Commit 1a0f175d by Ruan Beihong Committed by Richard Sandiford

loongson.md (<u>div<mode>3, [...]): New patterns.

gcc/
2008-11-13  Ruan Beihong  <ruanbeihong@gmail.com>

	* config/mips/loongson.md (<u>div<mode>3, <u>mod<mode>3): New patterns.
	* config/mips/loongson2ef.md (ls2_imult): Handle imul3nc.
	(ls2_idiv): Likewise idiv3.
	(ls2_prefetch): New reservation.
	* config/mips/mips.h (ISA_HAS_PREFETCH): Add TARGET_LOONGSON_2EF.
	* config/mips/mips.md (type): Add imul3nc and idiv3.
	(length): Handle idiv3.
	(any_mod): New code_iterator.
	(u): Handle MOD and UMOD.
	(mul<mode>3): Generate mul<mode>3_mul3_ls2ef on Loongson targets.
	(prefetch): Handle TARGET_LOONGSON_2EF.

From-SVN: r141835
parent a0daa811
2008-11-13 Ruan Beihong <ruanbeihong@gmail.com>
* config/mips/loongson.md (<u>div<mode>3, <u>mod<mode>3): New patterns.
* config/mips/loongson2ef.md (ls2_imult): Handle imul3nc.
(ls2_idiv): Likewise idiv3.
(ls2_prefetch): New reservation.
* config/mips/mips.h (ISA_HAS_PREFETCH): Add TARGET_LOONGSON_2EF.
* config/mips/mips.md (type): Add imul3nc and idiv3.
(length): Handle idiv3.
(any_mod): New code_iterator.
(u): Handle MOD and UMOD.
(mul<mode>3): Generate mul<mode>3_mul3_ls2ef on Loongson targets.
(prefetch): Handle TARGET_LOONGSON_2EF.
2008-11-13 Jakub Jelinek <jakub@redhat.com> 2008-11-13 Jakub Jelinek <jakub@redhat.com>
PR c++/27017 PR c++/27017
......
...@@ -473,3 +473,23 @@ ...@@ -473,3 +473,23 @@
"TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS" "TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS"
"punpckl<V_stretch_half_suffix>\t%0,%1,%2" "punpckl<V_stretch_half_suffix>\t%0,%1,%2"
[(set_attr "type" "fdiv")]) [(set_attr "type" "fdiv")])
;; Integer division and modulus.
(define_insn "<u>div<mode>3"
[(set (match_operand:GPR 0 "register_operand" "=&d")
(any_div:GPR (match_operand:GPR 1 "register_operand" "d")
(match_operand:GPR 2 "register_operand" "d")))]
"TARGET_LOONGSON_2EF"
{ return mips_output_division ("<d>div<u>.g\t%0,%1,%2", operands); }
[(set_attr "type" "idiv3")
(set_attr "mode" "<MODE>")])
(define_insn "<u>mod<mode>3"
[(set (match_operand:GPR 0 "register_operand" "=&d")
(any_mod:GPR (match_operand:GPR 1 "register_operand" "d")
(match_operand:GPR 2 "register_operand" "d")))]
"TARGET_LOONGSON_2EF"
{ return mips_output_division ("<d>mod<u>.g\t%0,%1,%2", operands); }
[(set_attr "type" "idiv3")
(set_attr "mode" "<MODE>")])
...@@ -160,14 +160,14 @@ ...@@ -160,14 +160,14 @@
;; Reservation for integer multiplication instructions. ;; Reservation for integer multiplication instructions.
(define_insn_reservation "ls2_imult" 5 (define_insn_reservation "ls2_imult" 5
(and (eq_attr "cpu" "loongson_2e,loongson_2f") (and (eq_attr "cpu" "loongson_2e,loongson_2f")
(eq_attr "type" "imul,imul3")) (eq_attr "type" "imul,imul3nc"))
"ls2_alu2,ls2_alu2_core") "ls2_alu2,ls2_alu2_core")
;; Reservation for integer division / remainder instructions. ;; Reservation for integer division / remainder instructions.
;; These instructions use the SRT algorithm and hence take 2-38 cycles. ;; These instructions use the SRT algorithm and hence take 2-38 cycles.
(define_insn_reservation "ls2_idiv" 20 (define_insn_reservation "ls2_idiv" 20
(and (eq_attr "cpu" "loongson_2e,loongson_2f") (and (eq_attr "cpu" "loongson_2e,loongson_2f")
(eq_attr "type" "idiv")) (eq_attr "type" "idiv,idiv3"))
"ls2_alu2,ls2_alu2_core*18") "ls2_alu2,ls2_alu2_core*18")
;; Reservation for memory load instructions. ;; Reservation for memory load instructions.
...@@ -176,6 +176,11 @@ ...@@ -176,6 +176,11 @@
(eq_attr "type" "load,fpload,mfc,mtc")) (eq_attr "type" "load,fpload,mfc,mtc"))
"ls2_mem") "ls2_mem")
(define_insn_reservation "ls2_prefetch" 0
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
(eq_attr "type" "prefetch,prefetchx"))
"ls2_mem")
;; Reservation for memory store instructions. ;; Reservation for memory store instructions.
;; With stores we assume they don't alias with dependent loads. ;; With stores we assume they don't alias with dependent loads.
;; Therefore we set the latency to zero. ;; Therefore we set the latency to zero.
......
...@@ -919,6 +919,7 @@ enum mips_code_readable_setting { ...@@ -919,6 +919,7 @@ enum mips_code_readable_setting {
/* ISA has data prefetch instructions. This controls use of 'pref'. */ /* ISA has data prefetch instructions. This controls use of 'pref'. */
#define ISA_HAS_PREFETCH ((ISA_MIPS4 \ #define ISA_HAS_PREFETCH ((ISA_MIPS4 \
|| TARGET_LOONGSON_2EF \
|| ISA_MIPS32 \ || ISA_MIPS32 \
|| ISA_MIPS32R2 \ || ISA_MIPS32R2 \
|| ISA_MIPS64 \ || ISA_MIPS64 \
......
...@@ -351,8 +351,10 @@ ...@@ -351,8 +351,10 @@
;; trap trap if instructions ;; trap trap if instructions
;; imul integer multiply 2 operands ;; imul integer multiply 2 operands
;; imul3 integer multiply 3 operands ;; imul3 integer multiply 3 operands
;; imul3nc integer multiply 3 operands without clobbering HI/LO
;; imadd integer multiply-add ;; imadd integer multiply-add
;; idiv integer divide ;; idiv integer divide 2 operands
;; idiv3 integer divide 3 operands
;; move integer register move ({,D}ADD{,U} with rt = 0) ;; move integer register move ({,D}ADD{,U} with rt = 0)
;; fmove floating point register move ;; fmove floating point register move
;; fadd floating point add/subtract ;; fadd floating point add/subtract
...@@ -376,9 +378,9 @@ ...@@ -376,9 +378,9 @@
(define_attr "type" (define_attr "type"
"unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore, "unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore,
prefetch,prefetchx,condmove,mtc,mfc,mthilo,mfhilo,const,arith,logical, prefetch,prefetchx,condmove,mtc,mfc,mthilo,mfhilo,const,arith,logical,
shift,slt,signext,clz,pop,trap,imul,imul3,imadd,idiv,move,fmove,fadd,fmul, shift,slt,signext,clz,pop,trap,imul,imul3,imul3nc,imadd,idiv,idiv3,move,
fmadd,fdiv,frdiv,frdiv1,frdiv2,fabs,fneg,fcmp,fcvt,fsqrt,frsqrt,frsqrt1, fmove,fadd,fmul,fmadd,fdiv,frdiv,frdiv1,frdiv2,fabs,fneg,fcmp,fcvt,fsqrt,
frsqrt2,multi,nop,ghost" frsqrt,frsqrt1,frsqrt2,multi,nop,ghost"
(cond [(eq_attr "jal" "!unset") (const_string "call") (cond [(eq_attr "jal" "!unset") (const_string "call")
(eq_attr "got" "load") (const_string "load") (eq_attr "got" "load") (const_string "load")
...@@ -553,7 +555,7 @@ ...@@ -553,7 +555,7 @@
(ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0)))) (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0))))
(const_int 8) (const_int 8)
(eq_attr "type" "idiv") (eq_attr "type" "idiv,idiv3")
(symbol_ref "mips_idiv_insns () * 4") (symbol_ref "mips_idiv_insns () * 4")
] (const_int 4))) ] (const_int 4)))
...@@ -787,6 +789,10 @@ ...@@ -787,6 +789,10 @@
;; from the same template. ;; from the same template.
(define_code_iterator any_div [div udiv]) (define_code_iterator any_div [div udiv])
;; This code iterator allows unsigned and signed modulus to be generated
;; from the same template.
(define_code_iterator any_mod [mod umod])
;; This code iterator allows all native floating-point comparisons to be ;; This code iterator allows all native floating-point comparisons to be
;; generated from the same template. ;; generated from the same template.
(define_code_iterator fcond [unordered uneq unlt unle eq lt le]) (define_code_iterator fcond [unordered uneq unlt unle eq lt le])
...@@ -809,6 +815,7 @@ ...@@ -809,6 +815,7 @@
;; "u" when doing an unsigned operation. ;; "u" when doing an unsigned operation.
(define_code_attr u [(sign_extend "") (zero_extend "u") (define_code_attr u [(sign_extend "") (zero_extend "u")
(div "") (udiv "u") (div "") (udiv "u")
(mod "") (umod "u")
(gt "") (gtu "u") (gt "") (gtu "u")
(ge "") (geu "u") (ge "") (geu "u")
(lt "") (ltu "u") (lt "") (ltu "u")
...@@ -1357,7 +1364,10 @@ ...@@ -1357,7 +1364,10 @@
(match_operand:GPR 2 "register_operand")))] (match_operand:GPR 2 "register_operand")))]
"" ""
{ {
if (ISA_HAS_<D>MUL3) if (TARGET_LOONGSON_2EF)
emit_insn (gen_mul<mode>3_mul3_ls2ef (operands[0], operands[1],
operands[2]));
else if (ISA_HAS_<D>MUL3)
emit_insn (gen_mul<mode>3_mul3 (operands[0], operands[1], operands[2])); emit_insn (gen_mul<mode>3_mul3 (operands[0], operands[1], operands[2]));
else if (TARGET_FIX_R4000) else if (TARGET_FIX_R4000)
emit_insn (gen_mul<mode>3_r4000 (operands[0], operands[1], operands[2])); emit_insn (gen_mul<mode>3_r4000 (operands[0], operands[1], operands[2]));
...@@ -1367,6 +1377,15 @@ ...@@ -1367,6 +1377,15 @@
DONE; DONE;
}) })
(define_insn "mul<mode>3_mul3_ls2ef"
[(set (match_operand:GPR 0 "register_operand" "=d")
(mult:GPR (match_operand:GPR 1 "register_operand" "d")
(match_operand:GPR 2 "register_operand" "d")))]
"TARGET_LOONGSON_2EF"
"<d>multu.g\t%0,%1,%2"
[(set_attr "type" "imul3nc")
(set_attr "mode" "<MODE>")])
(define_insn "mul<mode>3_mul3" (define_insn "mul<mode>3_mul3"
[(set (match_operand:GPR 0 "register_operand" "=d,l") [(set (match_operand:GPR 0 "register_operand" "=d,l")
(mult:GPR (match_operand:GPR 1 "register_operand" "d,d") (mult:GPR (match_operand:GPR 1 "register_operand" "d,d")
...@@ -6128,6 +6147,9 @@ ...@@ -6128,6 +6147,9 @@
(match_operand 2 "const_int_operand" "n"))] (match_operand 2 "const_int_operand" "n"))]
"ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS" "ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS"
{ {
if (TARGET_LOONGSON_2EF)
/* Loongson 2[ef] use load to $0 to perform prefetching. */
return "ld\t$0,%a0";
operands[1] = mips_prefetch_cookie (operands[1], operands[2]); operands[1] = mips_prefetch_cookie (operands[1], operands[2]);
return "pref\t%1,%a0"; return "pref\t%1,%a0";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment