blob: 93fa5dfb43a9e3426f79cfb99bde1f9d81ad6df0 [file] [log] [blame]
Mikhail Glushenkov2d3327f2008-05-30 06:20:54 +00001//===--- Tool.h - The LLVM Compiler Driver ----------------------*- C++ -*-===//
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +00002//
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"
Mikhail Glushenkov6ffde0c2008-05-30 06:11:18 +000020#include "llvm/ADT/StringSet.h"
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000021#include "llvm/System/Path.h"
22
23#include <string>
24#include <vector>
25
Mikhail Glushenkov34307a92008-05-06 18:08:59 +000026namespace llvmc {
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000027
28 typedef std::vector<llvm::sys::Path> PathVector;
Mikhail Glushenkov6ffde0c2008-05-30 06:11:18 +000029 typedef llvm::StringSet<> InputLanguagesSet;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000030
Mikhail Glushenkovbe46ae12008-05-07 21:50:19 +000031 /// Tool - A class
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000032 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
33 public:
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000034
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000035 virtual ~Tool() {}
36
37 virtual Action GenerateAction (const PathVector& inFiles,
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000038 const llvm::sys::Path& outFile,
Mikhail Glushenkov6ffde0c2008-05-30 06:11:18 +000039 const InputLanguagesSet& InLangs) const = 0;
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000040
41 virtual Action GenerateAction (const llvm::sys::Path& inFile,
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000042 const llvm::sys::Path& outFile,
Mikhail Glushenkov6ffde0c2008-05-30 06:11:18 +000043 const InputLanguagesSet& InLangs) const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000044
Mikhail Glushenkov61923cb2008-05-30 06:24:49 +000045 virtual const char* Name() const = 0;
46 virtual const char** InputLanguages() const = 0;
47 virtual const char* OutputLanguage() const = 0;
48 virtual const char* OutputSuffix() const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000049
50 virtual bool IsLast() const = 0;
51 virtual bool IsJoin() const = 0;
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000052 };
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000053
Mikhail Glushenkovbe46ae12008-05-07 21:50:19 +000054 /// JoinTool - A Tool that has an associated input file list.
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000055 class JoinTool : public Tool {
56 public:
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000057 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
58 void ClearJoinList() { JoinList_.clear(); }
59 bool JoinListEmpty() const { return JoinList_.empty(); }
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000060
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000061 Action GenerateAction(const llvm::sys::Path& outFile,
Mikhail Glushenkov6ffde0c2008-05-30 06:11:18 +000062 const InputLanguagesSet& InLangs) const {
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000063 return GenerateAction(JoinList_, outFile, InLangs);
64 }
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000065 // We shouldn't shadow base class's version of GenerateAction.
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000066 using Tool::GenerateAction;
67
68 private:
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000069 PathVector JoinList_;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000070 };
71
72}
73
74#endif //LLVM_TOOLS_LLVMC2_TOOL_H