23 auto LoadModule(mlir::MLIRContext &context,
const std::string &filename) -> std::unique_ptr<mlir::ModuleOp> {
43auto main(
const int argc,
char **argv) ->
int {
44 mlir::MLIRContext context;
46 mlir::DialectRegistry registry;
50 context.appendDialectRegistry(registry);
53 llvm::errs() <<
"usage: mllif-mlir <output> <file>...\n";
56 const std::string output = argv[1];
60 for (
auto i = 2; i < argc; ++i) {
61 const std::shared_ptr module = LoadModule(context, std::string(argv[i]));
63 module->walk([&module, &symbols](mlir::Operation *op, const mlir::WalkStage &stage) {
64 if (!stage.isAfterAllRegions()) {
69 adapter->handle(symbols, module, op);
74 std::error_code error;
75 llvm::raw_fd_ostream os(output, error);
77 llvm::errs() <<
"error: couldn't open file '" << output <<
"': " << error.message() <<
"\n";
81 symbols.root().print(os);