blob: b4478f9f2f8ef47ad20d00e25d46fbe7787c69ec [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
25namespace llvmcc {
26
27 typedef std::vector<llvm::sys::Path> PathVector;
28
29 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
30 public:
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000031
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000032 virtual ~Tool() {}
33
34 virtual Action GenerateAction (const PathVector& inFiles,
35 const llvm::sys::Path& outFile) const = 0;
36
37 virtual Action GenerateAction (const llvm::sys::Path& inFile,
38 const llvm::sys::Path& outFile) const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000039
Mikhail Glushenkovd379d162008-05-06 17:24:26 +000040 virtual const char* Name() const = 0;
41 virtual const char* InputLanguage() const = 0;
42 virtual const char* OutputLanguage() const = 0;
43 virtual const char* OutputSuffix() const = 0;
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000044
45 virtual bool IsLast() const = 0;
46 virtual bool IsJoin() const = 0;
47
48 // Helper function that is called by the auto-generated code
49 // Splits strings of the form ",-foo,-bar,-baz"
50 // TOFIX: find a better name
51 static void UnpackValues (std::string const& from,
52 std::vector<std::string>& to);
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000053 };
Mikhail Glushenkovafbeae92008-05-06 16:34:12 +000054
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000055 // Join tools have an input file list associated with them.
56 class JoinTool : public Tool {
57 public:
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000058 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
59 void ClearJoinList() { JoinList_.clear(); }
60 bool JoinListEmpty() const { return JoinList_.empty(); }
Mikhail Glushenkov121889c2008-05-06 17:26:53 +000061
62 Action GenerateAction(const llvm::sys::Path& outFile) const
Mikhail Glushenkovdfdb36a2008-05-06 18:07:48 +000063 { return GenerateAction(JoinList_, outFile); }
64 // 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