📄 rs6000.md
字号:
(clobber (match_scratch:SI 3 "=r,r"))] "! TARGET_POWER" "@ {muls.|mullw.} %3,%1,%2 #" [(set_attr "type" "imul_compare") (set_attr "length" "4,8")])(define_split [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "") (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "gpc_reg_operand" "")) (const_int 0))) (clobber (match_scratch:SI 3 ""))] "! TARGET_POWER && reload_completed" [(set (match_dup 3) (mult:SI (match_dup 1) (match_dup 2))) (set (match_dup 0) (compare:CC (match_dup 3) (const_int 0)))] "")(define_insn "*mulsi3_mq_internal2" [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y") (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r") (match_operand:SI 2 "gpc_reg_operand" "r,r")) (const_int 0))) (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (mult:SI (match_dup 1) (match_dup 2))) (clobber (match_scratch:SI 4 "=q,q"))] "TARGET_POWER" "@ {muls.|mullw.} %0,%1,%2 #" [(set_attr "type" "imul_compare") (set_attr "length" "4,8")])(define_split [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "") (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "gpc_reg_operand" "")) (const_int 0))) (set (match_operand:SI 0 "gpc_reg_operand" "") (mult:SI (match_dup 1) (match_dup 2))) (clobber (match_scratch:SI 4 ""))] "TARGET_POWER && reload_completed" [(parallel [(set (match_dup 0) (mult:SI (match_dup 1) (match_dup 2))) (clobber (match_dup 4))]) (set (match_dup 3) (compare:CC (match_dup 0) (const_int 0)))] "")(define_insn "*mulsi3_no_mq_internal2" [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y") (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r") (match_operand:SI 2 "gpc_reg_operand" "r,r")) (const_int 0))) (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (mult:SI (match_dup 1) (match_dup 2)))] "! TARGET_POWER" "@ {muls.|mullw.} %0,%1,%2 #" [(set_attr "type" "imul_compare") (set_attr "length" "4,8")])(define_split [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "") (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "gpc_reg_operand" "")) (const_int 0))) (set (match_operand:SI 0 "gpc_reg_operand" "") (mult:SI (match_dup 1) (match_dup 2)))] "! TARGET_POWER && reload_completed" [(set (match_dup 0) (mult:SI (match_dup 1) (match_dup 2))) (set (match_dup 3) (compare:CC (match_dup 0) (const_int 0)))] "");; Operand 1 is divided by operand 2; quotient goes to operand;; 0 and remainder to operand 3.;; ??? At some point, see what, if anything, we can do about if (x % y == 0).(define_expand "divmodsi4" [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "") (div:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "gpc_reg_operand" ""))) (set (match_operand:SI 3 "register_operand" "") (mod:SI (match_dup 1) (match_dup 2)))])] "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)" "{ if (! TARGET_POWER && ! TARGET_POWERPC) { emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]); emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]); emit_insn (gen_divss_call ()); emit_move_insn (operands[0], gen_rtx_REG (SImode, 3)); emit_move_insn (operands[3], gen_rtx_REG (SImode, 4)); DONE; }}")(define_insn "*divmodsi4_internal" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (div:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "gpc_reg_operand" "r"))) (set (match_operand:SI 3 "register_operand" "=q") (mod:SI (match_dup 1) (match_dup 2)))] "TARGET_POWER" "divs %0,%1,%2" [(set_attr "type" "idiv")])(define_expand "udivsi3" [(set (match_operand:SI 0 "gpc_reg_operand" "") (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "gpc_reg_operand" "")))] "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)" "{ if (! TARGET_POWER && ! TARGET_POWERPC) { emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]); emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]); emit_insn (gen_quous_call ()); emit_move_insn (operands[0], gen_rtx_REG (SImode, 3)); DONE; } else if (TARGET_POWER) { emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2])); DONE; }}")(define_insn "udivsi3_mq" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "gpc_reg_operand" "r"))) (clobber (match_scratch:SI 3 "=q"))] "TARGET_POWERPC && TARGET_POWER" "divwu %0,%1,%2" [(set_attr "type" "idiv")])(define_insn "*udivsi3_no_mq" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "gpc_reg_operand" "r")))] "TARGET_POWERPC && ! TARGET_POWER" "divwu %0,%1,%2" [(set_attr "type" "idiv")]);; For powers of two we can do srai/aze for divide and then adjust for;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be;; used; for PowerPC, force operands into register and do a normal divide;;; for AIX common-mode, use quoss call on register operands.(define_expand "divsi3" [(set (match_operand:SI 0 "gpc_reg_operand" "") (div:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "reg_or_cint_operand" "")))] "" "{ if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) > 0 && exact_log2 (INTVAL (operands[2])) >= 0) ; else if (TARGET_POWERPC) { operands[2] = force_reg (SImode, operands[2]); if (TARGET_POWER) { emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2])); DONE; } } else if (TARGET_POWER) FAIL; else { emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]); emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]); emit_insn (gen_quoss_call ()); emit_move_insn (operands[0], gen_rtx_REG (SImode, 3)); DONE; }}")(define_insn "divsi3_mq" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (div:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "gpc_reg_operand" "r"))) (clobber (match_scratch:SI 3 "=q"))] "TARGET_POWERPC && TARGET_POWER" "divw %0,%1,%2" [(set_attr "type" "idiv")])(define_insn "*divsi3_no_mq" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (div:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "gpc_reg_operand" "r")))] "TARGET_POWERPC && ! TARGET_POWER" "divw %0,%1,%2" [(set_attr "type" "idiv")])(define_expand "modsi3" [(use (match_operand:SI 0 "gpc_reg_operand" "")) (use (match_operand:SI 1 "gpc_reg_operand" "")) (use (match_operand:SI 2 "reg_or_cint_operand" ""))] "" "{ int i; rtx temp1; rtx temp2; if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) <= 0 || (i = exact_log2 (INTVAL (operands[2]))) < 0) FAIL; temp1 = gen_reg_rtx (SImode); temp2 = gen_reg_rtx (SImode); emit_insn (gen_divsi3 (temp1, operands[1], operands[2])); emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i))); emit_insn (gen_subsi3 (operands[0], operands[1], temp2)); DONE;}")(define_insn "" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (div:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "exact_log2_cint_operand" "N")))] "" "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0" [(set_attr "type" "two") (set_attr "length" "8")])(define_insn "" [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y") (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") (match_operand:SI 2 "exact_log2_cint_operand" "N,N")) (const_int 0))) (clobber (match_scratch:SI 3 "=r,r"))] "" "@ {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3 #" [(set_attr "type" "compare") (set_attr "length" "8,12")])(define_split [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "") (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "exact_log2_cint_operand" "")) (const_int 0))) (clobber (match_scratch:SI 3 ""))] "reload_completed" [(set (match_dup 3) (div:SI (match_dup 1) (match_dup 2))) (set (match_dup 0) (compare:CC (match_dup 3) (const_int 0)))] "")(define_insn "" [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y") (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") (match_operand:SI 2 "exact_log2_cint_operand" "N,N")) (const_int 0))) (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (div:SI (match_dup 1) (match_dup 2)))] "" "@ {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0 #" [(set_attr "type" "compare") (set_attr "length" "8,12")])(define_split [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "") (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "exact_log2_cint_operand" "")) (const_int 0))) (set (match_operand:SI 0 "gpc_reg_operand" "") (div:SI (match_dup 1) (match_dup 2)))] "reload_completed" [(set (match_dup 0) (div:SI (match_dup 1) (match_dup 2))) (set (match_dup 3) (compare:CC (match_dup 0) (const_int 0)))] "")(define_insn "" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r")) (const_int 32)) (zero_extend:DI (match_operand:SI 4 "register_operand" "2"))) (match_operand:SI 3 "gpc_reg_operand" "r"))) (set (match_operand:SI 2 "register_operand" "=*q") (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32)) (zero_extend:DI (match_dup 4))) (match_dup 3)))] "TARGET_POWER" "div %0,%1,%3" [(set_attr "type" "idiv")]);; To do unsigned divide we handle the cases of the divisor looking like a;; negative number. If it is a constant that is less than 2**31, we don't;; have to worry about the branches. So make a few subroutines here.;;;; First comes the normal case.(define_expand "udivmodsi4_normal" [(set (match_dup 4) (const_int 0)) (parallel [(set (match_operand:SI 0 "" "") (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4)) (const_int 32)) (zero_extend:DI (match_operand:SI 1 "" ""))) (match_operand:SI 2 "" ""))) (set (match_operand:SI 3 "" "") (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4)) (const_int 32)) (zero_extend:DI (match_dup 1))) (match_dup 2)))])] "TARGET_POWER" "{ operands[4] = gen_reg_rtx (SImode); }");; This handles the branches.(define_expand "udivmodsi4_tests" [(set (match_operand:SI 0 "" "") (const_int 0)) (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" "")) (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" ""))) (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0)) (label_ref (match_operand:SI 4 "" "")) (pc))) (set (match_dup 0) (const_int 1)) (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2))) (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0))) (set (pc) (if_then_else (lt (match_dup 6) (const_int 0)) (label_ref (match_dup 4)) (pc)))] "TARGET_POWER" "{ operands[5] = gen_reg_rtx (CCUNSmode); operands[6] = gen_reg_rtx (CCmode);}")(define_expand "udivmodsi4" [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "") (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "") (match_operand:SI 2 "reg_or_cint_operand" ""))) (set (match_operand:SI 3 "gpc_reg_operand" "") (umod:SI (match_dup 1) (match_dup 2)))])] "" "{ rtx label = 0; if (! TARGET_POWER) { if (! TARGET_POWERPC) { emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]); emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]); emit_insn (gen_divus_call ()); emit_move_insn (operands[0], gen_rtx_REG (SImode, 3)); emit_move_insn (operands[3], gen_rtx_REG (SImode, 4)); DONE; } else FAIL; } if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0) { operands[2] = force_reg (SImode, operands[2]); label = gen_label_rtx (); emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2], operands[3], label)); } else operands[2] = force_reg (SImode, operands[2]); emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2], operands[3])); if (label) emit_label (label); DONE;}");; AIX architecture-independent common-mode multiply (DImode),;; divide/modulus, and quotient subroutine calls. Input operands in R3 and;; R4; results in R3 and sometimes R4; link register always clobbered by bla;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but;; assumed unused if generating common-mode, so ignore.(define_insn "mulh_call" [(set (reg:SI 3) (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3)) (sign_extend:DI (reg:SI 4))) (const_int 32)))) (clobber (match_scratch:SI 0 "=l"))] "! TARGET_POWER && ! TARGET_POWERPC" "bla __mulh" [(set_attr "type" "imul")])(define_insn "mull_call" [(set (reg:DI 3) (mult:DI (sign_extend:DI (reg:SI 3)) (sign_extend:DI (reg:SI 4)))) (clobber (match_scratch:SI 0 "=l")) (clobber (reg:SI 0))] "! TARGET_POWER && ! TARGET_POWERPC" "bla __mull" [(set_attr "type" "imul")])(define_insn "divss_call" [(set (reg:SI 3) (div:SI (reg:SI 3) (reg:SI 4))) (set (reg:SI 4) (mod:SI (reg:SI 3) (reg:SI 4))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -