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