[PATCH] D98674: [NFC] [PowerPC] Determine Endianness in PPCTargetMachine
Nemanja Ivanovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 19 18:22:43 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG697f90ebfa7c: [NFC] [PowerPC] Determine Endianness in PPCTargetMachine (authored by gandhi21299, committed by nemanjai).
Changed prior to commit:
https://reviews.llvm.org/D98674?vs=330875&id=332049#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98674/new/
https://reviews.llvm.org/D98674
Files:
llvm/lib/Target/PowerPC/PPCSubtarget.cpp
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
llvm/lib/Target/PowerPC/PPCTargetMachine.h
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.h
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetMachine.h
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.h
@@ -25,9 +25,12 @@
class PPCTargetMachine final : public LLVMTargetMachine {
public:
enum PPCABI { PPC_ABI_UNKNOWN, PPC_ABI_ELFv1, PPC_ABI_ELFv2 };
+ enum Endian { NOT_DETECTED, LITTLE, BIG };
+
private:
std::unique_ptr<TargetLoweringObjectFile> TLOF;
PPCABI TargetABI;
+ Endian Endianness = Endian::NOT_DETECTED;
mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
@@ -63,6 +66,8 @@
// Addrspacecasts are always noops.
return true;
}
+
+ bool isLittleEndian() const;
};
} // end namespace llvm
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -126,13 +126,17 @@
initializeGlobalISel(PR);
}
+static bool isLittleEndianTriple(const Triple &T) {
+ return T.getArch() == Triple::ppc64le || T.getArch() == Triple::ppcle;
+}
+
/// Return the datalayout string of a subtarget.
static std::string getDataLayoutString(const Triple &T) {
bool is64Bit = T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le;
std::string Ret;
// Most PPC* platforms are big endian, PPC(64)LE is little endian.
- if (T.getArch() == Triple::ppc64le || T.getArch() == Triple::ppcle)
+ if (isLittleEndianTriple(T))
Ret = "e";
else
Ret = "E";
@@ -317,7 +321,8 @@
getEffectiveRelocModel(TT, RM),
getEffectivePPCCodeModel(TT, CM, JIT), OL),
TLOF(createTLOF(getTargetTriple())),
- TargetABI(computeTargetABI(TT, Options)) {
+ TargetABI(computeTargetABI(TT, Options)),
+ Endianness(isLittleEndianTriple(TT) ? Endian::LITTLE : Endian::BIG) {
initAsmInfo();
}
@@ -540,6 +545,12 @@
return TargetTransformInfo(PPCTTIImpl(this, F));
}
+bool PPCTargetMachine::isLittleEndian() const {
+ assert(Endianness != Endian::NOT_DETECTED &&
+ "Unable to determine endianness");
+ return Endianness == Endian::LITTLE;
+}
+
static MachineSchedRegistry
PPCPreRASchedRegistry("ppc-prera",
"Run PowerPC PreRA specific scheduler",
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -182,9 +182,7 @@
StackAlignment = getPlatformStackAlignment();
// Determine endianness.
- // FIXME: Part of the TargetMachine.
- IsLittleEndian = (TargetTriple.getArch() == Triple::ppc64le ||
- TargetTriple.getArch() == Triple::ppcle);
+ IsLittleEndian = TM.isLittleEndian();
}
bool PPCSubtarget::enableMachineScheduler() const { return true; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98674.332049.patch
Type: text/x-patch
Size: 2959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210320/b70b6aca/attachment.bin>
More information about the llvm-commits
mailing list