tools: Initial ARM64EC target support.

This commit is contained in:
Jacek Caban 2023-10-01 12:05:53 +02:00 committed by Alexandre Julliard
parent 5004e6bce7
commit a0a2ef5a2b
5 changed files with 57 additions and 11 deletions

View file

@ -90,7 +90,7 @@ extern char **environ;
struct target
{
enum { CPU_i386, CPU_x86_64, CPU_ARM, CPU_ARM64 } cpu;
enum { CPU_i386, CPU_x86_64, CPU_ARM, CPU_ARM64, CPU_ARM64EC } cpu;
enum
{
@ -481,6 +481,7 @@ static inline unsigned int get_target_ptr_size( struct target target )
[CPU_x86_64] = 8,
[CPU_ARM] = 4,
[CPU_ARM64] = 8,
[CPU_ARM64EC] = 8,
};
return sizes[target.cpu];
}
@ -500,6 +501,7 @@ static inline void set_target_ptr_size( struct target *target, unsigned int size
if (size == 8) target->cpu = CPU_ARM64;
break;
case CPU_ARM64:
case CPU_ARM64EC:
if (size == 4) target->cpu = CPU_ARM;
break;
}
@ -522,6 +524,7 @@ static inline int get_cpu_from_name( const char *name )
{ "x86_64", CPU_x86_64 },
{ "amd64", CPU_x86_64 },
{ "aarch64", CPU_ARM64 },
{ "arm64ec", CPU_ARM64EC },
{ "arm64", CPU_ARM64 },
{ "arm", CPU_ARM },
};
@ -566,10 +569,11 @@ static inline const char *get_arch_dir( struct target target )
{
static const char *cpu_names[] =
{
[CPU_i386] = "i386",
[CPU_x86_64] = "x86_64",
[CPU_ARM] = "arm",
[CPU_ARM64] = "aarch64"
[CPU_i386] = "i386",
[CPU_x86_64] = "x86_64",
[CPU_ARM] = "arm",
[CPU_ARM64] = "aarch64",
[CPU_ARM64EC] = "arm64ec",
};
if (!cpu_names[target.cpu]) return "";

View file

@ -192,7 +192,7 @@ static inline int is_pe(void)
#define FLAG_CPU(cpu) (0x10000 << (cpu))
#define FLAG_CPU_MASK (FLAG_CPU_WIN32 | FLAG_CPU_WIN64)
#define FLAG_CPU_WIN64 (FLAG_CPU(CPU_x86_64) | FLAG_CPU(CPU_ARM64))
#define FLAG_CPU_WIN64 (FLAG_CPU(CPU_x86_64) | FLAG_CPU(CPU_ARM64) | FLAG_CPU(CPU_ARM64EC))
#define FLAG_CPU_WIN32 (FLAG_CPU(CPU_i386) | FLAG_CPU(CPU_ARM))
#define MAX_ORDINALS 65535

View file

@ -802,6 +802,9 @@ static void output_import_thunk( const char *name, const char *table, int pos )
output( "\tldr x16, [x16, #%u]\n", pos & 0x7fff );
output( "\tbr x16\n" );
break;
case CPU_ARM64EC:
assert( 0 );
break;
}
output_function_size( name );
}
@ -1121,6 +1124,9 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
output( "\tldp x29, x30, [sp],#80\n" );
output( "\tbr x16\n" );
break;
case CPU_ARM64EC:
assert( 0 );
break;
}
output_cfi( ".cfi_endproc" );
output_function_size( module_func );
@ -1170,6 +1176,9 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
if (iat_pos) output( "\tadd x16, x16, #%u\n", iat_pos );
output( "\tb %s\n", asm_name(module_func) );
break;
case CPU_ARM64EC:
assert( 0 );
break;
}
iat_pos += get_ptr_size();
}
@ -1337,6 +1346,7 @@ void output_stubs( DLLSPEC *spec )
}
break;
case CPU_ARM64:
case CPU_ARM64EC:
output_seh( ".seh_proc %s", asm_name(name) );
output_seh( ".seh_endprologue" );
output( "\tadrp x0, %s\n", arm64_page(".L__wine_spec_file_name") );
@ -1353,8 +1363,6 @@ void output_stubs( DLLSPEC *spec )
output( "\tb %s\n", asm_name("__wine_spec_unimplemented_stub") );
output_seh( ".seh_endproc" );
break;
default:
assert(0);
}
output_function_size( name );
}
@ -1467,6 +1475,7 @@ void output_syscalls( DLLSPEC *spec )
output( "\tbx lr\n" );
break;
case CPU_ARM64:
case CPU_ARM64EC:
output_seh( ".seh_proc %s", asm_name(name) );
output_seh( ".seh_endprologue" );
output( "\tmov x8, #%u\n", id );
@ -1478,8 +1487,6 @@ void output_syscalls( DLLSPEC *spec )
output( "1:\t.quad %s\n", asm_name("__wine_syscall_dispatcher") );
output_seh( ".seh_endproc" );
break;
default:
assert(0);
}
output_function_size( name );
}
@ -1561,6 +1568,20 @@ static void assemble_files( const char *prefix )
}
}
static const char *get_target_machine(void)
{
static const char *machine_names[] =
{
[CPU_i386] = "x86",
[CPU_x86_64] = "x64",
[CPU_ARM] = "arm",
[CPU_ARM64] = "arm64",
[CPU_ARM64EC] = "arm64ec",
};
return machine_names[target.cpu];
}
/* build a library from the current asm files and any additional object files in argv */
void output_static_lib( const char *output_name, struct strarray files, int create )
{
@ -1576,6 +1597,7 @@ void output_static_lib( const char *output_name, struct strarray files, int crea
{
args = find_link_tool();
strarray_add( &args, "/lib" );
strarray_add( &args, strmake( "-machine:%s", get_target_machine() ));
strarray_add( &args, strmake( "-out:%s", output_name ));
}
strarray_addall( &args, as_files );
@ -1628,6 +1650,10 @@ static void build_dlltool_import_lib( const char *lib_name, DLLSPEC *spec, struc
strarray_add( &args, "-m" );
strarray_add( &args, "arm64" );
break;
case CPU_ARM64EC:
strarray_add( &args, "-m" );
strarray_add( &args, "arm64ec" );
break;
default:
break;
}
@ -1735,6 +1761,9 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc
output( "\tbr x16\n" );
output_seh( ".seh_endproc" );
break;
case CPU_ARM64EC:
assert( 0 );
break;
}
output_function_size( delay_load );
output_gnu_stack_note();
@ -1878,6 +1907,9 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc
output( "\tb %s\n", asm_name( delay_load ) );
}
break;
case CPU_ARM64EC:
assert( 0 );
break;
}
output( "\n\t.section .idata$4\n" );

