llvm/flang/test/CMakeLists.txt
Andrzej Warzynski 38101b4e95 [flang][driver] Add support for -S and implement -c/-emit-obj
This patch adds support for:
  * `-S` in Flang's compiler and frontend drivers,
and implements:
  * `-emit-obj` in Flang's frontend driver and `-c` in Flang's compiler
    driver (this is consistent with Clang).
(these options were already available before, but only as placeholders).
The semantics of these options in Clang and Flang are identical.

The `EmitObjAction` frontend action is renamed as `BackendAction`. This
new name more accurately reflects the fact that this action will
primarily run the code-gen/backend pipeline in LLVM. It also makes more
sense as an action implementing both `-emit-obj` and `-S` (originally,
it was just `-emit-obj`).

`tripleName` from FirContext.cpp is deleted and, when a target triple is
required, `mlir::LLVM::LLVMDialect::getTargetTripleAttrName()` is used
instead. In practice, this means that `fir.triple` is replaced with
`llvm.target_triple`. The former was effectively ignored. The latter is
used when lowering from the LLVM dialect in MLIR to LLVM IR (i.e. it's
embedded in the generated LLVM IR module). The driver can then re-use
it when configuring the backend. With this change, the LLVM IR files
generated by e.g. `tco` will from now on contain the correct target
triple.

The code-gen.f90 test is replaced with code-gen-x86.f90 and
code-gen-aarch64.f90. With 2 seperate files we can verify that
`--target` is correctly taken into account. LIT configuration is updated
to enable e.g.:
```
! REQUIRES: aarch64-registered-target
```

Differential Revision: https://reviews.llvm.org/D120568
2022-03-09 15:48:09 +00:00

84 lines
2.3 KiB
CMake

# Test runner infrastructure for Flang. This configures the Flang test trees
# for use by Lit, and delegates to LLVM's lit test handlers.
llvm_canonicalize_cmake_booleans(
FLANG_BUILD_EXAMPLES
FLANG_STANDALONE_BUILD
LLVM_ENABLE_PLUGINS
)
set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/bin)
# FIXME In out-of-tree builds, "SHLIBDIR" is undefined and passing it to
# `configure_lit_site_cfg` leads to a configuration error. This is currently
# only required by plugins/examples, which are not supported in out-of-tree
# builds.
if (FLANG_STANDALONE_BUILD)
set(PATHS_FOR_PLUGINS "")
else ()
set(PATHS_FOR_PLUGINS "SHLIBDIR")
endif ()
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
PATHS
${PATHS_FOR_PLUGINS}
)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/NonGtestUnit/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.cfg.py
)
set(FLANG_TEST_PARAMS
flang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
set(FLANG_TEST_DEPENDS
flang-new llvm-config FileCheck count not module_files fir-opt tco bbc llvm-objdump
)
if (FLANG_INCLUDE_TESTS)
if (FLANG_GTEST_AVAIL)
list(APPEND FLANG_TEST_DEPENDS FlangUnitTests)
endif()
endif()
if (FLANG_BUILD_EXAMPLES)
list(APPEND FLANG_TEST_DEPENDS
flangPrintFunctionNames
flangOmpReport
)
endif ()
add_custom_target(flang-test-depends DEPENDS ${FLANG_TEST_DEPENDS})
add_lit_testsuite(check-flang "Running the Flang regression tests"
${CMAKE_CURRENT_BINARY_DIR}
PARAMS ${FLANG_TEST_PARAMS}
DEPENDS ${FLANG_TEST_DEPENDS}
)
set_target_properties(check-flang PROPERTIES FOLDER "Tests")
# In case of standalone builds.
if (FLANG_STANDALONE_BUILD)
add_lit_testsuites(FLANG ${CMAKE_CURRENT_BINARY_DIR}
PARAMS ${FLANG_TEST_PARAMS}
DEPENDS ${FLANG_TEST_DEPENDS})
else()
add_lit_testsuites(FLANG ${CMAKE_CURRENT_SOURCE_DIR}
PARAMS ${FLANG_TEST_PARAMS}
DEPENDS ${FLANG_TEST_DEPENDS})
endif()