Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 1 | //===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===// |
| 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 defines the MCOperandInfo and MCInstrDesc classes, which |
| 11 | // are used to describe target instructions and their operands. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Nguyen Anh Quynh | 6023ef7 | 2014-04-29 11:21:04 +0800 | [diff] [blame] | 15 | /* Capstone Disassembly Engine */ |
| 16 | /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 */ |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 17 | |
| 18 | #ifndef CS_LLVM_MC_MCINSTRDESC_H |
| 19 | #define CS_LLVM_MC_MCINSTRDESC_H |
| 20 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 21 | #include <stdint.h> |
Nguyen Anh Quynh | c5cad6c | 2014-05-15 21:40:24 +0800 | [diff] [blame] | 22 | #include "include/platform.h" |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 23 | |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | // Machine Operand Flags and Description |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
| 28 | // Operand constraints |
| 29 | enum MCOI_OperandConstraint { |
| 30 | MCOI_TIED_TO = 0, // Must be allocated the same register as. |
| 31 | MCOI_EARLY_CLOBBER // Operand is an early clobber register operand |
| 32 | }; |
| 33 | |
| 34 | /// OperandFlags - These are flags set on operands, but should be considered |
| 35 | /// private, all access should go through the MCOperandInfo accessors. |
| 36 | /// See the accessors for a description of what these are. |
| 37 | enum MCOI_OperandFlags { |
| 38 | MCOI_LookupPtrRegClass = 0, |
| 39 | MCOI_Predicate, |
| 40 | MCOI_OptionalDef |
| 41 | }; |
| 42 | |
| 43 | /// Operand Type - Operands are tagged with one of the values of this enum. |
| 44 | enum MCOI_OperandType { |
| 45 | MCOI_OPERAND_UNKNOWN, |
| 46 | MCOI_OPERAND_IMMEDIATE, |
| 47 | MCOI_OPERAND_REGISTER, |
| 48 | MCOI_OPERAND_MEMORY, |
| 49 | MCOI_OPERAND_PCREL |
| 50 | }; |
| 51 | |
| 52 | |
| 53 | /// MCOperandInfo - This holds information about one operand of a machine |
| 54 | /// instruction, indicating the register class for register operands, etc. |
| 55 | /// |
| 56 | typedef struct MCOperandInfo { |
| 57 | /// RegClass - This specifies the register class enumeration of the operand |
| 58 | /// if the operand is a register. If isLookupPtrRegClass is set, then this is |
| 59 | /// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to |
| 60 | /// get a dynamic register class. |
| 61 | int16_t RegClass; |
| 62 | |
| 63 | /// Flags - These are flags from the MCOI::OperandFlags enum. |
| 64 | uint8_t Flags; |
| 65 | |
| 66 | /// OperandType - Information about the type of the operand. |
| 67 | uint8_t OperandType; |
| 68 | |
| 69 | /// Lower 16 bits are used to specify which constraints are set. The higher 16 |
| 70 | /// bits are used to specify the value of constraints (4 bits each). |
| 71 | uint32_t Constraints; |
| 72 | /// Currently no other information. |
| 73 | } MCOperandInfo; |
| 74 | |
| 75 | |
| 76 | //===----------------------------------------------------------------------===// |
| 77 | // Machine Instruction Flags and Description |
| 78 | //===----------------------------------------------------------------------===// |
| 79 | |
| 80 | /// MCInstrDesc flags - These should be considered private to the |
| 81 | /// implementation of the MCInstrDesc class. Clients should use the predicate |
| 82 | /// methods on MCInstrDesc, not use these directly. These all correspond to |
| 83 | /// bitfields in the MCInstrDesc::Flags field. |
| 84 | enum { |
| 85 | MCID_Variadic = 0, |
| 86 | MCID_HasOptionalDef, |
| 87 | MCID_Pseudo, |
| 88 | MCID_Return, |
| 89 | MCID_Call, |
| 90 | MCID_Barrier, |
| 91 | MCID_Terminator, |
| 92 | MCID_Branch, |
| 93 | MCID_IndirectBranch, |
| 94 | MCID_Compare, |
| 95 | MCID_MoveImm, |
| 96 | MCID_Bitcast, |
| 97 | MCID_Select, |
| 98 | MCID_DelaySlot, |
| 99 | MCID_FoldableAsLoad, |
| 100 | MCID_MayLoad, |
| 101 | MCID_MayStore, |
| 102 | MCID_Predicable, |
| 103 | MCID_NotDuplicable, |
| 104 | MCID_UnmodeledSideEffects, |
| 105 | MCID_Commutable, |
| 106 | MCID_ConvertibleTo3Addr, |
| 107 | MCID_UsesCustomInserter, |
| 108 | MCID_HasPostISelHook, |
| 109 | MCID_Rematerializable, |
| 110 | MCID_CheapAsAMove, |
| 111 | MCID_ExtraSrcRegAllocReq, |
| 112 | MCID_ExtraDefRegAllocReq |
| 113 | }; |
| 114 | |
| 115 | /// MCInstrDesc - Describe properties that are true of each instruction in the |
| 116 | /// target description file. This captures information about side effects, |
| 117 | /// register use and many other things. There is one instance of this struct |
| 118 | /// for each target instruction class, and the MachineInstr class points to |
| 119 | /// this struct directly to describe itself. |
| 120 | typedef struct MCInstrDesc { |
| 121 | unsigned short Opcode; // The opcode number |
| 122 | unsigned short NumOperands; // Num of args (may be more if variable_ops) |
| 123 | unsigned short NumDefs; // Num of args that are definitions |
| 124 | unsigned short SchedClass; // enum identifying instr sched class |
| 125 | unsigned short Size; // Number of bytes in encoding. |
| 126 | unsigned Flags; // Flags identifying machine instr class |
| 127 | uint64_t TSFlags; // Target Specific Flag values |
| 128 | uint16_t *ImplicitUses; // Registers implicitly read by this instr |
| 129 | uint16_t *ImplicitDefs; // Registers implicitly defined by this instr |
| 130 | MCOperandInfo *OpInfo; // 'NumOperands' entries about operands |
| 131 | uint64_t DeprecatedFeatureMask;// Feature bits that this is deprecated on, if any |
| 132 | // A complex method to determine is a certain is deprecated or not, and return |
| 133 | // the reason for deprecation. |
| 134 | //bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &, std::string &); |
| 135 | unsigned ComplexDeprecationInfo; // dummy field, just to satisfy initializer |
| 136 | } MCInstrDesc; |
| 137 | |
| 138 | bool MCOperandInfo_isPredicate(MCOperandInfo *m); |
| 139 | |
| 140 | bool MCOperandInfo_isOptionalDef(MCOperandInfo *m); |
| 141 | |
| 142 | #endif |