📄 pa.c
字号:
/* Get the address of the memory location. PIC-ify it if necessary. */ temp = XEXP (temp, 0); if (flag_pic) temp = legitimize_pic_address (temp, mode, scratch_reg); /* Put the address of the memory location into our destination register. */ operands[1] = temp; emit_move_sequence (operands, mode, scratch_reg); /* Now load from the memory location into our destination register. */ operands[1] = gen_rtx_MEM (Pmode, operands[0]); emit_move_sequence (operands, mode, scratch_reg); /* And add back in the constant part. */ if (const_part != NULL_RTX) expand_inc (operand0, const_part); return 1; } if (flag_pic) { rtx temp; if (reload_in_progress || reload_completed) temp = scratch_reg ? scratch_reg : operand0; else temp = gen_reg_rtx (Pmode); /* (const (plus (symbol) (const_int))) must be forced to memory during/after reload if the const_int will not fit in 14 bits. */ if (GET_CODE (operand1) == CONST && GET_CODE (XEXP (operand1, 0)) == PLUS && GET_CODE (XEXP (XEXP (operand1, 0), 1)) == CONST_INT && !INT_14_BITS (XEXP (XEXP (operand1, 0), 1)) && (reload_completed || reload_in_progress) && flag_pic) { operands[1] = force_const_mem (mode, operand1); operands[1] = legitimize_pic_address (XEXP (operands[1], 0), mode, temp); emit_move_sequence (operands, mode, temp); } else { operands[1] = legitimize_pic_address (operand1, mode, temp); emit_insn (gen_rtx_SET (VOIDmode, operand0, operands[1])); } } /* On the HPPA, references to data space are supposed to use dp, register 27, but showing it in the RTL inhibits various cse and loop optimizations. */ else { rtx temp, set; if (reload_in_progress || reload_completed) temp = scratch_reg ? scratch_reg : operand0; else temp = gen_reg_rtx (mode); /* Loading a SYMBOL_REF into a register makes that register safe to be used as the base in an indexed address. Don't mark hard registers though. That loses. */ if (GET_CODE (operand0) == REG && REGNO (operand0) >= FIRST_PSEUDO_REGISTER) REGNO_POINTER_FLAG (REGNO (operand0)) = 1; if (REGNO (temp) >= FIRST_PSEUDO_REGISTER) REGNO_POINTER_FLAG (REGNO (temp)) = 1; if (ishighonly) set = gen_rtx_SET (mode, operand0, temp); else set = gen_rtx_SET (VOIDmode, operand0, gen_rtx_LO_SUM (mode, temp, operand1)); emit_insn (gen_rtx_SET (VOIDmode, temp, gen_rtx_HIGH (mode, operand1))); emit_insn (set); } return 1; } else if (GET_CODE (operand1) != CONST_INT || ! cint_ok_for_move (INTVAL (operand1))) { rtx temp; if (reload_in_progress || reload_completed) temp = operand0; else temp = gen_reg_rtx (mode); emit_insn (gen_rtx_SET (VOIDmode, temp, gen_rtx_HIGH (mode, operand1))); operands[1] = gen_rtx_LO_SUM (mode, temp, operand1); } } /* Now have insn-emit do whatever it normally does. */ return 0;}/* Examine EXP and return nonzero if it contains an ADDR_EXPR (meaning it will need a link/runtime reloc). */intreloc_needed (exp) tree exp;{ int reloc = 0; switch (TREE_CODE (exp)) { case ADDR_EXPR: return 1; 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) rtx operand;{ 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. */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"; 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]. */voidcompute_zdepi_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;}/* Output assembler code to perform a doubleword move insn with operands OPERANDS. */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,ma %1,8(%0)\n\tstw %R1,-4(%0)"; return "stws,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,mb %1,8(%0)\n\tstw %R1,4(%0)"; return "stws,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,ma 8(%1),%0\n\tldw -4(%1),%R0"; return "ldws,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\tldws,ma 8(%1),%0"; return "ldw 4(%1),%R0\n\tldws,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,mb 8(%1),%0\n\tldw 4(%1),%R0"; return "ldws,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\tldws,mb 8(%1),%0"; return "ldw -4(%1),%R0\n\tldws,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", 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", 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. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -