[llvm] [RISCV] Add compress patterns for Xqcibi branch instructions (PR #143095)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 12:07:49 PDT 2025
================
@@ -341,21 +341,33 @@ def simm12 : RISCVSImmLeafOp<12> {
def simm12_no6 : ImmLeaf<XLenVT, [{
return isInt<12>(Imm) && !isInt<6>(Imm) && isInt<12>(-Imm);}]>;
-// A 13-bit signed immediate where the least significant bit is zero.
-def bare_simm13_lsb0 : Operand<OtherVT> {
- let ParserMatchClass = BareSImmNLsb0AsmOperand<13>;
- let PrintMethod = "printBranchOperand";
- let EncoderMethod = "getImmOpValueAsrN<1>";
- let DecoderMethod = "decodeSImmOperandAndLslN<13, 1>";
+class BareSImm13Lsb0MaybeSym : Operand<OtherVT> {
let MCOperandPredicate = [{
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isShiftedInt<12, 1>(Imm);
return MCOp.isBareSymbolRef();
}];
+}
+
+// A 13-bit signed immediate where the least significant bit is zero. The ImmLeaf
+// is needed so that the CompressInstEmitter can correctly add checks for the
+// compress patterns that involve instructions that use this operand. Similar to
+// bare_simm9_lsb0 in RISCVInstrINfoC.td.
+def bare_simm13_lsb0 : BareSImm13Lsb0MaybeSym,
+ ImmLeaf<XLenVT, [{return isShiftedInt<12, 1>(Imm);}]> {
+ let ParserMatchClass = BareSImmNLsb0AsmOperand<13>;
+ let PrintMethod = "printBranchOperand";
+ let EncoderMethod = "getImmOpValueAsrN<1>";
+ let DecoderMethod = "decodeSImmOperandAndLslN<13, 1>";
let OperandType = "OPERAND_PCREL";
}
+// We need this (sort of) duplicate defintion since adding ImmLeaf to
+// bare_simm13_lsb0 above makes it not sit well with patterns where it is used to
+// match with a basic block (eg. BccPat<>).
----------------
lenary wrote:
```suggestion
// We need this (sort of) duplicate definition since adding ImmLeaf to
// bare_simm13_lsb0 above makes it not sit well with codegen patterns where it is used to
// match with a basic block (eg. BccPat<>).
```
https://github.com/llvm/llvm-project/pull/143095
More information about the llvm-commits
mailing list