@@ -607,8 +607,8 @@ def CIR_ConditionOp : CIR_Op<"condition", [
607607//===----------------------------------------------------------------------===//
608608
609609defvar CIR_YieldableScopes = [
610- "ArrayCtor", "CaseOp", "DoWhileOp", "ForOp", "IfOp", "ScopeOp", "SwitchOp ",
611- "TernaryOp", "WhileOp"
610+ "ArrayCtor", "ArrayDtor", " CaseOp", "DoWhileOp", "ForOp", "IfOp", "ScopeOp",
611+ "SwitchOp", " TernaryOp", "WhileOp"
612612];
613613
614614def CIR_YieldOp : CIR_Op<"yield", [
@@ -1946,6 +1946,10 @@ def CIR_FuncOp : CIR_Op<"func", [
19461946 The function linkage information is specified by `linkage`, as defined by
19471947 `GlobalLinkageKind` attribute.
19481948
1949+ The `no_proto` keyword is used to identify functions that were declared
1950+ without a prototype and, consequently, may contain calls with invalid
1951+ arguments and undefined behavior.
1952+
19491953 Example:
19501954
19511955 ```mlir
@@ -1964,6 +1968,7 @@ def CIR_FuncOp : CIR_Op<"func", [
19641968 let arguments = (ins SymbolNameAttr:$sym_name,
19651969 CIR_VisibilityAttr:$global_visibility,
19661970 TypeAttrOf<CIR_FuncType>:$function_type,
1971+ UnitAttr:$no_proto,
19671972 UnitAttr:$dso_local,
19681973 DefaultValuedAttr<CIR_GlobalLinkageKind,
19691974 "cir::GlobalLinkageKind::ExternalLinkage">:$linkage,
@@ -2005,13 +2010,6 @@ def CIR_FuncOp : CIR_Op<"func", [
20052010 return getFunctionType().getReturnTypes();
20062011 }
20072012
2008- // TODO(cir): this should be an operand attribute, but for now we just hard-
2009- // wire this as a function. Will later add a $no_proto argument to this op.
2010- bool getNoProto() {
2011- assert(!cir::MissingFeatures::opFuncNoProto());
2012- return false;
2013- }
2014-
20152013 //===------------------------------------------------------------------===//
20162014 // SymbolOpInterface Methods
20172015 //===------------------------------------------------------------------===//
@@ -2229,7 +2227,7 @@ def CIR_TrapOp : CIR_Op<"trap", [Terminator]> {
22292227}
22302228
22312229//===----------------------------------------------------------------------===//
2232- // ArrayCtor
2230+ // ArrayCtor & ArrayDtor
22332231//===----------------------------------------------------------------------===//
22342232
22352233class CIR_ArrayInitDestroy<string mnemonic> : CIR_Op<mnemonic> {
@@ -2260,7 +2258,9 @@ def CIR_ArrayCtor : CIR_ArrayInitDestroy<"array.ctor"> {
22602258 let description = [{
22612259 Initialize each array element using the same C++ constructor. This
22622260 operation has one region, with one single block. The block has an
2263- incoming argument for the current array index to initialize.
2261+ incoming argument for the current array element to initialize.
2262+
2263+ Example:
22642264
22652265 ```mlir
22662266 cir.array.ctor(%0 : !cir.ptr<!cir.array<!rec_S x 42>>) {
@@ -2272,6 +2272,25 @@ def CIR_ArrayCtor : CIR_ArrayInitDestroy<"array.ctor"> {
22722272 }];
22732273}
22742274
2275+ def CIR_ArrayDtor : CIR_ArrayInitDestroy<"array.dtor"> {
2276+ let summary = "Destroy array elements with C++ dtors";
2277+ let description = [{
2278+ Destroy each array element using the same C++ destructor. This
2279+ operation has one region, with one single block. The block has an
2280+ incoming argument for the current array element to destruct.
2281+
2282+ Example:
2283+
2284+ ```mlir
2285+ cir.array.dtor(%0 : !cir.ptr<!cir.array<!rec_S x 42>>) {
2286+ ^bb0(%arg0: !cir.ptr<!rec_S>):
2287+ cir.call @some_dtor(%arg0) : (!cir.ptr<!rec_S>) -> ()
2288+ cir.yield
2289+ }
2290+ ```
2291+ }];
2292+ }
2293+
22752294//===----------------------------------------------------------------------===//
22762295// VecCreate
22772296//===----------------------------------------------------------------------===//
@@ -2911,6 +2930,28 @@ def CIR_BitCtzOp : CIR_BitZeroCountOpBase<"ctz",
29112930 }];
29122931}
29132932
2933+ def CIR_BitFfsOp : CIR_BitOpBase<"ffs", CIR_SIntOfWidths<[32, 64]>> {
2934+ let summary = "Get the position of the least significant 1-bit in input";
2935+ let description = [{
2936+ Compute the 1-based position of the least significant 1-bit of the input.
2937+
2938+ The input integer must be a signed integer. The `cir.ffs` operation returns
2939+ one plus the index of the least significant 1-bit of the input signed
2940+ integer. If the input integer is 0, `cir.ffs` yields 0.
2941+
2942+ Example:
2943+
2944+ ```mlir
2945+ !s32i = !cir.int<s, 32>
2946+
2947+ // %0 = 0x0010_1000
2948+ %0 = cir.const #cir.int<40> : !s32i
2949+ // #1 will be 4 since the 4th least significant bit is 1.
2950+ %1 = cir.ffs %0 : !s32i
2951+ ```
2952+ }];
2953+ }
2954+
29142955def CIR_BitParityOp : CIR_BitOpBase<"parity", CIR_UIntOfWidths<[32, 64]>> {
29152956 let summary = "Get the parity of input";
29162957 let description = [{
0 commit comments