aboutsummaryrefslogtreecommitdiff
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-06-25 15:06:43 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-06-28 19:05:42 +0200
commit6201277441db4023b833e6d643de8077fe38ed6e (patch)
treef352e3cda43ffefe86c022ec52655ebee1dc9f89 /libphobos
parented06274eacc17a224b87f23111d7ca874ea53b7c (diff)
downloadgcc-6201277441db4023b833e6d643de8077fe38ed6e.zip
gcc-6201277441db4023b833e6d643de8077fe38ed6e.tar.gz
gcc-6201277441db4023b833e6d643de8077fe38ed6e.tar.bz2
d: Add `@simd` and `@simd_clones` attributes to compiler and library
The `@simd` attribute is equivalent to `__attribute__((simd))`, and `@simd_clones` is a convenience alias to allow specifying whether the compiler should generated masked or non-masked simd clones. gcc/d/ChangeLog: * d-attribs.cc (handle_omp_declare_simd_attribute): New function. (d_handle_simd_attribute): New function. (d_langhook_common_attribute_table): Add 'omp declare simd' attribute. (d_langhook_attribute_table): Add simd attribute. libphobos/ChangeLog: * libdruntime/gcc/attributes.d (simd): Define. gcc/testsuite/ChangeLog: * gdc.dg/attr_simd1.d: New test. * gdc.dg/attr_simd2.d: New test.
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/libdruntime/gcc/attributes.d40
1 files changed, 40 insertions, 0 deletions
diff --git a/libphobos/libdruntime/gcc/attributes.d b/libphobos/libdruntime/gcc/attributes.d
index 40a18bf..9d7f2e1 100644
--- a/libphobos/libdruntime/gcc/attributes.d
+++ b/libphobos/libdruntime/gcc/attributes.d
@@ -372,6 +372,46 @@ auto section(A...)(A arguments)
}
/**
+ * The `@simd` attribute enables creation of one or more function versions that
+ * can process multiple arguments using SIMD instructions from a single
+ * invocation. Specifying this attribute allows compiler to assume that such
+ * versions are available at link time (provided in the same or another module).
+ * Generated versions are target-dependent and described in the corresponding
+ * Vector ABI document. For x86_64 target this document can be found here.
+ * https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt
+ *
+ * The `@simd_clones` attribute is the same as `@simd`, but also includes a
+ * `mask` argument. Valid masks values are `notinbranch` or `inbranch`, and
+ * instructs the compiler to generate non-masked or masked clones
+ * correspondingly.
+ *
+ * Example:
+ * ---
+ * import gcc.attributes;
+ *
+ * @simd double sqrt(double x);
+ * @simd("notinbranch") double atan2(double y, double x);
+ * ---
+ */
+enum simd = attribute("simd");
+
+auto simd_clones(string mask)
+{
+ if (mask == "notinbranch" || mask == "inbranch")
+ return attribute("simd", mask);
+ else
+ {
+ assert(false, "unrecognized parameter `" ~ mask
+ ~ "` for `gcc.attribute.simd_clones`");
+ }
+}
+
+auto simd_clones(A...)(A arguments)
+{
+ assert(false, "simd_clones attribute argument not a string constant");
+}
+
+/**
* The `@symver` attribute creates a symbol version on ELF targets. The syntax
* of the string parameter is `name@nodename`. The `name` part of the parameter
* is the actual name of the symbol by which it will be externally referenced.