📄 pa.c
字号:
case PLUS_EXPR: case MINUS_EXPR: reloc = reloc_needed (TREE_OPERAND (exp, 0)); reloc |= reloc_needed (TREE_OPERAND (exp, 1)); break; case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR: reloc = reloc_needed (TREE_OPERAND (exp, 0)); break; case CONSTRUCTOR: { register tree link; for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) if (TREE_VALUE (link) != 0) reloc |= reloc_needed (TREE_VALUE (link)); } break; case ERROR_MARK: break; default: break; } return reloc;}/* Does operand (which is a symbolic_operand) live in text space? If so SYMBOL_REF_FLAG, which is set by ENCODE_SECTION_INFO, will be true. */intread_only_operand (operand, mode) rtx operand; enum machine_mode mode ATTRIBUTE_UNUSED;{ if (GET_CODE (operand) == CONST) operand = XEXP (XEXP (operand, 0), 0); if (flag_pic) { if (GET_CODE (operand) == SYMBOL_REF) return SYMBOL_REF_FLAG (operand) && !CONSTANT_POOL_ADDRESS_P (operand); } else { if (GET_CODE (operand) == SYMBOL_REF) return SYMBOL_REF_FLAG (operand) || CONSTANT_POOL_ADDRESS_P (operand); } return 1;}/* Return the best assembler insn template for moving operands[1] into operands[0] as a fullword. */const char *singlemove_string (operands) rtx *operands;{ HOST_WIDE_INT intval; if (GET_CODE (operands[0]) == MEM) return "stw %r1,%0"; if (GET_CODE (operands[1]) == MEM) return "ldw %1,%0"; if (GET_CODE (operands[1]) == CONST_DOUBLE) { long i; REAL_VALUE_TYPE d; if (GET_MODE (operands[1]) != SFmode) abort (); /* Translate the CONST_DOUBLE to a CONST_INT with the same target bit pattern. */ REAL_VALUE_FROM_CONST_DOUBLE (d, operands[1]); REAL_VALUE_TO_TARGET_SINGLE (d, i); operands[1] = GEN_INT (i); /* Fall through to CONST_INT case. */ } if (GET_CODE (operands[1]) == CONST_INT) { intval = INTVAL (operands[1]); if (VAL_14_BITS_P (intval)) return "ldi %1,%0"; else if ((intval & 0x7ff) == 0) return "ldil L'%1,%0"; else if (zdepi_cint_p (intval)) return "{zdepi %Z1,%0|depwi,z %Z1,%0}"; else return "ldil L'%1,%0\n\tldo R'%1(%0),%0"; } return "copy %1,%0";}/* Compute position (in OP[1]) and width (in OP[2]) useful for copying IMM to a register using the zdepi instructions. Store the immediate value to insert in OP[0]. */static voidcompute_zdepwi_operands (imm, op) unsigned HOST_WIDE_INT imm; unsigned *op;{ int lsb, len; /* Find the least significant set bit in IMM. */ for (lsb = 0; lsb < 32; lsb++) { if ((imm & 1) != 0) break; imm >>= 1; } /* Choose variants based on *sign* of the 5-bit field. */ if ((imm & 0x10) == 0) len = (lsb <= 28) ? 4 : 32 - lsb; else { /* Find the width of the bitstring in IMM. */ for (len = 5; len < 32; len++) { if ((imm & (1 << len)) == 0) break; } /* Sign extend IMM as a 5-bit value. */ imm = (imm & 0xf) - 0x10; } op[0] = imm; op[1] = 31 - lsb; op[2] = len;}/* Compute position (in OP[1]) and width (in OP[2]) useful for copying IMM to a register using the depdi,z instructions. Store the immediate value to insert in OP[0]. */voidcompute_zdepdi_operands (imm, op) unsigned HOST_WIDE_INT imm; unsigned *op;{ HOST_WIDE_INT lsb, len; /* Find the least significant set bit in IMM. */ for (lsb = 0; lsb < HOST_BITS_PER_WIDE_INT; lsb++) { if ((imm & 1) != 0) break; imm >>= 1; } /* Choose variants based on *sign* of the 5-bit field. */ if ((imm & 0x10) == 0) len = ((lsb <= HOST_BITS_PER_WIDE_INT - 4) ? 4 : HOST_BITS_PER_WIDE_INT - lsb); else { /* Find the width of the bitstring in IMM. */ for (len = 5; len < HOST_BITS_PER_WIDE_INT; len++) { if ((imm & ((unsigned HOST_WIDE_INT) 1 << len)) == 0) break; } /* Sign extend IMM as a 5-bit value. */ imm = (imm & 0xf) - 0x10; } op[0] = imm; op[1] = 63 - lsb; op[2] = len;}/* Output assembler code to perform a doubleword move insn with operands OPERANDS. */const char *output_move_double (operands) rtx *operands;{ enum { REGOP, OFFSOP, MEMOP, CNSTOP, RNDOP } optype0, optype1; rtx latehalf[2]; rtx addreg0 = 0, addreg1 = 0; /* First classify both operands. */ if (REG_P (operands[0])) optype0 = REGOP; else if (offsettable_memref_p (operands[0])) optype0 = OFFSOP; else if (GET_CODE (operands[0]) == MEM) optype0 = MEMOP; else optype0 = RNDOP; if (REG_P (operands[1])) optype1 = REGOP; else if (CONSTANT_P (operands[1])) optype1 = CNSTOP; else if (offsettable_memref_p (operands[1])) optype1 = OFFSOP; else if (GET_CODE (operands[1]) == MEM) optype1 = MEMOP; else optype1 = RNDOP; /* Check for the cases that the operand constraints are not supposed to allow to happen. Abort if we get one, because generating code for these cases is painful. */ if (optype0 != REGOP && optype1 != REGOP) abort (); /* Handle auto decrementing and incrementing loads and stores specifically, since the structure of the function doesn't work for them without major modification. Do it better when we learn this port about the general inc/dec addressing of PA. (This was written by tege. Chide him if it doesn't work.) */ if (optype0 == MEMOP) { /* We have to output the address syntax ourselves, since print_operand doesn't deal with the addresses we want to use. Fix this later. */ rtx addr = XEXP (operands[0], 0); if (GET_CODE (addr) == POST_INC || GET_CODE (addr) == POST_DEC) { rtx high_reg = gen_rtx_SUBREG (SImode, operands[1], 0); operands[0] = XEXP (addr, 0); if (GET_CODE (operands[1]) != REG || GET_CODE (operands[0]) != REG) abort (); if (!reg_overlap_mentioned_p (high_reg, addr)) { /* No overlap between high target register and address register. (We do this in a non-obvious way to save a register file writeback) */ if (GET_CODE (addr) == POST_INC) return "{stws|stw},ma %1,8(%0)\n\tstw %R1,-4(%0)"; return "{stws|stw},ma %1,-8(%0)\n\tstw %R1,12(%0)"; } else abort (); } else if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC) { rtx high_reg = gen_rtx_SUBREG (SImode, operands[1], 0); operands[0] = XEXP (addr, 0); if (GET_CODE (operands[1]) != REG || GET_CODE (operands[0]) != REG) abort (); if (!reg_overlap_mentioned_p (high_reg, addr)) { /* No overlap between high target register and address register. (We do this in a non-obvious way to save a register file writeback) */ if (GET_CODE (addr) == PRE_INC) return "{stws|stw},mb %1,8(%0)\n\tstw %R1,4(%0)"; return "{stws|stw},mb %1,-8(%0)\n\tstw %R1,4(%0)"; } else abort (); } } if (optype1 == MEMOP) { /* We have to output the address syntax ourselves, since print_operand doesn't deal with the addresses we want to use. Fix this later. */ rtx addr = XEXP (operands[1], 0); if (GET_CODE (addr) == POST_INC || GET_CODE (addr) == POST_DEC) { rtx high_reg = gen_rtx_SUBREG (SImode, operands[0], 0); operands[1] = XEXP (addr, 0); if (GET_CODE (operands[0]) != REG || GET_CODE (operands[1]) != REG) abort (); if (!reg_overlap_mentioned_p (high_reg, addr)) { /* No overlap between high target register and address register. (We do this in a non-obvious way to save a register file writeback) */ if (GET_CODE (addr) == POST_INC) return "{ldws|ldw},ma 8(%1),%0\n\tldw -4(%1),%R0"; return "{ldws|ldw},ma -8(%1),%0\n\tldw 12(%1),%R0"; } else { /* This is an undefined situation. We should load into the address register *and* update that register. Probably we don't need to handle this at all. */ if (GET_CODE (addr) == POST_INC) return "ldw 4(%1),%R0\n\t{ldws|ldw},ma 8(%1),%0"; return "ldw 4(%1),%R0\n\t{ldws|ldw},ma -8(%1),%0"; } } else if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC) { rtx high_reg = gen_rtx_SUBREG (SImode, operands[0], 0); operands[1] = XEXP (addr, 0); if (GET_CODE (operands[0]) != REG || GET_CODE (operands[1]) != REG) abort (); if (!reg_overlap_mentioned_p (high_reg, addr)) { /* No overlap between high target register and address register. (We do this in a non-obvious way to save a register file writeback) */ if (GET_CODE (addr) == PRE_INC) return "{ldws|ldw},mb 8(%1),%0\n\tldw 4(%1),%R0"; return "{ldws|ldw},mb -8(%1),%0\n\tldw 4(%1),%R0"; } else { /* This is an undefined situation. We should load into the address register *and* update that register. Probably we don't need to handle this at all. */ if (GET_CODE (addr) == PRE_INC) return "ldw 12(%1),%R0\n\t{ldws|ldw},mb 8(%1),%0"; return "ldw -4(%1),%R0\n\t{ldws|ldw},mb -8(%1),%0"; } } else if (GET_CODE (addr) == PLUS && GET_CODE (XEXP (addr, 0)) == MULT) { rtx high_reg = gen_rtx_SUBREG (SImode, operands[0], 0); if (!reg_overlap_mentioned_p (high_reg, addr)) { rtx xoperands[3]; xoperands[0] = high_reg; xoperands[1] = XEXP (addr, 1); xoperands[2] = XEXP (XEXP (addr, 0), 0); xoperands[3] = XEXP (XEXP (addr, 0), 1); output_asm_insn ("{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0}", xoperands); return "ldw 4(%0),%R0\n\tldw 0(%0),%0"; } else { rtx xoperands[3]; xoperands[0] = high_reg; xoperands[1] = XEXP (addr, 1); xoperands[2] = XEXP (XEXP (addr, 0), 0); xoperands[3] = XEXP (XEXP (addr, 0), 1); output_asm_insn ("{sh%O3addl %2,%1,%R0|shladd,l %2,%O3,%1,%R0}", xoperands); return "ldw 0(%R0),%0\n\tldw 4(%R0),%R0"; } } } /* If an operand is an unoffsettable memory ref, find a register we can increment temporarily to make it refer to the second word. */ if (optype0 == MEMOP) addreg0 = find_addr_reg (XEXP (operands[0], 0)); if (optype1 == MEMOP) addreg1 = find_addr_reg (XEXP (operands[1], 0)); /* Ok, we can do one word at a time. Normally we do the low-numbered word first. In either case, set up in LATEHALF the operands to use for the high-numbered word and in some cases alter the operands in OPERANDS to be suitable for the low-numbered word. */ if (optype0 == REGOP) latehalf[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1); else if (optype0 == OFFSOP) latehalf[0] = adjust_address (operands[0], SImode, 4); else latehalf[0] = operands[0]; if (optype1 == REGOP) latehalf[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1); else if (optype1 == OFFSOP) latehalf[1] = adjust_address (operands[1], SImode, 4); else if (optype1 == CNSTOP) split_double (operands[1], &operands[1], &latehalf[1]); else latehalf[1] = operands[1]; /* If the first move would clobber the source of the second one, do them in the other order. This can happen in two cases: mem -> register where the first half of the destination register is the same register used in the memory's address. Reload can create such insns. mem in this case will be either register indirect or register indirect plus a valid offset. register -> register move where REGNO(dst) == REGNO(src + 1) someone (Tim/Tege?) claimed this can happen for parameter loads. Handle mem -> register case first. */ if (optype0 == REGOP && (optype1 == MEMOP || optype1 == OFFSOP) && refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1, operands[1], 0)) { /* Do the late half first. */ if (addreg1) output_asm_insn ("ldo 4(%0),%0", &addreg1); output_asm_insn (singlemove_string (latehalf), latehalf); /* Then clobber. */ if (addreg1) output_asm_insn ("ldo -4(%0),%0", &addreg1); return singlemove_string (operands); } /* Now handle register -> register case. */ if (optype0 == REGOP && optype1 == REGOP && REGNO (operands[0]) == REGNO (operands[1]) + 1) { output_asm_insn (singlemove_string (latehalf), latehalf); return singlemove_string (operands); } /* Normal case: do the two words, low-numbered first. */ output_asm_insn (singlemove_string (operands), operands); /* Make any unoffsettable addresses point at high-numbered word. */ if (addreg0) output_asm_insn ("ldo 4(%0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -