Print this page
patch fix-lint
3317 dis(1) should support cross-target disassembly

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdisasm/sparc/dis_sparc_fmt.c
          +++ new/usr/src/lib/libdisasm/common/dis_sparc_fmt.c
↓ open down ↓ 19 lines elided ↑ open up ↑
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28   28   * Copyright 2009 Jason King.  All rights reserved.
  29   29   * Use is subject to license terms.
       30 + * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
  30   31   */
  31   32  
  32   33  
  33   34  #include <sys/byteorder.h>
  34   35  #include <stdarg.h>
  35   36  
  36   37  #if !defined(DIS_STANDALONE)
  37   38  #include <stdio.h>
  38   39  #endif /* DIS_STANDALONE */
  39   40  
↓ open down ↓ 1 lines elided ↑ open up ↑
  41   42  #include "libdisasm_impl.h"
  42   43  #include "dis_sparc.h"
  43   44  #include "dis_sparc_fmt.h"
  44   45  
  45   46  extern char *strncpy(char *, const char *, size_t);
  46   47  extern size_t strlen(const char *);
  47   48  extern int strcmp(const char *, const char *);
  48   49  extern int strncmp(const char *, const char *, size_t);
  49   50  extern size_t strlcat(char *, const char *, size_t);
  50   51  extern size_t strlcpy(char *, const char *, size_t);
  51      -extern int snprintf(char *, size_t, const char *, ...);
  52      -extern int vsnprintf(char *, size_t, const char *, va_list);
  53   52  
  54   53  /*
  55   54   * This file has the functions that do all the dirty work of outputting the
  56   55   * disassembled instruction
  57   56   *
  58   57   * All the non-static functions follow the format_fcn (in dis_sparc.h):
  59   58   * Input:
  60   59   *      disassembler handle/context
  61   60   *      instruction to disassemble
  62   61   *      instruction definition pointer (inst_t *)
↓ open down ↓ 628 lines elided ↑ open up ↑
 691  690  
 692  691  
 693  692  /*
 694  693   * print out a call instruction
 695  694   * format: call address  <name>
 696  695   */
 697  696  /* ARGSUSED1 */
 698  697  int
 699  698  fmt_call(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
 700  699  {
      700 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
 701  701          ifmt_t *f = (ifmt_t *)&instr;
 702  702  
 703  703          int32_t disp;
 704  704          size_t curlen;
 705  705  
 706  706          int octal = ((dhp->dh_flags & DIS_OCTAL) != 0);
 707  707  
 708      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
      708 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
 709  709                  prt_field("op", f->f1.op, 2);
 710  710                  prt_field("disp30", f->f1.disp30, 30);
 711  711          }
 712  712  
 713  713          disp = sign_extend(f->f1.disp30, 30) * 4;
 714  714  
 715  715          prt_name(dhp, inp->in_data.in_def.in_name, 1);
 716  716  
 717  717          bprintf(dhp, (octal != 0) ? "%s0%-11lo" : "%s0x%-10lx",
 718  718              (disp < 0) ? "-" : "+",
 719  719              (disp < 0) ? (-disp) : disp);
 720  720  
 721      -        (void) strlcat(dhp->dh_buf, " <", dhp->dh_buflen);
      721 +        (void) strlcat(dhx->dhx_buf, " <", dhx->dhx_buflen);
 722  722  
 723      -        curlen = strlen(dhp->dh_buf);
      723 +        curlen = strlen(dhx->dhx_buf);
 724  724          dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp,
 725      -            dhp->dh_buf + curlen, dhp->dh_buflen - curlen - 1, NULL,
      725 +            dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen - 1, NULL,
 726  726              NULL);
 727      -        (void) strlcat(dhp->dh_buf, ">", dhp->dh_buflen);
      727 +        (void) strlcat(dhx->dhx_buf, ">", dhx->dhx_buflen);
 728  728  
 729  729  
 730  730          return (0);
 731  731  }
 732  732  
 733  733  int
 734  734  fmt_sethi(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
 735  735  {
      736 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
 736  737          ifmt_t *f = (ifmt_t *)&instr;
 737  738  
 738      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
      739 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
 739  740                  prt_field("op", f->f2.op, 2);
 740  741                  prt_field("op2", f->f2.op2, 3);
 741  742                  prt_field("rd", f->f2.rd, 5);
 742  743                  prt_field("imm22", f->f2.imm22, 22);
 743  744          }
 744  745  
 745  746          if (idx == 0) {
 746  747                  /* unimp / illtrap */
 747  748                  prt_name(dhp, inp->in_data.in_def.in_name, 1);
 748  749                  prt_imm(dhp, f->f2.imm22, 0);
↓ open down ↓ 15 lines elided ↑ open up ↑
 764  765              f->f2.imm22 << 10,
 765  766              reg_names[f->f2.rd]);
 766  767  
 767  768          return (0);
 768  769  }
 769  770  
 770  771  /* ARGSUSED3 */
 771  772  int
 772  773  fmt_branch(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
 773  774  {
      775 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
 774  776          const char *name = inp->in_data.in_def.in_name;
 775  777          const char *r = NULL;
 776  778          const char *annul = "";
 777  779          const char *pred  = "";
 778  780  
 779  781          char buf[15];
 780  782  
 781  783          ifmt_t *f = (ifmt_t *)&instr;
 782  784  
 783  785          size_t curlen;
 784  786          int32_t disp;
 785  787          uint32_t flags = inp->in_data.in_def.in_flags;
 786  788          int octal = ((dhp->dh_flags & DIS_OCTAL) != 0);
 787  789  
 788      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
      790 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
 789  791                  prt_field("op", f->f2.op, 2);
 790  792                  prt_field("op2", f->f2.op2, 3);
 791  793  
 792  794                  switch (FLG_DISP_VAL(flags)) {
 793  795                  case DISP22:
 794  796                          prt_field("cond", f->f2a.cond, 4);
 795  797                          prt_field("a", f->f2a.a, 1);
 796  798                          prt_field("disp22", f->f2a.disp22, 22);
 797  799                          break;
 798  800  
↓ open down ↓ 10 lines elided ↑ open up ↑
 809  811                          prt_field("rcond", f->f2c.cond, 3);
 810  812                          prt_field("p", f->f2c.p, 1);
 811  813                          prt_field("rs1", f->f2c.rs1, 5);
 812  814                          prt_field("d16hi", f->f2c.d16hi, 2);
 813  815                          prt_field("d16lo", f->f2c.d16lo, 14);
 814  816                          break;
 815  817                  }
 816  818          }
 817  819  
 818  820          if (f->f2b.op2 == 0x01 && idx == 0x00 && f->f2b.p == 1 &&
 819      -            f->f2b.cc == 0x02 && ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) != 0)) {
      821 +            f->f2b.cc == 0x02 && ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) != 0)) {
 820  822                  name = "iprefetch";
 821  823                  flags = FLG_RS1(REG_NONE)|FLG_DISP(DISP19);
 822  824          }
 823  825  
 824  826  
 825  827          switch (FLG_DISP_VAL(flags)) {
 826  828          case DISP22:
 827  829                  disp = sign_extend(f->f2a.disp22, 22);
 828  830                  break;
 829  831  
↓ open down ↓ 17 lines elided ↑ open up ↑
 847  849          if (r == NULL)
 848  850                  return (-1);
 849  851  
 850  852          if (f->f2a.a == 1)
 851  853                  annul = ",a";
 852  854  
 853  855          if ((flags & FLG_PRED) != 0) {
 854  856                  if (f->f2b.p == 0) {
 855  857                          pred = ",pn";
 856  858                  } else {
 857      -                        if ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0)
      859 +                        if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0)
 858  860                                  pred = ",pt";
 859  861                  }
 860  862          }
 861  863  
 862      -        (void) snprintf(buf, sizeof (buf), "%s%s%s", name, annul, pred);
      864 +        (void) dis_snprintf(buf, sizeof (buf), "%s%s%s", name, annul, pred);
 863  865          prt_name(dhp, buf, 1);
 864  866  
 865  867  
 866  868          switch (FLG_DISP_VAL(flags)) {
 867  869          case DISP22:
 868  870                  bprintf(dhp,
 869  871                      (octal != 0) ? "%s0%-11lo <" : "%s0x%-10lx <",
 870  872                      (disp < 0) ? "-" : "+",
 871  873                      (disp < 0) ? (-disp) : disp);
 872  874                  break;
↓ open down ↓ 8 lines elided ↑ open up ↑
 881  883  
 882  884          case DISP16:
 883  885                  bprintf(dhp,
 884  886                      (octal != 0) ? "%s, %s0%-6lo <" : "%s, %s0x%-5lx <",
 885  887                      r,
 886  888                      (disp < 0) ? "-" : "+",
 887  889                      (disp < 0) ? (-disp) : disp);
 888  890                  break;
 889  891          }
 890  892  
 891      -        curlen = strlen(dhp->dh_buf);
      893 +        curlen = strlen(dhx->dhx_buf);
 892  894          dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp,
 893      -            dhp->dh_buf + curlen, dhp->dh_buflen - curlen - 1, NULL, NULL);
      895 +            dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen - 1, NULL, NULL);
 894  896  
 895      -        (void) strlcat(dhp->dh_buf, ">", dhp->dh_buflen);
      897 +        (void) strlcat(dhx->dhx_buf, ">", dhx->dhx_buflen);
 896  898  
 897  899          return (0);
 898  900  }
 899  901  
 900  902  
 901  903  
 902  904  /*
 903  905   * print out the compare and swap instructions (casa/casxa)
 904  906   * format: casa/casxa [%rs1] imm_asi, %rs2, %rd
 905  907   *          casa/casxa [%rs1] %asi, %rs2, %rd
↓ open down ↓ 2 lines elided ↑ open up ↑
 908  910   * when an immediate ASI value is given as follows:
 909  911   *
 910  912   * casa  [%rs1]#ASI_P, %rs2, %rd    -> cas   [%rs1], %rs2, %rd
 911  913   * casa  [%rs1]#ASI_P_L, %rs2, %rd  -> casl  [%rs1], %rs2, %rd
 912  914   * casxa [%rs1]#ASI_P, %rs2, %rd    -> casx  [%rs1], %rs2, %rd
 913  915   * casxa [%rs1]#ASI_P_L, %rs2, %rd  -> casxl [%rs1], %rs2, %rd
 914  916   */
 915  917  static int
 916  918  fmt_cas(dis_handle_t *dhp, uint32_t instr, const char *name)
 917  919  {
      920 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
 918  921          ifmt_t *f = (ifmt_t *)&instr;
 919  922          const char *asistr = NULL;
 920  923          int noasi = 0;
 921  924  
 922  925          asistr = get_asi_name(f->f3.asi);
 923  926  
 924      -        if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) != 0) {
      927 +        if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) != 0) {
 925  928                  if (f->f3.op3 == 0x3c && f->f3.i == 0) {
 926  929                          if (f->f3.asi == 0x80) {
 927  930                                  noasi = 1;
 928  931                                  name = "cas";
 929  932                          }
 930  933  
 931  934                          if (f->f3.asi == 0x88) {
 932  935                                  noasi = 1;
 933  936                                  name = "casl";
 934  937                          }
↓ open down ↓ 10 lines elided ↑ open up ↑
 945  948                                  name = "casxl";
 946  949                          }
 947  950                  }
 948  951          }
 949  952  
 950  953          prt_name(dhp, name, 1);
 951  954  
 952  955          bprintf(dhp, "[%s]", reg_names[f->f3.rs1]);
 953  956  
 954  957          if (noasi == 0) {
 955      -                (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
      958 +                (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
 956  959                  prt_asi(dhp, instr);
 957  960          }
 958  961  
 959  962          bprintf(dhp, ", %s, %s", reg_names[f->f3.rs2], reg_names[f->f3.rd]);
 960  963  
 961  964          if (noasi == 0 && asistr != NULL)
 962  965                  bprintf(dhp, "\t<%s>", asistr);
 963  966  
 964  967          return (0);
 965  968  }
↓ open down ↓ 26 lines elided ↑ open up ↑
 992  995   *
 993  996   * If DIS_DEBUG_COMPAT is set, the following substitutions also take place
 994  997   *      lduw -> ld
 995  998   *      ldtw -> ld
 996  999   *      stuw -> st
 997 1000   *      sttw -> st
 998 1001   */
 999 1002  int
1000 1003  fmt_ls(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1001 1004  {
     1005 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1002 1006          ifmt_t *f = (ifmt_t *)&instr;
1003 1007          const char *regstr = NULL;
1004 1008          const char *asistr = NULL;
1005 1009  
1006 1010          const char *iname = inp->in_data.in_def.in_name;
1007 1011          uint32_t flags = inp->in_data.in_def.in_flags;
1008 1012  
1009      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
     1013 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
1010 1014                  prt_field("op", f->f3.op, 2);
1011 1015                  prt_field("op3", f->f3.op3, 6);
1012 1016                  prt_field("rs1", f->f3.rs1, 5);
1013 1017                  prt_field("i", f->f3.i, 1);
1014 1018                  if (f->f3.i != 0) {
1015 1019                          prt_field("simm13", f->f3a.simm13, 13);
1016 1020                  } else {
1017 1021                          if ((flags & FLG_ASI) != 0)
1018 1022                                  prt_field("imm_asi", f->f3.asi, 8);
1019 1023                          prt_field("rs2", f->f3.rs2, 5);
↓ open down ↓ 2 lines elided ↑ open up ↑
1022 1026          }
1023 1027  
1024 1028          if (idx == 0x2d || idx == 0x3d) {
1025 1029                  /* prefetch / prefetcha */
1026 1030  
1027 1031                  prt_name(dhp, iname, 1);
1028 1032  
1029 1033                  prt_address(dhp, instr, 0);
1030 1034  
1031 1035                  if (idx == 0x3d) {
1032      -                        (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
     1036 +                        (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
1033 1037                          prt_asi(dhp, instr);
1034 1038                  }
1035 1039  
1036      -                (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
     1040 +                (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
1037 1041  
1038 1042                  /* fcn field is the same as rd */
1039 1043                  if (prefetch_str[f->f3.rd] != NULL)
1040      -                        (void) strlcat(dhp->dh_buf, prefetch_str[f->f3.rd],
1041      -                            dhp->dh_buflen);
     1044 +                        (void) strlcat(dhx->dhx_buf, prefetch_str[f->f3.rd],
     1045 +                            dhx->dhx_buflen);
1042 1046                  else
1043 1047                          prt_imm(dhp, f->f3.rd, 0);
1044 1048  
1045 1049                  if (idx == 0x3d && f->f3.i == 0) {
1046 1050                          asistr = get_asi_name(f->f3.asi);
1047 1051                          if (asistr != NULL)
1048 1052                                  bprintf(dhp, "\t<%s>", asistr);
1049 1053                  }
1050 1054  
1051 1055                  return (0);
1052 1056          }
1053 1057  
1054 1058          /* casa / casxa */
1055 1059          if (idx == 0x3c || idx == 0x3e)
1056 1060                  return (fmt_cas(dhp, instr, iname));
1057 1061  
1058 1062          /* synthetic instructions & special cases */
1059 1063          switch (idx) {
1060 1064          case 0x00:
1061 1065                  /* ld */
1062      -                if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
     1066 +                if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
1063 1067                          iname = "lduw";
1064 1068                  break;
1065 1069  
1066 1070          case 0x03:
1067      -                if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
     1071 +                if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
1068 1072                          iname = "ldtw";
1069 1073                  break;
1070 1074  
1071 1075          case 0x04:
1072 1076                  /* stw */
1073      -                if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
     1077 +                if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
1074 1078                          iname = "stuw";
1075 1079  
1076 1080                  if ((dhp->dh_flags & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
1077 1081                      == 0)
1078 1082                          break;
1079 1083  
1080 1084                  if (f->f3.rd == 0) {
1081 1085                          iname = "clr";
1082 1086                          flags = FLG_RD(REG_NONE);
1083 1087                  }
↓ open down ↓ 17 lines elided ↑ open up ↑
1101 1105                      == 0)
1102 1106                          break;
1103 1107  
1104 1108                  if (f->f3.rd == 0) {
1105 1109                          iname = "clrh";
1106 1110                          flags = FLG_RD(REG_NONE);
1107 1111                  }
1108 1112                  break;
1109 1113  
1110 1114          case 0x07:
1111      -                if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
     1115 +                if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
1112 1116                          iname = "sttw";
1113 1117                  break;
1114 1118  
1115 1119          case 0x0e:
1116 1120                  /* stx */
1117 1121  
1118 1122                  if ((dhp->dh_flags & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
1119 1123                      == 0)
1120 1124                          break;
1121 1125  
1122 1126                  if (f->f3.rd == 0) {
1123 1127                          iname = "clrx";
1124 1128                          flags = FLG_RD(REG_NONE);
1125 1129                  }
1126 1130                  break;
1127 1131  
1128 1132          case 0x13:
1129 1133                  /* ldtwa */
1130      -                if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) &&
     1134 +                if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) &&
1131 1135                      ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0))
1132 1136                          iname = "ldtwa";
1133 1137                  break;
1134 1138  
1135 1139          case 0x17:
1136 1140                  /* sttwa */
1137      -                if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) &&
     1141 +                if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) &&
1138 1142                      ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0))
1139 1143                          iname = "sttwa";
1140 1144                  break;
1141 1145  
1142 1146          case 0x21:
1143 1147          case 0x25:
1144 1148                  /*
1145 1149                   * on sparcv8 it merely says that rd != 1 should generate an
1146 1150                   * exception, on v9, it is illegal
1147 1151                   */
↓ open down ↓ 57 lines elided ↑ open up ↑
1205 1209  
1206 1210          regstr = get_regname(dhp, FLG_RD_VAL(flags), f->f3.rd);
1207 1211  
1208 1212          if (f->f3.i == 0)
1209 1213                  asistr = get_asi_name(f->f3.asi);
1210 1214  
1211 1215          prt_name(dhp, iname, 1);
1212 1216  
1213 1217          if ((flags & FLG_STORE) != 0) {
1214 1218                  if (regstr[0] != '\0') {
1215      -                        (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen);
1216      -                        (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
     1219 +                        (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen);
     1220 +                        (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
1217 1221                  }
1218 1222  
1219 1223                  prt_address(dhp, instr, 0);
1220 1224                  if ((flags & FLG_ASI) != 0) {
1221      -                        (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
     1225 +                        (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
1222 1226                          prt_asi(dhp, instr);
1223 1227                  }
1224 1228          } else {
1225 1229                  prt_address(dhp, instr, 0);
1226 1230                  if ((flags & FLG_ASI) != 0) {
1227      -                        (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen);
     1231 +                        (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen);
1228 1232                          prt_asi(dhp, instr);
1229 1233                  }
1230 1234  
1231 1235                  if (regstr[0] != '\0') {
1232      -                        (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
1233      -                        (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen);
     1236 +                        (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
     1237 +                        (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen);
1234 1238                  }
1235 1239          }
1236 1240  
1237 1241          if ((flags & FLG_ASI) != 0 && asistr != NULL)
1238 1242                  bprintf(dhp, "\t<%s>", asistr);
1239 1243  
1240 1244          return (0);
1241 1245  }
1242 1246  
1243 1247  static int
1244 1248  fmt_cpop(dis_handle_t *dhp, uint32_t instr, const inst_t *inp)
1245 1249  {
     1250 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1246 1251          ifmt_t *f = (ifmt_t *)&instr;
1247 1252          int flags = FLG_P1(REG_CP)|FLG_P2(REG_CP)|FLG_NOIMM|FLG_P3(REG_CP);
1248 1253  
1249      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
     1254 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
1250 1255                  prt_field("op", f->fcp.op, 2);
1251 1256                  prt_field("op3", f->fcp.op3, 6);
1252 1257                  prt_field("opc", f->fcp.opc, 9);
1253 1258                  prt_field("rs1", f->fcp.rs1, 5);
1254 1259                  prt_field("rs2", f->fcp.rs2, 5);
1255 1260                  prt_field("rd", f->fcp.rd, 5);
1256 1261          }
1257 1262  
1258 1263          prt_name(dhp, inp->in_data.in_def.in_name, 1);
1259 1264          prt_imm(dhp, f->fcp.opc, 0);
1260 1265  
1261      -        (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
     1266 +        (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
1262 1267          (void) prt_aluargs(dhp, instr, flags);
1263 1268  
1264 1269          return (0);
1265 1270  }
1266 1271  
1267 1272  static int
1268 1273  dis_fmt_rdwr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1269 1274  {
     1275 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1270 1276          const char *psr_str = "%psr";
1271 1277          const char *wim_str = "%wim";
1272 1278          const char *tbr_str = "%tbr";
1273 1279  
1274 1280          const char *name = inp->in_data.in_def.in_name;
1275 1281          const char *regstr = NULL;
1276 1282  
1277 1283          ifmt_t *f = (ifmt_t *)&instr;
1278 1284  
1279 1285          int rd = (idx < 0x30);
↓ open down ↓ 105 lines elided ↑ open up ↑
1385 1391                   */
1386 1392                  if (v9 != 0 && f->f3.rd == 15 && f->f3.rs1 == 0 &&
1387 1393                      f->f3.i == 1) {
1388 1394                          prt_name(dhp, "sir", 1);
1389 1395                          prt_imm(dhp, sign_extend(f->f3a.simm13, 13),
1390 1396                              IMM_SIGNED);
1391 1397                          return (0);
1392 1398                  }
1393 1399  
1394 1400                  /* synth: mov */
1395      -                if ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
     1401 +                if ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
1396 1402                      == 0)
1397 1403                          break;
1398 1404  
1399 1405                  if (v9 == 0) {
1400 1406                          if (f->f3.rs1 == 0) {
1401 1407                                  name = "mov";
1402 1408                                  pr_rs1 = 0;
1403 1409                          }
1404 1410  
1405 1411                          if ((f->f3.i == 0 && f->f3.rs2 == 0) ||
↓ open down ↓ 51 lines elided ↑ open up ↑
1457 1463                  bprintf(dhp, "%s, %s", regstr, reg_names[f->f3.rd]);
1458 1464          } else {
1459 1465                  if (pr_rs1 == 1)
1460 1466                          bprintf(dhp, "%s, ", reg_names[f->f3.rs1]);
1461 1467  
1462 1468                  if (pr_rs2 != 0) {
1463 1469                          if (f->f3.i == 1)
1464 1470                                  prt_imm(dhp, sign_extend(f->f3a.simm13, 13),
1465 1471                                      IMM_SIGNED);
1466 1472                          else
1467      -                                (void) strlcat(dhp->dh_buf,
1468      -                                    reg_names[f->f3.rs2], dhp->dh_buflen);
1469      -                        (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
     1473 +                                (void) strlcat(dhx->dhx_buf,
     1474 +                                    reg_names[f->f3.rs2], dhx->dhx_buflen);
     1475 +                        (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
1470 1476                  }
1471 1477  
1472      -                (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen);
     1478 +                (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen);
1473 1479          }
1474 1480  
1475 1481          return (0);
1476 1482  }
1477 1483  
1478 1484  /* ARGSUSED3 */
1479 1485  int
1480 1486  fmt_trap(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1481 1487  {
     1488 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1482 1489          ifmt_t *f = (ifmt_t *)&instr;
1483 1490  
1484 1491          int v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0);
1485 1492          int p_rs1, p_t;
1486 1493  
1487 1494          if (f->ftcc.undef != 0)
1488 1495                  return (-1);
1489 1496  
1490 1497          if (icc_names[f->ftcc.cc] == NULL)
1491 1498                  return (-1);
1492 1499  
1493 1500          if (f->ftcc.i == 1 && f->ftcc.undef2 != 0)
1494 1501                  return (-1);
1495 1502  
1496 1503          if (f->ftcc2.i == 0 && f->ftcc2.undef2 != 0)
1497 1504                  return (-1);
1498 1505  
1499 1506          p_rs1 = ((f->ftcc.rs1 != 0) ||
1500      -            ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0));
     1507 +            ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0));
1501 1508  
1502 1509          if (f->ftcc.i == 0) {
1503 1510                  p_t = (f->f3.rs2 != 0 || p_rs1 == 0);
1504 1511  
1505 1512                  bprintf(dhp, "%-9s %s%s%s%s%s", inp->in_data.in_def.in_name,
1506 1513                      (v9 != 0) ? icc_names[f->ftcc2.cc] : "",
1507 1514                      (v9 != 0) ? ", " : "",
1508 1515                      (p_rs1 != 0) ? reg_names[f->ftcc2.rs1] : "",
1509 1516                      (p_rs1 != 0) ? " + " : "",
1510 1517                      (p_t != 0) ? reg_names[f->f3.rs2] : "");
↓ open down ↓ 37 lines elided ↑ open up ↑
1548 1555                  bprintf(dhp, "%s, %s, %s", reg_names[f->f3.rs1],
1549 1556                      reg_names[f->f3.rs2], reg_names[f->f3.rd]);
1550 1557  
1551 1558          return (0);
1552 1559  }
1553 1560  
1554 1561  /* ARGSUSED3 */
1555 1562  static int
1556 1563  prt_jmpl(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1557 1564  {
     1565 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1558 1566          const char *name = inp->in_data.in_def.in_name;
1559 1567          ifmt_t *f = (ifmt_t *)&instr;
1560 1568  
1561      -        if (f->f3.rd == 15 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0))
     1569 +        if (f->f3.rd == 15 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0))
1562 1570                  name = "call";
1563 1571  
1564 1572          if (f->f3.rd == 0) {
1565 1573                  if (f->f3.i == 1 && f->f3a.simm13 == 8) {
1566 1574                          if (f->f3.rs1 == 15) {
1567 1575                                  prt_name(dhp, "retl", 0);
1568 1576                                  return (0);
1569 1577                          }
1570 1578  
1571 1579                          if (f->f3.rs1 == 31) {
↓ open down ↓ 4 lines elided ↑ open up ↑
1576 1584  
1577 1585                  name = "jmp";
1578 1586          }
1579 1587  
1580 1588          prt_name(dhp, name, 1);
1581 1589          prt_address(dhp, instr, 1);
1582 1590  
1583 1591          if (f->f3.rd == 0)
1584 1592                  return (0);
1585 1593  
1586      -        if (f->f3.rd == 15 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0))
     1594 +        if (f->f3.rd == 15 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0))
1587 1595                  return (0);
1588 1596  
1589 1597          bprintf(dhp, ", %s", reg_names[f->f3.rd]);
1590 1598  
1591 1599          return (0);
1592 1600  }
1593 1601  
1594 1602  int
1595 1603  fmt_alu(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1596 1604  {
     1605 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1597 1606          ifmt_t *f = (ifmt_t *)&instr;
1598 1607  
1599 1608          const char *name = inp->in_data.in_def.in_name;
1600 1609          int flags = inp->in_data.in_def.in_flags;
1601 1610          int arg = 0;
1602 1611  
1603      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
     1612 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
1604 1613                  prt_field("op", f->f3.op, 2);
1605 1614                  prt_field("op3", f->f3.op3, 6);
1606 1615                  prt_field("rs1", f->f3.rs1, 5);
1607 1616  
1608 1617                  switch (idx) {
1609 1618                          /* TODO: more formats */
1610 1619  
1611 1620                  default:
1612 1621                          if (f->f3.i == 0)
1613 1622                                  prt_field("rs2", f->f3.rs2, 5);
↓ open down ↓ 2 lines elided ↑ open up ↑
1616 1625  
1617 1626                          prt_field("rd", f->f3.rd, 5);
1618 1627                  }
1619 1628  
1620 1629          }
1621 1630  
1622 1631          switch (idx) {
1623 1632          case 0x00:
1624 1633                  /* add */
1625 1634  
1626      -                if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0)
     1635 +                if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0)
1627 1636                          break;
1628 1637  
1629 1638                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
1630 1639                      f->f3a.simm13 == 1) {
1631 1640                          name = "inc";
1632 1641                          flags = FLG_P1(REG_NONE)|FLG_P2(REG_NONE)|FLG_NOIMM;
1633 1642                          break;
1634 1643                  }
1635 1644  
1636 1645                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
1637 1646                      f->f3a.simm13 != 1) {
1638 1647                          name = "inc";
1639 1648                          flags = FLG_P1(REG_NONE);
1640 1649                          break;
1641 1650                  }
1642 1651                  break;
1643 1652  
1644 1653          case 0x02:
1645 1654                  /* or */
1646 1655  
1647      -                if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
     1656 +                if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
1648 1657                      == 0)
1649 1658                          break;
1650 1659  
1651      -                if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) != 0) {
     1660 +                if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) != 0) {
1652 1661                          if (f->f3.rs1 == f->f3.rd) {
1653 1662                                  name = "bset";
1654 1663                                  flags = FLG_P1(REG_NONE);
1655 1664                                  break;
1656 1665                          }
1657 1666                  }
1658 1667  
1659 1668                  if (((f->f3.i == 0 && f->f3.rs2 == 0) ||
1660 1669                      (f->f3.i == 1 && f->f3a.simm13 == 0)) &&
1661 1670                      (f->f3.rs1 == 0)) {
↓ open down ↓ 5 lines elided ↑ open up ↑
1667 1676                  if (f->f3.rs1 == 0) {
1668 1677                          name = "mov";
1669 1678                          flags = FLG_P1(REG_NONE);
1670 1679                          break;
1671 1680                  }
1672 1681                  break;
1673 1682  
1674 1683          case 0x04:
1675 1684                  /* sub */
1676 1685  
1677      -                if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
     1686 +                if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
1678 1687                      == 0)
1679 1688                          break;
1680 1689  
1681 1690                  if (f->f3.rs1 == 0 && f->f3.i == 0 && f->f3.rs2 == f->f3.rd) {
1682 1691                          name = "neg";
1683 1692                          flags = FLG_P1(REG_NONE)|FLG_P2(REG_NONE);
1684 1693                          break;
1685 1694                  }
1686 1695  
1687 1696                  if (f->f3.rs1 == 0 && f->f3.i == 0 && f->f3.rs2 != f->f3.rd) {
1688 1697                          name = "neg";
1689 1698                          flags = FLG_P1(REG_NONE);
1690 1699                          break;
1691 1700                  }
1692 1701  
1693      -                if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0)
     1702 +                if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0)
