Skip to content

Commit 45df08a

Browse files
committed
[Flang][MLIR][OpenMP] Add support for target-cpu and target-features
This patch implements a complete flow to propagate information on the target CPU and target features, as obtained from Flang's command line arguments, to LLVM IR. The proposed approach can be summarized as follows: - A reference to the `TargetMachine` object is stored in the `LoweringBridge`. This enables the addition of the "target_cpu" and "llvm.target_features" MLIR discardable attributes to all generated `func.func` operations. - The Func to LLVM dialect conversion pass is updated to translate instances of "llvm.target_features" string attributes into the expected structured attribute representation for the corresponding "target_features" argument of `llvm.func` operations. The "target_cpu" is passed through by default to a new string attribute of that same name added to the `llvm.func` operation. - The new "target_cpu" attribute is translated to a "target-cpu" LLVM IR function attribute. - The existing `omp.target` OpenMP attribute class, which is used to represent these two attributes, is removed, together with all uses. - The OpenMP to LLVMIR translation is updated to propagate these attributes to outlined target regions, so they match the attributes from the function they are originally extracted. This patch is probably best to be split up into different parts to simplify reviews, but I think it's good to present the whole approach early to see if there are any conceptual problems with it, as I will only have bandwidth to split this patch in January.
1 parent 7f55d7d commit 45df08a

File tree

20 files changed

+146
-76
lines changed

20 files changed

+146
-76
lines changed

flang/include/flang/Lower/Bridge.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
#include "flang/Optimizer/Builder/FIRBuilder.h"
2222
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
2323
#include "mlir/IR/BuiltinOps.h"
24-
25-
namespace llvm {
26-
class DataLayout;
27-
} // namespace llvm
24+
#include "llvm/Target/TargetMachine.h"
2825

2926
namespace Fortran {
3027
namespace common {
@@ -64,11 +61,11 @@ class LoweringBridge {
6461
const Fortran::lower::LoweringOptions &loweringOptions,
6562
const std::vector<Fortran::lower::EnvironmentDefault> &envDefaults,
6663
const Fortran::common::LanguageFeatureControl &languageFeatures,
67-
const llvm::DataLayout *dataLayout = nullptr) {
64+
const llvm::TargetMachine &targetMachine) {
6865
return LoweringBridge(ctx, semanticsContext, defaultKinds, intrinsics,
6966
targetCharacteristics, allCooked, triple, kindMap,
7067
loweringOptions, envDefaults, languageFeatures,
71-
dataLayout);
68+
targetMachine);
7269
}
7370

7471
//===--------------------------------------------------------------------===//
@@ -110,6 +107,8 @@ class LoweringBridge {
110107
return languageFeatures;
111108
}
112109

110+
const llvm::TargetMachine &getTargetMachine() const { return targetMachine; }
111+
113112
/// Create a folding context. Careful: this is very expensive.
114113
Fortran::evaluate::FoldingContext createFoldingContext() const;
115114

@@ -147,7 +146,7 @@ class LoweringBridge {
147146
const Fortran::lower::LoweringOptions &loweringOptions,
148147
const std::vector<Fortran::lower::EnvironmentDefault> &envDefaults,
149148
const Fortran::common::LanguageFeatureControl &languageFeatures,
150-
const llvm::DataLayout *dataLayout);
149+
const llvm::TargetMachine &targetMachine);
151150
LoweringBridge() = delete;
152151
LoweringBridge(const LoweringBridge &) = delete;
153152

@@ -164,6 +163,7 @@ class LoweringBridge {
164163
const Fortran::lower::LoweringOptions &loweringOptions;
165164
const std::vector<Fortran::lower::EnvironmentDefault> &envDefaults;
166165
const Fortran::common::LanguageFeatureControl &languageFeatures;
166+
const llvm::TargetMachine &targetMachine;
167167
};
168168

169169
} // namespace lower

flang/include/flang/Tools/CrossToolHelpers.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,6 @@ void setOffloadModuleInterfaceAttributes(
103103
}
104104
}
105105

106-
// Shares assinging of the OpenMP OffloadModuleInterface and its TargetCPU
107-
// attribute accross Flang tools (bbc/flang)
108-
void setOffloadModuleInterfaceTargetAttribute(mlir::ModuleOp &module,
109-
llvm::StringRef targetCPU, llvm::StringRef targetFeatures) {
110-
// Should be registered by the OpenMPDialect
111-
if (auto offloadMod = llvm::dyn_cast<mlir::omp::OffloadModuleInterface>(
112-
module.getOperation())) {
113-
offloadMod.setTarget(targetCPU, targetFeatures);
114-
}
115-
}
116-
117106
void setOpenMPVersionAttribute(mlir::ModuleOp &module, int64_t version) {
118107
module.getOperation()->setAttr(
119108
mlir::StringAttr::get(module.getContext(), llvm::Twine{"omp.version"}),

flang/lib/Frontend/FrontendActions.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,14 @@ bool CodeGenAction::beginSourceFileAction() {
283283
ci.getSemanticsContext().defaultKinds();
284284
fir::KindMapping kindMap(mlirCtx.get(), llvm::ArrayRef<fir::KindTy>{
285285
fir::fromDefaultKinds(defKinds)});
286-
const llvm::DataLayout &dl = targetMachine.createDataLayout();
287-
288286
lower::LoweringBridge lb = Fortran::lower::LoweringBridge::create(
289287
*mlirCtx, ci.getSemanticsContext(), defKinds,
290288
ci.getSemanticsContext().intrinsics(),
291289
ci.getSemanticsContext().targetCharacteristics(),
292290
ci.getParsing().allCooked(), ci.getInvocation().getTargetOpts().triple,
293291
kindMap, ci.getInvocation().getLoweringOpts(),
294292
ci.getInvocation().getFrontendOpts().envDefaults,
295-
ci.getInvocation().getFrontendOpts().features, &dl);
293+
ci.getInvocation().getFrontendOpts().features, targetMachine);
296294

297295
// Fetch module from lb, so we can set
298296
mlirModule = std::make_unique<mlir::ModuleOp>(lb.getModule());
@@ -301,9 +299,6 @@ bool CodeGenAction::beginSourceFileAction() {
301299
Fortran::common::LanguageFeature::OpenMP)) {
302300
setOffloadModuleInterfaceAttributes(*mlirModule,
303301
ci.getInvocation().getLangOpts());
304-
setOffloadModuleInterfaceTargetAttribute(
305-
*mlirModule, targetMachine.getTargetCPU(),
306-
targetMachine.getTargetFeatureString());
307302
setOpenMPVersionAttribute(*mlirModule,
308303
ci.getInvocation().getLangOpts().OpenMPVersion);
309304
}

flang/lib/Lower/Bridge.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4326,6 +4326,17 @@ class FirConverter : public Fortran::lower::AbstractConverter {
43264326
assert(blockId == 0 && "invalid blockId");
43274327
assert(activeConstructStack.empty() && "invalid construct stack state");
43284328

4329+
// Set target_cpu and target_features attributes to be passed through to the
4330+
// llvm.func operation during lowering.
4331+
const llvm::TargetMachine &targetMachine = bridge.getTargetMachine();
4332+
if (auto targetCPU = targetMachine.getTargetCPU(); !targetCPU.empty())
4333+
func->setAttr("target_cpu",
4334+
mlir::StringAttr::get(func.getContext(), targetCPU));
4335+
if (auto targetFeatures = targetMachine.getTargetFeatureString();
4336+
!targetFeatures.empty())
4337+
func->setAttr("llvm.target_features",
4338+
mlir::StringAttr::get(func.getContext(), targetFeatures));
4339+
43294340
// Manage floating point exception, halting mode, and rounding mode
43304341
// settings at function entry and exit.
43314342
if (!funit.isMainProgram())
@@ -5091,12 +5102,12 @@ Fortran::lower::LoweringBridge::LoweringBridge(
50915102
const Fortran::lower::LoweringOptions &loweringOptions,
50925103
const std::vector<Fortran::lower::EnvironmentDefault> &envDefaults,
50935104
const Fortran::common::LanguageFeatureControl &languageFeatures,
5094-
const llvm::DataLayout *dataLayout)
5105+
const llvm::TargetMachine &targetMachine)
50955106
: semanticsContext{semanticsContext}, defaultKinds{defaultKinds},
50965107
intrinsics{intrinsics}, targetCharacteristics{targetCharacteristics},
50975108
cooked{&cooked}, context{context}, kindMap{kindMap},
50985109
loweringOptions{loweringOptions}, envDefaults{envDefaults},
5099-
languageFeatures{languageFeatures} {
5110+
languageFeatures{languageFeatures}, targetMachine{targetMachine} {
51005111
// Register the diagnostic handler.
51015112
context.getDiagEngine().registerHandler([](mlir::Diagnostic &diag) {
51025113
llvm::raw_ostream &os = llvm::errs();
@@ -5147,6 +5158,6 @@ Fortran::lower::LoweringBridge::LoweringBridge(
51475158
assert(module.get() && "module was not created");
51485159
fir::setTargetTriple(*module.get(), triple);
51495160
fir::setKindMapping(*module.get(), kindMap);
5150-
if (dataLayout)
5151-
fir::support::setMLIRDataLayout(*module.get(), *dataLayout);
5161+
fir::support::setMLIRDataLayout(*module.get(),
5162+
targetMachine.createDataLayout());
51525163
}

flang/test/Driver/save-mlir-temps.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
! Content to check from the MLIR outputs
5252
!--------------------------
5353
! MLIR-FIR-NOT: llvm.func
54-
! MLIR-FIR: func.func @{{.*}}main() {
54+
! MLIR-FIR: func.func @{{.*}}main()
5555

56-
! MLIR-FIR-NOT: func.func
57-
! MLIR-LLVMIR: llvm.func @{{.*}}main() {
56+
! MLIR-LLVMIR-NOT: func.func
57+
! MLIR-LLVMIR: llvm.func @{{.*}}main()
5858

5959
end program

flang/test/Lower/target-features.f90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s --check-prefixes=ALL,NONE
2+
! RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa %s -o - | FileCheck %s --check-prefixes=ALL,TRIPLE
3+
! RUN: %flang_fc1 -emit-fir -target-cpu gfx90a %s -o - | FileCheck %s --check-prefixes=ALL,CPU
4+
! RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa -target-cpu gfx90a %s -o - | FileCheck %s --check-prefixes=ALL,BOTH
5+
6+
! ALL-LABEL: func.func @_QPfoo()
7+
8+
! NONE-NOT: llvm.target_features
9+
! NONE-NOT: target_cpu
10+
11+
! TRIPLE-NOT: llvm.target_features
12+
! TRIPLE-SAME: target_cpu = "generic-hsa"
13+
14+
! CPU-NOT: llvm.target_features
15+
! CPU-SAME: target_cpu = "gfx90a"
16+
17+
! BOTH-SAME: llvm.target_features = "{{[^"]*}}+gfx90a-insts{{[^"]*}}"
18+
! BOTH-SAME: target_cpu = "gfx90a"
19+
subroutine foo
20+
end subroutine

flang/tools/bbc/bbc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ static mlir::LogicalResult convertFortranSourceToMLIR(
325325
auto &defKinds = semanticsContext.defaultKinds();
326326
fir::KindMapping kindMap(
327327
&ctx, llvm::ArrayRef<fir::KindTy>{fir::fromDefaultKinds(defKinds)});
328-
const llvm::DataLayout &dataLayout = targetMachine.createDataLayout();
329328
std::string targetTriple = targetMachine.getTargetTriple().normalize();
330329
// Use default lowering options for bbc.
331330
Fortran::lower::LoweringOptions loweringOptions{};
@@ -336,7 +335,7 @@ static mlir::LogicalResult convertFortranSourceToMLIR(
336335
ctx, semanticsContext, defKinds, semanticsContext.intrinsics(),
337336
semanticsContext.targetCharacteristics(), parsing.allCooked(),
338337
targetTriple, kindMap, loweringOptions, {},
339-
semanticsContext.languageFeatures(), &dataLayout);
338+
semanticsContext.languageFeatures(), targetMachine);
340339
burnside.lower(parseTree, semanticsContext);
341340
mlir::ModuleOp mlirModule = burnside.getModule();
342341
if (enableOpenMP) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
14181418
OptionalAttr<I64Attr>:$alignment,
14191419
OptionalAttr<LLVM_VScaleRangeAttr>:$vscale_range,
14201420
OptionalAttr<FramePointerKindAttr>:$frame_pointer,
1421+
OptionalAttr<StrAttr>:$target_cpu,
14211422
OptionalAttr<LLVM_TargetFeaturesAttr>:$target_features
14221423
);
14231424

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ def FlagsAttr : OpenMP_Attr<"Flags", "flags"> {
7171
let assemblyFormat = "`<` struct(params) `>`";
7272
}
7373

74-
def TargetAttr : OpenMP_Attr<"Target", "target"> {
75-
let parameters = (ins
76-
StringRefParameter<>:$target_cpu,
77-
StringRefParameter<>:$target_features
78-
);
79-
80-
let assemblyFormat = "`<` struct(params) `>`";
81-
}
82-
83-
8474
class OpenMP_Op<string mnemonic, list<Trait> traits = []> :
8575
Op<OpenMP_Dialect, mnemonic, traits>;
8676

mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -204,34 +204,6 @@ def OffloadModuleInterface : OpInterface<"OffloadModuleInterface"> {
204204
assumeTeamsOversubscription, assumeThreadsOversubscription,
205205
assumeNoThreadState, assumeNoNestedParallelism, openmpDeviceVersion));
206206
}]>,
207-
InterfaceMethod<
208-
/*description=*/[{
209-
Get the Target attribute on the current module if it exists
210-
and return the attribute, if it doesn't exist it returns a nullptr.
211-
}],
212-
/*retTy=*/"mlir::omp::TargetAttr",
213-
/*methodName=*/"getTarget",
214-
(ins), [{}], [{
215-
if (Attribute flags = $_op->getAttr("omp.target"))
216-
return ::llvm::dyn_cast_or_null<mlir::omp::TargetAttr>(flags);
217-
return nullptr;
218-
}]>,
219-
InterfaceMethod<
220-
/*description=*/[{
221-
Set the attribute target on the current module with the
222-
specified string arguments - name of cpu and corresponding features.
223-
}],
224-
/*retTy=*/"void",
225-
/*methodName=*/"setTarget",
226-
(ins "llvm::StringRef":$targetCPU,
227-
"llvm::StringRef":$targetFeatures), [{}], [{
228-
if (targetCPU.empty())
229-
return;
230-
$_op->setAttr(("omp." + mlir::omp::TargetAttr::getMnemonic()).str(),
231-
mlir::omp::TargetAttr::get($_op->getContext(),
232-
targetCPU.str(),
233-
targetFeatures.str()));
234-
}]>,
235207
InterfaceMethod<
236208
/*description=*/[{
237209
Set a StringAttr on the current module containing the host IR file path. This

mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ using namespace mlir;
6464
static constexpr StringRef varargsAttrName = "func.varargs";
6565
static constexpr StringRef linkageAttrName = "llvm.linkage";
6666
static constexpr StringRef barePtrAttrName = "llvm.bareptr";
67+
static constexpr StringRef targetFeaturesAttrName = "llvm.target_features";
6768

6869
/// Return `true` if the `op` should use bare pointer calling convention.
6970
static bool shouldUseBarePtrCallConv(Operation *op,
@@ -79,6 +80,7 @@ static void filterFuncAttributes(FunctionOpInterface func,
7980
for (const NamedAttribute &attr : func->getDiscardableAttrs()) {
8081
if (attr.getName() == linkageAttrName ||
8182
attr.getName() == varargsAttrName ||
83+
attr.getName() == targetFeaturesAttrName ||
8284
attr.getName() == LLVM::LLVMDialect::getReadnoneAttrName())
8385
continue;
8486
result.push_back(attr);
@@ -379,6 +381,19 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
379381
newFuncOp.setMemoryAttr(memoryAttr);
380382
}
381383

384+
// Create target_features attribute.
385+
if (funcOp->hasAttr(targetFeaturesAttrName)) {
386+
auto attr = funcOp->getAttrOfType<StringAttr>(targetFeaturesAttrName);
387+
if (!attr) {
388+
funcOp->emitError() << "Contains " << targetFeaturesAttrName
389+
<< " attribute not of type StringAttr";
390+
return rewriter.notifyMatchFailure(
391+
funcOp, "Contains target features attribute not of type StringAttr");
392+
}
393+
newFuncOp.setTargetFeaturesAttr(
394+
LLVM::TargetFeaturesAttr::get(rewriter.getContext(), attr.strref()));
395+
}
396+
382397
// Propagate argument/result attributes to all converted arguments/result
383398
// obtained after converting a given original argument/result.
384399
if (ArrayAttr resAttrDicts = funcOp.getAllResultAttrs()) {

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
23122312
if (!targetOpSupported(opInst))
23132313
return failure();
23142314

2315+
auto parentFn = opInst.getParentOfType<LLVM::LLVMFuncOp>();
23152316
auto targetOp = cast<omp::TargetOp>(opInst);
23162317
auto &targetRegion = targetOp.getRegion();
23172318
DataLayout dl = DataLayout(opInst.getParentOfType<ModuleOp>());
@@ -2322,6 +2323,23 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
23222323
auto bodyCB = [&](InsertPointTy allocaIP,
23232324
InsertPointTy codeGenIP) -> InsertPointTy {
23242325
builder.restoreIP(codeGenIP);
2326+
2327+
// Forward target-cpu and target-features function attributes from the
2328+
// original function to the new outlined function.
2329+
llvm::Function *llvmParentFn =
2330+
moduleTranslation.lookupFunction(parentFn.getName());
2331+
llvm::Function *llvmOutlinedFn = codeGenIP.getBlock()->getParent();
2332+
assert(llvmParentFn && llvmOutlinedFn &&
2333+
"Both parent and outlined functions must exist at this point");
2334+
2335+
if (auto attr = llvmParentFn->getFnAttribute("target-cpu");
2336+
attr.isStringAttribute())
2337+
llvmOutlinedFn->addFnAttr(attr);
2338+
2339+
if (auto attr = llvmParentFn->getFnAttribute("target-features");
2340+
attr.isStringAttribute())
2341+
llvmOutlinedFn->addFnAttr(attr);
2342+
23252343
unsigned argIndex = 0;
23262344
for (auto &mapOp : mapOperands) {
23272345
auto mapInfoOp =
@@ -2339,11 +2357,11 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
23392357
};
23402358

23412359
llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
2342-
StringRef parentName = opInst.getParentOfType<LLVM::LLVMFuncOp>().getName();
2360+
StringRef parentName = parentFn.getName();
23432361

23442362
// Override parent name if early outlining function
2345-
if (auto earlyOutlineOp = llvm::dyn_cast<mlir::omp::EarlyOutliningInterface>(
2346-
opInst.getParentOfType<LLVM::LLVMFuncOp>().getOperation())) {
2363+
if (auto earlyOutlineOp =
2364+
llvm::dyn_cast<mlir::omp::EarlyOutliningInterface>(*parentFn)) {
23472365
llvm::StringRef outlineParentName = earlyOutlineOp.getParentName();
23482366
parentName = outlineParentName.empty() ? parentName : outlineParentName;
23492367
}

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,11 @@ void ModuleImport::processFunctionAttributes(llvm::Function *func,
17351735
.value()));
17361736
}
17371737

1738+
if (llvm::Attribute attr = func->getFnAttribute("target-cpu");
1739+
attr.isStringAttribute()) {
1740+
funcOp.setTargetCpuAttr(StringAttr::get(context, attr.getValueAsString()));
1741+
}
1742+
17381743
if (llvm::Attribute attr = func->getFnAttribute("target-features");
17391744
attr.isStringAttribute()) {
17401745
funcOp.setTargetFeaturesAttr(

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,9 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
971971
if (func.getArmNewZa())
972972
llvmFunc->addFnAttr("aarch64_pstate_za_new");
973973

974+
if (auto targetCpu = func.getTargetCpu())
975+
llvmFunc->addFnAttr("target-cpu", *targetCpu);
976+
974977
if (auto targetFeatures = func.getTargetFeatures())
975978
llvmFunc->addFnAttr("target-features", targetFeatures->getFeaturesString());
976979

mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ func.func @variadic_func(%arg0: i32) attributes { "func.varargs" = true } {
6161
return
6262
}
6363

64+
// CHECK-LABEL: llvm.func @target_features()
65+
// CHECK-SAME: target_features = #llvm.target_features<["+sme", "+sve"]>
66+
func.func private @target_features() attributes { "llvm.target_features" = "+sme,+sve" }
67+
68+
// CHECK-LABEL: llvm.func @target_cpu()
69+
// CHECK-SAME: target_cpu = "gfx90a"
70+
func.func private @target_cpu() attributes { "target_cpu" = "gfx90a" }
71+
6472
// -----
6573

6674
// CHECK-LABEL: llvm.func @private_callee
@@ -86,3 +94,8 @@ func.func private @badllvmlinkage(i32) attributes { "llvm.linkage" = 3 : i64 } /
8694
func.func @variadic_func(%arg0: i32) attributes { "func.varargs" = true, "llvm.emit_c_interface" } {
8795
return
8896
}
97+
98+
// -----
99+
100+
// expected-error@+1{{Contains llvm.target_features attribute not of type StringAttr}}
101+
func.func private @badllvmtargetfeatures() attributes { "llvm.target_features" = 1 : i64 }

mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-analysis.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ func.func @insert_slice_chain(
772772
// CHECK-SAME: bufferization.access = "none"
773773
%arg2: tensor<62x90xf32> {bufferization.buffer_layout = affine_map<(d0, d1) -> (d0, d1)>, bufferization.writable = true})
774774
// CHECK-SAME: bufferization.access = "write"
775-
-> tensor<62x90xf32> attributes {passthrough = [["target-cpu", "skylake-avx512"], ["prefer-vector-width", "512"]]}
775+
-> tensor<62x90xf32> attributes {passthrough = [["prefer-vector-width", "512"]], target_cpu = "skylake-avx512"}
776776
{
777777
%c0 = arith.constant 0 : index
778778
%cst = arith.constant 0.000000e+00 : f32
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: mlir-translate -import-llvm -split-input-file %s | FileCheck %s
2+
3+
; CHECK-LABEL: llvm.func @target_cpu()
4+
; CHECK-SAME: target_cpu = "gfx90a"
5+
define void @target_cpu() #0 {
6+
ret void
7+
}
8+
9+
attributes #0 = { "target-cpu"="gfx90a" }

0 commit comments

Comments
 (0)