122c887ca9e61d29b604de05d8aee6a8e17d6d69
[oota-llvm.git] / tools / llvmc2 / Tool.h
1 //===--- Tools.h - The LLVM Compiler Driver ---------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Tool abstract base class - an interface to tool descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TOOLS_LLVMC2_TOOL_H
15 #define LLVM_TOOLS_LLVMC2_TOOL_H
16
17 #include "Action.h"
18
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/System/Path.h"
21
22 #include <string>
23 #include <vector>
24
25 namespace llvmc {
26
27   typedef std::vector<llvm::sys::Path> PathVector;
28
29   class Tool : public llvm::RefCountedBaseVPTR<Tool> {
30   public:
31
32     virtual ~Tool() {}
33
34     virtual Action GenerateAction (const PathVector& inFiles,
35                                    const llvm::sys::Path& outFile) const = 0;
36
37     virtual Action GenerateAction (const llvm::sys::Path& inFile,
38                                    const llvm::sys::Path& outFile) const = 0;
39
40     virtual const char* Name() const = 0;
41     virtual const char* InputLanguage() const = 0;
42     virtual const char* OutputLanguage() const = 0;
43     virtual const char* OutputSuffix() const = 0;
44
45     virtual bool IsLast() const = 0;
46     virtual bool IsJoin() const = 0;
47   };
48
49   // Join tools have an input file list associated with them.
50   class JoinTool : public Tool {
51   public:
52     void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
53     void ClearJoinList() { JoinList_.clear(); }
54     bool JoinListEmpty() const { return JoinList_.empty(); }
55
56     Action GenerateAction(const llvm::sys::Path& outFile) const
57     { return GenerateAction(JoinList_, outFile); }
58     // We shouldn't shadow base class's version of GenerateAction.
59     using Tool::GenerateAction;
60
61   private:
62     PathVector JoinList_;
63   };
64
65 }
66
67 #endif //LLVM_TOOLS_LLVMC2_TOOL_H