📄 alpha.c
字号:
Take into account what reload will do. We could say that out-of-range stack slots are alignable, but that would complicate get_aligned_mem and it isn't worth the trouble since few functions have large stack space. */intaligned_memory_operand (op, mode) register rtx op; enum machine_mode mode;{ if (GET_CODE (op) == SUBREG) { if (GET_MODE (op) != mode) return 0; op = SUBREG_REG (op); mode = GET_MODE (op); } if (reload_in_progress && GET_CODE (op) == REG && REGNO (op) >= FIRST_PSEUDO_REGISTER) op = reg_equiv_mem[REGNO (op)]; if (GET_CODE (op) != MEM || GET_MODE (op) != mode || ! memory_address_p (mode, XEXP (op, 0))) return 0; op = XEXP (op, 0); if (GET_CODE (op) == PLUS) op = XEXP (op, 0); return (GET_CODE (op) == REG && (REGNO (op) == STACK_POINTER_REGNUM || op == hard_frame_pointer_rtx || (REGNO (op) >= FIRST_VIRTUAL_REGISTER && REGNO (op) <= LAST_VIRTUAL_REGISTER)));}/* Similar, but return 1 if OP is a MEM which is not alignable. */intunaligned_memory_operand (op, mode) register rtx op; enum machine_mode mode;{ if (GET_CODE (op) == SUBREG) { if (GET_MODE (op) != mode) return 0; op = SUBREG_REG (op); mode = GET_MODE (op); } if (reload_in_progress && GET_CODE (op) == REG && REGNO (op) >= FIRST_PSEUDO_REGISTER) op = reg_equiv_mem[REGNO (op)]; if (GET_CODE (op) != MEM || GET_MODE (op) != mode) return 0; op = XEXP (op, 0); if (! memory_address_p (mode, op)) return 1; if (GET_CODE (op) == PLUS) op = XEXP (op, 0); return (GET_CODE (op) != REG || (REGNO (op) != STACK_POINTER_REGNUM && op != hard_frame_pointer_rtx && (REGNO (op) < FIRST_VIRTUAL_REGISTER || REGNO (op) > LAST_VIRTUAL_REGISTER)));}/* Return 1 if OP is any memory location. During reload a pseudo matches. */intany_memory_operand (op, mode) register rtx op; enum machine_mode mode;{ return (GET_CODE (op) == MEM || (GET_CODE (op) == SUBREG && GET_CODE (SUBREG_REG (op)) == REG) || (reload_in_progress && GET_CODE (op) == REG && REGNO (op) >= FIRST_PSEUDO_REGISTER) || (reload_in_progress && GET_CODE (op) == SUBREG && GET_CODE (SUBREG_REG (op)) == REG && REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER));}/* REF is an alignable memory location. Place an aligned SImode reference into *PALIGNED_MEM and the number of bits to shift into *PBITNUM. */voidget_aligned_mem (ref, paligned_mem, pbitnum) rtx ref; rtx *paligned_mem, *pbitnum;{ rtx base; HOST_WIDE_INT offset = 0; if (GET_CODE (ref) == SUBREG) { offset = SUBREG_WORD (ref) * UNITS_PER_WORD; if (BYTES_BIG_ENDIAN) offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (ref))) - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (ref))))); ref = SUBREG_REG (ref); } if (GET_CODE (ref) == REG) ref = reg_equiv_mem[REGNO (ref)]; if (reload_in_progress) base = find_replacement (&XEXP (ref, 0)); else base = XEXP (ref, 0); if (GET_CODE (base) == PLUS) offset += INTVAL (XEXP (base, 1)), base = XEXP (base, 0); *paligned_mem = gen_rtx (MEM, SImode, plus_constant (base, offset & ~3)); MEM_IN_STRUCT_P (*paligned_mem) = MEM_IN_STRUCT_P (ref); MEM_VOLATILE_P (*paligned_mem) = MEM_VOLATILE_P (ref); RTX_UNCHANGING_P (*paligned_mem) = RTX_UNCHANGING_P (ref); *pbitnum = GEN_INT ((offset & 3) * 8);}/* Similar, but just get the address. Handle the two reload cases. */rtxget_unaligned_address (ref) rtx ref;{ rtx base; HOST_WIDE_INT offset = 0; if (GET_CODE (ref) == SUBREG) { offset = SUBREG_WORD (ref) * UNITS_PER_WORD; if (BYTES_BIG_ENDIAN) offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (ref))) - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (ref))))); ref = SUBREG_REG (ref); } if (GET_CODE (ref) == REG) ref = reg_equiv_mem[REGNO (ref)]; if (reload_in_progress) base = find_replacement (&XEXP (ref, 0)); else base = XEXP (ref, 0); if (GET_CODE (base) == PLUS) offset += INTVAL (XEXP (base, 1)), base = XEXP (base, 0); return plus_constant (base, offset);}/* Subfunction of the following function. Update the flags of any MEM found in part of X. */static voidalpha_set_memflags_1 (x, in_struct_p, volatile_p, unchanging_p) rtx x; int in_struct_p, volatile_p, unchanging_p;{ int i; switch (GET_CODE (x)) { case SEQUENCE: case PARALLEL: for (i = XVECLEN (x, 0) - 1; i >= 0; i--) alpha_set_memflags_1 (XVECEXP (x, 0, i), in_struct_p, volatile_p, unchanging_p); break; case INSN: alpha_set_memflags_1 (PATTERN (x), in_struct_p, volatile_p, unchanging_p); break; case SET: alpha_set_memflags_1 (SET_DEST (x), in_struct_p, volatile_p, unchanging_p); alpha_set_memflags_1 (SET_SRC (x), in_struct_p, volatile_p, unchanging_p); break; case MEM: MEM_IN_STRUCT_P (x) = in_struct_p; MEM_VOLATILE_P (x) = volatile_p; RTX_UNCHANGING_P (x) = unchanging_p; break; }}/* Given INSN, which is either an INSN or a SEQUENCE generated to perform a memory operation, look for any MEMs in either a SET_DEST or a SET_SRC and copy the in-struct, unchanging, and volatile flags from REF into each of the MEMs found. If REF is not a MEM, don't do anything. */voidalpha_set_memflags (insn, ref) rtx insn; rtx ref;{ /* Note that it is always safe to get these flags, though they won't be what we think if REF is not a MEM. */ int in_struct_p = MEM_IN_STRUCT_P (ref); int volatile_p = MEM_VOLATILE_P (ref); int unchanging_p = RTX_UNCHANGING_P (ref); if (GET_CODE (ref) != MEM || (! in_struct_p && ! volatile_p && ! unchanging_p)) return; alpha_set_memflags_1 (insn, in_struct_p, volatile_p, unchanging_p);}/* Try to output insns to set TARGET equal to the constant C if it can be done in less than N insns. Do all computations in MODE. Returns the place where the output has been placed if it can be done and the insns have been emitted. If it would take more than N insns, zero is returned and no insns and emitted. */rtxalpha_emit_set_const (target, mode, c, n) rtx target; enum machine_mode mode; HOST_WIDE_INT c; int n;{ HOST_WIDE_INT new = c; int i, bits; /* Use a pseudo if highly optimizing and still generating RTL. */ rtx subtarget = (flag_expensive_optimizations && rtx_equal_function_value_matters ? 0 : target); rtx temp;#if HOST_BITS_PER_WIDE_INT == 64 /* We are only called for SImode and DImode. If this is SImode, ensure that we are sign extended to a full word. This does not make any sense when cross-compiling on a narrow machine. */ if (mode == SImode) c = (c & 0xffffffff) - 2 * (c & 0x80000000);#endif /* If this is a sign-extended 32-bit constant, we can do this in at most three insns, so do it if we have enough insns left. We always have a sign-extended 32-bit constant when compiling on a narrow machine. Note that we cannot handle the constant 0x80000000. */ if ((HOST_BITS_PER_WIDE_INT != 64 || c >> 31 == -1 || c >> 31 == 0) && c != 0x80000000U) { HOST_WIDE_INT low = (c & 0xffff) - 2 * (c & 0x8000); HOST_WIDE_INT tmp1 = c - low; HOST_WIDE_INT high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000); HOST_WIDE_INT extra = 0; /* If HIGH will be interpreted as negative but the constant is positive, we must adjust it to do two ldha insns. */ if ((high & 0x8000) != 0 && c >= 0) { extra = 0x4000; tmp1 -= 0x40000000; high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000); } if (c == low || (low == 0 && extra == 0)) return copy_to_suggested_reg (GEN_INT (c), target, mode); else if (n >= 2 + (extra != 0) /* We can't do this when SImode if HIGH required adjustment. This is because the code relies on an implicit overflow which is invisible to the RTL. We can thus get incorrect code if the two ldah instructions are combined. */ && ! (mode == SImode && extra != 0)) { temp = copy_to_suggested_reg (GEN_INT (low), subtarget, mode); if (extra != 0) temp = expand_binop (mode, add_optab, temp, GEN_INT (extra << 16), subtarget, 0, OPTAB_WIDEN); return expand_binop (mode, add_optab, temp, GEN_INT (high << 16), target, 0, OPTAB_WIDEN); } } /* If we couldn't do it that way, try some other methods. But if we have no instructions left, don't bother. Likewise, if this is SImode and we can't make pseudos, we can't do anything since the expand_binop and expand_unop calls will widen and try to make pseudos. */ if (n == 1 || (mode == SImode && ! rtx_equal_function_value_matters)) return 0;#if HOST_BITS_PER_WIDE_INT == 64 /* First, see if can load a value into the target that is the same as the constant except that all bytes that are 0 are changed to be 0xff. If we can, then we can do a ZAPNOT to obtain the desired constant. */ for (i = 0; i < 64; i += 8) if ((new & ((HOST_WIDE_INT) 0xff << i)) == 0) new |= (HOST_WIDE_INT) 0xff << i; /* We are only called for SImode and DImode. If this is SImode, ensure that we are sign extended to a full word. */ if (mode == SImode) new = (new & 0xffffffff) - 2 * (new & 0x80000000); if (new != c && (temp = alpha_emit_set_const (subtarget, mode, new, n - 1)) != 0) return expand_binop (mode, and_optab, temp, GEN_INT (c | ~ new), target, 0, OPTAB_WIDEN);#endif /* Next, see if we can load a related constant and then shift and possibly negate it to get the constant we want. Try this once each increasing numbers of insns. */ for (i = 1; i < n; i++) { /* First try complementing. */ if ((temp = alpha_emit_set_const (subtarget, mode, ~ c, i)) != 0) return expand_unop (mode, one_cmpl_optab, temp, target, 0); /* Next try to form a constant and do a left shift. We can do this if some low-order bits are zero; the exact_log2 call below tells us that information. The bits we are shifting out could be any value, but here we'll just try the 0- and sign-extended forms of the constant. To try to increase the chance of having the same constant in more than one insn, start at the highest number of bits to shift, but try all possibilities in case a ZAPNOT will be useful. */ if ((bits = exact_log2 (c & - c)) > 0) for (; bits > 0; bits--) if ((temp = (alpha_emit_set_const (subtarget, mode, (unsigned HOST_WIDE_INT) c >> bits, i))) != 0 || ((temp = (alpha_emit_set_const (subtarget, mode, ((unsigned HOST_WIDE_INT) c) >> bits, i))) != 0)) return expand_binop (mode, ashl_optab, temp, GEN_INT (bits), target, 0, OPTAB_WIDEN); /* Now try high-order zero bits. Here we try the shifted-in bits as all zero and all ones. Be careful to avoid shifting outside the mode and to avoid shifting outside the host wide int size. */ if ((bits = (MIN (HOST_BITS_PER_WIDE_INT, GET_MODE_SIZE (mode) * 8) - floor_log2 (c) - 1)) > 0) for (; bits > 0; bits--) if ((temp = alpha_emit_set_const (subtarget, mode, c << bits, i)) != 0 || ((temp = (alpha_emit_set_const (subtarget, mode, ((c << bits) | (((HOST_WIDE_INT) 1 << bits) - 1)), i))) != 0)) return expand_binop (mode, lshr_optab, temp, GEN_INT (bits), target, 1, OPTAB_WIDEN); /* Now try high-order 1 bits. We get that with a sign-extension. But one bit isn't enough here. Be careful to avoid shifting outside the mode and to avoid shifting outside the host wide int size. */ if ((bits = (MIN (HOST_BITS_PER_WIDE_INT, GET_MODE_SIZE (mode) * 8) - floor_log2 (~ c) - 2)) > 0) for (; bits > 0; bits--) if ((temp = alpha_emit_set_const (subtarget, mode, c << bits, i)) != 0 || ((temp = (alpha_emit_set_const (subtarget, mode, ((c << bits) | (((HOST_WIDE_INT) 1 << bits) - 1)), i))) != 0)) return expand_binop (mode, ashr_optab, temp, GEN_INT (bits), target, 0, OPTAB_WIDEN); } return 0;}/* Adjust the cost of a scheduling dependency. Return the new cost of a dependency LINK or INSN on DEP_INSN. COST is the current cost. */intalpha_adjust_cost (insn, link, dep_insn, cost) rtx insn; rtx link; rtx dep_insn; int cost;{ rtx set; /* If the dependence is an anti-dependence, there is no cost. For an output dependence, there is sometimes a cost, but it doesn't seem worth handling those few cases. */ if (REG_NOTE_KIND (link) != 0) return 0; /* If INSN is a store insn and DEP_INSN is setting the data being stored, we can sometimes lower the cost. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -