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

📄 alpha.c

📁 gcc库的原代码,对编程有很大帮助.
💻 C
📖 第 1 页 / 共 4 页
字号:
  /* If HIGH will be interpreted as negative, we must adjust it to do two     ldha insns.  Note that we will never be building a negative constant     here.  */  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.  */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.  */       fprintf (file, "\t.ent ");  assemble_name (file, alpha_function_name);  fprintf (file, "\n");  ASM_OUTPUT_LABEL (file, alpha_function_name);  inside_function = TRUE;  /* 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;  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 (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 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, 5, 5);      fprintf (file, "\tlda $4,4096($30)\n");      assemble_name (file, alpha_function_name);      fprintf (file, "..sc:\n");      fprintf (file, "\tstq $31,-8192($4)\n");      fprintf (file, "\tsubq $5,1,$5\n");      fprintf (file, "\tlda $4,-8192($4)\n");      fprintf (file, "\tbne $5,");      assemble_name (file, alpha_function_name);      fprintf (file, "..sc\n");      if (leftover > 4096 && sa_size == 0)	fprintf (file, "\tstq $31,-%d($4)\n", leftover);      fprintf (file, "\tlda $30,-%d($4)\n", leftover);    }  /* Describe our frame.  */  fprintf (file, "\t.frame $%d,%d,$26,%d\n", 	   (frame_pointer_needed	    ? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM),	   frame_size, current_function_pretend_args_size);      /* Save register 26 if any other register needs to be saved.  */  if (sa_size != 0)    {      reg_mask |= 1 << 26;      fprintf (file, "\tstq $26,%d($30)\n", reg_offset);      reg_offset += 8;      int_reg_save_area_size += 8;    }  /* Now save any other used integer registers required to be saved.  */  for (i = 0; i < 32; i++)    if (! fixed_regs[i] && ! call_used_regs[i] && regs_ever_live[i] && i != 26)      {	reg_mask |= 1 << i;	fprintf (file, "\tstq $%d,%d($30)\n", i, reg_offset);	reg_offset += 8;	int_reg_save_area_size += 8;      }  /* Print the register mask and do floating-point saves.  */  if (reg_mask)    fprintf (file, "\t.mask 0x%x,%d\n", reg_mask,	     actual_start_reg_offset - frame_size);  start_reg_offset = reg_offset;  reg_mask = 0;  for (i = 0; i < 32; i++)    if (! fixed_regs[i + 32] && ! call_used_regs[i + 32]	&& regs_ever_live[i + 32])      {	reg_mask |= 1 << 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 (reg_mask)    fprintf (file, "\t.fmask 0x%x,%d\n", reg_mask,	     actual_start_reg_offset - frame_size + int_reg_save_area_size);  /* If we need a frame pointer, set it from the stack pointer.  Note that     this must always be the last instruction in the prologue.  */  if (frame_pointer_needed)    fprintf (file, "\tbis $30,$30,$15\n");  /* End the prologue and say if we used gp.  */  fprintf (file, "\t.prologue %d\n", alpha_function_needs_gp);}/* Write function epilogue.  */voidoutput_epilog (file, size)     FILE *file;     int size;{  rtx insn = get_last_insn ();  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 frame_size_from_reg_save = frame_size - reg_offset;  int restore_fp    = frame_pointer_needed && regs_ever_live[HARD_FRAME_POINTER_REGNUM];  int i;  /* 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)    {      int fp_offset = 0;      /* If we have a frame pointer, restore SP from it.  */      if (frame_pointer_needed)	fprintf (file, "\tbis $15,$15,$30\n");      /* Restore all the registers, starting with the return address	 register.  */      if (sa_size != 0)	{	  fprintf (file, "\tldq $26,%d($30)\n", reg_offset);	  reg_offset += 8;	}      /* Now restore any other used integer registers that that we saved,	 except for FP if it is being used as FP, since it must be	 restored last.  */      for (i = 0; i < 32; i++)	if (! fixed_regs[i] && ! call_used_regs[i] && regs_ever_live[i]	    && i != 26)	  {	    if (i == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed)	      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 (! fixed_regs[i + 32] && ! call_used_regs[i + 32]	    && regs_ever_live[i + 32])	  {	    fprintf (file, "\tldt $f%d,%d($30)\n", i, reg_offset);	    reg_offset += 8;	  }      /* If the stack size is large and we have a frame pointer, compute the	 size of the stack into a register because the old FP restore, stack	 pointer adjust, and return are required to be consecutive	 instructions.   */      if (frame_size > 32767 && restore_fp)	add_long_const (file, frame_size, 31, 1, 1);      /* If we needed a frame pointer and we have to restore it, do it	 now.  This must be done in one instruction immediately	 before the SP update.  */      if (restore_fp && fp_offset)	fprintf (file, "\tldq $15,%d($30)\n", fp_offset);      /* Now update the stack pointer, if needed.  Only one instruction must	 modify the stack pointer.  It must be the last instruction in the	 sequence and must be an ADDQ or LDA instruction.  If the frame	 pointer was loaded above, we may only put one instruction here.  */      if (frame_size > 32768 && restore_fp)	fprintf  (file, "\taddq $1,$30,$30\n");      else	add_long_const (file, frame_size, 30, 30, 1);      /* 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;}/* Debugging support.  */#include "gstab.h"/* Count the number of sdb related labels are generated (to find block   start and end boundaries).  */int sdb_label_count = 0;/* Next label # for each statement.  */static int sym_lineno = 0;/* Count the number of .file directives, so that .loc is up to date.  */static int num_source_filenames = 0;/* Name of the file containing the current function.  */static char *current_function_file = "";/* Offsets to alpha virtual arg/local debugging pointers.  */long alpha_arg_offset;long alpha_auto_offset;/* Emit a new filename to a stream.  */voidalpha_output_filename (stream, name)     FILE *stream;     char *name;{  static int first_time = TRUE;  char ltext_label_name[100];  if (first_time)    {      first_time = FALSE;      ++num_source_filenames;      current_function_file = name;      fprintf (stream, "\t.file\t%d ", num_source_filenames);      output_quoted_string (stream, name);      fprintf (stream, "\n");      if (!TARGET_GAS && write_symbols == DBX_DEBUG)	fprintf (stream, "\t#@stabs\n");    }  else if (!TARGET_GAS && write_symbols == DBX_DEBUG)    {      ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);      fprintf (stream, "%s ", ASM_STABS_OP);      output_quoted_string (stream, name);      fprintf (stream, ",%d,0,0,%s\n", N_SOL, &ltext_label_name[1]);    }  else if (name != current_function_file      && strcmp (name, current_function_file) != 0)    {      if (inside_function && ! TARGET_GAS)	fprintf (stream, "\t#.file\t%d ", num_source_filenames);      else	{	  ++num_source_filenames;	  current_function_file = name;	  fprintf (stream, "\t.file\t%d ", num_source_filenames);	}      output_quoted_string (stream, name);      fprintf (stream, "\n");    }}/* Emit a linenumber to a stream.  */voidalpha_output_lineno (stream, line)     FILE *stream;     int line;{  if (! TARGET_GAS && write_symbols == DBX_DEBUG)    {      /* mips-tfile doesn't understand .stabd directives.  */      ++sym_lineno;      fprintf (stream, "$LM%d:\n\t%s %d,0,%d,$LM%d\n",	       sym_lineno, ASM_STABN_OP, N_SLINE, line, sym_lineno);    }  else    fprintf (stream, "\n\t.loc\t%d %d\n", num_source_filenames, line);}

⌨️ 快捷键说明

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