1694 1703                          break;
1695 1704  
1696 1705                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
1697 1706                      f->f3a.simm13 == 1) {
1698 1707                          name = "dec";
1699 1708                          flags = FLG_P1(REG_NONE)|FLG_P2(REG_NONE)|FLG_NOIMM;
1700 1709                          break;
1701 1710                  }
1702 1711  
1703 1712                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
1704 1713                      f->f3a.simm13 != 1) {
1705 1714                          name = "dec";
1706 1715                          flags = FLG_P1(REG_NONE);
1707 1716                          break;
1708 1717                  }
1709 1718                  break;
1710 1719  
1711 1720          case 0x07:
1712 1721                  /* xnor */
1713 1722  
1714      -                if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
     1723 +                if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
1715 1724                      == 0)
1716 1725                          break;
1717 1726  
1718 1727                  /*
1719 1728                   * xnor -> not when you have:
1720 1729                   *       xnor %rs1, 0x0 or %g0, %rd
1721 1730                   */
1722 1731                  if ((f->f3.i == 0 && f->f3.rs2 != 0) ||
1723 1732                      (f->f3.i == 1 && f->f3a.simm13 != 0))
1724 1733                          break;
↓ open down ↓ 5 lines elided ↑ open up ↑
1730 1739                              FLG_P3(REG_INT);
1731 1740                  else
1732 1741                          flags = FLG_P1(REG_INT)|FLG_P2(REG_NONE)|FLG_NOIMM|
1733 1742                              FLG_P3(REG_INT);
1734 1743  
1735 1744                  break;
1736 1745  
1737 1746          case 0x10:
1738 1747                  /* addcc */
1739 1748  
1740      -                if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0)
     1749 +                if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0)
