blob: f4c29b1676aa8d090b973082c3630c53605569de [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
14#ifndef MIPSSEINSTRUCTIONINFO_H
15#define MIPSSEINSTRUCTIONINFO_H
16
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:
27 explicit MipsSEInstrInfo(MipsTargetMachine &TM);
28
Akira Hatanakacb37e132012-07-31 23:41:32 +000029 virtual const MipsRegisterInfo &getRegisterInfo() const;
30
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.
36 virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
37 int &FrameIndex) const;
38
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.
44 virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
45 int &FrameIndex) const;
46
47 virtual void copyPhysReg(MachineBasicBlock &MBB,
48 MachineBasicBlock::iterator MI, DebugLoc DL,
49 unsigned DestReg, unsigned SrcReg,
50 bool KillSrc) const;
51
Akira Hatanaka465facca2013-03-29 02:14:12 +000052 virtual 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;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000058
Akira Hatanaka465facca2013-03-29 02:14:12 +000059 virtual 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;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000065
66 virtual bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const;
67
Akira Hatanaka067d8152013-05-13 17:43:19 +000068 virtual unsigned getOppositeBranchOpc(unsigned Opc) const;
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:
Akira Hatanaka067d8152013-05-13 17:43:19 +000082 virtual unsigned getAnalyzableBrOpc(unsigned Opc) const;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000083
Akira Hatanaka067d8152013-05-13 17:43:19 +000084 void expandRetRA(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000085 unsigned Opc) const;
Akira Hatanaka39d40f72013-05-16 19:48:37 +000086 void expandCvtFPInt(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
87 unsigned CvtOpc, unsigned MovOpc, bool DstIsLarger,
88 bool SrcIsLarger, bool IsI64) const;
Akira Hatanaka067d8152013-05-13 17:43:19 +000089 void expandExtractElementF64(MachineBasicBlock &MBB,
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000090 MachineBasicBlock::iterator I) const;
Akira Hatanaka067d8152013-05-13 17:43:19 +000091 void expandBuildPairF64(MachineBasicBlock &MBB,
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000092 MachineBasicBlock::iterator I) const;
Akira Hatanaka9edae022013-05-13 18:23:35 +000093 void expandDPLoadStore(MachineBasicBlock &MBB,
94 MachineBasicBlock::iterator I, unsigned OpcD,
95 unsigned OpcS) const;
Akira Hatanaka067d8152013-05-13 17:43:19 +000096 void expandEhReturn(MachineBasicBlock &MBB,
Akira Hatanakac0b02062013-01-30 00:26:49 +000097 MachineBasicBlock::iterator I) const;
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000098};
99
100}
101
102#endif