[cfe-commits] r57130 - in /cfe/trunk/lib: Basic/Targets.cpp Lex/Preprocessor.cpp
Chris Lattner
sabre at nondot.org
Sun Oct 5 12:44:25 PDT 2008
Author: lattner
Date: Sun Oct 5 14:44:25 2008
New Revision: 57130
URL: http://llvm.org/viewvc/llvm-project?rev=57130&view=rev
Log:
eliminate __USER_LABEL_PREFIX__ from the Targets.cpp file, start moving
integer size #defines over to the Preprocessor.
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=57130&r1=57129&r2=57130&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sun Oct 5 14:44:25 2008
@@ -129,14 +129,9 @@
Define(Defs, "__UINTMAX_TYPE__", "long long unsigned int");
}
Define(Defs, "__INT_MAX__", "2147483647");
- Define(Defs, "__LONG_LONG_MAX__", "9223372036854775807LL");
- Define(Defs, "__CHAR_BIT__", "8");
- Define(Defs, "__SCHAR_MAX__", "127");
- Define(Defs, "__SHRT_MAX__", "32767");
Define(Defs, "__SIZE_TYPE__", "long unsigned int");
// Subtarget options.
- Define(Defs, "__USER_LABEL_PREFIX__", "_");
Define(Defs, "__NATURAL_ALIGNMENT__");
Define(Defs, "__REGISTER_PREFIX__", "");
@@ -229,11 +224,7 @@
Define(Defs, "__UINTMAX_TYPE__", "long long unsigned int");
}
Define(Defs, "__SIZE_TYPE__", "long unsigned int");
- Define(Defs, "__CHAR_BIT__", "8");
Define(Defs, "__INT_MAX__", "2147483647");
- Define(Defs, "__LONG_LONG_MAX__", "9223372036854775807LL");
- Define(Defs, "__SCHAR_MAX__", "127");
- Define(Defs, "__SHRT_MAX__", "32767");
// Subtarget options.
Define(Defs, "__nocona");
@@ -313,11 +304,7 @@
Define(Defs, "__UINTMAX_TYPE__", "long long unsigned int");
Define(Defs, "__SIZE_TYPE__", "long unsigned int");
- Define(Defs, "__CHAR_BIT__", "8");
Define(Defs, "__INT_MAX__", "2147483647");
- Define(Defs, "__LONG_LONG_MAX__", "9223372036854775807LL");
- Define(Defs, "__SCHAR_MAX__", "127");
- Define(Defs, "__SHRT_MAX__", "32767");
// Subtarget options. [hard coded to v6 for now]
Define(Defs, "__ARM_ARCH_6K__");
@@ -719,11 +706,11 @@
class LinuxX86_32TargetInfo : public X86_32TargetInfo {
public:
LinuxX86_32TargetInfo(const std::string& triple) : X86_32TargetInfo(triple) {
+ UserLabelPrefix = "";
}
virtual void getTargetDefines(std::vector<char> &Defines) const {
X86_32TargetInfo::getTargetDefines(Defines);
getLinuxDefines(Defines);
- Define(Defines, "__USER_LABEL_PREFIX__", "");
}
};
} // end anonymous namespace
@@ -750,7 +737,6 @@
Define(Defines, "WINNT");
Define(Defines, "_X86_");
Define(Defines, "__MSVCRT__");
- Define(Defines, "__USER_LABEL_PREFIX__", "_");
}
};
} // end anonymous namespace
@@ -786,11 +772,11 @@
class LinuxX86_64TargetInfo : public X86_64TargetInfo {
public:
LinuxX86_64TargetInfo(const std::string& triple) : X86_64TargetInfo(triple) {
+ UserLabelPrefix = "";
}
virtual void getTargetDefines(std::vector<char> &Defines) const {
X86_64TargetInfo::getTargetDefines(Defines);
getLinuxDefines(Defines);
- Define(Defines, "__USER_LABEL_PREFIX__", "");
}
};
} // end anonymous namespace
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=57130&r1=57129&r2=57130&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Sun Oct 5 14:44:25 2008
@@ -427,6 +427,7 @@
// 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 @@
// 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.
}
More information about the cfe-commits
mailing list