From 1ae6ec457431c0d9a72fbef221a3fb766e3fdb41 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 10 Nov 2015 21:01:46 +0000 Subject: [PATCH] [WebAssembly] Change long double to be quadruple-precision floating point. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252646 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 2 ++ test/CodeGen/wasm-arguments.c | 4 +-- test/Driver/wasm32-unknown-unknown.cpp | 4 +-- test/Driver/wasm64-unknown-unknown.cpp | 4 +-- test/Preprocessor/init.c | 48 +++++++++++++------------- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 39bddd1f61..7481adab6b 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -7081,6 +7081,8 @@ public: LargeArrayAlign = 128; SimdDefaultAlign = 128; SigAtomicType = SignedLong; + LongDoubleWidth = LongDoubleAlign = 128; + LongDoubleFormat = &llvm::APFloat::IEEEquad; } protected: diff --git a/test/CodeGen/wasm-arguments.c b/test/CodeGen/wasm-arguments.c index 52388046f9..723632b62f 100644 --- a/test/CodeGen/wasm-arguments.c +++ b/test/CodeGen/wasm-arguments.c @@ -5,8 +5,8 @@ // Basic argument/attribute tests for WebAssembly -// WEBASSEMBLY32: define void @f0(i32 %i, i32 %j, i64 %k, double %l, double %m) -// WEBASSEMBLY64: define void @f0(i32 %i, i64 %j, i64 %k, double %l, double %m) +// WEBASSEMBLY32: define void @f0(i32 %i, i32 %j, i64 %k, double %l, fp128 %m) +// WEBASSEMBLY64: define void @f0(i32 %i, i64 %j, i64 %k, double %l, fp128 %m) void f0(int i, long j, long long k, double l, long double m) {} typedef struct { diff --git a/test/Driver/wasm32-unknown-unknown.cpp b/test/Driver/wasm32-unknown-unknown.cpp index e6fbb62a80..c47428796d 100644 --- a/test/Driver/wasm32-unknown-unknown.cpp +++ b/test/Driver/wasm32-unknown-unknown.cpp @@ -37,7 +37,7 @@ int align_f = __alignof(float); // CHECK: @align_d = global i32 8 int align_d = __alignof(double); -// CHECK: @align_ld = global i32 8 +// CHECK: @align_ld = global i32 16 int align_ld = __alignof(long double); // CHECK: @align_vl = global i32 4 @@ -97,7 +97,7 @@ float check_float() { return 0; } // CHECK: double @check_double() double check_double() { return 0; } -// CHECK: double @check_longdouble() +// CHECK: fp128 @check_longdouble() long double check_longdouble() { return 0; } } diff --git a/test/Driver/wasm64-unknown-unknown.cpp b/test/Driver/wasm64-unknown-unknown.cpp index 78b8c76718..c33f4e56a6 100644 --- a/test/Driver/wasm64-unknown-unknown.cpp +++ b/test/Driver/wasm64-unknown-unknown.cpp @@ -37,7 +37,7 @@ int align_f = __alignof(float); // CHECK: @align_d = global i32 8 int align_d = __alignof(double); -// CHECK: @align_ld = global i32 8 +// CHECK: @align_ld = global i32 16 int align_ld = __alignof(long double); // CHECK: @align_vl = global i32 8 @@ -97,7 +97,7 @@ float check_float() { return 0; } // CHECK: double @check_double() double check_double() { return 0; } -// CHECK: double @check_longdouble() +// CHECK: fp128 @check_longdouble() long double check_longdouble() { return 0; } } diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 7ddb9464d4..099e585616 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -8549,20 +8549,20 @@ // WEBASSEMBLY32-NEXT:#define __INT_LEAST8_MAX__ 127{{$}} // WEBASSEMBLY32-NEXT:#define __INT_LEAST8_TYPE__ signed char{{$}} // WEBASSEMBLY32-NEXT:#define __INT_MAX__ 2147483647{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_DECIMAL_DIG__ 17{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_DIG__ 15{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_EPSILON__ 2.2204460492503131e-16L{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_DECIMAL_DIG__ 36{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_DIG__ 33{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L{{$}} // WEBASSEMBLY32-NEXT:#define __LDBL_HAS_DENORM__ 1{{$}} // WEBASSEMBLY32-NEXT:#define __LDBL_HAS_INFINITY__ 1{{$}} // WEBASSEMBLY32-NEXT:#define __LDBL_HAS_QUIET_NAN__ 1{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_MANT_DIG__ 53{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_MAX_10_EXP__ 308{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_MAX_EXP__ 1024{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_MAX__ 1.7976931348623157e+308L{{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_MIN_10_EXP__ (-307){{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_MIN_EXP__ (-1021){{$}} -// WEBASSEMBLY32-NEXT:#define __LDBL_MIN__ 2.2250738585072014e-308L{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_MANT_DIG__ 113{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_MAX_10_EXP__ 4932{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_MAX_EXP__ 16384{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L{{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_MIN_10_EXP__ (-4931){{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_MIN_EXP__ (-16381){{$}} +// WEBASSEMBLY32-NEXT:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L{{$}} // WEBASSEMBLY32-NEXT:#define __LITTLE_ENDIAN__ 1{{$}} // WEBASSEMBLY32-NEXT:#define __LONG_LONG_MAX__ 9223372036854775807LL{{$}} // WEBASSEMBLY32-NEXT:#define __LONG_MAX__ 2147483647L{{$}} @@ -8587,7 +8587,7 @@ // WEBASSEMBLY32-NEXT:#define __SIZEOF_FLOAT__ 4{{$}} // WEBASSEMBLY32-NEXT:#define __SIZEOF_INT128__ 16{{$}} // WEBASSEMBLY32-NEXT:#define __SIZEOF_INT__ 4{{$}} -// WEBASSEMBLY32-NEXT:#define __SIZEOF_LONG_DOUBLE__ 8{{$}} +// WEBASSEMBLY32-NEXT:#define __SIZEOF_LONG_DOUBLE__ 16{{$}} // WEBASSEMBLY32-NEXT:#define __SIZEOF_LONG_LONG__ 8{{$}} // WEBASSEMBLY32-NEXT:#define __SIZEOF_LONG__ 4{{$}} // WEBASSEMBLY32-NEXT:#define __SIZEOF_POINTER__ 4{{$}} @@ -8865,20 +8865,20 @@ // WEBASSEMBLY64-NEXT:#define __INT_LEAST8_MAX__ 127{{$}} // WEBASSEMBLY64-NEXT:#define __INT_LEAST8_TYPE__ signed char{{$}} // WEBASSEMBLY64-NEXT:#define __INT_MAX__ 2147483647{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_DECIMAL_DIG__ 17{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_DIG__ 15{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_EPSILON__ 2.2204460492503131e-16L{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_DECIMAL_DIG__ 36{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_DIG__ 33{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L{{$}} // WEBASSEMBLY64-NEXT:#define __LDBL_HAS_DENORM__ 1{{$}} // WEBASSEMBLY64-NEXT:#define __LDBL_HAS_INFINITY__ 1{{$}} // WEBASSEMBLY64-NEXT:#define __LDBL_HAS_QUIET_NAN__ 1{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_MANT_DIG__ 53{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_MAX_10_EXP__ 308{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_MAX_EXP__ 1024{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_MAX__ 1.7976931348623157e+308L{{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_MIN_10_EXP__ (-307){{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_MIN_EXP__ (-1021){{$}} -// WEBASSEMBLY64-NEXT:#define __LDBL_MIN__ 2.2250738585072014e-308L{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_MANT_DIG__ 113{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_MAX_10_EXP__ 4932{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_MAX_EXP__ 16384{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L{{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_MIN_10_EXP__ (-4931){{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_MIN_EXP__ (-16381){{$}} +// WEBASSEMBLY64-NEXT:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L{{$}} // WEBASSEMBLY64-NEXT:#define __LITTLE_ENDIAN__ 1{{$}} // WEBASSEMBLY64-NEXT:#define __LONG_LONG_MAX__ 9223372036854775807LL{{$}} // WEBASSEMBLY64-NEXT:#define __LONG_MAX__ 9223372036854775807L{{$}} @@ -8903,7 +8903,7 @@ // WEBASSEMBLY64-NEXT:#define __SIZEOF_FLOAT__ 4{{$}} // WEBASSEMBLY64-NEXT:#define __SIZEOF_INT128__ 16{{$}} // WEBASSEMBLY64-NEXT:#define __SIZEOF_INT__ 4{{$}} -// WEBASSEMBLY64-NEXT:#define __SIZEOF_LONG_DOUBLE__ 8{{$}} +// WEBASSEMBLY64-NEXT:#define __SIZEOF_LONG_DOUBLE__ 16{{$}} // WEBASSEMBLY64-NEXT:#define __SIZEOF_LONG_LONG__ 8{{$}} // WEBASSEMBLY64-NEXT:#define __SIZEOF_LONG__ 8{{$}} // WEBASSEMBLY64-NEXT:#define __SIZEOF_POINTER__ 8{{$}} -- 2.40.0