winebuild: Simplify ARM64 import thunks.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-01-16 10:51:45 +01:00
parent 00401d2278
commit 90ac46fe33
1 changed files with 24 additions and 33 deletions

View File

@ -760,14 +760,11 @@ static void output_import_thunk( const char *name, const char *table, int pos )
output( "1:\t.long %s+%u-(1b+4)\n", table, pos ); output( "1:\t.long %s+%u-(1b+4)\n", table, pos );
break; break;
case CPU_ARM64: case CPU_ARM64:
output( "\tadrp x9, %s\n", arm64_page( table ) ); output( "\tadrp x16, %s\n", arm64_page( table ) );
output( "\tadd x9, x9, #%s\n", arm64_pageoff( table ) ); output( "\tadd x16, x16, #%s\n", arm64_pageoff( table ) );
if (pos & 0xf000) output( "\tadd x9, x9, #%u\n", pos & 0xf000 ); if (pos & ~0x7fff) output( "\tadd x16, x16, #%u\n", pos & ~0x7fff );
if (pos & 0x0f00) output( "\tadd x9, x9, #%u\n", pos & 0x0f00 ); output( "\tldr x16, [x16, #%u]\n", pos & 0x7fff );
if (pos & 0x00f0) output( "\tadd x9, x9, #%u\n", pos & 0x00f0 ); output( "\tbr x16\n" );
if (pos & 0x000f) output( "\tadd x9, x9, #%u\n", pos & 0x000f );
output( "\tldur x9, [x9, #0]\n" );
output( "\tbr x9\n" );
break; break;
case CPU_POWERPC: case CPU_POWERPC:
output( "\tmr %s, %s\n", ppc_reg(0), ppc_reg(31) ); output( "\tmr %s, %s\n", ppc_reg(0), ppc_reg(31) );
@ -1078,18 +1075,21 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
output( "2:\t.long %s-1b\n", asm_name("__wine_spec_delay_load") ); output( "2:\t.long %s-1b\n", asm_name("__wine_spec_delay_load") );
break; break;
case CPU_ARM64: case CPU_ARM64:
output( "\tstp x29, x30, [sp,#-16]!\n" ); output( "\tstp x29, x30, [sp,#-80]!\n" );
output( "\tmov x29, sp\n" ); output( "\tmov x29, sp\n" );
output( "\tadrp x9, %s\n", arm64_page( asm_name("__wine_spec_delay_load") ) ); output( "\tstp x0, x1, [sp,#16]\n" );
output( "\tadd x9, x9, #%s\n", arm64_pageoff( asm_name("__wine_spec_delay_load") ) ); output( "\tstp x2, x3, [sp,#32]\n" );
output( "\tblr x9\n" ); output( "\tstp x4, x5, [sp,#48]\n" );
output( "\tmov x9, x0\n" ); output( "\tstp x6, x7, [sp,#64]\n" );
output( "\tldp x29, x30, [sp],#16\n" ); output( "\tmov x0, x16\n" );
output( "\tbl %s\n", asm_name("__wine_spec_delay_load") );
output( "\tmov x16, x0\n" );
output( "\tldp x0, x1, [sp,#16]\n" ); output( "\tldp x0, x1, [sp,#16]\n" );
output( "\tldp x2, x3, [sp,#32]\n" ); output( "\tldp x2, x3, [sp,#32]\n" );
output( "\tldp x4, x5, [sp,#48]\n" ); output( "\tldp x4, x5, [sp,#48]\n" );
output( "\tldp x6, x7, [sp],#80\n" ); output( "\tldp x6, x7, [sp,#64]\n" );
output( "\tbr x9\n" ); /* or "ret x9" */ output( "\tldp x29, x30, [sp],#80\n" );
output( "\tbr x16\n" );
break; break;
case CPU_POWERPC: case CPU_POWERPC:
if (target_platform == PLATFORM_APPLE) extra_stack_storage = 56; if (target_platform == PLATFORM_APPLE) extra_stack_storage = 56;
@ -1176,20 +1176,13 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
break; break;
} }
case CPU_ARM64: case CPU_ARM64:
output( "\tstp x6, x7, [sp,#-80]!\n" ); if (idx)
output( "\tstp x4, x5, [sp,#48]\n" ); {
output( "\tstp x2, x3, [sp,#32]\n" ); output( "\tmov x16, #0x%x\n", idx << 16 );
output( "\tstp x0, x1, [sp,#16]\n" ); if (j) output( "\tmovk x16, #0x%x\n", j );
output( "\tmov x0, #%d\n", idx ); }
output( "\tmov x1, #16384\n" ); else output( "\tmov x16, #0x%x\n", j );
output( "\tmul x1, x0, x1\n" ); output( "\tb %s\n", asm_name("__wine_delay_load_asm") );
output( "\tmov x0, x1\n" );
output( "\tmov x1, #4\n" );
output( "\tmul x1, x0, x1\n" );
output( "\tmov x0, x1\n" );
output( "\tadd x0, x0, #%d\n", j );
output( "\tadr x9, %s\n", asm_name("__wine_delay_load_asm") );
output( "\tbr x9\n" );
break; break;
case CPU_POWERPC: case CPU_POWERPC:
switch(target_platform) switch(target_platform)
@ -1378,9 +1371,7 @@ void output_stubs( DLLSPEC *spec )
} }
else else
output( "\tmov x1, %u\n", odp->ordinal ); output( "\tmov x1, %u\n", odp->ordinal );
output( "\tadrp x2, %s\n", arm64_page( asm_name("__wine_spec_unimplemented_stub") ) ); output( "\tbl %s\n", asm_name("__wine_spec_unimplemented_stub") );
output( "\tadd x2, x2, #%s\n", arm64_pageoff( asm_name("__wine_spec_unimplemented_stub") ) );
output( "\tblr x2\n" );
break; break;
default: default:
assert(0); assert(0);