Added getTargetLowering() to TargetMachine. Refactored targets to support this.
authorEvan Cheng <evan.cheng@apple.com>
Mon, 13 Mar 2006 23:20:37 +0000 (23:20 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 13 Mar 2006 23:20:37 +0000 (23:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26742 91177308-0d34-0410-b5e6-96231b3b80d8

27 files changed:
lib/Target/IA64/IA64.h
lib/Target/IA64/IA64AsmPrinter.cpp
lib/Target/IA64/IA64Bundling.cpp
lib/Target/IA64/IA64ISelDAGToDAG.cpp
lib/Target/IA64/IA64TargetMachine.cpp
lib/Target/IA64/IA64TargetMachine.h
lib/Target/PowerPC/PPC.h
lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCISelDAGToDAG.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.h
lib/Target/PowerPC/PPCJITInfo.h
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/PowerPC/PPCTargetMachine.h
lib/Target/X86/X86.h
lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86ATTAsmPrinter.h
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.h
lib/Target/X86/X86ELFWriter.cpp
lib/Target/X86/X86ISelDAGToDAG.cpp
lib/Target/X86/X86ISelLowering.h
lib/Target/X86/X86IntelAsmPrinter.cpp
lib/Target/X86/X86IntelAsmPrinter.h
lib/Target/X86/X86JITInfo.h
lib/Target/X86/X86TargetMachine.cpp
lib/Target/X86/X86TargetMachine.h

index af3ce6d1479b32534bea6f997a9d49ac3e57951e..f8cfbf1826743640413efba1efafc7fd58c1b4ac 100644 (file)
 
 namespace llvm {
 
-class TargetMachine;
+class IA64TargetMachine;
 class FunctionPass;
 class IntrinsicLowering;
 
 /// createIA64DAGToDAGInstructionSelector - This pass converts an LLVM
 /// function into IA64 machine code in a sane, DAG->DAG transform.
 ///
-FunctionPass *createIA64DAGToDAGInstructionSelector(TargetMachine &TM);
+FunctionPass *createIA64DAGToDAGInstructionSelector(IA64TargetMachine &TM);
 
 /// createIA64BundlingPass - This pass adds stop bits and bundles
 /// instructions.
 ///
-FunctionPass *createIA64BundlingPass(TargetMachine &TM);
+FunctionPass *createIA64BundlingPass(IA64TargetMachine &TM);
 
 /// createIA64CodePrinterPass - Returns a pass that prints the IA64
 /// assembly code for a MachineFunction to the given output stream,
 /// using the given target machine description.  This should work
 /// regardless of whether the function is in SSA form.
 ///
-FunctionPass *createIA64CodePrinterPass(std::ostream &o,TargetMachine &tm);
+FunctionPass *createIA64CodePrinterPass(std::ostream &o, IA64TargetMachine &tm);
 
 } // End llvm namespace
 
index 09d388b84989dbb6af64c336d5fb40288d428afc..2cd156124a7b13de5c2028a4f2ab5a800a93b765 100644 (file)
@@ -374,7 +374,8 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
 /// assembly code for a MachineFunction to the given output stream, using
 /// the given target machine description.
 ///
-FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,TargetMachine &tm){
+FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,
+                                              IA64TargetMachine &tm) {
   return new IA64AsmPrinter(o, tm);
 }
 
index 2f3d238f082d6d5c0f8b56d6f81f1e7567066f78..11f0276da3a8e66cd293c4719c32c0ed81e188e9 100644 (file)
@@ -37,9 +37,9 @@ namespace {
     /// Target machine description which we query for reg. names, data
     /// layout, etc.
     ///
-    TargetMachine &TM;
+    IA64TargetMachine &TM;
 
-    IA64BundlingPass(TargetMachine &tm) : TM(tm) { }
+    IA64BundlingPass(IA64TargetMachine &tm) : TM(tm) { }
 
     virtual const char *getPassName() const {
       return "IA64 (Itanium) Bundling Pass";
@@ -64,7 +64,7 @@ namespace {
 /// createIA64BundlingPass - Returns a pass that adds STOP (;;) instructions
 /// and arranges the result into bundles.
 ///
-FunctionPass *llvm::createIA64BundlingPass(TargetMachine &tm) {
+FunctionPass *llvm::createIA64BundlingPass(IA64TargetMachine &tm) {
   return new IA64BundlingPass(tm);
 }
 
index c90493454ade91cebdd13172df8b141cf11d912f..9ce3ea64767980902fbe8ca5b71ab2e5bda07dfc 100644 (file)
@@ -42,8 +42,8 @@ namespace {
     IA64TargetLowering IA64Lowering;
     unsigned GlobalBaseReg;
   public:
-    IA64DAGToDAGISel(TargetMachine &TM)
-      : SelectionDAGISel(IA64Lowering), IA64Lowering(TM) {}
+    IA64DAGToDAGISel(IA64TargetMachine &TM)
+      : SelectionDAGISel(IA64Lowering), IA64Lowering(*TM.getTargetLowering()) {}
     
     virtual bool runOnFunction(Function &Fn) {
       // Make sure we re-emit a set of the global base reg if necessary
@@ -621,7 +621,8 @@ void IA64DAGToDAGISel::Select(SDOperand &Result, SDOperand Op) {
 /// createIA64DAGToDAGInstructionSelector - This pass converts a legalized DAG
 /// into an IA64-specific DAG, ready for instruction scheduling.
 ///
-FunctionPass *llvm::createIA64DAGToDAGInstructionSelector(TargetMachine &TM) {
+FunctionPass
+*llvm::createIA64DAGToDAGInstructionSelector(IA64TargetMachine &TM) {
   return new IA64DAGToDAGISel(TM);
 }
 
index 79377c577f9daddd4a234444681b0162eee7ff97..9757b991b6b8050bc238034ddc65b8eb96c67a94 100644 (file)
@@ -79,7 +79,8 @@ unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
 IA64TargetMachine::IA64TargetMachine(const Module &M, IntrinsicLowering *IL,
                                      const std::string &FS)
   : TargetMachine("IA64", IL, true),
-    FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0) { // FIXME? check this stuff
+    FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
+    TLInfo(*this) { // FIXME? check this stuff
 }
 
 // addPassesToEmitFile - We currently use all of the same passes as the JIT
index 127bdf1468ecc9e35d1ce24d209362c9955c6ebb..fb633bc51e0b1e954a9938de4dd9088440dcc3eb 100644 (file)
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/PassManager.h"
 #include "IA64InstrInfo.h"
+#include "IA64ISelLowering.h"
 
 namespace llvm {
 class IntrinsicLowering;
 
 class IA64TargetMachine : public TargetMachine {
-  IA64InstrInfo    InstrInfo;
-  TargetFrameInfo FrameInfo;
+  IA64InstrInfo      InstrInfo;
+  TargetFrameInfo    FrameInfo;
   //IA64JITInfo      JITInfo;
+  IA64TargetLowering TLInfo;
 public:
   IA64TargetMachine(const Module &M, IntrinsicLowering *IL,
                     const std::string &FS);
 
-  virtual const IA64InstrInfo     *getInstrInfo() const { return &InstrInfo; }
-  virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
+  virtual const IA64InstrInfo      *getInstrInfo() const { return &InstrInfo; }
+  virtual const TargetFrameInfo    *getFrameInfo() const { return &FrameInfo; }
+  virtual       IA64TargetLowering *getTargetLowering()  { return &TLInfo; }
   virtual const MRegisterInfo    *getRegisterInfo() const {
     return &InstrInfo.getRegisterInfo();
   }
index a12dfdfb112b9c06300e1773fabb94378c1df9f1..88fc87e30985186eeaf91d37ac8e432d0fe6004d 100644 (file)
 namespace llvm {
 
 class FunctionPass;
-class TargetMachine;
+class PPCTargetMachine;
 
 enum PPCTargetEnum {
   TargetDefault, TargetAIX, TargetDarwin
 };
 
 FunctionPass *createPPCBranchSelectionPass();
-FunctionPass *createPPCISelDag(TargetMachine &TM);
-FunctionPass *createDarwinAsmPrinter(std::ostream &OS, TargetMachine &TM);
-FunctionPass *createAIXAsmPrinter(std::ostream &OS, TargetMachine &TM);
+FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
+FunctionPass *createDarwinAsmPrinter(std::ostream &OS, PPCTargetMachine &TM);
+FunctionPass *createAIXAsmPrinter(std::ostream &OS, PPCTargetMachine &TM);
 
 extern PPCTargetEnum PPCTarget;
 } // end namespace llvm;
index 2b88a855f5c104fe3769d7037aad3a845d78dd5d..2b5ff5970e0dbaed03594888e7541a046dfa7cba 100644 (file)
@@ -307,7 +307,8 @@ namespace {
 /// code for a MachineFunction to the given output stream, in a format that the
 /// Darwin assembler can deal with.
 ///
-FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o, TargetMachine &tm) {
+FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o,
+                                           PPCTargetMachine &tm) {
   return new DarwinAsmPrinter(o, tm);
 }
 
@@ -315,7 +316,7 @@ FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o, TargetMachine &tm) {
 /// for a MachineFunction to the given output stream, in a format that the
 /// AIX 5L assembler can deal with.
 ///
-FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, TargetMachine &tm) {
+FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, PPCTargetMachine &tm) {
   return new AIXAsmPrinter(o, tm);
 }
 
index 02881433b699bce6140a394d1789f17bf498835c..991b088e17c0b260236dcaf22ceb7db7b78fe73f 100644 (file)
@@ -42,8 +42,9 @@ namespace {
     PPCTargetLowering PPCLowering;
     unsigned GlobalBaseReg;
   public:
-    PPCDAGToDAGISel(TargetMachine &TM)
-      : SelectionDAGISel(PPCLowering), PPCLowering(TM) {}
+    PPCDAGToDAGISel(PPCTargetMachine &TM)
+      : SelectionDAGISel(PPCLowering),
+        PPCLowering(*TM.getTargetLowering()){}
     
     virtual bool runOnFunction(Function &Fn) {
       // Make sure we re-emit a set of the global base reg if necessary
@@ -1140,7 +1141,7 @@ void PPCDAGToDAGISel::Select(SDOperand &Result, SDOperand Op) {
 /// createPPCISelDag - This pass converts a legalized DAG into a 
 /// PowerPC-specific DAG, ready for instruction scheduling.
 ///
-FunctionPass *llvm::createPPCISelDag(TargetMachine &TM) {
+FunctionPass *llvm::createPPCISelDag(PPCTargetMachine &TM) {
   return new PPCDAGToDAGISel(TM);
 }
 
index dac58f536805fa72c5764fee4f3e080a618c9bbb..0590b9ed687b297a769a99da7c11d79399fd4957 100644 (file)
@@ -14,6 +14,7 @@
 #include "PPCISelLowering.h"
 #include "PPCTargetMachine.h"
 #include "llvm/ADT/VectorExtras.h"
+#include "llvm/Analysis/ScalarEvolutionExpressions.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -1174,3 +1175,10 @@ isOperandValidForConstraint(SDOperand Op, char Letter) {
   // Handle standard constraint letters.
   return TargetLowering::isOperandValidForConstraint(Op, Letter);
 }
+
+/// isLegalAddressImmediate - Return true if the integer value can be used
+/// as the offset of the target addressing mode.
+bool PPCTargetLowering::isLegalAddressImmediate(int64_t V) const {
+  // PPC allows a sign-extended 16-bit immediate field.
+  return (V > -(1 << 16) && V < (1 << 16)-1);
+}
index a89727d2f7be92ec8fa6cf3f0eea76276140f540..b406e4e7996b3c527a576a35a49501d8a23d3a59 100644 (file)
@@ -109,6 +109,10 @@ namespace llvm {
       getRegClassForInlineAsmConstraint(const std::string &Constraint,
                                         MVT::ValueType VT) const;
     bool isOperandValidForConstraint(SDOperand Op, char ConstraintLetter);
+
+    /// isLegalAddressImmediate - Return true if the integer value can be used
+    /// as the offset of the target addressing mode.
+    virtual bool isLegalAddressImmediate(int64_t V) const;
   };
 }
 
index 39a706f083085eb3f714673a5ffc88f27db7319c..245cf9ad9023508114982ff754e207d56c6a65e3 100644 (file)
 #include "llvm/Target/TargetJITInfo.h"
 
 namespace llvm {
-  class TargetMachine;
+  class PPCTargetMachine;
 
   class PPCJITInfo : public TargetJITInfo {
   protected:
-    TargetMachine &TM;
+    PPCTargetMachine &TM;
   public:
-    PPCJITInfo(TargetMachine &tm) : TM(tm) {useGOT = 0;}
+    PPCJITInfo(PPCTargetMachine &tm) : TM(tm) {useGOT = 0;}
 
     /// addPassesToJITCompile - Add passes to the specified pass manager to
     /// implement a fast dynamic compiler for this target.  Return true if this
index ced492ccb95e9177cf8ce06d34a842bdb9982eb3..6fe41ea51aeb16fdaec98ad35aa43be1a4b9b19f 100644 (file)
@@ -62,7 +62,7 @@ PPCTargetMachine::PPCTargetMachine(const Module &M, IntrinsicLowering *IL,
                                    const std::string &FS)
 : TargetMachine("PowerPC", IL, false, 4, 4, 4, 4, 4, 4, 2, 1, 1),
   Subtarget(M, FS), FrameInfo(*this, false), JITInfo(*this),
-  InstrItins(Subtarget.getInstrItineraryData()) {
+  TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) {
   if (TargetDefault == PPCTarget) {
     if (Subtarget.isAIX()) PPCTarget = TargetAIX;
     if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
index dff48348de58165042c290b5fbf7566519211837..4038a2a84fad4735965146466d6e08e49ba5209e 100644 (file)
@@ -18,6 +18,7 @@
 #include "PPCSubtarget.h"
 #include "PPCJITInfo.h"
 #include "PPCInstrInfo.h"
+#include "PPCISelLowering.h"
 #include "llvm/Target/TargetMachine.h"
 
 namespace llvm {
@@ -31,6 +32,7 @@ class PPCTargetMachine : public TargetMachine {
   PPCSubtarget           Subtarget;
   PPCFrameInfo           FrameInfo;
   PPCJITInfo             JITInfo;
+  PPCTargetLowering      TLInfo;
   InstrItineraryData     InstrItins;
 public:
   PPCTargetMachine(const Module &M, IntrinsicLowering *IL,
@@ -40,6 +42,7 @@ public:
   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
   virtual       TargetJITInfo    *getJITInfo()         { return &JITInfo; }
   virtual const TargetSubtarget  *getSubtargetImpl() const{ return &Subtarget; }
+  virtual       PPCTargetLowering *getTargetLowering() { return &TLInfo; }
   virtual const MRegisterInfo    *getRegisterInfo() const {
     return &InstrInfo.getRegisterInfo();
   }
index f6d1be0987006e2d6ac17064cbccef3de6b793a4..8d2805ccc203b47d54cc3a7cb3e5ab8dfe32d041 100644 (file)
@@ -19,7 +19,7 @@
 
 namespace llvm {
 
-class TargetMachine;
+class X86TargetMachine;
 class PassManager;
 class FunctionPass;
 class IntrinsicLowering;
@@ -28,7 +28,7 @@ class MachineCodeEmitter;
 /// createX86ISelDag - This pass converts a legalized DAG into a 
 /// X86-specific DAG, ready for instruction scheduling.
 ///
-FunctionPass *createX86ISelDag(TargetMachine &TM);
+FunctionPass *createX86ISelDag(X86TargetMachine &TM);
 
 /// createX86FloatingPointStackifierPass - This function returns a pass which
 /// converts floating point register references and pseudo instructions into
@@ -40,7 +40,7 @@ FunctionPass *createX86FloatingPointStackifierPass();
 /// assembly code for a MachineFunction to the given output stream,
 /// using the given target machine description.
 ///
-FunctionPass *createX86CodePrinterPass(std::ostream &o, TargetMachine &tm);
+FunctionPass *createX86CodePrinterPass(std::ostream &o, X86TargetMachine &tm);
 
 /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
 /// to the specified MCE object.
@@ -50,7 +50,7 @@ FunctionPass *createX86CodeEmitterPass(MachineCodeEmitter &MCE);
 /// code as an ELF object file.
 ///
 void addX86ELFObjectWriterPass(PassManager &FPM,
-                               std::ostream &o, TargetMachine &tm);
+                               std::ostream &o, X86TargetMachine &tm);
 
 /// createX86EmitCodeToMemory - Returns a pass that converts a register
 /// allocated function into raw machine code in a dynamically
index f1b53fd7ea334fe9f0624a411514ff6f1a3771d0..9c5a83599d1f689ac3b3313e3e70b5a1e663018e 100755 (executable)
@@ -21,7 +21,6 @@
 #include "llvm/Target/TargetOptions.h"
 #include <iostream>
 using namespace llvm;
-using namespace x86;
 
 /// runOnMachineFunction - This uses the printMachineInstruction()
 /// method to print assembly for each instruction.
index 325b43d32b2cd3a5e500feb8854f567117515a30..8d400e8c7722cc57f6d7cba987d08e53e18f0578 100755 (executable)
 #include "llvm/CodeGen/ValueTypes.h"
 
 namespace llvm {
-namespace x86 {
 
 struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
- X86ATTAsmPrinter(std::ostream &O, TargetMachine &TM)
+ X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM)
     : X86SharedAsmPrinter(O, TM) { }
 
   virtual const char *getPassName() const {
@@ -69,7 +68,6 @@ struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
   bool runOnMachineFunction(MachineFunction &F);
 };
 
-} // end namespace x86
 } // end namespace llvm
 
 #endif
index ad2569d810dbf8e64c2c4c73eb4a8bc6a47ff167..cf2be9582d27764a0d8f3bd1f70fb69eaa286cbb 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
+#include "X86AsmPrinter.h"
 #include "X86ATTAsmPrinter.h"
 #include "X86IntelAsmPrinter.h"
 #include "X86Subtarget.h"
-#include "X86.h"
 #include "llvm/Constants.h"
 #include "llvm/Module.h"
 #include "llvm/Type.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/CommandLine.h"
 using namespace llvm;
-using namespace x86;
 
-Statistic<> llvm::x86::EmittedInsts("asm-printer",
-                                    "Number of machine instrs printed");
+Statistic<> llvm::EmittedInsts("asm-printer",
+                               "Number of machine instrs printed");
 
 enum AsmWriterFlavorTy { att, intel };
 cl::opt<AsmWriterFlavorTy>
@@ -210,7 +209,8 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
 /// for a MachineFunction to the given output stream, using the given target
 /// machine description.
 ///
-FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,TargetMachine &tm){
+FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,
+                                             X86TargetMachine &tm){
   switch (AsmWriterFlavor) {
   default:
     assert(0 && "Unknown asm flavor!");
index ed0fdbed27dbffb01b41a6a54a177bbd07f2f296..c4d67b6ac70431b8c5a4f9fa77fdb6ef1157acba 100755 (executable)
@@ -17,6 +17,7 @@
 #define X86ASMPRINTER_H
 
 #include "X86.h"
+#include "X86TargetMachine.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineDebugInfo.h"
@@ -25,7 +26,6 @@
 
 
 namespace llvm {
-namespace x86 {
 
 extern Statistic<> EmittedInsts;
 
@@ -56,7 +56,7 @@ X86DwarfWriter(std::ostream &o, AsmPrinter *ap)
 struct X86SharedAsmPrinter : public AsmPrinter {
   X86DwarfWriter DW;
 
-  X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
+  X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM)
     : AsmPrinter(O, TM), DW(O, this), forDarwin(false) { }
 
   bool doInitialization(Module &M);
@@ -90,7 +90,6 @@ struct X86SharedAsmPrinter : public AsmPrinter {
   }
 };
 
-} // end namespace x86
 } // end namespace llvm
 
 #endif
index 8a6f1fc89827604e92b5b97c2bf2ee44cdfd683f..a449ce2d8d9dbbd7e065c32644f96b6fc34eacd0 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "X86.h"
+#include "X86TargetMachine.h"
 #include "llvm/PassManager.h"
 #include "llvm/CodeGen/ELFWriter.h"
-#include "llvm/Target/TargetMachine.h"
 using namespace llvm;
 
 namespace {
   class X86ELFWriter : public ELFWriter {
   public:
-    X86ELFWriter(std::ostream &O, TargetMachine &TM) : ELFWriter(O, TM) {
+    X86ELFWriter(std::ostream &O, X86TargetMachine &TM) : ELFWriter(O, TM) {
       e_machine = 3;   // EM_386
     }
   };
@@ -31,7 +31,7 @@ namespace {
 /// as an ELF object file.
 ///
 void llvm::addX86ELFObjectWriterPass(PassManager &FPM,
-                                     std::ostream &O, TargetMachine &TM) {
+                                     std::ostream &O, X86TargetMachine &TM) {
   X86ELFWriter *EW = new X86ELFWriter(O, TM);
   FPM.add(EW);
   FPM.add(createX86CodeEmitterPass(EW->getMachineCodeEmitter()));
index 3cf3671ec856c7db7561e73ec51393dc2499af55..5d096ef61000b85899f666a6efff7972a281f464 100644 (file)
 #define DEBUG_TYPE "isel"
 #include "X86.h"
 #include "X86InstrBuilder.h"
+#include "X86ISelLowering.h"
 #include "X86RegisterInfo.h"
 #include "X86Subtarget.h"
-#include "X86ISelLowering.h"
+#include "X86TargetMachine.h"
 #include "llvm/GlobalValue.h"
 #include "llvm/Instructions.h"
 #include "llvm/Support/CFG.h"
@@ -90,8 +91,9 @@ namespace {
 
     unsigned GlobalBaseReg;
   public:
-    X86DAGToDAGISel(TargetMachine &TM)
-      : SelectionDAGISel(X86Lowering), X86Lowering(TM) {
+    X86DAGToDAGISel(X86TargetMachine &TM)
+      : SelectionDAGISel(X86Lowering),
+        X86Lowering(*TM.getTargetLowering()) {
       Subtarget = &TM.getSubtarget<X86Subtarget>();
     }
 
@@ -842,6 +844,6 @@ void X86DAGToDAGISel::Select(SDOperand &Result, SDOperand N) {
 /// createX86ISelDag - This pass converts a legalized DAG into a 
 /// X86-specific DAG, ready for instruction scheduling.
 ///
-FunctionPass *llvm::createX86ISelDag(TargetMachine &TM) {
+FunctionPass *llvm::createX86ISelDag(X86TargetMachine &TM) {
   return new X86DAGToDAGISel(TM);
 }
index 414a07086a41f6ad260e4d4725d8661d56104b37..823fa6a0144cc74b9186e9d354720158cfa45288 100644 (file)
@@ -230,6 +230,12 @@ namespace llvm {
     std::vector<unsigned> 
       getRegClassForInlineAsmConstraint(const std::string &Constraint,
                                         MVT::ValueType VT) const;
+
+    /// isLegalAddressImmediate - Return true if the integer value or
+    /// GlobalValue can be used as the offset of the target addressing mode.
+    virtual bool isLegalAddressImmediate(int64_t V) const;
+    virtual bool isLegalAddressImmediate(GlobalValue *GV) const;
+
   private:
     // C Calling Convention implementation.
     std::vector<SDOperand> LowerCCCArguments(Function &F, SelectionDAG &DAG);
index a04dfca854594cfddf9525ac7a804fb4895031bf..2980bfe1c2ca029990d0e0d7996980338b377dab 100755 (executable)
@@ -20,7 +20,6 @@
 #include "llvm/Support/Mangler.h"
 #include "llvm/Target/TargetOptions.h"
 using namespace llvm;
-using namespace x86;
 
 /// runOnMachineFunction - This uses the printMachineInstruction()
 /// method to print assembly for each instruction.
index cf8d3cf366dcb0fdd42aa48465112e68dbcb26fe..13d0ad6499eadb7a0e7dc03e748dcd8b334aac48 100755 (executable)
 
 #include "X86AsmPrinter.h"
 #include "llvm/CodeGen/ValueTypes.h"
-#include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MRegisterInfo.h"
 
 namespace llvm {
-namespace x86 {
 
 struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
- X86IntelAsmPrinter(std::ostream &O, TargetMachine &TM)
+ X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM)
     : X86SharedAsmPrinter(O, TM) { }
 
   virtual const char *getPassName() const {
@@ -91,7 +89,6 @@ struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
   bool doInitialization(Module &M);
 };
 
-} // end namespace x86
 } // end namespace llvm
 
 #endif
index b240674e63947588373c1c0a397af2fabfc70f4a..02e54af11af7b139da0a0d1430bb2003d93e7be0 100644 (file)
 #include "llvm/Target/TargetJITInfo.h"
 
 namespace llvm {
-  class TargetMachine;
+  class X86TargetMachine;
   class IntrinsicLowering;
 
   class X86JITInfo : public TargetJITInfo {
-    TargetMachine &TM;
+    X86TargetMachine &TM;
   public:
-    X86JITInfo(TargetMachine &tm) : TM(tm) {useGOT = 0;}
+    X86JITInfo(X86TargetMachine &tm) : TM(tm) {useGOT = 0;}
 
     /// addPassesToJITCompile - Add passes to the specified pass manager to
     /// implement a fast dynamic compiler for this target.  Return true if this
index de7004d97a02c0a199d5122af154f09da2058ea6..2de8cc0b61367add221b98748bba2dcf7d4fabf3 100644 (file)
@@ -79,7 +79,7 @@ X86TargetMachine::X86TargetMachine(const Module &M,
     Subtarget(M, FS),
     FrameInfo(TargetFrameInfo::StackGrowsDown,
               Subtarget.getStackAlignment(), -4),
-    JITInfo(*this) {
+    JITInfo(*this), TLInfo(*this) {
   if (getRelocationModel() == Reloc::Default)
     if (Subtarget.isTargetDarwin())
       setRelocationModel(Reloc::DynamicNoPIC);
@@ -97,7 +97,7 @@ bool X86TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
       FileType != TargetMachine::ObjectFile) return true;
 
   // Run loop strength reduction before anything else.
-  if (EnableX86LSR) PM.add(createLoopStrengthReducePass());
+  if (EnableX86LSR) PM.add(createLoopStrengthReducePass(1, &TLInfo));
 
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
@@ -164,6 +164,10 @@ void X86JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
   // The JIT should use static relocation model.
   TM.setRelocationModel(Reloc::Static);
 
+  // Run loop strength reduction before anything else.
+  if (EnableX86LSR)
+    PM.add(createLoopStrengthReducePass(1, TM.getTargetLowering()));
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
index 10f012a999187e951270c496787d2793a1aa670a..f63fc34bcd78450ab26228a9fa45a3f2972aee18 100644 (file)
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/PassManager.h"
+#include "X86.h"
 #include "X86InstrInfo.h"
 #include "X86JITInfo.h"
 #include "X86Subtarget.h"
+#include "X86ISelLowering.h"
 
 namespace llvm {
 class IntrinsicLowering;
 
 class X86TargetMachine : public TargetMachine {
-  X86InstrInfo    InstrInfo;
-  X86Subtarget    Subtarget;
-  TargetFrameInfo FrameInfo;
-  X86JITInfo      JITInfo;
+  X86InstrInfo      InstrInfo;
+  X86Subtarget      Subtarget;
+  TargetFrameInfo   FrameInfo;
+  X86JITInfo        JITInfo;
+  X86TargetLowering TLInfo;
 public:
   X86TargetMachine(const Module &M, IntrinsicLowering *IL,
                    const std::string &FS);
@@ -37,6 +40,7 @@ public:
   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
   virtual       TargetJITInfo    *getJITInfo()         { return &JITInfo; }
   virtual const TargetSubtarget  *getSubtargetImpl() const{ return &Subtarget; }
+  virtual       X86TargetLowering *getTargetLowering() { return &TLInfo; }
   virtual const MRegisterInfo    *getRegisterInfo() const {
     return &InstrInfo.getRegisterInfo();
   }