blob: ba94cede00d373fbcda988e2f8495a25275e9e0e [file] [log] [blame]
Anton Korobeynikov4403b932009-07-16 13:27:25 +00001//===- 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 Korobeynikov7d1e39b2009-07-16 13:52:51 +000017#include "SystemZ.h"
Anton Korobeynikov4403b932009-07-16 13:27:25 +000018#include "SystemZRegisterInfo.h"
Anton Korobeynikovef5deca2009-07-16 13:51:12 +000019#include "llvm/ADT/IndexedMap.h"
20#include "llvm/Target/TargetInstrInfo.h"
Anton Korobeynikov4403b932009-07-16 13:27:25 +000021
22namespace llvm {
23
24class SystemZTargetMachine;
25
Anton Korobeynikov6fe326c2009-07-16 14:16:05 +000026/// SystemZII - This namespace holds all of the target specific flags that
27/// instruction info tracks.
28///
29namespace 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 Korobeynikov4403b932009-07-16 13:27:25 +000050class SystemZInstrInfo : public TargetInstrInfoImpl {
51 const SystemZRegisterInfo RI;
52 SystemZTargetMachine &TM;
Anton Korobeynikovef5deca2009-07-16 13:51:12 +000053 IndexedMap<unsigned> RegSpillOffsets;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000054public:
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 Korobeynikov656ac6f2009-07-16 13:51:53 +000061 virtual const SystemZRegisterInfo &getRegisterInfo() const { return RI; }
Anton Korobeynikov4403b932009-07-16 13:27:25 +000062
63 bool copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
64 unsigned DestReg, unsigned SrcReg,
65 const TargetRegisterClass *DestRC,
66 const TargetRegisterClass *SrcRC) const;
67
68 bool isMoveInstr(const MachineInstr& MI,
69 unsigned &SrcReg, unsigned &DstReg,
70 unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
Anton Korobeynikov27bf6772009-07-16 14:32:41 +000071 unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const;
72 unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const;
Anton Korobeynikovf1106c42009-07-16 14:33:01 +000073 bool isInvariantLoad(const MachineInstr *MI) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000074
75 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
76 MachineBasicBlock::iterator MI,
77 unsigned SrcReg, bool isKill,
78 int FrameIndex,
79 const TargetRegisterClass *RC) const;
80 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
81 MachineBasicBlock::iterator MI,
82 unsigned DestReg, int FrameIdx,
83 const TargetRegisterClass *RC) const;
84
85 virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
86 MachineBasicBlock::iterator MI,
87 const std::vector<CalleeSavedInfo> &CSI) const;
88 virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
89 MachineBasicBlock::iterator MI,
90 const std::vector<CalleeSavedInfo> &CSI) const;
91
Anton Korobeynikovae46db82009-07-16 14:32:19 +000092 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
93 virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
94 virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
95 virtual bool AnalyzeBranch(MachineBasicBlock &MBB,
96 MachineBasicBlock *&TBB,
97 MachineBasicBlock *&FBB,
98 SmallVectorImpl<MachineOperand> &Cond,
99 bool AllowModify) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000100 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
101 MachineBasicBlock *FBB,
102 const SmallVectorImpl<MachineOperand> &Cond) const;
Anton Korobeynikovae46db82009-07-16 14:32:19 +0000103 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000104
Anton Korobeynikovae46db82009-07-16 14:32:19 +0000105 SystemZCC::CondCodes getOppositeCondition(SystemZCC::CondCodes CC) const;
106 SystemZCC::CondCodes getCondFromBranchOpc(unsigned Opc) const;
Anton Korobeynikov7d1e39b2009-07-16 13:52:51 +0000107 const TargetInstrDesc& getBrCond(SystemZCC::CondCodes CC) const;
Anton Korobeynikov5a11e022009-07-16 14:09:56 +0000108 const TargetInstrDesc& getLongDispOpc(unsigned Opc) const;
Anton Korobeynikov9de28482009-07-16 14:33:52 +0000109
110 const TargetInstrDesc& getMemoryInstr(unsigned Opc, int64_t Offset = 0) const {
111 if (Offset < 0 || Offset >= 4096)
112 return getLongDispOpc(Opc);
113 else
114 return get(Opc);
115 }
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000116};
117
118}
119
120#endif