From: Chris Lattner Date: Sun, 5 Oct 2008 21:49:27 +0000 (+0000) Subject: move __FLT_EVAL_METHOD__, __FLT_RADIX__, and __DECIMAL_DIG__ into X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12f09260294175dc097b843d3d06d048b9cd64a3;p=clang move __FLT_EVAL_METHOD__, __FLT_RADIX__, and __DECIMAL_DIG__ into target indep code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57139 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index d990dd0d59..424be5f268 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -119,12 +119,7 @@ static void getPowerPCDefines(std::vector &Defs, bool is64Bit) { 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 @@ static void getX86Defines(std::vector &Defs, bool is64Bit) { 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 @@ static void getARMDefines(std::vector &Defs) { 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"); } //===----------------------------------------------------------------------===// diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 0c1accd6c2..6c5daae13b 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -612,11 +612,10 @@ static void InitializePredefinedMacros(Preprocessor &PP, 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 @@ static void InitializePredefinedMacros(Preprocessor &PP, DefineBuiltinMacro(Buf, "__NO_INLINE__=1"); DefineBuiltinMacro(Buf, "__PIC__=1"); + // Macros to control C99 numerics and + 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);