From c5d9decfaa9eae32f8bcd6d71487dfd47a994e68 Mon Sep 17 00:00:00 2001 From: cacao Date: Wed, 18 Nov 1998 14:58:50 +0000 Subject: [PATCH] disassembler improved --- alpha/disass.c | 420 ++++++++++++++++++++++++++------------------- alpha/ngen.c | 9 +- alpha/types.h | 2 + jit/stack.c | 75 +++++--- src/vm/jit/stack.c | 75 +++++--- 5 files changed, 353 insertions(+), 228 deletions(-) diff --git a/alpha/disass.c b/alpha/disass.c index 38ec1bfa8..c04e876f8 100644 --- a/alpha/disass.c +++ b/alpha/disass.c @@ -9,7 +9,7 @@ Authors: Andreas Krall EMAIL: cacao@complang.tuwien.ac.at Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at - Last Change: 1998/11/06 + Last Change: 1998/11/18 *******************************************************************************/ @@ -26,9 +26,10 @@ #define ITYPE_UNDEF 0 /* undefined instructions (illegal opcode) */ #define ITYPE_JMP 1 /* jump instructions */ #define ITYPE_MEM 2 /* memory instructions */ -#define ITYPE_BRA 3 /* branch instructions */ -#define ITYPE_OP 4 /* integer instructions */ -#define ITYPE_FOP 5 /* floating point instructions */ +#define ITYPE_FMEM 3 /* floating point memory instructions */ +#define ITYPE_BRA 4 /* branch instructions */ +#define ITYPE_OP 5 /* integer instructions */ +#define ITYPE_FOP 6 /* floating point instructions */ /* instruction decode table for 6 bit op codes */ @@ -43,62 +44,62 @@ static struct {char *name; int itype;} ops[] = { /* 0x05 */ {"", ITYPE_UNDEF}, /* 0x06 */ {"", ITYPE_UNDEF}, /* 0x07 */ {"", ITYPE_UNDEF}, - /* 0x08 */ {"LDA ", ITYPE_MEM}, - /* 0x09 */ {"LDAH ", ITYPE_MEM}, - /* 0x0a */ {"LDB ", ITYPE_MEM}, - /* 0x0b */ {"LDQ_U ", ITYPE_MEM}, - /* 0x0c */ {"LDW ", ITYPE_MEM}, - /* 0x0d */ {"STW ", ITYPE_MEM}, - /* 0x0e */ {"STB ", ITYPE_MEM}, - /* 0x0f */ {"STQ_U ", ITYPE_MEM}, - /* 0x10 */ {"OP ", ITYPE_OP}, - /* 0x11 */ {"OP ", ITYPE_OP}, - /* 0x12 */ {"OP ", ITYPE_OP}, - /* 0x13 */ {"OP ", ITYPE_OP}, + /* 0x08 */ {"lda ", ITYPE_MEM}, + /* 0x09 */ {"ldah ", ITYPE_MEM}, + /* 0x0a */ {"ldb ", ITYPE_MEM}, + /* 0x0b */ {"ldq_u ", ITYPE_MEM}, + /* 0x0c */ {"ldw ", ITYPE_MEM}, + /* 0x0d */ {"stw ", ITYPE_MEM}, + /* 0x0e */ {"stb ", ITYPE_MEM}, + /* 0x0f */ {"stq_u ", ITYPE_MEM}, + /* 0x10 */ {"op ", ITYPE_OP}, + /* 0x11 */ {"op ", ITYPE_OP}, + /* 0x12 */ {"op ", ITYPE_OP}, + /* 0x13 */ {"op ", ITYPE_OP}, /* 0x14 */ {"", ITYPE_UNDEF}, /* 0x15 */ {"", ITYPE_UNDEF}, - /* 0x16 */ {"FOP ", ITYPE_FOP}, - /* 0x17 */ {"FOP ", ITYPE_FOP}, - /* 0x18 */ {"MEMFMT ", ITYPE_MEM}, + /* 0x16 */ {"fop ", ITYPE_FOP}, + /* 0x17 */ {"fop ", ITYPE_FOP}, + /* 0x18 */ {"memfmt ", ITYPE_MEM}, /* 0x19 */ {"", ITYPE_UNDEF}, - /* 0x1a */ {"JMP ", ITYPE_JMP}, + /* 0x1a */ {"jmp ", ITYPE_JMP}, /* 0x1b */ {"", ITYPE_UNDEF}, - /* 0x1c */ {"OP ", ITYPE_OP}, + /* 0x1c */ {"op ", ITYPE_OP}, /* 0x1d */ {"", ITYPE_UNDEF}, /* 0x1e */ {"", ITYPE_UNDEF}, /* 0x1f */ {"", ITYPE_UNDEF}, - /* 0x20 */ {"LDF ", ITYPE_MEM}, - /* 0x21 */ {"LDG ", ITYPE_MEM}, - /* 0x22 */ {"LDS ", ITYPE_MEM}, - /* 0x23 */ {"LDT ", ITYPE_MEM}, - /* 0x24 */ {"STF ", ITYPE_MEM}, - /* 0x25 */ {"STG ", ITYPE_MEM}, - /* 0x26 */ {"STS ", ITYPE_MEM}, - /* 0x27 */ {"STT ", ITYPE_MEM}, - /* 0x28 */ {"LDL ", ITYPE_MEM}, - /* 0x29 */ {"LDQ ", ITYPE_MEM}, - /* 0x2a */ {"LDL_L ", ITYPE_MEM}, - /* 0x2b */ {"LDQ_L ", ITYPE_MEM}, - /* 0x2c */ {"STL ", ITYPE_MEM}, - /* 0x2d */ {"STQ ", ITYPE_MEM}, - /* 0x2e */ {"STL_C ", ITYPE_MEM}, - /* 0x2f */ {"STQ_C ", ITYPE_MEM}, - /* 0x30 */ {"BR ", ITYPE_BRA}, - /* 0x31 */ {"FBEQ ", ITYPE_BRA}, - /* 0x32 */ {"FBLT ", ITYPE_BRA}, - /* 0x33 */ {"FBLE ", ITYPE_BRA}, - /* 0x34 */ {"BSR ", ITYPE_BRA}, - /* 0x35 */ {"FBNE ", ITYPE_BRA}, - /* 0x36 */ {"FBGE ", ITYPE_BRA}, - /* 0x37 */ {"FBGT ", ITYPE_BRA}, - /* 0x38 */ {"BLBC ", ITYPE_BRA}, - /* 0x39 */ {"BEQ ", ITYPE_BRA}, - /* 0x3a */ {"BLT ", ITYPE_BRA}, - /* 0x3b */ {"BLE ", ITYPE_BRA}, - /* 0x3c */ {"BLBS ", ITYPE_BRA}, - /* 0x3d */ {"BNE ", ITYPE_BRA}, - /* 0x3e */ {"BGE ", ITYPE_BRA}, - /* 0x3f */ {"BGT ", ITYPE_BRA} + /* 0x20 */ {"ldf ", ITYPE_FMEM}, + /* 0x21 */ {"ldg ", ITYPE_FMEM}, + /* 0x22 */ {"lds ", ITYPE_FMEM}, + /* 0x23 */ {"ldt ", ITYPE_FMEM}, + /* 0x24 */ {"stf ", ITYPE_FMEM}, + /* 0x25 */ {"stg ", ITYPE_FMEM}, + /* 0x26 */ {"sts ", ITYPE_FMEM}, + /* 0x27 */ {"stt ", ITYPE_FMEM}, + /* 0x28 */ {"ldl ", ITYPE_MEM}, + /* 0x29 */ {"ldq ", ITYPE_MEM}, + /* 0x2a */ {"ldl_l ", ITYPE_MEM}, + /* 0x2b */ {"ldq_l ", ITYPE_MEM}, + /* 0x2c */ {"stl ", ITYPE_MEM}, + /* 0x2d */ {"stq ", ITYPE_MEM}, + /* 0x2e */ {"stl_c ", ITYPE_MEM}, + /* 0x2f */ {"stq_c ", ITYPE_MEM}, + /* 0x30 */ {"br ", ITYPE_BRA}, + /* 0x31 */ {"fbeq ", ITYPE_BRA}, + /* 0x32 */ {"fblt ", ITYPE_BRA}, + /* 0x33 */ {"fble ", ITYPE_BRA}, + /* 0x34 */ {"bsr ", ITYPE_BRA}, + /* 0x35 */ {"fbne ", ITYPE_BRA}, + /* 0x36 */ {"fbge ", ITYPE_BRA}, + /* 0x37 */ {"fbgt ", ITYPE_BRA}, + /* 0x38 */ {"blbc ", ITYPE_BRA}, + /* 0x39 */ {"beq ", ITYPE_BRA}, + /* 0x3a */ {"blt ", ITYPE_BRA}, + /* 0x3b */ {"ble ", ITYPE_BRA}, + /* 0x3c */ {"blbs ", ITYPE_BRA}, + /* 0x3d */ {"bne ", ITYPE_BRA}, + /* 0x3e */ {"bge ", ITYPE_BRA}, + /* 0x3f */ {"bgt ", ITYPE_BRA} }; @@ -106,114 +107,160 @@ static struct {char *name; int itype;} ops[] = { static struct { u2 op, fun; char *name; } op3s[] = { - { 0x10, 0x00, "ADDL " }, - { 0x10, 0x40, "ADDL/V " }, - { 0x10, 0x20, "ADDQ " }, - { 0x10, 0x60, "ADDQ/V " }, - { 0x10, 0x09, "SUBL " }, - { 0x10, 0x49, "SUBL/V " }, - { 0x10, 0x29, "SUBQ " }, - { 0x10, 0x69, "SUBQ/V " }, - { 0x10, 0x2D, "CMPEQ " }, - { 0x10, 0x4D, "CMPLT " }, - { 0x10, 0x6D, "CMPLE " }, - { 0x10, 0x1D, "CMPULT " }, - { 0x10, 0x3D, "CMPULE " }, - { 0x10, 0x0F, "CMPBGE " }, - { 0x10, 0x02, "S4ADDL " }, - { 0x10, 0x0b, "S4SUBL " }, - { 0x10, 0x22, "S4ADDQ " }, - { 0x10, 0x2b, "S4SUBQ " }, - { 0x10, 0x12, "S8ADDL " }, - { 0x10, 0x1b, "S8SUBL " }, - { 0x10, 0x32, "S8ADDQ " }, - { 0x10, 0x3b, "S8SUBQ " }, - { 0x11, 0x00, "AND " }, - { 0x11, 0x20, "OR " }, - { 0x11, 0x40, "XOR " }, - { 0x11, 0x08, "ANDNOT " }, - { 0x11, 0x28, "ORNOT " }, - { 0x11, 0x48, "XORNOT " }, - { 0x11, 0x24, "CMOVEQ " }, - { 0x11, 0x44, "CMOVLT " }, - { 0x11, 0x64, "CMOVLE " }, - { 0x11, 0x26, "CMOVNE " }, - { 0x11, 0x46, "CMOVGE " }, - { 0x11, 0x66, "CMOVGT " }, - { 0x11, 0x14, "CMOVLBS" }, - { 0x11, 0x16, "CMOVLBC" }, - { 0x12, 0x39, "SLL " }, - { 0x12, 0x3C, "SRA " }, - { 0x12, 0x34, "SRL " }, - { 0x12, 0x30, "ZAP " }, - { 0x12, 0x31, "ZAPNOT " }, - { 0x12, 0x06, "EXTBL " }, - { 0x12, 0x16, "EXTWL " }, - { 0x12, 0x26, "EXTLL " }, - { 0x12, 0x36, "EXTQL " }, - { 0x12, 0x5a, "EXTWH " }, - { 0x12, 0x6a, "EXTLH " }, - { 0x12, 0x7a, "EXTQH " }, - { 0x12, 0x0b, "INSBL " }, - { 0x12, 0x1b, "INSWL " }, - { 0x12, 0x2b, "INSLL " }, - { 0x12, 0x3b, "INSQL " }, - { 0x12, 0x57, "INSWH " }, - { 0x12, 0x67, "INSLH " }, - { 0x12, 0x77, "INSQH " }, - { 0x12, 0x02, "MSKBL " }, - { 0x12, 0x12, "MSKWL " }, - { 0x12, 0x22, "MSKLL " }, - { 0x12, 0x32, "MSKQL " }, - { 0x12, 0x52, "MSKWH " }, - { 0x12, 0x62, "MSKLH " }, - { 0x12, 0x72, "MSKQH " }, - { 0x13, 0x00, "MULL " }, - { 0x13, 0x20, "MULQ " }, - { 0x13, 0x40, "MULL/V " }, - { 0x13, 0x60, "MULQ/V " }, - { 0x13, 0x30, "UMULH " }, - { 0x16, 0x080, "FADD " }, - { 0x16, 0x0a0, "DADD " }, - { 0x16, 0x081, "FSUB " }, - { 0x16, 0x0a1, "DSUB " }, - { 0x16, 0x082, "FMUL " }, - { 0x16, 0x0a2, "DMUL " }, - { 0x16, 0x083, "FDIV " }, - { 0x16, 0x0a3, "DDIV " }, - { 0x16, 0x580, "FADDS " }, - { 0x16, 0x5a0, "DADDS " }, - { 0x16, 0x581, "FSUBS " }, - { 0x16, 0x5a1, "DSUBS " }, - { 0x16, 0x582, "FMULS " }, - { 0x16, 0x5a2, "DMULS " }, - { 0x16, 0x583, "FDIVS " }, - { 0x16, 0x5a3, "DDIVS " }, - { 0x16, 0x0ac, "CVTDF " }, - { 0x16, 0x0bc, "CVTLF " }, - { 0x16, 0x0be, "CVTLD " }, - { 0x16, 0x0af, "CVTDL " }, - { 0x16, 0x02f, "CVTDLC " }, - { 0x16, 0x5ac, "CVTDFS " }, - { 0x16, 0x5af, "CVTDLS " }, - { 0x16, 0x52f, "CVTDLCS" }, - { 0x16, 0x0a4, "FCMPUN " }, - { 0x16, 0x0a5, "FCMPEQ " }, - { 0x16, 0x0a6, "FCMPLT " }, - { 0x16, 0x0a7, "FCMPLE " }, - { 0x16, 0x5a4, "FCMPUNS" }, - { 0x16, 0x5a5, "FCMPEQS" }, - { 0x16, 0x5a6, "FCMPLTS" }, - { 0x16, 0x5a7, "FCMPLES" }, - { 0x17, 0x020, "FMOV " }, - { 0x17, 0x021, "FMOVN " }, - { 0x1c, 0x0, "BSEXT " }, - { 0x1c, 0x1, "WSEXT " }, + { 0x10, 0x00, "addl " }, + { 0x10, 0x40, "addl/v " }, + { 0x10, 0x20, "addq " }, + { 0x10, 0x60, "addq/v " }, + { 0x10, 0x09, "subl " }, + { 0x10, 0x49, "subl/v " }, + { 0x10, 0x29, "subq " }, + { 0x10, 0x69, "subq/v " }, + { 0x10, 0x2D, "cmpeq " }, + { 0x10, 0x4D, "cmplt " }, + { 0x10, 0x6D, "cmple " }, + { 0x10, 0x1D, "cmpult " }, + { 0x10, 0x3D, "cmpule " }, + { 0x10, 0x0F, "cmpbge " }, + { 0x10, 0x02, "s4addl " }, + { 0x10, 0x0b, "s4subl " }, + { 0x10, 0x22, "s4addq " }, + { 0x10, 0x2b, "s4subq " }, + { 0x10, 0x12, "s8addl " }, + { 0x10, 0x1b, "s8subl " }, + { 0x10, 0x32, "s8addq " }, + { 0x10, 0x3b, "s8subq " }, + { 0x11, 0x00, "and " }, + { 0x11, 0x20, "or " }, + { 0x11, 0x40, "xor " }, + { 0x11, 0x08, "andnot " }, + { 0x11, 0x28, "ornot " }, + { 0x11, 0x48, "xornot " }, + { 0x11, 0x24, "cmoveq " }, + { 0x11, 0x44, "cmovlt " }, + { 0x11, 0x64, "cmovle " }, + { 0x11, 0x26, "cmovne " }, + { 0x11, 0x46, "cmovge " }, + { 0x11, 0x66, "cmovgt " }, + { 0x11, 0x14, "cmovlbs" }, + { 0x11, 0x16, "cmovlbc" }, + { 0x12, 0x39, "sll " }, + { 0x12, 0x3C, "sra " }, + { 0x12, 0x34, "srl " }, + { 0x12, 0x30, "zap " }, + { 0x12, 0x31, "zapnot " }, + { 0x12, 0x06, "extbl " }, + { 0x12, 0x16, "extwl " }, + { 0x12, 0x26, "extll " }, + { 0x12, 0x36, "extql " }, + { 0x12, 0x5a, "extwh " }, + { 0x12, 0x6a, "extlh " }, + { 0x12, 0x7a, "extqh " }, + { 0x12, 0x0b, "insbl " }, + { 0x12, 0x1b, "inswl " }, + { 0x12, 0x2b, "insll " }, + { 0x12, 0x3b, "insql " }, + { 0x12, 0x57, "inswh " }, + { 0x12, 0x67, "inslh " }, + { 0x12, 0x77, "insqh " }, + { 0x12, 0x02, "mskbl " }, + { 0x12, 0x12, "mskwl " }, + { 0x12, 0x22, "mskll " }, + { 0x12, 0x32, "mskql " }, + { 0x12, 0x52, "mskwh " }, + { 0x12, 0x62, "msklh " }, + { 0x12, 0x72, "mskqh " }, + { 0x13, 0x00, "mull " }, + { 0x13, 0x20, "mulq " }, + { 0x13, 0x40, "mull/v " }, + { 0x13, 0x60, "mulq/v " }, + { 0x13, 0x30, "umulh " }, + { 0x16, 0x080, "fadd " }, + { 0x16, 0x0a0, "dadd " }, + { 0x16, 0x081, "fsub " }, + { 0x16, 0x0a1, "dsub " }, + { 0x16, 0x082, "fmul " }, + { 0x16, 0x0a2, "dmul " }, + { 0x16, 0x083, "fdiv " }, + { 0x16, 0x0a3, "ddiv " }, + { 0x16, 0x580, "fadds " }, + { 0x16, 0x5a0, "dadds " }, + { 0x16, 0x581, "fsubs " }, + { 0x16, 0x5a1, "dsubs " }, + { 0x16, 0x582, "fmuls " }, + { 0x16, 0x5a2, "dmuls " }, + { 0x16, 0x583, "fdivs " }, + { 0x16, 0x5a3, "ddivs " }, + { 0x16, 0x0ac, "cvtdf " }, + { 0x16, 0x0bc, "cvtlf " }, + { 0x16, 0x0be, "cvtld " }, + { 0x16, 0x0af, "cvtdl " }, + { 0x16, 0x02f, "cvtdlc " }, + { 0x17, 0x030, "cvtli " }, + { 0x16, 0x1af, "cvtdlv " }, + { 0x16, 0x12f, "cvtdlcv" }, + { 0x17, 0x130, "cvtliv " }, + { 0x16, 0x5ac, "cvtdfs " }, + { 0x16, 0x5af, "cvtdls " }, + { 0x16, 0x52f, "cvtdlcs" }, + { 0x16, 0x0a4, "fcmpun " }, + { 0x16, 0x0a5, "fcmpeq " }, + { 0x16, 0x0a6, "fcmplt " }, + { 0x16, 0x0a7, "fcmple " }, + { 0x16, 0x5a4, "fcmpuns" }, + { 0x16, 0x5a5, "fcmpeqs" }, + { 0x16, 0x5a6, "fcmplts" }, + { 0x16, 0x5a7, "fcmples" }, + { 0x17, 0x020, "fmov " }, + { 0x17, 0x021, "fmovn " }, + { 0x1c, 0x0, "bsext " }, + { 0x1c, 0x1, "wsext " }, { 0x00, 0x00, NULL } }; +/* name table for 32 integer registers */ + +static char *regs[] = { + + /* 0x00 */ "v0", /* "$0", */ + /* 0x01 */ "t0", /* "$1", */ + /* 0x02 */ "t1", /* "$2", */ + /* 0x03 */ "t2", /* "$3", */ + /* 0x04 */ "t3", /* "$4", */ + /* 0x05 */ "t4", /* "$5", */ + /* 0x06 */ "t5", /* "$6", */ + /* 0x07 */ "t6", /* "$7", */ + + /* 0x08 */ "t7", /* "$8", */ + /* 0x09 */ "s0", /* "$9", */ + /* 0x0a */ "s1", /* "$10", */ + /* 0x0b */ "s2", /* "$11", */ + /* 0x0c */ "s3", /* "$12", */ + /* 0x0d */ "s4", /* "$13", */ + /* 0x0e */ "s5", /* "$14", */ + /* 0x0f */ "s6", /* "$15", */ + + /* 0x10 */ "a0", /* "$16", */ + /* 0x11 */ "a1", /* "$17", */ + /* 0x12 */ "a2", /* "$18", */ + /* 0x13 */ "a3", /* "$19", */ + /* 0x14 */ "a4", /* "$20", */ + /* 0x15 */ "a5", /* "$21", */ + /* 0x16 */ "t8", /* "$22", */ + /* 0x17 */ "t9", /* "$23", */ + + /* 0x18 */ "t10", /* "$24", */ + /* 0x19 */ "t11", /* "$25", */ + /* 0x1a */ "ra", /* "$26", */ + /* 0x1b */ "pv", /* "$27", */ + /* 0x1c */ "at", /* "$28", */ + /* 0x1d */ "gp", /* "$29", */ + /* 0x1e */ "sp", /* "$30", */ + /* 0x1f */ "zero" /* "$31" */ +}; + + /* function disassinstr ******************************************************** outputs a disassembler listing of one machine code instruction on 'stdout' @@ -243,33 +290,60 @@ static void disassinstr(int c, int pos) case ITYPE_JMP: switch ((c >> 14) & 3) { /* branch hint */ case 0: - printf ("JMP "); + if (ra == 31) { + printf ("jmp (%s)\n", regs[rb]); + return; + } + printf ("jmp "); break; case 1: - printf ("JSR "); + if (ra == 26) { + printf ("jsr (%s)\n", regs[rb]); + return; + } + printf ("jsr "); break; case 2: - printf ("RET "); + if (ra == 31 && rb == 26) { + printf ("ret\n"); + return; + } + if (ra == 31) { + printf ("ret (%s)\n", regs[rb]); + return; + } + printf ("ret "); break; case 3: - printf ("JSR_CO "); + printf ("jsr_co "); break; } - printf ("$%d,$%d\n", ra, rb); + printf ("%s,(%s)\n", regs[ra], regs[rb]); break; case ITYPE_MEM: { int disp = (c << 16) >> 16; /* 16 bit signed displacement */ if (op == 0x18 && ra == 0 && ra == 0 && disp == 0) - printf ("TRAPB\n"); + printf ("trapb\n"); else - printf ("%s $%d,$%d,%d\n", ops[op].name, ra, rb, disp); + printf ("%s %s,%d(%s)\n", ops[op].name, regs[ra], disp, regs[rb]); + break; + } + + case ITYPE_FMEM: { + printf ("%s $f%d,%d(%s)\n", ops[op].name, ra, (c << 16) >> 16, regs[rb]); break; } case ITYPE_BRA: /* 21 bit signed branch offset */ - printf("%s $%d,%x\n", ops[op].name, ra, pos + 4 + ((c << 11) >> 9)); + if (op == 0x30 && ra == 31) + printf("br 0x%x\n", pos + 4 + ((c << 11) >> 9)); + else if (op == 0x34 && ra == 26) + printf("brs 0x%x\n", pos + 4 + ((c << 11) >> 9)); + else + printf("%s %s,0x%x\n", + ops[op].name, regs[ra], pos + 4 + ((c << 11) >> 9)); break; case ITYPE_FOP: { @@ -277,9 +351,9 @@ static void disassinstr(int c, int pos) if (op == 0x17 && fopfun == 0x020 && ra == rb) { if (ra == 31 && rc == 31) - printf("FNOP\n"); + printf("fnop\n"); else - printf("FMOV $f%d,$f%d\n", ra, rc); + printf("fmov $f%d,$f%d\n", ra, rc); return; } for (i = 0; op3s[i].name; i++) @@ -294,26 +368,28 @@ static void disassinstr(int c, int pos) case ITYPE_OP: if (op == 0x11 && opfun == 0x20 && ra == rb && ~(c&0x1000)) { if (ra == 31 && rc == 31) - printf("NOP\n"); + printf("nop\n"); else if (ra == 31) - printf("CLR $%d\n", rc); + printf("clr %s\n", regs[rc]); else - printf("MOV $%d,$%d\n", ra, rc); + printf("mov %s,%s\n", regs[ra], regs[rc]); return; } for (i = 0; op3s[i].name; i++) { if (op3s[i].op == op && op3s[i].fun == opfun) { if (c & 0x1000) /* immediate instruction */ - printf("%s $%d,#%d,$%d\n", op3s[i].name, ra, lit, rc); + printf("%s %s,%d,%s\n", + op3s[i].name, regs[ra], lit, regs[rc]); else - printf("%s $%d,$%d,$%d\n", op3s[i].name, ra, rb, rc); + printf("%s %s,%s,%s\n", + op3s[i].name, regs[ra], regs[rb], regs[rc]); return; } } /* fall through */ default: if (c & 0x1000) /* immediate instruction */ - printf("UNDEF %x(%x) $%d,#%d,$%d\n", op, opfun, ra, lit, rc); + printf("UNDEF %x(%x) $%d,%d,$%d\n", op, opfun, ra, lit, rc); else printf("UNDEF %x(%x) $%d,$%d,$%d\n", op, opfun, ra, rb, rc); } diff --git a/alpha/ngen.c b/alpha/ngen.c index 5babc8a40..0a4c7616b 100644 --- a/alpha/ngen.c +++ b/alpha/ngen.c @@ -2948,8 +2948,13 @@ nowperformreturn: var_to_reg_int(s1, src, REG_ITMP1); if (l == 0) {M_INTMOVE(s1, REG_ITMP1);} - else + else if (l <= 32768) { M_LDA(REG_ITMP1, s1, -l); + } + else { + ICONST(REG_ITMP2, l); + M_ISUB(s1, REG_ITMP2, REG_ITMP1); + } i = i - l + 1; /* range check */ @@ -3318,7 +3323,7 @@ makeactualcall: /* a0 = dimension count */ - M_LDA(argintregs[0], REG_ZERO, iptr->op1); + ICONST(argintregs[0], iptr->op1); /* a1 = arraydescriptor */ diff --git a/alpha/types.h b/alpha/types.h index 464e71041..94b377914 100644 --- a/alpha/types.h +++ b/alpha/types.h @@ -34,6 +34,8 @@ #define SUPPORT_LONG_ICVT 1 #define SUPPORT_LONG_FCVT 1 +#define CONDITIONAL_LOADCONST + #define U8_AVAILABLE 1 diff --git a/jit/stack.c b/jit/stack.c index ef56f3501..cd5f44240 100644 --- a/jit/stack.c +++ b/jit/stack.c @@ -12,8 +12,6 @@ *******************************************************************************/ -#define CONDITIONAL_LOADCONST - #ifdef STATISTICS #define COUNT(cnt) cnt++ #else @@ -1544,18 +1542,20 @@ static void print_stack(stackptr s) { switch (s->varkind) { case TEMPVAR: if (s->flags & INMEMORY) - printf(" m%02d", s->regoff); + printf(" M%02d", s->regoff); + else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL)) + printf(" F%02d", s->regoff); else - printf(" r%02d", s->regoff); + printf(" %3s", regs[s->regoff]); break; case STACKVAR: - printf(" s%02d", s->varnum); + printf(" I%02d", s->varnum); break; case LOCALVAR: - printf(" l%02d", s->varnum); + printf(" L%02d", s->varnum); break; case ARGVAR: - printf(" a%02d", s->varnum); + printf(" A%02d", s->varnum); break; default: printf(" !%02d", j); @@ -1564,18 +1564,20 @@ static void print_stack(stackptr s) { switch (s->varkind) { case TEMPVAR: if (s->flags & INMEMORY) - printf(" M%02d", s->regoff); + printf(" m%02d", s->regoff); + else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL)) + printf(" f%02d", s->regoff); else - printf(" R%02d", s->regoff); + printf(" %3s", regs[s->regoff]); break; case STACKVAR: - printf(" S%02d", s->varnum); + printf(" i%02d", s->varnum); break; case LOCALVAR: - printf(" L%02d", s->varnum); + printf(" l%02d", s->varnum); break; case ARGVAR: - printf(" A%02d", s->varnum); + printf(" a%02d", s->varnum); break; default: printf(" ?%02d", j); @@ -1585,6 +1587,7 @@ static void print_stack(stackptr s) { } +#if 0 static void print_reg(stackptr s) { if (s) { if (s->flags & SAVEDVAR) @@ -1632,6 +1635,7 @@ static void print_reg(stackptr s) { printf(" "); } +#endif static char *builtin_name(functionptr bptr) @@ -1643,6 +1647,15 @@ static char *builtin_name(functionptr bptr) } +static char *jit_type[] = { + "int", + "lng", + "flt", + "dbl", + "adr" +}; + + static void show_icmd_method() { int b, i, j, last; @@ -1671,12 +1684,13 @@ static void show_icmd_method() printf(" %3d: ", i); for (j = TYPE_INT; j <= TYPE_ADR; j++) if (locals[i][j].type >= 0) { - printf(" (%d) ", j); - if (locals[i][j].flags) - printf("m"); + printf(" (%s) ", jit_type[j]); + if (locals[i][j].flags & INMEMORY) + printf("m%2d", locals[i][j].regoff); + else if ((j == TYPE_FLT) || (j == TYPE_DBL)) + printf("f%02d", locals[i][j].regoff); else - printf("r"); - printf("%2d", locals[i][j].regoff); + printf("%3s", regs[locals[i][j].regoff]); } printf("\n"); } @@ -1690,16 +1704,23 @@ static void show_icmd_method() printf(" %3d: ", i); for (j = TYPE_INT; j <= TYPE_ADR; j++) if (interfaces[i][j].type >= 0) { - printf(" (%d) ", j); - if (interfaces[i][j].flags & SAVEDVAR) - printf("s"); - else - printf("t"); - if (interfaces[i][j].flags & INMEMORY) - printf("m"); - else - printf("r"); - printf("%2d", interfaces[i][j].regoff); + printf(" (%s) ", jit_type[j]); + if (interfaces[i][j].flags & SAVEDVAR) { + if (interfaces[i][j].flags & INMEMORY) + printf("M%2d", interfaces[i][j].regoff); + else if ((j == TYPE_FLT) || (j == TYPE_DBL)) + printf("F%02d", interfaces[i][j].regoff); + else + printf("%3s", regs[interfaces[i][j].regoff]); + } + else { + if (interfaces[i][j].flags & INMEMORY) + printf("m%2d", interfaces[i][j].regoff); + else if ((j == TYPE_FLT) || (j == TYPE_DBL)) + printf("f%02d", interfaces[i][j].regoff); + else + printf("%3s", regs[interfaces[i][j].regoff]); + } } printf("\n"); } diff --git a/src/vm/jit/stack.c b/src/vm/jit/stack.c index ef56f3501..cd5f44240 100644 --- a/src/vm/jit/stack.c +++ b/src/vm/jit/stack.c @@ -12,8 +12,6 @@ *******************************************************************************/ -#define CONDITIONAL_LOADCONST - #ifdef STATISTICS #define COUNT(cnt) cnt++ #else @@ -1544,18 +1542,20 @@ static void print_stack(stackptr s) { switch (s->varkind) { case TEMPVAR: if (s->flags & INMEMORY) - printf(" m%02d", s->regoff); + printf(" M%02d", s->regoff); + else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL)) + printf(" F%02d", s->regoff); else - printf(" r%02d", s->regoff); + printf(" %3s", regs[s->regoff]); break; case STACKVAR: - printf(" s%02d", s->varnum); + printf(" I%02d", s->varnum); break; case LOCALVAR: - printf(" l%02d", s->varnum); + printf(" L%02d", s->varnum); break; case ARGVAR: - printf(" a%02d", s->varnum); + printf(" A%02d", s->varnum); break; default: printf(" !%02d", j); @@ -1564,18 +1564,20 @@ static void print_stack(stackptr s) { switch (s->varkind) { case TEMPVAR: if (s->flags & INMEMORY) - printf(" M%02d", s->regoff); + printf(" m%02d", s->regoff); + else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL)) + printf(" f%02d", s->regoff); else - printf(" R%02d", s->regoff); + printf(" %3s", regs[s->regoff]); break; case STACKVAR: - printf(" S%02d", s->varnum); + printf(" i%02d", s->varnum); break; case LOCALVAR: - printf(" L%02d", s->varnum); + printf(" l%02d", s->varnum); break; case ARGVAR: - printf(" A%02d", s->varnum); + printf(" a%02d", s->varnum); break; default: printf(" ?%02d", j); @@ -1585,6 +1587,7 @@ static void print_stack(stackptr s) { } +#if 0 static void print_reg(stackptr s) { if (s) { if (s->flags & SAVEDVAR) @@ -1632,6 +1635,7 @@ static void print_reg(stackptr s) { printf(" "); } +#endif static char *builtin_name(functionptr bptr) @@ -1643,6 +1647,15 @@ static char *builtin_name(functionptr bptr) } +static char *jit_type[] = { + "int", + "lng", + "flt", + "dbl", + "adr" +}; + + static void show_icmd_method() { int b, i, j, last; @@ -1671,12 +1684,13 @@ static void show_icmd_method() printf(" %3d: ", i); for (j = TYPE_INT; j <= TYPE_ADR; j++) if (locals[i][j].type >= 0) { - printf(" (%d) ", j); - if (locals[i][j].flags) - printf("m"); + printf(" (%s) ", jit_type[j]); + if (locals[i][j].flags & INMEMORY) + printf("m%2d", locals[i][j].regoff); + else if ((j == TYPE_FLT) || (j == TYPE_DBL)) + printf("f%02d", locals[i][j].regoff); else - printf("r"); - printf("%2d", locals[i][j].regoff); + printf("%3s", regs[locals[i][j].regoff]); } printf("\n"); } @@ -1690,16 +1704,23 @@ static void show_icmd_method() printf(" %3d: ", i); for (j = TYPE_INT; j <= TYPE_ADR; j++) if (interfaces[i][j].type >= 0) { - printf(" (%d) ", j); - if (interfaces[i][j].flags & SAVEDVAR) - printf("s"); - else - printf("t"); - if (interfaces[i][j].flags & INMEMORY) - printf("m"); - else - printf("r"); - printf("%2d", interfaces[i][j].regoff); + printf(" (%s) ", jit_type[j]); + if (interfaces[i][j].flags & SAVEDVAR) { + if (interfaces[i][j].flags & INMEMORY) + printf("M%2d", interfaces[i][j].regoff); + else if ((j == TYPE_FLT) || (j == TYPE_DBL)) + printf("F%02d", interfaces[i][j].regoff); + else + printf("%3s", regs[interfaces[i][j].regoff]); + } + else { + if (interfaces[i][j].flags & INMEMORY) + printf("m%2d", interfaces[i][j].regoff); + else if ((j == TYPE_FLT) || (j == TYPE_DBL)) + printf("f%02d", interfaces[i][j].regoff); + else + printf("%3s", regs[interfaces[i][j].regoff]); + } } printf("\n"); } -- 2.25.1