PPCInstrInfo.td 234 KB

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