LLVM 20.0.0git
Sparc.h
Go to the documentation of this file.
1//===-- Sparc.h - Top-level interface for Sparc representation --*- 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// This file contains the entry points for global functions defined in the LLVM
10// Sparc back-end.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_SPARC_SPARC_H
15#define LLVM_LIB_TARGET_SPARC_SPARC_H
16
20
21namespace llvm {
22class AsmPrinter;
23class FunctionPass;
24class MCInst;
25class MachineInstr;
26class PassRegistry;
27class SparcTargetMachine;
28
29FunctionPass *createSparcISelDag(SparcTargetMachine &TM);
30FunctionPass *createSparcDelaySlotFillerPass();
31
32void LowerSparcMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
33 AsmPrinter &AP);
36} // namespace llvm
37
38namespace llvm {
39 // Enums corresponding to Sparc condition codes, both icc's and fcc's. These
40 // values must be kept in sync with the ones in the .td file.
41 namespace SPCC {
42 enum CondCodes {
43 ICC_A = 8, // Always
44 ICC_N = 0, // Never
45 ICC_NE = 9, // Not Equal
46 ICC_E = 1, // Equal
47 ICC_G = 10, // Greater
48 ICC_LE = 2, // Less or Equal
49 ICC_GE = 11, // Greater or Equal
50 ICC_L = 3, // Less
51 ICC_GU = 12, // Greater Unsigned
52 ICC_LEU = 4, // Less or Equal Unsigned
53 ICC_CC = 13, // Carry Clear/Great or Equal Unsigned
54 ICC_CS = 5, // Carry Set/Less Unsigned
55 ICC_POS = 14, // Positive
56 ICC_NEG = 6, // Negative
57 ICC_VC = 15, // Overflow Clear
58 ICC_VS = 7, // Overflow Set
59
61 FCC_A = 8 + FCC_BEGIN, // Always
62 FCC_N = 0 + FCC_BEGIN, // Never
63 FCC_U = 7 + FCC_BEGIN, // Unordered
64 FCC_G = 6 + FCC_BEGIN, // Greater
65 FCC_UG = 5 + FCC_BEGIN, // Unordered or Greater
66 FCC_L = 4 + FCC_BEGIN, // Less
67 FCC_UL = 3 + FCC_BEGIN, // Unordered or Less
68 FCC_LG = 2 + FCC_BEGIN, // Less or Greater
69 FCC_NE = 1 + FCC_BEGIN, // Not Equal
70 FCC_E = 9 + FCC_BEGIN, // Equal
71 FCC_UE = 10 + FCC_BEGIN, // Unordered or Equal
72 FCC_GE = 11 + FCC_BEGIN, // Greater or Equal
73 FCC_UGE = 12 + FCC_BEGIN, // Unordered or Greater or Equal
74 FCC_LE = 13 + FCC_BEGIN, // Less or Equal
75 FCC_ULE = 14 + FCC_BEGIN, // Unordered or Less or Equal
76 FCC_O = 15 + FCC_BEGIN, // Ordered
77
79 CPCC_A = 8 + CPCC_BEGIN, // Always
80 CPCC_N = 0 + CPCC_BEGIN, // Never
95
97 REG_Z = 1 + REG_BEGIN, // Is zero
98 REG_LEZ = 2 + REG_BEGIN, // Less or equal to zero
99 REG_LZ = 3 + REG_BEGIN, // Less than zero
100 REG_NZ = 5 + REG_BEGIN, // Is not zero
101 REG_GZ = 6 + REG_BEGIN, // Greater than zero
102 REG_GEZ = 7 + REG_BEGIN // Greater than or equal to zero
103 };
104 }
105
106 inline static const char *SPARCCondCodeToString(SPCC::CondCodes CC) {
107 switch (CC) {
108 case SPCC::ICC_A: return "a";
109 case SPCC::ICC_N: return "n";
110 case SPCC::ICC_NE: return "ne";
111 case SPCC::ICC_E: return "e";
112 case SPCC::ICC_G: return "g";
113 case SPCC::ICC_LE: return "le";
114 case SPCC::ICC_GE: return "ge";
115 case SPCC::ICC_L: return "l";
116 case SPCC::ICC_GU: return "gu";
117 case SPCC::ICC_LEU: return "leu";
118 case SPCC::ICC_CC: return "cc";
119 case SPCC::ICC_CS: return "cs";
120 case SPCC::ICC_POS: return "pos";
121 case SPCC::ICC_NEG: return "neg";
122 case SPCC::ICC_VC: return "vc";
123 case SPCC::ICC_VS: return "vs";
124 case SPCC::FCC_A: return "a";
125 case SPCC::FCC_N: return "n";
126 case SPCC::FCC_U: return "u";
127 case SPCC::FCC_G: return "g";
128 case SPCC::FCC_UG: return "ug";
129 case SPCC::FCC_L: return "l";
130 case SPCC::FCC_UL: return "ul";
131 case SPCC::FCC_LG: return "lg";
132 case SPCC::FCC_NE: return "ne";
133 case SPCC::FCC_E: return "e";
134 case SPCC::FCC_UE: return "ue";
135 case SPCC::FCC_GE: return "ge";
136 case SPCC::FCC_UGE: return "uge";
137 case SPCC::FCC_LE: return "le";
138 case SPCC::FCC_ULE: return "ule";
139 case SPCC::FCC_O: return "o";
140 case SPCC::CPCC_A: return "a";
141 case SPCC::CPCC_N: return "n";
142 case SPCC::CPCC_3: return "3";
143 case SPCC::CPCC_2: return "2";
144 case SPCC::CPCC_23: return "23";
145 case SPCC::CPCC_1: return "1";
146 case SPCC::CPCC_13: return "13";
147 case SPCC::CPCC_12: return "12";
148 case SPCC::CPCC_123: return "123";
149 case SPCC::CPCC_0: return "0";
150 case SPCC::CPCC_03: return "03";
151 case SPCC::CPCC_02: return "02";
152 case SPCC::CPCC_023: return "023";
153 case SPCC::CPCC_01: return "01";
154 case SPCC::CPCC_013: return "013";
155 case SPCC::CPCC_012: return "012";
156 case SPCC::REG_BEGIN:
157 llvm_unreachable("Use of reserved cond code");
158 case SPCC::REG_Z:
159 return "z";
160 case SPCC::REG_LEZ:
161 return "lez";
162 case SPCC::REG_LZ:
163 return "lz";
164 case SPCC::REG_NZ:
165 return "nz";
166 case SPCC::REG_GZ:
167 return "gz";
168 case SPCC::REG_GEZ:
169 return "gez";
170 }
171 llvm_unreachable("Invalid cond code");
172 }
173
174 inline static unsigned HI22(int64_t imm) {
175 return (unsigned)((imm >> 10) & ((1 << 22)-1));
176 }
177
178 inline static unsigned LO10(int64_t imm) {
179 return (unsigned)(imm & 0x3FF);
180 }
181
182 inline static unsigned HIX22(int64_t imm) {
183 return HI22(~imm);
184 }
185
186 inline static unsigned LOX10(int64_t imm) {
187 return ~LO10(~imm);
188 }
189
190} // end namespace llvm
191#endif
IRTranslator LLVM IR MI
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:37
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CondCodes
Definition: Sparc.h:42
@ CPCC_03
Definition: Sparc.h:89
@ CPCC_013
Definition: Sparc.h:93
@ FCC_ULE
Definition: Sparc.h:75
@ ICC_POS
Definition: Sparc.h:55
@ FCC_UG
Definition: Sparc.h:65
@ ICC_N
Definition: Sparc.h:44
@ CPCC_123
Definition: Sparc.h:87
@ ICC_G
Definition: Sparc.h:47
@ REG_LEZ
Definition: Sparc.h:98
@ CPCC_23
Definition: Sparc.h:83
@ FCC_BEGIN
Definition: Sparc.h:60
@ REG_GZ
Definition: Sparc.h:101
@ ICC_L
Definition: Sparc.h:50
@ REG_BEGIN
Definition: Sparc.h:96
@ FCC_NE
Definition: Sparc.h:69
@ CPCC_01
Definition: Sparc.h:92
@ CPCC_12
Definition: Sparc.h:86
@ ICC_CS
Definition: Sparc.h:54
@ FCC_LG
Definition: Sparc.h:68
@ ICC_VS
Definition: Sparc.h:58
@ CPCC_1
Definition: Sparc.h:84
@ ICC_LEU
Definition: Sparc.h:52
@ CPCC_BEGIN
Definition: Sparc.h:78
@ CPCC_A
Definition: Sparc.h:79
@ CPCC_0
Definition: Sparc.h:88
@ FCC_LE
Definition: Sparc.h:74
@ CPCC_012
Definition: Sparc.h:94
@ ICC_LE
Definition: Sparc.h:48
@ FCC_U
Definition: Sparc.h:63
@ CPCC_2
Definition: Sparc.h:82
@ FCC_A
Definition: Sparc.h:61
@ CPCC_023
Definition: Sparc.h:91
@ CPCC_13
Definition: Sparc.h:85
@ ICC_GE
Definition: Sparc.h:49
@ FCC_E
Definition: Sparc.h:70
@ CPCC_02
Definition: Sparc.h:90
@ REG_LZ
Definition: Sparc.h:99
@ FCC_L
Definition: Sparc.h:66
@ ICC_GU
Definition: Sparc.h:51
@ FCC_O
Definition: Sparc.h:76
@ ICC_NE
Definition: Sparc.h:45
@ FCC_UE
Definition: Sparc.h:71
@ REG_NZ
Definition: Sparc.h:100
@ ICC_E
Definition: Sparc.h:46
@ FCC_GE
Definition: Sparc.h:72
@ ICC_A
Definition: Sparc.h:43
@ CPCC_3
Definition: Sparc.h:81
@ FCC_UGE
Definition: Sparc.h:73
@ REG_Z
Definition: Sparc.h:97
@ ICC_VC
Definition: Sparc.h:57
@ ICC_CC
Definition: Sparc.h:53
@ REG_GEZ
Definition: Sparc.h:102
@ CPCC_N
Definition: Sparc.h:80
@ FCC_G
Definition: Sparc.h:64
@ FCC_UL
Definition: Sparc.h:67
@ FCC_N
Definition: Sparc.h:62
@ ICC_NEG
Definition: Sparc.h:56
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static const char * SPARCCondCodeToString(SPCC::CondCodes CC)
Definition: Sparc.h:106
static unsigned HI22(int64_t imm)
Definition: Sparc.h:174
static unsigned HIX22(int64_t imm)
Definition: Sparc.h:182
void initializeSparcDAGToDAGISelLegacyPass(PassRegistry &)
void initializeErrataWorkaroundPass(PassRegistry &)
static unsigned LOX10(int64_t imm)
Definition: Sparc.h:186
void LowerSparcMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
FunctionPass * createSparcISelDag(SparcTargetMachine &TM)
createSparcISelDag - This pass converts a legalized DAG into a SPARC-specific DAG,...
static unsigned LO10(int64_t imm)
Definition: Sparc.h:178
FunctionPass * createSparcDelaySlotFillerPass()
createSparcDelaySlotFillerPass - Returns a pass that fills in delay slots in Sparc MachineFunctions