| Anton Korobeynikov | c334c28 | 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 | 0f59e1e | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 17 | #include "SystemZ.h" | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 18 | #include "SystemZRegisterInfo.h" | 
| Anton Korobeynikov | 8695a30 | 2009-07-16 13:51:12 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/IndexedMap.h" | 
|  | 20 | #include "llvm/Target/TargetInstrInfo.h" | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 21 |  | 
|  | 22 | namespace llvm { | 
|  | 23 |  | 
|  | 24 | class SystemZTargetMachine; | 
|  | 25 |  | 
| Anton Korobeynikov | 091872cb | 2009-07-16 14:16:05 +0000 | [diff] [blame] | 26 | /// SystemZII - This namespace holds all of the target specific flags that | 
|  | 27 | /// instruction info tracks. | 
|  | 28 | /// | 
|  | 29 | namespace SystemZII { | 
|  | 30 | enum { | 
|  | 31 | //===------------------------------------------------------------------===// | 
|  | 32 | // SystemZ Specific MachineOperand flags. | 
|  | 33 |  | 
|  | 34 | MO_NO_FLAG = 0, | 
|  | 35 |  | 
|  | 36 | /// MO_GOTENT - On a symbol operand this indicates that the immediate is | 
|  | 37 | /// the offset to the location of the symbol name from the base of the GOT. | 
|  | 38 | /// | 
|  | 39 | ///    SYMBOL_LABEL @GOTENT | 
|  | 40 | MO_GOTENT = 1, | 
|  | 41 |  | 
|  | 42 | /// MO_PLT - On a symbol operand this indicates that the immediate is | 
|  | 43 | /// offset to the PLT entry of symbol name from the current code location. | 
|  | 44 | /// | 
|  | 45 | ///    SYMBOL_LABEL @PLT | 
|  | 46 | MO_PLT = 2 | 
|  | 47 | }; | 
|  | 48 | } | 
|  | 49 |  | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 50 | class SystemZInstrInfo : public TargetInstrInfoImpl { | 
|  | 51 | const SystemZRegisterInfo RI; | 
|  | 52 | SystemZTargetMachine &TM; | 
| Anton Korobeynikov | 8695a30 | 2009-07-16 13:51:12 +0000 | [diff] [blame] | 53 | IndexedMap<unsigned> RegSpillOffsets; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 54 | public: | 
|  | 55 | explicit SystemZInstrInfo(SystemZTargetMachine &TM); | 
|  | 56 |  | 
|  | 57 | /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As | 
|  | 58 | /// such, whenever a client has an instance of instruction info, it should | 
|  | 59 | /// always be able to get register info as well (through this method). | 
|  | 60 | /// | 
| Anton Korobeynikov | 29329a0 | 2009-07-16 13:51:53 +0000 | [diff] [blame] | 61 | virtual const SystemZRegisterInfo &getRegisterInfo() const { return RI; } | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 62 |  | 
|  | 63 | bool copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, | 
|  | 64 | unsigned DestReg, unsigned SrcReg, | 
|  | 65 | const TargetRegisterClass *DestRC, | 
| Dan Gohman | 779c69b | 2010-05-06 20:33:48 +0000 | [diff] [blame] | 66 | const TargetRegisterClass *SrcRC, | 
|  | 67 | DebugLoc DL) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 68 |  | 
|  | 69 | bool isMoveInstr(const MachineInstr& MI, | 
|  | 70 | unsigned &SrcReg, unsigned &DstReg, | 
|  | 71 | unsigned &SrcSubIdx, unsigned &DstSubIdx) const; | 
| Anton Korobeynikov | 5761e33 | 2009-07-16 14:32:41 +0000 | [diff] [blame] | 72 | unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; | 
|  | 73 | unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 74 |  | 
|  | 75 | virtual void storeRegToStackSlot(MachineBasicBlock &MBB, | 
|  | 76 | MachineBasicBlock::iterator MI, | 
|  | 77 | unsigned SrcReg, bool isKill, | 
|  | 78 | int FrameIndex, | 
| Evan Cheng | efb126a | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 79 | const TargetRegisterClass *RC, | 
|  | 80 | const TargetRegisterInfo *TRI) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 81 | virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, | 
|  | 82 | MachineBasicBlock::iterator MI, | 
|  | 83 | unsigned DestReg, int FrameIdx, | 
| Evan Cheng | efb126a | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 84 | const TargetRegisterClass *RC, | 
|  | 85 | const TargetRegisterInfo *TRI) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 86 |  | 
|  | 87 | virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, | 
|  | 88 | MachineBasicBlock::iterator MI, | 
| Evan Cheng | 168ced9 | 2010-05-22 01:47:14 +0000 | [diff] [blame^] | 89 | const std::vector<CalleeSavedInfo> &CSI, | 
|  | 90 | const TargetRegisterInfo *TRI) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 91 | virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, | 
|  | 92 | MachineBasicBlock::iterator MI, | 
| Evan Cheng | 168ced9 | 2010-05-22 01:47:14 +0000 | [diff] [blame^] | 93 | const std::vector<CalleeSavedInfo> &CSI, | 
|  | 94 | const TargetRegisterInfo *TRI) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 95 |  | 
| Anton Korobeynikov | b22afc7 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 96 | bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; | 
| Anton Korobeynikov | b22afc7 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 97 | virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const; | 
|  | 98 | virtual bool AnalyzeBranch(MachineBasicBlock &MBB, | 
|  | 99 | MachineBasicBlock *&TBB, | 
|  | 100 | MachineBasicBlock *&FBB, | 
|  | 101 | SmallVectorImpl<MachineOperand> &Cond, | 
|  | 102 | bool AllowModify) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 103 | virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, | 
|  | 104 | MachineBasicBlock *FBB, | 
|  | 105 | const SmallVectorImpl<MachineOperand> &Cond) const; | 
| Anton Korobeynikov | b22afc7 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 106 | virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 107 |  | 
| Anton Korobeynikov | b22afc7 | 2009-07-16 14:32:19 +0000 | [diff] [blame] | 108 | SystemZCC::CondCodes getOppositeCondition(SystemZCC::CondCodes CC) const; | 
|  | 109 | SystemZCC::CondCodes getCondFromBranchOpc(unsigned Opc) const; | 
| Anton Korobeynikov | 0f59e1e | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 110 | const TargetInstrDesc& getBrCond(SystemZCC::CondCodes CC) const; | 
| Anton Korobeynikov | 3db6283 | 2009-07-16 14:09:56 +0000 | [diff] [blame] | 111 | const TargetInstrDesc& getLongDispOpc(unsigned Opc) const; | 
| Anton Korobeynikov | 7fa0ce1 | 2009-07-16 14:33:52 +0000 | [diff] [blame] | 112 |  | 
|  | 113 | const TargetInstrDesc& getMemoryInstr(unsigned Opc, int64_t Offset = 0) const { | 
|  | 114 | if (Offset < 0 || Offset >= 4096) | 
|  | 115 | return getLongDispOpc(Opc); | 
|  | 116 | else | 
|  | 117 | return get(Opc); | 
|  | 118 | } | 
| Anton Korobeynikov | c334c28 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 119 | }; | 
|  | 120 |  | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 | #endif |