#define DISASSEM 0
#define X86_TWOB 0x0f
-static GLubyte *cptr( void (*label)() )
+static unsigned char *cptr( void (*label)() )
{
- return (char *)(unsigned long)label;
+ return (unsigned char *)(unsigned long)label;
}
/* Emit bytes to the instruction stream:
*/
-static void emit_1b( struct x86_function *p, GLbyte b0 )
+static void emit_1b( struct x86_function *p, char b0 )
{
- *(GLbyte *)(p->csr++) = b0;
+ *(char *)(p->csr++) = b0;
}
-static void emit_1i( struct x86_function *p, GLint i0 )
+static void emit_1i( struct x86_function *p, int i0 )
{
- *(GLint *)(p->csr) = i0;
+ *(int *)(p->csr) = i0;
p->csr += 4;
}
#endif
}
-static void emit_1ub_fn( struct x86_function *p, GLubyte b0, const char *fn )
+static void emit_1ub_fn( struct x86_function *p, unsigned char b0, const char *fn )
{
disassem(p, fn);
*(p->csr++) = b0;
}
-static void emit_2ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, const char *fn )
+static void emit_2ub_fn( struct x86_function *p, unsigned char b0, unsigned char b1, const char *fn )
{
disassem(p, fn);
*(p->csr++) = b0;
*(p->csr++) = b1;
}
-static void emit_3ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, GLubyte b2, const char *fn )
+static void emit_3ub_fn( struct x86_function *p, unsigned char b0, unsigned char b1, unsigned char b2, const char *fn )
{
disassem(p, fn);
*(p->csr++) = b0;
struct x86_reg reg,
struct x86_reg regmem )
{
- GLubyte val = 0;
+ unsigned char val = 0;
assert(reg.mod == mod_REG);
static void emit_modrm_noreg( struct x86_function *p,
- GLuint op,
+ unsigned op,
struct x86_reg regmem )
{
struct x86_reg dummy = x86_make_reg(file_REG32, op);
* the arguments presented.
*/
static void emit_op_modrm( struct x86_function *p,
- GLubyte op_dst_is_reg,
- GLubyte op_dst_is_mem,
+ unsigned char op_dst_is_reg,
+ unsigned char op_dst_is_mem,
struct x86_reg dst,
struct x86_reg src )
{
}
struct x86_reg x86_make_disp( struct x86_reg reg,
- GLint disp )
+ int disp )
{
assert(reg.file == file_REG32);
return x86_make_reg( reg.file, reg.idx );
}
-GLubyte *x86_get_label( struct x86_function *p )
+unsigned char *x86_get_label( struct x86_function *p )
{
return p->csr;
}
void x86_jcc( struct x86_function *p,
enum x86_cc cc,
- GLubyte *label )
+ unsigned char *label )
{
- GLint offset = label - (x86_get_label(p) + 2);
+ int offset = label - (x86_get_label(p) + 2);
if (offset <= 127 && offset >= -128) {
emit_1ub(p, 0x70 + cc);
- emit_1b(p, (GLbyte) offset);
+ emit_1b(p, (char) offset);
}
else {
offset = label - (x86_get_label(p) + 6);
/* Always use a 32bit offset for forward jumps:
*/
-GLubyte *x86_jcc_forward( struct x86_function *p,
+unsigned char *x86_jcc_forward( struct x86_function *p,
enum x86_cc cc )
{
emit_2ub(p, 0x0f, 0x80 + cc);
return x86_get_label(p);
}
-GLubyte *x86_jmp_forward( struct x86_function *p)
+unsigned char *x86_jmp_forward( struct x86_function *p)
{
emit_1ub(p, 0xe9);
emit_1i(p, 0);
return x86_get_label(p);
}
-GLubyte *x86_call_forward( struct x86_function *p)
+unsigned char *x86_call_forward( struct x86_function *p)
{
emit_1ub(p, 0xe8);
emit_1i(p, 0);
/* Fixup offset from forward jump:
*/
void x86_fixup_fwd_jump( struct x86_function *p,
- GLubyte *fixup )
+ unsigned char *fixup )
{
*(int *)(fixup - 4) = x86_get_label(p) - fixup;
}
-void x86_jmp( struct x86_function *p, GLubyte *label)
+void x86_jmp( struct x86_function *p, unsigned char *label)
{
emit_1ub(p, 0xe9);
emit_1i(p, label - x86_get_label(p) - 4);
* Temporary. As I need immediate operands, and dont want to mess with the codegen,
* I load the immediate into general purpose register and use it.
*/
-void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm )
+void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm )
{
assert(dst.mod == mod_REG);
emit_1ub(p, 0xb8 + dst.idx);
void sse_shufps( struct x86_function *p,
struct x86_reg dest,
struct x86_reg arg0,
- GLubyte shuf)
+ unsigned char shuf)
{
emit_2ub(p, X86_TWOB, 0xC6);
emit_modrm(p, dest, arg0);
void sse_cmpps( struct x86_function *p,
struct x86_reg dest,
struct x86_reg arg0,
- GLubyte cc)
+ unsigned char cc)
{
emit_2ub(p, X86_TWOB, 0xC2);
emit_modrm(p, dest, arg0);
void sse2_pshufd( struct x86_function *p,
struct x86_reg dest,
struct x86_reg arg0,
- GLubyte shuf)
+ unsigned char shuf)
{
emit_3ub(p, 0x66, X86_TWOB, 0x70);
emit_modrm(p, dest, arg0);
static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86_reg arg,
- GLubyte dst0ub0,
- GLubyte dst0ub1,
- GLubyte arg0ub0,
- GLubyte arg0ub1,
- GLubyte argmem_noreg)
+ unsigned char dst0ub0,
+ unsigned char dst0ub1,
+ unsigned char arg0ub0,
+ unsigned char arg0ub1,
+ unsigned char argmem_noreg)
{
assert(dst.file == file_x87);
* account any push/pop activity:
*/
struct x86_reg x86_fn_arg( struct x86_function *p,
- GLuint arg )
+ unsigned arg )
{
return x86_make_disp(x86_make_reg(file_REG32, reg_SP),
p->stack_offset + arg * 4); /* ??? */
x86_init_func_size(p, 1024);
}
-void x86_init_func_size( struct x86_function *p, GLuint code_size )
+void x86_init_func_size( struct x86_function *p, unsigned code_size )
{
p->store = _mesa_exec_malloc(code_size);
p->csr = p->store;
#if defined(__i386__) || defined(__386__)
-#include "glheader.h"
-
/* It is up to the caller to ensure that instructions issued are
* suitable for the host cpu. There are no checks made in this module
* for mmx/sse/sse2 support on the cpu.
*/
struct x86_reg {
- GLuint file:3;
- GLuint idx:3;
- GLuint mod:2; /* mod_REG if this is just a register */
- GLint disp:24; /* only +/- 23bits of offset - should be enough... */
+ unsigned file:3;
+ unsigned idx:3;
+ unsigned mod:2; /* mod_REG if this is just a register */
+ int disp:24; /* only +/- 23bits of offset - should be enough... */
};
struct x86_function {
- GLubyte *store;
- GLubyte *csr;
- GLuint stack_offset;
- GLint need_emms;
+ unsigned char *store;
+ unsigned char *csr;
+ unsigned stack_offset;
+ int need_emms;
const char *fn;
};
void x86_init_func( struct x86_function *p );
-void x86_init_func_size( struct x86_function *p, GLuint code_size );
+void x86_init_func_size( struct x86_function *p, unsigned code_size );
void x86_release_func( struct x86_function *p );
void (*x86_get_func( struct x86_function *p ))( void );
enum x86_reg_name idx );
struct x86_reg x86_make_disp( struct x86_reg reg,
- GLint disp );
+ int disp );
struct x86_reg x86_deref( struct x86_reg reg );
/* Labels, jumps and fixup:
*/
-GLubyte *x86_get_label( struct x86_function *p );
+unsigned char *x86_get_label( struct x86_function *p );
void x86_jcc( struct x86_function *p,
enum x86_cc cc,
- GLubyte *label );
+ unsigned char *label );
-GLubyte *x86_jcc_forward( struct x86_function *p,
+unsigned char *x86_jcc_forward( struct x86_function *p,
enum x86_cc cc );
-GLubyte *x86_jmp_forward( struct x86_function *p);
+unsigned char *x86_jmp_forward( struct x86_function *p);
-GLubyte *x86_call_forward( struct x86_function *p);
+unsigned char *x86_call_forward( struct x86_function *p);
void x86_fixup_fwd_jump( struct x86_function *p,
- GLubyte *fixup );
+ unsigned char *fixup );
-void x86_jmp( struct x86_function *p, GLubyte *label );
+void x86_jmp( struct x86_function *p, unsigned char *label );
void x86_call( struct x86_function *p, void (*label)() );
* Temporary. As I need immediate operands, and dont want to mess with the codegen,
* I load the immediate into general purpose register and use it.
*/
-void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm );
+void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm );
/* Macro for sse_shufps() and sse2_pshufd():
void sse2_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse2_packsswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse2_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
-void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf );
+void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0,
+ unsigned char shuf );
void sse2_rcpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse2_rcpss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_divss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_andnps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_andps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
-void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src, GLubyte cc );
+void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src,
+ unsigned char cc );
void sse_maxps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_maxss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_minps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_rsqrtps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
-void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf );
+void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0,
+ unsigned char shuf );
void sse_pmovmskb( struct x86_function *p, struct x86_reg dest, struct x86_reg src );
void x86_add( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
* account any push/pop activity. Note - doesn't track explict
* manipulation of ESP by other instructions.
*/
-struct x86_reg x86_fn_arg( struct x86_function *p, GLuint arg );
+struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg );
#endif
#endif