@@ -34,13 +34,13 @@ namespace vast::cg {
34
34
35
35
owning_mlir_module_ref driver::freeze () { return std::move (top); }
36
36
37
- // TODO this should not be needed the data layout should be emitted from cached types directly
38
- dl::DataLayoutBlueprint emit_data_layout_blueprint (
39
- const acontext_t &actx, const type_caching_proxy &types
40
- ) {
37
+ // TODO this should not be needed the data layout should be emitted from cached types
38
+ // directly
39
+ dl::DataLayoutBlueprint
40
+ emit_data_layout_blueprint ( const acontext_t &actx, const type_caching_proxy &types ) {
41
41
dl::DataLayoutBlueprint dl;
42
42
43
- auto store_layout = [&] (const clang_type *orig, mlir_type vast_type) {
43
+ auto store_layout = [&](const clang_type *orig, mlir_type vast_type) {
44
44
if (orig->isFunctionType ()) {
45
45
return ;
46
46
}
@@ -83,7 +83,9 @@ namespace vast::cg {
83
83
auto list = std::dynamic_pointer_cast< visitor_list >(visitor);
84
84
for (auto node = list->head ; node; node = node->next ) {
85
85
if (auto types = std::dynamic_pointer_cast< type_caching_proxy >(node)) {
86
- ::vast::cg::emit_data_layout (mctx, mod, emit_data_layout_blueprint(actx, *types));
86
+ ::vast::cg::emit_data_layout (
87
+ mctx, mod, emit_data_layout_blueprint(actx, *types)
88
+ );
87
89
}
88
90
}
89
91
}
@@ -94,9 +96,8 @@ namespace vast::cg {
94
96
return std::make_unique< codegen_builder >(&mctx);
95
97
}
96
98
97
- std::shared_ptr< meta_generator > mk_meta_generator (
98
- acontext_t *actx, mcontext_t *mctx, const cc::vast_args &vargs
99
- ) {
99
+ std::shared_ptr< meta_generator >
100
+ mk_meta_generator (acontext_t *actx, mcontext_t *mctx, const cc::vast_args &vargs) {
100
101
if (vargs.has_option (cc::opt::locs_as_meta_ids)) {
101
102
return std::make_shared< id_meta_gen >(actx, mctx);
102
103
}
@@ -123,28 +124,23 @@ namespace vast::cg {
123
124
// setup visitor list
124
125
const bool enable_unsupported = !vargs.has_option (cc::opt::disable_unsupported);
125
126
126
- auto mg = mk_meta_generator (&actx, &mctx, vargs);
127
+ auto mg = mk_meta_generator (&actx, &mctx, vargs);
127
128
auto invalid_mg = mk_invalid_meta_generator (&mctx);
128
- auto sg = mk_symbol_generator (actx);
129
- auto policy = mk_codegen_policy (opts);
129
+ auto sg = mk_symbol_generator (actx);
130
+ auto policy = mk_codegen_policy (opts);
130
131
131
132
auto visitors = std::make_shared< visitor_list >()
132
- | as_node_with_list_ref< attr_visitor_proxy >()
133
- | as_node< type_caching_proxy >()
133
+ | as_node_with_list_ref< attr_visitor_proxy >() | as_node< type_caching_proxy >()
134
134
| as_node_with_list_ref< default_visitor >(
135
- mctx, actx, *bld, std::move (mg), std::move (sg), std::move (policy)
135
+ mctx, actx, *bld, std::move (mg), std::move (sg), std::move (policy)
136
136
)
137
137
| optional (enable_unsupported,
138
- as_node_with_list_ref< unsup_visitor >(
139
- mctx, *bld, std::move (invalid_mg)
140
- )
138
+ as_node_with_list_ref< unsup_visitor >(mctx, *bld, std::move (invalid_mg))
141
139
)
142
140
| as_node< unreach_visitor >();
143
141
144
142
// setup driver
145
- auto drv = std::make_unique< driver >(
146
- actx, mctx, std::move (bld), visitors
147
- );
143
+ auto drv = std::make_unique< driver >(actx, mctx, std::move (bld), visitors);
148
144
149
145
drv->enable_verifier (!vargs.has_option (cc::opt::disable_vast_verifier));
150
146
return drv;
@@ -181,24 +177,23 @@ namespace vast::cg {
181
177
}
182
178
} // namespace detail
183
179
184
- owning_mlir_module_ref mk_wrapping_module (mcontext_t &mctx) {
185
- return mlir::ModuleOp::create (mlir::UnknownLoc::get (&mctx));
180
+ owning_mlir_module_ref mk_wrapping_module (acontext_t &actx, mcontext_t &mctx) {
181
+ auto [loc, _] = detail::module_loc_name (mctx, actx);
182
+ return mlir::ModuleOp::create (loc);
186
183
}
187
184
188
185
core::module mk_module (acontext_t &actx, mlir_module top) {
189
186
mlir::OpBuilder bld (top);
190
187
bld.setInsertionPointToStart (top.getBody ());
191
188
192
189
// TODO use symbol generator
193
- auto mctx = top.getContext ();
190
+ auto mctx = top.getContext ();
194
191
auto [loc, name] = detail::module_loc_name (*mctx, actx);
195
192
return bld.create < core::module >(loc, name);
196
193
}
197
194
198
- core::module mk_module_with_attrs (
199
- acontext_t &actx, mlir_module top,
200
- cc::source_language lang
201
- ) {
195
+ core::module
196
+ mk_module_with_attrs (acontext_t &actx, mlir_module top, cc::source_language lang) {
202
197
auto mod = mk_module (actx, top);
203
198
204
199
set_target_triple (mod, actx.getTargetInfo ().getTriple ().str ());
0 commit comments