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