LLVM 24.0.0git
M68kSubtarget.h
Go to the documentation of this file.
1//===-- M68kSubtarget.h - Define Subtarget for the M68k ---------*- C++ -*-===//
2//
3// 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
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file declares the M68k specific subclass of TargetSubtargetInfo.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_M68K_M68KSUBTARGET_H
15#define LLVM_LIB_TARGET_M68K_M68KSUBTARGET_H
16
17#include "M68kFrameLowering.h"
18#include "M68kISelLowering.h"
19#include "M68kInstrInfo.h"
20
26#include "llvm/IR/DataLayout.h"
29
30#define OPTIONS_STRUCT_DECL
31#include "M68kOptions.inc"
32
33#define GET_SUBTARGETINFO_HEADER
34#include "M68kGenSubtargetInfo.inc"
35
36namespace llvm {
37class StringRef;
38
39class M68kTargetMachine;
40
42 const M68kOptions &CLOpts;
43 virtual void anchor();
44
45protected:
46 // These define which ISA is supported. Since each Motorola M68k ISA is
47 // built on top of the previous one whenever an ISA is selected the previous
48 // selected as well.
51
52 enum FPKindEnum { M881, M882 };
53 std::optional<FPKindEnum> FPUKind;
54
55 std::bitset<M68k::NUM_TARGET_REGS> UserReservedRegister;
56
58
59 /// Small section is used.
60 bool UseSmallSection = true;
61
63
67
68 /// The minimum alignment known to hold of the stack frame on
69 /// entry to the function and which must be maintained by every function.
70 unsigned stackAlignment = 8;
71
73
74public:
75 /// This constructor initializes the data members to match that
76 /// of the specified triple.
77 M68kSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
78 const M68kTargetMachine &_TM);
79
80 ~M68kSubtarget() override;
81
82 const M68kOptions &getCLOpts() const { return CLOpts; }
83
84 /// Parses features string setting specified subtarget options. Definition
85 /// of function is auto generated by tblgen.
87
88 bool isM68000() const { return SubtargetKind == M00; }
89 bool atLeastM68000() const { return SubtargetKind >= M00; }
90 bool atLeastM68010() const { return SubtargetKind >= M10; }
91 bool atLeastM68020() const { return SubtargetKind >= M20; }
92 bool atLeastM68030() const { return SubtargetKind >= M30; }
93 bool atLeastM68040() const { return SubtargetKind >= M40; }
94 bool atLeastM68060() const { return SubtargetKind >= M60; }
95
96 /// Floating point support
97 bool hasFPU() const { return FPUKind.has_value(); }
98 bool atLeastM68881() const { return hasFPU() && *FPUKind >= M881; }
99 bool atLeastM68882() const { return hasFPU() && *FPUKind >= M882; }
100
101 bool useSmallSection() const { return UseSmallSection; }
102
103 const Triple &getTargetTriple() const { return TargetTriple; }
104
105 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
106
107 /// Return true if the subtarget allows calls to immediate address.
108 bool isLegalToCallImmediateAddr() const;
109
110 bool isPositionIndependent() const;
111
112 bool isRegisterReservedByUser(Register R) const override {
113 assert(R < M68k::NUM_TARGET_REGS && "Register out of range");
114 return UserReservedRegister[R];
115 }
116
117 /// Classify a global variable reference for the current subtarget according
118 /// to how we should reference it in a non-pcrel context.
119 unsigned char classifyLocalReference(const GlobalValue *GV) const;
120
121 /// Classify a global variable reference for the current subtarget according
122 /// to how we should reference it in a non-pcrel context.
123 unsigned char classifyGlobalReference(const GlobalValue *GV,
124 const Module &M) const;
125 unsigned char classifyGlobalReference(const GlobalValue *GV) const;
126
127 /// Classify a external variable reference for the current subtarget according
128 /// to how we should reference it in a non-pcrel context.
129 unsigned char classifyExternalReference(const Module &M) const;
130
131 /// Classify a global function reference for the current subtarget.
132 unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
133 const Module &M) const;
134 unsigned char
135 classifyGlobalFunctionReference(const GlobalValue *GV) const override;
136
137 /// Classify a blockaddress reference for the current subtarget according to
138 /// how we should reference it in a non-pcrel context.
139 unsigned char classifyBlockAddressReference() const;
140
141 unsigned getJumpTableEncoding() const;
142
143 /// TODO this must be controlled by options like -malign-int and -mshort
145
146 /// getSlotSize - Stack slot size in bytes.
147 unsigned getSlotSize() const { return 4; }
148
150 StringRef FS,
151 const M68kTargetMachine &TM);
152
153 const M68kInstrInfo *getInstrInfo() const override { return &InstrInfo; }
154
155 const M68kFrameLowering *getFrameLowering() const override {
156 return &FrameLowering;
157 }
158
159 const M68kRegisterInfo *getRegisterInfo() const override {
160 return &InstrInfo.getRegisterInfo();
161 }
162
163 const M68kTargetLowering *getTargetLowering() const override {
164 return &TLInfo;
165 }
166
168 return &InstrItins;
169 }
170
171protected:
172 // SelectionDAGISel related APIs.
173 std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
174
175 // GlobalISel related APIs.
176 std::unique_ptr<CallLowering> CallLoweringInfo;
177 std::unique_ptr<InstructionSelector> InstSelector;
178 std::unique_ptr<LegalizerInfo> Legalizer;
179 std::unique_ptr<RegisterBankInfo> RegBankInfo;
180
181public:
182 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
183 const CallLowering *getCallLowering() const override;
185 const LegalizerInfo *getLegalizerInfo() const override;
186 const RegisterBankInfo *getRegBankInfo() const override;
187};
188} // namespace llvm
189
190#endif // LLVM_LIB_TARGET_M68K_M68KSUBTARGET_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file describes how to lower LLVM calls to machine code calls.
Interface for Targets to specify which operations they can successfully select and how the others sho...
This file contains the M68k declaration of TargetFrameLowering class.
This file defines the interfaces that M68k uses to lower LLVM code into a selection DAG.
This file contains the M68k implementation of the TargetInstrInfo class.
Itinerary data supplied by a subtarget to be used by a target.
Align getStackAlignment() const
TODO this must be controlled by options like -malign-int and -mshort.
unsigned char classifyExternalReference(const Module &M) const
Classify a external variable reference for the current subtarget according to how we should reference...
bool atLeastM68882() const
bool isM68000() const
InstrItineraryData InstrItins
const M68kTargetLowering * getTargetLowering() const override
bool atLeastM68060() const
std::optional< FPKindEnum > FPUKind
M68kSubtarget(const Triple &TT, StringRef CPU, StringRef FS, const M68kTargetMachine &_TM)
This constructor initializes the data members to match that of the specified triple.
SubtargetEnum SubtargetKind
bool atLeastM68040() const
unsigned char classifyBlockAddressReference() const
Classify a blockaddress reference for the current subtarget according to how we should reference it i...
const LegalizerInfo * getLegalizerInfo() const override
M68kInstrInfo InstrInfo
std::unique_ptr< const SelectionDAGTargetInfo > TSInfo
const InstrItineraryData * getInstrItineraryData() const override
std::bitset< M68k::NUM_TARGET_REGS > UserReservedRegister
const RegisterBankInfo * getRegBankInfo() const override
bool UseSmallSection
Small section is used.
bool isLegalToCallImmediateAddr() const
Return true if the subtarget allows calls to immediate address.
std::unique_ptr< CallLowering > CallLoweringInfo
bool atLeastM68881() const
const SelectionDAGTargetInfo * getSelectionDAGInfo() const override
const M68kOptions & getCLOpts() const
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
Parses features string setting specified subtarget options.
const M68kTargetMachine & TM
bool hasFPU() const
Floating point support.
unsigned getSlotSize() const
getSlotSize - Stack slot size in bytes.
const Triple & getTargetTriple() const
M68kTargetLowering TLInfo
const M68kInstrInfo * getInstrInfo() const override
unsigned char classifyGlobalReference(const GlobalValue *GV, const Module &M) const
Classify a global variable reference for the current subtarget according to how we should reference i...
bool atLeastM68000() const
const CallLowering * getCallLowering() const override
unsigned getJumpTableEncoding() const
InstructionSelector * getInstructionSelector() const override
bool useSmallSection() const
bool atLeastM68010() const
~M68kSubtarget() override
std::unique_ptr< RegisterBankInfo > RegBankInfo
unsigned char classifyLocalReference(const GlobalValue *GV) const
Classify a global variable reference for the current subtarget according to how we should reference i...
bool isRegisterReservedByUser(Register R) const override
unsigned stackAlignment
The minimum alignment known to hold of the stack frame on entry to the function and which must be mai...
const M68kRegisterInfo * getRegisterInfo() const override
std::unique_ptr< LegalizerInfo > Legalizer
bool atLeastM68020() const
bool isPositionIndependent() const
M68kSubtarget & initializeSubtargetDependencies(StringRef CPU, Triple TT, StringRef FS, const M68kTargetMachine &TM)
M68kFrameLowering FrameLowering
bool atLeastM68030() const
unsigned char classifyGlobalFunctionReference(const GlobalValue *GV, const Module &M) const
Classify a global function reference for the current subtarget.
bool isTargetELF() const
std::unique_ptr< InstructionSelector > InstSelector
const M68kFrameLowering * getFrameLowering() const override
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Holds all the information related to register banks.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39