LLVM API Documentation

SystemZInstrInfo.h

Go to the documentation of this file.
00001 //===- SystemZInstrInfo.h - SystemZ Instruction Information -------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the SystemZ implementation of the TargetInstrInfo class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_TARGET_SYSTEMZINSTRINFO_H
00015 #define LLVM_TARGET_SYSTEMZINSTRINFO_H
00016 
00017 #include "SystemZ.h"
00018 #include "SystemZRegisterInfo.h"
00019 #include "llvm/ADT/IndexedMap.h"
00020 #include "llvm/Target/TargetInstrInfo.h"
00021 
00022 namespace llvm {
00023 
00024 class SystemZTargetMachine;
00025 
00026 /// SystemZII - This namespace holds all of the target specific flags that
00027 /// instruction info tracks.
00028 ///
00029 namespace SystemZII {
00030   enum {
00031     //===------------------------------------------------------------------===//
00032     // SystemZ Specific MachineOperand flags.
00033 
00034     MO_NO_FLAG = 0,
00035 
00036     /// MO_GOTENT - On a symbol operand this indicates that the immediate is
00037     /// the offset to the location of the symbol name from the base of the GOT.
00038     ///
00039     ///    SYMBOL_LABEL @GOTENT
00040     MO_GOTENT = 1,
00041 
00042     /// MO_PLT - On a symbol operand this indicates that the immediate is
00043     /// offset to the PLT entry of symbol name from the current code location.
00044     ///
00045     ///    SYMBOL_LABEL @PLT
00046     MO_PLT = 2
00047   };
00048 }
00049 
00050 class SystemZInstrInfo : public TargetInstrInfoImpl {
00051   const SystemZRegisterInfo RI;
00052   SystemZTargetMachine &TM;
00053   IndexedMap<unsigned> RegSpillOffsets;
00054 public:
00055   explicit SystemZInstrInfo(SystemZTargetMachine &TM);
00056 
00057   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
00058   /// such, whenever a client has an instance of instruction info, it should
00059   /// always be able to get register info as well (through this method).
00060   ///
00061   virtual const SystemZRegisterInfo &getRegisterInfo() const { return RI; }
00062 
00063   bool copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
00064                     unsigned DestReg, unsigned SrcReg,
00065                     const TargetRegisterClass *DestRC,
00066                     const TargetRegisterClass *SrcRC) const;
00067 
00068   bool isMoveInstr(const MachineInstr& MI,
00069                    unsigned &SrcReg, unsigned &DstReg,
00070                    unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
00071   unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const;
00072   unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const;
00073   bool isInvariantLoad(const MachineInstr *MI) const;
00074 
00075   virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
00076                                    MachineBasicBlock::iterator MI,
00077                                    unsigned SrcReg, bool isKill,
00078                                    int FrameIndex,
00079                                    const TargetRegisterClass *RC) const;
00080   virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
00081                                     MachineBasicBlock::iterator MI,
00082                                     unsigned DestReg, int FrameIdx,
00083                                     const TargetRegisterClass *RC) const;
00084 
00085   virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
00086                                          MachineBasicBlock::iterator MI,
00087                                  const std::vector<CalleeSavedInfo> &CSI) const;
00088   virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
00089                                            MachineBasicBlock::iterator MI,
00090                                  const std::vector<CalleeSavedInfo> &CSI) const;
00091 
00092   bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
00093   virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
00094   virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
00095   virtual bool AnalyzeBranch(MachineBasicBlock &MBB,
00096                              MachineBasicBlock *&TBB,
00097                              MachineBasicBlock *&FBB,
00098                              SmallVectorImpl<MachineOperand> &Cond,
00099                              bool AllowModify) const;
00100   virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
00101                                 MachineBasicBlock *FBB,
00102                              const SmallVectorImpl<MachineOperand> &Cond) const;
00103   virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
00104 
00105   SystemZCC::CondCodes getOppositeCondition(SystemZCC::CondCodes CC) const;
00106   SystemZCC::CondCodes getCondFromBranchOpc(unsigned Opc) const;
00107   const TargetInstrDesc& getBrCond(SystemZCC::CondCodes CC) const;
00108   const TargetInstrDesc& getLongDispOpc(unsigned Opc) const;
00109 
00110   const TargetInstrDesc& getMemoryInstr(unsigned Opc, int64_t Offset = 0) const {
00111     if (Offset < 0 || Offset >= 4096)
00112       return getLongDispOpc(Opc);
00113     else
00114       return get(Opc);
00115   }
00116 };
00117 
00118 }
00119 
00120 #endif