blob: 3527817026d19b377b495ef8739e03535a662fed [file] [log] [blame]
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +00001//===--- 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"
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000018#include "StringSet.h"
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000019
20#include "llvm/ADT/IntrusiveRefCntPtr.h"
21#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;
29
Mikhail Glushenkovbe46ae12008-05-07 21:50:19 +000030 /// Tool - A class
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000031 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
32 public:
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000033
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000034 virtual ~Tool() {}
35
36 virtual Action GenerateAction (const PathVector& inFiles,
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000037 const llvm::sys::Path& outFile,
38 const StringSet<>& InLangs) const = 0;
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000039
40 virtual Action GenerateAction (const llvm::sys::Path& inFile,
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000041 const llvm::sys::Path& outFile,
42 const StringSet<>& InLangs) const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000043
Mikhail Glushenkovd379d162008-05-06 17:24:26 +000044 virtual const char* Name() const = 0;
45 virtual const char* InputLanguage() const = 0;
46 virtual const char* OutputLanguage() const = 0;
47 virtual const char* OutputSuffix() const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000048
49 virtual bool IsLast() const = 0;
50 virtual bool IsJoin() const = 0;
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000051 };
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000052
Mikhail Glushenkovbe46ae12008-05-07 21:50:19 +000053 /// JoinTool - A Tool that has an associated input file list.
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000054 class JoinTool : public Tool {
55 public:
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000056 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
57 void ClearJoinList() { JoinList_.clear(); }
58 bool JoinListEmpty() const { return JoinList_.empty(); }
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000059
Mikhail Glushenkov35576b02008-05-30 06:10:19 +000060 Action GenerateAction(const llvm::sys::Path& outFile,
61 const StringSet<>& InLangs) const {
62 return GenerateAction(JoinList_, outFile, InLangs);
63 }
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000064 // We shouldn't shadow base class's version of GenerateAction.
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000065 using Tool::GenerateAction;
66
67 private:
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000068 PathVector JoinList_;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000069 };
70
71}
72
73#endif //LLVM_TOOLS_LLVMC2_TOOL_H