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 GET_SUBTARGETINFO_HEADER
31#include "M68kGenSubtargetInfo.inc"
32
33extern bool M68kReserveGP;
34extern bool M68kNoCpload;
35
36namespace llvm {
37class StringRef;
38
39class M68kTargetMachine;
40
42 virtual void anchor();
43
44protected:
45 // These define which ISA is supported. Since each Motorola M68k ISA is
46 // built on top of the previous one whenever an ISA is selected the previous
47 // selected as well.
50
51 enum FPKindEnum { M881, M882 };
52 std::optional<FPKindEnum> FPUKind;
53
54 std::bitset<M68k::NUM_TARGET_REGS> UserReservedRegister;
55
57
58 /// Small section is used.
59 bool UseSmallSection = true;
60
62
66
67 /// The minimum alignment known to hold of the stack frame on
68 /// entry to the function and which must be maintained by every function.
69 unsigned stackAlignment = 8;
70
72
73public:
74 /// This constructor initializes the data members to match that
75 /// of the specified triple.
76 M68kSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
77 const M68kTargetMachine &_TM);
78
79 ~M68kSubtarget() override;
80
81 /// Parses features string setting specified subtarget options. Definition
82 /// of function is auto generated by tblgen.
84
85 bool isM68000() const { return SubtargetKind == M00; }
86 bool atLeastM68000() const { return SubtargetKind >= M00; }
87 bool atLeastM68010() const { return SubtargetKind >= M10; }
88 bool atLeastM68020() const { return SubtargetKind >= M20; }
89 bool atLeastM68030() const { return SubtargetKind >= M30; }
90 bool atLeastM68040() const { return SubtargetKind >= M40; }
91 bool atLeastM68060() const { return SubtargetKind >= M60; }
92
93 /// Floating point support
94 bool hasFPU() const { return FPUKind.has_value(); }
95 bool atLeastM68881() const { return hasFPU() && *FPUKind >= M881; }
96 bool atLeastM68882() const { return hasFPU() && *FPUKind >= M882; }
97
98 bool useSmallSection() const { return UseSmallSection; }
99
100 const Triple &getTargetTriple() const { return TargetTriple; }
101
102 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
103
104 /// Return true if the subtarget allows calls to immediate address.
105 bool isLegalToCallImmediateAddr() const;
106
107 bool isPositionIndependent() const;
108
109 bool isRegisterReservedByUser(Register R) const override {
110 assert(R < M68k::NUM_TARGET_REGS && "Register out of range");
111 return UserReservedRegister[R];
112 }
113
114 /// Classify a global variable reference for the current subtarget according
115 /// to how we should reference it in a non-pcrel context.
116 unsigned char classifyLocalReference(const GlobalValue *GV) const;
117
118 /// Classify a global variable reference for the current subtarget according
119 /// to how we should reference it in a non-pcrel context.
120 unsigned char classifyGlobalReference(const GlobalValue *GV,
121 const Module &M) const;
122 unsigned char classifyGlobalReference(const GlobalValue *GV) const;
123
124 /// Classify a external variable reference for the current subtarget according
125 /// to how we should reference it in a non-pcrel context.
126 unsigned char classifyExternalReference(const Module &M) const;
127
128 /// Classify a global function reference for the current subtarget.
129 unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
130 const Module &M) const;
131 unsigned char
132 classifyGlobalFunctionReference(const GlobalValue *GV) const override;
133
134 /// Classify a blockaddress reference for the current subtarget according to
135 /// how we should reference it in a non-pcrel context.
136 unsigned char classifyBlockAddressReference() const;
137
138 unsigned getJumpTableEncoding() const;
139
140 /// TODO this must be controlled by options like -malign-int and -mshort
142
143 /// getSlotSize - Stack slot size in bytes.
144 unsigned getSlotSize() const { return 4; }
145
147 StringRef FS,
148 const M68kTargetMachine &TM);
149
150 const M68kInstrInfo *getInstrInfo() const override { return &InstrInfo; }
151
152 const M68kFrameLowering *getFrameLowering() const override {
153 return &FrameLowering;
154 }
155
156 const M68kRegisterInfo *getRegisterInfo() const override {
157 return &InstrInfo.getRegisterInfo();
158 }
159
160 const M68kTargetLowering *getTargetLowering() const override {
161 return &TLInfo;
162 }
163
165 return &InstrItins;
166 }
167
168protected:
169 // SelectionDAGISel related APIs.
170 std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
171
172 // GlobalISel related APIs.
173 std::unique_ptr<CallLowering> CallLoweringInfo;
174 std::unique_ptr<InstructionSelector> InstSelector;
175 std::unique_ptr<LegalizerInfo> Legalizer;
176 std::unique_ptr<RegisterBankInfo> RegBankInfo;
177
178public:
179 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
180 const CallLowering *getCallLowering() const override;
182 const LegalizerInfo *getLegalizerInfo() const override;
183 const RegisterBankInfo *getRegBankInfo() const override;
184};
185} // namespace llvm
186
187#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.
bool M68kReserveGP
bool M68kNoCpload
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
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:67
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