LinkerConfig.h revision d0fbbb227051be16931a1aa9b4a7722ac039c698
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/TargetOptions.h>
20#include <mcld/BitcodeOption.h>
21#include <mcld/AttributeOption.h>
22#include <mcld/Support/Path.h>
23
24#include <string>
25
26namespace mcld {
27
28/** \class LinkerConfig
29 *  \brief LinkerConfig is composed of argumments of MCLinker.
30 *   options()        - the general options
31 *   scripts()        - the script options
32 *   bitcode()        - the bitcode being linked
33 *   attribute()      - the attribute options
34 */
35class LinkerConfig
36{
37public:
38  enum CodeGenType {
39    Unknown,
40    Object,
41    DynObj,
42    Exec,
43    External,
44    Binary
45  };
46
47public:
48  LinkerConfig();
49
50  explicit LinkerConfig(const std::string &pTripleString);
51
52  ~LinkerConfig();
53
54  const GeneralOptions& options() const { return m_Options; }
55  GeneralOptions&       options()       { return m_Options; }
56
57  const ScriptOptions&  scripts() const { return m_Scripts; }
58  ScriptOptions&        scripts()       { return m_Scripts; }
59
60  const TargetOptions&  targets() const { return m_Targets; }
61  TargetOptions&        targets()       { return m_Targets; }
62
63  const BitcodeOption&  bitcode() const { return m_Bitcode; }
64  BitcodeOption&        bitcode()       { return m_Bitcode; }
65
66  const AttributeOption& attribute() const { return m_Attribute; }
67  AttributeOption&       attribute()       { return m_Attribute; }
68
69  CodeGenType codeGenType() const { return m_CodeGenType; }
70
71  void setCodeGenType(CodeGenType pType) { m_CodeGenType = pType; }
72
73  static const char* version();
74
75private:
76  // -----  General Options  ----- //
77  GeneralOptions m_Options;
78  ScriptOptions m_Scripts;
79  TargetOptions m_Targets;
80  BitcodeOption m_Bitcode;
81  AttributeOption m_Attribute;
82
83  CodeGenType m_CodeGenType;
84};
85
86} // namespace of mcld
87
88#endif
89
90