View file

@ -98,6 +98,8 @@ static int has_relays( DLLSPEC *spec )
{
int i;
if (target.cpu == CPU_ARM64EC) return 0;
for (i = spec->base; i <= spec->limit; i++)
{
ORDDEF *odp = spec->ordinals[i];
@ -652,6 +654,9 @@ void output_module( DLLSPEC *spec )
output( "\n\t.section \".init\",\"ax\"\n" );
output( "\tb 1f\n" );
break;
case CPU_ARM64EC:
assert( 0 );
break;
}
output( "__wine_spec_pe_header:\n" );
output( "\t.skip %u\n", 65536 + page_size );
@ -671,6 +676,7 @@ void output_module( DLLSPEC *spec )
switch (target.cpu)
{
case CPU_i386: machine = IMAGE_FILE_MACHINE_I386; break;
case CPU_ARM64EC:
case CPU_x86_64: machine = IMAGE_FILE_MACHINE_AMD64; break;
case CPU_ARM: machine = IMAGE_FILE_MACHINE_ARMNT; break;
case CPU_ARM64: machine = IMAGE_FILE_MACHINE_ARM64; break;
@ -1089,6 +1095,7 @@ static void output_pe_file( DLLSPEC *spec, const char signature[32] )
switch (target.cpu)
{
case CPU_i386: put_word( IMAGE_FILE_MACHINE_I386 ); break;
case CPU_ARM64EC:
case CPU_x86_64: put_word( IMAGE_FILE_MACHINE_AMD64 ); break;
case CPU_ARM: put_word( IMAGE_FILE_MACHINE_ARMNT ); break;
case CPU_ARM64: put_word( IMAGE_FILE_MACHINE_ARM64 ); break;

View file

@ -505,8 +505,9 @@ static const char *get_multiarch_dir( struct target target )
case CPU_x86_64: return "/x86_64-linux-gnu";
case CPU_ARM: return "/arm-linux-gnueabi";
case CPU_ARM64: return "/aarch64-linux-gnu";
default:
assert(0);
}
assert(0);
return NULL;
}
@ -700,6 +701,8 @@ static void compile(struct options* opts, const char* lang)
strarray_add(&comp_args, "-D__cdecl=__stdcall");
strarray_add(&comp_args, "-D__fastcall=__stdcall");
break;
case CPU_ARM64EC:
break;
}
strarray_add(&comp_args, "-D_stdcall=__stdcall");
strarray_add(&comp_args, "-D_cdecl=__cdecl");