Skip to content

Commit

Permalink
[BPF] use target triple for pattern predicates (llvm#74998)
Browse files Browse the repository at this point in the history
This is used for eliminate uses of "CurDAG", which is SelectionDAG-spec,
and not compatible with GIsel algorithms.

(NFC)
  • Loading branch information
inclyc authored Dec 11, 2023
1 parent 99430c5 commit 75193b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/BPF/BPFInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def BPFWrapper : SDNode<"BPFISD::Wrapper", SDT_BPFWrapper>;
def BPFmemcpy : SDNode<"BPFISD::MEMCPY", SDT_BPFMEMCPY,
[SDNPHasChain, SDNPInGlue, SDNPOutGlue,
SDNPMayStore, SDNPMayLoad]>;
def BPFIsLittleEndian : Predicate<"CurDAG->getDataLayout().isLittleEndian()">;
def BPFIsBigEndian : Predicate<"!CurDAG->getDataLayout().isLittleEndian()">;
def BPFIsLittleEndian : Predicate<"Subtarget->isLittleEndian()">;
def BPFIsBigEndian : Predicate<"!Subtarget->isLittleEndian()">;
def BPFHasALU32 : Predicate<"Subtarget->getHasAlu32()">;
def BPFNoALU32 : Predicate<"!Subtarget->getHasAlu32()">;
def BPFHasLdsx : Predicate<"Subtarget->hasLdsx()">;
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Target/BPF/BPFSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU,
const std::string &FS, const TargetMachine &TM)
: BPFGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
FrameLowering(initializeSubtargetDependencies(CPU, FS)),
TLInfo(TM, *this) {}
TLInfo(TM, *this) {
IsLittleEndian = TT.isLittleEndian();
}
4 changes: 4 additions & 0 deletions llvm/lib/Target/BPF/BPFSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class BPFSubtarget : public BPFGenSubtargetInfo {
// unused
bool isDummyMode;

bool IsLittleEndian;

// whether the cpu supports jmp ext
bool HasJmpExt;

Expand Down Expand Up @@ -81,6 +83,8 @@ class BPFSubtarget : public BPFGenSubtargetInfo {
bool hasGotol() const { return HasGotol; }
bool hasStoreImm() const { return HasStoreImm; }

bool isLittleEndian() const { return IsLittleEndian; }

const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; }
const BPFFrameLowering *getFrameLowering() const override {
return &FrameLowering;
Expand Down

0 comments on commit 75193b1

Please sign in to comment.