Skip to content

Commit 942fb03

Browse files
[MLIR][LLVMIR] Translation: honor target-features fn attribute (#130343)
1 parent ff033d1 commit 942fb03

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,9 +1494,6 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
14941494
if (auto tuneCpu = func.getTuneCpu())
14951495
llvmFunc->addFnAttr("tune-cpu", *tuneCpu);
14961496

1497-
if (auto targetFeatures = func.getTargetFeatures())
1498-
llvmFunc->addFnAttr("target-features", targetFeatures->getFeaturesString());
1499-
15001497
if (auto attr = func.getVscaleRange())
15011498
llvmFunc->addFnAttr(llvm::Attribute::getWithVScaleRangeArgs(
15021499
getLLVMContext(), attr->getMinRange().getInt(),
@@ -1600,6 +1597,8 @@ static void convertFunctionAttributes(LLVMFuncOp func,
16001597
llvmFunc->addFnAttr(llvm::Attribute::NoUnwind);
16011598
if (func.getWillReturnAttr())
16021599
llvmFunc->addFnAttr(llvm::Attribute::WillReturn);
1600+
if (TargetFeaturesAttr targetFeatAttr = func.getTargetFeaturesAttr())
1601+
llvmFunc->addFnAttr("target-features", targetFeatAttr.getFeaturesString());
16031602
if (FramePointerKindAttr fpAttr = func.getFramePointerAttr())
16041603
llvmFunc->addFnAttr("frame-pointer", stringifyFramePointerKind(
16051604
fpAttr.getFramePointerKind()));

mlir/test/Target/LLVMIR/llvmir.mlir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,18 @@ llvm.func @readwrite_func() attributes {
23672367

23682368
// -----
23692369

2370+
//
2371+
// target-features attribute.
2372+
//
2373+
2374+
// CHECK-LABEL: @tf
2375+
// CHECK-SAME: #[[TargetFeat:.*]]
2376+
llvm.func @tf(!llvm.ptr) attributes {target_features = #llvm.target_features<["+fix-cortex-a53-835769", "+fp-armv8", "+neon", "+outline-atomics", "+v8a"]>}
2377+
2378+
// CHECK: attributes #[[TargetFeat]] = { "target-features"="+fix-cortex-a53-835769,+fp-armv8,+neon,+outline-atomics,+v8a" }
2379+
2380+
// -----
2381+
23702382
//
23712383
// arm_streaming attribute.
23722384
//

0 commit comments

Comments
 (0)