Add support for explicit calling conventions
authorChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 20:26:26 +0000 (20:26 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 20:26:26 +0000 (20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21745 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Function.h
include/llvm/Instructions.h
include/llvm/Support/CallSite.h

index edd88617b0fb73d84f6ee6a0740c3505358b3ef0..38f33ceeb8f3d02fcb3e77cd25b7d4107ee71851 100644 (file)
@@ -66,6 +66,7 @@ private:
   ArgumentListType ArgumentList;        // The formal arguments
 
   SymbolTable *SymTab;
+  unsigned CallingConvention;
 
   friend class SymbolTableListTraits<Function, Module, Module>;
 
@@ -106,6 +107,12 @@ public:
   unsigned getIntrinsicID() const;
   bool isIntrinsic() const { return getIntrinsicID() != 0; }
 
+  /// 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; }
+
   /// renameLocalSymbols - This method goes through the Function's symbol table
   /// and renames any symbols that conflict with symbols at global scope.  This
   /// is required before printing out to a textual form, to ensure that there is
index b398361aec23a48a87f465e83516974ff7b5bd04..696466858d19b99d960bf83a0d6c688734aa064b 100644 (file)
@@ -467,8 +467,9 @@ public:
 //===----------------------------------------------------------------------===//
 
 /// CallInst - This class represents a function call, abstracting a target
-/// machine's calling convention.  This class uses the SubClassData field to
-/// indicate whether or not this is a tail call.
+/// machine's calling convention.  This class uses low bit of the SubClassData
+/// field to indicate whether or not this is a tail call.  The rest of the bits
+/// hold the calling convention of the call.
 ///
 class CallInst : public Instruction {
   CallInst(const CallInst &CI);
@@ -502,8 +503,17 @@ public:
   virtual CallInst *clone() const;
   bool mayWriteToMemory() const { return true; }
 
-  bool isTailCall() const           { return SubclassData; }
-  void setTailCall(bool isTailCall = true) { SubclassData = isTailCall; }
+  bool isTailCall() const           { return SubclassData & 1; }
+  void setTailCall(bool isTailCall = true) {
+    SubclassData = (SubclassData & ~1) | isTailCall;
+  }
+
+  /// getCallingConv/setCallingConv - Get or set the calling convention of this
+  /// function call.
+  unsigned getCallingConv() const { return SubclassData >> 1; }
+  void setCallingConv(unsigned CC) {
+    SubclassData = (SubclassData & 1) | (CC << 1);
+  }
 
   /// getCalledFunction - Return the function being called by this instruction
   /// if it is a direct call.  If it is a call through a function pointer,
@@ -1165,7 +1175,9 @@ private:
 //===----------------------------------------------------------------------===//
 
 //===---------------------------------------------------------------------------
-/// InvokeInst - Invoke instruction
+
+/// InvokeInst - Invoke instruction.  The SubclassData field is used to hold the
+/// calling convention of the call.
 ///
 class InvokeInst : public TerminatorInst {
   InvokeInst(const InvokeInst &BI);
@@ -1184,6 +1196,13 @@ public:
 
   bool mayWriteToMemory() const { return true; }
 
+  /// getCallingConv/setCallingConv - Get or set the calling convention of this
+  /// function call.
+  unsigned getCallingConv() const { return SubclassData; }
+  void setCallingConv(unsigned CC) {
+    SubclassData = CC;
+  }
+
   /// getCalledFunction - Return the function called, or null if this is an
   /// indirect function invocation.
   ///
index 9df71a2743d46e5e07f9e6db12ae830629562b21..9d393e050b60f5b7cf0bcb9dee04cb31f0969664 100644 (file)
@@ -52,6 +52,11 @@ public:
     return CallSite();
   }
 
+  /// getCallingConv/setCallingConv - get or set the calling convention of the
+  /// call.
+  unsigned getCallingConv() const;
+  void setCallingConv(unsigned CC);
+
   /// getType - Return the type of the instruction that generated this call site
   ///
   const Type *getType() const { return I->getType(); }