12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986 |
- /* Copyright (C) 2006-2015 Free Software Foundation, Inc.
- This file 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 3 of the License, or (at your option)
- any later version.
- This file 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.
- Under Section 7 of GPL version 3, you are granted additional
- permissions described in the GCC Runtime Library Exception, version
- 3.1, as published by the Free Software Foundation.
- You should have received a copy of the GNU General Public License and
- a copy of the GCC Runtime Library Exception along with this program;
- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
- <http://www.gnu.org/licenses/>. */
- #ifndef _VMX2SPU_H_
- #define _VMX2SPU_H_ 1
- #ifdef __cplusplus
- #ifdef __SPU__
- #include <spu_intrinsics.h>
- #include <vec_types.h>
- /* This file maps generic VMX intrinsics and predicates to the SPU using
- * overloaded C++ functions.
- */
- /************************************************************************
- * INTRINSICS
- ************************************************************************/
- /* vec_abs (vector absolute value)
- * =======
- */
- static inline vec_char16 vec_abs(vec_char16 a)
- {
- vec_char16 minus_a;
- minus_a = (vec_char16)(spu_add((vec_ushort8)(spu_and(spu_xor(a, 0xFF), 0x7F)), 0x101));
- return (spu_sel(minus_a, a, spu_cmpgt(a, -1)));
- }
- static inline vec_short8 vec_abs(vec_short8 a)
- {
- return (spu_sel(spu_sub(0, a), a, spu_cmpgt(a, -1)));
- }
- static inline vec_int4 vec_abs(vec_int4 a)
- {
- return (spu_sel(spu_sub(0, a), a, spu_cmpgt(a, -1)));
- }
- static inline vec_float4 vec_abs(vec_float4 a)
- {
- return ((vec_float4)(spu_rlmask(spu_sl((vec_uint4)(a), 1), -1)));
- }
- /* vec_abss (vector absolute value saturate)
- * ========
- */
- static inline vec_char16 vec_abss(vec_char16 a)
- {
- vec_char16 minus_a;
- minus_a = (vec_char16)spu_add((vec_short8)(spu_xor(a, -1)),
- (vec_short8)(spu_and(spu_cmpgt((vec_uchar16)(a), 0x80), 1)));
- return (spu_sel(minus_a, a, spu_cmpgt(a, -1)));
- }
- static inline vec_short8 vec_abss(vec_short8 a)
- {
- vec_short8 minus_a;
- minus_a = spu_add(spu_sub(0, a), (vec_short8)(spu_cmpeq(a, ((vec_short8){0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000}))));
- return (spu_sel(minus_a, a, spu_cmpgt(a, -1)));
- }
- static inline vec_int4 vec_abss(vec_int4 a)
- {
- vec_int4 minus_a;
- minus_a = spu_add(spu_sub(0, a), (vec_int4)(spu_cmpeq(a, ((vec_int4){0x80000000,0x80000000,0x80000000,0x80000000}))));
- return (spu_sel(minus_a, a, spu_cmpgt(a, -1)));
- }
- /* vec_add (vector add)
- * =======
- */
- static inline vec_uchar16 vec_add(vec_uchar16 a, vec_uchar16 b)
- {
- return ((vec_uchar16)(spu_sel(spu_add((vec_ushort8)(a), (vec_ushort8)(b)),
- spu_add(spu_and((vec_ushort8)(a), 0xFF00), spu_and((vec_ushort8)(b), 0xFF00)),
- spu_splats((unsigned short)(0xFF00)))));
- }
- static inline vec_char16 vec_add(vec_char16 a, vec_char16 b)
- {
- return ((vec_char16)vec_add((vec_uchar16)(a), (vec_uchar16)(b)));
- }
- static inline vec_char16 vec_add(vec_bchar16 a, vec_char16 b)
- {
- return ((vec_char16)vec_add((vec_uchar16)(a), (vec_uchar16)(b)));
- }
- static inline vec_char16 vec_add(vec_char16 a, vec_bchar16 b)
- {
- return ((vec_char16)vec_add((vec_uchar16)(a), (vec_uchar16)(b)));
- }
- static inline vec_ushort8 vec_add(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_add(a, b));
- }
- static inline vec_short8 vec_add(vec_short8 a, vec_short8 b)
- {
- return (spu_add(a, b));
- }
- static inline vec_short8 vec_add(vec_bshort8 a, vec_short8 b)
- {
- return (spu_add((vec_short8)(a), b));
- }
- static inline vec_short8 vec_add(vec_short8 a, vec_bshort8 b)
- {
- return (spu_add(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_add(vec_uint4 a, vec_uint4 b)
- {
- return (spu_add(a, b));
- }
- static inline vec_int4 vec_add(vec_int4 a, vec_int4 b)
- {
- return (spu_add(a, b));
- }
- static inline vec_int4 vec_add(vec_bint4 a, vec_int4 b)
- {
- return (spu_add((vec_int4)(a), b));
- }
- static inline vec_int4 vec_add(vec_int4 a, vec_bint4 b)
- {
- return (spu_add(a, (vec_int4)(b)));
- }
- static inline vec_float4 vec_add(vec_float4 a, vec_float4 b)
- {
- return (spu_add(a, b));
- }
- /* vec_addc (vector add carryout unsigned word)
- * ========
- */
- #define vec_addc(_a, _b) spu_genc(_a, _b)
- /* vec_adds (vector add saturated)
- * ========
- */
- static inline vec_uchar16 vec_adds(vec_uchar16 a, vec_uchar16 b)
- {
- vec_uchar16 s1, s2, s, d;
- s1 = (vec_uchar16)(spu_add(spu_rlmask((vec_ushort8)(a), -8), spu_rlmask((vec_ushort8)(b), -8)));
- s2 = (vec_uchar16)(spu_add(spu_and((vec_ushort8)(a), 0xFF), spu_and((vec_ushort8)(b), 0xFF)));
- s = spu_shuffle(s1, s2, ((vec_uchar16){0, 16, 2, 18, 4, 20, 6, 22,
- 8, 24, 10, 26, 12, 28, 14, 30}));
- d = spu_shuffle(s1, s2, ((vec_uchar16){1, 17, 3, 19, 5, 21, 7, 23,
- 9, 25, 11, 27, 13, 29, 15, 31}));
- return (spu_or(d, spu_cmpeq(s, 1)));
- }
- static inline vec_char16 vec_adds(vec_char16 a, vec_char16 b)
- {
- vec_uchar16 s1, s2, s, d;
- s1 = (vec_uchar16)(spu_add(spu_rlmask((vec_ushort8)(a), -8), spu_rlmask((vec_ushort8)(b), -8)));
- s2 = (vec_uchar16)(spu_add(spu_and((vec_ushort8)(a), 0xFF), spu_and((vec_ushort8)(b), 0xFF)));
- s = spu_shuffle(s1, s2, ((vec_uchar16){1, 17, 3, 19, 5, 21, 7, 23,
- 9, 25, 11, 27, 13, 29, 15, 31}));
- d = spu_sel(s, spu_splats((unsigned char)0x7F), spu_cmpgt(spu_and(s, (vec_uchar16)(spu_nor(a, b))), 0x7F));
- d = spu_sel(d, spu_splats((unsigned char)0x80), spu_cmpgt(spu_nor(s, (vec_uchar16)(spu_nand(a, b))), 0x7F));
- return ((vec_char16)(d));
- }
- static inline vec_char16 vec_adds(vec_bchar16 a, vec_char16 b)
- {
- return (vec_adds((vec_char16)(a), b));
- }
- static inline vec_char16 vec_adds(vec_char16 a, vec_bchar16 b)
- {
- return (vec_adds(a, (vec_char16)(b)));
- }
- static inline vec_ushort8 vec_adds(vec_ushort8 a, vec_ushort8 b)
- {
- vec_ushort8 s, d;
-
- s = spu_add(a, b);
- d = spu_or(s, spu_rlmaska(spu_sel(spu_xor(s, -1), a, spu_eqv(a, b)), -15));
- return (d);
- }
- static inline vec_short8 vec_adds(vec_short8 a, vec_short8 b)
- {
- vec_short8 s, d;
-
- s = spu_add(a, b);
- d = spu_sel(s, spu_splats((signed short)0x7FFF), (vec_ushort8)(spu_rlmaska(spu_and(s, spu_nor(a, b)), -15)));
- d = spu_sel(d, spu_splats((signed short)0x8000), (vec_ushort8)(spu_rlmaska(spu_nor(s, spu_nand(a, b)), -15)));
- return (d);
- }
- static inline vec_short8 vec_adds(vec_bshort8 a, vec_short8 b)
- {
- return (vec_adds((vec_short8)(a), b));
- }
- static inline vec_short8 vec_adds(vec_short8 a, vec_bshort8 b)
- {
- return (vec_adds(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_adds(vec_uint4 a, vec_uint4 b)
- {
- return (spu_or(spu_add(a, b), spu_rlmaska(spu_sl(spu_genc(a, b), 31), -31)));
- }
- static inline vec_int4 vec_adds(vec_int4 a, vec_int4 b)
- {
- vec_int4 s, d;
-
- s = spu_add(a, b);
- d = spu_sel(s, spu_splats((signed int)0x7FFFFFFF), (vec_uint4)spu_rlmaska(spu_and(s, spu_nor(a, b)), -31));
- d = spu_sel(d, spu_splats((signed int)0x80000000), (vec_uint4)spu_rlmaska(spu_nor(s, spu_nand(a, b)), -31));
- return (d);
- }
- static inline vec_int4 vec_adds(vec_bint4 a, vec_int4 b)
- {
- return (vec_adds((vec_int4)(a), b));
- }
- static inline vec_int4 vec_adds(vec_int4 a, vec_bint4 b)
- {
- return (vec_adds(a, (vec_int4)(b)));
- }
- /* vec_and (vector logical and)
- * =======
- */
- static inline vec_uchar16 vec_and(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_and(a, b));
- }
- static inline vec_char16 vec_and(vec_char16 a, vec_char16 b)
- {
- return (spu_and(a, b));
- }
- static inline vec_char16 vec_and(vec_bchar16 a, vec_char16 b)
- {
- return (spu_and((vec_char16)(a), b));
- }
- static inline vec_char16 vec_and(vec_char16 a, vec_bchar16 b)
- {
- return (spu_and(a, (vec_char16)(b)));
- }
- static inline vec_ushort8 vec_and(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_and(a, b));
- }
- static inline vec_short8 vec_and(vec_short8 a, vec_short8 b)
- {
- return (spu_and(a, b));
- }
- static inline vec_short8 vec_and(vec_bshort8 a, vec_short8 b)
- {
- return (spu_and((vec_short8)(a), b));
- }
- static inline vec_short8 vec_and(vec_short8 a, vec_bshort8 b)
- {
- return (spu_and(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_and(vec_uint4 a, vec_uint4 b)
- {
- return (spu_and(a, b));
- }
- static inline vec_int4 vec_and(vec_int4 a, vec_int4 b)
- {
- return (spu_and(a, b));
- }
- static inline vec_int4 vec_and(vec_bint4 a, vec_int4 b)
- {
- return (spu_and((vec_int4)(a), b));
- }
- static inline vec_int4 vec_and(vec_int4 a, vec_bint4 b)
- {
- return (spu_and(a, (vec_int4)(b)));
- }
- static inline vec_float4 vec_and(vec_float4 a, vec_float4 b)
- {
- return (spu_and(a, b));
- }
- static inline vec_float4 vec_and(vec_bint4 a, vec_float4 b)
- {
- return (spu_and((vec_float4)(a),b));
- }
- static inline vec_float4 vec_and(vec_float4 a, vec_bint4 b)
- {
- return (spu_and(a, (vec_float4)(b)));
- }
- /* vec_andc (vector logical and with complement)
- * ========
- */
- static inline vec_uchar16 vec_andc(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_andc(a, b));
- }
- static inline vec_char16 vec_andc(vec_char16 a, vec_char16 b)
- {
- return (spu_andc(a, b));
- }
- static inline vec_char16 vec_andc(vec_bchar16 a, vec_char16 b)
- {
- return (spu_andc((vec_char16)(a), b));
- }
- static inline vec_char16 vec_andc(vec_char16 a, vec_bchar16 b)
- {
- return (spu_andc(a, (vec_char16)(b)));
- }
- static inline vec_ushort8 vec_andc(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_andc(a, b));
- }
- static inline vec_short8 vec_andc(vec_short8 a, vec_short8 b)
- {
- return (spu_andc(a, b));
- }
- static inline vec_short8 vec_andc(vec_bshort8 a, vec_short8 b)
- {
- return (spu_andc((vec_short8)(a), b));
- }
- static inline vec_short8 vec_andc(vec_short8 a, vec_bshort8 b)
- {
- return (spu_andc(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_andc(vec_uint4 a, vec_uint4 b)
- {
- return (spu_andc(a, b));
- }
- static inline vec_int4 vec_andc(vec_int4 a, vec_int4 b)
- {
- return (spu_andc(a, b));
- }
- static inline vec_int4 vec_andc(vec_bint4 a, vec_int4 b)
- {
- return (spu_andc((vec_int4)(a), b));
- }
- static inline vec_int4 vec_andc(vec_int4 a, vec_bint4 b)
- {
- return (spu_andc(a, (vec_int4)(b)));
- }
- static inline vec_float4 vec_andc(vec_float4 a, vec_float4 b)
- {
- return (spu_andc(a,b));
- }
- static inline vec_float4 vec_andc(vec_bint4 a, vec_float4 b)
- {
- return (spu_andc((vec_float4)(a),b));
- }
- static inline vec_float4 vec_andc(vec_float4 a, vec_bint4 b)
- {
- return (spu_andc(a, (vec_float4)(b)));
- }
- /* vec_avg (vector average)
- * =======
- */
- static inline vec_uchar16 vec_avg(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_avg(a, b));
- }
- static inline vec_char16 vec_avg(vec_char16 a, vec_char16 b)
- {
- return ((vec_char16)(spu_xor(spu_avg((vec_uchar16)(a), (vec_uchar16)(b)),
- (vec_uchar16)(spu_and(spu_xor(a,b), 0x80)))));
- }
- static inline vec_ushort8 vec_avg(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_add(spu_add(spu_rlmask(a, -1), spu_rlmask(b, -1)),
- spu_and(spu_or(a, b), 1)));
- }
- static inline vec_short8 vec_avg(vec_short8 a, vec_short8 b)
- {
- return (spu_add(spu_add(spu_rlmaska(a, -1), spu_rlmaska(b, -1)),
- spu_and(spu_or(a, b), 1)));
- }
- static inline vec_uint4 vec_avg(vec_uint4 a, vec_uint4 b)
- {
- return (spu_add(spu_add(spu_rlmask(a, -1), spu_rlmask(b, -1)),
- spu_and(spu_or(a, b), 1)));
- }
- static inline vec_int4 vec_avg(vec_int4 a, vec_int4 b)
- {
- return (spu_add(spu_add(spu_rlmaska(a, -1), spu_rlmaska(b, -1)),
- spu_and(spu_or(a, b), 1)));
- }
- /* vec_ceil (vector ceiling)
- * ========
- */
- static inline vec_float4 vec_ceil(vec_float4 a)
- {
- vec_int4 exp;
- vec_uint4 mask;
- a = spu_add(a, (vec_float4)(spu_and(spu_xor(spu_rlmaska((vec_int4)a, -31), -1), spu_splats((signed int)0x3F7FFFFF))));
- exp = spu_sub(127, (vec_int4)(spu_and(spu_rlmask((vec_uint4)(a), -23), 0xFF)));
- mask = spu_rlmask(spu_splats((unsigned int)0x7FFFFF), exp);
- mask = spu_sel(spu_splats((unsigned int)0), mask, spu_cmpgt(exp, -31));
- mask = spu_or(mask, spu_xor((vec_uint4)(spu_rlmaska(spu_add(exp, -1), -31)), -1));
- return ((vec_float4)(spu_andc((vec_uint4)(a), mask)));
- }
- /* vec_cmpb (vector compare bounds floating-point)
- * ========
- */
- static inline vec_int4 vec_cmpb(vec_float4 a, vec_float4 b)
- {
- vec_int4 b0 = (vec_int4)spu_splats(0x80000000);
- vec_int4 b1 = (vec_int4)spu_splats(0x40000000);
- return (spu_or(spu_and((vec_int4)spu_cmpgt(a, b), b0),
- spu_and((vec_int4)spu_cmpgt(spu_xor(b, (vec_float4)(b0)), a), b1)));
- }
- /* vec_cmpeq (vector compare equal)
- * =========
- */
- #define vec_cmpeq(_a, _b) spu_cmpeq(_a, _b)
- /* vec_cmpge (vector compare greater than or equal)
- * =========
- */
- static inline vec_bint4 vec_cmpge(vec_float4 a, vec_float4 b)
- {
- return (spu_xor(spu_cmpgt(b, a), -1));
- }
- /* vec_cmpgt (vector compare greater than)
- * =========
- */
- #define vec_cmpgt(_a, _b) spu_cmpgt(_a, _b)
- /* vec_cmple (vector compare less than or equal)
- * =========
- */
- static inline vec_bint4 vec_cmple(vec_float4 a, vec_float4 b)
- {
- return (spu_xor(spu_cmpgt(a, b), -1));
- }
- /* vec_cmplt (vector compare less than)
- * =========
- */
- #define vec_cmplt(_a, _b) spu_cmpgt(_b, _a)
- /* vec_ctf (vector convert from fixed-point word)
- * =======
- */
- #define vec_ctf(_a, _b) spu_convtf(_a, _b)
- /* vec_cts (vector convert to signed fixed-point word saturate)
- * =======
- */
- #define vec_cts(_a, _b) spu_convts(_a, _b)
- /* vec_ctu (vector convert to unsigned fixed-point word saturate)
- * =======
- */
- #define vec_ctu(_a, _b) spu_convtu(_a, _b)
- /* vec_dss (vector data stream stop)
- * =======
- */
- #define vec_dss(_a)
- /* vec_dssall (vector data stream stop all)
- * ==========
- */
- #define vec_dssall()
- /* vec_dst (vector data stream touch)
- * =======
- */
- #define vec_dst(_a, _b, _c)
- /* vec_dstst (vector data stream touch for store)
- * =========
- */
- #define vec_dstst(_a, _b, _c)
- /* vec_dststt (vector data stream touch for store transient)
- * ==========
- */
- #define vec_dststt(_a, _b, _c)
- /* vec_dstt (vector data stream touch transient)
- * ========
- */
- #define vec_dstt(_a, _b, _c)
- /* vec_expte (vector is 2 raised tp the exponent estimate floating-point)
- * =========
- */
- static inline vec_float4 vec_expte(vec_float4 a)
- {
- vec_float4 bias, frac, exp;
- vec_int4 ia;
- bias = (vec_float4)(spu_andc(spu_splats((signed int)0x3F7FFFFF), spu_rlmaska((vec_int4)(a), -31)));
- ia = spu_convts(spu_add(a, bias), 0);
- frac = spu_sub(spu_convtf(ia, 0), a);
- exp = (vec_float4)(spu_sl(spu_add(ia, 127), 23));
- return (spu_mul(spu_madd(spu_madd(spu_splats(0.17157287f), frac, spu_splats(-0.67157287f)),
- frac, spu_splats(1.0f)), exp));
- }
- /* vec_floor (vector floor)
- * =========
- */
- static inline vec_float4 vec_floor(vec_float4 a)
- {
- vec_int4 exp;
- vec_uint4 mask;
- a = spu_sub(a, (vec_float4)(spu_and(spu_rlmaska((vec_int4)a, -31), spu_splats((signed int)0x3F7FFFFF))));
- exp = spu_sub(127, (vec_int4)(spu_and(spu_rlmask((vec_uint4)(a), -23), 0xFF)));
- mask = spu_rlmask(spu_splats((unsigned int)0x7FFFFF), exp);
- mask = spu_sel(spu_splats((unsigned int)0), mask, spu_cmpgt(exp, -31));
- mask = spu_or(mask, spu_xor((vec_uint4)(spu_rlmaska(spu_add(exp, -1), -31)), -1));
- return ((vec_float4)(spu_andc((vec_uint4)(a), mask)));
- }
- /* vec_ld (vector load indexed)
- * ======
- */
- static inline vec_uchar16 vec_ld(int a, unsigned char *b)
- {
- return (*((vec_uchar16 *)(b+a)));
- }
- static inline vec_uchar16 vec_ld(int a, vec_uchar16 *b)
- {
- return (*((vec_uchar16 *)((unsigned char *)(b)+a)));
- }
- static inline vec_char16 vec_ld(int a, signed char *b)
- {
- return (*((vec_char16 *)(b+a)));
- }
- static inline vec_char16 vec_ld(int a, vec_char16 *b)
- {
- return (*((vec_char16 *)((signed char *)(b)+a)));
- }
- static inline vec_ushort8 vec_ld(int a, unsigned short *b)
- {
- return (*((vec_ushort8 *)((unsigned char *)(b)+a)));
- }
- static inline vec_ushort8 vec_ld(int a, vec_ushort8 *b)
- {
- return (*((vec_ushort8 *)((unsigned char *)(b)+a)));
- }
- static inline vec_short8 vec_ld(int a, signed short *b)
- {
- return (*((vec_short8 *)((unsigned char *)(b)+a)));
- }
- static inline vec_short8 vec_ld(int a, vec_short8 *b)
- {
- return (*((vec_short8 *)((signed char *)(b)+a)));
- }
- static inline vec_uint4 vec_ld(int a, unsigned int *b)
- {
- return (*((vec_uint4 *)((unsigned char *)(b)+a)));
- }
- static inline vec_uint4 vec_ld(int a, vec_uint4 *b)
- {
- return (*((vec_uint4 *)((unsigned char *)(b)+a)));
- }
- static inline vec_int4 vec_ld(int a, signed int *b)
- {
- return (*((vec_int4 *)((unsigned char *)(b)+a)));
- }
- static inline vec_int4 vec_ld(int a, vec_int4 *b)
- {
- return (*((vec_int4 *)((signed char *)(b)+a)));
- }
- static inline vec_float4 vec_ld(int a, float *b)
- {
- return (*((vec_float4 *)((unsigned char *)(b)+a)));
- }
- static inline vec_float4 vec_ld(int a, vec_float4 *b)
- {
- return (*((vec_float4 *)((unsigned char *)(b)+a)));
- }
- /* vec_lde (vector load element indexed)
- * =======
- */
- static inline vec_uchar16 vec_lde(int a, unsigned char *b)
- {
- return (*((vec_uchar16 *)(b+a)));
- }
- static inline vec_char16 vec_lde(int a, signed char *b)
- {
- return (*((vec_char16 *)(b+a)));
- }
- static inline vec_ushort8 vec_lde(int a, unsigned short *b)
- {
- return (*((vec_ushort8 *)((unsigned char *)(b)+a)));
- }
- static inline vec_short8 vec_lde(int a, signed short *b)
- {
- return (*((vec_short8 *)((unsigned char *)(b)+a)));
- }
- static inline vec_uint4 vec_lde(int a, unsigned int *b)
- {
- return (*((vec_uint4 *)((unsigned char *)(b)+a)));
- }
- static inline vec_int4 vec_lde(int a, signed int *b)
- {
- return (*((vec_int4 *)((unsigned char *)(b)+a)));
- }
- static inline vec_float4 vec_lde(int a, float *b)
- {
- return (*((vec_float4 *)((unsigned char *)(b)+a)));
- }
- /* vec_ldl (vector load indexed LRU)
- * =======
- */
- #define vec_ldl(_a, _b) vec_ld(_a, _b)
- /* vec_loge (vector log2 estimate floating-point)
- * ========
- */
- static inline vec_float4 vec_loge(vec_float4 a)
- {
- vec_int4 exp;
- vec_float4 frac;
- exp = spu_add((vec_int4)(spu_and(spu_rlmask((vec_uint4)(a), -23), 0xFF)), -127);
- frac = (vec_float4)(spu_sub((vec_int4)(a), spu_sl(exp, 23)));
- return (spu_madd(spu_madd(spu_splats(-0.33985f), frac, spu_splats(2.01955f)),
- frac, spu_sub(spu_convtf(exp, 0), spu_splats(1.6797f))));
- }
- /* vec_lvsl (vector load for shift left)
- * ========
- */
- static inline vec_uchar16 vec_lvsl(int a, unsigned char *b)
- {
- return ((vec_uchar16)spu_add((vec_ushort8)(spu_splats((unsigned char)((a + (int)(b)) & 0xF))),
- ((vec_ushort8){0x0001, 0x0203, 0x0405, 0x0607,
- 0x0809, 0x0A0B, 0x0C0D, 0x0E0F})));
- }
- static inline vec_uchar16 vec_lvsl(int a, signed char *b)
- {
- return (vec_lvsl(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsl(int a, unsigned short *b)
- {
- return (vec_lvsl(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsl(int a, short *b)
- {
- return (vec_lvsl(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsl(int a, unsigned int *b)
- {
- return (vec_lvsl(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsl(int a, int *b)
- {
- return (vec_lvsl(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsl(int a, float *b)
- {
- return (vec_lvsl(a, (unsigned char *)b));
- }
- /* vec_lvsr (vector load for shift right)
- * ========
- */
- static inline vec_uchar16 vec_lvsr(int a, unsigned char *b)
- {
- return ((vec_uchar16)(spu_sub(((vec_ushort8){0x1011, 0x1213, 0x1415, 0x1617,
- 0x1819, 0x1A1B, 0x1C1D, 0x1E1F}),
- (vec_ushort8)(spu_splats((unsigned char)((a + (int)(b)) & 0xF))))));
- }
- static inline vec_uchar16 vec_lvsr(int a, signed char *b)
- {
- return (vec_lvsr(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsr(int a, unsigned short *b)
- {
- return (vec_lvsr(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsr(int a, short *b)
- {
- return (vec_lvsr(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsr(int a, unsigned int *b)
- {
- return (vec_lvsr(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsr(int a, int *b)
- {
- return (vec_lvsr(a, (unsigned char *)b));
- }
- static inline vec_uchar16 vec_lvsr(int a, float *b)
- {
- return (vec_lvsr(a, (unsigned char *)b));
- }
- /* vec_madd (vector multiply add)
- * ========
- */
- #define vec_madd(_a, _b, _c) spu_madd(_a, _b, _c)
- /* vec_madds (vector multiply add saturate)
- * =========
- */
- static inline vec_short8 vec_madds(vec_short8 a, vec_short8 b, vec_short8 c)
- {
- return (vec_adds(c, spu_sel((vec_short8)(spu_sl(spu_mule(a, b), 1)),
- (vec_short8)(spu_rlmask(spu_mulo(a, b), -15)),
- ((vec_ushort8){0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF}))));
- }
- /* vec_max (vector maximum)
- * =======
- */
- static inline vec_uchar16 vec_max(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_sel(b, a, spu_cmpgt(a, b)));
- }
- static inline vec_char16 vec_max(vec_char16 a, vec_char16 b)
- {
- return (spu_sel(b, a, spu_cmpgt(a, b)));
- }
- static inline vec_char16 vec_max(vec_bchar16 a, vec_char16 b)
- {
- return (spu_sel(b, (vec_char16)(a), spu_cmpgt((vec_char16)(a), b)));
- }
- static inline vec_char16 vec_max(vec_char16 a, vec_bchar16 b)
- {
- return (spu_sel((vec_char16)(b), a, spu_cmpgt(a, (vec_char16)(b))));
- }
- static inline vec_ushort8 vec_max(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_sel(b, a, spu_cmpgt(a, b)));
- }
- static inline vec_short8 vec_max(vec_short8 a, vec_short8 b)
- {
- return (spu_sel(b, a, spu_cmpgt(a, b)));
- }
- static inline vec_short8 vec_max(vec_bshort8 a, vec_short8 b)
- {
- return (spu_sel(b, (vec_short8)(a), spu_cmpgt((vec_short8)(a), b)));
- }
- static inline vec_short8 vec_max(vec_short8 a, vec_bshort8 b)
- {
- return (spu_sel((vec_short8)(b), a, spu_cmpgt(a, (vec_short8)(b))));
- }
- static inline vec_uint4 vec_max(vec_uint4 a, vec_uint4 b)
- {
- return (spu_sel(b, a, spu_cmpgt(a, b)));
- }
- static inline vec_int4 vec_max(vec_int4 a, vec_int4 b)
- {
- return (spu_sel(b, a, spu_cmpgt(a, b)));
- }
- static inline vec_int4 vec_max(vec_bint4 a, vec_int4 b)
- {
- return (spu_sel(b, (vec_int4)(a), spu_cmpgt((vec_int4)(a), b)));
- }
- static inline vec_int4 vec_max(vec_int4 a, vec_bint4 b)
- {
- return (spu_sel((vec_int4)(b), a, spu_cmpgt(a, (vec_int4)(b))));
- }
- static inline vec_float4 vec_max(vec_float4 a, vec_float4 b)
- {
- return (spu_sel(b, a, spu_cmpgt(a, b)));
- }
- /* vec_mergeh (vector merge high)
- * ==========
- */
- static inline vec_uchar16 vec_mergeh(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){0, 16, 1, 17, 2, 18, 3, 19,
- 4, 20, 5, 21, 6, 22, 7, 23})));
- }
- static inline vec_char16 vec_mergeh(vec_char16 a, vec_char16 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){0, 16, 1, 17, 2, 18, 3, 19,
- 4, 20, 5, 21, 6, 22, 7, 23})));
- }
- static inline vec_ushort8 vec_mergeh(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){0, 1, 16, 17, 2, 3, 18, 19,
- 4, 5, 20, 21, 6, 7, 22, 23})));
- }
- static inline vec_short8 vec_mergeh(vec_short8 a, vec_short8 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){0, 1, 16, 17, 2, 3, 18, 19,
- 4, 5, 20, 21, 6, 7, 22, 23})));
- }
- static inline vec_uint4 vec_mergeh(vec_uint4 a, vec_uint4 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){0, 1, 2, 3, 16, 17, 18, 19,
- 4, 5, 6, 7, 20, 21, 22, 23})));
- }
- static inline vec_int4 vec_mergeh(vec_int4 a, vec_int4 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){0, 1, 2, 3, 16, 17, 18, 19,
- 4, 5, 6, 7, 20, 21, 22, 23})));
- }
- static inline vec_float4 vec_mergeh(vec_float4 a, vec_float4 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){0, 1, 2, 3, 16, 17, 18, 19,
- 4, 5, 6, 7, 20, 21, 22, 23})));
- }
- /* vec_mergel (vector merge low)
- * ==========
- */
- static inline vec_uchar16 vec_mergel(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){ 8, 24, 9, 25, 10, 26, 11, 27,
- 12, 28, 13, 29, 14, 30, 15, 31})));
- }
- static inline vec_char16 vec_mergel(vec_char16 a, vec_char16 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){ 8, 24, 9, 25, 10, 26, 11, 27,
- 12, 28, 13, 29, 14, 30, 15, 31})));
- }
- static inline vec_ushort8 vec_mergel(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){ 8, 9, 24, 25, 10, 11, 26, 27,
- 12, 13, 28, 29, 14, 15, 30, 31})));
- }
- static inline vec_short8 vec_mergel(vec_short8 a, vec_short8 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){ 8, 9, 24, 25, 10, 11, 26, 27,
- 12, 13, 28, 29, 14, 15, 30, 31})));
- }
- static inline vec_uint4 vec_mergel(vec_uint4 a, vec_uint4 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){ 8, 9, 10, 11, 24, 25, 26, 27,
- 12, 13, 14, 15, 28, 29, 30, 31})));
- }
- static inline vec_int4 vec_mergel(vec_int4 a, vec_int4 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){ 8, 9, 10, 11, 24, 25, 26, 27,
- 12, 13, 14, 15, 28, 29, 30, 31})));
- }
- static inline vec_float4 vec_mergel(vec_float4 a, vec_float4 b)
- {
- return (spu_shuffle(a, b, ((vec_uchar16){ 8, 9, 10, 11, 24, 25, 26, 27,
- 12, 13, 14, 15, 28, 29, 30, 31})));
- }
- /* vec_mfvscr (vector move from vector status and control register)
- * ==========
- */
- static inline vec_ushort8 vec_mfvscr()
- {
- return ((vec_ushort8)spu_splats(0)); /* not supported */
- }
- /* vec_min (vector minimum)
- * =======
- */
- static inline vec_uchar16 vec_min(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_sel(a, b, spu_cmpgt(a, b)));
- }
- static inline vec_char16 vec_min(vec_char16 a, vec_char16 b)
- {
- return (spu_sel(a, b, spu_cmpgt(a, b)));
- }
- static inline vec_char16 vec_min(vec_bchar16 a, vec_char16 b)
- {
- return (spu_sel((vec_char16)(a), b, spu_cmpgt((vec_char16)(a), b)));
- }
- static inline vec_char16 vec_min(vec_char16 a, vec_bchar16 b)
- {
- return (spu_sel(a, (vec_char16)(b), spu_cmpgt(a, (vec_char16)(b))));
- }
- static inline vec_ushort8 vec_min(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_sel(a, b, spu_cmpgt(a, b)));
- }
- static inline vec_short8 vec_min(vec_short8 a, vec_short8 b)
- {
- return (spu_sel(a, b, spu_cmpgt(a, b)));
- }
- static inline vec_short8 vec_min(vec_bshort8 a, vec_short8 b)
- {
- return (spu_sel((vec_short8)(a), b, spu_cmpgt((vec_short8)(a), b)));
- }
- static inline vec_short8 vec_min(vec_short8 a, vec_bshort8 b)
- {
- return (spu_sel(a, (vec_short8)(b), spu_cmpgt(a, (vec_short8)(b))));
- }
- static inline vec_uint4 vec_min(vec_uint4 a, vec_uint4 b)
- {
- return (spu_sel(a, b, spu_cmpgt(a, b)));
- }
- static inline vec_int4 vec_min(vec_int4 a, vec_int4 b)
- {
- return (spu_sel(a, b, spu_cmpgt(a, b)));
- }
- static inline vec_int4 vec_min(vec_bint4 a, vec_int4 b)
- {
- return (spu_sel((vec_int4)(a), b, spu_cmpgt((vec_int4)(a), b)));
- }
- static inline vec_int4 vec_min(vec_int4 a, vec_bint4 b)
- {
- return (spu_sel(a, (vec_int4)(b), spu_cmpgt(a, (vec_int4)(b))));
- }
- static inline vec_float4 vec_min(vec_float4 a, vec_float4 b)
- {
- return (spu_sel(a, b, spu_cmpgt(a, b)));
- }
- /* vec_mladd (vector multiply low and add unsigned half word)
- * =========
- */
- static inline vec_short8 vec_mladd(vec_short8 a, vec_short8 b, vec_short8 c)
- {
- return ((vec_short8)(spu_shuffle(spu_madd((vec_short8)(spu_rl((vec_uint4)(a), -16)),
- (vec_short8)(spu_rl((vec_uint4)(b), -16)),
- (vec_int4)(spu_rl((vec_uint4)(c), -16))),
- spu_madd(a, b, spu_extend(c)),
- ((vec_uchar16){ 2, 3, 18, 19, 6, 7, 22, 23,
- 10, 11, 26, 27, 14, 15, 30, 31}))));
- }
- static inline vec_ushort8 vec_mladd(vec_ushort8 a, vec_ushort8 b, vec_ushort8 c)
- {
- return ((vec_ushort8)(vec_mladd((vec_short8)(a), (vec_short8)(b), (vec_short8)(c))));
- }
- static inline vec_short8 vec_mladd(vec_ushort8 a, vec_short8 b, vec_short8 c)
- {
- return (vec_mladd((vec_short8)(a), b, c));
- }
- static inline vec_short8 vec_mladd(vec_short8 a, vec_ushort8 b, vec_ushort8 c)
- {
- return (vec_mladd(a, (vec_short8)(b), (vec_short8)(c)));
- }
- /* vec_mradds (vector multiply round and add saturate)
- * ==========
- */
- static inline vec_short8 vec_mradds(vec_short8 a, vec_short8 b, vec_short8 c)
- {
- vec_int4 round = (vec_int4)spu_splats(0x4000);
- vec_short8 hi, lo;
- hi = (vec_short8)(spu_sl(spu_add(spu_mule(a, b), round), 1));
- lo = (vec_short8)(spu_rlmask(spu_add(spu_mulo(a, b), round), -15));
- return (vec_adds(spu_sel(hi, lo, ((vec_ushort8){0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF})), c));
- }
- /* vec_msum (vector multiply sum)
- * ========
- */
- static inline vec_uint4 vec_msum(vec_uchar16 a, vec_uchar16 b, vec_uint4 c)
- {
- vec_ushort8 a1, a2, b1, b2;
- vec_uint4 p1, p2;
- a1 = spu_and((vec_ushort8)(a), 0xFF);
- a2 = spu_rlmask((vec_ushort8)(a), -8);
- b1 = spu_and((vec_ushort8)(b), 0xFF);
- b2 = spu_rlmask((vec_ushort8)(b), -8);
- p1 = spu_add(spu_mulo(a1, b1), spu_mulo(spu_rlqwbyte(a1, -2), spu_rlqwbyte(b1, -2)));
- p2 = spu_add(spu_mulo(a2, b2), spu_mulo(spu_rlqwbyte(a2, -2), spu_rlqwbyte(b2, -2)));
- return (spu_add(p2, spu_add(p1, c)));
- }
- static inline vec_int4 vec_msum(vec_char16 a, vec_uchar16 b, vec_int4 c)
- {
- vec_short8 a1, a2, b1, b2;
- vec_int4 p1, p2;
- a1 = (vec_short8)(spu_extend(a));
- a2 = spu_rlmaska((vec_short8)(a), -8);
- b1 = (vec_short8)(spu_and((vec_ushort8)(b), 0xFF));
- b2 = (vec_short8)spu_rlmask((vec_ushort8)(b), -8);
- p1 = spu_add(spu_mulo(a1, b1), spu_mulo(spu_rlqwbyte(a1, -2), spu_rlqwbyte(b1, -2)));
- p2 = spu_add(spu_mulo(a2, b2), spu_mulo(spu_rlqwbyte(a2, -2), spu_rlqwbyte(b2, -2)));
- return (spu_add(p2, spu_add(p1, c)));
- }
- static inline vec_uint4 vec_msum(vec_ushort8 a, vec_ushort8 b, vec_uint4 c)
- {
- return (spu_add(spu_add(spu_mulo(a, b), spu_mulo(spu_rlqwbyte(a, -2), spu_rlqwbyte(b, -2))), c));
- }
- static inline vec_int4 vec_msum(vec_short8 a, vec_short8 b, vec_int4 c)
- {
- return (spu_add(spu_add(spu_mulo(a, b), spu_mulo(spu_rlqwbyte(a, -2), spu_rlqwbyte(b, -2))), c));
- }
- /* vec_msums (vector multiply sum saturate)
- * ========
- */
- static inline vec_uint4 vec_msums(vec_ushort8 a, vec_ushort8 b, vec_uint4 c)
- {
- vec_uint4 p1, p2;
- p1 = spu_mulo(a, b);
- p2 = spu_mulo(spu_rlqwbyte(a, -2), spu_rlqwbyte(b, -2));
- return (vec_adds(p2, vec_adds(p1, c)));
- }
- static inline vec_int4 vec_msums(vec_short8 a, vec_short8 b, vec_int4 c)
- {
- return (vec_adds(spu_add(spu_mulo(a, b), spu_mulo(spu_rlqwbyte(a, -2), spu_rlqwbyte(b, -2))), c));
- }
- /* vec_mtvscr (vector move to vector status and control register)
- * ==========
- */
- #define vec_mtvscr(_a) /* not supported */
- /* vec_mule (vector multiply even)
- * ========
- */
- static inline vec_ushort8 vec_mule(vec_uchar16 a, vec_uchar16 b)
- {
- vec_ushort8 hi, lo;
- hi = (vec_ushort8)spu_mulo((vec_ushort8)(spu_rlmask((vec_uint4)(a), -24)),
- (vec_ushort8)(spu_rlmask((vec_uint4)(b), -24)));
- lo = (vec_ushort8)spu_mulo((vec_ushort8)(spu_rlmask((vec_short8)(a), -8)),
- (vec_ushort8)(spu_rlmask((vec_short8)(b), -8)));
- return (spu_shuffle(hi, lo, ((vec_uchar16){ 2, 3, 18, 19, 6, 7, 22, 23,
- 10, 11, 26, 27, 14, 15, 30, 31})));
- }
- static inline vec_short8 vec_mule(vec_char16 a, vec_char16 b)
- {
- vec_short8 hi, lo;
- hi = (vec_short8)spu_mulo((vec_short8)(spu_rlmaska((vec_uint4)(a), -24)),
- (vec_short8)(spu_rlmaska((vec_uint4)(b), -24)));
- lo = (vec_short8)spu_mulo((vec_short8)(spu_rlmaska((vec_short8)(a), -8)),
- (vec_short8)(spu_rlmaska((vec_short8)(b), -8)));
- return (spu_shuffle(hi, lo, ((vec_uchar16){ 2, 3, 18, 19, 6, 7, 22, 23,
- 10, 11, 26, 27, 14, 15, 30, 31})));
- }
- static inline vec_uint4 vec_mule(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_mulo((vec_ushort8)spu_rlmask((vec_uint4)(a), -16),
- (vec_ushort8)spu_rlmask((vec_uint4)(b), -16)));
- }
- static inline vec_int4 vec_mule(vec_short8 a, vec_short8 b)
- {
- return (spu_mulo((vec_short8)spu_rlmaska((vec_int4)(a), -16),
- (vec_short8)spu_rlmaska((vec_int4)(b), -16)));
- }
- /* vec_mulo (vector multiply odd)
- * ========
- */
- static inline vec_ushort8 vec_mulo(vec_uchar16 a, vec_uchar16 b)
- {
- vec_ushort8 hi, lo;
- hi = (vec_ushort8)spu_mulo((vec_ushort8)(spu_and(spu_rlmask((vec_uint4)(a), -16), 0xFF)),
- (vec_ushort8)(spu_and(spu_rlmask((vec_uint4)(b), -16), 0xFF)));
- lo = (vec_ushort8)spu_mulo(spu_and((vec_ushort8)(a), 0xFF), spu_and((vec_ushort8)(b), 0xFF));
- return (spu_shuffle(hi, lo, ((vec_uchar16){ 2, 3, 18, 19, 6, 7, 22, 23,
- 10, 11, 26, 27, 14, 15, 30, 31})));
- }
- static inline vec_short8 vec_mulo(vec_char16 a, vec_char16 b)
- {
- vec_short8 aa, bb, hi, lo;
- aa = spu_extend(a);
- bb = spu_extend(b);
- hi = (vec_short8)spu_mulo((vec_short8)(spu_rlmaska((vec_uint4)(aa), -16)),
- (vec_short8)(spu_rlmaska((vec_uint4)(bb), -16)));
- lo = (vec_short8)spu_mulo(aa, bb);
- return (spu_shuffle(hi, lo, ((vec_uchar16){ 2, 3, 18, 19, 6, 7, 22, 23,
- 10, 11, 26, 27, 14, 15, 30, 31})));
- }
- static inline vec_uint4 vec_mulo(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_mulo(a, b));
- }
- static inline vec_int4 vec_mulo(vec_short8 a, vec_short8 b)
- {
- return (spu_mulo(a, b));
- }
- /* vec_nmsub (vector negative multiply subtract)
- * =========
- */
- #define vec_nmsub(_a, _b, _c) spu_nmsub(_a, _b, _c)
- /* vec_nor (vector logical nor)
- * =======
- */
- #define vec_nor(_a, _b) spu_nor(_a, _b)
- /* vec_or (vector logical or)
- * ======
- */
- static inline vec_uchar16 vec_or(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_or(a, b));
- }
- static inline vec_char16 vec_or(vec_char16 a, vec_char16 b)
- {
- return (spu_or(a, b));
- }
- static inline vec_char16 vec_or(vec_bchar16 a, vec_char16 b)
- {
- return (spu_or((vec_char16)(a), b));
- }
- static inline vec_char16 vec_or(vec_char16 a, vec_bchar16 b)
- {
- return (spu_or(a, (vec_char16)(b)));
- }
- static inline vec_ushort8 vec_or(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_or(a, b));
- }
- static inline vec_short8 vec_or(vec_short8 a, vec_short8 b)
- {
- return (spu_or(a, b));
- }
- static inline vec_short8 vec_or(vec_bshort8 a, vec_short8 b)
- {
- return (spu_or((vec_short8)(a), b));
- }
- static inline vec_short8 vec_or(vec_short8 a, vec_bshort8 b)
- {
- return (spu_or(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_or(vec_uint4 a, vec_uint4 b)
- {
- return (spu_or(a, b));
- }
- static inline vec_int4 vec_or(vec_int4 a, vec_int4 b)
- {
- return (spu_or(a, b));
- }
- static inline vec_int4 vec_or(vec_bint4 a, vec_int4 b)
- {
- return (spu_or((vec_int4)(a), b));
- }
- static inline vec_int4 vec_or(vec_int4 a, vec_bint4 b)
- {
- return (spu_or(a, (vec_int4)(b)));
- }
- static inline vec_float4 vec_or(vec_float4 a, vec_float4 b)
- {
- return (spu_or(a, b));
- }
- static inline vec_float4 vec_or(vec_bint4 a, vec_float4 b)
- {
- return (spu_or((vec_float4)(a),b));
- }
- static inline vec_float4 vec_or(vec_float4 a, vec_bint4 b)
- {
- return (spu_or(a, (vec_float4)(b)));
- }
- /* vec_pack (vector pack)
- * ========
- */
- static inline vec_uchar16 vec_pack(vec_ushort8 a, vec_ushort8 b)
- {
- return ((vec_uchar16)spu_shuffle(a, b, ((vec_uchar16){ 1, 3, 5, 7, 9, 11, 13, 15,
- 17, 19, 21, 23, 25, 27, 29, 31})));
- }
- static inline vec_char16 vec_pack(vec_short8 a, vec_short8 b)
- {
- return ((vec_char16)spu_shuffle(a, b, ((vec_uchar16){ 1, 3, 5, 7, 9, 11, 13, 15,
- 17, 19, 21, 23, 25, 27, 29, 31})));
- }
- static inline vec_ushort8 vec_pack(vec_uint4 a, vec_uint4 b)
- {
- return ((vec_ushort8)spu_shuffle(a, b, ((vec_uchar16){ 2, 3, 6, 7, 10, 11, 14, 15,
- 18, 19, 22, 23, 26, 27, 30, 31})));
- }
- static inline vec_short8 vec_pack(vec_int4 a, vec_int4 b)
- {
- return ((vec_short8)spu_shuffle(a, b, ((vec_uchar16){ 2, 3, 6, 7, 10, 11, 14, 15,
- 18, 19, 22, 23, 26, 27, 30, 31})));
- }
- /* vec_packpx (vector pack pixel)
- * ==========
- */
- static inline vec_pixel8 vec_packpx(vec_uint4 a, vec_uint4 b)
- {
- vec_uint4 x03FF = (vec_uint4)(spu_splats((unsigned short)0x03FF));
- vec_uint4 x001F = (vec_uint4)(spu_splats((unsigned short)0x001F));
- return ((vec_pixel8)(spu_shuffle(spu_sel(spu_sel(spu_sl(a, 7), spu_sl(a, 10), x03FF),
- spu_sl(a, 13), x001F),
- spu_sel(spu_sel(spu_sl(b, 7), spu_sl(b, 10), x03FF),
- spu_sl(b, 13), x001F),
- ((vec_uchar16){ 0, 1, 4, 5, 8, 9, 12, 13,
- 16, 17, 20, 21, 24, 25, 28, 29}))));
- }
- /* vec_packs (vector pack saturate)
- * =========
- */
- static inline vec_uchar16 vec_packs(vec_ushort8 a, vec_ushort8 b)
- {
- vec_ushort8 max = spu_splats((unsigned short)0x00FF);
-
- return ((vec_uchar16)(spu_shuffle(spu_sel(a, max, spu_cmpgt(a, 255)),
- spu_sel(b, max, spu_cmpgt(b, 255)),
- ((vec_uchar16){ 1, 3, 5, 7, 9, 11, 13, 15,
- 17, 19, 21, 23, 25, 27, 29, 31}))));
- }
- static inline vec_char16 vec_packs(vec_short8 a, vec_short8 b)
- {
- vec_short8 max = spu_splats((signed short)0x007F);
- vec_short8 min = spu_splats((signed short)0xFF80);
-
- return ((vec_char16)(spu_shuffle(spu_sel(min, spu_sel(a, max, spu_cmpgt(a, 127)), spu_cmpgt(a, -128)),
- spu_sel(min, spu_sel(b, max, spu_cmpgt(b, 127)), spu_cmpgt(b, -128)),
- ((vec_uchar16){ 1, 3, 5, 7, 9, 11, 13, 15,
- 17, 19, 21, 23, 25, 27, 29, 31}))));
- }
- static inline vec_ushort8 vec_packs(vec_uint4 a, vec_uint4 b)
- {
- vec_uint4 max = spu_splats((unsigned int)0x0000FFFF);
-
- return ((vec_ushort8)(spu_shuffle(spu_sel(a, max, spu_cmpgt(a, max)),
- spu_sel(b, max, spu_cmpgt(b, max)),
- ((vec_uchar16){ 2, 3, 6, 7, 10, 11, 14, 15,
- 18, 19, 22, 23, 26, 27, 30, 31}))));
- }
- static inline vec_short8 vec_packs(vec_int4 a, vec_int4 b)
- {
- vec_int4 max = spu_splats((signed int)0x00007FFF);
- vec_int4 min = spu_splats((signed int)0xFFFF8000);
-
- return ((vec_short8)(spu_shuffle(spu_sel(min, spu_sel(a, max, spu_cmpgt(a, max)), spu_cmpgt(a, min)),
- spu_sel(min, spu_sel(b, max, spu_cmpgt(b, max)), spu_cmpgt(b, min)),
- ((vec_uchar16){ 2, 3, 6, 7, 10, 11, 14, 15,
- 18, 19, 22, 23, 26, 27, 30, 31}))));
- }
- /* vec_packsu (vector pack saturate unsigned)
- * ==========
- */
- static inline vec_uchar16 vec_packsu(vec_ushort8 a, vec_ushort8 b)
- {
- return ((vec_uchar16)spu_shuffle(spu_or(a, (vec_ushort8)(spu_cmpgt(a, 255))),
- spu_or(b, (vec_ushort8)(spu_cmpgt(b, 255))),
- ((vec_uchar16){ 1, 3, 5, 7, 9, 11, 13, 15,
- 17, 19, 21, 23, 25, 27, 29, 31})));
- }
- static inline vec_uchar16 vec_packsu(vec_short8 a, vec_short8 b)
- {
- vec_short8 max = spu_splats((signed short)0x00FF);
- vec_short8 min = spu_splats((signed short)0x0000);
-
- return ((vec_uchar16)(spu_shuffle(spu_sel(min, spu_sel(a, max, spu_cmpgt(a, 255)), spu_cmpgt(a, 0)),
- spu_sel(min, spu_sel(b, max, spu_cmpgt(b, 255)), spu_cmpgt(b, 0)),
- ((vec_uchar16){ 1, 3, 5, 7, 9, 11, 13, 15,
- 17, 19, 21, 23, 25, 27, 29, 31}))));
- return (vec_packsu((vec_ushort8)(a), (vec_ushort8)(b)));
- }
- static inline vec_ushort8 vec_packsu(vec_uint4 a, vec_uint4 b)
- {
- vec_uint4 max = spu_splats((unsigned int)0xFFFF);
- return ((vec_ushort8)spu_shuffle(spu_or(a, (vec_uint4)(spu_cmpgt(a, max))),
- spu_or(b, (vec_uint4)(spu_cmpgt(b, max))),
- ((vec_uchar16){ 2, 3, 6, 7, 10, 11, 14, 15,
- 18, 19, 22, 23, 26, 27, 30, 31})));
- }
- static inline vec_ushort8 vec_packsu(vec_int4 a, vec_int4 b)
- {
- vec_int4 max = spu_splats((signed int)0x0000FFFF);
- vec_int4 min = spu_splats((signed int)0x00000000);
-
- return ((vec_ushort8)(spu_shuffle(spu_sel(min, spu_sel(a, max, spu_cmpgt(a, max)), spu_cmpgt(a, min)),
- spu_sel(min, spu_sel(b, max, spu_cmpgt(b, max)), spu_cmpgt(b, min)),
- ((vec_uchar16){ 2, 3, 6, 7, 10, 11, 14, 15,
- 18, 19, 22, 23, 26, 27, 30, 31}))));
- }
- /* vec_perm (vector permute)
- * ========
- */
- static inline vec_uchar16 vec_perm(vec_uchar16 a, vec_uchar16 b, vec_uchar16 c)
- {
- return (spu_shuffle(a, b, spu_and(c, 0x1F)));
- }
- static inline vec_char16 vec_perm(vec_char16 a, vec_char16 b, vec_uchar16 c)
- {
- return ((vec_char16)(vec_perm((vec_uchar16)(a), (vec_uchar16)(b), c)));
- }
- static inline vec_ushort8 vec_perm(vec_ushort8 a, vec_ushort8 b, vec_uchar16 c)
- {
- return ((vec_ushort8)(vec_perm((vec_uchar16)(a), (vec_uchar16)(b), c)));
- }
- static inline vec_short8 vec_perm(vec_short8 a, vec_short8 b, vec_uchar16 c)
- {
- return ((vec_short8)(vec_perm((vec_uchar16)(a), (vec_uchar16)(b), c)));
- }
- static inline vec_uint4 vec_perm(vec_uint4 a, vec_uint4 b, vec_uchar16 c)
- {
- return ((vec_uint4)(vec_perm((vec_uchar16)(a), (vec_uchar16)(b), c)));
- }
- static inline vec_int4 vec_perm(vec_int4 a, vec_int4 b, vec_uchar16 c)
- {
- return ((vec_int4)(vec_perm((vec_uchar16)(a), (vec_uchar16)(b), c)));
- }
- static inline vec_float4 vec_perm(vec_float4 a, vec_float4 b, vec_uchar16 c)
- {
- return ((vec_float4)(vec_perm((vec_uchar16)(a), (vec_uchar16)(b), c)));
- }
- /* vec_re (vector reciprocal estimate)
- * ======
- */
- #define vec_re(_a) spu_re(_a)
- /* vec_rl (vector rotate left)
- * ======
- */
- static inline vec_uchar16 vec_rl(vec_uchar16 a, vec_uchar16 b)
- {
- vec_ushort8 r1, r2;
- r1 = spu_rl(spu_and((vec_ushort8)(a), 0xFF), (vec_short8)spu_and((vec_ushort8)(b), 7));
- r2 = spu_rl(spu_and((vec_ushort8)(a), -256), (vec_short8)spu_and(spu_rlmask((vec_ushort8)(b), -8), 7));
- return ((vec_uchar16)(spu_sel(spu_or(r2, spu_sl(r2, 8)), spu_or(r1, spu_rlmask(r1, -8)), spu_splats((unsigned short)0xFF))));
- }
- static inline vec_char16 vec_rl(vec_char16 a, vec_uchar16 b)
- {
- return ((vec_char16)(vec_rl((vec_uchar16)(a), b)));
- }
- static inline vec_ushort8 vec_rl(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_rl(a, (vec_short8)(b)));
- }
- static inline vec_short8 vec_rl(vec_short8 a, vec_ushort8 b)
- {
- return (spu_rl(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_rl(vec_uint4 a, vec_uint4 b)
- {
- return (spu_rl(a, (vec_int4)(b)));
- }
- static inline vec_int4 vec_rl(vec_int4 a, vec_uint4 b)
- {
- return (spu_rl(a, (vec_int4)(b)));
- }
- /* vec_round (vector round)
- * =========
- */
- static inline vec_float4 vec_round(vec_float4 a)
- {
- vec_float4 s_half, s_one, d;
- vec_uint4 odd;
- vec_uint4 msb = spu_splats((unsigned int)0x80000000);
- vec_float4 half = spu_splats(0.5f);
- vec_int4 exp;
- vec_uint4 mask;
- s_half = (vec_float4)(spu_sel((vec_uint4)(half), (vec_uint4)(a), msb));
- a = spu_add(a, s_half);
- s_one = spu_add(s_half, s_half);
- exp = spu_sub(127, (vec_int4)(spu_and(spu_rlmask((vec_uint4)(a), -23), 0xFF)));
- mask = spu_rlmask(spu_splats((unsigned int)0x7FFFFF), exp);
- mask = spu_sel(spu_splats((unsigned int)0), mask, spu_cmpgt(exp, -31));
- mask = spu_or(mask, spu_xor((vec_uint4)(spu_rlmaska(spu_add(exp, -1), -31)), -1));
- odd = spu_and((vec_uint4)(spu_convts(a, 0)), 1);
- s_one = spu_andc(s_one, (vec_float4)spu_cmpeq(mask, 0));
- s_one = spu_and(s_one, spu_and((vec_float4)spu_cmpeq(spu_and((vec_uint4)(a), mask), 0),
- (vec_float4)spu_cmpeq(odd, 1)));
- d = spu_andc(a, (vec_float4)(mask));
- d = spu_sub(d, s_one);
- return (d);
- }
- /* vec_rsqrte (vector reciprocal square root estimate)
- * ==========
- */
- #define vec_rsqrte(_a) spu_rsqrte(_a)
- /* vec_sel (vector select)
- * =======
- */
- #define vec_sel(_a, _b, _c) spu_sel(_a, _b, _c)
- /* vec_sl (vector shift left)
- * ======
- */
- static inline vec_uchar16 vec_sl(vec_uchar16 a, vec_uchar16 b)
- {
- vec_ushort8 hi, lo;
- lo = spu_and(spu_sl((vec_ushort8)(a), spu_and((vec_ushort8)(b), 7)), 0xFF);
- hi = spu_sl(spu_and((vec_ushort8)(a), -256), spu_and(spu_rlmask((vec_ushort8)(b), -8), 7));
- return ((vec_uchar16)(spu_or(hi, lo)));
- }
- static inline vec_char16 vec_sl(vec_char16 a, vec_uchar16 b)
- {
- return ((vec_char16)(vec_sl((vec_uchar16)(a), b)));
- }
- static inline vec_ushort8 vec_sl(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_sl(a, spu_and(b, 15)));
- }
- static inline vec_short8 vec_sl(vec_short8 a, vec_ushort8 b)
- {
- return (spu_sl(a, spu_and((vec_ushort8)(b), 15)));
- }
- static inline vec_uint4 vec_sl(vec_uint4 a, vec_uint4 b)
- {
- return (spu_sl(a, spu_and(b, 31)));
- }
- static inline vec_int4 vec_sl(vec_int4 a, vec_uint4 b)
- {
- return (spu_sl(a, spu_and(b, 31)));
- }
- /* vec_sld (vector shift left double)
- * =======
- */
- #define vec_sld(_a, _b, _c) spu_shuffle(_a, _b, ((vec_uchar16){ 0+(_c), 1+(_c), 2+(_c), 3+(_c), \
- 4+(_c), 5+(_c), 6+(_c), 7+(_c), \
- 8+(_c), 9+(_c), 10+(_c), 11+(_c), \
- 12+(_c), 13+(_c), 14+(_c), 15+(_c)}))
- /* vec_sll (vector shift left long)
- * =======
- */
- #define vec_sll(_a, _b) spu_slqw(_a, spu_extract((vec_uint4)(_b), 0))
- /* vec_slo (vector shift left by octet)
- * =======
- */
- #define vec_slo(_a, _b) spu_slqwbytebc(_a, spu_extract((vec_uint4)(_b), 3) & 0x7F)
- /* vec_splat (vector splat)
- * =========
- */
- #define vec_splat(_a, _b) spu_splats(spu_extract(_a, _b))
- /* vec_splat_s8 (vector splat signed byte)
- * ============
- */
- #define vec_splat_s8(_a) spu_splats((signed char)(_a))
- /* vec_splat_s16 (vector splat signed half-word)
- * =============
- */
- #define vec_splat_s16(_a) spu_splats((signed short)(_a))
- /* vec_splat_s32 (vector splat signed word)
- * =============
- */
- #define vec_splat_s32(_a) spu_splats((signed int)(_a))
- /* vec_splat_u8 (vector splat unsigned byte)
- * ============
- */
- #define vec_splat_u8(_a) spu_splats((unsigned char)(_a))
- /* vec_splat_u16 (vector splat unsigned half-word)
- * =============
- */
- #define vec_splat_u16(_a) spu_splats((unsigned short)(_a))
- /* vec_splat_u32 (vector splat unsigned word)
- * =============
- */
- #define vec_splat_u32(_a) spu_splats((unsigned int)(_a))
- /* vec_sr (vector shift right)
- * ======
- */
- static inline vec_uchar16 vec_sr(vec_uchar16 a, vec_uchar16 b)
- {
- vec_ushort8 hi, lo;
- lo = spu_rlmask(spu_and((vec_ushort8)(a), 0xFF), spu_sub(0, (vec_short8)(spu_and((vec_ushort8)(b), 7))));
- hi = spu_and(spu_rlmask((vec_ushort8)(a), spu_sub(0, (vec_short8)(spu_and(spu_rlmask((vec_ushort8)(b), -8), 7)))), -256);
- return ((vec_uchar16)(spu_or(hi, lo)));
- }
- static inline vec_char16 vec_sr(vec_char16 a, vec_uchar16 b)
- {
- return ((vec_char16)(vec_sr((vec_uchar16)(a), b)));
- }
- static inline vec_ushort8 vec_sr(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_rlmask(a, spu_sub(0, (vec_short8)(spu_and(b, 15)))));
- }
- static inline vec_short8 vec_sr(vec_short8 a, vec_ushort8 b)
- {
- return ((vec_short8)(vec_sr((vec_ushort8)(a), b)));
- }
- static inline vec_uint4 vec_sr(vec_uint4 a, vec_uint4 b)
- {
- return (spu_rlmask(a, spu_sub(0, (vec_int4)(spu_and(b, 31)))));
- }
- static inline vec_int4 vec_sr(vec_int4 a, vec_uint4 b)
- {
- return ((vec_int4)(vec_sr((vec_uint4)(a), b)));
- }
- /* vec_sra (vector shift right algebraic)
- * =======
- */
- static inline vec_char16 vec_sra(vec_char16 a, vec_uchar16 b)
- {
- vec_short8 hi, lo;
- lo = spu_and(spu_rlmaska(spu_extend(a), spu_sub(0, (vec_short8)(spu_and((vec_ushort8)(b), 7)))), 0xFF);
- hi = spu_and(spu_rlmaska((vec_short8)(a), spu_sub(0, (vec_short8)(spu_and(spu_rlmask((vec_ushort8)(b), -8), 7)))), -256);
- return ((vec_char16)(spu_or(hi, lo)));
- }
- static inline vec_uchar16 vec_sra(vec_uchar16 a, vec_uchar16 b)
- {
- return ((vec_uchar16)(vec_sra((vec_char16)(a), b)));
- }
- static inline vec_short8 vec_sra(vec_short8 a, vec_ushort8 b)
- {
- return (spu_rlmaska(a, spu_sub(0, (vec_short8)(spu_and(b, 15)))));
- }
- static inline vec_ushort8 vec_sra(vec_ushort8 a, vec_ushort8 b)
- {
- return ((vec_ushort8)(vec_sra((vec_short8)(a), b)));
- }
- static inline vec_int4 vec_sra(vec_int4 a, vec_uint4 b)
- {
- return (spu_rlmaska(a, spu_sub(0, (vec_int4)(spu_and(b, 31)))));
- }
- static inline vec_uint4 vec_sra(vec_uint4 a, vec_uint4 b)
- {
- return ((vec_uint4)(vec_sra((vec_int4)(a), b)));
- }
- /* vec_srl (vector shift right long)
- * =======
- */
- #define vec_srl(_a, _b) spu_rlmaskqw(_a, 0-spu_extract((vec_int4)(_b), 3))
- /* vec_sro (vector shift right by octet)
- * =======
- */
- #define vec_sro(_a, _b) spu_rlmaskqwbyte(_a, 0 - ((spu_extract((vec_int4)(_b), 3) >> 3) & 0xF))
- /* vec_st (vector store indexed)
- * ======
- */
- static inline void vec_st(vec_uchar16 a, int b, unsigned char *c)
- {
- *((vec_uchar16 *)(c+b)) = a;
- }
- static inline void vec_st(vec_uchar16 a, int b, vec_uchar16 *c)
- {
- *((vec_uchar16 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_char16 a, int b, signed char *c)
- {
- *((vec_char16 *)(c+b)) = a;
- }
- static inline void vec_st(vec_char16 a, int b, vec_char16 *c)
- {
- *((vec_char16 *)((signed char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_bchar16 a, int b, signed char *c)
- {
- *((vec_bchar16 *)((signed char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_ushort8 a, int b, unsigned short *c)
- {
- *((vec_ushort8 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_ushort8 a, int b, vec_ushort8 *c)
- {
- *((vec_ushort8 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_short8 a, int b, signed short *c)
- {
- *((vec_short8 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_short8 a, int b, vec_short8 *c)
- {
- *((vec_short8 *)((signed char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_bshort8 a, int b, signed short *c)
- {
- *((vec_bshort8 *)((signed char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_uint4 a, int b, unsigned int *c)
- {
- *((vec_uint4 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_uint4 a, int b, vec_uint4 *c)
- {
- *((vec_uint4 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_int4 a, int b, signed int *c)
- {
- *((vec_int4 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_int4 a, int b, vec_int4 *c)
- {
- *((vec_int4 *)((signed char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_bint4 a, int b, signed int *c)
- {
- *((vec_bint4 *)((signed char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_float4 a, int b, float *c)
- {
- *((vec_float4 *)((unsigned char *)(c)+b)) = a;
- }
- static inline void vec_st(vec_float4 a, int b, vec_float4 *c)
- {
- *((vec_float4 *)((unsigned char *)(c)+b)) = a;
- }
- /* vec_ste (vector store element indexed)
- * =======
- */
- static inline void vec_ste(vec_uchar16 a, int b, unsigned char *c)
- {
- unsigned char *ptr;
- ptr = c + b;
- *ptr = spu_extract(a, (int)(ptr) & 15);
- }
- static inline void vec_ste(vec_char16 a, int b, signed char *c)
- {
- vec_ste((vec_uchar16)(a), b, (unsigned char *)(c));
- }
- static inline void vec_ste(vec_bchar16 a, int b, signed char *c)
- {
- vec_ste((vec_uchar16)(a), b, (unsigned char *)(c));
- }
- static inline void vec_ste(vec_ushort8 a, int b, unsigned short *c)
- {
- unsigned short *ptr;
- ptr = (unsigned short *)(((unsigned int)(c) + b) & ~1);
- *ptr = spu_extract(a, ((int)(ptr) >> 1) & 7);
- }
- static inline void vec_ste(vec_short8 a, int b, signed short *c)
- {
- vec_ste((vec_ushort8)(a), b, (unsigned short *)(c));
- }
- static inline void vec_ste(vec_bshort8 a, int b, signed short *c)
- {
- vec_ste((vec_ushort8)(a), b, (unsigned short *)(c));
- }
- static inline void vec_ste(vec_uint4 a, int b, unsigned int *c)
- {
- unsigned int *ptr;
- ptr = (unsigned int *)(((unsigned int)(c) + b) & ~3);
- *ptr = spu_extract(a, ((int)(ptr) >> 2) & 3);
- }
- static inline void vec_ste(vec_int4 a, int b, signed int *c)
- {
- vec_ste((vec_uint4)(a), b, (unsigned int *)(c));
- }
- static inline void vec_ste(vec_bint4 a, int b, signed int *c)
- {
- vec_ste((vec_uint4)(a), b, (unsigned int *)(c));
- }
- static inline void vec_ste(vec_float4 a, int b, float *c)
- {
- vec_ste((vec_uint4)(a), b, (unsigned int *)(c));
- }
- /* vec_stl (vector store indexed LRU)
- * =======
- */
- #define vec_stl(_a, _b, _c) vec_st(_a, _b, _c)
- /* vec_sub (vector subtract)
- * =======
- */
- static inline vec_uchar16 vec_sub(vec_uchar16 a, vec_uchar16 b)
- {
- return ((vec_uchar16)(spu_sel(spu_sub((vec_ushort8)(a), (vec_ushort8)(b)),
- spu_sub(spu_and((vec_ushort8)(a), -256), spu_and((vec_ushort8)(b), -256)),
- spu_splats((unsigned short)0xFF00))));
- }
- static inline vec_char16 vec_sub(vec_char16 a, vec_char16 b)
- {
- return ((vec_char16)(vec_sub((vec_uchar16)(a), (vec_uchar16)(b))));
- }
- static inline vec_char16 vec_sub(vec_bchar16 a, vec_char16 b)
- {
- return ((vec_char16)(vec_sub((vec_uchar16)(a), (vec_uchar16)(b))));
- }
- static inline vec_char16 vec_sub(vec_char16 a, vec_bchar16 b)
- {
- return ((vec_char16)(vec_sub((vec_uchar16)(a), (vec_uchar16)(b))));
- }
- static inline vec_ushort8 vec_sub(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_sub(a, b));
- }
- static inline vec_short8 vec_sub(vec_short8 a, vec_short8 b)
- {
- return (spu_sub(a, b));
- }
- static inline vec_short8 vec_sub(vec_bshort8 a, vec_short8 b)
- {
- return (spu_sub((vec_short8)(a), b));
- }
- static inline vec_short8 vec_sub(vec_short8 a, vec_bshort8 b)
- {
- return (spu_sub(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_sub(vec_uint4 a, vec_uint4 b)
- {
- return (spu_sub(a, b));
- }
- static inline vec_int4 vec_sub(vec_int4 a, vec_int4 b)
- {
- return (spu_sub(a, b));
- }
- static inline vec_int4 vec_sub(vec_bint4 a, vec_int4 b)
- {
- return (spu_sub((vec_int4)(a), b));
- }
- static inline vec_int4 vec_sub(vec_int4 a, vec_bint4 b)
- {
- return (spu_sub(a, (vec_int4)(b)));
- }
- static inline vec_float4 vec_sub(vec_float4 a, vec_float4 b)
- {
- return (spu_sub(a, b));
- }
- /* vec_subc (vector subtract carryout)
- * ========
- */
- #define vec_subc(_a, _b) spu_genb(_a, _b)
- /* vec_subs (vector subtract saturate)
- * ========
- */
- static inline vec_uchar16 vec_subs(vec_uchar16 a, vec_uchar16 b)
- {
- vec_ushort8 s1, s2;
- vec_uchar16 s, d;
- s1 = spu_sub(spu_rlmask((vec_ushort8)(a), -8), spu_rlmask((vec_ushort8)(b), -8));
- s2 = spu_sub(spu_and((vec_ushort8)(a), 0xFF), spu_and((vec_ushort8)(b), 0xFF));
- s = (vec_uchar16)(spu_shuffle(s1, s2, ((vec_uchar16){0, 16, 2, 18, 4, 20, 6, 22,
- 8, 24, 10, 26, 12, 28, 14, 30})));
- d = (vec_uchar16)(spu_shuffle(s1, s2, ((vec_uchar16){1, 17, 3, 19, 5, 21, 7, 23,
- 9, 25, 11, 27, 13, 29, 15, 31})));
- return (spu_andc(d, s));
- }
- static inline vec_char16 vec_subs(vec_char16 a, vec_char16 b)
- {
- vec_ushort8 s1, s2;
- vec_uchar16 s, d;
- s1 = spu_sub(spu_rlmask((vec_ushort8)(a), -8), spu_rlmask((vec_ushort8)(b), -8));
- s2 = spu_sub(spu_and((vec_ushort8)(a), 0xFF), spu_and((vec_ushort8)(b), 0xFF));
- s = (vec_uchar16)(spu_shuffle(s1, s2, ((vec_uchar16){1, 17, 3, 19, 5, 21, 7, 23,
- 9, 25, 11, 27, 13, 29, 15, 31})));
- d = spu_sel(s, spu_splats((unsigned char)0x7F), spu_cmpgt(spu_nor((vec_uchar16)(a), spu_nand(s, (vec_uchar16)(b))), 0x7F));
- d = spu_sel(d, spu_splats((unsigned char)0x80), spu_cmpgt(spu_and((vec_uchar16)(a), spu_nor(s, (vec_uchar16)(b))), 0x7F));
-
- return ((vec_char16)(d));
- }
- static inline vec_char16 vec_subs(vec_bchar16 a, vec_char16 b)
- {
- return (vec_subs((vec_char16)(a), b));
- }
- static inline vec_char16 vec_subs(vec_char16 a, vec_bchar16 b)
- {
- return (vec_subs(a, (vec_char16)(b)));
- }
- static inline vec_ushort8 vec_subs(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_andc(spu_sub(a, b), spu_cmpgt(b, a)));
- }
- static inline vec_short8 vec_subs(vec_short8 a, vec_short8 b)
- {
- vec_short8 s;
- vec_short8 d;
-
- s = spu_sub(a, b);
- d = spu_sel(s, spu_splats((signed short)0x7FFF), (vec_ushort8)(spu_rlmaska(spu_nor(a, spu_nand(s, b)), -15)));
- d = spu_sel(d, spu_splats((signed short)0x8000), (vec_ushort8)(spu_rlmaska(spu_and(a, spu_nor(s, b)), -15)));
- return (d);
- }
- static inline vec_short8 vec_subs(vec_bshort8 a, vec_short8 b)
- {
- return ((vec_short8)(vec_subs((vec_short8)(a), b)));
- }
- static inline vec_short8 vec_subs(vec_short8 a, vec_bshort8 b)
- {
- return ((vec_short8)(vec_subs(a, (vec_short8)(b))));
- }
- static inline vec_uint4 vec_subs(vec_uint4 a, vec_uint4 b)
- {
- return (spu_andc(spu_sub(a, b), spu_cmpgt(b, a)));
- }
- static inline vec_int4 vec_subs(vec_int4 a, vec_int4 b)
- {
- vec_int4 s;
- vec_int4 d;
-
- s = spu_sub(a, b);
- d = spu_sel(s, spu_splats((signed int)0x7FFFFFFF), (vec_uint4)(spu_rlmaska(spu_nor(a, spu_nand(s, b)), -31)));
- d = spu_sel(d, spu_splats((signed int)0x80000000), (vec_uint4)(spu_rlmaska(spu_and(a, spu_nor(s, b)), -31)));
- return (d);
- }
- static inline vec_int4 vec_subs(vec_bint4 a, vec_int4 b)
- {
- return ((vec_int4)(vec_subs((vec_int4)(a), b)));
- }
- static inline vec_int4 vec_subs(vec_int4 a, vec_bint4 b)
- {
- return ((vec_int4)(vec_subs(a, (vec_int4)(b))));
- }
- /* vec_sum4s (vector sum across partial (1/4) saturated)
- * =========
- */
- static inline vec_uint4 vec_sum4s(vec_uchar16 a, vec_uint4 b)
- {
- vec_uint4 a01_23, a0123;
- a01_23 = (vec_uint4)(spu_add(spu_rlmask((vec_ushort8)(a), -8),
- spu_and((vec_ushort8)(a), 0xFF)));
- a0123 = spu_add(spu_rlmask(a01_23, -16), spu_and(a01_23, 0x1FF));
- return (vec_adds(a0123, b));
- }
- static inline vec_int4 vec_sum4s(vec_char16 a, vec_int4 b)
- {
- vec_int4 a01_23, a0123;
- a01_23 = (vec_int4)(spu_add(spu_rlmaska((vec_short8)(a), -8),
- spu_extend(a)));
- a0123 = spu_add(spu_rlmaska(a01_23, -16), spu_extend((vec_short8)(a01_23)));
- return (vec_adds(a0123, b));
- }
- static inline vec_int4 vec_sum4s(vec_short8 a, vec_int4 b)
- {
- vec_int4 a0123;
- a0123 = spu_add(spu_rlmaska((vec_int4)(a), -16), spu_extend(a));
- return (vec_adds(a0123, b));
- }
- /* vec_sum2s (vector sum across partial (1/2) saturated)
- * =========
- */
- static inline vec_int4 vec_sum2s(vec_int4 a, vec_int4 b)
- {
- vec_int4 c, d;
- vec_int4 sign1, sign2, sign3;
- vec_int4 carry, sum_l, sum_h, sat, sat_val;
- sign1 = spu_rlmaska(a, -31);
- sign2 = spu_rlmaska(b, -31);
- c = spu_rlqwbyte(a, -4);
- sign3 = spu_rlqwbyte(sign1, -4);
-
- carry = spu_genc(a, b);
- sum_l = spu_add(a, b);
- sum_h = spu_addx(sign1, sign2, carry);
- carry = spu_genc(sum_l, c);
- sum_l = spu_add(sum_l, c);
- sum_h = spu_addx(sum_h, sign3, carry);
-
- sign1 = spu_rlmaska(sum_l, -31);
- sign2 = spu_rlmaska(sum_h, -31);
- sat_val = spu_xor(sign2, spu_splats((signed int)0x7FFFFFFF));
- sat = spu_orc(spu_xor(sign1, sign2), (vec_int4)spu_cmpeq(sum_h, sign2));
- d = spu_and(spu_sel(sum_l, sat_val, (vec_uint4)(sat)), (vec_int4){0, -1, 0, -1});
- return (d);
- }
- /* vec_sums (vector sum saturated)
- * ========
- */
- static inline vec_int4 vec_sums(vec_int4 a, vec_int4 b)
- {
- vec_int4 a0, a1, a2, c0, c1, c2, d;
- vec_int4 sign_a, sign_b, sign_l, sign_h;
- vec_int4 sum_l, sum_h, sat, sat_val;
- sign_a = spu_rlmaska(a, -31);
- sign_b = spu_rlmaska(b, -31);
- a0 = spu_rlqwbyte(a, -12);
- a1 = spu_rlqwbyte(a, -8);
- a2 = spu_rlqwbyte(a, -4);
- sum_l = spu_add(a, b);
- sum_h = spu_addx(sign_a, sign_b, spu_genc(a, b));
-
- c2 = spu_genc(sum_l, a2);
- sum_l = spu_add(sum_l, a2);
- sum_h = spu_addx(sum_h, spu_rlqwbyte(sign_a, -4), c2);
- c1 = spu_genc(sum_l, a1);
- sum_l = spu_add(sum_l, a1);
- sum_h = spu_addx(sum_h, spu_rlqwbyte(sign_a, -8), c1);
- c0 = spu_genc(sum_l, a0);
- sum_l = spu_add(sum_l, a0);
- sum_h = spu_addx(sum_h, spu_rlqwbyte(sign_a, -12), c0);
- sign_l = spu_rlmaska(sum_l, -31);
- sign_h = spu_rlmaska(sum_h, -31);
- sat_val = spu_xor(sign_h, spu_splats((signed int)0x7FFFFFFF));
- sat = spu_orc(spu_xor(sign_l, sign_h), (vec_int4)spu_cmpeq(sum_h, sign_h));
- d = spu_and(spu_sel(sum_l, sat_val, (vec_uint4)(sat)), ((vec_int4){0, 0, 0, -1}));
- return (d);
- }
- /* vec_trunc (vector truncate)
- * =========
- */
- static inline vec_float4 vec_trunc(vec_float4 a)
- {
- vec_int4 exp;
- vec_uint4 mask;
- exp = spu_sub(127, (vec_int4)(spu_and(spu_rlmask((vec_uint4)(a), -23), 0xFF)));
- mask = spu_rlmask(spu_splats((unsigned int)0x7FFFFF), exp);
- mask = spu_sel(spu_splats((unsigned int)0), mask, spu_cmpgt(exp, -31));
- mask = spu_or(mask, spu_xor((vec_uint4)(spu_rlmaska(spu_add(exp, -1), -31)), -1));
- return (spu_andc(a, (vec_float4)(mask)));
- }
- /* vec_unpackh (vector unpack high element)
- * ===========
- */
- static inline vec_short8 vec_unpackh(vec_char16 a)
- {
- return (spu_extend(spu_shuffle(a, a, ((vec_uchar16){0, 0, 1, 1, 2, 2, 3, 3,
- 4, 4, 5, 5, 6, 6, 7, 7}))));
- }
- static inline vec_bshort8 vec_unpackh(vec_bchar16 a)
- {
- return ((vec_bshort8)(vec_unpackh((vec_char16)(a))));
- }
- static inline vec_int4 vec_unpackh(vec_short8 a)
- {
- return (spu_extend(spu_shuffle(a, a, ((vec_uchar16){0, 0, 0, 1, 0, 0, 2, 3,
- 0, 0, 4, 5, 0, 0, 6, 7}))));
- }
- #ifdef SUPPORT_UNPACK_PIXEL
- /* Due to type conflicts, unpacking of pixel types and boolean shorts
- * can not simultaneously be supported. By default, the boolean short is
- * supported.
- */
- static inline vec_uint4 vec_unpackh(vec_pixel8 a)
- {
- vec_ushort8 p1, p2;
- p1 = spu_shuffle((vec_ushort8)(spu_rlmaska((vec_short8)(a.p), -7)),
- spu_and((vec_ushort8)(a.p), 0x1F),
- ((vec_uchar16){ 0, 128, 128, 17, 2, 128, 128, 19,
- 4, 128, 128, 21, 6, 128, 128, 23}));
- p2 = spu_shuffle(spu_and(spu_rlmask((vec_ushort8)(a.p), -5), 0x1F),
- spu_and(spu_rlmask((vec_ushort8)(a.p), -10), 0x1F),
- ((vec_uchar16){ 128, 17, 1, 128, 128, 19, 3, 128,
- 128, 21, 5, 128, 128, 23, 7, 128}));
- return ((vec_uint4)(spu_or(p1, p2)));
- }
- #else
- static inline vec_bint4 vec_unpackh(vec_bshort8 a)
- {
- return ((vec_bint4)(vec_unpackh((vec_short8)(a))));
- }
- #endif
- /* vec_unpackl (vector unpack low element)
- * ===========
- */
- static inline vec_short8 vec_unpackl(vec_char16 a)
- {
- return (spu_extend(spu_shuffle(a, a, ((vec_uchar16){8, 8, 9, 9, 10, 10, 11, 11,
- 12, 12, 13, 13, 14, 14, 15, 15}))));
- }
- static inline vec_bshort8 vec_unpackl(vec_bchar16 a)
- {
- return ((vec_bshort8)(vec_unpackl((vec_char16)(a))));
- }
- static inline vec_int4 vec_unpackl(vec_short8 a)
- {
- return (spu_extend(spu_shuffle(a, a, ((vec_uchar16){0, 0, 8, 9, 0, 0, 10, 11,
- 0, 0,12,13, 0, 0, 14, 15}))));
- }
- #ifdef SUPPORT_UNPACK_PIXEL
- /* Due to type conflicts, unpacking of pixel types and boolean shorts
- * can not simultaneously be supported. By default, the boolean short is
- * supported.
- */
- static inline vec_uint4 vec_unpackl(vec_pixel8 a)
- {
- vec_ushort8 p1, p2;
- p1 = spu_shuffle((vec_ushort8)(spu_rlmaska((vec_short8)(a), -7)),
- spu_and((vec_ushort8)(a), 0x1F),
- ((vec_uchar16){ 8, 128, 128, 25, 10, 128, 128, 27,
- 12, 128, 128, 29, 14, 128, 128, 31}));
- p2 = spu_shuffle(spu_and(spu_rlmask((vec_ushort8)(a), -5), 0x1F),
- spu_and(spu_rlmask((vec_ushort8)(a), -10), 0x1F),
- ((vec_uchar16){ 128, 25, 9, 128, 128, 27, 11, 128,
- 128, 29, 13, 128, 128, 31, 15, 128}));
- return ((vec_uint4)(spu_or(p1, p2)));
- }
- #else
- static inline vec_bint4 vec_unpackl(vec_bshort8 a)
- {
- return ((vec_bint4)(vec_unpackl((vec_short8)(a))));
- }
- #endif
- /* vec_xor (vector logical xor)
- * ======
- */
- static inline vec_uchar16 vec_xor(vec_uchar16 a, vec_uchar16 b)
- {
- return (spu_xor(a, b));
- }
- static inline vec_char16 vec_xor(vec_char16 a, vec_char16 b)
- {
- return (spu_xor(a, b));
- }
- static inline vec_char16 vec_xor(vec_bchar16 a, vec_char16 b)
- {
- return (spu_xor((vec_char16)(a), b));
- }
- static inline vec_char16 vec_xor(vec_char16 a, vec_bchar16 b)
- {
- return (spu_xor(a, (vec_char16)(b)));
- }
- static inline vec_ushort8 vec_xor(vec_ushort8 a, vec_ushort8 b)
- {
- return (spu_xor(a, b));
- }
- static inline vec_short8 vec_xor(vec_short8 a, vec_short8 b)
- {
- return (spu_xor(a, b));
- }
- static inline vec_short8 vec_xor(vec_bshort8 a, vec_short8 b)
- {
- return (spu_xor((vec_short8)(a), b));
- }
- static inline vec_short8 vec_xor(vec_short8 a, vec_bshort8 b)
- {
- return (spu_xor(a, (vec_short8)(b)));
- }
- static inline vec_uint4 vec_xor(vec_uint4 a, vec_uint4 b)
- {
- return (spu_xor(a, b));
- }
- static inline vec_int4 vec_xor(vec_int4 a, vec_int4 b)
- {
- return (spu_xor(a, b));
- }
- static inline vec_int4 vec_xor(vec_bint4 a, vec_int4 b)
- {
- return (spu_xor((vec_int4)(a), b));
- }
- static inline vec_int4 vec_xor(vec_int4 a, vec_bint4 b)
- {
- return (spu_xor(a, (vec_int4)(b)));
- }
- static inline vec_float4 vec_xor(vec_float4 a, vec_float4 b)
- {
- return (spu_xor(a, b));
- }
- static inline vec_float4 vec_xor(vec_bint4 a, vec_float4 b)
- {
- return (spu_xor((vec_float4)(a),b));
- }
- static inline vec_float4 vec_xor(vec_float4 a, vec_bint4 b)
- {
- return (spu_xor(a, (vec_float4)(b)));
- }
- /************************************************************************
- * PREDICATES
- ************************************************************************/
- /* vec_all_eq (all elements equal)
- * ==========
- */
- static inline int vec_all_eq(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xFFFF));
- }
- static inline int vec_all_eq(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xFFFF));
- }
- static inline int vec_all_eq(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_char16)(a), b)), 0) == 0xFFFF));
- }
- static inline int vec_all_eq(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_char16)(b))), 0) == 0xFFFF));
- }
- static inline int vec_all_eq(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xFF));
- }
- static inline int vec_all_eq(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xFF));
- }
- static inline int vec_all_eq(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_short8)(a), b)), 0) == 0xFF));
- }
- static inline int vec_all_eq(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_short8)(b))), 0) == 0xFF));
- }
- static inline int vec_all_eq(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xF));
- }
- static inline int vec_all_eq(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xF));
- }
- static inline int vec_all_eq(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_int4)(a), b)), 0) == 0xF));
- }
- static inline int vec_all_eq(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_int4)(b))), 0) == 0xF));
- }
- static inline int vec_all_eq(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xF));
- }
- /* vec_all_ge (all elements greater than or equal)
- * ==========
- */
- static inline int vec_all_ge(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_char16)(a))), 0) == 0));
- }
- static inline int vec_all_ge(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(b), a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_short8)(a))), 0) == 0));
- }
- static inline int vec_all_ge(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(b), a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_int4)(a))), 0) == 0));
- }
- static inline int vec_all_ge(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_int4)(b), a)), 0) == 0));
- }
- static inline int vec_all_ge(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- /* vec_all_gt (all elements greater than)
- * ==========
- */
- static inline int vec_all_gt(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xFFFF));
- }
- static inline int vec_all_gt(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xFFFF));
- }
- static inline int vec_all_gt(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(a), b)), 0) == 0xFFFF));
- }
- static inline int vec_all_gt(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_char16)(b))), 0) == 0xFFFF));
- }
- static inline int vec_all_gt(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xFF));
- }
- static inline int vec_all_gt(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xFF));
- }
- static inline int vec_all_gt(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(a), b)), 0) == 0xFF));
- }
- static inline int vec_all_gt(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_short8)(b))), 0) == 0xFF));
- }
- static inline int vec_all_gt(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xF));
- }
- static inline int vec_all_gt(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xF));
- }
- static inline int vec_all_gt(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_int4)(a), b)), 0) == 0xF));
- }
- static inline int vec_all_gt(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_int4)(b))), 0) == 0xF));
- }
- static inline int vec_all_gt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xF));
- }
- /* vec_all_in (all elements in bounds)
- * ==========
- */
- static inline int vec_all_in(vec_float4 a, vec_float4 b)
- {
- return (spu_extract(spu_gather(spu_nor(spu_cmpabsgt(a, b), (vec_uint4)(spu_rlmaska((vec_int4)(b), -31)))), 0) == 0xF);
- }
- /* vec_all_le (all elements less than or equal)
- * ==========
- */
- static inline int vec_all_le(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- static inline int vec_all_le(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- static inline int vec_all_le(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(a), b)), 0) == 0));
- }
- static inline int vec_all_le(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_char16)(b))), 0) == 0));
- }
- static inline int vec_all_le(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- static inline int vec_all_le(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- static inline int vec_all_le(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(a), b)), 0) == 0));
- }
- static inline int vec_all_le(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_short8)(b))), 0) == 0));
- }
- static inline int vec_all_le(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- static inline int vec_all_le(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- static inline int vec_all_le(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_int4)(a), b)), 0) == 0));
- }
- static inline int vec_all_le(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_int4)(b))), 0) == 0));
- }
- static inline int vec_all_le(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- /* vec_all_lt (all elements less than)
- * ==========
- */
- static inline int vec_all_lt(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xFFFF));
- }
- static inline int vec_all_lt(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xFFFF));
- }
- static inline int vec_all_lt(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_char16)(a))), 0) == 0xFFFF));
- }
- static inline int vec_all_lt(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(b), a)), 0) == 0xFFFF));
- }
- static inline int vec_all_lt(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xFF));
- }
- static inline int vec_all_lt(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xFF));
- }
- static inline int vec_all_lt(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_short8)(a))), 0) == 0xFF));
- }
- static inline int vec_all_lt(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(b), a)), 0) == 0xFF));
- }
- static inline int vec_all_lt(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xF));
- }
- static inline int vec_all_lt(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xF));
- }
- static inline int vec_all_lt(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_int4)(a))), 0) == 0xF));
- }
- static inline int vec_all_lt(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_int4)(b), a)), 0) == 0xF));
- }
- static inline int vec_all_lt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xF));
- }
- /* vec_all_nan (all elements not a number)
- * ===========
- */
- static inline int vec_all_nan(vec_float4 a)
- {
- vec_uint4 exp, man;
- vec_uint4 exp_mask = spu_splats((unsigned int)0x7F800000);
- exp = spu_and((vec_uint4)(a), exp_mask);
- man = spu_and((vec_uint4)(a), spu_splats((unsigned int)0x007FFFFF));
- return ((int)(spu_extract(spu_gather(spu_andc(spu_cmpeq(exp, exp_mask),
- spu_cmpeq(man, 0))), 0) == 0xF));
- }
- #define vec_all_nan(_a) (0)
- /* vec_all_ne (all elements not equal)
- * ==========
- */
- static inline int vec_all_ne(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_char16)(a), b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_char16)(b))), 0) == 0));
- }
- static inline int vec_all_ne(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_short8)(a), b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_short8)(b))), 0) == 0));
- }
- static inline int vec_all_ne(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_int4)(a), b)), 0) == 0));
- }
- static inline int vec_all_ne(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_int4)(b))), 0) == 0));
- }
- static inline int vec_all_ne(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0));
- }
- /* vec_all_nge (all elements not greater than or equal)
- * ===========
- */
- static inline int vec_all_nge(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0xF));
- }
- /* vec_all_ngt (all elements not greater than)
- * ===========
- */
- static inline int vec_all_ngt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0));
- }
- /* vec_all_nle (all elements not less than or equal)
- * ===========
- */
- static inline int vec_all_nle(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) == 0xF));
- }
- /* vec_all_nlt (all elements not less than)
- * ===========
- */
- static inline int vec_all_nlt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) == 0));
- }
- /* vec_all_numeric (all elements numeric)
- * ===========
- */
- static inline int vec_all_numeric(vec_float4 a)
- {
- vec_uint4 exp;
- exp = spu_and(spu_rlmask((vec_uint4)(a), -23), 0xFF);
- return ((int)(spu_extract(spu_gather(spu_cmpeq(exp, 255)), 0) == 0));
- }
- /* vec_any_eq (any elements equal)
- * ==========
- */
- static inline int vec_any_eq(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0));
- }
- static inline int vec_any_eq(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0));
- }
- static inline int vec_any_eq(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_char16)(a), b)), 0) != 0));
- }
- static inline int vec_any_eq(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_char16)(b))), 0) != 0));
- }
- static inline int vec_any_eq(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0));
- }
- static inline int vec_any_eq(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0));
- }
- static inline int vec_any_eq(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_short8)(a), b)), 0) != 0));
- }
- static inline int vec_any_eq(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_short8)(b))), 0) != 0));
- }
- static inline int vec_any_eq(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpeq(a, b), -31)), 0)));
- }
- static inline int vec_any_eq(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpeq(a, b), -31)), 0)));
- }
- static inline int vec_any_eq(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpeq((vec_int4)(a), b), -31)), 0)));
- }
- static inline int vec_any_eq(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpeq(a, (vec_int4)(b)), -31)), 0)));
- }
- static inline int vec_any_eq(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpeq(a, b), -31)), 0)));
- }
- /* vec_any_ge (any elements greater than or equal)
- * ==========
- */
- static inline int vec_any_ge(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xFFFF));
- }
- static inline int vec_any_ge(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xFFFF));
- }
- static inline int vec_any_ge(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_char16)(a))), 0) != 0xFFFF));
- }
- static inline int vec_any_ge(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(b), a)), 0) != 0xFFFF));
- }
- static inline int vec_any_ge(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xFF));
- }
- static inline int vec_any_ge(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xFF));
- }
- static inline int vec_any_ge(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_short8)(a))), 0) != 0xFF));
- }
- static inline int vec_any_ge(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(b), a)), 0) != 0xFF));
- }
- static inline int vec_any_ge(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xF));
- }
- static inline int vec_any_ge(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xF));
- }
- static inline int vec_any_ge(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_int4)(a))), 0) != 0xF));
- }
- static inline int vec_any_ge(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_int4)(b), a)), 0) != 0xF));
- }
- static inline int vec_any_ge(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xF));
- }
- /* vec_any_gt (any elements greater than)
- * ==========
- */
- static inline int vec_any_gt(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0));
- }
- static inline int vec_any_gt(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0));
- }
- static inline int vec_any_gt(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(a), b)), 0) != 0));
- }
- static inline int vec_any_gt(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_char16)(b))), 0) != 0));
- }
- static inline int vec_any_gt(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0));
- }
- static inline int vec_any_gt(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0));
- }
- static inline int vec_any_gt(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(a), b)), 0) != 0));
- }
- static inline int vec_any_gt(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_short8)(b))), 0) != 0));
- }
- static inline int vec_any_gt(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(a, b), -31)), 0)));
- }
- static inline int vec_any_gt(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(a, b), -31)), 0)));
- }
- static inline int vec_any_gt(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt((vec_int4)(a), b), -31)), 0)));
- }
- static inline int vec_any_gt(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(a, (vec_int4)(b)), -31)), 0)));
- }
- static inline int vec_any_gt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(a, b), -31)), 0)));
- }
- /* vec_any_le (any elements less than or equal)
- * ==========
- */
- static inline int vec_any_le(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xFFFF));
- }
- static inline int vec_any_le(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xFFFF));
- }
- static inline int vec_any_le(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(a), b)), 0) != 0xFFFF));
- }
- static inline int vec_any_le(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_char16)(b))), 0) != 0xFFFF));
- }
- static inline int vec_any_le(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xFF));
- }
- static inline int vec_any_le(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xFF));
- }
- static inline int vec_any_le(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(a), b)), 0) != 0xFF));
- }
- static inline int vec_any_le(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_short8)(b))), 0) != 0xFF));
- }
- static inline int vec_any_le(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xF));
- }
- static inline int vec_any_le(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xF));
- }
- static inline int vec_any_le(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_int4)(a), b)), 0) != 0xF));
- }
- static inline int vec_any_le(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, (vec_int4)(b))), 0) != 0xF));
- }
- static inline int vec_any_le(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xF));
- }
- /* vec_any_lt (any elements less than)
- * ==========
- */
- static inline int vec_any_lt(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0));
- }
- static inline int vec_any_lt(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0));
- }
- static inline int vec_any_lt(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_char16)(a))), 0) != 0));
- }
- static inline int vec_any_lt(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_char16)(b), a)), 0) != 0));
- }
- static inline int vec_any_lt(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0));
- }
- static inline int vec_any_lt(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0));
- }
- static inline int vec_any_lt(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, (vec_short8)(a))), 0) != 0));
- }
- static inline int vec_any_lt(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt((vec_short8)(b), a)), 0) != 0));
- }
- static inline int vec_any_lt(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(b, a), -31)), 0)));
- }
- static inline int vec_any_lt(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(b, a), -31)), 0)));
- }
- static inline int vec_any_lt(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(b, (vec_int4)(a)), -31)), 0)));
- }
- static inline int vec_any_lt(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt((vec_int4)(b), a), -31)), 0)));
- }
- static inline int vec_any_lt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(b, a), -31)), 0)));
- }
- /* vec_any_nan (any elements not a number)
- * ===========
- */
- static inline int vec_any_nan(vec_float4 a)
- {
- vec_uint4 exp, man;
- vec_uint4 exp_mask = spu_splats((unsigned int)0x7F800000);
- exp = spu_and((vec_uint4)(a), exp_mask);
- man = spu_and((vec_uint4)(a), spu_splats((unsigned int)0x007FFFFF));
- return ((int)(spu_extract(spu_gather(spu_andc(spu_cmpeq(exp, exp_mask),
- spu_cmpeq(man, 0))), 0) != 0));
- }
- /* vec_any_ne (any elements not equal)
- * ==========
- */
- static inline int vec_any_ne(vec_uchar16 a, vec_uchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0xFFFF));
- }
- static inline int vec_any_ne(vec_char16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0xFFFF));
- }
- static inline int vec_any_ne(vec_bchar16 a, vec_char16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_char16)(a), b)), 0) != 0xFFFF));
- }
- static inline int vec_any_ne(vec_char16 a, vec_bchar16 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_char16)(b))), 0) != 0xFFFF));
- }
- static inline int vec_any_ne(vec_ushort8 a, vec_ushort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0xFF));
- }
- static inline int vec_any_ne(vec_short8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0xFF));
- }
- static inline int vec_any_ne(vec_bshort8 a, vec_short8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_short8)(a), b)), 0) != 0xFF));
- }
- static inline int vec_any_ne(vec_short8 a, vec_bshort8 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_short8)(b))), 0) != 0xFF));
- }
- static inline int vec_any_ne(vec_uint4 a, vec_uint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0xF));
- }
- static inline int vec_any_ne(vec_int4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0xF));
- }
- static inline int vec_any_ne(vec_bint4 a, vec_int4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq((vec_int4)(a), b)), 0) != 0xF));
- }
- static inline int vec_any_ne(vec_int4 a, vec_bint4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, (vec_int4)(b))), 0) != 0xF));
- }
- static inline int vec_any_ne(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpeq(a, b)), 0) != 0xF));
- }
- /* vec_any_nge (any elements not greater than or equal)
- * ===========
- */
- static inline int vec_any_nge(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_orx(spu_rlmask(spu_cmpgt(b, a), -31)), 0)));
- }
- /* vec_any_ngt (any elements not greater than)
- * ===========
- */
- static inline int vec_any_ngt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0xF));
- }
- /* vec_any_nle (any elements not less than or equal)
- * ===========
- */
- static inline int vec_any_nle(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(a, b)), 0) != 0));
- }
- /* vec_any_nlt (any elements not less than)
- * ===========
- */
- static inline int vec_any_nlt(vec_float4 a, vec_float4 b)
- {
- return ((int)(spu_extract(spu_gather(spu_cmpgt(b, a)), 0) != 0xF));
- }
- /* vec_any_numeric (any elements numeric)
- * ===============
- */
- static inline int vec_any_numeric(vec_float4 a)
- {
- vec_uint4 exp;
- exp = spu_and(spu_rlmask((vec_uint4)(a), -23), 0xFF);
- return ((int)(spu_extract(spu_gather(spu_cmpeq(exp, 255)), 0) != 0xF));
- }
- /* vec_any_out (any elements out of bounds)
- * ===========
- */
- static inline int vec_any_out(vec_float4 a, vec_float4 b)
- {
- return (spu_extract(spu_gather(spu_nor(spu_cmpabsgt(a, b), (vec_uint4)(spu_rlmaska((vec_int4)(b), -31)))), 0) != 0xF);
- }
- /* CBE Language Extension Intrinsics
- */
- /* vec_extract (extract element from vector)
- * ===========
- */
- #define vec_extract(_a, _element) spu_extract(_a, _element)
- /* vec_insert (insert scalar into specified vector element)
- * ==========
- */
- #define vec_insert(_a, _b, _element) spu_insert(_a, _b, _element)
- /* vec_lvlx (load vector left indexed)
- * ========
- */
- static inline vec_uchar16 vec_lvlx(int a, unsigned char *b)
- {
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_uchar16 vec_lvlx(int a, vec_uchar16 *b)
- {
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_char16 vec_lvlx(int a, signed char *b)
- {
- vec_char16 *p = (vec_char16 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_char16 vec_lvlx(int a, vec_char16 *b)
- {
- vec_char16 *p = (vec_char16 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_ushort8 vec_lvlx(int a, unsigned short *b)
- {
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_ushort8 vec_lvlx(int a, vec_ushort8 *b)
- {
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_short8 vec_lvlx(int a, signed short *b)
- {
- vec_short8 *p = (vec_short8 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_short8 vec_lvlx(int a, vec_short8 *b)
- {
- vec_short8 *p = (vec_short8 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_uint4 vec_lvlx(int a, unsigned int *b)
- {
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_uint4 vec_lvlx(int a, vec_uint4 *b)
- {
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_int4 vec_lvlx(int a, signed int *b)
- {
- vec_int4 *p = (vec_int4 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_int4 vec_lvlx(int a, vec_int4 *b)
- {
- vec_int4 *p = (vec_int4 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_float4 vec_lvlx(int a, float *b)
- {
- vec_float4 *p = (vec_float4 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- static inline vec_float4 vec_lvlx(int a, vec_float4 *b)
- {
- vec_float4 *p = (vec_float4 *)((unsigned char *)(b) + a);
- return(spu_slqwbyte(*p, (unsigned int)p & 0xF));
- }
- /* vec_lvlxl (load vector left indexed last)
- * =========
- */
- #define vec_lvlxl(_a, _b) vec_lvlx(_a, _b)
- /* vec_lvrx (load vector right indexed)
- * ========
- */
- static inline vec_uchar16 vec_lvrx(int a, unsigned char *b)
- {
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_uchar16 vec_lvrx(int a, vec_uchar16 *b)
- {
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_char16 vec_lvrx(int a, signed char *b)
- {
- vec_char16 *p = (vec_char16 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_char16 vec_lvrx(int a, vec_char16 *b)
- {
- vec_char16 *p = (vec_char16 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_ushort8 vec_lvrx(int a, unsigned short *b)
- {
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_ushort8 vec_lvrx(int a, vec_ushort8 *b)
- {
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_short8 vec_lvrx(int a, signed short *b)
- {
- vec_short8 *p = (vec_short8 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_short8 vec_lvrx(int a, vec_short8 *b)
- {
- vec_short8 *p = (vec_short8 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_uint4 vec_lvrx(int a, unsigned int *b)
- {
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_uint4 vec_lvrx(int a, vec_uint4 *b)
- {
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_int4 vec_lvrx(int a, signed int *b)
- {
- vec_int4 *p = (vec_int4 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_int4 vec_lvrx(int a, vec_int4 *b)
- {
- vec_int4 *p = (vec_int4 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_float4 vec_lvrx(int a, float *b)
- {
- vec_float4 *p = (vec_float4 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- static inline vec_float4 vec_lvrx(int a, vec_float4 *b)
- {
- vec_float4 *p = (vec_float4 *)((unsigned char *)(b) + a);
- return(spu_rlmaskqwbyte(*p, ((int)p & 0xF)-16));
- }
- /* vec_lvrxl (load vector right indexed last)
- * =========
- */
- #define vec_lvrxl(_a, _b) vec_lvrx(_a, _b)
- /* vec_promote (promote scalar to a vector)
- * ===========
- */
- #define vec_promote(_a, _element) spu_promote(_a, _element)
- /* vec_splats (splat scalar to a vector)
- * ==========
- */
- #define vec_splats(_a) spu_splats(_a)
- /* vec_stvlx (store vector left indexed)
- * =========
- */
- static inline void vec_stvlx(vec_uchar16 a, int b, unsigned char *c)
- {
- int shift;
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvlx(vec_uchar16 a, int b, vec_uchar16 *c)
- {
- int shift;
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvlx(vec_char16 a, int b, signed char *c)
- {
- int shift;
- vec_char16 *p = (vec_char16 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvlx(vec_char16 a, int b, vec_char16 *c)
- {
- int shift;
- vec_char16 *p = (vec_char16 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvlx(vec_ushort8 a, int b, unsigned short *c)
- {
- int shift;
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvlx(vec_ushort8 a, int b, vec_ushort8 *c)
- {
- int shift;
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvlx(vec_short8 a, int b, signed short *c)
- {
- int shift;
- vec_short8 *p = (vec_short8 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvlx(vec_short8 a, int b, vec_short8 *c)
- {
- int shift;
- vec_short8 *p = (vec_short8 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvlx(vec_uint4 a, int b, unsigned int *c)
- {
- int shift;
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvlx(vec_uint4 a, int b, vec_uint4 *c)
- {
- int shift;
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvlx(vec_int4 a, int b, signed int *c)
- {
- int shift;
- vec_int4 *p = (vec_int4 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvlx(vec_int4 a, int b, vec_int4 *c)
- {
- int shift;
- vec_int4 *p = (vec_int4 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvlx(vec_float4 a, int b, float *c)
- {
- int shift;
- vec_float4 *p = (vec_float4 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvlx(vec_float4 a, int b, vec_float4 *c)
- {
- int shift;
- vec_float4 *p = (vec_float4 *)((unsigned char *)(c) + b);
- shift = -((int)p & 0xF);
- *p = spu_sel(*p,
- spu_rlmaskqwbyte(a, shift),
- spu_rlmaskqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- /* vec_stvlxl (store vector left indexed last)
- * ==========
- */
- #define vec_stvlxl(_a, _b, _c) vec_stvlx(_a, _b, _c)
- /* vec_stvrx (store vector right indexed)
- * =========
- */
- static inline void vec_stvrx(vec_uchar16 a, int b, unsigned char *c)
- {
- int shift;
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvrx(vec_uchar16 a, int b, vec_uchar16 *c)
- {
- int shift;
- vec_uchar16 *p = (vec_uchar16 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvrx(vec_char16 a, int b, signed char *c)
- {
- int shift;
- vec_char16 *p = (vec_char16 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvrx(vec_char16 a, int b, vec_char16 *c)
- {
- int shift;
- vec_char16 *p = (vec_char16 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned char)0xFF), shift));
- }
- static inline void vec_stvrx(vec_ushort8 a, int b, unsigned short *c)
- {
- int shift;
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvrx(vec_ushort8 a, int b, vec_ushort8 *c)
- {
- int shift;
- vec_ushort8 *p = (vec_ushort8 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvrx(vec_short8 a, int b, signed short *c)
- {
- int shift;
- vec_short8 *p = (vec_short8 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvrx(vec_short8 a, int b, vec_short8 *c)
- {
- int shift;
- vec_short8 *p = (vec_short8 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned short)0xFFFF), shift));
- }
- static inline void vec_stvrx(vec_uint4 a, int b, unsigned int *c)
- {
- int shift;
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvrx(vec_uint4 a, int b, vec_uint4 *c)
- {
- int shift;
- vec_uint4 *p = (vec_uint4 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvrx(vec_int4 a, int b, signed int *c)
- {
- int shift;
- vec_int4 *p = (vec_int4 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvrx(vec_int4 a, int b, vec_int4 *c)
- {
- int shift;
- vec_int4 *p = (vec_int4 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvrx(vec_float4 a, int b, float *c)
- {
- int shift;
- vec_float4 *p = (vec_float4 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- static inline void vec_stvrx(vec_float4 a, int b, vec_float4 *c)
- {
- int shift;
- vec_float4 *p = (vec_float4 *)((unsigned char *)(c) + b);
- shift = 16-((int)p & 0xF);
- *p = spu_sel(*p,
- spu_slqwbyte(a, shift),
- spu_slqwbyte(spu_splats((unsigned int)0xFFFFFFFF), shift));
- }
- /* vec_stvrxl (store vector right indexed last)
- * ==========
- */
- #define vec_stvrxl(_a, _b, _c) vec_stvrx(_a, _b, _c)
- #endif /* __SPU__ */
- #endif /* __cplusplus */
- #endif /* !_VMX2SPU_H_ */
|