Jia Liu | bb481f8 | 2012-02-28 07:46:26 +0000 | [diff] [blame] | 1 | //===-- MipsInstrInfo.h - Mips Instruction Information ----------*- C++ -*-===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file contains the Mips implementation of the TargetInstrInfo class. |
| 11 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 13 | |
| 14 | #ifndef MIPSINSTRUCTIONINFO_H |
| 15 | #define MIPSINSTRUCTIONINFO_H |
| 16 | |
| 17 | #include "Mips.h" |
Craig Topper | 79aa341 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 18 | #include "MipsRegisterInfo.h" |
Torok Edwin | c25e758 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 19 | #include "llvm/Support/ErrorHandling.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetInstrInfo.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 21 | |
Evan Cheng | 4db3cff | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 22 | #define GET_INSTRINFO_HEADER |
| 23 | #include "MipsGenInstrInfo.inc" |
| 24 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 25 | namespace llvm { |
| 26 | |
Bruno Cardoso Lopes | 0b2cd89 | 2007-08-18 01:59:45 +0000 | [diff] [blame] | 27 | namespace Mips { |
Akira Hatanaka | 20ada98 | 2011-04-01 17:39:08 +0000 | [diff] [blame] | 28 | /// GetOppositeBranchOpc - Return the inverse of the specified |
| 29 | /// opcode, e.g. turning BEQ to BNE. |
| 30 | unsigned GetOppositeBranchOpc(unsigned Opc); |
Bruno Cardoso Lopes | 0b2cd89 | 2007-08-18 01:59:45 +0000 | [diff] [blame] | 31 | } |
| 32 | |
Evan Cheng | 4db3cff | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 33 | class MipsInstrInfo : public MipsGenInstrInfo { |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 34 | MipsTargetMachine &TM; |
Akira Hatanaka | 43aed32 | 2011-10-11 00:37:28 +0000 | [diff] [blame] | 35 | bool IsN64; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 36 | const MipsRegisterInfo RI; |
Akira Hatanaka | 6e55ff5 | 2011-12-12 22:39:35 +0000 | [diff] [blame] | 37 | unsigned UncondBrOpc; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 38 | public: |
Dan Gohman | 950a4c4 | 2008-03-25 22:06:05 +0000 | [diff] [blame] | 39 | explicit MipsInstrInfo(MipsTargetMachine &TM); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 40 | |
| 41 | /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As |
| 42 | /// such, whenever a client has an instance of instruction info, it should |
| 43 | /// always be able to get register info as well (through this method). |
| 44 | /// |
Akira Hatanaka | 794bf17 | 2011-07-07 23:56:50 +0000 | [diff] [blame] | 45 | virtual const MipsRegisterInfo &getRegisterInfo() const; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 46 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 47 | /// isLoadFromStackSlot - If the specified machine instruction is a direct |
| 48 | /// load from a stack slot, return the virtual or physical register number of |
| 49 | /// the destination along with the FrameIndex of the loaded stack slot. If |
| 50 | /// not, return 0. This predicate must return 0 if the instruction has |
| 51 | /// any side effects other than loading from the stack slot. |
Dan Gohman | cbad42c | 2008-11-18 19:49:32 +0000 | [diff] [blame] | 52 | virtual unsigned isLoadFromStackSlot(const MachineInstr *MI, |
| 53 | int &FrameIndex) const; |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 54 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 55 | /// isStoreToStackSlot - If the specified machine instruction is a direct |
| 56 | /// store to a stack slot, return the virtual or physical register number of |
| 57 | /// the source reg along with the FrameIndex of the loaded stack slot. If |
| 58 | /// not, return 0. This predicate must return 0 if the instruction has |
| 59 | /// any side effects other than storing to the stack slot. |
Dan Gohman | cbad42c | 2008-11-18 19:49:32 +0000 | [diff] [blame] | 60 | virtual unsigned isStoreToStackSlot(const MachineInstr *MI, |
| 61 | int &FrameIndex) const; |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 62 | |
Bruno Cardoso Lopes | 0b2cd89 | 2007-08-18 01:59:45 +0000 | [diff] [blame] | 63 | /// Branch Analysis |
| 64 | virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, |
| 65 | MachineBasicBlock *&FBB, |
Evan Cheng | dc54d31 | 2009-02-09 07:14:22 +0000 | [diff] [blame] | 66 | SmallVectorImpl<MachineOperand> &Cond, |
| 67 | bool AllowModify) const; |
Bruno Cardoso Lopes | 0b2cd89 | 2007-08-18 01:59:45 +0000 | [diff] [blame] | 68 | virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; |
Akira Hatanaka | 20ada98 | 2011-04-01 17:39:08 +0000 | [diff] [blame] | 69 | |
| 70 | private: |
| 71 | void BuildCondBr(MachineBasicBlock &MBB, MachineBasicBlock *TBB, DebugLoc DL, |
| 72 | const SmallVectorImpl<MachineOperand>& Cond) const; |
| 73 | |
| 74 | public: |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 75 | virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
Bruno Cardoso Lopes | 0b2cd89 | 2007-08-18 01:59:45 +0000 | [diff] [blame] | 76 | MachineBasicBlock *FBB, |
Stuart Hastings | 3bf9125 | 2010-06-17 22:43:56 +0000 | [diff] [blame] | 77 | const SmallVectorImpl<MachineOperand> &Cond, |
| 78 | DebugLoc DL) const; |
Jakob Stoklund Olesen | 273c14f | 2010-07-11 01:08:31 +0000 | [diff] [blame] | 79 | virtual void copyPhysReg(MachineBasicBlock &MBB, |
| 80 | MachineBasicBlock::iterator MI, DebugLoc DL, |
| 81 | unsigned DestReg, unsigned SrcReg, |
| 82 | bool KillSrc) const; |
Owen Anderson | f6372aa | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 83 | virtual void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 84 | MachineBasicBlock::iterator MBBI, |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 85 | unsigned SrcReg, bool isKill, int FrameIndex, |
Evan Cheng | 746ad69 | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 86 | const TargetRegisterClass *RC, |
| 87 | const TargetRegisterInfo *TRI) const; |
Owen Anderson | f6372aa | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 88 | |
Owen Anderson | f6372aa | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 89 | virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 90 | MachineBasicBlock::iterator MBBI, |
| 91 | unsigned DestReg, int FrameIndex, |
Evan Cheng | 746ad69 | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 92 | const TargetRegisterClass *RC, |
| 93 | const TargetRegisterInfo *TRI) const; |
Owen Anderson | f6372aa | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 94 | |
Akira Hatanaka | c4f24eb | 2011-07-01 01:04:43 +0000 | [diff] [blame] | 95 | virtual MachineInstr* emitFrameIndexDebugValue(MachineFunction &MF, |
| 96 | int FrameIx, uint64_t Offset, |
| 97 | const MDNode *MDPtr, |
| 98 | DebugLoc DL) const; |
| 99 | |
Owen Anderson | 44eb65c | 2008-08-14 22:49:33 +0000 | [diff] [blame] | 100 | virtual |
| 101 | bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; |
Bruno Cardoso Lopes | 0b2cd89 | 2007-08-18 01:59:45 +0000 | [diff] [blame] | 102 | |
| 103 | /// Insert nop instruction when hazard condition is found |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 104 | virtual void insertNoop(MachineBasicBlock &MBB, |
Bruno Cardoso Lopes | 0b2cd89 | 2007-08-18 01:59:45 +0000 | [diff] [blame] | 105 | MachineBasicBlock::iterator MI) const; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | } |
| 109 | |
| 110 | #endif |