Skip to content
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

Backend for generating RVSDG using the MLIR dialect #254

Closed
wants to merge 28 commits into from

Conversation

sjalander
Copy link
Collaborator

Initial attempt of creating a backend for jlm-opt that outputs rvsdg as MLIR IR.

The code currently assumes that the MLIR implementation of RVSDG resides in the same root directory as the main jlm directory, i.e.,
/
jlm
mlir-rvsdg

The dialect can be cloned with
git clone [email protected]:Riphiphip/mlir_rvsdg.git mlir-rvsdg
And built by
cd mlir-rvsdg
mkdir build
cd build
cmake -G Ninja ..
-DCMAKE_C_COMPILER=clang-16
-DCMAKE_CXX_COMPILER=clang++-16
-DLLVM_DIR=/usr/lib/llvm-16/cmake/
-DMLIR_DIR=/usr/lib/llvm-16/lib/cmake/mlir
cmake --build .

At this point, it should be possible to build jlm as normal.

The backend currently only supports lambda and arithmetic constants, so the test cases are limited.
Currently, the only code that has been used to test the backend is:

test.c :
int test() {
return 1;
}

The backend can be tested by:
/usr/lib/llvm-16/bin/clang -S -emit-llvm -o test.ll test.c
jlm-opt --mlir --dne test.ll

This should print the following MLIR IR:

rvsdg.omegaNode (): {
%0 = rvsdg.lambdaNode <(!rvsdg.ioState, !rvsdg.memState, !rvsdg.loopState) -> (i32, !rvsdg.ioState, !rvsdg.memState, !rvsdg.loopState)> () : (%arg0: !rvsdg.ioState, %arg1: !rvsdg.memState, %arg2: !rvsdg.loopState): {
%c1_i32 = arith.constant 1 : i32
rvsdg.lambdaResult (%c1_i32: i32, %arg0: !rvsdg.ioState, %arg1: !rvsdg.memState, %arg2: !rvsdg.loopState)
}
rvsdg.omegaResult (%0: !rvsdg.lambdaRef<(!rvsdg.ioState, !rvsdg.memState, !rvsdg.loopState) -> (i32, !rvsdg.ioState, !rvsdg.memState, !rvsdg.loopState)>)
}

@sjalander sjalander requested a review from phate October 3, 2023 19:16
jlm/hls/backend/rhls2firrtl/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/tooling/Command.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
@sjalander sjalander force-pushed the mlir-rvsdg branch 7 times, most recently from c96a863 to 12cc9ec Compare October 6, 2023 14:04
@sjalander sjalander requested a review from phate October 6, 2023 14:13
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
@sjalander sjalander force-pushed the mlir-rvsdg branch 4 times, most recently from 96d5729 to c458c2f Compare October 12, 2023 17:48
jlm/mlir/backend/mlirgen.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/tooling/Command.cpp Show resolved Hide resolved
jlm/tooling/Command.cpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
jlm/mlir/backend/mlirgen.hpp Outdated Show resolved Hide resolved
@sjalander sjalander force-pushed the mlir-rvsdg branch 2 times, most recently from 794d86d to d69d4f7 Compare October 13, 2023 14:58
@sjalander sjalander force-pushed the mlir-rvsdg branch 8 times, most recently from c0c3162 to 9841f30 Compare November 28, 2023 15:06
@sjalander
Copy link
Collaborator Author

When creating an MLIR backend and frontend, we need to be able to specify format for both the input and output. A question is how to handle the naming of these. The current version uses the following, non-optimal, names.

Select input format
--input-llvm - Input LLVM IR [default]
--input-mlir - Input MLIR
Select output format
--llvm - Output LLVM IR [default]
--xml - Output XML
--mlir - Output MLIR

@sjalander sjalander force-pushed the mlir-rvsdg branch 2 times, most recently from 945976d to 8726b15 Compare November 29, 2023 15:29
@sjalander sjalander force-pushed the mlir-rvsdg branch 6 times, most recently from 76e2513 to c4d997b Compare January 14, 2024 18:04
@sjalander sjalander closed this Feb 14, 2024
@sjalander sjalander deleted the mlir-rvsdg branch February 19, 2024 07:27
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.

2 participants