mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 08:58:02 +02:00
fine-tuning x86 gcc codegen
This commit is contained in:
parent
b48c575983
commit
13822537a7
2 changed files with 35 additions and 20 deletions
|
|
@ -109,6 +109,25 @@ do { \
|
|||
|
||||
|
||||
|
||||
#define FIXUPREL( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL )\
|
||||
do { \
|
||||
GLuint subst = 0x10101010 + CHECKVAL; \
|
||||
\
|
||||
if (DONT_KNOW_OFFSETS) { \
|
||||
while (*(int *)(CODE+offset) != subst) offset++; \
|
||||
*(int *)(CODE+offset) = (int)(NEWVAL) - ((int)(CODE)+offset) - 4; \
|
||||
if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL) - ((int)(CODE)+offset) - 4); \
|
||||
offset += 4; \
|
||||
} \
|
||||
else { \
|
||||
int *icode = (int *)(CODE+KNOWN_OFFSET); \
|
||||
assert (*icode == subst); \
|
||||
*icode = (int)(NEWVAL) - (int)(icode) - 4; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
|
||||
/* Build specialized versions of the immediate calls on the fly for
|
||||
* the current state. Generic x86 versions.
|
||||
|
|
@ -125,7 +144,7 @@ static struct _tnl_dynfn *makeX86Vertex1fv( GLcontext *ctx, int vertex_size )
|
|||
FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 4, (int)¬ify);
|
||||
FIXUPREL(dfn->code, 0, 4, (int)¬ify);
|
||||
|
||||
return dfn;
|
||||
}
|
||||
|
|
@ -141,7 +160,7 @@ static struct _tnl_dynfn *makeX86Vertex2fv( GLcontext *ctx, int vertex_size )
|
|||
FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 4, (int)¬ify);
|
||||
FIXUPREL(dfn->code, 0, 4, (int)¬ify);
|
||||
|
||||
return dfn;
|
||||
}
|
||||
|
|
@ -157,7 +176,7 @@ static struct _tnl_dynfn *makeX86Vertex3fv( GLcontext *ctx, int vertex_size )
|
|||
FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 4, (int)¬ify);
|
||||
FIXUPREL(dfn->code, 0, 4, (int)¬ify);
|
||||
return dfn;
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +191,7 @@ static struct _tnl_dynfn *makeX86Vertex4fv( GLcontext *ctx, int vertex_size )
|
|||
FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
|
||||
FIXUP(dfn->code, 0, 4, (int)¬ify);
|
||||
FIXUPREL(dfn->code, 0, 4, (int)¬ify);
|
||||
|
||||
return dfn;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,10 +66,9 @@ GLOBL ( _x86_Vertex1fv )
|
|||
pop %edi
|
||||
dec %edx // counter--
|
||||
movl %edx, SUBST(3) // 0x3 --> counter
|
||||
je .5 // if (counter != 0)
|
||||
ret // return
|
||||
.5: mov $SUBST(4), %eax // else notify()
|
||||
jmp *%eax // jmp $0x10101014 doesn't seem to work
|
||||
.short 0x840f // if (counter == 0)
|
||||
.long SUBST(4) // notify()
|
||||
ret // return
|
||||
GLOBL ( _x86_Vertex1fv_end )
|
||||
|
||||
|
||||
|
|
@ -94,10 +93,9 @@ GLOBL ( _x86_Vertex2fv )
|
|||
pop %edi
|
||||
dec %edx // counter--
|
||||
movl %edx, SUBST(3) // save counter
|
||||
je .6 // if (counter != 0)
|
||||
ret // return
|
||||
.6: mov $SUBST(4), %eax // else notify()
|
||||
jmp *%eax // jmp $0x10101014 doesn't seem to work
|
||||
.short 0x840f // if (counter == 0)
|
||||
.long SUBST(4) // notify()
|
||||
ret // return
|
||||
GLOBL ( _x86_Vertex2fv_end )
|
||||
|
||||
.align 4
|
||||
|
|
@ -123,10 +121,9 @@ GLOBL ( _x86_Vertex3fv )
|
|||
pop %edi
|
||||
dec %edx // counter--
|
||||
movl %edx, SUBST(3) // save counter
|
||||
je .7 // if (counter != 0)
|
||||
ret // return
|
||||
.7: mov $SUBST(4), %eax // else notify()
|
||||
jmp *%eax // jmp $0x10101014 doesn't seem to work
|
||||
.short 0x840f // if (counter == 0)
|
||||
.long SUBST(4) // notify()
|
||||
ret // return
|
||||
GLOBL ( _x86_Vertex3fv_end )
|
||||
|
||||
|
||||
|
|
@ -155,10 +152,9 @@ GLOBL ( _x86_Vertex4fv )
|
|||
pop %edi
|
||||
dec %edx // counter--
|
||||
movl %edx, SUBST(3) // save counter
|
||||
je .6 // if (counter != 0)
|
||||
ret // return
|
||||
.8: mov $SUBST(4), %eax // else notify()
|
||||
jmp *%eax // jmp $0x10101014 doesn't seem to work
|
||||
.short 0x840f // if (counter == 0)
|
||||
.long SUBST(4) // notify()
|
||||
ret // return
|
||||
GLOBL ( _x86_Vertex4fv_end )
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue