blob: 04f339bdd6081d5976c36d7b74b79d6528b106c3 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- MSP430InstrInfo.h - MSP430 Instruction Information ------*- C++ -*-===//
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +00002//
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
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +000017#include "MSP430RegisterInfo.h"
Craig Topper79aa3412012-03-17 18:46:09 +000018#include "llvm/Target/TargetInstrInfo.h"
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +000019
Evan Cheng4db3cff2011-07-01 17:57:27 +000020#define GET_INSTRINFO_HEADER
21#include "MSP430GenInstrInfo.inc"
22
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +000023namespace llvm {
24
25class MSP430TargetMachine;
26
Anton Korobeynikov702adab2010-01-15 21:19:05 +000027/// MSP430II - This namespace holds all of the target specific flags that
28/// instruction info tracks.
29///
30namespace MSP430II {
31 enum {
32 SizeShift = 2,
33 SizeMask = 7 << SizeShift,
34
35 SizeUnknown = 0 << SizeShift,
36 SizeSpecial = 1 << SizeShift,
37 Size2Bytes = 2 << SizeShift,
38 Size4Bytes = 3 << SizeShift,
39 Size6Bytes = 4 << SizeShift
40 };
41}
42
Evan Cheng4db3cff2011-07-01 17:57:27 +000043class MSP430InstrInfo : public MSP430GenInstrInfo {
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +000044 const MSP430RegisterInfo RI;
45 MSP430TargetMachine &TM;
46public:
47 explicit MSP430InstrInfo(MSP430TargetMachine &TM);
48
49 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
50 /// such, whenever a client has an instance of instruction info, it should
51 /// always be able to get register info as well (through this method).
52 ///
53 virtual const TargetRegisterInfo &getRegisterInfo() const { return RI; }
Anton Korobeynikov1df221f2009-05-03 13:02:04 +000054
Jakob Stoklund Olesen41ce3cf2010-07-11 06:53:30 +000055 void copyPhysReg(MachineBasicBlock &MBB,
56 MachineBasicBlock::iterator I, DebugLoc DL,
57 unsigned DestReg, unsigned SrcReg,
58 bool KillSrc) const;
Anton Korobeynikov1df221f2009-05-03 13:02:04 +000059
Anton Korobeynikovaa299152009-05-03 13:09:57 +000060 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
61 MachineBasicBlock::iterator MI,
Anton Korobeynikovd5047cb2009-05-03 13:11:04 +000062 unsigned SrcReg, bool isKill,
63 int FrameIndex,
Evan Cheng746ad692010-05-06 19:06:44 +000064 const TargetRegisterClass *RC,
65 const TargetRegisterInfo *TRI) const;
Anton Korobeynikovaa299152009-05-03 13:09:57 +000066 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
67 MachineBasicBlock::iterator MI,
68 unsigned DestReg, int FrameIdx,
Evan Cheng746ad692010-05-06 19:06:44 +000069 const TargetRegisterClass *RC,
70 const TargetRegisterInfo *TRI) const;
Anton Korobeynikovd5047cb2009-05-03 13:11:04 +000071
Anton Korobeynikov702adab2010-01-15 21:19:05 +000072 unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
73
Anton Korobeynikov90593d22009-10-21 19:17:18 +000074 // Branch folding goodness
75 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
Anton Korobeynikov90593d22009-10-21 19:17:18 +000076 bool isUnpredicatedTerminator(const MachineInstr *MI) const;
77 bool AnalyzeBranch(MachineBasicBlock &MBB,
78 MachineBasicBlock *&TBB, MachineBasicBlock *&FBB,
79 SmallVectorImpl<MachineOperand> &Cond,
80 bool AllowModify) const;
81
82 unsigned RemoveBranch(MachineBasicBlock &MBB) const;
83 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
84 MachineBasicBlock *FBB,
Stuart Hastings3bf91252010-06-17 22:43:56 +000085 const SmallVectorImpl<MachineOperand> &Cond,
86 DebugLoc DL) const;
Anton Korobeynikov8644af32009-05-03 13:15:22 +000087
Anton Korobeynikovf2c3e172009-05-03 12:57:15 +000088};
89
90}
91
92#endif