From 75193b192ad92e69236930dc35c262786a95f472 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Mon, 11 Dec 2023 17:10:39 +0800 Subject: [PATCH] [BPF] use target triple for pattern predicates (#74998) This is used for eliminate uses of "CurDAG", which is SelectionDAG-spec, and not compatible with GIsel algorithms. (NFC) --- llvm/lib/Target/BPF/BPFInstrInfo.td | 4 ++-- llvm/lib/Target/BPF/BPFSubtarget.cpp | 4 +++- llvm/lib/Target/BPF/BPFSubtarget.h | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/BPF/BPFInstrInfo.td b/llvm/lib/Target/BPF/BPFInstrInfo.td index 5972c9d49c5151..7d443a34490146 100644 --- a/llvm/lib/Target/BPF/BPFInstrInfo.td +++ b/llvm/lib/Target/BPF/BPFInstrInfo.td @@ -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()">; diff --git a/llvm/lib/Target/BPF/BPFSubtarget.cpp b/llvm/lib/Target/BPF/BPFSubtarget.cpp index ce02c831828e4d..5e79142ea9e1c8 100644 --- a/llvm/lib/Target/BPF/BPFSubtarget.cpp +++ b/llvm/lib/Target/BPF/BPFSubtarget.cpp @@ -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(); +} diff --git a/llvm/lib/Target/BPF/BPFSubtarget.h b/llvm/lib/Target/BPF/BPFSubtarget.h index 6e81daa4d955e0..a55ae618f4d1d3 100644 --- a/llvm/lib/Target/BPF/BPFSubtarget.h +++ b/llvm/lib/Target/BPF/BPFSubtarget.h @@ -43,6 +43,8 @@ class BPFSubtarget : public BPFGenSubtargetInfo { // unused bool isDummyMode; + bool IsLittleEndian; + // whether the cpu supports jmp ext bool HasJmpExt; @@ -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;