LLVM API Documentation
00001 //===--- Tool.h - The LLVM Compiler Driver ----------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open 00006 // Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // Tool abstract base class - an interface to tool descriptions. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_TOOLS_LLVMC2_TOOL_H 00015 #define LLVM_TOOLS_LLVMC2_TOOL_H 00016 00017 #include "llvm/CompilerDriver/Action.h" 00018 00019 #include "llvm/ADT/IntrusiveRefCntPtr.h" 00020 #include "llvm/ADT/StringSet.h" 00021 #include "llvm/System/Path.h" 00022 00023 #include <vector> 00024 00025 namespace llvmc { 00026 00027 class LanguageMap; 00028 typedef std::vector<llvm::sys::Path> PathVector; 00029 typedef llvm::StringSet<> InputLanguagesSet; 00030 00031 /// Tool - A class 00032 class Tool : public llvm::RefCountedBaseVPTR<Tool> { 00033 public: 00034 00035 virtual ~Tool() {} 00036 00037 virtual Action GenerateAction (const PathVector& inFiles, 00038 bool HasChildren, 00039 const llvm::sys::Path& TempDir, 00040 const InputLanguagesSet& InLangs, 00041 const LanguageMap& LangMap) const = 0; 00042 00043 virtual Action GenerateAction (const llvm::sys::Path& inFile, 00044 bool HasChildren, 00045 const llvm::sys::Path& TempDir, 00046 const InputLanguagesSet& InLangs, 00047 const LanguageMap& LangMap) const = 0; 00048 00049 virtual const char* Name() const = 0; 00050 virtual const char** InputLanguages() const = 0; 00051 virtual const char* OutputLanguage() const = 0; 00052 00053 virtual bool IsJoin() const = 0; 00054 00055 protected: 00056 /// OutFileName - Generate the output file name. 00057 llvm::sys::Path OutFilename(const llvm::sys::Path& In, 00058 const llvm::sys::Path& TempDir, 00059 bool StopCompilation, 00060 const char* OutputSuffix) const; 00061 }; 00062 00063 /// JoinTool - A Tool that has an associated input file list. 00064 class JoinTool : public Tool { 00065 public: 00066 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); } 00067 void ClearJoinList() { JoinList_.clear(); } 00068 bool JoinListEmpty() const { return JoinList_.empty(); } 00069 00070 Action GenerateAction(bool HasChildren, 00071 const llvm::sys::Path& TempDir, 00072 const InputLanguagesSet& InLangs, 00073 const LanguageMap& LangMap) const { 00074 return GenerateAction(JoinList_, HasChildren, TempDir, InLangs, LangMap); 00075 } 00076 // We shouldn't shadow base class's version of GenerateAction. 00077 using Tool::GenerateAction; 00078 00079 private: 00080 PathVector JoinList_; 00081 }; 00082 00083 } 00084 00085 #endif //LLVM_TOOLS_LLVMC2_TOOL_H