diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td index 87e1f2fdc9c8d..1f530b500d04e 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -263,6 +263,10 @@ def simm12 : RISCVSImmLeafOp<12> { int64_t Imm; if (MCOp.evaluateAsConstantImm(Imm)) return isInt<12>(Imm); + // Needed to make CHERIOT mnemonic aliases work. + if (STI.hasFeature(RISCV::FeatureVendorXCheriot) && + MCOp.isExpr()) + return true; return MCOp.isBareSymbolRef(); }]; } @@ -292,6 +296,10 @@ class UImm20OperandMaybeSym : RISCVUImmOp<20> { int64_t Imm; if (MCOp.evaluateAsConstantImm(Imm)) return isUInt<20>(Imm); + // Needed to make CHERIOT mnemonic aliases work. + if (STI.hasFeature(RISCV::FeatureVendorXCheriot) && + MCOp.isExpr()) + return true; return MCOp.isBareSymbolRef(); }]; } diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXCheri.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXCheri.td index dc1524716a230..587bebdf55fac 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoXCheri.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXCheri.td @@ -2056,9 +2056,8 @@ def PseudoCTAIL : Pseudo<(outs), (ins cap_call_symbol:$dst), []> { let AsmString = "ctail\t$dst"; } -let Predicates = [HasCheriot] in def : InstAlias< - "ct.ctail $dst", - (PseudoCTAIL cap_call_symbol:$dst)>; +let Predicates = [HasCheriot] in +def : InstAlias<"ct.ctail $dst", (PseudoCTAIL cap_call_symbol:$dst)>; let Predicates = [HasCheri, IsCapMode, IsPureCapABI], isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [C2] in diff --git a/llvm/test/MC/RISCV/cheri/cheriot-only.s b/llvm/test/MC/RISCV/cheri/cheriot-only.s new file mode 100644 index 0000000000000..f3e2a3ce719ea --- /dev/null +++ b/llvm/test/MC/RISCV/cheri/cheriot-only.s @@ -0,0 +1,9 @@ +// NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py UTC_ARGS: --version 5 +// RUN: llvm-mc %s -triple=riscv32cheriot -mcpu=cheriot -mattr=+xcheri,+xcheriot | FileCheck %s -check-prefixes=CHERIOT + +foo: +// CHERIOT: foo: + auipcc ct3, %cheriot_compartment_hi(foo) +// CHERIOT: ct.auipcc ct3, %cheriot_compartment_hi(foo) + clc ct2, %cheriot_compartment_lo_i(foo)(ct2) +// CHERIOT: ct.clc ct2, %cheriot_compartment_lo_i(foo)(ct2) diff --git a/llvm/test/MC/RISCV/cheri/cheriot.s b/llvm/test/MC/RISCV/cheri/cheriot.s index f8c7f033f4539..c5a0dc6ee91a6 100644 --- a/llvm/test/MC/RISCV/cheri/cheriot.s +++ b/llvm/test/MC/RISCV/cheri/cheriot.s @@ -119,4 +119,4 @@ ctestsubset x7, ca5, ca3 // CHERI: ctestsubset t2, ca5, ca3 # encoding: [0xdb,0x83,0xd7,0x40] cunseal ca5, ca3, ca1 // CHERIOT: ct.cunseal ca5, ca3, ca1 # encoding: [0xdb,0x87,0xb6,0x18] -// CHERI: cunseal ca5, ca3, ca1 # encoding: [0xdb,0x87,0xb6,0x18] +// CHERI: cunseal ca5, ca3, ca1 # encoding: [0xdb,0x87,0xb6,0x18] \ No newline at end of file