Add an "alignment" field to the MachineFunction object. It makes more sense to
[oota-llvm.git] / include / llvm / CodeGen / MachineFunction.h
index 4fa70fca6facec22a4da7a1acdacb01370f33d9b..e9cecf9d682ca939c18b4edcd88acd3e05c89402 100644 (file)
@@ -19,7 +19,7 @@
 #define LLVM_CODEGEN_MACHINEFUNCTION_H
 
 #include "llvm/ADT/ilist.h"
-#include "llvm/CodeGen/DebugLoc.h"
+#include "llvm/Support/DebugLoc.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/Support/Annotation.h"
 #include "llvm/Support/Allocator.h"
@@ -33,15 +33,24 @@ class MachineFrameInfo;
 class MachineConstantPool;
 class MachineJumpTableInfo;
 class TargetMachine;
+class TargetRegisterClass;
 
 template <>
 struct ilist_traits<MachineBasicBlock>
     : public ilist_default_traits<MachineBasicBlock> {
-  mutable MachineBasicBlock Sentinel;
+  mutable ilist_node<MachineBasicBlock> Sentinel;
 public:
-  MachineBasicBlock *createSentinel() const { return &Sentinel; }
+  MachineBasicBlock *createSentinel() const {
+    return static_cast<MachineBasicBlock*>(&Sentinel);
+  }
   void destroySentinel(MachineBasicBlock *) const {}
 
+  MachineBasicBlock *provideInitialHead() const { return createSentinel(); }
+  MachineBasicBlock *ensureHead(MachineBasicBlock*) const {
+    return createSentinel();
+  }
+  static void noteHead(MachineBasicBlock*, MachineBasicBlock*) {}
+
   void addNodeToList(MachineBasicBlock* MBB);
   void removeNodeFromList(MachineBasicBlock* MBB);
   void deleteNode(MachineBasicBlock *MBB);
@@ -95,9 +104,16 @@ class MachineFunction : private Annotation {
   typedef ilist<MachineBasicBlock> BasicBlockListType;
   BasicBlockListType BasicBlocks;
 
+  // Default debug location. Used to print out the debug label at the beginning
+  // of a function.
+  DebugLoc DefaultDebugLoc;
+
   // Tracks debug locations.
   DebugLocTracker DebugLocInfo;
 
+  // The alignment of the function.
+  unsigned Alignment;
+
 public:
   MachineFunction(const Function *Fn, const TargetMachine &TM);
   ~MachineFunction();
@@ -135,6 +151,14 @@ public:
   MachineConstantPool *getConstantPool() { return ConstantPool; }
   const MachineConstantPool *getConstantPool() const { return ConstantPool; }
 
+  /// getAlignment - Return the alignment of the function.
+  ///
+  unsigned getAlignment() const { return Alignment; }
+
+  /// setAlignment - Set the alignment of the function.
+  ///
+  void setAlignment(unsigned A) { Alignment = A; }
+
   /// MachineFunctionInfo - Keep track of various per-function pieces of
   /// information for backends that would like to do so.
   ///
@@ -163,7 +187,7 @@ public:
   /// basic block can be found by using the MBB::getBlockNumber method, this
   /// method provides the inverse mapping.
   ///
-  MachineBasicBlock *getBlockNumbered(unsigned N) {
+  MachineBasicBlock *getBlockNumbered(unsigned N) const {
     assert(N < MBBNumbering.size() && "Illegal block number");
     assert(MBBNumbering[N] && "Block was removed from the machine function!");
     return MBBNumbering[N];
@@ -226,6 +250,10 @@ public:
   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
   typedef std::reverse_iterator<iterator>             reverse_iterator;
 
+  /// addLiveIn - Add the specified physical register as a live-in value and
+  /// create a corresponding virtual register for it.
+  unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC);
+
   //===--------------------------------------------------------------------===//
   // BasicBlock accessor functions.
   //
@@ -286,6 +314,7 @@ public:
   /// of `new MachineInstr'.
   ///
   MachineInstr *CreateMachineInstr(const TargetInstrDesc &TID,
+                                   DebugLoc DL,
                                    bool NoImp = false);
 
   /// CloneMachineInstr - Create a new MachineInstr which is a copy of the
@@ -311,10 +340,22 @@ public:
   // Debug location.
   //
 
-  /// lookUpDebugLocId - Look up the DebugLocTuple index with the given
-  /// source file, line, and column. It may add a new filename and / or
-  /// a new DebugLocTuple.
-  unsigned lookUpDebugLocId(unsigned Src, unsigned Line, unsigned Col);
+  /// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
+  /// source file, line, and column. If none currently exists, create a new
+  /// DebugLocTuple, and insert it into the DebugIdMap.
+  unsigned getOrCreateDebugLocID(GlobalVariable *CompileUnit,
+                                 unsigned Line, unsigned Col);
+
+  /// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object.
+  DebugLocTuple getDebugLocTuple(DebugLoc DL) const;
+
+  /// getDefaultDebugLoc - Get the default debug location for the machine
+  /// function.
+  DebugLoc getDefaultDebugLoc() const { return DefaultDebugLoc; }
+
+  /// setDefaultDebugLoc - Get the default debug location for the machine
+  /// function.
+  void setDefaultDebugLoc(DebugLoc DL) { DefaultDebugLoc = DL; }
 };
 
 //===--------------------------------------------------------------------===//
@@ -345,8 +386,12 @@ template <> struct GraphTraits<const MachineFunction*> :
 
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
   typedef MachineFunction::const_iterator nodes_iterator;
-  static nodes_iterator nodes_begin(const MachineFunction *F) { return F->begin(); }
-  static nodes_iterator nodes_end  (const MachineFunction *F) { return F->end(); }
+  static nodes_iterator nodes_begin(const MachineFunction *F) {
+    return F->begin();
+  }
+  static nodes_iterator nodes_end  (const MachineFunction *F) {
+    return F->end();
+  }
 };