SVEInstrFormats.td 347 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515
  1. //=-- SVEInstrFormats.td - AArch64 SVE Instruction classes -*- 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. // AArch64 Scalable Vector Extension (SVE) Instruction Class Definitions.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. def SDT_AArch64Setcc : SDTypeProfile<1, 4, [
  13. SDTCisVec<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisVec<3>,
  14. SDTCVecEltisVT<0, i1>, SDTCVecEltisVT<1, i1>, SDTCisSameAs<2, 3>,
  15. SDTCisVT<4, OtherVT>
  16. ]>;
  17. def AArch64setcc_z : SDNode<"AArch64ISD::SETCC_MERGE_ZERO", SDT_AArch64Setcc>;
  18. def SVEPatternOperand : AsmOperandClass {
  19. let Name = "SVEPattern";
  20. let ParserMethod = "tryParseSVEPattern";
  21. let PredicateMethod = "isSVEPattern";
  22. let RenderMethod = "addImmOperands";
  23. let DiagnosticType = "InvalidSVEPattern";
  24. }
  25. def sve_pred_enum : Operand<i32>, TImmLeaf<i32, [{
  26. return (((uint32_t)Imm) < 32);
  27. }]> {
  28. let PrintMethod = "printSVEPattern";
  29. let ParserMatchClass = SVEPatternOperand;
  30. }
  31. def SVEPrefetchOperand : AsmOperandClass {
  32. let Name = "SVEPrefetch";
  33. let ParserMethod = "tryParsePrefetch<true>";
  34. let PredicateMethod = "isPrefetch";
  35. let RenderMethod = "addPrefetchOperands";
  36. }
  37. def sve_prfop : Operand<i32>, TImmLeaf<i32, [{
  38. return (((uint32_t)Imm) <= 15);
  39. }]> {
  40. let PrintMethod = "printPrefetchOp<true>";
  41. let ParserMatchClass = SVEPrefetchOperand;
  42. }
  43. class SVELogicalImmOperand<int Width> : AsmOperandClass {
  44. let Name = "SVELogicalImm" # Width;
  45. let DiagnosticType = "LogicalSecondSource";
  46. let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
  47. let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
  48. }
  49. def sve_logical_imm8 : Operand<i64> {
  50. let ParserMatchClass = SVELogicalImmOperand<8>;
  51. let PrintMethod = "printLogicalImm<int8_t>";
  52. let MCOperandPredicate = [{
  53. if (!MCOp.isImm())
  54. return false;
  55. int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
  56. return AArch64_AM::isSVEMaskOfIdenticalElements<int8_t>(Val);
  57. }];
  58. }
  59. def sve_logical_imm16 : Operand<i64> {
  60. let ParserMatchClass = SVELogicalImmOperand<16>;
  61. let PrintMethod = "printLogicalImm<int16_t>";
  62. let MCOperandPredicate = [{
  63. if (!MCOp.isImm())
  64. return false;
  65. int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
  66. return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val);
  67. }];
  68. }
  69. def sve_logical_imm32 : Operand<i64> {
  70. let ParserMatchClass = SVELogicalImmOperand<32>;
  71. let PrintMethod = "printLogicalImm<int32_t>";
  72. let MCOperandPredicate = [{
  73. if (!MCOp.isImm())
  74. return false;
  75. int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
  76. return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val);
  77. }];
  78. }
  79. class SVEPreferredLogicalImmOperand<int Width> : AsmOperandClass {
  80. let Name = "SVEPreferredLogicalImm" # Width;
  81. let PredicateMethod = "isSVEPreferredLogicalImm<int" # Width # "_t>";
  82. let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
  83. }
  84. def sve_preferred_logical_imm16 : Operand<i64> {
  85. let ParserMatchClass = SVEPreferredLogicalImmOperand<16>;
  86. let PrintMethod = "printSVELogicalImm<int16_t>";
  87. let MCOperandPredicate = [{
  88. if (!MCOp.isImm())
  89. return false;
  90. int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
  91. return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val) &&
  92. AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
  93. }];
  94. }
  95. def sve_preferred_logical_imm32 : Operand<i64> {
  96. let ParserMatchClass = SVEPreferredLogicalImmOperand<32>;
  97. let PrintMethod = "printSVELogicalImm<int32_t>";
  98. let MCOperandPredicate = [{
  99. if (!MCOp.isImm())
  100. return false;
  101. int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
  102. return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val) &&
  103. AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
  104. }];
  105. }
  106. def sve_preferred_logical_imm64 : Operand<i64> {
  107. let ParserMatchClass = SVEPreferredLogicalImmOperand<64>;
  108. let PrintMethod = "printSVELogicalImm<int64_t>";
  109. let MCOperandPredicate = [{
  110. if (!MCOp.isImm())
  111. return false;
  112. int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
  113. return AArch64_AM::isSVEMaskOfIdenticalElements<int64_t>(Val) &&
  114. AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
  115. }];
  116. }
  117. class SVELogicalImmNotOperand<int Width> : AsmOperandClass {
  118. let Name = "SVELogicalImm" # Width # "Not";
  119. let DiagnosticType = "LogicalSecondSource";
  120. let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
  121. let RenderMethod = "addLogicalImmNotOperands<int" # Width # "_t>";
  122. }
  123. def sve_logical_imm8_not : Operand<i64> {
  124. let ParserMatchClass = SVELogicalImmNotOperand<8>;
  125. }
  126. def sve_logical_imm16_not : Operand<i64> {
  127. let ParserMatchClass = SVELogicalImmNotOperand<16>;
  128. }
  129. def sve_logical_imm32_not : Operand<i64> {
  130. let ParserMatchClass = SVELogicalImmNotOperand<32>;
  131. }
  132. class SVEShiftedImmOperand<int ElementWidth, string Infix, string Predicate>
  133. : AsmOperandClass {
  134. let Name = "SVE" # Infix # "Imm" # ElementWidth;
  135. let DiagnosticType = "Invalid" # Name;
  136. let RenderMethod = "addImmWithOptionalShiftOperands<8>";
  137. let ParserMethod = "tryParseImmWithOptionalShift";
  138. let PredicateMethod = Predicate;
  139. }
  140. def SVECpyImmOperand8 : SVEShiftedImmOperand<8, "Cpy", "isSVECpyImm<int8_t>">;
  141. def SVECpyImmOperand16 : SVEShiftedImmOperand<16, "Cpy", "isSVECpyImm<int16_t>">;
  142. def SVECpyImmOperand32 : SVEShiftedImmOperand<32, "Cpy", "isSVECpyImm<int32_t>">;
  143. def SVECpyImmOperand64 : SVEShiftedImmOperand<64, "Cpy", "isSVECpyImm<int64_t>">;
  144. def SVEAddSubImmOperand8 : SVEShiftedImmOperand<8, "AddSub", "isSVEAddSubImm<int8_t>">;
  145. def SVEAddSubImmOperand16 : SVEShiftedImmOperand<16, "AddSub", "isSVEAddSubImm<int16_t>">;
  146. def SVEAddSubImmOperand32 : SVEShiftedImmOperand<32, "AddSub", "isSVEAddSubImm<int32_t>">;
  147. def SVEAddSubImmOperand64 : SVEShiftedImmOperand<64, "AddSub", "isSVEAddSubImm<int64_t>">;
  148. class imm8_opt_lsl<int ElementWidth, string printType,
  149. AsmOperandClass OpndClass>
  150. : Operand<i32> {
  151. let EncoderMethod = "getImm8OptLsl";
  152. let DecoderMethod = "DecodeImm8OptLsl<" # ElementWidth # ">";
  153. let PrintMethod = "printImm8OptLsl<" # printType # ">";
  154. let ParserMatchClass = OpndClass;
  155. let MIOperandInfo = (ops i32imm, i32imm);
  156. }
  157. def cpy_imm8_opt_lsl_i8 : imm8_opt_lsl<8, "int8_t", SVECpyImmOperand8>;
  158. def cpy_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "int16_t", SVECpyImmOperand16>;
  159. def cpy_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "int32_t", SVECpyImmOperand32>;
  160. def cpy_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "int64_t", SVECpyImmOperand64>;
  161. def addsub_imm8_opt_lsl_i8 : imm8_opt_lsl<8, "uint8_t", SVEAddSubImmOperand8>;
  162. def addsub_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "uint16_t", SVEAddSubImmOperand16>;
  163. def addsub_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "uint32_t", SVEAddSubImmOperand32>;
  164. def addsub_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "uint64_t", SVEAddSubImmOperand64>;
  165. def SVEAddSubImm8Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i8>", []>;
  166. def SVEAddSubImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i16>", []>;
  167. def SVEAddSubImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i32>", []>;
  168. def SVEAddSubImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubImm<MVT::i64>", []>;
  169. def SVELogicalImm8Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8>", []>;
  170. def SVELogicalImm16Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16>", []>;
  171. def SVELogicalImm32Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32>", []>;
  172. def SVELogicalImm64Pat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64>", []>;
  173. def SVELogicalImm8NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8, true>", []>;
  174. def SVELogicalImm16NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16, true>", []>;
  175. def SVELogicalImm32NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32, true>", []>;
  176. def SVELogicalImm64NotPat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64, true>", []>;
  177. def SVE8BitLslImm32 : ComplexPattern<i32, 2, "SelectSVE8BitLslImm", [imm]>;
  178. def SVE8BitLslImm64 : ComplexPattern<i64, 2, "SelectSVE8BitLslImm", [imm]>;
  179. class SVE8BitLslImm<ValueType ty> {
  180. ComplexPattern Pat = !cond(
  181. !eq(ty, i32): SVE8BitLslImm32,
  182. !eq(ty, i64): SVE8BitLslImm64);
  183. }
  184. def SVEArithUImm8Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i8>", []>;
  185. def SVEArithUImm16Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i16>", []>;
  186. def SVEArithUImm32Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i32>", []>;
  187. def SVEArithUImm64Pat : ComplexPattern<i64, 1, "SelectSVEArithImm<MVT::i64>", []>;
  188. def SVEArithSImmPat32 : ComplexPattern<i32, 1, "SelectSVESignedArithImm", []>;
  189. def SVEArithSImmPat64 : ComplexPattern<i64, 1, "SelectSVESignedArithImm", []>;
  190. def SVEShiftImmL8 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 7>", []>;
  191. def SVEShiftImmL16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 15>", []>;
  192. def SVEShiftImmL32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 31>", []>;
  193. def SVEShiftImmL64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<0, 63>", []>;
  194. def SVEShiftImmR8 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 8, true>", []>;
  195. def SVEShiftImmR16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 16, true>", []>;
  196. def SVEShiftImmR32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 32, true>", []>;
  197. def SVEShiftImmR64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<1, 64, true>", []>;
  198. def SVEAllActive : ComplexPattern<untyped, 0, "SelectAllActivePredicate", []>;
  199. class SVEExactFPImm<string Suffix, string ValA, string ValB> : AsmOperandClass {
  200. let Name = "SVEExactFPImmOperand" # Suffix;
  201. let DiagnosticType = "Invalid" # Name;
  202. let ParserMethod = "tryParseFPImm<false>";
  203. let PredicateMethod = "isExactFPImm<" # ValA # ", " # ValB # ">";
  204. let RenderMethod = "addExactFPImmOperands<" # ValA # ", " # ValB # ">";
  205. }
  206. class SVEExactFPImmOperand<string Suffix, string ValA, string ValB> : Operand<i32> {
  207. let PrintMethod = "printExactFPImm<" # ValA # ", " # ValB # ">";
  208. let ParserMatchClass = SVEExactFPImm<Suffix, ValA, ValB>;
  209. }
  210. def sve_fpimm_half_one
  211. : SVEExactFPImmOperand<"HalfOne", "AArch64ExactFPImm::half",
  212. "AArch64ExactFPImm::one">;
  213. def sve_fpimm_half_two
  214. : SVEExactFPImmOperand<"HalfTwo", "AArch64ExactFPImm::half",
  215. "AArch64ExactFPImm::two">;
  216. def sve_fpimm_zero_one
  217. : SVEExactFPImmOperand<"ZeroOne", "AArch64ExactFPImm::zero",
  218. "AArch64ExactFPImm::one">;
  219. def sve_incdec_imm : Operand<i32>, TImmLeaf<i32, [{
  220. return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
  221. }]> {
  222. let ParserMatchClass = Imm1_16Operand;
  223. let EncoderMethod = "getSVEIncDecImm";
  224. let DecoderMethod = "DecodeSVEIncDecImm";
  225. }
  226. // This allows i32 immediate extraction from i64 based arithmetic.
  227. def sve_cnt_mul_imm_i32 : ComplexPattern<i32, 1, "SelectCntImm<1, 16, 1, false>">;
  228. def sve_cnt_mul_imm_i64 : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, false>">;
  229. def sve_cnt_shl_imm : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, true>">;
  230. def sve_ext_imm_0_31 : ComplexPattern<i64, 1, "SelectEXTImm<31, 8>">;
  231. def sve_ext_imm_0_63 : ComplexPattern<i64, 1, "SelectEXTImm<63, 4>">;
  232. def sve_ext_imm_0_127 : ComplexPattern<i64, 1, "SelectEXTImm<127, 2>">;
  233. def sve_ext_imm_0_255 : ComplexPattern<i64, 1, "SelectEXTImm<255, 1>">;
  234. def int_aarch64_sve_cntp_oneuse : PatFrag<(ops node:$pred, node:$src2),
  235. (int_aarch64_sve_cntp node:$pred, node:$src2), [{
  236. return N->hasOneUse();
  237. }]>;
  238. def step_vector_oneuse : PatFrag<(ops node:$idx),
  239. (step_vector node:$idx), [{
  240. return N->hasOneUse();
  241. }]>;
  242. //===----------------------------------------------------------------------===//
  243. // SVE PTrue - These are used extensively throughout the pattern matching so
  244. // it's important we define them first.
  245. //===----------------------------------------------------------------------===//
  246. class sve_int_ptrue<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
  247. ValueType vt, SDPatternOperator op>
  248. : I<(outs pprty:$Pd), (ins sve_pred_enum:$pattern),
  249. asm, "\t$Pd, $pattern",
  250. "",
  251. [(set (vt pprty:$Pd), (op sve_pred_enum:$pattern))]>, Sched<[]> {
  252. bits<4> Pd;
  253. bits<5> pattern;
  254. let Inst{31-24} = 0b00100101;
  255. let Inst{23-22} = sz8_64;
  256. let Inst{21-19} = 0b011;
  257. let Inst{18-17} = opc{2-1};
  258. let Inst{16} = opc{0};
  259. let Inst{15-10} = 0b111000;
  260. let Inst{9-5} = pattern;
  261. let Inst{4} = 0b0;
  262. let Inst{3-0} = Pd;
  263. let Defs = !if(!eq (opc{0}, 1), [NZCV], []);
  264. let ElementSize = pprty.ElementSize;
  265. let isReMaterializable = 1;
  266. }
  267. multiclass sve_int_ptrue<bits<3> opc, string asm, SDPatternOperator op> {
  268. def _B : sve_int_ptrue<0b00, opc, asm, PPR8, nxv16i1, op>;
  269. def _H : sve_int_ptrue<0b01, opc, asm, PPR16, nxv8i1, op>;
  270. def _S : sve_int_ptrue<0b10, opc, asm, PPR32, nxv4i1, op>;
  271. def _D : sve_int_ptrue<0b11, opc, asm, PPR64, nxv2i1, op>;
  272. def : InstAlias<asm # "\t$Pd",
  273. (!cast<Instruction>(NAME # _B) PPR8:$Pd, 0b11111), 1>;
  274. def : InstAlias<asm # "\t$Pd",
  275. (!cast<Instruction>(NAME # _H) PPR16:$Pd, 0b11111), 1>;
  276. def : InstAlias<asm # "\t$Pd",
  277. (!cast<Instruction>(NAME # _S) PPR32:$Pd, 0b11111), 1>;
  278. def : InstAlias<asm # "\t$Pd",
  279. (!cast<Instruction>(NAME # _D) PPR64:$Pd, 0b11111), 1>;
  280. }
  281. def SDT_AArch64PTrue : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
  282. def AArch64ptrue : SDNode<"AArch64ISD::PTRUE", SDT_AArch64PTrue>;
  283. let Predicates = [HasSVEorStreamingSVE] in {
  284. defm PTRUE : sve_int_ptrue<0b000, "ptrue", AArch64ptrue>;
  285. defm PTRUES : sve_int_ptrue<0b001, "ptrues", null_frag>;
  286. }
  287. //===----------------------------------------------------------------------===//
  288. // SVE pattern match helpers.
  289. //===----------------------------------------------------------------------===//
  290. class SVE_1_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  291. Instruction inst>
  292. : Pat<(vtd (op vt1:$Op1)),
  293. (inst $Op1)>;
  294. class SVE_1_Op_Passthru_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
  295. ValueType vts, Instruction inst>
  296. : Pat<(vtd (op pg:$Op1, vts:$Op2, vtd:$Op3)),
  297. (inst $Op3, $Op1, $Op2)>;
  298. multiclass SVE_1_Op_PassthruUndef_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
  299. ValueType vts, Instruction inst> {
  300. def : Pat<(vtd (op pg:$Op1, vts:$Op2, (vtd undef))),
  301. (inst (IMPLICIT_DEF), $Op1, $Op2)>;
  302. def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, vtd:$Op3)),
  303. (inst $Op3, $Op1, $Op2)>;
  304. }
  305. // Used to match FP_ROUND_MERGE_PASSTHRU, which has an additional flag for the
  306. // type of rounding. This is matched by timm0_1 in pattern below and ignored.
  307. class SVE_1_Op_Passthru_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
  308. ValueType vts, Instruction inst>
  309. : Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), vtd:$Op3)),
  310. (inst $Op3, $Op1, $Op2)>;
  311. multiclass SVE_1_Op_PassthruUndef_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
  312. ValueType vts, Instruction inst>{
  313. def : Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), (vtd undef))),
  314. (inst (IMPLICIT_DEF), $Op1, $Op2)>;
  315. def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, (i64 timm0_1), vtd:$Op3)),
  316. (inst $Op3, $Op1, $Op2)>;
  317. }
  318. class SVE_1_Op_Imm_OptLsl_Reverse_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty,
  319. ValueType it, ComplexPattern cpx, Instruction inst>
  320. : Pat<(vt (op (vt (AArch64dup (it (cpx i32:$imm, i32:$shift)))), (vt zprty:$Op1))),
  321. (inst $Op1, i32:$imm, i32:$shift)>;
  322. class SVE_1_Op_Imm_OptLsl_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty,
  323. ValueType it, ComplexPattern cpx, Instruction inst>
  324. : Pat<(vt (op (vt zprty:$Op1), (vt (AArch64dup (it (cpx i32:$imm, i32:$shift)))))),
  325. (inst $Op1, i32:$imm, i32:$shift)>;
  326. class SVE_1_Op_Imm_Arith_All_Active<ValueType vt, ValueType pt, SDPatternOperator op,
  327. ZPRRegOp zprty, ValueType it, ComplexPattern cpx, Instruction inst>
  328. : Pat<(vt (op (pt (SVEAllActive)), (vt zprty:$Op1), (vt (AArch64dup (it (cpx i32:$imm)))))),
  329. (inst $Op1, i32:$imm)>;
  330. class SVE_1_Op_Imm_Log_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty,
  331. ValueType it, ComplexPattern cpx, Instruction inst>
  332. : Pat<(vt (op (vt zprty:$Op1), (vt (AArch64dup (it (cpx i64:$imm)))))),
  333. (inst $Op1, i64:$imm)>;
  334. class SVE_2_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  335. ValueType vt2, Instruction inst>
  336. : Pat<(vtd (op vt1:$Op1, vt2:$Op2)),
  337. (inst $Op1, $Op2)>;
  338. class SVE_2_Op_Pred_All_Active<ValueType vtd, SDPatternOperator op,
  339. ValueType pt, ValueType vt1, ValueType vt2,
  340. Instruction inst>
  341. : Pat<(vtd (op (pt (SVEAllActive)), vt1:$Op1, vt2:$Op2)),
  342. (inst $Op1, $Op2)>;
  343. class SVE_2_Op_Pred_All_Active_Pt<ValueType vtd, SDPatternOperator op,
  344. ValueType pt, ValueType vt1, ValueType vt2,
  345. Instruction inst>
  346. : Pat<(vtd (op (pt (SVEAllActive:$Op1)), vt1:$Op2, vt2:$Op3)),
  347. (inst $Op1, $Op2, $Op3)>;
  348. class SVE_3_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  349. ValueType vt2, ValueType vt3, Instruction inst>
  350. : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3)),
  351. (inst $Op1, $Op2, $Op3)>;
  352. multiclass SVE_3_Op_Undef_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  353. ValueType vt2, ValueType vt3, Instruction inst> {
  354. def : Pat<(vtd (op (vt1 undef), vt2:$Op1, vt3:$Op2)),
  355. (inst (IMPLICIT_DEF), $Op1, $Op2)>;
  356. def : Pat<(vtd (op vt1:$Op1, (vt2 (SVEAllActive:$Op2)), vt3:$Op3)),
  357. (inst $Op1, $Op2, $Op3)>;
  358. }
  359. class SVE_4_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  360. ValueType vt2, ValueType vt3, ValueType vt4,
  361. Instruction inst>
  362. : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, vt4:$Op4)),
  363. (inst $Op1, $Op2, $Op3, $Op4)>;
  364. class SVE_2_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  365. ValueType vt2, Operand ImmTy, Instruction inst>
  366. : Pat<(vtd (op vt1:$Op1, (vt2 ImmTy:$Op2))),
  367. (inst $Op1, ImmTy:$Op2)>;
  368. class SVE_3_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  369. ValueType vt2, ValueType vt3, Operand ImmTy,
  370. Instruction inst>
  371. : Pat<(vtd (op vt1:$Op1, vt2:$Op2, (vt3 ImmTy:$Op3))),
  372. (inst $Op1, $Op2, ImmTy:$Op3)>;
  373. class SVE_4_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  374. ValueType vt2, ValueType vt3, ValueType vt4,
  375. Operand ImmTy, Instruction inst>
  376. : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, (vt4 ImmTy:$Op4))),
  377. (inst $Op1, $Op2, $Op3, ImmTy:$Op4)>;
  378. def SVEDup0 : ComplexPattern<vAny, 0, "SelectDupZero", []>;
  379. def SVEDup0Undef : ComplexPattern<vAny, 0, "SelectDupZeroOrUndef", []>;
  380. let AddedComplexity = 1 in {
  381. class SVE_3_Op_Pat_SelZero<ValueType vtd, SDPatternOperator op, ValueType vt1,
  382. ValueType vt2, ValueType vt3, Instruction inst>
  383. : Pat<(vtd (vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), vt3:$Op3))),
  384. (inst $Op1, $Op2, $Op3)>;
  385. class SVE_3_Op_Pat_Shift_Imm_SelZero<ValueType vtd, SDPatternOperator op,
  386. ValueType vt1, ValueType vt2,
  387. Operand vt3, Instruction inst>
  388. : Pat<(vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), (i32 (vt3:$Op3)))),
  389. (inst $Op1, $Op2, vt3:$Op3)>;
  390. }
  391. //
  392. // Common but less generic patterns.
  393. //
  394. class SVE_1_Op_AllActive_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  395. Instruction inst, Instruction ptrue>
  396. : Pat<(vtd (op vt1:$Op1)),
  397. (inst (IMPLICIT_DEF), (ptrue 31), $Op1)>;
  398. class SVE_2_Op_AllActive_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
  399. ValueType vt2, Instruction inst, Instruction ptrue>
  400. : Pat<(vtd (op vt1:$Op1, vt2:$Op2)),
  401. (inst (ptrue 31), $Op1, $Op2)>;
  402. class SVE_InReg_Extend<ValueType vt, SDPatternOperator op, ValueType pt,
  403. ValueType inreg_vt, Instruction inst>
  404. : Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, vt:$PassThru)),
  405. (inst $PassThru, $Pg, $Src)>;
  406. multiclass SVE_InReg_Extend_PassthruUndef<ValueType vt, SDPatternOperator op, ValueType pt,
  407. ValueType inreg_vt, Instruction inst> {
  408. def : Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, (vt undef))),
  409. (inst (IMPLICIT_DEF), $Pg, $Src)>;
  410. def : Pat<(vt (op (pt (SVEAllActive:$Pg)), vt:$Src, inreg_vt, vt:$PassThru)),
  411. (inst $PassThru, $Pg, $Src)>;
  412. }
  413. class SVE_Shift_DupImm_Pred_Pat<ValueType vt, SDPatternOperator op,
  414. ValueType pt, ValueType it,
  415. ComplexPattern cast, Instruction inst>
  416. : Pat<(vt (op pt:$Pg, vt:$Rn, (vt (AArch64dup (it (cast i32:$imm)))))),
  417. (inst $Pg, $Rn, i32:$imm)>;
  418. class SVE_Shift_DupImm_All_Active_Pat<ValueType vt, SDPatternOperator op,
  419. ValueType pt, ValueType it,
  420. ComplexPattern cast, Instruction inst>
  421. : Pat<(vt (op (pt (SVEAllActive)), vt:$Rn, (vt (AArch64dup (it (cast i32:$imm)))))),
  422. (inst $Rn, i32:$imm)>;
  423. class SVE_2_Op_Fp_Imm_Pat<ValueType vt, SDPatternOperator op,
  424. ValueType pt, ValueType it,
  425. FPImmLeaf immL, int imm,
  426. Instruction inst>
  427. : Pat<(vt (op (pt PPR_3b:$Pg), (vt ZPR:$Zs1), (vt (AArch64dup (it immL))))),
  428. (inst $Pg, $Zs1, imm)>;
  429. class SVE_2_Op_Fp_Imm_Pat_Zero<ValueType vt, SDPatternOperator op,
  430. ValueType pt, ValueType it,
  431. FPImmLeaf immL, int imm,
  432. Instruction inst>
  433. : Pat<(vt (op pt:$Pg, (vselect pt:$Pg, vt:$Zs1, (SVEDup0)),
  434. (vt (AArch64dup (it immL))))),
  435. (inst $Pg, $Zs1, imm)>;
  436. //
  437. // Pseudo -> Instruction mappings
  438. //
  439. def getSVEPseudoMap : InstrMapping {
  440. let FilterClass = "SVEPseudo2Instr";
  441. let RowFields = ["PseudoName"];
  442. let ColFields = ["IsInstr"];
  443. let KeyCol = ["0"];
  444. let ValueCols = [["1"]];
  445. }
  446. class SVEPseudo2Instr<string name, bit instr> {
  447. string PseudoName = name;
  448. bit IsInstr = instr;
  449. }
  450. // Lookup e.g. DIV -> DIVR
  451. def getSVERevInstr : InstrMapping {
  452. let FilterClass = "SVEInstr2Rev";
  453. let RowFields = ["InstrName"];
  454. let ColFields = ["isReverseInstr"];
  455. let KeyCol = ["0"];
  456. let ValueCols = [["1"]];
  457. }
  458. // Lookup e.g. DIVR -> DIV
  459. def getSVENonRevInstr : InstrMapping {
  460. let FilterClass = "SVEInstr2Rev";
  461. let RowFields = ["InstrName"];
  462. let ColFields = ["isReverseInstr"];
  463. let KeyCol = ["1"];
  464. let ValueCols = [["0"]];
  465. }
  466. class SVEInstr2Rev<string name1, string name2, bit name1IsReverseInstr> {
  467. string InstrName = !if(name1IsReverseInstr, name1, name2);
  468. bit isReverseInstr = name1IsReverseInstr;
  469. }
  470. //
  471. // Pseudos for destructive operands
  472. //
  473. let hasNoSchedulingInfo = 1 in {
  474. class PredTwoOpPseudo<string name, ZPRRegOp zprty,
  475. FalseLanesEnum flags = FalseLanesNone>
  476. : SVEPseudo2Instr<name, 0>,
  477. Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2), []> {
  478. let FalseLanes = flags;
  479. }
  480. class PredTwoOpImmPseudo<string name, ZPRRegOp zprty, Operand immty,
  481. FalseLanesEnum flags = FalseLanesNone>
  482. : SVEPseudo2Instr<name, 0>,
  483. Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, immty:$imm), []> {
  484. let FalseLanes = flags;
  485. }
  486. class PredThreeOpPseudo<string name, ZPRRegOp zprty,
  487. FalseLanesEnum flags = FalseLanesNone>
  488. : SVEPseudo2Instr<name, 0>,
  489. Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2, zprty:$Zs3), []> {
  490. let FalseLanes = flags;
  491. }
  492. }
  493. //
  494. // Pseudos for passthru operands
  495. //
  496. let hasNoSchedulingInfo = 1 in {
  497. class PredOneOpPassthruPseudo<string name, ZPRRegOp zprty>
  498. : SVEPseudo2Instr<name, 0>,
  499. Pseudo<(outs zprty:$Zd), (ins zprty:$Passthru, PPR3bAny:$Pg, zprty:$Zs), []>;
  500. }
  501. //===----------------------------------------------------------------------===//
  502. // SVE Predicate Misc Group
  503. //===----------------------------------------------------------------------===//
  504. class sve_int_pfalse<bits<6> opc, string asm>
  505. : I<(outs PPR8:$Pd), (ins),
  506. asm, "\t$Pd",
  507. "",
  508. []>, Sched<[]> {
  509. bits<4> Pd;
  510. let Inst{31-24} = 0b00100101;
  511. let Inst{23-22} = opc{5-4};
  512. let Inst{21-19} = 0b011;
  513. let Inst{18-16} = opc{3-1};
  514. let Inst{15-10} = 0b111001;
  515. let Inst{9} = opc{0};
  516. let Inst{8-4} = 0b00000;
  517. let Inst{3-0} = Pd;
  518. let isReMaterializable = 1;
  519. }
  520. multiclass sve_int_pfalse<bits<6> opc, string asm> {
  521. def NAME : sve_int_pfalse<opc, asm>;
  522. def : Pat<(nxv16i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>;
  523. def : Pat<(nxv8i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>;
  524. def : Pat<(nxv4i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>;
  525. def : Pat<(nxv2i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>;
  526. }
  527. class sve_int_ptest<bits<6> opc, string asm>
  528. : I<(outs), (ins PPRAny:$Pg, PPR8:$Pn),
  529. asm, "\t$Pg, $Pn",
  530. "",
  531. []>, Sched<[]> {
  532. bits<4> Pg;
  533. bits<4> Pn;
  534. let Inst{31-24} = 0b00100101;
  535. let Inst{23-22} = opc{5-4};
  536. let Inst{21-19} = 0b010;
  537. let Inst{18-16} = opc{3-1};
  538. let Inst{15-14} = 0b11;
  539. let Inst{13-10} = Pg;
  540. let Inst{9} = opc{0};
  541. let Inst{8-5} = Pn;
  542. let Inst{4-0} = 0b00000;
  543. let Defs = [NZCV];
  544. let isCompare = 1;
  545. }
  546. class sve_int_pfirst_next<bits<2> sz8_64, bits<5> opc, string asm,
  547. PPRRegOp pprty>
  548. : I<(outs pprty:$Pdn), (ins PPRAny:$Pg, pprty:$_Pdn),
  549. asm, "\t$Pdn, $Pg, $_Pdn",
  550. "",
  551. []>, Sched<[]> {
  552. bits<4> Pdn;
  553. bits<4> Pg;
  554. let Inst{31-24} = 0b00100101;
  555. let Inst{23-22} = sz8_64;
  556. let Inst{21-19} = 0b011;
  557. let Inst{18-16} = opc{4-2};
  558. let Inst{15-11} = 0b11000;
  559. let Inst{10-9} = opc{1-0};
  560. let Inst{8-5} = Pg;
  561. let Inst{4} = 0;
  562. let Inst{3-0} = Pdn;
  563. let Constraints = "$Pdn = $_Pdn";
  564. let Defs = [NZCV];
  565. let isPTestLike = 1;
  566. let ElementSize = pprty.ElementSize;
  567. }
  568. multiclass sve_int_pfirst<bits<5> opc, string asm, SDPatternOperator op> {
  569. def _B : sve_int_pfirst_next<0b01, opc, asm, PPR8>;
  570. def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
  571. }
  572. multiclass sve_int_pnext<bits<5> opc, string asm, SDPatternOperator op> {
  573. def _B : sve_int_pfirst_next<0b00, opc, asm, PPR8>;
  574. def _H : sve_int_pfirst_next<0b01, opc, asm, PPR16>;
  575. def _S : sve_int_pfirst_next<0b10, opc, asm, PPR32>;
  576. def _D : sve_int_pfirst_next<0b11, opc, asm, PPR64>;
  577. def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
  578. def : SVE_2_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
  579. def : SVE_2_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
  580. def : SVE_2_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
  581. }
  582. //===----------------------------------------------------------------------===//
  583. // SVE Predicate Count Group
  584. //===----------------------------------------------------------------------===//
  585. class sve_int_count_r<bits<2> sz8_64, bits<5> opc, string asm,
  586. RegisterOperand dty, PPRRegOp pprty, RegisterOperand sty>
  587. : I<(outs dty:$Rdn), (ins pprty:$Pg, sty:$_Rdn),
  588. asm, "\t$Rdn, $Pg",
  589. "",
  590. []>, Sched<[]> {
  591. bits<5> Rdn;
  592. bits<4> Pg;
  593. let Inst{31-24} = 0b00100101;
  594. let Inst{23-22} = sz8_64;
  595. let Inst{21-19} = 0b101;
  596. let Inst{18-16} = opc{4-2};
  597. let Inst{15-11} = 0b10001;
  598. let Inst{10-9} = opc{1-0};
  599. let Inst{8-5} = Pg;
  600. let Inst{4-0} = Rdn;
  601. // Signed 32bit forms require their GPR operand printed.
  602. let AsmString = !if(!eq(opc{4,2-0}, 0b0000),
  603. !strconcat(asm, "\t$Rdn, $Pg, $_Rdn"),
  604. !strconcat(asm, "\t$Rdn, $Pg"));
  605. let Constraints = "$Rdn = $_Rdn";
  606. }
  607. multiclass sve_int_count_r_s32<bits<5> opc, string asm,
  608. SDPatternOperator op> {
  609. def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64as32>;
  610. def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64as32>;
  611. def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64as32>;
  612. def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64as32>;
  613. def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))),
  614. (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
  615. def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))))),
  616. (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
  617. def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))),
  618. (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
  619. def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))))),
  620. (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
  621. def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))),
  622. (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
  623. def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))))),
  624. (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
  625. def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))),
  626. (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
  627. def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))))),
  628. (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
  629. }
  630. multiclass sve_int_count_r_u32<bits<5> opc, string asm,
  631. SDPatternOperator op> {
  632. def _B : sve_int_count_r<0b00, opc, asm, GPR32z, PPR8, GPR32z>;
  633. def _H : sve_int_count_r<0b01, opc, asm, GPR32z, PPR16, GPR32z>;
  634. def _S : sve_int_count_r<0b10, opc, asm, GPR32z, PPR32, GPR32z>;
  635. def _D : sve_int_count_r<0b11, opc, asm, GPR32z, PPR64, GPR32z>;
  636. def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))),
  637. (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>;
  638. def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))),
  639. (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>;
  640. def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))),
  641. (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>;
  642. def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))),
  643. (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>;
  644. }
  645. multiclass sve_int_count_r_x64<bits<5> opc, string asm,
  646. SDPatternOperator op,
  647. SDPatternOperator combine_op = null_frag> {
  648. def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64z>;
  649. def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64z>;
  650. def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64z>;
  651. def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64z>;
  652. def : Pat<(i64 (op GPR64:$Rn, (nxv16i1 PPRAny:$Pg))),
  653. (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>;
  654. def : Pat<(i64 (op GPR64:$Rn, (nxv8i1 PPRAny:$Pg))),
  655. (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>;
  656. def : Pat<(i64 (op GPR64:$Rn, (nxv4i1 PPRAny:$Pg))),
  657. (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>;
  658. def : Pat<(i64 (op GPR64:$Rn, (nxv2i1 PPRAny:$Pg))),
  659. (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>;
  660. // combine_op(x, cntp(all_active, p)) ==> inst p, x
  661. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 (SVEAllActive)), (nxv16i1 PPRAny:$pred)))),
  662. (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>;
  663. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 (SVEAllActive)), (nxv8i1 PPRAny:$pred)))),
  664. (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>;
  665. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 (SVEAllActive)), (nxv4i1 PPRAny:$pred)))),
  666. (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>;
  667. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 (SVEAllActive)), (nxv2i1 PPRAny:$pred)))),
  668. (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>;
  669. // combine_op(x, cntp(p, p)) ==> inst p, x
  670. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 PPRAny:$pred), (nxv16i1 PPRAny:$pred)))),
  671. (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>;
  672. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 PPRAny:$pred), (nxv8i1 PPRAny:$pred)))),
  673. (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>;
  674. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 PPRAny:$pred), (nxv4i1 PPRAny:$pred)))),
  675. (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>;
  676. def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 PPRAny:$pred), (nxv2i1 PPRAny:$pred)))),
  677. (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>;
  678. }
  679. class sve_int_count_v<bits<2> sz8_64, bits<5> opc, string asm,
  680. ZPRRegOp zprty, PPRRegOp pprty>
  681. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, pprty:$Pm),
  682. asm, "\t$Zdn, $Pm",
  683. "",
  684. []>, Sched<[]> {
  685. bits<4> Pm;
  686. bits<5> Zdn;
  687. let Inst{31-24} = 0b00100101;
  688. let Inst{23-22} = sz8_64;
  689. let Inst{21-19} = 0b101;
  690. let Inst{18-16} = opc{4-2};
  691. let Inst{15-11} = 0b10000;
  692. let Inst{10-9} = opc{1-0};
  693. let Inst{8-5} = Pm;
  694. let Inst{4-0} = Zdn;
  695. let Constraints = "$Zdn = $_Zdn";
  696. let DestructiveInstType = DestructiveOther;
  697. let ElementSize = ElementSizeNone;
  698. }
  699. multiclass sve_int_count_v<bits<5> opc, string asm,
  700. SDPatternOperator op = null_frag> {
  701. def _H : sve_int_count_v<0b01, opc, asm, ZPR16, PPR16>;
  702. def _S : sve_int_count_v<0b10, opc, asm, ZPR32, PPR32>;
  703. def _D : sve_int_count_v<0b11, opc, asm, ZPR64, PPR64>;
  704. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, !cast<Instruction>(NAME # _H)>;
  705. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, !cast<Instruction>(NAME # _S)>;
  706. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, !cast<Instruction>(NAME # _D)>;
  707. def : InstAlias<asm # "\t$Zdn, $Pm",
  708. (!cast<Instruction>(NAME # "_H") ZPR16:$Zdn, PPRAny:$Pm), 0>;
  709. def : InstAlias<asm # "\t$Zdn, $Pm",
  710. (!cast<Instruction>(NAME # "_S") ZPR32:$Zdn, PPRAny:$Pm), 0>;
  711. def : InstAlias<asm # "\t$Zdn, $Pm",
  712. (!cast<Instruction>(NAME # "_D") ZPR64:$Zdn, PPRAny:$Pm), 0>;
  713. }
  714. class sve_int_pcount_pred<bits<2> sz8_64, bits<4> opc, string asm,
  715. PPRRegOp pprty>
  716. : I<(outs GPR64:$Rd), (ins PPRAny:$Pg, pprty:$Pn),
  717. asm, "\t$Rd, $Pg, $Pn",
  718. "",
  719. []>, Sched<[]> {
  720. bits<4> Pg;
  721. bits<4> Pn;
  722. bits<5> Rd;
  723. let Inst{31-24} = 0b00100101;
  724. let Inst{23-22} = sz8_64;
  725. let Inst{21-19} = 0b100;
  726. let Inst{18-16} = opc{3-1};
  727. let Inst{15-14} = 0b10;
  728. let Inst{13-10} = Pg;
  729. let Inst{9} = opc{0};
  730. let Inst{8-5} = Pn;
  731. let Inst{4-0} = Rd;
  732. }
  733. multiclass sve_int_pcount_pred<bits<4> opc, string asm,
  734. SDPatternOperator int_op> {
  735. def _B : sve_int_pcount_pred<0b00, opc, asm, PPR8>;
  736. def _H : sve_int_pcount_pred<0b01, opc, asm, PPR16>;
  737. def _S : sve_int_pcount_pred<0b10, opc, asm, PPR32>;
  738. def _D : sve_int_pcount_pred<0b11, opc, asm, PPR64>;
  739. def : SVE_2_Op_Pat<i64, int_op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
  740. def : SVE_2_Op_Pat<i64, int_op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
  741. def : SVE_2_Op_Pat<i64, int_op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
  742. def : SVE_2_Op_Pat<i64, int_op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
  743. }
  744. //===----------------------------------------------------------------------===//
  745. // SVE Element Count Group
  746. //===----------------------------------------------------------------------===//
  747. class sve_int_count<bits<3> opc, string asm>
  748. : I<(outs GPR64:$Rd), (ins sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
  749. asm, "\t$Rd, $pattern, mul $imm4",
  750. "",
  751. []>, Sched<[]> {
  752. bits<5> Rd;
  753. bits<4> imm4;
  754. bits<5> pattern;
  755. let Inst{31-24} = 0b00000100;
  756. let Inst{23-22} = opc{2-1};
  757. let Inst{21-20} = 0b10;
  758. let Inst{19-16} = imm4;
  759. let Inst{15-11} = 0b11100;
  760. let Inst{10} = opc{0};
  761. let Inst{9-5} = pattern;
  762. let Inst{4-0} = Rd;
  763. }
  764. multiclass sve_int_count<bits<3> opc, string asm, SDPatternOperator op> {
  765. def NAME : sve_int_count<opc, asm>;
  766. def : InstAlias<asm # "\t$Rd, $pattern",
  767. (!cast<Instruction>(NAME) GPR64:$Rd, sve_pred_enum:$pattern, 1), 1>;
  768. def : InstAlias<asm # "\t$Rd",
  769. (!cast<Instruction>(NAME) GPR64:$Rd, 0b11111, 1), 2>;
  770. def : Pat<(i64 (mul (op sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm))),
  771. (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>;
  772. def : Pat<(i64 (shl (op sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm))),
  773. (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>;
  774. def : Pat<(i64 (op sve_pred_enum:$pattern)),
  775. (!cast<Instruction>(NAME) sve_pred_enum:$pattern, 1)>;
  776. }
  777. class sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty>
  778. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
  779. asm, "\t$Zdn, $pattern, mul $imm4",
  780. "",
  781. []>, Sched<[]> {
  782. bits<5> Zdn;
  783. bits<5> pattern;
  784. bits<4> imm4;
  785. let Inst{31-24} = 0b00000100;
  786. let Inst{23-22} = opc{4-3};
  787. let Inst{21} = 0b1;
  788. let Inst{20} = opc{2};
  789. let Inst{19-16} = imm4;
  790. let Inst{15-12} = 0b1100;
  791. let Inst{11-10} = opc{1-0};
  792. let Inst{9-5} = pattern;
  793. let Inst{4-0} = Zdn;
  794. let Constraints = "$Zdn = $_Zdn";
  795. let DestructiveInstType = DestructiveOther;
  796. let ElementSize = ElementSizeNone;
  797. }
  798. multiclass sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty,
  799. SDPatternOperator op = null_frag,
  800. ValueType vt = OtherVT> {
  801. def NAME : sve_int_countvlv<opc, asm, zprty>;
  802. def : InstAlias<asm # "\t$Zdn, $pattern",
  803. (!cast<Instruction>(NAME) zprty:$Zdn, sve_pred_enum:$pattern, 1), 1>;
  804. def : InstAlias<asm # "\t$Zdn",
  805. (!cast<Instruction>(NAME) zprty:$Zdn, 0b11111, 1), 2>;
  806. def : Pat<(vt (op (vt zprty:$Zn), (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
  807. (!cast<Instruction>(NAME) $Zn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
  808. }
  809. class sve_int_pred_pattern_a<bits<3> opc, string asm>
  810. : I<(outs GPR64:$Rdn), (ins GPR64:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
  811. asm, "\t$Rdn, $pattern, mul $imm4",
  812. "",
  813. []>, Sched<[]> {
  814. bits<5> Rdn;
  815. bits<5> pattern;
  816. bits<4> imm4;
  817. let Inst{31-24} = 0b00000100;
  818. let Inst{23-22} = opc{2-1};
  819. let Inst{21-20} = 0b11;
  820. let Inst{19-16} = imm4;
  821. let Inst{15-11} = 0b11100;
  822. let Inst{10} = opc{0};
  823. let Inst{9-5} = pattern;
  824. let Inst{4-0} = Rdn;
  825. let Constraints = "$Rdn = $_Rdn";
  826. }
  827. multiclass sve_int_pred_pattern_a<bits<3> opc, string asm,
  828. SDPatternOperator op,
  829. SDPatternOperator opcnt> {
  830. let Predicates = [HasSVEorStreamingSVE] in {
  831. def NAME : sve_int_pred_pattern_a<opc, asm>;
  832. def : InstAlias<asm # "\t$Rdn, $pattern",
  833. (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1), 1>;
  834. def : InstAlias<asm # "\t$Rdn",
  835. (!cast<Instruction>(NAME) GPR64:$Rdn, 0b11111, 1), 2>;
  836. }
  837. let Predicates = [HasSVEorStreamingSVE, UseScalarIncVL] in {
  838. def : Pat<(i64 (op GPR64:$Rdn, (opcnt sve_pred_enum:$pattern))),
  839. (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1)>;
  840. def : Pat<(i64 (op GPR64:$Rdn, (mul (opcnt sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm)))),
  841. (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>;
  842. def : Pat<(i64 (op GPR64:$Rdn, (shl (opcnt sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm)))),
  843. (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>;
  844. def : Pat<(i32 (op GPR32:$Rdn, (i32 (trunc (opcnt (sve_pred_enum:$pattern)))))),
  845. (i32 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
  846. GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, 1),
  847. sub_32))>;
  848. def : Pat<(i32 (op GPR32:$Rdn, (mul (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_mul_imm_i32 i32:$imm)))),
  849. (i32 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
  850. GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm),
  851. sub_32))>;
  852. def : Pat<(i32 (op GPR32:$Rdn, (shl (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_shl_imm i32:$imm)))),
  853. (i32 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
  854. GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm),
  855. sub_32))>;
  856. }
  857. }
  858. class sve_int_pred_pattern_b<bits<5> opc, string asm, RegisterOperand dt,
  859. RegisterOperand st>
  860. : I<(outs dt:$Rdn), (ins st:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
  861. asm, "\t$Rdn, $pattern, mul $imm4",
  862. "",
  863. []>, Sched<[]> {
  864. bits<5> Rdn;
  865. bits<5> pattern;
  866. bits<4> imm4;
  867. let Inst{31-24} = 0b00000100;
  868. let Inst{23-22} = opc{4-3};
  869. let Inst{21} = 0b1;
  870. let Inst{20} = opc{2};
  871. let Inst{19-16} = imm4;
  872. let Inst{15-12} = 0b1111;
  873. let Inst{11-10} = opc{1-0};
  874. let Inst{9-5} = pattern;
  875. let Inst{4-0} = Rdn;
  876. // Signed 32bit forms require their GPR operand printed.
  877. let AsmString = !if(!eq(opc{2,0}, 0b00),
  878. !strconcat(asm, "\t$Rdn, $_Rdn, $pattern, mul $imm4"),
  879. !strconcat(asm, "\t$Rdn, $pattern, mul $imm4"));
  880. let Constraints = "$Rdn = $_Rdn";
  881. }
  882. multiclass sve_int_pred_pattern_b_s32<bits<5> opc, string asm,
  883. SDPatternOperator op> {
  884. def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64as32>;
  885. def : InstAlias<asm # "\t$Rd, $Rn, $pattern",
  886. (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, sve_pred_enum:$pattern, 1), 1>;
  887. def : InstAlias<asm # "\t$Rd, $Rn",
  888. (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, 0b11111, 1), 2>;
  889. // NOTE: Register allocation doesn't like tied operands of differing register
  890. // class, hence the extra INSERT_SUBREG complication.
  891. def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
  892. (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4), sub_32)>;
  893. def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))))),
  894. (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
  895. }
  896. multiclass sve_int_pred_pattern_b_u32<bits<5> opc, string asm,
  897. SDPatternOperator op> {
  898. def NAME : sve_int_pred_pattern_b<opc, asm, GPR32z, GPR32z>;
  899. def : InstAlias<asm # "\t$Rdn, $pattern",
  900. (!cast<Instruction>(NAME) GPR32z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
  901. def : InstAlias<asm # "\t$Rdn",
  902. (!cast<Instruction>(NAME) GPR32z:$Rdn, 0b11111, 1), 2>;
  903. def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
  904. (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
  905. }
  906. multiclass sve_int_pred_pattern_b_x64<bits<5> opc, string asm,
  907. SDPatternOperator op> {
  908. def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64z>;
  909. def : InstAlias<asm # "\t$Rdn, $pattern",
  910. (!cast<Instruction>(NAME) GPR64z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
  911. def : InstAlias<asm # "\t$Rdn",
  912. (!cast<Instruction>(NAME) GPR64z:$Rdn, 0b11111, 1), 2>;
  913. def : Pat<(i64 (op GPR64:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
  914. (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
  915. }
  916. //===----------------------------------------------------------------------===//
  917. // SVE Permute - Cross Lane Group
  918. //===----------------------------------------------------------------------===//
  919. class sve_int_perm_dup_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  920. ValueType vt, RegisterClass srcRegType,
  921. SDPatternOperator op>
  922. : I<(outs zprty:$Zd), (ins srcRegType:$Rn),
  923. asm, "\t$Zd, $Rn",
  924. "",
  925. [(set (vt zprty:$Zd), (op srcRegType:$Rn))]>, Sched<[]> {
  926. bits<5> Rn;
  927. bits<5> Zd;
  928. let Inst{31-24} = 0b00000101;
  929. let Inst{23-22} = sz8_64;
  930. let Inst{21-10} = 0b100000001110;
  931. let Inst{9-5} = Rn;
  932. let Inst{4-0} = Zd;
  933. }
  934. multiclass sve_int_perm_dup_r<string asm, SDPatternOperator op> {
  935. def _B : sve_int_perm_dup_r<0b00, asm, ZPR8, nxv16i8, GPR32sp, op>;
  936. def _H : sve_int_perm_dup_r<0b01, asm, ZPR16, nxv8i16, GPR32sp, op>;
  937. def _S : sve_int_perm_dup_r<0b10, asm, ZPR32, nxv4i32, GPR32sp, op>;
  938. def _D : sve_int_perm_dup_r<0b11, asm, ZPR64, nxv2i64, GPR64sp, op>;
  939. def : InstAlias<"mov $Zd, $Rn",
  940. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, GPR32sp:$Rn), 1>;
  941. def : InstAlias<"mov $Zd, $Rn",
  942. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, GPR32sp:$Rn), 1>;
  943. def : InstAlias<"mov $Zd, $Rn",
  944. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, GPR32sp:$Rn), 1>;
  945. def : InstAlias<"mov $Zd, $Rn",
  946. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, GPR64sp:$Rn), 1>;
  947. }
  948. class sve_int_perm_dup_i<bits<5> tsz, Operand immtype, string asm,
  949. ZPRRegOp zprty>
  950. : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$idx),
  951. asm, "\t$Zd, $Zn$idx",
  952. "",
  953. []>, Sched<[]> {
  954. bits<5> Zd;
  955. bits<5> Zn;
  956. bits<7> idx;
  957. let Inst{31-24} = 0b00000101;
  958. let Inst{23-22} = {?,?}; // imm3h
  959. let Inst{21} = 0b1;
  960. let Inst{20-16} = tsz;
  961. let Inst{15-10} = 0b001000;
  962. let Inst{9-5} = Zn;
  963. let Inst{4-0} = Zd;
  964. }
  965. multiclass sve_int_perm_dup_i<string asm> {
  966. def _B : sve_int_perm_dup_i<{?,?,?,?,1}, sve_elm_idx_extdup_b, asm, ZPR8> {
  967. let Inst{23-22} = idx{5-4};
  968. let Inst{20-17} = idx{3-0};
  969. }
  970. def _H : sve_int_perm_dup_i<{?,?,?,1,0}, sve_elm_idx_extdup_h, asm, ZPR16> {
  971. let Inst{23-22} = idx{4-3};
  972. let Inst{20-18} = idx{2-0};
  973. }
  974. def _S : sve_int_perm_dup_i<{?,?,1,0,0}, sve_elm_idx_extdup_s, asm, ZPR32> {
  975. let Inst{23-22} = idx{3-2};
  976. let Inst{20-19} = idx{1-0};
  977. }
  978. def _D : sve_int_perm_dup_i<{?,1,0,0,0}, sve_elm_idx_extdup_d, asm, ZPR64> {
  979. let Inst{23-22} = idx{2-1};
  980. let Inst{20} = idx{0};
  981. }
  982. def _Q : sve_int_perm_dup_i<{1,0,0,0,0}, sve_elm_idx_extdup_q, asm, ZPR128> {
  983. let Inst{23-22} = idx{1-0};
  984. }
  985. def : InstAlias<"mov $Zd, $Zn$idx",
  986. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, sve_elm_idx_extdup_b:$idx), 1>;
  987. def : InstAlias<"mov $Zd, $Zn$idx",
  988. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, sve_elm_idx_extdup_h:$idx), 1>;
  989. def : InstAlias<"mov $Zd, $Zn$idx",
  990. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, sve_elm_idx_extdup_s:$idx), 1>;
  991. def : InstAlias<"mov $Zd, $Zn$idx",
  992. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, sve_elm_idx_extdup_d:$idx), 1>;
  993. def : InstAlias<"mov $Zd, $Zn$idx",
  994. (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, ZPR128:$Zn, sve_elm_idx_extdup_q:$idx), 1>;
  995. def : InstAlias<"mov $Zd, $Bn",
  996. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, FPR8asZPR:$Bn, 0), 2>;
  997. def : InstAlias<"mov $Zd, $Hn",
  998. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, FPR16asZPR:$Hn, 0), 2>;
  999. def : InstAlias<"mov $Zd, $Sn",
  1000. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, FPR32asZPR:$Sn, 0), 2>;
  1001. def : InstAlias<"mov $Zd, $Dn",
  1002. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, FPR64asZPR:$Dn, 0), 2>;
  1003. def : InstAlias<"mov $Zd, $Qn",
  1004. (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 0), 2>;
  1005. // Duplicate extracted element of vector into all vector elements
  1006. def : Pat<(nxv16i8 (AArch64dup (i32 (vector_extract (nxv16i8 ZPR:$vec), sve_elm_idx_extdup_b:$index)))),
  1007. (!cast<Instruction>(NAME # _B) ZPR:$vec, sve_elm_idx_extdup_b:$index)>;
  1008. def : Pat<(nxv8i16 (AArch64dup (i32 (vector_extract (nxv8i16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))),
  1009. (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>;
  1010. def : Pat<(nxv4i32 (AArch64dup (i32 (vector_extract (nxv4i32 ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
  1011. (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
  1012. def : Pat<(nxv2i64 (AArch64dup (i64 (vector_extract (nxv2i64 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
  1013. (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
  1014. def : Pat<(nxv8f16 (AArch64dup (f16 (vector_extract (nxv8f16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))),
  1015. (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>;
  1016. def : Pat<(nxv8bf16 (AArch64dup (bf16 (vector_extract (nxv8bf16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))),
  1017. (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>;
  1018. def : Pat<(nxv4f16 (AArch64dup (f16 (vector_extract (nxv4f16 ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
  1019. (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
  1020. def : Pat<(nxv2f16 (AArch64dup (f16 (vector_extract (nxv2f16 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
  1021. (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
  1022. def : Pat<(nxv4f32 (AArch64dup (f32 (vector_extract (nxv4f32 ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
  1023. (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
  1024. def : Pat<(nxv2f32 (AArch64dup (f32 (vector_extract (nxv2f32 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
  1025. (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
  1026. def : Pat<(nxv2f64 (AArch64dup (f64 (vector_extract (nxv2f64 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
  1027. (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
  1028. }
  1029. class sve_int_perm_tbl<bits<2> sz8_64, bits<2> opc, string asm, ZPRRegOp zprty,
  1030. RegisterOperand VecList>
  1031. : I<(outs zprty:$Zd), (ins VecList:$Zn, zprty:$Zm),
  1032. asm, "\t$Zd, $Zn, $Zm",
  1033. "",
  1034. []>, Sched<[]> {
  1035. bits<5> Zd;
  1036. bits<5> Zm;
  1037. bits<5> Zn;
  1038. let Inst{31-24} = 0b00000101;
  1039. let Inst{23-22} = sz8_64;
  1040. let Inst{21} = 0b1;
  1041. let Inst{20-16} = Zm;
  1042. let Inst{15-13} = 0b001;
  1043. let Inst{12-11} = opc;
  1044. let Inst{10} = 0b0;
  1045. let Inst{9-5} = Zn;
  1046. let Inst{4-0} = Zd;
  1047. }
  1048. multiclass sve_int_perm_tbl<string asm, SDPatternOperator op> {
  1049. def _B : sve_int_perm_tbl<0b00, 0b10, asm, ZPR8, Z_b>;
  1050. def _H : sve_int_perm_tbl<0b01, 0b10, asm, ZPR16, Z_h>;
  1051. def _S : sve_int_perm_tbl<0b10, 0b10, asm, ZPR32, Z_s>;
  1052. def _D : sve_int_perm_tbl<0b11, 0b10, asm, ZPR64, Z_d>;
  1053. def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
  1054. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 0>;
  1055. def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
  1056. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 0>;
  1057. def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
  1058. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 0>;
  1059. def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
  1060. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, ZPR64:$Zm), 0>;
  1061. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  1062. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1063. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1064. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1065. def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1066. def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1067. def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1068. def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1069. }
  1070. multiclass sve2_int_perm_tbl<string asm, SDPatternOperator op> {
  1071. def _B : sve_int_perm_tbl<0b00, 0b01, asm, ZPR8, ZZ_b>;
  1072. def _H : sve_int_perm_tbl<0b01, 0b01, asm, ZPR16, ZZ_h>;
  1073. def _S : sve_int_perm_tbl<0b10, 0b01, asm, ZPR32, ZZ_s>;
  1074. def _D : sve_int_perm_tbl<0b11, 0b01, asm, ZPR64, ZZ_d>;
  1075. def : Pat<(nxv16i8 (op nxv16i8:$Op1, nxv16i8:$Op2, nxv16i8:$Op3)),
  1076. (nxv16i8 (!cast<Instruction>(NAME # _B) (REG_SEQUENCE ZPR2, nxv16i8:$Op1, zsub0,
  1077. nxv16i8:$Op2, zsub1),
  1078. nxv16i8:$Op3))>;
  1079. def : Pat<(nxv8i16 (op nxv8i16:$Op1, nxv8i16:$Op2, nxv8i16:$Op3)),
  1080. (nxv8i16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8i16:$Op1, zsub0,
  1081. nxv8i16:$Op2, zsub1),
  1082. nxv8i16:$Op3))>;
  1083. def : Pat<(nxv4i32 (op nxv4i32:$Op1, nxv4i32:$Op2, nxv4i32:$Op3)),
  1084. (nxv4i32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4i32:$Op1, zsub0,
  1085. nxv4i32:$Op2, zsub1),
  1086. nxv4i32:$Op3))>;
  1087. def : Pat<(nxv2i64 (op nxv2i64:$Op1, nxv2i64:$Op2, nxv2i64:$Op3)),
  1088. (nxv2i64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2i64:$Op1, zsub0,
  1089. nxv2i64:$Op2, zsub1),
  1090. nxv2i64:$Op3))>;
  1091. def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8i16:$Op3)),
  1092. (nxv8f16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8f16:$Op1, zsub0,
  1093. nxv8f16:$Op2, zsub1),
  1094. nxv8i16:$Op3))>;
  1095. def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4i32:$Op3)),
  1096. (nxv4f32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4f32:$Op1, zsub0,
  1097. nxv4f32:$Op2, zsub1),
  1098. nxv4i32:$Op3))>;
  1099. def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2i64:$Op3)),
  1100. (nxv2f64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2f64:$Op1, zsub0,
  1101. nxv2f64:$Op2, zsub1),
  1102. nxv2i64:$Op3))>;
  1103. def : Pat<(nxv8bf16 (op nxv8bf16:$Op1, nxv8bf16:$Op2, nxv8i16:$Op3)),
  1104. (nxv8bf16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8bf16:$Op1, zsub0,
  1105. nxv8bf16:$Op2, zsub1),
  1106. nxv8i16:$Op3))>;
  1107. }
  1108. class sve2_int_perm_tbx<bits<2> sz8_64, string asm, ZPRRegOp zprty>
  1109. : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, zprty:$Zm),
  1110. asm, "\t$Zd, $Zn, $Zm",
  1111. "",
  1112. []>, Sched<[]> {
  1113. bits<5> Zd;
  1114. bits<5> Zm;
  1115. bits<5> Zn;
  1116. let Inst{31-24} = 0b00000101;
  1117. let Inst{23-22} = sz8_64;
  1118. let Inst{21} = 0b1;
  1119. let Inst{20-16} = Zm;
  1120. let Inst{15-10} = 0b001011;
  1121. let Inst{9-5} = Zn;
  1122. let Inst{4-0} = Zd;
  1123. let Constraints = "$Zd = $_Zd";
  1124. }
  1125. multiclass sve2_int_perm_tbx<string asm, SDPatternOperator op> {
  1126. def _B : sve2_int_perm_tbx<0b00, asm, ZPR8>;
  1127. def _H : sve2_int_perm_tbx<0b01, asm, ZPR16>;
  1128. def _S : sve2_int_perm_tbx<0b10, asm, ZPR32>;
  1129. def _D : sve2_int_perm_tbx<0b11, asm, ZPR64>;
  1130. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  1131. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1132. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1133. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1134. def : SVE_3_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1135. def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1136. def : SVE_3_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1137. def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1138. }
  1139. class sve_int_perm_reverse_z<bits<2> sz8_64, string asm, ZPRRegOp zprty>
  1140. : I<(outs zprty:$Zd), (ins zprty:$Zn),
  1141. asm, "\t$Zd, $Zn",
  1142. "",
  1143. []>, Sched<[]> {
  1144. bits<5> Zd;
  1145. bits<5> Zn;
  1146. let Inst{31-24} = 0b00000101;
  1147. let Inst{23-22} = sz8_64;
  1148. let Inst{21-10} = 0b111000001110;
  1149. let Inst{9-5} = Zn;
  1150. let Inst{4-0} = Zd;
  1151. }
  1152. multiclass sve_int_perm_reverse_z<string asm, SDPatternOperator op> {
  1153. def _B : sve_int_perm_reverse_z<0b00, asm, ZPR8>;
  1154. def _H : sve_int_perm_reverse_z<0b01, asm, ZPR16>;
  1155. def _S : sve_int_perm_reverse_z<0b10, asm, ZPR32>;
  1156. def _D : sve_int_perm_reverse_z<0b11, asm, ZPR64>;
  1157. def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME # _B)>;
  1158. def : SVE_1_Op_Pat<nxv8i16, op, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1159. def : SVE_1_Op_Pat<nxv4i32, op, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1160. def : SVE_1_Op_Pat<nxv2i64, op, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1161. def : SVE_1_Op_Pat<nxv2f16, op, nxv2f16, !cast<Instruction>(NAME # _D)>;
  1162. def : SVE_1_Op_Pat<nxv4f16, op, nxv4f16, !cast<Instruction>(NAME # _S)>;
  1163. def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>;
  1164. def : SVE_1_Op_Pat<nxv2f32, op, nxv2f32, !cast<Instruction>(NAME # _D)>;
  1165. def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>;
  1166. def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>;
  1167. def : SVE_1_Op_Pat<nxv2bf16, op, nxv2bf16, !cast<Instruction>(NAME # _D)>;
  1168. def : SVE_1_Op_Pat<nxv4bf16, op, nxv4bf16, !cast<Instruction>(NAME # _S)>;
  1169. def : SVE_1_Op_Pat<nxv8bf16, op, nxv8bf16, !cast<Instruction>(NAME # _H)>;
  1170. }
  1171. class sve_int_perm_reverse_p<bits<2> sz8_64, string asm, PPRRegOp pprty>
  1172. : I<(outs pprty:$Pd), (ins pprty:$Pn),
  1173. asm, "\t$Pd, $Pn",
  1174. "",
  1175. []>, Sched<[]> {
  1176. bits<4> Pd;
  1177. bits<4> Pn;
  1178. let Inst{31-24} = 0b00000101;
  1179. let Inst{23-22} = sz8_64;
  1180. let Inst{21-9} = 0b1101000100000;
  1181. let Inst{8-5} = Pn;
  1182. let Inst{4} = 0b0;
  1183. let Inst{3-0} = Pd;
  1184. }
  1185. multiclass sve_int_perm_reverse_p<string asm, SDPatternOperator op> {
  1186. def _B : sve_int_perm_reverse_p<0b00, asm, PPR8>;
  1187. def _H : sve_int_perm_reverse_p<0b01, asm, PPR16>;
  1188. def _S : sve_int_perm_reverse_p<0b10, asm, PPR32>;
  1189. def _D : sve_int_perm_reverse_p<0b11, asm, PPR64>;
  1190. def : SVE_1_Op_Pat<nxv16i1, op, nxv16i1, !cast<Instruction>(NAME # _B)>;
  1191. def : SVE_1_Op_Pat<nxv8i1, op, nxv8i1, !cast<Instruction>(NAME # _H)>;
  1192. def : SVE_1_Op_Pat<nxv4i1, op, nxv4i1, !cast<Instruction>(NAME # _S)>;
  1193. def : SVE_1_Op_Pat<nxv2i1, op, nxv2i1, !cast<Instruction>(NAME # _D)>;
  1194. }
  1195. class sve_int_perm_unpk<bits<2> sz16_64, bits<2> opc, string asm,
  1196. ZPRRegOp zprty1, ZPRRegOp zprty2>
  1197. : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
  1198. asm, "\t$Zd, $Zn",
  1199. "", []>, Sched<[]> {
  1200. bits<5> Zd;
  1201. bits<5> Zn;
  1202. let Inst{31-24} = 0b00000101;
  1203. let Inst{23-22} = sz16_64;
  1204. let Inst{21-18} = 0b1100;
  1205. let Inst{17-16} = opc;
  1206. let Inst{15-10} = 0b001110;
  1207. let Inst{9-5} = Zn;
  1208. let Inst{4-0} = Zd;
  1209. }
  1210. multiclass sve_int_perm_unpk<bits<2> opc, string asm, SDPatternOperator op> {
  1211. def _H : sve_int_perm_unpk<0b01, opc, asm, ZPR16, ZPR8>;
  1212. def _S : sve_int_perm_unpk<0b10, opc, asm, ZPR32, ZPR16>;
  1213. def _D : sve_int_perm_unpk<0b11, opc, asm, ZPR64, ZPR32>;
  1214. def : SVE_1_Op_Pat<nxv8i16, op, nxv16i8, !cast<Instruction>(NAME # _H)>;
  1215. def : SVE_1_Op_Pat<nxv4i32, op, nxv8i16, !cast<Instruction>(NAME # _S)>;
  1216. def : SVE_1_Op_Pat<nxv2i64, op, nxv4i32, !cast<Instruction>(NAME # _D)>;
  1217. }
  1218. class sve_int_perm_insrs<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  1219. RegisterClass srcRegType>
  1220. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Rm),
  1221. asm, "\t$Zdn, $Rm",
  1222. "",
  1223. []>, Sched<[]> {
  1224. bits<5> Rm;
  1225. bits<5> Zdn;
  1226. let Inst{31-24} = 0b00000101;
  1227. let Inst{23-22} = sz8_64;
  1228. let Inst{21-10} = 0b100100001110;
  1229. let Inst{9-5} = Rm;
  1230. let Inst{4-0} = Zdn;
  1231. let Constraints = "$Zdn = $_Zdn";
  1232. let DestructiveInstType = DestructiveOther;
  1233. }
  1234. multiclass sve_int_perm_insrs<string asm, SDPatternOperator op> {
  1235. def _B : sve_int_perm_insrs<0b00, asm, ZPR8, GPR32>;
  1236. def _H : sve_int_perm_insrs<0b01, asm, ZPR16, GPR32>;
  1237. def _S : sve_int_perm_insrs<0b10, asm, ZPR32, GPR32>;
  1238. def _D : sve_int_perm_insrs<0b11, asm, ZPR64, GPR64>;
  1239. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, i32, !cast<Instruction>(NAME # _B)>;
  1240. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, i32, !cast<Instruction>(NAME # _H)>;
  1241. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, i32, !cast<Instruction>(NAME # _S)>;
  1242. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, i64, !cast<Instruction>(NAME # _D)>;
  1243. }
  1244. class sve_int_perm_insrv<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  1245. FPRasZPROperand srcOpType>
  1246. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcOpType:$Vm),
  1247. asm, "\t$Zdn, $Vm",
  1248. "",
  1249. []>, Sched<[]> {
  1250. bits<5> Vm;
  1251. bits<5> Zdn;
  1252. let Inst{31-24} = 0b00000101;
  1253. let Inst{23-22} = sz8_64;
  1254. let Inst{21-10} = 0b110100001110;
  1255. let Inst{9-5} = Vm;
  1256. let Inst{4-0} = Zdn;
  1257. let Constraints = "$Zdn = $_Zdn";
  1258. let DestructiveInstType = DestructiveOther;
  1259. }
  1260. multiclass sve_int_perm_insrv<string asm, SDPatternOperator op> {
  1261. def _B : sve_int_perm_insrv<0b00, asm, ZPR8, FPR8asZPR>;
  1262. def _H : sve_int_perm_insrv<0b01, asm, ZPR16, FPR16asZPR>;
  1263. def _S : sve_int_perm_insrv<0b10, asm, ZPR32, FPR32asZPR>;
  1264. def _D : sve_int_perm_insrv<0b11, asm, ZPR64, FPR64asZPR>;
  1265. def : Pat<(nxv8f16 (op nxv8f16:$Zn, f16:$Vm)),
  1266. (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>;
  1267. def : Pat<(nxv4f32 (op nxv4f32:$Zn, f32:$Vm)),
  1268. (!cast<Instruction>(NAME # _S) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, ssub))>;
  1269. def : Pat<(nxv2f64 (op nxv2f64:$Zn, f64:$Vm)),
  1270. (!cast<Instruction>(NAME # _D) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, dsub))>;
  1271. def : Pat<(nxv8bf16 (op nxv8bf16:$Zn, bf16:$Vm)),
  1272. (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>;
  1273. // Keep integer insertions within the vector unit.
  1274. def : Pat<(nxv16i8 (op (nxv16i8 ZPR:$Zn), (i32 (vector_extract (nxv16i8 ZPR:$Vm), 0)))),
  1275. (!cast<Instruction>(NAME # _B) $Zn, ZPR:$Vm)>;
  1276. def : Pat<(nxv8i16 (op (nxv8i16 ZPR:$Zn), (i32 (vector_extract (nxv8i16 ZPR:$Vm), 0)))),
  1277. (!cast<Instruction>(NAME # _H) $Zn, ZPR:$Vm)>;
  1278. def : Pat<(nxv4i32 (op (nxv4i32 ZPR:$Zn), (i32 (vector_extract (nxv4i32 ZPR:$Vm), 0)))),
  1279. (!cast<Instruction>(NAME # _S) $Zn, ZPR: $Vm)>;
  1280. def : Pat<(nxv2i64 (op (nxv2i64 ZPR:$Zn), (i64 (vector_extract (nxv2i64 ZPR:$Vm), 0)))),
  1281. (!cast<Instruction>(NAME # _D) $Zn, ZPR:$Vm)>;
  1282. }
  1283. //===----------------------------------------------------------------------===//
  1284. // SVE Permute - Extract Group
  1285. //===----------------------------------------------------------------------===//
  1286. class sve_int_perm_extract_i<string asm>
  1287. : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, imm0_255:$imm8),
  1288. asm, "\t$Zdn, $_Zdn, $Zm, $imm8",
  1289. "", []>, Sched<[]> {
  1290. bits<5> Zdn;
  1291. bits<5> Zm;
  1292. bits<8> imm8;
  1293. let Inst{31-21} = 0b00000101001;
  1294. let Inst{20-16} = imm8{7-3};
  1295. let Inst{15-13} = 0b000;
  1296. let Inst{12-10} = imm8{2-0};
  1297. let Inst{9-5} = Zm;
  1298. let Inst{4-0} = Zdn;
  1299. let Constraints = "$Zdn = $_Zdn";
  1300. let DestructiveInstType = DestructiveOther;
  1301. let ElementSize = ElementSizeNone;
  1302. }
  1303. multiclass sve_int_perm_extract_i<string asm, SDPatternOperator op> {
  1304. def NAME : sve_int_perm_extract_i<asm>;
  1305. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, imm0_255,
  1306. !cast<Instruction>(NAME)>;
  1307. }
  1308. class sve2_int_perm_extract_i_cons<string asm>
  1309. : I<(outs ZPR8:$Zd), (ins ZZ_b:$Zn, imm0_255:$imm8),
  1310. asm, "\t$Zd, $Zn, $imm8",
  1311. "", []>, Sched<[]> {
  1312. bits<5> Zd;
  1313. bits<5> Zn;
  1314. bits<8> imm8;
  1315. let Inst{31-21} = 0b00000101011;
  1316. let Inst{20-16} = imm8{7-3};
  1317. let Inst{15-13} = 0b000;
  1318. let Inst{12-10} = imm8{2-0};
  1319. let Inst{9-5} = Zn;
  1320. let Inst{4-0} = Zd;
  1321. }
  1322. //===----------------------------------------------------------------------===//
  1323. // SVE Vector Select Group
  1324. //===----------------------------------------------------------------------===//
  1325. class sve_int_sel_vvv<bits<2> sz8_64, string asm, ZPRRegOp zprty>
  1326. : I<(outs zprty:$Zd), (ins PPRAny:$Pg, zprty:$Zn, zprty:$Zm),
  1327. asm, "\t$Zd, $Pg, $Zn, $Zm",
  1328. "",
  1329. []>, Sched<[]> {
  1330. bits<4> Pg;
  1331. bits<5> Zd;
  1332. bits<5> Zm;
  1333. bits<5> Zn;
  1334. let Inst{31-24} = 0b00000101;
  1335. let Inst{23-22} = sz8_64;
  1336. let Inst{21} = 0b1;
  1337. let Inst{20-16} = Zm;
  1338. let Inst{15-14} = 0b11;
  1339. let Inst{13-10} = Pg;
  1340. let Inst{9-5} = Zn;
  1341. let Inst{4-0} = Zd;
  1342. }
  1343. multiclass sve_int_sel_vvv<string asm, SDPatternOperator op> {
  1344. def _B : sve_int_sel_vvv<0b00, asm, ZPR8>;
  1345. def _H : sve_int_sel_vvv<0b01, asm, ZPR16>;
  1346. def _S : sve_int_sel_vvv<0b10, asm, ZPR32>;
  1347. def _D : sve_int_sel_vvv<0b11, asm, ZPR64>;
  1348. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  1349. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1350. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1351. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1352. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  1353. def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>;
  1354. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  1355. def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>;
  1356. def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>;
  1357. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  1358. def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
  1359. def : InstAlias<"mov $Zd, $Pg/m, $Zn",
  1360. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPRAny:$Pg, ZPR8:$Zn, ZPR8:$Zd), 1>;
  1361. def : InstAlias<"mov $Zd, $Pg/m, $Zn",
  1362. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, ZPR16:$Zn, ZPR16:$Zd), 1>;
  1363. def : InstAlias<"mov $Zd, $Pg/m, $Zn",
  1364. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, ZPR32:$Zn, ZPR32:$Zd), 1>;
  1365. def : InstAlias<"mov $Zd, $Pg/m, $Zn",
  1366. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, ZPR64:$Zn, ZPR64:$Zd), 1>;
  1367. }
  1368. //===----------------------------------------------------------------------===//
  1369. // SVE Predicate Logical Operations Group
  1370. //===----------------------------------------------------------------------===//
  1371. class sve_int_pred_log<bits<4> opc, string asm>
  1372. : I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
  1373. asm, "\t$Pd, $Pg/z, $Pn, $Pm",
  1374. "",
  1375. []>, Sched<[]> {
  1376. bits<4> Pd;
  1377. bits<4> Pg;
  1378. bits<4> Pm;
  1379. bits<4> Pn;
  1380. let Inst{31-24} = 0b00100101;
  1381. let Inst{23-22} = opc{3-2};
  1382. let Inst{21-20} = 0b00;
  1383. let Inst{19-16} = Pm;
  1384. let Inst{15-14} = 0b01;
  1385. let Inst{13-10} = Pg;
  1386. let Inst{9} = opc{1};
  1387. let Inst{8-5} = Pn;
  1388. let Inst{4} = opc{0};
  1389. let Inst{3-0} = Pd;
  1390. // SEL has no predication qualifier.
  1391. let AsmString = !if(!eq(opc, 0b0011),
  1392. !strconcat(asm, "\t$Pd, $Pg, $Pn, $Pm"),
  1393. !strconcat(asm, "\t$Pd, $Pg/z, $Pn, $Pm"));
  1394. let Defs = !if(!eq (opc{2}, 1), [NZCV], []);
  1395. }
  1396. multiclass sve_int_pred_log<bits<4> opc, string asm, SDPatternOperator op,
  1397. SDPatternOperator op_nopred = null_frag> {
  1398. def NAME : sve_int_pred_log<opc, asm>;
  1399. def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
  1400. def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, nxv8i1, !cast<Instruction>(NAME)>;
  1401. def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, nxv4i1, !cast<Instruction>(NAME)>;
  1402. def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, nxv2i1, !cast<Instruction>(NAME)>;
  1403. def : SVE_2_Op_AllActive_Pat<nxv16i1, op_nopred, nxv16i1, nxv16i1,
  1404. !cast<Instruction>(NAME), PTRUE_B>;
  1405. def : SVE_2_Op_AllActive_Pat<nxv8i1, op_nopred, nxv8i1, nxv8i1,
  1406. !cast<Instruction>(NAME), PTRUE_H>;
  1407. def : SVE_2_Op_AllActive_Pat<nxv4i1, op_nopred, nxv4i1, nxv4i1,
  1408. !cast<Instruction>(NAME), PTRUE_S>;
  1409. def : SVE_2_Op_AllActive_Pat<nxv2i1, op_nopred, nxv2i1, nxv2i1,
  1410. !cast<Instruction>(NAME), PTRUE_D>;
  1411. }
  1412. // An instance of sve_int_pred_log_and but uses op_nopred's first operand as the
  1413. // general predicate.
  1414. multiclass sve_int_pred_log_v2<bits<4> opc, string asm, SDPatternOperator op,
  1415. SDPatternOperator op_nopred> :
  1416. sve_int_pred_log<opc, asm, op> {
  1417. def : Pat<(nxv16i1 (op_nopred nxv16i1:$Op1, nxv16i1:$Op2)),
  1418. (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
  1419. def : Pat<(nxv8i1 (op_nopred nxv8i1:$Op1, nxv8i1:$Op2)),
  1420. (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
  1421. def : Pat<(nxv4i1 (op_nopred nxv4i1:$Op1, nxv4i1:$Op2)),
  1422. (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
  1423. def : Pat<(nxv2i1 (op_nopred nxv2i1:$Op1, nxv2i1:$Op2)),
  1424. (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
  1425. }
  1426. //===----------------------------------------------------------------------===//
  1427. // SVE Logical Mask Immediate Group
  1428. //===----------------------------------------------------------------------===//
  1429. class sve_int_log_imm<bits<2> opc, string asm>
  1430. : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, logical_imm64:$imms13),
  1431. asm, "\t$Zdn, $_Zdn, $imms13",
  1432. "", []>, Sched<[]> {
  1433. bits<5> Zdn;
  1434. bits<13> imms13;
  1435. let Inst{31-24} = 0b00000101;
  1436. let Inst{23-22} = opc;
  1437. let Inst{21-18} = 0b0000;
  1438. let Inst{17-5} = imms13;
  1439. let Inst{4-0} = Zdn;
  1440. let Constraints = "$Zdn = $_Zdn";
  1441. let DecoderMethod = "DecodeSVELogicalImmInstruction";
  1442. let DestructiveInstType = DestructiveOther;
  1443. let ElementSize = ElementSizeNone;
  1444. }
  1445. multiclass sve_int_log_imm<bits<2> opc, string asm, string alias, SDPatternOperator op> {
  1446. def NAME : sve_int_log_imm<opc, asm>;
  1447. def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8, i32, SVELogicalImm8Pat, !cast<Instruction>(NAME)>;
  1448. def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16Pat, !cast<Instruction>(NAME)>;
  1449. def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32Pat, !cast<Instruction>(NAME)>;
  1450. def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64Pat, !cast<Instruction>(NAME)>;
  1451. def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
  1452. (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8:$imm), 4>;
  1453. def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
  1454. (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16:$imm), 3>;
  1455. def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
  1456. (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32:$imm), 2>;
  1457. def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
  1458. (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8_not:$imm), 0>;
  1459. def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
  1460. (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16_not:$imm), 0>;
  1461. def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
  1462. (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32_not:$imm), 0>;
  1463. def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
  1464. (!cast<Instruction>(NAME) ZPR64:$Zdn, logical_imm64_not:$imm), 0>;
  1465. }
  1466. multiclass sve_int_log_imm_bic<SDPatternOperator op> {
  1467. def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8, i32, SVELogicalImm8NotPat, !cast<Instruction>("AND_ZI")>;
  1468. def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16NotPat, !cast<Instruction>("AND_ZI")>;
  1469. def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32NotPat, !cast<Instruction>("AND_ZI")>;
  1470. def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64NotPat, !cast<Instruction>("AND_ZI")>;
  1471. }
  1472. class sve_int_dup_mask_imm<string asm>
  1473. : I<(outs ZPR64:$Zd), (ins logical_imm64:$imms),
  1474. asm, "\t$Zd, $imms",
  1475. "",
  1476. []>, Sched<[]> {
  1477. bits<5> Zd;
  1478. bits<13> imms;
  1479. let Inst{31-18} = 0b00000101110000;
  1480. let Inst{17-5} = imms;
  1481. let Inst{4-0} = Zd;
  1482. let isReMaterializable = 1;
  1483. let DecoderMethod = "DecodeSVELogicalImmInstruction";
  1484. }
  1485. multiclass sve_int_dup_mask_imm<string asm> {
  1486. def NAME : sve_int_dup_mask_imm<asm>;
  1487. def : InstAlias<"dupm $Zd, $imm",
  1488. (!cast<Instruction>(NAME) ZPR8:$Zd, sve_logical_imm8:$imm), 4>;
  1489. def : InstAlias<"dupm $Zd, $imm",
  1490. (!cast<Instruction>(NAME) ZPR16:$Zd, sve_logical_imm16:$imm), 3>;
  1491. def : InstAlias<"dupm $Zd, $imm",
  1492. (!cast<Instruction>(NAME) ZPR32:$Zd, sve_logical_imm32:$imm), 2>;
  1493. // All Zd.b forms have a CPY/DUP equivalent, hence no byte alias here.
  1494. def : InstAlias<"mov $Zd, $imm",
  1495. (!cast<Instruction>(NAME) ZPR16:$Zd, sve_preferred_logical_imm16:$imm), 7>;
  1496. def : InstAlias<"mov $Zd, $imm",
  1497. (!cast<Instruction>(NAME) ZPR32:$Zd, sve_preferred_logical_imm32:$imm), 6>;
  1498. def : InstAlias<"mov $Zd, $imm",
  1499. (!cast<Instruction>(NAME) ZPR64:$Zd, sve_preferred_logical_imm64:$imm), 5>;
  1500. def : Pat<(nxv2i64 (AArch64dup (i64 logical_imm64:$imm))),
  1501. (!cast<Instruction>(NAME) logical_imm64:$imm)>;
  1502. }
  1503. //===----------------------------------------------------------------------===//
  1504. // SVE Integer Arithmetic - Unpredicated Group.
  1505. //===----------------------------------------------------------------------===//
  1506. class sve_int_bin_cons_arit_0<bits<2> sz8_64, bits<3> opc, string asm,
  1507. ZPRRegOp zprty>
  1508. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
  1509. asm, "\t$Zd, $Zn, $Zm",
  1510. "", []>, Sched<[]> {
  1511. bits<5> Zd;
  1512. bits<5> Zm;
  1513. bits<5> Zn;
  1514. let Inst{31-24} = 0b00000100;
  1515. let Inst{23-22} = sz8_64;
  1516. let Inst{21} = 0b1;
  1517. let Inst{20-16} = Zm;
  1518. let Inst{15-13} = 0b000;
  1519. let Inst{12-10} = opc;
  1520. let Inst{9-5} = Zn;
  1521. let Inst{4-0} = Zd;
  1522. }
  1523. multiclass sve_int_bin_cons_arit_0<bits<3> opc, string asm, SDPatternOperator op> {
  1524. def _B : sve_int_bin_cons_arit_0<0b00, opc, asm, ZPR8>;
  1525. def _H : sve_int_bin_cons_arit_0<0b01, opc, asm, ZPR16>;
  1526. def _S : sve_int_bin_cons_arit_0<0b10, opc, asm, ZPR32>;
  1527. def _D : sve_int_bin_cons_arit_0<0b11, opc, asm, ZPR64>;
  1528. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  1529. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1530. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1531. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1532. }
  1533. //===----------------------------------------------------------------------===//
  1534. // SVE Floating Point Arithmetic - Predicated Group
  1535. //===----------------------------------------------------------------------===//
  1536. class sve_fp_2op_i_p_zds<bits<2> sz, bits<3> opc, string asm,
  1537. ZPRRegOp zprty,
  1538. Operand imm_ty>
  1539. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, imm_ty:$i1),
  1540. asm, "\t$Zdn, $Pg/m, $_Zdn, $i1",
  1541. "",
  1542. []>, Sched<[]> {
  1543. bits<3> Pg;
  1544. bits<5> Zdn;
  1545. bit i1;
  1546. let Inst{31-24} = 0b01100101;
  1547. let Inst{23-22} = sz;
  1548. let Inst{21-19} = 0b011;
  1549. let Inst{18-16} = opc;
  1550. let Inst{15-13} = 0b100;
  1551. let Inst{12-10} = Pg;
  1552. let Inst{9-6} = 0b0000;
  1553. let Inst{5} = i1;
  1554. let Inst{4-0} = Zdn;
  1555. let Constraints = "$Zdn = $_Zdn";
  1556. let DestructiveInstType = DestructiveOther;
  1557. let ElementSize = zprty.ElementSize;
  1558. }
  1559. multiclass sve_fp_2op_i_p_zds<bits<3> opc, string asm, string Ps, Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> {
  1560. let DestructiveInstType = DestructiveBinaryImm in {
  1561. def _H : SVEPseudo2Instr<Ps # _H, 1>, sve_fp_2op_i_p_zds<0b01, opc, asm, ZPR16, imm_ty>;
  1562. def _S : SVEPseudo2Instr<Ps # _S, 1>, sve_fp_2op_i_p_zds<0b10, opc, asm, ZPR32, imm_ty>;
  1563. def _D : SVEPseudo2Instr<Ps # _D, 1>, sve_fp_2op_i_p_zds<0b11, opc, asm, ZPR64, imm_ty>;
  1564. }
  1565. def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H")>;
  1566. def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H")>;
  1567. def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S")>;
  1568. def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S")>;
  1569. def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D")>;
  1570. def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D")>;
  1571. }
  1572. class sve_fp_2op_p_zds<bits<2> sz, bits<4> opc, string asm,
  1573. ZPRRegOp zprty>
  1574. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
  1575. asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
  1576. "",
  1577. []>, Sched<[]> {
  1578. bits<3> Pg;
  1579. bits<5> Zdn;
  1580. bits<5> Zm;
  1581. let Inst{31-24} = 0b01100101;
  1582. let Inst{23-22} = sz;
  1583. let Inst{21-20} = 0b00;
  1584. let Inst{19-16} = opc;
  1585. let Inst{15-13} = 0b100;
  1586. let Inst{12-10} = Pg;
  1587. let Inst{9-5} = Zm;
  1588. let Inst{4-0} = Zdn;
  1589. let Constraints = "$Zdn = $_Zdn";
  1590. let DestructiveInstType = DestructiveOther;
  1591. let ElementSize = zprty.ElementSize;
  1592. }
  1593. multiclass sve_fp_2op_p_zds<bits<4> opc, string asm, string Ps,
  1594. SDPatternOperator op, DestructiveInstTypeEnum flags,
  1595. string revname="", bit isReverseInstr=0> {
  1596. let DestructiveInstType = flags in {
  1597. def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>,
  1598. SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
  1599. def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>,
  1600. SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
  1601. def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>,
  1602. SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
  1603. }
  1604. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  1605. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  1606. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  1607. }
  1608. multiclass sve_fp_2op_p_zds_fscale<bits<4> opc, string asm,
  1609. SDPatternOperator op> {
  1610. def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>;
  1611. def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>;
  1612. def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>;
  1613. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1614. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1615. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1616. }
  1617. multiclass sve_fp_2op_p_zds_zeroing_hsd<SDPatternOperator op> {
  1618. def _ZERO_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>;
  1619. def _ZERO_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>;
  1620. def _ZERO_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>;
  1621. def : SVE_3_Op_Pat_SelZero<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _ZERO_H)>;
  1622. def : SVE_3_Op_Pat_SelZero<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _ZERO_S)>;
  1623. def : SVE_3_Op_Pat_SelZero<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _ZERO_D)>;
  1624. }
  1625. class sve_fp_ftmad<bits<2> sz, string asm, ZPRRegOp zprty>
  1626. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, timm32_0_7:$imm3),
  1627. asm, "\t$Zdn, $_Zdn, $Zm, $imm3",
  1628. "",
  1629. []>, Sched<[]> {
  1630. bits<5> Zdn;
  1631. bits<5> Zm;
  1632. bits<3> imm3;
  1633. let Inst{31-24} = 0b01100101;
  1634. let Inst{23-22} = sz;
  1635. let Inst{21-19} = 0b010;
  1636. let Inst{18-16} = imm3;
  1637. let Inst{15-10} = 0b100000;
  1638. let Inst{9-5} = Zm;
  1639. let Inst{4-0} = Zdn;
  1640. let Constraints = "$Zdn = $_Zdn";
  1641. let DestructiveInstType = DestructiveOther;
  1642. let ElementSize = ElementSizeNone;
  1643. }
  1644. multiclass sve_fp_ftmad<string asm, SDPatternOperator op> {
  1645. def _H : sve_fp_ftmad<0b01, asm, ZPR16>;
  1646. def _S : sve_fp_ftmad<0b10, asm, ZPR32>;
  1647. def _D : sve_fp_ftmad<0b11, asm, ZPR64>;
  1648. def : Pat<(nxv8f16 (op (nxv8f16 ZPR16:$Zn), (nxv8f16 ZPR16:$Zm), (i32 timm32_0_7:$imm))),
  1649. (!cast<Instruction>(NAME # _H) ZPR16:$Zn, ZPR16:$Zm, timm32_0_7:$imm)>;
  1650. def : Pat<(nxv4f32 (op (nxv4f32 ZPR32:$Zn), (nxv4f32 ZPR32:$Zm), (i32 timm32_0_7:$imm))),
  1651. (!cast<Instruction>(NAME # _S) ZPR32:$Zn, ZPR32:$Zm, timm32_0_7:$imm)>;
  1652. def : Pat<(nxv2f64 (op (nxv2f64 ZPR64:$Zn), (nxv2f64 ZPR64:$Zm), (i32 timm32_0_7:$imm))),
  1653. (!cast<Instruction>(NAME # _D) ZPR64:$Zn, ZPR64:$Zm, timm32_0_7:$imm)>;
  1654. }
  1655. multiclass sve_fp_2op_i_p_zds_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator ir_op = null_frag> {
  1656. def _UNDEF_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesUndef>;
  1657. def _UNDEF_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesUndef>;
  1658. def _UNDEF_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesUndef>;
  1659. def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_UNDEF_H")>;
  1660. def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_UNDEF_H")>;
  1661. def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, A, 0, !cast<Instruction>(NAME # "_UNDEF_H")>;
  1662. def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, B, 1, !cast<Instruction>(NAME # "_UNDEF_H")>;
  1663. def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, A, 0, !cast<Instruction>(NAME # "_UNDEF_H")>;
  1664. def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, B, 1, !cast<Instruction>(NAME # "_UNDEF_H")>;
  1665. def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_UNDEF_S")>;
  1666. def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_UNDEF_S")>;
  1667. def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, A, 0, !cast<Instruction>(NAME # "_UNDEF_S")>;
  1668. def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, B, 1, !cast<Instruction>(NAME # "_UNDEF_S")>;
  1669. def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_UNDEF_D")>;
  1670. def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_UNDEF_D")>;
  1671. }
  1672. multiclass sve_fp_2op_i_p_zds_zeroing_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> {
  1673. def _ZERO_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesZero>;
  1674. def _ZERO_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesZero>;
  1675. def _ZERO_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesZero>;
  1676. let AddedComplexity = 2 in {
  1677. def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_ZERO_H")>;
  1678. def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_ZERO_H")>;
  1679. def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_ZERO_S")>;
  1680. def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_ZERO_S")>;
  1681. def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_ZERO_D")>;
  1682. def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_ZERO_D")>;
  1683. }
  1684. }
  1685. //===----------------------------------------------------------------------===//
  1686. // SVE Floating Point Arithmetic - Unpredicated Group
  1687. //===----------------------------------------------------------------------===//
  1688. class sve_fp_3op_u_zd<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
  1689. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
  1690. asm, "\t$Zd, $Zn, $Zm",
  1691. "",
  1692. []>, Sched<[]> {
  1693. bits<5> Zd;
  1694. bits<5> Zm;
  1695. bits<5> Zn;
  1696. let Inst{31-24} = 0b01100101;
  1697. let Inst{23-22} = sz;
  1698. let Inst{21} = 0b0;
  1699. let Inst{20-16} = Zm;
  1700. let Inst{15-13} = 0b000;
  1701. let Inst{12-10} = opc;
  1702. let Inst{9-5} = Zn;
  1703. let Inst{4-0} = Zd;
  1704. }
  1705. multiclass sve_fp_3op_u_zd<bits<3> opc, string asm, SDPatternOperator op,
  1706. SDPatternOperator predicated_op = null_frag> {
  1707. def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
  1708. def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
  1709. def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
  1710. def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  1711. def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  1712. def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  1713. def : SVE_2_Op_Pred_All_Active<nxv8f16, predicated_op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  1714. def : SVE_2_Op_Pred_All_Active<nxv4f32, predicated_op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  1715. def : SVE_2_Op_Pred_All_Active<nxv2f64, predicated_op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  1716. }
  1717. multiclass sve_fp_3op_u_zd_ftsmul<bits<3> opc, string asm, SDPatternOperator op> {
  1718. def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
  1719. def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
  1720. def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
  1721. def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  1722. def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  1723. def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  1724. }
  1725. //===----------------------------------------------------------------------===//
  1726. // SVE Floating Point Fused Multiply-Add Group
  1727. //===----------------------------------------------------------------------===//
  1728. class sve_fp_3op_p_zds_a<bits<2> sz, bits<2> opc, string asm, ZPRRegOp zprty>
  1729. : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
  1730. asm, "\t$Zda, $Pg/m, $Zn, $Zm",
  1731. "",
  1732. []>, Sched<[]> {
  1733. bits<3> Pg;
  1734. bits<5> Zda;
  1735. bits<5> Zm;
  1736. bits<5> Zn;
  1737. let Inst{31-24} = 0b01100101;
  1738. let Inst{23-22} = sz;
  1739. let Inst{21} = 0b1;
  1740. let Inst{20-16} = Zm;
  1741. let Inst{15} = 0b0;
  1742. let Inst{14-13} = opc;
  1743. let Inst{12-10} = Pg;
  1744. let Inst{9-5} = Zn;
  1745. let Inst{4-0} = Zda;
  1746. let Constraints = "$Zda = $_Zda";
  1747. let ElementSize = zprty.ElementSize;
  1748. }
  1749. multiclass sve_fp_3op_p_zds_a<bits<2> opc, string asm, string Ps,
  1750. SDPatternOperator op, string revname,
  1751. bit isReverseInstr=0> {
  1752. let DestructiveInstType = DestructiveTernaryCommWithRev in {
  1753. def _H : sve_fp_3op_p_zds_a<0b01, opc, asm, ZPR16>,
  1754. SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
  1755. def _S : sve_fp_3op_p_zds_a<0b10, opc, asm, ZPR32>,
  1756. SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
  1757. def _D : sve_fp_3op_p_zds_a<0b11, opc, asm, ZPR64>,
  1758. SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
  1759. }
  1760. def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  1761. def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  1762. def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  1763. }
  1764. class sve_fp_3op_p_zds_b<bits<2> sz, bits<2> opc, string asm,
  1765. ZPRRegOp zprty>
  1766. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
  1767. asm, "\t$Zdn, $Pg/m, $Zm, $Za",
  1768. "",
  1769. []>, Sched<[]> {
  1770. bits<3> Pg;
  1771. bits<5> Za;
  1772. bits<5> Zdn;
  1773. bits<5> Zm;
  1774. let Inst{31-24} = 0b01100101;
  1775. let Inst{23-22} = sz;
  1776. let Inst{21} = 0b1;
  1777. let Inst{20-16} = Za;
  1778. let Inst{15} = 0b1;
  1779. let Inst{14-13} = opc;
  1780. let Inst{12-10} = Pg;
  1781. let Inst{9-5} = Zm;
  1782. let Inst{4-0} = Zdn;
  1783. let Constraints = "$Zdn = $_Zdn";
  1784. let DestructiveInstType = DestructiveOther;
  1785. let ElementSize = zprty.ElementSize;
  1786. }
  1787. multiclass sve_fp_3op_p_zds_b<bits<2> opc, string asm, SDPatternOperator op,
  1788. string revname, bit isReverseInstr> {
  1789. def _H : sve_fp_3op_p_zds_b<0b01, opc, asm, ZPR16>,
  1790. SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
  1791. def _S : sve_fp_3op_p_zds_b<0b10, opc, asm, ZPR32>,
  1792. SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
  1793. def _D : sve_fp_3op_p_zds_b<0b11, opc, asm, ZPR64>,
  1794. SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
  1795. def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  1796. def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  1797. def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  1798. }
  1799. multiclass sve_fp_3op_p_zds_zx {
  1800. def _UNDEF_H : PredThreeOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
  1801. def _UNDEF_S : PredThreeOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
  1802. def _UNDEF_D : PredThreeOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
  1803. }
  1804. //===----------------------------------------------------------------------===//
  1805. // SVE Floating Point Multiply-Add - Indexed Group
  1806. //===----------------------------------------------------------------------===//
  1807. class sve_fp_fma_by_indexed_elem<bits<2> sz, bit opc, string asm,
  1808. ZPRRegOp zprty1,
  1809. ZPRRegOp zprty2, Operand itype>
  1810. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty1:$Zn, zprty2:$Zm, itype:$iop),
  1811. asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
  1812. bits<5> Zda;
  1813. bits<5> Zn;
  1814. let Inst{31-24} = 0b01100100;
  1815. let Inst{23-22} = sz;
  1816. let Inst{21} = 0b1;
  1817. let Inst{15-11} = 0;
  1818. let Inst{10} = opc;
  1819. let Inst{9-5} = Zn;
  1820. let Inst{4-0} = Zda;
  1821. let Constraints = "$Zda = $_Zda";
  1822. let DestructiveInstType = DestructiveOther;
  1823. let ElementSize = ElementSizeNone;
  1824. }
  1825. multiclass sve_fp_fma_by_indexed_elem<bit opc, string asm,
  1826. SDPatternOperator op> {
  1827. def _H : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
  1828. bits<3> Zm;
  1829. bits<3> iop;
  1830. let Inst{22} = iop{2};
  1831. let Inst{20-19} = iop{1-0};
  1832. let Inst{18-16} = Zm;
  1833. }
  1834. def _S : sve_fp_fma_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR3b32, VectorIndexS32b> {
  1835. bits<3> Zm;
  1836. bits<2> iop;
  1837. let Inst{20-19} = iop;
  1838. let Inst{18-16} = Zm;
  1839. }
  1840. def _D : sve_fp_fma_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR4b64, VectorIndexD32b> {
  1841. bits<4> Zm;
  1842. bit iop;
  1843. let Inst{20} = iop;
  1844. let Inst{19-16} = Zm;
  1845. }
  1846. def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b_timm:$idx))),
  1847. (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b_timm:$idx)>;
  1848. def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b_timm:$idx))),
  1849. (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx)>;
  1850. def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b_timm:$idx))),
  1851. (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx)>;
  1852. }
  1853. //===----------------------------------------------------------------------===//
  1854. // SVE Floating Point Multiply - Indexed Group
  1855. //===----------------------------------------------------------------------===//
  1856. class sve_fp_fmul_by_indexed_elem<bits<2> sz, string asm, ZPRRegOp zprty,
  1857. ZPRRegOp zprty2, Operand itype>
  1858. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty2:$Zm, itype:$iop),
  1859. asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
  1860. bits<5> Zd;
  1861. bits<5> Zn;
  1862. let Inst{31-24} = 0b01100100;
  1863. let Inst{23-22} = sz;
  1864. let Inst{21} = 0b1;
  1865. let Inst{15-10} = 0b001000;
  1866. let Inst{9-5} = Zn;
  1867. let Inst{4-0} = Zd;
  1868. }
  1869. multiclass sve_fp_fmul_by_indexed_elem<string asm, SDPatternOperator op> {
  1870. def _H : sve_fp_fmul_by_indexed_elem<{0, ?}, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
  1871. bits<3> Zm;
  1872. bits<3> iop;
  1873. let Inst{22} = iop{2};
  1874. let Inst{20-19} = iop{1-0};
  1875. let Inst{18-16} = Zm;
  1876. }
  1877. def _S : sve_fp_fmul_by_indexed_elem<0b10, asm, ZPR32, ZPR3b32, VectorIndexS32b> {
  1878. bits<3> Zm;
  1879. bits<2> iop;
  1880. let Inst{20-19} = iop;
  1881. let Inst{18-16} = Zm;
  1882. }
  1883. def _D : sve_fp_fmul_by_indexed_elem<0b11, asm, ZPR64, ZPR4b64, VectorIndexD32b> {
  1884. bits<4> Zm;
  1885. bit iop;
  1886. let Inst{20} = iop;
  1887. let Inst{19-16} = Zm;
  1888. }
  1889. def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
  1890. (!cast<Instruction>(NAME # _H) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
  1891. def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b_timm:$idx))),
  1892. (!cast<Instruction>(NAME # _S) $Op1, $Op2, VectorIndexS32b_timm:$idx)>;
  1893. def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b_timm:$idx))),
  1894. (!cast<Instruction>(NAME # _D) $Op1, $Op2, VectorIndexD32b_timm:$idx)>;
  1895. }
  1896. //===----------------------------------------------------------------------===//
  1897. // SVE Floating Point Complex Multiply-Add Group
  1898. //===----------------------------------------------------------------------===//
  1899. class sve_fp_fcmla<bits<2> sz, string asm, ZPRRegOp zprty>
  1900. : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm,
  1901. complexrotateop:$imm),
  1902. asm, "\t$Zda, $Pg/m, $Zn, $Zm, $imm",
  1903. "", []>, Sched<[]> {
  1904. bits<5> Zda;
  1905. bits<3> Pg;
  1906. bits<5> Zn;
  1907. bits<5> Zm;
  1908. bits<2> imm;
  1909. let Inst{31-24} = 0b01100100;
  1910. let Inst{23-22} = sz;
  1911. let Inst{21} = 0;
  1912. let Inst{20-16} = Zm;
  1913. let Inst{15} = 0;
  1914. let Inst{14-13} = imm;
  1915. let Inst{12-10} = Pg;
  1916. let Inst{9-5} = Zn;
  1917. let Inst{4-0} = Zda;
  1918. let Constraints = "$Zda = $_Zda";
  1919. let DestructiveInstType = DestructiveOther;
  1920. let ElementSize = zprty.ElementSize;
  1921. }
  1922. multiclass sve_fp_fcmla<string asm, SDPatternOperator op> {
  1923. def _H : sve_fp_fcmla<0b01, asm, ZPR16>;
  1924. def _S : sve_fp_fcmla<0b10, asm, ZPR32>;
  1925. def _D : sve_fp_fcmla<0b11, asm, ZPR64>;
  1926. def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, nxv8f16:$Op4, (i32 complexrotateop:$imm))),
  1927. (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
  1928. def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, nxv4f32:$Op4, (i32 complexrotateop:$imm))),
  1929. (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
  1930. def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, nxv2f64:$Op4, (i32 complexrotateop:$imm))),
  1931. (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
  1932. }
  1933. //===----------------------------------------------------------------------===//
  1934. // SVE Floating Point Complex Multiply-Add - Indexed Group
  1935. //===----------------------------------------------------------------------===//
  1936. class sve_fp_fcmla_by_indexed_elem<bits<2> sz, string asm,
  1937. ZPRRegOp zprty,
  1938. ZPRRegOp zprty2, Operand itype>
  1939. : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty2:$Zm, itype:$iop,
  1940. complexrotateop:$imm),
  1941. asm, "\t$Zda, $Zn, $Zm$iop, $imm",
  1942. "", []>, Sched<[]> {
  1943. bits<5> Zda;
  1944. bits<5> Zn;
  1945. bits<2> imm;
  1946. let Inst{31-24} = 0b01100100;
  1947. let Inst{23-22} = sz;
  1948. let Inst{21} = 0b1;
  1949. let Inst{15-12} = 0b0001;
  1950. let Inst{11-10} = imm;
  1951. let Inst{9-5} = Zn;
  1952. let Inst{4-0} = Zda;
  1953. let Constraints = "$Zda = $_Zda";
  1954. let DestructiveInstType = DestructiveOther;
  1955. let ElementSize = ElementSizeNone;
  1956. }
  1957. multiclass sve_fp_fcmla_by_indexed_elem<string asm, SDPatternOperator op> {
  1958. def _H : sve_fp_fcmla_by_indexed_elem<0b10, asm, ZPR16, ZPR3b16, VectorIndexS32b> {
  1959. bits<3> Zm;
  1960. bits<2> iop;
  1961. let Inst{20-19} = iop;
  1962. let Inst{18-16} = Zm;
  1963. }
  1964. def _S : sve_fp_fcmla_by_indexed_elem<0b11, asm, ZPR32, ZPR4b32, VectorIndexD32b> {
  1965. bits<4> Zm;
  1966. bits<1> iop;
  1967. let Inst{20} = iop;
  1968. let Inst{19-16} = Zm;
  1969. }
  1970. def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
  1971. (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
  1972. def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
  1973. (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
  1974. }
  1975. //===----------------------------------------------------------------------===//
  1976. // SVE Floating Point Complex Addition Group
  1977. //===----------------------------------------------------------------------===//
  1978. class sve_fp_fcadd<bits<2> sz, string asm, ZPRRegOp zprty>
  1979. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm,
  1980. complexrotateopodd:$imm),
  1981. asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm, $imm",
  1982. "",
  1983. []>, Sched<[]> {
  1984. bits<5> Zdn;
  1985. bits<5> Zm;
  1986. bits<3> Pg;
  1987. bit imm;
  1988. let Inst{31-24} = 0b01100100;
  1989. let Inst{23-22} = sz;
  1990. let Inst{21-17} = 0;
  1991. let Inst{16} = imm;
  1992. let Inst{15-13} = 0b100;
  1993. let Inst{12-10} = Pg;
  1994. let Inst{9-5} = Zm;
  1995. let Inst{4-0} = Zdn;
  1996. let Constraints = "$Zdn = $_Zdn";
  1997. let DestructiveInstType = DestructiveOther;
  1998. let ElementSize = zprty.ElementSize;
  1999. }
  2000. multiclass sve_fp_fcadd<string asm, SDPatternOperator op> {
  2001. def _H : sve_fp_fcadd<0b01, asm, ZPR16>;
  2002. def _S : sve_fp_fcadd<0b10, asm, ZPR32>;
  2003. def _D : sve_fp_fcadd<0b11, asm, ZPR64>;
  2004. def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 complexrotateopodd:$imm))),
  2005. (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
  2006. def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 complexrotateopodd:$imm))),
  2007. (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
  2008. def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 complexrotateopodd:$imm))),
  2009. (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
  2010. }
  2011. //===----------------------------------------------------------------------===//
  2012. // SVE2 Floating Point Convert Group
  2013. //===----------------------------------------------------------------------===//
  2014. class sve2_fp_convert_precision<bits<4> opc, string asm,
  2015. ZPRRegOp zprty1, ZPRRegOp zprty2>
  2016. : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, PPR3bAny:$Pg, zprty2:$Zn),
  2017. asm, "\t$Zd, $Pg/m, $Zn",
  2018. "",
  2019. []>, Sched<[]> {
  2020. bits<5> Zd;
  2021. bits<5> Zn;
  2022. bits<3> Pg;
  2023. let Inst{31-24} = 0b01100100;
  2024. let Inst{23-22} = opc{3-2};
  2025. let Inst{21-18} = 0b0010;
  2026. let Inst{17-16} = opc{1-0};
  2027. let Inst{15-13} = 0b101;
  2028. let Inst{12-10} = Pg;
  2029. let Inst{9-5} = Zn;
  2030. let Inst{4-0} = Zd;
  2031. let Constraints = "$Zd = $_Zd";
  2032. }
  2033. multiclass sve2_fp_convert_down_narrow<string asm, string op> {
  2034. def _StoH : sve2_fp_convert_precision<0b1000, asm, ZPR16, ZPR32>;
  2035. def _DtoS : sve2_fp_convert_precision<0b1110, asm, ZPR32, ZPR64>;
  2036. def : SVE_3_Op_Pat<nxv8f16, !cast<SDPatternOperator>(op # _f16f32), nxv8f16, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _StoH)>;
  2037. def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
  2038. }
  2039. multiclass sve2_fp_convert_up_long<string asm, string op> {
  2040. def _HtoS : sve2_fp_convert_precision<0b1001, asm, ZPR32, ZPR16>;
  2041. def _StoD : sve2_fp_convert_precision<0b1111, asm, ZPR64, ZPR32>;
  2042. def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f16), nxv4f32, nxv4i1, nxv8f16, !cast<Instruction>(NAME # _HtoS)>;
  2043. def : SVE_3_Op_Pat<nxv2f64, !cast<SDPatternOperator>(op # _f64f32), nxv2f64, nxv2i1, nxv4f32, !cast<Instruction>(NAME # _StoD)>;
  2044. }
  2045. multiclass sve2_fp_convert_down_odd_rounding_top<string asm, string op> {
  2046. def _DtoS : sve2_fp_convert_precision<0b0010, asm, ZPR32, ZPR64>;
  2047. def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
  2048. }
  2049. //===----------------------------------------------------------------------===//
  2050. // SVE2 Floating Point Pairwise Group
  2051. //===----------------------------------------------------------------------===//
  2052. class sve2_fp_pairwise_pred<bits<2> sz, bits<3> opc, string asm,
  2053. ZPRRegOp zprty>
  2054. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
  2055. asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
  2056. "",
  2057. []>, Sched<[]> {
  2058. bits<3> Pg;
  2059. bits<5> Zm;
  2060. bits<5> Zdn;
  2061. let Inst{31-24} = 0b01100100;
  2062. let Inst{23-22} = sz;
  2063. let Inst{21-19} = 0b010;
  2064. let Inst{18-16} = opc;
  2065. let Inst{15-13} = 0b100;
  2066. let Inst{12-10} = Pg;
  2067. let Inst{9-5} = Zm;
  2068. let Inst{4-0} = Zdn;
  2069. let Constraints = "$Zdn = $_Zdn";
  2070. let DestructiveInstType = DestructiveOther;
  2071. let ElementSize = zprty.ElementSize;
  2072. }
  2073. multiclass sve2_fp_pairwise_pred<bits<3> opc, string asm,
  2074. SDPatternOperator op> {
  2075. def _H : sve2_fp_pairwise_pred<0b01, opc, asm, ZPR16>;
  2076. def _S : sve2_fp_pairwise_pred<0b10, opc, asm, ZPR32>;
  2077. def _D : sve2_fp_pairwise_pred<0b11, opc, asm, ZPR64>;
  2078. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  2079. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  2080. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  2081. }
  2082. //===----------------------------------------------------------------------===//
  2083. // SVE2 Floating Point Widening Multiply-Add - Indexed Group
  2084. //===----------------------------------------------------------------------===//
  2085. class sve2_fp_mla_long_by_indexed_elem<bits<2> opc, string asm>
  2086. : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm,
  2087. VectorIndexH32b:$iop),
  2088. asm, "\t$Zda, $Zn, $Zm$iop",
  2089. "",
  2090. []>, Sched<[]> {
  2091. bits<5> Zda;
  2092. bits<5> Zn;
  2093. bits<3> Zm;
  2094. bits<3> iop;
  2095. let Inst{31-21} = 0b01100100101;
  2096. let Inst{20-19} = iop{2-1};
  2097. let Inst{18-16} = Zm;
  2098. let Inst{15-14} = 0b01;
  2099. let Inst{13} = opc{1};
  2100. let Inst{12} = 0b0;
  2101. let Inst{11} = iop{0};
  2102. let Inst{10} = opc{0};
  2103. let Inst{9-5} = Zn;
  2104. let Inst{4-0} = Zda;
  2105. let Constraints = "$Zda = $_Zda";
  2106. let DestructiveInstType = DestructiveOther;
  2107. let ElementSize = ElementSizeNone;
  2108. }
  2109. multiclass sve2_fp_mla_long_by_indexed_elem<bits<2> opc, string asm,
  2110. SDPatternOperator op> {
  2111. def NAME : sve2_fp_mla_long_by_indexed_elem<opc, asm>;
  2112. def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, nxv8f16, nxv8f16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME)>;
  2113. }
  2114. //===----------------------------------------------------------------------===//
  2115. // SVE2 Floating Point Widening Multiply-Add Group
  2116. //===----------------------------------------------------------------------===//
  2117. class sve2_fp_mla_long<bits<2> opc, string asm>
  2118. : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
  2119. asm, "\t$Zda, $Zn, $Zm",
  2120. "",
  2121. []>, Sched<[]> {
  2122. bits<5> Zda;
  2123. bits<5> Zn;
  2124. bits<5> Zm;
  2125. let Inst{31-21} = 0b01100100101;
  2126. let Inst{20-16} = Zm;
  2127. let Inst{15-14} = 0b10;
  2128. let Inst{13} = opc{1};
  2129. let Inst{12-11} = 0b00;
  2130. let Inst{10} = opc{0};
  2131. let Inst{9-5} = Zn;
  2132. let Inst{4-0} = Zda;
  2133. let Constraints = "$Zda = $_Zda";
  2134. let DestructiveInstType = DestructiveOther;
  2135. let ElementSize = ElementSizeNone;
  2136. }
  2137. multiclass sve2_fp_mla_long<bits<2> opc, string asm, SDPatternOperator op> {
  2138. def NAME : sve2_fp_mla_long<opc, asm>;
  2139. def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8f16, nxv8f16, !cast<Instruction>(NAME)>;
  2140. }
  2141. //===----------------------------------------------------------------------===//
  2142. // SVE Stack Allocation Group
  2143. //===----------------------------------------------------------------------===//
  2144. class sve_int_arith_vl<bit opc, string asm>
  2145. : I<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, simm6_32b:$imm6),
  2146. asm, "\t$Rd, $Rn, $imm6",
  2147. "",
  2148. []>, Sched<[]> {
  2149. bits<5> Rd;
  2150. bits<5> Rn;
  2151. bits<6> imm6;
  2152. let Inst{31-23} = 0b000001000;
  2153. let Inst{22} = opc;
  2154. let Inst{21} = 0b1;
  2155. let Inst{20-16} = Rn;
  2156. let Inst{15-11} = 0b01010;
  2157. let Inst{10-5} = imm6;
  2158. let Inst{4-0} = Rd;
  2159. }
  2160. class sve_int_read_vl_a<bit op, bits<5> opc2, string asm>
  2161. : I<(outs GPR64:$Rd), (ins simm6_32b:$imm6),
  2162. asm, "\t$Rd, $imm6",
  2163. "",
  2164. []>, Sched<[]> {
  2165. bits<5> Rd;
  2166. bits<6> imm6;
  2167. let Inst{31-23} = 0b000001001;
  2168. let Inst{22} = op;
  2169. let Inst{21} = 0b1;
  2170. let Inst{20-16} = opc2{4-0};
  2171. let Inst{15-11} = 0b01010;
  2172. let Inst{10-5} = imm6;
  2173. let Inst{4-0} = Rd;
  2174. }
  2175. //===----------------------------------------------------------------------===//
  2176. // SVE Permute - In Lane Group
  2177. //===----------------------------------------------------------------------===//
  2178. class sve_int_perm_bin_perm_zz<bits<3> opc, bits<2> sz8_64, string asm,
  2179. ZPRRegOp zprty>
  2180. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
  2181. asm, "\t$Zd, $Zn, $Zm",
  2182. "",
  2183. []>, Sched<[]> {
  2184. bits<5> Zd;
  2185. bits<5> Zm;
  2186. bits<5> Zn;
  2187. let Inst{31-24} = 0b00000101;
  2188. let Inst{23-22} = sz8_64;
  2189. let Inst{21} = 0b1;
  2190. let Inst{20-16} = Zm;
  2191. let Inst{15-13} = 0b011;
  2192. let Inst{12-10} = opc;
  2193. let Inst{9-5} = Zn;
  2194. let Inst{4-0} = Zd;
  2195. }
  2196. multiclass sve_int_perm_bin_perm_zz<bits<3> opc, string asm,
  2197. SDPatternOperator op> {
  2198. def _B : sve_int_perm_bin_perm_zz<opc, 0b00, asm, ZPR8>;
  2199. def _H : sve_int_perm_bin_perm_zz<opc, 0b01, asm, ZPR16>;
  2200. def _S : sve_int_perm_bin_perm_zz<opc, 0b10, asm, ZPR32>;
  2201. def _D : sve_int_perm_bin_perm_zz<opc, 0b11, asm, ZPR64>;
  2202. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2203. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2204. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2205. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2206. def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  2207. def : SVE_2_Op_Pat<nxv4f16, op, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>;
  2208. def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  2209. def : SVE_2_Op_Pat<nxv2f16, op, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>;
  2210. def : SVE_2_Op_Pat<nxv2f32, op, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>;
  2211. def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  2212. def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
  2213. }
  2214. //===----------------------------------------------------------------------===//
  2215. // SVE Floating Point Unary Operations Group
  2216. //===----------------------------------------------------------------------===//
  2217. class sve_fp_2op_p_zd<bits<7> opc, string asm, RegisterOperand i_zprtype,
  2218. RegisterOperand o_zprtype, ElementSizeEnum Sz>
  2219. : I<(outs o_zprtype:$Zd), (ins i_zprtype:$_Zd, PPR3bAny:$Pg, i_zprtype:$Zn),
  2220. asm, "\t$Zd, $Pg/m, $Zn",
  2221. "",
  2222. []>, Sched<[]> {
  2223. bits<3> Pg;
  2224. bits<5> Zd;
  2225. bits<5> Zn;
  2226. let Inst{31-24} = 0b01100101;
  2227. let Inst{23-22} = opc{6-5};
  2228. let Inst{21} = 0b0;
  2229. let Inst{20-16} = opc{4-0};
  2230. let Inst{15-13} = 0b101;
  2231. let Inst{12-10} = Pg;
  2232. let Inst{9-5} = Zn;
  2233. let Inst{4-0} = Zd;
  2234. let Constraints = "$Zd = $_Zd";
  2235. let DestructiveInstType = DestructiveUnaryPassthru;
  2236. let ElementSize = Sz;
  2237. }
  2238. multiclass sve_fp_2op_p_zd<bits<7> opc, string asm,
  2239. RegisterOperand i_zprtype,
  2240. RegisterOperand o_zprtype,
  2241. SDPatternOperator int_op,
  2242. SDPatternOperator ir_op, ValueType vt1,
  2243. ValueType vt2, ValueType vt3, ElementSizeEnum Sz> {
  2244. def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>,
  2245. SVEPseudo2Instr<NAME, 1>;
  2246. // convert vt1 to a packed type for the intrinsic patterns
  2247. defvar packedvt1 = !cond(!eq(!cast<string>(vt1), "nxv2f16"): nxv8f16,
  2248. !eq(!cast<string>(vt1), "nxv4f16"): nxv8f16,
  2249. !eq(!cast<string>(vt1), "nxv2f32"): nxv4f32,
  2250. 1 : vt1);
  2251. // convert vt3 to a packed type for the intrinsic patterns
  2252. defvar packedvt3 = !cond(!eq(!cast<string>(vt3), "nxv2f16"): nxv8f16,
  2253. !eq(!cast<string>(vt3), "nxv4f16"): nxv8f16,
  2254. !eq(!cast<string>(vt3), "nxv2f32"): nxv4f32,
  2255. 1 : vt3);
  2256. def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, packedvt3, !cast<Instruction>(NAME)>;
  2257. def : SVE_1_Op_Passthru_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>;
  2258. def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>;
  2259. defm : SVE_1_Op_PassthruUndef_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>;
  2260. }
  2261. multiclass sve_fp_2op_p_zdr<bits<7> opc, string asm,
  2262. RegisterOperand i_zprtype,
  2263. RegisterOperand o_zprtype,
  2264. SDPatternOperator int_op,
  2265. SDPatternOperator ir_op, ValueType vt1,
  2266. ValueType vt2, ValueType vt3, ElementSizeEnum Sz> {
  2267. def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>,
  2268. SVEPseudo2Instr<NAME, 1>;
  2269. // convert vt1 to a packed type for the intrinsic patterns
  2270. defvar packedvt1 = !cond(!eq(!cast<string>(vt1), "nxv2f16"): nxv8f16,
  2271. !eq(!cast<string>(vt1), "nxv4f16"): nxv8f16,
  2272. !eq(!cast<string>(vt1), "nxv2f32"): nxv4f32,
  2273. 1 : vt1);
  2274. def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, vt3, !cast<Instruction>(NAME)>;
  2275. def : SVE_1_Op_Passthru_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>;
  2276. def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>;
  2277. defm : SVE_1_Op_PassthruUndef_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>;
  2278. }
  2279. multiclass sve_fp_2op_p_zd_HSD<bits<5> opc, string asm, SDPatternOperator op> {
  2280. def _H : sve_fp_2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16, ElementSizeH>,
  2281. SVEPseudo2Instr<NAME # _H, 1>;
  2282. def _S : sve_fp_2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32, ElementSizeS>,
  2283. SVEPseudo2Instr<NAME # _S, 1>;
  2284. def _D : sve_fp_2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64, ElementSizeD>,
  2285. SVEPseudo2Instr<NAME # _D, 1>;
  2286. def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  2287. def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
  2288. def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
  2289. def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  2290. def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  2291. def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  2292. def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
  2293. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  2294. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  2295. defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _UNDEF_H)>;
  2296. defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _UNDEF_H)>;
  2297. defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _UNDEF_H)>;
  2298. defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _UNDEF_S)>;
  2299. defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _UNDEF_S)>;
  2300. defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _UNDEF_D)>;
  2301. }
  2302. multiclass sve2_fp_flogb<string asm, SDPatternOperator op> {
  2303. def _H : sve_fp_2op_p_zd<0b0011010, asm, ZPR16, ZPR16, ElementSizeH>;
  2304. def _S : sve_fp_2op_p_zd<0b0011100, asm, ZPR32, ZPR32, ElementSizeS>;
  2305. def _D : sve_fp_2op_p_zd<0b0011110, asm, ZPR64, ZPR64, ElementSizeD>;
  2306. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  2307. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  2308. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  2309. }
  2310. multiclass sve2_fp_convert_down_odd_rounding<string asm, string op> {
  2311. def _DtoS : sve_fp_2op_p_zd<0b0001010, asm, ZPR64, ZPR32, ElementSizeD>;
  2312. def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
  2313. }
  2314. //===----------------------------------------------------------------------===//
  2315. // SVE Floating Point Unary Operations - Unpredicated Group
  2316. //===----------------------------------------------------------------------===//
  2317. class sve_fp_2op_u_zd<bits<2> sz, bits<3> opc, string asm,
  2318. ZPRRegOp zprty>
  2319. : I<(outs zprty:$Zd), (ins zprty:$Zn),
  2320. asm, "\t$Zd, $Zn",
  2321. "",
  2322. []>, Sched<[]> {
  2323. bits<5> Zd;
  2324. bits<5> Zn;
  2325. let Inst{31-24} = 0b01100101;
  2326. let Inst{23-22} = sz;
  2327. let Inst{21-19} = 0b001;
  2328. let Inst{18-16} = opc;
  2329. let Inst{15-10} = 0b001100;
  2330. let Inst{9-5} = Zn;
  2331. let Inst{4-0} = Zd;
  2332. }
  2333. multiclass sve_fp_2op_u_zd<bits<3> opc, string asm, SDPatternOperator op> {
  2334. def _H : sve_fp_2op_u_zd<0b01, opc, asm, ZPR16>;
  2335. def _S : sve_fp_2op_u_zd<0b10, opc, asm, ZPR32>;
  2336. def _D : sve_fp_2op_u_zd<0b11, opc, asm, ZPR64>;
  2337. def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>;
  2338. def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>;
  2339. def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>;
  2340. }
  2341. //===----------------------------------------------------------------------===//
  2342. // SVE Integer Arithmetic - Binary Predicated Group
  2343. //===----------------------------------------------------------------------===//
  2344. class sve_int_bin_pred_arit_log<bits<2> sz8_64, bits<2> fmt, bits<3> opc,
  2345. string asm, ZPRRegOp zprty>
  2346. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
  2347. asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
  2348. bits<3> Pg;
  2349. bits<5> Zdn;
  2350. bits<5> Zm;
  2351. let Inst{31-24} = 0b00000100;
  2352. let Inst{23-22} = sz8_64;
  2353. let Inst{21} = 0b0;
  2354. let Inst{20-19} = fmt;
  2355. let Inst{18-16} = opc;
  2356. let Inst{15-13} = 0b000;
  2357. let Inst{12-10} = Pg;
  2358. let Inst{9-5} = Zm;
  2359. let Inst{4-0} = Zdn;
  2360. let Constraints = "$Zdn = $_Zdn";
  2361. let DestructiveInstType = DestructiveOther;
  2362. let ElementSize = zprty.ElementSize;
  2363. }
  2364. multiclass sve_int_bin_pred_log<bits<3> opc, string asm, SDPatternOperator op> {
  2365. def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>;
  2366. def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>;
  2367. def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>;
  2368. def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>;
  2369. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2370. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2371. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2372. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2373. }
  2374. multiclass sve_int_bin_pred_arit_0<bits<3> opc, string asm, string Ps,
  2375. SDPatternOperator op,
  2376. DestructiveInstTypeEnum flags,
  2377. string revname="", bit isReverseInstr=0> {
  2378. let DestructiveInstType = flags in {
  2379. def _B : sve_int_bin_pred_arit_log<0b00, 0b00, opc, asm, ZPR8>,
  2380. SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
  2381. def _H : sve_int_bin_pred_arit_log<0b01, 0b00, opc, asm, ZPR16>,
  2382. SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
  2383. def _S : sve_int_bin_pred_arit_log<0b10, 0b00, opc, asm, ZPR32>,
  2384. SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
  2385. def _D : sve_int_bin_pred_arit_log<0b11, 0b00, opc, asm, ZPR64>,
  2386. SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
  2387. }
  2388. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2389. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2390. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2391. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2392. }
  2393. multiclass sve_int_bin_pred_arit_1<bits<3> opc, string asm, string Ps,
  2394. SDPatternOperator op,
  2395. DestructiveInstTypeEnum flags> {
  2396. let DestructiveInstType = flags in {
  2397. def _B : sve_int_bin_pred_arit_log<0b00, 0b01, opc, asm, ZPR8>,
  2398. SVEPseudo2Instr<Ps # _B, 1>;
  2399. def _H : sve_int_bin_pred_arit_log<0b01, 0b01, opc, asm, ZPR16>,
  2400. SVEPseudo2Instr<Ps # _H, 1>;
  2401. def _S : sve_int_bin_pred_arit_log<0b10, 0b01, opc, asm, ZPR32>,
  2402. SVEPseudo2Instr<Ps # _S, 1>;
  2403. def _D : sve_int_bin_pred_arit_log<0b11, 0b01, opc, asm, ZPR64>,
  2404. SVEPseudo2Instr<Ps # _D, 1>;
  2405. }
  2406. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2407. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2408. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2409. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2410. }
  2411. multiclass sve_int_bin_pred_arit_2<bits<3> opc, string asm, string Ps,
  2412. SDPatternOperator op,
  2413. DestructiveInstTypeEnum flags> {
  2414. let DestructiveInstType = flags in {
  2415. def _B : sve_int_bin_pred_arit_log<0b00, 0b10, opc, asm, ZPR8>,
  2416. SVEPseudo2Instr<Ps # _B, 1>;
  2417. def _H : sve_int_bin_pred_arit_log<0b01, 0b10, opc, asm, ZPR16>,
  2418. SVEPseudo2Instr<Ps # _H, 1>;
  2419. def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>,
  2420. SVEPseudo2Instr<Ps # _S, 1>;
  2421. def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>,
  2422. SVEPseudo2Instr<Ps # _D, 1>;
  2423. }
  2424. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2425. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2426. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2427. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2428. }
  2429. // Special case for divides which are not defined for 8b/16b elements.
  2430. multiclass sve_int_bin_pred_arit_2_div<bits<3> opc, string asm, string Ps,
  2431. SDPatternOperator op,
  2432. DestructiveInstTypeEnum flags,
  2433. string revname="", bit isReverseInstr=0> {
  2434. let DestructiveInstType = flags in {
  2435. def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>,
  2436. SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
  2437. def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>,
  2438. SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
  2439. }
  2440. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2441. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2442. }
  2443. //===----------------------------------------------------------------------===//
  2444. // SVE Integer Multiply-Add Group
  2445. //===----------------------------------------------------------------------===//
  2446. class sve_int_mladdsub_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
  2447. ZPRRegOp zprty>
  2448. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
  2449. asm, "\t$Zdn, $Pg/m, $Zm, $Za",
  2450. "",
  2451. []>, Sched<[]> {
  2452. bits<3> Pg;
  2453. bits<5> Zdn;
  2454. bits<5> Za;
  2455. bits<5> Zm;
  2456. let Inst{31-24} = 0b00000100;
  2457. let Inst{23-22} = sz8_64;
  2458. let Inst{21} = 0b0;
  2459. let Inst{20-16} = Zm;
  2460. let Inst{15-14} = 0b11;
  2461. let Inst{13} = opc;
  2462. let Inst{12-10} = Pg;
  2463. let Inst{9-5} = Za;
  2464. let Inst{4-0} = Zdn;
  2465. let Constraints = "$Zdn = $_Zdn";
  2466. let DestructiveInstType = DestructiveOther;
  2467. let ElementSize = zprty.ElementSize;
  2468. }
  2469. multiclass sve_int_mladdsub_vvv_pred<bits<1> opc, string asm, SDPatternOperator op> {
  2470. def _B : sve_int_mladdsub_vvv_pred<0b00, opc, asm, ZPR8>;
  2471. def _H : sve_int_mladdsub_vvv_pred<0b01, opc, asm, ZPR16>;
  2472. def _S : sve_int_mladdsub_vvv_pred<0b10, opc, asm, ZPR32>;
  2473. def _D : sve_int_mladdsub_vvv_pred<0b11, opc, asm, ZPR64>;
  2474. def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2475. def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2476. def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2477. def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2478. }
  2479. class sve_int_mlas_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
  2480. ZPRRegOp zprty>
  2481. : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
  2482. asm, "\t$Zda, $Pg/m, $Zn, $Zm",
  2483. "",
  2484. []>, Sched<[]> {
  2485. bits<3> Pg;
  2486. bits<5> Zda;
  2487. bits<5> Zm;
  2488. bits<5> Zn;
  2489. let Inst{31-24} = 0b00000100;
  2490. let Inst{23-22} = sz8_64;
  2491. let Inst{21} = 0b0;
  2492. let Inst{20-16} = Zm;
  2493. let Inst{15-14} = 0b01;
  2494. let Inst{13} = opc;
  2495. let Inst{12-10} = Pg;
  2496. let Inst{9-5} = Zn;
  2497. let Inst{4-0} = Zda;
  2498. let Constraints = "$Zda = $_Zda";
  2499. let DestructiveInstType = DestructiveOther;
  2500. let ElementSize = zprty.ElementSize;
  2501. }
  2502. multiclass sve_int_mlas_vvv_pred<bits<1> opc, string asm, SDPatternOperator op,
  2503. SDPatternOperator outerop, SDPatternOperator mulop> {
  2504. def _B : sve_int_mlas_vvv_pred<0b00, opc, asm, ZPR8>;
  2505. def _H : sve_int_mlas_vvv_pred<0b01, opc, asm, ZPR16>;
  2506. def _S : sve_int_mlas_vvv_pred<0b10, opc, asm, ZPR32>;
  2507. def _D : sve_int_mlas_vvv_pred<0b11, opc, asm, ZPR64>;
  2508. def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2509. def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2510. def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2511. def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2512. def : Pat<(outerop nxv16i8:$Op1, (mulop nxv16i1:$pred, nxv16i8:$Op2, nxv16i8:$Op3)),
  2513. (!cast<Instruction>(NAME # _B) $pred, $Op1, $Op2, $Op3)>;
  2514. def : Pat<(outerop nxv8i16:$Op1, (mulop nxv8i1:$pred, nxv8i16:$Op2, nxv8i16:$Op3)),
  2515. (!cast<Instruction>(NAME # _H) $pred, $Op1, $Op2, $Op3)>;
  2516. def : Pat<(outerop nxv4i32:$Op1, (mulop nxv4i1:$pred, nxv4i32:$Op2, nxv4i32:$Op3)),
  2517. (!cast<Instruction>(NAME # _S) $pred, $Op1, $Op2, $Op3)>;
  2518. def : Pat<(outerop nxv2i64:$Op1, (mulop nxv2i1:$pred, nxv2i64:$Op2, nxv2i64:$Op3)),
  2519. (!cast<Instruction>(NAME # _D) $pred, $Op1, $Op2, $Op3)>;
  2520. }
  2521. //===----------------------------------------------------------------------===//
  2522. // SVE2 Integer Multiply-Add - Unpredicated Group
  2523. //===----------------------------------------------------------------------===//
  2524. class sve2_int_mla<bits<2> sz, bits<5> opc, string asm,
  2525. ZPRRegOp zprty1, ZPRRegOp zprty2>
  2526. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
  2527. asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
  2528. bits<5> Zda;
  2529. bits<5> Zn;
  2530. bits<5> Zm;
  2531. let Inst{31-24} = 0b01000100;
  2532. let Inst{23-22} = sz;
  2533. let Inst{21} = 0b0;
  2534. let Inst{20-16} = Zm;
  2535. let Inst{15} = 0b0;
  2536. let Inst{14-10} = opc;
  2537. let Inst{9-5} = Zn;
  2538. let Inst{4-0} = Zda;
  2539. let Constraints = "$Zda = $_Zda";
  2540. let DestructiveInstType = DestructiveOther;
  2541. let ElementSize = ElementSizeNone;
  2542. }
  2543. multiclass sve2_int_mla<bit S, string asm, SDPatternOperator op> {
  2544. def _B : sve2_int_mla<0b00, { 0b1110, S }, asm, ZPR8, ZPR8>;
  2545. def _H : sve2_int_mla<0b01, { 0b1110, S }, asm, ZPR16, ZPR16>;
  2546. def _S : sve2_int_mla<0b10, { 0b1110, S }, asm, ZPR32, ZPR32>;
  2547. def _D : sve2_int_mla<0b11, { 0b1110, S }, asm, ZPR64, ZPR64>;
  2548. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2549. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2550. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2551. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2552. }
  2553. multiclass sve2_int_mla_long<bits<5> opc, string asm, SDPatternOperator op> {
  2554. def _H : sve2_int_mla<0b01, opc, asm, ZPR16, ZPR8>;
  2555. def _S : sve2_int_mla<0b10, opc, asm, ZPR32, ZPR16>;
  2556. def _D : sve2_int_mla<0b11, opc, asm, ZPR64, ZPR32>;
  2557. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
  2558. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
  2559. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
  2560. }
  2561. //===----------------------------------------------------------------------===//
  2562. // SVE2 Integer Multiply-Add - Indexed Group
  2563. //===----------------------------------------------------------------------===//
  2564. class sve2_int_mla_by_indexed_elem<bits<2> sz, bits<6> opc, string asm,
  2565. ZPRRegOp zprty1, ZPRRegOp zprty2,
  2566. ZPRRegOp zprty3, Operand itype>
  2567. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
  2568. asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
  2569. bits<5> Zda;
  2570. bits<5> Zn;
  2571. let Inst{31-24} = 0b01000100;
  2572. let Inst{23-22} = sz;
  2573. let Inst{21} = 0b1;
  2574. let Inst{15-10} = opc;
  2575. let Inst{9-5} = Zn;
  2576. let Inst{4-0} = Zda;
  2577. let Constraints = "$Zda = $_Zda";
  2578. let DestructiveInstType = DestructiveOther;
  2579. let ElementSize = ElementSizeNone;
  2580. }
  2581. multiclass sve2_int_mla_by_indexed_elem<bits<2> opc, bit S, string asm,
  2582. SDPatternOperator op> {
  2583. def _H : sve2_int_mla_by_indexed_elem<{0, ?}, { 0b000, opc, S }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> {
  2584. bits<3> Zm;
  2585. bits<3> iop;
  2586. let Inst{22} = iop{2};
  2587. let Inst{20-19} = iop{1-0};
  2588. let Inst{18-16} = Zm;
  2589. }
  2590. def _S : sve2_int_mla_by_indexed_elem<0b10, { 0b000, opc, S }, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> {
  2591. bits<3> Zm;
  2592. bits<2> iop;
  2593. let Inst{20-19} = iop;
  2594. let Inst{18-16} = Zm;
  2595. }
  2596. def _D : sve2_int_mla_by_indexed_elem<0b11, { 0b000, opc, S }, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> {
  2597. bits<4> Zm;
  2598. bit iop;
  2599. let Inst{20} = iop;
  2600. let Inst{19-16} = Zm;
  2601. }
  2602. def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
  2603. def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
  2604. def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
  2605. }
  2606. //===----------------------------------------------------------------------===//
  2607. // SVE2 Integer Multiply-Add Long - Indexed Group
  2608. //===----------------------------------------------------------------------===//
  2609. multiclass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm,
  2610. SDPatternOperator op> {
  2611. def _S : sve2_int_mla_by_indexed_elem<0b10, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
  2612. asm, ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> {
  2613. bits<3> Zm;
  2614. bits<3> iop;
  2615. let Inst{20-19} = iop{2-1};
  2616. let Inst{18-16} = Zm;
  2617. let Inst{11} = iop{0};
  2618. }
  2619. def _D : sve2_int_mla_by_indexed_elem<0b11, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
  2620. asm, ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> {
  2621. bits<4> Zm;
  2622. bits<2> iop;
  2623. let Inst{20} = iop{1};
  2624. let Inst{19-16} = Zm;
  2625. let Inst{11} = iop{0};
  2626. }
  2627. def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>;
  2628. def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
  2629. }
  2630. //===----------------------------------------------------------------------===//
  2631. // SVE Integer Dot Product Group
  2632. //===----------------------------------------------------------------------===//
  2633. class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
  2634. ZPRRegOp zprty2>
  2635. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm,
  2636. "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
  2637. bits<5> Zda;
  2638. bits<5> Zn;
  2639. bits<5> Zm;
  2640. let Inst{31-23} = 0b010001001;
  2641. let Inst{22} = sz;
  2642. let Inst{21} = 0;
  2643. let Inst{20-16} = Zm;
  2644. let Inst{15-11} = 0;
  2645. let Inst{10} = U;
  2646. let Inst{9-5} = Zn;
  2647. let Inst{4-0} = Zda;
  2648. let Constraints = "$Zda = $_Zda";
  2649. let DestructiveInstType = DestructiveOther;
  2650. }
  2651. multiclass sve_intx_dot<bit opc, string asm, SDPatternOperator op> {
  2652. def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
  2653. def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
  2654. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _S)>;
  2655. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _D)>;
  2656. }
  2657. //===----------------------------------------------------------------------===//
  2658. // SVE Integer Dot Product Group - Indexed Group
  2659. //===----------------------------------------------------------------------===//
  2660. class sve_intx_dot_by_indexed_elem<bit sz, bit U, string asm,
  2661. ZPRRegOp zprty1, ZPRRegOp zprty2,
  2662. ZPRRegOp zprty3, Operand itype>
  2663. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
  2664. asm, "\t$Zda, $Zn, $Zm$iop",
  2665. "", []>, Sched<[]> {
  2666. bits<5> Zda;
  2667. bits<5> Zn;
  2668. let Inst{31-23} = 0b010001001;
  2669. let Inst{22} = sz;
  2670. let Inst{21} = 0b1;
  2671. let Inst{15-11} = 0;
  2672. let Inst{10} = U;
  2673. let Inst{9-5} = Zn;
  2674. let Inst{4-0} = Zda;
  2675. let Constraints = "$Zda = $_Zda";
  2676. let DestructiveInstType = DestructiveOther;
  2677. }
  2678. multiclass sve_intx_dot_by_indexed_elem<bit opc, string asm,
  2679. SDPatternOperator op> {
  2680. def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b_timm> {
  2681. bits<2> iop;
  2682. bits<3> Zm;
  2683. let Inst{20-19} = iop;
  2684. let Inst{18-16} = Zm;
  2685. }
  2686. def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b_timm> {
  2687. bits<1> iop;
  2688. bits<4> Zm;
  2689. let Inst{20} = iop;
  2690. let Inst{19-16} = Zm;
  2691. }
  2692. def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
  2693. def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
  2694. }
  2695. //===----------------------------------------------------------------------===//
  2696. // SVE2 Complex Integer Dot Product Group
  2697. //===----------------------------------------------------------------------===//
  2698. class sve2_complex_int_arith<bits<2> sz, bits<4> opc, string asm,
  2699. ZPRRegOp zprty1, ZPRRegOp zprty2>
  2700. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm,
  2701. complexrotateop:$rot),
  2702. asm, "\t$Zda, $Zn, $Zm, $rot", "", []>, Sched<[]> {
  2703. bits<5> Zda;
  2704. bits<5> Zn;
  2705. bits<5> Zm;
  2706. bits<2> rot;
  2707. let Inst{31-24} = 0b01000100;
  2708. let Inst{23-22} = sz;
  2709. let Inst{21} = 0b0;
  2710. let Inst{20-16} = Zm;
  2711. let Inst{15-12} = opc;
  2712. let Inst{11-10} = rot;
  2713. let Inst{9-5} = Zn;
  2714. let Inst{4-0} = Zda;
  2715. let Constraints = "$Zda = $_Zda";
  2716. let DestructiveInstType = DestructiveOther;
  2717. let ElementSize = ElementSizeNone;
  2718. }
  2719. multiclass sve2_cintx_dot<string asm, SDPatternOperator op> {
  2720. def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
  2721. def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
  2722. def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
  2723. (i32 complexrotateop:$imm))),
  2724. (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>;
  2725. def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
  2726. (i32 complexrotateop:$imm))),
  2727. (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>;
  2728. }
  2729. //===----------------------------------------------------------------------===//
  2730. // SVE2 Complex Multiply-Add Group
  2731. //===----------------------------------------------------------------------===//
  2732. multiclass sve2_int_cmla<bit opc, string asm, SDPatternOperator op> {
  2733. def _B : sve2_complex_int_arith<0b00, { 0b001, opc }, asm, ZPR8, ZPR8>;
  2734. def _H : sve2_complex_int_arith<0b01, { 0b001, opc }, asm, ZPR16, ZPR16>;
  2735. def _S : sve2_complex_int_arith<0b10, { 0b001, opc }, asm, ZPR32, ZPR32>;
  2736. def _D : sve2_complex_int_arith<0b11, { 0b001, opc }, asm, ZPR64, ZPR64>;
  2737. def : SVE_4_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, i32, complexrotateop, !cast<Instruction>(NAME # _B)>;
  2738. def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, complexrotateop, !cast<Instruction>(NAME # _H)>;
  2739. def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, complexrotateop, !cast<Instruction>(NAME # _S)>;
  2740. def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, complexrotateop, !cast<Instruction>(NAME # _D)>;
  2741. }
  2742. //===----------------------------------------------------------------------===//
  2743. // SVE2 Complex Integer Dot Product - Indexed Group
  2744. //===----------------------------------------------------------------------===//
  2745. class sve2_complex_int_arith_indexed<bits<2> sz, bits<4> opc, string asm,
  2746. ZPRRegOp zprty1, ZPRRegOp zprty2,
  2747. ZPRRegOp zprty3, Operand itype>
  2748. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop,
  2749. complexrotateop:$rot),
  2750. asm, "\t$Zda, $Zn, $Zm$iop, $rot", "", []>, Sched<[]> {
  2751. bits<5> Zda;
  2752. bits<5> Zn;
  2753. bits<2> rot;
  2754. let Inst{31-24} = 0b01000100;
  2755. let Inst{23-22} = sz;
  2756. let Inst{21} = 0b1;
  2757. let Inst{15-12} = opc;
  2758. let Inst{11-10} = rot;
  2759. let Inst{9-5} = Zn;
  2760. let Inst{4-0} = Zda;
  2761. let Constraints = "$Zda = $_Zda";
  2762. let DestructiveInstType = DestructiveOther;
  2763. let ElementSize = ElementSizeNone;
  2764. }
  2765. multiclass sve2_cintx_dot_by_indexed_elem<string asm, SDPatternOperator op> {
  2766. def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
  2767. bits<2> iop;
  2768. bits<3> Zm;
  2769. let Inst{20-19} = iop;
  2770. let Inst{18-16} = Zm;
  2771. }
  2772. def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
  2773. bit iop;
  2774. bits<4> Zm;
  2775. let Inst{20} = iop;
  2776. let Inst{19-16} = Zm;
  2777. }
  2778. def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
  2779. (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
  2780. (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
  2781. def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
  2782. (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
  2783. (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
  2784. }
  2785. //===----------------------------------------------------------------------===//
  2786. // SVE2 Complex Multiply-Add - Indexed Group
  2787. //===----------------------------------------------------------------------===//
  2788. multiclass sve2_cmla_by_indexed_elem<bit opc, string asm,
  2789. SDPatternOperator op> {
  2790. def _H : sve2_complex_int_arith_indexed<0b10, { 0b011, opc }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexS32b> {
  2791. bits<2> iop;
  2792. bits<3> Zm;
  2793. let Inst{20-19} = iop;
  2794. let Inst{18-16} = Zm;
  2795. }
  2796. def _S : sve2_complex_int_arith_indexed<0b11, { 0b011, opc }, asm, ZPR32, ZPR32, ZPR4b32, VectorIndexD32b> {
  2797. bit iop;
  2798. bits<4> Zm;
  2799. let Inst{20} = iop;
  2800. let Inst{19-16} = Zm;
  2801. }
  2802. def : Pat<(nxv8i16 (op (nxv8i16 ZPR16:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
  2803. (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
  2804. (!cast<Instruction>(NAME # "_H") ZPR16:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
  2805. def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv4i32 ZPR32:$Op2), (nxv4i32 ZPR32:$Op3),
  2806. (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
  2807. (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR32:$Op2, ZPR32:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
  2808. }
  2809. //===----------------------------------------------------------------------===//
  2810. // SVE2 Integer Multiply - Unpredicated Group
  2811. //===----------------------------------------------------------------------===//
  2812. class sve2_int_mul<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
  2813. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
  2814. asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
  2815. bits<5> Zd;
  2816. bits<5> Zm;
  2817. bits<5> Zn;
  2818. let Inst{31-24} = 0b00000100;
  2819. let Inst{23-22} = sz;
  2820. let Inst{21} = 0b1;
  2821. let Inst{20-16} = Zm;
  2822. let Inst{15-13} = 0b011;
  2823. let Inst{12-10} = opc;
  2824. let Inst{9-5} = Zn;
  2825. let Inst{4-0} = Zd;
  2826. }
  2827. multiclass sve2_int_mul<bits<3> opc, string asm, SDPatternOperator op,
  2828. SDPatternOperator op_pred = null_frag> {
  2829. def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
  2830. def _H : sve2_int_mul<0b01, opc, asm, ZPR16>;
  2831. def _S : sve2_int_mul<0b10, opc, asm, ZPR32>;
  2832. def _D : sve2_int_mul<0b11, opc, asm, ZPR64>;
  2833. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2834. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2835. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2836. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2837. def : SVE_2_Op_Pred_All_Active<nxv16i8, op_pred, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2838. def : SVE_2_Op_Pred_All_Active<nxv8i16, op_pred, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2839. def : SVE_2_Op_Pred_All_Active<nxv4i32, op_pred, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2840. def : SVE_2_Op_Pred_All_Active<nxv2i64, op_pred, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2841. }
  2842. multiclass sve2_int_mul_single<bits<3> opc, string asm, SDPatternOperator op> {
  2843. def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
  2844. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2845. }
  2846. //===----------------------------------------------------------------------===//
  2847. // SVE2 Integer Multiply - Indexed Group
  2848. //===----------------------------------------------------------------------===//
  2849. class sve2_int_mul_by_indexed_elem<bits<2> sz, bits<4> opc, string asm,
  2850. ZPRRegOp zprty1, ZPRRegOp zprty2,
  2851. ZPRRegOp zprty3, Operand itype>
  2852. : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm, itype:$iop),
  2853. asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
  2854. bits<5> Zd;
  2855. bits<5> Zn;
  2856. let Inst{31-24} = 0b01000100;
  2857. let Inst{23-22} = sz;
  2858. let Inst{21} = 0b1;
  2859. let Inst{15-14} = 0b11;
  2860. let Inst{13-10} = opc;
  2861. let Inst{9-5} = Zn;
  2862. let Inst{4-0} = Zd;
  2863. }
  2864. multiclass sve2_int_mul_by_indexed_elem<bits<4> opc, string asm,
  2865. SDPatternOperator op> {
  2866. def _H : sve2_int_mul_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> {
  2867. bits<3> Zm;
  2868. bits<3> iop;
  2869. let Inst{22} = iop{2};
  2870. let Inst{20-19} = iop{1-0};
  2871. let Inst{18-16} = Zm;
  2872. }
  2873. def _S : sve2_int_mul_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> {
  2874. bits<3> Zm;
  2875. bits<2> iop;
  2876. let Inst{20-19} = iop;
  2877. let Inst{18-16} = Zm;
  2878. }
  2879. def _D : sve2_int_mul_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> {
  2880. bits<4> Zm;
  2881. bit iop;
  2882. let Inst{20} = iop;
  2883. let Inst{19-16} = Zm;
  2884. }
  2885. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
  2886. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
  2887. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
  2888. }
  2889. multiclass sve2_int_mul_long_by_indexed_elem<bits<3> opc, string asm,
  2890. SDPatternOperator op> {
  2891. def _S : sve2_int_mul_by_indexed_elem<0b10, { opc{2-1}, ?, opc{0} }, asm,
  2892. ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> {
  2893. bits<3> Zm;
  2894. bits<3> iop;
  2895. let Inst{20-19} = iop{2-1};
  2896. let Inst{18-16} = Zm;
  2897. let Inst{11} = iop{0};
  2898. }
  2899. def _D : sve2_int_mul_by_indexed_elem<0b11, { opc{2-1}, ?, opc{0} }, asm,
  2900. ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> {
  2901. bits<4> Zm;
  2902. bits<2> iop;
  2903. let Inst{20} = iop{1};
  2904. let Inst{19-16} = Zm;
  2905. let Inst{11} = iop{0};
  2906. }
  2907. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>;
  2908. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
  2909. }
  2910. //===----------------------------------------------------------------------===//
  2911. // SVE2 Integer - Predicated Group
  2912. //===----------------------------------------------------------------------===//
  2913. class sve2_int_arith_pred<bits<2> sz, bits<6> opc, string asm,
  2914. ZPRRegOp zprty>
  2915. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
  2916. asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
  2917. bits<3> Pg;
  2918. bits<5> Zm;
  2919. bits<5> Zdn;
  2920. let Inst{31-24} = 0b01000100;
  2921. let Inst{23-22} = sz;
  2922. let Inst{21-20} = 0b01;
  2923. let Inst{20-16} = opc{5-1};
  2924. let Inst{15-14} = 0b10;
  2925. let Inst{13} = opc{0};
  2926. let Inst{12-10} = Pg;
  2927. let Inst{9-5} = Zm;
  2928. let Inst{4-0} = Zdn;
  2929. let Constraints = "$Zdn = $_Zdn";
  2930. let DestructiveInstType = DestructiveOther;
  2931. let ElementSize = zprty.ElementSize;
  2932. }
  2933. multiclass sve2_int_arith_pred<bits<6> opc, string asm, SDPatternOperator op,
  2934. string Ps = "",
  2935. DestructiveInstTypeEnum flags=DestructiveOther,
  2936. string revname="", bit isReverseInstr=0> {
  2937. let DestructiveInstType = flags in {
  2938. def _B : sve2_int_arith_pred<0b00, opc, asm, ZPR8>,
  2939. SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
  2940. def _H : sve2_int_arith_pred<0b01, opc, asm, ZPR16>,
  2941. SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
  2942. def _S : sve2_int_arith_pred<0b10, opc, asm, ZPR32>,
  2943. SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
  2944. def _D : sve2_int_arith_pred<0b11, opc, asm, ZPR64>,
  2945. SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
  2946. }
  2947. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  2948. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  2949. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  2950. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  2951. }
  2952. class sve2_int_sadd_long_accum_pairwise<bits<2> sz, bit U, string asm,
  2953. ZPRRegOp zprty1, ZPRRegOp zprty2>
  2954. : I<(outs zprty1:$Zda), (ins PPR3bAny:$Pg, zprty1:$_Zda, zprty2:$Zn),
  2955. asm, "\t$Zda, $Pg/m, $Zn", "", []>, Sched<[]> {
  2956. bits<3> Pg;
  2957. bits<5> Zn;
  2958. bits<5> Zda;
  2959. let Inst{31-24} = 0b01000100;
  2960. let Inst{23-22} = sz;
  2961. let Inst{21-17} = 0b00010;
  2962. let Inst{16} = U;
  2963. let Inst{15-13} = 0b101;
  2964. let Inst{12-10} = Pg;
  2965. let Inst{9-5} = Zn;
  2966. let Inst{4-0} = Zda;
  2967. let Constraints = "$Zda = $_Zda";
  2968. let DestructiveInstType = DestructiveOther;
  2969. let ElementSize = zprty1.ElementSize;
  2970. }
  2971. multiclass sve2_int_sadd_long_accum_pairwise<bit U, string asm, SDPatternOperator op> {
  2972. def _H : sve2_int_sadd_long_accum_pairwise<0b01, U, asm, ZPR16, ZPR8>;
  2973. def _S : sve2_int_sadd_long_accum_pairwise<0b10, U, asm, ZPR32, ZPR16>;
  2974. def _D : sve2_int_sadd_long_accum_pairwise<0b11, U, asm, ZPR64, ZPR32>;
  2975. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>;
  2976. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>;
  2977. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>;
  2978. }
  2979. class sve2_int_un_pred_arit<bits<2> sz, bit Q, bits<2> opc,
  2980. string asm, ZPRRegOp zprty>
  2981. : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
  2982. asm, "\t$Zd, $Pg/m, $Zn",
  2983. "",
  2984. []>, Sched<[]> {
  2985. bits<3> Pg;
  2986. bits<5> Zd;
  2987. bits<5> Zn;
  2988. let Inst{31-24} = 0b01000100;
  2989. let Inst{23-22} = sz;
  2990. let Inst{21-20} = 0b00;
  2991. let Inst{19} = Q;
  2992. let Inst{18} = 0b0;
  2993. let Inst{17-16} = opc;
  2994. let Inst{15-13} = 0b101;
  2995. let Inst{12-10} = Pg;
  2996. let Inst{9-5} = Zn;
  2997. let Inst{4-0} = Zd;
  2998. let Constraints = "$Zd = $_Zd";
  2999. let DestructiveInstType = DestructiveUnaryPassthru;
  3000. let ElementSize = zprty.ElementSize;
  3001. }
  3002. multiclass sve2_int_un_pred_arit_s<bits<3> opc, string asm,
  3003. SDPatternOperator op> {
  3004. def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>,
  3005. SVEPseudo2Instr<NAME # _S, 1>;
  3006. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3007. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  3008. defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3009. }
  3010. multiclass sve2_int_un_pred_arit<bits<3> opc, string asm, SDPatternOperator op> {
  3011. def _B : sve2_int_un_pred_arit<0b00, opc{2}, opc{1-0}, asm, ZPR8>,
  3012. SVEPseudo2Instr<NAME # _B, 1>;
  3013. def _H : sve2_int_un_pred_arit<0b01, opc{2}, opc{1-0}, asm, ZPR16>,
  3014. SVEPseudo2Instr<NAME # _H, 1>;
  3015. def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>,
  3016. SVEPseudo2Instr<NAME # _S, 1>;
  3017. def _D : sve2_int_un_pred_arit<0b11, opc{2}, opc{1-0}, asm, ZPR64>,
  3018. SVEPseudo2Instr<NAME # _D, 1>;
  3019. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  3020. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  3021. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3022. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  3023. def _UNDEF_B : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
  3024. def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
  3025. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  3026. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  3027. defm : SVE_3_Op_Undef_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>;
  3028. defm : SVE_3_Op_Undef_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  3029. defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3030. defm : SVE_3_Op_Undef_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  3031. }
  3032. //===----------------------------------------------------------------------===//
  3033. // SVE2 Widening Integer Arithmetic Group
  3034. //===----------------------------------------------------------------------===//
  3035. class sve2_wide_int_arith<bits<2> sz, bits<5> opc, string asm,
  3036. ZPRRegOp zprty1, ZPRRegOp zprty2, ZPRRegOp zprty3>
  3037. : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm),
  3038. asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
  3039. bits<5> Zd;
  3040. bits<5> Zn;
  3041. bits<5> Zm;
  3042. let Inst{31-24} = 0b01000101;
  3043. let Inst{23-22} = sz;
  3044. let Inst{21} = 0b0;
  3045. let Inst{20-16} = Zm;
  3046. let Inst{15} = 0b0;
  3047. let Inst{14-10} = opc;
  3048. let Inst{9-5} = Zn;
  3049. let Inst{4-0} = Zd;
  3050. }
  3051. multiclass sve2_wide_int_arith_long<bits<5> opc, string asm,
  3052. SDPatternOperator op> {
  3053. def _H : sve2_wide_int_arith<0b01, opc, asm, ZPR16, ZPR8, ZPR8>;
  3054. def _S : sve2_wide_int_arith<0b10, opc, asm, ZPR32, ZPR16, ZPR16>;
  3055. def _D : sve2_wide_int_arith<0b11, opc, asm, ZPR64, ZPR32, ZPR32>;
  3056. def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
  3057. def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
  3058. def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
  3059. }
  3060. multiclass sve2_wide_int_arith_wide<bits<3> opc, string asm,
  3061. SDPatternOperator op> {
  3062. def _H : sve2_wide_int_arith<0b01, { 0b10, opc }, asm, ZPR16, ZPR16, ZPR8>;
  3063. def _S : sve2_wide_int_arith<0b10, { 0b10, opc }, asm, ZPR32, ZPR32, ZPR16>;
  3064. def _D : sve2_wide_int_arith<0b11, { 0b10, opc }, asm, ZPR64, ZPR64, ZPR32>;
  3065. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>;
  3066. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>;
  3067. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>;
  3068. }
  3069. multiclass sve2_wide_int_arith_pmul<bits<2> sz, bits<5> opc, string asm,
  3070. SDPatternOperator op> {
  3071. def NAME : sve2_wide_int_arith<sz, opc, asm, ZPR128, ZPR64, ZPR64>;
  3072. // To avoid using 128 bit elements in the IR, the pattern below works with
  3073. // llvm intrinsics with the _pair suffix, to reflect that
  3074. // _Q is implemented as a pair of _D.
  3075. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
  3076. }
  3077. multiclass sve2_pmul_long<bits<1> opc, string asm, SDPatternOperator op> {
  3078. def _H : sve2_wide_int_arith<0b01, {0b1101, opc}, asm, ZPR16, ZPR8, ZPR8>;
  3079. def _D : sve2_wide_int_arith<0b11, {0b1101, opc}, asm, ZPR64, ZPR32, ZPR32>;
  3080. // To avoid using 128 bit elements in the IR, the patterns below work with
  3081. // llvm intrinsics with the _pair suffix, to reflect that
  3082. // _H is implemented as a pair of _B and _D is implemented as a pair of _S.
  3083. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
  3084. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
  3085. }
  3086. //===----------------------------------------------------------------------===//
  3087. // SVE2 Misc Group
  3088. //===----------------------------------------------------------------------===//
  3089. class sve2_misc<bits<2> sz, bits<4> opc, string asm,
  3090. ZPRRegOp zprty1, ZPRRegOp zprty2>
  3091. : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
  3092. asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
  3093. bits<5> Zd;
  3094. bits<5> Zn;
  3095. bits<5> Zm;
  3096. let Inst{31-24} = 0b01000101;
  3097. let Inst{23-22} = sz;
  3098. let Inst{21} = 0b0;
  3099. let Inst{20-16} = Zm;
  3100. let Inst{15-14} = 0b10;
  3101. let Inst{13-10} = opc;
  3102. let Inst{9-5} = Zn;
  3103. let Inst{4-0} = Zd;
  3104. }
  3105. multiclass sve2_misc_bitwise<bits<4> opc, string asm, SDPatternOperator op> {
  3106. def _B : sve2_misc<0b00, opc, asm, ZPR8, ZPR8>;
  3107. def _H : sve2_misc<0b01, opc, asm, ZPR16, ZPR16>;
  3108. def _S : sve2_misc<0b10, opc, asm, ZPR32, ZPR32>;
  3109. def _D : sve2_misc<0b11, opc, asm, ZPR64, ZPR64>;
  3110. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  3111. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  3112. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3113. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  3114. }
  3115. multiclass sve2_misc_int_addsub_long_interleaved<bits<2> opc, string asm,
  3116. SDPatternOperator op> {
  3117. def _H : sve2_misc<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
  3118. def _S : sve2_misc<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
  3119. def _D : sve2_misc<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
  3120. def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
  3121. def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
  3122. def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
  3123. }
  3124. class sve2_bitwise_xor_interleaved<bits<2> sz, bits<1> opc, string asm,
  3125. ZPRRegOp zprty1, ZPRRegOp zprty2>
  3126. : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
  3127. asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
  3128. bits<5> Zd;
  3129. bits<5> Zn;
  3130. bits<5> Zm;
  3131. let Inst{31-24} = 0b01000101;
  3132. let Inst{23-22} = sz;
  3133. let Inst{21} = 0b0;
  3134. let Inst{20-16} = Zm;
  3135. let Inst{15-11} = 0b10010;
  3136. let Inst{10} = opc;
  3137. let Inst{9-5} = Zn;
  3138. let Inst{4-0} = Zd;
  3139. let Constraints = "$Zd = $_Zd";
  3140. let DestructiveInstType = DestructiveOther;
  3141. let ElementSize = ElementSizeNone;
  3142. }
  3143. multiclass sve2_bitwise_xor_interleaved<bit opc, string asm,
  3144. SDPatternOperator op> {
  3145. def _B : sve2_bitwise_xor_interleaved<0b00, opc, asm, ZPR8, ZPR8>;
  3146. def _H : sve2_bitwise_xor_interleaved<0b01, opc, asm, ZPR16, ZPR16>;
  3147. def _S : sve2_bitwise_xor_interleaved<0b10, opc, asm, ZPR32, ZPR32>;
  3148. def _D : sve2_bitwise_xor_interleaved<0b11, opc, asm, ZPR64, ZPR64>;
  3149. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  3150. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  3151. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3152. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  3153. }
  3154. class sve2_bitwise_shift_left_long<bits<3> tsz8_64, bits<2> opc, string asm,
  3155. ZPRRegOp zprty1, ZPRRegOp zprty2,
  3156. Operand immtype>
  3157. : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
  3158. asm, "\t$Zd, $Zn, $imm",
  3159. "", []>, Sched<[]> {
  3160. bits<5> Zd;
  3161. bits<5> Zn;
  3162. bits<5> imm;
  3163. let Inst{31-23} = 0b010001010;
  3164. let Inst{22} = tsz8_64{2};
  3165. let Inst{21} = 0b0;
  3166. let Inst{20-19} = tsz8_64{1-0};
  3167. let Inst{18-16} = imm{2-0}; // imm3
  3168. let Inst{15-12} = 0b1010;
  3169. let Inst{11-10} = opc;
  3170. let Inst{9-5} = Zn;
  3171. let Inst{4-0} = Zd;
  3172. }
  3173. multiclass sve2_bitwise_shift_left_long<bits<2> opc, string asm,
  3174. SDPatternOperator op> {
  3175. def _H : sve2_bitwise_shift_left_long<{0,0,1}, opc, asm,
  3176. ZPR16, ZPR8, vecshiftL8>;
  3177. def _S : sve2_bitwise_shift_left_long<{0,1,?}, opc, asm,
  3178. ZPR32, ZPR16, vecshiftL16> {
  3179. let Inst{19} = imm{3};
  3180. }
  3181. def _D : sve2_bitwise_shift_left_long<{1,?,?}, opc, asm,
  3182. ZPR64, ZPR32, vecshiftL32> {
  3183. let Inst{20-19} = imm{4-3};
  3184. }
  3185. def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _H)>;
  3186. def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _S)>;
  3187. def : SVE_2_Op_Imm_Pat<nxv2i64, op, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _D)>;
  3188. }
  3189. //===----------------------------------------------------------------------===//
  3190. // SVE2 Accumulate Group
  3191. //===----------------------------------------------------------------------===//
  3192. class sve2_int_bin_shift_imm<bits<4> tsz8_64, bit opc, string asm,
  3193. ZPRRegOp zprty, Operand immtype>
  3194. : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, immtype:$imm),
  3195. asm, "\t$Zd, $Zn, $imm",
  3196. "", []>, Sched<[]> {
  3197. bits<5> Zd;
  3198. bits<5> Zn;
  3199. bits<6> imm;
  3200. let Inst{31-24} = 0b01000101;
  3201. let Inst{23-22} = tsz8_64{3-2};
  3202. let Inst{21} = 0b0;
  3203. let Inst{20-19} = tsz8_64{1-0};
  3204. let Inst{18-16} = imm{2-0}; // imm3
  3205. let Inst{15-11} = 0b11110;
  3206. let Inst{10} = opc;
  3207. let Inst{9-5} = Zn;
  3208. let Inst{4-0} = Zd;
  3209. let Constraints = "$Zd = $_Zd";
  3210. }
  3211. multiclass sve2_int_bin_shift_imm_left<bit opc, string asm,
  3212. SDPatternOperator op> {
  3213. def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
  3214. def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
  3215. let Inst{19} = imm{3};
  3216. }
  3217. def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
  3218. let Inst{20-19} = imm{4-3};
  3219. }
  3220. def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
  3221. let Inst{22} = imm{5};
  3222. let Inst{20-19} = imm{4-3};
  3223. }
  3224. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _B)>;
  3225. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>;
  3226. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>;
  3227. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>;
  3228. }
  3229. multiclass sve2_int_bin_shift_imm_right<bit opc, string asm,
  3230. SDPatternOperator op> {
  3231. def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
  3232. def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
  3233. let Inst{19} = imm{3};
  3234. }
  3235. def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
  3236. let Inst{20-19} = imm{4-3};
  3237. }
  3238. def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
  3239. let Inst{22} = imm{5};
  3240. let Inst{20-19} = imm{4-3};
  3241. }
  3242. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
  3243. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
  3244. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
  3245. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
  3246. }
  3247. class sve2_int_bin_accum_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
  3248. ZPRRegOp zprty, Operand immtype>
  3249. : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, immtype:$imm),
  3250. asm, "\t$Zda, $Zn, $imm",
  3251. "", []>, Sched<[]> {
  3252. bits<5> Zda;
  3253. bits<5> Zn;
  3254. bits<6> imm;
  3255. let Inst{31-24} = 0b01000101;
  3256. let Inst{23-22} = tsz8_64{3-2};
  3257. let Inst{21} = 0b0;
  3258. let Inst{20-19} = tsz8_64{1-0};
  3259. let Inst{18-16} = imm{2-0}; // imm3
  3260. let Inst{15-12} = 0b1110;
  3261. let Inst{11-10} = opc;
  3262. let Inst{9-5} = Zn;
  3263. let Inst{4-0} = Zda;
  3264. let Constraints = "$Zda = $_Zda";
  3265. let DestructiveInstType = DestructiveOther;
  3266. let ElementSize = ElementSizeNone;
  3267. }
  3268. multiclass sve2_int_bin_accum_shift_imm_right<bits<2> opc, string asm,
  3269. SDPatternOperator op> {
  3270. def _B : sve2_int_bin_accum_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
  3271. def _H : sve2_int_bin_accum_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
  3272. let Inst{19} = imm{3};
  3273. }
  3274. def _S : sve2_int_bin_accum_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
  3275. let Inst{20-19} = imm{4-3};
  3276. }
  3277. def _D : sve2_int_bin_accum_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
  3278. let Inst{22} = imm{5};
  3279. let Inst{20-19} = imm{4-3};
  3280. }
  3281. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
  3282. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
  3283. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
  3284. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
  3285. }
  3286. class sve2_int_cadd<bits<2> sz, bit opc, string asm, ZPRRegOp zprty>
  3287. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, complexrotateopodd:$rot),
  3288. asm, "\t$Zdn, $_Zdn, $Zm, $rot", "", []>, Sched<[]> {
  3289. bits<5> Zdn;
  3290. bits<5> Zm;
  3291. bit rot;
  3292. let Inst{31-24} = 0b01000101;
  3293. let Inst{23-22} = sz;
  3294. let Inst{21-17} = 0b00000;
  3295. let Inst{16} = opc;
  3296. let Inst{15-11} = 0b11011;
  3297. let Inst{10} = rot;
  3298. let Inst{9-5} = Zm;
  3299. let Inst{4-0} = Zdn;
  3300. let Constraints = "$Zdn = $_Zdn";
  3301. let DestructiveInstType = DestructiveOther;
  3302. let ElementSize = ElementSizeNone;
  3303. }
  3304. multiclass sve2_int_cadd<bit opc, string asm, SDPatternOperator op> {
  3305. def _B : sve2_int_cadd<0b00, opc, asm, ZPR8>;
  3306. def _H : sve2_int_cadd<0b01, opc, asm, ZPR16>;
  3307. def _S : sve2_int_cadd<0b10, opc, asm, ZPR32>;
  3308. def _D : sve2_int_cadd<0b11, opc, asm, ZPR64>;
  3309. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, complexrotateopodd, !cast<Instruction>(NAME # _B)>;
  3310. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, complexrotateopodd, !cast<Instruction>(NAME # _H)>;
  3311. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, complexrotateopodd, !cast<Instruction>(NAME # _S)>;
  3312. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, complexrotateopodd, !cast<Instruction>(NAME # _D)>;
  3313. }
  3314. class sve2_int_absdiff_accum<bits<2> sz, bits<4> opc, string asm,
  3315. ZPRRegOp zprty1, ZPRRegOp zprty2>
  3316. : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
  3317. asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
  3318. bits<5> Zda;
  3319. bits<5> Zn;
  3320. bits<5> Zm;
  3321. let Inst{31-24} = 0b01000101;
  3322. let Inst{23-22} = sz;
  3323. let Inst{21} = 0b0;
  3324. let Inst{20-16} = Zm;
  3325. let Inst{15-14} = 0b11;
  3326. let Inst{13-10} = opc;
  3327. let Inst{9-5} = Zn;
  3328. let Inst{4-0} = Zda;
  3329. let Constraints = "$Zda = $_Zda";
  3330. let DestructiveInstType = DestructiveOther;
  3331. let ElementSize = ElementSizeNone;
  3332. }
  3333. multiclass sve2_int_absdiff_accum<bit opc, string asm, SDPatternOperator op> {
  3334. def _B : sve2_int_absdiff_accum<0b00, { 0b111, opc }, asm, ZPR8, ZPR8>;
  3335. def _H : sve2_int_absdiff_accum<0b01, { 0b111, opc }, asm, ZPR16, ZPR16>;
  3336. def _S : sve2_int_absdiff_accum<0b10, { 0b111, opc }, asm, ZPR32, ZPR32>;
  3337. def _D : sve2_int_absdiff_accum<0b11, { 0b111, opc }, asm, ZPR64, ZPR64>;
  3338. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  3339. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  3340. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3341. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  3342. }
  3343. multiclass sve2_int_absdiff_accum_long<bits<2> opc, string asm,
  3344. SDPatternOperator op> {
  3345. def _H : sve2_int_absdiff_accum<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
  3346. def _S : sve2_int_absdiff_accum<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
  3347. def _D : sve2_int_absdiff_accum<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
  3348. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
  3349. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
  3350. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
  3351. }
  3352. multiclass sve2_int_addsub_long_carry<bits<2> opc, string asm,
  3353. SDPatternOperator op> {
  3354. def _S : sve2_int_absdiff_accum<{ opc{1}, 0b0 }, { 0b010, opc{0} }, asm,
  3355. ZPR32, ZPR32>;
  3356. def _D : sve2_int_absdiff_accum<{ opc{1}, 0b1 }, { 0b010, opc{0} }, asm,
  3357. ZPR64, ZPR64>;
  3358. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3359. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  3360. }
  3361. //===----------------------------------------------------------------------===//
  3362. // SVE2 Narrowing Group
  3363. //===----------------------------------------------------------------------===//
  3364. class sve2_int_bin_shift_imm_narrow_bottom<bits<3> tsz8_64, bits<3> opc,
  3365. string asm, ZPRRegOp zprty1,
  3366. ZPRRegOp zprty2, Operand immtype>
  3367. : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
  3368. asm, "\t$Zd, $Zn, $imm",
  3369. "", []>, Sched<[]> {
  3370. bits<5> Zd;
  3371. bits<5> Zn;
  3372. bits<5> imm;
  3373. let Inst{31-23} = 0b010001010;
  3374. let Inst{22} = tsz8_64{2};
  3375. let Inst{21} = 0b1;
  3376. let Inst{20-19} = tsz8_64{1-0};
  3377. let Inst{18-16} = imm{2-0}; // imm3
  3378. let Inst{15-14} = 0b00;
  3379. let Inst{13-11} = opc;
  3380. let Inst{10} = 0b0;
  3381. let Inst{9-5} = Zn;
  3382. let Inst{4-0} = Zd;
  3383. }
  3384. multiclass sve2_int_bin_shift_imm_right_narrow_bottom<bits<3> opc, string asm,
  3385. SDPatternOperator op> {
  3386. def _B : sve2_int_bin_shift_imm_narrow_bottom<{0,0,1}, opc, asm, ZPR8, ZPR16,
  3387. tvecshiftR8>;
  3388. def _H : sve2_int_bin_shift_imm_narrow_bottom<{0,1,?}, opc, asm, ZPR16, ZPR32,
  3389. tvecshiftR16> {
  3390. let Inst{19} = imm{3};
  3391. }
  3392. def _S : sve2_int_bin_shift_imm_narrow_bottom<{1,?,?}, opc, asm, ZPR32, ZPR64,
  3393. tvecshiftR32> {
  3394. let Inst{20-19} = imm{4-3};
  3395. }
  3396. def : SVE_2_Op_Imm_Pat<nxv16i8, op, nxv8i16, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
  3397. def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
  3398. def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
  3399. }
  3400. class sve2_int_bin_shift_imm_narrow_top<bits<3> tsz8_64, bits<3> opc,
  3401. string asm, ZPRRegOp zprty1,
  3402. ZPRRegOp zprty2, Operand immtype>
  3403. : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, immtype:$imm),
  3404. asm, "\t$Zd, $Zn, $imm",
  3405. "", []>, Sched<[]> {
  3406. bits<5> Zd;
  3407. bits<5> Zn;
  3408. bits<5> imm;
  3409. let Inst{31-23} = 0b010001010;
  3410. let Inst{22} = tsz8_64{2};
  3411. let Inst{21} = 0b1;
  3412. let Inst{20-19} = tsz8_64{1-0};
  3413. let Inst{18-16} = imm{2-0}; // imm3
  3414. let Inst{15-14} = 0b00;
  3415. let Inst{13-11} = opc;
  3416. let Inst{10} = 0b1;
  3417. let Inst{9-5} = Zn;
  3418. let Inst{4-0} = Zd;
  3419. let Constraints = "$Zd = $_Zd";
  3420. }
  3421. multiclass sve2_int_bin_shift_imm_right_narrow_top<bits<3> opc, string asm,
  3422. SDPatternOperator op> {
  3423. def _B : sve2_int_bin_shift_imm_narrow_top<{0,0,1}, opc, asm, ZPR8, ZPR16,
  3424. tvecshiftR8>;
  3425. def _H : sve2_int_bin_shift_imm_narrow_top<{0,1,?}, opc, asm, ZPR16, ZPR32,
  3426. tvecshiftR16> {
  3427. let Inst{19} = imm{3};
  3428. }
  3429. def _S : sve2_int_bin_shift_imm_narrow_top<{1,?,?}, opc, asm, ZPR32, ZPR64,
  3430. tvecshiftR32> {
  3431. let Inst{20-19} = imm{4-3};
  3432. }
  3433. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv8i16, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
  3434. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
  3435. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
  3436. }
  3437. class sve2_int_addsub_narrow_high_bottom<bits<2> sz, bits<2> opc, string asm,
  3438. ZPRRegOp zprty1, ZPRRegOp zprty2>
  3439. : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
  3440. asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
  3441. bits<5> Zd;
  3442. bits<5> Zn;
  3443. bits<5> Zm;
  3444. let Inst{31-24} = 0b01000101;
  3445. let Inst{23-22} = sz;
  3446. let Inst{21} = 0b1;
  3447. let Inst{20-16} = Zm;
  3448. let Inst{15-13} = 0b011;
  3449. let Inst{12-11} = opc; // S, R
  3450. let Inst{10} = 0b0; // Top
  3451. let Inst{9-5} = Zn;
  3452. let Inst{4-0} = Zd;
  3453. }
  3454. multiclass sve2_int_addsub_narrow_high_bottom<bits<2> opc, string asm,
  3455. SDPatternOperator op> {
  3456. def _B : sve2_int_addsub_narrow_high_bottom<0b01, opc, asm, ZPR8, ZPR16>;
  3457. def _H : sve2_int_addsub_narrow_high_bottom<0b10, opc, asm, ZPR16, ZPR32>;
  3458. def _S : sve2_int_addsub_narrow_high_bottom<0b11, opc, asm, ZPR32, ZPR64>;
  3459. def : SVE_2_Op_Pat<nxv16i8, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>;
  3460. def : SVE_2_Op_Pat<nxv8i16, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>;
  3461. def : SVE_2_Op_Pat<nxv4i32, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>;
  3462. }
  3463. class sve2_int_addsub_narrow_high_top<bits<2> sz, bits<2> opc, string asm,
  3464. ZPRRegOp zprty1, ZPRRegOp zprty2>
  3465. : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
  3466. asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
  3467. bits<5> Zd;
  3468. bits<5> Zn;
  3469. bits<5> Zm;
  3470. let Inst{31-24} = 0b01000101;
  3471. let Inst{23-22} = sz;
  3472. let Inst{21} = 0b1;
  3473. let Inst{20-16} = Zm;
  3474. let Inst{15-13} = 0b011;
  3475. let Inst{12-11} = opc; // S, R
  3476. let Inst{10} = 0b1; // Top
  3477. let Inst{9-5} = Zn;
  3478. let Inst{4-0} = Zd;
  3479. let Constraints = "$Zd = $_Zd";
  3480. }
  3481. multiclass sve2_int_addsub_narrow_high_top<bits<2> opc, string asm,
  3482. SDPatternOperator op> {
  3483. def _B : sve2_int_addsub_narrow_high_top<0b01, opc, asm, ZPR8, ZPR16>;
  3484. def _H : sve2_int_addsub_narrow_high_top<0b10, opc, asm, ZPR16, ZPR32>;
  3485. def _S : sve2_int_addsub_narrow_high_top<0b11, opc, asm, ZPR32, ZPR64>;
  3486. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>;
  3487. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>;
  3488. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>;
  3489. }
  3490. class sve2_int_sat_extract_narrow_bottom<bits<3> tsz8_64, bits<2> opc, string asm,
  3491. ZPRRegOp zprty1, ZPRRegOp zprty2>
  3492. : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
  3493. asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
  3494. bits<5> Zd;
  3495. bits<5> Zn;
  3496. let Inst{31-23} = 0b010001010;
  3497. let Inst{22} = tsz8_64{2};
  3498. let Inst{21} = 0b1;
  3499. let Inst{20-19} = tsz8_64{1-0};
  3500. let Inst{18-13} = 0b000010;
  3501. let Inst{12-11} = opc;
  3502. let Inst{10} = 0b0;
  3503. let Inst{9-5} = Zn;
  3504. let Inst{4-0} = Zd;
  3505. }
  3506. multiclass sve2_int_sat_extract_narrow_bottom<bits<2> opc, string asm,
  3507. SDPatternOperator op> {
  3508. def _B : sve2_int_sat_extract_narrow_bottom<0b001, opc, asm, ZPR8, ZPR16>;
  3509. def _H : sve2_int_sat_extract_narrow_bottom<0b010, opc, asm, ZPR16, ZPR32>;
  3510. def _S : sve2_int_sat_extract_narrow_bottom<0b100, opc, asm, ZPR32, ZPR64>;
  3511. def : SVE_1_Op_Pat<nxv16i8, op, nxv8i16, !cast<Instruction>(NAME # _B)>;
  3512. def : SVE_1_Op_Pat<nxv8i16, op, nxv4i32, !cast<Instruction>(NAME # _H)>;
  3513. def : SVE_1_Op_Pat<nxv4i32, op, nxv2i64, !cast<Instruction>(NAME # _S)>;
  3514. }
  3515. class sve2_int_sat_extract_narrow_top<bits<3> tsz8_64, bits<2> opc, string asm,
  3516. ZPRRegOp zprty1, ZPRRegOp zprty2>
  3517. : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn),
  3518. asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
  3519. bits<5> Zd;
  3520. bits<5> Zn;
  3521. let Inst{31-23} = 0b010001010;
  3522. let Inst{22} = tsz8_64{2};
  3523. let Inst{21} = 0b1;
  3524. let Inst{20-19} = tsz8_64{1-0};
  3525. let Inst{18-13} = 0b000010;
  3526. let Inst{12-11} = opc;
  3527. let Inst{10} = 0b1;
  3528. let Inst{9-5} = Zn;
  3529. let Inst{4-0} = Zd;
  3530. let Constraints = "$Zd = $_Zd";
  3531. }
  3532. multiclass sve2_int_sat_extract_narrow_top<bits<2> opc, string asm,
  3533. SDPatternOperator op> {
  3534. def _B : sve2_int_sat_extract_narrow_top<0b001, opc, asm, ZPR8, ZPR16>;
  3535. def _H : sve2_int_sat_extract_narrow_top<0b010, opc, asm, ZPR16, ZPR32>;
  3536. def _S : sve2_int_sat_extract_narrow_top<0b100, opc, asm, ZPR32, ZPR64>;
  3537. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, !cast<Instruction>(NAME # _B)>;
  3538. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, !cast<Instruction>(NAME # _H)>;
  3539. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
  3540. }
  3541. //===----------------------------------------------------------------------===//
  3542. // SVE Integer Arithmetic - Unary Predicated Group
  3543. //===----------------------------------------------------------------------===//
  3544. class sve_int_un_pred_arit<bits<2> sz8_64, bits<4> opc,
  3545. string asm, ZPRRegOp zprty>
  3546. : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
  3547. asm, "\t$Zd, $Pg/m, $Zn",
  3548. "",
  3549. []>, Sched<[]> {
  3550. bits<3> Pg;
  3551. bits<5> Zd;
  3552. bits<5> Zn;
  3553. let Inst{31-24} = 0b00000100;
  3554. let Inst{23-22} = sz8_64;
  3555. let Inst{21-20} = 0b01;
  3556. let Inst{19} = opc{0};
  3557. let Inst{18-16} = opc{3-1};
  3558. let Inst{15-13} = 0b101;
  3559. let Inst{12-10} = Pg;
  3560. let Inst{9-5} = Zn;
  3561. let Inst{4-0} = Zd;
  3562. let Constraints = "$Zd = $_Zd";
  3563. let DestructiveInstType = DestructiveUnaryPassthru;
  3564. let ElementSize = zprty.ElementSize;
  3565. }
  3566. multiclass sve_int_un_pred_arit_0<bits<3> opc, string asm,
  3567. SDPatternOperator op> {
  3568. def _B : sve_int_un_pred_arit<0b00, { opc, 0b0 }, asm, ZPR8>,
  3569. SVEPseudo2Instr<NAME # _B, 1>;
  3570. def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>,
  3571. SVEPseudo2Instr<NAME # _H, 1>;
  3572. def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
  3573. SVEPseudo2Instr<NAME # _S, 1>;
  3574. def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
  3575. SVEPseudo2Instr<NAME # _D, 1>;
  3576. def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  3577. def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  3578. def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3579. def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  3580. def _UNDEF_B : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
  3581. def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
  3582. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  3583. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  3584. defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>;
  3585. defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  3586. defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3587. defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  3588. }
  3589. multiclass sve_int_un_pred_arit_0_h<bits<3> opc, string asm,
  3590. SDPatternOperator op> {
  3591. def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>,
  3592. SVEPseudo2Instr<NAME # _H, 1>;
  3593. def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
  3594. SVEPseudo2Instr<NAME # _S, 1>;
  3595. def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
  3596. SVEPseudo2Instr<NAME # _D, 1>;
  3597. def : SVE_InReg_Extend<nxv8i16, op, nxv8i1, nxv8i8, !cast<Instruction>(NAME # _H)>;
  3598. def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i8, !cast<Instruction>(NAME # _S)>;
  3599. def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i8, !cast<Instruction>(NAME # _D)>;
  3600. def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
  3601. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  3602. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  3603. defm : SVE_InReg_Extend_PassthruUndef<nxv8i16, op, nxv8i1, nxv8i8, !cast<Pseudo>(NAME # _UNDEF_H)>;
  3604. defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i8, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3605. defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i8, !cast<Pseudo>(NAME # _UNDEF_D)>;
  3606. }
  3607. multiclass sve_int_un_pred_arit_0_w<bits<3> opc, string asm,
  3608. SDPatternOperator op> {
  3609. def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
  3610. SVEPseudo2Instr<NAME # _S, 1>;
  3611. def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
  3612. SVEPseudo2Instr<NAME # _D, 1>;
  3613. def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i16, !cast<Instruction>(NAME # _S)>;
  3614. def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i16, !cast<Instruction>(NAME # _D)>;
  3615. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  3616. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  3617. defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i16, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3618. defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i16, !cast<Pseudo>(NAME # _UNDEF_D)>;
  3619. }
  3620. multiclass sve_int_un_pred_arit_0_d<bits<3> opc, string asm,
  3621. SDPatternOperator op> {
  3622. def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
  3623. SVEPseudo2Instr<NAME # _D, 1>;
  3624. def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i32, !cast<Instruction>(NAME # _D)>;
  3625. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  3626. defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i32, !cast<Pseudo>(NAME # _UNDEF_D)>;
  3627. }
  3628. multiclass sve_int_un_pred_arit_1<bits<3> opc, string asm,
  3629. SDPatternOperator op> {
  3630. def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>,
  3631. SVEPseudo2Instr<NAME # _B, 1>;
  3632. def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>,
  3633. SVEPseudo2Instr<NAME # _H, 1>;
  3634. def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>,
  3635. SVEPseudo2Instr<NAME # _S, 1>;
  3636. def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>,
  3637. SVEPseudo2Instr<NAME # _D, 1>;
  3638. def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  3639. def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  3640. def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  3641. def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  3642. def _UNDEF_B : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
  3643. def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
  3644. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  3645. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  3646. defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>;
  3647. defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  3648. defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3649. defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  3650. }
  3651. multiclass sve_int_un_pred_arit_1_fp<bits<3> opc, string asm, SDPatternOperator op> {
  3652. def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>,
  3653. SVEPseudo2Instr<NAME # _H, 1>;
  3654. def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>,
  3655. SVEPseudo2Instr<NAME # _S, 1>;
  3656. def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>,
  3657. SVEPseudo2Instr<NAME # _D, 1>;
  3658. def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  3659. def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
  3660. def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
  3661. def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  3662. def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  3663. def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  3664. def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
  3665. def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
  3666. def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
  3667. defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  3668. defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  3669. defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  3670. defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3671. defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  3672. defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  3673. }
  3674. //===----------------------------------------------------------------------===//
  3675. // SVE Integer Wide Immediate - Unpredicated Group
  3676. //===----------------------------------------------------------------------===//
  3677. class sve_int_dup_imm<bits<2> sz8_64, string asm,
  3678. ZPRRegOp zprty, Operand immtype>
  3679. : I<(outs zprty:$Zd), (ins immtype:$imm),
  3680. asm, "\t$Zd, $imm",
  3681. "",
  3682. []>, Sched<[]> {
  3683. bits<5> Zd;
  3684. bits<9> imm;
  3685. let Inst{31-24} = 0b00100101;
  3686. let Inst{23-22} = sz8_64;
  3687. let Inst{21-14} = 0b11100011;
  3688. let Inst{13} = imm{8}; // sh
  3689. let Inst{12-5} = imm{7-0}; // imm8
  3690. let Inst{4-0} = Zd;
  3691. let isReMaterializable = 1;
  3692. }
  3693. multiclass sve_int_dup_imm<string asm> {
  3694. def _B : sve_int_dup_imm<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8>;
  3695. def _H : sve_int_dup_imm<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16>;
  3696. def _S : sve_int_dup_imm<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32>;
  3697. def _D : sve_int_dup_imm<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64>;
  3698. def : InstAlias<"mov $Zd, $imm",
  3699. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, cpy_imm8_opt_lsl_i8:$imm), 1>;
  3700. def : InstAlias<"mov $Zd, $imm",
  3701. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, cpy_imm8_opt_lsl_i16:$imm), 1>;
  3702. def : InstAlias<"mov $Zd, $imm",
  3703. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, cpy_imm8_opt_lsl_i32:$imm), 1>;
  3704. def : InstAlias<"mov $Zd, $imm",
  3705. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, cpy_imm8_opt_lsl_i64:$imm), 1>;
  3706. def : InstAlias<"fmov $Zd, #0.0",
  3707. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, 0, 0), 1>;
  3708. def : InstAlias<"fmov $Zd, #0.0",
  3709. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, 0, 0), 1>;
  3710. def : InstAlias<"fmov $Zd, #0.0",
  3711. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, 0, 0), 1>;
  3712. }
  3713. class sve_int_dup_fpimm<bits<2> sz8_64, Operand fpimmtype,
  3714. string asm, ZPRRegOp zprty>
  3715. : I<(outs zprty:$Zd), (ins fpimmtype:$imm8),
  3716. asm, "\t$Zd, $imm8",
  3717. "",
  3718. []>, Sched<[]> {
  3719. bits<5> Zd;
  3720. bits<8> imm8;
  3721. let Inst{31-24} = 0b00100101;
  3722. let Inst{23-22} = sz8_64;
  3723. let Inst{21-14} = 0b11100111;
  3724. let Inst{13} = 0b0;
  3725. let Inst{12-5} = imm8;
  3726. let Inst{4-0} = Zd;
  3727. let isReMaterializable = 1;
  3728. }
  3729. multiclass sve_int_dup_fpimm<string asm> {
  3730. def _H : sve_int_dup_fpimm<0b01, fpimm16, asm, ZPR16>;
  3731. def _S : sve_int_dup_fpimm<0b10, fpimm32, asm, ZPR32>;
  3732. def _D : sve_int_dup_fpimm<0b11, fpimm64, asm, ZPR64>;
  3733. def : InstAlias<"fmov $Zd, $imm8",
  3734. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, fpimm16:$imm8), 1>;
  3735. def : InstAlias<"fmov $Zd, $imm8",
  3736. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, fpimm32:$imm8), 1>;
  3737. def : InstAlias<"fmov $Zd, $imm8",
  3738. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, fpimm64:$imm8), 1>;
  3739. }
  3740. class sve_int_arith_imm0<bits<2> sz8_64, bits<3> opc, string asm,
  3741. ZPRRegOp zprty, Operand immtype>
  3742. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
  3743. asm, "\t$Zdn, $_Zdn, $imm",
  3744. "",
  3745. []>, Sched<[]> {
  3746. bits<5> Zdn;
  3747. bits<9> imm;
  3748. let Inst{31-24} = 0b00100101;
  3749. let Inst{23-22} = sz8_64;
  3750. let Inst{21-19} = 0b100;
  3751. let Inst{18-16} = opc;
  3752. let Inst{15-14} = 0b11;
  3753. let Inst{13} = imm{8}; // sh
  3754. let Inst{12-5} = imm{7-0}; // imm8
  3755. let Inst{4-0} = Zdn;
  3756. let Constraints = "$Zdn = $_Zdn";
  3757. let DestructiveInstType = DestructiveOther;
  3758. let ElementSize = ElementSizeNone;
  3759. }
  3760. multiclass sve_int_arith_imm0<bits<3> opc, string asm, SDPatternOperator op> {
  3761. def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>;
  3762. def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
  3763. def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
  3764. def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
  3765. def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, op, ZPR8, i32, SVEAddSubImm8Pat, !cast<Instruction>(NAME # _B)>;
  3766. def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubImm16Pat, !cast<Instruction>(NAME # _H)>;
  3767. def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubImm32Pat, !cast<Instruction>(NAME # _S)>;
  3768. def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubImm64Pat, !cast<Instruction>(NAME # _D)>;
  3769. }
  3770. multiclass sve_int_arith_imm0_subr<bits<3> opc, string asm, SDPatternOperator op> {
  3771. def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>;
  3772. def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
  3773. def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
  3774. def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
  3775. def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv16i8, op, ZPR8, i32, SVEAddSubImm8Pat, !cast<Instruction>(NAME # _B)>;
  3776. def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubImm16Pat, !cast<Instruction>(NAME # _H)>;
  3777. def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubImm32Pat, !cast<Instruction>(NAME # _S)>;
  3778. def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubImm64Pat, !cast<Instruction>(NAME # _D)>;
  3779. }
  3780. class sve_int_arith_imm<bits<2> sz8_64, bits<6> opc, string asm,
  3781. ZPRRegOp zprty, Operand immtype>
  3782. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
  3783. asm, "\t$Zdn, $_Zdn, $imm",
  3784. "",
  3785. []>, Sched<[]> {
  3786. bits<5> Zdn;
  3787. bits<8> imm;
  3788. let Inst{31-24} = 0b00100101;
  3789. let Inst{23-22} = sz8_64;
  3790. let Inst{21-16} = opc;
  3791. let Inst{15-13} = 0b110;
  3792. let Inst{12-5} = imm;
  3793. let Inst{4-0} = Zdn;
  3794. let Constraints = "$Zdn = $_Zdn";
  3795. let DestructiveInstType = DestructiveOther;
  3796. let ElementSize = ElementSizeNone;
  3797. }
  3798. multiclass sve_int_arith_imm1<bits<2> opc, string asm, SDPatternOperator op> {
  3799. def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, simm8>;
  3800. def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, simm8>;
  3801. def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, simm8>;
  3802. def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, simm8>;
  3803. def : SVE_1_Op_Imm_Arith_All_Active<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>;
  3804. def : SVE_1_Op_Imm_Arith_All_Active<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>;
  3805. def : SVE_1_Op_Imm_Arith_All_Active<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>;
  3806. def : SVE_1_Op_Imm_Arith_All_Active<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>;
  3807. }
  3808. multiclass sve_int_arith_imm1_unsigned<bits<2> opc, string asm, SDPatternOperator op> {
  3809. def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, imm0_255>;
  3810. def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, imm0_255>;
  3811. def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, imm0_255>;
  3812. def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, imm0_255>;
  3813. def : SVE_1_Op_Imm_Arith_All_Active<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithUImm8Pat, !cast<Instruction>(NAME # _B)>;
  3814. def : SVE_1_Op_Imm_Arith_All_Active<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithUImm16Pat, !cast<Instruction>(NAME # _H)>;
  3815. def : SVE_1_Op_Imm_Arith_All_Active<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithUImm32Pat, !cast<Instruction>(NAME # _S)>;
  3816. def : SVE_1_Op_Imm_Arith_All_Active<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithUImm64Pat, !cast<Instruction>(NAME # _D)>;
  3817. }
  3818. multiclass sve_int_arith_imm2<string asm, SDPatternOperator op> {
  3819. def _B : sve_int_arith_imm<0b00, 0b110000, asm, ZPR8, simm8>;
  3820. def _H : sve_int_arith_imm<0b01, 0b110000, asm, ZPR16, simm8>;
  3821. def _S : sve_int_arith_imm<0b10, 0b110000, asm, ZPR32, simm8>;
  3822. def _D : sve_int_arith_imm<0b11, 0b110000, asm, ZPR64, simm8>;
  3823. def : SVE_1_Op_Imm_Arith_All_Active<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>;
  3824. def : SVE_1_Op_Imm_Arith_All_Active<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>;
  3825. def : SVE_1_Op_Imm_Arith_All_Active<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>;
  3826. def : SVE_1_Op_Imm_Arith_All_Active<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>;
  3827. }
  3828. //===----------------------------------------------------------------------===//
  3829. // SVE Bitwise Logical - Unpredicated Group
  3830. //===----------------------------------------------------------------------===//
  3831. class sve_int_bin_cons_log<bits<2> opc, string asm>
  3832. : I<(outs ZPR64:$Zd), (ins ZPR64:$Zn, ZPR64:$Zm),
  3833. asm, "\t$Zd, $Zn, $Zm",
  3834. "",
  3835. []>, Sched<[]> {
  3836. bits<5> Zd;
  3837. bits<5> Zm;
  3838. bits<5> Zn;
  3839. let Inst{31-24} = 0b00000100;
  3840. let Inst{23-22} = opc{1-0};
  3841. let Inst{21} = 0b1;
  3842. let Inst{20-16} = Zm;
  3843. let Inst{15-10} = 0b001100;
  3844. let Inst{9-5} = Zn;
  3845. let Inst{4-0} = Zd;
  3846. }
  3847. multiclass sve_int_bin_cons_log<bits<2> opc, string asm, SDPatternOperator op> {
  3848. def NAME : sve_int_bin_cons_log<opc, asm>;
  3849. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
  3850. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
  3851. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
  3852. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
  3853. def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
  3854. (!cast<Instruction>(NAME) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 1>;
  3855. def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
  3856. (!cast<Instruction>(NAME) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 1>;
  3857. def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
  3858. (!cast<Instruction>(NAME) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 1>;
  3859. }
  3860. class sve2_int_bitwise_ternary_op_d<bits<3> opc, string asm>
  3861. : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Zk),
  3862. asm, "\t$Zdn, $_Zdn, $Zm, $Zk",
  3863. "",
  3864. []>, Sched<[]> {
  3865. bits<5> Zdn;
  3866. bits<5> Zk;
  3867. bits<5> Zm;
  3868. let Inst{31-24} = 0b00000100;
  3869. let Inst{23-22} = opc{2-1};
  3870. let Inst{21} = 0b1;
  3871. let Inst{20-16} = Zm;
  3872. let Inst{15-11} = 0b00111;
  3873. let Inst{10} = opc{0};
  3874. let Inst{9-5} = Zk;
  3875. let Inst{4-0} = Zdn;
  3876. let Constraints = "$Zdn = $_Zdn";
  3877. let DestructiveInstType = DestructiveOther;
  3878. let ElementSize = ElementSizeNone;
  3879. }
  3880. multiclass sve2_int_bitwise_ternary_op<bits<3> opc, string asm, SDPatternOperator op> {
  3881. def NAME : sve2_int_bitwise_ternary_op_d<opc, asm>;
  3882. def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
  3883. (!cast<Instruction>(NAME) ZPR8:$Zdn, ZPR8:$Zm, ZPR8:$Zk), 1>;
  3884. def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
  3885. (!cast<Instruction>(NAME) ZPR16:$Zdn, ZPR16:$Zm, ZPR16:$Zk), 1>;
  3886. def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
  3887. (!cast<Instruction>(NAME) ZPR32:$Zdn, ZPR32:$Zm, ZPR32:$Zk), 1>;
  3888. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
  3889. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
  3890. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
  3891. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
  3892. }
  3893. class sve2_int_rotate_right_imm<bits<4> tsz8_64, string asm,
  3894. ZPRRegOp zprty, Operand immtype>
  3895. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, immtype:$imm),
  3896. asm, "\t$Zdn, $_Zdn, $Zm, $imm",
  3897. "",
  3898. []>, Sched<[]> {
  3899. bits<5> Zdn;
  3900. bits<5> Zm;
  3901. bits<6> imm;
  3902. let Inst{31-24} = 0b00000100;
  3903. let Inst{23-22} = tsz8_64{3-2};
  3904. let Inst{21} = 0b1;
  3905. let Inst{20-19} = tsz8_64{1-0};
  3906. let Inst{18-16} = imm{2-0}; // imm3
  3907. let Inst{15-10} = 0b001101;
  3908. let Inst{9-5} = Zm;
  3909. let Inst{4-0} = Zdn;
  3910. let Constraints = "$Zdn = $_Zdn";
  3911. let DestructiveInstType = DestructiveOther;
  3912. let ElementSize = ElementSizeNone;
  3913. }
  3914. multiclass sve2_int_rotate_right_imm<string asm, SDPatternOperator op> {
  3915. def _B : sve2_int_rotate_right_imm<{0,0,0,1}, asm, ZPR8, vecshiftR8>;
  3916. def _H : sve2_int_rotate_right_imm<{0,0,1,?}, asm, ZPR16, vecshiftR16> {
  3917. let Inst{19} = imm{3};
  3918. }
  3919. def _S : sve2_int_rotate_right_imm<{0,1,?,?}, asm, ZPR32, vecshiftR32> {
  3920. let Inst{20-19} = imm{4-3};
  3921. }
  3922. def _D : sve2_int_rotate_right_imm<{1,?,?,?}, asm, ZPR64, vecshiftR64> {
  3923. let Inst{22} = imm{5};
  3924. let Inst{20-19} = imm{4-3};
  3925. }
  3926. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
  3927. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
  3928. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
  3929. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
  3930. }
  3931. //===----------------------------------------------------------------------===//
  3932. // SVE Integer Wide Immediate - Predicated Group
  3933. //===----------------------------------------------------------------------===//
  3934. class sve_int_dup_fpimm_pred<bits<2> sz, Operand fpimmtype,
  3935. string asm, ZPRRegOp zprty>
  3936. : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPRAny:$Pg, fpimmtype:$imm8),
  3937. asm, "\t$Zd, $Pg/m, $imm8",
  3938. "",
  3939. []>, Sched<[]> {
  3940. bits<4> Pg;
  3941. bits<5> Zd;
  3942. bits<8> imm8;
  3943. let Inst{31-24} = 0b00000101;
  3944. let Inst{23-22} = sz;
  3945. let Inst{21-20} = 0b01;
  3946. let Inst{19-16} = Pg;
  3947. let Inst{15-13} = 0b110;
  3948. let Inst{12-5} = imm8;
  3949. let Inst{4-0} = Zd;
  3950. let Constraints = "$Zd = $_Zd";
  3951. let DestructiveInstType = DestructiveOther;
  3952. let ElementSize = zprty.ElementSize;
  3953. }
  3954. multiclass sve_int_dup_fpimm_pred<string asm> {
  3955. def _H : sve_int_dup_fpimm_pred<0b01, fpimm16, asm, ZPR16>;
  3956. def _S : sve_int_dup_fpimm_pred<0b10, fpimm32, asm, ZPR32>;
  3957. def _D : sve_int_dup_fpimm_pred<0b11, fpimm64, asm, ZPR64>;
  3958. def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
  3959. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, fpimm16:$imm8), 1>;
  3960. def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
  3961. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, fpimm32:$imm8), 1>;
  3962. def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
  3963. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, fpimm64:$imm8), 1>;
  3964. }
  3965. class sve_int_dup_imm_pred<bits<2> sz8_64, bit m, string asm,
  3966. ZPRRegOp zprty, string pred_qual, dag iops>
  3967. : I<(outs zprty:$Zd), iops,
  3968. asm, "\t$Zd, $Pg"#pred_qual#", $imm",
  3969. "", []>, Sched<[]> {
  3970. bits<5> Zd;
  3971. bits<4> Pg;
  3972. bits<9> imm;
  3973. let Inst{31-24} = 0b00000101;
  3974. let Inst{23-22} = sz8_64;
  3975. let Inst{21-20} = 0b01;
  3976. let Inst{19-16} = Pg;
  3977. let Inst{15} = 0b0;
  3978. let Inst{14} = m;
  3979. let Inst{13} = imm{8}; // sh
  3980. let Inst{12-5} = imm{7-0}; // imm8
  3981. let Inst{4-0} = Zd;
  3982. let DestructiveInstType = DestructiveOther;
  3983. let ElementSize = zprty.ElementSize;
  3984. }
  3985. multiclass sve_int_dup_imm_pred_merge_inst<
  3986. bits<2> sz8_64, string asm, ZPRRegOp zprty, ValueType intty,
  3987. ValueType predty, ValueType scalarty, imm8_opt_lsl cpyimm> {
  3988. let Constraints = "$Zd = $_Zd" in
  3989. def NAME : sve_int_dup_imm_pred<sz8_64, 1, asm, zprty, "/m",
  3990. (ins zprty:$_Zd, PPRAny:$Pg, cpyimm:$imm)>;
  3991. def : InstAlias<"mov $Zd, $Pg/m, $imm",
  3992. (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>;
  3993. def : Pat<(intty
  3994. (vselect predty:$Pg,
  3995. (intty (AArch64dup (scalarty (SVE8BitLslImm<scalarty>.Pat i32:$imm, i32:$shift)))),
  3996. intty:$Zd)),
  3997. (!cast<Instruction>(NAME) zprty:$Zd, $Pg, i32:$imm, i32:$shift)>;
  3998. }
  3999. multiclass sve_int_dup_imm_pred_merge<string asm> {
  4000. defm _B : sve_int_dup_imm_pred_merge_inst<0b00, asm, ZPR8, nxv16i8, nxv16i1,
  4001. i32, cpy_imm8_opt_lsl_i8>;
  4002. defm _H : sve_int_dup_imm_pred_merge_inst<0b01, asm, ZPR16, nxv8i16, nxv8i1,
  4003. i32, cpy_imm8_opt_lsl_i16>;
  4004. defm _S : sve_int_dup_imm_pred_merge_inst<0b10, asm, ZPR32, nxv4i32, nxv4i1,
  4005. i32, cpy_imm8_opt_lsl_i32>;
  4006. defm _D : sve_int_dup_imm_pred_merge_inst<0b11, asm, ZPR64, nxv2i64, nxv2i1,
  4007. i64, cpy_imm8_opt_lsl_i64>;
  4008. def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
  4009. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, 0, 0), 0>;
  4010. def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
  4011. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, 0, 0), 0>;
  4012. def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
  4013. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, 0, 0), 0>;
  4014. }
  4015. multiclass sve_int_dup_imm_pred_zero_inst<
  4016. bits<2> sz8_64, string asm, ZPRRegOp zprty, ValueType intty,
  4017. ValueType predty, ValueType scalarty, imm8_opt_lsl cpyimm> {
  4018. def NAME : sve_int_dup_imm_pred<sz8_64, 0, asm, zprty, "/z",
  4019. (ins PPRAny:$Pg, cpyimm:$imm)>;
  4020. def : InstAlias<"mov $Zd, $Pg/z, $imm",
  4021. (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>;
  4022. def : Pat<(intty (zext (predty PPRAny:$Ps1))),
  4023. (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>;
  4024. def : Pat<(intty (sext (predty PPRAny:$Ps1))),
  4025. (!cast<Instruction>(NAME) PPRAny:$Ps1, -1, 0)>;
  4026. def : Pat<(intty (anyext (predty PPRAny:$Ps1))),
  4027. (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>;
  4028. def : Pat<(intty
  4029. (vselect predty:$Pg,
  4030. (intty (AArch64dup (scalarty (SVE8BitLslImm<scalarty>.Pat i32:$imm, i32:$shift)))),
  4031. (intty (AArch64dup (scalarty 0))))),
  4032. (!cast<Instruction>(NAME) $Pg, i32:$imm, i32:$shift)>;
  4033. }
  4034. multiclass sve_int_dup_imm_pred_zero<string asm> {
  4035. defm _B : sve_int_dup_imm_pred_zero_inst<0b00, asm, ZPR8, nxv16i8, nxv16i1,
  4036. i32, cpy_imm8_opt_lsl_i8>;
  4037. defm _H : sve_int_dup_imm_pred_zero_inst<0b01, asm, ZPR16, nxv8i16, nxv8i1,
  4038. i32, cpy_imm8_opt_lsl_i16>;
  4039. defm _S : sve_int_dup_imm_pred_zero_inst<0b10, asm, ZPR32, nxv4i32, nxv4i1,
  4040. i32, cpy_imm8_opt_lsl_i32>;
  4041. defm _D : sve_int_dup_imm_pred_zero_inst<0b11, asm, ZPR64, nxv2i64, nxv2i1,
  4042. i64, cpy_imm8_opt_lsl_i64>;
  4043. }
  4044. //===----------------------------------------------------------------------===//
  4045. // SVE Integer Compare - Vectors Group
  4046. //===----------------------------------------------------------------------===//
  4047. class sve_int_cmp<bit cmp_1, bits<2> sz8_64, bits<3> opc, string asm,
  4048. PPRRegOp pprty, ZPRRegOp zprty1, ZPRRegOp zprty2>
  4049. : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty1:$Zn, zprty2:$Zm),
  4050. asm, "\t$Pd, $Pg/z, $Zn, $Zm",
  4051. "",
  4052. []>, Sched<[]> {
  4053. bits<4> Pd;
  4054. bits<3> Pg;
  4055. bits<5> Zm;
  4056. bits<5> Zn;
  4057. let Inst{31-24} = 0b00100100;
  4058. let Inst{23-22} = sz8_64;
  4059. let Inst{21} = 0b0;
  4060. let Inst{20-16} = Zm;
  4061. let Inst{15} = opc{2};
  4062. let Inst{14} = cmp_1;
  4063. let Inst{13} = opc{1};
  4064. let Inst{12-10} = Pg;
  4065. let Inst{9-5} = Zn;
  4066. let Inst{4} = opc{0};
  4067. let Inst{3-0} = Pd;
  4068. let Defs = [NZCV];
  4069. let ElementSize = pprty.ElementSize;
  4070. let isPTestLike = 1;
  4071. }
  4072. multiclass SVE_SETCC_Pat<CondCode cc, CondCode invcc, ValueType predvt,
  4073. ValueType intvt, Instruction cmp> {
  4074. def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, cc)),
  4075. (cmp $Op1, $Op2, $Op3)>;
  4076. def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, invcc)),
  4077. (cmp $Op1, $Op3, $Op2)>;
  4078. def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z (predvt (AArch64ptrue 31)), intvt:$Op2, intvt:$Op3, cc))),
  4079. (cmp $Pg, $Op2, $Op3)>;
  4080. def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z (predvt (AArch64ptrue 31)), intvt:$Op2, intvt:$Op3, invcc))),
  4081. (cmp $Pg, $Op3, $Op2)>;
  4082. }
  4083. multiclass SVE_SETCC_Pat_With_Zero<CondCode cc, CondCode invcc, ValueType predvt,
  4084. ValueType intvt, Instruction cmp> {
  4085. def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, (SVEDup0), cc)),
  4086. (cmp $Op1, $Op2)>;
  4087. def : Pat<(predvt (AArch64setcc_z predvt:$Op1, (SVEDup0), intvt:$Op2, invcc)),
  4088. (cmp $Op1, $Op2)>;
  4089. }
  4090. multiclass sve_int_cmp_0<bits<3> opc, string asm, CondCode cc, CondCode invcc> {
  4091. def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR8>;
  4092. def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR16>;
  4093. def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR32>;
  4094. def _D : sve_int_cmp<0b0, 0b11, opc, asm, PPR64, ZPR64, ZPR64>;
  4095. defm : SVE_SETCC_Pat<cc, invcc, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  4096. defm : SVE_SETCC_Pat<cc, invcc, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  4097. defm : SVE_SETCC_Pat<cc, invcc, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  4098. defm : SVE_SETCC_Pat<cc, invcc, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  4099. }
  4100. multiclass sve_int_cmp_0_wide<bits<3> opc, string asm, SDPatternOperator op> {
  4101. def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
  4102. def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
  4103. def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
  4104. def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
  4105. def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
  4106. def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
  4107. }
  4108. multiclass sve_int_cmp_1_wide<bits<3> opc, string asm, SDPatternOperator op> {
  4109. def _B : sve_int_cmp<0b1, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
  4110. def _H : sve_int_cmp<0b1, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
  4111. def _S : sve_int_cmp<0b1, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
  4112. def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
  4113. def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
  4114. def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
  4115. }
  4116. //===----------------------------------------------------------------------===//
  4117. // SVE Integer Compare - Signed Immediate Group
  4118. //===----------------------------------------------------------------------===//
  4119. class sve_int_scmp_vi<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
  4120. ZPRRegOp zprty,
  4121. Operand immtype>
  4122. : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm5),
  4123. asm, "\t$Pd, $Pg/z, $Zn, $imm5",
  4124. "",
  4125. []>, Sched<[]> {
  4126. bits<4> Pd;
  4127. bits<3> Pg;
  4128. bits<5> Zn;
  4129. bits<5> imm5;
  4130. let Inst{31-24} = 0b00100101;
  4131. let Inst{23-22} = sz8_64;
  4132. let Inst{21} = 0b0;
  4133. let Inst{20-16} = imm5;
  4134. let Inst{15} = opc{2};
  4135. let Inst{14} = 0b0;
  4136. let Inst{13} = opc{1};
  4137. let Inst{12-10} = Pg;
  4138. let Inst{9-5} = Zn;
  4139. let Inst{4} = opc{0};
  4140. let Inst{3-0} = Pd;
  4141. let Defs = [NZCV];
  4142. let ElementSize = pprty.ElementSize;
  4143. let isPTestLike = 1;
  4144. }
  4145. multiclass SVE_SETCC_Imm_Pat<CondCode cc, CondCode commuted_cc,
  4146. ValueType predvt, ValueType intvt,
  4147. Operand immtype, Instruction cmp> {
  4148. def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg),
  4149. (intvt ZPR:$Zs1),
  4150. (intvt (AArch64dup (immtype:$imm))),
  4151. cc)),
  4152. (cmp $Pg, $Zs1, immtype:$imm)>;
  4153. def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg),
  4154. (intvt (AArch64dup (immtype:$imm))),
  4155. (intvt ZPR:$Zs1),
  4156. commuted_cc)),
  4157. (cmp $Pg, $Zs1, immtype:$imm)>;
  4158. }
  4159. multiclass sve_int_scmp_vi<bits<3> opc, string asm, CondCode cc, CondCode commuted_cc> {
  4160. def _B : sve_int_scmp_vi<0b00, opc, asm, PPR8, ZPR8, simm5_32b>;
  4161. def _H : sve_int_scmp_vi<0b01, opc, asm, PPR16, ZPR16, simm5_32b>;
  4162. def _S : sve_int_scmp_vi<0b10, opc, asm, PPR32, ZPR32, simm5_32b>;
  4163. def _D : sve_int_scmp_vi<0b11, opc, asm, PPR64, ZPR64, simm5_64b>;
  4164. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, simm5_32b,
  4165. !cast<Instruction>(NAME # _B)>;
  4166. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1, nxv8i16, simm5_32b,
  4167. !cast<Instruction>(NAME # _H)>;
  4168. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1, nxv4i32, simm5_32b,
  4169. !cast<Instruction>(NAME # _S)>;
  4170. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1, nxv2i64, simm5_64b,
  4171. !cast<Instruction>(NAME # _D)>;
  4172. }
  4173. //===----------------------------------------------------------------------===//
  4174. // SVE Integer Compare - Unsigned Immediate Group
  4175. //===----------------------------------------------------------------------===//
  4176. class sve_int_ucmp_vi<bits<2> sz8_64, bits<2> opc, string asm, PPRRegOp pprty,
  4177. ZPRRegOp zprty, Operand immtype>
  4178. : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm7),
  4179. asm, "\t$Pd, $Pg/z, $Zn, $imm7",
  4180. "",
  4181. []>, Sched<[]> {
  4182. bits<4> Pd;
  4183. bits<3> Pg;
  4184. bits<5> Zn;
  4185. bits<7> imm7;
  4186. let Inst{31-24} = 0b00100100;
  4187. let Inst{23-22} = sz8_64;
  4188. let Inst{21} = 1;
  4189. let Inst{20-14} = imm7;
  4190. let Inst{13} = opc{1};
  4191. let Inst{12-10} = Pg;
  4192. let Inst{9-5} = Zn;
  4193. let Inst{4} = opc{0};
  4194. let Inst{3-0} = Pd;
  4195. let Defs = [NZCV];
  4196. let ElementSize = pprty.ElementSize;
  4197. let isPTestLike = 1;
  4198. }
  4199. multiclass sve_int_ucmp_vi<bits<2> opc, string asm, CondCode cc,
  4200. CondCode commuted_cc> {
  4201. def _B : sve_int_ucmp_vi<0b00, opc, asm, PPR8, ZPR8, imm0_127>;
  4202. def _H : sve_int_ucmp_vi<0b01, opc, asm, PPR16, ZPR16, imm0_127>;
  4203. def _S : sve_int_ucmp_vi<0b10, opc, asm, PPR32, ZPR32, imm0_127>;
  4204. def _D : sve_int_ucmp_vi<0b11, opc, asm, PPR64, ZPR64, imm0_127_64b>;
  4205. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, imm0_127,
  4206. !cast<Instruction>(NAME # _B)>;
  4207. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1, nxv8i16, imm0_127,
  4208. !cast<Instruction>(NAME # _H)>;
  4209. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1, nxv4i32, imm0_127,
  4210. !cast<Instruction>(NAME # _S)>;
  4211. defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1, nxv2i64, imm0_127_64b,
  4212. !cast<Instruction>(NAME # _D)>;
  4213. }
  4214. //===----------------------------------------------------------------------===//
  4215. // SVE Integer Compare - Scalars Group
  4216. //===----------------------------------------------------------------------===//
  4217. class sve_int_cterm<bit sz, bit opc, string asm, RegisterClass rt>
  4218. : I<(outs), (ins rt:$Rn, rt:$Rm),
  4219. asm, "\t$Rn, $Rm",
  4220. "",
  4221. []>, Sched<[]> {
  4222. bits<5> Rm;
  4223. bits<5> Rn;
  4224. let Inst{31-23} = 0b001001011;
  4225. let Inst{22} = sz;
  4226. let Inst{21} = 0b1;
  4227. let Inst{20-16} = Rm;
  4228. let Inst{15-10} = 0b001000;
  4229. let Inst{9-5} = Rn;
  4230. let Inst{4} = opc;
  4231. let Inst{3-0} = 0b0000;
  4232. let Defs = [NZCV];
  4233. }
  4234. class sve_int_while_rr<bits<2> sz8_64, bits<4> opc, string asm,
  4235. RegisterClass gprty, PPRRegOp pprty>
  4236. : I<(outs pprty:$Pd), (ins gprty:$Rn, gprty:$Rm),
  4237. asm, "\t$Pd, $Rn, $Rm",
  4238. "", []>, Sched<[]> {
  4239. bits<4> Pd;
  4240. bits<5> Rm;
  4241. bits<5> Rn;
  4242. let Inst{31-24} = 0b00100101;
  4243. let Inst{23-22} = sz8_64;
  4244. let Inst{21} = 0b1;
  4245. let Inst{20-16} = Rm;
  4246. let Inst{15-13} = 0b000;
  4247. let Inst{12-10} = opc{3-1};
  4248. let Inst{9-5} = Rn;
  4249. let Inst{4} = opc{0};
  4250. let Inst{3-0} = Pd;
  4251. let Defs = [NZCV];
  4252. let ElementSize = pprty.ElementSize;
  4253. let isWhile = 1;
  4254. }
  4255. multiclass sve_int_while4_rr<bits<3> opc, string asm, SDPatternOperator op> {
  4256. def _B : sve_int_while_rr<0b00, { 0, opc }, asm, GPR32, PPR8>;
  4257. def _H : sve_int_while_rr<0b01, { 0, opc }, asm, GPR32, PPR16>;
  4258. def _S : sve_int_while_rr<0b10, { 0, opc }, asm, GPR32, PPR32>;
  4259. def _D : sve_int_while_rr<0b11, { 0, opc }, asm, GPR32, PPR64>;
  4260. def : SVE_2_Op_Pat<nxv16i1, op, i32, i32, !cast<Instruction>(NAME # _B)>;
  4261. def : SVE_2_Op_Pat<nxv8i1, op, i32, i32, !cast<Instruction>(NAME # _H)>;
  4262. def : SVE_2_Op_Pat<nxv4i1, op, i32, i32, !cast<Instruction>(NAME # _S)>;
  4263. def : SVE_2_Op_Pat<nxv2i1, op, i32, i32, !cast<Instruction>(NAME # _D)>;
  4264. }
  4265. multiclass sve_int_while8_rr<bits<3> opc, string asm, SDPatternOperator op> {
  4266. def _B : sve_int_while_rr<0b00, { 1, opc }, asm, GPR64, PPR8>;
  4267. def _H : sve_int_while_rr<0b01, { 1, opc }, asm, GPR64, PPR16>;
  4268. def _S : sve_int_while_rr<0b10, { 1, opc }, asm, GPR64, PPR32>;
  4269. def _D : sve_int_while_rr<0b11, { 1, opc }, asm, GPR64, PPR64>;
  4270. def : SVE_2_Op_Pat<nxv16i1, op, i64, i64, !cast<Instruction>(NAME # _B)>;
  4271. def : SVE_2_Op_Pat<nxv8i1, op, i64, i64, !cast<Instruction>(NAME # _H)>;
  4272. def : SVE_2_Op_Pat<nxv4i1, op, i64, i64, !cast<Instruction>(NAME # _S)>;
  4273. def : SVE_2_Op_Pat<nxv2i1, op, i64, i64, !cast<Instruction>(NAME # _D)>;
  4274. }
  4275. class sve2_int_while_rr<bits<2> sz8_64, bits<1> rw, string asm,
  4276. PPRRegOp pprty>
  4277. : I<(outs pprty:$Pd), (ins GPR64:$Rn, GPR64:$Rm),
  4278. asm, "\t$Pd, $Rn, $Rm",
  4279. "", []>, Sched<[]> {
  4280. bits<4> Pd;
  4281. bits<5> Rm;
  4282. bits<5> Rn;
  4283. let Inst{31-24} = 0b00100101;
  4284. let Inst{23-22} = sz8_64;
  4285. let Inst{21} = 0b1;
  4286. let Inst{20-16} = Rm;
  4287. let Inst{15-10} = 0b001100;
  4288. let Inst{9-5} = Rn;
  4289. let Inst{4} = rw;
  4290. let Inst{3-0} = Pd;
  4291. let Defs = [NZCV];
  4292. let ElementSize = pprty.ElementSize;
  4293. let isWhile = 1;
  4294. }
  4295. multiclass sve2_int_while_rr<bits<1> rw, string asm, string op> {
  4296. def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>;
  4297. def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>;
  4298. def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>;
  4299. def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>;
  4300. def : SVE_2_Op_Pat<nxv16i1, !cast<SDPatternOperator>(op # _b), i64, i64, !cast<Instruction>(NAME # _B)>;
  4301. def : SVE_2_Op_Pat<nxv8i1, !cast<SDPatternOperator>(op # _h), i64, i64, !cast<Instruction>(NAME # _H)>;
  4302. def : SVE_2_Op_Pat<nxv4i1, !cast<SDPatternOperator>(op # _s), i64, i64, !cast<Instruction>(NAME # _S)>;
  4303. def : SVE_2_Op_Pat<nxv2i1, !cast<SDPatternOperator>(op # _d), i64, i64, !cast<Instruction>(NAME # _D)>;
  4304. }
  4305. //===----------------------------------------------------------------------===//
  4306. // SVE Floating Point Fast Reduction Group
  4307. //===----------------------------------------------------------------------===//
  4308. class sve_fp_fast_red<bits<2> sz, bits<3> opc, string asm,
  4309. ZPRRegOp zprty, FPRasZPROperand dstOpType>
  4310. : I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
  4311. asm, "\t$Vd, $Pg, $Zn",
  4312. "",
  4313. []>, Sched<[]> {
  4314. bits<5> Zn;
  4315. bits<5> Vd;
  4316. bits<3> Pg;
  4317. let Inst{31-24} = 0b01100101;
  4318. let Inst{23-22} = sz;
  4319. let Inst{21-19} = 0b000;
  4320. let Inst{18-16} = opc;
  4321. let Inst{15-13} = 0b001;
  4322. let Inst{12-10} = Pg;
  4323. let Inst{9-5} = Zn;
  4324. let Inst{4-0} = Vd;
  4325. }
  4326. multiclass sve_fp_fast_red<bits<3> opc, string asm, SDPatternOperator op> {
  4327. def _H : sve_fp_fast_red<0b01, opc, asm, ZPR16, FPR16asZPR>;
  4328. def _S : sve_fp_fast_red<0b10, opc, asm, ZPR32, FPR32asZPR>;
  4329. def _D : sve_fp_fast_red<0b11, opc, asm, ZPR64, FPR64asZPR>;
  4330. def : SVE_2_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
  4331. def : SVE_2_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
  4332. def : SVE_2_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  4333. def : SVE_2_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  4334. def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  4335. def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  4336. }
  4337. //===----------------------------------------------------------------------===//
  4338. // SVE Floating Point Accumulating Reduction Group
  4339. //===----------------------------------------------------------------------===//
  4340. class sve_fp_2op_p_vd<bits<2> sz, bits<3> opc, string asm,
  4341. ZPRRegOp zprty, FPRasZPROperand dstOpType>
  4342. : I<(outs dstOpType:$Vdn), (ins PPR3bAny:$Pg, dstOpType:$_Vdn, zprty:$Zm),
  4343. asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
  4344. "",
  4345. []>,
  4346. Sched<[]> {
  4347. bits<3> Pg;
  4348. bits<5> Vdn;
  4349. bits<5> Zm;
  4350. let Inst{31-24} = 0b01100101;
  4351. let Inst{23-22} = sz;
  4352. let Inst{21-19} = 0b011;
  4353. let Inst{18-16} = opc;
  4354. let Inst{15-13} = 0b001;
  4355. let Inst{12-10} = Pg;
  4356. let Inst{9-5} = Zm;
  4357. let Inst{4-0} = Vdn;
  4358. let Constraints = "$Vdn = $_Vdn";
  4359. }
  4360. multiclass sve_fp_2op_p_vd<bits<3> opc, string asm, SDPatternOperator op> {
  4361. def _H : sve_fp_2op_p_vd<0b01, opc, asm, ZPR16, FPR16asZPR>;
  4362. def _S : sve_fp_2op_p_vd<0b10, opc, asm, ZPR32, FPR32asZPR>;
  4363. def _D : sve_fp_2op_p_vd<0b11, opc, asm, ZPR64, FPR64asZPR>;
  4364. def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H)>;
  4365. def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H)>;
  4366. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  4367. def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S)>;
  4368. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  4369. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  4370. }
  4371. //===----------------------------------------------------------------------===//
  4372. // SVE Floating Point Compare - Vectors Group
  4373. //===----------------------------------------------------------------------===//
  4374. class sve_fp_3op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
  4375. ZPRRegOp zprty>
  4376. : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
  4377. asm, "\t$Pd, $Pg/z, $Zn, $Zm",
  4378. "",
  4379. []>, Sched<[]> {
  4380. bits<4> Pd;
  4381. bits<3> Pg;
  4382. bits<5> Zm;
  4383. bits<5> Zn;
  4384. let Inst{31-24} = 0b01100101;
  4385. let Inst{23-22} = sz;
  4386. let Inst{21} = 0b0;
  4387. let Inst{20-16} = Zm;
  4388. let Inst{15} = opc{2};
  4389. let Inst{14} = 0b1;
  4390. let Inst{13} = opc{1};
  4391. let Inst{12-10} = Pg;
  4392. let Inst{9-5} = Zn;
  4393. let Inst{4} = opc{0};
  4394. let Inst{3-0} = Pd;
  4395. }
  4396. multiclass sve_fp_3op_p_pd<bits<3> opc, string asm, SDPatternOperator op> {
  4397. def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
  4398. def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
  4399. def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
  4400. def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  4401. def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  4402. def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  4403. }
  4404. multiclass sve_fp_3op_p_pd_cc<bits<3> opc, string asm,
  4405. CondCode cc1, CondCode cc2,
  4406. CondCode invcc1, CondCode invcc2> {
  4407. def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
  4408. def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
  4409. def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
  4410. defm : SVE_SETCC_Pat<cc1, invcc1, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  4411. defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
  4412. defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
  4413. defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  4414. defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  4415. defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  4416. defm : SVE_SETCC_Pat<cc2, invcc2, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  4417. defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
  4418. defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
  4419. defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  4420. defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  4421. defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  4422. }
  4423. //===----------------------------------------------------------------------===//
  4424. // SVE Floating Point Compare - with Zero Group
  4425. //===----------------------------------------------------------------------===//
  4426. class sve_fp_2op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
  4427. ZPRRegOp zprty>
  4428. : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn),
  4429. asm, "\t$Pd, $Pg/z, $Zn, #0.0",
  4430. "",
  4431. []>, Sched<[]> {
  4432. bits<4> Pd;
  4433. bits<3> Pg;
  4434. bits<5> Zn;
  4435. let Inst{31-24} = 0b01100101;
  4436. let Inst{23-22} = sz;
  4437. let Inst{21-18} = 0b0100;
  4438. let Inst{17-16} = opc{2-1};
  4439. let Inst{15-13} = 0b001;
  4440. let Inst{12-10} = Pg;
  4441. let Inst{9-5} = Zn;
  4442. let Inst{4} = opc{0};
  4443. let Inst{3-0} = Pd;
  4444. }
  4445. multiclass sve_fp_2op_p_pd<bits<3> opc, string asm,
  4446. CondCode cc1, CondCode cc2,
  4447. CondCode invcc1, CondCode invcc2> {
  4448. def _H : sve_fp_2op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
  4449. def _S : sve_fp_2op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
  4450. def _D : sve_fp_2op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
  4451. defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  4452. defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
  4453. defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
  4454. defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  4455. defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  4456. defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  4457. defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  4458. defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
  4459. defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
  4460. defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  4461. defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  4462. defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  4463. }
  4464. //===----------------------------------------------------------------------===//
  4465. //SVE Index Generation Group
  4466. //===----------------------------------------------------------------------===//
  4467. def simm5_8b_tgt : TImmLeaf<i8, [{ return (int8_t)Imm >= -16 && (int8_t)Imm < 16; }]>;
  4468. def simm5_16b_tgt : TImmLeaf<i16, [{ return (int16_t)Imm >= -16 && (int16_t)Imm < 16; }]>;
  4469. def simm5_32b_tgt : TImmLeaf<i32, [{ return (int32_t)Imm >= -16 && (int32_t)Imm < 16; }]>;
  4470. def simm5_64b_tgt : TImmLeaf<i64, [{ return (int64_t)Imm >= -16 && (int64_t)Imm < 16; }]>;
  4471. def i64imm_32bit_tgt : TImmLeaf<i64, [{
  4472. return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
  4473. }]>;
  4474. class sve_int_index_ii<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  4475. Operand imm_ty>
  4476. : I<(outs zprty:$Zd), (ins imm_ty:$imm5, imm_ty:$imm5b),
  4477. asm, "\t$Zd, $imm5, $imm5b",
  4478. "", []>, Sched<[]> {
  4479. bits<5> Zd;
  4480. bits<5> imm5;
  4481. bits<5> imm5b;
  4482. let Inst{31-24} = 0b00000100;
  4483. let Inst{23-22} = sz8_64;
  4484. let Inst{21} = 0b1;
  4485. let Inst{20-16} = imm5b;
  4486. let Inst{15-10} = 0b010000;
  4487. let Inst{9-5} = imm5;
  4488. let Inst{4-0} = Zd;
  4489. }
  4490. multiclass sve_int_index_ii<string asm> {
  4491. def _B : sve_int_index_ii<0b00, asm, ZPR8, simm5_8b>;
  4492. def _H : sve_int_index_ii<0b01, asm, ZPR16, simm5_16b>;
  4493. def _S : sve_int_index_ii<0b10, asm, ZPR32, simm5_32b>;
  4494. def _D : sve_int_index_ii<0b11, asm, ZPR64, simm5_64b>;
  4495. def : Pat<(nxv16i8 (step_vector simm5_8b_tgt:$imm5b)),
  4496. (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
  4497. def : Pat<(nxv8i16 (step_vector simm5_16b_tgt:$imm5b)),
  4498. (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
  4499. def : Pat<(nxv4i32 (step_vector simm5_32b_tgt:$imm5b)),
  4500. (!cast<Instruction>(NAME # "_S") (i32 0), simm5_32b:$imm5b)>;
  4501. def : Pat<(nxv2i64 (step_vector simm5_64b_tgt:$imm5b)),
  4502. (!cast<Instruction>(NAME # "_D") (i64 0), simm5_64b:$imm5b)>;
  4503. // add(step_vector(step), dup(X)) -> index(X, step).
  4504. def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5b)), (nxv16i8 (AArch64dup(simm5_8b:$imm5)))),
  4505. (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
  4506. def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5b)), (nxv8i16 (AArch64dup(simm5_16b:$imm5)))),
  4507. (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
  4508. def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5b)), (nxv4i32 (AArch64dup(simm5_32b:$imm5)))),
  4509. (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, simm5_32b:$imm5b)>;
  4510. def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5b)), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))),
  4511. (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, simm5_64b:$imm5b)>;
  4512. }
  4513. class sve_int_index_ir<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  4514. RegisterClass srcRegType, Operand imm_ty>
  4515. : I<(outs zprty:$Zd), (ins imm_ty:$imm5, srcRegType:$Rm),
  4516. asm, "\t$Zd, $imm5, $Rm",
  4517. "", []>, Sched<[]> {
  4518. bits<5> Rm;
  4519. bits<5> Zd;
  4520. bits<5> imm5;
  4521. let Inst{31-24} = 0b00000100;
  4522. let Inst{23-22} = sz8_64;
  4523. let Inst{21} = 0b1;
  4524. let Inst{20-16} = Rm;
  4525. let Inst{15-10} = 0b010010;
  4526. let Inst{9-5} = imm5;
  4527. let Inst{4-0} = Zd;
  4528. }
  4529. multiclass sve_int_index_ir<string asm, SDPatternOperator mulop, SDPatternOperator muloneuseop> {
  4530. def _B : sve_int_index_ir<0b00, asm, ZPR8, GPR32, simm5_8b>;
  4531. def _H : sve_int_index_ir<0b01, asm, ZPR16, GPR32, simm5_16b>;
  4532. def _S : sve_int_index_ir<0b10, asm, ZPR32, GPR32, simm5_32b>;
  4533. def _D : sve_int_index_ir<0b11, asm, ZPR64, GPR64, simm5_64b>;
  4534. def : Pat<(nxv16i8 (step_vector i8:$imm)),
  4535. (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
  4536. def : Pat<(nxv8i16 (step_vector i16:$imm)),
  4537. (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
  4538. def : Pat<(nxv4i32 (step_vector i32:$imm)),
  4539. (!cast<Instruction>(NAME # "_S") (i32 0), (!cast<Instruction>("MOVi32imm") $imm))>;
  4540. def : Pat<(nxv2i64 (step_vector i64:$imm)),
  4541. (!cast<Instruction>(NAME # "_D") (i64 0), (!cast<Instruction>("MOVi64imm") $imm))>;
  4542. def : Pat<(nxv2i64 (step_vector i64imm_32bit_tgt:$imm)),
  4543. (!cast<Instruction>(NAME # "_D") (i64 0), (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
  4544. // add(step_vector(step), dup(X)) -> index(X, step).
  4545. def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (AArch64dup(simm5_8b:$imm5)))),
  4546. (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
  4547. def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (AArch64dup(simm5_16b:$imm5)))),
  4548. (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
  4549. def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (AArch64dup(simm5_32b:$imm5)))),
  4550. (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, (!cast<Instruction>("MOVi32imm") $imm))>;
  4551. def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))),
  4552. (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (!cast<Instruction>("MOVi64imm") $imm))>;
  4553. def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))),
  4554. (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
  4555. // mul(step_vector(1), dup(Y)) -> index(0, Y).
  4556. def : Pat<(mulop (nxv16i1 (AArch64ptrue 31)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))),
  4557. (!cast<Instruction>(NAME # "_B") (i32 0), GPR32:$Rm)>;
  4558. def : Pat<(mulop (nxv8i1 (AArch64ptrue 31)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))),
  4559. (!cast<Instruction>(NAME # "_H") (i32 0), GPR32:$Rm)>;
  4560. def : Pat<(mulop (nxv4i1 (AArch64ptrue 31)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))),
  4561. (!cast<Instruction>(NAME # "_S") (i32 0), GPR32:$Rm)>;
  4562. def : Pat<(mulop (nxv2i1 (AArch64ptrue 31)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))),
  4563. (!cast<Instruction>(NAME # "_D") (i64 0), GPR64:$Rm)>;
  4564. // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y).
  4565. def : Pat<(add (muloneuseop (nxv16i1 (AArch64ptrue 31)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))), (nxv16i8 (AArch64dup(simm5_8b:$imm5)))),
  4566. (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, GPR32:$Rm)>;
  4567. def : Pat<(add (muloneuseop (nxv8i1 (AArch64ptrue 31)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))), (nxv8i16 (AArch64dup(simm5_16b:$imm5)))),
  4568. (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, GPR32:$Rm)>;
  4569. def : Pat<(add (muloneuseop (nxv4i1 (AArch64ptrue 31)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))), (nxv4i32 (AArch64dup(simm5_32b:$imm5)))),
  4570. (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, GPR32:$Rm)>;
  4571. def : Pat<(add (muloneuseop (nxv2i1 (AArch64ptrue 31)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))),
  4572. (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, GPR64:$Rm)>;
  4573. }
  4574. class sve_int_index_ri<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  4575. RegisterClass srcRegType, Operand imm_ty>
  4576. : I<(outs zprty:$Zd), (ins srcRegType:$Rn, imm_ty:$imm5),
  4577. asm, "\t$Zd, $Rn, $imm5",
  4578. "", []>, Sched<[]> {
  4579. bits<5> Rn;
  4580. bits<5> Zd;
  4581. bits<5> imm5;
  4582. let Inst{31-24} = 0b00000100;
  4583. let Inst{23-22} = sz8_64;
  4584. let Inst{21} = 0b1;
  4585. let Inst{20-16} = imm5;
  4586. let Inst{15-10} = 0b010001;
  4587. let Inst{9-5} = Rn;
  4588. let Inst{4-0} = Zd;
  4589. }
  4590. multiclass sve_int_index_ri<string asm> {
  4591. def _B : sve_int_index_ri<0b00, asm, ZPR8, GPR32, simm5_8b>;
  4592. def _H : sve_int_index_ri<0b01, asm, ZPR16, GPR32, simm5_16b>;
  4593. def _S : sve_int_index_ri<0b10, asm, ZPR32, GPR32, simm5_32b>;
  4594. def _D : sve_int_index_ri<0b11, asm, ZPR64, GPR64, simm5_64b>;
  4595. // add(step_vector(step), dup(X)) -> index(X, step).
  4596. def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5)), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))),
  4597. (!cast<Instruction>(NAME # "_B") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>;
  4598. def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5)), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))),
  4599. (!cast<Instruction>(NAME # "_H") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>;
  4600. def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5)), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))),
  4601. (!cast<Instruction>(NAME # "_S") GPR32:$Rm, simm5_32b:$imm5)>;
  4602. def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5)), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))),
  4603. (!cast<Instruction>(NAME # "_D") GPR64:$Rm, simm5_64b:$imm5)>;
  4604. }
  4605. class sve_int_index_rr<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  4606. RegisterClass srcRegType>
  4607. : I<(outs zprty:$Zd), (ins srcRegType:$Rn, srcRegType:$Rm),
  4608. asm, "\t$Zd, $Rn, $Rm",
  4609. "", []>, Sched<[]> {
  4610. bits<5> Zd;
  4611. bits<5> Rm;
  4612. bits<5> Rn;
  4613. let Inst{31-24} = 0b00000100;
  4614. let Inst{23-22} = sz8_64;
  4615. let Inst{21} = 0b1;
  4616. let Inst{20-16} = Rm;
  4617. let Inst{15-10} = 0b010011;
  4618. let Inst{9-5} = Rn;
  4619. let Inst{4-0} = Zd;
  4620. }
  4621. multiclass sve_int_index_rr<string asm, SDPatternOperator mulop> {
  4622. def _B : sve_int_index_rr<0b00, asm, ZPR8, GPR32>;
  4623. def _H : sve_int_index_rr<0b01, asm, ZPR16, GPR32>;
  4624. def _S : sve_int_index_rr<0b10, asm, ZPR32, GPR32>;
  4625. def _D : sve_int_index_rr<0b11, asm, ZPR64, GPR64>;
  4626. // add(step_vector(step), dup(X)) -> index(X, step).
  4627. def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (AArch64dup(i32 GPR32:$Rn)))),
  4628. (!cast<Instruction>(NAME # "_B") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
  4629. def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (AArch64dup(i32 GPR32:$Rn)))),
  4630. (!cast<Instruction>(NAME # "_H") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
  4631. def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (AArch64dup(i32 GPR32:$Rn)))),
  4632. (!cast<Instruction>(NAME # "_S") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") $imm))>;
  4633. def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (AArch64dup(i64 GPR64:$Rn)))),
  4634. (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (!cast<Instruction>("MOVi64imm") $imm))>;
  4635. def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (AArch64dup(i64 GPR64:$Rn)))),
  4636. (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
  4637. // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y).
  4638. def : Pat<(add (mulop (nxv16i1 (AArch64ptrue 31)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))), (nxv16i8 (AArch64dup(i32 GPR32:$Rn)))),
  4639. (!cast<Instruction>(NAME # "_B") GPR32:$Rn, GPR32:$Rm)>;
  4640. def : Pat<(add (mulop (nxv8i1 (AArch64ptrue 31)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))),(nxv8i16 (AArch64dup(i32 GPR32:$Rn)))),
  4641. (!cast<Instruction>(NAME # "_H") GPR32:$Rn, GPR32:$Rm)>;
  4642. def : Pat<(add (mulop (nxv4i1 (AArch64ptrue 31)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))),(nxv4i32 (AArch64dup(i32 GPR32:$Rn)))),
  4643. (!cast<Instruction>(NAME # "_S") GPR32:$Rn, GPR32:$Rm)>;
  4644. def : Pat<(add (mulop (nxv2i1 (AArch64ptrue 31)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))),(nxv2i64 (AArch64dup(i64 GPR64:$Rn)))),
  4645. (!cast<Instruction>(NAME # "_D") GPR64:$Rn, GPR64:$Rm)>;
  4646. }
  4647. //===----------------------------------------------------------------------===//
  4648. // SVE Bitwise Shift - Predicated Group
  4649. //===----------------------------------------------------------------------===//
  4650. class sve_int_bin_pred_shift_imm<bits<4> tsz8_64, bits<4> opc, string asm,
  4651. ZPRRegOp zprty, Operand immtype>
  4652. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, immtype:$imm),
  4653. asm, "\t$Zdn, $Pg/m, $_Zdn, $imm",
  4654. "",
  4655. []>, Sched<[]> {
  4656. bits<3> Pg;
  4657. bits<5> Zdn;
  4658. bits<6> imm;
  4659. let Inst{31-24} = 0b00000100;
  4660. let Inst{23-22} = tsz8_64{3-2};
  4661. let Inst{21-20} = 0b00;
  4662. let Inst{19-16} = opc;
  4663. let Inst{15-13} = 0b100;
  4664. let Inst{12-10} = Pg;
  4665. let Inst{9-8} = tsz8_64{1-0};
  4666. let Inst{7-5} = imm{2-0}; // imm3
  4667. let Inst{4-0} = Zdn;
  4668. let Constraints = "$Zdn = $_Zdn";
  4669. let DestructiveInstType = DestructiveBinaryImm;
  4670. let ElementSize = zprty.ElementSize;
  4671. }
  4672. multiclass sve_int_bin_pred_shift_imm_left<bits<4> opc, string asm, string Ps,
  4673. SDPatternOperator op = null_frag> {
  4674. def _B : SVEPseudo2Instr<Ps # _B, 1>,
  4675. sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
  4676. def _H : SVEPseudo2Instr<Ps # _H, 1>,
  4677. sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
  4678. let Inst{8} = imm{3};
  4679. }
  4680. def _S : SVEPseudo2Instr<Ps # _S, 1>,
  4681. sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
  4682. let Inst{9-8} = imm{4-3};
  4683. }
  4684. def _D : SVEPseudo2Instr<Ps # _D, 1>,
  4685. sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
  4686. let Inst{22} = imm{5};
  4687. let Inst{9-8} = imm{4-3};
  4688. }
  4689. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _B)>;
  4690. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>;
  4691. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>;
  4692. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1, nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>;
  4693. }
  4694. // As above but shift amount takes the form of a "vector immediate".
  4695. multiclass sve_int_bin_pred_shift_imm_left_dup<bits<4> opc, string asm,
  4696. string Ps, SDPatternOperator op>
  4697. : sve_int_bin_pred_shift_imm_left<opc, asm, Ps, null_frag> {
  4698. def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8, !cast<Instruction>(NAME # _B)>;
  4699. def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>;
  4700. def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>;
  4701. def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>;
  4702. }
  4703. multiclass sve_int_bin_pred_shift_imm_left_zeroing_bhsd<SDPatternOperator op> {
  4704. def _ZERO_B : PredTwoOpImmPseudo<NAME # _B, ZPR8, tvecshiftL8, FalseLanesZero>;
  4705. def _ZERO_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, tvecshiftL16, FalseLanesZero>;
  4706. def _ZERO_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, tvecshiftL32, FalseLanesZero>;
  4707. def _ZERO_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, tvecshiftL64, FalseLanesZero>;
  4708. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftL8, !cast<Pseudo>(NAME # _ZERO_B)>;
  4709. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1, nxv8i16, tvecshiftL16, !cast<Pseudo>(NAME # _ZERO_H)>;
  4710. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1, nxv4i32, tvecshiftL32, !cast<Pseudo>(NAME # _ZERO_S)>;
  4711. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1, nxv2i64, tvecshiftL64, !cast<Pseudo>(NAME # _ZERO_D)>;
  4712. }
  4713. multiclass sve_int_bin_pred_shift_imm_right<bits<4> opc, string asm, string Ps,
  4714. SDPatternOperator op = null_frag> {
  4715. def _B : SVEPseudo2Instr<Ps # _B, 1>,
  4716. sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
  4717. def _H : SVEPseudo2Instr<Ps # _H, 1>,
  4718. sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
  4719. let Inst{8} = imm{3};
  4720. }
  4721. def _S : SVEPseudo2Instr<Ps # _S, 1>,
  4722. sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
  4723. let Inst{9-8} = imm{4-3};
  4724. }
  4725. def _D : SVEPseudo2Instr<Ps # _D, 1>,
  4726. sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
  4727. let Inst{22} = imm{5};
  4728. let Inst{9-8} = imm{4-3};
  4729. }
  4730. def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
  4731. def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
  4732. def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
  4733. def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
  4734. }
  4735. // As above but shift amount takes the form of a "vector immediate".
  4736. multiclass sve_int_bin_pred_shift_imm_right_dup<bits<4> opc, string asm,
  4737. string Ps, SDPatternOperator op>
  4738. : sve_int_bin_pred_shift_imm_right<opc, asm, Ps, null_frag> {
  4739. def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8, !cast<Instruction>(NAME # _B)>;
  4740. def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>;
  4741. def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>;
  4742. def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>;
  4743. }
  4744. multiclass sve_int_bin_pred_shift_imm_right_zeroing_bhsd<SDPatternOperator op = null_frag> {
  4745. def _ZERO_B : PredTwoOpImmPseudo<NAME # _B, ZPR8, vecshiftR8, FalseLanesZero>;
  4746. def _ZERO_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, vecshiftR16, FalseLanesZero>;
  4747. def _ZERO_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, vecshiftR32, FalseLanesZero>;
  4748. def _ZERO_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, vecshiftR64, FalseLanesZero>;
  4749. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftR8, !cast<Pseudo>(NAME # _ZERO_B)>;
  4750. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1, nxv8i16, tvecshiftR16, !cast<Pseudo>(NAME # _ZERO_H)>;
  4751. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1, nxv4i32, tvecshiftR32, !cast<Pseudo>(NAME # _ZERO_S)>;
  4752. def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1, nxv2i64, tvecshiftR64, !cast<Pseudo>(NAME # _ZERO_D)>;
  4753. }
  4754. class sve_int_bin_pred_shift<bits<2> sz8_64, bit wide, bits<3> opc,
  4755. string asm, ZPRRegOp zprty, ZPRRegOp zprty2>
  4756. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty2:$Zm),
  4757. asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
  4758. "",
  4759. []>, Sched<[]> {
  4760. bits<3> Pg;
  4761. bits<5> Zdn;
  4762. bits<5> Zm;
  4763. let Inst{31-24} = 0b00000100;
  4764. let Inst{23-22} = sz8_64;
  4765. let Inst{21-20} = 0b01;
  4766. let Inst{19} = wide;
  4767. let Inst{18-16} = opc;
  4768. let Inst{15-13} = 0b100;
  4769. let Inst{12-10} = Pg;
  4770. let Inst{9-5} = Zm;
  4771. let Inst{4-0} = Zdn;
  4772. let Constraints = "$Zdn = $_Zdn";
  4773. let DestructiveInstType = DestructiveOther;
  4774. let ElementSize = zprty.ElementSize;
  4775. }
  4776. multiclass sve_int_bin_pred_shift<bits<3> opc, string asm, string Ps,
  4777. SDPatternOperator op, string revname, bit isReverseInstr = 0> {
  4778. let DestructiveInstType = DestructiveBinaryCommWithRev in {
  4779. def _B : sve_int_bin_pred_shift<0b00, 0b0, opc, asm, ZPR8, ZPR8>,
  4780. SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
  4781. def _H : sve_int_bin_pred_shift<0b01, 0b0, opc, asm, ZPR16, ZPR16>,
  4782. SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
  4783. def _S : sve_int_bin_pred_shift<0b10, 0b0, opc, asm, ZPR32, ZPR32>,
  4784. SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
  4785. def _D : sve_int_bin_pred_shift<0b11, 0b0, opc, asm, ZPR64, ZPR64>,
  4786. SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
  4787. }
  4788. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  4789. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  4790. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  4791. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  4792. }
  4793. multiclass sve_int_bin_pred_zeroing_bhsd<SDPatternOperator op> {
  4794. def _ZERO_B : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesZero>;
  4795. def _ZERO_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>;
  4796. def _ZERO_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>;
  4797. def _ZERO_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>;
  4798. def : SVE_3_Op_Pat_SelZero<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _ZERO_B)>;
  4799. def : SVE_3_Op_Pat_SelZero<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _ZERO_H)>;
  4800. def : SVE_3_Op_Pat_SelZero<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _ZERO_S)>;
  4801. def : SVE_3_Op_Pat_SelZero<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _ZERO_D)>;
  4802. }
  4803. multiclass sve_int_bin_pred_shift_wide<bits<3> opc, string asm,
  4804. SDPatternOperator op> {
  4805. def _B : sve_int_bin_pred_shift<0b00, 0b1, opc, asm, ZPR8, ZPR64>;
  4806. def _H : sve_int_bin_pred_shift<0b01, 0b1, opc, asm, ZPR16, ZPR64>;
  4807. def _S : sve_int_bin_pred_shift<0b10, 0b1, opc, asm, ZPR32, ZPR64>;
  4808. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
  4809. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
  4810. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
  4811. }
  4812. //===----------------------------------------------------------------------===//
  4813. // SVE Shift - Unpredicated Group
  4814. //===----------------------------------------------------------------------===//
  4815. class sve_int_bin_cons_shift_wide<bits<2> sz8_64, bits<2> opc, string asm,
  4816. ZPRRegOp zprty>
  4817. : I<(outs zprty:$Zd), (ins zprty:$Zn, ZPR64:$Zm),
  4818. asm, "\t$Zd, $Zn, $Zm",
  4819. "",
  4820. []>, Sched<[]> {
  4821. bits<5> Zd;
  4822. bits<5> Zm;
  4823. bits<5> Zn;
  4824. let Inst{31-24} = 0b00000100;
  4825. let Inst{23-22} = sz8_64;
  4826. let Inst{21} = 0b1;
  4827. let Inst{20-16} = Zm;
  4828. let Inst{15-12} = 0b1000;
  4829. let Inst{11-10} = opc;
  4830. let Inst{9-5} = Zn;
  4831. let Inst{4-0} = Zd;
  4832. }
  4833. multiclass sve_int_bin_cons_shift_wide<bits<2> opc, string asm, SDPatternOperator op> {
  4834. def _B : sve_int_bin_cons_shift_wide<0b00, opc, asm, ZPR8>;
  4835. def _H : sve_int_bin_cons_shift_wide<0b01, opc, asm, ZPR16>;
  4836. def _S : sve_int_bin_cons_shift_wide<0b10, opc, asm, ZPR32>;
  4837. def : SVE_2_Op_Pred_All_Active<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
  4838. def : SVE_2_Op_Pred_All_Active<nxv8i16, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
  4839. def : SVE_2_Op_Pred_All_Active<nxv4i32, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
  4840. }
  4841. class sve_int_bin_cons_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
  4842. ZPRRegOp zprty, Operand immtype>
  4843. : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$imm),
  4844. asm, "\t$Zd, $Zn, $imm",
  4845. "",
  4846. []>, Sched<[]> {
  4847. bits<5> Zd;
  4848. bits<5> Zn;
  4849. bits<6> imm;
  4850. let Inst{31-24} = 0b00000100;
  4851. let Inst{23-22} = tsz8_64{3-2};
  4852. let Inst{21} = 0b1;
  4853. let Inst{20-19} = tsz8_64{1-0};
  4854. let Inst{18-16} = imm{2-0}; // imm3
  4855. let Inst{15-12} = 0b1001;
  4856. let Inst{11-10} = opc;
  4857. let Inst{9-5} = Zn;
  4858. let Inst{4-0} = Zd;
  4859. }
  4860. multiclass sve_int_bin_cons_shift_imm_left<bits<2> opc, string asm,
  4861. SDPatternOperator op> {
  4862. def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
  4863. def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
  4864. let Inst{19} = imm{3};
  4865. }
  4866. def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
  4867. let Inst{20-19} = imm{4-3};
  4868. }
  4869. def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
  4870. let Inst{22} = imm{5};
  4871. let Inst{20-19} = imm{4-3};
  4872. }
  4873. def : SVE_Shift_DupImm_All_Active_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8, !cast<Instruction>(NAME # _B)>;
  4874. def : SVE_Shift_DupImm_All_Active_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>;
  4875. def : SVE_Shift_DupImm_All_Active_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>;
  4876. def : SVE_Shift_DupImm_All_Active_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>;
  4877. }
  4878. multiclass sve_int_bin_cons_shift_imm_right<bits<2> opc, string asm,
  4879. SDPatternOperator op> {
  4880. def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
  4881. def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
  4882. let Inst{19} = imm{3};
  4883. }
  4884. def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
  4885. let Inst{20-19} = imm{4-3};
  4886. }
  4887. def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
  4888. let Inst{22} = imm{5};
  4889. let Inst{20-19} = imm{4-3};
  4890. }
  4891. def : SVE_Shift_DupImm_All_Active_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8, !cast<Instruction>(NAME # _B)>;
  4892. def : SVE_Shift_DupImm_All_Active_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>;
  4893. def : SVE_Shift_DupImm_All_Active_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>;
  4894. def : SVE_Shift_DupImm_All_Active_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>;
  4895. }
  4896. //===----------------------------------------------------------------------===//
  4897. // SVE Memory - Store Group
  4898. //===----------------------------------------------------------------------===//
  4899. class sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
  4900. RegisterOperand VecList>
  4901. : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
  4902. asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
  4903. "",
  4904. []>, Sched<[]> {
  4905. bits<3> Pg;
  4906. bits<5> Rn;
  4907. bits<5> Zt;
  4908. bits<4> imm4;
  4909. let Inst{31-25} = 0b1110010;
  4910. let Inst{24-23} = msz;
  4911. let Inst{22-21} = esz;
  4912. let Inst{20} = 0;
  4913. let Inst{19-16} = imm4;
  4914. let Inst{15-13} = 0b111;
  4915. let Inst{12-10} = Pg;
  4916. let Inst{9-5} = Rn;
  4917. let Inst{4-0} = Zt;
  4918. let mayStore = 1;
  4919. }
  4920. multiclass sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
  4921. RegisterOperand listty, ZPRRegOp zprty>
  4922. {
  4923. def NAME : sve_mem_cst_si<msz, esz, asm, listty>;
  4924. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
  4925. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
  4926. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
  4927. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
  4928. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
  4929. (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  4930. }
  4931. class sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
  4932. string asm, Operand immtype>
  4933. : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
  4934. asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
  4935. "",
  4936. []>, Sched<[]> {
  4937. bits<3> Pg;
  4938. bits<5> Rn;
  4939. bits<5> Zt;
  4940. bits<4> imm4;
  4941. let Inst{31-25} = 0b1110010;
  4942. let Inst{24-23} = sz;
  4943. let Inst{22-21} = nregs;
  4944. let Inst{20} = 1;
  4945. let Inst{19-16} = imm4;
  4946. let Inst{15-13} = 0b111;
  4947. let Inst{12-10} = Pg;
  4948. let Inst{9-5} = Rn;
  4949. let Inst{4-0} = Zt;
  4950. let mayStore = 1;
  4951. }
  4952. multiclass sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
  4953. string asm, Operand immtype> {
  4954. def NAME : sve_mem_est_si<sz, nregs, VecList, asm, immtype>;
  4955. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
  4956. (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  4957. }
  4958. class sve_mem_est_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
  4959. string asm, RegisterOperand gprty>
  4960. : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  4961. asm, "\t$Zt, $Pg, [$Rn, $Rm]",
  4962. "",
  4963. []>, Sched<[]> {
  4964. bits<3> Pg;
  4965. bits<5> Rm;
  4966. bits<5> Rn;
  4967. bits<5> Zt;
  4968. let Inst{31-25} = 0b1110010;
  4969. let Inst{24-23} = sz;
  4970. let Inst{22-21} = nregs;
  4971. let Inst{20-16} = Rm;
  4972. let Inst{15-13} = 0b011;
  4973. let Inst{12-10} = Pg;
  4974. let Inst{9-5} = Rn;
  4975. let Inst{4-0} = Zt;
  4976. let mayStore = 1;
  4977. }
  4978. class sve_mem_cst_ss_base<bits<4> dtype, string asm,
  4979. RegisterOperand listty, RegisterOperand gprty>
  4980. : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  4981. asm, "\t$Zt, $Pg, [$Rn, $Rm]",
  4982. "",
  4983. []>, Sched<[]> {
  4984. bits<3> Pg;
  4985. bits<5> Rm;
  4986. bits<5> Rn;
  4987. bits<5> Zt;
  4988. let Inst{31-25} = 0b1110010;
  4989. let Inst{24-21} = dtype;
  4990. let Inst{20-16} = Rm;
  4991. let Inst{15-13} = 0b010;
  4992. let Inst{12-10} = Pg;
  4993. let Inst{9-5} = Rn;
  4994. let Inst{4-0} = Zt;
  4995. let mayStore = 1;
  4996. }
  4997. multiclass sve_mem_cst_ss<bits<4> dtype, string asm,
  4998. RegisterOperand listty, ZPRRegOp zprty,
  4999. RegisterOperand gprty> {
  5000. def NAME : sve_mem_cst_ss_base<dtype, asm, listty, gprty>;
  5001. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
  5002. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
  5003. }
  5004. class sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand VecList>
  5005. : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
  5006. asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
  5007. "",
  5008. []>, Sched<[]> {
  5009. bits<3> Pg;
  5010. bits<5> Rn;
  5011. bits<5> Zt;
  5012. bits<4> imm4;
  5013. let Inst{31-25} = 0b1110010;
  5014. let Inst{24-23} = msz;
  5015. let Inst{22-20} = 0b001;
  5016. let Inst{19-16} = imm4;
  5017. let Inst{15-13} = 0b111;
  5018. let Inst{12-10} = Pg;
  5019. let Inst{9-5} = Rn;
  5020. let Inst{4-0} = Zt;
  5021. let mayStore = 1;
  5022. }
  5023. multiclass sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand listty,
  5024. ZPRRegOp zprty> {
  5025. def NAME : sve_mem_cstnt_si<msz, asm, listty>;
  5026. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
  5027. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
  5028. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
  5029. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
  5030. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
  5031. (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  5032. }
  5033. class sve_mem_cstnt_ss_base<bits<2> msz, string asm, RegisterOperand listty,
  5034. RegisterOperand gprty>
  5035. : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  5036. asm, "\t$Zt, $Pg, [$Rn, $Rm]",
  5037. "",
  5038. []>, Sched<[]> {
  5039. bits<3> Pg;
  5040. bits<5> Rm;
  5041. bits<5> Rn;
  5042. bits<5> Zt;
  5043. let Inst{31-25} = 0b1110010;
  5044. let Inst{24-23} = msz;
  5045. let Inst{22-21} = 0b00;
  5046. let Inst{20-16} = Rm;
  5047. let Inst{15-13} = 0b011;
  5048. let Inst{12-10} = Pg;
  5049. let Inst{9-5} = Rn;
  5050. let Inst{4-0} = Zt;
  5051. let mayStore = 1;
  5052. }
  5053. multiclass sve_mem_cstnt_ss<bits<2> msz, string asm, RegisterOperand listty,
  5054. ZPRRegOp zprty, RegisterOperand gprty> {
  5055. def NAME : sve_mem_cstnt_ss_base<msz, asm, listty, gprty>;
  5056. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
  5057. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
  5058. }
  5059. class sve2_mem_sstnt_vs_base<bits<3> opc, string asm,
  5060. RegisterOperand listty, ZPRRegOp zprty>
  5061. : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm),
  5062. asm, "\t$Zt, $Pg, [$Zn, $Rm]",
  5063. "",
  5064. []>, Sched<[]> {
  5065. bits<3> Pg;
  5066. bits<5> Rm;
  5067. bits<5> Zn;
  5068. bits<5> Zt;
  5069. let Inst{31-25} = 0b1110010;
  5070. let Inst{24-22} = opc;
  5071. let Inst{21} = 0b0;
  5072. let Inst{20-16} = Rm;
  5073. let Inst{15-13} = 0b001;
  5074. let Inst{12-10} = Pg;
  5075. let Inst{9-5} = Zn;
  5076. let Inst{4-0} = Zt;
  5077. let mayStore = 1;
  5078. }
  5079. multiclass sve2_mem_sstnt_vs_32_ptrs<bits<3> opc, string asm,
  5080. SDPatternOperator op,
  5081. ValueType vt> {
  5082. def _REAL : sve2_mem_sstnt_vs_base<opc, asm, Z_s, ZPR32>;
  5083. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
  5084. (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>;
  5085. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5086. (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>;
  5087. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5088. (!cast<Instruction>(NAME # _REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>;
  5089. def : Pat <(op (nxv4i32 ZPR32:$Zt), (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zn), (i64 GPR64:$Rm), vt),
  5090. (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm)>;
  5091. }
  5092. multiclass sve2_mem_sstnt_vs_64_ptrs<bits<3> opc, string asm,
  5093. SDPatternOperator op,
  5094. ValueType vt> {
  5095. def _REAL : sve2_mem_sstnt_vs_base<opc, asm, Z_d, ZPR64>;
  5096. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
  5097. (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>;
  5098. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5099. (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>;
  5100. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5101. (!cast<Instruction>(NAME # _REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
  5102. def : Pat <(op (nxv2i64 ZPR64:$Zt), (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64:$Rm), vt),
  5103. (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
  5104. }
  5105. class sve_mem_sst_sv<bits<3> opc, bit xs, bit scaled, string asm,
  5106. RegisterOperand VecList, RegisterOperand zprext>
  5107. : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
  5108. asm, "\t$Zt, $Pg, [$Rn, $Zm]",
  5109. "",
  5110. []>, Sched<[]> {
  5111. bits<3> Pg;
  5112. bits<5> Rn;
  5113. bits<5> Zm;
  5114. bits<5> Zt;
  5115. let Inst{31-25} = 0b1110010;
  5116. let Inst{24-22} = opc;
  5117. let Inst{21} = scaled;
  5118. let Inst{20-16} = Zm;
  5119. let Inst{15} = 0b1;
  5120. let Inst{14} = xs;
  5121. let Inst{13} = 0;
  5122. let Inst{12-10} = Pg;
  5123. let Inst{9-5} = Rn;
  5124. let Inst{4-0} = Zt;
  5125. let mayStore = 1;
  5126. }
  5127. multiclass sve_mem_32b_sst_sv_32_scaled<bits<3> opc, string asm,
  5128. SDPatternOperator sxtw_op,
  5129. SDPatternOperator uxtw_op,
  5130. RegisterOperand sxtw_opnd,
  5131. RegisterOperand uxtw_opnd,
  5132. ValueType vt > {
  5133. def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_s, uxtw_opnd>;
  5134. def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_s, sxtw_opnd>;
  5135. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5136. (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  5137. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5138. (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  5139. def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
  5140. (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5141. def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
  5142. (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5143. }
  5144. multiclass sve_mem_64b_sst_sv_32_scaled<bits<3> opc, string asm,
  5145. SDPatternOperator sxtw_op,
  5146. SDPatternOperator uxtw_op,
  5147. RegisterOperand sxtw_opnd,
  5148. RegisterOperand uxtw_opnd,
  5149. ValueType vt > {
  5150. def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_d, uxtw_opnd>;
  5151. def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_d, sxtw_opnd>;
  5152. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5153. (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  5154. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5155. (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  5156. def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
  5157. (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5158. def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
  5159. (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5160. }
  5161. multiclass sve_mem_64b_sst_sv_32_unscaled<bits<3> opc, string asm,
  5162. SDPatternOperator sxtw_op,
  5163. SDPatternOperator uxtw_op,
  5164. RegisterOperand sxtw_opnd,
  5165. RegisterOperand uxtw_opnd,
  5166. ValueType vt> {
  5167. def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_d, uxtw_opnd>;
  5168. def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_d, sxtw_opnd>;
  5169. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5170. (!cast<Instruction>(NAME # _UXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  5171. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5172. (!cast<Instruction>(NAME # _SXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  5173. def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
  5174. (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5175. def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
  5176. (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5177. }
  5178. multiclass sve_mem_32b_sst_sv_32_unscaled<bits<3> opc, string asm,
  5179. SDPatternOperator sxtw_op,
  5180. SDPatternOperator uxtw_op,
  5181. RegisterOperand sxtw_opnd,
  5182. RegisterOperand uxtw_opnd,
  5183. ValueType vt> {
  5184. def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_s, uxtw_opnd>;
  5185. def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_s, sxtw_opnd>;
  5186. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5187. (!cast<Instruction>(NAME # _UXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  5188. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5189. (!cast<Instruction>(NAME # _SXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  5190. def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
  5191. (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5192. def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
  5193. (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5194. }
  5195. class sve_mem_sst_sv2<bits<2> msz, bit scaled, string asm,
  5196. RegisterOperand zprext>
  5197. : I<(outs), (ins Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
  5198. asm, "\t$Zt, $Pg, [$Rn, $Zm]",
  5199. "",
  5200. []>, Sched<[]> {
  5201. bits<3> Pg;
  5202. bits<5> Rn;
  5203. bits<5> Zm;
  5204. bits<5> Zt;
  5205. let Inst{31-25} = 0b1110010;
  5206. let Inst{24-23} = msz;
  5207. let Inst{22} = 0b0;
  5208. let Inst{21} = scaled;
  5209. let Inst{20-16} = Zm;
  5210. let Inst{15-13} = 0b101;
  5211. let Inst{12-10} = Pg;
  5212. let Inst{9-5} = Rn;
  5213. let Inst{4-0} = Zt;
  5214. let mayStore = 1;
  5215. }
  5216. multiclass sve_mem_sst_sv_64_scaled<bits<2> msz, string asm,
  5217. SDPatternOperator op,
  5218. RegisterOperand zprext,
  5219. ValueType vt> {
  5220. def _SCALED_REAL : sve_mem_sst_sv2<msz, 1, asm, zprext>;
  5221. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5222. (!cast<Instruction>(NAME # _SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
  5223. def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt),
  5224. (!cast<Instruction>(NAME # _SCALED_REAL) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
  5225. }
  5226. multiclass sve_mem_sst_sv_64_unscaled<bits<2> msz, string asm,
  5227. SDPatternOperator op,
  5228. ValueType vt> {
  5229. def _REAL : sve_mem_sst_sv2<msz, 0, asm, ZPR64ExtLSL8>;
  5230. def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
  5231. (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
  5232. def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
  5233. (!cast<Instruction>(NAME # _REAL) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  5234. }
  5235. class sve_mem_sst_vi<bits<3> opc, string asm, ZPRRegOp zprty,
  5236. RegisterOperand VecList, Operand imm_ty>
  5237. : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5),
  5238. asm, "\t$Zt, $Pg, [$Zn, $imm5]",
  5239. "",
  5240. []>, Sched<[]> {
  5241. bits<3> Pg;
  5242. bits<5> imm5;
  5243. bits<5> Zn;
  5244. bits<5> Zt;
  5245. let Inst{31-25} = 0b1110010;
  5246. let Inst{24-23} = opc{2-1};
  5247. let Inst{22} = 0b1;
  5248. let Inst{21} = opc{0};
  5249. let Inst{20-16} = imm5;
  5250. let Inst{15-13} = 0b101;
  5251. let Inst{12-10} = Pg;
  5252. let Inst{9-5} = Zn;
  5253. let Inst{4-0} = Zt;
  5254. let mayStore = 1;
  5255. }
  5256. multiclass sve_mem_32b_sst_vi_ptrs<bits<3> opc, string asm,
  5257. Operand imm_ty,
  5258. SDPatternOperator op,
  5259. ValueType vt> {
  5260. def _IMM : sve_mem_sst_vi<opc, asm, ZPR32, Z_s, imm_ty>;
  5261. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5262. (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
  5263. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
  5264. (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
  5265. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5266. (!cast<Instruction>(NAME # _IMM) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
  5267. def : Pat<(op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt),
  5268. (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
  5269. }
  5270. multiclass sve_mem_64b_sst_vi_ptrs<bits<3> opc, string asm,
  5271. Operand imm_ty,
  5272. SDPatternOperator op,
  5273. ValueType vt> {
  5274. def _IMM : sve_mem_sst_vi<opc, asm, ZPR64, Z_d, imm_ty>;
  5275. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5276. (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
  5277. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
  5278. (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
  5279. def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
  5280. (!cast<Instruction>(NAME # _IMM) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
  5281. def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt),
  5282. (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
  5283. }
  5284. class sve_mem_z_spill<string asm>
  5285. : I<(outs), (ins ZPRAny:$Zt, GPR64sp:$Rn, simm9:$imm9),
  5286. asm, "\t$Zt, [$Rn, $imm9, mul vl]",
  5287. "",
  5288. []>, Sched<[]> {
  5289. bits<5> Rn;
  5290. bits<5> Zt;
  5291. bits<9> imm9;
  5292. let Inst{31-22} = 0b1110010110;
  5293. let Inst{21-16} = imm9{8-3};
  5294. let Inst{15-13} = 0b010;
  5295. let Inst{12-10} = imm9{2-0};
  5296. let Inst{9-5} = Rn;
  5297. let Inst{4-0} = Zt;
  5298. let mayStore = 1;
  5299. }
  5300. multiclass sve_mem_z_spill<string asm> {
  5301. def NAME : sve_mem_z_spill<asm>;
  5302. def : InstAlias<asm # "\t$Zt, [$Rn]",
  5303. (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
  5304. }
  5305. class sve_mem_p_spill<string asm>
  5306. : I<(outs), (ins PPRAny:$Pt, GPR64sp:$Rn, simm9:$imm9),
  5307. asm, "\t$Pt, [$Rn, $imm9, mul vl]",
  5308. "",
  5309. []>, Sched<[]> {
  5310. bits<4> Pt;
  5311. bits<5> Rn;
  5312. bits<9> imm9;
  5313. let Inst{31-22} = 0b1110010110;
  5314. let Inst{21-16} = imm9{8-3};
  5315. let Inst{15-13} = 0b000;
  5316. let Inst{12-10} = imm9{2-0};
  5317. let Inst{9-5} = Rn;
  5318. let Inst{4} = 0b0;
  5319. let Inst{3-0} = Pt;
  5320. let mayStore = 1;
  5321. }
  5322. multiclass sve_mem_p_spill<string asm> {
  5323. def NAME : sve_mem_p_spill<asm>;
  5324. def : InstAlias<asm # "\t$Pt, [$Rn]",
  5325. (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>;
  5326. }
  5327. //===----------------------------------------------------------------------===//
  5328. // SVE Permute - Predicates Group
  5329. //===----------------------------------------------------------------------===//
  5330. class sve_int_perm_bin_perm_pp<bits<3> opc, bits<2> sz8_64, string asm,
  5331. PPRRegOp pprty>
  5332. : I<(outs pprty:$Pd), (ins pprty:$Pn, pprty:$Pm),
  5333. asm, "\t$Pd, $Pn, $Pm",
  5334. "", []>, Sched<[]> {
  5335. bits<4> Pd;
  5336. bits<4> Pm;
  5337. bits<4> Pn;
  5338. let Inst{31-24} = 0b00000101;
  5339. let Inst{23-22} = sz8_64;
  5340. let Inst{21-20} = 0b10;
  5341. let Inst{19-16} = Pm;
  5342. let Inst{15-13} = 0b010;
  5343. let Inst{12-10} = opc;
  5344. let Inst{9} = 0b0;
  5345. let Inst{8-5} = Pn;
  5346. let Inst{4} = 0b0;
  5347. let Inst{3-0} = Pd;
  5348. }
  5349. multiclass sve_int_perm_bin_perm_pp<bits<3> opc, string asm,
  5350. SDPatternOperator op> {
  5351. def _B : sve_int_perm_bin_perm_pp<opc, 0b00, asm, PPR8>;
  5352. def _H : sve_int_perm_bin_perm_pp<opc, 0b01, asm, PPR16>;
  5353. def _S : sve_int_perm_bin_perm_pp<opc, 0b10, asm, PPR32>;
  5354. def _D : sve_int_perm_bin_perm_pp<opc, 0b11, asm, PPR64>;
  5355. def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
  5356. def : SVE_2_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
  5357. def : SVE_2_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
  5358. def : SVE_2_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
  5359. }
  5360. class sve_int_perm_punpk<bit opc, string asm>
  5361. : I<(outs PPR16:$Pd), (ins PPR8:$Pn),
  5362. asm, "\t$Pd, $Pn",
  5363. "",
  5364. []>, Sched<[]> {
  5365. bits<4> Pd;
  5366. bits<4> Pn;
  5367. let Inst{31-17} = 0b000001010011000;
  5368. let Inst{16} = opc;
  5369. let Inst{15-9} = 0b0100000;
  5370. let Inst{8-5} = Pn;
  5371. let Inst{4} = 0b0;
  5372. let Inst{3-0} = Pd;
  5373. }
  5374. multiclass sve_int_perm_punpk<bit opc, string asm, SDPatternOperator op> {
  5375. def NAME : sve_int_perm_punpk<opc, asm>;
  5376. def : SVE_1_Op_Pat<nxv8i1, op, nxv16i1, !cast<Instruction>(NAME)>;
  5377. def : SVE_1_Op_Pat<nxv4i1, op, nxv8i1, !cast<Instruction>(NAME)>;
  5378. def : SVE_1_Op_Pat<nxv2i1, op, nxv4i1, !cast<Instruction>(NAME)>;
  5379. }
  5380. class sve_int_rdffr_pred<bit s, string asm>
  5381. : I<(outs PPR8:$Pd), (ins PPRAny:$Pg),
  5382. asm, "\t$Pd, $Pg/z",
  5383. "",
  5384. []>, Sched<[]> {
  5385. bits<4> Pd;
  5386. bits<4> Pg;
  5387. let Inst{31-23} = 0b001001010;
  5388. let Inst{22} = s;
  5389. let Inst{21-9} = 0b0110001111000;
  5390. let Inst{8-5} = Pg;
  5391. let Inst{4} = 0;
  5392. let Inst{3-0} = Pd;
  5393. let Defs = !if(s, [NZCV], []);
  5394. let Uses = [FFR];
  5395. }
  5396. multiclass sve_int_rdffr_pred<bit s, string asm, SDPatternOperator op> {
  5397. def _REAL : sve_int_rdffr_pred<s, asm>;
  5398. // We need a layer of indirection because early machine code passes balk at
  5399. // physical register (i.e. FFR) uses that have no previous definition.
  5400. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  5401. def "" : Pseudo<(outs PPR8:$Pd), (ins PPRAny:$Pg), [(set (nxv16i1 PPR8:$Pd), (op (nxv16i1 PPRAny:$Pg)))]>,
  5402. PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) PPR8:$Pd, PPRAny:$Pg)>;
  5403. }
  5404. }
  5405. class sve_int_rdffr_unpred<string asm> : I<
  5406. (outs PPR8:$Pd), (ins),
  5407. asm, "\t$Pd",
  5408. "",
  5409. []>, Sched<[]> {
  5410. bits<4> Pd;
  5411. let Inst{31-4} = 0b0010010100011001111100000000;
  5412. let Inst{3-0} = Pd;
  5413. let Uses = [FFR];
  5414. }
  5415. multiclass sve_int_rdffr_unpred<string asm, SDPatternOperator op> {
  5416. def _REAL : sve_int_rdffr_unpred<asm>;
  5417. // We need a layer of indirection because early machine code passes balk at
  5418. // physical register (i.e. FFR) uses that have no previous definition.
  5419. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  5420. def "" : Pseudo<(outs PPR8:$Pd), (ins), [(set (nxv16i1 PPR8:$Pd), (op))]>,
  5421. PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) PPR8:$Pd)>;
  5422. }
  5423. }
  5424. class sve_int_wrffr<string asm, SDPatternOperator op>
  5425. : I<(outs), (ins PPR8:$Pn),
  5426. asm, "\t$Pn",
  5427. "",
  5428. [(op (nxv16i1 PPR8:$Pn))]>, Sched<[]> {
  5429. bits<4> Pn;
  5430. let Inst{31-9} = 0b00100101001010001001000;
  5431. let Inst{8-5} = Pn;
  5432. let Inst{4-0} = 0b00000;
  5433. let hasSideEffects = 1;
  5434. let Defs = [FFR];
  5435. }
  5436. class sve_int_setffr<string asm, SDPatternOperator op>
  5437. : I<(outs), (ins),
  5438. asm, "",
  5439. "",
  5440. [(op)]>, Sched<[]> {
  5441. let Inst{31-0} = 0b00100101001011001001000000000000;
  5442. let hasSideEffects = 1;
  5443. let Defs = [FFR];
  5444. }
  5445. //===----------------------------------------------------------------------===//
  5446. // SVE Permute Vector - Predicated Group
  5447. //===----------------------------------------------------------------------===//
  5448. class sve_int_perm_clast_rz<bits<2> sz8_64, bit ab, string asm,
  5449. ZPRRegOp zprty, RegisterClass rt>
  5450. : I<(outs rt:$Rdn), (ins PPR3bAny:$Pg, rt:$_Rdn, zprty:$Zm),
  5451. asm, "\t$Rdn, $Pg, $_Rdn, $Zm",
  5452. "",
  5453. []>, Sched<[]> {
  5454. bits<3> Pg;
  5455. bits<5> Rdn;
  5456. bits<5> Zm;
  5457. let Inst{31-24} = 0b00000101;
  5458. let Inst{23-22} = sz8_64;
  5459. let Inst{21-17} = 0b11000;
  5460. let Inst{16} = ab;
  5461. let Inst{15-13} = 0b101;
  5462. let Inst{12-10} = Pg;
  5463. let Inst{9-5} = Zm;
  5464. let Inst{4-0} = Rdn;
  5465. let Constraints = "$Rdn = $_Rdn";
  5466. }
  5467. multiclass sve_int_perm_clast_rz<bit ab, string asm, SDPatternOperator op> {
  5468. def _B : sve_int_perm_clast_rz<0b00, ab, asm, ZPR8, GPR32>;
  5469. def _H : sve_int_perm_clast_rz<0b01, ab, asm, ZPR16, GPR32>;
  5470. def _S : sve_int_perm_clast_rz<0b10, ab, asm, ZPR32, GPR32>;
  5471. def _D : sve_int_perm_clast_rz<0b11, ab, asm, ZPR64, GPR64>;
  5472. def : SVE_3_Op_Pat<i32, op, nxv16i1, i32, nxv16i8, !cast<Instruction>(NAME # _B)>;
  5473. def : SVE_3_Op_Pat<i32, op, nxv8i1, i32, nxv8i16, !cast<Instruction>(NAME # _H)>;
  5474. def : SVE_3_Op_Pat<i32, op, nxv4i1, i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5475. def : SVE_3_Op_Pat<i64, op, nxv2i1, i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5476. }
  5477. class sve_int_perm_clast_vz<bits<2> sz8_64, bit ab, string asm,
  5478. ZPRRegOp zprty, RegisterClass rt>
  5479. : I<(outs rt:$Vdn), (ins PPR3bAny:$Pg, rt:$_Vdn, zprty:$Zm),
  5480. asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
  5481. "",
  5482. []>, Sched<[]> {
  5483. bits<3> Pg;
  5484. bits<5> Vdn;
  5485. bits<5> Zm;
  5486. let Inst{31-24} = 0b00000101;
  5487. let Inst{23-22} = sz8_64;
  5488. let Inst{21-17} = 0b10101;
  5489. let Inst{16} = ab;
  5490. let Inst{15-13} = 0b100;
  5491. let Inst{12-10} = Pg;
  5492. let Inst{9-5} = Zm;
  5493. let Inst{4-0} = Vdn;
  5494. let Constraints = "$Vdn = $_Vdn";
  5495. }
  5496. multiclass sve_int_perm_clast_vz<bit ab, string asm, SDPatternOperator op> {
  5497. def _B : sve_int_perm_clast_vz<0b00, ab, asm, ZPR8, FPR8>;
  5498. def _H : sve_int_perm_clast_vz<0b01, ab, asm, ZPR16, FPR16>;
  5499. def _S : sve_int_perm_clast_vz<0b10, ab, asm, ZPR32, FPR32>;
  5500. def _D : sve_int_perm_clast_vz<0b11, ab, asm, ZPR64, FPR64>;
  5501. def : SVE_3_Op_Pat<f16, op, nxv8i1, f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  5502. def : SVE_3_Op_Pat<f32, op, nxv4i1, f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  5503. def : SVE_3_Op_Pat<f64, op, nxv2i1, f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  5504. def : SVE_3_Op_Pat<bf16, op, nxv8i1, bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
  5505. }
  5506. class sve_int_perm_clast_zz<bits<2> sz8_64, bit ab, string asm,
  5507. ZPRRegOp zprty>
  5508. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
  5509. asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
  5510. "",
  5511. []>, Sched<[]> {
  5512. bits<3> Pg;
  5513. bits<5> Zdn;
  5514. bits<5> Zm;
  5515. let Inst{31-24} = 0b00000101;
  5516. let Inst{23-22} = sz8_64;
  5517. let Inst{21-17} = 0b10100;
  5518. let Inst{16} = ab;
  5519. let Inst{15-13} = 0b100;
  5520. let Inst{12-10} = Pg;
  5521. let Inst{9-5} = Zm;
  5522. let Inst{4-0} = Zdn;
  5523. let Constraints = "$Zdn = $_Zdn";
  5524. let DestructiveInstType = DestructiveOther;
  5525. let ElementSize = ElementSizeNone;
  5526. }
  5527. multiclass sve_int_perm_clast_zz<bit ab, string asm, SDPatternOperator op> {
  5528. def _B : sve_int_perm_clast_zz<0b00, ab, asm, ZPR8>;
  5529. def _H : sve_int_perm_clast_zz<0b01, ab, asm, ZPR16>;
  5530. def _S : sve_int_perm_clast_zz<0b10, ab, asm, ZPR32>;
  5531. def _D : sve_int_perm_clast_zz<0b11, ab, asm, ZPR64>;
  5532. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  5533. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  5534. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5535. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5536. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  5537. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  5538. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  5539. def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
  5540. }
  5541. class sve_int_perm_last_r<bits<2> sz8_64, bit ab, string asm,
  5542. ZPRRegOp zprty, RegisterClass resultRegType>
  5543. : I<(outs resultRegType:$Rd), (ins PPR3bAny:$Pg, zprty:$Zn),
  5544. asm, "\t$Rd, $Pg, $Zn",
  5545. "",
  5546. []>, Sched<[]> {
  5547. bits<3> Pg;
  5548. bits<5> Rd;
  5549. bits<5> Zn;
  5550. let Inst{31-24} = 0b00000101;
  5551. let Inst{23-22} = sz8_64;
  5552. let Inst{21-17} = 0b10000;
  5553. let Inst{16} = ab;
  5554. let Inst{15-13} = 0b101;
  5555. let Inst{12-10} = Pg;
  5556. let Inst{9-5} = Zn;
  5557. let Inst{4-0} = Rd;
  5558. }
  5559. multiclass sve_int_perm_last_r<bit ab, string asm, SDPatternOperator op> {
  5560. def _B : sve_int_perm_last_r<0b00, ab, asm, ZPR8, GPR32>;
  5561. def _H : sve_int_perm_last_r<0b01, ab, asm, ZPR16, GPR32>;
  5562. def _S : sve_int_perm_last_r<0b10, ab, asm, ZPR32, GPR32>;
  5563. def _D : sve_int_perm_last_r<0b11, ab, asm, ZPR64, GPR64>;
  5564. def : SVE_2_Op_Pat<i32, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  5565. def : SVE_2_Op_Pat<i32, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  5566. def : SVE_2_Op_Pat<i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5567. def : SVE_2_Op_Pat<i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5568. }
  5569. class sve_int_perm_last_v<bits<2> sz8_64, bit ab, string asm,
  5570. ZPRRegOp zprty, RegisterClass dstRegtype>
  5571. : I<(outs dstRegtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
  5572. asm, "\t$Vd, $Pg, $Zn",
  5573. "",
  5574. []>, Sched<[]> {
  5575. bits<3> Pg;
  5576. bits<5> Vd;
  5577. bits<5> Zn;
  5578. let Inst{31-24} = 0b00000101;
  5579. let Inst{23-22} = sz8_64;
  5580. let Inst{21-17} = 0b10001;
  5581. let Inst{16} = ab;
  5582. let Inst{15-13} = 0b100;
  5583. let Inst{12-10} = Pg;
  5584. let Inst{9-5} = Zn;
  5585. let Inst{4-0} = Vd;
  5586. }
  5587. multiclass sve_int_perm_last_v<bit ab, string asm, SDPatternOperator op> {
  5588. def _B : sve_int_perm_last_v<0b00, ab, asm, ZPR8, FPR8>;
  5589. def _H : sve_int_perm_last_v<0b01, ab, asm, ZPR16, FPR16>;
  5590. def _S : sve_int_perm_last_v<0b10, ab, asm, ZPR32, FPR32>;
  5591. def _D : sve_int_perm_last_v<0b11, ab, asm, ZPR64, FPR64>;
  5592. def : SVE_2_Op_Pat<f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
  5593. def : SVE_2_Op_Pat<f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  5594. def : SVE_2_Op_Pat<f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
  5595. def : SVE_2_Op_Pat<f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  5596. def : SVE_2_Op_Pat<bf16, op, nxv8i1, nxv8bf16, !cast<Instruction>(NAME # _H)>;
  5597. }
  5598. class sve_int_perm_splice<bits<2> sz8_64, string asm, ZPRRegOp zprty>
  5599. : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
  5600. asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
  5601. "",
  5602. []>, Sched<[]> {
  5603. bits<3> Pg;
  5604. bits<5> Zdn;
  5605. bits<5> Zm;
  5606. let Inst{31-24} = 0b00000101;
  5607. let Inst{23-22} = sz8_64;
  5608. let Inst{21-13} = 0b101100100;
  5609. let Inst{12-10} = Pg;
  5610. let Inst{9-5} = Zm;
  5611. let Inst{4-0} = Zdn;
  5612. let Constraints = "$Zdn = $_Zdn";
  5613. let DestructiveInstType = DestructiveOther;
  5614. let ElementSize = ElementSizeNone;
  5615. }
  5616. multiclass sve_int_perm_splice<string asm, SDPatternOperator op> {
  5617. def _B : sve_int_perm_splice<0b00, asm, ZPR8>;
  5618. def _H : sve_int_perm_splice<0b01, asm, ZPR16>;
  5619. def _S : sve_int_perm_splice<0b10, asm, ZPR32>;
  5620. def _D : sve_int_perm_splice<0b11, asm, ZPR64>;
  5621. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  5622. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  5623. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5624. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5625. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
  5626. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
  5627. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
  5628. def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
  5629. }
  5630. class sve2_int_perm_splice_cons<bits<2> sz8_64, string asm,
  5631. ZPRRegOp zprty, RegisterOperand VecList>
  5632. : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, VecList:$Zn),
  5633. asm, "\t$Zd, $Pg, $Zn",
  5634. "",
  5635. []>, Sched<[]> {
  5636. bits<3> Pg;
  5637. bits<5> Zn;
  5638. bits<5> Zd;
  5639. let Inst{31-24} = 0b00000101;
  5640. let Inst{23-22} = sz8_64;
  5641. let Inst{21-13} = 0b101101100;
  5642. let Inst{12-10} = Pg;
  5643. let Inst{9-5} = Zn;
  5644. let Inst{4-0} = Zd;
  5645. }
  5646. multiclass sve2_int_perm_splice_cons<string asm> {
  5647. def _B : sve2_int_perm_splice_cons<0b00, asm, ZPR8, ZZ_b>;
  5648. def _H : sve2_int_perm_splice_cons<0b01, asm, ZPR16, ZZ_h>;
  5649. def _S : sve2_int_perm_splice_cons<0b10, asm, ZPR32, ZZ_s>;
  5650. def _D : sve2_int_perm_splice_cons<0b11, asm, ZPR64, ZZ_d>;
  5651. }
  5652. class sve_int_perm_rev<bits<2> sz8_64, bits<2> opc, string asm,
  5653. ZPRRegOp zprty>
  5654. : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
  5655. asm, "\t$Zd, $Pg/m, $Zn",
  5656. "",
  5657. []>, Sched<[]> {
  5658. bits<5> Zd;
  5659. bits<3> Pg;
  5660. bits<5> Zn;
  5661. let Inst{31-24} = 0b00000101;
  5662. let Inst{23-22} = sz8_64;
  5663. let Inst{21-18} = 0b1001;
  5664. let Inst{17-16} = opc;
  5665. let Inst{15-13} = 0b100;
  5666. let Inst{12-10} = Pg;
  5667. let Inst{9-5} = Zn;
  5668. let Inst{4-0} = Zd;
  5669. let Constraints = "$Zd = $_Zd";
  5670. let DestructiveInstType = DestructiveOther;
  5671. let ElementSize = zprty.ElementSize;
  5672. }
  5673. multiclass sve_int_perm_rev_rbit<string asm, SDPatternOperator op> {
  5674. def _B : sve_int_perm_rev<0b00, 0b11, asm, ZPR8>;
  5675. def _H : sve_int_perm_rev<0b01, 0b11, asm, ZPR16>;
  5676. def _S : sve_int_perm_rev<0b10, 0b11, asm, ZPR32>;
  5677. def _D : sve_int_perm_rev<0b11, 0b11, asm, ZPR64>;
  5678. def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  5679. def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  5680. def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5681. def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5682. }
  5683. multiclass sve_int_perm_rev_revb<string asm, SDPatternOperator op> {
  5684. def _H : sve_int_perm_rev<0b01, 0b00, asm, ZPR16>;
  5685. def _S : sve_int_perm_rev<0b10, 0b00, asm, ZPR32>;
  5686. def _D : sve_int_perm_rev<0b11, 0b00, asm, ZPR64>;
  5687. def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  5688. def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5689. def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5690. }
  5691. multiclass sve_int_perm_rev_revh<string asm, SDPatternOperator op> {
  5692. def _S : sve_int_perm_rev<0b10, 0b01, asm, ZPR32>;
  5693. def _D : sve_int_perm_rev<0b11, 0b01, asm, ZPR64>;
  5694. def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5695. def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5696. }
  5697. multiclass sve_int_perm_rev_revw<string asm, SDPatternOperator op> {
  5698. def _D : sve_int_perm_rev<0b11, 0b10, asm, ZPR64>;
  5699. def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5700. }
  5701. class sve_int_perm_cpy_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  5702. RegisterClass srcRegType>
  5703. : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegType:$Rn),
  5704. asm, "\t$Zd, $Pg/m, $Rn",
  5705. "",
  5706. []>, Sched<[]> {
  5707. bits<3> Pg;
  5708. bits<5> Rn;
  5709. bits<5> Zd;
  5710. let Inst{31-24} = 0b00000101;
  5711. let Inst{23-22} = sz8_64;
  5712. let Inst{21-13} = 0b101000101;
  5713. let Inst{12-10} = Pg;
  5714. let Inst{9-5} = Rn;
  5715. let Inst{4-0} = Zd;
  5716. let Constraints = "$Zd = $_Zd";
  5717. let DestructiveInstType = DestructiveOther;
  5718. let ElementSize = zprty.ElementSize;
  5719. }
  5720. multiclass sve_int_perm_cpy_r<string asm, SDPatternOperator op> {
  5721. def _B : sve_int_perm_cpy_r<0b00, asm, ZPR8, GPR32sp>;
  5722. def _H : sve_int_perm_cpy_r<0b01, asm, ZPR16, GPR32sp>;
  5723. def _S : sve_int_perm_cpy_r<0b10, asm, ZPR32, GPR32sp>;
  5724. def _D : sve_int_perm_cpy_r<0b11, asm, ZPR64, GPR64sp>;
  5725. def : InstAlias<"mov $Zd, $Pg/m, $Rn",
  5726. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
  5727. def : InstAlias<"mov $Zd, $Pg/m, $Rn",
  5728. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
  5729. def : InstAlias<"mov $Zd, $Pg/m, $Rn",
  5730. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
  5731. def : InstAlias<"mov $Zd, $Pg/m, $Rn",
  5732. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, GPR64sp:$Rn), 1>;
  5733. def : Pat<(nxv16i8 (op nxv16i1:$pg, i32:$splat, nxv16i8:$passthru)),
  5734. (!cast<Instruction>(NAME # _B) $passthru, $pg, $splat)>;
  5735. def : Pat<(nxv8i16 (op nxv8i1:$pg, i32:$splat, nxv8i16:$passthru)),
  5736. (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
  5737. def : Pat<(nxv4i32 (op nxv4i1:$pg, i32:$splat, nxv4i32:$passthru)),
  5738. (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
  5739. def : Pat<(nxv2i64 (op nxv2i1:$pg, i64:$splat, nxv2i64:$passthru)),
  5740. (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>;
  5741. }
  5742. class sve_int_perm_cpy_v<bits<2> sz8_64, string asm, ZPRRegOp zprty,
  5743. RegisterClass srcRegtype>
  5744. : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegtype:$Vn),
  5745. asm, "\t$Zd, $Pg/m, $Vn",
  5746. "",
  5747. []>, Sched<[]> {
  5748. bits<3> Pg;
  5749. bits<5> Vn;
  5750. bits<5> Zd;
  5751. let Inst{31-24} = 0b00000101;
  5752. let Inst{23-22} = sz8_64;
  5753. let Inst{21-13} = 0b100000100;
  5754. let Inst{12-10} = Pg;
  5755. let Inst{9-5} = Vn;
  5756. let Inst{4-0} = Zd;
  5757. let Constraints = "$Zd = $_Zd";
  5758. let DestructiveInstType = DestructiveOther;
  5759. let ElementSize = zprty.ElementSize;
  5760. }
  5761. multiclass sve_int_perm_cpy_v<string asm, SDPatternOperator op> {
  5762. def _B : sve_int_perm_cpy_v<0b00, asm, ZPR8, FPR8>;
  5763. def _H : sve_int_perm_cpy_v<0b01, asm, ZPR16, FPR16>;
  5764. def _S : sve_int_perm_cpy_v<0b10, asm, ZPR32, FPR32>;
  5765. def _D : sve_int_perm_cpy_v<0b11, asm, ZPR64, FPR64>;
  5766. def : InstAlias<"mov $Zd, $Pg/m, $Vn",
  5767. (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, FPR8:$Vn), 1>;
  5768. def : InstAlias<"mov $Zd, $Pg/m, $Vn",
  5769. (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, FPR16:$Vn), 1>;
  5770. def : InstAlias<"mov $Zd, $Pg/m, $Vn",
  5771. (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, FPR32:$Vn), 1>;
  5772. def : InstAlias<"mov $Zd, $Pg/m, $Vn",
  5773. (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, FPR64:$Vn), 1>;
  5774. def : Pat<(nxv8f16 (op nxv8i1:$pg, f16:$splat, nxv8f16:$passthru)),
  5775. (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
  5776. def : Pat<(nxv2f32 (op nxv2i1:$pg, f32:$splat, nxv2f32:$passthru)),
  5777. (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
  5778. def : Pat<(nxv4f32 (op nxv4i1:$pg, f32:$splat, nxv4f32:$passthru)),
  5779. (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
  5780. def : Pat<(nxv2f64 (op nxv2i1:$pg, f64:$splat, nxv2f64:$passthru)),
  5781. (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>;
  5782. def : Pat<(nxv8bf16 (op nxv8i1:$pg, bf16:$splat, nxv8bf16:$passthru)),
  5783. (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
  5784. }
  5785. class sve_int_perm_compact<bit sz, string asm, ZPRRegOp zprty>
  5786. : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
  5787. asm, "\t$Zd, $Pg, $Zn",
  5788. "",
  5789. []>, Sched<[]> {
  5790. bits<3> Pg;
  5791. bits<5> Zd;
  5792. bits<5> Zn;
  5793. let Inst{31-23} = 0b000001011;
  5794. let Inst{22} = sz;
  5795. let Inst{21-13} = 0b100001100;
  5796. let Inst{12-10} = Pg;
  5797. let Inst{9-5} = Zn;
  5798. let Inst{4-0} = Zd;
  5799. }
  5800. multiclass sve_int_perm_compact<string asm, SDPatternOperator op> {
  5801. def _S : sve_int_perm_compact<0b0, asm, ZPR32>;
  5802. def _D : sve_int_perm_compact<0b1, asm, ZPR64>;
  5803. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  5804. def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
  5805. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  5806. def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
  5807. }
  5808. //===----------------------------------------------------------------------===//
  5809. // SVE Memory - Contiguous Load Group
  5810. //===----------------------------------------------------------------------===//
  5811. class sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
  5812. RegisterOperand VecList>
  5813. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
  5814. asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
  5815. "",
  5816. []>, Sched<[]> {
  5817. bits<3> Pg;
  5818. bits<5> Rn;
  5819. bits<5> Zt;
  5820. bits<4> imm4;
  5821. let Inst{31-25} = 0b1010010;
  5822. let Inst{24-21} = dtype;
  5823. let Inst{20} = nf;
  5824. let Inst{19-16} = imm4;
  5825. let Inst{15-13} = 0b101;
  5826. let Inst{12-10} = Pg;
  5827. let Inst{9-5} = Rn;
  5828. let Inst{4-0} = Zt;
  5829. let mayLoad = 1;
  5830. let Uses = !if(nf, [FFR], []);
  5831. let Defs = !if(nf, [FFR], []);
  5832. }
  5833. multiclass sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
  5834. RegisterOperand listty, ZPRRegOp zprty> {
  5835. def _REAL : sve_mem_cld_si_base<dtype, nf, asm, listty>;
  5836. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5837. (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
  5838. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
  5839. (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
  5840. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5841. (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  5842. // We need a layer of indirection because early machine code passes balk at
  5843. // physical register (i.e. FFR) uses that have no previous definition.
  5844. let hasSideEffects = 1, hasNoSchedulingInfo = 1, mayLoad = 1 in {
  5845. def "" : Pseudo<(outs listty:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), []>,
  5846. PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4)>;
  5847. }
  5848. }
  5849. multiclass sve_mem_cld_si<bits<4> dtype, string asm, RegisterOperand listty,
  5850. ZPRRegOp zprty>
  5851. : sve_mem_cld_si_base<dtype, 0, asm, listty, zprty>;
  5852. class sve_mem_cldnt_si_base<bits<2> msz, string asm, RegisterOperand VecList>
  5853. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
  5854. asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
  5855. "",
  5856. []>, Sched<[]> {
  5857. bits<5> Zt;
  5858. bits<3> Pg;
  5859. bits<5> Rn;
  5860. bits<4> imm4;
  5861. let Inst{31-25} = 0b1010010;
  5862. let Inst{24-23} = msz;
  5863. let Inst{22-20} = 0b000;
  5864. let Inst{19-16} = imm4;
  5865. let Inst{15-13} = 0b111;
  5866. let Inst{12-10} = Pg;
  5867. let Inst{9-5} = Rn;
  5868. let Inst{4-0} = Zt;
  5869. let mayLoad = 1;
  5870. }
  5871. multiclass sve_mem_cldnt_si<bits<2> msz, string asm, RegisterOperand listty,
  5872. ZPRRegOp zprty> {
  5873. def NAME : sve_mem_cldnt_si_base<msz, asm, listty>;
  5874. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5875. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
  5876. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
  5877. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
  5878. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5879. (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  5880. }
  5881. class sve_mem_cldnt_ss_base<bits<2> msz, string asm, RegisterOperand VecList,
  5882. RegisterOperand gprty>
  5883. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  5884. asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
  5885. "",
  5886. []>, Sched<[]> {
  5887. bits<3> Pg;
  5888. bits<5> Rm;
  5889. bits<5> Rn;
  5890. bits<5> Zt;
  5891. let Inst{31-25} = 0b1010010;
  5892. let Inst{24-23} = msz;
  5893. let Inst{22-21} = 0b00;
  5894. let Inst{20-16} = Rm;
  5895. let Inst{15-13} = 0b110;
  5896. let Inst{12-10} = Pg;
  5897. let Inst{9-5} = Rn;
  5898. let Inst{4-0} = Zt;
  5899. let mayLoad = 1;
  5900. }
  5901. multiclass sve_mem_cldnt_ss<bits<2> msz, string asm, RegisterOperand listty,
  5902. ZPRRegOp zprty, RegisterOperand gprty> {
  5903. def NAME : sve_mem_cldnt_ss_base<msz, asm, listty, gprty>;
  5904. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
  5905. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
  5906. }
  5907. class sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand VecList>
  5908. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4),
  5909. asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
  5910. bits<5> Zt;
  5911. bits<5> Rn;
  5912. bits<3> Pg;
  5913. bits<4> imm4;
  5914. let Inst{31-25} = 0b1010010;
  5915. let Inst{24-23} = sz;
  5916. let Inst{22-20} = 0;
  5917. let Inst{19-16} = imm4;
  5918. let Inst{15-13} = 0b001;
  5919. let Inst{12-10} = Pg;
  5920. let Inst{9-5} = Rn;
  5921. let Inst{4-0} = Zt;
  5922. let mayLoad = 1;
  5923. }
  5924. multiclass sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand listty,
  5925. ZPRRegOp zprty> {
  5926. def NAME : sve_mem_ldqr_si<sz, asm, listty>;
  5927. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5928. (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  5929. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5930. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
  5931. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
  5932. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4), 0>;
  5933. }
  5934. class sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand VecList,
  5935. RegisterOperand gprty>
  5936. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  5937. asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
  5938. bits<5> Zt;
  5939. bits<3> Pg;
  5940. bits<5> Rn;
  5941. bits<5> Rm;
  5942. let Inst{31-25} = 0b1010010;
  5943. let Inst{24-23} = sz;
  5944. let Inst{22-21} = 0;
  5945. let Inst{20-16} = Rm;
  5946. let Inst{15-13} = 0;
  5947. let Inst{12-10} = Pg;
  5948. let Inst{9-5} = Rn;
  5949. let Inst{4-0} = Zt;
  5950. let mayLoad = 1;
  5951. }
  5952. multiclass sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand listty,
  5953. ZPRRegOp zprty, RegisterOperand gprty> {
  5954. def NAME : sve_mem_ldqr_ss<sz, asm, listty, gprty>;
  5955. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
  5956. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
  5957. }
  5958. class sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
  5959. RegisterOperand VecList, Operand immtype>
  5960. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6),
  5961. asm, "\t$Zt, $Pg/z, [$Rn, $imm6]",
  5962. "",
  5963. []>, Sched<[]> {
  5964. bits<3> Pg;
  5965. bits<5> Rn;
  5966. bits<5> Zt;
  5967. bits<6> imm6;
  5968. let Inst{31-25} = 0b1000010;
  5969. let Inst{24-23} = dtypeh;
  5970. let Inst{22} = 1;
  5971. let Inst{21-16} = imm6;
  5972. let Inst{15} = 0b1;
  5973. let Inst{14-13} = dtypel;
  5974. let Inst{12-10} = Pg;
  5975. let Inst{9-5} = Rn;
  5976. let Inst{4-0} = Zt;
  5977. let mayLoad = 1;
  5978. }
  5979. multiclass sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
  5980. RegisterOperand zlistty, ZPRRegOp zprty, Operand immtype> {
  5981. def NAME : sve_mem_ld_dup<dtypeh, dtypel, asm, zlistty, immtype>;
  5982. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5983. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
  5984. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm6]",
  5985. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6), 0>;
  5986. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  5987. (!cast<Instruction>(NAME) zlistty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  5988. }
  5989. class sve_mem_cld_ss_base<bits<4> dtype, bit ff, dag iops, string asm,
  5990. RegisterOperand VecList>
  5991. : I<(outs VecList:$Zt), iops,
  5992. asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
  5993. "",
  5994. []>, Sched<[]> {
  5995. bits<5> Zt;
  5996. bits<3> Pg;
  5997. bits<5> Rm;
  5998. bits<5> Rn;
  5999. let Inst{31-25} = 0b1010010;
  6000. let Inst{24-21} = dtype;
  6001. let Inst{20-16} = Rm;
  6002. let Inst{15-14} = 0b01;
  6003. let Inst{13} = ff;
  6004. let Inst{12-10} = Pg;
  6005. let Inst{9-5} = Rn;
  6006. let Inst{4-0} = Zt;
  6007. let mayLoad = 1;
  6008. let Uses = !if(ff, [FFR], []);
  6009. let Defs = !if(ff, [FFR], []);
  6010. }
  6011. multiclass sve_mem_cld_ss<bits<4> dtype, string asm, RegisterOperand listty,
  6012. ZPRRegOp zprty, RegisterOperand gprty> {
  6013. def "" : sve_mem_cld_ss_base<dtype, 0, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  6014. asm, listty>;
  6015. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
  6016. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
  6017. }
  6018. multiclass sve_mem_cldff_ss<bits<4> dtype, string asm, RegisterOperand listty,
  6019. ZPRRegOp zprty, RegisterOperand gprty> {
  6020. def _REAL : sve_mem_cld_ss_base<dtype, 1, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  6021. asm, listty>;
  6022. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
  6023. (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
  6024. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  6025. (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 1>;
  6026. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  6027. (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 0>;
  6028. // We need a layer of indirection because early machine code passes balk at
  6029. // physical register (i.e. FFR) uses that have no previous definition.
  6030. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6031. def "" : Pseudo<(outs listty:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), []>,
  6032. PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm)>;
  6033. }
  6034. }
  6035. multiclass sve_mem_cldnf_si<bits<4> dtype, string asm, RegisterOperand listty,
  6036. ZPRRegOp zprty>
  6037. : sve_mem_cld_si_base<dtype, 1, asm, listty, zprty>;
  6038. class sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
  6039. string asm, Operand immtype>
  6040. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
  6041. asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
  6042. "",
  6043. []>, Sched<[]> {
  6044. bits<5> Zt;
  6045. bits<3> Pg;
  6046. bits<5> Rn;
  6047. bits<4> imm4;
  6048. let Inst{31-25} = 0b1010010;
  6049. let Inst{24-23} = sz;
  6050. let Inst{22-21} = nregs;
  6051. let Inst{20} = 0;
  6052. let Inst{19-16} = imm4;
  6053. let Inst{15-13} = 0b111;
  6054. let Inst{12-10} = Pg;
  6055. let Inst{9-5} = Rn;
  6056. let Inst{4-0} = Zt;
  6057. let mayLoad = 1;
  6058. }
  6059. multiclass sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
  6060. string asm, Operand immtype> {
  6061. def NAME : sve_mem_eld_si<sz, nregs, VecList, asm, immtype>;
  6062. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  6063. (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  6064. }
  6065. class sve_mem_eld_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
  6066. string asm, RegisterOperand gprty>
  6067. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  6068. asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
  6069. "",
  6070. []>, Sched<[]> {
  6071. bits<3> Pg;
  6072. bits<5> Rm;
  6073. bits<5> Rn;
  6074. bits<5> Zt;
  6075. let Inst{31-25} = 0b1010010;
  6076. let Inst{24-23} = sz;
  6077. let Inst{22-21} = nregs;
  6078. let Inst{20-16} = Rm;
  6079. let Inst{15-13} = 0b110;
  6080. let Inst{12-10} = Pg;
  6081. let Inst{9-5} = Rn;
  6082. let Inst{4-0} = Zt;
  6083. let mayLoad = 1;
  6084. }
  6085. //===----------------------------------------------------------------------===//
  6086. // SVE Memory - 32-bit Gather and Unsized Contiguous Group
  6087. //===----------------------------------------------------------------------===//
  6088. // bit xs is '1' if offsets are signed
  6089. // bit scaled is '1' if the offsets are scaled
  6090. class sve_mem_32b_gld_sv<bits<4> opc, bit xs, bit scaled, string asm,
  6091. RegisterOperand zprext>
  6092. : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
  6093. asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6094. "",
  6095. []>, Sched<[]> {
  6096. bits<3> Pg;
  6097. bits<5> Rn;
  6098. bits<5> Zm;
  6099. bits<5> Zt;
  6100. let Inst{31-25} = 0b1000010;
  6101. let Inst{24-23} = opc{3-2};
  6102. let Inst{22} = xs;
  6103. let Inst{21} = scaled;
  6104. let Inst{20-16} = Zm;
  6105. let Inst{15} = 0b0;
  6106. let Inst{14-13} = opc{1-0};
  6107. let Inst{12-10} = Pg;
  6108. let Inst{9-5} = Rn;
  6109. let Inst{4-0} = Zt;
  6110. let mayLoad = 1;
  6111. let Defs = !if(!eq(opc{0}, 1), [FFR], []);
  6112. let Uses = !if(!eq(opc{0}, 1), [FFR], []);
  6113. }
  6114. multiclass sve_mem_32b_gld_sv_32_scaled<bits<4> opc, string asm,
  6115. SDPatternOperator sxtw_op,
  6116. SDPatternOperator uxtw_op,
  6117. RegisterOperand sxtw_opnd,
  6118. RegisterOperand uxtw_opnd,
  6119. ValueType vt> {
  6120. def _UXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 0, 1, asm, uxtw_opnd>;
  6121. def _SXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 1, 1, asm, sxtw_opnd>;
  6122. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6123. (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  6124. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6125. (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  6126. // We need a layer of indirection because early machine code passes balk at
  6127. // physical register (i.e. FFR) uses that have no previous definition.
  6128. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6129. def _UXTW_SCALED : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>,
  6130. PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_SCALED_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
  6131. def _SXTW_SCALED : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>,
  6132. PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_SCALED_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
  6133. }
  6134. def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)),
  6135. (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
  6136. def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)),
  6137. (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
  6138. }
  6139. multiclass sve_mem_32b_gld_vs_32_unscaled<bits<4> opc, string asm,
  6140. SDPatternOperator sxtw_op,
  6141. SDPatternOperator uxtw_op,
  6142. RegisterOperand sxtw_opnd,
  6143. RegisterOperand uxtw_opnd,
  6144. ValueType vt> {
  6145. def _UXTW_REAL : sve_mem_32b_gld_sv<opc, 0, 0, asm, uxtw_opnd>;
  6146. def _SXTW_REAL : sve_mem_32b_gld_sv<opc, 1, 0, asm, sxtw_opnd>;
  6147. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6148. (!cast<Instruction>(NAME # _UXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  6149. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6150. (!cast<Instruction>(NAME # _SXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  6151. // We need a layer of indirection because early machine code passes balk at
  6152. // physical register (i.e. FFR) uses that have no previous definition.
  6153. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6154. def _UXTW : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>,
  6155. PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
  6156. def _SXTW : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>,
  6157. PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
  6158. }
  6159. def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)),
  6160. (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  6161. def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)),
  6162. (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  6163. }
  6164. class sve_mem_32b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
  6165. : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
  6166. asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
  6167. "",
  6168. []>, Sched<[]> {
  6169. bits<3> Pg;
  6170. bits<5> Zn;
  6171. bits<5> Zt;
  6172. bits<5> imm5;
  6173. let Inst{31-25} = 0b1000010;
  6174. let Inst{24-23} = opc{3-2};
  6175. let Inst{22-21} = 0b01;
  6176. let Inst{20-16} = imm5;
  6177. let Inst{15} = 0b1;
  6178. let Inst{14-13} = opc{1-0};
  6179. let Inst{12-10} = Pg;
  6180. let Inst{9-5} = Zn;
  6181. let Inst{4-0} = Zt;
  6182. let mayLoad = 1;
  6183. let Defs = !if(!eq(opc{0}, 1), [FFR], []);
  6184. let Uses = !if(!eq(opc{0}, 1), [FFR], []);
  6185. }
  6186. multiclass sve_mem_32b_gld_vi_32_ptrs<bits<4> opc, string asm, Operand imm_ty,
  6187. SDPatternOperator op, ValueType vt> {
  6188. def _IMM_REAL : sve_mem_32b_gld_vi<opc, asm, imm_ty>;
  6189. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6190. (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
  6191. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
  6192. (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
  6193. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6194. (!cast<Instruction>(NAME # _IMM_REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
  6195. // We need a layer of indirection because early machine code passes balk at
  6196. // physical register (i.e. FFR) uses that have no previous definition.
  6197. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6198. def _IMM : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), []>,
  6199. PseudoInstExpansion<(!cast<Instruction>(NAME # _IMM_REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5)>;
  6200. }
  6201. def : Pat<(nxv4i32 (op (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt)),
  6202. (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
  6203. }
  6204. class sve_mem_prfm_si<bits<2> msz, string asm>
  6205. : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, simm6s1:$imm6),
  6206. asm, "\t$prfop, $Pg, [$Rn, $imm6, mul vl]",
  6207. "",
  6208. []>, Sched<[]> {
  6209. bits<5> Rn;
  6210. bits<3> Pg;
  6211. bits<6> imm6;
  6212. bits<4> prfop;
  6213. let Inst{31-22} = 0b1000010111;
  6214. let Inst{21-16} = imm6;
  6215. let Inst{15} = 0b0;
  6216. let Inst{14-13} = msz;
  6217. let Inst{12-10} = Pg;
  6218. let Inst{9-5} = Rn;
  6219. let Inst{4} = 0b0;
  6220. let Inst{3-0} = prfop;
  6221. let hasSideEffects = 1;
  6222. }
  6223. multiclass sve_mem_prfm_si<bits<2> msz, string asm> {
  6224. def NAME : sve_mem_prfm_si<msz, asm>;
  6225. def : InstAlias<asm # "\t$prfop, $Pg, [$Rn]",
  6226. (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  6227. }
  6228. class sve_mem_prfm_ss<bits<3> opc, string asm, RegisterOperand gprty>
  6229. : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  6230. asm, "\t$prfop, $Pg, [$Rn, $Rm]",
  6231. "",
  6232. []>, Sched<[]> {
  6233. bits<5> Rm;
  6234. bits<5> Rn;
  6235. bits<3> Pg;
  6236. bits<4> prfop;
  6237. let Inst{31-25} = 0b1000010;
  6238. let Inst{24-23} = opc{2-1};
  6239. let Inst{22-21} = 0b00;
  6240. let Inst{20-16} = Rm;
  6241. let Inst{15} = 0b1;
  6242. let Inst{14} = opc{0};
  6243. let Inst{13} = 0b0;
  6244. let Inst{12-10} = Pg;
  6245. let Inst{9-5} = Rn;
  6246. let Inst{4} = 0b0;
  6247. let Inst{3-0} = prfop;
  6248. let hasSideEffects = 1;
  6249. }
  6250. class sve_mem_32b_prfm_sv<bits<2> msz, bit xs, string asm,
  6251. RegisterOperand zprext>
  6252. : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
  6253. asm, "\t$prfop, $Pg, [$Rn, $Zm]",
  6254. "",
  6255. []>, Sched<[]> {
  6256. bits<3> Pg;
  6257. bits<5> Rn;
  6258. bits<5> Zm;
  6259. bits<4> prfop;
  6260. let Inst{31-23} = 0b100001000;
  6261. let Inst{22} = xs;
  6262. let Inst{21} = 0b1;
  6263. let Inst{20-16} = Zm;
  6264. let Inst{15} = 0b0;
  6265. let Inst{14-13} = msz;
  6266. let Inst{12-10} = Pg;
  6267. let Inst{9-5} = Rn;
  6268. let Inst{4} = 0b0;
  6269. let Inst{3-0} = prfop;
  6270. let hasSideEffects = 1;
  6271. }
  6272. multiclass sve_mem_32b_prfm_sv_scaled<bits<2> msz, string asm,
  6273. RegisterOperand sxtw_opnd,
  6274. RegisterOperand uxtw_opnd,
  6275. SDPatternOperator op_sxtw,
  6276. SDPatternOperator op_uxtw> {
  6277. def _UXTW_SCALED : sve_mem_32b_prfm_sv<msz, 0, asm, uxtw_opnd>;
  6278. def _SXTW_SCALED : sve_mem_32b_prfm_sv<msz, 1, asm, sxtw_opnd>;
  6279. def : Pat<(op_uxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
  6280. (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
  6281. def : Pat<(op_sxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
  6282. (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
  6283. }
  6284. class sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
  6285. : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
  6286. asm, "\t$prfop, $Pg, [$Zn, $imm5]",
  6287. "",
  6288. []>, Sched<[]> {
  6289. bits<3> Pg;
  6290. bits<5> Zn;
  6291. bits<5> imm5;
  6292. bits<4> prfop;
  6293. let Inst{31-25} = 0b1000010;
  6294. let Inst{24-23} = msz;
  6295. let Inst{22-21} = 0b00;
  6296. let Inst{20-16} = imm5;
  6297. let Inst{15-13} = 0b111;
  6298. let Inst{12-10} = Pg;
  6299. let Inst{9-5} = Zn;
  6300. let Inst{4} = 0b0;
  6301. let Inst{3-0} = prfop;
  6302. }
  6303. multiclass sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> {
  6304. def NAME : sve_mem_32b_prfm_vi<msz, asm, imm_ty>;
  6305. def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
  6306. (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
  6307. def : Pat<(op (nxv4i1 PPR_3b:$Pg), (nxv4i32 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)),
  6308. (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>;
  6309. }
  6310. class sve_mem_z_fill<string asm>
  6311. : I<(outs ZPRAny:$Zt), (ins GPR64sp:$Rn, simm9:$imm9),
  6312. asm, "\t$Zt, [$Rn, $imm9, mul vl]",
  6313. "",
  6314. []>, Sched<[]> {
  6315. bits<5> Rn;
  6316. bits<5> Zt;
  6317. bits<9> imm9;
  6318. let Inst{31-22} = 0b1000010110;
  6319. let Inst{21-16} = imm9{8-3};
  6320. let Inst{15-13} = 0b010;
  6321. let Inst{12-10} = imm9{2-0};
  6322. let Inst{9-5} = Rn;
  6323. let Inst{4-0} = Zt;
  6324. let mayLoad = 1;
  6325. }
  6326. multiclass sve_mem_z_fill<string asm> {
  6327. def NAME : sve_mem_z_fill<asm>;
  6328. def : InstAlias<asm # "\t$Zt, [$Rn]",
  6329. (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
  6330. }
  6331. class sve_mem_p_fill<string asm>
  6332. : I<(outs PPRAny:$Pt), (ins GPR64sp:$Rn, simm9:$imm9),
  6333. asm, "\t$Pt, [$Rn, $imm9, mul vl]",
  6334. "",
  6335. []>, Sched<[]> {
  6336. bits<4> Pt;
  6337. bits<5> Rn;
  6338. bits<9> imm9;
  6339. let Inst{31-22} = 0b1000010110;
  6340. let Inst{21-16} = imm9{8-3};
  6341. let Inst{15-13} = 0b000;
  6342. let Inst{12-10} = imm9{2-0};
  6343. let Inst{9-5} = Rn;
  6344. let Inst{4} = 0b0;
  6345. let Inst{3-0} = Pt;
  6346. let mayLoad = 1;
  6347. }
  6348. multiclass sve_mem_p_fill<string asm> {
  6349. def NAME : sve_mem_p_fill<asm>;
  6350. def : InstAlias<asm # "\t$Pt, [$Rn]",
  6351. (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>;
  6352. }
  6353. class sve2_mem_gldnt_vs_base<bits<5> opc, dag iops, string asm,
  6354. RegisterOperand VecList>
  6355. : I<(outs VecList:$Zt), iops,
  6356. asm, "\t$Zt, $Pg/z, [$Zn, $Rm]",
  6357. "",
  6358. []>, Sched<[]> {
  6359. bits<3> Pg;
  6360. bits<5> Rm;
  6361. bits<5> Zn;
  6362. bits<5> Zt;
  6363. let Inst{31} = 0b1;
  6364. let Inst{30} = opc{4};
  6365. let Inst{29-25} = 0b00010;
  6366. let Inst{24-23} = opc{3-2};
  6367. let Inst{22-21} = 0b00;
  6368. let Inst{20-16} = Rm;
  6369. let Inst{15} = 0b1;
  6370. let Inst{14-13} = opc{1-0};
  6371. let Inst{12-10} = Pg;
  6372. let Inst{9-5} = Zn;
  6373. let Inst{4-0} = Zt;
  6374. let mayLoad = 1;
  6375. }
  6376. multiclass sve2_mem_gldnt_vs_32_ptrs<bits<5> opc, string asm,
  6377. SDPatternOperator op,
  6378. ValueType vt> {
  6379. def _REAL : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm),
  6380. asm, Z_s>;
  6381. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
  6382. (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>;
  6383. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6384. (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>;
  6385. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6386. (!cast<Instruction>(NAME # _REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>;
  6387. def : Pat <(nxv4i32 (op (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zd), (i64 GPR64:$Rm), vt)),
  6388. (!cast<Instruction>(NAME # _REAL) PPR3bAny:$Pg, ZPR32:$Zd, GPR64:$Rm)>;
  6389. }
  6390. multiclass sve2_mem_gldnt_vs_64_ptrs<bits<5> opc, string asm,
  6391. SDPatternOperator op,
  6392. ValueType vt> {
  6393. def _REAL : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm),
  6394. asm, Z_d>;
  6395. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
  6396. (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>;
  6397. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6398. (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>;
  6399. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6400. (!cast<Instruction>(NAME # _REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
  6401. def : Pat <(nxv2i64 (op (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zd), (i64 GPR64:$Rm), vt)),
  6402. (!cast<Instruction>(NAME # _REAL) PPR3bAny:$Pg, ZPR64:$Zd, GPR64:$Rm)>;
  6403. }
  6404. //===----------------------------------------------------------------------===//
  6405. // SVE Memory - 64-bit Gather Group
  6406. //===----------------------------------------------------------------------===//
  6407. // bit xs is '1' if offsets are signed
  6408. // bit scaled is '1' if the offsets are scaled
  6409. // bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
  6410. class sve_mem_64b_gld_sv<bits<4> opc, bit xs, bit scaled, bit lsl, string asm,
  6411. RegisterOperand zprext>
  6412. : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
  6413. asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6414. "",
  6415. []>, Sched<[]> {
  6416. bits<3> Pg;
  6417. bits<5> Rn;
  6418. bits<5> Zm;
  6419. bits<5> Zt;
  6420. let Inst{31-25} = 0b1100010;
  6421. let Inst{24-23} = opc{3-2};
  6422. let Inst{22} = xs;
  6423. let Inst{21} = scaled;
  6424. let Inst{20-16} = Zm;
  6425. let Inst{15} = lsl;
  6426. let Inst{14-13} = opc{1-0};
  6427. let Inst{12-10} = Pg;
  6428. let Inst{9-5} = Rn;
  6429. let Inst{4-0} = Zt;
  6430. let mayLoad = 1;
  6431. let Defs = !if(!eq(opc{0}, 1), [FFR], []);
  6432. let Uses = !if(!eq(opc{0}, 1), [FFR], []);
  6433. }
  6434. multiclass sve_mem_64b_gld_sv_32_scaled<bits<4> opc, string asm,
  6435. SDPatternOperator sxtw_op,
  6436. SDPatternOperator uxtw_op,
  6437. RegisterOperand sxtw_opnd,
  6438. RegisterOperand uxtw_opnd,
  6439. ValueType vt> {
  6440. def _UXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 0, 1, 0, asm, uxtw_opnd>;
  6441. def _SXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 0, asm, sxtw_opnd>;
  6442. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6443. (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  6444. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6445. (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  6446. // We need a layer of indirection because early machine code passes balk at
  6447. // physical register (i.e. FFR) uses that have no previous definition.
  6448. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6449. def _UXTW_SCALED : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>,
  6450. PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_SCALED_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
  6451. def _SXTW_SCALED : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>,
  6452. PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_SCALED_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
  6453. }
  6454. def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
  6455. (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
  6456. def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
  6457. (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
  6458. }
  6459. multiclass sve_mem_64b_gld_vs_32_unscaled<bits<4> opc, string asm,
  6460. SDPatternOperator sxtw_op,
  6461. SDPatternOperator uxtw_op,
  6462. RegisterOperand sxtw_opnd,
  6463. RegisterOperand uxtw_opnd,
  6464. ValueType vt> {
  6465. def _UXTW_REAL : sve_mem_64b_gld_sv<opc, 0, 0, 0, asm, uxtw_opnd>;
  6466. def _SXTW_REAL : sve_mem_64b_gld_sv<opc, 1, 0, 0, asm, sxtw_opnd>;
  6467. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6468. (!cast<Instruction>(NAME # _UXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
  6469. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6470. (!cast<Instruction>(NAME # _SXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
  6471. // We need a layer of indirection because early machine code passes balk at
  6472. // physical register (i.e. FFR) uses that have no previous definition.
  6473. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6474. def _UXTW : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>,
  6475. PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
  6476. def _SXTW : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>,
  6477. PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
  6478. }
  6479. def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
  6480. (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  6481. def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
  6482. (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  6483. }
  6484. multiclass sve_mem_64b_gld_sv2_64_scaled<bits<4> opc, string asm,
  6485. SDPatternOperator op,
  6486. RegisterOperand zprext, ValueType vt> {
  6487. def _SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 1, asm, zprext>;
  6488. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6489. (!cast<Instruction>(NAME # _SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
  6490. // We need a layer of indirection because early machine code passes balk at
  6491. // physical register (i.e. FFR) uses that have no previous definition.
  6492. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6493. def _SCALED : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), []>,
  6494. PseudoInstExpansion<(!cast<Instruction>(NAME # _SCALED_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm)>;
  6495. }
  6496. def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
  6497. (!cast<Instruction>(NAME # _SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
  6498. }
  6499. multiclass sve_mem_64b_gld_vs2_64_unscaled<bits<4> opc, string asm,
  6500. SDPatternOperator op, ValueType vt> {
  6501. def _REAL : sve_mem_64b_gld_sv<opc, 1, 0, 1, asm, ZPR64ExtLSL8>;
  6502. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
  6503. (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
  6504. // We need a layer of indirection because early machine code passes balk at
  6505. // physical register (i.e. FFR) uses that have no previous definition.
  6506. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6507. def "" : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), []>,
  6508. PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm)>;
  6509. }
  6510. def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
  6511. (!cast<Instruction>(NAME) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
  6512. }
  6513. class sve_mem_64b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
  6514. : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
  6515. asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
  6516. "",
  6517. []>, Sched<[]> {
  6518. bits<3> Pg;
  6519. bits<5> Zn;
  6520. bits<5> Zt;
  6521. bits<5> imm5;
  6522. let Inst{31-25} = 0b1100010;
  6523. let Inst{24-23} = opc{3-2};
  6524. let Inst{22-21} = 0b01;
  6525. let Inst{20-16} = imm5;
  6526. let Inst{15} = 0b1;
  6527. let Inst{14-13} = opc{1-0};
  6528. let Inst{12-10} = Pg;
  6529. let Inst{9-5} = Zn;
  6530. let Inst{4-0} = Zt;
  6531. let mayLoad = 1;
  6532. let Defs = !if(!eq(opc{0}, 1), [FFR], []);
  6533. let Uses = !if(!eq(opc{0}, 1), [FFR], []);
  6534. }
  6535. multiclass sve_mem_64b_gld_vi_64_ptrs<bits<4> opc, string asm, Operand imm_ty,
  6536. SDPatternOperator op, ValueType vt> {
  6537. def _IMM_REAL : sve_mem_64b_gld_vi<opc, asm, imm_ty>;
  6538. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6539. (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
  6540. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
  6541. (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
  6542. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
  6543. (!cast<Instruction>(NAME # _IMM_REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
  6544. // We need a layer of indirection because early machine code passes balk at
  6545. // physical register (i.e. FFR) uses that have no previous definition.
  6546. let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
  6547. def _IMM : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), []>,
  6548. PseudoInstExpansion<(!cast<Instruction>(NAME # _IMM_REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5)>;
  6549. }
  6550. def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt)),
  6551. (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
  6552. }
  6553. // bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
  6554. class sve_mem_64b_prfm_sv<bits<2> msz, bit xs, bit lsl, string asm,
  6555. RegisterOperand zprext>
  6556. : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
  6557. asm, "\t$prfop, $Pg, [$Rn, $Zm]",
  6558. "",
  6559. []>, Sched<[]> {
  6560. bits<3> Pg;
  6561. bits<5> Rn;
  6562. bits<5> Zm;
  6563. bits<4> prfop;
  6564. let Inst{31-23} = 0b110001000;
  6565. let Inst{22} = xs;
  6566. let Inst{21} = 0b1;
  6567. let Inst{20-16} = Zm;
  6568. let Inst{15} = lsl;
  6569. let Inst{14-13} = msz;
  6570. let Inst{12-10} = Pg;
  6571. let Inst{9-5} = Rn;
  6572. let Inst{4} = 0b0;
  6573. let Inst{3-0} = prfop;
  6574. let hasSideEffects = 1;
  6575. }
  6576. multiclass sve_mem_64b_prfm_sv_ext_scaled<bits<2> msz, string asm,
  6577. RegisterOperand sxtw_opnd,
  6578. RegisterOperand uxtw_opnd,
  6579. SDPatternOperator op_sxtw,
  6580. SDPatternOperator op_uxtw> {
  6581. def _UXTW_SCALED : sve_mem_64b_prfm_sv<msz, 0, 0, asm, uxtw_opnd>;
  6582. def _SXTW_SCALED : sve_mem_64b_prfm_sv<msz, 1, 0, asm, sxtw_opnd>;
  6583. def : Pat<(op_uxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
  6584. (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
  6585. def : Pat<(op_sxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
  6586. (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
  6587. }
  6588. multiclass sve_mem_64b_prfm_sv_lsl_scaled<bits<2> msz, string asm,
  6589. RegisterOperand zprext, SDPatternOperator frag> {
  6590. def NAME : sve_mem_64b_prfm_sv<msz, 1, 1, asm, zprext>;
  6591. def : Pat<(frag (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 zprext:$Zm), (i32 sve_prfop:$prfop)),
  6592. (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm)>;
  6593. }
  6594. class sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
  6595. : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
  6596. asm, "\t$prfop, $Pg, [$Zn, $imm5]",
  6597. "",
  6598. []>, Sched<[]> {
  6599. bits<3> Pg;
  6600. bits<5> Zn;
  6601. bits<5> imm5;
  6602. bits<4> prfop;
  6603. let Inst{31-25} = 0b1100010;
  6604. let Inst{24-23} = msz;
  6605. let Inst{22-21} = 0b00;
  6606. let Inst{20-16} = imm5;
  6607. let Inst{15-13} = 0b111;
  6608. let Inst{12-10} = Pg;
  6609. let Inst{9-5} = Zn;
  6610. let Inst{4} = 0b0;
  6611. let Inst{3-0} = prfop;
  6612. let hasSideEffects = 1;
  6613. }
  6614. multiclass sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> {
  6615. def NAME : sve_mem_64b_prfm_vi<msz, asm, imm_ty>;
  6616. def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
  6617. (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
  6618. def : Pat<(op (nxv2i1 PPR_3b:$Pg), (nxv2i64 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)),
  6619. (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>;
  6620. }
  6621. //===----------------------------------------------------------------------===//
  6622. // SVE Compute Vector Address Group
  6623. //===----------------------------------------------------------------------===//
  6624. class sve_int_bin_cons_misc_0_a<bits<2> opc, bits<2> msz, string asm,
  6625. ZPRRegOp zprty, RegisterOperand zprext>
  6626. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprext:$Zm),
  6627. asm, "\t$Zd, [$Zn, $Zm]",
  6628. "",
  6629. []>, Sched<[]> {
  6630. bits<5> Zd;
  6631. bits<5> Zn;
  6632. bits<5> Zm;
  6633. let Inst{31-24} = 0b00000100;
  6634. let Inst{23-22} = opc;
  6635. let Inst{21} = 0b1;
  6636. let Inst{20-16} = Zm;
  6637. let Inst{15-12} = 0b1010;
  6638. let Inst{11-10} = msz;
  6639. let Inst{9-5} = Zn;
  6640. let Inst{4-0} = Zd;
  6641. }
  6642. multiclass sve_int_bin_cons_misc_0_a_uxtw<bits<2> opc, string asm> {
  6643. def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtUXTW8>;
  6644. def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtUXTW16>;
  6645. def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtUXTW32>;
  6646. def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtUXTW64>;
  6647. }
  6648. multiclass sve_int_bin_cons_misc_0_a_sxtw<bits<2> opc, string asm> {
  6649. def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtSXTW8>;
  6650. def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtSXTW16>;
  6651. def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtSXTW32>;
  6652. def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtSXTW64>;
  6653. }
  6654. multiclass sve_int_bin_cons_misc_0_a_32_lsl<bits<2> opc, string asm> {
  6655. def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR32, ZPR32ExtLSL8>;
  6656. def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR32, ZPR32ExtLSL16>;
  6657. def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR32, ZPR32ExtLSL32>;
  6658. def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR32, ZPR32ExtLSL64>;
  6659. }
  6660. multiclass sve_int_bin_cons_misc_0_a_64_lsl<bits<2> opc, string asm> {
  6661. def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtLSL8>;
  6662. def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtLSL16>;
  6663. def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtLSL32>;
  6664. def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtLSL64>;
  6665. }
  6666. //===----------------------------------------------------------------------===//
  6667. // SVE Integer Misc - Unpredicated Group
  6668. //===----------------------------------------------------------------------===//
  6669. class sve_int_bin_cons_misc_0_b<bits<2> sz, string asm, ZPRRegOp zprty>
  6670. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
  6671. asm, "\t$Zd, $Zn, $Zm",
  6672. "",
  6673. []>, Sched<[]> {
  6674. bits<5> Zd;
  6675. bits<5> Zm;
  6676. bits<5> Zn;
  6677. let Inst{31-24} = 0b00000100;
  6678. let Inst{23-22} = sz;
  6679. let Inst{21} = 0b1;
  6680. let Inst{20-16} = Zm;
  6681. let Inst{15-10} = 0b101100;
  6682. let Inst{9-5} = Zn;
  6683. let Inst{4-0} = Zd;
  6684. }
  6685. multiclass sve_int_bin_cons_misc_0_b<string asm, SDPatternOperator op> {
  6686. def _H : sve_int_bin_cons_misc_0_b<0b01, asm, ZPR16>;
  6687. def _S : sve_int_bin_cons_misc_0_b<0b10, asm, ZPR32>;
  6688. def _D : sve_int_bin_cons_misc_0_b<0b11, asm, ZPR64>;
  6689. def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  6690. def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  6691. def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  6692. }
  6693. class sve_int_bin_cons_misc_0_c<bits<8> opc, string asm, ZPRRegOp zprty>
  6694. : I<(outs zprty:$Zd), (ins zprty:$Zn),
  6695. asm, "\t$Zd, $Zn",
  6696. "",
  6697. []>, Sched<[]> {
  6698. bits<5> Zd;
  6699. bits<5> Zn;
  6700. let Inst{31-24} = 0b00000100;
  6701. let Inst{23-22} = opc{7-6};
  6702. let Inst{21} = 0b1;
  6703. let Inst{20-16} = opc{5-1};
  6704. let Inst{15-11} = 0b10111;
  6705. let Inst{10} = opc{0};
  6706. let Inst{9-5} = Zn;
  6707. let Inst{4-0} = Zd;
  6708. }
  6709. multiclass sve_int_bin_cons_misc_0_c_fexpa<string asm, SDPatternOperator op> {
  6710. def _H : sve_int_bin_cons_misc_0_c<0b01000000, asm, ZPR16>;
  6711. def _S : sve_int_bin_cons_misc_0_c<0b10000000, asm, ZPR32>;
  6712. def _D : sve_int_bin_cons_misc_0_c<0b11000000, asm, ZPR64>;
  6713. def : SVE_1_Op_Pat<nxv8f16, op, nxv8i16, !cast<Instruction>(NAME # _H)>;
  6714. def : SVE_1_Op_Pat<nxv4f32, op, nxv4i32, !cast<Instruction>(NAME # _S)>;
  6715. def : SVE_1_Op_Pat<nxv2f64, op, nxv2i64, !cast<Instruction>(NAME # _D)>;
  6716. }
  6717. //===----------------------------------------------------------------------===//
  6718. // SVE Integer Reduction Group
  6719. //===----------------------------------------------------------------------===//
  6720. class sve_int_reduce<bits<2> sz8_32, bits<2> fmt, bits<3> opc, string asm,
  6721. ZPRRegOp zprty, FPRasZPROperand dstOpType>
  6722. : I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
  6723. asm, "\t$Vd, $Pg, $Zn",
  6724. "",
  6725. []>, Sched<[]> {
  6726. bits<3> Pg;
  6727. bits<5> Vd;
  6728. bits<5> Zn;
  6729. let Inst{31-24} = 0b00000100;
  6730. let Inst{23-22} = sz8_32;
  6731. let Inst{21} = 0b0;
  6732. let Inst{20-19} = fmt;
  6733. let Inst{18-16} = opc;
  6734. let Inst{15-13} = 0b001;
  6735. let Inst{12-10} = Pg;
  6736. let Inst{9-5} = Zn;
  6737. let Inst{4-0} = Vd;
  6738. }
  6739. multiclass sve_int_reduce_0_saddv<bits<3> opc, string asm,
  6740. SDPatternOperator op> {
  6741. def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>;
  6742. def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>;
  6743. def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>;
  6744. def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  6745. def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  6746. def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  6747. }
  6748. multiclass sve_int_reduce_0_uaddv<bits<3> opc, string asm,
  6749. SDPatternOperator op> {
  6750. def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>;
  6751. def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>;
  6752. def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>;
  6753. def _D : sve_int_reduce<0b11, 0b00, opc, asm, ZPR64, FPR64asZPR>;
  6754. def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  6755. def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  6756. def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  6757. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  6758. }
  6759. multiclass sve_int_reduce_1<bits<3> opc, string asm,
  6760. SDPatternOperator op> {
  6761. def _B : sve_int_reduce<0b00, 0b01, opc, asm, ZPR8, FPR8asZPR>;
  6762. def _H : sve_int_reduce<0b01, 0b01, opc, asm, ZPR16, FPR16asZPR>;
  6763. def _S : sve_int_reduce<0b10, 0b01, opc, asm, ZPR32, FPR32asZPR>;
  6764. def _D : sve_int_reduce<0b11, 0b01, opc, asm, ZPR64, FPR64asZPR>;
  6765. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  6766. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  6767. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  6768. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  6769. }
  6770. multiclass sve_int_reduce_2<bits<3> opc, string asm,
  6771. SDPatternOperator op> {
  6772. def _B : sve_int_reduce<0b00, 0b11, opc, asm, ZPR8, FPR8asZPR>;
  6773. def _H : sve_int_reduce<0b01, 0b11, opc, asm, ZPR16, FPR16asZPR>;
  6774. def _S : sve_int_reduce<0b10, 0b11, opc, asm, ZPR32, FPR32asZPR>;
  6775. def _D : sve_int_reduce<0b11, 0b11, opc, asm, ZPR64, FPR64asZPR>;
  6776. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
  6777. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
  6778. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
  6779. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
  6780. }
  6781. class sve_int_movprfx_pred<bits<2> sz8_32, bits<3> opc, string asm,
  6782. ZPRRegOp zprty, string pg_suffix, dag iops>
  6783. : I<(outs zprty:$Zd), iops,
  6784. asm, "\t$Zd, $Pg"#pg_suffix#", $Zn",
  6785. "",
  6786. []>, Sched<[]> {
  6787. bits<3> Pg;
  6788. bits<5> Zd;
  6789. bits<5> Zn;
  6790. let Inst{31-24} = 0b00000100;
  6791. let Inst{23-22} = sz8_32;
  6792. let Inst{21-19} = 0b010;
  6793. let Inst{18-16} = opc;
  6794. let Inst{15-13} = 0b001;
  6795. let Inst{12-10} = Pg;
  6796. let Inst{9-5} = Zn;
  6797. let Inst{4-0} = Zd;
  6798. let ElementSize = zprty.ElementSize;
  6799. }
  6800. multiclass sve_int_movprfx_pred_merge<bits<3> opc, string asm> {
  6801. let Constraints = "$Zd = $_Zd" in {
  6802. def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/m",
  6803. (ins ZPR8:$_Zd, PPR3bAny:$Pg, ZPR8:$Zn)>;
  6804. def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/m",
  6805. (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR16:$Zn)>;
  6806. def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/m",
  6807. (ins ZPR32:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn)>;
  6808. def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/m",
  6809. (ins ZPR64:$_Zd, PPR3bAny:$Pg, ZPR64:$Zn)>;
  6810. }
  6811. }
  6812. multiclass sve_int_movprfx_pred_zero<bits<3> opc, string asm> {
  6813. def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/z",
  6814. (ins PPR3bAny:$Pg, ZPR8:$Zn)>;
  6815. def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/z",
  6816. (ins PPR3bAny:$Pg, ZPR16:$Zn)>;
  6817. def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/z",
  6818. (ins PPR3bAny:$Pg, ZPR32:$Zn)>;
  6819. def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/z",
  6820. (ins PPR3bAny:$Pg, ZPR64:$Zn)>;
  6821. }
  6822. //===----------------------------------------------------------------------===//
  6823. // SVE Propagate Break Group
  6824. //===----------------------------------------------------------------------===//
  6825. class sve_int_brkp<bits<2> opc, string asm>
  6826. : I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
  6827. asm, "\t$Pd, $Pg/z, $Pn, $Pm",
  6828. "",
  6829. []>, Sched<[]> {
  6830. bits<4> Pd;
  6831. bits<4> Pg;
  6832. bits<4> Pm;
  6833. bits<4> Pn;
  6834. let Inst{31-24} = 0b00100101;
  6835. let Inst{23} = 0b0;
  6836. let Inst{22} = opc{1};
  6837. let Inst{21-20} = 0b00;
  6838. let Inst{19-16} = Pm;
  6839. let Inst{15-14} = 0b11;
  6840. let Inst{13-10} = Pg;
  6841. let Inst{9} = 0b0;
  6842. let Inst{8-5} = Pn;
  6843. let Inst{4} = opc{0};
  6844. let Inst{3-0} = Pd;
  6845. let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
  6846. }
  6847. multiclass sve_int_brkp<bits<2> opc, string asm, SDPatternOperator op> {
  6848. def NAME : sve_int_brkp<opc, asm>;
  6849. def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
  6850. }
  6851. //===----------------------------------------------------------------------===//
  6852. // SVE Partition Break Group
  6853. //===----------------------------------------------------------------------===//
  6854. class sve_int_brkn<bit S, string asm>
  6855. : I<(outs PPR8:$Pdm), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$_Pdm),
  6856. asm, "\t$Pdm, $Pg/z, $Pn, $_Pdm",
  6857. "",
  6858. []>, Sched<[]> {
  6859. bits<4> Pdm;
  6860. bits<4> Pg;
  6861. bits<4> Pn;
  6862. let Inst{31-23} = 0b001001010;
  6863. let Inst{22} = S;
  6864. let Inst{21-14} = 0b01100001;
  6865. let Inst{13-10} = Pg;
  6866. let Inst{9} = 0b0;
  6867. let Inst{8-5} = Pn;
  6868. let Inst{4} = 0b0;
  6869. let Inst{3-0} = Pdm;
  6870. let Constraints = "$Pdm = $_Pdm";
  6871. let Defs = !if(S, [NZCV], []);
  6872. }
  6873. multiclass sve_int_brkn<bits<1> opc, string asm, SDPatternOperator op> {
  6874. def NAME : sve_int_brkn<opc, asm>;
  6875. def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
  6876. }
  6877. class sve_int_break<bits<3> opc, string asm, string suffix, dag iops>
  6878. : I<(outs PPR8:$Pd), iops,
  6879. asm, "\t$Pd, $Pg"#suffix#", $Pn",
  6880. "",
  6881. []>, Sched<[]> {
  6882. bits<4> Pd;
  6883. bits<4> Pg;
  6884. bits<4> Pn;
  6885. let Inst{31-24} = 0b00100101;
  6886. let Inst{23-22} = opc{2-1};
  6887. let Inst{21-14} = 0b01000001;
  6888. let Inst{13-10} = Pg;
  6889. let Inst{9} = 0b0;
  6890. let Inst{8-5} = Pn;
  6891. let Inst{4} = opc{0};
  6892. let Inst{3-0} = Pd;
  6893. let Constraints = !if(!eq (opc{0}, 1), "$Pd = $_Pd", "");
  6894. let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
  6895. }
  6896. multiclass sve_int_break_m<bits<3> opc, string asm, SDPatternOperator op> {
  6897. def NAME : sve_int_break<opc, asm, "/m", (ins PPR8:$_Pd, PPRAny:$Pg, PPR8:$Pn)>;
  6898. def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
  6899. }
  6900. multiclass sve_int_break_z<bits<3> opc, string asm, SDPatternOperator op> {
  6901. def NAME : sve_int_break<opc, asm, "/z", (ins PPRAny:$Pg, PPR8:$Pn)>;
  6902. def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
  6903. }
  6904. //===----------------------------------------------------------------------===//
  6905. // SVE2 String Processing Group
  6906. //===----------------------------------------------------------------------===//
  6907. class sve2_char_match<bit sz, bit opc, string asm,
  6908. PPRRegOp pprty, ZPRRegOp zprty>
  6909. : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
  6910. asm, "\t$Pd, $Pg/z, $Zn, $Zm",
  6911. "",
  6912. []>, Sched<[]> {
  6913. bits<4> Pd;
  6914. bits<3> Pg;
  6915. bits<5> Zm;
  6916. bits<5> Zn;
  6917. let Inst{31-23} = 0b010001010;
  6918. let Inst{22} = sz;
  6919. let Inst{21} = 0b1;
  6920. let Inst{20-16} = Zm;
  6921. let Inst{15-13} = 0b100;
  6922. let Inst{12-10} = Pg;
  6923. let Inst{9-5} = Zn;
  6924. let Inst{4} = opc;
  6925. let Inst{3-0} = Pd;
  6926. let Defs = [NZCV];
  6927. let isPTestLike = 1;
  6928. }
  6929. multiclass sve2_char_match<bit opc, string asm, SDPatternOperator op> {
  6930. def _B : sve2_char_match<0b0, opc, asm, PPR8, ZPR8>;
  6931. def _H : sve2_char_match<0b1, opc, asm, PPR16, ZPR16>;
  6932. def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
  6933. def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
  6934. }
  6935. //===----------------------------------------------------------------------===//
  6936. // SVE2 Histogram Computation - Segment Group
  6937. //===----------------------------------------------------------------------===//
  6938. class sve2_hist_gen_segment<string asm, SDPatternOperator op>
  6939. : I<(outs ZPR8:$Zd), (ins ZPR8:$Zn, ZPR8:$Zm),
  6940. asm, "\t$Zd, $Zn, $Zm",
  6941. "",
  6942. [(set nxv16i8:$Zd, (op nxv16i8:$Zn, nxv16i8:$Zm))]>, Sched<[]> {
  6943. bits<5> Zd;
  6944. bits<5> Zn;
  6945. bits<5> Zm;
  6946. let Inst{31-21} = 0b01000101001;
  6947. let Inst{20-16} = Zm;
  6948. let Inst{15-10} = 0b101000;
  6949. let Inst{9-5} = Zn;
  6950. let Inst{4-0} = Zd;
  6951. }
  6952. //===----------------------------------------------------------------------===//
  6953. // SVE2 Histogram Computation - Vector Group
  6954. //===----------------------------------------------------------------------===//
  6955. class sve2_hist_gen_vector<bit sz, string asm, ZPRRegOp zprty>
  6956. : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
  6957. asm, "\t$Zd, $Pg/z, $Zn, $Zm",
  6958. "",
  6959. []>, Sched<[]> {
  6960. bits<5> Zd;
  6961. bits<5> Zn;
  6962. bits<3> Pg;
  6963. bits<5> Zm;
  6964. let Inst{31-23} = 0b010001011;
  6965. let Inst{22} = sz;
  6966. let Inst{21} = 0b1;
  6967. let Inst{20-16} = Zm;
  6968. let Inst{15-13} = 0b110;
  6969. let Inst{12-10} = Pg;
  6970. let Inst{9-5} = Zn;
  6971. let Inst{4-0} = Zd;
  6972. }
  6973. multiclass sve2_hist_gen_vector<string asm, SDPatternOperator op> {
  6974. def _S : sve2_hist_gen_vector<0b0, asm, ZPR32>;
  6975. def _D : sve2_hist_gen_vector<0b1, asm, ZPR64>;
  6976. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
  6977. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
  6978. }
  6979. //===----------------------------------------------------------------------===//
  6980. // SVE2 Crypto Extensions Group
  6981. //===----------------------------------------------------------------------===//
  6982. class sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty>
  6983. : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
  6984. asm, "\t$Zd, $Zn, $Zm",
  6985. "",
  6986. []>, Sched<[]> {
  6987. bits<5> Zd;
  6988. bits<5> Zn;
  6989. bits<5> Zm;
  6990. let Inst{31-21} = 0b01000101001;
  6991. let Inst{20-16} = Zm;
  6992. let Inst{15-11} = 0b11110;
  6993. let Inst{10} = opc;
  6994. let Inst{9-5} = Zn;
  6995. let Inst{4-0} = Zd;
  6996. }
  6997. multiclass sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty,
  6998. SDPatternOperator op, ValueType vt> {
  6999. def NAME : sve2_crypto_cons_bin_op<opc, asm, zprty>;
  7000. def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>;
  7001. }
  7002. class sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty>
  7003. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm),
  7004. asm, "\t$Zdn, $_Zdn, $Zm",
  7005. "",
  7006. []>, Sched<[]> {
  7007. bits<5> Zdn;
  7008. bits<5> Zm;
  7009. let Inst{31-17} = 0b010001010010001;
  7010. let Inst{16} = opc{1};
  7011. let Inst{15-11} = 0b11100;
  7012. let Inst{10} = opc{0};
  7013. let Inst{9-5} = Zm;
  7014. let Inst{4-0} = Zdn;
  7015. let Constraints = "$Zdn = $_Zdn";
  7016. }
  7017. multiclass sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty,
  7018. SDPatternOperator op, ValueType vt> {
  7019. def NAME : sve2_crypto_des_bin_op<opc, asm, zprty>;
  7020. def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>;
  7021. }
  7022. class sve2_crypto_unary_op<bit opc, string asm, ZPRRegOp zprty>
  7023. : I<(outs zprty:$Zdn), (ins zprty:$_Zdn),
  7024. asm, "\t$Zdn, $_Zdn",
  7025. "",
  7026. []>, Sched<[]> {
  7027. bits<5> Zdn;
  7028. let Inst{31-11} = 0b010001010010000011100;
  7029. let Inst{10} = opc;
  7030. let Inst{9-5} = 0b00000;
  7031. let Inst{4-0} = Zdn;
  7032. let Constraints = "$Zdn = $_Zdn";
  7033. }
  7034. multiclass sve2_crypto_unary_op<bit opc, string asm, SDPatternOperator op> {
  7035. def NAME : sve2_crypto_unary_op<opc, asm, ZPR8>;
  7036. def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME)>;
  7037. }
  7038. //===----------------------------------------------------------------------===//
  7039. // SVE BFloat16 Group
  7040. //===----------------------------------------------------------------------===//
  7041. class sve_bfloat_dot_base<bits<2> opc, string asm, string ops, dag iops>
  7042. : I<(outs ZPR32:$Zda), iops, asm, ops, "", []>, Sched<[]> {
  7043. bits<5> Zda;
  7044. bits<5> Zn;
  7045. let Inst{31-21} = 0b01100100011;
  7046. let Inst{15-14} = opc;
  7047. let Inst{13-10} = 0b0000;
  7048. let Inst{9-5} = Zn;
  7049. let Inst{4-0} = Zda;
  7050. let Constraints = "$Zda = $_Zda";
  7051. let DestructiveInstType = DestructiveOther;
  7052. let ElementSize = ElementSizeH;
  7053. }
  7054. class sve_bfloat_dot<string asm>
  7055. : sve_bfloat_dot_base<0b10, asm, "\t$Zda, $Zn, $Zm",
  7056. (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm)> {
  7057. bits<5> Zm;
  7058. let Inst{20-16} = Zm;
  7059. }
  7060. multiclass sve_bfloat_dot<string asm, SDPatternOperator op> {
  7061. def NAME : sve_bfloat_dot<asm>;
  7062. def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16 ,!cast<Instruction>(NAME)>;
  7063. }
  7064. class sve_bfloat_dot_indexed<string asm>
  7065. : sve_bfloat_dot_base<0b01, asm, "\t$Zda, $Zn, $Zm$iop",
  7066. (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexS:$iop)> {
  7067. bits<2> iop;
  7068. bits<3> Zm;
  7069. let Inst{20-19} = iop;
  7070. let Inst{18-16} = Zm;
  7071. }
  7072. multiclass sve_bfloat_dot_indexed<string asm, SDPatternOperator op> {
  7073. def NAME : sve_bfloat_dot_indexed<asm>;
  7074. def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16, i64, VectorIndexS_timm, !cast<Instruction>(NAME)>;
  7075. }
  7076. class sve_bfloat_matmul<string asm>
  7077. : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
  7078. asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
  7079. bits<5> Zm;
  7080. bits<5> Zda;
  7081. bits<5> Zn;
  7082. let Inst{31-21} = 0b01100100011;
  7083. let Inst{20-16} = Zm;
  7084. let Inst{15-10} = 0b111001;
  7085. let Inst{9-5} = Zn;
  7086. let Inst{4-0} = Zda;
  7087. let Constraints = "$Zda = $_Zda";
  7088. let DestructiveInstType = DestructiveOther;
  7089. let ElementSize = ElementSizeH;
  7090. }
  7091. multiclass sve_bfloat_matmul<string asm, SDPatternOperator op> {
  7092. def NAME : sve_bfloat_matmul<asm>;
  7093. def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16 ,!cast<Instruction>(NAME)>;
  7094. }
  7095. class sve_bfloat_matmul_longvecl<bit BT, string asm>
  7096. : sve_bfloat_matmul<asm> {
  7097. let Inst{23} = 0b1;
  7098. let Inst{14-13} = 0b00;
  7099. let Inst{10} = BT;
  7100. }
  7101. multiclass sve_bfloat_matmul_longvecl<bit BT, string asm, SDPatternOperator op> {
  7102. def NAME : sve_bfloat_matmul_longvecl<BT, asm>;
  7103. def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16 ,!cast<Instruction>(NAME)>;
  7104. }
  7105. class sve_bfloat_matmul_longvecl_idx<bit BT, string asm>
  7106. : sve_bfloat_dot_base<0b01, asm, "\t$Zda, $Zn, $Zm$iop",
  7107. (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexH:$iop)> {
  7108. bits<3> iop;
  7109. bits<3> Zm;
  7110. let Inst{23} = 0b1;
  7111. let Inst{20-19} = iop{2-1};
  7112. let Inst{18-16} = Zm;
  7113. let Inst{11} = iop{0};
  7114. let Inst{10} = BT;
  7115. }
  7116. multiclass sve_bfloat_matmul_longvecl_idx<bit BT, string asm, SDPatternOperator op> {
  7117. def NAME : sve_bfloat_matmul_longvecl_idx<BT, asm>;
  7118. def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16, i64, VectorIndexH_timm, !cast<Instruction>(NAME)>;
  7119. }
  7120. class sve_bfloat_convert<bit N, string asm>
  7121. : I<(outs ZPR16:$Zd), (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn),
  7122. asm, "\t$Zd, $Pg/m, $Zn", "", []>, Sched<[]> {
  7123. bits<5> Zd;
  7124. bits<3> Pg;
  7125. bits<5> Zn;
  7126. let Inst{31-25} = 0b0110010;
  7127. let Inst{24} = N;
  7128. let Inst{23-13} = 0b10001010101;
  7129. let Inst{12-10} = Pg;
  7130. let Inst{9-5} = Zn;
  7131. let Inst{4-0} = Zd;
  7132. let Constraints = "$Zd = $_Zd";
  7133. let DestructiveInstType = DestructiveOther;
  7134. let hasSideEffects = 1;
  7135. let ElementSize = ElementSizeS;
  7136. }
  7137. multiclass sve_bfloat_convert<bit N, string asm, SDPatternOperator op> {
  7138. def NAME : sve_bfloat_convert<N, asm>;
  7139. def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i1, nxv4f32, !cast<Instruction>(NAME)>;
  7140. }
  7141. //===----------------------------------------------------------------------===//
  7142. // SVE Integer Matrix Multiply Group
  7143. //===----------------------------------------------------------------------===//
  7144. class sve_int_matmul<bits<2> uns, string asm>
  7145. : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm,
  7146. "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
  7147. bits<5> Zda;
  7148. bits<5> Zn;
  7149. bits<5> Zm;
  7150. let Inst{31-24} = 0b01000101;
  7151. let Inst{23-22} = uns;
  7152. let Inst{21} = 0;
  7153. let Inst{20-16} = Zm;
  7154. let Inst{15-10} = 0b100110;
  7155. let Inst{9-5} = Zn;
  7156. let Inst{4-0} = Zda;
  7157. let Constraints = "$Zda = $_Zda";
  7158. let DestructiveInstType = DestructiveOther;
  7159. let ElementSize = ZPR32.ElementSize;
  7160. }
  7161. multiclass sve_int_matmul<bits<2> uns, string asm, SDPatternOperator op> {
  7162. def NAME : sve_int_matmul<uns, asm>;
  7163. def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
  7164. }
  7165. //===----------------------------------------------------------------------===//
  7166. // SVE Integer Dot Product Mixed Sign Group
  7167. //===----------------------------------------------------------------------===//
  7168. class sve_int_dot_mixed<string asm>
  7169. : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm,
  7170. "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
  7171. bits<5> Zda;
  7172. bits<5> Zn;
  7173. bits<5> Zm;
  7174. let Inst{31-21} = 0b01000100100;
  7175. let Inst{20-16} = Zm;
  7176. let Inst{15-10} = 0b011110;
  7177. let Inst{9-5} = Zn;
  7178. let Inst{4-0} = Zda;
  7179. let Constraints = "$Zda = $_Zda";
  7180. let DestructiveInstType = DestructiveOther;
  7181. let ElementSize = ZPR32.ElementSize;
  7182. }
  7183. multiclass sve_int_dot_mixed<string asm, SDPatternOperator op> {
  7184. def NAME : sve_int_dot_mixed<asm>;
  7185. def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
  7186. }
  7187. //===----------------------------------------------------------------------===//
  7188. // SVE Integer Dot Product Mixed Sign - Indexed Group
  7189. //===----------------------------------------------------------------------===//
  7190. class sve_int_dot_mixed_indexed<bit U, string asm>
  7191. : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexS32b:$idx),
  7192. asm, "\t$Zda, $Zn, $Zm$idx", "", []>, Sched<[]> {
  7193. bits<5> Zda;
  7194. bits<5> Zn;
  7195. bits<3> Zm;
  7196. bits<2> idx;
  7197. let Inst{31-21} = 0b01000100101;
  7198. let Inst{20-19} = idx;
  7199. let Inst{18-16} = Zm;
  7200. let Inst{15-11} = 0b00011;
  7201. let Inst{10} = U;
  7202. let Inst{9-5} = Zn;
  7203. let Inst{4-0} = Zda;
  7204. let Constraints = "$Zda = $_Zda";
  7205. let DestructiveInstType = DestructiveOther;
  7206. let ElementSize = ZPR32.ElementSize;
  7207. }
  7208. multiclass sve_int_dot_mixed_indexed<bit U, string asm, SDPatternOperator op> {
  7209. def NAME : sve_int_dot_mixed_indexed<U, asm>;
  7210. def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>;
  7211. }
  7212. //===----------------------------------------------------------------------===//
  7213. // SVE Floating Point Matrix Multiply Accumulate Group
  7214. //===----------------------------------------------------------------------===//
  7215. class sve_fp_matrix_mla<bit sz, string asm, ZPRRegOp zprty>
  7216. : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty:$Zm),
  7217. asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
  7218. bits<5> Zda;
  7219. bits<5> Zn;
  7220. bits<5> Zm;
  7221. let Inst{31-23} = 0b011001001;
  7222. let Inst{22} = sz;
  7223. let Inst{21} = 1;
  7224. let Inst{20-16} = Zm;
  7225. let Inst{15-10} = 0b111001;
  7226. let Inst{9-5} = Zn;
  7227. let Inst{4-0} = Zda;
  7228. let Constraints = "$Zda = $_Zda";
  7229. let DestructiveInstType = DestructiveOther;
  7230. let ElementSize = zprty.ElementSize;
  7231. }
  7232. multiclass sve_fp_matrix_mla<bit sz, string asm, ZPRRegOp zprty, SDPatternOperator op, ValueType vt> {
  7233. def NAME : sve_fp_matrix_mla<sz, asm, zprty>;
  7234. def : SVE_3_Op_Pat<vt, op , vt, vt, vt, !cast<Instruction>(NAME)>;
  7235. }
  7236. //===----------------------------------------------------------------------===//
  7237. // SVE Memory - Contiguous Load And Replicate 256-bit Group
  7238. //===----------------------------------------------------------------------===//
  7239. class sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand VecList>
  7240. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4),
  7241. asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
  7242. bits<5> Zt;
  7243. bits<5> Rn;
  7244. bits<3> Pg;
  7245. bits<4> imm4;
  7246. let Inst{31-25} = 0b1010010;
  7247. let Inst{24-23} = sz;
  7248. let Inst{22-20} = 0b010;
  7249. let Inst{19-16} = imm4;
  7250. let Inst{15-13} = 0b001;
  7251. let Inst{12-10} = Pg;
  7252. let Inst{9-5} = Rn;
  7253. let Inst{4-0} = Zt;
  7254. let mayLoad = 1;
  7255. }
  7256. multiclass sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand listty,
  7257. ZPRRegOp zprty, ValueType Ty, ValueType PredTy, SDNode Ld1ro> {
  7258. def NAME : sve_mem_ldor_si<sz, asm, listty>;
  7259. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  7260. (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
  7261. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
  7262. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
  7263. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
  7264. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4), 0>;
  7265. // Base addressing mode
  7266. def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), GPR64sp:$base)),
  7267. (!cast<Instruction>(NAME) PPR3bAny:$Pg, GPR64sp:$base, (i64 0))>;
  7268. let AddedComplexity = 2 in {
  7269. // Reg + Imm addressing mode
  7270. def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), (add GPR64:$base, (i64 simm4s32:$imm)))),
  7271. (!cast<Instruction>(NAME) $Pg, $base, simm4s32:$imm)>;
  7272. }
  7273. }
  7274. class sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand VecList,
  7275. RegisterOperand gprty>
  7276. : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
  7277. asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
  7278. bits<5> Zt;
  7279. bits<3> Pg;
  7280. bits<5> Rn;
  7281. bits<5> Rm;
  7282. let Inst{31-25} = 0b1010010;
  7283. let Inst{24-23} = sz;
  7284. let Inst{22-21} = 0b01;
  7285. let Inst{20-16} = Rm;
  7286. let Inst{15-13} = 0;
  7287. let Inst{12-10} = Pg;
  7288. let Inst{9-5} = Rn;
  7289. let Inst{4-0} = Zt;
  7290. let mayLoad = 1;
  7291. }
  7292. multiclass sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand listty,
  7293. ZPRRegOp zprty, RegisterOperand gprty, ValueType Ty,
  7294. ValueType PredTy, SDNode Ld1ro, ComplexPattern AddrCP> {
  7295. def NAME : sve_mem_ldor_ss<sz, asm, listty, gprty>;
  7296. def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
  7297. (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
  7298. def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$gp), (AddrCP GPR64sp:$base, gprty:$offset))),
  7299. (!cast<Instruction>(NAME) PPR3bAny:$gp, GPR64sp:$base, gprty:$offset)>;
  7300. }
  7301. //===----------------------------------------------------------------------===//
  7302. // SVE Interleave 128-bit Elements Group
  7303. //===----------------------------------------------------------------------===//
  7304. class sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm>
  7305. : I<(outs ZPR128:$Zd), (ins ZPR128:$Zn, ZPR128:$Zm),
  7306. asm, "\t$Zd, $Zn, $Zm",
  7307. "",
  7308. []>, Sched<[]> {
  7309. bits<5> Zd;
  7310. bits<5> Zm;
  7311. bits<5> Zn;
  7312. let Inst{31-21} = 0b00000101101;
  7313. let Inst{20-16} = Zm;
  7314. let Inst{15-13} = 0b000;
  7315. let Inst{12-11} = opc;
  7316. let Inst{10} = P;
  7317. let Inst{9-5} = Zn;
  7318. let Inst{4-0} = Zd;
  7319. }
  7320. multiclass sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm, SDPatternOperator op> {
  7321. def NAME : sve_int_perm_bin_perm_128_zz<opc, P, asm>;
  7322. def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
  7323. def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
  7324. def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME)>;
  7325. def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
  7326. def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME)>;
  7327. def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
  7328. def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME)>;
  7329. def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
  7330. }
  7331. /// Addressing modes
  7332. def am_sve_indexed_s4 :ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-8,7>", [], [SDNPWantRoot]>;
  7333. def am_sve_indexed_s6 :ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-32,31>", [], [SDNPWantRoot]>;
  7334. def am_sve_regreg_lsl0 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<0>", []>;
  7335. def am_sve_regreg_lsl1 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<1>", []>;
  7336. def am_sve_regreg_lsl2 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<2>", []>;
  7337. def am_sve_regreg_lsl3 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<3>", []>;
  7338. // Predicated pseudo floating point two operand instructions.
  7339. multiclass sve_fp_bin_pred_hfd<SDPatternOperator op> {
  7340. def _UNDEF_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
  7341. def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
  7342. def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
  7343. def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  7344. def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  7345. def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  7346. def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  7347. def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  7348. def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  7349. }
  7350. // Predicated pseudo integer two operand instructions.
  7351. multiclass sve_int_bin_pred_bhsd<SDPatternOperator op> {
  7352. def _UNDEF_B : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>;
  7353. def _UNDEF_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
  7354. def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
  7355. def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
  7356. def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>;
  7357. def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  7358. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  7359. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  7360. }
  7361. // As sve_int_bin_pred but when only i32 and i64 vector types are required.
  7362. multiclass sve_int_bin_pred_sd<SDPatternOperator op> {
  7363. def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
  7364. def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
  7365. def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  7366. def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  7367. }
  7368. // Predicated pseudo integer two operand instructions. Second operand is an
  7369. // immediate specified by imm_[bhsd].
  7370. multiclass sve_int_shift_pred_bhsd<SDPatternOperator op,
  7371. ComplexPattern imm_b, ComplexPattern imm_h,
  7372. ComplexPattern imm_s, ComplexPattern imm_d> {
  7373. def _UNDEF_B : PredTwoOpImmPseudo<NAME # _B, ZPR8, Operand<i32>, FalseLanesUndef>;
  7374. def _UNDEF_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, Operand<i32>, FalseLanesUndef>;
  7375. def _UNDEF_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, Operand<i32>, FalseLanesUndef>;
  7376. def _UNDEF_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, Operand<i32>, FalseLanesUndef>;
  7377. def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, imm_b, !cast<Instruction>(NAME # _UNDEF_B)>;
  7378. def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, imm_h, !cast<Instruction>(NAME # _UNDEF_H)>;
  7379. def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, imm_s, !cast<Instruction>(NAME # _UNDEF_S)>;
  7380. def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, imm_d, !cast<Instruction>(NAME # _UNDEF_D)>;
  7381. }
  7382. multiclass sve_int_bin_pred_all_active_bhsd<SDPatternOperator op> {
  7383. def _UNDEF_B : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>;
  7384. def _UNDEF_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
  7385. def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
  7386. def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
  7387. def : SVE_2_Op_Pred_All_Active_Pt<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>;
  7388. def : SVE_2_Op_Pred_All_Active_Pt<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>;
  7389. def : SVE_2_Op_Pred_All_Active_Pt<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>;
  7390. def : SVE_2_Op_Pred_All_Active_Pt<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>;
  7391. }