PPCInstrInfo.td 248 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605
  1. //===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file describes the subset of the 32-bit PowerPC instruction set, as used
  10. // by the PowerPC instruction selector.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. include "PPCInstrFormats.td"
  14. //===----------------------------------------------------------------------===//
  15. // PowerPC specific type constraints.
  16. //
  17. def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
  18. SDTCisVT<0, f64>, SDTCisPtrTy<1>
  19. ]>;
  20. def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x
  21. SDTCisVT<0, f64>, SDTCisPtrTy<1>
  22. ]>;
  23. def SDT_PPCLxsizx : SDTypeProfile<1, 2, [
  24. SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
  25. ]>;
  26. def SDT_PPCstxsix : SDTypeProfile<0, 3, [
  27. SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
  28. ]>;
  29. def SDT_PPCcv_fp_to_int : SDTypeProfile<1, 1, [
  30. SDTCisFP<0>, SDTCisFP<1>
  31. ]>;
  32. def SDT_PPCstore_scal_int_from_vsr : SDTypeProfile<0, 3, [
  33. SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
  34. ]>;
  35. def SDT_PPCVexts : SDTypeProfile<1, 2, [
  36. SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2>
  37. ]>;
  38. def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
  39. SDTCisVT<1, i32> ]>;
  40. def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
  41. SDTCisVT<1, i32> ]>;
  42. def SDT_PPCvperm : SDTypeProfile<1, 3, [
  43. SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
  44. ]>;
  45. def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>,
  46. SDTCisVec<1>, SDTCisInt<2>
  47. ]>;
  48. def SDT_PPCSpToDp : SDTypeProfile<1, 1, [ SDTCisVT<0, v2f64>,
  49. SDTCisInt<1>
  50. ]>;
  51. def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>,
  52. SDTCisVec<1>, SDTCisVec<2>, SDTCisPtrTy<3>
  53. ]>;
  54. def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>,
  55. SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
  56. ]>;
  57. def SDT_PPCxxpermdi: SDTypeProfile<1, 3, [ SDTCisVec<0>,
  58. SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
  59. ]>;
  60. def SDT_PPCvcmp : SDTypeProfile<1, 3, [
  61. SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
  62. ]>;
  63. def SDT_PPCcondbr : SDTypeProfile<0, 3, [
  64. SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
  65. ]>;
  66. def SDT_PPCFtsqrt : SDTypeProfile<1, 1, [
  67. SDTCisVT<0, i32>]>;
  68. def SDT_PPClbrx : SDTypeProfile<1, 2, [
  69. SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
  70. ]>;
  71. def SDT_PPCstbrx : SDTypeProfile<0, 3, [
  72. SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
  73. ]>;
  74. def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
  75. SDTCisPtrTy<0>, SDTCisVT<1, i32>
  76. ]>;
  77. def tocentry32 : Operand<iPTR> {
  78. let MIOperandInfo = (ops i32imm:$imm);
  79. }
  80. def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
  81. SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
  82. ]>;
  83. def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
  84. SDTCisVec<0>, SDTCisInt<1>
  85. ]>;
  86. def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
  87. SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
  88. ]>;
  89. def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
  90. SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
  91. ]>;
  92. def SDT_PPCqbflt : SDTypeProfile<1, 1, [
  93. SDTCisVec<0>, SDTCisVec<1>
  94. ]>;
  95. def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
  96. SDTCisVec<0>, SDTCisPtrTy<1>
  97. ]>;
  98. def SDT_PPCextswsli : SDTypeProfile<1, 2, [ // extswsli
  99. SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisInt<2>
  100. ]>;
  101. def SDT_PPCFPMinMax : SDTypeProfile<1, 2, [
  102. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
  103. ]>;
  104. //===----------------------------------------------------------------------===//
  105. // PowerPC specific DAG Nodes.
  106. //
  107. def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
  108. def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
  109. def PPCfsqrt : SDNode<"PPCISD::FSQRT", SDTFPUnaryOp, []>;
  110. def PPCftsqrt : SDNode<"PPCISD::FTSQRT", SDT_PPCFtsqrt,[]>;
  111. def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
  112. def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
  113. def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
  114. def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
  115. def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
  116. def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
  117. def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
  118. def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
  119. def PPCstrict_fcfid : SDNode<"PPCISD::STRICT_FCFID",
  120. SDTFPUnaryOp, [SDNPHasChain]>;
  121. def PPCstrict_fcfidu : SDNode<"PPCISD::STRICT_FCFIDU",
  122. SDTFPUnaryOp, [SDNPHasChain]>;
  123. def PPCstrict_fcfids : SDNode<"PPCISD::STRICT_FCFIDS",
  124. SDTFPRoundOp, [SDNPHasChain]>;
  125. def PPCstrict_fcfidus : SDNode<"PPCISD::STRICT_FCFIDUS",
  126. SDTFPRoundOp, [SDNPHasChain]>;
  127. def PPCany_fcfid : PatFrags<(ops node:$op),
  128. [(PPCfcfid node:$op),
  129. (PPCstrict_fcfid node:$op)]>;
  130. def PPCany_fcfidu : PatFrags<(ops node:$op),
  131. [(PPCfcfidu node:$op),
  132. (PPCstrict_fcfidu node:$op)]>;
  133. def PPCany_fcfids : PatFrags<(ops node:$op),
  134. [(PPCfcfids node:$op),
  135. (PPCstrict_fcfids node:$op)]>;
  136. def PPCany_fcfidus : PatFrags<(ops node:$op),
  137. [(PPCfcfidus node:$op),
  138. (PPCstrict_fcfidus node:$op)]>;
  139. def PPCcv_fp_to_uint_in_vsr:
  140. SDNode<"PPCISD::FP_TO_UINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
  141. def PPCcv_fp_to_sint_in_vsr:
  142. SDNode<"PPCISD::FP_TO_SINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
  143. def PPCstore_scal_int_from_vsr:
  144. SDNode<"PPCISD::ST_VSR_SCAL_INT", SDT_PPCstore_scal_int_from_vsr,
  145. [SDNPHasChain, SDNPMayStore]>;
  146. def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
  147. [SDNPHasChain, SDNPMayStore]>;
  148. def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
  149. [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
  150. def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
  151. [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
  152. def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
  153. [SDNPHasChain, SDNPMayLoad]>;
  154. def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
  155. [SDNPHasChain, SDNPMayStore]>;
  156. def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
  157. // Extract FPSCR (not modeled at the DAG level).
  158. def PPCmffs : SDNode<"PPCISD::MFFS",
  159. SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>,
  160. [SDNPHasChain]>;
  161. // Perform FADD in round-to-zero mode.
  162. def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
  163. def PPCstrict_faddrtz: SDNode<"PPCISD::STRICT_FADDRTZ", SDTFPBinOp,
  164. [SDNPHasChain]>;
  165. def PPCany_faddrtz: PatFrags<(ops node:$lhs, node:$rhs),
  166. [(PPCfaddrtz node:$lhs, node:$rhs),
  167. (PPCstrict_faddrtz node:$lhs, node:$rhs)]>;
  168. def PPCfsel : SDNode<"PPCISD::FSEL",
  169. // Type constraint for fsel.
  170. SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
  171. SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
  172. def PPCxsmaxc : SDNode<"PPCISD::XSMAXCDP", SDT_PPCFPMinMax, []>;
  173. def PPCxsminc : SDNode<"PPCISD::XSMINCDP", SDT_PPCFPMinMax, []>;
  174. def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
  175. def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
  176. def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
  177. [SDNPMayLoad, SDNPMemOperand]>;
  178. def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
  179. def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
  180. def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
  181. [SDNPMayLoad]>;
  182. def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
  183. def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
  184. def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
  185. def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
  186. def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
  187. SDTypeProfile<1, 3, [
  188. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
  189. SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
  190. def PPCTlsgdAIX : SDNode<"PPCISD::TLSGD_AIX", SDTIntBinOp>;
  191. def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
  192. def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
  193. def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
  194. def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
  195. SDTypeProfile<1, 3, [
  196. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
  197. SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
  198. def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
  199. def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
  200. def PPCpaddiDtprel : SDNode<"PPCISD::PADDI_DTPREL", SDTIntBinOp>;
  201. def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
  202. def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
  203. def PPCxxspltidp : SDNode<"PPCISD::XXSPLTI_SP_TO_DP", SDT_PPCSpToDp, []>;
  204. def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>;
  205. def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>;
  206. def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
  207. def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
  208. // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
  209. // amounts. These nodes are generated by the multi-precision shift code.
  210. def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
  211. def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
  212. def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
  213. def PPCfnmsub : SDNode<"PPCISD::FNMSUB" , SDTFPTernaryOp>;
  214. def PPCextswsli : SDNode<"PPCISD::EXTSWSLI" , SDT_PPCextswsli>;
  215. def PPCstrict_fctidz : SDNode<"PPCISD::STRICT_FCTIDZ",
  216. SDTFPUnaryOp, [SDNPHasChain]>;
  217. def PPCstrict_fctiwz : SDNode<"PPCISD::STRICT_FCTIWZ",
  218. SDTFPUnaryOp, [SDNPHasChain]>;
  219. def PPCstrict_fctiduz : SDNode<"PPCISD::STRICT_FCTIDUZ",
  220. SDTFPUnaryOp, [SDNPHasChain]>;
  221. def PPCstrict_fctiwuz : SDNode<"PPCISD::STRICT_FCTIWUZ",
  222. SDTFPUnaryOp, [SDNPHasChain]>;
  223. def PPCany_fctidz : PatFrags<(ops node:$op),
  224. [(PPCstrict_fctidz node:$op),
  225. (PPCfctidz node:$op)]>;
  226. def PPCany_fctiwz : PatFrags<(ops node:$op),
  227. [(PPCstrict_fctiwz node:$op),
  228. (PPCfctiwz node:$op)]>;
  229. def PPCany_fctiduz : PatFrags<(ops node:$op),
  230. [(PPCstrict_fctiduz node:$op),
  231. (PPCfctiduz node:$op)]>;
  232. def PPCany_fctiwuz : PatFrags<(ops node:$op),
  233. [(PPCstrict_fctiwuz node:$op),
  234. (PPCfctiwuz node:$op)]>;
  235. // Move 2 i64 values into a VSX register
  236. def PPCbuild_fp128: SDNode<"PPCISD::BUILD_FP128",
  237. SDTypeProfile<1, 2,
  238. [SDTCisFP<0>, SDTCisSameSizeAs<1,2>,
  239. SDTCisSameAs<1,2>]>,
  240. []>;
  241. def PPCbuild_spe64: SDNode<"PPCISD::BUILD_SPE64",
  242. SDTypeProfile<1, 2,
  243. [SDTCisVT<0, f64>, SDTCisVT<1,i32>,
  244. SDTCisVT<1,i32>]>,
  245. []>;
  246. def PPCextract_spe : SDNode<"PPCISD::EXTRACT_SPE",
  247. SDTypeProfile<1, 2,
  248. [SDTCisVT<0, i32>, SDTCisVT<1, f64>,
  249. SDTCisPtrTy<2>]>,
  250. []>;
  251. // These are target-independent nodes, but have target-specific formats.
  252. def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
  253. [SDNPHasChain, SDNPOutGlue]>;
  254. def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
  255. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
  256. def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
  257. def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
  258. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  259. SDNPVariadic]>;
  260. def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
  261. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  262. SDNPVariadic]>;
  263. def PPCcall_notoc : SDNode<"PPCISD::CALL_NOTOC", SDT_PPCCall,
  264. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  265. SDNPVariadic]>;
  266. def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
  267. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
  268. def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
  269. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  270. SDNPVariadic]>;
  271. def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
  272. SDTypeProfile<0, 1, []>,
  273. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  274. SDNPVariadic]>;
  275. // Call nodes for strictfp calls (that define RM).
  276. def PPCcall_rm : SDNode<"PPCISD::CALL_RM", SDT_PPCCall,
  277. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  278. SDNPVariadic]>;
  279. def PPCcall_nop_rm : SDNode<"PPCISD::CALL_NOP_RM", SDT_PPCCall,
  280. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  281. SDNPVariadic]>;
  282. def PPCcall_notoc_rm : SDNode<"PPCISD::CALL_NOTOC_RM", SDT_PPCCall,
  283. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  284. SDNPVariadic]>;
  285. def PPCbctrl_rm : SDNode<"PPCISD::BCTRL_RM", SDTNone,
  286. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  287. SDNPVariadic]>;
  288. def PPCbctrl_load_toc_rm : SDNode<"PPCISD::BCTRL_LOAD_TOC_RM",
  289. SDTypeProfile<0, 1, []>,
  290. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
  291. SDNPVariadic]>;
  292. def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
  293. [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
  294. def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
  295. [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
  296. def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
  297. SDTypeProfile<1, 1, [SDTCisInt<0>,
  298. SDTCisPtrTy<1>]>,
  299. [SDNPHasChain, SDNPSideEffect]>;
  300. def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
  301. SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
  302. [SDNPHasChain, SDNPSideEffect]>;
  303. def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
  304. def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
  305. [SDNPHasChain, SDNPSideEffect]>;
  306. def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
  307. [SDNPHasChain, SDNPSideEffect]>;
  308. def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
  309. def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
  310. [SDNPHasChain, SDNPSideEffect]>;
  311. def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
  312. def PPCvcmp_rec : SDNode<"PPCISD::VCMP_rec", SDT_PPCvcmp, [SDNPOutGlue]>;
  313. def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
  314. [SDNPHasChain, SDNPOptInGlue]>;
  315. // PPC-specific atomic operations.
  316. def PPCatomicCmpSwap_8 :
  317. SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3,
  318. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  319. def PPCatomicCmpSwap_16 :
  320. SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3,
  321. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  322. def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
  323. [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
  324. def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
  325. [SDNPHasChain, SDNPMayStore]>;
  326. // Instructions to set/unset CR bit 6 for SVR4 vararg calls
  327. def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
  328. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
  329. def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
  330. [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
  331. // Instructions to support dynamic alloca.
  332. def SDTDynOp : SDTypeProfile<1, 2, []>;
  333. def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
  334. def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
  335. def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
  336. def PPCprobedalloca : SDNode<"PPCISD::PROBED_ALLOCA", SDTDynOp, [SDNPHasChain]>;
  337. // PC Relative Specific Nodes
  338. def PPCmatpcreladdr : SDNode<"PPCISD::MAT_PCREL_ADDR", SDTIntUnaryOp, []>;
  339. def PPCtlsdynamatpcreladdr : SDNode<"PPCISD::TLS_DYNAMIC_MAT_PCREL_ADDR",
  340. SDTIntUnaryOp, []>;
  341. def PPCtlslocalexecmataddr : SDNode<"PPCISD::TLS_LOCAL_EXEC_MAT_ADDR",
  342. SDTIntUnaryOp, []>;
  343. //===----------------------------------------------------------------------===//
  344. // PowerPC specific transformation functions and pattern fragments.
  345. //
  346. // A floating point immediate that is not a positive zero and can be converted
  347. // to a single precision floating point non-denormal immediate without loss of
  348. // information.
  349. def nzFPImmAsi32 : PatLeaf<(fpimm), [{
  350. APFloat APFloatOfN = N->getValueAPF();
  351. return convertToNonDenormSingle(APFloatOfN) && !N->isExactlyValue(+0.0);
  352. }]>;
  353. // Convert the floating point immediate into a 32 bit floating point immediate
  354. // and get a i32 with the resulting bits.
  355. def getFPAs32BitInt : SDNodeXForm<fpimm, [{
  356. APFloat APFloatOfN = N->getValueAPF();
  357. convertToNonDenormSingle(APFloatOfN);
  358. return CurDAG->getTargetConstant(APFloatOfN.bitcastToAPInt().getZExtValue(),
  359. SDLoc(N), MVT::i32);
  360. }]>;
  361. // Check if the value can be converted to be single precision immediate, which
  362. // can be exploited by XXSPLTIDP. Ensure that it cannot be converted to single
  363. // precision before exploiting with XXSPLTI32DX.
  364. def nzFPImmAsi64 : PatLeaf<(fpimm), [{
  365. APFloat APFloatOfN = N->getValueAPF();
  366. return !N->isExactlyValue(+0.0) && !checkConvertToNonDenormSingle(APFloatOfN);
  367. }]>;
  368. // Get the Hi bits of a 64 bit immediate.
  369. def getFPAs64BitIntHi : SDNodeXForm<fpimm, [{
  370. APFloat APFloatOfN = N->getValueAPF();
  371. bool Unused;
  372. APFloatOfN.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
  373. &Unused);
  374. uint32_t Hi = (uint32_t)((APFloatOfN.bitcastToAPInt().getZExtValue() &
  375. 0xFFFFFFFF00000000LL) >> 32);
  376. return CurDAG->getTargetConstant(Hi, SDLoc(N), MVT::i32);
  377. }]>;
  378. // Get the Lo bits of a 64 bit immediate.
  379. def getFPAs64BitIntLo : SDNodeXForm<fpimm, [{
  380. APFloat APFloatOfN = N->getValueAPF();
  381. bool Unused;
  382. APFloatOfN.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
  383. &Unused);
  384. uint32_t Lo = (uint32_t)(APFloatOfN.bitcastToAPInt().getZExtValue() &
  385. 0xFFFFFFFF);
  386. return CurDAG->getTargetConstant(Lo, SDLoc(N), MVT::i32);
  387. }]>;
  388. def imm34 : PatLeaf<(imm), [{
  389. return isInt<34>(N->getSExtValue());
  390. }]>;
  391. def getImmAs64BitInt : SDNodeXForm<imm, [{
  392. return getI64Imm(N->getSExtValue(), SDLoc(N));
  393. }]>;
  394. def SHL32 : SDNodeXForm<imm, [{
  395. // Transformation function: 31 - imm
  396. return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
  397. }]>;
  398. def SRL32 : SDNodeXForm<imm, [{
  399. // Transformation function: 32 - imm
  400. return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
  401. : getI32Imm(0, SDLoc(N));
  402. }]>;
  403. def LO16 : SDNodeXForm<imm, [{
  404. // Transformation function: get the low 16 bits.
  405. return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
  406. }]>;
  407. def HI16 : SDNodeXForm<imm, [{
  408. // Transformation function: shift the immediate value down into the low bits.
  409. return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
  410. }]>;
  411. def HA16 : SDNodeXForm<imm, [{
  412. // Transformation function: shift the immediate value down into the low bits.
  413. long Val = N->getZExtValue();
  414. return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
  415. }]>;
  416. def MB : SDNodeXForm<imm, [{
  417. // Transformation function: get the start bit of a mask
  418. unsigned mb = 0, me;
  419. (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
  420. return getI32Imm(mb, SDLoc(N));
  421. }]>;
  422. def ME : SDNodeXForm<imm, [{
  423. // Transformation function: get the end bit of a mask
  424. unsigned mb, me = 0;
  425. (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
  426. return getI32Imm(me, SDLoc(N));
  427. }]>;
  428. def maskimm32 : PatLeaf<(imm), [{
  429. // maskImm predicate - True if immediate is a run of ones.
  430. unsigned mb, me;
  431. if (N->getValueType(0) == MVT::i32)
  432. return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
  433. else
  434. return false;
  435. }]>;
  436. def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
  437. // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
  438. // sign extended field. Used by instructions like 'addi'.
  439. return (int32_t)Imm == (short)Imm;
  440. }]>;
  441. def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
  442. // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
  443. // sign extended field. Used by instructions like 'addi'.
  444. return (int64_t)Imm == (short)Imm;
  445. }]>;
  446. def immZExt16 : PatLeaf<(imm), [{
  447. // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
  448. // field. Used by instructions like 'ori'.
  449. return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
  450. }], LO16>;
  451. def immNonAllOneAnyExt8 : ImmLeaf<i32, [{
  452. return (isInt<8>(Imm) && (Imm != -1)) || (isUInt<8>(Imm) && (Imm != 0xFF));
  453. }]>;
  454. def i32immNonAllOneNonZero : ImmLeaf<i32, [{ return Imm && (Imm != -1); }]>;
  455. def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
  456. // imm16Shifted* - These match immediates where the low 16-bits are zero. There
  457. // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
  458. // identical in 32-bit mode, but in 64-bit mode, they return true if the
  459. // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
  460. // clear).
  461. def imm16ShiftedZExt : PatLeaf<(imm), [{
  462. // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
  463. // immediate are set. Used by instructions like 'xoris'.
  464. return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
  465. }], HI16>;
  466. def imm16ShiftedSExt : PatLeaf<(imm), [{
  467. // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
  468. // immediate are set. Used by instructions like 'addis'. Identical to
  469. // imm16ShiftedZExt in 32-bit mode.
  470. if (N->getZExtValue() & 0xFFFF) return false;
  471. if (N->getValueType(0) == MVT::i32)
  472. return true;
  473. // For 64-bit, make sure it is sext right.
  474. return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
  475. }], HI16>;
  476. def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
  477. // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
  478. // zero extended field.
  479. return isUInt<32>(Imm);
  480. }]>;
  481. // This is a somewhat weaker condition than actually checking for 4-byte
  482. // alignment. It is simply checking that the displacement can be represented
  483. // as an immediate that is a multiple of 4 (i.e. the requirements for DS-Form
  484. // instructions).
  485. // But some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
  486. // restricted memrix (4-aligned) constants are alignment sensitive. If these
  487. // offsets are hidden behind TOC entries than the values of the lower-order
  488. // bits cannot be checked directly. As a result, we need to also incorporate
  489. // an alignment check into the relevant patterns.
  490. def DSFormLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  491. return isOffsetMultipleOf(N, 4) || cast<LoadSDNode>(N)->getAlignment() >= 4;
  492. }]>;
  493. def DSFormStore : PatFrag<(ops node:$val, node:$ptr),
  494. (store node:$val, node:$ptr), [{
  495. return isOffsetMultipleOf(N, 4) || cast<StoreSDNode>(N)->getAlignment() >= 4;
  496. }]>;
  497. def DSFormSextLoadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
  498. return isOffsetMultipleOf(N, 4) || cast<LoadSDNode>(N)->getAlignment() >= 4;
  499. }]>;
  500. def DSFormPreStore : PatFrag<
  501. (ops node:$val, node:$base, node:$offset),
  502. (pre_store node:$val, node:$base, node:$offset), [{
  503. return isOffsetMultipleOf(N, 4) || cast<StoreSDNode>(N)->getAlignment() >= 4;
  504. }]>;
  505. def NonDSFormLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  506. return cast<LoadSDNode>(N)->getAlignment() < 4 && !isOffsetMultipleOf(N, 4);
  507. }]>;
  508. def NonDSFormStore : PatFrag<(ops node:$val, node:$ptr),
  509. (store node:$val, node:$ptr), [{
  510. return cast<StoreSDNode>(N)->getAlignment() < 4 && !isOffsetMultipleOf(N, 4);
  511. }]>;
  512. def NonDSFormSextLoadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
  513. return cast<LoadSDNode>(N)->getAlignment() < 4 && !isOffsetMultipleOf(N, 4);
  514. }]>;
  515. // This is a somewhat weaker condition than actually checking for 16-byte
  516. // alignment. It is simply checking that the displacement can be represented
  517. // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
  518. // instructions).
  519. def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  520. return isOffsetMultipleOf(N, 16);
  521. }]>;
  522. def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
  523. (store node:$val, node:$ptr), [{
  524. return isOffsetMultipleOf(N, 16);
  525. }]>;
  526. def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  527. return !isOffsetMultipleOf(N, 16);
  528. }]>;
  529. def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
  530. (store node:$val, node:$ptr), [{
  531. return !isOffsetMultipleOf(N, 16);
  532. }]>;
  533. // PatFrag for binary operation whose operands are both non-constant
  534. class BinOpWithoutSImm16Operand<SDNode opcode> :
  535. PatFrag<(ops node:$left, node:$right), (opcode node:$left, node:$right), [{
  536. int16_t Imm;
  537. return !isIntS16Immediate(N->getOperand(0), Imm)
  538. && !isIntS16Immediate(N->getOperand(1), Imm);
  539. }]>;
  540. def add_without_simm16 : BinOpWithoutSImm16Operand<add>;
  541. def mul_without_simm16 : BinOpWithoutSImm16Operand<mul>;
  542. //===----------------------------------------------------------------------===//
  543. // PowerPC Flag Definitions.
  544. class isPPC64 { bit PPC64 = 1; }
  545. class isRecordForm { bit RC = 1; }
  546. class RegConstraint<string C> {
  547. string Constraints = C;
  548. }
  549. class NoEncode<string E> {
  550. string DisableEncoding = E;
  551. }
  552. //===----------------------------------------------------------------------===//
  553. // PowerPC Operand Definitions.
  554. // In the default PowerPC assembler syntax, registers are specified simply
  555. // by number, so they cannot be distinguished from immediate values (without
  556. // looking at the opcode). This means that the default operand matching logic
  557. // for the asm parser does not work, and we need to specify custom matchers.
  558. // Since those can only be specified with RegisterOperand classes and not
  559. // directly on the RegisterClass, all instructions patterns used by the asm
  560. // parser need to use a RegisterOperand (instead of a RegisterClass) for
  561. // all their register operands.
  562. // For this purpose, we define one RegisterOperand for each RegisterClass,
  563. // using the same name as the class, just in lower case.
  564. def PPCRegGPRCAsmOperand : AsmOperandClass {
  565. let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
  566. }
  567. def gprc : RegisterOperand<GPRC> {
  568. let ParserMatchClass = PPCRegGPRCAsmOperand;
  569. }
  570. def PPCRegG8RCAsmOperand : AsmOperandClass {
  571. let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
  572. }
  573. def g8rc : RegisterOperand<G8RC> {
  574. let ParserMatchClass = PPCRegG8RCAsmOperand;
  575. }
  576. def PPCRegG8pRCAsmOperand : AsmOperandClass {
  577. let Name = "RegG8pRC"; let PredicateMethod = "isEvenRegNumber";
  578. }
  579. def g8prc : RegisterOperand<G8pRC> {
  580. let ParserMatchClass = PPCRegG8pRCAsmOperand;
  581. }
  582. def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
  583. let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
  584. }
  585. def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
  586. let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
  587. }
  588. def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
  589. let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
  590. }
  591. def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
  592. let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
  593. }
  594. def PPCRegF8RCAsmOperand : AsmOperandClass {
  595. let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
  596. }
  597. def f8rc : RegisterOperand<F8RC> {
  598. let ParserMatchClass = PPCRegF8RCAsmOperand;
  599. }
  600. def PPCRegF4RCAsmOperand : AsmOperandClass {
  601. let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
  602. }
  603. def f4rc : RegisterOperand<F4RC> {
  604. let ParserMatchClass = PPCRegF4RCAsmOperand;
  605. }
  606. def PPCRegVRRCAsmOperand : AsmOperandClass {
  607. let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
  608. }
  609. def vrrc : RegisterOperand<VRRC> {
  610. let ParserMatchClass = PPCRegVRRCAsmOperand;
  611. }
  612. def PPCRegVFRCAsmOperand : AsmOperandClass {
  613. let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
  614. }
  615. def vfrc : RegisterOperand<VFRC> {
  616. let ParserMatchClass = PPCRegVFRCAsmOperand;
  617. }
  618. def PPCRegCRBITRCAsmOperand : AsmOperandClass {
  619. let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
  620. }
  621. def crbitrc : RegisterOperand<CRBITRC> {
  622. let ParserMatchClass = PPCRegCRBITRCAsmOperand;
  623. }
  624. def PPCRegCRRCAsmOperand : AsmOperandClass {
  625. let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
  626. }
  627. def crrc : RegisterOperand<CRRC> {
  628. let ParserMatchClass = PPCRegCRRCAsmOperand;
  629. }
  630. def PPCRegSPERCAsmOperand : AsmOperandClass {
  631. let Name = "RegSPERC"; let PredicateMethod = "isRegNumber";
  632. }
  633. def sperc : RegisterOperand<SPERC> {
  634. let ParserMatchClass = PPCRegSPERCAsmOperand;
  635. }
  636. def PPCRegSPE4RCAsmOperand : AsmOperandClass {
  637. let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber";
  638. }
  639. def spe4rc : RegisterOperand<GPRC> {
  640. let ParserMatchClass = PPCRegSPE4RCAsmOperand;
  641. }
  642. def PPCU1ImmAsmOperand : AsmOperandClass {
  643. let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
  644. let RenderMethod = "addImmOperands";
  645. }
  646. def u1imm : Operand<i32> {
  647. let PrintMethod = "printU1ImmOperand";
  648. let ParserMatchClass = PPCU1ImmAsmOperand;
  649. let OperandType = "OPERAND_IMMEDIATE";
  650. }
  651. def PPCU2ImmAsmOperand : AsmOperandClass {
  652. let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
  653. let RenderMethod = "addImmOperands";
  654. }
  655. def u2imm : Operand<i32> {
  656. let PrintMethod = "printU2ImmOperand";
  657. let ParserMatchClass = PPCU2ImmAsmOperand;
  658. let OperandType = "OPERAND_IMMEDIATE";
  659. }
  660. def PPCATBitsAsHintAsmOperand : AsmOperandClass {
  661. let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
  662. let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
  663. }
  664. def atimm : Operand<i32> {
  665. let PrintMethod = "printATBitsAsHint";
  666. let ParserMatchClass = PPCATBitsAsHintAsmOperand;
  667. let OperandType = "OPERAND_IMMEDIATE";
  668. }
  669. def PPCU3ImmAsmOperand : AsmOperandClass {
  670. let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
  671. let RenderMethod = "addImmOperands";
  672. }
  673. def u3imm : Operand<i32> {
  674. let PrintMethod = "printU3ImmOperand";
  675. let ParserMatchClass = PPCU3ImmAsmOperand;
  676. let OperandType = "OPERAND_IMMEDIATE";
  677. }
  678. def PPCU4ImmAsmOperand : AsmOperandClass {
  679. let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
  680. let RenderMethod = "addImmOperands";
  681. }
  682. def u4imm : Operand<i32> {
  683. let PrintMethod = "printU4ImmOperand";
  684. let ParserMatchClass = PPCU4ImmAsmOperand;
  685. let OperandType = "OPERAND_IMMEDIATE";
  686. }
  687. def PPCS5ImmAsmOperand : AsmOperandClass {
  688. let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
  689. let RenderMethod = "addImmOperands";
  690. }
  691. def s5imm : Operand<i32> {
  692. let PrintMethod = "printS5ImmOperand";
  693. let ParserMatchClass = PPCS5ImmAsmOperand;
  694. let DecoderMethod = "decodeSImmOperand<5>";
  695. let OperandType = "OPERAND_IMMEDIATE";
  696. }
  697. def PPCU5ImmAsmOperand : AsmOperandClass {
  698. let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
  699. let RenderMethod = "addImmOperands";
  700. }
  701. def u5imm : Operand<i32> {
  702. let PrintMethod = "printU5ImmOperand";
  703. let ParserMatchClass = PPCU5ImmAsmOperand;
  704. let DecoderMethod = "decodeUImmOperand<5>";
  705. let OperandType = "OPERAND_IMMEDIATE";
  706. }
  707. def PPCU6ImmAsmOperand : AsmOperandClass {
  708. let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
  709. let RenderMethod = "addImmOperands";
  710. }
  711. def u6imm : Operand<i32> {
  712. let PrintMethod = "printU6ImmOperand";
  713. let ParserMatchClass = PPCU6ImmAsmOperand;
  714. let DecoderMethod = "decodeUImmOperand<6>";
  715. let OperandType = "OPERAND_IMMEDIATE";
  716. }
  717. def PPCU7ImmAsmOperand : AsmOperandClass {
  718. let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
  719. let RenderMethod = "addImmOperands";
  720. }
  721. def u7imm : Operand<i32> {
  722. let PrintMethod = "printU7ImmOperand";
  723. let ParserMatchClass = PPCU7ImmAsmOperand;
  724. let DecoderMethod = "decodeUImmOperand<7>";
  725. let OperandType = "OPERAND_IMMEDIATE";
  726. }
  727. def PPCU8ImmAsmOperand : AsmOperandClass {
  728. let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
  729. let RenderMethod = "addImmOperands";
  730. }
  731. def u8imm : Operand<i32> {
  732. let PrintMethod = "printU8ImmOperand";
  733. let ParserMatchClass = PPCU8ImmAsmOperand;
  734. let DecoderMethod = "decodeUImmOperand<8>";
  735. let OperandType = "OPERAND_IMMEDIATE";
  736. }
  737. def PPCU10ImmAsmOperand : AsmOperandClass {
  738. let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
  739. let RenderMethod = "addImmOperands";
  740. }
  741. def u10imm : Operand<i32> {
  742. let PrintMethod = "printU10ImmOperand";
  743. let ParserMatchClass = PPCU10ImmAsmOperand;
  744. let DecoderMethod = "decodeUImmOperand<10>";
  745. let OperandType = "OPERAND_IMMEDIATE";
  746. }
  747. def PPCU12ImmAsmOperand : AsmOperandClass {
  748. let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
  749. let RenderMethod = "addImmOperands";
  750. }
  751. def u12imm : Operand<i32> {
  752. let PrintMethod = "printU12ImmOperand";
  753. let ParserMatchClass = PPCU12ImmAsmOperand;
  754. let DecoderMethod = "decodeUImmOperand<12>";
  755. let OperandType = "OPERAND_IMMEDIATE";
  756. }
  757. def PPCS16ImmAsmOperand : AsmOperandClass {
  758. let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
  759. let RenderMethod = "addS16ImmOperands";
  760. }
  761. def s16imm : Operand<i32> {
  762. let PrintMethod = "printS16ImmOperand";
  763. let EncoderMethod = "getImm16Encoding";
  764. let ParserMatchClass = PPCS16ImmAsmOperand;
  765. let DecoderMethod = "decodeSImmOperand<16>";
  766. let OperandType = "OPERAND_IMMEDIATE";
  767. }
  768. def PPCU16ImmAsmOperand : AsmOperandClass {
  769. let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
  770. let RenderMethod = "addU16ImmOperands";
  771. }
  772. def u16imm : Operand<i32> {
  773. let PrintMethod = "printU16ImmOperand";
  774. let EncoderMethod = "getImm16Encoding";
  775. let ParserMatchClass = PPCU16ImmAsmOperand;
  776. let DecoderMethod = "decodeUImmOperand<16>";
  777. let OperandType = "OPERAND_IMMEDIATE";
  778. }
  779. def PPCS17ImmAsmOperand : AsmOperandClass {
  780. let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
  781. let RenderMethod = "addS16ImmOperands";
  782. }
  783. def s17imm : Operand<i32> {
  784. // This operand type is used for addis/lis to allow the assembler parser
  785. // to accept immediates in the range -65536..65535 for compatibility with
  786. // the GNU assembler. The operand is treated as 16-bit otherwise.
  787. let PrintMethod = "printS16ImmOperand";
  788. let EncoderMethod = "getImm16Encoding";
  789. let ParserMatchClass = PPCS17ImmAsmOperand;
  790. let DecoderMethod = "decodeSImmOperand<16>";
  791. let OperandType = "OPERAND_IMMEDIATE";
  792. }
  793. def PPCS34ImmAsmOperand : AsmOperandClass {
  794. let Name = "S34Imm";
  795. let PredicateMethod = "isS34Imm";
  796. let RenderMethod = "addImmOperands";
  797. }
  798. def s34imm : Operand<i64> {
  799. let PrintMethod = "printS34ImmOperand";
  800. let EncoderMethod = "getImm34EncodingNoPCRel";
  801. let ParserMatchClass = PPCS34ImmAsmOperand;
  802. let DecoderMethod = "decodeSImmOperand<34>";
  803. let OperandType = "OPERAND_IMMEDIATE";
  804. }
  805. def s34imm_pcrel : Operand<i64> {
  806. let PrintMethod = "printS34ImmOperand";
  807. let EncoderMethod = "getImm34EncodingPCRel";
  808. let ParserMatchClass = PPCS34ImmAsmOperand;
  809. let DecoderMethod = "decodeSImmOperand<34>";
  810. let OperandType = "OPERAND_IMMEDIATE";
  811. }
  812. def PPCImmZeroAsmOperand : AsmOperandClass {
  813. let Name = "ImmZero";
  814. let PredicateMethod = "isImmZero";
  815. let RenderMethod = "addImmOperands";
  816. }
  817. def immZero : Operand<i32> {
  818. let PrintMethod = "printImmZeroOperand";
  819. let ParserMatchClass = PPCImmZeroAsmOperand;
  820. let DecoderMethod = "decodeImmZeroOperand";
  821. let OperandType = "OPERAND_IMMEDIATE";
  822. }
  823. def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
  824. def PPCDirectBrAsmOperand : AsmOperandClass {
  825. let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
  826. let RenderMethod = "addBranchTargetOperands";
  827. }
  828. def directbrtarget : Operand<OtherVT> {
  829. let PrintMethod = "printBranchOperand";
  830. let EncoderMethod = "getDirectBrEncoding";
  831. let DecoderMethod = "decodeDirectBrTarget";
  832. let ParserMatchClass = PPCDirectBrAsmOperand;
  833. let OperandType = "OPERAND_PCREL";
  834. }
  835. def absdirectbrtarget : Operand<OtherVT> {
  836. let PrintMethod = "printAbsBranchOperand";
  837. let EncoderMethod = "getAbsDirectBrEncoding";
  838. let ParserMatchClass = PPCDirectBrAsmOperand;
  839. }
  840. def PPCCondBrAsmOperand : AsmOperandClass {
  841. let Name = "CondBr"; let PredicateMethod = "isCondBr";
  842. let RenderMethod = "addBranchTargetOperands";
  843. }
  844. def condbrtarget : Operand<OtherVT> {
  845. let PrintMethod = "printBranchOperand";
  846. let EncoderMethod = "getCondBrEncoding";
  847. let DecoderMethod = "decodeCondBrTarget";
  848. let ParserMatchClass = PPCCondBrAsmOperand;
  849. let OperandType = "OPERAND_PCREL";
  850. }
  851. def abscondbrtarget : Operand<OtherVT> {
  852. let PrintMethod = "printAbsBranchOperand";
  853. let EncoderMethod = "getAbsCondBrEncoding";
  854. let ParserMatchClass = PPCCondBrAsmOperand;
  855. }
  856. def calltarget : Operand<iPTR> {
  857. let PrintMethod = "printBranchOperand";
  858. let EncoderMethod = "getDirectBrEncoding";
  859. let DecoderMethod = "decodeDirectBrTarget";
  860. let ParserMatchClass = PPCDirectBrAsmOperand;
  861. let OperandType = "OPERAND_PCREL";
  862. }
  863. def abscalltarget : Operand<iPTR> {
  864. let PrintMethod = "printAbsBranchOperand";
  865. let EncoderMethod = "getAbsDirectBrEncoding";
  866. let ParserMatchClass = PPCDirectBrAsmOperand;
  867. }
  868. def PPCCRBitMaskOperand : AsmOperandClass {
  869. let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
  870. }
  871. def crbitm: Operand<i8> {
  872. let PrintMethod = "printcrbitm";
  873. let EncoderMethod = "get_crbitm_encoding";
  874. let DecoderMethod = "decodeCRBitMOperand";
  875. let ParserMatchClass = PPCCRBitMaskOperand;
  876. }
  877. // Address operands
  878. // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
  879. def PPCRegGxRCNoR0Operand : AsmOperandClass {
  880. let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
  881. }
  882. def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
  883. let ParserMatchClass = PPCRegGxRCNoR0Operand;
  884. }
  885. // New addressing modes with 34 bit immediates.
  886. def PPCDispRI34Operand : AsmOperandClass {
  887. let Name = "DispRI34"; let PredicateMethod = "isS34Imm";
  888. let RenderMethod = "addImmOperands";
  889. }
  890. def dispRI34 : Operand<iPTR> {
  891. let ParserMatchClass = PPCDispRI34Operand;
  892. }
  893. def memri34 : Operand<iPTR> { // memri, imm is a 34-bit value.
  894. let PrintMethod = "printMemRegImm34";
  895. let MIOperandInfo = (ops dispRI34:$imm, ptr_rc_nor0:$reg);
  896. let EncoderMethod = "getMemRI34Encoding";
  897. let DecoderMethod = "decodeMemRI34Operands";
  898. }
  899. // memri, imm is a 34-bit value for pc-relative instructions where
  900. // base register is set to zero.
  901. def memri34_pcrel : Operand<iPTR> { // memri, imm is a 34-bit value.
  902. let PrintMethod = "printMemRegImm34PCRel";
  903. let MIOperandInfo = (ops dispRI34:$imm, immZero:$reg);
  904. let EncoderMethod = "getMemRI34PCRelEncoding";
  905. let DecoderMethod = "decodeMemRI34PCRelOperands";
  906. }
  907. // A version of ptr_rc usable with the asm parser.
  908. def PPCRegGxRCOperand : AsmOperandClass {
  909. let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
  910. }
  911. def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
  912. let ParserMatchClass = PPCRegGxRCOperand;
  913. }
  914. def PPCDispRIOperand : AsmOperandClass {
  915. let Name = "DispRI"; let PredicateMethod = "isS16Imm";
  916. let RenderMethod = "addS16ImmOperands";
  917. }
  918. def dispRI : Operand<iPTR> {
  919. let ParserMatchClass = PPCDispRIOperand;
  920. }
  921. def PPCDispRIXOperand : AsmOperandClass {
  922. let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
  923. let RenderMethod = "addS16ImmOperands";
  924. }
  925. def dispRIX : Operand<iPTR> {
  926. let ParserMatchClass = PPCDispRIXOperand;
  927. }
  928. def PPCDispRIHashOperand : AsmOperandClass {
  929. let Name = "DispRIHash"; let PredicateMethod = "isHashImmX8";
  930. let RenderMethod = "addImmOperands";
  931. }
  932. def dispRIHash : Operand<iPTR> {
  933. let ParserMatchClass = PPCDispRIHashOperand;
  934. }
  935. def PPCDispRIX16Operand : AsmOperandClass {
  936. let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
  937. let RenderMethod = "addS16ImmOperands";
  938. }
  939. def dispRIX16 : Operand<iPTR> {
  940. let ParserMatchClass = PPCDispRIX16Operand;
  941. }
  942. def PPCDispSPE8Operand : AsmOperandClass {
  943. let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
  944. let RenderMethod = "addImmOperands";
  945. }
  946. def dispSPE8 : Operand<iPTR> {
  947. let ParserMatchClass = PPCDispSPE8Operand;
  948. }
  949. def PPCDispSPE4Operand : AsmOperandClass {
  950. let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
  951. let RenderMethod = "addImmOperands";
  952. }
  953. def dispSPE4 : Operand<iPTR> {
  954. let ParserMatchClass = PPCDispSPE4Operand;
  955. }
  956. def PPCDispSPE2Operand : AsmOperandClass {
  957. let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
  958. let RenderMethod = "addImmOperands";
  959. }
  960. def dispSPE2 : Operand<iPTR> {
  961. let ParserMatchClass = PPCDispSPE2Operand;
  962. }
  963. def memri : Operand<iPTR> {
  964. let PrintMethod = "printMemRegImm";
  965. let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
  966. let EncoderMethod = "getMemRIEncoding";
  967. let DecoderMethod = "decodeMemRIOperands";
  968. let OperandType = "OPERAND_MEMORY";
  969. }
  970. def memrr : Operand<iPTR> {
  971. let PrintMethod = "printMemRegReg";
  972. let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
  973. let OperandType = "OPERAND_MEMORY";
  974. }
  975. def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
  976. let PrintMethod = "printMemRegImm";
  977. let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
  978. let EncoderMethod = "getMemRIXEncoding";
  979. let DecoderMethod = "decodeMemRIXOperands";
  980. let OperandType = "OPERAND_MEMORY";
  981. }
  982. def memrihash : Operand<iPTR> {
  983. // memrihash 8-aligned for ROP Protection Instructions.
  984. let PrintMethod = "printMemRegImmHash";
  985. let MIOperandInfo = (ops dispRIHash:$imm, ptr_rc_nor0:$reg);
  986. let EncoderMethod = "getMemRIHashEncoding";
  987. let DecoderMethod = "decodeMemRIHashOperands";
  988. let OperandType = "OPERAND_MEMORY";
  989. }
  990. def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
  991. let PrintMethod = "printMemRegImm";
  992. let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
  993. let EncoderMethod = "getMemRIX16Encoding";
  994. let DecoderMethod = "decodeMemRIX16Operands";
  995. let OperandType = "OPERAND_MEMORY";
  996. }
  997. def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
  998. let PrintMethod = "printMemRegImm";
  999. let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
  1000. let EncoderMethod = "getSPE8DisEncoding";
  1001. let DecoderMethod = "decodeSPE8Operands";
  1002. let OperandType = "OPERAND_MEMORY";
  1003. }
  1004. def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
  1005. let PrintMethod = "printMemRegImm";
  1006. let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
  1007. let EncoderMethod = "getSPE4DisEncoding";
  1008. let DecoderMethod = "decodeSPE4Operands";
  1009. let OperandType = "OPERAND_MEMORY";
  1010. }
  1011. def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
  1012. let PrintMethod = "printMemRegImm";
  1013. let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
  1014. let EncoderMethod = "getSPE2DisEncoding";
  1015. let DecoderMethod = "decodeSPE2Operands";
  1016. let OperandType = "OPERAND_MEMORY";
  1017. }
  1018. // A single-register address. This is used with the SjLj
  1019. // pseudo-instructions which translates to LD/LWZ. These instructions requires
  1020. // G8RC_NOX0 registers.
  1021. def memr : Operand<iPTR> {
  1022. let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
  1023. let OperandType = "OPERAND_MEMORY";
  1024. }
  1025. def PPCTLSRegOperand : AsmOperandClass {
  1026. let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
  1027. let RenderMethod = "addTLSRegOperands";
  1028. }
  1029. def tlsreg32 : Operand<i32> {
  1030. let EncoderMethod = "getTLSRegEncoding";
  1031. let ParserMatchClass = PPCTLSRegOperand;
  1032. }
  1033. def tlsgd32 : Operand<i32> {}
  1034. def tlscall32 : Operand<i32> {
  1035. let PrintMethod = "printTLSCall";
  1036. let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
  1037. let EncoderMethod = "getTLSCallEncoding";
  1038. }
  1039. // PowerPC Predicate operand.
  1040. def pred : Operand<OtherVT> {
  1041. let PrintMethod = "printPredicateOperand";
  1042. let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
  1043. }
  1044. // Define PowerPC specific addressing mode.
  1045. // d-form
  1046. def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>; // "stb"
  1047. // ds-form
  1048. def iaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
  1049. // dq-form
  1050. def iaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
  1051. // 8LS:d-form
  1052. def iaddrX34 : ComplexPattern<iPTR, 2, "SelectAddrImmX34", [], []>; // "pstxvp"
  1053. // Below forms are all x-form addressing mode, use three different ones so we
  1054. // can make a accurate check for x-form instructions in ISEL.
  1055. // x-form addressing mode whose associated displacement form is D.
  1056. def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>; // "stbx"
  1057. // x-form addressing mode whose associated displacement form is DS.
  1058. def xaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrIdxX4", [], []>; // "stdx"
  1059. // x-form addressing mode whose associated displacement form is DQ.
  1060. def xaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrIdxX16", [], []>; // "stxvx"
  1061. def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
  1062. // The address in a single register. This is used with the SjLj
  1063. // pseudo-instructions.
  1064. def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
  1065. /// This is just the offset part of iaddr, used for preinc.
  1066. def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
  1067. // Load and Store Instruction Selection addressing modes.
  1068. def DForm : ComplexPattern<iPTR, 2, "SelectDForm", [], [SDNPWantParent]>;
  1069. def DSForm : ComplexPattern<iPTR, 2, "SelectDSForm", [], [SDNPWantParent]>;
  1070. def DQForm : ComplexPattern<iPTR, 2, "SelectDQForm", [], [SDNPWantParent]>;
  1071. def XForm : ComplexPattern<iPTR, 2, "SelectXForm", [], [SDNPWantParent]>;
  1072. def ForceXForm : ComplexPattern<iPTR, 2, "SelectForceXForm", [], [SDNPWantParent]>;
  1073. def PCRelForm : ComplexPattern<iPTR, 2, "SelectPCRelForm", [], [SDNPWantParent]>;
  1074. def PDForm : ComplexPattern<iPTR, 2, "SelectPDForm", [], [SDNPWantParent]>;
  1075. //===----------------------------------------------------------------------===//
  1076. // PowerPC Instruction Predicate Definitions.
  1077. def In32BitMode : Predicate<"!Subtarget->isPPC64()">;
  1078. def In64BitMode : Predicate<"Subtarget->isPPC64()">;
  1079. def IsBookE : Predicate<"Subtarget->isBookE()">;
  1080. def IsNotBookE : Predicate<"!Subtarget->isBookE()">;
  1081. def HasOnlyMSYNC : Predicate<"Subtarget->hasOnlyMSYNC()">;
  1082. def HasSYNC : Predicate<"!Subtarget->hasOnlyMSYNC()">;
  1083. def IsPPC4xx : Predicate<"Subtarget->isPPC4xx()">;
  1084. def IsPPC6xx : Predicate<"Subtarget->isPPC6xx()">;
  1085. def IsE500 : Predicate<"Subtarget->isE500()">;
  1086. def HasSPE : Predicate<"Subtarget->hasSPE()">;
  1087. def HasICBT : Predicate<"Subtarget->hasICBT()">;
  1088. def HasPartwordAtomics : Predicate<"Subtarget->hasPartwordAtomics()">;
  1089. def HasQuadwordAtomics : Predicate<"Subtarget->hasQuadwordAtomics()">;
  1090. def NoNaNsFPMath
  1091. : Predicate<"Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
  1092. def NaNsFPMath
  1093. : Predicate<"!Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
  1094. def HasBPERMD : Predicate<"Subtarget->hasBPERMD()">;
  1095. def HasExtDiv : Predicate<"Subtarget->hasExtDiv()">;
  1096. def IsISA2_06 : Predicate<"Subtarget->isISA2_06()">;
  1097. def IsISA2_07 : Predicate<"Subtarget->isISA2_07()">;
  1098. def IsISA3_0 : Predicate<"Subtarget->isISA3_0()">;
  1099. def HasFPU : Predicate<"Subtarget->hasFPU()">;
  1100. def PCRelativeMemops : Predicate<"Subtarget->hasPCRelativeMemops()">;
  1101. def IsNotISA3_1 : Predicate<"!Subtarget->isISA3_1()">;
  1102. // AIX assembler may not be modern enough to support some extended mne.
  1103. def ModernAs: Predicate<"!Subtarget->isAIXABI() || Subtarget->HasModernAIXAs">,
  1104. AssemblerPredicate<(any_of (not AIXOS), FeatureModernAIXAs)>;
  1105. def IsAIX : Predicate<"Subtarget->isAIXABI()">;
  1106. def NotAIX : Predicate<"!Subtarget->isAIXABI()">;
  1107. //===----------------------------------------------------------------------===//
  1108. // PowerPC Multiclass Definitions.
  1109. multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  1110. string asmbase, string asmstr, InstrItinClass itin,
  1111. list<dag> pattern> {
  1112. let BaseName = asmbase in {
  1113. def NAME : XForm_6<opcode, xo, OOL, IOL,
  1114. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1115. pattern>, RecFormRel;
  1116. let Defs = [CR0] in
  1117. def _rec : XForm_6<opcode, xo, OOL, IOL,
  1118. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1119. []>, isRecordForm, RecFormRel;
  1120. }
  1121. }
  1122. multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  1123. string asmbase, string asmstr, InstrItinClass itin,
  1124. list<dag> pattern> {
  1125. let BaseName = asmbase in {
  1126. let Defs = [CARRY] in
  1127. def NAME : XForm_6<opcode, xo, OOL, IOL,
  1128. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1129. pattern>, RecFormRel;
  1130. let Defs = [CARRY, CR0] in
  1131. def _rec : XForm_6<opcode, xo, OOL, IOL,
  1132. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1133. []>, isRecordForm, RecFormRel;
  1134. }
  1135. }
  1136. multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  1137. string asmbase, string asmstr, InstrItinClass itin,
  1138. list<dag> pattern> {
  1139. let BaseName = asmbase in {
  1140. let Defs = [CARRY] in
  1141. def NAME : XForm_10<opcode, xo, OOL, IOL,
  1142. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1143. pattern>, RecFormRel;
  1144. let Defs = [CARRY, CR0] in
  1145. def _rec : XForm_10<opcode, xo, OOL, IOL,
  1146. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1147. []>, isRecordForm, RecFormRel;
  1148. }
  1149. }
  1150. multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  1151. string asmbase, string asmstr, InstrItinClass itin,
  1152. list<dag> pattern> {
  1153. let BaseName = asmbase in {
  1154. def NAME : XForm_11<opcode, xo, OOL, IOL,
  1155. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1156. pattern>, RecFormRel;
  1157. let Defs = [CR0] in
  1158. def _rec : XForm_11<opcode, xo, OOL, IOL,
  1159. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1160. []>, isRecordForm, RecFormRel;
  1161. }
  1162. }
  1163. multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
  1164. string asmbase, string asmstr, InstrItinClass itin,
  1165. list<dag> pattern> {
  1166. let BaseName = asmbase in {
  1167. def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
  1168. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1169. pattern>, RecFormRel;
  1170. let Defs = [CR0] in
  1171. def _rec : XOForm_1<opcode, xo, oe, OOL, IOL,
  1172. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1173. []>, isRecordForm, RecFormRel;
  1174. }
  1175. }
  1176. // Multiclass for instructions which have a record overflow form as well
  1177. // as a record form but no carry (i.e. mulld, mulldo, subf, subfo, etc.)
  1178. multiclass XOForm_1rx<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
  1179. string asmbase, string asmstr, InstrItinClass itin,
  1180. list<dag> pattern> {
  1181. let BaseName = asmbase in {
  1182. def NAME : XOForm_1<opcode, xo, 0, OOL, IOL,
  1183. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1184. pattern>, RecFormRel;
  1185. let Defs = [CR0] in
  1186. def _rec : XOForm_1<opcode, xo, 0, OOL, IOL,
  1187. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1188. []>, isRecordForm, RecFormRel;
  1189. }
  1190. let BaseName = !strconcat(asmbase, "O") in {
  1191. let Defs = [XER] in
  1192. def O : XOForm_1<opcode, xo, 1, OOL, IOL,
  1193. !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
  1194. []>, RecFormRel;
  1195. let Defs = [XER, CR0] in
  1196. def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL,
  1197. !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
  1198. []>, isRecordForm, RecFormRel;
  1199. }
  1200. }
  1201. // Multiclass for instructions for which the non record form is not cracked
  1202. // and the record form is cracked (i.e. divw, mullw, etc.)
  1203. multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
  1204. string asmbase, string asmstr, InstrItinClass itin,
  1205. list<dag> pattern> {
  1206. let BaseName = asmbase in {
  1207. def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
  1208. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1209. pattern>, RecFormRel;
  1210. let Defs = [CR0] in
  1211. def _rec : XOForm_1<opcode, xo, oe, OOL, IOL,
  1212. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1213. []>, isRecordForm, RecFormRel, PPC970_DGroup_First,
  1214. PPC970_DGroup_Cracked;
  1215. }
  1216. let BaseName = !strconcat(asmbase, "O") in {
  1217. let Defs = [XER] in
  1218. def O : XOForm_1<opcode, xo, 1, OOL, IOL,
  1219. !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
  1220. []>, RecFormRel;
  1221. let Defs = [XER, CR0] in
  1222. def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL,
  1223. !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
  1224. []>, isRecordForm, RecFormRel;
  1225. }
  1226. }
  1227. multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
  1228. string asmbase, string asmstr, InstrItinClass itin,
  1229. list<dag> pattern> {
  1230. let BaseName = asmbase in {
  1231. let Defs = [CARRY] in
  1232. def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
  1233. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1234. pattern>, RecFormRel;
  1235. let Defs = [CARRY, CR0] in
  1236. def _rec : XOForm_1<opcode, xo, oe, OOL, IOL,
  1237. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1238. []>, isRecordForm, RecFormRel;
  1239. }
  1240. let BaseName = !strconcat(asmbase, "O") in {
  1241. let Defs = [CARRY, XER] in
  1242. def O : XOForm_1<opcode, xo, 1, OOL, IOL,
  1243. !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
  1244. []>, RecFormRel;
  1245. let Defs = [CARRY, XER, CR0] in
  1246. def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL,
  1247. !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
  1248. []>, isRecordForm, RecFormRel;
  1249. }
  1250. }
  1251. multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
  1252. string asmbase, string asmstr, InstrItinClass itin,
  1253. list<dag> pattern> {
  1254. let BaseName = asmbase in {
  1255. def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
  1256. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1257. pattern>, RecFormRel;
  1258. let Defs = [CR0] in
  1259. def _rec : XOForm_3<opcode, xo, oe, OOL, IOL,
  1260. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1261. []>, isRecordForm, RecFormRel;
  1262. }
  1263. let BaseName = !strconcat(asmbase, "O") in {
  1264. let Defs = [XER] in
  1265. def O : XOForm_3<opcode, xo, 1, OOL, IOL,
  1266. !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
  1267. []>, RecFormRel;
  1268. let Defs = [XER, CR0] in
  1269. def O_rec : XOForm_3<opcode, xo, 1, OOL, IOL,
  1270. !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
  1271. []>, isRecordForm, RecFormRel;
  1272. }
  1273. }
  1274. multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
  1275. string asmbase, string asmstr, InstrItinClass itin,
  1276. list<dag> pattern> {
  1277. let BaseName = asmbase in {
  1278. let Defs = [CARRY] in
  1279. def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
  1280. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1281. pattern>, RecFormRel;
  1282. let Defs = [CARRY, CR0] in
  1283. def _rec : XOForm_3<opcode, xo, oe, OOL, IOL,
  1284. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1285. []>, isRecordForm, RecFormRel;
  1286. }
  1287. let BaseName = !strconcat(asmbase, "O") in {
  1288. let Defs = [CARRY, XER] in
  1289. def O : XOForm_3<opcode, xo, 1, OOL, IOL,
  1290. !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
  1291. []>, RecFormRel;
  1292. let Defs = [CARRY, XER, CR0] in
  1293. def O_rec : XOForm_3<opcode, xo, 1, OOL, IOL,
  1294. !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
  1295. []>, isRecordForm, RecFormRel;
  1296. }
  1297. }
  1298. multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
  1299. string asmbase, string asmstr, InstrItinClass itin,
  1300. list<dag> pattern> {
  1301. let BaseName = asmbase in {
  1302. def NAME : MForm_2<opcode, OOL, IOL,
  1303. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1304. pattern>, RecFormRel;
  1305. let Defs = [CR0] in
  1306. def _rec : MForm_2<opcode, OOL, IOL,
  1307. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1308. []>, isRecordForm, RecFormRel;
  1309. }
  1310. }
  1311. multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
  1312. string asmbase, string asmstr, InstrItinClass itin,
  1313. list<dag> pattern> {
  1314. let BaseName = asmbase in {
  1315. def NAME : MDForm_1<opcode, xo, OOL, IOL,
  1316. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1317. pattern>, RecFormRel;
  1318. let Defs = [CR0] in
  1319. def _rec : MDForm_1<opcode, xo, OOL, IOL,
  1320. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1321. []>, isRecordForm, RecFormRel;
  1322. }
  1323. }
  1324. multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
  1325. string asmbase, string asmstr, InstrItinClass itin,
  1326. list<dag> pattern> {
  1327. let BaseName = asmbase in {
  1328. def NAME : MDSForm_1<opcode, xo, OOL, IOL,
  1329. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1330. pattern>, RecFormRel;
  1331. let Defs = [CR0] in
  1332. def _rec : MDSForm_1<opcode, xo, OOL, IOL,
  1333. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1334. []>, isRecordForm, RecFormRel;
  1335. }
  1336. }
  1337. multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
  1338. string asmbase, string asmstr, InstrItinClass itin,
  1339. list<dag> pattern> {
  1340. let BaseName = asmbase in {
  1341. let Defs = [CARRY] in
  1342. def NAME : XSForm_1<opcode, xo, OOL, IOL,
  1343. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1344. pattern>, RecFormRel;
  1345. let Defs = [CARRY, CR0] in
  1346. def _rec : XSForm_1<opcode, xo, OOL, IOL,
  1347. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1348. []>, isRecordForm, RecFormRel;
  1349. }
  1350. }
  1351. multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
  1352. string asmbase, string asmstr, InstrItinClass itin,
  1353. list<dag> pattern> {
  1354. let BaseName = asmbase in {
  1355. def NAME : XSForm_1<opcode, xo, OOL, IOL,
  1356. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1357. pattern>, RecFormRel;
  1358. let Defs = [CR0] in
  1359. def _rec : XSForm_1<opcode, xo, OOL, IOL,
  1360. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1361. []>, isRecordForm, RecFormRel;
  1362. }
  1363. }
  1364. multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  1365. string asmbase, string asmstr, InstrItinClass itin,
  1366. list<dag> pattern> {
  1367. let BaseName = asmbase in {
  1368. def NAME : XForm_26<opcode, xo, OOL, IOL,
  1369. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1370. pattern>, RecFormRel;
  1371. let Defs = [CR1] in
  1372. def _rec : XForm_26<opcode, xo, OOL, IOL,
  1373. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1374. []>, isRecordForm, RecFormRel;
  1375. }
  1376. }
  1377. multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  1378. string asmbase, string asmstr, InstrItinClass itin,
  1379. list<dag> pattern> {
  1380. let BaseName = asmbase in {
  1381. def NAME : XForm_28<opcode, xo, OOL, IOL,
  1382. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1383. pattern>, RecFormRel;
  1384. let Defs = [CR1] in
  1385. def _rec : XForm_28<opcode, xo, OOL, IOL,
  1386. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1387. []>, isRecordForm, RecFormRel;
  1388. }
  1389. }
  1390. multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
  1391. string asmbase, string asmstr, InstrItinClass itin,
  1392. list<dag> pattern> {
  1393. let BaseName = asmbase in {
  1394. def NAME : AForm_1<opcode, xo, OOL, IOL,
  1395. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1396. pattern>, RecFormRel;
  1397. let Defs = [CR1] in
  1398. def _rec : AForm_1<opcode, xo, OOL, IOL,
  1399. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1400. []>, isRecordForm, RecFormRel;
  1401. }
  1402. }
  1403. multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
  1404. string asmbase, string asmstr, InstrItinClass itin,
  1405. list<dag> pattern> {
  1406. let BaseName = asmbase in {
  1407. def NAME : AForm_2<opcode, xo, OOL, IOL,
  1408. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1409. pattern>, RecFormRel;
  1410. let Defs = [CR1] in
  1411. def _rec : AForm_2<opcode, xo, OOL, IOL,
  1412. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1413. []>, isRecordForm, RecFormRel;
  1414. }
  1415. }
  1416. multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
  1417. string asmbase, string asmstr, InstrItinClass itin,
  1418. list<dag> pattern> {
  1419. let BaseName = asmbase in {
  1420. def NAME : AForm_3<opcode, xo, OOL, IOL,
  1421. !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
  1422. pattern>, RecFormRel;
  1423. let Defs = [CR1] in
  1424. def _rec : AForm_3<opcode, xo, OOL, IOL,
  1425. !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
  1426. []>, isRecordForm, RecFormRel;
  1427. }
  1428. }
  1429. //===----------------------------------------------------------------------===//
  1430. // PowerPC Instruction Definitions.
  1431. // Pseudo instructions:
  1432. let hasCtrlDep = 1 in {
  1433. let Defs = [R1], Uses = [R1] in {
  1434. def ADJCALLSTACKDOWN : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
  1435. "#ADJCALLSTACKDOWN $amt1 $amt2",
  1436. [(callseq_start timm:$amt1, timm:$amt2)]>;
  1437. def ADJCALLSTACKUP : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
  1438. "#ADJCALLSTACKUP $amt1 $amt2",
  1439. [(callseq_end timm:$amt1, timm:$amt2)]>;
  1440. }
  1441. } // hasCtrlDep
  1442. let Defs = [R1], Uses = [R1] in
  1443. def DYNALLOC : PPCEmitTimePseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
  1444. [(set i32:$result,
  1445. (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
  1446. def DYNAREAOFFSET : PPCEmitTimePseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
  1447. [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
  1448. // Probed alloca to support stack clash protection.
  1449. let Defs = [R1], Uses = [R1], hasNoSchedulingInfo = 1 in {
  1450. def PROBED_ALLOCA_32 : PPCCustomInserterPseudo<(outs gprc:$result),
  1451. (ins gprc:$negsize, memri:$fpsi), "#PROBED_ALLOCA_32",
  1452. [(set i32:$result,
  1453. (PPCprobedalloca i32:$negsize, iaddr:$fpsi))]>;
  1454. def PREPARE_PROBED_ALLOCA_32 : PPCEmitTimePseudo<(outs
  1455. gprc:$fp, gprc:$actual_negsize),
  1456. (ins gprc:$negsize, memri:$fpsi), "#PREPARE_PROBED_ALLOCA_32", []>;
  1457. def PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32 : PPCEmitTimePseudo<(outs
  1458. gprc:$fp, gprc:$actual_negsize),
  1459. (ins gprc:$negsize, memri:$fpsi),
  1460. "#PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32", []>,
  1461. RegConstraint<"$actual_negsize = $negsize">;
  1462. def PROBED_STACKALLOC_32 : PPCEmitTimePseudo<(outs gprc:$scratch, gprc:$temp),
  1463. (ins i64imm:$stacksize),
  1464. "#PROBED_STACKALLOC_32", []>;
  1465. }
  1466. // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
  1467. // instruction selection into a branch sequence.
  1468. let PPC970_Single = 1 in {
  1469. // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
  1470. // because either operand might become the first operand in an isel, and
  1471. // that operand cannot be r0.
  1472. def SELECT_CC_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crrc:$cond,
  1473. gprc_nor0:$T, gprc_nor0:$F,
  1474. i32imm:$BROPC), "#SELECT_CC_I4",
  1475. []>;
  1476. def SELECT_CC_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crrc:$cond,
  1477. g8rc_nox0:$T, g8rc_nox0:$F,
  1478. i32imm:$BROPC), "#SELECT_CC_I8",
  1479. []>;
  1480. def SELECT_CC_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
  1481. i32imm:$BROPC), "#SELECT_CC_F4",
  1482. []>;
  1483. def SELECT_CC_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
  1484. i32imm:$BROPC), "#SELECT_CC_F8",
  1485. []>;
  1486. def SELECT_CC_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
  1487. i32imm:$BROPC), "#SELECT_CC_F16",
  1488. []>;
  1489. def SELECT_CC_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
  1490. i32imm:$BROPC), "#SELECT_CC_VRRC",
  1491. []>;
  1492. // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
  1493. // register bit directly.
  1494. def SELECT_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crbitrc:$cond,
  1495. gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
  1496. [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
  1497. def SELECT_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
  1498. g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
  1499. [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
  1500. let Predicates = [HasFPU] in {
  1501. def SELECT_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
  1502. f4rc:$T, f4rc:$F), "#SELECT_F4",
  1503. [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
  1504. def SELECT_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
  1505. f8rc:$T, f8rc:$F), "#SELECT_F8",
  1506. [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
  1507. def SELECT_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
  1508. vrrc:$T, vrrc:$F), "#SELECT_F16",
  1509. [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>;
  1510. }
  1511. def SELECT_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
  1512. vrrc:$T, vrrc:$F), "#SELECT_VRRC",
  1513. [(set v4i32:$dst,
  1514. (select i1:$cond, v4i32:$T, v4i32:$F))]>;
  1515. }
  1516. // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
  1517. // scavenge a register for it.
  1518. let mayStore = 1 in {
  1519. def SPILL_CR : PPCEmitTimePseudo<(outs), (ins crrc:$cond, memri:$F),
  1520. "#SPILL_CR", []>;
  1521. def SPILL_CRBIT : PPCEmitTimePseudo<(outs), (ins crbitrc:$cond, memri:$F),
  1522. "#SPILL_CRBIT", []>;
  1523. }
  1524. // RESTORE_CR - Indicate that we're restoring the CR register (previously
  1525. // spilled), so we'll need to scavenge a register for it.
  1526. let mayLoad = 1 in {
  1527. def RESTORE_CR : PPCEmitTimePseudo<(outs crrc:$cond), (ins memri:$F),
  1528. "#RESTORE_CR", []>;
  1529. def RESTORE_CRBIT : PPCEmitTimePseudo<(outs crbitrc:$cond), (ins memri:$F),
  1530. "#RESTORE_CRBIT", []>;
  1531. }
  1532. let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, hasSideEffects = 0 in {
  1533. let isPredicable = 1, isReturn = 1, Uses = [LR, RM] in
  1534. def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
  1535. [(retflag)]>, Requires<[In32BitMode]>;
  1536. let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
  1537. let isPredicable = 1 in
  1538. def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
  1539. []>;
  1540. let isCodeGenOnly = 1 in {
  1541. def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
  1542. "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
  1543. []>;
  1544. def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
  1545. "bcctr 12, $bi, 0", IIC_BrB, []>;
  1546. def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
  1547. "bcctr 4, $bi, 0", IIC_BrB, []>;
  1548. }
  1549. }
  1550. }
  1551. // Set the float rounding mode.
  1552. let Uses = [RM], Defs = [RM] in {
  1553. def SETRNDi : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins u2imm:$RND),
  1554. "#SETRNDi", [(set f64:$FRT, (int_ppc_setrnd (i32 imm:$RND)))]>;
  1555. def SETRND : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins gprc:$in),
  1556. "#SETRND", [(set f64:$FRT, (int_ppc_setrnd gprc :$in))]>;
  1557. def SETFLM : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FLM),
  1558. "#SETFLM", [(set f64:$FRT, (int_ppc_setflm f8rc:$FLM))]>;
  1559. }
  1560. let Defs = [LR] in
  1561. def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
  1562. PPC970_Unit_BRU;
  1563. let Defs = [LR] in
  1564. def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>,
  1565. PPC970_Unit_BRU;
  1566. let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
  1567. hasSideEffects = 0 in {
  1568. let isBarrier = 1 in {
  1569. let isPredicable = 1 in
  1570. def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
  1571. "b $dst", IIC_BrB,
  1572. [(br bb:$dst)]>;
  1573. def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
  1574. "ba $dst", IIC_BrB, []>;
  1575. }
  1576. // BCC represents an arbitrary conditional branch on a predicate.
  1577. // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
  1578. // a two-value operand where a dag node expects two operands. :(
  1579. let isCodeGenOnly = 1 in {
  1580. class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
  1581. "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
  1582. /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
  1583. def BCC : BCC_class;
  1584. // The same as BCC, except that it's not a terminator. Used for introducing
  1585. // control flow dependency without creating new blocks.
  1586. let isTerminator = 0 in def CTRL_DEP : BCC_class;
  1587. def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
  1588. "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
  1589. let isReturn = 1, Uses = [LR, RM] in
  1590. def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
  1591. "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
  1592. }
  1593. let isCodeGenOnly = 1 in {
  1594. let Pattern = [(brcond i1:$bi, bb:$dst)] in
  1595. def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
  1596. "bc 12, $bi, $dst">;
  1597. let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
  1598. def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
  1599. "bc 4, $bi, $dst">;
  1600. let isReturn = 1, Uses = [LR, RM] in {
  1601. def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
  1602. "bclr 12, $bi, 0", IIC_BrB, []>;
  1603. def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
  1604. "bclr 4, $bi, 0", IIC_BrB, []>;
  1605. }
  1606. }
  1607. let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
  1608. def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
  1609. "bdzlr", IIC_BrB, []>;
  1610. def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
  1611. "bdnzlr", IIC_BrB, []>;
  1612. def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
  1613. "bdzlr+", IIC_BrB, []>;
  1614. def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
  1615. "bdnzlr+", IIC_BrB, []>;
  1616. def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
  1617. "bdzlr-", IIC_BrB, []>;
  1618. def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
  1619. "bdnzlr-", IIC_BrB, []>;
  1620. }
  1621. let Defs = [CTR], Uses = [CTR] in {
  1622. def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
  1623. "bdz $dst">;
  1624. def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
  1625. "bdnz $dst">;
  1626. def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
  1627. "bdza $dst">;
  1628. def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
  1629. "bdnza $dst">;
  1630. def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
  1631. "bdz+ $dst">;
  1632. def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
  1633. "bdnz+ $dst">;
  1634. def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
  1635. "bdza+ $dst">;
  1636. def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
  1637. "bdnza+ $dst">;
  1638. def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
  1639. "bdz- $dst">;
  1640. def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
  1641. "bdnz- $dst">;
  1642. def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
  1643. "bdza- $dst">;
  1644. def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
  1645. "bdnza- $dst">;
  1646. }
  1647. }
  1648. // The unconditional BCL used by the SjLj setjmp code.
  1649. let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7,
  1650. hasSideEffects = 0 in {
  1651. let Defs = [LR], Uses = [RM] in {
  1652. def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
  1653. "bcl 20, 31, $dst">;
  1654. }
  1655. }
  1656. let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
  1657. // Convenient aliases for call instructions
  1658. let Uses = [RM] in {
  1659. def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
  1660. "bl $func", IIC_BrB, []>; // See Pat patterns below.
  1661. def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
  1662. "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
  1663. let isCodeGenOnly = 1 in {
  1664. def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
  1665. "bl $func", IIC_BrB, []>;
  1666. def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
  1667. "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
  1668. def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
  1669. "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
  1670. def BCL : BForm_4<16, 12, 0, 1, (outs),
  1671. (ins crbitrc:$bi, condbrtarget:$dst),
  1672. "bcl 12, $bi, $dst">;
  1673. def BCLn : BForm_4<16, 4, 0, 1, (outs),
  1674. (ins crbitrc:$bi, condbrtarget:$dst),
  1675. "bcl 4, $bi, $dst">;
  1676. def BL_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
  1677. (outs), (ins calltarget:$func),
  1678. "bl $func\n\tnop", IIC_BrB, []>;
  1679. }
  1680. }
  1681. let Uses = [CTR, RM] in {
  1682. let isPredicable = 1 in
  1683. def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
  1684. "bctrl", IIC_BrB, [(PPCbctrl)]>,
  1685. Requires<[In32BitMode]>;
  1686. let isCodeGenOnly = 1 in {
  1687. def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
  1688. "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
  1689. []>;
  1690. def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
  1691. "bcctrl 12, $bi, 0", IIC_BrB, []>;
  1692. def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
  1693. "bcctrl 4, $bi, 0", IIC_BrB, []>;
  1694. }
  1695. }
  1696. let Uses = [LR, RM] in {
  1697. def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
  1698. "blrl", IIC_BrB, []>;
  1699. let isCodeGenOnly = 1 in {
  1700. def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
  1701. "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
  1702. []>;
  1703. def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
  1704. "bclrl 12, $bi, 0", IIC_BrB, []>;
  1705. def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
  1706. "bclrl 4, $bi, 0", IIC_BrB, []>;
  1707. }
  1708. }
  1709. let Defs = [CTR], Uses = [CTR, RM] in {
  1710. def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
  1711. "bdzl $dst">;
  1712. def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
  1713. "bdnzl $dst">;
  1714. def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
  1715. "bdzla $dst">;
  1716. def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
  1717. "bdnzla $dst">;
  1718. def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
  1719. "bdzl+ $dst">;
  1720. def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
  1721. "bdnzl+ $dst">;
  1722. def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
  1723. "bdzla+ $dst">;
  1724. def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
  1725. "bdnzla+ $dst">;
  1726. def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
  1727. "bdzl- $dst">;
  1728. def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
  1729. "bdnzl- $dst">;
  1730. def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
  1731. "bdzla- $dst">;
  1732. def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
  1733. "bdnzla- $dst">;
  1734. }
  1735. let Defs = [CTR], Uses = [CTR, LR, RM] in {
  1736. def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
  1737. "bdzlrl", IIC_BrB, []>;
  1738. def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
  1739. "bdnzlrl", IIC_BrB, []>;
  1740. def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
  1741. "bdzlrl+", IIC_BrB, []>;
  1742. def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
  1743. "bdnzlrl+", IIC_BrB, []>;
  1744. def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
  1745. "bdzlrl-", IIC_BrB, []>;
  1746. def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
  1747. "bdnzlrl-", IIC_BrB, []>;
  1748. }
  1749. }
  1750. let isCall = 1, PPC970_Unit = 7, Defs = [LR, RM], isCodeGenOnly = 1 in {
  1751. // Convenient aliases for call instructions
  1752. let Uses = [RM] in {
  1753. def BL_RM : IForm<18, 0, 1, (outs), (ins calltarget:$func),
  1754. "bl $func", IIC_BrB, []>; // See Pat patterns below.
  1755. def BLA_RM : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
  1756. "bla $func", IIC_BrB, [(PPCcall_rm (i32 imm:$func))]>;
  1757. def BL_NOP_RM : IForm_and_DForm_4_zero<18, 0, 1, 24,
  1758. (outs), (ins calltarget:$func),
  1759. "bl $func\n\tnop", IIC_BrB, []>;
  1760. }
  1761. let Uses = [CTR, RM] in {
  1762. let isPredicable = 1 in
  1763. def BCTRL_RM : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
  1764. "bctrl", IIC_BrB, [(PPCbctrl_rm)]>,
  1765. Requires<[In32BitMode]>;
  1766. }
  1767. }
  1768. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
  1769. def TCRETURNdi :PPCEmitTimePseudo< (outs),
  1770. (ins calltarget:$dst, i32imm:$offset),
  1771. "#TC_RETURNd $dst $offset",
  1772. []>;
  1773. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
  1774. def TCRETURNai :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
  1775. "#TC_RETURNa $func $offset",
  1776. [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
  1777. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
  1778. def TCRETURNri : PPCEmitTimePseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
  1779. "#TC_RETURNr $dst $offset",
  1780. []>;
  1781. let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
  1782. Defs = [LR, R2], Uses = [CTR, RM], RST = 2 in {
  1783. def BCTRL_LWZinto_toc:
  1784. XLForm_2_ext_and_DForm_1<19, 528, 20, 0, 1, 32, (outs),
  1785. (ins memri:$src), "bctrl\n\tlwz 2, $src", IIC_BrB,
  1786. [(PPCbctrl_load_toc iaddr:$src)]>, Requires<[In32BitMode]>;
  1787. }
  1788. let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
  1789. Defs = [LR, R2, RM], Uses = [CTR, RM], RST = 2 in {
  1790. def BCTRL_LWZinto_toc_RM:
  1791. XLForm_2_ext_and_DForm_1<19, 528, 20, 0, 1, 32, (outs),
  1792. (ins memri:$src), "bctrl\n\tlwz 2, $src", IIC_BrB,
  1793. [(PPCbctrl_load_toc_rm iaddr:$src)]>, Requires<[In32BitMode]>;
  1794. }
  1795. let isCodeGenOnly = 1, hasSideEffects = 0 in {
  1796. let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
  1797. isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
  1798. def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
  1799. []>, Requires<[In32BitMode]>;
  1800. let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
  1801. isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
  1802. def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
  1803. "b $dst", IIC_BrB,
  1804. []>;
  1805. let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
  1806. isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
  1807. def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
  1808. "ba $dst", IIC_BrB,
  1809. []>;
  1810. }
  1811. // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
  1812. // is not.
  1813. let hasSideEffects = 1 in {
  1814. let Defs = [CTR] in
  1815. def EH_SjLj_SetJmp32 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
  1816. "#EH_SJLJ_SETJMP32",
  1817. [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
  1818. Requires<[In32BitMode]>;
  1819. }
  1820. let hasSideEffects = 1, isBarrier = 1 in {
  1821. let isTerminator = 1 in
  1822. def EH_SjLj_LongJmp32 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
  1823. "#EH_SJLJ_LONGJMP32",
  1824. [(PPCeh_sjlj_longjmp addr:$buf)]>,
  1825. Requires<[In32BitMode]>;
  1826. }
  1827. // This pseudo is never removed from the function, as it serves as
  1828. // a terminator. Size is set to 0 to prevent the builtin assembler
  1829. // from emitting it.
  1830. let isBranch = 1, isTerminator = 1, Size = 0 in {
  1831. def EH_SjLj_Setup : PPCEmitTimePseudo<(outs), (ins directbrtarget:$dst),
  1832. "#EH_SjLj_Setup\t$dst", []>;
  1833. }
  1834. // System call.
  1835. let PPC970_Unit = 7 in {
  1836. def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
  1837. "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
  1838. }
  1839. // Branch history rolling buffer.
  1840. def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
  1841. [(PPCclrbhrb)]>,
  1842. PPC970_DGroup_Single;
  1843. // The $dmy argument used for MFBHRBE is not needed; however, including
  1844. // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
  1845. // interferes with necessary special handling (see PPCFastISel.cpp).
  1846. def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
  1847. (ins u10imm:$imm, u10imm:$dmy),
  1848. "mfbhrbe $rD, $imm", IIC_BrB,
  1849. [(set i32:$rD,
  1850. (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
  1851. PPC970_DGroup_First;
  1852. def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
  1853. IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
  1854. PPC970_DGroup_Single;
  1855. def : InstAlias<"rfebb", (RFEBB 1)>;
  1856. // DCB* instructions.
  1857. def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
  1858. IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
  1859. PPC970_DGroup_Single;
  1860. def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
  1861. IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
  1862. PPC970_DGroup_Single;
  1863. def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
  1864. IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
  1865. PPC970_DGroup_Single;
  1866. def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
  1867. IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
  1868. PPC970_DGroup_Single;
  1869. def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
  1870. IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
  1871. PPC970_DGroup_Single;
  1872. def DCBF : DCB_Form_hint<86, (outs), (ins u3imm:$TH, memrr:$dst),
  1873. "dcbf $dst, $TH", IIC_LdStDCBF, []>,
  1874. PPC970_DGroup_Single;
  1875. let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
  1876. def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
  1877. "dcbt $dst, $TH", IIC_LdStDCBF, []>,
  1878. PPC970_DGroup_Single;
  1879. def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
  1880. "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
  1881. PPC970_DGroup_Single;
  1882. } // hasSideEffects = 0
  1883. def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
  1884. "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
  1885. def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
  1886. "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
  1887. def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
  1888. "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
  1889. def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
  1890. "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
  1891. def : Pat<(int_ppc_dcbt xoaddr:$dst),
  1892. (DCBT 0, xoaddr:$dst)>;
  1893. def : Pat<(int_ppc_dcbtst xoaddr:$dst),
  1894. (DCBTST 0, xoaddr:$dst)>;
  1895. def : Pat<(int_ppc_dcbf xoaddr:$dst),
  1896. (DCBF 0, xoaddr:$dst)>;
  1897. def : Pat<(int_ppc_icbt xoaddr:$dst),
  1898. (ICBT 0, xoaddr:$dst)>;
  1899. def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
  1900. (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
  1901. def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
  1902. (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
  1903. def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
  1904. (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
  1905. def : Pat<(int_ppc_dcbt_with_hint xoaddr:$dst, i32:$TH),
  1906. (DCBT i32:$TH, xoaddr:$dst)>;
  1907. def : Pat<(int_ppc_dcbtst_with_hint xoaddr:$dst, i32:$TH),
  1908. (DCBTST i32:$TH, xoaddr:$dst)>;
  1909. // Atomic operations
  1910. // FIXME: some of these might be used with constant operands. This will result
  1911. // in constant materialization instructions that may be redundant. We currently
  1912. // clean this up in PPCMIPeephole with calls to
  1913. // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
  1914. // in the first place.
  1915. let Defs = [CR0] in {
  1916. def ATOMIC_LOAD_ADD_I8 : PPCCustomInserterPseudo<
  1917. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
  1918. [(set i32:$dst, (atomic_load_add_8 ForceXForm:$ptr, i32:$incr))]>;
  1919. def ATOMIC_LOAD_SUB_I8 : PPCCustomInserterPseudo<
  1920. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
  1921. [(set i32:$dst, (atomic_load_sub_8 ForceXForm:$ptr, i32:$incr))]>;
  1922. def ATOMIC_LOAD_AND_I8 : PPCCustomInserterPseudo<
  1923. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
  1924. [(set i32:$dst, (atomic_load_and_8 ForceXForm:$ptr, i32:$incr))]>;
  1925. def ATOMIC_LOAD_OR_I8 : PPCCustomInserterPseudo<
  1926. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
  1927. [(set i32:$dst, (atomic_load_or_8 ForceXForm:$ptr, i32:$incr))]>;
  1928. def ATOMIC_LOAD_XOR_I8 : PPCCustomInserterPseudo<
  1929. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
  1930. [(set i32:$dst, (atomic_load_xor_8 ForceXForm:$ptr, i32:$incr))]>;
  1931. def ATOMIC_LOAD_NAND_I8 : PPCCustomInserterPseudo<
  1932. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
  1933. [(set i32:$dst, (atomic_load_nand_8 ForceXForm:$ptr, i32:$incr))]>;
  1934. def ATOMIC_LOAD_MIN_I8 : PPCCustomInserterPseudo<
  1935. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
  1936. [(set i32:$dst, (atomic_load_min_8 ForceXForm:$ptr, i32:$incr))]>;
  1937. def ATOMIC_LOAD_MAX_I8 : PPCCustomInserterPseudo<
  1938. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
  1939. [(set i32:$dst, (atomic_load_max_8 ForceXForm:$ptr, i32:$incr))]>;
  1940. def ATOMIC_LOAD_UMIN_I8 : PPCCustomInserterPseudo<
  1941. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
  1942. [(set i32:$dst, (atomic_load_umin_8 ForceXForm:$ptr, i32:$incr))]>;
  1943. def ATOMIC_LOAD_UMAX_I8 : PPCCustomInserterPseudo<
  1944. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
  1945. [(set i32:$dst, (atomic_load_umax_8 ForceXForm:$ptr, i32:$incr))]>;
  1946. def ATOMIC_LOAD_ADD_I16 : PPCCustomInserterPseudo<
  1947. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
  1948. [(set i32:$dst, (atomic_load_add_16 ForceXForm:$ptr, i32:$incr))]>;
  1949. def ATOMIC_LOAD_SUB_I16 : PPCCustomInserterPseudo<
  1950. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
  1951. [(set i32:$dst, (atomic_load_sub_16 ForceXForm:$ptr, i32:$incr))]>;
  1952. def ATOMIC_LOAD_AND_I16 : PPCCustomInserterPseudo<
  1953. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
  1954. [(set i32:$dst, (atomic_load_and_16 ForceXForm:$ptr, i32:$incr))]>;
  1955. def ATOMIC_LOAD_OR_I16 : PPCCustomInserterPseudo<
  1956. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
  1957. [(set i32:$dst, (atomic_load_or_16 ForceXForm:$ptr, i32:$incr))]>;
  1958. def ATOMIC_LOAD_XOR_I16 : PPCCustomInserterPseudo<
  1959. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
  1960. [(set i32:$dst, (atomic_load_xor_16 ForceXForm:$ptr, i32:$incr))]>;
  1961. def ATOMIC_LOAD_NAND_I16 : PPCCustomInserterPseudo<
  1962. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
  1963. [(set i32:$dst, (atomic_load_nand_16 ForceXForm:$ptr, i32:$incr))]>;
  1964. def ATOMIC_LOAD_MIN_I16 : PPCCustomInserterPseudo<
  1965. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
  1966. [(set i32:$dst, (atomic_load_min_16 ForceXForm:$ptr, i32:$incr))]>;
  1967. def ATOMIC_LOAD_MAX_I16 : PPCCustomInserterPseudo<
  1968. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
  1969. [(set i32:$dst, (atomic_load_max_16 ForceXForm:$ptr, i32:$incr))]>;
  1970. def ATOMIC_LOAD_UMIN_I16 : PPCCustomInserterPseudo<
  1971. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
  1972. [(set i32:$dst, (atomic_load_umin_16 ForceXForm:$ptr, i32:$incr))]>;
  1973. def ATOMIC_LOAD_UMAX_I16 : PPCCustomInserterPseudo<
  1974. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
  1975. [(set i32:$dst, (atomic_load_umax_16 ForceXForm:$ptr, i32:$incr))]>;
  1976. def ATOMIC_LOAD_ADD_I32 : PPCCustomInserterPseudo<
  1977. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
  1978. [(set i32:$dst, (atomic_load_add_32 ForceXForm:$ptr, i32:$incr))]>;
  1979. def ATOMIC_LOAD_SUB_I32 : PPCCustomInserterPseudo<
  1980. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
  1981. [(set i32:$dst, (atomic_load_sub_32 ForceXForm:$ptr, i32:$incr))]>;
  1982. def ATOMIC_LOAD_AND_I32 : PPCCustomInserterPseudo<
  1983. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
  1984. [(set i32:$dst, (atomic_load_and_32 ForceXForm:$ptr, i32:$incr))]>;
  1985. def ATOMIC_LOAD_OR_I32 : PPCCustomInserterPseudo<
  1986. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
  1987. [(set i32:$dst, (atomic_load_or_32 ForceXForm:$ptr, i32:$incr))]>;
  1988. def ATOMIC_LOAD_XOR_I32 : PPCCustomInserterPseudo<
  1989. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
  1990. [(set i32:$dst, (atomic_load_xor_32 ForceXForm:$ptr, i32:$incr))]>;
  1991. def ATOMIC_LOAD_NAND_I32 : PPCCustomInserterPseudo<
  1992. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
  1993. [(set i32:$dst, (atomic_load_nand_32 ForceXForm:$ptr, i32:$incr))]>;
  1994. def ATOMIC_LOAD_MIN_I32 : PPCCustomInserterPseudo<
  1995. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
  1996. [(set i32:$dst, (atomic_load_min_32 ForceXForm:$ptr, i32:$incr))]>;
  1997. def ATOMIC_LOAD_MAX_I32 : PPCCustomInserterPseudo<
  1998. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
  1999. [(set i32:$dst, (atomic_load_max_32 ForceXForm:$ptr, i32:$incr))]>;
  2000. def ATOMIC_LOAD_UMIN_I32 : PPCCustomInserterPseudo<
  2001. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
  2002. [(set i32:$dst, (atomic_load_umin_32 ForceXForm:$ptr, i32:$incr))]>;
  2003. def ATOMIC_LOAD_UMAX_I32 : PPCCustomInserterPseudo<
  2004. (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
  2005. [(set i32:$dst, (atomic_load_umax_32 ForceXForm:$ptr, i32:$incr))]>;
  2006. def ATOMIC_CMP_SWAP_I8 : PPCCustomInserterPseudo<
  2007. (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
  2008. [(set i32:$dst, (atomic_cmp_swap_8 ForceXForm:$ptr, i32:$old, i32:$new))]>;
  2009. def ATOMIC_CMP_SWAP_I16 : PPCCustomInserterPseudo<
  2010. (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
  2011. [(set i32:$dst, (atomic_cmp_swap_16 ForceXForm:$ptr, i32:$old, i32:$new))]>;
  2012. def ATOMIC_CMP_SWAP_I32 : PPCCustomInserterPseudo<
  2013. (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
  2014. [(set i32:$dst, (atomic_cmp_swap_32 ForceXForm:$ptr, i32:$old, i32:$new))]>;
  2015. def ATOMIC_SWAP_I8 : PPCCustomInserterPseudo<
  2016. (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
  2017. [(set i32:$dst, (atomic_swap_8 ForceXForm:$ptr, i32:$new))]>;
  2018. def ATOMIC_SWAP_I16 : PPCCustomInserterPseudo<
  2019. (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
  2020. [(set i32:$dst, (atomic_swap_16 ForceXForm:$ptr, i32:$new))]>;
  2021. def ATOMIC_SWAP_I32 : PPCCustomInserterPseudo<
  2022. (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
  2023. [(set i32:$dst, (atomic_swap_32 ForceXForm:$ptr, i32:$new))]>;
  2024. }
  2025. def : Pat<(PPCatomicCmpSwap_8 ForceXForm:$ptr, i32:$old, i32:$new),
  2026. (ATOMIC_CMP_SWAP_I8 ForceXForm:$ptr, i32:$old, i32:$new)>;
  2027. def : Pat<(PPCatomicCmpSwap_16 ForceXForm:$ptr, i32:$old, i32:$new),
  2028. (ATOMIC_CMP_SWAP_I16 ForceXForm:$ptr, i32:$old, i32:$new)>;
  2029. // Instructions to support atomic operations
  2030. let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
  2031. def LBARX : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
  2032. "lbarx $rD, $src", IIC_LdStLWARX, []>,
  2033. Requires<[HasPartwordAtomics]>;
  2034. def LHARX : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
  2035. "lharx $rD, $src", IIC_LdStLWARX, []>,
  2036. Requires<[HasPartwordAtomics]>;
  2037. def LWARX : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
  2038. "lwarx $rD, $src", IIC_LdStLWARX, []>;
  2039. // Instructions to support lock versions of atomics
  2040. // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
  2041. def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
  2042. "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isRecordForm,
  2043. Requires<[HasPartwordAtomics]>;
  2044. def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
  2045. "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isRecordForm,
  2046. Requires<[HasPartwordAtomics]>;
  2047. def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
  2048. "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isRecordForm;
  2049. // The atomic instructions use the destination register as well as the next one
  2050. // or two registers in order (modulo 31).
  2051. let hasExtraSrcRegAllocReq = 1 in
  2052. def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
  2053. "lwat $rD, $rA, $FC", IIC_LdStLoad>,
  2054. Requires<[IsISA3_0]>;
  2055. }
  2056. let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
  2057. def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
  2058. "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
  2059. isRecordForm, Requires<[HasPartwordAtomics]>;
  2060. def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
  2061. "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
  2062. isRecordForm, Requires<[HasPartwordAtomics]>;
  2063. def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
  2064. "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isRecordForm;
  2065. }
  2066. let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
  2067. def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
  2068. "stwat $rS, $rA, $FC", IIC_LdStStore>,
  2069. Requires<[IsISA3_0]>;
  2070. let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
  2071. def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
  2072. def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
  2073. "twi $to, $rA, $imm", IIC_IntTrapW, []>;
  2074. def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
  2075. "tw $to, $rA, $rB", IIC_IntTrapW, []>;
  2076. def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
  2077. "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
  2078. def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
  2079. "td $to, $rA, $rB", IIC_IntTrapD, []>;
  2080. def POPCNTB : XForm_11<31, 122, (outs gprc:$rA), (ins gprc:$rS),
  2081. "popcntb $rA, $rS", IIC_IntGeneral,
  2082. [(set i32:$rA, (int_ppc_popcntb i32:$rS))]>;
  2083. //===----------------------------------------------------------------------===//
  2084. // PPC32 Load Instructions.
  2085. //
  2086. // Unindexed (r+i) Loads.
  2087. let PPC970_Unit = 2 in {
  2088. def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
  2089. "lbz $rD, $src", IIC_LdStLoad,
  2090. [(set i32:$rD, (zextloadi8 DForm:$src))]>;
  2091. def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
  2092. "lha $rD, $src", IIC_LdStLHA,
  2093. [(set i32:$rD, (sextloadi16 DForm:$src))]>,
  2094. PPC970_DGroup_Cracked;
  2095. def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
  2096. "lhz $rD, $src", IIC_LdStLoad,
  2097. [(set i32:$rD, (zextloadi16 DForm:$src))]>;
  2098. def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
  2099. "lwz $rD, $src", IIC_LdStLoad,
  2100. [(set i32:$rD, (load DForm:$src))]>;
  2101. let Predicates = [HasFPU] in {
  2102. def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
  2103. "lfs $rD, $src", IIC_LdStLFD,
  2104. [(set f32:$rD, (load DForm:$src))]>;
  2105. def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
  2106. "lfd $rD, $src", IIC_LdStLFD,
  2107. [(set f64:$rD, (load DForm:$src))]>;
  2108. }
  2109. // Unindexed (r+i) Loads with Update (preinc).
  2110. let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
  2111. def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
  2112. "lbzu $rD, $addr", IIC_LdStLoadUpd,
  2113. []>, RegConstraint<"$addr.reg = $ea_result">,
  2114. NoEncode<"$ea_result">;
  2115. def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
  2116. "lhau $rD, $addr", IIC_LdStLHAU,
  2117. []>, RegConstraint<"$addr.reg = $ea_result">,
  2118. NoEncode<"$ea_result">;
  2119. def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
  2120. "lhzu $rD, $addr", IIC_LdStLoadUpd,
  2121. []>, RegConstraint<"$addr.reg = $ea_result">,
  2122. NoEncode<"$ea_result">;
  2123. def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
  2124. "lwzu $rD, $addr", IIC_LdStLoadUpd,
  2125. []>, RegConstraint<"$addr.reg = $ea_result">,
  2126. NoEncode<"$ea_result">;
  2127. let Predicates = [HasFPU] in {
  2128. def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
  2129. "lfsu $rD, $addr", IIC_LdStLFDU,
  2130. []>, RegConstraint<"$addr.reg = $ea_result">,
  2131. NoEncode<"$ea_result">;
  2132. def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
  2133. "lfdu $rD, $addr", IIC_LdStLFDU,
  2134. []>, RegConstraint<"$addr.reg = $ea_result">,
  2135. NoEncode<"$ea_result">;
  2136. }
  2137. // Indexed (r+r) Loads with Update (preinc).
  2138. def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
  2139. (ins memrr:$addr),
  2140. "lbzux $rD, $addr", IIC_LdStLoadUpdX,
  2141. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  2142. NoEncode<"$ea_result">;
  2143. def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
  2144. (ins memrr:$addr),
  2145. "lhaux $rD, $addr", IIC_LdStLHAUX,
  2146. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  2147. NoEncode<"$ea_result">;
  2148. def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
  2149. (ins memrr:$addr),
  2150. "lhzux $rD, $addr", IIC_LdStLoadUpdX,
  2151. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  2152. NoEncode<"$ea_result">;
  2153. def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
  2154. (ins memrr:$addr),
  2155. "lwzux $rD, $addr", IIC_LdStLoadUpdX,
  2156. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  2157. NoEncode<"$ea_result">;
  2158. let Predicates = [HasFPU] in {
  2159. def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
  2160. (ins memrr:$addr),
  2161. "lfsux $rD, $addr", IIC_LdStLFDUX,
  2162. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  2163. NoEncode<"$ea_result">;
  2164. def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
  2165. (ins memrr:$addr),
  2166. "lfdux $rD, $addr", IIC_LdStLFDUX,
  2167. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  2168. NoEncode<"$ea_result">;
  2169. }
  2170. }
  2171. }
  2172. // Indexed (r+r) Loads.
  2173. //
  2174. let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
  2175. def LBZX : XForm_1_memOp<31, 87, (outs gprc:$rD), (ins memrr:$src),
  2176. "lbzx $rD, $src", IIC_LdStLoad,
  2177. [(set i32:$rD, (zextloadi8 XForm:$src))]>;
  2178. def LHAX : XForm_1_memOp<31, 343, (outs gprc:$rD), (ins memrr:$src),
  2179. "lhax $rD, $src", IIC_LdStLHA,
  2180. [(set i32:$rD, (sextloadi16 XForm:$src))]>,
  2181. PPC970_DGroup_Cracked;
  2182. def LHZX : XForm_1_memOp<31, 279, (outs gprc:$rD), (ins memrr:$src),
  2183. "lhzx $rD, $src", IIC_LdStLoad,
  2184. [(set i32:$rD, (zextloadi16 XForm:$src))]>;
  2185. def LWZX : XForm_1_memOp<31, 23, (outs gprc:$rD), (ins memrr:$src),
  2186. "lwzx $rD, $src", IIC_LdStLoad,
  2187. [(set i32:$rD, (load XForm:$src))]>;
  2188. def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$rD), (ins memrr:$src),
  2189. "lhbrx $rD, $src", IIC_LdStLoad,
  2190. [(set i32:$rD, (PPClbrx ForceXForm:$src, i16))]>;
  2191. def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$rD), (ins memrr:$src),
  2192. "lwbrx $rD, $src", IIC_LdStLoad,
  2193. [(set i32:$rD, (PPClbrx ForceXForm:$src, i32))]>;
  2194. let Predicates = [HasFPU] in {
  2195. def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$frD), (ins memrr:$src),
  2196. "lfsx $frD, $src", IIC_LdStLFD,
  2197. [(set f32:$frD, (load XForm:$src))]>;
  2198. def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$frD), (ins memrr:$src),
  2199. "lfdx $frD, $src", IIC_LdStLFD,
  2200. [(set f64:$frD, (load XForm:$src))]>;
  2201. def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$frD), (ins memrr:$src),
  2202. "lfiwax $frD, $src", IIC_LdStLFD,
  2203. [(set f64:$frD, (PPClfiwax ForceXForm:$src))]>;
  2204. def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$frD), (ins memrr:$src),
  2205. "lfiwzx $frD, $src", IIC_LdStLFD,
  2206. [(set f64:$frD, (PPClfiwzx ForceXForm:$src))]>;
  2207. }
  2208. }
  2209. // Load Multiple
  2210. let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
  2211. def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
  2212. "lmw $rD, $src", IIC_LdStLMW, []>;
  2213. //===----------------------------------------------------------------------===//
  2214. // PPC32 Store Instructions.
  2215. //
  2216. // Unindexed (r+i) Stores.
  2217. let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
  2218. def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$dst),
  2219. "stb $rS, $dst", IIC_LdStStore,
  2220. [(truncstorei8 i32:$rS, DForm:$dst)]>;
  2221. def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$dst),
  2222. "sth $rS, $dst", IIC_LdStStore,
  2223. [(truncstorei16 i32:$rS, DForm:$dst)]>;
  2224. def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$dst),
  2225. "stw $rS, $dst", IIC_LdStStore,
  2226. [(store i32:$rS, DForm:$dst)]>;
  2227. let Predicates = [HasFPU] in {
  2228. def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
  2229. "stfs $rS, $dst", IIC_LdStSTFD,
  2230. [(store f32:$rS, DForm:$dst)]>;
  2231. def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
  2232. "stfd $rS, $dst", IIC_LdStSTFD,
  2233. [(store f64:$rS, DForm:$dst)]>;
  2234. }
  2235. }
  2236. // Unindexed (r+i) Stores with Update (preinc).
  2237. let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
  2238. def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
  2239. "stbu $rS, $dst", IIC_LdStSTU, []>,
  2240. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  2241. def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
  2242. "sthu $rS, $dst", IIC_LdStSTU, []>,
  2243. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  2244. def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
  2245. "stwu $rS, $dst", IIC_LdStSTU, []>,
  2246. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  2247. let Predicates = [HasFPU] in {
  2248. def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
  2249. "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
  2250. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  2251. def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
  2252. "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
  2253. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  2254. }
  2255. }
  2256. // Patterns to match the pre-inc stores. We can't put the patterns on
  2257. // the instruction definitions directly as ISel wants the address base
  2258. // and offset to be separate operands, not a single complex operand.
  2259. def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  2260. (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
  2261. def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  2262. (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
  2263. def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  2264. (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
  2265. def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  2266. (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
  2267. def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  2268. (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
  2269. // Indexed (r+r) Stores.
  2270. let PPC970_Unit = 2 in {
  2271. def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
  2272. "stbx $rS, $dst", IIC_LdStStore,
  2273. [(truncstorei8 i32:$rS, XForm:$dst)]>,
  2274. PPC970_DGroup_Cracked;
  2275. def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
  2276. "sthx $rS, $dst", IIC_LdStStore,
  2277. [(truncstorei16 i32:$rS, XForm:$dst)]>,
  2278. PPC970_DGroup_Cracked;
  2279. def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
  2280. "stwx $rS, $dst", IIC_LdStStore,
  2281. [(store i32:$rS, XForm:$dst)]>,
  2282. PPC970_DGroup_Cracked;
  2283. def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
  2284. "sthbrx $rS, $dst", IIC_LdStStore,
  2285. [(PPCstbrx i32:$rS, ForceXForm:$dst, i16)]>,
  2286. PPC970_DGroup_Cracked;
  2287. def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
  2288. "stwbrx $rS, $dst", IIC_LdStStore,
  2289. [(PPCstbrx i32:$rS, ForceXForm:$dst, i32)]>,
  2290. PPC970_DGroup_Cracked;
  2291. let Predicates = [HasFPU] in {
  2292. def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
  2293. "stfiwx $frS, $dst", IIC_LdStSTFD,
  2294. [(PPCstfiwx f64:$frS, ForceXForm:$dst)]>;
  2295. def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
  2296. "stfsx $frS, $dst", IIC_LdStSTFD,
  2297. [(store f32:$frS, XForm:$dst)]>;
  2298. def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
  2299. "stfdx $frS, $dst", IIC_LdStSTFD,
  2300. [(store f64:$frS, XForm:$dst)]>;
  2301. }
  2302. }
  2303. // Indexed (r+r) Stores with Update (preinc).
  2304. let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
  2305. def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
  2306. (ins gprc:$rS, memrr:$dst),
  2307. "stbux $rS, $dst", IIC_LdStSTUX, []>,
  2308. RegConstraint<"$dst.ptrreg = $ea_res">,
  2309. NoEncode<"$ea_res">,
  2310. PPC970_DGroup_Cracked;
  2311. def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
  2312. (ins gprc:$rS, memrr:$dst),
  2313. "sthux $rS, $dst", IIC_LdStSTUX, []>,
  2314. RegConstraint<"$dst.ptrreg = $ea_res">,
  2315. NoEncode<"$ea_res">,
  2316. PPC970_DGroup_Cracked;
  2317. def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
  2318. (ins gprc:$rS, memrr:$dst),
  2319. "stwux $rS, $dst", IIC_LdStSTUX, []>,
  2320. RegConstraint<"$dst.ptrreg = $ea_res">,
  2321. NoEncode<"$ea_res">,
  2322. PPC970_DGroup_Cracked;
  2323. let Predicates = [HasFPU] in {
  2324. def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res),
  2325. (ins f4rc:$rS, memrr:$dst),
  2326. "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
  2327. RegConstraint<"$dst.ptrreg = $ea_res">,
  2328. NoEncode<"$ea_res">,
  2329. PPC970_DGroup_Cracked;
  2330. def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res),
  2331. (ins f8rc:$rS, memrr:$dst),
  2332. "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
  2333. RegConstraint<"$dst.ptrreg = $ea_res">,
  2334. NoEncode<"$ea_res">,
  2335. PPC970_DGroup_Cracked;
  2336. }
  2337. }
  2338. // Patterns to match the pre-inc stores. We can't put the patterns on
  2339. // the instruction definitions directly as ISel wants the address base
  2340. // and offset to be separate operands, not a single complex operand.
  2341. def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  2342. (STBUX $rS, $ptrreg, $ptroff)>;
  2343. def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  2344. (STHUX $rS, $ptrreg, $ptroff)>;
  2345. def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  2346. (STWUX $rS, $ptrreg, $ptroff)>;
  2347. let Predicates = [HasFPU] in {
  2348. def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  2349. (STFSUX $rS, $ptrreg, $ptroff)>;
  2350. def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  2351. (STFDUX $rS, $ptrreg, $ptroff)>;
  2352. }
  2353. // Store Multiple
  2354. let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
  2355. def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
  2356. "stmw $rS, $dst", IIC_LdStLMW, []>;
  2357. def SYNC : XForm_24_sync<31, 598, (outs), (ins u2imm:$L),
  2358. "sync $L", IIC_LdStSync, []>;
  2359. let isCodeGenOnly = 1 in {
  2360. def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
  2361. "msync", IIC_LdStSync, []> {
  2362. let L = 0;
  2363. }
  2364. }
  2365. // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
  2366. def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
  2367. "eieio", IIC_LdStLoad, []>;
  2368. def PseudoEIEIO : PPCEmitTimePseudo<(outs), (ins), "#PPCEIEIO",
  2369. [(int_ppc_eieio)]>;
  2370. def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
  2371. def : Pat<(int_ppc_iospace_sync), (SYNC 0)>, Requires<[HasSYNC]>;
  2372. def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
  2373. def : Pat<(int_ppc_iospace_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
  2374. def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
  2375. def : Pat<(int_ppc_iospace_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
  2376. def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
  2377. def : Pat<(int_ppc_iospace_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
  2378. def : Pat<(int_ppc_eieio), (PseudoEIEIO)>;
  2379. def : Pat<(int_ppc_iospace_eieio), (PseudoEIEIO)>;
  2380. //===----------------------------------------------------------------------===//
  2381. // PPC32 Arithmetic Instructions.
  2382. //
  2383. let PPC970_Unit = 1 in { // FXU Operations.
  2384. def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
  2385. "addi $rD, $rA, $imm", IIC_IntSimple,
  2386. [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
  2387. let BaseName = "addic" in {
  2388. let Defs = [CARRY] in
  2389. def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
  2390. "addic $rD, $rA, $imm", IIC_IntGeneral,
  2391. [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
  2392. RecFormRel, PPC970_DGroup_Cracked;
  2393. let Defs = [CARRY, CR0] in
  2394. def ADDIC_rec : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
  2395. "addic. $rD, $rA, $imm", IIC_IntGeneral,
  2396. []>, isRecordForm, RecFormRel;
  2397. }
  2398. def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
  2399. "addis $rD, $rA, $imm", IIC_IntSimple,
  2400. [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
  2401. let isCodeGenOnly = 1 in
  2402. def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
  2403. "la $rD, $sym($rA)", IIC_IntGeneral,
  2404. [(set i32:$rD, (add i32:$rA,
  2405. (PPClo tglobaladdr:$sym, 0)))]>;
  2406. def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
  2407. "mulli $rD, $rA, $imm", IIC_IntMulLI,
  2408. [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
  2409. let Defs = [CARRY] in
  2410. def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
  2411. "subfic $rD, $rA, $imm", IIC_IntGeneral,
  2412. [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
  2413. let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
  2414. def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
  2415. "li $rD, $imm", IIC_IntSimple,
  2416. [(set i32:$rD, imm32SExt16:$imm)]>;
  2417. def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
  2418. "lis $rD, $imm", IIC_IntSimple,
  2419. [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
  2420. }
  2421. }
  2422. def : InstAlias<"li $rD, $imm", (ADDI gprc:$rD, ZERO, s16imm:$imm)>;
  2423. def : InstAlias<"lis $rD, $imm", (ADDIS gprc:$rD, ZERO, s17imm:$imm)>;
  2424. let PPC970_Unit = 1 in { // FXU Operations.
  2425. let Defs = [CR0] in {
  2426. def ANDI_rec : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
  2427. "andi. $dst, $src1, $src2", IIC_IntGeneral,
  2428. [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
  2429. isRecordForm;
  2430. def ANDIS_rec : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
  2431. "andis. $dst, $src1, $src2", IIC_IntGeneral,
  2432. [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
  2433. isRecordForm;
  2434. }
  2435. def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
  2436. "ori $dst, $src1, $src2", IIC_IntSimple,
  2437. [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
  2438. def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
  2439. "oris $dst, $src1, $src2", IIC_IntSimple,
  2440. [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
  2441. def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
  2442. "xori $dst, $src1, $src2", IIC_IntSimple,
  2443. [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
  2444. def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
  2445. "xoris $dst, $src1, $src2", IIC_IntSimple,
  2446. [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
  2447. def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
  2448. []>;
  2449. let isCodeGenOnly = 1 in {
  2450. // The POWER6 and POWER7 have special group-terminating nops.
  2451. def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
  2452. "ori 1, 1, 0", IIC_IntSimple, []>;
  2453. def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
  2454. "ori 2, 2, 0", IIC_IntSimple, []>;
  2455. }
  2456. let isCompare = 1, hasSideEffects = 0 in {
  2457. def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
  2458. "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
  2459. def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
  2460. "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
  2461. def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crrc:$BF),
  2462. (ins u1imm:$L, gprc:$rA, gprc:$rB),
  2463. "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
  2464. Requires<[IsISA3_0]>;
  2465. }
  2466. }
  2467. let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
  2468. let isCommutable = 1 in {
  2469. defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2470. "nand", "$rA, $rS, $rB", IIC_IntSimple,
  2471. [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
  2472. defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2473. "and", "$rA, $rS, $rB", IIC_IntSimple,
  2474. [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
  2475. } // isCommutable
  2476. defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2477. "andc", "$rA, $rS, $rB", IIC_IntSimple,
  2478. [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
  2479. let isCommutable = 1 in {
  2480. defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2481. "or", "$rA, $rS, $rB", IIC_IntSimple,
  2482. [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
  2483. defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2484. "nor", "$rA, $rS, $rB", IIC_IntSimple,
  2485. [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
  2486. } // isCommutable
  2487. defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2488. "orc", "$rA, $rS, $rB", IIC_IntSimple,
  2489. [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
  2490. let isCommutable = 1 in {
  2491. defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2492. "eqv", "$rA, $rS, $rB", IIC_IntSimple,
  2493. [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
  2494. defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2495. "xor", "$rA, $rS, $rB", IIC_IntSimple,
  2496. [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
  2497. } // isCommutable
  2498. defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2499. "slw", "$rA, $rS, $rB", IIC_IntGeneral,
  2500. [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
  2501. defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2502. "srw", "$rA, $rS, $rB", IIC_IntGeneral,
  2503. [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
  2504. defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2505. "sraw", "$rA, $rS, $rB", IIC_IntShift,
  2506. [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
  2507. }
  2508. def : InstAlias<"mr $rA, $rB", (OR gprc:$rA, gprc:$rB, gprc:$rB)>;
  2509. def : InstAlias<"mr. $rA, $rB", (OR_rec gprc:$rA, gprc:$rB, gprc:$rB)>;
  2510. def : InstAlias<"not $rA, $rS", (NOR gprc:$rA, gprc:$rS, gprc:$rS)>;
  2511. def : InstAlias<"not. $rA, $rS", (NOR_rec gprc:$rA, gprc:$rS, gprc:$rS)>;
  2512. def : InstAlias<"nop", (ORI R0, R0, 0)>;
  2513. let PPC970_Unit = 1 in { // FXU Operations.
  2514. let hasSideEffects = 0 in {
  2515. defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
  2516. "srawi", "$rA, $rS, $SH", IIC_IntShift,
  2517. [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
  2518. defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
  2519. "cntlzw", "$rA, $rS", IIC_IntGeneral,
  2520. [(set i32:$rA, (ctlz i32:$rS))]>;
  2521. defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
  2522. "cnttzw", "$rA, $rS", IIC_IntGeneral,
  2523. [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
  2524. defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
  2525. "extsb", "$rA, $rS", IIC_IntSimple,
  2526. [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
  2527. defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
  2528. "extsh", "$rA, $rS", IIC_IntSimple,
  2529. [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
  2530. let isCommutable = 1 in
  2531. def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
  2532. "cmpb $rA, $rS, $rB", IIC_IntGeneral,
  2533. [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
  2534. }
  2535. let isCompare = 1, hasSideEffects = 0 in {
  2536. def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
  2537. "cmpw $crD, $rA, $rB", IIC_IntCompare>;
  2538. def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
  2539. "cmplw $crD, $rA, $rB", IIC_IntCompare>;
  2540. }
  2541. }
  2542. let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations.
  2543. let isCompare = 1, mayRaiseFPException = 1, hasSideEffects = 0 in {
  2544. def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
  2545. "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
  2546. def FCMPOS : XForm_17<63, 32, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
  2547. "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
  2548. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  2549. def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
  2550. "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
  2551. def FCMPOD : XForm_17<63, 32, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
  2552. "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
  2553. }
  2554. }
  2555. def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
  2556. "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
  2557. def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
  2558. "ftsqrt $crD, $fB", IIC_FPCompare,
  2559. [(set i32:$crD, (PPCftsqrt f64:$fB))]>;
  2560. let mayRaiseFPException = 1, hasSideEffects = 0 in {
  2561. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2562. defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
  2563. "frin", "$frD, $frB", IIC_FPGeneral,
  2564. [(set f64:$frD, (any_fround f64:$frB))]>;
  2565. defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
  2566. "frin", "$frD, $frB", IIC_FPGeneral,
  2567. [(set f32:$frD, (any_fround f32:$frB))]>;
  2568. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2569. defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
  2570. "frip", "$frD, $frB", IIC_FPGeneral,
  2571. [(set f64:$frD, (any_fceil f64:$frB))]>;
  2572. defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
  2573. "frip", "$frD, $frB", IIC_FPGeneral,
  2574. [(set f32:$frD, (any_fceil f32:$frB))]>;
  2575. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2576. defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
  2577. "friz", "$frD, $frB", IIC_FPGeneral,
  2578. [(set f64:$frD, (any_ftrunc f64:$frB))]>;
  2579. defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
  2580. "friz", "$frD, $frB", IIC_FPGeneral,
  2581. [(set f32:$frD, (any_ftrunc f32:$frB))]>;
  2582. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2583. defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
  2584. "frim", "$frD, $frB", IIC_FPGeneral,
  2585. [(set f64:$frD, (any_ffloor f64:$frB))]>;
  2586. defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
  2587. "frim", "$frD, $frB", IIC_FPGeneral,
  2588. [(set f32:$frD, (any_ffloor f32:$frB))]>;
  2589. }
  2590. let Uses = [RM], mayRaiseFPException = 1, hasSideEffects = 0 in {
  2591. defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
  2592. "fctiw", "$frD, $frB", IIC_FPGeneral,
  2593. []>;
  2594. defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
  2595. "fctiwu", "$frD, $frB", IIC_FPGeneral,
  2596. []>;
  2597. defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
  2598. "fctiwz", "$frD, $frB", IIC_FPGeneral,
  2599. [(set f64:$frD, (PPCany_fctiwz f64:$frB))]>;
  2600. defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
  2601. "frsp", "$frD, $frB", IIC_FPGeneral,
  2602. [(set f32:$frD, (any_fpround f64:$frB))]>;
  2603. defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
  2604. "fsqrt", "$frD, $frB", IIC_FPSqrtD,
  2605. [(set f64:$frD, (any_fsqrt f64:$frB))]>;
  2606. defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
  2607. "fsqrts", "$frD, $frB", IIC_FPSqrtS,
  2608. [(set f32:$frD, (any_fsqrt f32:$frB))]>;
  2609. }
  2610. }
  2611. def : Pat<(PPCfsqrt f64:$frA), (FSQRT $frA)>;
  2612. /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
  2613. /// often coalesced away and we don't want the dispatch group builder to think
  2614. /// that they will fill slots (which could cause the load of a LSU reject to
  2615. /// sneak into a d-group with a store).
  2616. let hasSideEffects = 0, Predicates = [HasFPU] in
  2617. defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
  2618. "fmr", "$frD, $frB", IIC_FPGeneral,
  2619. []>, // (set f32:$frD, f32:$frB)
  2620. PPC970_Unit_Pseudo;
  2621. let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
  2622. // These are artificially split into two different forms, for 4/8 byte FP.
  2623. defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
  2624. "fabs", "$frD, $frB", IIC_FPGeneral,
  2625. [(set f32:$frD, (fabs f32:$frB))]>;
  2626. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2627. defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
  2628. "fabs", "$frD, $frB", IIC_FPGeneral,
  2629. [(set f64:$frD, (fabs f64:$frB))]>;
  2630. defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
  2631. "fnabs", "$frD, $frB", IIC_FPGeneral,
  2632. [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
  2633. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2634. defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
  2635. "fnabs", "$frD, $frB", IIC_FPGeneral,
  2636. [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
  2637. defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
  2638. "fneg", "$frD, $frB", IIC_FPGeneral,
  2639. [(set f32:$frD, (fneg f32:$frB))]>;
  2640. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2641. defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
  2642. "fneg", "$frD, $frB", IIC_FPGeneral,
  2643. [(set f64:$frD, (fneg f64:$frB))]>;
  2644. defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
  2645. "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
  2646. [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
  2647. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  2648. defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
  2649. "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
  2650. [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
  2651. // Reciprocal estimates.
  2652. let mayRaiseFPException = 1 in {
  2653. defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
  2654. "fre", "$frD, $frB", IIC_FPGeneral,
  2655. [(set f64:$frD, (PPCfre f64:$frB))]>;
  2656. defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
  2657. "fres", "$frD, $frB", IIC_FPGeneral,
  2658. [(set f32:$frD, (PPCfre f32:$frB))]>;
  2659. defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
  2660. "frsqrte", "$frD, $frB", IIC_FPGeneral,
  2661. [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
  2662. defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
  2663. "frsqrtes", "$frD, $frB", IIC_FPGeneral,
  2664. [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
  2665. }
  2666. }
  2667. // XL-Form instructions. condition register logical ops.
  2668. //
  2669. let hasSideEffects = 0 in
  2670. def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
  2671. "mcrf $BF, $BFA", IIC_BrMCR>,
  2672. PPC970_DGroup_First, PPC970_Unit_CRU;
  2673. // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
  2674. // condition-register logical instructions have preferred forms. Specifically,
  2675. // it is preferred that the bit specified by the BT field be in the same
  2676. // condition register as that specified by the bit BB. We might want to account
  2677. // for this via hinting the register allocator and anti-dep breakers, or we
  2678. // could constrain the register class to force this constraint and then loosen
  2679. // it during register allocation via convertToThreeAddress or some similar
  2680. // mechanism.
  2681. let isCommutable = 1 in {
  2682. def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
  2683. (ins crbitrc:$CRA, crbitrc:$CRB),
  2684. "crand $CRD, $CRA, $CRB", IIC_BrCR,
  2685. [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
  2686. def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
  2687. (ins crbitrc:$CRA, crbitrc:$CRB),
  2688. "crnand $CRD, $CRA, $CRB", IIC_BrCR,
  2689. [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
  2690. def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
  2691. (ins crbitrc:$CRA, crbitrc:$CRB),
  2692. "cror $CRD, $CRA, $CRB", IIC_BrCR,
  2693. [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
  2694. def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
  2695. (ins crbitrc:$CRA, crbitrc:$CRB),
  2696. "crxor $CRD, $CRA, $CRB", IIC_BrCR,
  2697. [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
  2698. def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
  2699. (ins crbitrc:$CRA, crbitrc:$CRB),
  2700. "crnor $CRD, $CRA, $CRB", IIC_BrCR,
  2701. [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
  2702. def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
  2703. (ins crbitrc:$CRA, crbitrc:$CRB),
  2704. "creqv $CRD, $CRA, $CRB", IIC_BrCR,
  2705. [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
  2706. } // isCommutable
  2707. def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
  2708. (ins crbitrc:$CRA, crbitrc:$CRB),
  2709. "crandc $CRD, $CRA, $CRB", IIC_BrCR,
  2710. [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
  2711. def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
  2712. (ins crbitrc:$CRA, crbitrc:$CRB),
  2713. "crorc $CRD, $CRA, $CRB", IIC_BrCR,
  2714. [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
  2715. let isCodeGenOnly = 1 in {
  2716. let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
  2717. def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
  2718. "creqv $dst, $dst, $dst", IIC_BrCR,
  2719. [(set i1:$dst, 1)]>;
  2720. def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
  2721. "crxor $dst, $dst, $dst", IIC_BrCR,
  2722. [(set i1:$dst, 0)]>;
  2723. }
  2724. let Defs = [CR1EQ], CRD = 6 in {
  2725. def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
  2726. "creqv 6, 6, 6", IIC_BrCR,
  2727. [(PPCcr6set)]>;
  2728. def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
  2729. "crxor 6, 6, 6", IIC_BrCR,
  2730. [(PPCcr6unset)]>;
  2731. }
  2732. }
  2733. // XFX-Form instructions. Instructions that deal with SPRs.
  2734. //
  2735. def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
  2736. "mfspr $RT, $SPR", IIC_SprMFSPR>;
  2737. def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
  2738. "mtspr $SPR, $RT", IIC_SprMTSPR>;
  2739. def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
  2740. "mftb $RT, $SPR", IIC_SprMFTB>;
  2741. def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
  2742. "mfpmr $RT, $SPR", IIC_SprMFPMR>;
  2743. def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
  2744. "mtpmr $SPR, $RT", IIC_SprMTPMR>;
  2745. // A pseudo-instruction used to implement the read of the 64-bit cycle counter
  2746. // on a 32-bit target.
  2747. let hasSideEffects = 1 in
  2748. def ReadTB : PPCCustomInserterPseudo<(outs gprc:$lo, gprc:$hi), (ins),
  2749. "#ReadTB", []>;
  2750. let Uses = [CTR] in {
  2751. def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
  2752. "mfctr $rT", IIC_SprMFSPR>,
  2753. PPC970_DGroup_First, PPC970_Unit_FXU;
  2754. }
  2755. let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
  2756. def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
  2757. "mtctr $rS", IIC_SprMTSPR>,
  2758. PPC970_DGroup_First, PPC970_Unit_FXU;
  2759. }
  2760. let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
  2761. let Pattern = [(int_set_loop_iterations i32:$rS)] in
  2762. def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
  2763. "mtctr $rS", IIC_SprMTSPR>,
  2764. PPC970_DGroup_First, PPC970_Unit_FXU;
  2765. }
  2766. let hasSideEffects = 0 in {
  2767. let Defs = [LR] in {
  2768. def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
  2769. "mtlr $rS", IIC_SprMTSPR>,
  2770. PPC970_DGroup_First, PPC970_Unit_FXU;
  2771. }
  2772. let Uses = [LR] in {
  2773. def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
  2774. "mflr $rT", IIC_SprMFSPR>,
  2775. PPC970_DGroup_First, PPC970_Unit_FXU;
  2776. }
  2777. }
  2778. let isCodeGenOnly = 1 in {
  2779. // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
  2780. // like a GPR on the PPC970. As such, copies in and out have the same
  2781. // performance characteristics as an OR instruction.
  2782. def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
  2783. "mtspr 256, $rS", IIC_IntGeneral>,
  2784. PPC970_DGroup_Single, PPC970_Unit_FXU;
  2785. def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
  2786. "mfspr $rT, 256", IIC_IntGeneral>,
  2787. PPC970_DGroup_First, PPC970_Unit_FXU;
  2788. def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
  2789. (outs VRSAVERC:$reg), (ins gprc:$rS),
  2790. "mtspr 256, $rS", IIC_IntGeneral>,
  2791. PPC970_DGroup_Single, PPC970_Unit_FXU;
  2792. def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
  2793. (ins VRSAVERC:$reg),
  2794. "mfspr $rT, 256", IIC_IntGeneral>,
  2795. PPC970_DGroup_First, PPC970_Unit_FXU;
  2796. }
  2797. // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
  2798. def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
  2799. def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
  2800. let hasSideEffects = 0 in {
  2801. // mtocrf's input needs to be prepared by shifting by an amount dependent
  2802. // on the cr register selected. Thus, post-ra anti-dep breaking must not
  2803. // later change that register assignment.
  2804. let hasExtraDefRegAllocReq = 1 in {
  2805. def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
  2806. "mtocrf $FXM, $ST", IIC_BrMCRX>,
  2807. PPC970_DGroup_First, PPC970_Unit_CRU;
  2808. // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
  2809. // is dependent on the cr fields being set.
  2810. def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
  2811. "mtcrf $FXM, $rS", IIC_BrMCRX>,
  2812. PPC970_MicroCode, PPC970_Unit_CRU;
  2813. } // hasExtraDefRegAllocReq = 1
  2814. // mfocrf's input needs to be prepared by shifting by an amount dependent
  2815. // on the cr register selected. Thus, post-ra anti-dep breaking must not
  2816. // later change that register assignment.
  2817. let hasExtraSrcRegAllocReq = 1 in {
  2818. def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
  2819. "mfocrf $rT, $FXM", IIC_SprMFCRF>,
  2820. PPC970_DGroup_First, PPC970_Unit_CRU;
  2821. // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
  2822. // is dependent on the cr fields being copied.
  2823. def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
  2824. "mfcr $rT", IIC_SprMFCR>,
  2825. PPC970_MicroCode, PPC970_Unit_CRU;
  2826. } // hasExtraSrcRegAllocReq = 1
  2827. def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
  2828. "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
  2829. } // hasSideEffects = 0
  2830. def : InstAlias<"mtcr $rA", (MTCRF 255, gprc:$rA)>;
  2831. let Predicates = [HasFPU] in {
  2832. // Custom inserter instruction to perform FADD in round-to-zero mode.
  2833. let Uses = [RM], mayRaiseFPException = 1 in {
  2834. def FADDrtz: PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
  2835. [(set f64:$FRT, (PPCany_faddrtz f64:$FRA, f64:$FRB))]>;
  2836. }
  2837. // The above pseudo gets expanded to make use of the following instructions
  2838. // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
  2839. // When FM is 30/31, we are setting the 62/63 bit of FPSCR, the implicit-def
  2840. // RM should be set.
  2841. let hasSideEffects = 1, Defs = [RM] in {
  2842. def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
  2843. "mtfsb0 $FM", IIC_IntMTFSB0,
  2844. [(int_ppc_mtfsb0 timm:$FM)]>,
  2845. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2846. def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
  2847. "mtfsb1 $FM", IIC_IntMTFSB0,
  2848. [(int_ppc_mtfsb1 timm:$FM)]>,
  2849. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2850. }
  2851. let Defs = [RM], hasSideEffects = 1 in {
  2852. let isCodeGenOnly = 1 in
  2853. def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
  2854. "mtfsf $FM, $rT", IIC_IntMTFSB0,
  2855. [(int_ppc_mtfsf timm:$FM, f64:$rT)]>,
  2856. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2857. }
  2858. let Uses = [RM], hasSideEffects = 1 in {
  2859. def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
  2860. "mffs $rT", IIC_IntMFFS,
  2861. [(set f64:$rT, (PPCmffs))]>,
  2862. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2863. let Defs = [CR1] in
  2864. def MFFS_rec : XForm_42<63, 583, (outs f8rc:$rT), (ins),
  2865. "mffs. $rT", IIC_IntMFFS, []>, isRecordForm;
  2866. def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins),
  2867. "mffsce $rT", IIC_IntMFFS, []>,
  2868. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2869. def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT),
  2870. (ins f8rc:$FRB), "mffscdrn $rT, $FRB",
  2871. IIC_IntMFFS, []>,
  2872. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2873. def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT),
  2874. (ins u3imm:$DRM),
  2875. "mffscdrni $rT, $DRM",
  2876. IIC_IntMFFS, []>,
  2877. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2878. def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT),
  2879. (ins f8rc:$FRB), "mffscrn $rT, $FRB",
  2880. IIC_IntMFFS, []>,
  2881. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2882. def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT),
  2883. (ins u2imm:$RM), "mffscrni $rT, $RM",
  2884. IIC_IntMFFS, []>,
  2885. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2886. def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins),
  2887. "mffsl $rT", IIC_IntMFFS, []>,
  2888. PPC970_DGroup_Single, PPC970_Unit_FPU;
  2889. }
  2890. }
  2891. let Predicates = [IsISA3_0] in {
  2892. def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2893. "modsw $rT, $rA, $rB", IIC_IntDivW,
  2894. [(set i32:$rT, (srem i32:$rA, i32:$rB))]>;
  2895. def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2896. "moduw $rT, $rA, $rB", IIC_IntDivW,
  2897. [(set i32:$rT, (urem i32:$rA, i32:$rB))]>;
  2898. let hasSideEffects = 1 in
  2899. def ADDEX : Z23Form_RTAB5_CY2<31, 170, (outs gprc:$rT),
  2900. (ins gprc:$rA, gprc:$rB, u2imm:$CY),
  2901. "addex $rT, $rA, $rB, $CY", IIC_IntGeneral, []>;
  2902. }
  2903. let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
  2904. // XO-Form instructions. Arithmetic instructions that can set overflow bit
  2905. let isCommutable = 1 in
  2906. defm ADD4 : XOForm_1rx<31, 266, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2907. "add", "$rT, $rA, $rB", IIC_IntSimple,
  2908. [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
  2909. let isCodeGenOnly = 1 in
  2910. def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
  2911. "add $rT, $rA, $rB", IIC_IntSimple,
  2912. [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
  2913. let isCommutable = 1 in
  2914. defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2915. "addc", "$rT, $rA, $rB", IIC_IntGeneral,
  2916. [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
  2917. PPC970_DGroup_Cracked;
  2918. defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2919. "divw", "$rT, $rA, $rB", IIC_IntDivW,
  2920. [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
  2921. defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2922. "divwu", "$rT, $rA, $rB", IIC_IntDivW,
  2923. [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
  2924. defm DIVWE : XOForm_1rcr<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2925. "divwe", "$rT, $rA, $rB", IIC_IntDivW,
  2926. [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
  2927. Requires<[HasExtDiv]>;
  2928. defm DIVWEU : XOForm_1rcr<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2929. "divweu", "$rT, $rA, $rB", IIC_IntDivW,
  2930. [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
  2931. Requires<[HasExtDiv]>;
  2932. let isCommutable = 1 in {
  2933. defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2934. "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
  2935. [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
  2936. defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2937. "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
  2938. [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
  2939. defm MULLW : XOForm_1rx<31, 235, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2940. "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
  2941. [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
  2942. } // isCommutable
  2943. defm SUBF : XOForm_1rx<31, 40, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2944. "subf", "$rT, $rA, $rB", IIC_IntGeneral,
  2945. [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
  2946. defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2947. "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
  2948. [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
  2949. PPC970_DGroup_Cracked;
  2950. defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
  2951. "neg", "$rT, $rA", IIC_IntSimple,
  2952. [(set i32:$rT, (ineg i32:$rA))]>;
  2953. let Uses = [CARRY] in {
  2954. let isCommutable = 1 in
  2955. defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2956. "adde", "$rT, $rA, $rB", IIC_IntGeneral,
  2957. [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
  2958. defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
  2959. "addme", "$rT, $rA", IIC_IntGeneral,
  2960. [(set i32:$rT, (adde i32:$rA, -1))]>;
  2961. defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
  2962. "addze", "$rT, $rA", IIC_IntGeneral,
  2963. [(set i32:$rT, (adde i32:$rA, 0))]>;
  2964. defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
  2965. "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
  2966. [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
  2967. defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
  2968. "subfme", "$rT, $rA", IIC_IntGeneral,
  2969. [(set i32:$rT, (sube -1, i32:$rA))]>;
  2970. defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
  2971. "subfze", "$rT, $rA", IIC_IntGeneral,
  2972. [(set i32:$rT, (sube 0, i32:$rA))]>;
  2973. }
  2974. }
  2975. def : InstAlias<"sub $rA, $rB, $rC", (SUBF gprc:$rA, gprc:$rC, gprc:$rB)>;
  2976. def : InstAlias<"sub. $rA, $rB, $rC", (SUBF_rec gprc:$rA, gprc:$rC, gprc:$rB)>;
  2977. def : InstAlias<"subc $rA, $rB, $rC", (SUBFC gprc:$rA, gprc:$rC, gprc:$rB)>;
  2978. def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC_rec gprc:$rA, gprc:$rC, gprc:$rB)>;
  2979. // A-Form instructions. Most of the instructions executed in the FPU are of
  2980. // this type.
  2981. //
  2982. let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
  2983. let mayRaiseFPException = 1, Uses = [RM] in {
  2984. let isCommutable = 1 in {
  2985. defm FMADD : AForm_1r<63, 29,
  2986. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
  2987. "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
  2988. [(set f64:$FRT, (any_fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
  2989. defm FMADDS : AForm_1r<59, 29,
  2990. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
  2991. "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
  2992. [(set f32:$FRT, (any_fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
  2993. defm FMSUB : AForm_1r<63, 28,
  2994. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
  2995. "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
  2996. [(set f64:$FRT,
  2997. (any_fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
  2998. defm FMSUBS : AForm_1r<59, 28,
  2999. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
  3000. "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
  3001. [(set f32:$FRT,
  3002. (any_fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
  3003. defm FNMADD : AForm_1r<63, 31,
  3004. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
  3005. "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
  3006. [(set f64:$FRT,
  3007. (fneg (any_fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
  3008. defm FNMADDS : AForm_1r<59, 31,
  3009. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
  3010. "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
  3011. [(set f32:$FRT,
  3012. (fneg (any_fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
  3013. defm FNMSUB : AForm_1r<63, 30,
  3014. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
  3015. "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
  3016. [(set f64:$FRT, (fneg (any_fma f64:$FRA, f64:$FRC,
  3017. (fneg f64:$FRB))))]>;
  3018. defm FNMSUBS : AForm_1r<59, 30,
  3019. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
  3020. "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
  3021. [(set f32:$FRT, (fneg (any_fma f32:$FRA, f32:$FRC,
  3022. (fneg f32:$FRB))))]>;
  3023. } // isCommutable
  3024. }
  3025. // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
  3026. // having 4 of these, force the comparison to always be an 8-byte double (code
  3027. // should use an FMRSD if the input comparison value really wants to be a float)
  3028. // and 4/8 byte forms for the result and operand type..
  3029. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  3030. defm FSELD : AForm_1r<63, 23,
  3031. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
  3032. "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
  3033. [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
  3034. defm FSELS : AForm_1r<63, 23,
  3035. (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
  3036. "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
  3037. [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
  3038. let Uses = [RM], mayRaiseFPException = 1 in {
  3039. let isCommutable = 1 in {
  3040. defm FADD : AForm_2r<63, 21,
  3041. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
  3042. "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
  3043. [(set f64:$FRT, (any_fadd f64:$FRA, f64:$FRB))]>;
  3044. defm FADDS : AForm_2r<59, 21,
  3045. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
  3046. "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
  3047. [(set f32:$FRT, (any_fadd f32:$FRA, f32:$FRB))]>;
  3048. } // isCommutable
  3049. defm FDIV : AForm_2r<63, 18,
  3050. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
  3051. "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
  3052. [(set f64:$FRT, (any_fdiv f64:$FRA, f64:$FRB))]>;
  3053. defm FDIVS : AForm_2r<59, 18,
  3054. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
  3055. "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
  3056. [(set f32:$FRT, (any_fdiv f32:$FRA, f32:$FRB))]>;
  3057. let isCommutable = 1 in {
  3058. defm FMUL : AForm_3r<63, 25,
  3059. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
  3060. "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
  3061. [(set f64:$FRT, (any_fmul f64:$FRA, f64:$FRC))]>;
  3062. defm FMULS : AForm_3r<59, 25,
  3063. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
  3064. "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
  3065. [(set f32:$FRT, (any_fmul f32:$FRA, f32:$FRC))]>;
  3066. } // isCommutable
  3067. defm FSUB : AForm_2r<63, 20,
  3068. (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
  3069. "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
  3070. [(set f64:$FRT, (any_fsub f64:$FRA, f64:$FRB))]>;
  3071. defm FSUBS : AForm_2r<59, 20,
  3072. (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
  3073. "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
  3074. [(set f32:$FRT, (any_fsub f32:$FRA, f32:$FRB))]>;
  3075. }
  3076. }
  3077. let hasSideEffects = 0 in {
  3078. let PPC970_Unit = 1 in { // FXU Operations.
  3079. let isSelect = 1 in
  3080. def ISEL : AForm_4<31, 15,
  3081. (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
  3082. "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
  3083. []>;
  3084. }
  3085. let PPC970_Unit = 1 in { // FXU Operations.
  3086. // M-Form instructions. rotate and mask instructions.
  3087. //
  3088. let isCommutable = 1 in {
  3089. // RLWIMI can be commuted if the rotate amount is zero.
  3090. defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
  3091. (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
  3092. u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
  3093. IIC_IntRotate, []>, PPC970_DGroup_Cracked,
  3094. RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
  3095. }
  3096. let BaseName = "rlwinm" in {
  3097. def RLWINM : MForm_2<21,
  3098. (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
  3099. "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
  3100. []>, RecFormRel;
  3101. let Defs = [CR0] in
  3102. def RLWINM_rec : MForm_2<21,
  3103. (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
  3104. "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
  3105. []>, isRecordForm, RecFormRel, PPC970_DGroup_Cracked;
  3106. }
  3107. defm RLWNM : MForm_2r<23, (outs gprc:$rA),
  3108. (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
  3109. "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
  3110. []>;
  3111. }
  3112. } // hasSideEffects = 0
  3113. //===----------------------------------------------------------------------===//
  3114. // PowerPC Instruction Patterns
  3115. //
  3116. // Arbitrary immediate support. Implement in terms of LIS/ORI.
  3117. def : Pat<(i32 imm:$imm),
  3118. (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
  3119. // Implement the 'not' operation with the NOR instruction.
  3120. def i32not : OutPatFrag<(ops node:$in),
  3121. (NOR $in, $in)>;
  3122. def : Pat<(not i32:$in),
  3123. (i32not $in)>;
  3124. // ADD an arbitrary immediate.
  3125. def : Pat<(add i32:$in, imm:$imm),
  3126. (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
  3127. // OR an arbitrary immediate.
  3128. def : Pat<(or i32:$in, imm:$imm),
  3129. (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
  3130. // XOR an arbitrary immediate.
  3131. def : Pat<(xor i32:$in, imm:$imm),
  3132. (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
  3133. // SUBFIC
  3134. def : Pat<(sub imm32SExt16:$imm, i32:$in),
  3135. (SUBFIC $in, imm:$imm)>;
  3136. // SHL/SRL
  3137. def : Pat<(shl i32:$in, (i32 imm:$imm)),
  3138. (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
  3139. def : Pat<(srl i32:$in, (i32 imm:$imm)),
  3140. (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
  3141. // ROTL
  3142. def : Pat<(rotl i32:$in, i32:$sh),
  3143. (RLWNM $in, $sh, 0, 31)>;
  3144. def : Pat<(rotl i32:$in, (i32 imm:$imm)),
  3145. (RLWINM $in, imm:$imm, 0, 31)>;
  3146. // RLWNM
  3147. def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
  3148. (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
  3149. // Calls
  3150. def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
  3151. (BL tglobaladdr:$dst)>;
  3152. def : Pat<(PPCcall (i32 texternalsym:$dst)),
  3153. (BL texternalsym:$dst)>;
  3154. def : Pat<(PPCcall_rm (i32 tglobaladdr:$dst)),
  3155. (BL_RM tglobaladdr:$dst)>;
  3156. def : Pat<(PPCcall_rm (i32 texternalsym:$dst)),
  3157. (BL_RM texternalsym:$dst)>;
  3158. // Calls for AIX only
  3159. def : Pat<(PPCcall (i32 mcsym:$dst)),
  3160. (BL mcsym:$dst)>;
  3161. def : Pat<(PPCcall_nop (i32 mcsym:$dst)),
  3162. (BL_NOP mcsym:$dst)>;
  3163. def : Pat<(PPCcall_nop (i32 texternalsym:$dst)),
  3164. (BL_NOP texternalsym:$dst)>;
  3165. def : Pat<(PPCcall_rm (i32 mcsym:$dst)),
  3166. (BL_RM mcsym:$dst)>;
  3167. def : Pat<(PPCcall_nop_rm (i32 mcsym:$dst)),
  3168. (BL_NOP_RM mcsym:$dst)>;
  3169. def : Pat<(PPCcall_nop_rm (i32 texternalsym:$dst)),
  3170. (BL_NOP_RM texternalsym:$dst)>;
  3171. def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
  3172. (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
  3173. def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
  3174. (TCRETURNdi texternalsym:$dst, imm:$imm)>;
  3175. def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
  3176. (TCRETURNri CTRRC:$dst, imm:$imm)>;
  3177. def : Pat<(int_ppc_readflm), (MFFS)>;
  3178. // Hi and Lo for Darwin Global Addresses.
  3179. def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
  3180. def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
  3181. def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
  3182. def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
  3183. def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
  3184. def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
  3185. def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
  3186. def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
  3187. def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
  3188. (ADDIS $in, tglobaltlsaddr:$g)>;
  3189. def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
  3190. (ADDI $in, tglobaltlsaddr:$g)>;
  3191. def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
  3192. (ADDIS $in, tglobaladdr:$g)>;
  3193. def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
  3194. (ADDIS $in, tconstpool:$g)>;
  3195. def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
  3196. (ADDIS $in, tjumptable:$g)>;
  3197. def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
  3198. (ADDIS $in, tblockaddress:$g)>;
  3199. // Support for thread-local storage.
  3200. def PPC32GOT: PPCEmitTimePseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
  3201. [(set i32:$rD, (PPCppc32GOT))]>;
  3202. // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
  3203. // This uses two output registers, the first as the real output, the second as a
  3204. // temporary register, used internally in code generation.
  3205. def PPC32PICGOT: PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
  3206. []>, NoEncode<"$rT">;
  3207. def LDgotTprelL32: PPCEmitTimePseudo<(outs gprc_nor0:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
  3208. "#LDgotTprelL32",
  3209. [(set i32:$rD,
  3210. (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
  3211. def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
  3212. (ADD4TLS $in, tglobaltlsaddr:$g)>;
  3213. def ADDItlsgdL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
  3214. "#ADDItlsgdL32",
  3215. [(set i32:$rD,
  3216. (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
  3217. // LR is a true define, while the rest of the Defs are clobbers. R3 is
  3218. // explicitly defined when this op is created, so not mentioned here.
  3219. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
  3220. Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
  3221. def GETtlsADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
  3222. "GETtlsADDR32",
  3223. [(set i32:$rD,
  3224. (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
  3225. // R3 is explicitly defined when this op is created, so not mentioned here.
  3226. // The rest of the Defs are the exact set of registers that will be clobbered by
  3227. // the call.
  3228. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
  3229. Defs = [R0,R4,R5,R11,LR,CR0] in
  3230. def GETtlsADDR32AIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$offset, gprc:$handle),
  3231. "GETtlsADDR32AIX",
  3232. [(set i32:$rD,
  3233. (PPCgetTlsAddr i32:$offset, i32:$handle))]>;
  3234. // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
  3235. // are true defines while the rest of the Defs are clobbers.
  3236. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
  3237. Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
  3238. def ADDItlsgdLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
  3239. (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
  3240. "#ADDItlsgdLADDR32",
  3241. [(set i32:$rD,
  3242. (PPCaddiTlsgdLAddr i32:$reg,
  3243. tglobaltlsaddr:$disp,
  3244. tglobaltlsaddr:$sym))]>;
  3245. def ADDItlsldL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
  3246. "#ADDItlsldL32",
  3247. [(set i32:$rD,
  3248. (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
  3249. // This pseudo is expanded to two copies to put the variable offset in R4 and
  3250. // the region handle in R3 and GETtlsADDR32AIX.
  3251. def TLSGDAIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$offset, gprc:$handle),
  3252. "#TLSGDAIX",
  3253. [(set i32:$rD,
  3254. (PPCTlsgdAIX i32:$offset, i32:$handle))]>;
  3255. // LR is a true define, while the rest of the Defs are clobbers. R3 is
  3256. // explicitly defined when this op is created, so not mentioned here.
  3257. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
  3258. Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
  3259. def GETtlsldADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
  3260. "GETtlsldADDR32",
  3261. [(set i32:$rD,
  3262. (PPCgetTlsldAddr i32:$reg,
  3263. tglobaltlsaddr:$sym))]>;
  3264. // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
  3265. // are true defines while the rest of the Defs are clobbers.
  3266. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
  3267. Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
  3268. def ADDItlsldLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
  3269. (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
  3270. "#ADDItlsldLADDR32",
  3271. [(set i32:$rD,
  3272. (PPCaddiTlsldLAddr i32:$reg,
  3273. tglobaltlsaddr:$disp,
  3274. tglobaltlsaddr:$sym))]>;
  3275. def ADDIdtprelL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
  3276. "#ADDIdtprelL32",
  3277. [(set i32:$rD,
  3278. (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
  3279. def ADDISdtprelHA32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
  3280. "#ADDISdtprelHA32",
  3281. [(set i32:$rD,
  3282. (PPCaddisDtprelHA i32:$reg,
  3283. tglobaltlsaddr:$disp))]>;
  3284. // Support for Position-independent code
  3285. def LWZtoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
  3286. "#LWZtoc",
  3287. [(set i32:$rD,
  3288. (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
  3289. def LWZtocL : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc_nor0:$reg),
  3290. "#LWZtocL",
  3291. [(set i32:$rD,
  3292. (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
  3293. def ADDIStocHA : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, tocentry32:$disp),
  3294. "#ADDIStocHA",
  3295. [(set i32:$rD,
  3296. (PPCtoc_entry i32:$reg, tglobaladdr:$disp))]>;
  3297. // Local Data Transform
  3298. def ADDItoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
  3299. "#ADDItoc",
  3300. [(set i32:$rD,
  3301. (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
  3302. // Get Global (GOT) Base Register offset, from the word immediately preceding
  3303. // the function label.
  3304. def UpdateGBR : PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
  3305. // Pseudo-instruction marked for deletion. When deleting the instruction would
  3306. // cause iterator invalidation in MIR transformation passes, this pseudo can be
  3307. // used instead. It will be removed unconditionally at pre-emit time (prior to
  3308. // branch selection).
  3309. def UNENCODED_NOP: PPCEmitTimePseudo<(outs), (ins), "#UNENCODED_NOP", []>;
  3310. // Standard shifts. These are represented separately from the real shifts above
  3311. // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
  3312. // amounts.
  3313. def : Pat<(sra i32:$rS, i32:$rB),
  3314. (SRAW $rS, $rB)>;
  3315. def : Pat<(srl i32:$rS, i32:$rB),
  3316. (SRW $rS, $rB)>;
  3317. def : Pat<(shl i32:$rS, i32:$rB),
  3318. (SLW $rS, $rB)>;
  3319. def : Pat<(i32 (zextloadi1 DForm:$src)),
  3320. (LBZ DForm:$src)>;
  3321. def : Pat<(i32 (zextloadi1 XForm:$src)),
  3322. (LBZX XForm:$src)>;
  3323. def : Pat<(i32 (extloadi1 DForm:$src)),
  3324. (LBZ DForm:$src)>;
  3325. def : Pat<(i32 (extloadi1 XForm:$src)),
  3326. (LBZX XForm:$src)>;
  3327. def : Pat<(i32 (extloadi8 DForm:$src)),
  3328. (LBZ DForm:$src)>;
  3329. def : Pat<(i32 (extloadi8 XForm:$src)),
  3330. (LBZX XForm:$src)>;
  3331. def : Pat<(i32 (extloadi16 DForm:$src)),
  3332. (LHZ DForm:$src)>;
  3333. def : Pat<(i32 (extloadi16 XForm:$src)),
  3334. (LHZX XForm:$src)>;
  3335. let Predicates = [HasFPU] in {
  3336. def : Pat<(f64 (extloadf32 DForm:$src)),
  3337. (COPY_TO_REGCLASS (LFS DForm:$src), F8RC)>;
  3338. def : Pat<(f64 (extloadf32 XForm:$src)),
  3339. (COPY_TO_REGCLASS (LFSX XForm:$src), F8RC)>;
  3340. def : Pat<(f64 (any_fpextend f32:$src)),
  3341. (COPY_TO_REGCLASS $src, F8RC)>;
  3342. }
  3343. // Only seq_cst fences require the heavyweight sync (SYNC 0).
  3344. // All others can use the lightweight sync (SYNC 1).
  3345. // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
  3346. // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
  3347. // versions of Power.
  3348. def : Pat<(atomic_fence (i64 7), (timm)), (SYNC 0)>, Requires<[HasSYNC]>;
  3349. def : Pat<(atomic_fence (i32 7), (timm)), (SYNC 0)>, Requires<[HasSYNC]>;
  3350. def : Pat<(atomic_fence (timm), (timm)), (SYNC 1)>, Requires<[HasSYNC]>;
  3351. def : Pat<(atomic_fence (timm), (timm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
  3352. let Predicates = [HasFPU] in {
  3353. // Additional fnmsub patterns for custom node
  3354. def : Pat<(PPCfnmsub f64:$A, f64:$B, f64:$C),
  3355. (FNMSUB $A, $B, $C)>;
  3356. def : Pat<(PPCfnmsub f32:$A, f32:$B, f32:$C),
  3357. (FNMSUBS $A, $B, $C)>;
  3358. def : Pat<(fneg (PPCfnmsub f64:$A, f64:$B, f64:$C)),
  3359. (FMSUB $A, $B, $C)>;
  3360. def : Pat<(fneg (PPCfnmsub f32:$A, f32:$B, f32:$C)),
  3361. (FMSUBS $A, $B, $C)>;
  3362. def : Pat<(PPCfnmsub f64:$A, f64:$B, (fneg f64:$C)),
  3363. (FNMADD $A, $B, $C)>;
  3364. def : Pat<(PPCfnmsub f32:$A, f32:$B, (fneg f32:$C)),
  3365. (FNMADDS $A, $B, $C)>;
  3366. // FCOPYSIGN's operand types need not agree.
  3367. def : Pat<(fcopysign f64:$frB, f32:$frA),
  3368. (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
  3369. def : Pat<(fcopysign f32:$frB, f64:$frA),
  3370. (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
  3371. }
  3372. // XL Compat intrinsics.
  3373. def : Pat<(int_ppc_fmsub f64:$A, f64:$B, f64:$C), (FMSUB $A, $B, $C)>;
  3374. def : Pat<(int_ppc_fmsubs f32:$A, f32:$B, f32:$C), (FMSUBS $A, $B, $C)>;
  3375. def : Pat<(int_ppc_fnmsub f64:$A, f64:$B, f64:$C), (FNMSUB $A, $B, $C)>;
  3376. def : Pat<(int_ppc_fnmsubs f32:$A, f32:$B, f32:$C), (FNMSUBS $A, $B, $C)>;
  3377. def : Pat<(int_ppc_fnmadd f64:$A, f64:$B, f64:$C), (FNMADD $A, $B, $C)>;
  3378. def : Pat<(int_ppc_fnmadds f32:$A, f32:$B, f32:$C), (FNMADDS $A, $B, $C)>;
  3379. def : Pat<(int_ppc_fre f64:$A), (FRE $A)>;
  3380. def : Pat<(int_ppc_fres f32:$A), (FRES $A)>;
  3381. include "PPCInstrAltivec.td"
  3382. include "PPCInstrSPE.td"
  3383. include "PPCInstr64Bit.td"
  3384. include "PPCInstrVSX.td"
  3385. include "PPCInstrHTM.td"
  3386. def crnot : OutPatFrag<(ops node:$in),
  3387. (CRNOR $in, $in)>;
  3388. def : Pat<(not i1:$in),
  3389. (crnot $in)>;
  3390. // Prefixed instructions may require access to the above defs at a later
  3391. // time so we include this after the def.
  3392. include "PPCInstrPrefix.td"
  3393. // Patterns for arithmetic i1 operations.
  3394. def : Pat<(add i1:$a, i1:$b),
  3395. (CRXOR $a, $b)>;
  3396. def : Pat<(sub i1:$a, i1:$b),
  3397. (CRXOR $a, $b)>;
  3398. def : Pat<(mul i1:$a, i1:$b),
  3399. (CRAND $a, $b)>;
  3400. // We're sometimes asked to materialize i1 -1, which is just 1 in this case
  3401. // (-1 is used to mean all bits set).
  3402. def : Pat<(i1 -1), (CRSET)>;
  3403. // i1 extensions, implemented in terms of isel.
  3404. def : Pat<(i32 (zext i1:$in)),
  3405. (SELECT_I4 $in, (LI 1), (LI 0))>;
  3406. def : Pat<(i32 (sext i1:$in)),
  3407. (SELECT_I4 $in, (LI -1), (LI 0))>;
  3408. def : Pat<(i64 (zext i1:$in)),
  3409. (SELECT_I8 $in, (LI8 1), (LI8 0))>;
  3410. def : Pat<(i64 (sext i1:$in)),
  3411. (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
  3412. // FIXME: We should choose either a zext or a sext based on other constants
  3413. // already around.
  3414. def : Pat<(i32 (anyext i1:$in)),
  3415. (SELECT_I4 $in, (LI 1), (LI 0))>;
  3416. def : Pat<(i64 (anyext i1:$in)),
  3417. (SELECT_I8 $in, (LI8 1), (LI8 0))>;
  3418. // match setcc on i1 variables.
  3419. // CRANDC is:
  3420. // 1 1 : F
  3421. // 1 0 : T
  3422. // 0 1 : F
  3423. // 0 0 : F
  3424. //
  3425. // LT is:
  3426. // -1 -1 : F
  3427. // -1 0 : T
  3428. // 0 -1 : F
  3429. // 0 0 : F
  3430. //
  3431. // ULT is:
  3432. // 1 1 : F
  3433. // 1 0 : F
  3434. // 0 1 : T
  3435. // 0 0 : F
  3436. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
  3437. (CRANDC $s1, $s2)>;
  3438. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
  3439. (CRANDC $s2, $s1)>;
  3440. // CRORC is:
  3441. // 1 1 : T
  3442. // 1 0 : T
  3443. // 0 1 : F
  3444. // 0 0 : T
  3445. //
  3446. // LE is:
  3447. // -1 -1 : T
  3448. // -1 0 : T
  3449. // 0 -1 : F
  3450. // 0 0 : T
  3451. //
  3452. // ULE is:
  3453. // 1 1 : T
  3454. // 1 0 : F
  3455. // 0 1 : T
  3456. // 0 0 : T
  3457. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
  3458. (CRORC $s1, $s2)>;
  3459. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
  3460. (CRORC $s2, $s1)>;
  3461. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
  3462. (CREQV $s1, $s2)>;
  3463. // GE is:
  3464. // -1 -1 : T
  3465. // -1 0 : F
  3466. // 0 -1 : T
  3467. // 0 0 : T
  3468. //
  3469. // UGE is:
  3470. // 1 1 : T
  3471. // 1 0 : T
  3472. // 0 1 : F
  3473. // 0 0 : T
  3474. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
  3475. (CRORC $s2, $s1)>;
  3476. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
  3477. (CRORC $s1, $s2)>;
  3478. // GT is:
  3479. // -1 -1 : F
  3480. // -1 0 : F
  3481. // 0 -1 : T
  3482. // 0 0 : F
  3483. //
  3484. // UGT is:
  3485. // 1 1 : F
  3486. // 1 0 : T
  3487. // 0 1 : F
  3488. // 0 0 : F
  3489. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
  3490. (CRANDC $s2, $s1)>;
  3491. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
  3492. (CRANDC $s1, $s2)>;
  3493. def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
  3494. (CRXOR $s1, $s2)>;
  3495. // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
  3496. // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
  3497. // floating-point types.
  3498. multiclass CRNotPat<dag pattern, dag result> {
  3499. def : Pat<pattern, (crnot result)>;
  3500. def : Pat<(not pattern), result>;
  3501. // We can also fold the crnot into an extension:
  3502. def : Pat<(i32 (zext pattern)),
  3503. (SELECT_I4 result, (LI 0), (LI 1))>;
  3504. def : Pat<(i32 (sext pattern)),
  3505. (SELECT_I4 result, (LI 0), (LI -1))>;
  3506. // We can also fold the crnot into an extension:
  3507. def : Pat<(i64 (zext pattern)),
  3508. (SELECT_I8 result, (LI8 0), (LI8 1))>;
  3509. def : Pat<(i64 (sext pattern)),
  3510. (SELECT_I8 result, (LI8 0), (LI8 -1))>;
  3511. // FIXME: We should choose either a zext or a sext based on other constants
  3512. // already around.
  3513. def : Pat<(i32 (anyext pattern)),
  3514. (SELECT_I4 result, (LI 0), (LI 1))>;
  3515. def : Pat<(i64 (anyext pattern)),
  3516. (SELECT_I8 result, (LI8 0), (LI8 1))>;
  3517. }
  3518. // FIXME: Because of what seems like a bug in TableGen's type-inference code,
  3519. // we need to write imm:$imm in the output patterns below, not just $imm, or
  3520. // else the resulting matcher will not correctly add the immediate operand
  3521. // (making it a register operand instead).
  3522. // extended SETCC.
  3523. multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
  3524. OutPatFrag rfrag, OutPatFrag rfrag8> {
  3525. def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
  3526. (rfrag $s1)>;
  3527. def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
  3528. (rfrag8 $s1)>;
  3529. def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
  3530. (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
  3531. def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
  3532. (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
  3533. def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
  3534. (rfrag $s1)>;
  3535. def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
  3536. (rfrag8 $s1)>;
  3537. def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
  3538. (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
  3539. def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
  3540. (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
  3541. }
  3542. // Note that we do all inversions below with i(32|64)not, instead of using
  3543. // (xori x, 1) because on the A2 nor has single-cycle latency while xori
  3544. // has 2-cycle latency.
  3545. defm : ExtSetCCPat<SETEQ,
  3546. PatFrag<(ops node:$in, node:$cc),
  3547. (setcc $in, 0, $cc)>,
  3548. OutPatFrag<(ops node:$in),
  3549. (RLWINM (CNTLZW $in), 27, 31, 31)>,
  3550. OutPatFrag<(ops node:$in),
  3551. (RLDICL (CNTLZD $in), 58, 63)> >;
  3552. defm : ExtSetCCPat<SETNE,
  3553. PatFrag<(ops node:$in, node:$cc),
  3554. (setcc $in, 0, $cc)>,
  3555. OutPatFrag<(ops node:$in),
  3556. (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
  3557. OutPatFrag<(ops node:$in),
  3558. (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
  3559. defm : ExtSetCCPat<SETLT,
  3560. PatFrag<(ops node:$in, node:$cc),
  3561. (setcc $in, 0, $cc)>,
  3562. OutPatFrag<(ops node:$in),
  3563. (RLWINM $in, 1, 31, 31)>,
  3564. OutPatFrag<(ops node:$in),
  3565. (RLDICL $in, 1, 63)> >;
  3566. defm : ExtSetCCPat<SETGE,
  3567. PatFrag<(ops node:$in, node:$cc),
  3568. (setcc $in, 0, $cc)>,
  3569. OutPatFrag<(ops node:$in),
  3570. (RLWINM (i32not $in), 1, 31, 31)>,
  3571. OutPatFrag<(ops node:$in),
  3572. (RLDICL (i64not $in), 1, 63)> >;
  3573. defm : ExtSetCCPat<SETGT,
  3574. PatFrag<(ops node:$in, node:$cc),
  3575. (setcc $in, 0, $cc)>,
  3576. OutPatFrag<(ops node:$in),
  3577. (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
  3578. OutPatFrag<(ops node:$in),
  3579. (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
  3580. defm : ExtSetCCPat<SETLE,
  3581. PatFrag<(ops node:$in, node:$cc),
  3582. (setcc $in, 0, $cc)>,
  3583. OutPatFrag<(ops node:$in),
  3584. (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
  3585. OutPatFrag<(ops node:$in),
  3586. (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
  3587. defm : ExtSetCCPat<SETLT,
  3588. PatFrag<(ops node:$in, node:$cc),
  3589. (setcc $in, -1, $cc)>,
  3590. OutPatFrag<(ops node:$in),
  3591. (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
  3592. OutPatFrag<(ops node:$in),
  3593. (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
  3594. defm : ExtSetCCPat<SETGE,
  3595. PatFrag<(ops node:$in, node:$cc),
  3596. (setcc $in, -1, $cc)>,
  3597. OutPatFrag<(ops node:$in),
  3598. (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
  3599. OutPatFrag<(ops node:$in),
  3600. (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
  3601. defm : ExtSetCCPat<SETGT,
  3602. PatFrag<(ops node:$in, node:$cc),
  3603. (setcc $in, -1, $cc)>,
  3604. OutPatFrag<(ops node:$in),
  3605. (RLWINM (i32not $in), 1, 31, 31)>,
  3606. OutPatFrag<(ops node:$in),
  3607. (RLDICL (i64not $in), 1, 63)> >;
  3608. defm : ExtSetCCPat<SETLE,
  3609. PatFrag<(ops node:$in, node:$cc),
  3610. (setcc $in, -1, $cc)>,
  3611. OutPatFrag<(ops node:$in),
  3612. (RLWINM $in, 1, 31, 31)>,
  3613. OutPatFrag<(ops node:$in),
  3614. (RLDICL $in, 1, 63)> >;
  3615. // An extended SETCC with shift amount.
  3616. multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
  3617. OutPatFrag rfrag, OutPatFrag rfrag8> {
  3618. def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
  3619. (rfrag $s1, $sa)>;
  3620. def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
  3621. (rfrag8 $s1, $sa)>;
  3622. def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
  3623. (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
  3624. def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
  3625. (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
  3626. def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
  3627. (rfrag $s1, $sa)>;
  3628. def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
  3629. (rfrag8 $s1, $sa)>;
  3630. def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
  3631. (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
  3632. def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
  3633. (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
  3634. }
  3635. defm : ExtSetCCShiftPat<SETNE,
  3636. PatFrag<(ops node:$in, node:$sa, node:$cc),
  3637. (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
  3638. OutPatFrag<(ops node:$in, node:$sa),
  3639. (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
  3640. OutPatFrag<(ops node:$in, node:$sa),
  3641. (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
  3642. defm : ExtSetCCShiftPat<SETEQ,
  3643. PatFrag<(ops node:$in, node:$sa, node:$cc),
  3644. (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
  3645. OutPatFrag<(ops node:$in, node:$sa),
  3646. (RLWNM (i32not $in),
  3647. (SUBFIC $sa, 32), 31, 31)>,
  3648. OutPatFrag<(ops node:$in, node:$sa),
  3649. (RLDCL (i64not $in),
  3650. (SUBFIC $sa, 64), 63)> >;
  3651. // SETCC for i32.
  3652. def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
  3653. (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
  3654. def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
  3655. (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
  3656. def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
  3657. (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
  3658. def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
  3659. (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
  3660. def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
  3661. (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
  3662. def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
  3663. (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
  3664. // For non-equality comparisons, the default code would materialize the
  3665. // constant, then compare against it, like this:
  3666. // lis r2, 4660
  3667. // ori r2, r2, 22136
  3668. // cmpw cr0, r3, r2
  3669. // beq cr0,L6
  3670. // Since we are just comparing for equality, we can emit this instead:
  3671. // xoris r0,r3,0x1234
  3672. // cmplwi cr0,r0,0x5678
  3673. // beq cr0,L6
  3674. def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
  3675. (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
  3676. (LO16 imm:$imm)), sub_eq)>;
  3677. def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
  3678. (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
  3679. def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
  3680. (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
  3681. def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
  3682. (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
  3683. def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
  3684. (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
  3685. def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
  3686. (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
  3687. // SETCC for i64.
  3688. def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
  3689. (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
  3690. def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
  3691. (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
  3692. def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
  3693. (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
  3694. def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
  3695. (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
  3696. def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
  3697. (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
  3698. def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
  3699. (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
  3700. // For non-equality comparisons, the default code would materialize the
  3701. // constant, then compare against it, like this:
  3702. // lis r2, 4660
  3703. // ori r2, r2, 22136
  3704. // cmpd cr0, r3, r2
  3705. // beq cr0,L6
  3706. // Since we are just comparing for equality, we can emit this instead:
  3707. // xoris r0,r3,0x1234
  3708. // cmpldi cr0,r0,0x5678
  3709. // beq cr0,L6
  3710. def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
  3711. (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
  3712. (LO16 imm:$imm)), sub_eq)>;
  3713. def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
  3714. (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
  3715. def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
  3716. (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
  3717. def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
  3718. (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
  3719. def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
  3720. (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
  3721. def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
  3722. (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
  3723. let Predicates = [IsNotISA3_1] in {
  3724. // Instantiations of CRNotPat for i32.
  3725. defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
  3726. (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
  3727. defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
  3728. (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
  3729. defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
  3730. (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
  3731. defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
  3732. (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
  3733. defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
  3734. (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
  3735. defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
  3736. (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
  3737. defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
  3738. (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
  3739. (LO16 imm:$imm)), sub_eq)>;
  3740. defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
  3741. (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
  3742. defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
  3743. (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
  3744. defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
  3745. (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
  3746. defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
  3747. (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
  3748. defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
  3749. (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
  3750. // Instantiations of CRNotPat for i64.
  3751. defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
  3752. (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
  3753. defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
  3754. (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
  3755. defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
  3756. (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
  3757. defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
  3758. (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
  3759. defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
  3760. (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
  3761. defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
  3762. (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
  3763. defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
  3764. (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
  3765. (LO16 imm:$imm)), sub_eq)>;
  3766. defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
  3767. (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
  3768. defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
  3769. (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
  3770. defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
  3771. (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
  3772. defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
  3773. (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
  3774. defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
  3775. (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
  3776. }
  3777. multiclass FSetCCPat<SDPatternOperator SetCC, ValueType Ty, I FCmp> {
  3778. defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUGE)),
  3779. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
  3780. defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETGE)),
  3781. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
  3782. defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETULE)),
  3783. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
  3784. defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETLE)),
  3785. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
  3786. defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUNE)),
  3787. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
  3788. defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETNE)),
  3789. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
  3790. defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETO)),
  3791. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_un)>;
  3792. def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOLT)),
  3793. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
  3794. def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETLT)),
  3795. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
  3796. def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOGT)),
  3797. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
  3798. def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETGT)),
  3799. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
  3800. def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOEQ)),
  3801. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
  3802. def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETEQ)),
  3803. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
  3804. def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUO)),
  3805. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_un)>;
  3806. }
  3807. let Predicates = [HasFPU] in {
  3808. // FCMPU: If either of the operands is a Signaling NaN, then VXSNAN is set.
  3809. // SETCC for f32.
  3810. defm : FSetCCPat<any_fsetcc, f32, FCMPUS>;
  3811. // SETCC for f64.
  3812. defm : FSetCCPat<any_fsetcc, f64, FCMPUD>;
  3813. // SETCC for f128.
  3814. defm : FSetCCPat<any_fsetcc, f128, XSCMPUQP>;
  3815. // FCMPO: If either of the operands is a Signaling NaN, then VXSNAN is set and,
  3816. // if neither operand is a Signaling NaN but at least one operand is a Quiet NaN,
  3817. // then VXVC is set.
  3818. // SETCCS for f32.
  3819. defm : FSetCCPat<strict_fsetccs, f32, FCMPOS>;
  3820. // SETCCS for f64.
  3821. defm : FSetCCPat<strict_fsetccs, f64, FCMPOD>;
  3822. // SETCCS for f128.
  3823. defm : FSetCCPat<strict_fsetccs, f128, XSCMPOQP>;
  3824. }
  3825. // This must be in this file because it relies on patterns defined in this file
  3826. // after the inclusion of the instruction sets.
  3827. let Predicates = [HasSPE] in {
  3828. // SETCC for f32.
  3829. def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOLT)),
  3830. (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
  3831. def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETLT)),
  3832. (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
  3833. def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOGT)),
  3834. (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
  3835. def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETGT)),
  3836. (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
  3837. def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOEQ)),
  3838. (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
  3839. def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETEQ)),
  3840. (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
  3841. defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETUGE)),
  3842. (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
  3843. defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETGE)),
  3844. (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
  3845. defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETULE)),
  3846. (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
  3847. defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETLE)),
  3848. (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
  3849. defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETUNE)),
  3850. (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
  3851. defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETNE)),
  3852. (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
  3853. // SETCC for f64.
  3854. def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOLT)),
  3855. (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
  3856. def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETLT)),
  3857. (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
  3858. def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOGT)),
  3859. (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
  3860. def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETGT)),
  3861. (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
  3862. def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOEQ)),
  3863. (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
  3864. def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETEQ)),
  3865. (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
  3866. defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETUGE)),
  3867. (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
  3868. defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETGE)),
  3869. (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
  3870. defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETULE)),
  3871. (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
  3872. defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETLE)),
  3873. (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
  3874. defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETUNE)),
  3875. (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
  3876. defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETNE)),
  3877. (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
  3878. }
  3879. // match select on i1 variables:
  3880. def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
  3881. (CROR (CRAND $cond , $tval),
  3882. (CRAND (crnot $cond), $fval))>;
  3883. // match selectcc on i1 variables:
  3884. // select (lhs == rhs), tval, fval is:
  3885. // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
  3886. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
  3887. (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
  3888. (CRAND (CRORC $rhs, $lhs), $fval))>;
  3889. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
  3890. (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
  3891. (CRAND (CRORC $lhs, $rhs), $fval))>;
  3892. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
  3893. (CROR (CRAND (CRORC $lhs, $rhs), $tval),
  3894. (CRAND (CRANDC $rhs, $lhs), $fval))>;
  3895. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
  3896. (CROR (CRAND (CRORC $rhs, $lhs), $tval),
  3897. (CRAND (CRANDC $lhs, $rhs), $fval))>;
  3898. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
  3899. (CROR (CRAND (CREQV $lhs, $rhs), $tval),
  3900. (CRAND (CRXOR $lhs, $rhs), $fval))>;
  3901. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
  3902. (CROR (CRAND (CRORC $rhs, $lhs), $tval),
  3903. (CRAND (CRANDC $lhs, $rhs), $fval))>;
  3904. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
  3905. (CROR (CRAND (CRORC $lhs, $rhs), $tval),
  3906. (CRAND (CRANDC $rhs, $lhs), $fval))>;
  3907. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
  3908. (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
  3909. (CRAND (CRORC $lhs, $rhs), $fval))>;
  3910. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
  3911. (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
  3912. (CRAND (CRORC $rhs, $lhs), $fval))>;
  3913. def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
  3914. (CROR (CRAND (CREQV $lhs, $rhs), $fval),
  3915. (CRAND (CRXOR $lhs, $rhs), $tval))>;
  3916. // match selectcc on i1 variables with non-i1 output.
  3917. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
  3918. (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3919. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
  3920. (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3921. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
  3922. (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
  3923. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
  3924. (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
  3925. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
  3926. (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
  3927. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
  3928. (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
  3929. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
  3930. (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
  3931. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
  3932. (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3933. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
  3934. (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3935. def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
  3936. (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
  3937. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
  3938. (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3939. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
  3940. (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3941. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
  3942. (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
  3943. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
  3944. (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
  3945. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
  3946. (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
  3947. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
  3948. (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
  3949. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
  3950. (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
  3951. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
  3952. (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3953. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
  3954. (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3955. def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
  3956. (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
  3957. let Predicates = [HasFPU] in {
  3958. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
  3959. (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3960. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
  3961. (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3962. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
  3963. (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
  3964. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
  3965. (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
  3966. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
  3967. (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
  3968. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
  3969. (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
  3970. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
  3971. (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
  3972. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
  3973. (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3974. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
  3975. (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3976. def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
  3977. (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
  3978. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
  3979. (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3980. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
  3981. (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3982. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
  3983. (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
  3984. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
  3985. (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
  3986. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
  3987. (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
  3988. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
  3989. (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
  3990. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
  3991. (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
  3992. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
  3993. (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
  3994. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
  3995. (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
  3996. def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
  3997. (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
  3998. }
  3999. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
  4000. (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
  4001. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
  4002. (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
  4003. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
  4004. (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
  4005. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
  4006. (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
  4007. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
  4008. (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
  4009. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
  4010. (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
  4011. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
  4012. (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
  4013. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
  4014. (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
  4015. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
  4016. (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
  4017. def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
  4018. (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
  4019. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
  4020. (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
  4021. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
  4022. (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
  4023. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
  4024. (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
  4025. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
  4026. (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
  4027. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
  4028. (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
  4029. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
  4030. (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
  4031. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
  4032. (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
  4033. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
  4034. (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
  4035. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
  4036. (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
  4037. def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
  4038. (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
  4039. def ANDI_rec_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
  4040. "#ANDI_rec_1_EQ_BIT",
  4041. [(set i1:$dst, (trunc (not i32:$in)))]>;
  4042. def ANDI_rec_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
  4043. "#ANDI_rec_1_GT_BIT",
  4044. [(set i1:$dst, (trunc i32:$in))]>;
  4045. def ANDI_rec_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
  4046. "#ANDI_rec_1_EQ_BIT8",
  4047. [(set i1:$dst, (trunc (not i64:$in)))]>;
  4048. def ANDI_rec_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
  4049. "#ANDI_rec_1_GT_BIT8",
  4050. [(set i1:$dst, (trunc i64:$in))]>;
  4051. def : Pat<(i1 (not (trunc i32:$in))),
  4052. (ANDI_rec_1_EQ_BIT $in)>;
  4053. def : Pat<(i1 (not (trunc i64:$in))),
  4054. (ANDI_rec_1_EQ_BIT8 $in)>;
  4055. def : Pat<(int_ppc_fsel f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), (FSELD $FRA, $FRC, $FRB)>;
  4056. def : Pat<(int_ppc_frsqrte f8rc:$frB), (FRSQRTE $frB)>;
  4057. def : Pat<(int_ppc_frsqrtes f4rc:$frB), (FRSQRTES $frB)>;
  4058. //===----------------------------------------------------------------------===//
  4059. // PowerPC Instructions used for assembler/disassembler only
  4060. //
  4061. // FIXME: For B=0 or B > 8, the registers following RT are used.
  4062. // WARNING: Do not add patterns for this instruction without fixing this.
  4063. def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT),
  4064. (ins gprc:$A, u5imm:$B),
  4065. "lswi $RT, $A, $B", IIC_LdStLoad, []>;
  4066. // FIXME: For B=0 or B > 8, the registers following RT are used.
  4067. // WARNING: Do not add patterns for this instruction without fixing this.
  4068. def STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
  4069. (ins gprc:$RT, gprc:$A, u5imm:$B),
  4070. "stswi $RT, $A, $B", IIC_LdStLoad, []>;
  4071. def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
  4072. "isync", IIC_SprISYNC, []>;
  4073. def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
  4074. "icbi $src", IIC_LdStICBI, []>;
  4075. def WAIT : XForm_24_sync<31, 30, (outs), (ins u2imm:$L),
  4076. "wait $L", IIC_LdStLoad, []>;
  4077. def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
  4078. "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
  4079. def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
  4080. "mtsr $SR, $RS", IIC_SprMTSR>;
  4081. def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
  4082. "mfsr $RS, $SR", IIC_SprMFSR>;
  4083. def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
  4084. "mtsrin $RS, $RB", IIC_SprMTSR>;
  4085. def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
  4086. "mfsrin $RS, $RB", IIC_SprMFSR>;
  4087. def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, u1imm:$L),
  4088. "mtmsr $RS, $L", IIC_SprMTMSR>;
  4089. def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
  4090. "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
  4091. let L = 0;
  4092. }
  4093. def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
  4094. Requires<[IsBookE]> {
  4095. bits<1> E;
  4096. let Inst{16} = E;
  4097. let Inst{21-30} = 163;
  4098. }
  4099. def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
  4100. "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
  4101. def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
  4102. "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
  4103. def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
  4104. def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
  4105. def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
  4106. def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
  4107. def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
  4108. "mfmsr $RT", IIC_SprMFMSR, []>;
  4109. def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, u1imm:$L),
  4110. "mtmsrd $RS, $L", IIC_SprMTMSRD>;
  4111. def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
  4112. "mcrfs $BF, $BFA", IIC_BrMCR>;
  4113. // All MTFSF variants may change the rounding mode so conservatively set it
  4114. // as an implicit def for all of them.
  4115. let Predicates = [HasFPU] in {
  4116. let Defs = [RM], hasSideEffects = 1 in {
  4117. let isCodeGenOnly = 1,
  4118. Pattern = [(int_ppc_mtfsfi timm:$BF, timm:$U)], W = 0 in
  4119. def MTFSFIb : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U),
  4120. "mtfsfi $BF, $U", IIC_IntMFFS>;
  4121. def MTFSFI : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U, i32imm:$W),
  4122. "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
  4123. let Defs = [CR1] in
  4124. def MTFSFI_rec : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U, u1imm:$W),
  4125. "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isRecordForm;
  4126. def MTFSF : XFLForm_1<63, 711, (outs),
  4127. (ins i32imm:$FLM, f8rc:$FRB, u1imm:$L, i32imm:$W),
  4128. "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
  4129. let Defs = [CR1] in
  4130. def MTFSF_rec : XFLForm_1<63, 711, (outs),
  4131. (ins i32imm:$FLM, f8rc:$FRB, u1imm:$L, i32imm:$W),
  4132. "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isRecordForm;
  4133. }
  4134. def : InstAlias<"mtfsfi $BF, $U", (MTFSFI u3imm:$BF, u4imm:$U, 0)>;
  4135. def : InstAlias<"mtfsfi. $BF, $U", (MTFSFI_rec u3imm:$BF, u4imm:$U, 0)>;
  4136. def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
  4137. def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSF_rec i32imm:$FLM, f8rc:$FRB, 0, 0)>;
  4138. }
  4139. def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
  4140. "slbie $RB", IIC_SprSLBIE, []>;
  4141. def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
  4142. "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
  4143. def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
  4144. "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
  4145. def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
  4146. "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
  4147. def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
  4148. let Defs = [CR0] in
  4149. def SLBFEE_rec : XForm_26<31, 979, (outs gprc:$RT), (ins gprc:$RB),
  4150. "slbfee. $RT, $RB", IIC_SprSLBFEE, []>, isRecordForm;
  4151. def TLBIA : XForm_0<31, 370, (outs), (ins),
  4152. "tlbia", IIC_SprTLBIA, []>;
  4153. def TLBSYNC : XForm_0<31, 566, (outs), (ins),
  4154. "tlbsync", IIC_SprTLBSYNC, []>;
  4155. def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
  4156. "tlbiel $RB", IIC_SprTLBIEL, []>;
  4157. def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
  4158. "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
  4159. def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
  4160. "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
  4161. def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
  4162. "tlbie $RB,$RS", IIC_SprTLBIE, []>;
  4163. def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
  4164. IIC_LdStLoad>, Requires<[IsBookE]>;
  4165. def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
  4166. IIC_LdStLoad>, Requires<[IsBookE]>;
  4167. def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
  4168. "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
  4169. def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
  4170. "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
  4171. def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
  4172. "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
  4173. def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
  4174. "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
  4175. def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
  4176. "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
  4177. Requires<[IsPPC4xx]>;
  4178. def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
  4179. (ins gprc:$RST, gprc:$A, gprc:$B),
  4180. "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
  4181. Requires<[IsPPC4xx]>, isRecordForm;
  4182. def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
  4183. def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
  4184. Requires<[IsBookE]>;
  4185. def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
  4186. Requires<[IsBookE]>;
  4187. def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
  4188. Requires<[IsE500]>;
  4189. def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
  4190. Requires<[IsE500]>;
  4191. def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
  4192. "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
  4193. def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
  4194. "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
  4195. def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
  4196. def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
  4197. def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
  4198. def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
  4199. (ins gprc:$A, gprc:$B),
  4200. "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
  4201. def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
  4202. (ins gprc:$A, gprc:$B),
  4203. "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
  4204. def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
  4205. (ins gprc:$A, gprc:$B),
  4206. "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
  4207. def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
  4208. (ins gprc:$A, gprc:$B),
  4209. "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
  4210. def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
  4211. (ins gprc:$RST, gprc:$A, gprc:$B),
  4212. "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
  4213. def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
  4214. (ins gprc:$RST, gprc:$A, gprc:$B),
  4215. "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
  4216. def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
  4217. (ins gprc:$RST, gprc:$A, gprc:$B),
  4218. "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
  4219. def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
  4220. (ins gprc:$RST, gprc:$A, gprc:$B),
  4221. "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
  4222. // External PID Load Store Instructions
  4223. def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
  4224. "lbepx $rD, $src", IIC_LdStLoad, []>,
  4225. Requires<[IsE500]>;
  4226. def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
  4227. "lfdepx $frD, $src", IIC_LdStLFD, []>,
  4228. Requires<[IsE500]>;
  4229. def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
  4230. "lhepx $rD, $src", IIC_LdStLoad, []>,
  4231. Requires<[IsE500]>;
  4232. def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
  4233. "lwepx $rD, $src", IIC_LdStLoad, []>,
  4234. Requires<[IsE500]>;
  4235. def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
  4236. "stbepx $rS, $dst", IIC_LdStStore, []>,
  4237. Requires<[IsE500]>;
  4238. def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
  4239. "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
  4240. Requires<[IsE500]>;
  4241. def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
  4242. "sthepx $rS, $dst", IIC_LdStStore, []>,
  4243. Requires<[IsE500]>;
  4244. def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
  4245. "stwepx $rS, $dst", IIC_LdStStore, []>,
  4246. Requires<[IsE500]>;
  4247. def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
  4248. IIC_LdStDCBF, []>, Requires<[IsE500]>;
  4249. def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
  4250. IIC_LdStDCBF, []>, Requires<[IsE500]>;
  4251. def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
  4252. "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
  4253. Requires<[IsE500]>;
  4254. def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
  4255. "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
  4256. Requires<[IsE500]>;
  4257. def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
  4258. IIC_LdStDCBF, []>, Requires<[IsE500]>;
  4259. def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
  4260. IIC_LdStDCBF, []>, Requires<[IsE500]>;
  4261. def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
  4262. IIC_LdStICBI, []>, Requires<[IsE500]>;
  4263. //===----------------------------------------------------------------------===//
  4264. // PowerPC Assembler Instruction Aliases
  4265. //
  4266. // Pseudo-instructions for alternate assembly syntax (never used by codegen).
  4267. // These are aliases that require C++ handling to convert to the target
  4268. // instruction, while InstAliases can be handled directly by tblgen.
  4269. class PPCAsmPseudo<string asm, dag iops>
  4270. : Instruction {
  4271. let Namespace = "PPC";
  4272. bit PPC64 = 0; // Default value, override with isPPC64
  4273. let OutOperandList = (outs);
  4274. let InOperandList = iops;
  4275. let Pattern = [];
  4276. let AsmString = asm;
  4277. let isAsmParserOnly = 1;
  4278. let isPseudo = 1;
  4279. let hasNoSchedulingInfo = 1;
  4280. }
  4281. def : InstAlias<"sc", (SC 0)>;
  4282. def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
  4283. def : InstAlias<"hwsync", (SYNC 0), 0>, Requires<[HasSYNC]>;
  4284. def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
  4285. def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
  4286. def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
  4287. def : InstAlias<"wait", (WAIT 0)>;
  4288. def : InstAlias<"waitrsv", (WAIT 1)>;
  4289. def : InstAlias<"waitimpl", (WAIT 2)>;
  4290. def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
  4291. def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
  4292. def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
  4293. def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
  4294. def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
  4295. def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
  4296. def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
  4297. def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
  4298. def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
  4299. def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
  4300. def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
  4301. def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
  4302. def : Pat<(int_ppc_isync), (ISYNC)>;
  4303. def : Pat<(int_ppc_dcbfl xoaddr:$dst),
  4304. (DCBF 1, xoaddr:$dst)>;
  4305. def : Pat<(int_ppc_dcbflp xoaddr:$dst),
  4306. (DCBF 3, xoaddr:$dst)>;
  4307. let Predicates = [IsISA3_1] in {
  4308. def DCBFPS : PPCAsmPseudo<"dcbfps $dst", (ins memrr:$dst)>;
  4309. def DCBSTPS : PPCAsmPseudo<"dcbstps $dst", (ins memrr:$dst)>;
  4310. def : Pat<(int_ppc_dcbfps xoaddr:$dst),
  4311. (DCBF 4, xoaddr:$dst)>;
  4312. def : Pat<(int_ppc_dcbstps xoaddr:$dst),
  4313. (DCBF 6, xoaddr:$dst)>;
  4314. }
  4315. def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
  4316. def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
  4317. def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
  4318. def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
  4319. def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
  4320. def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
  4321. def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
  4322. def : InstAlias<"xnop", (XORI R0, R0, 0)>;
  4323. def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
  4324. def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
  4325. //Disable this alias on AIX for now because as does not support them.
  4326. let Predicates = [ModernAs] in {
  4327. foreach BR = 0-7 in {
  4328. def : InstAlias<"mfbr"#BR#" $Rx",
  4329. (MFDCR gprc:$Rx, !add(BR, 0x80))>,
  4330. Requires<[IsPPC4xx]>;
  4331. def : InstAlias<"mtbr"#BR#" $Rx",
  4332. (MTDCR gprc:$Rx, !add(BR, 0x80))>,
  4333. Requires<[IsPPC4xx]>;
  4334. }
  4335. def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
  4336. def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
  4337. def : InstAlias<"mtudscr $Rx", (MTSPR 3, gprc:$Rx)>;
  4338. def : InstAlias<"mfudscr $Rx", (MFSPR gprc:$Rx, 3)>;
  4339. def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
  4340. def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
  4341. def : InstAlias<"mtlr $Rx", (MTSPR 8, gprc:$Rx)>;
  4342. def : InstAlias<"mflr $Rx", (MFSPR gprc:$Rx, 8)>;
  4343. def : InstAlias<"mtctr $Rx", (MTSPR 9, gprc:$Rx)>;
  4344. def : InstAlias<"mfctr $Rx", (MFSPR gprc:$Rx, 9)>;
  4345. def : InstAlias<"mtuamr $Rx", (MTSPR 13, gprc:$Rx)>;
  4346. def : InstAlias<"mfuamr $Rx", (MFSPR gprc:$Rx, 13)>;
  4347. def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
  4348. def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
  4349. def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
  4350. def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
  4351. def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
  4352. def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
  4353. def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
  4354. def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
  4355. def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
  4356. def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
  4357. def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
  4358. def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
  4359. def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
  4360. def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
  4361. def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
  4362. def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
  4363. def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
  4364. def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
  4365. def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
  4366. def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
  4367. foreach SPRG = 4-7 in {
  4368. def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
  4369. Requires<[IsBookE]>;
  4370. def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
  4371. Requires<[IsBookE]>;
  4372. def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
  4373. Requires<[IsBookE]>;
  4374. def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
  4375. Requires<[IsBookE]>;
  4376. }
  4377. foreach SPRG = 0-3 in {
  4378. def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
  4379. def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
  4380. def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
  4381. def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
  4382. }
  4383. def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
  4384. def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
  4385. def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
  4386. def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
  4387. def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
  4388. def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
  4389. def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
  4390. foreach BATR = 0-3 in {
  4391. def : InstAlias<"mtdbatu "#BATR#", $Rx",
  4392. (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
  4393. Requires<[IsPPC6xx]>;
  4394. def : InstAlias<"mfdbatu $Rx, "#BATR,
  4395. (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
  4396. Requires<[IsPPC6xx]>;
  4397. def : InstAlias<"mtdbatl "#BATR#", $Rx",
  4398. (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
  4399. Requires<[IsPPC6xx]>;
  4400. def : InstAlias<"mfdbatl $Rx, "#BATR,
  4401. (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
  4402. Requires<[IsPPC6xx]>;
  4403. def : InstAlias<"mtibatu "#BATR#", $Rx",
  4404. (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
  4405. Requires<[IsPPC6xx]>;
  4406. def : InstAlias<"mfibatu $Rx, "#BATR,
  4407. (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
  4408. Requires<[IsPPC6xx]>;
  4409. def : InstAlias<"mtibatl "#BATR#", $Rx",
  4410. (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
  4411. Requires<[IsPPC6xx]>;
  4412. def : InstAlias<"mfibatl $Rx, "#BATR,
  4413. (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
  4414. Requires<[IsPPC6xx]>;
  4415. }
  4416. def : InstAlias<"mtppr $RT", (MTSPR 896, gprc:$RT)>;
  4417. def : InstAlias<"mfppr $RT", (MFSPR gprc:$RT, 896)>;
  4418. def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4419. def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
  4420. def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4421. def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
  4422. def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4423. def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
  4424. def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
  4425. def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4426. def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
  4427. def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4428. def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4429. def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
  4430. def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4431. def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
  4432. def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4433. def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
  4434. def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
  4435. def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
  4436. }
  4437. def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
  4438. def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
  4439. Requires<[IsPPC4xx]>;
  4440. def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
  4441. Requires<[IsPPC4xx]>;
  4442. def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
  4443. Requires<[IsPPC4xx]>;
  4444. def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
  4445. Requires<[IsPPC4xx]>;
  4446. def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
  4447. def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
  4448. (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
  4449. def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
  4450. (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
  4451. def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
  4452. (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
  4453. def SUBIC_rec : PPCAsmPseudo<"subic. $rA, $rB, $imm",
  4454. (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
  4455. def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
  4456. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4457. def EXTLWI_rec : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
  4458. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4459. def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
  4460. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4461. def EXTRWI_rec : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
  4462. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4463. def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
  4464. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4465. def INSLWI_rec : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
  4466. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4467. def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
  4468. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4469. def INSRWI_rec : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
  4470. (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
  4471. def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
  4472. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4473. def ROTRWI_rec : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
  4474. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4475. def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
  4476. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4477. def SLWI_rec : PPCAsmPseudo<"slwi. $rA, $rS, $n",
  4478. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4479. def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
  4480. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4481. def SRWI_rec : PPCAsmPseudo<"srwi. $rA, $rS, $n",
  4482. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4483. def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
  4484. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4485. def CLRRWI_rec : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
  4486. (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
  4487. def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
  4488. (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
  4489. def CLRLSLWI_rec : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
  4490. (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
  4491. def : InstAlias<"isellt $rT, $rA, $rB",
  4492. (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0LT)>;
  4493. def : InstAlias<"iselgt $rT, $rA, $rB",
  4494. (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0GT)>;
  4495. def : InstAlias<"iseleq $rT, $rA, $rB",
  4496. (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0EQ)>;
  4497. def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
  4498. def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINM_rec gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
  4499. def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
  4500. def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNM_rec gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
  4501. def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
  4502. def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINM_rec gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
  4503. def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
  4504. def : InstAlias<"cntlzw. $rA, $rS", (CNTLZW_rec gprc:$rA, gprc:$rS)>;
  4505. // The POWER variant
  4506. def : MnemonicAlias<"cntlz", "cntlzw">;
  4507. def : MnemonicAlias<"cntlz.", "cntlzw.">;
  4508. def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
  4509. (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
  4510. def EXTLDI_rec : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
  4511. (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
  4512. def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
  4513. (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
  4514. def EXTRDI_rec : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
  4515. (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
  4516. def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
  4517. (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
  4518. def INSRDI_rec : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
  4519. (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
  4520. def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
  4521. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4522. def ROTRDI_rec : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
  4523. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4524. def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
  4525. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4526. def SLDI_rec : PPCAsmPseudo<"sldi. $rA, $rS, $n",
  4527. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4528. def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
  4529. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4530. def SRDI_rec : PPCAsmPseudo<"srdi. $rA, $rS, $n",
  4531. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4532. def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
  4533. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4534. def CLRRDI_rec : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
  4535. (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
  4536. def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
  4537. (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
  4538. def CLRLSLDI_rec : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
  4539. (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
  4540. def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
  4541. def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
  4542. def : InstAlias<"rotldi $rA, $rS, $n",
  4543. (RLDICL_32_64 g8rc:$rA, gprc:$rS, u6imm:$n, 0)>;
  4544. def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICL_rec g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
  4545. def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
  4546. def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCL_rec g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
  4547. def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
  4548. def : InstAlias<"clrldi $rA, $rS, $n",
  4549. (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
  4550. def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICL_rec g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
  4551. def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
  4552. def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
  4553. (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
  4554. def RLWINMbm_rec : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
  4555. (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
  4556. def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
  4557. (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
  4558. def RLWIMIbm_rec : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
  4559. (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
  4560. def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
  4561. (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
  4562. def RLWNMbm_rec : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
  4563. (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
  4564. // These generic branch instruction forms are used for the assembler parser only.
  4565. // Defs and Uses are conservative, since we don't know the BO value.
  4566. let PPC970_Unit = 7, isBranch = 1, hasSideEffects = 0 in {
  4567. let Defs = [CTR], Uses = [CTR, RM] in {
  4568. def gBC : BForm_3<16, 0, 0, (outs),
  4569. (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
  4570. "bc $bo, $bi, $dst">;
  4571. def gBCA : BForm_3<16, 1, 0, (outs),
  4572. (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
  4573. "bca $bo, $bi, $dst">;
  4574. let isAsmParserOnly = 1 in {
  4575. def gBCat : BForm_3_at<16, 0, 0, (outs),
  4576. (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
  4577. condbrtarget:$dst),
  4578. "bc$at $bo, $bi, $dst">;
  4579. def gBCAat : BForm_3_at<16, 1, 0, (outs),
  4580. (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
  4581. abscondbrtarget:$dst),
  4582. "bca$at $bo, $bi, $dst">;
  4583. } // isAsmParserOnly = 1
  4584. }
  4585. let Defs = [LR, CTR], Uses = [CTR, RM] in {
  4586. def gBCL : BForm_3<16, 0, 1, (outs),
  4587. (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
  4588. "bcl $bo, $bi, $dst">;
  4589. def gBCLA : BForm_3<16, 1, 1, (outs),
  4590. (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
  4591. "bcla $bo, $bi, $dst">;
  4592. let isAsmParserOnly = 1 in {
  4593. def gBCLat : BForm_3_at<16, 0, 1, (outs),
  4594. (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
  4595. condbrtarget:$dst),
  4596. "bcl$at $bo, $bi, $dst">;
  4597. def gBCLAat : BForm_3_at<16, 1, 1, (outs),
  4598. (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
  4599. abscondbrtarget:$dst),
  4600. "bcla$at $bo, $bi, $dst">;
  4601. } // // isAsmParserOnly = 1
  4602. }
  4603. let Defs = [CTR], Uses = [CTR, LR, RM] in
  4604. def gBCLR : XLForm_2<19, 16, 0, (outs),
  4605. (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
  4606. "bclr $bo, $bi, $bh", IIC_BrB, []>;
  4607. let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
  4608. def gBCLRL : XLForm_2<19, 16, 1, (outs),
  4609. (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
  4610. "bclrl $bo, $bi, $bh", IIC_BrB, []>;
  4611. let Defs = [CTR], Uses = [CTR, LR, RM] in
  4612. def gBCCTR : XLForm_2<19, 528, 0, (outs),
  4613. (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
  4614. "bcctr $bo, $bi, $bh", IIC_BrB, []>;
  4615. let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
  4616. def gBCCTRL : XLForm_2<19, 528, 1, (outs),
  4617. (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
  4618. "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
  4619. }
  4620. multiclass BranchSimpleMnemonicAT<string pm, int at> {
  4621. def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
  4622. condbrtarget:$dst)>;
  4623. def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
  4624. condbrtarget:$dst)>;
  4625. def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
  4626. condbrtarget:$dst)>;
  4627. def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
  4628. condbrtarget:$dst)>;
  4629. }
  4630. defm : BranchSimpleMnemonicAT<"+", 3>;
  4631. defm : BranchSimpleMnemonicAT<"-", 2>;
  4632. def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
  4633. def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
  4634. def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
  4635. def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
  4636. multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
  4637. def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
  4638. def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
  4639. def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
  4640. def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
  4641. def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
  4642. def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
  4643. }
  4644. multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
  4645. : BranchSimpleMnemonic1<name, pm, bo> {
  4646. def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
  4647. def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
  4648. }
  4649. defm : BranchSimpleMnemonic2<"t", "", 12>;
  4650. defm : BranchSimpleMnemonic2<"f", "", 4>;
  4651. defm : BranchSimpleMnemonic2<"t", "-", 14>;
  4652. defm : BranchSimpleMnemonic2<"f", "-", 6>;
  4653. defm : BranchSimpleMnemonic2<"t", "+", 15>;
  4654. defm : BranchSimpleMnemonic2<"f", "+", 7>;
  4655. defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
  4656. defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
  4657. defm : BranchSimpleMnemonic1<"dzt", "", 10>;
  4658. defm : BranchSimpleMnemonic1<"dzf", "", 2>;
  4659. multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
  4660. def : InstAlias<"b"#name#pm#" $cc, $dst",
  4661. (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
  4662. def : InstAlias<"b"#name#pm#" $dst",
  4663. (BCC bibo, CR0, condbrtarget:$dst)>;
  4664. def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
  4665. (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
  4666. def : InstAlias<"b"#name#"a"#pm#" $dst",
  4667. (BCCA bibo, CR0, abscondbrtarget:$dst)>;
  4668. def : InstAlias<"b"#name#"lr"#pm#" $cc",
  4669. (BCCLR bibo, crrc:$cc)>;
  4670. def : InstAlias<"b"#name#"lr"#pm,
  4671. (BCCLR bibo, CR0)>;
  4672. def : InstAlias<"b"#name#"ctr"#pm#" $cc",
  4673. (BCCCTR bibo, crrc:$cc)>;
  4674. def : InstAlias<"b"#name#"ctr"#pm,
  4675. (BCCCTR bibo, CR0)>;
  4676. def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
  4677. (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
  4678. def : InstAlias<"b"#name#"l"#pm#" $dst",
  4679. (BCCL bibo, CR0, condbrtarget:$dst)>;
  4680. def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
  4681. (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
  4682. def : InstAlias<"b"#name#"la"#pm#" $dst",
  4683. (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
  4684. def : InstAlias<"b"#name#"lrl"#pm#" $cc",
  4685. (BCCLRL bibo, crrc:$cc)>;
  4686. def : InstAlias<"b"#name#"lrl"#pm,
  4687. (BCCLRL bibo, CR0)>;
  4688. def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
  4689. (BCCCTRL bibo, crrc:$cc)>;
  4690. def : InstAlias<"b"#name#"ctrl"#pm,
  4691. (BCCCTRL bibo, CR0)>;
  4692. }
  4693. multiclass BranchExtendedMnemonic<string name, int bibo> {
  4694. defm : BranchExtendedMnemonicPM<name, "", bibo>;
  4695. defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
  4696. defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
  4697. }
  4698. defm : BranchExtendedMnemonic<"lt", 12>;
  4699. defm : BranchExtendedMnemonic<"gt", 44>;
  4700. defm : BranchExtendedMnemonic<"eq", 76>;
  4701. defm : BranchExtendedMnemonic<"un", 108>;
  4702. defm : BranchExtendedMnemonic<"so", 108>;
  4703. defm : BranchExtendedMnemonic<"ge", 4>;
  4704. defm : BranchExtendedMnemonic<"nl", 4>;
  4705. defm : BranchExtendedMnemonic<"le", 36>;
  4706. defm : BranchExtendedMnemonic<"ng", 36>;
  4707. defm : BranchExtendedMnemonic<"ne", 68>;
  4708. defm : BranchExtendedMnemonic<"nu", 100>;
  4709. defm : BranchExtendedMnemonic<"ns", 100>;
  4710. def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
  4711. def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
  4712. def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
  4713. def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
  4714. def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
  4715. def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
  4716. def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
  4717. def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
  4718. def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
  4719. def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
  4720. def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
  4721. def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
  4722. def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
  4723. def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
  4724. def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
  4725. def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
  4726. def : InstAlias<"trap", (TW 31, R0, R0)>;
  4727. multiclass TrapExtendedMnemonic<string name, int to> {
  4728. def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
  4729. def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
  4730. def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
  4731. def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
  4732. }
  4733. defm : TrapExtendedMnemonic<"lt", 16>;
  4734. defm : TrapExtendedMnemonic<"le", 20>;
  4735. defm : TrapExtendedMnemonic<"eq", 4>;
  4736. defm : TrapExtendedMnemonic<"ge", 12>;
  4737. defm : TrapExtendedMnemonic<"gt", 8>;
  4738. defm : TrapExtendedMnemonic<"nl", 12>;
  4739. defm : TrapExtendedMnemonic<"ne", 24>;
  4740. defm : TrapExtendedMnemonic<"ng", 20>;
  4741. defm : TrapExtendedMnemonic<"llt", 2>;
  4742. defm : TrapExtendedMnemonic<"lle", 6>;
  4743. defm : TrapExtendedMnemonic<"lge", 5>;
  4744. defm : TrapExtendedMnemonic<"lgt", 1>;
  4745. defm : TrapExtendedMnemonic<"lnl", 5>;
  4746. defm : TrapExtendedMnemonic<"lng", 6>;
  4747. defm : TrapExtendedMnemonic<"u", 31>;
  4748. // Atomic loads
  4749. def : Pat<(atomic_load_8 DForm:$src), (LBZ memri:$src)>;
  4750. def : Pat<(atomic_load_16 DForm:$src), (LHZ memri:$src)>;
  4751. def : Pat<(atomic_load_32 DForm:$src), (LWZ memri:$src)>;
  4752. def : Pat<(atomic_load_8 XForm:$src), (LBZX memrr:$src)>;
  4753. def : Pat<(atomic_load_16 XForm:$src), (LHZX memrr:$src)>;
  4754. def : Pat<(atomic_load_32 XForm:$src), (LWZX memrr:$src)>;
  4755. // Atomic stores
  4756. def : Pat<(atomic_store_8 DForm:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
  4757. def : Pat<(atomic_store_16 DForm:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
  4758. def : Pat<(atomic_store_32 DForm:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
  4759. def : Pat<(atomic_store_8 XForm:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
  4760. def : Pat<(atomic_store_16 XForm:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
  4761. def : Pat<(atomic_store_32 XForm:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
  4762. let Predicates = [IsISA3_0] in {
  4763. // Copy-Paste Facility
  4764. // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
  4765. // PASTE for naming consistency.
  4766. let mayLoad = 1 in
  4767. def CP_COPY : X_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
  4768. let mayStore = 1, Defs = [CR0] in
  4769. def CP_PASTE_rec : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isRecordForm;
  4770. def : InstAlias<"paste. $RA, $RB", (CP_PASTE_rec gprc:$RA, gprc:$RB, 1)>;
  4771. def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cpabort", IIC_SprABORT, []>;
  4772. // Message Synchronize
  4773. def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
  4774. // Power-Saving Mode Instruction:
  4775. def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
  4776. def SETB : XForm_44<31, 128, (outs gprc:$RT), (ins crrc:$BFA),
  4777. "setb $RT, $BFA", IIC_IntGeneral>;
  4778. } // IsISA3_0
  4779. let Predicates = [IsISA3_0] in {
  4780. def : Pat<(i32 (int_ppc_cmprb i32:$a, gprc:$b, gprc:$c)),
  4781. (i32 (SETB (CMPRB u1imm:$a, $b, $c)))>;
  4782. }
  4783. def : Pat<(i32 (int_ppc_mulhw gprc:$a, gprc:$b)),
  4784. (i32 (MULHW $a, $b))>;
  4785. def : Pat<(i32 (int_ppc_mulhwu gprc:$a, gprc:$b)),
  4786. (i32 (MULHWU $a, $b))>;
  4787. def : Pat<(i32 (int_ppc_cmpb gprc:$a, gprc:$b)),
  4788. (i32 (CMPB $a, $b))>;
  4789. def : Pat<(int_ppc_load2r ForceXForm:$ptr),
  4790. (LHBRX ForceXForm:$ptr)>;
  4791. def : Pat<(int_ppc_load4r ForceXForm:$ptr),
  4792. (LWBRX ForceXForm:$ptr)>;
  4793. def : Pat<(int_ppc_store2r gprc:$a, ForceXForm:$ptr),
  4794. (STHBRX gprc:$a, ForceXForm:$ptr)>;
  4795. def : Pat<(int_ppc_store4r gprc:$a, ForceXForm:$ptr),
  4796. (STWBRX gprc:$a, ForceXForm:$ptr)>;
  4797. // Fast 32-bit reverse bits algorithm:
  4798. // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
  4799. // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
  4800. // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
  4801. // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
  4802. // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
  4803. // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
  4804. // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
  4805. // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
  4806. // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
  4807. // Step 4.2: Insert B3 to the right position:
  4808. // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
  4809. // Step 4.3: Insert B1 to the right position:
  4810. // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
  4811. def MaskValues {
  4812. dag Lo1 = (ORI (LIS 0x5555), 0x5555);
  4813. dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
  4814. dag Lo2 = (ORI (LIS 0x3333), 0x3333);
  4815. dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
  4816. dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
  4817. dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
  4818. }
  4819. def Shift1 {
  4820. dag Right = (RLWINM $A, 31, 1, 31);
  4821. dag Left = (RLWINM $A, 1, 0, 30);
  4822. }
  4823. def Swap1 {
  4824. dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
  4825. (AND Shift1.Left, MaskValues.Hi1));
  4826. }
  4827. def Shift2 {
  4828. dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
  4829. dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
  4830. }
  4831. def Swap2 {
  4832. dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
  4833. (AND Shift2.Left, MaskValues.Hi2));
  4834. }
  4835. def Shift4 {
  4836. dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
  4837. dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
  4838. }
  4839. def Swap4 {
  4840. dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
  4841. (AND Shift4.Left, MaskValues.Hi4));
  4842. }
  4843. def Rotate {
  4844. dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
  4845. }
  4846. def RotateInsertByte3 {
  4847. dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
  4848. }
  4849. def RotateInsertByte1 {
  4850. dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
  4851. }
  4852. // Clear the upper half of the register when in 64-bit mode
  4853. let Predicates = [In64BitMode] in
  4854. def : Pat<(i32 (bitreverse i32:$A)), (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
  4855. let Predicates = [In32BitMode] in
  4856. def : Pat<(i32 (bitreverse i32:$A)), RotateInsertByte1.Left>;
  4857. // Fast 64-bit reverse bits algorithm:
  4858. // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
  4859. // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
  4860. // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
  4861. // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
  4862. // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
  4863. // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
  4864. // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
  4865. // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
  4866. // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
  4867. // then OR them together to get the final result.
  4868. def MaskValues64 {
  4869. dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
  4870. dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
  4871. dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
  4872. dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
  4873. dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
  4874. dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
  4875. }
  4876. def DWMaskValues {
  4877. dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
  4878. dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
  4879. dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
  4880. dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
  4881. dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
  4882. dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
  4883. }
  4884. def DWSwapInByte {
  4885. dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
  4886. (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
  4887. dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
  4888. (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
  4889. dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
  4890. (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
  4891. }
  4892. // Intra-byte swap is done, now start inter-byte swap.
  4893. def DWBytes4567 {
  4894. dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
  4895. }
  4896. def DWBytes7456 {
  4897. dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
  4898. }
  4899. def DWBytes7656 {
  4900. dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
  4901. }
  4902. // B7 B6 B5 B4 in the right order
  4903. def DWBytes7654 {
  4904. dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
  4905. dag DWord =
  4906. (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
  4907. }
  4908. def DWBytes0123 {
  4909. dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
  4910. }
  4911. def DWBytes3012 {
  4912. dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
  4913. }
  4914. def DWBytes3212 {
  4915. dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
  4916. }
  4917. // B3 B2 B1 B0 in the right order
  4918. def DWBytes3210 {
  4919. dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
  4920. dag DWord =
  4921. (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
  4922. }
  4923. // These instructions store a hash computed from the value of the link register
  4924. // and the value of the stack pointer.
  4925. let mayStore = 1 in {
  4926. def HASHST : XForm_XD6_RA5_RB5<31, 722, (outs),
  4927. (ins gprc:$RB, memrihash:$D_RA_XD),
  4928. "hashst $RB, $D_RA_XD", IIC_IntGeneral, []>;
  4929. def HASHSTP : XForm_XD6_RA5_RB5<31, 658, (outs),
  4930. (ins gprc:$RB, memrihash:$D_RA_XD),
  4931. "hashstp $RB, $D_RA_XD", IIC_IntGeneral, []>;
  4932. }
  4933. // These instructions check a hash computed from the value of the link register
  4934. // and the value of the stack pointer. The hasSideEffects flag is needed as the
  4935. // instruction may TRAP if the hash does not match the hash stored at the
  4936. // specified address.
  4937. let mayLoad = 1, hasSideEffects = 1 in {
  4938. def HASHCHK : XForm_XD6_RA5_RB5<31, 754, (outs),
  4939. (ins gprc:$RB, memrihash:$D_RA_XD),
  4940. "hashchk $RB, $D_RA_XD", IIC_IntGeneral, []>;
  4941. def HASHCHKP : XForm_XD6_RA5_RB5<31, 690, (outs),
  4942. (ins gprc:$RB, memrihash:$D_RA_XD),
  4943. "hashchkp $RB, $D_RA_XD", IIC_IntGeneral, []>;
  4944. }
  4945. // Now both high word and low word are reversed, next
  4946. // swap the high word and low word.
  4947. def : Pat<(i64 (bitreverse i64:$A)),
  4948. (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;
  4949. def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A),
  4950. (STWCX gprc:$A, ForceXForm:$dst)>;
  4951. def : Pat<(int_ppc_stbcx ForceXForm:$dst, gprc:$A),
  4952. (STBCX gprc:$A, ForceXForm:$dst)>;
  4953. def : Pat<(int_ppc_trap gprc:$A),
  4954. (TWI 24, $A, 0)>;
  4955. def : Pat<(int_ppc_fcfid f64:$A),
  4956. (XSCVSXDDP $A)>;
  4957. def : Pat<(int_ppc_fcfud f64:$A),
  4958. (XSCVUXDDP $A)>;
  4959. def : Pat<(int_ppc_fctid f64:$A),
  4960. (FCTID $A)>;
  4961. def : Pat<(int_ppc_fctidz f64:$A),
  4962. (XSCVDPSXDS $A)>;
  4963. def : Pat<(int_ppc_fctiw f64:$A),
  4964. (FCTIW $A)>;
  4965. def : Pat<(int_ppc_fctiwz f64:$A),
  4966. (XSCVDPSXWS $A)>;
  4967. def : Pat<(int_ppc_fctudz f64:$A),
  4968. (XSCVDPUXDS $A)>;
  4969. def : Pat<(int_ppc_fctuwz f64:$A),
  4970. (XSCVDPUXWS $A)>;
  4971. def : Pat<(int_ppc_mfmsr), (MFMSR)>;
  4972. def : Pat<(int_ppc_mftbu), (MFTB 269)>;
  4973. def : Pat<(i32 (int_ppc_mfspr timm:$SPR)),
  4974. (MFSPR $SPR)>;
  4975. def : Pat<(int_ppc_mtspr timm:$SPR, gprc:$RT),
  4976. (MTSPR $SPR, $RT)>;
  4977. def : Pat<(int_ppc_mtmsr gprc:$RS),
  4978. (MTMSR $RS, 0)>;
  4979. let Predicates = [IsISA2_07] in {
  4980. def : Pat<(int_ppc_sthcx ForceXForm:$dst, gprc:$A),
  4981. (STHCX gprc:$A, ForceXForm:$dst)>;
  4982. }
  4983. def : Pat<(int_ppc_dcbtstt ForceXForm:$dst),
  4984. (DCBTST 16, ForceXForm:$dst)>;
  4985. def : Pat<(int_ppc_dcbtt ForceXForm:$dst),
  4986. (DCBT 16, ForceXForm:$dst)>;
  4987. def : Pat<(int_ppc_stfiw ForceXForm:$dst, f64:$XT),
  4988. (STFIWX f64:$XT, ForceXForm:$dst)>;