Skip to content

Commit 950d281

Browse files
authored
[RISCV] Add ISel patterns for Qualcomm uC Xqcicm extension (#145643)
Add codegen patterns for the conditional move instructions in this extension
1 parent bc90166 commit 950d281

File tree

4 files changed

+907
-1
lines changed

4 files changed

+907
-1
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
436436
setOperationAction(ISD::ABS, MVT::i32, Custom);
437437
}
438438

439-
if (!Subtarget.useCCMovInsn() && !Subtarget.hasVendorXTHeadCondMov())
439+
if (!Subtarget.useCCMovInsn() && !Subtarget.hasVendorXTHeadCondMov() &&
440+
!Subtarget.hasVendorXqcicm())
440441
setOperationAction(ISD::SELECT, XLenVT, Custom);
441442

442443
if (Subtarget.hasVendorXqcia() && !Subtarget.is64Bit()) {

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,14 @@ class QCScaledStPat<PatFrag StoreOp, RVInst Inst>
13041304
: Pat<(StoreOp (i32 GPR:$rd), (AddrRegRegScale7 (i32 GPRMem:$rs1), (i32 GPRNoX0:$rs2), uimm3:$shamt)),
13051305
(Inst GPR:$rd, GPRMem:$rs1, GPRNoX0:$rs2, uimm3:$shamt)>;
13061306

1307+
class QCIMVCCPat<CondCode Cond, QCIMVCC Inst>
1308+
: Pat<(select (XLenVT (setcc (XLenVT GPRNoX0:$rs1), (XLenVT GPRNoX0:$rs2), Cond)), (XLenVT GPRNoX0:$rs3), (XLenVT GPRNoX0:$rd)),
1309+
(Inst GPRNoX0:$rd, GPRNoX0:$rs1, GPRNoX0:$rs2, GPRNoX0:$rs3)>;
1310+
1311+
class QCIMVCCIPat<CondCode Cond, QCIMVCCI Inst>
1312+
: Pat<(select (XLenVT (setcc (XLenVT GPRNoX0:$rs1), simm5:$imm, Cond)), (XLenVT GPRNoX0:$rs3), (XLenVT GPRNoX0:$rd)),
1313+
(Inst GPRNoX0:$rd, GPRNoX0:$rs1, simm5:$imm, GPRNoX0:$rs3)>;
1314+
13071315
// Match `riscv_brcc` and lower to the appropriate XQCIBI branch instruction.
13081316
class BcciPat<CondCode Cond, QCIBranchInst_rii Inst, DAGOperand InTyImm>
13091317
: Pat<(riscv_brcc (XLenVT GPRNoX0:$rs1), InTyImm:$rs2, Cond, bb:$imm12),
@@ -1438,6 +1446,20 @@ def: Pat<(i32 (ctlz (not (i32 GPR:$rs1)))), (QC_CLO GPR:$rs1)>;
14381446
let Predicates = [HasVendorXqciint, IsRV32] in
14391447
def : Pat<(riscv_mileaveret_glue), (QC_C_MILEAVERET)>;
14401448

1449+
let Predicates = [HasVendorXqcicm, IsRV32] in {
1450+
def : Pat<(select (XLenVT GPRNoX0:$rs1), (XLenVT GPRNoX0:$rd),(XLenVT GPRNoX0:$rs3)),
1451+
(QC_MVEQI GPRNoX0:$rd, GPRNoX0:$rs1, (XLenVT 0), GPRNoX0:$rs3)>;
1452+
1453+
def : QCIMVCCPat <SETEQ, QC_MVEQ>;
1454+
def : QCIMVCCPat <SETNE, QC_MVNE>;
1455+
def : QCIMVCCPat <SETLT, QC_MVLT>;
1456+
def : QCIMVCCPat <SETULT, QC_MVLTU>;
1457+
1458+
def : QCIMVCCIPat <SETEQ, QC_MVEQI>;
1459+
def : QCIMVCCIPat <SETNE, QC_MVNEI>;
1460+
def : QCIMVCCIPat <SETLT, QC_MVLTI>;
1461+
def : QCIMVCCIPat <SETULT, QC_MVLTUI>;
1462+
}
14411463

14421464
//===----------------------------------------------------------------------===/i
14431465
// Compress Instruction tablegen backend.

0 commit comments

Comments
 (0)