Skip to content

Commit

Permalink
repl: Mock basic initialization and usage of tower on mlir module c…
Browse files Browse the repository at this point in the history
…reation.
  • Loading branch information
lkorenc committed Jun 20, 2024
1 parent 2c85be8 commit 7fc2184
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 8 additions & 0 deletions include/vast/repl/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ namespace vast::repl {
// mlir module and context
//
mcontext_t &ctx;

//
// Tower related state
//
tw::location_info li;
std::optional< tw::default_tower > tower;

//
Expand All @@ -44,6 +49,9 @@ namespace vast::repl {
// verbosity flags
//
bool verbose_pipeline = true;

void raise_tower(owning_module_ref mod);
vast_module current_module();
};

} // namespace vast::repl
1 change: 1 addition & 0 deletions tools/vast-repl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_vast_executable(vast-repl
codegen.cpp
command.cpp
config.cpp
state.cpp

LINK_LIBS
${CLANG_LIBS}
Expand Down
11 changes: 4 additions & 7 deletions tools/vast-repl/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ namespace cmd {
}

void check_and_emit_module(state_t &state) {
if (!state.tower) {
check_source(state);
auto mod = codegen::emit_module(state.source.value(), state.ctx);
auto [t, _] = tw::default_tower::get(state.ctx, std::move(mod));
state.tower = std::move(t);
}
check_source(state);
auto mod = codegen::emit_module(state.source.value(), state.ctx);
state.raise_tower(std::move(mod));
}

//
Expand Down Expand Up @@ -77,7 +74,7 @@ namespace cmd {

void show_module(state_t &state) {
check_and_emit_module(state);
llvm::outs() << state.tower->top().mod << "\n";
llvm::outs() << state.current_module() << "\n";
}

void show_symbols(state_t &state) {
Expand Down

0 comments on commit 7fc2184

Please sign in to comment.