|
1 | 1 | /* Capstone Disassembly Engine */
|
2 | 2 | /* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */
|
3 |
| - |
4 | 3 | #if defined(CAPSTONE_HAS_OSXKERNEL)
|
5 | 4 | #include <Availability.h>
|
6 | 5 | #include <libkern/libkern.h>
|
|
11 | 10 | #include <string.h>
|
12 | 11 | #include <assert.h>
|
13 | 12 |
|
| 13 | +#include "MCInstrDesc.h" |
14 | 14 | #include "MCInst.h"
|
15 | 15 | #include "utils.h"
|
16 | 16 |
|
@@ -105,12 +105,12 @@ bool MCOperand_isValid(const MCOperand *op)
|
105 | 105 |
|
106 | 106 | bool MCOperand_isReg(const MCOperand *op)
|
107 | 107 | {
|
108 |
| - return op->Kind == kRegister; |
| 108 | + return op->Kind == kRegister || op->MachineOperandType == kRegister; |
109 | 109 | }
|
110 | 110 |
|
111 | 111 | bool MCOperand_isImm(const MCOperand *op)
|
112 | 112 | {
|
113 |
| - return op->Kind == kImmediate; |
| 113 | + return op->Kind == kImmediate || op->MachineOperandType == kImmediate; |
114 | 114 | }
|
115 | 115 |
|
116 | 116 | bool MCOperand_isFPImm(const MCOperand *op)
|
@@ -224,16 +224,26 @@ bool MCInst_isPredicable(const MCInstrDesc *MIDesc)
|
224 | 224 | /// Checks if tied operands exist in the instruction and sets
|
225 | 225 | /// - The writeback flag in detail
|
226 | 226 | /// - Saves the indices of the tied destination operands.
|
227 |
| -void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc) |
228 |
| -{ |
229 |
| - const MCOperandInfo *OpInfo = InstDesc[MCInst_getOpcode(MI)].OpInfo; |
230 |
| - unsigned short NumOps = InstDesc[MCInst_getOpcode(MI)].NumOperands; |
| 227 | +void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDescTable, unsigned tbl_size) |
| 228 | +{ |
| 229 | + const MCInstrDesc *InstDesc = NULL; |
| 230 | + const MCOperandInfo *OpInfo = NULL; |
| 231 | + unsigned short NumOps = 0; |
| 232 | + if (MI->csh->arch == CS_ARCH_ARM) { |
| 233 | + // Uses old (pre LLVM 18) indexing method. |
| 234 | + InstDesc = &InstDescTable[MCInst_getOpcode(MI)]; |
| 235 | + OpInfo = InstDescTable[MCInst_getOpcode(MI)].OpInfo; |
| 236 | + NumOps = InstDescTable[MCInst_getOpcode(MI)].NumOperands; |
| 237 | + } else { |
| 238 | + InstDesc = MCInstrDesc_get(MCInst_getOpcode(MI), InstDescTable, tbl_size); |
| 239 | + OpInfo = MCInstrDesc_get(MCInst_getOpcode(MI), InstDescTable, tbl_size)->OpInfo; |
| 240 | + NumOps = MCInstrDesc_get(MCInst_getOpcode(MI), InstDescTable, tbl_size)->NumOperands; |
| 241 | + } |
231 | 242 |
|
232 |
| - unsigned i; |
233 |
| - for (i = 0; i < NumOps; ++i) { |
| 243 | + for (unsigned i = 0; i < NumOps; ++i) { |
234 | 244 | if (MCOperandInfo_isTiedToOp(&OpInfo[i])) {
|
235 | 245 | int idx = MCOperandInfo_getOperandConstraint(
|
236 |
| - &InstDesc[MCInst_getOpcode(MI)], i, |
| 246 | + InstDesc, i, |
237 | 247 | MCOI_TIED_TO);
|
238 | 248 |
|
239 | 249 | if (idx == -1)
|
|
0 commit comments