[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/pranavk created https://github.com/llvm/llvm-project/pull/67196 None >From 8c07729b195fa78133258b03a31e8668d70a922d Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Sep 2023 20:50:32 + Subject: [PATCH] [clang] Predefined macros for float128 support --- clang/lib/Frontend/InitPreprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index e5db8a654e6707d..9e4d4d398a21da5 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1076,6 +1076,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); + if (TI.hasFloat128Type()) +DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q"); // Define a __POINTER_WIDTH__ macro for stdint.h. Builder.defineMacro("__POINTER_WIDTH__", ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/pranavk edited https://github.com/llvm/llvm-project/pull/67196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
llvmbot wrote: @llvm/pr-subscribers-clang Changes Expose some predefined macros for Float128 support. --- Full diff: https://github.com/llvm/llvm-project/pull/67196.diff 1 Files Affected: - (modified) clang/lib/Frontend/InitPreprocessor.cpp (+2) ``diff diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index e5db8a654e6707d..9e4d4d398a21da5 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1076,6 +1076,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); + if (TI.hasFloat128Type()) +DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q"); // Define a __POINTER_WIDTH__ macro for stdint.h. Builder.defineMacro("__POINTER_WIDTH__", `` https://github.com/llvm/llvm-project/pull/67196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/pranavk updated https://github.com/llvm/llvm-project/pull/67196 >From 8c07729b195fa78133258b03a31e8668d70a922d Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Sep 2023 20:50:32 + Subject: [PATCH 1/2] [clang] Predefined macros for float128 support --- clang/lib/Frontend/InitPreprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index e5db8a654e6707d..9e4d4d398a21da5 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1076,6 +1076,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); + if (TI.hasFloat128Type()) +DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q"); // Define a __POINTER_WIDTH__ macro for stdint.h. Builder.defineMacro("__POINTER_WIDTH__", >From 0978352c91562f82229daeb1fb65f27f04f93d97 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Sep 2023 21:23:51 + Subject: [PATCH 2/2] Fix test --- clang/test/Preprocessor/init.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 59c5122afe1e4c3..395c4cebfa5be76 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1576,6 +1576,20 @@ // EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_DECIMAL_DIG__ 36 +// WEBASSEMBLY-NEXT:#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966Q +// WEBASSEMBLY-NEXT:#define __FLT128_DIG__ 33 +// WEBASSEMBLY-NEXT:#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34Q +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_DENORM__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_INFINITY__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_QUIET_NAN__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_MANT_DIG__ 113 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX_10_EXP__ 4932 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX_EXP__ 16384 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932Q +// WEBASSEMBLY-NEXT:#define __FLT128_MIN_10_EXP__ (-4931) +// WEBASSEMBLY-NEXT:#define __FLT128_MIN_EXP__ (-16381) +// WEBASSEMBLY-NEXT:#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932Q // WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__ // WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__ // WEBASSEMBLY-NOT:#define __FLT16_DIG__ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
@@ -1076,6 +1076,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); + if (TI.hasFloat128Type()) +DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q"); alexander-shaposhnikov wrote: This needs tests (see e.g. https://reviews.llvm.org/D111382, https://github.com/llvm/llvm-project/blob/main/clang/test/Preprocessor) https://github.com/llvm/llvm-project/pull/67196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
@@ -1076,6 +1076,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); + if (TI.hasFloat128Type()) +DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q"); pranavk wrote: I am not adding any new float type or any literal suffix (unlike other revision you pointed by Ray). This is only adding float macros for which I modified the test that was expecting it. https://github.com/llvm/llvm-project/pull/67196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/pranavk updated https://github.com/llvm/llvm-project/pull/67196 >From 8c07729b195fa78133258b03a31e8668d70a922d Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Sep 2023 20:50:32 + Subject: [PATCH 1/3] [clang] Predefined macros for float128 support --- clang/lib/Frontend/InitPreprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index e5db8a654e6707d..9e4d4d398a21da5 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1076,6 +1076,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); + if (TI.hasFloat128Type()) +DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q"); // Define a __POINTER_WIDTH__ macro for stdint.h. Builder.defineMacro("__POINTER_WIDTH__", >From 0978352c91562f82229daeb1fb65f27f04f93d97 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Sep 2023 21:23:51 + Subject: [PATCH 2/3] Fix test --- clang/test/Preprocessor/init.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 59c5122afe1e4c3..395c4cebfa5be76 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1576,6 +1576,20 @@ // EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_DECIMAL_DIG__ 36 +// WEBASSEMBLY-NEXT:#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966Q +// WEBASSEMBLY-NEXT:#define __FLT128_DIG__ 33 +// WEBASSEMBLY-NEXT:#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34Q +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_DENORM__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_INFINITY__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_QUIET_NAN__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_MANT_DIG__ 113 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX_10_EXP__ 4932 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX_EXP__ 16384 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932Q +// WEBASSEMBLY-NEXT:#define __FLT128_MIN_10_EXP__ (-4931) +// WEBASSEMBLY-NEXT:#define __FLT128_MIN_EXP__ (-16381) +// WEBASSEMBLY-NEXT:#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932Q // WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__ // WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__ // WEBASSEMBLY-NOT:#define __FLT16_DIG__ >From 98b9a38df6ae039aae014929e26939e38d8d7f55 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Tue, 26 Sep 2023 18:22:12 + Subject: [PATCH 3/3] Add FLOAT128 macros to NETBSD tests --- clang/test/Preprocessor/init-x86.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/clang/test/Preprocessor/init-x86.c b/clang/test/Preprocessor/init-x86.c index 58be9b716571747..8984fcbd02c4f13 100644 --- a/clang/test/Preprocessor/init-x86.c +++ b/clang/test/Preprocessor/init-x86.c @@ -1235,6 +1235,21 @@ // X86_64-NETBSD:#define __DBL_MIN_EXP__ (-1021) // X86_64-NETBSD:#define __DBL_MIN__ 2.2250738585072014e-308 // X86_64-NETBSD:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ +// X86_64-NETBSD:#define __FLOAT128__ 1 +// X86_64-NETBSD:#define __FLT128_DECIMAL_DIG__ 36 +// X86_64-NETBSD:#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966Q +// X86_64-NETBSD:#define __FLT128_DIG__ 33 +// X86_64-NETBSD:#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34Q +// X86_64-NETBSD:#define __FLT128_HAS_DENORM__ 1 +// X86_64-NETBSD:#define __FLT128_HAS_INFINITY__ 1 +// X86_64-NETBSD:#define __FLT128_HAS_QUIET_NAN__ 1 +// X86_64-NETBSD:#define __FLT128_MANT_DIG__ 113 +// X86_64-NETBSD:#define __FLT128_MAX_10_EXP__ 4932 +// X86_64-NETBSD:#define __FLT128_MAX_EXP__ 16384 +// X86_64-NETBSD:#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932Q +// X86_64-NETBSD:#define __FLT128_MIN_10_EXP__ (-4931) +// X86_64-NETBSD:#define __FLT128_MIN_EXP__ (-16381) +// X86_64-NETBSD:#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932Q // X86_64-NETBSD:#define __FLT_DENORM_MIN__ 1.40129846e-45F // X86_64-NETBSD:#define __FLT_DIG__ 6 // X86_64-NETBSD:#define __FLT_EPSILON__ 1.19209290e-7F ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/pranavk updated https://github.com/llvm/llvm-project/pull/67196 >From 8c07729b195fa78133258b03a31e8668d70a922d Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Sep 2023 20:50:32 + Subject: [PATCH 1/3] [clang] Predefined macros for float128 support --- clang/lib/Frontend/InitPreprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index e5db8a654e6707d..9e4d4d398a21da5 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1076,6 +1076,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); + if (TI.hasFloat128Type()) +DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q"); // Define a __POINTER_WIDTH__ macro for stdint.h. Builder.defineMacro("__POINTER_WIDTH__", >From 0978352c91562f82229daeb1fb65f27f04f93d97 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Sep 2023 21:23:51 + Subject: [PATCH 2/3] Fix test --- clang/test/Preprocessor/init.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 59c5122afe1e4c3..395c4cebfa5be76 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1576,6 +1576,20 @@ // EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_DECIMAL_DIG__ 36 +// WEBASSEMBLY-NEXT:#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966Q +// WEBASSEMBLY-NEXT:#define __FLT128_DIG__ 33 +// WEBASSEMBLY-NEXT:#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34Q +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_DENORM__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_INFINITY__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_HAS_QUIET_NAN__ 1 +// WEBASSEMBLY-NEXT:#define __FLT128_MANT_DIG__ 113 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX_10_EXP__ 4932 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX_EXP__ 16384 +// WEBASSEMBLY-NEXT:#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932Q +// WEBASSEMBLY-NEXT:#define __FLT128_MIN_10_EXP__ (-4931) +// WEBASSEMBLY-NEXT:#define __FLT128_MIN_EXP__ (-16381) +// WEBASSEMBLY-NEXT:#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932Q // WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__ // WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__ // WEBASSEMBLY-NOT:#define __FLT16_DIG__ >From 7882a56d4b9d610cfda5aa141478746c378dbcfb Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Tue, 26 Sep 2023 20:15:43 + Subject: [PATCH 3/3] Fix test for x86_64 --- clang/test/Preprocessor/init-x86.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/clang/test/Preprocessor/init-x86.c b/clang/test/Preprocessor/init-x86.c index 58be9b716571747..1ee770df0c4a303 100644 --- a/clang/test/Preprocessor/init-x86.c +++ b/clang/test/Preprocessor/init-x86.c @@ -1023,6 +1023,21 @@ // X86_64-LINUX:#define __DBL_MIN_EXP__ (-1021) // X86_64-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308 // X86_64-LINUX:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ +// X86_64-LINUX:#define __FLOAT128__ 1 +// X86_64-LINUX:#define __FLT128_DECIMAL_DIG__ 36 +// X86_64-LINUX:#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966Q +// X86_64-LINUX:#define __FLT128_DIG__ 33 +// X86_64-LINUX:#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34Q +// X86_64-LINUX:#define __FLT128_HAS_DENORM__ 1 +// X86_64-LINUX:#define __FLT128_HAS_INFINITY__ 1 +// X86_64-LINUX:#define __FLT128_HAS_QUIET_NAN__ 1 +// X86_64-LINUX:#define __FLT128_MANT_DIG__ 113 +// X86_64-LINUX:#define __FLT128_MAX_10_EXP__ 4932 +// X86_64-LINUX:#define __FLT128_MAX_EXP__ 16384 +// X86_64-LINUX:#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932Q +// X86_64-LINUX:#define __FLT128_MIN_10_EXP__ (-4931) +// X86_64-LINUX:#define __FLT128_MIN_EXP__ (-16381) +// X86_64-LINUX:#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932Q // X86_64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F // X86_64-LINUX:#define __FLT_DIG__ 6 // X86_64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/echristo commented: In general this looks good. Since we don't have full compiler-rt support for this yet we may want to wait until that to merge. Alex is already looking at this and coordinating with his needs is probably the best solution. https://github.com/llvm/llvm-project/pull/67196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/alexander-shaposhnikov approved this pull request. LG https://github.com/llvm/llvm-project/pull/67196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Predefined macros for float128 support (PR #67196)
https://github.com/pranavk closed https://github.com/llvm/llvm-project/pull/67196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits