S390: Introduce struct machine_function
Hartmut Penner
hpenner@de.ibm.com
Tue Nov 26 07:27:00 GMT 2002
Hello,
the s390 backend now uses the machine_function structure to keep
function specific information for the backend.
ChangeLog:
* config/s390/s390.md (literal_pool_64, literal_pool_31 ): New
insns.
* config/s390/s390.c (struct machine_function): Introduction of
struct machine_function.
* config/s390/s390-protos.h (s390_output_constant_pool): Changed
prototype.
Index: s390-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390-protos.h,v
retrieving revision 1.20
diff -r1.20 s390-protos.h
73c73
< extern void s390_output_constant_pool PARAMS ((FILE *));
---
> extern void s390_output_constant_pool PARAMS ((rtx, rtx));
Index: s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.68
diff -r1.68 s390.c
118c118
< /* Structure containing information for prologue and epilogue. */
---
> /* Define the structure for the machine field in struct function. */
120c120
< struct s390_frame
---
> struct machine_function GTY(())
122c122,125
< int frame_pointer_p;
---
> /* Label of start of initial literal pool. */
> rtx literal_pool_label;
>
> /* Set, if some of the fprs 8-15 need to be saved (64 bit abi). */
123a127,128
>
> /* Number of first and last gpr to be saved, restored. */
127d131
< int arg_frame_offset;
128a133
> /* Size of stack frame. */
149c154
< static void s390_frame_info PARAMS ((struct s390_frame *));
---
> static void s390_frame_info PARAMS ((void));
155c160
<
---
> static struct machine_function * s390_init_machine_status PARAMS ((void));
830d834
< }
831a836,838
> /* Set up function hooks. */
> init_machine_status = s390_init_machine_status;
> }
2583,2584c2590,2592
< fprintf (file, "-.LT%d", current_function_funcdef_no);
< break;
---
> fprintf (file, "-");
> s390_output_symbolic_const (file, cfun->machine->literal_pool_label);
> break;
2586c2594,2595
< fprintf (file, ".LT%d-", current_function_funcdef_no);
---
> s390_output_symbolic_const (file, cfun->machine->literal_pool_label);
> fprintf (file, "-");
2607c2616,2617
< fprintf (file, "@PLT-.LT%d", current_function_funcdef_no);
---
> fprintf (file, "@PLT-");
> s390_output_symbolic_const (file, cfun->machine->literal_pool_label);
4050,4054c4060,4083
< s390_output_constant_pool (file)
< FILE *file;
< {
< /* Output constant pool. */
< if (s390_nr_constants)
---
> s390_output_constant_pool (start_label, end_label)
> rtx start_label;
> rtx end_label;
> {
> if (TARGET_64BIT)
> {
> readonly_data_section ();
> ASM_OUTPUT_ALIGN (asm_out_file, 3);
> ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
> CODE_LABEL_NUMBER (start_label));
> }
> else
> {
> ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
> CODE_LABEL_NUMBER (start_label));
> ASM_OUTPUT_ALIGN (asm_out_file, 2);
> }
>
> s390_pool_count = 0;
> output_constant_pool (current_function_name, current_function_decl);
> s390_pool_count = -1;
> if (TARGET_64BIT)
> function_section (current_function_decl);
> else
4056,4077c4085,4086
< if (TARGET_64BIT)
< {
< fprintf (file, "\tlarl\t%s,.LT%d\n", reg_names[BASE_REGISTER],
< current_function_funcdef_no);
< readonly_data_section ();
< ASM_OUTPUT_ALIGN (file, 3);
< }
< else
< {
< fprintf (file, "\tbras\t%s,.LTN%d\n", reg_names[BASE_REGISTER],
< current_function_funcdef_no);
< }
< fprintf (file, ".LT%d:\n", current_function_funcdef_no);
<
< s390_pool_count = 0;
< output_constant_pool (current_function_name, current_function_decl);
< s390_pool_count = -1;
<
< if (TARGET_64BIT)
< function_section (current_function_decl);
< else
< fprintf (file, ".LTN%d:\n", current_function_funcdef_no);
---
> ASM_OUTPUT_ALIGN (asm_out_file, 1);
> ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER
(end_label));
4079,4082d4087
<
< /* If no pool required, at least output the anchor label. */
< else if (!TARGET_64BIT && flag_pic)
< fprintf (file, ".LT%d:\n", current_function_funcdef_no);
4085d4089
<
4100,4102d4103
< struct s390_frame frame;
< s390_frame_info (&frame);
<
4106c4107
< regs_ever_live[STACK_POINTER_REGNUM] = frame.frame_size > 0;
---
> regs_ever_live[STACK_POINTER_REGNUM] = cfun->machine->frame_size > 0;
4244,4246d4244
< struct s390_frame frame;
< s390_frame_info (&frame);
<
4259c4257
< if (frame.frame_pointer_p)
---
> if (frame_pointer_needed)
4264c4262
< off = GEN_INT (frame.frame_size + REGNO (return_reg) *
UNITS_PER_WORD);
---
> off = GEN_INT (cfun->machine->frame_size + REGNO (return_reg) *
UNITS_PER_WORD);
4416,4417c4414
< s390_frame_info (frame)
< struct s390_frame *frame;
---
> s390_frame_info ()
4427c4424
< frame->save_fprs_p = 0;
---
> cfun->machine->save_fprs_p = 0;
4432c4429
< frame->save_fprs_p = 1;
---
> cfun->machine->save_fprs_p = 1;
4436c4433
< frame->frame_size = fsize + frame->save_fprs_p * 64;
---
> cfun->machine->frame_size = fsize + cfun->machine->save_fprs_p * 64;
4441c4438
< || frame->frame_size > 0
---
> || cfun->machine->frame_size > 0
4444,4448c4441
< frame->frame_size += STARTING_FRAME_OFFSET;
<
< /* Frame pointer needed. */
<
< frame->frame_pointer_p = frame_pointer_needed;
---
> cfun->machine->frame_size += STARTING_FRAME_OFFSET;
4462c4455
< gprs_ever_live[STACK_POINTER_REGNUM] = frame->frame_size > 0;
---
> gprs_ever_live[STACK_POINTER_REGNUM] = cfun->machine->frame_size > 0;
4474,4476c4467,4469
< frame->first_save_gpr = i;
< frame->first_restore_gpr = i;
< frame->last_save_gpr = j;
---
> cfun->machine->first_save_gpr = i;
> cfun->machine->first_restore_gpr = i;
> cfun->machine->last_save_gpr = j;
4480c4473
< frame->first_save_gpr = 2;
---
> cfun->machine->first_save_gpr = 2;
4489c4482,4483
< struct s390_frame frame;
---
> HOST_WIDE_INT fsize = get_frame_size ();
> int save_fprs_p, i;
4491c4485,4493
< /* Compute frame_info. */
---
> /* fprs 8 - 15 are caller saved for 64 Bit ABI. */
> save_fprs_p = 0;
> if (TARGET_64BIT)
> for (i = 24; i < 32; i++)
> if (regs_ever_live[i])
> {
> save_fprs_p = 1;
> break;
> }
4493c4495
< s390_frame_info (&frame);
---
> fsize = fsize + save_fprs_p * 64;
4495c4497,4504
< return frame.frame_size + STACK_POINTER_OFFSET;
---
> /* Does function need to setup frame and save area. */
>
> if (! current_function_is_leaf
> || fsize > 0
> || current_function_calls_alloca
> || current_function_stdarg)
> fsize += STARTING_FRAME_OFFSET;
> return fsize + STACK_POINTER_OFFSET;
4649d4657
< struct s390_frame frame;
4651a4660
> rtx pool_start_label, pool_end_label;
4656c4665
< s390_frame_info (&frame);
---
> s390_frame_info ();
4670c4679
< frame.first_save_gpr, frame.last_save_gpr);
---
> cfun->machine->first_save_gpr, cfun->machine->last_save_gpr);
4673,4675c4682,4693
< /* Dump constant pool and set constant pool register (13). */
<
< insn = emit_insn (gen_lit ());
---
> /* Dump constant pool and set constant pool register. */
>
> pool_start_label = gen_label_rtx();
> pool_end_label = gen_label_rtx();
> cfun->machine->literal_pool_label = pool_start_label;
>
> if (TARGET_64BIT)
> insn = emit_insn (gen_literal_pool_64 (gen_rtx_REG (Pmode,
BASE_REGISTER),
> pool_start_label, pool_end_label));
> else
> insn = emit_insn (gen_literal_pool_31 (gen_rtx_REG (Pmode,
BASE_REGISTER),
> pool_start_label, pool_end_label));
4714c4732
< if (frame.frame_size > 0)
---
> if (cfun->machine->frame_size > 0)
4716c4734
< rtx frame_off = GEN_INT (-frame.frame_size);
---
> rtx frame_off = GEN_INT (-cfun->machine->frame_size);
4720c4738
< if (TARGET_BACKCHAIN || frame.save_fprs_p)
---
> if (TARGET_BACKCHAIN || cfun->machine->save_fprs_p)
4727,4728c4745,4746
< frame_off = GEN_INT (-frame.frame_size);
< if (!CONST_OK_FOR_LETTER_P (-frame.frame_size, 'K'))
---
> frame_off = GEN_INT (-cfun->machine->frame_size);
> if (!CONST_OK_FOR_LETTER_P (-cfun->machine->frame_size, 'K'))
4737c4755
< GEN_INT (-frame.frame_size))),
---
> GEN_INT (-cfun->machine->frame_size))),
4752c4770
< if (frame.save_fprs_p)
---
> if (cfun->machine->save_fprs_p)
4760c4778
< frame.frame_size - 64 + (i-24)*8);
---
> cfun->machine->frame_size - 64 + (i-24)*8);
4775c4793
< if (frame.frame_pointer_p)
---
> if (frame_pointer_needed)
4821d4838
< struct s390_frame frame;
4826,4829d4842
< /* Compute frame_info. */
<
< s390_frame_info (&frame);
<
4832c4845
< frame_pointer = frame.frame_pointer_p ?
---
> frame_pointer = frame_pointer_needed ?
4837c4850
< if (frame.first_restore_gpr != -1)
---
> if (cfun->machine->first_restore_gpr != -1)
4839,4840c4852,4853
< area_bottom = frame.first_restore_gpr * UNITS_PER_WORD;
< area_top = (frame.last_save_gpr + 1) * UNITS_PER_WORD;
---
> area_bottom = cfun->machine->first_restore_gpr * UNITS_PER_WORD;
> area_top = (cfun->machine->last_save_gpr + 1) * UNITS_PER_WORD;
4850c4863
< if (frame.save_fprs_p)
---
> if (cfun->machine->save_fprs_p)
4883,4884c4896,4897
< else if (frame.frame_size + area_bottom >= 0
< && frame.frame_size + area_top <= 4096)
---
> else if (cfun->machine->frame_size + area_bottom >= 0
> && cfun->machine->frame_size + area_top <= 4096)
4887c4900
< offset = frame.frame_size;
---
> offset = cfun->machine->frame_size;
4894c4907
< frame_off = GEN_INT (frame.frame_size - offset);
---
> frame_off = GEN_INT (cfun->machine->frame_size - offset);
4908c4921
< if (frame.save_fprs_p)
---
> if (cfun->machine->save_fprs_p)
4928c4941
< if (frame.first_restore_gpr != -1)
---
> if (cfun->machine->first_restore_gpr != -1)
4936,4937c4949,4950
< for (i = frame.first_restore_gpr;
< i <= frame.last_save_gpr;
---
> for (i = cfun->machine->first_restore_gpr;
> i <= cfun->machine->last_save_gpr;
4982c4995,4996
< frame.first_restore_gpr, frame.last_save_gpr);
---
> cfun->machine->first_restore_gpr,
> cfun->machine->last_save_gpr);
5813a5828,5836
> /* How to allocate a 'struct machine_function'. */
>
> static struct machine_function *
> s390_init_machine_status ()
> {
> return ggc_alloc_cleared (sizeof (struct machine_function));
> }
>
> #include "gt-s390.h"
Index: s390.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.md,v
retrieving revision 1.40
diff -r1.40 s390.md
6817,6820c6817,6821
<
< (define_insn "lit"
< [(set (reg 13) (pc))
< (unspec_volatile [(const_int 0)] 200)]
---
> (define_insn "literal_pool_31"
> [(unspec_volatile [(const_int 0)] 300)
> (set (match_operand:SI 0 "register_operand" "=a")
> (label_ref (match_operand 1 "" "")))
> (use (label_ref (match_operand 2 "" "")))]
6824,6825c6825,6829
< s390_output_constant_pool (asm_out_file);
< return \"\";
---
> if (s390_nr_constants) {
> output_asm_insn (\"bras\\t%0,%2\", operands);
> s390_output_constant_pool (operands[1], operands[2]);
> }
> return \"\";
6828,6829c6832
< (set_attr "length" "6")
< (set_attr "type" "integer")])
---
> (set_attr "type" "la")])
6830a6834,6849
> (define_insn "literal_pool_64"
> [(unspec_volatile [(const_int 0)] 300)
> (set (match_operand:DI 0 "register_operand" "=a")
> (label_ref (match_operand 1 "" "")))
> (use (label_ref (match_operand 2 "" "")))]
> ""
> "*
> {
> if (s390_nr_constants) {
> output_asm_insn (\"larl\\t%0,%1\", operands);
> s390_output_constant_pool (operands[1], operands[2]);
> }
> return \"\";
> }"
> [(set_attr "op_type" "NN")
> (set_attr "type" "la")])
More information about the Gcc-patches
mailing list