[cfe-commits] r39331 - /cfe/cfe/trunk/Basic/TargetInfo.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:43:12 PDT 2007
Author: sabre
Date: Wed Jul 11 11:43:12 2007
New Revision: 39331
URL: http://llvm.org/viewvc/llvm-project?rev=39331&view=rev
Log:
Optimize #define analysis for the common case of a single target.
Modified:
cfe/cfe/trunk/Basic/TargetInfo.cpp
Modified: cfe/cfe/trunk/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Basic/TargetInfo.cpp?rev=39331&r1=39330&r2=39331&view=diff
==============================================================================
--- cfe/cfe/trunk/Basic/TargetInfo.cpp (original)
+++ cfe/cfe/trunk/Basic/TargetInfo.cpp Wed Jul 11 11:43:12 2007
@@ -68,6 +68,24 @@
std::map<std::string, std::string> PrimaryDefines;
GetTargetDefineMap(PrimaryTarget, PrimaryDefines);
+ // If we have no secondary targets, be a bit more efficient.
+ if (SecondaryTargets.empty()) {
+ for (std::map<std::string, std::string>::iterator I =
+ PrimaryDefines.begin(), E = PrimaryDefines.end(); I != E; ++I) {
+ // If this define is non-portable, turn it into #define_target, otherwise
+ // just use #define.
+ const char *Command = "#define ";
+ Buffer.insert(Buffer.end(), Command, Command+strlen(Command));
+
+ // Insert "defname defvalue\n".
+ Buffer.insert(Buffer.end(), I->first.begin(), I->first.end());
+ Buffer.push_back(' ');
+ Buffer.insert(Buffer.end(), I->second.begin(), I->second.end());
+ Buffer.push_back('\n');
+ }
+ return;
+ }
+
// Get the sets of secondary #defines.
std::vector<std::map<std::string, std::string> > SecondaryDefines;
SecondaryDefines.resize(SecondaryTargets.size());
More information about the cfe-commits
mailing list