Jia Liu | 31d157a | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- MSP430InstrInfo.h - MSP430 Instruction Information ------*- C++ -*-===// |
Anton Korobeynikov | f2c3e17 | 2009-05-03 12:57:15 +0000 | [diff] [blame] | 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 | |
Anton Korobeynikov | f2c3e17 | 2009-05-03 12:57:15 +0000 | [diff] [blame] | 17 | #include "MSP430RegisterInfo.h" |
Craig Topper | 79aa341 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetInstrInfo.h" |
Anton Korobeynikov | f2c3e17 | 2009-05-03 12:57:15 +0000 | [diff] [blame] | 19 | |
Evan Cheng | 4db3cff | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 20 | #define GET_INSTRINFO_HEADER |
| 21 | #include "MSP430GenInstrInfo.inc" |
| 22 | |
Anton Korobeynikov | f2c3e17 | 2009-05-03 12:57:15 +0000 | [diff] [blame] | 23 | namespace llvm { |
| 24 | |
| 25 | class MSP430TargetMachine; |
| 26 | |
Anton Korobeynikov | 702adab | 2010-01-15 21:19:05 +0000 | [diff] [blame] | 27 | /// MSP430II - This namespace holds all of the target specific flags that |
| 28 | /// instruction info tracks. |
| 29 | /// |
| 30 | namespace 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 Cheng | 4db3cff | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 43 | class MSP430InstrInfo : public MSP430GenInstrInfo { |
Anton Korobeynikov | f2c3e17 | 2009-05-03 12:57:15 +0000 | [diff] [blame] | 44 | const MSP430RegisterInfo RI; |
Anton Korobeynikov | f2c3e17 | 2009-05-03 12:57:15 +0000 | [diff] [blame] | 45 | public: |
| 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 Korobeynikov | 1df221f | 2009-05-03 13:02:04 +0000 | [diff] [blame] | 53 | |
Jakob Stoklund Olesen | 41ce3cf | 2010-07-11 06:53:30 +0000 | [diff] [blame] | 54 | void copyPhysReg(MachineBasicBlock &MBB, |
| 55 | MachineBasicBlock::iterator I, DebugLoc DL, |
| 56 | unsigned DestReg, unsigned SrcReg, |
| 57 | bool KillSrc) const; |
Anton Korobeynikov | 1df221f | 2009-05-03 13:02:04 +0000 | [diff] [blame] | 58 | |
Anton Korobeynikov | aa29915 | 2009-05-03 13:09:57 +0000 | [diff] [blame] | 59 | virtual void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 60 | MachineBasicBlock::iterator MI, |
Anton Korobeynikov | d5047cb | 2009-05-03 13:11:04 +0000 | [diff] [blame] | 61 | unsigned SrcReg, bool isKill, |
| 62 | int FrameIndex, |
Evan Cheng | 746ad69 | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 63 | const TargetRegisterClass *RC, |
| 64 | const TargetRegisterInfo *TRI) const; |
Anton Korobeynikov | aa29915 | 2009-05-03 13:09:57 +0000 | [diff] [blame] | 65 | virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 66 | MachineBasicBlock::iterator MI, |
| 67 | unsigned DestReg, int FrameIdx, |
Evan Cheng | 746ad69 | 2010-05-06 19:06:44 +0000 | [diff] [blame] | 68 | const TargetRegisterClass *RC, |
| 69 | const TargetRegisterInfo *TRI) const; |
Anton Korobeynikov | d5047cb | 2009-05-03 13:11:04 +0000 | [diff] [blame] | 70 | |
Anton Korobeynikov | 702adab | 2010-01-15 21:19:05 +0000 | [diff] [blame] | 71 | unsigned GetInstSizeInBytes(const MachineInstr *MI) const; |
| 72 | |
Anton Korobeynikov | 90593d2 | 2009-10-21 19:17:18 +0000 | [diff] [blame] | 73 | // Branch folding goodness |
| 74 | bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; |
Anton Korobeynikov | 90593d2 | 2009-10-21 19:17:18 +0000 | [diff] [blame] | 75 | 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 Hastings | 3bf9125 | 2010-06-17 22:43:56 +0000 | [diff] [blame] | 84 | const SmallVectorImpl<MachineOperand> &Cond, |
| 85 | DebugLoc DL) const; |
Anton Korobeynikov | 8644af3 | 2009-05-03 13:15:22 +0000 | [diff] [blame] | 86 | |
Anton Korobeynikov | f2c3e17 | 2009-05-03 12:57:15 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | #endif |