Thu Mar 7 11:19:33 1996 James G. Smith <jsmith@cygnus.co.uk>

* gencode.c, interp.c: Replaced explicit long long references with
 	WORD64HI, WORD64LO, SET64HI and SET64LO macro calls.
	* support.h (SET64LO, SET64HI): Macros added.

This is an intermediate checkin. The work of removing "long long"
usage is not yet finished. These changes are clean, and have been
sitting on my machine for a while (whilst doing other work), and it is
safer for them to be checked in.
This commit is contained in:
Jackie Smith Cashion 1996-03-07 11:25:15 +00:00
parent 653fed07a6
commit a647a859cb
2 changed files with 72 additions and 38 deletions

View file

@ -1,10 +1,22 @@
/*> gencode.c <*/
/*---------------------------------------------------------------------------*/
/* $Revision$ */
/* $Author$ */
/* $Date$ */
/* Copyright (c) 1995, Cygnus Support */
/*---------------------------------------------------------------------------*/
/* Instruction handling support for the MIPS architecture simulator.
This file is part of the MIPS sim
THIS SOFTWARE IS NOT COPYRIGHTED
Cygnus offers the following for use in the public domain. Cygnus
makes no warranty with regard to the software or it's performance
and the user accepts the software "AS IS" with all faults.
CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
$Revision$
$Author$
$Date$
*/
#if 0
#define DEBUG (1) /* Just for testing */
@ -1028,22 +1040,22 @@ process_instructions(doarch,features)
if (GETDATASIZE() == DOUBLEWORD) {
printf(" uword64 mid;\n");
printf(" uword64 temp;\n");
printf(" LO = ((op1 & 0xFFFFFFFF) * (op2 & 0xFFFFFFFF));\n");
printf(" HI = ((op1 >> 32) * (op2 >> 32));\n");
printf(" mid = ((op1 >> 32) * (op2 & 0xFFFFFFFF));\n");
printf(" temp = (LO + ((mid & 0xFFFFFFFF) << 32));\n");
printf(" LO = ((uword64)WORD64LO(op1) * WORD64LO(op2));\n");
printf(" HI = ((uword64)WORD64HI(op1) * WORD64HI(op2));\n");
printf(" mid = ((uword64)WORD64HI(op1) * WORD64LO(op2));\n");
printf(" temp = (LO + SET64HI(WORD64LO(mid)));\n");
printf(" if ((temp == mid) ? (LO != 0) : (temp < mid))\n");
printf(" HI += 1;\n");
printf(" HI += ((mid >> 32) & 0xFFFFFFFF);\n");
printf(" mid = ((op1 & 0xFFFFFFFF) * (op2 >> 32));\n");
printf(" LO = (temp + ((mid & 0xFFFFFFFF) << 32));\n");
printf(" HI += WORD64HI(mid);\n");
printf(" mid = ((uword64)WORD64LO(op1) * WORD64HI(op2));\n");
printf(" LO = (temp + SET64HI(WORD64LO(mid)));\n");
printf(" if ((LO == mid) ? (temp != 0) : (LO < mid))\n");
printf(" HI += 1;\n");
printf(" HI += ((mid >> 32) & 0xFFFFFFFF);\n");
printf(" HI += WORD64HI(mid);\n");
} else {
printf(" uword64 temp = (op1 * op2);\n");
printf(" LO = SIGNEXTEND((%s)(temp & 0xFFFFFFFF),32);\n",regtype);
printf(" HI = SIGNEXTEND((%s)((temp >> 32) & 0xFFFFFFFF),32);\n",regtype);
printf(" LO = SIGNEXTEND((%s)WORD64LO(temp),32);\n",regtype);
printf(" HI = SIGNEXTEND((%s)WORD64HI(temp),32);\n",regtype);
}
printf(" }\n");
break ;
@ -1251,9 +1263,9 @@ process_instructions(doarch,features)
if (GETDATASIZE() == DOUBLEWORD) {
printf(" LO = LO + temp;\n");
} else { /* WORD */
printf(" temp += (((HI&0xFFFFFFFF) << 32) | (LO & 0xFFFFFFFF));\n");
printf(" LO = SIGNEXTEND((%s)(temp & 0xFFFFFFFF),32);\n",regtype);
printf(" HI = SIGNEXTEND((%s)((temp >> 32) & 0xFFFFFFFF),32);\n",regtype);
printf(" temp += (SET64HI(WORD64LO(HI)) | WORD64LO(LO));\n");
printf(" LO = SIGNEXTEND((%s)WORD64LO(temp),32);\n",regtype);
printf(" HI = SIGNEXTEND((%s)WORD64HI(temp),32);\n",regtype);
}
printf(" }\n");
break;
@ -1641,16 +1653,16 @@ process_instructions(doarch,features)
printf(" if (to) {\n");
if (doisa < 4) {
printf(" if (fs == 0) {\n");
printf(" PENDING_FILL((fs + FCR0IDX),(GPR[ft]&0xFFFFFFFF));\n");
printf(" PENDING_FILL((fs + FCR0IDX),WORD64LO(GPR[ft]));\n");
printf(" } else if (fs == 31) {\n");
printf(" PENDING_FILL((fs + FCR31IDX),(GPR[ft]&0xFFFFFFFF));\n");
printf(" PENDING_FILL((fs + FCR31IDX),WORD64LO(GPR[ft]));\n");
printf(" } /* else NOP */\n");
printf(" PENDING_FILL(COCIDX,0); /* special case */\n");
} else {
printf(" if (fs == 0) {\n");
printf(" FCR0 = (GPR[ft] & 0xFFFFFFFF);\n");
printf(" FCR0 = WORD64LO(GPR[ft]);\n");
printf(" } else if (fs == 31) {\n");
printf(" FCR31 = (GPR[ft] & 0xFFFFFFFF);\n");
printf(" FCR31 = WORD64LO(GPR[ft]);\n");
printf(" } /* else NOP */\n");
printf(" SETFCC(0,((FCR31 & (1 << 23)) ? 1 : 0)); /* COC[1] */\n");
}
@ -1674,15 +1686,15 @@ process_instructions(doarch,features)
if (GETDATASIZE() == WORD) {
if (doisa < 4) {
printf(" if (SizeFGR() == 64) {\n");
printf(" PENDING_FILL((fs + FGRIDX),((unsigned long long)((unsigned long long)0xDEADC0DE << 32) | (GPR[ft]&0xFFFFFFFF)));\n");
printf(" PENDING_FILL((fs + FGRIDX),(SET64HI(0xDEADC0DE) | WORD64LO(GPR[ft])));\n");
printf(" } else { \n");
printf(" PENDING_FILL((fs + FGRIDX),(GPR[ft]&0xFFFFFFFF));\n");
printf(" PENDING_FILL((fs + FGRIDX),WORD64LO(GPR[ft]));\n");
printf(" }\n");
} else {
printf(" if (SizeFGR() == 64)\n");
printf(" FGR[fs] = ((unsigned long long)((unsigned long long)0xDEADC0DE << 32) | (GPR[ft] & 0xFFFFFFFF));\n");
printf(" FGR[fs] = (SET64HI(0xDEADC0DE) | WORD64LO(GPR[ft]));\n");
printf(" else\n");
printf(" FGR[fs] = (GPR[ft] & 0xFFFFFFFF);\n");
printf(" FGR[fs] = WORD64LO(GPR[ft]);\n");
printf(" fpr_state[fs] = fmt_uninterpreted;\n");
}
} else if (GETDATASIZE() == DOUBLEWORD) {
@ -1692,8 +1704,8 @@ process_instructions(doarch,features)
printf(" } else\n");
printf(" if ((fs & 0x1) == 0)\n");
printf(" {\n");
printf(" PENDING_FILL(((fs + 1) + FGRIDX),(GPR[ft]>>32));\n");
printf(" PENDING_FILL((fs + FGRIDX),(GPR[ft]&0xFFFFFFFF));\n");
printf(" PENDING_FILL(((fs + 1) + FGRIDX),WORD64HI(GPR[ft]));\n");
printf(" PENDING_FILL((fs + FGRIDX),WORD64LO(GPR[ft]));\n");
printf(" }\n");
if (features & FEATURE_WARN_RESULT) {
printf(" else\n");
@ -1706,8 +1718,8 @@ process_instructions(doarch,features)
printf(" } else\n");
printf(" if ((fs & 0x1) == 0)\n");
printf(" {\n");
printf(" FGR[fs + 1] = (GPR[ft] >> 32);\n");
printf(" FGR[fs] = (GPR[ft] & 0xFFFFFFFF);\n");
printf(" FGR[fs + 1] = WORD64HI(GPR[ft]);\n");
printf(" FGR[fs] = WORD64LO(GPR[ft]);\n");
printf(" fpr_state[fs + 1] = fmt_uninterpreted;\n");
printf(" fpr_state[fs] = fmt_uninterpreted;\n");
printf(" }\n");
@ -1732,9 +1744,9 @@ process_instructions(doarch,features)
printf(" PENDING_FILL(ft,FGR[fs]);\n");
printf(" } else\n");
printf(" if ((fs & 0x1) == 0) {\n");
printf(" PENDING_FILL(ft,((FGR[fs+1]<<32)|FGR[fs]));\n");
printf(" PENDING_FILL(ft,(SET64HI(FGR[fs+1]) | FGR[fs]));\n");
printf(" } else {\n");
printf(" PENDING_FILL(ft,((unsigned long long)0xDEADC0DE << 32) | 0xBAD0BAD0);\n");
printf(" PENDING_FILL(ft,SET64HI(0xDEADC0DE) | 0xBAD0BAD0);\n");
if (features & FEATURE_WARN_RESULT)
printf(" UndefinedResult();\n");
printf(" }\n");
@ -1743,9 +1755,9 @@ process_instructions(doarch,features)
printf(" GPR[ft] = FGR[fs];\n");
printf(" else\n");
printf(" if ((fs & 0x1) == 0)\n");
printf(" GPR[ft] = ((FGR[fs + 1] << 32) | FGR[fs]);\n");
printf(" GPR[ft] = (SET64HI(FGR[fs + 1]) | FGR[fs]);\n");
printf(" else {\n");
printf(" GPR[ft] = (((unsigned long long)0xDEADC0DE << 32) | 0xBAD0BAD0);\n");
printf(" GPR[ft] = (SET64HI(0xDEADC0DE) | 0xBAD0BAD0);\n");
if (features & FEATURE_WARN_RESULT)
printf(" UndefinedResult();\n");
printf(" }\n");

View file

@ -1,4 +1,22 @@
/*> support.h <*/
/* Support for the MIPS architecture simulator.
This file is part of the MIPS sim
THIS SOFTWARE IS NOT COPYRIGHTED
Cygnus offers the following for use in the public domain. Cygnus
makes no warranty with regard to the software or it's performance
and the user accepts the software "AS IS" with all faults.
CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
$Revision$
$Author$
$Date$
*/
#ifndef __support_h
#define __support_h
@ -18,7 +36,9 @@ typedef long long word64;
typedef unsigned long long uword64;
#define WORD64LO(t) (unsigned int)((t)&0xFFFFFFFF)
#define WORD64HI(t) (unsigned int)((t)>>32)
#define WORD64HI(t) (unsigned int)(((uword64)(t))>>32)
#define SET64LO(t) (((uword64)(t))&0xFFFFFFFF)
#define SET64HI(t) (((uword64)(t))<<32)
/* Sign-extend the given value (e) as a value (b) bits long. We cannot
assume the HI32bits of the operand are zero, so we must perform a
@ -45,13 +65,15 @@ typedef unsigned long long uword64;
#error "non-GCC build to be completed" /* avoid using long long */
typedef struct word64 {
typedef struct uword64 {
unsigned int lo;
unsigned int hi;
} word64;
} uword64;
#define WORD64LO(t) (unsigned int)(t.lo)
#define WORD64HI(t) (unsigned int)(t.hi)
#define SET64LO(t) (..TODO..) /* need structure into which value will be placed */
#define SET64HI(t) (..TODO..) /* need structure into which value will be placed */
/* TODO: Update these to manipulate the split structure values */
#define SIGNEXTEND(e,b) /* TODO */