Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
fix: import some SelectionDAG patterns into GlobalISel
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgillett committed Apr 2, 2023
1 parent c5f9c75 commit 186301f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 13 additions & 2 deletions llvm/lib/Target/Delendum/DelendumInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MemOpEncoding<string opname> {
}

// Node immediate fits as 32-bit sign extended on target immediate.
def ImmSExt32 : PatLeaf<(imm), [{ return isInt<32>(N->getSExtValue()); }]>;
def ImmSExt32 : ImmLeaf<i32, [{ return isInt<32>(Imm); }]>;

//===----------------------------------------------------------------------===//
// Patterns
Expand Down Expand Up @@ -74,7 +74,7 @@ class ALU_rr<bits<32> op, string opcodestr, SDNode OpNode>
}

class ALU_ri<bits<32> op, string opcodestr, SDNode OpNode,
Operand Od, PatLeaf imm_type>
Operand Od, ImmLeaf imm_type>
: DInst<op, (outs I32:$rd), (ins MemOp:$rs1, Od:$imm32),
!strconcat(opcodestr, "\t$rd, $rs1, $imm32"),
[(set I32:$rd, (OpNode addr:$rs1, imm_type:$imm32))]> {
Expand Down Expand Up @@ -136,3 +136,14 @@ def ADJCALLSTACKUP : DPseudoInst<8, (outs), (ins ImmOp32:$amt1, ImmOp32:$amt2)
"# ADJCALLSTACKUP $amt1",
[(callseq_end timm:$amt1, timm:$amt2)]>;

//===----------------------------------------------------------------------===//
// GlobalISel mapping
//===----------------------------------------------------------------------===//

// Map custom ISD nodes (FIXME: not currently matching gMIR "RET" instruction)
def G_RET : DPseudoInst<9, (outs), (ins), "ret", []>;
def : GINodeEquiv<G_RET, DLretflag>;

// Map complex patterns
def g_addr : GIComplexOperandMatcher<s32, "selectAddr">,
GIComplexPatternEquiv<addr>;
15 changes: 11 additions & 4 deletions llvm/lib/Target/Delendum/GISel/DelendumInstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ namespace {

class DelendumInstructionSelector : public InstructionSelector {
public:
DelendumInstructionSelector(const DelendumTargetMachine &TM, const DelendumSubtarget &STI,
const DelendumRegisterBankInfo &RBI);
DelendumInstructionSelector(const DelendumTargetMachine &TM,
const DelendumSubtarget &STI,
const DelendumRegisterBankInfo &RBI);

bool select(MachineInstr &I) override;
static const char *getName() { return DEBUG_TYPE; }

InstructionSelector::ComplexRendererFns selectAddr(MachineOperand &Root) const;

private:
bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;

Expand Down Expand Up @@ -79,12 +82,16 @@ bool DelendumInstructionSelector::select(MachineInstr &I) {

return false;
}
InstructionSelector::ComplexRendererFns
DelendumInstructionSelector::selectAddr(MachineOperand &Root) const {
// TODO
}

namespace llvm {
InstructionSelector *
createDelendumInstructionSelector(const DelendumTargetMachine &TM,
const DelendumSubtarget &Subtarget,
const DelendumRegisterBankInfo &RBI) {
const DelendumSubtarget &Subtarget,
const DelendumRegisterBankInfo &RBI) {
return new DelendumInstructionSelector(TM, Subtarget, RBI);
}
} // end namespace llvm

0 comments on commit 186301f

Please sign in to comment.