================ @@ -264,6 +263,37 @@ static void addDepdendentLibs(mlir::ModuleOp &mlirModule, } } +// Add to MLIR code target specific items which are dependent on target +// configuration specified by the user +static void addTargetSpecificMLIRItems(mlir::ModuleOp &mlirModule, + CompilerInstance &ci) { + const TargetOptions &targetOpts = ci.getInvocation().getTargetOpts(); + const llvm::Triple triple(targetOpts.triple); + if (triple.isAMDGPU()) { + unsigned oclcABIVERsion; + const unsigned defaultOclcABIVERsion = 400; + mlir::OpBuilder builder(mlirModule.getContext()); + const CodeGenOptions &codeGenOpts = ci.getInvocation().getCodeGenOpts(); + if (codeGenOpts.CodeObjectVersion == + CodeGenOptions::CodeObjectVersionKind::COV_None) + oclcABIVERsion = defaultOclcABIVERsion; + else + oclcABIVERsion = static_cast<unsigned>(codeGenOpts.CodeObjectVersion); + + auto int32Type = builder.getI32Type(); + auto covInfo = builder.create<mlir::LLVM::GlobalOp>( + mlirModule.getLoc(), int32Type, true, mlir::LLVM::Linkage::WeakODR, + "__oclc_ABI_version", + builder.getIntegerAttr(int32Type, oclcABIVERsion)); + covInfo.setUnnamedAddr(mlir::LLVM::UnnamedAddr::Local); + covInfo.setAddrSpace(4); + covInfo.setVisibility_(mlir::LLVM::Visibility::Hidden); + builder.setInsertionPointToStart(mlirModule.getBody()); + builder.insert(covInfo); + } + addDependentLibs(mlirModule, ci); ---------------- banach-space wrote:
My terminology might be off, but: * most of this function adds some specific to a particular hardware _target_ (i.e. AMDGPU), * `addDependentLibs` is something linked to specific to a particular _platform_ (i.e. MSVC/Windows). My suggestion: * keep `addDependentLibs` as an independent hook, * rename `addTargetSpecificMLIRItems` as `addAMDGPUSpecificMLIRItems` (we can rename this later if people want to add support for other targets). @jsjodin - is that consistent with what you had in mind? https://github.com/llvm/llvm-project/pull/72638 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits