mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-21 10:42:35 +00:00
[flang] [mlir rebase] Add MLIR config and react to MLIR name changes (flang-compiler/f18#1090)
[mlir rebase] Add MLIR config and react to MLIR name changes Similar to flang-compiler/f18#1085. Now use the MLIR package to set up paths for include files and libraries. Three MLIR names changed: * VectorOpsDialect to VectorDialect * AffineOpsDialect to AffineDialect * createVectorizePass to createSuperVectorizePass Update README.md to explain how to link with MLIR. Update the example gcc to version 8.3. Update drone.io config to define -DMLIR_DIR Co-authored-by: Jean Perier <jperier@nvidia.com> Original-commit: flang-compiler/f18@116f64315f Reviewed-on: https://github.com/flang-compiler/f18/pull/1090
This commit is contained in:
parent
643edd57fe
commit
282358fac9
@ -14,7 +14,7 @@ def clang(arch):
|
||||
"ninja install",
|
||||
"cd ../..",
|
||||
"mkdir build && cd build",
|
||||
'env CC=clang-8 CXX=clang++-8 CXXFLAGS="-UNDEBUG -stdlib=libc++" LDFLAGS="-fuse-ld=lld" cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. -DLLVM_DIR=/drone/src/llvm-project/install/lib/cmake/llvm -DLLVM_EXTERNAL_LIT=/drone/src/llvm-project/build/bin/llvm-lit',
|
||||
'env CC=clang-8 CXX=clang++-8 CXXFLAGS="-UNDEBUG -stdlib=libc++" LDFLAGS="-fuse-ld=lld" cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. -DLLVM_DIR=/drone/src/llvm-project/install/lib/cmake/llvm -DMLIR_DIR=/drone/src/llvm-project/install/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=/drone/src/llvm-project/build/bin/llvm-lit',
|
||||
"ninja -j8",
|
||||
"ctest --output-on-failure -j24",
|
||||
"ninja check-all",
|
||||
@ -40,7 +40,7 @@ def gcc(arch):
|
||||
"ninja install",
|
||||
"cd ../..",
|
||||
"mkdir build && cd build",
|
||||
'env CC=gcc CXX=g++ CXXFLAGS="-UNDEBUG" LDFLAGS="-fuse-ld=gold" cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. -DLLVM_DIR=/drone/src/llvm-project/install/lib/cmake/llvm -DLLVM_EXTERNAL_LIT=/drone/src/llvm-project/build/bin/llvm-lit',
|
||||
'env CC=gcc CXX=g++ CXXFLAGS="-UNDEBUG" LDFLAGS="-fuse-ld=gold" cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. -DLLVM_DIR=/drone/src/llvm-project/install/lib/cmake/llvm -DMLIR_DIR=/drone/src/llvm-project/install/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=/drone/src/llvm-project/build/bin/llvm-lit',
|
||||
"ninja -j8",
|
||||
"ctest --output-on-failure -j24",
|
||||
"ninja check-all",
|
||||
|
@ -67,6 +67,10 @@ project(Flang)
|
||||
|
||||
if(LINK_WITH_FIR)
|
||||
include(TableGen)
|
||||
find_package(MLIR REQUIRED CONFIG)
|
||||
# Use SYSTEM for the same reasons as for LLVM includes
|
||||
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
|
||||
list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR})
|
||||
include(AddMLIR)
|
||||
find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR}
|
||||
NO_DEFAULT_PATH)
|
||||
|
@ -1,9 +1,9 @@
|
||||
<!--===- README.md
|
||||
|
||||
<!--===- README.md
|
||||
|
||||
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
See https://llvm.org/LICENSE.txt for license information.
|
||||
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
|
||||
-->
|
||||
|
||||
# F18
|
||||
@ -72,12 +72,16 @@ https://llvm.org/docs/GettingStarted.html.
|
||||
We highly recommend using the same compiler to compile both llvm and f18.
|
||||
|
||||
The f18 CMakeList.txt file uses
|
||||
the variable `LLVM_DIR` to find the installed components.
|
||||
the variable `LLVM_DIR` to find the installed LLVM components
|
||||
and
|
||||
the variable `MLIR_DIR` to find the installed MLIR components.
|
||||
|
||||
To get the correct LLVM libraries included in your f18 build,
|
||||
define LLVM_DIR on the cmake command line.
|
||||
To get the correct LLVM and MLIR libraries included in your f18 build,
|
||||
define LLVM_DIR and MLIR_DIR on the cmake command line.
|
||||
```
|
||||
LLVM=<LLVM_BUILD_DIR>/lib/cmake/llvm cmake -DLLVM_DIR=$LLVM ...
|
||||
LLVM=<LLVM_BUILD_DIR>/lib/cmake/llvm \
|
||||
MLIR=<LLVM_BUILD_DIR>/lib/cmake/mlir \
|
||||
cmake -DLLVM_DIR=$LLVM -DMLIR_DIR=$MLIR ...
|
||||
```
|
||||
where `LLVM_BUILD_DIR` is
|
||||
the top-level directory where LLVM was built.
|
||||
@ -121,7 +125,11 @@ make install
|
||||
```
|
||||
|
||||
Then, `-DLLVM_DIR` would have to be set to
|
||||
`<where/you/want/to/build/llvm>/install/lib/cmake/llvm` in f18 cmake command.
|
||||
`<where/you/want/to/build/llvm>/install/lib/cmake/llvm`
|
||||
and, `-DMLIR_DIR` would have to be set to
|
||||
`<where/you/want/to/build/llvm>/install/lib/cmake/mlir`
|
||||
|
||||
in f18 cmake command.
|
||||
|
||||
To run lit tests,
|
||||
`-DLLVM_EXTERNAL_LIT=<where/you/want/to/build/llvm>/build/bin/llvm-lit` must be
|
||||
@ -142,13 +150,13 @@ Or,
|
||||
cmake will use the variable CXX to find the C++ compiler.
|
||||
CXX should include the full path to the compiler
|
||||
or a name that will be found on your PATH,
|
||||
e.g. g++-7.2, assuming g++-7.2 is on your PATH.
|
||||
e.g. g++-8.3, assuming g++-8.3 is on your PATH.
|
||||
```
|
||||
export CXX=g++-7.2
|
||||
export CXX=g++-8.3
|
||||
```
|
||||
or
|
||||
```
|
||||
CXX=/opt/gcc-7.2/bin/g++-7.2 cmake ...
|
||||
CXX=/opt/gcc-8.3/bin/g++-8.3 cmake ...
|
||||
```
|
||||
|
||||
### Building f18 with clang
|
||||
@ -189,7 +197,7 @@ Release builds execute quickly.
|
||||
### Build F18
|
||||
```
|
||||
cd ~/f18/build
|
||||
cmake -DLLVM_DIR=$LLVM ~/f18/src
|
||||
cmake -DLLVM_DIR=$LLVM -DMLIR_DIR=$MLIR ~/f18/src
|
||||
make
|
||||
```
|
||||
|
||||
@ -198,7 +206,7 @@ make
|
||||
To run all tests:
|
||||
```
|
||||
cd ~/f18/build
|
||||
cmake -DLLVM_DIR=$LLVM ~/f18/src
|
||||
cmake -DLLVM_DIR=$LLVM -DMLIR_DIR=$MLIR ~/f18/src
|
||||
make test check-all
|
||||
```
|
||||
|
||||
|
@ -50,11 +50,11 @@ public:
|
||||
inline void registerFIR() {
|
||||
// we want to register exactly once
|
||||
[[maybe_unused]] static bool init_once = [] {
|
||||
mlir::registerDialect<mlir::AffineOpsDialect>();
|
||||
mlir::registerDialect<mlir::AffineDialect>();
|
||||
mlir::registerDialect<mlir::LLVM::LLVMDialect>();
|
||||
mlir::registerDialect<mlir::loop::LoopOpsDialect>();
|
||||
mlir::registerDialect<mlir::StandardOpsDialect>();
|
||||
mlir::registerDialect<mlir::vector::VectorOpsDialect>();
|
||||
mlir::registerDialect<mlir::vector::VectorDialect>();
|
||||
mlir::registerDialect<FIROpsDialect>();
|
||||
return true;
|
||||
}();
|
||||
@ -65,7 +65,7 @@ inline void registerFIR() {
|
||||
inline void registerGeneralPasses() {
|
||||
mlir::createCanonicalizerPass();
|
||||
mlir::createCSEPass();
|
||||
mlir::createVectorizePass({});
|
||||
mlir::createSuperVectorizePass({});
|
||||
mlir::createLoopUnrollPass();
|
||||
mlir::createLoopUnrollAndJamPass();
|
||||
mlir::createSimplifyAffineStructuresPass();
|
||||
|
Loading…
x
Reference in New Issue
Block a user