-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV][MC] Add support for experimental Zcmop extension #76395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===-- RISCVInstrInfoZcmop.td -----------------------------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file describes the RISC-V instructions from the standard Compressed | ||
// May-Be-Operations Extension (Zcmop). | ||
// This version is still experimental as the 'Zcmop' extension hasn't been | ||
// ratified yet. It is based on v0.2 of the specification. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in | ||
class CMOPInst<bits<3> imm3, string opcodestr> | ||
: RVInst16CI<0b011, 0b01, (outs), (ins), opcodestr, ""> { | ||
let Inst{6-2} = 0; | ||
let Inst{7} = 1; | ||
let Inst{10-8} = imm3; | ||
let Inst{12-11} = 0; | ||
} | ||
|
||
foreach i = 0...7 in { | ||
let Predicates = [HasStdExtZcmop] in { | ||
defvar n = !add(!mul(i, 2), 1); | ||
def CMOP # n : CMOPInst<i, "cmop." # n>, Sched<[]>; | ||
} // Predicates = [HasStdExtZcmop] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zcmop < %s 2>&1 | FileCheck %s | ||
|
||
cmop.0 # CHECK: :[[@LINE]]:1: error: unrecognized instruction mnemonic | ||
|
||
cmop.1 t0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction | ||
|
||
cmop.1 0x0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zcmop -show-encoding \ | ||
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zcmop -show-encoding \ | ||
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zcmop < %s \ | ||
# RUN: | llvm-objdump --mattr=+experimental-zcmop -d -r - \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zcmop < %s \ | ||
# RUN: | llvm-objdump --mattr=+experimental-zcmop -d -r - \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.1 | ||
# CHECK-ASM: encoding: [0x81,0x60] | ||
cmop.1 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.3 | ||
# CHECK-ASM: encoding: [0x81,0x61] | ||
cmop.3 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.5 | ||
# CHECK-ASM: encoding: [0x81,0x62] | ||
cmop.5 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.7 | ||
# CHECK-ASM: encoding: [0x81,0x63] | ||
cmop.7 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.9 | ||
# CHECK-ASM: encoding: [0x81,0x64] | ||
cmop.9 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.11 | ||
# CHECK-ASM: encoding: [0x81,0x65] | ||
cmop.11 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.13 | ||
# CHECK-ASM: encoding: [0x81,0x66] | ||
cmop.13 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.15 | ||
# CHECK-ASM: encoding: [0x81,0x67] | ||
cmop.15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec says Zcmop requires Zca. Is this means Zcmop imply Zca? I am not sure with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. The specs have been very inconsistent on terminology. The fundamental issue is that the specs define hardware and don't think about how
-march
in tools works. What the spec is saying is that if your hardware supports Zcmop, it must support Zca.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding for those terminology on RISC-V ISA spec is: imply == depend == require
See comment from Krste and Andrew in this issue: riscvarchive/riscv-v-spec#723 (comment)