summaryrefslogtreecommitdiffstats
path: root/clang/utils
diff options
context:
space:
mode:
authorSven van Haastregt <sven.vanhaastregt@arm.com>2019-08-20 12:21:03 +0000
committerSven van Haastregt <sven.vanhaastregt@arm.com>2019-08-20 12:21:03 +0000
commitcc0ba28cf07fd696148d70eb454fbaeb9c0b30c2 (patch)
treee49dd32f6aa880da4e1017460fbc10aeac73ee78 /clang/utils
parent66d109640f10ecf3597f6bed06a081710f871469 (diff)
downloadbcm5719-llvm-cc0ba28cf07fd696148d70eb454fbaeb9c0b30c2.tar.gz
bcm5719-llvm-cc0ba28cf07fd696148d70eb454fbaeb9c0b30c2.zip
[OpenCL] Add const, volatile and pointer builtin handling
Const, volatile, and pointer types were previously available, but not working. This patch adds handling for OpenCL builtin functions. Add TableGen definitions for some atomic and asynchronous builtins to make use of the new functionality. Patch by Pierre Gondois and Sven van Haastregt. Differential Revision: https://reviews.llvm.org/D63442 llvm-svn: 369373
Diffstat (limited to 'clang/utils')
-rw-r--r--clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index 89ba5e0d973..4bf59c3a923 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -236,10 +236,18 @@ void BuiltinNameEmitter::EmitDeclarations() {
// Represents a return type or argument type.
struct OpenCLTypeStruct {
- // A type (e.g. float, int, ...)
+ // A type (e.g. float, int, ...).
const OpenCLTypeID ID;
// Vector size (if applicable; 0 for scalars and generic types).
const unsigned VectorWidth;
+ // 0 if the type is not a pointer.
+ const bool IsPointer;
+ // 0 if the type is not const.
+ const bool IsConst;
+ // 0 if the type is not volatile.
+ const bool IsVolatile;
+ // Address space of the pointer (if applicable).
+ const LangAS AS;
};
// One overload of an OpenCL builtin function.
@@ -341,7 +349,11 @@ void BuiltinNameEmitter::EmitTypeTable() {
for (const auto &T : TypeMap) {
OS << " // " << T.second << "\n";
OS << " {OCLT_" << T.first->getValueAsString("Name") << ", "
- << T.first->getValueAsInt("VecWidth") << "},\n";
+ << T.first->getValueAsInt("VecWidth") << ", "
+ << T.first->getValueAsBit("IsPointer") << ", "
+ << T.first->getValueAsBit("IsConst") << ", "
+ << T.first->getValueAsBit("IsVolatile") << ", "
+ << T.first->getValueAsString("AddrSpace") << "},\n";
}
OS << "};\n\n";
}
@@ -525,6 +537,28 @@ static void OCL2Qual(ASTContext &Context, const OpenCLTypeStruct &Ty,
QT[Index] = Context.getExtVectorType(QT[Index], Ty.VectorWidth);
}
}
+
+ if (Ty.IsVolatile != 0) {
+ for (unsigned Index = 0; Index < QT.size(); Index++) {
+ QT[Index] = Context.getVolatileType(QT[Index]);
+ }
+ }
+
+ if (Ty.IsConst != 0) {
+ for (unsigned Index = 0; Index < QT.size(); Index++) {
+ QT[Index] = Context.getConstType(QT[Index]);
+ }
+ }
+
+ // Transform the type to a pointer as the last step, if necessary.
+ // Builtin functions only have pointers on [const|volatile], no
+ // [const|volatile] pointers, so this is ok to do it as a last step.
+ if (Ty.IsPointer != 0) {
+ for (unsigned Index = 0; Index < QT.size(); Index++) {
+ QT[Index] = Context.getAddrSpaceQualType(QT[Index], Ty.AS);
+ QT[Index] = Context.getPointerType(QT[Index]);
+ }
+ }
)";
// End of the "OCL2Qual" function.
OpenPOWER on IntegriCloud