LLVM 20.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
27#include "llvm/IR/DataLayout.h"
30
31#include <string>
32
33#define GET_SUBTARGETINFO_HEADER
34#include "M68kGenSubtargetInfo.inc"
35
36extern bool M68kReserveGP;
37extern bool M68kNoCpload;
38
39namespace llvm {
40class StringRef;
41
42class M68kTargetMachine;
43
45 virtual void anchor();
46
47protected:
48 // These define which ISA is supported. Since each Motorola M68k ISA is
49 // built on top of the previous one whenever an ISA is selected the previous
50 // selected as well.
53
54 enum FPKindEnum { M881, M882 };
55 std::optional<FPKindEnum> FPUKind;
56
57 std::bitset<M68k::NUM_TARGET_REGS> UserReservedRegister;
58
60
61 /// Small section is used.
62 bool UseSmallSection = true;
63
65
70
71 /// The minimum alignment known to hold of the stack frame on
72 /// entry to the function and which must be maintained by every function.
73 unsigned stackAlignment = 8;
74
76
77public:
78 /// This constructor initializes the data members to match that
79 /// of the specified triple.
80 M68kSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
81 const M68kTargetMachine &_TM);
82
83 /// Parses features string setting specified subtarget options. Definition
84 /// of function is auto generated by tblgen.
86
87 bool atLeastM68000() const { return SubtargetKind >= M00; }
88 bool atLeastM68010() const { return SubtargetKind >= M10; }
89 bool atLeastM68020() const { return SubtargetKind >= M20; }
90 bool atLeastM68030() const { return SubtargetKind >= M30; }
91 bool atLeastM68040() const { return SubtargetKind >= M40; }
92 bool atLeastM68060() const { return SubtargetKind >= M60; }
93
94 /// Floating point support
95 bool hasFPU() const { return FPUKind.has_value(); }
96 bool atLeastM68881() const { return hasFPU() && *FPUKind >= M881; }
97 bool atLeastM68882() const { return hasFPU() && *FPUKind >= M882; }
98
99 bool useSmallSection() const { return UseSmallSection; }
100
101 const Triple &getTargetTriple() const { return TargetTriple; }
102
103 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
104
105 /// Return true if the subtarget allows calls to immediate address.
106 bool isLegalToCallImmediateAddr() const;
107
108 bool isPositionIndependent() const;
109
110 bool isRegisterReservedByUser(Register R) const override {
111 assert(R < M68k::NUM_TARGET_REGS && "Register out of range");
112 return UserReservedRegister[R];
113 }
114
115 /// Classify a global variable reference for the current subtarget according
116 /// to how we should reference it in a non-pcrel context.
117 unsigned char classifyLocalReference(const GlobalValue *GV) const;
118
119 /// Classify a global variable reference for the current subtarget according
120 /// to how we should reference it in a non-pcrel context.
121 unsigned char classifyGlobalReference(const GlobalValue *GV,
122 const Module &M) const;
123 unsigned char classifyGlobalReference(const GlobalValue *GV) const;
124
125 /// Classify a external variable reference for the current subtarget according
126 /// to how we should reference it in a non-pcrel context.
127 unsigned char classifyExternalReference(const Module &M) const;
128
129 /// Classify a global function reference for the current subtarget.
130 unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
131 const Module &M) const;
132 unsigned char
133 classifyGlobalFunctionReference(const GlobalValue *GV) const override;
134
135 /// Classify a blockaddress reference for the current subtarget according to
136 /// how we should reference it in a non-pcrel context.
137 unsigned char classifyBlockAddressReference() const;
138
139 unsigned getJumpTableEncoding() const;
140
141 /// TODO this must be controlled by options like -malign-int and -mshort
143
144 /// getSlotSize - Stack slot size in bytes.
145 unsigned getSlotSize() const { return 4; }
146
148 StringRef FS,
149 const M68kTargetMachine &TM);
150
152 return &TSInfo;
153 }
154
155 const M68kInstrInfo *getInstrInfo() const override { return &InstrInfo; }
156
157 const M68kFrameLowering *getFrameLowering() const override {
158 return &FrameLowering;
159 }
160
161 const M68kRegisterInfo *getRegisterInfo() const override {
162 return &InstrInfo.getRegisterInfo();
163 }
164
165 const M68kTargetLowering *getTargetLowering() const override {
166 return &TLInfo;
167 }
168
170 return &InstrItins;
171 }
172
173protected:
174 // GlobalISel related APIs.
175 std::unique_ptr<CallLowering> CallLoweringInfo;
176 std::unique_ptr<InstructionSelector> InstSelector;
177 std::unique_ptr<LegalizerInfo> Legalizer;
178 std::unique_ptr<RegisterBankInfo> RegBankInfo;
179
180public:
181 const CallLowering *getCallLowering() const override;
183 const LegalizerInfo *getLegalizerInfo() const override;
184 const RegisterBankInfo *getRegBankInfo() const override;
185};
186} // namespace llvm
187
188#endif // LLVM_LIB_TARGET_M68K_M68KSUBTARGET_H
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.
bool M68kReserveGP
bool M68kNoCpload
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Itinerary data supplied by a subtarget to be used by a target.
const M68kRegisterInfo & getRegisterInfo() const
TargetInstrInfo is a superset of MRegister info.
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
Definition: M68kSubtarget.h:97
InstrItineraryData InstrItins
Definition: M68kSubtarget.h:59
const M68kTargetLowering * getTargetLowering() const override
bool atLeastM68060() const
Definition: M68kSubtarget.h:92
std::optional< FPKindEnum > FPUKind
Definition: M68kSubtarget.h:55
SubtargetEnum SubtargetKind
Definition: M68kSubtarget.h:52
bool atLeastM68040() const
Definition: M68kSubtarget.h:91
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
Definition: M68kSubtarget.h:67
const InstrItineraryData * getInstrItineraryData() const override
std::bitset< M68k::NUM_TARGET_REGS > UserReservedRegister
Definition: M68kSubtarget.h:57
const RegisterBankInfo * getRegBankInfo() const override
bool UseSmallSection
Small section is used.
Definition: M68kSubtarget.h:62
bool isLegalToCallImmediateAddr() const
Return true if the subtarget allows calls to immediate address.
std::unique_ptr< CallLowering > CallLoweringInfo
bool atLeastM68881() const
Definition: M68kSubtarget.h:96
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
Parses features string setting specified subtarget options.
const M68kTargetMachine & TM
Definition: M68kSubtarget.h:64
bool hasFPU() const
Floating point support.
Definition: M68kSubtarget.h:95
unsigned getSlotSize() const
getSlotSize - Stack slot size in bytes.
const Triple & getTargetTriple() const
M68kTargetLowering TLInfo
Definition: M68kSubtarget.h:69
SelectionDAGTargetInfo TSInfo
Definition: M68kSubtarget.h:66
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
Definition: M68kSubtarget.h:87
const CallLowering * getCallLowering() const override
const SelectionDAGTargetInfo * getSelectionDAGInfo() const override
unsigned getJumpTableEncoding() const
InstructionSelector * getInstructionSelector() const override
bool useSmallSection() const
Definition: M68kSubtarget.h:99
bool atLeastM68010() const
Definition: M68kSubtarget.h:88
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...
Definition: M68kSubtarget.h:73
const M68kRegisterInfo * getRegisterInfo() const override
std::unique_ptr< LegalizerInfo > Legalizer
bool atLeastM68020() const
Definition: M68kSubtarget.h:89
bool isPositionIndependent() const
M68kSubtarget & initializeSubtargetDependencies(StringRef CPU, Triple TT, StringRef FS, const M68kTargetMachine &TM)
M68kFrameLowering FrameLowering
Definition: M68kSubtarget.h:68
bool atLeastM68030() const
Definition: M68kSubtarget.h:90
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:65
Holds all the information related to register banks.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:730
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39