[llvm] [BPF] use target triple for pattern predicates (PR #74998)
Yingchi Long via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 10 07:02:58 PST 2023
https://github.com/inclyc created https://github.com/llvm/llvm-project/pull/74998
This is used for eliminate uses of "CurDAG", which is SelectionDAG-spec, and not compatible with GIsel algorithms.
(NFC)
>From 75bf5ff5f57d8b9e1127b4cba86d372e22a8c04d Mon Sep 17 00:00:00 2001
From: Yingchi Long <i at lyc.dev>
Date: Sun, 10 Dec 2023 21:14:43 +0800
Subject: [PATCH] [BPF] use target triple for pattern predicates
This is used for eliminate uses of "CurDAG", which is
SelectionDAG-spec, and not compatible with GIsel algorithms.
---
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;
More information about the llvm-commits
mailing list