1 //===- MSP430InstrInfo.h - MSP430 Instruction Information -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the MSP430 implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_MSP430INSTRINFO_H
15 #define LLVM_TARGET_MSP430INSTRINFO_H
17 #include "llvm/Target/TargetInstrInfo.h"
18 #include "MSP430RegisterInfo.h"
22 class MSP430TargetMachine
;
24 /// MSP430II - This namespace holds all of the target specific flags that
25 /// instruction info tracks.
30 SizeMask
= 7 << SizeShift
,
32 SizeUnknown
= 0 << SizeShift
,
33 SizeSpecial
= 1 << SizeShift
,
34 Size2Bytes
= 2 << SizeShift
,
35 Size4Bytes
= 3 << SizeShift
,
36 Size6Bytes
= 4 << SizeShift
40 class MSP430InstrInfo
: public TargetInstrInfoImpl
{
41 const MSP430RegisterInfo RI
;
42 MSP430TargetMachine
&TM
;
44 explicit MSP430InstrInfo(MSP430TargetMachine
&TM
);
46 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
47 /// such, whenever a client has an instance of instruction info, it should
48 /// always be able to get register info as well (through this method).
50 virtual const TargetRegisterInfo
&getRegisterInfo() const { return RI
; }
52 void copyPhysReg(MachineBasicBlock
&MBB
,
53 MachineBasicBlock::iterator I
, DebugLoc DL
,
54 unsigned DestReg
, unsigned SrcReg
,
57 virtual void storeRegToStackSlot(MachineBasicBlock
&MBB
,
58 MachineBasicBlock::iterator MI
,
59 unsigned SrcReg
, bool isKill
,
61 const TargetRegisterClass
*RC
,
62 const TargetRegisterInfo
*TRI
) const;
63 virtual void loadRegFromStackSlot(MachineBasicBlock
&MBB
,
64 MachineBasicBlock::iterator MI
,
65 unsigned DestReg
, int FrameIdx
,
66 const TargetRegisterClass
*RC
,
67 const TargetRegisterInfo
*TRI
) const;
69 virtual bool spillCalleeSavedRegisters(MachineBasicBlock
&MBB
,
70 MachineBasicBlock::iterator MI
,
71 const std::vector
<CalleeSavedInfo
> &CSI
,
72 const TargetRegisterInfo
*TRI
) const;
73 virtual bool restoreCalleeSavedRegisters(MachineBasicBlock
&MBB
,
74 MachineBasicBlock::iterator MI
,
75 const std::vector
<CalleeSavedInfo
> &CSI
,
76 const TargetRegisterInfo
*TRI
) const;
78 unsigned GetInstSizeInBytes(const MachineInstr
*MI
) const;
80 // Branch folding goodness
81 bool ReverseBranchCondition(SmallVectorImpl
<MachineOperand
> &Cond
) const;
82 bool isUnpredicatedTerminator(const MachineInstr
*MI
) const;
83 bool AnalyzeBranch(MachineBasicBlock
&MBB
,
84 MachineBasicBlock
*&TBB
, MachineBasicBlock
*&FBB
,
85 SmallVectorImpl
<MachineOperand
> &Cond
,
86 bool AllowModify
) const;
88 unsigned RemoveBranch(MachineBasicBlock
&MBB
) const;
89 unsigned InsertBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*TBB
,
90 MachineBasicBlock
*FBB
,
91 const SmallVectorImpl
<MachineOperand
> &Cond
,