Skip to content

Commit 0359620

Browse files
committed
[MLIR:LLVM] Add UWTableKind attribute
1 parent 637f352 commit 0359620

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,4 +1365,14 @@ def LLVM_DependentLibrariesAttr
13651365
let assemblyFormat = "`<` $libs `>`";
13661366
}
13671367

1368+
//===----------------------------------------------------------------------===//
1369+
// UWTableKindAttr
1370+
//===----------------------------------------------------------------------===//
1371+
1372+
def UWTableKindAttr : LLVM_Attr<"UWTableKind", "uwtableKind"> {
1373+
let parameters = (ins "uwtable::UWTableKind":$uwtableKind);
1374+
let assemblyFormat = "`<` $uwtableKind `>`";
1375+
}
1376+
1377+
13681378
#endif // LLVMIR_ATTRDEFS

mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,4 +855,27 @@ def ModFlagBehaviorAttr : LLVM_EnumAttr<
855855
let cppNamespace = "::mlir::LLVM";
856856
}
857857

858+
//===----------------------------------------------------------------------===//
859+
// UWTableKind
860+
//===----------------------------------------------------------------------===//
861+
862+
def UWTableKindNone
863+
: LLVM_EnumAttrCase<"None", "none", "None", 0>;
864+
def UWTableKindSync
865+
: LLVM_EnumAttrCase<"Sync", "sync", "Sync", 1>;
866+
def UWTableKindAsync
867+
: LLVM_EnumAttrCase<"Async", "async", "Async", 2>;
868+
def UWTableKindDefault
869+
: LLVM_EnumAttrCase<"Default", "default", "Default", 2>;
870+
871+
// UWTableKindDefault is unsupported as the llvm enum value is the same as async
872+
// which the generated enum converters can't deal with.
873+
def UWTableKindEnum : LLVM_EnumAttr<
874+
"UWTableKind",
875+
"::llvm::UWTableKind",
876+
"LLVM Unwind Behavior",
877+
[UWTableKindNone, UWTableKindSync, UWTableKindAsync]> {
878+
let cppNamespace = "::mlir::LLVM::uwtable";
879+
}
880+
858881
#endif // LLVMIR_ENUMS

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,8 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
18421842
OptionalAttr<LLVM_VecTypeHintAttr>:$vec_type_hint,
18431843
OptionalAttr<DenseI32ArrayAttr>:$work_group_size_hint,
18441844
OptionalAttr<DenseI32ArrayAttr>:$reqd_work_group_size,
1845-
OptionalAttr<I32Attr>:$intel_reqd_sub_group_size
1845+
OptionalAttr<I32Attr>:$intel_reqd_sub_group_size,
1846+
OptionalAttr<UWTableKindAttr>:$uwtable_kind
18461847
);
18471848

18481849
let regions = (region AnyRegion:$body);

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,9 @@ static void convertFunctionAttributes(LLVMFuncOp func,
16021602
if (FramePointerKindAttr fpAttr = func.getFramePointerAttr())
16031603
llvmFunc->addFnAttr("frame-pointer", stringifyFramePointerKind(
16041604
fpAttr.getFramePointerKind()));
1605+
if (UWTableKindAttr uwTableKindAttr = func.getUwtableKindAttr())
1606+
llvmFunc->setUWTableKind(
1607+
convertUWTableKindToLLVM(uwTableKindAttr.getUwtableKind()));
16051608
convertFunctionMemoryAttributes(func, llvmFunc);
16061609
}
16071610

mlir/test/Target/LLVMIR/uwtable.mlir

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
2+
3+
// CHECK-LABEL: define void @uwtable_func()
4+
// CHECK-SAME: #[[ATTRS:[0-9]+]]
5+
llvm.func @uwtable_func() attributes {uwtable_kind = #llvm.uwtableKind<"sync">} {
6+
llvm.return
7+
}
8+
// CHECK: attributes #[[ATTRS]] = { uwtable(sync) }

0 commit comments

Comments
 (0)