Skip to content

Commit 7d83175

Browse files
committed
added coversion of CIR TargetTripleAttr to llvm mlir TargetTripleAttr when convertion MLIR core module to LLVM MLIR module + added removal of unnecessary CIR Attr
1 parent 11d674b commit 7d83175

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

clang/lib/CIR/Lowering/ThroughMLIR/LowerMLIRToLLVM.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "mlir/Pass/PassManager.h"
2525
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
2626
#include "mlir/Transforms/DialectConversion.h"
27+
#include "clang/CIR/Dialect/IR/CIRDialect.h"
2728
#include "clang/CIR/Passes.h"
2829

2930
using namespace cir;
@@ -62,6 +63,17 @@ void ConvertMLIRToLLVMPass::runOnOperation() {
6263
populateFuncToLLVMConversionPatterns(typeConverter, patterns);
6364

6465
auto module = getOperation();
66+
67+
// Lower the module attributes to LLVM equivalents.
68+
if (auto tripleAttr = module->getAttr(cir::CIRDialect::getTripleAttrName()))
69+
module->setAttr(mlir::LLVM::LLVMDialect::getTargetTripleAttrName(),
70+
tripleAttr);
71+
72+
// Strip the CIR attributes.
73+
module->removeAttr(cir::CIRDialect::getSOBAttrName());
74+
module->removeAttr(cir::CIRDialect::getLangAttrName());
75+
module->removeAttr(cir::CIRDialect::getTripleAttrName());
76+
6577
if (failed(applyFullConversion(module, target, std::move(patterns))))
6678
signalPassFailure();
6779
}

0 commit comments

Comments
 (0)