1 //===--- Action.h - Abstract compilation steps ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_DRIVER_ACTION_H_
11 #define CLANG_DRIVER_ACTION_H_
13 #include "clang/Driver/Types.h"
14 #include "clang/Driver/Util.h"
15 #include "llvm/ADT/SmallVector.h"
26 /// Action - Represent an abstract compilation step to perform.
28 /// An action represents an edge in the compilation graph; typically
29 /// it is a job to transform an input using some tool.
31 /// The current driver is hard wired to expect actions which produce a
32 /// single primary output, at least in terms of controlling the
33 /// compilation. Actions can produce auxiliary files, but can only
34 /// produce a single output to feed into subsequent actions.
37 typedef ActionList::size_type size_type;
38 typedef ActionList::iterator iterator;
39 typedef ActionList::const_iterator const_iterator;
53 VerifyDebugInfoJobClass,
56 JobClassFirst=PreprocessJobClass,
57 JobClassLast=VerifyPCHJobClass
60 static const char *getClassName(ActionClass AC);
65 /// The output type of this action.
70 unsigned OwnsInputs : 1;
73 Action(ActionClass _Kind, types::ID _Type)
74 : Kind(_Kind), Type(_Type), OwnsInputs(true) {}
75 Action(ActionClass _Kind, Action *Input, types::ID _Type)
76 : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1), OwnsInputs(true) {}
77 Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
78 : Kind(_Kind), Type(_Type), Inputs(_Inputs), OwnsInputs(true) {}
82 const char *getClassName() const { return Action::getClassName(getKind()); }
84 bool getOwnsInputs() { return OwnsInputs; }
85 void setOwnsInputs(bool Value) { OwnsInputs = Value; }
87 ActionClass getKind() const { return Kind; }
88 types::ID getType() const { return Type; }
90 ActionList &getInputs() { return Inputs; }
91 const ActionList &getInputs() const { return Inputs; }
93 size_type size() const { return Inputs.size(); }
95 iterator begin() { return Inputs.begin(); }
96 iterator end() { return Inputs.end(); }
97 const_iterator begin() const { return Inputs.begin(); }
98 const_iterator end() const { return Inputs.end(); }
101 class InputAction : public Action {
102 virtual void anchor();
103 const llvm::opt::Arg &Input;
106 InputAction(const llvm::opt::Arg &_Input, types::ID _Type);
108 const llvm::opt::Arg &getInputArg() const { return Input; }
110 static bool classof(const Action *A) {
111 return A->getKind() == InputClass;
115 class BindArchAction : public Action {
116 virtual void anchor();
117 /// The architecture to bind, or 0 if the default architecture
119 const char *ArchName;
122 BindArchAction(Action *Input, const char *_ArchName);
124 const char *getArchName() const { return ArchName; }
126 static bool classof(const Action *A) {
127 return A->getKind() == BindArchClass;
131 class JobAction : public Action {
132 virtual void anchor();
134 JobAction(ActionClass Kind, Action *Input, types::ID Type);
135 JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type);
138 static bool classof(const Action *A) {
139 return (A->getKind() >= JobClassFirst &&
140 A->getKind() <= JobClassLast);
144 class PreprocessJobAction : public JobAction {
145 void anchor() override;
147 PreprocessJobAction(Action *Input, types::ID OutputType);
149 static bool classof(const Action *A) {
150 return A->getKind() == PreprocessJobClass;
154 class PrecompileJobAction : public JobAction {
155 void anchor() override;
157 PrecompileJobAction(Action *Input, types::ID OutputType);
159 static bool classof(const Action *A) {
160 return A->getKind() == PrecompileJobClass;
164 class AnalyzeJobAction : public JobAction {
165 void anchor() override;
167 AnalyzeJobAction(Action *Input, types::ID OutputType);
169 static bool classof(const Action *A) {
170 return A->getKind() == AnalyzeJobClass;
174 class MigrateJobAction : public JobAction {
175 void anchor() override;
177 MigrateJobAction(Action *Input, types::ID OutputType);
179 static bool classof(const Action *A) {
180 return A->getKind() == MigrateJobClass;
184 class CompileJobAction : public JobAction {
185 void anchor() override;
187 CompileJobAction(Action *Input, types::ID OutputType);
189 static bool classof(const Action *A) {
190 return A->getKind() == CompileJobClass;
194 class AssembleJobAction : public JobAction {
195 void anchor() override;
197 AssembleJobAction(Action *Input, types::ID OutputType);
199 static bool classof(const Action *A) {
200 return A->getKind() == AssembleJobClass;
204 class LinkJobAction : public JobAction {
205 void anchor() override;
207 LinkJobAction(ActionList &Inputs, types::ID Type);
209 static bool classof(const Action *A) {
210 return A->getKind() == LinkJobClass;
214 class LipoJobAction : public JobAction {
215 void anchor() override;
217 LipoJobAction(ActionList &Inputs, types::ID Type);
219 static bool classof(const Action *A) {
220 return A->getKind() == LipoJobClass;
224 class DsymutilJobAction : public JobAction {
225 void anchor() override;
227 DsymutilJobAction(ActionList &Inputs, types::ID Type);
229 static bool classof(const Action *A) {
230 return A->getKind() == DsymutilJobClass;
234 class VerifyJobAction : public JobAction {
235 void anchor() override;
237 VerifyJobAction(ActionClass Kind, Action *Input, types::ID Type);
238 VerifyJobAction(ActionClass Kind, ActionList &Inputs, types::ID Type);
239 static bool classof(const Action *A) {
240 return A->getKind() == VerifyDebugInfoJobClass ||
241 A->getKind() == VerifyPCHJobClass;
245 class VerifyDebugInfoJobAction : public VerifyJobAction {
246 void anchor() override;
248 VerifyDebugInfoJobAction(Action *Input, types::ID Type);
249 static bool classof(const Action *A) {
250 return A->getKind() == VerifyDebugInfoJobClass;
254 class VerifyPCHJobAction : public VerifyJobAction {
255 void anchor() override;
257 VerifyPCHJobAction(Action *Input, types::ID Type);
258 static bool classof(const Action *A) {
259 return A->getKind() == VerifyPCHJobClass;
263 } // end namespace driver
264 } // end namespace clang