Home | History | Annotate | Download | only in mcld
      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 {
     24 public:
     25   enum Endian {
     26     Little,
     27     Big,
     28     Unknown
     29   };
     30 
     31 public:
     32   TargetOptions();
     33 
     34   TargetOptions(const std::string& pTriple);
     35 
     36   ~TargetOptions();
     37 
     38   const llvm::Triple& triple() const { return m_Triple; }
     39 
     40   void setTriple(const std::string& pTriple);
     41 
     42   void setTriple(const llvm::Triple& pTriple);
     43 
     44   const std::string& getArch() const { return m_ArchName; }
     45 
     46   void setArch(const std::string& pArchName);
     47 
     48   const std::string& getTargetCPU() const { return m_TargetCPU; }
     49 
     50   void setTargetCPU(const std::string& pCPU);
     51 
     52   const std::string& getTargetFeatureString() const { return m_TargetFS; }
     53 
     54   void setTargetFeatureString(const std::string& pFS);
     55 
     56   Endian endian() const { return m_Endian; }
     57 
     58   void setEndian(Endian pEndian) { m_Endian = pEndian; }
     59 
     60   bool isLittleEndian() const { return (Little == m_Endian); }
     61   bool isBigEndian   () const { return (Big    == m_Endian); }
     62 
     63   unsigned int bitclass() const { return m_BitClass; }
     64 
     65   void setBitClass(unsigned int pBitClass) { m_BitClass = pBitClass; }
     66 
     67   bool is32Bits() const { return (32 == m_BitClass); }
     68   bool is64Bits() const { return (64 == m_BitClass); }
     69 
     70 private:
     71   llvm::Triple m_Triple;
     72   std::string m_ArchName;
     73   std::string m_TargetCPU;
     74   std::string m_TargetFS;
     75   Endian m_Endian;
     76   unsigned int m_BitClass;
     77 
     78 };
     79 
     80 } // namespace of mcld
     81 
     82 #endif
     83 
     84