Nick Lewycky | 6da9077 | 2010-12-31 17:31:54 +0000 | [diff] [blame] | 1 | //===--- Action.cpp - Abstract compilation steps --------------------------===// |
Daniel Dunbar | f479c12 | 2009-03-12 18:40:18 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "clang/Driver/Action.h" |
David Blaikie | 7900020 | 2011-09-23 05:57:42 +0000 | [diff] [blame] | 11 | #include "llvm/Support/ErrorHandling.h" |
Justin Lebar | 7bf7798 | 2016-01-11 23:27:13 +0000 | [diff] [blame^] | 12 | #include "llvm/Support/Regex.h" |
Daniel Dunbar | f479c12 | 2009-03-12 18:40:18 +0000 | [diff] [blame] | 13 | #include <cassert> |
| 14 | using namespace clang::driver; |
Reid Kleckner | 898229a | 2013-06-14 17:17:23 +0000 | [diff] [blame] | 15 | using namespace llvm::opt; |
Daniel Dunbar | f479c12 | 2009-03-12 18:40:18 +0000 | [diff] [blame] | 16 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 17 | Action::~Action() {} |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 18 | |
| 19 | const char *Action::getClassName(ActionClass AC) { |
| 20 | switch (AC) { |
| 21 | case InputClass: return "input"; |
| 22 | case BindArchClass: return "bind-arch"; |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 23 | case CudaDeviceClass: return "cuda-device"; |
| 24 | case CudaHostClass: return "cuda-host"; |
Daniel Dunbar | 7326ad5 | 2009-03-13 17:52:07 +0000 | [diff] [blame] | 25 | case PreprocessJobClass: return "preprocessor"; |
| 26 | case PrecompileJobClass: return "precompiler"; |
| 27 | case AnalyzeJobClass: return "analyzer"; |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 28 | case MigrateJobClass: return "migrator"; |
Daniel Dunbar | 7326ad5 | 2009-03-13 17:52:07 +0000 | [diff] [blame] | 29 | case CompileJobClass: return "compiler"; |
Bob Wilson | 23a55f1 | 2014-12-21 07:00:00 +0000 | [diff] [blame] | 30 | case BackendJobClass: return "backend"; |
Daniel Dunbar | 7326ad5 | 2009-03-13 17:52:07 +0000 | [diff] [blame] | 31 | case AssembleJobClass: return "assembler"; |
| 32 | case LinkJobClass: return "linker"; |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 33 | case LipoJobClass: return "lipo"; |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 34 | case DsymutilJobClass: return "dsymutil"; |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 35 | case VerifyDebugInfoJobClass: return "verify-debug-info"; |
| 36 | case VerifyPCHJobClass: return "verify-pch"; |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 37 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 38 | |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 39 | llvm_unreachable("invalid class"); |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 40 | } |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 41 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 42 | void InputAction::anchor() {} |
| 43 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 44 | InputAction::InputAction(const Arg &_Input, types::ID _Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 45 | : Action(InputClass, _Type), Input(_Input) { |
| 46 | } |
| 47 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 48 | void BindArchAction::anchor() {} |
| 49 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 50 | BindArchAction::BindArchAction(Action *Input, const char *_ArchName) |
| 51 | : Action(BindArchClass, Input), ArchName(_ArchName) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 52 | |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 53 | void CudaDeviceAction::anchor() {} |
| 54 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 55 | CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName, |
| 56 | bool AtTopLevel) |
| 57 | : Action(CudaDeviceClass, Input), GpuArchName(ArchName), |
Justin Lebar | 7bf7798 | 2016-01-11 23:27:13 +0000 | [diff] [blame^] | 58 | AtTopLevel(AtTopLevel) { |
| 59 | assert(IsValidGpuArchName(GpuArchName)); |
| 60 | } |
| 61 | |
| 62 | bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) { |
| 63 | static llvm::Regex RE("^sm_[0-9]+$"); |
| 64 | return RE.match(ArchName); |
| 65 | } |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 66 | |
| 67 | void CudaHostAction::anchor() {} |
| 68 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 69 | CudaHostAction::CudaHostAction(Action *Input, const ActionList &DeviceActions) |
| 70 | : Action(CudaHostClass, Input), DeviceActions(DeviceActions) {} |
Artem Belevich | 0ff05cd | 2015-07-13 23:27:56 +0000 | [diff] [blame] | 71 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 72 | void JobAction::anchor() {} |
| 73 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 74 | JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type) |
| 75 | : Action(Kind, Input, Type) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 76 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 77 | JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 78 | : Action(Kind, Inputs, Type) { |
| 79 | } |
| 80 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 81 | void PreprocessJobAction::anchor() {} |
| 82 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 83 | PreprocessJobAction::PreprocessJobAction(Action *Input, types::ID OutputType) |
| 84 | : JobAction(PreprocessJobClass, Input, OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 85 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 86 | void PrecompileJobAction::anchor() {} |
| 87 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 88 | PrecompileJobAction::PrecompileJobAction(Action *Input, types::ID OutputType) |
| 89 | : JobAction(PrecompileJobClass, Input, OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 90 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 91 | void AnalyzeJobAction::anchor() {} |
| 92 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 93 | AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType) |
| 94 | : JobAction(AnalyzeJobClass, Input, OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 95 | |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 96 | void MigrateJobAction::anchor() {} |
| 97 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 98 | MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType) |
| 99 | : JobAction(MigrateJobClass, Input, OutputType) {} |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 100 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 101 | void CompileJobAction::anchor() {} |
| 102 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 103 | CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType) |
| 104 | : JobAction(CompileJobClass, Input, OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 105 | |
Bob Wilson | 23a55f1 | 2014-12-21 07:00:00 +0000 | [diff] [blame] | 106 | void BackendJobAction::anchor() {} |
| 107 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 108 | BackendJobAction::BackendJobAction(Action *Input, types::ID OutputType) |
| 109 | : JobAction(BackendJobClass, Input, OutputType) {} |
Bob Wilson | 23a55f1 | 2014-12-21 07:00:00 +0000 | [diff] [blame] | 110 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 111 | void AssembleJobAction::anchor() {} |
| 112 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 113 | AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType) |
| 114 | : JobAction(AssembleJobClass, Input, OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 115 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 116 | void LinkJobAction::anchor() {} |
| 117 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 118 | LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 119 | : JobAction(LinkJobClass, Inputs, Type) { |
| 120 | } |
| 121 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 122 | void LipoJobAction::anchor() {} |
| 123 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 124 | LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 125 | : JobAction(LipoJobClass, Inputs, Type) { |
| 126 | } |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 127 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 128 | void DsymutilJobAction::anchor() {} |
| 129 | |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 130 | DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type) |
| 131 | : JobAction(DsymutilJobClass, Inputs, Type) { |
| 132 | } |
Eric Christopher | 551ef45 | 2011-08-23 17:56:55 +0000 | [diff] [blame] | 133 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 134 | void VerifyJobAction::anchor() {} |
| 135 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 136 | VerifyJobAction::VerifyJobAction(ActionClass Kind, Action *Input, |
| 137 | types::ID Type) |
| 138 | : JobAction(Kind, Input, Type) { |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 139 | assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) && |
| 140 | "ActionClass is not a valid VerifyJobAction"); |
| 141 | } |
| 142 | |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 143 | void VerifyDebugInfoJobAction::anchor() {} |
| 144 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 145 | VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(Action *Input, |
| 146 | types::ID Type) |
| 147 | : VerifyJobAction(VerifyDebugInfoJobClass, Input, Type) {} |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 148 | |
| 149 | void VerifyPCHJobAction::anchor() {} |
| 150 | |
Justin Lebar | 4109461 | 2016-01-11 23:07:27 +0000 | [diff] [blame] | 151 | VerifyPCHJobAction::VerifyPCHJobAction(Action *Input, types::ID Type) |
| 152 | : VerifyJobAction(VerifyPCHJobClass, Input, Type) {} |