Skip to content

Commit

Permalink
Let mlir-miopen-driver to recognize mlir-opt options.
Browse files Browse the repository at this point in the history
  • Loading branch information
whchung committed Jun 6, 2020
1 parent ed1c0ff commit ec9e3b7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mlir/tools/mlir-miopen-driver/mlir-miopen-driver.cpp
Expand Up @@ -23,6 +23,9 @@
#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Types.h"
#include "mlir/InitAllDialects.h"
#include "mlir/InitAllPasses.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/FileUtilities.h"
#include "mlir/Support/LogicalResult.h"

Expand Down Expand Up @@ -275,10 +278,24 @@ static LogicalResult populateModule(ModuleOp &module, OpBuilder &builder,
return success();
}

static LogicalResult runMLIRPasses(ModuleOp &module, mlir::PassPipelineCLParser &passPipeline) {
PassManager pm(module.getContext());
applyPassManagerCLOptions(pm);
if (failed(passPipeline.addToPipeline(pm)))
return failure();

return pm.run(module);
}

int main(int argc, char **argv) {
mlir::registerAllDialects();
mlir::registerAllPasses();
InitLLVM y(argc, argv);

// Register any pass manager command line options.
mlir::registerPassManagerCLOptions();
mlir::PassPipelineCLParser passPipeline("", "compiler passes to run");

// Parse pass names in main to ensure static initialization completed.
cl::ParseCommandLineOptions(argc, argv, "MLIR MIOpen Dialect driver\n");

Expand All @@ -293,6 +310,12 @@ int main(int argc, char **argv) {
exit(1);
}

// Apply passes.
if (failed(runMLIRPasses(module, passPipeline))) {
llvm::errs() << "Lowering failed\n";
exit(1);
}

// Set up the output file.
std::string errorMessage;
auto output = openOutputFile(outputFilename, &errorMessage);
Expand Down

0 comments on commit ec9e3b7

Please sign in to comment.