@@ -418,6 +418,8 @@ def NegImm : SDNodeXForm<imm, [{
418418 return CurDAG->getSignedTargetConstant(-N->getSExtValue(), SDLoc(N),
419419 N->getValueType(0));
420420}]>;
421+ def GINegImm : GICustomOperandRenderer<"renderNegImm">,
422+ GISDNodeXFormEquiv<NegImm>;
421423
422424// Return an immediate value minus 32.
423425def ImmSub32 : SDNodeXForm<imm, [{
@@ -431,12 +433,16 @@ def ImmSubFromXLen : SDNodeXForm<imm, [{
431433 return CurDAG->getTargetConstant(XLen - N->getZExtValue(), SDLoc(N),
432434 N->getValueType(0));
433435}]>;
436+ def GIImmSubFromXLen : GICustomOperandRenderer<"renderImmSubFromXLen">,
437+ GISDNodeXFormEquiv<ImmSubFromXLen>;
434438
435439// Return an immediate subtracted from 32.
436440def ImmSubFrom32 : SDNodeXForm<imm, [{
437441 return CurDAG->getTargetConstant(32 - N->getZExtValue(), SDLoc(N),
438442 N->getValueType(0));
439443}]>;
444+ def GIImmSubFrom32 : GICustomOperandRenderer<"renderImmSubFrom32">,
445+ GISDNodeXFormEquiv<ImmSubFrom32>;
440446
441447// Check if (add r, imm) can be optimized to (ADDI (ADDI r, imm0), imm1),
442448// in which imm = imm0 + imm1 and both imm0 and imm1 are simm12. We make imm0
@@ -469,6 +475,8 @@ def TrailingZeros : SDNodeXForm<imm, [{
469475 return CurDAG->getTargetConstant(llvm::countr_zero(N->getZExtValue()),
470476 SDLoc(N), N->getValueType(0));
471477}]>;
478+ def GITrailingZeros : GICustomOperandRenderer<"renderTrailingZeros">,
479+ GISDNodeXFormEquiv<TrailingZeros>;
472480
473481def XLenSubTrailingOnes : SDNodeXForm<imm, [{
474482 uint64_t XLen = Subtarget->getXLen();
@@ -1267,13 +1275,26 @@ def assertsexti32 : PatFrag<(ops node:$src), (assertsext node:$src), [{
12671275 return cast<VTSDNode>(N->getOperand(1))->getVT().bitsLE(MVT::i32);
12681276}]>;
12691277def sexti16 : ComplexPattern<XLenVT, 1, "selectSExtBits<16>">;
1278+
12701279def sexti32 : ComplexPattern<i64, 1, "selectSExtBits<32>">;
1280+ def gi_sexti32 : GIComplexOperandMatcher<s64, "selectSExtBits<32>">,
1281+ GIComplexPatternEquiv<sexti32>;
1282+
12711283def assertzexti32 : PatFrag<(ops node:$src), (assertzext node:$src), [{
12721284 return cast<VTSDNode>(N->getOperand(1))->getVT().bitsLE(MVT::i32);
12731285}]>;
1286+
12741287def zexti32 : ComplexPattern<i64, 1, "selectZExtBits<32>">;
1288+ def gi_zexti32 : GIComplexOperandMatcher<s64, "selectZExtBits<32>">,
1289+ GIComplexPatternEquiv<zexti32>;
1290+
12751291def zexti16 : ComplexPattern<XLenVT, 1, "selectZExtBits<16>">;
1292+ def gi_zexti16 : GIComplexOperandMatcher<s32, "selectZExtBits<16>">,
1293+ GIComplexPatternEquiv<zexti16>;
1294+
12761295def zexti8 : ComplexPattern<XLenVT, 1, "selectZExtBits<8>">;
1296+ def gi_zexti8 : GIComplexOperandMatcher<s32, "selectZExtBits<8>">,
1297+ GIComplexPatternEquiv<zexti8>;
12771298
12781299def ext : PatFrags<(ops node:$A), [(sext node:$A), (zext node:$A)]>;
12791300
@@ -1357,6 +1378,17 @@ def : Pat<(XLenVT (and GPR:$rs, TrailingOnesMask:$mask)),
13571378// ISA only read the least significant 5 bits (RV32I) or 6 bits (RV64I).
13581379def shiftMaskXLen : ComplexPattern<XLenVT, 1, "selectShiftMaskXLen", [], [], 0>;
13591380def shiftMask32 : ComplexPattern<i64, 1, "selectShiftMask32", [], [], 0>;
1381+ // FIXME: This is labelled as handling 's32', however the ComplexPattern it
1382+ // refers to handles both i32 and i64 based on the HwMode. Currently this LLT
1383+ // parameter appears to be ignored so this pattern works for both, however we
1384+ // should add a LowLevelTypeByHwMode, and use that to define our XLenLLT instead
1385+ // here.
1386+ def GIShiftMaskXLen :
1387+ GIComplexOperandMatcher<s32, "selectShiftMaskXLen">,
1388+ GIComplexPatternEquiv<shiftMaskXLen>;
1389+ def GIShiftMask32 :
1390+ GIComplexOperandMatcher<s64, "selectShiftMask32">,
1391+ GIComplexPatternEquiv<shiftMask32>;
13601392
13611393class shiftop<SDPatternOperator operator>
13621394 : PatFrag<(ops node:$val, node:$count),
@@ -1382,6 +1414,9 @@ def PseudoAddTPRel : Pseudo<(outs GPR:$rd),
13821414
13831415def : Pat<(FrameAddrRegImm (iPTR GPR:$rs1), simm12:$imm12),
13841416 (ADDI GPR:$rs1, simm12:$imm12)>;
1417+ def GIAddrRegImm :
1418+ GIComplexOperandMatcher<s32, "selectAddrRegImm">,
1419+ GIComplexPatternEquiv<AddrRegImm>;
13851420
13861421/// Stack probing
13871422
0 commit comments