1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-04 18:34:14 +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:
Bruce Mitchener
2021-01-30 14:18:09 +07:00
committed by GitHub
parent 0480fee86c
commit b09663b3e9
9 changed files with 26 additions and 47 deletions

View File

@@ -1,7 +1,24 @@
#ifndef BYTESWAPDEFS_H
#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 word_swap_page(unsigned short *page, int longwordcount);
void bit_reverse_region(unsigned short *top, int width, int height, int rasterwidth);

View File

@@ -68,7 +68,6 @@
#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; }
@@ -686,10 +685,10 @@ register LispPTR *chain; \
chain = (LispPTR *) (PVar + n); \
if(WBITSPTR(chain)->LSB){ \
PUSH(GetLongWord(Addr68k_from_LADDR( \
POINTERMASK & SWAP_WORDS(native_newframe(n >> 1))))); \
POINTERMASK & swapx(native_newframe(n >> 1))))); \
nextop1; \
}/* if(((WBITS */ \
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & swapx(*chain)))); \
nextop1; \
}
@@ -699,10 +698,10 @@ register LispPTR *chain; \
chain = (LispPTR *) (PVar + nn); \
if(WBITSPTR(chain)->LSB){ \
PUSH(GetLongWord(Addr68k_from_LADDR( \
POINTERMASK & SWAP_WORDS(native_newframe(nn >> 1))))); \
POINTERMASK & swapx(native_newframe(nn >> 1))))); \
nextop2; \
}/* if(((WBITS */ \
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \
PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & swapx(*chain)))); \
nextop2; \
}

View File

@@ -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 */
#undef Get_BYTE_PCMAC0
#undef Get_BYTE_PCMAC1

View File

@@ -39,10 +39,7 @@
#undef LISTP
#undef NTYPEX
#undef TYPEP
#undef SWAP_WORDS
#define SWAP_WORDS(x) swapx(x)
#define DIFFERENCE { \
TOPOFSTACK = op_difference(POP_TOS_1, TOPOFSTACK); \
nextop1; \

View File

@@ -145,7 +145,3 @@ lispemul.h: typedef struct {unsigned code : 8;} BYTECODE;
UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \
TOPOFSTACK = POP_TOS_1 + arg2; \
nextop1;}
#undef SWAP_WORDS
#define SWAP_WORDS(x) swapx(x)

View File

@@ -42,7 +42,7 @@
#define SWAP_FNHEAD
#else
#undef SWAP_FNHEAD
#define SWAP_FNHEAD(x) SWAP_WORDS(x)
#define SWAP_FNHEAD(x) swapx(x)
#endif /* BIGVM */
@@ -638,7 +638,7 @@ op_fn_common: \
\
case TYPE_NEWATOM: \
nnewframe(CURRENTFX, &scratch, TOPOFSTACK); \
work = POINTERMASK & SWAP_WORDS(scratch); \
work = POINTERMASK & swapx(scratch); \
lookuped = *((LispPTR *) \
(Addr68k_from_LADDR(work))); \
if(lookuped==NOBIND_PTR) goto op_ufn; \

View File

@@ -27,24 +27,6 @@
#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 */

View File

@@ -90,14 +90,6 @@ done: ! else done;
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)

View File

@@ -66,6 +66,7 @@
#include "array6defs.h"
#include "bitbltdefs.h"
#include "bltdefs.h"
#include "byteswapdefs.h"
#include "car-cdrdefs.h"
#include "commondefs.h"
#include "conspagedefs.h"