ARMInstrMVE.td 322 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537
  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. let Predicates = [HasFullFP16] in {
  1649. def : Pat<(ARMinsertelt (v8i16 MQPR:$src1),
  1650. (ARMvgetlaneu (v8i16 MQPR:$src2), imm_even:$extlane),
  1651. imm_odd:$inslane),
  1652. (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)),
  1653. (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$inslane)),
  1654. (EXTRACT_SUBREG MQPR:$src2, (SSubReg_f16_reg imm_even:$extlane))),
  1655. (SSubReg_f16_reg imm_odd:$inslane)), MQPR)>;
  1656. }
  1657. def : Pat<(v16i8 (scalar_to_vector GPR:$src)),
  1658. (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1659. def : Pat<(v8i16 (scalar_to_vector GPR:$src)),
  1660. (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1661. def : Pat<(v4i32 (scalar_to_vector GPR:$src)),
  1662. (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1663. // Floating point patterns, still enabled under HasMVEInt
  1664. def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane),
  1665. (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>;
  1666. def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane),
  1667. (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>;
  1668. def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_even:$lane),
  1669. (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS (f16 HPR:$src2), rGPR), imm:$lane)>;
  1670. let Predicates = [HasFullFP16] in {
  1671. def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_odd:$lane),
  1672. (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)),
  1673. (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$lane)),
  1674. (COPY_TO_REGCLASS HPR:$src2, SPR)),
  1675. (SSubReg_f16_reg imm_odd:$lane)), MQPR)>;
  1676. }
  1677. def : Pat<(extractelt (v8f16 MQPR:$src), imm_even:$lane),
  1678. (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_even:$lane))>;
  1679. let Predicates = [HasFullFP16] in {
  1680. def : Pat<(extractelt (v8f16 MQPR:$src), imm_odd:$lane),
  1681. (COPY_TO_REGCLASS
  1682. (VMOVH (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane))),
  1683. HPR)>;
  1684. }
  1685. def : Pat<(v2f64 (scalar_to_vector (f64 DPR:$src))),
  1686. (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
  1687. def : Pat<(v4f32 (scalar_to_vector SPR:$src)),
  1688. (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
  1689. def : Pat<(v4f32 (scalar_to_vector GPR:$src)),
  1690. (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1691. def : Pat<(v8f16 (scalar_to_vector (f16 HPR:$src))),
  1692. (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), (f16 HPR:$src), ssub_0)>;
  1693. def : Pat<(v8f16 (scalar_to_vector GPR:$src)),
  1694. (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
  1695. }
  1696. // end of mve_bit instructions
  1697. // start of MVE Integer instructions
  1698. class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
  1699. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
  1700. iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", size, pattern> {
  1701. bits<4> Qd;
  1702. bits<4> Qn;
  1703. bits<4> Qm;
  1704. let Inst{22} = Qd{3};
  1705. let Inst{21-20} = size;
  1706. let Inst{19-17} = Qn{2-0};
  1707. let Inst{15-13} = Qd{2-0};
  1708. let Inst{7} = Qn{3};
  1709. let Inst{6} = 0b1;
  1710. let Inst{5} = Qm{3};
  1711. let Inst{3-1} = Qm{2-0};
  1712. }
  1713. class MVE_VMULt1<string iname, string suffix, bits<2> size,
  1714. list<dag> pattern=[]>
  1715. : MVE_int<iname, suffix, size, pattern> {
  1716. let Inst{28} = 0b0;
  1717. let Inst{25-23} = 0b110;
  1718. let Inst{16} = 0b0;
  1719. let Inst{12-8} = 0b01001;
  1720. let Inst{4} = 0b1;
  1721. let Inst{0} = 0b0;
  1722. let validForTailPredication = 1;
  1723. }
  1724. multiclass MVE_VMUL_m<MVEVectorVTInfo VTI> {
  1725. def "" : MVE_VMULt1<"vmul", VTI.Suffix, VTI.Size>;
  1726. let Predicates = [HasMVEInt] in {
  1727. defm : MVE_TwoOpPattern<VTI, mul, int_arm_mve_mul_predicated, (? ),
  1728. !cast<Instruction>(NAME), ARMimmOneV>;
  1729. }
  1730. }
  1731. defm MVE_VMULi8 : MVE_VMUL_m<MVE_v16i8>;
  1732. defm MVE_VMULi16 : MVE_VMUL_m<MVE_v8i16>;
  1733. defm MVE_VMULi32 : MVE_VMUL_m<MVE_v4i32>;
  1734. class MVE_VQxDMULH_Base<string iname, string suffix, bits<2> size, bit rounding,
  1735. list<dag> pattern=[]>
  1736. : MVE_int<iname, suffix, size, pattern> {
  1737. let Inst{28} = rounding;
  1738. let Inst{25-23} = 0b110;
  1739. let Inst{16} = 0b0;
  1740. let Inst{12-8} = 0b01011;
  1741. let Inst{4} = 0b0;
  1742. let Inst{0} = 0b0;
  1743. let validForTailPredication = 1;
  1744. }
  1745. def MVEvqdmulh : SDNode<"ARMISD::VQDMULH", SDTIntBinOp>;
  1746. multiclass MVE_VQxDMULH_m<string iname, MVEVectorVTInfo VTI,
  1747. SDNode Op, Intrinsic unpred_int, Intrinsic pred_int,
  1748. bit rounding> {
  1749. def "" : MVE_VQxDMULH_Base<iname, VTI.Suffix, VTI.Size, rounding>;
  1750. defvar Inst = !cast<Instruction>(NAME);
  1751. let Predicates = [HasMVEInt] in {
  1752. defm : MVE_TwoOpPattern<VTI, Op, pred_int, (? ), Inst>;
  1753. // Extra unpredicated multiply intrinsic patterns
  1754. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
  1755. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  1756. }
  1757. }
  1758. multiclass MVE_VQxDMULH<string iname, MVEVectorVTInfo VTI, bit rounding>
  1759. : MVE_VQxDMULH_m<iname, VTI, !if(rounding, null_frag,
  1760. MVEvqdmulh),
  1761. !if(rounding, int_arm_mve_vqrdmulh,
  1762. int_arm_mve_vqdmulh),
  1763. !if(rounding, int_arm_mve_qrdmulh_predicated,
  1764. int_arm_mve_qdmulh_predicated),
  1765. rounding>;
  1766. defm MVE_VQDMULHi8 : MVE_VQxDMULH<"vqdmulh", MVE_v16s8, 0b0>;
  1767. defm MVE_VQDMULHi16 : MVE_VQxDMULH<"vqdmulh", MVE_v8s16, 0b0>;
  1768. defm MVE_VQDMULHi32 : MVE_VQxDMULH<"vqdmulh", MVE_v4s32, 0b0>;
  1769. defm MVE_VQRDMULHi8 : MVE_VQxDMULH<"vqrdmulh", MVE_v16s8, 0b1>;
  1770. defm MVE_VQRDMULHi16 : MVE_VQxDMULH<"vqrdmulh", MVE_v8s16, 0b1>;
  1771. defm MVE_VQRDMULHi32 : MVE_VQxDMULH<"vqrdmulh", MVE_v4s32, 0b1>;
  1772. class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract,
  1773. list<dag> pattern=[]>
  1774. : MVE_int<iname, suffix, size, pattern> {
  1775. let Inst{28} = subtract;
  1776. let Inst{25-23} = 0b110;
  1777. let Inst{16} = 0b0;
  1778. let Inst{12-8} = 0b01000;
  1779. let Inst{4} = 0b0;
  1780. let Inst{0} = 0b0;
  1781. let validForTailPredication = 1;
  1782. }
  1783. multiclass MVE_VADDSUB_m<string iname, MVEVectorVTInfo VTI, bit subtract,
  1784. SDNode Op, Intrinsic PredInt> {
  1785. def "" : MVE_VADDSUB<iname, VTI.Suffix, VTI.Size, subtract>;
  1786. defvar Inst = !cast<Instruction>(NAME);
  1787. let Predicates = [HasMVEInt] in {
  1788. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>;
  1789. }
  1790. }
  1791. multiclass MVE_VADD<MVEVectorVTInfo VTI>
  1792. : MVE_VADDSUB_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>;
  1793. multiclass MVE_VSUB<MVEVectorVTInfo VTI>
  1794. : MVE_VADDSUB_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>;
  1795. defm MVE_VADDi8 : MVE_VADD<MVE_v16i8>;
  1796. defm MVE_VADDi16 : MVE_VADD<MVE_v8i16>;
  1797. defm MVE_VADDi32 : MVE_VADD<MVE_v4i32>;
  1798. defm MVE_VSUBi8 : MVE_VSUB<MVE_v16i8>;
  1799. defm MVE_VSUBi16 : MVE_VSUB<MVE_v8i16>;
  1800. defm MVE_VSUBi32 : MVE_VSUB<MVE_v4i32>;
  1801. class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract,
  1802. bits<2> size>
  1803. : MVE_int<iname, suffix, size, []> {
  1804. let Inst{28} = U;
  1805. let Inst{25-23} = 0b110;
  1806. let Inst{16} = 0b0;
  1807. let Inst{12-10} = 0b000;
  1808. let Inst{9} = subtract;
  1809. let Inst{8} = 0b0;
  1810. let Inst{4} = 0b1;
  1811. let Inst{0} = 0b0;
  1812. let validForTailPredication = 1;
  1813. }
  1814. class MVE_VQADD_<string suffix, bit U, bits<2> size>
  1815. : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size>;
  1816. class MVE_VQSUB_<string suffix, bit U, bits<2> size>
  1817. : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size>;
  1818. multiclass MVE_VQADD_m<MVEVectorVTInfo VTI,
  1819. SDNode Op, Intrinsic PredInt> {
  1820. def "" : MVE_VQADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1821. defvar Inst = !cast<Instruction>(NAME);
  1822. let Predicates = [HasMVEInt] in {
  1823. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  1824. !cast<Instruction>(NAME)>;
  1825. }
  1826. }
  1827. multiclass MVE_VQADD<MVEVectorVTInfo VTI, SDNode unpred_op>
  1828. : MVE_VQADD_m<VTI, unpred_op, int_arm_mve_qadd_predicated>;
  1829. defm MVE_VQADDs8 : MVE_VQADD<MVE_v16s8, saddsat>;
  1830. defm MVE_VQADDs16 : MVE_VQADD<MVE_v8s16, saddsat>;
  1831. defm MVE_VQADDs32 : MVE_VQADD<MVE_v4s32, saddsat>;
  1832. defm MVE_VQADDu8 : MVE_VQADD<MVE_v16u8, uaddsat>;
  1833. defm MVE_VQADDu16 : MVE_VQADD<MVE_v8u16, uaddsat>;
  1834. defm MVE_VQADDu32 : MVE_VQADD<MVE_v4u32, uaddsat>;
  1835. multiclass MVE_VQSUB_m<MVEVectorVTInfo VTI,
  1836. SDNode Op, Intrinsic PredInt> {
  1837. def "" : MVE_VQSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1838. defvar Inst = !cast<Instruction>(NAME);
  1839. let Predicates = [HasMVEInt] in {
  1840. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  1841. !cast<Instruction>(NAME)>;
  1842. }
  1843. }
  1844. multiclass MVE_VQSUB<MVEVectorVTInfo VTI, SDNode unpred_op>
  1845. : MVE_VQSUB_m<VTI, unpred_op, int_arm_mve_qsub_predicated>;
  1846. defm MVE_VQSUBs8 : MVE_VQSUB<MVE_v16s8, ssubsat>;
  1847. defm MVE_VQSUBs16 : MVE_VQSUB<MVE_v8s16, ssubsat>;
  1848. defm MVE_VQSUBs32 : MVE_VQSUB<MVE_v4s32, ssubsat>;
  1849. defm MVE_VQSUBu8 : MVE_VQSUB<MVE_v16u8, usubsat>;
  1850. defm MVE_VQSUBu16 : MVE_VQSUB<MVE_v8u16, usubsat>;
  1851. defm MVE_VQSUBu32 : MVE_VQSUB<MVE_v4u32, usubsat>;
  1852. class MVE_VABD_int<string suffix, bit U, bits<2> size,
  1853. list<dag> pattern=[]>
  1854. : MVE_int<"vabd", suffix, size, pattern> {
  1855. let Inst{28} = U;
  1856. let Inst{25-23} = 0b110;
  1857. let Inst{16} = 0b0;
  1858. let Inst{12-8} = 0b00111;
  1859. let Inst{4} = 0b0;
  1860. let Inst{0} = 0b0;
  1861. let validForTailPredication = 1;
  1862. }
  1863. multiclass MVE_VABD_m<MVEVectorVTInfo VTI, SDNode Op,
  1864. Intrinsic unpred_int, Intrinsic PredInt> {
  1865. def "" : MVE_VABD_int<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1866. defvar Inst = !cast<Instruction>(NAME);
  1867. let Predicates = [HasMVEInt] in {
  1868. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  1869. !cast<Instruction>(NAME)>;
  1870. // Unpredicated absolute difference
  1871. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  1872. (i32 VTI.Unsigned))),
  1873. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  1874. }
  1875. }
  1876. multiclass MVE_VABD<MVEVectorVTInfo VTI, SDNode Op>
  1877. : MVE_VABD_m<VTI, Op, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
  1878. defm MVE_VABDs8 : MVE_VABD<MVE_v16s8, abds>;
  1879. defm MVE_VABDs16 : MVE_VABD<MVE_v8s16, abds>;
  1880. defm MVE_VABDs32 : MVE_VABD<MVE_v4s32, abds>;
  1881. defm MVE_VABDu8 : MVE_VABD<MVE_v16u8, abdu>;
  1882. defm MVE_VABDu16 : MVE_VABD<MVE_v8u16, abdu>;
  1883. defm MVE_VABDu32 : MVE_VABD<MVE_v4u32, abdu>;
  1884. class MVE_VRHADD_Base<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
  1885. : MVE_int<"vrhadd", suffix, size, pattern> {
  1886. let Inst{28} = U;
  1887. let Inst{25-23} = 0b110;
  1888. let Inst{16} = 0b0;
  1889. let Inst{12-8} = 0b00001;
  1890. let Inst{4} = 0b0;
  1891. let Inst{0} = 0b0;
  1892. let validForTailPredication = 1;
  1893. }
  1894. def addnuw : PatFrag<(ops node:$lhs, node:$rhs),
  1895. (add node:$lhs, node:$rhs), [{
  1896. return N->getFlags().hasNoUnsignedWrap();
  1897. }]>;
  1898. def addnsw : PatFrag<(ops node:$lhs, node:$rhs),
  1899. (add node:$lhs, node:$rhs), [{
  1900. return N->getFlags().hasNoSignedWrap();
  1901. }]>;
  1902. def subnuw : PatFrag<(ops node:$lhs, node:$rhs),
  1903. (sub node:$lhs, node:$rhs), [{
  1904. return N->getFlags().hasNoUnsignedWrap();
  1905. }]>;
  1906. def subnsw : PatFrag<(ops node:$lhs, node:$rhs),
  1907. (sub node:$lhs, node:$rhs), [{
  1908. return N->getFlags().hasNoSignedWrap();
  1909. }]>;
  1910. multiclass MVE_VRHADD_m<MVEVectorVTInfo VTI, SDNode Op,
  1911. SDNode unpred_op, Intrinsic PredInt> {
  1912. def "" : MVE_VRHADD_Base<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  1913. defvar Inst = !cast<Instruction>(NAME);
  1914. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
  1915. let Predicates = [HasMVEInt] in {
  1916. // Unpredicated rounding add-with-divide-by-two intrinsic
  1917. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  1918. (i32 VTI.Unsigned))),
  1919. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  1920. }
  1921. }
  1922. multiclass MVE_VRHADD<MVEVectorVTInfo VTI, SDNode rhadd>
  1923. : MVE_VRHADD_m<VTI, rhadd, int_arm_mve_vrhadd, int_arm_mve_rhadd_predicated>;
  1924. defm MVE_VRHADDs8 : MVE_VRHADD<MVE_v16s8, avgceils>;
  1925. defm MVE_VRHADDs16 : MVE_VRHADD<MVE_v8s16, avgceils>;
  1926. defm MVE_VRHADDs32 : MVE_VRHADD<MVE_v4s32, avgceils>;
  1927. defm MVE_VRHADDu8 : MVE_VRHADD<MVE_v16u8, avgceilu>;
  1928. defm MVE_VRHADDu16 : MVE_VRHADD<MVE_v8u16, avgceilu>;
  1929. defm MVE_VRHADDu32 : MVE_VRHADD<MVE_v4u32, avgceilu>;
  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, SDNode Op,
  2005. SDNode unpred_op, Intrinsic PredInt, PatFrag add_op,
  2006. SDNode shift_op> {
  2007. def "" : MVE_VHADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  2008. defvar Inst = !cast<Instruction>(NAME);
  2009. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
  2010. let Predicates = [HasMVEInt] in {
  2011. // Unpredicated add-and-divide-by-two
  2012. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), (i32 VTI.Unsigned))),
  2013. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  2014. def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))),
  2015. (Inst MQPR:$Qm, MQPR:$Qn)>;
  2016. }
  2017. }
  2018. multiclass MVE_VHADD<MVEVectorVTInfo VTI, SDNode Op, PatFrag add_op, SDNode shift_op>
  2019. : MVE_VHADD_m<VTI, Op, int_arm_mve_vhadd, int_arm_mve_hadd_predicated, add_op,
  2020. shift_op>;
  2021. // Halving add/sub perform the arithemtic operation with an extra bit of
  2022. // precision, before performing the shift, to void clipping errors. We're not
  2023. // modelling that here with these patterns, but we're using no wrap forms of
  2024. // add/sub to ensure that the extra bit of information is not needed.
  2025. defm MVE_VHADDs8 : MVE_VHADD<MVE_v16s8, avgfloors, addnsw, ARMvshrsImm>;
  2026. defm MVE_VHADDs16 : MVE_VHADD<MVE_v8s16, avgfloors, addnsw, ARMvshrsImm>;
  2027. defm MVE_VHADDs32 : MVE_VHADD<MVE_v4s32, avgfloors, addnsw, ARMvshrsImm>;
  2028. defm MVE_VHADDu8 : MVE_VHADD<MVE_v16u8, avgflooru, addnuw, ARMvshruImm>;
  2029. defm MVE_VHADDu16 : MVE_VHADD<MVE_v8u16, avgflooru, addnuw, ARMvshruImm>;
  2030. defm MVE_VHADDu32 : MVE_VHADD<MVE_v4u32, avgflooru, addnuw, ARMvshruImm>;
  2031. multiclass MVE_VHSUB_m<MVEVectorVTInfo VTI,
  2032. SDNode unpred_op, Intrinsic pred_int, PatFrag sub_op,
  2033. SDNode shift_op> {
  2034. def "" : MVE_VHSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
  2035. defvar Inst = !cast<Instruction>(NAME);
  2036. let Predicates = [HasMVEInt] in {
  2037. // Unpredicated subtract-and-divide-by-two
  2038. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  2039. (i32 VTI.Unsigned))),
  2040. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  2041. def : Pat<(VTI.Vec (shift_op (sub_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))),
  2042. (Inst MQPR:$Qm, MQPR:$Qn)>;
  2043. // Predicated subtract-and-divide-by-two
  2044. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  2045. (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
  2046. (VTI.Vec MQPR:$inactive))),
  2047. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  2048. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  2049. (VTI.Vec MQPR:$inactive)))>;
  2050. }
  2051. }
  2052. multiclass MVE_VHSUB<MVEVectorVTInfo VTI, PatFrag sub_op, SDNode shift_op>
  2053. : MVE_VHSUB_m<VTI, int_arm_mve_vhsub, int_arm_mve_hsub_predicated, sub_op,
  2054. shift_op>;
  2055. defm MVE_VHSUBs8 : MVE_VHSUB<MVE_v16s8, subnsw, ARMvshrsImm>;
  2056. defm MVE_VHSUBs16 : MVE_VHSUB<MVE_v8s16, subnsw, ARMvshrsImm>;
  2057. defm MVE_VHSUBs32 : MVE_VHSUB<MVE_v4s32, subnsw, ARMvshrsImm>;
  2058. defm MVE_VHSUBu8 : MVE_VHSUB<MVE_v16u8, subnuw, ARMvshruImm>;
  2059. defm MVE_VHSUBu16 : MVE_VHSUB<MVE_v8u16, subnuw, ARMvshruImm>;
  2060. defm MVE_VHSUBu32 : MVE_VHSUB<MVE_v4u32, subnuw, ARMvshruImm>;
  2061. class MVE_VDUP<string suffix, bit B, bit E, bits<2> vecsize, list<dag> pattern=[]>
  2062. : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary,
  2063. "vdup", suffix, "$Qd, $Rt", vpred_r, "", vecsize, pattern> {
  2064. bits<4> Qd;
  2065. bits<4> Rt;
  2066. let Inst{28} = 0b0;
  2067. let Inst{25-23} = 0b101;
  2068. let Inst{22} = B;
  2069. let Inst{21-20} = 0b10;
  2070. let Inst{19-17} = Qd{2-0};
  2071. let Inst{16} = 0b0;
  2072. let Inst{15-12} = Rt;
  2073. let Inst{11-8} = 0b1011;
  2074. let Inst{7} = Qd{3};
  2075. let Inst{6} = 0b0;
  2076. let Inst{5} = E;
  2077. let Inst{4-0} = 0b10000;
  2078. let validForTailPredication = 1;
  2079. }
  2080. def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0, 0b10>;
  2081. def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1, 0b01>;
  2082. def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0, 0b00>;
  2083. let Predicates = [HasMVEInt] in {
  2084. def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))),
  2085. (MVE_VDUP8 rGPR:$elem)>;
  2086. def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))),
  2087. (MVE_VDUP16 rGPR:$elem)>;
  2088. def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))),
  2089. (MVE_VDUP32 rGPR:$elem)>;
  2090. def : Pat<(v8f16 (ARMvdup (i32 rGPR:$elem))),
  2091. (MVE_VDUP16 rGPR:$elem)>;
  2092. def : Pat<(v4f32 (ARMvdup (i32 rGPR:$elem))),
  2093. (MVE_VDUP32 rGPR:$elem)>;
  2094. // Match a vselect with an ARMvdup as a predicated MVE_VDUP
  2095. def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred),
  2096. (v16i8 (ARMvdup (i32 rGPR:$elem))),
  2097. (v16i8 MQPR:$inactive))),
  2098. (MVE_VDUP8 rGPR:$elem, ARMVCCThen, (v16i1 VCCR:$pred), zero_reg,
  2099. (v16i8 MQPR:$inactive))>;
  2100. def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred),
  2101. (v8i16 (ARMvdup (i32 rGPR:$elem))),
  2102. (v8i16 MQPR:$inactive))),
  2103. (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg,
  2104. (v8i16 MQPR:$inactive))>;
  2105. def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred),
  2106. (v4i32 (ARMvdup (i32 rGPR:$elem))),
  2107. (v4i32 MQPR:$inactive))),
  2108. (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg,
  2109. (v4i32 MQPR:$inactive))>;
  2110. def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred),
  2111. (v4f32 (ARMvdup (i32 rGPR:$elem))),
  2112. (v4f32 MQPR:$inactive))),
  2113. (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg,
  2114. (v4f32 MQPR:$inactive))>;
  2115. def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred),
  2116. (v8f16 (ARMvdup (i32 rGPR:$elem))),
  2117. (v8f16 MQPR:$inactive))),
  2118. (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg,
  2119. (v8f16 MQPR:$inactive))>;
  2120. }
  2121. class MVEIntSingleSrc<string iname, string suffix, bits<2> size,
  2122. list<dag> pattern=[]>
  2123. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary,
  2124. iname, suffix, "$Qd, $Qm", vpred_r, "", size, pattern> {
  2125. bits<4> Qd;
  2126. bits<4> Qm;
  2127. let Inst{22} = Qd{3};
  2128. let Inst{19-18} = size{1-0};
  2129. let Inst{15-13} = Qd{2-0};
  2130. let Inst{5} = Qm{3};
  2131. let Inst{3-1} = Qm{2-0};
  2132. }
  2133. class MVE_VCLSCLZ<string iname, string suffix, bits<2> size,
  2134. bit count_zeroes, list<dag> pattern=[]>
  2135. : MVEIntSingleSrc<iname, suffix, size, pattern> {
  2136. let Inst{28} = 0b1;
  2137. let Inst{25-23} = 0b111;
  2138. let Inst{21-20} = 0b11;
  2139. let Inst{17-16} = 0b00;
  2140. let Inst{12-8} = 0b00100;
  2141. let Inst{7} = count_zeroes;
  2142. let Inst{6} = 0b1;
  2143. let Inst{4} = 0b0;
  2144. let Inst{0} = 0b0;
  2145. let validForTailPredication = 1;
  2146. }
  2147. multiclass MVE_VCLSCLZ_p<string opname, bit opcode, MVEVectorVTInfo VTI,
  2148. SDPatternOperator unpred_op> {
  2149. def "": MVE_VCLSCLZ<"v"#opname, VTI.Suffix, VTI.Size, opcode>;
  2150. defvar Inst = !cast<Instruction>(NAME);
  2151. defvar pred_int = !cast<Intrinsic>("int_arm_mve_"#opname#"_predicated");
  2152. let Predicates = [HasMVEInt] in {
  2153. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))),
  2154. (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>;
  2155. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred),
  2156. (VTI.Vec MQPR:$inactive))),
  2157. (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen,
  2158. (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
  2159. }
  2160. }
  2161. defm MVE_VCLSs8 : MVE_VCLSCLZ_p<"cls", 0, MVE_v16s8, int_arm_mve_vcls>;
  2162. defm MVE_VCLSs16 : MVE_VCLSCLZ_p<"cls", 0, MVE_v8s16, int_arm_mve_vcls>;
  2163. defm MVE_VCLSs32 : MVE_VCLSCLZ_p<"cls", 0, MVE_v4s32, int_arm_mve_vcls>;
  2164. defm MVE_VCLZs8 : MVE_VCLSCLZ_p<"clz", 1, MVE_v16i8, ctlz>;
  2165. defm MVE_VCLZs16 : MVE_VCLSCLZ_p<"clz", 1, MVE_v8i16, ctlz>;
  2166. defm MVE_VCLZs32 : MVE_VCLSCLZ_p<"clz", 1, MVE_v4i32, ctlz>;
  2167. class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate,
  2168. bit saturate, list<dag> pattern=[]>
  2169. : MVEIntSingleSrc<iname, suffix, size, pattern> {
  2170. let Inst{28} = 0b1;
  2171. let Inst{25-23} = 0b111;
  2172. let Inst{21-20} = 0b11;
  2173. let Inst{17} = 0b0;
  2174. let Inst{16} = !eq(saturate, 0);
  2175. let Inst{12-11} = 0b00;
  2176. let Inst{10} = saturate;
  2177. let Inst{9-8} = 0b11;
  2178. let Inst{7} = negate;
  2179. let Inst{6} = 0b1;
  2180. let Inst{4} = 0b0;
  2181. let Inst{0} = 0b0;
  2182. let validForTailPredication = 1;
  2183. }
  2184. multiclass MVE_VABSNEG_int_m<string iname, bit negate, bit saturate,
  2185. SDPatternOperator unpred_op, Intrinsic pred_int,
  2186. MVEVectorVTInfo VTI> {
  2187. def "" : MVE_VABSNEG_int<iname, VTI.Suffix, VTI.Size, negate, saturate>;
  2188. defvar Inst = !cast<Instruction>(NAME);
  2189. let Predicates = [HasMVEInt] in {
  2190. // VQABS and VQNEG have more difficult isel patterns defined elsewhere
  2191. if !not(saturate) then {
  2192. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))),
  2193. (VTI.Vec (Inst $v))>;
  2194. }
  2195. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask),
  2196. (VTI.Vec MQPR:$inactive))),
  2197. (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>;
  2198. }
  2199. }
  2200. foreach VTI = [ MVE_v16s8, MVE_v8s16, MVE_v4s32 ] in {
  2201. defm "MVE_VABS" # VTI.Suffix : MVE_VABSNEG_int_m<
  2202. "vabs", 0, 0, abs, int_arm_mve_abs_predicated, VTI>;
  2203. defm "MVE_VQABS" # VTI.Suffix : MVE_VABSNEG_int_m<
  2204. "vqabs", 0, 1, ?, int_arm_mve_qabs_predicated, VTI>;
  2205. defm "MVE_VNEG" # VTI.Suffix : MVE_VABSNEG_int_m<
  2206. "vneg", 1, 0, vnegq, int_arm_mve_neg_predicated, VTI>;
  2207. defm "MVE_VQNEG" # VTI.Suffix : MVE_VABSNEG_int_m<
  2208. "vqneg", 1, 1, ?, int_arm_mve_qneg_predicated, VTI>;
  2209. }
  2210. // int_min/int_max: vector containing INT_MIN/INT_MAX VTI.Size times
  2211. // zero_vec: v4i32-initialized zero vector, potentially wrapped in a bitconvert
  2212. multiclass vqabsneg_pattern<MVEVectorVTInfo VTI, dag int_min, dag int_max,
  2213. dag zero_vec, MVE_VABSNEG_int vqabs_instruction,
  2214. MVE_VABSNEG_int vqneg_instruction> {
  2215. let Predicates = [HasMVEInt] in {
  2216. // The below tree can be replaced by a vqabs instruction, as it represents
  2217. // the following vectorized expression (r being the value in $reg):
  2218. // r > 0 ? r : (r == INT_MIN ? INT_MAX : -r)
  2219. def : Pat<(VTI.Vec (vselect
  2220. (VTI.Pred (ARMvcmpz (VTI.Vec MQPR:$reg), ARMCCgt)),
  2221. (VTI.Vec MQPR:$reg),
  2222. (VTI.Vec (vselect
  2223. (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)),
  2224. int_max,
  2225. (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))))),
  2226. (VTI.Vec (vqabs_instruction (VTI.Vec MQPR:$reg)))>;
  2227. // Similarly, this tree represents vqneg, i.e. the following vectorized expression:
  2228. // r == INT_MIN ? INT_MAX : -r
  2229. def : Pat<(VTI.Vec (vselect
  2230. (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)),
  2231. int_max,
  2232. (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))),
  2233. (VTI.Vec (vqneg_instruction (VTI.Vec MQPR:$reg)))>;
  2234. }
  2235. }
  2236. defm MVE_VQABSNEG_Ps8 : vqabsneg_pattern<MVE_v16i8,
  2237. (v16i8 (ARMvmovImm (i32 3712))),
  2238. (v16i8 (ARMvmovImm (i32 3711))),
  2239. (bitconvert (v4i32 (ARMvmovImm (i32 0)))),
  2240. MVE_VQABSs8, MVE_VQNEGs8>;
  2241. defm MVE_VQABSNEG_Ps16 : vqabsneg_pattern<MVE_v8i16,
  2242. (v8i16 (ARMvmovImm (i32 2688))),
  2243. (v8i16 (ARMvmvnImm (i32 2688))),
  2244. (bitconvert (v4i32 (ARMvmovImm (i32 0)))),
  2245. MVE_VQABSs16, MVE_VQNEGs16>;
  2246. defm MVE_VQABSNEG_Ps32 : vqabsneg_pattern<MVE_v4i32,
  2247. (v4i32 (ARMvmovImm (i32 1664))),
  2248. (v4i32 (ARMvmvnImm (i32 1664))),
  2249. (ARMvmovImm (i32 0)),
  2250. MVE_VQABSs32, MVE_VQNEGs32>;
  2251. class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op,
  2252. dag iops, bits<2> vecsize, list<dag> pattern=[]>
  2253. : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm",
  2254. vpred_r, "", vecsize, pattern> {
  2255. bits<13> imm;
  2256. bits<4> Qd;
  2257. let Inst{28} = imm{7};
  2258. let Inst{25-23} = 0b111;
  2259. let Inst{22} = Qd{3};
  2260. let Inst{21-19} = 0b000;
  2261. let Inst{18-16} = imm{6-4};
  2262. let Inst{15-13} = Qd{2-0};
  2263. let Inst{12} = 0b0;
  2264. let Inst{11-8} = cmode{3-0};
  2265. let Inst{7-6} = 0b01;
  2266. let Inst{5} = op;
  2267. let Inst{4} = 0b1;
  2268. let Inst{3-0} = imm{3-0};
  2269. let DecoderMethod = "DecodeMVEModImmInstruction";
  2270. let validForTailPredication = 1;
  2271. }
  2272. let isReMaterializable = 1 in {
  2273. let isAsCheapAsAMove = 1 in {
  2274. def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm), 0b00>;
  2275. def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm), 0b01> {
  2276. let Inst{9} = imm{9};
  2277. }
  2278. def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm), 0b10> {
  2279. let Inst{11-8} = imm{11-8};
  2280. }
  2281. def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm), 0b11>;
  2282. def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm), 0b10>;
  2283. } // let isAsCheapAsAMove = 1
  2284. def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm), 0b01> {
  2285. let Inst{9} = imm{9};
  2286. }
  2287. def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm), 0b10> {
  2288. let Inst{11-8} = imm{11-8};
  2289. }
  2290. } // let isReMaterializable = 1
  2291. let Predicates = [HasMVEInt] in {
  2292. def : Pat<(v16i8 (ARMvmovImm timm:$simm)),
  2293. (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>;
  2294. def : Pat<(v8i16 (ARMvmovImm timm:$simm)),
  2295. (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>;
  2296. def : Pat<(v4i32 (ARMvmovImm timm:$simm)),
  2297. (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>;
  2298. def : Pat<(v2i64 (ARMvmovImm timm:$simm)),
  2299. (v2i64 (MVE_VMOVimmi64 nImmSplatI64:$simm))>;
  2300. def : Pat<(v8i16 (ARMvmvnImm timm:$simm)),
  2301. (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>;
  2302. def : Pat<(v4i32 (ARMvmvnImm timm:$simm)),
  2303. (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>;
  2304. def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)),
  2305. (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>;
  2306. def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (ARMvmvnImm timm:$simm),
  2307. MQPR:$inactive)),
  2308. (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm,
  2309. ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>;
  2310. def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (ARMvmvnImm timm:$simm),
  2311. MQPR:$inactive)),
  2312. (v4i32 (MVE_VMVNimmi32 nImmSplatI32:$simm,
  2313. ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>;
  2314. }
  2315. class MVE_VMINMAXA<string iname, string suffix, bits<2> size,
  2316. bit bit_12, list<dag> pattern=[]>
  2317. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
  2318. NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
  2319. size, pattern> {
  2320. bits<4> Qd;
  2321. bits<4> Qm;
  2322. let Inst{28} = 0b0;
  2323. let Inst{25-23} = 0b100;
  2324. let Inst{22} = Qd{3};
  2325. let Inst{21-20} = 0b11;
  2326. let Inst{19-18} = size;
  2327. let Inst{17-16} = 0b11;
  2328. let Inst{15-13} = Qd{2-0};
  2329. let Inst{12} = bit_12;
  2330. let Inst{11-6} = 0b111010;
  2331. let Inst{5} = Qm{3};
  2332. let Inst{4} = 0b0;
  2333. let Inst{3-1} = Qm{2-0};
  2334. let Inst{0} = 0b1;
  2335. let validForTailPredication = 1;
  2336. }
  2337. multiclass MVE_VMINMAXA_m<string iname, MVEVectorVTInfo VTI,
  2338. SDNode unpred_op, Intrinsic pred_int, bit bit_12> {
  2339. def "" : MVE_VMINMAXA<iname, VTI.Suffix, VTI.Size, bit_12>;
  2340. defvar Inst = !cast<Instruction>(NAME);
  2341. let Predicates = [HasMVEInt] in {
  2342. // Unpredicated v(min|max)a
  2343. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (abs (VTI.Vec MQPR:$Qm)))),
  2344. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
  2345. // Predicated v(min|max)a
  2346. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  2347. (VTI.Pred VCCR:$mask))),
  2348. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  2349. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  2350. }
  2351. }
  2352. multiclass MVE_VMINA<MVEVectorVTInfo VTI>
  2353. : MVE_VMINMAXA_m<"vmina", VTI, umin, int_arm_mve_vmina_predicated, 0b1>;
  2354. defm MVE_VMINAs8 : MVE_VMINA<MVE_v16s8>;
  2355. defm MVE_VMINAs16 : MVE_VMINA<MVE_v8s16>;
  2356. defm MVE_VMINAs32 : MVE_VMINA<MVE_v4s32>;
  2357. multiclass MVE_VMAXA<MVEVectorVTInfo VTI>
  2358. : MVE_VMINMAXA_m<"vmaxa", VTI, umax, int_arm_mve_vmaxa_predicated, 0b0>;
  2359. defm MVE_VMAXAs8 : MVE_VMAXA<MVE_v16s8>;
  2360. defm MVE_VMAXAs16 : MVE_VMAXA<MVE_v8s16>;
  2361. defm MVE_VMAXAs32 : MVE_VMAXA<MVE_v4s32>;
  2362. // end of MVE Integer instructions
  2363. // start of mve_imm_shift instructions
  2364. def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd),
  2365. (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm),
  2366. NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm",
  2367. vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc", 0b10> {
  2368. bits<5> imm;
  2369. bits<4> Qd;
  2370. bits<4> RdmDest;
  2371. let Inst{28} = 0b0;
  2372. let Inst{25-23} = 0b101;
  2373. let Inst{22} = Qd{3};
  2374. let Inst{21} = 0b1;
  2375. let Inst{20-16} = imm{4-0};
  2376. let Inst{15-13} = Qd{2-0};
  2377. let Inst{12-4} = 0b011111100;
  2378. let Inst{3-0} = RdmDest{3-0};
  2379. }
  2380. class MVE_shift_imm<dag oops, dag iops, string iname, string suffix,
  2381. string ops, vpred_ops vpred, string cstr,
  2382. bits<2> vecsize, list<dag> pattern=[]>
  2383. : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  2384. bits<4> Qd;
  2385. bits<4> Qm;
  2386. let Inst{22} = Qd{3};
  2387. let Inst{15-13} = Qd{2-0};
  2388. let Inst{5} = Qm{3};
  2389. let Inst{3-1} = Qm{2-0};
  2390. }
  2391. class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U, bit top,
  2392. list<dag> pattern=[]>
  2393. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
  2394. iname, suffix, "$Qd, $Qm", vpred_r, "",
  2395. sz, pattern> {
  2396. let Inst{28} = U;
  2397. let Inst{25-23} = 0b101;
  2398. let Inst{21} = 0b1;
  2399. let Inst{20-19} = sz{1-0};
  2400. let Inst{18-16} = 0b000;
  2401. let Inst{12} = top;
  2402. let Inst{11-6} = 0b111101;
  2403. let Inst{4} = 0b0;
  2404. let Inst{0} = 0b0;
  2405. let doubleWidthResult = 1;
  2406. }
  2407. multiclass MVE_VMOVL_m<bit top, string chr, MVEVectorVTInfo OutVTI,
  2408. MVEVectorVTInfo InVTI> {
  2409. def "": MVE_VMOVL<"vmovl" # chr, InVTI.Suffix, OutVTI.Size,
  2410. InVTI.Unsigned, top>;
  2411. defvar Inst = !cast<Instruction>(NAME);
  2412. def : Pat<(OutVTI.Vec (int_arm_mve_vmovl_predicated (InVTI.Vec MQPR:$src),
  2413. (i32 InVTI.Unsigned), (i32 top),
  2414. (OutVTI.Pred VCCR:$pred),
  2415. (OutVTI.Vec MQPR:$inactive))),
  2416. (OutVTI.Vec (Inst (InVTI.Vec MQPR:$src), ARMVCCThen,
  2417. (OutVTI.Pred VCCR:$pred), zero_reg,
  2418. (OutVTI.Vec MQPR:$inactive)))>;
  2419. }
  2420. defm MVE_VMOVLs8bh : MVE_VMOVL_m<0, "b", MVE_v8s16, MVE_v16s8>;
  2421. defm MVE_VMOVLs8th : MVE_VMOVL_m<1, "t", MVE_v8s16, MVE_v16s8>;
  2422. defm MVE_VMOVLu8bh : MVE_VMOVL_m<0, "b", MVE_v8u16, MVE_v16u8>;
  2423. defm MVE_VMOVLu8th : MVE_VMOVL_m<1, "t", MVE_v8u16, MVE_v16u8>;
  2424. defm MVE_VMOVLs16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8s16>;
  2425. defm MVE_VMOVLs16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8s16>;
  2426. defm MVE_VMOVLu16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8u16>;
  2427. defm MVE_VMOVLu16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8u16>;
  2428. let Predicates = [HasMVEInt] in {
  2429. def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16),
  2430. (MVE_VMOVLs16bh MQPR:$src)>;
  2431. def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8),
  2432. (MVE_VMOVLs8bh MQPR:$src)>;
  2433. def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8),
  2434. (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>;
  2435. def : Pat<(sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), v8i8),
  2436. (MVE_VMOVLs8th MQPR:$src)>;
  2437. def : Pat<(sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))), v4i16),
  2438. (MVE_VMOVLs16th MQPR:$src)>;
  2439. // zext_inreg 8 -> 16
  2440. def : Pat<(ARMvbicImm (v8i16 MQPR:$src), (i32 0xAFF)),
  2441. (MVE_VMOVLu8bh MQPR:$src)>;
  2442. // zext_inreg 16 -> 32
  2443. def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))),
  2444. (MVE_VMOVLu16bh MQPR:$src)>;
  2445. // Same zext_inreg with vrevs, picking the top half
  2446. def : Pat<(ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), (i32 0xAFF)),
  2447. (MVE_VMOVLu8th MQPR:$src)>;
  2448. def : Pat<(and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))),
  2449. (v4i32 (ARMvmovImm (i32 0xCFF)))),
  2450. (MVE_VMOVLu16th MQPR:$src)>;
  2451. }
  2452. class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th,
  2453. Operand immtype, bits<2> vecsize, list<dag> pattern=[]>
  2454. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm, immtype:$imm),
  2455. iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", vecsize, pattern> {
  2456. let Inst{28} = U;
  2457. let Inst{25-23} = 0b101;
  2458. let Inst{21} = 0b1;
  2459. let Inst{12} = th;
  2460. let Inst{11-6} = 0b111101;
  2461. let Inst{4} = 0b0;
  2462. let Inst{0} = 0b0;
  2463. // For the MVE_VSHLL_patterns multiclass to refer to
  2464. Operand immediateType = immtype;
  2465. let doubleWidthResult = 1;
  2466. }
  2467. // The immediate VSHLL instructions accept shift counts from 1 up to
  2468. // the lane width (8 or 16), but the full-width shifts have an
  2469. // entirely separate encoding, given below with 'lw' in the name.
  2470. class MVE_VSHLL_imm8<string iname, string suffix,
  2471. bit U, bit th, list<dag> pattern=[]>
  2472. : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_7, 0b01, pattern> {
  2473. bits<3> imm;
  2474. let Inst{20-19} = 0b01;
  2475. let Inst{18-16} = imm;
  2476. }
  2477. class MVE_VSHLL_imm16<string iname, string suffix,
  2478. bit U, bit th, list<dag> pattern=[]>
  2479. : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_15, 0b10, pattern> {
  2480. bits<4> imm;
  2481. let Inst{20} = 0b1;
  2482. let Inst{19-16} = imm;
  2483. }
  2484. def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>;
  2485. def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>;
  2486. def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>;
  2487. def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>;
  2488. def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>;
  2489. def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>;
  2490. def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>;
  2491. def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>;
  2492. class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size,
  2493. bit U, string ops, list<dag> pattern=[]>
  2494. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
  2495. iname, suffix, ops, vpred_r, "", !if(size, 0b10, 0b01), pattern> {
  2496. let Inst{28} = U;
  2497. let Inst{25-23} = 0b100;
  2498. let Inst{21-20} = 0b11;
  2499. let Inst{19-18} = size{1-0};
  2500. let Inst{17-16} = 0b01;
  2501. let Inst{11-6} = 0b111000;
  2502. let Inst{4} = 0b0;
  2503. let Inst{0} = 0b1;
  2504. let doubleWidthResult = 1;
  2505. }
  2506. multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U,
  2507. string ops, list<dag> pattern=[]> {
  2508. def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> {
  2509. let Inst{12} = 0b0;
  2510. }
  2511. def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> {
  2512. let Inst{12} = 0b1;
  2513. }
  2514. }
  2515. defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">;
  2516. defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">;
  2517. defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">;
  2518. defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">;
  2519. multiclass MVE_VSHLL_patterns<MVEVectorVTInfo VTI, int top> {
  2520. defvar suffix = !strconcat(VTI.Suffix, !if(top, "th", "bh"));
  2521. defvar inst_imm = !cast<MVE_VSHLL_imm>("MVE_VSHLL_imm" # suffix);
  2522. defvar inst_lw = !cast<MVE_VSHLL_by_lane_width>("MVE_VSHLL_lw" # suffix);
  2523. defvar unpred_int = int_arm_mve_vshll_imm;
  2524. defvar pred_int = int_arm_mve_vshll_imm_predicated;
  2525. defvar imm = inst_imm.immediateType;
  2526. def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), imm:$imm,
  2527. (i32 VTI.Unsigned), (i32 top))),
  2528. (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm))>;
  2529. def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits),
  2530. (i32 VTI.Unsigned), (i32 top))),
  2531. (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src)))>;
  2532. def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), imm:$imm,
  2533. (i32 VTI.Unsigned), (i32 top),
  2534. (VTI.DblPred VCCR:$mask),
  2535. (VTI.DblVec MQPR:$inactive))),
  2536. (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm,
  2537. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  2538. (VTI.DblVec MQPR:$inactive)))>;
  2539. def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits),
  2540. (i32 VTI.Unsigned), (i32 top),
  2541. (VTI.DblPred VCCR:$mask),
  2542. (VTI.DblVec MQPR:$inactive))),
  2543. (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src), ARMVCCThen,
  2544. (VTI.DblPred VCCR:$mask), zero_reg,
  2545. (VTI.DblVec MQPR:$inactive)))>;
  2546. }
  2547. foreach VTI = [MVE_v16s8, MVE_v8s16, MVE_v16u8, MVE_v8u16] in
  2548. foreach top = [0, 1] in
  2549. defm : MVE_VSHLL_patterns<VTI, top>;
  2550. class MVE_shift_imm_partial<Operand imm, string iname, string suffix, bits<2> vecsize>
  2551. : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$QdSrc, MQPR:$Qm, imm:$imm),
  2552. iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc", vecsize> {
  2553. Operand immediateType = imm;
  2554. }
  2555. class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28,
  2556. Operand imm, bits<2> vecsize>
  2557. : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
  2558. bits<5> imm;
  2559. let Inst{28} = bit_28;
  2560. let Inst{25-23} = 0b101;
  2561. let Inst{21} = 0b0;
  2562. let Inst{20-16} = imm{4-0};
  2563. let Inst{12} = bit_12;
  2564. let Inst{11-6} = 0b111111;
  2565. let Inst{4} = 0b0;
  2566. let Inst{0} = 0b1;
  2567. let validForTailPredication = 1;
  2568. let retainsPreviousHalfElement = 1;
  2569. }
  2570. def MVE_VRSHRNi16bh : MVE_VxSHRN<"vrshrnb", "i16", 0b0, 0b1, shr_imm8, 0b01> {
  2571. let Inst{20-19} = 0b01;
  2572. }
  2573. def MVE_VRSHRNi16th : MVE_VxSHRN<"vrshrnt", "i16", 0b1, 0b1, shr_imm8, 0b01> {
  2574. let Inst{20-19} = 0b01;
  2575. }
  2576. def MVE_VRSHRNi32bh : MVE_VxSHRN<"vrshrnb", "i32", 0b0, 0b1, shr_imm16, 0b10> {
  2577. let Inst{20} = 0b1;
  2578. }
  2579. def MVE_VRSHRNi32th : MVE_VxSHRN<"vrshrnt", "i32", 0b1, 0b1, shr_imm16, 0b10> {
  2580. let Inst{20} = 0b1;
  2581. }
  2582. def MVE_VSHRNi16bh : MVE_VxSHRN<"vshrnb", "i16", 0b0, 0b0, shr_imm8, 0b01> {
  2583. let Inst{20-19} = 0b01;
  2584. }
  2585. def MVE_VSHRNi16th : MVE_VxSHRN<"vshrnt", "i16", 0b1, 0b0, shr_imm8, 0b01> {
  2586. let Inst{20-19} = 0b01;
  2587. }
  2588. def MVE_VSHRNi32bh : MVE_VxSHRN<"vshrnb", "i32", 0b0, 0b0, shr_imm16, 0b10> {
  2589. let Inst{20} = 0b1;
  2590. }
  2591. def MVE_VSHRNi32th : MVE_VxSHRN<"vshrnt", "i32", 0b1, 0b0, shr_imm16, 0b10> {
  2592. let Inst{20} = 0b1;
  2593. }
  2594. class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12,
  2595. Operand imm, bits<2> vecsize>
  2596. : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
  2597. bits<5> imm;
  2598. let Inst{28} = bit_28;
  2599. let Inst{25-23} = 0b101;
  2600. let Inst{21} = 0b0;
  2601. let Inst{20-16} = imm{4-0};
  2602. let Inst{12} = bit_12;
  2603. let Inst{11-6} = 0b111111;
  2604. let Inst{4} = 0b0;
  2605. let Inst{0} = 0b0;
  2606. let validForTailPredication = 1;
  2607. let retainsPreviousHalfElement = 1;
  2608. }
  2609. def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN<
  2610. "vqrshrunb", "s16", 0b1, 0b0, shr_imm8, 0b01> {
  2611. let Inst{20-19} = 0b01;
  2612. }
  2613. def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN<
  2614. "vqrshrunt", "s16", 0b1, 0b1, shr_imm8, 0b01> {
  2615. let Inst{20-19} = 0b01;
  2616. }
  2617. def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN<
  2618. "vqrshrunb", "s32", 0b1, 0b0, shr_imm16, 0b10> {
  2619. let Inst{20} = 0b1;
  2620. }
  2621. def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN<
  2622. "vqrshrunt", "s32", 0b1, 0b1, shr_imm16, 0b10> {
  2623. let Inst{20} = 0b1;
  2624. }
  2625. def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN<
  2626. "vqshrunb", "s16", 0b0, 0b0, shr_imm8, 0b01> {
  2627. let Inst{20-19} = 0b01;
  2628. }
  2629. def MVE_VQSHRUNs16th : MVE_VxQRSHRUN<
  2630. "vqshrunt", "s16", 0b0, 0b1, shr_imm8, 0b01> {
  2631. let Inst{20-19} = 0b01;
  2632. }
  2633. def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN<
  2634. "vqshrunb", "s32", 0b0, 0b0, shr_imm16, 0b10> {
  2635. let Inst{20} = 0b1;
  2636. }
  2637. def MVE_VQSHRUNs32th : MVE_VxQRSHRUN<
  2638. "vqshrunt", "s32", 0b0, 0b1, shr_imm16, 0b10> {
  2639. let Inst{20} = 0b1;
  2640. }
  2641. class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12,
  2642. Operand imm, bits<2> vecsize>
  2643. : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
  2644. bits<5> imm;
  2645. let Inst{25-23} = 0b101;
  2646. let Inst{21} = 0b0;
  2647. let Inst{20-16} = imm{4-0};
  2648. let Inst{12} = bit_12;
  2649. let Inst{11-6} = 0b111101;
  2650. let Inst{4} = 0b0;
  2651. let Inst{0} = bit_0;
  2652. let validForTailPredication = 1;
  2653. let retainsPreviousHalfElement = 1;
  2654. }
  2655. multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> {
  2656. def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, shr_imm8, 0b01> {
  2657. let Inst{28} = 0b0;
  2658. let Inst{20-19} = 0b01;
  2659. }
  2660. def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, shr_imm8, 0b01> {
  2661. let Inst{28} = 0b1;
  2662. let Inst{20-19} = 0b01;
  2663. }
  2664. def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, shr_imm16, 0b10> {
  2665. let Inst{28} = 0b0;
  2666. let Inst{20} = 0b1;
  2667. }
  2668. def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, shr_imm16, 0b10> {
  2669. let Inst{28} = 0b1;
  2670. let Inst{20} = 0b1;
  2671. }
  2672. }
  2673. defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>;
  2674. defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>;
  2675. defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>;
  2676. defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>;
  2677. multiclass MVE_VSHRN_patterns<MVE_shift_imm_partial inst,
  2678. MVEVectorVTInfo OutVTI, MVEVectorVTInfo InVTI,
  2679. bit q, bit r, bit top> {
  2680. defvar inparams = (? (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm),
  2681. (inst.immediateType:$imm), (i32 q), (i32 r),
  2682. (i32 OutVTI.Unsigned), (i32 InVTI.Unsigned), (i32 top));
  2683. defvar outparams = (inst (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm),
  2684. (imm:$imm));
  2685. def : Pat<(OutVTI.Vec !setdagop(inparams, int_arm_mve_vshrn)),
  2686. (OutVTI.Vec outparams)>;
  2687. def : Pat<(OutVTI.Vec !con(inparams, (int_arm_mve_vshrn_predicated
  2688. (InVTI.Pred VCCR:$pred)))),
  2689. (OutVTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>;
  2690. }
  2691. defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,0,0>;
  2692. defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16s8, MVE_v8s16, 0,0,1>;
  2693. defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,0,0>;
  2694. defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8s16, MVE_v4s32, 0,0,1>;
  2695. defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,0,0>;
  2696. defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16u8, MVE_v8u16, 0,0,1>;
  2697. defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,0,0>;
  2698. defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8u16, MVE_v4u32, 0,0,1>;
  2699. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,1,0>;
  2700. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16s8, MVE_v8s16, 0,1,1>;
  2701. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,1,0>;
  2702. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8s16, MVE_v4s32, 0,1,1>;
  2703. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,1,0>;
  2704. defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16u8, MVE_v8u16, 0,1,1>;
  2705. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,1,0>;
  2706. defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8u16, MVE_v4u32, 0,1,1>;
  2707. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,0,0>;
  2708. defm : MVE_VSHRN_patterns<MVE_VQSHRNths16, MVE_v16s8, MVE_v8s16, 1,0,1>;
  2709. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,0,0>;
  2710. defm : MVE_VSHRN_patterns<MVE_VQSHRNths32, MVE_v8s16, MVE_v4s32, 1,0,1>;
  2711. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,0,0>;
  2712. defm : MVE_VSHRN_patterns<MVE_VQSHRNthu16, MVE_v16u8, MVE_v8u16, 1,0,1>;
  2713. defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,0,0>;
  2714. defm : MVE_VSHRN_patterns<MVE_VQSHRNthu32, MVE_v8u16, MVE_v4u32, 1,0,1>;
  2715. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,1,0>;
  2716. defm : MVE_VSHRN_patterns<MVE_VQRSHRNths16, MVE_v16s8, MVE_v8s16, 1,1,1>;
  2717. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,1,0>;
  2718. defm : MVE_VSHRN_patterns<MVE_VQRSHRNths32, MVE_v8s16, MVE_v4s32, 1,1,1>;
  2719. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,1,0>;
  2720. defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu16, MVE_v16u8, MVE_v8u16, 1,1,1>;
  2721. defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,1,0>;
  2722. defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu32, MVE_v8u16, MVE_v4u32, 1,1,1>;
  2723. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,0,0>;
  2724. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,0,1>;
  2725. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,0,0>;
  2726. defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,0,1>;
  2727. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,1,0>;
  2728. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,1,1>;
  2729. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,1,0>;
  2730. defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,1,1>;
  2731. // end of mve_imm_shift instructions
  2732. // start of mve_shift instructions
  2733. class MVE_shift_by_vec<string iname, string suffix, bit U,
  2734. bits<2> size, bit bit_4, bit bit_8>
  2735. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary,
  2736. iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", size, []> {
  2737. // Shift instructions which take a vector of shift counts
  2738. bits<4> Qd;
  2739. bits<4> Qm;
  2740. bits<4> Qn;
  2741. let Inst{28} = U;
  2742. let Inst{25-24} = 0b11;
  2743. let Inst{23} = 0b0;
  2744. let Inst{22} = Qd{3};
  2745. let Inst{21-20} = size;
  2746. let Inst{19-17} = Qn{2-0};
  2747. let Inst{16} = 0b0;
  2748. let Inst{15-13} = Qd{2-0};
  2749. let Inst{12-9} = 0b0010;
  2750. let Inst{8} = bit_8;
  2751. let Inst{7} = Qn{3};
  2752. let Inst{6} = 0b1;
  2753. let Inst{5} = Qm{3};
  2754. let Inst{4} = bit_4;
  2755. let Inst{3-1} = Qm{2-0};
  2756. let Inst{0} = 0b0;
  2757. let validForTailPredication = 1;
  2758. }
  2759. multiclass MVE_shift_by_vec_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> {
  2760. def "" : MVE_shift_by_vec<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>;
  2761. defvar Inst = !cast<Instruction>(NAME);
  2762. def : Pat<(VTI.Vec (int_arm_mve_vshl_vector
  2763. (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
  2764. (i32 q), (i32 r), (i32 VTI.Unsigned))),
  2765. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh)))>;
  2766. def : Pat<(VTI.Vec (int_arm_mve_vshl_vector_predicated
  2767. (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
  2768. (i32 q), (i32 r), (i32 VTI.Unsigned),
  2769. (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
  2770. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
  2771. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  2772. (VTI.Vec MQPR:$inactive)))>;
  2773. }
  2774. multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> {
  2775. defm s8 : MVE_shift_by_vec_p<iname, MVE_v16s8, bit_4, bit_8>;
  2776. defm s16 : MVE_shift_by_vec_p<iname, MVE_v8s16, bit_4, bit_8>;
  2777. defm s32 : MVE_shift_by_vec_p<iname, MVE_v4s32, bit_4, bit_8>;
  2778. defm u8 : MVE_shift_by_vec_p<iname, MVE_v16u8, bit_4, bit_8>;
  2779. defm u16 : MVE_shift_by_vec_p<iname, MVE_v8u16, bit_4, bit_8>;
  2780. defm u32 : MVE_shift_by_vec_p<iname, MVE_v4u32, bit_4, bit_8>;
  2781. }
  2782. defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>;
  2783. defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>;
  2784. defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>;
  2785. defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>;
  2786. let Predicates = [HasMVEInt] in {
  2787. def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
  2788. (v4i32 (MVE_VSHL_by_vecu32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
  2789. def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
  2790. (v8i16 (MVE_VSHL_by_vecu16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
  2791. def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
  2792. (v16i8 (MVE_VSHL_by_vecu8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
  2793. def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
  2794. (v4i32 (MVE_VSHL_by_vecs32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
  2795. def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
  2796. (v8i16 (MVE_VSHL_by_vecs16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
  2797. def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
  2798. (v16i8 (MVE_VSHL_by_vecs8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
  2799. }
  2800. class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops,
  2801. string ops, vpred_ops vpred, string cstr,
  2802. bits<2> vecsize, list<dag> pattern=[]>
  2803. : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  2804. bits<4> Qd;
  2805. bits<4> Qm;
  2806. let Inst{23} = 0b1;
  2807. let Inst{22} = Qd{3};
  2808. let Inst{15-13} = Qd{2-0};
  2809. let Inst{12-11} = 0b00;
  2810. let Inst{7-6} = 0b01;
  2811. let Inst{5} = Qm{3};
  2812. let Inst{4} = 0b1;
  2813. let Inst{3-1} = Qm{2-0};
  2814. let Inst{0} = 0b0;
  2815. let validForTailPredication = 1;
  2816. // For the MVE_shift_imm_patterns multiclass to refer to
  2817. MVEVectorVTInfo VTI;
  2818. Operand immediateType;
  2819. Intrinsic unpred_int;
  2820. Intrinsic pred_int;
  2821. dag unsignedFlag = (?);
  2822. }
  2823. class MVE_VSxI_imm<string iname, string suffix, bit bit_8, Operand immType, bits<2> vecsize>
  2824. : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd),
  2825. (ins MQPR:$Qd_src, MQPR:$Qm, immType:$imm),
  2826. "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src", vecsize> {
  2827. bits<6> imm;
  2828. let Inst{28} = 0b1;
  2829. let Inst{25-24} = 0b11;
  2830. let Inst{21-16} = imm;
  2831. let Inst{10-9} = 0b10;
  2832. let Inst{8} = bit_8;
  2833. let validForTailPredication = 1;
  2834. Operand immediateType = immType;
  2835. }
  2836. def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, shr_imm8, 0b00> {
  2837. let Inst{21-19} = 0b001;
  2838. }
  2839. def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, shr_imm16, 0b01> {
  2840. let Inst{21-20} = 0b01;
  2841. }
  2842. def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, shr_imm32, 0b10> {
  2843. let Inst{21} = 0b1;
  2844. }
  2845. def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, imm0_7, 0b00> {
  2846. let Inst{21-19} = 0b001;
  2847. }
  2848. def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, imm0_15, 0b01> {
  2849. let Inst{21-20} = 0b01;
  2850. }
  2851. def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,imm0_31, 0b10> {
  2852. let Inst{21} = 0b1;
  2853. }
  2854. multiclass MVE_VSxI_patterns<MVE_VSxI_imm inst, string name,
  2855. MVEVectorVTInfo VTI> {
  2856. defvar inparams = (? (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm),
  2857. (inst.immediateType:$imm));
  2858. defvar outparams = (inst (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm),
  2859. (inst.immediateType:$imm));
  2860. defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # name);
  2861. defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # name # "_predicated");
  2862. def : Pat<(VTI.Vec !setdagop(inparams, unpred_int)),
  2863. (VTI.Vec outparams)>;
  2864. def : Pat<(VTI.Vec !con(inparams, (pred_int (VTI.Pred VCCR:$pred)))),
  2865. (VTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>;
  2866. }
  2867. defm : MVE_VSxI_patterns<MVE_VSLIimm8, "vsli", MVE_v16i8>;
  2868. defm : MVE_VSxI_patterns<MVE_VSLIimm16, "vsli", MVE_v8i16>;
  2869. defm : MVE_VSxI_patterns<MVE_VSLIimm32, "vsli", MVE_v4i32>;
  2870. defm : MVE_VSxI_patterns<MVE_VSRIimm8, "vsri", MVE_v16i8>;
  2871. defm : MVE_VSxI_patterns<MVE_VSRIimm16, "vsri", MVE_v8i16>;
  2872. defm : MVE_VSxI_patterns<MVE_VSRIimm32, "vsri", MVE_v4i32>;
  2873. class MVE_VQSHL_imm<MVEVectorVTInfo VTI_, Operand immType>
  2874. : MVE_shift_with_imm<"vqshl", VTI_.Suffix, (outs MQPR:$Qd),
  2875. (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
  2876. vpred_r, "", VTI_.Size> {
  2877. bits<6> imm;
  2878. let Inst{28} = VTI_.Unsigned;
  2879. let Inst{25-24} = 0b11;
  2880. let Inst{21-16} = imm;
  2881. let Inst{10-8} = 0b111;
  2882. let VTI = VTI_;
  2883. let immediateType = immType;
  2884. let unsignedFlag = (? (i32 VTI.Unsigned));
  2885. }
  2886. let unpred_int = int_arm_mve_vqshl_imm,
  2887. pred_int = int_arm_mve_vqshl_imm_predicated in {
  2888. def MVE_VQSHLimms8 : MVE_VQSHL_imm<MVE_v16s8, imm0_7> {
  2889. let Inst{21-19} = 0b001;
  2890. }
  2891. def MVE_VQSHLimmu8 : MVE_VQSHL_imm<MVE_v16u8, imm0_7> {
  2892. let Inst{21-19} = 0b001;
  2893. }
  2894. def MVE_VQSHLimms16 : MVE_VQSHL_imm<MVE_v8s16, imm0_15> {
  2895. let Inst{21-20} = 0b01;
  2896. }
  2897. def MVE_VQSHLimmu16 : MVE_VQSHL_imm<MVE_v8u16, imm0_15> {
  2898. let Inst{21-20} = 0b01;
  2899. }
  2900. def MVE_VQSHLimms32 : MVE_VQSHL_imm<MVE_v4s32, imm0_31> {
  2901. let Inst{21} = 0b1;
  2902. }
  2903. def MVE_VQSHLimmu32 : MVE_VQSHL_imm<MVE_v4u32, imm0_31> {
  2904. let Inst{21} = 0b1;
  2905. }
  2906. }
  2907. class MVE_VQSHLU_imm<MVEVectorVTInfo VTI_, Operand immType>
  2908. : MVE_shift_with_imm<"vqshlu", VTI_.Suffix, (outs MQPR:$Qd),
  2909. (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
  2910. vpred_r, "", VTI_.Size> {
  2911. bits<6> imm;
  2912. let Inst{28} = 0b1;
  2913. let Inst{25-24} = 0b11;
  2914. let Inst{21-16} = imm;
  2915. let Inst{10-8} = 0b110;
  2916. let VTI = VTI_;
  2917. let immediateType = immType;
  2918. }
  2919. let unpred_int = int_arm_mve_vqshlu_imm,
  2920. pred_int = int_arm_mve_vqshlu_imm_predicated in {
  2921. def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<MVE_v16s8, imm0_7> {
  2922. let Inst{21-19} = 0b001;
  2923. }
  2924. def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<MVE_v8s16, imm0_15> {
  2925. let Inst{21-20} = 0b01;
  2926. }
  2927. def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<MVE_v4s32, imm0_31> {
  2928. let Inst{21} = 0b1;
  2929. }
  2930. }
  2931. class MVE_VRSHR_imm<MVEVectorVTInfo VTI_, Operand immType>
  2932. : MVE_shift_with_imm<"vrshr", VTI_.Suffix, (outs MQPR:$Qd),
  2933. (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
  2934. vpred_r, "", VTI_.Size> {
  2935. bits<6> imm;
  2936. let Inst{28} = VTI_.Unsigned;
  2937. let Inst{25-24} = 0b11;
  2938. let Inst{21-16} = imm;
  2939. let Inst{10-8} = 0b010;
  2940. let VTI = VTI_;
  2941. let immediateType = immType;
  2942. let unsignedFlag = (? (i32 VTI.Unsigned));
  2943. }
  2944. let unpred_int = int_arm_mve_vrshr_imm,
  2945. pred_int = int_arm_mve_vrshr_imm_predicated in {
  2946. def MVE_VRSHR_imms8 : MVE_VRSHR_imm<MVE_v16s8, shr_imm8> {
  2947. let Inst{21-19} = 0b001;
  2948. }
  2949. def MVE_VRSHR_immu8 : MVE_VRSHR_imm<MVE_v16u8, shr_imm8> {
  2950. let Inst{21-19} = 0b001;
  2951. }
  2952. def MVE_VRSHR_imms16 : MVE_VRSHR_imm<MVE_v8s16, shr_imm16> {
  2953. let Inst{21-20} = 0b01;
  2954. }
  2955. def MVE_VRSHR_immu16 : MVE_VRSHR_imm<MVE_v8u16, shr_imm16> {
  2956. let Inst{21-20} = 0b01;
  2957. }
  2958. def MVE_VRSHR_imms32 : MVE_VRSHR_imm<MVE_v4s32, shr_imm32> {
  2959. let Inst{21} = 0b1;
  2960. }
  2961. def MVE_VRSHR_immu32 : MVE_VRSHR_imm<MVE_v4u32, shr_imm32> {
  2962. let Inst{21} = 0b1;
  2963. }
  2964. }
  2965. multiclass MVE_shift_imm_patterns<MVE_shift_with_imm inst> {
  2966. def : Pat<(inst.VTI.Vec !con((inst.unpred_int (inst.VTI.Vec MQPR:$src),
  2967. inst.immediateType:$imm),
  2968. inst.unsignedFlag)),
  2969. (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src),
  2970. inst.immediateType:$imm))>;
  2971. def : Pat<(inst.VTI.Vec !con((inst.pred_int (inst.VTI.Vec MQPR:$src),
  2972. inst.immediateType:$imm),
  2973. inst.unsignedFlag,
  2974. (? (inst.VTI.Pred VCCR:$mask),
  2975. (inst.VTI.Vec MQPR:$inactive)))),
  2976. (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src),
  2977. inst.immediateType:$imm,
  2978. ARMVCCThen, (inst.VTI.Pred VCCR:$mask), zero_reg,
  2979. (inst.VTI.Vec MQPR:$inactive)))>;
  2980. }
  2981. defm : MVE_shift_imm_patterns<MVE_VQSHLimms8>;
  2982. defm : MVE_shift_imm_patterns<MVE_VQSHLimmu8>;
  2983. defm : MVE_shift_imm_patterns<MVE_VQSHLimms16>;
  2984. defm : MVE_shift_imm_patterns<MVE_VQSHLimmu16>;
  2985. defm : MVE_shift_imm_patterns<MVE_VQSHLimms32>;
  2986. defm : MVE_shift_imm_patterns<MVE_VQSHLimmu32>;
  2987. defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms8>;
  2988. defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms16>;
  2989. defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms32>;
  2990. defm : MVE_shift_imm_patterns<MVE_VRSHR_imms8>;
  2991. defm : MVE_shift_imm_patterns<MVE_VRSHR_immu8>;
  2992. defm : MVE_shift_imm_patterns<MVE_VRSHR_imms16>;
  2993. defm : MVE_shift_imm_patterns<MVE_VRSHR_immu16>;
  2994. defm : MVE_shift_imm_patterns<MVE_VRSHR_imms32>;
  2995. defm : MVE_shift_imm_patterns<MVE_VRSHR_immu32>;
  2996. class MVE_VSHR_imm<string suffix, dag imm, bits<2> vecsize>
  2997. : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd),
  2998. !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
  2999. vpred_r, "", vecsize> {
  3000. bits<6> imm;
  3001. let Inst{25-24} = 0b11;
  3002. let Inst{21-16} = imm;
  3003. let Inst{10-8} = 0b000;
  3004. }
  3005. def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm), 0b00> {
  3006. let Inst{28} = 0b0;
  3007. let Inst{21-19} = 0b001;
  3008. }
  3009. def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm), 0b00> {
  3010. let Inst{28} = 0b1;
  3011. let Inst{21-19} = 0b001;
  3012. }
  3013. def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm), 0b01> {
  3014. let Inst{28} = 0b0;
  3015. let Inst{21-20} = 0b01;
  3016. }
  3017. def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm), 0b01> {
  3018. let Inst{28} = 0b1;
  3019. let Inst{21-20} = 0b01;
  3020. }
  3021. def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm), 0b10> {
  3022. let Inst{28} = 0b0;
  3023. let Inst{21} = 0b1;
  3024. }
  3025. def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm), 0b10> {
  3026. let Inst{28} = 0b1;
  3027. let Inst{21} = 0b1;
  3028. }
  3029. class MVE_VSHL_imm<string suffix, dag imm, bits<2> vecsize>
  3030. : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd),
  3031. !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
  3032. vpred_r, "", vecsize> {
  3033. bits<6> imm;
  3034. let Inst{28} = 0b0;
  3035. let Inst{25-24} = 0b11;
  3036. let Inst{21-16} = imm;
  3037. let Inst{10-8} = 0b101;
  3038. }
  3039. def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm), 0b00> {
  3040. let Inst{21-19} = 0b001;
  3041. }
  3042. def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm), 0b01> {
  3043. let Inst{21-20} = 0b01;
  3044. }
  3045. def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm), 0b10> {
  3046. let Inst{21} = 0b1;
  3047. }
  3048. multiclass MVE_immediate_shift_patterns_inner<
  3049. MVEVectorVTInfo VTI, Operand imm_operand_type, SDNode unpred_op,
  3050. Intrinsic pred_int, Instruction inst, list<int> unsignedFlag = []> {
  3051. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src), imm_operand_type:$imm)),
  3052. (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm))>;
  3053. def : Pat<(VTI.Vec !con((pred_int (VTI.Vec MQPR:$src), imm_operand_type:$imm),
  3054. !dag(pred_int, unsignedFlag, ?),
  3055. (pred_int (VTI.Pred VCCR:$mask),
  3056. (VTI.Vec MQPR:$inactive)))),
  3057. (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm,
  3058. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  3059. (VTI.Vec MQPR:$inactive)))>;
  3060. }
  3061. multiclass MVE_immediate_shift_patterns<MVEVectorVTInfo VTI,
  3062. Operand imm_operand_type> {
  3063. defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
  3064. ARMvshlImm, int_arm_mve_shl_imm_predicated,
  3065. !cast<Instruction>("MVE_VSHL_immi" # VTI.BitsSuffix)>;
  3066. defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
  3067. ARMvshruImm, int_arm_mve_shr_imm_predicated,
  3068. !cast<Instruction>("MVE_VSHR_immu" # VTI.BitsSuffix), [1]>;
  3069. defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
  3070. ARMvshrsImm, int_arm_mve_shr_imm_predicated,
  3071. !cast<Instruction>("MVE_VSHR_imms" # VTI.BitsSuffix), [0]>;
  3072. }
  3073. let Predicates = [HasMVEInt] in {
  3074. defm : MVE_immediate_shift_patterns<MVE_v16i8, imm0_7>;
  3075. defm : MVE_immediate_shift_patterns<MVE_v8i16, imm0_15>;
  3076. defm : MVE_immediate_shift_patterns<MVE_v4i32, imm0_31>;
  3077. }
  3078. // end of mve_shift instructions
  3079. // start of MVE Floating Point instructions
  3080. class MVE_float<string iname, string suffix, dag oops, dag iops, string ops,
  3081. vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  3082. : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  3083. bits<4> Qm;
  3084. let Inst{12} = 0b0;
  3085. let Inst{6} = 0b1;
  3086. let Inst{5} = Qm{3};
  3087. let Inst{3-1} = Qm{2-0};
  3088. let Inst{0} = 0b0;
  3089. }
  3090. class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size,
  3091. list<dag> pattern=[]>
  3092. : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd),
  3093. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3094. bits<4> Qd;
  3095. let Inst{28} = 0b1;
  3096. let Inst{25-23} = 0b111;
  3097. let Inst{22} = Qd{3};
  3098. let Inst{21-20} = 0b11;
  3099. let Inst{19-18} = size;
  3100. let Inst{17-16} = 0b10;
  3101. let Inst{15-13} = Qd{2-0};
  3102. let Inst{11-10} = 0b01;
  3103. let Inst{9-7} = op{2-0};
  3104. let Inst{4} = 0b0;
  3105. let validForTailPredication = 1;
  3106. }
  3107. multiclass MVE_VRINT_m<MVEVectorVTInfo VTI, string suffix, bits<3> opcode,
  3108. SDPatternOperator unpred_op> {
  3109. def "": MVE_VRINT<suffix, opcode, VTI.Suffix, VTI.Size>;
  3110. defvar Inst = !cast<Instruction>(NAME);
  3111. defvar pred_int = !cast<Intrinsic>("int_arm_mve_vrint"#suffix#"_predicated");
  3112. let Predicates = [HasMVEFloat] in {
  3113. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))),
  3114. (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>;
  3115. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred),
  3116. (VTI.Vec MQPR:$inactive))),
  3117. (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen,
  3118. (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
  3119. }
  3120. }
  3121. multiclass MVE_VRINT_ops<MVEVectorVTInfo VTI> {
  3122. defm N : MVE_VRINT_m<VTI, "n", 0b000, int_arm_mve_vrintn>;
  3123. defm X : MVE_VRINT_m<VTI, "x", 0b001, frint>;
  3124. defm A : MVE_VRINT_m<VTI, "a", 0b010, fround>;
  3125. defm Z : MVE_VRINT_m<VTI, "z", 0b011, ftrunc>;
  3126. defm M : MVE_VRINT_m<VTI, "m", 0b101, ffloor>;
  3127. defm P : MVE_VRINT_m<VTI, "p", 0b111, fceil>;
  3128. }
  3129. defm MVE_VRINTf16 : MVE_VRINT_ops<MVE_v8f16>;
  3130. defm MVE_VRINTf32 : MVE_VRINT_ops<MVE_v4f32>;
  3131. class MVEFloatArithNeon<string iname, string suffix, bit size,
  3132. dag oops, dag iops, string ops,
  3133. vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  3134. : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, vecsize, pattern> {
  3135. let Inst{20} = size;
  3136. let Inst{16} = 0b0;
  3137. }
  3138. class MVE_VMUL_fp<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
  3139. : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd),
  3140. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "",
  3141. size, pattern> {
  3142. bits<4> Qd;
  3143. bits<4> Qn;
  3144. let Inst{28} = 0b1;
  3145. let Inst{25-23} = 0b110;
  3146. let Inst{22} = Qd{3};
  3147. let Inst{21} = 0b0;
  3148. let Inst{19-17} = Qn{2-0};
  3149. let Inst{15-13} = Qd{2-0};
  3150. let Inst{12-8} = 0b01101;
  3151. let Inst{7} = Qn{3};
  3152. let Inst{4} = 0b1;
  3153. let validForTailPredication = 1;
  3154. }
  3155. multiclass MVE_VMULT_fp_m<string iname, MVEVectorVTInfo VTI, SDNode Op,
  3156. Intrinsic PredInt, SDPatternOperator IdentityVec> {
  3157. def "" : MVE_VMUL_fp<iname, VTI.Suffix, VTI.Size>;
  3158. defvar Inst = !cast<Instruction>(NAME);
  3159. let Predicates = [HasMVEFloat] in {
  3160. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>;
  3161. }
  3162. }
  3163. multiclass MVE_VMUL_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
  3164. : MVE_VMULT_fp_m<"vmul", VTI, fmul, int_arm_mve_mul_predicated, IdentityVec>;
  3165. def ARMimmOneF: PatLeaf<(bitconvert (v4f32 (ARMvmovFPImm (i32 112))))>; // 1.0 float
  3166. def ARMimmOneH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2620))))>; // 1.0 half
  3167. defm MVE_VMULf32 : MVE_VMUL_fp_m<MVE_v4f32, ARMimmOneF>;
  3168. defm MVE_VMULf16 : MVE_VMUL_fp_m<MVE_v8f16, ARMimmOneH>;
  3169. class MVE_VCMLA<string suffix, bits<2> size>
  3170. : MVEFloatArithNeon<"vcmla", suffix, size{1}, (outs MQPR:$Qd),
  3171. (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
  3172. "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src", size, []> {
  3173. bits<4> Qd;
  3174. bits<4> Qn;
  3175. bits<2> rot;
  3176. let Inst{28} = 0b1;
  3177. let Inst{25} = 0b0;
  3178. let Inst{24-23} = rot;
  3179. let Inst{22} = Qd{3};
  3180. let Inst{21} = 0b1;
  3181. let Inst{19-17} = Qn{2-0};
  3182. let Inst{15-13} = Qd{2-0};
  3183. let Inst{12-8} = 0b01000;
  3184. let Inst{7} = Qn{3};
  3185. let Inst{4} = 0b0;
  3186. }
  3187. multiclass MVE_VCMLA_m<MVEVectorVTInfo VTI> {
  3188. def "" : MVE_VCMLA<VTI.Suffix, VTI.Size>;
  3189. defvar Inst = !cast<Instruction>(NAME);
  3190. let Predicates = [HasMVEFloat] in {
  3191. def : Pat<(VTI.Vec (int_arm_mve_vcmlaq
  3192. imm:$rot, (VTI.Vec MQPR:$Qd_src),
  3193. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  3194. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  3195. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3196. imm:$rot))>;
  3197. def : Pat<(VTI.Vec (int_arm_mve_vcmlaq_predicated
  3198. imm:$rot, (VTI.Vec MQPR:$Qd_src),
  3199. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3200. (VTI.Pred VCCR:$mask))),
  3201. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qn),
  3202. (VTI.Vec MQPR:$Qm), imm:$rot,
  3203. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  3204. }
  3205. }
  3206. defm MVE_VCMLAf16 : MVE_VCMLA_m<MVE_v8f16>;
  3207. defm MVE_VCMLAf32 : MVE_VCMLA_m<MVE_v4f32>;
  3208. class MVE_VADDSUBFMA_fp<string iname, string suffix, bits<2> size, bit bit_4,
  3209. bit bit_8, bit bit_21, dag iops=(ins),
  3210. vpred_ops vpred=vpred_r, string cstr="",
  3211. list<dag> pattern=[]>
  3212. : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd),
  3213. !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm",
  3214. vpred, cstr, size, pattern> {
  3215. bits<4> Qd;
  3216. bits<4> Qn;
  3217. let Inst{28} = 0b0;
  3218. let Inst{25-23} = 0b110;
  3219. let Inst{22} = Qd{3};
  3220. let Inst{21} = bit_21;
  3221. let Inst{19-17} = Qn{2-0};
  3222. let Inst{15-13} = Qd{2-0};
  3223. let Inst{11-9} = 0b110;
  3224. let Inst{8} = bit_8;
  3225. let Inst{7} = Qn{3};
  3226. let Inst{4} = bit_4;
  3227. let validForTailPredication = 1;
  3228. }
  3229. multiclass MVE_VFMA_fp_multi<string iname, bit fms, MVEVectorVTInfo VTI> {
  3230. def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0b1, 0b0, fms,
  3231. (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
  3232. defvar Inst = !cast<Instruction>(NAME);
  3233. defvar pred_int = int_arm_mve_fma_predicated;
  3234. defvar m1 = (VTI.Vec MQPR:$m1);
  3235. defvar m2 = (VTI.Vec MQPR:$m2);
  3236. defvar add = (VTI.Vec MQPR:$add);
  3237. defvar pred = (VTI.Pred VCCR:$pred);
  3238. let Predicates = [HasMVEFloat] in {
  3239. if fms then {
  3240. def : Pat<(VTI.Vec (fma (fneg m1), m2, add)),
  3241. (Inst $add, $m1, $m2)>;
  3242. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  3243. (VTI.Vec (fma (fneg m1), m2, add)),
  3244. add)),
  3245. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3246. def : Pat<(VTI.Vec (pred_int (fneg m1), m2, add, pred)),
  3247. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3248. def : Pat<(VTI.Vec (pred_int m1, (fneg m2), add, pred)),
  3249. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3250. } else {
  3251. def : Pat<(VTI.Vec (fma m1, m2, add)),
  3252. (Inst $add, $m1, $m2)>;
  3253. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  3254. (VTI.Vec (fma m1, m2, add)),
  3255. add)),
  3256. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3257. def : Pat<(VTI.Vec (pred_int m1, m2, add, pred)),
  3258. (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
  3259. }
  3260. }
  3261. }
  3262. defm MVE_VFMAf32 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v4f32>;
  3263. defm MVE_VFMAf16 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v8f16>;
  3264. defm MVE_VFMSf32 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v4f32>;
  3265. defm MVE_VFMSf16 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v8f16>;
  3266. multiclass MVE_VADDSUB_fp_m<string iname, bit bit_21, MVEVectorVTInfo VTI,
  3267. SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> {
  3268. def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0, 1, bit_21> {
  3269. let validForTailPredication = 1;
  3270. }
  3271. defvar Inst = !cast<Instruction>(NAME);
  3272. let Predicates = [HasMVEFloat] in {
  3273. defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>;
  3274. }
  3275. }
  3276. multiclass MVE_VADD_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
  3277. : MVE_VADDSUB_fp_m<"vadd", 0, VTI, fadd, int_arm_mve_add_predicated, IdentityVec>;
  3278. multiclass MVE_VSUB_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
  3279. : MVE_VADDSUB_fp_m<"vsub", 1, VTI, fsub, int_arm_mve_sub_predicated, IdentityVec>;
  3280. def ARMimmMinusZeroF: PatLeaf<(bitconvert (v4i32 (ARMvmovImm (i32 1664))))>; // -0.0 float
  3281. def ARMimmMinusZeroH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2688))))>; // -0.0 half
  3282. defm MVE_VADDf32 : MVE_VADD_fp_m<MVE_v4f32, ARMimmMinusZeroF>;
  3283. defm MVE_VADDf16 : MVE_VADD_fp_m<MVE_v8f16, ARMimmMinusZeroH>;
  3284. defm MVE_VSUBf32 : MVE_VSUB_fp_m<MVE_v4f32, ARMimmAllZerosV>;
  3285. defm MVE_VSUBf16 : MVE_VSUB_fp_m<MVE_v8f16, ARMimmAllZerosV>;
  3286. class MVE_VCADD<string suffix, bits<2> size, string cstr="">
  3287. : MVEFloatArithNeon<"vcadd", suffix, size{1}, (outs MQPR:$Qd),
  3288. (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
  3289. "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> {
  3290. bits<4> Qd;
  3291. bits<4> Qn;
  3292. bit rot;
  3293. let Inst{28} = 0b1;
  3294. let Inst{25} = 0b0;
  3295. let Inst{24} = rot;
  3296. let Inst{23} = 0b1;
  3297. let Inst{22} = Qd{3};
  3298. let Inst{21} = 0b0;
  3299. let Inst{19-17} = Qn{2-0};
  3300. let Inst{15-13} = Qd{2-0};
  3301. let Inst{12-8} = 0b01000;
  3302. let Inst{7} = Qn{3};
  3303. let Inst{4} = 0b0;
  3304. }
  3305. multiclass MVE_VCADD_m<MVEVectorVTInfo VTI, string cstr=""> {
  3306. def "" : MVE_VCADD<VTI.Suffix, VTI.Size, cstr>;
  3307. defvar Inst = !cast<Instruction>(NAME);
  3308. let Predicates = [HasMVEFloat] in {
  3309. def : Pat<(VTI.Vec (int_arm_mve_vcaddq (i32 1),
  3310. imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  3311. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3312. imm:$rot))>;
  3313. def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated (i32 1),
  3314. imm:$rot, (VTI.Vec MQPR:$inactive),
  3315. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3316. (VTI.Pred VCCR:$mask))),
  3317. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  3318. imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  3319. (VTI.Vec MQPR:$inactive)))>;
  3320. }
  3321. }
  3322. defm MVE_VCADDf16 : MVE_VCADD_m<MVE_v8f16>;
  3323. defm MVE_VCADDf32 : MVE_VCADD_m<MVE_v4f32, "@earlyclobber $Qd">;
  3324. class MVE_VABD_fp<string suffix, bits<2> size>
  3325. : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
  3326. "$Qd, $Qn, $Qm", vpred_r, "", size> {
  3327. bits<4> Qd;
  3328. bits<4> Qn;
  3329. let Inst{28} = 0b1;
  3330. let Inst{25-23} = 0b110;
  3331. let Inst{22} = Qd{3};
  3332. let Inst{21} = 0b1;
  3333. let Inst{20} = size{0};
  3334. let Inst{19-17} = Qn{2-0};
  3335. let Inst{16} = 0b0;
  3336. let Inst{15-13} = Qd{2-0};
  3337. let Inst{11-8} = 0b1101;
  3338. let Inst{7} = Qn{3};
  3339. let Inst{4} = 0b0;
  3340. let validForTailPredication = 1;
  3341. }
  3342. multiclass MVE_VABDT_fp_m<MVEVectorVTInfo VTI,
  3343. Intrinsic unpred_int, Intrinsic pred_int> {
  3344. def "" : MVE_VABD_fp<VTI.Suffix, VTI.Size>;
  3345. defvar Inst = !cast<Instruction>(NAME);
  3346. let Predicates = [HasMVEFloat] in {
  3347. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  3348. (i32 0))),
  3349. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  3350. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  3351. (i32 0), (VTI.Pred VCCR:$mask),
  3352. (VTI.Vec MQPR:$inactive))),
  3353. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  3354. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  3355. (VTI.Vec MQPR:$inactive)))>;
  3356. }
  3357. }
  3358. multiclass MVE_VABD_fp_m<MVEVectorVTInfo VTI>
  3359. : MVE_VABDT_fp_m<VTI, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
  3360. defm MVE_VABDf32 : MVE_VABD_fp_m<MVE_v4f32>;
  3361. defm MVE_VABDf16 : MVE_VABD_fp_m<MVE_v8f16>;
  3362. let Predicates = [HasMVEFloat] in {
  3363. def : Pat<(v8f16 (fabs (fsub (v8f16 MQPR:$Qm), (v8f16 MQPR:$Qn)))),
  3364. (MVE_VABDf16 MQPR:$Qm, MQPR:$Qn)>;
  3365. def : Pat<(v4f32 (fabs (fsub (v4f32 MQPR:$Qm), (v4f32 MQPR:$Qn)))),
  3366. (MVE_VABDf32 MQPR:$Qm, MQPR:$Qn)>;
  3367. }
  3368. class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op,
  3369. Operand imm_operand_type>
  3370. : MVE_float<"vcvt", suffix,
  3371. (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6),
  3372. "$Qd, $Qm, $imm6", vpred_r, "", !if(fsi, 0b10, 0b01), []> {
  3373. bits<4> Qd;
  3374. bits<6> imm6;
  3375. let Inst{28} = U;
  3376. let Inst{25-23} = 0b111;
  3377. let Inst{22} = Qd{3};
  3378. let Inst{21} = 0b1;
  3379. let Inst{19-16} = imm6{3-0};
  3380. let Inst{15-13} = Qd{2-0};
  3381. let Inst{11-10} = 0b11;
  3382. let Inst{9} = fsi;
  3383. let Inst{8} = op;
  3384. let Inst{7} = 0b0;
  3385. let Inst{4} = 0b1;
  3386. let DecoderMethod = "DecodeMVEVCVTt1fp";
  3387. let validForTailPredication = 1;
  3388. }
  3389. class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass {
  3390. let PredicateMethod = "isImmediate<1," # Bits # ">";
  3391. let DiagnosticString =
  3392. "MVE fixed-point immediate operand must be between 1 and " # Bits;
  3393. let Name = "MVEVcvtImm" # Bits;
  3394. let RenderMethod = "addImmOperands";
  3395. }
  3396. class MVE_VCVT_imm<int Bits>: Operand<i32> {
  3397. let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>;
  3398. let EncoderMethod = "getNEONVcvtImm32OpValue";
  3399. let DecoderMethod = "DecodeVCVTImmOperand";
  3400. }
  3401. class MVE_VCVT_fix_f32<string suffix, bit U, bit op>
  3402. : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> {
  3403. let Inst{20} = imm6{4};
  3404. }
  3405. class MVE_VCVT_fix_f16<string suffix, bit U, bit op>
  3406. : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> {
  3407. let Inst{20} = 0b1;
  3408. }
  3409. multiclass MVE_VCVT_fix_patterns<Instruction Inst, bit U, MVEVectorVTInfo DestVTI,
  3410. MVEVectorVTInfo SrcVTI> {
  3411. let Predicates = [HasMVEFloat] in {
  3412. def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix
  3413. (i32 U), (SrcVTI.Vec MQPR:$Qm), imm:$scale)),
  3414. (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale))>;
  3415. def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix_predicated (i32 U),
  3416. (DestVTI.Vec MQPR:$inactive),
  3417. (SrcVTI.Vec MQPR:$Qm),
  3418. imm:$scale,
  3419. (DestVTI.Pred VCCR:$mask))),
  3420. (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale,
  3421. ARMVCCThen, (DestVTI.Pred VCCR:$mask), zero_reg,
  3422. (DestVTI.Vec MQPR:$inactive)))>;
  3423. }
  3424. }
  3425. multiclass MVE_VCVT_fix_f32_m<bit U, bit op,
  3426. MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> {
  3427. def "" : MVE_VCVT_fix_f32<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>;
  3428. defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>;
  3429. }
  3430. multiclass MVE_VCVT_fix_f16_m<bit U, bit op,
  3431. MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> {
  3432. def "" : MVE_VCVT_fix_f16<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>;
  3433. defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>;
  3434. }
  3435. defm MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16_m<0b0, 0b0, MVE_v8f16, MVE_v8s16>;
  3436. defm MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16_m<0b0, 0b1, MVE_v8s16, MVE_v8f16>;
  3437. defm MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16_m<0b1, 0b0, MVE_v8f16, MVE_v8u16>;
  3438. defm MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16_m<0b1, 0b1, MVE_v8u16, MVE_v8f16>;
  3439. defm MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32_m<0b0, 0b0, MVE_v4f32, MVE_v4s32>;
  3440. defm MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32_m<0b0, 0b1, MVE_v4s32, MVE_v4f32>;
  3441. defm MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32_m<0b1, 0b0, MVE_v4f32, MVE_v4u32>;
  3442. defm MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32_m<0b1, 0b1, MVE_v4u32, MVE_v4f32>;
  3443. class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm,
  3444. bits<2> rm, list<dag> pattern=[]>
  3445. : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd),
  3446. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3447. bits<4> Qd;
  3448. let Inst{28} = 0b1;
  3449. let Inst{25-23} = 0b111;
  3450. let Inst{22} = Qd{3};
  3451. let Inst{21-20} = 0b11;
  3452. let Inst{19-18} = size;
  3453. let Inst{17-16} = 0b11;
  3454. let Inst{15-13} = Qd{2-0};
  3455. let Inst{12-10} = 0b000;
  3456. let Inst{9-8} = rm;
  3457. let Inst{7} = op;
  3458. let Inst{4} = 0b0;
  3459. let validForTailPredication = 1;
  3460. }
  3461. multiclass MVE_VCVT_fp_int_anpm_inner<MVEVectorVTInfo Int, MVEVectorVTInfo Flt,
  3462. string anpm, bits<2> rm> {
  3463. def "": MVE_VCVT_fp_int_anpm<Int.Suffix # "." # Flt.Suffix, Int.Size,
  3464. Int.Unsigned, anpm, rm>;
  3465. defvar Inst = !cast<Instruction>(NAME);
  3466. defvar IntrBaseName = "int_arm_mve_vcvt" # anpm;
  3467. defvar UnpredIntr = !cast<Intrinsic>(IntrBaseName);
  3468. defvar PredIntr = !cast<Intrinsic>(IntrBaseName # "_predicated");
  3469. let Predicates = [HasMVEFloat] in {
  3470. def : Pat<(Int.Vec (UnpredIntr (i32 Int.Unsigned), (Flt.Vec MQPR:$in))),
  3471. (Int.Vec (Inst (Flt.Vec MQPR:$in)))>;
  3472. def : Pat<(Int.Vec (PredIntr (i32 Int.Unsigned), (Int.Vec MQPR:$inactive),
  3473. (Flt.Vec MQPR:$in), (Flt.Pred VCCR:$pred))),
  3474. (Int.Vec (Inst (Flt.Vec MQPR:$in), ARMVCCThen,
  3475. (Flt.Pred VCCR:$pred), zero_reg, (Int.Vec MQPR:$inactive)))>;
  3476. }
  3477. }
  3478. multiclass MVE_VCVT_fp_int_anpm_outer<MVEVectorVTInfo Int,
  3479. MVEVectorVTInfo Flt> {
  3480. defm a : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "a", 0b00>;
  3481. defm n : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "n", 0b01>;
  3482. defm p : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "p", 0b10>;
  3483. defm m : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "m", 0b11>;
  3484. }
  3485. // This defines instructions such as MVE_VCVTu16f16a, with an explicit
  3486. // rounding-mode suffix on the mnemonic. The class below will define
  3487. // the bare MVE_VCVTu16f16 (with implied rounding toward zero).
  3488. defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8s16, MVE_v8f16>;
  3489. defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8u16, MVE_v8f16>;
  3490. defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4s32, MVE_v4f32>;
  3491. defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4u32, MVE_v4f32>;
  3492. class MVE_VCVT_fp_int<string suffix, bits<2> size, bit toint, bit unsigned,
  3493. list<dag> pattern=[]>
  3494. : MVE_float<"vcvt", suffix, (outs MQPR:$Qd),
  3495. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3496. bits<4> Qd;
  3497. let Inst{28} = 0b1;
  3498. let Inst{25-23} = 0b111;
  3499. let Inst{22} = Qd{3};
  3500. let Inst{21-20} = 0b11;
  3501. let Inst{19-18} = size;
  3502. let Inst{17-16} = 0b11;
  3503. let Inst{15-13} = Qd{2-0};
  3504. let Inst{12-9} = 0b0011;
  3505. let Inst{8} = toint;
  3506. let Inst{7} = unsigned;
  3507. let Inst{4} = 0b0;
  3508. let validForTailPredication = 1;
  3509. }
  3510. multiclass MVE_VCVT_fp_int_m<MVEVectorVTInfo Dest, MVEVectorVTInfo Src,
  3511. SDNode unpred_op> {
  3512. defvar Unsigned = !or(!eq(Dest.SuffixLetter,"u"), !eq(Src.SuffixLetter,"u"));
  3513. defvar ToInt = !eq(Src.SuffixLetter,"f");
  3514. def "" : MVE_VCVT_fp_int<Dest.Suffix # "." # Src.Suffix, Dest.Size,
  3515. ToInt, Unsigned>;
  3516. defvar Inst = !cast<Instruction>(NAME);
  3517. let Predicates = [HasMVEFloat] in {
  3518. def : Pat<(Dest.Vec (unpred_op (Src.Vec MQPR:$src))),
  3519. (Dest.Vec (Inst (Src.Vec MQPR:$src)))>;
  3520. def : Pat<(Dest.Vec (int_arm_mve_vcvt_fp_int_predicated
  3521. (Src.Vec MQPR:$src), (i32 Unsigned),
  3522. (Src.Pred VCCR:$mask), (Dest.Vec MQPR:$inactive))),
  3523. (Dest.Vec (Inst (Src.Vec MQPR:$src), ARMVCCThen,
  3524. (Src.Pred VCCR:$mask), zero_reg,
  3525. (Dest.Vec MQPR:$inactive)))>;
  3526. }
  3527. }
  3528. // The unsuffixed VCVT for float->int implicitly rounds toward zero,
  3529. // which I reflect here in the llvm instruction names
  3530. defm MVE_VCVTs16f16z : MVE_VCVT_fp_int_m<MVE_v8s16, MVE_v8f16, fp_to_sint>;
  3531. defm MVE_VCVTu16f16z : MVE_VCVT_fp_int_m<MVE_v8u16, MVE_v8f16, fp_to_uint>;
  3532. defm MVE_VCVTs32f32z : MVE_VCVT_fp_int_m<MVE_v4s32, MVE_v4f32, fp_to_sint>;
  3533. defm MVE_VCVTu32f32z : MVE_VCVT_fp_int_m<MVE_v4u32, MVE_v4f32, fp_to_uint>;
  3534. // Whereas VCVT for int->float rounds to nearest
  3535. defm MVE_VCVTf16s16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8s16, sint_to_fp>;
  3536. defm MVE_VCVTf16u16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8u16, uint_to_fp>;
  3537. defm MVE_VCVTf32s32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4s32, sint_to_fp>;
  3538. defm MVE_VCVTf32u32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4u32, uint_to_fp>;
  3539. let Predicates = [HasMVEFloat] in {
  3540. def : Pat<(v4i32 (fp_to_sint_sat v4f32:$src, i32)),
  3541. (MVE_VCVTs32f32z v4f32:$src)>;
  3542. def : Pat<(v4i32 (fp_to_uint_sat v4f32:$src, i32)),
  3543. (MVE_VCVTu32f32z v4f32:$src)>;
  3544. def : Pat<(v8i16 (fp_to_sint_sat v8f16:$src, i16)),
  3545. (MVE_VCVTs16f16z v8f16:$src)>;
  3546. def : Pat<(v8i16 (fp_to_uint_sat v8f16:$src, i16)),
  3547. (MVE_VCVTu16f16z v8f16:$src)>;
  3548. }
  3549. class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate,
  3550. list<dag> pattern=[]>
  3551. : MVE_float<iname, suffix, (outs MQPR:$Qd),
  3552. (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
  3553. bits<4> Qd;
  3554. let Inst{28} = 0b1;
  3555. let Inst{25-23} = 0b111;
  3556. let Inst{22} = Qd{3};
  3557. let Inst{21-20} = 0b11;
  3558. let Inst{19-18} = size;
  3559. let Inst{17-16} = 0b01;
  3560. let Inst{15-13} = Qd{2-0};
  3561. let Inst{11-8} = 0b0111;
  3562. let Inst{7} = negate;
  3563. let Inst{4} = 0b0;
  3564. let validForTailPredication = 1;
  3565. }
  3566. multiclass MVE_VABSNEG_fp_m<string iname, SDNode unpred_op, Intrinsic pred_int,
  3567. MVEVectorVTInfo VTI, bit opcode> {
  3568. def "" : MVE_VABSNEG_fp<iname, VTI.Suffix, VTI.Size, opcode>;
  3569. defvar Inst = !cast<Instruction>(NAME);
  3570. let Predicates = [HasMVEInt] in {
  3571. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))),
  3572. (VTI.Vec (Inst $v))>;
  3573. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask),
  3574. (VTI.Vec MQPR:$inactive))),
  3575. (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>;
  3576. }
  3577. }
  3578. defm MVE_VABSf16 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated,
  3579. MVE_v8f16, 0>;
  3580. defm MVE_VABSf32 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated,
  3581. MVE_v4f32, 0>;
  3582. defm MVE_VNEGf16 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated,
  3583. MVE_v8f16, 1>;
  3584. defm MVE_VNEGf32 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated,
  3585. MVE_v4f32, 1>;
  3586. class MVE_VMAXMINNMA<string iname, string suffix, bits<2> size, bit bit_12,
  3587. list<dag> pattern=[]>
  3588. : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
  3589. NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
  3590. size, pattern> {
  3591. bits<4> Qd;
  3592. bits<4> Qm;
  3593. let Inst{28} = size{0};
  3594. let Inst{25-23} = 0b100;
  3595. let Inst{22} = Qd{3};
  3596. let Inst{21-16} = 0b111111;
  3597. let Inst{15-13} = Qd{2-0};
  3598. let Inst{12} = bit_12;
  3599. let Inst{11-6} = 0b111010;
  3600. let Inst{5} = Qm{3};
  3601. let Inst{4} = 0b0;
  3602. let Inst{3-1} = Qm{2-0};
  3603. let Inst{0} = 0b1;
  3604. let isCommutable = 1;
  3605. let validForTailPredication = 1;
  3606. }
  3607. multiclass MVE_VMAXMINNMA_m<string iname, MVEVectorVTInfo VTI,
  3608. SDNode unpred_op, Intrinsic pred_int,
  3609. bit bit_12> {
  3610. def "" : MVE_VMAXMINNMA<iname, VTI.Suffix, VTI.Size, bit_12>;
  3611. defvar Inst = !cast<Instruction>(NAME);
  3612. let Predicates = [HasMVEInt] in {
  3613. // Unpredicated v(max|min)nma
  3614. def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
  3615. (fabs (VTI.Vec MQPR:$Qm)))),
  3616. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
  3617. // Predicated v(max|min)nma
  3618. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  3619. (VTI.Pred VCCR:$mask))),
  3620. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
  3621. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  3622. }
  3623. }
  3624. multiclass MVE_VMAXNMA<MVEVectorVTInfo VTI, bit bit_12>
  3625. : MVE_VMAXMINNMA_m<"vmaxnma", VTI, fmaxnum, int_arm_mve_vmaxnma_predicated, bit_12>;
  3626. defm MVE_VMAXNMAf32 : MVE_VMAXNMA<MVE_v4f32, 0b0>;
  3627. defm MVE_VMAXNMAf16 : MVE_VMAXNMA<MVE_v8f16, 0b0>;
  3628. multiclass MVE_VMINNMA<MVEVectorVTInfo VTI, bit bit_12>
  3629. : MVE_VMAXMINNMA_m<"vminnma", VTI, fminnum, int_arm_mve_vminnma_predicated, bit_12>;
  3630. defm MVE_VMINNMAf32 : MVE_VMINNMA<MVE_v4f32, 0b1>;
  3631. defm MVE_VMINNMAf16 : MVE_VMINNMA<MVE_v8f16, 0b1>;
  3632. // end of MVE Floating Point instructions
  3633. // start of MVE compares
  3634. class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
  3635. VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
  3636. : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc),
  3637. NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", vecsize, pattern> {
  3638. // Base class for comparing two vector registers
  3639. bits<3> fc;
  3640. bits<4> Qn;
  3641. bits<4> Qm;
  3642. let Inst{28} = bit_28;
  3643. let Inst{25-22} = 0b1000;
  3644. let Inst{21-20} = bits_21_20;
  3645. let Inst{19-17} = Qn{2-0};
  3646. let Inst{16-13} = 0b1000;
  3647. let Inst{12} = fc{2};
  3648. let Inst{11-8} = 0b1111;
  3649. let Inst{7} = fc{0};
  3650. let Inst{6} = 0b0;
  3651. let Inst{5} = Qm{3};
  3652. let Inst{4} = 0b0;
  3653. let Inst{3-1} = Qm{2-0};
  3654. let Inst{0} = fc{1};
  3655. let Constraints = "";
  3656. // We need a custom decoder method for these instructions because of
  3657. // the output VCCR operand, which isn't encoded in the instruction
  3658. // bits anywhere (there is only one choice for it) but has to be
  3659. // included in the MC operands so that codegen will be able to track
  3660. // its data flow between instructions, spill/reload it when
  3661. // necessary, etc. There seems to be no way to get the Tablegen
  3662. // decoder to emit an operand that isn't affected by any instruction
  3663. // bit.
  3664. let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">";
  3665. let validForTailPredication = 1;
  3666. }
  3667. class MVE_VCMPqqf<string suffix, bit size>
  3668. : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> {
  3669. let Predicates = [HasMVEFloat];
  3670. }
  3671. class MVE_VCMPqqi<string suffix, bits<2> size>
  3672. : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i, size> {
  3673. let Inst{12} = 0b0;
  3674. let Inst{0} = 0b0;
  3675. }
  3676. class MVE_VCMPqqu<string suffix, bits<2> size>
  3677. : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u, size> {
  3678. let Inst{12} = 0b0;
  3679. let Inst{0} = 0b1;
  3680. }
  3681. class MVE_VCMPqqs<string suffix, bits<2> size>
  3682. : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s, size> {
  3683. let Inst{12} = 0b1;
  3684. }
  3685. def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>;
  3686. def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>;
  3687. def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>;
  3688. def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>;
  3689. def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>;
  3690. def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>;
  3691. def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>;
  3692. def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>;
  3693. def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>;
  3694. def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>;
  3695. def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>;
  3696. class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
  3697. VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
  3698. : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc),
  3699. NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", vecsize, pattern> {
  3700. // Base class for comparing a vector register with a scalar
  3701. bits<3> fc;
  3702. bits<4> Qn;
  3703. bits<4> Rm;
  3704. let Inst{28} = bit_28;
  3705. let Inst{25-22} = 0b1000;
  3706. let Inst{21-20} = bits_21_20;
  3707. let Inst{19-17} = Qn{2-0};
  3708. let Inst{16-13} = 0b1000;
  3709. let Inst{12} = fc{2};
  3710. let Inst{11-8} = 0b1111;
  3711. let Inst{7} = fc{0};
  3712. let Inst{6} = 0b1;
  3713. let Inst{5} = fc{1};
  3714. let Inst{4} = 0b0;
  3715. let Inst{3-0} = Rm{3-0};
  3716. let Constraints = "";
  3717. // Custom decoder method, for the same reason as MVE_VCMPqq
  3718. let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">";
  3719. let validForTailPredication = 1;
  3720. }
  3721. class MVE_VCMPqrf<string suffix, bit size>
  3722. : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> {
  3723. let Predicates = [HasMVEFloat];
  3724. }
  3725. class MVE_VCMPqri<string suffix, bits<2> size>
  3726. : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i, size> {
  3727. let Inst{12} = 0b0;
  3728. let Inst{5} = 0b0;
  3729. }
  3730. class MVE_VCMPqru<string suffix, bits<2> size>
  3731. : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u, size> {
  3732. let Inst{12} = 0b0;
  3733. let Inst{5} = 0b1;
  3734. }
  3735. class MVE_VCMPqrs<string suffix, bits<2> size>
  3736. : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s, size> {
  3737. let Inst{12} = 0b1;
  3738. }
  3739. def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>;
  3740. def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>;
  3741. def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>;
  3742. def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>;
  3743. def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>;
  3744. def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>;
  3745. def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>;
  3746. def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>;
  3747. def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>;
  3748. def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>;
  3749. def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>;
  3750. multiclass unpred_vcmp_z<string suffix, PatLeaf fc> {
  3751. def i8 : Pat<(v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)),
  3752. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>;
  3753. def i16 : Pat<(v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)),
  3754. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>;
  3755. def i32 : Pat<(v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)),
  3756. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>;
  3757. def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)))),
  3758. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3759. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)))),
  3760. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3761. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)))),
  3762. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3763. }
  3764. multiclass unpred_vcmp_r<string suffix, PatLeaf fc> {
  3765. def i8 : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)),
  3766. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>;
  3767. def i16 : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)),
  3768. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>;
  3769. def i32 : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)),
  3770. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>;
  3771. def i8r : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)),
  3772. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3773. def i16r : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)),
  3774. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3775. def i32r : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)),
  3776. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3777. def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)))),
  3778. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3779. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)))),
  3780. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3781. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)))),
  3782. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3783. def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)))),
  3784. (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3785. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)))),
  3786. (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3787. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)))),
  3788. (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3789. }
  3790. multiclass unpred_vcmpf_z<PatLeaf fc> {
  3791. def f16 : Pat<(v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)),
  3792. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>;
  3793. def f32 : Pat<(v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)),
  3794. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>;
  3795. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)))),
  3796. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3797. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)))),
  3798. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3799. }
  3800. multiclass unpred_vcmpf_r<PatLeaf fc> {
  3801. def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)),
  3802. (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>;
  3803. def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)),
  3804. (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>;
  3805. def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)),
  3806. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3807. def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)),
  3808. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc))>;
  3809. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)))),
  3810. (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3811. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)))),
  3812. (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3813. def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)))),
  3814. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3815. def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)))),
  3816. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
  3817. }
  3818. let Predicates = [HasMVEInt] in {
  3819. defm MVE_VCEQZ : unpred_vcmp_z<"i", ARMCCeq>;
  3820. defm MVE_VCNEZ : unpred_vcmp_z<"i", ARMCCne>;
  3821. defm MVE_VCGEZ : unpred_vcmp_z<"s", ARMCCge>;
  3822. defm MVE_VCLTZ : unpred_vcmp_z<"s", ARMCClt>;
  3823. defm MVE_VCGTZ : unpred_vcmp_z<"s", ARMCCgt>;
  3824. defm MVE_VCLEZ : unpred_vcmp_z<"s", ARMCCle>;
  3825. defm MVE_VCGTUZ : unpred_vcmp_z<"u", ARMCChi>;
  3826. defm MVE_VCGEUZ : unpred_vcmp_z<"u", ARMCChs>;
  3827. defm MVE_VCEQ : unpred_vcmp_r<"i", ARMCCeq>;
  3828. defm MVE_VCNE : unpred_vcmp_r<"i", ARMCCne>;
  3829. defm MVE_VCGE : unpred_vcmp_r<"s", ARMCCge>;
  3830. defm MVE_VCLT : unpred_vcmp_r<"s", ARMCClt>;
  3831. defm MVE_VCGT : unpred_vcmp_r<"s", ARMCCgt>;
  3832. defm MVE_VCLE : unpred_vcmp_r<"s", ARMCCle>;
  3833. defm MVE_VCGTU : unpred_vcmp_r<"u", ARMCChi>;
  3834. defm MVE_VCGEU : unpred_vcmp_r<"u", ARMCChs>;
  3835. }
  3836. let Predicates = [HasMVEFloat] in {
  3837. defm MVE_VFCEQZ : unpred_vcmpf_z<ARMCCeq>;
  3838. defm MVE_VFCNEZ : unpred_vcmpf_z<ARMCCne>;
  3839. defm MVE_VFCGEZ : unpred_vcmpf_z<ARMCCge>;
  3840. defm MVE_VFCLTZ : unpred_vcmpf_z<ARMCClt>;
  3841. defm MVE_VFCGTZ : unpred_vcmpf_z<ARMCCgt>;
  3842. defm MVE_VFCLEZ : unpred_vcmpf_z<ARMCCle>;
  3843. defm MVE_VFCEQ : unpred_vcmpf_r<ARMCCeq>;
  3844. defm MVE_VFCNE : unpred_vcmpf_r<ARMCCne>;
  3845. defm MVE_VFCGE : unpred_vcmpf_r<ARMCCge>;
  3846. defm MVE_VFCLT : unpred_vcmpf_r<ARMCClt>;
  3847. defm MVE_VFCGT : unpred_vcmpf_r<ARMCCgt>;
  3848. defm MVE_VFCLE : unpred_vcmpf_r<ARMCCle>;
  3849. }
  3850. // Extra "worst case" and/or/xor patterns, going into and out of GRP
  3851. multiclass two_predops<SDPatternOperator opnode, Instruction insn> {
  3852. def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))),
  3853. (v16i1 (COPY_TO_REGCLASS
  3854. (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)),
  3855. (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))),
  3856. VCCR))>;
  3857. def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))),
  3858. (v8i1 (COPY_TO_REGCLASS
  3859. (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)),
  3860. (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))),
  3861. VCCR))>;
  3862. def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))),
  3863. (v4i1 (COPY_TO_REGCLASS
  3864. (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)),
  3865. (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))),
  3866. VCCR))>;
  3867. def v2i1 : Pat<(v2i1 (opnode (v2i1 VCCR:$p1), (v2i1 VCCR:$p2))),
  3868. (v2i1 (COPY_TO_REGCLASS
  3869. (insn (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p1), rGPR)),
  3870. (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p2), rGPR))),
  3871. VCCR))>;
  3872. }
  3873. let Predicates = [HasMVEInt] in {
  3874. defm POR : two_predops<or, t2ORRrr>;
  3875. defm PAND : two_predops<and, t2ANDrr>;
  3876. defm PEOR : two_predops<xor, t2EORrr>;
  3877. }
  3878. // Occasionally we need to cast between a i32 and a boolean vector, for
  3879. // example when moving between rGPR and VPR.P0 as part of predicate vector
  3880. // shuffles. We also sometimes need to cast between different predicate
  3881. // vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles.
  3882. def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>;
  3883. def load_align4 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  3884. return cast<LoadSDNode>(N)->getAlign() >= 4;
  3885. }]>;
  3886. let Predicates = [HasMVEInt] in {
  3887. foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in {
  3888. def : Pat<(i32 (predicate_cast (VT VCCR:$src))),
  3889. (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>;
  3890. def : Pat<(VT (predicate_cast (i32 VCCR:$src))),
  3891. (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>;
  3892. foreach VT2 = [ v2i1, v4i1, v8i1, v16i1 ] in
  3893. def : Pat<(VT (predicate_cast (VT2 VCCR:$src))),
  3894. (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>;
  3895. }
  3896. // If we happen to be casting from a load we can convert that straight
  3897. // into a predicate load, so long as the load is of the correct type.
  3898. foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in {
  3899. def : Pat<(VT (predicate_cast (i32 (load_align4 taddrmode_imm7<2>:$addr)))),
  3900. (VT (VLDR_P0_off taddrmode_imm7<2>:$addr))>;
  3901. }
  3902. // Here we match the specific SDNode type 'ARMVectorRegCastImpl'
  3903. // rather than the more general 'ARMVectorRegCast' which would also
  3904. // match some bitconverts. If we use the latter in cases where the
  3905. // input and output types are the same, the bitconvert gets elided
  3906. // and we end up generating a nonsense match of nothing.
  3907. foreach VT = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in
  3908. foreach VT2 = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in
  3909. def : Pat<(VT (ARMVectorRegCastImpl (VT2 MQPR:$src))),
  3910. (VT MQPR:$src)>;
  3911. }
  3912. // end of MVE compares
  3913. // start of MVE_qDest_qSrc
  3914. class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops,
  3915. string ops, vpred_ops vpred, string cstr,
  3916. bits<2> vecsize, list<dag> pattern=[]>
  3917. : MVE_p<oops, iops, NoItinerary, iname, suffix,
  3918. ops, vpred, cstr, vecsize, pattern> {
  3919. bits<4> Qd;
  3920. bits<4> Qm;
  3921. let Inst{25-23} = 0b100;
  3922. let Inst{22} = Qd{3};
  3923. let Inst{15-13} = Qd{2-0};
  3924. let Inst{11-9} = 0b111;
  3925. let Inst{6} = 0b0;
  3926. let Inst{5} = Qm{3};
  3927. let Inst{4} = 0b0;
  3928. let Inst{3-1} = Qm{2-0};
  3929. }
  3930. class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract,
  3931. string suffix, bits<2> size, string cstr="",
  3932. list<dag> pattern=[]>
  3933. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  3934. (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  3935. vpred_n, "$Qd = $Qd_src"#cstr, size, pattern> {
  3936. bits<4> Qn;
  3937. let Inst{28} = subtract;
  3938. let Inst{21-20} = size;
  3939. let Inst{19-17} = Qn{2-0};
  3940. let Inst{16} = 0b0;
  3941. let Inst{12} = exch;
  3942. let Inst{8} = 0b0;
  3943. let Inst{7} = Qn{3};
  3944. let Inst{0} = round;
  3945. }
  3946. multiclass MVE_VQxDMLxDH_p<string iname, bit exch, bit round, bit subtract,
  3947. MVEVectorVTInfo VTI> {
  3948. def "": MVE_VQxDMLxDH<iname, exch, round, subtract, VTI.Suffix, VTI.Size,
  3949. !if(!eq(VTI.LaneBits, 32), ",@earlyclobber $Qd", "")>;
  3950. defvar Inst = !cast<Instruction>(NAME);
  3951. defvar ConstParams = (? (i32 exch), (i32 round), (i32 subtract));
  3952. defvar unpred_intr = int_arm_mve_vqdmlad;
  3953. defvar pred_intr = int_arm_mve_vqdmlad_predicated;
  3954. def : Pat<(VTI.Vec !con((unpred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3955. (VTI.Vec MQPR:$c)), ConstParams)),
  3956. (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3957. (VTI.Vec MQPR:$c)))>;
  3958. def : Pat<(VTI.Vec !con((pred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3959. (VTI.Vec MQPR:$c)), ConstParams,
  3960. (? (VTI.Pred VCCR:$pred)))),
  3961. (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
  3962. (VTI.Vec MQPR:$c),
  3963. ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>;
  3964. }
  3965. multiclass MVE_VQxDMLxDH_multi<string iname, bit exch,
  3966. bit round, bit subtract> {
  3967. defm s8 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v16s8>;
  3968. defm s16 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v8s16>;
  3969. defm s32 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v4s32>;
  3970. }
  3971. defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>;
  3972. defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>;
  3973. defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>;
  3974. defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>;
  3975. defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>;
  3976. defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>;
  3977. defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>;
  3978. defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>;
  3979. class MVE_VCMUL<string iname, string suffix, bits<2> size, string cstr="">
  3980. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  3981. (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
  3982. "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size,
  3983. []> {
  3984. bits<4> Qn;
  3985. bits<2> rot;
  3986. let Inst{28} = size{1};
  3987. let Inst{21-20} = 0b11;
  3988. let Inst{19-17} = Qn{2-0};
  3989. let Inst{16} = 0b0;
  3990. let Inst{12} = rot{1};
  3991. let Inst{8} = 0b0;
  3992. let Inst{7} = Qn{3};
  3993. let Inst{0} = rot{0};
  3994. let Predicates = [HasMVEFloat];
  3995. }
  3996. multiclass MVE_VCMUL_m<string iname, MVEVectorVTInfo VTI,
  3997. string cstr=""> {
  3998. def "" : MVE_VCMUL<iname, VTI.Suffix, VTI.Size, cstr>;
  3999. defvar Inst = !cast<Instruction>(NAME);
  4000. let Predicates = [HasMVEFloat] in {
  4001. def : Pat<(VTI.Vec (int_arm_mve_vcmulq
  4002. imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  4003. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4004. imm:$rot))>;
  4005. def : Pat<(VTI.Vec (int_arm_mve_vcmulq_predicated
  4006. imm:$rot, (VTI.Vec MQPR:$inactive),
  4007. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4008. (VTI.Pred VCCR:$mask))),
  4009. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4010. imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4011. (VTI.Vec MQPR:$inactive)))>;
  4012. }
  4013. }
  4014. defm MVE_VCMULf16 : MVE_VCMUL_m<"vcmul", MVE_v8f16>;
  4015. defm MVE_VCMULf32 : MVE_VCMUL_m<"vcmul", MVE_v4f32, "@earlyclobber $Qd">;
  4016. class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20,
  4017. bit T, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  4018. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4019. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  4020. vpred_r, cstr, vecsize, pattern> {
  4021. bits<4> Qd;
  4022. bits<4> Qn;
  4023. bits<4> Qm;
  4024. let Inst{28} = bit_28;
  4025. let Inst{21-20} = bits_21_20;
  4026. let Inst{19-17} = Qn{2-0};
  4027. let Inst{16} = 0b1;
  4028. let Inst{12} = T;
  4029. let Inst{8} = 0b0;
  4030. let Inst{7} = Qn{3};
  4031. let Inst{0} = 0b0;
  4032. let validForTailPredication = 1;
  4033. let doubleWidthResult = 1;
  4034. }
  4035. multiclass MVE_VMULL_m<MVEVectorVTInfo VTI,
  4036. SDPatternOperator unpred_op, Intrinsic pred_int,
  4037. bit Top, bits<2> vecsize, string cstr=""> {
  4038. def "" : MVE_VMULL<"vmull" # !if(Top, "t", "b"), VTI.Suffix, VTI.Unsigned,
  4039. VTI.Size, Top, cstr, vecsize>;
  4040. defvar Inst = !cast<Instruction>(NAME);
  4041. let Predicates = [HasMVEInt] in {
  4042. defvar uflag = !if(!eq(VTI.SuffixLetter, "p"), (?), (? (i32 VTI.Unsigned)));
  4043. // Unpredicated multiply
  4044. def : Pat<(VTI.DblVec !con((unpred_op (VTI.Vec MQPR:$Qm),
  4045. (VTI.Vec MQPR:$Qn)),
  4046. uflag, (? (i32 Top)))),
  4047. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  4048. // Predicated multiply
  4049. def : Pat<(VTI.DblVec !con((pred_int (VTI.Vec MQPR:$Qm),
  4050. (VTI.Vec MQPR:$Qn)),
  4051. uflag, (? (i32 Top), (VTI.DblPred VCCR:$mask),
  4052. (VTI.DblVec MQPR:$inactive)))),
  4053. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4054. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  4055. (VTI.DblVec MQPR:$inactive)))>;
  4056. }
  4057. }
  4058. // For polynomial multiplies, the size bits take the unused value 0b11, and
  4059. // the unsigned bit switches to encoding the size.
  4060. defm MVE_VMULLBs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull,
  4061. int_arm_mve_mull_int_predicated, 0b0, 0b01>;
  4062. defm MVE_VMULLTs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull,
  4063. int_arm_mve_mull_int_predicated, 0b1, 0b01>;
  4064. defm MVE_VMULLBs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull,
  4065. int_arm_mve_mull_int_predicated, 0b0, 0b10>;
  4066. defm MVE_VMULLTs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull,
  4067. int_arm_mve_mull_int_predicated, 0b1, 0b10>;
  4068. defm MVE_VMULLBs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull,
  4069. int_arm_mve_mull_int_predicated, 0b0, 0b11,
  4070. "@earlyclobber $Qd">;
  4071. defm MVE_VMULLTs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull,
  4072. int_arm_mve_mull_int_predicated, 0b1, 0b11,
  4073. "@earlyclobber $Qd">;
  4074. defm MVE_VMULLBu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull,
  4075. int_arm_mve_mull_int_predicated, 0b0, 0b01>;
  4076. defm MVE_VMULLTu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull,
  4077. int_arm_mve_mull_int_predicated, 0b1, 0b01>;
  4078. defm MVE_VMULLBu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull,
  4079. int_arm_mve_mull_int_predicated, 0b0, 0b10>;
  4080. defm MVE_VMULLTu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull,
  4081. int_arm_mve_mull_int_predicated, 0b1, 0b10>;
  4082. defm MVE_VMULLBu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull,
  4083. int_arm_mve_mull_int_predicated, 0b0, 0b11,
  4084. "@earlyclobber $Qd">;
  4085. defm MVE_VMULLTu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull,
  4086. int_arm_mve_mull_int_predicated, 0b1, 0b11,
  4087. "@earlyclobber $Qd">;
  4088. defm MVE_VMULLBp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly,
  4089. int_arm_mve_mull_poly_predicated, 0b0, 0b01>;
  4090. defm MVE_VMULLTp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly,
  4091. int_arm_mve_mull_poly_predicated, 0b1, 0b01>;
  4092. defm MVE_VMULLBp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly,
  4093. int_arm_mve_mull_poly_predicated, 0b0, 0b10>;
  4094. defm MVE_VMULLTp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly,
  4095. int_arm_mve_mull_poly_predicated, 0b1, 0b10>;
  4096. let Predicates = [HasMVEInt] in {
  4097. def : Pat<(v2i64 (ARMvmulls (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))),
  4098. (MVE_VMULLBs32 MQPR:$src1, MQPR:$src2)>;
  4099. def : Pat<(v2i64 (ARMvmulls (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))),
  4100. (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))),
  4101. (MVE_VMULLTs32 MQPR:$src1, MQPR:$src2)>;
  4102. def : Pat<(mul (sext_inreg (v4i32 MQPR:$src1), v4i16),
  4103. (sext_inreg (v4i32 MQPR:$src2), v4i16)),
  4104. (MVE_VMULLBs16 MQPR:$src1, MQPR:$src2)>;
  4105. def : Pat<(mul (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))), v4i16),
  4106. (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))), v4i16)),
  4107. (MVE_VMULLTs16 MQPR:$src1, MQPR:$src2)>;
  4108. def : Pat<(mul (sext_inreg (v8i16 MQPR:$src1), v8i8),
  4109. (sext_inreg (v8i16 MQPR:$src2), v8i8)),
  4110. (MVE_VMULLBs8 MQPR:$src1, MQPR:$src2)>;
  4111. def : Pat<(mul (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), v8i8),
  4112. (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), v8i8)),
  4113. (MVE_VMULLTs8 MQPR:$src1, MQPR:$src2)>;
  4114. def : Pat<(v2i64 (ARMvmullu (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))),
  4115. (MVE_VMULLBu32 MQPR:$src1, MQPR:$src2)>;
  4116. def : Pat<(v2i64 (ARMvmullu (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))),
  4117. (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))),
  4118. (MVE_VMULLTu32 MQPR:$src1, MQPR:$src2)>;
  4119. def : Pat<(mul (and (v4i32 MQPR:$src1), (v4i32 (ARMvmovImm (i32 0xCFF)))),
  4120. (and (v4i32 MQPR:$src2), (v4i32 (ARMvmovImm (i32 0xCFF))))),
  4121. (MVE_VMULLBu16 MQPR:$src1, MQPR:$src2)>;
  4122. def : Pat<(mul (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))),
  4123. (v4i32 (ARMvmovImm (i32 0xCFF)))),
  4124. (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))),
  4125. (v4i32 (ARMvmovImm (i32 0xCFF))))),
  4126. (MVE_VMULLTu16 MQPR:$src1, MQPR:$src2)>;
  4127. def : Pat<(mul (ARMvbicImm (v8i16 MQPR:$src1), (i32 0xAFF)),
  4128. (ARMvbicImm (v8i16 MQPR:$src2), (i32 0xAFF))),
  4129. (MVE_VMULLBu8 MQPR:$src1, MQPR:$src2)>;
  4130. def : Pat<(mul (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), (i32 0xAFF)),
  4131. (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), (i32 0xAFF))),
  4132. (MVE_VMULLTu8 MQPR:$src1, MQPR:$src2)>;
  4133. }
  4134. class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size, bit round,
  4135. list<dag> pattern=[]>
  4136. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4137. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  4138. vpred_r, "", size, pattern> {
  4139. bits<4> Qn;
  4140. let Inst{28} = U;
  4141. let Inst{21-20} = size;
  4142. let Inst{19-17} = Qn{2-0};
  4143. let Inst{16} = 0b1;
  4144. let Inst{12} = round;
  4145. let Inst{8} = 0b0;
  4146. let Inst{7} = Qn{3};
  4147. let Inst{0} = 0b1;
  4148. let validForTailPredication = 1;
  4149. }
  4150. multiclass MVE_VxMULH_m<string iname, MVEVectorVTInfo VTI, SDNode unpred_op,
  4151. Intrinsic PredInt, bit round> {
  4152. def "" : MVE_VxMULH<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, round>;
  4153. defvar Inst = !cast<Instruction>(NAME);
  4154. let Predicates = [HasMVEInt] in {
  4155. if !eq(round, 0b0) then {
  4156. defvar mulh = !if(VTI.Unsigned, mulhu, mulhs);
  4157. defm : MVE_TwoOpPattern<VTI, mulh, PredInt, (? (i32 VTI.Unsigned)),
  4158. !cast<Instruction>(NAME)>;
  4159. } else {
  4160. // Predicated multiply returning high bits
  4161. def : Pat<(VTI.Vec (PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4162. (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
  4163. (VTI.Vec MQPR:$inactive))),
  4164. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4165. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4166. (VTI.Vec MQPR:$inactive)))>;
  4167. }
  4168. // Unpredicated intrinsic
  4169. def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4170. (i32 VTI.Unsigned))),
  4171. (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  4172. }
  4173. }
  4174. multiclass MVE_VMULT<string iname, MVEVectorVTInfo VTI, bit round>
  4175. : MVE_VxMULH_m<iname, VTI, !if(round, int_arm_mve_vrmulh, int_arm_mve_vmulh),
  4176. !if(round, int_arm_mve_rmulh_predicated,
  4177. int_arm_mve_mulh_predicated),
  4178. round>;
  4179. defm MVE_VMULHs8 : MVE_VMULT<"vmulh", MVE_v16s8, 0b0>;
  4180. defm MVE_VMULHs16 : MVE_VMULT<"vmulh", MVE_v8s16, 0b0>;
  4181. defm MVE_VMULHs32 : MVE_VMULT<"vmulh", MVE_v4s32, 0b0>;
  4182. defm MVE_VMULHu8 : MVE_VMULT<"vmulh", MVE_v16u8, 0b0>;
  4183. defm MVE_VMULHu16 : MVE_VMULT<"vmulh", MVE_v8u16, 0b0>;
  4184. defm MVE_VMULHu32 : MVE_VMULT<"vmulh", MVE_v4u32, 0b0>;
  4185. defm MVE_VRMULHs8 : MVE_VMULT<"vrmulh", MVE_v16s8, 0b1>;
  4186. defm MVE_VRMULHs16 : MVE_VMULT<"vrmulh", MVE_v8s16, 0b1>;
  4187. defm MVE_VRMULHs32 : MVE_VMULT<"vrmulh", MVE_v4s32, 0b1>;
  4188. defm MVE_VRMULHu8 : MVE_VMULT<"vrmulh", MVE_v16u8, 0b1>;
  4189. defm MVE_VRMULHu16 : MVE_VMULT<"vrmulh", MVE_v8u16, 0b1>;
  4190. defm MVE_VRMULHu32 : MVE_VMULT<"vrmulh", MVE_v4u32, 0b1>;
  4191. class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17,
  4192. bits<2> size, bit T, list<dag> pattern=[]>
  4193. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4194. (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm",
  4195. vpred_n, "$Qd = $Qd_src", !if(size, 0b10, 0b01), pattern> {
  4196. let Inst{28} = bit_28;
  4197. let Inst{21-20} = 0b11;
  4198. let Inst{19-18} = size;
  4199. let Inst{17} = bit_17;
  4200. let Inst{16} = 0b1;
  4201. let Inst{12} = T;
  4202. let Inst{8} = 0b0;
  4203. let Inst{7} = !not(bit_17);
  4204. let Inst{0} = 0b1;
  4205. let validForTailPredication = 1;
  4206. let retainsPreviousHalfElement = 1;
  4207. }
  4208. multiclass MVE_VxMOVxN_halves<string iname, string suffix,
  4209. bit bit_28, bit bit_17, bits<2> size> {
  4210. def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>;
  4211. def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>;
  4212. }
  4213. defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>;
  4214. defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>;
  4215. defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>;
  4216. defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>;
  4217. defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>;
  4218. defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>;
  4219. defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>;
  4220. defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>;
  4221. def MVEvmovn : SDNode<"ARMISD::VMOVN", SDTARMVEXT>;
  4222. multiclass MVE_VMOVN_p<Instruction Inst, bit top,
  4223. MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> {
  4224. // Match the most obvious MVEvmovn(a,b,t), which overwrites the odd or even
  4225. // lanes of a (depending on t) with the even lanes of b.
  4226. def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qd_src),
  4227. (VTI.Vec MQPR:$Qm), (i32 top))),
  4228. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>;
  4229. if !not(top) then {
  4230. // If we see MVEvmovn(a,ARMvrev(b),1), that wants to overwrite the odd
  4231. // lanes of a with the odd lanes of b. In other words, the lanes we're
  4232. // _keeping_ from a are the even ones. So we can flip it round and say that
  4233. // this is the same as overwriting the even lanes of b with the even lanes
  4234. // of a, i.e. it's a VMOVNB with the operands reversed.
  4235. defvar vrev = !cast<SDNode>("ARMvrev" # InVTI.LaneBits);
  4236. def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qm),
  4237. (VTI.Vec (vrev MQPR:$Qd_src)), (i32 1))),
  4238. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>;
  4239. }
  4240. // Match the IR intrinsic for a predicated VMOVN. This regards the Qm input
  4241. // as having wider lanes that we're narrowing, instead of already-narrow
  4242. // lanes that we're taking every other one of.
  4243. def : Pat<(VTI.Vec (int_arm_mve_vmovn_predicated (VTI.Vec MQPR:$Qd_src),
  4244. (InVTI.Vec MQPR:$Qm), (i32 top),
  4245. (InVTI.Pred VCCR:$pred))),
  4246. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  4247. (InVTI.Vec MQPR:$Qm),
  4248. ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>;
  4249. }
  4250. defm : MVE_VMOVN_p<MVE_VMOVNi32bh, 0, MVE_v8i16, MVE_v4i32>;
  4251. defm : MVE_VMOVN_p<MVE_VMOVNi32th, 1, MVE_v8i16, MVE_v4i32>;
  4252. defm : MVE_VMOVN_p<MVE_VMOVNi16bh, 0, MVE_v16i8, MVE_v8i16>;
  4253. defm : MVE_VMOVN_p<MVE_VMOVNi16th, 1, MVE_v16i8, MVE_v8i16>;
  4254. multiclass MVE_VQMOVN_p<Instruction Inst, bit outU, bit inU, bit top,
  4255. MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> {
  4256. def : Pat<(VTI.Vec (int_arm_mve_vqmovn (VTI.Vec MQPR:$Qd_src),
  4257. (InVTI.Vec MQPR:$Qm),
  4258. (i32 outU), (i32 inU), (i32 top))),
  4259. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  4260. (InVTI.Vec MQPR:$Qm)))>;
  4261. def : Pat<(VTI.Vec (int_arm_mve_vqmovn_predicated (VTI.Vec MQPR:$Qd_src),
  4262. (InVTI.Vec MQPR:$Qm),
  4263. (i32 outU), (i32 inU), (i32 top),
  4264. (InVTI.Pred VCCR:$pred))),
  4265. (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
  4266. (InVTI.Vec MQPR:$Qm),
  4267. ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>;
  4268. }
  4269. defm : MVE_VQMOVN_p<MVE_VQMOVNs32bh, 0, 0, 0, MVE_v8i16, MVE_v4i32>;
  4270. defm : MVE_VQMOVN_p<MVE_VQMOVNs32th, 0, 0, 1, MVE_v8i16, MVE_v4i32>;
  4271. defm : MVE_VQMOVN_p<MVE_VQMOVNs16bh, 0, 0, 0, MVE_v16i8, MVE_v8i16>;
  4272. defm : MVE_VQMOVN_p<MVE_VQMOVNs16th, 0, 0, 1, MVE_v16i8, MVE_v8i16>;
  4273. defm : MVE_VQMOVN_p<MVE_VQMOVNu32bh, 1, 1, 0, MVE_v8i16, MVE_v4i32>;
  4274. defm : MVE_VQMOVN_p<MVE_VQMOVNu32th, 1, 1, 1, MVE_v8i16, MVE_v4i32>;
  4275. defm : MVE_VQMOVN_p<MVE_VQMOVNu16bh, 1, 1, 0, MVE_v16i8, MVE_v8i16>;
  4276. defm : MVE_VQMOVN_p<MVE_VQMOVNu16th, 1, 1, 1, MVE_v16i8, MVE_v8i16>;
  4277. defm : MVE_VQMOVN_p<MVE_VQMOVUNs32bh, 1, 0, 0, MVE_v8i16, MVE_v4i32>;
  4278. defm : MVE_VQMOVN_p<MVE_VQMOVUNs32th, 1, 0, 1, MVE_v8i16, MVE_v4i32>;
  4279. defm : MVE_VQMOVN_p<MVE_VQMOVUNs16bh, 1, 0, 0, MVE_v16i8, MVE_v8i16>;
  4280. defm : MVE_VQMOVN_p<MVE_VQMOVUNs16th, 1, 0, 1, MVE_v16i8, MVE_v8i16>;
  4281. def SDTARMVMOVNQ : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0, 1>,
  4282. SDTCisVec<2>, SDTCisVT<3, i32>]>;
  4283. def MVEvqmovns : SDNode<"ARMISD::VQMOVNs", SDTARMVMOVNQ>;
  4284. def MVEvqmovnu : SDNode<"ARMISD::VQMOVNu", SDTARMVMOVNQ>;
  4285. let Predicates = [HasMVEInt] in {
  4286. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))),
  4287. (v8i16 (MVE_VQMOVNs32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4288. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))),
  4289. (v8i16 (MVE_VQMOVNs32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4290. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))),
  4291. (v16i8 (MVE_VQMOVNs16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4292. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))),
  4293. (v16i8 (MVE_VQMOVNs16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4294. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))),
  4295. (v8i16 (MVE_VQMOVNu32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4296. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))),
  4297. (v8i16 (MVE_VQMOVNu32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
  4298. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))),
  4299. (v16i8 (MVE_VQMOVNu16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4300. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))),
  4301. (v16i8 (MVE_VQMOVNu16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
  4302. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))),
  4303. (v8i16 (MVE_VQSHRNbhs32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4304. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))),
  4305. (v16i8 (MVE_VQSHRNbhs16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4306. def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))),
  4307. (v8i16 (MVE_VQSHRNths32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4308. def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))),
  4309. (v16i8 (MVE_VQSHRNths16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4310. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))),
  4311. (v8i16 (MVE_VQSHRNbhu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4312. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))),
  4313. (v16i8 (MVE_VQSHRNbhu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4314. def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))),
  4315. (v8i16 (MVE_VQSHRNthu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
  4316. def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))),
  4317. (v16i8 (MVE_VQSHRNthu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
  4318. }
  4319. class MVE_VCVT_ff<string iname, string suffix, bit op, bit T,
  4320. dag iops_extra, vpred_ops vpred, string cstr>
  4321. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4322. !con(iops_extra, (ins MQPR:$Qm)), "$Qd, $Qm",
  4323. vpred, cstr, 0b10, []> {
  4324. let Inst{28} = op;
  4325. let Inst{21-16} = 0b111111;
  4326. let Inst{12} = T;
  4327. let Inst{8-7} = 0b00;
  4328. let Inst{0} = 0b1;
  4329. let Predicates = [HasMVEFloat];
  4330. let retainsPreviousHalfElement = 1;
  4331. }
  4332. def SDTARMVCVTL : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
  4333. SDTCisVT<2, i32>]>;
  4334. def MVEvcvtn : SDNode<"ARMISD::VCVTN", SDTARMVMOVNQ>;
  4335. def MVEvcvtl : SDNode<"ARMISD::VCVTL", SDTARMVCVTL>;
  4336. multiclass MVE_VCVT_f2h_m<string iname, int half> {
  4337. def "": MVE_VCVT_ff<iname, "f16.f32", 0b0, half,
  4338. (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
  4339. defvar Inst = !cast<Instruction>(NAME);
  4340. let Predicates = [HasMVEFloat] in {
  4341. def : Pat<(v8f16 (int_arm_mve_vcvt_narrow
  4342. (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))),
  4343. (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>;
  4344. def : Pat<(v8f16 (int_arm_mve_vcvt_narrow_predicated
  4345. (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half),
  4346. (v4i1 VCCR:$mask))),
  4347. (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm),
  4348. ARMVCCThen, (v4i1 VCCR:$mask), zero_reg))>;
  4349. def : Pat<(v8f16 (MVEvcvtn (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))),
  4350. (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>;
  4351. }
  4352. }
  4353. multiclass MVE_VCVT_h2f_m<string iname, int half> {
  4354. def "": MVE_VCVT_ff<iname, "f32.f16", 0b1, half, (ins), vpred_r, "">;
  4355. defvar Inst = !cast<Instruction>(NAME);
  4356. let Predicates = [HasMVEFloat] in {
  4357. def : Pat<(v4f32 (int_arm_mve_vcvt_widen (v8f16 MQPR:$Qm), (i32 half))),
  4358. (v4f32 (Inst (v8f16 MQPR:$Qm)))>;
  4359. def : Pat<(v4f32 (int_arm_mve_vcvt_widen_predicated
  4360. (v4f32 MQPR:$inactive), (v8f16 MQPR:$Qm), (i32 half),
  4361. (v4i1 VCCR:$mask))),
  4362. (v4f32 (Inst (v8f16 MQPR:$Qm), ARMVCCThen,
  4363. (v4i1 VCCR:$mask), zero_reg, (v4f32 MQPR:$inactive)))>;
  4364. def : Pat<(v4f32 (MVEvcvtl (v8f16 MQPR:$Qm), (i32 half))),
  4365. (v4f32 (Inst (v8f16 MQPR:$Qm)))>;
  4366. }
  4367. }
  4368. defm MVE_VCVTf16f32bh : MVE_VCVT_f2h_m<"vcvtb", 0b0>;
  4369. defm MVE_VCVTf16f32th : MVE_VCVT_f2h_m<"vcvtt", 0b1>;
  4370. defm MVE_VCVTf32f16bh : MVE_VCVT_h2f_m<"vcvtb", 0b0>;
  4371. defm MVE_VCVTf32f16th : MVE_VCVT_h2f_m<"vcvtt", 0b1>;
  4372. class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve,
  4373. string cstr="">
  4374. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4375. (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
  4376. "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> {
  4377. bits<4> Qn;
  4378. bit rot;
  4379. let Inst{28} = halve;
  4380. let Inst{21-20} = size;
  4381. let Inst{19-17} = Qn{2-0};
  4382. let Inst{16} = 0b0;
  4383. let Inst{12} = rot;
  4384. let Inst{8} = 0b1;
  4385. let Inst{7} = Qn{3};
  4386. let Inst{0} = 0b0;
  4387. }
  4388. multiclass MVE_VxCADD_m<string iname, MVEVectorVTInfo VTI,
  4389. bit halve, string cstr=""> {
  4390. def "" : MVE_VxCADD<iname, VTI.Suffix, VTI.Size, halve, cstr>;
  4391. defvar Inst = !cast<Instruction>(NAME);
  4392. let Predicates = [HasMVEInt] in {
  4393. def : Pat<(VTI.Vec (int_arm_mve_vcaddq halve,
  4394. imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
  4395. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4396. imm:$rot))>;
  4397. def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated halve,
  4398. imm:$rot, (VTI.Vec MQPR:$inactive),
  4399. (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4400. (VTI.Pred VCCR:$mask))),
  4401. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
  4402. imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4403. (VTI.Vec MQPR:$inactive)))>;
  4404. }
  4405. }
  4406. defm MVE_VCADDi8 : MVE_VxCADD_m<"vcadd", MVE_v16i8, 0b1>;
  4407. defm MVE_VCADDi16 : MVE_VxCADD_m<"vcadd", MVE_v8i16, 0b1>;
  4408. defm MVE_VCADDi32 : MVE_VxCADD_m<"vcadd", MVE_v4i32, 0b1, "@earlyclobber $Qd">;
  4409. defm MVE_VHCADDs8 : MVE_VxCADD_m<"vhcadd", MVE_v16s8, 0b0>;
  4410. defm MVE_VHCADDs16 : MVE_VxCADD_m<"vhcadd", MVE_v8s16, 0b0>;
  4411. defm MVE_VHCADDs32 : MVE_VxCADD_m<"vhcadd", MVE_v4s32, 0b0, "@earlyclobber $Qd">;
  4412. class MVE_VADCSBC<string iname, bit I, bit subtract,
  4413. dag carryin, list<dag> pattern=[]>
  4414. : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout),
  4415. !con((ins MQPR:$Qn, MQPR:$Qm), carryin),
  4416. "$Qd, $Qn, $Qm", vpred_r, "", 0b10, pattern> {
  4417. bits<4> Qn;
  4418. let Inst{28} = subtract;
  4419. let Inst{21-20} = 0b11;
  4420. let Inst{19-17} = Qn{2-0};
  4421. let Inst{16} = 0b0;
  4422. let Inst{12} = I;
  4423. let Inst{8} = 0b1;
  4424. let Inst{7} = Qn{3};
  4425. let Inst{0} = 0b0;
  4426. // Custom decoder method in order to add the FPSCR operand(s), which
  4427. // Tablegen won't do right
  4428. let DecoderMethod = "DecodeMVEVADCInstruction";
  4429. }
  4430. def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>;
  4431. def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>;
  4432. def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>;
  4433. def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>;
  4434. class MVE_VQDMULL<string iname, string suffix, bit size, bit T,
  4435. string cstr="", list<dag> pattern=[]>
  4436. : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
  4437. (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
  4438. vpred_r, cstr, !if(size, 0b10, 0b01), pattern> {
  4439. bits<4> Qn;
  4440. let Inst{28} = size;
  4441. let Inst{21-20} = 0b11;
  4442. let Inst{19-17} = Qn{2-0};
  4443. let Inst{16} = 0b0;
  4444. let Inst{12} = T;
  4445. let Inst{8} = 0b1;
  4446. let Inst{7} = Qn{3};
  4447. let Inst{0} = 0b1;
  4448. let validForTailPredication = 1;
  4449. let doubleWidthResult = 1;
  4450. }
  4451. multiclass MVE_VQDMULL_m<string iname, MVEVectorVTInfo VTI, bit size, bit T,
  4452. string cstr> {
  4453. def "" : MVE_VQDMULL<iname, VTI.Suffix, size, T, cstr>;
  4454. defvar Inst = !cast<Instruction>(NAME);
  4455. let Predicates = [HasMVEInt] in {
  4456. // Unpredicated saturating multiply
  4457. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm),
  4458. (VTI.Vec MQPR:$Qn), (i32 T))),
  4459. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
  4460. // Predicated saturating multiply
  4461. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated
  4462. (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4463. (i32 T), (VTI.DblPred VCCR:$mask),
  4464. (VTI.DblVec MQPR:$inactive))),
  4465. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
  4466. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  4467. (VTI.DblVec MQPR:$inactive)))>;
  4468. }
  4469. }
  4470. multiclass MVE_VQDMULL_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> {
  4471. defm bh : MVE_VQDMULL_m<"vqdmullb", VTI, size, 0b0, cstr>;
  4472. defm th : MVE_VQDMULL_m<"vqdmullt", VTI, size, 0b1, cstr>;
  4473. }
  4474. defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<MVE_v8s16, 0b0>;
  4475. defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">;
  4476. // end of mve_qDest_qSrc
  4477. // start of mve_qDest_rSrc
  4478. class MVE_qr_base<dag oops, dag iops, string iname, string suffix, string ops,
  4479. vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  4480. : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
  4481. bits<4> Qd;
  4482. bits<4> Qn;
  4483. bits<4> Rm;
  4484. let Inst{25-23} = 0b100;
  4485. let Inst{22} = Qd{3};
  4486. let Inst{19-17} = Qn{2-0};
  4487. let Inst{15-13} = Qd{2-0};
  4488. let Inst{11-9} = 0b111;
  4489. let Inst{7} = Qn{3};
  4490. let Inst{6} = 0b1;
  4491. let Inst{4} = 0b0;
  4492. let Inst{3-0} = Rm{3-0};
  4493. }
  4494. class MVE_qDest_rSrc<string iname, string suffix, string cstr="", bits<2> vecsize, list<dag> pattern=[]>
  4495. : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm),
  4496. iname, suffix, "$Qd, $Qn, $Rm", vpred_r, cstr,
  4497. vecsize, pattern>;
  4498. class MVE_qDestSrc_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]>
  4499. : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm),
  4500. iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src",
  4501. vecsize, pattern>;
  4502. class MVE_qDest_single_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]>
  4503. : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname,
  4504. suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", vecsize, pattern> {
  4505. bits<4> Qd;
  4506. bits<4> Rm;
  4507. let Inst{22} = Qd{3};
  4508. let Inst{15-13} = Qd{2-0};
  4509. let Inst{3-0} = Rm{3-0};
  4510. }
  4511. // Patterns for vector-scalar instructions with integer operands
  4512. multiclass MVE_vec_scalar_int_pat_m<Instruction inst, MVEVectorVTInfo VTI,
  4513. SDPatternOperator unpred_op,
  4514. SDPatternOperator pred_op,
  4515. bit unpred_has_sign = 0,
  4516. bit pred_has_sign = 0> {
  4517. defvar UnpredSign = !if(unpred_has_sign, (? (i32 VTI.Unsigned)), (?));
  4518. defvar PredSign = !if(pred_has_sign, (? (i32 VTI.Unsigned)), (?));
  4519. let Predicates = [HasMVEInt] in {
  4520. // Unpredicated version
  4521. def : Pat<(VTI.Vec !con((unpred_op (VTI.Vec MQPR:$Qm),
  4522. (VTI.Vec (ARMvdup rGPR:$val))),
  4523. UnpredSign)),
  4524. (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>;
  4525. // Predicated version
  4526. def : Pat<(VTI.Vec !con((pred_op (VTI.Vec MQPR:$Qm),
  4527. (VTI.Vec (ARMvdup rGPR:$val))),
  4528. PredSign,
  4529. (pred_op (VTI.Pred VCCR:$mask),
  4530. (VTI.Vec MQPR:$inactive)))),
  4531. (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val),
  4532. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4533. (VTI.Vec MQPR:$inactive)))>;
  4534. }
  4535. }
  4536. class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size,
  4537. bit bit_5, bit bit_12, bit bit_16, bit bit_28>
  4538. : MVE_qDest_rSrc<iname, suffix, "", size> {
  4539. let Inst{28} = bit_28;
  4540. let Inst{21-20} = size;
  4541. let Inst{16} = bit_16;
  4542. let Inst{12} = bit_12;
  4543. let Inst{8} = 0b1;
  4544. let Inst{5} = bit_5;
  4545. let validForTailPredication = 1;
  4546. }
  4547. // Vector-scalar add/sub
  4548. multiclass MVE_VADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract,
  4549. SDNode Op, Intrinsic PredInt> {
  4550. def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b0, subtract, 0b1, 0b0>;
  4551. let Predicates = [HasMVEInt] in {
  4552. defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>;
  4553. }
  4554. }
  4555. multiclass MVE_VADD_qr_m<MVEVectorVTInfo VTI>
  4556. : MVE_VADDSUB_qr_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>;
  4557. multiclass MVE_VSUB_qr_m<MVEVectorVTInfo VTI>
  4558. : MVE_VADDSUB_qr_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>;
  4559. defm MVE_VADD_qr_i8 : MVE_VADD_qr_m<MVE_v16i8>;
  4560. defm MVE_VADD_qr_i16 : MVE_VADD_qr_m<MVE_v8i16>;
  4561. defm MVE_VADD_qr_i32 : MVE_VADD_qr_m<MVE_v4i32>;
  4562. defm MVE_VSUB_qr_i8 : MVE_VSUB_qr_m<MVE_v16i8>;
  4563. defm MVE_VSUB_qr_i16 : MVE_VSUB_qr_m<MVE_v8i16>;
  4564. defm MVE_VSUB_qr_i32 : MVE_VSUB_qr_m<MVE_v4i32>;
  4565. // Vector-scalar saturating add/sub
  4566. multiclass MVE_VQADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract,
  4567. SDNode Op, Intrinsic PredInt> {
  4568. def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b1, subtract,
  4569. 0b0, VTI.Unsigned>;
  4570. let Predicates = [HasMVEInt] in {
  4571. defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
  4572. !cast<Instruction>(NAME)>;
  4573. }
  4574. }
  4575. multiclass MVE_VQADD_qr_m<MVEVectorVTInfo VTI, SDNode Op>
  4576. : MVE_VQADDSUB_qr_m<"vqadd", VTI, 0b0, Op, int_arm_mve_qadd_predicated>;
  4577. multiclass MVE_VQSUB_qr_m<MVEVectorVTInfo VTI, SDNode Op>
  4578. : MVE_VQADDSUB_qr_m<"vqsub", VTI, 0b1, Op, int_arm_mve_qsub_predicated>;
  4579. defm MVE_VQADD_qr_s8 : MVE_VQADD_qr_m<MVE_v16s8, saddsat>;
  4580. defm MVE_VQADD_qr_s16 : MVE_VQADD_qr_m<MVE_v8s16, saddsat>;
  4581. defm MVE_VQADD_qr_s32 : MVE_VQADD_qr_m<MVE_v4s32, saddsat>;
  4582. defm MVE_VQADD_qr_u8 : MVE_VQADD_qr_m<MVE_v16u8, uaddsat>;
  4583. defm MVE_VQADD_qr_u16 : MVE_VQADD_qr_m<MVE_v8u16, uaddsat>;
  4584. defm MVE_VQADD_qr_u32 : MVE_VQADD_qr_m<MVE_v4u32, uaddsat>;
  4585. defm MVE_VQSUB_qr_s8 : MVE_VQSUB_qr_m<MVE_v16s8, ssubsat>;
  4586. defm MVE_VQSUB_qr_s16 : MVE_VQSUB_qr_m<MVE_v8s16, ssubsat>;
  4587. defm MVE_VQSUB_qr_s32 : MVE_VQSUB_qr_m<MVE_v4s32, ssubsat>;
  4588. defm MVE_VQSUB_qr_u8 : MVE_VQSUB_qr_m<MVE_v16u8, usubsat>;
  4589. defm MVE_VQSUB_qr_u16 : MVE_VQSUB_qr_m<MVE_v8u16, usubsat>;
  4590. defm MVE_VQSUB_qr_u32 : MVE_VQSUB_qr_m<MVE_v4u32, usubsat>;
  4591. class MVE_VQDMULL_qr<string iname, string suffix, bit size,
  4592. bit T, string cstr="", list<dag> pattern=[]>
  4593. : MVE_qDest_rSrc<iname, suffix, cstr, !if(size, 0b10, 0b01), pattern> {
  4594. let Inst{28} = size;
  4595. let Inst{21-20} = 0b11;
  4596. let Inst{16} = 0b0;
  4597. let Inst{12} = T;
  4598. let Inst{8} = 0b1;
  4599. let Inst{5} = 0b1;
  4600. let validForTailPredication = 1;
  4601. let doubleWidthResult = 1;
  4602. }
  4603. multiclass MVE_VQDMULL_qr_m<string iname, MVEVectorVTInfo VTI, bit size,
  4604. bit T, string cstr> {
  4605. def "" : MVE_VQDMULL_qr<iname, VTI.Suffix, size, T, cstr>;
  4606. defvar Inst = !cast<Instruction>(NAME);
  4607. let Predicates = [HasMVEInt] in {
  4608. // Unpredicated saturating multiply
  4609. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm),
  4610. (VTI.Vec (ARMvdup rGPR:$val)),
  4611. (i32 T))),
  4612. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>;
  4613. // Predicated saturating multiply
  4614. def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated
  4615. (VTI.Vec MQPR:$Qm),
  4616. (VTI.Vec (ARMvdup rGPR:$val)),
  4617. (i32 T),
  4618. (VTI.DblPred VCCR:$mask),
  4619. (VTI.DblVec MQPR:$inactive))),
  4620. (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val),
  4621. ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
  4622. (VTI.DblVec MQPR:$inactive)))>;
  4623. }
  4624. }
  4625. multiclass MVE_VQDMULL_qr_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> {
  4626. defm bh : MVE_VQDMULL_qr_m<"vqdmullb", VTI, size, 0b0, cstr>;
  4627. defm th : MVE_VQDMULL_qr_m<"vqdmullt", VTI, size, 0b1, cstr>;
  4628. }
  4629. defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<MVE_v8s16, 0b0>;
  4630. defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">;
  4631. class MVE_VxADDSUB_qr<string iname, string suffix,
  4632. bit bit_28, bits<2> size, bit subtract,
  4633. bits<2> vecsize, list<dag> pattern=[]>
  4634. : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> {
  4635. let Inst{28} = bit_28;
  4636. let Inst{21-20} = size;
  4637. let Inst{16} = 0b0;
  4638. let Inst{12} = subtract;
  4639. let Inst{8} = 0b1;
  4640. let Inst{5} = 0b0;
  4641. let validForTailPredication = 1;
  4642. }
  4643. multiclass MVE_VHADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, SDNode Op,
  4644. Intrinsic unpred_int, Intrinsic pred_int, PatFrag add_op, PatFrag shift_op> {
  4645. def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, subtract, VTI.Size>;
  4646. defm : MVE_TwoOpPatternDup<VTI, Op, pred_int, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
  4647. defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME),
  4648. VTI, unpred_int, pred_int, 1, 1>;
  4649. defvar Inst = !cast<Instruction>(NAME);
  4650. let Predicates = [HasMVEInt] in {
  4651. def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))), (i32 1))),
  4652. (Inst MQPR:$Qm, rGPR:$Rn)>;
  4653. }
  4654. }
  4655. multiclass MVE_VHADD_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op, SDNode Op> :
  4656. MVE_VHADDSUB_qr_m<"vhadd", VTI, 0b0, Op, int_arm_mve_vhadd,
  4657. int_arm_mve_hadd_predicated, add_op, shift_op>;
  4658. multiclass MVE_VHSUB_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> :
  4659. MVE_VHADDSUB_qr_m<"vhsub", VTI, 0b1, null_frag, int_arm_mve_vhsub,
  4660. int_arm_mve_hsub_predicated, add_op, shift_op>;
  4661. defm MVE_VHADD_qr_s8 : MVE_VHADD_qr_m<MVE_v16s8, addnsw, ARMvshrsImm, avgfloors>;
  4662. defm MVE_VHADD_qr_s16 : MVE_VHADD_qr_m<MVE_v8s16, addnsw, ARMvshrsImm, avgfloors>;
  4663. defm MVE_VHADD_qr_s32 : MVE_VHADD_qr_m<MVE_v4s32, addnsw, ARMvshrsImm, avgfloors>;
  4664. defm MVE_VHADD_qr_u8 : MVE_VHADD_qr_m<MVE_v16u8, addnuw, ARMvshruImm, avgflooru>;
  4665. defm MVE_VHADD_qr_u16 : MVE_VHADD_qr_m<MVE_v8u16, addnuw, ARMvshruImm, avgflooru>;
  4666. defm MVE_VHADD_qr_u32 : MVE_VHADD_qr_m<MVE_v4u32, addnuw, ARMvshruImm, avgflooru>;
  4667. defm MVE_VHSUB_qr_s8 : MVE_VHSUB_qr_m<MVE_v16s8, subnsw, ARMvshrsImm>;
  4668. defm MVE_VHSUB_qr_s16 : MVE_VHSUB_qr_m<MVE_v8s16, subnsw, ARMvshrsImm>;
  4669. defm MVE_VHSUB_qr_s32 : MVE_VHSUB_qr_m<MVE_v4s32, subnsw, ARMvshrsImm>;
  4670. defm MVE_VHSUB_qr_u8 : MVE_VHSUB_qr_m<MVE_v16u8, subnuw, ARMvshruImm>;
  4671. defm MVE_VHSUB_qr_u16 : MVE_VHSUB_qr_m<MVE_v8u16, subnuw, ARMvshruImm>;
  4672. defm MVE_VHSUB_qr_u32 : MVE_VHSUB_qr_m<MVE_v4u32, subnuw, ARMvshruImm>;
  4673. multiclass MVE_VADDSUB_qr_f<string iname, MVEVectorVTInfo VTI, bit subtract,
  4674. SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> {
  4675. def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, subtract, VTI.Size>;
  4676. defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ),
  4677. !cast<Instruction>(NAME), IdentityVec>;
  4678. }
  4679. let Predicates = [HasMVEFloat] in {
  4680. defm MVE_VADD_qr_f32 : MVE_VADDSUB_qr_f<"vadd", MVE_v4f32, 0b0, fadd,
  4681. int_arm_mve_add_predicated, ARMimmMinusZeroF>;
  4682. defm MVE_VADD_qr_f16 : MVE_VADDSUB_qr_f<"vadd", MVE_v8f16, 0b0, fadd,
  4683. int_arm_mve_add_predicated, ARMimmMinusZeroH>;
  4684. defm MVE_VSUB_qr_f32 : MVE_VADDSUB_qr_f<"vsub", MVE_v4f32, 0b1, fsub,
  4685. int_arm_mve_sub_predicated, ARMimmAllZerosV>;
  4686. defm MVE_VSUB_qr_f16 : MVE_VADDSUB_qr_f<"vsub", MVE_v8f16, 0b1, fsub,
  4687. int_arm_mve_sub_predicated, ARMimmAllZerosV>;
  4688. }
  4689. class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size,
  4690. bit bit_7, bit bit_17, list<dag> pattern=[]>
  4691. : MVE_qDest_single_rSrc<iname, suffix, size, pattern> {
  4692. let Inst{28} = U;
  4693. let Inst{25-23} = 0b100;
  4694. let Inst{21-20} = 0b11;
  4695. let Inst{19-18} = size;
  4696. let Inst{17} = bit_17;
  4697. let Inst{16} = 0b1;
  4698. let Inst{12-8} = 0b11110;
  4699. let Inst{7} = bit_7;
  4700. let Inst{6-4} = 0b110;
  4701. let validForTailPredication = 1;
  4702. }
  4703. multiclass MVE_VxSHL_qr_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> {
  4704. def "" : MVE_VxSHL_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>;
  4705. defvar Inst = !cast<Instruction>(NAME);
  4706. def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar
  4707. (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
  4708. (i32 q), (i32 r), (i32 VTI.Unsigned))),
  4709. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh)))>;
  4710. def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar_predicated
  4711. (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
  4712. (i32 q), (i32 r), (i32 VTI.Unsigned),
  4713. (VTI.Pred VCCR:$mask))),
  4714. (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
  4715. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
  4716. }
  4717. multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> {
  4718. defm s8 : MVE_VxSHL_qr_p<iname, MVE_v16s8, bit_7, bit_17>;
  4719. defm s16 : MVE_VxSHL_qr_p<iname, MVE_v8s16, bit_7, bit_17>;
  4720. defm s32 : MVE_VxSHL_qr_p<iname, MVE_v4s32, bit_7, bit_17>;
  4721. defm u8 : MVE_VxSHL_qr_p<iname, MVE_v16u8, bit_7, bit_17>;
  4722. defm u16 : MVE_VxSHL_qr_p<iname, MVE_v8u16, bit_7, bit_17>;
  4723. defm u32 : MVE_VxSHL_qr_p<iname, MVE_v4u32, bit_7, bit_17>;
  4724. }
  4725. defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>;
  4726. defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>;
  4727. defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>;
  4728. defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>;
  4729. let Predicates = [HasMVEInt] in {
  4730. def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))),
  4731. (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), rGPR:$Rm))>;
  4732. def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))),
  4733. (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), rGPR:$Rm))>;
  4734. def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))),
  4735. (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), rGPR:$Rm))>;
  4736. def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))),
  4737. (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), rGPR:$Rm))>;
  4738. def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))),
  4739. (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), rGPR:$Rm))>;
  4740. def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))),
  4741. (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), rGPR:$Rm))>;
  4742. }
  4743. class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
  4744. : MVE_qDest_rSrc<iname, suffix, "", size, pattern> {
  4745. let Inst{28} = 0b1;
  4746. let Inst{21-20} = size;
  4747. let Inst{16} = 0b1;
  4748. let Inst{12} = 0b1;
  4749. let Inst{8} = 0b0;
  4750. let Inst{5} = 0b1;
  4751. let validForTailPredication = 1;
  4752. }
  4753. def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>;
  4754. def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
  4755. def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
  4756. multiclass MVE_VBRSR_pat_m<MVEVectorVTInfo VTI, Instruction Inst> {
  4757. // Unpredicated
  4758. def : Pat<(VTI.Vec (int_arm_mve_vbrsr (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm))),
  4759. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm)))>;
  4760. // Predicated
  4761. def : Pat<(VTI.Vec (int_arm_mve_vbrsr_predicated
  4762. (VTI.Vec MQPR:$inactive),
  4763. (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm),
  4764. (VTI.Pred VCCR:$mask))),
  4765. (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm),
  4766. ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
  4767. (VTI.Vec MQPR:$inactive)))>;
  4768. }
  4769. let Predicates = [HasMVEInt] in {
  4770. def : Pat<(v16i8 ( bitreverse (v16i8 MQPR:$val1))),
  4771. (v16i8 ( MVE_VBRSR8 (v16i8 MQPR:$val1), (t2MOVi (i32 8)) ))>;
  4772. def : Pat<(v4i32 ( bitreverse (v4i32 MQPR:$val1))),
  4773. (v4i32 ( MVE_VBRSR32 (v4i32 MQPR:$val1), (t2MOVi (i32 32)) ))>;
  4774. def : Pat<(v8i16 ( bitreverse (v8i16 MQPR:$val1))),
  4775. (v8i16 ( MVE_VBRSR16 (v8i16 MQPR:$val1), (t2MOVi (i32 16)) ))>;
  4776. defm : MVE_VBRSR_pat_m<MVE_v16i8, MVE_VBRSR8>;
  4777. defm : MVE_VBRSR_pat_m<MVE_v8i16, MVE_VBRSR16>;
  4778. defm : MVE_VBRSR_pat_m<MVE_v4i32, MVE_VBRSR32>;
  4779. }
  4780. let Predicates = [HasMVEFloat] in {
  4781. defm : MVE_VBRSR_pat_m<MVE_v8f16, MVE_VBRSR16>;
  4782. defm : MVE_VBRSR_pat_m<MVE_v4f32, MVE_VBRSR32>;
  4783. }
  4784. class MVE_VMUL_qr_int<string iname, string suffix, bits<2> size>
  4785. : MVE_qDest_rSrc<iname, suffix, "", size> {
  4786. let Inst{28} = 0b0;
  4787. let Inst{21-20} = size;
  4788. let Inst{16} = 0b1;
  4789. let Inst{12} = 0b1;
  4790. let Inst{8} = 0b0;
  4791. let Inst{5} = 0b1;
  4792. let validForTailPredication = 1;
  4793. }
  4794. multiclass MVE_VMUL_qr_int_m<MVEVectorVTInfo VTI> {
  4795. def "" : MVE_VMUL_qr_int<"vmul", VTI.Suffix, VTI.Size>;
  4796. let Predicates = [HasMVEInt] in {
  4797. defm : MVE_TwoOpPatternDup<VTI, mul, int_arm_mve_mul_predicated, (? ),
  4798. !cast<Instruction>(NAME), ARMimmOneV>;
  4799. }
  4800. }
  4801. defm MVE_VMUL_qr_i8 : MVE_VMUL_qr_int_m<MVE_v16i8>;
  4802. defm MVE_VMUL_qr_i16 : MVE_VMUL_qr_int_m<MVE_v8i16>;
  4803. defm MVE_VMUL_qr_i32 : MVE_VMUL_qr_int_m<MVE_v4i32>;
  4804. class MVE_VxxMUL_qr<string iname, string suffix,
  4805. bit bit_28, bits<2> size, bits<2> vecsize, list<dag> pattern=[]>
  4806. : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> {
  4807. let Inst{28} = bit_28;
  4808. let Inst{21-20} = size;
  4809. let Inst{16} = 0b1;
  4810. let Inst{12} = 0b0;
  4811. let Inst{8} = 0b0;
  4812. let Inst{5} = 0b1;
  4813. let validForTailPredication = 1;
  4814. }
  4815. multiclass MVE_VxxMUL_qr_m<string iname, MVEVectorVTInfo VTI, bit bit_28,
  4816. PatFrag Op, Intrinsic int_unpred, Intrinsic int_pred> {
  4817. def "" : MVE_VxxMUL_qr<iname, VTI.Suffix, bit_28, VTI.Size, VTI.Size>;
  4818. let Predicates = [HasMVEInt] in {
  4819. defm : MVE_TwoOpPatternDup<VTI, Op, int_pred, (? ), !cast<Instruction>(NAME)>;
  4820. }
  4821. defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME), VTI, int_unpred, int_pred>;
  4822. }
  4823. multiclass MVE_VQDMULH_qr_m<MVEVectorVTInfo VTI> :
  4824. MVE_VxxMUL_qr_m<"vqdmulh", VTI, 0b0, MVEvqdmulh,
  4825. int_arm_mve_vqdmulh, int_arm_mve_qdmulh_predicated>;
  4826. multiclass MVE_VQRDMULH_qr_m<MVEVectorVTInfo VTI> :
  4827. MVE_VxxMUL_qr_m<"vqrdmulh", VTI, 0b1, null_frag,
  4828. int_arm_mve_vqrdmulh, int_arm_mve_qrdmulh_predicated>;
  4829. defm MVE_VQDMULH_qr_s8 : MVE_VQDMULH_qr_m<MVE_v16s8>;
  4830. defm MVE_VQDMULH_qr_s16 : MVE_VQDMULH_qr_m<MVE_v8s16>;
  4831. defm MVE_VQDMULH_qr_s32 : MVE_VQDMULH_qr_m<MVE_v4s32>;
  4832. defm MVE_VQRDMULH_qr_s8 : MVE_VQRDMULH_qr_m<MVE_v16s8>;
  4833. defm MVE_VQRDMULH_qr_s16 : MVE_VQRDMULH_qr_m<MVE_v8s16>;
  4834. defm MVE_VQRDMULH_qr_s32 : MVE_VQRDMULH_qr_m<MVE_v4s32>;
  4835. multiclass MVE_VxxMUL_qr_f_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> {
  4836. let validForTailPredication = 1 in
  4837. def "" : MVE_VxxMUL_qr<"vmul", VTI.Suffix, VTI.Size{0}, 0b11, VTI.Size>;
  4838. defm : MVE_TwoOpPatternDup<VTI, fmul, int_arm_mve_mul_predicated, (? ),
  4839. !cast<Instruction>(NAME), IdentityVec>;
  4840. }
  4841. let Predicates = [HasMVEFloat] in {
  4842. defm MVE_VMUL_qr_f16 : MVE_VxxMUL_qr_f_m<MVE_v8f16, ARMimmOneH>;
  4843. defm MVE_VMUL_qr_f32 : MVE_VxxMUL_qr_f_m<MVE_v4f32, ARMimmOneF>;
  4844. }
  4845. class MVE_VFMAMLA_qr<string iname, string suffix,
  4846. bit bit_28, bits<2> bits_21_20, bit S,
  4847. bits<2> vecsize, list<dag> pattern=[]>
  4848. : MVE_qDestSrc_rSrc<iname, suffix, vecsize, pattern> {
  4849. let Inst{28} = bit_28;
  4850. let Inst{21-20} = bits_21_20;
  4851. let Inst{16} = 0b1;
  4852. let Inst{12} = S;
  4853. let Inst{8} = 0b0;
  4854. let Inst{5} = 0b0;
  4855. let validForTailPredication = 1;
  4856. let hasSideEffects = 0;
  4857. }
  4858. multiclass MVE_VMLA_qr_multi<string iname, MVEVectorVTInfo VTI,
  4859. bit scalar_addend> {
  4860. def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, 0b0, VTI.Size,
  4861. scalar_addend, VTI.Size>;
  4862. defvar Inst = !cast<Instruction>(NAME);
  4863. defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_n_predicated");
  4864. defvar v1 = (VTI.Vec MQPR:$v1);
  4865. defvar v2 = (VTI.Vec MQPR:$v2);
  4866. defvar vs = (VTI.Vec (ARMvdup rGPR:$s));
  4867. defvar s = (i32 rGPR:$s);
  4868. defvar pred = (VTI.Pred VCCR:$pred);
  4869. let Predicates = [HasMVEInt] in {
  4870. if scalar_addend then {
  4871. def : Pat<(VTI.Vec (add (mul v1, v2), vs)),
  4872. (VTI.Vec (Inst v1, v2, s))>;
  4873. } else {
  4874. def : Pat<(VTI.Vec (add (mul v2, vs), v1)),
  4875. (VTI.Vec (Inst v1, v2, s))>;
  4876. }
  4877. def : Pat<(VTI.Vec (pred_int v1, v2, s, pred)),
  4878. (VTI.Vec (Inst v1, v2, s, ARMVCCThen, pred, zero_reg))>;
  4879. }
  4880. }
  4881. defm MVE_VMLA_qr_i8 : MVE_VMLA_qr_multi<"vmla", MVE_v16i8, 0b0>;
  4882. defm MVE_VMLA_qr_i16 : MVE_VMLA_qr_multi<"vmla", MVE_v8i16, 0b0>;
  4883. defm MVE_VMLA_qr_i32 : MVE_VMLA_qr_multi<"vmla", MVE_v4i32, 0b0>;
  4884. defm MVE_VMLAS_qr_i8 : MVE_VMLA_qr_multi<"vmlas", MVE_v16i8, 0b1>;
  4885. defm MVE_VMLAS_qr_i16 : MVE_VMLA_qr_multi<"vmlas", MVE_v8i16, 0b1>;
  4886. defm MVE_VMLAS_qr_i32 : MVE_VMLA_qr_multi<"vmlas", MVE_v4i32, 0b1>;
  4887. multiclass MVE_VFMA_qr_multi<string iname, MVEVectorVTInfo VTI,
  4888. bit scalar_addend> {
  4889. def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, scalar_addend, VTI.Size>;
  4890. defvar Inst = !cast<Instruction>(NAME);
  4891. defvar pred_int = int_arm_mve_fma_predicated;
  4892. defvar v1 = (VTI.Vec MQPR:$v1);
  4893. defvar v2 = (VTI.Vec MQPR:$v2);
  4894. defvar vs = (VTI.Vec (ARMvdup (i32 rGPR:$s)));
  4895. defvar is = (i32 rGPR:$s);
  4896. defvar pred = (VTI.Pred VCCR:$pred);
  4897. let Predicates = [HasMVEFloat] in {
  4898. if scalar_addend then {
  4899. def : Pat<(VTI.Vec (fma v1, v2, vs)),
  4900. (VTI.Vec (Inst v1, v2, is))>;
  4901. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  4902. (VTI.Vec (fma v1, v2, vs)),
  4903. v1)),
  4904. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
  4905. def : Pat<(VTI.Vec (pred_int v1, v2, vs, pred)),
  4906. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, pred, zero_reg))>;
  4907. } else {
  4908. def : Pat<(VTI.Vec (fma v1, vs, v2)),
  4909. (VTI.Vec (Inst v2, v1, is))>;
  4910. def : Pat<(VTI.Vec (fma vs, v1, v2)),
  4911. (VTI.Vec (Inst v2, v1, is))>;
  4912. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  4913. (VTI.Vec (fma vs, v2, v1)),
  4914. v1)),
  4915. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
  4916. def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
  4917. (VTI.Vec (fma v2, vs, v1)),
  4918. v1)),
  4919. (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
  4920. def : Pat<(VTI.Vec (pred_int v1, vs, v2, pred)),
  4921. (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>;
  4922. def : Pat<(VTI.Vec (pred_int vs, v1, v2, pred)),
  4923. (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>;
  4924. }
  4925. }
  4926. }
  4927. let Predicates = [HasMVEFloat] in {
  4928. defm MVE_VFMA_qr_f16 : MVE_VFMA_qr_multi<"vfma", MVE_v8f16, 0>;
  4929. defm MVE_VFMA_qr_f32 : MVE_VFMA_qr_multi<"vfma", MVE_v4f32, 0>;
  4930. defm MVE_VFMA_qr_Sf16 : MVE_VFMA_qr_multi<"vfmas", MVE_v8f16, 1>;
  4931. defm MVE_VFMA_qr_Sf32 : MVE_VFMA_qr_multi<"vfmas", MVE_v4f32, 1>;
  4932. }
  4933. class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size,
  4934. bit bit_5, bit bit_12, list<dag> pattern=[]>
  4935. : MVE_qDestSrc_rSrc<iname, suffix, size, pattern> {
  4936. let Inst{28} = U;
  4937. let Inst{21-20} = size;
  4938. let Inst{16} = 0b0;
  4939. let Inst{12} = bit_12;
  4940. let Inst{8} = 0b0;
  4941. let Inst{5} = bit_5;
  4942. }
  4943. multiclass MVE_VQDMLAH_qr_multi<string iname, MVEVectorVTInfo VTI,
  4944. bit bit_5, bit bit_12> {
  4945. def "": MVE_VQDMLAH_qr<iname, VTI.Suffix, 0b0, VTI.Size, bit_5, bit_12>;
  4946. defvar Inst = !cast<Instruction>(NAME);
  4947. defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # iname);
  4948. defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_predicated");
  4949. let Predicates = [HasMVEInt] in {
  4950. def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4951. (i32 rGPR:$s))),
  4952. (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4953. (i32 rGPR:$s)))>;
  4954. def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4955. (i32 rGPR:$s), (VTI.Pred VCCR:$pred))),
  4956. (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
  4957. (i32 rGPR:$s), ARMVCCThen,
  4958. (VTI.Pred VCCR:$pred), zero_reg))>;
  4959. }
  4960. }
  4961. multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> {
  4962. defm s8 : MVE_VQDMLAH_qr_multi<iname, MVE_v16s8, bit_5, bit_12>;
  4963. defm s16 : MVE_VQDMLAH_qr_multi<iname, MVE_v8s16, bit_5, bit_12>;
  4964. defm s32 : MVE_VQDMLAH_qr_multi<iname, MVE_v4s32, bit_5, bit_12>;
  4965. }
  4966. defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>;
  4967. defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>;
  4968. defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>;
  4969. defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>;
  4970. class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12,
  4971. ValueType VT, SDPatternOperator vxdup>
  4972. : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
  4973. (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary,
  4974. iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src", size,
  4975. [(set (VT MQPR:$Qd), (i32 tGPREven:$Rn),
  4976. (vxdup (i32 tGPREven:$Rn_src), (i32 imm:$imm)))]> {
  4977. bits<4> Qd;
  4978. bits<4> Rn;
  4979. bits<2> imm;
  4980. let Inst{28} = 0b0;
  4981. let Inst{25-23} = 0b100;
  4982. let Inst{22} = Qd{3};
  4983. let Inst{21-20} = size;
  4984. let Inst{19-17} = Rn{3-1};
  4985. let Inst{16} = 0b1;
  4986. let Inst{15-13} = Qd{2-0};
  4987. let Inst{12} = bit_12;
  4988. let Inst{11-8} = 0b1111;
  4989. let Inst{7} = imm{1};
  4990. let Inst{6-1} = 0b110111;
  4991. let Inst{0} = imm{0};
  4992. let validForTailPredication = 1;
  4993. let hasSideEffects = 0;
  4994. }
  4995. def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0, v16i8, ARMvidup>;
  4996. def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0, v8i16, ARMvidup>;
  4997. def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0, v4i32, ARMvidup>;
  4998. def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1, v16i8, null_frag>;
  4999. def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1, v8i16, null_frag>;
  5000. def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1, v4i32, null_frag>;
  5001. class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12,
  5002. list<dag> pattern=[]>
  5003. : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
  5004. (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary,
  5005. iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src", size,
  5006. pattern> {
  5007. bits<4> Qd;
  5008. bits<4> Rm;
  5009. bits<4> Rn;
  5010. bits<2> imm;
  5011. let Inst{28} = 0b0;
  5012. let Inst{25-23} = 0b100;
  5013. let Inst{22} = Qd{3};
  5014. let Inst{21-20} = size;
  5015. let Inst{19-17} = Rn{3-1};
  5016. let Inst{16} = 0b1;
  5017. let Inst{15-13} = Qd{2-0};
  5018. let Inst{12} = bit_12;
  5019. let Inst{11-8} = 0b1111;
  5020. let Inst{7} = imm{1};
  5021. let Inst{6-4} = 0b110;
  5022. let Inst{3-1} = Rm{3-1};
  5023. let Inst{0} = imm{0};
  5024. let validForTailPredication = 1;
  5025. let hasSideEffects = 0;
  5026. }
  5027. def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>;
  5028. def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>;
  5029. def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>;
  5030. def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>;
  5031. def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>;
  5032. def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>;
  5033. let isReMaterializable = 1 in
  5034. class MVE_VCTPInst<string suffix, bits<2> size, list<dag> pattern=[]>
  5035. : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix,
  5036. "$Rn", vpred_n, "", size, pattern> {
  5037. bits<4> Rn;
  5038. let Inst{28-27} = 0b10;
  5039. let Inst{26-22} = 0b00000;
  5040. let Inst{21-20} = size;
  5041. let Inst{19-16} = Rn{3-0};
  5042. let Inst{15-11} = 0b11101;
  5043. let Inst{10-0} = 0b00000000001;
  5044. let Unpredictable{10-0} = 0b11111111111;
  5045. let Constraints = "";
  5046. let DecoderMethod = "DecodeMveVCTP";
  5047. let validForTailPredication = 1;
  5048. }
  5049. multiclass MVE_VCTP<MVEVectorVTInfo VTI, Intrinsic intr> {
  5050. def "": MVE_VCTPInst<VTI.BitsSuffix, VTI.Size>;
  5051. defvar Inst = !cast<Instruction>(NAME);
  5052. let Predicates = [HasMVEInt] in {
  5053. def : Pat<(intr rGPR:$Rn),
  5054. (VTI.Pred (Inst rGPR:$Rn))>;
  5055. def : Pat<(and (intr rGPR:$Rn), (VTI.Pred VCCR:$mask)),
  5056. (VTI.Pred (Inst rGPR:$Rn, ARMVCCThen, VCCR:$mask, zero_reg))>;
  5057. }
  5058. }
  5059. defm MVE_VCTP8 : MVE_VCTP<MVE_v16i8, int_arm_mve_vctp8>;
  5060. defm MVE_VCTP16 : MVE_VCTP<MVE_v8i16, int_arm_mve_vctp16>;
  5061. defm MVE_VCTP32 : MVE_VCTP<MVE_v4i32, int_arm_mve_vctp32>;
  5062. defm MVE_VCTP64 : MVE_VCTP<MVE_v2i64, int_arm_mve_vctp64>;
  5063. // end of mve_qDest_rSrc
  5064. // start of coproc mov
  5065. class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr>
  5066. : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx,
  5067. MVEPairVectorIndex0:$idx2)),
  5068. NoItinerary, "vmov", "", ops, cstr, []> {
  5069. bits<5> Rt;
  5070. bits<5> Rt2;
  5071. bits<4> Qd;
  5072. bit idx;
  5073. bit idx2;
  5074. let Inst{31-23} = 0b111011000;
  5075. let Inst{22} = Qd{3};
  5076. let Inst{21} = 0b0;
  5077. let Inst{20} = to_qreg;
  5078. let Inst{19-16} = Rt2{3-0};
  5079. let Inst{15-13} = Qd{2-0};
  5080. let Inst{12-5} = 0b01111000;
  5081. let Inst{4} = idx2;
  5082. let Inst{3-0} = Rt{3-0};
  5083. let VecSize = 0b10;
  5084. let hasSideEffects = 0;
  5085. }
  5086. // The assembly syntax for these instructions mentions the vector
  5087. // register name twice, e.g.
  5088. //
  5089. // vmov q2[2], q2[0], r0, r1
  5090. // vmov r0, r1, q2[2], q2[0]
  5091. //
  5092. // which needs a bit of juggling with MC operand handling.
  5093. //
  5094. // For the move _into_ a vector register, the MC operand list also has
  5095. // to mention the register name twice: once as the output, and once as
  5096. // an extra input to represent where the unchanged half of the output
  5097. // register comes from (when this instruction is used in code
  5098. // generation). So we arrange that the first mention of the vector reg
  5099. // in the instruction is considered by the AsmMatcher to be the output
  5100. // ($Qd), and the second one is the input ($QdSrc). Binding them
  5101. // together with the existing 'tie' constraint is enough to enforce at
  5102. // register allocation time that they have to be the same register.
  5103. //
  5104. // For the move _from_ a vector register, there's no way to get round
  5105. // the fact that both instances of that register name have to be
  5106. // inputs. They have to be the same register again, but this time, we
  5107. // can't use a tie constraint, because that has to be between an
  5108. // output and an input operand. So this time, we have to arrange that
  5109. // the q-reg appears just once in the MC operand list, in spite of
  5110. // being mentioned twice in the asm syntax - which needs a custom
  5111. // AsmMatchConverter.
  5112. def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd),
  5113. (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2),
  5114. 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2",
  5115. "$Qd = $QdSrc"> {
  5116. let DecoderMethod = "DecodeMVEVMOVDRegtoQ";
  5117. }
  5118. def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd),
  5119. 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> {
  5120. let DecoderMethod = "DecodeMVEVMOVQtoDReg";
  5121. let AsmMatchConverter = "cvtMVEVMOVQtoDReg";
  5122. }
  5123. let Predicates = [HasMVEInt] in {
  5124. // Double lane moves. There are a number of patterns here. We know that the
  5125. // insertelt's will be in descending order by index, and need to match the 5
  5126. // patterns that might contain 2-0 or 3-1 pairs. These are:
  5127. // 3 2 1 0 -> vmovqrr 31; vmovqrr 20
  5128. // 3 2 1 -> vmovqrr 31; vmov 2
  5129. // 3 1 -> vmovqrr 31
  5130. // 2 1 0 -> vmovqrr 20; vmov 1
  5131. // 2 0 -> vmovqrr 20
  5132. // The other potential patterns will be handled by single lane inserts.
  5133. def : Pat<(insertelt (insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
  5134. rGPR:$srcA, (i32 0)),
  5135. rGPR:$srcB, (i32 1)),
  5136. rGPR:$srcC, (i32 2)),
  5137. rGPR:$srcD, (i32 3)),
  5138. (MVE_VMOV_q_rr (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcC, (i32 2), (i32 0)),
  5139. rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>;
  5140. def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
  5141. rGPR:$srcB, (i32 1)),
  5142. rGPR:$srcC, (i32 2)),
  5143. rGPR:$srcD, (i32 3)),
  5144. (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 2)),
  5145. rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>;
  5146. def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 1)), rGPR:$srcB, (i32 3)),
  5147. (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 3), (i32 1))>;
  5148. def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
  5149. rGPR:$srcB, (i32 0)),
  5150. rGPR:$srcC, (i32 1)),
  5151. rGPR:$srcD, (i32 2)),
  5152. (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 1)),
  5153. rGPR:$srcB, rGPR:$srcD, (i32 2), (i32 0))>;
  5154. def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 0)), rGPR:$srcB, (i32 2)),
  5155. (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 2), (i32 0))>;
  5156. }
  5157. // end of coproc mov
  5158. // start of MVE interleaving load/store
  5159. // Base class for the family of interleaving/deinterleaving
  5160. // load/stores with names like VLD20.8 and VST43.32.
  5161. class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size,
  5162. bit load, dag Oops, dag loadIops, dag wbIops,
  5163. string iname, string ops,
  5164. string cstr, list<dag> pattern=[]>
  5165. : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, size, pattern> {
  5166. bits<4> VQd;
  5167. bits<4> Rn;
  5168. let Inst{31-22} = 0b1111110010;
  5169. let Inst{21} = writeback;
  5170. let Inst{20} = load;
  5171. let Inst{19-16} = Rn;
  5172. let Inst{15-13} = VQd{2-0};
  5173. let Inst{12-9} = 0b1111;
  5174. let Inst{8-7} = size;
  5175. let Inst{6-5} = stage;
  5176. let Inst{4-1} = 0b0000;
  5177. let Inst{0} = fourregs;
  5178. let mayLoad = load;
  5179. let mayStore = !eq(load,0);
  5180. let hasSideEffects = 0;
  5181. let validForTailPredication = load;
  5182. }
  5183. // A parameter class used to encapsulate all the ways the writeback
  5184. // variants of VLD20 and friends differ from the non-writeback ones.
  5185. class MVE_vldst24_writeback<bit b, dag Oo, dag Io,
  5186. string sy="", string c="", string n=""> {
  5187. bit writeback = b;
  5188. dag Oops = Oo;
  5189. dag Iops = Io;
  5190. string syntax = sy;
  5191. string cstr = c;
  5192. string id_suffix = n;
  5193. }
  5194. // Another parameter class that encapsulates the differences between VLD2x
  5195. // and VLD4x.
  5196. class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> {
  5197. int nvecs = n;
  5198. list<int> stages = s;
  5199. bit bit0 = b;
  5200. RegisterOperand VecList = vl;
  5201. }
  5202. // A third parameter class that distinguishes VLDnn.8 from .16 from .32.
  5203. class MVE_vldst24_lanesize<int i, bits<2> b> {
  5204. int lanesize = i;
  5205. bits<2> sizebits = b;
  5206. }
  5207. // A base class for each direction of transfer: one for load, one for
  5208. // store. I can't make these a fourth independent parametric tuple
  5209. // class, because they have to take the nvecs tuple class as a
  5210. // parameter, in order to find the right VecList operand type.
  5211. class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
  5212. MVE_vldst24_writeback wb, string iname,
  5213. list<dag> pattern=[]>
  5214. : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1,
  5215. !con((outs n.VecList:$VQd), wb.Oops),
  5216. (ins n.VecList:$VQdSrc), wb.Iops,
  5217. iname, "$VQd, $Rn" # wb.syntax,
  5218. wb.cstr # ",$VQdSrc = $VQd", pattern>;
  5219. class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
  5220. MVE_vldst24_writeback wb, string iname,
  5221. list<dag> pattern=[]>
  5222. : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0,
  5223. wb.Oops, (ins n.VecList:$VQd), wb.Iops,
  5224. iname, "$VQd, $Rn" # wb.syntax,
  5225. wb.cstr, pattern>;
  5226. // Actually define all the interleaving loads and stores, by a series
  5227. // of nested foreaches over number of vectors (VLD2/VLD4); stage
  5228. // within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of
  5229. // vector lane; writeback or no writeback.
  5230. foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>,
  5231. MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in
  5232. foreach stage = n.stages in
  5233. foreach s = [MVE_vldst24_lanesize< 8, 0b00>,
  5234. MVE_vldst24_lanesize<16, 0b01>,
  5235. MVE_vldst24_lanesize<32, 0b10>] in
  5236. foreach wb = [MVE_vldst24_writeback<
  5237. 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn),
  5238. "!", "$Rn.base = $wb", "_wb">,
  5239. MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in {
  5240. // For each case within all of those foreaches, define the actual
  5241. // instructions. The def names are made by gluing together pieces
  5242. // from all the parameter classes, and will end up being things like
  5243. // MVE_VLD20_8 and MVE_VST43_16_wb.
  5244. def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
  5245. : MVE_vld24_base<n, stage, s.sizebits, wb,
  5246. "vld" # n.nvecs # stage # "." # s.lanesize>;
  5247. def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
  5248. : MVE_vst24_base<n, stage, s.sizebits, wb,
  5249. "vst" # n.nvecs # stage # "." # s.lanesize>;
  5250. }
  5251. def SDTARMVST2 : SDTypeProfile<1, 5, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>,
  5252. SDTCisSameAs<3, 4>, SDTCisVT<5, i32>]>;
  5253. def SDTARMVST4 : SDTypeProfile<1, 7, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>,
  5254. SDTCisSameAs<3, 4>, SDTCisSameAs<3, 5>,
  5255. SDTCisSameAs<3, 6>, SDTCisVT<7, i32>]>;
  5256. def MVEVST2UPD : SDNode<"ARMISD::VST2_UPD", SDTARMVST2, [SDNPHasChain, SDNPMemOperand]>;
  5257. def MVEVST4UPD : SDNode<"ARMISD::VST4_UPD", SDTARMVST4, [SDNPHasChain, SDNPMemOperand]>;
  5258. multiclass MVE_vst24_patterns<int lanesize, ValueType VT> {
  5259. foreach stage = [0,1] in
  5260. def : Pat<(int_arm_mve_vst2q i32:$addr,
  5261. (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage)),
  5262. (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize)
  5263. (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1),
  5264. t2_addr_offset_none:$addr)>;
  5265. foreach stage = [0,1] in
  5266. def : Pat<(i32 (MVEVST2UPD i32:$addr, (i32 32),
  5267. (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage))),
  5268. (i32 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize#_wb)
  5269. (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1),
  5270. t2_addr_offset_none:$addr))>;
  5271. foreach stage = [0,1,2,3] in
  5272. def : Pat<(int_arm_mve_vst4q i32:$addr,
  5273. (VT MQPR:$v0), (VT MQPR:$v1),
  5274. (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage)),
  5275. (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize)
  5276. (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1,
  5277. VT:$v2, qsub_2, VT:$v3, qsub_3),
  5278. t2_addr_offset_none:$addr)>;
  5279. foreach stage = [0,1,2,3] in
  5280. def : Pat<(i32 (MVEVST4UPD i32:$addr, (i32 64),
  5281. (VT MQPR:$v0), (VT MQPR:$v1),
  5282. (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage))),
  5283. (i32 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize#_wb)
  5284. (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1,
  5285. VT:$v2, qsub_2, VT:$v3, qsub_3),
  5286. t2_addr_offset_none:$addr))>;
  5287. }
  5288. defm : MVE_vst24_patterns<8, v16i8>;
  5289. defm : MVE_vst24_patterns<16, v8i16>;
  5290. defm : MVE_vst24_patterns<32, v4i32>;
  5291. defm : MVE_vst24_patterns<16, v8f16>;
  5292. defm : MVE_vst24_patterns<32, v4f32>;
  5293. // end of MVE interleaving load/store
  5294. // start of MVE predicable load/store
  5295. // A parameter class for the direction of transfer.
  5296. class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> {
  5297. bit load = b;
  5298. dag Oops = Oo;
  5299. dag Iops = Io;
  5300. string cstr = c;
  5301. }
  5302. def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">;
  5303. def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>;
  5304. // A parameter class for the size of memory access in a load.
  5305. class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> {
  5306. bits<2> encoding = e; // opcode bit(s) for encoding
  5307. int shift = s; // shift applied to immediate load offset
  5308. AddrMode AM = m;
  5309. // For instruction aliases: define the complete list of type
  5310. // suffixes at this size, and the canonical ones for loads and
  5311. // stores.
  5312. string MnemonicLetter = mn;
  5313. int TypeBits = !shl(8, s);
  5314. string CanonLoadSuffix = ".u" # TypeBits;
  5315. string CanonStoreSuffix = "." # TypeBits;
  5316. list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits);
  5317. }
  5318. // Instances of MVE_memsz.
  5319. //
  5320. // (memD doesn't need an AddrMode, because those are only for
  5321. // contiguous loads, and memD is only used by gather/scatters.)
  5322. def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>;
  5323. def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>;
  5324. def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>;
  5325. def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>;
  5326. // This is the base class for all the MVE loads and stores other than
  5327. // the interleaving ones. All the non-interleaving loads/stores share
  5328. // the characteristic that they operate on just one vector register,
  5329. // so they are VPT-predicable.
  5330. //
  5331. // The predication operand is vpred_n, for both loads and stores. For
  5332. // store instructions, the reason is obvious: if there is no output
  5333. // register, there can't be a need for an input parameter giving the
  5334. // output register's previous value. Load instructions also don't need
  5335. // that input parameter, because unlike MVE data processing
  5336. // instructions, predicated loads are defined to set the inactive
  5337. // lanes of the output register to zero, instead of preserving their
  5338. // input values.
  5339. class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc,
  5340. dag oops, dag iops, string asm, string suffix,
  5341. string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]>
  5342. : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, vecsize, pattern> {
  5343. bits<3> Qd;
  5344. let Inst{28} = U;
  5345. let Inst{25} = 0b0;
  5346. let Inst{24} = P;
  5347. let Inst{22} = 0b0;
  5348. let Inst{21} = W;
  5349. let Inst{20} = dir.load;
  5350. let Inst{15-13} = Qd{2-0};
  5351. let Inst{12} = opc;
  5352. let Inst{11-9} = 0b111;
  5353. let mayLoad = dir.load;
  5354. let mayStore = !eq(dir.load,0);
  5355. let hasSideEffects = 0;
  5356. let validForTailPredication = 1;
  5357. }
  5358. // Contiguous load and store instructions. These come in two main
  5359. // categories: same-size loads/stores in which 128 bits of vector
  5360. // register is transferred to or from 128 bits of memory in the most
  5361. // obvious way, and widening loads / narrowing stores, in which the
  5362. // size of memory accessed is less than the size of a vector register,
  5363. // so the load instructions sign- or zero-extend each memory value
  5364. // into a wider vector lane, and the store instructions truncate
  5365. // correspondingly.
  5366. //
  5367. // The instruction mnemonics for these two classes look reasonably
  5368. // similar, but the actual encodings are different enough to need two
  5369. // separate base classes.
  5370. // Contiguous, same size
  5371. class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W,
  5372. dag oops, dag iops, string asm, string suffix,
  5373. IndexMode im, string ops, string cstr>
  5374. : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr, memsz.encoding> {
  5375. bits<12> addr;
  5376. let Inst{23} = addr{7};
  5377. let Inst{19-16} = addr{11-8};
  5378. let Inst{8-7} = memsz.encoding;
  5379. let Inst{6-0} = addr{6-0};
  5380. let IM = im;
  5381. }
  5382. // Contiguous, widening/narrowing
  5383. class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
  5384. bit P, bit W, bits<2> size, dag oops, dag iops,
  5385. string asm, string suffix, IndexMode im,
  5386. string ops, string cstr>
  5387. : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr, size> {
  5388. bits<11> addr;
  5389. let Inst{23} = addr{7};
  5390. let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit
  5391. let Inst{18-16} = addr{10-8};
  5392. let Inst{8-7} = size;
  5393. let Inst{6-0} = addr{6-0};
  5394. let IM = im;
  5395. }
  5396. // Multiclass wrapper on each of the _cw and _cs base classes, to
  5397. // generate three writeback modes (none, preindex, postindex).
  5398. multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz,
  5399. string asm, string suffix, bit U, bits<2> size> {
  5400. let AM = memsz.AM in {
  5401. def "" : MVE_VLDRSTR_cw<
  5402. dir, memsz, U, 1, 0, size,
  5403. dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
  5404. asm, suffix, IndexModeNone, "$Qd, $addr", "">;
  5405. def _pre : MVE_VLDRSTR_cw<
  5406. dir, memsz, U, 1, 1, size,
  5407. !con((outs tGPR:$wb), dir.Oops),
  5408. !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
  5409. asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
  5410. let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">";
  5411. }
  5412. def _post : MVE_VLDRSTR_cw<
  5413. dir, memsz, U, 0, 1, size,
  5414. !con((outs tGPR:$wb), dir.Oops),
  5415. !con(dir.Iops, (ins t_addr_offset_none:$Rn,
  5416. t2am_imm7_offset<memsz.shift>:$addr)),
  5417. asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
  5418. bits<4> Rn;
  5419. let Inst{18-16} = Rn{2-0};
  5420. }
  5421. }
  5422. }
  5423. multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz,
  5424. string asm, string suffix> {
  5425. let AM = memsz.AM in {
  5426. def "" : MVE_VLDRSTR_cs<
  5427. dir, memsz, 1, 0,
  5428. dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)),
  5429. asm, suffix, IndexModeNone, "$Qd, $addr", "">;
  5430. def _pre : MVE_VLDRSTR_cs<
  5431. dir, memsz, 1, 1,
  5432. !con((outs rGPR:$wb), dir.Oops),
  5433. !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)),
  5434. asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
  5435. let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">";
  5436. }
  5437. def _post : MVE_VLDRSTR_cs<
  5438. dir, memsz, 0, 1,
  5439. !con((outs rGPR:$wb), dir.Oops),
  5440. !con(dir.Iops, (ins t2_nosp_addr_offset_none:$Rn,
  5441. t2am_imm7_offset<memsz.shift>:$addr)),
  5442. asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
  5443. bits<4> Rn;
  5444. let Inst{19-16} = Rn{3-0};
  5445. }
  5446. }
  5447. }
  5448. // Now actually declare all the contiguous load/stores, via those
  5449. // multiclasses. The instruction ids coming out of this are the bare
  5450. // names shown in the defm, with _pre or _post appended for writeback,
  5451. // e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post.
  5452. defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>;
  5453. defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>;
  5454. defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>;
  5455. defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>;
  5456. defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>;
  5457. defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>;
  5458. defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">;
  5459. defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">;
  5460. defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">;
  5461. defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>;
  5462. defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>;
  5463. defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>;
  5464. defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">;
  5465. defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">;
  5466. defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">;
  5467. // Gather loads / scatter stores whose address operand is of the form
  5468. // [Rn,Qm], i.e. a single GPR as the common base address, plus a
  5469. // vector of offset from it. ('Load/store this sequence of elements of
  5470. // the same array.')
  5471. //
  5472. // Like the contiguous family, these loads and stores can widen the
  5473. // loaded values / truncate the stored ones, or they can just
  5474. // load/store the same size of memory and vector lane. But unlike the
  5475. // contiguous family, there's no particular difference in encoding
  5476. // between those two cases.
  5477. //
  5478. // This family also comes with the option to scale the offset values
  5479. // in Qm by the size of the loaded memory (i.e. to treat them as array
  5480. // indices), or not to scale them (to treat them as plain byte offsets
  5481. // in memory, so that perhaps the loaded values are unaligned). The
  5482. // scaled instructions' address operand in assembly looks like
  5483. // [Rn,Qm,UXTW #2] or similar.
  5484. // Base class.
  5485. class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
  5486. bits<2> size, bit os, string asm, string suffix, int shift>
  5487. : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops,
  5488. !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)),
  5489. asm, suffix, "$Qd, $addr", dir.cstr, size> {
  5490. bits<7> addr;
  5491. let Inst{23} = 0b1;
  5492. let Inst{19-16} = addr{6-3};
  5493. let Inst{8-7} = size;
  5494. let Inst{6} = memsz.encoding{1};
  5495. let Inst{5} = 0;
  5496. let Inst{4} = memsz.encoding{0};
  5497. let Inst{3-1} = addr{2-0};
  5498. let Inst{0} = os;
  5499. }
  5500. // Multiclass that defines the scaled and unscaled versions of an
  5501. // instruction, when the memory size is wider than a byte. The scaled
  5502. // version gets the default name like MVE_VLDRBU16_rq; the unscaled /
  5503. // potentially unaligned version gets a "_u" suffix, e.g.
  5504. // MVE_VLDRBU16_rq_u.
  5505. multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz,
  5506. string asm, string suffix, bit U, bits<2> size> {
  5507. def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
  5508. def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>;
  5509. }
  5510. // Subclass of MVE_VLDRSTR_rq with the same API as that multiclass,
  5511. // for use when the memory size is one byte, so there's no 'scaled'
  5512. // version of the instruction at all. (This is encoded as if it were
  5513. // unscaled, but named in the default way with no _u suffix.)
  5514. class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz,
  5515. string asm, string suffix, bit U, bits<2> size>
  5516. : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
  5517. // Multiclasses wrapping that to add ISel patterns for intrinsics.
  5518. multiclass MVE_VLDR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> {
  5519. defm "": MVE_VLDRSTR_rq_w<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter,
  5520. VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>;
  5521. defvar Inst = !cast<Instruction>(NAME);
  5522. defvar InstU = !cast<Instruction>(NAME # "_u");
  5523. foreach VTI = VTIs in
  5524. foreach UnsignedFlag = !if(!eq(VTI.Size, memsz.encoding),
  5525. [0,1], [VTI.Unsigned]) in {
  5526. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, 0, UnsignedFlag)),
  5527. (VTI.Vec (InstU GPR:$base, MQPR:$offsets))>;
  5528. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, memsz.shift, UnsignedFlag)),
  5529. (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>;
  5530. 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))),
  5531. (VTI.Vec (InstU GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
  5532. 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))),
  5533. (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
  5534. }
  5535. }
  5536. multiclass MVE_VLDR_rq_b<list<MVEVectorVTInfo> VTIs> {
  5537. def "": MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb",
  5538. VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>;
  5539. defvar Inst = !cast<Instruction>(NAME);
  5540. foreach VTI = VTIs in {
  5541. def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), 8, 0, VTI.Unsigned)),
  5542. (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>;
  5543. 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))),
  5544. (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
  5545. }
  5546. }
  5547. multiclass MVE_VSTR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> {
  5548. defm "": MVE_VLDRSTR_rq_w<MVE_st, memsz, "vstr" # memsz.MnemonicLetter,
  5549. VTIs[0].BitsSuffix, 0, VTIs[0].Size>;
  5550. defvar Inst = !cast<Instruction>(NAME);
  5551. defvar InstU = !cast<Instruction>(NAME # "_u");
  5552. foreach VTI = VTIs in {
  5553. def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, 0),
  5554. (InstU MQPR:$data, GPR:$base, MQPR:$offsets)>;
  5555. def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, memsz.shift),
  5556. (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>;
  5557. 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)),
  5558. (InstU MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
  5559. 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)),
  5560. (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
  5561. }
  5562. }
  5563. multiclass MVE_VSTR_rq_b<list<MVEVectorVTInfo> VTIs> {
  5564. def "": MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb",
  5565. VTIs[0].BitsSuffix, 0, VTIs[0].Size>;
  5566. defvar Inst = !cast<Instruction>(NAME);
  5567. foreach VTI = VTIs in {
  5568. def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), 8, 0),
  5569. (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>;
  5570. 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)),
  5571. (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
  5572. }
  5573. }
  5574. // Actually define all the loads and stores in this family.
  5575. defm MVE_VLDRBU8_rq : MVE_VLDR_rq_b<[MVE_v16u8,MVE_v16s8]>;
  5576. defm MVE_VLDRBU16_rq: MVE_VLDR_rq_b<[MVE_v8u16]>;
  5577. defm MVE_VLDRBS16_rq: MVE_VLDR_rq_b<[MVE_v8s16]>;
  5578. defm MVE_VLDRBU32_rq: MVE_VLDR_rq_b<[MVE_v4u32]>;
  5579. defm MVE_VLDRBS32_rq: MVE_VLDR_rq_b<[MVE_v4s32]>;
  5580. defm MVE_VLDRHU16_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v8u16,MVE_v8s16,MVE_v8f16]>;
  5581. defm MVE_VLDRHU32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4u32]>;
  5582. defm MVE_VLDRHS32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4s32]>;
  5583. defm MVE_VLDRWU32_rq: MVE_VLDR_rq_w<MVE_memW, [MVE_v4u32,MVE_v4s32,MVE_v4f32]>;
  5584. defm MVE_VLDRDU64_rq: MVE_VLDR_rq_w<MVE_memD, [MVE_v2u64,MVE_v2s64]>;
  5585. defm MVE_VSTRB8_rq : MVE_VSTR_rq_b<[MVE_v16i8]>;
  5586. defm MVE_VSTRB16_rq : MVE_VSTR_rq_b<[MVE_v8i16]>;
  5587. defm MVE_VSTRB32_rq : MVE_VSTR_rq_b<[MVE_v4i32]>;
  5588. defm MVE_VSTRH16_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v8i16,MVE_v8f16]>;
  5589. defm MVE_VSTRH32_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v4i32]>;
  5590. defm MVE_VSTRW32_rq : MVE_VSTR_rq_w<MVE_memW, [MVE_v4i32,MVE_v4f32]>;
  5591. defm MVE_VSTRD64_rq : MVE_VSTR_rq_w<MVE_memD, [MVE_v2i64]>;
  5592. // Gather loads / scatter stores whose address operand is of the form
  5593. // [Qm,#imm], i.e. a vector containing a full base address for each
  5594. // loaded item, plus an immediate offset applied consistently to all
  5595. // of them. ('Load/store the same field from this vector of pointers
  5596. // to a structure type.')
  5597. //
  5598. // This family requires the vector lane size to be at least 32 bits
  5599. // (so there's room for an address in each lane at all). It has no
  5600. // widening/narrowing variants. But it does support preindex
  5601. // writeback, in which the address vector is updated to hold the
  5602. // addresses actually loaded from.
  5603. // Base class.
  5604. class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops,
  5605. string asm, string wbAsm, string suffix, string cstr = "">
  5606. : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops),
  5607. !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)),
  5608. asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr, memsz.encoding> {
  5609. bits<11> addr;
  5610. let Inst{23} = addr{7};
  5611. let Inst{19-17} = addr{10-8};
  5612. let Inst{16} = 0;
  5613. let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit
  5614. let Inst{7} = 0;
  5615. let Inst{6-0} = addr{6-0};
  5616. }
  5617. // Multiclass that generates the non-writeback and writeback variants.
  5618. multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz,
  5619. string asm, string suffix> {
  5620. def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>;
  5621. def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix,
  5622. "$addr.base = $wb"> {
  5623. let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">";
  5624. }
  5625. }
  5626. // Multiclasses wrapping that one, adding selection patterns for the
  5627. // non-writeback loads and all the stores. (The writeback loads must
  5628. // deliver multiple output values, so they have to be selected by C++
  5629. // code.)
  5630. multiclass MVE_VLDR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI,
  5631. list<MVEVectorVTInfo> DVTIs> {
  5632. defm "" : MVE_VLDRSTR_qi_m<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter,
  5633. "u" # memsz.TypeBits>;
  5634. defvar Inst = !cast<Instruction>(NAME);
  5635. foreach DVTI = DVTIs in {
  5636. def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base
  5637. (AVTI.Vec MQPR:$addr), (i32 imm:$offset))),
  5638. (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset)))>;
  5639. def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base_predicated
  5640. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (AVTI.Pred VCCR:$pred))),
  5641. (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset),
  5642. ARMVCCThen, VCCR:$pred, zero_reg))>;
  5643. }
  5644. }
  5645. multiclass MVE_VSTR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI,
  5646. list<MVEVectorVTInfo> DVTIs> {
  5647. defm "" : MVE_VLDRSTR_qi_m<MVE_st, memsz, "vstr" # memsz.MnemonicLetter,
  5648. !cast<string>(memsz.TypeBits)>;
  5649. defvar Inst = !cast<Instruction>(NAME);
  5650. defvar InstPre = !cast<Instruction>(NAME # "_pre");
  5651. foreach DVTI = DVTIs in {
  5652. def : Pat<(int_arm_mve_vstr_scatter_base
  5653. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data)),
  5654. (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5655. (i32 imm:$offset))>;
  5656. def : Pat<(int_arm_mve_vstr_scatter_base_predicated
  5657. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred)),
  5658. (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5659. (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg)>;
  5660. def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb
  5661. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data))),
  5662. (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5663. (i32 imm:$offset)))>;
  5664. def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb_predicated
  5665. (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred))),
  5666. (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
  5667. (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg))>;
  5668. }
  5669. }
  5670. // Actual instruction definitions.
  5671. defm MVE_VLDRWU32_qi: MVE_VLDR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>;
  5672. defm MVE_VLDRDU64_qi: MVE_VLDR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>;
  5673. defm MVE_VSTRW32_qi: MVE_VSTR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>;
  5674. defm MVE_VSTRD64_qi: MVE_VSTR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>;
  5675. // Define aliases for all the instructions where memory size and
  5676. // vector lane size are the same. These are mnemonic aliases, so they
  5677. // apply consistently across all of the above families - contiguous
  5678. // loads, and both the rq and qi types of gather/scatter.
  5679. //
  5680. // Rationale: As long as you're loading (for example) 16-bit memory
  5681. // values into 16-bit vector lanes, you can think of them as signed or
  5682. // unsigned integers, fp16 or just raw 16-bit blobs and it makes no
  5683. // difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16,
  5684. // vldrh.f16 and treat them all as equivalent to the canonical
  5685. // spelling (which happens to be .u16 for loads, and just .16 for
  5686. // stores).
  5687. foreach vpt_cond = ["", "t", "e"] in
  5688. foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in
  5689. foreach suffix = memsz.suffixes in {
  5690. // Define an alias with every suffix in the list, except for the one
  5691. // used by the real Instruction record (i.e. the one that all the
  5692. // rest are aliases *for*).
  5693. if !ne(suffix, memsz.CanonLoadSuffix) then {
  5694. def : MnemonicAlias<
  5695. "vldr" # memsz.MnemonicLetter # vpt_cond # suffix,
  5696. "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>;
  5697. }
  5698. if !ne(suffix, memsz.CanonStoreSuffix) then {
  5699. def : MnemonicAlias<
  5700. "vstr" # memsz.MnemonicLetter # vpt_cond # suffix,
  5701. "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>;
  5702. }
  5703. }
  5704. // end of MVE predicable load/store
  5705. class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]>
  5706. : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", size, pattern> {
  5707. bits<3> fc;
  5708. bits<4> Mk;
  5709. bits<3> Qn;
  5710. let Inst{31-23} = 0b111111100;
  5711. let Inst{22} = Mk{3};
  5712. let Inst{21-20} = size;
  5713. let Inst{19-17} = Qn{2-0};
  5714. let Inst{16} = 0b1;
  5715. let Inst{15-13} = Mk{2-0};
  5716. let Inst{12} = fc{2};
  5717. let Inst{11-8} = 0b1111;
  5718. let Inst{7} = fc{0};
  5719. let Inst{4} = 0b0;
  5720. let Defs = [VPR];
  5721. let validForTailPredication=1;
  5722. }
  5723. class MVE_VPTt1<string suffix, bits<2> size, dag iops>
  5724. : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> {
  5725. bits<4> Qm;
  5726. bits<4> Mk;
  5727. let Inst{6} = 0b0;
  5728. let Inst{5} = Qm{3};
  5729. let Inst{3-1} = Qm{2-0};
  5730. let Inst{0} = fc{1};
  5731. }
  5732. class MVE_VPTt1i<string suffix, bits<2> size>
  5733. : MVE_VPTt1<suffix, size,
  5734. (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_i:$fc)> {
  5735. let Inst{12} = 0b0;
  5736. let Inst{0} = 0b0;
  5737. }
  5738. def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>;
  5739. def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>;
  5740. def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>;
  5741. class MVE_VPTt1u<string suffix, bits<2> size>
  5742. : MVE_VPTt1<suffix, size,
  5743. (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_u:$fc)> {
  5744. let Inst{12} = 0b0;
  5745. let Inst{0} = 0b1;
  5746. }
  5747. def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>;
  5748. def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>;
  5749. def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>;
  5750. class MVE_VPTt1s<string suffix, bits<2> size>
  5751. : MVE_VPTt1<suffix, size,
  5752. (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_s:$fc)> {
  5753. let Inst{12} = 0b1;
  5754. }
  5755. def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>;
  5756. def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>;
  5757. def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>;
  5758. class MVE_VPTt2<string suffix, bits<2> size, dag iops>
  5759. : MVE_VPT<suffix, size, iops,
  5760. "$fc, $Qn, $Rm"> {
  5761. bits<4> Rm;
  5762. bits<3> fc;
  5763. bits<4> Mk;
  5764. let Inst{6} = 0b1;
  5765. let Inst{5} = fc{1};
  5766. let Inst{3-0} = Rm{3-0};
  5767. }
  5768. class MVE_VPTt2i<string suffix, bits<2> size>
  5769. : MVE_VPTt2<suffix, size,
  5770. (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_i:$fc)> {
  5771. let Inst{12} = 0b0;
  5772. let Inst{5} = 0b0;
  5773. }
  5774. def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>;
  5775. def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>;
  5776. def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>;
  5777. class MVE_VPTt2u<string suffix, bits<2> size>
  5778. : MVE_VPTt2<suffix, size,
  5779. (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_u:$fc)> {
  5780. let Inst{12} = 0b0;
  5781. let Inst{5} = 0b1;
  5782. }
  5783. def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>;
  5784. def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>;
  5785. def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>;
  5786. class MVE_VPTt2s<string suffix, bits<2> size>
  5787. : MVE_VPTt2<suffix, size,
  5788. (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_s:$fc)> {
  5789. let Inst{12} = 0b1;
  5790. }
  5791. def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>;
  5792. def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>;
  5793. def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>;
  5794. class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]>
  5795. : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm,
  5796. "", !if(size, 0b01, 0b10), pattern> {
  5797. bits<3> fc;
  5798. bits<4> Mk;
  5799. bits<3> Qn;
  5800. let Inst{31-29} = 0b111;
  5801. let Inst{28} = size;
  5802. let Inst{27-23} = 0b11100;
  5803. let Inst{22} = Mk{3};
  5804. let Inst{21-20} = 0b11;
  5805. let Inst{19-17} = Qn{2-0};
  5806. let Inst{16} = 0b1;
  5807. let Inst{15-13} = Mk{2-0};
  5808. let Inst{12} = fc{2};
  5809. let Inst{11-8} = 0b1111;
  5810. let Inst{7} = fc{0};
  5811. let Inst{4} = 0b0;
  5812. let Defs = [VPR];
  5813. let Predicates = [HasMVEFloat];
  5814. let validForTailPredication=1;
  5815. }
  5816. class MVE_VPTft1<string suffix, bit size>
  5817. : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_fp:$fc),
  5818. "$fc, $Qn, $Qm"> {
  5819. bits<3> fc;
  5820. bits<4> Qm;
  5821. let Inst{6} = 0b0;
  5822. let Inst{5} = Qm{3};
  5823. let Inst{3-1} = Qm{2-0};
  5824. let Inst{0} = fc{1};
  5825. }
  5826. def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>;
  5827. def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>;
  5828. class MVE_VPTft2<string suffix, bit size>
  5829. : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_fp:$fc),
  5830. "$fc, $Qn, $Rm"> {
  5831. bits<3> fc;
  5832. bits<4> Rm;
  5833. let Inst{6} = 0b1;
  5834. let Inst{5} = fc{1};
  5835. let Inst{3-0} = Rm{3-0};
  5836. }
  5837. def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>;
  5838. def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>;
  5839. def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary,
  5840. !strconcat("vpst", "${Mk}"), "", "", 0b00, []> {
  5841. bits<4> Mk;
  5842. let Inst{31-23} = 0b111111100;
  5843. let Inst{22} = Mk{3};
  5844. let Inst{21-16} = 0b110001;
  5845. let Inst{15-13} = Mk{2-0};
  5846. let Inst{12-0} = 0b0111101001101;
  5847. let Unpredictable{12} = 0b1;
  5848. let Unpredictable{7} = 0b1;
  5849. let Unpredictable{5} = 0b1;
  5850. let Uses = [VPR];
  5851. let validForTailPredication = 1;
  5852. }
  5853. def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
  5854. "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", 0b00, []> {
  5855. bits<4> Qn;
  5856. bits<4> Qd;
  5857. bits<4> Qm;
  5858. let Inst{28} = 0b1;
  5859. let Inst{25-23} = 0b100;
  5860. let Inst{22} = Qd{3};
  5861. let Inst{21-20} = 0b11;
  5862. let Inst{19-17} = Qn{2-0};
  5863. let Inst{16} = 0b1;
  5864. let Inst{15-13} = Qd{2-0};
  5865. let Inst{12-9} = 0b0111;
  5866. let Inst{8} = 0b1;
  5867. let Inst{7} = Qn{3};
  5868. let Inst{6} = 0b0;
  5869. let Inst{5} = Qm{3};
  5870. let Inst{4} = 0b0;
  5871. let Inst{3-1} = Qm{2-0};
  5872. let Inst{0} = 0b1;
  5873. }
  5874. foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32",
  5875. "i8", "i16", "i32", "f16", "f32"] in
  5876. def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm",
  5877. (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
  5878. let Predicates = [HasMVEInt] in {
  5879. def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
  5880. (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5881. def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
  5882. (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5883. def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
  5884. (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5885. def : Pat<(v2i64 (vselect (v2i1 VCCR:$pred), (v2i64 MQPR:$v1), (v2i64 MQPR:$v2))),
  5886. (v2i64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5887. def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
  5888. (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5889. def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
  5890. (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5891. def : Pat<(v2f64 (vselect (v2i1 VCCR:$pred), (v2f64 MQPR:$v1), (v2f64 MQPR:$v2))),
  5892. (v2f64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
  5893. def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
  5894. (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5895. (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), ARMCCne), zero_reg))>;
  5896. def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
  5897. (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5898. (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>;
  5899. def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
  5900. (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5901. (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>;
  5902. def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
  5903. (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5904. (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>;
  5905. def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
  5906. (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
  5907. (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>;
  5908. // Pred <-> Int
  5909. def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))),
  5910. (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5911. def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))),
  5912. (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5913. def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))),
  5914. (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5915. def : Pat<(v2i64 (zext (v2i1 VCCR:$pred))),
  5916. (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5917. def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))),
  5918. (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5919. def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))),
  5920. (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5921. def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))),
  5922. (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5923. def : Pat<(v2i64 (sext (v2i1 VCCR:$pred))),
  5924. (v2i64 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5925. def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))),
  5926. (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5927. def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))),
  5928. (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5929. def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))),
  5930. (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5931. def : Pat<(v2i64 (anyext (v2i1 VCCR:$pred))),
  5932. (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5933. }
  5934. let Predicates = [HasMVEFloat] in {
  5935. // Pred <-> Float
  5936. // 112 is 1.0 in float
  5937. def : Pat<(v4f32 (uint_to_fp (v4i1 VCCR:$pred))),
  5938. (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 112)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5939. // 2620 in 1.0 in half
  5940. def : Pat<(v8f16 (uint_to_fp (v8i1 VCCR:$pred))),
  5941. (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2620)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5942. // 240 is -1.0 in float
  5943. def : Pat<(v4f32 (sint_to_fp (v4i1 VCCR:$pred))),
  5944. (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 240)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5945. // 2748 is -1.0 in half
  5946. def : Pat<(v8f16 (sint_to_fp (v8i1 VCCR:$pred))),
  5947. (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2748)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
  5948. def : Pat<(v4i1 (fp_to_uint (v4f32 MQPR:$v1))),
  5949. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>;
  5950. def : Pat<(v8i1 (fp_to_uint (v8f16 MQPR:$v1))),
  5951. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>;
  5952. def : Pat<(v4i1 (fp_to_sint (v4f32 MQPR:$v1))),
  5953. (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>;
  5954. def : Pat<(v8i1 (fp_to_sint (v8f16 MQPR:$v1))),
  5955. (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>;
  5956. }
  5957. def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary,
  5958. "vpnot", "", "", vpred_n, "", 0b00, []> {
  5959. let Inst{31-0} = 0b11111110001100010000111101001101;
  5960. let Unpredictable{19-17} = 0b111;
  5961. let Unpredictable{12} = 0b1;
  5962. let Unpredictable{7} = 0b1;
  5963. let Unpredictable{5} = 0b1;
  5964. let Constraints = "";
  5965. let DecoderMethod = "DecodeMVEVPNOT";
  5966. }
  5967. let Predicates = [HasMVEInt] in {
  5968. def : Pat<(v2i1 (xor (v2i1 VCCR:$pred), (v2i1 (predicate_cast (i32 65535))))),
  5969. (v2i1 (MVE_VPNOT (v2i1 VCCR:$pred)))>;
  5970. def : Pat<(v4i1 (xor (v4i1 VCCR:$pred), (v4i1 (predicate_cast (i32 65535))))),
  5971. (v4i1 (MVE_VPNOT (v4i1 VCCR:$pred)))>;
  5972. def : Pat<(v8i1 (xor (v8i1 VCCR:$pred), (v8i1 (predicate_cast (i32 65535))))),
  5973. (v8i1 (MVE_VPNOT (v8i1 VCCR:$pred)))>;
  5974. def : Pat<(v16i1 (xor (v16i1 VCCR:$pred), (v16i1 (predicate_cast (i32 65535))))),
  5975. (v16i1 (MVE_VPNOT (v16i1 VCCR:$pred)))>;
  5976. }
  5977. class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size>
  5978. : t2LOL<(outs GPRlr:$LR), iops, asm, ops> {
  5979. bits<4> Rn;
  5980. let Predicates = [HasMVEInt];
  5981. let Inst{22} = 0b0;
  5982. let Inst{21-20} = size;
  5983. let Inst{19-16} = Rn{3-0};
  5984. let Inst{12} = 0b0;
  5985. }
  5986. class MVE_DLSTP<string asm, bits<2> size>
  5987. : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> {
  5988. let Inst{13} = 0b1;
  5989. let Inst{11-1} = 0b00000000000;
  5990. let Unpredictable{10-1} = 0b1111111111;
  5991. }
  5992. class MVE_WLSTP<string asm, bits<2> size>
  5993. : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label),
  5994. asm, "$LR, $Rn, $label", size> {
  5995. bits<11> label;
  5996. let Inst{13} = 0b0;
  5997. let Inst{11} = label{0};
  5998. let Inst{10-1} = label{10-1};
  5999. let isBranch = 1;
  6000. let isTerminator = 1;
  6001. }
  6002. def SDT_MVEMEMCPYLOOPNODE
  6003. : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
  6004. def MVE_MEMCPYLOOPNODE : SDNode<"ARMISD::MEMCPYLOOP", SDT_MVEMEMCPYLOOPNODE,
  6005. [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
  6006. let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in {
  6007. def MVE_MEMCPYLOOPINST : PseudoInst<(outs),
  6008. (ins rGPR:$dst, rGPR:$src, rGPR:$sz),
  6009. NoItinerary,
  6010. [(MVE_MEMCPYLOOPNODE rGPR:$dst, rGPR:$src, rGPR:$sz)]>;
  6011. }
  6012. def SDT_MVEMEMSETLOOPNODE
  6013. : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisVT<1, v16i8>, SDTCisVT<2, i32>]>;
  6014. def MVE_MEMSETLOOPNODE : SDNode<"ARMISD::MEMSETLOOP", SDT_MVEMEMSETLOOPNODE,
  6015. [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
  6016. let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in {
  6017. def MVE_MEMSETLOOPINST : PseudoInst<(outs),
  6018. (ins rGPR:$dst, MQPR:$src, rGPR:$sz),
  6019. NoItinerary,
  6020. [(MVE_MEMSETLOOPNODE rGPR:$dst, MQPR:$src, rGPR:$sz)]>;
  6021. }
  6022. def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>;
  6023. def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>;
  6024. def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>;
  6025. def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>;
  6026. def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>;
  6027. def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>;
  6028. def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>;
  6029. def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>;
  6030. class MVE_loltp_end<dag oops, dag iops, string asm, string ops>
  6031. : t2LOL<oops, iops, asm, ops> {
  6032. let Predicates = [HasMVEInt];
  6033. let Inst{22-21} = 0b00;
  6034. let Inst{19-16} = 0b1111;
  6035. let Inst{12} = 0b0;
  6036. }
  6037. def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout),
  6038. (ins GPRlr:$LRin, lelabel_u11:$label),
  6039. "letp", "$LRin, $label"> {
  6040. bits<11> label;
  6041. let Inst{20} = 0b1;
  6042. let Inst{13} = 0b0;
  6043. let Inst{11} = label{0};
  6044. let Inst{10-1} = label{10-1};
  6045. let isBranch = 1;
  6046. let isTerminator = 1;
  6047. }
  6048. def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> {
  6049. let Inst{20} = 0b0;
  6050. let Inst{13} = 0b1;
  6051. let Inst{11-1} = 0b00000000000;
  6052. let Unpredictable{21-20} = 0b11;
  6053. let Unpredictable{11-1} = 0b11111111111;
  6054. }
  6055. // Pseudo instructions for lowering MQQPR and MQQQQPR stack spills and reloads.
  6056. // They are equivalent to VLDMDIA/VSTMDIA with a single reg, as opposed to multiple
  6057. // dreg subregs.
  6058. let Predicates = [HasMVEInt], AM = AddrMode4 in {
  6059. let mayStore = 1, hasSideEffects = 0 in {
  6060. def MQQPRStore : t2PseudoInst<(outs), (ins MQQPR:$val, GPRnopc:$ptr),
  6061. 4, NoItinerary, []>;
  6062. def MQQQQPRStore : t2PseudoInst<(outs), (ins MQQQQPR:$val, GPRnopc:$ptr),
  6063. 4, NoItinerary, []>;
  6064. }
  6065. let mayLoad = 1, hasSideEffects = 0 in {
  6066. def MQQPRLoad : t2PseudoInst<(outs MQQPR:$val), (ins GPRnopc:$ptr),
  6067. 4, NoItinerary, []>;
  6068. def MQQQQPRLoad : t2PseudoInst<(outs MQQQQPR:$val), (ins GPRnopc:$ptr),
  6069. 4, NoItinerary, []>;
  6070. }
  6071. }
  6072. // Pseudo for lowering MVE Q register COPYs. These will usually get converted
  6073. // to a "MVE_VORR dst, src, src", but may behave differently in tail predicated
  6074. // loops to ensure the whole register is copied, not a subset from a
  6075. // tail-predicated MVE_VORR. In the event we cannot prove a MVE_VORR is valid,
  6076. // it will become a pair of VMOVD instructions for each half of the Q register.
  6077. let Predicates = [HasMVEInt], hasSideEffects = 0, isMoveReg = 1,
  6078. D = MVEDomain in {
  6079. def MQPRCopy : t2PseudoInst<(outs MQPR:$dst), (ins MQPR:$src),
  6080. 8, NoItinerary, []>;
  6081. }
  6082. //===----------------------------------------------------------------------===//
  6083. // Patterns
  6084. //===----------------------------------------------------------------------===//
  6085. // PatFrags for loads and stores. Often trying to keep semi-consistent names.
  6086. def aligned32_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6087. (pre_store node:$val, node:$ptr, node:$offset), [{
  6088. return cast<StoreSDNode>(N)->getAlign() >= 4;
  6089. }]>;
  6090. def aligned32_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6091. (post_store node:$val, node:$ptr, node:$offset), [{
  6092. return cast<StoreSDNode>(N)->getAlign() >= 4;
  6093. }]>;
  6094. def aligned16_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6095. (pre_store node:$val, node:$ptr, node:$offset), [{
  6096. return cast<StoreSDNode>(N)->getAlign() >= 2;
  6097. }]>;
  6098. def aligned16_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  6099. (post_store node:$val, node:$ptr, node:$offset), [{
  6100. return cast<StoreSDNode>(N)->getAlign() >= 2;
  6101. }]>;
  6102. def aligned_maskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6103. (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
  6104. auto *Ld = cast<MaskedLoadSDNode>(N);
  6105. return Ld->getMemoryVT().getScalarType() == MVT::i8;
  6106. }]>;
  6107. def aligned_sextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6108. (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
  6109. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
  6110. }]>;
  6111. def aligned_zextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6112. (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
  6113. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
  6114. }]>;
  6115. def aligned_extmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6116. (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
  6117. auto *Ld = cast<MaskedLoadSDNode>(N);
  6118. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6119. return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
  6120. }]>;
  6121. def aligned_maskedloadvi16: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6122. (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
  6123. auto *Ld = cast<MaskedLoadSDNode>(N);
  6124. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6125. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && Ld->getAlign() >= 2;
  6126. }]>;
  6127. def aligned_sextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6128. (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
  6129. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
  6130. }]>;
  6131. def aligned_zextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6132. (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
  6133. return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
  6134. }]>;
  6135. def aligned_extmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6136. (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
  6137. auto *Ld = cast<MaskedLoadSDNode>(N);
  6138. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6139. return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
  6140. }]>;
  6141. def aligned_maskedloadvi32: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
  6142. (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
  6143. auto *Ld = cast<MaskedLoadSDNode>(N);
  6144. EVT ScalarVT = Ld->getMemoryVT().getScalarType();
  6145. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && Ld->getAlign() >= 4;
  6146. }]>;
  6147. def aligned_maskedstvi8 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
  6148. (masked_st node:$val, node:$ptr, undef, node:$pred), [{
  6149. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6150. }]>;
  6151. def aligned_maskedstvi16 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
  6152. (masked_st node:$val, node:$ptr, undef, node:$pred), [{
  6153. auto *St = cast<MaskedStoreSDNode>(N);
  6154. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6155. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
  6156. }]>;
  6157. def aligned_maskedstvi32 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
  6158. (masked_st node:$val, node:$ptr, undef, node:$pred), [{
  6159. auto *St = cast<MaskedStoreSDNode>(N);
  6160. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6161. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4;
  6162. }]>;
  6163. def pre_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask),
  6164. (masked_st node:$val, node:$base, node:$offset, node:$mask), [{
  6165. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6166. return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
  6167. }]>;
  6168. def post_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask),
  6169. (masked_st node:$val, node:$base, node:$offset, node:$mask), [{
  6170. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6171. return AM == ISD::POST_INC || AM == ISD::POST_DEC;
  6172. }]>;
  6173. def aligned_pre_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6174. (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6175. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6176. }]>;
  6177. def aligned_post_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6178. (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6179. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6180. }]>;
  6181. def aligned_pre_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6182. (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6183. auto *St = cast<MaskedStoreSDNode>(N);
  6184. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6185. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
  6186. }]>;
  6187. def aligned_post_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6188. (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6189. auto *St = cast<MaskedStoreSDNode>(N);
  6190. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6191. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
  6192. }]>;
  6193. def aligned_pre_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6194. (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6195. auto *St = cast<MaskedStoreSDNode>(N);
  6196. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6197. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4;
  6198. }]>;
  6199. def aligned_post_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
  6200. (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
  6201. auto *St = cast<MaskedStoreSDNode>(N);
  6202. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6203. return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4;
  6204. }]>;
  6205. // PatFrags for "Aligned" extending / truncating
  6206. def aligned_extloadvi8 : PatFrag<(ops node:$ptr), (extloadvi8 node:$ptr)>;
  6207. def aligned_sextloadvi8 : PatFrag<(ops node:$ptr), (sextloadvi8 node:$ptr)>;
  6208. def aligned_zextloadvi8 : PatFrag<(ops node:$ptr), (zextloadvi8 node:$ptr)>;
  6209. def aligned_truncstvi8 : PatFrag<(ops node:$val, node:$ptr),
  6210. (truncstorevi8 node:$val, node:$ptr)>;
  6211. def aligned_post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6212. (post_truncstvi8 node:$val, node:$base, node:$offset)>;
  6213. def aligned_pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6214. (pre_truncstvi8 node:$val, node:$base, node:$offset)>;
  6215. let MinAlignment = 2 in {
  6216. def aligned_extloadvi16 : PatFrag<(ops node:$ptr), (extloadvi16 node:$ptr)>;
  6217. def aligned_sextloadvi16 : PatFrag<(ops node:$ptr), (sextloadvi16 node:$ptr)>;
  6218. def aligned_zextloadvi16 : PatFrag<(ops node:$ptr), (zextloadvi16 node:$ptr)>;
  6219. def aligned_truncstvi16 : PatFrag<(ops node:$val, node:$ptr),
  6220. (truncstorevi16 node:$val, node:$ptr)>;
  6221. def aligned_post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6222. (post_truncstvi16 node:$val, node:$base, node:$offset)>;
  6223. def aligned_pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  6224. (pre_truncstvi16 node:$val, node:$base, node:$offset)>;
  6225. }
  6226. def truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$pred),
  6227. (masked_st node:$val, node:$base, undef, node:$pred), [{
  6228. return cast<MaskedStoreSDNode>(N)->isTruncatingStore();
  6229. }]>;
  6230. def aligned_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$pred),
  6231. (truncmaskedst node:$val, node:$base, node:$pred), [{
  6232. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6233. }]>;
  6234. def aligned_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$pred),
  6235. (truncmaskedst node:$val, node:$base, node:$pred), [{
  6236. auto *St = cast<MaskedStoreSDNode>(N);
  6237. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6238. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
  6239. }]>;
  6240. def pre_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
  6241. (masked_st node:$val, node:$base, node:$offset, node:$pred), [{
  6242. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6243. return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::PRE_INC || AM == ISD::PRE_DEC);
  6244. }]>;
  6245. def aligned_pre_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
  6246. (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{
  6247. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6248. }]>;
  6249. def aligned_pre_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
  6250. (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{
  6251. auto *St = cast<MaskedStoreSDNode>(N);
  6252. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6253. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
  6254. }]>;
  6255. def post_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
  6256. (masked_st node:$val, node:$base, node:$offset, node:$postd), [{
  6257. ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
  6258. return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::POST_INC || AM == ISD::POST_DEC);
  6259. }]>;
  6260. def aligned_post_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
  6261. (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{
  6262. return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
  6263. }]>;
  6264. def aligned_post_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
  6265. (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{
  6266. auto *St = cast<MaskedStoreSDNode>(N);
  6267. EVT ScalarVT = St->getMemoryVT().getScalarType();
  6268. return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
  6269. }]>;
  6270. // Load/store patterns
  6271. class MVE_vector_store_typed<ValueType Ty, Instruction RegImmInst,
  6272. PatFrag StoreKind, int shift>
  6273. : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr),
  6274. (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>;
  6275. class MVE_vector_maskedstore_typed<ValueType Ty, Instruction RegImmInst,
  6276. PatFrag StoreKind, int shift>
  6277. : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, VCCR:$pred),
  6278. (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6279. multiclass MVE_vector_store<Instruction RegImmInst, PatFrag StoreKind,
  6280. int shift> {
  6281. def : MVE_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>;
  6282. def : MVE_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>;
  6283. def : MVE_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>;
  6284. def : MVE_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>;
  6285. def : MVE_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>;
  6286. def : MVE_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>;
  6287. def : MVE_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>;
  6288. }
  6289. class MVE_vector_load_typed<ValueType Ty, Instruction RegImmInst,
  6290. PatFrag LoadKind, int shift>
  6291. : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)),
  6292. (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>;
  6293. class MVE_vector_maskedload_typed<ValueType Ty, Instruction RegImmInst,
  6294. PatFrag LoadKind, int shift>
  6295. : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr, VCCR:$pred, (Ty (ARMvmovImm (i32 0))))),
  6296. (Ty (RegImmInst t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6297. multiclass MVE_vector_load<Instruction RegImmInst, PatFrag LoadKind,
  6298. int shift> {
  6299. def : MVE_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>;
  6300. def : MVE_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>;
  6301. def : MVE_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>;
  6302. def : MVE_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>;
  6303. def : MVE_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>;
  6304. def : MVE_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>;
  6305. def : MVE_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>;
  6306. }
  6307. class MVE_vector_offset_store_typed<ValueType Ty, Instruction Opcode,
  6308. PatFrag StoreKind, int shift>
  6309. : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr),
  6310. (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr)>;
  6311. class MVE_vector_offset_maskedstore_typed<ValueType Ty, Instruction Opcode,
  6312. PatFrag StoreKind, int shift>
  6313. : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr, VCCR:$pred),
  6314. (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6315. multiclass MVE_vector_offset_store<Instruction RegImmInst, PatFrag StoreKind,
  6316. int shift> {
  6317. def : MVE_vector_offset_store_typed<v16i8, RegImmInst, StoreKind, shift>;
  6318. def : MVE_vector_offset_store_typed<v8i16, RegImmInst, StoreKind, shift>;
  6319. def : MVE_vector_offset_store_typed<v8f16, RegImmInst, StoreKind, shift>;
  6320. def : MVE_vector_offset_store_typed<v4i32, RegImmInst, StoreKind, shift>;
  6321. def : MVE_vector_offset_store_typed<v4f32, RegImmInst, StoreKind, shift>;
  6322. def : MVE_vector_offset_store_typed<v2i64, RegImmInst, StoreKind, shift>;
  6323. def : MVE_vector_offset_store_typed<v2f64, RegImmInst, StoreKind, shift>;
  6324. }
  6325. let Predicates = [HasMVEInt, IsLE] in {
  6326. // Stores
  6327. defm : MVE_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>;
  6328. defm : MVE_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>;
  6329. defm : MVE_vector_store<MVE_VSTRWU32, alignedstore32, 2>;
  6330. // Loads
  6331. defm : MVE_vector_load<MVE_VLDRBU8, byte_alignedload, 0>;
  6332. defm : MVE_vector_load<MVE_VLDRHU16, hword_alignedload, 1>;
  6333. defm : MVE_vector_load<MVE_VLDRWU32, alignedload32, 2>;
  6334. // Pre/post inc stores
  6335. defm : MVE_vector_offset_store<MVE_VSTRBU8_pre, pre_store, 0>;
  6336. defm : MVE_vector_offset_store<MVE_VSTRBU8_post, post_store, 0>;
  6337. defm : MVE_vector_offset_store<MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
  6338. defm : MVE_vector_offset_store<MVE_VSTRHU16_post, aligned16_post_store, 1>;
  6339. defm : MVE_vector_offset_store<MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
  6340. defm : MVE_vector_offset_store<MVE_VSTRWU32_post, aligned32_post_store, 2>;
  6341. }
  6342. let Predicates = [HasMVEInt, IsBE] in {
  6343. // Aligned Stores
  6344. def : MVE_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>;
  6345. def : MVE_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>;
  6346. def : MVE_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>;
  6347. def : MVE_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>;
  6348. def : MVE_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>;
  6349. // Aligned Loads
  6350. def : MVE_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>;
  6351. def : MVE_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>;
  6352. def : MVE_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>;
  6353. def : MVE_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>;
  6354. def : MVE_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>;
  6355. // Other unaligned loads/stores need to go though a VREV
  6356. def : Pat<(v2f64 (load t2addrmode_imm7<0>:$addr)),
  6357. (v2f64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6358. def : Pat<(v2i64 (load t2addrmode_imm7<0>:$addr)),
  6359. (v2i64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6360. def : Pat<(v4i32 (load t2addrmode_imm7<0>:$addr)),
  6361. (v4i32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6362. def : Pat<(v4f32 (load t2addrmode_imm7<0>:$addr)),
  6363. (v4f32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6364. def : Pat<(v8i16 (load t2addrmode_imm7<0>:$addr)),
  6365. (v8i16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6366. def : Pat<(v8f16 (load t2addrmode_imm7<0>:$addr)),
  6367. (v8f16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
  6368. def : Pat<(store (v2f64 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6369. (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6370. def : Pat<(store (v2i64 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6371. (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6372. def : Pat<(store (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6373. (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6374. def : Pat<(store (v4f32 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6375. (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6376. def : Pat<(store (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6377. (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6378. def : Pat<(store (v8f16 MQPR:$val), t2addrmode_imm7<0>:$addr),
  6379. (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
  6380. // Pre/Post inc stores
  6381. def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_pre, pre_store, 0>;
  6382. def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_post, post_store, 0>;
  6383. def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
  6384. def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
  6385. def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
  6386. def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
  6387. def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
  6388. def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
  6389. def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
  6390. def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
  6391. }
  6392. let Predicates = [HasMVEInt] in {
  6393. // Aligned masked store, shared between LE and BE
  6394. def : MVE_vector_maskedstore_typed<v16i8, MVE_VSTRBU8, aligned_maskedstvi8, 0>;
  6395. def : MVE_vector_maskedstore_typed<v8i16, MVE_VSTRHU16, aligned_maskedstvi16, 1>;
  6396. def : MVE_vector_maskedstore_typed<v8f16, MVE_VSTRHU16, aligned_maskedstvi16, 1>;
  6397. def : MVE_vector_maskedstore_typed<v4i32, MVE_VSTRWU32, aligned_maskedstvi32, 2>;
  6398. def : MVE_vector_maskedstore_typed<v4f32, MVE_VSTRWU32, aligned_maskedstvi32, 2>;
  6399. // Pre/Post inc masked stores
  6400. def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_pre, aligned_pre_maskedstorevi8, 0>;
  6401. def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_post, aligned_post_maskedstorevi8, 0>;
  6402. def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>;
  6403. def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>;
  6404. def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>;
  6405. def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>;
  6406. def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>;
  6407. def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>;
  6408. def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>;
  6409. def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>;
  6410. // Aligned masked loads
  6411. def : MVE_vector_maskedload_typed<v16i8, MVE_VLDRBU8, aligned_maskedloadvi8, 0>;
  6412. def : MVE_vector_maskedload_typed<v8i16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>;
  6413. def : MVE_vector_maskedload_typed<v8f16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>;
  6414. def : MVE_vector_maskedload_typed<v4i32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>;
  6415. def : MVE_vector_maskedload_typed<v4f32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>;
  6416. }
  6417. // Widening/Narrowing Loads/Stores
  6418. multiclass MVEExtLoadStore<Instruction LoadSInst, Instruction LoadUInst, string StoreInst,
  6419. string Amble, ValueType VT, int Shift> {
  6420. // Trunc stores
  6421. def : Pat<(!cast<PatFrag>("aligned_truncst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr),
  6422. (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr)>;
  6423. def : Pat<(!cast<PatFrag>("aligned_post_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr),
  6424. (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>;
  6425. def : Pat<(!cast<PatFrag>("aligned_pre_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr),
  6426. (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>;
  6427. // Masked trunc stores
  6428. def : Pat<(!cast<PatFrag>("aligned_truncmaskedst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr, VCCR:$pred),
  6429. (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6430. def : Pat<(!cast<PatFrag>("aligned_post_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred),
  6431. (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6432. def : Pat<(!cast<PatFrag>("aligned_pre_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred),
  6433. (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
  6434. // Ext loads
  6435. def : Pat<(VT (!cast<PatFrag>("aligned_extload"#Amble) taddrmode_imm7<Shift>:$addr)),
  6436. (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>;
  6437. def : Pat<(VT (!cast<PatFrag>("aligned_sextload"#Amble) taddrmode_imm7<Shift>:$addr)),
  6438. (VT (LoadSInst taddrmode_imm7<Shift>:$addr))>;
  6439. def : Pat<(VT (!cast<PatFrag>("aligned_zextload"#Amble) taddrmode_imm7<Shift>:$addr)),
  6440. (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>;
  6441. // Masked ext loads
  6442. def : Pat<(VT (!cast<PatFrag>("aligned_extmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
  6443. (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6444. def : Pat<(VT (!cast<PatFrag>("aligned_sextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
  6445. (VT (LoadSInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6446. def : Pat<(VT (!cast<PatFrag>("aligned_zextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
  6447. (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
  6448. }
  6449. let Predicates = [HasMVEInt] in {
  6450. defm : MVEExtLoadStore<MVE_VLDRBS16, MVE_VLDRBU16, "MVE_VSTRB16", "vi8", v8i16, 0>;
  6451. defm : MVEExtLoadStore<MVE_VLDRBS32, MVE_VLDRBU32, "MVE_VSTRB32", "vi8", v4i32, 0>;
  6452. defm : MVEExtLoadStore<MVE_VLDRHS32, MVE_VLDRHU32, "MVE_VSTRH32", "vi16", v4i32, 1>;
  6453. }
  6454. // Bit convert patterns
  6455. let Predicates = [HasMVEInt] in {
  6456. def : Pat<(v2f64 (bitconvert (v2i64 MQPR:$src))), (v2f64 MQPR:$src)>;
  6457. def : Pat<(v2i64 (bitconvert (v2f64 MQPR:$src))), (v2i64 MQPR:$src)>;
  6458. def : Pat<(v4i32 (bitconvert (v4f32 MQPR:$src))), (v4i32 MQPR:$src)>;
  6459. def : Pat<(v4f32 (bitconvert (v4i32 MQPR:$src))), (v4f32 MQPR:$src)>;
  6460. def : Pat<(v8i16 (bitconvert (v8f16 MQPR:$src))), (v8i16 MQPR:$src)>;
  6461. def : Pat<(v8f16 (bitconvert (v8i16 MQPR:$src))), (v8f16 MQPR:$src)>;
  6462. }
  6463. let Predicates = [IsLE,HasMVEInt] in {
  6464. def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 MQPR:$src)>;
  6465. def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 MQPR:$src)>;
  6466. def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 MQPR:$src)>;
  6467. def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 MQPR:$src)>;
  6468. def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 MQPR:$src)>;
  6469. def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 MQPR:$src)>;
  6470. def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 MQPR:$src)>;
  6471. def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 MQPR:$src)>;
  6472. def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 MQPR:$src)>;
  6473. def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 MQPR:$src)>;
  6474. def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 MQPR:$src)>;
  6475. def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 MQPR:$src)>;
  6476. def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 MQPR:$src)>;
  6477. def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 MQPR:$src)>;
  6478. def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 MQPR:$src)>;
  6479. def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 MQPR:$src)>;
  6480. def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 MQPR:$src)>;
  6481. def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 MQPR:$src)>;
  6482. def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 MQPR:$src)>;
  6483. def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 MQPR:$src)>;
  6484. def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 MQPR:$src)>;
  6485. def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 MQPR:$src)>;
  6486. def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 MQPR:$src)>;
  6487. def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 MQPR:$src)>;
  6488. def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 MQPR:$src)>;
  6489. def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 MQPR:$src)>;
  6490. def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 MQPR:$src)>;
  6491. def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 MQPR:$src)>;
  6492. def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 MQPR:$src)>;
  6493. def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 MQPR:$src)>;
  6494. def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 MQPR:$src)>;
  6495. def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 MQPR:$src)>;
  6496. def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 MQPR:$src)>;
  6497. def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 MQPR:$src)>;
  6498. def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 MQPR:$src)>;
  6499. def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 MQPR:$src)>;
  6500. }
  6501. let Predicates = [IsBE,HasMVEInt] in {
  6502. def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
  6503. def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
  6504. def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
  6505. def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
  6506. def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 (MVE_VREV64_8 MQPR:$src))>;
  6507. def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
  6508. def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
  6509. def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
  6510. def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
  6511. def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 (MVE_VREV64_8 MQPR:$src))>;
  6512. def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
  6513. def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
  6514. def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
  6515. def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
  6516. def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 (MVE_VREV32_8 MQPR:$src))>;
  6517. def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
  6518. def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
  6519. def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
  6520. def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
  6521. def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 (MVE_VREV32_8 MQPR:$src))>;
  6522. def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
  6523. def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
  6524. def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
  6525. def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
  6526. def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 (MVE_VREV16_8 MQPR:$src))>;
  6527. def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
  6528. def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
  6529. def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
  6530. def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
  6531. def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 (MVE_VREV16_8 MQPR:$src))>;
  6532. def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
  6533. def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
  6534. def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
  6535. def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
  6536. def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;
  6537. def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;
  6538. }