Print this page
style fixes
comments; lint
take to dis and libdisasm with an axe; does not yet compile
@@ -25,10 +25,11 @@
*/
/*
* Copyright 2009 Jason King. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
*/
#include <sys/byteorder.h>
#include <stdarg.h>
@@ -696,18 +697,19 @@
*/
/* ARGSUSED1 */
int
fmt_call(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
int32_t disp;
size_t curlen;
int octal = ((dhp->dh_flags & DIS_OCTAL) != 0);
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f1.op, 2);
prt_field("disp30", f->f1.disp30, 30);
}
disp = sign_extend(f->f1.disp30, 30) * 4;
@@ -716,28 +718,29 @@
bprintf(dhp, (octal != 0) ? "%s0%-11lo" : "%s0x%-10lx",
(disp < 0) ? "-" : "+",
(disp < 0) ? (-disp) : disp);
- (void) strlcat(dhp->dh_buf, " <", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, " <", dhx->dhx_buflen);
- curlen = strlen(dhp->dh_buf);
+ curlen = strlen(dhx->dhx_buf);
dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp,
- dhp->dh_buf + curlen, dhp->dh_buflen - curlen - 1, NULL,
+ dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen - 1, NULL,
NULL);
- (void) strlcat(dhp->dh_buf, ">", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, ">", dhx->dhx_buflen);
return (0);
}
int
fmt_sethi(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f2.op, 2);
prt_field("op2", f->f2.op2, 3);
prt_field("rd", f->f2.rd, 5);
prt_field("imm22", f->f2.imm22, 22);
}
@@ -769,10 +772,11 @@
/* ARGSUSED3 */
int
fmt_branch(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
const char *name = inp->in_data.in_def.in_name;
const char *r = NULL;
const char *annul = "";
const char *pred = "";
@@ -783,11 +787,11 @@
size_t curlen;
int32_t disp;
uint32_t flags = inp->in_data.in_def.in_flags;
int octal = ((dhp->dh_flags & DIS_OCTAL) != 0);
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f2.op, 2);
prt_field("op2", f->f2.op2, 3);
switch (FLG_DISP_VAL(flags)) {
case DISP22:
@@ -814,11 +818,11 @@
break;
}
}
if (f->f2b.op2 == 0x01 && idx == 0x00 && f->f2b.p == 1 &&
- f->f2b.cc == 0x02 && ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) != 0)) {
+ f->f2b.cc == 0x02 && ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) != 0)) {
name = "iprefetch";
flags = FLG_RS1(REG_NONE)|FLG_DISP(DISP19);
}
@@ -852,11 +856,11 @@
if ((flags & FLG_PRED) != 0) {
if (f->f2b.p == 0) {
pred = ",pn";
} else {
- if ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0)
pred = ",pt";
}
}
(void) snprintf(buf, sizeof (buf), "%s%s%s", name, annul, pred);
@@ -886,15 +890,15 @@
(disp < 0) ? "-" : "+",
(disp < 0) ? (-disp) : disp);
break;
}
- curlen = strlen(dhp->dh_buf);
+ curlen = strlen(dhx->dhx_buf);
dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp,
- dhp->dh_buf + curlen, dhp->dh_buflen - curlen - 1, NULL, NULL);
+ dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen - 1, NULL, NULL);
- (void) strlcat(dhp->dh_buf, ">", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, ">", dhx->dhx_buflen);
return (0);
}
@@ -913,17 +917,18 @@
* casxa [%rs1]#ASI_P_L, %rs2, %rd -> casxl [%rs1], %rs2, %rd
*/
static int
fmt_cas(dis_handle_t *dhp, uint32_t instr, const char *name)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
const char *asistr = NULL;
int noasi = 0;
asistr = get_asi_name(f->f3.asi);
- if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) != 0) {
+ if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) != 0) {
if (f->f3.op3 == 0x3c && f->f3.i == 0) {
if (f->f3.asi == 0x80) {
noasi = 1;
name = "cas";
}
@@ -950,11 +955,11 @@
prt_name(dhp, name, 1);
bprintf(dhp, "[%s]", reg_names[f->f3.rs1]);
if (noasi == 0) {
- (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
prt_asi(dhp, instr);
}
bprintf(dhp, ", %s, %s", reg_names[f->f3.rs2], reg_names[f->f3.rd]);
@@ -997,18 +1002,19 @@
* sttw -> st
*/
int
fmt_ls(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
const char *regstr = NULL;
const char *asistr = NULL;
const char *iname = inp->in_data.in_def.in_name;
uint32_t flags = inp->in_data.in_def.in_flags;
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f3.op, 2);
prt_field("op3", f->f3.op3, 6);
prt_field("rs1", f->f3.rs1, 5);
prt_field("i", f->f3.i, 1);
if (f->f3.i != 0) {
@@ -1027,20 +1033,20 @@
prt_name(dhp, iname, 1);
prt_address(dhp, instr, 0);
if (idx == 0x3d) {
- (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
prt_asi(dhp, instr);
}
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
/* fcn field is the same as rd */
if (prefetch_str[f->f3.rd] != NULL)
- (void) strlcat(dhp->dh_buf, prefetch_str[f->f3.rd],
- dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, prefetch_str[f->f3.rd],
+ dhx->dhx_buflen);
else
prt_imm(dhp, f->f3.rd, 0);
if (idx == 0x3d && f->f3.i == 0) {
asistr = get_asi_name(f->f3.asi);
@@ -1057,22 +1063,22 @@
/* synthetic instructions & special cases */
switch (idx) {
case 0x00:
/* ld */
- if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
iname = "lduw";
break;
case 0x03:
- if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
iname = "ldtw";
break;
case 0x04:
/* stw */
- if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
iname = "stuw";
if ((dhp->dh_flags & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
== 0)
break;
@@ -1106,11 +1112,11 @@
flags = FLG_RD(REG_NONE);
}
break;
case 0x07:
- if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
iname = "sttw";
break;
case 0x0e:
/* stx */
@@ -1125,18 +1131,18 @@
}
break;
case 0x13:
/* ldtwa */
- if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) &&
+ if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) &&
((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0))
iname = "ldtwa";
break;
case 0x17:
/* sttwa */
- if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) &&
+ if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) &&
((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0))
iname = "sttwa";
break;
case 0x21:
@@ -1210,29 +1216,29 @@
prt_name(dhp, iname, 1);
if ((flags & FLG_STORE) != 0) {
if (regstr[0] != '\0') {
- (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen);
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
}
prt_address(dhp, instr, 0);
if ((flags & FLG_ASI) != 0) {
- (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
prt_asi(dhp, instr);
}
} else {
prt_address(dhp, instr, 0);
if ((flags & FLG_ASI) != 0) {
- (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
prt_asi(dhp, instr);
}
if (regstr[0] != '\0') {
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
- (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
+ (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen);
}
}
if ((flags & FLG_ASI) != 0 && asistr != NULL)
bprintf(dhp, "\t<%s>", asistr);
@@ -1241,14 +1247,15 @@
}
static int
fmt_cpop(dis_handle_t *dhp, uint32_t instr, const inst_t *inp)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
int flags = FLG_P1(REG_CP)|FLG_P2(REG_CP)|FLG_NOIMM|FLG_P3(REG_CP);
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->fcp.op, 2);
prt_field("op3", f->fcp.op3, 6);
prt_field("opc", f->fcp.opc, 9);
prt_field("rs1", f->fcp.rs1, 5);
prt_field("rs2", f->fcp.rs2, 5);
@@ -1256,19 +1263,20 @@
}
prt_name(dhp, inp->in_data.in_def.in_name, 1);
prt_imm(dhp, f->fcp.opc, 0);
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
(void) prt_aluargs(dhp, instr, flags);
return (0);
}
static int
dis_fmt_rdwr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
const char *psr_str = "%psr";
const char *wim_str = "%wim";
const char *tbr_str = "%tbr";
const char *name = inp->in_data.in_def.in_name;
@@ -1390,11 +1398,11 @@
IMM_SIGNED);
return (0);
}
/* synth: mov */
- if ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
+ if ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
== 0)
break;
if (v9 == 0) {
if (f->f3.rs1 == 0) {
@@ -1462,25 +1470,26 @@
if (pr_rs2 != 0) {
if (f->f3.i == 1)
prt_imm(dhp, sign_extend(f->f3a.simm13, 13),
IMM_SIGNED);
else
- (void) strlcat(dhp->dh_buf,
- reg_names[f->f3.rs2], dhp->dh_buflen);
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf,
+ reg_names[f->f3.rs2], dhx->dhx_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
}
- (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen);
}
return (0);
}
/* ARGSUSED3 */
int
fmt_trap(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
int v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0);
int p_rs1, p_t;
@@ -1495,11 +1504,11 @@
if (f->ftcc2.i == 0 && f->ftcc2.undef2 != 0)
return (-1);
p_rs1 = ((f->ftcc.rs1 != 0) ||
- ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0));
+ ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0));
if (f->ftcc.i == 0) {
p_t = (f->f3.rs2 != 0 || p_rs1 == 0);
bprintf(dhp, "%-9s %s%s%s%s%s", inp->in_data.in_def.in_name,
@@ -1553,14 +1562,15 @@
/* ARGSUSED3 */
static int
prt_jmpl(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
const char *name = inp->in_data.in_def.in_name;
ifmt_t *f = (ifmt_t *)&instr;
- if (f->f3.rd == 15 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0))
+ if (f->f3.rd == 15 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0))
name = "call";
if (f->f3.rd == 0) {
if (f->f3.i == 1 && f->f3a.simm13 == 8) {
if (f->f3.rs1 == 15) {
@@ -1581,11 +1591,11 @@
prt_address(dhp, instr, 1);
if (f->f3.rd == 0)
return (0);
- if (f->f3.rd == 15 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0))
+ if (f->f3.rd == 15 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0))
return (0);
bprintf(dhp, ", %s", reg_names[f->f3.rd]);
return (0);
@@ -1592,17 +1602,18 @@
}
int
fmt_alu(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
const char *name = inp->in_data.in_def.in_name;
int flags = inp->in_data.in_def.in_flags;
int arg = 0;
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f3.op, 2);
prt_field("op3", f->f3.op3, 6);
prt_field("rs1", f->f3.rs1, 5);
switch (idx) {
@@ -1621,11 +1632,11 @@
switch (idx) {
case 0x00:
/* add */
- if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0)
break;
if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
f->f3a.simm13 == 1) {
name = "inc";
@@ -1642,15 +1653,15 @@
break;
case 0x02:
/* or */
- if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
+ if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
== 0)
break;
- if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) != 0) {
if (f->f3.rs1 == f->f3.rd) {
name = "bset";
flags = FLG_P1(REG_NONE);
break;
}
@@ -1672,11 +1683,11 @@
break;
case 0x04:
/* sub */
- if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
+ if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
== 0)
break;
if (f->f3.rs1 == 0 && f->f3.i == 0 && f->f3.rs2 == f->f3.rd) {
name = "neg";
@@ -1688,11 +1699,11 @@
name = "neg";
flags = FLG_P1(REG_NONE);
break;
}
- if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0)
break;
if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
f->f3a.simm13 == 1) {
name = "dec";
@@ -1709,11 +1720,11 @@
break;
case 0x07:
/* xnor */
- if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
+ if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
== 0)
break;
/*
* xnor -> not when you have:
@@ -1735,11 +1746,11 @@
break;
case 0x10:
/* addcc */
- if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0)
break;
if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
f->f3a.simm13 == 1) {
name = "inccc";
@@ -1759,15 +1770,15 @@
/* andcc */
if (f->f3.rd != 0)
break;
- if ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
+ if ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
== 0)
break;
- if (((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0) &&
+ if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0) &&
((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) == 0))
break;
name = "btst";
flags = FLG_P1(REG_NONE);
@@ -1775,11 +1786,11 @@
break;
case 0x12:
/* orcc */
- if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
+ if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
== 0)
break;
if (f->f3.rs1 == 0 && f->f3.rd == 0 && f->f3.i == 0) {
name = "tst";
@@ -1796,21 +1807,21 @@
break;
case 0x14:
/* subcc */
- if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
+ if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
== 0)
break;
if (f->f3.rd == 0) {
name = "cmp";
flags = FLG_P3(REG_NONE);
break;
}
- if ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0)
break;
if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
f->f3a.simm13 == 1) {
name = "deccc";
@@ -1866,18 +1877,18 @@
return (0);
case 0x3c:
case 0x3d:
/* save / restore */
- if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
+ if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
== 0)
break;
if (f->f3.rs1 != 0 || f->f3.rs2 != 0 || f->f3.rd != 0)
break;
- if (f->f3.i != 0 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0))
+ if (f->f3.i != 0 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0))
break;
prt_name(dhp, name, 0);
return (0);
}
@@ -1917,14 +1928,15 @@
/* ARGSUSED3 */
int
fmt_movcc(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
const char **regs = NULL;
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f3c.op, 2);
prt_field("op3", f->f3c.op3, 6);
prt_field("cond", f->f3c.cond, 4);
prt_field("cc2", f->f3c.cc2, 1);
prt_field("cc", f->f3c.cc, 2);
@@ -1951,12 +1963,12 @@
bprintf(dhp, "%s, ", regs[f->f3c.cc]);
if (f->f3c.i == 1)
prt_imm(dhp, sign_extend(f->f3c.simm11, 11), IMM_SIGNED);
else
- (void) strlcat(dhp->dh_buf, reg_names[f->f3.rs2],
- dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, reg_names[f->f3.rs2],
+ dhx->dhx_buflen);
bprintf(dhp, ", %s", reg_names[f->f3.rd]);
return (0);
}
@@ -1963,21 +1975,22 @@
/* ARGSUSED3 */
int
fmt_movr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
prt_name(dhp, inp->in_data.in_def.in_name, 1);
bprintf(dhp, "%s, ", reg_names[f->f3d.rs1]);
if (f->f3d.i == 1)
prt_imm(dhp, sign_extend(f->f3d.simm10, 10), IMM_SIGNED);
else
- (void) strlcat(dhp->dh_buf, reg_names[f->f3.rs2],
- dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, reg_names[f->f3.rs2],
+ dhx->dhx_buflen);
bprintf(dhp, ", %s", reg_names[f->f3.rd]);
return (0);
}
@@ -1984,16 +1997,17 @@
/* ARGSUSED3 */
int
fmt_fpop1(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
int flags = inp->in_data.in_def.in_flags;
flags |= FLG_NOIMM;
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f3.op, 2);
prt_field("op3", f->f3.op3, 6);
prt_field("opf", f->fcmp.opf, 9);
prt_field("rs1", f->f3.rs1, 5);
prt_field("rs2", f->f3.rs2, 5);
@@ -2017,26 +2031,27 @@
static const char *condstr_fcc[16] = {
"n", "nz", "lg", "ul", "l", "ug", "g", "u",
"a", "e", "ue", "ge", "uge", "le", "ule", "o"
};
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
const char *ccstr = "";
char name[15];
int flags = inp->in_data.in_def.in_flags;
int is_cmp = (idx == 0x51 || idx == 0x52 || idx == 0x53 ||
idx == 0x55 || idx == 0x56 || idx == 0x57);
int is_fmov = (idx & 0x3f);
int is_v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0);
- int is_compat = ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0);
+ int is_compat = ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0);
int p_cc = 0;
is_fmov = (is_fmov == 0x1 || is_fmov == 0x2 || is_fmov == 0x3);
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f3.op, 2);
prt_field("op3", f->f3.op3, 6);
prt_field("opf", f->fcmp.opf, 9);
switch (idx & 0x3f) {
@@ -2102,14 +2117,15 @@
}
int
fmt_vis(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
int flags = inp->in_data.in_def.in_flags;
- if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
+ if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
prt_field("op", f->f3.op, 2);
prt_field("op3", f->f3.op3, 6);
prt_field("opf", f->fcmp.opf, 9);
if (idx == 0x081) {
@@ -2249,10 +2265,11 @@
* such as with the %icc/%xcc sets
*/
static const char *
get_regname(dis_handle_t *dhp, int regset, uint32_t idx)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
const char *regname = NULL;
switch (regset) {
case REG_INT:
regname = reg_names[idx];
@@ -2261,20 +2278,20 @@
case REG_FP:
regname = freg_names[idx];
break;
case REG_FPD:
- if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) ||
+ if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) ||
((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0))
regname = fdreg_names[idx];
else
regname = compat_fdreg_names[idx];
break;
case REG_FPQ:
- if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
+ if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
regname = fqreg_names[idx];
else
regname = freg_names[idx];
break;
@@ -2348,15 +2365,16 @@
* [%g0] is output
*/
static void
prt_address(dis_handle_t *dhp, uint32_t instr, int nobrackets)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
int32_t simm13;
int octal = ((dhp->dh_flags & DIS_OCTAL) != 0);
- int p1 = ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
- int p2 = ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
+ int p1 = ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
+ int p2 = ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
if (f->f3a.i == 0) {
p1 |= ((f->f3a.rs1 != 0) || f->f3.rs2 == 0);
p2 |= (f->f3.rs2 != 0);
@@ -2419,10 +2437,11 @@
* floating point operations
*/
static void
prt_aluargs(dis_handle_t *dhp, uint32_t instr, uint32_t flags)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
ifmt_t *f = (ifmt_t *)&instr;
const char *r1, *r2, *r3;
int p1, p2, p3;
unsigned int opf = 0;
@@ -2445,34 +2464,34 @@
if ((f->fcmp.op == 2) && (f->fcmp.op3 == 0x36) && (f->fcmp.cc != 0))
opf = f->fcmp.opf;
if ((opf == 0x151) || (opf == 0x152)) {
- (void) strlcat(dhp->dh_buf, r3, dhp->dh_buflen);
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, r3, dhx->dhx_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
p3 = 0;
}
if (p1 != 0) {
- (void) strlcat(dhp->dh_buf, r1, dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, r1, dhx->dhx_buflen);
if (p2 != 0 || p3 != 0)
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
}
if (p2 != 0) {
if (f->f3.i == 0 || ((flags & FLG_NOIMM) != 0))
- (void) strlcat(dhp->dh_buf, r2, dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, r2, dhx->dhx_buflen);
else
prt_imm(dhp, sign_extend(f->f3a.simm13, 13),
IMM_SIGNED);
if (p3 != 0)
- (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
}
if (p3 != 0)
- (void) strlcat(dhp->dh_buf, r3, dhp->dh_buflen);
+ (void) strlcat(dhx->dhx_buf, r3, dhx->dhx_buflen);
}
static const char *
get_asi_name(uint8_t asi)
{
@@ -2740,15 +2759,16 @@
* PRINTF LIKE 1
*/
static void
bprintf(dis_handle_t *dhp, const char *fmt, ...)
{
+ dis_handle_sparc_t *dhx = dhp->dh_arch_private;
size_t curlen;
va_list ap;
- curlen = strlen(dhp->dh_buf);
+ curlen = strlen(dhx->dhx_buf);
va_start(ap, fmt);
- (void) vsnprintf(dhp->dh_buf + curlen, dhp->dh_buflen - curlen, fmt,
+ (void) vsnprintf(dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen, fmt,
ap);
va_end(ap);
}