From 7c3efe45b1f889621b1ead7489f5e2eccb386a1a Mon Sep 17 00:00:00 2001 From: John van Groningen Date: Tue, 10 Jan 2006 14:10:22 +0000 Subject: port to 64 bit windows --- cg.c | 4 + cgcalc.c | 35 +++ cgcode.c | 694 ++++++++++++++++++++++++++++++++++++++++--------------- cgcode.h | 18 +- cgcodep.h | 6 +- cgconst.h | 25 +- cgiconst.h | 5 +- cginput.c | 41 +++- cginstructions.c | 548 +++++++++++++++++++++++++++++++++++++------ cginstructions.h | 2 +- cglin.c | 563 ++++++++++++++++++++++++++++++++++---------- cglin.h | 6 +- cgopt.c | 67 +++--- cgport.h | 17 ++ cgrconst.h | 9 + cgstack.c | 414 ++++++++++++++++++++++----------- cgtypes.h | 10 + 17 files changed, 1911 insertions(+), 553 deletions(-) diff --git a/cg.c b/cg.c index 49054c1..d86d89c 100644 --- a/cg.c +++ b/cg.c @@ -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; diff --git a/cgcalc.c b/cgcalc.c index 7c88f00..1d3c291 100644 --- a/cgcalc.c +++ b/cgcalc.c @@ -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){ diff --git a/cgcode.c b/cgcode.c index 4b72a1c..a0f8f2a 100644 --- a/cgcode.c +++ b/cgcode.c @@ -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<instruction_parameters[1]; for (argument_n=1; argument_ninode_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<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<=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)<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)<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<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<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<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<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)<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<instruction_code==GFHIGH && i+10; --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<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<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<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)<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)<=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<=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)<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<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<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)<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<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)<instruction_code==GFHIGH && i+1instruction_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)<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)<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)<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)<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<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); diff --git a/cgcode.h b/cgcode.h index 7b329e8..8b778ca 100644 --- a/cgcode.h +++ b/cgcode.h @@ -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 diff --git a/cgcodep.h b/cgcodep.h index 0f4a663..d716abe 100644 --- a/cgcodep.h +++ b/cgcodep.h @@ -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); diff --git a/cgconst.h b/cgconst.h index 287f29c..f7699a1 100644 --- a/cgconst.h +++ b/cgconst.h @@ -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 diff --git a/cgiconst.h b/cgiconst.h index b4d79bb..74d8d9f 100644 --- a/cgiconst.h +++ b/cgiconst.h @@ -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 { diff --git a/cginput.c b/cginput.c index 82c7da7..ab44aa8 100644 --- a/cginput.c +++ b/cginput.c @@ -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=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)<1){ --a_size; - graph_5=g_load_id ((a_size-1)<<2,graph_3); + graph_5=g_load_id ((a_size-1)<0){ --ab_size; - graph_5=g_load_id (ab_size<<2,graph_3); + graph_5=g_load_id (ab_size<>2)+n_clean_b_register_parameters-(function_address_parameter=='F'); for (l=first_pointer_result_index; 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=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=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=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; linstruction_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<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+1ad_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; iinstruction_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_registerad_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,15 +6875,18 @@ 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); */ @@ -6592,7 +6894,7 @@ static void linearize_float_graph (register INSTRUCTION_GRAPH graph,register ADD } } -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; diff --git a/cglin.h b/cglin.h index fe6a547..b694706 100644 --- a/cglin.h +++ b/cglin.h @@ -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); diff --git a/cgopt.c b/cgopt.c index 1bd87be..ccd4e39 100644 --- a/cgopt.c +++ b/cgopt.c @@ -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_offsetparameter_offset!=b_offset-4){ + if (parameter1->parameter_offsetparameter_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_offsetparameter_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_offsetparameter_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_ninstruction_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; diff --git a/cgport.h b/cgport.h index 58c5d86..a0ee42d 100644 --- a/cgport.h +++ b/cgport.h @@ -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 diff --git a/cgrconst.h b/cgrconst.h index 4256a62..9c87cca 100644 --- a/cgrconst.h +++ b/cgrconst.h @@ -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)) diff --git a/cgstack.c b/cgstack.c index d5284d4..3e2aaf8 100644 --- a/cgstack.c +++ b/cgstack.c @@ -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)<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)<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)<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)<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)<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)<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)<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; ib_stack_graph->instruction_code==GFROMF) +#else if (ib_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 (ib_stack_graph)!=NULL + && graph->instruction_code==GFROMF) +#else if (ib_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))<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))<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))<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)<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)<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)<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_parametersb_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)<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)<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)<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_registersb_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<instruction_parameters[0].p; + if (graph_1->instruction_code==GFLOAD) + graph_1->instruction_parameters[0].i = (b_element->b_stack_offset<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<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)<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)<node_mark=offsetnode_mark= offsetnode_mark= offsetb_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_2block_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_2block_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)<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)<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)<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)<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)<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)<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)<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)<block_b_stack_check_size=(n_d_registers<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)<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=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; n0) @@ -3687,7 +3831,9 @@ static void generate_code_for_basic_block (struct block_graph *next_block_graph) } else { if (n_allocated_f_regsblock_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)<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)<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<block_graph_a_stack_displacement+=a_stack_change<block_graph_b_stack_displacement+=b_stack_change<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<block_graph_stack_displacement+=stack_change<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<block_graph_b_stack, - next_block_graph->block_graph_b_stack_begin_displacement<<2); + next_block_graph->block_graph_b_stack_begin_displacement<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<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<