Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 1 | //===- SystemZInstrInfo.h - SystemZ 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 SystemZ implementation of the TargetInstrInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_TARGET_SYSTEMZINSTRINFO_H |
| 15 | #define LLVM_TARGET_SYSTEMZINSTRINFO_H |
| 16 | |
Anton Korobeynikov | 7d1e39b | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 17 | #include "SystemZ.h" |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 18 | #include "SystemZRegisterInfo.h" |
Anton Korobeynikov | ef5deca | 2009-07-16 13:51:12 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/IndexedMap.h" |
| 20 | #include "llvm/Target/TargetInstrInfo.h" |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 21 | |
Evan Cheng | 4db3cff | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 22 | #define GET_INSTRINFO_HEADER |
| 23 | #include "SystemZGenInstrInfo.inc" |
| 24 | |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 25 | namespace llvm { |
| 26 | |
| 27 | class SystemZTargetMachine; |
| 28 | |
Anton Korobeynikov | 6fe326c | 2009-07-16 14:16:05 +0000 | [diff] [blame] | 29 | /// SystemZII - This namespace holds all of the target specific flags that |
| 30 | /// instruction info tracks. |
| 31 | /// |
| 32 | namespace SystemZII { |
| 33 | enum { |
| 34 | //===------------------------------------------------------------------===// |
| 35 | // SystemZ Specific MachineOperand flags. |
| 36 | |
| 37 | MO_NO_FLAG = 0, |
| 38 | |
| 39 | /// MO_GOTENT - On a symbol operand this indicates that the immediate is |
| 40 | /// the offset to the location of the symbol name from the base of the GOT. |
| 41 | /// |
| 42 | /// SYMBOL_LABEL @GOTENT |
| 43 | MO_GOTENT = 1, |
| 44 | |
| 45 | /// MO_PLT - On a symbol operand this indicates that the immediate is |
| 46 | /// offset to the PLT entry of symbol name from the current code location. |
| 47 | /// |
| 48 | /// SYMBOL_LABEL @PLT |
| 49 | MO_PLT = 2 |
| 50 | }; |
| 51 | } |
| 52 | |
Evan Cheng | 4db3cff | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 53 | class SystemZInstrInfo : public SystemZGenInstrInfo { |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 54 | const SystemZRegisterInfo RI; |
| 55 | SystemZTargetMachine &TM; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 56 | public: |
| 57 | explicit SystemZInstrInfo(SystemZTargetMachine &TM); |
| 58 | |
| 59 | /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As |
| 60 | /// such, whenever a client has an instance of instruction info, it should |
| 61 | /// always be able to get register info as well (through this method). |
| 62 | /// |
Anton Korobeynikov | 656ac6f | 2009-07-16 13:51:53 +0000 | [diff] [blame] | 63 | virtual const SystemZRegisterInfo &getRegisterInfo() const { return RI; } |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 64 | |
Jakob Stoklund Olesen | f7d55b9 | 2010-07-11 16:40:46 +0000 | [diff] [blame] | 65 | virtual void copyPhysReg(MachineBasicBlock &MBB, |
| 66 | MachineBasicBlock::iterator I, DebugLoc DL, |
| 67 | unsigned DestReg, unsigned SrcReg, |
| 68 | bool KillSrc) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 69 | |
Anton Korobeynikov | 27bf677 | 2009-07-16 14:32:41 +0000 | [diff] [blame] | 70 | unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; |
| 71 | unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 72 | |
| 73 | virtual void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 74 | MachineBasicBlock::iterator MI, |
| 75 | unsigned SrcReg, bool isKill, |
| 76 | int FrameIndex, |
Evan Cheng | 746ad69 | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 77 | const TargetRegisterClass *RC, |
| 78 | const TargetRegisterInfo *TRI) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 79 | virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 80 | MachineBasicBlock::iterator MI, |
| 81 | unsigned DestReg, int FrameIdx, |
Evan Cheng | 746ad69 | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 82 | const TargetRegisterClass *RC, |
| 83 | const TargetRegisterInfo *TRI) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 84 | |
Anton Korobeynikov | ae46db8 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 85 | bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; |
Anton Korobeynikov | ae46db8 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 86 | virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const; |
| 87 | virtual bool AnalyzeBranch(MachineBasicBlock &MBB, |
| 88 | MachineBasicBlock *&TBB, |
| 89 | MachineBasicBlock *&FBB, |
| 90 | SmallVectorImpl<MachineOperand> &Cond, |
| 91 | bool AllowModify) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 92 | virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
| 93 | MachineBasicBlock *FBB, |
Stuart Hastings | 3bf9125 | 2010-06-17 22:43:56 +0000 | [diff] [blame] | 94 | const SmallVectorImpl<MachineOperand> &Cond, |
| 95 | DebugLoc DL) const; |
Anton Korobeynikov | ae46db8 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 96 | virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 97 | |
Anton Korobeynikov | ae46db8 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 98 | SystemZCC::CondCodes getOppositeCondition(SystemZCC::CondCodes CC) const; |
| 99 | SystemZCC::CondCodes getCondFromBranchOpc(unsigned Opc) const; |
Evan Cheng | e837dea | 2011-06-28 19:10:37 +0000 | [diff] [blame] | 100 | const MCInstrDesc& getBrCond(SystemZCC::CondCodes CC) const; |
| 101 | const MCInstrDesc& getLongDispOpc(unsigned Opc) const; |
Anton Korobeynikov | 9de2848 | 2009-07-16 14:33:52 +0000 | [diff] [blame] | 102 | |
Evan Cheng | e837dea | 2011-06-28 19:10:37 +0000 | [diff] [blame] | 103 | const MCInstrDesc& getMemoryInstr(unsigned Opc, int64_t Offset = 0) const { |
Anton Korobeynikov | 9de2848 | 2009-07-16 14:33:52 +0000 | [diff] [blame] | 104 | if (Offset < 0 || Offset >= 4096) |
| 105 | return getLongDispOpc(Opc); |
| 106 | else |
| 107 | return get(Opc); |
| 108 | } |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | } |
| 112 | |
| 113 | #endif |