Since only z13 has vector support, the Clang FE should preferrably abort early if vector builtins are used with earlier subtargets.
The same applies similarly to transactional memory builtins.
Details
Diff Detail
Event Timeline
I'm not sure this is the right approach. In any case, it differs from how the option is handled in GCC.
-mzvector enables the language *syntax* extension, i.e. allows use of the "vector unsigned int" etc. data types. Note that this is simply syntactic sugar, the same vector types can *always* be enabled using the attribute((vector_size)) extension instead.
Therefore, GCC allows -mzvector to be always used, even when using a -march= setting that does not include z13 vector operations. In the latter case, the operations on vector types are simply implemented via scalar operations, just like what happens when you use attribute((vector_size)) without hardware vector support.
However, there is one hitch: most of the vector *built-ins* cannot be supported without hardware vector support. But I guess the correct fix for that problem is to disable those built-ins, not to disable all of -mzvector.
This patch has been reworked, and aims to specify which features systemz builtins require. The way of doing this has been taken from the X86 Target (with a '#define TARGET_BUILTIN')
If a builtin is used by the programmer for a target that does not include a required feature, the FE will abort early with an error message.
This includes vector and transactional memory builtins.
Three new tests: One for z13, which pass, and two for the generic target, which are supposed to fail (therefore I put them in separate files). The correct error messages are generated by clang, and recognized by Filecheck, but the tests are still reported as failing. I am not sure what to do to get around this, and would appreciate a hint on this. I tried expected-error{{}}, but that did not work.
This patch has been reworked, and aims to specify which features systemz builtins require. The way of doing this has been taken from the X86 Target (with a '#define TARGET_BUILTIN')
If a builtin is used by the programmer for a target that does not include a required feature, the FE will abort early with an error message.
This includes vector and transactional memory builtins.
Ah, very nice.
Three new tests: One for z13, which pass, and two for the generic target, which are supposed to fail (therefore I put them in separate files). The correct error messages are generated by clang, and recognized by Filecheck, but the tests are still reported as failing. I am not sure what to do to get around this, and would appreciate a hint on this. I tried expected-error{{}}, but that did not work.
In order to use expected-error, you have to build with -verify. See e.g. tools/clang/test/CodeGen/target-builtin-error.c
I don't think we actually need the builtins-systemz-z13.c test, it only duplicates tests already done by builtins-systemz.c and builtins-systemz-vector.c. (Note that those tests implicitly verify that there is no compiler error by checking the compiler exit code.)
Also, you should be able to combine the two -generic tests into a single one (the compiler doesn't abort at errors, so you can check for multiple errors with a single -verify run). Maybe the combined test should be named builtins-systemz-error.c ?
LGTM with those changes.