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;
49 JobClassFirst=PreprocessJobClass,
50 JobClassLast=VerifyJobClass
53 static const char *getClassName(ActionClass AC);
58 /// The output type of this action.
63 unsigned OwnsInputs : 1;
66 Action(ActionClass _Kind, types::ID _Type)
67 : Kind(_Kind), Type(_Type), OwnsInputs(true) {}
68 Action(ActionClass _Kind, Action *Input, types::ID _Type)
69 : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1), OwnsInputs(true) {}
70 Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
71 : Kind(_Kind), Type(_Type), Inputs(_Inputs), OwnsInputs(true) {}
75 const char *getClassName() const { return Action::getClassName(getKind()); }
77 bool getOwnsInputs() { return OwnsInputs; }
78 void setOwnsInputs(bool Value) { OwnsInputs = Value; }
80 ActionClass getKind() const { return Kind; }
81 types::ID getType() const { return Type; }
83 ActionList &getInputs() { return Inputs; }
84 const ActionList &getInputs() const { return Inputs; }
86 size_type size() const { return Inputs.size(); }
88 iterator begin() { return Inputs.begin(); }
89 iterator end() { return Inputs.end(); }
90 const_iterator begin() const { return Inputs.begin(); }
91 const_iterator end() const { return Inputs.end(); }
93 static bool classof(const Action *) { return true; }
96 class InputAction : public Action {
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;
106 static bool classof(const InputAction *) { return true; }
109 class BindArchAction : public Action {
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;
122 static bool classof(const BindArchAction *) { return true; }
125 class JobAction : public Action {
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);
135 static bool classof(const JobAction *) { return true; }
138 class PreprocessJobAction : public JobAction {
140 PreprocessJobAction(Action *Input, types::ID OutputType);
142 static bool classof(const Action *A) {
143 return A->getKind() == PreprocessJobClass;
145 static bool classof(const PreprocessJobAction *) { return true; }
148 class PrecompileJobAction : public JobAction {
150 PrecompileJobAction(Action *Input, types::ID OutputType);
152 static bool classof(const Action *A) {
153 return A->getKind() == PrecompileJobClass;
155 static bool classof(const PrecompileJobAction *) { return true; }
158 class AnalyzeJobAction : public JobAction {
160 AnalyzeJobAction(Action *Input, types::ID OutputType);
162 static bool classof(const Action *A) {
163 return A->getKind() == AnalyzeJobClass;
165 static bool classof(const AnalyzeJobAction *) { return true; }
168 class CompileJobAction : public JobAction {
170 CompileJobAction(Action *Input, types::ID OutputType);
172 static bool classof(const Action *A) {
173 return A->getKind() == CompileJobClass;
175 static bool classof(const CompileJobAction *) { return true; }
178 class AssembleJobAction : public JobAction {
180 AssembleJobAction(Action *Input, types::ID OutputType);
182 static bool classof(const Action *A) {
183 return A->getKind() == AssembleJobClass;
185 static bool classof(const AssembleJobAction *) { return true; }
188 class LinkJobAction : public JobAction {
190 LinkJobAction(ActionList &Inputs, types::ID Type);
192 static bool classof(const Action *A) {
193 return A->getKind() == LinkJobClass;
195 static bool classof(const LinkJobAction *) { return true; }
198 class LipoJobAction : public JobAction {
200 LipoJobAction(ActionList &Inputs, types::ID Type);
202 static bool classof(const Action *A) {
203 return A->getKind() == LipoJobClass;
205 static bool classof(const LipoJobAction *) { return true; }
208 class DsymutilJobAction : public JobAction {
210 DsymutilJobAction(ActionList &Inputs, types::ID Type);
212 static bool classof(const Action *A) {
213 return A->getKind() == DsymutilJobClass;
215 static bool classof(const DsymutilJobAction *) { return true; }
218 class VerifyJobAction : public JobAction {
220 VerifyJobAction(ActionList &Inputs, types::ID Type);
221 static bool classof(const Action *A) {
222 return A->getKind() == VerifyJobClass;
224 static bool classof(const VerifyJobAction *) { return true; }
227 } // end namespace driver
228 } // end namespace clang