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

📄 tc-ia64.c

📁 基于4个mips核的noc设计
💻 C
📖 第 1 页 / 共 5 页
字号:
    { "nt",	PSEUDO_FUNC_CONST, { 2 } },    /* unwind-related registers:  */    { "priunat",PSEUDO_FUNC_REG, { REG_PRIUNAT } }  };/* 41-bit nop opcodes (one per unit):  */static const bfd_vma nop[IA64_NUM_UNITS] =  {    0x0000000000LL,	/* NIL => break 0 */    0x0008000000LL,	/* I-unit nop */    0x0008000000LL,	/* M-unit nop */    0x4000000000LL,	/* B-unit nop */    0x0008000000LL,	/* F-unit nop */    0x0008000000LL,	/* L-"unit" nop */    0x0008000000LL,	/* X-unit nop */  };/* Can't be `const' as it's passed to input routines (which have the   habit of setting temporary sentinels.  */static char special_section_name[][20] =  {    {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},    {".IA_64.unwind"}, {".IA_64.unwind_info"}  };/* The best template for a particular sequence of up to three   instructions:  */#define N	IA64_NUM_TYPESstatic unsigned char best_template[N][N][N];#undef N/* Resource dependencies currently in effect */static struct rsrc {  int depind;                       /* dependency index */  const struct ia64_dependency *dependency; /* actual dependency */  unsigned specific:1,              /* is this a specific bit/regno? */    link_to_qp_branch:1;           /* will a branch on the same QP clear it?*/  int index;                        /* specific regno/bit within dependency */  int note;                         /* optional qualifying note (0 if none) */#define STATE_NONE 0#define STATE_STOP 1#define STATE_SRLZ 2  int insn_srlz;                    /* current insn serialization state */  int data_srlz;                    /* current data serialization state */  int qp_regno;                     /* qualifying predicate for this usage */  char *file;                       /* what file marked this dependency */  unsigned int line;                /* what line marked this dependency */  struct mem_offset mem_offset;     /* optional memory offset hint */  enum { CMP_NONE, CMP_OR, CMP_AND } cmp_type; /* OR or AND compare? */  int path;                         /* corresponding code entry index */} *regdeps = NULL;static int regdepslen = 0;static int regdepstotlen = 0;static const char *dv_mode[] = { "RAW", "WAW", "WAR" };static const char *dv_sem[] = { "none", "implied", "impliedf",				"data", "instr", "specific", "stop", "other" };static const char *dv_cmp_type[] = { "none", "OR", "AND" };/* Current state of PR mutexation */static struct qpmutex {  valueT prmask;  int path;} *qp_mutexes = NULL;          /* QP mutex bitmasks */static int qp_mutexeslen = 0;static int qp_mutexestotlen = 0;static valueT qp_safe_across_calls = 0;/* Current state of PR implications */static struct qp_imply {  unsigned p1:6;  unsigned p2:6;  unsigned p2_branched:1;  int path;} *qp_implies = NULL;static int qp_implieslen = 0;static int qp_impliestotlen = 0;/* Keep track of static GR values so that indirect register usage can   sometimes be tracked.  */static struct gr {  unsigned known:1;  int path;  valueT value;} gr_values[128] = {{ 1, 0, 0 }};/* These are the routines required to output the various types of   unwind records.  *//* A slot_number is a frag address plus the slot index (0-2).  We use the   frag address here so that if there is a section switch in the middle of   a function, then instructions emitted to a different section are not   counted.  Since there may be more than one frag for a function, this   means we also need to keep track of which frag this address belongs to   so we can compute inter-frag distances.  This also nicely solves the   problem with nops emitted for align directives, which can't easily be   counted, but can easily be derived from frag sizes.  */typedef struct unw_rec_list {  unwind_record r;  unsigned long slot_number;  fragS *slot_frag;  struct unw_rec_list *next;} unw_rec_list;#define SLOT_NUM_NOT_SET        (unsigned)-1static struct{  unsigned long next_slot_number;  fragS *next_slot_frag;  /* Maintain a list of unwind entries for the current function.  */  unw_rec_list *list;  unw_rec_list *tail;  /* Any unwind entires that should be attached to the current slot     that an insn is being constructed for.  */  unw_rec_list *current_entry;  /* These are used to create the unwind table entry for this function.  */  symbolS *proc_start;  symbolS *proc_end;  symbolS *info;		/* pointer to unwind info */  symbolS *personality_routine;  segT saved_text_seg;  subsegT saved_text_subseg;  unsigned int force_unwind_entry : 1;	/* force generation of unwind entry? */  /* TRUE if processing unwind directives in a prologue region.  */  int prologue;  int prologue_mask;  unsigned int prologue_count;	/* number of .prologues seen so far */} unwind;typedef void (*vbyte_func) PARAMS ((int, char *, char *));/* Forward delarations:  */static int ar_is_in_integer_unit PARAMS ((int regnum));static void set_section PARAMS ((char *name));static unsigned int set_regstack PARAMS ((unsigned int, unsigned int,					  unsigned int, unsigned int));static void dot_radix PARAMS ((int));static void dot_special_section PARAMS ((int));static void dot_proc PARAMS ((int));static void dot_fframe PARAMS ((int));static void dot_vframe PARAMS ((int));static void dot_vframesp PARAMS ((int));static void dot_vframepsp PARAMS ((int));static void dot_save PARAMS ((int));static void dot_restore PARAMS ((int));static void dot_restorereg PARAMS ((int));static void dot_restorereg_p PARAMS ((int));static void dot_handlerdata  PARAMS ((int));static void dot_unwentry PARAMS ((int));static void dot_altrp PARAMS ((int));static void dot_savemem PARAMS ((int));static void dot_saveg PARAMS ((int));static void dot_savef PARAMS ((int));static void dot_saveb PARAMS ((int));static void dot_savegf PARAMS ((int));static void dot_spill PARAMS ((int));static void dot_spillreg PARAMS ((int));static void dot_spillmem PARAMS ((int));static void dot_spillreg_p PARAMS ((int));static void dot_spillmem_p PARAMS ((int));static void dot_label_state PARAMS ((int));static void dot_copy_state PARAMS ((int));static void dot_unwabi PARAMS ((int));static void dot_personality PARAMS ((int));static void dot_body PARAMS ((int));static void dot_prologue PARAMS ((int));static void dot_endp PARAMS ((int));static void dot_template PARAMS ((int));static void dot_regstk PARAMS ((int));static void dot_rot PARAMS ((int));static void dot_byteorder PARAMS ((int));static void dot_psr PARAMS ((int));static void dot_alias PARAMS ((int));static void dot_ln PARAMS ((int));static char *parse_section_name PARAMS ((void));static void dot_xdata PARAMS ((int));static void stmt_float_cons PARAMS ((int));static void stmt_cons_ua PARAMS ((int));static void dot_xfloat_cons PARAMS ((int));static void dot_xstringer PARAMS ((int));static void dot_xdata_ua PARAMS ((int));static void dot_xfloat_cons_ua PARAMS ((int));static void print_prmask PARAMS ((valueT mask));static void dot_pred_rel PARAMS ((int));static void dot_reg_val PARAMS ((int));static void dot_dv_mode PARAMS ((int));static void dot_entry PARAMS ((int));static void dot_mem_offset PARAMS ((int));static void add_unwind_entry PARAMS((unw_rec_list *ptr));static symbolS *declare_register PARAMS ((const char *name, int regnum));static void declare_register_set PARAMS ((const char *, int, int));static unsigned int operand_width PARAMS ((enum ia64_opnd));static enum operand_match_result operand_match PARAMS ((const struct ia64_opcode *idesc,							int index,							expressionS *e));static int parse_operand PARAMS ((expressionS *e));static struct ia64_opcode * parse_operands PARAMS ((struct ia64_opcode *));static void build_insn PARAMS ((struct slot *, bfd_vma *));static void emit_one_bundle PARAMS ((void));static void fix_insn PARAMS ((fixS *, const struct ia64_operand *, valueT));static bfd_reloc_code_real_type ia64_gen_real_reloc_type PARAMS ((struct symbol *sym,								  bfd_reloc_code_real_type r_type));static void insn_group_break PARAMS ((int, int, int));static void mark_resource PARAMS ((struct ia64_opcode *, const struct ia64_dependency *,				   struct rsrc *, int depind, int path));static void add_qp_mutex PARAMS((valueT mask));static void add_qp_imply PARAMS((int p1, int p2));static void clear_qp_branch_flag PARAMS((valueT mask));static void clear_qp_mutex PARAMS((valueT mask));static void clear_qp_implies PARAMS((valueT p1_mask, valueT p2_mask));static void clear_register_values PARAMS ((void));static void print_dependency PARAMS ((const char *action, int depind));static void instruction_serialization PARAMS ((void));static void data_serialization PARAMS ((void));static void remove_marked_resource PARAMS ((struct rsrc *));static int is_conditional_branch PARAMS ((struct ia64_opcode *));static int is_taken_branch PARAMS ((struct ia64_opcode *));static int is_interruption_or_rfi PARAMS ((struct ia64_opcode *));static int depends_on PARAMS ((int, struct ia64_opcode *));static int specify_resource PARAMS ((const struct ia64_dependency *,				     struct ia64_opcode *, int, struct rsrc [], int, int));static int check_dv PARAMS((struct ia64_opcode *idesc));static void check_dependencies PARAMS((struct ia64_opcode *));static void mark_resources PARAMS((struct ia64_opcode *));static void update_dependencies PARAMS((struct ia64_opcode *));static void note_register_values PARAMS((struct ia64_opcode *));static int qp_mutex PARAMS ((int, int, int));static int resources_match PARAMS ((struct rsrc *, struct ia64_opcode *, int, int, int));static void output_vbyte_mem PARAMS ((int, char *, char *));static void count_output PARAMS ((int, char *, char *));static void output_R1_format PARAMS ((vbyte_func, unw_record_type, int));static void output_R2_format PARAMS ((vbyte_func, int, int, unsigned long));static void output_R3_format PARAMS ((vbyte_func, unw_record_type, unsigned long));static void output_P1_format PARAMS ((vbyte_func, int));static void output_P2_format PARAMS ((vbyte_func, int, int));static void output_P3_format PARAMS ((vbyte_func, unw_record_type, int));static void output_P4_format PARAMS ((vbyte_func, unsigned char *, unsigned long));static void output_P5_format PARAMS ((vbyte_func, int, unsigned long));static void output_P6_format PARAMS ((vbyte_func, unw_record_type, int));static void output_P7_format PARAMS ((vbyte_func, unw_record_type, unsigned long, unsigned long));static void output_P8_format PARAMS ((vbyte_func, unw_record_type, unsigned long));static void output_P9_format PARAMS ((vbyte_func, int, int));static void output_P10_format PARAMS ((vbyte_func, int, int));static void output_B1_format PARAMS ((vbyte_func, unw_record_type, unsigned long));static void output_B2_format PARAMS ((vbyte_func, unsigned long, unsigned long));static void output_B3_format PARAMS ((vbyte_func, unsigned long, unsigned long));static void output_B4_format PARAMS ((vbyte_func, unw_record_type, unsigned long));static char format_ab_reg PARAMS ((int, int));static void output_X1_format PARAMS ((vbyte_func, unw_record_type, int, int, unsigned long,				      unsigned long));static void output_X2_format PARAMS ((vbyte_func, int, int, int, int, int, unsigned long));static void output_X3_format PARAMS ((vbyte_func, unw_record_type, int, int, int, unsigned long,				      unsigned long));static void output_X4_format PARAMS ((vbyte_func, int, int, int, int, int, int, unsigned long));static void free_list_records PARAMS ((unw_rec_list *));static unw_rec_list *output_prologue PARAMS ((void));static unw_rec_list *output_prologue_gr PARAMS ((unsigned int, unsigned int));static unw_rec_list *output_body PARAMS ((void));static unw_rec_list *output_mem_stack_f PARAMS ((unsigned int));static unw_rec_list *output_mem_stack_v PARAMS ((void));static unw_rec_list *output_psp_gr PARAMS ((unsigned int));static unw_rec_list *output_psp_sprel PARAMS ((unsigned int));static unw_rec_list *output_rp_when PARAMS ((void));static unw_rec_list *output_rp_gr PARAMS ((unsigned int));static unw_rec_list *output_rp_br PARAMS ((unsigned int));static unw_rec_list *output_rp_psprel PARAMS ((unsigned int));static unw_rec_list *output_rp_sprel PARAMS ((unsigned int));static unw_rec_list *output_pfs_when PARAMS ((void));static unw_rec_list *output_pfs_gr PARAMS ((unsigned int));static unw_rec_list *output_pfs_psprel PARAMS ((unsigned int));static unw_rec_list *output_pfs_sprel PARAMS ((unsigned int));static unw_rec_list *output_preds_when PARAMS ((void));static unw_rec_list *output_preds_gr PARAMS ((unsigned int));static unw_rec_list *output_preds_psprel PARAMS ((unsigned int));static unw_rec_list *output_preds_sprel PARAMS ((unsigned int));static unw_rec_list *output_fr_mem PARAMS ((unsigned int));static unw_rec_list *output_frgr_mem PARAMS ((unsigned int, unsigned int));static unw_rec_list *output_gr_gr PARAMS ((unsigned int, unsigned int));static unw_rec_list *output_gr_mem PARAMS ((unsigned int));static unw_rec_list *output_br_mem PARAMS ((unsigned int));static unw_rec_list *output_br_gr PARAMS ((unsigned int, unsigned int));static unw_rec_list *output_spill_base PARAMS ((unsigned int));static unw_rec_list *output_unat_when PARAMS ((void));static unw_rec_list *output_unat_gr PARAMS ((unsigned int));static unw_rec_list *output_unat_psprel PARAMS ((unsigned int));static unw_rec_list *output_unat_sprel PARAMS ((unsigned int));static unw_rec_list *output_lc_when PARAMS ((void));static unw_rec_list *output_lc_gr PARAMS ((unsigned int));static unw_rec_list *output_lc_psprel PARAMS ((unsigned int));static unw_rec_list *output_lc_sprel PARAMS ((unsigned int));static unw_rec_list *output_fpsr_when PARAMS ((void));static unw_rec_list *output_fpsr_gr PARAMS ((unsigned int));static unw_rec_list *output_fpsr_psprel PARAMS ((unsigned int));static unw_rec_list *output_fpsr_sprel PARAMS ((unsigned int));static unw_rec_list *output_priunat_when_gr PARAMS ((void));static unw_rec_list *output_priunat_when_mem PARAMS ((void));static unw_rec_list *output_priunat_gr PARAMS ((unsigned int));static unw_rec_list *output_priunat_psprel PARAMS ((unsigned int));static unw_rec_list *output_priunat_sprel PARAMS ((unsigned int));static unw_rec_list *output_bsp_when PARAMS ((void));static unw_rec_list *output_bsp_gr PARAMS ((unsigned int));static unw_rec_list *output_bsp_psprel PARAMS ((unsigned int));static unw_rec_list *output_bsp_sprel PARAMS ((unsigned int));static unw_rec_list *output_bspstore_when PARAMS ((void));static unw_rec_list *output_bspstore_gr PARAMS ((unsigned int));static unw_rec_list *output_bspstore_psprel PARAMS ((unsigned int));static unw_rec_list *output_bspstore_sprel PARAMS ((unsigned int));static unw_rec_list *output_rnat_when PARAMS ((void));static unw_rec_list *output_rnat_gr PARAMS ((unsigned int));static unw_rec_list *output_rnat_psprel PARAMS ((unsigned int));static unw_rec_list *output_rnat_sprel PARAMS ((unsigned int));static unw_rec_list *output_unwabi PARAMS ((unsigned long, unsigned long));static unw_rec_list *output_epilogue PARAMS ((unsigned long));static unw_rec_list *output_label_state PARAMS ((unsigned long));static unw_rec_list *output_copy_state PARAMS ((unsigned long));static unw_rec_list *output_spill_psprel PARAMS ((unsigned int, unsigned int, unsigned int));static unw_rec_list *output_spill_sprel PARAMS ((unsigned int, unsigned int, unsigned int));static unw_rec_list *output_spill_psprel_p PARAMS ((unsigned int, unsigned int, unsigned int,						    unsigned int));static unw_rec_list *output_spill_sprel_p PARAMS ((unsigned int, unsigned int, unsigned int,						   unsigned int));static unw_rec_list *output_spill_reg PARAMS ((unsigned int, unsigned int, unsigned int,					       unsigned int));static unw_rec_list *output_spill_reg_p PARAMS ((unsigned int, unsigned int, unsigned int,						 unsigned int, unsigned int));static void process_one_record PARAMS ((unw_rec_list *, vbyte_func));static void process_unw_records PARAMS ((unw_rec_list *, vbyte_func));static int calc_record_size PARAMS ((unw_rec_list *));static void set_imask PARAMS ((unw_rec_list *, unsigned long, unsigned long, unsigned int));static int count_bits PARAMS ((unsigned long));static unsigned long slot_index PARAMS ((unsigned long, fragS *,					 unsigned long, fragS *));static unw_rec_list *optimize_unw_records PARAMS ((unw_rec_list *));static void fixup_unw_records PARAMS ((unw_rec_list *));static int output_unw_records PARAMS ((unw_rec_list *, void **));static int convert_expr_to_ab_reg PARAMS ((expressionS *, unsigned int *, unsigned int *));static int convert_expr_to_xy_reg PARAMS ((expressionS *, unsigned int *, unsigned int *));static int generate_unwind_image PARAMS ((const char *));/* Build the unwind section name by appending the (possibly stripped)   text section NAME to the unwind PREFIX.  The resulting string   pointer is assigned to RESULT.  The string is allocated on the   stack, so this must be a macro... */#define make_unw_section_name(special, text_name, result)		   \  {									   \    char *_prefix = special_section_name[special];			   \    size_t _prefix_len = strlen (_prefix), _text_len = strlen (text_name); \    char *_result = alloca (_prefix_len + _text_len + 1);		   \    memcpy(_result, _prefix, _prefix_len);				   \    memcpy(_result + _prefix_len, text_name, _text_len);		   \    _result[_prefix_len + _text_len] = '\0';				   \    result = _result;							   \  }									   \while (0)/* Determine if application register REGNUM resides in the integer   unit (as opposed to the memory unit).  */static intar_is_in_integer_unit (reg)     int reg;{  reg -= REG_AR;  return (reg == 64	/* pfs */	  || reg == 65	/* lc */	  || reg == 66	/* ec */	  /* ??? ias accepts and puts these in the integer unit.  */	  || (reg >= 112 && reg <= 127));}/* Switch to section NAME and create section if necessary.  It's   rather ugly that we have to manipulate input_line_pointer but I   don't see any other way to accomplish the same thing without   changing obj-elf.c (which may be the Right Thing, in the end).  */static voidset_section (name)     char *name;{  char *saved_input_line_pointer;  saved_input_line_pointer = input_line_pointer;  input_line_pointer = name;  obj_elf_section (0);  input_line_pointer = saved_input_line_pointer;}/* Map SHF_IA_64_SHORT to SEC_SMALL_DATA.  */flagwordia64_elf_section_flags (flags, attr, type)     flagword flags;     int attr, type ATTRIBUTE_UNUSED;{  if (attr & SHF_IA_64_SHORT)    flags |= SEC_SMALL_DATA;  return flags;}intia64_elf_section_type (str, len)	const char *str;	size_t len;{  len = sizeof (ELF_STRING_ia64_unwind_info) - 1;  if (strncmp (str, ELF_STRING_ia64_unwind_info, len) == 0)    return SHT_PROGBITS;  len = sizeof (ELF_STRING_ia64_unwind) - 1;  if (strncmp (str, ELF_STRING_ia64_unwind, len) == 0)    return SHT_IA_64_UNWIND;  return -1;}static unsigned intset_regstack (ins, locs, outs, rots)     unsigned int ins, locs, outs, rots;{  /* Size of frame.  */  unsigned int sof;  sof = ins + locs + outs;  if (sof > 96)    {      as_bad ("Size of frame exceeds maximum of 96 registers");      return 0;    }  if (rots > sof)    {      as_warn ("Size of rotating registers exceeds frame size");      return 0;    }  md.in.base = REG_GR + 32;  md.loc.base = md.in.base + ins;  md.out.base = md.loc.base + locs;  md.in.num_regs  = ins;  md.loc.num_regs = locs;  md.out.num_regs = outs;  md.rot.num_regs = rots;  return sof;}voidia64_flush_insns (){  struct label_fix *lfix;  segT saved_seg;  subsegT saved_subseg;  unw_rec_list *ptr;  if (!md.last_text_seg)    return;  saved_seg = now_seg;  saved_subseg = now_subseg;  subseg_set (md.last_text_seg, 0);  while (md.num_slots_in_use > 0)    emit_one_bundle ();		/* force out queued instructions */  /* In case there are labels following the last instruction, resolve     those now:  */  for (lfix = CURR_SLOT.label_fixups; lfix; lfix = lfix->next)    {      S_SET_VALUE (lfix->sym, frag_now_fix ());      symbol_set_frag (lfix->sym, frag_now);    }  CURR_SLOT.label_fixups = 0;  for (lfix = CURR_SLOT.tag_fixups; lfix; lfix = lfix->next)    {      S_SET_VALUE (lfix->sym, frag_now_fix ());      symbol_set_frag (lfix->sym, frag_now);    }  CURR_SLOT.tag_fixups = 0;  /* In case there are unwind directives following the last instruction,     resolve those now.  We only handle body and prologue directives here.     Give an error for others.  */  for (ptr = unwind.current_entry; ptr; ptr = ptr->next)    {      if (ptr->r.type == prologue || ptr->r.type == prologue_gr	  || ptr->r.type == body)	{	  ptr->slot_number = (unsigned long) frag_more (0);	  ptr->slot_frag = frag_now;	}      else	as_bad (_("Unwind directive not followed by an instruction."));    }  unwind.current_entry = NULL;  subseg_set (saved_seg, saved_subseg);  if (md.qp.X_op == O_register)

⌨️ 快捷键说明

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