blob: 842b4cb06e41499437f1813470bb7a4aa68727f9 [file] [log] [blame]
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +00001//===- MSP430InstrInfo.h - MSP430 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 MSP430 implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TARGET_MSP430INSTRINFO_H
15#define LLVM_TARGET_MSP430INSTRINFO_H
16
17#include "llvm/Target/TargetInstrInfo.h"
18#include "MSP430RegisterInfo.h"
19
20namespace llvm {
21
22class MSP430TargetMachine;
23
Anton Korobeynikov702adab2010-01-15 21:19:05 +000024/// MSP430II - This namespace holds all of the target specific flags that
25/// instruction info tracks.
26///
27namespace MSP430II {
28 enum {
29 SizeShift = 2,
30 SizeMask = 7 << SizeShift,
31
32 SizeUnknown = 0 << SizeShift,
33 SizeSpecial = 1 << SizeShift,
34 Size2Bytes = 2 << SizeShift,
35 Size4Bytes = 3 << SizeShift,
36 Size6Bytes = 4 << SizeShift
37 };
38}
39
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +000040class MSP430InstrInfo : public TargetInstrInfoImpl {
41 const MSP430RegisterInfo RI;
42 MSP430TargetMachine &TM;
43public:
44 explicit MSP430InstrInfo(MSP430TargetMachine &TM);
45
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).
49 ///
50 virtual const TargetRegisterInfo &getRegisterInfo() const { return RI; }
Anton Korobeynikov1df221f2009-05-03 13:02:04 +000051
52 bool copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
53 unsigned DestReg, unsigned SrcReg,
54 const TargetRegisterClass *DestRC,
Dan Gohman34dcc6f2010-05-06 20:33:48 +000055 const TargetRegisterClass *SrcRC,
56 DebugLoc DL) const;
Anton Korobeynikov1df221f2009-05-03 13:02:04 +000057
58 bool isMoveInstr(const MachineInstr& MI,
59 unsigned &SrcReg, unsigned &DstReg,
60 unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
Anton Korobeynikovaa299152009-05-03 13:09:57 +000061
62 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
63 MachineBasicBlock::iterator MI,
Anton Korobeynikovd5047cb2009-05-03 13:11:04 +000064 unsigned SrcReg, bool isKill,
65 int FrameIndex,
Evan Cheng746ad692010-05-06 19:06:44 +000066 const TargetRegisterClass *RC,
67 const TargetRegisterInfo *TRI) const;
Anton Korobeynikovaa299152009-05-03 13:09:57 +000068 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
69 MachineBasicBlock::iterator MI,
70 unsigned DestReg, int FrameIdx,
Evan Cheng746ad692010-05-06 19:06:44 +000071 const TargetRegisterClass *RC,
72 const TargetRegisterInfo *TRI) const;
Anton Korobeynikovd5047cb2009-05-03 13:11:04 +000073
74 virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
75 MachineBasicBlock::iterator MI,
Evan Cheng2457f2c2010-05-22 01:47:14 +000076 const std::vector<CalleeSavedInfo> &CSI,
77 const TargetRegisterInfo *TRI) const;
Anton Korobeynikovd5047cb2009-05-03 13:11:04 +000078 virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
79 MachineBasicBlock::iterator MI,
Evan Cheng2457f2c2010-05-22 01:47:14 +000080 const std::vector<CalleeSavedInfo> &CSI,
81 const TargetRegisterInfo *TRI) const;
Anton Korobeynikovd5047cb2009-05-03 13:11:04 +000082
Anton Korobeynikov702adab2010-01-15 21:19:05 +000083 unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
84
Anton Korobeynikov90593d22009-10-21 19:17:18 +000085 // Branch folding goodness
86 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
Anton Korobeynikov90593d22009-10-21 19:17:18 +000087 bool isUnpredicatedTerminator(const MachineInstr *MI) const;
88 bool AnalyzeBranch(MachineBasicBlock &MBB,
89 MachineBasicBlock *&TBB, MachineBasicBlock *&FBB,
90 SmallVectorImpl<MachineOperand> &Cond,
91 bool AllowModify) const;
92
93 unsigned RemoveBranch(MachineBasicBlock &MBB) const;
94 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
95 MachineBasicBlock *FBB,
96 const SmallVectorImpl<MachineOperand> &Cond) const;
Anton Korobeynikov8644af32009-05-03 13:15:22 +000097
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +000098};
99
100}
101
102#endif