Move target independent td files from lib/Target/ to include/llvm/Target so they...
[oota-llvm.git] / include / llvm / CompilerDriver / Tool.h
1 //===--- Tool.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 "llvm/CompilerDriver/Action.h"
18
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/ADT/StringSet.h"
21 #include "llvm/System/Path.h"
22
23 #include <string>
24 #include <vector>
25
26 namespace llvmc {
27
28   class LanguageMap;
29   typedef std::vector<llvm::sys::Path> PathVector;
30   typedef llvm::StringSet<> InputLanguagesSet;
31
32   /// Tool - A class
33   class Tool : public llvm::RefCountedBaseVPTR<Tool> {
34   public:
35
36     virtual ~Tool() {}
37
38     virtual Action GenerateAction (const PathVector& inFiles,
39                                    const llvm::sys::Path& outFile,
40                                    const InputLanguagesSet& InLangs,
41                                    const LanguageMap& LangMap) const = 0;
42
43     virtual Action GenerateAction (const llvm::sys::Path& inFile,
44                                    const llvm::sys::Path& outFile,
45                                    const InputLanguagesSet& InLangs,
46                                    const LanguageMap& LangMap) const = 0;
47
48     virtual const char*  Name() const = 0;
49     virtual const char** InputLanguages() const = 0;
50     virtual const char*  OutputLanguage() const = 0;
51     virtual const char*  OutputSuffix() const = 0;
52
53     virtual bool IsLast() const = 0;
54     virtual bool IsJoin() const = 0;
55   };
56
57   /// JoinTool - A Tool that has an associated input file list.
58   class JoinTool : public Tool {
59   public:
60     void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
61     void ClearJoinList() { JoinList_.clear(); }
62     bool JoinListEmpty() const { return JoinList_.empty(); }
63
64     Action GenerateAction(const llvm::sys::Path& outFile,
65                           const InputLanguagesSet& InLangs,
66                           const LanguageMap& LangMap) const {
67       return GenerateAction(JoinList_, outFile, InLangs, LangMap);
68     }
69     // We shouldn't shadow base class's version of GenerateAction.
70     using Tool::GenerateAction;
71
72   private:
73     PathVector JoinList_;
74   };
75
76 }
77
78 #endif //LLVM_TOOLS_LLVMC2_TOOL_H