1 //===-- M68kBaseInfo.h - Top level definitions for M68k MC --*- C++ -*-----===//
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
7 //===----------------------------------------------------------------------===//
10 /// This file contains small standalone helper functions and enum definitions
11 /// for the M68k target useful for the compiler back-end and the MC
12 /// libraries. As such, it deliberately does not include references to LLVM
13 /// core code gen types, passes, etc..
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_LIB_TARGET_M68K_MCTARGETDESC_M68KBASEINFO_H
18 #define LLVM_LIB_TARGET_M68K_MCTARGETDESC_M68KBASEINFO_H
20 #include "M68kMCTargetDesc.h"
22 #include "llvm/MC/MCExpr.h"
23 #include "llvm/Support/DataTypes.h"
24 #include "llvm/Support/ErrorHandling.h"
26 #define GET_INSTRINFO_MI_OPS_INFO
27 #define GET_INSTRINFO_OPERAND_TYPES_ENUM
28 #define GET_INSTRINFO_LOGICAL_OPERAND_SIZE_MAP
29 #include "M68kGenInstrInfo.inc"
35 /// Enums for memory operand decoding. Supports these forms:
40 /// TODO Implement scaling other than 1
41 enum { MemDisp
= 0, MemBase
= 1, MemIndex
= 2, MemOuter
= 3 };
43 /// Enums for pc-relative memory operand decoding. Supports these forms:
48 enum { PCRelDisp
= 0, PCRelIndex
= 1, PCRelOuter
= 2 };
74 } // namespace M68kBeads
76 /// This namespace holds all of the target specific flags that instruction info
79 /// Target Operand Flag enum.
84 /// On a symbol operand this indicates that the immediate is the absolute
85 /// address of the symbol.
88 /// On a symbol operand this indicates that the immediate is the pc-relative
89 /// address of the symbol.
90 MO_PC_RELATIVE_ADDRESS
,
92 /// On a symbol operand this indicates that the immediate is the offset to
93 /// the GOT entry for the symbol name from the base of the GOT.
98 /// On a symbol operand this indicates that the immediate is the offset to
99 /// the location of the symbol name from the base of the GOT.
104 /// On a symbol operand this indicates that the immediate is offset to the
105 /// GOT entry for the symbol name from the current code location.
110 /// On a symbol operand this indicates that the immediate is offset to the
111 /// PLT entry of symbol name from the current code location.
117 /// Return true if the specified TargetFlag operand is a reference to a stub
118 /// for a global, not the global itself.
119 inline static bool isGlobalStubReference(unsigned char TargetFlag
) {
120 switch (TargetFlag
) {
123 case M68kII::MO_GOTPCREL
: // pc-relative GOT reference.
124 case M68kII::MO_GOT
: // normal GOT reference.
129 /// Return True if the specified GlobalValue is a direct reference for a
131 inline static bool isDirectGlobalReference(unsigned char Flag
) {
135 case M68kII::MO_NO_FLAG
:
136 case M68kII::MO_ABSOLUTE_ADDRESS
:
137 case M68kII::MO_PC_RELATIVE_ADDRESS
:
142 /// Return true if the specified global value reference is relative to a 32-bit
143 /// PIC base (M68kISD::GLOBAL_BASE_REG). If this is true, the addressing mode
144 /// has the PIC base register added in.
145 inline static bool isGlobalRelativeToPICBase(unsigned char TargetFlag
) {
146 switch (TargetFlag
) {
149 case M68kII::MO_GOTOFF
: // isPICStyleGOT: local global.
150 case M68kII::MO_GOT
: // isPICStyleGOT: other global.
155 /// Return True if the specified GlobalValue requires PC addressing mode.
156 inline static bool isPCRelGlobalReference(unsigned char Flag
) {
160 case M68kII::MO_GOTPCREL
:
161 case M68kII::MO_PC_RELATIVE_ADDRESS
:
166 /// Return True if the Block is referenced using PC
167 inline static bool isPCRelBlockReference(unsigned char Flag
) {
171 case M68kII::MO_PC_RELATIVE_ADDRESS
:
176 static inline bool isAddressRegister(unsigned RegNo
) {
200 static inline bool hasMultiMIOperands(unsigned Op
, unsigned LogicalOpIdx
) {
201 return M68k::getLogicalOperandSize(Op
, LogicalOpIdx
) > 1;
204 static inline unsigned getMaskedSpillRegister(unsigned order
) {
243 } // namespace M68kII