[all-commits] [llvm/llvm-project] e59e84: [flang] Updating drivers to create data layout bef...

jeanPerier via All-commits all-commits at lists.llvm.org
Wed Dec 6 05:20:21 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e59e848805f57bd52ebbb0f7f7d4d951e6af597c
      https://github.com/llvm/llvm-project/commit/e59e848805f57bd52ebbb0f7f7d4d951e6af597c
  Author: jeanPerier <jperier at nvidia.com>
  Date:   2023-12-06 (Wed, 06 Dec 2023)

  Changed paths:
    M flang/include/flang/Frontend/CompilerInstance.h
    M flang/include/flang/Frontend/CompilerInvocation.h
    M flang/include/flang/Frontend/FrontendActions.h
    M flang/include/flang/Lower/Bridge.h
    A flang/include/flang/Optimizer/Support/DataLayout.h
    A flang/include/flang/Tools/TargetSetup.h
    M flang/lib/Frontend/CompilerInstance.cpp
    M flang/lib/Frontend/CompilerInvocation.cpp
    M flang/lib/Frontend/FrontendActions.cpp
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Optimizer/Support/CMakeLists.txt
    A flang/lib/Optimizer/Support/DataLayout.cpp
    A flang/test/Fir/tco-default-datalayout.fir
    A flang/test/Fir/tco-explicit-datalayout.fir
    A flang/test/Lower/bbc-host-datalayout.f90
    A flang/test/Lower/bbc-target-datalayout.f90
    M flang/test/Semantics/realkinds-aarch64-01.f90
    M flang/tools/bbc/CMakeLists.txt
    M flang/tools/bbc/bbc.cpp
    M flang/tools/f18/CMakeLists.txt
    M flang/tools/tco/tco.cpp
    M flang/unittests/Frontend/FrontendActionTest.cpp

  Log Message:
  -----------
  [flang] Updating drivers to create data layout before semantics (#73301)

Preliminary patch to change lowering/code generation to use
llvm::DataLayout information instead of generating "sizeof" GEP (see
https://github.com/llvm/llvm-project/issues/71507).

Fortran Semantic analysis needs to know about the target type size and
alignment to deal with common blocks, and intrinsics like
C_SIZEOF/TRANSFER. This information should be obtained from the
llvm::DataLayout so that it is consistent during the whole compilation
flow.

This change is changing flang-new and bbc drivers to:
1. Create the llvm::TargetMachine so that the data layout of the target
can be obtained before semantics.
2. Sharing bbc/flang-new set-up of the
SemanticConstext.targetCharateristics from the llvm::TargetMachine. For
now, the actual part that set-up the Fortran type size and alignment
from the llvm::DataLayout is left TODO so that this change is mostly an
NFC impacting the drivers.
3. Let the lowering bridge set-up the mlir::Module datalayout attributes
since it is doing it for the target attribute, and that allows the llvm
data layout information to be available during lowering.

For flang-new, the changes are code shuffling: the `llvm::TargetMachine`
instance is moved to `CompilerInvocation` class so that it can be used
to set-up the semantic contexts. `setMLIRDataLayout` is moved to
`flang/Optimizer/Support/DataLayout.h` (it will need to be used from
codegen pass for fir-opt target independent testing.)), and the code
setting-up semantics targetCharacteristics is moved to
`Tools/TargetSetup.h` so that it can be shared with bbc.

As a consequence, LLVM targets must be registered when running
semantics, and it is not possible to run semantics for a target that is
not registered with the -triple option (hence the power pc specific
modules can only be built if the PowerPC target is available.




More information about the All-commits mailing list