1741 1750                          break;
1742 1751  
1743 1752                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
1744 1753                      f->f3a.simm13 == 1) {
1745 1754                          name = "inccc";
1746 1755                          flags = FLG_P1(REG_NONE)|FLG_P2(REG_NONE)|FLG_NOIMM;
1747 1756                          break;
1748 1757                  }
1749 1758  
1750 1759                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
↓ open down ↓ 3 lines elided ↑ open up ↑
1754 1763                          break;
1755 1764                  }
1756 1765                  break;
1757 1766  
1758 1767          case 0x11:
1759 1768                  /* andcc */
1760 1769  
1761 1770                  if (f->f3.rd != 0)
1762 1771                          break;
1763 1772  
1764      -                if ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
     1773 +                if ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL))
1765 1774                      == 0)
1766 1775                          break;
1767 1776  
1768      -                if (((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0) &&
     1777 +                if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0) &&
1769 1778                      ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) == 0))
1770 1779                          break;
1771 1780  
1772 1781                  name = "btst";
1773 1782                  flags = FLG_P1(REG_NONE);
1774 1783                  f->f3.rd = f->f3.rs1;
1775 1784                  break;
1776 1785  
1777 1786          case 0x12:
1778 1787                  /* orcc */
1779 1788  
1780      -                if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
     1789 +                if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
1781 1790                      == 0)
1782 1791                          break;
1783 1792  
1784 1793                  if (f->f3.rs1 == 0 && f->f3.rd == 0 && f->f3.i == 0) {
1785 1794                          name = "tst";
1786 1795                          flags = FLG_P1(REG_NONE)|FLG_P3(REG_NONE);
1787 1796                          break;
1788 1797                  }
1789 1798  
1790 1799                  if (f->f3.rs2 == 0 && f->f3.rd == 0 && f->f3.i == 0) {
1791 1800                          name = "tst";
1792 1801                          flags = FLG_P2(REG_NONE)|FLG_P3(REG_NONE);
1793 1802                          break;
1794 1803                  }
1795 1804  
1796 1805                  break;
1797 1806  
1798 1807          case 0x14:
1799 1808                  /* subcc */
1800 1809  
1801      -                if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
     1810 +                if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
1802 1811                      == 0)
1803 1812                          break;
1804 1813  
1805 1814                  if (f->f3.rd == 0) {
1806 1815                          name = "cmp";
1807 1816                          flags = FLG_P3(REG_NONE);
1808 1817                          break;
1809 1818                  }
1810 1819  
1811      -                if ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0)
     1820 +                if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0)
1812 1821                          break;
1813 1822  
1814 1823                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
1815 1824                      f->f3a.simm13 == 1) {
1816 1825                          name = "deccc";
1817 1826                          flags = FLG_P1(REG_NONE)|FLG_P2(REG_NONE)|FLG_NOIMM;
1818 1827                          break;
1819 1828                  }
1820 1829  
1821 1830                  if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 &&
↓ open down ↓ 39 lines elided ↑ open up ↑
1861 1870  
1862 1871          case 0x3b:
1863 1872                  /* flush */
1864 1873                  prt_name(dhp, name, 1);
1865 1874                  prt_address(dhp, instr, 0);
1866 1875                  return (0);
1867 1876  
1868 1877          case 0x3c:
1869 1878          case 0x3d:
1870 1879                  /* save / restore */
1871      -                if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
     1880 +                if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT))
