gcc S/390 backend 2

Geoff Keating geoffk@cygnus.com
Wed Oct 11 12:26:00 GMT 2000


This is much better.  I can now read the code.  

- There are still a few places where there are no spaces before `('
  and after `,', and I'd appreciate it if you could go through and fix
  these (they may not be completely in the order in the patches):

s390-1:+        fprintf (file, "\tL\t%d,0(%d)\n",fp,fp);
s390-1:+      fprintf (file, "\tL\t%d,%d(%d)\n",return_reg,56+offset,fp);
s390-1:+        fprintf (file, "\tLD\t4,%d(%d)\n",80+offset,fp); 
s390-1:+        fprintf (file, "\tLD\t6,%d(%d)\n",88+offset,fp);
s390-1:+          assemble_name (asm_out_file,(char*) name);
s390-2:+{ { "hard-float",    1,N_("Use hardware fp")},                         \
s390-2:+  { "soft-float",   -1,N_("Don't use hardware fp")},                   \
s390-2:+  { "backchain",     2,N_("Set backchain")},                           \
s390-2:+  { "no-backchain", -2,N_("Don't set backchain (faster, but debug harder")}, \
s390-2:+  { "small-exec",    4,N_("Use bras for execucable < 64k")},           \
s390-2:+  { "no-small-exec",-4,N_("Don't use bras")},                          \
s390-2:+  { "debug_arg",     8,N_("Additional debug prints")},                 \
s390-2:+  { "no-debug_arg", -8,N_("Don't print additional debug prints")},     \
s390-2:+  output_addr_const (FILE,(VALUE));             \
s390-2:+  putc ('\n',FILE);                             \
s390-2:+  output_addr_const (FILE,(VALUE));             \
s390-2:+  putc ('\n',FILE);                             \
s390-2:+  output_addr_const (FILE,(VALUE)),             \
s390-2:+  putc ('\n',FILE))
s390-2:+  fprintf (FILE, "\t.long %s%d-.LT%X_%X\n",LPREFIX, VALUE, \
s390-2:+           s390_function_count,s390_pool_count)
s390-2:+      fprintf (FILE, "\t.long  %d\n",DELTA);                           \
s390-2:+extern int legitimate_constant_p PARAMS((rtx));
s390-2:+extern int unsigned_comparison_operator PARAMS((rtx));
s390-2:+extern int unsigned_jump_follows_p PARAMS((rtx));
s390-2:+extern int s390_stop_dump_lit_p PARAMS((rtx));
s390-2:+extern void s390_dump_literal_pool PARAMS((rtx, rtx));
s390-2:+extern void s390_expand_eh_epilogue PARAMS((rtx, rtx,rtx));
s390-2:+extern int s390_expand_pic_movsi PARAMS((rtx[]));
s390-2:+extern void output_pic_addr_const PARAMS((FILE *, rtx));
s390-2:+extern void s390_asm_output_external_libcall PARAMS((FILE *, rtx));
s390-2:+extern void encode_section_info PARAMS((tree));
s390-2:+extern void asm_generate_internal_label PARAMS((char *, char* , int));
s390-2:+check_mode (op,mode)
s390-2:+  if (code == MEM && GET_CODE (XEXP (op,0)) == SYMBOL_REF &&
s390-2:+      CONSTANT_POOL_ADDRESS_P (XEXP (op,0))) 
s390-2:+      sym = get_pool_constant (XEXP (op,0));
s390-2:+    if (base_n_index_p (XEXP (op,0)))
s390-2:+  return memory_operand (op,mode);
s390-2:+  if (!general_pmode_operand (op,mode))
s390-2:+    if (base_n_index_p (XEXP (op,0)))
s390-2:+      return memory_operand (op,mode);
s390-2:+  return register_operand (op,mode);
s390-2:+  if (!general_pmode_operand (op,mode))
s390-2:+    if (base_n_index_p (XEXP (op,0)))
s390-2:+      return memory_operand (op,mode);
s390-2:+  return register_operand (op,mode) || immediate_operand (op,mode);
s390-2:+  if (! general_pmode_operand (op,mode))
s390-2:+  return register_operand (op,mode) || memory_operand (op,mode);
s390-2:+  if (!general_pmode_operand (op,mode))
s390-2:+  return register_operand (op,mode) || memory_operand (op,mode);
s390-2:+do_print_operand_address (FILE *file, rtx addr,int off)
s390-2:+    fprintf (file, "%d(%s)",off, reg_names[REGNO (addr)]);
s390-2:+        offset = gen_rtx (CONST_INT,SImode,
s390-2:+        offset = gen_rtx (CONST_INT,SImode,off);
s390-2:+    fprintf (file,"-.LT_%X_%X(%d)",s390_function_count,s390_pool_count,
s390-2:+              s390_function_count,s390_pool_count,BASE_REGISTER);
s390-2:+      fprintf (file,"_%X-.LT%X_%X(%d)",s390_pool_count,
s390-2:+              s390_function_count,s390_pool_count,BASE_REGISTER);
s390-2:+            fprintf (file,"%s",reg_names[REGNO (x)+1]);
s390-2:+            strcpy (curreg,reg_names[REGNO (x)+1]);
s390-2:+            fprintf (file,"%s",reg_names[REGNO (x)]);
s390-2:+            strcpy (curreg,reg_names[REGNO (x)]);
s390-2:+              else if (GET_CODE (XEXP (addr,1)) != REG)
s390-2:+                         reg_names[REGNO (XEXP (XEXP (addr,0),0))],
s390-2:+                         reg_names[REGNO (XEXP (XEXP (addr,0),1))]);
s390-2:+              else  if (GET_CODE (XEXP (addr,1)) != REG)
s390-2:+                         reg_names[REGNO (XEXP (addr,0))],
s390-2:+                         reg_names[REGNO (XEXP (addr,1))]);
s390-2:+            do_print_operand_address (file,addr,4);
s390-2:+      do_print_operand_address (file,x,0);
s390-2:+        fprintf (file, ".LT%X_%X-.",s390_function_count,s390_pool_count);
s390-2:+                s390_function_count,s390_pool_count);
s390-2:+        assemble_name (file,XSTR (x,0));
s390-2:+        s390_output_const (file,x,SImode);
s390-2:+        s390_output_const (file,x,SImode);
s390-2:+        fprintf (file, "%d",INTVAL (x));
s390-2:+      s390_output_const (file,x,DFmode);
s390-2:+      output_addr_const (file,x);
s390-2:+        output_branch_condition (file,x);
s390-2:+        output_inverse_branch_condition (file,x);
s390-2:+  do_print_operand_address (file,addr,0);
s390-2:+    strcpy (new_str+2,XSTR (sym_ref,0));
s390-2:+    XSTR (sym_ref,0) = new_str+2;
s390-2:+s390_adjust_cost (rtx insn, rtx link, rtx dep_insn,int cost )
s390-2:+  rtx dep_rtx,insn_rtx;
s390-2:+      (GET_CODE (XEXP (dep_rtx,0)) == REG)) {
s390-2:+    dep_reg = REGNO (XEXP (dep_rtx,0));
s390-2:+        (GET_CODE (XEXP (insn_rtx,0)) == REG ) &&
s390-2:+        (GET_CODE (XEXP (insn_rtx,1)) == PLUS) &&
s390-2:+        (GET_CODE (XEXP (XEXP (insn_rtx,1),0)) == REG) &&
s390-2:+        (REGNO (XEXP (XEXP (insn_rtx,1),0)) == dep_reg)) {
s390-2:+s390_asm_output_pool_prologue (FILE *file, char *fname,tree fndecl,int size)
s390-2:+    fprintf (file,"\t.align 4\n\tBRAS\t13,0f\n.LT%X_%X:\t# Pool %d \n",
s390-2:+            s390_function_count,s390_pool_count,s390_pool_count);
s390-2:+other_chunk (int *ltorg,int my_addr,int other_addr)
s390-2:+  int ad,i=0,j=0;
s390-2:+far_away (int my_addr,int other_addr)
s390-2:+check_and_change_labels (rtx insn,int *ltorg_uids)
s390-2:+  rtx pattern,tmp,body,label1;
s390-2:+  int addr0,addr1;
s390-2:+    body = XEXP (pattern,1);
s390-2:+      addr1 = INSN_ADDRESSES (INSN_UID (XEXP (body,0)));
s390-2:+      if (other_chunk (ltorg_uids,addr0,addr1)) {
s390-2:+        SYMBOL_REF_USED (XEXP (body,0)) = 1;
s390-2:+      if (far_away (addr0,addr1)) { 
s390-2:+        emit_insn_before (gen_movsi (gen_rtx_REG (Pmode,RETURN_REGNUM),
s390-2:+                                   force_const_mem (Pmode,body)),insn);
s390-2:+              gen_rtx_MEM (Pmode,gen_rtx_REG (Pmode,14))),insn);
s390-2:+      if (GET_CODE (XEXP (body,1)) == LABEL_REF) {
s390-2:+        addr1 = INSN_ADDRESSES (INSN_UID (XEXP (XEXP (body,1),0)));
s390-2:+        if (other_chunk (ltorg_uids,addr0,addr1)) {
s390-2:+          SYMBOL_REF_USED (XEXP (XEXP (body,1),0)) = 1;
s390-2:+        if (far_away (addr0,addr1)) {
s390-2:+          emit_jump_insn_before (gen_icjump (label1,XEXP (body,0)),insn);
s390-2:+          emit_insn_before (gen_movsi (gen_rtx_REG (Pmode,RETURN_REGNUM),
s390-2:+                           force_const_mem (Pmode,XEXP (body,1))),insn);
s390-2:+                gen_rtx_MEM (Pmode,gen_rtx_REG (Pmode,14))),insn);
s390-2:+          emit_label_before (label1,insn);
s390-2:+      addr1 = INSN_ADDRESSES (INSN_UID (XEXP (XVECEXP (pattern,diff_vec_p,i),0)));
s390-2:+      if (other_chunk (ltorg_uids,addr0,addr1)) {
s390-2:+        SYMBOL_REF_USED (XEXP (XVECEXP (pattern,diff_vec_p,i),0)) = 1;
s390-2:+  rtx insn,ninsn,tmp;
s390-2:+  int addr,naddr,uids;
s390-2:+  memset (ltorg_uids,0,size/1024+1024);
s390-2:+                 naddr,INSN_ADDRESSES (INSN_UID (tmp)));
s390-2:+      asms = XSTR (PATTERN (insn),0);
s390-2:+      if ((memcmp (asms,".section",8) == 0) ||
s390-2:+          (memcmp (asms,".text",5) == 0)    ||
s390-2:+          (memcmp (asms,"\t.section",9) == 0) ||
s390-2:+          (memcmp (asms,"\t.text",6) == 0))  {
s390-2:+                                           ".align 4"),insn);
s390-2:+  for (insn=get_insns (),uids=0; insn;insn = next_real_insn (insn)) {
s390-2:+                       gen_rtx_CONST_INT (Pmode,ltorg_uids[++uids])),
s390-2:+      insn = check_and_change_labels (insn,ltorg_uids);
s390-2:+                                          gen_rtx_LABEL_REF (Pmode,XEXP (insn,0))),insn);
s390-2:+      && GET_CODE (XEXP ((XVECEXP (body, 0, 1)),0)) == CONST_INT
s390-2:+  output_constant_pool (current_function_name,current_function_decl);
s390-2:+                     profile_block_flag,BLOCKNO);                          \
s390-2:+  fputc ('\n',FILE);                                                    \
s390-2:+    fprintf (file,"-.LT_%X_%X(%d)",s390_function_count,s390_pool_count,
s390-2:+      fprintf (file,"_%X-.LT%X_%X(%d)",s390_pool_count,
s390-2:+  s390_function_arg_advance(&CUM, MODE, TYPE, NAMED)
s390-2:+  s390_function_arg(&CUM, MODE, TYPE, NAMED)
s390-2:+  ((REGNO(X) > 0 && REGNO(X) < 16) || REGNO(X) >= FIRST_PSEUDO_REGISTER-1)
s390-2:+  else if (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P(X))    \
s390-2:+                 CONSTANT_POOL_ADDRESS_P(XEXP (XEXP (X, 0), 0)))        \
s390-2:+    (X) = force_const_mem(SImode,(X));                                  \
s390-3:+   output_asm_insn (\"CLC   %O1(%c3,%R1),%2\",operands);
s390-3:+  if(TARGET_IBM_FLOAT) {
s390-3:+    emit_insn (gen_do_floatsisf2(operands[0], operands[1],
s390-3:+  if (CONSTANT_P(operands[1]))

Also:

-  in s390-protos.h, s390_expand_pic_movsi is prototyped but never
   defined anywhere; you want to delete it.

- This is wrong:

+/* 
+ * Caller save not (always) working in gcc-2.95.2
+ */
+
+#undef CC1_SPEC
+#define CC1_SPEC "-fno-caller-saves"
+#define CC1PLUS_SPEC "-fno-caller-saves"

  If you really wanted to switch this off, you should do it in
  OPTIMIZATION_OPTIONS or OVERRIDE_OPTIONS.  However, it'd be better if
  you worked out what the real problem was and fixed that.

- Replace `gen_rtx (CONST_INT, SImode,16)))' with GEN_INT.
  (Also insert a space after the comma.)  It's also wrong to have a
  CONST_INT with mode other than VOIDmode.

- Replace `gen_rtx (SYMBOL_REF, SImode, XSTR (XEXP (operands[0], 0), 0)-1)'
  other uses of gen_rtx with a constant node type with
  `gen_rtx_SYMBOL_REF (SImode, XSTR (XEXP (operands[0], 0), 0)-1)'.

- Replace 'gen_rtx (REG, SImode, STACK_POINTER_REGNUM)' with
  stack_pointer_rtx.
  
  For instance,

s390-3:+   xoperands[1] = gen_rtx (MEM, SImode,
s390-3:+                    gen_rtx (PLUS, SImode,
s390-3:+                      gen_rtx (REG, SImode, STACK_POINTER_REGNUM),
s390-3:+                      gen_rtx (CONST_INT, SImode, 16+4)));

  should be

  xoperands[1] = gen_rtx_MEM (SImode,
			      gen_rtx_PLUS (SImode, stack_pointer_rtx,
					    GEN_INT (16+4)));
- This:

+          } else if (code == 'N') {
+           do_print_operand_address (file,addr,4);
+          }
 
  should read:

           }
         else if (code == 'N')
           {
             do_print_operand_address (file, addr, 4);
           }

  This is the correct way to do it, and incidentally the way the code
  a few lines above is formatted...

  This function (print_operand) could also use some blank lines, I
  suggest before every 'case'.

- This port seems to be generating the prologue and epilogue as
  text, not as RTL.  You should know that certain optimisations
  cannot work if this is done.  This doesn't have to be fixed before
  integration, though.

- This code seems to be in the wrong place:

+int
+s390_function_epilogue (FILE * file, int lsize)
+{
...
+
+  current_function_uses_pic_offset_table = 0;
+  leaf_function_flag = 0;
+  s390_pool_start_insn = NULL_RTX;
+  s390_pool_count = -1;
+  s390_function_count++;
+  return 0;
+}

   Why is it there?

-- 
- Geoffrey Keating <geoffk@cygnus.com>


More information about the Gcc-patches mailing list