📄 altivec.md
字号:
;; AltiVec patterns.;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.;; Contributed by Aldy Hernandez (aldy@quesejoda.com);; This file is part of GCC.;; GCC is free software; you can redistribute it and/or modify it;; under the terms of the GNU General Public License as published;; by the Free Software Foundation; either version 2, or (at your;; option) any later version.;; GCC is distributed in the hope that it will be useful, but WITHOUT;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public;; License for more details.;; You should have received a copy of the GNU General Public License;; along with GCC; see the file COPYING. If not, write to the;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,;; MA 02110-1301, USA.(define_constants [(UNSPEC_VCMPBFP 50) (UNSPEC_VCMPEQUB 51) (UNSPEC_VCMPEQUH 52) (UNSPEC_VCMPEQUW 53) (UNSPEC_VCMPEQFP 54) (UNSPEC_VCMPGEFP 55) (UNSPEC_VCMPGTUB 56) (UNSPEC_VCMPGTSB 57) (UNSPEC_VCMPGTUH 58) (UNSPEC_VCMPGTSH 59) (UNSPEC_VCMPGTUW 60) (UNSPEC_VCMPGTSW 61) (UNSPEC_VCMPGTFP 62) (UNSPEC_VMSUMU 65) (UNSPEC_VMSUMM 66) (UNSPEC_VMSUMSHM 68) (UNSPEC_VMSUMUHS 69) (UNSPEC_VMSUMSHS 70) (UNSPEC_VMHADDSHS 71) (UNSPEC_VMHRADDSHS 72) (UNSPEC_VMLADDUHM 73) (UNSPEC_VADDCUW 75) (UNSPEC_VADDU 76) (UNSPEC_VADDS 77) (UNSPEC_VAVGU 80) (UNSPEC_VAVGS 81) (UNSPEC_VMULEUB 83) (UNSPEC_VMULESB 84) (UNSPEC_VMULEUH 85) (UNSPEC_VMULESH 86) (UNSPEC_VMULOUB 87) (UNSPEC_VMULOSB 88) (UNSPEC_VMULOUH 89) (UNSPEC_VMULOSH 90) (UNSPEC_VPKUHUM 93) (UNSPEC_VPKUWUM 94) (UNSPEC_VPKPX 95) (UNSPEC_VPKSHSS 97) (UNSPEC_VPKSWSS 99) (UNSPEC_VPKUHUS 100) (UNSPEC_VPKSHUS 101) (UNSPEC_VPKUWUS 102) (UNSPEC_VPKSWUS 103) (UNSPEC_VRL 104) (UNSPEC_VSL 107) (UNSPEC_VSLW 109) (UNSPEC_VSLV4SI 110) (UNSPEC_VSLO 111) (UNSPEC_VSR 118) (UNSPEC_VSRO 119) (UNSPEC_VSUBCUW 124) (UNSPEC_VSUBU 125) (UNSPEC_VSUBS 126) (UNSPEC_VSUM4UBS 131) (UNSPEC_VSUM4S 132) (UNSPEC_VSUM2SWS 134) (UNSPEC_VSUMSWS 135) (UNSPEC_VPERM 144) (UNSPEC_VRFIP 148) (UNSPEC_VRFIN 149) (UNSPEC_VRFIM 150) (UNSPEC_VCFUX 151) (UNSPEC_VCFSX 152) (UNSPEC_VCTUXS 153) (UNSPEC_VCTSXS 154) (UNSPEC_VLOGEFP 155) (UNSPEC_VEXPTEFP 156) (UNSPEC_VRSQRTEFP 157) (UNSPEC_VREFP 158) (UNSPEC_VSEL4SI 159) (UNSPEC_VSEL4SF 160) (UNSPEC_VSEL8HI 161) (UNSPEC_VSEL16QI 162) (UNSPEC_VLSDOI 163) (UNSPEC_VUPKHSB 167) (UNSPEC_VUPKHPX 168) (UNSPEC_VUPKHSH 169) (UNSPEC_VUPKLSB 170) (UNSPEC_VUPKLPX 171) (UNSPEC_VUPKLSH 172) (UNSPEC_PREDICATE 173) (UNSPEC_DST 190) (UNSPEC_DSTT 191) (UNSPEC_DSTST 192) (UNSPEC_DSTSTT 193) (UNSPEC_LVSL 194) (UNSPEC_LVSR 195) (UNSPEC_LVE 196) (UNSPEC_STVX 201) (UNSPEC_STVXL 202) (UNSPEC_STVE 203) (UNSPEC_SET_VSCR 213) (UNSPEC_GET_VRSAVE 214) (UNSPEC_REALIGN_LOAD 215) (UNSPEC_REDUC_PLUS 217) (UNSPEC_VECSH 219) (UNSPEC_VCOND_V4SI 301) (UNSPEC_VCOND_V4SF 302) (UNSPEC_VCOND_V8HI 303) (UNSPEC_VCOND_V16QI 304) (UNSPEC_VCONDU_V4SI 305) (UNSPEC_VCONDU_V8HI 306) (UNSPEC_VCONDU_V16QI 307) ])(define_constants [(UNSPECV_SET_VRSAVE 30) (UNSPECV_MTVSCR 186) (UNSPECV_MFVSCR 187) (UNSPECV_DSSALL 188) (UNSPECV_DSS 189) ]);; Vec int modes(define_mode_macro VI [V4SI V8HI V16QI]);; Short vec in modes(define_mode_macro VIshort [V8HI V16QI]);; Vec float modes(define_mode_macro VF [V4SF]);; Vec modes, pity mode macros are not composable(define_mode_macro V [V4SI V8HI V16QI V4SF])(define_mode_attr VI_char [(V4SI "w") (V8HI "h") (V16QI "b")]);; Generic LVX load instruction.(define_insn "altivec_lvx_<mode>" [(set (match_operand:V 0 "altivec_register_operand" "=v") (match_operand:V 1 "memory_operand" "Z"))] "TARGET_ALTIVEC" "lvx %0,%y1" [(set_attr "type" "vecload")]);; Generic STVX store instruction.(define_insn "altivec_stvx_<mode>" [(set (match_operand:V 0 "memory_operand" "=Z") (match_operand:V 1 "altivec_register_operand" "v"))] "TARGET_ALTIVEC" "stvx %1,%y0" [(set_attr "type" "vecstore")]);; Vector move instructions.(define_expand "mov<mode>" [(set (match_operand:V 0 "nonimmediate_operand" "") (match_operand:V 1 "any_operand" ""))] "TARGET_ALTIVEC"{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE;})(define_insn "*mov<mode>_internal" [(set (match_operand:V 0 "nonimmediate_operand" "=Z,v,v,o,r,r,v") (match_operand:V 1 "input_operand" "v,Z,v,r,o,r,W"))] "TARGET_ALTIVEC && (register_operand (operands[0], <MODE>mode) || register_operand (operands[1], <MODE>mode))"{ switch (which_alternative) { case 0: return "stvx %1,%y0"; case 1: return "lvx %0,%y1"; case 2: return "vor %0,%1,%1"; case 3: return "#"; case 4: return "#"; case 5: return "#"; case 6: return output_vec_const_move (operands); default: gcc_unreachable (); }} [(set_attr "type" "vecstore,vecload,vecsimple,store,load,*,*")])(define_split [(set (match_operand:V4SI 0 "nonimmediate_operand" "") (match_operand:V4SI 1 "input_operand" ""))] "TARGET_ALTIVEC && reload_completed && gpr_or_gpr_p (operands[0], operands[1])" [(pc)]{ rs6000_split_multireg_move (operands[0], operands[1]); DONE;})(define_split [(set (match_operand:V8HI 0 "nonimmediate_operand" "") (match_operand:V8HI 1 "input_operand" ""))] "TARGET_ALTIVEC && reload_completed && gpr_or_gpr_p (operands[0], operands[1])" [(pc)]{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })(define_split [(set (match_operand:V16QI 0 "nonimmediate_operand" "") (match_operand:V16QI 1 "input_operand" ""))] "TARGET_ALTIVEC && reload_completed && gpr_or_gpr_p (operands[0], operands[1])" [(pc)]{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })(define_split [(set (match_operand:V4SF 0 "nonimmediate_operand" "") (match_operand:V4SF 1 "input_operand" ""))] "TARGET_ALTIVEC && reload_completed && gpr_or_gpr_p (operands[0], operands[1])" [(pc)]{ rs6000_split_multireg_move (operands[0], operands[1]); DONE;})(define_split [(set (match_operand:VI 0 "altivec_register_operand" "") (match_operand:VI 1 "easy_vector_constant_add_self" ""))] "TARGET_ALTIVEC && reload_completed" [(set (match_dup 0) (match_dup 3)) (set (match_dup 0) (plus:VI (match_dup 0) (match_dup 0)))]{ rtx dup = gen_easy_altivec_constant (operands[1]); rtx const_vec; /* Divide the operand of the resulting VEC_DUPLICATE, and use simplify_rtx to make a CONST_VECTOR. */ XEXP (dup, 0) = simplify_const_binary_operation (ASHIFTRT, QImode, XEXP (dup, 0), const1_rtx); const_vec = simplify_rtx (dup); if (GET_MODE (const_vec) == <MODE>mode) operands[3] = const_vec; else operands[3] = gen_lowpart (<MODE>mode, const_vec);})(define_insn "get_vrsave_internal" [(set (match_operand:SI 0 "register_operand" "=r") (unspec:SI [(reg:SI 109)] UNSPEC_GET_VRSAVE))] "TARGET_ALTIVEC"{ if (TARGET_MACHO) return "mfspr %0,256"; else return "mfvrsave %0";} [(set_attr "type" "*")])(define_insn "*set_vrsave_internal" [(match_parallel 0 "vrsave_operation" [(set (reg:SI 109) (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r") (reg:SI 109)] UNSPECV_SET_VRSAVE))])] "TARGET_ALTIVEC"{ if (TARGET_MACHO) return "mtspr 256,%1"; else return "mtvrsave %1";} [(set_attr "type" "*")])(define_insn "*save_world" [(match_parallel 0 "save_world_operation" [(clobber (match_operand:SI 1 "register_operand" "=l")) (use (match_operand:SI 2 "call_operand" "s"))])] "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT" "bl %z2" [(set_attr "type" "branch") (set_attr "length" "4")])(define_insn "*restore_world" [(match_parallel 0 "restore_world_operation" [(return) (use (match_operand:SI 1 "register_operand" "l")) (use (match_operand:SI 2 "call_operand" "s")) (clobber (match_operand:SI 3 "gpc_reg_operand" "=r"))])] "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT" "b %z2");; Simple binary operations.;; add(define_insn "add<mode>3" [(set (match_operand:VI 0 "register_operand" "=v") (plus:VI (match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")))] "TARGET_ALTIVEC" "vaddu<VI_char>m %0,%1,%2" [(set_attr "type" "vecsimple")])(define_insn "addv4sf3" [(set (match_operand:V4SF 0 "register_operand" "=v") (plus:V4SF (match_operand:V4SF 1 "register_operand" "v") (match_operand:V4SF 2 "register_operand" "v")))] "TARGET_ALTIVEC" "vaddfp %0,%1,%2" [(set_attr "type" "vecfloat")])(define_insn "altivec_vaddcuw" [(set (match_operand:V4SI 0 "register_operand" "=v") (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v") (match_operand:V4SI 2 "register_operand" "v")] UNSPEC_VADDCUW))] "TARGET_ALTIVEC" "vaddcuw %0,%1,%2" [(set_attr "type" "vecsimple")])(define_insn "altivec_vaddu<VI_char>s" [(set (match_operand:VI 0 "register_operand" "=v") (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VADDU)) (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vaddu<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")])(define_insn "altivec_vadds<VI_char>s" [(set (match_operand:VI 0 "register_operand" "=v") (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VADDS)) (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vadds<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")]);; sub(define_insn "sub<mode>3" [(set (match_operand:VI 0 "register_operand" "=v") (minus:VI (match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")))] "TARGET_ALTIVEC" "vsubu<VI_char>m %0,%1,%2" [(set_attr "type" "vecsimple")])(define_insn "subv4sf3" [(set (match_operand:V4SF 0 "register_operand" "=v") (minus:V4SF (match_operand:V4SF 1 "register_operand" "v") (match_operand:V4SF 2 "register_operand" "v")))] "TARGET_ALTIVEC" "vsubfp %0,%1,%2" [(set_attr "type" "vecfloat")])(define_insn "altivec_vsubcuw" [(set (match_operand:V4SI 0 "register_operand" "=v") (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v") (match_operand:V4SI 2 "register_operand" "v")] UNSPEC_VSUBCUW))] "TARGET_ALTIVEC" "vsubcuw %0,%1,%2" [(set_attr "type" "vecsimple")])(define_insn "altivec_vsubu<VI_char>s" [(set (match_operand:VI 0 "register_operand" "=v") (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VSUBU)) (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vsubu<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")])(define_insn "altivec_vsubs<VI_char>s" [(set (match_operand:VI 0 "register_operand" "=v") (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VSUBS)) (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vsubs<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")]);;(define_insn "altivec_vavgu<VI_char>" [(set (match_operand:VI 0 "register_operand" "=v") (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VAVGU))]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -