📄 sh.md
字号:
if (TARGET_LITTLE_ENDIAN) { rtx low_dst = operand_subword (operands[0], 0, 1, DImode); rtx high_dst = operand_subword (operands[0], 1, 1, DImode); emit_insn (gen_mulsidi3_i (operands[1], operands[2])); emit_insn (gen_rtx (CLOBBER, VOIDmode, operands[0])); emit_move_insn (low_dst, gen_rtx (REG, SImode, 21)); emit_move_insn (high_dst, gen_rtx (REG, SImode, 20)); DONE; }}")(define_insn "umulsidi3_i" [(set (reg:DI 20) (mult:DI (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r")) (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))))] "TARGET_SH2" "dmulu.l %1,%0" [(set_attr "type" "dmpy")])(define_expand "umulsidi3" [(set (reg:DI 20) (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "")) (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "")))) (set (match_operand:DI 0 "arith_reg_operand" "") (reg:DI 20))] "TARGET_SH2" "{ /* We must swap the two words when copying them from MACH/MACL to the output register. */ if (TARGET_LITTLE_ENDIAN) { rtx low_dst = operand_subword (operands[0], 0, 1, DImode); rtx high_dst = operand_subword (operands[0], 1, 1, DImode); emit_insn (gen_umulsidi3_i (operands[1], operands[2])); emit_insn (gen_rtx (CLOBBER, VOIDmode, operands[0])); emit_move_insn (low_dst, gen_rtx (REG, SImode, 21)); emit_move_insn (high_dst, gen_rtx (REG, SImode, 20)); DONE; }}")(define_insn "" [(set (reg:SI 20) (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 0 "arith_reg_operand" "r")) (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))) (const_int 32)))) (clobber (reg:SI 21))] "TARGET_SH2" "dmuls.l %1,%0" [(set_attr "type" "dmpy")])(define_expand "smulsi3_highpart" [(parallel [(set (reg:SI 20) (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "")) (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))) (const_int 32)))) (clobber (reg:SI 21))]) (set (match_operand:SI 0 "arith_reg_operand" "") (reg:SI 20))] "TARGET_SH2" "")(define_insn "" [(set (reg:SI 20) (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r")) (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))) (const_int 32)))) (clobber (reg:SI 21))] "TARGET_SH2" "dmulu.l %1,%0" [(set_attr "type" "dmpy")])(define_expand "umulsi3_highpart" [(parallel [(set (reg:SI 20) (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "")) (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))) (const_int 32)))) (clobber (reg:SI 21))]) (set (match_operand:SI 0 "arith_reg_operand" "") (reg:SI 20))] "TARGET_SH2" "");; -------------------------------------------------------------------------;; Logical operations;; -------------------------------------------------------------------------(define_insn "" [(set (match_operand:SI 0 "arith_reg_operand" "=r,z") (and:SI (match_operand:SI 1 "arith_reg_operand" "%0,0") (match_operand:SI 2 "logical_operand" "r,L")))] "" "and %2,%0" [(set_attr "type" "arith")]);; If the constant is 255, then emit a extu.b instruction instead of an;; and, since that will give better code.(define_expand "andsi3" [(set (match_operand:SI 0 "arith_reg_operand" "") (and:SI (match_operand:SI 1 "arith_reg_operand" "") (match_operand:SI 2 "logical_operand" "")))] "" "{ if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 255) { emit_insn (gen_zero_extendqisi2 (operands[0], gen_lowpart (QImode, operands[1]))); DONE; }}")(define_insn "iorsi3" [(set (match_operand:SI 0 "arith_reg_operand" "=r,z") (ior:SI (match_operand:SI 1 "arith_reg_operand" "%0,0") (match_operand:SI 2 "logical_operand" "r,L")))] "" "or %2,%0" [(set_attr "type" "arith")])(define_insn "xorsi3" [(set (match_operand:SI 0 "arith_reg_operand" "=z,r") (xor:SI (match_operand:SI 1 "arith_reg_operand" "%0,0") (match_operand:SI 2 "logical_operand" "L,r")))] "" "xor %2,%0" [(set_attr "type" "arith")]);; -------------------------------------------------------------------------;; Shifts and rotates;; -------------------------------------------------------------------------(define_insn "rotlsi3_1" [(set (match_operand:SI 0 "arith_reg_operand" "=r") (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0") (const_int 1))) (set (reg:SI 18) (lshiftrt:SI (match_dup 1) (const_int 31)))] "" "rotl %0" [(set_attr "type" "arith")])(define_insn "rotlsi3_31" [(set (match_operand:SI 0 "arith_reg_operand" "=r") (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0") (const_int 31))) (clobber (reg:SI 18))] "" "rotr %0" [(set_attr "type" "arith")])(define_insn "rotlsi3_16" [(set (match_operand:SI 0 "arith_reg_operand" "=r") (rotate:SI (match_operand:SI 1 "arith_reg_operand" "r") (const_int 16)))] "" "swap.w %1,%0" [(set_attr "type" "arith")])(define_expand "rotlsi3" [(set (match_operand:SI 0 "arith_reg_operand" "") (rotate:SI (match_operand:SI 1 "arith_reg_operand" "") (match_operand:SI 2 "immediate_operand" "")))] "" "{ static char rot_tab[] = { 000, 000, 000, 000, 000, 000, 010, 001, 001, 001, 011, 013, 003, 003, 003, 003, 003, 003, 003, 003, 003, 013, 012, 002, 002, 002, 010, 000, 000, 000, 000, 000, }; int count, choice; if (GET_CODE (operands[2]) != CONST_INT) FAIL; count = INTVAL (operands[2]); choice = rot_tab[count]; if (choice & 010 && SH_DYNAMIC_SHIFT_COST <= 1) FAIL; choice &= 7; switch (choice) { case 0: emit_move_insn (operands[0], operands[1]); count -= (count & 16) * 2; break; case 3: emit_insn (gen_rotlsi3_16 (operands[0], operands[1])); count -= 16; break; case 1: case 2: { rtx parts[2]; parts[0] = gen_reg_rtx (SImode); parts[1] = gen_reg_rtx (SImode); emit_insn (gen_rotlsi3_16 (parts[2-choice], operands[1])); parts[choice-1] = operands[1]; emit_insn (gen_ashlsi3 (parts[0], parts[0], GEN_INT (8))); emit_insn (gen_lshrsi3 (parts[1], parts[1], GEN_INT (8))); emit_insn (gen_iorsi3 (operands[0], parts[0], parts[1])); count = (count & ~16) - 8; } } for (; count > 0; count--) emit_insn (gen_rotlsi3_1 (operands[0], operands[0])); for (; count < 0; count++) emit_insn (gen_rotlsi3_31 (operands[0], operands[0])); DONE;}")(define_insn "*rotlhi3_8" [(set (match_operand:HI 0 "arith_reg_operand" "=r") (rotate:HI (match_operand:HI 1 "arith_reg_operand" "r") (const_int 8)))] "" "swap.b %1,%0" [(set_attr "type" "arith")])(define_expand "rotlhi3" [(set (match_operand:HI 0 "arith_reg_operand" "") (rotate:HI (match_operand:HI 1 "arith_reg_operand" "") (match_operand:HI 2 "immediate_operand" "")))] "" "{ if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 8) FAIL;}");;;; shift left(define_insn "ashlsi3_d" [(set (match_operand:SI 0 "arith_reg_operand" "=r") (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0") (match_operand:SI 2 "arith_reg_operand" "r")))] "TARGET_SH3" "shld %2,%0" [(set_attr "type" "dyn_shift")])(define_insn "ashlsi3_k" [(set (match_operand:SI 0 "arith_reg_operand" "=r,r") (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0,0") (match_operand:SI 2 "const_int_operand" "M,K")))] "CONST_OK_FOR_K (INTVAL (operands[2]))" "@ add %0,%0 shll%O2 %0" [(set_attr "type" "arith")])(define_insn "ashlhi3_k" [(set (match_operand:HI 0 "arith_reg_operand" "=r,r") (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0,0") (match_operand:HI 2 "const_int_operand" "M,K")))] "CONST_OK_FOR_K (INTVAL (operands[2]))" "@ add %0,%0 shll%O2 %0" [(set_attr "type" "arith")])(define_insn "ashlsi3_n" [(set (match_operand:SI 0 "arith_reg_operand" "=r") (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0") (match_operand:SI 2 "const_int_operand" "n"))) (clobber (reg:SI 18))] "! sh_dynamicalize_shift_p (operands[2])" "#" [(set (attr "length") (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1)) (const_string "2") (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2)) (const_string "4") (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3)) (const_string "6")] (const_string "8"))) (set_attr "type" "arith")])(define_split [(set (match_operand:SI 0 "arith_reg_operand" "") (ashift:SI (match_operand:SI 1 "arith_reg_operand" "") (match_operand:SI 2 "const_int_operand" "n"))) (clobber (reg:SI 18))] "" [(use (reg:SI 0))] "{ gen_shifty_op (ASHIFT, operands); DONE;}")(define_expand "ashlsi3" [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "") (ashift:SI (match_operand:SI 1 "arith_reg_operand" "") (match_operand:SI 2 "nonmemory_operand" ""))) (clobber (reg:SI 18))])] "" "{ if (GET_CODE (operands[2]) == CONST_INT && sh_dynamicalize_shift_p (operands[2])) operands[2] = force_reg (SImode, operands[2]); if (TARGET_SH3 && arith_reg_operand (operands[2], GET_MODE (operands[2]))) { emit_insn (gen_ashlsi3_d (operands[0], operands[1], operands[2])); DONE; } if (! immediate_operand (operands[2], GET_MODE (operands[2]))) FAIL;}")(define_insn "ashlhi3" [(set (match_operand:HI 0 "arith_reg_operand" "=r") (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0") (match_operand:HI 2 "const_int_operand" "n"))) (clobber (reg:SI 18))] "" "#" [(set (attr "length") (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1)) (const_string "2") (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2)) (const_string "4")] (const_string "6"))) (set_attr "type" "arith")])(define_split [(set (match_operand:HI 0 "arith_reg_operand" "") (ashift:HI (match_operand:HI 1 "arith_reg_operand" "") (match_operand:HI 2 "const_int_operand" "n"))) (clobber (reg:SI 18))] "" [(use (reg:SI 0))] "{ gen_shifty_hi_op (ASHIFT, operands); DONE;}");; arithmetic shift right;(define_insn "ashrsi3_k" [(set (match_operand:SI 0 "arith_reg_operand" "=r") (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0") (match_operand:SI 2 "const_int_operand" "M"))) (clobber (reg:SI 18))] "INTVAL (operands[2]) == 1" "shar %0" [(set_attr "type" "arith")]);; We can't do HImode right shifts correctly unless we start out with an;; explicit zero / sign extension; doing that would result in worse overall;; code, so just let the machine independent code widen the mode.;; That's why we don't have ashrhi3_k / lshrhi3_k / lshrhi3_m / lshrhi3 .;; ??? This should be a define expand.(define_insn "ashrsi2_16" [(set (match_operand:SI 0 "arith_reg_operand" "=r") (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r") (const_int 16)))] "" "#" [(set_attr "length" "4")])(define_split [(set (match_operand:SI 0 "arith_reg_operand" "=r")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -