================ @@ -4290,6 +4291,18 @@ class FirConverter : public Fortran::lower::AbstractConverter { assert(blockId == 0 && "invalid blockId"); assert(activeConstructStack.empty() && "invalid construct stack state"); + // Set target_cpu and target_features attributes to be passed through to the + // llvm.func operation during lowering. + const llvm::TargetMachine &targetMachine = bridge.getTargetMachine(); + if (auto targetCPU = targetMachine.getTargetCPU(); !targetCPU.empty()) + func->setAttr("target_cpu", + mlir::StringAttr::get(func.getContext(), targetCPU)); + + if (auto targetFeatures = targetMachine.getTargetFeatureString(); + !targetFeatures.empty()) + func->setAttr("target_features", mlir::LLVM::TargetFeaturesAttr::get( + func.getContext(), targetFeatures)); ---------------- kparzysz wrote:
In FrontendAction we already have the TargetMachine, and we use a part of it in the bridge, so this change does not introduce any new dependencies. Not that it would be wrong to do so, but it shows that we already use a part of the information from the target machine. I think it is logical to take it further, and include _all_ information from TargetMachine into the lowered MLIR. https://github.com/llvm/llvm-project/pull/78289 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits