[Flang][Driver] Handle target CPU and features
authorUsman Nadeem <mnadeem@quicinc.com>
Wed, 30 Nov 2022 21:15:43 +0000 (13:15 -0800)
committerUsman Nadeem <mnadeem@quicinc.com>
Fri, 2 Dec 2022 17:37:53 +0000 (09:37 -0800)
commit3951a73490df0f3dd307e8ea6aa52d2776259a4c
tree88082e9764517193937c1fc296f7e2db72a5802f
parent4fd0c14a17f91fb7b0d188b509eb3dbdfbfec01a
[Flang][Driver] Handle target CPU and features

This patch:

- Adds target-feature and target-cpu to FC1Options.
- Moves getTargetFeatures() from Clang.cpp to CommonArgs.cpp.
- Processes target cpu and features in the flang driver. Right now
  features are only added for AArch64/x86 because I only did basic
  testing on them but it should generally work for others as well.
  Option handling is similar to clang.
- Adds appropriate structures in TargetOptions and passes them to
  the target machine.

What's missing:

- Adding the CPU info and the features as attributes in the LLVM IR
  module.
- Processing target specific flags, e.g. SVE vector bits for AArch64,
  ABI etc.

Differential Revision: https://reviews.llvm.org/D137995

Change-Id: Ib081a74ea98617674845518a5d2754edba596418
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Flang.cpp
clang/lib/Driver/ToolChains/Flang.h
flang/include/flang/Frontend/TargetOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/test/Driver/driver-help.f90
flang/test/Driver/target-cpu-features.f90 [new file with mode: 0644]