[cfe-commits] r122956 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp test/CodeGen/bool_test_darwin.c test/CodeGen/va_list_test_svr4.c
Roman Divacky
rdivacky at freebsd.org
Thu Jan 6 00:27:10 PST 2011
Author: rdivacky
Date: Thu Jan 6 02:27:10 2011
New Revision: 122956
URL: http://llvm.org/viewvc/llvm-project?rev=122956&view=rev
Log:
PowerPC fixes.
Fix the width and align of bool type on Darwin to be 32bits
while keeping it 8 everywhere else.
Change the definition of va_list to default to SV4 ABI one
and let darwin subtarget override this.
Both changes submitted by Nathan Whitehorn and reviewed
by Rafael Espindola.
Added:
cfe/trunk/test/CodeGen/bool_test_darwin.c
cfe/trunk/test/CodeGen/va_list_test_svr4.c
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=122956&r1=122955&r2=122956&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Jan 6 02:27:10 2011
@@ -66,6 +66,7 @@
bool TLSSupported;
bool NoAsmVariants; // True if {|} are normal characters.
unsigned char PointerWidth, PointerAlign;
+ unsigned char BoolWidth, BoolAlign;
unsigned char IntWidth, IntAlign;
unsigned char FloatWidth, FloatAlign;
unsigned char DoubleWidth, DoubleAlign;
@@ -164,8 +165,8 @@
/// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this
/// target, in bits.
- unsigned getBoolWidth(bool isWide = false) const { return 8; } // FIXME
- unsigned getBoolAlign(bool isWide = false) const { return 8; } // FIXME
+ unsigned getBoolWidth() const { return BoolWidth; }
+ unsigned getBoolAlign() const { return BoolAlign; }
unsigned getCharWidth() const { return 8; } // FIXME
unsigned getCharAlign() const { return 8; } // FIXME
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=122956&r1=122955&r2=122956&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Thu Jan 6 02:27:10 2011
@@ -26,6 +26,7 @@
TLSSupported = true;
NoAsmVariants = false;
PointerWidth = PointerAlign = 32;
+ BoolWidth = BoolAlign = 8;
IntWidth = IntAlign = 32;
LongWidth = LongAlign = 32;
LongLongWidth = LongLongAlign = 64;
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=122956&r1=122955&r2=122956&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jan 6 02:27:10 2011
@@ -479,17 +479,6 @@
virtual void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const;
- virtual const char *getVAListDeclaration() const {
- return "typedef char* __builtin_va_list;";
- // This is the right definition for ABI/V4: System V.4/eabi.
- /*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];";*/
- }
virtual void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const;
virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
@@ -754,7 +743,18 @@
"i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32";
if (getTriple().getOS() == llvm::Triple::FreeBSD)
- this->SizeType = TargetInfo::UnsignedInt;
+ SizeType = UnsignedInt;
+ }
+
+ virtual const char *getVAListDeclaration() const {
+ // This is the ELF definition, and is overridden by the Darwin sub-target
+ 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];";
}
};
} // end anonymous namespace.
@@ -770,17 +770,24 @@
DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
"i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64";
}
+ virtual const char *getVAListDeclaration() const {
+ return "typedef char* __builtin_va_list;";
+ }
};
} // end anonymous namespace.
namespace {
-class DarwinPPCTargetInfo :
- public DarwinTargetInfo<PPCTargetInfo> {
+class DarwinPPC32TargetInfo :
+ public DarwinTargetInfo<PPC32TargetInfo> {
public:
- DarwinPPCTargetInfo(const std::string& triple)
- : DarwinTargetInfo<PPCTargetInfo>(triple) {
+ DarwinPPC32TargetInfo(const std::string& triple)
+ : DarwinTargetInfo<PPC32TargetInfo>(triple) {
HasAlignMac68kSupport = true;
+ BoolWidth = BoolAlign = 32; //XXX support -mone-byte-bool?
+ }
+ virtual const char *getVAListDeclaration() const {
+ return "typedef char* __builtin_va_list;";
}
};
@@ -2578,7 +2585,7 @@
case llvm::Triple::ppc:
if (os == llvm::Triple::Darwin)
- return new DarwinPPCTargetInfo(T);
+ return new DarwinPPC32TargetInfo(T);
else if (os == llvm::Triple::FreeBSD)
return new FreeBSDTargetInfo<PPC32TargetInfo>(T);
return new PPC32TargetInfo(T);
Added: cfe/trunk/test/CodeGen/bool_test_darwin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bool_test_darwin.c?rev=122956&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/bool_test_darwin.c (added)
+++ cfe/trunk/test/CodeGen/bool_test_darwin.c Thu Jan 6 02:27:10 2011
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple powerpc-apple-darwin -emit-llvm -o - %s| FileCheck %s
+
+int boolsize = sizeof(_Bool);
+//CHECK: boolsize = global i32 4, align 4
+
Added: cfe/trunk/test/CodeGen/va_list_test_svr4.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/va_list_test_svr4.c?rev=122956&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/va_list_test_svr4.c (added)
+++ cfe/trunk/test/CodeGen/va_list_test_svr4.c Thu Jan 6 02:27:10 2011
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-freebsd -emit-llvm -o - %s| FileCheck %s
+
+#include <stdarg.h>
+
+int va_list_size = sizeof(va_list);
+// CHECK: va_list_size = global i32 12, align 4
More information about the cfe-commits
mailing list