📄 sh.md
字号:
"" [(set_attr "type" "arith_media") (set_attr "highpart" "ignore")])(define_split [(set (match_operand:SI 0 "arith_reg_dest" "") (zero_extend:SI (subreg:QI (not:SI (subreg:SI (match_operand:QI 1 "general_extend_operand" "") 0)) 0)))] "TARGET_SHMEDIA && TARGET_LITTLE_ENDIAN" [(set (match_dup 0) (zero_extend:SI (match_dup 1))) (set (match_dup 0) (xor:SI (match_dup 0) (const_int 255)))] "")(define_split [(set (match_operand:SI 0 "arith_reg_dest" "") (zero_extend:SI (subreg:QI (not:SI (subreg:SI (match_operand:QI 1 "general_extend_operand" "") 0)) 3)))] "TARGET_SHMEDIA && ! TARGET_LITTLE_ENDIAN" [(set (match_dup 0) (zero_extend:SI (match_dup 1))) (set (match_dup 0) (xor:SI (match_dup 0) (const_int 255)))] "");; Convert `constant - reg' to `neg rX; add rX, #const' since this;; will sometimes save one instruction. Otherwise we might get;; `mov #const, rY; sub rY,rX; mov rX, rY' if the source and dest regs;; are the same.(define_expand "subsi3" [(set (match_operand:SI 0 "arith_reg_operand" "") (minus:SI (match_operand:SI 1 "arith_operand" "") (match_operand:SI 2 "arith_reg_operand" "")))] "" "{ if (TARGET_SH1 && GET_CODE (operands[1]) == CONST_INT) { emit_insn (gen_negsi2 (operands[0], operands[2])); emit_insn (gen_addsi3 (operands[0], operands[0], operands[1])); DONE; } if (TARGET_SHMEDIA) { if (no_new_pseudos && ! arith_reg_or_0_operand (operands[1], SImode)) FAIL; if (operands[1] != const0_rtx && GET_CODE (operands[1]) != SUBREG) operands[1] = force_reg (SImode, operands[1]); }}");; -------------------------------------------------------------------------;; Division instructions;; -------------------------------------------------------------------------;; We take advantage of the library routines which don't clobber as many;; registers as a normal function call would.;; The INSN_REFERENCES_ARE_DELAYED in sh.h is problematic because it;; also has an effect on the register that holds the address of the sfunc.;; To make this work, we have an extra dummy insn that shows the use;; of this register for reorg.(define_insn "use_sfunc_addr" [(set (reg:SI PR_REG) (unspec:SI [(match_operand:SI 0 "register_operand" "r")] UNSPEC_SFUNC))] "TARGET_SH1 && check_use_sfunc_addr (insn, operands[0])" "" [(set_attr "length" "0")])(define_insn "udivsi3_sh2a" [(set (match_operand:SI 0 "arith_reg_dest" "=r") (udiv:SI (match_operand:SI 1 "arith_reg_operand" "0") (match_operand:SI 2 "arith_reg_operand" "z")))] "TARGET_SH2A" "divu %2,%1" [(set_attr "type" "arith") (set_attr "in_delay_slot" "no")]);; We must use a pseudo-reg forced to reg 0 in the SET_DEST rather than;; hard register 0. If we used hard register 0, then the next instruction;; would be a move from hard register 0 to a pseudo-reg. If the pseudo-reg;; gets allocated to a stack slot that needs its address reloaded, then;; there is nothing to prevent reload from using r0 to reload the address.;; This reload would clobber the value in r0 we are trying to store.;; If we let reload allocate r0, then this problem can never happen.(define_insn "udivsi3_i1" [(set (match_operand:SI 0 "register_operand" "=z") (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_REG)) (clobber (reg:SI PR_REG)) (clobber (reg:SI R4_REG)) (use (match_operand:SI 1 "arith_reg_operand" "r"))] "TARGET_SH1 && ! TARGET_SH4" "jsr @%1%#" [(set_attr "type" "sfunc") (set_attr "needs_delay_slot" "yes")]); Since shmedia-nofpu code could be linked against shcompact code, and; the udivsi3 libcall has the same name, we must consider all registers; clobbered that are in the union of the registers clobbered by the; shmedia and the shcompact implementation. Note, if the shcompact; implementation actually used shcompact code, we'd need to clobber; also r23 and fr23.(define_insn "udivsi3_i1_media" [(set (match_operand:SI 0 "register_operand" "=z") (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_MEDIA_REG)) (clobber (reg:SI PR_MEDIA_REG)) (clobber (reg:SI R20_REG)) (clobber (reg:SI R21_REG)) (clobber (reg:SI R22_REG)) (clobber (reg:DI TR0_REG)) (clobber (reg:DI TR1_REG)) (clobber (reg:DI TR2_REG)) (use (match_operand 1 "target_operand" "b"))] "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)" "blink %1, r18" [(set_attr "type" "sfunc") (set_attr "needs_delay_slot" "yes")])(define_expand "udivsi3_i4_media" [(set (match_dup 3) (zero_extend:DI (match_operand:SI 1 "register_operand" ""))) (set (match_dup 4) (zero_extend:DI (match_operand:SI 2 "register_operand" ""))) (set (match_dup 5) (float:DF (match_dup 3))) (set (match_dup 6) (float:DF (match_dup 4))) (set (match_dup 7) (div:DF (match_dup 5) (match_dup 6))) (set (match_dup 8) (fix:DI (match_dup 7))) (set (match_operand:SI 0 "register_operand" "") (truncate:SI (match_dup 8)))] "TARGET_SHMEDIA_FPU" "{ operands[3] = gen_reg_rtx (DImode); operands[4] = gen_reg_rtx (DImode); operands[5] = gen_reg_rtx (DFmode); operands[6] = gen_reg_rtx (DFmode); operands[7] = gen_reg_rtx (DFmode); operands[8] = gen_reg_rtx (DImode);}")(define_insn "udivsi3_i4" [(set (match_operand:SI 0 "register_operand" "=y") (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_REG)) (clobber (reg:SI PR_REG)) (clobber (reg:DF DR0_REG)) (clobber (reg:DF DR2_REG)) (clobber (reg:DF DR4_REG)) (clobber (reg:SI R0_REG)) (clobber (reg:SI R1_REG)) (clobber (reg:SI R4_REG)) (clobber (reg:SI R5_REG)) (use (reg:PSI FPSCR_REG)) (use (match_operand:SI 1 "arith_reg_operand" "r"))] "TARGET_SH4 && ! TARGET_FPU_SINGLE" "jsr @%1%#" [(set_attr "type" "sfunc") (set_attr "fp_mode" "double") (set_attr "needs_delay_slot" "yes")])(define_insn "udivsi3_i4_single" [(set (match_operand:SI 0 "register_operand" "=y") (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_REG)) (clobber (reg:SI PR_REG)) (clobber (reg:DF DR0_REG)) (clobber (reg:DF DR2_REG)) (clobber (reg:DF DR4_REG)) (clobber (reg:SI R0_REG)) (clobber (reg:SI R1_REG)) (clobber (reg:SI R4_REG)) (clobber (reg:SI R5_REG)) (use (match_operand:SI 1 "arith_reg_operand" "r"))] "(TARGET_HARD_SH4 || TARGET_SHCOMPACT) && TARGET_FPU_SINGLE" "jsr @%1%#" [(set_attr "type" "sfunc") (set_attr "needs_delay_slot" "yes")])(define_expand "udivsi3" [(set (match_dup 3) (symbol_ref:SI "__udivsi3")) (set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" "")) (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" "")) (parallel [(set (match_operand:SI 0 "register_operand" "") (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_REG)) (clobber (reg:SI PR_REG)) (clobber (reg:SI R4_REG)) (use (match_dup 3))])] "" "{ rtx first, last; operands[3] = gen_reg_rtx (Pmode); /* Emit the move of the address to a pseudo outside of the libcall. */ if (TARGET_HARD_SH4 && TARGET_SH2E) { function_symbol (operands[3], \"__udivsi3_i4\", SFUNC_STATIC); if (TARGET_FPU_SINGLE) last = gen_udivsi3_i4_single (operands[0], operands[3]); else last = gen_udivsi3_i4 (operands[0], operands[3]); } else if (TARGET_SHMEDIA_FPU) { operands[1] = force_reg (SImode, operands[1]); operands[2] = force_reg (SImode, operands[2]); emit_insn (gen_udivsi3_i4_media (operands[0], operands[1], operands[2])); DONE; } else if (TARGET_SH2A) { operands[1] = force_reg (SImode, operands[1]); operands[2] = force_reg (SImode, operands[2]); emit_insn (gen_udivsi3_sh2a (operands[0], operands[1], operands[2])); DONE; } else if (TARGET_SH5) { function_symbol (operands[3], TARGET_FPU_ANY ? \"__udivsi3_i4\" : \"__udivsi3\", SFUNC_STATIC); if (TARGET_SHMEDIA) last = gen_udivsi3_i1_media (operands[0], operands[3]); else if (TARGET_FPU_ANY) last = gen_udivsi3_i4_single (operands[0], operands[3]); else last = gen_udivsi3_i1 (operands[0], operands[3]); } else { function_symbol (operands[3], \"__udivsi3\", SFUNC_STATIC); last = gen_udivsi3_i1 (operands[0], operands[3]); } first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]); emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]); last = emit_insn (last); /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop invariant code motion can move it. */ REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first)); REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last)); DONE;}")(define_insn "divsi3_sh2a" [(set (match_operand:SI 0 "arith_reg_dest" "=r") (div:SI (match_operand:SI 1 "arith_reg_operand" "0") (match_operand:SI 2 "arith_reg_operand" "z")))] "TARGET_SH2A" "divs %2,%1" [(set_attr "type" "arith") (set_attr "in_delay_slot" "no")])(define_insn "divsi3_i1" [(set (match_operand:SI 0 "register_operand" "=z") (div:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_REG)) (clobber (reg:SI PR_REG)) (clobber (reg:SI R1_REG)) (clobber (reg:SI R2_REG)) (clobber (reg:SI R3_REG)) (use (match_operand:SI 1 "arith_reg_operand" "r"))] "TARGET_SH1 && ! TARGET_SH4" "jsr @%1%#" [(set_attr "type" "sfunc") (set_attr "needs_delay_slot" "yes")])(define_insn "divsi3_i1_media" [(set (match_operand:SI 0 "register_operand" "=z") (div:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_MEDIA_REG)) (clobber (reg:SI PR_MEDIA_REG)) (clobber (reg:SI R1_REG)) (clobber (reg:SI R20_REG)) (clobber (reg:SI R21_REG)) (clobber (reg:SI TR0_REG)) (use (match_operand 1 "target_operand" "b"))] "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)" "blink %1, r18" [(set_attr "type" "sfunc")])(define_insn "divsi3_media_2" [(set (match_operand:SI 0 "register_operand" "=z") (div:SI (reg:SI R4_REG) (reg:SI R5_REG))) (clobber (reg:SI T_MEDIA_REG)) (clobber (reg:SI PR_MEDIA_REG)) (clobber (reg:SI R1_REG)) (clobber (reg:SI R21_REG)) (clobber (reg:SI TR0_REG)) (use (reg:SI R20_REG)) (use (match_operand 1 "target_operand" "b"))] "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)" "blink %1, r18" [(set_attr "type" "sfunc")]);; This pattern acts as a placeholder for -mdiv=inv:call to carry;; hard reg clobbers and data dependencies that we need when we want;; to rematerialize the division into a call.(define_insn_and_split "divsi_inv_call" [(set (match_operand:SI 0 "register_operand" "=r") (div:SI (match_operand:SI 1 "register_operand" "r") (match_operand:SI 2 "register_operand" "r"))) (clobber (reg:SI R4_REG)) (clobber (reg:SI R5_REG)) (clobber (reg:SI T_MEDIA_REG)) (clobber (reg:SI PR_MEDIA_REG)) (clobber (reg:SI R1_REG)) (clobber (reg:SI R21_REG)) (clobber (reg:SI TR0_REG)) (clobber (reg:SI R20_REG)) (use (match_operand:SI 3 "register_operand" "r"))] "TARGET_SHMEDIA" "#" "&& (high_life_started || reload_completed)" [(set (match_dup 0) (match_dup 3))] "" [(set_attr "highpart" "must_split")]);; This is the combiner pattern for -mdiv=inv:call .(define_insn_and_split "*divsi_inv_call_combine" [(set (match_operand:SI 0 "register_operand" "=z") (div:SI (match_operand:SI 1 "register_operand" "r") (match_operand:SI 2 "register_operand" "r"))) (clobber (reg:SI R4_REG)) (clobber (reg:SI R5_REG)) (clobber (reg:SI T_MEDIA_REG)) (clobber (reg:SI PR_MEDIA_REG)) (clobber (reg:SI R1_REG)) (clobber (reg:SI R21_REG)) (clobber (reg:SI TR0_REG)) (clobber (reg:SI R20_REG)) (use (unspec:SI [(match_dup 1) (match_operand:SI 3 "" "") (unspec:SI [(match_operand:SI 4 "" "") (match_dup 3) (match_operand:DI 5 "" "")] UNSPEC_DIV_INV_M2) (match_operand:DI 6 "" "") (const_int 0) (const_int 0)] UNSPEC_DIV_INV_M3))] "TARGET_SHMEDIA" "#" "&& (high_life_started || reload_completed)" [(pc)] "{ const char *name = sh_divsi3_libfunc; enum sh_function_kind kind = SFUNC_GOT; rtx sym; emit_move_insn (gen_rtx_REG (SImode, R4_REG), operands[1]); emit_move_insn (gen_rtx_REG (SImode, R5_REG), operands[2]); while (TARGET_DIVIDE_INV_CALL2) { rtx x = operands[3]; if (GET_CODE (x) != UNSPEC || XINT (x, 1) != UNSPEC_DIV_INV_M1) break; x = XVECEXP (x, 0, 0); name = \"__sdivsi3_2\"; kind = SFUNC_STATIC; emit_move_insn (gen_rtx_REG (DImode, R20_REG), x); break; } sym = function_symbol (NULL, name, kind); emit_insn (gen_divsi3_media_2 (operands[0], sym)); DONE;}" [(set_attr "highpart" "must_split")])(define_expand "divsi3_i4_media" [(set (match_dup 3) (float:DF (match_operand:SI 1 "register_operand" "r"))) (set (match_dup 4) (float:DF (match_operand:SI 2 "register_operand" "r"))) (set (match_dup 5) (div:DF (match_dup 3) (match_dup 4))) (set (match_operand:SI 0 "register_operand" "=r") (fix:SI (match_dup 5)))] "TARGET_SHMEDIA_FPU" "{ operands[3] = gen
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -