suck the rest of the FP macros out of the targets into the PP

llvm-svn: 57137
This commit is contained in:
Chris Lattner 2008-10-05 21:40:58 +00:00
parent 279d9814e5
commit 6da2f0dd2e
2 changed files with 54 additions and 106 deletions

View File

@ -119,48 +119,18 @@ static void getPowerPCDefines(std::vector<char> &Defs, bool is64Bit) {
Define(Defs, "__NATURAL_ALIGNMENT__");
Define(Defs, "__REGISTER_PREFIX__", "");
// Float macros.
Define(Defs, "__FLT_DIG__", "6");
Define(Defs, "__FLT_EPSILON__", "1.19209290e-7F");
Define(Defs, "__FLT_EVAL_METHOD__", "0");
Define(Defs, "__FLT_HAS_INFINITY__");
Define(Defs, "__FLT_HAS_QUIET_NAN__");
Define(Defs, "__FLT_MANT_DIG__", "24");
Define(Defs, "__FLT_MAX_10_EXP__", "38");
Define(Defs, "__FLT_MAX_EXP__", "128");
Define(Defs, "__FLT_MAX__", "3.40282347e+38F");
Define(Defs, "__FLT_MIN_10_EXP__", "(-37)");
Define(Defs, "__FLT_MIN_EXP__", "(-125)");
Define(Defs, "__FLT_MIN__", "1.17549435e-38F");
Define(Defs, "__FLT_RADIX__", "2");
Define(Defs, "__DECIMAL_DIG__", "33");
// Float macros.
Define(Defs, "__FLT_MIN__", "1.17549435e-38F");
// double macros.
Define(Defs, "__DBL_DIG__", "15");
Define(Defs, "__DBL_EPSILON__", "2.2204460492503131e-16");
Define(Defs, "__DBL_HAS_INFINITY__");
Define(Defs, "__DBL_HAS_QUIET_NAN__");
Define(Defs, "__DBL_MANT_DIG__", "53");
Define(Defs, "__DBL_MAX_10_EXP__", "308");
Define(Defs, "__DBL_MAX_EXP__", "1024");
Define(Defs, "__DBL_MAX__", "1.7976931348623157e+308");
Define(Defs, "__DBL_MIN_10_EXP__", "(-307)");
Define(Defs, "__DBL_MIN_EXP__", "(-1021)");
Define(Defs, "__DBL_MIN__", "2.2250738585072014e-308");
Define(Defs, "__DECIMAL_DIG__", "33");
// 128-bit long double macros.
Define(Defs, "__LDBL_DIG__", "31");
Define(Defs, "__LDBL_EPSILON__",
"4.94065645841246544176568792868221e-324L");
Define(Defs, "__LDBL_HAS_INFINITY__");
Define(Defs, "__LDBL_HAS_QUIET_NAN__");
Define(Defs, "__LDBL_MANT_DIG__", "106");
Define(Defs, "__LDBL_MAX_10_EXP__", "308");
Define(Defs, "__LDBL_MAX_EXP__", "1024");
Define(Defs, "__LDBL_MAX__",
"1.79769313486231580793728971405301e+308L");
Define(Defs, "__LDBL_MIN_10_EXP__", "(-291)");
Define(Defs, "__LDBL_MIN_EXP__", "(-968)");
Define(Defs, "__LDBL_MIN__",
"2.00416836000897277799610805135016e-292L");
Define(Defs, "__LONG_DOUBLE_128__");
@ -197,47 +167,17 @@ static void getX86Defines(std::vector<char> &Defs, bool is64Bit) {
Define(Defs, "__MMX__");
Define(Defs, "__REGISTER_PREFIX__", "");
// Float macros.
Define(Defs, "__FLT_DIG__", "6");
Define(Defs, "__FLT_EPSILON__", "1.19209290e-7F");
Define(Defs, "__FLT_EVAL_METHOD__", "0");
Define(Defs, "__FLT_HAS_INFINITY__");
Define(Defs, "__FLT_HAS_QUIET_NAN__");
Define(Defs, "__FLT_MANT_DIG__", "24");
Define(Defs, "__FLT_MAX_10_EXP__", "38");
Define(Defs, "__FLT_MAX_EXP__", "128");
Define(Defs, "__FLT_MAX__", "3.40282347e+38F");
Define(Defs, "__FLT_MIN_10_EXP__", "(-37)");
Define(Defs, "__FLT_MIN_EXP__", "(-125)");
Define(Defs, "__FLT_MIN__", "1.17549435e-38F");
Define(Defs, "__FLT_RADIX__", "2");
// Double macros.
Define(Defs, "__DBL_DIG__", "15");
Define(Defs, "__DBL_EPSILON__", "2.2204460492503131e-16");
Define(Defs, "__DBL_HAS_INFINITY__");
Define(Defs, "__DBL_HAS_QUIET_NAN__");
Define(Defs, "__DBL_MANT_DIG__", "53");
Define(Defs, "__DBL_MAX_10_EXP__", "308");
Define(Defs, "__DBL_MAX_EXP__", "1024");
Define(Defs, "__DBL_MAX__", "1.7976931348623157e+308");
Define(Defs, "__DBL_MIN_10_EXP__", "(-307)");
Define(Defs, "__DBL_MIN_EXP__", "(-1021)");
Define(Defs, "__DBL_MIN__", "2.2250738585072014e-308");
Define(Defs, "__DECIMAL_DIG__", "21");
// Float macros.
Define(Defs, "__FLT_MIN__", "1.17549435e-38F");
// Double macros.
Define(Defs, "__DBL_MIN__", "2.2250738585072014e-308");
// 80-bit Long double macros.
Define(Defs, "__LDBL_DIG__", "18");
Define(Defs, "__LDBL_EPSILON__", "1.08420217248550443401e-19L");
Define(Defs, "__LDBL_HAS_INFINITY__");
Define(Defs, "__LDBL_HAS_QUIET_NAN__");
Define(Defs, "__LDBL_MANT_DIG__", "64");
Define(Defs, "__LDBL_MAX_10_EXP__", "4932");
Define(Defs, "__LDBL_MAX_EXP__", "16384");
Define(Defs, "__LDBL_MAX__", "1.18973149535723176502e+4932L");
Define(Defs, "__LDBL_MIN_10_EXP__", "(-4931)");
Define(Defs, "__LDBL_MIN_EXP__", "(-16381)");
Define(Defs, "__LDBL_MIN__", "3.36210314311209350626e-4932L");
}
@ -256,47 +196,17 @@ static void getARMDefines(std::vector<char> &Defs) {
Define(Defs, "__ARMEL__");
Define(Defs, "__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", "20000");
Define(Defs, "__DECIMAL_DIG__", "17");
Define(Defs, "__FLT_EVAL_METHOD__", "0");
Define(Defs, "__FLT_RADIX__", "2");
Define(Defs, "__DECIMAL_DIG__", "17");
// Float macros.
Define(Defs, "__FLT_DIG__", "6");
Define(Defs, "__FLT_EPSILON__", "1.19209290e-7F");
Define(Defs, "__FLT_EVAL_METHOD__", "0");
Define(Defs, "__FLT_HAS_INFINITY__");
Define(Defs, "__FLT_HAS_QUIET_NAN__");
Define(Defs, "__FLT_MANT_DIG__", "24");
Define(Defs, "__FLT_MAX_10_EXP__", "38");
Define(Defs, "__FLT_MAX_EXP__", "128");
Define(Defs, "__FLT_MAX__", "3.40282347e+38F");
Define(Defs, "__FLT_MIN_10_EXP__", "(-37)");
Define(Defs, "__FLT_MIN_EXP__", "(-125)");
Define(Defs, "__FLT_MIN__", "1.17549435e-38F");
// Double macros.
Define(Defs, "__DBL_DIG__", "15");
Define(Defs, "__DBL_EPSILON__", "2.2204460492503131e-16");
Define(Defs, "__DBL_HAS_INFINITY__");
Define(Defs, "__DBL_HAS_QUIET_NAN__");
Define(Defs, "__DBL_MANT_DIG__", "53");
Define(Defs, "__DBL_MAX_10_EXP__", "308");
Define(Defs, "__DBL_MAX_EXP__", "1024");
Define(Defs, "__DBL_MAX__", "1.7976931348623157e+308");
Define(Defs, "__DBL_MIN_10_EXP__", "(-307)");
Define(Defs, "__DBL_MIN_EXP__", "(-1021)");
Define(Defs, "__DBL_MIN__", "2.2250738585072014e-308");
// 64-bit Long double macros (same as double).
Define(Defs, "__LDBL_DIG__", "15");
Define(Defs, "__LDBL_EPSILON__", "2.2204460492503131e-16");
Define(Defs, "__LDBL_HAS_INFINITY__");
Define(Defs, "__LDBL_HAS_QUIET_NAN__");
Define(Defs, "__LDBL_MANT_DIG__", "53");
Define(Defs, "__LDBL_MAX_10_EXP__", "308");
Define(Defs, "__LDBL_MAX_EXP__", "1024");
Define(Defs, "__LDBL_MAX__", "1.7976931348623157e+308");
Define(Defs, "__LDBL_MIN_10_EXP__", "(-307)");
Define(Defs, "__LDBL_MIN_EXP__", "(-1021)");
Define(Defs, "__LDBL_MIN__", "2.2250738585072014e-308");
}

View File

@ -395,14 +395,52 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEESingleVal,
static void DefineFloatMacros(std::vector<char> &Buf, const char *Prefix,
const llvm::fltSemantics *Sem) {
const char *DenormMin = PickFP(Sem, "1.40129846e-45F",
"4.9406564584124654e-324",
"3.64519953188247460253e-4951L",
"4.94065645841246544176568792868221e-324L");
const char *DenormMin, *Epsilon, *Max, *Min;
DenormMin = PickFP(Sem, "1.40129846e-45F", "4.9406564584124654e-324",
"3.64519953188247460253e-4951L",
"4.94065645841246544176568792868221e-324L");
int Digits = PickFP(Sem, 6, 15, 18, 31);
Epsilon = PickFP(Sem, "1.19209290e-7F", "2.2204460492503131e-16",
"1.08420217248550443401e-19L",
"4.94065645841246544176568792868221e-324L");
int HasInifinity = 1, HasQuietNaN = 1;
int MantissaDigits = PickFP(Sem, 24, 53, 64, 106);
int Min10Exp = PickFP(Sem, -37, -307, -4931, -291);
int Max10Exp = PickFP(Sem, 38, 308, 4932, 308);
int MinExp = PickFP(Sem, -125, -1021, -16381, -968);
int MaxExp = PickFP(Sem, 128, 1024, 16384, 1024);
Min = PickFP(Sem, "1.17549435e-38F", "2.2250738585072014e-308",
"3.36210314311209350626e-4932L",
"2.00416836000897277799610805135016e-292L");
Max = PickFP(Sem, "3.40282347e+38F", "1.7976931348623157e+308",
"1.18973149535723176502e+4932L",
"1.79769313486231580793728971405301e+308L");
char MacroBuf[60];
sprintf(MacroBuf, "__%s_DENORM_MIN__=%s", Prefix, DenormMin);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_DIG__=%d", Prefix, Digits);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_EPSILON__=%s", Prefix, Epsilon);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_HAS_INFINITY__=%d", Prefix, HasInifinity);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_HAS_QUIET_NAN__=%d", Prefix, HasQuietNaN);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_MANT_DIG__=%d", Prefix, MantissaDigits);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_MAX_10_EXP__=%d", Prefix, Max10Exp);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_MAX_EXP__=%d", Prefix, MaxExp);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_MAX__=%s", Prefix, Max);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_MIN_10_EXP__=(%d)", Prefix, Min10Exp);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_MIN_EXP__=(%d)", Prefix, MinExp);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__%s_MIN__=%s", Prefix, Min);
DefineBuiltinMacro(Buf, MacroBuf);
}