summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorFraser Cormack <fraser@codeplay.com>2014-07-30 14:39:53 +0000
committerFraser Cormack <fraser@codeplay.com>2014-07-30 14:39:53 +0000
commitdadc371e851105c77f21a6cb0e67979453b29d22 (patch)
tree39643a3390e1b865d3831a99352c644d6d15028c /clang/lib/CodeGen/CodeGenFunction.cpp
parent326e48cd096cf2960a99699437c5f0f4526854c9 (diff)
downloadbcm5719-llvm-dadc371e851105c77f21a6cb0e67979453b29d22.tar.gz
bcm5719-llvm-dadc371e851105c77f21a6cb0e67979453b29d22.zip
Add OpenCL/SPIR kernel_arg_base_type metadata node
As defined in the SPIR 1.2 specification, this node behaves similarly to kernel_arg_type but will print the underlying type name, e.g., without typedefs. Example: typedef unsigned int myunsignedint; would report: 'myunsignedint' in the kernel_arg_type node 'uint' in the kernel_arg_base_type node llvm-svn: 214308
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 6fe90fd3d47..8ff02b390e4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -358,6 +358,11 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
SmallVector<llvm::Value*, 8> argTypeNames;
argTypeNames.push_back(llvm::MDString::get(Context, "kernel_arg_type"));
+ // MDNode for the kernel argument base type names.
+ SmallVector<llvm::Value*, 8> argBaseTypeNames;
+ argBaseTypeNames.push_back(
+ llvm::MDString::get(Context, "kernel_arg_base_type"));
+
// MDNode for the kernel argument type qualifiers.
SmallVector<llvm::Value*, 8> argTypeQuals;
argTypeQuals.push_back(llvm::MDString::get(Context, "kernel_arg_type_qual"));
@@ -389,6 +394,18 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
argTypeNames.push_back(llvm::MDString::get(Context, typeName));
+ std::string baseTypeName =
+ pointeeTy.getUnqualifiedType().getCanonicalType().getAsString(
+ Policy) +
+ "*";
+
+ // Turn "unsigned type" to "utype"
+ pos = baseTypeName.find("unsigned");
+ if (pos != std::string::npos)
+ baseTypeName.erase(pos+1, 8);
+
+ argBaseTypeNames.push_back(llvm::MDString::get(Context, baseTypeName));
+
// Get argument type qualifiers:
if (ty.isRestrictQualified())
typeQuals = "restrict";
@@ -415,6 +432,16 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
argTypeNames.push_back(llvm::MDString::get(Context, typeName));
+ std::string baseTypeName =
+ ty.getUnqualifiedType().getCanonicalType().getAsString(Policy);
+
+ // Turn "unsigned type" to "utype"
+ pos = baseTypeName.find("unsigned");
+ if (pos != std::string::npos)
+ baseTypeName.erase(pos+1, 8);
+
+ argBaseTypeNames.push_back(llvm::MDString::get(Context, baseTypeName));
+
// Get argument type qualifiers:
if (ty.isConstQualified())
typeQuals = "const";
@@ -442,6 +469,7 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
kernelMDArgs.push_back(llvm::MDNode::get(Context, addressQuals));
kernelMDArgs.push_back(llvm::MDNode::get(Context, accessQuals));
kernelMDArgs.push_back(llvm::MDNode::get(Context, argTypeNames));
+ kernelMDArgs.push_back(llvm::MDNode::get(Context, argBaseTypeNames));
kernelMDArgs.push_back(llvm::MDNode::get(Context, argTypeQuals));
kernelMDArgs.push_back(llvm::MDNode::get(Context, argNames));
}
OpenPOWER on IntegriCloud