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_TARGETOPTIONS_H_ 10 #define MCLD_TARGETOPTIONS_H_ 11 12 #include <llvm/ADT/Triple.h> 13 14 #include <string> 15 16 namespace mcld { 17 18 /** \class TargetOptions 19 * \brief TargetOptions collects the options that dependent on a target 20 * backend. 21 */ 22 class TargetOptions { 23 public: 24 enum Endian { Little, Big, Unknown }; 25 26 public: 27 TargetOptions(); 28 29 explicit TargetOptions(const std::string& pTriple); 30 31 ~TargetOptions(); 32 triple()33 const llvm::Triple& triple() const { return m_Triple; } 34 35 void setTriple(const std::string& pTriple); 36 37 void setTriple(const llvm::Triple& pTriple); 38 getArch()39 const std::string& getArch() const { return m_ArchName; } 40 41 void setArch(const std::string& pArchName); 42 getTargetCPU()43 const std::string& getTargetCPU() const { return m_TargetCPU; } 44 45 void setTargetCPU(const std::string& pCPU); 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 std::string m_ArchName; 64 std::string m_TargetCPU; 65 Endian m_Endian; 66 unsigned int m_BitClass; 67 }; 68 69 } // namespace mcld 70 71 #endif // MCLD_TARGETOPTIONS_H_ 72