[Mlir-commits] [mlir] [mlir][emitc][NFC] Add an example to the description of the emitc.literal operation (PR #128005)
Andrey Timonin
llvmlistbot at llvm.org
Fri Feb 21 06:53:08 PST 2025
https://github.com/EtoAndruwa updated https://github.com/llvm/llvm-project/pull/128005
>From 0179aa53913aec32e0fa6fdefb3be1b4460121f4 Mon Sep 17 00:00:00 2001
From: EtoAndruwa <timonina1909 at gmail.com>
Date: Thu, 20 Feb 2025 16:25:28 +0300
Subject: [PATCH 1/2] [mlir][emitc][NFC] Add an example to the description of
the emitc.literal operation
---
mlir/include/mlir/Dialect/EmitC/IR/EmitC.td | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
index 4fbce995ce5b8..47e5390dc2106 100644
--- a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
+++ b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
@@ -798,6 +798,19 @@ def EmitC_LiteralOp : EmitC_Op<"literal", [Pure]> {
let description = [{
The `emitc.literal` operation produces an SSA value equal to some constant
specified by an attribute.
+
+ Example:
+
+ ```mlir
+ %x = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> !emitc.lvalue<i32>
+ %one = literal "1" : i32
+ "emitc.assign"(%x, %one) : (!emitc.lvalue<i32>, i32) -> ()
+ ```
+ ```c++
+ // Code emitted for the operation above.
+ int32_t v1;
+ v1 = 1;
+ ```
}];
let arguments = (ins StrAttr:$value);
>From 6c987dbd1357c22177e0e5469411539d7d0270a3 Mon Sep 17 00:00:00 2001
From: Andrey Timonin <timonina1909 at gmail.com>
Date: Fri, 21 Feb 2025 17:53:00 +0300
Subject: [PATCH 2/2] Update mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
Co-authored-by: Marius Brehler <marius.brehler at gmail.com>
---
mlir/include/mlir/Dialect/EmitC/IR/EmitC.td | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
index 47e5390dc2106..a70f497d56700 100644
--- a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
+++ b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
@@ -802,14 +802,12 @@ def EmitC_LiteralOp : EmitC_Op<"literal", [Pure]> {
Example:
```mlir
- %x = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> !emitc.lvalue<i32>
- %one = literal "1" : i32
- "emitc.assign"(%x, %one) : (!emitc.lvalue<i32>, i32) -> ()
+ %p0 = emitc.literal "M_PI" : f32
+ %1 = "emitc.add" (%arg0, %p0) : (f32, f32) -> f32
```
```c++
// Code emitted for the operation above.
- int32_t v1;
- v1 = 1;
+ float v2 = v1 + M_PI;
```
}];
More information about the Mlir-commits
mailing list