[clang] [CIR] Extract CIR_VAOp base class for VAStartOp and VAEndOp (PR #185258)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 7 23:47:22 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
Author: Henrich Lauko (xlauko)
<details>
<summary>Changes</summary>
Both ops share identical arguments and assembly format. Extract a common
base class to eliminate the duplication.
---
Full diff: https://github.com/llvm/llvm-project/pull/185258.diff
1 Files Affected:
- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+10-13)
``````````diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 79eef71229192..44c8d69cd53ca 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -6246,7 +6246,15 @@ def CIR_ATan2Op : CIR_BinaryFPToFPBuiltinOp<"atan2", "ATan2Op"> {
// Variadic Operations
//===----------------------------------------------------------------------===//
-def CIR_VAStartOp : CIR_Op<"va_start"> {
+class CIR_VAOp<string mnemonic> : CIR_Op<mnemonic> {
+ let arguments = (ins CIR_PointerType:$arg_list);
+
+ let assemblyFormat = [{
+ $arg_list attr-dict `:` type(operands)
+ }];
+}
+
+def CIR_VAStartOp : CIR_VAOp<"va_start"> {
let summary = "Starts a variable argument list";
let description = [{
The cir.va_start operation models the C/C++ va_start macro by
@@ -6275,14 +6283,9 @@ def CIR_VAStartOp : CIR_Op<"va_start"> {
cir.va_start %p : !cir.ptr<!rec___va_list_tag>
```
}];
- let arguments = (ins CIR_PointerType:$arg_list);
-
- let assemblyFormat = [{
- $arg_list attr-dict `:` type(operands)
- }];
}
-def CIR_VAEndOp : CIR_Op<"va_end"> {
+def CIR_VAEndOp : CIR_VAOp<"va_end"> {
let summary = "Ends a variable argument list";
let description = [{
The `cir.va_end` operation models the C/C++ va_end macro by finalizing
@@ -6310,12 +6313,6 @@ def CIR_VAEndOp : CIR_Op<"va_end"> {
cir.va_end %p : !cir.ptr<!rec___va_list_tag>
```
}];
-
- let arguments = (ins CIR_PointerType:$arg_list);
-
- let assemblyFormat = [{
- $arg_list attr-dict `:` type(operands)
- }];
}
def CIR_VACopyOp : CIR_Op<"va_copy"> {
``````````
</details>
https://github.com/llvm/llvm-project/pull/185258
More information about the cfe-commits
mailing list