Register printer and context CL options with the toyc example
authorMehdi Amini <joker.eph@gmail.com>
Wed, 10 Jun 2020 18:18:43 +0000 (18:18 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 10 Jun 2020 19:59:40 +0000 (19:59 +0000)
The tutorial refers to invoking toyc with '-mlir-print-debuginfo' but
it wasn't registered anymore.

Differential Revision: https://reviews.llvm.org/D81604

mlir/examples/toy/Ch2/toyc.cpp
mlir/examples/toy/Ch3/toyc.cpp
mlir/examples/toy/Ch4/toyc.cpp
mlir/examples/toy/Ch5/toyc.cpp
mlir/examples/toy/Ch6/toyc.cpp
mlir/examples/toy/Ch7/toyc.cpp

index 22a33aa..d0880ce 100644 (file)
@@ -15,6 +15,7 @@
 #include "toy/Parser.h"
 #include <memory>
 
+#include "mlir/IR/AsmState.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/Module.h"
 #include "mlir/IR/Verifier.h"
@@ -122,6 +123,9 @@ int dumpAST() {
 }
 
 int main(int argc, char **argv) {
+  // Register any command line options.
+  mlir::registerAsmPrinterCLOptions();
+  mlir::registerMLIRContextCLOptions();
   cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
 
   switch (emitAction) {
index 0f09acb..f9d5631 100644 (file)
@@ -14,6 +14,7 @@
 #include "toy/MLIRGen.h"
 #include "toy/Parser.h"
 
+#include "mlir/IR/AsmState.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/Module.h"
 #include "mlir/IR/Verifier.h"
@@ -141,7 +142,11 @@ int dumpAST() {
 }
 
 int main(int argc, char **argv) {
+  // Register any command line options.
+  mlir::registerAsmPrinterCLOptions();
+  mlir::registerMLIRContextCLOptions();
   mlir::registerPassManagerCLOptions();
+
   cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
 
   switch (emitAction) {
index b757d66..e11f35c 100644 (file)
@@ -15,6 +15,7 @@
 #include "toy/Parser.h"
 #include "toy/Passes.h"
 
+#include "mlir/IR/AsmState.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/Module.h"
 #include "mlir/IR/Verifier.h"
@@ -150,7 +151,11 @@ int dumpAST() {
 }
 
 int main(int argc, char **argv) {
+  // Register any command line options.
+  mlir::registerAsmPrinterCLOptions();
+  mlir::registerMLIRContextCLOptions();
   mlir::registerPassManagerCLOptions();
+
   cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
 
   switch (emitAction) {
index b4d3988..ed04969 100644 (file)
@@ -15,6 +15,7 @@
 #include "toy/Parser.h"
 #include "toy/Passes.h"
 
+#include "mlir/IR/AsmState.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/Module.h"
 #include "mlir/IR/Verifier.h"
@@ -172,7 +173,12 @@ int dumpAST() {
 
 int main(int argc, char **argv) {
   mlir::registerAllDialects();
+
+  // Register any command line options.
+  mlir::registerAsmPrinterCLOptions();
+  mlir::registerMLIRContextCLOptions();
   mlir::registerPassManagerCLOptions();
+
   cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
 
   switch (emitAction) {
index a713b1a..2f984cb 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "mlir/ExecutionEngine/ExecutionEngine.h"
 #include "mlir/ExecutionEngine/OptUtils.h"
+#include "mlir/IR/AsmState.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/Module.h"
 #include "mlir/IR/Verifier.h"
@@ -239,7 +240,12 @@ int runJit(mlir::ModuleOp module) {
 
 int main(int argc, char **argv) {
   mlir::registerAllDialects();
+
+  // Register any command line options.
+  mlir::registerAsmPrinterCLOptions();
+  mlir::registerMLIRContextCLOptions();
   mlir::registerPassManagerCLOptions();
+
   cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
 
   if (emitAction == Action::DumpAST)
index a8795d8..ef2bf83 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "mlir/ExecutionEngine/ExecutionEngine.h"
 #include "mlir/ExecutionEngine/OptUtils.h"
+#include "mlir/IR/AsmState.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/Module.h"
 #include "mlir/IR/Verifier.h"
@@ -240,7 +241,12 @@ int runJit(mlir::ModuleOp module) {
 
 int main(int argc, char **argv) {
   mlir::registerAllDialects();
+
+  // Register any command line options.
+  mlir::registerAsmPrinterCLOptions();
+  mlir::registerMLIRContextCLOptions();
   mlir::registerPassManagerCLOptions();
+
   cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
 
   if (emitAction == Action::DumpAST)