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

📄 m68hc11.c

📁 linux下编程用 编译软件
💻 C
📖 第 1 页 / 共 5 页
字号:
      rtx op = XEXP (operand, 0);      if (symbolic_memory_operand (op, mode))	return 1;    }  return 0;}intm68hc11_indirect_p (rtx operand, enum machine_mode mode){  if (GET_CODE (operand) == MEM && GET_MODE (operand) == mode)    {      rtx op = XEXP (operand, 0);      int addr_mode;      if (m68hc11_page0_symbol_p (op))        return 1;      if (symbolic_memory_operand (op, mode))	return TARGET_M6812;      if (reload_in_progress)        return 1;      operand = XEXP (operand, 0);      addr_mode = m68hc11_addr_mode | (reload_completed ? ADDR_STRICT : 0);      return m68hc11_valid_addressing_p (operand, mode, addr_mode);    }  return 0;}intmemory_indexed_operand (rtx operand, enum machine_mode mode ATTRIBUTE_UNUSED){  if (GET_CODE (operand) != MEM)    return 0;  operand = XEXP (operand, 0);  if (GET_CODE (operand) == PLUS)    {      if (GET_CODE (XEXP (operand, 0)) == REG)	operand = XEXP (operand, 0);      else if (GET_CODE (XEXP (operand, 1)) == REG)	operand = XEXP (operand, 1);    }  return GET_CODE (operand) == REG    && (REGNO (operand) >= FIRST_PSEUDO_REGISTER	|| A_REGNO_P (REGNO (operand)));}intpush_pop_operand_p (rtx operand){  if (GET_CODE (operand) != MEM)    {      return 0;    }  operand = XEXP (operand, 0);  return PUSH_POP_ADDRESS_P (operand);}/* Returns 1 if OP is either a symbol reference or a sum of a symbol   reference and a constant.  */intsymbolic_memory_operand (rtx op, enum machine_mode mode){  switch (GET_CODE (op))    {    case SYMBOL_REF:    case LABEL_REF:      return 1;    case CONST:      op = XEXP (op, 0);      return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF	       || GET_CODE (XEXP (op, 0)) == LABEL_REF)	      && GET_CODE (XEXP (op, 1)) == CONST_INT);      /* ??? This clause seems to be irrelevant.  */    case CONST_DOUBLE:      return GET_MODE (op) == mode;    case PLUS:      return symbolic_memory_operand (XEXP (op, 0), mode)	&& symbolic_memory_operand (XEXP (op, 1), mode);    default:      return 0;    }}/* Emit the code to build the trampoline used to call a nested function.      68HC11               68HC12   ldy #&CXT            movw #&CXT,*_.d1   sty *_.d1            jmp FNADDR   jmp FNADDR*/voidm68hc11_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt){  const char *static_chain_reg = reg_names[STATIC_CHAIN_REGNUM];  /* Skip the '*'.  */  if (*static_chain_reg == '*')    static_chain_reg++;  if (TARGET_M6811)    {      emit_move_insn (gen_rtx_MEM (HImode, tramp), GEN_INT (0x18ce));      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 2)), cxt);      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 4)),                      GEN_INT (0x18df));      emit_move_insn (gen_rtx_MEM (QImode, plus_constant (tramp, 6)),                      gen_rtx_CONST (QImode,                                     gen_rtx_SYMBOL_REF (Pmode,                                                         static_chain_reg)));      emit_move_insn (gen_rtx_MEM (QImode, plus_constant (tramp, 7)),                      GEN_INT (0x7e));      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 8)), fnaddr);    }  else    {      emit_move_insn (gen_rtx_MEM (HImode, tramp), GEN_INT (0x1803));      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 2)), cxt);      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 4)),                      gen_rtx_CONST (HImode,                                     gen_rtx_SYMBOL_REF (Pmode,                                                         static_chain_reg)));      emit_move_insn (gen_rtx_MEM (QImode, plus_constant (tramp, 6)),                      GEN_INT (0x06));      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 7)), fnaddr);    }}/* Declaration of types.  *//* Handle an "tiny_data" attribute; arguments as in   struct attribute_spec.handler.  */static treem68hc11_handle_page0_attribute (tree *node, tree name,                                tree args ATTRIBUTE_UNUSED,                                int flags ATTRIBUTE_UNUSED, bool *no_add_attrs){  tree decl = *node;  if (TREE_STATIC (decl) || DECL_EXTERNAL (decl))    {      DECL_SECTION_NAME (decl) = build_string (6, ".page0");    }  else    {      warning (OPT_Wattributes, "%qs attribute ignored",	       IDENTIFIER_POINTER (name));      *no_add_attrs = true;    }  return NULL_TREE;}const struct attribute_spec m68hc11_attribute_table[] ={  /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */  { "interrupt", 0, 0, false, true,  true,  m68hc11_handle_fntype_attribute },  { "trap",      0, 0, false, true,  true,  m68hc11_handle_fntype_attribute },  { "far",       0, 0, false, true,  true,  m68hc11_handle_fntype_attribute },  { "near",      0, 0, false, true,  true,  m68hc11_handle_fntype_attribute },  { "page0",     0, 0, false, false, false, m68hc11_handle_page0_attribute },  { NULL,        0, 0, false, false, false, NULL }};/* Keep track of the symbol which has a `trap' attribute and which uses   the `swi' calling convention.  Since there is only one trap, we only   record one such symbol.  If there are several, a warning is reported.  */static rtx trap_handler_symbol = 0;/* Handle an attribute requiring a FUNCTION_TYPE, FIELD_DECL or TYPE_DECL;   arguments as in struct attribute_spec.handler.  */static treem68hc11_handle_fntype_attribute (tree *node, tree name,                                 tree args ATTRIBUTE_UNUSED,                                 int flags ATTRIBUTE_UNUSED,                                 bool *no_add_attrs){  if (TREE_CODE (*node) != FUNCTION_TYPE      && TREE_CODE (*node) != METHOD_TYPE      && TREE_CODE (*node) != FIELD_DECL      && TREE_CODE (*node) != TYPE_DECL)    {      warning (OPT_Wattributes, "%qs attribute only applies to functions",	       IDENTIFIER_POINTER (name));      *no_add_attrs = true;    }  return NULL_TREE;}/* Undo the effects of the above.  */static const char *m68hc11_strip_name_encoding (const char *str){  return str + (*str == '*' || *str == '@' || *str == '&');}static voidm68hc11_encode_label (tree decl){  const char *str = XSTR (XEXP (DECL_RTL (decl), 0), 0);  int len = strlen (str);  char *newstr = alloca (len + 2);  newstr[0] = '@';  strcpy (&newstr[1], str);  XSTR (XEXP (DECL_RTL (decl), 0), 0) = ggc_alloc_string (newstr, len + 1);}/* Return 1 if this is a symbol in page0  */intm68hc11_page0_symbol_p (rtx x){  switch (GET_CODE (x))    {    case SYMBOL_REF:      return XSTR (x, 0) != 0 && XSTR (x, 0)[0] == '@';    case CONST:      return m68hc11_page0_symbol_p (XEXP (x, 0));    case PLUS:      if (!m68hc11_page0_symbol_p (XEXP (x, 0)))        return 0;      return GET_CODE (XEXP (x, 1)) == CONST_INT        && INTVAL (XEXP (x, 1)) < 256        && INTVAL (XEXP (x, 1)) >= 0;    default:      return 0;    }}/* We want to recognize trap handlers so that we handle calls to traps   in a special manner (by issuing the trap).  This information is stored   in SYMBOL_REF_FLAG.  */static voidm68hc11_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED){  tree func_attr;  int trap_handler;  int is_far = 0;    if (TREE_CODE (decl) == VAR_DECL)    {      if (lookup_attribute ("page0", DECL_ATTRIBUTES (decl)) != 0)        m68hc11_encode_label (decl);      return;    }  if (TREE_CODE (decl) != FUNCTION_DECL)    return;  func_attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));  if (lookup_attribute ("far", func_attr) != NULL_TREE)    is_far = 1;  else if (lookup_attribute ("near", func_attr) == NULL_TREE)    is_far = TARGET_LONG_CALLS != 0;  trap_handler = lookup_attribute ("trap", func_attr) != NULL_TREE;  if (trap_handler && is_far)    {      warning (OPT_Wattributes, "%<trap%> and %<far%> attributes are "	       "not compatible, ignoring %<far%>");      trap_handler = 0;    }  if (trap_handler)    {      if (trap_handler_symbol != 0)        warning (OPT_Wattributes, "%<trap%> attribute is already used");      else        trap_handler_symbol = XEXP (rtl, 0);    }  SYMBOL_REF_FLAG (XEXP (rtl, 0)) = is_far;}static unsigned intm68hc11_section_type_flags (tree decl, const char *name, int reloc){  unsigned int flags = default_section_type_flags (decl, name, reloc);  if (strncmp (name, ".eeprom", 7) == 0)    {      flags |= SECTION_WRITE | SECTION_CODE | SECTION_OVERRIDE;    }  return flags;}intm68hc11_is_far_symbol (rtx sym){  if (GET_CODE (sym) == MEM)    sym = XEXP (sym, 0);  return SYMBOL_REF_FLAG (sym);}intm68hc11_is_trap_symbol (rtx sym){  if (GET_CODE (sym) == MEM)    sym = XEXP (sym, 0);  return trap_handler_symbol != 0 && rtx_equal_p (trap_handler_symbol, sym);}/* Argument support functions.  *//* Define the offset between two registers, one to be eliminated, and the   other its replacement, at the start of a routine.  */intm68hc11_initial_elimination_offset (int from, int to){  int trap_handler;  tree func_attr;  int size;  int regno;  /* For a trap handler, we must take into account the registers which     are pushed on the stack during the trap (except the PC).  */  func_attr = TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl));  current_function_interrupt = lookup_attribute ("interrupt",						 func_attr) != NULL_TREE;  trap_handler = lookup_attribute ("trap", func_attr) != NULL_TREE;  if (lookup_attribute ("far", func_attr) != 0)    current_function_far = 1;  else if (lookup_attribute ("near", func_attr) != 0)    current_function_far = 0;  else    current_function_far = (TARGET_LONG_CALLS != 0                            && !current_function_interrupt                            && !trap_handler);  if (trap_handler && from == ARG_POINTER_REGNUM)    size = 7;  /* For a function using 'call/rtc' we must take into account the     page register which is pushed in the call.  */  else if (current_function_far && from == ARG_POINTER_REGNUM)    size = 1;  else    size = 0;  if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)    {      /* 2 is for the saved frame.         1 is for the 'sts' correction when creating the frame.  */      return get_frame_size () + 2 + m68hc11_sp_correction + size;    }  if (from == FRAME_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)    {      return m68hc11_sp_correction;    }  /* Push any 2 byte pseudo hard registers that we need to save.  */  for (regno = SOFT_REG_FIRST; regno < SOFT_REG_LAST; regno++)    {      if (regs_ever_live[regno] && !call_used_regs[regno])	{	  size += 2;	}    }  if (from == ARG_POINTER_REGNUM && to == HARD_SP_REGNUM)    {      return get_frame_size () + size;    }  if (from == FRAME_POINTER_REGNUM && to == HARD_SP_REGNUM)    {      return size;    }  return 0;}/* Initialize a variable CUM of type CUMULATIVE_ARGS   for a call to a function whose data type is FNTYPE.   For a library call, FNTYPE is 0.  */voidm68hc11_init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, rtx libname){  tree ret_type;  z_replacement_completed = 0;  cum->words = 0;  cum->nregs = 0;  /* For a library call, we must find out the type of the return value.     When the return value is bigger than 4 bytes, it is returned in     memory.  In that case, the first argument of the library call is a     pointer to the memory location.  Because the first argument is passed in     register D, we have to identify this, so that the first function     parameter is not passed in D either.  */  if (fntype == 0)    {      const char *name;      size_t len;      if (libname == 0 || GET_CODE (libname) != SYMBOL_REF)	return;      /* If the library ends in 'di' or in 'df', we assume it's         returning some DImode or some DFmode which are 64-bit wide.  */      name = XSTR (libname, 0);      len = strlen (name);      if (len > 3	  && ((name[len - 2] == 'd'	       && (name[len - 1] == 'f' || name[len - 1] == 'i'))	      || (name[len - 3] == 'd'		  && (name[len - 2] == 'i' || name[len - 2] == 'f'))))	{	  /* We are in.  Mark the first parameter register as already used.  */	  cum->words = 1;	  cum->nregs = 1;	}      return;    }  ret_type = TREE_TYPE (fntype);  if (ret_type && aggregate_value_p (ret_type, fntype))    {      cum->words = 1;      cum->nregs = 1;    }}/* Update the data in CUM to advance over an argument   of mode MODE and data type TYPE.   (TYPE is null for libcalls where that information may not be available.)  */voidm68hc11_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,                              tree type, int named ATTRIBUTE_UNUSED){  if (mode != BLKmode)    {      if (cum->words == 0 && GET_MODE_SIZE (mode) == 4)	{	  cum->nregs = 2;	  cum->words = GET_MODE_SIZE (mode);	}      else	{	  cum->words += GET_MODE_SIZE (mode);	  if (cum->words <= HARD_REG_SIZE)	    cum->nregs = 1;	}    }  else    {      cum->words += int_size_in_bytes (type);    }  return;}/* Define where to put the arguments to a function.   Value is zero to push the argument on the stack,   or a hard register in which to store the argument.   MODE is the argument's machine mode.

⌨️ 快捷键说明

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