[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCSubtarget.cpp PPCSubtarget.h PPCTargetMachine.cpp PPCTargetMachine.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Jun 15 18:37:39 PDT 2006
Changes in directory llvm/lib/Target/PowerPC:
PPCSubtarget.cpp updated: 1.19 -> 1.20
PPCSubtarget.h updated: 1.13 -> 1.14
PPCTargetMachine.cpp updated: 1.91 -> 1.92
PPCTargetMachine.h updated: 1.21 -> 1.22
---
Log message:
First baby step towards ppc64 support. This adds a new -march=ppc64 backend
that is currently just like ppc32 :)
---
Diffs of the changes: (+88 -26)
PPCSubtarget.cpp | 2 -
PPCSubtarget.h | 6 ++++-
PPCTargetMachine.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++---------
PPCTargetMachine.h | 47 ++++++++++++++++++++++++++++------------
4 files changed, 88 insertions(+), 26 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
diff -u llvm/lib/Target/PowerPC/PPCSubtarget.cpp:1.19 llvm/lib/Target/PowerPC/PPCSubtarget.cpp:1.20
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp:1.19 Tue Feb 28 23:50:56 2006
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp Thu Jun 15 20:37:27 2006
@@ -69,7 +69,7 @@
#endif
-PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS)
+PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit)
: StackAlignment(16)
, InstrItins()
, IsGigaProcessor(false)
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
diff -u llvm/lib/Target/PowerPC/PPCSubtarget.h:1.13 llvm/lib/Target/PowerPC/PPCSubtarget.h:1.14
--- llvm/lib/Target/PowerPC/PPCSubtarget.h:1.13 Tue Feb 28 01:08:22 2006
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h Thu Jun 15 20:37:27 2006
@@ -44,7 +44,7 @@
/// This constructor initializes the data members to match that
/// of the specified module.
///
- PPCSubtarget(const Module &M, const std::string &FS);
+ PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit);
/// ParseSubtargetFeatures - Parses features string setting specified
/// subtarget options. Definition of function is auto generated by tblgen.
@@ -59,6 +59,10 @@
/// selection.
const InstrItineraryData getInstrItineraryData() const { return InstrItins; }
+ const char *getTargetDataString() const {
+ // FIXME: Make is64Bit be for the processor, not the target.
+ return true ? "E-p:32:32-d:32-l:32" : "E-p:64:64-d:32-l:32";
+ }
bool hasFSQRT() const { return HasFSQRT; }
bool hasSTFIWX() const { return HasSTFIWX; }
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.91 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.92
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.91 Sat May 20 18:28:54 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Thu Jun 15 20:37:27 2006
@@ -29,19 +29,29 @@
namespace {
// Register the targets
- RegisterTarget<PPCTargetMachine>
- X("ppc32", " PowerPC");
+ RegisterTarget<PPC32TargetMachine>
+ X("ppc32", " PowerPC 32");
+ RegisterTarget<PPC64TargetMachine>
+ Y("ppc64", " PowerPC 64");
}
-unsigned PPCTargetMachine::getJITMatchQuality() {
+unsigned PPC32TargetMachine::getJITMatchQuality() {
#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
- return 10;
+ if (sizeof(void*) == 4)
+ return 10;
#else
return 0;
#endif
}
+unsigned PPC64TargetMachine::getJITMatchQuality() {
+#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
+ if (sizeof(void*) == 8)
+ return 10 * 0/*FIXME: not PPC64-JIT support yet! */;
+#endif
+ return 0;
+}
-unsigned PPCTargetMachine::getModuleMatchQuality(const Module &M) {
+unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
// We strongly match "powerpc-*".
std::string TT = M.getTargetTriple();
if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
@@ -57,11 +67,31 @@
return getJITMatchQuality()/2;
}
-PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS)
-: TargetMachine("PowerPC"),
- DataLayout(std::string("PowerPC"), std::string("E-p:32:32-d:32-l:32")),
- Subtarget(M, FS), FrameInfo(*this, false), JITInfo(*this),
- TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) {
+unsigned PPC64TargetMachine::getModuleMatchQuality(const Module &M) {
+ // We strongly match "powerpc64-*".
+ std::string TT = M.getTargetTriple();
+ if (TT.size() >= 10 && std::string(TT.begin(), TT.begin()+10) == "powerpc64-")
+ return 20;
+
+ if (M.getEndianness() == Module::BigEndian &&
+ M.getPointerSize() == Module::Pointer64)
+ return 10; // Weak match
+ else if (M.getEndianness() != Module::AnyEndianness ||
+ M.getPointerSize() != Module::AnyPointerSize)
+ return 0; // Match for some other target
+
+ return getJITMatchQuality()/2;
+}
+
+
+PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS,
+ bool is64Bit)
+ : TargetMachine("PowerPC"), Subtarget(M, FS, is64Bit),
+ DataLayout(std::string("PowerPC"),
+ std::string(Subtarget.getTargetDataString())),
+ FrameInfo(*this, false), JITInfo(*this), TLInfo(*this),
+ InstrItins(Subtarget.getInstrItineraryData()) {
+
if (TargetDefault == PPCTarget) {
if (Subtarget.isAIX()) PPCTarget = TargetAIX;
if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
@@ -73,6 +103,15 @@
setRelocationModel(Reloc::PIC);
}
+PPC32TargetMachine::PPC32TargetMachine(const Module &M, const std::string &FS)
+ : PPCTargetMachine(M, FS, false) {
+}
+
+
+PPC64TargetMachine::PPC64TargetMachine(const Module &M, const std::string &FS)
+ : PPCTargetMachine(M, FS, true) {
+}
+
/// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target.
///
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.h
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.21 llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.22
--- llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.21 Fri May 12 16:09:57 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.h Thu Jun 15 20:37:27 2006
@@ -26,44 +26,63 @@
class PassManager;
class GlobalValue;
+/// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
+///
class PPCTargetMachine : public TargetMachine {
- const TargetData DataLayout; // Calculates type size & alignment
- PPCInstrInfo InstrInfo;
- PPCSubtarget Subtarget;
- PPCFrameInfo FrameInfo;
- PPCJITInfo JITInfo;
- PPCTargetLowering TLInfo;
- InstrItineraryData InstrItins;
+ PPCSubtarget Subtarget;
+ const TargetData DataLayout; // Calculates type size & alignment
+ PPCInstrInfo InstrInfo;
+ PPCFrameInfo FrameInfo;
+ PPCJITInfo JITInfo;
+ PPCTargetLowering TLInfo;
+ InstrItineraryData InstrItins;
public:
- PPCTargetMachine(const Module &M, const std::string &FS);
+ PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit);
virtual const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
virtual TargetJITInfo *getJITInfo() { return &JITInfo; }
- virtual const TargetSubtarget *getSubtargetImpl() const{ return &Subtarget; }
virtual PPCTargetLowering *getTargetLowering() const {
return const_cast<PPCTargetLowering*>(&TLInfo);
}
virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}
- virtual const TargetData *getTargetData() const { return &DataLayout; }
+
+ virtual const TargetData *getTargetData() const { return &DataLayout; }
+ virtual const PPCSubtarget *getSubtargetImpl() const { return &Subtarget; }
virtual const InstrItineraryData getInstrItineraryData() const {
return InstrItins;
}
- static unsigned getJITMatchQuality();
-
- static unsigned getModuleMatchQuality(const Module &M);
-
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType, bool Fast);
bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);
};
+
+/// PPC32TargetMachine - PowerPC 32-bit target machine.
+///
+class PPC32TargetMachine : public PPCTargetMachine {
+public:
+ PPC32TargetMachine(const Module &M, const std::string &FS);
+ static unsigned getJITMatchQuality();
+ static unsigned getModuleMatchQuality(const Module &M);
+};
+
+/// PPC64TargetMachine - PowerPC 64-bit target machine.
+///
+class PPC64TargetMachine : public PPCTargetMachine {
+public:
+ PPC64TargetMachine(const Module &M, const std::string &FS);
+
+ static unsigned getJITMatchQuality();
+ static unsigned getModuleMatchQuality(const Module &M);
+};
+
} // end namespace llvm
#endif
More information about the llvm-commits
mailing list