diff options
author | Stuart Ellis <stuart.ellis@arm.com> | 2021-08-12 11:42:08 +0100 |
---|---|---|
committer | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2021-08-12 11:42:16 +0100 |
commit | f52fc591fa34a8c85577108358b3b36c42b6d364 (patch) | |
tree | 15b3d78f63b9d1a9137ab96a126613223c230356 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | 8f359a80e466f221e3b3d93e65587d74f9ba2fda (diff) | |
download | llvm-f52fc591fa34a8c85577108358b3b36c42b6d364.zip llvm-f52fc591fa34a8c85577108358b3b36c42b6d364.tar.gz llvm-f52fc591fa34a8c85577108358b3b36c42b6d364.tar.bz2 |
[flang][driver] Add support for Frontend Plugins
Introducing a plugin API and a simple HelloWorld Plugin example.
This patch adds the `-load` and `-plugin` flags to frontend driver and
the code around using custom frontend actions from within a plugin
shared library object.
It also adds to the Driver-help test to check the help option with the
updated driver flags.
Additionally, the patch creates a plugin-example test to check the
HelloWorld plugin example runs correctly. As part of this, a new CMake
flag (`FLANG_BUILD_EXAMPLES`) is added to allow the example to be built
and for the test to run.
This Plugin API has only been tested on Linux.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D106137
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index baa0f32..c16c969 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -199,6 +199,18 @@ static bool ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args, } } + // Parsing -load <dsopath> option and storing shared object path + if (llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_load)) { + opts.plugins.push_back(a->getValue()); + } + + // Parsing -plugin <name> option and storing plugin name and setting action + if (const llvm::opt::Arg *a = + args.getLastArg(clang::driver::options::OPT_plugin)) { + opts.programAction = PluginAction; + opts.ActionName = a->getValue(); + } + opts.outputFile = args.getLastArgValue(clang::driver::options::OPT_o); opts.showHelp = args.hasArg(clang::driver::options::OPT_help); opts.showVersion = args.hasArg(clang::driver::options::OPT_version); |