@@ -418,6 +418,8 @@ def NegImm : SDNodeXForm<imm, [{
418
418
return CurDAG->getSignedTargetConstant(-N->getSExtValue(), SDLoc(N),
419
419
N->getValueType(0));
420
420
}]>;
421
+ def GINegImm : GICustomOperandRenderer<"renderNegImm">,
422
+ GISDNodeXFormEquiv<NegImm>;
421
423
422
424
// Return an immediate value minus 32.
423
425
def ImmSub32 : SDNodeXForm<imm, [{
@@ -431,12 +433,16 @@ def ImmSubFromXLen : SDNodeXForm<imm, [{
431
433
return CurDAG->getTargetConstant(XLen - N->getZExtValue(), SDLoc(N),
432
434
N->getValueType(0));
433
435
}]>;
436
+ def GIImmSubFromXLen : GICustomOperandRenderer<"renderImmSubFromXLen">,
437
+ GISDNodeXFormEquiv<ImmSubFromXLen>;
434
438
435
439
// Return an immediate subtracted from 32.
436
440
def ImmSubFrom32 : SDNodeXForm<imm, [{
437
441
return CurDAG->getTargetConstant(32 - N->getZExtValue(), SDLoc(N),
438
442
N->getValueType(0));
439
443
}]>;
444
+ def GIImmSubFrom32 : GICustomOperandRenderer<"renderImmSubFrom32">,
445
+ GISDNodeXFormEquiv<ImmSubFrom32>;
440
446
441
447
// Check if (add r, imm) can be optimized to (ADDI (ADDI r, imm0), imm1),
442
448
// in which imm = imm0 + imm1 and both imm0 and imm1 are simm12. We make imm0
@@ -469,6 +475,8 @@ def TrailingZeros : SDNodeXForm<imm, [{
469
475
return CurDAG->getTargetConstant(llvm::countr_zero(N->getZExtValue()),
470
476
SDLoc(N), N->getValueType(0));
471
477
}]>;
478
+ def GITrailingZeros : GICustomOperandRenderer<"renderTrailingZeros">,
479
+ GISDNodeXFormEquiv<TrailingZeros>;
472
480
473
481
def XLenSubTrailingOnes : SDNodeXForm<imm, [{
474
482
uint64_t XLen = Subtarget->getXLen();
@@ -1267,13 +1275,26 @@ def assertsexti32 : PatFrag<(ops node:$src), (assertsext node:$src), [{
1267
1275
return cast<VTSDNode>(N->getOperand(1))->getVT().bitsLE(MVT::i32);
1268
1276
}]>;
1269
1277
def sexti16 : ComplexPattern<XLenVT, 1, "selectSExtBits<16>">;
1278
+
1270
1279
def sexti32 : ComplexPattern<i64, 1, "selectSExtBits<32>">;
1280
+ def gi_sexti32 : GIComplexOperandMatcher<s64, "selectSExtBits<32>">,
1281
+ GIComplexPatternEquiv<sexti32>;
1282
+
1271
1283
def assertzexti32 : PatFrag<(ops node:$src), (assertzext node:$src), [{
1272
1284
return cast<VTSDNode>(N->getOperand(1))->getVT().bitsLE(MVT::i32);
1273
1285
}]>;
1286
+
1274
1287
def zexti32 : ComplexPattern<i64, 1, "selectZExtBits<32>">;
1288
+ def gi_zexti32 : GIComplexOperandMatcher<s64, "selectZExtBits<32>">,
1289
+ GIComplexPatternEquiv<zexti32>;
1290
+
1275
1291
def zexti16 : ComplexPattern<XLenVT, 1, "selectZExtBits<16>">;
1292
+ def gi_zexti16 : GIComplexOperandMatcher<s32, "selectZExtBits<16>">,
1293
+ GIComplexPatternEquiv<zexti16>;
1294
+
1276
1295
def zexti8 : ComplexPattern<XLenVT, 1, "selectZExtBits<8>">;
1296
+ def gi_zexti8 : GIComplexOperandMatcher<s32, "selectZExtBits<8>">,
1297
+ GIComplexPatternEquiv<zexti8>;
1277
1298
1278
1299
def ext : PatFrags<(ops node:$A), [(sext node:$A), (zext node:$A)]>;
1279
1300
@@ -1357,6 +1378,17 @@ def : Pat<(XLenVT (and GPR:$rs, TrailingOnesMask:$mask)),
1357
1378
// ISA only read the least significant 5 bits (RV32I) or 6 bits (RV64I).
1358
1379
def shiftMaskXLen : ComplexPattern<XLenVT, 1, "selectShiftMaskXLen", [], [], 0>;
1359
1380
def 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>;
1360
1392
1361
1393
class shiftop<SDPatternOperator operator>
1362
1394
: PatFrag<(ops node:$val, node:$count),
@@ -1382,6 +1414,9 @@ def PseudoAddTPRel : Pseudo<(outs GPR:$rd),
1382
1414
1383
1415
def : Pat<(FrameAddrRegImm (iPTR GPR:$rs1), simm12:$imm12),
1384
1416
(ADDI GPR:$rs1, simm12:$imm12)>;
1417
+ def GIAddrRegImm :
1418
+ GIComplexOperandMatcher<s32, "selectAddrRegImm">,
1419
+ GIComplexPatternEquiv<AddrRegImm>;
1385
1420
1386
1421
/// Stack probing
1387
1422
0 commit comments