📄 sparc.md
字号:
(define_function_unit "ieuN" 2 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "ialu,binary,move,unary,shift,compare,call,call_no_delay_slot,uncond_branch")) 1 1)(define_function_unit "ieu0" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "shift")) 1 1)(define_function_unit "ieu0" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "cmove")) 2 1)(define_function_unit "ieu1" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "compare,call,call_no_delay_slot,uncond_branch")) 1 1)(define_function_unit "cti" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "branch")) 1 1);; Timings; throughput/latency;; FMOV 1/1 fmov, fabs, fneg;; FMOVcc 1/2;; FADD 1/4 add/sub, format conv, compar;; FMUL 1/4;; FDIVs 12/12;; FDIVd 22/22;; FSQRTs 12/12;; FSQRTd 22/22;; FCMP takes 1 cycle to branch, 2 cycles to conditional move.;;;; ??? This is really bogus because the timings really depend upon;; who uses the result. We should record who the user is with;; more descriptive 'type' attribute names and account for these;; issues in ultrasparc_adjust_cost. (define_function_unit "fadd" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpmove")) 1 1)(define_function_unit "fadd" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpcmove")) 2 1)(define_function_unit "fadd" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fp")) 4 1)(define_function_unit "fadd" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpcmp")) 2 1)(define_function_unit "fmul" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpmul")) 4 1)(define_function_unit "fadd" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpcmove")) 2 1)(define_function_unit "fmul" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpdivs")) 12 12)(define_function_unit "fmul" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpdivd")) 22 22)(define_function_unit "fmul" 1 0 (and (eq_attr "cpu" "ultrasparc") (eq_attr "type" "fpsqrt")) 12 12);; 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 scc and bcc patterns;; emit RTL for both the compare and the branch.;;;; We do this because we want to generate different code for an sne and;; seq insn. In those cases, if the second operand of the compare is not;; const0_rtx, we want to compute the xor of the two operands and test;; it against zero.;;;; We start with the DEFINE_EXPANDs, then the DEFINE_INSNs to match;; the patterns. Finally, we have the DEFINE_SPLITs for some of the scc;; insns that actually require more than one machine instruction.;; Put cmpsi first among compare insns so it matches two CONST_INT operands.(define_expand "cmpsi" [(set (reg:CC 100) (compare:CC (match_operand:SI 0 "register_operand" "") (match_operand:SI 1 "arith_operand" "")))] "" "{ sparc_compare_op0 = operands[0]; sparc_compare_op1 = operands[1]; DONE;}")(define_expand "cmpdi" [(set (reg:CCX 100) (compare:CCX (match_operand:DI 0 "register_operand" "") (match_operand:DI 1 "arith_double_operand" "")))] "TARGET_ARCH64" "{ sparc_compare_op0 = operands[0]; sparc_compare_op1 = operands[1]; DONE;}")(define_expand "cmpsf" ;; The 96 here isn't ever used by anyone. [(set (reg:CCFP 96) (compare:CCFP (match_operand:SF 0 "register_operand" "") (match_operand:SF 1 "register_operand" "")))] "TARGET_FPU" "{ sparc_compare_op0 = operands[0]; sparc_compare_op1 = operands[1]; DONE;}")(define_expand "cmpdf" ;; The 96 here isn't ever used by anyone. [(set (reg:CCFP 96) (compare:CCFP (match_operand:DF 0 "register_operand" "") (match_operand:DF 1 "register_operand" "")))] "TARGET_FPU" "{ sparc_compare_op0 = operands[0]; sparc_compare_op1 = operands[1]; DONE;}")(define_expand "cmptf" ;; The 96 here isn't ever used by anyone. [(set (reg:CCFP 96) (compare:CCFP (match_operand:TF 0 "register_operand" "") (match_operand:TF 1 "register_operand" "")))] "TARGET_FPU" "{ sparc_compare_op0 = operands[0]; sparc_compare_op1 = operands[1]; DONE;}");; Now the compare DEFINE_INSNs.(define_insn "*cmpsi_insn" [(set (reg:CC 100) (compare:CC (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "arith_operand" "rI")))] "" "cmp\\t%0, %1" [(set_attr "type" "compare")])(define_insn "*cmpdi_sp64" [(set (reg:CCX 100) (compare:CCX (match_operand:DI 0 "register_operand" "r") (match_operand:DI 1 "arith_double_operand" "rHI")))] "TARGET_ARCH64" "cmp\\t%0, %1" [(set_attr "type" "compare")])(define_insn "*cmpsf_fpe" [(set (match_operand:CCFPE 0 "fcc_reg_operand" "=c") (compare:CCFPE (match_operand:SF 1 "register_operand" "f") (match_operand:SF 2 "register_operand" "f")))] "TARGET_FPU" "*{ if (TARGET_V9) return \"fcmpes\\t%0, %1, %2\"; return \"fcmpes\\t%1, %2\";}" [(set_attr "type" "fpcmp")])(define_insn "*cmpdf_fpe" [(set (match_operand:CCFPE 0 "fcc_reg_operand" "=c") (compare:CCFPE (match_operand:DF 1 "register_operand" "e") (match_operand:DF 2 "register_operand" "e")))] "TARGET_FPU" "*{ if (TARGET_V9) return \"fcmped\\t%0, %1, %2\"; return \"fcmped\\t%1, %2\";}" [(set_attr "type" "fpcmp")])(define_insn "*cmptf_fpe" [(set (match_operand:CCFPE 0 "fcc_reg_operand" "=c") (compare:CCFPE (match_operand:TF 1 "register_operand" "e") (match_operand:TF 2 "register_operand" "e")))] "TARGET_FPU && TARGET_HARD_QUAD" "*{ if (TARGET_V9) return \"fcmpeq\\t%0, %1, %2\"; return \"fcmpeq\\t%1, %2\";}" [(set_attr "type" "fpcmp")])(define_insn "*cmpsf_fp" [(set (match_operand:CCFP 0 "fcc_reg_operand" "=c") (compare:CCFP (match_operand:SF 1 "register_operand" "f") (match_operand:SF 2 "register_operand" "f")))] "TARGET_FPU" "*{ if (TARGET_V9) return \"fcmps\\t%0, %1, %2\"; return \"fcmps\\t%1, %2\";}" [(set_attr "type" "fpcmp")])(define_insn "*cmpdf_fp" [(set (match_operand:CCFP 0 "fcc_reg_operand" "=c") (compare:CCFP (match_operand:DF 1 "register_operand" "e") (match_operand:DF 2 "register_operand" "e")))] "TARGET_FPU" "*{ if (TARGET_V9) return \"fcmpd\\t%0, %1, %2\"; return \"fcmpd\\t%1, %2\";}" [(set_attr "type" "fpcmp")])(define_insn "*cmptf_fp" [(set (match_operand:CCFP 0 "fcc_reg_operand" "=c") (compare:CCFP (match_operand:TF 1 "register_operand" "e") (match_operand:TF 2 "register_operand" "e")))] "TARGET_FPU && TARGET_HARD_QUAD" "*{ if (TARGET_V9) return \"fcmpq\\t%0, %1, %2\"; return \"fcmpq\\t%1, %2\";}" [(set_attr "type" "fpcmp")]);; Next come the scc insns. For seq, sne, sgeu, and sltu, we can do this;; without jumps using the addx/subx instructions. For seq/sne on v9 we use;; the same code as v8 (the addx/subx method has more applications). The;; exception to this is "reg != 0" which can be done in one instruction on v9;; (so we do it). For the rest, on v9 we use conditional moves; on v8, we do;; branches.;; Seq_special[_xxx] and sne_special[_xxx] clobber the CC reg, because they;; generate addcc/subcc instructions.(define_expand "seqsi_special" [(set (match_dup 3) (xor:SI (match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "register_operand" ""))) (parallel [(set (match_operand:SI 0 "register_operand" "") (eq:SI (match_dup 3) (const_int 0))) (clobber (reg:CC 100))])] "! TARGET_LIVE_G0" "{ operands[3] = gen_reg_rtx (SImode); }")(define_expand "seqdi_special" [(set (match_dup 3) (xor:DI (match_operand:DI 1 "register_operand" "") (match_operand:DI 2 "register_operand" ""))) (set (match_operand:DI 0 "register_operand" "") (eq:DI (match_dup 3) (const_int 0)))] "TARGET_ARCH64" "{ operands[3] = gen_reg_rtx (DImode); }")(define_expand "snesi_special" [(set (match_dup 3) (xor:SI (match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "register_operand" ""))) (parallel [(set (match_operand:SI 0 "register_operand" "") (ne:SI (match_dup 3) (const_int 0))) (clobber (reg:CC 100))])] "! TARGET_LIVE_G0" "{ operands[3] = gen_reg_rtx (SImode); }")(define_expand "snedi_special" [(set (match_dup 3) (xor:DI (match_operand:DI 1 "register_operand" "") (match_operand:DI 2 "register_operand" ""))) (set (match_operand:DI 0 "register_operand" "") (ne:DI (match_dup 3) (const_int 0)))] "TARGET_ARCH64" "{ operands[3] = gen_reg_rtx (DImode); }")(define_expand "seqdi_special_trunc" [(set (match_dup 3) (xor:DI (match_operand:DI 1 "register_operand" "") (match_operand:DI 2 "register_operand" ""))) (set (match_operand:SI 0 "register_operand" "") (eq:SI (match_dup 3) (const_int 0)))] "TARGET_ARCH64" "{ operands[3] = gen_reg_rtx (DImode); }")(define_expand "snedi_special_trunc" [(set (match_dup 3) (xor:DI (match_operand:DI 1 "register_operand" "") (match_operand:DI 2 "register_operand" ""))) (set (match_operand:SI 0 "register_operand" "") (ne:SI (match_dup 3) (const_int 0)))] "TARGET_ARCH64" "{ operands[3] = gen_reg_rtx (DImode); }")(define_expand "seqsi_special_extend" [(set (match_dup 3) (xor:SI (match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "register_operand" ""))) (parallel [(set (match_operand:DI 0 "register_operand" "") (eq:DI (match_dup 3) (const_int 0))) (clobber (reg:CC 100))])] "TARGET_ARCH64" "{ operands[3] = gen_reg_rtx (SImode); }")(define_expand "snesi_special_extend" [(set (match_dup 3) (xor:SI (match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "register_operand" ""))) (parallel [(set (match_operand:DI 0 "register_operand" "") (ne:DI (match_dup 3) (const_int 0))) (clobber (reg:CC 100))])] "TARGET_ARCH64" "{ operands[3] = gen_reg_rtx (SImode); }");; ??? v9: Operand 0 needs a mode, so SImode was chosen.;; However, the code handles both SImode and DImode.(define_expand "seq" [(set (match_operand:SI 0 "intreg_operand" "") (eq:SI (match_dup 1) (const_int 0)))] "! TARGET_LIVE_G0" "{ if (GET_MODE (sparc_compare_op0) == SImode) { rtx pat; if (GET_MODE (operands[0]) == SImode) pat = gen_seqsi_special (operands[0], sparc_compare_op0, sparc_compare_op1); else if (! TARGET_ARCH64) FAIL; else pat = gen_seqsi_special_extend (operands[0], sparc_compare_op0, sparc_compare_op1); emit_insn (pat); DONE; } else if (GET_MODE (sparc_compare_op0) == DImode) { rtx pat; if (! TARGET_ARCH64) FAIL; else if (GET_MODE (operands[0]) == SImode) pat = gen_seqdi_special_trunc (operands[0], sparc_compare_op0, sparc_compare_op1); else pat = gen_seqdi_special (operands[0], sparc_compare_op0, sparc_compare_op1); emit_insn (pat); DONE; } else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) { emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, EQ); emit_insn (gen_sne (operands[0])); DONE; } else if (TARGET_V9) { if (gen_v9_scc (EQ, operands)) DONE; /* fall through */ } FAIL;}");; ??? v9: Operand 0 needs a mode, so SImode was chosen.;; However, the code handles both SImode and DImode.(define_expand "sne" [(set (match_operand:SI 0 "intreg_operand" "") (ne:SI (match_dup 1) (const_int 0)))] "! TARGET_LIVE_G0" "{ if (GET_MODE (sparc_compare_op0) == SImode) { rtx pat; if (GET_MODE (operands[0]) == SImode) pat = gen_snesi_special (operands[0], sparc_compare_op0, sparc_compare_op1); else if (! TARGET_ARCH64) FAIL; else pat = gen_snesi_special_extend (operands[0], sparc_compare_op0, sparc_compare_op1); emit_insn (pat); DONE; } else if (GET_MODE (sparc_compare_op0) == DImode) { rtx pat; if (! TARGET_ARCH64) FAIL; else if (GET_MODE (operands[0]) == SImode) pat = gen_snedi_special_trunc (operands[0], sparc_compare_op0, sparc_compare_op1); else pat = gen_snedi_special (operands[0], sparc_compare_op0, sparc_compare_op1); emit_insn (pat); DONE; } else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) { emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, NE); emit_insn (gen_sne (operands[0])); DONE; } else if (TARGET_V9) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -