Skip to content

Commit 1d7c460

Browse files
authored
[RISCV] Set isTrap for EBREAK and {C_,}UNIMP (#131636)
This is done for completeness. The property isn't used in upstream llvm/, although it is queried in BOLT in MCPlusBuilder.cpp.
1 parent e7c6e35 commit 1d7c460

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ def ECALL : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ecall", "">, Sched<[Write
752752
let imm12 = 0;
753753
}
754754

755+
let isTrap = 1 in
755756
def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
756757
Sched<[]> {
757758
let rs1 = 0;
@@ -762,6 +763,7 @@ def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
762763
// This is a de facto standard (as set by GNU binutils) 32-bit unimplemented
763764
// instruction (i.e., it should always trap, if your implementation has invalid
764765
// instruction traps).
766+
let isTrap = 1 in
765767
def UNIMP : RVInstI<0b001, OPC_SYSTEM, (outs), (ins), "unimp", "">,
766768
Sched<[]> {
767769
let rs1 = 0;

llvm/lib/Target/RISCV/RISCVInstrInfoC.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def C_SDSP : CStackStore<0b111, "c.sdsp", GPR, uimm9_lsb000>,
596596

597597
// The all zeros pattern isn't a valid RISC-V instruction. It's used by GNU
598598
// binutils as 16-bit instruction known to be unimplemented (i.e., trapping).
599-
let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
599+
let hasSideEffects = 1, mayLoad = 0, mayStore = 0, isTrap = 1 in
600600
def C_UNIMP : RVInst16<(outs), (ins), "c.unimp", "", [], InstFormatOther>,
601601
Sched<[]> {
602602
let Inst{15-0} = 0;

0 commit comments

Comments
 (0)