blob: 9df3ee5c7358e57b798896a9e382eb81add5c124 [file] [log] [blame]
Chris Lattner7c90f732006-02-05 05:50:24 +00001//===- SparcInstrInfo.h - Sparc Instruction Information ---------*- C++ -*-===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Brian Gaekee785e532004-02-25 19:28:19 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanb5f662f2005-04-21 23:30:14 +00007//
Brian Gaekee785e532004-02-25 19:28:19 +00008//===----------------------------------------------------------------------===//
9//
Chris Lattner7c90f732006-02-05 05:50:24 +000010// This file contains the Sparc implementation of the TargetInstrInfo class.
Brian Gaekee785e532004-02-25 19:28:19 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattner7c90f732006-02-05 05:50:24 +000014#ifndef SPARCINSTRUCTIONINFO_H
15#define SPARCINSTRUCTIONINFO_H
Brian Gaekee785e532004-02-25 19:28:19 +000016
17#include "llvm/Target/TargetInstrInfo.h"
Chris Lattner7c90f732006-02-05 05:50:24 +000018#include "SparcRegisterInfo.h"
Brian Gaekee785e532004-02-25 19:28:19 +000019
20namespace llvm {
21
Chris Lattner7c90f732006-02-05 05:50:24 +000022/// SPII - This namespace holds all of the target specific flags that
Brian Gaeke7d7ac632004-07-16 10:31:59 +000023/// instruction info tracks.
24///
Chris Lattner7c90f732006-02-05 05:50:24 +000025namespace SPII {
Brian Gaeke7d7ac632004-07-16 10:31:59 +000026 enum {
27 Pseudo = (1<<0),
28 Load = (1<<1),
29 Store = (1<<2),
30 DelaySlot = (1<<3)
31 };
Chris Lattnerd74ea2b2006-05-24 17:04:05 +000032}
Brian Gaeke7d7ac632004-07-16 10:31:59 +000033
Chris Lattner64105522008-01-01 01:03:04 +000034class SparcInstrInfo : public TargetInstrInfoImpl {
Chris Lattner7c90f732006-02-05 05:50:24 +000035 const SparcRegisterInfo RI;
Owen Andersond10fd972007-12-31 06:32:00 +000036 const SparcSubtarget& Subtarget;
Brian Gaekee785e532004-02-25 19:28:19 +000037public:
Dan Gohman950a4c42008-03-25 22:06:05 +000038 explicit SparcInstrInfo(SparcSubtarget &ST);
Brian Gaekee785e532004-02-25 19:28:19 +000039
40 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
41 /// such, whenever a client has an instance of instruction info, it should
42 /// always be able to get register info as well (through this method).
43 ///
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000044 virtual const SparcRegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattner1d6dc972004-07-25 06:19:04 +000045
Evan Cheng04ee5a12009-01-20 19:12:24 +000046 /// Return true if the instruction is a register to register move and return
47 /// the source and dest operands and their sub-register indices by reference.
Chris Lattner1d6dc972004-07-25 06:19:04 +000048 virtual bool isMoveInstr(const MachineInstr &MI,
Evan Cheng04ee5a12009-01-20 19:12:24 +000049 unsigned &SrcReg, unsigned &DstReg,
50 unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
Chris Lattner5ccc7222006-02-03 06:44:54 +000051
52 /// isLoadFromStackSlot - If the specified machine instruction is a direct
53 /// load from a stack slot, return the virtual or physical register number of
54 /// the destination along with the FrameIndex of the loaded stack slot. If
55 /// not, return 0. This predicate must return 0 if the instruction has
56 /// any side effects other than loading from the stack slot.
Dan Gohmancbad42c2008-11-18 19:49:32 +000057 virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
58 int &FrameIndex) const;
Chris Lattner5ccc7222006-02-03 06:44:54 +000059
60 /// isStoreToStackSlot - If the specified machine instruction is a direct
61 /// store to a stack slot, return the virtual or physical register number of
62 /// the source reg along with the FrameIndex of the loaded stack slot. If
63 /// not, return 0. This predicate must return 0 if the instruction has
64 /// any side effects other than storing to the stack slot.
Dan Gohmancbad42c2008-11-18 19:49:32 +000065 virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
66 int &FrameIndex) const;
Chris Lattnere87146a2006-10-24 16:39:19 +000067
68
Evan Cheng6ae36262007-05-18 00:18:17 +000069 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
70 MachineBasicBlock *FBB,
Stuart Hastings3bf91252010-06-17 22:43:56 +000071 const SmallVectorImpl<MachineOperand> &Cond,
72 DebugLoc DL) const;
Owen Andersond10fd972007-12-31 06:32:00 +000073
Owen Anderson940f83e2008-08-26 18:03:31 +000074 virtual bool copyRegToReg(MachineBasicBlock &MBB,
Owen Andersond10fd972007-12-31 06:32:00 +000075 MachineBasicBlock::iterator I,
76 unsigned DestReg, unsigned SrcReg,
77 const TargetRegisterClass *DestRC,
Dan Gohman34dcc6f2010-05-06 20:33:48 +000078 const TargetRegisterClass *SrcRC,
79 DebugLoc DL) const;
Owen Andersonf6372aa2008-01-01 21:11:32 +000080
81 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
82 MachineBasicBlock::iterator MBBI,
83 unsigned SrcReg, bool isKill, int FrameIndex,
Evan Cheng746ad692010-05-06 19:06:44 +000084 const TargetRegisterClass *RC,
85 const TargetRegisterInfo *TRI) const;
Owen Andersonf6372aa2008-01-01 21:11:32 +000086
Owen Andersonf6372aa2008-01-01 21:11:32 +000087 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
88 MachineBasicBlock::iterator MBBI,
89 unsigned DestReg, int FrameIndex,
Evan Cheng746ad692010-05-06 19:06:44 +000090 const TargetRegisterClass *RC,
91 const TargetRegisterInfo *TRI) const;
Owen Anderson43dbe052008-01-07 01:35:02 +000092
Dan Gohmanc54baa22008-12-03 18:43:12 +000093 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
94 MachineInstr* MI,
95 const SmallVectorImpl<unsigned> &Ops,
96 int FrameIndex) const;
Owen Anderson43dbe052008-01-07 01:35:02 +000097
Dan Gohmanc54baa22008-12-03 18:43:12 +000098 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
99 MachineInstr* MI,
100 const SmallVectorImpl<unsigned> &Ops,
101 MachineInstr* LoadMI) const {
Owen Anderson43dbe052008-01-07 01:35:02 +0000102 return 0;
103 }
Chris Lattnerdb486a62009-09-15 17:46:24 +0000104
105 unsigned getGlobalBaseReg(MachineFunction *MF) const;
Brian Gaekee785e532004-02-25 19:28:19 +0000106};
107
108}
109
110#endif