[cfe-commits] r57139 - in /cfe/trunk/lib: Basic/Targets.cpp Lex/Preprocessor.cpp

Chris Lattner sabre at nondot.org
Sun Oct 5 14:49:27 PDT 2008


Author: lattner
Date: Sun Oct  5 16:49:27 2008
New Revision: 57139

URL: http://llvm.org/viewvc/llvm-project?rev=57139&view=rev
Log:
move __FLT_EVAL_METHOD__, __FLT_RADIX__, and __DECIMAL_DIG__ into
target indep code.

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=57139&r1=57138&r2=57139&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sun Oct  5 16:49:27 2008
@@ -119,12 +119,7 @@
   Define(Defs, "__NATURAL_ALIGNMENT__");
   Define(Defs, "__REGISTER_PREFIX__", "");
 
-  Define(Defs, "__FLT_EVAL_METHOD__", "0");
-  Define(Defs, "__FLT_RADIX__", "2");
-  Define(Defs, "__DECIMAL_DIG__", "33");
-
-  Define(Defs, "__LDBL_MIN_10_EXP__", "(-291)");
-  
+  // FIXME: Should be controlled by command line option.
   Define(Defs, "__LONG_DOUBLE_128__");
 }
 
@@ -158,10 +153,6 @@
   Define(Defs, "__SSE__");
   Define(Defs, "__MMX__");
   Define(Defs, "__REGISTER_PREFIX__", "");
-
-  Define(Defs, "__FLT_EVAL_METHOD__", "0");
-  Define(Defs, "__FLT_RADIX__", "2");
-  Define(Defs, "__DECIMAL_DIG__", "21");
 }
 
 /// getARMDefines - Return a set of the ARM-specific #defines that are
@@ -178,10 +169,6 @@
   Define(Defs, "__ARM_ARCH_6K__");
   Define(Defs, "__ARMEL__");
   Define(Defs, "__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", "20000");
-  
-  Define(Defs, "__FLT_EVAL_METHOD__", "0");
-  Define(Defs, "__FLT_RADIX__", "2");
-  Define(Defs, "__DECIMAL_DIG__", "17");
 }
 
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=57139&r1=57138&r2=57139&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Sun Oct  5 16:49:27 2008
@@ -612,11 +612,10 @@
     Buf.push_back('\n');
   }
   
+  char MacroBuf[60];
   if (const char *Prefix = TI.getUserLabelPrefix()) {
-    llvm::SmallString<20> TmpStr;
-    TmpStr += "__USER_LABEL_PREFIX__=";
-    TmpStr += Prefix;
-    DefineBuiltinMacro(Buf, TmpStr.c_str());
+    sprintf(MacroBuf, "__USER_LABEL_PREFIX__=%s", Prefix);
+    DefineBuiltinMacro(Buf, MacroBuf);
   }
   
   // Build configuration options.  FIXME: these should be controlled by
@@ -626,6 +625,13 @@
   DefineBuiltinMacro(Buf, "__NO_INLINE__=1");
   DefineBuiltinMacro(Buf, "__PIC__=1");
 
+  // Macros to control C99 numerics and <float.h>
+  DefineBuiltinMacro(Buf, "__FLT_EVAL_METHOD__=0");
+  DefineBuiltinMacro(Buf, "__FLT_RADIX__=2");
+  sprintf(MacroBuf, "__DECIMAL_DIG__=%d",
+          PickFP(&TI.getLongDoubleFormat(), -1/*FIXME*/, 17, 21, 33));
+  DefineBuiltinMacro(Buf, MacroBuf);
+  
   // Get other target #defines.
   TI.getTargetDefines(Buf);
   





More information about the cfe-commits mailing list