TargetOptions.h revision a6c24dff8b7fa2551a3a885e77a2e814f5b764a2
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 16namespace mcld { 17 18/** \class TargetOptions 19 * \brief TargetOptions collects the options that dependent on a target 20 * backend. 21 */ 22class 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 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 39 const std::string& getArch() const { return m_ArchName; } 40 41 void setArch(const std::string& pArchName); 42 43 const std::string& getTargetCPU() const { return m_TargetCPU; } 44 45 void setTargetCPU(const std::string& pCPU); 46 47 Endian endian() const { return m_Endian; } 48 49 void setEndian(Endian pEndian) { m_Endian = pEndian; } 50 51 bool isLittleEndian() const { return (Little == m_Endian); } 52 bool isBigEndian() const { return (Big == m_Endian); } 53 54 unsigned int bitclass() const { return m_BitClass; } 55 56 void setBitClass(unsigned int pBitClass) { m_BitClass = pBitClass; } 57 58 bool is32Bits() const { return (32 == m_BitClass); } 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