blob: d79f99245e715a0de1d1f44573dc4bca29a3d35e [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- MSP430InstrInfo.h - MSP430 Instruction Information ------*- C++ -*-===//
Anton Korobeynikov10138002009-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 Korobeynikov10138002009-05-03 12:57:15 +000017#include "MSP430RegisterInfo.h"
Craig Topperb25fda92012-03-17 18:46:09 +000018#include "llvm/Target/TargetInstrInfo.h"
Anton Korobeynikov10138002009-05-03 12:57:15 +000019
Evan Cheng703a0fb2011-07-01 17:57:27 +000020#define GET_INSTRINFO_HEADER
21#include "MSP430GenInstrInfo.inc"
22
Anton Korobeynikov10138002009-05-03 12:57:15 +000023namespace llvm {
24
25class MSP430TargetMachine;
26
Anton Korobeynikovce52fd52010-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 Cheng703a0fb2011-07-01 17:57:27 +000043class MSP430InstrInfo : public MSP430GenInstrInfo {
Anton Korobeynikov10138002009-05-03 12:57:15 +000044 const MSP430RegisterInfo RI;
Anton Korobeynikov10138002009-05-03 12:57:15 +000045public:
46 explicit MSP430InstrInfo(MSP430TargetMachine &TM);
47
48 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
49 /// such, whenever a client has an instance of instruction info, it should
50 /// always be able to get register info as well (through this method).
51 ///
52 virtual const TargetRegisterInfo &getRegisterInfo() const { return RI; }
Anton Korobeynikovd7afd692009-05-03 13:02:04 +000053
Jakob Stoklund Olesen65306362010-07-11 06:53:30 +000054 void copyPhysReg(MachineBasicBlock &MBB,
55 MachineBasicBlock::iterator I, DebugLoc DL,
56 unsigned DestReg, unsigned SrcReg,
57 bool KillSrc) const;
Anton Korobeynikovd7afd692009-05-03 13:02:04 +000058
Anton Korobeynikovf6af8222009-05-03 13:09:57 +000059 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
60 MachineBasicBlock::iterator MI,
Anton Korobeynikov1af0b612009-05-03 13:11:04 +000061 unsigned SrcReg, bool isKill,
62 int FrameIndex,
Evan Chengefb126a2010-05-06 19:06:44 +000063 const TargetRegisterClass *RC,
64 const TargetRegisterInfo *TRI) const;
Anton Korobeynikovf6af8222009-05-03 13:09:57 +000065 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
66 MachineBasicBlock::iterator MI,
67 unsigned DestReg, int FrameIdx,
Evan Chengefb126a2010-05-06 19:06:44 +000068 const TargetRegisterClass *RC,
69 const TargetRegisterInfo *TRI) const;
Anton Korobeynikov1af0b612009-05-03 13:11:04 +000070
Anton Korobeynikovce52fd52010-01-15 21:19:05 +000071 unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
72
Anton Korobeynikov5399c2d2009-10-21 19:17:18 +000073 // Branch folding goodness
74 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
Anton Korobeynikov5399c2d2009-10-21 19:17:18 +000075 bool isUnpredicatedTerminator(const MachineInstr *MI) const;
76 bool AnalyzeBranch(MachineBasicBlock &MBB,
77 MachineBasicBlock *&TBB, MachineBasicBlock *&FBB,
78 SmallVectorImpl<MachineOperand> &Cond,
79 bool AllowModify) const;
80
81 unsigned RemoveBranch(MachineBasicBlock &MBB) const;
82 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
83 MachineBasicBlock *FBB,
Stuart Hastings0125b642010-06-17 22:43:56 +000084 const SmallVectorImpl<MachineOperand> &Cond,
85 DebugLoc DL) const;
Anton Korobeynikov41917df2009-05-03 13:15:22 +000086
Anton Korobeynikov10138002009-05-03 12:57:15 +000087};
88
89}
90
91#endif