[llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCSubtarget.cpp PowerPCSubtarget.h PowerPCTargetMachine.cpp PowerPCTargetMachine.h

Nate Begeman natebegeman at mac.com
Thu Aug 4 00:12:21 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PowerPCSubtarget.cpp added (r1.1)
PowerPCSubtarget.h added (r1.1)
PowerPCTargetMachine.cpp updated: 1.57 -> 1.58
PowerPCTargetMachine.h updated: 1.13 -> 1.14
---
Log message:

Add Subtarget support to PowerPC.  Next up, using it.


---
Diffs of the changes:  (+114 -8)

 PowerPCSubtarget.cpp     |   54 +++++++++++++++++++++++++++++++++++++++++++++++
 PowerPCSubtarget.h       |   48 +++++++++++++++++++++++++++++++++++++++++
 PowerPCTargetMachine.cpp |    8 +++---
 PowerPCTargetMachine.h   |   12 ++++++----
 4 files changed, 114 insertions(+), 8 deletions(-)


Index: llvm/lib/Target/PowerPC/PowerPCSubtarget.cpp
diff -c /dev/null llvm/lib/Target/PowerPC/PowerPCSubtarget.cpp:1.1
*** /dev/null	Thu Aug  4 02:12:19 2005
--- llvm/lib/Target/PowerPC/PowerPCSubtarget.cpp	Thu Aug  4 02:12:08 2005
***************
*** 0 ****
--- 1,54 ----
+ //===- PowerPCSubtarget.cpp - PPC Subtarget Information ---------*- C++ -*-===//
+ //
+ //                     The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Nate Begeman and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This file implements the PPC specific subclass of TargetSubtarget.
+ //
+ //===----------------------------------------------------------------------===//
+ 
+ #include "PowerPCSubtarget.h"
+ #include "llvm/Module.h"
+ 
+ #if defined(__APPLE__)
+ #include <mach/mach.h>
+ #include <mach/mach_host.h>
+ #include <mach/host_info.h>
+ #include <mach/machine.h>
+ 
+ static boolean_t IsGP() {
+   host_basic_info_data_t hostInfo;
+   mach_msg_type_number_t infoCount;
+ 
+   infoCount = HOST_BASIC_INFO_COUNT;
+   host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, 
+             &infoCount);
+   
+   return ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
+           (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
+ } 
+ #endif
+ 
+ using namespace llvm;
+ 
+ PPCSubtarget::PPCSubtarget(const Module &M)
+   : TargetSubtarget(), stackAlignment(16), isGigaProcessor(false), isAIX(false),
+     isDarwin(false) {
+   // Set the boolean corresponding to the current target triple, or the default
+   // if one cannot be determined, to true.
+   const std::string& TT = M.getTargetTriple();
+   if (TT.length() > 5) {
+     isDarwin = TT.find("darwin") != std::string::npos;
+   } else if (TT.empty()) {
+ #if defined(_POWER)
+     isAIX = true;
+ #elif defined(__APPLE__)
+     isDarwin = true;
+     isGigaProcessor = IsGP();
+ #endif
+   }
+ }


Index: llvm/lib/Target/PowerPC/PowerPCSubtarget.h
diff -c /dev/null llvm/lib/Target/PowerPC/PowerPCSubtarget.h:1.1
*** /dev/null	Thu Aug  4 02:12:21 2005
--- llvm/lib/Target/PowerPC/PowerPCSubtarget.h	Thu Aug  4 02:12:08 2005
***************
*** 0 ****
--- 1,48 ----
+ //=====-- PowerPCSubtarget.h - Define Subtarget for the PPC ---*- C++ -*--====//
+ //
+ //                     The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Nate Begeman and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This file declares the X86 specific subclass of TargetSubtarget.
+ //
+ //===----------------------------------------------------------------------===//
+ 
+ #ifndef POWERPCSUBTARGET_H
+ #define POWERPCSUBTARGET_H
+ 
+ #include "llvm/Target/TargetSubtarget.h"
+ 
+ namespace llvm {
+ class Module;
+ 
+ class PPCSubtarget : public TargetSubtarget {
+ protected:
+   /// stackAlignment - The minimum alignment known to hold of the stack frame on
+   /// entry to the function and which must be maintained by every function.
+   unsigned stackAlignment;
+ 
+   /// Used by the ISel to turn in optimizations for POWER4-derived architectures
+   bool isGigaProcessor;
+   bool isAIX;
+   bool isDarwin;
+ public:
+   /// This constructor initializes the data members to match that
+   /// of the specified module.
+   ///
+   PPCSubtarget(const Module &M);
+ 
+   /// getStackAlignment - Returns the minimum alignment known to hold of the
+   /// stack frame on entry to the function and which must be maintained by every
+   /// function for this subtarget.
+   unsigned getStackAlignment() const { return stackAlignment; }
+ 
+   bool IsAIX() const { return isAIX; }
+   bool IsDarwin() const { return isDarwin; }
+ };
+ } // End llvm namespace
+ 
+ #endif


Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.57 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.58
--- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.57	Wed Jul 27 01:12:33 2005
+++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp	Thu Aug  4 02:12:08 2005
@@ -59,10 +59,10 @@
 
 PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name,
                                            IntrinsicLowering *IL,
+                                           const Module &M,
                                            const TargetData &TD,
                                            const PowerPCFrameInfo &TFI)
