14
14
#include " ABI/LoweringFunctionInfo.h"
15
15
#include " ABI/LoweringModule.h"
16
16
#include " ABI/MissingFeature.h"
17
+ #include " mlir/Dialect/LLVMIR/LLVMDialect.h"
17
18
#include " mlir/IR/PatternMatch.h"
18
19
#include " mlir/Pass/Pass.h"
19
20
#include " mlir/Transforms/GreedyPatternRewriteDriver.h"
20
21
#include " clang/Basic/TargetOptions.h"
21
22
#include " clang/CIR/Dialect/IR/CIRDialect.h"
23
+ #include " llvm/IR/DataLayout.h"
22
24
#include " llvm/Support/raw_ostream.h"
23
25
24
26
#define GEN_PASS_DEF_CALLCONVLOWERING
@@ -37,6 +39,9 @@ struct DummyRewrite : public OpRewritePattern<FuncOp> {
37
39
LogicalResult matchAndRewrite (FuncOp op,
38
40
PatternRewriter &rewriter) const final {
39
41
auto module = op->getParentOfType <mlir::ModuleOp>();
42
+ auto dataLayout =
43
+ module->getAttr (LLVM::LLVMDialect::getDataLayoutAttrName ())
44
+ .cast <StringAttr>();
40
45
41
46
llvm::Triple triple (
42
47
module->getAttr (" cir.triple" ).cast <StringAttr>().getValue ());
@@ -52,12 +57,13 @@ struct DummyRewrite : public OpRewritePattern<FuncOp> {
52
57
auto context = CIRContext (module.getContext (), langOpts);
53
58
context.initBuiltinTypes (*targetInfo);
54
59
55
- LoweringModule state (context, module, *targetInfo);
60
+ LoweringModule state (context, module, dataLayout, *targetInfo);
56
61
57
62
const LoweringFunctionInfo &FI =
58
63
state.getTypes ().arrangeGlobalDeclaration (op);
59
64
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 " ;
61
67
62
68
return success ();
63
69
}
0 commit comments