Trying to build a graph visualizer and analyzer and for that need to start with an MLIR txt and byte code reader.
I got the following structure:
#include <iostream>
#include <iomanip>
#include <filesystem>
#include "mlir/Parser/Parser.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/BuiltinOps.h"
#include "llvm/Support/SourceMgr.h"
int main(int argc, char* argv[]) {
mlir::MLIRContext context;
llvm::SourceMgr sourceMgr;
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <path-to-mlirbc-file>\n";
return 1;
}
std::string filepath = argv[1];
// Load your MLIR source into sourceMgr here.
mlir::OwningOpRef<mlir::ModuleOp> module =
mlir::parseSourceFile<mlir::ModuleOp>(sourceMgr, &context);
if (!module) {
// Handle parsing error.
return 1;
}
// Use the parsed module as needed.
return 0;
}
It has all the right includes, but how do I find all the libraries that need to be loaded, and second, what is the CMake infrastructure that I need to pull in to name these libs symbolically? This must run across platforms, such as Windows/MacOS/Linux.
and that is giving me a working skeleton.
compile_all() is a macro for automating a GLOB into a set of tests.
I wasn’t able to figure out how to generalize the target_link_libraries so that it would associate programmatic targets to a set of MLIR libs, so I split it out explicitely.
In general there is a 1:1 mapping from the header path to a library: so without looking at the code I would say you’d need MLIRIR, MLIRParse, and LLVMSupport here
Not sure I understand the question exactly, but have you seen this example: it shows how an external project can be setup to use MLIR.