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;
55 JobClassFirst=PreprocessJobClass,
56 JobClassLast=VerifyJobClass
59 static const char *getClassName(ActionClass AC);
64 /// The output type of this action.
69 unsigned OwnsInputs : 1;
72 Action(ActionClass _Kind, types::ID _Type)
73 : Kind(_Kind), Type(_Type), OwnsInputs(true) {}
74 Action(ActionClass _Kind, Action *Input, types::ID _Type)
75 : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1), OwnsInputs(true) {}
76 Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
77 : Kind(_Kind), Type(_Type), Inputs(_Inputs), OwnsInputs(true) {}
81 const char *getClassName() const { return Action::getClassName(getKind()); }
83 bool getOwnsInputs() { return OwnsInputs; }
84 void setOwnsInputs(bool Value) { OwnsInputs = Value; }
86 ActionClass getKind() const { return Kind; }
87 types::ID getType() const { return Type; }
89 ActionList &getInputs() { return Inputs; }
90 const ActionList &getInputs() const { return Inputs; }
92 size_type size() const { return Inputs.size(); }
94 iterator begin() { return Inputs.begin(); }
95 iterator end() { return Inputs.end(); }
96 const_iterator begin() const { return Inputs.begin(); }
97 const_iterator end() const { return Inputs.end(); }
100 class InputAction : public Action {
101 virtual void anchor();
102 const llvm::opt::Arg &Input;
105 InputAction(const llvm::opt::Arg &_Input, types::ID _Type);
107 const llvm::opt::Arg &getInputArg() const { return Input; }
109 static bool classof(const Action *A) {
110 return A->getKind() == InputClass;
114 class BindArchAction : public Action {
115 virtual void anchor();
116 /// The architecture to bind, or 0 if the default architecture
118 const char *ArchName;
121 BindArchAction(Action *Input, const char *_ArchName);
123 const char *getArchName() const { return ArchName; }
125 static bool classof(const Action *A) {
126 return A->getKind() == BindArchClass;
130 class JobAction : public Action {
131 virtual void anchor();
133 JobAction(ActionClass Kind, Action *Input, types::ID Type);
134 JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type);
137 static bool classof(const Action *A) {
138 return (A->getKind() >= JobClassFirst &&
139 A->getKind() <= JobClassLast);
143 class PreprocessJobAction : public JobAction {
144 virtual void anchor();
146 PreprocessJobAction(Action *Input, types::ID OutputType);
148 static bool classof(const Action *A) {
149 return A->getKind() == PreprocessJobClass;
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;
163 class AnalyzeJobAction : public JobAction {
164 virtual void anchor();
166 AnalyzeJobAction(Action *Input, types::ID OutputType);
168 static bool classof(const Action *A) {
169 return A->getKind() == AnalyzeJobClass;
173 class MigrateJobAction : public JobAction {
174 virtual void anchor();
176 MigrateJobAction(Action *Input, types::ID OutputType);
178 static bool classof(const Action *A) {
179 return A->getKind() == MigrateJobClass;
183 class CompileJobAction : public JobAction {
184 virtual void anchor();
186 CompileJobAction(Action *Input, types::ID OutputType);
188 static bool classof(const Action *A) {
189 return A->getKind() == CompileJobClass;
193 class AssembleJobAction : public JobAction {
194 virtual void anchor();
196 AssembleJobAction(Action *Input, types::ID OutputType);
198 static bool classof(const Action *A) {
199 return A->getKind() == AssembleJobClass;
203 class LinkJobAction : public JobAction {
204 virtual void anchor();
206 LinkJobAction(ActionList &Inputs, types::ID Type);
208 static bool classof(const Action *A) {
209 return A->getKind() == LinkJobClass;
213 class LipoJobAction : public JobAction {
214 virtual void anchor();
216 LipoJobAction(ActionList &Inputs, types::ID Type);
218 static bool classof(const Action *A) {
219 return A->getKind() == LipoJobClass;
223 class DsymutilJobAction : public JobAction {
224 virtual void anchor();
226 DsymutilJobAction(ActionList &Inputs, types::ID Type);
228 static bool classof(const Action *A) {
229 return A->getKind() == DsymutilJobClass;
233 class VerifyJobAction : public JobAction {
234 virtual void anchor();
236 VerifyJobAction(ActionList &Inputs, types::ID Type);
237 static bool classof(const Action *A) {
238 return A->getKind() == VerifyJobClass;
242 } // end namespace driver
243 } // end namespace clang