Added a bit of framework for future x86_64 support.

This commit is contained in:
Alexandre Julliard 2005-09-07 13:31:37 +00:00
parent c72d13291a
commit c382ed06d3
5 changed files with 42 additions and 1 deletions

View File

@ -110,7 +110,7 @@ typedef struct
enum target_cpu
{
CPU_x86, CPU_SPARC, CPU_ALPHA, CPU_POWERPC
CPU_x86, CPU_x86_64, CPU_SPARC, CPU_ALPHA, CPU_POWERPC
};
enum target_platform
@ -180,9 +180,11 @@ extern void free_dll_spec( DLLSPEC *spec );
extern const char *make_c_identifier( const char *str );
extern unsigned int get_alignment(unsigned int align);
extern unsigned int get_page_size(void);
extern unsigned int get_ptr_size(void);
extern const char *asm_name( const char *func );
extern const char *func_declaration( const char *func );
extern const char *func_size( const char *func );
extern const char *get_asm_ptr_keyword(void);
extern const char *get_asm_string_keyword(void);
extern const char *get_asm_short_keyword(void);

View File

@ -632,6 +632,7 @@ static void output_import_thunk( FILE *outfile, const char *name, const char *ta
switch(target_cpu)
{
case CPU_x86_64: /* FIXME */
case CPU_x86:
if (!UsePIC)
{
@ -976,6 +977,7 @@ static void output_delayed_import_thunks( FILE *outfile, const DLLSPEC *spec )
fprintf( outfile, " \"%s:\\n\"\n", asm_name("__wine_delay_load_asm") );
switch(target_cpu)
{
case CPU_x86_64: /* FIXME */
case CPU_x86:
fprintf( outfile, " \"\\tpushl %%ecx\\n\\tpushl %%edx\\n\\tpushl %%eax\\n\"\n" );
fprintf( outfile, " \"\\tcall %s\\n\"\n", asm_name("__wine_spec_delay_load") );
@ -1054,6 +1056,7 @@ static void output_delayed_import_thunks( FILE *outfile, const DLLSPEC *spec )
fprintf( outfile, " \".L__wine_delay_imp_%d_%s:\\n\"\n", i, name );
switch(target_cpu)
{
case CPU_x86_64: /* FIXME */
case CPU_x86:
fprintf( outfile, " \"\\tmovl $%d, %%eax\\n\"\n", (idx << 16) | j );
fprintf( outfile, " \"\\tjmp %s\\n\"\n", asm_name("__wine_delay_load_asm") );

View File

@ -49,6 +49,8 @@ int kill_at = 0;
#ifdef __i386__
enum target_cpu target_cpu = CPU_x86;
#elif defined(__x86_64__)
enum target_cpu target_cpu = CPU_x86_64;
#elif defined(__sparc__)
enum target_cpu target_cpu = CPU_SPARC;
#elif defined(__ALPHA__)
@ -109,6 +111,7 @@ static const struct
{ "i586", CPU_x86 },
{ "i686", CPU_x86 },
{ "i786", CPU_x86 },
{ "x86_64", CPU_x86_64 },
{ "sparc", CPU_SPARC },
{ "alpha", CPU_ALPHA },
{ "powerpc", CPU_POWERPC }

View File

@ -375,6 +375,7 @@ void output_dll_init( FILE *outfile, const char *constructor, const char *destru
else switch(target_cpu)
{
case CPU_x86:
case CPU_x86_64:
if (constructor)
{
fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" );
@ -502,6 +503,7 @@ void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
switch(target_cpu)
{
case CPU_x86: machine = IMAGE_FILE_MACHINE_I386; break;
case CPU_x86_64: machine = IMAGE_FILE_MACHINE_AMD64; break;
case CPU_POWERPC: machine = IMAGE_FILE_MACHINE_POWERPC; break;
case CPU_ALPHA: machine = IMAGE_FILE_MACHINE_ALPHA; break;
case CPU_SPARC: machine = IMAGE_FILE_MACHINE_UNKNOWN; break;

View File

@ -349,6 +349,7 @@ unsigned int get_alignment(unsigned int align)
switch(target_cpu)
{
case CPU_x86:
case CPU_x86_64:
case CPU_SPARC:
if (target_platform != PLATFORM_APPLE) return align;
/* fall through */
@ -369,6 +370,7 @@ unsigned int get_page_size(void)
switch(target_cpu)
{
case CPU_x86: return 4096;
case CPU_x86_64: return 4096;
case CPU_POWERPC: return 4096;
case CPU_SPARC: return 8192;
case CPU_ALPHA: return 8192;
@ -378,6 +380,24 @@ unsigned int get_page_size(void)
return 0;
}
/* return the size of a pointer on the target CPU */
unsigned int get_ptr_size(void)
{
switch(target_cpu)
{
case CPU_x86:
case CPU_POWERPC:
case CPU_SPARC:
case CPU_ALPHA:
return 4;
case CPU_x86_64:
return 8;
}
/* unreached */
assert(0);
return 0;
}
/* return the assembly name for a C symbol */
const char *asm_name( const char *sym )
{
@ -433,6 +453,17 @@ const char *func_size( const char *func )
}
}
const char *get_asm_ptr_keyword(void)
{
switch(get_ptr_size())
{
case 4: return ".long";
case 8: return ".quad";
}
assert(0);
return NULL;
}
const char *get_asm_string_keyword(void)
{
switch (target_platform)