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