blob: bfa7e46f9e855fcbe2d7cb7faf9538ace11d08bc [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"
18
19#include "llvm/ADT/IntrusiveRefCntPtr.h"
20#include "llvm/System/Path.h"
21
22#include <string>
23#include <vector>
24
Mikhail Glushenkov34307a92008-05-06 18:08:59 +000025namespace llvmc {
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000026
27 typedef std::vector<llvm::sys::Path> PathVector;
28
Mikhail Glushenkovbe46ae12008-05-07 21:50:19 +000029 /// Tool - A class
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000030 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
31 public:
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000032
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000033 virtual ~Tool() {}
34
35 virtual Action GenerateAction (const PathVector& inFiles,
36 const llvm::sys::Path& outFile) const = 0;
37
38 virtual Action GenerateAction (const llvm::sys::Path& inFile,
39 const llvm::sys::Path& outFile) const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000040
Mikhail Glushenkovd379d162008-05-06 17:24:26 +000041 virtual const char* Name() const = 0;
42 virtual const char* InputLanguage() const = 0;
43 virtual const char* OutputLanguage() const = 0;
44 virtual const char* OutputSuffix() const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000045
46 virtual bool IsLast() const = 0;
47 virtual bool IsJoin() const = 0;
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000048 };
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000049
Mikhail Glushenkovbe46ae12008-05-07 21:50:19 +000050 /// JoinTool - A Tool that has an associated input file list.
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000051 class JoinTool : public Tool {
52 public:
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000053 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
54 void ClearJoinList() { JoinList_.clear(); }
55 bool JoinListEmpty() const { return JoinList_.empty(); }
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000056
57 Action GenerateAction(const llvm::sys::Path& outFile) const
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000058 { return GenerateAction(JoinList_, outFile); }
59 // We shouldn't shadow base class's version of GenerateAction.
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000060 using Tool::GenerateAction;
61
62 private:
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000063 PathVector JoinList_;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000064 };
65
66}
67
68#endif //LLVM_TOOLS_LLVMC2_TOOL_H