aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/CBackend
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-04-02 23:52:49 +0000
committerDan Gohman <gohman@apple.com>2008-04-02 23:52:49 +0000
commit3f795233d2a7557f6df6746a7cfe85fabf0dd6ae (patch)
tree08d3ada45b7bcd99cb581d7516ebb7eb9f5ac008 /lib/Target/CBackend
parent435e4ca9f5ad18be53587321a3da42e5a4cf3e28 (diff)
downloadexternal_llvm-3f795233d2a7557f6df6746a7cfe85fabf0dd6ae.zip
external_llvm-3f795233d2a7557f6df6746a7cfe85fabf0dd6ae.tar.gz
external_llvm-3f795233d2a7557f6df6746a7cfe85fabf0dd6ae.tar.bz2
Suppress the 128-bit integer typedef on 32-bit targets, because
it causes compile errors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49122 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend')
-rw-r--r--lib/Target/CBackend/CBackend.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 161c6be..e8ac954 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -1363,7 +1363,8 @@ void CWriter::writeOperandWithCast(Value* Operand, const ICmpInst &Cmp) {
// generateCompilerSpecificCode - This is where we add conditional compilation
// directives to cater to specific compilers as need be.
//
-static void generateCompilerSpecificCode(std::ostream& Out) {
+static void generateCompilerSpecificCode(std::ostream& Out,
+ const TargetData *TD) {
// Alloca is hard to get, and we don't want to include stdlib.h here.
Out << "/* get a declaration for alloca */\n"
<< "#if defined(__CYGWIN__) || defined(__MINGW32__)\n"
@@ -1480,10 +1481,15 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
<< "#define __builtin_stack_restore(X) /* noop */\n"
<< "#endif\n\n";
- Out << "#ifdef __GNUC__ /* 128-bit integer types */\n"
- << "typedef int __attribute__((mode(TI))) llvmInt128;\n"
- << "typedef unsigned __attribute__((mode(TI))) llvmUInt128;\n"
- << "#endif\n\n";
+ // Output typedefs for 128-bit integers. If these are needed with a
+ // 32-bit target or with a C compiler that doesn't support mode(TI),
+ // more drastic measures will be needed.
+ if (TD->getPointerSize() >= 8) {
+ Out << "#ifdef __GNUC__ /* 128-bit integer types */\n"
+ << "typedef int __attribute__((mode(TI))) llvmInt128;\n"
+ << "typedef unsigned __attribute__((mode(TI))) llvmUInt128;\n"
+ << "#endif\n\n";
+ }
// Output target-specific code that should be inserted into main.
Out << "#define CODE_FOR_MAIN() /* Any target-specific code for main()*/\n";
@@ -1568,7 +1574,7 @@ bool CWriter::doInitialization(Module &M) {
Out << "/* Provide Declarations */\n";
Out << "#include <stdarg.h>\n"; // Varargs support
Out << "#include <setjmp.h>\n"; // Unwind support
- generateCompilerSpecificCode(Out);
+ generateCompilerSpecificCode(Out, TD);
// Provide a definition for `bool' if not compiling with a C++ compiler.
Out << "\n"