diff options
| author | Matthias Gehre <matthias.gehre@amd.com> | 2024-03-15 11:08:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-15 11:08:34 +0100 |
| commit | 01a31cee561efe90fbd1d33fa89f403dd8ff9012 (patch) | |
| tree | 925844eba01f2a95069f067a04021dddf85e1bd9 /llvm/lib/Bitcode/Reader | |
| parent | dbb2fd5974fbdf82d4b1b0dd0dde5170e3629768 (diff) | |
| download | llvm-01a31cee561efe90fbd1d33fa89f403dd8ff9012.zip llvm-01a31cee561efe90fbd1d33fa89f403dd8ff9012.tar.gz llvm-01a31cee561efe90fbd1d33fa89f403dd8ff9012.tar.bz2 | |
[MLIR] EmitC: Add subscript operator (#84783)
Introduces a SubscriptOp that allows to write IR like
```
func.func @load_store(%arg0: !emitc.array<4x8xf32>, %arg1: !emitc.array<3x5xf32>, %arg2: index, %arg3: index) {
%0 = emitc.subscript %arg0[%arg2, %arg3] : <4x8xf32>, index, index
%1 = emitc.subscript %arg1[%arg2, %arg3] : <3x5xf32>, index, index
emitc.assign %0 : f32 to %1 : f32
return
}
```
which gets translated into the C++ code
```
v1[v2][v3] = v0[v1][v2];
```
To make this happen, this
- adds the SubscriptOp
- allows the subscript op as rhs of emitc.assign
- updates the emitter to print SubscriptOps
The emitter prints emitc.subscript in a delayed fashing to allow it
being used as lvalue.
I.e. while processing
```
%0 = emitc.subscript %arg0[%arg2, %arg3] : <4x8xf32>, index, index
```
it will not emit any text, but record in the `valueMapper` that the name
for `%0` is `v0[v1][v2]`, see `CppEmitter::getSubscriptName`. Only when
that result is then used (here in `emitc.assign`), that name is inserted
into the text.
Diffstat (limited to 'llvm/lib/Bitcode/Reader')
0 files changed, 0 insertions, 0 deletions
