| Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame^] | 1 | //===- ARMInstrInfo.h - ARM Instruction Information -------------*- C++ -*-===// | 
| Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
|  | 5 | // This file was developed by the "Instituto Nokia de Tecnologia" and | 
|  | 6 | // is distributed under the University of Illinois Open Source | 
|  | 7 | // License. See LICENSE.TXT for details. | 
|  | 8 | // | 
|  | 9 | //===----------------------------------------------------------------------===// | 
|  | 10 | // | 
|  | 11 | // This file contains the ARM implementation of the TargetInstrInfo class. | 
|  | 12 | // | 
|  | 13 | //===----------------------------------------------------------------------===// | 
|  | 14 |  | 
|  | 15 | #ifndef ARMINSTRUCTIONINFO_H | 
|  | 16 | #define ARMINSTRUCTIONINFO_H | 
|  | 17 |  | 
|  | 18 | #include "llvm/Target/TargetInstrInfo.h" | 
|  | 19 | #include "ARMRegisterInfo.h" | 
|  | 20 |  | 
|  | 21 | namespace llvm { | 
| Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame^] | 22 | class ARMSubtarget; | 
|  | 23 |  | 
|  | 24 | /// ARMII - This namespace holds all of the target specific flags that | 
|  | 25 | /// instruction info tracks. | 
|  | 26 | /// | 
|  | 27 | namespace ARMII { | 
|  | 28 | enum { | 
|  | 29 | //===------------------------------------------------------------------===// | 
|  | 30 | // Instruction Flags. | 
|  | 31 |  | 
|  | 32 | //===------------------------------------------------------------------===// | 
|  | 33 | // This three-bit field describes the addressing mode used.  Zero is unused | 
|  | 34 | // so that we can tell if we forgot to set a value. | 
|  | 35 |  | 
|  | 36 | AddrModeMask  = 0xf, | 
|  | 37 | AddrMode1     = 1, | 
|  | 38 | AddrMode2     = 2, | 
|  | 39 | AddrMode3     = 3, | 
|  | 40 | AddrMode4     = 4, | 
|  | 41 | AddrMode5     = 5, | 
|  | 42 | AddrModeT1    = 6, | 
|  | 43 | AddrModeT2    = 7, | 
|  | 44 | AddrModeT4    = 8, | 
|  | 45 | AddrModeTs    = 9,   // i8 * 4 for pc and sp relative data | 
|  | 46 |  | 
|  | 47 | // Size* - Flags to keep track of the size of an instruction. | 
|  | 48 | SizeShift     = 4, | 
|  | 49 | SizeMask      = 7 << SizeShift, | 
|  | 50 | SizeSpecial   = 1,   // 0 byte pseudo or special case. | 
|  | 51 | Size8Bytes    = 2, | 
|  | 52 | Size4Bytes    = 3, | 
|  | 53 | Size2Bytes    = 4, | 
|  | 54 |  | 
|  | 55 | // IndexMode - Unindex, pre-indexed, or post-indexed. Only valid for load | 
|  | 56 | // and store ops | 
|  | 57 | IndexModeShift = 7, | 
|  | 58 | IndexModeMask  = 3 << IndexModeShift, | 
|  | 59 | IndexModePre   = 1, | 
|  | 60 | IndexModePost  = 2, | 
|  | 61 |  | 
|  | 62 | // Opcode | 
|  | 63 | OpcodeShift   = 9, | 
|  | 64 | OpcodeMask    = 0xf << OpcodeShift | 
|  | 65 | }; | 
|  | 66 | } | 
| Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 67 |  | 
|  | 68 | class ARMInstrInfo : public TargetInstrInfo { | 
|  | 69 | const ARMRegisterInfo RI; | 
|  | 70 | public: | 
| Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame^] | 71 | ARMInstrInfo(const ARMSubtarget &STI); | 
| Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 72 |  | 
|  | 73 | /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As | 
|  | 74 | /// such, whenever a client has an instance of instruction info, it should | 
|  | 75 | /// always be able to get register info as well (through this method). | 
|  | 76 | /// | 
|  | 77 | virtual const MRegisterInfo &getRegisterInfo() const { return RI; } | 
|  | 78 |  | 
| Rafael Espindola | 46adf81 | 2006-08-08 20:35:03 +0000 | [diff] [blame] | 79 | /// getPointerRegClass - Return the register class to use to hold pointers. | 
|  | 80 | /// This is used for addressing modes. | 
|  | 81 | virtual const TargetRegisterClass *getPointerRegClass() const; | 
|  | 82 |  | 
| Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame^] | 83 | /// getDWARF_LABELOpcode - Return the opcode of the target's DWARF_LABEL | 
|  | 84 | /// instruction if it has one.  This is used by codegen passes that update | 
|  | 85 | /// DWARF line number info as they modify the code. | 
|  | 86 | virtual unsigned getDWARF_LABELOpcode() const; | 
|  | 87 |  | 
| Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 88 | /// Return true if the instruction is a register to register move and | 
|  | 89 | /// leave the source and dest operands in the passed parameters. | 
|  | 90 | /// | 
|  | 91 | virtual bool isMoveInstr(const MachineInstr &MI, | 
|  | 92 | unsigned &SrcReg, unsigned &DstReg) const; | 
| Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame^] | 93 | virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const; | 
|  | 94 | virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const; | 
|  | 95 |  | 
|  | 96 | virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI, | 
|  | 97 | MachineBasicBlock::iterator &MBBI, | 
|  | 98 | LiveVariables &LV) const; | 
| Chris Lattner | 578e64a | 2006-10-24 16:47:57 +0000 | [diff] [blame] | 99 |  | 
| Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame^] | 100 | // Branch analysis. | 
|  | 101 | virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, | 
|  | 102 | MachineBasicBlock *&FBB, | 
|  | 103 | std::vector<MachineOperand> &Cond) const; | 
|  | 104 | virtual void RemoveBranch(MachineBasicBlock &MBB) const; | 
| Chris Lattner | 578e64a | 2006-10-24 16:47:57 +0000 | [diff] [blame] | 105 | virtual void InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, | 
|  | 106 | MachineBasicBlock *FBB, | 
|  | 107 | const std::vector<MachineOperand> &Cond) const; | 
| Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame^] | 108 | virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const; | 
|  | 109 | virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const; | 
| Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 110 | }; | 
|  | 111 |  | 
|  | 112 | } | 
|  | 113 |  | 
|  | 114 | #endif |