tms320c64x_detail.c
Go to the documentation of this file.
1 /* Capstone testing regression */
2 /* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
3 
4 
5 #include "factory.h"
6 
7 char *get_detail_tms320c64x(csh *handle, cs_mode mode, cs_insn *ins)
8 {
9  cs_tms320c64x *tms320c64x;
10  int i;
11  char *result;
12 
13  result = (char *)malloc(sizeof(char));
14  result[0] = '\0';
15 
16  if (ins->detail == NULL)
17  return result;
18 
19  tms320c64x = &(ins->detail->tms320c64x);
20  if (tms320c64x->op_count)
21  add_str(&result, " ; op_count: %u", tms320c64x->op_count);
22 
23  for (i = 0; i < tms320c64x->op_count; i++) {
24  cs_tms320c64x_op *op = &(tms320c64x->operands[i]);
25  switch((int)op->type) {
26  default:
27  break;
28  case TMS320C64X_OP_REG:
29  add_str(&result, " ; operands[%u].type: REG = %s", i, cs_reg_name(*handle, op->reg));
30  break;
31  case TMS320C64X_OP_IMM:
32  add_str(&result, " ; operands[%u].type: IMM = 0x%x", i, op->imm);
33  break;
34  case TMS320C64X_OP_MEM:
35  add_str(&result, " ; operands[%u].type: MEM", i);
36  if (op->mem.base != TMS320C64X_REG_INVALID)
37  add_str(&result, " ; operands[%u].mem.base: REG = %s", i, cs_reg_name(*handle, op->mem.base));
38  add_str(&result, " ; operands[%u].mem.disptype: ", i);
39  if (op->mem.disptype == TMS320C64X_MEM_DISP_INVALID) {
40  add_str(&result, "Invalid");
41  add_str(&result, " ; operands[%u].mem.disp: %u", i, op->mem.disp);
42  }
43  if (op->mem.disptype == TMS320C64X_MEM_DISP_CONSTANT) {
44  add_str(&result, "Constant");
45  add_str(&result, " ; operands[%u].mem.disp: %u", i, op->mem.disp);
46  }
47  if (op->mem.disptype == TMS320C64X_MEM_DISP_REGISTER) {
48  add_str(&result, "Register");
49  add_str(&result, " ; operands[%u].mem.disp: %s", i, cs_reg_name(*handle, op->mem.disp));
50  }
51  add_str(&result, " ; operands[%u].mem.unit: %u", i, op->mem.unit);
52  add_str(&result, " ; operands[%u].mem.direction: ", i);
53  if (op->mem.direction == TMS320C64X_MEM_DIR_INVALID)
54  add_str(&result, "Invalid");
55  if (op->mem.direction == TMS320C64X_MEM_DIR_FW)
56  add_str(&result, "Forward");
57  if (op->mem.direction == TMS320C64X_MEM_DIR_BW)
58  add_str(&result, "Backward");
59  add_str(&result, " ; operands[%u].mem.modify: ", i);
60  if (op->mem.modify == TMS320C64X_MEM_MOD_INVALID)
61  add_str(&result, "Invalid");
62  if (op->mem.modify == TMS320C64X_MEM_MOD_NO)
63  add_str(&result, "No");
64  if (op->mem.modify == TMS320C64X_MEM_MOD_PRE)
65  add_str(&result, "Pre");
66  if (op->mem.modify == TMS320C64X_MEM_MOD_POST)
67  add_str(&result, "Post");
68  add_str(&result, " ; operands[%u].mem.scaled: %u", i, op->mem.scaled);
69 
70  break;
72  add_str(&result, " ; operands[%u].type: REGPAIR = %s:%s", i, cs_reg_name(*handle, op->reg + 1), cs_reg_name(*handle, op->reg));
73  break;
74  }
75  }
76 
77  add_str(&result, " ; Functional unit: ");
78  switch(tms320c64x->funit.unit) {
79  case TMS320C64X_FUNIT_D:
80  add_str(&result, "D%u", tms320c64x->funit.side);
81  break;
82  case TMS320C64X_FUNIT_L:
83  add_str(&result, "L%u", tms320c64x->funit.side);
84  break;
85  case TMS320C64X_FUNIT_M:
86  add_str(&result, "M%u", tms320c64x->funit.side);
87  break;
88  case TMS320C64X_FUNIT_S:
89  add_str(&result, "S%u", tms320c64x->funit.side);
90  break;
92  add_str(&result, "No Functional Unit");
93  break;
94  default:
95  add_str(&result, "Unknown (Unit %u, Side %u)", tms320c64x->funit.unit, tms320c64x->funit.side);
96  break;
97  }
98  if (tms320c64x->funit.crosspath == 1)
99  add_str(&result, " ; Crosspath: 1");
100 
101  if (tms320c64x->condition.reg != TMS320C64X_REG_INVALID)
102  add_str(&result, " ; Condition: [%c%s]", (tms320c64x->condition.zero == 1) ? '!' : ' ', cs_reg_name(*handle, tms320c64x->condition.reg));
103  add_str(&result, " ; Parallel: %s", (tms320c64x->parallel == 1) ? "true" : "false");
104 
105  return result;
106 }
107 
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
TMS320C64X_FUNIT_S
@ TMS320C64X_FUNIT_S
Definition: tms320c64x.h:350
factory.h
cs_tms320c64x::side
unsigned int side
Definition: tms320c64x.h:73
cs_tms320c64x::unit
unsigned int unit
Definition: tms320c64x.h:72
TMS320C64X_MEM_DIR_INVALID
@ TMS320C64X_MEM_DIR_INVALID
Definition: tms320c64x.h:33
cs_tms320c64x::condition
struct cs_tms320c64x::@169 condition
mode
const char int mode
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
cs_tms320c64x::op_count
uint8_t op_count
Definition: tms320c64x.h:65
TMS320C64X_MEM_DIR_BW
@ TMS320C64X_MEM_DIR_BW
Definition: tms320c64x.h:35
TMS320C64X_MEM_MOD_NO
@ TMS320C64X_MEM_MOD_NO
Definition: tms320c64x.h:40
cs_tms320c64x
Definition: tms320c64x.h:64
cs_mode
cs_mode
Mode type.
Definition: capstone.h:103
TMS320C64X_MEM_MOD_POST
@ TMS320C64X_MEM_MOD_POST
Definition: tms320c64x.h:42
TMS320C64X_MEM_DISP_INVALID
@ TMS320C64X_MEM_DISP_INVALID
Definition: tms320c64x.h:27
TMS320C64X_OP_IMM
@ TMS320C64X_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: tms320c64x.h:21
cs_reg_name
const CAPSTONE_EXPORT char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
Definition: cs.c:1176
cs_tms320c64x::reg
unsigned int reg
Definition: tms320c64x.h:68
TMS320C64X_MEM_DISP_CONSTANT
@ TMS320C64X_MEM_DISP_CONSTANT
Definition: tms320c64x.h:28
TMS320C64X_MEM_DIR_FW
@ TMS320C64X_MEM_DIR_FW
Definition: tms320c64x.h:34
add_str
void add_str(char **src, const char *format,...)
Definition: helper.c:89
cs_tms320c64x_op
Definition: tms320c64x.h:55
TMS320C64X_MEM_DISP_REGISTER
@ TMS320C64X_MEM_DISP_REGISTER
Definition: tms320c64x.h:29
cs_tms320c64x::crosspath
unsigned int crosspath
Definition: tms320c64x.h:74
csh
size_t csh
Definition: capstone.h:71
TMS320C64X_FUNIT_L
@ TMS320C64X_FUNIT_L
Definition: tms320c64x.h:348
TMS320C64X_OP_MEM
@ TMS320C64X_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: tms320c64x.h:22
cs_tms320c64x::zero
unsigned int zero
Definition: tms320c64x.h:69
get_detail_tms320c64x
char * get_detail_tms320c64x(csh *handle, cs_mode mode, cs_insn *ins)
Definition: tms320c64x_detail.c:7
TMS320C64X_MEM_MOD_INVALID
@ TMS320C64X_MEM_MOD_INVALID
Definition: tms320c64x.h:39
cs_tms320c64x::parallel
unsigned int parallel
Definition: tms320c64x.h:76
TMS320C64X_FUNIT_D
@ TMS320C64X_FUNIT_D
Definition: tms320c64x.h:347
TMS320C64X_FUNIT_M
@ TMS320C64X_FUNIT_M
Definition: tms320c64x.h:349
handle
static csh handle
Definition: test_arm_regression.c:16
TMS320C64X_REG_INVALID
@ TMS320C64X_REG_INVALID
Definition: tms320c64x.h:80
TMS320C64X_OP_REG
@ TMS320C64X_OP_REG
= CS_OP_REG (Register operand).
Definition: tms320c64x.h:20
TMS320C64X_MEM_MOD_PRE
@ TMS320C64X_MEM_MOD_PRE
Definition: tms320c64x.h:41
TMS320C64X_FUNIT_NO
@ TMS320C64X_FUNIT_NO
Definition: tms320c64x.h:351
TMS320C64X_OP_REGPAIR
@ TMS320C64X_OP_REGPAIR
Register pair for double word ops.
Definition: tms320c64x.h:23
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
cs_tms320c64x::operands
cs_tms320c64x_op operands[8]
operands for this instruction.
Definition: tms320c64x.h:66
cs_tms320c64x::funit
struct cs_tms320c64x::@170 funit


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:39