m32r.md
来自「GCC编译器源代码」· Markdown 代码 · 共 1,470 行 · 第 1/3 页
MD
1,470 行
"*{ switch (which_alternative) { case 0 : /* We normally copy the low-numbered register first. However, if the first register operand 0 is the same as the second register of operand 1, we must copy in the opposite order. */ if (REGNO (operands[0]) == REGNO (operands[1]) + 1) return \"mv %R0,%R1\;mv %0,%1\"; else return \"mv %0,%1\;mv %R0,%R1\"; case 1 : { REAL_VALUE_TYPE r; long l[2]; REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]); REAL_VALUE_TO_TARGET_DOUBLE (r, l); operands[1] = GEN_INT (l[0]); if (l[0] == 0 && l[1] == 0) return \"ldi %0,%#0\;ldi %R0,%#0\"; else if (l[1] != 0) abort (); else if ((l[0] & 0xffff) == 0) return \"seth %0,%#%T1\;ldi %R0,%#0\"; else abort (); } case 2 : /* If the low-address word is used in the address, we must load it last. Otherwise, load it first. Note that we cannot have auto-increment in that case since the address register is known to be dead. */ if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1, operands [1], 0)) { return \"ld %R0,%R1\;ld %0,%1\"; } else { /* Try to use auto-inc addressing if we can. */ if (GET_CODE (XEXP (operands[1], 0)) == REG && dead_or_set_p (insn, XEXP (operands[1], 0))) { operands[1] = XEXP (operands[1], 0); return \"ld %0,@%1+\;ld %R0,@%1\"; } return \"ld %0,%1\;ld %R0,%R1\"; } case 3 : /* Try to use auto-inc addressing if we can. */ if (GET_CODE (XEXP (operands[0], 0)) == REG && dead_or_set_p (insn, XEXP (operands[0], 0))) { operands[0] = XEXP (operands[0], 0); return \"st %1,@%0\;st %R1,@+%0\"; } return \"st %1,%0\;st %R1,%R0\"; }}" [(set_attr "type" "multi,multi,multi,multi") (set_attr "length" "4,6,6,6")]);; Zero extension instructions.(define_insn "zero_extendqihi2" [(set (match_operand:HI 0 "register_operand" "=r,r") (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,m")))] "" "@ and3 %0,%1,%#255 ldub %0,%1" [(set_attr "type" "unary,load") (set_attr "length" "4,*")])(define_insn "zero_extendqisi2" [(set (match_operand:SI 0 "register_operand" "=r,r") (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))] "" "@ and3 %0,%1,%#255 ldub %0,%1" [(set_attr "type" "unary,load") (set_attr "length" "4,*")])(define_insn "zero_extendhisi2" [(set (match_operand:SI 0 "register_operand" "=r,r") (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))] "" "@ and3 %0,%1,%#65535 lduh %0,%1" [(set_attr "type" "unary,load") (set_attr "length" "4,*")]);; Sign extension instructions.;; ??? See v850.md.;; These patterns originally accepted general_operands, however, slightly;; better code is generated by only accepting register_operands, and then;; letting combine generate the lds[hb] insns.;; [This comment copied from sparc.md, I think.](define_expand "extendqihi2" [(set (match_operand:HI 0 "register_operand" "") (sign_extend:HI (match_operand:QI 1 "register_operand" "")))] "" "{ rtx temp = gen_reg_rtx (SImode); rtx shift_24 = gen_rtx (CONST_INT, VOIDmode, 24); int op1_subword = 0; int op0_subword = 0; if (GET_CODE (operand1) == SUBREG) { op1_subword = SUBREG_WORD (operand1); operand1 = XEXP (operand1, 0); } if (GET_CODE (operand0) == SUBREG) { op0_subword = SUBREG_WORD (operand0); operand0 = XEXP (operand0, 0); } emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1, op1_subword), shift_24)); if (GET_MODE (operand0) != SImode) operand0 = gen_rtx (SUBREG, SImode, operand0, op0_subword); emit_insn (gen_ashrsi3 (operand0, temp, shift_24)); DONE;}")(define_insn "*sign_extendqihi2_insn" [(set (match_operand:HI 0 "register_operand" "=r") (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))] "" "ldb %0,%1" [(set_attr "type" "load")])(define_expand "extendqisi2" [(set (match_operand:SI 0 "register_operand" "") (sign_extend:SI (match_operand:QI 1 "register_operand" "")))] "" "{ rtx temp = gen_reg_rtx (SImode); rtx shift_24 = gen_rtx (CONST_INT, VOIDmode, 24); int op1_subword = 0; if (GET_CODE (operand1) == SUBREG) { op1_subword = SUBREG_WORD (operand1); operand1 = XEXP (operand1, 0); } emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1, op1_subword), shift_24)); emit_insn (gen_ashrsi3 (operand0, temp, shift_24)); DONE;}")(define_insn "*sign_extendqisi2_insn" [(set (match_operand:SI 0 "register_operand" "=r") (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))] "" "ldb %0,%1" [(set_attr "type" "load")])(define_expand "extendhisi2" [(set (match_operand:SI 0 "register_operand" "") (sign_extend:SI (match_operand:HI 1 "register_operand" "")))] "" "{ rtx temp = gen_reg_rtx (SImode); rtx shift_16 = gen_rtx (CONST_INT, VOIDmode, 16); int op1_subword = 0; if (GET_CODE (operand1) == SUBREG) { op1_subword = SUBREG_WORD (operand1); operand1 = XEXP (operand1, 0); } emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1, op1_subword), shift_16)); emit_insn (gen_ashrsi3 (operand0, temp, shift_16)); DONE;}")(define_insn "*sign_extendhisi2_insn" [(set (match_operand:SI 0 "register_operand" "=r") (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))] "" "ldh %0,%1" [(set_attr "type" "load")]);; Arithmetic instructions.; ??? Adding an alternative to split add3 of small constants into two; insns yields better instruction packing but slower code. Adds of small; values is done a lot.(define_insn "addsi3" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (plus:SI (match_operand:SI 1 "register_operand" "%0,0,r") (match_operand:SI 2 "nonmemory_operand" "r,I,J")))] "" "@ add %0,%2 addi %0,%#%2 add3 %0,%1,%#%2" [(set_attr "type" "binary") (set_attr "length" "2,2,4")]);(define_split; [(set (match_operand:SI 0 "register_operand" ""); (plus:SI (match_operand:SI 1 "register_operand" ""); (match_operand:SI 2 "int8_operand" "")))]; "reload_completed; && REGNO (operands[0]) != REGNO (operands[1]); && INT8_P (INTVAL (operands[2])); && INTVAL (operands[2]) != 0"; [(set (match_dup 0) (match_dup 1)); (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]; "")(define_insn "adddi3" [(set (match_operand:DI 0 "register_operand" "=r") (plus:DI (match_operand:DI 1 "register_operand" "%0") (match_operand:DI 2 "register_operand" "r"))) (clobber (reg:CC 17))] "" "*{ /* ??? The cmp clears the condition bit. Can we speed up somehow? */ return \"cmp %L0,%L0\;addx %L0,%L2\;addx %H0,%H2\";}" [(set_attr "type" "binary") (set_attr "length" "6")])(define_insn "subsi3" [(set (match_operand:SI 0 "register_operand" "=r") (minus:SI (match_operand:SI 1 "register_operand" "0") (match_operand:SI 2 "register_operand" "r")))] "" "sub %0,%2" [(set_attr "type" "binary")])(define_insn "subdi3" [(set (match_operand:DI 0 "register_operand" "=r") (minus:DI (match_operand:DI 1 "register_operand" "0") (match_operand:DI 2 "register_operand" "r"))) (clobber (reg:CC 17))] "" "*{ /* ??? The cmp clears the condition bit. Can we speed up somehow? */ return \"cmp %L0,%L0\;subx %L0,%L2\;subx %H0,%H2\";}" [(set_attr "type" "binary") (set_attr "length" "6")]); Multiply/Divide instructions.(define_insn "mulhisi3" [(set (match_operand:SI 0 "register_operand" "=r") (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "r")) (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))] "" "mullo %1,%2\;mvfacmi %0" [(set_attr "type" "mul") (set_attr "length" "4")])(define_insn "mulsi3" [(set (match_operand:SI 0 "register_operand" "=r") (mult:SI (match_operand:SI 1 "register_operand" "%0") (match_operand:SI 2 "register_operand" "r")))] "" "mul %0,%2" [(set_attr "type" "mul")])(define_insn "divsi3" [(set (match_operand:SI 0 "register_operand" "=r") (div:SI (match_operand:SI 1 "register_operand" "0") (match_operand:SI 2 "register_operand" "r")))] "" "div %0,%2" [(set_attr "type" "div")])(define_insn "udivsi3" [(set (match_operand:SI 0 "register_operand" "=r") (udiv:SI (match_operand:SI 1 "register_operand" "0") (match_operand:SI 2 "register_operand" "r")))] "" "divu %0,%2" [(set_attr "type" "div")])(define_insn "modsi3" [(set (match_operand:SI 0 "register_operand" "=r") (mod:SI (match_operand:SI 1 "register_operand" "0") (match_operand:SI 2 "register_operand" "r")))] "" "rem %0,%2" [(set_attr "type" "div")])(define_insn "umodsi3" [(set (match_operand:SI 0 "register_operand" "=r") (umod:SI (match_operand:SI 1 "register_operand" "0") (match_operand:SI 2 "register_operand" "r")))] "" "remu %0,%2" [(set_attr "type" "div")]);; Boolean instructions.;;;; We don't define the DImode versions as expand_binop does a good enough job.;; And if it doesn't it should be fixed.(define_insn "andsi3" [(set (match_operand:SI 0 "register_operand" "=r,r") (and:SI (match_operand:SI 1 "register_operand" "%0,r") (match_operand:SI 2 "nonmemory_operand" "r,K")))] "" "@ and %0,%2 and3 %0,%1,%#%2 ; %X2" [(set_attr "type" "binary")])(define_insn "iorsi3" [(set (match_operand:SI 0 "register_operand" "=r,r") (ior:SI (match_operand:SI 1 "register_operand" "%0,r") (match_operand:SI 2 "nonmemory_operand" "r,K")))] "" "@ or %0,%2 or3 %0,%1,%#%2 ; %X2" [(set_attr "type" "binary")])(define_insn "xorsi3" [(set (match_operand:SI 0 "register_operand" "=r,r") (xor:SI (match_operand:SI 1 "register_operand" "%0,r") (match_operand:SI 2 "nonmemory_operand" "r,K")))] "" "@ xor %0,%2 xor3 %0,%1,%#%2 ; %X2" [(set_attr "type" "binary")])(define_insn "negsi2" [(set (match_operand:SI 0 "register_operand" "=r") (neg:SI (match_operand:SI 1 "register_operand" "r")))] "" "neg %0,%1" [(set_attr "type" "unary")])(define_insn "one_cmplsi2" [(set (match_operand:SI 0 "register_operand" "=r") (not:SI (match_operand:SI 1 "register_operand" "r")))] "" "not %0,%1" [(set_attr "type" "unary")]);; Shift instructions.(define_insn "ashlsi3" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (ashift:SI (match_operand:SI 1 "register_operand" "0,0,r") (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))] "" "@ sll %0,%2 slli %0,%#%2 sll3 %0,%1,%#%2" [(set_attr "type" "shift") (set_attr "length" "2,2,4")])(define_insn "ashrsi3" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r") (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))] "" "@ sra %0,%2 srai %0,%#%2 sra3 %0,%1,%#%2" [(set_attr "type" "shift") (set_attr "length" "2,2,4")])(define_insn "lshrsi3" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r") (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))] "" "@ srl %0,%2 srli %0,%#%2 srl3 %0,%1,%#%2" [(set_attr "type" "shift") (set_attr "length" "2,2,4")]);; Compare instructions.;; This controls RTL generation and register allocation.;; We generate RTL for comparisons and branches by having the cmpxx ;; patterns store away the operands. Then the bcc patterns;; emit RTL for both the compare and the branch.;;;; On the m32r it is more efficient to use the bxxz instructions and;; thus merge the compare and branch into one instruction, so they are;; preferred.(define_expand "cmpsi" [(set (reg:CC 17) (compare:CC (match_operand:SI 0 "register_operand" "") (match_operand:SI 1 "nonmemory_operand" "")))] "" "{ m32r_compare_op0 = operands[0]; m32r_compare_op1 = operands[1]; DONE;}");; The cmp_xxx_insn patterns set the condition bit to the result of the;; comparison. There isn't a "compare equal" instruction so cmp_eqsi_insn;; is quite inefficient. However, it is rarely used.(define_insn "cmp_eqsi_insn" [(set (reg:CC 17) (eq:CC (match_operand:SI 0 "register_operand" "r,r") (match_operand:SI 1 "reg_or_cmp_int16_operand" "r,P"))) (clobber (match_scratch:SI 2 "=&r,&r"))] "TARGET_OLD_COMPARE" "@ mv %2,%0\;sub %2,%1\;cmpui %2,#1 add3 %2,%0,%#%N1\;cmpui %2,#1" [(set_attr "type" "compare,compare") (set_attr "length" "8,8")])(define_insn "cmp_ltsi_insn" [(set (reg:CC 17) (lt:CC (match_operand:SI 0 "register_operand" "r,r") (match_operand:SI 1 "reg_or_int16_operand" "r,J")))] "" "@ cmp %0,%1 cmpi %0,%#%1" [(set_attr "type" "compare")])(define_insn "cmp_ltusi_insn" [(set (reg:CC 17) (ltu:CC (match_operand:SI 0 "register_operand" "r,r") (match_operand:SI 1 "reg_or_uint16_operand" "r,K")))] "" "@ cmpu %0,%1 cmpui %0,%#%1" [(set_attr "type" "compare")]);; reg == small constant comparisons are best handled by putting the result;; of the comparison in a tmp reg and then using beqz/bnez.;; ??? The result register doesn't contain 0/STORE_FLAG_VALUE,;; it contains 0/non-zero.(define_insn "cmp_ne_small_const_insn" [(set (match_operand:SI 0 "register_operand" "=r") (ne:SI (match_operand:SI 1 "register_operand" "r") (match_operand:SI 2 "cmp_int16_operand" "P")))] "" "add3 %0,%1,%#%N2" [(set_attr "type" "compare") (set_attr "length" "4")]);; These control RTL generation for conditional jump insns.(define_expand "beq" [(set (pc) (if_then_else (match_dup 1) (label_ref (match_operand 0 "" "")) (pc)))] "" "{ operands[1] = gen_compare (EQ, m32r_compare_op0, m32r_compare_op1);}")
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?