Skip to content

Backport EmitC-related commits from upstream (FXML-4370) #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 22, 2024

Conversation

mgehre-amd
Copy link
Collaborator

No description provided.

marbre and others added 7 commits March 21, 2024 14:32
Removes linking and registering dialects that are not support any more.
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.
Emits `2.0e+00f` instead of `(float)2.0e+00`.

This helps consumers of the emitted code, especially when there are
large numbers of floating point literals, to have a simple AST.
Restrict which integers and floating-point types are valid in EmitC.
This should cover the types which are supported in C++ and is aligned
with what the emitter currently supports.

The checks are implemented as functions and not fully in tablegen to
allow them to be re-used by conversions to EmitC.
This converts `memref.alloca`, `memref.load` & `memref.store` to
`emitc.variable`, `emitc.subscript` and `emitc.assign`.
@mgehre-amd mgehre-amd requested a review from TinaAMD March 22, 2024 07:53
Copy link

@TinaAMD TinaAMD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mgehre-amd mgehre-amd changed the title Backport EmitC-related commits from upstream Backport EmitC-related commits from upstream (FXML-4370) Mar 22, 2024
@mgehre-amd mgehre-amd merged commit bedd22f into feature/fused-ops Mar 22, 2024
@mgehre-amd mgehre-amd deleted the matthias.backport_emitc branch March 22, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants