llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Francesco Petrogalli (fpetrogalli) <details> <summary>Changes</summary> Clang extended vector types are mangled as follows: ext_vector_type_<lanes>_<scalar type> This is used to defetmine the builtins signature for builtins that use parmeters defined as typedef <scalar type> ext_vector_type_<lanes>_<scalar type> __attribute__((ext_vector_type(<lanes>))) For example: typedef double ext_vector_type_4_double __attribute__((ext_vector_type(4))) --- Full diff: https://github.com/llvm/llvm-project/pull/83584.diff 2 Files Affected: - (added) clang/test/TableGen/target-builtins-prototype-parser.td (+20) - (modified) clang/utils/TableGen/ClangBuiltinsEmitter.cpp (+10) ``````````diff diff --git a/clang/test/TableGen/target-builtins-prototype-parser.td b/clang/test/TableGen/target-builtins-prototype-parser.td new file mode 100644 index 00000000000000..681a607da7e115 --- /dev/null +++ b/clang/test/TableGen/target-builtins-prototype-parser.td @@ -0,0 +1,20 @@ +// RUN: clang-tblgen -I %p/../../../clang/include/ %s --gen-clang-builtins | FileCheck %s +// RUN: not clang-tblgen -I %p/../../../clang/include/ %s --gen-clang-builtins -DERROR_EXPECTED_LANES 2>&1 | FileCheck %s --check-prefix=ERROR_EXPECTED_LANES + +include "clang/Basic/BuiltinsBase.td" + +def : Builtin { + let Prototype = "ext_vector_type_8_int(double, ext_vector_type_4_bool)"; + let Spellings = ["__builtin_test_use_clang_extended_vectors"]; +} + +// CHECK: BUILTIN(__builtin_test_use_clang_extended_vectors, "E8idE4b", "") + +#ifdef ERROR_EXPECTED_LANES +def : Builtin { +// ERROR_EXPECTED_LANES: :[[# @LINE + 1]]:7: error: Expected number of lanes + let Prototype = "ext_vector_type__int(double, ext_vector_type_4_bool)"; + let Spellings = ["__builtin_test_use_clang_extended_vectors"]; +} +#endif + diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp index 48f55b8af97e4e..774f703390a05e 100644 --- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp +++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp @@ -85,6 +85,16 @@ class PrototypeParser { if (Substitution.empty()) PrintFatalError(Loc, "Not a template"); ParseType(Substitution); + } else if (T.consume_front("ext_vector_type_")) { + // Clang extended vector types are mangled as follows: + // + // ext_vector_type_<lanes>_<scalar type> + unsigned long long Lanes; + if (llvm::consumeUnsignedInteger(T, 10, Lanes)) + PrintFatalError(Loc, "Expected number of lanes "); + Type += "E" + std::to_string(Lanes); + T.consume_front("_"); + ParseType(T); } else { auto ReturnTypeVal = StringSwitch<std::string>(T) .Case("__builtin_va_list_ref", "A") `````````` </details> https://github.com/llvm/llvm-project/pull/83584 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits