diff options
author | John van Groningen | 2006-01-10 14:10:22 +0000 |
---|---|---|
committer | John van Groningen | 2006-01-10 14:10:22 +0000 |
commit | 7c3efe45b1f889621b1ead7489f5e2eccb386a1a (patch) | |
tree | ea8dd3c0e13d01382e4df243e154e1f440f8cb26 | |
parent | add pushLc instruction for pushing the value of a label, with (diff) |
port to 64 bit windows
-rw-r--r-- | cg.c | 4 | ||||
-rw-r--r-- | cgcalc.c | 35 | ||||
-rw-r--r-- | cgcode.c | 694 | ||||
-rw-r--r-- | cgcode.h | 18 | ||||
-rw-r--r-- | cgcodep.h | 6 | ||||
-rw-r--r-- | cgconst.h | 25 | ||||
-rw-r--r-- | cgiconst.h | 5 | ||||
-rw-r--r-- | cginput.c | 41 | ||||
-rw-r--r-- | cginstructions.c | 548 | ||||
-rw-r--r-- | cginstructions.h | 2 | ||||
-rw-r--r-- | cglin.c | 563 | ||||
-rw-r--r-- | cglin.h | 6 | ||||
-rw-r--r-- | cgopt.c | 67 | ||||
-rw-r--r-- | cgport.h | 17 | ||||
-rw-r--r-- | cgrconst.h | 9 | ||||
-rw-r--r-- | cgstack.c | 414 | ||||
-rw-r--r-- | cgtypes.h | 10 |
17 files changed, 1911 insertions, 553 deletions
@@ -613,6 +613,8 @@ static void argument_error (VOID) extern int compiler_id; #endif +extern int intel_asm; + #ifdef MAIN_CLM # if !(defined (__MWERKS__) && defined (__cplusplus)) # ifdef CG_PPC_XO @@ -697,6 +699,8 @@ int main (int argc,char **argv) else if (!strcmp (s,"pt")) profile_table_flag=1; #endif + else if (!strcmp (s,"intelasm")) + intel_asm=1; else if (!strcmp (s,"mc68000")){ mc68000_flag=1; mc68881_flag=0; @@ -2485,9 +2485,14 @@ void calculate_graph_register_uses (INSTRUCTION_GRAPH graph) graph->order_alterable=0; return; case GALLOCATE: +#ifdef G_A64 + case GFROMF: + case GTOF: +#else case GFJOIN: case GFHIGH: case GFLOW: +#endif case GFMOVEMI: graph->u_aregs=graph->i_aregs=0; graph->u_dregs=graph->i_dregs=0; @@ -2583,6 +2588,7 @@ static void count_gstore_x_node (INSTRUCTION_GRAPH graph) /* optime store_x for reals */ low_graph=graph->instruction_parameters[0].p; +#ifndef G_A64 if (low_graph->instruction_code==GFLOW){ h_store_x_graph=graph->instruction_parameters[1].p; if (h_store_x_graph!=NULL @@ -2601,6 +2607,7 @@ static void count_gstore_x_node (INSTRUCTION_GRAPH graph) } } } +#endif if (++graph->node_count==1){ count_graph (graph->instruction_parameters[0].p); @@ -2630,7 +2637,9 @@ void count_graph (INSTRUCTION_GRAPH graph) case GFCMP_GT: case GFCMP_LT: case GFDIV: +#ifndef G_A64 case GFJOIN: +#endif case GFMUL: case GFREM: case GFSUB: @@ -2660,10 +2669,18 @@ void count_graph (INSTRUCTION_GRAPH graph) count_graph (graph->instruction_parameters[1].p); } break; +#ifdef G_A64 + case GFROMF: + case GTOF: +#endif case GCNOT: +#ifndef G_A64 case GFHIGH: +#endif case GFITOR: +#ifndef G_A64 case GFLOW: +#endif case GFRTOI: case GFCOS: case GFSIN: @@ -2815,7 +2832,9 @@ void mark_graph_2 (register INSTRUCTION_GRAPH graph) case GFCMP_GT: case GFCMP_LT: case GFDIV: +#ifndef G_A64 case GFJOIN: +#endif case GFMUL: case GFREM: case GFSUB: @@ -2846,10 +2865,18 @@ void mark_graph_2 (register INSTRUCTION_GRAPH graph) mark_graph_2 (graph->instruction_parameters[1].p); } break; +#ifdef G_A64 + case GFROMF: + case GTOF: +#endif case GCNOT: +#ifndef G_A64 case GFHIGH: +#endif case GFITOR: +#ifndef G_A64 case GFLOW: +#endif case GFRTOI: case GFCOS: case GFSIN: @@ -3016,7 +3043,9 @@ void mark_graph_1 (register INSTRUCTION_GRAPH graph) case GFCMP_GT: case GFCMP_LT: case GFDIV: +#ifndef G_A64 case GFJOIN: +#endif case GFMUL: case GFREM: case GFSUB: @@ -3047,6 +3076,10 @@ void mark_graph_1 (register INSTRUCTION_GRAPH graph) mark_graph_2 (graph->instruction_parameters[1].p); } break; +#ifdef G_A64 + case GFROMF: + case GTOF: +#endif case GCNOT: case GFITOR: case GFRTOI: @@ -3179,6 +3212,7 @@ void mark_graph_1 (register INSTRUCTION_GRAPH graph) if (!graph->node_mark) graph->node_mark=1; break; +#ifndef G_A64 case GFHIGH: case GFLOW: if (!graph->node_mark){ @@ -3186,6 +3220,7 @@ void mark_graph_1 (register INSTRUCTION_GRAPH graph) mark_graph_1 (graph->instruction_parameters[0].p); } break; +#endif #ifdef I486 case GDIVDU: if (!graph->node_mark){ @@ -28,7 +28,11 @@ # define PROFILE_OFFSET 12 # endif # else +# ifndef G_AI64 # define PROFILE_OFFSET 10 +# else +# define PROFILE_OFFSET 12 +# endif # endif #endif @@ -47,8 +51,13 @@ # include "cgpwas.h" #else # ifdef I486 +# ifdef G_AI64 +# include "cgaas.h" +# include "cgawas.h" +# else # include "cgias.h" # include "cgiwas.h" +# endif # else # ifdef SOLARIS # include "cgswas.h" @@ -67,10 +76,18 @@ #define GEN_OBJ #ifdef NEW_DESCRIPTORS +# ifdef G_A64 +# define ARITY_0_DESCRIPTOR_OFFSET (-8) +# else # define ARITY_0_DESCRIPTOR_OFFSET (-4) +# endif #else # if defined (M68000) || (defined (NO_STRING_ADDRES_IN_DESCRIPTOR) && (defined (G_POWER) || defined (I486))) -# define ARITY_0_DESCRIPTOR_OFFSET (-8) +# ifdef G_A64 +# define ARITY_0_DESCRIPTOR_OFFSET (-12) +# else +# define ARITY_0_DESCRIPTOR_OFFSET (-8) +# endif # else # define ARITY_0_DESCRIPTOR_OFFSET (-12) # endif @@ -85,6 +102,12 @@ # endif #endif +#ifdef G_A64 +# define SIZE_OF_REAL_IN_STACK_ELEMENTS 1 +#else +# define SIZE_OF_REAL_IN_STACK_ELEMENTS 2 +#endif + #ifdef THINK_C # define SMALL_LAZY_DESCRIPTORS 1 #else @@ -105,22 +128,22 @@ #ifdef NEW_ARRAYS # ifdef ARRAY_SIZE_BEFORE_DESCRIPTOR -# define ARRAY_ELEMENTS_OFFSET 4 +# define ARRAY_ELEMENTS_OFFSET STACK_ELEMENT_SIZE # else -# define ARRAY_ELEMENTS_OFFSET 8 +# define ARRAY_ELEMENTS_OFFSET (2<<STACK_ELEMENT_LOG_SIZE) # endif #else -# define ARRAY_ELEMENTS_OFFSET 12 +# define ARRAY_ELEMENTS_OFFSET (3<<STACK_ELEMENT_LOG_SIZE) #endif #if defined (NEW_ARRAYS) || defined (ALIGN_REAL_ARRAYS) # ifdef ARRAY_SIZE_BEFORE_DESCRIPTOR -# define REAL_ARRAY_ELEMENTS_OFFSET 4 +# define REAL_ARRAY_ELEMENTS_OFFSET STACK_ELEMENT_SIZE # else -# define REAL_ARRAY_ELEMENTS_OFFSET 8 +# define REAL_ARRAY_ELEMENTS_OFFSET (2<<STACK_ELEMENT_LOG_SIZE) # endif #else -# define REAL_ARRAY_ELEMENTS_OFFSET 12 +# define REAL_ARRAY_ELEMENTS_OFFSET (3<<STACK_ELEMENT_LOG_SIZE) #endif #ifdef __MWERKS__ @@ -159,12 +182,21 @@ INSTRUCTION_GRAPH load_indexed_list; ULONG e_vector[] = { 0 }; ULONG i_vector[] = { 0 }; +#ifdef G_A64 +ULONG r_vector[] = { 1 }; +#else ULONG r_vector[] = { 3 }; +#endif ULONG i_i_vector[] = { 0 }; ULONG i_i_i_vector[]= { 0 }; ULONG i_i_i_i_i_vector[]= { 0 }; +#ifdef G_A64 +static ULONG i_r_vector[] = { 2 }; +static ULONG r_r_vector[]= { 3 }; +#else static ULONG i_r_vector[] = { 6 }; static ULONG r_r_vector[]= { 15 }; +#endif static ULONG *demanded_vector; int demanded_a_stack_size=0; @@ -309,14 +341,14 @@ LABEL *r_to_i_buffer_label; #endif LABEL *collect_0_label,*collect_1_label,*collect_2_label, -#ifndef I486 +#if !(defined (I486) && !defined (G_AI64)) *collect_3_label, #endif #ifdef G_POWER *collect_00_label,*collect_01_label,*collect_02_label,*collect_03_label, *eval_01_label,*eval_11_label,*eval_02_label,*eval_12_label,*eval_22_label, #endif -#if defined (I486) && defined (GEN_OBJ) +#if defined (I486) && defined (GEN_OBJ) && !defined (G_AI64) *collect_0l_label,*collect_1l_label,*collect_2l_label,*end_heap_label, #endif *system_sp_label,*EMPTY_label; @@ -398,10 +430,22 @@ LABEL *new_local_label (int label_flags) } #define DESCRIPTOR_OFFSET 2 -#define ARGUMENTS_OFFSET 4 +#define ARGUMENTS_OFFSET STACK_ELEMENT_SIZE static void code_monadic_real_operator (int g_code) { +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4; + + graph_1=s_get_b (0); + graph_2=g_fp_arg (graph_1); + + graph_3=g_instruction_1 (g_code,graph_2); + + graph_4=g_fromf (graph_3); + + s_put_b (0,graph_4); +#else INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6; graph_2=s_get_b (1); @@ -414,6 +458,7 @@ static void code_monadic_real_operator (int g_code) s_put_b (1,graph_6); s_put_b (0,graph_5); +#endif } static int eval_label_number; @@ -431,14 +476,20 @@ static void code_monadic_sane_operator (LABEL *label) graph=g_lea (label2); #endif +#ifdef G_A64 + s_push_b (s_get_b (0)); + s_put_b (1,NULL); + insert_basic_block (JSR_BLOCK,0,1+1,r_vector,label); +#else s_push_b (s_get_b (0)); s_put_b (1,s_get_b (2)); -#ifdef M68000 +# ifdef M68000 s_put_b (2,graph); -#else +# else s_put_b (2,NULL); -#endif +# endif insert_basic_block (JSR_BLOCK,0,2+1,r_vector,label); +#endif #ifdef M68000 new_label=fast_memory_allocate_type (struct block_label); @@ -469,17 +520,23 @@ static void code_dyadic_sane_operator (LABEL *label) s_push_b (s_get_b (0)); s_put_b (1,s_get_b (2)); +#ifdef G_A64 + s_put_b (2,NULL); + + insert_basic_block (JSR_BLOCK,0,2+1,r_r_vector,label); +#else s_put_b (2,s_get_b (3)); s_put_b (3,s_get_b (4)); -#ifdef M68000 +# ifdef M68000 if (!mc68881_flag) s_put_b (4,graph); else -#endif +# endif s_put_b (4,NULL); insert_basic_block (JSR_BLOCK,0,4+1,r_r_vector,label); +#endif #ifdef M68000 if (!mc68881_flag){ @@ -512,7 +569,7 @@ void code_acosR (VOID) if (acos_real==NULL) acos_real=enter_label ("acos_real",IMPORT_LABEL); code_monadic_sane_operator (acos_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } void code_addI (VOID) @@ -577,16 +634,31 @@ void code_addIo (VOID) void code_addR (VOID) { +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6; + + graph_1=s_pop_b(); + graph_2=g_fp_arg (graph_1); + + graph_3=s_get_b (0); + graph_4=g_fp_arg (graph_3); + + graph_5=g_fadd (graph_4,graph_2); + + graph_6=g_fromf (graph_5); + + s_put_b (0,graph_6); +#else INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7,graph_8,graph_9; -#ifdef M68000 +# ifdef M68000 if (!mc68881_flag){ if (add_real==NULL) add_real=enter_label ("add_real",IMPORT_LABEL); code_dyadic_sane_operator (add_real); init_b_stack (2,r_vector); } else { -#endif +# endif graph_1=s_pop_b(); graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); @@ -601,8 +673,9 @@ void code_addR (VOID) s_put_b (1,graph_9); s_put_b (0,graph_8); -#ifdef M68000 +# ifdef M68000 } +# endif #endif } @@ -639,7 +712,7 @@ void code_asinR (VOID) if (asin_real==NULL) asin_real=enter_label ("asin_real",IMPORT_LABEL); code_monadic_sane_operator (asin_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } void code_atanR (VOID) @@ -650,7 +723,7 @@ void code_atanR (VOID) if (atan_real==NULL) atan_real=enter_label ("atan_real",IMPORT_LABEL); code_monadic_sane_operator (atan_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); #ifdef M68000 } else code_monadic_real_operator (GFATAN); @@ -1007,7 +1080,7 @@ void code_buildC (int value) if (static_characters_label==NULL) static_characters_label=enter_label ("static_characters",IMPORT_LABEL | DATA_LABEL); - graph_4=g_lea_i (static_characters_label,(value<<3)+NODE_POINTER_OFFSET); + graph_4=g_lea_i (static_characters_label,(value<<(1+STACK_ELEMENT_LOG_SIZE))+NODE_POINTER_OFFSET); s_push_a (graph_4); return; } @@ -1067,7 +1140,11 @@ static INSTRUCTION_GRAPH int_descriptor_graph (void) graph=last_INT_descriptor_graph; else { if (INT_label==NULL) +#ifdef G_AI64 + INT_label=enter_label ("dINT",IMPORT_LABEL | DATA_LABEL); +#else INT_label=enter_label ("INT",IMPORT_LABEL | DATA_LABEL); +#endif graph=g_load_des_i (INT_label,0); @@ -1080,7 +1157,7 @@ static INSTRUCTION_GRAPH int_descriptor_graph (void) return graph; } -void code_buildI (LONG value) +void code_buildI (CleanInt value) { INSTRUCTION_GRAPH graph_3,graph_4,graph_5; @@ -1088,7 +1165,7 @@ void code_buildI (LONG value) if (small_integers_label==NULL) small_integers_label=enter_label ("small_integers",IMPORT_LABEL | DATA_LABEL); - graph_5=g_lea_i (small_integers_label,(value<<3)+NODE_POINTER_OFFSET); + graph_5=g_lea_i (small_integers_label,(value<<(STACK_ELEMENT_LOG_SIZE+1))+NODE_POINTER_OFFSET); s_push_a (graph_5); return; } @@ -1163,13 +1240,20 @@ void code_buildR_b (int b_offset) graph_2=real_descriptor_graph(); graph_3=s_get_b (b_offset); +#ifndef G_A64 graph_4=s_get_b (b_offset+1); +#endif +#ifdef M68000 if (!mc68881_flag) graph_5=g_create_3 (graph_2,graph_3,graph_4); else +#endif +#ifdef G_A64 + graph_5=g_create_r (graph_2,g_fp_arg (graph_3)); +#else graph_5=g_create_r (graph_2,g_fjoin (graph_3,graph_4)); - +#endif s_push_a (graph_5); } @@ -1237,7 +1321,7 @@ void code_CtoAC (VOID) #ifdef ARRAY_SIZE_BEFORE_DESCRIPTOR graph_4=g_create_3 (graph_2,graph_1,graph_3); - graph_4=g_add (g_load_i (4),graph_4); + graph_4=g_add (g_load_i (STACK_ELEMENT_SIZE),graph_4); #else graph_4=g_create_3 (graph_1,graph_2,graph_3); #endif @@ -1332,9 +1416,14 @@ static void code_create_arrayR (VOID) #endif s_push_b (s_get_b (0)); s_put_b (1,s_get_b (2)); +#ifdef G_A64 + s_put_b (2,NULL); + insert_basic_block (JSR_BLOCK,0,2+1,i_r_vector,create_arrayR_label); +#else s_put_b (2,s_get_b (3)); s_put_b (3,NULL); insert_basic_block (JSR_BLOCK,0,3+1,i_r_vector,create_arrayR_label); +#endif #ifdef M68000 } #endif @@ -1703,7 +1792,7 @@ void code_create_array_ (char element_descriptor[],int a_size,int b_size) void code_cosR (VOID) { -#ifdef I486 +#if defined (I486) && !defined (G_AI64) code_monadic_real_operator (GFCOS); #else # ifdef M68000 @@ -1712,7 +1801,7 @@ void code_cosR (VOID) if (cos_real==NULL) cos_real=enter_label ("cos_real",IMPORT_LABEL); code_monadic_sane_operator (cos_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); # ifdef M68000 } else code_monadic_real_operator (GFCOS); @@ -1834,16 +1923,31 @@ void code_divI (VOID) void code_divR (VOID) { +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6; + + graph_1=s_pop_b(); + graph_2=g_fp_arg (graph_1); + + graph_3=s_get_b (0); + graph_4=g_fp_arg (graph_3); + + graph_5=g_fdiv (graph_4,graph_2); + + graph_6=g_fromf (graph_5); + + s_put_b (0,graph_6); +#else INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7,graph_8,graph_9; -#ifdef M68000 +# ifdef M68000 if (!mc68881_flag){ if (div_real==NULL) div_real=enter_label ("div_real",IMPORT_LABEL); code_dyadic_sane_operator (div_real); init_b_stack (2,r_vector); } else { -#endif +# endif graph_1=s_pop_b(); graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); @@ -1858,8 +1962,9 @@ void code_divR (VOID) s_put_b (0,graph_8); s_put_b (1,graph_9); -#ifdef M68000 +# ifdef M68000 } +# endif #endif } @@ -2047,9 +2152,22 @@ void code_eqI_b (LONG value,int b_offset) void code_eqR (VOID) { +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5; + + graph_1=s_pop_b(); + graph_2=g_fp_arg (graph_1); + + graph_3=s_pop_b(); + graph_4=g_fp_arg (graph_3); + + graph_5=g_fcmp_eq (graph_4,graph_2); + + s_push_b (graph_5); +#else INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7; -#ifdef M68000 +# ifdef M68000 if (!mc68881_flag){ if (eq_real==NULL) eq_real=enter_label ("eq_real",IMPORT_LABEL); @@ -2057,7 +2175,7 @@ void code_eqR (VOID) code_dyadic_sane_operator (eq_real); init_b_stack (1,i_vector); } else { -#endif +# endif graph_1=s_pop_b(); graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); @@ -2069,8 +2187,9 @@ void code_eqR (VOID) graph_7=g_fcmp_eq (graph_6,graph_3); s_push_b (graph_7); -#ifdef M68000 +# ifdef M68000 } +# endif #endif } @@ -2146,10 +2265,14 @@ void code_eqR_b (double value,int b_offset) init_b_stack (1,i_vector); } else { #endif +#ifdef G_A64 + graph_1=s_get_b (b_offset); + graph_3=g_fp_arg (graph_1); +#else graph_1=s_get_b (b_offset); graph_2=s_get_b (b_offset+1); graph_3=g_fjoin (graph_1,graph_2); - +#endif graph_4=g_fload_i (value); graph_5=g_fcmp_eq (graph_4,graph_3); @@ -2171,7 +2294,7 @@ void code_eqAC_a (char *string,int string_length) string_label=w_code_length_and_string (string,string_length); graph_1=s_pop_a(); - graph_2=g_lea_i (string_label,-4); + graph_2=g_lea_i (string_label,-STACK_ELEMENT_SIZE); s_push_a (graph_2); s_push_a (graph_1); @@ -2309,7 +2432,7 @@ void code_expR (VOID) if (exp_real==NULL) exp_real=enter_label ("exp_real",IMPORT_LABEL); code_monadic_sane_operator (exp_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } void code_fill_r (char descriptor_name[],int a_size,int b_size,int root_offset,int a_offset,int b_offset) @@ -2857,7 +2980,7 @@ void code_fill2 (char descriptor_name[],int arity,int a_offset,char bits[]) --a_offset; } - graph_3=g_fill_m (g_load_id (8-NODE_POINTER_OFFSET,graph_1),arity-1); + graph_3=g_fill_m (g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1),arity-1); parameter=&graph_3->instruction_parameters[1]; for (argument_n=1; argument_n<arity; ++argument_n){ @@ -2929,13 +3052,13 @@ void code_fill3 (char descriptor_name[],int arity,int a_offset,char bits[]) } if (bits[0]=='0') - graph_5=g_load_id (4,graph_0); + graph_5=g_load_id (STACK_ELEMENT_SIZE,graph_0); else { graph_5=s_pop_a(); --a_offset; } - graph_0=g_load_id (8,graph_0); + graph_0=g_load_id (2*STACK_ELEMENT_SIZE,graph_0); a_n=1; @@ -3035,7 +3158,7 @@ void code_fillC (int value,int a_offset) graph_1->inode_arity=1; graph_1->instruction_parameters[0].l=static_characters_label; - graph_1->instruction_parameters[1].i=(value<<3)+NODE_POINTER_OFFSET; + graph_1->instruction_parameters[1].i=(value<<(1+STACK_ELEMENT_LOG_SIZE))+NODE_POINTER_OFFSET; return; } @@ -3153,14 +3276,23 @@ void code_fillR_b (int b_offset,int a_offset) graph_4=real_descriptor_graph(); graph_1=s_get_b (b_offset); +#ifndef G_A64 graph_2=s_get_b (b_offset+1); +#endif graph_5=s_get_a (a_offset); +#ifdef M68000 if (!mc68881_flag) graph_6=g_fill_4 (graph_5,graph_4,graph_1,graph_2); - else { + else +#endif + { +#ifdef G_A64 + graph_3=g_fp_arg (graph_1); +#else graph_3=g_fjoin (graph_1,graph_2); +#endif graph_6=g_fill_r (graph_5,graph_4,graph_3); } @@ -3233,7 +3365,7 @@ void code_fillcaf (char *label_name,int a_stack_size,int b_stack_size) caf_listp_label=enter_label ("caf_listp",DATA_LABEL | IMPORT_LABEL); graph_5=g_lea (caf_listp_label); - graph_6=g_sub (g_load_i (4),g_load_id (0,graph_5)); + graph_6=g_sub (g_load_i (STACK_ELEMENT_SIZE),g_load_id (0,graph_5)); graph_7=g_fill_2 (graph_6,graph_2); graph_8=g_fill_2 (graph_5,g_keep (graph_7,graph_2)); @@ -3243,6 +3375,11 @@ void code_fillcaf (char *label_name,int a_stack_size,int b_stack_size) } else { graph_3=s_get_b (0); +#ifdef G_A64 + if (b_stack_size>0 && graph_3->instruction_code==GFROMF) + graph_4=g_fromf (g_fkeep (graph_2,g_fp_arg (graph_3))); + else +#else if (b_stack_size>=2 && graph_3->instruction_code==GFHIGH){ graph_4=s_get_b (1); if (graph_4->instruction_code==GFLOW && @@ -3260,6 +3397,7 @@ void code_fillcaf (char *label_name,int a_stack_size,int b_stack_size) return; } } +#endif graph_4=g_keep (graph_2,graph_3); s_put_b (0,graph_4); @@ -3347,9 +3485,22 @@ void code_gtI (VOID) void code_gtR (VOID) { - INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7; +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5; -#ifdef M68000 + graph_1=s_pop_b(); + graph_2=g_fp_arg (graph_1); + + graph_3=s_pop_b(); + graph_4=g_fp_arg (graph_3); + + graph_5=g_fcmp_gt (graph_4,graph_2); + + s_push_b (graph_5); +#else + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7; + +# ifdef M68000 if (!mc68881_flag){ if (gt_real==NULL) gt_real=enter_label ("gt_real",IMPORT_LABEL); @@ -3357,7 +3508,7 @@ void code_gtR (VOID) code_dyadic_sane_operator (gt_real); init_b_stack (1,i_vector); } else { -#endif +# endif graph_1=s_pop_b(); graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); @@ -3369,8 +3520,9 @@ void code_gtR (VOID) graph_7=g_fcmp_gt (graph_6,graph_3); s_push_b (graph_7); -#ifdef M68000 +# ifdef M68000 } +# endif #endif } @@ -3412,7 +3564,7 @@ void code_incI (VOID) s_put_b (0,graph_3); } -void code_instruction (int i) +void code_instruction (CleanInt i) { i_word_i (i); } @@ -3480,9 +3632,15 @@ void code_ItoR (VOID) graph_1=s_pop_b(); graph_2=g_fitor (graph_1); +#ifdef G_A64 + graph_3=g_fromf (graph_2); +#else g_fhighlow (graph_3,graph_4,graph_2); +#endif +#ifndef G_A64 s_push_b (graph_4); +#endif s_push_b (graph_3); #ifdef M68000 } @@ -3774,13 +3932,13 @@ void code_jmp_eval_upd (VOID) # else i_move_r_id (REGISTER_D0,0,REGISTER_A0); # ifdef I486 - i_move_id_id (4,REGISTER_A1,4,REGISTER_A0); - i_move_id_id (8,REGISTER_A1,8,REGISTER_A0); + i_move_id_id (STACK_ELEMENT_SIZE,REGISTER_A1,STACK_ELEMENT_SIZE,REGISTER_A0); + i_move_id_id (2*STACK_ELEMENT_SIZE,REGISTER_A1,2*STACK_ELEMENT_SIZE,REGISTER_A0); # else - i_move_id_r (4,REGISTER_A1,REGISTER_D1); - i_move_id_r (8,REGISTER_A1,REGISTER_D2); - i_move_r_id (REGISTER_D1,4,REGISTER_A0); - i_move_r_id (REGISTER_D2,8,REGISTER_A0); + i_move_id_r (STACK_ELEMENT_SIZE,REGISTER_A1,REGISTER_D1); + i_move_id_r (2*STACK_ELEMENT_SIZE,REGISTER_A1,REGISTER_D2); + i_move_r_id (REGISTER_D1,STACK_ELEMENT_SIZE,REGISTER_A0); + i_move_r_id (REGISTER_D2,2*STACK_ELEMENT_SIZE,REGISTER_A0); # endif # endif @@ -4139,7 +4297,7 @@ void code_lnR (VOID) if (ln_real==NULL) ln_real=enter_label ("ln_real",IMPORT_LABEL); code_monadic_sane_operator (ln_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } void code_log10R (VOID) @@ -4153,7 +4311,7 @@ void code_log10R (VOID) if (log10_real==NULL) log10_real=enter_label ("log10_real",IMPORT_LABEL); code_monadic_sane_operator (log10_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } void code_ltC (VOID) @@ -4180,16 +4338,29 @@ void code_ltI (VOID) void code_ltR (VOID) { +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5; + + graph_1=s_pop_b(); + graph_2=g_fp_arg (graph_1); + + graph_3=s_pop_b(); + graph_4=g_fp_arg (graph_3); + + graph_5=g_fcmp_lt (graph_4,graph_2); + + s_push_b (graph_5); +#else INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7; -#ifdef M68000 +# ifdef M68000 if (!mc68881_flag){ if (lt_real==NULL) lt_real=enter_label ("lt_real",IMPORT_LABEL); code_dyadic_sane_operator (lt_real); init_b_stack (1,i_vector); } else { -#endif +# endif graph_1=s_pop_b(); graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); @@ -4201,8 +4372,9 @@ void code_ltR (VOID) graph_7=g_fcmp_lt (graph_6,graph_3); s_push_b (graph_7); -#ifdef M68000 +# ifdef M68000 } +# endif #endif } @@ -4391,16 +4563,31 @@ void code_mulIo (VOID) void code_mulR (VOID) { +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6; + + graph_1=s_pop_b(); + graph_2=g_fp_arg (graph_1); + + graph_3=s_get_b (0); + graph_4=g_fp_arg (graph_3); + + graph_5=g_fmul (graph_4,graph_2); + + graph_6=g_fromf (graph_5); + + s_put_b (0,graph_6); +#else INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7,graph_8,graph_9; -#ifdef M68000 +# ifdef M68000 if (!mc68881_flag){ if (mul_real==NULL) mul_real=enter_label ("mul_real",IMPORT_LABEL); code_dyadic_sane_operator (mul_real); init_b_stack (2,r_vector); } else { -#endif +# endif graph_1=s_pop_b(); graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); @@ -4415,8 +4602,9 @@ void code_mulR (VOID) s_put_b (0,graph_8); s_put_b (1,graph_9); -#ifdef M68000 +# ifdef M68000 } +# endif #endif } @@ -4517,7 +4705,7 @@ void code_negR (void) if (neg_real==NULL) neg_real=enter_label ("neg_real",IMPORT_LABEL); code_monadic_sane_operator (neg_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } else #endif code_monadic_real_operator (GFNEG); @@ -4595,7 +4783,7 @@ void code_powR (VOID) pow_real=enter_label ("pow_real",IMPORT_LABEL); code_dyadic_sane_operator (pow_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } void code_print (char *string,int length) @@ -4658,6 +4846,12 @@ void code_print_real (VOID) print_real_label=enter_label ("print_real",IMPORT_LABEL); graph_1=s_pop_b(); +#ifdef G_A64 + s_push_b (NULL); + s_push_b (graph_1); + + insert_basic_block (JSR_BLOCK,0,1+1,r_vector,print_real_label); +#else graph_2=s_pop_b(); s_push_b (NULL); @@ -4665,6 +4859,7 @@ void code_print_real (VOID) s_push_b (graph_1); insert_basic_block (JSR_BLOCK,0,2+1,r_vector,print_real_label); +#endif } void code_print_sc (char *string,int length) @@ -4782,17 +4977,17 @@ void code_pushcaf (char *label_name,int a_stack_size,int b_stack_size) { int offset; - offset=n_arguments<<2; + offset=n_arguments<<STACK_ELEMENT_LOG_SIZE; while (b_stack_size>0){ s_push_b (g_load_id (offset,graph_1)); - offset-=4; + offset-=STACK_ELEMENT_SIZE; --b_stack_size; } while (a_stack_size>0){ s_push_a (g_load_id (offset,graph_1)); - offset-=4; + offset-=STACK_ELEMENT_SIZE; --a_stack_size; } } @@ -4803,7 +4998,7 @@ void code_pushA_a (int a_offset) INSTRUCTION_GRAPH graph_1,graph_2; graph_1=s_get_a (a_offset); - graph_2=g_load_id (4,graph_1); + graph_2=g_load_id (STACK_ELEMENT_SIZE,graph_1); s_push_a (graph_2); } @@ -4897,7 +5092,7 @@ void code_pushF_a (int a_offset) s_push_b (graph_4); } -void code_pushI (LONG i) +void code_pushI (CleanInt i) { INSTRUCTION_GRAPH graph_1; @@ -4972,10 +5167,16 @@ void code_pushR (double v) } else { graph_1=g_fload_i (v); +#ifdef G_A64 + graph_2=g_fromf (graph_1); +#else g_fhighlow (graph_2,graph_3,graph_1); +#endif } +#ifndef G_A64 s_push_b (graph_3); +#endif s_push_b (graph_2); } @@ -4995,11 +5196,16 @@ void code_pushR_a (int a_offset) graph_4=g_load_id (ARGUMENTS_OFFSET-NODE_POINTER_OFFSET+4,graph_1); } else { graph_2=g_fload_id (ARGUMENTS_OFFSET-NODE_POINTER_OFFSET,graph_1); - +#ifdef G_A64 + graph_3=g_fromf (graph_2); +#else g_fhighlow (graph_3,graph_4,graph_2); +#endif } +#ifndef G_A64 s_push_b (graph_4); +#endif s_push_b (graph_3); } @@ -5084,12 +5290,12 @@ void code_push_arg (int a_offset,int arity,int argument_number) graph_1=s_get_a (a_offset); if (argument_number<2 || (argument_number==2 && arity==2)) - graph_2=g_load_id (argument_number<<2,graph_1); + graph_2=g_load_id (argument_number<<STACK_ELEMENT_LOG_SIZE,graph_1); else { INSTRUCTION_GRAPH graph_3; - graph_3=g_load_id (8,graph_1); - graph_2=g_load_id ((argument_number-2)<<2,graph_3); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE,graph_1); + graph_2=g_load_id ((argument_number-2)<<STACK_ELEMENT_LOG_SIZE,graph_3); } s_push_a (graph_2); @@ -5136,12 +5342,12 @@ void code_push_args (int a_offset,int arity,int n_arguments) if (n_arguments!=1) if (n_arguments==2 && arity==2){ - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); s_push_a (graph_3); } else { INSTRUCTION_GRAPH graph_4; - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); --n_arguments; if (n_arguments==1){ @@ -5156,7 +5362,7 @@ void code_push_args (int a_offset,int arity,int n_arguments) --n_arguments; - graph_5=g_load_id ((n_arguments<<2)-NODE_POINTER_OFFSET,graph_3); + graph_5=g_load_id ((n_arguments<<STACK_ELEMENT_LOG_SIZE)-NODE_POINTER_OFFSET,graph_3); s_push_a (graph_5); } @@ -5185,9 +5391,9 @@ void code_push_arraysize (char element_descriptor[],int a_size,int b_size) graph_1=s_pop_a(); #ifdef ARRAY_SIZE_BEFORE_DESCRIPTOR - graph_2=g_load_id (-4,graph_1); + graph_2=g_load_id (-STACK_ELEMENT_SIZE,graph_1); #else - graph_2=g_load_id (4,graph_1); + graph_2=g_load_id (STACK_ELEMENT_SIZE,graph_1); #endif s_push_b (graph_2); } @@ -5231,7 +5437,7 @@ static void push_record_arguments (INSTRUCTION_GRAPH graph_1,int a_size,int b_si return; case 2: graph_2=g_load_id (ARGUMENTS_OFFSET-NODE_POINTER_OFFSET,graph_1); - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); switch (b_size){ case 0: s_push_a (graph_3); @@ -5248,7 +5454,7 @@ static void push_record_arguments (INSTRUCTION_GRAPH graph_1,int a_size,int b_si return; default: graph_2=g_load_id (ARGUMENTS_OFFSET-NODE_POINTER_OFFSET,graph_1); - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); #ifdef M68000 if (a_size+b_size-1>=8){ @@ -5257,13 +5463,13 @@ static void push_record_arguments (INSTRUCTION_GRAPH graph_1,int a_size,int b_si while (b_size>a_size && b_size>1){ --b_size; - graph_5=g_load_id (((b_size-1)<<2)-NODE_POINTER_OFFSET,graph_3); + graph_5=g_load_id (((b_size-1)<<STACK_ELEMENT_LOG_SIZE)-NODE_POINTER_OFFSET,graph_3); s_push_b (graph_5); } while (a_size>1){ --a_size; - graph_5=g_load_id (((a_size-1)<<2)-NODE_POINTER_OFFSET,graph_3); + graph_5=g_load_id (((a_size-1)<<STACK_ELEMENT_LOG_SIZE)-NODE_POINTER_OFFSET,graph_3); s_push_a (graph_5); } #ifdef M68000 @@ -5322,11 +5528,11 @@ void code_push_r_args_a (int a_offset,int a_size,int b_size,int argument_number, for (; n_arguments>0; --n_arguments){ --argument_number; if (argument_number<2 || (argument_number==2 && a_size+b_size==2)) - graph_2=g_load_id (argument_number<<2,graph_1); + graph_2=g_load_id (argument_number<<STACK_ELEMENT_LOG_SIZE,graph_1); else { if (graph_3==NULL) - graph_3=g_load_id (8,graph_1); - graph_2=g_load_id ((argument_number-2)<<2,graph_3); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE,graph_1); + graph_2=g_load_id ((argument_number-2)<<STACK_ELEMENT_LOG_SIZE,graph_3); } s_push_a (graph_2); } @@ -5343,11 +5549,11 @@ void code_push_r_args_b (int a_offset,int a_size,int b_size,int argument_number, for (; n_arguments>0; --n_arguments){ --argument_number; if (argument_number<2 || (argument_number==2 && a_size+b_size==2)) - graph_2=g_load_id (argument_number<<2,graph_1); + graph_2=g_load_id (argument_number<<STACK_ELEMENT_LOG_SIZE,graph_1); else { if (graph_3==NULL) - graph_3=g_load_id (8,graph_1); - graph_2=g_load_id ((argument_number-2)<<2,graph_3); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE,graph_1); + graph_2=g_load_id ((argument_number-2)<<STACK_ELEMENT_LOG_SIZE,graph_3); } s_push_b (graph_2); } @@ -5401,7 +5607,7 @@ void code_push_node (char *label_name,int n_arguments) #ifdef I486 argument_n=n_arguments; while (argument_n!=0){ - graph_5=g_load_id ((argument_n<<2)-NODE_POINTER_OFFSET,graph_1); + graph_5=g_load_id ((argument_n<<STACK_ELEMENT_LOG_SIZE)-NODE_POINTER_OFFSET,graph_1); --argument_n; s_push_a (graph_5); } @@ -5416,7 +5622,7 @@ void code_push_node (char *label_name,int n_arguments) } #endif } else { - graph_4=g_load_id (4-NODE_POINTER_OFFSET,graph_1); + graph_4=g_load_id (STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); s_push_a (graph_4); } } @@ -5477,7 +5683,7 @@ void code_push_node_u (char *label_name,int a_size,int b_size) #ifdef I486 argument_n=a_size+b_size; while (argument_n!=0){ - graph_5=g_load_id ((argument_n<<2)-NODE_POINTER_OFFSET,graph_1); + graph_5=g_load_id ((argument_n<<(STACK_ELEMENT_LOG_SIZE))-NODE_POINTER_OFFSET,graph_1); --argument_n; if (argument_n<a_size) s_push_a (graph_5); @@ -5485,7 +5691,7 @@ void code_push_node_u (char *label_name,int a_size,int b_size) s_push_b (graph_5); } #else - graph_4=g_movem (4-NODE_POINTER_OFFSET,graph_1,a_size+b_size); + graph_4=g_movem (STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1,a_size+b_size); argument_n=a_size+b_size; while (argument_n!=0){ @@ -5498,7 +5704,7 @@ void code_push_node_u (char *label_name,int a_size,int b_size) } #endif } else { - graph_4=g_load_id (4-NODE_POINTER_OFFSET,graph_1); + graph_4=g_load_id (STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); if (a_size>0) s_push_a (graph_4); else @@ -5741,18 +5947,18 @@ static INSTRUCTION_GRAPH g_lsl_3_add_12 (INSTRUCTION_GRAPH graph_1) graph_1_arg_1=graph_1->instruction_parameters[0].p; graph_1_arg_2=graph_1->instruction_parameters[1].p; if (graph_1_arg_1->instruction_code==GLOAD_I) - return g_add (g_load_i (12+(graph_1_arg_1->instruction_parameters[0].i<<3)),g_lsl_3 (graph_1_arg_2)); + return g_add (g_load_i (REAL_ARRAY_ELEMENTS_OFFSET+(graph_1_arg_1->instruction_parameters[0].i<<3)),g_lsl_3 (graph_1_arg_2)); if (graph_1_arg_2->instruction_code==GLOAD_I) - return g_add (g_load_i (12+(graph_1_arg_2->instruction_parameters[0].i<<3)),g_lsl_3 (graph_1_arg_1)); + return g_add (g_load_i (REAL_ARRAY_ELEMENTS_OFFSET+(graph_1_arg_2->instruction_parameters[0].i<<3)),g_lsl_3 (graph_1_arg_1)); } else if (graph_1->instruction_code==GSUB){ INSTRUCTION_GRAPH graph_1_arg_1,graph_1_arg_2; graph_1_arg_1=graph_1->instruction_parameters[0].p; graph_1_arg_2=graph_1->instruction_parameters[1].p; if (graph_1_arg_1->instruction_code==GLOAD_I) - return g_add (g_load_i (12-(graph_1_arg_1->instruction_parameters[0].i<<3)),g_lsl_3 (graph_1_arg_2)); + return g_add (g_load_i (REAL_ARRAY_ELEMENTS_OFFSET-(graph_1_arg_1->instruction_parameters[0].i<<3)),g_lsl_3 (graph_1_arg_2)); if (graph_1_arg_2->instruction_code==GLOAD_I) - return g_sub (g_lsl_3 (graph_1_arg_1),g_load_i (12+(graph_1_arg_2->instruction_parameters[0].i<<3))); + return g_sub (g_lsl_3 (graph_1_arg_1),g_load_i (REAL_ARRAY_ELEMENTS_OFFSET+(graph_1_arg_2->instruction_parameters[0].i<<3))); } graph_2=g_add (g_load_i (REAL_ARRAY_ELEMENTS_OFFSET),g_lsl_3 (graph_1)); #endif @@ -5816,10 +6022,10 @@ static void code_replaceI (VOID) graph_3=s_get_b (0); if (!check_index_flag && graph_2->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>2)) + LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>STACK_ELEMENT_LOG_SIZE)) { int offset; - offset=ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<2); + offset=ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<STACK_ELEMENT_LOG_SIZE); graph_5=g_load_x (graph_1,offset,0,NULL); graph_4=g_store_x (graph_3,graph_1,offset,0,NULL); @@ -5838,9 +6044,9 @@ static void code_replaceI (VOID) { int offset; - graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,2,graph_2,&offset); - graph_5=g_load_x (graph_1,offset,2,graph_2); - graph_4=g_store_x (graph_3,graph_1,offset,2,graph_2); + graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,STACK_ELEMENT_LOG_SIZE,graph_2,&offset); + graph_5=g_load_x (graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_2); + graph_4=g_store_x (graph_3,graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_2); } #else graph_2=g_lsl_2_add_12 (graph_2); @@ -5926,11 +6132,11 @@ static void code_lazy_replace (VOID) graph_3=s_pop_b(); if (!check_index_flag && graph_3->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_3->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>2)) + LESS_UNSIGNED (graph_3->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>STACK_ELEMENT_LOG_SIZE)) { int offset; - offset=ARRAY_ELEMENTS_OFFSET+(graph_3->instruction_parameters[0].i<<2); + offset=ARRAY_ELEMENTS_OFFSET+(graph_3->instruction_parameters[0].i<<STACK_ELEMENT_LOG_SIZE); graph_5=g_load_x (graph_1,offset,0,NULL); graph_4=g_store_x (graph_2,graph_1,offset,0,NULL); } else { @@ -5948,9 +6154,9 @@ static void code_lazy_replace (VOID) { int offset; - graph_3=optimize_array_index (ARRAY_ELEMENTS_OFFSET,2,graph_3,&offset); - graph_5=g_load_x (graph_1,offset,2,graph_3); - graph_4=g_store_x (graph_2,graph_1,offset,2,graph_3); + graph_3=optimize_array_index (ARRAY_ELEMENTS_OFFSET,STACK_ELEMENT_LOG_SIZE,graph_3,&offset); + graph_5=g_load_x (graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_3); + graph_4=g_store_x (graph_2,graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_3); } #else graph_3=g_lsl_2_add_12 (graph_3); @@ -5971,7 +6177,9 @@ static void code_replaceR (VOID) graph_2=s_pop_b(); graph_3=s_pop_b(); +#ifndef G_A64 graph_4=s_pop_b(); +#endif if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); @@ -5995,7 +6203,7 @@ static void code_replaceR (VOID) graph_9=g_load_x (graph_1,REAL_ARRAY_ELEMENTS_OFFSET,0,graph_6); graph_10=g_load_x (graph_1,REAL_ARRAY_ELEMENTS_OFFSET+4,0,graph_6); graph_7=g_store_x (graph_3,graph_1,REAL_ARRAY_ELEMENTS_OFFSET,0,graph_6); - graph_8=g_store_x (graph_4,graph_7,16,0,graph_6); + graph_8=g_store_x (graph_4,graph_7,REAL_ARRAY_ELEMENTS_OFFSET+4,0,graph_6); } else { graph_9=g_load_x (graph_1,REAL_ARRAY_ELEMENTS_OFFSET,3,graph_2); graph_10=g_load_x (graph_1,REAL_ARRAY_ELEMENTS_OFFSET+4,3,graph_2); @@ -6006,8 +6214,11 @@ static void code_replaceR (VOID) } else #endif { +#ifdef G_A64 + graph_7=g_fp_arg (graph_3); +#else graph_7=g_fjoin (graph_3,graph_4); - +#endif if (!check_index_flag && graph_2->instruction_code==GLOAD_I && LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-REAL_ARRAY_ELEMENTS_OFFSET)>>3)) { @@ -6039,12 +6250,18 @@ static void code_replaceR (VOID) graph_8->inode_arity |= LOAD_STORE_ALIGNED_REAL; #endif +#ifdef G_A64 + graph_9=g_fromf (graph_4); +#else g_fhighlow (graph_9,graph_10,graph_4); +#endif } s_put_a (0,graph_8); +#ifndef G_A64 s_push_b (graph_10); +#endif s_push_b (graph_9); } @@ -6056,19 +6273,19 @@ static void code_r_replace (int a_size,int b_size) graph_1=s_get_a (0); graph_2=s_pop_b(); - element_size=(a_size+b_size)<<2; + element_size=(a_size+b_size)<<STACK_ELEMENT_LOG_SIZE; if (!check_index_flag && graph_2->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-12-(element_size-4))/element_size)) + LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET-(element_size-STACK_ELEMENT_SIZE))/element_size)) { - offset=12+graph_2->instruction_parameters[0].i*element_size; + offset=ARRAY_ELEMENTS_OFFSET+graph_2->instruction_parameters[0].i*element_size; graph_3=NULL; } else { if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); - offset=12; - graph_3=multiply_by_constant ((a_size+b_size)<<2,graph_2); + offset=3<<STACK_ELEMENT_LOG_SIZE; + graph_3=multiply_by_constant ((a_size+b_size)<<STACK_ELEMENT_LOG_SIZE,graph_2); #if defined (sparc) || defined (G_POWER) graph_3=g_add (graph_1,graph_3); @@ -6079,8 +6296,8 @@ static void code_r_replace (int a_size,int b_size) INSTRUCTION_GRAPH graph_4,graph_5; graph_4=s_get_a (i+1); - graph_5=g_load_x (graph_1,offset+(i<<2),0,graph_3); - graph_1=g_store_x (graph_4,graph_1,offset+(i<<2),0,graph_3); + graph_5=g_load_x (graph_1,offset+(i<<STACK_ELEMENT_LOG_SIZE),0,graph_3); + graph_1=g_store_x (graph_4,graph_1,offset+(i<<STACK_ELEMENT_LOG_SIZE),0,graph_3); s_put_a (i,graph_5); } @@ -6090,6 +6307,7 @@ static void code_r_replace (int a_size,int b_size) graph_4=s_get_b (i); +#ifndef G_A64 if (graph_4->instruction_code==GFHIGH && i+1<b_size){ INSTRUCTION_GRAPH graph_5; @@ -6098,8 +6316,8 @@ static void code_r_replace (int a_size,int b_size) INSTRUCTION_GRAPH graph_6,graph_7,graph_8,graph_9; graph_6=g_fjoin (graph_4,graph_5); - graph_7=g_fload_x (graph_1,offset+((a_size+i)<<2),0,graph_3); - graph_1=g_fstore_x (graph_6,graph_1,offset+((a_size+i)<<2),0,graph_3); + graph_7=g_fload_x (graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); + graph_1=g_fstore_x (graph_6,graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); g_fhighlow (graph_8,graph_9,graph_7); @@ -6110,9 +6328,10 @@ static void code_r_replace (int a_size,int b_size) continue; } } +#endif - graph_5=g_load_x (graph_1,offset+((a_size+i)<<2),0,graph_3); - graph_1=g_store_x (graph_4,graph_1,offset+((a_size+i)<<2),0,graph_3); + graph_5=g_load_x (graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); + graph_1=g_store_x (graph_4,graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); s_put_b (i,graph_5); } @@ -6142,9 +6361,9 @@ void code_replace (char element_descriptor[],int a_size,int b_size) element_descriptor[4]=='\0') { #ifdef ARRAY_SIZE_BEFORE_DESCRIPTOR - code_replaceBC (4,0); + code_replaceBC (STACK_ELEMENT_SIZE,0); #else - code_replaceBC (8,0); + code_replaceBC (2*STACK_ELEMENT_SIZE,0); #endif return; } @@ -6209,12 +6428,12 @@ void code_repl_arg (int arity,int argument_n) graph_1=s_pop_a(); if (argument_n<2 || (argument_n==2 && arity==2)) - graph_2=g_load_id (argument_n<<2,graph_1); + graph_2=g_load_id (argument_n<<STACK_ELEMENT_LOG_SIZE,graph_1); else { INSTRUCTION_GRAPH graph_3; - graph_3=g_load_id (8,graph_1); - graph_2=g_load_id ((argument_n-2)<<2,graph_3); + graph_3=g_load_id (2<<STACK_ELEMENT_LOG_SIZE,graph_1); + graph_2=g_load_id ((argument_n-2)<<STACK_ELEMENT_LOG_SIZE,graph_3); } s_push_a (graph_2); @@ -6232,12 +6451,12 @@ void code_repl_args (int arity,int n_arguments) if (n_arguments!=1) if (n_arguments==2 && arity==2){ - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); s_push_a (graph_3); } else { INSTRUCTION_GRAPH graph_4; - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); --n_arguments; if (n_arguments==1){ @@ -6252,7 +6471,7 @@ void code_repl_args (int arity,int n_arguments) --n_arguments; - graph_5=g_load_id ((n_arguments<<2)-NODE_POINTER_OFFSET,graph_3); + graph_5=g_load_id ((n_arguments<<STACK_ELEMENT_LOG_SIZE)-NODE_POINTER_OFFSET,graph_3); s_push_a (graph_5); } #ifndef I486 @@ -6306,11 +6525,11 @@ void code_repl_r_args_a (int a_size,int b_size,int argument_number,int n_argumen for (; n_arguments>0; --n_arguments){ --argument_number; if (argument_number<2 || (argument_number==2 && a_size+b_size==2)) - graph_2=g_load_id (argument_number<<2,graph_1); + graph_2=g_load_id (argument_number<<STACK_ELEMENT_LOG_SIZE,graph_1); else { if (graph_3==NULL) - graph_3=g_load_id (8,graph_1); - graph_2=g_load_id ((argument_number-2)<<2,graph_3); + graph_3=g_load_id (2<<STACK_ELEMENT_LOG_SIZE,graph_1); + graph_2=g_load_id ((argument_number-2)<<STACK_ELEMENT_LOG_SIZE,graph_3); } s_push_a (graph_2); } @@ -6499,9 +6718,13 @@ void code_RtoI (VOID) r_to_i_buffer_label=enter_label ("r_to_i_buffer",IMPORT_LABEL); # endif graph_1=s_pop_b(); + +# ifdef G_A64 + graph_3=g_fp_arg (graph_1); +# else graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); - +# endif graph_4=g_frtoi (graph_3); s_push_b (graph_4); @@ -6536,9 +6759,9 @@ static void code_lazy_select (VOID) graph_2=s_pop_b(); if (!check_index_flag && graph_2->instruction_code==GLOAD_I && - (unsigned long) graph_2->instruction_parameters[0].i < (unsigned long) ((MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>2)) + (unsigned long) graph_2->instruction_parameters[0].i < (unsigned long) ((MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>STACK_ELEMENT_LOG_SIZE)) { - graph_3=g_load_x (graph_1,ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<2),0,NULL); + graph_3=g_load_x (graph_1,ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<STACK_ELEMENT_LOG_SIZE),0,NULL); } else { if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); @@ -6553,8 +6776,8 @@ static void code_lazy_select (VOID) { int offset; - graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,2,graph_2,&offset); - graph_3=g_load_x (graph_1,offset,2,graph_2); + graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,STACK_ELEMENT_LOG_SIZE,graph_2,&offset); + graph_3=g_load_x (graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_2); } #else graph_2=g_lsl_2_add_12 (graph_2); @@ -6619,9 +6842,9 @@ static void code_selectI (VOID) #endif if (!check_index_flag && graph_2->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>2)) + LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>STACK_ELEMENT_LOG_SIZE)) { - graph_3=g_load_x (graph_1,ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<2),0,NULL); + graph_3=g_load_x (graph_1,ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<STACK_ELEMENT_LOG_SIZE),0,NULL); } else { if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); @@ -6636,8 +6859,8 @@ static void code_selectI (VOID) { int offset; - graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,2,graph_2,&offset); - graph_3=g_load_x (graph_1,offset,2,graph_2); + graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,STACK_ELEMENT_LOG_SIZE,graph_2,&offset); + graph_3=g_load_x (graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_2); } #else graph_2=g_lsl_2_add_12 (graph_2); @@ -6707,10 +6930,16 @@ static void code_selectR (VOID) graph_4->inode_arity |= LOAD_STORE_ALIGNED_REAL; #endif +#ifdef G_A64 + graph_5=g_fromf (graph_4); +#else g_fhighlow (graph_5,graph_6,graph_4); +#endif } +#ifndef G_A64 s_push_b (graph_6); +#endif s_push_b (graph_5); } @@ -6723,19 +6952,19 @@ static void code_r_select (int a_size,int b_size) graph_1=s_pop_a(); graph_2=s_pop_b(); - element_size=(a_size+b_size)<<2; + element_size=(a_size+b_size)<<STACK_ELEMENT_LOG_SIZE; if (!check_index_flag && graph_2->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-12-(element_size-4))/element_size)) + LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET-(element_size-STACK_ELEMENT_SIZE))/element_size)) { - offset=12+graph_2->instruction_parameters[0].i*element_size; + offset=ARRAY_ELEMENTS_OFFSET+graph_2->instruction_parameters[0].i*element_size; graph_3=NULL; } else { if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); - offset=12; - graph_3=multiply_by_constant ((a_size+b_size)<<2,graph_2); + offset=ARRAY_ELEMENTS_OFFSET; + graph_3=multiply_by_constant ((a_size+b_size)<<STACK_ELEMENT_LOG_SIZE,graph_2); #if defined (sparc) || defined (G_POWER) graph_3=g_add (graph_1,graph_3); @@ -6745,14 +6974,14 @@ static void code_r_select (int a_size,int b_size) for (i=a_size-1; i>=0; --i){ INSTRUCTION_GRAPH graph_4; - graph_4=g_load_x (graph_1,offset+(i<<2),0,graph_3); + graph_4=g_load_x (graph_1,offset+(i<<STACK_ELEMENT_LOG_SIZE),0,graph_3); s_push_a (graph_4); } for (i=b_size-1; i>=0; --i){ INSTRUCTION_GRAPH graph_4; - graph_4=g_load_x (graph_1,offset+((a_size+i)<<2),0,graph_3); + graph_4=g_load_x (graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); s_push_b (graph_4); } } @@ -6780,9 +7009,9 @@ void code_select (char element_descriptor[],int a_size,int b_size) element_descriptor[4]=='\0') { #ifdef ARRAY_SIZE_BEFORE_DESCRIPTOR - code_selectBC (4,0); + code_selectBC (STACK_ELEMENT_SIZE,0); #else - code_selectBC (8,0); + code_selectBC (2*STACK_ELEMENT_SIZE,0); #endif return; } @@ -6956,7 +7185,7 @@ void code_sliceS (int source_offset,int destination_offset) void code_sinR (VOID) { -#ifdef I486 +#if defined (I486) && !defined (G_AI64) code_monadic_real_operator (GFSIN); #else # ifdef M68000 @@ -6965,7 +7194,7 @@ void code_sinR (VOID) if (sin_real==NULL) sin_real=enter_label ("sin_real",IMPORT_LABEL); code_monadic_sane_operator (sin_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); # ifdef M68000 } else code_monadic_real_operator (GFSIN); @@ -6980,7 +7209,7 @@ void code_sqrtR (VOID) if (sqrt_real==NULL) sqrt_real=enter_label ("sqrt_real",IMPORT_LABEL); code_monadic_sane_operator (sqrt_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); } else code_monadic_real_operator (GFSQRT); #else @@ -6988,7 +7217,7 @@ void code_sqrtR (VOID) if (sqrt_real==NULL) sqrt_real=enter_label ("sqrt_real",IMPORT_LABEL); code_monadic_sane_operator (sqrt_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); # else code_monadic_real_operator (GFSQRT); # endif @@ -7039,16 +7268,31 @@ void code_subIo (VOID) void code_subR (VOID) { +#ifdef G_A64 + INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7; + + graph_1=s_pop_b(); + graph_2=g_fp_arg (graph_1); + + graph_3=s_get_b (0); + graph_4=g_fp_arg (graph_3); + + graph_5=g_fsub (graph_4,graph_2); + + graph_6=g_fromf (graph_5); + + s_put_b (0,graph_6); +#else INSTRUCTION_GRAPH graph_1,graph_2,graph_3,graph_4,graph_5,graph_6,graph_7,graph_8,graph_9; -#ifdef M68000 +# ifdef M68000 if (!mc68881_flag){ if (sub_real==NULL) sub_real=enter_label ("sub_real",IMPORT_LABEL); code_dyadic_sane_operator (sub_real); init_b_stack (2,r_vector); } else { -#endif +# endif graph_1=s_pop_b(); graph_2=s_pop_b(); graph_3=g_fjoin (graph_1,graph_2); @@ -7063,8 +7307,9 @@ void code_subR (VOID) s_put_b (1,graph_9); s_put_b (0,graph_8); -#ifdef M68000 +# ifdef M68000 } +# endif #endif } @@ -7076,7 +7321,7 @@ void code_tanR (VOID) if (tan_real==NULL) tan_real=enter_label ("tan_real",IMPORT_LABEL); code_monadic_sane_operator (tan_real); - init_b_stack (2,r_vector); + init_b_stack (SIZE_OF_REAL_IN_STACK_ELEMENTS,r_vector); #ifdef M68000 } else code_monadic_real_operator (GFTAN); @@ -7137,9 +7382,9 @@ static void code_lazy_update (VOID) graph_3=s_pop_b(); if (!check_index_flag && graph_3->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_3->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>2)) + LESS_UNSIGNED (graph_3->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>STACK_ELEMENT_LOG_SIZE)) { - graph_4=g_store_x (graph_2,graph_1,ARRAY_ELEMENTS_OFFSET+(graph_3->instruction_parameters[0].i<<2),0,NULL); + graph_4=g_store_x (graph_2,graph_1,ARRAY_ELEMENTS_OFFSET+(graph_3->instruction_parameters[0].i<<STACK_ELEMENT_LOG_SIZE),0,NULL); } else { if (check_index_flag) graph_3=g_bounds (graph_1,graph_3); @@ -7154,8 +7399,8 @@ static void code_lazy_update (VOID) { int offset; - graph_3=optimize_array_index (ARRAY_ELEMENTS_OFFSET,2,graph_3,&offset); - graph_4=g_store_x (graph_2,graph_1,offset,2,graph_3); + graph_3=optimize_array_index (ARRAY_ELEMENTS_OFFSET,STACK_ELEMENT_LOG_SIZE,graph_3,&offset); + graph_4=g_store_x (graph_2,graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_3); } #else graph_3=g_lsl_2_add_12 (graph_3); @@ -7219,9 +7464,9 @@ static void code_updateI (VOID) #endif if (!check_index_flag && graph_2->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>2)) + LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET)>>STACK_ELEMENT_LOG_SIZE)) { - graph_4=g_store_x (graph_3,graph_1,ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<2),0,NULL); + graph_4=g_store_x (graph_3,graph_1,ARRAY_ELEMENTS_OFFSET+(graph_2->instruction_parameters[0].i<<STACK_ELEMENT_LOG_SIZE),0,NULL); } else { if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); @@ -7236,8 +7481,8 @@ static void code_updateI (VOID) { int offset; - graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,2,graph_2,&offset); - graph_4=g_store_x (graph_3,graph_1,offset,2,graph_2); + graph_2=optimize_array_index (ARRAY_ELEMENTS_OFFSET,STACK_ELEMENT_LOG_SIZE,graph_2,&offset); + graph_4=g_store_x (graph_3,graph_1,offset,STACK_ELEMENT_LOG_SIZE,graph_2); } #else graph_2=g_lsl_2_add_12 (graph_2); @@ -7256,7 +7501,9 @@ static void code_updateR (VOID) graph_2=s_pop_b(); graph_3=s_pop_b(); +#ifndef G_A64 graph_4=s_pop_b(); +#endif if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); @@ -7285,8 +7532,11 @@ static void code_updateR (VOID) } else #endif { +#ifdef G_A64 + graph_7=g_fp_arg (graph_3); +#else graph_7=g_fjoin (graph_3,graph_4); - +#endif if (!check_index_flag && graph_2->instruction_code==GLOAD_I && LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-REAL_ARRAY_ELEMENTS_OFFSET)>>3)) { @@ -7341,12 +7591,12 @@ static void code_r_update (int a_size,int b_size) graph_1=s_pop_a(); graph_2=s_pop_b(); - element_size=(a_size+b_size)<<2; + element_size=(a_size+b_size)<<STACK_ELEMENT_LOG_SIZE; if (!check_index_flag && graph_2->instruction_code==GLOAD_I && - LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-12-(element_size-4))/element_size)) + LESS_UNSIGNED (graph_2->instruction_parameters[0].i,(MAX_INDIRECT_OFFSET-ARRAY_ELEMENTS_OFFSET-(element_size-STACK_ELEMENT_SIZE))/element_size)) { - offset=12+graph_2->instruction_parameters[0].i*element_size; + offset=ARRAY_ELEMENTS_OFFSET+graph_2->instruction_parameters[0].i*element_size; graph_3=NULL; } else { INSTRUCTION_GRAPH select_graph; @@ -7354,7 +7604,7 @@ static void code_r_update (int a_size,int b_size) if (check_index_flag) graph_2=g_bounds (graph_1,graph_2); - offset=12; + offset=3<<STACK_ELEMENT_LOG_SIZE; graph_3=multiply_by_constant (element_size,graph_2); #if defined (sparc) || defined (G_POWER) @@ -7385,7 +7635,7 @@ static void code_r_update (int a_size,int b_size) INSTRUCTION_GRAPH graph_4; graph_4=s_pop_a(); - graph_1=g_store_x (graph_4,graph_1,offset+(i<<2),0,graph_3); + graph_1=g_store_x (graph_4,graph_1,offset+(i<<STACK_ELEMENT_LOG_SIZE),0,graph_3); } for (i=0; i<b_size; ++i){ @@ -7393,6 +7643,21 @@ static void code_r_update (int a_size,int b_size) graph_4=s_pop_b(); +#ifdef G_A64 + if (graph_4->instruction_code==GFROMF){ + INSTRUCTION_GRAPH graph_5; + + graph_5=g_fp_arg (graph_4); +# if defined (sparc) || defined (G_POWER) + if (offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE)!=0 && graph_3!=NULL) + graph_1=g_fstore_x (graph_5,graph_1,0,0,g_add (g_load_i (offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE)),graph_3)); + else +# endif + graph_1=g_fstore_x (graph_5,graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); + + continue; + } +#else if (graph_4->instruction_code==GFHIGH && i+1<b_size){ INSTRUCTION_GRAPH graph_5,graph_6; @@ -7404,23 +7669,24 @@ static void code_r_update (int a_size,int b_size) if (! ( graph_6->instruction_code==GFLOAD_X && graph_6->instruction_parameters[0].p==graph_7 && - graph_6->instruction_parameters[1].i==((offset+((a_size+i)<<2))<<2) && + graph_6->instruction_parameters[1].i==((offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE))<<2) && graph_6->instruction_parameters[2].p==graph_3)) { - graph_1=g_fstore_x (graph_6,graph_1,offset+((a_size+i)<<2),0,graph_3); + graph_1=g_fstore_x (graph_6,graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); } ++i; continue; } } +#endif if (! ( graph_4->instruction_code==GLOAD_X && graph_4->instruction_parameters[0].p==graph_7 && - graph_4->instruction_parameters[1].i==((offset+((a_size+i)<<2))<<2) && + graph_4->instruction_parameters[1].i==((offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE))<<2) && graph_4->instruction_parameters[2].p==graph_3)) { - graph_1=g_store_x (graph_4,graph_1,offset+((a_size+i)<<2),0,graph_3); + graph_1=g_store_x (graph_4,graph_1,offset+((a_size+i)<<STACK_ELEMENT_LOG_SIZE),0,graph_3); } } @@ -7450,9 +7716,9 @@ void code_update (char element_descriptor[],int a_size,int b_size) element_descriptor[4]=='\0') { #ifdef ARRAY_SIZE_BEFORE_DESCRIPTOR - code_updateBC (4); + code_updateBC (STACK_ELEMENT_SIZE); #else - code_updateBC (8); + code_updateBC (2*STACK_ELEMENT_SIZE); #endif return; } @@ -7565,10 +7831,18 @@ void code_caf (char *label_name,int a_stack_size,int b_stack_size) if (a_stack_size>0){ #if defined (GEN_MAC_OBJ) || defined (GEN_OBJ) +# ifdef G_A64 + store_word64_in_data_section (0); +# else store_long_word_in_data_section (0); +# endif #endif if (assembly_flag) +#ifdef G_A64 + w_as_word64_in_data_section ((__int64)0); +#else w_as_long_in_data_section (0); +#endif } #ifdef GEN_MAC_OBJ @@ -7591,10 +7865,18 @@ void code_caf (char *label_name,int a_stack_size,int b_stack_size) for (n=0; n<=n_arguments; ++n){ #if defined (GEN_MAC_OBJ) || defined (GEN_OBJ) +# ifdef G_A64 + store_word64_in_data_section (0); +# else store_long_word_in_data_section (0); +# endif #endif if (assembly_flag) +#ifdef G_A64 + w_as_word64_in_data_section ((__int64)0); +#else w_as_long_in_data_section (0); +#endif } } @@ -7925,7 +8207,11 @@ static void code_descriptor (char label_name[],char node_entry_label_name[],char store_word_in_data_section (arity); # else # ifdef GEN_OBJ +# ifdef I486 + store_long_word_in_data_section ((arity<<16) | lazy_record_flag); +# else store_2_words_in_data_section (lazy_record_flag,arity); +# endif # endif # endif if (assembly_flag){ @@ -8110,6 +8396,12 @@ void code_descs (char label_name[],char node_entry_label_name[],char *result_des LABEL *string_label,*label; int string_code_label_id; +#ifdef G_AI64 + if (result_descriptor_name[0]=='I' && result_descriptor_name[1]=='N' && + result_descriptor_name[2]=='T' && result_descriptor_name[3]=='\0') + result_descriptor_name="dINT"; +#endif + #if defined (NO_FUNCTION_NAMES) descriptor_name_length=0; #endif @@ -8166,14 +8458,14 @@ void code_descs (char label_name[],char node_entry_label_name[],char *result_des #ifdef GEN_OBJ store_2_words_in_data_section (0,8); - store_2_words_in_data_section (offset1<<2,offset2<<2); + store_2_words_in_data_section (offset1<<STACK_ELEMENT_LOG_SIZE,offset2<<STACK_ELEMENT_LOG_SIZE); store_2_words_in_data_section (1,0); #endif if (assembly_flag){ w_as_word_in_data_section (0); w_as_word_in_data_section (8); - w_as_word_in_data_section (offset1<<2); - w_as_word_in_data_section (offset2<<2); + w_as_word_in_data_section (offset1<<STACK_ELEMENT_LOG_SIZE); + w_as_word_in_data_section (offset2<<STACK_ELEMENT_LOG_SIZE); w_as_word_in_data_section (1); w_as_word_in_data_section (0); } @@ -8470,7 +8762,11 @@ void code_pb (char string[],int string_length) # ifdef GEN_OBJ define_data_label (profile_function_label); +# ifdef G_A64 + store_word64_in_data_section (0); +# else store_long_word_in_data_section (0); +# endif store_c_string_in_data_section (string,string_length); # endif @@ -8489,7 +8785,11 @@ void code_pb (char string[],int string_length) # endif w_as_define_data_label (profile_function_label->label_number); # endif +# ifdef G_A64 + w_as_word64_in_data_section ((__int64)0); +# else w_as_long_in_data_section (0); +# endif w_as_c_string_in_data_section (string,string_length); } #endif @@ -8646,7 +8946,37 @@ void code_string (char label_name[],char string[],int string_length) void code_module (char label_name[],char string[],int string_length) { +#ifdef G_A64 + LABEL *label; + + label=enter_label (label_name,LOCAL_LABEL +#ifdef G_POWER + | DATA_LABEL | STRING_LABEL +#endif + ); + + if (label->label_id>=0) + error_s ("Label %d defined twice\n",label_name); + label->label_id=next_label_id++; + +#ifdef FUNCTION_LEVEL_LINKING + as_new_data_module(); + if (assembly_flag) + w_as_new_data_module(); +#endif + +# ifdef GEN_OBJ + define_data_label (label); + store_abc_string4_in_data_section (string,string_length); +# endif + + if (assembly_flag) + w_as_abc_string_and_label_in_data_section (string,string_length,label_name); + + module_label=label; +#else module_label=code_string_or_module (label_name,string,string_length); +#endif } void code_label (char *label_name) @@ -8947,10 +9277,10 @@ void initialize_coding (VOID) collect_0_label=enter_label ("collect_0",IMPORT_LABEL); collect_1_label=enter_label ("collect_1",IMPORT_LABEL); collect_2_label=enter_label ("collect_2",IMPORT_LABEL); -#ifndef I486 +#if !(defined (I486) && !defined (G_AI64)) collect_3_label=enter_label ("collect_3",IMPORT_LABEL); #endif -#if defined (I486) && defined (GEN_OBJ) +#if defined (I486) && defined (GEN_OBJ) && !defined (G_AI64) collect_0l_label=enter_label ("collect_0l",IMPORT_LABEL); collect_1l_label=enter_label ("collect_1l",IMPORT_LABEL); collect_2l_label=enter_label ("collect_2l",IMPORT_LABEL); @@ -1,18 +1,28 @@ +#ifndef G_A64 #define g_fhighlow(gh,gl,gf) \ (gh)=g_instruction_2 (GFHIGH,(gf),NULL); \ (gl)=g_instruction_2 (GFLOW,(gf),(gh)); \ (gh)->instruction_parameters[1].p=(gl) +#endif extern void initialize_coding (VOID); extern void show_code (VOID); extern void show_imports_and_exports (VOID); extern INSTRUCTION_GRAPH g_load (int offset,int stack); +#ifdef G_A64 +extern INSTRUCTION_GRAPH g_fp_arg (INSTRUCTION_GRAPH graph_1); +#else extern INSTRUCTION_GRAPH g_fjoin (INSTRUCTION_GRAPH graph_1,INSTRUCTION_GRAPH graph_2); +#endif extern INSTRUCTION_GRAPH g_fregister (int float_reg); extern INSTRUCTION_GRAPH g_fstore (int offset,int reg_1,INSTRUCTION_GRAPH graph_1, +#ifdef G_A64 + INSTRUCTION_GRAPH graph_2); +#else INSTRUCTION_GRAPH graph_2,INSTRUCTION_GRAPH graph_3); +#endif extern INSTRUCTION_GRAPH g_fstore_r (int reg_1,INSTRUCTION_GRAPH graph_1); extern INSTRUCTION_GRAPH g_store (int offset,int reg_1,INSTRUCTION_GRAPH graph_1,INSTRUCTION_GRAPH graph_2); extern INSTRUCTION_GRAPH g_store_r (int reg_1,INSTRUCTION_GRAPH graph_1); @@ -22,9 +32,9 @@ extern INSTRUCTION_GRAPH g_instruction_1 (int instruction_code,INSTRUCTION_GRAPH extern INSTRUCTION_GRAPH g_instruction_2 (int instruction_code,INSTRUCTION_GRAPH graph_1,INSTRUCTION_GRAPH graph_2); extern INSTRUCTION_GRAPH g_new_node (int,int,int); -#ifndef g_fhighlow -# define g_fhigh(g1) g_instruction_1(GFHIGH,(g1)) -# define g_flow(g1) g_instruction_1(GFLOW,(g1)) +#ifdef G_A64 +# define g_fromf(g1) g_instruction_1(GFROMF,(g1)) +# define g_tof(g1) g_instruction_1(GTOF,(g1)) #endif extern LABEL *enter_label (char *label_name,int label_flags); @@ -37,7 +47,7 @@ extern struct local_label *local_labels; extern struct dependency_list *first_dependency; extern LABEL *collect_0_label,*collect_1_label,*collect_2_label, -#ifndef I486 +#if !(defined (I486) && !defined (G_AI64)) *collect_3_label, #endif #ifdef I486 @@ -35,7 +35,7 @@ void code_build (char descriptor_name[],int arity,char *code_name); void code_buildh (char descriptor_name[],int arity); void code_buildB (int value); void code_buildC (int value); -void code_buildI (LONG value); +void code_buildI (CleanInt value); void code_buildR (double value); void code_buildAC (char *string,int string_length); void code_buildB_b (int b_offset); @@ -129,7 +129,7 @@ void code_gtU (VOID); void code_halt (VOID); void code_in (char parameters[]); void code_incI (VOID); -void code_instruction (int i); +void code_instruction (CleanInt i); void code_is_record (int a_offset); void code_ItoC (VOID); void code_ItoP (VOID); @@ -208,7 +208,7 @@ void code_pushC_a (int a_offset); void code_pushD (char *descriptor); void code_pushD_a (int a_offset); void code_pushF_a (int a_offset); -void code_pushI (LONG i); +void code_pushI (CleanInt i); void code_pushI_a (int a_offset); void code_pushL (char *label_name); void code_pushLc (char *c_function_name); @@ -4,19 +4,24 @@ enum { GBEFORE0, GBOUNDS, GCMP_EQ, GCMP_GT, GCMP_GTU, GCMP_LT, GCMP_LTU, GCNOT, GCOPY, GCREATE, GCREATE_R, GDIV, GEOR, GFABS, GFADD, GFCMP_EQ, GFCMP_GT, GFATAN, - GFCMP_LT, GFCOS, GFDIV, GFHIGH, GFITOR, GFJOIN, - GFKEEP, GFLOAD, GFLOAD_I, GFLOAD_ID, GFLOAD_X, GFLOW, - GFMOVEMI, GFMUL, GFNEG, GFREM, GFRTOI, GFSIN, - GFSUB, GFILL, GFILL_R, GFREGISTER, GFSQRT, GFSTORE, - GFSTORE_R, GFSTORE_X, GFTAN, GGFREGISTER, GGREGISTER, GKEEP, - GINDIRECTION, GLEA, GLOAD, GLOAD_I, GLOAD_ID, GLOAD_X, - GLOAD_B_ID, GLOAD_B_X, GLOAD_DES_ID, GLOAD_DES_I, GLSL, GLSR, - GMOD, GMOVEM, GMOVEMI, GMUL, GMUL_O, GNEG, - GOR, GREGISTER, GSTORE, GSTORE_R, GSTORE_B_X, GSTORE_X, - GSUB, GSUB_O, GTEST_O, GEXIT_IF + GFCMP_LT, GFCOS, GFDIV, GFITOR, GFKEEP, GFLOAD, + GFLOAD_I, GFLOAD_ID, GFLOAD_X, GFMOVEMI, GFMUL, GFNEG, + GFREM, GFRTOI, GFSIN, GFSUB, GFILL, GFILL_R, + GFREGISTER, GFSQRT, GFSTORE, GFSTORE_R, GFSTORE_X, GFTAN, + GGFREGISTER, GGREGISTER, GKEEP, GINDIRECTION, GLEA, GLOAD, + GLOAD_I, GLOAD_ID, GLOAD_X, GLOAD_B_ID, GLOAD_B_X, GLOAD_DES_ID, + GLOAD_DES_I, GLSL, GLSR, GMOD, GMOVEM, GMOVEMI, + GMUL, GMUL_O, GNEG, GOR, GREGISTER, GSTORE, + GSTORE_R, GSTORE_B_X, GSTORE_X, GSUB, GSUB_O, GTEST_O, + GEXIT_IF #if defined (I486) || defined (G_POWER) ,GNOT #endif +#ifndef G_A64 + ,GFHIGH,GFJOIN,GFLOW +#else + ,GFROMF,GTOF +#endif #ifdef G_POWER ,GCREATE_S, GUMULH #endif @@ -3,7 +3,7 @@ # define FMADD #endif -#ifdef I486 +#if defined (I486) && !defined (G_AI64) # define FP_STACK_OPTIMIZATIONS #endif @@ -63,6 +63,9 @@ enum { #ifdef G_POWER ,IUMULH #endif +#ifdef G_AI64 + ,IMOVESW +#endif }; enum { @@ -238,6 +238,39 @@ static int parse_integer (LONG *integer_p) return 1; } +static int parse_clean_integer (CleanInt *integer_p) +{ + CleanInt integer; + int minus_sign; + + minus_sign=0; + if (last_char=='+' || last_char=='-'){ + if (last_char=='-') + minus_sign=!minus_sign; + last_char=getc (abc_file); + } + + if (!is_digit_character (last_char)) + abc_parser_error_i ("Integer expected at line %d\n",line_number); + + integer=last_char-'0'; + last_char=getc (abc_file); + + while (is_digit_character (last_char)){ + integer*=10; + integer+=last_char-'0'; + last_char=getc (abc_file); + } + + skip_spaces_and_tabs(); + + if (minus_sign) + integer=-integer; + *integer_p=integer; + + return 1; +} + static int parse_hexadecimal_number (int *n_p) { register int n; @@ -740,9 +773,9 @@ static int parse_instruction_c (InstructionP instruction) static int parse_instruction_i (InstructionP instruction) { - LONG i; + CleanInt i; - if (!parse_integer (&i)) + if (!parse_clean_integer (&i)) return 0; instruction->instruction_code_function (i); return 1; @@ -1303,8 +1336,10 @@ static int parse_directive_n_n_t (InstructionP instruction) case 'r': case 'R': vector_p[i>>LOG_SMALL_VECTOR_SIZE] |= (1<< (i & MASK_SMALL_VECTOR_SIZE)); i+=1; +#ifndef G_A64 vector_p[i>>LOG_SMALL_VECTOR_SIZE] |= (1<< (i & MASK_SMALL_VECTOR_SIZE)); i+=1; +#endif break; default: abc_parser_error_i ("B, C, F, I, P or R expected at line %d\n",line_number); @@ -2446,8 +2481,10 @@ static int parse_binary_directive_nnt (BInstructionP instruction) case 'r': case 'R': vector_p[i>>LOG_SMALL_VECTOR_SIZE] |= (1<< (i & MASK_SMALL_VECTOR_SIZE)); i+=1; +#ifndef G_A64 vector_p[i>>LOG_SMALL_VECTOR_SIZE] |= (1<< (i & MASK_SMALL_VECTOR_SIZE)); i+=1; +#endif break; default: abc_parser_error_i ("B, C, F, I, P or R expected at line %d\n",line_number); diff --git a/cginstructions.c b/cginstructions.c index 557285b..1d98737 100644 --- a/cginstructions.c +++ b/cginstructions.c @@ -390,6 +390,90 @@ INSTRUCTION_GRAPH g_fill_r (INSTRUCTION_GRAPH graph_1,INSTRUCTION_GRAPH graph_2, return instruction; } +#ifdef G_A64 +INSTRUCTION_GRAPH g_fp_arg (INSTRUCTION_GRAPH graph_1) +{ + if (graph_1->instruction_code==GFROMF) + return graph_1->instruction_parameters[0].p; + + if (graph_1->instruction_code==GLOAD){ + INSTRUCTION_GRAPH fload_graph; + + fload_graph=g_fload (graph_1->instruction_parameters[0].i,graph_1->instruction_parameters[1].i); + + graph_1->instruction_code=GFROMF; + graph_1->instruction_parameters[0].p=fload_graph; + + return fload_graph; + } + + if (graph_1->instruction_code==GLOAD_ID){ + INSTRUCTION_GRAPH fload_graph; + + fload_graph= + g_fload_id (graph_1->instruction_parameters[0].i,graph_1->instruction_parameters[1].p); + + graph_1->instruction_code=GFROMF; + graph_1->instruction_parameters[0].p=fload_graph; + + return fload_graph; + } + + if (graph_1->instruction_code==GMOVEMI){ + INSTRUCTION_GRAPH fmovemi_graph,movem_graph; + int number; + + movem_graph=graph_1->instruction_parameters[0].p; + number=graph_1->inode_arity; + + fmovemi_graph=g_new_node (GFMOVEMI,number,2*sizeof (union instruction_parameter)); + + fmovemi_graph->instruction_parameters[0].p=movem_graph; + fmovemi_graph->instruction_parameters[1].i=0; + + movem_graph->instruction_parameters[2+number].p=fmovemi_graph; + movem_graph->instruction_parameters[2+number+1].p=NULL; + + graph_1->instruction_code=GFROMF; + graph_1->instruction_parameters[0].p=fmovemi_graph; + + return fmovemi_graph; + } + + if (graph_1->instruction_code==GLOAD_X){ + INSTRUCTION_GRAPH fload_graph,*previous_loadx; + + previous_loadx=&load_indexed_list; + + /* added 25-10-2001 */ + while (*previous_loadx!=NULL && *previous_loadx!=graph_1) + /* while (*previous_loadx!=graph_1) */ + previous_loadx=&(*previous_loadx)->instruction_parameters[3].p; + + fload_graph=g_new_node (GFLOAD_X,0,4*sizeof (union instruction_parameter)); + + fload_graph->instruction_parameters[0].p=graph_1->instruction_parameters[0].p; + fload_graph->instruction_parameters[1].i=graph_1->instruction_parameters[1].i; + fload_graph->instruction_parameters[2].p=graph_1->instruction_parameters[2].p; + fload_graph->instruction_parameters[3].p=graph_1->instruction_parameters[3].p; + + /* added 25-10-2001 */ + if (*previous_loadx!=NULL) + /* */ + *previous_loadx=fload_graph; + + fload_graph->instruction_d_min_a_cost+=1; + + graph_1->instruction_code=GFROMF; + graph_1->instruction_parameters[0].p=fload_graph; + /* graph_1->instruction_parameters[3].p=fload_graph; */ + + return fload_graph; + } + + return g_tof (graph_1); +} +#else INSTRUCTION_GRAPH g_fjoin (INSTRUCTION_GRAPH graph_1,INSTRUCTION_GRAPH graph_2) { if (graph_1->instruction_code==GFHIGH && graph_2->instruction_code==GFLOW @@ -408,10 +492,10 @@ INSTRUCTION_GRAPH g_fjoin (INSTRUCTION_GRAPH graph_1,INSTRUCTION_GRAPH graph_2) graph_2->instruction_code=GFLOW; graph_1->instruction_parameters[0].p=fload_graph; graph_2->instruction_parameters[0].p=fload_graph; -#ifdef g_fhighlow + graph_1->instruction_parameters[1].p=graph_2; graph_2->instruction_parameters[1].p=graph_1; -#endif + return fload_graph; } @@ -529,6 +613,7 @@ INSTRUCTION_GRAPH g_fjoin (INSTRUCTION_GRAPH graph_1,INSTRUCTION_GRAPH graph_2) return g_instruction_2 (GFJOIN,graph_1,graph_2); } +#endif INSTRUCTION_GRAPH g_fload (int offset,int stack) { @@ -591,16 +676,29 @@ INSTRUCTION_GRAPH g_fload_x (INSTRUCTION_GRAPH graph_1,int offset,int shift,INST } INSTRUCTION_GRAPH g_fstore (int offset,int reg_1,INSTRUCTION_GRAPH graph_1, +#ifdef G_A64 + INSTRUCTION_GRAPH graph_2) +#else INSTRUCTION_GRAPH graph_2,INSTRUCTION_GRAPH graph_3) +#endif { - register INSTRUCTION_GRAPH instruction; + INSTRUCTION_GRAPH instruction; +#ifdef G_A64 + instruction=g_new_node (GFSTORE,0,4*sizeof (union instruction_parameter)); +#else instruction=g_new_node (GFSTORE,0,5*sizeof (union instruction_parameter)); - +#endif instruction->instruction_parameters[0].i=offset; instruction->instruction_parameters[1].i=reg_1; instruction->instruction_parameters[2].p=graph_1; +#ifdef G_A64 + if (graph_2 && graph_2->instruction_code==GTOF) + instruction->instruction_parameters[3].p=graph_2->instruction_parameters[0].p; + else + instruction->instruction_parameters[3].p=graph_2; +#else if (graph_2 && (graph_2->instruction_code==GFLOW || graph_2->instruction_code==GFHIGH)) instruction->instruction_parameters[3].p=graph_2->instruction_parameters[0].p; else @@ -610,7 +708,7 @@ INSTRUCTION_GRAPH g_fstore (int offset,int reg_1,INSTRUCTION_GRAPH graph_1, instruction->instruction_parameters[4].p=graph_3->instruction_parameters[0].p; else instruction->instruction_parameters[4].p=graph_3; - +#endif return instruction; } @@ -661,13 +759,13 @@ INSTRUCTION_GRAPH g_load (int offset,int stack) return instruction; } -INSTRUCTION_GRAPH g_load_i (LONG value) +INSTRUCTION_GRAPH g_load_i (CleanInt value) { INSTRUCTION_GRAPH instruction; instruction=g_new_node (GLOAD_I,0,sizeof (union instruction_parameter)); - instruction->instruction_parameters[0].i=value; + instruction->instruction_parameters[0].imm=value; return instruction; } @@ -876,7 +974,11 @@ INSTRUCTION_GRAPH g_store (int offset,int reg_1,INSTRUCTION_GRAPH graph_1, instruction->instruction_parameters[1].i=reg_1; instruction->instruction_parameters[2].p=graph_1; +#ifdef G_A64 + if (graph_2 && graph_2->instruction_code==GTOF) +#else if (graph_2 && (graph_2->instruction_code==GFLOW || graph_2->instruction_code==GFHIGH)) +#endif instruction->instruction_parameters[3].p=graph_2->instruction_parameters[0].p; else instruction->instruction_parameters[3].p=graph_2; @@ -1272,7 +1374,7 @@ void code_fill2_r (char descriptor_name[],int a_size,int b_size,int root_offset, ++b_n; } - graph_3=g_fill_m (g_load_id (8,graph_1),a_size+b_size-1); + graph_3=g_fill_m (g_load_id (2*STACK_ELEMENT_SIZE,graph_1),a_size+b_size-1); parameter=&graph_3->instruction_parameters[1]; @@ -1357,7 +1459,7 @@ void code_fill3_r (char descriptor_name[],int a_size,int b_size,int root_offset, b_n=0; if (bits[0]=='0'){ - graph_5=g_load_id (4,graph_0); + graph_5=g_load_id (STACK_ELEMENT_SIZE,graph_0); if (a_n<a_size) ++a_n; else @@ -1373,7 +1475,7 @@ void code_fill3_r (char descriptor_name[],int a_size,int b_size,int root_offset, } } - graph_0=g_load_id (8,graph_0); + graph_0=g_load_id (2*STACK_ELEMENT_SIZE,graph_0); graph_3=g_fill_m (graph_0,a_size+b_size-1); @@ -1404,7 +1506,7 @@ void code_fill3_r (char descriptor_name[],int a_size,int b_size,int root_offset, s_put_a (root_offset,graph_4); } -#define ARGUMENTS_OFFSET 4 +#define ARGUMENTS_OFFSET STACK_ELEMENT_SIZE void code_push_args_u (int a_offset,int arity,int n_arguments) { @@ -1422,13 +1524,13 @@ void code_push_args_u (int a_offset,int arity,int n_arguments) if (n_arguments!=1) if (n_arguments==2 && arity==2){ - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); *--graph_p=graph_3; s_push_a (graph_3); } else { INSTRUCTION_GRAPH graph_4; - graph_3=g_load_id (8-NODE_POINTER_OFFSET,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,graph_1); --n_arguments; if (n_arguments==1){ @@ -1444,7 +1546,7 @@ void code_push_args_u (int a_offset,int arity,int n_arguments) --n_arguments; - graph_5=g_load_id ((n_arguments<<2)-NODE_POINTER_OFFSET,graph_3); + graph_5=g_load_id ((n_arguments<<STACK_ELEMENT_LOG_SIZE)-NODE_POINTER_OFFSET,graph_3); *--graph_p=graph_5; s_push_a (graph_5); } @@ -1494,7 +1596,7 @@ void code_push_r_args_u (int a_offset,int a_size,int b_size) return; case 2: graph_2=g_load_id (ARGUMENTS_OFFSET,graph_1); - graph_3=g_load_id (8,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE,graph_1); *--graph_p=graph_3; *--graph_p=graph_2; switch (b_size){ @@ -1513,7 +1615,7 @@ void code_push_r_args_u (int a_offset,int a_size,int b_size) return; default: graph_2=g_load_id (ARGUMENTS_OFFSET,graph_1); - graph_3=g_load_id (8,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE,graph_1); #ifdef M68000 if (a_size+b_size-1>=8){ @@ -1522,14 +1624,14 @@ void code_push_r_args_u (int a_offset,int a_size,int b_size) while (b_size>a_size && b_size>1){ --b_size; - graph_5=g_load_id ((b_size-1)<<2,graph_3); + graph_5=g_load_id ((b_size-1)<<STACK_ELEMENT_LOG_SIZE,graph_3); *--graph_p=graph_5; s_push_b (graph_5); } while (a_size>1){ --a_size; - graph_5=g_load_id ((a_size-1)<<2,graph_3); + graph_5=g_load_id ((a_size-1)<<STACK_ELEMENT_LOG_SIZE,graph_3); *--graph_p=graph_5; s_push_a (graph_5); } @@ -1588,7 +1690,7 @@ void code_push_r_arg_u (int a_offset,int a_size,int b_size,int a_arg_offset,int break; case 2: graph_2=g_load_id (ARGUMENTS_OFFSET,graph_1); - graph_3=g_load_id (8,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE,graph_1); *--graph_p=graph_3; *--graph_p=graph_2; break; @@ -1597,7 +1699,7 @@ void code_push_r_arg_u (int a_offset,int a_size,int b_size,int a_arg_offset,int int ab_size; graph_2=g_load_id (ARGUMENTS_OFFSET,graph_1); - graph_3=g_load_id (8,graph_1); + graph_3=g_load_id (2*STACK_ELEMENT_SIZE,graph_1); ab_size=a_size+b_size-1; #ifdef M68000 @@ -1605,7 +1707,7 @@ void code_push_r_arg_u (int a_offset,int a_size,int b_size,int a_arg_offset,int #endif while (ab_size>0){ --ab_size; - graph_5=g_load_id (ab_size<<2,graph_3); + graph_5=g_load_id (ab_size<<STACK_ELEMENT_LOG_SIZE,graph_3); *--graph_p=graph_5; } #ifdef M68000 @@ -2293,6 +2395,10 @@ static char ccall_error_string[] = "Error in ccall of '%s'"; # endif #endif +#ifdef G_AI64 +# define REGISTER_RBP (-5) +#endif + #ifdef ALIGN_C_CALLS # define B_STACK_REGISTER REGISTER_O0 #else @@ -2335,9 +2441,9 @@ void code_ccall (char *c_function_name,char *s,int length) #if defined (sparc) || defined (G_POWER) int c_parameter_n; -# ifdef G_POWER +# ifdef G_POWER int c_offset,c_fp_parameter_n; -# endif +# endif #elif defined (I486) int c_offset; #else @@ -2380,13 +2486,14 @@ void code_ccall (char *c_function_name,char *s,int length) min_index=l; break; case 'I': - b_offset+=4; + case 'p': + b_offset+=STACK_ELEMENT_SIZE; if (!float_parameters) ++n_clean_b_register_parameters; continue; -#if defined (I486) || defined (G_POWER) +# if (defined (I486) && !defined (G_AI64)) || defined (G_POWER) case 'r': -#endif +# endif case 'R': float_parameters=1; b_offset+=8; @@ -2394,7 +2501,7 @@ void code_ccall (char *c_function_name,char *s,int length) case 'S': case 's': case 'A': - a_offset+=4; + a_offset+=STACK_ELEMENT_SIZE; continue; case 'O': case 'F': @@ -2412,7 +2519,7 @@ void code_ccall (char *c_function_name,char *s,int length) error_s (ccall_error_string,c_function_name); } } - b_offset+=4; + b_offset+=STACK_ELEMENT_SIZE; if (!float_parameters) ++n_clean_b_register_parameters; continue; @@ -2433,14 +2540,15 @@ void code_ccall (char *c_function_name,char *s,int length) for (++l; l<length; ++l){ switch (s[l]){ case 'I': - b_result_offset+=4; + case 'p': + b_result_offset+=STACK_ELEMENT_SIZE; continue; case 'R': float_parameters=1; b_result_offset+=8; continue; case 'S': - a_result_offset+=4; + a_result_offset+=STACK_ELEMENT_SIZE; continue; case ':': if (l==min_index+1 || l==length-1) @@ -2453,6 +2561,7 @@ void code_ccall (char *c_function_name,char *s,int length) for (++l; l<length; ++l){ switch (s[l]){ case 'I': + case 'p': if (!extra_float_parameters) ++n_extra_clean_b_register_parameters; break; @@ -2487,19 +2596,19 @@ void code_ccall (char *c_function_name,char *s,int length) end_basic_block_with_registers (0,n_clean_b_register_parameters+n_extra_clean_b_register_parameters,e_vector); - b_offset-=n_clean_b_register_parameters<<2; + b_offset-=n_clean_b_register_parameters<<STACK_ELEMENT_LOG_SIZE; if (n_extra_clean_b_register_parameters!=0){ int n,offset; - offset=-4; + offset=-STACK_ELEMENT_SIZE; for (n=0; n<n_extra_clean_b_register_parameters-1; ++n){ # ifdef i486 i_move_r_pd (REGISTER_D0+n,B_STACK_POINTER); # else i_move_r_id (REGISTER_D0+n,offset,B_STACK_POINTER); # endif - offset-=4; + offset-=STACK_ELEMENT_SIZE; } # ifdef G_POWER @@ -2523,14 +2632,15 @@ void code_ccall (char *c_function_name,char *s,int length) result=s[min_index+1]; switch (result){ case 'I': - b_result_offset-=4; + case 'p': + b_result_offset-=STACK_ELEMENT_SIZE; break; case 'R': b_result_offset-=8; break; case 'S': case 'A': - a_result_offset-=4; + a_result_offset-=STACK_ELEMENT_SIZE; } first_pointer_result_index=min_index+2; @@ -2538,7 +2648,7 @@ void code_ccall (char *c_function_name,char *s,int length) #endif if (!function_address_parameter){ -#if (defined (sparc) && !defined (SOLARIS)) || (defined (I486) && !defined (LINUX_ELF)) || (defined (G_POWER) && !defined (LINUX_ELF)) || defined (MACH_O) +#if (defined (sparc) && !defined (SOLARIS)) || (defined (I486) && !defined (LINUX_ELF) && !defined (G_AI64)) || (defined (G_POWER) && !defined (LINUX_ELF)) || defined (MACH_O) { char label_name [202]; @@ -2577,19 +2687,20 @@ void code_ccall (char *c_function_name,char *s,int length) # endif b_a_offset=b_o; -#ifdef ALIGN_C_CALLS +# ifdef ALIGN_C_CALLS i_move_r_r (B_STACK_POINTER,REGISTER_O0); i_or_i_r (28,B_STACK_POINTER); -#endif +# endif c_parameter_n=(b_offset+a_offset>>2)+n_clean_b_register_parameters-(function_address_parameter=='F'); for (l=first_pointer_result_index; l<length; ++l){ switch (s[l]){ case 'I': + case 'p': ccall_load_b_offset (b_o,c_parameter_n); ++c_parameter_n; - b_o+=4; + b_o+=STACK_ELEMENT_SIZE; break; case 'R': ccall_load_b_offset (b_o,c_parameter_n); @@ -2597,7 +2708,7 @@ void code_ccall (char *c_function_name,char *s,int length) b_o+=8; break; case 'S': - b_a_offset-=4; + b_a_offset-=STACK_ELEMENT_SIZE; ccall_load_b_offset (b_a_offset,c_parameter_n); ++c_parameter_n; break; @@ -2627,6 +2738,7 @@ void code_ccall (char *c_function_name,char *s,int length) for (l=0; l<min_index; ++l){ switch (s[l]){ case 'I': + case 'p': if (clean_b_register_parameter_n < n_clean_b_register_parameters){ int clean_b_reg_n; @@ -2644,7 +2756,7 @@ void code_ccall (char *c_function_name,char *s,int length) i_move_id_r (b_o,B_STACK_REGISTER,REGISTER_A3); i_move_r_id (REGISTER_A3,(FIRST_C_STACK_PARAMETER_WORD_OFFSET+c_parameter_n++)<<2,SP_REGISTER); } - b_o+=4; + b_o+=STACK_ELEMENT_SIZE; } break; # ifdef G_POWER @@ -2696,17 +2808,17 @@ void code_ccall (char *c_function_name,char *s,int length) b_o+=8; break; case 'S': - a_o-=4; + a_o-=STACK_ELEMENT_SIZE; ccall_load_string_or_array_offset (4,c_parameter_n,a_o); ++c_parameter_n; break; case 's': - a_o-=4; + a_o-=STACK_ELEMENT_SIZE; ccall_load_string_or_array_offset (8,c_parameter_n,a_o); ++c_parameter_n; break; case 'A': - a_o-=4; + a_o-=STACK_ELEMENT_SIZE; ccall_load_string_or_array_offset (12,c_parameter_n,a_o); ++c_parameter_n; break; @@ -2796,6 +2908,7 @@ void code_ccall (char *c_function_name,char *s,int length) for (l=first_pointer_result_index; l<length; ++l){ switch (s[l]){ case 'I': + case 'p': case 'R': break; case 'S': @@ -2805,7 +2918,7 @@ void code_ccall (char *c_function_name,char *s,int length) i_move_id_r (0,B_STACK_POINTER,REGISTER_A0); i_jsr_l_id (string_to_string_node_label,0); i_move_r_id (REGISTER_A0,0,A_STACK_POINTER); - i_add_i_r (4,A_STACK_POINTER); + i_add_i_r (STACK_ELEMENT_SIZE,A_STACK_POINTER); break; case 'V': break; @@ -2816,14 +2929,15 @@ void code_ccall (char *c_function_name,char *s,int length) switch (result){ case 'I': + case 'p': i_move_r_r (C_PARAMETER_REGISTER_0,REGISTER_D0); begin_new_basic_block(); init_b_stack (1,i_vector); break; case 'R': -#ifdef G_POWER +# ifdef G_POWER i_fmove_fr_fr (1-14,0); -#endif +# endif begin_new_basic_block(); init_b_stack (2,r_vector); break; @@ -2832,7 +2946,7 @@ void code_ccall (char *c_function_name,char *s,int length) string_to_string_node_label=enter_label ("string_to_string_node",IMPORT_LABEL); i_move_r_r (C_PARAMETER_REGISTER_0,REGISTER_A0); - i_sub_i_r (4,B_STACK_POINTER); + i_sub_i_r (STACK_ELEMENT_SIZE,B_STACK_POINTER); i_jsr_l_id (string_to_string_node_label,0); begin_new_basic_block(); @@ -2845,6 +2959,7 @@ void code_ccall (char *c_function_name,char *s,int length) error_s (ccall_error_string,c_function_name); } #elif defined (I486) +# ifndef G_AI64 { int c_offset_before_pushing_arguments,function_address_reg; @@ -2861,22 +2976,23 @@ void code_ccall (char *c_function_name,char *s,int length) for (l=length-1; l>=first_pointer_result_index; --l){ switch (s[l]){ case 'I': - b_o-=4; + case 'p': + b_o-=STACK_ELEMENT_SIZE; i_lea_id_r (b_o+c_offset,B_STACK_POINTER,REGISTER_A0); i_move_r_pd (REGISTER_A0,B_STACK_POINTER); - c_offset+=4; + c_offset+=STACK_ELEMENT_SIZE; break; case 'R': b_o-=8; i_lea_id_r (b_o+c_offset,B_STACK_POINTER,REGISTER_A0); i_move_r_pd (REGISTER_A0,B_STACK_POINTER); - c_offset+=4; + c_offset+=STACK_ELEMENT_SIZE; break; case 'S': i_lea_id_r (a_o+c_offset,B_STACK_POINTER,REGISTER_A0); i_move_r_pd (REGISTER_A0,B_STACK_POINTER); - a_o+=4; - c_offset+=4; + a_o+=STACK_ELEMENT_SIZE; + c_offset+=STACK_ELEMENT_SIZE; break; case 'V': break; @@ -2893,7 +3009,7 @@ void code_ccall (char *c_function_name,char *s,int length) reg_n=0; l=0; while (reg_n<n_clean_b_register_parameters && l<min_index){ - if (s[l]=='I' || s[l]=='F' || s[l]=='O'){ + if (s[l]=='I' || s[l]=='p' || s[l]=='F' || s[l]=='O'){ ++reg_n; last_register_parameter_index=l; } @@ -2906,14 +3022,15 @@ void code_ccall (char *c_function_name,char *s,int length) for (l=min_index-1; l>=0; --l){ switch (s[l]){ case 'I': + case 'p': if (l<=last_register_parameter_index){ i_move_r_pd (REGISTER_D0+n_extra_clean_b_register_parameters+reg_n,B_STACK_POINTER); ++reg_n; } else { - b_o-=4; + b_o-=STACK_ELEMENT_SIZE; i_move_id_pd (b_o+c_offset,B_STACK_POINTER,B_STACK_POINTER); } - c_offset+=4; + c_offset+=STACK_ELEMENT_SIZE; break; #ifdef I486 case 'r': @@ -2956,24 +3073,24 @@ void code_ccall (char *c_function_name,char *s,int length) break; case 'S': i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0); - i_add_i_r (4,REGISTER_A0); + i_add_i_r (STACK_ELEMENT_SIZE,REGISTER_A0); i_move_r_pd (REGISTER_A0,B_STACK_POINTER); - a_o+=4; - c_offset+=4; + a_o+=STACK_ELEMENT_SIZE; + c_offset+=STACK_ELEMENT_SIZE; break; case 's': i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0); i_add_i_r (8,REGISTER_A0); i_move_r_pd (REGISTER_A0,B_STACK_POINTER); - a_o+=4; - c_offset+=4; + a_o+=STACK_ELEMENT_SIZE; + c_offset+=STACK_ELEMENT_SIZE; break; case 'A': i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0); i_add_i_r (12,REGISTER_A0); i_move_r_pd (REGISTER_A0,B_STACK_POINTER); - a_o+=4; - c_offset+=4; + a_o+=STACK_ELEMENT_SIZE; + c_offset+=STACK_ELEMENT_SIZE; break; case 'F': case 'O': @@ -2990,7 +3107,7 @@ void code_ccall (char *c_function_name,char *s,int length) if (function_address_parameter=='O'){ i_move_r_pd (clean_b_reg_n,B_STACK_POINTER); - c_offset+=4; + c_offset+=STACK_ELEMENT_SIZE; } ++reg_n; @@ -3063,6 +3180,7 @@ void code_ccall (char *c_function_name,char *s,int length) for (l=length-1; l>=first_pointer_result_index; --l){ switch (s[l]){ case 'I': + case 'p': case 'R': break; case 'S': @@ -3071,7 +3189,7 @@ void code_ccall (char *c_function_name,char *s,int length) i_move_pi_r (B_STACK_POINTER,REGISTER_A0); i_jsr_l (string_to_string_node_label,0); i_move_r_id (REGISTER_A0,0,A_STACK_POINTER); - i_add_i_r (4,A_STACK_POINTER); + i_add_i_r (STACK_ELEMENT_SIZE,A_STACK_POINTER); break; case 'V': break; @@ -3082,6 +3200,7 @@ void code_ccall (char *c_function_name,char *s,int length) switch (result){ case 'I': + case 'p': begin_new_basic_block(); init_b_stack (1,i_vector); break; @@ -3105,6 +3224,305 @@ void code_ccall (char *c_function_name,char *s,int length) default: error_s (ccall_error_string,c_function_name); } +# else /* G_AI64 */ + { + int c_offset_before_pushing_arguments,function_address_reg,c_parameter_n; + + a_o=-b_result_offset-a_result_offset; + b_o=0; + + if (a_result_offset+b_result_offset>b_offset){ + i_sub_i_r (a_result_offset+b_result_offset-b_offset,B_STACK_POINTER); + c_offset=a_result_offset+b_result_offset; + } + + c_offset_before_pushing_arguments=c_offset; + + c_parameter_n=((a_offset+b_offset+a_result_offset+b_result_offset)>>3)+n_clean_b_register_parameters; + + i_move_r_r (B_STACK_POINTER,REGISTER_RBP); + if (c_parameter_n>=4 && (c_parameter_n & 1)!=0){ + i_sub_i_r (8,B_STACK_POINTER); + i_or_i_r (8,B_STACK_POINTER); + } else { + i_or_i_r (8,B_STACK_POINTER); + i_sub_i_r (8,B_STACK_POINTER); + } + + for (l=length-1; l>=first_pointer_result_index; --l){ + switch (s[l]){ + case 'I': + case 'p': + b_o-=STACK_ELEMENT_SIZE; + if (--c_parameter_n<4) + i_lea_id_r (b_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0-c_parameter_n); + else { + i_lea_id_r (b_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + c_offset+=STACK_ELEMENT_SIZE; + } + break; + case 'R': + b_o-=8; + if (--c_parameter_n<4) + i_lea_id_r (b_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0-c_parameter_n); + else { + i_lea_id_r (b_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + c_offset+=STACK_ELEMENT_SIZE; + } + break; + case 'S': + if (--c_parameter_n<4) + i_lea_id_r (a_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0-c_parameter_n); + else { + i_lea_id_r (a_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + c_offset+=STACK_ELEMENT_SIZE; + } + a_o+=STACK_ELEMENT_SIZE; + break; + case 'V': + break; + default: + error_s (ccall_error_string,c_function_name); + } + } + + { + int last_register_parameter_index,reg_n; + + last_register_parameter_index=-1; + + reg_n=0; + l=0; + while (reg_n<n_clean_b_register_parameters && l<min_index){ + if (s[l]=='I' || s[l]=='p' || s[l]=='F' || s[l]=='O'){ + ++reg_n; + last_register_parameter_index=l; + } + ++l; + } + + reg_n=0; + a_o=-a_offset; + b_o=0; + for (l=min_index-1; l>=0; --l){ + switch (s[l]){ + case 'I': + case 'p': + if (--c_parameter_n<4){ + if (l<=last_register_parameter_index){ + i_move_r_r (REGISTER_D0+n_extra_clean_b_register_parameters+reg_n,REGISTER_A0-c_parameter_n); + ++reg_n; + } else { + b_o-=STACK_ELEMENT_SIZE; + i_move_id_r (b_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0-c_parameter_n); + } + } else { + if (l<=last_register_parameter_index){ + i_move_r_pd (REGISTER_D0+n_extra_clean_b_register_parameters+reg_n,B_STACK_POINTER); + ++reg_n; + } else { + b_o-=STACK_ELEMENT_SIZE; + i_move_id_r (b_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + } + c_offset+=STACK_ELEMENT_SIZE; + } + break; + case 'R': + b_o-=8; + i_move_id_r (b_o+c_offset_before_pushing_arguments,REGISTER_RBP,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + c_offset+=8; + break; + case 'S': + if (--c_parameter_n<4){ + i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0-c_parameter_n); + i_add_i_r (STACK_ELEMENT_SIZE,REGISTER_A0-c_parameter_n); + } else { + i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0); + i_add_i_r (STACK_ELEMENT_SIZE,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + c_offset+=STACK_ELEMENT_SIZE; + } + a_o+=STACK_ELEMENT_SIZE; + break; + case 's': + if (--c_parameter_n<4){ + i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0-c_parameter_n); + i_add_i_r (2*STACK_ELEMENT_SIZE,REGISTER_A0-c_parameter_n); + } else { + i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0); + i_add_i_r (2*STACK_ELEMENT_SIZE,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + c_offset+=STACK_ELEMENT_SIZE; + } + a_o+=STACK_ELEMENT_SIZE; + break; + case 'A': + if (--c_parameter_n<4){ + i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0-c_parameter_n); + i_add_i_r (3*STACK_ELEMENT_SIZE,REGISTER_A0-c_parameter_n); + } else { + i_move_id_r (a_o,A_STACK_POINTER,REGISTER_A0); + i_add_i_r (3*STACK_ELEMENT_SIZE,REGISTER_A0); + i_move_r_pd (REGISTER_A0,B_STACK_POINTER); + c_offset+=STACK_ELEMENT_SIZE; + } + a_o+=STACK_ELEMENT_SIZE; + break; + case 'F': + case 'O': + case '*': + case ']': + /* while (l>=0 && !(s[l]=='F' || s[l]=='O')) bug in watcom c */ + while (l>=0 && (s[l]!='F' && s[l]!='O')) + --l; + + if (l<=last_register_parameter_index){ + int clean_b_reg_n,i; + + clean_b_reg_n=REGISTER_D0+n_extra_clean_b_register_parameters+reg_n; + + if (function_address_parameter=='O'){ + i_move_r_pd (clean_b_reg_n,B_STACK_POINTER); + c_offset+=STACK_ELEMENT_SIZE; + } + + ++reg_n; + + function_address_reg=clean_b_reg_n; + i=l; + while (i+1<length && (s[i+1]=='*' || s[i+1]=='[')){ + int n; + + ++i; + n=0; + + if (s[i]=='['){ + ++i; + while (i<length && (unsigned)(s[i]-'0')<(unsigned)10){ + n=n*10+(s[i]-'0'); + ++i; + } + } + + i_move_id_r (n,clean_b_reg_n,clean_b_reg_n); + } + break; + } + default: + error_s (ccall_error_string,c_function_name); + } + } + } + + if (save_state_in_global_variables){ + i_move_r_l (-4/*ESI*/,saved_a_stack_p_label); + i_move_r_l (-5/*EDI*/,saved_heap_p_label); + } + + i_sub_i_r (32,B_STACK_POINTER); + if (!function_address_parameter) + i_jsr_l (label,0); + else + i_jsr_r (function_address_reg); + + /* i_add_i_r (32,B_STACK_POINTER); */ + + if (c_offset_before_pushing_arguments-(b_result_offset+a_result_offset)==0) + i_move_r_r (REGISTER_RBP,B_STACK_POINTER); + else + i_lea_id_r (c_offset_before_pushing_arguments-(b_result_offset+a_result_offset),REGISTER_RBP,B_STACK_POINTER); + + if (save_state_in_global_variables){ + i_move_l_r (saved_a_stack_p_label,-4/*ESI*/); + i_move_l_r (saved_heap_p_label,-5/*EDI*/); + } + + if (callee_pops_arguments) + c_offset=c_offset_before_pushing_arguments; + + if (a_offset!=0) + i_sub_i_r (a_offset,A_STACK_POINTER); + /* + if (c_offset-(b_result_offset+a_result_offset)!=0) + i_add_i_r (c_offset-(b_result_offset+a_result_offset),B_STACK_POINTER); + */ + } + + for (l=length-1; l>=first_pointer_result_index; --l){ + switch (s[l]){ + case 'S': + if (string_to_string_node_label==NULL) + string_to_string_node_label=enter_label ("string_to_string_node",IMPORT_LABEL); + i_move_pi_r (B_STACK_POINTER,REGISTER_A0); + i_jsr_l (string_to_string_node_label,0); + i_move_r_id (REGISTER_A0,0,A_STACK_POINTER); + i_add_i_r (STACK_ELEMENT_SIZE,A_STACK_POINTER); + break; + case 'I': + case 'p': + case 'R': + case 'V': + break; + default: + error_s (ccall_error_string,c_function_name); + } + } + + b_o=0; + for (l=first_pointer_result_index; l<length; ++l){ + switch (s[l]){ + case 'I': + i_movesw_id_r (b_o,B_STACK_POINTER,REGISTER_RBP); + i_move_r_id (REGISTER_RBP,b_o,B_STACK_POINTER); + b_o+=STACK_ELEMENT_SIZE; + break; + case 'p': + b_o+=STACK_ELEMENT_SIZE; + break; + case 'R': + b_o+=8; + break; + case 'S': + case 'V': + break; + default: + error_s (ccall_error_string,c_function_name); + } + } + + switch (result){ + case 'I': + i_movesw_r_r (REGISTER_D0,REGISTER_D0); + case 'p': + begin_new_basic_block(); + init_b_stack (1,i_vector); + break; + case 'R': + begin_new_basic_block(); + init_b_stack (2,r_vector); + break; + case 'S': + if (string_to_string_node_label==NULL) + string_to_string_node_label=enter_label ("string_to_string_node",IMPORT_LABEL); + + i_move_r_r (REGISTER_D0,REGISTER_A0); + i_jsr_l (string_to_string_node_label,0); + + begin_new_basic_block(); + init_a_stack (1); + break; + case 'V': + begin_new_basic_block(); + break; + default: + error_s (ccall_error_string,c_function_name); + } +# endif #endif } diff --git a/cginstructions.h b/cginstructions.h index 88087f1..b86f12f 100644 --- a/cginstructions.h +++ b/cginstructions.h @@ -25,7 +25,7 @@ extern INSTRUCTION_GRAPH g_fload_x (INSTRUCTION_GRAPH graph_1,int offset,int shi extern INSTRUCTION_GRAPH g_lea (LABEL *label); extern INSTRUCTION_GRAPH g_lea_i (LABEL *label,int offset); extern INSTRUCTION_GRAPH g_load (int offset,int stack); -extern INSTRUCTION_GRAPH g_load_i (LONG value); +extern INSTRUCTION_GRAPH g_load_i (CleanInt value); extern INSTRUCTION_GRAPH g_load_id (int offset,INSTRUCTION_GRAPH graph_1); extern INSTRUCTION_GRAPH g_load_b_x (INSTRUCTION_GRAPH graph_1,int offset,int sign_extend,INSTRUCTION_GRAPH graph_2); extern INSTRUCTION_GRAPH g_load_x (INSTRUCTION_GRAPH graph_1,int offset,int shift,INSTRUCTION_GRAPH graph_2); @@ -143,7 +143,7 @@ void i_add_i_r (LONG value,int register_1) instruction=i_new_instruction2 (IADD); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, parameter_data.i=register_1); @@ -176,7 +176,7 @@ static void i_addi_r_r (LONG value,int register_1,int register_2) parameter_data.i=register_2); S2 (instruction->instruction_parameters[2], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); } #endif @@ -191,7 +191,7 @@ void i_and_i_r (LONG value,int register_1) instruction=i_new_instruction2 (IAND); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, parameter_data.i=register_1); @@ -217,7 +217,7 @@ LONG *i_bmi_i (VOID) instruction->instruction_parameters[0].parameter_type=P_IMMEDIATE; - return &instruction->instruction_parameters[0].parameter_data.i; + return &instruction->instruction_parameters[0].parameter_data.imm; } #endif @@ -287,7 +287,7 @@ void i_btst_i_id (LONG i,int offset,int register_1) instruction=i_new_instruction2 (IBTST); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=i); + parameter_data.imm=i); instruction->instruction_parameters[1].parameter_type=P_INDIRECT; instruction->instruction_parameters[1].parameter_offset=offset; @@ -303,7 +303,7 @@ void i_btst_i_r (LONG i,int register_1) instruction=i_new_instruction2 (IBTST); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=i); + parameter_data.imm=i); S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, parameter_data.i=register_1); @@ -317,7 +317,7 @@ static void i_cmp_i_r (LONG value,int register_1) instruction=i_new_instruction2 (ICMP); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, parameter_data.i=register_1); @@ -908,7 +908,7 @@ static void i_lsli_r_r (LONG value,int register_1,int register_2) parameter_data.i=register_2); S2 (instruction->instruction_parameters[2], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); } #endif @@ -1043,6 +1043,35 @@ void i_movem_id_r (int offset,int register_1,int register_2) } #endif +#ifdef G_AI64 +void i_movesw_r_r (int register_1,int register_2) +{ + struct instruction *instruction; + + instruction=i_new_instruction2 (IMOVESW); + + S2 (instruction->instruction_parameters[0], parameter_type=P_REGISTER, + parameter_data.i=register_1); + + S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, + parameter_data.i=register_2); +} + +void i_movesw_id_r (int offset,int register_1,int register_2) +{ + struct instruction *instruction; + + instruction=i_new_instruction2 (IMOVESW); + + S3 (instruction->instruction_parameters[0], parameter_type=P_INDIRECT, + parameter_offset=offset, + parameter_data.i=register_1); + + S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, + parameter_data.i=register_2); +} +#endif + void i_movew_id_r (int offset,int register_1,int register_2) { register struct instruction *instruction; @@ -1057,14 +1086,18 @@ void i_movew_id_r (int offset,int register_1,int register_2) parameter_data.i=register_2); } +#ifdef G_A64 +static void i_move_i_id (__int64 i,int offset_1,int register_1) +#else static void i_move_i_id (LONG i,int offset_1,int register_1) +#endif { - register struct instruction *instruction; + struct instruction *instruction; instruction=i_new_instruction2 (IMOVE); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=i); + parameter_data.imm=i); instruction->instruction_parameters[1].parameter_type=P_INDIRECT; instruction->instruction_parameters[1].parameter_offset=offset_1; @@ -1079,38 +1112,42 @@ static void i_move_i_pi (LONG i,int register_1) instruction=i_new_instruction2 (IMOVE); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=i); + parameter_data.imm=i); instruction->instruction_parameters[1].parameter_type=P_POST_INCREMENT; instruction->instruction_parameters[1].parameter_data.i=register_1; } #endif -void i_move_i_r (LONG i,int register_1) +void i_move_i_r (CleanInt i,int register_1) { - register struct instruction *instruction; + struct instruction *instruction; instruction=i_new_instruction2 (IMOVE); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=i); + parameter_data.imm=i); S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, parameter_data.i=register_1); } #if defined (M68000) || defined (I486) +# ifdef G_A64 +static void i_move_i_x (__int64 i,int offset,int register_1,int register_2) +# else static void i_move_i_x (LONG i,int offset,int register_1,int register_2) +# endif { - register struct instruction *instruction; - register struct index_registers *index_registers; + struct instruction *instruction; + struct index_registers *index_registers; instruction=i_new_instruction (IMOVE,2,2*sizeof (struct parameter)+sizeof (struct index_registers)); index_registers=(struct index_registers *)&instruction->instruction_parameters[2]; S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=i); + parameter_data.imm=i); instruction->instruction_parameters[1].parameter_type=P_INDEXED; instruction->instruction_parameters[1].parameter_offset=offset; @@ -1627,7 +1664,7 @@ void i_mulud_r_r (int register_1,int register_2) } #endif -#ifdef G_POWER +#if defined (G_POWER) || defined (G_AI64) void i_or_i_r (LONG value,int register_1) { struct instruction *instruction; @@ -1635,12 +1672,14 @@ void i_or_i_r (LONG value,int register_1) instruction=i_new_instruction2 (IOR); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, parameter_data.i=register_1); } +#endif +#ifdef G_POWER void i_mtctr (int register_1) { struct instruction *instruction; @@ -1666,7 +1705,7 @@ void i_mtctr (int register_1) instruction=i_new_instruction (IRTSI,1,1*sizeof (struct parameter)); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=offset); + parameter_data.imm=offset); } void i_rts_profile (void) @@ -1686,7 +1725,7 @@ void i_mtctr (int register_1) instruction->instruction_parameters[0].parameter_data.i=B_STACK_POINTER; instruction->instruction_parameters[1].parameter_type=P_IMMEDIATE; - instruction->instruction_parameters[1].parameter_data.i=offset_2; + instruction->instruction_parameters[1].parameter_data.imm=offset_2; } #endif @@ -1707,7 +1746,7 @@ void i_mtctr (int register_1) instruction->instruction_parameters[0].parameter_data.i=B_STACK_POINTER; instruction->instruction_parameters[1].parameter_type=P_IMMEDIATE; - instruction->instruction_parameters[1].parameter_data.i=offset_2; + instruction->instruction_parameters[1].parameter_data.imm=offset_2; } void i_rts_r (int register1,int offset_1) @@ -1720,7 +1759,7 @@ void i_mtctr (int register_1) instruction->instruction_parameters[0].parameter_data.i=register1; instruction->instruction_parameters[1].parameter_type=P_IMMEDIATE; - instruction->instruction_parameters[1].parameter_data.i=offset_1; + instruction->instruction_parameters[1].parameter_data.imm=offset_1; } void i_rts_r_profile (int register1,int offset_1) @@ -1733,7 +1772,7 @@ void i_mtctr (int register_1) instruction->instruction_parameters[0].parameter_data.i=register1; instruction->instruction_parameters[1].parameter_type=P_IMMEDIATE; - instruction->instruction_parameters[1].parameter_data.i=offset_1; + instruction->instruction_parameters[1].parameter_data.imm=offset_1; } #endif @@ -1744,7 +1783,7 @@ void i_schedule_i (int value) instruction=i_new_instruction1 (ISCHEDULE); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); } void i_sub_i_r (LONG value,int register_1) @@ -1755,7 +1794,7 @@ void i_sub_i_r (LONG value,int register_1) instruction=i_new_instruction2 (ISUB); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); S2 (instruction->instruction_parameters[1], parameter_type=P_REGISTER, parameter_data.i=register_1); @@ -1790,7 +1829,7 @@ void i_word_i (int value) instruction=i_new_instruction1 (IWORD); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); } #define N_VECTOR_BITS 32 @@ -1975,7 +2014,7 @@ void free_all_dregisters (VOID) { free_dregisters.r_s_first_free=d_reg_num (REGISTER_D0); free_dregisters.r_s_highest=8; -#ifdef I486 +#if defined (I486) && !defined (G_AI64) free_dregisters.r_s_list.r_l_vector= (1<<d_reg_num (REGISTER_D0)) | (1<<d_reg_num (REGISTER_D1)); #else @@ -2072,7 +2111,10 @@ typedef struct address { WORD ad_dreg; } s; } u; - LONG ad_offset; + union { + CleanInt ad_offset; + INSTRUCTION_GRAPH ad_load_x_graph; + } u2; } s; DOUBLE ad_real; } u; @@ -2086,7 +2128,8 @@ typedef struct address { #define ad_label u.s.u.ad_label #define ad_areg u.s.u.s.ad_areg #define ad_dreg u.s.u.s.ad_dreg -#define ad_offset u.s.ad_offset +#define ad_offset u.s.u2.ad_offset +#define ad_load_x_graph u.s.u2.ad_load_x_graph #define ad_real u.ad_real static void ad_to_parameter (ADDRESS *ad_p,struct parameter *parameter_p) @@ -2100,7 +2143,7 @@ static void ad_to_parameter (ADDRESS *ad_p,struct parameter *parameter_p) break; case P_IMMEDIATE: parameter_p->parameter_type=P_IMMEDIATE; - parameter_p->parameter_data.i=ad_p->ad_offset; + parameter_p->parameter_data.imm=ad_p->ad_offset; break; case P_INDIRECT: parameter_p->parameter_type=P_INDIRECT; @@ -2120,7 +2163,7 @@ static void ad_to_parameter (ADDRESS *ad_p,struct parameter *parameter_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -2200,7 +2243,7 @@ static int fad_to_parameter (ADDRESS *ad_p,struct parameter *parameter_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -2326,7 +2369,7 @@ static void instruction_i_ad (int instruction_code,LONG value,ADDRESS *ad_p) instruction=i_new_instruction2 (instruction_code); S2 (instruction->instruction_parameters[0], parameter_type=P_IMMEDIATE, - parameter_data.i=value); + parameter_data.imm=value); ad_to_parameter (ad_p,&instruction->instruction_parameters[1]); } @@ -2421,7 +2464,7 @@ static void instruction_ad_x (int instruction_code,ADDRESS *ad_p,int offset,int index_registers->d_reg.r=register_2; } -static void to_data_addressing_mode (register ADDRESS *ad_p) +static void to_data_addressing_mode (ADDRESS *ad_p) { if (ad_p->ad_mode==P_REGISTER && is_a_register (ad_p->ad_register)){ int dreg; @@ -2435,6 +2478,18 @@ static void to_data_addressing_mode (register ADDRESS *ad_p) ad_p->ad_count_p=&ad_p->ad_count; ad_p->ad_count=1; } +#ifdef G_A64 + else if (ad_p->ad_mode==P_IMMEDIATE && ((int)ad_p->ad_offset)!=ad_p->ad_offset){ + int dreg; + + dreg=get_dregister(); + i_move_i_r (ad_p->ad_offset,dreg); + ad_p->ad_mode=P_REGISTER; + ad_p->ad_register=dreg; + ad_p->ad_count_p=&ad_p->ad_count; + ad_p->ad_count=1; + } +#endif } static void in_register (register ADDRESS *ad_p) @@ -2463,7 +2518,7 @@ static void in_register (register ADDRESS *ad_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -2531,7 +2586,7 @@ static void in_data_register (register ADDRESS *ad_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -2613,7 +2668,7 @@ static void in_alterable_data_register (ADDRESS *ad_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -2713,7 +2768,7 @@ static void in_preferred_alterable_register (ADDRESS *ad_p,int preferred_reg) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -2813,7 +2868,7 @@ static void in_address_register (register ADDRESS *ad_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -2895,7 +2950,7 @@ static void in_alterable_address_register (register ADDRESS *ad_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -4169,7 +4224,29 @@ static ADDRESS *evaluate_arguments (union instruction_parameter arguments[],int } } } - +#ifdef G_A64 + if (a_graph_1->instruction_code==GFROMF){ + INSTRUCTION_GRAPH f_graph; + + f_graph=a_graph_1->instruction_parameters[0].p; + arguments[first_argument_number].p=f_graph; + + { + int f_graph_count; + + f_graph_count=f_graph->node_count; + if (--a_graph_1->node_count==0) + --f_graph_count; + f_graph->node_count=f_graph_count+1; + } + + linearize_float_graph (f_graph,&ad_a[first_argument_number]); + argument_evaluated[first_argument_number]=1; + + ad_a[first_argument_number].ad_mode+=100; + continue; + } +#else if (a_graph_1->instruction_code==GFHIGH && first_argument_number+1<n_arguments && !argument_evaluated[first_argument_number+1]) @@ -4209,7 +4286,7 @@ static ADDRESS *evaluate_arguments (union instruction_parameter arguments[],int continue; } } - +#endif linearize_graph (a_graph_1,&ad_a[first_argument_number]); argument_evaluated[first_argument_number]=1; } @@ -4324,7 +4401,9 @@ static void move_float_ad_id (ADDRESS *ad_p,int offset,int areg) } else { #endif i_move_id_id (ad_p->ad_offset,ad_p->ad_register,offset,areg); +#ifndef G_A64 i_move_id_id (ad_p->ad_offset+4,ad_p->ad_register,offset+4,areg); +#endif if (--*ad_p->ad_count_p==0) free_aregister (ad_p->ad_register); #ifdef M68000 @@ -4332,15 +4411,19 @@ static void move_float_ad_id (ADDRESS *ad_p,int offset,int areg) #endif return; case P_F_IMMEDIATE: +#ifdef G_A64 + i_move_i_id (((__int64*)&ad_p->ad_register)[0],offset,areg); +#else i_move_i_id (((LONG*)&ad_p->ad_register)[0],offset,areg); i_move_i_id (((LONG*)&ad_p->ad_register)[1],offset+4,areg); +#endif return; case P_INDEXED: { INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -4370,9 +4453,10 @@ static void move_float_ad_id (ADDRESS *ad_p,int offset,int areg) i_move_x_id (i_ad_p->ad_offset,i_ad_p->ad_areg,i_ad_p->ad_dreg,offset,areg); if (--*i_ad_p->ad_count_p==0) free_aregister (i_ad_p->ad_areg); -#if defined (M68000) || defined (I486) +#ifndef G_A64 +# if defined (M68000) || defined (I486) i_move_x_id (i_ad_p->ad_offset+(4<<2),i_ad_p->ad_areg,i_ad_p->ad_dreg,offset+4,areg); -#else +# else { int a_reg; @@ -4381,12 +4465,15 @@ static void move_float_ad_id (ADDRESS *ad_p,int offset,int areg) i_move_id_id (4,a_reg,offset+4,areg); free_aregister (a_reg); } +# endif #endif if (--*i_ad_p->ad_count_p2==0) free_dregister (i_ad_p->ad_dreg); } else { i_move_id_id (i_ad_p->ad_offset,i_ad_p->ad_register,offset,areg); +#ifndef G_A64 i_move_id_id (i_ad_p->ad_offset+4,i_ad_p->ad_register,offset+4,areg); +#endif if (--*i_ad_p->ad_count_p==0) free_aregister (i_ad_p->ad_register); } @@ -4446,8 +4533,11 @@ static void linearize_load_graph (register INSTRUCTION_GRAPH load_graph) internal_error_in_function ("linearize_load_graph"); } } - /* added 24-8-1999 */ +#ifdef G_A64 + else if (load_graph->instruction_code==GFROMF){ +#else else if (load_graph->instruction_code==GFHIGH || load_graph->instruction_code==GFLOW){ +#endif load_graph=load_graph->instruction_parameters[0].p; if (load_graph->node_count>0 && load_graph->instruction_code==GFLOAD){ int reg; @@ -4459,7 +4549,6 @@ static void linearize_load_graph (register INSTRUCTION_GRAPH load_graph) float_register_node (load_graph,reg); } } - /* */ } } @@ -4545,7 +4634,9 @@ static void linearize_create_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p,int # endif heap_offset+=8; #endif +#ifndef G_A64 ++argument_number; +#endif } else { #ifdef M68000 instruction_ad_pi (IMOVE,&ad_a[argument_number],HEAP_POINTER); @@ -4557,14 +4648,14 @@ static void linearize_create_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p,int instruction = (struct instruction*)ad_a[argument_number].ad_offset; instruction->instruction_parameters[1].parameter_data.i= - heap_pointer_offset_in_basic_block+heap_offset+4 + heap_pointer_offset_in_basic_block+heap_offset+STACK_ELEMENT_SIZE -instruction->instruction_parameters[1].parameter_data.i; } else - instruction_ad_id (IMOVE,&ad_a[argument_number],heap_offset+4,HEAP_POINTER); + instruction_ad_id (IMOVE,&ad_a[argument_number],heap_offset+STACK_ELEMENT_SIZE,HEAP_POINTER); # else instruction_ad_id (IMOVE,&ad_a[argument_number],heap_offset,HEAP_POINTER); # endif - heap_offset+=4; + heap_offset+=STACK_ELEMENT_SIZE; #endif } } else { @@ -4586,7 +4677,7 @@ static void linearize_create_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p,int reg_1=get_aregister(); # ifdef G_POWER - i_lea_id_r (offset_from_heap_register+4+NODE_POINTER_OFFSET,HEAP_POINTER,reg_1); + i_lea_id_r (offset_from_heap_register+STACK_ELEMENT_SIZE+NODE_POINTER_OFFSET,HEAP_POINTER,reg_1); # else if (offset_from_heap_register==0) i_move_r_r (HEAP_POINTER,reg_1); @@ -4598,14 +4689,14 @@ static void linearize_create_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p,int } # ifdef G_POWER - i_move_r_id (reg_1,heap_offset+4,HEAP_POINTER); + i_move_r_id (reg_1,heap_offset+STACK_ELEMENT_SIZE,HEAP_POINTER); # else i_move_r_id (reg_1,heap_offset,HEAP_POINTER); # endif - heap_offset+=4; + heap_offset+=STACK_ELEMENT_SIZE; #endif } else - heap_offset+=4; + heap_offset+=STACK_ELEMENT_SIZE; } } @@ -4620,7 +4711,7 @@ static void linearize_create_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p,int reg_1=get_aregister(); # ifdef G_POWER - i_lea_id_r (offset_from_heap_register+4+NODE_POINTER_OFFSET,HEAP_POINTER,reg_1); + i_lea_id_r (offset_from_heap_register+STACK_ELEMENT_SIZE+NODE_POINTER_OFFSET,HEAP_POINTER,reg_1); # else if (offset_from_heap_register==0) i_move_r_r (HEAP_POINTER,reg_1); @@ -4682,17 +4773,17 @@ linearize_store_create_operator (int offset,int stack_pointer,INSTRUCTION_GRAPH #ifdef G_POWER # if NODE_POINTER_OFFSET==0 if (arity>=1 && graph->instruction_parameters[0].p!=NULL && ad_a[0].ad_mode<100){ - i_move_ad_idu (&ad_a[0],offset_from_heap_register+4,HEAP_POINTER); - heap_pointer_offset_in_basic_block+=offset_from_heap_register+4; - offset_from_heap_register=-4; - heap_offset=4; + i_move_ad_idu (&ad_a[0],offset_from_heap_register+STACK_ELEMENT_SIZE,HEAP_POINTER); + heap_pointer_offset_in_basic_block+=offset_from_heap_register+STACK_ELEMENT_SIZE; + offset_from_heap_register=-STACK_ELEMENT_SIZE; + heap_offset=STACK_ELEMENT_SIZE; ++argument_number; } else { #endif - if (offset_from_heap_register!=-(4+NODE_POINTER_OFFSET)){ - i_add_i_r (offset_from_heap_register+(4+NODE_POINTER_OFFSET),HEAP_POINTER); - heap_pointer_offset_in_basic_block+=offset_from_heap_register+(4+NODE_POINTER_OFFSET); - offset_from_heap_register=-(4+NODE_POINTER_OFFSET); + if (offset_from_heap_register!=-(STACK_ELEMENT_SIZE+NODE_POINTER_OFFSET)){ + i_add_i_r (offset_from_heap_register+(STACK_ELEMENT_SIZE+NODE_POINTER_OFFSET),HEAP_POINTER); + heap_pointer_offset_in_basic_block+=offset_from_heap_register+(STACK_ELEMENT_SIZE+NODE_POINTER_OFFSET); + offset_from_heap_register=-(STACK_ELEMENT_SIZE+NODE_POINTER_OFFSET); } # if NODE_POINTER_OFFSET==0 } @@ -4735,7 +4826,9 @@ linearize_store_create_operator (int offset,int stack_pointer,INSTRUCTION_GRAPH move_float_ad_id (&ad_a[argument_number],heap_offset,HEAP_POINTER); heap_offset+=8; #endif +#ifndef G_A64 ++argument_number; +#endif } else { #ifdef M68000 instruction_ad_pi (IMOVE,&ad_a[argument_number],HEAP_POINTER); @@ -4752,16 +4845,16 @@ linearize_store_create_operator (int offset,int stack_pointer,INSTRUCTION_GRAPH } else # endif instruction_ad_id (IMOVE,&ad_a[argument_number],heap_offset,HEAP_POINTER); - heap_offset+=4; + heap_offset+=STACK_ELEMENT_SIZE; #endif } } else - heap_offset+=4; + heap_offset+=STACK_ELEMENT_SIZE; } #ifndef M68000 # ifdef G_POWER - offset_from_heap_register=heap_offset-4; + offset_from_heap_register=heap_offset-STACK_ELEMENT_SIZE; # else offset_from_heap_register=heap_offset; # endif @@ -4804,10 +4897,21 @@ static void linearize_fill_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) if (ad_a[1].ad_mode>=100){ ad_a[1].ad_mode-=100; move_float_ad_id (&ad_a[1],0-NODE_POINTER_OFFSET,reg_2); - } else { + } else +#ifdef G_A64 + instruction_ad_id (IMOVE,&ad_a[1],0-NODE_POINTER_OFFSET,reg_2); + + if (ad_a[2].ad_mode>=100){ + ad_a[2].ad_mode-=100; + move_float_ad_id (&ad_a[2],STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,reg_2); + } else + instruction_ad_id (IMOVE,&ad_a[2],STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,reg_2); +#else + { instruction_ad_id (IMOVE,&ad_a[1],0-NODE_POINTER_OFFSET,reg_2); - instruction_ad_id (IMOVE,&ad_a[2],4-NODE_POINTER_OFFSET,reg_2); + instruction_ad_id (IMOVE,&ad_a[2],STACK_ELEMENT_SIZE-NODE_POINTER_OFFSET,reg_2); } +#endif if (--*ad_a[0].ad_count_p==0 && graph->node_count==0) free_aregister (reg_2); } else { @@ -4858,7 +4962,9 @@ static void linearize_fill_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) move_float_ad_id (&ad_a[argument_number],offset,reg_1); offset+=8; #endif +#ifndef G_A64 ++argument_number; +#endif } else { #ifdef M68000 if (argument_number!=n_arguments-1) @@ -4867,14 +4973,14 @@ static void linearize_fill_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) instruction_ad_id (IMOVE,&ad_a[argument_number],0,reg_1); #else instruction_ad_id (IMOVE,&ad_a[argument_number],offset,reg_1); - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } } else #ifdef M68000 - i_add_i_r (4,reg_1); + i_add_i_r (STACK_ELEMENT_SIZE,reg_1); #else - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } @@ -4958,8 +5064,12 @@ static void move_float_ad_x (ADDRESS *ad_p,int offset,int areg,int dreg) # endif return; case P_F_IMMEDIATE: +#ifdef G_A64 + i_move_i_x (((__int64*)&ad_p->ad_register)[0],offset,areg,dreg); +#else i_move_i_x (((LONG*)&ad_p->ad_register)[0],offset,areg,dreg); i_move_i_x (((LONG*)&ad_p->ad_register)[1],offset+(4<<2),areg,dreg); +#endif return; #endif #ifdef M68000 @@ -5013,7 +5123,7 @@ static void linearize_fill_r_operator (register INSTRUCTION_GRAPH graph,register reg_2=ad_a[0].ad_register; instruction_ad_id (IMOVE,&ad_a[1],0,reg_2); - move_float_ad_id (&ad_a[2],4,reg_2); + move_float_ad_id (&ad_a[2],STACK_ELEMENT_SIZE,reg_2); if (graph->node_count==0) if (--*ad_a[0].ad_count_p==0) @@ -5098,7 +5208,9 @@ static void linearize_store_fill_operator (INSTRUCTION_GRAPH s_graph,INSTRUCTION move_float_ad_id (&ad_a[argument_number],offset,reg_1); offset+=8; #endif +#ifndef G_A64 ++argument_number; +#endif } else { #ifdef M68000 if (argument_number!=n_arguments-1) @@ -5107,14 +5219,14 @@ static void linearize_store_fill_operator (INSTRUCTION_GRAPH s_graph,INSTRUCTION instruction_ad_id (IMOVE,&ad_a[argument_number],0,reg_1); #else instruction_ad_id (IMOVE,&ad_a[argument_number],offset,reg_1); - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } } else #ifdef M68000 - i_add_i_r (4,reg_1); + i_add_i_r (STACK_ELEMENT_SIZE,reg_1); #else - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } @@ -5150,7 +5262,7 @@ static int movem_registers (int a_reg,register int n_registers,int registers[],i for (i=0; i<n_registers; ++i){ i_move_id_r (offset,a_reg,registers[i]); - offset+=4; + offset+=STACK_ELEMENT_SIZE; } return offset; #endif @@ -5187,7 +5299,7 @@ static void linearize_movem_operator (INSTRUCTION_GRAPH graph) address_register_used=0; n_registers=0; } - offset+=4; + offset+=STACK_ELEMENT_SIZE; } else { if (a_graph->instruction_code==GFMOVEMI){ int l_f_reg; @@ -5237,7 +5349,7 @@ static void linearize_movem_operator (INSTRUCTION_GRAPH graph) i_move_pi_r (a_reg,reg_n); #else i_move_id_r (offset,a_reg,reg_n); - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } else i_move_id_r (offset,a_reg,reg_n); @@ -5261,7 +5373,7 @@ static void linearize_movem_operator (INSTRUCTION_GRAPH graph) i_move_pi_r (a_reg,reg_n); #else i_move_id_r (offset,a_reg,reg_n); - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } else i_move_id_r (offset,a_reg,reg_n); @@ -5289,7 +5401,7 @@ static void linearize_movem_operator (INSTRUCTION_GRAPH graph) i_move_pi_r (a_reg,l_d_reg); #else i_move_id_r (offset,a_reg,l_d_reg); - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } else i_move_id_r (offset,a_reg,l_d_reg); @@ -5320,7 +5432,7 @@ static void linearize_movem_operator (INSTRUCTION_GRAPH graph) i_move_pi_r (a_reg,l_a_reg); #else i_move_id_r (offset,a_reg,l_a_reg); - offset+=4; + offset+=STACK_ELEMENT_SIZE; #endif } else i_move_id_r (offset,a_reg,l_a_reg); @@ -5381,8 +5493,8 @@ static void linearize_copy_operator (register INSTRUCTION_GRAPH graph,register A i_move_pi_id (areg_1,8,areg_2); #else i_move_id_id (0,areg_1,0,areg_2); - i_move_id_id (4,areg_1,4,areg_2); - i_move_id_id (8,areg_1,8,areg_2); + i_move_id_id (STACK_ELEMENT_SIZE,areg_1,STACK_ELEMENT_SIZE,areg_2); + i_move_id_id (2*STACK_ELEMENT_SIZE,areg_1,2*STACK_ELEMENT_SIZE,areg_2); #endif if (--*ad.ad_count_p==0) @@ -5425,7 +5537,7 @@ static void in_alterable_float_register (ADDRESS *ad_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -5491,7 +5603,7 @@ static void in_float_register (ADDRESS *ad_p) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -5583,7 +5695,7 @@ static void instruction_ad_fr (int instruction_code,ADDRESS *ad_p,int register_1 INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (load_x_graph->inode_arity & LOAD_X_TO_ADDRESS){ @@ -5654,7 +5766,169 @@ static void instruction_lad_fr (int instruction_code,ADDRESS *ad_p,int f_registe set_float_register_parameter (instruction->instruction_parameters[1],f_register_1); } -static void linearize_fhigh_operator (register INSTRUCTION_GRAPH graph,register ADDRESS *ad_p) +#ifdef G_A64 +static void linearize_fromf_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) +{ + linearize_float_graph (graph->instruction_parameters[0].p,ad_p); + + switch (ad_p->ad_mode){ + case P_INDIRECT: + if (graph->node_count>1){ + int reg; + + if (graph->instruction_d_min_a_cost<=0) + reg=get_dregister(); + else + reg=get_aregister(); + i_move_id_r (ad_p->ad_offset,ad_p->ad_register,reg); + if (--*ad_p->ad_count_p==0) + free_aregister (ad_p->ad_register); + + ad_p->ad_mode=P_REGISTER; + ad_p->ad_register=reg; + ad_p->ad_count_p=&graph->node_count; + + graph->instruction_code=P_REGISTER; + graph->instruction_parameters[0].i=reg; + } + return; + case P_F_REGISTER: + local_data_offset-=FLOAT_SIZE; + + i_fmove_fr_id (ad_p->ad_register,local_data_offset,B_STACK_POINTER); + if (--*ad_p->ad_count_p==0){ + free_fregister (ad_p->ad_register); + } + + if (graph->node_count>1){ + int reg; + + if (graph->instruction_d_min_a_cost<=0) + reg=get_dregister(); + else + reg=get_aregister(); + i_move_id_r (local_data_offset,B_STACK_POINTER,reg); + + ad_p->ad_mode=P_REGISTER; + ad_p->ad_register=reg; + ad_p->ad_count_p=&graph->node_count; + + register_node (graph,reg); + } else { + ad_p->ad_mode=P_INDIRECT; + ad_p->ad_offset=local_data_offset; + ad_p->ad_register=B_STACK_POINTER; + ad_p->ad_count_p=&ad_p->ad_count; + ad_p->ad_count=graph->node_count+1; + } + return; + case P_F_IMMEDIATE: + { + DOUBLE r; + + r=ad_p->ad_real; + + if (graph->node_count>1){ + int reg; + + if (graph->instruction_d_min_a_cost<=0) + reg=get_dregister(); + else + reg=get_aregister(); + + i_move_i_r (((__int64*)&r)[0],reg); + ad_p->ad_mode=P_REGISTER; + ad_p->ad_register=reg; + ad_p->ad_count_p=&graph->node_count; + + register_node (graph,reg); + } else { + ad_p->ad_mode=P_IMMEDIATE; + ad_p->ad_offset=((LONG*)&r)[0]; + } + return; + } + case P_INDEXED: + { + INSTRUCTION_GRAPH load_x_graph; + ADDRESS *i_ad_p; + + load_x_graph=ad_p->ad_load_x_graph; + i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; + + if (graph->node_count>1){ + int reg; + + if (load_x_graph->inode_arity==1){ + load_x_graph->inode_arity=2; + + if (i_ad_p->ad_mode==P_INDEXED){ + if (--*i_ad_p->ad_count_p==0) + free_aregister (i_ad_p->ad_areg); + if (--*i_ad_p->ad_count_p2==0) + free_dregister (i_ad_p->ad_dreg); + if (graph->instruction_d_min_a_cost<=0) + reg=get_dregister(); + else + reg=get_aregister(); + i_move_x_r (i_ad_p->ad_offset,i_ad_p->ad_areg,i_ad_p->ad_dreg,reg); + } else { + if (--*i_ad_p->ad_count_p==0) + free_aregister (i_ad_p->ad_register); + if (graph->instruction_d_min_a_cost<=0) + reg=get_dregister(); + else + reg=get_aregister(); + i_move_id_r (i_ad_p->ad_offset,i_ad_p->ad_register,reg); + } + i_ad_p->ad_register=reg; + } else { + int reg; + + local_data_offset-=FLOAT_SIZE; + + i_fmove_fr_id (i_ad_p->ad_register,local_data_offset,B_STACK_POINTER); + free_fregister (i_ad_p->ad_register); + + if (graph->instruction_d_min_a_cost<=0) + reg=get_dregister(); + else + reg=get_aregister(); + i_move_id_r (local_data_offset,B_STACK_POINTER,reg); + } + + ad_p->ad_mode=P_REGISTER; + ad_p->ad_register=reg; + ad_p->ad_count_p=&graph->node_count; + + graph->instruction_code=P_REGISTER; + graph->instruction_parameters[0].i=reg; + + register_node (graph,reg); + } else { + if (load_x_graph->inode_arity==1){ + } else { + local_data_offset-=FLOAT_SIZE; + + i_fmove_fr_id (i_ad_p->ad_register,local_data_offset,B_STACK_POINTER); + free_fregister (i_ad_p->ad_register); + + ad_p->ad_mode=P_INDIRECT; + ad_p->ad_offset=local_data_offset; + ad_p->ad_register=B_STACK_POINTER; + ad_p->ad_count_p=&ad_p->ad_count; + ad_p->ad_count=graph->node_count+1; + } + } + return; + } + + default: + internal_error_in_function ("linearize_fromf_operator"); + } +} +#else +static void linearize_fhigh_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) { linearize_float_graph (graph->instruction_parameters[0].p,ad_p); @@ -5756,7 +6030,7 @@ static void linearize_fhigh_operator (register INSTRUCTION_GRAPH graph,register INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (graph->node_count>1){ @@ -5837,7 +6111,7 @@ static void linearize_fhigh_operator (register INSTRUCTION_GRAPH graph,register } } -static void linearize_flow_operator (register INSTRUCTION_GRAPH graph,register ADDRESS *ad_p) +static void linearize_flow_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) { linearize_float_graph (graph->instruction_parameters[0].p,ad_p); @@ -5939,7 +6213,7 @@ static void linearize_flow_operator (register INSTRUCTION_GRAPH graph,register A INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_p->ad_offset; + load_x_graph=ad_p->ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; if (graph->node_count>1){ @@ -6005,7 +6279,39 @@ static void linearize_flow_operator (register INSTRUCTION_GRAPH graph,register A internal_error_in_function ("linearize_flow_operator"); } } +#endif + +#ifdef G_A64 +static void linearize_tof_operator (INSTRUCTION_GRAPH graph,register ADDRESS *ad_p) +{ + ADDRESS ad_1; + + linearize_graph (graph->instruction_parameters[0].p,&ad_1); + + local_data_offset-=FLOAT_SIZE; + instruction_ad_id (IMOVE,&ad_1,local_data_offset,B_STACK_POINTER); + + if (graph->node_count>1){ + int freg; + + freg=get_fregister(); + i_fmove_id_fr (local_data_offset,B_STACK_POINTER,freg); + + ad_p->ad_mode=P_F_REGISTER; + ad_p->ad_register=freg; + ad_p->ad_count_p=&graph->node_count; + + float_register_node (graph,freg); + } else { + ad_p->ad_mode=P_INDIRECT; + ad_p->ad_offset=local_data_offset; + ad_p->ad_register=B_STACK_POINTER; + ad_p->ad_count_p=&ad_p->ad_count; + ad_p->ad_count=1+1; + } +} +#else static void linearize_fjoin_operator (INSTRUCTION_GRAPH graph,register ADDRESS *ad_p) { INSTRUCTION_GRAPH high_graph,low_graph; @@ -6014,15 +6320,10 @@ static void linearize_fjoin_operator (INSTRUCTION_GRAPH graph,register ADDRESS * high_graph=graph->instruction_parameters[0].p; low_graph=graph->instruction_parameters[1].p; -#ifdef g_fhighlow linearize_graph (low_graph,&ad_2); linearize_graph (high_graph,&ad_1); -#else - linearize_graph (high_graph,&ad_1); - linearize_graph (low_graph,&ad_2); -#endif -#ifdef sparc +# ifdef sparc if (ad_1.ad_mode==P_INDIRECT && ad_2.ad_mode==P_INDIRECT){ int freg; @@ -6039,17 +6340,12 @@ static void linearize_fjoin_operator (INSTRUCTION_GRAPH graph,register ADDRESS * return; } -#endif +# endif local_data_offset-=FLOAT_SIZE; -#ifdef g_fhighlow instruction_ad_id (IMOVE,&ad_2,local_data_offset+4,B_STACK_POINTER); instruction_ad_id (IMOVE,&ad_1,local_data_offset,B_STACK_POINTER); -#else - instruction_ad_id (IMOVE,&ad_1,local_data_offset,B_STACK_POINTER); - instruction_ad_id (IMOVE,&ad_2,local_data_offset+4,B_STACK_POINTER); -#endif if (graph->node_count>1){ int freg; @@ -6070,6 +6366,7 @@ static void linearize_fjoin_operator (INSTRUCTION_GRAPH graph,register ADDRESS * ad_p->ad_count=1+1; } } +#endif static int float_compare_node (INSTRUCTION_GRAPH graph,int i_test_1,int i_test_2) { @@ -6178,7 +6475,7 @@ static void linearize_dyadic_non_commutative_float_operator (int instruction_cod } #if 1 -# if defined (I486) || defined (G_POWER) +# if (defined (I486) && !defined (G_AI64)) || defined (G_POWER) /* added 15-12-1998 */ if (ad_1.ad_mode==P_F_REGISTER && *ad_1.ad_count_p==1 && !(ad_2.ad_mode==P_F_REGISTER && ad_2.ad_register<ad_1.ad_register && *ad_2.ad_count_p==1) @@ -6342,7 +6639,7 @@ static void linearize_fload_x_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) ADDRESS *i_ad_p; ad_p->ad_mode=P_INDEXED; - ad_p->ad_offset=(LONG)graph; + ad_p->ad_load_x_graph=graph; i_ad_p=(ADDRESS*)fast_memory_allocate (sizeof (ADDRESS)); graph->instruction_parameters[1].p=(INSTRUCTION_GRAPH)i_ad_p; @@ -6391,7 +6688,7 @@ static void linearize_fload_x_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) ADDRESS *i_ad_p; ad_p->ad_mode=P_INDEXED; - ad_p->ad_offset=(LONG)graph; + ad_p->ad_load_x_graph=graph; i_ad_p=(ADDRESS*)fast_memory_allocate (sizeof (ADDRESS)); graph->instruction_parameters[1].p=(INSTRUCTION_GRAPH)i_ad_p; @@ -6532,9 +6829,11 @@ static void linearize_float_graph (register INSTRUCTION_GRAPH graph,register ADD case GFSUB: linearize_dyadic_non_commutative_float_operator (IFSUB,graph,ad_p); return; +#ifndef G_A64 case GFJOIN: linearize_fjoin_operator (graph,ad_p); return; +#endif case GFITOR: linearize_itor_operator (graph,ad_p); return; @@ -6576,23 +6875,26 @@ static void linearize_float_graph (register INSTRUCTION_GRAPH graph,register ADD case GFKEEP: linearize_float_keep_operator (graph,ad_p); break; -/* added 10-12-97 */ case GINDIRECTION: linearize_float_graph (graph->instruction_parameters[0].p,ad_p); break; -/* */ #if !defined (G_POWER) case GFSQRT: linearize_monadic_float_operator (graph,ad_p,IFSQRT); break; #endif +#ifdef G_A64 + case GTOF: + linearize_tof_operator (graph,ad_p); + return; +#endif default: /* printf ("%d %d\n",(int)graph,graph->instruction_code); */ internal_error_in_function ("linearize_float_graph"); } } -static void linearize_fstore_operator (register INSTRUCTION_GRAPH graph) +static void linearize_fstore_operator (INSTRUCTION_GRAPH graph) { int offset,stack_pointer; ADDRESS ad_1; @@ -6603,7 +6905,9 @@ static void linearize_fstore_operator (register INSTRUCTION_GRAPH graph) stack_pointer=graph->instruction_parameters[1].i; linearize_load_graph (graph->instruction_parameters[3].p); +#ifndef G_A64 linearize_load_graph (graph->instruction_parameters[4].p); +#endif move_float_ad_id (&ad_1,offset,stack_pointer); } @@ -6642,7 +6946,7 @@ static void linearize_fstore_r_operator (register INSTRUCTION_GRAPH graph) register_graph_2_p=NULL; if (register_graph_1_p!=NULL && *register_graph_1_p!=NULL && (*register_graph_1_p)->node_count>0){ -#ifdef FP_STACK_OPTIMIZATIONS +#if defined (FP_STACK_OPTIMIZATIONS) && !defined (G_AI64) if (register_graph_2_p!=NULL && (*register_graph_2_p==NULL || (*register_graph_2_p)->instruction_code!=GGFREGISTER)){ INSTRUCTION_GRAPH graph; @@ -6677,7 +6981,7 @@ static void linearize_fstore_r_operator (register INSTRUCTION_GRAPH graph) *register_graph_2_p=*register_graph_1_p; *register_graph_1_p=NULL; -#ifdef FP_STACK_OPTIMIZATIONS +#if defined (FP_STACK_OPTIMIZATIONS) && !defined (G_AI64) } #endif } else { @@ -6726,7 +7030,11 @@ static void linearize_create_r_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p,i ADDRESS ad_1,ad_2; int reg_1; +#ifdef G_A64 + last_block->block_n_new_heap_cells+=2; +#else last_block->block_n_new_heap_cells+=3; +#endif #ifndef M68000 # ifdef I486 @@ -6773,12 +7081,16 @@ static void linearize_create_r_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p,i #else # ifdef G_POWER instruction_ad_id (IMOVE,&ad_1,offset_from_heap_register+4,HEAP_POINTER); - move_float_ad_id (&ad_2,offset_from_heap_register+8,HEAP_POINTER); + move_float_ad_id (&ad_2,offset_from_heap_register+4+STACK_ELEMENT_SIZE,HEAP_POINTER); # else instruction_ad_id (IMOVE,&ad_1,offset_from_heap_register,HEAP_POINTER); - move_float_ad_id (&ad_2,offset_from_heap_register+4,HEAP_POINTER); + move_float_ad_id (&ad_2,offset_from_heap_register+STACK_ELEMENT_SIZE,HEAP_POINTER); # endif +# ifdef G_A64 + offset_from_heap_register+=16; +# else offset_from_heap_register+=12; +# endif #endif ad_p->ad_mode=P_REGISTER; @@ -6860,7 +7172,7 @@ static void linearize_load_x_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p ADDRESS *i_ad_p; ad_p->ad_mode=P_INDEXED; - ad_p->ad_offset=(LONG)graph; + ad_p->ad_load_x_graph=graph; i_ad_p=(ADDRESS*)fast_memory_allocate (sizeof (ADDRESS)); graph->instruction_parameters[1].p=(INSTRUCTION_GRAPH)i_ad_p; @@ -6917,7 +7229,7 @@ static void linearize_load_x_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p ADDRESS *i_ad_p; ad_p->ad_mode=P_INDEXED; - ad_p->ad_offset=(LONG)graph; + ad_p->ad_load_x_graph=graph; i_ad_p=(ADDRESS*)fast_memory_allocate (sizeof (ADDRESS)); graph->instruction_parameters[1].p=(INSTRUCTION_GRAPH)i_ad_p; @@ -7079,7 +7391,7 @@ static void linearize_store_r_node (INSTRUCTION_GRAPH graph) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_1.ad_offset; + load_x_graph=ad_1.ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; #ifdef M68000 if ((load_x_graph->inode_arity & LOAD_X_TO_ADDRESS) && i_ad_p->ad_mode==P_INDEXED) @@ -7128,7 +7440,7 @@ static void linearize_store_r_node (INSTRUCTION_GRAPH graph) INSTRUCTION_GRAPH load_x_graph; ADDRESS *i_ad_p; - load_x_graph=(INSTRUCTION_GRAPH)ad_1.ad_offset; + load_x_graph=ad_1.ad_load_x_graph; i_ad_p=(ADDRESS *)load_x_graph->instruction_parameters[1].p; #ifdef M68000 if ((load_x_graph->inode_arity & LOAD_X_TO_ADDRESS) && i_ad_p->ad_mode==P_INDEXED) @@ -7415,8 +7727,10 @@ static void do_array_selects_before_update (INSTRUCTION_GRAPH select_graph,INSTR break; case GREGISTER: case GFREGISTER: +#ifndef G_A64 case GFHIGH: case GFLOW: +#endif case GGREGISTER: break; default: @@ -7563,7 +7877,7 @@ static void linearize_bounds_operator (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) else in_data_register (ad_p); - i_cmp_id_r (4,ad_1.ad_register,ad_p->ad_register); + i_cmp_id_r (STACK_ELEMENT_SIZE,ad_1.ad_register,ad_p->ad_register); instruction_l (IBHS,index_error_label); if (--*ad_1.ad_count_p==0) @@ -7644,15 +7958,15 @@ static void linearize_graph (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) case GLOAD_I: if (graph->node_count<=1){ ad_p->ad_mode=P_IMMEDIATE; - ad_p->ad_offset=graph->instruction_parameters[0].i; + ad_p->ad_offset=graph->instruction_parameters[0].imm; } else { - register int reg_1; + int reg_1; if (graph->instruction_d_min_a_cost<=0) reg_1=get_dregister(); else reg_1=get_aregister(); - i_move_i_r (graph->instruction_parameters[0].i,reg_1); + i_move_i_r (graph->instruction_parameters[0].imm,reg_1); ad_p->ad_mode=P_REGISTER; ad_p->ad_register=reg_1; @@ -8098,12 +8412,14 @@ static void linearize_graph (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) case GCOPY: linearize_copy_operator (graph,ad_p); return; +#ifndef G_A64 case GFHIGH: linearize_fhigh_operator (graph,ad_p); return; case GFLOW: linearize_flow_operator (graph,ad_p); return; +#endif case GFCMP_EQ: linearize_float_compare_operator (CFEQ,CFEQ,graph,ad_p); return; @@ -8113,6 +8429,11 @@ static void linearize_graph (INSTRUCTION_GRAPH graph,ADDRESS *ad_p) case GFCMP_GT: linearize_float_compare_operator (CFGT,CFLT,graph,ad_p); return; +#ifdef G_A64 + case GFROMF: + linearize_fromf_operator (graph,ad_p); + return; +#endif case GFRTOI: linearize_rtoi_operator (graph,ad_p); return; @@ -56,10 +56,12 @@ void i_beq_l (LABEL *label); extern LONG *i_bmi_i (VOID); void i_bmi_l (LABEL *label); #endif +#if defined (G_POWER) || defined (G_AI64) + void i_or_i_r (LONG value,int register_1); +#endif #ifdef G_POWER void i_and_i_r (LONG value,int register_1); void i_bnep_l (LABEL *label); - void i_or_i_r (LONG value,int register_1); void i_mtctr (int register_1); #endif #if defined (sparc) || defined (I486) || defined (G_POWER) @@ -87,7 +89,7 @@ void i_move_id_r (int offset,int register_1,int register_2); void i_movew_id_idu (int offset1,int register_1,int offset2,int register_2); void i_movew_r_idu (int register_1,int offset,int register_2); #endif -void i_move_i_r (LONG i,int register_1); +void i_move_i_r (CleanInt i,int register_1); void i_move_l_r (LABEL *label,int register_1); #ifdef M68000 void i_move_pi_id (int register_1,int offset_2,int register_2); @@ -14,7 +14,7 @@ #include "cgopt.h" -#ifdef I486 +#if defined (I486) && !defined (G_AI64) # define I486_USE_SCRATCH_REGISTER #endif @@ -819,7 +819,7 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off parameter0=&instruction->instruction_parameters[0]; parameter1=&instruction->instruction_parameters[1]; - if (parameter1->parameter_offset<b_offset && parameter1->parameter_offset!=b_offset-4){ + if (parameter1->parameter_offset<b_offset && parameter1->parameter_offset!=b_offset-STACK_ELEMENT_SIZE){ insert_decrement_b_stack_pointer (instruction,b_offset-parameter1->parameter_offset); b_offset=parameter1->parameter_offset; @@ -836,8 +836,8 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off if (parameter0->parameter_offset==b_offset && b_offset<((WORD)parameter0->parameter_data.reg.u)) { - if (b_offset+4<=((WORD)parameter0->parameter_data.reg.u)){ - b_offset+=4; + if (b_offset+STACK_ELEMENT_SIZE<=((WORD)parameter0->parameter_data.reg.u)){ + b_offset+=STACK_ELEMENT_SIZE; parameter0->parameter_type=P_POST_INCREMENT; } else parameter0->parameter_offset-=b_offset; @@ -846,8 +846,8 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off } if (parameter1->parameter_offset<b_offset){ - if (parameter1->parameter_offset==b_offset-4){ - b_offset-=4; + if (parameter1->parameter_offset==b_offset-STACK_ELEMENT_SIZE){ + b_offset-=STACK_ELEMENT_SIZE; parameter1->parameter_type=P_PRE_DECREMENT; continue; } else @@ -867,8 +867,8 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off if (parameter->parameter_offset==b_offset && b_offset<((WORD)parameter->parameter_data.reg.u)) { - if (b_offset+4<=((WORD)parameter->parameter_data.reg.u)){ - b_offset+=4; + if (b_offset+STACK_ELEMENT_SIZE<=((WORD)parameter->parameter_data.reg.u)){ + b_offset+=STACK_ELEMENT_SIZE; parameter->parameter_type=P_POST_INCREMENT; continue; } @@ -885,8 +885,8 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off parameter=&instruction->instruction_parameters[1]; if (parameter->parameter_offset<b_offset){ - if (parameter->parameter_offset==b_offset-4){ - b_offset-=4; + if (parameter->parameter_offset==b_offset-STACK_ELEMENT_SIZE){ + b_offset-=STACK_ELEMENT_SIZE; parameter->parameter_type=P_PRE_DECREMENT; continue; } else { @@ -941,7 +941,7 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off if (instruction->instruction_parameters[0].parameter_type==P_INDIRECT && instruction->instruction_parameters[0].parameter_data.reg.r==B_STACK_POINTER && instruction->instruction_parameters[0].parameter_offset==b_offset && - b_offset+4<=((WORD)instruction->instruction_parameters[0].parameter_data.reg.u) + b_offset+STACK_ELEMENT_SIZE<=((WORD)instruction->instruction_parameters[0].parameter_data.reg.u) ){ instruction->instruction_parameters[0].parameter_type=P_POST_INCREMENT; @@ -950,12 +950,12 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off ){ instruction->instruction_parameters[1].parameter_offset-=b_offset; } - b_offset+=4; + b_offset+=STACK_ELEMENT_SIZE; continue; } if (instruction->instruction_parameters[1].parameter_type==P_INDIRECT && instruction->instruction_parameters[1].parameter_data.reg.r==B_STACK_POINTER && - instruction->instruction_parameters[1].parameter_offset==b_offset-4 + instruction->instruction_parameters[1].parameter_offset==b_offset-STACK_ELEMENT_SIZE ){ instruction->instruction_parameters[1].parameter_type=P_PRE_DECREMENT; @@ -964,7 +964,7 @@ void optimize_stack_access (struct basic_block *block,int *a_offset_p,int *b_off ){ instruction->instruction_parameters[0].parameter_offset-=b_offset; } - b_offset-=4; + b_offset-=STACK_ELEMENT_SIZE; continue; } } @@ -1236,7 +1236,11 @@ struct register_allocation r_reg_alloc[N_REAL_REGISTERS]; struct register_allocation a_reg_alloc[8],d_reg_alloc[8]; #endif -#if defined (NEW_R_ALLOC) && (defined (sparc) || defined (G_POWER)) +#if defined (NEW_R_ALLOC) && (defined (sparc) || defined (G_POWER) || defined (G_AI64)) +# define F_REG_15 +#endif + +#ifdef F_REG_15 struct register_allocation f_reg_alloc[15]; #else struct register_allocation f_reg_alloc[8]; @@ -1594,6 +1598,9 @@ IF_G_POWER ( case IUMULH: ) case IFABS: IF_G_SPARC (case IFMOVEHI: case IFMOVELO:) IF_G_RISC (case IADDI: case ILSLI:) +#ifdef G_AI64 + case IMOVESW: +#endif define_parameter (&instruction->instruction_parameters[1]); use_parameter (&instruction->instruction_parameters[0]); break; @@ -1756,7 +1763,7 @@ static void initialize_register_allocation() } #endif -#if defined (NEW_R_ALLOC) && (defined (sparc) || defined (G_POWER)) +#ifdef F_REG_15 for (n=8; n<15; ++n){ f_reg_alloc[n].reg=-32768; f_reg_alloc[n].instruction_n=0; @@ -2015,7 +2022,7 @@ static int find_register (int reg_n,register struct register_allocation *reg_all real_reg_n=REAL_A1; i=reg_alloc[REAL_A1].instruction_n; } -#if !defined (I486) || defined (I486_USE_SCRATCH_REGISTER) +#if !(defined (I486) && !defined (G_AI64)) || defined (I486_USE_SCRATCH_REGISTER) if (reg_alloc[REAL_A2].instruction_n<i # if defined (I486_USE_SCRATCH_REGISTER) && allocate_scratch_register @@ -2069,12 +2076,12 @@ static int find_register (int reg_n,register struct register_allocation *reg_all real_reg_n=6; i=reg_alloc[6].instruction_n; } -# ifndef I486 +# if ! (defined (I486) && !defined (G_AI64)) if (reg_alloc[7].instruction_n<i){ real_reg_n=7; i=reg_alloc[7].instruction_n; } -# if defined (sparc) || defined (G_POWER) +# if defined (sparc) || defined (G_POWER) || defined (G_AI64) if (reg_alloc[8].instruction_n<i){ real_reg_n=8; i=reg_alloc[8].instruction_n; @@ -2240,7 +2247,7 @@ static int find_non_reg_2_register (int reg_n,int avoid_reg_n, real_reg_n=REAL_A1; i=reg_alloc[REAL_A1].instruction_n; } -#if !defined (I486) || defined (I486_USE_SCRATCH_REGISTER) +#if !(defined (I486) && !defined (G_AI64)) || defined (I486_USE_SCRATCH_REGISTER) if (reg_alloc[REAL_A2].instruction_n<i && avoid_reg_n!=REAL_A2 # if defined (I486_USE_SCRATCH_REGISTER) && allocate_scratch_register @@ -2295,12 +2302,12 @@ static int find_non_reg_2_register (int reg_n,int avoid_reg_n, real_reg_n=6; i=reg_alloc[6].instruction_n; } -# ifndef I486 +# if ! (defined (I486) && !defined (G_AI64)) if (reg_alloc[7].instruction_n<i && avoid_reg_n!=7){ real_reg_n=7; i=reg_alloc[7].instruction_n; } -# if defined (sparc) || defined (G_POWER) +# if defined (sparc) || defined (G_POWER) || defined (G_AI64) if (reg_alloc[8].instruction_n<i && avoid_reg_n!=8){ real_reg_n=8; i=reg_alloc[8].instruction_n; @@ -2470,7 +2477,7 @@ static int find_reg_not_in_set real_reg_n=REAL_A1; i=reg_alloc[REAL_A1].instruction_n; } -# if !defined (I486) || defined (I486_USE_SCRATCH_REGISTER) +# if !(defined (I486) && !defined (G_AI64)) || defined (I486_USE_SCRATCH_REGISTER) if (reg_alloc[REAL_A2].instruction_n<i && !(avoid_reg_set & (1<<REAL_A2)) # if defined (I486_USE_SCRATCH_REGISTER) && allocate_scratch_register @@ -2525,12 +2532,12 @@ static int find_reg_not_in_set real_reg_n=6; i=reg_alloc[6].instruction_n; } -# ifndef I486 +# if ! (defined (I486) && !defined (G_AI64)) if (reg_alloc[7].instruction_n<i && !(avoid_reg_set & 128)){ real_reg_n=7; i=reg_alloc[7].instruction_n; } -# if defined (sparc) || defined (G_POWER) +# if defined (sparc) || defined (G_POWER) || defined (G_AI64) if (reg_alloc[8].instruction_n<i && !(avoid_reg_set & 256)){ real_reg_n=8; i=reg_alloc[8].instruction_n; @@ -2620,9 +2627,11 @@ static int free_2_register ( int real_reg_n,struct register_use *reg_uses, #endif if (reg_alloc[real_reg_n].value_used){ if (reg_uses[old_reg_n].offset==0){ +#ifndef G_A64 if (register_flag!=F_REGISTER) local_data_offset-=4; else +#endif local_data_offset-=8; reg_uses[old_reg_n].offset=local_data_offset; @@ -3892,7 +3901,9 @@ IF_G_POWER (case ICMPLW:) case IFABS: IF_G_SPARC (case IFMOVEHI: case IFMOVELO:) IF_G_RISC (case IADDI: case ILSLI:) - +#ifdef G_AI64 + case IMOVESW: +#endif #if 1 if (instruction->instruction_parameters[1].parameter_type==P_REGISTER || instruction->instruction_parameters[1].parameter_type==P_F_REGISTER) @@ -4078,7 +4089,7 @@ int do_register_allocation struct register_use *r_reg_uses_block; #endif -#if defined(NEW_R_ALLOC) && (defined (sparc) || defined (G_POWER)) +#ifdef F_REG_15 if (highest_a_register<=N_REAL_A_REGISTERS && highest_d_register<=8 && highest_f_register<=15) #else if (highest_a_register<=8 && highest_d_register<=8 && highest_f_register<=8) @@ -4131,7 +4142,7 @@ int do_register_allocation initialize_register_uses (d_reg_uses,highest_d_register,end_d_registers); #endif -#if defined(NEW_R_ALLOC) && (defined(sparc) || defined (G_POWER)) +#ifdef F_REG_15 { int max_15_and_highest_f_register; @@ -2,6 +2,13 @@ #define FINALIZERS #define NEW_APPLY +#ifdef _WIN64 +# define G_AI64 +#endif +#ifdef G_AI64 +# define G_A64 +#endif + #if defined (__MWERKS__) || defined (__MRC__) # define POWER # ifdef __cplusplus @@ -69,6 +76,16 @@ # endif #endif +#ifndef G_A64 +# define STACK_ELEMENT_SIZE 4 +# define STACK_ELEMENT_LOG_SIZE 2 +# define CleanInt LONG +#else +# define STACK_ELEMENT_SIZE 8 +# define STACK_ELEMENT_LOG_SIZE 3 +# define CleanInt __int64 +#endif + #if defined (I486) || (defined (G_POWER) || defined (ALIGN_C_CALLS)) || defined (MACH_O) # define SEPARATE_A_AND_B_STACK_OVERFLOW_CHECKS #endif @@ -23,12 +23,21 @@ enum { REGISTER_FP0, REGISTER_FP1, REGISTER_FP2, REGISTER_FP3, #define num_to_d_reg(r) (r) #ifdef I486 +# ifdef G_AI64 +# define A_STACK_POINTER REGISTER_A5 +# define HEAP_POINTER REGISTER_A6 +# define B_STACK_POINTER REGISTER_A7 +# define N_ADDRESS_PARAMETER_REGISTERS 3 +# define N_DATA_PARAMETER_REGISTERS 7 +# define N_FLOAT_PARAMETER_REGISTERS 8 +# else # define A_STACK_POINTER REGISTER_A3 # define HEAP_POINTER REGISTER_A4 # define B_STACK_POINTER REGISTER_A5 # define N_ADDRESS_PARAMETER_REGISTERS 2 # define N_DATA_PARAMETER_REGISTERS 2 # define N_FLOAT_PARAMETER_REGISTERS 7 +# endif #else # define A_STACK_POINTER REGISTER_A4 # if !(defined (sparc) || defined (G_POWER)) @@ -20,10 +20,12 @@ #define for_l(v,l,n) for(v=(l);v!=NULL;v=v->n) -#define g_fhighlow(gh,gl,gf) \ +#ifndef G_A64 +# define g_fhighlow(gh,gl,gf) \ (gh)=g_instruction_2 (GFHIGH,(gf),NULL); \ (gl)=g_instruction_2 (GFLOW,(gf),(gh)); \ (gh)->instruction_parameters[1].p=(gl) +#endif #define ELEMENT_MAY_BE_REMOVED 1 #define ELEMENT_USED_BEFORE_JSR 2 @@ -93,7 +95,7 @@ INSTRUCTION_GRAPH s_get_a (int offset) } graph=g_load - (-((required_offset+global_block.block_graph_a_stack_begin_displacement+1)<<2),A_STACK_POINTER); + (-((required_offset+global_block.block_graph_a_stack_begin_displacement+1)<<STACK_ELEMENT_LOG_SIZE),A_STACK_POINTER); new_element=allocate_struct_from_heap (a_stack); new_element->a_stack_offset=required_offset; @@ -201,7 +203,7 @@ INSTRUCTION_GRAPH s_get_b (int offset) } graph=g_load - ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); new_element=allocate_struct_from_heap (b_stack); new_element->b_stack_offset=required_offset; @@ -344,25 +346,33 @@ void init_b_stack (int b_stack_size,ULONG vector[]) float_offsets [number_of_float_register_parameters++]=offset; if (all_parameters_in_registers) +#ifdef G_A64 + stack_displacement-=1; +#else stack_displacement-=2; +#endif } else { INSTRUCTION_GRAPH f_graph,h_graph,l_graph; - f_graph=g_fload ((offset+stack_displacement)<<2,B_STACK_POINTER); -#ifdef g_fhighlow - g_fhighlow (h_graph,l_graph,f_graph); + f_graph=g_fload ((offset+stack_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); +#ifdef G_A64 + f_graph=g_fromf (f_graph); + s_put_b_l (offset,f_graph,f_graph); #else - h_graph=g_fhigh (f_graph); - l_graph=g_flow (f_graph); -#endif + g_fhighlow (h_graph,l_graph,f_graph); + s_put_b_l (offset+1,l_graph,l_graph); s_put_b_l (offset,h_graph,h_graph); - +#endif all_parameters_in_registers=0; } } else all_parameters_in_registers=0; +#ifdef G_A64 + offset+=1; +#else offset+=2; +#endif } else { if (number_of_data_register_parameters < (parallel_flag ? N_DATA_PARAMETER_REGISTERS-1 : N_DATA_PARAMETER_REGISTERS)){ data_offsets [number_of_data_register_parameters++]=offset; @@ -388,16 +398,18 @@ void init_b_stack (int b_stack_size,ULONG vector[]) register_graph=g_fregister (number_of_float_register_parameters-1-n); -#ifdef g_fhighlow - g_fhighlow (h_graph,l_graph,register_graph); -#else - h_graph=g_fhigh (register_graph); - l_graph=g_flow (register_graph); -#endif offset=float_offsets[n]; + +#ifdef G_A64 + register_graph=g_fromf (register_graph); + + s_put_b_l (offset,register_graph,register_graph); +#else + g_fhighlow (h_graph,l_graph,register_graph); s_put_b_l (offset+1,l_graph,l_graph); s_put_b_l (offset,h_graph,h_graph); +#endif } last_block->block_n_begin_d_parameter_registers=number_of_data_register_parameters; @@ -436,25 +448,34 @@ void init_ab_stack (int a_stack_size,int b_stack_size,ULONG vector[]) float_offsets [number_of_float_register_parameters++]=offset; if (all_parameters_in_registers) +#ifdef G_A64 + stack_displacement-=1; +#else stack_displacement-=2; +#endif } else { INSTRUCTION_GRAPH f_graph,h_graph,l_graph; - f_graph=g_fload ((offset+stack_displacement)<<2,B_STACK_POINTER); -#ifdef g_fhighlow - g_fhighlow (h_graph,l_graph,f_graph); + f_graph=g_fload ((offset+stack_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); +#ifdef G_A64 + f_graph=g_fromf (f_graph); + + s_put_b_l (offset,f_graph,f_graph); #else - h_graph=g_fhigh (f_graph); - l_graph=g_flow (f_graph); -#endif + g_fhighlow (h_graph,l_graph,f_graph); + s_put_b_l (offset+1,l_graph,l_graph); s_put_b_l (offset,h_graph,h_graph); - +#endif all_parameters_in_registers=0; } } else all_parameters_in_registers=0; +#ifdef G_A64 + offset+=1; +#else offset+=2; +#endif } else { if (number_of_data_register_parameters < (parallel_flag ? n_data_parameter_registers-1 : n_data_parameter_registers) + n_extra_data_parameter_registers) @@ -492,16 +513,18 @@ void init_ab_stack (int a_stack_size,int b_stack_size,ULONG vector[]) register_graph=g_fregister (number_of_float_register_parameters-1-n); -#ifdef g_fhighlow - g_fhighlow (h_graph,l_graph,register_graph); -#else - h_graph=g_fhigh (register_graph); - l_graph=g_flow (register_graph); -#endif offset=float_offsets[n]; + +#ifdef G_A64 + register_graph=g_fromf (register_graph); + s_put_b_l (offset,register_graph,register_graph); +#else + g_fhighlow (h_graph,l_graph,register_graph); + s_put_b_l (offset+1,l_graph,l_graph); s_put_b_l (offset,h_graph,h_graph); +#endif } last_block->block_n_begin_d_parameter_registers=number_of_data_register_parameters; @@ -528,13 +551,24 @@ void insert_graph_in_b_stack (INSTRUCTION_GRAPH graph,int b_stack_size,ULONG *ve INSTRUCTION_GRAPH f_graph,l_graph,h_graph; f_graph=g_fload - ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); -#ifdef g_fhighlow - g_fhighlow (h_graph,l_graph,f_graph); + ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); + +#ifdef G_A64 + f_graph=g_fromf (f_graph); + + new_element=allocate_struct_from_heap (b_stack); + new_element->b_stack_offset=required_offset; + new_element->b_stack_flags=0; + new_element->b_stack_graph=f_graph; + new_element->b_stack_load_graph=f_graph; + + new_element->b_stack_next=*element_p; + *element_p=new_element; + + element_p=&new_element->b_stack_next; #else - h_graph=g_fhigh (f_graph); - l_graph=g_flow (f_graph); -#endif + g_fhighlow (h_graph,l_graph,f_graph); + new_element=allocate_struct_from_heap (b_stack); new_element->b_stack_offset=required_offset; new_element->b_stack_flags=0; @@ -558,13 +592,16 @@ void insert_graph_in_b_stack (INSTRUCTION_GRAPH graph,int b_stack_size,ULONG *ve *element_p=new_element; element_p=&new_element->b_stack_next; +#endif continue; - } else { + } +#ifndef G_A64 + else { if (*element_p==NULL || (*element_p)->b_stack_offset!=required_offset){ INSTRUCTION_GRAPH load_graph; load_graph=g_load - ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); new_element=allocate_struct_from_heap (b_stack); new_element->b_stack_offset=required_offset; @@ -580,13 +617,14 @@ void insert_graph_in_b_stack (INSTRUCTION_GRAPH graph,int b_stack_size,ULONG *ve ++offset; ++required_offset; } +#endif } if (*element_p==NULL || (*element_p)->b_stack_offset!=required_offset){ INSTRUCTION_GRAPH load_graph; load_graph=g_load - ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); new_element=allocate_struct_from_heap (b_stack); new_element->b_stack_offset=required_offset; @@ -694,20 +732,28 @@ static int count_b_stack_size (ULONG *vector_p[],struct b_stack *b_stack,int b_s b_element=first_b_element; for (i=0; i<b_stack_size; ){ - register struct b_stack *next_b_element; + struct b_stack *next_b_element; INSTRUCTION_GRAPH graph,next_graph; +#ifdef G_A64 + if (i<b_stack_size && b_element->b_stack_graph->instruction_code==GFROMF) +#else if (i<b_stack_size-1 && (graph=b_element->b_stack_graph)->instruction_code==GFHIGH && (next_graph=(next_b_element=b_element->b_stack_next)->b_stack_graph)!=NULL && next_graph->instruction_code==GFLOW && next_graph->instruction_parameters[0].p==graph->instruction_parameters[0].p) +#endif { set_bit (vector,i); ++i; +#ifdef G_A64 + b_element=b_element->b_stack_next; +#else set_bit (vector,i); ++i; b_element=next_b_element->b_stack_next; +#endif } else { clear_bit (vector,i); ++i; @@ -762,18 +808,28 @@ static int count_b_stack_size_2 (ULONG *vector_p[],struct b_stack *b_stack,int b register struct b_stack *next_b_element; INSTRUCTION_GRAPH graph,next_graph; +#ifdef G_A64 + if (i<b_stack_size + && (graph=b_element->b_stack_graph)!=NULL + && graph->instruction_code==GFROMF) +#else if (i<b_stack_size-1 && (graph=b_element->b_stack_graph)!=NULL && graph->instruction_code==GFHIGH && (next_graph=(next_b_element=b_element->b_stack_next)->b_stack_graph)!=NULL && next_graph->instruction_code==GFLOW && next_graph->instruction_parameters[0].p==graph->instruction_parameters[0].p) +#endif { set_bit (vector,i); ++i; +#ifdef G_A64 + b_element=b_element->b_stack_next; +#else set_bit (vector,i); ++i; b_element=next_b_element->b_stack_next; +#endif } else { clear_bit (vector,i); ++i; @@ -814,14 +870,14 @@ static void a_stack_load_register_values (int n_parameters,int n_address_paramet element=*element_p; if (element->a_stack_flags & ELEMENT_MAY_BE_REMOVED && element->a_stack_graph==NULL){ graph=g_load - ((-(1+required_offset+global_block.block_graph_a_stack_begin_displacement))<<2,A_STACK_POINTER); + ((-(1+required_offset+global_block.block_graph_a_stack_begin_displacement))<<STACK_ELEMENT_LOG_SIZE,A_STACK_POINTER); element->a_stack_graph=graph; element->a_stack_load_graph=graph; } element_p=&(*element_p)->a_stack_next; } else { graph=g_load - ((-(1+required_offset+global_block.block_graph_a_stack_begin_displacement))<<2,A_STACK_POINTER); + ((-(1+required_offset+global_block.block_graph_a_stack_begin_displacement))<<STACK_ELEMENT_LOG_SIZE,A_STACK_POINTER); new_element=allocate_struct_from_heap (a_stack); new_element->a_stack_offset=required_offset; @@ -878,7 +934,7 @@ static void a_stack_stores (int n_parameters,int n_address_parameter_registers) || a_element->a_stack_load_graph->instruction_code==GREGISTER ) a_element->a_stack_graph=g_store ( - (-(1+a_element->a_stack_offset+global_block.block_graph_a_stack_begin_displacement))<<2, + (-(1+a_element->a_stack_offset+global_block.block_graph_a_stack_begin_displacement))<<STACK_ELEMENT_LOG_SIZE, A_STACK_POINTER,a_element->a_stack_graph, a_element->a_stack_load_graph ); @@ -957,7 +1013,7 @@ static void compute_a_load_offsets (register struct a_stack *a_element,int offse if (load_graph!=NULL) switch (load_graph->instruction_code){ case GLOAD: - load_graph->instruction_parameters[0].i= -((1+a_element->a_stack_offset)<<2)-offset; + load_graph->instruction_parameters[0].i= -((1+a_element->a_stack_offset)<<STACK_ELEMENT_LOG_SIZE)-offset; break; case GREGISTER: break; @@ -1008,13 +1064,13 @@ static void b_stack_load_register_values (int n_parameters,ULONG vector[],int n_ element=*element_p; if (element->b_stack_flags & ELEMENT_MAY_BE_REMOVED && element->b_stack_graph==NULL){ - graph=g_load ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + graph=g_load ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); element->b_stack_graph=graph; element->b_stack_load_graph=graph; } element_p=&(*element_p)->b_stack_next; } else{ - graph=g_load ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + graph=g_load ((required_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); new_element=allocate_struct_from_heap (b_stack); new_element->b_stack_offset=required_offset; @@ -1073,6 +1129,11 @@ static void b_stack_stores (int n_parameters,ULONG vector[],int n_data_parameter if ((unsigned)parameter_n<(unsigned)n_parameters) if (test_bit (vector,parameter_n)){ if (number_of_f_register_parameters<N_FLOAT_PARAMETER_REGISTERS && mc68881_flag){ +#ifdef G_A64 + f_graphs[number_of_f_register_parameters]=g_fp_arg (graph); + f_graphs_p[number_of_f_register_parameters]=&b_element->b_stack_graph; + ++number_of_f_register_parameters; +#else struct b_stack *next_b_element; next_b_element=b_element->b_stack_next; @@ -1087,7 +1148,7 @@ static void b_stack_stores (int n_parameters,ULONG vector[],int n_data_parameter ++number_of_f_register_parameters; b_element=next_b_element; - +#endif continue; } } else { @@ -1107,7 +1168,22 @@ static void b_stack_stores (int n_parameters,ULONG vector[],int n_data_parameter if (graph!=NULL){ struct b_stack *next_b_element; INSTRUCTION_GRAPH next_graph; - +#ifdef G_A64 + if (graph->instruction_code==GFROMF){ + if (graph==b_element->b_stack_load_graph && + graph->instruction_parameters[0].p->instruction_code!=GFREGISTER) + { + b_element->b_stack_graph=NULL; + } else { + b_element->b_stack_graph=g_fstore ( + (b_element->b_stack_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE, + B_STACK_POINTER,graph->instruction_parameters[0].p, + b_element->b_stack_load_graph + ); + } + continue; + } +#else if (graph->instruction_code==GFHIGH && (next_b_element=b_element->b_stack_next)!=NULL && (next_graph=next_b_element->b_stack_graph)!=NULL @@ -1123,7 +1199,7 @@ static void b_stack_stores (int n_parameters,ULONG vector[],int n_data_parameter next_b_element->b_stack_graph=NULL; } else { b_element->b_stack_graph=g_fstore ( - (b_element->b_stack_offset+global_block.block_graph_b_stack_begin_displacement)<<2, + (b_element->b_stack_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE, B_STACK_POINTER,graph->instruction_parameters[0].p, b_element->b_stack_load_graph,next_b_element->b_stack_load_graph ); @@ -1132,12 +1208,12 @@ static void b_stack_stores (int n_parameters,ULONG vector[],int n_data_parameter b_element=next_b_element; continue; } - +#endif if (graph==b_element->b_stack_load_graph && graph->instruction_code!=GREGISTER) b_element->b_stack_graph=NULL; else b_element->b_stack_graph=g_store ( - (b_element->b_stack_offset+global_block.block_graph_b_stack_begin_displacement)<<2, + (b_element->b_stack_offset+global_block.block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE, B_STACK_POINTER,graph,b_element->b_stack_load_graph ); } @@ -1216,8 +1292,12 @@ static void b_stack_stores (int n_parameters,ULONG vector[],int n_data_parameter && mc68881_flag) { ++number_of_f_register_parameters; +#ifdef G_A64 + displacement+=1; +#else displacement+=2; ++parameter_n; +#endif } else break; } else { @@ -1268,7 +1348,9 @@ static int set_basic_block_begin_d_registers } else { if (n_f_registers<N_FLOAT_PARAMETER_REGISTERS && mc68881_flag) ++n_f_registers; +#ifndef G_A64 ++offset; +#endif } stack_displacement=0; @@ -1319,6 +1401,7 @@ static int set_basic_block_begin_d_registers } else { graph=element->b_stack_load_graph; if (graph!=NULL){ +#ifndef G_A64 if (graph->instruction_code==GFHIGH && graph->instruction_parameters[0].p->instruction_code==GFLOAD) { @@ -1346,7 +1429,7 @@ static int set_basic_block_begin_d_registers fload_graph->instruction_parameters[0].p=graph; fload_graph->instruction_parameters[1].p=low_graph; } - +#endif graph->instruction_code=GREGISTER; graph->inode_arity=0; #ifdef MORE_PARAMETER_REGISTERS @@ -1439,7 +1522,11 @@ static int set_basic_block_begin_d_registers if ((element=*element_p)!=NULL){ if (element->b_stack_offset==offset){ if ((graph=element->b_stack_load_graph)!=NULL && +#ifdef G_A64 + graph->instruction_code==GFROMF) +#else graph->instruction_code==GFHIGH) +#endif { r_graph=graph->instruction_parameters[0].p; r_graph->instruction_code=GFREGISTER; @@ -1448,6 +1535,7 @@ static int set_basic_block_begin_d_registers } element=element->b_stack_next; } +#ifndef G_A64 if (element!=NULL && element->b_stack_offset==offset+1 && (graph=element->b_stack_load_graph)!=NULL && graph->instruction_code==GFLOW) @@ -1457,6 +1545,7 @@ static int set_basic_block_begin_d_registers r_graph->inode_arity=0; r_graph->instruction_parameters[0].i=n_f_registers; } +#endif } if (r_graph==NULL){ @@ -1468,24 +1557,26 @@ static int set_basic_block_begin_d_registers if ((element=*element_p)!=NULL && element->b_stack_offset==offset){ if (element->b_stack_flags & ELEMENT_MAY_BE_REMOVED && element->b_stack_graph==NULL){ -#ifdef g_fhighlow +#ifdef G_A64 + graph=g_fromf (r_graph); +#else graph=g_new_node (GFHIGH,0,2*sizeof (union instruction_parameter)); graph->instruction_parameters[1].p=NULL; -#else - graph=g_new_node (GFHIGH,0,sizeof (union instruction_parameter)); -#endif graph->instruction_parameters[0].p=r_graph; - +#endif element->b_stack_graph=NULL; element->b_stack_load_graph=NULL; } else { graph=element->b_stack_load_graph; if (graph!=NULL){ +#ifdef G_A64 + graph->instruction_code=GFROMF; + graph->inode_arity=0; + graph->instruction_parameters[0].p=r_graph; +#else graph->instruction_code=GFHIGH; graph->inode_arity=0; graph->instruction_parameters[0].p=r_graph; -#ifdef g_fhighlow - graph->instruction_parameters[1].p=NULL; #endif } else ++f_register_not_used_flag; @@ -1493,16 +1584,14 @@ static int set_basic_block_begin_d_registers element_p=&(*element_p)->b_stack_next; } else { - register struct b_stack *new_element; - -#ifdef g_fhighlow + struct b_stack *new_element; +#ifdef G_A64 + graph=g_fromf (r_graph); +#else graph=g_new_node (GFHIGH,0,2*sizeof (union instruction_parameter)); graph->instruction_parameters[1].p=NULL; -#else - graph=g_new_node (GFHIGH,0,sizeof (union instruction_parameter)); -#endif graph->instruction_parameters[0].p=r_graph; - +#endif new_element=allocate_struct_from_heap (b_stack); new_element->b_stack_offset=offset; new_element->b_stack_flags=0; @@ -1514,6 +1603,7 @@ static int set_basic_block_begin_d_registers element_p=&new_element->b_stack_next; } +#ifndef G_A64 ++offset; if (all_parameters_in_registers) @@ -1524,12 +1614,8 @@ static int set_basic_block_begin_d_registers element=*element_p; if (element->b_stack_flags & ELEMENT_MAY_BE_REMOVED && element->b_stack_graph==NULL){ -#ifdef g_fhighlow graph=g_new_node (GFLOW,0,2*sizeof (union instruction_parameter)); graph->instruction_parameters[1].p=NULL; -#else - graph=g_new_node (GFLOW,0,sizeof (union instruction_parameter)); -#endif graph->instruction_parameters[0].p=r_graph; element->b_stack_graph=NULL; @@ -1540,9 +1626,7 @@ static int set_basic_block_begin_d_registers graph->instruction_code=GFLOW; graph->inode_arity=0; graph->instruction_parameters[0].p=r_graph; -#ifdef g_fhighlow graph->instruction_parameters[1].p=NULL; -#endif } else ++f_register_not_used_flag; } @@ -1551,12 +1635,9 @@ static int set_basic_block_begin_d_registers } else { register struct b_stack *new_element; -#ifdef g_fhighlow graph=g_new_node (GFLOW,0,2*sizeof (union instruction_parameter)); graph->instruction_parameters[1].p=NULL; -#else - graph=g_new_node (GFLOW,0,sizeof (union instruction_parameter)); -#endif + graph->instruction_parameters[0].p=r_graph; new_element=allocate_struct_from_heap (b_stack); @@ -1569,7 +1650,7 @@ static int set_basic_block_begin_d_registers *element_p=new_element; element_p=&new_element->b_stack_next; } - +#endif f_register_parameter_node[n_f_registers]= f_register_not_used_flag!=2 ? r_graph : NULL; } @@ -1590,18 +1671,32 @@ static void compute_b_load_offsets (register struct b_stack *b_element,int offse switch (load_graph->instruction_code){ case GLOAD: load_graph->instruction_parameters[0].i= - (b_element->b_stack_offset<<2)+offset; + (b_element->b_stack_offset<<STACK_ELEMENT_LOG_SIZE)+offset; break; case GREGISTER: case GFREGISTER: break; +#ifdef G_A64 + case GFROMF: + { + INSTRUCTION_GRAPH graph_1; + + graph_1=load_graph->instruction_parameters[0].p; + if (graph_1->instruction_code==GFLOAD) + graph_1->instruction_parameters[0].i = (b_element->b_stack_offset<<STACK_ELEMENT_LOG_SIZE)+offset; + else if (graph_1->instruction_code!=GFREGISTER) + internal_error_in_function ("compute_b_load_offsets"); + + break; + } +#else case GFHIGH: { INSTRUCTION_GRAPH graph_1; graph_1=load_graph->instruction_parameters[0].p; if (graph_1->instruction_code==GFLOAD) - graph_1->instruction_parameters[0].i = (b_element->b_stack_offset<<2)+offset; + graph_1->instruction_parameters[0].i = (b_element->b_stack_offset<<STACK_ELEMENT_LOG_SIZE)+offset; else if (graph_1->instruction_code!=GFREGISTER) internal_error_in_function ("compute_b_load_offsets"); @@ -1613,12 +1708,13 @@ static void compute_b_load_offsets (register struct b_stack *b_element,int offse graph_1=load_graph->instruction_parameters[0].p; if (graph_1->instruction_code==GFLOAD) - graph_1->instruction_parameters[0].i = ((b_element->b_stack_offset-1)<<2)+offset; + graph_1->instruction_parameters[0].i = ((b_element->b_stack_offset-1)<<STACK_ELEMENT_LOG_SIZE)+offset; else if (graph_1->instruction_code!=GFREGISTER) internal_error_in_function ("compute_b_load_offsets"); break; } +#endif default: internal_error_in_function ("compute_b_load_offsets"); } @@ -1666,9 +1762,9 @@ static void remove_end_stack_element INSTRUCTION_GRAPH graph; if (!b_stack_flag) - graph=g_load (-(offset+stack_begin_displacement+1)<<2,A_STACK_POINTER); + graph=g_load (-(offset+stack_begin_displacement+1)<<STACK_ELEMENT_LOG_SIZE,A_STACK_POINTER); else - graph=g_load ((offset+stack_begin_displacement)<<2,B_STACK_POINTER); + graph=g_load ((offset+stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); graph->node_mark=offset<stack_top_offset ? 0 : 2; @@ -1724,9 +1820,9 @@ static void remove_begin_stack_element INSTRUCTION_GRAPH graph; if (!b_stack_flag) - graph=g_load (-(offset+stack_begin_displacement+1)<<2,A_STACK_POINTER); + graph=g_load (-(offset+stack_begin_displacement+1)<<STACK_ELEMENT_LOG_SIZE,A_STACK_POINTER); else - graph=g_load ((offset+stack_begin_displacement)<<2,B_STACK_POINTER); + graph=g_load ((offset+stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); graph->node_mark= offset<stack_top_offset ? 0 : 2; @@ -1801,9 +1897,9 @@ static void remove_begin_stack_element INSTRUCTION_GRAPH graph; if (!b_stack_flag) - graph=g_load (-(offset+stack_begin_displacement+1)<<2,A_STACK_POINTER); + graph=g_load (-(offset+stack_begin_displacement+1)<<STACK_ELEMENT_LOG_SIZE,A_STACK_POINTER); else - graph=g_load ((offset+stack_begin_displacement)<<2,B_STACK_POINTER); + graph=g_load ((offset+stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); graph->node_mark= offset<stack_top_offset ? 0 : 2; @@ -2153,8 +2249,13 @@ static void remove_not_used_b_stack_elements (struct block_graph *block_graph,st ( (b_element_2!=NULL && b_element_2->b_stack_offset==offset_2) ? ((load_graph=b_element_2->b_stack_load_graph)==NULL || (!load_graph->node_mark && - !((load_graph->instruction_code==GFHIGH || + !( +#ifdef G_A64 + load_graph->instruction_code==GFROMF +#else + (load_graph->instruction_code==GFHIGH || load_graph->instruction_code==GFLOW) +#endif && load_graph->instruction_parameters[0].p->node_mark))) : offset_2<next_block_graph->block_graph_b_stack_top_offset))) { @@ -2206,8 +2307,13 @@ static void remove_not_used_b_stack_elements (struct block_graph *block_graph,st if ((b_element_2!=NULL && b_element_2->b_stack_offset==offset_2) ? ((load_graph=b_element_2->b_stack_load_graph)==NULL || (!load_graph->node_mark && - !((load_graph->instruction_code==GFHIGH || + !( +#ifdef G_A64 + load_graph->instruction_code==GFROMF +#else + (load_graph->instruction_code==GFHIGH || load_graph->instruction_code==GFLOW) +#endif && load_graph->instruction_parameters[0].p->node_mark))) : offset_2<next_block_graph->block_graph_b_stack_top_offset) { @@ -2521,9 +2627,14 @@ static void insert_dummy_graphs_for_unused_b_stack_elements if (b_element_2->b_stack_flags & ELEMENT_MAY_BE_REMOVED || ((load_graph=b_element_2->b_stack_load_graph)==NULL || (!load_graph->node_mark && - !((load_graph->instruction_code==GFHIGH || - load_graph->instruction_code==GFLOW) && - load_graph->instruction_parameters[0].p->node_mark)))) + !( +#ifdef G_A64 + load_graph->instruction_code==GFROMF +#else + (load_graph->instruction_code==GFHIGH || + load_graph->instruction_code==GFLOW) +#endif + && load_graph->instruction_parameters[0].p->node_mark)))) { offset_1=b_element_2->b_stack_offset+stack_offset_1_min_2; @@ -2655,8 +2766,13 @@ static void mark_stack_graphs_1 (b_element_2!=NULL && b_element_2->b_stack_offset==required_offset && b_element_2->b_stack_load_graph!=NULL && (b_element_2->b_stack_load_graph->node_mark==2 || - ((b_element_2->b_stack_load_graph->instruction_code==GFHIGH + ( +#ifdef G_A64 + b_element_2->b_stack_load_graph->instruction_code==GFROMF +#else + (b_element_2->b_stack_load_graph->instruction_code==GFHIGH || b_element_2->b_stack_load_graph->instruction_code==GFLOW) +#endif && b_element_2->b_stack_load_graph->instruction_parameters[0].p->node_mark==2)))) { b_element_1->b_stack_flags|=ELEMENT_USED_BEFORE_JSR; @@ -2682,7 +2798,12 @@ static void mark_stack_graphs_1 load_graph=b_element_2->b_stack_load_graph; if (load_graph!=NULL && (load_graph->node_mark==2 || - ((load_graph->instruction_code==GFHIGH || load_graph->instruction_code==GFLOW) + ( +#ifdef G_A64 + load_graph->instruction_code==GFROMF +#else + (load_graph->instruction_code==GFHIGH || load_graph->instruction_code==GFLOW) +#endif && load_graph->instruction_parameters[0].p->node_mark==2)) && (offset=b_element_2->b_stack_offset+stack_offset_difference)>=first_non_parameter_offset) { @@ -2691,6 +2812,7 @@ static void mark_stack_graphs_1 b_element_1=*b_element_1_p; } +#ifndef G_A64 if (load_graph->instruction_code==GFHIGH && (next_b_element_2=b_element_2->b_stack_next)!=NULL && next_b_element_2->b_stack_offset==b_element_2->b_stack_offset+1 && @@ -2717,19 +2839,19 @@ static void mark_stack_graphs_1 graph_1->instruction_code=GFHIGH; graph_1->instruction_parameters[0].p=f_graph; -#ifdef g_fhighlow graph_1->instruction_parameters[1].p=next_graph_1; -#endif graph_1->node_mark=2; next_graph_1->instruction_code=GFLOW; next_graph_1->instruction_parameters[0].p=f_graph; -#ifdef g_fhighlow next_graph_1->instruction_parameters[1].p=graph_1; -#endif next_graph_1->node_mark=2; } else +#endif if (b_element_1==NULL || b_element_1->b_stack_offset!=offset){ +#ifdef G_A64 + if (load_graph->instruction_code==GFROMF) +#else if (load_graph->instruction_code==GFHIGH && (next_b_element_2=b_element_2->b_stack_next)!=NULL && next_b_element_2->b_stack_offset==b_element_2->b_stack_offset+1 && @@ -2737,6 +2859,7 @@ static void mark_stack_graphs_1 next_load_graph->instruction_code==GFLOW && next_load_graph->instruction_parameters[0].p==load_graph->instruction_parameters[0].p && (b_element_1==NULL || b_element_1->b_stack_offset!=offset+1)) +#endif { register struct b_stack *new_element; INSTRUCTION_GRAPH f_graph,l_graph,h_graph; @@ -2744,15 +2867,24 @@ static void mark_stack_graphs_1 /* printf ("%d# ",offset); */ f_graph=g_fload - ((offset+block_graph->block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + ((offset+block_graph->block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); f_graph->node_mark=2; -#ifdef g_fhighlow - g_fhighlow (h_graph,l_graph,f_graph); +#ifdef G_A64 + f_graph=g_fromf (f_graph); + f_graph->node_mark=2; + + new_element=allocate_struct_from_heap (b_stack); + new_element->b_stack_offset=offset; + new_element->b_stack_flags=ELEMENT_USED_BEFORE_JSR; + new_element->b_stack_graph=f_graph; + new_element->b_stack_load_graph=f_graph; + + new_element->b_stack_next=b_element_1; + *b_element_1_p=new_element; + b_element_1_p=&new_element->b_stack_next; #else - h_graph=g_fhigh (f_graph); - l_graph=g_flow (f_graph); -#endif + g_fhighlow (h_graph,l_graph,f_graph); h_graph->node_mark=2; l_graph->node_mark=2; @@ -2777,6 +2909,7 @@ static void mark_stack_graphs_1 b_element_1_p=&new_element->b_stack_next; b_element_2=next_b_element_2; +#endif } else { register struct b_stack *new_element; INSTRUCTION_GRAPH graph; @@ -2784,7 +2917,7 @@ static void mark_stack_graphs_1 /* printf ("%d ",offset); */ graph=g_load - ((offset+block_graph->block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + ((offset+block_graph->block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); graph->node_mark=2; new_element=allocate_struct_from_heap (b_stack); @@ -2827,14 +2960,24 @@ static void mark_stack_graphs_1 /* printf ("%d$# ",offset); */ f_graph=g_fload - ((offset+block_graph->block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + ((offset+block_graph->block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); + f_graph->node_mark=2; + +#ifdef G_A64 + f_graph=g_fromf (f_graph); f_graph->node_mark=2; -#ifdef g_fhighlow + + new_element=allocate_struct_from_heap (b_stack); + new_element->b_stack_offset=offset; + new_element->b_stack_flags=ELEMENT_USED_BEFORE_JSR; + new_element->b_stack_graph=f_graph; + new_element->b_stack_load_graph=f_graph; + + new_element->b_stack_next=b_element_1; + *b_element_1_p=new_element; + b_element_1_p=&new_element->b_stack_next; +#else g_fhighlow (h_graph,l_graph,f_graph); -#else - h_graph=g_fhigh (f_graph); - l_graph=g_flow (f_graph); -#endif h_graph->node_mark=2; l_graph->node_mark=2; @@ -2859,6 +3002,7 @@ static void mark_stack_graphs_1 b_element_1_p=&new_element->b_stack_next; ++offset; +#endif } else { register struct b_stack *new_element; INSTRUCTION_GRAPH graph; @@ -2866,7 +3010,7 @@ static void mark_stack_graphs_1 /* printf ("%d$ ",offset); */ graph=g_load - ((offset+block_graph->block_graph_b_stack_begin_displacement)<<2,B_STACK_POINTER); + ((offset+block_graph->block_graph_b_stack_begin_displacement)<<STACK_ELEMENT_LOG_SIZE,B_STACK_POINTER); graph->node_mark=2; new_element=allocate_struct_from_heap (b_stack); @@ -2969,7 +3113,7 @@ static void calculate_and_linearize_graphs (int n_elements,INSTRUCTION_GRAPH gra local_data_offset= (global_block.block_graph_b_stack_top_offset+ global_block.block_graph_b_stack_begin_displacement+ - global_block.block_graph_b_stack_end_displacement)<<2; + global_block.block_graph_b_stack_end_displacement)<<STACK_ELEMENT_LOG_SIZE; if (local_data_offset>0) local_data_offset=0; @@ -3100,7 +3244,7 @@ void linearize_stack_graphs_with_overflow_test (INSTRUCTION_GRAPH test_overflow_ local_data_offset= (global_block.block_graph_b_stack_top_offset+ global_block.block_graph_b_stack_begin_displacement+ - global_block.block_graph_b_stack_end_displacement)<<2; + global_block.block_graph_b_stack_end_displacement)<<STACK_ELEMENT_LOG_SIZE; if (local_data_offset>0) local_data_offset=0; @@ -3200,10 +3344,10 @@ static int stack_access_and_adjust_a_stack_pointer (int extra_b_offset,int do_no a_offset=-( global_block.block_graph_a_stack_top_offset+ global_block.block_graph_a_stack_begin_displacement+ - global_block.block_graph_a_stack_end_displacement)<<2; + global_block.block_graph_a_stack_end_displacement)<<STACK_ELEMENT_LOG_SIZE; b_offset=( global_block.block_graph_b_stack_top_offset+ global_block.block_graph_b_stack_begin_displacement+ - global_block.block_graph_b_stack_end_displacement)<<2; + global_block.block_graph_b_stack_end_displacement)<<STACK_ELEMENT_LOG_SIZE; minimum_b_offset= local_data_offset<b_offset ? local_data_offset : b_offset; @@ -3391,10 +3535,10 @@ generate_code_for_jsr_eval (int n_a_registers,int n_d_registers,int n_f_register new_block->block_n_begin_a_parameter_registers=n_a_registers; new_block->block_n_begin_d_parameter_registers=n_d_registers+1; #ifdef SEPARATE_A_AND_B_STACK_OVERFLOW_CHECKS - new_block->block_a_stack_check_size=(n_a_registers)<<2; - new_block->block_b_stack_check_size=(n_d_registers<<2) + (n_f_registers<<3); + new_block->block_a_stack_check_size=(n_a_registers)<<STACK_ELEMENT_LOG_SIZE; + new_block->block_b_stack_check_size=(n_d_registers<<STACK_ELEMENT_LOG_SIZE) + (n_f_registers<<3); #else - new_block->block_stack_check_size=((n_a_registers+n_d_registers)<<2) + (n_f_registers<<3); + new_block->block_stack_check_size=((n_a_registers+n_d_registers)<<STACK_ELEMENT_LOG_SIZE) + (n_f_registers<<3); #endif new_block->block_next=last_block->block_next; @@ -3417,7 +3561,7 @@ generate_code_for_jsr_eval (int n_a_registers,int n_d_registers,int n_f_register for (n=n_a_registers-1; n>=0; --n) if (n!=node_a_register){ i_move_r_id (num_to_a_reg (n),a_offset,A_STACK_POINTER); - a_offset+=4; + a_offset+=STACK_ELEMENT_SIZE; } if (a_offset>0) i_add_i_r (a_offset,A_STACK_POINTER); @@ -3449,7 +3593,7 @@ generate_code_for_jsr_eval (int n_a_registers,int n_d_registers,int n_f_register i_move_r_pd (num_to_d_reg (n),B_STACK_POINTER); # else for (n=0; n<n_d_registers; ++n){ - b_offset+=4; + b_offset+=STACK_ELEMENT_SIZE; i_move_r_id (num_to_d_reg (n),-b_offset,B_STACK_POINTER); } # endif @@ -3534,7 +3678,7 @@ generate_code_for_jsr_eval (int n_a_registers,int n_d_registers,int n_f_register # else for (n=n_d_registers-1; n>=0; --n){ i_move_id_r (-offset,B_STACK_POINTER,num_to_d_reg (n)); - offset-=4; + offset-=STACK_ELEMENT_SIZE; } if (b_offset>0) i_add_i_r (b_offset,B_STACK_POINTER); @@ -3576,7 +3720,7 @@ generate_code_for_jsr_eval (int n_a_registers,int n_d_registers,int n_f_register # else for (n=0; n<n_a_registers; ++n) if (n!=node_a_register){ - offset-=4; + offset-=STACK_ELEMENT_SIZE; i_move_id_r (offset,A_STACK_POINTER,num_to_a_reg (n)); } if (a_offset>0) @@ -3687,7 +3831,9 @@ static void generate_code_for_basic_block (struct block_graph *next_block_graph) } else { if (n_allocated_f_regs<N_FLOAT_PARAMETER_REGISTERS && mc68881_flag) ++n_allocated_f_regs; +#ifndef G_A64 ++n; +#endif } #ifdef I486 i_btst_i_id (2,0,num_to_a_reg (block_graph->block_graph_end_a_stack_size @@ -3733,7 +3879,7 @@ static void generate_code_for_basic_block (struct block_graph *next_block_graph) #if ! (defined (sparc) || defined (G_POWER)) b_offset=local_register_allocation_and_adjust_a_stack_pointer - (end_b_stack_size==global_block.block_graph_b_stack_end_displacement ? 4 : 0); + (end_b_stack_size==global_block.block_graph_b_stack_end_displacement ? STACK_ELEMENT_SIZE : 0); #else b_offset=local_register_allocation_and_adjust_a_stack_pointer (0); #endif @@ -3742,7 +3888,7 @@ static void generate_code_for_basic_block (struct block_graph *next_block_graph) { int return_offset; - return_offset = (end_b_stack_size-global_block.block_graph_b_stack_end_displacement)<<2; + return_offset = (end_b_stack_size-global_block.block_graph_b_stack_end_displacement)<<STACK_ELEMENT_LOG_SIZE; if (return_offset==0 && b_offset!=0) i_jsr_l_idu (block_graph->block_graph_last_instruction_label,b_offset); @@ -3795,7 +3941,7 @@ static void generate_code_for_basic_block (struct block_graph *next_block_graph) } # else i_jsr_l_id (block_graph->block_graph_last_instruction_label, - (end_b_stack_size-global_block.block_graph_b_stack_end_displacement)<<2); + (end_b_stack_size-global_block.block_graph_b_stack_end_displacement)<<STACK_ELEMENT_LOG_SIZE); # endif #endif if (block_check){ @@ -3812,10 +3958,10 @@ static void generate_code_for_basic_block (struct block_graph *next_block_graph) next_block_graph->block_graph_b_stack_begin_displacement)- (block_graph->block_graph_end_b_stack_size- block_graph->block_graph_b_stack_end_displacement); - block_a_stack_displacement+=a_stack_change<<2; - block_b_stack_displacement+=b_stack_change<<2; - block_graph->block_graph_a_stack_displacement+=a_stack_change<<2; - block_graph->block_graph_b_stack_displacement+=b_stack_change<<2; + block_a_stack_displacement+=a_stack_change<<STACK_ELEMENT_LOG_SIZE; + block_b_stack_displacement+=b_stack_change<<STACK_ELEMENT_LOG_SIZE; + block_graph->block_graph_a_stack_displacement+=a_stack_change<<STACK_ELEMENT_LOG_SIZE; + block_graph->block_graph_b_stack_displacement+=b_stack_change<<STACK_ELEMENT_LOG_SIZE; #else int stack_change; @@ -3828,8 +3974,8 @@ static void generate_code_for_basic_block (struct block_graph *next_block_graph) next_block_graph->block_graph_b_stack_begin_displacement)- (block_graph->block_graph_end_b_stack_size- block_graph->block_graph_b_stack_end_displacement); - block_stack_displacement+=stack_change<<2; - block_graph->block_graph_stack_displacement+=stack_change<<2; + block_stack_displacement+=stack_change<<STACK_ELEMENT_LOG_SIZE; + block_graph->block_graph_stack_displacement+=stack_change<<STACK_ELEMENT_LOG_SIZE; #endif } @@ -4012,9 +4158,9 @@ void generate_code_for_previous_blocks (int jmp_jsr_or_rtn_flag) if (block_graph->block_graph_kind!=JSR_EVAL_BLOCK){ compute_a_load_offsets (next_block_graph->block_graph_a_stack, - next_block_graph->block_graph_a_stack_begin_displacement<<2); + next_block_graph->block_graph_a_stack_begin_displacement<<STACK_ELEMENT_LOG_SIZE); compute_b_load_offsets (next_block_graph->block_graph_b_stack, - next_block_graph->block_graph_b_stack_begin_displacement<<2); + next_block_graph->block_graph_b_stack_begin_displacement<<STACK_ELEMENT_LOG_SIZE); } else { int a_stack_size,b_stack_size; ULONG *vector; @@ -4053,7 +4199,7 @@ void generate_code_for_previous_blocks (int jmp_jsr_or_rtn_flag) (&next_block_graph->block_graph_a_stack,a_stack_size, next_block_graph->block_graph_a_register_parameter_node); compute_a_load_offsets (next_block_graph->block_graph_a_stack, - next_block_graph->block_graph_a_stack_begin_displacement<<2); + next_block_graph->block_graph_a_stack_begin_displacement<<STACK_ELEMENT_LOG_SIZE); next_block_graph->block_graph_b_stack_begin_displacement= set_basic_block_begin_d_registers @@ -4067,7 +4213,7 @@ void generate_code_for_previous_blocks (int jmp_jsr_or_rtn_flag) #endif ); compute_b_load_offsets (next_block_graph->block_graph_b_stack, - next_block_graph->block_graph_b_stack_begin_displacement<<2); + next_block_graph->block_graph_b_stack_begin_displacement<<STACK_ELEMENT_LOG_SIZE); } } @@ -98,12 +98,19 @@ struct index_registers { struct reg d_reg; }; +#ifndef G_A64 +# define imm i +#endif + struct parameter { char parameter_type; char parameter_flags; short parameter_offset; union parameter_data { LONG i; +#ifdef G_A64 + __int64 imm; +#endif LABEL *l; DOUBLE *r; struct reg reg; @@ -151,6 +158,9 @@ struct instruction_node { struct instruction_node * p; LABEL * l; LONG i; +# ifdef G_A64 + __int64 imm; +# endif } #endif instruction_parameters[VARIABLE_ARRAY_SIZE]; |