📄 m68k.c
字号:
output_asm_insn ("scs %5\n\tjbra %l6", loperands);#else output_asm_insn ("scs %5\n\tjra %l6", loperands);#endif ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[4])); output_asm_insn ("slt %5", loperands); ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[6])); break; case LTU: ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[4])); output_asm_insn ("scs %5", loperands); break; case GE: loperands[6] = gen_label_rtx();#ifdef MOTOROLA output_asm_insn ("scc %5\n\tjbra %l6", loperands);#else output_asm_insn ("scc %5\n\tjra %l6", loperands);#endif ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[4])); output_asm_insn ("sge %5", loperands); ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[6])); break; case GEU: ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[4])); output_asm_insn ("scc %5", loperands); break; case LE: loperands[6] = gen_label_rtx();#ifdef MOTOROLA output_asm_insn ("sls %5\n\tjbra %l6", loperands);#else output_asm_insn ("sls %5\n\tjra %l6", loperands);#endif ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[4])); output_asm_insn ("sle %5", loperands); ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[6])); break; case LEU: ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (loperands[4])); output_asm_insn ("sls %5", loperands); break; default: abort (); } return "";}const char *output_btst (operands, countop, dataop, insn, signpos) rtx *operands; rtx countop, dataop; rtx insn; int signpos;{ operands[0] = countop; operands[1] = dataop; if (GET_CODE (countop) == CONST_INT) { register int count = INTVAL (countop); /* If COUNT is bigger than size of storage unit in use, advance to the containing unit of same size. */ if (count > signpos) { int offset = (count & ~signpos) / 8; count = count & signpos; operands[1] = dataop = adjust_address (dataop, QImode, offset); } if (count == signpos) cc_status.flags = CC_NOT_POSITIVE | CC_Z_IN_NOT_N; else cc_status.flags = CC_NOT_NEGATIVE | CC_Z_IN_NOT_N; /* These three statements used to use next_insns_test_no... but it appears that this should do the same job. */ if (count == 31 && next_insn_tests_no_inequality (insn)) return "tst%.l %1"; if (count == 15 && next_insn_tests_no_inequality (insn)) return "tst%.w %1"; if (count == 7 && next_insn_tests_no_inequality (insn)) return "tst%.b %1"; cc_status.flags = CC_NOT_NEGATIVE; } return "btst %0,%1";}/* Returns 1 if OP is either a symbol reference or a sum of a symbol reference and a constant. */intsymbolic_operand (op, mode) register rtx op; enum machine_mode mode ATTRIBUTE_UNUSED;{ 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);#if 0 /* Deleted, with corresponding change in m68k.h, so as to fit the specs. No CONST_DOUBLE is ever symbolic. */ case CONST_DOUBLE: return GET_MODE (op) == mode;#endif default: return 0; }}/* Check for sign_extend or zero_extend. Used for bit-count operands. */intextend_operator(x, mode) rtx x; enum machine_mode mode;{ if (mode != VOIDmode && GET_MODE(x) != mode) return 0; switch (GET_CODE(x)) { case SIGN_EXTEND : case ZERO_EXTEND : return 1; default : return 0; }}/* Legitimize PIC addresses. If the address is already position-independent, we return ORIG. Newly generated position-independent addresses go to REG. If we need more than one register, we lose. An address is legitimized by making an indirect reference through the Global Offset Table with the name of the symbol used as an offset. The assembler and linker are responsible for placing the address of the symbol in the GOT. The function prologue is responsible for initializing a5 to the starting address of the GOT. The assembler is also responsible for translating a symbol name into a constant displacement from the start of the GOT. A quick example may make things a little clearer: When not generating PIC code to store the value 12345 into _foo we would generate the following code: movel #12345, _foo When generating PIC two transformations are made. First, the compiler loads the address of foo into a register. So the first transformation makes: lea _foo, a0 movel #12345, a0@ The code in movsi will intercept the lea instruction and call this routine which will transform the instructions into: movel a5@(_foo:w), a0 movel #12345, a0@ That (in a nutshell) is how *all* symbol and label references are handled. */rtxlegitimize_pic_address (orig, mode, reg) rtx orig, reg; enum machine_mode mode ATTRIBUTE_UNUSED;{ rtx pic_ref = orig; /* First handle a simple SYMBOL_REF or LABEL_REF */ if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF) { if (reg == 0) abort (); pic_ref = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, pic_offset_table_rtx, orig)); current_function_uses_pic_offset_table = 1; RTX_UNCHANGING_P (pic_ref) = 1; emit_move_insn (reg, pic_ref); return reg; } else if (GET_CODE (orig) == CONST) { rtx base; /* Make sure this is CONST has not already been legitimized */ if (GET_CODE (XEXP (orig, 0)) == PLUS && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx) return orig; if (reg == 0) abort (); /* legitimize both operands of the PLUS */ if (GET_CODE (XEXP (orig, 0)) == PLUS) { base = legitimize_pic_address (XEXP (XEXP (orig, 0), 0), Pmode, reg); orig = legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode, base == reg ? 0 : reg); } else abort (); if (GET_CODE (orig) == CONST_INT) return plus_constant (base, INTVAL (orig)); pic_ref = gen_rtx_PLUS (Pmode, base, orig); /* Likewise, should we set special REG_NOTEs here? */ } return pic_ref;}typedef enum { MOVL, SWAP, NEGW, NOTW, NOTB, MOVQ } CONST_METHOD;static CONST_METHOD const_method PARAMS ((rtx));#define USE_MOVQ(i) ((unsigned)((i) + 128) <= 255)static CONST_METHODconst_method (constant) rtx constant;{ int i; unsigned u; i = INTVAL (constant); if (USE_MOVQ (i)) return MOVQ; /* The Coldfire doesn't have byte or word operations. */ /* FIXME: This may not be useful for the m68060 either */ if (!TARGET_5200) { /* if -256 < N < 256 but N is not in range for a moveq N^ff will be, so use moveq #N^ff, dreg; not.b dreg. */ if (USE_MOVQ (i ^ 0xff)) return NOTB; /* Likewise, try with not.w */ if (USE_MOVQ (i ^ 0xffff)) return NOTW; /* This is the only value where neg.w is useful */ if (i == -65408) return NEGW; /* Try also with swap */ u = i; if (USE_MOVQ ((u >> 16) | (u << 16))) return SWAP; } /* Otherwise, use move.l */ return MOVL;}intconst_int_cost (constant) rtx constant;{ switch (const_method (constant)) { case MOVQ : /* Constants between -128 and 127 are cheap due to moveq */ return 0; case NOTB : case NOTW : case NEGW : case SWAP : /* Constants easily generated by moveq + not.b/not.w/neg.w/swap */ return 1; case MOVL : return 2; default : abort (); }}const char *output_move_const_into_data_reg (operands) rtx *operands;{ int i; i = INTVAL (operands[1]); switch (const_method (operands[1])) { case MOVQ :#if defined (MOTOROLA) && !defined (CRDS) return "moveq%.l %1,%0";#else return "moveq %1,%0";#endif case NOTB : CC_STATUS_INIT; operands[1] = GEN_INT (i ^ 0xff);#if defined (MOTOROLA) && !defined (CRDS) return "moveq%.l %1,%0\n\tnot%.b %0";#else return "moveq %1,%0\n\tnot%.b %0";#endif case NOTW : CC_STATUS_INIT; operands[1] = GEN_INT (i ^ 0xffff);#if defined (MOTOROLA) && !defined (CRDS) return "moveq%.l %1,%0\n\tnot%.w %0";#else return "moveq %1,%0\n\tnot%.w %0";#endif case NEGW : CC_STATUS_INIT;#if defined (MOTOROLA) && !defined (CRDS) return "moveq%.l %#-128,%0\n\tneg%.w %0";#else return "moveq %#-128,%0\n\tneg%.w %0";#endif case SWAP : { unsigned u = i; operands[1] = GEN_INT ((u << 16) | (u >> 16));#if defined (MOTOROLA) && !defined (CRDS) return "moveq%.l %1,%0\n\tswap %0";#else return "moveq %1,%0\n\tswap %0";#endif } case MOVL : return "move%.l %1,%0"; default : abort (); }}const char *output_move_simode_const (operands) rtx *operands;{ if (operands[1] == const0_rtx && (DATA_REG_P (operands[0]) || GET_CODE (operands[0]) == MEM) /* clr insns on 68000 read before writing. This isn't so on the 68010, but we have no TARGET_68010. */ && ((TARGET_68020 || TARGET_5200) || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) return "clr%.l %0"; else if (operands[1] == const0_rtx && ADDRESS_REG_P (operands[0])) return "sub%.l %0,%0"; else if (DATA_REG_P (operands[0])) return output_move_const_into_data_reg (operands); else if (ADDRESS_REG_P (operands[0]) && INTVAL (operands[1]) < 0x8000 && INTVAL (operands[1]) >= -0x8000) return "move%.w %1,%0"; else if (GET_CODE (operands[0]) == MEM && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM && INTVAL (operands[1]) < 0x8000 && INTVAL (operands[1]) >= -0x8000) return "pea %a1"; return "move%.l %1,%0";}const char *output_move_simode (operands) rtx *operands;{ if (GET_CODE (operands[1]) == CONST_INT) return output_move_simode_const (operands); else if ((GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == CONST) && push_operand (operands[0], SImode)) return "pea %a1"; else if ((GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == CONST) && ADDRESS_REG_P (operands[0])) return "lea %a1,%0"; return "move%.l %1,%0";}const char *output_move_himode (operands) rtx *operands;{ if (GET_CODE (operands[1]) == CONST_INT) { if (operands[1] == const0_rtx && (DATA_REG_P (operands[0]) || GET_CODE (operands[0]) == MEM) /* clr insns on 68000 read before writing. This isn't so on the 68010, but we have no TARGET_68010. */ && ((TARGET_68020 || TARGET_5200) || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) return "clr%.w %0"; else if (operands[1] == const0_rtx && ADDRESS_REG_P (operands[0])) return "sub%.l %0,%0"; else if (DATA_REG_P (operands[0]) && INTVAL (operands[1]) < 128 && INTVAL (operands[1]) >= -128) {#if defined(MOTOROLA) && !defined(CRDS) return "moveq%.l %1,%0";#else return "moveq %1,%0";#endif } else if (INTVAL (operands[1]) < 0x8000 && INTVAL (operands[1]) >= -0x8000) return "move%.w %1,%0"; } else if (CONSTANT_P (operands[1])) return "move%.l %1,%0";#ifndef SGS_NO_LI /* Recognize the insn before a tablejump, one that refers to a table of offsets. Such an insn will need to refer to a label on the insn. So output one. Use the label-number of the table of offsets to generate this label. This code, and similar code below, assumes that there will be at most one reference to each table. */ if (GET_CODE (operands[1]) == MEM && GET_CODE (XEXP (operands[1], 0)) == PLUS && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS) { rtx labelref = XEXP (XEXP (operands[1], 0), 1);#if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES)#ifdef SGS asm_fprintf (asm_out_file, "\tset %LLI%d,.+2\n", CODE_LABEL_NUMBER (XEXP (labelref, 0)));#else /* not SGS */ asm_fprintf (asm_out_file, "\t.set %LLI%d,.+2\n", CODE_LABEL_NUMBER (XEXP (labelref, 0)));#endif /* not SGS */#else /* SGS_SWITCH_TABLES or not MOTOROLA */ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LI",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -