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  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   // -G, max GP size option
     62   void setGPSize(unsigned pGPSize) { m_GPSize = pGPSize; }
     63 
     64   unsigned getGPSize() const { return m_GPSize; }
     65 
     66   void setStubGroupSize(unsigned pSize) { m_StubGroupSize = pSize; }
     67 
     68   unsigned getStubGroupSize() const { return m_StubGroupSize; }
     69 
     70   void setFixCA53Erratum835769(bool pEnable = true) {
     71     m_FixCA53Erratum835769 = pEnable;
     72   }
     73 
     74   bool fixCA53Erratum835769() const { return m_FixCA53Erratum835769; }
     75 
     76   void setFixCA53Erratum843419(bool pEnable = true) {
     77     m_FixCA53Erratum843419 = pEnable;
     78   }
     79 
     80   bool fixCA53Erratum843419() const { return m_FixCA53Erratum843419; }
     81 
     82  private:
     83   llvm::Triple m_Triple;
     84   std::string m_ArchName;
     85   std::string m_TargetCPU;
     86   Endian m_Endian;
     87   unsigned int m_BitClass;
     88   unsigned m_GPSize;  // -G, --gpsize
     89   unsigned m_StubGroupSize;
     90   bool m_FixCA53Erratum835769 : 1;
     91   bool m_FixCA53Erratum843419 : 1;
     92 };
     93 
     94 }  // namespace mcld
     95 
     96 #endif  // MCLD_TARGETOPTIONS_H_
     97