LinkerConfig.h revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- LinkerConfig.h -----------------------------------------------------===//
2//
3//                     The MCLinker Project
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#ifndef MCLD_LINKER_CONFIG_H
10#define MCLD_LINKER_CONFIG_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <llvm/ADT/Triple.h>
16
17#include <mcld/GeneralOptions.h>
18#include <mcld/ScriptOptions.h>
19#include <mcld/BitcodeOption.h>
20#include <mcld/AttributeOption.h>
21#include <mcld/Support/Path.h>
22
23#include <string>
24
25namespace mcld {
26
27/** \class LinkerConfig
28 *  \brief LinkerConfig is composed of argumments of MCLinker.
29 *   options()        - the general options
30 *   scripts()        - the script options
31 *   bitcode()        - the bitcode being linked
32 *   attribute()      - the attribute options
33 */
34class LinkerConfig
35{
36public:
37  enum CodeGenType {
38    Unknown,
39    Object,
40    DynObj,
41    Exec,
42    External
43  };
44
45public:
46  LinkerConfig();
47
48  explicit LinkerConfig(const std::string &pTripleString);
49
50  ~LinkerConfig();
51
52  const GeneralOptions& options() const { return m_Options; }
53  GeneralOptions&       options()       { return m_Options; }
54
55  const ScriptOptions&  scripts() const { return m_Scripts; }
56  ScriptOptions&        scripts()       { return m_Scripts; }
57
58  const BitcodeOption&  bitcode() const { return m_Bitcode; }
59  BitcodeOption&        bitcode()       { return m_Bitcode; }
60
61  const AttributeOption& attribute() const { return m_Attribute; }
62  AttributeOption&       attribute()       { return m_Attribute; }
63
64  CodeGenType codeGenType() const { return m_CodeGenType; }
65
66  void setCodeGenType(CodeGenType pType) { m_CodeGenType = pType; }
67
68  const llvm::Triple& triple() const { return m_Triple; }
69
70  void setTriple(const std::string& pTriple);
71
72  void setTriple(const llvm::Triple& pTriple);
73
74  static const char* version();
75
76private:
77  // -----  General Options  ----- //
78  GeneralOptions m_Options;
79  ScriptOptions m_Scripts;
80  BitcodeOption m_Bitcode;
81  AttributeOption m_Attribute;
82
83  llvm::Triple m_Triple;
84  CodeGenType m_CodeGenType;
85};
86
87} // namespace of mcld
88
89#endif
90
91