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