Make enum-valued bitfield large enough to avoid interpretation as negative values...
[oota-llvm.git] / include / llvm / Function.h
index d42c8d8aa2b5d66889c6779dbe7d13012bf10fcc..862edca9c7d2f4ed04f6510b44c81aaac185c8ed 100644 (file)
@@ -37,6 +37,7 @@ template<> struct ilist_traits<BasicBlock>
   static void destroySentinel(BasicBlock *BB) { delete BB; }
   static iplist<BasicBlock> &getList(Function *F);
   static ValueSymbolTable *getSymTab(Function *ItemParent);
+  static int getListOffset();
 };
 
 template<> struct ilist_traits<Argument>
@@ -47,6 +48,7 @@ template<> struct ilist_traits<Argument>
   static void destroySentinel(Argument *A) { delete A; }
   static iplist<Argument> &getList(Function *F);
   static ValueSymbolTable *getSymTab(Function *ItemParent);
+  static int getListOffset();
 };
 
 class Function : public GlobalValue, public Annotable {
@@ -67,7 +69,10 @@ private:
   ArgumentListType ArgumentList;     ///< The formal arguments
   ValueSymbolTable *SymTab;          ///< Symbol table of args/instructions
   ParamAttrsList *ParamAttrs;        ///< Parameter attributes
-  unsigned CallingConvention;        ///< Calling convention to use
+
+  
+  // The Calling Convention is stored in Value::SubclassData.
+  /*unsigned CallingConvention;*/
 
   friend class SymbolTableListTraits<Function, Module>;
 
@@ -111,8 +116,8 @@ public:
   /// getCallingConv()/setCallingConv(uint) - These method get and set the
   /// calling convention of this function.  The enum values for the known
   /// calling conventions are defined in CallingConv.h.
-  unsigned getCallingConv() const { return CallingConvention; }
-  void setCallingConv(unsigned CC) { CallingConvention = CC; }
+  unsigned getCallingConv() const { return SubclassData; }
+  void setCallingConv(unsigned CC) { SubclassData = CC; }
 
   /// Obtains a constant pointer to the ParamAttrsList object which holds the
   /// parameter attributes information, if any. 
@@ -144,15 +149,6 @@ public:
   void eraseFromParent();
 
 
-  // getNext/Prev - Return the next or previous function in the list.  These
-  // methods should never be used directly, and are only used to implement the
-  // function list as part of the module.
-  //
-        Function *getNext()       { return Next; }
-  const Function *getNext() const { return Next; }
-        Function *getPrev()       { return Prev; }
-  const Function *getPrev() const { return Prev; }
-
   /// Get the underlying elements of the Function... the basic block list is
   /// empty for external functions.
   ///
@@ -238,6 +234,24 @@ public:
   /// including any contained basic blocks.
   ///
   void dropAllReferences();
+  
+  static unsigned getBasicBlockListOffset() {
+    Function *Obj = 0;
+    return unsigned(reinterpret_cast<uintptr_t>(&Obj->BasicBlocks));
+  }
+  static unsigned getArgumentListOffset() {
+    Function *Obj = 0;
+    return unsigned(reinterpret_cast<uintptr_t>(&Obj->ArgumentList));
+  }
+private:
+  // getNext/Prev - Return the next or previous function in the list.  These
+  // methods should never be used directly, and are only used to implement the
+  // function list as part of the module.
+  //
+  Function *getNext()             { return Next; }
+  const Function *getNext() const { return Next; }
+  Function *getPrev()             { return Prev; }
+  const Function *getPrev() const { return Prev; }
 };
 
 inline ValueSymbolTable *
@@ -250,6 +264,17 @@ ilist_traits<Argument>::getSymTab(Function *F) {
   return F ? &F->getValueSymbolTable() : 0;
 }
 
+inline int 
+ilist_traits<BasicBlock>::getListOffset() {
+  return Function::getBasicBlockListOffset();
+}
+
+inline int 
+ilist_traits<Argument>::getListOffset() {
+  return Function::getArgumentListOffset();
+}
+
+
 } // End llvm namespace
 
 #endif