mirror of
https://github.com/Interlisp/maiko.git
synced 2026-04-27 20:58:44 +00:00
Inline swapx and byte_swap_word. (#323)
This lets us remove `SWAP_WORDS` and some bits of assembly.
This commit is contained in:
@@ -1,7 +1,24 @@
|
|||||||
#ifndef BYTESWAPDEFS_H
|
#ifndef BYTESWAPDEFS_H
|
||||||
#define BYTESWAPDEFS_H 1
|
#define BYTESWAPDEFS_H 1
|
||||||
unsigned int swapx(unsigned int word);
|
|
||||||
unsigned short byte_swap_word(unsigned short word);
|
/****************************************************************/
|
||||||
|
/* */
|
||||||
|
/* swap halves of a single 4-byte word */
|
||||||
|
/* */
|
||||||
|
/****************************************************************/
|
||||||
|
static inline unsigned int swapx(unsigned int word) {
|
||||||
|
return (((word >> 16) & 0xffff) | ((word & 0xffff) << 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Byte-swap a single 2-byte word */
|
||||||
|
/* */
|
||||||
|
/****************************************************************/
|
||||||
|
static inline unsigned short byte_swap_word(unsigned short word) {
|
||||||
|
return (((word >> 8) & 0xff) | ((word & 0xff) << 8));
|
||||||
|
}
|
||||||
|
|
||||||
void byte_swap_page(unsigned short *page, int wordcount);
|
void byte_swap_page(unsigned short *page, int wordcount);
|
||||||
void word_swap_page(unsigned short *page, int longwordcount);
|
void word_swap_page(unsigned short *page, int longwordcount);
|
||||||
void bit_reverse_region(unsigned short *top, int width, int height, int rasterwidth);
|
void bit_reverse_region(unsigned short *top, int width, int height, int rasterwidth);
|
||||||
|
|||||||
@@ -68,7 +68,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#define CHECK_INTERRUPT {if((UNSIGNED)CSTKPTR > Irq_Stk_Check) goto check_interrupt;}
|
#define CHECK_INTERRUPT {if((UNSIGNED)CSTKPTR > Irq_Stk_Check) goto check_interrupt;}
|
||||||
#define SWAP_WORDS(x) (((unsigned int)x << 16) | (((unsigned int)x >> 16) & 0xFFFF))
|
|
||||||
|
|
||||||
|
|
||||||
#define nextop0 {goto nextopcode; }
|
#define nextop0 {goto nextopcode; }
|
||||||
@@ -686,10 +685,10 @@ register LispPTR *chain; \
|
|||||||
chain = (LispPTR *) (PVar + n); \
|
chain = (LispPTR *) (PVar + n); \
|
||||||
if(WBITSPTR(chain)->LSB){ \
|
if(WBITSPTR(chain)->LSB){ \
|
||||||
PUSH(GetLongWord(Addr68k_from_LADDR( \
|
PUSH(GetLongWord(Addr68k_from_LADDR( \
|
||||||
POINTERMASK & SWAP_WORDS(native_newframe(n >> 1))))); \
|
POINTERMASK & swapx(native_newframe(n >> 1))))); \
|
||||||
nextop1; \
|
nextop1; \
|
||||||
}/* if(((WBITS */ \
|
}/* if(((WBITS */ \
|
||||||
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \
|
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & swapx(*chain)))); \
|
||||||
nextop1; \
|
nextop1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,10 +698,10 @@ register LispPTR *chain; \
|
|||||||
chain = (LispPTR *) (PVar + nn); \
|
chain = (LispPTR *) (PVar + nn); \
|
||||||
if(WBITSPTR(chain)->LSB){ \
|
if(WBITSPTR(chain)->LSB){ \
|
||||||
PUSH(GetLongWord(Addr68k_from_LADDR( \
|
PUSH(GetLongWord(Addr68k_from_LADDR( \
|
||||||
POINTERMASK & SWAP_WORDS(native_newframe(nn >> 1))))); \
|
POINTERMASK & swapx(native_newframe(nn >> 1))))); \
|
||||||
nextop2; \
|
nextop2; \
|
||||||
}/* if(((WBITS */ \
|
}/* if(((WBITS */ \
|
||||||
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \
|
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & swapx(*chain)))); \
|
||||||
nextop2; \
|
nextop2; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,6 @@
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* use the swapx [inline] function to swap words in a dword */
|
|
||||||
#undef SWAP_WORDS
|
|
||||||
#define SWAP_WORDS(x) swapx(x)
|
|
||||||
|
|
||||||
|
|
||||||
/* undefine these macros so we use the 386i inline code */
|
/* undefine these macros so we use the 386i inline code */
|
||||||
#undef Get_BYTE_PCMAC0
|
#undef Get_BYTE_PCMAC0
|
||||||
#undef Get_BYTE_PCMAC1
|
#undef Get_BYTE_PCMAC1
|
||||||
|
|||||||
@@ -39,10 +39,7 @@
|
|||||||
#undef LISTP
|
#undef LISTP
|
||||||
#undef NTYPEX
|
#undef NTYPEX
|
||||||
#undef TYPEP
|
#undef TYPEP
|
||||||
#undef SWAP_WORDS
|
|
||||||
|
|
||||||
#define SWAP_WORDS(x) swapx(x)
|
|
||||||
|
|
||||||
#define DIFFERENCE { \
|
#define DIFFERENCE { \
|
||||||
TOPOFSTACK = op_difference(POP_TOS_1, TOPOFSTACK); \
|
TOPOFSTACK = op_difference(POP_TOS_1, TOPOFSTACK); \
|
||||||
nextop1; \
|
nextop1; \
|
||||||
|
|||||||
@@ -145,7 +145,3 @@ lispemul.h: typedef struct {unsigned code : 8;} BYTECODE;
|
|||||||
UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \
|
UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \
|
||||||
TOPOFSTACK = POP_TOS_1 + arg2; \
|
TOPOFSTACK = POP_TOS_1 + arg2; \
|
||||||
nextop1;}
|
nextop1;}
|
||||||
|
|
||||||
|
|
||||||
#undef SWAP_WORDS
|
|
||||||
#define SWAP_WORDS(x) swapx(x)
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#define SWAP_FNHEAD
|
#define SWAP_FNHEAD
|
||||||
#else
|
#else
|
||||||
#undef SWAP_FNHEAD
|
#undef SWAP_FNHEAD
|
||||||
#define SWAP_FNHEAD(x) SWAP_WORDS(x)
|
#define SWAP_FNHEAD(x) swapx(x)
|
||||||
#endif /* BIGVM */
|
#endif /* BIGVM */
|
||||||
|
|
||||||
|
|
||||||
@@ -638,7 +638,7 @@ op_fn_common: \
|
|||||||
\
|
\
|
||||||
case TYPE_NEWATOM: \
|
case TYPE_NEWATOM: \
|
||||||
nnewframe(CURRENTFX, &scratch, TOPOFSTACK); \
|
nnewframe(CURRENTFX, &scratch, TOPOFSTACK); \
|
||||||
work = POINTERMASK & SWAP_WORDS(scratch); \
|
work = POINTERMASK & swapx(scratch); \
|
||||||
lookuped = *((LispPTR *) \
|
lookuped = *((LispPTR *) \
|
||||||
(Addr68k_from_LADDR(work))); \
|
(Addr68k_from_LADDR(work))); \
|
||||||
if(lookuped==NOBIND_PTR) goto op_ufn; \
|
if(lookuped==NOBIND_PTR) goto op_ufn; \
|
||||||
|
|||||||
@@ -27,24 +27,6 @@
|
|||||||
|
|
||||||
#include "byteswapdefs.h"
|
#include "byteswapdefs.h"
|
||||||
|
|
||||||
/****************************************************************/
|
|
||||||
/* */
|
|
||||||
/* swap halves of a single 4-byte word */
|
|
||||||
/* */
|
|
||||||
/****************************************************************/
|
|
||||||
unsigned int swapx(unsigned int word) {
|
|
||||||
return (((word >> 16) & 0xffff) | ((word & 0xffff) << 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************/
|
|
||||||
/* */
|
|
||||||
/* Byte-swap a single 2-byte word */
|
|
||||||
/* */
|
|
||||||
/****************************************************************/
|
|
||||||
unsigned short byte_swap_word(unsigned short word) {
|
|
||||||
return (((word >> 8) & 0xff) | ((word & 0xff) << 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************/
|
/****************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* Byte-swap a region wordcount words long */
|
/* Byte-swap a region wordcount words long */
|
||||||
|
|||||||
@@ -90,14 +90,6 @@ done: ! else done;
|
|||||||
be fixed through the ifdef flats.
|
be fixed through the ifdef flats.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* SWAP halves of a register */
|
|
||||||
|
|
||||||
.inline _swapx,4
|
|
||||||
sll %o0,16,%o1
|
|
||||||
srl %o0,16,%o0
|
|
||||||
or %o0,%o1,%o0
|
|
||||||
.end
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
***************************************************************
|
***************************************************************
|
||||||
DIFFERENCE VERSIONS sp@ - sp@(4) i.e. (tos-1) - (tos)
|
DIFFERENCE VERSIONS sp@ - sp@(4) i.e. (tos-1) - (tos)
|
||||||
|
|||||||
1
src/xc.c
1
src/xc.c
@@ -66,6 +66,7 @@
|
|||||||
#include "array6defs.h"
|
#include "array6defs.h"
|
||||||
#include "bitbltdefs.h"
|
#include "bitbltdefs.h"
|
||||||
#include "bltdefs.h"
|
#include "bltdefs.h"
|
||||||
|
#include "byteswapdefs.h"
|
||||||
#include "car-cdrdefs.h"
|
#include "car-cdrdefs.h"
|
||||||
#include "commondefs.h"
|
#include "commondefs.h"
|
||||||
#include "conspagedefs.h"
|
#include "conspagedefs.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user