aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-07-25 23:19:36 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2021-07-28 13:13:05 +0200
commitb2f6e1de242fff5713763cd3146dcf3f9dee51ca (patch)
treeb5e25559184ca505e2a59645a742ae9d8185b549 /gcc/testsuite/gdc.dg
parent3e2136117487fa839f7601c3e22a2856978fb9d0 (diff)
downloadgcc-b2f6e1de242fff5713763cd3146dcf3f9dee51ca.zip
gcc-b2f6e1de242fff5713763cd3146dcf3f9dee51ca.tar.gz
gcc-b2f6e1de242fff5713763cd3146dcf3f9dee51ca.tar.bz2
d: Compile-time reflection for supported built-ins (PR101127)
In order to allow user-code to determine whether a back-end builtin is available without error, LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE has been defined to delay putting back-end builtin functions until the ISA that defines them has been declared. However in D, there is no global namespace. All builtins get pushed into the `gcc.builtins' module, which is constructed during the semantic analysis pass, which has already finished by the time target attributes are evaluated. So builtins are not pushed by the new langhook because they would be ultimately ignored. Builtins exposed to D code then can now only be altered by the command-line. PR d/101127 gcc/d/ChangeLog: * d-builtins.cc (d_builtin_function_ext_scope): New function. * d-lang.cc (LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE): Define. * d-tree.h (d_builtin_function_ext_scope): Declare. gcc/testsuite/ChangeLog: * gdc.dg/pr101127a.d: New test. * gdc.dg/pr101127b.d: New test.
Diffstat (limited to 'gcc/testsuite/gdc.dg')
-rw-r--r--gcc/testsuite/gdc.dg/pr101127a.d8
-rw-r--r--gcc/testsuite/gdc.dg/pr101127b.d7
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.dg/pr101127a.d b/gcc/testsuite/gdc.dg/pr101127a.d
new file mode 100644
index 0000000..b56398e
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr101127a.d
@@ -0,0 +1,8 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101127
+// { dg-do compile { target i?86*-*-* x86_64-*-* } }
+// { dg-additional-options "-mavx" }
+
+import gcc.builtins;
+
+static assert(__traits(compiles, __builtin_ia32_andps256));
+static assert(__traits(compiles, __builtin_ia32_pmulhrsw128));
diff --git a/gcc/testsuite/gdc.dg/pr101127b.d b/gcc/testsuite/gdc.dg/pr101127b.d
new file mode 100644
index 0000000..b462d75
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr101127b.d
@@ -0,0 +1,7 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101127
+// { dg-do compile { target i?86*-*-* x86_64-*-* } }
+
+import gcc.builtins;
+
+static assert(!__traits(compiles, __builtin_ia32_andps256));
+static assert(!__traits(compiles, __builtin_ia32_pmulhrsw128));