[clang] [llvm] [AMDGPU] Enable OpenCL hostcall printf (WIP) (PR #72556)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 15 08:59:23 PDT 2024


================
@@ -3616,6 +3617,12 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const {
   if (!ConsiderWrapperFunctions && getStorageClass() == SC_Static)
     return 0;
 
+  // AMDGCN implementation supports printf as a builtin
+  // for OpenCL
+  if (Context.getTargetInfo().getTriple().isAMDGCN() &&
+      Context.getLangOpts().OpenCL && BuiltinID == AMDGPU::BIprintf)
+    return BuiltinID;
----------------
arsenm wrote:

I think CustomTypeChecking is the backdoor for builtin types to change based on code. Not sure if there's a nicer mechanism. If it doesn't exist already, we could maybe come up with a way to swap out a type based on the language mode. It looks like the move to define builtins in TableGen is incomplete ,as the target builtins (with the address space handling) seems to not have moved yet. The existing OpenCL builtins defined in tablegen do not declare their address spaces

https://github.com/llvm/llvm-project/pull/72556


More information about the cfe-commits mailing list