| 1 | //===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===//cxx . . $ `<file>/MCInstrDesc.h`/ |
| 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 <[email protected]>, 2013-2019 */ |
| 17 | |
| 18 | #ifndef CS_LLVM_MC_MCINSTRDESC_H |
| 19 | #define CS_LLVM_MC_MCINSTRDESC_Hcxx . . $ `MCInstrDesc.h:19:9`! |
| 20 | |
| 21 | #include "MCRegisterInfo.h"cxx . . $ `<file>/MCRegisterInfo.h`/ |
| 22 | #include "capstone/platform.h"cxx . . $ `<file>/include/capstone/platform.h`/ |
| 23 | |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | // Machine Operand Flags and Description |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
| 28 | /// Operand constraints. These are encoded in 16 bits with one of the |
| 29 | /// low-order 3 bits specifying that a constraint is present and the |
| 30 | /// corresponding high-order hex digit specifying the constraint value. |
| 31 | /// This allows for a maximum of 3 constraints. |
| 32 | typedef enumcxx . . $ $anonymous_type_fb55001d67a551d_0# { |
| 33 | MCOI_TIED_TOcxx . . $ MCOI_TIED_TO. = 0, // Operand tied to another operand. |
| 34 | MCOI_EARLY_CLOBBERcxx . . $ MCOI_EARLY_CLOBBER. // Operand is an early clobber register operand |
| 35 | } MCOI_OperandConstraintcxx . . $ MCOI_OperandConstraint#; |
| 36 | |
| 37 | // Define a macro to produce each constraint value. |
| 38 | #define CONSTRAINT_MCOI_TIED_TOcxx . . $ `MCInstrDesc.h:38:9`!(op) \ |
| 39 | ((1 << MCOI_TIED_TO) | ((op) << (4 + MCOI_TIED_TO * 4))) |
| 40 | |
| 41 | #define CONSTRAINT_MCOI_EARLY_CLOBBERcxx . . $ `MCInstrDesc.h:41:9`! \ |
| 42 | (1 << MCOI_EARLY_CLOBBER) |
| 43 | |
| 44 | /// OperandFlags - These are flags set on operands, but should be considered |
| 45 | /// private, all access should go through the MCOperandInfo accessors. |
| 46 | /// See the accessors for a description of what these are. |
| 47 | enum MCOI_OperandFlagscxx . . $ MCOI_OperandFlags# { |
| 48 | MCOI_LookupPtrRegClasscxx . . $ MCOI_LookupPtrRegClass. = 0, |
| 49 | MCOI_Predicatecxx . . $ MCOI_Predicate., |
| 50 | MCOI_OptionalDefcxx . . $ MCOI_OptionalDef. |
| 51 | }; |
| 52 | |
| 53 | /// Operand Type - Operands are tagged with one of the values of this enum. |
| 54 | enum MCOI_OperandTypecxx . . $ MCOI_OperandType# { |
| 55 | MCOI_OPERAND_UNKNOWNcxx . . $ MCOI_OPERAND_UNKNOWN. = 0, |
| 56 | MCOI_OPERAND_IMMEDIATEcxx . . $ MCOI_OPERAND_IMMEDIATE. = 1, |
| 57 | MCOI_OPERAND_REGISTERcxx . . $ MCOI_OPERAND_REGISTER. = 2, |
| 58 | MCOI_OPERAND_MEMORYcxx . . $ MCOI_OPERAND_MEMORY. = 3, |
| 59 | MCOI_OPERAND_PCRELcxx . . $ MCOI_OPERAND_PCREL. = 4, |
| 60 | |
| 61 | MCOI_OPERAND_FIRST_GENERICcxx . . $ MCOI_OPERAND_FIRST_GENERIC. = 6, |
| 62 | MCOI_OPERAND_GENERIC_0cxx . . $ MCOI_OPERAND_GENERIC_0. = 6, |
| 63 | MCOI_OPERAND_GENERIC_1cxx . . $ MCOI_OPERAND_GENERIC_1. = 7, |
| 64 | MCOI_OPERAND_GENERIC_2cxx . . $ MCOI_OPERAND_GENERIC_2. = 8, |
| 65 | MCOI_OPERAND_GENERIC_3cxx . . $ MCOI_OPERAND_GENERIC_3. = 9, |
| 66 | MCOI_OPERAND_GENERIC_4cxx . . $ MCOI_OPERAND_GENERIC_4. = 10, |
| 67 | MCOI_OPERAND_GENERIC_5cxx . . $ MCOI_OPERAND_GENERIC_5. = 11, |
| 68 | MCOI_OPERAND_LAST_GENERICcxx . . $ MCOI_OPERAND_LAST_GENERIC. = 11, |
| 69 | |
| 70 | MCOI_OPERAND_FIRST_GENERIC_IMMcxx . . $ MCOI_OPERAND_FIRST_GENERIC_IMM. = 12, |
| 71 | MCOI_OPERAND_GENERIC_IMM_0cxx . . $ MCOI_OPERAND_GENERIC_IMM_0. = 12, |
| 72 | MCOI_OPERAND_LAST_GENERIC_IMMcxx . . $ MCOI_OPERAND_LAST_GENERIC_IMM. = 12, |
| 73 | |
| 74 | MCOI_OPERAND_FIRST_TARGETcxx . . $ MCOI_OPERAND_FIRST_TARGET. = 13, |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | /// MCOperandInfo - This holds information about one operand of a machine |
| 79 | /// instruction, indicating the register class for register operands, etc. |
| 80 | /// |
| 81 | typedef struct MCOperandInfocxx . . $ MCOperandInfo# { |
| 82 | /// This specifies the register class enumeration of the operand |
| 83 | /// if the operand is a register. If isLookupPtrRegClass is set, then this is |
| 84 | /// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to |
| 85 | /// get a dynamic register class. |
| 86 | int16_tcxx . . $ int16_t# RegClasscxx . . $ MCOperandInfo#RegClass.; |
| 87 | |
| 88 | /// These are flags from the MCOI::OperandFlags enum. |
| 89 | uint8_tcxx . . $ uint8_t# Flagscxx . . $ MCOperandInfo#Flags.; |
| 90 | |
| 91 | /// Information about the type of the operand. |
| 92 | uint8_tcxx . . $ uint8_t# OperandTypecxx . . $ MCOperandInfo#OperandType.; |
| 93 | |
| 94 | /// The lower 16 bits are used to specify which constraints are set. |
| 95 | /// The higher 16 bits are used to specify the value of constraints (4 bits each). |
| 96 | uint32_tcxx . . $ uint32_t# Constraintscxx . . $ MCOperandInfo#Constraints.; |
| 97 | /// Currently no other information. |
| 98 | } MCOperandInfocxx . . $ MCOperandInfo#; |
| 99 | |
| 100 | |
| 101 | //===----------------------------------------------------------------------===// |
| 102 | // Machine Instruction Flags and Description |
| 103 | //===----------------------------------------------------------------------===// |
| 104 | |
| 105 | /// MCInstrDesc flags - These should be considered private to the |
| 106 | /// implementation of the MCInstrDesc class. Clients should use the predicate |
| 107 | /// methods on MCInstrDesc, not use these directly. These all correspond to |
| 108 | /// bitfields in the MCInstrDesc::Flags field. |
| 109 | enumcxx . . $ $anonymous_type_fb55001d67a551d_1# { |
| 110 | MCID_Variadiccxx . . $ MCID_Variadic. = 0, |
| 111 | MCID_HasOptionalDefcxx . . $ MCID_HasOptionalDef., |
| 112 | MCID_Pseudocxx . . $ MCID_Pseudo., |
| 113 | MCID_Returncxx . . $ MCID_Return., |
| 114 | MCID_Callcxx . . $ MCID_Call., |
| 115 | MCID_Barriercxx . . $ MCID_Barrier., |
| 116 | MCID_Terminatorcxx . . $ MCID_Terminator., |
| 117 | MCID_Branchcxx . . $ MCID_Branch., |
| 118 | MCID_IndirectBranchcxx . . $ MCID_IndirectBranch., |
| 119 | MCID_Comparecxx . . $ MCID_Compare., |
| 120 | MCID_MoveImmcxx . . $ MCID_MoveImm., |
| 121 | MCID_MoveRegcxx . . $ MCID_MoveReg., |
| 122 | MCID_Bitcastcxx . . $ MCID_Bitcast., |
| 123 | MCID_Selectcxx . . $ MCID_Select., |
| 124 | MCID_DelaySlotcxx . . $ MCID_DelaySlot., |
| 125 | MCID_FoldableAsLoadcxx . . $ MCID_FoldableAsLoad., |
| 126 | MCID_MayLoadcxx . . $ MCID_MayLoad., |
| 127 | MCID_MayStorecxx . . $ MCID_MayStore., |
| 128 | MCID_Predicablecxx . . $ MCID_Predicable., |
| 129 | MCID_NotDuplicablecxx . . $ MCID_NotDuplicable., |
| 130 | MCID_UnmodeledSideEffectscxx . . $ MCID_UnmodeledSideEffects., |
| 131 | MCID_Commutablecxx . . $ MCID_Commutable., |
| 132 | MCID_ConvertibleTo3Addrcxx . . $ MCID_ConvertibleTo3Addr., |
| 133 | MCID_UsesCustomInsertercxx . . $ MCID_UsesCustomInserter., |
| 134 | MCID_HasPostISelHookcxx . . $ MCID_HasPostISelHook., |
| 135 | MCID_Rematerializablecxx . . $ MCID_Rematerializable., |
| 136 | MCID_CheapAsAMovecxx . . $ MCID_CheapAsAMove., |
| 137 | MCID_ExtraSrcRegAllocReqcxx . . $ MCID_ExtraSrcRegAllocReq., |
| 138 | MCID_ExtraDefRegAllocReqcxx . . $ MCID_ExtraDefRegAllocReq., |
| 139 | MCID_RegSequencecxx . . $ MCID_RegSequence., |
| 140 | MCID_ExtractSubregcxx . . $ MCID_ExtractSubreg., |
| 141 | MCID_InsertSubregcxx . . $ MCID_InsertSubreg., |
| 142 | MCID_Convergentcxx . . $ MCID_Convergent., |
| 143 | MCID_Addcxx . . $ MCID_Add., |
| 144 | MCID_Trapcxx . . $ MCID_Trap., |
| 145 | }; |
| 146 | |
| 147 | /// MCInstrDesc - Describe properties that are true of each instruction in the |
| 148 | /// target description file. This captures information about side effects, |
| 149 | /// register use and many other things. There is one instance of this struct |
| 150 | /// for each target instruction class, and the MachineInstr class points to |
| 151 | /// this struct directly to describe itself. |
| 152 | typedef struct MCInstrDesccxx . . $ MCInstrDesc# { |
| 153 | unsigned char NumOperandscxx . . $ MCInstrDesc#NumOperands.; // Num of args (may be more if variable_ops) |
| 154 | const MCOperandInfocxx . . $ MCOperandInfo# *OpInfocxx . . $ MCInstrDesc#OpInfo.; // 'NumOperands' entries about operands |
| 155 | } MCInstrDesccxx . . $ MCInstrDesc#; |
| 156 | |
| 157 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! MCOperandInfo_isPredicatecxx . . $ MCOperandInfo_isPredicate(fd07c0332416d4df).(const MCOperandInfocxx . . $ MCOperandInfo# *m); |
| 158 | |
| 159 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! MCOperandInfo_isOptionalDefcxx . . $ MCOperandInfo_isOptionalDef(fd07c0332416d4df).(const MCOperandInfocxx . . $ MCOperandInfo# *m); |
| 160 | |
| 161 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! MCOperandInfo_isTiedToOpcxx . . $ MCOperandInfo_isTiedToOp(fd07c0332416d4df).(const MCOperandInfocxx . . $ MCOperandInfo# *m); |
| 162 | |
| 163 | int MCOperandInfo_getOperandConstraintcxx . . $ MCOperandInfo_getOperandConstraint(cc1c42ad4c38c5e3).(const MCInstrDesccxx . . $ MCInstrDesc# *OpInfo, |
| 164 | unsigned OpNum, |
| 165 | MCOI_OperandConstraintcxx . . $ MCOI_OperandConstraint# Constraint); |
| 166 | |
| 167 | #endif |