• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- TargetOptions.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_TARGET_OPTIONS_H
10 #define MCLD_TARGET_OPTIONS_H
11 #ifdef ENABLE_UNITTEST
12 #include <gtest.h>
13 #endif
14 
15 #include <llvm/ADT/Triple.h>
16 
17 #include <string>
18 
19 namespace mcld {
20 
21 /** \class TargetOptions
22  *  \brief TargetOptions collects the options that dependent on a target
23  *  backend.
24  */
25 class TargetOptions
26 {
27 public:
28   enum Endian {
29     Little,
30     Big,
31     Unknown
32   };
33 
34 public:
35   TargetOptions();
36 
37   TargetOptions(const std::string& pTriple);
38 
39   ~TargetOptions();
40 
triple()41   const llvm::Triple& triple() const { return m_Triple; }
42 
43   void setTriple(const std::string& pTriple);
44 
45   void setTriple(const llvm::Triple& pTriple);
46 
endian()47   Endian endian() const { return m_Endian; }
48 
setEndian(Endian pEndian)49   void setEndian(Endian pEndian) { m_Endian = pEndian; }
50 
isLittleEndian()51   bool isLittleEndian() const { return (Little == m_Endian); }
isBigEndian()52   bool isBigEndian   () const { return (Big    == m_Endian); }
53 
bitclass()54   unsigned int bitclass() const { return m_BitClass; }
55 
setBitClass(unsigned int pBitClass)56   void setBitClass(unsigned int pBitClass) { m_BitClass = pBitClass; }
57 
is32Bits()58   bool is32Bits() const { return (32 == m_BitClass); }
is64Bits()59   bool is64Bits() const { return (64 == m_BitClass); }
60 
61 private:
62   llvm::Triple m_Triple;
63   Endian m_Endian;
64   unsigned int m_BitClass;
65 
66 };
67 
68 } // namespace of mcld
69 
70 #endif
71 
72