Skip to content

Commit f33086b

Browse files
sitio-coutolanza
authored andcommitted
[CIR][NFC] Add stdarg builtin CIR Ops
Adds custom CIR operations to represent builtin calls from the stdarg header. These include `va_start`, `va_end`, `va_copy`, and `va_arg`. ghstack-source-id: b861b23 Pull Request resolved: #93
1 parent e5b0f2c commit f33086b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,4 +1649,36 @@ def AwaitOp : CIR_Op<"await",
16491649
let hasVerifier = 1;
16501650
}
16511651

1652+
//===----------------------------------------------------------------------===//
1653+
// Variadic Operations
1654+
//===----------------------------------------------------------------------===//
1655+
1656+
def VAStartOp : CIR_Op<"va.start">, Arguments<(ins CIR_PointerType:$arg_list)> {
1657+
let summary = "Starts a variable argument list";
1658+
let assemblyFormat = "$arg_list attr-dict `:` type(operands)";
1659+
let hasVerifier = 0;
1660+
}
1661+
1662+
def VAEndOp : CIR_Op<"va.end">, Arguments<(ins CIR_PointerType:$arg_list)> {
1663+
let summary = "Ends a variable argument list";
1664+
let assemblyFormat = "$arg_list attr-dict `:` type(operands)";
1665+
let hasVerifier = 0;
1666+
}
1667+
1668+
def VACopyOp : CIR_Op<"va.copy">,
1669+
Arguments<(ins CIR_PointerType:$dst_list,
1670+
CIR_PointerType:$src_list)> {
1671+
let summary = "Copies a variable argument list";
1672+
let assemblyFormat = "$src_list `to` $dst_list attr-dict `:` type(operands)";
1673+
let hasVerifier = 0;
1674+
}
1675+
1676+
def VAArgOp : CIR_Op<"va.arg">,
1677+
Results<(outs AnyType:$result)>,
1678+
Arguments<(ins CIR_PointerType:$arg_list)> {
1679+
let summary = "Fetches next variadic element as a given type";
1680+
let assemblyFormat = "$arg_list attr-dict `:` functional-type(operands, $result)";
1681+
let hasVerifier = 0;
1682+
}
1683+
16521684
#endif // LLVM_CLANG_CIR_DIALECT_IR_CIROPS

0 commit comments

Comments
 (0)