blob: b2d2301b3d21ae4fd917df5ccf14f37d45fe4670 [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 Hatanakab7fa3c92012-07-31 21:49:49 +000024 bool IsN64;
Akira Hatanakacb37e132012-07-31 23:41:32 +000025
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000026public:
Eric Christopher675cb4d2014-07-18 23:25:00 +000027 explicit MipsSEInstrInfo(const MipsSubtarget &STI);
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000028
Craig Topper56c590a2014-04-29 07:58:02 +000029 const MipsRegisterInfo &getRegisterInfo() const override;
Akira Hatanakacb37e132012-07-31 23:41:32 +000030
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000031 /// isLoadFromStackSlot - If the specified machine instruction is a direct
32 /// load from a stack slot, return the virtual or physical register number of
33 /// the destination along with the FrameIndex of the loaded stack slot. If
34 /// not, return 0. This predicate must return 0 if the instruction has
35 /// any side effects other than loading from the stack slot.
Craig Topper56c590a2014-04-29 07:58:02 +000036 unsigned isLoadFromStackSlot(const MachineInstr *MI,
37 int &FrameIndex) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000038
39 /// isStoreToStackSlot - If the specified machine instruction is a direct
40 /// store to a stack slot, return the virtual or physical register number of
41 /// the source reg along with the FrameIndex of the loaded stack slot. If
42 /// not, return 0. This predicate must return 0 if the instruction has
43 /// any side effects other than storing to the stack slot.
Craig Topper56c590a2014-04-29 07:58:02 +000044 unsigned isStoreToStackSlot(const MachineInstr *MI,
45 int &FrameIndex) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000046
Craig Topper56c590a2014-04-29 07:58:02 +000047 void copyPhysReg(MachineBasicBlock &MBB,
48 MachineBasicBlock::iterator MI, DebugLoc DL,
49 unsigned DestReg, unsigned SrcReg,
50 bool KillSrc) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000051
Craig Topper56c590a2014-04-29 07:58:02 +000052 void storeRegToStack(MachineBasicBlock &MBB,
53 MachineBasicBlock::iterator MI,
54 unsigned SrcReg, bool isKill, int FrameIndex,
55 const TargetRegisterClass *RC,
56 const TargetRegisterInfo *TRI,
57 int64_t Offset) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000058
Craig Topper56c590a2014-04-29 07:58:02 +000059 void loadRegFromStack(MachineBasicBlock &MBB,
60 MachineBasicBlock::iterator MI,
61 unsigned DestReg, int FrameIndex,
62 const TargetRegisterClass *RC,
63 const TargetRegisterInfo *TRI,
64 int64_t Offset) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000065
Craig Topper56c590a2014-04-29 07:58:02 +000066 bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000067
Craig Topper56c590a2014-04-29 07:58:02 +000068 unsigned getOppositeBranchOpc(unsigned Opc) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000069
Akira Hatanaka88d76cf2012-07-31 23:52:55 +000070 /// Adjust SP by Amount bytes.
71 void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,
72 MachineBasicBlock::iterator I) const;
73
Akira Hatanakabf493942012-08-23 00:21:05 +000074 /// Emit a series of instructions to load an immediate. If NewImm is a
75 /// non-NULL parameter, the last instruction is not emitted, but instead
76 /// its immediate operand is returned in NewImm.
77 unsigned loadImmediate(int64_t Imm, MachineBasicBlock &MBB,
78 MachineBasicBlock::iterator II, DebugLoc DL,
79 unsigned *NewImm) const;
80
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000081private:
Craig Topper56c590a2014-04-29 07:58:02 +000082 unsigned getAnalyzableBrOpc(unsigned Opc) const override;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000083
Daniel Sanders338513b2014-07-09 10:16:07 +000084 void expandRetRA(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const;
Akira Hatanakafce4dd72013-05-16 19:57:23 +000085
Akira Hatanaka4be04b12013-06-11 18:48:16 +000086 std::pair<bool, bool> compareOpndSize(unsigned Opc,
87 const MachineFunction &MF) const;
Akira Hatanakaae9d8e22013-06-08 00:14:54 +000088
Akira Hatanaka16048332013-10-07 18:49:46 +000089 void expandPseudoMFHiLo(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
90 unsigned NewOpc) const;
91
Akira Hatanaka06aff572013-10-15 01:48:30 +000092 void expandPseudoMTLoHi(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
93 unsigned LoOpc, unsigned HiOpc,
94 bool HasExplicitDef) const;
95
Akira Hatanakafce4dd72013-05-16 19:57:23 +000096 /// Expand pseudo Int-to-FP conversion instructions.
97 ///
98 /// For example, the following pseudo instruction
99 /// PseudoCVT_D32_W D2, A5
100 /// gets expanded into these two instructions:
101 /// MTC1 F4, A5
102 /// CVT_D32_W D2, F4
103 ///
104 /// We do this expansion post-RA to avoid inserting a floating point copy
105 /// instruction between MTC1 and CVT_D32_W.
Akira Hatanaka39d40f72013-05-16 19:48:37 +0000106 void expandCvtFPInt(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
Akira Hatanakaae9d8e22013-06-08 00:14:54 +0000107 unsigned CvtOpc, unsigned MovOpc, bool IsI64) const;
Akira Hatanakafce4dd72013-05-16 19:57:23 +0000108
Akira Hatanaka067d8152013-05-13 17:43:19 +0000109 void expandExtractElementF64(MachineBasicBlock &MBB,
Akira Hatanaka9a1fb6b2013-08-20 23:47:25 +0000110 MachineBasicBlock::iterator I, bool FP64) const;
Akira Hatanaka067d8152013-05-13 17:43:19 +0000111 void expandBuildPairF64(MachineBasicBlock &MBB,
Akira Hatanaka9a1fb6b2013-08-20 23:47:25 +0000112 MachineBasicBlock::iterator I, bool FP64) const;
Akira Hatanaka067d8152013-05-13 17:43:19 +0000113 void expandEhReturn(MachineBasicBlock &MBB,
Akira Hatanakac0b02062013-01-30 00:26:49 +0000114 MachineBasicBlock::iterator I) const;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +0000115};
116
117}
118
119#endif