diff options
author | Usman Nadeem <mnadeem@quicinc.com> | 2022-11-30 13:15:43 -0800 |
---|---|---|
committer | Usman Nadeem <mnadeem@quicinc.com> | 2022-12-02 09:37:53 -0800 |
commit | 3951a73490df0f3dd307e8ea6aa52d2776259a4c (patch) | |
tree | 88082e9764517193937c1fc296f7e2db72a5802f /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | 4fd0c14a17f91fb7b0d188b509eb3dbdfbfec01a (diff) | |
download | llvm-3951a73490df0f3dd307e8ea6aa52d2776259a4c.zip llvm-3951a73490df0f3dd307e8ea6aa52d2776259a4c.tar.gz llvm-3951a73490df0f3dd307e8ea6aa52d2776259a4c.tar.bz2 |
[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
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index b8f4ad7..e24d816 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -171,6 +171,14 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) { if (const llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_triple)) opts.triple = a->getValue(); + + if (const llvm::opt::Arg *a = + args.getLastArg(clang::driver::options::OPT_target_cpu)) + opts.cpu = a->getValue(); + + for (const llvm::opt::Arg *currentArg : + args.filtered(clang::driver::options::OPT_target_feature)) + opts.featuresAsWritten.emplace_back(currentArg->getValue()); } // Tweak the frontend configuration based on the frontend action |