1872 1881                      == 0)
1873 1882                          break;
1874 1883  
1875 1884                  if (f->f3.rs1 != 0 || f->f3.rs2 != 0 || f->f3.rd != 0)
1876 1885                          break;
1877 1886  
1878      -                if (f->f3.i != 0 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0))
     1887 +                if (f->f3.i != 0 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0))
1879 1888                          break;
1880 1889  
1881 1890                  prt_name(dhp, name, 0);
1882 1891                  return (0);
1883 1892          }
1884 1893  
1885 1894          if (FLG_P1_VAL(flags) != REG_NONE || FLG_P2_VAL(flags) != REG_NONE ||
1886 1895              FLG_P3_VAL(flags) != REG_NONE)
1887 1896                  arg = 1;
1888 1897  
↓ open down ↓ 23 lines elided ↑ open up ↑
1912 1921                  prt_address(dhp, instr, 1);
1913 1922          }
1914 1923  
1915 1924          return (0);
1916 1925  }
1917 1926  
1918 1927  /* ARGSUSED3 */
1919 1928  int
1920 1929  fmt_movcc(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1921 1930  {
     1931 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1922 1932          ifmt_t *f = (ifmt_t *)&instr;
1923 1933          const char **regs = NULL;
1924 1934  
1925      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
     1935 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
1926 1936                  prt_field("op", f->f3c.op, 2);
1927 1937                  prt_field("op3", f->f3c.op3, 6);
1928 1938                  prt_field("cond", f->f3c.cond, 4);
1929 1939                  prt_field("cc2", f->f3c.cc2, 1);
1930 1940                  prt_field("cc", f->f3c.cc, 2);
1931 1941                  prt_field("i", f->f3c.i, 1);
1932 1942  
1933 1943                  if (f->f3c.i == 0)
1934 1944                          prt_field("rs2", f->f3.rs2, 5);
1935 1945                  else
↓ open down ↓ 10 lines elided ↑ open up ↑
1946 1956                          return (-1);
1947 1957          }
1948 1958  
1949 1959          prt_name(dhp, inp->in_data.in_def.in_name, 1);
1950 1960  
1951 1961          bprintf(dhp, "%s, ", regs[f->f3c.cc]);
1952 1962  
1953 1963          if (f->f3c.i == 1)
1954 1964                  prt_imm(dhp, sign_extend(f->f3c.simm11, 11), IMM_SIGNED);
1955 1965          else
1956      -                (void) strlcat(dhp->dh_buf, reg_names[f->f3.rs2],
1957      -                    dhp->dh_buflen);
     1966 +                (void) strlcat(dhx->dhx_buf, reg_names[f->f3.rs2],
     1967 +                    dhx->dhx_buflen);
1958 1968  
1959 1969          bprintf(dhp, ", %s", reg_names[f->f3.rd]);
1960 1970  
1961 1971          return (0);
1962 1972  }
1963 1973  
1964 1974  /* ARGSUSED3 */
1965 1975  int
1966 1976  fmt_movr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1967 1977  {
     1978 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1968 1979          ifmt_t *f = (ifmt_t *)&instr;
1969 1980  
1970 1981          prt_name(dhp, inp->in_data.in_def.in_name, 1);
1971 1982  
1972 1983          bprintf(dhp, "%s, ", reg_names[f->f3d.rs1]);
1973 1984  
1974 1985          if (f->f3d.i == 1)
1975 1986                  prt_imm(dhp, sign_extend(f->f3d.simm10, 10), IMM_SIGNED);
1976 1987          else
1977      -                (void) strlcat(dhp->dh_buf, reg_names[f->f3.rs2],
1978      -                    dhp->dh_buflen);
     1988 +                (void) strlcat(dhx->dhx_buf, reg_names[f->f3.rs2],
     1989 +                    dhx->dhx_buflen);
1979 1990  
1980 1991          bprintf(dhp, ", %s", reg_names[f->f3.rd]);
1981 1992  
1982 1993          return (0);
1983 1994  }
1984 1995  
1985 1996  /* ARGSUSED3 */
1986 1997  int
1987 1998  fmt_fpop1(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
1988 1999  {
     2000 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
1989 2001          ifmt_t *f = (ifmt_t *)&instr;
1990 2002          int flags = inp->in_data.in_def.in_flags;
1991 2003  
1992 2004          flags |= FLG_NOIMM;
1993 2005  
1994      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
     2006 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
1995 2007                  prt_field("op", f->f3.op, 2);
1996 2008                  prt_field("op3", f->f3.op3, 6);
1997 2009                  prt_field("opf", f->fcmp.opf, 9);
1998 2010                  prt_field("rs1", f->f3.rs1, 5);
1999 2011                  prt_field("rs2", f->f3.rs2, 5);
2000 2012                  prt_field("rd", f->f3.rd, 5);
2001 2013          }
2002 2014  
2003 2015          prt_name(dhp, inp->in_data.in_def.in_name, 1);
2004 2016          prt_aluargs(dhp, instr, flags);
↓ open down ↓ 7 lines elided ↑ open up ↑
2012 2024          static const char *condstr_icc[16] = {
2013 2025                  "n", "e",  "le", "l",  "leu", "lu",  "neg", "vs",
2014 2026                  "a", "nz", "g",  "ge", "gu",  "geu", "pos", "vc"
2015 2027          };
2016 2028  
2017 2029          static const char *condstr_fcc[16] = {
2018 2030                  "n", "nz", "lg", "ul", "l",   "ug", "g",   "u",
2019 2031                  "a", "e",  "ue", "ge", "uge", "le", "ule", "o"
2020 2032          };
2021 2033  
     2034 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
2022 2035          ifmt_t *f = (ifmt_t *)&instr;
2023 2036          const char *ccstr = "";
2024 2037          char name[15];
2025 2038  
2026 2039          int flags = inp->in_data.in_def.in_flags;
2027 2040          int is_cmp = (idx == 0x51 || idx == 0x52 || idx == 0x53 ||
2028 2041              idx == 0x55 || idx == 0x56 || idx == 0x57);
2029 2042          int is_fmov = (idx & 0x3f);
2030 2043          int is_v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0);
2031      -        int is_compat = ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0);
     2044 +        int is_compat = ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0);
2032 2045  
2033 2046          int p_cc = 0;
2034 2047  
2035 2048          is_fmov = (is_fmov == 0x1 || is_fmov == 0x2 || is_fmov == 0x3);
2036 2049  
2037      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
     2050 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
2038 2051                  prt_field("op", f->f3.op, 2);
2039 2052                  prt_field("op3", f->f3.op3, 6);
2040 2053                  prt_field("opf", f->fcmp.opf, 9);
2041 2054  
2042 2055                  switch (idx & 0x3f) {
2043 2056                  case 0x51:
2044 2057                  case 0x52:
2045 2058                  case 0x53:
2046 2059                  case 0x55:
2047 2060                  case 0x56:
↓ open down ↓ 49 lines elided ↑ open up ↑
2097 2110                  bprintf(dhp, "%s, ", ccstr);
2098 2111  
2099 2112          prt_aluargs(dhp, instr, flags);
2100 2113  
2101 2114          return (0);
2102 2115  }
2103 2116  
2104 2117  int
2105 2118  fmt_vis(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx)
2106 2119  {
     2120 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
2107 2121          ifmt_t *f = (ifmt_t *)&instr;
2108 2122          int flags = inp->in_data.in_def.in_flags;
2109 2123  
2110      -        if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) {
     2124 +        if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) {
2111 2125                  prt_field("op", f->f3.op, 2);
2112 2126                  prt_field("op3", f->f3.op3, 6);
2113 2127                  prt_field("opf", f->fcmp.opf, 9);
2114 2128  
2115 2129                  if (idx == 0x081) {
2116 2130                          prt_field("mode", instr & 02L, 2);
2117 2131                  } else {
2118 2132                          prt_field("rs1", f->f3.rs1, 5);
2119 2133                          prt_field("rs2", f->f3.rs2, 5);
2120 2134                          prt_field("rd", f->f3.rd, 5);
↓ open down ↓ 123 lines elided ↑ open up ↑
2244 2258   * such as integer, floating point, etc.
2245 2259   * idx is the numeric value of the register
2246 2260   *
2247 2261   * If regset is REG_NONE, an empty, but non-NULL string is returned
2248 2262   * NULL may be returned if the index indicates an invalid register value
2249 2263   * such as with the %icc/%xcc sets
2250 2264   */
2251 2265  static const char *
2252 2266  get_regname(dis_handle_t *dhp, int regset, uint32_t idx)
2253 2267  {
     2268 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
2254 2269          const char *regname = NULL;
2255 2270  
2256 2271          switch (regset) {
2257 2272          case REG_INT:
2258 2273                  regname = reg_names[idx];
2259 2274                  break;
2260 2275  
2261 2276          case REG_FP:
2262 2277                  regname = freg_names[idx];
2263 2278                  break;
2264 2279  
2265 2280          case REG_FPD:
2266      -                if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) ||
     2281 +                if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) ||
2267 2282                      ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0))
2268 2283                          regname = fdreg_names[idx];
2269 2284                  else
2270 2285                          regname = compat_fdreg_names[idx];
2271 2286  
2272 2287                  break;
2273 2288  
2274 2289          case REG_FPQ:
2275      -                if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)
     2290 +                if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)
