Jacques Pienaar | fcef3e4 | 2016-03-28 13:09:54 +0000 | [diff] [blame] | 1 | //===- LanaiInstrInfo.h - Lanai 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 Lanai implementation of the TargetInstrInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H |
| 15 | #define LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H |
| 16 | |
| 17 | #include "LanaiRegisterInfo.h" |
| 18 | #include "llvm/Target/TargetInstrInfo.h" |
| 19 | |
| 20 | #define GET_INSTRINFO_HEADER |
| 21 | #include "LanaiGenInstrInfo.inc" |
| 22 | |
| 23 | namespace llvm { |
| 24 | |
| 25 | class LanaiInstrInfo : public LanaiGenInstrInfo { |
| 26 | const LanaiRegisterInfo RegisterInfo; |
| 27 | |
| 28 | public: |
| 29 | LanaiInstrInfo(); |
| 30 | |
| 31 | // getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As |
| 32 | // such, whenever a client has an instance of instruction info, it should |
| 33 | // always be able to get register info as well (through this method). |
| 34 | virtual const LanaiRegisterInfo &getRegisterInfo() const { |
| 35 | return RegisterInfo; |
| 36 | } |
| 37 | |
Jacques Pienaar | add4a27 | 2016-04-14 16:47:42 +0000 | [diff] [blame] | 38 | bool areMemAccessesTriviallyDisjoint(MachineInstr *MIa, MachineInstr *MIb, |
| 39 | AliasAnalysis *AA) const override; |
| 40 | |
Jacques Pienaar | fcef3e4 | 2016-03-28 13:09:54 +0000 | [diff] [blame] | 41 | unsigned isLoadFromStackSlot(const MachineInstr *MI, |
| 42 | int &FrameIndex) const override; |
| 43 | |
| 44 | unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI, |
| 45 | int &FrameIndex) const override; |
| 46 | |
| 47 | unsigned isStoreToStackSlot(const MachineInstr *MI, |
| 48 | int &FrameIndex) const override; |
| 49 | |
| 50 | void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position, |
| 51 | DebugLoc DL, unsigned DestinationRegister, |
| 52 | unsigned SourceRegister, bool KillSource) const override; |
| 53 | |
| 54 | void |
| 55 | storeRegToStackSlot(MachineBasicBlock &MBB, |
| 56 | MachineBasicBlock::iterator Position, |
| 57 | unsigned SourceRegister, bool IsKill, int FrameIndex, |
| 58 | const TargetRegisterClass *RegisterClass, |
| 59 | const TargetRegisterInfo *RegisterInfo) const override; |
| 60 | |
| 61 | void |
| 62 | loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 63 | MachineBasicBlock::iterator Position, |
| 64 | unsigned DestinationRegister, int FrameIndex, |
| 65 | const TargetRegisterClass *RegisterClass, |
| 66 | const TargetRegisterInfo *RegisterInfo) const override; |
| 67 | |
| 68 | bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override; |
| 69 | |
Jacques Pienaar | add4a27 | 2016-04-14 16:47:42 +0000 | [diff] [blame] | 70 | bool getMemOpBaseRegImmOfs(MachineInstr *LdSt, unsigned &BaseReg, |
| 71 | int64_t &Offset, |
| 72 | const TargetRegisterInfo *TRI) const override; |
| 73 | |
| 74 | bool getMemOpBaseRegImmOfsWidth(MachineInstr *LdSt, unsigned &BaseReg, |
| 75 | int64_t &Offset, unsigned &Width, |
| 76 | const TargetRegisterInfo *TRI) const; |
| 77 | |
Jacques Pienaar | fcef3e4 | 2016-03-28 13:09:54 +0000 | [diff] [blame] | 78 | bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TrueBlock, |
| 79 | MachineBasicBlock *&FalseBlock, |
| 80 | SmallVectorImpl<MachineOperand> &Condition, |
| 81 | bool AllowModify) const override; |
| 82 | |
| 83 | unsigned RemoveBranch(MachineBasicBlock &MBB) const override; |
| 84 | |
| 85 | bool ReverseBranchCondition( |
| 86 | SmallVectorImpl<MachineOperand> &Condition) const override; |
| 87 | |
| 88 | unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TrueBlock, |
| 89 | MachineBasicBlock *FalseBlock, |
| 90 | ArrayRef<MachineOperand> Condition, |
| 91 | DebugLoc DL) const override; |
| 92 | }; |
| 93 | |
| 94 | static inline bool isSPLSOpcode(unsigned Opcode) { |
| 95 | switch (Opcode) { |
| 96 | case Lanai::LDBs_RI: |
| 97 | case Lanai::LDBz_RI: |
| 98 | case Lanai::LDHs_RI: |
| 99 | case Lanai::LDHz_RI: |
| 100 | case Lanai::STB_RI: |
| 101 | case Lanai::STH_RI: |
| 102 | return true; |
| 103 | default: |
| 104 | return false; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | static inline bool isRMOpcode(unsigned Opcode) { |
| 109 | switch (Opcode) { |
| 110 | case Lanai::LDW_RI: |
| 111 | case Lanai::SW_RI: |
| 112 | return true; |
| 113 | default: |
| 114 | return false; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | static inline bool isRRMOpcode(unsigned Opcode) { |
| 119 | switch (Opcode) { |
| 120 | case Lanai::LDBs_RR: |
| 121 | case Lanai::LDBz_RR: |
| 122 | case Lanai::LDHs_RR: |
| 123 | case Lanai::LDHz_RR: |
| 124 | case Lanai::LDWz_RR: |
| 125 | case Lanai::LDW_RR: |
| 126 | case Lanai::STB_RR: |
| 127 | case Lanai::STH_RR: |
| 128 | case Lanai::SW_RR: |
| 129 | return true; |
| 130 | default: |
| 131 | return false; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | } // namespace llvm |
| 136 | |
| 137 | #endif // LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H |