📄 v850.md
字号:
;; Matching for sasf requires combining 4 instructions, so we provide a;; dummy pattern to match the first 3, which will always be turned into the;; second pattern by subsequent combining. As above, we must include the;; comparison to avoid input reloads in an insn using cc0.(define_insn "*sasf_1" [(set (match_operand:SI 0 "register_operand" "") (ior:SI (match_operator 1 "comparison_operator" [(cc0) (const_int 0)]) (ashift:SI (match_operand:SI 2 "register_operand" "") (const_int 1))))] "TARGET_V850E" "* abort ();")(define_insn "*sasf_2" [(set (match_operand:SI 0 "register_operand" "=r") (ior:SI (match_operator 1 "comparison_operator" [(match_operand:SI 3 "register_operand" "r") (match_operand:SI 4 "reg_or_int5_operand" "rJ")]) (ashift:SI (match_operand:SI 2 "register_operand" "0") (const_int 1))))] "TARGET_V850E" "cmp %4,%3 ; sasf %c1,%0" [(set_attr "length" "6") (set_attr "cc" "clobber")])(define_split [(set (match_operand:SI 0 "register_operand" "") (if_then_else:SI (match_operator 1 "comparison_operator" [(match_operand:SI 4 "register_operand" "") (match_operand:SI 5 "reg_or_int5_operand" "")]) (match_operand:SI 2 "const_int_operand" "") (match_operand:SI 3 "const_int_operand" "")))] "TARGET_V850E && ((INTVAL (operands[2]) ^ INTVAL (operands[3])) == 1) && ((INTVAL (operands[2]) + INTVAL (operands[3])) != 1) && (GET_CODE (operands[5]) == CONST_INT || REGNO (operands[0]) != REGNO (operands[5])) && REGNO (operands[0]) != REGNO (operands[4])" [(set (match_dup 0) (match_dup 6)) (set (match_dup 0) (ior:SI (match_op_dup 7 [(match_dup 4) (match_dup 5)]) (ashift:SI (match_dup 0) (const_int 1))))] "{ operands[6] = GEN_INT (INTVAL (operands[2]) >> 1); if (INTVAL (operands[2]) & 0x1) operands[7] = operands[1]; else operands[7] = gen_rtx (reverse_condition (GET_CODE (operands[1])), GET_MODE (operands[1]), XEXP (operands[1], 0), XEXP (operands[1], 1));}");; ---------------------------------------------------------------------;; BYTE SWAP INSTRUCTIONS;; ---------------------------------------------------------------------(define_expand "rotlhi3" [(set (match_operand:HI 0 "register_operand" "") (rotate:HI (match_operand:HI 1 "register_operand" "") (match_operand:HI 2 "const_int_operand" "")))] "TARGET_V850E" "{ if (INTVAL (operands[2]) != 8) FAIL;}")(define_insn "*rotlhi3_8" [(set (match_operand:HI 0 "register_operand" "=r") (rotate:HI (match_operand:HI 1 "register_operand" "r") (const_int 8)))] "TARGET_V850E" "bsh %1,%0" [(set_attr "length" "4") (set_attr "cc" "clobber")])(define_expand "rotlsi3" [(set (match_operand:SI 0 "register_operand" "") (rotate:SI (match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "const_int_operand" "")))] "TARGET_V850E" "{ if (INTVAL (operands[2]) != 16) FAIL;}")(define_insn "*rotlsi3_16" [(set (match_operand:SI 0 "register_operand" "=r") (rotate:SI (match_operand:SI 1 "register_operand" "r") (const_int 16)))] "TARGET_V850E" "hsw %1,%0" [(set_attr "length" "4") (set_attr "cc" "clobber")]);; ----------------------------------------------------------------------;; JUMP INSTRUCTIONS;; ----------------------------------------------------------------------;; Conditional jump instructions(define_expand "ble" [(set (pc) (if_then_else (le (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "bleu" [(set (pc) (if_then_else (leu (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "bge" [(set (pc) (if_then_else (ge (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "bgeu" [(set (pc) (if_then_else (geu (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "blt" [(set (pc) (if_then_else (lt (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "bltu" [(set (pc) (if_then_else (ltu (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "bgt" [(set (pc) (if_then_else (gt (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "bgtu" [(set (pc) (if_then_else (gtu (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "beq" [(set (pc) (if_then_else (eq (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_expand "bne" [(set (pc) (if_then_else (ne (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "")(define_insn "*branch_normal" [(set (pc) (if_then_else (match_operator 1 "comparison_operator" [(cc0) (const_int 0)]) (label_ref (match_operand 0 "" "")) (pc)))] "" "*{ if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 && (GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == GE || GET_CODE (operands[1]) == LE || GET_CODE (operands[1]) == LT)) return 0; if (get_attr_length (insn) == 2) return \"b%b1 %l0\"; else return \"b%B1 .+6 ; jr %l0\";}" [(set (attr "length") (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 256)) (const_int 2) (const_int 6))) (set_attr "cc" "none")])(define_insn "*branch_invert" [(set (pc) (if_then_else (match_operator 1 "comparison_operator" [(cc0) (const_int 0)]) (pc) (label_ref (match_operand 0 "" ""))))] "" "*{ if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 && (GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == GE || GET_CODE (operands[1]) == LE || GET_CODE (operands[1]) == LT)) return 0; if (get_attr_length (insn) == 2) return \"b%B1 %l0\"; else return \"b%b1 .+6 ; jr %l0\";}" [(set (attr "length") (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 256)) (const_int 2) (const_int 6))) (set_attr "cc" "none")]);; Unconditional and other jump instructions.(define_insn "jump" [(set (pc) (label_ref (match_operand 0 "" "")))] "" "*{ if (get_attr_length (insn) == 2) return \"br %0\"; else return \"jr %0\";}" [(set (attr "length") (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 256)) (const_int 2) (const_int 4))) (set_attr "cc" "none")])(define_insn "indirect_jump" [(set (pc) (match_operand:SI 0 "register_operand" "r"))] "" "jmp %0" [(set_attr "length" "2") (set_attr "cc" "none")])(define_insn "tablejump" [(set (pc) (match_operand:SI 0 "register_operand" "r")) (use (label_ref (match_operand 1 "" "")))] "" "jmp %0" [(set_attr "length" "2") (set_attr "cc" "none")])(define_insn "switch" [(set (pc) (plus:SI (sign_extend:SI (mem:HI (plus:SI (ashift:SI (match_operand:SI 0 "register_operand" "r") (const_int 1)) (label_ref (match_operand 1 "" ""))))) (label_ref (match_dup 1))))] "TARGET_V850E" "switch %0" [(set_attr "length" "2") (set_attr "cc" "none")])(define_expand "casesi" [(match_operand:SI 0 "register_operand" "") (match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "register_operand" "") (match_operand 3 "" "") (match_operand 4 "" "")] "" "{ rtx reg = gen_reg_rtx (SImode); rtx tableaddress = gen_reg_rtx (SImode); rtx mem; /* Subtract the lower bound from the index. */ emit_insn (gen_subsi3 (reg, operands[0], operands[1])); /* Compare the result against the number of table entries. */ emit_insn (gen_cmpsi (reg, operands[2])); /* Branch to the default label if out of range of the table. */ emit_jump_insn (gen_bgtu (operands[4])); if (! TARGET_BIG_SWITCH && TARGET_V850E) { emit_jump_insn (gen_switch (reg, operands[3])); DONE; } /* Shift index for the table array access. */ emit_insn (gen_ashlsi3 (reg, reg, GEN_INT (TARGET_BIG_SWITCH ? 2 : 1))); /* Load the table address into a pseudo. */ emit_insn (gen_movsi (tableaddress, gen_rtx_LABEL_REF (Pmode, operands[3]))); /* Add the table address to the index. */ emit_insn (gen_addsi3 (reg, reg, tableaddress)); /* Load the table entry. */ mem = gen_rtx_MEM (CASE_VECTOR_MODE, reg); RTX_UNCHANGING_P (mem) = 1; if (! TARGET_BIG_SWITCH) { rtx reg2 = gen_reg_rtx (HImode); emit_insn (gen_movhi (reg2, mem)); emit_insn (gen_extendhisi2 (reg, reg2)); } else emit_insn (gen_movsi (reg, mem)); /* Add the table address. */ emit_insn (gen_addsi3 (reg, reg, tableaddress)); /* Branch to the switch label. */ emit_jump_insn (gen_tablejump (reg, operands[3])); DONE;}");; Call subroutine with no return value.(define_expand "call" [(call (match_operand:QI 0 "general_operand" "") (match_operand:SI 1 "general_operand" ""))] "" "{ if (! call_address_operand (XEXP (operands[0], 0), QImode) || TARGET_LONG_CALLS) XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0)); if (TARGET_LONG_CALLS) emit_call_insn (gen_call_internal_long (XEXP (operands[0], 0), operands[1])); else emit_call_insn (gen_call_internal_short (XEXP (operands[0], 0), operands[1])); DONE;}")(define_insn "call_internal_short" [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r")) (match_operand:SI 1 "general_operand" "g,g")) (clobber (reg:SI 31))] "! TARGET_LONG_CALLS" "@ jarl %0,r31 jarl .+4,r31 ; add 4,r31 ; jmp %0" [(set_attr "length" "4,8")])(define_insn "call_internal_long" [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r")) (match_operand:SI 1 "general_operand" "g,g")) (clobber (reg:SI 31))] "TARGET_LONG_CALLS" "* { if (which_alternative == 0) { if (GET_CODE (operands[0]) == REG) return \"jarl %0,r31\"; else return \"movhi hi(%0), r0, r11 ; movea lo(%0), r11, r11 ; jarl .+4,r31 ; add 4, r31 ; jmp r11\"; } else return \"jarl .+4,r31 ; add 4,r31 ; jmp %0\"; }" [(set_attr "length" "16,8")]);; Call subroutine, returning value in operand 0;; (which must be a hard register).(define_expand "call_value" [(set (match_operand 0 "" "") (call (match_operand:QI 1 "general_operand" "") (match_operand:SI 2 "general_operand" "")))] "" "{ if (! call_address_operand (XEXP (operands[1], 0), QImode) || TARGET_LONG_CALLS) XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0)); if (TARGET_LONG_CALLS) emit_call_insn (gen_call_value_internal_long (operands[0], XEXP (operands[1], 0), operands[2])); else emit_call_insn (gen_call_value_internal_short (operands[0], XEXP (operands[1], 0), operands[2])); DONE;}")(define_insn "call_value_internal_short" [(set (match_operand 0 "" "=r,r") (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r")) (match_operand:SI 2 "general_operand" "g,g"))) (clobber (reg:SI 31))] "! TARGET_LONG_CALLS" "@ jarl %1,r31 jarl .+4,r31 ; add 4,r31 ; jmp %1" [(set_attr "length" "4,8")])(define_insn "call_value_internal_long" [(set (match_operand 0 "" "=r,r") (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r")) (match_operand:SI 2 "general_operand" "g,g"))) (clobber (reg:SI 31))] "TARGET_LONG_CALLS" "* { if (which_alternative == 0) { if (GET_CODE (operands[1]) == REG) return \"jarl %1, r31\"; else /* Reload can generate this pattern... */ return \"movhi hi(%1), r0, r11 ; movea lo(%1), r11, r11 ; jarl .+4, r31 ; add 4, r31 ; jmp r11\"; } else return \"jarl .+4, r31 ; add 4, r31 ; jmp %1\"; }" [(set_attr "length" "16,8")])(define_insn "nop" [(const_int 0)] "" "nop" [(set_attr "length" "2") (set_attr "cc" "none")]);; ----------------------------------------------------------------------;; EXTEND INSTRUCTIONS;; ----------------------------------------------------------------------(define_insn "" [(set (match_operand:SI 0 "register_operand" "=r,r,r,r") (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,r,T,m")))] "TARGET_V850E" "@ zxh %0 andi 65535,%1,%0 sld.hu %1,%0 ld.hu %1,%0" [(set_attr "length" "2,4,2,4") (set_attr "cc" "none_0hit,set_znv,none_0hit,none_0hit")])(define_insn "zero_extendhisi2" [(set (match_operand:SI 0 "register_operand" "=r") (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))] "" "andi 65535,%1,%0" [(set_attr "length" "4") (set_attr "cc" "set_znv")])(define_insn "" [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -