https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/185258
Both ops share identical arguments and assembly format. Extract a common base class to eliminate the duplication. >From a729e0ae25f39ade3970b28f34fb94e68becde77 Mon Sep 17 00:00:00 2001 From: xlauko <[email protected]> Date: Sun, 8 Mar 2026 08:41:34 +0100 Subject: [PATCH] [CIR] Extract CIR_VAOp base class for VAStartOp and VAEndOp Both ops share identical arguments and assembly format. Extract a common base class to eliminate the duplication. --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) 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"> { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
