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

[flang][driver] Add support for -emit-obj in the frontend driver #1152

Merged
merged 1 commit into from Nov 1, 2021
Merged

[flang][driver] Add support for -emit-obj in the frontend driver #1152

merged 1 commit into from Nov 1, 2021

Commits on Oct 29, 2021

  1. [flang][driver] Add support for -emit-obj in the frontend driver

    This patch implements the `EmitObjAction` frontend action. The
    `CodeGenAction` is extended to contain an instance of `llvm::LLVMCtx`
    and `llvm::Module`. These variables are unlikely to be needed in other,
    non-code-gen actions (or in `CompilerInstance` or `CompilerInvocation`),
    so these should be the right location. Also, a member method for
    generating LLVM IR is added (see `GenerateLLVMIR`).
    
    The target triple is hard-coded as `native`, i.e. no cross-compilation
    is supported at this stage.
    
    `tripleName` in FirContext.cpp is updated from `fir.triple` to
    `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
    that 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. As these tests are arch specific (they check the
    generated assembly), support for `!REQUIRES: <arch>-registered-target`
    was added in LIT. The current approach is a bit fragile and will cause
    problems if multiple targets are available (e.g. X86 and AArch64).
    That's because `!REQUIRES: X86-registered-target` will be satisfied even
    on AArch64 targets if the X86 backend is enabled (through e.g.
    `LLVM_ENABLE_TARGETS`). However, the test could fail as currently
    `flang-new -fc1 -emit-obj` always generates code for the host
    architecture. This can be fixed by adding support for `-target`.
    banach-space committed Oct 29, 2021
    Configuration menu
    Copy the full SHA
    4e6f6d7 View commit details
    Browse the repository at this point in the history