blob: fc55716d598acdbe11ac3037f57ffbbde00adf02 [file] [log] [blame]
Akira Hatanakab7fa3c92012-07-31 21:49:49 +00001//===-- MipsSEInstrInfo.h - Mips32/64 Instruction Information ---*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the Mips32/64 implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_MIPS_MIPSSEINSTRINFO_H
15#define LLVM_LIB_TARGET_MIPS_MIPSSEINSTRINFO_H
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000016
17#include "MipsInstrInfo.h"
Akira Hatanakacb37e132012-07-31 23:41:32 +000018#include "MipsSERegisterInfo.h"
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000019
20namespace llvm {
21
22class MipsSEInstrInfo : public MipsInstrInfo {
Akira Hatanakacb37e132012-07-31 23:41:32 +000023 const MipsSERegisterInfo RI;
Akira Hatanakacb37e132012-07-31 23:41:32 +000024
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000025public:
Eric Christopher675cb4d2014-07-18 23:25:00 +000026 explicit MipsSEInstrInfo(const MipsSubtarget &STI);
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000027
Craig Topper56c590a2014-04-29 07:58:02 +000028 const MipsRegisterInfo &getRegisterInfo() const override;
Akira Hatanakacb37e132012-07-31 23:41:32 +000029
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000030 /// isLoadFromStackSlot - If the specified machine instruction is a direct
31 /// load from a stack slot, return the virtual or physical register number of
32 /// the destination along with the FrameIndex of the loaded stack slot. If
33 /// not, return 0. This predicate must return 0 if the instruction has
34 /// any side effects other than loading from the stack slot.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000035 unsigned isLoadFromStackSlot(const MachineInstr &MI,
Craig Topper56c590a2014-04-29 07:58:02 +000036 int &FrameIndex) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000037
38 /// isStoreToStackSlot - If the specified machine instruction is a direct
39 /// store to a stack slot, return the virtual or physical register number of
40 /// the source reg along with the FrameIndex of the loaded stack slot. If
41 /// not, return 0. This predicate must return 0 if the instruction has
42 /// any side effects other than storing to the stack slot.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000043 unsigned isStoreToStackSlot(const MachineInstr &MI,
Craig Topper56c590a2014-04-29 07:58:02 +000044 int &FrameIndex) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000045
Benjamin Kramerbdc49562016-06-12 15:39:02 +000046 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
47 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
Craig Topper56c590a2014-04-29 07:58:02 +000048 bool KillSrc) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000049
Petar Jovanovic8cb6a522018-06-06 16:36:30 +000050 bool isCopyInstr(const MachineInstr &MI, const MachineOperand *&Src,
51 const MachineOperand *&Dest) const override;
Petar Jovanovicc0510002018-05-23 15:28:28 +000052
Craig Topper56c590a2014-04-29 07:58:02 +000053 void storeRegToStack(MachineBasicBlock &MBB,
54 MachineBasicBlock::iterator MI,
55 unsigned SrcReg, bool isKill, int FrameIndex,
56 const TargetRegisterClass *RC,
57 const TargetRegisterInfo *TRI,
58 int64_t Offset) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000059
Craig Topper56c590a2014-04-29 07:58:02 +000060 void loadRegFromStack(MachineBasicBlock &MBB,
61 MachineBasicBlock::iterator MI,
62 unsigned DestReg, int FrameIndex,
63 const TargetRegisterClass *RC,
64 const TargetRegisterInfo *TRI,
65 int64_t Offset) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000066
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000067 bool expandPostRAPseudo(MachineInstr &MI) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000068
Craig Topper56c590a2014-04-29 07:58:02 +000069 unsigned getOppositeBranchOpc(unsigned Opc) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000070
Akira Hatanaka88d76cf2012-07-31 23:52:55 +000071 /// Adjust SP by Amount bytes.
72 void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,
Vasileios Kalintiris6d687782015-04-02 10:42:44 +000073 MachineBasicBlock::iterator I) const override;
Akira Hatanaka88d76cf2012-07-31 23:52:55 +000074
Akira Hatanakabf493942012-08-23 00:21:05 +000075 /// Emit a series of instructions to load an immediate. If NewImm is a
76 /// non-NULL parameter, the last instruction is not emitted, but instead
77 /// its immediate operand is returned in NewImm.
78 unsigned loadImmediate(int64_t Imm, MachineBasicBlock &MBB,
Benjamin Kramerbdc49562016-06-12 15:39:02 +000079 MachineBasicBlock::iterator II, const DebugLoc &DL,
Akira Hatanakabf493942012-08-23 00:21:05 +000080 unsigned *NewImm) const;
81
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000082private:
Craig Topper56c590a2014-04-29 07:58:02 +000083 unsigned getAnalyzableBrOpc(unsigned Opc) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000084
Daniel Sanders338513b2014-07-09 10:16:07 +000085 void expandRetRA(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const;
Akira Hatanakafce4dd72013-05-16 19:57:23 +000086
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +000087 void expandERet(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const;
88
Akira Hatanaka4be04b12013-06-11 18:48:16 +000089 std::pair<bool, bool> compareOpndSize(unsigned Opc,
90 const MachineFunction &MF) const;
Akira Hatanakaae9d8e22013-06-08 00:14:54 +000091
Akira Hatanaka16048332013-10-07 18:49:46 +000092 void expandPseudoMFHiLo(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
93 unsigned NewOpc) const;
94
Akira Hatanaka06aff572013-10-15 01:48:30 +000095 void expandPseudoMTLoHi(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
96 unsigned LoOpc, unsigned HiOpc,
97 bool HasExplicitDef) const;
98
Akira Hatanakafce4dd72013-05-16 19:57:23 +000099 /// Expand pseudo Int-to-FP conversion instructions.
100 ///
101 /// For example, the following pseudo instruction
102 /// PseudoCVT_D32_W D2, A5
103 /// gets expanded into these two instructions:
104 /// MTC1 F4, A5
105 /// CVT_D32_W D2, F4
106 ///
107 /// We do this expansion post-RA to avoid inserting a floating point copy
108 /// instruction between MTC1 and CVT_D32_W.
Akira Hatanaka39d40f72013-05-16 19:48:37 +0000109 void expandCvtFPInt(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
Akira Hatanakaae9d8e22013-06-08 00:14:54 +0000110 unsigned CvtOpc, unsigned MovOpc, bool IsI64) const;
Akira Hatanakafce4dd72013-05-16 19:57:23 +0000111
Akira Hatanaka067d8152013-05-13 17:43:19 +0000112 void expandExtractElementF64(MachineBasicBlock &MBB,
Stefan Maksimovicb3e7ed32018-02-08 09:25:17 +0000113 MachineBasicBlock::iterator I, bool isMicroMips,
114 bool FP64) const;
Akira Hatanaka067d8152013-05-13 17:43:19 +0000115 void expandBuildPairF64(MachineBasicBlock &MBB,
Stefan Maksimovicb3e7ed32018-02-08 09:25:17 +0000116 MachineBasicBlock::iterator I, bool isMicroMips,
117 bool FP64) const;
Akira Hatanaka067d8152013-05-13 17:43:19 +0000118 void expandEhReturn(MachineBasicBlock &MBB,
Akira Hatanakac0b02062013-01-30 00:26:49 +0000119 MachineBasicBlock::iterator I) const;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +0000120};
121
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000122}
Akira Hatanakab7fa3c92012-07-31 21:49:49 +0000123
124#endif