blob: 2fc2afee9a59147f359581131d47c7cee72fab07 [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//===- MipsInstrInfo.h - Mips Instruction Information -----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the Mips implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MIPSINSTRUCTIONINFO_H
15#define MIPSINSTRUCTIONINFO_H
16
17#include "Mips.h"
18#include "llvm/Target/TargetInstrInfo.h"
19#include "MipsRegisterInfo.h"
20
21namespace llvm {
22
Bruno Cardoso Lopes0b2cd892007-08-18 01:59:45 +000023namespace Mips {
24
Bruno Cardoso Lopesdc0c04c2007-08-28 05:06:17 +000025 // Mips Condition Codes
Bruno Cardoso Lopes0b2cd892007-08-18 01:59:45 +000026 enum CondCode {
27 COND_E,
28 COND_GZ,
29 COND_GEZ,
30 COND_LZ,
31 COND_LEZ,
32 COND_NE,
33 COND_INVALID
34 };
35
36 // Turn condition code into conditional branch opcode.
37 unsigned GetCondBranchFromCond(CondCode CC);
38
39 /// GetOppositeBranchCondition - Return the inverse of the specified cond,
40 /// e.g. turning COND_E to COND_NE.
41 CondCode GetOppositeBranchCondition(Mips::CondCode CC);
42
43}
44
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000045class MipsInstrInfo : public TargetInstrInfo
46{
47 MipsTargetMachine &TM;
48 const MipsRegisterInfo RI;
49public:
50 MipsInstrInfo(MipsTargetMachine &TM);
51
52 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
53 /// such, whenever a client has an instance of instruction info, it should
54 /// always be able to get register info as well (through this method).
55 ///
56 virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
57
58 /// Return true if the instruction is a register to register move and
59 /// leave the source and dest operands in the passed parameters.
60 ///
61 virtual bool isMoveInstr(const MachineInstr &MI,
62 unsigned &SrcReg, unsigned &DstReg) const;
63
64 /// isLoadFromStackSlot - If the specified machine instruction is a direct
65 /// load from a stack slot, return the virtual or physical register number of
66 /// the destination along with the FrameIndex of the loaded stack slot. If
67 /// not, return 0. This predicate must return 0 if the instruction has
68 /// any side effects other than loading from the stack slot.
69 virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
70
71 /// isStoreToStackSlot - If the specified machine instruction is a direct
72 /// store to a stack slot, return the virtual or physical register number of
73 /// the source reg along with the FrameIndex of the loaded stack slot. If
74 /// not, return 0. This predicate must return 0 if the instruction has
75 /// any side effects other than storing to the stack slot.
76 virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
Bruno Cardoso Lopes0b2cd892007-08-18 01:59:45 +000077
78 /// Branch Analysis
79 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
80 MachineBasicBlock *&FBB,
81 std::vector<MachineOperand> &Cond) const;
82 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000083 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Bruno Cardoso Lopes0b2cd892007-08-18 01:59:45 +000084 MachineBasicBlock *FBB,
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000085 const std::vector<MachineOperand> &Cond) const;
Bruno Cardoso Lopes0b2cd892007-08-18 01:59:45 +000086 virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const;
87 virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const;
88
89 /// Insert nop instruction when hazard condition is found
90 virtual void insertNoop(MachineBasicBlock &MBB,
91 MachineBasicBlock::iterator MI) const;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000092};
93
94}
95
96#endif