19 using namespace clang;
24 const ArgList &Args,
const char *LinkingOutput)
const {
25 const auto &TC = getToolChain();
26 const llvm::Triple &Triple = TC.getEffectiveTriple();
27 const std::string &TripleStr = Triple.getTriple();
29 ArgStringList CmdArgs;
31 CmdArgs.push_back(
"-fc1");
33 CmdArgs.push_back(
"-triple");
34 CmdArgs.push_back(Args.MakeArgString(TripleStr));
36 if (isa<PreprocessJobAction>(JA)) {
37 CmdArgs.push_back(
"-E");
38 }
else if (isa<CompileJobAction>(JA) || isa<BackendJobAction>(JA)) {
39 if (JA.
getType() == types::TY_Nothing) {
40 CmdArgs.push_back(
"-fsyntax-only");
41 }
else if (JA.
getType() == types::TY_AST) {
42 CmdArgs.push_back(
"-emit-ast");
43 }
else if (JA.
getType() == types::TY_LLVM_IR ||
44 JA.
getType() == types::TY_LTO_IR) {
45 CmdArgs.push_back(
"-emit-llvm");
46 }
else if (JA.
getType() == types::TY_LLVM_BC ||
47 JA.
getType() == types::TY_LTO_BC) {
48 CmdArgs.push_back(
"-emit-llvm-bc");
49 }
else if (JA.
getType() == types::TY_PP_Asm) {
50 CmdArgs.push_back(
"-S");
52 assert(
false &&
"Unexpected output type!");
54 }
else if (isa<AssembleJobAction>(JA)) {
55 CmdArgs.push_back(
"-emit-obj");
57 assert(
false &&
"Unexpected action class for Flang tool.");
61 CmdArgs.push_back(
"-o");
64 assert(Output.
isNothing() &&
"Invalid output.");
68 assert(Input.isFilename() &&
"Invalid input.");
69 CmdArgs.push_back(Input.getFilename());
72 const char* Exec = Args.MakeArgString(D.GetProgramPath(
"flang", TC));
73 C.
addCommand(std::make_unique<Command>(JA, *
this, Exec, CmdArgs, Inputs));
77 :
Tool(
"flang",
"flang frontend", TC, RF_Full) {}
types::ID getType() const
void addCommand(std::unique_ptr< Command > C)
Dataflow Directional Tag Classes.
Compilation - A set of tasks to perform for a single driver invocation.
const Driver & getDriver() const