⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alpha.c

📁 GCC编译器源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
  if (high & 0x8000)    {      extra = 0x4000;      tmp1 -= 0x40000000;      high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000);    }  if (low != 0)    {      int result_reg = (extra == 0 && high == 0) ? out_reg : temp_reg;      if (low >= 0 && low < 255)	fprintf (file, "\taddq $%d,%d,$%d\n", in_reg, low, result_reg);      else	fprintf (file, "\tlda $%d,%d($%d)\n", result_reg, low, in_reg);      in_reg = result_reg;    }  if (extra)    {      int result_reg = (high == 0) ? out_reg : temp_reg;      fprintf (file, "\tldah $%d,%d($%d)\n", result_reg, extra, in_reg);      in_reg = result_reg;    }  if (high)    fprintf (file, "\tldah $%d,%d($%d)\n", out_reg, high, in_reg);}/* Write function prologue.  */#if OPEN_VMS/* On vms we have two kinds of functions:   - stack frame (PROC_STACK)	these are 'normal' functions with local vars and which are	calling other functions   - register frame (PROC_REGISTER)	keeps all data in registers, needs no stack   We must pass this to the assembler so it can generate the   proper pdsc (procedure descriptor)   This is done with the '.pdesc' command.   size is the stack size needed for local variables.  */voidoutput_prolog (file, size)     FILE *file;     HOST_WIDE_INT size;{  unsigned long imask = 0;  unsigned long fmask = 0;  /* Stack space needed for pushing registers clobbered by us.  */  HOST_WIDE_INT sa_size;  /* Complete stack size needed.  */  HOST_WIDE_INT frame_size;  /* Offset from base reg to register save area.  */  int rsa_offset = 8;  /* Offset during register save.  */  int reg_offset;  /* Label for the procedure entry.  */  char *entry_label = (char *) alloca (strlen (alpha_function_name) + 5);  int i;  sa_size = alpha_sa_size ();  frame_size    = ALPHA_ROUND (sa_size 		   + (is_stack_procedure ? 8 : 0)		   + size + current_function_pretend_args_size);  /* Issue function start and label.  */  fprintf (file, "\t.ent ");  assemble_name (file, alpha_function_name);  fprintf (file, "\n");  sprintf (entry_label, "%s..en", alpha_function_name);  ASM_OUTPUT_LABEL (file, entry_label);  inside_function = TRUE;  fprintf (file, "\t.base $%d\n", base_regno);  /* Calculate register masks for clobbered registers.  */  if (is_stack_procedure)    alpha_sa_mask (&imask, &fmask);  /* Adjust the stack by the frame size.  If the frame size is > 4096     bytes, we need to be sure we probe somewhere in the first and last     4096 bytes (we can probably get away without the latter test) and     every 8192 bytes in between.  If the frame size is > 32768, we     do this in a loop.  Otherwise, we generate the explicit probe     instructions.      Note that we are only allowed to adjust sp once in the prologue.  */  if (frame_size < 32768)    {      if (frame_size > 4096)	{	  int probed = 4096;	  fprintf (file, "\tstq $31,-%d($30)\n", probed);	  while (probed + 8192 < frame_size)	    fprintf (file, "\tstq $31,-%d($30)\n", probed += 8192);	  /* We only have to do this probe if we aren't saving registers.  */	  if (sa_size == 0 && probed + 4096 < frame_size)	    fprintf (file, "\tstq $31,-%d($30)\n", frame_size);	}      if (frame_size != 0)	  fprintf (file, "\tlda $30,-%d($30)\n", frame_size);    }  else    {      /* Here we generate code to set R4 to SP + 4096 and set R23 to the	 number of 8192 byte blocks to probe.  We then probe each block	 in the loop and then set SP to the proper location.  If the	 amount remaining is > 4096, we have to do one more probe if we	 are not saving any registers.  */      HOST_WIDE_INT blocks = (frame_size + 4096) / 8192;      HOST_WIDE_INT leftover = frame_size + 4096 - blocks * 8192;      add_long_const (file, blocks, 31, 23, 23);      fprintf (file, "\tlda $22,4096($30)\n");      assemble_name (file, alpha_function_name);      fprintf (file, "..sc:\n");      fprintf (file, "\tstq $31,-8192($22)\n");      fprintf (file, "\tsubq $23,1,$23\n");      fprintf (file, "\tlda $22,-8192($22)\n");      fprintf (file, "\tbne $23,");      assemble_name (file, alpha_function_name);      fprintf (file, "..sc\n");      if (leftover > 4096 && sa_size == 0)	fprintf (file, "\tstq $31,-%d($22)\n", leftover);      fprintf (file, "\tlda $30,-%d($22)\n", leftover);    }  if (is_stack_procedure)    {      int reg_offset = rsa_offset;      /* Store R26 (RA) first.  */      fprintf (file, "\tstq $26,%d($30)\n", reg_offset);      reg_offset += 8;      /* Store integer regs. according to mask.  */      for (i = 0; i < 32; i++)        if (imask & (1L<<i))	  {	    fprintf (file, "\tstq $%d,%d($30)\n", i, reg_offset);	    reg_offset += 8;	  }      /* Print the register mask and do floating-point saves.  */      if (imask)	fprintf (file, "\t.mask 0x%x,0\n", imask);      for (i = 0; i < 32; i++)	{	  if (fmask & (1L << i))	    {	      fprintf (file, "\tstt $f%d,%d($30)\n", i, reg_offset);	      reg_offset += 8;	    }	}      /* Print the floating-point mask, if we've saved any fp register.  */      if (fmask)	fprintf (file, "\t.fmask 0x%x,0\n", fmask);      fprintf (file, "\tstq $27,0($30)\n");    }  else     {      fprintf (file, "\t.fp_save $%d\n", save_fp_regno);      fprintf (file, "\tbis $%d,$%d,$%d\n", HARD_FRAME_POINTER_REGNUM,	       HARD_FRAME_POINTER_REGNUM, save_fp_regno);    }  if (base_regno != REG_PV)    fprintf (file, "\tbis $%d,$%d,$%d\n", REG_PV, REG_PV, base_regno);  if (unwind_regno == HARD_FRAME_POINTER_REGNUM)    fprintf (file, "\tbis $%d,$%d,$%d\n", STACK_POINTER_REGNUM,	     STACK_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM);  /* Describe our frame.  */  fprintf (file, "\t.frame $%d,%d,$26,%d\n", 	   unwind_regno, frame_size, rsa_offset);  /* If we have to allocate space for outgoing args, do it now.  */  if (current_function_outgoing_args_size != 0)    fprintf (file, "\tlda $%d,%d($%d)\n", STACK_POINTER_REGNUM,	     - ALPHA_ROUND (current_function_outgoing_args_size),	     HARD_FRAME_POINTER_REGNUM);  fprintf (file, "\t.prologue\n");  link_section ();  fprintf (file, "\t.align 3\n");  ASM_OUTPUT_LABEL (file, alpha_function_name);  fprintf (file, "\t.pdesc ");  assemble_name (file, alpha_function_name);  fprintf (file, "..en,%s\n", is_stack_procedure ? "stack" : "reg");  alpha_need_linkage (alpha_function_name, 1);  text_section ();  return;}/* Write function epilogue.  */voidoutput_epilog (file, size)     FILE *file;     int size;{  unsigned long imask = 0;  unsigned long fmask = 0;  /* Stack space needed for pushing registers clobbered by us.  */  HOST_WIDE_INT sa_size = alpha_sa_size ();  /* Complete stack size needed.  */  HOST_WIDE_INT frame_size    = ALPHA_ROUND (sa_size		   + (is_stack_procedure ? 8 : 0)		   + size + current_function_pretend_args_size);  int i;  rtx insn = get_last_insn ();  /* If the last insn was a BARRIER, we don't have to write anything except     the .end pseudo-op.  */  if (GET_CODE (insn) == NOTE)    insn = prev_nonnote_insn (insn);  if (insn == 0 || GET_CODE (insn) != BARRIER)    {      /* Restore clobbered registers, load FP last.  */      if (is_stack_procedure)	{	  int rsa_offset = 8;	  int reg_offset;	  int fp_offset;	  if (unwind_regno == HARD_FRAME_POINTER_REGNUM)	    fprintf (file, "\tbis $%d,$%d,$%d\n", HARD_FRAME_POINTER_REGNUM,		     HARD_FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM);	  alpha_sa_mask (&imask, &fmask);	  /* Start reloading registers after RA.  */	  reg_offset = rsa_offset + 8;	  for (i = 0; i < 32; i++)	    if (imask & (1L<<i))	      {		if (i == HARD_FRAME_POINTER_REGNUM)		  fp_offset = reg_offset;		else		  fprintf (file, "\tldq $%d,%d($30)\n",				  i, reg_offset);		reg_offset += 8;	      }	  for (i = 0; i < 32; i++)	    if (fmask & (1L << i))	      {		fprintf (file, "\tldt $f%d,%d($30)\n", i, reg_offset);		reg_offset += 8;	      }	  /* Restore R26 (RA).  */	  fprintf (file, "\tldq $26,%d($30)\n", rsa_offset);	  /* Restore R29 (FP).  */	  fprintf (file, "\tldq $29,%d($30)\n", fp_offset);	}      else	fprintf (file, "\tbis $%d,$%d,$%d\n", save_fp_regno, save_fp_regno,		 HARD_FRAME_POINTER_REGNUM);      if (frame_size != 0)	{	  if (frame_size < 32768)	    fprintf (file, "\tlda $30,%d($30)\n", frame_size);	  else	    {	      long high = frame_size >> 16;	      long low = frame_size & 0xffff;	      if (low & 0x8000)		{		  high++;		  low = -32768 + (low & 0x7fff);		}	      fprintf (file, "\tldah $2,%ld($31)\n", high);	      fprintf (file, "\tlda $2,%ld($2)\n", low);	      fprintf (file, "\taddq $30,$2,$30\n");	    }	}      /* Finally return to the caller.  */      fprintf (file, "\tret $31,($26),1\n");    }  /* End the function.  */  fprintf (file, "\t.end ");  assemble_name (file,  alpha_function_name);  fprintf (file, "\n");  inside_function = FALSE;  /* Show that we know this function if it is called again.  */  SYMBOL_REF_FLAG (XEXP (DECL_RTL (current_function_decl), 0)) = 1;  alpha_return_addr_rtx = 0;}intvms_valid_decl_attribute_p (decl, attributes, identifier, args)     tree decl;     tree attributes;     tree identifier;     tree args;{  if (is_attribute_p ("overlaid", identifier))    return (args == NULL_TREE);}#else /* !OPEN_VMS */voidoutput_prolog (file, size)     FILE *file;     int size;{  HOST_WIDE_INT out_args_size    = ALPHA_ROUND (current_function_outgoing_args_size);  HOST_WIDE_INT sa_size = alpha_sa_size ();  HOST_WIDE_INT frame_size    = (out_args_size + sa_size       + ALPHA_ROUND (size + current_function_pretend_args_size));  HOST_WIDE_INT reg_offset = out_args_size;  HOST_WIDE_INT start_reg_offset = reg_offset;  HOST_WIDE_INT actual_start_reg_offset = start_reg_offset;  int int_reg_save_area_size = 0;  rtx insn;  unsigned reg_mask = 0;  int i;  /* Ecoff can handle multiple .file directives, so put out file and lineno.     We have to do that before the .ent directive as we cannot switch     files within procedures with native ecoff because line numbers are     linked to procedure descriptors.     Outputting the lineno helps debugging of one line functions as they     would otherwise get no line number at all. Please note that we would     like to put out last_linenum from final.c, but it is not accessible.  */  if (write_symbols == SDB_DEBUG)    {      ASM_OUTPUT_SOURCE_FILENAME (file,				  DECL_SOURCE_FILE (current_function_decl));      if (debug_info_level != DINFO_LEVEL_TERSE)        ASM_OUTPUT_SOURCE_LINE (file,				DECL_SOURCE_LINE (current_function_decl));    }  /* The assembly language programmer's guide states that the second argument     to the .ent directive, the lex_level, is ignored by the assembler,     so we might as well omit it.  */       if (!flag_inhibit_size_directive)    {      fprintf (file, "\t.ent ");      assemble_name (file, alpha_function_name);      fprintf (file, "\n");    }  ASM_OUTPUT_LABEL (file, alpha_function_name);  inside_function = TRUE;  if (TARGET_IEEE_CONFORMANT && !flag_inhibit_size_directive)    /* Set flags in procedure descriptor to request IEEE-conformant       math-library routines.  The value we set it to is PDSC_EXC_IEEE       (/usr/include/pdsc.h). */    fprintf (file, "\t.eflag 48\n");  /* Set up offsets to alpha virtual arg/local debugging pointer.  */  alpha_auto_offset = -frame_size + current_function_pretend_args_size;  alpha_arg_offset = -frame_size + 48;  /* If we need a GP (we have a LDSYM insn or a CALL_INSN), load it first.      Even if we are a static function, we still need to do this in case     our address is taken and passed to something like qsort.     We never need a GP for Windows/NT.  */  alpha_function_needs_gp = 0;#ifdef TARGET_PROFILING_NEEDS_GP  if (profile_flag)    alpha_function_needs_gp = 1;#endif  for (insn = get_insns (); insn; insn = NEXT_INSN (insn))    if ((GET_CODE (insn) == CALL_INSN)	|| (GET_RTX_CLASS (GET_CODE (insn)) == 'i'	    && GET_CODE (PATTERN (insn)) != USE	    && GET_CODE (PATTERN (insn)) != CLOBBER	    && (get_attr_type (insn) == TYPE_LDSYM		|| get_attr_type (insn) == TYPE_ISUBR)))      {	alpha_function_needs_gp = 1;	break;      }  if (TARGET_WINDOWS_NT == 0)    {      if (alpha_function_needs_gp)	fprintf (file, "\tldgp $29,0($27)\n");      /* Put a label after the GP load so we can enter the function at it.  */      assemble_name (file, alpha_function_name);      fprintf (file, "..ng:\n");    }  /* Adjust the stack by the frame size.  If the frame size is > 4096     bytes, we need to be sure we probe somewhere in the first and last     4096 bytes (we can probably get away without the latter test) and     every 8192 bytes in between.  If the frame size is > 32768, we     do this in a loop.  Otherwise, we generate the explicit probe     instructions.      Note that we are only allowed to adjust sp once in the prologue.  */  if (frame_size < 32768)    {      if (frame_size > 4096)	{	  int probed = 4096;	  fprintf (file, "\tstq $31,-%d($30)\n", probed);	  while (probed + 8192 < frame_size)	    fprintf (file, "\tstq $31,-%d($30)\n", probed += 8192);	  /* We only have to do this probe if we aren't saving registers.  */	  if (sa_size == 0 && probed + 4096 < frame_size)	    fprintf (file, "\tstq $31,-%d($30)\n", frame_size);	}      if (frame_size != 0)	fprintf (file, "\tlda $30,-%d($30)\n", frame_size);    }  else    {      /* Here we generate code to set R4 to SP + 4096 and set R5 to the	 number of 8192 byte blocks to probe.  We then probe eac

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -