1414#include " ABI/LoweringFunctionInfo.h"
1515#include " ABI/LoweringModule.h"
1616#include " ABI/MissingFeature.h"
17+ #include " mlir/Dialect/LLVMIR/LLVMDialect.h"
1718#include " mlir/IR/PatternMatch.h"
1819#include " mlir/Pass/Pass.h"
1920#include " mlir/Transforms/GreedyPatternRewriteDriver.h"
2021#include " clang/Basic/TargetOptions.h"
2122#include " clang/CIR/Dialect/IR/CIRDialect.h"
23+ #include " llvm/IR/DataLayout.h"
2224#include " llvm/Support/raw_ostream.h"
2325
2426#define GEN_PASS_DEF_CALLCONVLOWERING
@@ -37,6 +39,9 @@ struct DummyRewrite : public OpRewritePattern<FuncOp> {
3739 LogicalResult matchAndRewrite (FuncOp op,
3840 PatternRewriter &rewriter) const final {
3941 auto module = op->getParentOfType <mlir::ModuleOp>();
42+ auto dataLayout =
43+ module ->getAttr (LLVM::LLVMDialect::getDataLayoutAttrName ())
44+ .cast <StringAttr>();
4045
4146 llvm::Triple triple (
4247 module ->getAttr (" cir.triple" ).cast <StringAttr>().getValue ());
@@ -52,12 +57,13 @@ struct DummyRewrite : public OpRewritePattern<FuncOp> {
5257 auto context = CIRContext (module .getContext (), langOpts);
5358 context.initBuiltinTypes (*targetInfo);
5459
55- LoweringModule state (context, module , *targetInfo);
60+ LoweringModule state (context, module , dataLayout, *targetInfo);
5661
5762 const LoweringFunctionInfo &FI =
5863 state.getTypes ().arrangeGlobalDeclaration (op);
5964 FuncType Ty = state.getTypes ().getFunctionType (FI);
60- Ty.dump ();
65+ llvm::outs () << " Call Conv Lowering \n \t from: " << op.getFunctionType ()
66+ << " \n\t to: " << Ty << " \n " ;
6167
6268 return success ();
6369 }
0 commit comments