|
18 | 18 | // Operand and SDNode transformation definitions. |
19 | 19 | //===----------------------------------------------------------------------===// |
20 | 20 |
|
21 | | -def simm10 : RISCVSImmLeafOp<10>; |
| 21 | +def simm10 : RISCVSImmOp<10>; |
| 22 | + |
| 23 | +def SImm8UnsignedAsmOperand : SImmAsmOperand<8, "Unsigned"> { |
| 24 | + let RenderMethod = "addSImm8UnsignedOperands"; |
| 25 | +} |
| 26 | + |
| 27 | +// A 8-bit signed immediate allowing range [-128, 255] |
| 28 | +// but represented as [-128, 127]. |
| 29 | +def simm8_unsigned : RISCVOp { |
| 30 | + let ParserMatchClass = SImm8UnsignedAsmOperand; |
| 31 | + let EncoderMethod = "getImmOpValue"; |
| 32 | + let DecoderMethod = "decodeSImmOperand<8>"; |
| 33 | + let OperandType = "OPERAND_SIMM10"; |
| 34 | + let MCOperandPredicate = [{ |
| 35 | + int64_t Imm; |
| 36 | + if (!MCOp.evaluateAsConstantImm(Imm)) |
| 37 | + return false; |
| 38 | + return isInt<8>(Imm); |
| 39 | + }]; |
| 40 | +} |
22 | 41 |
|
23 | 42 | def SImm10UnsignedAsmOperand : SImmAsmOperand<10, "Unsigned"> { |
24 | 43 | let RenderMethod = "addSImm10UnsignedOperands"; |
@@ -75,13 +94,13 @@ class PLUI_i<bits<7> funct7, string opcodestr> |
75 | 94 |
|
76 | 95 | let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in |
77 | 96 | class PLI_B_i<bits<8> funct8, string opcodestr> |
78 | | - : RVInst<(outs GPR:$rd), (ins uimm8:$uimm8), opcodestr, "$rd, $uimm8", [], |
79 | | - InstFormatOther> { |
80 | | - bits<8> uimm8; |
| 97 | + : RVInst<(outs GPR:$rd), (ins simm8_unsigned:$imm8), opcodestr, |
| 98 | + "$rd, $imm8", [], InstFormatOther> { |
| 99 | + bits<8> imm8; |
81 | 100 | bits<5> rd; |
82 | 101 |
|
83 | 102 | let Inst{31-24} = funct8; |
84 | | - let Inst{23-16} = uimm8; |
| 103 | + let Inst{23-16} = imm8; |
85 | 104 | let Inst{15} = 0b0; |
86 | 105 | let Inst{14-12} = 0b010; |
87 | 106 | let Inst{11-7} = rd; |
|
0 commit comments