blob: 345674bacf37eb9ff5bb22e108bd5229c702b3f6 [file] [log] [blame]
Chris Lattner158e1f52006-02-05 05:50:24 +00001//===- SparcInstrInfo.h - Sparc Instruction Information ---------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner158e1f52006-02-05 05:50:24 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the Sparc implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef SPARCINSTRUCTIONINFO_H
15#define SPARCINSTRUCTIONINFO_H
16
17#include "llvm/Target/TargetInstrInfo.h"
18#include "SparcRegisterInfo.h"
19
20namespace llvm {
21
22/// SPII - This namespace holds all of the target specific flags that
23/// instruction info tracks.
24///
25namespace SPII {
26 enum {
27 Pseudo = (1<<0),
28 Load = (1<<1),
29 Store = (1<<2),
30 DelaySlot = (1<<3)
31 };
Chris Lattneraa2372562006-05-24 17:04:05 +000032}
Chris Lattner158e1f52006-02-05 05:50:24 +000033
Chris Lattner25568e42008-01-01 01:03:04 +000034class SparcInstrInfo : public TargetInstrInfoImpl {
Chris Lattner158e1f52006-02-05 05:50:24 +000035 const SparcRegisterInfo RI;
Owen Anderson7a73ae92007-12-31 06:32:00 +000036 const SparcSubtarget& Subtarget;
Chris Lattner158e1f52006-02-05 05:50:24 +000037public:
Dan Gohmanc60c67f2008-03-25 22:06:05 +000038 explicit SparcInstrInfo(SparcSubtarget &ST);
Chris Lattner158e1f52006-02-05 05:50:24 +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 Gohmaneabd6472008-05-14 01:58:56 +000044 virtual const SparcRegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattner158e1f52006-02-05 05:50:24 +000045
Evan Chengc544cb02009-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 Lattner158e1f52006-02-05 05:50:24 +000048 virtual bool isMoveInstr(const MachineInstr &MI,
Evan Chengc544cb02009-01-20 19:12:24 +000049 unsigned &SrcReg, unsigned &DstReg,
50 unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
Chris Lattner158e1f52006-02-05 05:50:24 +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 Gohman0b273252008-11-18 19:49:32 +000057 virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
58 int &FrameIndex) const;
Chris Lattner158e1f52006-02-05 05:50:24 +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 Gohman0b273252008-11-18 19:49:32 +000065 virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
66 int &FrameIndex) const;
Chris Lattnerb7267bd2006-10-24 16:39:19 +000067
68
Evan Chenge20dd922007-05-18 00:18:17 +000069 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
70 MachineBasicBlock *FBB,
Owen Anderson4f6bf042008-08-14 22:49:33 +000071 const SmallVectorImpl<MachineOperand> &Cond) const;
Owen Anderson7a73ae92007-12-31 06:32:00 +000072
Owen Anderson27fb3dc2008-08-26 18:03:31 +000073 virtual bool copyRegToReg(MachineBasicBlock &MBB,
Owen Anderson7a73ae92007-12-31 06:32:00 +000074 MachineBasicBlock::iterator I,
75 unsigned DestReg, unsigned SrcReg,
76 const TargetRegisterClass *DestRC,
77 const TargetRegisterClass *SrcRC) const;
Owen Andersoneee14602008-01-01 21:11:32 +000078
79 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
80 MachineBasicBlock::iterator MBBI,
81 unsigned SrcReg, bool isKill, int FrameIndex,
82 const TargetRegisterClass *RC) const;
83
Owen Andersoneee14602008-01-01 21:11:32 +000084 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
85 MachineBasicBlock::iterator MBBI,
86 unsigned DestReg, int FrameIndex,
87 const TargetRegisterClass *RC) const;
Owen Anderson2a3be7b2008-01-07 01:35:02 +000088
Dan Gohman3f86b512008-12-03 18:43:12 +000089 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
90 MachineInstr* MI,
91 const SmallVectorImpl<unsigned> &Ops,
92 int FrameIndex) const;
Owen Anderson2a3be7b2008-01-07 01:35:02 +000093
Dan Gohman3f86b512008-12-03 18:43:12 +000094 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
95 MachineInstr* MI,
96 const SmallVectorImpl<unsigned> &Ops,
97 MachineInstr* LoadMI) const {
Owen Anderson2a3be7b2008-01-07 01:35:02 +000098 return 0;
99 }
Chris Lattner840c7002009-09-15 17:46:24 +0000100
101 unsigned getGlobalBaseReg(MachineFunction *MF) const;
Chris Lattner158e1f52006-02-05 05:50:24 +0000102};
103
104}
105
106#endif