[Mlir-commits] [llvm] [mlir] [mlir][docs] Fix typo: 'DDR' → 'DRR' in Creating a Dialect tutorial (PR #161965)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Oct 4 12:05:58 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Joseph Bak (josephbak)

<details>
<summary>Changes</summary>

Fixes a small typo in the Creating a Dialect tutorial.

The rewrite rules format should be DRR (Declarative Rewrite Rules), not DDR.

---
Full diff: https://github.com/llvm/llvm-project/pull/161965.diff


3 Files Affected:

- (modified) llvm/examples/Kaleidoscope/Chapter2/toy.cpp (+3-1) 
- (modified) mlir/docs/Tutorials/CreatingADialect.md (+1-1) 
- (added) tmp/ToyDialect.md (+259) 


``````````diff
diff --git a/llvm/examples/Kaleidoscope/Chapter2/toy.cpp b/llvm/examples/Kaleidoscope/Chapter2/toy.cpp
index 882613533bb67..6a774cd8cbbab 100644
--- a/llvm/examples/Kaleidoscope/Chapter2/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter2/toy.cpp
@@ -33,9 +33,11 @@ static int gettok() {
   static int LastChar = ' ';
 
   // Skip any whitespace.
-  while (isspace(LastChar))
+  while (isspace(LastChar)){
     LastChar = getchar();
+  }
 
+  // Get identifier
   if (isalpha(LastChar)) { // identifier: [a-zA-Z][a-zA-Z0-9]*
     IdentifierStr = LastChar;
     while (isalnum((LastChar = getchar())))
diff --git a/mlir/docs/Tutorials/CreatingADialect.md b/mlir/docs/Tutorials/CreatingADialect.md
index af709fc46eff5..e30b80bc5207c 100644
--- a/mlir/docs/Tutorials/CreatingADialect.md
+++ b/mlir/docs/Tutorials/CreatingADialect.md
@@ -22,7 +22,7 @@ typically defined in FooDialect.cpp, which includes FooOps.cpp.inc and
 FooOpsInterfaces.h.inc.
 
 The 'Transforms' directory contains rewrite rules for the dialect,
-typically described in TableGen file using the [DDR
+typically described in TableGen file using the [DRR
 format](../DeclarativeRewrites.md).
 
 Note that dialect names should not generally be suffixed with “Ops”,
diff --git a/tmp/ToyDialect.md b/tmp/ToyDialect.md
new file mode 100644
index 0000000000000..a991811f4267c
--- /dev/null
+++ b/tmp/ToyDialect.md
@@ -0,0 +1,259 @@
+<!-- Autogenerated by mlir-tblgen; don't manually edit -->
+
+### `toy.add` (toy::AddOp)
+
+_Element-wise addition operation_
+
+The "add" operation performs element-wise addition between two tensors.
+The shapes of the tensor operands are expected to match.
+
+#### Operands:
+
+| Operand | Description |
+| :-----: | ----------- |
+| `lhs` | tensor of 64-bit float values |
+| `rhs` | tensor of 64-bit float values |
+
+#### Results:
+
+| Result | Description |
+| :----: | ----------- |
+| «unnamed» | tensor of 64-bit float values |
+
+
+### `toy.constant` (toy::ConstantOp)
+
+_Constant_
+
+Constant operation turns a literal into an SSA value. The data is attached
+to the operation as an attribute. For example:
+
+```mlir
+  %0 = toy.constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]>
+                    : tensor<2x3xf64>
+```
+
+Traits: `AlwaysSpeculatableImplTrait`
+
+Interfaces: `ConditionallySpeculatable`, `NoMemoryEffect (MemoryEffectOpInterface)`
+
+Effects: `MemoryEffects::Effect{}`
+
+#### Attributes:
+
+<table>
+<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
+<tr><td><code>value</code></td><td>::mlir::DenseElementsAttr</td><td>64-bit float elements attribute</td></tr>
+</table>
+
+#### Results:
+
+| Result | Description |
+| :----: | ----------- |
+| «unnamed» | tensor of 64-bit float values |
+
+
+### `toy.func` (toy::FuncOp)
+
+_User defined function operation_
+
+The "toy.func" operation represents a user defined function. These are
+callable SSA-region operations that contain toy computations.
+
+Example:
+
+```mlir
+toy.func @main() {
+  %0 = toy.constant dense<5.500000e+00> : tensor<f64>
+  %1 = toy.reshape(%0 : tensor<f64>) to tensor<2x2xf64>
+  toy.print %1 : tensor<2x2xf64>
+  toy.return
+}
+```
+
+Traits: `IsolatedFromAbove`
+
+Interfaces: `ArgAndResultAttrsOpInterface`, `CallableOpInterface`, `FunctionOpInterface`, `Symbol`
+
+#### Attributes:
+
+<table>
+<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
+<tr><td><code>sym_name</code></td><td>::mlir::StringAttr</td><td>string attribute</td></tr>
+<tr><td><code>function_type</code></td><td>::mlir::TypeAttr</td><td>type attribute of function type</td></tr>
+<tr><td><code>arg_attrs</code></td><td>::mlir::ArrayAttr</td><td>Array of dictionary attributes</td></tr>
+<tr><td><code>res_attrs</code></td><td>::mlir::ArrayAttr</td><td>Array of dictionary attributes</td></tr>
+</table>
+
+
+### `toy.generic_call` (toy::GenericCallOp)
+
+_Generic call operation_
+
+Syntax:
+
+```
+operation ::= `toy.generic_call` $callee `(` $inputs `)` attr-dict `:` functional-type($inputs, results)
+```
+
+Generic calls represent calls to a user defined function that needs to
+be specialized for the shape of its arguments. The callee name is attached
+as a symbol reference via an attribute. The arguments list must match the
+arguments expected by the callee. For example:
+
+```mlir
+ %4 = toy.generic_call @my_func(%1, %3)
+       : (tensor<2x3xf64>, tensor<2x3xf64>) -> tensor<*xf64>
+```
+
+This is only valid if a function named "my_func" exists and takes two
+arguments.
+
+#### Attributes:
+
+<table>
+<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
+<tr><td><code>callee</code></td><td>::mlir::FlatSymbolRefAttr</td><td>flat symbol reference attribute</td></tr>
+</table>
+
+#### Operands:
+
+| Operand | Description |
+| :-----: | ----------- |
+| `inputs` | variadic of tensor of 64-bit float values |
+
+#### Results:
+
+| Result | Description |
+| :----: | ----------- |
+| «unnamed» | tensor of 64-bit float values |
+
+
+### `toy.mul` (toy::MulOp)
+
+_Element-wise multiplication operation_
+
+The "mul" operation performs element-wise multiplication between two
+tensors. The shapes of the tensor operands are expected to match.
+
+#### Operands:
+
+| Operand | Description |
+| :-----: | ----------- |
+| `lhs` | tensor of 64-bit float values |
+| `rhs` | tensor of 64-bit float values |
+
+#### Results:
+
+| Result | Description |
+| :----: | ----------- |
+| «unnamed» | tensor of 64-bit float values |
+
+
+### `toy.print` (toy::PrintOp)
+
+_Print operation_
+
+Syntax:
+
+```
+operation ::= `toy.print` $input attr-dict `:` type($input)
+```
+
+The "print" builtin operation prints a given input tensor, and produces
+no results.
+
+#### Operands:
+
+| Operand | Description |
+| :-----: | ----------- |
+| `input` | tensor of 64-bit float values |
+
+
+### `toy.reshape` (toy::ReshapeOp)
+
+_Tensor reshape operation_
+
+Syntax:
+
+```
+operation ::= `toy.reshape` `(` $input `:` type($input) `)` attr-dict `to` type(results)
+```
+
+Reshape operation is transforming its input tensor into a new tensor with
+the same number of elements but different shapes. For example:
+
+```mlir
+   %0 = toy.reshape (%arg1 : tensor<10xf64>) to tensor<5x2xf64>
+```
+
+#### Operands:
+
+| Operand | Description |
+| :-----: | ----------- |
+| `input` | tensor of 64-bit float values |
+
+#### Results:
+
+| Result | Description |
+| :----: | ----------- |
+| «unnamed» | statically shaped tensor of 64-bit float values |
+
+
+### `toy.return` (toy::ReturnOp)
+
+_Return operation_
+
+Syntax:
+
+```
+operation ::= `toy.return` ($input^ `:` type($input))? attr-dict
+```
+
+The "return" operation represents a return operation within a function.
+The operation takes an optional tensor operand and produces no results.
+The operand type must match the signature of the function that contains
+the operation. For example:
+
+```mlir
+  toy.func @foo() -> tensor<2xf64> {
+    ...
+    toy.return %0 : tensor<2xf64>
+  }
+```
+
+Traits: `AlwaysSpeculatableImplTrait`, `HasParent<FuncOp>`, `Terminator`
+
+Interfaces: `ConditionallySpeculatable`, `NoMemoryEffect (MemoryEffectOpInterface)`
+
+Effects: `MemoryEffects::Effect{}`
+
+#### Operands:
+
+| Operand | Description |
+| :-----: | ----------- |
+| `input` | variadic of tensor of 64-bit float values |
+
+
+### `toy.transpose` (toy::TransposeOp)
+
+_Transpose operation_
+
+Syntax:
+
+```
+operation ::= `toy.transpose` `(` $input `:` type($input) `)` attr-dict `to` type(results)
+```
+
+#### Operands:
+
+| Operand | Description |
+| :-----: | ----------- |
+| `input` | tensor of 64-bit float values |
+
+#### Results:
+
+| Result | Description |
+| :----: | ----------- |
+| «unnamed» | tensor of 64-bit float values |
+

``````````

</details>


https://github.com/llvm/llvm-project/pull/161965


More information about the Mlir-commits mailing list