1 //===-- AVRSubtarget.h - Define Subtarget for the AVR -----------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file declares the AVR specific subclass of TargetSubtargetInfo. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_AVR_SUBTARGET_H 15 #define LLVM_AVR_SUBTARGET_H 16 17 #include "llvm/Target/TargetSubtargetInfo.h" 18 #include "llvm/IR/DataLayout.h" 19 #include "llvm/IR/DataLayout.h" 20 #include "llvm/Target/TargetMachine.h" 21 22 #include "AVRFrameLowering.h" 23 #include "AVRISelLowering.h" 24 #include "AVRInstrInfo.h" 25 #include "AVRSelectionDAGInfo.h" 26 27 #define GET_SUBTARGETINFO_HEADER 28 #include "AVRGenSubtargetInfo.inc" 29 30 namespace llvm { 31 32 /// A specific AVR target MCU. 33 class AVRSubtarget : public AVRGenSubtargetInfo { 34 public: 35 //! Creates an AVR subtarget. 36 //! \param TT The target triple. 37 //! \param CPU The CPU to target. 38 //! \param FS The feature string. 39 //! \param TM The target machine. 40 AVRSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, 41 AVRTargetMachine &TM); 42 43 const AVRInstrInfo *getInstrInfo() const override { return &InstrInfo; } 44 const TargetFrameLowering *getFrameLowering() const override { return &FrameLowering; } 45 const AVRTargetLowering *getTargetLowering() const override { return &TLInfo; } 46 const AVRSelectionDAGInfo *getSelectionDAGInfo() const override { return &TSInfo; } 47 const AVRRegisterInfo *getRegisterInfo() const override { return &InstrInfo.getRegisterInfo(); } 48 49 /// Parses a subtarget feature string, setting appropriate options. 50 /// \note Definition of function is auto generated by `tblgen`. 51 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 52 53 // Subtarget feature getters. 54 // See AVR.td for details. 55 bool hasSRAM() const { return m_hasSRAM; } 56 bool hasJMPCALL() const { return m_hasJMPCALL; } 57 bool hasIJMPCALL() const { return m_hasIJMPCALL; } 58 bool hasEIJMPCALL() const { return m_hasEIJMPCALL; } 59 bool hasADDSUBIW() const { return m_hasADDSUBIW; } 60 bool hasSmallStack() const { return m_hasSmallStack; } 61 bool hasMOVW() const { return m_hasMOVW; } 62 bool hasLPM() const { return m_hasLPM; } 63 bool hasLPMX() const { return m_hasLPMX; } 64 bool hasELPM() const { return m_hasELPM; } 65 bool hasELPMX() const { return m_hasELPMX; } 66 bool hasSPM() const { return m_hasSPM; } 67 bool hasSPMX() const { return m_hasSPMX; } 68 bool hasDES() const { return m_hasDES; } 69 bool supportsRMW() const { return m_supportsRMW; } 70 bool supportsMultiplication() const { return m_supportsMultiplication; } 71 bool hasBREAK() const { return m_hasBREAK; } 72 bool hasTinyEncoding() const { return m_hasTinyEncoding; } 73 74 /// Gets the ELF architecture for the e_flags field 75 /// of an ELF object file. 76 unsigned getELFArch() const { 77 assert(ELFArch != 0 && 78 "every device must have an associate ELF architecture"); 79 return ELFArch; 80 } 81 82 private: 83 AVRInstrInfo InstrInfo; 84 AVRFrameLowering FrameLowering; 85 AVRTargetLowering TLInfo; 86 AVRSelectionDAGInfo TSInfo; 87 88 // Subtarget feature settings 89 // See AVR.td for details. 90 bool m_hasSRAM; 91 bool m_hasJMPCALL; 92 bool m_hasIJMPCALL; 93 bool m_hasEIJMPCALL; 94 bool m_hasADDSUBIW; 95 bool m_hasSmallStack; 96 bool m_hasMOVW; 97 bool m_hasLPM; 98 bool m_hasLPMX; 99 bool m_hasELPM; 100 bool m_hasELPMX; 101 bool m_hasSPM; 102 bool m_hasSPMX; 103 bool m_hasDES; 104 bool m_supportsRMW; 105 bool m_supportsMultiplication; 106 bool m_hasBREAK; 107 bool m_hasTinyEncoding; 108 109 /// The ELF e_flags architecture. 110 unsigned ELFArch; 111 112 // Dummy member, used by FeatureSet's. We cannot have a SubtargetFeature with 113 // no variable, so we instead bind pseudo features to this variable. 114 bool m_FeatureSetDummy; 115 }; 116 117 } // end namespace llvm 118 119 #endif // LLVM_AVR_SUBTARGET_H 120