ARMInstrMVE.td 322 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553
  1. //===-- ARMInstrMVE.td - MVE support for ARM ---------------*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file describes the ARM MVE instruction set.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. // VPT condition mask
  13. def vpt_mask : Operand<i32> {
  14. let PrintMethod = "printVPTMask";
  15. let ParserMatchClass = it_mask_asmoperand;
  16. let EncoderMethod = "getVPTMaskOpValue";
  17. let DecoderMethod = "DecodeVPTMaskOperand";
  18. }
  19. // VPT/VCMP restricted predicate for sign invariant types
  20. def pred_restricted_i_asmoperand : AsmOperandClass {
  21. let Name = "CondCodeRestrictedI";
  22. let RenderMethod = "addITCondCodeOperands";
  23. let PredicateMethod = "isITCondCodeRestrictedI";
  24. let ParserMethod = "parseITCondCode";
  25. let DiagnosticString = "condition code for sign-independent integer "#
  26. "comparison must be EQ or NE";
  27. }
  28. // VPT/VCMP restricted predicate for signed types
  29. def pred_restricted_s_asmoperand : AsmOperandClass {
  30. let Name = "CondCodeRestrictedS";
  31. let RenderMethod = "addITCondCodeOperands";
  32. let PredicateMethod = "isITCondCodeRestrictedS";
  33. let ParserMethod = "parseITCondCode";
  34. let DiagnosticString = "condition code for signed integer "#
  35. "comparison must be EQ, NE, LT, GT, LE or GE";
  36. }
  37. // VPT/VCMP restricted predicate for unsigned types
  38. def pred_restricted_u_asmoperand : AsmOperandClass {
  39. let Name = "CondCodeRestrictedU";
  40. let RenderMethod = "addITCondCodeOperands";
  41. let PredicateMethod = "isITCondCodeRestrictedU";
  42. let ParserMethod = "parseITCondCode";
  43. let DiagnosticString = "condition code for unsigned integer "#
  44. "comparison must be EQ, NE, HS or HI";
  45. }
  46. // VPT/VCMP restricted predicate for floating point
  47. def pred_restricted_fp_asmoperand : AsmOperandClass {
  48. let Name = "CondCodeRestrictedFP";
  49. let RenderMethod = "addITCondCodeOperands";
  50. let PredicateMethod = "isITCondCodeRestrictedFP";
  51. let ParserMethod = "parseITCondCode";
  52. let DiagnosticString = "condition code for floating-point "#
  53. "comparison must be EQ, NE, LT, GT, LE or GE";
  54. }
  55. class VCMPPredicateOperand : Operand<i32>;
  56. def pred_basic_i : VCMPPredicateOperand {
  57. let PrintMethod = "printMandatoryRestrictedPredicateOperand";
  58. let ParserMatchClass = pred_restricted_i_asmoperand;
  59. let DecoderMethod = "DecodeRestrictedIPredicateOperand";
  60. let EncoderMethod = "getRestrictedCondCodeOpValue";
  61. }
  62. def pred_basic_u : VCMPPredicateOperand {
  63. let PrintMethod = "printMandatoryRestrictedPredicateOperand";
  64. let ParserMatchClass = pred_restricted_u_asmoperand;
  65. let DecoderMethod = "DecodeRestrictedUPredicateOperand";
  66. let EncoderMethod = "getRestrictedCondCodeOpValue";
  67. }
  68. def pred_basic_s : VCMPPredicateOperand {
  69. let PrintMethod = "printMandatoryRestrictedPredicateOperand";
  70. let ParserMatchClass = pred_restricted_s_asmoperand;
  71. let DecoderMethod = "DecodeRestrictedSPredicateOperand";
  72. let EncoderMethod = "getRestrictedCondCodeOpValue";
  73. }
  74. def pred_basic_fp : VCMPPredicateOperand {
  75. let PrintMethod = "printMandatoryRestrictedPredicateOperand";
  76. let ParserMatchClass = pred_restricted_fp_asmoperand;
  77. let DecoderMethod = "DecodeRestrictedFPPredicateOperand";
  78. let EncoderMethod = "getRestrictedCondCodeOpValue";
  79. }
  80. // Register list operands for interleaving load/stores
  81. def VecList2QAsmOperand : AsmOperandClass {
  82. let Name = "VecListTwoMQ";
  83. let ParserMethod = "parseVectorList";
  84. let RenderMethod = "addMVEVecListOperands";
  85. let DiagnosticString = "operand must be a list of two consecutive "#
  86. "q-registers in range [q0,q7]";
  87. }
  88. def VecList2Q : RegisterOperand<MQQPR, "printMVEVectorListTwoQ"> {
  89. let ParserMatchClass = VecList2QAsmOperand;
  90. let PrintMethod = "printMVEVectorList<2>";
  91. }
  92. def VecList4QAsmOperand : AsmOperandClass {
  93. let Name = "VecListFourMQ";
  94. let ParserMethod = "parseVectorList";
  95. let RenderMethod = "addMVEVecListOperands";
  96. let DiagnosticString = "operand must be a list of four consecutive "#
  97. "q-registers in range [q0,q7]";
  98. }
  99. def VecList4Q : RegisterOperand<MQQQQPR, "printMVEVectorListFourQ"> {
  100. let ParserMatchClass = VecList4QAsmOperand;
  101. let PrintMethod = "printMVEVectorList<4>";
  102. }
  103. // taddrmode_imm7 := reg[r0-r7] +/- (imm7 << shift)
  104. class TMemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass {
  105. let Name = "TMemImm7Shift"#shift#"Offset";
  106. let PredicateMethod = "isMemImm7ShiftedOffset<"#shift#",ARM::tGPRRegClassID>";
  107. let RenderMethod = "addMemImmOffsetOperands";
  108. }
  109. class taddrmode_imm7<int shift> : MemOperand,
  110. ComplexPattern<i32, 2, "SelectTAddrModeImm7<"#shift#">", []> {
  111. let ParserMatchClass = TMemImm7ShiftOffsetAsmOperand<shift>;
  112. // They are printed the same way as the T2 imm8 version
  113. let PrintMethod = "printT2AddrModeImm8Operand<false>";
  114. // This can also be the same as the T2 version.
  115. let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
  116. let DecoderMethod = "DecodeTAddrModeImm7<"#shift#">";
  117. let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
  118. }
  119. // t2addrmode_imm7 := reg +/- (imm7)
  120. class MemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass {
  121. let Name = "MemImm7Shift"#shift#"Offset";
  122. let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
  123. ",ARM::GPRnopcRegClassID>";
  124. let RenderMethod = "addMemImmOffsetOperands";
  125. }
  126. def MemImm7Shift0OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<0>;
  127. def MemImm7Shift1OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<1>;
  128. def MemImm7Shift2OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<2>;
  129. class T2AddrMode_Imm7<int shift> : MemOperand,
  130. ComplexPattern<i32, 2, "SelectT2AddrModeImm7<"#shift#">", []> {
  131. let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
  132. let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 0>";
  133. let ParserMatchClass =
  134. !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetAsmOperand");
  135. let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
  136. }
  137. class t2addrmode_imm7<int shift> : T2AddrMode_Imm7<shift> {
  138. // They are printed the same way as the imm8 version
  139. let PrintMethod = "printT2AddrModeImm8Operand<false>";
  140. }
  141. class MemImm7ShiftOffsetWBAsmOperand<int shift> : AsmOperandClass {
  142. let Name = "MemImm7Shift"#shift#"OffsetWB";
  143. let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
  144. ",ARM::rGPRRegClassID>";
  145. let RenderMethod = "addMemImmOffsetOperands";
  146. }
  147. def MemImm7Shift0OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<0>;
  148. def MemImm7Shift1OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<1>;
  149. def MemImm7Shift2OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<2>;
  150. class t2addrmode_imm7_pre<int shift> : T2AddrMode_Imm7<shift> {
  151. // They are printed the same way as the imm8 version
  152. let PrintMethod = "printT2AddrModeImm8Operand<true>";
  153. let ParserMatchClass =
  154. !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetWBAsmOperand");
  155. let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 1>";
  156. let MIOperandInfo = (ops rGPR:$base, i32imm:$offsim);
  157. }
  158. class t2am_imm7shiftOffsetAsmOperand<int shift>
  159. : AsmOperandClass { let Name = "Imm7Shift"#shift; }
  160. def t2am_imm7shift0OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<0>;
  161. def t2am_imm7shift1OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<1>;
  162. def t2am_imm7shift2OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<2>;
  163. class t2am_imm7_offset<int shift> : MemOperand,
  164. ComplexPattern<i32, 1, "SelectT2AddrModeImm7Offset<"#shift#">",
  165. [], [SDNPWantRoot]> {
  166. // They are printed the same way as the imm8 version
  167. let PrintMethod = "printT2AddrModeImm8OffsetOperand";
  168. let ParserMatchClass =
  169. !cast<AsmOperandClass>("t2am_imm7shift"#shift#"OffsetAsmOperand");
  170. let EncoderMethod = "getT2ScaledImmOpValue<7,"#shift#">";
  171. let DecoderMethod = "DecodeT2Imm7<"#shift#">";
  172. }
  173. // Operands for gather/scatter loads of the form [Rbase, Qoffsets]
  174. class MemRegRQOffsetAsmOperand<int shift> : AsmOperandClass {
  175. let Name = "MemRegRQS"#shift#"Offset";
  176. let PredicateMethod = "isMemRegRQOffset<"#shift#">";
  177. let RenderMethod = "addMemRegRQOffsetOperands";
  178. }
  179. def MemRegRQS0OffsetAsmOperand : MemRegRQOffsetAsmOperand<0>;
  180. def MemRegRQS1OffsetAsmOperand : MemRegRQOffsetAsmOperand<1>;
  181. def MemRegRQS2OffsetAsmOperand : MemRegRQOffsetAsmOperand<2>;
  182. def MemRegRQS3OffsetAsmOperand : MemRegRQOffsetAsmOperand<3>;
  183. // mve_addr_rq_shift := reg + vreg{ << UXTW #shift}
  184. class mve_addr_rq_shift<int shift> : MemOperand {
  185. let EncoderMethod = "getMveAddrModeRQOpValue";
  186. let PrintMethod = "printMveAddrModeRQOperand<"#shift#">";
  187. let ParserMatchClass =
  188. !cast<AsmOperandClass>("MemRegRQS"#shift#"OffsetAsmOperand");
  189. let DecoderMethod = "DecodeMveAddrModeRQ";
  190. let MIOperandInfo = (ops GPRnopc:$base, MQPR:$offsreg);
  191. }
  192. class MemRegQOffsetAsmOperand<int shift> : AsmOperandClass {
  193. let Name = "MemRegQS"#shift#"Offset";
  194. let PredicateMethod = "isMemRegQOffset<"#shift#">";
  195. let RenderMethod = "addMemImmOffsetOperands";
  196. }
  197. def MemRegQS2OffsetAsmOperand : MemRegQOffsetAsmOperand<2>;
  198. def MemRegQS3OffsetAsmOperand : MemRegQOffsetAsmOperand<3>;
  199. // mve_addr_q_shift := vreg {+ #imm7s2/4}
  200. class mve_addr_q_shift<int shift> : MemOperand {
  201. let EncoderMethod = "getMveAddrModeQOpValue<"#shift#">";
  202. // Can be printed same way as other reg + imm operands
  203. let PrintMethod = "printT2AddrModeImm8Operand<false>";
  204. let ParserMatchClass =
  205. !cast<AsmOperandClass>("MemRegQS"#shift#"OffsetAsmOperand");
  206. let DecoderMethod = "DecodeMveAddrModeQ<"#shift#">";
  207. let MIOperandInfo = (ops MQPR:$base, i32imm:$imm);
  208. }
  209. // A family of classes wrapping up information about the vector types
  210. // used by MVE.
  211. class MVEVectorVTInfo<ValueType vec, ValueType dblvec,
  212. ValueType pred, ValueType dblpred,
  213. bits<2> size, string suffixletter, bit unsigned> {
  214. // The LLVM ValueType representing the vector, so we can use it in
  215. // ISel patterns.
  216. ValueType Vec = vec;
  217. // The LLVM ValueType representing a vector with elements double the size
  218. // of those in Vec, so we can use it in ISel patterns. It is up to the
  219. // invoker of this class to ensure that this is a correct choice.
  220. ValueType DblVec = dblvec;
  221. // An LLVM ValueType representing a corresponding vector of
  222. // predicate bits, for use in ISel patterns that handle an IR
  223. // intrinsic describing the predicated form of the instruction.
  224. ValueType Pred = pred;
  225. // Same as Pred but for DblVec rather than Vec.
  226. ValueType DblPred = dblpred;
  227. // The most common representation of the vector element size in MVE
  228. // instruction encodings: a 2-bit value V representing an (8<<V)-bit
  229. // vector element.
  230. bits<2> Size = size;
  231. // For vectors explicitly mentioning a signedness of integers: 0 for
  232. // signed and 1 for unsigned. For anything else, undefined.
  233. bit Unsigned = unsigned;
  234. // The number of bits in a vector element, in integer form.
  235. int LaneBits = !shl(8, Size);
  236. // The suffix used in assembly language on an instruction operating
  237. // on this lane if it only cares about number of bits.
  238. string BitsSuffix = !if(!eq(suffixletter, "p"),
  239. !if(!eq(unsigned, 0b0), "8", "16"),
  240. !cast<string>(LaneBits));
  241. // The suffix used on an instruction that mentions the whole type.
  242. string Suffix = suffixletter # BitsSuffix;
  243. // The letter part of the suffix only.
  244. string SuffixLetter = suffixletter;
  245. }
  246. // Integer vector types that don't treat signed and unsigned differently.
  247. def MVE_v16i8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "i", ?>;
  248. def MVE_v8i16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "i", ?>;
  249. def MVE_v4i32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "i", ?>;
  250. def MVE_v2i64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "i", ?>;
  251. // Explicitly signed and unsigned integer vectors. They map to the
  252. // same set of LLVM ValueTypes as above, but are represented
  253. // differently in assembly and instruction encodings.
  254. def MVE_v16s8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "s", 0b0>;
  255. def MVE_v8s16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "s", 0b0>;
  256. def MVE_v4s32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "s", 0b0>;
  257. def MVE_v2s64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "s", 0b0>;
  258. def MVE_v16u8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "u", 0b1>;
  259. def MVE_v8u16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "u", 0b1>;
  260. def MVE_v4u32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "u", 0b1>;
  261. def MVE_v2u64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "u", 0b1>;
  262. // FP vector types.
  263. def MVE_v8f16 : MVEVectorVTInfo<v8f16, v4f32, v8i1, v4i1, 0b01, "f", ?>;
  264. def MVE_v4f32 : MVEVectorVTInfo<v4f32, v2f64, v4i1, v2i1, 0b10, "f", ?>;
  265. def MVE_v2f64 : MVEVectorVTInfo<v2f64, ?, v2i1, ?, 0b11, "f", ?>;
  266. // Polynomial vector types.
  267. def MVE_v16p8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b11, "p", 0b0>;
  268. def MVE_v8p16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b11, "p", 0b1>;
  269. multiclass MVE_TwoOpPattern<MVEVectorVTInfo VTI, SDPatternOperator Op, Intrinsic PredInt,
  270. dag PredOperands, Instruction Inst,
  271. SDPatternOperator IdentityVec = null_frag> {
  272. // Unpredicated
  273. def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
  274. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  275. // Predicated with select
  276. if !ne(VTI.Size, 0b11) then {
  277. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$mask),
  278. (VTI.Vec (Op (VTI.Vec MQPR:$Qm),
  279. (VTI.Vec MQPR:$Qn))),
  280. (VTI.Vec MQPR:$inactive))),
  281. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  282. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  283. (VTI.Vec MQPR:$inactive)))>;
  284. // Optionally with the select folded through the op
  285. def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm),
  286. (VTI.Vec (vselect (VTI.Pred VCCR:$mask),
  287. (VTI.Vec MQPR:$Qn),
  288. (VTI.Vec IdentityVec))))),
  289. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  290. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  291. (VTI.Vec MQPR:$Qm)))>;
  292. }
  293. // Predicated with intrinsic
  294. def : Pat<(VTI.Vec !con((PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)),
  295. PredOperands,
  296. (? (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive)))),
  297. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  298. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  299. (VTI.Vec MQPR:$inactive)))>;
  300. }
  301. multiclass MVE_TwoOpPatternDup<MVEVectorVTInfo VTI, SDPatternOperator Op, Intrinsic PredInt,
  302. dag PredOperands, Instruction Inst,
  303. SDPatternOperator IdentityVec = null_frag> {
  304. // Unpredicated
  305. def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn)))),
  306. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn))>;
  307. // Predicated with select
  308. if !ne(VTI.Size, 0b11) then {
  309. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$mask),
  310. (VTI.Vec (Op (VTI.Vec MQPR:$Qm),
  311. (VTI.Vec (ARMvdup rGPR:$Rn)))),
  312. (VTI.Vec MQPR:$inactive))),
  313. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn,
  314. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  315. (VTI.Vec MQPR:$inactive)))>;
  316. // Optionally with the select folded through the op
  317. def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm),
  318. (VTI.Vec (vselect (VTI.Pred VCCR:$mask),
  319. (ARMvdup rGPR:$Rn),
  320. (VTI.Vec IdentityVec))))),
  321. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn,
  322. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  323. (VTI.Vec MQPR:$Qm)))>;
  324. }
  325. // Predicated with intrinsic
  326. def : Pat<(VTI.Vec !con((PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))),
  327. PredOperands,
  328. (? (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive)))),
  329. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn,
  330. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  331. (VTI.Vec MQPR:$inactive)))>;
  332. }
  333. // --------- Start of base classes for the instructions themselves
  334. class MVE_MI<dag oops, dag iops, InstrItinClass itin, string asm,
  335. string ops, string cstr, bits<2> vecsize, list<dag> pattern>
  336. : Thumb2XI<oops, iops, AddrModeNone, 4, itin, !strconcat(asm, "\t", ops), cstr,
  337. pattern>,
  338. Requires<[HasMVEInt]> {
  339. let D = MVEDomain;
  340. let DecoderNamespace = "MVE";
  341. let VecSize = vecsize;
  342. }
  343. // MVE_p is used for most predicated instructions, to add the cluster
  344. // of input operands that provides the VPT suffix (none, T or E) and
  345. // the input predicate register.
  346. class MVE_p<dag oops, dag iops, InstrItinClass itin, string iname,
  347. string suffix, string ops, vpred_ops vpred, string cstr,
  348. bits<2> vecsize, list<dag> pattern=[]>
  349. : MVE_MI<oops, !con(iops, (ins vpred:$vp)), itin,
  350. // If the instruction has a suffix, like vadd.f32, then the
  351. // VPT predication suffix goes before the dot, so the full
  352. // name has to be "vadd${vp}.f32".
  353. !strconcat(iname, "${vp}",
  354. !if(!eq(suffix, ""), "", !strconcat(".", suffix))),
  355. ops, !strconcat(cstr, vpred.vpred_constraint), vecsize, pattern> {
  356. let Inst{31-29} = 0b111;
  357. let Inst{27-26} = 0b11;
  358. }
  359. class MVE_f<dag oops, dag iops, InstrItinClass itin, string iname,
  360. string suffix, string ops, vpred_ops vpred, string cstr,
  361. bits<2> vecsize, list<dag> pattern=[]>
  362. : MVE_p<oops, iops, itin, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  363. let Predicates = [HasMVEFloat];
  364. }
  365. class MVE_MI_with_pred<dag oops, dag iops, InstrItinClass itin, string asm,
  366. string ops, string cstr, list<dag> pattern>
  367. : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm, !strconcat("\t", ops), cstr,
  368. pattern>,
  369. Requires<[HasV8_1MMainline, HasMVEInt]> {
  370. let D = MVEDomain;
  371. let DecoderNamespace = "MVE";
  372. }
  373. class MVE_VMOV_lane_base<dag oops, dag iops, InstrItinClass itin, string asm,
  374. string suffix, string ops, string cstr,
  375. list<dag> pattern>
  376. : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm,
  377. !if(!eq(suffix, ""), "", "." # suffix) # "\t" # ops,
  378. cstr, pattern>,
  379. Requires<[HasV8_1MMainline, HasMVEInt]> {
  380. let D = MVEDomain;
  381. let DecoderNamespace = "MVE";
  382. }
  383. class MVE_ScalarShift<string iname, dag oops, dag iops, string asm, string cstr,
  384. list<dag> pattern=[]>
  385. : MVE_MI_with_pred<oops, iops, NoItinerary, iname, asm, cstr, pattern> {
  386. let Inst{31-20} = 0b111010100101;
  387. let Inst{8} = 0b1;
  388. let validForTailPredication=1;
  389. }
  390. class MVE_ScalarShiftSingleReg<string iname, dag iops, string asm, string cstr,
  391. list<dag> pattern=[]>
  392. : MVE_ScalarShift<iname, (outs rGPR:$RdaDest), iops, asm, cstr, pattern> {
  393. bits<4> RdaDest;
  394. let Inst{19-16} = RdaDest{3-0};
  395. }
  396. class MVE_ScalarShiftSRegImm<string iname, bits<2> op5_4>
  397. : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, long_shift:$imm),
  398. "$RdaSrc, $imm", "$RdaDest = $RdaSrc",
  399. [(set rGPR:$RdaDest,
  400. (i32 (!cast<Intrinsic>("int_arm_mve_" # iname)
  401. (i32 rGPR:$RdaSrc), (i32 imm:$imm))))]> {
  402. bits<5> imm;
  403. let Inst{15} = 0b0;
  404. let Inst{14-12} = imm{4-2};
  405. let Inst{11-8} = 0b1111;
  406. let Inst{7-6} = imm{1-0};
  407. let Inst{5-4} = op5_4{1-0};
  408. let Inst{3-0} = 0b1111;
  409. }
  410. def MVE_SQSHL : MVE_ScalarShiftSRegImm<"sqshl", 0b11>;
  411. def MVE_SRSHR : MVE_ScalarShiftSRegImm<"srshr", 0b10>;
  412. def MVE_UQSHL : MVE_ScalarShiftSRegImm<"uqshl", 0b00>;
  413. def MVE_URSHR : MVE_ScalarShiftSRegImm<"urshr", 0b01>;
  414. class MVE_ScalarShiftSRegReg<string iname, bits<2> op5_4>
  415. : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, rGPR:$Rm),
  416. "$RdaSrc, $Rm", "$RdaDest = $RdaSrc",
  417. [(set rGPR:$RdaDest,
  418. (i32 (!cast<Intrinsic>("int_arm_mve_" # iname)
  419. (i32 rGPR:$RdaSrc), (i32 rGPR:$Rm))))]> {
  420. bits<4> Rm;
  421. let Inst{15-12} = Rm{3-0};
  422. let Inst{11-8} = 0b1111;
  423. let Inst{7-6} = 0b00;
  424. let Inst{5-4} = op5_4{1-0};
  425. let Inst{3-0} = 0b1101;
  426. let Unpredictable{8-6} = 0b111;
  427. }
  428. def MVE_SQRSHR : MVE_ScalarShiftSRegReg<"sqrshr", 0b10>;
  429. def MVE_UQRSHL : MVE_ScalarShiftSRegReg<"uqrshl", 0b00>;
  430. class MVE_ScalarShiftDoubleReg<string iname, dag iops, string asm,
  431. string cstr, list<dag> pattern=[]>
  432. : MVE_ScalarShift<iname, (outs tGPREven:$RdaLo, tGPROdd:$RdaHi),
  433. iops, asm, cstr, pattern> {
  434. bits<4> RdaLo;
  435. bits<4> RdaHi;
  436. let Inst{19-17} = RdaLo{3-1};
  437. let Inst{11-9} = RdaHi{3-1};
  438. let hasSideEffects = 0;
  439. }
  440. class MVE_ScalarShiftDRegImm<string iname, bits<2> op5_4, bit op16,
  441. list<dag> pattern=[]>
  442. : MVE_ScalarShiftDoubleReg<
  443. iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, long_shift:$imm),
  444. "$RdaLo, $RdaHi, $imm", "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
  445. pattern> {
  446. bits<5> imm;
  447. let Inst{16} = op16;
  448. let Inst{15} = 0b0;
  449. let Inst{14-12} = imm{4-2};
  450. let Inst{7-6} = imm{1-0};
  451. let Inst{5-4} = op5_4{1-0};
  452. let Inst{3-0} = 0b1111;
  453. }
  454. class MVE_ScalarShiftDRegRegBase<string iname, dag iops, string asm,
  455. bit op5, bit op16, list<dag> pattern=[]>
  456. : MVE_ScalarShiftDoubleReg<
  457. iname, iops, asm, "@earlyclobber $RdaHi,@earlyclobber $RdaLo,"
  458. "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
  459. pattern> {
  460. bits<4> Rm;
  461. let Inst{16} = op16;
  462. let Inst{15-12} = Rm{3-0};
  463. let Inst{6} = 0b0;
  464. let Inst{5} = op5;
  465. let Inst{4} = 0b0;
  466. let Inst{3-0} = 0b1101;
  467. // Custom decoder method because of the following overlapping encodings:
  468. // ASRL and SQRSHR
  469. // LSLL and UQRSHL
  470. // SQRSHRL and SQRSHR
  471. // UQRSHLL and UQRSHL
  472. let DecoderMethod = "DecodeMVEOverlappingLongShift";
  473. }
  474. class MVE_ScalarShiftDRegReg<string iname, bit op5, list<dag> pattern=[]>
  475. : MVE_ScalarShiftDRegRegBase<
  476. iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm),
  477. "$RdaLo, $RdaHi, $Rm", op5, 0b0, pattern> {
  478. let Inst{7} = 0b0;
  479. }
  480. class MVE_ScalarShiftDRegRegWithSat<string iname, bit op5, list<dag> pattern=[]>
  481. : MVE_ScalarShiftDRegRegBase<
  482. iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm, saturateop:$sat),
  483. "$RdaLo, $RdaHi, $sat, $Rm", op5, 0b1, pattern> {
  484. bit sat;
  485. let Inst{7} = sat;
  486. }
  487. def MVE_ASRLr : MVE_ScalarShiftDRegReg<"asrl", 0b1, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
  488. (ARMasrl tGPREven:$RdaLo_src,
  489. tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
  490. def MVE_ASRLi : MVE_ScalarShiftDRegImm<"asrl", 0b10, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
  491. (ARMasrl tGPREven:$RdaLo_src,
  492. tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
  493. def MVE_LSLLr : MVE_ScalarShiftDRegReg<"lsll", 0b0, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
  494. (ARMlsll tGPREven:$RdaLo_src,
  495. tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
  496. def MVE_LSLLi : MVE_ScalarShiftDRegImm<"lsll", 0b00, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
  497. (ARMlsll tGPREven:$RdaLo_src,
  498. tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
  499. def MVE_LSRL : MVE_ScalarShiftDRegImm<"lsrl", 0b01, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
  500. (ARMlsrl tGPREven:$RdaLo_src,
  501. tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
  502. def MVE_SQRSHRL : MVE_ScalarShiftDRegRegWithSat<"sqrshrl", 0b1>;
  503. def MVE_SQSHLL : MVE_ScalarShiftDRegImm<"sqshll", 0b11, 0b1>;
  504. def MVE_SRSHRL : MVE_ScalarShiftDRegImm<"srshrl", 0b10, 0b1>;
  505. def MVE_UQRSHLL : MVE_ScalarShiftDRegRegWithSat<"uqrshll", 0b0>;
  506. def MVE_UQSHLL : MVE_ScalarShiftDRegImm<"uqshll", 0b00, 0b1>;
  507. def MVE_URSHRL : MVE_ScalarShiftDRegImm<"urshrl", 0b01, 0b1>;
  508. // start of mve_rDest instructions
  509. class MVE_rDest<dag oops, dag iops, InstrItinClass itin,
  510. string iname, string suffix,
  511. string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  512. // Always use vpred_n and not vpred_r: with the output register being
  513. // a GPR and not a vector register, there can't be any question of
  514. // what to put in its inactive lanes.
  515. : MVE_p<oops, iops, itin, iname, suffix, ops, vpred_n, cstr, vecsize, pattern> {
  516. let Inst{25-23} = 0b101;
  517. let Inst{11-9} = 0b111;
  518. let Inst{4} = 0b0;
  519. }
  520. class MVE_VABAV<string suffix, bit U, bits<2> size>
  521. : MVE_rDest<(outs rGPR:$Rda), (ins rGPR:$Rda_src, MQPR:$Qn, MQPR:$Qm),
  522. NoItinerary, "vabav", suffix, "$Rda, $Qn, $Qm", "$Rda = $Rda_src",
  523. size, []> {
  524. bits<4> Qm;
  525. bits<4> Qn;
  526. bits<4> Rda;
  527. let Inst{28} = U;
  528. let Inst{22} = 0b0;
  529. let Inst{21-20} = size{1-0};
  530. let Inst{19-17} = Qn{2-0};
  531. let Inst{16} = 0b0;
  532. let Inst{15-12} = Rda{3-0};
  533. let Inst{8} = 0b1;
  534. let Inst{7} = Qn{3};
  535. let Inst{6} = 0b0;
  536. let Inst{5} = Qm{3};
  537. let Inst{3-1} = Qm{2-0};
  538. let Inst{0} = 0b1;
  539. let horizontalReduction = 1;
  540. }
  541. multiclass MVE_VABAV_m<MVEVectorVTInfo VTI> {
  542. def "" : MVE_VABAV<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  543. defvar Inst = !cast<Instruction>(NAME);
  544. let Predicates = [HasMVEInt] in {
  545. def : Pat<(i32 (int_arm_mve_vabav
  546. (i32 VTI.Unsigned),
  547. (i32 rGPR:$Rda_src),
  548. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  549. (i32 (Inst (i32 rGPR:$Rda_src),
  550. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
  551. def : Pat<(i32 (int_arm_mve_vabav_predicated
  552. (i32 VTI.Unsigned),
  553. (i32 rGPR:$Rda_src),
  554. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  555. (VTI.Pred VCCR:$mask))),
  556. (i32 (Inst (i32 rGPR:$Rda_src),
  557. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  558. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  559. }
  560. }
  561. defm MVE_VABAVs8 : MVE_VABAV_m<MVE_v16s8>;
  562. defm MVE_VABAVs16 : MVE_VABAV_m<MVE_v8s16>;
  563. defm MVE_VABAVs32 : MVE_VABAV_m<MVE_v4s32>;
  564. defm MVE_VABAVu8 : MVE_VABAV_m<MVE_v16u8>;
  565. defm MVE_VABAVu16 : MVE_VABAV_m<MVE_v8u16>;
  566. defm MVE_VABAVu32 : MVE_VABAV_m<MVE_v4u32>;
  567. class MVE_VADDV<string iname, string suffix, dag iops, string cstr,
  568. bit A, bit U, bits<2> size, list<dag> pattern=[]>
  569. : MVE_rDest<(outs tGPREven:$Rda), iops, NoItinerary,
  570. iname, suffix, "$Rda, $Qm", cstr, size, pattern> {
  571. bits<3> Qm;
  572. bits<4> Rda;
  573. let Inst{28} = U;
  574. let Inst{22-20} = 0b111;
  575. let Inst{19-18} = size{1-0};
  576. let Inst{17-16} = 0b01;
  577. let Inst{15-13} = Rda{3-1};
  578. let Inst{12} = 0b0;
  579. let Inst{8-6} = 0b100;
  580. let Inst{5} = A;
  581. let Inst{3-1} = Qm{2-0};
  582. let Inst{0} = 0b0;
  583. let horizontalReduction = 1;
  584. let validForTailPredication = 1;
  585. }
  586. def SDTVecReduceP : SDTypeProfile<1, 2, [ // VADDLVp
  587. SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2>
  588. ]>;
  589. def ARMVADDVs : SDNode<"ARMISD::VADDVs", SDTVecReduce>;
  590. def ARMVADDVu : SDNode<"ARMISD::VADDVu", SDTVecReduce>;
  591. def ARMVADDVps : SDNode<"ARMISD::VADDVps", SDTVecReduceP>;
  592. def ARMVADDVpu : SDNode<"ARMISD::VADDVpu", SDTVecReduceP>;
  593. multiclass MVE_VADDV_A<MVEVectorVTInfo VTI> {
  594. def acc : MVE_VADDV<"vaddva", VTI.Suffix,
  595. (ins tGPREven:$Rda_src, MQPR:$Qm), "$Rda = $Rda_src",
  596. 0b1, VTI.Unsigned, VTI.Size>;
  597. def no_acc : MVE_VADDV<"vaddv", VTI.Suffix,
  598. (ins MQPR:$Qm), "",
  599. 0b0, VTI.Unsigned, VTI.Size>;
  600. defvar InstA = !cast<Instruction>(NAME # "acc");
  601. defvar InstN = !cast<Instruction>(NAME # "no_acc");
  602. let Predicates = [HasMVEInt] in {
  603. if VTI.Unsigned then {
  604. def : Pat<(i32 (vecreduce_add (VTI.Vec MQPR:$vec))),
  605. (i32 (InstN $vec))>;
  606. def : Pat<(i32 (vecreduce_add (VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  607. (VTI.Vec MQPR:$vec),
  608. (VTI.Vec ARMimmAllZerosV))))),
  609. (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
  610. def : Pat<(i32 (ARMVADDVu (VTI.Vec MQPR:$vec))),
  611. (i32 (InstN $vec))>;
  612. def : Pat<(i32 (ARMVADDVpu (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
  613. (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
  614. def : Pat<(i32 (add (i32 (vecreduce_add (VTI.Vec MQPR:$vec))),
  615. (i32 tGPREven:$acc))),
  616. (i32 (InstA $acc, $vec))>;
  617. def : Pat<(i32 (add (i32 (vecreduce_add (VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  618. (VTI.Vec MQPR:$vec),
  619. (VTI.Vec ARMimmAllZerosV))))),
  620. (i32 tGPREven:$acc))),
  621. (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
  622. def : Pat<(i32 (add (i32 (ARMVADDVu (VTI.Vec MQPR:$vec))),
  623. (i32 tGPREven:$acc))),
  624. (i32 (InstA $acc, $vec))>;
  625. def : Pat<(i32 (add (i32 (ARMVADDVpu (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
  626. (i32 tGPREven:$acc))),
  627. (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
  628. } else {
  629. def : Pat<(i32 (ARMVADDVs (VTI.Vec MQPR:$vec))),
  630. (i32 (InstN $vec))>;
  631. def : Pat<(i32 (add (i32 (ARMVADDVs (VTI.Vec MQPR:$vec))),
  632. (i32 tGPREven:$acc))),
  633. (i32 (InstA $acc, $vec))>;
  634. def : Pat<(i32 (ARMVADDVps (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
  635. (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
  636. def : Pat<(i32 (add (i32 (ARMVADDVps (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
  637. (i32 tGPREven:$acc))),
  638. (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
  639. }
  640. def : Pat<(i32 (int_arm_mve_addv_predicated (VTI.Vec MQPR:$vec),
  641. (i32 VTI.Unsigned),
  642. (VTI.Pred VCCR:$pred))),
  643. (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
  644. def : Pat<(i32 (add (int_arm_mve_addv_predicated (VTI.Vec MQPR:$vec),
  645. (i32 VTI.Unsigned),
  646. (VTI.Pred VCCR:$pred)),
  647. (i32 tGPREven:$acc))),
  648. (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
  649. }
  650. }
  651. defm MVE_VADDVs8 : MVE_VADDV_A<MVE_v16s8>;
  652. defm MVE_VADDVs16 : MVE_VADDV_A<MVE_v8s16>;
  653. defm MVE_VADDVs32 : MVE_VADDV_A<MVE_v4s32>;
  654. defm MVE_VADDVu8 : MVE_VADDV_A<MVE_v16u8>;
  655. defm MVE_VADDVu16 : MVE_VADDV_A<MVE_v8u16>;
  656. defm MVE_VADDVu32 : MVE_VADDV_A<MVE_v4u32>;
  657. class MVE_VADDLV<string iname, string suffix, dag iops, string cstr,
  658. bit A, bit U, list<dag> pattern=[]>
  659. : MVE_rDest<(outs tGPREven:$RdaLo, tGPROdd:$RdaHi), iops, NoItinerary, iname,
  660. suffix, "$RdaLo, $RdaHi, $Qm", cstr, 0b10, pattern> {
  661. bits<3> Qm;
  662. bits<4> RdaLo;
  663. bits<4> RdaHi;
  664. let Inst{28} = U;
  665. let Inst{22-20} = RdaHi{3-1};
  666. let Inst{19-18} = 0b10;
  667. let Inst{17-16} = 0b01;
  668. let Inst{15-13} = RdaLo{3-1};
  669. let Inst{12} = 0b0;
  670. let Inst{8-6} = 0b100;
  671. let Inst{5} = A;
  672. let Inst{3-1} = Qm{2-0};
  673. let Inst{0} = 0b0;
  674. let horizontalReduction = 1;
  675. }
  676. def SDTVecReduceL : SDTypeProfile<2, 1, [ // VADDLV
  677. SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>
  678. ]>;
  679. def SDTVecReduceLA : SDTypeProfile<2, 3, [ // VADDLVA
  680. SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
  681. SDTCisVec<4>
  682. ]>;
  683. def SDTVecReduceLP : SDTypeProfile<2, 2, [ // VADDLVp
  684. SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<2>
  685. ]>;
  686. def SDTVecReduceLPA : SDTypeProfile<2, 4, [ // VADDLVAp
  687. SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
  688. SDTCisVec<4>, SDTCisVec<5>
  689. ]>;
  690. multiclass MVE_VADDLV_A<MVEVectorVTInfo VTI> {
  691. def acc : MVE_VADDLV<"vaddlva", VTI.Suffix,
  692. (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, MQPR:$Qm),
  693. "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
  694. 0b1, VTI.Unsigned>;
  695. def no_acc : MVE_VADDLV<"vaddlv", VTI.Suffix,
  696. (ins MQPR:$Qm), "",
  697. 0b0, VTI.Unsigned>;
  698. defvar InstA = !cast<Instruction>(NAME # "acc");
  699. defvar InstN = !cast<Instruction>(NAME # "no_acc");
  700. defvar letter = VTI.SuffixLetter;
  701. defvar ARMVADDLV = SDNode<"ARMISD::VADDLV" # letter, SDTVecReduceL>;
  702. defvar ARMVADDLVA = SDNode<"ARMISD::VADDLVA" # letter, SDTVecReduceLA>;
  703. defvar ARMVADDLVp = SDNode<"ARMISD::VADDLVp" # letter, SDTVecReduceLP>;
  704. defvar ARMVADDLVAp = SDNode<"ARMISD::VADDLVAp" # letter, SDTVecReduceLPA>;
  705. let Predicates = [HasMVEInt] in {
  706. def : Pat<(ARMVADDLV (v4i32 MQPR:$vec)),
  707. (InstN (v4i32 MQPR:$vec))>;
  708. def : Pat<(ARMVADDLVA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec)),
  709. (InstA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec))>;
  710. def : Pat<(ARMVADDLVp (v4i32 MQPR:$vec), (VTI.Pred VCCR:$pred)),
  711. (InstN (v4i32 MQPR:$vec), ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg)>;
  712. def : Pat<(ARMVADDLVAp tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec),
  713. (VTI.Pred VCCR:$pred)),
  714. (InstA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec),
  715. ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg)>;
  716. }
  717. }
  718. defm MVE_VADDLVs32 : MVE_VADDLV_A<MVE_v4s32>;
  719. defm MVE_VADDLVu32 : MVE_VADDLV_A<MVE_v4u32>;
  720. class MVE_VMINMAXNMV<string iname, string suffix, bit sz,
  721. bit bit_17, bit bit_7, list<dag> pattern=[]>
  722. : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm),
  723. NoItinerary, iname, suffix, "$RdaSrc, $Qm",
  724. "$RdaDest = $RdaSrc", !if(sz, 0b01, 0b10), pattern> {
  725. bits<3> Qm;
  726. bits<4> RdaDest;
  727. let Inst{28} = sz;
  728. let Inst{22-20} = 0b110;
  729. let Inst{19-18} = 0b11;
  730. let Inst{17} = bit_17;
  731. let Inst{16} = 0b0;
  732. let Inst{15-12} = RdaDest{3-0};
  733. let Inst{8} = 0b1;
  734. let Inst{7} = bit_7;
  735. let Inst{6-5} = 0b00;
  736. let Inst{3-1} = Qm{2-0};
  737. let Inst{0} = 0b0;
  738. let horizontalReduction = 1;
  739. let Predicates = [HasMVEFloat];
  740. let hasSideEffects = 0;
  741. }
  742. multiclass MVE_VMINMAXNMV_p<string iname, bit notAbs, bit isMin,
  743. MVEVectorVTInfo VTI, string intrBaseName,
  744. ValueType Scalar, RegisterClass ScalarReg> {
  745. def "": MVE_VMINMAXNMV<iname, VTI.Suffix, VTI.Size{0}, notAbs, isMin>;
  746. defvar Inst = !cast<Instruction>(NAME);
  747. defvar unpred_intr = !cast<Intrinsic>(intrBaseName);
  748. defvar pred_intr = !cast<Intrinsic>(intrBaseName#"_predicated");
  749. let Predicates = [HasMVEFloat] in {
  750. def : Pat<(Scalar (unpred_intr (Scalar ScalarReg:$prev),
  751. (VTI.Vec MQPR:$vec))),
  752. (COPY_TO_REGCLASS (Inst (COPY_TO_REGCLASS ScalarReg:$prev, rGPR),
  753. (VTI.Vec MQPR:$vec)),
  754. ScalarReg)>;
  755. def : Pat<(Scalar (pred_intr (Scalar ScalarReg:$prev),
  756. (VTI.Vec MQPR:$vec),
  757. (VTI.Pred VCCR:$pred))),
  758. (COPY_TO_REGCLASS (Inst (COPY_TO_REGCLASS ScalarReg:$prev, rGPR),
  759. (VTI.Vec MQPR:$vec),
  760. ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg),
  761. ScalarReg)>;
  762. }
  763. }
  764. multiclass MVE_VMINMAXNMV_fty<string iname, bit notAbs, bit isMin,
  765. string intrBase> {
  766. defm f32 : MVE_VMINMAXNMV_p<iname, notAbs, isMin, MVE_v4f32, intrBase,
  767. f32, SPR>;
  768. defm f16 : MVE_VMINMAXNMV_p<iname, notAbs, isMin, MVE_v8f16, intrBase,
  769. f16, HPR>;
  770. }
  771. defm MVE_VMINNMV : MVE_VMINMAXNMV_fty<"vminnmv", 1, 1, "int_arm_mve_minnmv">;
  772. defm MVE_VMAXNMV : MVE_VMINMAXNMV_fty<"vmaxnmv", 1, 0, "int_arm_mve_maxnmv">;
  773. defm MVE_VMINNMAV: MVE_VMINMAXNMV_fty<"vminnmav", 0, 1, "int_arm_mve_minnmav">;
  774. defm MVE_VMAXNMAV: MVE_VMINMAXNMV_fty<"vmaxnmav", 0, 0, "int_arm_mve_maxnmav">;
  775. class MVE_VMINMAXV<string iname, string suffix, bit U, bits<2> size,
  776. bit bit_17, bit bit_7, list<dag> pattern=[]>
  777. : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm), NoItinerary,
  778. iname, suffix, "$RdaSrc, $Qm", "$RdaDest = $RdaSrc", size, pattern> {
  779. bits<3> Qm;
  780. bits<4> RdaDest;
  781. let Inst{28} = U;
  782. let Inst{22-20} = 0b110;
  783. let Inst{19-18} = size{1-0};
  784. let Inst{17} = bit_17;
  785. let Inst{16} = 0b0;
  786. let Inst{15-12} = RdaDest{3-0};
  787. let Inst{8} = 0b1;
  788. let Inst{7} = bit_7;
  789. let Inst{6-5} = 0b00;
  790. let Inst{3-1} = Qm{2-0};
  791. let Inst{0} = 0b0;
  792. let horizontalReduction = 1;
  793. }
  794. multiclass MVE_VMINMAXV_p<string iname, bit notAbs, bit isMin,
  795. MVEVectorVTInfo VTI, string intrBaseName> {
  796. def "": MVE_VMINMAXV<iname, VTI.Suffix, VTI.Unsigned, VTI.Size,
  797. notAbs, isMin>;
  798. defvar Inst = !cast<Instruction>(NAME);
  799. defvar unpred_intr = !cast<Intrinsic>(intrBaseName);
  800. defvar pred_intr = !cast<Intrinsic>(intrBaseName#"_predicated");
  801. defvar base_args = (? (i32 rGPR:$prev), (VTI.Vec MQPR:$vec));
  802. defvar args = !if(notAbs, !con(base_args, (? (i32 VTI.Unsigned))),
  803. base_args);
  804. let Predicates = [HasMVEInt] in {
  805. def : Pat<(i32 !con(args, (unpred_intr))),
  806. (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)))>;
  807. def : Pat<(i32 !con(args, (pred_intr (VTI.Pred VCCR:$pred)))),
  808. (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec),
  809. ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>;
  810. }
  811. }
  812. multiclass MVE_VMINMAXV_ty<string iname, bit isMin, string intrBaseName> {
  813. defm s8 : MVE_VMINMAXV_p<iname, 1, isMin, MVE_v16s8, intrBaseName>;
  814. defm s16: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v8s16, intrBaseName>;
  815. defm s32: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v4s32, intrBaseName>;
  816. defm u8 : MVE_VMINMAXV_p<iname, 1, isMin, MVE_v16u8, intrBaseName>;
  817. defm u16: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v8u16, intrBaseName>;
  818. defm u32: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v4u32, intrBaseName>;
  819. }
  820. def SDTVecReduceR : SDTypeProfile<1, 2, [ // Reduction of an integer and vector into an integer
  821. SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>
  822. ]>;
  823. def ARMVMINVu : SDNode<"ARMISD::VMINVu", SDTVecReduceR>;
  824. def ARMVMINVs : SDNode<"ARMISD::VMINVs", SDTVecReduceR>;
  825. def ARMVMAXVu : SDNode<"ARMISD::VMAXVu", SDTVecReduceR>;
  826. def ARMVMAXVs : SDNode<"ARMISD::VMAXVs", SDTVecReduceR>;
  827. defm MVE_VMINV : MVE_VMINMAXV_ty<"vminv", 1, "int_arm_mve_minv">;
  828. defm MVE_VMAXV : MVE_VMINMAXV_ty<"vmaxv", 0, "int_arm_mve_maxv">;
  829. let Predicates = [HasMVEInt] in {
  830. def : Pat<(i32 (vecreduce_smax (v16i8 MQPR:$src))),
  831. (i32 (MVE_VMAXVs8 (t2MVNi (i32 127)), $src))>;
  832. def : Pat<(i32 (vecreduce_smax (v8i16 MQPR:$src))),
  833. (i32 (MVE_VMAXVs16 (t2MOVi32imm (i32 -32768)), $src))>;
  834. def : Pat<(i32 (vecreduce_smax (v4i32 MQPR:$src))),
  835. (i32 (MVE_VMAXVs32 (t2MOVi (i32 -2147483648)), $src))>;
  836. def : Pat<(i32 (vecreduce_umax (v16i8 MQPR:$src))),
  837. (i32 (MVE_VMAXVu8 (t2MOVi (i32 0)), $src))>;
  838. def : Pat<(i32 (vecreduce_umax (v8i16 MQPR:$src))),
  839. (i32 (MVE_VMAXVu16 (t2MOVi (i32 0)), $src))>;
  840. def : Pat<(i32 (vecreduce_umax (v4i32 MQPR:$src))),
  841. (i32 (MVE_VMAXVu32 (t2MOVi (i32 0)), $src))>;
  842. def : Pat<(i32 (vecreduce_smin (v16i8 MQPR:$src))),
  843. (i32 (MVE_VMINVs8 (t2MOVi (i32 127)), $src))>;
  844. def : Pat<(i32 (vecreduce_smin (v8i16 MQPR:$src))),
  845. (i32 (MVE_VMINVs16 (t2MOVi16 (i32 32767)), $src))>;
  846. def : Pat<(i32 (vecreduce_smin (v4i32 MQPR:$src))),
  847. (i32 (MVE_VMINVs32 (t2MVNi (i32 -2147483648)), $src))>;
  848. def : Pat<(i32 (vecreduce_umin (v16i8 MQPR:$src))),
  849. (i32 (MVE_VMINVu8 (t2MOVi (i32 255)), $src))>;
  850. def : Pat<(i32 (vecreduce_umin (v8i16 MQPR:$src))),
  851. (i32 (MVE_VMINVu16 (t2MOVi16 (i32 65535)), $src))>;
  852. def : Pat<(i32 (vecreduce_umin (v4i32 MQPR:$src))),
  853. (i32 (MVE_VMINVu32 (t2MOVi (i32 4294967295)), $src))>;
  854. def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v16i8 MQPR:$src))),
  855. (i32 (MVE_VMINVu8 $x, $src))>;
  856. def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v8i16 MQPR:$src))),
  857. (i32 (MVE_VMINVu16 $x, $src))>;
  858. def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v4i32 MQPR:$src))),
  859. (i32 (MVE_VMINVu32 $x, $src))>;
  860. def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v16i8 MQPR:$src))),
  861. (i32 (MVE_VMINVs8 $x, $src))>;
  862. def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v8i16 MQPR:$src))),
  863. (i32 (MVE_VMINVs16 $x, $src))>;
  864. def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v4i32 MQPR:$src))),
  865. (i32 (MVE_VMINVs32 $x, $src))>;
  866. def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v16i8 MQPR:$src))),
  867. (i32 (MVE_VMAXVu8 $x, $src))>;
  868. def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v8i16 MQPR:$src))),
  869. (i32 (MVE_VMAXVu16 $x, $src))>;
  870. def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v4i32 MQPR:$src))),
  871. (i32 (MVE_VMAXVu32 $x, $src))>;
  872. def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v16i8 MQPR:$src))),
  873. (i32 (MVE_VMAXVs8 $x, $src))>;
  874. def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v8i16 MQPR:$src))),
  875. (i32 (MVE_VMAXVs16 $x, $src))>;
  876. def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v4i32 MQPR:$src))),
  877. (i32 (MVE_VMAXVs32 $x, $src))>;
  878. }
  879. multiclass MVE_VMINMAXAV_ty<string iname, bit isMin, string intrBaseName> {
  880. defm s8 : MVE_VMINMAXV_p<iname, 0, isMin, MVE_v16s8, intrBaseName>;
  881. defm s16: MVE_VMINMAXV_p<iname, 0, isMin, MVE_v8s16, intrBaseName>;
  882. defm s32: MVE_VMINMAXV_p<iname, 0, isMin, MVE_v4s32, intrBaseName>;
  883. }
  884. defm MVE_VMINAV : MVE_VMINMAXAV_ty<"vminav", 1, "int_arm_mve_minav">;
  885. defm MVE_VMAXAV : MVE_VMINMAXAV_ty<"vmaxav", 0, "int_arm_mve_maxav">;
  886. class MVE_VMLAMLSDAV<string iname, string suffix, dag iops, string cstr,
  887. bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
  888. bits<2> vecsize>
  889. : MVE_rDest<(outs tGPREven:$RdaDest), iops, NoItinerary, iname, suffix,
  890. "$RdaDest, $Qn, $Qm", cstr, vecsize, []> {
  891. bits<4> RdaDest;
  892. bits<3> Qm;
  893. bits<3> Qn;
  894. let Inst{28} = bit_28;
  895. let Inst{22-20} = 0b111;
  896. let Inst{19-17} = Qn{2-0};
  897. let Inst{16} = sz;
  898. let Inst{15-13} = RdaDest{3-1};
  899. let Inst{12} = X;
  900. let Inst{8} = bit_8;
  901. let Inst{7-6} = 0b00;
  902. let Inst{5} = A;
  903. let Inst{3-1} = Qm{2-0};
  904. let Inst{0} = bit_0;
  905. let horizontalReduction = 1;
  906. // Allow tail predication for non-exchanging versions. As this is also a
  907. // horizontalReduction, ARMLowOverheadLoops will also have to check that
  908. // the vector operands contain zeros in their false lanes for the instruction
  909. // to be properly valid.
  910. let validForTailPredication = !eq(X, 0);
  911. }
  912. multiclass MVE_VMLAMLSDAV_A<string iname, string x, MVEVectorVTInfo VTI,
  913. bit sz, bit bit_28, bit X, bit bit_8, bit bit_0> {
  914. def ""#x#VTI.Suffix : MVE_VMLAMLSDAV<iname # x, VTI.Suffix,
  915. (ins MQPR:$Qn, MQPR:$Qm), "",
  916. sz, bit_28, 0b0, X, bit_8, bit_0, VTI.Size>;
  917. def "a"#x#VTI.Suffix : MVE_VMLAMLSDAV<iname # "a" # x, VTI.Suffix,
  918. (ins tGPREven:$RdaSrc, MQPR:$Qn, MQPR:$Qm),
  919. "$RdaDest = $RdaSrc",
  920. sz, bit_28, 0b1, X, bit_8, bit_0, VTI.Size>;
  921. let Predicates = [HasMVEInt] in {
  922. def : Pat<(i32 (int_arm_mve_vmldava
  923. (i32 VTI.Unsigned),
  924. (i32 bit_0) /* subtract */,
  925. (i32 X) /* exchange */,
  926. (i32 0) /* accumulator */,
  927. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  928. (i32 (!cast<Instruction>(NAME # x # VTI.Suffix)
  929. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
  930. def : Pat<(i32 (int_arm_mve_vmldava_predicated
  931. (i32 VTI.Unsigned),
  932. (i32 bit_0) /* subtract */,
  933. (i32 X) /* exchange */,
  934. (i32 0) /* accumulator */,
  935. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  936. (VTI.Pred VCCR:$mask))),
  937. (i32 (!cast<Instruction>(NAME # x # VTI.Suffix)
  938. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  939. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  940. def : Pat<(i32 (int_arm_mve_vmldava
  941. (i32 VTI.Unsigned),
  942. (i32 bit_0) /* subtract */,
  943. (i32 X) /* exchange */,
  944. (i32 tGPREven:$RdaSrc),
  945. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  946. (i32 (!cast<Instruction>(NAME # "a" # x # VTI.Suffix)
  947. (i32 tGPREven:$RdaSrc),
  948. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
  949. def : Pat<(i32 (int_arm_mve_vmldava_predicated
  950. (i32 VTI.Unsigned),
  951. (i32 bit_0) /* subtract */,
  952. (i32 X) /* exchange */,
  953. (i32 tGPREven:$RdaSrc),
  954. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  955. (VTI.Pred VCCR:$mask))),
  956. (i32 (!cast<Instruction>(NAME # "a" # x # VTI.Suffix)
  957. (i32 tGPREven:$RdaSrc),
  958. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  959. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  960. }
  961. }
  962. multiclass MVE_VMLAMLSDAV_AX<string iname, MVEVectorVTInfo VTI, bit sz,
  963. bit bit_28, bit bit_8, bit bit_0> {
  964. defm "" : MVE_VMLAMLSDAV_A<iname, "", VTI, sz, bit_28,
  965. 0b0, bit_8, bit_0>;
  966. defm "" : MVE_VMLAMLSDAV_A<iname, "x", VTI, sz, bit_28,
  967. 0b1, bit_8, bit_0>;
  968. }
  969. multiclass MVE_VMLADAV_multi<MVEVectorVTInfo SVTI, MVEVectorVTInfo UVTI,
  970. bit sz, bit bit_8> {
  971. defm "" : MVE_VMLAMLSDAV_AX<"vmladav", SVTI,
  972. sz, 0b0, bit_8, 0b0>;
  973. defm "" : MVE_VMLAMLSDAV_A<"vmladav", "", UVTI,
  974. sz, 0b1, 0b0, bit_8, 0b0>;
  975. }
  976. multiclass MVE_VMLSDAV_multi<MVEVectorVTInfo VTI, bit sz, bit bit_28> {
  977. defm "" : MVE_VMLAMLSDAV_AX<"vmlsdav", VTI,
  978. sz, bit_28, 0b0, 0b1>;
  979. }
  980. defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v16s8, MVE_v16u8, 0b0, 0b1>;
  981. defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v8s16, MVE_v8u16, 0b0, 0b0>;
  982. defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v4s32, MVE_v4u32, 0b1, 0b0>;
  983. defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v16s8, 0b0, 0b1>;
  984. defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v8s16, 0b0, 0b0>;
  985. defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v4s32, 0b1, 0b0>;
  986. def SDTVecReduce2 : SDTypeProfile<1, 2, [ // VMLAV
  987. SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2>
  988. ]>;
  989. def SDTVecReduce2L : SDTypeProfile<2, 2, [ // VMLALV
  990. SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<3>
  991. ]>;
  992. def SDTVecReduce2LA : SDTypeProfile<2, 4, [ // VMLALVA
  993. SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
  994. SDTCisVec<4>, SDTCisVec<5>
  995. ]>;
  996. def SDTVecReduce2P : SDTypeProfile<1, 3, [ // VMLAV
  997. SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisVec<3>
  998. ]>;
  999. def SDTVecReduce2LP : SDTypeProfile<2, 3, [ // VMLALV
  1000. SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<3>, SDTCisVec<4>
  1001. ]>;
  1002. def SDTVecReduce2LAP : SDTypeProfile<2, 5, [ // VMLALVA
  1003. SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
  1004. SDTCisVec<4>, SDTCisVec<5>, SDTCisVec<6>
  1005. ]>;
  1006. def ARMVMLAVs : SDNode<"ARMISD::VMLAVs", SDTVecReduce2>;
  1007. def ARMVMLAVu : SDNode<"ARMISD::VMLAVu", SDTVecReduce2>;
  1008. def ARMVMLALVs : SDNode<"ARMISD::VMLALVs", SDTVecReduce2L>;
  1009. def ARMVMLALVu : SDNode<"ARMISD::VMLALVu", SDTVecReduce2L>;
  1010. def ARMVMLALVAs : SDNode<"ARMISD::VMLALVAs", SDTVecReduce2LA>;
  1011. def ARMVMLALVAu : SDNode<"ARMISD::VMLALVAu", SDTVecReduce2LA>;
  1012. def ARMVMLAVps : SDNode<"ARMISD::VMLAVps", SDTVecReduce2P>;
  1013. def ARMVMLAVpu : SDNode<"ARMISD::VMLAVpu", SDTVecReduce2P>;
  1014. def ARMVMLALVps : SDNode<"ARMISD::VMLALVps", SDTVecReduce2LP>;
  1015. def ARMVMLALVpu : SDNode<"ARMISD::VMLALVpu", SDTVecReduce2LP>;
  1016. def ARMVMLALVAps : SDNode<"ARMISD::VMLALVAps", SDTVecReduce2LAP>;
  1017. def ARMVMLALVApu : SDNode<"ARMISD::VMLALVApu", SDTVecReduce2LAP>;
  1018. let Predicates = [HasMVEInt] in {
  1019. def : Pat<(i32 (vecreduce_add (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)))),
  1020. (i32 (MVE_VMLADAVu32 $src1, $src2))>;
  1021. def : Pat<(i32 (vecreduce_add (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)))),
  1022. (i32 (MVE_VMLADAVu16 $src1, $src2))>;
  1023. def : Pat<(i32 (ARMVMLAVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
  1024. (i32 (MVE_VMLADAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
  1025. def : Pat<(i32 (ARMVMLAVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
  1026. (i32 (MVE_VMLADAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
  1027. def : Pat<(i32 (vecreduce_add (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)))),
  1028. (i32 (MVE_VMLADAVu8 $src1, $src2))>;
  1029. def : Pat<(i32 (ARMVMLAVs (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
  1030. (i32 (MVE_VMLADAVs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
  1031. def : Pat<(i32 (ARMVMLAVu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
  1032. (i32 (MVE_VMLADAVu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
  1033. def : Pat<(i32 (add (i32 (vecreduce_add (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)))),
  1034. (i32 tGPREven:$src3))),
  1035. (i32 (MVE_VMLADAVau32 $src3, $src1, $src2))>;
  1036. def : Pat<(i32 (add (i32 (vecreduce_add (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)))),
  1037. (i32 tGPREven:$src3))),
  1038. (i32 (MVE_VMLADAVau16 $src3, $src1, $src2))>;
  1039. def : Pat<(i32 (add (ARMVMLAVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), tGPREven:$Rd)),
  1040. (i32 (MVE_VMLADAVas16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
  1041. def : Pat<(i32 (add (ARMVMLAVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), tGPREven:$Rd)),
  1042. (i32 (MVE_VMLADAVau16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
  1043. def : Pat<(i32 (add (i32 (vecreduce_add (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)))),
  1044. (i32 tGPREven:$src3))),
  1045. (i32 (MVE_VMLADAVau8 $src3, $src1, $src2))>;
  1046. def : Pat<(i32 (add (ARMVMLAVs (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)), tGPREven:$Rd)),
  1047. (i32 (MVE_VMLADAVas8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
  1048. def : Pat<(i32 (add (ARMVMLAVu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)), tGPREven:$Rd)),
  1049. (i32 (MVE_VMLADAVau8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
  1050. // Predicated
  1051. def : Pat<(i32 (vecreduce_add (vselect (v4i1 VCCR:$pred),
  1052. (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)),
  1053. (v4i32 ARMimmAllZerosV)))),
  1054. (i32 (MVE_VMLADAVu32 $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
  1055. def : Pat<(i32 (vecreduce_add (vselect (v8i1 VCCR:$pred),
  1056. (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)),
  1057. (v8i16 ARMimmAllZerosV)))),
  1058. (i32 (MVE_VMLADAVu16 $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
  1059. def : Pat<(i32 (ARMVMLAVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred))),
  1060. (i32 (MVE_VMLADAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1061. def : Pat<(i32 (ARMVMLAVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred))),
  1062. (i32 (MVE_VMLADAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1063. def : Pat<(i32 (vecreduce_add (vselect (v16i1 VCCR:$pred),
  1064. (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)),
  1065. (v16i8 ARMimmAllZerosV)))),
  1066. (i32 (MVE_VMLADAVu8 $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
  1067. def : Pat<(i32 (ARMVMLAVps (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred))),
  1068. (i32 (MVE_VMLADAVs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1069. def : Pat<(i32 (ARMVMLAVpu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred))),
  1070. (i32 (MVE_VMLADAVu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1071. def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v4i1 VCCR:$pred),
  1072. (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)),
  1073. (v4i32 ARMimmAllZerosV)))),
  1074. (i32 tGPREven:$src3))),
  1075. (i32 (MVE_VMLADAVau32 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
  1076. def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v8i1 VCCR:$pred),
  1077. (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)),
  1078. (v8i16 ARMimmAllZerosV)))),
  1079. (i32 tGPREven:$src3))),
  1080. (i32 (MVE_VMLADAVau16 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
  1081. def : Pat<(i32 (add (ARMVMLAVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), tGPREven:$Rd)),
  1082. (i32 (MVE_VMLADAVas16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1083. def : Pat<(i32 (add (ARMVMLAVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), tGPREven:$Rd)),
  1084. (i32 (MVE_VMLADAVau16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1085. def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v16i1 VCCR:$pred),
  1086. (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)),
  1087. (v16i8 ARMimmAllZerosV)))),
  1088. (i32 tGPREven:$src3))),
  1089. (i32 (MVE_VMLADAVau8 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
  1090. def : Pat<(i32 (add (ARMVMLAVps (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred)), tGPREven:$Rd)),
  1091. (i32 (MVE_VMLADAVas8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1092. def : Pat<(i32 (add (ARMVMLAVpu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred)), tGPREven:$Rd)),
  1093. (i32 (MVE_VMLADAVau8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
  1094. }
  1095. // vmlav aliases vmladav
  1096. foreach acc = ["", "a"] in {
  1097. foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32"] in {
  1098. def : MVEInstAlias<"vmlav"#acc#"${vp}."#suffix#"\t$RdaDest, $Qn, $Qm",
  1099. (!cast<Instruction>("MVE_VMLADAV"#acc#suffix)
  1100. tGPREven:$RdaDest, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  1101. }
  1102. }
  1103. // Base class for VMLALDAV and VMLSLDAV, VRMLALDAVH, VRMLSLDAVH
  1104. class MVE_VMLALDAVBase<string iname, string suffix, dag iops, string cstr,
  1105. bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
  1106. bits<2> vecsize, list<dag> pattern=[]>
  1107. : MVE_rDest<(outs tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest), iops, NoItinerary,
  1108. iname, suffix, "$RdaLoDest, $RdaHiDest, $Qn, $Qm", cstr, vecsize, pattern> {
  1109. bits<4> RdaLoDest;
  1110. bits<4> RdaHiDest;
  1111. bits<3> Qm;
  1112. bits<3> Qn;
  1113. let Inst{28} = bit_28;
  1114. let Inst{22-20} = RdaHiDest{3-1};
  1115. let Inst{19-17} = Qn{2-0};
  1116. let Inst{16} = sz;
  1117. let Inst{15-13} = RdaLoDest{3-1};
  1118. let Inst{12} = X;
  1119. let Inst{8} = bit_8;
  1120. let Inst{7-6} = 0b00;
  1121. let Inst{5} = A;
  1122. let Inst{3-1} = Qm{2-0};
  1123. let Inst{0} = bit_0;
  1124. let horizontalReduction = 1;
  1125. // Allow tail predication for non-exchanging versions. As this is also a
  1126. // horizontalReduction, ARMLowOverheadLoops will also have to check that
  1127. // the vector operands contain zeros in their false lanes for the instruction
  1128. // to be properly valid.
  1129. let validForTailPredication = !eq(X, 0);
  1130. let hasSideEffects = 0;
  1131. }
  1132. multiclass MVE_VMLALDAVBase_A<string iname, string x, string suffix,
  1133. bit sz, bit bit_28, bit X, bit bit_8, bit bit_0,
  1134. bits<2> vecsize, list<dag> pattern=[]> {
  1135. def ""#x#suffix : MVE_VMLALDAVBase<
  1136. iname # x, suffix, (ins MQPR:$Qn, MQPR:$Qm), "",
  1137. sz, bit_28, 0b0, X, bit_8, bit_0, vecsize, pattern>;
  1138. def "a"#x#suffix : MVE_VMLALDAVBase<
  1139. iname # "a" # x, suffix,
  1140. (ins tGPREven:$RdaLoSrc, tGPROdd:$RdaHiSrc, MQPR:$Qn, MQPR:$Qm),
  1141. "$RdaLoDest = $RdaLoSrc,$RdaHiDest = $RdaHiSrc",
  1142. sz, bit_28, 0b1, X, bit_8, bit_0, vecsize, pattern>;
  1143. }
  1144. multiclass MVE_VMLALDAVBase_AX<string iname, string suffix, bit sz, bit bit_28,
  1145. bit bit_8, bit bit_0, bits<2> vecsize, list<dag> pattern=[]> {
  1146. defm "" : MVE_VMLALDAVBase_A<iname, "", suffix, sz,
  1147. bit_28, 0b0, bit_8, bit_0, vecsize, pattern>;
  1148. defm "" : MVE_VMLALDAVBase_A<iname, "x", suffix, sz,
  1149. bit_28, 0b1, bit_8, bit_0, vecsize, pattern>;
  1150. }
  1151. multiclass MVE_VRMLALDAVH_multi<MVEVectorVTInfo VTI, list<dag> pattern=[]> {
  1152. defm "" : MVE_VMLALDAVBase_AX<"vrmlaldavh", "s"#VTI.BitsSuffix,
  1153. 0b0, 0b0, 0b1, 0b0, VTI.Size, pattern>;
  1154. defm "" : MVE_VMLALDAVBase_A<"vrmlaldavh", "", "u"#VTI.BitsSuffix,
  1155. 0b0, 0b1, 0b0, 0b1, 0b0, VTI.Size, pattern>;
  1156. }
  1157. defm MVE_VRMLALDAVH : MVE_VRMLALDAVH_multi<MVE_v4i32>;
  1158. // vrmlalvh aliases for vrmlaldavh
  1159. def : MVEInstAlias<"vrmlalvh${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
  1160. (MVE_VRMLALDAVHs32
  1161. tGPREven:$RdaLo, tGPROdd:$RdaHi,
  1162. MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  1163. def : MVEInstAlias<"vrmlalvha${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
  1164. (MVE_VRMLALDAVHas32
  1165. tGPREven:$RdaLo, tGPROdd:$RdaHi,
  1166. MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  1167. def : MVEInstAlias<"vrmlalvh${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
  1168. (MVE_VRMLALDAVHu32
  1169. tGPREven:$RdaLo, tGPROdd:$RdaHi,
  1170. MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  1171. def : MVEInstAlias<"vrmlalvha${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
  1172. (MVE_VRMLALDAVHau32
  1173. tGPREven:$RdaLo, tGPROdd:$RdaHi,
  1174. MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  1175. multiclass MVE_VMLALDAV_multi<MVEVectorVTInfo VTI, list<dag> pattern=[]> {
  1176. defm "" : MVE_VMLALDAVBase_AX<"vmlaldav", "s"#VTI.BitsSuffix,
  1177. VTI.Size{1}, 0b0, 0b0, 0b0, VTI.Size, pattern>;
  1178. defm "" : MVE_VMLALDAVBase_A<"vmlaldav", "", "u"#VTI.BitsSuffix,
  1179. VTI.Size{1}, 0b1, 0b0, 0b0, 0b0, VTI.Size, pattern>;
  1180. }
  1181. defm MVE_VMLALDAV : MVE_VMLALDAV_multi<MVE_v8i16>;
  1182. defm MVE_VMLALDAV : MVE_VMLALDAV_multi<MVE_v4i32>;
  1183. let Predicates = [HasMVEInt] in {
  1184. def : Pat<(ARMVMLALVs (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
  1185. (MVE_VMLALDAVs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
  1186. def : Pat<(ARMVMLALVu (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
  1187. (MVE_VMLALDAVu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
  1188. def : Pat<(ARMVMLALVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
  1189. (MVE_VMLALDAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
  1190. def : Pat<(ARMVMLALVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
  1191. (MVE_VMLALDAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
  1192. def : Pat<(ARMVMLALVAs tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
  1193. (MVE_VMLALDAVas32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
  1194. def : Pat<(ARMVMLALVAu tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
  1195. (MVE_VMLALDAVau32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
  1196. def : Pat<(ARMVMLALVAs tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
  1197. (MVE_VMLALDAVas16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
  1198. def : Pat<(ARMVMLALVAu tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
  1199. (MVE_VMLALDAVau16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
  1200. // Predicated
  1201. def : Pat<(ARMVMLALVps (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
  1202. (MVE_VMLALDAVs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1203. def : Pat<(ARMVMLALVpu (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
  1204. (MVE_VMLALDAVu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1205. def : Pat<(ARMVMLALVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
  1206. (MVE_VMLALDAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1207. def : Pat<(ARMVMLALVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
  1208. (MVE_VMLALDAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1209. def : Pat<(ARMVMLALVAps tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
  1210. (MVE_VMLALDAVas32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1211. def : Pat<(ARMVMLALVApu tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
  1212. (MVE_VMLALDAVau32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1213. def : Pat<(ARMVMLALVAps tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
  1214. (MVE_VMLALDAVas16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1215. def : Pat<(ARMVMLALVApu tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
  1216. (MVE_VMLALDAVau16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
  1217. }
  1218. // vmlalv aliases vmlaldav
  1219. foreach acc = ["", "a"] in {
  1220. foreach suffix = ["s16", "s32", "u16", "u32"] in {
  1221. def : MVEInstAlias<"vmlalv" # acc # "${vp}." # suffix #
  1222. "\t$RdaLoDest, $RdaHiDest, $Qn, $Qm",
  1223. (!cast<Instruction>("MVE_VMLALDAV"#acc#suffix)
  1224. tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest,
  1225. MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  1226. }
  1227. }
  1228. multiclass MVE_VMLSLDAV_multi<string iname, string suffix, bit sz,
  1229. bit bit_28, bits<2> vecsize, list<dag> pattern=[]> {
  1230. defm "" : MVE_VMLALDAVBase_AX<iname, suffix, sz, bit_28, 0b0, 0b1, vecsize, pattern>;
  1231. }
  1232. defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s16", 0b0, 0b0, 0b01>;
  1233. defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s32", 0b1, 0b0, 0b10>;
  1234. defm MVE_VRMLSLDAVH : MVE_VMLSLDAV_multi<"vrmlsldavh", "s32", 0b0, 0b1, 0b10>;
  1235. // end of mve_rDest instructions
  1236. // start of mve_comp instructions
  1237. class MVE_comp<InstrItinClass itin, string iname, string suffix,
  1238. string cstr, bits<2> vecsize, list<dag> pattern=[]>
  1239. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), itin, iname, suffix,
  1240. "$Qd, $Qn, $Qm", vpred_r, cstr, vecsize, pattern> {
  1241. bits<4> Qd;
  1242. bits<4> Qn;
  1243. bits<4> Qm;
  1244. let Inst{22} = Qd{3};
  1245. let Inst{19-17} = Qn{2-0};
  1246. let Inst{16} = 0b0;
  1247. let Inst{15-13} = Qd{2-0};
  1248. let Inst{12} = 0b0;
  1249. let Inst{10-9} = 0b11;
  1250. let Inst{7} = Qn{3};
  1251. let Inst{5} = Qm{3};
  1252. let Inst{3-1} = Qm{2-0};
  1253. let Inst{0} = 0b0;
  1254. }
  1255. class MVE_VMINMAXNM<string iname, string suffix, bits<2> sz, bit bit_21,
  1256. list<dag> pattern=[]>
  1257. : MVE_comp<NoItinerary, iname, suffix, "", sz, pattern> {
  1258. let Inst{28} = 0b1;
  1259. let Inst{25-24} = 0b11;
  1260. let Inst{23} = 0b0;
  1261. let Inst{21} = bit_21;
  1262. let Inst{20} = sz{0};
  1263. let Inst{11} = 0b1;
  1264. let Inst{8} = 0b1;
  1265. let Inst{6} = 0b1;
  1266. let Inst{4} = 0b1;
  1267. let Predicates = [HasMVEFloat];
  1268. let validForTailPredication = 1;
  1269. }
  1270. multiclass MVE_VMINMAXNM_m<string iname, bit bit_4, MVEVectorVTInfo VTI, SDNode Op, Intrinsic PredInt> {
  1271. def "" : MVE_VMINMAXNM<iname, VTI.Suffix, VTI.Size, bit_4>;
  1272. let Predicates = [HasMVEFloat] in {
  1273. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 0)), !cast<Instruction>(NAME)>;
  1274. }
  1275. }
  1276. defm MVE_VMAXNMf32 : MVE_VMINMAXNM_m<"vmaxnm", 0b0, MVE_v4f32, fmaxnum, int_arm_mve_max_predicated>;
  1277. defm MVE_VMAXNMf16 : MVE_VMINMAXNM_m<"vmaxnm", 0b0, MVE_v8f16, fmaxnum, int_arm_mve_max_predicated>;
  1278. defm MVE_VMINNMf32 : MVE_VMINMAXNM_m<"vminnm", 0b1, MVE_v4f32, fminnum, int_arm_mve_min_predicated>;
  1279. defm MVE_VMINNMf16 : MVE_VMINMAXNM_m<"vminnm", 0b1, MVE_v8f16, fminnum, int_arm_mve_min_predicated>;
  1280. class MVE_VMINMAX<string iname, string suffix, bit U, bits<2> size,
  1281. bit bit_4, list<dag> pattern=[]>
  1282. : MVE_comp<NoItinerary, iname, suffix, "", size, pattern> {
  1283. let Inst{28} = U;
  1284. let Inst{25-24} = 0b11;
  1285. let Inst{23} = 0b0;
  1286. let Inst{21-20} = size{1-0};
  1287. let Inst{11} = 0b0;
  1288. let Inst{8} = 0b0;
  1289. let Inst{6} = 0b1;
  1290. let Inst{4} = bit_4;
  1291. let validForTailPredication = 1;
  1292. }
  1293. multiclass MVE_VMINMAX_m<string iname, bit bit_4, MVEVectorVTInfo VTI,
  1294. SDNode Op, Intrinsic PredInt> {
  1295. def "" : MVE_VMINMAX<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, bit_4>;
  1296. let Predicates = [HasMVEInt] in {
  1297. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
  1298. }
  1299. }
  1300. multiclass MVE_VMAX<MVEVectorVTInfo VTI>
  1301. : MVE_VMINMAX_m<"vmax", 0b0, VTI, !if(VTI.Unsigned, umax, smax), int_arm_mve_max_predicated>;
  1302. multiclass MVE_VMIN<MVEVectorVTInfo VTI>
  1303. : MVE_VMINMAX_m<"vmin", 0b1, VTI, !if(VTI.Unsigned, umin, smin), int_arm_mve_min_predicated>;
  1304. defm MVE_VMINs8 : MVE_VMIN<MVE_v16s8>;
  1305. defm MVE_VMINs16 : MVE_VMIN<MVE_v8s16>;
  1306. defm MVE_VMINs32 : MVE_VMIN<MVE_v4s32>;
  1307. defm MVE_VMINu8 : MVE_VMIN<MVE_v16u8>;
  1308. defm MVE_VMINu16 : MVE_VMIN<MVE_v8u16>;
  1309. defm MVE_VMINu32 : MVE_VMIN<MVE_v4u32>;
  1310. defm MVE_VMAXs8 : MVE_VMAX<MVE_v16s8>;
  1311. defm MVE_VMAXs16 : MVE_VMAX<MVE_v8s16>;
  1312. defm MVE_VMAXs32 : MVE_VMAX<MVE_v4s32>;
  1313. defm MVE_VMAXu8 : MVE_VMAX<MVE_v16u8>;
  1314. defm MVE_VMAXu16 : MVE_VMAX<MVE_v8u16>;
  1315. defm MVE_VMAXu32 : MVE_VMAX<MVE_v4u32>;
  1316. // end of mve_comp instructions
  1317. // start of mve_bit instructions
  1318. class MVE_bit_arith<dag oops, dag iops, string iname, string suffix,
  1319. string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  1320. : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred_r, cstr, vecsize, pattern> {
  1321. bits<4> Qd;
  1322. bits<4> Qm;
  1323. let Inst{22} = Qd{3};
  1324. let Inst{15-13} = Qd{2-0};
  1325. let Inst{5} = Qm{3};
  1326. let Inst{3-1} = Qm{2-0};
  1327. }
  1328. def MVE_VBIC : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
  1329. "vbic", "", "$Qd, $Qn, $Qm", "", 0b00> {
  1330. bits<4> Qn;
  1331. let Inst{28} = 0b0;
  1332. let Inst{25-23} = 0b110;
  1333. let Inst{21-20} = 0b01;
  1334. let Inst{19-17} = Qn{2-0};
  1335. let Inst{16} = 0b0;
  1336. let Inst{12-8} = 0b00001;
  1337. let Inst{7} = Qn{3};
  1338. let Inst{6} = 0b1;
  1339. let Inst{4} = 0b1;
  1340. let Inst{0} = 0b0;
  1341. let validForTailPredication = 1;
  1342. }
  1343. class MVE_VREV<string iname, string suffix, bits<2> size, bits<2> bit_8_7,
  1344. bits<2> vecsize, string cstr="">
  1345. : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm), iname,
  1346. suffix, "$Qd, $Qm", cstr, vecsize> {
  1347. let Inst{28} = 0b1;
  1348. let Inst{25-23} = 0b111;
  1349. let Inst{21-20} = 0b11;
  1350. let Inst{19-18} = size;
  1351. let Inst{17-16} = 0b00;
  1352. let Inst{12-9} = 0b0000;
  1353. let Inst{8-7} = bit_8_7;
  1354. let Inst{6} = 0b1;
  1355. let Inst{4} = 0b0;
  1356. let Inst{0} = 0b0;
  1357. }
  1358. def MVE_VREV64_8 : MVE_VREV<"vrev64", "8", 0b00, 0b00, 0b11, "@earlyclobber $Qd">;
  1359. def MVE_VREV64_16 : MVE_VREV<"vrev64", "16", 0b01, 0b00, 0b11, "@earlyclobber $Qd">;
  1360. def MVE_VREV64_32 : MVE_VREV<"vrev64", "32", 0b10, 0b00, 0b11, "@earlyclobber $Qd">;
  1361. def MVE_VREV32_8 : MVE_VREV<"vrev32", "8", 0b00, 0b01, 0b10>;
  1362. def MVE_VREV32_16 : MVE_VREV<"vrev32", "16", 0b01, 0b01, 0b10>;
  1363. def MVE_VREV16_8 : MVE_VREV<"vrev16", "8", 0b00, 0b10, 0b01>;
  1364. let Predicates = [HasMVEInt] in {
  1365. def : Pat<(v8i16 (bswap (v8i16 MQPR:$src))),
  1366. (v8i16 (MVE_VREV16_8 (v8i16 MQPR:$src)))>;
  1367. def : Pat<(v4i32 (bswap (v4i32 MQPR:$src))),
  1368. (v4i32 (MVE_VREV32_8 (v4i32 MQPR:$src)))>;
  1369. }
  1370. multiclass MVE_VREV_basic_patterns<int revbits, list<MVEVectorVTInfo> VTIs,
  1371. Instruction Inst> {
  1372. defvar unpred_op = !cast<SDNode>("ARMvrev" # revbits);
  1373. foreach VTI = VTIs in {
  1374. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src))),
  1375. (VTI.Vec (Inst (VTI.Vec MQPR:$src)))>;
  1376. def : Pat<(VTI.Vec (int_arm_mve_vrev_predicated (VTI.Vec MQPR:$src),
  1377. revbits, (VTI.Pred VCCR:$pred), (VTI.Vec MQPR:$inactive))),
  1378. (VTI.Vec (Inst (VTI.Vec MQPR:$src), ARMVCCThen,
  1379. (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
  1380. }
  1381. }
  1382. let Predicates = [HasMVEInt] in {
  1383. defm: MVE_VREV_basic_patterns<64, [MVE_v4i32, MVE_v4f32], MVE_VREV64_32>;
  1384. defm: MVE_VREV_basic_patterns<64, [MVE_v8i16, MVE_v8f16], MVE_VREV64_16>;
  1385. defm: MVE_VREV_basic_patterns<64, [MVE_v16i8 ], MVE_VREV64_8>;
  1386. defm: MVE_VREV_basic_patterns<32, [MVE_v8i16, MVE_v8f16], MVE_VREV32_16>;
  1387. defm: MVE_VREV_basic_patterns<32, [MVE_v16i8 ], MVE_VREV32_8>;
  1388. defm: MVE_VREV_basic_patterns<16, [MVE_v16i8 ], MVE_VREV16_8>;
  1389. }
  1390. def MVE_VMVN : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm),
  1391. "vmvn", "", "$Qd, $Qm", "", 0b00> {
  1392. let Inst{28} = 0b1;
  1393. let Inst{25-23} = 0b111;
  1394. let Inst{21-16} = 0b110000;
  1395. let Inst{12-6} = 0b0010111;
  1396. let Inst{4} = 0b0;
  1397. let Inst{0} = 0b0;
  1398. let validForTailPredication = 1;
  1399. }
  1400. let Predicates = [HasMVEInt] in {
  1401. foreach VTI = [ MVE_v16i8, MVE_v8i16, MVE_v4i32, MVE_v2i64 ] in {
  1402. def : Pat<(VTI.Vec (vnotq (VTI.Vec MQPR:$val1))),
  1403. (VTI.Vec (MVE_VMVN (VTI.Vec MQPR:$val1)))>;
  1404. def : Pat<(VTI.Vec (int_arm_mve_mvn_predicated (VTI.Vec MQPR:$val1),
  1405. (VTI.Pred VCCR:$pred), (VTI.Vec MQPR:$inactive))),
  1406. (VTI.Vec (MVE_VMVN (VTI.Vec MQPR:$val1), ARMVCCThen,
  1407. (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
  1408. }
  1409. }
  1410. class MVE_bit_ops<string iname, bits<2> bit_21_20, bit bit_28>
  1411. : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
  1412. iname, "", "$Qd, $Qn, $Qm", "", 0b00> {
  1413. bits<4> Qn;
  1414. let Inst{28} = bit_28;
  1415. let Inst{25-23} = 0b110;
  1416. let Inst{21-20} = bit_21_20;
  1417. let Inst{19-17} = Qn{2-0};
  1418. let Inst{16} = 0b0;
  1419. let Inst{12-8} = 0b00001;
  1420. let Inst{7} = Qn{3};
  1421. let Inst{6} = 0b1;
  1422. let Inst{4} = 0b1;
  1423. let Inst{0} = 0b0;
  1424. let validForTailPredication = 1;
  1425. }
  1426. def MVE_VEOR : MVE_bit_ops<"veor", 0b00, 0b1>;
  1427. def MVE_VORN : MVE_bit_ops<"vorn", 0b11, 0b0>;
  1428. def MVE_VORR : MVE_bit_ops<"vorr", 0b10, 0b0>;
  1429. def MVE_VAND : MVE_bit_ops<"vand", 0b00, 0b0>;
  1430. // add ignored suffixes as aliases
  1431. foreach s=["s8", "s16", "s32", "u8", "u16", "u32", "i8", "i16", "i32", "f16", "f32"] in {
  1432. def : MVEInstAlias<"vbic${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
  1433. (MVE_VBIC MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
  1434. def : MVEInstAlias<"veor${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
  1435. (MVE_VEOR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
  1436. def : MVEInstAlias<"vorn${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
  1437. (MVE_VORN MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
  1438. def : MVEInstAlias<"vorr${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
  1439. (MVE_VORR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
  1440. def : MVEInstAlias<"vand${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
  1441. (MVE_VAND MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
  1442. }
  1443. let Predicates = [HasMVEInt] in {
  1444. defm : MVE_TwoOpPattern<MVE_v16i8, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
  1445. defm : MVE_TwoOpPattern<MVE_v8i16, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
  1446. defm : MVE_TwoOpPattern<MVE_v4i32, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
  1447. defm : MVE_TwoOpPattern<MVE_v2i64, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
  1448. defm : MVE_TwoOpPattern<MVE_v16i8, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
  1449. defm : MVE_TwoOpPattern<MVE_v8i16, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
  1450. defm : MVE_TwoOpPattern<MVE_v4i32, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
  1451. defm : MVE_TwoOpPattern<MVE_v2i64, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
  1452. defm : MVE_TwoOpPattern<MVE_v16i8, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
  1453. defm : MVE_TwoOpPattern<MVE_v8i16, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
  1454. defm : MVE_TwoOpPattern<MVE_v4i32, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
  1455. defm : MVE_TwoOpPattern<MVE_v2i64, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
  1456. defm : MVE_TwoOpPattern<MVE_v16i8, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
  1457. int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
  1458. defm : MVE_TwoOpPattern<MVE_v8i16, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
  1459. int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
  1460. defm : MVE_TwoOpPattern<MVE_v4i32, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
  1461. int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
  1462. defm : MVE_TwoOpPattern<MVE_v2i64, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
  1463. int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
  1464. defm : MVE_TwoOpPattern<MVE_v16i8, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
  1465. int_arm_mve_orn_predicated, (? ), MVE_VORN>;
  1466. defm : MVE_TwoOpPattern<MVE_v8i16, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
  1467. int_arm_mve_orn_predicated, (? ), MVE_VORN>;
  1468. defm : MVE_TwoOpPattern<MVE_v4i32, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
  1469. int_arm_mve_orn_predicated, (? ), MVE_VORN>;
  1470. defm : MVE_TwoOpPattern<MVE_v2i64, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
  1471. int_arm_mve_orn_predicated, (? ), MVE_VORN>;
  1472. }
  1473. class MVE_bit_cmode<string iname, string suffix, bit halfword, dag inOps, bits<2> vecsize>
  1474. : MVE_p<(outs MQPR:$Qd), inOps, NoItinerary,
  1475. iname, suffix, "$Qd, $imm", vpred_n, "$Qd = $Qd_src", vecsize> {
  1476. bits<12> imm;
  1477. bits<4> Qd;
  1478. let Inst{28} = imm{7};
  1479. let Inst{27-23} = 0b11111;
  1480. let Inst{22} = Qd{3};
  1481. let Inst{21-19} = 0b000;
  1482. let Inst{18-16} = imm{6-4};
  1483. let Inst{15-13} = Qd{2-0};
  1484. let Inst{12} = 0b0;
  1485. let Inst{11} = halfword;
  1486. let Inst{10} = !if(halfword, 0, imm{10});
  1487. let Inst{9} = imm{9};
  1488. let Inst{8} = 0b1;
  1489. let Inst{7-6} = 0b01;
  1490. let Inst{4} = 0b1;
  1491. let Inst{3-0} = imm{3-0};
  1492. }
  1493. multiclass MVE_bit_cmode_p<string iname, bit opcode,
  1494. MVEVectorVTInfo VTI, Operand imm_type, SDNode op> {
  1495. def "" : MVE_bit_cmode<iname, VTI.Suffix, VTI.Size{0},
  1496. (ins MQPR:$Qd_src, imm_type:$imm), VTI.Size> {
  1497. let Inst{5} = opcode;
  1498. let validForTailPredication = 1;
  1499. }
  1500. defvar Inst = !cast<Instruction>(NAME);
  1501. defvar UnpredPat = (VTI.Vec (op (VTI.Vec MQPR:$src), timm:$simm));
  1502. let Predicates = [HasMVEInt] in {
  1503. def : Pat<UnpredPat,
  1504. (VTI.Vec (Inst (VTI.Vec MQPR:$src), imm_type:$simm))>;
  1505. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  1506. UnpredPat, (VTI.Vec MQPR:$src))),
  1507. (VTI.Vec (Inst (VTI.Vec MQPR:$src), imm_type:$simm,
  1508. ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>;
  1509. }
  1510. }
  1511. multiclass MVE_VORRimm<MVEVectorVTInfo VTI, Operand imm_type> {
  1512. defm "": MVE_bit_cmode_p<"vorr", 0, VTI, imm_type, ARMvorrImm>;
  1513. }
  1514. multiclass MVE_VBICimm<MVEVectorVTInfo VTI, Operand imm_type> {
  1515. defm "": MVE_bit_cmode_p<"vbic", 1, VTI, imm_type, ARMvbicImm>;
  1516. }
  1517. defm MVE_VORRimmi16 : MVE_VORRimm<MVE_v8i16, nImmSplatI16>;
  1518. defm MVE_VORRimmi32 : MVE_VORRimm<MVE_v4i32, nImmSplatI32>;
  1519. defm MVE_VBICimmi16 : MVE_VBICimm<MVE_v8i16, nImmSplatI16>;
  1520. defm MVE_VBICimmi32 : MVE_VBICimm<MVE_v4i32, nImmSplatI32>;
  1521. def MVE_VORNimmi16 : MVEInstAlias<"vorn${vp}.i16\t$Qd, $imm",
  1522. (MVE_VORRimmi16 MQPR:$Qd, nImmSplatNotI16:$imm, vpred_n:$vp), 0>;
  1523. def MVE_VORNimmi32 : MVEInstAlias<"vorn${vp}.i32\t$Qd, $imm",
  1524. (MVE_VORRimmi32 MQPR:$Qd, nImmSplatNotI32:$imm, vpred_n:$vp), 0>;
  1525. def MVE_VANDimmi16 : MVEInstAlias<"vand${vp}.i16\t$Qd, $imm",
  1526. (MVE_VBICimmi16 MQPR:$Qd, nImmSplatNotI16:$imm, vpred_n:$vp), 0>;
  1527. def MVE_VANDimmi32 : MVEInstAlias<"vand${vp}.i32\t$Qd, $imm",
  1528. (MVE_VBICimmi32 MQPR:$Qd, nImmSplatNotI32:$imm, vpred_n:$vp), 0>;
  1529. def MVE_VMOV : MVEInstAlias<"vmov${vp}\t$Qd, $Qm",
  1530. (MVE_VORR MQPR:$Qd, MQPR:$Qm, MQPR:$Qm, vpred_r:$vp)>;
  1531. class MVE_VMOV_lane_direction {
  1532. bit bit_20;
  1533. dag oops;
  1534. dag iops;
  1535. string ops;
  1536. string cstr;
  1537. }
  1538. def MVE_VMOV_from_lane : MVE_VMOV_lane_direction {
  1539. let bit_20 = 0b1;
  1540. let oops = (outs rGPR:$Rt);
  1541. let iops = (ins MQPR:$Qd);
  1542. let ops = "$Rt, $Qd$Idx";
  1543. let cstr = "";
  1544. }
  1545. def MVE_VMOV_to_lane : MVE_VMOV_lane_direction {
  1546. let bit_20 = 0b0;
  1547. let oops = (outs MQPR:$Qd);
  1548. let iops = (ins MQPR:$Qd_src, rGPR:$Rt);
  1549. let ops = "$Qd$Idx, $Rt";
  1550. let cstr = "$Qd = $Qd_src";
  1551. }
  1552. class MVE_VMOV_lane<string suffix, bit U, dag indexop,
  1553. MVE_VMOV_lane_direction dir>
  1554. : MVE_VMOV_lane_base<dir.oops, !con(dir.iops, indexop), NoItinerary,
  1555. "vmov", suffix, dir.ops, dir.cstr, []> {
  1556. bits<4> Qd;
  1557. bits<4> Rt;
  1558. let Inst{31-24} = 0b11101110;
  1559. let Inst{23} = U;
  1560. let Inst{20} = dir.bit_20;
  1561. let Inst{19-17} = Qd{2-0};
  1562. let Inst{15-12} = Rt{3-0};
  1563. let Inst{11-8} = 0b1011;
  1564. let Inst{7} = Qd{3};
  1565. let Inst{4-0} = 0b10000;
  1566. let hasSideEffects = 0;
  1567. }
  1568. class MVE_VMOV_lane_32<MVE_VMOV_lane_direction dir>
  1569. : MVE_VMOV_lane<"32", 0b0, (ins MVEVectorIndex<4>:$Idx), dir> {
  1570. bits<2> Idx;
  1571. let Inst{22} = 0b0;
  1572. let Inst{6-5} = 0b00;
  1573. let Inst{16} = Idx{1};
  1574. let Inst{21} = Idx{0};
  1575. let VecSize = 0b10;
  1576. let Predicates = [HasFPRegsV8_1M];
  1577. }
  1578. class MVE_VMOV_lane_16<string suffix, bit U, MVE_VMOV_lane_direction dir>
  1579. : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<8>:$Idx), dir> {
  1580. bits<3> Idx;
  1581. let Inst{22} = 0b0;
  1582. let Inst{5} = 0b1;
  1583. let Inst{16} = Idx{2};
  1584. let Inst{21} = Idx{1};
  1585. let Inst{6} = Idx{0};
  1586. let VecSize = 0b01;
  1587. }
  1588. class MVE_VMOV_lane_8<string suffix, bit U, MVE_VMOV_lane_direction dir>
  1589. : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<16>:$Idx), dir> {
  1590. bits<4> Idx;
  1591. let Inst{22} = 0b1;
  1592. let Inst{16} = Idx{3};
  1593. let Inst{21} = Idx{2};
  1594. let Inst{6} = Idx{1};
  1595. let Inst{5} = Idx{0};
  1596. let VecSize = 0b00;
  1597. }
  1598. def MVE_VMOV_from_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_from_lane>;
  1599. def MVE_VMOV_from_lane_s16 : MVE_VMOV_lane_16<"s16", 0b0, MVE_VMOV_from_lane>;
  1600. def MVE_VMOV_from_lane_u16 : MVE_VMOV_lane_16<"u16", 0b1, MVE_VMOV_from_lane>;
  1601. def MVE_VMOV_from_lane_s8 : MVE_VMOV_lane_8 < "s8", 0b0, MVE_VMOV_from_lane>;
  1602. def MVE_VMOV_from_lane_u8 : MVE_VMOV_lane_8 < "u8", 0b1, MVE_VMOV_from_lane>;
  1603. let isInsertSubreg = 1 in
  1604. def MVE_VMOV_to_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_to_lane>;
  1605. def MVE_VMOV_to_lane_16 : MVE_VMOV_lane_16< "16", 0b0, MVE_VMOV_to_lane>;
  1606. def MVE_VMOV_to_lane_8 : MVE_VMOV_lane_8 < "8", 0b0, MVE_VMOV_to_lane>;
  1607. // This is the same as insertelt but allows the inserted value to be an i32 as
  1608. // will be used when it is the only legal type.
  1609. def ARMVecInsert : SDTypeProfile<1, 3, [
  1610. SDTCisVT<2, i32>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3>
  1611. ]>;
  1612. def ARMinsertelt : SDNode<"ISD::INSERT_VECTOR_ELT", ARMVecInsert>;
  1613. let Predicates = [HasMVEInt] in {
  1614. def : Pat<(extractelt (v2f64 MQPR:$src), imm:$lane),
  1615. (f64 (EXTRACT_SUBREG MQPR:$src, (DSubReg_f64_reg imm:$lane)))>;
  1616. def : Pat<(insertelt (v2f64 MQPR:$src1), DPR:$src2, imm:$lane),
  1617. (INSERT_SUBREG (v2f64 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), DPR:$src2, (DSubReg_f64_reg imm:$lane))>;
  1618. def : Pat<(extractelt (v4i32 MQPR:$src), imm:$lane),
  1619. (COPY_TO_REGCLASS
  1620. (i32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), rGPR)>;
  1621. def : Pat<(insertelt (v4i32 MQPR:$src1), rGPR:$src2, imm:$lane),
  1622. (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$src2, imm:$lane)>;
  1623. // This tries to copy from one lane to another, without going via GPR regs
  1624. def : Pat<(insertelt (v4i32 MQPR:$src1), (extractelt (v4i32 MQPR:$src2), imm:$extlane), imm:$inslane),
  1625. (v4i32 (COPY_TO_REGCLASS
  1626. (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4i32 MQPR:$src1), MQPR)),
  1627. (f32 (EXTRACT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4i32 MQPR:$src2), MQPR)),
  1628. (SSubReg_f32_reg imm:$extlane))),
  1629. (SSubReg_f32_reg imm:$inslane)),
  1630. MQPR))>;
  1631. def : Pat<(vector_insert (v16i8 MQPR:$src1), rGPR:$src2, imm:$lane),
  1632. (MVE_VMOV_to_lane_8 MQPR:$src1, rGPR:$src2, imm:$lane)>;
  1633. def : Pat<(vector_insert (v8i16 MQPR:$src1), rGPR:$src2, imm:$lane),
  1634. (MVE_VMOV_to_lane_16 MQPR:$src1, rGPR:$src2, imm:$lane)>;
  1635. def : Pat<(ARMvgetlanes (v16i8 MQPR:$src), imm:$lane),
  1636. (MVE_VMOV_from_lane_s8 MQPR:$src, imm:$lane)>;
  1637. def : Pat<(ARMvgetlanes (v8i16 MQPR:$src), imm:$lane),
  1638. (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>;
  1639. def : Pat<(ARMvgetlanes (v8f16 MQPR:$src), imm:$lane),
  1640. (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>;
  1641. def : Pat<(ARMvgetlaneu (v16i8 MQPR:$src), imm:$lane),
  1642. (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane)>;
  1643. def : Pat<(ARMvgetlaneu (v8i16 MQPR:$src), imm:$lane),
  1644. (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>;
  1645. def : Pat<(ARMvgetlaneu (v8f16 MQPR:$src), imm:$lane),
  1646. (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>;
  1647. // For i16's inserts being extracted from low lanes, then may use VINS.
  1648. def : Pat<(ARMinsertelt (v8i16 MQPR:$src1),
  1649. (ARMvgetlaneu (v8i16 MQPR:$src2), imm_even:$extlane),
  1650. imm_odd:$inslane),
  1651. (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)),
  1652. (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$inslane)),
  1653. (EXTRACT_SUBREG MQPR:$src2, (SSubReg_f16_reg imm_even:$extlane))),
  1654. (SSubReg_f16_reg imm_odd:$inslane)), MQPR)>;
  1655. def : Pat<(v16i8 (scalar_to_vector GPR:$src)),
  1656. (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1657. def : Pat<(v8i16 (scalar_to_vector GPR:$src)),
  1658. (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1659. def : Pat<(v4i32 (scalar_to_vector GPR:$src)),
  1660. (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1661. // Floating point patterns, still enabled under HasMVEInt
  1662. def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane),
  1663. (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>;
  1664. def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane),
  1665. (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>;
  1666. def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_even:$lane),
  1667. (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS (f16 HPR:$src2), rGPR), imm:$lane)>;
  1668. def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_odd:$lane),
  1669. (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)),
  1670. (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$lane)),
  1671. (COPY_TO_REGCLASS HPR:$src2, SPR)),
  1672. (SSubReg_f16_reg imm_odd:$lane)), MQPR)>;
  1673. def : Pat<(extractelt (v8f16 MQPR:$src), imm_even:$lane),
  1674. (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_even:$lane))>;
  1675. def : Pat<(extractelt (v8f16 MQPR:$src), imm_odd:$lane),
  1676. (COPY_TO_REGCLASS
  1677. (VMOVH (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane))),
  1678. HPR)>;
  1679. def : Pat<(v2f64 (scalar_to_vector (f64 DPR:$src))),
  1680. (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
  1681. def : Pat<(v4f32 (scalar_to_vector SPR:$src)),
  1682. (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
  1683. def : Pat<(v4f32 (scalar_to_vector GPR:$src)),
  1684. (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1685. def : Pat<(v8f16 (scalar_to_vector (f16 HPR:$src))),
  1686. (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), (f16 HPR:$src), ssub_0)>;
  1687. def : Pat<(v8f16 (scalar_to_vector GPR:$src)),
  1688. (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1689. }
  1690. // end of mve_bit instructions
  1691. // start of MVE Integer instructions
  1692. class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
  1693. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
  1694. iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", size, pattern> {
  1695. bits<4> Qd;
  1696. bits<4> Qn;
  1697. bits<4> Qm;
  1698. let Inst{22} = Qd{3};
  1699. let Inst{21-20} = size;
  1700. let Inst{19-17} = Qn{2-0};
  1701. let Inst{15-13} = Qd{2-0};
  1702. let Inst{7} = Qn{3};
  1703. let Inst{6} = 0b1;
  1704. let Inst{5} = Qm{3};
  1705. let Inst{3-1} = Qm{2-0};
  1706. }
  1707. class MVE_VMULt1<string iname, string suffix, bits<2> size,
  1708. list<dag> pattern=[]>
  1709. : MVE_int<iname, suffix, size, pattern> {
  1710. let Inst{28} = 0b0;
  1711. let Inst{25-23} = 0b110;
  1712. let Inst{16} = 0b0;
  1713. let Inst{12-8} = 0b01001;
  1714. let Inst{4} = 0b1;
  1715. let Inst{0} = 0b0;
  1716. let validForTailPredication = 1;
  1717. }
  1718. multiclass MVE_VMUL_m<MVEVectorVTInfo VTI> {
  1719. def "" : MVE_VMULt1<"vmul", VTI.Suffix, VTI.Size>;
  1720. let Predicates = [HasMVEInt] in {
  1721. defm : MVE_TwoOpPattern<VTI, mul, int_arm_mve_mul_predicated, (? ),
  1722. !cast<Instruction>(NAME), ARMimmOneV>;
  1723. }
  1724. }
  1725. defm MVE_VMULi8 : MVE_VMUL_m<MVE_v16i8>;
  1726. defm MVE_VMULi16 : MVE_VMUL_m<MVE_v8i16>;
  1727. defm MVE_VMULi32 : MVE_VMUL_m<MVE_v4i32>;
  1728. class MVE_VQxDMULH_Base<string iname, string suffix, bits<2> size, bit rounding,
  1729. list<dag> pattern=[]>
  1730. : MVE_int<iname, suffix, size, pattern> {
  1731. let Inst{28} = rounding;
  1732. let Inst{25-23} = 0b110;
  1733. let Inst{16} = 0b0;
  1734. let Inst{12-8} = 0b01011;
  1735. let Inst{4} = 0b0;
  1736. let Inst{0} = 0b0;
  1737. let validForTailPredication = 1;
  1738. }
  1739. def MVEvqdmulh : SDNode<"ARMISD::VQDMULH", SDTIntBinOp>;
  1740. multiclass MVE_VQxDMULH_m<string iname, MVEVectorVTInfo VTI,
  1741. SDNode Op, Intrinsic unpred_int, Intrinsic pred_int,
  1742. bit rounding> {
  1743. def "" : MVE_VQxDMULH_Base<iname, VTI.Suffix, VTI.Size, rounding>;
  1744. defvar Inst = !cast<Instruction>(NAME);
  1745. let Predicates = [HasMVEInt] in {
  1746. defm : MVE_TwoOpPattern<VTI, Op, pred_int, (? ), Inst>;
  1747. // Extra unpredicated multiply intrinsic patterns
  1748. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
  1749. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  1750. }
  1751. }
  1752. multiclass MVE_VQxDMULH<string iname, MVEVectorVTInfo VTI, bit rounding>
  1753. : MVE_VQxDMULH_m<iname, VTI, !if(rounding, null_frag,
  1754. MVEvqdmulh),
  1755. !if(rounding, int_arm_mve_vqrdmulh,
  1756. int_arm_mve_vqdmulh),
  1757. !if(rounding, int_arm_mve_qrdmulh_predicated,
  1758. int_arm_mve_qdmulh_predicated),
  1759. rounding>;
  1760. defm MVE_VQDMULHi8 : MVE_VQxDMULH<"vqdmulh", MVE_v16s8, 0b0>;
  1761. defm MVE_VQDMULHi16 : MVE_VQxDMULH<"vqdmulh", MVE_v8s16, 0b0>;
  1762. defm MVE_VQDMULHi32 : MVE_VQxDMULH<"vqdmulh", MVE_v4s32, 0b0>;
  1763. defm MVE_VQRDMULHi8 : MVE_VQxDMULH<"vqrdmulh", MVE_v16s8, 0b1>;
  1764. defm MVE_VQRDMULHi16 : MVE_VQxDMULH<"vqrdmulh", MVE_v8s16, 0b1>;
  1765. defm MVE_VQRDMULHi32 : MVE_VQxDMULH<"vqrdmulh", MVE_v4s32, 0b1>;
  1766. class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract,
  1767. list<dag> pattern=[]>
  1768. : MVE_int<iname, suffix, size, pattern> {
  1769. let Inst{28} = subtract;
  1770. let Inst{25-23} = 0b110;
  1771. let Inst{16} = 0b0;
  1772. let Inst{12-8} = 0b01000;
  1773. let Inst{4} = 0b0;
  1774. let Inst{0} = 0b0;
  1775. let validForTailPredication = 1;
  1776. }
  1777. multiclass MVE_VADDSUB_m<string iname, MVEVectorVTInfo VTI, bit subtract,
  1778. SDNode Op, Intrinsic PredInt> {
  1779. def "" : MVE_VADDSUB<iname, VTI.Suffix, VTI.Size, subtract>;
  1780. defvar Inst = !cast<Instruction>(NAME);
  1781. let Predicates = [HasMVEInt] in {
  1782. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>;
  1783. }
  1784. }
  1785. multiclass MVE_VADD<MVEVectorVTInfo VTI>
  1786. : MVE_VADDSUB_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>;
  1787. multiclass MVE_VSUB<MVEVectorVTInfo VTI>
  1788. : MVE_VADDSUB_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>;
  1789. defm MVE_VADDi8 : MVE_VADD<MVE_v16i8>;
  1790. defm MVE_VADDi16 : MVE_VADD<MVE_v8i16>;
  1791. defm MVE_VADDi32 : MVE_VADD<MVE_v4i32>;
  1792. defm MVE_VSUBi8 : MVE_VSUB<MVE_v16i8>;
  1793. defm MVE_VSUBi16 : MVE_VSUB<MVE_v8i16>;
  1794. defm MVE_VSUBi32 : MVE_VSUB<MVE_v4i32>;
  1795. class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract,
  1796. bits<2> size>
  1797. : MVE_int<iname, suffix, size, []> {
  1798. let Inst{28} = U;
  1799. let Inst{25-23} = 0b110;
  1800. let Inst{16} = 0b0;
  1801. let Inst{12-10} = 0b000;
  1802. let Inst{9} = subtract;
  1803. let Inst{8} = 0b0;
  1804. let Inst{4} = 0b1;
  1805. let Inst{0} = 0b0;
  1806. let validForTailPredication = 1;
  1807. }
  1808. class MVE_VQADD_<string suffix, bit U, bits<2> size>
  1809. : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size>;
  1810. class MVE_VQSUB_<string suffix, bit U, bits<2> size>
  1811. : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size>;
  1812. multiclass MVE_VQADD_m<MVEVectorVTInfo VTI,
  1813. SDNode Op, Intrinsic PredInt> {
  1814. def "" : MVE_VQADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1815. defvar Inst = !cast<Instruction>(NAME);
  1816. let Predicates = [HasMVEInt] in {
  1817. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  1818. !cast<Instruction>(NAME)>;
  1819. }
  1820. }
  1821. multiclass MVE_VQADD<MVEVectorVTInfo VTI, SDNode unpred_op>
  1822. : MVE_VQADD_m<VTI, unpred_op, int_arm_mve_qadd_predicated>;
  1823. defm MVE_VQADDs8 : MVE_VQADD<MVE_v16s8, saddsat>;
  1824. defm MVE_VQADDs16 : MVE_VQADD<MVE_v8s16, saddsat>;
  1825. defm MVE_VQADDs32 : MVE_VQADD<MVE_v4s32, saddsat>;
  1826. defm MVE_VQADDu8 : MVE_VQADD<MVE_v16u8, uaddsat>;
  1827. defm MVE_VQADDu16 : MVE_VQADD<MVE_v8u16, uaddsat>;
  1828. defm MVE_VQADDu32 : MVE_VQADD<MVE_v4u32, uaddsat>;
  1829. multiclass MVE_VQSUB_m<MVEVectorVTInfo VTI,
  1830. SDNode Op, Intrinsic PredInt> {
  1831. def "" : MVE_VQSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1832. defvar Inst = !cast<Instruction>(NAME);
  1833. let Predicates = [HasMVEInt] in {
  1834. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  1835. !cast<Instruction>(NAME)>;
  1836. }
  1837. }
  1838. multiclass MVE_VQSUB<MVEVectorVTInfo VTI, SDNode unpred_op>
  1839. : MVE_VQSUB_m<VTI, unpred_op, int_arm_mve_qsub_predicated>;
  1840. defm MVE_VQSUBs8 : MVE_VQSUB<MVE_v16s8, ssubsat>;
  1841. defm MVE_VQSUBs16 : MVE_VQSUB<MVE_v8s16, ssubsat>;
  1842. defm MVE_VQSUBs32 : MVE_VQSUB<MVE_v4s32, ssubsat>;
  1843. defm MVE_VQSUBu8 : MVE_VQSUB<MVE_v16u8, usubsat>;
  1844. defm MVE_VQSUBu16 : MVE_VQSUB<MVE_v8u16, usubsat>;
  1845. defm MVE_VQSUBu32 : MVE_VQSUB<MVE_v4u32, usubsat>;
  1846. class MVE_VABD_int<string suffix, bit U, bits<2> size,
  1847. list<dag> pattern=[]>
  1848. : MVE_int<"vabd", suffix, size, pattern> {
  1849. let Inst{28} = U;
  1850. let Inst{25-23} = 0b110;
  1851. let Inst{16} = 0b0;
  1852. let Inst{12-8} = 0b00111;
  1853. let Inst{4} = 0b0;
  1854. let Inst{0} = 0b0;
  1855. let validForTailPredication = 1;
  1856. }
  1857. multiclass MVE_VABD_m<MVEVectorVTInfo VTI, SDNode Op,
  1858. Intrinsic unpred_int, Intrinsic PredInt> {
  1859. def "" : MVE_VABD_int<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1860. defvar Inst = !cast<Instruction>(NAME);
  1861. let Predicates = [HasMVEInt] in {
  1862. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  1863. !cast<Instruction>(NAME)>;
  1864. // Unpredicated absolute difference
  1865. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  1866. (i32 VTI.Unsigned))),
  1867. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  1868. }
  1869. }
  1870. multiclass MVE_VABD<MVEVectorVTInfo VTI, SDNode Op>
  1871. : MVE_VABD_m<VTI, Op, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
  1872. defm MVE_VABDs8 : MVE_VABD<MVE_v16s8, abds>;
  1873. defm MVE_VABDs16 : MVE_VABD<MVE_v8s16, abds>;
  1874. defm MVE_VABDs32 : MVE_VABD<MVE_v4s32, abds>;
  1875. defm MVE_VABDu8 : MVE_VABD<MVE_v16u8, abdu>;
  1876. defm MVE_VABDu16 : MVE_VABD<MVE_v8u16, abdu>;
  1877. defm MVE_VABDu32 : MVE_VABD<MVE_v4u32, abdu>;
  1878. class MVE_VRHADD_Base<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
  1879. : MVE_int<"vrhadd", suffix, size, pattern> {
  1880. let Inst{28} = U;
  1881. let Inst{25-23} = 0b110;
  1882. let Inst{16} = 0b0;
  1883. let Inst{12-8} = 0b00001;
  1884. let Inst{4} = 0b0;
  1885. let Inst{0} = 0b0;
  1886. let validForTailPredication = 1;
  1887. }
  1888. def addnuw : PatFrag<(ops node:$lhs, node:$rhs),
  1889. (add node:$lhs, node:$rhs), [{
  1890. return N->getFlags().hasNoUnsignedWrap();
  1891. }]>;
  1892. def addnsw : PatFrag<(ops node:$lhs, node:$rhs),
  1893. (add node:$lhs, node:$rhs), [{
  1894. return N->getFlags().hasNoSignedWrap();
  1895. }]>;
  1896. def subnuw : PatFrag<(ops node:$lhs, node:$rhs),
  1897. (sub node:$lhs, node:$rhs), [{
  1898. return N->getFlags().hasNoUnsignedWrap();
  1899. }]>;
  1900. def subnsw : PatFrag<(ops node:$lhs, node:$rhs),
  1901. (sub node:$lhs, node:$rhs), [{
  1902. return N->getFlags().hasNoSignedWrap();
  1903. }]>;
  1904. multiclass MVE_VRHADD_m<MVEVectorVTInfo VTI,
  1905. SDNode unpred_op, Intrinsic pred_int> {
  1906. def "" : MVE_VRHADD_Base<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1907. defvar Inst = !cast<Instruction>(NAME);
  1908. let Predicates = [HasMVEInt] in {
  1909. // Unpredicated rounding add-with-divide-by-two
  1910. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  1911. (i32 VTI.Unsigned))),
  1912. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  1913. // Predicated add-with-divide-by-two
  1914. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  1915. (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
  1916. (VTI.Vec MQPR:$inactive))),
  1917. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  1918. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  1919. (VTI.Vec MQPR:$inactive)))>;
  1920. }
  1921. }
  1922. multiclass MVE_VRHADD<MVEVectorVTInfo VTI>
  1923. : MVE_VRHADD_m<VTI, int_arm_mve_vrhadd, int_arm_mve_rhadd_predicated>;
  1924. defm MVE_VRHADDs8 : MVE_VRHADD<MVE_v16s8>;
  1925. defm MVE_VRHADDs16 : MVE_VRHADD<MVE_v8s16>;
  1926. defm MVE_VRHADDs32 : MVE_VRHADD<MVE_v4s32>;
  1927. defm MVE_VRHADDu8 : MVE_VRHADD<MVE_v16u8>;
  1928. defm MVE_VRHADDu16 : MVE_VRHADD<MVE_v8u16>;
  1929. defm MVE_VRHADDu32 : MVE_VRHADD<MVE_v4u32>;
  1930. // Rounding Halving Add perform the arithemtic operation with an extra bit of
  1931. // precision, before performing the shift, to void clipping errors. We're not
  1932. // modelling that here with these patterns, but we're using no wrap forms of
  1933. // add to ensure that the extra bit of information is not needed for the
  1934. // arithmetic or the rounding.
  1935. let Predicates = [HasMVEInt] in {
  1936. def : Pat<(v16i8 (ARMvshrsImm (addnsw (addnsw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)),
  1937. (v16i8 (ARMvmovImm (i32 3585)))),
  1938. (i32 1))),
  1939. (MVE_VRHADDs8 MQPR:$Qm, MQPR:$Qn)>;
  1940. def : Pat<(v8i16 (ARMvshrsImm (addnsw (addnsw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)),
  1941. (v8i16 (ARMvmovImm (i32 2049)))),
  1942. (i32 1))),
  1943. (MVE_VRHADDs16 MQPR:$Qm, MQPR:$Qn)>;
  1944. def : Pat<(v4i32 (ARMvshrsImm (addnsw (addnsw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)),
  1945. (v4i32 (ARMvmovImm (i32 1)))),
  1946. (i32 1))),
  1947. (MVE_VRHADDs32 MQPR:$Qm, MQPR:$Qn)>;
  1948. def : Pat<(v16i8 (ARMvshruImm (addnuw (addnuw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)),
  1949. (v16i8 (ARMvmovImm (i32 3585)))),
  1950. (i32 1))),
  1951. (MVE_VRHADDu8 MQPR:$Qm, MQPR:$Qn)>;
  1952. def : Pat<(v8i16 (ARMvshruImm (addnuw (addnuw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)),
  1953. (v8i16 (ARMvmovImm (i32 2049)))),
  1954. (i32 1))),
  1955. (MVE_VRHADDu16 MQPR:$Qm, MQPR:$Qn)>;
  1956. def : Pat<(v4i32 (ARMvshruImm (addnuw (addnuw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)),
  1957. (v4i32 (ARMvmovImm (i32 1)))),
  1958. (i32 1))),
  1959. (MVE_VRHADDu32 MQPR:$Qm, MQPR:$Qn)>;
  1960. def : Pat<(v16i8 (ARMvshrsImm (addnsw (addnsw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)),
  1961. (v16i8 (ARMvdup (i32 1)))),
  1962. (i32 1))),
  1963. (MVE_VRHADDs8 MQPR:$Qm, MQPR:$Qn)>;
  1964. def : Pat<(v8i16 (ARMvshrsImm (addnsw (addnsw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)),
  1965. (v8i16 (ARMvdup (i32 1)))),
  1966. (i32 1))),
  1967. (MVE_VRHADDs16 MQPR:$Qm, MQPR:$Qn)>;
  1968. def : Pat<(v4i32 (ARMvshrsImm (addnsw (addnsw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)),
  1969. (v4i32 (ARMvdup (i32 1)))),
  1970. (i32 1))),
  1971. (MVE_VRHADDs32 MQPR:$Qm, MQPR:$Qn)>;
  1972. def : Pat<(v16i8 (ARMvshruImm (addnuw (addnuw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)),
  1973. (v16i8 (ARMvdup (i32 1)))),
  1974. (i32 1))),
  1975. (MVE_VRHADDu8 MQPR:$Qm, MQPR:$Qn)>;
  1976. def : Pat<(v8i16 (ARMvshruImm (addnuw (addnuw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)),
  1977. (v8i16 (ARMvdup (i32 1)))),
  1978. (i32 1))),
  1979. (MVE_VRHADDu16 MQPR:$Qm, MQPR:$Qn)>;
  1980. def : Pat<(v4i32 (ARMvshruImm (addnuw (addnuw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)),
  1981. (v4i32 (ARMvdup (i32 1)))),
  1982. (i32 1))),
  1983. (MVE_VRHADDu32 MQPR:$Qm, MQPR:$Qn)>;
  1984. }
  1985. class MVE_VHADDSUB<string iname, string suffix, bit U, bit subtract,
  1986. bits<2> size, list<dag> pattern=[]>
  1987. : MVE_int<iname, suffix, size, pattern> {
  1988. let Inst{28} = U;
  1989. let Inst{25-23} = 0b110;
  1990. let Inst{16} = 0b0;
  1991. let Inst{12-10} = 0b000;
  1992. let Inst{9} = subtract;
  1993. let Inst{8} = 0b0;
  1994. let Inst{4} = 0b0;
  1995. let Inst{0} = 0b0;
  1996. let validForTailPredication = 1;
  1997. }
  1998. class MVE_VHADD_<string suffix, bit U, bits<2> size,
  1999. list<dag> pattern=[]>
  2000. : MVE_VHADDSUB<"vhadd", suffix, U, 0b0, size, pattern>;
  2001. class MVE_VHSUB_<string suffix, bit U, bits<2> size,
  2002. list<dag> pattern=[]>
  2003. : MVE_VHADDSUB<"vhsub", suffix, U, 0b1, size, pattern>;
  2004. multiclass MVE_VHADD_m<MVEVectorVTInfo VTI,
  2005. SDNode unpred_op, Intrinsic pred_int, PatFrag add_op,
  2006. SDNode shift_op> {
  2007. def "" : MVE_VHADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  2008. defvar Inst = !cast<Instruction>(NAME);
  2009. let Predicates = [HasMVEInt] in {
  2010. // Unpredicated add-and-divide-by-two
  2011. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), (i32 VTI.Unsigned))),
  2012. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  2013. def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))),
  2014. (Inst MQPR:$Qm, MQPR:$Qn)>;
  2015. // Predicated add-and-divide-by-two
  2016. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), (i32 VTI.Unsigned),
  2017. (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
  2018. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  2019. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  2020. (VTI.Vec MQPR:$inactive)))>;
  2021. }
  2022. }
  2023. multiclass MVE_VHADD<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op>
  2024. : MVE_VHADD_m<VTI, int_arm_mve_vhadd, int_arm_mve_hadd_predicated, add_op,
  2025. shift_op>;
  2026. // Halving add/sub perform the arithemtic operation with an extra bit of
  2027. // precision, before performing the shift, to void clipping errors. We're not
  2028. // modelling that here with these patterns, but we're using no wrap forms of
  2029. // add/sub to ensure that the extra bit of information is not needed.
  2030. defm MVE_VHADDs8 : MVE_VHADD<MVE_v16s8, addnsw, ARMvshrsImm>;
  2031. defm MVE_VHADDs16 : MVE_VHADD<MVE_v8s16, addnsw, ARMvshrsImm>;
  2032. defm MVE_VHADDs32 : MVE_VHADD<MVE_v4s32, addnsw, ARMvshrsImm>;
  2033. defm MVE_VHADDu8 : MVE_VHADD<MVE_v16u8, addnuw, ARMvshruImm>;
  2034. defm MVE_VHADDu16 : MVE_VHADD<MVE_v8u16, addnuw, ARMvshruImm>;
  2035. defm MVE_VHADDu32 : MVE_VHADD<MVE_v4u32, addnuw, ARMvshruImm>;
  2036. multiclass MVE_VHSUB_m<MVEVectorVTInfo VTI,
  2037. SDNode unpred_op, Intrinsic pred_int, PatFrag sub_op,
  2038. SDNode shift_op> {
  2039. def "" : MVE_VHSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  2040. defvar Inst = !cast<Instruction>(NAME);
  2041. let Predicates = [HasMVEInt] in {
  2042. // Unpredicated subtract-and-divide-by-two
  2043. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  2044. (i32 VTI.Unsigned))),
  2045. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  2046. def : Pat<(VTI.Vec (shift_op (sub_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))),
  2047. (Inst MQPR:$Qm, MQPR:$Qn)>;
  2048. // Predicated subtract-and-divide-by-two
  2049. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  2050. (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
  2051. (VTI.Vec MQPR:$inactive))),
  2052. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  2053. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  2054. (VTI.Vec MQPR:$inactive)))>;
  2055. }
  2056. }
  2057. multiclass MVE_VHSUB<MVEVectorVTInfo VTI, PatFrag sub_op, SDNode shift_op>
  2058. : MVE_VHSUB_m<VTI, int_arm_mve_vhsub, int_arm_mve_hsub_predicated, sub_op,
  2059. shift_op>;
  2060. defm MVE_VHSUBs8 : MVE_VHSUB<MVE_v16s8, subnsw, ARMvshrsImm>;
  2061. defm MVE_VHSUBs16 : MVE_VHSUB<MVE_v8s16, subnsw, ARMvshrsImm>;
  2062. defm MVE_VHSUBs32 : MVE_VHSUB<MVE_v4s32, subnsw, ARMvshrsImm>;
  2063. defm MVE_VHSUBu8 : MVE_VHSUB<MVE_v16u8, subnuw, ARMvshruImm>;
  2064. defm MVE_VHSUBu16 : MVE_VHSUB<MVE_v8u16, subnuw, ARMvshruImm>;
  2065. defm MVE_VHSUBu32 : MVE_VHSUB<MVE_v4u32, subnuw, ARMvshruImm>;
  2066. class MVE_VDUP<string suffix, bit B, bit E, bits<2> vecsize, list<dag> pattern=[]>
  2067. : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary,
  2068. "vdup", suffix, "$Qd, $Rt", vpred_r, "", vecsize, pattern> {
  2069. bits<4> Qd;
  2070. bits<4> Rt;
  2071. let Inst{28} = 0b0;
  2072. let Inst{25-23} = 0b101;
  2073. let Inst{22} = B;
  2074. let Inst{21-20} = 0b10;
  2075. let Inst{19-17} = Qd{2-0};
  2076. let Inst{16} = 0b0;
  2077. let Inst{15-12} = Rt;
  2078. let Inst{11-8} = 0b1011;
  2079. let Inst{7} = Qd{3};
  2080. let Inst{6} = 0b0;
  2081. let Inst{5} = E;
  2082. let Inst{4-0} = 0b10000;
  2083. let validForTailPredication = 1;
  2084. }
  2085. def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0, 0b10>;
  2086. def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1, 0b01>;
  2087. def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0, 0b00>;
  2088. let Predicates = [HasMVEInt] in {
  2089. def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))),
  2090. (MVE_VDUP8 rGPR:$elem)>;
  2091. def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))),
  2092. (MVE_VDUP16 rGPR:$elem)>;
  2093. def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))),
  2094. (MVE_VDUP32 rGPR:$elem)>;
  2095. def : Pat<(v8f16 (ARMvdup (i32 rGPR:$elem))),
  2096. (MVE_VDUP16 rGPR:$elem)>;
  2097. def : Pat<(v4f32 (ARMvdup (i32 rGPR:$elem))),
  2098. (MVE_VDUP32 rGPR:$elem)>;
  2099. // Match a vselect with an ARMvdup as a predicated MVE_VDUP
  2100. def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred),
  2101. (v16i8 (ARMvdup (i32 rGPR:$elem))),
  2102. (v16i8 MQPR:$inactive))),
  2103. (MVE_VDUP8 rGPR:$elem, ARMVCCThen, (v16i1 VCCR:$pred), zero_reg,
  2104. (v16i8 MQPR:$inactive))>;
  2105. def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred),
  2106. (v8i16 (ARMvdup (i32 rGPR:$elem))),
  2107. (v8i16 MQPR:$inactive))),
  2108. (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg,
  2109. (v8i16 MQPR:$inactive))>;
  2110. def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred),
  2111. (v4i32 (ARMvdup (i32 rGPR:$elem))),
  2112. (v4i32 MQPR:$inactive))),
  2113. (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg,
  2114. (v4i32 MQPR:$inactive))>;
  2115. def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred),
  2116. (v4f32 (ARMvdup (i32 rGPR:$elem))),
  2117. (v4f32 MQPR:$inactive))),
  2118. (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg,
  2119. (v4f32 MQPR:$inactive))>;
  2120. def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred),
  2121. (v8f16 (ARMvdup (i32 rGPR:$elem))),
  2122. (v8f16 MQPR:$inactive))),
  2123. (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg,
  2124. (v8f16 MQPR:$inactive))>;
  2125. }
  2126. class MVEIntSingleSrc<string iname, string suffix, bits<2> size,
  2127. list<dag> pattern=[]>
  2128. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary,
  2129. iname, suffix, "$Qd, $Qm", vpred_r, "", size, pattern> {
  2130. bits<4> Qd;
  2131. bits<4> Qm;
  2132. let Inst{22} = Qd{3};
  2133. let Inst{19-18} = size{1-0};
  2134. let Inst{15-13} = Qd{2-0};
  2135. let Inst{5} = Qm{3};
  2136. let Inst{3-1} = Qm{2-0};
  2137. }
  2138. class MVE_VCLSCLZ<string iname, string suffix, bits<2> size,
  2139. bit count_zeroes, list<dag> pattern=[]>
  2140. : MVEIntSingleSrc<iname, suffix, size, pattern> {
  2141. let Inst{28} = 0b1;
  2142. let Inst{25-23} = 0b111;
  2143. let Inst{21-20} = 0b11;
  2144. let Inst{17-16} = 0b00;
  2145. let Inst{12-8} = 0b00100;
  2146. let Inst{7} = count_zeroes;
  2147. let Inst{6} = 0b1;
  2148. let Inst{4} = 0b0;
  2149. let Inst{0} = 0b0;
  2150. let validForTailPredication = 1;
  2151. }
  2152. multiclass MVE_VCLSCLZ_p<string opname, bit opcode, MVEVectorVTInfo VTI,
  2153. SDPatternOperator unpred_op> {
  2154. def "": MVE_VCLSCLZ<"v"#opname, VTI.Suffix, VTI.Size, opcode>;
  2155. defvar Inst = !cast<Instruction>(NAME);
  2156. defvar pred_int = !cast<Intrinsic>("int_arm_mve_"#opname#"_predicated");
  2157. let Predicates = [HasMVEInt] in {
  2158. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))),
  2159. (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>;
  2160. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred),
  2161. (VTI.Vec MQPR:$inactive))),
  2162. (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen,
  2163. (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
  2164. }
  2165. }
  2166. defm MVE_VCLSs8 : MVE_VCLSCLZ_p<"cls", 0, MVE_v16s8, int_arm_mve_vcls>;
  2167. defm MVE_VCLSs16 : MVE_VCLSCLZ_p<"cls", 0, MVE_v8s16, int_arm_mve_vcls>;
  2168. defm MVE_VCLSs32 : MVE_VCLSCLZ_p<"cls", 0, MVE_v4s32, int_arm_mve_vcls>;
  2169. defm MVE_VCLZs8 : MVE_VCLSCLZ_p<"clz", 1, MVE_v16i8, ctlz>;
  2170. defm MVE_VCLZs16 : MVE_VCLSCLZ_p<"clz", 1, MVE_v8i16, ctlz>;
  2171. defm MVE_VCLZs32 : MVE_VCLSCLZ_p<"clz", 1, MVE_v4i32, ctlz>;
  2172. class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate,
  2173. bit saturate, list<dag> pattern=[]>
  2174. : MVEIntSingleSrc<iname, suffix, size, pattern> {
  2175. let Inst{28} = 0b1;
  2176. let Inst{25-23} = 0b111;
  2177. let Inst{21-20} = 0b11;
  2178. let Inst{17} = 0b0;
  2179. let Inst{16} = !eq(saturate, 0);
  2180. let Inst{12-11} = 0b00;
  2181. let Inst{10} = saturate;
  2182. let Inst{9-8} = 0b11;
  2183. let Inst{7} = negate;
  2184. let Inst{6} = 0b1;
  2185. let Inst{4} = 0b0;
  2186. let Inst{0} = 0b0;
  2187. let validForTailPredication = 1;
  2188. }
  2189. multiclass MVE_VABSNEG_int_m<string iname, bit negate, bit saturate,
  2190. SDPatternOperator unpred_op, Intrinsic pred_int,
  2191. MVEVectorVTInfo VTI> {
  2192. def "" : MVE_VABSNEG_int<iname, VTI.Suffix, VTI.Size, negate, saturate>;
  2193. defvar Inst = !cast<Instruction>(NAME);
  2194. let Predicates = [HasMVEInt] in {
  2195. // VQABS and VQNEG have more difficult isel patterns defined elsewhere
  2196. if !not(saturate) then {
  2197. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))),
  2198. (VTI.Vec (Inst $v))>;
  2199. }
  2200. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask),
  2201. (VTI.Vec MQPR:$inactive))),
  2202. (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>;
  2203. }
  2204. }
  2205. foreach VTI = [ MVE_v16s8, MVE_v8s16, MVE_v4s32 ] in {
  2206. defm "MVE_VABS" # VTI.Suffix : MVE_VABSNEG_int_m<
  2207. "vabs", 0, 0, abs, int_arm_mve_abs_predicated, VTI>;
  2208. defm "MVE_VQABS" # VTI.Suffix : MVE_VABSNEG_int_m<
  2209. "vqabs", 0, 1, ?, int_arm_mve_qabs_predicated, VTI>;
  2210. defm "MVE_VNEG" # VTI.Suffix : MVE_VABSNEG_int_m<
  2211. "vneg", 1, 0, vnegq, int_arm_mve_neg_predicated, VTI>;
  2212. defm "MVE_VQNEG" # VTI.Suffix : MVE_VABSNEG_int_m<
  2213. "vqneg", 1, 1, ?, int_arm_mve_qneg_predicated, VTI>;
  2214. }
  2215. // int_min/int_max: vector containing INT_MIN/INT_MAX VTI.Size times
  2216. // zero_vec: v4i32-initialized zero vector, potentially wrapped in a bitconvert
  2217. multiclass vqabsneg_pattern<MVEVectorVTInfo VTI, dag int_min, dag int_max,
  2218. dag zero_vec, MVE_VABSNEG_int vqabs_instruction,
  2219. MVE_VABSNEG_int vqneg_instruction> {
  2220. let Predicates = [HasMVEInt] in {
  2221. // The below tree can be replaced by a vqabs instruction, as it represents
  2222. // the following vectorized expression (r being the value in $reg):
  2223. // r > 0 ? r : (r == INT_MIN ? INT_MAX : -r)
  2224. def : Pat<(VTI.Vec (vselect
  2225. (VTI.Pred (ARMvcmpz (VTI.Vec MQPR:$reg), ARMCCgt)),
  2226. (VTI.Vec MQPR:$reg),
  2227. (VTI.Vec (vselect
  2228. (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)),
  2229. int_max,
  2230. (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))))),
  2231. (VTI.Vec (vqabs_instruction (VTI.Vec MQPR:$reg)))>;
  2232. // Similarly, this tree represents vqneg, i.e. the following vectorized expression:
  2233. // r == INT_MIN ? INT_MAX : -r
  2234. def : Pat<(VTI.Vec (vselect
  2235. (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)),
  2236. int_max,
  2237. (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))),
  2238. (VTI.Vec (vqneg_instruction (VTI.Vec MQPR:$reg)))>;
  2239. }
  2240. }
  2241. defm MVE_VQABSNEG_Ps8 : vqabsneg_pattern<MVE_v16i8,
  2242. (v16i8 (ARMvmovImm (i32 3712))),
  2243. (v16i8 (ARMvmovImm (i32 3711))),
  2244. (bitconvert (v4i32 (ARMvmovImm (i32 0)))),
  2245. MVE_VQABSs8, MVE_VQNEGs8>;
  2246. defm MVE_VQABSNEG_Ps16 : vqabsneg_pattern<MVE_v8i16,
  2247. (v8i16 (ARMvmovImm (i32 2688))),
  2248. (v8i16 (ARMvmvnImm (i32 2688))),
  2249. (bitconvert (v4i32 (ARMvmovImm (i32 0)))),
  2250. MVE_VQABSs16, MVE_VQNEGs16>;
  2251. defm MVE_VQABSNEG_Ps32 : vqabsneg_pattern<MVE_v4i32,
  2252. (v4i32 (ARMvmovImm (i32 1664))),
  2253. (v4i32 (ARMvmvnImm (i32 1664))),
  2254. (ARMvmovImm (i32 0)),
  2255. MVE_VQABSs32, MVE_VQNEGs32>;
  2256. class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op,
  2257. dag iops, bits<2> vecsize, list<dag> pattern=[]>
  2258. : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm",
  2259. vpred_r, "", vecsize, pattern> {
  2260. bits<13> imm;
  2261. bits<4> Qd;
  2262. let Inst{28} = imm{7};
  2263. let Inst{25-23} = 0b111;
  2264. let Inst{22} = Qd{3};
  2265. let Inst{21-19} = 0b000;
  2266. let Inst{18-16} = imm{6-4};
  2267. let Inst{15-13} = Qd{2-0};
  2268. let Inst{12} = 0b0;
  2269. let Inst{11-8} = cmode{3-0};
  2270. let Inst{7-6} = 0b01;
  2271. let Inst{5} = op;
  2272. let Inst{4} = 0b1;
  2273. let Inst{3-0} = imm{3-0};
  2274. let DecoderMethod = "DecodeMVEModImmInstruction";
  2275. let validForTailPredication = 1;
  2276. }
  2277. let isReMaterializable = 1 in {
  2278. let isAsCheapAsAMove = 1 in {
  2279. def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm), 0b00>;
  2280. def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm), 0b01> {
  2281. let Inst{9} = imm{9};
  2282. }
  2283. def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm), 0b10> {
  2284. let Inst{11-8} = imm{11-8};
  2285. }
  2286. def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm), 0b11>;
  2287. def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm), 0b10>;
  2288. } // let isAsCheapAsAMove = 1
  2289. def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm), 0b01> {
  2290. let Inst{9} = imm{9};
  2291. }
  2292. def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm), 0b10> {
  2293. let Inst{11-8} = imm{11-8};
  2294. }
  2295. } // let isReMaterializable = 1
  2296. let Predicates = [HasMVEInt] in {
  2297. def : Pat<(v16i8 (ARMvmovImm timm:$simm)),
  2298. (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>;
  2299. def : Pat<(v8i16 (ARMvmovImm timm:$simm)),
  2300. (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>;
  2301. def : Pat<(v4i32 (ARMvmovImm timm:$simm)),
  2302. (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>;
  2303. def : Pat<(v2i64 (ARMvmovImm timm:$simm)),
  2304. (v2i64 (MVE_VMOVimmi64 nImmSplatI64:$simm))>;
  2305. def : Pat<(v8i16 (ARMvmvnImm timm:$simm)),
  2306. (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>;
  2307. def : Pat<(v4i32 (ARMvmvnImm timm:$simm)),
  2308. (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>;
  2309. def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)),
  2310. (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>;
  2311. def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (ARMvmvnImm timm:$simm),
  2312. MQPR:$inactive)),
  2313. (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm,
  2314. ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>;
  2315. def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (ARMvmvnImm timm:$simm),
  2316. MQPR:$inactive)),
  2317. (v4i32 (MVE_VMVNimmi32 nImmSplatI32:$simm,
  2318. ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>;
  2319. }
  2320. class MVE_VMINMAXA<string iname, string suffix, bits<2> size,
  2321. bit bit_12, list<dag> pattern=[]>
  2322. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
  2323. NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
  2324. size, pattern> {
  2325. bits<4> Qd;
  2326. bits<4> Qm;
  2327. let Inst{28} = 0b0;
  2328. let Inst{25-23} = 0b100;
  2329. let Inst{22} = Qd{3};
  2330. let Inst{21-20} = 0b11;
  2331. let Inst{19-18} = size;
  2332. let Inst{17-16} = 0b11;
  2333. let Inst{15-13} = Qd{2-0};
  2334. let Inst{12} = bit_12;
  2335. let Inst{11-6} = 0b111010;
  2336. let Inst{5} = Qm{3};
  2337. let Inst{4} = 0b0;
  2338. let Inst{3-1} = Qm{2-0};
  2339. let Inst{0} = 0b1;
  2340. let validForTailPredication = 1;
  2341. }
  2342. multiclass MVE_VMINMAXA_m<string iname, MVEVectorVTInfo VTI,
  2343. SDNode unpred_op, Intrinsic pred_int, bit bit_12> {
  2344. def "" : MVE_VMINMAXA<iname, VTI.Suffix, VTI.Size, bit_12>;
  2345. defvar Inst = !cast<Instruction>(NAME);
  2346. let Predicates = [HasMVEInt] in {
  2347. // Unpredicated v(min|max)a
  2348. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (abs (VTI.Vec MQPR:$Qm)))),
  2349. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
  2350. // Predicated v(min|max)a
  2351. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  2352. (VTI.Pred VCCR:$mask))),
  2353. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  2354. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  2355. }
  2356. }
  2357. multiclass MVE_VMINA<MVEVectorVTInfo VTI>
  2358. : MVE_VMINMAXA_m<"vmina", VTI, umin, int_arm_mve_vmina_predicated, 0b1>;
  2359. defm MVE_VMINAs8 : MVE_VMINA<MVE_v16s8>;
  2360. defm MVE_VMINAs16 : MVE_VMINA<MVE_v8s16>;
  2361. defm MVE_VMINAs32 : MVE_VMINA<MVE_v4s32>;
  2362. multiclass MVE_VMAXA<MVEVectorVTInfo VTI>
  2363. : MVE_VMINMAXA_m<"vmaxa", VTI, umax, int_arm_mve_vmaxa_predicated, 0b0>;
  2364. defm MVE_VMAXAs8 : MVE_VMAXA<MVE_v16s8>;
  2365. defm MVE_VMAXAs16 : MVE_VMAXA<MVE_v8s16>;
  2366. defm MVE_VMAXAs32 : MVE_VMAXA<MVE_v4s32>;
  2367. // end of MVE Integer instructions
  2368. // start of mve_imm_shift instructions
  2369. def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd),
  2370. (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm),
  2371. NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm",
  2372. vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc", 0b10> {
  2373. bits<5> imm;
  2374. bits<4> Qd;
  2375. bits<4> RdmDest;
  2376. let Inst{28} = 0b0;
  2377. let Inst{25-23} = 0b101;
  2378. let Inst{22} = Qd{3};
  2379. let Inst{21} = 0b1;
  2380. let Inst{20-16} = imm{4-0};
  2381. let Inst{15-13} = Qd{2-0};
  2382. let Inst{12-4} = 0b011111100;
  2383. let Inst{3-0} = RdmDest{3-0};
  2384. }
  2385. class MVE_shift_imm<dag oops, dag iops, string iname, string suffix,
  2386. string ops, vpred_ops vpred, string cstr,
  2387. bits<2> vecsize, list<dag> pattern=[]>
  2388. : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  2389. bits<4> Qd;
  2390. bits<4> Qm;
  2391. let Inst{22} = Qd{3};
  2392. let Inst{15-13} = Qd{2-0};
  2393. let Inst{5} = Qm{3};
  2394. let Inst{3-1} = Qm{2-0};
  2395. }
  2396. class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U, bit top,
  2397. list<dag> pattern=[]>
  2398. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
  2399. iname, suffix, "$Qd, $Qm", vpred_r, "",
  2400. sz, pattern> {
  2401. let Inst{28} = U;
  2402. let Inst{25-23} = 0b101;
  2403. let Inst{21} = 0b1;
  2404. let Inst{20-19} = sz{1-0};
  2405. let Inst{18-16} = 0b000;
  2406. let Inst{12} = top;
  2407. let Inst{11-6} = 0b111101;
  2408. let Inst{4} = 0b0;
  2409. let Inst{0} = 0b0;
  2410. let doubleWidthResult = 1;
  2411. }
  2412. multiclass MVE_VMOVL_m<bit top, string chr, MVEVectorVTInfo OutVTI,
  2413. MVEVectorVTInfo InVTI> {
  2414. def "": MVE_VMOVL<"vmovl" # chr, InVTI.Suffix, OutVTI.Size,
  2415. InVTI.Unsigned, top>;
  2416. defvar Inst = !cast<Instruction>(NAME);
  2417. def : Pat<(OutVTI.Vec (int_arm_mve_vmovl_predicated (InVTI.Vec MQPR:$src),
  2418. (i32 InVTI.Unsigned), (i32 top),
  2419. (OutVTI.Pred VCCR:$pred),
  2420. (OutVTI.Vec MQPR:$inactive))),
  2421. (OutVTI.Vec (Inst (InVTI.Vec MQPR:$src), ARMVCCThen,
  2422. (OutVTI.Pred VCCR:$pred), zero_reg,
  2423. (OutVTI.Vec MQPR:$inactive)))>;
  2424. }
  2425. defm MVE_VMOVLs8bh : MVE_VMOVL_m<0, "b", MVE_v8s16, MVE_v16s8>;
  2426. defm MVE_VMOVLs8th : MVE_VMOVL_m<1, "t", MVE_v8s16, MVE_v16s8>;
  2427. defm MVE_VMOVLu8bh : MVE_VMOVL_m<0, "b", MVE_v8u16, MVE_v16u8>;
  2428. defm MVE_VMOVLu8th : MVE_VMOVL_m<1, "t", MVE_v8u16, MVE_v16u8>;
  2429. defm MVE_VMOVLs16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8s16>;
  2430. defm MVE_VMOVLs16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8s16>;
  2431. defm MVE_VMOVLu16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8u16>;
  2432. defm MVE_VMOVLu16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8u16>;
  2433. let Predicates = [HasMVEInt] in {
  2434. def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16),
  2435. (MVE_VMOVLs16bh MQPR:$src)>;
  2436. def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8),
  2437. (MVE_VMOVLs8bh MQPR:$src)>;
  2438. def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8),
  2439. (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>;
  2440. def : Pat<(sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), v8i8),
  2441. (MVE_VMOVLs8th MQPR:$src)>;
  2442. def : Pat<(sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))), v4i16),
  2443. (MVE_VMOVLs16th MQPR:$src)>;
  2444. // zext_inreg 8 -> 16
  2445. def : Pat<(ARMvbicImm (v8i16 MQPR:$src), (i32 0xAFF)),
  2446. (MVE_VMOVLu8bh MQPR:$src)>;
  2447. // zext_inreg 16 -> 32
  2448. def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))),
  2449. (MVE_VMOVLu16bh MQPR:$src)>;
  2450. // Same zext_inreg with vrevs, picking the top half
  2451. def : Pat<(ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), (i32 0xAFF)),
  2452. (MVE_VMOVLu8th MQPR:$src)>;
  2453. def : Pat<(and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))),
  2454. (v4i32 (ARMvmovImm (i32 0xCFF)))),
  2455. (MVE_VMOVLu16th MQPR:$src)>;
  2456. }
  2457. class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th,
  2458. Operand immtype, bits<2> vecsize, list<dag> pattern=[]>
  2459. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm, immtype:$imm),
  2460. iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", vecsize, pattern> {
  2461. let Inst{28} = U;
  2462. let Inst{25-23} = 0b101;
  2463. let Inst{21} = 0b1;
  2464. let Inst{12} = th;
  2465. let Inst{11-6} = 0b111101;
  2466. let Inst{4} = 0b0;
  2467. let Inst{0} = 0b0;
  2468. // For the MVE_VSHLL_patterns multiclass to refer to
  2469. Operand immediateType = immtype;
  2470. let doubleWidthResult = 1;
  2471. }
  2472. // The immediate VSHLL instructions accept shift counts from 1 up to
  2473. // the lane width (8 or 16), but the full-width shifts have an
  2474. // entirely separate encoding, given below with 'lw' in the name.
  2475. class MVE_VSHLL_imm8<string iname, string suffix,
  2476. bit U, bit th, list<dag> pattern=[]>
  2477. : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_7, 0b01, pattern> {
  2478. bits<3> imm;
  2479. let Inst{20-19} = 0b01;
  2480. let Inst{18-16} = imm;
  2481. }
  2482. class MVE_VSHLL_imm16<string iname, string suffix,
  2483. bit U, bit th, list<dag> pattern=[]>
  2484. : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_15, 0b10, pattern> {
  2485. bits<4> imm;
  2486. let Inst{20} = 0b1;
  2487. let Inst{19-16} = imm;
  2488. }
  2489. def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>;
  2490. def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>;
  2491. def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>;
  2492. def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>;
  2493. def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>;
  2494. def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>;
  2495. def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>;
  2496. def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>;
  2497. class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size,
  2498. bit U, string ops, list<dag> pattern=[]>
  2499. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
  2500. iname, suffix, ops, vpred_r, "", !if(size, 0b10, 0b01), pattern> {
  2501. let Inst{28} = U;
  2502. let Inst{25-23} = 0b100;
  2503. let Inst{21-20} = 0b11;
  2504. let Inst{19-18} = size{1-0};
  2505. let Inst{17-16} = 0b01;
  2506. let Inst{11-6} = 0b111000;
  2507. let Inst{4} = 0b0;
  2508. let Inst{0} = 0b1;
  2509. let doubleWidthResult = 1;
  2510. }
  2511. multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U,
  2512. string ops, list<dag> pattern=[]> {
  2513. def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> {
  2514. let Inst{12} = 0b0;
  2515. }
  2516. def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> {
  2517. let Inst{12} = 0b1;
  2518. }
  2519. }
  2520. defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">;
  2521. defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">;
  2522. defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">;
  2523. defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">;
  2524. multiclass MVE_VSHLL_patterns<MVEVectorVTInfo VTI, int top> {
  2525. defvar suffix = !strconcat(VTI.Suffix, !if(top, "th", "bh"));
  2526. defvar inst_imm = !cast<MVE_VSHLL_imm>("MVE_VSHLL_imm" # suffix);
  2527. defvar inst_lw = !cast<MVE_VSHLL_by_lane_width>("MVE_VSHLL_lw" # suffix);
  2528. defvar unpred_int = int_arm_mve_vshll_imm;
  2529. defvar pred_int = int_arm_mve_vshll_imm_predicated;
  2530. defvar imm = inst_imm.immediateType;
  2531. def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), imm:$imm,
  2532. (i32 VTI.Unsigned), (i32 top))),
  2533. (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm))>;
  2534. def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits),
  2535. (i32 VTI.Unsigned), (i32 top))),
  2536. (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src)))>;
  2537. def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), imm:$imm,
  2538. (i32 VTI.Unsigned), (i32 top),
  2539. (VTI.DblPred VCCR:$mask),
  2540. (VTI.DblVec MQPR:$inactive))),
  2541. (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm,
  2542. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  2543. (VTI.DblVec MQPR:$inactive)))>;
  2544. def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits),
  2545. (i32 VTI.Unsigned), (i32 top),
  2546. (VTI.DblPred VCCR:$mask),
  2547. (VTI.DblVec MQPR:$inactive))),
  2548. (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src), ARMVCCThen,
  2549. (VTI.DblPred VCCR:$mask), zero_reg,
  2550. (VTI.DblVec MQPR:$inactive)))>;
  2551. }
  2552. foreach VTI = [MVE_v16s8, MVE_v8s16, MVE_v16u8, MVE_v8u16] in
  2553. foreach top = [0, 1] in
  2554. defm : MVE_VSHLL_patterns<VTI, top>;
  2555. class MVE_shift_imm_partial<Operand imm, string iname, string suffix, bits<2> vecsize>
  2556. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$QdSrc, MQPR:$Qm, imm:$imm),
  2557. iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc", vecsize> {
  2558. Operand immediateType = imm;
  2559. }
  2560. class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28,
  2561. Operand imm, bits<2> vecsize>
  2562. : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
  2563. bits<5> imm;
  2564. let Inst{28} = bit_28;
  2565. let Inst{25-23} = 0b101;
  2566. let Inst{21} = 0b0;
  2567. let Inst{20-16} = imm{4-0};
  2568. let Inst{12} = bit_12;
  2569. let Inst{11-6} = 0b111111;
  2570. let Inst{4} = 0b0;
  2571. let Inst{0} = 0b1;
  2572. let validForTailPredication = 1;
  2573. let retainsPreviousHalfElement = 1;
  2574. }
  2575. def MVE_VRSHRNi16bh : MVE_VxSHRN<"vrshrnb", "i16", 0b0, 0b1, shr_imm8, 0b01> {
  2576. let Inst{20-19} = 0b01;
  2577. }
  2578. def MVE_VRSHRNi16th : MVE_VxSHRN<"vrshrnt", "i16", 0b1, 0b1, shr_imm8, 0b01> {
  2579. let Inst{20-19} = 0b01;
  2580. }
  2581. def MVE_VRSHRNi32bh : MVE_VxSHRN<"vrshrnb", "i32", 0b0, 0b1, shr_imm16, 0b10> {
  2582. let Inst{20} = 0b1;
  2583. }
  2584. def MVE_VRSHRNi32th : MVE_VxSHRN<"vrshrnt", "i32", 0b1, 0b1, shr_imm16, 0b10> {
  2585. let Inst{20} = 0b1;
  2586. }
  2587. def MVE_VSHRNi16bh : MVE_VxSHRN<"vshrnb", "i16", 0b0, 0b0, shr_imm8, 0b01> {
  2588. let Inst{20-19} = 0b01;
  2589. }
  2590. def MVE_VSHRNi16th : MVE_VxSHRN<"vshrnt", "i16", 0b1, 0b0, shr_imm8, 0b01> {
  2591. let Inst{20-19} = 0b01;
  2592. }
  2593. def MVE_VSHRNi32bh : MVE_VxSHRN<"vshrnb", "i32", 0b0, 0b0, shr_imm16, 0b10> {
  2594. let Inst{20} = 0b1;
  2595. }
  2596. def MVE_VSHRNi32th : MVE_VxSHRN<"vshrnt", "i32", 0b1, 0b0, shr_imm16, 0b10> {
  2597. let Inst{20} = 0b1;
  2598. }
  2599. class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12,
  2600. Operand imm, bits<2> vecsize>
  2601. : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
  2602. bits<5> imm;
  2603. let Inst{28} = bit_28;
  2604. let Inst{25-23} = 0b101;
  2605. let Inst{21} = 0b0;
  2606. let Inst{20-16} = imm{4-0};
  2607. let Inst{12} = bit_12;
  2608. let Inst{11-6} = 0b111111;
  2609. let Inst{4} = 0b0;
  2610. let Inst{0} = 0b0;
  2611. let validForTailPredication = 1;
  2612. let retainsPreviousHalfElement = 1;
  2613. }
  2614. def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN<
  2615. "vqrshrunb", "s16", 0b1, 0b0, shr_imm8, 0b01> {
  2616. let Inst{20-19} = 0b01;
  2617. }
  2618. def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN<
  2619. "vqrshrunt", "s16", 0b1, 0b1, shr_imm8, 0b01> {
  2620. let Inst{20-19} = 0b01;
  2621. }
  2622. def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN<
  2623. "vqrshrunb", "s32", 0b1, 0b0, shr_imm16, 0b10> {
  2624. let Inst{20} = 0b1;
  2625. }
  2626. def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN<
  2627. "vqrshrunt", "s32", 0b1, 0b1, shr_imm16, 0b10> {
  2628. let Inst{20} = 0b1;
  2629. }
  2630. def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN<
  2631. "vqshrunb", "s16", 0b0, 0b0, shr_imm8, 0b01> {
  2632. let Inst{20-19} = 0b01;
  2633. }
  2634. def MVE_VQSHRUNs16th : MVE_VxQRSHRUN<
  2635. "vqshrunt", "s16", 0b0, 0b1, shr_imm8, 0b01> {
  2636. let Inst{20-19} = 0b01;
  2637. }
  2638. def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN<
  2639. "vqshrunb", "s32", 0b0, 0b0, shr_imm16, 0b10> {
  2640. let Inst{20} = 0b1;
  2641. }
  2642. def MVE_VQSHRUNs32th : MVE_VxQRSHRUN<
  2643. "vqshrunt", "s32", 0b0, 0b1, shr_imm16, 0b10> {
  2644. let Inst{20} = 0b1;
  2645. }
  2646. class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12,
  2647. Operand imm, bits<2> vecsize>
  2648. : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
  2649. bits<5> imm;
  2650. let Inst{25-23} = 0b101;
  2651. let Inst{21} = 0b0;
  2652. let Inst{20-16} = imm{4-0};
  2653. let Inst{12} = bit_12;
  2654. let Inst{11-6} = 0b111101;
  2655. let Inst{4} = 0b0;
  2656. let Inst{0} = bit_0;
  2657. let validForTailPredication = 1;
  2658. let retainsPreviousHalfElement = 1;
  2659. }
  2660. multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> {
  2661. def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, shr_imm8, 0b01> {
  2662. let Inst{28} = 0b0;
  2663. let Inst{20-19} = 0b01;
  2664. }
  2665. def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, shr_imm8, 0b01> {
  2666. let Inst{28} = 0b1;
  2667. let Inst{20-19} = 0b01;
  2668. }
  2669. def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, shr_imm16, 0b10> {
  2670. let Inst{28} = 0b0;
  2671. let Inst{20} = 0b1;
  2672. }
  2673. def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, shr_imm16, 0b10> {
  2674. let Inst{28} = 0b1;
  2675. let Inst{20} = 0b1;
  2676. }
  2677. }
  2678. defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>;
  2679. defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>;
  2680. defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>;
  2681. defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>;
  2682. multiclass MVE_VSHRN_patterns<MVE_shift_imm_partial inst,
  2683. MVEVectorVTInfo OutVTI, MVEVectorVTInfo InVTI,
  2684. bit q, bit r, bit top> {
  2685. defvar inparams = (? (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm),
  2686. (inst.immediateType:$imm), (i32 q), (i32 r),
  2687. (i32 OutVTI.Unsigned), (i32 InVTI.Unsigned), (i32 top));
  2688. defvar outparams = (inst (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm),
  2689. (imm:$imm));
  2690. def : Pat<(OutVTI.Vec !setdagop(inparams, int_arm_mve_vshrn)),
  2691. (OutVTI.Vec outparams)>;
  2692. def : Pat<(OutVTI.Vec !con(inparams, (int_arm_mve_vshrn_predicated
  2693. (InVTI.Pred VCCR:$pred)))),
  2694. (OutVTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>;
  2695. }
  2696. defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,0,0>;
  2697. defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16s8, MVE_v8s16, 0,0,1>;
  2698. defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,0,0>;
  2699. defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8s16, MVE_v4s32, 0,0,1>;
  2700. defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,0,0>;
  2701. defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16u8, MVE_v8u16, 0,0,1>;
  2702. defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,0,0>;
  2703. defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8u16, MVE_v4u32, 0,0,1>;
  2704. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,1,0>;
  2705. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16s8, MVE_v8s16, 0,1,1>;
  2706. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,1,0>;
  2707. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8s16, MVE_v4s32, 0,1,1>;
  2708. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,1,0>;
  2709. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16u8, MVE_v8u16, 0,1,1>;
  2710. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,1,0>;
  2711. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8u16, MVE_v4u32, 0,1,1>;
  2712. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,0,0>;
  2713. defm : MVE_VSHRN_patterns<MVE_VQSHRNths16, MVE_v16s8, MVE_v8s16, 1,0,1>;
  2714. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,0,0>;
  2715. defm : MVE_VSHRN_patterns<MVE_VQSHRNths32, MVE_v8s16, MVE_v4s32, 1,0,1>;
  2716. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,0,0>;
  2717. defm : MVE_VSHRN_patterns<MVE_VQSHRNthu16, MVE_v16u8, MVE_v8u16, 1,0,1>;
  2718. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,0,0>;
  2719. defm : MVE_VSHRN_patterns<MVE_VQSHRNthu32, MVE_v8u16, MVE_v4u32, 1,0,1>;
  2720. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,1,0>;
  2721. defm : MVE_VSHRN_patterns<MVE_VQRSHRNths16, MVE_v16s8, MVE_v8s16, 1,1,1>;
  2722. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,1,0>;
  2723. defm : MVE_VSHRN_patterns<MVE_VQRSHRNths32, MVE_v8s16, MVE_v4s32, 1,1,1>;
  2724. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,1,0>;
  2725. defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu16, MVE_v16u8, MVE_v8u16, 1,1,1>;
  2726. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,1,0>;
  2727. defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu32, MVE_v8u16, MVE_v4u32, 1,1,1>;
  2728. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,0,0>;
  2729. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,0,1>;
  2730. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,0,0>;
  2731. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,0,1>;
  2732. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,1,0>;
  2733. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,1,1>;
  2734. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,1,0>;
  2735. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,1,1>;
  2736. // end of mve_imm_shift instructions
  2737. // start of mve_shift instructions
  2738. class MVE_shift_by_vec<string iname, string suffix, bit U,
  2739. bits<2> size, bit bit_4, bit bit_8>
  2740. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary,
  2741. iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", size, []> {
  2742. // Shift instructions which take a vector of shift counts
  2743. bits<4> Qd;
  2744. bits<4> Qm;
  2745. bits<4> Qn;
  2746. let Inst{28} = U;
  2747. let Inst{25-24} = 0b11;
  2748. let Inst{23} = 0b0;
  2749. let Inst{22} = Qd{3};
  2750. let Inst{21-20} = size;
  2751. let Inst{19-17} = Qn{2-0};
  2752. let Inst{16} = 0b0;
  2753. let Inst{15-13} = Qd{2-0};
  2754. let Inst{12-9} = 0b0010;
  2755. let Inst{8} = bit_8;
  2756. let Inst{7} = Qn{3};
  2757. let Inst{6} = 0b1;
  2758. let Inst{5} = Qm{3};
  2759. let Inst{4} = bit_4;
  2760. let Inst{3-1} = Qm{2-0};
  2761. let Inst{0} = 0b0;
  2762. let validForTailPredication = 1;
  2763. }
  2764. multiclass MVE_shift_by_vec_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> {
  2765. def "" : MVE_shift_by_vec<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>;
  2766. defvar Inst = !cast<Instruction>(NAME);
  2767. def : Pat<(VTI.Vec (int_arm_mve_vshl_vector
  2768. (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
  2769. (i32 q), (i32 r), (i32 VTI.Unsigned))),
  2770. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh)))>;
  2771. def : Pat<(VTI.Vec (int_arm_mve_vshl_vector_predicated
  2772. (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
  2773. (i32 q), (i32 r), (i32 VTI.Unsigned),
  2774. (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
  2775. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
  2776. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  2777. (VTI.Vec MQPR:$inactive)))>;
  2778. }
  2779. multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> {
  2780. defm s8 : MVE_shift_by_vec_p<iname, MVE_v16s8, bit_4, bit_8>;
  2781. defm s16 : MVE_shift_by_vec_p<iname, MVE_v8s16, bit_4, bit_8>;
  2782. defm s32 : MVE_shift_by_vec_p<iname, MVE_v4s32, bit_4, bit_8>;
  2783. defm u8 : MVE_shift_by_vec_p<iname, MVE_v16u8, bit_4, bit_8>;
  2784. defm u16 : MVE_shift_by_vec_p<iname, MVE_v8u16, bit_4, bit_8>;
  2785. defm u32 : MVE_shift_by_vec_p<iname, MVE_v4u32, bit_4, bit_8>;
  2786. }
  2787. defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>;
  2788. defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>;
  2789. defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>;
  2790. defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>;
  2791. let Predicates = [HasMVEInt] in {
  2792. def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
  2793. (v4i32 (MVE_VSHL_by_vecu32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
  2794. def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
  2795. (v8i16 (MVE_VSHL_by_vecu16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
  2796. def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
  2797. (v16i8 (MVE_VSHL_by_vecu8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
  2798. def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
  2799. (v4i32 (MVE_VSHL_by_vecs32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
  2800. def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
  2801. (v8i16 (MVE_VSHL_by_vecs16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
  2802. def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
  2803. (v16i8 (MVE_VSHL_by_vecs8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
  2804. }
  2805. class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops,
  2806. string ops, vpred_ops vpred, string cstr,
  2807. bits<2> vecsize, list<dag> pattern=[]>
  2808. : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  2809. bits<4> Qd;
  2810. bits<4> Qm;
  2811. let Inst{23} = 0b1;
  2812. let Inst{22} = Qd{3};
  2813. let Inst{15-13} = Qd{2-0};
  2814. let Inst{12-11} = 0b00;
  2815. let Inst{7-6} = 0b01;
  2816. let Inst{5} = Qm{3};
  2817. let Inst{4} = 0b1;
  2818. let Inst{3-1} = Qm{2-0};
  2819. let Inst{0} = 0b0;
  2820. let validForTailPredication = 1;
  2821. // For the MVE_shift_imm_patterns multiclass to refer to
  2822. MVEVectorVTInfo VTI;
  2823. Operand immediateType;
  2824. Intrinsic unpred_int;
  2825. Intrinsic pred_int;
  2826. dag unsignedFlag = (?);
  2827. }
  2828. class MVE_VSxI_imm<string iname, string suffix, bit bit_8, Operand immType, bits<2> vecsize>
  2829. : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd),
  2830. (ins MQPR:$Qd_src, MQPR:$Qm, immType:$imm),
  2831. "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src", vecsize> {
  2832. bits<6> imm;
  2833. let Inst{28} = 0b1;
  2834. let Inst{25-24} = 0b11;
  2835. let Inst{21-16} = imm;
  2836. let Inst{10-9} = 0b10;
  2837. let Inst{8} = bit_8;
  2838. let validForTailPredication = 1;
  2839. Operand immediateType = immType;
  2840. }
  2841. def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, shr_imm8, 0b00> {
  2842. let Inst{21-19} = 0b001;
  2843. }
  2844. def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, shr_imm16, 0b01> {
  2845. let Inst{21-20} = 0b01;
  2846. }
  2847. def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, shr_imm32, 0b10> {
  2848. let Inst{21} = 0b1;
  2849. }
  2850. def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, imm0_7, 0b00> {
  2851. let Inst{21-19} = 0b001;
  2852. }
  2853. def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, imm0_15, 0b01> {
  2854. let Inst{21-20} = 0b01;
  2855. }
  2856. def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,imm0_31, 0b10> {
  2857. let Inst{21} = 0b1;
  2858. }
  2859. multiclass MVE_VSxI_patterns<MVE_VSxI_imm inst, string name,
  2860. MVEVectorVTInfo VTI> {
  2861. defvar inparams = (? (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm),
  2862. (inst.immediateType:$imm));
  2863. defvar outparams = (inst (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm),
  2864. (inst.immediateType:$imm));
  2865. defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # name);
  2866. defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # name # "_predicated");
  2867. def : Pat<(VTI.Vec !setdagop(inparams, unpred_int)),
  2868. (VTI.Vec outparams)>;
  2869. def : Pat<(VTI.Vec !con(inparams, (pred_int (VTI.Pred VCCR:$pred)))),
  2870. (VTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>;
  2871. }
  2872. defm : MVE_VSxI_patterns<MVE_VSLIimm8, "vsli", MVE_v16i8>;
  2873. defm : MVE_VSxI_patterns<MVE_VSLIimm16, "vsli", MVE_v8i16>;
  2874. defm : MVE_VSxI_patterns<MVE_VSLIimm32, "vsli", MVE_v4i32>;
  2875. defm : MVE_VSxI_patterns<MVE_VSRIimm8, "vsri", MVE_v16i8>;
  2876. defm : MVE_VSxI_patterns<MVE_VSRIimm16, "vsri", MVE_v8i16>;
  2877. defm : MVE_VSxI_patterns<MVE_VSRIimm32, "vsri", MVE_v4i32>;
  2878. class MVE_VQSHL_imm<MVEVectorVTInfo VTI_, Operand immType>
  2879. : MVE_shift_with_imm<"vqshl", VTI_.Suffix, (outs MQPR:$Qd),
  2880. (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
  2881. vpred_r, "", VTI_.Size> {
  2882. bits<6> imm;
  2883. let Inst{28} = VTI_.Unsigned;
  2884. let Inst{25-24} = 0b11;
  2885. let Inst{21-16} = imm;
  2886. let Inst{10-8} = 0b111;
  2887. let VTI = VTI_;
  2888. let immediateType = immType;
  2889. let unsignedFlag = (? (i32 VTI.Unsigned));
  2890. }
  2891. let unpred_int = int_arm_mve_vqshl_imm,
  2892. pred_int = int_arm_mve_vqshl_imm_predicated in {
  2893. def MVE_VQSHLimms8 : MVE_VQSHL_imm<MVE_v16s8, imm0_7> {
  2894. let Inst{21-19} = 0b001;
  2895. }
  2896. def MVE_VQSHLimmu8 : MVE_VQSHL_imm<MVE_v16u8, imm0_7> {
  2897. let Inst{21-19} = 0b001;
  2898. }
  2899. def MVE_VQSHLimms16 : MVE_VQSHL_imm<MVE_v8s16, imm0_15> {
  2900. let Inst{21-20} = 0b01;
  2901. }
  2902. def MVE_VQSHLimmu16 : MVE_VQSHL_imm<MVE_v8u16, imm0_15> {
  2903. let Inst{21-20} = 0b01;
  2904. }
  2905. def MVE_VQSHLimms32 : MVE_VQSHL_imm<MVE_v4s32, imm0_31> {
  2906. let Inst{21} = 0b1;
  2907. }
  2908. def MVE_VQSHLimmu32 : MVE_VQSHL_imm<MVE_v4u32, imm0_31> {
  2909. let Inst{21} = 0b1;
  2910. }
  2911. }
  2912. class MVE_VQSHLU_imm<MVEVectorVTInfo VTI_, Operand immType>
  2913. : MVE_shift_with_imm<"vqshlu", VTI_.Suffix, (outs MQPR:$Qd),
  2914. (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
  2915. vpred_r, "", VTI_.Size> {
  2916. bits<6> imm;
  2917. let Inst{28} = 0b1;
  2918. let Inst{25-24} = 0b11;
  2919. let Inst{21-16} = imm;
  2920. let Inst{10-8} = 0b110;
  2921. let VTI = VTI_;
  2922. let immediateType = immType;
  2923. }
  2924. let unpred_int = int_arm_mve_vqshlu_imm,
  2925. pred_int = int_arm_mve_vqshlu_imm_predicated in {
  2926. def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<MVE_v16s8, imm0_7> {
  2927. let Inst{21-19} = 0b001;
  2928. }
  2929. def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<MVE_v8s16, imm0_15> {
  2930. let Inst{21-20} = 0b01;
  2931. }
  2932. def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<MVE_v4s32, imm0_31> {
  2933. let Inst{21} = 0b1;
  2934. }
  2935. }
  2936. class MVE_VRSHR_imm<MVEVectorVTInfo VTI_, Operand immType>
  2937. : MVE_shift_with_imm<"vrshr", VTI_.Suffix, (outs MQPR:$Qd),
  2938. (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
  2939. vpred_r, "", VTI_.Size> {
  2940. bits<6> imm;
  2941. let Inst{28} = VTI_.Unsigned;
  2942. let Inst{25-24} = 0b11;
  2943. let Inst{21-16} = imm;
  2944. let Inst{10-8} = 0b010;
  2945. let VTI = VTI_;
  2946. let immediateType = immType;
  2947. let unsignedFlag = (? (i32 VTI.Unsigned));
  2948. }
  2949. let unpred_int = int_arm_mve_vrshr_imm,
  2950. pred_int = int_arm_mve_vrshr_imm_predicated in {
  2951. def MVE_VRSHR_imms8 : MVE_VRSHR_imm<MVE_v16s8, shr_imm8> {
  2952. let Inst{21-19} = 0b001;
  2953. }
  2954. def MVE_VRSHR_immu8 : MVE_VRSHR_imm<MVE_v16u8, shr_imm8> {
  2955. let Inst{21-19} = 0b001;
  2956. }
  2957. def MVE_VRSHR_imms16 : MVE_VRSHR_imm<MVE_v8s16, shr_imm16> {
  2958. let Inst{21-20} = 0b01;
  2959. }
  2960. def MVE_VRSHR_immu16 : MVE_VRSHR_imm<MVE_v8u16, shr_imm16> {
  2961. let Inst{21-20} = 0b01;
  2962. }
  2963. def MVE_VRSHR_imms32 : MVE_VRSHR_imm<MVE_v4s32, shr_imm32> {
  2964. let Inst{21} = 0b1;
  2965. }
  2966. def MVE_VRSHR_immu32 : MVE_VRSHR_imm<MVE_v4u32, shr_imm32> {
  2967. let Inst{21} = 0b1;
  2968. }
  2969. }
  2970. multiclass MVE_shift_imm_patterns<MVE_shift_with_imm inst> {
  2971. def : Pat<(inst.VTI.Vec !con((inst.unpred_int (inst.VTI.Vec MQPR:$src),
  2972. inst.immediateType:$imm),
  2973. inst.unsignedFlag)),
  2974. (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src),
  2975. inst.immediateType:$imm))>;
  2976. def : Pat<(inst.VTI.Vec !con((inst.pred_int (inst.VTI.Vec MQPR:$src),
  2977. inst.immediateType:$imm),
  2978. inst.unsignedFlag,
  2979. (? (inst.VTI.Pred VCCR:$mask),
  2980. (inst.VTI.Vec MQPR:$inactive)))),
  2981. (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src),
  2982. inst.immediateType:$imm,
  2983. ARMVCCThen, (inst.VTI.Pred VCCR:$mask), zero_reg,
  2984. (inst.VTI.Vec MQPR:$inactive)))>;
  2985. }
  2986. defm : MVE_shift_imm_patterns<MVE_VQSHLimms8>;
  2987. defm : MVE_shift_imm_patterns<MVE_VQSHLimmu8>;
  2988. defm : MVE_shift_imm_patterns<MVE_VQSHLimms16>;
  2989. defm : MVE_shift_imm_patterns<MVE_VQSHLimmu16>;
  2990. defm : MVE_shift_imm_patterns<MVE_VQSHLimms32>;
  2991. defm : MVE_shift_imm_patterns<MVE_VQSHLimmu32>;
  2992. defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms8>;
  2993. defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms16>;
  2994. defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms32>;
  2995. defm : MVE_shift_imm_patterns<MVE_VRSHR_imms8>;
  2996. defm : MVE_shift_imm_patterns<MVE_VRSHR_immu8>;
  2997. defm : MVE_shift_imm_patterns<MVE_VRSHR_imms16>;
  2998. defm : MVE_shift_imm_patterns<MVE_VRSHR_immu16>;
  2999. defm : MVE_shift_imm_patterns<MVE_VRSHR_imms32>;
  3000. defm : MVE_shift_imm_patterns<MVE_VRSHR_immu32>;
  3001. class MVE_VSHR_imm<string suffix, dag imm, bits<2> vecsize>
  3002. : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd),
  3003. !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
  3004. vpred_r, "", vecsize> {
  3005. bits<6> imm;
  3006. let Inst{25-24} = 0b11;
  3007. let Inst{21-16} = imm;
  3008. let Inst{10-8} = 0b000;
  3009. }
  3010. def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm), 0b00> {
  3011. let Inst{28} = 0b0;
  3012. let Inst{21-19} = 0b001;
  3013. }
  3014. def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm), 0b00> {
  3015. let Inst{28} = 0b1;
  3016. let Inst{21-19} = 0b001;
  3017. }
  3018. def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm), 0b01> {
  3019. let Inst{28} = 0b0;
  3020. let Inst{21-20} = 0b01;
  3021. }
  3022. def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm), 0b01> {
  3023. let Inst{28} = 0b1;
  3024. let Inst{21-20} = 0b01;
  3025. }
  3026. def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm), 0b10> {
  3027. let Inst{28} = 0b0;
  3028. let Inst{21} = 0b1;
  3029. }
  3030. def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm), 0b10> {
  3031. let Inst{28} = 0b1;
  3032. let Inst{21} = 0b1;
  3033. }
  3034. class MVE_VSHL_imm<string suffix, dag imm, bits<2> vecsize>
  3035. : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd),
  3036. !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
  3037. vpred_r, "", vecsize> {
  3038. bits<6> imm;
  3039. let Inst{28} = 0b0;
  3040. let Inst{25-24} = 0b11;
  3041. let Inst{21-16} = imm;
  3042. let Inst{10-8} = 0b101;
  3043. }
  3044. def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm), 0b00> {
  3045. let Inst{21-19} = 0b001;
  3046. }
  3047. def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm), 0b01> {
  3048. let Inst{21-20} = 0b01;
  3049. }
  3050. def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm), 0b10> {
  3051. let Inst{21} = 0b1;
  3052. }
  3053. multiclass MVE_immediate_shift_patterns_inner<
  3054. MVEVectorVTInfo VTI, Operand imm_operand_type, SDNode unpred_op,
  3055. Intrinsic pred_int, Instruction inst, list<int> unsignedFlag = []> {
  3056. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src), imm_operand_type:$imm)),
  3057. (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm))>;
  3058. def : Pat<(VTI.Vec !con((pred_int (VTI.Vec MQPR:$src), imm_operand_type:$imm),
  3059. !dag(pred_int, unsignedFlag, ?),
  3060. (pred_int (VTI.Pred VCCR:$mask),
  3061. (VTI.Vec MQPR:$inactive)))),
  3062. (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm,
  3063. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  3064. (VTI.Vec MQPR:$inactive)))>;
  3065. }
  3066. multiclass MVE_immediate_shift_patterns<MVEVectorVTInfo VTI,
  3067. Operand imm_operand_type> {
  3068. defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
  3069. ARMvshlImm, int_arm_mve_shl_imm_predicated,
  3070. !cast<Instruction>("MVE_VSHL_immi" # VTI.BitsSuffix)>;
  3071. defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
  3072. ARMvshruImm, int_arm_mve_shr_imm_predicated,
  3073. !cast<Instruction>("MVE_VSHR_immu" # VTI.BitsSuffix), [1]>;
  3074. defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
  3075. ARMvshrsImm, int_arm_mve_shr_imm_predicated,
  3076. !cast<Instruction>("MVE_VSHR_imms" # VTI.BitsSuffix), [0]>;
  3077. }
  3078. let Predicates = [HasMVEInt] in {
  3079. defm : MVE_immediate_shift_patterns<MVE_v16i8, imm0_7>;
  3080. defm : MVE_immediate_shift_patterns<MVE_v8i16, imm0_15>;
  3081. defm : MVE_immediate_shift_patterns<MVE_v4i32, imm0_31>;
  3082. }
  3083. // end of mve_shift instructions
  3084. // start of MVE Floating Point instructions
  3085. class MVE_float<string iname, string suffix, dag oops, dag iops, string ops,
  3086. vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  3087. : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  3088. bits<4> Qm;
  3089. let Inst{12} = 0b0;
  3090. let Inst{6} = 0b1;
  3091. let Inst{5} = Qm{3};
  3092. let Inst{3-1} = Qm{2-0};
  3093. let Inst{0} = 0b0;
  3094. }
  3095. class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size,
  3096. list<dag> pattern=[]>
  3097. : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd),
  3098. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3099. bits<4> Qd;
  3100. let Inst{28} = 0b1;
  3101. let Inst{25-23} = 0b111;
  3102. let Inst{22} = Qd{3};
  3103. let Inst{21-20} = 0b11;
  3104. let Inst{19-18} = size;
  3105. let Inst{17-16} = 0b10;
  3106. let Inst{15-13} = Qd{2-0};
  3107. let Inst{11-10} = 0b01;
  3108. let Inst{9-7} = op{2-0};
  3109. let Inst{4} = 0b0;
  3110. let validForTailPredication = 1;
  3111. }
  3112. multiclass MVE_VRINT_m<MVEVectorVTInfo VTI, string suffix, bits<3> opcode,
  3113. SDPatternOperator unpred_op> {
  3114. def "": MVE_VRINT<suffix, opcode, VTI.Suffix, VTI.Size>;
  3115. defvar Inst = !cast<Instruction>(NAME);
  3116. defvar pred_int = !cast<Intrinsic>("int_arm_mve_vrint"#suffix#"_predicated");
  3117. let Predicates = [HasMVEFloat] in {
  3118. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))),
  3119. (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>;
  3120. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred),
  3121. (VTI.Vec MQPR:$inactive))),
  3122. (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen,
  3123. (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
  3124. }
  3125. }
  3126. multiclass MVE_VRINT_ops<MVEVectorVTInfo VTI> {
  3127. defm N : MVE_VRINT_m<VTI, "n", 0b000, int_arm_mve_vrintn>;
  3128. defm X : MVE_VRINT_m<VTI, "x", 0b001, frint>;
  3129. defm A : MVE_VRINT_m<VTI, "a", 0b010, fround>;
  3130. defm Z : MVE_VRINT_m<VTI, "z", 0b011, ftrunc>;
  3131. defm M : MVE_VRINT_m<VTI, "m", 0b101, ffloor>;
  3132. defm P : MVE_VRINT_m<VTI, "p", 0b111, fceil>;
  3133. }
  3134. defm MVE_VRINTf16 : MVE_VRINT_ops<MVE_v8f16>;
  3135. defm MVE_VRINTf32 : MVE_VRINT_ops<MVE_v4f32>;
  3136. class MVEFloatArithNeon<string iname, string suffix, bit size,
  3137. dag oops, dag iops, string ops,
  3138. vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  3139. : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, vecsize, pattern> {
  3140. let Inst{20} = size;
  3141. let Inst{16} = 0b0;
  3142. }
  3143. class MVE_VMUL_fp<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
  3144. : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd),
  3145. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "",
  3146. size, pattern> {
  3147. bits<4> Qd;
  3148. bits<4> Qn;
  3149. let Inst{28} = 0b1;
  3150. let Inst{25-23} = 0b110;
  3151. let Inst{22} = Qd{3};
  3152. let Inst{21} = 0b0;
  3153. let Inst{19-17} = Qn{2-0};
  3154. let Inst{15-13} = Qd{2-0};
  3155. let Inst{12-8} = 0b01101;
  3156. let Inst{7} = Qn{3};
  3157. let Inst{4} = 0b1;
  3158. let validForTailPredication = 1;
  3159. }
  3160. multiclass MVE_VMULT_fp_m<string iname, MVEVectorVTInfo VTI, SDNode Op,
  3161. Intrinsic PredInt, SDPatternOperator IdentityVec> {
  3162. def "" : MVE_VMUL_fp<iname, VTI.Suffix, VTI.Size>;
  3163. defvar Inst = !cast<Instruction>(NAME);
  3164. let Predicates = [HasMVEFloat] in {
  3165. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>;
  3166. }
  3167. }
  3168. multiclass MVE_VMUL_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
  3169. : MVE_VMULT_fp_m<"vmul", VTI, fmul, int_arm_mve_mul_predicated, IdentityVec>;
  3170. def ARMimmOneF: PatLeaf<(bitconvert (v4f32 (ARMvmovFPImm (i32 112))))>; // 1.0 float
  3171. def ARMimmOneH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2620))))>; // 1.0 half
  3172. defm MVE_VMULf32 : MVE_VMUL_fp_m<MVE_v4f32, ARMimmOneF>;
  3173. defm MVE_VMULf16 : MVE_VMUL_fp_m<MVE_v8f16, ARMimmOneH>;
  3174. class MVE_VCMLA<string suffix, bits<2> size>
  3175. : MVEFloatArithNeon<"vcmla", suffix, size{1}, (outs MQPR:$Qd),
  3176. (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
  3177. "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src", size, []> {
  3178. bits<4> Qd;
  3179. bits<4> Qn;
  3180. bits<2> rot;
  3181. let Inst{28} = 0b1;
  3182. let Inst{25} = 0b0;
  3183. let Inst{24-23} = rot;
  3184. let Inst{22} = Qd{3};
  3185. let Inst{21} = 0b1;
  3186. let Inst{19-17} = Qn{2-0};
  3187. let Inst{15-13} = Qd{2-0};
  3188. let Inst{12-8} = 0b01000;
  3189. let Inst{7} = Qn{3};
  3190. let Inst{4} = 0b0;
  3191. }
  3192. multiclass MVE_VCMLA_m<MVEVectorVTInfo VTI> {
  3193. def "" : MVE_VCMLA<VTI.Suffix, VTI.Size>;
  3194. defvar Inst = !cast<Instruction>(NAME);
  3195. let Predicates = [HasMVEFloat] in {
  3196. def : Pat<(VTI.Vec (int_arm_mve_vcmlaq
  3197. imm:$rot, (VTI.Vec MQPR:$Qd_src),
  3198. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  3199. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  3200. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3201. imm:$rot))>;
  3202. def : Pat<(VTI.Vec (int_arm_mve_vcmlaq_predicated
  3203. imm:$rot, (VTI.Vec MQPR:$Qd_src),
  3204. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3205. (VTI.Pred VCCR:$mask))),
  3206. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qn),
  3207. (VTI.Vec MQPR:$Qm), imm:$rot,
  3208. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  3209. }
  3210. }
  3211. defm MVE_VCMLAf16 : MVE_VCMLA_m<MVE_v8f16>;
  3212. defm MVE_VCMLAf32 : MVE_VCMLA_m<MVE_v4f32>;
  3213. class MVE_VADDSUBFMA_fp<string iname, string suffix, bits<2> size, bit bit_4,
  3214. bit bit_8, bit bit_21, dag iops=(ins),
  3215. vpred_ops vpred=vpred_r, string cstr="",
  3216. list<dag> pattern=[]>
  3217. : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd),
  3218. !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm",
  3219. vpred, cstr, size, pattern> {
  3220. bits<4> Qd;
  3221. bits<4> Qn;
  3222. let Inst{28} = 0b0;
  3223. let Inst{25-23} = 0b110;
  3224. let Inst{22} = Qd{3};
  3225. let Inst{21} = bit_21;
  3226. let Inst{19-17} = Qn{2-0};
  3227. let Inst{15-13} = Qd{2-0};
  3228. let Inst{11-9} = 0b110;
  3229. let Inst{8} = bit_8;
  3230. let Inst{7} = Qn{3};
  3231. let Inst{4} = bit_4;
  3232. let validForTailPredication = 1;
  3233. }
  3234. multiclass MVE_VFMA_fp_multi<string iname, bit fms, MVEVectorVTInfo VTI> {
  3235. def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0b1, 0b0, fms,
  3236. (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
  3237. defvar Inst = !cast<Instruction>(NAME);
  3238. defvar pred_int = int_arm_mve_fma_predicated;
  3239. defvar m1 = (VTI.Vec MQPR:$m1);
  3240. defvar m2 = (VTI.Vec MQPR:$m2);
  3241. defvar add = (VTI.Vec MQPR:$add);
  3242. defvar pred = (VTI.Pred VCCR:$pred);
  3243. let Predicates = [HasMVEFloat] in {
  3244. if fms then {
  3245. def : Pat<(VTI.Vec (fma (fneg m1), m2, add)),
  3246. (Inst $add, $m1, $m2)>;
  3247. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  3248. (VTI.Vec (fma (fneg m1), m2, add)),
  3249. add)),
  3250. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3251. def : Pat<(VTI.Vec (pred_int (fneg m1), m2, add, pred)),
  3252. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3253. def : Pat<(VTI.Vec (pred_int m1, (fneg m2), add, pred)),
  3254. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3255. } else {
  3256. def : Pat<(VTI.Vec (fma m1, m2, add)),
  3257. (Inst $add, $m1, $m2)>;
  3258. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  3259. (VTI.Vec (fma m1, m2, add)),
  3260. add)),
  3261. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3262. def : Pat<(VTI.Vec (pred_int m1, m2, add, pred)),
  3263. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3264. }
  3265. }
  3266. }
  3267. defm MVE_VFMAf32 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v4f32>;
  3268. defm MVE_VFMAf16 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v8f16>;
  3269. defm MVE_VFMSf32 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v4f32>;
  3270. defm MVE_VFMSf16 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v8f16>;
  3271. multiclass MVE_VADDSUB_fp_m<string iname, bit bit_21, MVEVectorVTInfo VTI,
  3272. SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> {
  3273. def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0, 1, bit_21> {
  3274. let validForTailPredication = 1;
  3275. }
  3276. defvar Inst = !cast<Instruction>(NAME);
  3277. let Predicates = [HasMVEFloat] in {
  3278. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>;
  3279. }
  3280. }
  3281. multiclass MVE_VADD_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
  3282. : MVE_VADDSUB_fp_m<"vadd", 0, VTI, fadd, int_arm_mve_add_predicated, IdentityVec>;
  3283. multiclass MVE_VSUB_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
  3284. : MVE_VADDSUB_fp_m<"vsub", 1, VTI, fsub, int_arm_mve_sub_predicated, IdentityVec>;
  3285. def ARMimmMinusZeroF: PatLeaf<(bitconvert (v4i32 (ARMvmovImm (i32 1664))))>; // -0.0 float
  3286. def ARMimmMinusZeroH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2688))))>; // -0.0 half
  3287. defm MVE_VADDf32 : MVE_VADD_fp_m<MVE_v4f32, ARMimmMinusZeroF>;
  3288. defm MVE_VADDf16 : MVE_VADD_fp_m<MVE_v8f16, ARMimmMinusZeroH>;
  3289. defm MVE_VSUBf32 : MVE_VSUB_fp_m<MVE_v4f32, ARMimmAllZerosV>;
  3290. defm MVE_VSUBf16 : MVE_VSUB_fp_m<MVE_v8f16, ARMimmAllZerosV>;
  3291. class MVE_VCADD<string suffix, bits<2> size, string cstr="">
  3292. : MVEFloatArithNeon<"vcadd", suffix, size{1}, (outs MQPR:$Qd),
  3293. (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
  3294. "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> {
  3295. bits<4> Qd;
  3296. bits<4> Qn;
  3297. bit rot;
  3298. let Inst{28} = 0b1;
  3299. let Inst{25} = 0b0;
  3300. let Inst{24} = rot;
  3301. let Inst{23} = 0b1;
  3302. let Inst{22} = Qd{3};
  3303. let Inst{21} = 0b0;
  3304. let Inst{19-17} = Qn{2-0};
  3305. let Inst{15-13} = Qd{2-0};
  3306. let Inst{12-8} = 0b01000;
  3307. let Inst{7} = Qn{3};
  3308. let Inst{4} = 0b0;
  3309. }
  3310. multiclass MVE_VCADD_m<MVEVectorVTInfo VTI, string cstr=""> {
  3311. def "" : MVE_VCADD<VTI.Suffix, VTI.Size, cstr>;
  3312. defvar Inst = !cast<Instruction>(NAME);
  3313. let Predicates = [HasMVEFloat] in {
  3314. def : Pat<(VTI.Vec (int_arm_mve_vcaddq (i32 1),
  3315. imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  3316. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3317. imm:$rot))>;
  3318. def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated (i32 1),
  3319. imm:$rot, (VTI.Vec MQPR:$inactive),
  3320. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3321. (VTI.Pred VCCR:$mask))),
  3322. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3323. imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  3324. (VTI.Vec MQPR:$inactive)))>;
  3325. }
  3326. }
  3327. defm MVE_VCADDf16 : MVE_VCADD_m<MVE_v8f16>;
  3328. defm MVE_VCADDf32 : MVE_VCADD_m<MVE_v4f32, "@earlyclobber $Qd">;
  3329. class MVE_VABD_fp<string suffix, bits<2> size>
  3330. : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
  3331. "$Qd, $Qn, $Qm", vpred_r, "", size> {
  3332. bits<4> Qd;
  3333. bits<4> Qn;
  3334. let Inst{28} = 0b1;
  3335. let Inst{25-23} = 0b110;
  3336. let Inst{22} = Qd{3};
  3337. let Inst{21} = 0b1;
  3338. let Inst{20} = size{0};
  3339. let Inst{19-17} = Qn{2-0};
  3340. let Inst{16} = 0b0;
  3341. let Inst{15-13} = Qd{2-0};
  3342. let Inst{11-8} = 0b1101;
  3343. let Inst{7} = Qn{3};
  3344. let Inst{4} = 0b0;
  3345. let validForTailPredication = 1;
  3346. }
  3347. multiclass MVE_VABDT_fp_m<MVEVectorVTInfo VTI,
  3348. Intrinsic unpred_int, Intrinsic pred_int> {
  3349. def "" : MVE_VABD_fp<VTI.Suffix, VTI.Size>;
  3350. defvar Inst = !cast<Instruction>(NAME);
  3351. let Predicates = [HasMVEFloat] in {
  3352. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  3353. (i32 0))),
  3354. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  3355. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  3356. (i32 0), (VTI.Pred VCCR:$mask),
  3357. (VTI.Vec MQPR:$inactive))),
  3358. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  3359. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  3360. (VTI.Vec MQPR:$inactive)))>;
  3361. }
  3362. }
  3363. multiclass MVE_VABD_fp_m<MVEVectorVTInfo VTI>
  3364. : MVE_VABDT_fp_m<VTI, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
  3365. defm MVE_VABDf32 : MVE_VABD_fp_m<MVE_v4f32>;
  3366. defm MVE_VABDf16 : MVE_VABD_fp_m<MVE_v8f16>;
  3367. let Predicates = [HasMVEFloat] in {
  3368. def : Pat<(v8f16 (fabs (fsub (v8f16 MQPR:$Qm), (v8f16 MQPR:$Qn)))),
  3369. (MVE_VABDf16 MQPR:$Qm, MQPR:$Qn)>;
  3370. def : Pat<(v4f32 (fabs (fsub (v4f32 MQPR:$Qm), (v4f32 MQPR:$Qn)))),
  3371. (MVE_VABDf32 MQPR:$Qm, MQPR:$Qn)>;
  3372. }
  3373. class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op,
  3374. Operand imm_operand_type>
  3375. : MVE_float<"vcvt", suffix,
  3376. (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6),
  3377. "$Qd, $Qm, $imm6", vpred_r, "", !if(fsi, 0b10, 0b01), []> {
  3378. bits<4> Qd;
  3379. bits<6> imm6;
  3380. let Inst{28} = U;
  3381. let Inst{25-23} = 0b111;
  3382. let Inst{22} = Qd{3};
  3383. let Inst{21} = 0b1;
  3384. let Inst{19-16} = imm6{3-0};
  3385. let Inst{15-13} = Qd{2-0};
  3386. let Inst{11-10} = 0b11;
  3387. let Inst{9} = fsi;
  3388. let Inst{8} = op;
  3389. let Inst{7} = 0b0;
  3390. let Inst{4} = 0b1;
  3391. let DecoderMethod = "DecodeMVEVCVTt1fp";
  3392. let validForTailPredication = 1;
  3393. }
  3394. class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass {
  3395. let PredicateMethod = "isImmediate<1," # Bits # ">";
  3396. let DiagnosticString =
  3397. "MVE fixed-point immediate operand must be between 1 and " # Bits;
  3398. let Name = "MVEVcvtImm" # Bits;
  3399. let RenderMethod = "addImmOperands";
  3400. }
  3401. class MVE_VCVT_imm<int Bits>: Operand<i32> {
  3402. let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>;
  3403. let EncoderMethod = "getNEONVcvtImm32OpValue";
  3404. let DecoderMethod = "DecodeVCVTImmOperand";
  3405. }
  3406. class MVE_VCVT_fix_f32<string suffix, bit U, bit op>
  3407. : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> {
  3408. let Inst{20} = imm6{4};
  3409. }
  3410. class MVE_VCVT_fix_f16<string suffix, bit U, bit op>
  3411. : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> {
  3412. let Inst{20} = 0b1;
  3413. }
  3414. multiclass MVE_VCVT_fix_patterns<Instruction Inst, bit U, MVEVectorVTInfo DestVTI,
  3415. MVEVectorVTInfo SrcVTI> {
  3416. let Predicates = [HasMVEFloat] in {
  3417. def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix
  3418. (i32 U), (SrcVTI.Vec MQPR:$Qm), imm:$scale)),
  3419. (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale))>;
  3420. def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix_predicated (i32 U),
  3421. (DestVTI.Vec MQPR:$inactive),
  3422. (SrcVTI.Vec MQPR:$Qm),
  3423. imm:$scale,
  3424. (DestVTI.Pred VCCR:$mask))),
  3425. (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale,
  3426. ARMVCCThen, (DestVTI.Pred VCCR:$mask), zero_reg,
  3427. (DestVTI.Vec MQPR:$inactive)))>;
  3428. }
  3429. }
  3430. multiclass MVE_VCVT_fix_f32_m<bit U, bit op,
  3431. MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> {
  3432. def "" : MVE_VCVT_fix_f32<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>;
  3433. defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>;
  3434. }
  3435. multiclass MVE_VCVT_fix_f16_m<bit U, bit op,
  3436. MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> {
  3437. def "" : MVE_VCVT_fix_f16<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>;
  3438. defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>;
  3439. }
  3440. defm MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16_m<0b0, 0b0, MVE_v8f16, MVE_v8s16>;
  3441. defm MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16_m<0b0, 0b1, MVE_v8s16, MVE_v8f16>;
  3442. defm MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16_m<0b1, 0b0, MVE_v8f16, MVE_v8u16>;
  3443. defm MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16_m<0b1, 0b1, MVE_v8u16, MVE_v8f16>;
  3444. defm MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32_m<0b0, 0b0, MVE_v4f32, MVE_v4s32>;
  3445. defm MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32_m<0b0, 0b1, MVE_v4s32, MVE_v4f32>;
  3446. defm MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32_m<0b1, 0b0, MVE_v4f32, MVE_v4u32>;
  3447. defm MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32_m<0b1, 0b1, MVE_v4u32, MVE_v4f32>;
  3448. class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm,
  3449. bits<2> rm, list<dag> pattern=[]>
  3450. : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd),
  3451. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3452. bits<4> Qd;
  3453. let Inst{28} = 0b1;
  3454. let Inst{25-23} = 0b111;
  3455. let Inst{22} = Qd{3};
  3456. let Inst{21-20} = 0b11;
  3457. let Inst{19-18} = size;
  3458. let Inst{17-16} = 0b11;
  3459. let Inst{15-13} = Qd{2-0};
  3460. let Inst{12-10} = 0b000;
  3461. let Inst{9-8} = rm;
  3462. let Inst{7} = op;
  3463. let Inst{4} = 0b0;
  3464. let validForTailPredication = 1;
  3465. }
  3466. multiclass MVE_VCVT_fp_int_anpm_inner<MVEVectorVTInfo Int, MVEVectorVTInfo Flt,
  3467. string anpm, bits<2> rm> {
  3468. def "": MVE_VCVT_fp_int_anpm<Int.Suffix # "." # Flt.Suffix, Int.Size,
  3469. Int.Unsigned, anpm, rm>;
  3470. defvar Inst = !cast<Instruction>(NAME);
  3471. defvar IntrBaseName = "int_arm_mve_vcvt" # anpm;
  3472. defvar UnpredIntr = !cast<Intrinsic>(IntrBaseName);
  3473. defvar PredIntr = !cast<Intrinsic>(IntrBaseName # "_predicated");
  3474. let Predicates = [HasMVEFloat] in {
  3475. def : Pat<(Int.Vec (UnpredIntr (i32 Int.Unsigned), (Flt.Vec MQPR:$in))),
  3476. (Int.Vec (Inst (Flt.Vec MQPR:$in)))>;
  3477. def : Pat<(Int.Vec (PredIntr (i32 Int.Unsigned), (Int.Vec MQPR:$inactive),
  3478. (Flt.Vec MQPR:$in), (Flt.Pred VCCR:$pred))),
  3479. (Int.Vec (Inst (Flt.Vec MQPR:$in), ARMVCCThen,
  3480. (Flt.Pred VCCR:$pred), zero_reg, (Int.Vec MQPR:$inactive)))>;
  3481. }
  3482. }
  3483. multiclass MVE_VCVT_fp_int_anpm_outer<MVEVectorVTInfo Int,
  3484. MVEVectorVTInfo Flt> {
  3485. defm a : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "a", 0b00>;
  3486. defm n : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "n", 0b01>;
  3487. defm p : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "p", 0b10>;
  3488. defm m : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "m", 0b11>;
  3489. }
  3490. // This defines instructions such as MVE_VCVTu16f16a, with an explicit
  3491. // rounding-mode suffix on the mnemonic. The class below will define
  3492. // the bare MVE_VCVTu16f16 (with implied rounding toward zero).
  3493. defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8s16, MVE_v8f16>;
  3494. defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8u16, MVE_v8f16>;
  3495. defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4s32, MVE_v4f32>;
  3496. defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4u32, MVE_v4f32>;
  3497. class MVE_VCVT_fp_int<string suffix, bits<2> size, bit toint, bit unsigned,
  3498. list<dag> pattern=[]>
  3499. : MVE_float<"vcvt", suffix, (outs MQPR:$Qd),
  3500. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3501. bits<4> Qd;
  3502. let Inst{28} = 0b1;
  3503. let Inst{25-23} = 0b111;
  3504. let Inst{22} = Qd{3};
  3505. let Inst{21-20} = 0b11;
  3506. let Inst{19-18} = size;
  3507. let Inst{17-16} = 0b11;
  3508. let Inst{15-13} = Qd{2-0};
  3509. let Inst{12-9} = 0b0011;
  3510. let Inst{8} = toint;
  3511. let Inst{7} = unsigned;
  3512. let Inst{4} = 0b0;
  3513. let validForTailPredication = 1;
  3514. }
  3515. multiclass MVE_VCVT_fp_int_m<MVEVectorVTInfo Dest, MVEVectorVTInfo Src,
  3516. SDNode unpred_op> {
  3517. defvar Unsigned = !or(!eq(Dest.SuffixLetter,"u"), !eq(Src.SuffixLetter,"u"));
  3518. defvar ToInt = !eq(Src.SuffixLetter,"f");
  3519. def "" : MVE_VCVT_fp_int<Dest.Suffix # "." # Src.Suffix, Dest.Size,
  3520. ToInt, Unsigned>;
  3521. defvar Inst = !cast<Instruction>(NAME);
  3522. let Predicates = [HasMVEFloat] in {
  3523. def : Pat<(Dest.Vec (unpred_op (Src.Vec MQPR:$src))),
  3524. (Dest.Vec (Inst (Src.Vec MQPR:$src)))>;
  3525. def : Pat<(Dest.Vec (int_arm_mve_vcvt_fp_int_predicated
  3526. (Src.Vec MQPR:$src), (i32 Unsigned),
  3527. (Src.Pred VCCR:$mask), (Dest.Vec MQPR:$inactive))),
  3528. (Dest.Vec (Inst (Src.Vec MQPR:$src), ARMVCCThen,
  3529. (Src.Pred VCCR:$mask), zero_reg,
  3530. (Dest.Vec MQPR:$inactive)))>;
  3531. }
  3532. }
  3533. // The unsuffixed VCVT for float->int implicitly rounds toward zero,
  3534. // which I reflect here in the llvm instruction names
  3535. defm MVE_VCVTs16f16z : MVE_VCVT_fp_int_m<MVE_v8s16, MVE_v8f16, fp_to_sint>;
  3536. defm MVE_VCVTu16f16z : MVE_VCVT_fp_int_m<MVE_v8u16, MVE_v8f16, fp_to_uint>;
  3537. defm MVE_VCVTs32f32z : MVE_VCVT_fp_int_m<MVE_v4s32, MVE_v4f32, fp_to_sint>;
  3538. defm MVE_VCVTu32f32z : MVE_VCVT_fp_int_m<MVE_v4u32, MVE_v4f32, fp_to_uint>;
  3539. // Whereas VCVT for int->float rounds to nearest
  3540. defm MVE_VCVTf16s16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8s16, sint_to_fp>;
  3541. defm MVE_VCVTf16u16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8u16, uint_to_fp>;
  3542. defm MVE_VCVTf32s32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4s32, sint_to_fp>;
  3543. defm MVE_VCVTf32u32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4u32, uint_to_fp>;
  3544. let Predicates = [HasMVEFloat] in {
  3545. def : Pat<(v4i32 (fp_to_sint_sat v4f32:$src, i32)),
  3546. (MVE_VCVTs32f32z v4f32:$src)>;
  3547. def : Pat<(v4i32 (fp_to_uint_sat v4f32:$src, i32)),
  3548. (MVE_VCVTu32f32z v4f32:$src)>;
  3549. def : Pat<(v8i16 (fp_to_sint_sat v8f16:$src, i16)),
  3550. (MVE_VCVTs16f16z v8f16:$src)>;
  3551. def : Pat<(v8i16 (fp_to_uint_sat v8f16:$src, i16)),
  3552. (MVE_VCVTu16f16z v8f16:$src)>;
  3553. }
  3554. class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate,
  3555. list<dag> pattern=[]>
  3556. : MVE_float<iname, suffix, (outs MQPR:$Qd),
  3557. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3558. bits<4> Qd;
  3559. let Inst{28} = 0b1;
  3560. let Inst{25-23} = 0b111;
  3561. let Inst{22} = Qd{3};
  3562. let Inst{21-20} = 0b11;
  3563. let Inst{19-18} = size;
  3564. let Inst{17-16} = 0b01;
  3565. let Inst{15-13} = Qd{2-0};
  3566. let Inst{11-8} = 0b0111;
  3567. let Inst{7} = negate;
  3568. let Inst{4} = 0b0;
  3569. let validForTailPredication = 1;
  3570. }
  3571. multiclass MVE_VABSNEG_fp_m<string iname, SDNode unpred_op, Intrinsic pred_int,
  3572. MVEVectorVTInfo VTI, bit opcode> {
  3573. def "" : MVE_VABSNEG_fp<iname, VTI.Suffix, VTI.Size, opcode>;
  3574. defvar Inst = !cast<Instruction>(NAME);
  3575. let Predicates = [HasMVEInt] in {
  3576. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))),
  3577. (VTI.Vec (Inst $v))>;
  3578. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask),
  3579. (VTI.Vec MQPR:$inactive))),
  3580. (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>;
  3581. }
  3582. }
  3583. defm MVE_VABSf16 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated,
  3584. MVE_v8f16, 0>;
  3585. defm MVE_VABSf32 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated,
  3586. MVE_v4f32, 0>;
  3587. defm MVE_VNEGf16 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated,
  3588. MVE_v8f16, 1>;
  3589. defm MVE_VNEGf32 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated,
  3590. MVE_v4f32, 1>;
  3591. class MVE_VMAXMINNMA<string iname, string suffix, bits<2> size, bit bit_12,
  3592. list<dag> pattern=[]>
  3593. : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
  3594. NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
  3595. size, pattern> {
  3596. bits<4> Qd;
  3597. bits<4> Qm;
  3598. let Inst{28} = size{0};
  3599. let Inst{25-23} = 0b100;
  3600. let Inst{22} = Qd{3};
  3601. let Inst{21-16} = 0b111111;
  3602. let Inst{15-13} = Qd{2-0};
  3603. let Inst{12} = bit_12;
  3604. let Inst{11-6} = 0b111010;
  3605. let Inst{5} = Qm{3};
  3606. let Inst{4} = 0b0;
  3607. let Inst{3-1} = Qm{2-0};
  3608. let Inst{0} = 0b1;
  3609. let isCommutable = 1;
  3610. let validForTailPredication = 1;
  3611. }
  3612. multiclass MVE_VMAXMINNMA_m<string iname, MVEVectorVTInfo VTI,
  3613. SDNode unpred_op, Intrinsic pred_int,
  3614. bit bit_12> {
  3615. def "" : MVE_VMAXMINNMA<iname, VTI.Suffix, VTI.Size, bit_12>;
  3616. defvar Inst = !cast<Instruction>(NAME);
  3617. let Predicates = [HasMVEInt] in {
  3618. // Unpredicated v(max|min)nma
  3619. def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
  3620. (fabs (VTI.Vec MQPR:$Qm)))),
  3621. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
  3622. // Predicated v(max|min)nma
  3623. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  3624. (VTI.Pred VCCR:$mask))),
  3625. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  3626. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  3627. }
  3628. }
  3629. multiclass MVE_VMAXNMA<MVEVectorVTInfo VTI, bit bit_12>
  3630. : MVE_VMAXMINNMA_m<"vmaxnma", VTI, fmaxnum, int_arm_mve_vmaxnma_predicated, bit_12>;
  3631. defm MVE_VMAXNMAf32 : MVE_VMAXNMA<MVE_v4f32, 0b0>;
  3632. defm MVE_VMAXNMAf16 : MVE_VMAXNMA<MVE_v8f16, 0b0>;
  3633. multiclass MVE_VMINNMA<MVEVectorVTInfo VTI, bit bit_12>
  3634. : MVE_VMAXMINNMA_m<"vminnma", VTI, fminnum, int_arm_mve_vminnma_predicated, bit_12>;
  3635. defm MVE_VMINNMAf32 : MVE_VMINNMA<MVE_v4f32, 0b1>;
  3636. defm MVE_VMINNMAf16 : MVE_VMINNMA<MVE_v8f16, 0b1>;
  3637. // end of MVE Floating Point instructions
  3638. // start of MVE compares
  3639. class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
  3640. VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
  3641. : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc),
  3642. NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", vecsize, pattern> {
  3643. // Base class for comparing two vector registers
  3644. bits<3> fc;
  3645. bits<4> Qn;
  3646. bits<4> Qm;
  3647. let Inst{28} = bit_28;
  3648. let Inst{25-22} = 0b1000;
  3649. let Inst{21-20} = bits_21_20;
  3650. let Inst{19-17} = Qn{2-0};
  3651. let Inst{16-13} = 0b1000;
  3652. let Inst{12} = fc{2};
  3653. let Inst{11-8} = 0b1111;
  3654. let Inst{7} = fc{0};
  3655. let Inst{6} = 0b0;
  3656. let Inst{5} = Qm{3};
  3657. let Inst{4} = 0b0;
  3658. let Inst{3-1} = Qm{2-0};
  3659. let Inst{0} = fc{1};
  3660. let Constraints = "";
  3661. // We need a custom decoder method for these instructions because of
  3662. // the output VCCR operand, which isn't encoded in the instruction
  3663. // bits anywhere (there is only one choice for it) but has to be
  3664. // included in the MC operands so that codegen will be able to track
  3665. // its data flow between instructions, spill/reload it when
  3666. // necessary, etc. There seems to be no way to get the Tablegen
  3667. // decoder to emit an operand that isn't affected by any instruction
  3668. // bit.
  3669. let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">";
  3670. let validForTailPredication = 1;
  3671. }
  3672. class MVE_VCMPqqf<string suffix, bit size>
  3673. : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> {
  3674. let Predicates = [HasMVEFloat];
  3675. }
  3676. class MVE_VCMPqqi<string suffix, bits<2> size>
  3677. : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i, size> {
  3678. let Inst{12} = 0b0;
  3679. let Inst{0} = 0b0;
  3680. }
  3681. class MVE_VCMPqqu<string suffix, bits<2> size>
  3682. : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u, size> {
  3683. let Inst{12} = 0b0;
  3684. let Inst{0} = 0b1;
  3685. }
  3686. class MVE_VCMPqqs<string suffix, bits<2> size>
  3687. : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s, size> {
  3688. let Inst{12} = 0b1;
  3689. }
  3690. def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>;
  3691. def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>;
  3692. def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>;
  3693. def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>;
  3694. def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>;
  3695. def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>;
  3696. def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>;
  3697. def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>;
  3698. def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>;
  3699. def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>;
  3700. def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>;
  3701. class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
  3702. VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
  3703. : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc),
  3704. NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", vecsize, pattern> {
  3705. // Base class for comparing a vector register with a scalar
  3706. bits<3> fc;
  3707. bits<4> Qn;
  3708. bits<4> Rm;
  3709. let Inst{28} = bit_28;
  3710. let Inst{25-22} = 0b1000;
  3711. let Inst{21-20} = bits_21_20;
  3712. let Inst{19-17} = Qn{2-0};
  3713. let Inst{16-13} = 0b1000;
  3714. let Inst{12} = fc{2};
  3715. let Inst{11-8} = 0b1111;
  3716. let Inst{7} = fc{0};
  3717. let Inst{6} = 0b1;
  3718. let Inst{5} = fc{1};
  3719. let Inst{4} = 0b0;
  3720. let Inst{3-0} = Rm{3-0};
  3721. let Constraints = "";
  3722. // Custom decoder method, for the same reason as MVE_VCMPqq
  3723. let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">";
  3724. let validForTailPredication = 1;
  3725. }
  3726. class MVE_VCMPqrf<string suffix, bit size>
  3727. : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> {
  3728. let Predicates = [HasMVEFloat];
  3729. }
  3730. class MVE_VCMPqri<string suffix, bits<2> size>
  3731. : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i, size> {
  3732. let Inst{12} = 0b0;
  3733. let Inst{5} = 0b0;
  3734. }
  3735. class MVE_VCMPqru<string suffix, bits<2> size>
  3736. : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u, size> {
  3737. let Inst{12} = 0b0;
  3738. let Inst{5} = 0b1;
  3739. }
  3740. class MVE_VCMPqrs<string suffix, bits<2> size>
  3741. : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s, size> {
  3742. let Inst{12} = 0b1;
  3743. }
  3744. def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>;
  3745. def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>;
  3746. def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>;
  3747. def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>;
  3748. def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>;
  3749. def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>;
  3750. def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>;
  3751. def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>;
  3752. def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>;
  3753. def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>;
  3754. def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>;
  3755. multiclass unpred_vcmp_z<string suffix, PatLeaf fc> {
  3756. def i8 : Pat<(v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)),
  3757. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>;
  3758. def i16 : Pat<(v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)),
  3759. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>;
  3760. def i32 : Pat<(v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)),
  3761. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>;
  3762. def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)))),
  3763. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3764. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)))),
  3765. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3766. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)))),
  3767. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3768. }
  3769. multiclass unpred_vcmp_r<string suffix, PatLeaf fc> {
  3770. def i8 : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)),
  3771. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>;
  3772. def i16 : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)),
  3773. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>;
  3774. def i32 : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)),
  3775. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>;
  3776. def i8r : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)),
  3777. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3778. def i16r : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)),
  3779. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3780. def i32r : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)),
  3781. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3782. def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)))),
  3783. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3784. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)))),
  3785. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3786. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)))),
  3787. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3788. def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)))),
  3789. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3790. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)))),
  3791. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3792. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)))),
  3793. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3794. }
  3795. multiclass unpred_vcmpf_z<PatLeaf fc> {
  3796. def f16 : Pat<(v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)),
  3797. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>;
  3798. def f32 : Pat<(v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)),
  3799. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>;
  3800. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)))),
  3801. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3802. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)))),
  3803. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3804. }
  3805. multiclass unpred_vcmpf_r<PatLeaf fc> {
  3806. def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)),
  3807. (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>;
  3808. def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)),
  3809. (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>;
  3810. def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)),
  3811. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3812. def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)),
  3813. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3814. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)))),
  3815. (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3816. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)))),
  3817. (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3818. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)))),
  3819. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3820. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)))),
  3821. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3822. }
  3823. let Predicates = [HasMVEInt] in {
  3824. defm MVE_VCEQZ : unpred_vcmp_z<"i", ARMCCeq>;
  3825. defm MVE_VCNEZ : unpred_vcmp_z<"i", ARMCCne>;
  3826. defm MVE_VCGEZ : unpred_vcmp_z<"s", ARMCCge>;
  3827. defm MVE_VCLTZ : unpred_vcmp_z<"s", ARMCClt>;
  3828. defm MVE_VCGTZ : unpred_vcmp_z<"s", ARMCCgt>;
  3829. defm MVE_VCLEZ : unpred_vcmp_z<"s", ARMCCle>;
  3830. defm MVE_VCGTUZ : unpred_vcmp_z<"u", ARMCChi>;
  3831. defm MVE_VCGEUZ : unpred_vcmp_z<"u", ARMCChs>;
  3832. defm MVE_VCEQ : unpred_vcmp_r<"i", ARMCCeq>;
  3833. defm MVE_VCNE : unpred_vcmp_r<"i", ARMCCne>;
  3834. defm MVE_VCGE : unpred_vcmp_r<"s", ARMCCge>;
  3835. defm MVE_VCLT : unpred_vcmp_r<"s", ARMCClt>;
  3836. defm MVE_VCGT : unpred_vcmp_r<"s", ARMCCgt>;
  3837. defm MVE_VCLE : unpred_vcmp_r<"s", ARMCCle>;
  3838. defm MVE_VCGTU : unpred_vcmp_r<"u", ARMCChi>;
  3839. defm MVE_VCGEU : unpred_vcmp_r<"u", ARMCChs>;
  3840. }
  3841. let Predicates = [HasMVEFloat] in {
  3842. defm MVE_VFCEQZ : unpred_vcmpf_z<ARMCCeq>;
  3843. defm MVE_VFCNEZ : unpred_vcmpf_z<ARMCCne>;
  3844. defm MVE_VFCGEZ : unpred_vcmpf_z<ARMCCge>;
  3845. defm MVE_VFCLTZ : unpred_vcmpf_z<ARMCClt>;
  3846. defm MVE_VFCGTZ : unpred_vcmpf_z<ARMCCgt>;
  3847. defm MVE_VFCLEZ : unpred_vcmpf_z<ARMCCle>;
  3848. defm MVE_VFCEQ : unpred_vcmpf_r<ARMCCeq>;
  3849. defm MVE_VFCNE : unpred_vcmpf_r<ARMCCne>;
  3850. defm MVE_VFCGE : unpred_vcmpf_r<ARMCCge>;
  3851. defm MVE_VFCLT : unpred_vcmpf_r<ARMCClt>;
  3852. defm MVE_VFCGT : unpred_vcmpf_r<ARMCCgt>;
  3853. defm MVE_VFCLE : unpred_vcmpf_r<ARMCCle>;
  3854. }
  3855. // Extra "worst case" and/or/xor patterns, going into and out of GRP
  3856. multiclass two_predops<SDPatternOperator opnode, Instruction insn> {
  3857. def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))),
  3858. (v16i1 (COPY_TO_REGCLASS
  3859. (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)),
  3860. (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))),
  3861. VCCR))>;
  3862. def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))),
  3863. (v8i1 (COPY_TO_REGCLASS
  3864. (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)),
  3865. (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))),
  3866. VCCR))>;
  3867. def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))),
  3868. (v4i1 (COPY_TO_REGCLASS
  3869. (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)),
  3870. (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))),
  3871. VCCR))>;
  3872. def v2i1 : Pat<(v2i1 (opnode (v2i1 VCCR:$p1), (v2i1 VCCR:$p2))),
  3873. (v2i1 (COPY_TO_REGCLASS
  3874. (insn (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p1), rGPR)),
  3875. (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p2), rGPR))),
  3876. VCCR))>;
  3877. }
  3878. let Predicates = [HasMVEInt] in {
  3879. defm POR : two_predops<or, t2ORRrr>;
  3880. defm PAND : two_predops<and, t2ANDrr>;
  3881. defm PEOR : two_predops<xor, t2EORrr>;
  3882. }
  3883. // Occasionally we need to cast between a i32 and a boolean vector, for
  3884. // example when moving between rGPR and VPR.P0 as part of predicate vector
  3885. // shuffles. We also sometimes need to cast between different predicate
  3886. // vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles.
  3887. def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>;
  3888. def load_align4 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  3889. return cast<LoadSDNode>(N)->getAlignment() >= 4;
  3890. }]>;
  3891. let Predicates = [HasMVEInt] in {
  3892. foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in {
  3893. def : Pat<(i32 (predicate_cast (VT VCCR:$src))),
  3894. (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>;
  3895. def : Pat<(VT (predicate_cast (i32 VCCR:$src))),
  3896. (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>;
  3897. foreach VT2 = [ v2i1, v4i1, v8i1, v16i1 ] in
  3898. def : Pat<(VT (predicate_cast (VT2 VCCR:$src))),
  3899. (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>;
  3900. }
  3901. // If we happen to be casting from a load we can convert that straight
  3902. // into a predicate load, so long as the load is of the correct type.
  3903. foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in {
  3904. def : Pat<(VT (predicate_cast (i32 (load_align4 taddrmode_imm7<2>:$addr)))),
  3905. (VT (VLDR_P0_off taddrmode_imm7<2>:$addr))>;
  3906. }
  3907. // Here we match the specific SDNode type 'ARMVectorRegCastImpl'
  3908. // rather than the more general 'ARMVectorRegCast' which would also
  3909. // match some bitconverts. If we use the latter in cases where the
  3910. // input and output types are the same, the bitconvert gets elided
  3911. // and we end up generating a nonsense match of nothing.
  3912. foreach VT = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in
  3913. foreach VT2 = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in
  3914. def : Pat<(VT (ARMVectorRegCastImpl (VT2 MQPR:$src))),
  3915. (VT MQPR:$src)>;
  3916. }
  3917. // end of MVE compares
  3918. // start of MVE_qDest_qSrc
  3919. class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops,
  3920. string ops, vpred_ops vpred, string cstr,
  3921. bits<2> vecsize, list<dag> pattern=[]>
  3922. : MVE_p<oops, iops, NoItinerary, iname, suffix,
  3923. ops, vpred, cstr, vecsize, pattern> {
  3924. bits<4> Qd;
  3925. bits<4> Qm;
  3926. let Inst{25-23} = 0b100;
  3927. let Inst{22} = Qd{3};
  3928. let Inst{15-13} = Qd{2-0};
  3929. let Inst{11-9} = 0b111;
  3930. let Inst{6} = 0b0;
  3931. let Inst{5} = Qm{3};
  3932. let Inst{4} = 0b0;
  3933. let Inst{3-1} = Qm{2-0};
  3934. }
  3935. class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract,
  3936. string suffix, bits<2> size, string cstr="",
  3937. list<dag> pattern=[]>
  3938. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  3939. (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  3940. vpred_n, "$Qd = $Qd_src"#cstr, size, pattern> {
  3941. bits<4> Qn;
  3942. let Inst{28} = subtract;
  3943. let Inst{21-20} = size;
  3944. let Inst{19-17} = Qn{2-0};
  3945. let Inst{16} = 0b0;
  3946. let Inst{12} = exch;
  3947. let Inst{8} = 0b0;
  3948. let Inst{7} = Qn{3};
  3949. let Inst{0} = round;
  3950. }
  3951. multiclass MVE_VQxDMLxDH_p<string iname, bit exch, bit round, bit subtract,
  3952. MVEVectorVTInfo VTI> {
  3953. def "": MVE_VQxDMLxDH<iname, exch, round, subtract, VTI.Suffix, VTI.Size,
  3954. !if(!eq(VTI.LaneBits, 32), ",@earlyclobber $Qd", "")>;
  3955. defvar Inst = !cast<Instruction>(NAME);
  3956. defvar ConstParams = (? (i32 exch), (i32 round), (i32 subtract));
  3957. defvar unpred_intr = int_arm_mve_vqdmlad;
  3958. defvar pred_intr = int_arm_mve_vqdmlad_predicated;
  3959. def : Pat<(VTI.Vec !con((unpred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3960. (VTI.Vec MQPR:$c)), ConstParams)),
  3961. (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3962. (VTI.Vec MQPR:$c)))>;
  3963. def : Pat<(VTI.Vec !con((pred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3964. (VTI.Vec MQPR:$c)), ConstParams,
  3965. (? (VTI.Pred VCCR:$pred)))),
  3966. (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3967. (VTI.Vec MQPR:$c),
  3968. ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>;
  3969. }
  3970. multiclass MVE_VQxDMLxDH_multi<string iname, bit exch,
  3971. bit round, bit subtract> {
  3972. defm s8 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v16s8>;
  3973. defm s16 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v8s16>;
  3974. defm s32 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v4s32>;
  3975. }
  3976. defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>;
  3977. defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>;
  3978. defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>;
  3979. defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>;
  3980. defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>;
  3981. defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>;
  3982. defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>;
  3983. defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>;
  3984. class MVE_VCMUL<string iname, string suffix, bits<2> size, string cstr="">
  3985. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  3986. (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
  3987. "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size,
  3988. []> {
  3989. bits<4> Qn;
  3990. bits<2> rot;
  3991. let Inst{28} = size{1};
  3992. let Inst{21-20} = 0b11;
  3993. let Inst{19-17} = Qn{2-0};
  3994. let Inst{16} = 0b0;
  3995. let Inst{12} = rot{1};
  3996. let Inst{8} = 0b0;
  3997. let Inst{7} = Qn{3};
  3998. let Inst{0} = rot{0};
  3999. let Predicates = [HasMVEFloat];
  4000. }
  4001. multiclass MVE_VCMUL_m<string iname, MVEVectorVTInfo VTI,
  4002. string cstr=""> {
  4003. def "" : MVE_VCMUL<iname, VTI.Suffix, VTI.Size, cstr>;
  4004. defvar Inst = !cast<Instruction>(NAME);
  4005. let Predicates = [HasMVEFloat] in {
  4006. def : Pat<(VTI.Vec (int_arm_mve_vcmulq
  4007. imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  4008. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4009. imm:$rot))>;
  4010. def : Pat<(VTI.Vec (int_arm_mve_vcmulq_predicated
  4011. imm:$rot, (VTI.Vec MQPR:$inactive),
  4012. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4013. (VTI.Pred VCCR:$mask))),
  4014. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4015. imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4016. (VTI.Vec MQPR:$inactive)))>;
  4017. }
  4018. }
  4019. defm MVE_VCMULf16 : MVE_VCMUL_m<"vcmul", MVE_v8f16>;
  4020. defm MVE_VCMULf32 : MVE_VCMUL_m<"vcmul", MVE_v4f32, "@earlyclobber $Qd">;
  4021. class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20,
  4022. bit T, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  4023. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4024. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  4025. vpred_r, cstr, vecsize, pattern> {
  4026. bits<4> Qd;
  4027. bits<4> Qn;
  4028. bits<4> Qm;
  4029. let Inst{28} = bit_28;
  4030. let Inst{21-20} = bits_21_20;
  4031. let Inst{19-17} = Qn{2-0};
  4032. let Inst{16} = 0b1;
  4033. let Inst{12} = T;
  4034. let Inst{8} = 0b0;
  4035. let Inst{7} = Qn{3};
  4036. let Inst{0} = 0b0;
  4037. let validForTailPredication = 1;
  4038. let doubleWidthResult = 1;
  4039. }
  4040. multiclass MVE_VMULL_m<MVEVectorVTInfo VTI,
  4041. SDPatternOperator unpred_op, Intrinsic pred_int,
  4042. bit Top, bits<2> vecsize, string cstr=""> {
  4043. def "" : MVE_VMULL<"vmull" # !if(Top, "t", "b"), VTI.Suffix, VTI.Unsigned,
  4044. VTI.Size, Top, cstr, vecsize>;
  4045. defvar Inst = !cast<Instruction>(NAME);
  4046. let Predicates = [HasMVEInt] in {
  4047. defvar uflag = !if(!eq(VTI.SuffixLetter, "p"), (?), (? (i32 VTI.Unsigned)));
  4048. // Unpredicated multiply
  4049. def : Pat<(VTI.DblVec !con((unpred_op (VTI.Vec MQPR:$Qm),
  4050. (VTI.Vec MQPR:$Qn)),
  4051. uflag, (? (i32 Top)))),
  4052. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  4053. // Predicated multiply
  4054. def : Pat<(VTI.DblVec !con((pred_int (VTI.Vec MQPR:$Qm),
  4055. (VTI.Vec MQPR:$Qn)),
  4056. uflag, (? (i32 Top), (VTI.DblPred VCCR:$mask),
  4057. (VTI.DblVec MQPR:$inactive)))),
  4058. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4059. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  4060. (VTI.DblVec MQPR:$inactive)))>;
  4061. }
  4062. }
  4063. // For polynomial multiplies, the size bits take the unused value 0b11, and
  4064. // the unsigned bit switches to encoding the size.
  4065. defm MVE_VMULLBs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull,
  4066. int_arm_mve_mull_int_predicated, 0b0, 0b01>;
  4067. defm MVE_VMULLTs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull,
  4068. int_arm_mve_mull_int_predicated, 0b1, 0b01>;
  4069. defm MVE_VMULLBs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull,
  4070. int_arm_mve_mull_int_predicated, 0b0, 0b10>;
  4071. defm MVE_VMULLTs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull,
  4072. int_arm_mve_mull_int_predicated, 0b1, 0b10>;
  4073. defm MVE_VMULLBs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull,
  4074. int_arm_mve_mull_int_predicated, 0b0, 0b11,
  4075. "@earlyclobber $Qd">;
  4076. defm MVE_VMULLTs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull,
  4077. int_arm_mve_mull_int_predicated, 0b1, 0b11,
  4078. "@earlyclobber $Qd">;
  4079. defm MVE_VMULLBu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull,
  4080. int_arm_mve_mull_int_predicated, 0b0, 0b01>;
  4081. defm MVE_VMULLTu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull,
  4082. int_arm_mve_mull_int_predicated, 0b1, 0b01>;
  4083. defm MVE_VMULLBu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull,
  4084. int_arm_mve_mull_int_predicated, 0b0, 0b10>;
  4085. defm MVE_VMULLTu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull,
  4086. int_arm_mve_mull_int_predicated, 0b1, 0b10>;
  4087. defm MVE_VMULLBu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull,
  4088. int_arm_mve_mull_int_predicated, 0b0, 0b11,
  4089. "@earlyclobber $Qd">;
  4090. defm MVE_VMULLTu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull,
  4091. int_arm_mve_mull_int_predicated, 0b1, 0b11,
  4092. "@earlyclobber $Qd">;
  4093. defm MVE_VMULLBp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly,
  4094. int_arm_mve_mull_poly_predicated, 0b0, 0b01>;
  4095. defm MVE_VMULLTp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly,
  4096. int_arm_mve_mull_poly_predicated, 0b1, 0b01>;
  4097. defm MVE_VMULLBp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly,
  4098. int_arm_mve_mull_poly_predicated, 0b0, 0b10>;
  4099. defm MVE_VMULLTp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly,
  4100. int_arm_mve_mull_poly_predicated, 0b1, 0b10>;
  4101. let Predicates = [HasMVEInt] in {
  4102. def : Pat<(v2i64 (ARMvmulls (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))),
  4103. (MVE_VMULLBs32 MQPR:$src1, MQPR:$src2)>;
  4104. def : Pat<(v2i64 (ARMvmulls (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))),
  4105. (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))),
  4106. (MVE_VMULLTs32 MQPR:$src1, MQPR:$src2)>;
  4107. def : Pat<(mul (sext_inreg (v4i32 MQPR:$src1), v4i16),
  4108. (sext_inreg (v4i32 MQPR:$src2), v4i16)),
  4109. (MVE_VMULLBs16 MQPR:$src1, MQPR:$src2)>;
  4110. def : Pat<(mul (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))), v4i16),
  4111. (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))), v4i16)),
  4112. (MVE_VMULLTs16 MQPR:$src1, MQPR:$src2)>;
  4113. def : Pat<(mul (sext_inreg (v8i16 MQPR:$src1), v8i8),
  4114. (sext_inreg (v8i16 MQPR:$src2), v8i8)),
  4115. (MVE_VMULLBs8 MQPR:$src1, MQPR:$src2)>;
  4116. def : Pat<(mul (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), v8i8),
  4117. (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), v8i8)),
  4118. (MVE_VMULLTs8 MQPR:$src1, MQPR:$src2)>;
  4119. def : Pat<(v2i64 (ARMvmullu (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))),
  4120. (MVE_VMULLBu32 MQPR:$src1, MQPR:$src2)>;
  4121. def : Pat<(v2i64 (ARMvmullu (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))),
  4122. (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))),
  4123. (MVE_VMULLTu32 MQPR:$src1, MQPR:$src2)>;
  4124. def : Pat<(mul (and (v4i32 MQPR:$src1), (v4i32 (ARMvmovImm (i32 0xCFF)))),
  4125. (and (v4i32 MQPR:$src2), (v4i32 (ARMvmovImm (i32 0xCFF))))),
  4126. (MVE_VMULLBu16 MQPR:$src1, MQPR:$src2)>;
  4127. def : Pat<(mul (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))),
  4128. (v4i32 (ARMvmovImm (i32 0xCFF)))),
  4129. (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))),
  4130. (v4i32 (ARMvmovImm (i32 0xCFF))))),
  4131. (MVE_VMULLTu16 MQPR:$src1, MQPR:$src2)>;
  4132. def : Pat<(mul (ARMvbicImm (v8i16 MQPR:$src1), (i32 0xAFF)),
  4133. (ARMvbicImm (v8i16 MQPR:$src2), (i32 0xAFF))),
  4134. (MVE_VMULLBu8 MQPR:$src1, MQPR:$src2)>;
  4135. def : Pat<(mul (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), (i32 0xAFF)),
  4136. (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), (i32 0xAFF))),
  4137. (MVE_VMULLTu8 MQPR:$src1, MQPR:$src2)>;
  4138. }
  4139. class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size, bit round,
  4140. list<dag> pattern=[]>
  4141. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4142. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  4143. vpred_r, "", size, pattern> {
  4144. bits<4> Qn;
  4145. let Inst{28} = U;
  4146. let Inst{21-20} = size;
  4147. let Inst{19-17} = Qn{2-0};
  4148. let Inst{16} = 0b1;
  4149. let Inst{12} = round;
  4150. let Inst{8} = 0b0;
  4151. let Inst{7} = Qn{3};
  4152. let Inst{0} = 0b1;
  4153. let validForTailPredication = 1;
  4154. }
  4155. multiclass MVE_VxMULH_m<string iname, MVEVectorVTInfo VTI, SDNode unpred_op,
  4156. Intrinsic PredInt, bit round> {
  4157. def "" : MVE_VxMULH<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, round>;
  4158. defvar Inst = !cast<Instruction>(NAME);
  4159. let Predicates = [HasMVEInt] in {
  4160. if !eq(round, 0b0) then {
  4161. defvar mulh = !if(VTI.Unsigned, mulhu, mulhs);
  4162. defm : MVE_TwoOpPattern<VTI, mulh, PredInt, (? (i32 VTI.Unsigned)),
  4163. !cast<Instruction>(NAME)>;
  4164. } else {
  4165. // Predicated multiply returning high bits
  4166. def : Pat<(VTI.Vec (PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4167. (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
  4168. (VTI.Vec MQPR:$inactive))),
  4169. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4170. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4171. (VTI.Vec MQPR:$inactive)))>;
  4172. }
  4173. // Unpredicated intrinsic
  4174. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4175. (i32 VTI.Unsigned))),
  4176. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  4177. }
  4178. }
  4179. multiclass MVE_VMULT<string iname, MVEVectorVTInfo VTI, bit round>
  4180. : MVE_VxMULH_m<iname, VTI, !if(round, int_arm_mve_vrmulh, int_arm_mve_vmulh),
  4181. !if(round, int_arm_mve_rmulh_predicated,
  4182. int_arm_mve_mulh_predicated),
  4183. round>;
  4184. defm MVE_VMULHs8 : MVE_VMULT<"vmulh", MVE_v16s8, 0b0>;
  4185. defm MVE_VMULHs16 : MVE_VMULT<"vmulh", MVE_v8s16, 0b0>;
  4186. defm MVE_VMULHs32 : MVE_VMULT<"vmulh", MVE_v4s32, 0b0>;
  4187. defm MVE_VMULHu8 : MVE_VMULT<"vmulh", MVE_v16u8, 0b0>;
  4188. defm MVE_VMULHu16 : MVE_VMULT<"vmulh", MVE_v8u16, 0b0>;
  4189. defm MVE_VMULHu32 : MVE_VMULT<"vmulh", MVE_v4u32, 0b0>;
  4190. defm MVE_VRMULHs8 : MVE_VMULT<"vrmulh", MVE_v16s8, 0b1>;
  4191. defm MVE_VRMULHs16 : MVE_VMULT<"vrmulh", MVE_v8s16, 0b1>;
  4192. defm MVE_VRMULHs32 : MVE_VMULT<"vrmulh", MVE_v4s32, 0b1>;
  4193. defm MVE_VRMULHu8 : MVE_VMULT<"vrmulh", MVE_v16u8, 0b1>;
  4194. defm MVE_VRMULHu16 : MVE_VMULT<"vrmulh", MVE_v8u16, 0b1>;
  4195. defm MVE_VRMULHu32 : MVE_VMULT<"vrmulh", MVE_v4u32, 0b1>;
  4196. class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17,
  4197. bits<2> size, bit T, list<dag> pattern=[]>
  4198. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4199. (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm",
  4200. vpred_n, "$Qd = $Qd_src", !if(size, 0b10, 0b01), pattern> {
  4201. let Inst{28} = bit_28;
  4202. let Inst{21-20} = 0b11;
  4203. let Inst{19-18} = size;
  4204. let Inst{17} = bit_17;
  4205. let Inst{16} = 0b1;
  4206. let Inst{12} = T;
  4207. let Inst{8} = 0b0;
  4208. let Inst{7} = !not(bit_17);
  4209. let Inst{0} = 0b1;
  4210. let validForTailPredication = 1;
  4211. let retainsPreviousHalfElement = 1;
  4212. }
  4213. multiclass MVE_VxMOVxN_halves<string iname, string suffix,
  4214. bit bit_28, bit bit_17, bits<2> size> {
  4215. def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>;
  4216. def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>;
  4217. }
  4218. defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>;
  4219. defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>;
  4220. defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>;
  4221. defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>;
  4222. defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>;
  4223. defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>;
  4224. defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>;
  4225. defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>;
  4226. def MVEvmovn : SDNode<"ARMISD::VMOVN", SDTARMVEXT>;
  4227. multiclass MVE_VMOVN_p<Instruction Inst, bit top,
  4228. MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> {
  4229. // Match the most obvious MVEvmovn(a,b,t), which overwrites the odd or even
  4230. // lanes of a (depending on t) with the even lanes of b.
  4231. def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qd_src),
  4232. (VTI.Vec MQPR:$Qm), (i32 top))),
  4233. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>;
  4234. if !not(top) then {
  4235. // If we see MVEvmovn(a,ARMvrev(b),1), that wants to overwrite the odd
  4236. // lanes of a with the odd lanes of b. In other words, the lanes we're
  4237. // _keeping_ from a are the even ones. So we can flip it round and say that
  4238. // this is the same as overwriting the even lanes of b with the even lanes
  4239. // of a, i.e. it's a VMOVNB with the operands reversed.
  4240. defvar vrev = !cast<SDNode>("ARMvrev" # InVTI.LaneBits);
  4241. def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qm),
  4242. (VTI.Vec (vrev MQPR:$Qd_src)), (i32 1))),
  4243. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>;
  4244. }
  4245. // Match the IR intrinsic for a predicated VMOVN. This regards the Qm input
  4246. // as having wider lanes that we're narrowing, instead of already-narrow
  4247. // lanes that we're taking every other one of.
  4248. def : Pat<(VTI.Vec (int_arm_mve_vmovn_predicated (VTI.Vec MQPR:$Qd_src),
  4249. (InVTI.Vec MQPR:$Qm), (i32 top),
  4250. (InVTI.Pred VCCR:$pred))),
  4251. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  4252. (InVTI.Vec MQPR:$Qm),
  4253. ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>;
  4254. }
  4255. defm : MVE_VMOVN_p<MVE_VMOVNi32bh, 0, MVE_v8i16, MVE_v4i32>;
  4256. defm : MVE_VMOVN_p<MVE_VMOVNi32th, 1, MVE_v8i16, MVE_v4i32>;
  4257. defm : MVE_VMOVN_p<MVE_VMOVNi16bh, 0, MVE_v16i8, MVE_v8i16>;
  4258. defm : MVE_VMOVN_p<MVE_VMOVNi16th, 1, MVE_v16i8, MVE_v8i16>;
  4259. multiclass MVE_VQMOVN_p<Instruction Inst, bit outU, bit inU, bit top,
  4260. MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> {
  4261. def : Pat<(VTI.Vec (int_arm_mve_vqmovn (VTI.Vec MQPR:$Qd_src),
  4262. (InVTI.Vec MQPR:$Qm),
  4263. (i32 outU), (i32 inU), (i32 top))),
  4264. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  4265. (InVTI.Vec MQPR:$Qm)))>;
  4266. def : Pat<(VTI.Vec (int_arm_mve_vqmovn_predicated (VTI.Vec MQPR:$Qd_src),
  4267. (InVTI.Vec MQPR:$Qm),
  4268. (i32 outU), (i32 inU), (i32 top),
  4269. (InVTI.Pred VCCR:$pred))),
  4270. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  4271. (InVTI.Vec MQPR:$Qm),
  4272. ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>;
  4273. }
  4274. defm : MVE_VQMOVN_p<MVE_VQMOVNs32bh, 0, 0, 0, MVE_v8i16, MVE_v4i32>;
  4275. defm : MVE_VQMOVN_p<MVE_VQMOVNs32th, 0, 0, 1, MVE_v8i16, MVE_v4i32>;
  4276. defm : MVE_VQMOVN_p<MVE_VQMOVNs16bh, 0, 0, 0, MVE_v16i8, MVE_v8i16>;
  4277. defm : MVE_VQMOVN_p<MVE_VQMOVNs16th, 0, 0, 1, MVE_v16i8, MVE_v8i16>;
  4278. defm : MVE_VQMOVN_p<MVE_VQMOVNu32bh, 1, 1, 0, MVE_v8i16, MVE_v4i32>;
  4279. defm : MVE_VQMOVN_p<MVE_VQMOVNu32th, 1, 1, 1, MVE_v8i16, MVE_v4i32>;
  4280. defm : MVE_VQMOVN_p<MVE_VQMOVNu16bh, 1, 1, 0, MVE_v16i8, MVE_v8i16>;
  4281. defm : MVE_VQMOVN_p<MVE_VQMOVNu16th, 1, 1, 1, MVE_v16i8, MVE_v8i16>;
  4282. defm : MVE_VQMOVN_p<MVE_VQMOVUNs32bh, 1, 0, 0, MVE_v8i16, MVE_v4i32>;
  4283. defm : MVE_VQMOVN_p<MVE_VQMOVUNs32th, 1, 0, 1, MVE_v8i16, MVE_v4i32>;
  4284. defm : MVE_VQMOVN_p<MVE_VQMOVUNs16bh, 1, 0, 0, MVE_v16i8, MVE_v8i16>;
  4285. defm : MVE_VQMOVN_p<MVE_VQMOVUNs16th, 1, 0, 1, MVE_v16i8, MVE_v8i16>;
  4286. def SDTARMVMOVNQ : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0, 1>,
  4287. SDTCisVec<2>, SDTCisVT<3, i32>]>;
  4288. def MVEvqmovns : SDNode<"ARMISD::VQMOVNs", SDTARMVMOVNQ>;
  4289. def MVEvqmovnu : SDNode<"ARMISD::VQMOVNu", SDTARMVMOVNQ>;
  4290. let Predicates = [HasMVEInt] in {
  4291. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))),
  4292. (v8i16 (MVE_VQMOVNs32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4293. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))),
  4294. (v8i16 (MVE_VQMOVNs32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4295. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))),
  4296. (v16i8 (MVE_VQMOVNs16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4297. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))),
  4298. (v16i8 (MVE_VQMOVNs16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4299. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))),
  4300. (v8i16 (MVE_VQMOVNu32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4301. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))),
  4302. (v8i16 (MVE_VQMOVNu32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4303. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))),
  4304. (v16i8 (MVE_VQMOVNu16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4305. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))),
  4306. (v16i8 (MVE_VQMOVNu16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4307. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))),
  4308. (v8i16 (MVE_VQSHRNbhs32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4309. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))),
  4310. (v16i8 (MVE_VQSHRNbhs16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4311. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))),
  4312. (v8i16 (MVE_VQSHRNths32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4313. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))),
  4314. (v16i8 (MVE_VQSHRNths16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4315. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))),
  4316. (v8i16 (MVE_VQSHRNbhu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4317. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))),
  4318. (v16i8 (MVE_VQSHRNbhu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4319. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))),
  4320. (v8i16 (MVE_VQSHRNthu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4321. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))),
  4322. (v16i8 (MVE_VQSHRNthu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4323. }
  4324. class MVE_VCVT_ff<string iname, string suffix, bit op, bit T,
  4325. dag iops_extra, vpred_ops vpred, string cstr>
  4326. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4327. !con(iops_extra, (ins MQPR:$Qm)), "$Qd, $Qm",
  4328. vpred, cstr, 0b10, []> {
  4329. let Inst{28} = op;
  4330. let Inst{21-16} = 0b111111;
  4331. let Inst{12} = T;
  4332. let Inst{8-7} = 0b00;
  4333. let Inst{0} = 0b1;
  4334. let Predicates = [HasMVEFloat];
  4335. let retainsPreviousHalfElement = 1;
  4336. }
  4337. def SDTARMVCVTL : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
  4338. SDTCisVT<2, i32>]>;
  4339. def MVEvcvtn : SDNode<"ARMISD::VCVTN", SDTARMVMOVNQ>;
  4340. def MVEvcvtl : SDNode<"ARMISD::VCVTL", SDTARMVCVTL>;
  4341. multiclass MVE_VCVT_f2h_m<string iname, int half> {
  4342. def "": MVE_VCVT_ff<iname, "f16.f32", 0b0, half,
  4343. (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
  4344. defvar Inst = !cast<Instruction>(NAME);
  4345. let Predicates = [HasMVEFloat] in {
  4346. def : Pat<(v8f16 (int_arm_mve_vcvt_narrow
  4347. (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))),
  4348. (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>;
  4349. def : Pat<(v8f16 (int_arm_mve_vcvt_narrow_predicated
  4350. (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half),
  4351. (v4i1 VCCR:$mask))),
  4352. (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm),
  4353. ARMVCCThen, (v4i1 VCCR:$mask), zero_reg))>;
  4354. def : Pat<(v8f16 (MVEvcvtn (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))),
  4355. (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>;
  4356. }
  4357. }
  4358. multiclass MVE_VCVT_h2f_m<string iname, int half> {
  4359. def "": MVE_VCVT_ff<iname, "f32.f16", 0b1, half, (ins), vpred_r, "">;
  4360. defvar Inst = !cast<Instruction>(NAME);
  4361. let Predicates = [HasMVEFloat] in {
  4362. def : Pat<(v4f32 (int_arm_mve_vcvt_widen (v8f16 MQPR:$Qm), (i32 half))),
  4363. (v4f32 (Inst (v8f16 MQPR:$Qm)))>;
  4364. def : Pat<(v4f32 (int_arm_mve_vcvt_widen_predicated
  4365. (v4f32 MQPR:$inactive), (v8f16 MQPR:$Qm), (i32 half),
  4366. (v4i1 VCCR:$mask))),
  4367. (v4f32 (Inst (v8f16 MQPR:$Qm), ARMVCCThen,
  4368. (v4i1 VCCR:$mask), zero_reg, (v4f32 MQPR:$inactive)))>;
  4369. def : Pat<(v4f32 (MVEvcvtl (v8f16 MQPR:$Qm), (i32 half))),
  4370. (v4f32 (Inst (v8f16 MQPR:$Qm)))>;
  4371. }
  4372. }
  4373. defm MVE_VCVTf16f32bh : MVE_VCVT_f2h_m<"vcvtb", 0b0>;
  4374. defm MVE_VCVTf16f32th : MVE_VCVT_f2h_m<"vcvtt", 0b1>;
  4375. defm MVE_VCVTf32f16bh : MVE_VCVT_h2f_m<"vcvtb", 0b0>;
  4376. defm MVE_VCVTf32f16th : MVE_VCVT_h2f_m<"vcvtt", 0b1>;
  4377. class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve,
  4378. string cstr="">
  4379. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4380. (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
  4381. "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> {
  4382. bits<4> Qn;
  4383. bit rot;
  4384. let Inst{28} = halve;
  4385. let Inst{21-20} = size;
  4386. let Inst{19-17} = Qn{2-0};
  4387. let Inst{16} = 0b0;
  4388. let Inst{12} = rot;
  4389. let Inst{8} = 0b1;
  4390. let Inst{7} = Qn{3};
  4391. let Inst{0} = 0b0;
  4392. }
  4393. multiclass MVE_VxCADD_m<string iname, MVEVectorVTInfo VTI,
  4394. bit halve, string cstr=""> {
  4395. def "" : MVE_VxCADD<iname, VTI.Suffix, VTI.Size, halve, cstr>;
  4396. defvar Inst = !cast<Instruction>(NAME);
  4397. let Predicates = [HasMVEInt] in {
  4398. def : Pat<(VTI.Vec (int_arm_mve_vcaddq halve,
  4399. imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  4400. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4401. imm:$rot))>;
  4402. def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated halve,
  4403. imm:$rot, (VTI.Vec MQPR:$inactive),
  4404. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4405. (VTI.Pred VCCR:$mask))),
  4406. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4407. imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4408. (VTI.Vec MQPR:$inactive)))>;
  4409. }
  4410. }
  4411. defm MVE_VCADDi8 : MVE_VxCADD_m<"vcadd", MVE_v16i8, 0b1>;
  4412. defm MVE_VCADDi16 : MVE_VxCADD_m<"vcadd", MVE_v8i16, 0b1>;
  4413. defm MVE_VCADDi32 : MVE_VxCADD_m<"vcadd", MVE_v4i32, 0b1, "@earlyclobber $Qd">;
  4414. defm MVE_VHCADDs8 : MVE_VxCADD_m<"vhcadd", MVE_v16s8, 0b0>;
  4415. defm MVE_VHCADDs16 : MVE_VxCADD_m<"vhcadd", MVE_v8s16, 0b0>;
  4416. defm MVE_VHCADDs32 : MVE_VxCADD_m<"vhcadd", MVE_v4s32, 0b0, "@earlyclobber $Qd">;
  4417. class MVE_VADCSBC<string iname, bit I, bit subtract,
  4418. dag carryin, list<dag> pattern=[]>
  4419. : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout),
  4420. !con((ins MQPR:$Qn, MQPR:$Qm), carryin),
  4421. "$Qd, $Qn, $Qm", vpred_r, "", 0b10, pattern> {
  4422. bits<4> Qn;
  4423. let Inst{28} = subtract;
  4424. let Inst{21-20} = 0b11;
  4425. let Inst{19-17} = Qn{2-0};
  4426. let Inst{16} = 0b0;
  4427. let Inst{12} = I;
  4428. let Inst{8} = 0b1;
  4429. let Inst{7} = Qn{3};
  4430. let Inst{0} = 0b0;
  4431. // Custom decoder method in order to add the FPSCR operand(s), which
  4432. // Tablegen won't do right
  4433. let DecoderMethod = "DecodeMVEVADCInstruction";
  4434. }
  4435. def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>;
  4436. def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>;
  4437. def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>;
  4438. def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>;
  4439. class MVE_VQDMULL<string iname, string suffix, bit size, bit T,
  4440. string cstr="", list<dag> pattern=[]>
  4441. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4442. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  4443. vpred_r, cstr, !if(size, 0b10, 0b01), pattern> {
  4444. bits<4> Qn;
  4445. let Inst{28} = size;
  4446. let Inst{21-20} = 0b11;
  4447. let Inst{19-17} = Qn{2-0};
  4448. let Inst{16} = 0b0;
  4449. let Inst{12} = T;
  4450. let Inst{8} = 0b1;
  4451. let Inst{7} = Qn{3};
  4452. let Inst{0} = 0b1;
  4453. let validForTailPredication = 1;
  4454. let doubleWidthResult = 1;
  4455. }
  4456. multiclass MVE_VQDMULL_m<string iname, MVEVectorVTInfo VTI, bit size, bit T,
  4457. string cstr> {
  4458. def "" : MVE_VQDMULL<iname, VTI.Suffix, size, T, cstr>;
  4459. defvar Inst = !cast<Instruction>(NAME);
  4460. let Predicates = [HasMVEInt] in {
  4461. // Unpredicated saturating multiply
  4462. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm),
  4463. (VTI.Vec MQPR:$Qn), (i32 T))),
  4464. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  4465. // Predicated saturating multiply
  4466. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated
  4467. (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4468. (i32 T), (VTI.DblPred VCCR:$mask),
  4469. (VTI.DblVec MQPR:$inactive))),
  4470. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4471. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  4472. (VTI.DblVec MQPR:$inactive)))>;
  4473. }
  4474. }
  4475. multiclass MVE_VQDMULL_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> {
  4476. defm bh : MVE_VQDMULL_m<"vqdmullb", VTI, size, 0b0, cstr>;
  4477. defm th : MVE_VQDMULL_m<"vqdmullt", VTI, size, 0b1, cstr>;
  4478. }
  4479. defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<MVE_v8s16, 0b0>;
  4480. defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">;
  4481. // end of mve_qDest_qSrc
  4482. // start of mve_qDest_rSrc
  4483. class MVE_qr_base<dag oops, dag iops, string iname, string suffix, string ops,
  4484. vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  4485. : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  4486. bits<4> Qd;
  4487. bits<4> Qn;
  4488. bits<4> Rm;
  4489. let Inst{25-23} = 0b100;
  4490. let Inst{22} = Qd{3};
  4491. let Inst{19-17} = Qn{2-0};
  4492. let Inst{15-13} = Qd{2-0};
  4493. let Inst{11-9} = 0b111;
  4494. let Inst{7} = Qn{3};
  4495. let Inst{6} = 0b1;
  4496. let Inst{4} = 0b0;
  4497. let Inst{3-0} = Rm{3-0};
  4498. }
  4499. class MVE_qDest_rSrc<string iname, string suffix, string cstr="", bits<2> vecsize, list<dag> pattern=[]>
  4500. : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm),
  4501. iname, suffix, "$Qd, $Qn, $Rm", vpred_r, cstr,
  4502. vecsize, pattern>;
  4503. class MVE_qDestSrc_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]>
  4504. : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm),
  4505. iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src",
  4506. vecsize, pattern>;
  4507. class MVE_qDest_single_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]>
  4508. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname,
  4509. suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", vecsize, pattern> {
  4510. bits<4> Qd;
  4511. bits<4> Rm;
  4512. let Inst{22} = Qd{3};
  4513. let Inst{15-13} = Qd{2-0};
  4514. let Inst{3-0} = Rm{3-0};
  4515. }
  4516. // Patterns for vector-scalar instructions with integer operands
  4517. multiclass MVE_vec_scalar_int_pat_m<Instruction inst, MVEVectorVTInfo VTI,
  4518. SDPatternOperator unpred_op,
  4519. SDPatternOperator pred_op,
  4520. bit unpred_has_sign = 0,
  4521. bit pred_has_sign = 0> {
  4522. defvar UnpredSign = !if(unpred_has_sign, (? (i32 VTI.Unsigned)), (?));
  4523. defvar PredSign = !if(pred_has_sign, (? (i32 VTI.Unsigned)), (?));
  4524. let Predicates = [HasMVEInt] in {
  4525. // Unpredicated version
  4526. def : Pat<(VTI.Vec !con((unpred_op (VTI.Vec MQPR:$Qm),
  4527. (VTI.Vec (ARMvdup rGPR:$val))),
  4528. UnpredSign)),
  4529. (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>;
  4530. // Predicated version
  4531. def : Pat<(VTI.Vec !con((pred_op (VTI.Vec MQPR:$Qm),
  4532. (VTI.Vec (ARMvdup rGPR:$val))),
  4533. PredSign,
  4534. (pred_op (VTI.Pred VCCR:$mask),
  4535. (VTI.Vec MQPR:$inactive)))),
  4536. (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val),
  4537. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4538. (VTI.Vec MQPR:$inactive)))>;
  4539. }
  4540. }
  4541. class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size,
  4542. bit bit_5, bit bit_12, bit bit_16, bit bit_28>
  4543. : MVE_qDest_rSrc<iname, suffix, "", size> {
  4544. let Inst{28} = bit_28;
  4545. let Inst{21-20} = size;
  4546. let Inst{16} = bit_16;
  4547. let Inst{12} = bit_12;
  4548. let Inst{8} = 0b1;
  4549. let Inst{5} = bit_5;
  4550. let validForTailPredication = 1;
  4551. }
  4552. // Vector-scalar add/sub
  4553. multiclass MVE_VADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract,
  4554. SDNode Op, Intrinsic PredInt> {
  4555. def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b0, subtract, 0b1, 0b0>;
  4556. let Predicates = [HasMVEInt] in {
  4557. defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>;
  4558. }
  4559. }
  4560. multiclass MVE_VADD_qr_m<MVEVectorVTInfo VTI>
  4561. : MVE_VADDSUB_qr_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>;
  4562. multiclass MVE_VSUB_qr_m<MVEVectorVTInfo VTI>
  4563. : MVE_VADDSUB_qr_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>;
  4564. defm MVE_VADD_qr_i8 : MVE_VADD_qr_m<MVE_v16i8>;
  4565. defm MVE_VADD_qr_i16 : MVE_VADD_qr_m<MVE_v8i16>;
  4566. defm MVE_VADD_qr_i32 : MVE_VADD_qr_m<MVE_v4i32>;
  4567. defm MVE_VSUB_qr_i8 : MVE_VSUB_qr_m<MVE_v16i8>;
  4568. defm MVE_VSUB_qr_i16 : MVE_VSUB_qr_m<MVE_v8i16>;
  4569. defm MVE_VSUB_qr_i32 : MVE_VSUB_qr_m<MVE_v4i32>;
  4570. // Vector-scalar saturating add/sub
  4571. multiclass MVE_VQADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract,
  4572. SDNode Op, Intrinsic PredInt> {
  4573. def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b1, subtract,
  4574. 0b0, VTI.Unsigned>;
  4575. let Predicates = [HasMVEInt] in {
  4576. defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  4577. !cast<Instruction>(NAME)>;
  4578. }
  4579. }
  4580. multiclass MVE_VQADD_qr_m<MVEVectorVTInfo VTI, SDNode Op>
  4581. : MVE_VQADDSUB_qr_m<"vqadd", VTI, 0b0, Op, int_arm_mve_qadd_predicated>;
  4582. multiclass MVE_VQSUB_qr_m<MVEVectorVTInfo VTI, SDNode Op>
  4583. : MVE_VQADDSUB_qr_m<"vqsub", VTI, 0b1, Op, int_arm_mve_qsub_predicated>;
  4584. defm MVE_VQADD_qr_s8 : MVE_VQADD_qr_m<MVE_v16s8, saddsat>;
  4585. defm MVE_VQADD_qr_s16 : MVE_VQADD_qr_m<MVE_v8s16, saddsat>;
  4586. defm MVE_VQADD_qr_s32 : MVE_VQADD_qr_m<MVE_v4s32, saddsat>;
  4587. defm MVE_VQADD_qr_u8 : MVE_VQADD_qr_m<MVE_v16u8, uaddsat>;
  4588. defm MVE_VQADD_qr_u16 : MVE_VQADD_qr_m<MVE_v8u16, uaddsat>;
  4589. defm MVE_VQADD_qr_u32 : MVE_VQADD_qr_m<MVE_v4u32, uaddsat>;
  4590. defm MVE_VQSUB_qr_s8 : MVE_VQSUB_qr_m<MVE_v16s8, ssubsat>;
  4591. defm MVE_VQSUB_qr_s16 : MVE_VQSUB_qr_m<MVE_v8s16, ssubsat>;
  4592. defm MVE_VQSUB_qr_s32 : MVE_VQSUB_qr_m<MVE_v4s32, ssubsat>;
  4593. defm MVE_VQSUB_qr_u8 : MVE_VQSUB_qr_m<MVE_v16u8, usubsat>;
  4594. defm MVE_VQSUB_qr_u16 : MVE_VQSUB_qr_m<MVE_v8u16, usubsat>;
  4595. defm MVE_VQSUB_qr_u32 : MVE_VQSUB_qr_m<MVE_v4u32, usubsat>;
  4596. class MVE_VQDMULL_qr<string iname, string suffix, bit size,
  4597. bit T, string cstr="", list<dag> pattern=[]>
  4598. : MVE_qDest_rSrc<iname, suffix, cstr, !if(size, 0b10, 0b01), pattern> {
  4599. let Inst{28} = size;
  4600. let Inst{21-20} = 0b11;
  4601. let Inst{16} = 0b0;
  4602. let Inst{12} = T;
  4603. let Inst{8} = 0b1;
  4604. let Inst{5} = 0b1;
  4605. let validForTailPredication = 1;
  4606. let doubleWidthResult = 1;
  4607. }
  4608. multiclass MVE_VQDMULL_qr_m<string iname, MVEVectorVTInfo VTI, bit size,
  4609. bit T, string cstr> {
  4610. def "" : MVE_VQDMULL_qr<iname, VTI.Suffix, size, T, cstr>;
  4611. defvar Inst = !cast<Instruction>(NAME);
  4612. let Predicates = [HasMVEInt] in {
  4613. // Unpredicated saturating multiply
  4614. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm),
  4615. (VTI.Vec (ARMvdup rGPR:$val)),
  4616. (i32 T))),
  4617. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>;
  4618. // Predicated saturating multiply
  4619. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated
  4620. (VTI.Vec MQPR:$Qm),
  4621. (VTI.Vec (ARMvdup rGPR:$val)),
  4622. (i32 T),
  4623. (VTI.DblPred VCCR:$mask),
  4624. (VTI.DblVec MQPR:$inactive))),
  4625. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val),
  4626. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  4627. (VTI.DblVec MQPR:$inactive)))>;
  4628. }
  4629. }
  4630. multiclass MVE_VQDMULL_qr_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> {
  4631. defm bh : MVE_VQDMULL_qr_m<"vqdmullb", VTI, size, 0b0, cstr>;
  4632. defm th : MVE_VQDMULL_qr_m<"vqdmullt", VTI, size, 0b1, cstr>;
  4633. }
  4634. defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<MVE_v8s16, 0b0>;
  4635. defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">;
  4636. class MVE_VxADDSUB_qr<string iname, string suffix,
  4637. bit bit_28, bits<2> size, bit subtract,
  4638. bits<2> vecsize, list<dag> pattern=[]>
  4639. : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> {
  4640. let Inst{28} = bit_28;
  4641. let Inst{21-20} = size;
  4642. let Inst{16} = 0b0;
  4643. let Inst{12} = subtract;
  4644. let Inst{8} = 0b1;
  4645. let Inst{5} = 0b0;
  4646. let validForTailPredication = 1;
  4647. }
  4648. multiclass MVE_VHADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract,
  4649. Intrinsic unpred_int, Intrinsic pred_int, PatFrag add_op,
  4650. SDNode shift_op> {
  4651. def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, subtract, VTI.Size>;
  4652. defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME),
  4653. VTI, unpred_int, pred_int, 1, 1>;
  4654. defvar Inst = !cast<Instruction>(NAME);
  4655. let Predicates = [HasMVEInt] in {
  4656. def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))), (i32 1))),
  4657. (Inst MQPR:$Qm, rGPR:$Rn)>;
  4658. }
  4659. }
  4660. multiclass MVE_VHADD_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> :
  4661. MVE_VHADDSUB_qr_m<"vhadd", VTI, 0b0, int_arm_mve_vhadd, int_arm_mve_hadd_predicated,
  4662. add_op, shift_op>;
  4663. multiclass MVE_VHSUB_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> :
  4664. MVE_VHADDSUB_qr_m<"vhsub", VTI, 0b1, int_arm_mve_vhsub, int_arm_mve_hsub_predicated,
  4665. add_op, shift_op>;
  4666. defm MVE_VHADD_qr_s8 : MVE_VHADD_qr_m<MVE_v16s8, addnsw, ARMvshrsImm>;
  4667. defm MVE_VHADD_qr_s16 : MVE_VHADD_qr_m<MVE_v8s16, addnsw, ARMvshrsImm>;
  4668. defm MVE_VHADD_qr_s32 : MVE_VHADD_qr_m<MVE_v4s32, addnsw, ARMvshrsImm>;
  4669. defm MVE_VHADD_qr_u8 : MVE_VHADD_qr_m<MVE_v16u8, addnuw, ARMvshruImm>;
  4670. defm MVE_VHADD_qr_u16 : MVE_VHADD_qr_m<MVE_v8u16, addnuw, ARMvshruImm>;
  4671. defm MVE_VHADD_qr_u32 : MVE_VHADD_qr_m<MVE_v4u32, addnuw, ARMvshruImm>;
  4672. defm MVE_VHSUB_qr_s8 : MVE_VHSUB_qr_m<MVE_v16s8, subnsw, ARMvshrsImm>;
  4673. defm MVE_VHSUB_qr_s16 : MVE_VHSUB_qr_m<MVE_v8s16, subnsw, ARMvshrsImm>;
  4674. defm MVE_VHSUB_qr_s32 : MVE_VHSUB_qr_m<MVE_v4s32, subnsw, ARMvshrsImm>;
  4675. defm MVE_VHSUB_qr_u8 : MVE_VHSUB_qr_m<MVE_v16u8, subnuw, ARMvshruImm>;
  4676. defm MVE_VHSUB_qr_u16 : MVE_VHSUB_qr_m<MVE_v8u16, subnuw, ARMvshruImm>;
  4677. defm MVE_VHSUB_qr_u32 : MVE_VHSUB_qr_m<MVE_v4u32, subnuw, ARMvshruImm>;
  4678. multiclass MVE_VADDSUB_qr_f<string iname, MVEVectorVTInfo VTI, bit subtract,
  4679. SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> {
  4680. def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, subtract, VTI.Size>;
  4681. defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ),
  4682. !cast<Instruction>(NAME), IdentityVec>;
  4683. }
  4684. let Predicates = [HasMVEFloat] in {
  4685. defm MVE_VADD_qr_f32 : MVE_VADDSUB_qr_f<"vadd", MVE_v4f32, 0b0, fadd,
  4686. int_arm_mve_add_predicated, ARMimmMinusZeroF>;
  4687. defm MVE_VADD_qr_f16 : MVE_VADDSUB_qr_f<"vadd", MVE_v8f16, 0b0, fadd,
  4688. int_arm_mve_add_predicated, ARMimmMinusZeroH>;
  4689. defm MVE_VSUB_qr_f32 : MVE_VADDSUB_qr_f<"vsub", MVE_v4f32, 0b1, fsub,
  4690. int_arm_mve_sub_predicated, ARMimmAllZerosV>;
  4691. defm MVE_VSUB_qr_f16 : MVE_VADDSUB_qr_f<"vsub", MVE_v8f16, 0b1, fsub,
  4692. int_arm_mve_sub_predicated, ARMimmAllZerosV>;
  4693. }
  4694. class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size,
  4695. bit bit_7, bit bit_17, list<dag> pattern=[]>
  4696. : MVE_qDest_single_rSrc<iname, suffix, size, pattern> {
  4697. let Inst{28} = U;
  4698. let Inst{25-23} = 0b100;
  4699. let Inst{21-20} = 0b11;
  4700. let Inst{19-18} = size;
  4701. let Inst{17} = bit_17;
  4702. let Inst{16} = 0b1;
  4703. let Inst{12-8} = 0b11110;
  4704. let Inst{7} = bit_7;
  4705. let Inst{6-4} = 0b110;
  4706. let validForTailPredication = 1;
  4707. }
  4708. multiclass MVE_VxSHL_qr_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> {
  4709. def "" : MVE_VxSHL_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>;
  4710. defvar Inst = !cast<Instruction>(NAME);
  4711. def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar
  4712. (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
  4713. (i32 q), (i32 r), (i32 VTI.Unsigned))),
  4714. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh)))>;
  4715. def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar_predicated
  4716. (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
  4717. (i32 q), (i32 r), (i32 VTI.Unsigned),
  4718. (VTI.Pred VCCR:$mask))),
  4719. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
  4720. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  4721. }
  4722. multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> {
  4723. defm s8 : MVE_VxSHL_qr_p<iname, MVE_v16s8, bit_7, bit_17>;
  4724. defm s16 : MVE_VxSHL_qr_p<iname, MVE_v8s16, bit_7, bit_17>;
  4725. defm s32 : MVE_VxSHL_qr_p<iname, MVE_v4s32, bit_7, bit_17>;
  4726. defm u8 : MVE_VxSHL_qr_p<iname, MVE_v16u8, bit_7, bit_17>;
  4727. defm u16 : MVE_VxSHL_qr_p<iname, MVE_v8u16, bit_7, bit_17>;
  4728. defm u32 : MVE_VxSHL_qr_p<iname, MVE_v4u32, bit_7, bit_17>;
  4729. }
  4730. defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>;
  4731. defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>;
  4732. defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>;
  4733. defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>;
  4734. let Predicates = [HasMVEInt] in {
  4735. def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))),
  4736. (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), rGPR:$Rm))>;
  4737. def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))),
  4738. (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), rGPR:$Rm))>;
  4739. def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))),
  4740. (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), rGPR:$Rm))>;
  4741. def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))),
  4742. (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), rGPR:$Rm))>;
  4743. def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))),
  4744. (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), rGPR:$Rm))>;
  4745. def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))),
  4746. (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), rGPR:$Rm))>;
  4747. }
  4748. class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
  4749. : MVE_qDest_rSrc<iname, suffix, "", size, pattern> {
  4750. let Inst{28} = 0b1;
  4751. let Inst{21-20} = size;
  4752. let Inst{16} = 0b1;
  4753. let Inst{12} = 0b1;
  4754. let Inst{8} = 0b0;
  4755. let Inst{5} = 0b1;
  4756. let validForTailPredication = 1;
  4757. }
  4758. def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>;
  4759. def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
  4760. def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
  4761. multiclass MVE_VBRSR_pat_m<MVEVectorVTInfo VTI, Instruction Inst> {
  4762. // Unpredicated
  4763. def : Pat<(VTI.Vec (int_arm_mve_vbrsr (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm))),
  4764. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm)))>;
  4765. // Predicated
  4766. def : Pat<(VTI.Vec (int_arm_mve_vbrsr_predicated
  4767. (VTI.Vec MQPR:$inactive),
  4768. (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm),
  4769. (VTI.Pred VCCR:$mask))),
  4770. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm),
  4771. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4772. (VTI.Vec MQPR:$inactive)))>;
  4773. }
  4774. let Predicates = [HasMVEInt] in {
  4775. def : Pat<(v16i8 ( bitreverse (v16i8 MQPR:$val1))),
  4776. (v16i8 ( MVE_VBRSR8 (v16i8 MQPR:$val1), (t2MOVi (i32 8)) ))>;
  4777. def : Pat<(v4i32 ( bitreverse (v4i32 MQPR:$val1))),
  4778. (v4i32 ( MVE_VBRSR32 (v4i32 MQPR:$val1), (t2MOVi (i32 32)) ))>;
  4779. def : Pat<(v8i16 ( bitreverse (v8i16 MQPR:$val1))),
  4780. (v8i16 ( MVE_VBRSR16 (v8i16 MQPR:$val1), (t2MOVi (i32 16)) ))>;
  4781. defm : MVE_VBRSR_pat_m<MVE_v16i8, MVE_VBRSR8>;
  4782. defm : MVE_VBRSR_pat_m<MVE_v8i16, MVE_VBRSR16>;
  4783. defm : MVE_VBRSR_pat_m<MVE_v4i32, MVE_VBRSR32>;
  4784. }
  4785. let Predicates = [HasMVEFloat] in {
  4786. defm : MVE_VBRSR_pat_m<MVE_v8f16, MVE_VBRSR16>;
  4787. defm : MVE_VBRSR_pat_m<MVE_v4f32, MVE_VBRSR32>;
  4788. }
  4789. class MVE_VMUL_qr_int<string iname, string suffix, bits<2> size>
  4790. : MVE_qDest_rSrc<iname, suffix, "", size> {
  4791. let Inst{28} = 0b0;
  4792. let Inst{21-20} = size;
  4793. let Inst{16} = 0b1;
  4794. let Inst{12} = 0b1;
  4795. let Inst{8} = 0b0;
  4796. let Inst{5} = 0b1;
  4797. let validForTailPredication = 1;
  4798. }
  4799. multiclass MVE_VMUL_qr_int_m<MVEVectorVTInfo VTI> {
  4800. def "" : MVE_VMUL_qr_int<"vmul", VTI.Suffix, VTI.Size>;
  4801. let Predicates = [HasMVEInt] in {
  4802. defm : MVE_TwoOpPatternDup<VTI, mul, int_arm_mve_mul_predicated, (? ),
  4803. !cast<Instruction>(NAME), ARMimmOneV>;
  4804. }
  4805. }
  4806. defm MVE_VMUL_qr_i8 : MVE_VMUL_qr_int_m<MVE_v16i8>;
  4807. defm MVE_VMUL_qr_i16 : MVE_VMUL_qr_int_m<MVE_v8i16>;
  4808. defm MVE_VMUL_qr_i32 : MVE_VMUL_qr_int_m<MVE_v4i32>;
  4809. class MVE_VxxMUL_qr<string iname, string suffix,
  4810. bit bit_28, bits<2> size, bits<2> vecsize, list<dag> pattern=[]>
  4811. : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> {
  4812. let Inst{28} = bit_28;
  4813. let Inst{21-20} = size;
  4814. let Inst{16} = 0b1;
  4815. let Inst{12} = 0b0;
  4816. let Inst{8} = 0b0;
  4817. let Inst{5} = 0b1;
  4818. let validForTailPredication = 1;
  4819. }
  4820. multiclass MVE_VxxMUL_qr_m<string iname, MVEVectorVTInfo VTI, bit bit_28,
  4821. PatFrag Op, Intrinsic int_unpred, Intrinsic int_pred> {
  4822. def "" : MVE_VxxMUL_qr<iname, VTI.Suffix, bit_28, VTI.Size, VTI.Size>;
  4823. let Predicates = [HasMVEInt] in {
  4824. defm : MVE_TwoOpPatternDup<VTI, Op, int_pred, (? ), !cast<Instruction>(NAME)>;
  4825. }
  4826. defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME), VTI, int_unpred, int_pred>;
  4827. }
  4828. multiclass MVE_VQDMULH_qr_m<MVEVectorVTInfo VTI> :
  4829. MVE_VxxMUL_qr_m<"vqdmulh", VTI, 0b0, MVEvqdmulh,
  4830. int_arm_mve_vqdmulh, int_arm_mve_qdmulh_predicated>;
  4831. multiclass MVE_VQRDMULH_qr_m<MVEVectorVTInfo VTI> :
  4832. MVE_VxxMUL_qr_m<"vqrdmulh", VTI, 0b1, null_frag,
  4833. int_arm_mve_vqrdmulh, int_arm_mve_qrdmulh_predicated>;
  4834. defm MVE_VQDMULH_qr_s8 : MVE_VQDMULH_qr_m<MVE_v16s8>;
  4835. defm MVE_VQDMULH_qr_s16 : MVE_VQDMULH_qr_m<MVE_v8s16>;
  4836. defm MVE_VQDMULH_qr_s32 : MVE_VQDMULH_qr_m<MVE_v4s32>;
  4837. defm MVE_VQRDMULH_qr_s8 : MVE_VQRDMULH_qr_m<MVE_v16s8>;
  4838. defm MVE_VQRDMULH_qr_s16 : MVE_VQRDMULH_qr_m<MVE_v8s16>;
  4839. defm MVE_VQRDMULH_qr_s32 : MVE_VQRDMULH_qr_m<MVE_v4s32>;
  4840. multiclass MVE_VxxMUL_qr_f_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> {
  4841. let validForTailPredication = 1 in
  4842. def "" : MVE_VxxMUL_qr<"vmul", VTI.Suffix, VTI.Size{0}, 0b11, VTI.Size>;
  4843. defm : MVE_TwoOpPatternDup<VTI, fmul, int_arm_mve_mul_predicated, (? ),
  4844. !cast<Instruction>(NAME), IdentityVec>;
  4845. }
  4846. let Predicates = [HasMVEFloat] in {
  4847. defm MVE_VMUL_qr_f16 : MVE_VxxMUL_qr_f_m<MVE_v8f16, ARMimmOneH>;
  4848. defm MVE_VMUL_qr_f32 : MVE_VxxMUL_qr_f_m<MVE_v4f32, ARMimmOneF>;
  4849. }
  4850. class MVE_VFMAMLA_qr<string iname, string suffix,
  4851. bit bit_28, bits<2> bits_21_20, bit S,
  4852. bits<2> vecsize, list<dag> pattern=[]>
  4853. : MVE_qDestSrc_rSrc<iname, suffix, vecsize, pattern> {
  4854. let Inst{28} = bit_28;
  4855. let Inst{21-20} = bits_21_20;
  4856. let Inst{16} = 0b1;
  4857. let Inst{12} = S;
  4858. let Inst{8} = 0b0;
  4859. let Inst{5} = 0b0;
  4860. let validForTailPredication = 1;
  4861. let hasSideEffects = 0;
  4862. }
  4863. multiclass MVE_VMLA_qr_multi<string iname, MVEVectorVTInfo VTI,
  4864. bit scalar_addend> {
  4865. def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size,
  4866. scalar_addend, VTI.Size>;
  4867. defvar Inst = !cast<Instruction>(NAME);
  4868. defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_n_predicated");
  4869. defvar v1 = (VTI.Vec MQPR:$v1);
  4870. defvar v2 = (VTI.Vec MQPR:$v2);
  4871. defvar vs = (VTI.Vec (ARMvdup rGPR:$s));
  4872. defvar s = (i32 rGPR:$s);
  4873. defvar pred = (VTI.Pred VCCR:$pred);
  4874. // The signed and unsigned variants of this instruction have different
  4875. // encodings, but they're functionally identical. For the sake of
  4876. // determinism, we generate only the unsigned variant.
  4877. if VTI.Unsigned then let Predicates = [HasMVEInt] in {
  4878. if scalar_addend then {
  4879. def : Pat<(VTI.Vec (add (mul v1, v2), vs)),
  4880. (VTI.Vec (Inst v1, v2, s))>;
  4881. } else {
  4882. def : Pat<(VTI.Vec (add (mul v2, vs), v1)),
  4883. (VTI.Vec (Inst v1, v2, s))>;
  4884. }
  4885. def : Pat<(VTI.Vec (pred_int v1, v2, s, pred)),
  4886. (VTI.Vec (Inst v1, v2, s, ARMVCCThen, pred, zero_reg))>;
  4887. }
  4888. }
  4889. defm MVE_VMLA_qr_s8 : MVE_VMLA_qr_multi<"vmla", MVE_v16s8, 0b0>;
  4890. defm MVE_VMLA_qr_s16 : MVE_VMLA_qr_multi<"vmla", MVE_v8s16, 0b0>;
  4891. defm MVE_VMLA_qr_s32 : MVE_VMLA_qr_multi<"vmla", MVE_v4s32, 0b0>;
  4892. defm MVE_VMLA_qr_u8 : MVE_VMLA_qr_multi<"vmla", MVE_v16u8, 0b0>;
  4893. defm MVE_VMLA_qr_u16 : MVE_VMLA_qr_multi<"vmla", MVE_v8u16, 0b0>;
  4894. defm MVE_VMLA_qr_u32 : MVE_VMLA_qr_multi<"vmla", MVE_v4u32, 0b0>;
  4895. defm MVE_VMLAS_qr_s8 : MVE_VMLA_qr_multi<"vmlas", MVE_v16s8, 0b1>;
  4896. defm MVE_VMLAS_qr_s16 : MVE_VMLA_qr_multi<"vmlas", MVE_v8s16, 0b1>;
  4897. defm MVE_VMLAS_qr_s32 : MVE_VMLA_qr_multi<"vmlas", MVE_v4s32, 0b1>;
  4898. defm MVE_VMLAS_qr_u8 : MVE_VMLA_qr_multi<"vmlas", MVE_v16u8, 0b1>;
  4899. defm MVE_VMLAS_qr_u16 : MVE_VMLA_qr_multi<"vmlas", MVE_v8u16, 0b1>;
  4900. defm MVE_VMLAS_qr_u32 : MVE_VMLA_qr_multi<"vmlas", MVE_v4u32, 0b1>;
  4901. multiclass MVE_VFMA_qr_multi<string iname, MVEVectorVTInfo VTI,
  4902. bit scalar_addend> {
  4903. def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, scalar_addend, VTI.Size>;
  4904. defvar Inst = !cast<Instruction>(NAME);
  4905. defvar pred_int = int_arm_mve_fma_predicated;
  4906. defvar v1 = (VTI.Vec MQPR:$v1);
  4907. defvar v2 = (VTI.Vec MQPR:$v2);
  4908. defvar vs = (VTI.Vec (ARMvdup (i32 rGPR:$s)));
  4909. defvar is = (i32 rGPR:$s);
  4910. defvar pred = (VTI.Pred VCCR:$pred);
  4911. let Predicates = [HasMVEFloat] in {
  4912. if scalar_addend then {
  4913. def : Pat<(VTI.Vec (fma v1, v2, vs)),
  4914. (VTI.Vec (Inst v1, v2, is))>;
  4915. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  4916. (VTI.Vec (fma v1, v2, vs)),
  4917. v1)),
  4918. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
  4919. def : Pat<(VTI.Vec (pred_int v1, v2, vs, pred)),
  4920. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, pred, zero_reg))>;
  4921. } else {
  4922. def : Pat<(VTI.Vec (fma v1, vs, v2)),
  4923. (VTI.Vec (Inst v2, v1, is))>;
  4924. def : Pat<(VTI.Vec (fma vs, v1, v2)),
  4925. (VTI.Vec (Inst v2, v1, is))>;
  4926. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  4927. (VTI.Vec (fma vs, v2, v1)),
  4928. v1)),
  4929. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
  4930. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  4931. (VTI.Vec (fma v2, vs, v1)),
  4932. v1)),
  4933. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
  4934. def : Pat<(VTI.Vec (pred_int v1, vs, v2, pred)),
  4935. (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>;
  4936. def : Pat<(VTI.Vec (pred_int vs, v1, v2, pred)),
  4937. (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>;
  4938. }
  4939. }
  4940. }
  4941. let Predicates = [HasMVEFloat] in {
  4942. defm MVE_VFMA_qr_f16 : MVE_VFMA_qr_multi<"vfma", MVE_v8f16, 0>;
  4943. defm MVE_VFMA_qr_f32 : MVE_VFMA_qr_multi<"vfma", MVE_v4f32, 0>;
  4944. defm MVE_VFMA_qr_Sf16 : MVE_VFMA_qr_multi<"vfmas", MVE_v8f16, 1>;
  4945. defm MVE_VFMA_qr_Sf32 : MVE_VFMA_qr_multi<"vfmas", MVE_v4f32, 1>;
  4946. }
  4947. class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size,
  4948. bit bit_5, bit bit_12, list<dag> pattern=[]>
  4949. : MVE_qDestSrc_rSrc<iname, suffix, size, pattern> {
  4950. let Inst{28} = U;
  4951. let Inst{21-20} = size;
  4952. let Inst{16} = 0b0;
  4953. let Inst{12} = bit_12;
  4954. let Inst{8} = 0b0;
  4955. let Inst{5} = bit_5;
  4956. }
  4957. multiclass MVE_VQDMLAH_qr_multi<string iname, MVEVectorVTInfo VTI,
  4958. bit bit_5, bit bit_12> {
  4959. def "": MVE_VQDMLAH_qr<iname, VTI.Suffix, 0b0, VTI.Size, bit_5, bit_12>;
  4960. defvar Inst = !cast<Instruction>(NAME);
  4961. defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # iname);
  4962. defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_predicated");
  4963. let Predicates = [HasMVEInt] in {
  4964. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4965. (i32 rGPR:$s))),
  4966. (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4967. (i32 rGPR:$s)))>;
  4968. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4969. (i32 rGPR:$s), (VTI.Pred VCCR:$pred))),
  4970. (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4971. (i32 rGPR:$s), ARMVCCThen,
  4972. (VTI.Pred VCCR:$pred), zero_reg))>;
  4973. }
  4974. }
  4975. multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> {
  4976. defm s8 : MVE_VQDMLAH_qr_multi<iname, MVE_v16s8, bit_5, bit_12>;
  4977. defm s16 : MVE_VQDMLAH_qr_multi<iname, MVE_v8s16, bit_5, bit_12>;
  4978. defm s32 : MVE_VQDMLAH_qr_multi<iname, MVE_v4s32, bit_5, bit_12>;
  4979. }
  4980. defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>;
  4981. defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>;
  4982. defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>;
  4983. defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>;
  4984. class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12,
  4985. ValueType VT, SDPatternOperator vxdup>
  4986. : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
  4987. (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary,
  4988. iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src", size,
  4989. [(set (VT MQPR:$Qd), (i32 tGPREven:$Rn),
  4990. (vxdup (i32 tGPREven:$Rn_src), (i32 imm:$imm)))]> {
  4991. bits<4> Qd;
  4992. bits<4> Rn;
  4993. bits<2> imm;
  4994. let Inst{28} = 0b0;
  4995. let Inst{25-23} = 0b100;
  4996. let Inst{22} = Qd{3};
  4997. let Inst{21-20} = size;
  4998. let Inst{19-17} = Rn{3-1};
  4999. let Inst{16} = 0b1;
  5000. let Inst{15-13} = Qd{2-0};
  5001. let Inst{12} = bit_12;
  5002. let Inst{11-8} = 0b1111;
  5003. let Inst{7} = imm{1};
  5004. let Inst{6-1} = 0b110111;
  5005. let Inst{0} = imm{0};
  5006. let validForTailPredication = 1;
  5007. let hasSideEffects = 0;
  5008. }
  5009. def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0, v16i8, ARMvidup>;
  5010. def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0, v8i16, ARMvidup>;
  5011. def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0, v4i32, ARMvidup>;
  5012. def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1, v16i8, null_frag>;
  5013. def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1, v8i16, null_frag>;
  5014. def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1, v4i32, null_frag>;
  5015. class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12,
  5016. list<dag> pattern=[]>
  5017. : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
  5018. (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary,
  5019. iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src", size,
  5020. pattern> {
  5021. bits<4> Qd;
  5022. bits<4> Rm;
  5023. bits<4> Rn;
  5024. bits<2> imm;
  5025. let Inst{28} = 0b0;
  5026. let Inst{25-23} = 0b100;
  5027. let Inst{22} = Qd{3};
  5028. let Inst{21-20} = size;
  5029. let Inst{19-17} = Rn{3-1};
  5030. let Inst{16} = 0b1;
  5031. let Inst{15-13} = Qd{2-0};
  5032. let Inst{12} = bit_12;
  5033. let Inst{11-8} = 0b1111;
  5034. let Inst{7} = imm{1};
  5035. let Inst{6-4} = 0b110;
  5036. let Inst{3-1} = Rm{3-1};
  5037. let Inst{0} = imm{0};
  5038. let validForTailPredication = 1;
  5039. let hasSideEffects = 0;
  5040. }
  5041. def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>;
  5042. def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>;
  5043. def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>;
  5044. def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>;
  5045. def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>;
  5046. def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>;
  5047. let isReMaterializable = 1 in
  5048. class MVE_VCTPInst<string suffix, bits<2> size, list<dag> pattern=[]>
  5049. : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix,
  5050. "$Rn", vpred_n, "", size, pattern> {
  5051. bits<4> Rn;
  5052. let Inst{28-27} = 0b10;
  5053. let Inst{26-22} = 0b00000;
  5054. let Inst{21-20} = size;
  5055. let Inst{19-16} = Rn{3-0};
  5056. let Inst{15-11} = 0b11101;
  5057. let Inst{10-0} = 0b00000000001;
  5058. let Unpredictable{10-0} = 0b11111111111;
  5059. let Constraints = "";
  5060. let DecoderMethod = "DecodeMveVCTP";
  5061. let validForTailPredication = 1;
  5062. }
  5063. multiclass MVE_VCTP<MVEVectorVTInfo VTI, Intrinsic intr> {
  5064. def "": MVE_VCTPInst<VTI.BitsSuffix, VTI.Size>;
  5065. defvar Inst = !cast<Instruction>(NAME);
  5066. let Predicates = [HasMVEInt] in {
  5067. def : Pat<(intr rGPR:$Rn),
  5068. (VTI.Pred (Inst rGPR:$Rn))>;
  5069. def : Pat<(and (intr rGPR:$Rn), (VTI.Pred VCCR:$mask)),
  5070. (VTI.Pred (Inst rGPR:$Rn, ARMVCCThen, VCCR:$mask, zero_reg))>;
  5071. }
  5072. }
  5073. defm MVE_VCTP8 : MVE_VCTP<MVE_v16i8, int_arm_mve_vctp8>;
  5074. defm MVE_VCTP16 : MVE_VCTP<MVE_v8i16, int_arm_mve_vctp16>;
  5075. defm MVE_VCTP32 : MVE_VCTP<MVE_v4i32, int_arm_mve_vctp32>;
  5076. defm MVE_VCTP64 : MVE_VCTP<MVE_v2i64, int_arm_mve_vctp64>;
  5077. // end of mve_qDest_rSrc
  5078. // start of coproc mov
  5079. class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr>
  5080. : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx,
  5081. MVEPairVectorIndex0:$idx2)),
  5082. NoItinerary, "vmov", "", ops, cstr, []> {
  5083. bits<5> Rt;
  5084. bits<5> Rt2;
  5085. bits<4> Qd;
  5086. bit idx;
  5087. bit idx2;
  5088. let Inst{31-23} = 0b111011000;
  5089. let Inst{22} = Qd{3};
  5090. let Inst{21} = 0b0;
  5091. let Inst{20} = to_qreg;
  5092. let Inst{19-16} = Rt2{3-0};
  5093. let Inst{15-13} = Qd{2-0};
  5094. let Inst{12-5} = 0b01111000;
  5095. let Inst{4} = idx2;
  5096. let Inst{3-0} = Rt{3-0};
  5097. let VecSize = 0b10;
  5098. let hasSideEffects = 0;
  5099. }
  5100. // The assembly syntax for these instructions mentions the vector
  5101. // register name twice, e.g.
  5102. //
  5103. // vmov q2[2], q2[0], r0, r1
  5104. // vmov r0, r1, q2[2], q2[0]
  5105. //
  5106. // which needs a bit of juggling with MC operand handling.
  5107. //
  5108. // For the move _into_ a vector register, the MC operand list also has
  5109. // to mention the register name twice: once as the output, and once as
  5110. // an extra input to represent where the unchanged half of the output
  5111. // register comes from (when this instruction is used in code
  5112. // generation). So we arrange that the first mention of the vector reg
  5113. // in the instruction is considered by the AsmMatcher to be the output
  5114. // ($Qd), and the second one is the input ($QdSrc). Binding them
  5115. // together with the existing 'tie' constraint is enough to enforce at
  5116. // register allocation time that they have to be the same register.
  5117. //
  5118. // For the move _from_ a vector register, there's no way to get round
  5119. // the fact that both instances of that register name have to be
  5120. // inputs. They have to be the same register again, but this time, we
  5121. // can't use a tie constraint, because that has to be between an
  5122. // output and an input operand. So this time, we have to arrange that
  5123. // the q-reg appears just once in the MC operand list, in spite of
  5124. // being mentioned twice in the asm syntax - which needs a custom
  5125. // AsmMatchConverter.
  5126. def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd),
  5127. (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2),
  5128. 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2",
  5129. "$Qd = $QdSrc"> {
  5130. let DecoderMethod = "DecodeMVEVMOVDRegtoQ";
  5131. }
  5132. def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd),
  5133. 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> {
  5134. let DecoderMethod = "DecodeMVEVMOVQtoDReg";
  5135. let AsmMatchConverter = "cvtMVEVMOVQtoDReg";
  5136. }
  5137. let Predicates = [HasMVEInt] in {
  5138. // Double lane moves. There are a number of patterns here. We know that the
  5139. // insertelt's will be in descending order by index, and need to match the 5
  5140. // patterns that might contain 2-0 or 3-1 pairs. These are:
  5141. // 3 2 1 0 -> vmovqrr 31; vmovqrr 20
  5142. // 3 2 1 -> vmovqrr 31; vmov 2
  5143. // 3 1 -> vmovqrr 31
  5144. // 2 1 0 -> vmovqrr 20; vmov 1
  5145. // 2 0 -> vmovqrr 20
  5146. // The other potential patterns will be handled by single lane inserts.
  5147. def : Pat<(insertelt (insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
  5148. rGPR:$srcA, (i32 0)),
  5149. rGPR:$srcB, (i32 1)),
  5150. rGPR:$srcC, (i32 2)),
  5151. rGPR:$srcD, (i32 3)),
  5152. (MVE_VMOV_q_rr (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcC, (i32 2), (i32 0)),
  5153. rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>;
  5154. def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
  5155. rGPR:$srcB, (i32 1)),
  5156. rGPR:$srcC, (i32 2)),
  5157. rGPR:$srcD, (i32 3)),
  5158. (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 2)),
  5159. rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>;
  5160. def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 1)), rGPR:$srcB, (i32 3)),
  5161. (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 3), (i32 1))>;
  5162. def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
  5163. rGPR:$srcB, (i32 0)),
  5164. rGPR:$srcC, (i32 1)),
  5165. rGPR:$srcD, (i32 2)),
  5166. (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 1)),
  5167. rGPR:$srcB, rGPR:$srcD, (i32 2), (i32 0))>;
  5168. def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 0)), rGPR:$srcB, (i32 2)),
  5169. (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 2), (i32 0))>;
  5170. }
  5171. // end of coproc mov
  5172. // start of MVE interleaving load/store
  5173. // Base class for the family of interleaving/deinterleaving
  5174. // load/stores with names like VLD20.8 and VST43.32.
  5175. class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size,
  5176. bit load, dag Oops, dag loadIops, dag wbIops,
  5177. string iname, string ops,
  5178. string cstr, list<dag> pattern=[]>
  5179. : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, size, pattern> {
  5180. bits<4> VQd;
  5181. bits<4> Rn;
  5182. let Inst{31-22} = 0b1111110010;
  5183. let Inst{21} = writeback;
  5184. let Inst{20} = load;
  5185. let Inst{19-16} = Rn;
  5186. let Inst{15-13} = VQd{2-0};
  5187. let Inst{12-9} = 0b1111;
  5188. let Inst{8-7} = size;
  5189. let Inst{6-5} = stage;
  5190. let Inst{4-1} = 0b0000;
  5191. let Inst{0} = fourregs;
  5192. let mayLoad = load;
  5193. let mayStore = !eq(load,0);
  5194. let hasSideEffects = 0;
  5195. let validForTailPredication = load;
  5196. }
  5197. // A parameter class used to encapsulate all the ways the writeback
  5198. // variants of VLD20 and friends differ from the non-writeback ones.
  5199. class MVE_vldst24_writeback<bit b, dag Oo, dag Io,
  5200. string sy="", string c="", string n=""> {
  5201. bit writeback = b;
  5202. dag Oops = Oo;
  5203. dag Iops = Io;
  5204. string syntax = sy;
  5205. string cstr = c;
  5206. string id_suffix = n;
  5207. }
  5208. // Another parameter class that encapsulates the differences between VLD2x
  5209. // and VLD4x.
  5210. class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> {
  5211. int nvecs = n;
  5212. list<int> stages = s;
  5213. bit bit0 = b;
  5214. RegisterOperand VecList = vl;
  5215. }
  5216. // A third parameter class that distinguishes VLDnn.8 from .16 from .32.
  5217. class MVE_vldst24_lanesize<int i, bits<2> b> {
  5218. int lanesize = i;
  5219. bits<2> sizebits = b;
  5220. }
  5221. // A base class for each direction of transfer: one for load, one for
  5222. // store. I can't make these a fourth independent parametric tuple
  5223. // class, because they have to take the nvecs tuple class as a
  5224. // parameter, in order to find the right VecList operand type.
  5225. class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
  5226. MVE_vldst24_writeback wb, string iname,
  5227. list<dag> pattern=[]>
  5228. : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1,
  5229. !con((outs n.VecList:$VQd), wb.Oops),
  5230. (ins n.VecList:$VQdSrc), wb.Iops,
  5231. iname, "$VQd, $Rn" # wb.syntax,
  5232. wb.cstr # ",$VQdSrc = $VQd", pattern>;
  5233. class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
  5234. MVE_vldst24_writeback wb, string iname,
  5235. list<dag> pattern=[]>
  5236. : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0,
  5237. wb.Oops, (ins n.VecList:$VQd), wb.Iops,
  5238. iname, "$VQd, $Rn" # wb.syntax,
  5239. wb.cstr, pattern>;
  5240. // Actually define all the interleaving loads and stores, by a series
  5241. // of nested foreaches over number of vectors (VLD2/VLD4); stage
  5242. // within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of
  5243. // vector lane; writeback or no writeback.
  5244. foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>,
  5245. MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in
  5246. foreach stage = n.stages in
  5247. foreach s = [MVE_vldst24_lanesize< 8, 0b00>,
  5248. MVE_vldst24_lanesize<16, 0b01>,
  5249. MVE_vldst24_lanesize<32, 0b10>] in
  5250. foreach wb = [MVE_vldst24_writeback<
  5251. 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn),
  5252. "!", "$Rn.base = $wb", "_wb">,
  5253. MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in {
  5254. // For each case within all of those foreaches, define the actual
  5255. // instructions. The def names are made by gluing together pieces
  5256. // from all the parameter classes, and will end up being things like
  5257. // MVE_VLD20_8 and MVE_VST43_16_wb.
  5258. def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
  5259. : MVE_vld24_base<n, stage, s.sizebits, wb,
  5260. "vld" # n.nvecs # stage # "." # s.lanesize>;
  5261. def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
  5262. : MVE_vst24_base<n, stage, s.sizebits, wb,
  5263. "vst" # n.nvecs # stage # "." # s.lanesize>;
  5264. }
  5265. def SDTARMVST2 : SDTypeProfile<1, 5, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>,
  5266. SDTCisSameAs<3, 4>, SDTCisVT<5, i32>]>;
  5267. def SDTARMVST4 : SDTypeProfile<1, 7, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>,
  5268. SDTCisSameAs<3, 4>, SDTCisSameAs<3, 5>,
  5269. SDTCisSameAs<3, 6>, SDTCisVT<7, i32>]>;
  5270. def MVEVST2UPD : SDNode<"ARMISD::VST2_UPD", SDTARMVST2, [SDNPHasChain, SDNPMemOperand]>;
  5271. def MVEVST4UPD : SDNode<"ARMISD::VST4_UPD", SDTARMVST4, [SDNPHasChain, SDNPMemOperand]>;
  5272. multiclass MVE_vst24_patterns<int lanesize, ValueType VT> {
  5273. foreach stage = [0,1] in
  5274. def : Pat<(int_arm_mve_vst2q i32:$addr,
  5275. (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage)),
  5276. (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize)
  5277. (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1),
  5278. t2_addr_offset_none:$addr)>;
  5279. foreach stage = [0,1] in
  5280. def : Pat<(i32 (MVEVST2UPD i32:$addr, (i32 32),
  5281. (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage))),
  5282. (i32 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize#_wb)
  5283. (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1),
  5284. t2_addr_offset_none:$addr))>;
  5285. foreach stage = [0,1,2,3] in
  5286. def : Pat<(int_arm_mve_vst4q i32:$addr,
  5287. (VT MQPR:$v0), (VT MQPR:$v1),
  5288. (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage)),
  5289. (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize)
  5290. (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1,
  5291. VT:$v2, qsub_2, VT:$v3, qsub_3),
  5292. t2_addr_offset_none:$addr)>;
  5293. foreach stage = [0,1,2,3] in
  5294. def : Pat<(i32 (MVEVST4UPD i32:$addr, (i32 64),
  5295. (VT MQPR:$v0), (VT MQPR:$v1),
  5296. (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage))),
  5297. (i32 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize#_wb)
  5298. (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1,
  5299. VT:$v2, qsub_2, VT:$v3, qsub_3),
  5300. t2_addr_offset_none:$addr))>;
  5301. }
  5302. defm : MVE_vst24_patterns<8, v16i8>;
  5303. defm : MVE_vst24_patterns<16, v8i16>;
  5304. defm : MVE_vst24_patterns<32, v4i32>;
  5305. defm : MVE_vst24_patterns<16, v8f16>;
  5306. defm : MVE_vst24_patterns<32, v4f32>;
  5307. // end of MVE interleaving load/store
  5308. // start of MVE predicable load/store
  5309. // A parameter class for the direction of transfer.
  5310. class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> {
  5311. bit load = b;
  5312. dag Oops = Oo;
  5313. dag Iops = Io;
  5314. string cstr = c;
  5315. }
  5316. def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">;
  5317. def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>;
  5318. // A parameter class for the size of memory access in a load.
  5319. class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> {
  5320. bits<2> encoding = e; // opcode bit(s) for encoding
  5321. int shift = s; // shift applied to immediate load offset
  5322. AddrMode AM = m;
  5323. // For instruction aliases: define the complete list of type
  5324. // suffixes at this size, and the canonical ones for loads and
  5325. // stores.
  5326. string MnemonicLetter = mn;
  5327. int TypeBits = !shl(8, s);
  5328. string CanonLoadSuffix = ".u" # TypeBits;
  5329. string CanonStoreSuffix = "." # TypeBits;
  5330. list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits);
  5331. }
  5332. // Instances of MVE_memsz.
  5333. //
  5334. // (memD doesn't need an AddrMode, because those are only for
  5335. // contiguous loads, and memD is only used by gather/scatters.)
  5336. def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>;
  5337. def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>;
  5338. def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>;
  5339. def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>;
  5340. // This is the base class for all the MVE loads and stores other than
  5341. // the interleaving ones. All the non-interleaving loads/stores share
  5342. // the characteristic that they operate on just one vector register,
  5343. // so they are VPT-predicable.
  5344. //
  5345. // The predication operand is vpred_n, for both loads and stores. For
  5346. // store instructions, the reason is obvious: if there is no output
  5347. // register, there can't be a need for an input parameter giving the
  5348. // output register's previous value. Load instructions also don't need
  5349. // that input parameter, because unlike MVE data processing
  5350. // instructions, predicated loads are defined to set the inactive
  5351. // lanes of the output register to zero, instead of preserving their
  5352. // input values.
  5353. class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc,
  5354. dag oops, dag iops, string asm, string suffix,
  5355. string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  5356. : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, vecsize, pattern> {
  5357. bits<3> Qd;
  5358. let Inst{28} = U;
  5359. let Inst{25} = 0b0;
  5360. let Inst{24} = P;
  5361. let Inst{22} = 0b0;
  5362. let Inst{21} = W;
  5363. let Inst{20} = dir.load;
  5364. let Inst{15-13} = Qd{2-0};
  5365. let Inst{12} = opc;
  5366. let Inst{11-9} = 0b111;
  5367. let mayLoad = dir.load;
  5368. let mayStore = !eq(dir.load,0);
  5369. let hasSideEffects = 0;
  5370. let validForTailPredication = 1;
  5371. }
  5372. // Contiguous load and store instructions. These come in two main
  5373. // categories: same-size loads/stores in which 128 bits of vector
  5374. // register is transferred to or from 128 bits of memory in the most
  5375. // obvious way, and widening loads / narrowing stores, in which the
  5376. // size of memory accessed is less than the size of a vector register,
  5377. // so the load instructions sign- or zero-extend each memory value
  5378. // into a wider vector lane, and the store instructions truncate
  5379. // correspondingly.
  5380. //
  5381. // The instruction mnemonics for these two classes look reasonably
  5382. // similar, but the actual encodings are different enough to need two
  5383. // separate base classes.
  5384. // Contiguous, same size
  5385. class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W,
  5386. dag oops, dag iops, string asm, string suffix,
  5387. IndexMode im, string ops, string cstr>
  5388. : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr, memsz.encoding> {
  5389. bits<12> addr;
  5390. let Inst{23} = addr{7};
  5391. let Inst{19-16} = addr{11-8};
  5392. let Inst{8-7} = memsz.encoding;
  5393. let Inst{6-0} = addr{6-0};
  5394. let IM = im;
  5395. }
  5396. // Contiguous, widening/narrowing
  5397. class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
  5398. bit P, bit W, bits<2> size, dag oops, dag iops,
  5399. string asm, string suffix, IndexMode im,
  5400. string ops, string cstr>
  5401. : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr, size> {
  5402. bits<11> addr;
  5403. let Inst{23} = addr{7};
  5404. let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit
  5405. let Inst{18-16} = addr{10-8};
  5406. let Inst{8-7} = size;
  5407. let Inst{6-0} = addr{6-0};
  5408. let IM = im;
  5409. }
  5410. // Multiclass wrapper on each of the _cw and _cs base classes, to
  5411. // generate three writeback modes (none, preindex, postindex).
  5412. multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz,
  5413. string asm, string suffix, bit U, bits<2> size> {
  5414. let AM = memsz.AM in {
  5415. def "" : MVE_VLDRSTR_cw<
  5416. dir, memsz, U, 1, 0, size,
  5417. dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
  5418. asm, suffix, IndexModeNone, "$Qd, $addr", "">;
  5419. def _pre : MVE_VLDRSTR_cw<
  5420. dir, memsz, U, 1, 1, size,
  5421. !con((outs tGPR:$wb), dir.Oops),
  5422. !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
  5423. asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
  5424. let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">";
  5425. }
  5426. def _post : MVE_VLDRSTR_cw<
  5427. dir, memsz, U, 0, 1, size,
  5428. !con((outs tGPR:$wb), dir.Oops),
  5429. !con(dir.Iops, (ins t_addr_offset_none:$Rn,
  5430. t2am_imm7_offset<memsz.shift>:$addr)),
  5431. asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
  5432. bits<4> Rn;
  5433. let Inst{18-16} = Rn{2-0};
  5434. }
  5435. }
  5436. }
  5437. multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz,
  5438. string asm, string suffix> {
  5439. let AM = memsz.AM in {
  5440. def "" : MVE_VLDRSTR_cs<
  5441. dir, memsz, 1, 0,
  5442. dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)),
  5443. asm, suffix, IndexModeNone, "$Qd, $addr", "">;
  5444. def _pre : MVE_VLDRSTR_cs<
  5445. dir, memsz, 1, 1,
  5446. !con((outs rGPR:$wb), dir.Oops),
  5447. !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)),
  5448. asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
  5449. let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">";
  5450. }
  5451. def _post : MVE_VLDRSTR_cs<
  5452. dir, memsz, 0, 1,
  5453. !con((outs rGPR:$wb), dir.Oops),
  5454. !con(dir.Iops, (ins t2_nosp_addr_offset_none:$Rn,
  5455. t2am_imm7_offset<memsz.shift>:$addr)),
  5456. asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
  5457. bits<4> Rn;
  5458. let Inst{19-16} = Rn{3-0};
  5459. }
  5460. }
  5461. }
  5462. // Now actually declare all the contiguous load/stores, via those
  5463. // multiclasses. The instruction ids coming out of this are the bare
  5464. // names shown in the defm, with _pre or _post appended for writeback,
  5465. // e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post.
  5466. defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>;
  5467. defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>;
  5468. defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>;
  5469. defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>;
  5470. defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>;
  5471. defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>;
  5472. defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">;
  5473. defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">;
  5474. defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">;
  5475. defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>;
  5476. defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>;
  5477. defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>;
  5478. defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">;
  5479. defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">;
  5480. defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">;
  5481. // Gather loads / scatter stores whose address operand is of the form
  5482. // [Rn,Qm], i.e. a single GPR as the common base address, plus a
  5483. // vector of offset from it. ('Load/store this sequence of elements of
  5484. // the same array.')
  5485. //
  5486. // Like the contiguous family, these loads and stores can widen the
  5487. // loaded values / truncate the stored ones, or they can just
  5488. // load/store the same size of memory and vector lane. But unlike the
  5489. // contiguous family, there's no particular difference in encoding
  5490. // between those two cases.
  5491. //
  5492. // This family also comes with the option to scale the offset values
  5493. // in Qm by the size of the loaded memory (i.e. to treat them as array
  5494. // indices), or not to scale them (to treat them as plain byte offsets
  5495. // in memory, so that perhaps the loaded values are unaligned). The
  5496. // scaled instructions' address operand in assembly looks like
  5497. // [Rn,Qm,UXTW #2] or similar.
  5498. // Base class.
  5499. class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
  5500. bits<2> size, bit os, string asm, string suffix, int shift>
  5501. : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops,
  5502. !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)),
  5503. asm, suffix, "$Qd, $addr", dir.cstr, size> {
  5504. bits<7> addr;
  5505. let Inst{23} = 0b1;
  5506. let Inst{19-16} = addr{6-3};
  5507. let Inst{8-7} = size;
  5508. let Inst{6} = memsz.encoding{1};
  5509. let Inst{5} = 0;
  5510. let Inst{4} = memsz.encoding{0};
  5511. let Inst{3-1} = addr{2-0};
  5512. let Inst{0} = os;
  5513. }
  5514. // Multiclass that defines the scaled and unscaled versions of an
  5515. // instruction, when the memory size is wider than a byte. The scaled
  5516. // version gets the default name like MVE_VLDRBU16_rq; the unscaled /
  5517. // potentially unaligned version gets a "_u" suffix, e.g.
  5518. // MVE_VLDRBU16_rq_u.
  5519. multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz,
  5520. string asm, string suffix, bit U, bits<2> size> {
  5521. def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
  5522. def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>;
  5523. }
  5524. // Subclass of MVE_VLDRSTR_rq with the same API as that multiclass,
  5525. // for use when the memory size is one byte, so there's no 'scaled'
  5526. // version of the instruction at all. (This is encoded as if it were
  5527. // unscaled, but named in the default way with no _u suffix.)
  5528. class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz,
  5529. string asm, string suffix, bit U, bits<2> size>
  5530. : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
  5531. // Multiclasses wrapping that to add ISel patterns for intrinsics.
  5532. multiclass MVE_VLDR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> {
  5533. defm "": MVE_VLDRSTR_rq_w<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter,
  5534. VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>;
  5535. defvar Inst = !cast<Instruction>(NAME);
  5536. defvar InstU = !cast<Instruction>(NAME # "_u");
  5537. foreach VTI = VTIs in
  5538. foreach UnsignedFlag = !if(!eq(VTI.Size, memsz.encoding),
  5539. [0,1], [VTI.Unsigned]) in {
  5540. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, 0, UnsignedFlag)),
  5541. (VTI.Vec (InstU GPR:$base, MQPR:$offsets))>;
  5542. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, memsz.shift, UnsignedFlag)),
  5543. (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>;
  5544. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, 0, UnsignedFlag, (VTI.Pred VCCR:$pred))),
  5545. (VTI.Vec (InstU GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
  5546. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, memsz.shift, UnsignedFlag, (VTI.Pred VCCR:$pred))),
  5547. (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
  5548. }
  5549. }
  5550. multiclass MVE_VLDR_rq_b<list<MVEVectorVTInfo> VTIs> {
  5551. def "": MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb",
  5552. VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>;
  5553. defvar Inst = !cast<Instruction>(NAME);
  5554. foreach VTI = VTIs in {
  5555. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), 8, 0, VTI.Unsigned)),
  5556. (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>;
  5557. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), 8, 0, VTI.Unsigned, (VTI.Pred VCCR:$pred))),
  5558. (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
  5559. }
  5560. }
  5561. multiclass MVE_VSTR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> {
  5562. defm "": MVE_VLDRSTR_rq_w<MVE_st, memsz, "vstr" # memsz.MnemonicLetter,
  5563. VTIs[0].BitsSuffix, 0, VTIs[0].Size>;
  5564. defvar Inst = !cast<Instruction>(NAME);
  5565. defvar InstU = !cast<Instruction>(NAME # "_u");
  5566. foreach VTI = VTIs in {
  5567. def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, 0),
  5568. (InstU MQPR:$data, GPR:$base, MQPR:$offsets)>;
  5569. def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, memsz.shift),
  5570. (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>;
  5571. def : Pat<(int_arm_mve_vstr_scatter_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, 0, (VTI.Pred VCCR:$pred)),
  5572. (InstU MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
  5573. def : Pat<(int_arm_mve_vstr_scatter_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, memsz.shift, (VTI.Pred VCCR:$pred)),
  5574. (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
  5575. }
  5576. }
  5577. multiclass MVE_VSTR_rq_b<list<MVEVectorVTInfo> VTIs> {
  5578. def "": MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb",
  5579. VTIs[0].BitsSuffix, 0, VTIs[0].Size>;
  5580. defvar Inst = !cast<Instruction>(NAME);
  5581. foreach VTI = VTIs in {
  5582. def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), 8, 0),
  5583. (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>;
  5584. def : Pat<(int_arm_mve_vstr_scatter_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), 8, 0, (VTI.Pred VCCR:$pred)),
  5585. (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
  5586. }
  5587. }
  5588. // Actually define all the loads and stores in this family.
  5589. defm MVE_VLDRBU8_rq : MVE_VLDR_rq_b<[MVE_v16u8,MVE_v16s8]>;
  5590. defm MVE_VLDRBU16_rq: MVE_VLDR_rq_b<[MVE_v8u16]>;
  5591. defm MVE_VLDRBS16_rq: MVE_VLDR_rq_b<[MVE_v8s16]>;
  5592. defm MVE_VLDRBU32_rq: MVE_VLDR_rq_b<[MVE_v4u32]>;
  5593. defm MVE_VLDRBS32_rq: MVE_VLDR_rq_b<[MVE_v4s32]>;
  5594. defm MVE_VLDRHU16_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v8u16,MVE_v8s16,MVE_v8f16]>;
  5595. defm MVE_VLDRHU32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4u32]>;
  5596. defm MVE_VLDRHS32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4s32]>;
  5597. defm MVE_VLDRWU32_rq: MVE_VLDR_rq_w<MVE_memW, [MVE_v4u32,MVE_v4s32,MVE_v4f32]>;
  5598. defm MVE_VLDRDU64_rq: MVE_VLDR_rq_w<MVE_memD, [MVE_v2u64,MVE_v2s64]>;
  5599. defm MVE_VSTRB8_rq : MVE_VSTR_rq_b<[MVE_v16i8]>;
  5600. defm MVE_VSTRB16_rq : MVE_VSTR_rq_b<[MVE_v8i16]>;
  5601. defm MVE_VSTRB32_rq : MVE_VSTR_rq_b<[MVE_v4i32]>;
  5602. defm MVE_VSTRH16_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v8i16,MVE_v8f16]>;
  5603. defm MVE_VSTRH32_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v4i32]>;
  5604. defm MVE_VSTRW32_rq : MVE_VSTR_rq_w<MVE_memW, [MVE_v4i32,MVE_v4f32]>;
  5605. defm MVE_VSTRD64_rq : MVE_VSTR_rq_w<MVE_memD, [MVE_v2i64]>;
  5606. // Gather loads / scatter stores whose address operand is of the form
  5607. // [Qm,#imm], i.e. a vector containing a full base address for each
  5608. // loaded item, plus an immediate offset applied consistently to all
  5609. // of them. ('Load/store the same field from this vector of pointers
  5610. // to a structure type.')
  5611. //
  5612. // This family requires the vector lane size to be at least 32 bits
  5613. // (so there's room for an address in each lane at all). It has no
  5614. // widening/narrowing variants. But it does support preindex
  5615. // writeback, in which the address vector is updated to hold the
  5616. // addresses actually loaded from.
  5617. // Base class.
  5618. class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops,
  5619. string asm, string wbAsm, string suffix, string cstr = "">
  5620. : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops),
  5621. !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)),
  5622. asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr, memsz.encoding> {
  5623. bits<11> addr;
  5624. let Inst{23} = addr{7};
  5625. let Inst{19-17} = addr{10-8};
  5626. let Inst{16} = 0;
  5627. let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit
  5628. let Inst{7} = 0;
  5629. let Inst{6-0} = addr{6-0};
  5630. }
  5631. // Multiclass that generates the non-writeback and writeback variants.
  5632. multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz,
  5633. string asm, string suffix> {
  5634. def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>;
  5635. def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix,
  5636. "$addr.base = $wb"> {
  5637. let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">";
  5638. }
  5639. }
  5640. // Multiclasses wrapping that one, adding selection patterns for the
  5641. // non-writeback loads and all the stores. (The writeback loads must
  5642. // deliver multiple output values, so they have to be selected by C++
  5643. // code.)
  5644. multiclass MVE_VLDR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI,
  5645. list<MVEVectorVTInfo> DVTIs> {
  5646. defm "" : MVE_VLDRSTR_qi_m<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter,
  5647. "u" # memsz.TypeBits>;
  5648. defvar Inst = !cast<Instruction>(NAME);
  5649. foreach DVTI = DVTIs in {
  5650. def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base
  5651. (AVTI.Vec MQPR:$addr), (i32 imm:$offset))),
  5652. (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset)))>;
  5653. def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base_predicated
  5654. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (AVTI.Pred VCCR:$pred))),
  5655. (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset),
  5656. ARMVCCThen, VCCR:$pred, zero_reg))>;
  5657. }
  5658. }
  5659. multiclass MVE_VSTR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI,
  5660. list<MVEVectorVTInfo> DVTIs> {
  5661. defm "" : MVE_VLDRSTR_qi_m<MVE_st, memsz, "vstr" # memsz.MnemonicLetter,
  5662. !cast<string>(memsz.TypeBits)>;
  5663. defvar Inst = !cast<Instruction>(NAME);
  5664. defvar InstPre = !cast<Instruction>(NAME # "_pre");
  5665. foreach DVTI = DVTIs in {
  5666. def : Pat<(int_arm_mve_vstr_scatter_base
  5667. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data)),
  5668. (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5669. (i32 imm:$offset))>;
  5670. def : Pat<(int_arm_mve_vstr_scatter_base_predicated
  5671. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred)),
  5672. (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5673. (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg)>;
  5674. def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb
  5675. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data))),
  5676. (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5677. (i32 imm:$offset)))>;
  5678. def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb_predicated
  5679. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred))),
  5680. (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5681. (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg))>;
  5682. }
  5683. }
  5684. // Actual instruction definitions.
  5685. defm MVE_VLDRWU32_qi: MVE_VLDR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>;
  5686. defm MVE_VLDRDU64_qi: MVE_VLDR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>;
  5687. defm MVE_VSTRW32_qi: MVE_VSTR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>;
  5688. defm MVE_VSTRD64_qi: MVE_VSTR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>;
  5689. // Define aliases for all the instructions where memory size and
  5690. // vector lane size are the same. These are mnemonic aliases, so they
  5691. // apply consistently across all of the above families - contiguous
  5692. // loads, and both the rq and qi types of gather/scatter.
  5693. //
  5694. // Rationale: As long as you're loading (for example) 16-bit memory
  5695. // values into 16-bit vector lanes, you can think of them as signed or
  5696. // unsigned integers, fp16 or just raw 16-bit blobs and it makes no
  5697. // difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16,
  5698. // vldrh.f16 and treat them all as equivalent to the canonical
  5699. // spelling (which happens to be .u16 for loads, and just .16 for
  5700. // stores).
  5701. foreach vpt_cond = ["", "t", "e"] in
  5702. foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in
  5703. foreach suffix = memsz.suffixes in {
  5704. // Define an alias with every suffix in the list, except for the one
  5705. // used by the real Instruction record (i.e. the one that all the
  5706. // rest are aliases *for*).
  5707. if !ne(suffix, memsz.CanonLoadSuffix) then {
  5708. def : MnemonicAlias<
  5709. "vldr" # memsz.MnemonicLetter # vpt_cond # suffix,
  5710. "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>;
  5711. }
  5712. if !ne(suffix, memsz.CanonStoreSuffix) then {
  5713. def : MnemonicAlias<
  5714. "vstr" # memsz.MnemonicLetter # vpt_cond # suffix,
  5715. "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>;
  5716. }
  5717. }
  5718. // end of MVE predicable load/store
  5719. class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]>
  5720. : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", size, pattern> {
  5721. bits<3> fc;
  5722. bits<4> Mk;
  5723. bits<3> Qn;
  5724. let Inst{31-23} = 0b111111100;
  5725. let Inst{22} = Mk{3};
  5726. let Inst{21-20} = size;
  5727. let Inst{19-17} = Qn{2-0};
  5728. let Inst{16} = 0b1;
  5729. let Inst{15-13} = Mk{2-0};
  5730. let Inst{12} = fc{2};
  5731. let Inst{11-8} = 0b1111;
  5732. let Inst{7} = fc{0};
  5733. let Inst{4} = 0b0;
  5734. let Defs = [VPR];
  5735. let validForTailPredication=1;
  5736. }
  5737. class MVE_VPTt1<string suffix, bits<2> size, dag iops>
  5738. : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> {
  5739. bits<4> Qm;
  5740. bits<4> Mk;
  5741. let Inst{6} = 0b0;
  5742. let Inst{5} = Qm{3};
  5743. let Inst{3-1} = Qm{2-0};
  5744. let Inst{0} = fc{1};
  5745. }
  5746. class MVE_VPTt1i<string suffix, bits<2> size>
  5747. : MVE_VPTt1<suffix, size,
  5748. (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_i:$fc)> {
  5749. let Inst{12} = 0b0;
  5750. let Inst{0} = 0b0;
  5751. }
  5752. def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>;
  5753. def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>;
  5754. def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>;
  5755. class MVE_VPTt1u<string suffix, bits<2> size>
  5756. : MVE_VPTt1<suffix, size,
  5757. (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_u:$fc)> {
  5758. let Inst{12} = 0b0;
  5759. let Inst{0} = 0b1;
  5760. }
  5761. def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>;
  5762. def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>;
  5763. def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>;
  5764. class MVE_VPTt1s<string suffix, bits<2> size>
  5765. : MVE_VPTt1<suffix, size,
  5766. (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_s:$fc)> {
  5767. let Inst{12} = 0b1;
  5768. }
  5769. def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>;
  5770. def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>;
  5771. def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>;
  5772. class MVE_VPTt2<string suffix, bits<2> size, dag iops>
  5773. : MVE_VPT<suffix, size, iops,
  5774. "$fc, $Qn, $Rm"> {
  5775. bits<4> Rm;
  5776. bits<3> fc;
  5777. bits<4> Mk;
  5778. let Inst{6} = 0b1;
  5779. let Inst{5} = fc{1};
  5780. let Inst{3-0} = Rm{3-0};
  5781. }
  5782. class MVE_VPTt2i<string suffix, bits<2> size>
  5783. : MVE_VPTt2<suffix, size,
  5784. (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_i:$fc)> {
  5785. let Inst{12} = 0b0;
  5786. let Inst{5} = 0b0;
  5787. }
  5788. def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>;
  5789. def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>;
  5790. def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>;
  5791. class MVE_VPTt2u<string suffix, bits<2> size>
  5792. : MVE_VPTt2<suffix, size,
  5793. (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_u:$fc)> {
  5794. let Inst{12} = 0b0;
  5795. let Inst{5} = 0b1;
  5796. }
  5797. def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>;
  5798. def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>;
  5799. def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>;
  5800. class MVE_VPTt2s<string suffix, bits<2> size>
  5801. : MVE_VPTt2<suffix, size,
  5802. (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_s:$fc)> {
  5803. let Inst{12} = 0b1;
  5804. }
  5805. def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>;
  5806. def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>;
  5807. def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>;
  5808. class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]>
  5809. : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm,
  5810. "", !if(size, 0b01, 0b10), pattern> {
  5811. bits<3> fc;
  5812. bits<4> Mk;
  5813. bits<3> Qn;
  5814. let Inst{31-29} = 0b111;
  5815. let Inst{28} = size;
  5816. let Inst{27-23} = 0b11100;
  5817. let Inst{22} = Mk{3};
  5818. let Inst{21-20} = 0b11;
  5819. let Inst{19-17} = Qn{2-0};
  5820. let Inst{16} = 0b1;
  5821. let Inst{15-13} = Mk{2-0};
  5822. let Inst{12} = fc{2};
  5823. let Inst{11-8} = 0b1111;
  5824. let Inst{7} = fc{0};
  5825. let Inst{4} = 0b0;
  5826. let Defs = [VPR];
  5827. let Predicates = [HasMVEFloat];
  5828. let validForTailPredication=1;
  5829. }
  5830. class MVE_VPTft1<string suffix, bit size>
  5831. : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_fp:$fc),
  5832. "$fc, $Qn, $Qm"> {
  5833. bits<3> fc;
  5834. bits<4> Qm;
  5835. let Inst{6} = 0b0;
  5836. let Inst{5} = Qm{3};
  5837. let Inst{3-1} = Qm{2-0};
  5838. let Inst{0} = fc{1};
  5839. }
  5840. def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>;
  5841. def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>;
  5842. class MVE_VPTft2<string suffix, bit size>
  5843. : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_fp:$fc),
  5844. "$fc, $Qn, $Rm"> {
  5845. bits<3> fc;
  5846. bits<4> Rm;
  5847. let Inst{6} = 0b1;
  5848. let Inst{5} = fc{1};
  5849. let Inst{3-0} = Rm{3-0};
  5850. }
  5851. def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>;
  5852. def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>;
  5853. def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary,
  5854. !strconcat("vpst", "${Mk}"), "", "", 0b00, []> {
  5855. bits<4> Mk;
  5856. let Inst{31-23} = 0b111111100;
  5857. let Inst{22} = Mk{3};
  5858. let Inst{21-16} = 0b110001;
  5859. let Inst{15-13} = Mk{2-0};
  5860. let Inst{12-0} = 0b0111101001101;
  5861. let Unpredictable{12} = 0b1;
  5862. let Unpredictable{7} = 0b1;
  5863. let Unpredictable{5} = 0b1;
  5864. let Uses = [VPR];
  5865. let validForTailPredication = 1;
  5866. }
  5867. def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
  5868. "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", 0b00, []> {
  5869. bits<4> Qn;
  5870. bits<4> Qd;
  5871. bits<4> Qm;
  5872. let Inst{28} = 0b1;
  5873. let Inst{25-23} = 0b100;
  5874. let Inst{22} = Qd{3};
  5875. let Inst{21-20} = 0b11;
  5876. let Inst{19-17} = Qn{2-0};
  5877. let Inst{16} = 0b1;
  5878. let Inst{15-13} = Qd{2-0};
  5879. let Inst{12-9} = 0b0111;
  5880. let Inst{8} = 0b1;
  5881. let Inst{7} = Qn{3};
  5882. let Inst{6} = 0b0;
  5883. let Inst{5} = Qm{3};
  5884. let Inst{4} = 0b0;
  5885. let Inst{3-1} = Qm{2-0};
  5886. let Inst{0} = 0b1;
  5887. }
  5888. foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32",
  5889. "i8", "i16", "i32", "f16", "f32"] in
  5890. def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm",
  5891. (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  5892. let Predicates = [HasMVEInt] in {
  5893. def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
  5894. (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5895. def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
  5896. (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5897. def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
  5898. (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5899. def : Pat<(v2i64 (vselect (v2i1 VCCR:$pred), (v2i64 MQPR:$v1), (v2i64 MQPR:$v2))),
  5900. (v2i64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5901. def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
  5902. (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5903. def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
  5904. (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5905. def : Pat<(v2f64 (vselect (v2i1 VCCR:$pred), (v2f64 MQPR:$v1), (v2f64 MQPR:$v2))),
  5906. (v2f64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5907. def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
  5908. (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5909. (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), ARMCCne), zero_reg))>;
  5910. def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
  5911. (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5912. (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>;
  5913. def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
  5914. (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5915. (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>;
  5916. def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
  5917. (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5918. (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>;
  5919. def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
  5920. (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5921. (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>;
  5922. // Pred <-> Int
  5923. def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))),
  5924. (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5925. def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))),
  5926. (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5927. def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))),
  5928. (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5929. def : Pat<(v2i64 (zext (v2i1 VCCR:$pred))),
  5930. (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5931. def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))),
  5932. (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5933. def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))),
  5934. (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5935. def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))),
  5936. (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5937. def : Pat<(v2i64 (sext (v2i1 VCCR:$pred))),
  5938. (v2i64 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5939. def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))),
  5940. (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5941. def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))),
  5942. (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5943. def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))),
  5944. (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5945. def : Pat<(v2i64 (anyext (v2i1 VCCR:$pred))),
  5946. (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5947. }
  5948. let Predicates = [HasMVEFloat] in {
  5949. // Pred <-> Float
  5950. // 112 is 1.0 in float
  5951. def : Pat<(v4f32 (uint_to_fp (v4i1 VCCR:$pred))),
  5952. (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 112)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5953. // 2620 in 1.0 in half
  5954. def : Pat<(v8f16 (uint_to_fp (v8i1 VCCR:$pred))),
  5955. (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2620)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5956. // 240 is -1.0 in float
  5957. def : Pat<(v4f32 (sint_to_fp (v4i1 VCCR:$pred))),
  5958. (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 240)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5959. // 2748 is -1.0 in half
  5960. def : Pat<(v8f16 (sint_to_fp (v8i1 VCCR:$pred))),
  5961. (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2748)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5962. def : Pat<(v4i1 (fp_to_uint (v4f32 MQPR:$v1))),
  5963. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>;
  5964. def : Pat<(v8i1 (fp_to_uint (v8f16 MQPR:$v1))),
  5965. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>;
  5966. def : Pat<(v4i1 (fp_to_sint (v4f32 MQPR:$v1))),
  5967. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>;
  5968. def : Pat<(v8i1 (fp_to_sint (v8f16 MQPR:$v1))),
  5969. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>;
  5970. }
  5971. def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary,
  5972. "vpnot", "", "", vpred_n, "", 0b00, []> {
  5973. let Inst{31-0} = 0b11111110001100010000111101001101;
  5974. let Unpredictable{19-17} = 0b111;
  5975. let Unpredictable{12} = 0b1;
  5976. let Unpredictable{7} = 0b1;
  5977. let Unpredictable{5} = 0b1;
  5978. let Constraints = "";
  5979. let DecoderMethod = "DecodeMVEVPNOT";
  5980. }
  5981. let Predicates = [HasMVEInt] in {
  5982. def : Pat<(v2i1 (xor (v2i1 VCCR:$pred), (v2i1 (predicate_cast (i32 65535))))),
  5983. (v2i1 (MVE_VPNOT (v2i1 VCCR:$pred)))>;
  5984. def : Pat<(v4i1 (xor (v4i1 VCCR:$pred), (v4i1 (predicate_cast (i32 65535))))),
  5985. (v4i1 (MVE_VPNOT (v4i1 VCCR:$pred)))>;
  5986. def : Pat<(v8i1 (xor (v8i1 VCCR:$pred), (v8i1 (predicate_cast (i32 65535))))),
  5987. (v8i1 (MVE_VPNOT (v8i1 VCCR:$pred)))>;
  5988. def : Pat<(v16i1 (xor (v16i1 VCCR:$pred), (v16i1 (predicate_cast (i32 65535))))),
  5989. (v16i1 (MVE_VPNOT (v16i1 VCCR:$pred)))>;
  5990. }
  5991. class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size>
  5992. : t2LOL<(outs GPRlr:$LR), iops, asm, ops> {
  5993. bits<4> Rn;
  5994. let Predicates = [HasMVEInt];
  5995. let Inst{22} = 0b0;
  5996. let Inst{21-20} = size;
  5997. let Inst{19-16} = Rn{3-0};
  5998. let Inst{12} = 0b0;
  5999. }
  6000. class MVE_DLSTP<string asm, bits<2> size>
  6001. : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> {
  6002. let Inst{13} = 0b1;
  6003. let Inst{11-1} = 0b00000000000;
  6004. let Unpredictable{10-1} = 0b1111111111;
  6005. }
  6006. class MVE_WLSTP<string asm, bits<2> size>
  6007. : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label),
  6008. asm, "$LR, $Rn, $label", size> {
  6009. bits<11> label;
  6010. let Inst{13} = 0b0;
  6011. let Inst{11} = label{0};
  6012. let Inst{10-1} = label{10-1};
  6013. let isBranch = 1;
  6014. let isTerminator = 1;
  6015. }
  6016. def SDT_MVEMEMCPYLOOPNODE
  6017. : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
  6018. def MVE_MEMCPYLOOPNODE : SDNode<"ARMISD::MEMCPYLOOP", SDT_MVEMEMCPYLOOPNODE,
  6019. [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
  6020. let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in {
  6021. def MVE_MEMCPYLOOPINST : PseudoInst<(outs),
  6022. (ins rGPR:$dst, rGPR:$src, rGPR:$sz),
  6023. NoItinerary,
  6024. [(MVE_MEMCPYLOOPNODE rGPR:$dst, rGPR:$src, rGPR:$sz)]>;
  6025. }
  6026. def SDT_MVEMEMSETLOOPNODE
  6027. : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisVT<1, v16i8>, SDTCisVT<2, i32>]>;
  6028. def MVE_MEMSETLOOPNODE : SDNode<"ARMISD::MEMSETLOOP", SDT_MVEMEMSETLOOPNODE,
  6029. [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
  6030. let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in {
  6031. def MVE_MEMSETLOOPINST : PseudoInst<(outs),
  6032. (ins rGPR:$dst, MQPR:$src, rGPR:$sz),
  6033. NoItinerary,
  6034. [(MVE_MEMSETLOOPNODE rGPR:$dst, MQPR:$src, rGPR:$sz)]>;
  6035. }
  6036. def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>;
  6037. def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>;
  6038. def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>;
  6039. def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>;
  6040. def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>;
  6041. def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>;
  6042. def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>;
  6043. def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>;
  6044. class MVE_loltp_end<dag oops, dag iops, string asm, string ops>
  6045. : t2LOL<oops, iops, asm, ops> {
  6046. let Predicates = [HasMVEInt];
  6047. let Inst{22-21} = 0b00;
  6048. let Inst{19-16} = 0b1111;
  6049. let Inst{12} = 0b0;
  6050. }
  6051. def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout),
  6052. (ins GPRlr:$LRin, lelabel_u11:$label),
  6053. "letp", "$LRin, $label"> {
  6054. bits<11> label;
  6055. let Inst{20} = 0b1;
  6056. let Inst{13} = 0b0;
  6057. let Inst{11} = label{0};
  6058. let Inst{10-1} = label{10-1};
  6059. let isBranch = 1;
  6060. let isTerminator = 1;
  6061. }
  6062. def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> {
  6063. let Inst{20} = 0b0;
  6064. let Inst{13} = 0b1;
  6065. let Inst{11-1} = 0b00000000000;
  6066. let Unpredictable{21-20} = 0b11;
  6067. let Unpredictable{11-1} = 0b11111111111;
  6068. }
  6069. // Pseudo instructions for lowering MQQPR and MQQQQPR stack spills and reloads.
  6070. // They are equivalent to VLDMDIA/VSTMDIA with a single reg, as opposed to multiple
  6071. // dreg subregs.
  6072. let Predicates = [HasMVEInt], AM = AddrMode4 in {
  6073. let mayStore = 1, hasSideEffects = 0 in {
  6074. def MQQPRStore : t2PseudoInst<(outs), (ins MQQPR:$val, GPRnopc:$ptr),
  6075. 4, NoItinerary, []>;
  6076. def MQQQQPRStore : t2PseudoInst<(outs), (ins MQQQQPR:$val, GPRnopc:$ptr),
  6077. 4, NoItinerary, []>;
  6078. }
  6079. let mayLoad = 1, hasSideEffects = 0 in {
  6080. def MQQPRLoad : t2PseudoInst<(outs MQQPR:$val), (ins GPRnopc:$ptr),
  6081. 4, NoItinerary, []>;
  6082. def MQQQQPRLoad : t2PseudoInst<(outs MQQQQPR:$val), (ins GPRnopc:$ptr),
  6083. 4, NoItinerary, []>;
  6084. }
  6085. }
  6086. // Pseudo for lowering MVE Q register COPYs. These will usually get converted
  6087. // to a "MVE_VORR dst, src, src", but may behave differently in tail predicated
  6088. // loops to ensure the whole register is copied, not a subset from a
  6089. // tail-predicated MVE_VORR. In the event we cannot prove a MVE_VORR is valid,
  6090. // it will become a pair of VMOVD instructions for each half of the Q register.
  6091. let Predicates = [HasMVEInt], hasSideEffects = 0, isMoveReg = 1,
  6092. D = MVEDomain in {
  6093. def MQPRCopy : t2PseudoInst<(outs MQPR:$dst), (ins MQPR:$src),
  6094. 8, NoItinerary, []>;
  6095. }
  6096. //===----------------------------------------------------------------------===//
  6097. // Patterns
  6098. //===----------------------------------------------------------------------===//
  6099. // PatFrags for loads and stores. Often trying to keep semi-consistent names.
  6100. def aligned32_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6101. (pre_store node:$val, node:$ptr, node:$offset), [{
  6102. return cast<StoreSDNode>(N)->getAlignment() >= 4;
  6103. }]>;
  6104. def aligned32_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6105. (post_store node:$val, node:$ptr, node:$offset), [{
  6106. return cast<StoreSDNode>(N)->getAlignment() >= 4;
  6107. }]>;
  6108. def aligned16_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6109. (pre_store node:$val, node:$ptr, node:$offset), [{
  6110. return cast<StoreSDNode>(N)->getAlignment() >= 2;
  6111. }]>;
  6112. def aligned16_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6113. (post_store node:$val, node:$ptr, node:$offset), [{
  6114. return cast<StoreSDNode>(N)->getAlignment() >= 2;
  6115. }]>;
  6116. def aligned_maskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6117. (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
  6118. auto *Ld = cast<MaskedLoadSDNode>(N);
  6119. return Ld->getMemoryVT().getScalarType() == MVT::i8;
  6120. }]>;
  6121. def aligned_sextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6122. (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
  6123. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
  6124. }]>;
  6125. def aligned_zextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6126. (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
  6127. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
  6128. }]>;
  6129. def aligned_extmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6130. (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
  6131. auto *Ld = cast<MaskedLoadSDNode>(N);
  6132. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6133. return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
  6134. }]>;
  6135. def aligned_maskedloadvi16: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6136. (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
  6137. auto *Ld = cast<MaskedLoadSDNode>(N);
  6138. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6139. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && Ld->getAlignment() >= 2;
  6140. }]>;
  6141. def aligned_sextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6142. (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
  6143. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
  6144. }]>;
  6145. def aligned_zextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6146. (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
  6147. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
  6148. }]>;
  6149. def aligned_extmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6150. (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
  6151. auto *Ld = cast<MaskedLoadSDNode>(N);
  6152. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6153. return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
  6154. }]>;
  6155. def aligned_maskedloadvi32: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6156. (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
  6157. auto *Ld = cast<MaskedLoadSDNode>(N);
  6158. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6159. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && Ld->getAlignment() >= 4;
  6160. }]>;
  6161. def aligned_maskedstvi8 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
  6162. (masked_st node:$val, node:$ptr, undef, node:$pred), [{
  6163. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6164. }]>;
  6165. def aligned_maskedstvi16 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
  6166. (masked_st node:$val, node:$ptr, undef, node:$pred), [{
  6167. auto *St = cast<MaskedStoreSDNode>(N);
  6168. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6169. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2;
  6170. }]>;
  6171. def aligned_maskedstvi32 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
  6172. (masked_st node:$val, node:$ptr, undef, node:$pred), [{
  6173. auto *St = cast<MaskedStoreSDNode>(N);
  6174. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6175. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlignment() >= 4;
  6176. }]>;
  6177. def pre_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask),
  6178. (masked_st node:$val, node:$base, node:$offset, node:$mask), [{
  6179. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6180. return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
  6181. }]>;
  6182. def post_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask),
  6183. (masked_st node:$val, node:$base, node:$offset, node:$mask), [{
  6184. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6185. return AM == ISD::POST_INC || AM == ISD::POST_DEC;
  6186. }]>;
  6187. def aligned_pre_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6188. (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6189. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6190. }]>;
  6191. def aligned_post_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6192. (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6193. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6194. }]>;
  6195. def aligned_pre_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6196. (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6197. auto *St = cast<MaskedStoreSDNode>(N);
  6198. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6199. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2;
  6200. }]>;
  6201. def aligned_post_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6202. (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6203. auto *St = cast<MaskedStoreSDNode>(N);
  6204. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6205. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2;
  6206. }]>;
  6207. def aligned_pre_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6208. (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6209. auto *St = cast<MaskedStoreSDNode>(N);
  6210. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6211. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlignment() >= 4;
  6212. }]>;
  6213. def aligned_post_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6214. (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6215. auto *St = cast<MaskedStoreSDNode>(N);
  6216. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6217. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlignment() >= 4;
  6218. }]>;
  6219. // PatFrags for "Aligned" extending / truncating
  6220. def aligned_extloadvi8 : PatFrag<(ops node:$ptr), (extloadvi8 node:$ptr)>;
  6221. def aligned_sextloadvi8 : PatFrag<(ops node:$ptr), (sextloadvi8 node:$ptr)>;
  6222. def aligned_zextloadvi8 : PatFrag<(ops node:$ptr), (zextloadvi8 node:$ptr)>;
  6223. def aligned_truncstvi8 : PatFrag<(ops node:$val, node:$ptr),
  6224. (truncstorevi8 node:$val, node:$ptr)>;
  6225. def aligned_post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6226. (post_truncstvi8 node:$val, node:$base, node:$offset)>;
  6227. def aligned_pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6228. (pre_truncstvi8 node:$val, node:$base, node:$offset)>;
  6229. let MinAlignment = 2 in {
  6230. def aligned_extloadvi16 : PatFrag<(ops node:$ptr), (extloadvi16 node:$ptr)>;
  6231. def aligned_sextloadvi16 : PatFrag<(ops node:$ptr), (sextloadvi16 node:$ptr)>;
  6232. def aligned_zextloadvi16 : PatFrag<(ops node:$ptr), (zextloadvi16 node:$ptr)>;
  6233. def aligned_truncstvi16 : PatFrag<(ops node:$val, node:$ptr),
  6234. (truncstorevi16 node:$val, node:$ptr)>;
  6235. def aligned_post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6236. (post_truncstvi16 node:$val, node:$base, node:$offset)>;
  6237. def aligned_pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6238. (pre_truncstvi16 node:$val, node:$base, node:$offset)>;
  6239. }
  6240. def truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$pred),
  6241. (masked_st node:$val, node:$base, undef, node:$pred), [{
  6242. return cast<MaskedStoreSDNode>(N)->isTruncatingStore();
  6243. }]>;
  6244. def aligned_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$pred),
  6245. (truncmaskedst node:$val, node:$base, node:$pred), [{
  6246. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6247. }]>;
  6248. def aligned_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$pred),
  6249. (truncmaskedst node:$val, node:$base, node:$pred), [{
  6250. auto *St = cast<MaskedStoreSDNode>(N);
  6251. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6252. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2;
  6253. }]>;
  6254. def pre_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
  6255. (masked_st node:$val, node:$base, node:$offset, node:$pred), [{
  6256. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6257. return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::PRE_INC || AM == ISD::PRE_DEC);
  6258. }]>;
  6259. def aligned_pre_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
  6260. (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{
  6261. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6262. }]>;
  6263. def aligned_pre_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
  6264. (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{
  6265. auto *St = cast<MaskedStoreSDNode>(N);
  6266. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6267. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2;
  6268. }]>;
  6269. def post_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
  6270. (masked_st node:$val, node:$base, node:$offset, node:$postd), [{
  6271. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6272. return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::POST_INC || AM == ISD::POST_DEC);
  6273. }]>;
  6274. def aligned_post_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
  6275. (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{
  6276. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6277. }]>;
  6278. def aligned_post_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
  6279. (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{
  6280. auto *St = cast<MaskedStoreSDNode>(N);
  6281. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6282. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2;
  6283. }]>;
  6284. // Load/store patterns
  6285. class MVE_vector_store_typed<ValueType Ty, Instruction RegImmInst,
  6286. PatFrag StoreKind, int shift>
  6287. : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr),
  6288. (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>;
  6289. class MVE_vector_maskedstore_typed<ValueType Ty, Instruction RegImmInst,
  6290. PatFrag StoreKind, int shift>
  6291. : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, VCCR:$pred),
  6292. (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6293. multiclass MVE_vector_store<Instruction RegImmInst, PatFrag StoreKind,
  6294. int shift> {
  6295. def : MVE_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>;
  6296. def : MVE_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>;
  6297. def : MVE_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>;
  6298. def : MVE_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>;
  6299. def : MVE_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>;
  6300. def : MVE_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>;
  6301. def : MVE_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>;
  6302. }
  6303. class MVE_vector_load_typed<ValueType Ty, Instruction RegImmInst,
  6304. PatFrag LoadKind, int shift>
  6305. : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)),
  6306. (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>;
  6307. class MVE_vector_maskedload_typed<ValueType Ty, Instruction RegImmInst,
  6308. PatFrag LoadKind, int shift>
  6309. : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr, VCCR:$pred, (Ty (ARMvmovImm (i32 0))))),
  6310. (Ty (RegImmInst t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6311. multiclass MVE_vector_load<Instruction RegImmInst, PatFrag LoadKind,
  6312. int shift> {
  6313. def : MVE_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>;
  6314. def : MVE_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>;
  6315. def : MVE_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>;
  6316. def : MVE_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>;
  6317. def : MVE_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>;
  6318. def : MVE_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>;
  6319. def : MVE_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>;
  6320. }
  6321. class MVE_vector_offset_store_typed<ValueType Ty, Instruction Opcode,
  6322. PatFrag StoreKind, int shift>
  6323. : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr),
  6324. (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr)>;
  6325. class MVE_vector_offset_maskedstore_typed<ValueType Ty, Instruction Opcode,
  6326. PatFrag StoreKind, int shift>
  6327. : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr, VCCR:$pred),
  6328. (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6329. multiclass MVE_vector_offset_store<Instruction RegImmInst, PatFrag StoreKind,
  6330. int shift> {
  6331. def : MVE_vector_offset_store_typed<v16i8, RegImmInst, StoreKind, shift>;
  6332. def : MVE_vector_offset_store_typed<v8i16, RegImmInst, StoreKind, shift>;
  6333. def : MVE_vector_offset_store_typed<v8f16, RegImmInst, StoreKind, shift>;
  6334. def : MVE_vector_offset_store_typed<v4i32, RegImmInst, StoreKind, shift>;
  6335. def : MVE_vector_offset_store_typed<v4f32, RegImmInst, StoreKind, shift>;
  6336. def : MVE_vector_offset_store_typed<v2i64, RegImmInst, StoreKind, shift>;
  6337. def : MVE_vector_offset_store_typed<v2f64, RegImmInst, StoreKind, shift>;
  6338. }
  6339. let Predicates = [HasMVEInt, IsLE] in {
  6340. // Stores
  6341. defm : MVE_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>;
  6342. defm : MVE_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>;
  6343. defm : MVE_vector_store<MVE_VSTRWU32, alignedstore32, 2>;
  6344. // Loads
  6345. defm : MVE_vector_load<MVE_VLDRBU8, byte_alignedload, 0>;
  6346. defm : MVE_vector_load<MVE_VLDRHU16, hword_alignedload, 1>;
  6347. defm : MVE_vector_load<MVE_VLDRWU32, alignedload32, 2>;
  6348. // Pre/post inc stores
  6349. defm : MVE_vector_offset_store<MVE_VSTRBU8_pre, pre_store, 0>;
  6350. defm : MVE_vector_offset_store<MVE_VSTRBU8_post, post_store, 0>;
  6351. defm : MVE_vector_offset_store<MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
  6352. defm : MVE_vector_offset_store<MVE_VSTRHU16_post, aligned16_post_store, 1>;
  6353. defm : MVE_vector_offset_store<MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
  6354. defm : MVE_vector_offset_store<MVE_VSTRWU32_post, aligned32_post_store, 2>;
  6355. }
  6356. let Predicates = [HasMVEInt, IsBE] in {
  6357. // Aligned Stores
  6358. def : MVE_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>;
  6359. def : MVE_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>;
  6360. def : MVE_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>;
  6361. def : MVE_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>;
  6362. def : MVE_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>;
  6363. // Aligned Loads
  6364. def : MVE_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>;
  6365. def : MVE_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>;
  6366. def : MVE_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>;
  6367. def : MVE_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>;
  6368. def : MVE_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>;
  6369. // Other unaligned loads/stores need to go though a VREV
  6370. def : Pat<(v2f64 (load t2addrmode_imm7<0>:$addr)),
  6371. (v2f64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6372. def : Pat<(v2i64 (load t2addrmode_imm7<0>:$addr)),
  6373. (v2i64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6374. def : Pat<(v4i32 (load t2addrmode_imm7<0>:$addr)),
  6375. (v4i32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6376. def : Pat<(v4f32 (load t2addrmode_imm7<0>:$addr)),
  6377. (v4f32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6378. def : Pat<(v8i16 (load t2addrmode_imm7<0>:$addr)),
  6379. (v8i16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6380. def : Pat<(v8f16 (load t2addrmode_imm7<0>:$addr)),
  6381. (v8f16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6382. def : Pat<(store (v2f64 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6383. (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6384. def : Pat<(store (v2i64 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6385. (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6386. def : Pat<(store (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6387. (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6388. def : Pat<(store (v4f32 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6389. (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6390. def : Pat<(store (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6391. (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6392. def : Pat<(store (v8f16 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6393. (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6394. // Pre/Post inc stores
  6395. def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_pre, pre_store, 0>;
  6396. def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_post, post_store, 0>;
  6397. def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
  6398. def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
  6399. def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
  6400. def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
  6401. def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
  6402. def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
  6403. def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
  6404. def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
  6405. }
  6406. let Predicates = [HasMVEInt] in {
  6407. // Aligned masked store, shared between LE and BE
  6408. def : MVE_vector_maskedstore_typed<v16i8, MVE_VSTRBU8, aligned_maskedstvi8, 0>;
  6409. def : MVE_vector_maskedstore_typed<v8i16, MVE_VSTRHU16, aligned_maskedstvi16, 1>;
  6410. def : MVE_vector_maskedstore_typed<v8f16, MVE_VSTRHU16, aligned_maskedstvi16, 1>;
  6411. def : MVE_vector_maskedstore_typed<v4i32, MVE_VSTRWU32, aligned_maskedstvi32, 2>;
  6412. def : MVE_vector_maskedstore_typed<v4f32, MVE_VSTRWU32, aligned_maskedstvi32, 2>;
  6413. // Pre/Post inc masked stores
  6414. def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_pre, aligned_pre_maskedstorevi8, 0>;
  6415. def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_post, aligned_post_maskedstorevi8, 0>;
  6416. def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>;
  6417. def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>;
  6418. def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>;
  6419. def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>;
  6420. def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>;
  6421. def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>;
  6422. def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>;
  6423. def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>;
  6424. // Aligned masked loads
  6425. def : MVE_vector_maskedload_typed<v16i8, MVE_VLDRBU8, aligned_maskedloadvi8, 0>;
  6426. def : MVE_vector_maskedload_typed<v8i16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>;
  6427. def : MVE_vector_maskedload_typed<v8f16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>;
  6428. def : MVE_vector_maskedload_typed<v4i32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>;
  6429. def : MVE_vector_maskedload_typed<v4f32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>;
  6430. }
  6431. // Widening/Narrowing Loads/Stores
  6432. multiclass MVEExtLoadStore<Instruction LoadSInst, Instruction LoadUInst, string StoreInst,
  6433. string Amble, ValueType VT, int Shift> {
  6434. // Trunc stores
  6435. def : Pat<(!cast<PatFrag>("aligned_truncst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr),
  6436. (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr)>;
  6437. def : Pat<(!cast<PatFrag>("aligned_post_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr),
  6438. (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>;
  6439. def : Pat<(!cast<PatFrag>("aligned_pre_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr),
  6440. (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>;
  6441. // Masked trunc stores
  6442. def : Pat<(!cast<PatFrag>("aligned_truncmaskedst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr, VCCR:$pred),
  6443. (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6444. def : Pat<(!cast<PatFrag>("aligned_post_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred),
  6445. (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6446. def : Pat<(!cast<PatFrag>("aligned_pre_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred),
  6447. (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6448. // Ext loads
  6449. def : Pat<(VT (!cast<PatFrag>("aligned_extload"#Amble) taddrmode_imm7<Shift>:$addr)),
  6450. (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>;
  6451. def : Pat<(VT (!cast<PatFrag>("aligned_sextload"#Amble) taddrmode_imm7<Shift>:$addr)),
  6452. (VT (LoadSInst taddrmode_imm7<Shift>:$addr))>;
  6453. def : Pat<(VT (!cast<PatFrag>("aligned_zextload"#Amble) taddrmode_imm7<Shift>:$addr)),
  6454. (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>;
  6455. // Masked ext loads
  6456. def : Pat<(VT (!cast<PatFrag>("aligned_extmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
  6457. (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6458. def : Pat<(VT (!cast<PatFrag>("aligned_sextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
  6459. (VT (LoadSInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6460. def : Pat<(VT (!cast<PatFrag>("aligned_zextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
  6461. (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6462. }
  6463. let Predicates = [HasMVEInt] in {
  6464. defm : MVEExtLoadStore<MVE_VLDRBS16, MVE_VLDRBU16, "MVE_VSTRB16", "vi8", v8i16, 0>;
  6465. defm : MVEExtLoadStore<MVE_VLDRBS32, MVE_VLDRBU32, "MVE_VSTRB32", "vi8", v4i32, 0>;
  6466. defm : MVEExtLoadStore<MVE_VLDRHS32, MVE_VLDRHU32, "MVE_VSTRH32", "vi16", v4i32, 1>;
  6467. }
  6468. // Bit convert patterns
  6469. let Predicates = [HasMVEInt] in {
  6470. def : Pat<(v2f64 (bitconvert (v2i64 MQPR:$src))), (v2f64 MQPR:$src)>;
  6471. def : Pat<(v2i64 (bitconvert (v2f64 MQPR:$src))), (v2i64 MQPR:$src)>;
  6472. def : Pat<(v4i32 (bitconvert (v4f32 MQPR:$src))), (v4i32 MQPR:$src)>;
  6473. def : Pat<(v4f32 (bitconvert (v4i32 MQPR:$src))), (v4f32 MQPR:$src)>;
  6474. def : Pat<(v8i16 (bitconvert (v8f16 MQPR:$src))), (v8i16 MQPR:$src)>;
  6475. def : Pat<(v8f16 (bitconvert (v8i16 MQPR:$src))), (v8f16 MQPR:$src)>;
  6476. }
  6477. let Predicates = [IsLE,HasMVEInt] in {
  6478. def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 MQPR:$src)>;
  6479. def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 MQPR:$src)>;
  6480. def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 MQPR:$src)>;
  6481. def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 MQPR:$src)>;
  6482. def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 MQPR:$src)>;
  6483. def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 MQPR:$src)>;
  6484. def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 MQPR:$src)>;
  6485. def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 MQPR:$src)>;
  6486. def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 MQPR:$src)>;
  6487. def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 MQPR:$src)>;
  6488. def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 MQPR:$src)>;
  6489. def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 MQPR:$src)>;
  6490. def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 MQPR:$src)>;
  6491. def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 MQPR:$src)>;
  6492. def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 MQPR:$src)>;
  6493. def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 MQPR:$src)>;
  6494. def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 MQPR:$src)>;
  6495. def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 MQPR:$src)>;
  6496. def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 MQPR:$src)>;
  6497. def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 MQPR:$src)>;
  6498. def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 MQPR:$src)>;
  6499. def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 MQPR:$src)>;
  6500. def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 MQPR:$src)>;
  6501. def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 MQPR:$src)>;
  6502. def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 MQPR:$src)>;
  6503. def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 MQPR:$src)>;
  6504. def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 MQPR:$src)>;
  6505. def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 MQPR:$src)>;
  6506. def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 MQPR:$src)>;
  6507. def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 MQPR:$src)>;
  6508. def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 MQPR:$src)>;
  6509. def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 MQPR:$src)>;
  6510. def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 MQPR:$src)>;
  6511. def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 MQPR:$src)>;
  6512. def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 MQPR:$src)>;
  6513. def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 MQPR:$src)>;
  6514. }
  6515. let Predicates = [IsBE,HasMVEInt] in {
  6516. def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
  6517. def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
  6518. def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
  6519. def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
  6520. def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 (MVE_VREV64_8 MQPR:$src))>;
  6521. def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
  6522. def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
  6523. def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
  6524. def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
  6525. def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 (MVE_VREV64_8 MQPR:$src))>;
  6526. def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
  6527. def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
  6528. def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
  6529. def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
  6530. def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 (MVE_VREV32_8 MQPR:$src))>;
  6531. def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
  6532. def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
  6533. def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
  6534. def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
  6535. def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 (MVE_VREV32_8 MQPR:$src))>;
  6536. def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
  6537. def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
  6538. def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
  6539. def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
  6540. def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 (MVE_VREV16_8 MQPR:$src))>;
  6541. def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
  6542. def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
  6543. def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
  6544. def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
  6545. def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 (MVE_VREV16_8 MQPR:$src))>;
  6546. def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
  6547. def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
  6548. def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
  6549. def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
  6550. def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;
  6551. def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;
  6552. }