-  : TargetMachine(name, IL, TD), FrameInfo(TFI)
-{}
+: TargetMachine(name, IL, TD), FrameInfo(TFI), Subtarget(M) {}
 
 unsigned PPC32TargetMachine::getJITMatchQuality() {
 #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
@@ -177,14 +177,14 @@
 /// PowerPCTargetMachine ctor - Create an ILP32 architecture model
 ///
 PPC32TargetMachine::PPC32TargetMachine(const Module &M, IntrinsicLowering *IL)
-  : PowerPCTargetMachine(PPC32ID, IL,
+  : PowerPCTargetMachine(PPC32ID, IL, M,
                          TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,1),
                          PowerPCFrameInfo(*this, false)), JITInfo(*this) {}
 
 /// PPC64TargetMachine ctor - Create a LP64 architecture model
 ///
 PPC64TargetMachine::PPC64TargetMachine(const Module &M, IntrinsicLowering *IL)
-  : PowerPCTargetMachine(PPC64ID, IL,
+  : PowerPCTargetMachine(PPC64ID, IL, M,
                          TargetData(PPC64ID,false,8,4,4,4,4,4,2,1,1),
                          PowerPCFrameInfo(*this, true)) {}
 


Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.h
diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.h:1.13 llvm/lib/Target/PowerPC/PowerPCTargetMachine.h:1.14
--- llvm/lib/Target/PowerPC/PowerPCTargetMachine.h:1.13	Fri Jun 24 21:48:37 2005
+++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.h	Thu Aug  4 02:12:08 2005
@@ -14,9 +14,11 @@
 #ifndef POWERPC_TARGETMACHINE_H
 #define POWERPC_TARGETMACHINE_H
 
-#include "PowerPCFrameInfo.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/PassManager.h"
+#include "PowerPCFrameInfo.h"
+#include "PowerPCSubtarget.h"
 
 namespace llvm {
 
@@ -24,13 +26,15 @@
 class IntrinsicLowering;
 
 class PowerPCTargetMachine : public TargetMachine {
-  PowerPCFrameInfo FrameInfo;
-
+  PowerPCFrameInfo  FrameInfo;
+  PPCSubtarget      Subtarget;
 protected:
   PowerPCTargetMachine(const std::string &name, IntrinsicLowering *IL,
-                       const TargetData &TD, const PowerPCFrameInfo &TFI);
+                       const Module &M, const TargetData &TD, 
+                       const PowerPCFrameInfo &TFI);
 public:
   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
+  virtual const TargetSubtarget  *getSubtargetImpl() const{ return &Subtarget; }
 
   virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
                                    CodeGenFileType FileType);






More information about the llvm-commits mailing list