Lines Matching refs:ops

27 static void ins__delete(struct ins_operands *ops)
29 free(ops->source.raw);
30 free(ops->source.name);
31 free(ops->target.raw);
32 free(ops->target.name);
36 struct ins_operands *ops)
38 return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
42 struct ins_operands *ops)
44 if (ins->ops->scnprintf)
45 return ins->ops->scnprintf(ins, bf, size, ops);
47 return ins__raw_scnprintf(ins, bf, size, ops);
50 static int call__parse(struct ins_operands *ops)
54 ops->target.addr = strtoull(ops->raw, &endptr, 16);
67 ops->target.name = strdup(name);
70 return ops->target.name == NULL ? -1 : 0;
75 ops->target.addr = 0;
83 ops->target.addr = strtoull(tok + 1, NULL, 16);
88 struct ins_operands *ops)
90 if (ops->target.name)
91 return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->target.name);
93 if (ops->target.addr == 0)
94 return ins__raw_scnprintf(ins, bf, size, ops);
96 return scnprintf(bf, size, "%-6.6s *%" PRIx64, ins->name, ops->target.addr);
106 return ins->ops == &call_ops;
109 static int jump__parse(struct ins_operands *ops)
111 const char *s = strchr(ops->raw, '+');
113 ops->target.addr = strtoull(ops->raw, NULL, 16);
116 ops->target.offset = strtoull(s, NULL, 16);
118 ops->target.offset = UINT64_MAX;
124 struct ins_operands *ops)
126 return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset);
136 return ins->ops == &jump_ops;
164 static int lock__parse(struct ins_operands *ops)
168 ops->locked.ops = zalloc(sizeof(*ops->locked.ops));
169 if (ops->locked.ops == NULL)
172 if (disasm_line__parse(ops->raw, &name, &ops->locked.ops->raw) < 0)
175 ops->locked.ins = ins__find(name);
176 if (ops->locked.ins == NULL)
179 if (!ops->locked.ins->ops)
182 if (ops->locked.ins->ops->parse)
183 ops->locked.ins->ops->parse(ops->locked.ops);
188 free(ops->locked.ops);
189 ops->locked.ops = NULL;
194 struct ins_operands *ops)
198 if (ops->locked.ins == NULL)
199 return ins__raw_scnprintf(ins, bf, size, ops);
202 return printed + ins__scnprintf(ops->locked.ins, bf + printed,
203 size - printed, ops->locked.ops);
206 static void lock__delete(struct ins_operands *ops)
208 free(ops->locked.ops);
209 free(ops->target.raw);
210 free(ops->target.name);
219 static int mov__parse(struct ins_operands *ops)
221 char *s = strchr(ops->raw, ','), *target, *comment, prev;
227 ops->source.raw = strdup(ops->raw);
230 if (ops->source.raw == NULL)
240 ops->target.raw = strdup(target);
243 if (ops->target.raw == NULL)
253 comment__symbol(ops->source.raw, comment, &ops->source.addr, &ops->source.name);
254 comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name);
259 free(ops->source.raw);
260 ops->source.raw = NULL;
265 struct ins_operands *ops)
268 ops->source.name ?: ops->source.raw,
269 ops->target.name ?: ops->target.raw);
277 static int dec__parse(struct ins_operands *ops)
281 target = s = ops->raw;
288 ops->target.raw = strdup(target);
291 if (ops->target.raw == NULL)
301 comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name);
307 struct ins_operands *ops)
310 ops->target.name ?: ops->target.raw);
319 struct ins_operands *ops __maybe_unused)
332 { .name = "add", .ops = &mov_ops, },
333 { .name = "addl", .ops = &mov_ops, },
334 { .name = "addq", .ops = &mov_ops, },
335 { .name = "addw", .ops = &mov_ops, },
336 { .name = "and", .ops = &mov_ops, },
337 { .name = "bts", .ops = &mov_ops, },
338 { .name = "call", .ops = &call_ops, },
339 { .name = "callq", .ops = &call_ops, },
340 { .name = "cmp", .ops = &mov_ops, },
341 { .name = "cmpb", .ops = &mov_ops, },
342 { .name = "cmpl", .ops = &mov_ops, },
343 { .name = "cmpq", .ops = &mov_ops, },
344 { .name = "cmpw", .ops = &mov_ops, },
345 { .name = "cmpxch", .ops = &mov_ops, },
346 { .name = "dec", .ops = &dec_ops, },
347 { .name = "decl", .ops = &dec_ops, },
348 { .name = "imul", .ops = &mov_ops, },
349 { .name = "inc", .ops = &dec_ops, },
350 { .name = "incl", .ops = &dec_ops, },
351 { .name = "ja", .ops = &jump_ops, },
352 { .name = "jae", .ops = &jump_ops, },
353 { .name = "jb", .ops = &jump_ops, },
354 { .name = "jbe", .ops = &jump_ops, },
355 { .name = "jc", .ops = &jump_ops, },
356 { .name = "jcxz", .ops = &jump_ops, },
357 { .name = "je", .ops = &jump_ops, },
358 { .name = "jecxz", .ops = &jump_ops, },
359 { .name = "jg", .ops = &jump_ops, },
360 { .name = "jge", .ops = &jump_ops, },
361 { .name = "jl", .ops = &jump_ops, },
362 { .name = "jle", .ops = &jump_ops, },
363 { .name = "jmp", .ops = &jump_ops, },
364 { .name = "jmpq", .ops = &jump_ops, },
365 { .name = "jna", .ops = &jump_ops, },
366 { .name = "jnae", .ops = &jump_ops, },
367 { .name = "jnb", .ops = &jump_ops, },
368 { .name = "jnbe", .ops = &jump_ops, },
369 { .name = "jnc", .ops = &jump_ops, },
370 { .name = "jne", .ops = &jump_ops, },
371 { .name = "jng", .ops = &jump_ops, },
372 { .name = "jnge", .ops = &jump_ops, },
373 { .name = "jnl", .ops = &jump_ops, },
374 { .name = "jnle", .ops = &jump_ops, },
375 { .name = "jno", .ops = &jump_ops, },
376 { .name = "jnp", .ops = &jump_ops, },
377 { .name = "jns", .ops = &jump_ops, },
378 { .name = "jnz", .ops = &jump_ops, },
379 { .name = "jo", .ops = &jump_ops, },
380 { .name = "jp", .ops = &jump_ops, },
381 { .name = "jpe", .ops = &jump_ops, },
382 { .name = "jpo", .ops = &jump_ops, },
383 { .name = "jrcxz", .ops = &jump_ops, },
384 { .name = "js", .ops = &jump_ops, },
385 { .name = "jz", .ops = &jump_ops, },
386 { .name = "lea", .ops = &mov_ops, },
387 { .name = "lock", .ops = &lock_ops, },
388 { .name = "mov", .ops = &mov_ops, },
389 { .name = "movb", .ops = &mov_ops, },
390 { .name = "movdqa",.ops = &mov_ops, },
391 { .name = "movl", .ops = &mov_ops, },
392 { .name = "movq", .ops = &mov_ops, },
393 { .name = "movslq", .ops = &mov_ops, },
394 { .name = "movzbl", .ops = &mov_ops, },
395 { .name = "movzwl", .ops = &mov_ops, },
396 { .name = "nop", .ops = &nop_ops, },
397 { .name = "nopl", .ops = &nop_ops, },
398 { .name = "nopw", .ops = &nop_ops, },
399 { .name = "or", .ops = &mov_ops, },
400 { .name = "orl", .ops = &mov_ops, },
401 { .name = "test", .ops = &mov_ops, },
402 { .name = "testb", .ops = &mov_ops, },
403 { .name = "testl", .ops = &mov_ops, },
404 { .name = "xadd", .ops = &mov_ops, },
405 { .name = "xbeginl", .ops = &jump_ops, },
406 { .name = "xbeginq", .ops = &jump_ops, },
501 if (!dl->ins->ops)
504 if (dl->ins->ops->parse)
505 dl->ins->ops->parse(&dl->ops);
557 if (disasm_line__parse(dl->line, &dl->name, &dl->ops.raw) < 0)
577 if (dl->ins && dl->ins->ops->free)
578 dl->ins->ops->free(&dl->ops);
580 ins__delete(&dl->ops);
587 return scnprintf(bf, size, "%-6.6s %s", dl->name, dl->ops.raw);
589 return ins__scnprintf(dl->ins, bf, size, &dl->ops);
757 * <offset> <name> <ops.raw>
761 * The ops.raw part will be parsed further according to type of the instruction.
824 if (dl->ops.target.offset == UINT64_MAX)
825 dl->ops.target.offset = dl->ops.target.addr -
832 if (dl->ins && ins__is_call(dl->ins) && !dl->ops.target.name) {
834 u64 ip = dl->ops.target.addr;
840 dl->ops.target.name = strdup(s->name);
858 if (dl->ins && dl->ins->ops) {
859 if (dl->ins->ops != &nop_ops)
1335 if (dl->ops.raw[0] != '\0') {
1337 dl->ops.raw);