[clang] [CIR] Add calling convention values to CIR_CallingConv (PR #188715)

Rana Pratap Reddy via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 26 03:07:43 PDT 2026


https://github.com/ranapratap55 created https://github.com/llvm/llvm-project/pull/188715

Populates the `CIR_CallingConv` enum with calling convention values: `C`, `SpirKernel`, `SpirFunction`, `OpenCLKernel`, `PTXKernel`, and `AMDGPUKernel`.

This is a partial upstreaming of [clangir#760](https://github.com/llvm/clangir/pull/760/).

Follow-up PRs:

1. Add `calling_conv` attribute to `FuncOp`
2. Add LLVM lowering support for calling conventions

Tests will be added in follow-up PRs.

>From 067c0acce9810ed7612ef597da8cafd7e3e9148c Mon Sep 17 00:00:00 2001
From: ranapratap55 <RanaPratapReddy.Nimmakayala at amd.com>
Date: Thu, 26 Mar 2026 15:31:43 +0530
Subject: [PATCH] [CIR] Add calling convention values to CIR_CallingConv

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index b15dc30ffb87d..0f3d2c10cf678 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3586,9 +3586,14 @@ def CIR_OptionalPriorityAttr : OptionalAttr<
   >
 >;
 
-// TODO(CIR): CallingConv is a placeholder here so we can use it in
-// infrastructure calls, but it currently has no values.
-def CIR_CallingConv : CIR_I32EnumAttr<"CallingConv", "calling convention", []>;
+def CIR_CallingConv : CIR_I32EnumAttr<"CallingConv", "calling convention", [
+  I32EnumAttrCase<"C", 1, "c">,
+  I32EnumAttrCase<"SpirKernel", 2, "spir_kernel">,
+  I32EnumAttrCase<"SpirFunction", 3, "spir_function">,
+  I32EnumAttrCase<"OpenCLKernel", 4, "opencl_kernel">,
+  I32EnumAttrCase<"PTXKernel", 5, "ptx_kernel">,
+  I32EnumAttrCase<"AMDGPUKernel", 6, "amdgpu_kernel">
+]>;
 
 def CIR_FuncOp : CIR_Op<"func", [
   AutomaticAllocationScope, CallableOpInterface, FunctionOpInterface,



More information about the cfe-commits mailing list