2276 2291                          regname = fqreg_names[idx];
2277 2292                  else
2278 2293                          regname = freg_names[idx];
2279 2294  
2280 2295                  break;
2281 2296  
2282 2297          case REG_CP:
2283 2298                  regname = cpreg_names[idx];
2284 2299                  break;
2285 2300  
↓ open down ↓ 57 lines elided ↑ open up ↑
2343 2358   * %g0 or 0x0 appears in the address
2344 2359   *
2345 2360   * If DIS_DEBUG_SYN_ALL or DIS_DEBUG_COMPAT are set, when %g0 or 0x0
2346 2361   * appear in the address, they are not output.  If the wierd (and probably
2347 2362   * shouldn't happen) address of [%g0 + %g0] or [%g0 + 0x0] is encountered,
2348 2363   * [%g0] is output
2349 2364   */
2350 2365  static void
2351 2366  prt_address(dis_handle_t *dhp, uint32_t instr, int nobrackets)
2352 2367  {
     2368 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
2353 2369          ifmt_t *f = (ifmt_t *)&instr;
2354 2370          int32_t simm13;
2355 2371          int octal = ((dhp->dh_flags & DIS_OCTAL) != 0);
2356      -        int p1 = ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
2357      -        int p2 = ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
     2372 +        int p1 = ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
     2373 +        int p2 = ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0);
2358 2374  
2359 2375          if (f->f3a.i == 0) {
2360 2376                  p1 |= ((f->f3a.rs1 != 0) || f->f3.rs2 == 0);
2361 2377                  p2 |= (f->f3.rs2 != 0);
2362 2378  
2363 2379                  bprintf(dhp, "%s%s%s%s%s",
2364 2380                      (nobrackets == 0) ? "[" : "",
2365 2381                      (p1 != 0) ? reg_names[f->f3a.rs1] : "",
2366 2382                      (p1 != 0 && p2 != 0) ? " + " : "",
2367 2383                      (p2 != 0) ? reg_names[f->f3.rs2] : "",
↓ open down ↓ 46 lines elided ↑ open up ↑
2414 2430   * flags indicates the register set to use for each position (p1, p2, p3)
2415 2431   * as well as if immediate values (i == 1) are allowed
2416 2432   *
2417 2433   * if flags indicates a specific position has REG_NONE set as it's register
2418 2434   * set, it is omitted from the output.  This is primarly used for certain
2419 2435   * floating point operations
2420 2436   */
2421 2437  static void
2422 2438  prt_aluargs(dis_handle_t *dhp, uint32_t instr, uint32_t flags)
2423 2439  {
     2440 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
2424 2441          ifmt_t *f = (ifmt_t *)&instr;
2425 2442          const char *r1, *r2, *r3;
2426 2443          int p1, p2, p3;
2427 2444          unsigned int opf = 0;
2428 2445  
2429 2446          r1 = get_regname(dhp, FLG_P1_VAL(flags), f->f3.rs1);
2430 2447          r2 = get_regname(dhp, FLG_P2_VAL(flags), f->f3.rs2);
2431 2448          r3 = get_regname(dhp, FLG_P3_VAL(flags), f->f3.rd);
2432 2449  
2433 2450          p1 = (FLG_P1_VAL(flags) != REG_NONE);
↓ open down ↓ 6 lines elided ↑ open up ↑
2440 2457          if (f->f3a.i == 0 && (r2 == NULL || r2[0] == '\0'))
2441 2458                  p2 = 0;
2442 2459  
2443 2460          if (r3 == NULL || r3[0] == '\0')
2444 2461                  p3 = 0;
2445 2462  
2446 2463          if ((f->fcmp.op == 2) && (f->fcmp.op3 == 0x36) && (f->fcmp.cc != 0))
2447 2464                  opf = f->fcmp.opf;
2448 2465  
2449 2466          if ((opf == 0x151) || (opf == 0x152)) {
2450      -                (void) strlcat(dhp->dh_buf, r3, dhp->dh_buflen);
2451      -                (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
     2467 +                (void) strlcat(dhx->dhx_buf, r3, dhx->dhx_buflen);
     2468 +                (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
2452 2469                  p3 = 0;
2453 2470          }
2454 2471  
2455 2472          if (p1 != 0) {
2456      -                (void) strlcat(dhp->dh_buf, r1, dhp->dh_buflen);
     2473 +                (void) strlcat(dhx->dhx_buf, r1, dhx->dhx_buflen);
2457 2474                  if (p2 != 0 || p3 != 0)
2458      -                        (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
     2475 +                        (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
2459 2476          }
2460 2477  
2461 2478          if (p2 != 0) {
2462 2479                  if (f->f3.i == 0 || ((flags & FLG_NOIMM) != 0))
2463      -                        (void) strlcat(dhp->dh_buf, r2, dhp->dh_buflen);
     2480 +                        (void) strlcat(dhx->dhx_buf, r2, dhx->dhx_buflen);
2464 2481                  else
2465 2482                          prt_imm(dhp, sign_extend(f->f3a.simm13, 13),
2466 2483                              IMM_SIGNED);
2467 2484  
2468 2485                  if (p3 != 0)
2469      -                        (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen);
     2486 +                        (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen);
2470 2487          }
2471 2488  
2472 2489          if (p3 != 0)
2473      -                (void) strlcat(dhp->dh_buf, r3, dhp->dh_buflen);
     2490 +                (void) strlcat(dhx->dhx_buf, r3, dhx->dhx_buflen);
2474 2491  }
2475 2492  
2476 2493  static const char *
2477 2494  get_asi_name(uint8_t asi)
2478 2495  {
2479 2496          switch (asi) {
2480 2497                  case 0x04:
2481 2498                          return ("ASI_N");
2482 2499  
2483 2500                  case 0x0c:
↓ open down ↓ 251 lines elided ↑ open up ↑
2735 2752   * just a handy function that takes care of managing the buffer length
2736 2753   * w/ printf
2737 2754   */
2738 2755  
2739 2756  /*
2740 2757   * PRINTF LIKE 1
2741 2758   */
2742 2759  static void
2743 2760  bprintf(dis_handle_t *dhp, const char *fmt, ...)
2744 2761  {
     2762 +        dis_handle_sparc_t *dhx = dhp->dh_arch_private;
2745 2763          size_t curlen;
2746 2764          va_list ap;
2747 2765  
2748      -        curlen = strlen(dhp->dh_buf);
     2766 +        curlen = strlen(dhx->dhx_buf);
2749 2767  
2750 2768          va_start(ap, fmt);
2751      -        (void) vsnprintf(dhp->dh_buf + curlen, dhp->dh_buflen - curlen, fmt,
2752      -            ap);
     2769 +        (void) dis_vsnprintf(dhx->dhx_buf + curlen, dhx->dhx_buflen -
     2770 +            curlen, fmt, ap);
2753 2771          va_end(ap);
2754 2772  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX