You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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`.
0 commit comments