aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-05 19:44:25 +0000
committerChris Lattner <sabre@nondot.org>2008-10-05 19:44:25 +0000
commit9b533164570a67c81ad49f3691f02608530a042e (patch)
tree83bd7df1dca8796faa600a46796e146c4c553674 /lib/Lex/Preprocessor.cpp
parent2b43ad9588b8c7f0c9fdc1d95f4f972257215fca (diff)
eliminate __USER_LABEL_PREFIX__ from the Targets.cpp file, start moving
integer size #defines over to the Preprocessor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index c97cda3bcd..5d1f119c8c 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -427,6 +427,7 @@ static void InitializePredefinedMacros(Preprocessor &PP,
// on other things like the runtime I believe.
DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");
}
+
if (PP.getLangOptions().ObjC2)
DefineBuiltinMacro(Buf, "OBJC_NEW_PROPERTIES");
@@ -465,29 +466,45 @@ static void InitializePredefinedMacros(Preprocessor &PP,
// Initialize target-specific preprocessor defines.
+ const TargetInfo &TI = PP.getTargetInfo();
+
+ // Define type sizing macros based on the target properties.
+ assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
+ DefineBuiltinMacro(Buf, "__CHAR_BIT__=8");
+ DefineBuiltinMacro(Buf, "__SCHAR_MAX__=127");
+
+ assert(TI.getShortWidth() == 16 && "Only support 16-bit short so far");
+ DefineBuiltinMacro(Buf, "__CHAR_BIT__=8");
+ DefineBuiltinMacro(Buf, "__SHRT_MAX__=32767");
+
+
+ assert(TI.getLongLongWidth() == 64 && "Only support 64-bit long long so far");
+ DefineBuiltinMacro(Buf, "__LONG_LONG_MAX__=9223372036854775807LL");
+
// Add __builtin_va_list typedef.
{
- const char *VAList = PP.getTargetInfo().getVAListDeclaration();
+ const char *VAList = TI.getVAListDeclaration();
Buf.insert(Buf.end(), VAList, VAList+strlen(VAList));
Buf.push_back('\n');
}
- if (const char *Prefix = PP.getTargetInfo().getUserLabelPrefix()) {
+ if (const char *Prefix = TI.getUserLabelPrefix()) {
llvm::SmallString<20> TmpStr;
TmpStr += "__USER_LABEL_PREFIX__=";
TmpStr += Prefix;
DefineBuiltinMacro(Buf, TmpStr.c_str());
}
- // Get the target #defines.
- PP.getTargetInfo().getTargetDefines(Buf);
-
- // Build configuration options.
+ // Build configuration options. FIXME: these should be controlled by
+ // command line options or something.
DefineBuiltinMacro(Buf, "__DYNAMIC__=1");
DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0");
DefineBuiltinMacro(Buf, "__NO_INLINE__=1");
DefineBuiltinMacro(Buf, "__PIC__=1");
+
+ // Get other target #defines.
+ TI.getTargetDefines(Buf);
// FIXME: Should emit a #line directive here.
}