-
Notifications
You must be signed in to change notification settings - Fork 112
[WIP][CIR] Single-source C++ lowering with ClangIR MLIR CIR #1913
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
Draft
keryell
wants to merge
81
commits into
Xilinx:main
Choose a base branch
from
keryell:clangir
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Extend conflicting --mlir-to-llvmir option.
This avoids choking on some remaining CIR attributes like: Unable to parse module assembly: error: "-":1:101: #"cir"<"lang<cxx>"> : 'none' attribute created with unregistered dialect. If this is intended, please call allowUnregisteredDialects() on the MLIRContext, or use -allow-unregistered-dialect with the MLIR opt tool used This is simpler than adding the CIR dialect itself to the Python infrastructure which is quite complex.
Allow aie.device to appear anywhere.
For example to allow simpler transformations in a single-source framework.
Start the new CIR infrastructure in some separate CIR directories for a cleaner organization.
It is unclear how to pass information to a Pattern::matchAndRewrite.
Clean up some code too.
Add a "aie.device" attribute with the device name to make things clearer.
To do: integrate this into CMake infrastructure.
Also simplify some type names by removing some `_t`.
Also updated to new types in aie++.hpp header. Generate things like: %2 = builtin.unrealized_conversion_cast %1 : !cir.ptr<!ty_aie3A3Adevice3Caie3A3Anpu13E> to !cir.ptr<!ty_aie3A3Atile3C12C_43E> {"aie::tile" = ["1", "4"]}
For now only --cir-to-aie-prepare does something.
Generate also aie.tile and WIP hard-coded aie.buffer.
Optimize out the lambda capture leftover in aie.core.
Disable this option for now to keep the old behavior without any ClangIR MLIR C++ front-end feature.
Returning a handle was too disruptive to the MLIR AIE unit tests. Controlling a specific aie.device by the runtime can be done later without using the result as a handler.
All the AIE operations which are created have now a "cir.type" type attribute for any later introspection.
Take into account Xilinx#1936
This relies on llvm/clangir#1203 and llvm/clangir#1164 |
Now there is no type at all instead of a problematic !cir.void.
Improve also documentation and type-safety.
Extract the aie.device operation as the top-module operation. Anything else is removed. For now just keep the first aie.device.
The CIR lowering passes are aware of AIE dialects when going to LLVM dialect or MLIR standard dialects from aie-opt or aie-translate. Also expose the --cir-to-llvm pass to aie-opt.
Work-around for struct lowering which does not work yet.
Execute this script with the right path according to your environment, for example with: PATH=$LLVM_DIR/build/bin:$MLIR_AIE_HOME/build/bin:$PATH $MLIR_AIE_HOME/utils/aie++-compile.sh example.cpp
Resolve conflicts on: - README.md - python/compiler/aiecc/main.py
This requires on-going implementation of annotate("cir.aie.replace_by","...") and annotate("cir.aie.label", "...")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a huge WIP for now and far from review.
Some context and documentation is given in https://github.com/keryell/mlir-aie/blob/clangir/docs/CIR.md
It requires a specific branch of ClangIR llvm/clangir#1334 instead of the usual Clang/LLVM/MLIR and it is not clear how to have this in current CI.