]> granicus.if.org Git - clang/commitdiff
Add __builtin_va_list definitions for x86_64 and ppc64.
authorAnders Carlsson <andersca@mac.com>
Sat, 13 Oct 2007 00:45:48 +0000 (00:45 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 13 Oct 2007 00:45:48 +0000 (00:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42943 91177308-0d34-0410-b5e6-96231b3b80d8

Basic/TargetInfo.cpp
Driver/Targets.cpp
include/clang/Basic/TargetInfo.h

index 20f12c7455e1bfc0eec288659f3fb197519bee64..a3e0a2101d3d851a7681b555039be9996a3d5a0a 100644 (file)
@@ -260,4 +260,9 @@ void TargetInfo::getTargetBuiltins(const Builtin::Info *&Records,
   }
 }
 
+/// getVAListDeclaration - Return the declaration to use for
+/// __builtin_va_list, which is target-specific.
+const char *TargetInfo::getVAListDeclaration() const {
+  return PrimaryTarget->getVAListDeclaration();
+}
 
index bf05c645c9fdb08949c385467831c6ae828370a5..e7e6a051dacafd2043a2578647ec534ca996c067 100644 (file)
@@ -279,6 +279,32 @@ static void getX86Defines(std::vector<char> &Defs, bool is64Bit) {
   Define(Defs, "__LDBL_MIN__", "3.36210314311209350626e-4932L");
 }
 
+static const char* getI386VAListDeclaration() {
+  return "typedef char* __builtin_va_list;";
+}
+
+static const char* getX86_64VAListDeclaration() {
+  return 
+    "typedef struct __va_list_tag {"
+    "  unsigned gp_offset;"
+    "  unsigned fp_offset;"
+    "  void* overflow_arg_area;"
+    "  void* reg_save_area;"
+    "} __builtin_va_list[1];";
+}
+
+static const char* getPPCVAListDeclaration() {
+  return 
+    "typedef struct __va_list_tag {"
+    "  unsigned char gpr;"
+    "  unsigned char fpr;"
+    "  unsigned short reserved;"
+    "  void* overflow_arg_area;"
+    "  void* reg_save_area;"
+    "} __builtin_va_list[1];";
+}
+
+
 /// PPC builtin info.
 namespace PPC {
   enum {
@@ -336,6 +362,9 @@ public:
                                  unsigned &NumRecords) const {
     PPC::getBuiltins(Records, NumRecords);
   }
+  virtual const char *getVAListDeclaration() const {
+    return getPPCVAListDeclaration();
+  }  
 };
 } // end anonymous namespace.
 
@@ -350,6 +379,9 @@ public:
                                  unsigned &NumRecords) const {
     PPC::getBuiltins(Records, NumRecords);
   }
+  virtual const char *getVAListDeclaration() const {
+    return getPPCVAListDeclaration();
+  }  
 };
 } // end anonymous namespace.
 
@@ -364,6 +396,10 @@ public:
                                  unsigned &NumRecords) const {
     X86::getBuiltins(Records, NumRecords);
   }
+  
+  virtual const char *getVAListDeclaration() const {
+    return getI386VAListDeclaration();
+  }
 };
 } // end anonymous namespace.
 
@@ -378,6 +414,9 @@ public:
                                  unsigned &NumRecords) const {
     X86::getBuiltins(Records, NumRecords);
   }
+  virtual const char *getVAListDeclaration() const {
+    return getX86_64VAListDeclaration();
+  }  
 };
 } // end anonymous namespace.
 
@@ -398,6 +437,9 @@ public:
                                  unsigned &NumRecords) const {
     X86::getBuiltins(Records, NumRecords);
   }
+  virtual const char *getVAListDeclaration() const {
+    return getI386VAListDeclaration();
+  }  
 };
 } // end anonymous namespace.
 
index 02a0f88da517fadcdd9cffbf99f74d72f0d88e82..334f87851d9709c8c59d122b971488ed65de8229 100644 (file)
@@ -185,10 +185,8 @@ public:
 
   /// getVAListDeclaration - Return the declaration to use for
   /// __builtin_va_list, which is target-specific.
-  const char *getVAListDeclaration() const {
-    // FIXME: dispatch to target impl.
-    return "typedef char* __builtin_va_list;";
-  }
+  const char *getVAListDeclaration() const;
+
   ///===---- Some helper methods ------------------------------------------===//
 
   unsigned getCharWidth(SourceLocation Loc) {
@@ -244,6 +242,10 @@ public:
   /// "#define X Y\n".
   virtual void getTargetDefines(std::vector<char> &Defines) const = 0;
 
+  /// getVAListDeclaration - Return the declaration to use for
+  /// __builtin_va_list, which is target-specific.
+  virtual const char *getVAListDeclaration() const = 0;
+  
   /// getWCharWidth - Return the size of wchar_t in bits.
   ///
   void getWCharInfo(unsigned &Size, unsigned &Align) const {