diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -98,7 +98,7 @@ ConstantOp::build(builder, state, dataType, dataAttribute); } -/// The 'OpAsmPrinter' class provides a collection of methods for parsing +/// The 'OpAsmParser' class provides a collection of methods for parsing /// various punctuation, as well as attributes, operands, types, etc. Each of /// these methods returns a `ParseResult`. This class is a wrapper around /// `LogicalResult` that can be converted to a boolean `true` value on failure, @@ -116,7 +116,7 @@ return success(); } -/// The 'OpAsmPrinter' class is a stream that will allows for formatting +/// The 'OpAsmPrinter' class is a stream that allows for formatting /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -98,7 +98,7 @@ ConstantOp::build(builder, state, dataType, dataAttribute); } -/// The 'OpAsmPrinter' class provides a collection of methods for parsing +/// The 'OpAsmParser' class provides a collection of methods for parsing /// various punctuation, as well as attributes, operands, types, etc. Each of /// these methods returns a `ParseResult`. This class is a wrapper around /// `LogicalResult` that can be converted to a boolean `true` value on failure, @@ -116,7 +116,7 @@ return success(); } -/// The 'OpAsmPrinter' class is a stream that will allows for formatting +/// The 'OpAsmPrinter' class is a stream that allows for formatting /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; diff --git a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp @@ -24,7 +24,7 @@ } // end anonymous namespace /// This is an example of a c++ rewrite pattern for the TransposeOp. It -/// optimizes the following scenario: transpose(transpose(x)) -> transpose(x) +/// optimizes the following scenario: transpose(transpose(x)) -> x struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { /// We register this pattern to match every toy.transpose in the IR. /// The "benefit" is used by the framework to order the patterns and process diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -166,7 +166,7 @@ return success(); } -/// The 'OpAsmPrinter' class is a stream that will allows for formatting +/// The 'OpAsmPrinter' class is a stream that allows for formatting /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; diff --git a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp @@ -29,7 +29,7 @@ } /// This is an example of a c++ rewrite pattern for the TransposeOp. It -/// optimizes the following scenario: transpose(transpose(x)) -> transpose(x) +/// optimizes the following scenario: transpose(transpose(x)) -> x struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { /// We register this pattern to match every toy.transpose in the IR. /// The "benefit" is used by the framework to order the patterns and process diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -148,7 +148,7 @@ ConstantOp::build(builder, state, dataType, dataAttribute); } -/// The 'OpAsmPrinter' class provides a collection of methods for parsing +/// The 'OpAsmParser' class provides a collection of methods for parsing /// various punctuation, as well as attributes, operands, types, etc. Each of /// these methods returns a `ParseResult`. This class is a wrapper around /// `LogicalResult` that can be converted to a boolean `true` value on failure, @@ -166,7 +166,7 @@ return success(); } -/// The 'OpAsmPrinter' class is a stream that will allows for formatting +/// The 'OpAsmPrinter' class is a stream that allows for formatting /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; diff --git a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp @@ -29,7 +29,7 @@ } /// This is an example of a c++ rewrite pattern for the TransposeOp. It -/// optimizes the following scenario: transpose(transpose(x)) -> transpose(x) +/// optimizes the following scenario: transpose(transpose(x)) -> x struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { /// We register this pattern to match every toy.transpose in the IR. /// The "benefit" is used by the framework to order the patterns and process diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -148,7 +148,7 @@ ConstantOp::build(builder, state, dataType, dataAttribute); } -/// The 'OpAsmPrinter' class provides a collection of methods for parsing +/// The 'OpAsmParser' class provides a collection of methods for parsing /// various punctuation, as well as attributes, operands, types, etc. Each of /// these methods returns a `ParseResult`. This class is a wrapper around /// `LogicalResult` that can be converted to a boolean `true` value on failure, @@ -166,7 +166,7 @@ return success(); } -/// The 'OpAsmPrinter' class is a stream that will allows for formatting +/// The 'OpAsmPrinter' class is a stream that allows for formatting /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -6,9 +6,18 @@ // //===----------------------------------------------------------------------===// // -// This file implements a partial lowering of Toy operations to a combination of -// affine loops and standard operations. This lowering expects that all calls -// have been inlined, and all shapes have been resolved. +// This file implements full lowering of Toy operations to LLVM MLIR dialect. +// 'toy.print' is lowered to a loop nest that calls `printf` on each element of +// the input array. The file also sets up the ToyToLLVMLoweringPass. This pass +// lowers the combination of Affine + SCF + Standard dialects to the LLVM one: +// +// Affine -- +// | +// v +// Standard --> LLVM (Dialect) +// ^ +// | +// 'toy.print' --> Loop (SCF) -- // //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp @@ -29,7 +29,7 @@ } /// This is an example of a c++ rewrite pattern for the TransposeOp. It -/// optimizes the following scenario: transpose(transpose(x)) -> transpose(x) +/// optimizes the following scenario: transpose(transpose(x)) -> x struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { /// We register this pattern to match every toy.transpose in the IR. /// The "benefit" is used by the framework to order the patterns and process diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -161,7 +161,7 @@ ConstantOp::build(builder, state, dataType, dataAttribute); } -/// The 'OpAsmPrinter' class provides a collection of methods for parsing +/// The 'OpAsmParser' class provides a collection of methods for parsing /// various punctuation, as well as attributes, operands, types, etc. Each of /// these methods returns a `ParseResult`. This class is a wrapper around /// `LogicalResult` that can be converted to a boolean `true` value on failure, @@ -179,7 +179,7 @@ return success(); } -/// The 'OpAsmPrinter' class is a stream that will allows for formatting +/// The 'OpAsmPrinter' class is a stream that allows for formatting /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -6,9 +6,18 @@ // //===----------------------------------------------------------------------===// // -// This file implements a partial lowering of Toy operations to a combination of -// affine loops and standard operations. This lowering expects that all calls -// have been inlined, and all shapes have been resolved. +// This file implements full lowering of Toy operations to LLVM MLIR dialect. +// 'toy.print' is lowered to a loop nest that calls `printf` on each element of +// the input array. The file also sets up the ToyToLLVMLoweringPass. This pass +// lowers the combination of Affine + SCF + Standard dialects to the LLVM one: +// +// Affine -- +// | +// v +// Standard --> LLVM (Dialect) +// ^ +// | +// 'toy.print' --> Loop (SCF) -- // //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp @@ -47,7 +47,7 @@ } /// This is an example of a c++ rewrite pattern for the TransposeOp. It -/// optimizes the following scenario: transpose(transpose(x)) -> transpose(x) +/// optimizes the following scenario: transpose(transpose(x)) -> x struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { /// We register this pattern to match every toy.transpose in the IR. /// The "benefit" is used by the framework to order the patterns and process