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"
21 /// Action - Represent an abstract compilation step to perform.
23 /// An action represents an edge in the compilation graph; typically
24 /// it is a job to transform an input using some tool.
26 /// The current driver is hard wired to expect actions which produce a
27 /// single primary output, at least in terms of controlling the
28 /// compilation. Actions can produce auxiliary files, but can only
29 /// produce a single output to feed into subsequent actions.
32 typedef ActionList::size_type size_type;
33 typedef ActionList::iterator iterator;
34 typedef ActionList::const_iterator const_iterator;
50 JobClassFirst=PreprocessJobClass,
51 JobClassLast=VerifyJobClass
54 static const char *getClassName(ActionClass AC);
59 /// The output type of this action.
64 unsigned OwnsInputs : 1;
67 Action(ActionClass _Kind, types::ID _Type)
68 : Kind(_Kind), Type(_Type), OwnsInputs(true) {}
69 Action(ActionClass _Kind, Action *Input, types::ID _Type)
70 : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1), OwnsInputs(true) {}
71 Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
72 : Kind(_Kind), Type(_Type), Inputs(_Inputs), OwnsInputs(true) {}
76 const char *getClassName() const { return Action::getClassName(getKind()); }
78 bool getOwnsInputs() { return OwnsInputs; }
79 void setOwnsInputs(bool Value) { OwnsInputs = Value; }
81 ActionClass getKind() const { return Kind; }
82 types::ID getType() const { return Type; }
84 ActionList &getInputs() { return Inputs; }
85 const ActionList &getInputs() const { return Inputs; }
87 size_type size() const { return Inputs.size(); }
89 iterator begin() { return Inputs.begin(); }
90 iterator end() { return Inputs.end(); }
91 const_iterator begin() const { return Inputs.begin(); }
92 const_iterator end() const { return Inputs.end(); }
94 static bool classof(const Action *) { return true; }
97 class InputAction : public Action {
98 virtual void anchor();
101 InputAction(const Arg &_Input, types::ID _Type);
103 const Arg &getInputArg() const { return Input; }
105 static bool classof(const Action *A) {
106 return A->getKind() == InputClass;
108 static bool classof(const InputAction *) { return true; }
111 class BindArchAction : public Action {
112 virtual void anchor();
113 /// The architecture to bind, or 0 if the default architecture
115 const char *ArchName;
118 BindArchAction(Action *Input, const char *_ArchName);
120 const char *getArchName() const { return ArchName; }
122 static bool classof(const Action *A) {
123 return A->getKind() == BindArchClass;
125 static bool classof(const BindArchAction *) { return true; }
128 class JobAction : public Action {
129 virtual void anchor();
131 JobAction(ActionClass Kind, Action *Input, types::ID Type);
132 JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type);
135 static bool classof(const Action *A) {
136 return (A->getKind() >= JobClassFirst &&
137 A->getKind() <= JobClassLast);
139 static bool classof(const JobAction *) { return true; }
142 class PreprocessJobAction : public JobAction {
143 virtual void anchor();
145 PreprocessJobAction(Action *Input, types::ID OutputType);
147 static bool classof(const Action *A) {
148 return A->getKind() == PreprocessJobClass;
150 static bool classof(const PreprocessJobAction *) { return true; }
153 class PrecompileJobAction : public JobAction {
154 virtual void anchor();
156 PrecompileJobAction(Action *Input, types::ID OutputType);
158 static bool classof(const Action *A) {
159 return A->getKind() == PrecompileJobClass;
161 static bool classof(const PrecompileJobAction *) { return true; }
164 class AnalyzeJobAction : public JobAction {
165 virtual void anchor();
167 AnalyzeJobAction(Action *Input, types::ID OutputType);
169 static bool classof(const Action *A) {
170 return A->getKind() == AnalyzeJobClass;
172 static bool classof(const AnalyzeJobAction *) { return true; }
175 class MigrateJobAction : public JobAction {
176 virtual void anchor();
178 MigrateJobAction(Action *Input, types::ID OutputType);
180 static bool classof(const Action *A) {
181 return A->getKind() == MigrateJobClass;
183 static bool classof(const MigrateJobAction *) { return true; }
186 class CompileJobAction : public JobAction {
187 virtual void anchor();
189 CompileJobAction(Action *Input, types::ID OutputType);
191 static bool classof(const Action *A) {
192 return A->getKind() == CompileJobClass;
194 static bool classof(const CompileJobAction *) { return true; }
197 class AssembleJobAction : public JobAction {
198 virtual void anchor();
200 AssembleJobAction(Action *Input, types::ID OutputType);
202 static bool classof(const Action *A) {
203 return A->getKind() == AssembleJobClass;
205 static bool classof(const AssembleJobAction *) { return true; }
208 class LinkJobAction : public JobAction {
209 virtual void anchor();
211 LinkJobAction(ActionList &Inputs, types::ID Type);
213 static bool classof(const Action *A) {
214 return A->getKind() == LinkJobClass;
216 static bool classof(const LinkJobAction *) { return true; }
219 class LipoJobAction : public JobAction {
220 virtual void anchor();
222 LipoJobAction(ActionList &Inputs, types::ID Type);
224 static bool classof(const Action *A) {
225 return A->getKind() == LipoJobClass;
227 static bool classof(const LipoJobAction *) { return true; }
230 class DsymutilJobAction : public JobAction {
231 virtual void anchor();
233 DsymutilJobAction(ActionList &Inputs, types::ID Type);
235 static bool classof(const Action *A) {
236 return A->getKind() == DsymutilJobClass;
238 static bool classof(const DsymutilJobAction *) { return true; }
241 class VerifyJobAction : public JobAction {
242 virtual void anchor();
244 VerifyJobAction(ActionList &Inputs, types::ID Type);
245 static bool classof(const Action *A) {
246 return A->getKind() == VerifyJobClass;
248 static bool classof(const VerifyJobAction *) { return true; }
251 } // end namespace driver
252 } // end namespace clang