blob: a39c21e43611f892477dae2d48fd716c528cda00 [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 Korobeynikov4403b932009-07-16 13:27:25 +000053public:
54 explicit SystemZInstrInfo(SystemZTargetMachine &TM);
55
56 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
57 /// such, whenever a client has an instance of instruction info, it should
58 /// always be able to get register info as well (through this method).
59 ///
Anton Korobeynikov656ac6f2009-07-16 13:51:53 +000060 virtual const SystemZRegisterInfo &getRegisterInfo() const { return RI; }
Anton Korobeynikov4403b932009-07-16 13:27:25 +000061
Jakob Stoklund Olesenf7d55b92010-07-11 16:40:46 +000062 virtual void copyPhysReg(MachineBasicBlock &MBB,
63 MachineBasicBlock::iterator I, DebugLoc DL,
64 unsigned DestReg, unsigned SrcReg,
65 bool KillSrc) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000066
Anton Korobeynikov27bf6772009-07-16 14:32:41 +000067 unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const;
68 unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000069
70 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
71 MachineBasicBlock::iterator MI,
72 unsigned SrcReg, bool isKill,
73 int FrameIndex,
Evan Cheng746ad692010-05-06 19:06:44 +000074 const TargetRegisterClass *RC,
75 const TargetRegisterInfo *TRI) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000076 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
77 MachineBasicBlock::iterator MI,
78 unsigned DestReg, int FrameIdx,
Evan Cheng746ad692010-05-06 19:06:44 +000079 const TargetRegisterClass *RC,
80 const TargetRegisterInfo *TRI) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000081
Anton Korobeynikovae46db82009-07-16 14:32:19 +000082 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
Anton Korobeynikovae46db82009-07-16 14:32:19 +000083 virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
84 virtual bool AnalyzeBranch(MachineBasicBlock &MBB,
85 MachineBasicBlock *&TBB,
86 MachineBasicBlock *&FBB,
87 SmallVectorImpl<MachineOperand> &Cond,
88 bool AllowModify) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000089 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
90 MachineBasicBlock *FBB,
Stuart Hastings3bf91252010-06-17 22:43:56 +000091 const SmallVectorImpl<MachineOperand> &Cond,
92 DebugLoc DL) const;
Anton Korobeynikovae46db82009-07-16 14:32:19 +000093 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
Anton Korobeynikov4403b932009-07-16 13:27:25 +000094
Anton Korobeynikovae46db82009-07-16 14:32:19 +000095 SystemZCC::CondCodes getOppositeCondition(SystemZCC::CondCodes CC) const;
96 SystemZCC::CondCodes getCondFromBranchOpc(unsigned Opc) const;
Evan Chenge837dea2011-06-28 19:10:37 +000097 const MCInstrDesc& getBrCond(SystemZCC::CondCodes CC) const;
98 const MCInstrDesc& getLongDispOpc(unsigned Opc) const;
Anton Korobeynikov9de28482009-07-16 14:33:52 +000099
Evan Chenge837dea2011-06-28 19:10:37 +0000100 const MCInstrDesc& getMemoryInstr(unsigned Opc, int64_t Offset = 0) const {
Anton Korobeynikov9de28482009-07-16 14:33:52 +0000101 if (Offset < 0 || Offset >= 4096)
102 return getLongDispOpc(Opc);
103 else
104 return get(Opc);
105 }
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000106};
107
108}
109
110#endif