@@ -161,6 +161,11 @@ class UImmAsmOperand<int width, string suffix = "">
161161 : ImmAsmOperand<"U", width, suffix> {
162162}
163163
164+ class BareSImmNLsb0AsmOperand<int width>
165+ : ImmAsmOperand<"BareS", width, "Lsb0"> {
166+ let PredicateMethod = "isBareSimmNLsb0<" # width # ">";
167+ }
168+
164169class RISCVOp<ValueType vt = XLenVT> : Operand<vt> {
165170 let OperandNamespace = "RISCVOp";
166171}
@@ -271,8 +276,8 @@ def simm12_no6 : ImmLeaf<XLenVT, [{
271276 return isInt<12>(Imm) && !isInt<6>(Imm) && isInt<12>(-Imm);}]>;
272277
273278// A 13-bit signed immediate where the least significant bit is zero.
274- def simm13_lsb0 : Operand<OtherVT> {
275- let ParserMatchClass = SImmAsmOperand <13, "Lsb0" >;
279+ def bare_simm13_lsb0 : Operand<OtherVT> {
280+ let ParserMatchClass = BareSImmNLsb0AsmOperand <13>;
276281 let PrintMethod = "printBranchOperand";
277282 let EncoderMethod = "getImmOpValueAsr1";
278283 let DecoderMethod = "decodeSImmOperandAndLsl1<13>";
@@ -303,7 +308,7 @@ def uimm20_auipc : UImm20OperandMaybeSym {
303308
304309def uimm20 : RISCVUImmOp<20>;
305310
306- def Simm21Lsb0JALAsmOperand : SImmAsmOperand <21, "Lsb0JAL" > {
311+ def Simm21Lsb0JALAsmOperand : BareSImmNLsb0AsmOperand <21> {
307312 let ParserMethod = "parseJALOffset";
308313}
309314
@@ -527,7 +532,7 @@ include "RISCVInstrFormatsV.td"
527532
528533class BranchCC_rri<bits<3> funct3, string opcodestr>
529534 : RVInstB<funct3, OPC_BRANCH, (outs),
530- (ins GPR:$rs1, GPR:$rs2, simm13_lsb0 :$imm12),
535+ (ins GPR:$rs1, GPR:$rs2, bare_simm13_lsb0 :$imm12),
531536 opcodestr, "$rs1, $rs2, $imm12">,
532537 Sched<[WriteJmp, ReadJmp, ReadJmp]> {
533538 let isBranch = 1;
@@ -959,30 +964,30 @@ def : InstAlias<"sgt $rd, $rs, $rt", (SLT GPR:$rd, GPR:$rt, GPR:$rs), 0>;
959964def : InstAlias<"sgtu $rd, $rs, $rt", (SLTU GPR:$rd, GPR:$rt, GPR:$rs), 0>;
960965
961966def : InstAlias<"beqz $rs, $offset",
962- (BEQ GPR:$rs, X0, simm13_lsb0 :$offset)>;
967+ (BEQ GPR:$rs, X0, bare_simm13_lsb0 :$offset)>;
963968def : InstAlias<"bnez $rs, $offset",
964- (BNE GPR:$rs, X0, simm13_lsb0 :$offset)>;
969+ (BNE GPR:$rs, X0, bare_simm13_lsb0 :$offset)>;
965970def : InstAlias<"blez $rs, $offset",
966- (BGE X0, GPR:$rs, simm13_lsb0 :$offset)>;
971+ (BGE X0, GPR:$rs, bare_simm13_lsb0 :$offset)>;
967972def : InstAlias<"bgez $rs, $offset",
968- (BGE GPR:$rs, X0, simm13_lsb0 :$offset)>;
973+ (BGE GPR:$rs, X0, bare_simm13_lsb0 :$offset)>;
969974def : InstAlias<"bltz $rs, $offset",
970- (BLT GPR:$rs, X0, simm13_lsb0 :$offset)>;
975+ (BLT GPR:$rs, X0, bare_simm13_lsb0 :$offset)>;
971976def : InstAlias<"bgtz $rs, $offset",
972- (BLT X0, GPR:$rs, simm13_lsb0 :$offset)>;
977+ (BLT X0, GPR:$rs, bare_simm13_lsb0 :$offset)>;
973978
974979// Always output the canonical mnemonic for the pseudo branch instructions.
975980// The GNU tools emit the canonical mnemonic for the branch pseudo instructions
976981// as well (e.g. "bgt" will be recognised by the assembler but never printed by
977982// objdump). Match this behaviour by setting a zero weight.
978983def : InstAlias<"bgt $rs, $rt, $offset",
979- (BLT GPR:$rt, GPR:$rs, simm13_lsb0 :$offset), 0>;
984+ (BLT GPR:$rt, GPR:$rs, bare_simm13_lsb0 :$offset), 0>;
980985def : InstAlias<"ble $rs, $rt, $offset",
981- (BGE GPR:$rt, GPR:$rs, simm13_lsb0 :$offset), 0>;
986+ (BGE GPR:$rt, GPR:$rs, bare_simm13_lsb0 :$offset), 0>;
982987def : InstAlias<"bgtu $rs, $rt, $offset",
983- (BLTU GPR:$rt, GPR:$rs, simm13_lsb0 :$offset), 0>;
988+ (BLTU GPR:$rt, GPR:$rs, bare_simm13_lsb0 :$offset), 0>;
984989def : InstAlias<"bleu $rs, $rt, $offset",
985- (BGEU GPR:$rt, GPR:$rs, simm13_lsb0 :$offset), 0>;
990+ (BGEU GPR:$rt, GPR:$rs, bare_simm13_lsb0 :$offset), 0>;
986991
987992def : InstAlias<"j $offset", (JAL X0, simm21_lsb0_jal:$offset)>;
988993def : InstAlias<"jal $offset", (JAL X1, simm21_lsb0_jal:$offset)>;
@@ -1162,7 +1167,7 @@ def InsnI_Mem : DirectiveInsnI<(outs AnyReg:$rd), (ins uimm7_opcode:$opcode,
11621167 "$opcode, $funct3, $rd, ${imm12}(${rs1})">;
11631168def InsnB : DirectiveInsnB<(outs), (ins uimm7_opcode:$opcode, uimm3:$funct3,
11641169 AnyReg:$rs1, AnyReg:$rs2,
1165- simm13_lsb0 :$imm12),
1170+ bare_simm13_lsb0 :$imm12),
11661171 "$opcode, $funct3, $rs1, $rs2, $imm12">;
11671172def InsnU : DirectiveInsnU<(outs AnyReg:$rd), (ins uimm7_opcode:$opcode,
11681173 uimm20_lui:$imm20),
@@ -1218,11 +1223,11 @@ def : InstAlias<".insn_i $opcode, $funct3, $rd, (${rs1})",
12181223 AnyReg:$rs1, 0)>;
12191224def : InstAlias<".insn_b $opcode, $funct3, $rs1, $rs2, $imm12",
12201225 (InsnB uimm7_opcode:$opcode, uimm3:$funct3, AnyReg:$rs1,
1221- AnyReg:$rs2, simm13_lsb0 :$imm12)>;
1226+ AnyReg:$rs2, bare_simm13_lsb0 :$imm12)>;
12221227// Accept sb as an alias for b.
12231228def : InstAlias<".insn_sb $opcode, $funct3, $rs1, $rs2, $imm12",
12241229 (InsnB uimm7_opcode:$opcode, uimm3:$funct3, AnyReg:$rs1,
1225- AnyReg:$rs2, simm13_lsb0 :$imm12)>;
1230+ AnyReg:$rs2, bare_simm13_lsb0 :$imm12)>;
12261231def : InstAlias<".insn_u $opcode, $rd, $imm20",
12271232 (InsnU AnyReg:$rd, uimm7_opcode:$opcode, uimm20_lui:$imm20)>;
12281233def : InstAlias<".insn_j $opcode, $rd, $imm20",
@@ -1568,10 +1573,10 @@ let Predicates = [HasStdExtC, OptForMinSize] in {
15681573// Match `riscv_brcc` and lower to the appropriate RISC-V branch instruction.
15691574multiclass BccPat<CondCode Cond, RVInstB Inst> {
15701575 def : Pat<(riscv_brcc (XLenVT GPR:$rs1), GPR:$rs2, Cond, bb:$imm12),
1571- (Inst GPR:$rs1, GPR:$rs2, simm13_lsb0 :$imm12)>;
1576+ (Inst GPR:$rs1, GPR:$rs2, bare_simm13_lsb0 :$imm12)>;
15721577 // Explicitly select 0 to X0. The register coalescer doesn't always do it.
15731578 def : Pat<(riscv_brcc (XLenVT GPR:$rs1), 0, Cond, bb:$imm12),
1574- (Inst GPR:$rs1, (XLenVT X0), simm13_lsb0 :$imm12)>;
1579+ (Inst GPR:$rs1, (XLenVT X0), bare_simm13_lsb0 :$imm12)>;
15751580}
15761581
15771582class BrccCompressOpt<CondCode Cond, RVInstB Inst>
0 commit comments