xref: /minix3/external/bsd/llvm/dist/llvm/lib/Target/MSP430/MSP430InstrInfo.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc //===-- MSP430InstrInfo.h - MSP430 Instruction Information ------*- C++ -*-===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc // This file contains the MSP430 implementation of the TargetInstrInfo class.
11f4a2713aSLionel Sambuc //
12f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
13f4a2713aSLionel Sambuc 
14*0a6a1f1dSLionel Sambuc #ifndef LLVM_LIB_TARGET_MSP430_MSP430INSTRINFO_H
15*0a6a1f1dSLionel Sambuc #define LLVM_LIB_TARGET_MSP430_MSP430INSTRINFO_H
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc #include "MSP430RegisterInfo.h"
18f4a2713aSLionel Sambuc #include "llvm/Target/TargetInstrInfo.h"
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc #define GET_INSTRINFO_HEADER
21f4a2713aSLionel Sambuc #include "MSP430GenInstrInfo.inc"
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc namespace llvm {
24f4a2713aSLionel Sambuc 
25*0a6a1f1dSLionel Sambuc class MSP430Subtarget;
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc /// MSP430II - This namespace holds all of the target specific flags that
28f4a2713aSLionel Sambuc /// instruction info tracks.
29f4a2713aSLionel Sambuc ///
30f4a2713aSLionel Sambuc namespace MSP430II {
31f4a2713aSLionel Sambuc   enum {
32f4a2713aSLionel Sambuc     SizeShift   = 2,
33f4a2713aSLionel Sambuc     SizeMask    = 7 << SizeShift,
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc     SizeUnknown = 0 << SizeShift,
36f4a2713aSLionel Sambuc     SizeSpecial = 1 << SizeShift,
37f4a2713aSLionel Sambuc     Size2Bytes  = 2 << SizeShift,
38f4a2713aSLionel Sambuc     Size4Bytes  = 3 << SizeShift,
39f4a2713aSLionel Sambuc     Size6Bytes  = 4 << SizeShift
40f4a2713aSLionel Sambuc   };
41f4a2713aSLionel Sambuc }
42f4a2713aSLionel Sambuc 
43f4a2713aSLionel Sambuc class MSP430InstrInfo : public MSP430GenInstrInfo {
44f4a2713aSLionel Sambuc   const MSP430RegisterInfo RI;
45f4a2713aSLionel Sambuc   virtual void anchor();
46f4a2713aSLionel Sambuc public:
47*0a6a1f1dSLionel Sambuc   explicit MSP430InstrInfo(MSP430Subtarget &STI);
48f4a2713aSLionel Sambuc 
49f4a2713aSLionel Sambuc   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
50f4a2713aSLionel Sambuc   /// such, whenever a client has an instance of instruction info, it should
51f4a2713aSLionel Sambuc   /// always be able to get register info as well (through this method).
52f4a2713aSLionel Sambuc   ///
getRegisterInfo()53*0a6a1f1dSLionel Sambuc   const TargetRegisterInfo &getRegisterInfo() const { return RI; }
54f4a2713aSLionel Sambuc 
55f4a2713aSLionel Sambuc   void copyPhysReg(MachineBasicBlock &MBB,
56f4a2713aSLionel Sambuc                    MachineBasicBlock::iterator I, DebugLoc DL,
57f4a2713aSLionel Sambuc                    unsigned DestReg, unsigned SrcReg,
58*0a6a1f1dSLionel Sambuc                    bool KillSrc) const override;
59f4a2713aSLionel Sambuc 
60*0a6a1f1dSLionel Sambuc   void storeRegToStackSlot(MachineBasicBlock &MBB,
61f4a2713aSLionel Sambuc                            MachineBasicBlock::iterator MI,
62f4a2713aSLionel Sambuc                            unsigned SrcReg, bool isKill,
63f4a2713aSLionel Sambuc                            int FrameIndex,
64f4a2713aSLionel Sambuc                            const TargetRegisterClass *RC,
65*0a6a1f1dSLionel Sambuc                            const TargetRegisterInfo *TRI) const override;
66*0a6a1f1dSLionel Sambuc   void loadRegFromStackSlot(MachineBasicBlock &MBB,
67f4a2713aSLionel Sambuc                             MachineBasicBlock::iterator MI,
68f4a2713aSLionel Sambuc                             unsigned DestReg, int FrameIdx,
69f4a2713aSLionel Sambuc                             const TargetRegisterClass *RC,
70*0a6a1f1dSLionel Sambuc                             const TargetRegisterInfo *TRI) const override;
71f4a2713aSLionel Sambuc 
72f4a2713aSLionel Sambuc   unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
73f4a2713aSLionel Sambuc 
74f4a2713aSLionel Sambuc   // Branch folding goodness
75*0a6a1f1dSLionel Sambuc   bool
76*0a6a1f1dSLionel Sambuc   ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
77*0a6a1f1dSLionel Sambuc   bool isUnpredicatedTerminator(const MachineInstr *MI) const override;
78f4a2713aSLionel Sambuc   bool AnalyzeBranch(MachineBasicBlock &MBB,
79f4a2713aSLionel Sambuc                      MachineBasicBlock *&TBB, MachineBasicBlock *&FBB,
80f4a2713aSLionel Sambuc                      SmallVectorImpl<MachineOperand> &Cond,
81*0a6a1f1dSLionel Sambuc                      bool AllowModify) const override;
82f4a2713aSLionel Sambuc 
83*0a6a1f1dSLionel Sambuc   unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
84f4a2713aSLionel Sambuc   unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
85f4a2713aSLionel Sambuc                         MachineBasicBlock *FBB,
86f4a2713aSLionel Sambuc                         const SmallVectorImpl<MachineOperand> &Cond,
87*0a6a1f1dSLionel Sambuc                         DebugLoc DL) const override;
88f4a2713aSLionel Sambuc 
89f4a2713aSLionel Sambuc };
90f4a2713aSLionel Sambuc 
91f4a2713aSLionel Sambuc }
92f4a2713aSLionel Sambuc 
93f4a2713aSLionel Sambuc #endif
94