Move getInitialFrameState from TargetFrameInfo to MCAsmInfo (suggestions for
authorEvan Cheng <evan.cheng@apple.com>
Mon, 18 Jul 2011 22:29:13 +0000 (22:29 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 18 Jul 2011 22:29:13 +0000 (22:29 +0000)
better location welcome).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135438 91177308-0d34-0410-b5e6-96231b3b80d8

45 files changed:
include/llvm/CodeGen/MachineLocation.h [deleted file]
include/llvm/CodeGen/MachineModuleInfo.h
include/llvm/MC/MCAsmInfo.h
include/llvm/MC/MCDwarf.h
include/llvm/MC/MachineLocation.h [new file with mode: 0644]
include/llvm/Target/TargetAsmInfo.h
include/llvm/Target/TargetFrameLowering.h
lib/CodeGen/AsmPrinter/ARMException.cpp
lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h
lib/CodeGen/AsmPrinter/DwarfException.cpp
lib/CodeGen/AsmPrinter/Win64Exception.cpp
lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp
lib/ExecutionEngine/JIT/JITDwarfEmitter.h
lib/MC/MCDwarf.cpp
lib/Target/ARM/ARMBaseRegisterInfo.cpp
lib/Target/ARM/Thumb1RegisterInfo.cpp
lib/Target/Alpha/AlphaRegisterInfo.cpp
lib/Target/Blackfin/BlackfinRegisterInfo.cpp
lib/Target/CellSPU/MCTargetDesc/SPUMCTargetDesc.cpp
lib/Target/CellSPU/SPUFrameLowering.cpp
lib/Target/CellSPU/SPUFrameLowering.h
lib/Target/CellSPU/SPURegisterInfo.cpp
lib/Target/MBlaze/MBlazeRegisterInfo.cpp
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
lib/Target/Mips/MipsFrameLowering.cpp
lib/Target/Mips/MipsFrameLowering.h
lib/Target/Mips/MipsRegisterInfo.cpp
lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
lib/Target/PowerPC/PPCFrameLowering.cpp
lib/Target/PowerPC/PPCFrameLowering.h
lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/Sparc/SparcRegisterInfo.cpp
lib/Target/TargetAsmInfo.cpp
lib/Target/TargetFrameLowering.cpp
lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
lib/Target/X86/X86FrameLowering.cpp
lib/Target/X86/X86FrameLowering.h
lib/Target/X86/X86RegisterInfo.cpp
lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp
lib/Target/XCore/XCoreFrameLowering.cpp
lib/Target/XCore/XCoreFrameLowering.h
lib/Target/XCore/XCoreInstrInfo.cpp
lib/Target/XCore/XCoreRegisterInfo.cpp

diff --git a/include/llvm/CodeGen/MachineLocation.h b/include/llvm/CodeGen/MachineLocation.h
deleted file mode 100644 (file)
index 21951b6..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-//===-- llvm/CodeGen/MachineLocation.h --------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-// The MachineLocation class is used to represent a simple location in a machine
-// frame.  Locations will be one of two forms; a register or an address formed
-// from a base address plus an offset.  Register indirection can be specified by
-// using an offset of zero.
-//
-// The MachineMove class is used to represent abstract move operations in the 
-// prolog/epilog of a compiled function.  A collection of these objects can be
-// used by a debug consumer to track the location of values when unwinding stack
-// frames.
-//===----------------------------------------------------------------------===//
-
-
-#ifndef LLVM_CODEGEN_MACHINELOCATION_H
-#define LLVM_CODEGEN_MACHINELOCATION_H
-
-namespace llvm {
-  class MCSymbol;
-  
-class MachineLocation {
-private:
-  bool IsRegister;                      // True if location is a register.
-  unsigned Register;                    // gcc/gdb register number.
-  int Offset;                           // Displacement if not register.
-public:
-  enum {
-    // The target register number for an abstract frame pointer. The value is
-    // an arbitrary value that doesn't collide with any real target register.
-    VirtualFP = ~0U
-  };
-  MachineLocation()
-  : IsRegister(false), Register(0), Offset(0) {}
-  explicit MachineLocation(unsigned R)
-  : IsRegister(true), Register(R), Offset(0) {}
-  MachineLocation(unsigned R, int O)
-  : IsRegister(false), Register(R), Offset(O) {}
-
-  bool operator==(const MachineLocation &Other) const {
-      return IsRegister == Other.IsRegister && Register == Other.Register &&
-        Offset == Other.Offset;
-  }
-  
-  // Accessors
-  bool isReg()           const { return IsRegister; }
-  unsigned getReg()      const { return Register; }
-  int getOffset()        const { return Offset; }
-  void setIsRegister(bool Is)  { IsRegister = Is; }
-  void setRegister(unsigned R) { Register = R; }
-  void setOffset(int O)        { Offset = O; }
-  void set(unsigned R) {
-    IsRegister = true;
-    Register = R;
-    Offset = 0;
-  }
-  void set(unsigned R, int O) {
-    IsRegister = false;
-    Register = R;
-    Offset = O;
-  }
-
-#ifndef NDEBUG
-  void dump();
-#endif
-};
-
-/// MachineMove - This class represents the save or restore of a callee saved
-/// register that exception or debug info needs to know about.
-class MachineMove {
-private:
-  /// Label - Symbol for post-instruction address when result of move takes
-  /// effect.
-  MCSymbol *Label;
-  
-  // Move to & from location.
-  MachineLocation Destination, Source;
-public:
-  MachineMove() : Label(0) {}
-
-  MachineMove(MCSymbol *label, const MachineLocation &D,
-              const MachineLocation &S)
-  : Label(label), Destination(D), Source(S) {}
-  
-  // Accessors
-  MCSymbol *getLabel()                    const { return Label; }
-  const MachineLocation &getDestination() const { return Destination; }
-  const MachineLocation &getSource()      const { return Source; }
-};
-
-} // End llvm namespace
-
-#endif
index c138dbfb72359d41bddb4dd711a5c76a36718cf4..33d5ffd9c365e5e92341f8e4508c4174b4c5ca73 100644 (file)
@@ -34,7 +34,7 @@
 #include "llvm/Pass.h"
 #include "llvm/GlobalValue.h"
 #include "llvm/Metadata.h"
-#include "llvm/CodeGen/MachineLocation.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/DebugLoc.h"
index 41c171761e7866a733bf131cb21dd4d64a4f87a4..f9486de463cd1608704b63208e071f6e06dc0b66 100644 (file)
 #ifndef LLVM_TARGET_ASM_INFO_H
 #define LLVM_TARGET_ASM_INFO_H
 
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCDirectives.h"
 #include <cassert>
+#include <vector>
 
 namespace llvm {
   class MCExpr;
@@ -304,6 +306,10 @@ namespace llvm {
 
     const char *const *AsmTransCBE;          // Defaults to empty
 
+    //===--- Prologue State ----------------------------------------------===//
+
+    std::vector<MachineMove> InitialFrameState;
+
   public:
     explicit MCAsmInfo();
     virtual ~MCAsmInfo();
@@ -512,6 +518,14 @@ namespace llvm {
     const char *const *getAsmCBE() const {
       return AsmTransCBE;
     }
+
+    void addInitialFrameState(MCSymbol *label, const MachineLocation &D,
+                              const MachineLocation &S) {
+      InitialFrameState.push_back(MachineMove(label, D, S));
+    }
+    const std::vector<MachineMove> &getInitialFrameState() const {
+      return InitialFrameState;
+    }
   };
 }
 
index 90c3728567498a5aa75fc23873768d9e68b96548..c426e132940a6d55f95bb88bda09185224ade6de 100644 (file)
 #define LLVM_MC_MCDWARF_H
 
 #include "llvm/ADT/StringRef.h"
-#include "llvm/CodeGen/MachineLocation.h" // FIXME
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCObjectWriter.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Dwarf.h"
 #include <vector>
 
 namespace llvm {
-  class TargetAsmInfo;
-  class MachineMove;
   class MCContext;
   class MCExpr;
   class MCSection;
diff --git a/include/llvm/MC/MachineLocation.h b/include/llvm/MC/MachineLocation.h
new file mode 100644 (file)
index 0000000..8ddfdbc
--- /dev/null
@@ -0,0 +1,98 @@
+//===-- llvm/MC/MachineLocation.h -------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// The MachineLocation class is used to represent a simple location in a machine
+// frame.  Locations will be one of two forms; a register or an address formed
+// from a base address plus an offset.  Register indirection can be specified by
+// using an offset of zero.
+//
+// The MachineMove class is used to represent abstract move operations in the 
+// prolog/epilog of a compiled function.  A collection of these objects can be
+// used by a debug consumer to track the location of values when unwinding stack
+// frames.
+//===----------------------------------------------------------------------===//
+
+
+#ifndef LLVM_MC_MACHINELOCATION_H
+#define LLVM_MC_MACHINELOCATION_H
+
+namespace llvm {
+  class MCSymbol;
+  
+class MachineLocation {
+private:
+  bool IsRegister;                      // True if location is a register.
+  unsigned Register;                    // gcc/gdb register number.
+  int Offset;                           // Displacement if not register.
+public:
+  enum {
+    // The target register number for an abstract frame pointer. The value is
+    // an arbitrary value that doesn't collide with any real target register.
+    VirtualFP = ~0U
+  };
+  MachineLocation()
+    : IsRegister(false), Register(0), Offset(0) {}
+  explicit MachineLocation(unsigned R)
+    : IsRegister(true), Register(R), Offset(0) {}
+  MachineLocation(unsigned R, int O)
+    : IsRegister(false), Register(R), Offset(O) {}
+
+  bool operator==(const MachineLocation &Other) const {
+      return IsRegister == Other.IsRegister && Register == Other.Register &&
+        Offset == Other.Offset;
+  }
+  
+  // Accessors
+  bool isReg()           const { return IsRegister; }
+  unsigned getReg()      const { return Register; }
+  int getOffset()        const { return Offset; }
+  void setIsRegister(bool Is)  { IsRegister = Is; }
+  void setRegister(unsigned R) { Register = R; }
+  void setOffset(int O)        { Offset = O; }
+  void set(unsigned R) {
+    IsRegister = true;
+    Register = R;
+    Offset = 0;
+  }
+  void set(unsigned R, int O) {
+    IsRegister = false;
+    Register = R;
+    Offset = O;
+  }
+
+#ifndef NDEBUG
+  void dump();
+#endif
+};
+
+/// MachineMove - This class represents the save or restore of a callee saved
+/// register that exception or debug info needs to know about.
+class MachineMove {
+private:
+  /// Label - Symbol for post-instruction address when result of move takes
+  /// effect.
+  MCSymbol *Label;
+  
+  // Move to & from location.
+  MachineLocation Destination, Source;
+public:
+  MachineMove() : Label(0) {}
+
+  MachineMove(MCSymbol *label, const MachineLocation &D,
+              const MachineLocation &S)
+  : Label(label), Destination(D), Source(S) {}
+  
+  // Accessors
+  MCSymbol *getLabel()                    const { return Label; }
+  const MachineLocation &getDestination() const { return Destination; }
+  const MachineLocation &getSource()      const { return Source; }
+};
+
+} // End llvm namespace
+
+#endif
index f1ffbd51d48690e56995136a575201842b4fb007..d04a5f3643b4940aa8b715413fc248fd0700fa65 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef LLVM_TARGET_TARGETASMINFO_H
 #define LLVM_TARGET_TARGETASMINFO_H
 
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
 #include "llvm/Target/TargetFrameLowering.h"
 #include "llvm/Target/TargetRegisterInfo.h"
 namespace llvm {
   template <typename T> class ArrayRef;
   class MCSection;
-  class MCContext;
-  class MachineFunction;
   class TargetMachine;
   class TargetLoweringObjectFile;
 
 class TargetAsmInfo {
-  std::vector<MachineMove> InitialFrameState;
   const TargetFrameLowering *TFI;
   const TargetLoweringObjectFile *TLOF;
 
@@ -72,10 +68,6 @@ public:
                                bool IsEH) const {
     return TFI->getCompactUnwindEncoding(Instrs, DataAlignmentFactor, IsEH);
   }
-
-  const std::vector<MachineMove> &getInitialFrameState() const {
-    return InitialFrameState;
-  }
 };
 
 }
index e3d77cf7625dcc89c42d17a29388216a910eba72..352b7aee8c8ad7d990ae9bd57d07aa2d5680226f 100644 (file)
@@ -161,11 +161,6 @@ public:
     return hasReservedCallFrame(MF) || hasFP(MF);
   }
 
-  /// getInitialFrameState - Returns a list of machine moves that are assumed
-  /// on entry to all functions.  Note that LabelID is ignored (assumed to be
-  /// the beginning of the function.)
-  virtual void getInitialFrameState(std::vector<MachineMove> &Moves) const;
-
   /// getFrameIndexOffset - Returns the displacement from the frame register to
   /// the stack frame of the specified index.
   virtual int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
index 5861fa4817f60ad8815e2ac0548058bb4ca87bf8..f8e4fa7e443d08674a7c517a3667fb4eb0046de0 100644 (file)
@@ -17,7 +17,6 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
index dd5b0e261490fe19c2de22d6248b3e87b8302aaa..4d6c28118427a2f82eed39eef46286e45723c2ef 100644 (file)
@@ -13,7 +13,7 @@
 
 #define DEBUG_TYPE "asm-printer"
 #include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/CodeGen/MachineLocation.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCStreamer.h"
index 91b7d08c6ae2e71fd8e209977bcbe920f88cac61..d165be30d508e0a7a5085173e9201b39d90b8f49 100644 (file)
@@ -17,7 +17,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineLocation.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
index b2450064e3d0c272533008fd00c5f14936212274..32006a394314ceff152011557b0111df94beb355 100644 (file)
@@ -15,7 +15,7 @@
 #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
 
 #include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/CodeGen/MachineLocation.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/Analysis/DebugInfo.h"
 #include "DIE.h"
 #include "llvm/ADT/DenseMap.h"
index 1f992faaadb5c5ac4bd631961141603642509755..94a274d7cb863c48afd9a07a8842eb29bc2f3505 100644 (file)
@@ -17,7 +17,6 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
index c2ad5eba3b3cd1ff6673df8eec3fcc048165f951..b83aa5ae3a1b05b44442a554d7e5abed4ea36c91 100644 (file)
@@ -17,7 +17,6 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
index ddb0d5478596ded66b8a7e896e9da3b8b0a619e2..8f84ac7b41267eeaeac2cb1f087a8d6b45e3b394 100644 (file)
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/CodeGen/JITCodeEmitter.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/ExecutionEngine/JITMemoryManager.h"
-#include "llvm/Support/ErrorHandling.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetFrameLowering.h"
@@ -45,7 +45,7 @@ unsigned char* JITDwarfEmitter::EmitDwarfTable(MachineFunction& F,
   TD = TM.getTargetData();
   stackGrowthDirection = TM.getFrameLowering()->getStackGrowthDirection();
   RI = TM.getRegisterInfo();
-  TFI = TM.getFrameLowering();
+  MAI = TM.getMCAsmInfo();
   JCE = &jce;
 
   unsigned char* ExceptionTable = EmitExceptionTable(&F, StartFunction,
@@ -523,9 +523,7 @@ JITDwarfEmitter::EmitCommonEHFrame(const Function* Personality) const {
     JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
   }
 
-  std::vector<MachineMove> Moves;
-  TFI->getInitialFrameState(Moves);
-  EmitFrameMoves(0, Moves);
+  EmitFrameMoves(0, MAI->getInitialFrameState());
 
   JCE->emitAlignmentWithFill(PointerSize, dwarf::DW_CFA_nop);
 
index e1d00454d8d2bb96c315e1866adff808836328ca..8dc99abc4224e1269604f0abe0de2a0e4d2f0c7d 100644 (file)
@@ -22,8 +22,8 @@ class JITCodeEmitter;
 class MachineFunction;
 class MachineModuleInfo;
 class MachineMove;
+class MCAsmInfo;
 class TargetData;
-class TargetFrameLowering;
 class TargetMachine;
 class TargetRegisterInfo;
 
@@ -31,7 +31,7 @@ class JITDwarfEmitter {
   const TargetData* TD;
   JITCodeEmitter* JCE;
   const TargetRegisterInfo* RI;
-  const TargetFrameLowering *TFI;
+  const MCAsmInfo *MAI;
   MachineModuleInfo* MMI;
   JIT& Jit;
   bool stackGrowthDirection;
index 2aab4a3e78bce564dff76cd610f99f297f9baa52..aba470e17cca89ac14937ceaca9445345eaf0cba 100644 (file)
@@ -865,7 +865,8 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
 
   // Initial Instructions
 
-  const std::vector<MachineMove> &Moves = TAI.getInitialFrameState();
+  const MCAsmInfo &MAI = context.getAsmInfo();
+  const std::vector<MachineMove> &Moves = MAI.getInitialFrameState();
   std::vector<MCCFIInstruction> Instructions;
 
   for (int i = 0, n = Moves.size(); i != n; ++i) {
index d41fdb9d2ac73b482f6ee8955f3da195cd153f57..25130f912365f979ee7733245696b9678b55a20d 100644 (file)
@@ -27,7 +27,6 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/RegisterScavenging.h"
 #include "llvm/Support/Debug.h"
index 4eb0b6c93e1dc86b15259e99ee8dbaa0f21f9b5b..61156e2d50c7c6e93baf1c6e05f3bde325379aa5 100644 (file)
@@ -27,7 +27,6 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/Target/TargetFrameLowering.h"
 #include "llvm/Target/TargetMachine.h"
index 0f87d14f2d340f192408f35f115261a00e444240..8b6230fa2a242d361b0e0d71c99d7c6119f37b27 100644 (file)
@@ -21,7 +21,6 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetFrameLowering.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
index e29bc5c9dbc620e587b95f2c71e9b4db745e1123..0d415c5f342be3e32640e737291d07e82ff9e02b 100644 (file)
@@ -20,7 +20,6 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/RegisterScavenging.h"
 #include "llvm/Target/TargetFrameLowering.h"
 #include "llvm/Target/TargetMachine.h"
index 7d9b29531d626cf66dd25736eb51f553e9b9dccf..3c4147bc9f66d9ba3650fa1140bb5964fd98db80 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "SPUMCTargetDesc.h"
 #include "SPUMCAsmInfo.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
@@ -62,6 +63,17 @@ extern "C" void LLVMInitializeCellSPUMCSubtargetInfo() {
                                           createSPUMCSubtargetInfo);
 }
 
+static MCAsmInfo *createSPUMCAsmInfo(const Target &T, StringRef TT) {
+  MCAsmInfo *MAI = new SPULinuxMCAsmInfo(T, TT);
+
+  // Initial state of the frame pointer is R1.
+  MachineLocation Dst(MachineLocation::VirtualFP);
+  MachineLocation Src(SPU::R1, 0);
+  MAI->addInitialFrameState(0, Dst, Src);
+
+  return MAI;
+}
+
 extern "C" void LLVMInitializeCellSPUMCAsmInfo() {
-  RegisterMCAsmInfo<SPULinuxMCAsmInfo> X(TheCellSPUTarget);
+  RegisterMCAsmInfoFn X(TheCellSPUTarget, createSPUMCAsmInfo);
 }
index a3e7e73ae30ae4b19b9d4d76be61f3e4123ee109..8e3186b599b5f0f40d7cacca15cb959be40e32cd 100644 (file)
@@ -249,14 +249,6 @@ void SPUFrameLowering::emitEpilogue(MachineFunction &MF,
   }
 }
 
-void SPUFrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves)
-                                                                         const {
-  // Initial state of the frame pointer is R1.
-  MachineLocation Dst(MachineLocation::VirtualFP);
-  MachineLocation Src(SPU::R1, 0);
-  Moves.push_back(MachineMove(0, Dst, Src));
-}
-
 void SPUFrameLowering::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                                         RegScavenger *RS) const{
   // Mark LR and SP unused, since the prolog spills them to stack and
index 4fee72d946a2a9e51ce419e1a7b9e23239182090..16789ddfc5e3e6b308479a0c9a457a629434330a 100644 (file)
@@ -43,9 +43,6 @@ namespace llvm {
     void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                               RegScavenger *RS = NULL) const;
 
-    //! Perform target-specific stack frame setup.
-    void getInitialFrameState(std::vector<MachineMove> &Moves) const;
-
     //! Return a function's saved spill slots
     /*!
       For CellSPU, a function's saved spill slots is just the link register.
index bb49e5ff1e0ffd0c40c38c7b20ee009eabe5d914..bbac6fd0be54de24f98a4917b3cfa4a150c2b2e3 100644 (file)
@@ -25,7 +25,6 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/RegisterScavenging.h"
 #include "llvm/CodeGen/ValueTypes.h"
index 152e34c9fc8a320ae04944eba55bd5088f0fb494..c82a84c48dd991af07760bfbfdf433169154eda2 100644 (file)
@@ -25,7 +25,6 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetFrameLowering.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
index 4acb12898466301381f15fc551ef1fbb4334abc0..3a2ed8a7628a511d5966f374526ef1c8e73bd211 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "MipsMCTargetDesc.h"
 #include "MipsMCAsmInfo.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
@@ -62,7 +63,17 @@ extern "C" void LLVMInitializeMipsMCSubtargetInfo() {
                                           createMipsMCSubtargetInfo);
 }
 
+static MCAsmInfo *createMipsMCAsmInfo(const Target &T, StringRef TT) {
+  MCAsmInfo *MAI = new MipsMCAsmInfo(T, TT);
+
+  MachineLocation Dst(MachineLocation::VirtualFP);
+  MachineLocation Src(Mips::SP, 0);
+  MAI->addInitialFrameState(0, Dst, Src);
+
+  return MAI;
+}
+
 extern "C" void LLVMInitializeMipsMCAsmInfo() {
-  RegisterMCAsmInfo<MipsMCAsmInfo> X(TheMipsTarget);
-  RegisterMCAsmInfo<MipsMCAsmInfo> Y(TheMipselTarget);
+  RegisterMCAsmInfoFn X(TheMipsTarget, createMipsMCAsmInfo);
+  RegisterMCAsmInfoFn Y(TheMipselTarget, createMipsMCAsmInfo);
 }
index a0f90a0d487aeb3c44f094f1500753184af5cc38..8b4e23876e8bafdf041e9db159d0d25d070052db 100644 (file)
@@ -300,13 +300,6 @@ void MipsFrameLowering::emitEpilogue(MachineFunction &MF,
   }
 }
 
-void
-MipsFrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves) const {
-  MachineLocation Dst(MachineLocation::VirtualFP);
-  MachineLocation Src(Mips::SP, 0);
-  Moves.push_back(MachineMove(0, Dst, Src));
-}
-
 void MipsFrameLowering::
 processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                      RegScavenger *RS) const {
index 78c78eea5b9af865313983fa96450f5719d305d0..a778fde7a332eafa9c1e6e93fd4eef576790160f 100644 (file)
@@ -39,8 +39,6 @@ public:
 
   bool hasFP(const MachineFunction &MF) const;
 
-  void getInitialFrameState(std::vector<MachineMove> &Moves) const;
-  
   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                             RegScavenger *RS) const;
 };
index 0988bd5dad3d984af0680f2ef598d187d361c496..94e84d764de4200da93b0e97bbab2982f6c8d570 100644 (file)
@@ -24,7 +24,6 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetFrameLowering.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
index 3ac644d1fda066d3024a94f9e0935a9a1fe7ec37..e651330a0edea02db7d6f6dc04dad2cff721c443 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "PPCMCTargetDesc.h"
 #include "PPCMCAsmInfo.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
@@ -70,16 +71,25 @@ extern "C" void LLVMInitializePowerPCMCSubtargetInfo() {
                                           createPPCMCSubtargetInfo);
 }
 
-static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
+static MCAsmInfo *createPPCMCAsmInfo(const Target &T, StringRef TT) {
   Triple TheTriple(TT);
   bool isPPC64 = TheTriple.getArch() == Triple::ppc64;
+
+  MCAsmInfo *MAI;
   if (TheTriple.isOSDarwin())
-    return new PPCMCAsmInfoDarwin(isPPC64);
-  return new PPCLinuxMCAsmInfo(isPPC64);
-  
+    MAI = new PPCMCAsmInfoDarwin(isPPC64);
+  else
+    MAI = new PPCLinuxMCAsmInfo(isPPC64);
+
+  // Initial state of the frame pointer is R1.
+  MachineLocation Dst(MachineLocation::VirtualFP);
+  MachineLocation Src(PPC::R1, 0);
+  MAI->addInitialFrameState(0, Dst, Src);
+
+  return MAI;
 }
 
 extern "C" void LLVMInitializePowerPCMCAsmInfo() {
-  RegisterMCAsmInfoFn C(ThePPC32Target, createMCAsmInfo);
-  RegisterMCAsmInfoFn D(ThePPC64Target, createMCAsmInfo);  
+  RegisterMCAsmInfoFn C(ThePPC32Target, createPPCMCAsmInfo);
+  RegisterMCAsmInfoFn D(ThePPC64Target, createPPCMCAsmInfo);  
 }
index 375e000fe401becc10fe17537658863a8901690b..8dd6cbae64d61aac3cf32cce1808cc7eeefc4d9f 100644 (file)
@@ -712,13 +712,6 @@ void PPCFrameLowering::emitEpilogue(MachineFunction &MF,
   }
 }
 
-void PPCFrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves) const {
-  // Initial state of the frame pointer is R1.
-  MachineLocation Dst(MachineLocation::VirtualFP);
-  MachineLocation Src(PPC::R1, 0);
-  Moves.push_back(MachineMove(0, Dst, Src));
-}
-
 static bool spillsCR(const MachineFunction &MF) {
   const PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
   return FuncInfo->isCRSpilled();
index 0c18de1e2e26ef08d9c17744e751c6b03304c850..20faa71d4148d696f6cd771f4e6599a7cb170f64 100644 (file)
@@ -40,7 +40,6 @@ public:
 
   bool hasFP(const MachineFunction &MF) const;
   bool needsFP(const MachineFunction &MF) const;
-  void getInitialFrameState(std::vector<MachineMove> &Moves) const;
 
   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                             RegScavenger *RS = NULL) const;
index 65fc4cf1d9a7aa548fc28602a9f35cd9ce360f46..c9c170e7dce4ca66f809a2bf8b0190ae878503a7 100644 (file)
@@ -28,7 +28,6 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/RegisterScavenging.h"
 #include "llvm/Target/TargetFrameLowering.h"
index 56000c1ef995635963178348a94fae1dfe2b7e90..8c1625148c8cc599cfac0aa1eca6edf963f9abe1 100644 (file)
@@ -17,7 +17,6 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Type.h"
index b25fff0f9bd543c398d162cf0cc6696bc7382740..3320bfbfa721735128de1fcfe32c93870f155679 100644 (file)
@@ -18,5 +18,4 @@ using namespace llvm;
 TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) {
   TLOF = &TM.getTargetLowering()->getObjFileLowering();
   TFI = TM.getFrameLowering();
-  TFI->getInitialFrameState(InitialFrameState);
 }
index 19fd581c7dd5cb65deceae56378cc1508463b0a6..122f8696e2ce623e2dbf33bddf258c6487dbe1d6 100644 (file)
@@ -23,14 +23,6 @@ using namespace llvm;
 TargetFrameLowering::~TargetFrameLowering() {
 }
 
-/// getInitialFrameState - Returns a list of machine moves that are assumed
-/// on entry to a function.
-void
-TargetFrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves)
-                                                                         const {
-  // Default is to do nothing.
-}
-
 /// getFrameIndexOffset - Returns the displacement from the frame register to
 /// the stack frame of the specified index. This is the default implementation
 /// which is overridden for some targets.
index d46f7e28bcee3842fa122e44022006c595b6ab4f..a60b69f2fb2e88425c1b8b6c4265e8b196e41438 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "X86MCTargetDesc.h"
 #include "X86MCAsmInfo.h"
+#include "llvm/MC/MachineLocation.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
@@ -301,18 +302,35 @@ extern "C" void LLVMInitializeX86MCRegisterInfo() {
 
 static MCAsmInfo *createX86MCAsmInfo(const Target &T, StringRef TT) {
   Triple TheTriple(TT);
+  bool is64Bit = TheTriple.getArch() == Triple::x86_64;
 
+  MCAsmInfo *MAI;
   if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) {
-    if (TheTriple.getArch() == Triple::x86_64)
-      return new X86_64MCAsmInfoDarwin(TheTriple);
+    if (is64Bit)
+      MAI = new X86_64MCAsmInfoDarwin(TheTriple);
     else
-      return new X86MCAsmInfoDarwin(TheTriple);
+      MAI = new X86MCAsmInfoDarwin(TheTriple);
+  } else if (TheTriple.isOSWindows()) {
+    MAI = new X86MCAsmInfoCOFF(TheTriple);
+  } else {
+    MAI = new X86ELFMCAsmInfo(TheTriple);
   }
 
-  if (TheTriple.isOSWindows())
-    return new X86MCAsmInfoCOFF(TheTriple);
+  // Initialize initial frame state.
+  // Calculate amount of bytes used for return address storing
+  int stackGrowth = is64Bit ? -8 : -4;
 
-  return new X86ELFMCAsmInfo(TheTriple);
+  // Initial state of the frame pointer is esp+stackGrowth.
+  MachineLocation Dst(MachineLocation::VirtualFP);
+  MachineLocation Src(is64Bit ? X86::RSP : X86::ESP, stackGrowth);
+  MAI->addInitialFrameState(0, Dst, Src);
+
+  // Add return address to move list
+  MachineLocation CSDst(is64Bit ? X86::RSP : X86::ESP, stackGrowth);
+  MachineLocation CSSrc(is64Bit ? X86::RIP : X86::EIP);
+  MAI->addInitialFrameState(0, CSDst, CSSrc);
+
+  return MAI;
 }
 
 extern "C" void LLVMInitializeX86MCAsmInfo() {
index ed45a9a4c1c0aaf700081fe39f95dd61f4b8b9d1..b97641f0b1618aa993b8277061ce9efaf79a38d3 100644 (file)
@@ -844,23 +844,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
   }
 }
 
-void
-X86FrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves) const {
-  // Calculate amount of bytes used for return address storing
-  int stackGrowth = (STI.is64Bit() ? -8 : -4);
-  const X86RegisterInfo *RI = TM.getRegisterInfo();
-
-  // Initial state of the frame pointer is esp+stackGrowth.
-  MachineLocation Dst(MachineLocation::VirtualFP);
-  MachineLocation Src(RI->getStackRegister(), stackGrowth);
-  Moves.push_back(MachineMove(0, Dst, Src));
-
-  // Add return address to move list
-  MachineLocation CSDst(RI->getStackRegister(), stackGrowth);
-  MachineLocation CSSrc(RI->getRARegister());
-  Moves.push_back(MachineMove(0, CSDst, CSSrc));
-}
-
 int X86FrameLowering::getFrameIndexOffset(const MachineFunction &MF, int FI) const {
   const X86RegisterInfo *RI =
     static_cast<const X86RegisterInfo*>(MF.getTarget().getRegisterInfo());
index 14c31ed47cf14a12b03f9a35bdd59f5e28dbd3ff..a03ea76f50554bfaedfaaca43d3016657df11506 100644 (file)
@@ -57,7 +57,6 @@ public:
   bool hasFP(const MachineFunction &MF) const;
   bool hasReservedCallFrame(const MachineFunction &MF) const;
 
-  void getInitialFrameState(std::vector<MachineMove> &Moves) const;
   int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
 
   uint32_t getCompactUnwindEncoding(ArrayRef<MCCFIInstruction> Instrs,
index 3f1cc1a6131dd48648d1d90c8f770c0fd1e8fc33..0e96991af968749b6104e37f12b57807029685c5 100644 (file)
@@ -27,7 +27,6 @@
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/MC/MCAsmInfo.h"
index a29f160d41bbbac950f0d12fa26d0c667509e294..104170c32858aac5978317885b693119d479dc5d 100644 (file)
@@ -61,6 +61,17 @@ extern "C" void LLVMInitializeXCoreMCSubtargetInfo() {
                                           createXCoreMCSubtargetInfo);
 }
 
+static MCAsmInfo *createXCoreMCAsmInfo(const Target &T, StringRef TT) {
+  MCAsmInfo *MAI = new XCoreMCAsmInfo(T, TT);
+
+  // Initial state of the frame pointer is SP.
+  MachineLocation Dst(MachineLocation::VirtualFP);
+  MachineLocation Src(XCore::SP, 0);
+  MAI->addInitialFrameState(0, Dst, Src);
+
+  return MAI;
+}
+
 extern "C" void LLVMInitializeXCoreMCAsmInfo() {
-  RegisterMCAsmInfo<XCoreMCAsmInfo> X(TheXCoreTarget);
+  RegisterMCAsmInfoFn X(TheXCoreTarget, createXCoreMCAsmInfo);
 }
index 057822074e5469cdb9bdd29a98efc36c49102d23..e4cbeb9cda8272493430f1f84f2ec573fb2b4809 100644 (file)
@@ -270,14 +270,6 @@ void XCoreFrameLowering::emitEpilogue(MachineFunction &MF,
   }
 }
 
-void XCoreFrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves)
-                                                                        const {
-  // Initial state of the frame pointer is SP.
-  MachineLocation Dst(MachineLocation::VirtualFP);
-  MachineLocation Src(XCore::SP, 0);
-  Moves.push_back(MachineMove(0, Dst, Src));
-}
-
 bool XCoreFrameLowering::spillCalleeSavedRegisters(MachineBasicBlock &MBB,
                                                MachineBasicBlock::iterator MI,
                                         const std::vector<CalleeSavedInfo> &CSI,
index 7da19f0deb1b5ebdd052c4d89c7019024eacc361..c591e93780aa59a0d8907e7e5f74c615a9541ecc 100644 (file)
@@ -42,8 +42,6 @@ namespace llvm {
 
     bool hasFP(const MachineFunction &MF) const;
 
-    void getInitialFrameState(std::vector<MachineMove> &Moves) const;
-
     void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                               RegScavenger *RS = NULL) const;
 
index f90481f3fbc9c4a00aec810ab4cfdca1790935d3..2db70fcdd2a1b8b4cd6d5353aff15ad0e4930022 100644 (file)
@@ -17,7 +17,6 @@
 #include "llvm/MC/MCContext.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetRegistry.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
index 0d5df743f85a2ef77a89b8b63184ad2430f4fc49..1b78b373fffa4ed29d9571ce4a330a3d7e59b23b 100644 (file)
@@ -17,7 +17,6 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/RegisterScavenging.h"