summaryrefslogtreecommitdiffstats
path: root/clang/utils/TableGen/TableGen.cpp
diff options
context:
space:
mode:
authorSimon Tatham <simon.tatham@arm.com>2019-09-02 15:50:50 +0100
committerSimon Tatham <simon.tatham@arm.com>2019-10-24 16:33:13 +0100
commit08074cc96557dcb7ec91d7cd84c412414fa9a516 (patch)
tree11371e0a7950d1d4b5dc0e2d4476e1ba91b4672d /clang/utils/TableGen/TableGen.cpp
parent7c11da0cfd3396150c13657a2217f2044f314734 (diff)
downloadbcm5719-llvm-08074cc96557dcb7ec91d7cd84c412414fa9a516.tar.gz
bcm5719-llvm-08074cc96557dcb7ec91d7cd84c412414fa9a516.zip
[clang,ARM] Initial ACLE intrinsics for MVE.
This commit sets up the infrastructure for auto-generating <arm_mve.h> and doing clang-side code generation for the builtins it relies on, and demonstrates that it works by implementing a representative sample of the ACLE intrinsics, more or less matching the ones introduced in LLVM IR by D67158,D68699,D68700. Like NEON, that header file will provide a set of vector types like uint16x8_t and C functions with names like vaddq_u32(). Unlike NEON, the ACLE spec for <arm_mve.h> includes a polymorphism system, so that you can write plain vaddq() and disambiguate by the vector types you pass to it. Unlike the corresponding NEON code, I've arranged to make every user- facing ACLE intrinsic into a clang builtin, and implement all the code generation inside clang. So <arm_mve.h> itself contains nothing but typedefs and function declarations, with the latter all using the new `__attribute__((__clang_builtin))` system to arrange that the user- facing function names correspond to the right internal BuiltinIDs. So the new MveEmitter tablegen system specifies the full sequence of IRBuilder operations that each user-facing ACLE intrinsic should translate into. Where possible, the ACLE intrinsics map to standard IR operations such as vector-typed `add` and `fadd`; where no standard representation exists, I call down to the sample IR intrinsics introduced in an earlier commit. Doing it like this means that you get the polymorphism for free just by using __attribute__((overloadable)): the clang overload resolution decides which function declaration is the relevant one, and _then_ its BuiltinID is looked up, so by the time we're doing code generation, that's all been resolved by the standard system. It also means that you get really nice error messages if the user passes the wrong combination of types: clang will show the declarations from the header file and explain why each one doesn't match. (The obvious alternative approach would be to have wrapper functions in <arm_mve.h> which pass their arguments to the underlying builtins. But that doesn't work in the case where one of the arguments has to be a constant integer: the wrapper function can't pass the constantness through. So you'd have to do that case using a macro instead, and then use C11 `_Generic` to handle the polymorphism. Then you have to add horrible workarounds because `_Generic` requires even the untaken branches to type-check successfully, and //then// if the user gets the types wrong, the error message is totally unreadable!) Reviewers: dmgreen, miyuki, ostannard Subscribers: mgorny, javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67161
Diffstat (limited to 'clang/utils/TableGen/TableGen.cpp')
-rw-r--r--clang/utils/TableGen/TableGen.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp
index d0f8a756449..29c6d76f73e 100644
--- a/clang/utils/TableGen/TableGen.cpp
+++ b/clang/utils/TableGen/TableGen.cpp
@@ -60,6 +60,11 @@ enum ActionType {
GenArmFP16,
GenArmNeonSema,
GenArmNeonTest,
+ GenArmMveHeader,
+ GenArmMveBuiltinDef,
+ GenArmMveBuiltinSema,
+ GenArmMveBuiltinCG,
+ GenArmMveBuiltinAliases,
GenAttrDocs,
GenDiagDocs,
GenOptDocs,
@@ -162,6 +167,16 @@ cl::opt<ActionType> Action(
"Generate ARM NEON sema support for clang"),
clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
"Generate ARM NEON tests for clang"),
+ clEnumValN(GenArmMveHeader, "gen-arm-mve-header",
+ "Generate arm_mve.h for clang"),
+ clEnumValN(GenArmMveBuiltinDef, "gen-arm-mve-builtin-def",
+ "Generate ARM MVE builtin definitions for clang"),
+ clEnumValN(GenArmMveBuiltinSema, "gen-arm-mve-builtin-sema",
+ "Generate ARM MVE builtin sema checks for clang"),
+ clEnumValN(GenArmMveBuiltinCG, "gen-arm-mve-builtin-codegen",
+ "Generate ARM MVE builtin code-generator for clang"),
+ clEnumValN(GenArmMveBuiltinAliases, "gen-arm-mve-builtin-aliases",
+ "Generate list of valid ARM MVE builtin aliases for clang"),
clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -296,6 +311,21 @@ bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
case GenArmNeonTest:
EmitNeonTest(Records, OS);
break;
+ case GenArmMveHeader:
+ EmitMveHeader(Records, OS);
+ break;
+ case GenArmMveBuiltinDef:
+ EmitMveBuiltinDef(Records, OS);
+ break;
+ case GenArmMveBuiltinSema:
+ EmitMveBuiltinSema(Records, OS);
+ break;
+ case GenArmMveBuiltinCG:
+ EmitMveBuiltinCG(Records, OS);
+ break;
+ case GenArmMveBuiltinAliases:
+ EmitMveBuiltinAliases(Records, OS);
+ break;
case GenAttrDocs:
EmitClangAttrDocs(Records, OS);
break;
OpenPOWER on IntegriCloud