LLVM 24.0.0git
MipsSEInstrInfo.cpp
Go to the documentation of this file.
1//===-- MipsSEInstrInfo.cpp - Mips32/64 Instruction Information -----------===//
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 Mips32/64 implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "MipsSEInstrInfo.h"
15#include "MipsTargetMachine.h"
21
22using namespace llvm;
23
24static unsigned getUnconditionalBranch(const MipsSubtarget &STI) {
25 if (STI.inMicroMipsMode())
26 return STI.isPositionIndependent() ? Mips::B_MM : Mips::J_MM;
27 return STI.isPositionIndependent() ? Mips::B : Mips::J;
28}
29
32
33/// isLoadFromStackSlot - If the specified machine instruction is a direct
34/// load from a stack slot, return the virtual or physical register number of
35/// the destination along with the FrameIndex of the loaded stack slot. If
36/// not, return 0. This predicate must return 0 if the instruction has
37/// any side effects other than loading from the stack slot.
39 int &FrameIndex) const {
40 unsigned Opc = MI.getOpcode();
41
42 if ((Opc == Mips::LW) || (Opc == Mips::LD) ||
43 (Opc == Mips::LWC1) || (Opc == Mips::LDC1) || (Opc == Mips::LDC164)) {
44 if ((MI.getOperand(1).isFI()) && // is a stack slot
45 (MI.getOperand(2).isImm()) && // the imm is zero
46 (isZeroImm(MI.getOperand(2))) &&
47 // Not half of an AFGR64 register (MIPS I).
48 !MI.getOperand(0).getSubReg()) {
49 FrameIndex = MI.getOperand(1).getIndex();
50 return MI.getOperand(0).getReg();
51 }
52 }
53
54 return 0;
55}
56
57/// isStoreToStackSlot - If the specified machine instruction is a direct
58/// store to a stack slot, return the virtual or physical register number of
59/// the source reg along with the FrameIndex of the loaded stack slot. If
60/// not, return 0. This predicate must return 0 if the instruction has
61/// any side effects other than storing to the stack slot.
63 int &FrameIndex) const {
64 unsigned Opc = MI.getOpcode();
65
66 if ((Opc == Mips::SW) || (Opc == Mips::SD) ||
67 (Opc == Mips::SWC1) || (Opc == Mips::SDC1) || (Opc == Mips::SDC164)) {
68 if ((MI.getOperand(1).isFI()) && // is a stack slot
69 (MI.getOperand(2).isImm()) && // the imm is zero
70 (isZeroImm(MI.getOperand(2))) &&
71 // Not half of an AFGR64 register (MIPS I).
72 !MI.getOperand(0).getSubReg()) {
73 FrameIndex = MI.getOperand(1).getIndex();
74 return MI.getOperand(0).getReg();
75 }
76 }
77 return 0;
78}
79
82 const DebugLoc &DL, Register DestReg,
83 Register SrcReg, bool KillSrc,
84 bool RenamableDest, bool RenamableSrc) const {
85 unsigned Opc = 0, ZeroReg = 0;
86 bool isMicroMips = Subtarget.inMicroMipsMode();
87
88 if (Mips::GPR32RegClass.contains(DestReg)) { // Copy to CPU Reg.
89 if (Mips::GPR32RegClass.contains(SrcReg)) {
90 if (Subtarget.hasNanoMips())
91 Opc = Mips::MOVE_NM;
92 else if (isMicroMips)
93 Opc = Mips::MOVE16_MM;
94 else
95 Opc = Mips::OR, ZeroReg = Mips::R0;
96 } else if (Mips::CCRRegClass.contains(SrcReg))
97 Opc = Mips::CFC1;
98 else if (Mips::FGR32RegClass.contains(SrcReg))
99 Opc = Mips::MFC1;
100 else if (Mips::HI32RegClass.contains(SrcReg)) {
101 Opc = isMicroMips ? Mips::MFHI16_MM : Mips::MFHI;
102 SrcReg = 0;
103 } else if (Mips::LO32RegClass.contains(SrcReg)) {
104 Opc = isMicroMips ? Mips::MFLO16_MM : Mips::MFLO;
105 SrcReg = 0;
106 } else if (Mips::HI32DSPRegClass.contains(SrcReg))
107 Opc = Mips::MFHI_DSP;
108 else if (Mips::LO32DSPRegClass.contains(SrcReg))
109 Opc = Mips::MFLO_DSP;
110 else if (Mips::DSPCCRegClass.contains(SrcReg)) {
111 BuildMI(MBB, I, DL, get(Mips::RDDSP), DestReg).addImm(1 << 4)
112 .addReg(SrcReg, RegState::Implicit | getKillRegState(KillSrc));
113 return;
114 } else if (Mips::MSACtrlRegClass.contains(SrcReg)) {
115 Opc = Mips::CFCMSA;
116 }
117 }
118 else if (Mips::GPR32RegClass.contains(SrcReg)) { // Copy from CPU Reg.
119 if (Mips::CCRRegClass.contains(DestReg))
120 Opc = Mips::CTC1;
121 else if (Mips::FGR32RegClass.contains(DestReg))
122 Opc = Mips::MTC1;
123 else if (Mips::HI32RegClass.contains(DestReg))
124 Opc = Mips::MTHI, DestReg = 0;
125 else if (Mips::LO32RegClass.contains(DestReg))
126 Opc = Mips::MTLO, DestReg = 0;
127 else if (Mips::HI32DSPRegClass.contains(DestReg))
128 Opc = Mips::MTHI_DSP;
129 else if (Mips::LO32DSPRegClass.contains(DestReg))
130 Opc = Mips::MTLO_DSP;
131 else if (Mips::DSPCCRegClass.contains(DestReg)) {
132 BuildMI(MBB, I, DL, get(Mips::WRDSP))
133 .addReg(SrcReg, getKillRegState(KillSrc)).addImm(1 << 4)
135 return;
136 } else if (Mips::MSACtrlRegClass.contains(DestReg)) {
137 BuildMI(MBB, I, DL, get(Mips::CTCMSA))
138 .addReg(DestReg)
139 .addReg(SrcReg, getKillRegState(KillSrc));
140 return;
141 }
142 }
143 else if (Mips::FGR32RegClass.contains(DestReg, SrcReg))
144 Opc = Mips::FMOV_S;
145 else if (Mips::AFGR64RegClass.contains(DestReg, SrcReg))
146 Opc = Mips::FMOV_D32;
147 else if (Mips::FGR64RegClass.contains(DestReg, SrcReg))
148 Opc = Mips::FMOV_D64;
149 else if (Mips::GPR64RegClass.contains(DestReg)) { // Copy to CPU64 Reg.
150 if (Mips::GPR64RegClass.contains(SrcReg))
151 Opc = Mips::OR64, ZeroReg = Mips::R0_64;
152 else if (Mips::HI64RegClass.contains(SrcReg))
153 Opc = Mips::MFHI64, SrcReg = 0;
154 else if (Mips::LO64RegClass.contains(SrcReg))
155 Opc = Mips::MFLO64, SrcReg = 0;
156 else if (Mips::FGR64RegClass.contains(SrcReg))
157 Opc = Mips::DMFC1;
158 }
159 else if (Mips::GPR64RegClass.contains(SrcReg)) { // Copy from CPU64 Reg.
160 if (Mips::HI64RegClass.contains(DestReg))
161 Opc = Mips::MTHI64, DestReg = 0;
162 else if (Mips::LO64RegClass.contains(DestReg))
163 Opc = Mips::MTLO64, DestReg = 0;
164 else if (Mips::FGR64RegClass.contains(DestReg))
165 Opc = Mips::DMTC1;
166 } else if (Mips::MSA128BRegClass.contains(DestReg)) { // Copy to MSA reg
167 if (Mips::MSA128BRegClass.contains(SrcReg))
168 Opc = Mips::MOVE_V;
169 }
170
171 assert(Opc && "Cannot copy registers");
172
174
175 if (DestReg)
176 MIB.addReg(DestReg, RegState::Define);
177
178 if (SrcReg)
179 MIB.addReg(SrcReg, getKillRegState(KillSrc));
180
181 if (ZeroReg)
182 MIB.addReg(ZeroReg);
183}
184
185static bool isORCopyInst(const MachineInstr &MI) {
186 switch (MI.getOpcode()) {
187 default:
188 break;
189 case Mips::OR_MM:
190 case Mips::OR:
191 if (MI.getOperand(2).getReg() == Mips::R0)
192 return true;
193 break;
194 case Mips::OR64:
195 if (MI.getOperand(2).getReg() == Mips::R0_64)
196 return true;
197 break;
198 }
199 return false;
200}
201
202/// We check for the common case of 'or', as it's MIPS' preferred instruction
203/// for GPRs but we have to check the operands to ensure that is the case.
204/// Other move instructions for MIPS are directly identifiable.
205std::optional<DestSourcePair>
207 if (MI.isMoveReg() || isORCopyInst(MI))
208 return DestSourcePair{MI.getOperand(0), MI.getOperand(1)};
209
210 return std::nullopt;
211}
212
213/// Store or load an AFGR64 register as two words with swc1/lwc1. The words
214/// are laid out in memory the same way sdc1/ldc1 would lay them out.
215void MipsSEInstrInfo::storeLoadAFGR64Halves(MachineBasicBlock &MBB,
217 Register Reg, bool IsKill, int FI,
218 int64_t Offset,
220 bool IsStore) const {
221 MachineFunction &MF = *MBB.getParent();
222 DebugLoc DL;
223 if (I != MBB.end())
224 DL = I->getDebugLoc();
225
226 // The low word is at the lower address on little endian targets and at the
227 // higher address on big endian targets.
228 unsigned SubIdx[2] = {Mips::sub_lo, Mips::sub_hi};
229 if (!Subtarget.isLittle())
230 std::swap(SubIdx[0], SubIdx[1]);
231
232 for (unsigned N = 0; N < 2; ++N) {
233 MachineMemOperand *WordMMO =
234 MF.getMachineMemOperand(MMO, 4 * N, LLT::scalar(32));
236 BuildMI(MBB, I, DL, get(IsStore ? Mips::SWC1 : Mips::LWC1));
237
238 if (IsStore) {
239 if (Reg.isVirtual())
240 MIB.addReg(Reg, getKillRegState(IsKill && N == 1), SubIdx[N]);
241 else
242 MIB.addReg(RI.getSubReg(Reg, SubIdx[N]), getKillRegState(IsKill));
243 } else {
244 if (Reg.isVirtual())
245 MIB.addReg(Reg, RegState::Define | getUndefRegState(N == 0), SubIdx[N]);
246 else
247 MIB.addReg(RI.getSubReg(Reg, SubIdx[N]), RegState::Define);
248 }
249
250 MIB.addFrameIndex(FI).addImm(Offset + 4 * N).addMemOperand(WordMMO);
251
252 // The last load defines the whole register. Spill folding expects the
253 // last instruction to fully define a physical register.
254 if (!IsStore && N == 1 && Reg.isPhysical())
256 }
257}
258
261 Register SrcReg, bool isKill, int FI,
262 const TargetRegisterClass *RC,
263 int64_t Offset,
264 MachineInstr::MIFlag Flags) const {
265 DebugLoc DL;
267
268 unsigned Opc = 0;
269
270 if (Mips::GPR32RegClass.hasSubClassEq(RC))
271 Opc = Subtarget.hasNanoMips() ? Mips::SW_NM : Mips::SW;
272 else if (Mips::GPR64RegClass.hasSubClassEq(RC))
273 Opc = Mips::SD;
274 else if (Mips::ACC64RegClass.hasSubClassEq(RC))
275 Opc = Mips::STORE_ACC64;
276 else if (Mips::ACC64DSPRegClass.hasSubClassEq(RC))
277 Opc = Mips::STORE_ACC64DSP;
278 else if (Mips::ACC128RegClass.hasSubClassEq(RC))
279 Opc = Mips::STORE_ACC128;
280 else if (Mips::DSPCCRegClass.hasSubClassEq(RC))
281 Opc = Mips::STORE_CCOND_DSP;
282 else if (Mips::FGR32RegClass.hasSubClassEq(RC))
283 Opc = Mips::SWC1;
284 else if (Mips::AFGR64RegClass.hasSubClassEq(RC)) {
285 // MIPS I has no sdc1, so store the two halves with swc1.
286 if (!Subtarget.hasMips2()) {
287 storeLoadAFGR64Halves(MBB, I, SrcReg, isKill, FI, Offset, MMO,
288 /*IsStore=*/true);
289 return;
290 }
291 Opc = Mips::SDC1;
292 } else if (Mips::FGR64RegClass.hasSubClassEq(RC))
293 Opc = Mips::SDC164;
294 else if (RI.isTypeLegalForClass(*RC, MVT::v16i8))
295 Opc = Mips::ST_B;
296 else if (RI.isTypeLegalForClass(*RC, MVT::v8i16) ||
297 RI.isTypeLegalForClass(*RC, MVT::v8f16))
298 Opc = Mips::ST_H;
299 else if (RI.isTypeLegalForClass(*RC, MVT::v4i32) ||
300 RI.isTypeLegalForClass(*RC, MVT::v4f32))
301 Opc = Mips::ST_W;
302 else if (RI.isTypeLegalForClass(*RC, MVT::v2i64) ||
303 RI.isTypeLegalForClass(*RC, MVT::v2f64))
304 Opc = Mips::ST_D;
305 else if (Mips::LO32RegClass.hasSubClassEq(RC))
306 Opc = Mips::SW;
307 else if (Mips::LO64RegClass.hasSubClassEq(RC))
308 Opc = Mips::SD;
309 else if (Mips::HI32RegClass.hasSubClassEq(RC))
310 Opc = Mips::SW;
311 else if (Mips::HI64RegClass.hasSubClassEq(RC))
312 Opc = Mips::SD;
313 else if (Mips::DSPRRegClass.hasSubClassEq(RC))
314 Opc = Mips::SWDSP;
315
316 // Hi, Lo are normally caller save but they are callee save
317 // for interrupt handling.
318 const Function &Func = MBB.getParent()->getFunction();
319 if (Func.hasFnAttribute("interrupt")) {
320 if (Mips::HI32RegClass.hasSubClassEq(RC)) {
321 BuildMI(MBB, I, DL, get(Mips::MFHI), Mips::R26);
322 SrcReg = Mips::R26;
323 } else if (Mips::HI64RegClass.hasSubClassEq(RC)) {
324 BuildMI(MBB, I, DL, get(Mips::MFHI64), Mips::R26_64);
325 SrcReg = Mips::R26_64;
326 } else if (Mips::LO32RegClass.hasSubClassEq(RC)) {
327 BuildMI(MBB, I, DL, get(Mips::MFLO), Mips::R26);
328 SrcReg = Mips::R26;
329 } else if (Mips::LO64RegClass.hasSubClassEq(RC)) {
330 BuildMI(MBB, I, DL, get(Mips::MFLO64), Mips::R26_64);
331 SrcReg = Mips::R26_64;
332 }
333 }
334
335 assert(Opc && "Register class not handled!");
336 BuildMI(MBB, I, DL, get(Opc)).addReg(SrcReg, getKillRegState(isKill))
338}
339
342 Register DestReg, int FI,
343 const TargetRegisterClass *RC,
344 int64_t Offset,
345 MachineInstr::MIFlag Flags) const {
346 DebugLoc DL;
347 if (I != MBB.end()) DL = I->getDebugLoc();
349 unsigned Opc = 0;
350
351 const Function &Func = MBB.getParent()->getFunction();
352 bool ReqIndirectLoad = Func.hasFnAttribute("interrupt") &&
353 (DestReg == Mips::LO0 || DestReg == Mips::LO0_64 ||
354 DestReg == Mips::HI0 || DestReg == Mips::HI0_64);
355
356 if (Mips::GPR32RegClass.hasSubClassEq(RC))
357 Opc = Subtarget.hasNanoMips() ? Mips::LW_NM : Mips::LW;
358 else if (Mips::GPR64RegClass.hasSubClassEq(RC))
359 Opc = Mips::LD;
360 else if (Mips::ACC64RegClass.hasSubClassEq(RC))
361 Opc = Mips::LOAD_ACC64;
362 else if (Mips::ACC64DSPRegClass.hasSubClassEq(RC))
363 Opc = Mips::LOAD_ACC64DSP;
364 else if (Mips::ACC128RegClass.hasSubClassEq(RC))
365 Opc = Mips::LOAD_ACC128;
366 else if (Mips::DSPCCRegClass.hasSubClassEq(RC))
367 Opc = Mips::LOAD_CCOND_DSP;
368 else if (Mips::FGR32RegClass.hasSubClassEq(RC))
369 Opc = Mips::LWC1;
370 else if (Mips::AFGR64RegClass.hasSubClassEq(RC)) {
371 // MIPS I has no ldc1, so load the two halves with lwc1.
372 if (!Subtarget.hasMips2()) {
373 storeLoadAFGR64Halves(MBB, I, DestReg, false, FI, Offset, MMO,
374 /*IsStore=*/false);
375 return;
376 }
377 Opc = Mips::LDC1;
378 } else if (Mips::FGR64RegClass.hasSubClassEq(RC))
379 Opc = Mips::LDC164;
380 else if (RI.isTypeLegalForClass(*RC, MVT::v16i8))
381 Opc = Mips::LD_B;
382 else if (RI.isTypeLegalForClass(*RC, MVT::v8i16) ||
383 RI.isTypeLegalForClass(*RC, MVT::v8f16))
384 Opc = Mips::LD_H;
385 else if (RI.isTypeLegalForClass(*RC, MVT::v4i32) ||
386 RI.isTypeLegalForClass(*RC, MVT::v4f32))
387 Opc = Mips::LD_W;
388 else if (RI.isTypeLegalForClass(*RC, MVT::v2i64) ||
389 RI.isTypeLegalForClass(*RC, MVT::v2f64))
390 Opc = Mips::LD_D;
391 else if (Mips::HI32RegClass.hasSubClassEq(RC))
392 Opc = Mips::LW;
393 else if (Mips::HI64RegClass.hasSubClassEq(RC))
394 Opc = Mips::LD;
395 else if (Mips::LO32RegClass.hasSubClassEq(RC))
396 Opc = Mips::LW;
397 else if (Mips::LO64RegClass.hasSubClassEq(RC))
398 Opc = Mips::LD;
399 else if (Mips::DSPRRegClass.hasSubClassEq(RC))
400 Opc = Mips::LWDSP;
401
402 assert(Opc && "Register class not handled!");
403
404 if (!ReqIndirectLoad)
405 BuildMI(MBB, I, DL, get(Opc), DestReg)
406 .addFrameIndex(FI)
407 .addImm(Offset)
408 .addMemOperand(MMO);
409 else {
410 // Load HI/LO through K0. Notably the DestReg is encoded into the
411 // instruction itself.
412 unsigned Reg = Mips::R26;
413 unsigned LdOp = Mips::MTLO;
414 if (DestReg == Mips::HI0)
415 LdOp = Mips::MTHI;
416
417 if (Subtarget.getABI().ArePtrs64bit()) {
418 Reg = Mips::R26_64;
419 if (DestReg == Mips::HI0_64)
420 LdOp = Mips::MTHI64;
421 else
422 LdOp = Mips::MTLO64;
423 }
424
425 BuildMI(MBB, I, DL, get(Opc), Reg)
426 .addFrameIndex(FI)
427 .addImm(Offset)
428 .addMemOperand(MMO);
429 BuildMI(MBB, I, DL, get(LdOp)).addReg(Reg);
430 }
431}
432
434 MachineBasicBlock &MBB = *MI.getParent();
435 bool isMicroMips = Subtarget.inMicroMipsMode();
436 unsigned Opc;
437
438 switch (MI.getDesc().getOpcode()) {
439 default:
440 return false;
441 case Mips::RetRA:
442 expandRetRA(MBB, MI);
443 break;
444 case Mips::ERet:
445 expandERet(MBB, MI);
446 break;
447 case Mips::PseudoMFHI:
448 expandPseudoMFHiLo(MBB, MI, Mips::MFHI);
449 break;
450 case Mips::PseudoMFHI_MM:
451 expandPseudoMFHiLo(MBB, MI, Mips::MFHI16_MM);
452 break;
453 case Mips::PseudoMFLO:
454 expandPseudoMFHiLo(MBB, MI, Mips::MFLO);
455 break;
456 case Mips::PseudoMFLO_MM:
457 expandPseudoMFHiLo(MBB, MI, Mips::MFLO16_MM);
458 break;
459 case Mips::PseudoMFHI64:
460 expandPseudoMFHiLo(MBB, MI, Mips::MFHI64);
461 break;
462 case Mips::PseudoMFLO64:
463 expandPseudoMFHiLo(MBB, MI, Mips::MFLO64);
464 break;
465 case Mips::PseudoMTLOHI:
466 expandPseudoMTLoHi(MBB, MI, Mips::MTLO, Mips::MTHI, false);
467 break;
468 case Mips::PseudoMTLOHI64:
469 expandPseudoMTLoHi(MBB, MI, Mips::MTLO64, Mips::MTHI64, false);
470 break;
471 case Mips::PseudoMTLOHI_DSP:
472 expandPseudoMTLoHi(MBB, MI, Mips::MTLO_DSP, Mips::MTHI_DSP, true);
473 break;
474 case Mips::PseudoMTLOHI_MM:
475 expandPseudoMTLoHi(MBB, MI, Mips::MTLO_MM, Mips::MTHI_MM, false);
476 break;
477 case Mips::PseudoCVT_S_W:
478 expandCvtFPInt(MBB, MI, Mips::CVT_S_W, Mips::MTC1, false);
479 break;
480 case Mips::PseudoCVT_D32_W:
481 Opc = isMicroMips ? Mips::CVT_D32_W_MM : Mips::CVT_D32_W;
482 expandCvtFPInt(MBB, MI, Opc, Mips::MTC1, false);
483 break;
484 case Mips::PseudoCVT_S_L:
485 expandCvtFPInt(MBB, MI, Mips::CVT_S_L, Mips::DMTC1, true);
486 break;
487 case Mips::PseudoCVT_D64_W:
488 Opc = isMicroMips ? Mips::CVT_D64_W_MM : Mips::CVT_D64_W;
489 expandCvtFPInt(MBB, MI, Opc, Mips::MTC1, true);
490 break;
491 case Mips::PseudoCVT_D64_L:
492 expandCvtFPInt(MBB, MI, Mips::CVT_D64_L, Mips::DMTC1, true);
493 break;
494 case Mips::BuildPairF64:
495 expandBuildPairF64(MBB, MI, isMicroMips, false);
496 break;
497 case Mips::BuildPairF64_64:
498 expandBuildPairF64(MBB, MI, isMicroMips, true);
499 break;
500 case Mips::ExtractElementF64:
501 expandExtractElementF64(MBB, MI, isMicroMips, false);
502 break;
503 case Mips::ExtractElementF64_64:
504 expandExtractElementF64(MBB, MI, isMicroMips, true);
505 break;
506 case Mips::MIPSeh_return32:
507 case Mips::MIPSeh_return64:
508 expandEhReturn(MBB, MI);
509 break;
510 }
511
512 MBB.erase(MI);
513 return true;
514}
515
516/// isBranchWithImm - Return true if the branch contains an immediate
517/// operand (\see lib/Target/Mips/MipsBranchExpansion.cpp).
519 switch (Opc) {
520 default:
521 return false;
522 case Mips::BBIT0:
523 case Mips::BBIT1:
524 case Mips::BBIT032:
525 case Mips::BBIT132:
526 return true;
527 }
528}
529
530/// getOppositeBranchOpc - Return the inverse of the specified
531/// opcode, e.g. turning BEQ to BNE.
533 switch (Opc) {
534 default: llvm_unreachable("Illegal opcode!");
535 case Mips::BEQ: return Mips::BNE;
536 case Mips::BEQ_MM: return Mips::BNE_MM;
537 case Mips::BNE: return Mips::BEQ;
538 case Mips::BNE_MM: return Mips::BEQ_MM;
539 case Mips::BGTZ: return Mips::BLEZ;
540 case Mips::BGEZ: return Mips::BLTZ;
541 case Mips::BLTZ: return Mips::BGEZ;
542 case Mips::BLEZ: return Mips::BGTZ;
543 case Mips::BGTZ_MM: return Mips::BLEZ_MM;
544 case Mips::BGEZ_MM: return Mips::BLTZ_MM;
545 case Mips::BLTZ_MM: return Mips::BGEZ_MM;
546 case Mips::BLEZ_MM: return Mips::BGTZ_MM;
547 case Mips::BEQ64: return Mips::BNE64;
548 case Mips::BNE64: return Mips::BEQ64;
549 case Mips::BGTZ64: return Mips::BLEZ64;
550 case Mips::BGEZ64: return Mips::BLTZ64;
551 case Mips::BLTZ64: return Mips::BGEZ64;
552 case Mips::BLEZ64: return Mips::BGTZ64;
553 case Mips::BC1T: return Mips::BC1F;
554 case Mips::BC1F: return Mips::BC1T;
555 case Mips::BC1T_MM: return Mips::BC1F_MM;
556 case Mips::BC1F_MM: return Mips::BC1T_MM;
557 case Mips::BEQZ16_MM: return Mips::BNEZ16_MM;
558 case Mips::BNEZ16_MM: return Mips::BEQZ16_MM;
559 case Mips::BEQZC_MM: return Mips::BNEZC_MM;
560 case Mips::BNEZC_MM: return Mips::BEQZC_MM;
561 case Mips::BEQZC: return Mips::BNEZC;
562 case Mips::BNEZC: return Mips::BEQZC;
563 case Mips::BLEZC: return Mips::BGTZC;
564 case Mips::BGEZC: return Mips::BLTZC;
565 case Mips::BGEC: return Mips::BLTC;
566 case Mips::BGTZC: return Mips::BLEZC;
567 case Mips::BLTZC: return Mips::BGEZC;
568 case Mips::BLTC: return Mips::BGEC;
569 case Mips::BGEUC: return Mips::BLTUC;
570 case Mips::BLTUC: return Mips::BGEUC;
571 case Mips::BEQC: return Mips::BNEC;
572 case Mips::BNEC: return Mips::BEQC;
573 case Mips::BC1EQZ: return Mips::BC1NEZ;
574 case Mips::BC1NEZ: return Mips::BC1EQZ;
575 case Mips::BEQZC_MMR6: return Mips::BNEZC_MMR6;
576 case Mips::BNEZC_MMR6: return Mips::BEQZC_MMR6;
577 case Mips::BLEZC_MMR6: return Mips::BGTZC_MMR6;
578 case Mips::BGEZC_MMR6: return Mips::BLTZC_MMR6;
579 case Mips::BGEC_MMR6: return Mips::BLTC_MMR6;
580 case Mips::BGTZC_MMR6: return Mips::BLEZC_MMR6;
581 case Mips::BLTZC_MMR6: return Mips::BGEZC_MMR6;
582 case Mips::BLTC_MMR6: return Mips::BGEC_MMR6;
583 case Mips::BGEUC_MMR6: return Mips::BLTUC_MMR6;
584 case Mips::BLTUC_MMR6: return Mips::BGEUC_MMR6;
585 case Mips::BEQC_MMR6: return Mips::BNEC_MMR6;
586 case Mips::BNEC_MMR6: return Mips::BEQC_MMR6;
587 case Mips::BC1EQZC_MMR6: return Mips::BC1NEZC_MMR6;
588 case Mips::BC1NEZC_MMR6: return Mips::BC1EQZC_MMR6;
589 case Mips::BEQZC64: return Mips::BNEZC64;
590 case Mips::BNEZC64: return Mips::BEQZC64;
591 case Mips::BEQC64: return Mips::BNEC64;
592 case Mips::BNEC64: return Mips::BEQC64;
593 case Mips::BGEC64: return Mips::BLTC64;
594 case Mips::BGEUC64: return Mips::BLTUC64;
595 case Mips::BLTC64: return Mips::BGEC64;
596 case Mips::BLTUC64: return Mips::BGEUC64;
597 case Mips::BGTZC64: return Mips::BLEZC64;
598 case Mips::BGEZC64: return Mips::BLTZC64;
599 case Mips::BLTZC64: return Mips::BGEZC64;
600 case Mips::BLEZC64: return Mips::BGTZC64;
601 case Mips::BBIT0: return Mips::BBIT1;
602 case Mips::BBIT1: return Mips::BBIT0;
603 case Mips::BBIT032: return Mips::BBIT132;
604 case Mips::BBIT132: return Mips::BBIT032;
605 case Mips::BZ_B: return Mips::BNZ_B;
606 case Mips::BZ_H: return Mips::BNZ_H;
607 case Mips::BZ_W: return Mips::BNZ_W;
608 case Mips::BZ_D: return Mips::BNZ_D;
609 case Mips::BZ_V: return Mips::BNZ_V;
610 case Mips::BNZ_B: return Mips::BZ_B;
611 case Mips::BNZ_H: return Mips::BZ_H;
612 case Mips::BNZ_W: return Mips::BZ_W;
613 case Mips::BNZ_D: return Mips::BZ_D;
614 case Mips::BNZ_V: return Mips::BZ_V;
615 }
616}
617
618/// Adjust SP by Amount bytes.
619void MipsSEInstrInfo::adjustStackPtr(unsigned SP, int64_t Amount,
622 MipsABIInfo ABI = Subtarget.getABI();
623 DebugLoc DL;
624 unsigned ADDiu = ABI.GetPtrAddiuOp();
625
626 if (Amount == 0)
627 return;
628
629 if (isInt<16>(Amount)) {
630 // addi sp, sp, amount
631 BuildMI(MBB, I, DL, get(ADDiu), SP).addReg(SP).addImm(Amount);
632 } else {
633 // For numbers which are not 16bit integers we synthesize Amount inline
634 // then add or subtract it from sp.
635 unsigned Opc = ABI.GetPtrAdduOp();
636 if (Amount < 0) {
637 Opc = ABI.GetPtrSubuOp();
638 Amount = -Amount;
639 }
640 unsigned Reg = loadImmediate(Amount, MBB, I, DL, nullptr);
641 BuildMI(MBB, I, DL, get(Opc), SP).addReg(SP).addReg(Reg, RegState::Kill);
642 }
643}
644
645/// This function generates the sequence of instructions needed to get the
646/// result of adding register REG and immediate IMM.
649 const DebugLoc &DL,
650 unsigned *NewImm) const {
651 MipsAnalyzeImmediate AnalyzeImm;
652 const MipsSubtarget &STI = Subtarget;
653 MachineRegisterInfo &RegInfo = MBB.getParent()->getRegInfo();
654 unsigned Size = STI.isABI_N64() ? 64 : 32;
655 unsigned LUi = STI.isABI_N64() ? Mips::LUi64 : Mips::LUi;
656 unsigned ZEROReg = STI.isABI_N64() ? Mips::R0_64 : Mips::R0;
657 const TargetRegisterClass *RC = STI.isABI_N64() ?
658 &Mips::GPR64RegClass : &Mips::GPR32RegClass;
659 bool LastInstrIsADDiu = NewImm;
660
662 AnalyzeImm.Analyze(Imm, Size, LastInstrIsADDiu);
664
665 assert(Seq.size() && (!LastInstrIsADDiu || (Seq.size() > 1)));
666
667 // The first instruction can be a LUi, which is different from other
668 // instructions (ADDiu, ORI and SLL) in that it does not have a register
669 // operand.
670 Register Reg = RegInfo.createVirtualRegister(RC);
671
672 if (Inst->Opc == LUi)
673 BuildMI(MBB, II, DL, get(LUi), Reg).addImm(SignExtend64<16>(Inst->ImmOpnd));
674 else
675 BuildMI(MBB, II, DL, get(Inst->Opc), Reg).addReg(ZEROReg)
676 .addImm(SignExtend64<16>(Inst->ImmOpnd));
677
678 // Build the remaining instructions in Seq.
679 for (++Inst; Inst != Seq.end() - LastInstrIsADDiu; ++Inst)
680 BuildMI(MBB, II, DL, get(Inst->Opc), Reg).addReg(Reg, RegState::Kill)
681 .addImm(SignExtend64<16>(Inst->ImmOpnd));
682
683 if (LastInstrIsADDiu)
684 *NewImm = Inst->ImmOpnd;
685
686 return Reg;
687}
688
689unsigned MipsSEInstrInfo::getAnalyzableBrOpc(unsigned Opc) const {
690 return (Opc == Mips::BEQ || Opc == Mips::BEQ_MM || Opc == Mips::BNE ||
691 Opc == Mips::BNE_MM || Opc == Mips::BGTZ || Opc == Mips::BGEZ ||
692 Opc == Mips::BLTZ || Opc == Mips::BLEZ || Opc == Mips::BEQ64 ||
693 Opc == Mips::BNE64 || Opc == Mips::BGTZ64 || Opc == Mips::BGEZ64 ||
694 Opc == Mips::BLTZ64 || Opc == Mips::BLEZ64 || Opc == Mips::BC1T ||
695 Opc == Mips::BC1F || Opc == Mips::B || Opc == Mips::J ||
696 Opc == Mips::J_MM || Opc == Mips::B_MM || Opc == Mips::BEQZC_MM ||
697 Opc == Mips::BNEZC_MM || Opc == Mips::BEQC || Opc == Mips::BNEC ||
698 Opc == Mips::BLTC || Opc == Mips::BGEC || Opc == Mips::BLTUC ||
699 Opc == Mips::BGEUC || Opc == Mips::BGTZC || Opc == Mips::BLEZC ||
700 Opc == Mips::BGEZC || Opc == Mips::BLTZC || Opc == Mips::BEQZC ||
701 Opc == Mips::BNEZC || Opc == Mips::BEQZC64 || Opc == Mips::BNEZC64 ||
702 Opc == Mips::BEQC64 || Opc == Mips::BNEC64 || Opc == Mips::BGEC64 ||
703 Opc == Mips::BGEUC64 || Opc == Mips::BLTC64 || Opc == Mips::BLTUC64 ||
704 Opc == Mips::BGTZC64 || Opc == Mips::BGEZC64 ||
705 Opc == Mips::BLTZC64 || Opc == Mips::BLEZC64 || Opc == Mips::BC ||
706 Opc == Mips::BC1EQZ || Opc == Mips::BC1NEZ || Opc == Mips::BBIT0 ||
707 Opc == Mips::BBIT1 || Opc == Mips::BBIT032 || Opc == Mips::BBIT132 ||
708 Opc == Mips::BC_MMR6 || Opc == Mips::BEQC_MMR6 ||
709 Opc == Mips::BNEC_MMR6 || Opc == Mips::BLTC_MMR6 ||
710 Opc == Mips::BGEC_MMR6 || Opc == Mips::BLTUC_MMR6 ||
711 Opc == Mips::BGEUC_MMR6 || Opc == Mips::BGTZC_MMR6 ||
712 Opc == Mips::BLEZC_MMR6 || Opc == Mips::BGEZC_MMR6 ||
713 Opc == Mips::BLTZC_MMR6 || Opc == Mips::BEQZC_MMR6 ||
714 Opc == Mips::BNEZC_MMR6 || Opc == Mips::BC1EQZC_MMR6 ||
715 Opc == Mips::BC1NEZC_MMR6)
716 ? Opc
717 : 0;
718}
719
720void MipsSEInstrInfo::expandRetRA(MachineBasicBlock &MBB,
722
724 if (Subtarget.isGP64bit())
725 MIB = BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn64))
727 else
728 MIB = BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn))
730
731 // Retain any imp-use flags.
732 for (auto & MO : I->operands()) {
733 if (MO.isImplicit())
734 MIB.add(MO);
735 }
736}
737
738void MipsSEInstrInfo::expandERet(MachineBasicBlock &MBB,
740 BuildMI(MBB, I, I->getDebugLoc(), get(Mips::ERET));
741}
742
743std::pair<bool, bool>
744MipsSEInstrInfo::compareOpndSize(unsigned Opc,
745 const MachineFunction &MF) const {
746 const MCInstrDesc &Desc = get(Opc);
747 assert(Desc.NumOperands == 2 && "Unary instruction expected.");
748 const MipsRegisterInfo *RI = &getRegisterInfo();
749 unsigned DstRegSize = RI->getRegSizeInBits(*getRegClass(Desc, 0));
750 unsigned SrcRegSize = RI->getRegSizeInBits(*getRegClass(Desc, 1));
751
752 return std::make_pair(DstRegSize > SrcRegSize, DstRegSize < SrcRegSize);
753}
754
755void MipsSEInstrInfo::expandPseudoMFHiLo(MachineBasicBlock &MBB,
757 unsigned NewOpc) const {
758 BuildMI(MBB, I, I->getDebugLoc(), get(NewOpc), I->getOperand(0).getReg());
759}
760
761void MipsSEInstrInfo::expandPseudoMTLoHi(MachineBasicBlock &MBB,
763 unsigned LoOpc,
764 unsigned HiOpc,
765 bool HasExplicitDef) const {
766 // Expand
767 // lo_hi pseudomtlohi $gpr0, $gpr1
768 // to these two instructions:
769 // mtlo $gpr0
770 // mthi $gpr1
771
772 DebugLoc DL = I->getDebugLoc();
773 const MachineOperand &SrcLo = I->getOperand(1), &SrcHi = I->getOperand(2);
774 MachineInstrBuilder LoInst = BuildMI(MBB, I, DL, get(LoOpc));
775 MachineInstrBuilder HiInst = BuildMI(MBB, I, DL, get(HiOpc));
776
777 // Add lo/hi registers if the mtlo/hi instructions created have explicit
778 // def registers.
779 if (HasExplicitDef) {
780 Register DstReg = I->getOperand(0).getReg();
781 Register DstLo = getRegisterInfo().getSubReg(DstReg, Mips::sub_lo);
782 Register DstHi = getRegisterInfo().getSubReg(DstReg, Mips::sub_hi);
783 LoInst.addReg(DstLo, RegState::Define);
784 HiInst.addReg(DstHi, RegState::Define);
785 }
786
787 LoInst.addReg(SrcLo.getReg(), getKillRegState(SrcLo.isKill()));
788 HiInst.addReg(SrcHi.getReg(), getKillRegState(SrcHi.isKill()));
789}
790
791void MipsSEInstrInfo::expandCvtFPInt(MachineBasicBlock &MBB,
793 unsigned CvtOpc, unsigned MovOpc,
794 bool IsI64) const {
795 const MCInstrDesc &CvtDesc = get(CvtOpc), &MovDesc = get(MovOpc);
796 const MachineOperand &Dst = I->getOperand(0), &Src = I->getOperand(1);
797 unsigned DstReg = Dst.getReg(), SrcReg = Src.getReg(), TmpReg = DstReg;
798 RegState KillSrc = getKillRegState(Src.isKill());
799 DebugLoc DL = I->getDebugLoc();
800 bool DstIsLarger, SrcIsLarger;
801
802 std::tie(DstIsLarger, SrcIsLarger) =
803 compareOpndSize(CvtOpc, *MBB.getParent());
804
805 if (DstIsLarger)
806 TmpReg = getRegisterInfo().getSubReg(DstReg, Mips::sub_lo);
807
808 if (SrcIsLarger)
809 DstReg = getRegisterInfo().getSubReg(DstReg, Mips::sub_lo);
810
811 BuildMI(MBB, I, DL, MovDesc, TmpReg).addReg(SrcReg, KillSrc);
812 BuildMI(MBB, I, DL, CvtDesc, DstReg).addReg(TmpReg, RegState::Kill);
813}
814
815void MipsSEInstrInfo::expandExtractElementF64(MachineBasicBlock &MBB,
817 bool isMicroMips,
818 bool FP64) const {
819 Register DstReg = I->getOperand(0).getReg();
820 Register SrcReg = I->getOperand(1).getReg();
821 unsigned N = I->getOperand(2).getImm();
822 DebugLoc dl = I->getDebugLoc();
823
824 assert(N < 2 && "Invalid immediate");
825 unsigned SubIdx = N ? Mips::sub_hi : Mips::sub_lo;
826 Register SubReg = getRegisterInfo().getSubReg(SrcReg, SubIdx);
827
828 // FPXX/FP64 without MFHC1 should have been handled with a spill/reload
829 // in MipsSEFrameLowering.cpp.
830 assert(!((Subtarget.isABI_FPXX() || FP64) && !Subtarget.hasMTHC1()));
831
832 // FP64A (FP64 with nooddspreg) should have been handled with a spill/reload
833 // in MipsSEFrameLowering.cpp.
834 assert(!(Subtarget.isFP64bit() && !Subtarget.useOddSPReg()));
835
836 if (SubIdx == Mips::sub_hi && Subtarget.hasMTHC1()) {
837 // FIXME: Strictly speaking MFHC1 only reads the top 32-bits however, we
838 // claim to read the whole 64-bits as part of a white lie used to
839 // temporarily work around a widespread bug in the -mfp64 support.
840 // The problem is that none of the 32-bit fpu ops mention the fact
841 // that they clobber the upper 32-bits of the 64-bit FPR. Fixing that
842 // requires a major overhaul of the FPU implementation which can't
843 // be done right now due to time constraints.
844 // MFHC1 is one of two instructions that are affected since they are
845 // the only instructions that don't read the lower 32-bits.
846 // We therefore pretend that it reads the bottom 32-bits to
847 // artificially create a dependency and prevent the scheduler
848 // changing the behaviour of the code.
849 BuildMI(MBB, I, dl,
850 get(isMicroMips ? (FP64 ? Mips::MFHC1_D64_MM : Mips::MFHC1_D32_MM)
851 : (FP64 ? Mips::MFHC1_D64 : Mips::MFHC1_D32)),
852 DstReg)
853 .addReg(SrcReg);
854 } else
855 BuildMI(MBB, I, dl, get(Mips::MFC1), DstReg).addReg(SubReg);
856}
857
858void MipsSEInstrInfo::expandBuildPairF64(MachineBasicBlock &MBB,
860 bool isMicroMips, bool FP64) const {
861 Register DstReg = I->getOperand(0).getReg();
862 unsigned LoReg = I->getOperand(1).getReg(), HiReg = I->getOperand(2).getReg();
863 const MCInstrDesc& Mtc1Tdd = get(Mips::MTC1);
864 DebugLoc dl = I->getDebugLoc();
865 const TargetRegisterInfo &TRI = getRegisterInfo();
866
867 // When mthc1 is available, use:
868 // mtc1 Lo, $fp
869 // mthc1 Hi, $fp
870 //
871 // Otherwise, for FPXX/FP64:
872 // spill + reload via ldc1
873 // This case is handled by the frame lowering code.
874 //
875 // Otherwise, for FP32:
876 // mtc1 Lo, $fp
877 // mtc1 Hi, $fp + 1
878 //
879 // The case where 64-bit GPRs can be used doesn't need to be handled here
880 // because it never creates a BuildPairF64 node.
881
882 // FPXX/FP64 without MTHC1 should have been handled with a spill/reload
883 // in MipsSEFrameLowering.cpp.
884 assert(!((Subtarget.isABI_FPXX() || FP64) && !Subtarget.hasMTHC1()));
885
886 // FP64A (FP64 with nooddspreg) should have been handled with a spill/reload
887 // in MipsSEFrameLowering.cpp.
888 assert(!(Subtarget.isFP64bit() && !Subtarget.useOddSPReg()));
889
890 BuildMI(MBB, I, dl, Mtc1Tdd, TRI.getSubReg(DstReg, Mips::sub_lo))
891 .addReg(LoReg);
892
893 if (Subtarget.hasMTHC1()) {
894 // FIXME: The .addReg(DstReg) is a white lie used to temporarily work
895 // around a widespread bug in the -mfp64 support.
896 // The problem is that none of the 32-bit fpu ops mention the fact
897 // that they clobber the upper 32-bits of the 64-bit FPR. Fixing that
898 // requires a major overhaul of the FPU implementation which can't
899 // be done right now due to time constraints.
900 // MTHC1 is one of two instructions that are affected since they are
901 // the only instructions that don't read the lower 32-bits.
902 // We therefore pretend that it reads the bottom 32-bits to
903 // artificially create a dependency and prevent the scheduler
904 // changing the behaviour of the code.
905 BuildMI(MBB, I, dl,
906 get(isMicroMips ? (FP64 ? Mips::MTHC1_D64_MM : Mips::MTHC1_D32_MM)
907 : (FP64 ? Mips::MTHC1_D64 : Mips::MTHC1_D32)),
908 DstReg)
909 .addReg(DstReg)
910 .addReg(HiReg);
911 } else if (Subtarget.isABI_FPXX())
912 llvm_unreachable("BuildPairF64 not expanded in frame lowering code!");
913 else
914 BuildMI(MBB, I, dl, Mtc1Tdd, TRI.getSubReg(DstReg, Mips::sub_hi))
915 .addReg(HiReg);
916}
917
918void MipsSEInstrInfo::expandEhReturn(MachineBasicBlock &MBB,
920 // This pseudo instruction is generated as part of the lowering of
921 // ISD::EH_RETURN. We convert it to a stack increment by OffsetReg, and
922 // indirect jump to TargetReg
923 MipsABIInfo ABI = Subtarget.getABI();
924 unsigned ADDU = ABI.GetPtrAdduOp();
925 unsigned SP = Subtarget.isGP64bit() ? Mips::SP_64 : Mips::SP;
926 unsigned RA = Subtarget.isGP64bit() ? Mips::RA_64 : Mips::RA;
927 unsigned T9 = ABI.getTempReg(9, Subtarget.isGP64bit());
928 unsigned ZERO = Subtarget.isGP64bit() ? Mips::R0_64 : Mips::R0;
929 Register OffsetReg = I->getOperand(0).getReg();
930 Register TargetReg = I->getOperand(1).getReg();
931
932 // addu $ra, $v0, $zero
933 // addu $sp, $sp, $v1
934 // jr $ra (via RetRA)
935 const TargetMachine &TM = MBB.getParent()->getTarget();
936 if (TM.isPositionIndependent())
937 BuildMI(MBB, I, I->getDebugLoc(), get(ADDU), T9)
938 .addReg(TargetReg)
939 .addReg(ZERO);
940 BuildMI(MBB, I, I->getDebugLoc(), get(ADDU), RA)
941 .addReg(TargetReg)
942 .addReg(ZERO);
943 BuildMI(MBB, I, I->getDebugLoc(), get(ADDU), SP).addReg(SP).addReg(OffsetReg);
944 expandRetRA(MBB, I);
945}
946
948 return new MipsSEInstrInfo(STI);
949}
const AArch64Subtarget & Subtarget
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t Imm
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
@ ZERO
Special weight used for cases with exact zero probability.
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
static bool isORCopyInst(const MachineInstr &MI)
static unsigned getUnconditionalBranch(const MipsSubtarget &STI)
static bool isMicroMips(const MCSubtargetInfo *STI)
uint64_t IntrinsicInst * II
SI optimize exec mask operations pre RA
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:479
A debug info location.
Definition DebugLoc.h:127
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineInstrBundleIterator< MachineInstr > iterator
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
A description of a memory reference used in the backend.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const InstSeq & Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu)
Analyze - Get an instruction sequence to load immediate Imm.
SmallVector< Inst, 7 > InstSeq
const MipsSubtarget & Subtarget
MachineMemOperand * GetMemOperand(MachineBasicBlock &MBB, int FI, MachineMemOperand::Flags Flags) const
bool isZeroImm(const MachineOperand &op) const
MipsInstrInfo(const MipsSubtarget &STI, const MipsRegisterInfo &RI, unsigned UncondBrOpc)
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlot - If the specified machine instruction is a direct load from a stack slot,...
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlot - If the specified machine instruction is a direct store to a stack slot,...
void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
Adjust SP by Amount bytes.
std::optional< DestSourcePair > isCopyInstrImpl(const MachineInstr &MI) const override
If the specific machine instruction is a instruction that moves/copies value from one register to ano...
unsigned loadImmediate(int64_t Imm, MachineBasicBlock &MBB, MachineBasicBlock::iterator II, const DebugLoc &DL, unsigned *NewImm) const
Emit a series of instructions to load an immediate.
bool isBranchWithImm(unsigned Opc) const override
isBranchWithImm - Return true if the branch contains an immediate operand (
MipsSEInstrInfo(const MipsSubtarget &STI)
bool expandPostRAPseudo(MachineInstr &MI) const override
void loadRegFromStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, int64_t Offset, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, int64_t Offset, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
unsigned getOppositeBranchOpc(unsigned Opc) const override
getOppositeBranchOpc - Return the inverse of the specified opcode, e.g.
const MipsSERegisterInfo & getRegisterInfo() const
bool inMicroMipsMode() const
bool isPositionIndependent() const
Wrapper class representing virtual and physical registers.
Definition Register.h:20
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition Register.h:79
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Definition Register.h:83
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
bool isPositionIndependent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr MCPhysReg RA_64
constexpr MCPhysReg SP
constexpr MCPhysReg SP_64
constexpr MCPhysReg RA
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:166
const MipsInstrInfo * createMipsSEInstrInfo(const MipsSubtarget &STI)
RegState
Flags to represent properties of register accesses.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
@ Define
Register definition.
constexpr RegState getKillRegState(bool B)
Op::Description Desc
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
Definition MathExtras.h:572
constexpr RegState getUndefRegState(bool B)
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:881
#define N