blob: 250142daf6c489472c70fe241dd8687829c0a431 [file] [log] [blame]
Sanjiv Gupta09bb4202008-05-13 09:02:57 +00001//===- PIC16InstrInfo.h - PIC16 Instruction Information----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the niversity of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the PIC16 implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef PIC16INSTRUCTIONINFO_H
15#define PIC16INSTRUCTIONINFO_H
16
17#include "PIC16.h"
18#include "PIC16RegisterInfo.h"
19#include "llvm/Target/TargetInstrInfo.h"
20
21namespace llvm {
22
23
24class PIC16InstrInfo : public TargetInstrInfoImpl
25{
26 PIC16TargetMachine &TM;
27 const PIC16RegisterInfo RI;
28public:
29 explicit PIC16InstrInfo(PIC16TargetMachine &TM);
30
31 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
32 /// such, whenever a client has an instance of instruction info, it should
33 /// always be able to get register info as well (through this method).
34 ///
Dan Gohmanb41dfba2008-05-14 01:58:56 +000035 virtual const PIC16RegisterInfo &getRegisterInfo() const { return RI; }
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000036
37
38 /// isLoadFromStackSlot - If the specified machine instruction is a direct
39 /// load from a stack slot, return the virtual or physical register number of
40 /// the destination along with the FrameIndex of the loaded stack slot. If
41 /// not, return 0. This predicate must return 0 if the instruction has
42 /// any side effects other than loading from the stack slot.
Dan Gohman90feee22008-11-18 19:49:32 +000043 virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
44 int &FrameIndex) const;
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000045
46 /// isStoreToStackSlot - If the specified machine instruction is a direct
47 /// store to a stack slot, return the virtual or physical register number of
48 /// the source reg along with the FrameIndex of the loaded stack slot. If
49 /// not, return 0. This predicate must return 0 if the instruction has
50 /// any side effects other than storing to the stack slot.
Dan Gohman90feee22008-11-18 19:49:32 +000051 virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
52 int &FrameIndex) const;
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000053
54 /// Used for spilling a register
55 void storeRegToStackSlot(MachineBasicBlock &MBB,
56 MachineBasicBlock::iterator MI,
57 unsigned SrcReg, bool isKill, int FrameIndex,
58 const TargetRegisterClass *RC) const;
59
60
61 void loadRegFromStackSlot(MachineBasicBlock &MBB,
62 MachineBasicBlock::iterator MI,
63 unsigned DestReg, int FrameIndex,
64 const TargetRegisterClass *RC) const;
65
66 /// InsertBranch - Insert a branch into the end of the specified
67 /// MachineBasicBlock. This operands to this method are the same as those
68 /// returned by AnalyzeBranch. This is invoked in cases where AnalyzeBranch
69 /// returns success and when an unconditional branch (TBB is non-null, FBB is
70 /// null, Cond is empty) needs to be inserted. It returns the number of
71 /// instructions inserted.
72 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
73 MachineBasicBlock *FBB,
Owen Andersond131b5b2008-08-14 22:49:33 +000074 const SmallVectorImpl<MachineOperand> &Cond) const ;
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000075
76};
77
78} // namespace llvm
79
80#endif