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(); }
95 class InputAction : public Action {
96 virtual void anchor();
99 InputAction(const Arg &_Input, types::ID _Type);
101 const Arg &getInputArg() const { return Input; }
103 static bool classof(const Action *A) {
104 return A->getKind() == InputClass;
108 class BindArchAction : public Action {
109 virtual void anchor();
110 /// The architecture to bind, or 0 if the default architecture
112 const char *ArchName;
115 BindArchAction(Action *Input, const char *_ArchName);
117 const char *getArchName() const { return ArchName; }
119 static bool classof(const Action *A) {
120 return A->getKind() == BindArchClass;
124 class JobAction : public Action {
125 virtual void anchor();
127 JobAction(ActionClass Kind, Action *Input, types::ID Type);
128 JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type);
131 static bool classof(const Action *A) {
132 return (A->getKind() >= JobClassFirst &&
133 A->getKind() <= JobClassLast);
137 class PreprocessJobAction : public JobAction {
138 virtual void anchor();
140 PreprocessJobAction(Action *Input, types::ID OutputType);
142 static bool classof(const Action *A) {
143 return A->getKind() == PreprocessJobClass;
147 class PrecompileJobAction : public JobAction {
148 virtual void anchor();
150 PrecompileJobAction(Action *Input, types::ID OutputType);
152 static bool classof(const Action *A) {
153 return A->getKind() == PrecompileJobClass;
157 class AnalyzeJobAction : public JobAction {
158 virtual void anchor();
160 AnalyzeJobAction(Action *Input, types::ID OutputType);
162 static bool classof(const Action *A) {
163 return A->getKind() == AnalyzeJobClass;
167 class MigrateJobAction : public JobAction {
168 virtual void anchor();
170 MigrateJobAction(Action *Input, types::ID OutputType);
172 static bool classof(const Action *A) {
173 return A->getKind() == MigrateJobClass;
177 class CompileJobAction : public JobAction {
178 virtual void anchor();
180 CompileJobAction(Action *Input, types::ID OutputType);
182 static bool classof(const Action *A) {
183 return A->getKind() == CompileJobClass;
187 class AssembleJobAction : public JobAction {
188 virtual void anchor();
190 AssembleJobAction(Action *Input, types::ID OutputType);
192 static bool classof(const Action *A) {
193 return A->getKind() == AssembleJobClass;
197 class LinkJobAction : public JobAction {
198 virtual void anchor();
200 LinkJobAction(ActionList &Inputs, types::ID Type);
202 static bool classof(const Action *A) {
203 return A->getKind() == LinkJobClass;
207 class LipoJobAction : public JobAction {
208 virtual void anchor();
210 LipoJobAction(ActionList &Inputs, types::ID Type);
212 static bool classof(const Action *A) {
213 return A->getKind() == LipoJobClass;
217 class DsymutilJobAction : public JobAction {
218 virtual void anchor();
220 DsymutilJobAction(ActionList &Inputs, types::ID Type);
222 static bool classof(const Action *A) {
223 return A->getKind() == DsymutilJobClass;
227 class VerifyJobAction : public JobAction {
228 virtual void anchor();
230 VerifyJobAction(ActionList &Inputs, types::ID Type);
231 static bool classof(const Action *A) {
232 return A->getKind() == VerifyJobClass;
236 } // end namespace driver
237 } // end namespace clang