metag-gcc.patch 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286
  1. diff -Nur gcc-4.2.4.orig/ccs_version.h gcc-4.2.4/ccs_version.h
  2. --- gcc-4.2.4.orig/ccs_version.h 1969-12-31 18:00:00.000000000 -0600
  3. +++ gcc-4.2.4/ccs_version.h 2015-07-03 18:46:05.717283542 -0500
  4. @@ -0,0 +1,8 @@
  5. +/* This file has been generated by CCS - do not edit. */
  6. +
  7. +#define CCS_FULL_VSTR "1.4.0.3"
  8. +
  9. +#define CCS_MAJOR_VN 1
  10. +#define CCS_MINOR_VN 4
  11. +#define CCS_RELEASE_VN 0
  12. +#define CCS_BUILD_VN 3
  13. diff -Nur gcc-4.2.4.orig/config.guess gcc-4.2.4/config.guess
  14. --- gcc-4.2.4.orig/config.guess 2006-10-15 22:27:17.000000000 -0500
  15. +++ gcc-4.2.4/config.guess 2015-07-03 19:15:14.097267674 -0500
  16. @@ -1,14 +1,12 @@
  17. #! /bin/sh
  18. # Attempt to guess a canonical system name.
  19. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
  20. -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
  21. -# Inc.
  22. +# Copyright 1992-2014 Free Software Foundation, Inc.
  23. -timestamp='2006-07-02'
  24. +timestamp='2014-03-23'
  25. # This file is free software; you can redistribute it and/or modify it
  26. # under the terms of the GNU General Public License as published by
  27. -# the Free Software Foundation; either version 2 of the License, or
  28. +# the Free Software Foundation; either version 3 of the License, or
  29. # (at your option) any later version.
  30. #
  31. # This program is distributed in the hope that it will be useful, but
  32. @@ -17,26 +15,22 @@
  33. # General Public License for more details.
  34. #
  35. # You should have received a copy of the GNU General Public License
  36. -# along with this program; if not, write to the Free Software
  37. -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
  38. -# 02110-1301, USA.
  39. +# along with this program; if not, see <http://www.gnu.org/licenses/>.
  40. #
  41. # As a special exception to the GNU General Public License, if you
  42. # distribute this file as part of a program that contains a
  43. # configuration script generated by Autoconf, you may include it under
  44. -# the same distribution terms that you use for the rest of that program.
  45. -
  46. -
  47. -# Originally written by Per Bothner <per@bothner.com>.
  48. -# Please send patches to <config-patches@gnu.org>. Submit a context
  49. -# diff and a properly formatted ChangeLog entry.
  50. +# the same distribution terms that you use for the rest of that
  51. +# program. This Exception is an additional permission under section 7
  52. +# of the GNU General Public License, version 3 ("GPLv3").
  53. #
  54. -# This script attempts to guess a canonical system name similar to
  55. -# config.sub. If it succeeds, it prints the system name on stdout, and
  56. -# exits with 0. Otherwise, it exits with 1.
  57. +# Originally written by Per Bothner.
  58. #
  59. -# The plan is that this can be called by configure scripts if you
  60. -# don't specify an explicit build system type.
  61. +# You can get the latest version of this script from:
  62. +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
  63. +#
  64. +# Please send patches with a ChangeLog entry to config-patches@gnu.org.
  65. +
  66. me=`echo "$0" | sed -e 's,.*/,,'`
  67. @@ -56,8 +50,7 @@
  68. GNU config.guess ($timestamp)
  69. Originally written by Per Bothner.
  70. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
  71. -Free Software Foundation, Inc.
  72. +Copyright 1992-2014 Free Software Foundation, Inc.
  73. This is free software; see the source for copying conditions. There is NO
  74. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
  75. @@ -139,12 +132,33 @@
  76. UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
  77. UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
  78. +case "${UNAME_SYSTEM}" in
  79. +Linux|GNU|GNU/*)
  80. + # If the system lacks a compiler, then just pick glibc.
  81. + # We could probably try harder.
  82. + LIBC=gnu
  83. +
  84. + eval $set_cc_for_build
  85. + cat <<-EOF > $dummy.c
  86. + #include <features.h>
  87. + #if defined(__UCLIBC__)
  88. + LIBC=uclibc
  89. + #elif defined(__dietlibc__)
  90. + LIBC=dietlibc
  91. + #else
  92. + LIBC=gnu
  93. + #endif
  94. + EOF
  95. + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
  96. + ;;
  97. +esac
  98. +
  99. # Note: order is significant - the case branches are not exclusive.
  100. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
  101. *:NetBSD:*:*)
  102. # NetBSD (nbsd) targets should (where applicable) match one or
  103. - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
  104. + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
  105. # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
  106. # switched to ELF, *-*-netbsd* would select the old
  107. # object file format. This provides both forward
  108. @@ -161,6 +175,7 @@
  109. arm*) machine=arm-unknown ;;
  110. sh3el) machine=shl-unknown ;;
  111. sh3eb) machine=sh-unknown ;;
  112. + sh5el) machine=sh5le-unknown ;;
  113. *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
  114. esac
  115. # The Operating System including object format, if it has switched
  116. @@ -169,7 +184,7 @@
  117. arm*|i386|m68k|ns32k|sh3*|sparc|vax)
  118. eval $set_cc_for_build
  119. if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
  120. - | grep __ELF__ >/dev/null
  121. + | grep -q __ELF__
  122. then
  123. # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
  124. # Return netbsd for either. FIX?
  125. @@ -179,7 +194,7 @@
  126. fi
  127. ;;
  128. *)
  129. - os=netbsd
  130. + os=netbsd
  131. ;;
  132. esac
  133. # The OS release
  134. @@ -200,6 +215,10 @@
  135. # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
  136. echo "${machine}-${os}${release}"
  137. exit ;;
  138. + *:Bitrig:*:*)
  139. + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
  140. + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
  141. + exit ;;
  142. *:OpenBSD:*:*)
  143. UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
  144. echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
  145. @@ -222,7 +241,7 @@
  146. UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
  147. ;;
  148. *5.*)
  149. - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
  150. + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
  151. ;;
  152. esac
  153. # According to Compaq, /usr/sbin/psrinfo has been available on
  154. @@ -268,7 +287,10 @@
  155. # A Xn.n version is an unreleased experimental baselevel.
  156. # 1.2 uses "1.2" for uname -r.
  157. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
  158. - exit ;;
  159. + # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
  160. + exitcode=$?
  161. + trap '' 0
  162. + exit $exitcode ;;
  163. Alpha\ *:Windows_NT*:*)
  164. # How do we know it's Interix rather than the generic POSIX subsystem?
  165. # Should we change UNAME_MACHINE based on the output of uname instead
  166. @@ -294,12 +316,12 @@
  167. echo s390-ibm-zvmoe
  168. exit ;;
  169. *:OS400:*:*)
  170. - echo powerpc-ibm-os400
  171. + echo powerpc-ibm-os400
  172. exit ;;
  173. arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
  174. echo arm-acorn-riscix${UNAME_RELEASE}
  175. exit ;;
  176. - arm:riscos:*:*|arm:RISCOS:*:*)
  177. + arm*:riscos:*:*|arm*:RISCOS:*:*)
  178. echo arm-unknown-riscos
  179. exit ;;
  180. SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
  181. @@ -323,14 +345,33 @@
  182. case `/usr/bin/uname -p` in
  183. sparc) echo sparc-icl-nx7; exit ;;
  184. esac ;;
  185. + s390x:SunOS:*:*)
  186. + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  187. + exit ;;
  188. sun4H:SunOS:5.*:*)
  189. echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  190. exit ;;
  191. sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
  192. echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  193. exit ;;
  194. - i86pc:SunOS:5.*:*)
  195. - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  196. + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
  197. + echo i386-pc-auroraux${UNAME_RELEASE}
  198. + exit ;;
  199. + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
  200. + eval $set_cc_for_build
  201. + SUN_ARCH="i386"
  202. + # If there is a compiler, see if it is configured for 64-bit objects.
  203. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
  204. + # This test works for both compilers.
  205. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
  206. + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
  207. + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
  208. + grep IS_64BIT_ARCH >/dev/null
  209. + then
  210. + SUN_ARCH="x86_64"
  211. + fi
  212. + fi
  213. + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  214. exit ;;
  215. sun4*:SunOS:6*:*)
  216. # According to config.sub, this is the proper way to canonicalize
  217. @@ -374,23 +415,23 @@
  218. # MiNT. But MiNT is downward compatible to TOS, so this should
  219. # be no problem.
  220. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
  221. - echo m68k-atari-mint${UNAME_RELEASE}
  222. + echo m68k-atari-mint${UNAME_RELEASE}
  223. exit ;;
  224. atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
  225. echo m68k-atari-mint${UNAME_RELEASE}
  226. - exit ;;
  227. + exit ;;
  228. *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
  229. - echo m68k-atari-mint${UNAME_RELEASE}
  230. + echo m68k-atari-mint${UNAME_RELEASE}
  231. exit ;;
  232. milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
  233. - echo m68k-milan-mint${UNAME_RELEASE}
  234. - exit ;;
  235. + echo m68k-milan-mint${UNAME_RELEASE}
  236. + exit ;;
  237. hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
  238. - echo m68k-hades-mint${UNAME_RELEASE}
  239. - exit ;;
  240. + echo m68k-hades-mint${UNAME_RELEASE}
  241. + exit ;;
  242. *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
  243. - echo m68k-unknown-mint${UNAME_RELEASE}
  244. - exit ;;
  245. + echo m68k-unknown-mint${UNAME_RELEASE}
  246. + exit ;;
  247. m68k:machten:*:*)
  248. echo m68k-apple-machten${UNAME_RELEASE}
  249. exit ;;
  250. @@ -460,8 +501,8 @@
  251. echo m88k-motorola-sysv3
  252. exit ;;
  253. AViiON:dgux:*:*)
  254. - # DG/UX returns AViiON for all architectures
  255. - UNAME_PROCESSOR=`/usr/bin/uname -p`
  256. + # DG/UX returns AViiON for all architectures
  257. + UNAME_PROCESSOR=`/usr/bin/uname -p`
  258. if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
  259. then
  260. if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
  261. @@ -474,7 +515,7 @@
  262. else
  263. echo i586-dg-dgux${UNAME_RELEASE}
  264. fi
  265. - exit ;;
  266. + exit ;;
  267. M88*:DolphinOS:*:*) # DolphinOS (SVR3)
  268. echo m88k-dolphin-sysv3
  269. exit ;;
  270. @@ -531,7 +572,7 @@
  271. echo rs6000-ibm-aix3.2
  272. fi
  273. exit ;;
  274. - *:AIX:*:[45])
  275. + *:AIX:*:[4567])
  276. IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
  277. if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
  278. IBM_ARCH=rs6000
  279. @@ -574,52 +615,52 @@
  280. 9000/[678][0-9][0-9])
  281. if [ -x /usr/bin/getconf ]; then
  282. sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
  283. - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
  284. - case "${sc_cpu_version}" in
  285. - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
  286. - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
  287. - 532) # CPU_PA_RISC2_0
  288. - case "${sc_kernel_bits}" in
  289. - 32) HP_ARCH="hppa2.0n" ;;
  290. - 64) HP_ARCH="hppa2.0w" ;;
  291. + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
  292. + case "${sc_cpu_version}" in
  293. + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
  294. + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
  295. + 532) # CPU_PA_RISC2_0
  296. + case "${sc_kernel_bits}" in
  297. + 32) HP_ARCH="hppa2.0n" ;;
  298. + 64) HP_ARCH="hppa2.0w" ;;
  299. '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
  300. - esac ;;
  301. - esac
  302. + esac ;;
  303. + esac
  304. fi
  305. if [ "${HP_ARCH}" = "" ]; then
  306. eval $set_cc_for_build
  307. - sed 's/^ //' << EOF >$dummy.c
  308. + sed 's/^ //' << EOF >$dummy.c
  309. +
  310. + #define _HPUX_SOURCE
  311. + #include <stdlib.h>
  312. + #include <unistd.h>
  313. +
  314. + int main ()
  315. + {
  316. + #if defined(_SC_KERNEL_BITS)
  317. + long bits = sysconf(_SC_KERNEL_BITS);
  318. + #endif
  319. + long cpu = sysconf (_SC_CPU_VERSION);
  320. - #define _HPUX_SOURCE
  321. - #include <stdlib.h>
  322. - #include <unistd.h>
  323. -
  324. - int main ()
  325. - {
  326. - #if defined(_SC_KERNEL_BITS)
  327. - long bits = sysconf(_SC_KERNEL_BITS);
  328. - #endif
  329. - long cpu = sysconf (_SC_CPU_VERSION);
  330. -
  331. - switch (cpu)
  332. - {
  333. - case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
  334. - case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
  335. - case CPU_PA_RISC2_0:
  336. - #if defined(_SC_KERNEL_BITS)
  337. - switch (bits)
  338. - {
  339. - case 64: puts ("hppa2.0w"); break;
  340. - case 32: puts ("hppa2.0n"); break;
  341. - default: puts ("hppa2.0"); break;
  342. - } break;
  343. - #else /* !defined(_SC_KERNEL_BITS) */
  344. - puts ("hppa2.0"); break;
  345. - #endif
  346. - default: puts ("hppa1.0"); break;
  347. - }
  348. - exit (0);
  349. - }
  350. + switch (cpu)
  351. + {
  352. + case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
  353. + case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
  354. + case CPU_PA_RISC2_0:
  355. + #if defined(_SC_KERNEL_BITS)
  356. + switch (bits)
  357. + {
  358. + case 64: puts ("hppa2.0w"); break;
  359. + case 32: puts ("hppa2.0n"); break;
  360. + default: puts ("hppa2.0"); break;
  361. + } break;
  362. + #else /* !defined(_SC_KERNEL_BITS) */
  363. + puts ("hppa2.0"); break;
  364. + #endif
  365. + default: puts ("hppa1.0"); break;
  366. + }
  367. + exit (0);
  368. + }
  369. EOF
  370. (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
  371. test -z "$HP_ARCH" && HP_ARCH=hppa
  372. @@ -639,7 +680,7 @@
  373. # => hppa64-hp-hpux11.23
  374. if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
  375. - grep __LP64__ >/dev/null
  376. + grep -q __LP64__
  377. then
  378. HP_ARCH="hppa2.0w"
  379. else
  380. @@ -710,22 +751,22 @@
  381. exit ;;
  382. C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
  383. echo c1-convex-bsd
  384. - exit ;;
  385. + exit ;;
  386. C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
  387. if getsysinfo -f scalar_acc
  388. then echo c32-convex-bsd
  389. else echo c2-convex-bsd
  390. fi
  391. - exit ;;
  392. + exit ;;
  393. C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
  394. echo c34-convex-bsd
  395. - exit ;;
  396. + exit ;;
  397. C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
  398. echo c38-convex-bsd
  399. - exit ;;
  400. + exit ;;
  401. C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
  402. echo c4-convex-bsd
  403. - exit ;;
  404. + exit ;;
  405. CRAY*Y-MP:*:*:*)
  406. echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
  407. exit ;;
  408. @@ -749,14 +790,14 @@
  409. exit ;;
  410. F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
  411. FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
  412. - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
  413. - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
  414. - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
  415. - exit ;;
  416. + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
  417. + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
  418. + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
  419. + exit ;;
  420. 5000:UNIX_System_V:4.*:*)
  421. - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
  422. - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
  423. - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
  424. + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
  425. + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
  426. + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
  427. exit ;;
  428. i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
  429. echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
  430. @@ -768,37 +809,51 @@
  431. echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
  432. exit ;;
  433. *:FreeBSD:*:*)
  434. - case ${UNAME_MACHINE} in
  435. - pc98)
  436. - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  437. + UNAME_PROCESSOR=`/usr/bin/uname -p`
  438. + case ${UNAME_PROCESSOR} in
  439. amd64)
  440. echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  441. *)
  442. - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  443. + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  444. esac
  445. exit ;;
  446. i*:CYGWIN*:*)
  447. echo ${UNAME_MACHINE}-pc-cygwin
  448. exit ;;
  449. - i*:MINGW*:*)
  450. + *:MINGW64*:*)
  451. + echo ${UNAME_MACHINE}-pc-mingw64
  452. + exit ;;
  453. + *:MINGW*:*)
  454. echo ${UNAME_MACHINE}-pc-mingw32
  455. exit ;;
  456. + *:MSYS*:*)
  457. + echo ${UNAME_MACHINE}-pc-msys
  458. + exit ;;
  459. i*:windows32*:*)
  460. - # uname -m includes "-pc" on this system.
  461. - echo ${UNAME_MACHINE}-mingw32
  462. + # uname -m includes "-pc" on this system.
  463. + echo ${UNAME_MACHINE}-mingw32
  464. exit ;;
  465. i*:PW*:*)
  466. echo ${UNAME_MACHINE}-pc-pw32
  467. exit ;;
  468. - x86:Interix*:[3456]*)
  469. - echo i586-pc-interix${UNAME_RELEASE}
  470. - exit ;;
  471. - EM64T:Interix*:[3456]*)
  472. - echo x86_64-unknown-interix${UNAME_RELEASE}
  473. - exit ;;
  474. + *:Interix*:*)
  475. + case ${UNAME_MACHINE} in
  476. + x86)
  477. + echo i586-pc-interix${UNAME_RELEASE}
  478. + exit ;;
  479. + authenticamd | genuineintel | EM64T)
  480. + echo x86_64-unknown-interix${UNAME_RELEASE}
  481. + exit ;;
  482. + IA64)
  483. + echo ia64-unknown-interix${UNAME_RELEASE}
  484. + exit ;;
  485. + esac ;;
  486. [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
  487. echo i${UNAME_MACHINE}-pc-mks
  488. exit ;;
  489. + 8664:Windows_NT:*)
  490. + echo x86_64-pc-mks
  491. + exit ;;
  492. i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
  493. # How do we know it's Interix rather than the generic POSIX subsystem?
  494. # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
  495. @@ -819,200 +874,157 @@
  496. exit ;;
  497. *:GNU:*:*)
  498. # the GNU system
  499. - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
  500. + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
  501. exit ;;
  502. *:GNU/*:*:*)
  503. # other systems with GNU libc and userland
  504. - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
  505. + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
  506. exit ;;
  507. i*86:Minix:*:*)
  508. echo ${UNAME_MACHINE}-pc-minix
  509. exit ;;
  510. + aarch64:Linux:*:*)
  511. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  512. + exit ;;
  513. + aarch64_be:Linux:*:*)
  514. + UNAME_MACHINE=aarch64_be
  515. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  516. + exit ;;
  517. + alpha:Linux:*:*)
  518. + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
  519. + EV5) UNAME_MACHINE=alphaev5 ;;
  520. + EV56) UNAME_MACHINE=alphaev56 ;;
  521. + PCA56) UNAME_MACHINE=alphapca56 ;;
  522. + PCA57) UNAME_MACHINE=alphapca56 ;;
  523. + EV6) UNAME_MACHINE=alphaev6 ;;
  524. + EV67) UNAME_MACHINE=alphaev67 ;;
  525. + EV68*) UNAME_MACHINE=alphaev68 ;;
  526. + esac
  527. + objdump --private-headers /bin/sh | grep -q ld.so.1
  528. + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
  529. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  530. + exit ;;
  531. + arc:Linux:*:* | arceb:Linux:*:*)
  532. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  533. + exit ;;
  534. arm*:Linux:*:*)
  535. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  536. + eval $set_cc_for_build
  537. + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
  538. + | grep -q __ARM_EABI__
  539. + then
  540. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  541. + else
  542. + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
  543. + | grep -q __ARM_PCS_VFP
  544. + then
  545. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
  546. + else
  547. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
  548. + fi
  549. + fi
  550. exit ;;
  551. avr32*:Linux:*:*)
  552. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  553. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  554. exit ;;
  555. cris:Linux:*:*)
  556. - echo cris-axis-linux-gnu
  557. + echo ${UNAME_MACHINE}-axis-linux-${LIBC}
  558. exit ;;
  559. crisv32:Linux:*:*)
  560. - echo crisv32-axis-linux-gnu
  561. + echo ${UNAME_MACHINE}-axis-linux-${LIBC}
  562. exit ;;
  563. frv:Linux:*:*)
  564. - echo frv-unknown-linux-gnu
  565. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  566. + exit ;;
  567. + hexagon:Linux:*:*)
  568. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  569. + exit ;;
  570. + i*86:Linux:*:*)
  571. + echo ${UNAME_MACHINE}-pc-linux-${LIBC}
  572. exit ;;
  573. ia64:Linux:*:*)
  574. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  575. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  576. exit ;;
  577. m32r*:Linux:*:*)
  578. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  579. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  580. exit ;;
  581. m68*:Linux:*:*)
  582. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  583. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  584. exit ;;
  585. - mips:Linux:*:*)
  586. + mips:Linux:*:* | mips64:Linux:*:*)
  587. eval $set_cc_for_build
  588. sed 's/^ //' << EOF >$dummy.c
  589. #undef CPU
  590. - #undef mips
  591. - #undef mipsel
  592. + #undef ${UNAME_MACHINE}
  593. + #undef ${UNAME_MACHINE}el
  594. #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
  595. - CPU=mipsel
  596. + CPU=${UNAME_MACHINE}el
  597. #else
  598. #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
  599. - CPU=mips
  600. + CPU=${UNAME_MACHINE}
  601. #else
  602. CPU=
  603. #endif
  604. #endif
  605. EOF
  606. - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
  607. - /^CPU/{
  608. - s: ::g
  609. - p
  610. - }'`"
  611. - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
  612. + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
  613. + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
  614. ;;
  615. - mips64:Linux:*:*)
  616. - eval $set_cc_for_build
  617. - sed 's/^ //' << EOF >$dummy.c
  618. - #undef CPU
  619. - #undef mips64
  620. - #undef mips64el
  621. - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
  622. - CPU=mips64el
  623. - #else
  624. - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
  625. - CPU=mips64
  626. - #else
  627. - CPU=
  628. - #endif
  629. - #endif
  630. -EOF
  631. - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
  632. - /^CPU/{
  633. - s: ::g
  634. - p
  635. - }'`"
  636. - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
  637. - ;;
  638. - or32:Linux:*:*)
  639. - echo or32-unknown-linux-gnu
  640. + openrisc*:Linux:*:*)
  641. + echo or1k-unknown-linux-${LIBC}
  642. exit ;;
  643. - ppc:Linux:*:*)
  644. - echo powerpc-unknown-linux-gnu
  645. + or32:Linux:*:* | or1k*:Linux:*:*)
  646. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  647. exit ;;
  648. - ppc64:Linux:*:*)
  649. - echo powerpc64-unknown-linux-gnu
  650. + padre:Linux:*:*)
  651. + echo sparc-unknown-linux-${LIBC}
  652. exit ;;
  653. - alpha:Linux:*:*)
  654. - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
  655. - EV5) UNAME_MACHINE=alphaev5 ;;
  656. - EV56) UNAME_MACHINE=alphaev56 ;;
  657. - PCA56) UNAME_MACHINE=alphapca56 ;;
  658. - PCA57) UNAME_MACHINE=alphapca56 ;;
  659. - EV6) UNAME_MACHINE=alphaev6 ;;
  660. - EV67) UNAME_MACHINE=alphaev67 ;;
  661. - EV68*) UNAME_MACHINE=alphaev68 ;;
  662. - esac
  663. - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
  664. - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
  665. - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
  666. + parisc64:Linux:*:* | hppa64:Linux:*:*)
  667. + echo hppa64-unknown-linux-${LIBC}
  668. exit ;;
  669. parisc:Linux:*:* | hppa:Linux:*:*)
  670. # Look for CPU level
  671. case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
  672. - PA7*) echo hppa1.1-unknown-linux-gnu ;;
  673. - PA8*) echo hppa2.0-unknown-linux-gnu ;;
  674. - *) echo hppa-unknown-linux-gnu ;;
  675. + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
  676. + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
  677. + *) echo hppa-unknown-linux-${LIBC} ;;
  678. esac
  679. exit ;;
  680. - parisc64:Linux:*:* | hppa64:Linux:*:*)
  681. - echo hppa64-unknown-linux-gnu
  682. + ppc64:Linux:*:*)
  683. + echo powerpc64-unknown-linux-${LIBC}
  684. + exit ;;
  685. + ppc:Linux:*:*)
  686. + echo powerpc-unknown-linux-${LIBC}
  687. + exit ;;
  688. + ppc64le:Linux:*:*)
  689. + echo powerpc64le-unknown-linux-${LIBC}
  690. + exit ;;
  691. + ppcle:Linux:*:*)
  692. + echo powerpcle-unknown-linux-${LIBC}
  693. exit ;;
  694. s390:Linux:*:* | s390x:Linux:*:*)
  695. - echo ${UNAME_MACHINE}-ibm-linux
  696. + echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
  697. exit ;;
  698. sh64*:Linux:*:*)
  699. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  700. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  701. exit ;;
  702. sh*:Linux:*:*)
  703. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  704. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  705. exit ;;
  706. sparc:Linux:*:* | sparc64:Linux:*:*)
  707. - echo ${UNAME_MACHINE}-unknown-linux-gnu
  708. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  709. + exit ;;
  710. + tile*:Linux:*:*)
  711. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  712. exit ;;
  713. vax:Linux:*:*)
  714. - echo ${UNAME_MACHINE}-dec-linux-gnu
  715. + echo ${UNAME_MACHINE}-dec-linux-${LIBC}
  716. exit ;;
  717. x86_64:Linux:*:*)
  718. - echo x86_64-unknown-linux-gnu
  719. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  720. + exit ;;
  721. + xtensa*:Linux:*:*)
  722. + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
  723. exit ;;
  724. - i*86:Linux:*:*)
  725. - # The BFD linker knows what the default object file format is, so
  726. - # first see if it will tell us. cd to the root directory to prevent
  727. - # problems with other programs or directories called `ld' in the path.
  728. - # Set LC_ALL=C to ensure ld outputs messages in English.
  729. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
  730. - | sed -ne '/supported targets:/!d
  731. - s/[ ][ ]*/ /g
  732. - s/.*supported targets: *//
  733. - s/ .*//
  734. - p'`
  735. - case "$ld_supported_targets" in
  736. - elf32-i386)
  737. - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
  738. - ;;
  739. - a.out-i386-linux)
  740. - echo "${UNAME_MACHINE}-pc-linux-gnuaout"
  741. - exit ;;
  742. - coff-i386)
  743. - echo "${UNAME_MACHINE}-pc-linux-gnucoff"
  744. - exit ;;
  745. - "")
  746. - # Either a pre-BFD a.out linker (linux-gnuoldld) or
  747. - # one that does not give us useful --help.
  748. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
  749. - exit ;;
  750. - esac
  751. - # Determine whether the default compiler is a.out or elf
  752. - eval $set_cc_for_build
  753. - sed 's/^ //' << EOF >$dummy.c
  754. - #include <features.h>
  755. - #ifdef __ELF__
  756. - # ifdef __GLIBC__
  757. - # if __GLIBC__ >= 2
  758. - LIBC=gnu
  759. - # else
  760. - LIBC=gnulibc1
  761. - # endif
  762. - # else
  763. - LIBC=gnulibc1
  764. - # endif
  765. - #else
  766. - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  767. - LIBC=gnu
  768. - #else
  769. - LIBC=gnuaout
  770. - #endif
  771. - #endif
  772. - #ifdef __dietlibc__
  773. - LIBC=dietlibc
  774. - #endif
  775. -EOF
  776. - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
  777. - /^LIBC/{
  778. - s: ::g
  779. - p
  780. - }'`"
  781. - test x"${LIBC}" != x && {
  782. - echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
  783. - exit
  784. - }
  785. - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
  786. - ;;
  787. i*86:DYNIX/ptx:4*:*)
  788. # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
  789. # earlier versions are messed up and put the nodename in both
  790. @@ -1020,11 +1032,11 @@
  791. echo i386-sequent-sysv4
  792. exit ;;
  793. i*86:UNIX_SV:4.2MP:2.*)
  794. - # Unixware is an offshoot of SVR4, but it has its own version
  795. - # number series starting with 2...
  796. - # I am not positive that other SVR4 systems won't match this,
  797. + # Unixware is an offshoot of SVR4, but it has its own version
  798. + # number series starting with 2...
  799. + # I am not positive that other SVR4 systems won't match this,
  800. # I just have to hope. -- rms.
  801. - # Use sysv4.2uw... so that sysv4* matches it.
  802. + # Use sysv4.2uw... so that sysv4* matches it.
  803. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
  804. exit ;;
  805. i*86:OS/2:*:*)
  806. @@ -1041,7 +1053,7 @@
  807. i*86:syllable:*:*)
  808. echo ${UNAME_MACHINE}-pc-syllable
  809. exit ;;
  810. - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
  811. + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
  812. echo i386-unknown-lynxos${UNAME_RELEASE}
  813. exit ;;
  814. i*86:*DOS:*:*)
  815. @@ -1056,7 +1068,7 @@
  816. fi
  817. exit ;;
  818. i*86:*:5:[678]*)
  819. - # UnixWare 7.x, OpenUNIX and OpenServer 6.
  820. + # UnixWare 7.x, OpenUNIX and OpenServer 6.
  821. case `/bin/uname -X | grep "^Machine"` in
  822. *486*) UNAME_MACHINE=i486 ;;
  823. *Pentium) UNAME_MACHINE=i586 ;;
  824. @@ -1084,10 +1096,13 @@
  825. exit ;;
  826. pc:*:*:*)
  827. # Left here for compatibility:
  828. - # uname -m prints for DJGPP always 'pc', but it prints nothing about
  829. - # the processor, so we play safe by assuming i386.
  830. - echo i386-pc-msdosdjgpp
  831. - exit ;;
  832. + # uname -m prints for DJGPP always 'pc', but it prints nothing about
  833. + # the processor, so we play safe by assuming i586.
  834. + # Note: whatever this is, it MUST be the same as what config.sub
  835. + # prints for the "djgpp" host, or else GDB configury will decide that
  836. + # this is a cross-build.
  837. + echo i586-pc-msdosdjgpp
  838. + exit ;;
  839. Intel:Mach:3*:*)
  840. echo i386-pc-mach3
  841. exit ;;
  842. @@ -1122,8 +1137,18 @@
  843. /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
  844. && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
  845. 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
  846. - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
  847. - && { echo i486-ncr-sysv4; exit; } ;;
  848. + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
  849. + && { echo i486-ncr-sysv4; exit; } ;;
  850. + NCR*:*:4.2:* | MPRAS*:*:4.2:*)
  851. + OS_REL='.3'
  852. + test -r /etc/.relid \
  853. + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
  854. + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
  855. + && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
  856. + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
  857. + && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
  858. + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
  859. + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
  860. m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
  861. echo m68k-unknown-lynxos${UNAME_RELEASE}
  862. exit ;;
  863. @@ -1136,7 +1161,7 @@
  864. rs6000:LynxOS:2.*:*)
  865. echo rs6000-unknown-lynxos${UNAME_RELEASE}
  866. exit ;;
  867. - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
  868. + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
  869. echo powerpc-unknown-lynxos${UNAME_RELEASE}
  870. exit ;;
  871. SM[BE]S:UNIX_SV:*:*)
  872. @@ -1156,10 +1181,10 @@
  873. echo ns32k-sni-sysv
  874. fi
  875. exit ;;
  876. - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
  877. - # says <Richard.M.Bartel@ccMail.Census.GOV>
  878. - echo i586-unisys-sysv4
  879. - exit ;;
  880. + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
  881. + # says <Richard.M.Bartel@ccMail.Census.GOV>
  882. + echo i586-unisys-sysv4
  883. + exit ;;
  884. *:UNIX_System_V:4*:FTX*)
  885. # From Gerald Hewes <hewes@openmarket.com>.
  886. # How about differentiating between stratus architectures? -djm
  887. @@ -1185,11 +1210,11 @@
  888. exit ;;
  889. R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
  890. if [ -d /usr/nec ]; then
  891. - echo mips-nec-sysv${UNAME_RELEASE}
  892. + echo mips-nec-sysv${UNAME_RELEASE}
  893. else
  894. - echo mips-unknown-sysv${UNAME_RELEASE}
  895. + echo mips-unknown-sysv${UNAME_RELEASE}
  896. fi
  897. - exit ;;
  898. + exit ;;
  899. BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
  900. echo powerpc-be-beos
  901. exit ;;
  902. @@ -1199,6 +1224,12 @@
  903. BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
  904. echo i586-pc-beos
  905. exit ;;
  906. + BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
  907. + echo i586-pc-haiku
  908. + exit ;;
  909. + x86_64:Haiku:*:*)
  910. + echo x86_64-unknown-haiku
  911. + exit ;;
  912. SX-4:SUPER-UX:*:*)
  913. echo sx4-nec-superux${UNAME_RELEASE}
  914. exit ;;
  915. @@ -1208,6 +1239,15 @@
  916. SX-6:SUPER-UX:*:*)
  917. echo sx6-nec-superux${UNAME_RELEASE}
  918. exit ;;
  919. + SX-7:SUPER-UX:*:*)
  920. + echo sx7-nec-superux${UNAME_RELEASE}
  921. + exit ;;
  922. + SX-8:SUPER-UX:*:*)
  923. + echo sx8-nec-superux${UNAME_RELEASE}
  924. + exit ;;
  925. + SX-8R:SUPER-UX:*:*)
  926. + echo sx8r-nec-superux${UNAME_RELEASE}
  927. + exit ;;
  928. Power*:Rhapsody:*:*)
  929. echo powerpc-apple-rhapsody${UNAME_RELEASE}
  930. exit ;;
  931. @@ -1216,9 +1256,31 @@
  932. exit ;;
  933. *:Darwin:*:*)
  934. UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
  935. - case $UNAME_PROCESSOR in
  936. - unknown) UNAME_PROCESSOR=powerpc ;;
  937. - esac
  938. + eval $set_cc_for_build
  939. + if test "$UNAME_PROCESSOR" = unknown ; then
  940. + UNAME_PROCESSOR=powerpc
  941. + fi
  942. + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
  943. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
  944. + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
  945. + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
  946. + grep IS_64BIT_ARCH >/dev/null
  947. + then
  948. + case $UNAME_PROCESSOR in
  949. + i386) UNAME_PROCESSOR=x86_64 ;;
  950. + powerpc) UNAME_PROCESSOR=powerpc64 ;;
  951. + esac
  952. + fi
  953. + fi
  954. + elif test "$UNAME_PROCESSOR" = i386 ; then
  955. + # Avoid executing cc on OS X 10.9, as it ships with a stub
  956. + # that puts up a graphical alert prompting to install
  957. + # developer tools. Any system running Mac OS X 10.7 or
  958. + # later (Darwin 11 and later) is required to have a 64-bit
  959. + # processor. This is not true of the ARM version of Darwin
  960. + # that Apple uses in portable devices.
  961. + UNAME_PROCESSOR=x86_64
  962. + fi
  963. echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
  964. exit ;;
  965. *:procnto*:*:* | *:QNX:[0123456789]*:*)
  966. @@ -1232,7 +1294,10 @@
  967. *:QNX:*:4*)
  968. echo i386-pc-qnx
  969. exit ;;
  970. - NSE-?:NONSTOP_KERNEL:*:*)
  971. + NEO-?:NONSTOP_KERNEL:*:*)
  972. + echo neo-tandem-nsk${UNAME_RELEASE}
  973. + exit ;;
  974. + NSE-*:NONSTOP_KERNEL:*:*)
  975. echo nse-tandem-nsk${UNAME_RELEASE}
  976. exit ;;
  977. NSR-?:NONSTOP_KERNEL:*:*)
  978. @@ -1277,13 +1342,13 @@
  979. echo pdp10-unknown-its
  980. exit ;;
  981. SEI:*:*:SEIUX)
  982. - echo mips-sei-seiux${UNAME_RELEASE}
  983. + echo mips-sei-seiux${UNAME_RELEASE}
  984. exit ;;
  985. *:DragonFly:*:*)
  986. echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
  987. exit ;;
  988. *:*VMS:*:*)
  989. - UNAME_MACHINE=`(uname -p) 2>/dev/null`
  990. + UNAME_MACHINE=`(uname -p) 2>/dev/null`
  991. case "${UNAME_MACHINE}" in
  992. A*) echo alpha-dec-vms ; exit ;;
  993. I*) echo ia64-dec-vms ; exit ;;
  994. @@ -1298,158 +1363,13 @@
  995. i*86:rdos:*:*)
  996. echo ${UNAME_MACHINE}-pc-rdos
  997. exit ;;
  998. -esac
  999. -
  1000. -#echo '(No uname command or uname output not recognized.)' 1>&2
  1001. -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
  1002. -
  1003. -eval $set_cc_for_build
  1004. -cat >$dummy.c <<EOF
  1005. -#ifdef _SEQUENT_
  1006. -# include <sys/types.h>
  1007. -# include <sys/utsname.h>
  1008. -#endif
  1009. -main ()
  1010. -{
  1011. -#if defined (sony)
  1012. -#if defined (MIPSEB)
  1013. - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
  1014. - I don't know.... */
  1015. - printf ("mips-sony-bsd\n"); exit (0);
  1016. -#else
  1017. -#include <sys/param.h>
  1018. - printf ("m68k-sony-newsos%s\n",
  1019. -#ifdef NEWSOS4
  1020. - "4"
  1021. -#else
  1022. - ""
  1023. -#endif
  1024. - ); exit (0);
  1025. -#endif
  1026. -#endif
  1027. -
  1028. -#if defined (__arm) && defined (__acorn) && defined (__unix)
  1029. - printf ("arm-acorn-riscix\n"); exit (0);
  1030. -#endif
  1031. -
  1032. -#if defined (hp300) && !defined (hpux)
  1033. - printf ("m68k-hp-bsd\n"); exit (0);
  1034. -#endif
  1035. -
  1036. -#if defined (NeXT)
  1037. -#if !defined (__ARCHITECTURE__)
  1038. -#define __ARCHITECTURE__ "m68k"
  1039. -#endif
  1040. - int version;
  1041. - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
  1042. - if (version < 4)
  1043. - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
  1044. - else
  1045. - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
  1046. - exit (0);
  1047. -#endif
  1048. -
  1049. -#if defined (MULTIMAX) || defined (n16)
  1050. -#if defined (UMAXV)
  1051. - printf ("ns32k-encore-sysv\n"); exit (0);
  1052. -#else
  1053. -#if defined (CMU)
  1054. - printf ("ns32k-encore-mach\n"); exit (0);
  1055. -#else
  1056. - printf ("ns32k-encore-bsd\n"); exit (0);
  1057. -#endif
  1058. -#endif
  1059. -#endif
  1060. -
  1061. -#if defined (__386BSD__)
  1062. - printf ("i386-pc-bsd\n"); exit (0);
  1063. -#endif
  1064. -
  1065. -#if defined (sequent)
  1066. -#if defined (i386)
  1067. - printf ("i386-sequent-dynix\n"); exit (0);
  1068. -#endif
  1069. -#if defined (ns32000)
  1070. - printf ("ns32k-sequent-dynix\n"); exit (0);
  1071. -#endif
  1072. -#endif
  1073. -
  1074. -#if defined (_SEQUENT_)
  1075. - struct utsname un;
  1076. -
  1077. - uname(&un);
  1078. -
  1079. - if (strncmp(un.version, "V2", 2) == 0) {
  1080. - printf ("i386-sequent-ptx2\n"); exit (0);
  1081. - }
  1082. - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
  1083. - printf ("i386-sequent-ptx1\n"); exit (0);
  1084. - }
  1085. - printf ("i386-sequent-ptx\n"); exit (0);
  1086. -
  1087. -#endif
  1088. -
  1089. -#if defined (vax)
  1090. -# if !defined (ultrix)
  1091. -# include <sys/param.h>
  1092. -# if defined (BSD)
  1093. -# if BSD == 43
  1094. - printf ("vax-dec-bsd4.3\n"); exit (0);
  1095. -# else
  1096. -# if BSD == 199006
  1097. - printf ("vax-dec-bsd4.3reno\n"); exit (0);
  1098. -# else
  1099. - printf ("vax-dec-bsd\n"); exit (0);
  1100. -# endif
  1101. -# endif
  1102. -# else
  1103. - printf ("vax-dec-bsd\n"); exit (0);
  1104. -# endif
  1105. -# else
  1106. - printf ("vax-dec-ultrix\n"); exit (0);
  1107. -# endif
  1108. -#endif
  1109. -
  1110. -#if defined (alliant) && defined (i860)
  1111. - printf ("i860-alliant-bsd\n"); exit (0);
  1112. -#endif
  1113. -
  1114. - exit (1);
  1115. -}
  1116. -EOF
  1117. -
  1118. -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
  1119. - { echo "$SYSTEM_NAME"; exit; }
  1120. -
  1121. -# Apollos put the system type in the environment.
  1122. -
  1123. -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
  1124. -
  1125. -# Convex versions that predate uname can use getsysinfo(1)
  1126. -
  1127. -if [ -x /usr/convex/getsysinfo ]
  1128. -then
  1129. - case `getsysinfo -f cpu_type` in
  1130. - c1*)
  1131. - echo c1-convex-bsd
  1132. + i*86:AROS:*:*)
  1133. + echo ${UNAME_MACHINE}-pc-aros
  1134. exit ;;
  1135. - c2*)
  1136. - if getsysinfo -f scalar_acc
  1137. - then echo c32-convex-bsd
  1138. - else echo c2-convex-bsd
  1139. - fi
  1140. - exit ;;
  1141. - c34*)
  1142. - echo c34-convex-bsd
  1143. + x86_64:VMkernel:*:*)
  1144. + echo ${UNAME_MACHINE}-unknown-esx
  1145. exit ;;
  1146. - c38*)
  1147. - echo c38-convex-bsd
  1148. - exit ;;
  1149. - c4*)
  1150. - echo c4-convex-bsd
  1151. - exit ;;
  1152. - esac
  1153. -fi
  1154. +esac
  1155. cat >&2 <<EOF
  1156. $0: unable to guess system type
  1157. @@ -1458,9 +1378,9 @@
  1158. the operating system you are using. It is advised that you
  1159. download the most up to date version of the config scripts from
  1160. - http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
  1161. + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
  1162. and
  1163. - http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
  1164. + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
  1165. If the version you run ($0) is already up to date, please
  1166. send the following data and any information you think might be
  1167. diff -Nur gcc-4.2.4.orig/config-ml.in gcc-4.2.4/config-ml.in
  1168. --- gcc-4.2.4.orig/config-ml.in 2006-06-13 15:48:23.000000000 -0500
  1169. +++ gcc-4.2.4/config-ml.in 2015-07-03 18:46:05.717283542 -0500
  1170. @@ -1,8 +1,8 @@
  1171. # Configure fragment invoked in the post-target section for subdirs
  1172. # wanting multilib support.
  1173. #
  1174. -# Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
  1175. -# Free Software Foundation, Inc.
  1176. +# Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
  1177. +# 2005, 2006, 2007 Free Software Foundation, Inc.
  1178. #
  1179. # This file is free software; you can redistribute it and/or modify
  1180. # it under the terms of the GNU General Public License as published by
  1181. @@ -108,6 +108,11 @@
  1182. ml_verbose=--verbose
  1183. for option in ${ac_configure_args}
  1184. do
  1185. + # strip single quotes surrounding individual options
  1186. + case $option in
  1187. + \'*\') eval option=$option ;;
  1188. + esac
  1189. +
  1190. case $option in
  1191. --*) ;;
  1192. -*) option=-$option ;;
  1193. @@ -535,7 +540,7 @@
  1194. else \
  1195. rootpre=`${PWD_COMMAND}`/; export rootpre; \
  1196. srcrootpre=`cd $(srcdir); ${PWD_COMMAND}`/; export srcrootpre; \
  1197. - lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
  1198. + lib=`echo "$${rootpre}" | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
  1199. compiler="$(CC)"; \
  1200. for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
  1201. dir=`echo $$i | sed -e 's/;.*$$//'`; \
  1202. @@ -581,8 +586,13 @@
  1203. true; \
  1204. else \
  1205. lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
  1206. - for dir in Makefile $(MULTIDIRS); do \
  1207. - if [ -f ../$${dir}/$${lib}/Makefile ]; then \
  1208. + for dir in : $(MULTIDIRS); do \
  1209. + test $$dir != : || continue; \
  1210. +EOF
  1211. +cat >>Multi.tem <<EOF
  1212. + if [ -f ../\$\${dir}/\$\${lib}/${Makefile} ]; then \\
  1213. +EOF
  1214. +cat >>Multi.tem <<\EOF
  1215. if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
  1216. then true; \
  1217. else exit 1; \
  1218. @@ -600,7 +610,7 @@
  1219. fi # ${ml_toplevel_p} = yes
  1220. if [ "${ml_verbose}" = --verbose ]; then
  1221. - echo "Adding multilib support to Makefile in ${ml_realsrcdir}"
  1222. + echo "Adding multilib support to ${Makefile} in ${ml_realsrcdir}"
  1223. if [ "${ml_toplevel_p}" = yes ]; then
  1224. echo "multidirs=${multidirs}"
  1225. fi
  1226. @@ -691,7 +701,7 @@
  1227. fi
  1228. ml_origdir=`${PWDCMD-pwd}`
  1229. - ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'`
  1230. + ml_libdir=`echo "$ml_origdir" | sed -e 's,^.*/,,'`
  1231. # cd to top-level-build-dir/${with_target_subdir}
  1232. cd ..
  1233. @@ -727,7 +737,7 @@
  1234. case ${srcdir} in
  1235. ".")
  1236. - echo Building symlink tree in `${PWDCMD-pwd}`/${ml_dir}/${ml_libdir}
  1237. + echo "Building symlink tree in `${PWDCMD-pwd}`/${ml_dir}/${ml_libdir}"
  1238. if [ "${with_target_subdir}" != "." ]; then
  1239. ml_unsubdir="../"
  1240. else
  1241. @@ -735,7 +745,7 @@
  1242. fi
  1243. (cd ${ml_dir}/${ml_libdir};
  1244. ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
  1245. - if [ -f ${ml_dir}/${ml_libdir}/Makefile ]; then
  1246. + if [ -f ${ml_dir}/${ml_libdir}/${Makefile} ]; then
  1247. if [ x"${MAKE}" = x ]; then
  1248. (cd ${ml_dir}/${ml_libdir}; make distclean)
  1249. else
  1250. @@ -792,7 +802,7 @@
  1251. else
  1252. # Create a regular expression that matches any string as long
  1253. # as ML_POPDIR.
  1254. - popdir_rx=`echo ${ML_POPDIR} | sed 's,.,.,g'`
  1255. + popdir_rx=`echo "${ML_POPDIR}" | sed 's,.,.,g'`
  1256. CC_=
  1257. for arg in ${CC}; do
  1258. case $arg in
  1259. @@ -890,17 +900,17 @@
  1260. if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
  1261. --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
  1262. - ${ac_configure_args} ${ml_srcdiroption} ; then
  1263. + ${ac_configure_args} ${ml_config_env} ${ml_srcdiroption} ; then
  1264. true
  1265. else
  1266. exit 1
  1267. fi
  1268. - cd ${ML_POPDIR}
  1269. + cd "${ML_POPDIR}"
  1270. done
  1271. - cd ${ml_origdir}
  1272. + cd "${ml_origdir}"
  1273. fi
  1274. fi # ${ml_toplevel_p} = yes
  1275. diff -Nur gcc-4.2.4.orig/config.sub gcc-4.2.4/config.sub
  1276. --- gcc-4.2.4.orig/config.sub 2006-10-15 22:27:17.000000000 -0500
  1277. +++ gcc-4.2.4/config.sub 2015-07-03 19:15:14.097267674 -0500
  1278. @@ -1,44 +1,40 @@
  1279. #! /bin/sh
  1280. # Configuration validation subroutine script.
  1281. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
  1282. -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
  1283. -# Inc.
  1284. -
  1285. -timestamp='2006-09-20'
  1286. -
  1287. -# This file is (in principle) common to ALL GNU software.
  1288. -# The presence of a machine in this file suggests that SOME GNU software
  1289. -# can handle that machine. It does not imply ALL GNU software can.
  1290. -#
  1291. -# This file is free software; you can redistribute it and/or modify
  1292. -# it under the terms of the GNU General Public License as published by
  1293. -# the Free Software Foundation; either version 2 of the License, or
  1294. +# Copyright 1992-2014 Free Software Foundation, Inc.
  1295. +
  1296. +timestamp='2014-09-26'
  1297. +
  1298. +# This file is free software; you can redistribute it and/or modify it
  1299. +# under the terms of the GNU General Public License as published by
  1300. +# the Free Software Foundation; either version 3 of the License, or
  1301. # (at your option) any later version.
  1302. #
  1303. -# This program is distributed in the hope that it will be useful,
  1304. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1305. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1306. -# GNU General Public License for more details.
  1307. +# This program is distributed in the hope that it will be useful, but
  1308. +# WITHOUT ANY WARRANTY; without even the implied warranty of
  1309. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1310. +# General Public License for more details.
  1311. #
  1312. # You should have received a copy of the GNU General Public License
  1313. -# along with this program; if not, write to the Free Software
  1314. -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
  1315. -# 02110-1301, USA.
  1316. +# along with this program; if not, see <http://www.gnu.org/licenses/>.
  1317. #
  1318. # As a special exception to the GNU General Public License, if you
  1319. # distribute this file as part of a program that contains a
  1320. # configuration script generated by Autoconf, you may include it under
  1321. -# the same distribution terms that you use for the rest of that program.
  1322. +# the same distribution terms that you use for the rest of that
  1323. +# program. This Exception is an additional permission under section 7
  1324. +# of the GNU General Public License, version 3 ("GPLv3").
  1325. -# Please send patches to <config-patches@gnu.org>. Submit a context
  1326. -# diff and a properly formatted ChangeLog entry.
  1327. +# Please send patches with a ChangeLog entry to config-patches@gnu.org.
  1328. #
  1329. # Configuration subroutine to validate and canonicalize a configuration type.
  1330. # Supply the specified configuration type as an argument.
  1331. # If it is invalid, we print an error message on stderr and exit with code 1.
  1332. # Otherwise, we print the canonical config type on stdout and succeed.
  1333. +# You can get the latest version of this script from:
  1334. +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
  1335. +
  1336. # This file is supposed to be the same for all GNU packages
  1337. # and recognize all the CPU types, system types and aliases
  1338. # that are meaningful with *any* GNU software.
  1339. @@ -72,8 +68,7 @@
  1340. version="\
  1341. GNU config.sub ($timestamp)
  1342. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
  1343. -Free Software Foundation, Inc.
  1344. +Copyright 1992-2014 Free Software Foundation, Inc.
  1345. This is free software; see the source for copying conditions. There is NO
  1346. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
  1347. @@ -120,12 +115,18 @@
  1348. # Here we must recognize all the valid KERNEL-OS combinations.
  1349. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
  1350. case $maybe_os in
  1351. - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
  1352. - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
  1353. + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
  1354. + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
  1355. + knetbsd*-gnu* | netbsd*-gnu* | \
  1356. + kopensolaris*-gnu* | \
  1357. storm-chaos* | os2-emx* | rtmk-nova*)
  1358. os=-$maybe_os
  1359. basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
  1360. ;;
  1361. + android-linux)
  1362. + os=-linux-android
  1363. + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
  1364. + ;;
  1365. *)
  1366. basic_machine=`echo $1 | sed 's/-[^-]*$//'`
  1367. if [ $basic_machine != $1 ]
  1368. @@ -148,10 +149,13 @@
  1369. -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
  1370. -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
  1371. -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
  1372. - -apple | -axis | -knuth | -cray)
  1373. + -apple | -axis | -knuth | -cray | -microblaze*)
  1374. os=
  1375. basic_machine=$1
  1376. ;;
  1377. + -bluegene*)
  1378. + os=-cnk
  1379. + ;;
  1380. -sim | -cisco | -oki | -wec | -winbond)
  1381. os=
  1382. basic_machine=$1
  1383. @@ -166,10 +170,10 @@
  1384. os=-chorusos
  1385. basic_machine=$1
  1386. ;;
  1387. - -chorusrdb)
  1388. - os=-chorusrdb
  1389. + -chorusrdb)
  1390. + os=-chorusrdb
  1391. basic_machine=$1
  1392. - ;;
  1393. + ;;
  1394. -hiux*)
  1395. os=-hiuxwe2
  1396. ;;
  1397. @@ -214,6 +218,12 @@
  1398. -isc*)
  1399. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  1400. ;;
  1401. + -lynx*178)
  1402. + os=-lynxos178
  1403. + ;;
  1404. + -lynx*5)
  1405. + os=-lynxos5
  1406. + ;;
  1407. -lynx*)
  1408. os=-lynxos
  1409. ;;
  1410. @@ -238,59 +248,89 @@
  1411. # Some are omitted here because they have special meanings below.
  1412. 1750a | 580 \
  1413. | a29k \
  1414. + | aarch64 | aarch64_be \
  1415. | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
  1416. | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
  1417. | am33_2.0 \
  1418. - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
  1419. + | arc | arceb \
  1420. + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
  1421. + | avr | avr32 \
  1422. + | be32 | be64 \
  1423. | bfin \
  1424. - | c4x | clipper \
  1425. + | c4x | c8051 | clipper \
  1426. | d10v | d30v | dlx | dsp16xx \
  1427. - | fr30 | frv \
  1428. + | epiphany \
  1429. + | fido | fr30 | frv \
  1430. | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
  1431. + | hexagon \
  1432. | i370 | i860 | i960 | ia64 \
  1433. | ip2k | iq2000 \
  1434. + | k1om \
  1435. + | le32 | le64 \
  1436. + | lm32 \
  1437. | m32c | m32r | m32rle | m68000 | m68k | m88k \
  1438. - | maxq | mb | microblaze | mcore \
  1439. + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
  1440. | mips | mipsbe | mipseb | mipsel | mipsle \
  1441. | mips16 \
  1442. | mips64 | mips64el \
  1443. - | mips64vr | mips64vrel \
  1444. + | mips64octeon | mips64octeonel \
  1445. | mips64orion | mips64orionel \
  1446. + | mips64r5900 | mips64r5900el \
  1447. + | mips64vr | mips64vrel \
  1448. | mips64vr4100 | mips64vr4100el \
  1449. | mips64vr4300 | mips64vr4300el \
  1450. | mips64vr5000 | mips64vr5000el \
  1451. | mips64vr5900 | mips64vr5900el \
  1452. | mipsisa32 | mipsisa32el \
  1453. | mipsisa32r2 | mipsisa32r2el \
  1454. + | mipsisa32r6 | mipsisa32r6el \
  1455. | mipsisa64 | mipsisa64el \
  1456. | mipsisa64r2 | mipsisa64r2el \
  1457. + | mipsisa64r6 | mipsisa64r6el \
  1458. | mipsisa64sb1 | mipsisa64sb1el \
  1459. | mipsisa64sr71k | mipsisa64sr71kel \
  1460. + | mipsr5900 | mipsr5900el \
  1461. | mipstx39 | mipstx39el \
  1462. | mn10200 | mn10300 \
  1463. + | moxie \
  1464. | mt \
  1465. | msp430 \
  1466. - | nios | nios2 \
  1467. + | nds32 | nds32le | nds32be \
  1468. + | nios | nios2 | nios2eb | nios2el \
  1469. | ns16k | ns32k \
  1470. - | or32 \
  1471. + | open8 | or1k | or1knd | or32 \
  1472. | pdp10 | pdp11 | pj | pjl \
  1473. - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
  1474. + | powerpc | powerpc64 | powerpc64le | powerpcle \
  1475. | pyramid \
  1476. + | riscv32 | riscv64 \
  1477. + | rl78 | rx \
  1478. | score \
  1479. - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
  1480. + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
  1481. | sh64 | sh64le \
  1482. | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
  1483. | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
  1484. - | spu | strongarm \
  1485. - | tahoe | thumb | tic4x | tic80 | tron \
  1486. - | v850 | v850e \
  1487. + | spu \
  1488. + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
  1489. + | ubicom32 \
  1490. + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
  1491. | we32k \
  1492. - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
  1493. - | z8k)
  1494. + | x86 | xc16x | xstormy16 | xtensa \
  1495. + | z8k | z80)
  1496. basic_machine=$basic_machine-unknown
  1497. ;;
  1498. - m6811 | m68hc11 | m6812 | m68hc12)
  1499. - # Motorola 68HC11/12.
  1500. + c54x)
  1501. + basic_machine=tic54x-unknown
  1502. + ;;
  1503. + c55x)
  1504. + basic_machine=tic55x-unknown
  1505. + ;;
  1506. + c6x)
  1507. + basic_machine=tic6x-unknown
  1508. + ;;
  1509. + leon|leon[3-9])
  1510. + basic_machine=sparc-$basic_machine
  1511. + ;;
  1512. + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
  1513. basic_machine=$basic_machine-unknown
  1514. os=-none
  1515. ;;
  1516. @@ -300,6 +340,21 @@
  1517. basic_machine=mt-unknown
  1518. ;;
  1519. + strongarm | thumb | xscale)
  1520. + basic_machine=arm-unknown
  1521. + ;;
  1522. + xgate)
  1523. + basic_machine=$basic_machine-unknown
  1524. + os=-none
  1525. + ;;
  1526. + xscaleeb)
  1527. + basic_machine=armeb-unknown
  1528. + ;;
  1529. +
  1530. + xscaleel)
  1531. + basic_machine=armel-unknown
  1532. + ;;
  1533. +
  1534. # We use `pc' rather than `unknown'
  1535. # because (1) that's what they normally are, and
  1536. # (2) the word "unknown" tends to confuse beginning users.
  1537. @@ -314,64 +369,86 @@
  1538. # Recognize the basic CPU types with company name.
  1539. 580-* \
  1540. | a29k-* \
  1541. + | aarch64-* | aarch64_be-* \
  1542. | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
  1543. | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
  1544. - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
  1545. + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
  1546. | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
  1547. | avr-* | avr32-* \
  1548. + | be32-* | be64-* \
  1549. | bfin-* | bs2000-* \
  1550. - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
  1551. - | clipper-* | craynv-* | cydra-* \
  1552. + | c[123]* | c30-* | [cjt]90-* | c4x-* \
  1553. + | c8051-* | clipper-* | craynv-* | cydra-* \
  1554. | d10v-* | d30v-* | dlx-* \
  1555. | elxsi-* \
  1556. - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
  1557. + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
  1558. | h8300-* | h8500-* \
  1559. | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
  1560. + | hexagon-* \
  1561. | i*86-* | i860-* | i960-* | ia64-* \
  1562. | ip2k-* | iq2000-* \
  1563. + | k1om-* \
  1564. + | le32-* | le64-* \
  1565. + | lm32-* \
  1566. | m32c-* | m32r-* | m32rle-* \
  1567. | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
  1568. - | m88110-* | m88k-* | maxq-* | mcore-* \
  1569. + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
  1570. + | microblaze-* | microblazeel-* \
  1571. | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
  1572. | mips16-* \
  1573. | mips64-* | mips64el-* \
  1574. - | mips64vr-* | mips64vrel-* \
  1575. + | mips64octeon-* | mips64octeonel-* \
  1576. | mips64orion-* | mips64orionel-* \
  1577. + | mips64r5900-* | mips64r5900el-* \
  1578. + | mips64vr-* | mips64vrel-* \
  1579. | mips64vr4100-* | mips64vr4100el-* \
  1580. | mips64vr4300-* | mips64vr4300el-* \
  1581. | mips64vr5000-* | mips64vr5000el-* \
  1582. | mips64vr5900-* | mips64vr5900el-* \
  1583. | mipsisa32-* | mipsisa32el-* \
  1584. | mipsisa32r2-* | mipsisa32r2el-* \
  1585. + | mipsisa32r6-* | mipsisa32r6el-* \
  1586. | mipsisa64-* | mipsisa64el-* \
  1587. | mipsisa64r2-* | mipsisa64r2el-* \
  1588. + | mipsisa64r6-* | mipsisa64r6el-* \
  1589. | mipsisa64sb1-* | mipsisa64sb1el-* \
  1590. | mipsisa64sr71k-* | mipsisa64sr71kel-* \
  1591. + | mipsr5900-* | mipsr5900el-* \
  1592. | mipstx39-* | mipstx39el-* \
  1593. | mmix-* \
  1594. | mt-* \
  1595. | msp430-* \
  1596. - | nios-* | nios2-* \
  1597. + | nds32-* | nds32le-* | nds32be-* \
  1598. + | nios-* | nios2-* | nios2eb-* | nios2el-* \
  1599. | none-* | np1-* | ns16k-* | ns32k-* \
  1600. + | open8-* \
  1601. + | or1k*-* \
  1602. | orion-* \
  1603. | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
  1604. - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
  1605. + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
  1606. | pyramid-* \
  1607. - | romp-* | rs6000-* \
  1608. - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
  1609. + | rl78-* | romp-* | rs6000-* | rx-* \
  1610. + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
  1611. | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
  1612. | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
  1613. | sparclite-* \
  1614. - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
  1615. - | tahoe-* | thumb-* \
  1616. + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
  1617. + | tahoe-* \
  1618. | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
  1619. + | tile*-* \
  1620. | tron-* \
  1621. - | v850-* | v850e-* | vax-* \
  1622. + | ubicom32-* \
  1623. + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
  1624. + | vax-* \
  1625. | we32k-* \
  1626. - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
  1627. - | xstormy16-* | xtensa-* \
  1628. + | x86-* | x86_64-* | xc16x-* | xps100-* \
  1629. + | xstormy16-* | xtensa*-* \
  1630. | ymp-* \
  1631. - | z8k-*)
  1632. + | z8k-* | z80-*)
  1633. + ;;
  1634. + # Recognize the basic CPU types without company name, with glob match.
  1635. + xtensa*)
  1636. + basic_machine=$basic_machine-unknown
  1637. ;;
  1638. # Recognize the various machine names and aliases which stand
  1639. # for a CPU type and a company and sometimes even an OS.
  1640. @@ -389,7 +466,7 @@
  1641. basic_machine=a29k-amd
  1642. os=-udi
  1643. ;;
  1644. - abacus)
  1645. + abacus)
  1646. basic_machine=abacus-unknown
  1647. ;;
  1648. adobe68k)
  1649. @@ -435,6 +512,10 @@
  1650. basic_machine=m68k-apollo
  1651. os=-bsd
  1652. ;;
  1653. + aros)
  1654. + basic_machine=i386-pc
  1655. + os=-aros
  1656. + ;;
  1657. aux)
  1658. basic_machine=m68k-apple
  1659. os=-aux
  1660. @@ -443,10 +524,35 @@
  1661. basic_machine=ns32k-sequent
  1662. os=-dynix
  1663. ;;
  1664. + blackfin)
  1665. + basic_machine=bfin-unknown
  1666. + os=-linux
  1667. + ;;
  1668. + blackfin-*)
  1669. + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
  1670. + os=-linux
  1671. + ;;
  1672. + bluegene*)
  1673. + basic_machine=powerpc-ibm
  1674. + os=-cnk
  1675. + ;;
  1676. + c54x-*)
  1677. + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
  1678. + ;;
  1679. + c55x-*)
  1680. + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
  1681. + ;;
  1682. + c6x-*)
  1683. + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
  1684. + ;;
  1685. c90)
  1686. basic_machine=c90-cray
  1687. os=-unicos
  1688. ;;
  1689. + cegcc)
  1690. + basic_machine=arm-unknown
  1691. + os=-cegcc
  1692. + ;;
  1693. convex-c1)
  1694. basic_machine=c1-convex
  1695. os=-bsd
  1696. @@ -475,8 +581,8 @@
  1697. basic_machine=craynv-cray
  1698. os=-unicosmp
  1699. ;;
  1700. - cr16c)
  1701. - basic_machine=cr16c-unknown
  1702. + cr16 | cr16-*)
  1703. + basic_machine=cr16-unknown
  1704. os=-elf
  1705. ;;
  1706. crds | unos)
  1707. @@ -514,6 +620,10 @@
  1708. basic_machine=m88k-motorola
  1709. os=-sysv3
  1710. ;;
  1711. + dicos)
  1712. + basic_machine=i686-pc
  1713. + os=-dicos
  1714. + ;;
  1715. djgpp)
  1716. basic_machine=i586-pc
  1717. os=-msdosdjgpp
  1718. @@ -629,7 +739,6 @@
  1719. i370-ibm* | ibm*)
  1720. basic_machine=i370-ibm
  1721. ;;
  1722. -# I'm not sure what "Sysv32" means. Should this be sysv3.2?
  1723. i*86v32)
  1724. basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
  1725. os=-sysv32
  1726. @@ -668,6 +777,17 @@
  1727. basic_machine=m68k-isi
  1728. os=-sysv
  1729. ;;
  1730. + leon-*|leon[3-9]-*)
  1731. + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
  1732. + ;;
  1733. + m68knommu)
  1734. + basic_machine=m68k-unknown
  1735. + os=-linux
  1736. + ;;
  1737. + m68knommu-*)
  1738. + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
  1739. + os=-linux
  1740. + ;;
  1741. m88k-omron*)
  1742. basic_machine=m88k-omron
  1743. ;;
  1744. @@ -679,10 +799,21 @@
  1745. basic_machine=ns32k-utek
  1746. os=-sysv
  1747. ;;
  1748. + microblaze*)
  1749. + basic_machine=microblaze-xilinx
  1750. + ;;
  1751. + mingw64)
  1752. + basic_machine=x86_64-pc
  1753. + os=-mingw64
  1754. + ;;
  1755. mingw32)
  1756. - basic_machine=i386-pc
  1757. + basic_machine=i686-pc
  1758. os=-mingw32
  1759. ;;
  1760. + mingw32ce)
  1761. + basic_machine=arm-unknown
  1762. + os=-mingw32ce
  1763. + ;;
  1764. miniframe)
  1765. basic_machine=m68000-convergent
  1766. ;;
  1767. @@ -704,6 +835,10 @@
  1768. basic_machine=powerpc-unknown
  1769. os=-morphos
  1770. ;;
  1771. + moxiebox)
  1772. + basic_machine=moxie-unknown
  1773. + os=-moxiebox
  1774. + ;;
  1775. msdos)
  1776. basic_machine=i386-pc
  1777. os=-msdos
  1778. @@ -711,10 +846,18 @@
  1779. ms1-*)
  1780. basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
  1781. ;;
  1782. + msys)
  1783. + basic_machine=i686-pc
  1784. + os=-msys
  1785. + ;;
  1786. mvs)
  1787. basic_machine=i370-ibm
  1788. os=-mvs
  1789. ;;
  1790. + nacl)
  1791. + basic_machine=le32-unknown
  1792. + os=-nacl
  1793. + ;;
  1794. ncr3000)
  1795. basic_machine=i486-ncr
  1796. os=-sysv4
  1797. @@ -779,6 +922,12 @@
  1798. np1)
  1799. basic_machine=np1-gould
  1800. ;;
  1801. + neo-tandem)
  1802. + basic_machine=neo-tandem
  1803. + ;;
  1804. + nse-tandem)
  1805. + basic_machine=nse-tandem
  1806. + ;;
  1807. nsr-tandem)
  1808. basic_machine=nsr-tandem
  1809. ;;
  1810. @@ -809,6 +958,14 @@
  1811. basic_machine=i860-intel
  1812. os=-osf
  1813. ;;
  1814. + parisc)
  1815. + basic_machine=hppa-unknown
  1816. + os=-linux
  1817. + ;;
  1818. + parisc-*)
  1819. + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
  1820. + os=-linux
  1821. + ;;
  1822. pbd)
  1823. basic_machine=sparc-tti
  1824. ;;
  1825. @@ -853,9 +1010,10 @@
  1826. ;;
  1827. power) basic_machine=power-ibm
  1828. ;;
  1829. - ppc) basic_machine=powerpc-unknown
  1830. + ppc | ppcbe) basic_machine=powerpc-unknown
  1831. ;;
  1832. - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
  1833. + ppc-* | ppcbe-*)
  1834. + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
  1835. ;;
  1836. ppcle | powerpclittle | ppc-le | powerpc-little)
  1837. basic_machine=powerpcle-unknown
  1838. @@ -880,7 +1038,11 @@
  1839. basic_machine=i586-unknown
  1840. os=-pw32
  1841. ;;
  1842. - rdos)
  1843. + rdos | rdos64)
  1844. + basic_machine=x86_64-pc
  1845. + os=-rdos
  1846. + ;;
  1847. + rdos32)
  1848. basic_machine=i386-pc
  1849. os=-rdos
  1850. ;;
  1851. @@ -925,6 +1087,9 @@
  1852. basic_machine=sh-hitachi
  1853. os=-hms
  1854. ;;
  1855. + sh5el)
  1856. + basic_machine=sh5le-unknown
  1857. + ;;
  1858. sh64)
  1859. basic_machine=sh64-unknown
  1860. ;;
  1861. @@ -946,6 +1111,9 @@
  1862. basic_machine=i860-stratus
  1863. os=-sysv4
  1864. ;;
  1865. + strongarm-* | thumb-*)
  1866. + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
  1867. + ;;
  1868. sun2)
  1869. basic_machine=m68000-sun
  1870. ;;
  1871. @@ -1002,17 +1170,9 @@
  1872. basic_machine=t90-cray
  1873. os=-unicos
  1874. ;;
  1875. - tic54x | c54x*)
  1876. - basic_machine=tic54x-unknown
  1877. - os=-coff
  1878. - ;;
  1879. - tic55x | c55x*)
  1880. - basic_machine=tic55x-unknown
  1881. - os=-coff
  1882. - ;;
  1883. - tic6x | c6x*)
  1884. - basic_machine=tic6x-unknown
  1885. - os=-coff
  1886. + tile*)
  1887. + basic_machine=$basic_machine-unknown
  1888. + os=-linux-gnu
  1889. ;;
  1890. tx39)
  1891. basic_machine=mipstx39-unknown
  1892. @@ -1081,6 +1241,9 @@
  1893. xps | xps100)
  1894. basic_machine=xps100-honeywell
  1895. ;;
  1896. + xscale-* | xscalee[bl]-*)
  1897. + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
  1898. + ;;
  1899. ymp)
  1900. basic_machine=ymp-cray
  1901. os=-unicos
  1902. @@ -1089,6 +1252,10 @@
  1903. basic_machine=z8k-unknown
  1904. os=-sim
  1905. ;;
  1906. + z80-*-coff)
  1907. + basic_machine=z80-unknown
  1908. + os=-sim
  1909. + ;;
  1910. none)
  1911. basic_machine=none-none
  1912. os=-none
  1913. @@ -1127,7 +1294,7 @@
  1914. we32k)
  1915. basic_machine=we32k-att
  1916. ;;
  1917. - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
  1918. + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
  1919. basic_machine=sh-unknown
  1920. ;;
  1921. sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
  1922. @@ -1174,9 +1341,12 @@
  1923. if [ x"$os" != x"" ]
  1924. then
  1925. case $os in
  1926. - # First match some system type aliases
  1927. - # that might get confused with valid system types.
  1928. + # First match some system type aliases
  1929. + # that might get confused with valid system types.
  1930. # -solaris* is a basic system type, with this one exception.
  1931. + -auroraux)
  1932. + os=-auroraux
  1933. + ;;
  1934. -solaris1 | -solaris1.*)
  1935. os=`echo $os | sed -e 's|solaris1|sunos4|'`
  1936. ;;
  1937. @@ -1197,29 +1367,31 @@
  1938. # Each alternative MUST END IN A *, to match a version number.
  1939. # -sysv* is not here because it comes later, after sysvr4.
  1940. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
  1941. - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
  1942. - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
  1943. + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
  1944. + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
  1945. + | -sym* | -kopensolaris* | -plan9* \
  1946. | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
  1947. - | -aos* \
  1948. + | -aos* | -aros* \
  1949. | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
  1950. | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
  1951. | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
  1952. - | -openbsd* | -solidbsd* \
  1953. + | -bitrig* | -openbsd* | -solidbsd* \
  1954. | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
  1955. | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
  1956. | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
  1957. | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
  1958. - | -chorusos* | -chorusrdb* \
  1959. - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
  1960. - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
  1961. - | -uxpv* | -beos* | -mpeix* | -udk* \
  1962. + | -chorusos* | -chorusrdb* | -cegcc* \
  1963. + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
  1964. + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
  1965. + | -linux-newlib* | -linux-musl* | -linux-uclibc* \
  1966. + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
  1967. | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
  1968. | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
  1969. | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
  1970. | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
  1971. | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
  1972. | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
  1973. - | -skyos* | -haiku* | -rdos* | -toppers*)
  1974. + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
  1975. # Remember, each alternative MUST END IN *, to match a version number.
  1976. ;;
  1977. -qnx*)
  1978. @@ -1258,7 +1430,7 @@
  1979. -opened*)
  1980. os=-openedition
  1981. ;;
  1982. - -os400*)
  1983. + -os400*)
  1984. os=-os400
  1985. ;;
  1986. -wince*)
  1987. @@ -1307,7 +1479,7 @@
  1988. -sinix*)
  1989. os=-sysv4
  1990. ;;
  1991. - -tpf*)
  1992. + -tpf*)
  1993. os=-tpf
  1994. ;;
  1995. -triton*)
  1996. @@ -1343,12 +1515,14 @@
  1997. -aros*)
  1998. os=-aros
  1999. ;;
  2000. - -kaos*)
  2001. - os=-kaos
  2002. - ;;
  2003. -zvmoe)
  2004. os=-zvmoe
  2005. ;;
  2006. + -dicos*)
  2007. + os=-dicos
  2008. + ;;
  2009. + -nacl*)
  2010. + ;;
  2011. -none)
  2012. ;;
  2013. *)
  2014. @@ -1371,10 +1545,10 @@
  2015. # system, and we'll never get to this point.
  2016. case $basic_machine in
  2017. - score-*)
  2018. + score-*)
  2019. os=-elf
  2020. ;;
  2021. - spu-*)
  2022. + spu-*)
  2023. os=-elf
  2024. ;;
  2025. *-acorn)
  2026. @@ -1386,8 +1560,23 @@
  2027. arm*-semi)
  2028. os=-aout
  2029. ;;
  2030. - c4x-* | tic4x-*)
  2031. - os=-coff
  2032. + c4x-* | tic4x-*)
  2033. + os=-coff
  2034. + ;;
  2035. + c8051-*)
  2036. + os=-elf
  2037. + ;;
  2038. + hexagon-*)
  2039. + os=-elf
  2040. + ;;
  2041. + tic54x-*)
  2042. + os=-coff
  2043. + ;;
  2044. + tic55x-*)
  2045. + os=-coff
  2046. + ;;
  2047. + tic6x-*)
  2048. + os=-coff
  2049. ;;
  2050. # This must come before the *-dec entry.
  2051. pdp10-*)
  2052. @@ -1407,13 +1596,13 @@
  2053. ;;
  2054. m68000-sun)
  2055. os=-sunos3
  2056. - # This also exists in the configure program, but was not the
  2057. - # default.
  2058. - # os=-sunos4
  2059. ;;
  2060. m68*-cisco)
  2061. os=-aout
  2062. ;;
  2063. + mep-*)
  2064. + os=-elf
  2065. + ;;
  2066. mips*-cisco)
  2067. os=-elf
  2068. ;;
  2069. @@ -1438,7 +1627,7 @@
  2070. *-ibm)
  2071. os=-aix
  2072. ;;
  2073. - *-knuth)
  2074. + *-knuth)
  2075. os=-mmixware
  2076. ;;
  2077. *-wec)
  2078. @@ -1543,7 +1732,7 @@
  2079. -sunos*)
  2080. vendor=sun
  2081. ;;
  2082. - -aix*)
  2083. + -cnk*|-aix*)
  2084. vendor=ibm
  2085. ;;
  2086. -beos*)
  2087. diff -Nur gcc-4.2.4.orig/contrib/test_installed gcc-4.2.4/contrib/test_installed
  2088. --- gcc-4.2.4.orig/contrib/test_installed 2003-07-11 01:05:01.000000000 -0500
  2089. +++ gcc-4.2.4/contrib/test_installed 2015-07-03 18:46:05.717283542 -0500
  2090. @@ -107,6 +107,8 @@
  2091. set srcdir "${testsuite-${srcdir}/gcc/testsuite}"
  2092. set CFLAGS ""
  2093. set CXXFLAGS ""
  2094. +set HOSTCC "cc"
  2095. +set HOSTCFLAGS ""
  2096. set GCC_UNDER_TEST "${GCC_UNDER_TEST-${prefix}${prefix+/bin/}gcc}"
  2097. set GXX_UNDER_TEST "${GXX_UNDER_TEST-${prefix}${prefix+/bin/}g++}"
  2098. set G77_UNDER_TEST "${G77_UNDER_TEST-${prefix}${prefix+/bin/}g77}"
  2099. diff -Nur gcc-4.2.4.orig/fixincludes/mkfixinc.sh gcc-4.2.4/fixincludes/mkfixinc.sh
  2100. --- gcc-4.2.4.orig/fixincludes/mkfixinc.sh 2004-11-23 16:45:53.000000000 -0600
  2101. +++ gcc-4.2.4/fixincludes/mkfixinc.sh 2015-07-03 18:46:05.717283542 -0500
  2102. @@ -23,6 +23,7 @@
  2103. i?86-*-mingw32* | \
  2104. i?86-*-uwin* | \
  2105. i?86-*-interix* | \
  2106. + metag*-linux-uclibc* | \
  2107. powerpc-*-eabiaix* | \
  2108. powerpc-*-eabisim* | \
  2109. powerpc-*-eabi* | \
  2110. diff -Nur gcc-4.2.4.orig/gcc/caller-save.c gcc-4.2.4/gcc/caller-save.c
  2111. --- gcc-4.2.4.orig/gcc/caller-save.c 2007-09-01 10:28:30.000000000 -0500
  2112. +++ gcc-4.2.4/gcc/caller-save.c 2015-07-03 18:46:05.717283542 -0500
  2113. @@ -36,6 +36,10 @@
  2114. #include "tm_p.h"
  2115. #include "addresses.h"
  2116. +#ifndef CALLER_SAVE_INSN_CODE
  2117. +#define CALLER_SAVE_INSN_CODE(CODE) (CODE)
  2118. +#endif
  2119. +
  2120. #ifndef MAX_MOVE_MAX
  2121. #define MAX_MOVE_MAX MOVE_MAX
  2122. #endif
  2123. @@ -776,7 +780,8 @@
  2124. /* Emit a new caller-save insn and set the code. */
  2125. static struct insn_chain *
  2126. -insert_one_insn (struct insn_chain *chain, int before_p, int code, rtx pat)
  2127. +insert_one_insn (struct insn_chain *chain, int before_p,
  2128. + int code ATTRIBUTE_UNUSED, rtx pat)
  2129. {
  2130. rtx insn = chain->insn;
  2131. struct insn_chain *new;
  2132. @@ -857,6 +862,6 @@
  2133. new->block = chain->block;
  2134. new->is_caller_save_insn = 1;
  2135. - INSN_CODE (new->insn) = code;
  2136. + INSN_CODE (new->insn) = CALLER_SAVE_INSN_CODE (code);
  2137. return new;
  2138. }
  2139. diff -Nur gcc-4.2.4.orig/gcc/calls.c gcc-4.2.4/gcc/calls.c
  2140. --- gcc-4.2.4.orig/gcc/calls.c 2007-09-01 10:28:30.000000000 -0500
  2141. +++ gcc-4.2.4/gcc/calls.c 2015-07-03 18:46:05.717283542 -0500
  2142. @@ -829,6 +829,7 @@
  2143. {
  2144. int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
  2145. int endian_correction = 0;
  2146. + rtx value;
  2147. if (args[i].partial)
  2148. {
  2149. @@ -858,10 +859,22 @@
  2150. )
  2151. endian_correction = BITS_PER_WORD - bytes * BITS_PER_UNIT;
  2152. +
  2153. + value = args[i].value;
  2154. +
  2155. +#if METAG_PARTIAL_ARGS
  2156. + if (args[i].partial)
  2157. + {
  2158. + HOST_WIDE_INT excess = (bytes + (UNITS_PER_WORD - 1)) & ~(UNITS_PER_WORD - 1);
  2159. +
  2160. + value = adjust_address (value, GET_MODE (value), excess - args[i].partial);
  2161. + }
  2162. +#endif
  2163. +
  2164. for (j = 0; j < args[i].n_aligned_regs; j++)
  2165. {
  2166. rtx reg = gen_reg_rtx (word_mode);
  2167. - rtx word = operand_subword_force (args[i].value, j, BLKmode);
  2168. + rtx word = operand_subword_force (value, j, BLKmode);
  2169. int bitsize = MIN (bytes * BITS_PER_UNIT, BITS_PER_WORD);
  2170. args[i].aligned_regs[j] = reg;
  2171. diff -Nur gcc-4.2.4.orig/gcc/config/metag/builtins.md gcc-4.2.4/gcc/config/metag/builtins.md
  2172. --- gcc-4.2.4.orig/gcc/config/metag/builtins.md 1969-12-31 18:00:00.000000000 -0600
  2173. +++ gcc-4.2.4/gcc/config/metag/builtins.md 2015-07-03 18:46:05.741283542 -0500
  2174. @@ -0,0 +1,106 @@
  2175. +;; Machine description for GNU compiler,
  2176. +;; Imagination Technologies Meta version.
  2177. +;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
  2178. +;; Imagination Technologies Ltd
  2179. +
  2180. +;; This file is part of GCC.
  2181. +
  2182. +;; GCC is free software; you can redistribute it and/or modify it under
  2183. +;; the terms of the GNU General Public License as published by the Free
  2184. +;; Software Foundation; either version 3, or (at your option) any later
  2185. +;; version.
  2186. +
  2187. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  2188. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  2189. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  2190. +;; for more details.
  2191. +
  2192. +;; You should have received a copy of the GNU General Public License
  2193. +;; along with GCC; see the file COPYING3. If not see
  2194. +;; <http://www.gnu.org/licenses/>.
  2195. +
  2196. +;;- meta builtins functions
  2197. +
  2198. +;; "__builtin_dcache_preload" data cache preload
  2199. +(define_insn "dcache_preload"
  2200. + [(set (reg:SI RAPF_REG)
  2201. + (unspec_volatile:SI [(match_operand:SI 0 "metag_register_op" "r")] VUNSPEC_DCACHE_PRELOAD))]
  2202. + "TARGET_BUILTINS_METAC_1_1 || TARGET_BUILTINS_METAC_1_2 || TARGET_BUILTINS_METAC_2_1"
  2203. + "MOV\\tRAPF,%0\\t\\t%@ (*prefetch OK)"
  2204. + [(set_attr "type" "fast")])
  2205. +
  2206. +;; "__builtin_dcache_flush" data cache flush
  2207. +(define_insn "dcache_flush"
  2208. + [(unspec_volatile [(match_operand:SI 0 "metag_register_op" "r")
  2209. + (match_operand:SI 1 "metag_register_op" "r")] VUNSPEC_DCACHE)]
  2210. + "TARGET_BUILTINS_METAC_1_2 || TARGET_BUILTINS_METAC_2_1"
  2211. + "DCACHE\\t[%0],%1\\t\\t%@ (*flush OK)"
  2212. + [(set_attr "type" "fast")])
  2213. +
  2214. +;; "__builtin_dcache_refresh" data cache refresh
  2215. +(define_insn "dcache_refresh"
  2216. + [(set (reg:SI RAPF_REG)
  2217. + (unspec_volatile:SI [(match_operand:SI 0 "metag_register_op" "d")
  2218. + (match_operand:SI 1 "metag_register_op" "a")] VUNSPEC_DCACHE_REFRESH))]
  2219. + "TARGET_BUILTINS_METAC_1_1 || TARGET_BUILTINS_METAC_1_2 || TARGET_BUILTINS_METAC_2_1"
  2220. + "*
  2221. +{
  2222. + if (TARGET_BUILTINS_METAC_1_1)
  2223. + output_asm_insn (\"SETB\\t[%0],%1\\t\\t%@ (*refresh ...\\n\\tLSL\\tRAPF,%0,#6\\t\\t%@ ... OK)\",
  2224. + operands);
  2225. + else
  2226. + output_asm_insn (\"DCACHE\\t[%0],%1\\t\\t%@ (*refresh ...\\n\\tADD\\tRAPF,%0,#0\\t\\t%@ ... OK)\",
  2227. + operands);
  2228. + return \"\";
  2229. +}"
  2230. + [(set_attr "type" "two")])
  2231. +
  2232. +;; "__builtin_meta2_cacherd"
  2233. +(define_insn "meta2_cacherd"
  2234. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  2235. + (unspec_volatile:SI [(match_operand:SI 1 "metag_register_op" "r")] VUNSPEC_META2_CACHERD))]
  2236. + "TARGET_BUILTINS_METAC_2_1"
  2237. + "CACHERD\\t%0,[%1]\\t\\t%@ (*cacherd OK)"
  2238. + [(set_attr "type" "fast")])
  2239. +
  2240. +;; "__builtin_meta2_cacherl"
  2241. +(define_insn "meta2_cacherl"
  2242. + [(set (match_operand:DI 0 "metag_register_op" "=r")
  2243. + (unspec_volatile:DI [(match_operand:SI 1 "metag_register_op" "r")] VUNSPEC_META2_CACHERL))]
  2244. + "TARGET_BUILTINS_METAC_2_1"
  2245. + "CACHERL\\t%0,%t0,[%1]\\t\\t%@ (*cacherl OK)"
  2246. + [(set_attr "type" "fast")])
  2247. +
  2248. +;; "__builtin_meta2_cachewd"
  2249. +(define_insn "meta2_cachewd"
  2250. + [(unspec_volatile [(match_operand:SI 0 "metag_register_op" "r")
  2251. + (match_operand:SI 1 "metag_register_op" "r")] VUNSPEC_META2_CACHEWD)]
  2252. + "TARGET_BUILTINS_METAC_2_1"
  2253. + "CACHEWD\\t[%0],%1\\t\\t%@ (*cachewd OK)"
  2254. + [(set_attr "type" "fast")])
  2255. +
  2256. +;; "__builtin_meta2_cachewl"
  2257. +(define_insn "meta2_cachewl"
  2258. + [(unspec_volatile [(match_operand:SI 0 "metag_register_op" "r")
  2259. + (match_operand:DI 1 "metag_register_op" "r")] VUNSPEC_META2_CACHEWL)]
  2260. + "TARGET_BUILTINS_METAC_2_1"
  2261. + "CACHEWL\\t[%0],%1,%t1\\t\\t%@ (*cachewl OK)"
  2262. + [(set_attr "type" "fast")])
  2263. +
  2264. +; "__builtin_metag_bswap"
  2265. +(define_insn "metag_bswap"
  2266. + [(set (match_operand:SI 0 "metag_register_op" "=e,f")
  2267. + (unspec:SI [(match_operand:SI 1 "metag_register_op" "e,f")] UNSPEC_METAG_BSWAP))]
  2268. + "TARGET_BUILTINS_METAC_2_1 && metag_meta2_bex_enabled"
  2269. + "BEXD\\t%0,%1\\t\\t%@ (*bswap OK)"
  2270. + [(set_attr "type" "fast")])
  2271. +
  2272. +; "__builtin_metag_bswapll"
  2273. +(define_insn "metag_bswapll"
  2274. + [(set (match_operand:DI 0 "metag_register_op" "=d")
  2275. + (unspec:DI [(match_operand:DI 1 "metag_register_op" "d")] UNSPEC_METAG_BSWAPLL))]
  2276. + "TARGET_BUILTINS_METAC_2_1 && metag_meta2_bex_enabled"
  2277. + "BEXL\\t%t0,%1\\t\\t%@ (*bswapll OK)"
  2278. + [(set_attr "type" "fast")])
  2279. +
  2280. +;; end of file
  2281. diff -Nur gcc-4.2.4.orig/gcc/config/metag/combines.md gcc-4.2.4/gcc/config/metag/combines.md
  2282. --- gcc-4.2.4.orig/gcc/config/metag/combines.md 1969-12-31 18:00:00.000000000 -0600
  2283. +++ gcc-4.2.4/gcc/config/metag/combines.md 2015-07-03 18:46:05.745283542 -0500
  2284. @@ -0,0 +1,1052 @@
  2285. +;; Machine description for GNU compiler,
  2286. +;; Imagination Technologies Meta version.
  2287. +;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
  2288. +;; Imagination Technologies Ltd
  2289. +
  2290. +;; This file is part of GCC.
  2291. +
  2292. +;; GCC is free software; you can redistribute it and/or modify it under
  2293. +;; the terms of the GNU General Public License as published by the Free
  2294. +;; Software Foundation; either version 3, or (at your option) any later
  2295. +;; version.
  2296. +
  2297. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  2298. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  2299. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  2300. +;; for more details.
  2301. +
  2302. +;; You should have received a copy of the GNU General Public License
  2303. +;; along with GCC; see the file COPYING3. If not see
  2304. +;; <http://www.gnu.org/licenses/>.
  2305. +
  2306. +;; -----------------------------------------------------------------------------
  2307. +;; | Recognising SI/HI/QI store pre-inc/dec/modify |
  2308. +;; -----------------------------------------------------------------------------
  2309. +
  2310. +(define_insn_and_split "*sto_<mode>_pre_inc_dec_modify_disp_split"
  2311. + [(set (mem:MEMOP (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+efhl")
  2312. + (match_operand:SI 1 "metag_offset6_<mode>" "<O>")))
  2313. + (match_operand:<MODE> 2 "metag_register_op" "r"))
  2314. + (set (match_dup 0)
  2315. + (plus:SI (match_dup 0)
  2316. + (match_dup 1)))]
  2317. + "TARGET_METAC_1_1
  2318. + && !reload_in_progress && !reload_completed"
  2319. + "#"
  2320. + "&& TRUE"
  2321. + [(const_int 0)]
  2322. + {
  2323. + rtx pre, mem, insn;
  2324. +
  2325. + if (INTVAL (operands[1]) == GET_MODE_SIZE (<MODE>mode))
  2326. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  2327. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (<MODE>mode))
  2328. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  2329. + else
  2330. + {
  2331. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2332. +
  2333. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  2334. + }
  2335. +
  2336. + mem = gen_rtx_MEM (<MODE>mode, pre);
  2337. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  2338. +
  2339. + if (auto_inc_p (pre))
  2340. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  2341. + DONE;
  2342. + }
  2343. + [(set_attr "type" "fast")])
  2344. +
  2345. +(define_insn_and_split "*sto_<mode>_pre_modify_reg_split"
  2346. + [(set (mem:MEMOP (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+%e,f,h,l")
  2347. + (match_operand:SI 1 "metag_register_op" "e,f,h,l")))
  2348. + (match_operand:<MODE> 2 "metag_register_op" "t,u,y,z"))
  2349. + (set (match_dup 0)
  2350. + (plus:SI (match_dup 0)
  2351. + (match_dup 1)))]
  2352. + "TARGET_METAC_1_1
  2353. + && !reload_in_progress && !reload_completed"
  2354. + "#"
  2355. + "&& TRUE"
  2356. + [(const_int 0)]
  2357. + {
  2358. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2359. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  2360. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  2361. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  2362. +
  2363. + if (auto_inc_p (pre_modify))
  2364. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  2365. + DONE;
  2366. + }
  2367. + [(set_attr "type" "fast")])
  2368. +
  2369. +;; -----------------------------------------------------------------------------
  2370. +
  2371. +;; -----------------------------------------------------------------------------
  2372. +;; | Recognising SI/HI/QI store post-inc/dec/modify |
  2373. +;; -----------------------------------------------------------------------------
  2374. +
  2375. +(define_insn_and_split "*sto_<mode>_post_inc_dec_modify_disp_split"
  2376. + [(set (mem:MEMOP (match_operand:SI 0 "metag_regnofrm_op" "+efhl"))
  2377. + (match_operand:<MODE> 1 "metag_register_op" "r"))
  2378. + (set (match_dup 0)
  2379. + (plus:SI (match_dup 0)
  2380. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>")))]
  2381. + "TARGET_METAC_1_1
  2382. + && !reload_in_progress && !reload_completed"
  2383. + "#"
  2384. + "&& TRUE"
  2385. + [(const_int 0)]
  2386. + {
  2387. + rtx post, mem, insn;
  2388. +
  2389. + if (INTVAL (operands[2]) == GET_MODE_SIZE (<MODE>mode))
  2390. + post = gen_rtx_POST_INC (SImode, operands[0]);
  2391. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (<MODE>mode))
  2392. + post = gen_rtx_POST_DEC (SImode, operands[0]);
  2393. + else
  2394. + {
  2395. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  2396. +
  2397. + post = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  2398. + }
  2399. +
  2400. + mem = gen_rtx_MEM (<MODE>mode, post);
  2401. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  2402. +
  2403. + if (auto_inc_p (post))
  2404. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  2405. + DONE;
  2406. + }
  2407. + [(set_attr "type" "fast")])
  2408. +
  2409. +(define_insn_and_split "*sto_<mode>_post_modify_reg_split"
  2410. + [(set (mem:MEMOP (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l"))
  2411. + (match_operand:<MODE> 1 "metag_register_op" "t,u,y,z"))
  2412. + (set (match_dup 0)
  2413. + (plus:SI (match_dup 0)
  2414. + (match_operand:SI 2 "metag_register_op" "e,f,h,l")))]
  2415. + "TARGET_METAC_1_1
  2416. + && !reload_in_progress && !reload_completed"
  2417. + "#"
  2418. + "&& TRUE"
  2419. + [(const_int 0)]
  2420. + {
  2421. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  2422. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  2423. + rtx mem = gen_rtx_MEM (<MODE>mode, post_modify);
  2424. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  2425. +
  2426. + if (auto_inc_p (post_modify))
  2427. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  2428. + DONE;
  2429. + }
  2430. + [(set_attr "type" "fast")])
  2431. +
  2432. +;; -----------------------------------------------------------------------------
  2433. +
  2434. +;; -----------------------------------------------------------------------------
  2435. +;; | Recognising QI/HI/SI load pre-inc/dec/modify |
  2436. +;; -----------------------------------------------------------------------------
  2437. +
  2438. +(define_insn_and_split "*lod_<mode>_pre_inc_dec_modify_disp_split"
  2439. + [(set (match_operand:<MODE> 0 "metag_register_op" "=r")
  2440. + (mem:MEMOP (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+efhl")
  2441. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>"))))
  2442. + (set (match_dup 1)
  2443. + (plus:SI (match_dup 1)
  2444. + (match_dup 2)))]
  2445. + "TARGET_METAC_1_1
  2446. + && !reload_in_progress && !reload_completed"
  2447. + "#"
  2448. + "&& TRUE"
  2449. + [(const_int 0)]
  2450. + {
  2451. + rtx pre, mem, insn;
  2452. +
  2453. + if (INTVAL (operands[2]) == GET_MODE_SIZE (<MODE>mode))
  2454. + pre = gen_rtx_PRE_INC (SImode, operands[1]);
  2455. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (<MODE>mode))
  2456. + pre = gen_rtx_PRE_DEC (SImode, operands[1]);
  2457. + else
  2458. + {
  2459. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2460. +
  2461. + pre = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2462. + }
  2463. +
  2464. + mem = gen_rtx_MEM (<MODE>mode, pre);
  2465. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  2466. +
  2467. + if (auto_inc_p (pre))
  2468. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  2469. + DONE;
  2470. + }
  2471. + [(set_attr "type" "fast")])
  2472. +
  2473. +(define_insn_and_split "*lod_<mode>_pre_modify_reg_split"
  2474. + [(set (match_operand:<MODE> 0 "metag_register_op" "=r,r,r,r")
  2475. + (mem:MEMOP (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+e,f,h,l")
  2476. + (match_operand:SI 2 "metag_register_op" "e,f,h,l"))))
  2477. + (set (match_dup 1)
  2478. + (plus:SI (match_dup 1)
  2479. + (match_dup 2)))]
  2480. + "TARGET_METAC_1_1
  2481. + && !reload_in_progress && !reload_completed"
  2482. + "#"
  2483. + "&& TRUE"
  2484. + [(const_int 0)]
  2485. + {
  2486. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2487. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2488. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  2489. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  2490. +
  2491. + if (auto_inc_p (pre_modify))
  2492. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  2493. + DONE;
  2494. + }
  2495. + [(set_attr "type" "fast")])
  2496. +
  2497. +;; -----------------------------------------------------------------------------
  2498. +
  2499. +;; -----------------------------------------------------------------------------
  2500. +;; | Recognising DI store pre-inc/dec/modify |
  2501. +;; -----------------------------------------------------------------------------
  2502. +
  2503. +(define_insn_and_split "*sto_di_pre_inc_dec_modify_disp_split"
  2504. + [(set (mem:DI (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+efhl")
  2505. + (match_operand:SI 1 "metag_offset6_di" "O8")))
  2506. + (match_operand:DI 2 "metag_register_op" "r"))
  2507. + (set (match_dup 0)
  2508. + (plus:SI (match_dup 0)
  2509. + (match_dup 1)))]
  2510. + "TARGET_METAC_1_1
  2511. + && !reload_in_progress && !reload_completed"
  2512. + "#"
  2513. + "&& TRUE"
  2514. + [(const_int 0)]
  2515. + {
  2516. + rtx pre, mem, insn;
  2517. +
  2518. + if (INTVAL (operands[1]) == GET_MODE_SIZE (DImode))
  2519. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  2520. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (DImode))
  2521. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  2522. + else
  2523. + {
  2524. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2525. +
  2526. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  2527. + }
  2528. +
  2529. + mem = gen_rtx_MEM (DImode, pre);
  2530. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  2531. +
  2532. + if (auto_inc_p (pre))
  2533. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  2534. + DONE;
  2535. + }
  2536. + [(set_attr "type" "fast")])
  2537. +
  2538. +(define_insn_and_split "*sto_di_pre_modify_reg_split"
  2539. + [(set (mem:DI (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l")
  2540. + (match_operand:SI 1 "metag_register_op" "e,f,h,l")))
  2541. + (match_operand:DI 2 "metag_register_op" "a,a,d,d"))
  2542. + (set (match_dup 0)
  2543. + (plus:SI (match_dup 0)
  2544. + (match_dup 1)))]
  2545. + "TARGET_METAC_1_1
  2546. + && !reload_in_progress && !reload_completed"
  2547. + "#"
  2548. + "&& TRUE"
  2549. + [(const_int 0)]
  2550. + {
  2551. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2552. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  2553. + rtx mem = gen_rtx_MEM (DImode, pre_modify);
  2554. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  2555. +
  2556. + if (auto_inc_p (pre_modify))
  2557. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  2558. + DONE;
  2559. + }
  2560. + [(set_attr "type" "fast")])
  2561. +
  2562. +;; -----------------------------------------------------------------------------
  2563. +;; | Recognising DI store post-inc/dec/modify |
  2564. +;; -----------------------------------------------------------------------------
  2565. +
  2566. +(define_insn_and_split "*sto_di_post_inc_dec_modify_disp_split"
  2567. + [(set (mem:DI (match_operand:SI 0 "metag_regnofrm_op" "+efhl"))
  2568. + (match_operand:DI 1 "metag_register_op" "r"))
  2569. + (set (match_dup 0)
  2570. + (plus:SI (match_dup 0)
  2571. + (match_operand:SI 2 "metag_offset6_di" "O8")))]
  2572. + "TARGET_METAC_1_1
  2573. + && !reload_in_progress && !reload_completed"
  2574. + "#"
  2575. + "&& TRUE"
  2576. + [(const_int 0)]
  2577. + {
  2578. + rtx post, mem, insn;
  2579. +
  2580. + if (INTVAL (operands[2]) == GET_MODE_SIZE (DImode))
  2581. + post = gen_rtx_POST_INC (SImode, operands[0]);
  2582. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (DImode))
  2583. + post = gen_rtx_POST_DEC (SImode, operands[0]);
  2584. + else
  2585. + {
  2586. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  2587. +
  2588. + post = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  2589. + }
  2590. +
  2591. + mem = gen_rtx_MEM (DImode, post);
  2592. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  2593. +
  2594. + if (auto_inc_p (post))
  2595. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  2596. + DONE;
  2597. + }
  2598. + [(set_attr "type" "fast")])
  2599. +
  2600. +(define_insn_and_split "*sto_di_post_modify_reg_split"
  2601. + [(set (mem:DI (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l"))
  2602. + (match_operand:DI 1 "metag_register_op" "a,a,d,d"))
  2603. + (set (match_dup 0)
  2604. + (plus:SI (match_dup 0)
  2605. + (match_operand:SI 2 "metag_register_op" "e,f,h,l")))]
  2606. +
  2607. + "TARGET_METAC_1_1
  2608. + && !reload_in_progress && !reload_completed"
  2609. + "#"
  2610. + "&& TRUE"
  2611. + [(const_int 0)]
  2612. + {
  2613. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  2614. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  2615. + rtx mem = gen_rtx_MEM (DImode, post_modify);
  2616. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  2617. +
  2618. + if (auto_inc_p (post_modify))
  2619. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  2620. + DONE;
  2621. + }
  2622. + [(set_attr "type" "fast")])
  2623. +
  2624. +;; -----------------------------------------------------------------------------
  2625. +
  2626. +;; -----------------------------------------------------------------------------
  2627. +;; | Recognising DI load pre-inc/dec/modify |
  2628. +;; -----------------------------------------------------------------------------
  2629. +
  2630. +(define_insn_and_split "*lod_di_pre_inc_dec_modify_disp_split"
  2631. + [(set (match_operand:DI 0 "metag_register_op" "=r")
  2632. + (mem:DI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+efhl")
  2633. + (match_operand:SI 2 "metag_offset6_di" "O8"))))
  2634. + (set (match_dup 1)
  2635. + (plus:SI (match_dup 1)
  2636. + (match_dup 2)))]
  2637. + "TARGET_METAC_1_1
  2638. + && !reload_in_progress && !reload_completed"
  2639. + "#"
  2640. + "&& TRUE"
  2641. + [(const_int 0)]
  2642. + {
  2643. + rtx pre, mem, insn;
  2644. +
  2645. + if (INTVAL (operands[2]) == GET_MODE_SIZE (DImode))
  2646. + pre = gen_rtx_PRE_INC (SImode, operands[1]);
  2647. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (DImode))
  2648. + pre = gen_rtx_PRE_DEC (SImode, operands[1]);
  2649. + else
  2650. + {
  2651. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2652. +
  2653. + pre = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2654. + }
  2655. +
  2656. + mem = gen_rtx_MEM (DImode, pre);
  2657. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  2658. +
  2659. + if (auto_inc_p (pre))
  2660. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  2661. + DONE;
  2662. + }
  2663. + [(set_attr "type" "load")])
  2664. +
  2665. +(define_insn_and_split "*lod_di_pre_modify_reg_split"
  2666. + [(set (match_operand:DI 0 "metag_register_op" "=r,r,r,r")
  2667. + (mem:DI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+e,f,h,l")
  2668. + (match_operand:SI 2 "metag_register_op" "e,f,h,l"))))
  2669. + (set (match_dup 1)
  2670. + (plus:SI (match_dup 1)
  2671. + (match_dup 2)))]
  2672. + "TARGET_METAC_1_1
  2673. + && !reload_in_progress && !reload_completed"
  2674. + "#"
  2675. + "&& TRUE"
  2676. + [(const_int 0)]
  2677. + {
  2678. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2679. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2680. + rtx mem = gen_rtx_MEM (DImode, pre_modify);
  2681. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  2682. +
  2683. + if (auto_inc_p (pre_modify))
  2684. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  2685. + DONE;
  2686. + }
  2687. + [(set_attr "type" "load")])
  2688. +
  2689. +;; -----------------------------------------------------------------------------
  2690. +
  2691. +;; -----------------------------------------------------------------------------
  2692. +;; | Recognising DI load post-inc/dec/modify |
  2693. +;; -----------------------------------------------------------------------------
  2694. +
  2695. +(define_insn_and_split "*lod_di_post_inc_dec_modify_disp_split"
  2696. + [(set (match_operand:SI 0 "metag_regnofrm_op" "+efhl")
  2697. + (plus:SI (match_dup 0)
  2698. + (match_operand:SI 1 "metag_offset6_di" "O8")))
  2699. + (set (match_operand:DI 2 "metag_register_op" "=r")
  2700. + (mem:DI (match_dup 0)))]
  2701. + "TARGET_METAC_1_1
  2702. + && !reload_in_progress && !reload_completed"
  2703. + "#"
  2704. + "&& TRUE"
  2705. + [(const_int 0)]
  2706. + {
  2707. + rtx post, mem, insn;
  2708. +
  2709. + if (INTVAL (operands[1]) == GET_MODE_SIZE (DImode))
  2710. + post = gen_rtx_PRE_INC (SImode, operands[0]);
  2711. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (DImode))
  2712. + post = gen_rtx_PRE_DEC (SImode, operands[0]);
  2713. + else
  2714. + {
  2715. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2716. +
  2717. + post = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  2718. + }
  2719. +
  2720. + mem = gen_rtx_MEM (DImode, post);
  2721. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], mem));
  2722. +
  2723. + if (auto_inc_p (post))
  2724. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  2725. + DONE;
  2726. + }
  2727. + [(set_attr "type" "load")])
  2728. +
  2729. +(define_insn_and_split "*lod_di_post_modify_reg_split"
  2730. + [(set (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l")
  2731. + (plus:SI (match_dup 0)
  2732. + (match_operand:SI 1 "metag_register_op" "e,f,h,l")))
  2733. + (set (match_operand:DI 2 "metag_register_op" "=r,r,r,r")
  2734. + (mem:DI (match_dup 0)))]
  2735. + "TARGET_METAC_1_1
  2736. + && !reload_in_progress && !reload_completed"
  2737. + "#"
  2738. + "&& TRUE"
  2739. + [(const_int 0)]
  2740. + {
  2741. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2742. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  2743. + rtx mem = gen_rtx_MEM (DImode, post_modify);
  2744. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], mem));
  2745. +
  2746. + if (auto_inc_p (post_modify))
  2747. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  2748. + DONE;
  2749. + }
  2750. + [(set_attr "type" "load")])
  2751. +
  2752. +;; -----------------------------------------------------------------------------
  2753. +
  2754. +;; -----------------------------------------------------------------------------
  2755. +;; | Recognising zero extend EXTHI load pre-inc/dec/modify |
  2756. +;; -----------------------------------------------------------------------------
  2757. +
  2758. +(define_insn_and_split "*lodz_<mode>hi_pre_inc_dec_modify_disp_split"
  2759. + [(set (match_operand:HI 0 "metag_register_op" "=r")
  2760. + (zero_extend:HI
  2761. + (mem:EXTHI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+efhl")
  2762. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>")))))
  2763. + (set (match_dup 1)
  2764. + (plus:SI (match_dup 1)
  2765. + (match_dup 2)))]
  2766. + "TARGET_METAC_1_1
  2767. + && !reload_in_progress && !reload_completed"
  2768. + "#"
  2769. + "&& TRUE"
  2770. + [(const_int 0)]
  2771. + {
  2772. + rtx pre, mem, zextend, insn;
  2773. +
  2774. + if (INTVAL (operands[2]) == GET_MODE_SIZE (<MODE>mode))
  2775. + pre = gen_rtx_PRE_INC (SImode, operands[1]);
  2776. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (<MODE>mode))
  2777. + pre = gen_rtx_PRE_DEC (SImode, operands[1]);
  2778. + else
  2779. + {
  2780. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2781. +
  2782. + pre = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2783. + }
  2784. +
  2785. + mem = gen_rtx_MEM (<MODE>mode, pre);
  2786. + zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  2787. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  2788. +
  2789. + if (auto_inc_p (pre))
  2790. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  2791. + DONE;
  2792. + }
  2793. + [(set_attr "type" "fast")])
  2794. +
  2795. +(define_insn_and_split "*lodz_<mode>hi_pre_modify_reg_split"
  2796. + [(set (match_operand:HI 0 "metag_register_op" "=r,r,r,r")
  2797. + (zero_extend:HI
  2798. + (mem:EXTHI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+e,f,h,l")
  2799. + (match_operand:SI 2 "metag_register_op" "e,f,h,l")))))
  2800. + (set (match_dup 1)
  2801. + (plus:SI (match_dup 1)
  2802. + (match_dup 2)))]
  2803. + "TARGET_METAC_1_1
  2804. + && !reload_in_progress && !reload_completed"
  2805. + "#"
  2806. + "&& TRUE"
  2807. + [(const_int 0)]
  2808. + {
  2809. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2810. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2811. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  2812. + rtx zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  2813. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  2814. +
  2815. + if (auto_inc_p (pre_modify))
  2816. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  2817. + DONE;
  2818. + }
  2819. + [(set_attr "type" "fast")])
  2820. +
  2821. +;; -----------------------------------------------------------------------------
  2822. +
  2823. +;; -----------------------------------------------------------------------------
  2824. +;; | Recognising zero extend EXTSI load pre-inc/dec/modify |
  2825. +;; -----------------------------------------------------------------------------
  2826. +
  2827. +(define_insn_and_split "*lodz_<mode>si_pre_inc_dec_modify_disp_split"
  2828. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  2829. + (zero_extend:SI
  2830. + (mem:EXTSI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+efhl")
  2831. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>")))))
  2832. + (set (match_dup 1)
  2833. + (plus:SI (match_dup 1)
  2834. + (match_dup 2)))]
  2835. + "TARGET_METAC_1_1
  2836. + && !reload_in_progress && !reload_completed"
  2837. + "#"
  2838. + "&& TRUE"
  2839. + [(const_int 0)]
  2840. + {
  2841. + rtx pre, mem, zextend, insn;
  2842. +
  2843. + if (INTVAL (operands[2]) == GET_MODE_SIZE (<MODE>mode))
  2844. + pre = gen_rtx_PRE_INC (SImode, operands[1]);
  2845. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (<MODE>mode))
  2846. + pre = gen_rtx_PRE_DEC (SImode, operands[1]);
  2847. + else
  2848. + {
  2849. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2850. +
  2851. + pre = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2852. + }
  2853. +
  2854. + mem = gen_rtx_MEM (<MODE>mode, pre);
  2855. + zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  2856. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  2857. +
  2858. + if (auto_inc_p (pre))
  2859. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  2860. + DONE;
  2861. + }
  2862. + [(set_attr "type" "fast")])
  2863. +
  2864. +(define_insn_and_split "*lodz_<mode>si_pre_modify_reg_split"
  2865. + [(set (match_operand:SI 0 "metag_register_op" "=r,r,r,r")
  2866. + (zero_extend:SI
  2867. + (mem:EXTSI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+e,f,h,l")
  2868. + (match_operand:SI 2 "metag_register_op" "e,f,h,l")))))
  2869. + (set (match_dup 1)
  2870. + (plus:SI (match_dup 1)
  2871. + (match_dup 2)))]
  2872. + "TARGET_METAC_1_1
  2873. + && !reload_in_progress && !reload_completed"
  2874. + "#"
  2875. + "&& TRUE"
  2876. + [(const_int 0)]
  2877. + {
  2878. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  2879. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  2880. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  2881. + rtx zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  2882. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  2883. +
  2884. + if (auto_inc_p (pre_modify))
  2885. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  2886. + DONE;
  2887. + }
  2888. + [(set_attr "type" "fast")])
  2889. +
  2890. +;; -----------------------------------------------------------------------------
  2891. +
  2892. +;; -----------------------------------------------------------------------------
  2893. +;; | Recognising SF store pre-inc/dec/modify |
  2894. +;; -----------------------------------------------------------------------------
  2895. +
  2896. +(define_insn_and_split "*sto_sf_pre_inc_dec_modify_disp_split"
  2897. + [(set (mem:SF
  2898. + (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+efhl")
  2899. + (match_operand:SI 1 "metag_offset6_sf" "O4")))
  2900. + (match_operand:SF 2 "metag_register_op" "r"))
  2901. + (set (match_dup 0)
  2902. + (plus:SI (match_dup 0)
  2903. + (match_dup 1)))]
  2904. + "TARGET_METAC_1_1
  2905. + && !reload_in_progress && !reload_completed"
  2906. + "#"
  2907. + "&& TRUE"
  2908. + [(const_int 0)]
  2909. + {
  2910. + rtx pre, mem, insn;
  2911. +
  2912. + if (INTVAL (operands[1]) == GET_MODE_SIZE (SFmode))
  2913. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  2914. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (SFmode))
  2915. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  2916. + else
  2917. + {
  2918. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2919. +
  2920. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  2921. + }
  2922. +
  2923. + mem = gen_rtx_MEM (SFmode, pre);
  2924. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  2925. +
  2926. + if (auto_inc_p (pre))
  2927. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  2928. + DONE;
  2929. + }
  2930. + [(set_attr "type" "fast")])
  2931. +
  2932. +(define_insn_and_split "*sto_sf_pre_modify_reg_split"
  2933. + [(set (mem:SF
  2934. + (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+%e,f,h,l")
  2935. + (match_operand:SI 1 "metag_register_op" "e,f,h,l")))
  2936. + (match_operand:SF 2 "metag_register_op" "t,u,y,z"))
  2937. + (set (match_dup 0)
  2938. + (plus:SI (match_dup 0)
  2939. + (match_dup 1)))]
  2940. + "TARGET_METAC_1_1
  2941. + && !reload_in_progress && !reload_completed"
  2942. + "#"
  2943. + "&& TRUE"
  2944. + [(const_int 0)]
  2945. + {
  2946. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  2947. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  2948. + rtx mem = gen_rtx_MEM (SFmode, pre_modify);
  2949. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  2950. +
  2951. + if (auto_inc_p (pre_modify))
  2952. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  2953. + DONE;
  2954. + }
  2955. + [(set_attr "type" "fast")])
  2956. +
  2957. +;; -----------------------------------------------------------------------------
  2958. +
  2959. +;; -----------------------------------------------------------------------------
  2960. +;; | Recognising SF store post-inc/dec/modify |
  2961. +;; -----------------------------------------------------------------------------
  2962. +
  2963. +(define_insn_and_split "*sto_sf_post_inc_dec_modify_disp_split"
  2964. + [(set (mem:SF (match_operand:SI 0 "metag_regnofrm_op" "+efhl"))
  2965. + (match_operand:SF 1 "metag_register_op" "r"))
  2966. + (set (match_dup 0)
  2967. + (plus:SI (match_dup 0)
  2968. + (match_operand:SI 2 "metag_offset6_sf" "O4")))]
  2969. + "TARGET_METAC_1_1
  2970. + && !reload_in_progress && !reload_completed"
  2971. + "#"
  2972. + "&& TRUE"
  2973. + [(const_int 0)]
  2974. + {
  2975. + rtx post, mem, insn;
  2976. +
  2977. + if (INTVAL (operands[2]) == GET_MODE_SIZE (SFmode))
  2978. + post = gen_rtx_POST_INC (SImode, operands[0]);
  2979. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (SFmode))
  2980. + post = gen_rtx_POST_DEC (SImode, operands[0]);
  2981. + else
  2982. + {
  2983. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  2984. +
  2985. + post = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  2986. + }
  2987. +
  2988. + mem = gen_rtx_MEM (SFmode, post);
  2989. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  2990. +
  2991. + if (auto_inc_p (post))
  2992. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  2993. + DONE;
  2994. + }
  2995. + [(set_attr "type" "fast")])
  2996. +
  2997. +(define_insn_and_split "*sto_sf_post_modify_reg_split"
  2998. + [(set (mem:SF (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l"))
  2999. + (match_operand:SF 1 "metag_register_op" "t,u,y,z"))
  3000. + (set (match_dup 0)
  3001. + (plus:SI (match_dup 0)
  3002. + (match_operand:SI 2 "metag_register_op" "e,f,h,l")))]
  3003. + "TARGET_METAC_1_1
  3004. + && !reload_in_progress && !reload_completed"
  3005. + "#"
  3006. + "&& TRUE"
  3007. + [(const_int 0)]
  3008. + {
  3009. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  3010. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  3011. + rtx mem = gen_rtx_MEM (SFmode, post_modify);
  3012. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  3013. +
  3014. + if (auto_inc_p (post_modify))
  3015. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  3016. + DONE;
  3017. + }
  3018. + [(set_attr "type" "fast")])
  3019. +
  3020. +;; -----------------------------------------------------------------------------
  3021. +
  3022. +;; -----------------------------------------------------------------------------
  3023. +;; | Recognising SF load pre-inc/dec/modify |
  3024. +;; -----------------------------------------------------------------------------
  3025. +
  3026. +(define_insn_and_split "*lod_sf_pre_inc_dec_modify_disp_split"
  3027. + [(set (match_operand:SF 0 "metag_register_op" "=r")
  3028. + (mem:SF (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+efhl")
  3029. + (match_operand:SI 2 "metag_offset6_sf" "O4"))))
  3030. + (set (match_dup 1)
  3031. + (plus:SI (match_dup 1)
  3032. + (match_dup 2)))]
  3033. + "TARGET_METAC_1_1
  3034. + && !reload_in_progress && !reload_completed"
  3035. + "#"
  3036. + "&& TRUE"
  3037. + [(const_int 0)]
  3038. + {
  3039. + rtx pre, mem, insn;
  3040. +
  3041. + if (INTVAL (operands[2]) == GET_MODE_SIZE (SFmode))
  3042. + pre = gen_rtx_PRE_INC (SImode, operands[1]);
  3043. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (SFmode))
  3044. + pre = gen_rtx_PRE_DEC (SImode, operands[1]);
  3045. + else
  3046. + {
  3047. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  3048. +
  3049. + pre = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  3050. + }
  3051. +
  3052. + mem = gen_rtx_MEM (SFmode, pre);
  3053. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  3054. +
  3055. + if (auto_inc_p (pre))
  3056. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  3057. + DONE;
  3058. + }
  3059. + [(set_attr "type" "fast")])
  3060. +
  3061. +(define_insn_and_split "*lod_sf_pre_modify_reg_split"
  3062. + [(set (match_operand:SF 0 "metag_register_op" "=r,r,r,r")
  3063. + (mem:SF (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+e,f,h,l")
  3064. + (match_operand:SI 2 "metag_register_op" "e,f,h,l"))))
  3065. + (set (match_dup 1)
  3066. + (plus:SI (match_dup 1)
  3067. + (match_dup 2)))]
  3068. + "TARGET_METAC_1_1
  3069. + && !reload_in_progress && !reload_completed"
  3070. + "#"
  3071. + "&& TRUE"
  3072. + [(const_int 0)]
  3073. + {
  3074. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  3075. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  3076. + rtx mem = gen_rtx_MEM (SFmode, pre_modify);
  3077. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  3078. +
  3079. + if (auto_inc_p (pre_modify))
  3080. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  3081. + DONE;
  3082. + }
  3083. + [(set_attr "type" "fast")])
  3084. +
  3085. +;; -----------------------------------------------------------------------------
  3086. +;; | Recognising DF load pre-inc/dec/modify |
  3087. +;; -----------------------------------------------------------------------------
  3088. +
  3089. +(define_insn_and_split "*lod_df_pre_inc_dec_modify_disp_split"
  3090. + [(set (match_operand:DF 0 "metag_register_op" "=r")
  3091. + (mem:DF (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+efhl")
  3092. + (match_operand:SI 2 "metag_offset6_df" "O8"))))
  3093. + (set (match_dup 1)
  3094. + (plus:SI (match_dup 1)
  3095. + (match_dup 2)))]
  3096. + "TARGET_METAC_1_1
  3097. + && !reload_in_progress && !reload_completed"
  3098. + "#"
  3099. + "&& TRUE"
  3100. + [(const_int 0)]
  3101. + {
  3102. + rtx pre, mem, insn;
  3103. +
  3104. + if (INTVAL (operands[2]) == GET_MODE_SIZE (DFmode))
  3105. + pre = gen_rtx_PRE_INC (SImode, operands[1]);
  3106. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (DFmode))
  3107. + pre = gen_rtx_PRE_DEC (SImode, operands[1]);
  3108. + else
  3109. + {
  3110. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  3111. +
  3112. + pre = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  3113. + }
  3114. +
  3115. + mem = gen_rtx_MEM (DFmode, pre);
  3116. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  3117. +
  3118. + if (auto_inc_p (pre))
  3119. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  3120. + DONE;
  3121. + }
  3122. + [(set_attr "type" "load")])
  3123. +
  3124. +(define_insn_and_split "*lod_df_pre_modify_reg_split"
  3125. + [(set (match_operand:DF 0 "metag_register_op" "=r,r,r,r")
  3126. + (mem:DF (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "+e,f,h,l")
  3127. + (match_operand:SI 2 "metag_register_op" "e,f,h,l"))))
  3128. + (set (match_dup 1)
  3129. + (plus:SI (match_dup 1)
  3130. + (match_dup 2)))]
  3131. + "TARGET_METAC_1_1
  3132. + && !reload_in_progress && !reload_completed"
  3133. + "#"
  3134. + "&& TRUE"
  3135. + [(const_int 0)]
  3136. + {
  3137. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  3138. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[1], plus);
  3139. + rtx mem = gen_rtx_MEM (DFmode, pre_modify);
  3140. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  3141. +
  3142. + if (auto_inc_p (pre_modify))
  3143. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  3144. + DONE;
  3145. + }
  3146. + [(set_attr "type" "load")])
  3147. +
  3148. +;; -----------------------------------------------------------------------------
  3149. +
  3150. +;; -----------------------------------------------------------------------------
  3151. +;; | Recognising DF load post-inc/dec/modify |
  3152. +;; -----------------------------------------------------------------------------
  3153. +
  3154. +(define_insn_and_split "*lod_df_post_inc_dec_modify_disp_split"
  3155. + [(set (match_operand:SI 0 "metag_regnofrm_op" "+efhl")
  3156. + (plus:SI (match_dup 0)
  3157. + (match_operand:SI 1 "metag_offset6_df" "O8")))
  3158. + (set (match_operand:DF 2 "metag_register_op" "=r")
  3159. + (mem:DF (match_dup 0)))]
  3160. + "TARGET_METAC_1_1
  3161. + && !reload_in_progress && !reload_completed"
  3162. + "#"
  3163. + "&& TRUE"
  3164. + [(const_int 0)]
  3165. + {
  3166. + rtx post, mem, insn;
  3167. +
  3168. + if (INTVAL (operands[1]) == GET_MODE_SIZE (DFmode))
  3169. + post = gen_rtx_PRE_INC (SImode, operands[0]);
  3170. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (DFmode))
  3171. + post = gen_rtx_PRE_DEC (SImode, operands[0]);
  3172. + else
  3173. + {
  3174. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  3175. +
  3176. + post = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  3177. + }
  3178. +
  3179. + mem = gen_rtx_MEM (DFmode, post);
  3180. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], mem));
  3181. +
  3182. + if (auto_inc_p (post))
  3183. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  3184. + DONE;
  3185. + }
  3186. + [(set_attr "type" "load")])
  3187. +
  3188. +(define_insn_and_split "*lod_df_post_modify_reg_split"
  3189. + [(set (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l")
  3190. + (plus:SI (match_dup 0)
  3191. + (match_operand:SI 1 "metag_register_op" "e,f,h,l")))
  3192. + (set (match_operand:DF 2 "metag_register_op" "=r,r,r,r")
  3193. + (mem:DF (match_dup 0)))]
  3194. + "TARGET_METAC_1_1
  3195. + && !reload_in_progress && !reload_completed"
  3196. + "#"
  3197. + "&& TRUE"
  3198. + [(const_int 0)]
  3199. + {
  3200. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  3201. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  3202. + rtx mem = gen_rtx_MEM (DFmode, post_modify);
  3203. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], mem));
  3204. +
  3205. + if (auto_inc_p (post_modify))
  3206. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  3207. + DONE;
  3208. + }
  3209. + [(set_attr "type" "load")])
  3210. +
  3211. +;; -----------------------------------------------------------------------------
  3212. +
  3213. +;; -----------------------------------------------------------------------------
  3214. +;; | Recognising DF store pre-inc/dec/modify |
  3215. +;; -----------------------------------------------------------------------------
  3216. +
  3217. +(define_insn_and_split "*sto_df_pre_inc_dec_modify_disp_split"
  3218. + [(set (mem:DF (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+efhl")
  3219. + (match_operand:SI 1 "metag_offset6_df" "O8")))
  3220. + (match_operand:DF 2 "metag_register_op" "r"))
  3221. + (set (match_dup 0)
  3222. + (plus:SI (match_dup 0)
  3223. + (match_dup 1)))]
  3224. + "TARGET_METAC_1_1
  3225. + && !reload_in_progress && !reload_completed"
  3226. + "#"
  3227. + "&& TRUE"
  3228. + [(const_int 0)]
  3229. + {
  3230. + rtx pre, mem, insn;
  3231. +
  3232. + if (INTVAL (operands[1]) == GET_MODE_SIZE (DFmode))
  3233. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  3234. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (DFmode))
  3235. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  3236. + else
  3237. + {
  3238. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  3239. +
  3240. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  3241. + }
  3242. +
  3243. + mem = gen_rtx_MEM (DFmode, pre);
  3244. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  3245. +
  3246. + if (auto_inc_p (pre))
  3247. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  3248. + DONE;
  3249. + }
  3250. + [(set_attr "type" "fast")])
  3251. +
  3252. +(define_insn_and_split "*sto_df_pre_modify_reg_split"
  3253. + [(set (mem:DF (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l")
  3254. + (match_operand:SI 1 "metag_register_op" "e,f,h,l")))
  3255. + (match_operand:DF 2 "metag_register_op" "a,a,d,d"))
  3256. + (set (match_dup 0)
  3257. + (plus:SI (match_dup 0)
  3258. + (match_dup 1)))]
  3259. + "TARGET_METAC_1_1
  3260. + && !reload_in_progress && !reload_completed"
  3261. + "#"
  3262. + "&& TRUE"
  3263. + [(const_int 0)]
  3264. + {
  3265. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  3266. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  3267. + rtx mem = gen_rtx_MEM (DFmode, pre_modify);
  3268. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[2]));
  3269. +
  3270. + if (auto_inc_p (pre_modify))
  3271. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  3272. + DONE;
  3273. + }
  3274. + [(set_attr "type" "fast")])
  3275. +
  3276. +;; -----------------------------------------------------------------------------
  3277. +;; | Recognising DF store post-inc/dec/modify |
  3278. +;; -----------------------------------------------------------------------------
  3279. +
  3280. +(define_insn_and_split "*sto_df_post_inc_dec_modify_disp_split"
  3281. + [(set (mem:DF (match_operand:SI 0 "metag_regnofrm_op" "+efhl"))
  3282. + (match_operand:DF 1 "metag_register_op" "r"))
  3283. + (set (match_dup 0)
  3284. + (plus:SI (match_dup 0)
  3285. + (match_operand:SI 2 "metag_offset6_df" "O8")))]
  3286. + "TARGET_METAC_1_1
  3287. + && !reload_in_progress && !reload_completed"
  3288. + "#"
  3289. + "&& TRUE"
  3290. + [(const_int 0)]
  3291. + {
  3292. + rtx post, mem, insn;
  3293. +
  3294. + if (INTVAL (operands[2]) == GET_MODE_SIZE (DFmode))
  3295. + post = gen_rtx_POST_INC (SImode, operands[0]);
  3296. + else if (INTVAL (operands[2]) == -GET_MODE_SIZE (DFmode))
  3297. + post = gen_rtx_POST_DEC (SImode, operands[0]);
  3298. + else
  3299. + {
  3300. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  3301. +
  3302. + post = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  3303. + }
  3304. +
  3305. + mem = gen_rtx_MEM (DFmode, post);
  3306. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  3307. +
  3308. + if (auto_inc_p (post))
  3309. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  3310. + DONE;
  3311. + }
  3312. + [(set_attr "type" "fast")])
  3313. +
  3314. +(define_insn_and_split "*sto_df_post_modify_reg_split"
  3315. + [(set (mem:DF (match_operand:SI 0 "metag_regnofrm_op" "+e,f,h,l"))
  3316. + (match_operand:DF 1 "metag_register_op" "a,a,d,d"))
  3317. + (set (match_dup 0)
  3318. + (plus:SI (match_dup 0)
  3319. + (match_operand:SI 2 "metag_register_op" "e,f,h,l")))]
  3320. +
  3321. + "TARGET_METAC_1_1
  3322. + && !reload_in_progress && !reload_completed"
  3323. + "#"
  3324. + "&& TRUE"
  3325. + [(const_int 0)]
  3326. + {
  3327. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[2]);
  3328. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[0], plus);
  3329. + rtx mem = gen_rtx_MEM (DFmode, post_modify);
  3330. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  3331. +
  3332. + if (auto_inc_p (post_modify))
  3333. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  3334. + DONE;
  3335. + }
  3336. + [(set_attr "type" "fast")])
  3337. diff -Nur gcc-4.2.4.orig/gcc/config/metag/constants.md gcc-4.2.4/gcc/config/metag/constants.md
  3338. --- gcc-4.2.4.orig/gcc/config/metag/constants.md 1969-12-31 18:00:00.000000000 -0600
  3339. +++ gcc-4.2.4/gcc/config/metag/constants.md 2015-07-03 18:46:05.745283542 -0500
  3340. @@ -0,0 +1,179 @@
  3341. +;; Constants definitions for META
  3342. +;; Copyright (C) 2007 Imagination Technologies Ltd
  3343. +
  3344. +;; This file is part of GCC.
  3345. +
  3346. +;; GCC is free software; you can redistribute it and/or modify it under
  3347. +;; the terms of the GNU General Public License as published by the Free
  3348. +;; Software Foundation; either version 3, or (at your option) any later
  3349. +;; version.
  3350. +
  3351. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  3352. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  3353. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  3354. +;; for more details.
  3355. +
  3356. +;; You should have received a copy of the GNU General Public License
  3357. +;; along with GCC; see the file COPYING3. If not see
  3358. +;; <http://www.gnu.org/licenses/>.
  3359. +
  3360. +;; UNSPEC
  3361. +(define_constants
  3362. + [(UNSPEC_GOTOFF 1)
  3363. + (UNSPEC_GOT 2)
  3364. + (UNSPEC_PLT 3)
  3365. + (UNSPEC_PIC 4)
  3366. + (UNSPEC_PIC_BASE 5)
  3367. +
  3368. + (UNSPEC_PROLOGUE_USE 6)
  3369. + (UNSPEC_CONCAT 7)
  3370. + (UNSPEC_SIBCALL 8)
  3371. + (UNSPEC_SIBCALL_VALUE 9)
  3372. +
  3373. + (UNSPEC_RET_COND 10)
  3374. + (UNSPEC_RET_COND_INVERTED 11)
  3375. +
  3376. + (UNSPEC_METAG_BSWAP 12)
  3377. + (UNSPEC_METAG_BSWAPLL 13)
  3378. +
  3379. + (UNSPEC_MINIM_JUMP_TABLE 14)
  3380. +
  3381. + (UNSPEC_FIRST_TLS 15)
  3382. + (UNSPEC_TLS 15)
  3383. + (UNSPEC_TLSGD 16)
  3384. + (UNSPEC_TLSLDM 17)
  3385. + (UNSPEC_TLSLDO 18)
  3386. + (UNSPEC_TLSIE 19)
  3387. + (UNSPEC_TLSLE 20)
  3388. + (UNSPEC_LAST_TLS 20)])
  3389. +
  3390. +
  3391. +;; UNSPEC VOLATILE
  3392. +(define_constants
  3393. + [(VUNSPEC_DCACHE_PRELOAD 1)
  3394. + (VUNSPEC_DCACHE 2)
  3395. + (VUNSPEC_DCACHE_REFRESH 3)
  3396. + (VUNSPEC_BLOCKAGE 4)
  3397. + (VUNSPEC_EPILOGUE 5)
  3398. + (VUNSPEC_EH_RETURN 6)
  3399. + (VUNSPEC_META2_CACHERD 7)
  3400. + (VUNSPEC_META2_CACHERL 8)
  3401. + (VUNSPEC_META2_CACHEWD 9)
  3402. + (VUNSPEC_META2_CACHEWL 10)
  3403. + (VUNSPEC_TTMOV 11)
  3404. + (VUNSPEC_TTREC 12)])
  3405. +
  3406. +
  3407. +;; Register
  3408. +(define_constants
  3409. + [(D0Ar6_REG 2)
  3410. + (D1Ar5_REG 3)
  3411. + (D0Ar4_REG 4)
  3412. + (D1Ar3_REG 5)
  3413. + (D0Ar2_REG 6)
  3414. + (D1Ar1_REG 7)
  3415. +
  3416. + (D0Re0_REG 0)
  3417. + (D1Re0_REG 1)
  3418. + (D0FrT_REG 8)
  3419. + (D1RtP_REG 9)
  3420. +
  3421. + (FIRST_DATA_REG 0)
  3422. + (D0_0_REG 0)
  3423. + (D1_0_REG 1)
  3424. + (D0_1_REG 2)
  3425. + (D1_1_REG 3)
  3426. + (D0_2_REG 4)
  3427. + (D1_2_REG 5)
  3428. + (D0_3_REG 6)
  3429. + (D1_3_REG 7)
  3430. + (D0_4_REG 8)
  3431. + (D1_4_REG 9)
  3432. + (D0_5_REG 10)
  3433. + (D1_5_REG 11)
  3434. + (D0_6_REG 12)
  3435. + (D1_6_REG 13)
  3436. + (D0_7_REG 14)
  3437. + (D1_7_REG 15)
  3438. + (FIRST_ECH_DATA_REG 16)
  3439. + (D0_8_REG 16)
  3440. + (D1_8_REG 17)
  3441. + (D0_9_REG 18)
  3442. + (D1_9_REG 19)
  3443. + (D0_10_REG 20)
  3444. + (D1_10_REG 21)
  3445. + (D0_11_REG 22)
  3446. + (D1_11_REG 23)
  3447. + (D0_12_REG 24)
  3448. + (D1_12_REG 25)
  3449. + (D0_13_REG 26)
  3450. + (D1_13_REG 27)
  3451. + (D0_14_REG 28)
  3452. + (D1_14_REG 29)
  3453. + (D0_15_REG 30)
  3454. + (D1_15_REG 31)
  3455. + (LAST_DATA_REG 31)
  3456. +
  3457. + (A0StP_REG 32)
  3458. + (A1GbP_REG 33)
  3459. + (A0FrP_REG 34)
  3460. + (A1LbP_REG 35)
  3461. +
  3462. + (PIC_REG 35)
  3463. +
  3464. + (FIRST_ADDR_REG 32)
  3465. + (A0_0_REG 32)
  3466. + (A1_0_REG 33)
  3467. + (A0_1_REG 34)
  3468. + (A1_1_REG 35)
  3469. + (A0_2_REG 36)
  3470. + (A1_2_REG 37)
  3471. + (A0_3_REG 38)
  3472. + (A1_3_REG 39)
  3473. + (FIRST_ECH_ADDR_REG 40)
  3474. + (A0_4_REG 40)
  3475. + (A1_4_REG 41)
  3476. + (A0_5_REG 42)
  3477. + (A1_5_REG 43)
  3478. + (A0_6_REG 44)
  3479. + (A1_6_REG 45)
  3480. + (A0_7_REG 46)
  3481. + (A1_7_REG 47)
  3482. + (LAST_ADDR_REG 47)
  3483. +
  3484. + (FRAME_REG 48)
  3485. + (CC_REG 49)
  3486. + (ARGP_REG 50)
  3487. + (RAPF_REG 51)
  3488. + (CPC0_REG 52)
  3489. + (CPC1_REG 53)
  3490. + (PC_REG 54)
  3491. + (TXRPT_REG 55)
  3492. +
  3493. + (FIRST_FP_REG 56)
  3494. + (FX_0_REG 56)
  3495. + (FX_1_REG 57)
  3496. + (FX_2_REG 58)
  3497. + (FX_3_REG 59)
  3498. + (FX_4_REG 60)
  3499. + (FX_5_REG 61)
  3500. + (FX_6_REG 62)
  3501. + (FX_7_REG 63)
  3502. + (FX_8_REG 64)
  3503. + (FX_9_REG 65)
  3504. + (FX_10_REG 66)
  3505. + (FX_11_REG 67)
  3506. + (FX_12_REG 68)
  3507. + (FX_13_REG 69)
  3508. + (FX_14_REG 70)
  3509. + (FX_15_REG 71)
  3510. + (LAST_FP_REG 71)
  3511. + (TTREC_REG 72)
  3512. + (TTRECL_REG 73)
  3513. + (LAST_REG 73)])
  3514. +
  3515. +;; Exception handling - dwarf2 call frame unwinder
  3516. +(define_constants
  3517. + [(EH_RETURN_FIRST_DATA_REG 2)
  3518. + (EH_RETURN_LAST_DATA_REG 3)
  3519. + (EH_RETURN_STACKADJ_REG 4)])
  3520. diff -Nur gcc-4.2.4.orig/gcc/config/metag/constraints.md gcc-4.2.4/gcc/config/metag/constraints.md
  3521. --- gcc-4.2.4.orig/gcc/config/metag/constraints.md 1969-12-31 18:00:00.000000000 -0600
  3522. +++ gcc-4.2.4/gcc/config/metag/constraints.md 2015-07-03 18:46:05.745283542 -0500
  3523. @@ -0,0 +1,319 @@
  3524. +;; Constraint definitions for META.
  3525. +;; Copyright (C) 2007, 2010 Imagination Technologies Ltd
  3526. +
  3527. +;; This file is part of GCC.
  3528. +
  3529. +;; GCC is free software; you can redistribute it and/or modify it under
  3530. +;; the terms of the GNU General Public License as published by the Free
  3531. +;; Software Foundation; either version 3, or (at your option) any later
  3532. +;; version.
  3533. +
  3534. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  3535. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  3536. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  3537. +;; for more details.
  3538. +
  3539. +;; You should have received a copy of the GNU General Public License
  3540. +;; along with GCC; see the file COPYING3. If not see
  3541. +;; <http://www.gnu.org/licenses/>.
  3542. +
  3543. +;; Register constraints
  3544. +
  3545. +(define_register_constraint "d" "D_REGS"
  3546. + "data unit register")
  3547. +
  3548. +(define_register_constraint "e" "D0_REGS"
  3549. + "data unit 0 register")
  3550. +
  3551. +(define_register_constraint "f" "D1_REGS"
  3552. + "data unit 1 register")
  3553. +
  3554. +(define_register_constraint "a" "A_REGS"
  3555. + "address unit register")
  3556. +
  3557. +(define_register_constraint "h" "A0_REGS"
  3558. + "address unit 0 register")
  3559. +
  3560. +(define_register_constraint "l" "A1_REGS"
  3561. + "address unit 1 register")
  3562. +
  3563. +(define_register_constraint "be" "Be_REGS"
  3564. + "O2R register data unit 0")
  3565. +
  3566. +(define_register_constraint "bf" "Bf_REGS"
  3567. + "O2R register data unit 1")
  3568. +
  3569. +(define_register_constraint "bd" "Bd_REGS"
  3570. + "O2R register data unit")
  3571. +
  3572. +(define_register_constraint "bh" "Bh_REGS"
  3573. + "O2R register address unit 0")
  3574. +
  3575. +(define_register_constraint "bl" "Bl_REGS"
  3576. + "O2R register address unit 1")
  3577. +
  3578. +(define_register_constraint "ba" "Ba_REGS"
  3579. + "O2R register address unit")
  3580. +
  3581. +(define_register_constraint "br" "Br_REGS"
  3582. + "O2R register any unit")
  3583. +
  3584. +(define_register_constraint "t" "nD0_REGS"
  3585. + "data unit 1, addr unit 0, addr unit 1 register")
  3586. +
  3587. +(define_register_constraint "u" "nD1_REGS"
  3588. + "data unit 0, addr unit 0, addr unit 1 register")
  3589. +
  3590. +(define_register_constraint "y" "nA0_REGS"
  3591. + "data unit 0, data unit 1, addr unit 1 register")
  3592. +
  3593. +(define_register_constraint "z" "nA1_REGS"
  3594. + "data unit 0, addr unit 1, addr unit 0 register")
  3595. +
  3596. +(define_register_constraint "q" "nBU_REGS"
  3597. + "not base unit register")
  3598. +
  3599. +(define_register_constraint "Wx" "Wx_REGS"
  3600. + "control register i.e. TXRPT")
  3601. +
  3602. +(define_register_constraint "WQh" "WQh_REGS"
  3603. + "A0 QuickRoT control registers A0.2 A0.3")
  3604. +
  3605. +(define_register_constraint "WQl" "WQl_REGS"
  3606. + "A1 QuickRoT control registers A1.2 A1.3")
  3607. +
  3608. +(define_register_constraint "Ye" "Ye_REGS"
  3609. + "data unit 0 register 12-bit offsetable")
  3610. +
  3611. +(define_register_constraint "Yf" "Yf_REGS"
  3612. + "data unit 1 register 12-bit offsetable")
  3613. +
  3614. +(define_register_constraint "Yd" "Yd_REGS"
  3615. + "data unit register 12-bit offsetable")
  3616. +
  3617. +(define_register_constraint "Yh" "Yh_REGS"
  3618. + "addr unit 0 register 12-bit offsetable")
  3619. +
  3620. +(define_register_constraint "Yl" "Yl_REGS"
  3621. + "addr unit 1 register 12-bit offsetable")
  3622. +
  3623. +(define_register_constraint "Ya" "Ya_REGS"
  3624. + "addr unit register 12-bit offsetable")
  3625. +
  3626. +(define_register_constraint "Yr" "Yr_REGS"
  3627. + "data/addr register 12-bit offsetable")
  3628. +
  3629. +(define_register_constraint "Yne" "nYe_REGS"
  3630. + "...")
  3631. +
  3632. +(define_register_constraint "Ynf" "nYf_REGS"
  3633. + "...")
  3634. +
  3635. +(define_register_constraint "Ynd" "nYd_REGS"
  3636. + "...")
  3637. +
  3638. +(define_register_constraint "Ynh" "nYh_REGS"
  3639. + "...")
  3640. +
  3641. +(define_register_constraint "Ynl" "nYl_REGS"
  3642. + "...")
  3643. +
  3644. +(define_register_constraint "Yna" "nYa_REGS"
  3645. + "...")
  3646. +
  3647. +(define_register_constraint "Ynr" "nYr_REGS"
  3648. + "...")
  3649. +
  3650. +(define_register_constraint "ce" "metag_fpu_resources ? cD0_REGS : D0_REGS"
  3651. + "data 0 or float unit register")
  3652. +
  3653. +(define_register_constraint "cf" "metag_fpu_resources ? cD1_REGS : D1_REGS"
  3654. + "data 1, or float unit register")
  3655. +
  3656. +(define_register_constraint "cd" "metag_fpu_resources ? cD_REGS : D_REGS"
  3657. + "data, or float unit register")
  3658. +
  3659. +(define_register_constraint "ch" "metag_fpu_resources ? cA0_REGS : A0_REGS"
  3660. + "addr 0 or float unit register")
  3661. +
  3662. +(define_register_constraint "cl" "metag_fpu_resources ? cA1_REGS : A1_REGS"
  3663. + "addr 1 or float unit register")
  3664. +
  3665. +(define_register_constraint "ca" "metag_fpu_resources ? cA_REGS : A_REGS"
  3666. + "addr or float unit register")
  3667. +
  3668. +(define_register_constraint "cr" "metag_fpu_resources ? cDA_REGS : DA_REGS"
  3669. + "data, addr or float unit register")
  3670. +
  3671. +(define_register_constraint "ct" "metag_fpu_resources ? cnD0_REGS : nD0_REGS"
  3672. + "data unit 1, addr unit 0, addr unit 1 or float unit register")
  3673. +
  3674. +(define_register_constraint "cu" "metag_fpu_resources ? cnD1_REGS : nD1_REGS"
  3675. + "data unit 0, addr unit 0, addr unit 1 or float unit register")
  3676. +
  3677. +(define_register_constraint "cy" "metag_fpu_resources ? cnA0_REGS : nA0_REGS"
  3678. + "data unit 0, data unit 0, addr unit 1 or float unit register")
  3679. +
  3680. +(define_register_constraint "cz" "metag_fpu_resources ? cnA1_REGS : nA1_REGS"
  3681. + "data unit 0, data unit 1, addr unit 0 or float unit register")
  3682. +
  3683. +(define_register_constraint "cx" "metag_fpu_resources ? FPC_REGS : NO_REGS"
  3684. + "floating point register")
  3685. +
  3686. +(define_register_constraint "cp" "metag_fpu_resources ? FPP_REGS : NO_REGS"
  3687. + "floating point register pair")
  3688. +
  3689. +;; Integer constraints
  3690. +
  3691. +(define_constraint "I"
  3692. + "...."
  3693. + (and (match_code "const_int")
  3694. + (match_test "(ival >= -32768 && ival <= -256) || (ival >= 256 && ival <= 65535)")))
  3695. +
  3696. +(define_constraint "J"
  3697. + "...."
  3698. + (and (match_code "const_int")
  3699. + (match_test "(ival & 0x0000FFFF) == 0")))
  3700. +
  3701. +(define_constraint "O0"
  3702. + "...."
  3703. + (and (match_code "const_int")
  3704. + (match_test "(ival & 0xFFFF) == 0")))
  3705. +
  3706. +(define_constraint "O3"
  3707. + "...."
  3708. + (and (match_code "const_int")
  3709. + (match_test "((ival >> 16) & 0x0000FFFF) == 0")))
  3710. +
  3711. +(define_constraint "K"
  3712. + "..."
  3713. + (and (match_code "const_int")
  3714. + (match_test "0 <= ival && ival <= 255")))
  3715. +
  3716. +(define_constraint "L"
  3717. + "..."
  3718. + (and (match_code "const_int")
  3719. + (match_test "0 <= ival && ival <= 31")))
  3720. +
  3721. +(define_constraint "M"
  3722. + "..."
  3723. + (and (match_code "const_int")
  3724. + (match_test "((ival >> 16) & 0xFFFF) == 0x0000FFFF")))
  3725. +
  3726. +(define_constraint "N"
  3727. + "..."
  3728. + (and (match_code "const_int")
  3729. + (match_test "((ival & 0x0000FFFF) == 0x0000FFFF)")))
  3730. +
  3731. +(define_constraint "O1"
  3732. + "..."
  3733. + (and (match_code "const_int")
  3734. + (match_test "-32 <= ival && ival < 32")))
  3735. +
  3736. +(define_constraint "O2"
  3737. + "..."
  3738. + (and (match_code "const_int")
  3739. + (match_test "(-64 <= ival && ival < 64) && (ival & 1) == 0")))
  3740. +
  3741. +(define_constraint "O4"
  3742. + "..."
  3743. + (and (match_code "const_int")
  3744. + (match_test "(-128 <= ival && ival < 128) && (ival & 3) == 0")))
  3745. +
  3746. +(define_constraint "O8"
  3747. + "..."
  3748. + (and (match_code "const_int")
  3749. + (match_test "(-256 <= ival && ival < 256) && (ival & 7) == 0")))
  3750. +
  3751. +(define_constraint "P"
  3752. + "..."
  3753. + (and (match_code "const_int")
  3754. + (match_test "-255 <= ival && ival < 0")))
  3755. +
  3756. +(define_constraint "vci"
  3757. + "..."
  3758. + (and (match_code "const_vector")
  3759. + (match_test "GET_MODE_INNER (mode) == SImode")))
  3760. +
  3761. +(define_constraint "vcf"
  3762. + "..."
  3763. + (and (match_code "const_vector")
  3764. + (match_test "GET_MODE_INNER (mode) == SFmode")))
  3765. +
  3766. +(define_constraint "vc5"
  3767. + "..."
  3768. + (and (match_code "const_vector")
  3769. + (match_test "metag_vector_5bit_op (op, mode)")))
  3770. +
  3771. +(define_constraint "v16"
  3772. + "..."
  3773. + (and (match_code "const_vector")
  3774. + (match_test "metag_vector_16bit_op (op, mode)")))
  3775. +
  3776. +;; Floating-point constraints
  3777. +
  3778. +(define_constraint "G"
  3779. + "Floating-point zero."
  3780. + (and (match_code "const_double")
  3781. + (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT && op == CONST0_RTX (mode)")))
  3782. +
  3783. +(define_constraint "H"
  3784. + "Floating-point one."
  3785. + (and (match_code "const_double")
  3786. + (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT && op == CONST1_RTX (mode)")))
  3787. +
  3788. +(define_constraint "ci"
  3789. + "Floating-point immediates in half precision"
  3790. + (and (match_code "const_double")
  3791. + (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT && metag_fphalf_imm_op (op, mode)")))
  3792. +
  3793. +;; General constraints
  3794. +
  3795. +(define_constraint "Th"
  3796. + "@internal"
  3797. + (and (match_test "metag_mem_base_p (op, A0_REGS)")
  3798. + (match_test "metag_legitimate_address_p (XEXP (op, 0), GET_MODE (op), true)")))
  3799. +
  3800. +(define_constraint "Tl"
  3801. + "@internal"
  3802. + (and (match_test "metag_mem_base_p (op, A1_REGS)")
  3803. + (match_test "metag_legitimate_address_p (XEXP (op, 0), GET_MODE (op), true)")))
  3804. +
  3805. +(define_constraint "Te"
  3806. + "@internal"
  3807. + (and (match_test "metag_mem_base_p (op, D0_REGS)")
  3808. + (match_test "metag_legitimate_address_p (XEXP (op, 0), GET_MODE (op), true)")))
  3809. +
  3810. +(define_constraint "Tf"
  3811. + "@internal"
  3812. + (and (match_test "metag_mem_base_p (op, D1_REGS)")
  3813. + (match_test "metag_legitimate_address_p (XEXP (op, 0), GET_MODE (op), true)")))
  3814. +
  3815. +(define_constraint "Tr"
  3816. + "@internal"
  3817. + (and (match_test "metag_legitimate_address_p (XEXP (op, 0), GET_MODE (op), true)")
  3818. + (not (match_test "GET_CODE (XEXP (op, 0)) == PLUS
  3819. + && metag_regs_ok_for_base_offset_p (XEXP (XEXP (op, 0), 0),
  3820. + XEXP (XEXP (op, 0), 1),
  3821. + true)"))))
  3822. +
  3823. +(define_constraint "Z1"
  3824. + "..."
  3825. + (and (match_code "const_int")
  3826. + (match_test "-2048 <= ival && ival < 2048")))
  3827. +
  3828. +(define_constraint "Z2"
  3829. + "..."
  3830. + (and (match_code "const_int")
  3831. + (match_test "-4096 <= ival && ival < 4096 && (ival & 1) == 0")))
  3832. +
  3833. +(define_constraint "Z4"
  3834. + "..."
  3835. + (and (match_code "const_int")
  3836. + (match_test "-8192 <= ival && ival < 8192 && (ival & 3) == 0")))
  3837. +
  3838. +(define_constraint "Z8"
  3839. + "..."
  3840. + (and (match_code "const_int")
  3841. + (match_test "-16384 <= ival && ival < 16384 && (ival & 7) == 0")))
  3842. +
  3843. diff -Nur gcc-4.2.4.orig/gcc/config/metag/driver-metag.c gcc-4.2.4/gcc/config/metag/driver-metag.c
  3844. --- gcc-4.2.4.orig/gcc/config/metag/driver-metag.c 1969-12-31 18:00:00.000000000 -0600
  3845. +++ gcc-4.2.4/gcc/config/metag/driver-metag.c 2015-07-03 18:46:05.745283542 -0500
  3846. @@ -0,0 +1,276 @@
  3847. +/* Subroutines for the gcc driver.
  3848. + Copyright (C) 2008 Imagination Technologies Ltd
  3849. +
  3850. +This file is part of GCC.
  3851. +
  3852. +GCC is free software; you can redistribute it and/or modify
  3853. +it under the terms of the GNU General Public License as published by
  3854. +the Free Software Foundation; either version 3, or (at your option)
  3855. +any later version.
  3856. +
  3857. +GCC is distributed in the hope that it will be useful,
  3858. +but WITHOUT ANY WARRANTY; without even the implied warranty of
  3859. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3860. +GNU General Public License for more details.
  3861. +
  3862. +You should have received a copy of the GNU General Public License
  3863. +along with GCC; see the file COPYING3. If not see
  3864. +<http://www.gnu.org/licenses/>. */
  3865. +
  3866. +#include <string.h>
  3867. +#include <stdlib.h>
  3868. +#include "libiberty.h"
  3869. +#include "filenames.h"
  3870. +
  3871. +const char *metag_reduce_options (int argc, const char **argv);
  3872. +const char *metag_emb_asm_preprocessor (int argc, const char **argv);
  3873. +const char *metag_emb_onlylast (int argc, const char **argv);
  3874. +const char *metag_emb_change_suffix (int argc, const char **argv);
  3875. +
  3876. +/* This function will reduce all -mmetac options to remove all but
  3877. + the last one with the %<S construct. It will do the same for
  3878. + hard-float taking in to account that soft-float is the inverse
  3879. + and also dealing with simd-float */
  3880. +
  3881. +enum fpu_state
  3882. +{
  3883. + FPU_SOFT_FLOAT,
  3884. + FPU_HARD_FLOAT,
  3885. + FPU_HARD_FLOAT_DOUBLE,
  3886. + FPU_HARD_FLOAT_SINGLE
  3887. +};
  3888. +
  3889. +const char *
  3890. +metag_reduce_options (int argc, const char **argv)
  3891. +{
  3892. + /* Default FPU mode is soft float */
  3893. + enum fpu_state fpu_state = FPU_SOFT_FLOAT;
  3894. +
  3895. + /* Default META core is 2.1 (though this will always be overriden so it does not matter) */
  3896. + int metac_state = 21;
  3897. +
  3898. + /* SIMD FPU is not enabled by default */
  3899. + int simd_float = 0;
  3900. +
  3901. + /* 'i' is always useful */
  3902. + int i;
  3903. +
  3904. + /* 140 is the total length of all possible options that will be emitted with a null
  3905. + terminator at the end */
  3906. + char* buf = (char*)xmalloc(159);
  3907. +
  3908. + for (i = 0 ; i < argc ; i++)
  3909. + {
  3910. + if (strcmp (argv[i], "mhard-float=D") == 0)
  3911. + {
  3912. + fpu_state = FPU_HARD_FLOAT_DOUBLE;
  3913. + simd_float = 0;
  3914. + }
  3915. + else if (strcmp (argv[i], "mhard-float=S") == 0)
  3916. + {
  3917. + fpu_state = FPU_HARD_FLOAT_SINGLE;
  3918. + simd_float = 0;
  3919. + }
  3920. + else if (strcmp (argv[i], "mhard-float") == 0)
  3921. + {
  3922. + fpu_state = FPU_HARD_FLOAT;
  3923. + simd_float = 0;
  3924. + }
  3925. + else if (strcmp (argv[i], "msoft-float") == 0 || strcmp (argv[i], "mhard-float=none") == 0)
  3926. + {
  3927. + fpu_state = FPU_SOFT_FLOAT;
  3928. + simd_float = 0;
  3929. + }
  3930. + else if (strcmp (argv[i], "msimd-float") == 0)
  3931. + simd_float = 1;
  3932. + else if (strncmp (argv[i], "mmetac=", 7) == 0)
  3933. + if (strlen (argv[i]) == 10)
  3934. + {
  3935. + metac_state = (argv[i][7] - '0') * 10;
  3936. + metac_state += (argv[i][9] - '0');
  3937. + }
  3938. + }
  3939. +
  3940. + /* Point to the start of the buffer */
  3941. + i = 0;
  3942. +
  3943. + /* Strip various duplicated/overridden options */
  3944. + strncpy (&buf[i], "%<mhard-float=none ", 19);
  3945. + i += 19;
  3946. +
  3947. + if (simd_float == 0)
  3948. + {
  3949. + strncpy (&buf[i], "%<msimd-float ", 14);
  3950. + i += 14;
  3951. + }
  3952. +
  3953. + if (fpu_state != FPU_SOFT_FLOAT)
  3954. + {
  3955. + strncpy (&buf[i], "%<msoft-float ", 14);
  3956. + i += 14;
  3957. + }
  3958. +
  3959. + if (fpu_state != FPU_HARD_FLOAT)
  3960. + {
  3961. + strncpy (&buf[i], "%<mhard-float ", 14);
  3962. + i += 14;
  3963. + }
  3964. +
  3965. + if (fpu_state != FPU_HARD_FLOAT_DOUBLE)
  3966. + {
  3967. + strncpy (&buf[i], "%<mhard-float=D ", 16);
  3968. + i += 16;
  3969. + }
  3970. +
  3971. + if (fpu_state != FPU_HARD_FLOAT_SINGLE)
  3972. + {
  3973. + strncpy (&buf[i], "%<mhard-float=S ", 16);
  3974. + i += 16;
  3975. + }
  3976. +
  3977. + if (metac_state != 1)
  3978. + {
  3979. + strncpy (&buf[i], "%<mmetac=0.1 ", 13);
  3980. + i += 13;
  3981. + }
  3982. +
  3983. + if (metac_state != 10)
  3984. + {
  3985. + strncpy (&buf[i], "%<mmetac=1.0 ", 13);
  3986. + i += 13;
  3987. + }
  3988. +
  3989. + if (metac_state != 11)
  3990. + {
  3991. + strncpy (&buf[i], "%<mmetac=1.1 ", 13);
  3992. + i += 13;
  3993. + }
  3994. +
  3995. + if (metac_state != 12)
  3996. + {
  3997. + strncpy (&buf[i], "%<mmetac=1.2 ", 13);
  3998. + i += 13;
  3999. + }
  4000. +
  4001. + if (metac_state != 21)
  4002. + {
  4003. + strncpy (&buf[i], "%<mmetac=2.1 ", 13);
  4004. + i += 13;
  4005. + }
  4006. +
  4007. + buf[i] = 0;
  4008. +
  4009. + return buf;
  4010. +}
  4011. +
  4012. +/* This will be called by the spec parser in gcc.c when it sees
  4013. + a %:meta_preprocessor(args) construct.
  4014. +
  4015. + It returns a string containing new command line parameters to be
  4016. + passed to the assembler. This is for transforming -Dwhatever
  4017. + into --defwhatever. The spec will do the translation of -D
  4018. + to --def but this code removes all definitions that have
  4019. + assignments as the embedded assembler cannot cope with these
  4020. +
  4021. + ARGC and ARGV are set depending on the actual arguments given
  4022. + in the spec. */
  4023. +const char *
  4024. +metag_emb_asm_preprocessor (int argc, const char **argv)
  4025. +{
  4026. + char * cmd_args = NULL;
  4027. + char * current_pos = NULL;
  4028. + int args_size = 0;
  4029. + int i;
  4030. +
  4031. + for (i = 0 ; i < argc ; i++)
  4032. + {
  4033. + if (strchr (argv[i], '=') == NULL)
  4034. + args_size += strlen (argv[i]) + 1;
  4035. + }
  4036. +
  4037. + if (args_size == 0)
  4038. + return NULL;
  4039. +
  4040. + cmd_args = (char *)malloc (args_size);
  4041. + current_pos = cmd_args;
  4042. +
  4043. + for (i = 0 ; i < argc ; i++)
  4044. + {
  4045. + if (strchr (argv[i], '=') == NULL)
  4046. + {
  4047. + int length = strlen (argv[i]);
  4048. +
  4049. + strcpy (current_pos, argv[i]);
  4050. + *(current_pos+length) = ' ';
  4051. + current_pos += length + 1;
  4052. + }
  4053. + }
  4054. + *(current_pos-1) = 0;
  4055. +
  4056. + return cmd_args;
  4057. +}
  4058. +
  4059. +const char *
  4060. +metag_emb_onlylast (int argc, const char **argv)
  4061. +{
  4062. + if (argc != 0)
  4063. + return argv[argc-1];
  4064. + else
  4065. + return NULL;
  4066. +}
  4067. +
  4068. +const char *
  4069. +metag_emb_change_suffix (int argc, const char **argv)
  4070. +{
  4071. + const char * old_filename = NULL;
  4072. + char * new_filename = NULL;
  4073. + unsigned int old_length = 0;
  4074. + unsigned int new_length = 0;
  4075. + const char * suffix = NULL;
  4076. + int new_suffix_length = 0;
  4077. + int dot_pos = 0;
  4078. + int has_dot = 0;
  4079. +
  4080. + if (argc < 2)
  4081. + {
  4082. + fprintf (stderr, "Not enough arguments given to the meta_change_suffix function!\n");
  4083. + exit (1);
  4084. + }
  4085. + else
  4086. + {
  4087. + suffix = argv[0];
  4088. + /* If multiple -o switches are used on the command line the last one is used */
  4089. + old_filename = argv[argc - 1];
  4090. + old_length = strlen (old_filename);
  4091. + new_suffix_length = strlen (suffix);
  4092. +
  4093. + /* Find the location of the . in the filename */
  4094. + dot_pos = old_length;
  4095. + while (dot_pos-- && !IS_DIR_SEPARATOR (old_filename[dot_pos]))
  4096. + {
  4097. + if (old_filename[dot_pos] == '.')
  4098. + {
  4099. + has_dot = 1;
  4100. + break;
  4101. + }
  4102. + }
  4103. +
  4104. + /* Deal with the case where there is no dot in the filename */
  4105. + if (!has_dot)
  4106. + dot_pos = old_length;
  4107. +
  4108. + /* Compute the length of the string to hold the filename with the new suffix. */
  4109. + new_length = dot_pos + new_suffix_length + 1;
  4110. +
  4111. + /* Create a new string to hold the filename, and initialise
  4112. + it with the old filename excluding the dot and suffix (if applicable) */
  4113. + new_filename = (char *)malloc (new_length + 1);
  4114. + strncpy (new_filename, old_filename, dot_pos + 1);
  4115. +
  4116. + /* Add the dot and new suffix to the filename */
  4117. + new_filename[dot_pos] = '.';
  4118. + strcpy (&new_filename[dot_pos + 1], suffix);
  4119. +
  4120. + return new_filename;
  4121. + }
  4122. +}
  4123. diff -Nur gcc-4.2.4.orig/gcc/config/metag/dsppeephole2.md gcc-4.2.4/gcc/config/metag/dsppeephole2.md
  4124. --- gcc-4.2.4.orig/gcc/config/metag/dsppeephole2.md 1969-12-31 18:00:00.000000000 -0600
  4125. +++ gcc-4.2.4/gcc/config/metag/dsppeephole2.md 2015-07-03 18:46:05.745283542 -0500
  4126. @@ -0,0 +1,394 @@
  4127. +;; Machine description for GNU compiler,
  4128. +;; Imagination Technologies Meta version.
  4129. +;; Copyright (C) 2008
  4130. +;; Imagination Technologies Ltd
  4131. +
  4132. +;; This file is part of GCC.
  4133. +
  4134. +;; GCC is free software; you can redistribute it and/or modify it under
  4135. +;; the terms of the GNU General Public License as published by the Free
  4136. +;; Software Foundation; either version 3, or (at your option) any later
  4137. +;; version.
  4138. +
  4139. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  4140. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  4141. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  4142. +;; for more details.
  4143. +
  4144. +;; You should have received a copy of the GNU General Public License
  4145. +;; along with GCC; see the file COPYING3. If not see
  4146. +;; <http://www.gnu.org/licenses/>.
  4147. +
  4148. +;; See comment at the top of dsppeephole.md for information about
  4149. +;; dual unit DSP support in the metag backend.
  4150. +
  4151. +;; The metag_dsp_peephole2_xxxxxx_convert functions used in these
  4152. +;; rules promote operands to V2SI mode. They are all structured such
  4153. +;; that they can be used for both flag setting and non-flag setting
  4154. +;; rules.
  4155. +
  4156. +;; DSP Math peephole2s
  4157. +
  4158. +(define_peephole2
  4159. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4160. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4161. + (match_operand:SI 2 "metag_datareg_op" "")))
  4162. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4163. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4164. + (match_operand:SI 5 "metag_datareg_op" "")))]
  4165. + "TARGET_DSP
  4166. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4167. + [(set (match_dup 3)
  4168. + (3OPREG:V2SI (match_dup 4)
  4169. + (match_dup 5)))]
  4170. + {
  4171. + metag_dsp_peephole2_rrr_convert (operands);
  4172. + })
  4173. +
  4174. +(define_peephole2
  4175. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4176. + (3OPIMM16:SI (match_dup 0)
  4177. + (match_operand:SI 1 "metag_16bit_op" "")))
  4178. + (set (match_operand:SI 2 "metag_datareg_op" "")
  4179. + (3OPIMM16:SI (match_dup 2)
  4180. + (match_dup 1)))]
  4181. + "TARGET_DSP
  4182. + && metag_dsp_ri16_operands (operands)
  4183. + <dualunitimmcondition>"
  4184. + [(set (match_dup 2)
  4185. + (3OPIMM16:V2SI (match_dup 2)
  4186. + (match_dup 3)))]
  4187. + {
  4188. + metag_dsp_peephole2_ri16_convert (operands);
  4189. + })
  4190. +
  4191. +(define_peephole2
  4192. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4193. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4194. + (match_operand:SI 2 "metag_5bit_op" "")))
  4195. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4196. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4197. + (match_dup 2)))]
  4198. + "TARGET_DSP
  4199. + && metag_dsp_rri5_operands (operands)
  4200. + <dualunitimmcondition>"
  4201. + [(set (match_dup 3)
  4202. + (3OPIMM5:V2SI (match_dup 4)
  4203. + (match_dup 5)))]
  4204. + {
  4205. + metag_dsp_peephole2_rri5_convert (operands);
  4206. + })
  4207. +
  4208. +;; DSP MUL peephole
  4209. +
  4210. +;; MUL is not supported due to default DSP arithmetic mode being 16x16
  4211. +
  4212. +;; DSP MIN/MAX
  4213. +
  4214. +(define_peephole2
  4215. + [(parallel
  4216. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4217. + (MINMAX:SI (match_operand:SI 1 "metag_datareg_op" "")
  4218. + (match_operand:SI 2 "metag_datareg_op" "")))
  4219. + (clobber (reg:CC CC_REG))])
  4220. + (parallel
  4221. + [(set (match_operand:SI 3 "metag_datareg_op" "")
  4222. + (MINMAX:SI (match_operand:SI 4 "metag_datareg_op" "")
  4223. + (match_operand:SI 5 "metag_datareg_op" "")))
  4224. + (clobber (reg:CC CC_REG))])]
  4225. + "TARGET_DSP && !metag_cond_exec_p ()
  4226. + && metag_dsp_rrr_operands (operands, true)"
  4227. + [(parallel
  4228. + [(set (match_dup 3)
  4229. + (MINMAX:V2SI (match_dup 4)
  4230. + (match_dup 5)))
  4231. + (clobber (reg:CC CC_REG))])]
  4232. + {
  4233. + metag_dsp_peephole2_rrr_convert (operands);
  4234. + })
  4235. +
  4236. +;; DSP ABS peephole
  4237. +
  4238. +(define_peephole2
  4239. + [(parallel
  4240. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4241. + (abs:SI (match_operand:SI 1 "metag_datareg_op" "")))
  4242. + (clobber (reg:CC CC_REG))])
  4243. + (parallel
  4244. + [(set (match_operand:SI 2 "metag_datareg_op" "")
  4245. + (abs:SI (match_operand:SI 3 "metag_datareg_op" "")))
  4246. + (clobber (reg:CC CC_REG))])]
  4247. + "TARGET_DSP && !metag_cond_exec_p ()
  4248. + && metag_dsp_rr_operands (operands)"
  4249. + [(parallel
  4250. + [(set (match_dup 2)
  4251. + (abs:V2SI (match_dup 3)))
  4252. + (clobber (reg:CC CC_REG))])]
  4253. + {
  4254. + metag_dsp_peephole2_rr_convert (operands);
  4255. + })
  4256. +
  4257. +;; DSP MOV peephole
  4258. +
  4259. +(define_peephole2
  4260. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4261. + (match_operand:SI 1 "metag_datareg_op" ""))
  4262. + (set (match_operand:SI 2 "metag_datareg_op" "")
  4263. + (match_operand:SI 3 "metag_datareg_op" ""))]
  4264. + "TARGET_DSP && !metag_cond_exec_p ()
  4265. + && metag_dsp_rr_operands (operands)"
  4266. + [(set (match_dup 2)
  4267. + (match_dup 3))]
  4268. + {
  4269. + metag_dsp_peephole2_rr_convert (operands);
  4270. + })
  4271. +
  4272. +;; DSP Math with flags peepholes
  4273. +
  4274. +(define_peephole2
  4275. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4276. + (compare:CC_NOOV
  4277. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4278. + (match_operand:SI 2 "metag_datareg_op" ""))
  4279. + (const_int 0)))
  4280. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4281. + (3OPREG:SI (match_dup 1)
  4282. + (match_dup 2)))])
  4283. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4284. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4285. + (match_operand:SI 5 "metag_datareg_op" "")))]
  4286. + "TARGET_DSP && !metag_cond_exec_p ()
  4287. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4288. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4289. + (compare:CC_NOOV
  4290. + (3OPREG:SI (match_dup 1)
  4291. + (match_dup 2))
  4292. + (const_int 0)))
  4293. + (set (match_dup 3)
  4294. + (3OPREG:V2SI (match_dup 4)
  4295. + (match_dup 5)))])]
  4296. + {
  4297. + metag_dsp_peephole2_rrr_convert (operands);
  4298. + })
  4299. +
  4300. +(define_peephole2
  4301. + [(set (reg:CC_NOOV CC_REG)
  4302. + (compare:CC_NOOV
  4303. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4304. + (match_operand:SI 2 "metag_datareg_op" ""))
  4305. + (const_int 0)))
  4306. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4307. + (3OPREG:SI (match_dup 1)
  4308. + (match_dup 2)))
  4309. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4310. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4311. + (match_operand:SI 5 "metag_datareg_op" "")))]
  4312. + "TARGET_DSP && !metag_cond_exec_p ()
  4313. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4314. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4315. + (compare:CC_NOOV
  4316. + (3OPREG:SI (match_dup 1)
  4317. + (match_dup 2))
  4318. + (const_int 0)))
  4319. + (set (match_dup 3)
  4320. + (3OPREG:V2SI (match_dup 4)
  4321. + (match_dup 5)))])]
  4322. + {
  4323. + metag_dsp_peephole2_rrr_convert (operands);
  4324. + })
  4325. +
  4326. +(define_peephole2
  4327. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4328. + (compare:CC_NOOV
  4329. + (3OPIMM16:SI (match_operand:SI 0 "metag_datareg_op" "")
  4330. + (match_operand:SI 1 "metag_16bit_op" ""))
  4331. + (const_int 0)))
  4332. + (set (match_dup 0)
  4333. + (3OPIMM16:SI (match_dup 0)
  4334. + (match_dup 1)))])
  4335. + (set (match_operand:SI 2 "metag_datareg_op" "")
  4336. + (3OPIMM16:SI (match_dup 2)
  4337. + (match_dup 1)))]
  4338. + "TARGET_DSP && !metag_cond_exec_p ()
  4339. + && metag_dsp_ri16_operands (operands)
  4340. + <dualunitimmcondition>"
  4341. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4342. + (compare:CC_NOOV
  4343. + (3OPIMM16:SI (match_dup 0)
  4344. + (match_dup 1))
  4345. + (const_int 0)))
  4346. + (set (match_dup 2)
  4347. + (3OPIMM16:V2SI (match_dup 2)
  4348. + (match_dup 3)))])]
  4349. + {
  4350. + metag_dsp_peephole2_ri16_convert (operands);
  4351. + })
  4352. +
  4353. +(define_peephole2
  4354. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4355. + (compare:CC_NOOV
  4356. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4357. + (match_operand:SI 2 "metag_5bit_op" ""))
  4358. + (const_int 0)))
  4359. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4360. + (3OPIMM5:SI (match_dup 1)
  4361. + (match_dup 2)))])
  4362. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4363. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4364. + (match_dup 2)))]
  4365. + "TARGET_DSP && !metag_cond_exec_p ()
  4366. + && metag_dsp_rri5_operands (operands)
  4367. + <dualunitimmcondition>"
  4368. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4369. + (compare:CC_NOOV
  4370. + (3OPIMM5:SI (match_dup 1)
  4371. + (match_dup 2))
  4372. + (const_int 0)))
  4373. + (set (match_dup 3)
  4374. + (3OPIMM5:V2SI (match_dup 4)
  4375. + (match_dup 5)))])]
  4376. + {
  4377. + metag_dsp_peephole2_rri5_convert (operands);
  4378. + })
  4379. +
  4380. +(define_peephole2
  4381. + [(set (reg:CC_NOOV CC_REG)
  4382. + (compare:CC_NOOV
  4383. + (3OPIMM16:SI (match_operand:SI 0 "metag_datareg_op" "")
  4384. + (match_operand:SI 1 "metag_16bit_op" ""))
  4385. + (const_int 0)))
  4386. + (set (match_dup 0)
  4387. + (3OPIMM16:SI (match_dup 0)
  4388. + (match_dup 1)))
  4389. + (set (match_operand:SI 2 "metag_datareg_op" "")
  4390. + (3OPIMM16:SI (match_dup 2)
  4391. + (match_dup 1)))]
  4392. + "TARGET_DSP && !metag_cond_exec_p ()
  4393. + && metag_dsp_ri16_operands (operands)
  4394. + <dualunitimmcondition>"
  4395. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4396. + (compare:CC_NOOV
  4397. + (3OPIMM16:SI (match_dup 0)
  4398. + (match_dup 1))
  4399. + (const_int 0)))
  4400. + (set (match_dup 2)
  4401. + (3OPIMM16:V2SI (match_dup 2)
  4402. + (match_dup 3)))])]
  4403. + {
  4404. + metag_dsp_peephole2_ri16_convert (operands);
  4405. + })
  4406. +
  4407. +(define_peephole2
  4408. + [(set (reg:CC_NOOV CC_REG)
  4409. + (compare:CC_NOOV
  4410. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4411. + (match_operand:SI 2 "metag_5bit_op" ""))
  4412. + (const_int 0)))
  4413. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4414. + (3OPIMM5:SI (match_dup 1)
  4415. + (match_dup 2)))
  4416. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4417. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4418. + (match_dup 2)))]
  4419. + "TARGET_DSP && !metag_cond_exec_p ()
  4420. + && metag_dsp_rri5_operands (operands)
  4421. + <dualunitimmcondition>"
  4422. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4423. + (compare:CC_NOOV
  4424. + (3OPIMM5:SI (match_dup 1)
  4425. + (match_dup 2))
  4426. + (const_int 0)))
  4427. + (set (match_dup 3)
  4428. + (3OPIMM5:V2SI (match_dup 4)
  4429. + (match_dup 5)))])]
  4430. + {
  4431. + metag_dsp_peephole2_rri5_convert (operands);
  4432. + })
  4433. +
  4434. +;; DSP OP + MOV
  4435. +
  4436. +(define_peephole2
  4437. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4438. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4439. + (match_operand:SI 2 "metag_datareg_op" "")))
  4440. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4441. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4442. + (match_operand:SI 5 "metag_datareg_op" "")))
  4443. + (set (match_operand:SI 6 "metag_datareg_op" "")
  4444. + (match_dup 0))
  4445. + (set (match_operand:SI 7 "metag_datareg_op" "")
  4446. + (match_dup 3))]
  4447. + "TARGET_DSP && !metag_cond_exec_p ()
  4448. + && metag_dsp_rrr_mov_operands (operands, <commutative>)
  4449. + && peep2_reg_dead_p (3, operands[0])
  4450. + && peep2_reg_dead_p (4, operands[3])"
  4451. + [(set (match_dup 6)
  4452. + (3OPREG:V2SI (match_dup 1)
  4453. + (match_dup 2)))]
  4454. + {
  4455. + metag_dsp_peephole2_rrr_mov_convert (operands);
  4456. + })
  4457. +
  4458. +;; DSP MUL + MOV
  4459. +
  4460. +;; MUL is not supported due to default dsp arithmetic mode being 16x16
  4461. +
  4462. +;; DSP ABS + MOV
  4463. +
  4464. +(define_peephole2
  4465. + [(parallel
  4466. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  4467. + (abs:SI (match_operand:SI 1 "metag_datareg_op" "")))
  4468. + (clobber (reg:CC CC_REG))])
  4469. + (set (match_operand:SI 4 "metag_datareg_op" "")
  4470. + (match_dup 0))
  4471. + (parallel
  4472. + [(set (match_operand:SI 2 "metag_reg_nofloat_op" "")
  4473. + (abs:SI (match_operand:SI 3 "metag_datareg_op" "")))
  4474. + (clobber (reg:CC CC_REG))])
  4475. + (set (match_operand:SI 5 "metag_datareg_op" "")
  4476. + (match_dup 2))]
  4477. + "TARGET_DSP && !metag_cond_exec_p ()
  4478. + && metag_dsp_rr_rr_mov_operands (operands)
  4479. + && peep2_reg_dead_p (2, operands[0])
  4480. + && peep2_reg_dead_p (4, operands[2])"
  4481. + [(parallel
  4482. + [(set (match_dup 4)
  4483. + (abs:SI (match_dup 1)))
  4484. + (clobber (reg:CC CC_REG))])]
  4485. + {
  4486. + metag_dsp_peephole2_rr_mov_convert (operands);
  4487. + })
  4488. +
  4489. +;; DSP MIN/MAX + MOV
  4490. +
  4491. +(define_peephole2
  4492. + [(parallel
  4493. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4494. + (MINMAX:SI (match_operand:SI 1 "metag_datareg_op" "")
  4495. + (match_operand:SI 2 "metag_datareg_op" "")))
  4496. + (clobber (reg:CC CC_REG))])
  4497. + (set (match_operand:SI 6 "metag_datareg_op" "")
  4498. + (match_dup 0))
  4499. + (parallel
  4500. + [(set (match_operand:SI 3 "metag_datareg_op" "")
  4501. + (MINMAX:SI (match_operand:SI 4 "metag_datareg_op" "")
  4502. + (match_operand:SI 5 "metag_datareg_op" "")))
  4503. + (clobber (reg:CC CC_REG))])
  4504. + (set (match_operand:SI 7 "metag_datareg_op" "")
  4505. + (match_dup 3))]
  4506. + "TARGET_DSP && !metag_cond_exec_p ()
  4507. + && metag_dsp_rrr_mov_operands (operands, <commutative>)
  4508. + && peep2_reg_dead_p (2, operands[0])
  4509. + && peep2_reg_dead_p (4, operands[3])"
  4510. + [(parallel
  4511. + [(set (match_dup 6)
  4512. + (MINMAX:SI (match_dup 1)
  4513. + (match_dup 2)))
  4514. + (clobber (reg:CC CC_REG))])]
  4515. + {
  4516. + metag_dsp_peephole2_rrr_mov_convert (operands);
  4517. + })
  4518. +
  4519. +;; END DSP Peephole2s
  4520. +
  4521. diff -Nur gcc-4.2.4.orig/gcc/config/metag/dsppeephole.md gcc-4.2.4/gcc/config/metag/dsppeephole.md
  4522. --- gcc-4.2.4.orig/gcc/config/metag/dsppeephole.md 1969-12-31 18:00:00.000000000 -0600
  4523. +++ gcc-4.2.4/gcc/config/metag/dsppeephole.md 2015-07-03 18:46:05.745283542 -0500
  4524. @@ -0,0 +1,434 @@
  4525. +;; Machine description for GNU compiler,
  4526. +;; Imagination Technologies Meta version.
  4527. +;; Copyright (C) 2008
  4528. +;; Imagination Technologies Ltd
  4529. +
  4530. +;; This file is part of GCC.
  4531. +
  4532. +;; GCC is free software; you can redistribute it and/or modify it under
  4533. +;; the terms of the GNU General Public License as published by the Free
  4534. +;; Software Foundation; either version 3, or (at your option) any later
  4535. +;; version.
  4536. +
  4537. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  4538. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  4539. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  4540. +;; for more details.
  4541. +
  4542. +;; You should have received a copy of the GNU General Public License
  4543. +;; along with GCC; see the file COPYING3. If not see
  4544. +;; <http://www.gnu.org/licenses/>.
  4545. +
  4546. +;; READ THIS...
  4547. +
  4548. +;; DSP peephole transformations are mostly templated. There are 3 templates:
  4549. +;; 1) 3OPREG - This is the set of operations that have 3 register operands
  4550. +;; 2 input and 1 output.
  4551. +;; 2) 3OPIMM16 - This is the set of operations that have 3 operands
  4552. +;; 1 register input, 1 16 bit immediate input, 1 register output
  4553. +;; 2) 3OPIMM5 - This is the set of operations that have 3 operands
  4554. +;; 1 register input, 1 5 bit immediate input, 1 register output
  4555. +
  4556. +;; Special code attributes:
  4557. +
  4558. +;; <commutative>
  4559. +;; Indicates if an insn code has commutative input operands.
  4560. +;; <dualunitimmcondition>
  4561. +;; Special immediate conditions for dual unit operations.
  4562. +;; <expander>
  4563. +;; The name of the insn suitable for use in rtl generation.
  4564. +;; <MNEMONIC>
  4565. +;; The assembler nmemonic for the given insn code.
  4566. +
  4567. +;; Dual unit conditions:
  4568. +
  4569. +;; The conditions for all DSP transformations are checked in the functions
  4570. +;; called metag_dsp_xxxxxxx_operands. These functions check that the operands
  4571. +;; in one instruction are an exact mirror of the operands of another
  4572. +;; instruction.
  4573. +;; For example metag_dsp_rrr_operands returns true for the following 2
  4574. +;; instructions regardless of which order they appear (D1 or D0 first):
  4575. +;;
  4576. +;; (set (reg D0Re0 [D0.0])
  4577. +;; (operation (reg D0Ar6 [D0.1])
  4578. +;; (reg D0Ar4 (D0.2])))
  4579. +;; (set (reg D1Re0 [D1.0])
  4580. +;; (operation (reg D1Ar5 [D1.1])
  4581. +;; (reg D1Ar3 (D1.2])))
  4582. +
  4583. +(define_peephole
  4584. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4585. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4586. + (match_operand:SI 2 "metag_datareg_op" "")))
  4587. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4588. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4589. + (match_operand:SI 5 "metag_datareg_op" "")))]
  4590. + "TARGET_DSP && !metag_cond_exec_p ()
  4591. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4592. + "DL\\t<MNEMONIC>\\t%0, %1, %2\\t%@ (*<MNEMONIC>\\t%3, %4, %5)"
  4593. + [(set_attr "type" "fast")])
  4594. +
  4595. +(define_peephole
  4596. + [(set (match_operand:SI 3 "metag_datareg_op" "")
  4597. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4598. + (match_operand:SI 5 "metag_datareg_op" "")))
  4599. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4600. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4601. + (match_operand:SI 2 "metag_datareg_op" "")))]
  4602. + "TARGET_DSP && !metag_cond_exec_p ()
  4603. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4604. + "DL\\t<MNEMONIC>\\t%3, %4, %5\\t%@ (*<MNEMONIC>\\t%0, %1, %2)"
  4605. + [(set_attr "type" "fast")])
  4606. +
  4607. +(define_peephole
  4608. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4609. + (3OPIMM16:SI (match_dup 0)
  4610. + (match_operand:SI 1 "metag_16bit_op" "")))
  4611. + (set (match_operand:SI 2 "metag_datareg_op" "")
  4612. + (3OPIMM16:SI (match_dup 2)
  4613. + (match_dup 1)))]
  4614. + "TARGET_DSP && !metag_cond_exec_p ()
  4615. + && metag_dsp_ri16_operands (operands)
  4616. + <dualunitimmcondition>"
  4617. + "DL\\t<MNEMONIC>\\t%0, %0, %1\\t%@ (*<MNEMONIC>\\t%2, %2, %1)"
  4618. + [(set_attr "type" "fast")])
  4619. +
  4620. +(define_peephole
  4621. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4622. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4623. + (match_operand:SI 2 "metag_5bit_op" "")))
  4624. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4625. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4626. + (match_dup 2)))]
  4627. + "TARGET_DSP && !metag_cond_exec_p ()
  4628. + && metag_dsp_rri5_operands (operands)
  4629. + <dualunitimmcondition>"
  4630. + "DL\\t<MNEMONIC>\\t%0, %1, %2\\t%@ (*<MNEMONIC>\\t%3, %4, %2)"
  4631. + [(set_attr "type" "fast")])
  4632. +
  4633. +;; DSP MIN/MAX
  4634. +
  4635. +(define_peephole
  4636. + [(parallel
  4637. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4638. + (MINMAX:SI (match_operand:SI 1 "metag_datareg_op" "")
  4639. + (match_operand:SI 2 "metag_datareg_op" "")))
  4640. + (clobber (reg:CC CC_REG))])
  4641. + (parallel
  4642. + [(set (match_operand:SI 3 "metag_datareg_op" "")
  4643. + (MINMAX:SI (match_operand:SI 4 "metag_datareg_op" "")
  4644. + (match_operand:SI 5 "metag_datareg_op" "")))
  4645. + (clobber (reg:CC CC_REG))])]
  4646. + "TARGET_DSP && !metag_cond_exec_p ()
  4647. + && metag_dsp_rrr_operands (operands, true)"
  4648. + "DL\\t<MNEMONIC>\\t%0, %1, %2\\t%@ (*<MNEMONIC>\\t%3, %4, %5)"
  4649. + [(set_attr "type" "fast")
  4650. + (set_attr "ccstate" "ccx")])
  4651. +
  4652. +;; DSP ABS peephole
  4653. +
  4654. +(define_peephole
  4655. + [(parallel
  4656. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4657. + (abs:SI (match_operand:SI 1 "metag_datareg_op" "")))
  4658. + (clobber (reg:CC CC_REG))])
  4659. + (parallel
  4660. + [(set (match_operand:SI 2 "metag_datareg_op" "")
  4661. + (abs:SI (match_operand:SI 3 "metag_datareg_op" "")))
  4662. + (clobber (reg:CC CC_REG))])]
  4663. + "TARGET_DSP && !metag_cond_exec_p ()
  4664. + && metag_dsp_rr_operands (operands)"
  4665. + "DL\\tABS\\t%0, %1\\t%@ *ABS\\t%2, %3)"
  4666. + [(set_attr "type" "fast")
  4667. + (set_attr "ccstate" "ccx")])
  4668. +
  4669. +;; DSP MOV peephole
  4670. +
  4671. +(define_peephole
  4672. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4673. + (match_operand:SI 1 "metag_datareg_op" ""))
  4674. + (set (match_operand:SI 2 "metag_datareg_op" "")
  4675. + (match_operand:SI 3 "metag_datareg_op" ""))]
  4676. + "TARGET_DSP && !metag_cond_exec_p ()
  4677. + && metag_dsp_rr_operands (operands)"
  4678. + "DL\\tMOV\\t%0, %1\\t%@ (*MOV\\t%2, %3)"
  4679. + [(set_attr "type" "fast")])
  4680. +
  4681. +;; DSP Math with flags peepholes
  4682. +
  4683. +(define_peephole
  4684. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4685. + (compare:CC_NOOV
  4686. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4687. + (match_operand:SI 2 "metag_datareg_op" ""))
  4688. + (const_int 0)))
  4689. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4690. + (3OPREG:SI (match_dup 1)
  4691. + (match_dup 2)))])
  4692. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4693. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4694. + (match_operand:SI 5 "metag_datareg_op" "")))]
  4695. + "TARGET_DSP && !metag_cond_exec_p ()
  4696. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4697. + "DL\\t<MNEMONIC>S\\t%0, %1, %2\\t%@ (*<MNEMONIC>S\\t%3, %4, %5)"
  4698. + [(set_attr "type" "fast")
  4699. + (set_attr "ccstate" "set")])
  4700. +
  4701. +(define_peephole
  4702. + [(set (match_operand:SI 3 "metag_datareg_op" "")
  4703. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4704. + (match_operand:SI 5 "metag_datareg_op" "")))
  4705. + (parallel [(set (reg:CC_NOOV CC_REG)
  4706. + (compare:CC_NOOV
  4707. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4708. + (match_operand:SI 2 "metag_datareg_op" ""))
  4709. + (const_int 0)))
  4710. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4711. + (3OPREG:SI (match_dup 1)
  4712. + (match_dup 2)))])]
  4713. + "TARGET_DSP && !metag_cond_exec_p ()
  4714. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4715. + "DL\\t<MNEMONIC>S\\t%0, %1, %2\\t%@ (*<MNEMONIC>S\\t%3, %4, %5)"
  4716. + [(set_attr "type" "fast")
  4717. + (set_attr "ccstate" "set")])
  4718. +
  4719. +(define_peephole
  4720. + [(set (reg:CC_NOOV CC_REG)
  4721. + (compare:CC_NOOV
  4722. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4723. + (match_operand:SI 5 "metag_datareg_op" ""))
  4724. + (const_int 0)))
  4725. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4726. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4727. + (match_operand:SI 2 "metag_datareg_op" "")))
  4728. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4729. + (3OPREG:SI (match_dup 4)
  4730. + (match_dup 5)))]
  4731. + "TARGET_DSP && !metag_cond_exec_p ()
  4732. + && metag_dsp_rrr_operands (operands, <commutative>)"
  4733. + "DL\\t<MNEMONIC>S\\t%3, %4, %5\\t%@ (*<MNEMONIC>S\\t%0, %1, %2)"
  4734. + [(set_attr "type" "fast")
  4735. + (set_attr "ccstate" "set")])
  4736. +
  4737. +(define_peephole
  4738. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4739. + (compare:CC_NOOV
  4740. + (3OPIMM16:SI (match_operand:SI 0 "metag_datareg_op" "")
  4741. + (match_operand:SI 1 "metag_16bit_op" ""))
  4742. + (const_int 0)))
  4743. + (set (match_dup 0)
  4744. + (3OPIMM16:SI (match_dup 0)
  4745. + (match_dup 1)))])
  4746. + (set (match_operand:SI 2 "metag_datareg_op" "")
  4747. + (3OPIMM16:SI (match_dup 2)
  4748. + (match_dup 1)))]
  4749. + "TARGET_DSP && !metag_cond_exec_p ()
  4750. + && metag_dsp_ri16_operands (operands)
  4751. + <dualunitimmcondition>"
  4752. + "DL\\t<MNEMONIC>S\\t%0, %0, %1\\t%@ (*<MNEMONIC>S\\t%2, %2, %1)"
  4753. + [(set_attr "type" "fast")
  4754. + (set_attr "ccstate" "set")])
  4755. +
  4756. +(define_peephole
  4757. + [(parallel [(set (reg:CC_NOOV CC_REG)
  4758. + (compare:CC_NOOV
  4759. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4760. + (match_operand:SI 2 "metag_5bit_op" ""))
  4761. + (const_int 0)))
  4762. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4763. + (3OPIMM5:SI (match_dup 1)
  4764. + (match_dup 2)))])
  4765. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4766. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4767. + (match_dup 2)))]
  4768. + "TARGET_DSP && !metag_cond_exec_p ()
  4769. + && metag_dsp_rri5_operands (operands)
  4770. + <dualunitimmcondition>"
  4771. + "DL\\t<MNEMONIC>S\\t%0, %1, %2\\t%@ (*<MNEMONIC>S\\t%3, %4, %2)"
  4772. + [(set_attr "type" "fast")
  4773. + (set_attr "ccstate" "set")])
  4774. +
  4775. +(define_peephole
  4776. + [(set (match_operand:SI 2 "metag_datareg_op" "")
  4777. + (3OPIMM16:SI (match_dup 2)
  4778. + (match_operand:SI 1 "metag_16bit_op" "")))
  4779. + (parallel [(set (reg:CC_NOOV CC_REG)
  4780. + (compare:CC_NOOV
  4781. + (3OPIMM16:SI (match_operand:SI 0 "metag_datareg_op" "")
  4782. + (match_dup 1))
  4783. + (const_int 0)))
  4784. + (set (match_dup 0)
  4785. + (3OPIMM16:SI (match_dup 0)
  4786. + (match_dup 1)))])]
  4787. + "TARGET_DSP && !metag_cond_exec_p ()
  4788. + && metag_dsp_ri16_operands (operands)
  4789. + <dualunitimmcondition>"
  4790. + "DL\\t<MNEMONIC>S\\t%0, %0, %1\\t%@ (*<MNEMONIC>S\\t%2, %2, %1)"
  4791. + [(set_attr "type" "fast")
  4792. + (set_attr "ccstate" "set")])
  4793. +
  4794. +(define_peephole
  4795. + [(set (match_operand:SI 3 "metag_datareg_op" "")
  4796. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4797. + (match_operand:SI 2 "metag_5bit_op" "")))
  4798. + (parallel [(set (reg:CC_NOOV CC_REG)
  4799. + (compare:CC_NOOV
  4800. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4801. + (match_dup 2))
  4802. + (const_int 0)))
  4803. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4804. + (3OPIMM5:SI (match_dup 1)
  4805. + (match_dup 2)))])]
  4806. + "TARGET_DSP && !metag_cond_exec_p ()
  4807. + && metag_dsp_rri5_operands (operands)
  4808. + <dualunitimmcondition>"
  4809. + "DL\\t<MNEMONIC>S\\t%0, %1, %2\\t%@ (*<MNEMONIC>S\\t%3, %4, %2)"
  4810. + [(set_attr "type" "fast")
  4811. + (set_attr "ccstate" "set")])
  4812. +
  4813. +(define_peephole
  4814. + [(set (reg:CC_NOOV CC_REG)
  4815. + (compare:CC_NOOV
  4816. + (3OPIMM16:SI (match_operand:SI 2 "metag_datareg_op" "")
  4817. + (match_operand:SI 1 "metag_16bit_op" ""))
  4818. + (const_int 0)))
  4819. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4820. + (3OPIMM16:SI (match_dup 0)
  4821. + (match_dup 1)))
  4822. + (set (match_dup 2)
  4823. + (3OPIMM16:SI (match_dup 2)
  4824. + (match_dup 1)))]
  4825. + "TARGET_DSP && !metag_cond_exec_p ()
  4826. + && metag_dsp_ri16_operands (operands)
  4827. + <dualunitimmcondition>"
  4828. + "DL\\t<MNEMONIC>S\\t%2, %2, %1\\t%@ (*<MNEMONIC>S\\t%0, %0, %1)"
  4829. + [(set_attr "type" "fast")
  4830. + (set_attr "ccstate" "set")])
  4831. +
  4832. +(define_peephole
  4833. + [(set (reg:CC_NOOV CC_REG)
  4834. + (compare:CC_NOOV
  4835. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4836. + (match_operand:SI 2 "metag_5bit_op" ""))
  4837. + (const_int 0)))
  4838. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4839. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4840. + (match_dup 2)))
  4841. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4842. + (3OPIMM5:SI (match_dup 4)
  4843. + (match_dup 2)))]
  4844. + "TARGET_DSP && !metag_cond_exec_p ()
  4845. + && metag_dsp_rri5_operands (operands)
  4846. + <dualunitimmcondition>"
  4847. + "DL\\t<MNEMONIC>S\\t%3, %4, %2\\t%@ (*<MNEMONIC>S\\t%0, %1, %2)"
  4848. + [(set_attr "type" "fast")
  4849. + (set_attr "ccstate" "set")])
  4850. +
  4851. +(define_peephole
  4852. + [(set (reg:CC_NOOV CC_REG)
  4853. + (compare:CC_NOOV
  4854. + (3OPIMM16:SI (match_operand:SI 2 "metag_datareg_op" "")
  4855. + (match_operand:SI 1 "metag_16bit_op" ""))
  4856. + (const_int 0)))
  4857. + (set (match_dup 2)
  4858. + (3OPIMM16:SI (match_dup 2)
  4859. + (match_dup 1)))
  4860. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4861. + (3OPIMM16:SI (match_dup 0)
  4862. + (match_dup 1)))]
  4863. + "TARGET_DSP && !metag_cond_exec_p ()
  4864. + && metag_dsp_ri16_operands (operands)
  4865. + <dualunitimmcondition>"
  4866. + "DL\\t<MNEMONIC>S\\t%2, %2, %1\\t%@ (*<MNEMONIC>S\\t%0, %0, %1)"
  4867. + [(set_attr "type" "fast")
  4868. + (set_attr "ccstate" "set")])
  4869. +
  4870. +(define_peephole
  4871. + [(set (reg:CC_NOOV CC_REG)
  4872. + (compare:CC_NOOV
  4873. + (3OPIMM5:SI (match_operand:SI 4 "metag_datareg_op" "")
  4874. + (match_operand:SI 2 "metag_5bit_op" ""))
  4875. + (const_int 0)))
  4876. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4877. + (3OPIMM5:SI (match_dup 4)
  4878. + (match_dup 2)))
  4879. + (set (match_operand:SI 0 "metag_datareg_op" "")
  4880. + (3OPIMM5:SI (match_operand:SI 1 "metag_datareg_op" "")
  4881. + (match_dup 2)))]
  4882. + "TARGET_DSP && !metag_cond_exec_p ()
  4883. + && metag_dsp_rri5_operands (operands)
  4884. + <dualunitimmcondition>"
  4885. + "DL\\t<MNEMONIC>S\\t%3, %4, %2\\t%@ (*<MNEMONIC>S\\t%0, %1, %2)"
  4886. + [(set_attr "type" "fast")
  4887. + (set_attr "ccstate" "set")])
  4888. +
  4889. +;; DSP OP + MOV
  4890. +
  4891. +(define_peephole
  4892. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4893. + (3OPREG:SI (match_operand:SI 1 "metag_datareg_op" "")
  4894. + (match_operand:SI 2 "metag_datareg_op" "")))
  4895. + (set (match_operand:SI 3 "metag_datareg_op" "")
  4896. + (3OPREG:SI (match_operand:SI 4 "metag_datareg_op" "")
  4897. + (match_operand:SI 5 "metag_datareg_op" "")))
  4898. + (set (match_operand:SI 6 "metag_datareg_op" "")
  4899. + (match_dup 0))
  4900. + (set (match_operand:SI 7 "metag_datareg_op" "")
  4901. + (match_dup 3))]
  4902. + "TARGET_DSP && !metag_cond_exec_p ()
  4903. + && metag_dsp_rrr_mov_operands (operands, <commutative>)
  4904. + && dead_or_set_p (PREV_INSN (insn), operands[0])
  4905. + && dead_or_set_p (insn, operands[3])"
  4906. + "DL\\t<MNEMONIC>\\t%6, %1, %2\\t%@ (*<MNEMONIC>\\t%7, %4, %5)"
  4907. + [(set_attr "type" "fast")])
  4908. +
  4909. +;; DSP ABS + MOV
  4910. +
  4911. +(define_peephole
  4912. + [(parallel
  4913. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  4914. + (abs:SI (match_operand:SI 1 "metag_datareg_op" "")))
  4915. + (clobber (reg:CC CC_REG))])
  4916. + (set (match_operand:SI 4 "metag_datareg_op" "")
  4917. + (match_dup 0))
  4918. + (parallel
  4919. + [(set (match_operand:SI 2 "metag_reg_nofloat_op" "")
  4920. + (abs:SI (match_operand:SI 3 "metag_datareg_op" "")))
  4921. + (clobber (reg:CC CC_REG))])
  4922. + (set (match_operand:SI 5 "metag_datareg_op" "")
  4923. + (match_dup 2))]
  4924. + "TARGET_DSP && !metag_cond_exec_p ()
  4925. + && metag_dsp_rr_rr_mov_operands (operands)
  4926. + && dead_or_set_p (PREV_INSN (PREV_INSN (insn)), operands[0])
  4927. + && dead_or_set_p (insn, operands[2])"
  4928. + "DL\\tABS\\t%4, %1\\t%@ (*ABS\\t%5, %2)"
  4929. + [(set_attr "type" "fast")
  4930. + (set_attr "ccstate" "ccx")])
  4931. +
  4932. +;; DSP MIN/MAX + MOV
  4933. +
  4934. +(define_peephole
  4935. + [(parallel
  4936. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  4937. + (MINMAX:SI (match_operand:SI 1 "metag_datareg_op" "")
  4938. + (match_operand:SI 2 "metag_datareg_op" "")))
  4939. + (clobber (reg:CC CC_REG))])
  4940. + (set (match_operand:SI 6 "metag_datareg_op" "")
  4941. + (match_dup 0))
  4942. + (parallel
  4943. + [(set (match_operand:SI 3 "metag_datareg_op" "")
  4944. + (MINMAX:SI (match_operand:SI 4 "metag_datareg_op" "")
  4945. + (match_operand:SI 5 "metag_datareg_op" "")))
  4946. + (clobber (reg:CC CC_REG))])
  4947. + (set (match_operand:SI 7 "metag_datareg_op" "")
  4948. + (match_dup 3))]
  4949. + "TARGET_DSP && !metag_cond_exec_p ()
  4950. + && metag_dsp_rrr_mov_operands (operands, <commutative>)
  4951. + && dead_or_set_p (PREV_INSN (PREV_INSN (insn)), operands[0])
  4952. + && dead_or_set_p (insn, operands[3])"
  4953. + "DL\\t<MNEMONIC>\\t%6, %1, %2\\t%@ (*<MNEMONIC>\\r%7, %4, %5)"
  4954. + [(set_attr "type" "fast")
  4955. + (set_attr "ccstate" "ccx")])
  4956. +
  4957. +;; END DSP Peepholes
  4958. +
  4959. diff -Nur gcc-4.2.4.orig/gcc/config/metag/elf.h gcc-4.2.4/gcc/config/metag/elf.h
  4960. --- gcc-4.2.4.orig/gcc/config/metag/elf.h 1969-12-31 18:00:00.000000000 -0600
  4961. +++ gcc-4.2.4/gcc/config/metag/elf.h 2015-07-03 18:46:05.745283542 -0500
  4962. @@ -0,0 +1,84 @@
  4963. +/* Definitions of target machine for GNU compiler,
  4964. + for Meta Linux-based GNU systems.
  4965. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
  4966. + Free Software Foundation, Inc.
  4967. + Contributed by Imagination Technologies Ltd (toolkit@metagence.com)
  4968. +
  4969. +This file is part of GCC.
  4970. +
  4971. +GCC is free software; you can redistribute it and/or modify it under
  4972. +the terms of the GNU General Public License as published by the Free
  4973. +Software Foundation; either version 3, or (at your option) any later
  4974. +version.
  4975. +
  4976. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  4977. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  4978. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  4979. +for more details.
  4980. +
  4981. +You should have received a copy of the GNU General Public License
  4982. +along with GCC; see the file COPYING3. If not see
  4983. +<http://www.gnu.org/licenses/>. */
  4984. +
  4985. +#ifndef OBJECT_FORMAT_ELF
  4986. +#error elf.h included before elfos.h
  4987. +#endif
  4988. +
  4989. +#undef BSS_SECTION_ASM_OP
  4990. +
  4991. +/* Dots in labels are not allowed. */
  4992. +
  4993. +#define NO_DOT_IN_LABEL 1
  4994. +
  4995. +#define ASM_PN_FORMAT "%s___%lu"
  4996. +
  4997. +#undef DBX_DEBUGGING_INFO
  4998. +
  4999. +#undef PREFERRED_DEBUGGING_TYPE
  5000. +#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
  5001. +
  5002. +#undef ASM_FINAL_SPEC
  5003. +
  5004. +#ifdef MINIM_DEFAULT
  5005. +#define DEFAULT_MINIM_LINK_SPEC "%{!mno-minim:%{mmetac=2.1:--minim}} "
  5006. +#else
  5007. +#define DEFAULT_MINIM_LINK_SPEC
  5008. +#endif
  5009. +
  5010. +#ifdef METAG_LINK_GLOBAL
  5011. +#define LINK_MACHINE_TYPE "-m elf32metag_global "
  5012. +#else
  5013. +#define LINK_MACHINE_TYPE "-m elf32metag "
  5014. +#endif
  5015. +
  5016. +#undef LINK_SPEC
  5017. +#define LINK_SPEC \
  5018. + LINK_MACHINE_TYPE \
  5019. + "%{shared:-shared} " \
  5020. + "-init=__init -fini=__fini " \
  5021. + "%{mminim:%{mmetac=2.1:--minim}%{!mmetac=2.1:%eMiniM mode is only available on a META 2.1}} "\
  5022. + DEFAULT_MINIM_LINK_SPEC \
  5023. + "%{!shared: " \
  5024. + "%{!static: " \
  5025. + "%{rdynamic:-export-dynamic} " \
  5026. + "%{!dynamic-linker:-dynamic-linker %(elf_dynamic_linker)}} " \
  5027. + "%{static:-static}} "
  5028. +
  5029. +#ifndef ASM_COMMENT_START
  5030. +#define ASM_COMMENT_START "!"
  5031. +#endif
  5032. +
  5033. +#define ASM_IDENTIFY_LANGUAGE(FILE) \
  5034. + fprintf (FILE, "%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
  5035. + lang_identify (), version_string)
  5036. +
  5037. +
  5038. +#undef ASM_OUTPUT_CASE_LABEL
  5039. +
  5040. +/* For PIC code we need to explicitly specify (PLT) and (GOT) relocs. */
  5041. +#define NEED_PLT_RELOC flag_pic
  5042. +#define NEED_GOT_RELOC flag_pic
  5043. +
  5044. +#ifndef SUBTARGET_CPP_SPEC
  5045. +#define SUBTARGET_CPP_SPEC "-D__ELF__"
  5046. +#endif
  5047. diff -Nur gcc-4.2.4.orig/gcc/config/metag/fp-hard-bit.c gcc-4.2.4/gcc/config/metag/fp-hard-bit.c
  5048. --- gcc-4.2.4.orig/gcc/config/metag/fp-hard-bit.c 1969-12-31 18:00:00.000000000 -0600
  5049. +++ gcc-4.2.4/gcc/config/metag/fp-hard-bit.c 2015-07-03 18:46:05.745283542 -0500
  5050. @@ -0,0 +1,1756 @@
  5051. +/* This is a software floating point library which can be used
  5052. + for targets without hardware floating point.
  5053. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003,
  5054. + 2004, 2005, 2009 Free Software Foundation, Inc.
  5055. +
  5056. +This file is part of GCC.
  5057. +
  5058. +GCC is free software; you can redistribute it and/or modify it under
  5059. +the terms of the GNU General Public License as published by the Free
  5060. +Software Foundation; either version 3, or (at your option) any later
  5061. +version.
  5062. +
  5063. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  5064. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  5065. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  5066. +for more details.
  5067. +
  5068. +Under Section 7 of GPL version 3, you are granted additional
  5069. +permissions described in the GCC Runtime Library Exception, version
  5070. +3.1, as published by the Free Software Foundation.
  5071. +
  5072. +You should have received a copy of the GNU General Public License and
  5073. +a copy of the GCC Runtime Library Exception along with this program;
  5074. +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  5075. +<http://www.gnu.org/licenses/>. */
  5076. +
  5077. +/* This implements IEEE 754 format arithmetic, but does not provide a
  5078. + mechanism for setting the rounding mode, or for generating or handling
  5079. + exceptions.
  5080. +
  5081. + The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
  5082. + Wilson, all of Cygnus Support. */
  5083. +
  5084. +/* The intended way to use this file is to make two copies, add `#define FLOAT'
  5085. + to one copy, then compile both copies and add them to libgcc.a. */
  5086. +
  5087. +#include "tconfig.h"
  5088. +#include "coretypes.h"
  5089. +#include "tm.h"
  5090. +#include "config/fp-bit.h"
  5091. +
  5092. +/* The following macros can be defined to change the behavior of this file:
  5093. + FLOAT: Implement a `float', aka SFmode, fp library. If this is not
  5094. + defined, then this file implements a `double', aka DFmode, fp library.
  5095. + FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
  5096. + don't include float->double conversion which requires the double library.
  5097. + This is useful only for machines which can't support doubles, e.g. some
  5098. + 8-bit processors.
  5099. + CMPtype: Specify the type that floating point compares should return.
  5100. + This defaults to SItype, aka int.
  5101. + US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
  5102. + US Software goFast library.
  5103. + _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
  5104. + two integers to the FLO_union_type.
  5105. + NO_DENORMALS: Disable handling of denormals.
  5106. + NO_NANS: Disable nan and infinity handling
  5107. + SMALL_MACHINE: Useful when operations on QIs and HIs are faster
  5108. + than on an SI */
  5109. +
  5110. +/* We don't currently support extended floats (long doubles) on machines
  5111. + without hardware to deal with them.
  5112. +
  5113. + These stubs are just to keep the linker from complaining about unresolved
  5114. + references which can be pulled in from libio & libstdc++, even if the
  5115. + user isn't using long doubles. However, they may generate an unresolved
  5116. + external to abort if abort is not used by the function, and the stubs
  5117. + are referenced from within libc, since libgcc goes before and after the
  5118. + system library. */
  5119. +
  5120. +#ifdef DECLARE_LIBRARY_RENAMES
  5121. + DECLARE_LIBRARY_RENAMES
  5122. +#endif
  5123. +
  5124. +#ifdef EXTENDED_FLOAT_STUBS
  5125. +extern void abort (void);
  5126. +void __extendsfxf2 (void) { abort(); }
  5127. +void __extenddfxf2 (void) { abort(); }
  5128. +void __truncxfdf2 (void) { abort(); }
  5129. +void __truncxfsf2 (void) { abort(); }
  5130. +void __fixxfsi (void) { abort(); }
  5131. +void __floatsixf (void) { abort(); }
  5132. +void __addxf3 (void) { abort(); }
  5133. +void __subxf3 (void) { abort(); }
  5134. +void __mulxf3 (void) { abort(); }
  5135. +void __divxf3 (void) { abort(); }
  5136. +void __negxf2 (void) { abort(); }
  5137. +void __eqxf2 (void) { abort(); }
  5138. +void __nexf2 (void) { abort(); }
  5139. +void __gtxf2 (void) { abort(); }
  5140. +void __gexf2 (void) { abort(); }
  5141. +void __lexf2 (void) { abort(); }
  5142. +void __ltxf2 (void) { abort(); }
  5143. +
  5144. +void __extendsftf2 (void) { abort(); }
  5145. +void __extenddftf2 (void) { abort(); }
  5146. +void __trunctfdf2 (void) { abort(); }
  5147. +void __trunctfsf2 (void) { abort(); }
  5148. +void __fixtfsi (void) { abort(); }
  5149. +void __floatsitf (void) { abort(); }
  5150. +void __addtf3 (void) { abort(); }
  5151. +void __subtf3 (void) { abort(); }
  5152. +void __multf3 (void) { abort(); }
  5153. +void __divtf3 (void) { abort(); }
  5154. +void __negtf2 (void) { abort(); }
  5155. +void __eqtf2 (void) { abort(); }
  5156. +void __netf2 (void) { abort(); }
  5157. +void __gttf2 (void) { abort(); }
  5158. +void __getf2 (void) { abort(); }
  5159. +void __letf2 (void) { abort(); }
  5160. +void __lttf2 (void) { abort(); }
  5161. +#else /* !EXTENDED_FLOAT_STUBS, rest of file */
  5162. +
  5163. +/* IEEE "special" number predicates */
  5164. +
  5165. +#ifdef NO_NANS
  5166. +
  5167. +#define nan() 0
  5168. +#define isnan(x) 0
  5169. +#define isinf(x) 0
  5170. +#else
  5171. +
  5172. +#if defined L_thenan_sf
  5173. +const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
  5174. +#elif defined L_thenan_df
  5175. +const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
  5176. +#elif defined L_thenan_tf
  5177. +const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
  5178. +#elif defined TFLOAT
  5179. +extern const fp_number_type __thenan_tf;
  5180. +#elif defined FLOAT
  5181. +extern const fp_number_type __thenan_sf;
  5182. +#else
  5183. +extern const fp_number_type __thenan_df;
  5184. +#endif
  5185. +
  5186. +INLINE
  5187. +static fp_number_type *
  5188. +nan (void)
  5189. +{
  5190. + /* Discard the const qualifier... */
  5191. +#ifdef TFLOAT
  5192. + return (fp_number_type *) (& __thenan_tf);
  5193. +#elif defined FLOAT
  5194. + return (fp_number_type *) (& __thenan_sf);
  5195. +#else
  5196. + return (fp_number_type *) (& __thenan_df);
  5197. +#endif
  5198. +}
  5199. +
  5200. +INLINE
  5201. +static int
  5202. +isnan ( fp_number_type * x)
  5203. +{
  5204. + return __builtin_expect (x->class == CLASS_SNAN || x->class == CLASS_QNAN,
  5205. + 0);
  5206. +}
  5207. +
  5208. +INLINE
  5209. +static int
  5210. +isinf ( fp_number_type * x)
  5211. +{
  5212. + return __builtin_expect (x->class == CLASS_INFINITY, 0);
  5213. +}
  5214. +
  5215. +#endif /* NO_NANS */
  5216. +
  5217. +INLINE
  5218. +static int
  5219. +iszero ( fp_number_type * x)
  5220. +{
  5221. + return x->class == CLASS_ZERO;
  5222. +}
  5223. +
  5224. +INLINE
  5225. +static void
  5226. +flip_sign ( fp_number_type * x)
  5227. +{
  5228. + x->sign = !x->sign;
  5229. +}
  5230. +
  5231. +/* Count leading zeroes in N. */
  5232. +INLINE
  5233. +static int
  5234. +clzusi (USItype n)
  5235. +{
  5236. + extern int __clzsi2 (USItype);
  5237. + if (sizeof (USItype) == sizeof (unsigned int))
  5238. + return __builtin_clz (n);
  5239. + else if (sizeof (USItype) == sizeof (unsigned long))
  5240. + return __builtin_clzl (n);
  5241. + else if (sizeof (USItype) == sizeof (unsigned long long))
  5242. + return __builtin_clzll (n);
  5243. + else
  5244. + return __clzsi2 (n);
  5245. +}
  5246. +
  5247. +extern FLO_type pack_d ( fp_number_type * );
  5248. +
  5249. +#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
  5250. +FLO_type
  5251. +pack_d ( fp_number_type * src)
  5252. +{
  5253. + FLO_union_type dst;
  5254. + fractype fraction = src->fraction.ll; /* wasn't unsigned before? */
  5255. + int sign = src->sign;
  5256. + int exp = 0;
  5257. +
  5258. + if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
  5259. + {
  5260. + /* We can't represent these values accurately. By using the
  5261. + largest possible magnitude, we guarantee that the conversion
  5262. + of infinity is at least as big as any finite number. */
  5263. + exp = EXPMAX;
  5264. + fraction = ((fractype) 1 << FRACBITS) - 1;
  5265. + }
  5266. + else if (isnan (src))
  5267. + {
  5268. + exp = EXPMAX;
  5269. + if (src->class == CLASS_QNAN || 1)
  5270. + {
  5271. +#ifdef QUIET_NAN_NEGATED
  5272. + fraction |= QUIET_NAN - 1;
  5273. +#else
  5274. + fraction |= QUIET_NAN;
  5275. +#endif
  5276. + }
  5277. + }
  5278. + else if (isinf (src))
  5279. + {
  5280. + exp = EXPMAX;
  5281. + fraction = 0;
  5282. + }
  5283. + else if (iszero (src))
  5284. + {
  5285. + exp = 0;
  5286. + fraction = 0;
  5287. + }
  5288. + else if (fraction == 0)
  5289. + {
  5290. + exp = 0;
  5291. + }
  5292. + else
  5293. + {
  5294. + if (__builtin_expect (src->normal_exp < NORMAL_EXPMIN, 0))
  5295. + {
  5296. +#ifdef NO_DENORMALS
  5297. + /* Go straight to a zero representation if denormals are not
  5298. + supported. The denormal handling would be harmless but
  5299. + isn't unnecessary. */
  5300. + exp = 0;
  5301. + fraction = 0;
  5302. +#else /* NO_DENORMALS */
  5303. + /* This number's exponent is too low to fit into the bits
  5304. + available in the number, so we'll store 0 in the exponent and
  5305. + shift the fraction to the right to make up for it. */
  5306. +
  5307. + int shift = NORMAL_EXPMIN - src->normal_exp;
  5308. +
  5309. + exp = 0;
  5310. +
  5311. + if (shift > FRAC_NBITS - NGARDS)
  5312. + {
  5313. + /* No point shifting, since it's more that 64 out. */
  5314. + fraction = 0;
  5315. + }
  5316. + else
  5317. + {
  5318. + int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
  5319. + fraction = (fraction >> shift) | lowbit;
  5320. + }
  5321. + if ((fraction & GARDMASK) == GARDMSB)
  5322. + {
  5323. + if ((fraction & (1 << NGARDS)))
  5324. + fraction += GARDROUND + 1;
  5325. + }
  5326. + else
  5327. + {
  5328. + /* Add to the guards to round up. */
  5329. + fraction += GARDROUND;
  5330. + }
  5331. + /* Perhaps the rounding means we now need to change the
  5332. + exponent, because the fraction is no longer denormal. */
  5333. + if (fraction >= IMPLICIT_1)
  5334. + {
  5335. + exp += 1;
  5336. + }
  5337. + fraction >>= NGARDS;
  5338. +#endif /* NO_DENORMALS */
  5339. + }
  5340. + else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
  5341. + && __builtin_expect (src->normal_exp > EXPBIAS, 0))
  5342. + {
  5343. + exp = EXPMAX;
  5344. + fraction = 0;
  5345. + }
  5346. + else
  5347. + {
  5348. + exp = src->normal_exp + EXPBIAS;
  5349. + if (!ROUND_TOWARDS_ZERO)
  5350. + {
  5351. + /* IF the gard bits are the all zero, but the first, then we're
  5352. + half way between two numbers, choose the one which makes the
  5353. + lsb of the answer 0. */
  5354. + if ((fraction & GARDMASK) == GARDMSB)
  5355. + {
  5356. + if (fraction & (1 << NGARDS))
  5357. + fraction += GARDROUND + 1;
  5358. + }
  5359. + else
  5360. + {
  5361. + /* Add a one to the guards to round up */
  5362. + fraction += GARDROUND;
  5363. + }
  5364. + if (fraction >= IMPLICIT_2)
  5365. + {
  5366. + fraction >>= 1;
  5367. + exp += 1;
  5368. + }
  5369. + }
  5370. + fraction >>= NGARDS;
  5371. +
  5372. + if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
  5373. + {
  5374. + /* Saturate on overflow. */
  5375. + exp = EXPMAX;
  5376. + fraction = ((fractype) 1 << FRACBITS) - 1;
  5377. + }
  5378. + }
  5379. + }
  5380. +
  5381. + /* We previously used bitfields to store the number, but this doesn't
  5382. + handle little/big endian systems conveniently, so use shifts and
  5383. + masks */
  5384. +#ifdef FLOAT_BIT_ORDER_MISMATCH
  5385. + dst.bits.fraction = fraction;
  5386. + dst.bits.exp = exp;
  5387. + dst.bits.sign = sign;
  5388. +#else
  5389. +# if defined TFLOAT && defined HALFFRACBITS
  5390. + {
  5391. + halffractype high, low, unity;
  5392. + int lowsign, lowexp;
  5393. +
  5394. + unity = (halffractype) 1 << HALFFRACBITS;
  5395. +
  5396. + /* Set HIGH to the high double's significand, masking out the implicit 1.
  5397. + Set LOW to the low double's full significand. */
  5398. + high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
  5399. + low = fraction & (unity * 2 - 1);
  5400. +
  5401. + /* Get the initial sign and exponent of the low double. */
  5402. + lowexp = exp - HALFFRACBITS - 1;
  5403. + lowsign = sign;
  5404. +
  5405. + /* HIGH should be rounded like a normal double, making |LOW| <=
  5406. + 0.5 ULP of HIGH. Assume round-to-nearest. */
  5407. + if (exp < EXPMAX)
  5408. + if (low > unity || (low == unity && (high & 1) == 1))
  5409. + {
  5410. + /* Round HIGH up and adjust LOW to match. */
  5411. + high++;
  5412. + if (high == unity)
  5413. + {
  5414. + /* May make it infinite, but that's OK. */
  5415. + high = 0;
  5416. + exp++;
  5417. + }
  5418. + low = unity * 2 - low;
  5419. + lowsign ^= 1;
  5420. + }
  5421. +
  5422. + high |= (halffractype) exp << HALFFRACBITS;
  5423. + high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
  5424. +
  5425. + if (exp == EXPMAX || exp == 0 || low == 0)
  5426. + low = 0;
  5427. + else
  5428. + {
  5429. + while (lowexp > 0 && low < unity)
  5430. + {
  5431. + low <<= 1;
  5432. + lowexp--;
  5433. + }
  5434. +
  5435. + if (lowexp <= 0)
  5436. + {
  5437. + halffractype roundmsb, round;
  5438. + int shift;
  5439. +
  5440. + shift = 1 - lowexp;
  5441. + roundmsb = (1 << (shift - 1));
  5442. + round = low & ((roundmsb << 1) - 1);
  5443. +
  5444. + low >>= shift;
  5445. + lowexp = 0;
  5446. +
  5447. + if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
  5448. + {
  5449. + low++;
  5450. + if (low == unity)
  5451. + /* LOW rounds up to the smallest normal number. */
  5452. + lowexp++;
  5453. + }
  5454. + }
  5455. +
  5456. + low &= unity - 1;
  5457. + low |= (halffractype) lowexp << HALFFRACBITS;
  5458. + low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
  5459. + }
  5460. + dst.value_raw = ((fractype) high << HALFSHIFT) | low;
  5461. + }
  5462. +# else
  5463. + dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
  5464. + dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
  5465. + dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
  5466. +# endif
  5467. +#endif
  5468. +
  5469. +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
  5470. +#ifdef TFLOAT
  5471. + {
  5472. + qrtrfractype tmp1 = dst.words[0];
  5473. + qrtrfractype tmp2 = dst.words[1];
  5474. + dst.words[0] = dst.words[3];
  5475. + dst.words[1] = dst.words[2];
  5476. + dst.words[2] = tmp2;
  5477. + dst.words[3] = tmp1;
  5478. + }
  5479. +#else
  5480. + {
  5481. + halffractype tmp = dst.words[0];
  5482. + dst.words[0] = dst.words[1];
  5483. + dst.words[1] = tmp;
  5484. + }
  5485. +#endif
  5486. +#endif
  5487. +
  5488. + return dst.value;
  5489. +}
  5490. +#endif
  5491. +
  5492. +#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
  5493. +void
  5494. +unpack_d (FLO_union_type * src, fp_number_type * dst)
  5495. +{
  5496. + /* We previously used bitfields to store the number, but this doesn't
  5497. + handle little/big endian systems conveniently, so use shifts and
  5498. + masks */
  5499. + fractype fraction;
  5500. + int exp;
  5501. + int sign;
  5502. +
  5503. +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
  5504. + FLO_union_type swapped;
  5505. +
  5506. +#ifdef TFLOAT
  5507. + swapped.words[0] = src->words[3];
  5508. + swapped.words[1] = src->words[2];
  5509. + swapped.words[2] = src->words[1];
  5510. + swapped.words[3] = src->words[0];
  5511. +#else
  5512. + swapped.words[0] = src->words[1];
  5513. + swapped.words[1] = src->words[0];
  5514. +#endif
  5515. + src = &swapped;
  5516. +#endif
  5517. +
  5518. +#ifdef FLOAT_BIT_ORDER_MISMATCH
  5519. + fraction = src->bits.fraction;
  5520. + exp = src->bits.exp;
  5521. + sign = src->bits.sign;
  5522. +#else
  5523. +# if defined TFLOAT && defined HALFFRACBITS
  5524. + {
  5525. + halffractype high, low;
  5526. +
  5527. + high = src->value_raw >> HALFSHIFT;
  5528. + low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
  5529. +
  5530. + fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
  5531. + fraction <<= FRACBITS - HALFFRACBITS;
  5532. + exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
  5533. + sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
  5534. +
  5535. + if (exp != EXPMAX && exp != 0 && low != 0)
  5536. + {
  5537. + int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
  5538. + int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
  5539. + int shift;
  5540. + fractype xlow;
  5541. +
  5542. + xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
  5543. + if (lowexp)
  5544. + xlow |= (((halffractype)1) << HALFFRACBITS);
  5545. + else
  5546. + lowexp = 1;
  5547. + shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
  5548. + if (shift > 0)
  5549. + xlow <<= shift;
  5550. + else if (shift < 0)
  5551. + xlow >>= -shift;
  5552. + if (sign == lowsign)
  5553. + fraction += xlow;
  5554. + else if (fraction >= xlow)
  5555. + fraction -= xlow;
  5556. + else
  5557. + {
  5558. + /* The high part is a power of two but the full number is lower.
  5559. + This code will leave the implicit 1 in FRACTION, but we'd
  5560. + have added that below anyway. */
  5561. + fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
  5562. + exp--;
  5563. + }
  5564. + }
  5565. + }
  5566. +# else
  5567. + fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
  5568. + exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
  5569. + sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
  5570. +# endif
  5571. +#endif
  5572. +
  5573. + dst->sign = sign;
  5574. + if (exp == 0)
  5575. + {
  5576. + /* Hmm. Looks like 0 */
  5577. + if (fraction == 0
  5578. +#ifdef NO_DENORMALS
  5579. + || 1
  5580. +#endif
  5581. + )
  5582. + {
  5583. + /* tastes like zero */
  5584. + dst->class = CLASS_ZERO;
  5585. + }
  5586. + else
  5587. + {
  5588. + /* Zero exponent with nonzero fraction - it's denormalized,
  5589. + so there isn't a leading implicit one - we'll shift it so
  5590. + it gets one. */
  5591. + dst->normal_exp = exp - EXPBIAS + 1;
  5592. + fraction <<= NGARDS;
  5593. +
  5594. + dst->class = CLASS_NUMBER;
  5595. +#if 1
  5596. + while (fraction < IMPLICIT_1)
  5597. + {
  5598. + fraction <<= 1;
  5599. + dst->normal_exp--;
  5600. + }
  5601. +#endif
  5602. + dst->fraction.ll = fraction;
  5603. + }
  5604. + }
  5605. + else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
  5606. + && __builtin_expect (exp == EXPMAX, 0))
  5607. + {
  5608. + /* Huge exponent*/
  5609. + if (fraction == 0)
  5610. + {
  5611. + /* Attached to a zero fraction - means infinity */
  5612. + dst->class = CLASS_INFINITY;
  5613. + }
  5614. + else
  5615. + {
  5616. + /* Nonzero fraction, means nan */
  5617. +#ifdef QUIET_NAN_NEGATED
  5618. + if ((fraction & QUIET_NAN) == 0)
  5619. +#else
  5620. + if (fraction & QUIET_NAN)
  5621. +#endif
  5622. + {
  5623. + dst->class = CLASS_QNAN;
  5624. + }
  5625. + else
  5626. + {
  5627. + dst->class = CLASS_SNAN;
  5628. + }
  5629. + /* Keep the fraction part as the nan number */
  5630. + dst->fraction.ll = fraction;
  5631. + }
  5632. + }
  5633. + else
  5634. + {
  5635. + /* Nothing strange about this number */
  5636. + dst->normal_exp = exp - EXPBIAS;
  5637. + dst->class = CLASS_NUMBER;
  5638. + dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
  5639. + }
  5640. +}
  5641. +#endif /* L_unpack_df || L_unpack_sf */
  5642. +
  5643. +#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
  5644. +static fp_number_type *
  5645. +_fpadd_parts (fp_number_type * a,
  5646. + fp_number_type * b,
  5647. + fp_number_type * tmp)
  5648. +{
  5649. + intfrac tfraction;
  5650. +
  5651. + /* Put commonly used fields in local variables. */
  5652. + int a_normal_exp;
  5653. + int b_normal_exp;
  5654. + fractype a_fraction;
  5655. + fractype b_fraction;
  5656. +
  5657. + if (isnan (a))
  5658. + {
  5659. + return a;
  5660. + }
  5661. + if (isnan (b))
  5662. + {
  5663. + return b;
  5664. + }
  5665. + if (isinf (a))
  5666. + {
  5667. + /* Adding infinities with opposite signs yields a NaN. */
  5668. + if (isinf (b) && a->sign != b->sign)
  5669. + return nan ();
  5670. + return a;
  5671. + }
  5672. + if (isinf (b))
  5673. + {
  5674. + return b;
  5675. + }
  5676. + if (iszero (b))
  5677. + {
  5678. + if (iszero (a))
  5679. + {
  5680. + *tmp = *a;
  5681. + tmp->sign = a->sign & b->sign;
  5682. + return tmp;
  5683. + }
  5684. + return a;
  5685. + }
  5686. + if (iszero (a))
  5687. + {
  5688. + return b;
  5689. + }
  5690. +
  5691. + /* Got two numbers. shift the smaller and increment the exponent till
  5692. + they're the same */
  5693. + {
  5694. + int diff;
  5695. + int sdiff;
  5696. +
  5697. + a_normal_exp = a->normal_exp;
  5698. + b_normal_exp = b->normal_exp;
  5699. + a_fraction = a->fraction.ll;
  5700. + b_fraction = b->fraction.ll;
  5701. +
  5702. + diff = a_normal_exp - b_normal_exp;
  5703. + sdiff = diff;
  5704. +
  5705. + if (diff < 0)
  5706. + diff = -diff;
  5707. + if (diff < FRAC_NBITS)
  5708. + {
  5709. + if (sdiff > 0)
  5710. + {
  5711. + b_normal_exp += diff;
  5712. + LSHIFT (b_fraction, diff);
  5713. + }
  5714. + else if (sdiff < 0)
  5715. + {
  5716. + a_normal_exp += diff;
  5717. + LSHIFT (a_fraction, diff);
  5718. + }
  5719. + }
  5720. + else
  5721. + {
  5722. + /* Somethings's up.. choose the biggest */
  5723. + if (a_normal_exp > b_normal_exp)
  5724. + {
  5725. + b_normal_exp = a_normal_exp;
  5726. + b_fraction = 0;
  5727. + }
  5728. + else
  5729. + {
  5730. + a_normal_exp = b_normal_exp;
  5731. + a_fraction = 0;
  5732. + }
  5733. + }
  5734. + }
  5735. +
  5736. + if (a->sign != b->sign)
  5737. + {
  5738. + if (a->sign)
  5739. + {
  5740. + tfraction = -a_fraction + b_fraction;
  5741. + }
  5742. + else
  5743. + {
  5744. + tfraction = a_fraction - b_fraction;
  5745. + }
  5746. + if (tfraction >= 0)
  5747. + {
  5748. + tmp->sign = 0;
  5749. + tmp->normal_exp = a_normal_exp;
  5750. + tmp->fraction.ll = tfraction;
  5751. + }
  5752. + else
  5753. + {
  5754. + tmp->sign = 1;
  5755. + tmp->normal_exp = a_normal_exp;
  5756. + tmp->fraction.ll = -tfraction;
  5757. + }
  5758. + /* and renormalize it */
  5759. +
  5760. + while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
  5761. + {
  5762. + tmp->fraction.ll <<= 1;
  5763. + tmp->normal_exp--;
  5764. + }
  5765. + }
  5766. + else
  5767. + {
  5768. + tmp->sign = a->sign;
  5769. + tmp->normal_exp = a_normal_exp;
  5770. + tmp->fraction.ll = a_fraction + b_fraction;
  5771. + }
  5772. + tmp->class = CLASS_NUMBER;
  5773. + /* Now the fraction is added, we have to shift down to renormalize the
  5774. + number */
  5775. +
  5776. + if (tmp->fraction.ll >= IMPLICIT_2)
  5777. + {
  5778. + LSHIFT (tmp->fraction.ll, 1);
  5779. + tmp->normal_exp++;
  5780. + }
  5781. + return tmp;
  5782. +
  5783. +}
  5784. +
  5785. +FLO_type
  5786. +add (FLO_type arg_a, FLO_type arg_b)
  5787. +{
  5788. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  5789. + fp_number_type a;
  5790. + fp_number_type b;
  5791. + fp_number_type tmp;
  5792. + fp_number_type *res;
  5793. + FLO_union_type au, bu;
  5794. +
  5795. + au.value = arg_a;
  5796. + bu.value = arg_b;
  5797. +
  5798. + unpack_d (&au, &a);
  5799. + unpack_d (&bu, &b);
  5800. +
  5801. + res = _fpadd_parts (&a, &b, &tmp);
  5802. +
  5803. + return pack_d (res);
  5804. +#else
  5805. + return arg_a + arg_b;
  5806. +#endif
  5807. +}
  5808. +
  5809. +FLO_type
  5810. +sub (FLO_type arg_a, FLO_type arg_b)
  5811. +{
  5812. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  5813. + fp_number_type a;
  5814. + fp_number_type b;
  5815. + fp_number_type tmp;
  5816. + fp_number_type *res;
  5817. + FLO_union_type au, bu;
  5818. +
  5819. + au.value = arg_a;
  5820. + bu.value = arg_b;
  5821. +
  5822. + unpack_d (&au, &a);
  5823. + unpack_d (&bu, &b);
  5824. +
  5825. + b.sign ^= 1;
  5826. +
  5827. + res = _fpadd_parts (&a, &b, &tmp);
  5828. +
  5829. + return pack_d (res);
  5830. +#else
  5831. + return arg_a - arg_b;
  5832. +#endif
  5833. +}
  5834. +#endif /* L_addsub_sf || L_addsub_df */
  5835. +
  5836. +#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
  5837. +static inline __attribute__ ((__always_inline__)) fp_number_type *
  5838. +_fpmul_parts ( fp_number_type * a,
  5839. + fp_number_type * b,
  5840. + fp_number_type * tmp)
  5841. +{
  5842. + fractype low = 0;
  5843. + fractype high = 0;
  5844. +
  5845. + if (isnan (a))
  5846. + {
  5847. + a->sign = a->sign != b->sign;
  5848. + return a;
  5849. + }
  5850. + if (isnan (b))
  5851. + {
  5852. + b->sign = a->sign != b->sign;
  5853. + return b;
  5854. + }
  5855. + if (isinf (a))
  5856. + {
  5857. + if (iszero (b))
  5858. + return nan ();
  5859. + a->sign = a->sign != b->sign;
  5860. + return a;
  5861. + }
  5862. + if (isinf (b))
  5863. + {
  5864. + if (iszero (a))
  5865. + {
  5866. + return nan ();
  5867. + }
  5868. + b->sign = a->sign != b->sign;
  5869. + return b;
  5870. + }
  5871. + if (iszero (a))
  5872. + {
  5873. + a->sign = a->sign != b->sign;
  5874. + return a;
  5875. + }
  5876. + if (iszero (b))
  5877. + {
  5878. + b->sign = a->sign != b->sign;
  5879. + return b;
  5880. + }
  5881. +
  5882. + /* Calculate the mantissa by multiplying both numbers to get a
  5883. + twice-as-wide number. */
  5884. + {
  5885. +#if defined(NO_DI_MODE) || defined(TFLOAT)
  5886. + {
  5887. + fractype x = a->fraction.ll;
  5888. + fractype ylow = b->fraction.ll;
  5889. + fractype yhigh = 0;
  5890. + int bit;
  5891. +
  5892. + /* ??? This does multiplies one bit at a time. Optimize. */
  5893. + for (bit = 0; bit < FRAC_NBITS; bit++)
  5894. + {
  5895. + int carry;
  5896. +
  5897. + if (x & 1)
  5898. + {
  5899. + carry = (low += ylow) < ylow;
  5900. + high += yhigh + carry;
  5901. + }
  5902. + yhigh <<= 1;
  5903. + if (ylow & FRACHIGH)
  5904. + {
  5905. + yhigh |= 1;
  5906. + }
  5907. + ylow <<= 1;
  5908. + x >>= 1;
  5909. + }
  5910. + }
  5911. +#elif defined(FLOAT)
  5912. + /* Multiplying two USIs to get a UDI, we're safe. */
  5913. + {
  5914. + UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
  5915. +
  5916. + high = answer >> BITS_PER_SI;
  5917. + low = answer;
  5918. + }
  5919. +#else
  5920. + /* fractype is DImode, but we need the result to be twice as wide.
  5921. + Assuming a widening multiply from DImode to TImode is not
  5922. + available, build one by hand. */
  5923. + {
  5924. + USItype nl = a->fraction.ll;
  5925. + USItype nh = a->fraction.ll >> BITS_PER_SI;
  5926. + USItype ml = b->fraction.ll;
  5927. + USItype mh = b->fraction.ll >> BITS_PER_SI;
  5928. + UDItype pp_ll = (UDItype) ml * nl;
  5929. + UDItype pp_hl = (UDItype) mh * nl;
  5930. + UDItype pp_lh = (UDItype) ml * nh;
  5931. + UDItype pp_hh = (UDItype) mh * nh;
  5932. + UDItype res2 = 0;
  5933. + UDItype res0 = 0;
  5934. + UDItype ps_hh__ = pp_hl + pp_lh;
  5935. + if (ps_hh__ < pp_hl)
  5936. + res2 += (UDItype)1 << BITS_PER_SI;
  5937. + pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
  5938. + res0 = pp_ll + pp_hl;
  5939. + if (res0 < pp_ll)
  5940. + res2++;
  5941. + res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
  5942. + high = res2;
  5943. + low = res0;
  5944. + }
  5945. +#endif
  5946. + }
  5947. +
  5948. + tmp->normal_exp = a->normal_exp + b->normal_exp
  5949. + + FRAC_NBITS - (FRACBITS + NGARDS);
  5950. + tmp->sign = a->sign != b->sign;
  5951. + while (high >= IMPLICIT_2)
  5952. + {
  5953. + tmp->normal_exp++;
  5954. + if (high & 1)
  5955. + {
  5956. + low >>= 1;
  5957. + low |= FRACHIGH;
  5958. + }
  5959. + high >>= 1;
  5960. + }
  5961. + while (high < IMPLICIT_1)
  5962. + {
  5963. + tmp->normal_exp--;
  5964. +
  5965. + high <<= 1;
  5966. + if (low & FRACHIGH)
  5967. + high |= 1;
  5968. + low <<= 1;
  5969. + }
  5970. +
  5971. + if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
  5972. + {
  5973. + if (high & (1 << NGARDS))
  5974. + {
  5975. + /* Because we're half way, we would round to even by adding
  5976. + GARDROUND + 1, except that's also done in the packing
  5977. + function, and rounding twice will lose precision and cause
  5978. + the result to be too far off. Example: 32-bit floats with
  5979. + bit patterns 0xfff * 0x3f800400 ~= 0xfff (less than 0.5ulp
  5980. + off), not 0x1000 (more than 0.5ulp off). */
  5981. + }
  5982. + else if (low)
  5983. + {
  5984. + /* We're a further than half way by a small amount corresponding
  5985. + to the bits set in "low". Knowing that, we round here and
  5986. + not in pack_d, because there we don't have "low" available
  5987. + anymore. */
  5988. + high += GARDROUND + 1;
  5989. +
  5990. + /* Avoid further rounding in pack_d. */
  5991. + high &= ~(fractype) GARDMASK;
  5992. + }
  5993. + }
  5994. + tmp->fraction.ll = high;
  5995. + tmp->class = CLASS_NUMBER;
  5996. + return tmp;
  5997. +}
  5998. +
  5999. +FLO_type
  6000. +multiply (FLO_type arg_a, FLO_type arg_b)
  6001. +{
  6002. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6003. + fp_number_type a;
  6004. + fp_number_type b;
  6005. + fp_number_type tmp;
  6006. + fp_number_type *res;
  6007. + FLO_union_type au, bu;
  6008. +
  6009. + au.value = arg_a;
  6010. + bu.value = arg_b;
  6011. +
  6012. + unpack_d (&au, &a);
  6013. + unpack_d (&bu, &b);
  6014. +
  6015. + res = _fpmul_parts (&a, &b, &tmp);
  6016. +
  6017. + return pack_d (res);
  6018. +#else
  6019. + return arg_a * arg_b;
  6020. +#endif
  6021. +}
  6022. +#endif /* L_mul_sf || L_mul_df || L_mul_tf */
  6023. +
  6024. +#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
  6025. +static inline __attribute__ ((__always_inline__)) fp_number_type *
  6026. +_fpdiv_parts (fp_number_type * a,
  6027. + fp_number_type * b)
  6028. +{
  6029. + fractype bit;
  6030. + fractype numerator;
  6031. + fractype denominator;
  6032. + fractype quotient;
  6033. +
  6034. + if (isnan (a))
  6035. + {
  6036. + return a;
  6037. + }
  6038. + if (isnan (b))
  6039. + {
  6040. + return b;
  6041. + }
  6042. +
  6043. + a->sign = a->sign ^ b->sign;
  6044. +
  6045. + if (isinf (a) || iszero (a))
  6046. + {
  6047. + if (a->class == b->class)
  6048. + return nan ();
  6049. + return a;
  6050. + }
  6051. +
  6052. + if (isinf (b))
  6053. + {
  6054. + a->fraction.ll = 0;
  6055. + a->normal_exp = 0;
  6056. + return a;
  6057. + }
  6058. + if (iszero (b))
  6059. + {
  6060. + a->class = CLASS_INFINITY;
  6061. + return a;
  6062. + }
  6063. +
  6064. + /* Calculate the mantissa by multiplying both 64bit numbers to get a
  6065. + 128 bit number */
  6066. + {
  6067. + /* quotient =
  6068. + ( numerator / denominator) * 2^(numerator exponent - denominator exponent)
  6069. + */
  6070. +
  6071. + a->normal_exp = a->normal_exp - b->normal_exp;
  6072. + numerator = a->fraction.ll;
  6073. + denominator = b->fraction.ll;
  6074. +
  6075. + if (numerator < denominator)
  6076. + {
  6077. + /* Fraction will be less than 1.0 */
  6078. + numerator *= 2;
  6079. + a->normal_exp--;
  6080. + }
  6081. + bit = IMPLICIT_1;
  6082. + quotient = 0;
  6083. + /* ??? Does divide one bit at a time. Optimize. */
  6084. + while (bit)
  6085. + {
  6086. + if (numerator >= denominator)
  6087. + {
  6088. + quotient |= bit;
  6089. + numerator -= denominator;
  6090. + }
  6091. + bit >>= 1;
  6092. + numerator *= 2;
  6093. + }
  6094. +
  6095. + if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
  6096. + {
  6097. + if (quotient & (1 << NGARDS))
  6098. + {
  6099. + /* Because we're half way, we would round to even by adding
  6100. + GARDROUND + 1, except that's also done in the packing
  6101. + function, and rounding twice will lose precision and cause
  6102. + the result to be too far off. */
  6103. + }
  6104. + else if (numerator)
  6105. + {
  6106. + /* We're a further than half way by the small amount
  6107. + corresponding to the bits set in "numerator". Knowing
  6108. + that, we round here and not in pack_d, because there we
  6109. + don't have "numerator" available anymore. */
  6110. + quotient += GARDROUND + 1;
  6111. +
  6112. + /* Avoid further rounding in pack_d. */
  6113. + quotient &= ~(fractype) GARDMASK;
  6114. + }
  6115. + }
  6116. +
  6117. + a->fraction.ll = quotient;
  6118. + return (a);
  6119. + }
  6120. +}
  6121. +
  6122. +FLO_type
  6123. +divide (FLO_type arg_a, FLO_type arg_b)
  6124. +{
  6125. + fp_number_type a;
  6126. + fp_number_type b;
  6127. + fp_number_type *res;
  6128. + FLO_union_type au, bu;
  6129. +
  6130. + au.value = arg_a;
  6131. + bu.value = arg_b;
  6132. +
  6133. + unpack_d (&au, &a);
  6134. + unpack_d (&bu, &b);
  6135. +
  6136. + res = _fpdiv_parts (&a, &b);
  6137. +
  6138. + return pack_d (res);
  6139. +}
  6140. +#endif /* L_div_sf || L_div_df */
  6141. +
  6142. +#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
  6143. + || defined(L_fpcmp_parts_tf)
  6144. +/* according to the demo, fpcmp returns a comparison with 0... thus
  6145. + a<b -> -1
  6146. + a==b -> 0
  6147. + a>b -> +1
  6148. + */
  6149. +
  6150. +int
  6151. +__fpcmp_parts (fp_number_type * a, fp_number_type * b)
  6152. +{
  6153. +#if 0
  6154. + /* either nan -> unordered. Must be checked outside of this routine. */
  6155. + if (isnan (a) && isnan (b))
  6156. + {
  6157. + return 1; /* still unordered! */
  6158. + }
  6159. +#endif
  6160. +
  6161. + if (isnan (a) || isnan (b))
  6162. + {
  6163. + return 1; /* how to indicate unordered compare? */
  6164. + }
  6165. + if (isinf (a) && isinf (b))
  6166. + {
  6167. + /* +inf > -inf, but +inf != +inf */
  6168. + /* b \a| +inf(0)| -inf(1)
  6169. + ______\+--------+--------
  6170. + +inf(0)| a==b(0)| a<b(-1)
  6171. + -------+--------+--------
  6172. + -inf(1)| a>b(1) | a==b(0)
  6173. + -------+--------+--------
  6174. + So since unordered must be nonzero, just line up the columns...
  6175. + */
  6176. + return b->sign - a->sign;
  6177. + }
  6178. + /* but not both... */
  6179. + if (isinf (a))
  6180. + {
  6181. + return a->sign ? -1 : 1;
  6182. + }
  6183. + if (isinf (b))
  6184. + {
  6185. + return b->sign ? 1 : -1;
  6186. + }
  6187. + if (iszero (a) && iszero (b))
  6188. + {
  6189. + return 0;
  6190. + }
  6191. + if (iszero (a))
  6192. + {
  6193. + return b->sign ? 1 : -1;
  6194. + }
  6195. + if (iszero (b))
  6196. + {
  6197. + return a->sign ? -1 : 1;
  6198. + }
  6199. + /* now both are "normal". */
  6200. + if (a->sign != b->sign)
  6201. + {
  6202. + /* opposite signs */
  6203. + return a->sign ? -1 : 1;
  6204. + }
  6205. + /* same sign; exponents? */
  6206. + if (a->normal_exp > b->normal_exp)
  6207. + {
  6208. + return a->sign ? -1 : 1;
  6209. + }
  6210. + if (a->normal_exp < b->normal_exp)
  6211. + {
  6212. + return a->sign ? 1 : -1;
  6213. + }
  6214. + /* same exponents; check size. */
  6215. + if (a->fraction.ll > b->fraction.ll)
  6216. + {
  6217. + return a->sign ? -1 : 1;
  6218. + }
  6219. + if (a->fraction.ll < b->fraction.ll)
  6220. + {
  6221. + return a->sign ? 1 : -1;
  6222. + }
  6223. + /* after all that, they're equal. */
  6224. + return 0;
  6225. +}
  6226. +#endif
  6227. +
  6228. +#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
  6229. +CMPtype
  6230. +compare (FLO_type arg_a, FLO_type arg_b)
  6231. +{
  6232. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6233. + fp_number_type a;
  6234. + fp_number_type b;
  6235. + FLO_union_type au, bu;
  6236. +
  6237. + au.value = arg_a;
  6238. + bu.value = arg_b;
  6239. +
  6240. + unpack_d (&au, &a);
  6241. + unpack_d (&bu, &b);
  6242. +
  6243. + return __fpcmp_parts (&a, &b);
  6244. +#else
  6245. + if (arg_a < arg_b)
  6246. + return -1;
  6247. + else if (arg_a == arg_b)
  6248. + return 0;
  6249. + else
  6250. + return 1;
  6251. +#endif
  6252. +}
  6253. +#endif /* L_compare_sf || L_compare_df */
  6254. +
  6255. +#ifndef US_SOFTWARE_GOFAST
  6256. +
  6257. +/* These should be optimized for their specific tasks someday. */
  6258. +
  6259. +#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
  6260. +CMPtype
  6261. +_eq_f2 (FLO_type arg_a, FLO_type arg_b)
  6262. +{
  6263. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6264. + fp_number_type a;
  6265. + fp_number_type b;
  6266. + FLO_union_type au, bu;
  6267. +
  6268. + au.value = arg_a;
  6269. + bu.value = arg_b;
  6270. +
  6271. + unpack_d (&au, &a);
  6272. + unpack_d (&bu, &b);
  6273. +
  6274. + if (isnan (&a) || isnan (&b))
  6275. + return 1; /* false, truth == 0 */
  6276. +
  6277. + return __fpcmp_parts (&a, &b) ;
  6278. +#else
  6279. + return compare (arg_a, arg_b);
  6280. +#endif
  6281. +}
  6282. +#endif /* L_eq_sf || L_eq_df */
  6283. +
  6284. +#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
  6285. +CMPtype
  6286. +_ne_f2 (FLO_type arg_a, FLO_type arg_b)
  6287. +{
  6288. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6289. + fp_number_type a;
  6290. + fp_number_type b;
  6291. + FLO_union_type au, bu;
  6292. +
  6293. + au.value = arg_a;
  6294. + bu.value = arg_b;
  6295. +
  6296. + unpack_d (&au, &a);
  6297. + unpack_d (&bu, &b);
  6298. +
  6299. + if (isnan (&a) || isnan (&b))
  6300. + return 1; /* true, truth != 0 */
  6301. +
  6302. + return __fpcmp_parts (&a, &b) ;
  6303. +#else
  6304. + return compare (arg_a, arg_b);
  6305. +#endif
  6306. +}
  6307. +#endif /* L_ne_sf || L_ne_df */
  6308. +
  6309. +#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
  6310. +CMPtype
  6311. +_gt_f2 (FLO_type arg_a, FLO_type arg_b)
  6312. +{
  6313. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6314. + fp_number_type a;
  6315. + fp_number_type b;
  6316. + FLO_union_type au, bu;
  6317. +
  6318. + au.value = arg_a;
  6319. + bu.value = arg_b;
  6320. +
  6321. + unpack_d (&au, &a);
  6322. + unpack_d (&bu, &b);
  6323. +
  6324. + if (isnan (&a) || isnan (&b))
  6325. + return -1; /* false, truth > 0 */
  6326. +
  6327. + return __fpcmp_parts (&a, &b);
  6328. +#else
  6329. + if (__builtin_isnan (arg_a) || __builtin_isnan (arg_b))
  6330. + return -1;
  6331. +
  6332. + return compare (arg_a, arg_b);
  6333. +#endif
  6334. +}
  6335. +#endif /* L_gt_sf || L_gt_df */
  6336. +
  6337. +#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
  6338. +CMPtype
  6339. +_ge_f2 (FLO_type arg_a, FLO_type arg_b)
  6340. +{
  6341. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6342. + fp_number_type a;
  6343. + fp_number_type b;
  6344. + FLO_union_type au, bu;
  6345. +
  6346. + au.value = arg_a;
  6347. + bu.value = arg_b;
  6348. +
  6349. + unpack_d (&au, &a);
  6350. + unpack_d (&bu, &b);
  6351. +
  6352. + if (isnan (&a) || isnan (&b))
  6353. + return -1; /* false, truth >= 0 */
  6354. + return __fpcmp_parts (&a, &b) ;
  6355. +#else
  6356. + if (__builtin_isnan (arg_a) || __builtin_isnan (arg_b))
  6357. + return -1;
  6358. +
  6359. + return compare (arg_a, arg_b);
  6360. +#endif
  6361. +}
  6362. +#endif /* L_ge_sf || L_ge_df */
  6363. +
  6364. +#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
  6365. +CMPtype
  6366. +_lt_f2 (FLO_type arg_a, FLO_type arg_b)
  6367. +{
  6368. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6369. + fp_number_type a;
  6370. + fp_number_type b;
  6371. + FLO_union_type au, bu;
  6372. +
  6373. + au.value = arg_a;
  6374. + bu.value = arg_b;
  6375. +
  6376. + unpack_d (&au, &a);
  6377. + unpack_d (&bu, &b);
  6378. +
  6379. + if (isnan (&a) || isnan (&b))
  6380. + return 1; /* false, truth < 0 */
  6381. +
  6382. + return __fpcmp_parts (&a, &b);
  6383. +#else
  6384. + return compare (arg_a, arg_b);
  6385. +#endif
  6386. +}
  6387. +#endif /* L_lt_sf || L_lt_df */
  6388. +
  6389. +#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
  6390. +CMPtype
  6391. +_le_f2 (FLO_type arg_a, FLO_type arg_b)
  6392. +{
  6393. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6394. + fp_number_type a;
  6395. + fp_number_type b;
  6396. + FLO_union_type au, bu;
  6397. +
  6398. + au.value = arg_a;
  6399. + bu.value = arg_b;
  6400. +
  6401. + unpack_d (&au, &a);
  6402. + unpack_d (&bu, &b);
  6403. +
  6404. + if (isnan (&a) || isnan (&b))
  6405. + return 1; /* false, truth <= 0 */
  6406. +
  6407. + return __fpcmp_parts (&a, &b) ;
  6408. +#else
  6409. + return compare (arg_a, arg_b);
  6410. +#endif
  6411. +}
  6412. +#endif /* L_le_sf || L_le_df */
  6413. +
  6414. +#endif /* ! US_SOFTWARE_GOFAST */
  6415. +
  6416. +#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
  6417. +CMPtype
  6418. +_unord_f2 (FLO_type arg_a, FLO_type arg_b)
  6419. +{
  6420. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6421. + fp_number_type a;
  6422. + fp_number_type b;
  6423. + FLO_union_type au, bu;
  6424. +
  6425. + au.value = arg_a;
  6426. + bu.value = arg_b;
  6427. +
  6428. + unpack_d (&au, &a);
  6429. + unpack_d (&bu, &b);
  6430. +
  6431. + return (isnan (&a) || isnan (&b));
  6432. +#else
  6433. + return __builtin_isunordered (arg_a, arg_b);
  6434. +#endif
  6435. +}
  6436. +#endif /* L_unord_sf || L_unord_df */
  6437. +
  6438. +#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
  6439. +FLO_type
  6440. +si_to_float (SItype arg_a)
  6441. +{
  6442. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6443. + fp_number_type in;
  6444. +
  6445. + in.class = CLASS_NUMBER;
  6446. + in.sign = arg_a < 0;
  6447. + if (!arg_a)
  6448. + {
  6449. + in.class = CLASS_ZERO;
  6450. + }
  6451. + else
  6452. + {
  6453. + USItype uarg;
  6454. + int shift;
  6455. + in.normal_exp = FRACBITS + NGARDS;
  6456. + if (in.sign)
  6457. + {
  6458. + /* Special case for minint, since there is no +ve integer
  6459. + representation for it */
  6460. + if (arg_a == (- MAX_SI_INT - 1))
  6461. + {
  6462. + return (FLO_type)(- MAX_SI_INT - 1);
  6463. + }
  6464. + uarg = (-arg_a);
  6465. + }
  6466. + else
  6467. + uarg = arg_a;
  6468. +
  6469. + in.fraction.ll = uarg;
  6470. + shift = clzusi (uarg) - (BITS_PER_SI - 1 - FRACBITS - NGARDS);
  6471. + if (shift > 0)
  6472. + {
  6473. + in.fraction.ll <<= shift;
  6474. + in.normal_exp -= shift;
  6475. + }
  6476. + }
  6477. + return pack_d (&in);
  6478. +#else
  6479. + return (FLO_type)arg_a;
  6480. +#endif
  6481. +}
  6482. +#endif /* L_si_to_sf || L_si_to_df */
  6483. +
  6484. +#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
  6485. +FLO_type
  6486. +usi_to_float (USItype arg_a)
  6487. +{
  6488. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6489. + fp_number_type in;
  6490. +
  6491. + in.sign = 0;
  6492. + if (!arg_a)
  6493. + {
  6494. + in.class = CLASS_ZERO;
  6495. + }
  6496. + else
  6497. + {
  6498. + int shift;
  6499. + in.class = CLASS_NUMBER;
  6500. + in.normal_exp = FRACBITS + NGARDS;
  6501. + in.fraction.ll = arg_a;
  6502. +
  6503. + shift = clzusi (arg_a) - (BITS_PER_SI - 1 - FRACBITS - NGARDS);
  6504. + if (shift < 0)
  6505. + {
  6506. + fractype guard = in.fraction.ll & (((fractype)1 << -shift) - 1);
  6507. + in.fraction.ll >>= -shift;
  6508. + in.fraction.ll |= (guard != 0);
  6509. + in.normal_exp -= shift;
  6510. + }
  6511. + else if (shift > 0)
  6512. + {
  6513. + in.fraction.ll <<= shift;
  6514. + in.normal_exp -= shift;
  6515. + }
  6516. + }
  6517. + return pack_d (&in);
  6518. +#else
  6519. + return (FLO_type)arg_a;
  6520. +#endif
  6521. +}
  6522. +#endif
  6523. +
  6524. +#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
  6525. +SItype
  6526. +float_to_si (FLO_type arg_a)
  6527. +{
  6528. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6529. + fp_number_type a;
  6530. + SItype tmp;
  6531. + FLO_union_type au;
  6532. +
  6533. + au.value = arg_a;
  6534. + unpack_d (&au, &a);
  6535. +
  6536. + if (iszero (&a))
  6537. + return 0;
  6538. + if (isnan (&a))
  6539. + return 0;
  6540. + /* get reasonable MAX_SI_INT... */
  6541. + if (isinf (&a))
  6542. + return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
  6543. + /* it is a number, but a small one */
  6544. + if (a.normal_exp < 0)
  6545. + return 0;
  6546. + if (a.normal_exp > BITS_PER_SI - 2)
  6547. + return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
  6548. + tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
  6549. + return a.sign ? (-tmp) : (tmp);
  6550. +#else
  6551. + return (SItype)arg_a;
  6552. +#endif
  6553. +}
  6554. +#endif /* L_sf_to_si || L_df_to_si */
  6555. +
  6556. +#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
  6557. +#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
  6558. +/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
  6559. + we also define them for GOFAST because the ones in libgcc2.c have the
  6560. + wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
  6561. + out of libgcc2.c. We can't define these here if not GOFAST because then
  6562. + there'd be duplicate copies. */
  6563. +
  6564. +USItype
  6565. +float_to_usi (FLO_type arg_a)
  6566. +{
  6567. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6568. + fp_number_type a;
  6569. + FLO_union_type au;
  6570. +
  6571. + au.value = arg_a;
  6572. + unpack_d (&au, &a);
  6573. +
  6574. + if (iszero (&a))
  6575. + return 0;
  6576. + if (isnan (&a))
  6577. + return 0;
  6578. + /* it is a negative number */
  6579. + if (a.sign)
  6580. + return 0;
  6581. + /* get reasonable MAX_USI_INT... */
  6582. + if (isinf (&a))
  6583. + return MAX_USI_INT;
  6584. + /* it is a number, but a small one */
  6585. + if (a.normal_exp < 0)
  6586. + return 0;
  6587. + if (a.normal_exp > BITS_PER_SI - 1)
  6588. + return MAX_USI_INT;
  6589. + else if (a.normal_exp > (FRACBITS + NGARDS))
  6590. + return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
  6591. + else
  6592. + return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
  6593. +#else
  6594. + return (USItype)arg_a;
  6595. +#endif
  6596. +}
  6597. +#endif /* US_SOFTWARE_GOFAST */
  6598. +#endif /* L_sf_to_usi || L_df_to_usi */
  6599. +
  6600. +#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
  6601. +FLO_type
  6602. +negate (FLO_type arg_a)
  6603. +{
  6604. +#if defined(TFLOAT) || (!defined(FLOAT) && !defined(METAC_FPU_DOUBLE)) || !defined(METAC_FPU_FLOAT)
  6605. + fp_number_type a;
  6606. + FLO_union_type au;
  6607. +
  6608. + au.value = arg_a;
  6609. + unpack_d (&au, &a);
  6610. +
  6611. + flip_sign (&a);
  6612. + return pack_d (&a);
  6613. +#else
  6614. + return -arg_a;
  6615. +#endif
  6616. +}
  6617. +#endif /* L_negate_sf || L_negate_df */
  6618. +
  6619. +#ifdef FLOAT
  6620. +
  6621. +#if defined(L_make_sf)
  6622. +SFtype
  6623. +__make_fp(fp_class_type class,
  6624. + unsigned int sign,
  6625. + int exp,
  6626. + USItype frac)
  6627. +{
  6628. + fp_number_type in;
  6629. +
  6630. + in.class = class;
  6631. + in.sign = sign;
  6632. + in.normal_exp = exp;
  6633. + in.fraction.ll = frac;
  6634. + return pack_d (&in);
  6635. +}
  6636. +#endif /* L_make_sf */
  6637. +
  6638. +#ifndef FLOAT_ONLY
  6639. +
  6640. +/* This enables one to build an fp library that supports float but not double.
  6641. + Otherwise, we would get an undefined reference to __make_dp.
  6642. + This is needed for some 8-bit ports that can't handle well values that
  6643. + are 8-bytes in size, so we just don't support double for them at all. */
  6644. +
  6645. +#if defined(L_sf_to_df)
  6646. +DFtype
  6647. +sf_to_df (SFtype arg_a)
  6648. +{
  6649. +#if defined(TFLOAT) || !defined(METAC_FPU_DOUBLE)
  6650. + fp_number_type in;
  6651. + FLO_union_type au;
  6652. +
  6653. + au.value = arg_a;
  6654. + unpack_d (&au, &in);
  6655. +
  6656. + return __make_dp (in.class, in.sign, in.normal_exp,
  6657. + ((UDItype) in.fraction.ll) << F_D_BITOFF);
  6658. +#else
  6659. + return (DFtype)arg_a;
  6660. +#endif
  6661. +}
  6662. +#endif /* L_sf_to_df */
  6663. +
  6664. +#if defined(L_sf_to_tf) && defined(TMODES)
  6665. +TFtype
  6666. +sf_to_tf (SFtype arg_a)
  6667. +{
  6668. + fp_number_type in;
  6669. + FLO_union_type au;
  6670. +
  6671. + au.value = arg_a;
  6672. + unpack_d (&au, &in);
  6673. +
  6674. + return __make_tp (in.class, in.sign, in.normal_exp,
  6675. + ((UTItype) in.fraction.ll) << F_T_BITOFF);
  6676. +}
  6677. +#endif /* L_sf_to_df */
  6678. +
  6679. +#endif /* ! FLOAT_ONLY */
  6680. +#endif /* FLOAT */
  6681. +
  6682. +#ifndef FLOAT
  6683. +
  6684. +extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
  6685. +
  6686. +#if defined(L_make_df)
  6687. +DFtype
  6688. +__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
  6689. +{
  6690. + fp_number_type in;
  6691. +
  6692. + in.class = class;
  6693. + in.sign = sign;
  6694. + in.normal_exp = exp;
  6695. + in.fraction.ll = frac;
  6696. + return pack_d (&in);
  6697. +}
  6698. +#endif /* L_make_df */
  6699. +
  6700. +#if defined(L_df_to_sf)
  6701. +SFtype
  6702. +df_to_sf (DFtype arg_a)
  6703. +{
  6704. +#if defined(TFLOAT) || !defined(METAC_FPU_DOUBLE)
  6705. + fp_number_type in;
  6706. + USItype sffrac;
  6707. + FLO_union_type au;
  6708. +
  6709. + au.value = arg_a;
  6710. + unpack_d (&au, &in);
  6711. +
  6712. + sffrac = in.fraction.ll >> F_D_BITOFF;
  6713. +
  6714. + /* We set the lowest guard bit in SFFRAC if we discarded any non
  6715. + zero bits. */
  6716. + if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
  6717. + sffrac |= 1;
  6718. +
  6719. + return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
  6720. +#else
  6721. + return (SFtype)arg_a;
  6722. +#endif
  6723. +}
  6724. +#endif /* L_df_to_sf */
  6725. +
  6726. +#if defined(L_df_to_tf) && defined(TMODES) \
  6727. + && !defined(FLOAT) && !defined(TFLOAT)
  6728. +TFtype
  6729. +df_to_tf (DFtype arg_a)
  6730. +{
  6731. + fp_number_type in;
  6732. + FLO_union_type au;
  6733. +
  6734. + au.value = arg_a;
  6735. + unpack_d (&au, &in);
  6736. +
  6737. + return __make_tp (in.class, in.sign, in.normal_exp,
  6738. + ((UTItype) in.fraction.ll) << D_T_BITOFF);
  6739. +}
  6740. +#endif /* L_sf_to_df */
  6741. +
  6742. +#ifdef TFLOAT
  6743. +#if defined(L_make_tf)
  6744. +TFtype
  6745. +__make_tp(fp_class_type class,
  6746. + unsigned int sign,
  6747. + int exp,
  6748. + UTItype frac)
  6749. +{
  6750. + fp_number_type in;
  6751. +
  6752. + in.class = class;
  6753. + in.sign = sign;
  6754. + in.normal_exp = exp;
  6755. + in.fraction.ll = frac;
  6756. + return pack_d (&in);
  6757. +}
  6758. +#endif /* L_make_tf */
  6759. +
  6760. +#if defined(L_tf_to_df)
  6761. +DFtype
  6762. +tf_to_df (TFtype arg_a)
  6763. +{
  6764. + fp_number_type in;
  6765. + UDItype sffrac;
  6766. + FLO_union_type au;
  6767. +
  6768. + au.value = arg_a;
  6769. + unpack_d (&au, &in);
  6770. +
  6771. + sffrac = in.fraction.ll >> D_T_BITOFF;
  6772. +
  6773. + /* We set the lowest guard bit in SFFRAC if we discarded any non
  6774. + zero bits. */
  6775. + if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
  6776. + sffrac |= 1;
  6777. +
  6778. + return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
  6779. +}
  6780. +#endif /* L_tf_to_df */
  6781. +
  6782. +#if defined(L_tf_to_sf)
  6783. +SFtype
  6784. +tf_to_sf (TFtype arg_a)
  6785. +{
  6786. + fp_number_type in;
  6787. + USItype sffrac;
  6788. + FLO_union_type au;
  6789. +
  6790. + au.value = arg_a;
  6791. + unpack_d (&au, &in);
  6792. +
  6793. + sffrac = in.fraction.ll >> F_T_BITOFF;
  6794. +
  6795. + /* We set the lowest guard bit in SFFRAC if we discarded any non
  6796. + zero bits. */
  6797. + if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
  6798. + sffrac |= 1;
  6799. +
  6800. + return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
  6801. +}
  6802. +#endif /* L_tf_to_sf */
  6803. +#endif /* TFLOAT */
  6804. +
  6805. +#endif /* ! FLOAT */
  6806. +#endif /* !EXTENDED_FLOAT_STUBS */
  6807. diff -Nur gcc-4.2.4.orig/gcc/config/metag/fp.md gcc-4.2.4/gcc/config/metag/fp.md
  6808. --- gcc-4.2.4.orig/gcc/config/metag/fp.md 1969-12-31 18:00:00.000000000 -0600
  6809. +++ gcc-4.2.4/gcc/config/metag/fp.md 2015-07-03 18:46:05.745283542 -0500
  6810. @@ -0,0 +1,1037 @@
  6811. +;; Machine description for GNU compiler,
  6812. +;; Imagination Technologies Meta version.
  6813. +;; Copyright (C) 2008
  6814. +;; Imagination Technologies Ltd
  6815. +
  6816. +;; This file is part of GCC.
  6817. +
  6818. +;; GCC is free software; you can redistribute it and/or modify it under
  6819. +;; the terms of the GNU General Public License as published by the Free
  6820. +;; Software Foundation; either version 3, or (at your option) any later
  6821. +;; version.
  6822. +
  6823. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  6824. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  6825. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  6826. +;; for more details.
  6827. +
  6828. +;; You should have received a copy of the GNU General Public License
  6829. +;; along with GCC; see the file COPYING3. If not see
  6830. +;; <http://www.gnu.org/licenses/>.
  6831. +
  6832. +;;- instruction definitions
  6833. +
  6834. +;;- @@The original PO technology requires these to be ordered by speed,
  6835. +;;- @@ so that assigner will pick the fastest.
  6836. +
  6837. +;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  6838. +
  6839. +;;- When naming insn's (operand 0 of define_insn) be careful about using
  6840. +;;- names from other targets machine descriptions.
  6841. +
  6842. +
  6843. +
  6844. +(define_insn_and_split "*movv2sfrr"
  6845. + [(set (match_operand:V2SF 0 "metag_fpreg_or_dreg_op" "=cx,cx,d, d")
  6846. + (match_operand:V2SF 1 "metag_fpreg_or_dreg_op" "cx,d, cx,d"))]
  6847. + "TARGET_FPU_SIMD"
  6848. + "@
  6849. + FL\\tMOV\\t%0,%1\\t%@ (*mov v2sf rr)
  6850. + #
  6851. + #
  6852. + #"
  6853. + "&& reload_completed"
  6854. + [(set (match_dup 2)
  6855. + (match_dup 3))
  6856. + (set (match_dup 4)
  6857. + (match_dup 5))]
  6858. + {
  6859. + operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));
  6860. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]));
  6861. + operands[4] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  6862. + operands[5] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  6863. + }
  6864. + [(set_attr "type" "FPfast")])
  6865. +
  6866. +(define_insn_and_split "*movv2sfri"
  6867. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6868. + (match_operand:V2SF 1 "metag_vector_float_op" "vcf"))]
  6869. + "TARGET_FPU_SIMD"
  6870. + {
  6871. + if (rtx_equal_p (CONST_VECTOR_ELT (operands[1], 0),
  6872. + CONST_VECTOR_ELT (operands[1], 1)))
  6873. + return "FL\\tMOV\\t%0,#%h1";
  6874. + else
  6875. + return "#";
  6876. + }
  6877. + "&& reload_completed
  6878. + && !rtx_equal_p (CONST_VECTOR_ELT (operands[1], 0),
  6879. + CONST_VECTOR_ELT (operands[1], 1))"
  6880. + [(set (match_dup 2)
  6881. + (match_dup 4))
  6882. + (set (match_dup 3)
  6883. + (match_dup 5))]
  6884. + {
  6885. + operands[2] = gen_rtx_REG (SFmode, REGNO (operands[0]));
  6886. + operands[3] = gen_rtx_REG (SFmode, REGNO (operands[0]) + 1);
  6887. + operands[4] = CONST_VECTOR_ELT (operands[1], 0);
  6888. + operands[5] = CONST_VECTOR_ELT (operands[1], 1);
  6889. + }
  6890. + [(set_attr "type" "FPfast")])
  6891. +
  6892. +(define_expand "movv2sf"
  6893. + [(set (match_operand:V2SF 0 "nonimmediate_operand" "")
  6894. + (match_operand:V2SF 1 "general_operand" ""))]
  6895. + "TARGET_FPU_SIMD"
  6896. + {
  6897. + if (MEM_P (operands[0]) && !REG_P (operands[1]))
  6898. + {
  6899. + /* All except mem = const, mem = mem, or mem = addr can be done quickly */
  6900. + if (!no_new_pseudos)
  6901. + operands[1] = force_reg (V2SFmode, operands[1]);
  6902. + }
  6903. + else if (GET_CODE(operands[1]) == CONST_VECTOR)
  6904. + if ( (!metag_fphalf_imm_op (CONST_VECTOR_ELT (operands[1], 0), SFmode)
  6905. + || !metag_fphalf_imm_op (CONST_VECTOR_ELT (operands[1], 1), SFmode)))
  6906. + {
  6907. + emit_move_insn (gen_rtx_SUBREG (SFmode, operands[0], 0),
  6908. + CONST_VECTOR_ELT (operands[1], 0));
  6909. + emit_move_insn (gen_rtx_SUBREG (SFmode, operands[0], UNITS_PER_WORD),
  6910. + CONST_VECTOR_ELT (operands[1], 1));
  6911. + DONE;
  6912. + }
  6913. + }
  6914. +)
  6915. +
  6916. +;; -----------------------------------------------------------------------------
  6917. +;; | Matching V2SF load [post/pre]_[inc/dec/modify]
  6918. +;; -----------------------------------------------------------------------------
  6919. +
  6920. +(define_insn "*lod_v2sf_post_inc"
  6921. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6922. + (mem:V2SF (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  6923. + "TARGET_FPU_SIMD"
  6924. + "F\\tGETL\\t%0, %t0, [%1++]\\t%@ (*load V2SF post_inc OK)"
  6925. + [(set_attr "type" "load")])
  6926. +
  6927. +(define_insn "*lod_v2sf_post_dec"
  6928. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6929. + (mem:V2SF (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  6930. + "TARGET_FPU_SIMD"
  6931. + "F\\tGETL\\t%0, %t0, [%1--]\\t%@ (*load V2SF post_dec OK)"
  6932. + [(set_attr "type" "load")])
  6933. +
  6934. +(define_insn "*lod_v2sf_pre_inc"
  6935. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6936. + (mem:V2SF (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  6937. + "TARGET_FPU_SIMD"
  6938. + "F\\tGETL\\t%0, %t0, [++%1]\\t%@ (*load V2SF pre_inc OK)"
  6939. + [(set_attr "type" "load")])
  6940. +
  6941. +(define_insn "*lod_v2sf_pre_dec"
  6942. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6943. + (mem:V2SF (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  6944. + "TARGET_FPU_SIMD"
  6945. + "F\\tGETL\\t%0, %t0, [--%1]\\t%@ (*load V2SF pre_dec OK)"
  6946. + [(set_attr "type" "load")])
  6947. +
  6948. +(define_insn "*lod_v2sf_post_modify_disp"
  6949. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6950. + (mem:V2SF (post_modify:SI
  6951. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  6952. + (plus:SI (match_dup 1)
  6953. + (match_operand:SI 2 "metag_offset6_v2sf" "O8")))))]
  6954. + "TARGET_FPU_SIMD"
  6955. + "F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load V2SF post_modify_disp OK)"
  6956. + [(set_attr "type" "load")])
  6957. +
  6958. +(define_insn "*lod_v2sf_post_modify_reg"
  6959. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx,cx,cx,cx")
  6960. + (mem:V2SF (post_modify:SI
  6961. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  6962. + (plus:SI (match_dup 1)
  6963. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  6964. + "TARGET_FPU_SIMD"
  6965. + "F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load V2SF post_modify_reg OK)"
  6966. + [(set_attr "type" "load")])
  6967. +
  6968. +(define_insn "*lod_v2sf_pre_modify_disp"
  6969. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6970. + (mem:V2SF (pre_modify:SI
  6971. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  6972. + (plus:SI (match_dup 1)
  6973. + (match_operand:SI 2 "metag_offset6_v2sf" "O8")))))]
  6974. + "TARGET_FPU_SIMD"
  6975. + "F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load V2SF pre_modify_disp OK)"
  6976. + [(set_attr "type" "load")])
  6977. +
  6978. +(define_insn "*lod_v2sf_pre_modify_reg"
  6979. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx,cx,cx,cx")
  6980. + (mem:V2SF (pre_modify:SI
  6981. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  6982. + (plus:SI (match_dup 1)
  6983. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  6984. + "TARGET_FPU_SIMD"
  6985. + "F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load V2SF pre_modify_reg OK)"
  6986. + [(set_attr "type" "load")])
  6987. +
  6988. +;; -----------------------------------------------------------------------------
  6989. +
  6990. +(define_insn "*lod_v2sf_off6"
  6991. + [(set (match_operand:V2SF 0 "metag_fpreg_op" "=cx")
  6992. + (mem:V2SF (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  6993. + (match_operand:SI 2 "metag_offset6_v2sf" "O8"))))]
  6994. + "TARGET_FPU_SIMD"
  6995. + "F\\tGETL\\t%0, %t0, [%1+%2]"
  6996. + [(set_attr "type" "load")])
  6997. +
  6998. +(define_insn "*lod_v2sf_mem"
  6999. + [(set (match_operand:V2SF 0 "metag_datareg_op" "=d")
  7000. + (match_operand:V2SF 1 "memory_operand" "m"))]
  7001. + "TARGET_FPU_SIMD"
  7002. + "GETL\\t%0, %t0, %1\\t%@ (*lod v2sf rm OK)"
  7003. + [(set_attr "memaccess" "load")])
  7004. +
  7005. +;; -----------------------------------------------------------------------------
  7006. +;; | Matching V2SF store [post/pre]_[inc/dec/modify]
  7007. +;; -----------------------------------------------------------------------------
  7008. +
  7009. +(define_insn "*sto_v2sf_post_inc"
  7010. + [(set (mem:V2SF (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  7011. + (match_operand:V2SF 1 "metag_fpreg_op" "cx"))]
  7012. + "TARGET_FPU_SIMD"
  7013. + "F\\tSETL\\t[%0++], %1, %t1\\t%@ (*store V2SF post_inc OK)"
  7014. + [(set_attr "type" "fast")])
  7015. +
  7016. +(define_insn "*sto_v2sf_post_dec"
  7017. + [(set (mem:V2SF (post_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  7018. + (match_operand:V2SF 1 "metag_fpreg_op" "cx"))]
  7019. + "TARGET_FPU_SIMD"
  7020. + "F\\tSETL\\t[%0--], %1, %t1\\t%@ (*store V2SF post_dec OK)"
  7021. + [(set_attr "type" "fast")])
  7022. +
  7023. +(define_insn "*sto_v2sf_pre_inc"
  7024. + [(set (mem:V2SF (pre_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  7025. + (match_operand:V2SF 1 "metag_fpreg_op" "cx"))]
  7026. + "TARGET_FPU_SIMD"
  7027. + "F\\tSETL\\t[++%0], %1, %t1\\t%@ (*store V2SF pre_inc OK)"
  7028. + [(set_attr "type" "fast")])
  7029. +
  7030. +(define_insn "*sto_v2sf_pre_dec"
  7031. + [(set (mem:V2SF (pre_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  7032. + (match_operand:V2SF 1 "metag_fpreg_op" "cx"))]
  7033. + "TARGET_FPU_SIMD"
  7034. + "F\\tSETL\\t[--%0], %1, %t1\\t%@ (*store V2SF pre_dec OK)"
  7035. + [(set_attr "type" "fast")])
  7036. +
  7037. +(define_insn "*sto_v2sf_post_modify_disp"
  7038. + [(set (mem:V2SF (post_modify:SI
  7039. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  7040. + (plus:SI (match_dup 0)
  7041. + (match_operand:SI 1 "metag_offset6_v2sf" "O8"))))
  7042. + (match_operand:V2SF 2 "metag_fpreg_op" "cx"))]
  7043. + "TARGET_FPU_SIMD"
  7044. + "F\\tSETL\\t[%0+%1++], %2, %t2\\t%@ (*store V2SF post_modify_disp OK)"
  7045. + [(set_attr "type" "fast")])
  7046. +
  7047. +(define_insn "*sto_v2sf_post_modify_reg"
  7048. + [(set (mem:V2SF (post_modify:SI
  7049. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  7050. + (plus:SI (match_dup 0)
  7051. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  7052. + (match_operand:V2SF 2 "metag_fpreg_op" "cx,cx,cx,cx"))]
  7053. + "TARGET_FPU_SIMD"
  7054. + "F\\tSETL\\t[%0+%1++], %2, %t2\\t%@ (*store V2SF post_modify_reg OK)"
  7055. + [(set_attr "type" "fast")])
  7056. +
  7057. +(define_insn "*sto_v2sf_pre_modify_disp"
  7058. + [(set (mem:V2SF (pre_modify:SI
  7059. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  7060. + (plus:SI (match_dup 0)
  7061. + (match_operand:SI 1 "metag_offset6_v2sf" "O8"))))
  7062. + (match_operand:V2SF 2 "metag_fpreg_op" "cx"))]
  7063. + "TARGET_FPU_SIMD"
  7064. + "F\\tSETL\\t[%0++%1], %2, %t2\\t%@ (*store V2SF pre_modify_disp OK)"
  7065. + [(set_attr "type" "fast")])
  7066. +
  7067. +(define_insn "*sto_v2sf_pre_modify_reg"
  7068. + [(set (mem:V2SF (pre_modify:SI
  7069. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  7070. + (plus:SI (match_dup 0)
  7071. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  7072. + (match_operand:V2SF 2 "metag_fpreg_op" "cx,cx,cx,cx"))]
  7073. + "TARGET_FPU_SIMD"
  7074. + "F\\tSETL\\t[%0++%1], %2, %t2\\t%@ (*store V2SF pre_modify_reg OK)"
  7075. + [(set_attr "type" "fast")])
  7076. +
  7077. +;; -----------------------------------------------------------------------------
  7078. +
  7079. +(define_insn "*sto_v2sf_off6"
  7080. + [(set (mem:V2SF (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  7081. + (match_operand:SI 1 "metag_offset6_v2sf" "O8")))
  7082. + (match_operand:V2SF 2 "metag_fpreg_op" "cx"))]
  7083. + "TARGET_FPU_SIMD"
  7084. + "F\\tSETL\\t[%0+%1], %2, %t2"
  7085. + [(set_attr "type" "fast")])
  7086. +
  7087. +(define_insn "*sto_v2sf_mem"
  7088. + [(set (match_operand:V2SF 0 "memory_operand" "=m")
  7089. + (match_operand:V2SF 1 "metag_datareg_op" "d"))]
  7090. + "TARGET_FPU_SIMD"
  7091. + "SETL\\t%0, %1, %t1\\t%@ (*sto v2sf rm OK)"
  7092. + [(set_attr "type" "FPfast")])
  7093. +
  7094. +; Movement instructions
  7095. +
  7096. +(define_insn "abs<mode>2"
  7097. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7098. + (abs:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")))]
  7099. + "<fcondition>"
  7100. + "F<FW>\\tABS%?\\t%0,%1"
  7101. + [(set_attr "type" "FPmas")
  7102. + (set_attr "predicable" "yes")])
  7103. +
  7104. +;;(define_insn "*mmovsf_d_to_f"
  7105. +;; [(match_parallel 0 "metag_mmov_valid"
  7106. +;; [(set (match_operand:SF 1 "metag_fpreg_op" "=cx")
  7107. +;; (match_operand:SF 2 "metag_datareg_op" "d" ))
  7108. +;; (set (match_operand:SF 3 "metag_fpreg_op" "=cx")
  7109. +;; (match_operand:SF 4 "metag_datareg_op" "d" ))])]
  7110. +;; "TARGET_FPU"
  7111. +;; {
  7112. +;; switch (XVECLEN(operands[0], 0))
  7113. +;; {
  7114. +;; case 2:
  7115. +;; return "F\\tMMOV\\t%1,%3,%2,%4";
  7116. +;; case 3:
  7117. +;; return "F\\tMMOV\\t%1,%3,%5,%2,%4,%6";
  7118. +;; case 4:
  7119. +;; return "F\\tMMOV\\t%1,%3,%5,%7,%2,%4,%6,%8";
  7120. +;; case 5:
  7121. +;; return "F\\tMMOV\\t%1,%3,%5,%7,%9,%2,%4,%6,%8,%10";
  7122. +;; case 6:
  7123. +;; return "F\\tMMOV\\t%1,%3,%5,%7,%9,%11,%2,%4,%6,%8,%10,%12";
  7124. +;; case 7:
  7125. +;; return "F\\tMMOV\\t%1,%3,%5,%7,%9,%11,%13,%2,%4,%6,%8,%10,%12,%14";
  7126. +;; case 8:
  7127. +;; return "F\\tMMOV\\t%1,%3,%5,%7,%9,%11,%13,%15,%2,%4,%6,%8,%10,%12,%14,%16";
  7128. +;; default:
  7129. +;; gcc_unreachable ();
  7130. +;; }
  7131. +;; })
  7132. +
  7133. +(define_insn "*mov_<mode>_imm"
  7134. + [(set (match_operand:FMODES 0 "metag_fpreg_op" "=cx")
  7135. + (match_operand:<MODE> 1 "metag_fphalf_imm_op" "ci"))]
  7136. + "<fcondition>"
  7137. + "F<FW>\\tMOV\\t%0,#%h1"
  7138. + [(set_attr "type" "FPfast")])
  7139. +
  7140. +(define_insn "neg<mode>2"
  7141. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7142. + (neg:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")))]
  7143. + "<fcondition>"
  7144. + "F<FW>\\tNEG%?\\t%0,%1"
  7145. + [(set_attr "type" "FPmas")
  7146. + (set_attr "predicable" "yes")])
  7147. +
  7148. +; TODO: PACK
  7149. +; TODO: SWAP
  7150. +
  7151. +; Comparison Operations
  7152. +
  7153. +(define_expand "cmp<mode>"
  7154. + [(match_operand:FMODES 0 "metag_fpreg_op" "")
  7155. + (match_operand:<MODE> 1 "metag_fpreg_or_imm_op" "")]
  7156. + "<fcondition>"
  7157. + {
  7158. + enum machine_mode mode;
  7159. +
  7160. + /* These are processed via the conditional branch define_expand's later */
  7161. + metag_compare_op0 = operands[0];
  7162. + metag_compare_op1 = operands[1];
  7163. +
  7164. + mode = GET_MODE (operands[1]);
  7165. +
  7166. + /* Have to do register to register comparison for big constants */
  7167. + if (CONST_DOUBLE_P (operands[1]) && operands[1] != CONST0_RTX (mode))
  7168. + metag_compare_op1 = force_reg (mode, operands[1]);
  7169. +
  7170. + DONE;
  7171. + })
  7172. +
  7173. +(define_insn "*cmpsf<CCFP:mode>"
  7174. + [(set (reg:CCFP CC_REG)
  7175. + (compare:CCFP
  7176. + (match_operand:SF 0 "metag_fpreg_op" "cx,cx")
  7177. + (match_operand:SF 1 "metag_fpreg_or_fpzero_imm_op" "cx,G")))]
  7178. + "TARGET_FPU"
  7179. + "@
  7180. + F<CCQ>\\tCMP%?\\t%0,%1
  7181. + F<CCQ>\\tCMP%?\\t%0,#%h1"
  7182. + [(set_attr "type" "FPfast")])
  7183. +
  7184. +(define_insn "*cmpdf<CCFP:mode>"
  7185. + [(set (reg:CCFP CC_REG)
  7186. + (compare:CCFP
  7187. + (match_operand:DF 0 "metag_fpreg_op" "cx,cx")
  7188. + (match_operand:DF 1 "metag_fpreg_or_fpzero_imm_op" "cx,G")))]
  7189. + "TARGET_FPU && !metag_fpu_single"
  7190. + "@
  7191. + FD<CCQ>\\tCMP%?\\t%0,%1
  7192. + FD<CCQ>\\tCMP%?\\t%0,#%h1"
  7193. + [(set_attr "type" "FPfast")])
  7194. +
  7195. +(define_insn "*abscmpsf<CCFP:mode>2"
  7196. + [(set (reg:CCFP CC_REG)
  7197. + (compare:CCFP
  7198. + (abs:SF (match_operand:SF 0 "metag_fpreg_op" "cx,cx"))
  7199. + (abs:SF (match_operand:SF 1 "metag_fpreg_or_fpzero_imm_op" "cx,G"))))]
  7200. + "TARGET_FPU"
  7201. + "@
  7202. + FA<CCQ>\\tCMP%?\\t%0,%1
  7203. + FA<CCQ>\\tCMP%?\\t%0,#%h1"
  7204. + [(set_attr "type" "FPmas")])
  7205. +
  7206. +(define_insn "*abscmpdf<CCFP:mode>2"
  7207. + [(set (reg:CCFP CC_REG)
  7208. + (compare:CCFP
  7209. + (abs:DF (match_operand:DF 0 "metag_fpreg_op" "cx,cx"))
  7210. + (abs:DF (match_operand:DF 1 "metag_fpreg_or_fpzero_imm_op" "cx,G"))))]
  7211. + "TARGET_FPU && !metag_fpu_single"
  7212. + "@
  7213. + FDA<CCQ>\\tCMP%?\\t%0,%1
  7214. + FDA<CCQ>\\tCMP%?\\t%0,#%h1"
  7215. + [(set_attr "type" "FPmas")
  7216. + (set_attr "predicable" "yes")])
  7217. +
  7218. +(define_insn "smax<mode>3"
  7219. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7220. + (smax:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7221. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx")))
  7222. + (clobber (reg:CC CC_REG))]
  7223. + "<fcondition>"
  7224. + "F<FW>\\tMAX%?\\t%0,%1,%2"
  7225. + [(set_attr "type" "FPmas")
  7226. + (set_attr "predicable" "yes")
  7227. + (set_attr "ccstate" "ccx")])
  7228. +
  7229. +(define_insn "smin<mode>3"
  7230. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7231. + (smin:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7232. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx")))
  7233. + (clobber (reg:CC CC_REG))]
  7234. + "<fcondition>"
  7235. + "F<FW>\\tMIN%?\\t%0,%1,%2"
  7236. + [(set_attr "type" "FPmas")
  7237. + (set_attr "predicable" "yes")
  7238. + (set_attr "ccstate" "ccx")])
  7239. +
  7240. +; Data Conversion
  7241. +(define_insn "extendsfdf2"
  7242. + [(set (match_operand:DF 0 "metag_fpreg_op" "=cx")
  7243. + (float_extend:DF (match_operand:SF 1 "metag_fpreg_op" "cx")))]
  7244. + "TARGET_FPU && !metag_fpu_single"
  7245. + "F\\tFTOD%?\\t%0,%1"
  7246. + [(set_attr "type" "FPmas")
  7247. + (set_attr "predicable" "yes")])
  7248. +
  7249. +(define_insn "truncdfsf2"
  7250. + [(set (match_operand:SF 0 "metag_fpreg_op" "=cx")
  7251. + (float_truncate:SF (match_operand:DF 1 "metag_fpreg_op" "cx")))]
  7252. + "TARGET_FPU && !metag_fpu_single"
  7253. + "F\\tDTOF%?\\t%0,%1"
  7254. + [(set_attr "type" "FPmas")
  7255. + (set_attr "predicable" "yes")])
  7256. +
  7257. +;; HFmode isnt supported at the moment but the rules would be something like:
  7258. +;;
  7259. +;;(define_insn "truncsfhf2"
  7260. +;; [(set (match_operand:HF 0 "metag_fpreg_op" "=cx")
  7261. +;; (float:HF (match_operand:SF 1 "metag_fpreg_op" "cx")))]
  7262. +;; "TARGET_FPU"
  7263. +;; "F\\tFTOH%?\\t%0,%1"
  7264. +;; )
  7265. +;;
  7266. +;;(define_insn "truncdfhf2"
  7267. +;; [(set (match_operand:HF 0 "metag_fpreg_op" "=cx")
  7268. +;; (float:HF (match_operand:DF 1 "metag_fpreg_op" "cx")))]
  7269. +;; "TARGET_FPU"
  7270. +;; "F\\tDTOH%?\\t%0,%1"
  7271. +;; )
  7272. +
  7273. +(define_insn "fix_trunc<mode>si2"
  7274. + [(set (match_operand:SI 0 "metag_fpreg_op" "=cx")
  7275. + (fix:SI (match_operand:FSMODES 1 "metag_fpreg_op" "cx")))]
  7276. + "<fcondition>"
  7277. + "FZ\\t<FT>TOI%?\\t%0,%1"
  7278. + [(set_attr "type" "FPmas")
  7279. + (set_attr "predicable" "yes")])
  7280. +
  7281. +(define_expand "fix_truncsfdi2"
  7282. + [(set (match_dup 2)
  7283. + (float_extend:DF (match_operand:SF 1 "metag_fpreg_op" "")))
  7284. + (set (match_operand:DI 0 "metag_fpreg_op" "")
  7285. + (fix:DI (match_dup 2)))]
  7286. + "TARGET_FPU && !metag_fpu_single"
  7287. + {
  7288. + operands[2] = gen_reg_rtx (DFmode);
  7289. + })
  7290. +
  7291. +(define_insn "fix_truncdfdi2"
  7292. + [(set (match_operand:DI 0 "metag_fpreg_op" "=cx")
  7293. + (fix:DI (match_operand:DF 1 "metag_fpreg_op" "cx")))]
  7294. + "TARGET_FPU && !metag_fpu_single"
  7295. + "FZ\\tDTOL%?\\t%0,%1"
  7296. + [(set_attr "type" "FPmas")
  7297. + (set_attr "predicable" "yes")])
  7298. +
  7299. +(define_expand "fixuns_truncsfdi2"
  7300. + [(set (match_operand:DI 0 "metag_fpreg_op" "")
  7301. + (unsigned_fix:DI (match_operand:SF 1 "metag_fpreg_op" "")))]
  7302. + "TARGET_FPU && !metag_fpu_single"
  7303. + {
  7304. + rtx dscr = gen_reg_rtx (SImode);
  7305. + rtx fscr = gen_reg_rtx (SFmode);
  7306. + rtx fscr_as_si = gen_rtx_SUBREG (SImode, fscr, 0);
  7307. + rtx fscr2 = gen_reg_rtx (SFmode);
  7308. + rtx fdscr = gen_reg_rtx (DFmode);
  7309. + rtx rdhi = gen_rtx_SUBREG (SImode, operands[0], 4);
  7310. + rtx temp_operands[1];
  7311. +
  7312. + /* single precision 2^63 is 0x5F000000 */
  7313. + emit_move_insn (fscr_as_si,
  7314. + gen_int_mode (0x5F000000, SImode));
  7315. +
  7316. + /* Is input in 'difficult' range */
  7317. + emit_insn (gen_cmpsf (operands[1], fscr));
  7318. + gen_metag_compare (GE, temp_operands, 0);
  7319. +
  7320. + /* Copy input to scratch */
  7321. + emit_move_insn (fscr2, operands[1]);
  7322. +
  7323. + /* If it is then wrap around once (note, we dont have to
  7324. + * deal with the case where it's still difficult, C doesnt define
  7325. + * overflow behaviour */
  7326. + emit_insn (gen_rtx_SET (VOIDmode, fscr2,
  7327. + gen_rtx_IF_THEN_ELSE (SFmode,
  7328. + gen_rtx_GE (VOIDmode, temp_operands[0],
  7329. + const0_rtx),
  7330. + gen_rtx_MINUS (SFmode, operands[1],
  7331. + fscr),
  7332. + fscr2)));
  7333. +
  7334. + /* Extend to double before DI conversion */
  7335. + emit_insn (gen_rtx_SET (DFmode, fdscr,
  7336. + gen_rtx_FLOAT_EXTEND (DFmode, fscr2)));
  7337. +
  7338. + /* Convert to DI */
  7339. + emit_insn (gen_rtx_SET (DImode, operands[0],
  7340. + gen_rtx_FIX (DImode, fdscr)));
  7341. +
  7342. + /* Restore truncated value from earlier */
  7343. + emit_insn (gen_rtx_SET (SImode, dscr,
  7344. + gen_int_mode (0x80000000, SImode)));
  7345. + emit_insn (gen_rtx_SET (VOIDmode, rdhi,
  7346. + gen_rtx_IF_THEN_ELSE (SImode,
  7347. + gen_rtx_GE (VOIDmode, temp_operands[0],
  7348. + const0_rtx),
  7349. + gen_rtx_PLUS (SImode, rdhi,
  7350. + dscr),
  7351. + rdhi)));
  7352. + DONE;
  7353. +
  7354. + })
  7355. +
  7356. +(define_expand "fixuns_truncdfdi2"
  7357. + [(set (match_operand:DI 0 "metag_fpreg_op" "")
  7358. + (unsigned_fix:DI (match_operand:DF 1 "metag_fpreg_op" "")))]
  7359. + "TARGET_FPU && !metag_fpu_single"
  7360. + {
  7361. + rtx dscr = gen_reg_rtx (SImode);
  7362. + rtx fscr = gen_reg_rtx (DFmode);
  7363. + rtx fscrlo_as_si = gen_rtx_SUBREG (SImode, fscr, 0);
  7364. + rtx fscrhi_as_si = gen_rtx_SUBREG (SImode, fscr, 4);
  7365. + rtx fdscr = gen_reg_rtx (DFmode);
  7366. + rtx rdhi = gen_rtx_SUBREG (SImode, operands[0], 4);
  7367. + rtx temp_operands[1];
  7368. +
  7369. + /* double precision 2^63 is 0x43e00000 00000000*/
  7370. + emit_move_insn (fscrhi_as_si,
  7371. + gen_int_mode (0x43e00000, SImode));
  7372. + emit_move_insn (fscrlo_as_si, const0_rtx);
  7373. +
  7374. + /* Is input in 'difficult' range */
  7375. + emit_insn (gen_cmpdf (operands[1], fscr));
  7376. + gen_metag_compare (GE, temp_operands, 0);
  7377. +
  7378. + /* Copy input to scratch */
  7379. + emit_move_insn (fdscr, operands[1]);
  7380. +
  7381. + /* If it is then wrap around once (note, we dont have to
  7382. + * deal with the case where it's still difficult, C doesnt define
  7383. + * overflow behaviour */
  7384. + emit_insn (gen_rtx_SET (VOIDmode, fdscr,
  7385. + gen_rtx_IF_THEN_ELSE (DFmode,
  7386. + gen_rtx_GE (VOIDmode, temp_operands[0],
  7387. + const0_rtx),
  7388. + gen_rtx_MINUS (DFmode, operands[1],
  7389. + fscr),
  7390. + fdscr)));
  7391. +
  7392. + /* Convert to DI */
  7393. + emit_insn (gen_rtx_SET (DImode, operands[0],
  7394. + gen_rtx_FIX (DImode, fdscr)));
  7395. +
  7396. + /* Restore truncated value from earlier */
  7397. + emit_insn (gen_rtx_SET (SImode, dscr,
  7398. + gen_int_mode (0x80000000, SImode)));
  7399. + emit_insn (gen_rtx_SET (VOIDmode, rdhi,
  7400. + gen_rtx_IF_THEN_ELSE (SImode,
  7401. + gen_rtx_GE (VOIDmode, temp_operands[0],
  7402. + const0_rtx),
  7403. + gen_rtx_PLUS (SImode, rdhi,
  7404. + dscr),
  7405. + rdhi)));
  7406. +
  7407. + DONE;
  7408. +
  7409. + })
  7410. +
  7411. +(define_expand "fixuns_truncsfsi2"
  7412. + [(set (match_operand:SI 0 "metag_fpreg_op" "")
  7413. + (unsigned_fix:SI (match_operand:SF 1 "metag_fpreg_op" "")))]
  7414. + "TARGET_FPU && metag_fpu_single"
  7415. + {
  7416. + if (metag_fpu_single)
  7417. + {
  7418. + rtx dscr = gen_reg_rtx (SImode);
  7419. + rtx fscr = gen_reg_rtx (SFmode);
  7420. + rtx fscr_as_si = gen_rtx_SUBREG (SImode, fscr, 0);
  7421. + rtx fscr2 = gen_reg_rtx (SFmode);
  7422. + rtx temp_operands[1];
  7423. +
  7424. + /* single precision 2^31 is 0x4F000000 */
  7425. + emit_move_insn (fscr_as_si,
  7426. + gen_int_mode (0x4f000000, SImode));
  7427. +
  7428. + /* Is input in 'difficult' range */
  7429. + emit_insn (gen_cmpsf (operands[1], fscr));
  7430. + gen_metag_compare (GE, temp_operands, 0);
  7431. +
  7432. + /* Copy input to scratch */
  7433. + emit_move_insn (fscr2, operands[1]);
  7434. +
  7435. + /* If it is then wrap around once (note, we dont have to
  7436. + * deal with the case where it's still difficult, C doesnt define
  7437. + * overflow behaviour */
  7438. + emit_insn (gen_rtx_SET (VOIDmode, fscr2,
  7439. + gen_rtx_IF_THEN_ELSE (SFmode,
  7440. + gen_rtx_GE (VOIDmode, temp_operands[0],
  7441. + const0_rtx),
  7442. + gen_rtx_MINUS (SFmode, operands[1],
  7443. + fscr),
  7444. + fscr2)));
  7445. +
  7446. + /* Convert to SI */
  7447. + emit_insn (gen_rtx_SET (SImode, operands[0],
  7448. + gen_rtx_FIX (SImode, fscr2)));
  7449. +
  7450. + /* Restore truncated value from earlier */
  7451. + emit_insn (gen_rtx_SET (SImode, dscr,
  7452. + gen_int_mode (0x80000000, SImode)));
  7453. + emit_insn (gen_rtx_SET (VOIDmode, operands[0],
  7454. + gen_rtx_IF_THEN_ELSE (SImode,
  7455. + gen_rtx_GE (VOIDmode, temp_operands[0],
  7456. + const0_rtx),
  7457. + gen_rtx_PLUS (SImode, operands[0],
  7458. + dscr),
  7459. + operands[0])));
  7460. +
  7461. + DONE;
  7462. + }
  7463. + else
  7464. + {
  7465. + rtx op2 = gen_reg_rtx (DFmode);
  7466. + rtx op3 = gen_reg_rtx (DImode);
  7467. +
  7468. + emit_insn (gen_extendsfdf2 (op2, operands[1]));
  7469. + emit_insn (gen_fix_truncdfdi2 (op3, op2));
  7470. + emit_move_insn (operands[0], gen_rtx_SUBREG (SImode, op3, 0));
  7471. + DONE;
  7472. + }
  7473. +
  7474. + })
  7475. +
  7476. +
  7477. +; DTOX, FTOX, DTOXL not supported
  7478. +(define_insn "floatsi<mode>2"
  7479. + [(set (match_operand:FSMODES 0 "metag_fpreg_op" "=cx")
  7480. + (float:<MODE> (match_operand:SI 1 "metag_fpreg_op" "cx")))]
  7481. + "<fcondition>"
  7482. + "F\\tITO<FT>%?\\t%0,%1"
  7483. + [(set_attr "type" "FPmas")
  7484. + (set_attr "predicable" "yes")])
  7485. +
  7486. +(define_expand "floatdisf2"
  7487. + [(set (match_dup 2)
  7488. + (float:DF (match_operand:DI 1 "metag_fpreg_op" "")))
  7489. + (set (match_operand:SF 0 "metag_fpreg_op" "")
  7490. + (float_truncate:SF (match_dup 2)))]
  7491. + "TARGET_FPU && !metag_fpu_single"
  7492. + {
  7493. + operands[2] = gen_reg_rtx (DFmode);
  7494. + })
  7495. +
  7496. +(define_insn "floatdidf2"
  7497. + [(set (match_operand:DF 0 "metag_fpreg_op" "=cx")
  7498. + (float:DF (match_operand:DI 1 "metag_fpreg_op" "cx")))]
  7499. + "TARGET_FPU && !metag_fpu_single"
  7500. + "F\\tLTOD%?\\t%0,%1"
  7501. + [(set_attr "type" "FPmas")
  7502. + (set_attr "predicable" "yes")])
  7503. +
  7504. +(define_expand "floatunshi<mode>2"
  7505. + [(set (match_dup:SI 2)
  7506. + (zero_extend:SI (match_operand:HI 1 "metag_reg_nofloat_op" "")))
  7507. + (set (match_operand:FMODES 0 "metag_fpreg_op" "")
  7508. + (float:<MODE> (match_dup 2)))]
  7509. + "<fcondition>"
  7510. + {
  7511. + operands[2] = gen_reg_rtx (SImode);
  7512. + })
  7513. +
  7514. +(define_expand "floatunssidf2"
  7515. + [(set (match_dup 2)
  7516. + (zero_extend:DI (match_operand:SI 1 "metag_register_op" "")))
  7517. + (set (match_operand:DF 0 "metag_fpreg_op" "")
  7518. + (float:DF (match_dup 2)))]
  7519. + "TARGET_FPU && !metag_fpu_single"
  7520. + {
  7521. + operands[2] = gen_reg_rtx (DImode);
  7522. + })
  7523. +
  7524. +(define_expand "floatunsdidf2"
  7525. + [(set (match_operand:DF 0 "metag_fpreg_op" "")
  7526. + (unsigned_float:DF (match_operand:DI 1 "metag_register_op" "")))]
  7527. + "TARGET_FPU && !metag_fpu_single"
  7528. + {
  7529. + metag_expand_didf2 (operands[0], operands[1]);
  7530. + DONE;
  7531. + })
  7532. +
  7533. +(define_expand "floatunsdisf2"
  7534. + [(set (match_dup 2)
  7535. + (unsigned_float:DF (match_operand:DI 1 "metag_register_op" "")))
  7536. + (set (match_operand:SF 0 "metag_fpreg_op" "")
  7537. + (float_truncate:SF (match_dup 2)))]
  7538. + "TARGET_FPU && !metag_fpu_single"
  7539. + {
  7540. + operands[2] = gen_reg_rtx (DFmode);
  7541. +
  7542. + metag_expand_didf2 (operands[2], operands[1]);
  7543. +
  7544. + emit_insn (gen_truncdfsf2 (operands[0], operands[2]));
  7545. + DONE;
  7546. + })
  7547. +
  7548. +(define_expand "floatunssisf2"
  7549. + [(set (match_operand:SF 0 "metag_fpreg_op" "")
  7550. + (unsigned_float:SF (match_operand:SI 1 "metag_register_op" "")))]
  7551. + "TARGET_FPU && metag_fpu_single"
  7552. + {
  7553. + if (metag_fpu_single)
  7554. + {
  7555. + rtx dscr = gen_reg_rtx (SImode);
  7556. + rtx fscr2 = gen_reg_rtx (SFmode);
  7557. + rtx fscr2_as_si = gen_rtx_SUBREG (SImode, fscr2, 0);
  7558. + rtx temp_operands[1];
  7559. +
  7560. + /* Test to see if rs is in the difficult range (> 2^31) */
  7561. + emit_move_insn (dscr, operands[1]);
  7562. + metag_compare_op0 = gen_rtx_AND (SImode, dscr,
  7563. + gen_int_mode (0x80000000, SImode));
  7564. + metag_compare_op1 = const0_rtx;
  7565. + gen_metag_compare (NE, temp_operands, 0);
  7566. +
  7567. + /* Drop the 2^31 component */
  7568. + emit_insn (gen_andsi3 (dscr, dscr,
  7569. + gen_int_mode (0x7fffffff, SImode)));
  7570. +
  7571. + /* Convert to single */
  7572. + emit_insn (gen_floatsisf2 (operands[0], dscr));
  7573. +
  7574. + /* Prepare 2^31 in single precision */
  7575. + emit_move_insn (fscr2_as_si,
  7576. + gen_int_mode (0x4f000000, SImode));
  7577. +
  7578. + /* Add on the missing 2^31 if requried */
  7579. + emit_insn (gen_rtx_SET (VOIDmode, operands[0],
  7580. + gen_rtx_IF_THEN_ELSE (SFmode,
  7581. + gen_rtx_NE (VOIDmode, temp_operands[0],
  7582. + const0_rtx),
  7583. + gen_rtx_PLUS (SFmode, operands[0], fscr2),
  7584. + operands[0])));
  7585. +
  7586. + DONE;
  7587. + }
  7588. + else
  7589. + {
  7590. + rtx op2 = gen_reg_rtx (DImode);
  7591. + rtx op3 = gen_reg_rtx (DFmode);
  7592. +
  7593. + emit_insn (gen_zero_extendsidi2 (op2, operands[1]));
  7594. + emit_insn (gen_floatdidf2 (op3, op2));
  7595. + emit_insn (gen_truncdfsf2 (operands[0], op3));
  7596. + DONE;
  7597. + }
  7598. + })
  7599. +
  7600. +; Basic Arithmetic
  7601. +; SFmode
  7602. +(define_insn "add<mode>3"
  7603. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7604. + (plus:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7605. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx")))]
  7606. + "<fcondition>"
  7607. + "F<FW>\\tADD%?\\t%0,%1,%2"
  7608. + [(set_attr "type" "FPmas")
  7609. + (set_attr "predicable" "yes")])
  7610. +
  7611. +(define_insn "*add<FMODES:mode>_if_<CCALL:mode>_cxcxcxcx"
  7612. + [(set (match_operand:FMODES 0 "metag_fpreg_op" "=cx")
  7613. + (if_then_else:FMODES (match_operator 1 "comparison_operator"
  7614. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  7615. + (const_int 0)])
  7616. + (plus:FMODES (match_operand:FMODES 3 "metag_fpreg_op" "cx")
  7617. + (match_operand:FMODES 4 "metag_fpreg_op" "cx"))
  7618. + (match_operand:FMODES 5 "metag_fpreg_op" "0")))]
  7619. + "<fcondition>"
  7620. + "F<FMODES:FW>\\tADD%z1\\t%0,%3,%4"
  7621. + [(set_attr "type" "FPmas")
  7622. + (set_attr "ccstate" "xcc")])
  7623. +
  7624. +(define_insn "*nadd<mode>3"
  7625. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7626. + (neg:<MODE>
  7627. + (plus:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7628. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))))]
  7629. + "<fcondition>"
  7630. + "F<FW>I\\tADD%?\\t%0,%1,%2"
  7631. + [(set_attr "type" "FPmas")
  7632. + (set_attr "predicable" "yes")])
  7633. +
  7634. +(define_insn "mul<mode>3"
  7635. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7636. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7637. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx")))]
  7638. + "<fcondition>"
  7639. + "F<FW>\\tMUL%?\\t%0,%1,%2"
  7640. + [(set_attr "type" "FPmas")
  7641. + (set_attr "predicable" "yes")])
  7642. +
  7643. +(define_insn "*nmul<mode>3"
  7644. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7645. + (neg:<MODE>
  7646. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7647. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))))]
  7648. + "<fcondition>"
  7649. + "F<FW>I\\tMUL%?\\t%0,%1,%2"
  7650. + [(set_attr "type" "FPmas")
  7651. + (set_attr "predicable" "yes")])
  7652. +
  7653. +(define_insn "sub<mode>3"
  7654. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7655. + (minus:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7656. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx")))]
  7657. + "<fcondition>"
  7658. + "F<FW>\\tSUB%?\\t%0,%1,%2"
  7659. + [(set_attr "type" "FPmas")
  7660. + (set_attr "predicable" "yes")])
  7661. +
  7662. +(define_insn "*sub<FMODES:mode>_if_<CCALL:mode>_cxcxcxcx"
  7663. + [(set (match_operand:FMODES 0 "metag_fpreg_op" "=cx")
  7664. + (if_then_else:FMODES (match_operator 1 "comparison_operator"
  7665. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  7666. + (const_int 0)])
  7667. + (minus:FMODES (match_operand:FMODES 3 "metag_fpreg_op" "cx")
  7668. + (match_operand:FMODES 4 "metag_fpreg_op" "cx"))
  7669. + (match_operand:FMODES 5 "metag_fpreg_op" "0")))]
  7670. + "<fcondition>"
  7671. + "F<FMODES:FW>\\tSUB%z1\\t%0,%3,%4"
  7672. + [(set_attr "type" "FPmas")
  7673. + (set_attr "ccstate" "xcc")])
  7674. +
  7675. +(define_insn "*nsub<mode>3"
  7676. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7677. + (neg:<MODE>
  7678. + (minus:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7679. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))))]
  7680. + "<fcondition>"
  7681. + "F<FW>I\\tSUB%?\\t%0,%1,%2"
  7682. + [(set_attr "type" "FPmas")
  7683. + (set_attr "predicable" "yes")])
  7684. +
  7685. +
  7686. +; Extended Floating Point Insn's
  7687. +; SFmode
  7688. +
  7689. +; TODO MUZ
  7690. +(define_insn "*muladd<mode>3_fused"
  7691. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7692. + (plus:<MODE>
  7693. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7694. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7695. + (match_operand:<MODE> 3 "metag_fpreg_op" "0")))]
  7696. + "<fcondition>"
  7697. + "F<FW>\\tMUZ\\t%0,%1,%2"
  7698. + [(set_attr "type" "FPmas")])
  7699. +
  7700. +(define_insn "*muladd1<mode>3_fused"
  7701. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7702. + (plus:<MODE>
  7703. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7704. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7705. + (match_operand:<MODE> 3 "metag_fpone_imm_op" "H")))]
  7706. + "<fcondition>"
  7707. + "F<FW>\\tMUZ1\\t%0,%1,%2"
  7708. + [(set_attr "type" "FPmas")])
  7709. +
  7710. +(define_insn "*mulsub<mode>3_fused"
  7711. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7712. + (minus:<MODE>
  7713. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7714. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7715. + (match_operand:<MODE> 3 "metag_fpreg_op" "0")))]
  7716. + "<fcondition>"
  7717. + "F<FW>\\tMUZS\\t%0,%1,%2"
  7718. + [(set_attr "type" "FPmas")])
  7719. +
  7720. +(define_insn "*mulsub1<mode>3_fused"
  7721. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7722. + (minus:<MODE>
  7723. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7724. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7725. + (match_operand:<MODE> 3 "metag_fpone_imm_op" "H")))]
  7726. + "<fcondition>"
  7727. + "F<FW>\\tMUZS1\\t%0,%1,%2"
  7728. + [(set_attr "type" "FPmas")])
  7729. +
  7730. +(define_insn "*nmuladd<mode>3_fused"
  7731. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7732. + (neg:<MODE>
  7733. + (plus:<MODE>
  7734. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7735. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7736. + (match_operand:<MODE> 3 "metag_fpreg_op" "0"))))]
  7737. + "<fcondition>"
  7738. + "F<FW>I\\tMUZ\\t%0,%1,%2"
  7739. + [(set_attr "type" "FPmas")])
  7740. +
  7741. +(define_insn "*nmuladd1<mode>3_fused"
  7742. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7743. + (neg:<MODE>
  7744. + (plus:<MODE>
  7745. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7746. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7747. + (match_operand:<MODE> 3 "metag_fpone_imm_op" "H"))))]
  7748. + "<fcondition>"
  7749. + "F<FW>I\\tMUZ1\\t%0,%1,%2"
  7750. + [(set_attr "type" "FPmas")])
  7751. +
  7752. +(define_insn "*nmulsub<mode>3_fused"
  7753. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7754. + (neg:<MODE>
  7755. + (minus:<MODE>
  7756. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7757. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7758. + (match_operand:<MODE> 3 "metag_fpreg_op" "0"))))]
  7759. + "<fcondition>"
  7760. + "F<FW>I\\tMUZS\\t%0,%1,%2"
  7761. + [(set_attr "type" "FPmas")])
  7762. +
  7763. +(define_insn "*nmulsub1<mode>3_fused"
  7764. + [(set (match_operand:FLMODES 0 "metag_fpreg_op" "=cx")
  7765. + (neg:<MODE>
  7766. + (minus:<MODE>
  7767. + (mult:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7768. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))
  7769. + (match_operand:<MODE> 3 "metag_fpone_imm_op" "H"))))]
  7770. + "<fcondition>"
  7771. + "F<FW>I\\tMUZS1\\t%0,%1,%2"
  7772. + [(set_attr "type" "FPmas")])
  7773. +
  7774. +;; Divides etc
  7775. +
  7776. +(define_expand "divsf3"
  7777. + [(set (match_operand:SF 0 "metag_fpreg_op" "")
  7778. + (div:SF (match_operand:SF 1 "metag_fpreg_op" "")
  7779. + (match_operand:SF 2 "metag_fpreg_op" "")))]
  7780. + "TARGET_FPU && TARGET_FAST_MATH"
  7781. + {
  7782. + })
  7783. +
  7784. +(define_expand "divdf3"
  7785. + [(set (match_operand:DF 0 "metag_fpreg_op" "")
  7786. + (div:DF (match_dup 3)
  7787. + (match_operand:DF 2 "metag_fpreg_op" "")))
  7788. + (set (match_dup 4)
  7789. + (neg:DF (minus:DF (mult:DF (match_dup 2)
  7790. + (match_dup 0))
  7791. + (match_dup 3))))
  7792. + (set (match_dup 0)
  7793. + (plus:DF (mult:DF (match_dup 4)
  7794. + (match_dup 0))
  7795. + (match_dup 0)))
  7796. + (set (match_dup 0)
  7797. + (mult:DF (match_operand:DF 1 "metag_fpreg_op" "")
  7798. + (match_dup 0)))]
  7799. + "TARGET_FPU && !metag_fpu_single && TARGET_FAST_MATH"
  7800. + {
  7801. + operands[3] = CONST1_RTX (DFmode);
  7802. + operands[4] = gen_reg_rtx (DFmode);
  7803. + })
  7804. +
  7805. +(define_insn_and_split "*div<mode>2_fast"
  7806. + [(set (match_operand:FMODES 0 "metag_fpreg_op" "=&cx")
  7807. + (div:<MODE> (match_operand:<MODE> 1 "metag_fpreg_op" "cx")
  7808. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx")))]
  7809. + "<fcondition> && TARGET_FAST_MATH"
  7810. + "#"
  7811. + "&& 1"
  7812. + [(const_int 0)]
  7813. + {
  7814. + emit_insn (gen_rcp<mode>2 (operands[0], CONST1_RTX (<MODE>mode), operands[2]));
  7815. + emit_insn (gen_mul<mode>3 (operands[0], operands[0], operands[1]));
  7816. + DONE;
  7817. + }
  7818. + [(set_attr "type" "FPrecipmas")])
  7819. +
  7820. +(define_insn "rcp<mode>2"
  7821. + [(set (match_operand:FMODES 0 "metag_fpreg_op" "=cx")
  7822. + (div:<MODE> (match_operand:<MODE> 1 "metag_fpone_imm_op" "H")
  7823. + (match_operand:<MODE> 2 "metag_fpreg_op" "cx")))]
  7824. + "<fcondition> && TARGET_FAST_MATH"
  7825. + {
  7826. + if (TARGET_FLUSH_TO_ZERO)
  7827. + return "F<FW>Z\\tRCP\\t%0,%2";
  7828. + else
  7829. + return "F<FW>\\tRCP\\t%0,%2";
  7830. + }
  7831. + [(set_attr "type" "FPrecip")])
  7832. +
  7833. +(define_insn "*rsq<mode>2"
  7834. + [(set (match_operand:FMODES 0 "metag_fpreg_op" "=cx")
  7835. + (div:<MODE> (match_operand:<MODE> 1 "metag_fpone_imm_op" "H")
  7836. + (sqrt:<MODE> (match_operand:<MODE> 2 "metag_fpreg_op" "cx"))))]
  7837. + "<fcondition> && TARGET_FAST_MATH"
  7838. + {
  7839. + if (TARGET_FLUSH_TO_ZERO)
  7840. + return "F<FW>Z\\tRSQ\\t%0,%2";
  7841. + else
  7842. + return "F<FW>\\tRSQ\\t%0,%2";
  7843. + }
  7844. + [(set_attr "type" "FPrecip")])
  7845. +
  7846. +; ADDRE, MULRE, and SUBRE need vector modes
  7847. +; Memory operations all use core instrutions with U[sd]=9
  7848. diff -Nur gcc-4.2.4.orig/gcc/config/metag/lib1funcs.asm gcc-4.2.4/gcc/config/metag/lib1funcs.asm
  7849. --- gcc-4.2.4.orig/gcc/config/metag/lib1funcs.asm 1969-12-31 18:00:00.000000000 -0600
  7850. +++ gcc-4.2.4/gcc/config/metag/lib1funcs.asm 2015-07-03 18:46:05.749283542 -0500
  7851. @@ -0,0 +1,2740 @@
  7852. +/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
  7853. + Imagination Technologies Ltd
  7854. +
  7855. +This file is part of GCC.
  7856. +
  7857. +GCC is free software; you can redistribute it and/or modify it under
  7858. +the terms of the GNU General Public License as published by the Free
  7859. +Software Foundation; either version 3, or (at your option) any later
  7860. +version.
  7861. +
  7862. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  7863. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  7864. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  7865. +for more details.
  7866. +
  7867. +Under Section 7 of GPL version 3, you are granted additional
  7868. +permissions described in the GCC Runtime Library Exception, version
  7869. +3.1, as published by the Free Software Foundation.
  7870. +
  7871. +You should have received a copy of the GNU General Public License and
  7872. +a copy of the GCC Runtime Library Exception along with this program;
  7873. +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  7874. +<http://www.gnu.org/licenses/>. */
  7875. +
  7876. +/* As a special exception, if you link this library with other files,
  7877. + some of which are compiled with GCC, to produce an executable,
  7878. + this library does not by itself cause the resulting executable
  7879. + to be covered by the GNU General Public License.
  7880. + This exception does not however invalidate any other reasons why
  7881. + the executable file might be covered by the GNU General Public License. */
  7882. +
  7883. +!! libgcc1 routines for META cpu.
  7884. +!! Contributed by Metagence Technologies (toolkit@metagence.com)
  7885. +
  7886. +!! Division routines
  7887. +
  7888. +#ifdef L_udivsi3
  7889. +!!
  7890. +!! 32-bit division unsigned i/p - passed unsigned 32-bit numbers
  7891. +!!
  7892. + .text
  7893. + .global ___udivsi3
  7894. + .type ___udivsi3,function
  7895. + .align 2
  7896. +___udivsi3:
  7897. +!!
  7898. +!! Since core is signed divide case, just set control variable
  7899. +!!
  7900. + MOV D1Re0,D0Ar2 ! Au already in A1Ar1, Bu -> D1Re0
  7901. + MOV D0Re0,#0 ! Result is 0
  7902. + MOV D0Ar4,#0 ! Return positive result
  7903. + B __IDMCUStart
  7904. + .size ___udivsi3,.-___udivsi3
  7905. +#endif
  7906. +
  7907. +#ifdef L_divsi3
  7908. +!!
  7909. +!! 32-bit division signed i/p - passed signed 32-bit numbers
  7910. +!!
  7911. + .text
  7912. + .global ___divsi3
  7913. + .type ___divsi3,function
  7914. + .align 2
  7915. +___divsi3:
  7916. +!!
  7917. +!! A already in D1Ar1, B already in D0Ar2 -> make B abs(B)
  7918. +!!
  7919. + MOV D1Re0,D0Ar2 ! A already in A1Ar1, B -> D1Re0
  7920. + MOV D0Re0,#0 ! Result is 0
  7921. + XOR D0Ar4,D1Ar1,D1Re0 ! D0Ar4 -ive if result is -ive
  7922. + ABS D1Ar1,D1Ar1 ! abs(A) -> Au
  7923. + ABS D1Re0,D1Re0 ! abs(B) -> Bu
  7924. + .global __IDMCUStart
  7925. + .hidden __IDMCUStart
  7926. +__IDMCUStart:
  7927. + CMP D1Ar1,D1Re0 ! Is ( Au > Bu )?
  7928. + LSR D1Ar3,D1Ar1,#2 ! Calculate (Au & (~3)) >> 2
  7929. + CMPHI D1Re0,D1Ar3 ! OR ( (Au & (~3)) <= (Bu << 2) )?
  7930. + LSLSHI D1Ar3,D1Re0,#1 ! Buq = Bu << 1
  7931. + BLS $IDMCUSetup ! Yes: Do normal divide
  7932. +!!
  7933. +!! Quick divide setup can assume that CurBit only needs to start at 2
  7934. +!!
  7935. +$IDMCQuick:
  7936. + CMP D1Ar1,D1Ar3 ! ( A >= Buq )?
  7937. + ADDCC D0Re0,D0Re0,#2 ! If yes result += 2
  7938. + SUBCC D1Ar1,D1Ar1,D1Ar3 ! and A -= Buq
  7939. + CMP D1Ar1,D1Re0 ! ( A >= Bu )?
  7940. + ADDCC D0Re0,D0Re0,#1 ! If yes result += 1
  7941. + SUBCC D1Ar1,D1Ar1,D1Re0 ! and A -= Bu
  7942. + ORS D0Ar4,D0Ar4,D0Ar4 ! Return neg result?
  7943. + NEG D0Ar2,D0Re0 ! Calulate neg result
  7944. + MOVMI D0Re0,D0Ar2 ! Yes: Take neg result
  7945. +$IDMCRet:
  7946. + MOV PC,D1RtP
  7947. +!!
  7948. +!! Setup for general unsigned divide code
  7949. +!!
  7950. +!! D0Re0 is used to form the result, already set to Zero
  7951. +!! D1Re0 is the input Bu value, this gets trashed
  7952. +!! D0Ar6 is curbit which is set to 1 at the start and shifted up
  7953. +!! D0Ar4 is negative if we should return a negative result
  7954. +!! D1Ar1 is the input Au value, eventually this holds the remainder
  7955. +!!
  7956. +$IDMCUSetup:
  7957. + CMP D1Ar1,D1Re0 ! Is ( Au < Bu )?
  7958. + MOV D0Ar6,#1 ! Set curbit to 1
  7959. + BCS $IDMCRet ! Yes: Return 0 remainder Au
  7960. +!!
  7961. +!! Calculate alignment using FFB instruction
  7962. +!!
  7963. + FFB D1Ar5,D1Ar1 ! Find first bit of Au
  7964. + ANDN D1Ar5,D1Ar5,#31 ! Handle exceptional case.
  7965. + ORN D1Ar5,D1Ar5,#31 ! if N bit set, set to 31
  7966. + FFB D1Ar3,D1Re0 ! Find first bit of Bu
  7967. + ANDN D1Ar3,D1Ar3,#31 ! Handle exceptional case.
  7968. + ORN D1Ar3,D1Ar3,#31 ! if N bit set, set to 31
  7969. + SUBS D1Ar3,D1Ar5,D1Ar3 ! calculate diff, ffbA - ffbB
  7970. + MOV D0Ar2,D1Ar3 ! copy into bank 0
  7971. + LSLGT D1Re0,D1Re0,D1Ar3 ! ( > 0) ? left shift B
  7972. + LSLGT D0Ar6,D0Ar6,D0Ar2 ! ( > 0) ? left shift curbit
  7973. +!!
  7974. +!! Now we start the divide proper, logic is
  7975. +!!
  7976. +!! if ( A >= B ) add curbit to result and subtract B from A
  7977. +!! shift curbit and B down by 1 in either case
  7978. +!!
  7979. +$IDMCLoop:
  7980. + CMP D1Ar1, D1Re0 ! ( A >= B )?
  7981. + ADDCC D0Re0, D0Re0, D0Ar6 ! If yes result += curbit
  7982. + SUBCC D1Ar1, D1Ar1, D1Re0 ! and A -= B
  7983. + LSRS D0Ar6, D0Ar6, #1 ! Shift down curbit, is it zero?
  7984. + LSR D1Re0, D1Re0, #1 ! Shift down B
  7985. + BNZ $IDMCLoop ! Was single bit in curbit lost?
  7986. + ORS D0Ar4,D0Ar4,D0Ar4 ! Return neg result?
  7987. + NEG D0Ar2,D0Re0 ! Calulate neg result
  7988. + MOVMI D0Re0,D0Ar2 ! Yes: Take neg result
  7989. + MOV PC,D1RtP
  7990. + .size ___divsi3,.-___divsi3
  7991. +#endif
  7992. +
  7993. +!! Modulus routines
  7994. +
  7995. +#ifdef L_umodsi3
  7996. +!!
  7997. +!! 32-bit modulus unsigned i/p - passed unsigned 32-bit numbers
  7998. +!!
  7999. + .text
  8000. + .global ___umodsi3
  8001. + .type ___umodsi3,function
  8002. + .align 2
  8003. +___umodsi3:
  8004. +#ifdef __PIC__
  8005. + SETL [A0StP++],D0FrT,D1RtP ! Save return address
  8006. + CALLR D1RtP,___udivsi3@PLT
  8007. + GETL D0FrT,D1RtP,[--A0StP] ! Recover return address
  8008. +#else
  8009. + MOV D0FrT,DRtP ! Save original return address
  8010. + CALLR D1RtP,___udivsi3
  8011. + MOV D1RtP,D0FrT ! Recover return address
  8012. +#endif
  8013. + MOV D0Re0,D1Ar1 ! Return remainder
  8014. + MOV PC,D1RtP
  8015. + .size ___umodsi3,.-___umodsi3
  8016. +#endif
  8017. +
  8018. +#ifdef L_modsi3
  8019. +!!
  8020. +!! 32-bit modulus signed i/p - passed signed 32-bit numbers
  8021. +!!
  8022. + .text
  8023. + .global ___modsi3
  8024. + .type ___modsi3,function
  8025. + .align 2
  8026. +___modsi3:
  8027. +#ifdef __PIC__
  8028. + MOV D0.4,D1Ar1
  8029. + SETL [A0StP++],D0.4,D1RtP ! Save A and return address
  8030. + CALLR D1RtP,___divsi3@PLT
  8031. + GETL D0.4,D1RtP,[--A0StP] ! Recover A and return address
  8032. + MOV D1Re0,D0.4
  8033. +#else
  8034. + MOV D0FrT,D1RtP ! Save original return address
  8035. + MOV A0.2,D1Ar1 ! Save A in A0.2
  8036. + CALLR D1RtP,___divsi3
  8037. + MOV D1RtP,D0FrT ! Recover return address
  8038. + MOV D1Re0,A0.2 ! Recover A
  8039. +#endif
  8040. + MOV D0Re0,D1Ar1 ! Return remainder
  8041. + ORS D1Re0,D1Re0,D1Re0 ! Was A negative?
  8042. + NEG D1Ar1,D1Ar1 ! Negate remainder
  8043. + MOVMI D0Re0,D1Ar1 ! Return neg remainder
  8044. + MOV PC, D1RtP
  8045. + .size ___modsi3,.-___modsi3
  8046. +#endif
  8047. +
  8048. +!! Floating point support routines
  8049. +
  8050. +#ifdef L_adddf3
  8051. +!!
  8052. +!! Floating point - double add
  8053. +!!
  8054. + .text
  8055. + .global ___adddf3
  8056. + .type ___adddf3,function
  8057. + .align 2
  8058. +___adddf3:
  8059. + AND D1Re0, D1Ar1, D1Ar3
  8060. + ANDT D1Re0, D1Re0, #0x8000 ! sign1 & sign2
  8061. +
  8062. + LSL D0Re0, D1Ar1, #1 ! Ignore sign
  8063. + ORS D0Re0, D0Re0, D0Ar2 ! Zero?
  8064. +
  8065. + LSL D0Re0, D1Ar3, #1 ! Ignore sign
  8066. + ORSZ D0Re0, D0Re0, D0Ar4 ! Zero
  8067. +
  8068. + MOVZ PC, D1RtP ! both zero return +/-Zero
  8069. +
  8070. + LSL D0Re0, D1Ar1, #1 ! Ignore sign
  8071. + ORS D0Re0, D0Re0, D0Ar2 ! Zero?
  8072. +
  8073. + MOVZ D0Re0, D0Ar4
  8074. + MOVZ D1Re0, D1Ar3
  8075. + MOVZ PC, D1RtP ! Arg1 zero return Arg2
  8076. +
  8077. + LSL D0Re0, D1Ar3, #1 ! Ignore sign
  8078. + ORS D0Re0, D0Re0, D0Ar4 ! Zero?
  8079. +
  8080. + MOVZ D1Re0, D1Ar1
  8081. + MOVZ D0Re0, D0Ar2
  8082. + MOVZ PC, D1RtP ! Arg2 zero return Arg1
  8083. +
  8084. + MOV D1Ar5, D1Ar1
  8085. + ANDMT D1Ar5, D1Ar5, #0x7FFF
  8086. + LSR D1Ar5, D1Ar5, #20 ! exp1
  8087. +
  8088. + MOV D0Ar6, D1Ar3
  8089. + ANDMT D0Ar6, D0Ar6, #0x7FFF
  8090. + LSR D0Ar6, D0Ar6, #20 ! exp2
  8091. +
  8092. + MOV D0Re0, D1Ar5
  8093. + SUBS D1Re0, D0Re0, D0Ar6 ! exp = exp1 - exp2 ---> D1Re0
  8094. + BGE $L2
  8095. +
  8096. + SWAP D0Re0, D1Ar3 ! mant1 <-> mant2
  8097. + SWAP D0Re0, D1Ar1
  8098. + SWAP D0Re0, D1Ar3
  8099. +
  8100. + SWAP D1Re0, D0Ar4
  8101. + SWAP D1Re0, D0Ar2
  8102. + SWAP D1Re0, D0Ar4
  8103. +
  8104. + SWAP D0Ar6, D1Ar5 ! exp1 <-> exp2
  8105. + NEG D1Re0, D1Re0 ! exp = -exp
  8106. +
  8107. +$L2:
  8108. + CMP D1Re0, #54
  8109. + BLE $L3
  8110. +
  8111. + MOV D1Re0, D1Ar1
  8112. + MOV D0Re0, D0Ar2
  8113. +
  8114. + MOV PC, D1RtP
  8115. +
  8116. +$L3:
  8117. + SWAP D1Re0, D0Re0
  8118. +
  8119. + ADDS D1Ar1, D1Ar1, #0
  8120. + ANDMT D1Ar1, D1Ar1, #0x000F
  8121. + ORT D1Ar1, D1Ar1, #0x0010
  8122. + LSL D1Ar1, D1Ar1, #9
  8123. +
  8124. + LSR D1Re0, D0Ar2, #23
  8125. + OR D1Ar1, D1Ar1, D1Re0
  8126. + LSL D0Ar2, D0Ar2, #9 ! man1 <<= 9 ---> D1Ar1:D0Ar2
  8127. +
  8128. + BGE $L4
  8129. +
  8130. + NEGS D0Ar2, D0Ar2
  8131. + NEG D1Ar1, D1Ar1
  8132. + SUBNZ D1Ar1, D1Ar1, #1 ! man1 D1Ar1:D0Ar2
  8133. +
  8134. +$L4:
  8135. + ADDS D1Ar3, D1Ar3, #0
  8136. + ANDMT D1Ar3, D1Ar3, #0x000F
  8137. + ORT D1Ar3, D1Ar3, #0x0010
  8138. + LSL D1Ar3, D1Ar3, #9
  8139. +
  8140. + LSR D1Re0, D0Ar4, #23
  8141. + OR D1Ar3, D1Ar3, D1Re0
  8142. + LSL D0Ar4, D0Ar4, #9 ! man2 <<= 9 --->D1Ar3, D0Ar4
  8143. +
  8144. + BGE $L5
  8145. +
  8146. + NEGS D0Ar4, D0Ar4
  8147. + NEG D1Ar3, D1Ar3
  8148. + SUBNZ D1Ar3, D1Ar3, #1 ! man2 D1Ar3:D0Ar4
  8149. +
  8150. +$L5:
  8151. + SWAP D1Re0, D0Re0
  8152. + CMP D1Re0, #32 ! ought to consider 32 <= exp1 - exp2 <64
  8153. + BGE $L6
  8154. +
  8155. + CMP D1Re0, #0 ! Zero is a special case
  8156. + BZ $L7
  8157. +
  8158. + MOV D0Re0, D1Re0
  8159. + NEG D0Re0, D0Re0
  8160. + ADD D0Re0, D0Re0, #32 ! 32 + (- (exp1 - exp2))
  8161. + ! man2 D1Ar3:D0Ar4
  8162. + MOV D0Ar6, D1Re0 ! man2 >> exp1 - exp2
  8163. + LSR D0Ar4, D0Ar4, D0Ar6
  8164. + MOV D0Ar6, D1Ar3
  8165. + LSL D0Ar6, D0Ar6, D0Re0
  8166. + OR D0Ar4, D0Ar4, D0Ar6
  8167. + ASR D1Ar3, D1Ar3, D1Re0
  8168. + B $L7
  8169. +
  8170. +$L6: ! exp >= 32
  8171. + SUB D1Re0, D1Re0, #32
  8172. + ASRS D0Ar4, D1Ar3, D1Re0 ! man2 >>= exp
  8173. + MOV D1Ar3, #-1
  8174. + ADDGE D1Ar3, D1Ar3, #1
  8175. +
  8176. +$L7: ! man (D1Re0:D1Re0)
  8177. + ADDS D0Re0, D0Ar2, D0Ar4 ! man = man1 + man2
  8178. + ADD D1Re0, D1Ar1, D1Ar3
  8179. + ADDCS D1Re0, D1Re0, #1
  8180. +
  8181. + MOV D0Ar6, #0 ! assume sign +ve
  8182. +
  8183. + CMP D1Re0, #0 ! man < 0 ?
  8184. + BGT $L9
  8185. + BLT $L8
  8186. +
  8187. + CMP D0Re0, #0
  8188. +
  8189. + MOVZ PC, D1RtP ! man == 0 return 0
  8190. +
  8191. +$L8:
  8192. + CMP D1Re0, #0 ! man < 0
  8193. + BZ $L9 ! treat D1Re0 0 as positive
  8194. +
  8195. + MOVT D0Ar6, #0x8000 ! sign -ve
  8196. +
  8197. + ! man D1Re0:D0Re0
  8198. + NEGS D0Re0, D0Re0 ! man = -man
  8199. + NEG D1Re0, D1Re0
  8200. + SUBNZ D1Re0, D1Re0, #1
  8201. +
  8202. +$L9: ! man +ve
  8203. + NORM D1Ar1, D1Re0
  8204. + BZ $L10 ! MSword zero
  8205. +
  8206. + CMP D1Ar1, #0 ! Already normalised ?
  8207. + BZ $L11 ! yes, skip normlisation
  8208. +
  8209. + MOV D0Ar2, D1Re0 ! Shifting < 32 bits
  8210. + FFB D0Ar2, D0Ar2
  8211. +
  8212. + LSL D1Re0, D1Re0, D1Ar1 ! MSWord
  8213. + ADD D0Ar2, D0Ar2, #2
  8214. + LSR D1Ar3, D0Re0, D0Ar2
  8215. + OR D1Re0, D1Re0, D1Ar3
  8216. +
  8217. + MOV D0Ar2, D1Ar1
  8218. + LSL D0Re0, D0Re0, D0Ar2 ! LSWord
  8219. +
  8220. + SUB D1Ar5, D1Ar5, D1Ar1 ! exp -= NORM (man)
  8221. + B $L11
  8222. +
  8223. +$L10: ! Shifting >= 32 bits
  8224. + MOVS D1Re0, D0Re0 ! Shift by 32 bits.
  8225. + SUBGT D0Re0, D0Re0, D0Re0
  8226. +
  8227. + LSRLT D1Re0, D1Re0, #1 ! If the results has MSBit set the
  8228. + LSLLT D0Re0, D0Re0, #31 ! we must only shift by 31 bits so
  8229. + ! we dont use NORM on a neg value.
  8230. +
  8231. + SUBLT D1Ar5, D1Ar5, #31 ! adjust exponent
  8232. + SUBGE D1Ar5, D1Ar5, #32
  8233. +
  8234. + NORM D1Ar1, D1Re0
  8235. +
  8236. +
  8237. + NEG D0Ar4, D1Ar1 ! (32 - D1Ar1)
  8238. + ADD D0Ar4, D0Ar4, #32
  8239. +
  8240. + LSR D0Ar4, D0Re0, D0Ar4
  8241. + MOV D0Ar2, D1Ar1
  8242. + LSL D0Re0, D0Re0, D0Ar2
  8243. + OR D0Re0, D0Re0, D0Ar4
  8244. + LSL D1Re0, D1Re0, D1Ar1
  8245. +
  8246. + SUB D1Ar5, D1Ar5, D1Ar1 ! exp -= NORM (man)
  8247. +
  8248. +$L11:
  8249. + ADD D1Ar5, D1Ar5, #(10-9)
  8250. +
  8251. + TST D0Re0, #(1<<10)
  8252. + BZ $L12
  8253. +
  8254. + ADDS D0Re0, D0Re0, #1 ! man += 1
  8255. + ADDCS D1Re0, D1Re0, #1
  8256. +
  8257. +$L12:
  8258. + ADDS D0Re0, D0Re0, #((1<<9)-1)
  8259. + ADDCS D1Re0, D1Re0, #1
  8260. +
  8261. + TSTT D1Re0, #0x8000 ! rounding overflowed?
  8262. + BZ $L14
  8263. +
  8264. + ! adjust man and exp
  8265. + LSR D0Re0, D0Re0, #1 ! man >>= 1
  8266. + LSL D0Ar2, D1Re0, #(32-1)
  8267. + LSR D1Re0, D1Re0, #1
  8268. + OR D0Re0, D0Re0, D0Ar2
  8269. +
  8270. + ADD D1Ar5, D1Ar5, #1 ! exp += 1
  8271. +
  8272. +$L14:
  8273. + CMP D1Ar5, #0 ! exp <= 0 ?
  8274. + SUBLE D0Re0, D0Re0, D0Re0 ! underflow
  8275. + MOVLE D1Re0, D1Ar3
  8276. + MOVLE PC, D1RtP ! return +/-Zero
  8277. +
  8278. + LSR D0Re0, D0Re0, #10
  8279. + LSL D0Ar4, D1Re0, #(32-10)
  8280. + OR D0Re0, D0Re0, D0Ar4
  8281. + LSR D1Re0, D1Re0, #10 ! man >>= 10
  8282. +
  8283. + ANDMT D1Re0, D1Re0, #0x000F
  8284. + LSL D1Ar5, D1Ar5, #(52 - 32) ! position exp
  8285. + MOV D1Ar3, D0Ar6
  8286. + OR D1Ar5, D1Ar5, D1Ar3 ! sign|exp
  8287. + OR D1Re0, D1Re0, D1Ar5 ! man|exp|sign -> D1Re0, D0Re0
  8288. +
  8289. + MOV PC, D1RtP
  8290. + .size ___adddf3,.-___adddf3
  8291. +#endif
  8292. +
  8293. +#ifdef L_addsf3
  8294. +!!
  8295. +!! Floating point - float add
  8296. +!!
  8297. + .text
  8298. + .global ___addsf3
  8299. + .type ___addsf3,function
  8300. + .align 2
  8301. +___addsf3:
  8302. + MOV D1Re0, D0Ar2
  8303. + AND D1Re0, D1Re0, D1Ar1
  8304. + ANDT D1Re0, D1Re0, #0x8000 ! sign = sign1 & sign2
  8305. +
  8306. + LSLS D0Re0, D1Ar1, #1 ! Ignore sign bit
  8307. + LSL D0Re0, D0Ar2, #1
  8308. + ORSZ D0Re0, D0Re0, D0Re0
  8309. +
  8310. + MOVZ D0Re0, D1Re0 ! sign = sign1 & sign2
  8311. + MOVZ PC, D1RtP ! both zero return +/-Zero
  8312. +
  8313. + LSLS D0Re0, D1Ar1, #1 ! Ignore sign bit
  8314. + MOVZ D0Re0, D0Ar2
  8315. + MOVZ PC, D1RtP ! Arg1 zero return Arg2
  8316. +
  8317. + LSLS D0Re0, D0Ar2, #1 ! Ignore sign bit
  8318. + MOVZ D0Re0, D1Ar1
  8319. + MOVZ PC, D1RtP ! Arg2 zero return Arg1
  8320. +
  8321. + MOV D1Ar5, D1Ar1
  8322. + ANDMT D1Ar5, D1Ar5, #0x7FFF
  8323. + LSR D1Ar5, D1Ar5, #23 ! exp1
  8324. +
  8325. + MOV D1Ar3, D0Ar2
  8326. + ANDMT D1Ar3, D1Ar3, #0x7FFF
  8327. + LSR D1Ar3, D1Ar3, #23 ! exp2
  8328. +
  8329. + SUB D0Re0, D1Ar5, D1Ar3 ! exp1 - exp2
  8330. + CMP D0Re0, #25 ! >25
  8331. +
  8332. + MOVGT D0Re0, D1Ar1
  8333. + MOVGT PC, D1RtP
  8334. +
  8335. + CMP D0Re0, #-25 ! <-25
  8336. +
  8337. + MOVLT D0Re0, D0Ar2
  8338. + MOVLT PC, D1RtP
  8339. +
  8340. + MOV D0Ar6, D1Ar1
  8341. + ANDMT D0Ar6, D0Ar6, #0x007F
  8342. + ORT D0Ar6, D0Ar6, #0x0080 ! man1
  8343. + LSL D0Ar6, D0Ar6, #6 ! man1 <<= 6
  8344. +
  8345. + MOV D0Ar4, D0Ar2
  8346. + ANDMT D0Ar4, D0Ar4, #0x007F
  8347. + ORT D0Ar4, D0Ar4, #0x0080 ! man2
  8348. + LSL D0Ar4, D0Ar4, #6 ! man2 <<= 6
  8349. +
  8350. + CMP D1Ar1, #0
  8351. + BGE $L4
  8352. +
  8353. + NEG D0Ar6, D0Ar6 ! man1 = -man1
  8354. +
  8355. +$L4:
  8356. + CMP D0Ar2, #0
  8357. + BGE $L5
  8358. +
  8359. + NEG D0Ar4, D0Ar4 ! man2 = -man2
  8360. +
  8361. +$L5:
  8362. + CMP D0Re0, #0 ! D0Re0 = exp1 - exp2
  8363. + BGE $L6
  8364. +
  8365. + NEG D0Re0, D0Re0
  8366. + ASR D0Ar6, D0Ar6, D0Re0 ! man1 >> (exp2 - exp1)
  8367. + MOV D1Ar5, D1Ar3 ! D1Ar5 = exp2
  8368. + B $L7
  8369. +
  8370. +$L6:
  8371. + ASR D0Ar4, D0Ar4, D0Re0 ! man2 >> (exp1 - exp2)
  8372. +
  8373. +$L7:
  8374. + ADDS D0Re0, D0Ar6, D0Ar4 ! man = man1 + man2
  8375. + MOV D1Re0, #0 ! --> sign
  8376. + MOVZ PC, D1RtP
  8377. +
  8378. + BGT $L8
  8379. + MOVT D1Re0, #0x8000 ! --->sign
  8380. + NEG D0Re0, D0Re0
  8381. +
  8382. +$L8:
  8383. + MOV D0Ar4, D0Re0 ! man
  8384. + ANDT D0Ar4, D0Ar4, #0xE000
  8385. + CMP D0Ar4, #0
  8386. + BNE $L9
  8387. +
  8388. + LSL D0Re0, D0Re0, #1
  8389. + SUB D1Ar5, D1Ar5, #1
  8390. + B $L8
  8391. +
  8392. +$L9:
  8393. + MOV D0Ar4, D0Re0 ! D0Ar4 = man
  8394. + ANDT D0Re0, D0Re0, #0x4000
  8395. + CMP D0Re0, #0
  8396. + BZ $L11
  8397. +
  8398. + LSR D0Ar4, D0Ar4, #1
  8399. + ADD D1Ar5, D1Ar5, #1
  8400. +
  8401. +$L11:
  8402. + MOV D0Ar6, D0Ar4
  8403. + AND D0Ar6, D0Ar6, #0x40
  8404. + CMP D0Ar6, #0
  8405. + ADDNZ D0Ar4, D0Ar4, #1
  8406. + ADD D0Ar4, D0Ar4, #0x1F
  8407. + MOV D0Ar6, D0Ar4
  8408. + ANDT D0Ar6, D0Ar6, #0x4000
  8409. + CMP D0Ar6, #0
  8410. + BZ $L13
  8411. +
  8412. + ASR D0Ar4, D0Ar4, #1
  8413. + ADD D1Ar5, D1Ar5, #1
  8414. +
  8415. +$L13:
  8416. + CMP D1Ar5, #0 ! exp <= 0 ?
  8417. + MOVLE D0Re0, D1Re0 ! underflow
  8418. + MOVLE PC, D1RtP ! return +/-Zero
  8419. +
  8420. + LSR D0Ar4, D0Ar4, #6 ! man >>= 6
  8421. + MOV D0Ar6, D1Ar5
  8422. + LSL D0Ar6, D0Ar6, #23
  8423. +
  8424. + MOV D0Re0, D1Re0
  8425. + OR D0Re0, D0Re0, D0Ar6
  8426. + ANDMT D0Ar4, D0Ar4, #0x007F
  8427. + OR D0Re0, D0Re0, D0Ar4
  8428. +
  8429. + MOV PC, D1RtP
  8430. + .size ___addsf3,.-___addsf3
  8431. +#endif
  8432. +
  8433. +#ifdef L_subdf3
  8434. +!!
  8435. +!! Floating point - double sub
  8436. +!!
  8437. + .text
  8438. + .global ___subdf3
  8439. + .type ___subdf3,function
  8440. + .align 2
  8441. +___subdf3:
  8442. + MOV D1Re0, D0Ar4
  8443. + ORS D0Re0, D1Ar3, D1Re0
  8444. + MOVZ D1Re0, D1Ar1
  8445. + MOVZ D0Re0, D0Ar2
  8446. + MOVZ PC, D1RtP
  8447. + XORT D1Ar3, D1Ar3, #0x8000
  8448. +#ifdef __PIC__
  8449. + B ___adddf3@PLT
  8450. +#else
  8451. + B ___adddf3
  8452. +#endif
  8453. + .size ___subdf3,.-___subdf3
  8454. +#endif
  8455. +
  8456. +#ifdef L_addsf3
  8457. +!!
  8458. +!! Floating point - float sub
  8459. +!!
  8460. + .text
  8461. + .global ___subsf3
  8462. + .type ___subsf3,function
  8463. + .align 2
  8464. +___subsf3:
  8465. + CMP D0Ar2, #0
  8466. + MOVZ D0Re0, D1Ar1
  8467. + MOVZ PC, D1RtP
  8468. + XORT D0Ar2, D0Ar2, #0x8000
  8469. +#ifdef __PIC__
  8470. + B ___addsf3@PLT
  8471. +#else
  8472. + B ___addsf3
  8473. +#endif
  8474. + .size ___subsf3,.-___subsf3
  8475. +#endif
  8476. +
  8477. +#ifdef L_negdf2
  8478. +!!
  8479. +!! Floating point - double negate
  8480. +!!
  8481. + .text
  8482. + .global ___negdf2
  8483. + .type ___negdf2,function
  8484. + .align 2
  8485. +___negdf2:
  8486. + MOV D0Re0, D0Ar2
  8487. + MOV D1Re0, D1Ar1
  8488. + XORT D1Re0, D1Re0, #0x8000
  8489. + MOV PC, D1RtP
  8490. + .size ___negdf2,.-___negdf2
  8491. +#endif
  8492. +
  8493. +#ifdef L_negsf2
  8494. +!!
  8495. +!! Floating point - double negate
  8496. +!!
  8497. + .text
  8498. + .global ___negsf2
  8499. + .type ___negsf2,function
  8500. + .align 2
  8501. +___negsf2:
  8502. + MOV D0Re0, D1Ar1
  8503. + XORT D0Re0, D0Re0, #0x8000
  8504. + MOV PC, D1RtP
  8505. + .size ___negsf2,.-___negsf2
  8506. +#endif
  8507. +
  8508. +#ifdef L_cmpdf2
  8509. +!!
  8510. +!! Compare two double(s)
  8511. +!! return -1 if <
  8512. +!! 0 if ==
  8513. +!! +1 if >
  8514. + .text
  8515. + .global ___cmpdf2
  8516. + .type ___cmpdf2,function
  8517. + .align 2
  8518. +___cmpdf2:
  8519. + LSR A0.2, D1Ar1, #31 ! sign1
  8520. + LSR A0.3, D1Ar3, #31 ! sign2
  8521. +
  8522. + LSR D1Ar5, D1Ar1, #(52-32) ! exp1
  8523. + AND D1Ar5, D1Ar5, #0x07FF
  8524. +
  8525. + LSR D0Ar6, D1Ar3, #(52-32) ! exp2
  8526. + AND D0Ar6, D0Ar6, #0x07FF
  8527. +
  8528. + ANDMT D1Ar1, D1Ar1, #0x000F ! mant1
  8529. + ANDMT D1Ar3, D1Ar3, #0x000F ! mant1
  8530. +
  8531. +!!
  8532. +!! if (D_NAN_P (dp1) || D_NAN_P (dp2))
  8533. +!! return 1;
  8534. +
  8535. + MOV D0Re0, #1
  8536. +
  8537. + CMP D1Ar5, #0x07FF ! exp1 == 0x07FF
  8538. + BNE $L1
  8539. +
  8540. + ORS D1Re0, D1Ar1, D1Ar1 ! HI(mant1) == 0?
  8541. + ORSZ D1Re0, D0Ar2, D0Ar2 ! and LO(mant1) == 0?
  8542. + MOVNZ PC, D1RtP ! no, Nan, return 1
  8543. +
  8544. + B $L2
  8545. +
  8546. +$L1:
  8547. +
  8548. + CMP D0Ar6, #0x07FF ! exp2 == 0x07FF
  8549. + BNE $L2
  8550. +
  8551. + ORS D1Re0, D1Ar3, D1Ar3 ! HI(mant2) == 0 ?
  8552. + ORSZ D1Re0, D0Ar4, D0Ar4 ! and LO(mant2) == 0 ?
  8553. + MOVNZ PC, D1RtP ! no, Nan, return 1
  8554. +
  8555. +$L2:
  8556. +!!
  8557. +!! if (D_INF_P (dp1) && D_INF_P (dp2))
  8558. +!! return sign2 - sign1;
  8559. +!!
  8560. +
  8561. + SUB D0Re0, A0.3, A0.2
  8562. +
  8563. + MOV D1Re0, D0Ar6
  8564. + AND D1Re0, D1Re0, D1Ar5
  8565. + CMP D1Re0, #0x7FF ! (exp1 & exp2) == 0x7FF
  8566. +
  8567. + CMPEQ D1Ar1,D1Ar3
  8568. + CMPEQ D0Ar2,D0Ar4 ! mant1 == mant2
  8569. + CMPEQ D1Ar1, #0
  8570. + CMPEQ D0Ar2, #0 ! == 0
  8571. + MOVEQ PC, D1RtP
  8572. +
  8573. +!! if (D_INF_P (dp1))
  8574. +!! return sign1 ? -1 : 1;
  8575. +
  8576. + MOV D0Re0, #0 ! result
  8577. + MOV D1Re0, A0.2
  8578. + TST D1Re0, #1 ! sign1 ?
  8579. + SUBNZ D0Re0, D0Re0, #1 ! -1
  8580. + ADDZ D0Re0, D0Re0, #1 ! +1
  8581. +
  8582. + CMP D1Ar5, #0x7FF ! exp1 == 0x7FF
  8583. + MOVEQ D1Re0, D0Ar2
  8584. + ORSEQ D1Re0, D1Re0, D1Ar1 ! mant1 == 0
  8585. + MOVEQ PC, D1RtP
  8586. +
  8587. +!!
  8588. +!! if (D_INF_P (dp2))
  8589. +!! return sign2 ? 1 : -1;
  8590. +
  8591. + MOV D0Re0, #0 ! result
  8592. + MOV D1Re0, A0.3
  8593. + TST D1Re0, #1 ! sign2 ?
  8594. + ADDNZ D0Re0, D0Re0, #1 ! +1
  8595. + SUBZ D0Re0, D0Re0, #1 ! -1
  8596. +
  8597. + CMP D0Ar6, #0x7FF ! exp2 == 0x7FF
  8598. + MOVEQ D1Re0, D0Ar4
  8599. + ORSEQ D1Re0, D1Re0, D1Ar3 ! mant2 == 0
  8600. + MOVEQ PC, D1RtP
  8601. +
  8602. +!!
  8603. +!! if (D_ZERO_P (dp1) && D_ZERO_P (dp2))
  8604. +!! return 0;
  8605. +
  8606. + MOV D0Re0, #0
  8607. + MOV D1Re0, D0Ar6
  8608. + ORS D1Re0, D1Re0, D1Ar5 ! exp1 | exp1
  8609. + ORSZ D1Re0, D1Ar1, D1Ar3 ! mant1 | mant2
  8610. + ORSZ D1Re0, D0Ar2, D0Ar4
  8611. + MOVZ PC, D1RtP ! both zero return 0
  8612. +!!
  8613. +!! if (D_ZERO_P (dp1))
  8614. +!! return sign2 ? 1 : -1;
  8615. +!!
  8616. +
  8617. + ! result (D0Re0) already 0
  8618. + MOV D1Re0, A0.3
  8619. + TST D1Re0, #1 ! sign2?
  8620. + ADDNZ D0Re0, D0Re0, #1 ! +1
  8621. + SUBZ D0Re0, D0Re0, #1 ! -1
  8622. +
  8623. + ORS D1Re0, D1Ar5, D1Ar5 ! exp1 == 0
  8624. + ORSZ D1Re0, D1Ar1, D1Ar1 ! and mant1 == 0
  8625. + ORSZ D1Re0, D0Ar2, D0Ar2
  8626. + MOVZ PC, D1RtP
  8627. +
  8628. +!! if (D_ZERO_P (dp2))
  8629. +!! return sign1 ? -1 : 1;
  8630. +
  8631. + MOV D0Re0, #0 ! result
  8632. + MOV D1Re0, A0.2
  8633. + TST D1Re0, #1 ! sign1?
  8634. + SUBNZ D0Re0, D0Re0, #1 ! -1
  8635. + ADDZ D0Re0, D0Re0, #1 ! +1
  8636. +
  8637. + ORS D1Re0, D0Ar6, D0Ar6 ! exp2 == 0
  8638. + ORSZ D1Re0, D1Ar3, D1Ar3 ! and mant2 == 0
  8639. + ORSZ D1Re0, D0Ar4, D0Ar4
  8640. + MOVZ PC, D1RtP
  8641. +
  8642. +!! /* Normalize the numbers. */
  8643. +!! D_NORMALIZE (dp1, exp1, mant1);
  8644. +!! D_NORMALIZE (dp2, exp2, mant2);
  8645. +
  8646. +!! now both are "normal".
  8647. +
  8648. + MOV D0Re0, #0 ! result
  8649. + MOV D1Re0,A0.2
  8650. + TST D1Re0, #1 ! sign1
  8651. + SUBNZ D0Re0, D0Re0, #1 ! -1
  8652. + ADDZ D0Re0, D0Re0, #1 ! +1
  8653. +
  8654. + SUB D1Re0, A0.2, A0.3
  8655. + CMP D1Re0, #0 ! sign1 != sign2
  8656. + MOVNE PC, D1RtP ! yes, return sign1 ? -1 : +1
  8657. +
  8658. + MOV D1Re0, D0Ar6
  8659. + CMP D1Ar5, D1Re0 ! exp1 > exp2
  8660. + MOVGT PC, D1RtP ! yes, return sign1 ? -1 : +1
  8661. +
  8662. + NEG D0Re0, D0Re0 ! result -= result
  8663. + MOVLT PC, D1RtP ! exp < exp2 return -(sign1 ? -1 : +1)
  8664. +
  8665. + CMP D1Ar1, D1Ar3 ! HI(mant1) < HI(mant2)
  8666. + CMPEQ D0Ar2, D0Ar4 ! LO(mant1) < LO(mant2)
  8667. + MOVLO PC, D1RtP ! yes, return -(sign1 ? -1 : +1)
  8668. +
  8669. + NEG D0Re0, D0Re0 ! result = -result
  8670. + MOVHI PC, D1RtP ! > return sign1 ? -1 : +1
  8671. +
  8672. + MOV D0Re0, #0
  8673. + MOV PC, D1RtP
  8674. + .size ___cmpdf2,.-___cmpdf2
  8675. +#endif
  8676. +
  8677. +#ifdef L_cmpdf2_nan
  8678. +!!
  8679. +!! Filters for Nan arguments before calling ___cmpdf2
  8680. +!!
  8681. +!! If either Arg1 or Arg2 is Nan then return Arg3 (D1Ar5)
  8682. +!! otherwise tail calls ___cmpdf2
  8683. +!!
  8684. + .text
  8685. + .global ___cmpdf2_nan
  8686. + .type ___cmpdf2_nan,function
  8687. + .align 2
  8688. +___cmpdf2_nan:
  8689. + LSR D1Re0, D1Ar1, #(52-32) ! arg1 NAN ?
  8690. + AND D1Re0, D1Re0, #0x07FF
  8691. + CMP D1Re0, #0x07FF ! exp all 1s
  8692. + BNE $L10
  8693. +
  8694. + MOV D0Ar6, D1Ar1
  8695. + LSL D0Ar6, D0Ar6, #(64-52) ! mantisa non-zero?
  8696. + ORS D0Ar6, D0Ar6, D0Ar2
  8697. + MOVNZ D0Re0, D1Ar5
  8698. + MOVNZ PC, D1RtP ! return (D1Ar3)
  8699. +
  8700. +$L10:
  8701. + LSR D1Re0, D1Ar3, #(52-32) ! arg2 NAN ?
  8702. + AND D1Re0, D1Re0, #0x07FF
  8703. + CMP D1Re0, #0x07FF ! exp all 1s
  8704. + BNE $L11
  8705. +
  8706. + MOV D0Ar6, D1Ar3
  8707. + LSL D0Ar6, D0Ar6, #(64-52) ! mantisa non-zero?
  8708. + ORS D0Ar6, D0Ar6, D0Ar4
  8709. + MOVNZ D0Re0, D1Ar5
  8710. + MOVNZ PC, D1RtP ! return (D1Ar3)
  8711. +
  8712. +$L11:
  8713. +#ifdef __PIC__
  8714. + B ___cmpdf2@PLT
  8715. +#else
  8716. + B ___cmpdf2
  8717. +#endif
  8718. + .size ___cmpdf2_nan,.-___cmpdf2_nan
  8719. +#endif
  8720. +
  8721. +#ifdef L_cmpsf2
  8722. +!!
  8723. +!! Compare two float(s)
  8724. +!! return -1 if <
  8725. +!! 0 if ==
  8726. +!! +1 if >
  8727. +!!
  8728. + .text
  8729. + .global ___cmpsf2
  8730. + .type ___cmpsf2,function
  8731. + .align 2
  8732. +___cmpsf2:
  8733. + LSR D1Ar3, D1Ar1, #31 ! sign1
  8734. + LSR D1Ar5, D0Ar2, #31 ! sign2
  8735. +
  8736. + LSR D0Ar4, D1Ar1, #23 ! exp1
  8737. + AND D0Ar4, D0Ar4, #0x00FF
  8738. +
  8739. + LSR D0Ar6, D0Ar2, #23 ! exp2
  8740. + AND D0Ar6, D0Ar6, #0x00FF
  8741. +
  8742. + ANDMT D1Ar1, D1Ar1, #0x007F ! mant1
  8743. + ANDMT D0Ar2, D0Ar2, #0x007F ! mant2
  8744. +
  8745. +!! if (F_NAN_P (fp1) || F_NAN_P (fp2))
  8746. +!! return 1;
  8747. +
  8748. + MOV D0Re0, #1
  8749. +
  8750. + CMP D0Ar4, #0xFF ! exp1 == 0xFF?
  8751. + BNE $L1
  8752. +
  8753. + CMP D1Ar1, #0 ! and mant1 == 0?
  8754. + MOVNZ PC, D1RtP ! No, Nan, return 1
  8755. +
  8756. + B $L2
  8757. +
  8758. +$L1:
  8759. + CMP D0Ar6, #0xFF ! exp2 == 0xFF?
  8760. + BNE $L2
  8761. +
  8762. + CMP D0Ar2, #0 ! mant2 == 0?
  8763. + MOVNZ PC, D1RtP ! No, Nan, return 1
  8764. +
  8765. +$L2:
  8766. +
  8767. +!! if (F_INF_P (fp1) && F_INF_P (fp2))
  8768. +!! return sign2 - sign1;
  8769. +
  8770. + SUB D0Re0, D1Ar5, D1Ar3 ! sign2 - sign1
  8771. +
  8772. + AND D1Re0, D0Ar4, D0Ar6
  8773. + CMP D1Re0, #0xFF ! (exp1 & exp2) == 0xFF
  8774. + MOV D1Re0, D0Ar2
  8775. + CMPEQ D1Ar1, D1Re0 ! mant1 == mant2
  8776. + CMPEQ D1Ar1, #0 ! == 0
  8777. + MOVEQ PC, D1RtP
  8778. +
  8779. +!! if (F_INF_P (fp1))
  8780. +!! return sign1 ? -1 : 1;
  8781. +
  8782. + MOV D0Re0, #0 ! result
  8783. + TST D1Ar3, #1 ! sign1 ?
  8784. + SUBNZ D0Re0, D0Re0, #1 ! -1
  8785. + ADDZ D0Re0, D0Re0, #1 ! +1
  8786. +
  8787. + CMP D0Ar4, #0x00FF ! exp1 == 0xFF
  8788. + CMPEQ D1Ar1, #0 ! mant1 == 0
  8789. + MOVEQ PC, D1RtP
  8790. +
  8791. +!! if (F_INF_P (fp2))
  8792. +!! return sign2 ? 1 : -1;
  8793. +
  8794. + MOV D0Re0, #0 ! result
  8795. + TST D1Ar5, #1 ! sign2 ?
  8796. + ADDNZ D0Re0, D0Re0, #1 ! +1
  8797. + SUBZ D0Re0, D0Re0, #1 ! -1
  8798. +
  8799. + CMP D0Ar6, #0x00FF ! exp2 == 0xFF
  8800. + CMPEQ D0Ar2, #0 ! mant2 == 0
  8801. + MOVEQ PC, D1RtP
  8802. +
  8803. +!! if (F_ZERO_P (fp1) && F_ZERO_P (fp2))
  8804. +!! return 0;
  8805. +
  8806. + MOV D0Re0, #0
  8807. + ORS D1Re0, D0Ar4, D0Ar6 ! exp1 | exp2
  8808. + MOV D1Re0, D0Ar2
  8809. + ORSZ D1Re0, D1Ar1, D1Re0 ! mant1 | mant1
  8810. + MOVZ PC, D1RtP ! both zero return 0
  8811. +
  8812. +!! if (F_ZERO_P (fp1))
  8813. +!! return sign2 ? 1 : -1;
  8814. +
  8815. + ! result (D0Re0) already 0
  8816. + TST D1Ar5, #1 ! sign2 ?
  8817. + ADDNZ D0Re0, D0Re0, #1 ! +1
  8818. + SUBZ D0Re0, D0Re0, #1 ! -1
  8819. +
  8820. + ORS D1Re0, D0Ar4, D0Ar4 ! exp1 == 0
  8821. + ORSZ D1Re0, D1Ar1, D1Ar1 ! and mant1 == 0?
  8822. + MOVZ PC, D1RtP
  8823. +
  8824. +!! if (F_ZERO_P (fp2))
  8825. +!! return sign1 ? -1 : 1;
  8826. +
  8827. + MOV D0Re0, #0 ! result
  8828. + TST D1Ar3, #1 ! sign1 ?
  8829. + SUBNZ D0Re0, D0Re0, #1 ! -1
  8830. + ADDZ D0Re0, D0Re0, #1 ! +1
  8831. +
  8832. + ORS D1Re0, D0Ar6, D0Ar2 ! exp2 and mant2 == 0?
  8833. + MOVZ PC, D1RtP
  8834. +
  8835. +!! /* Normalize the numbers. */
  8836. +!! F_NORMALIZE (fp1, exp1, mant1);
  8837. +!! F_NORMALIZE (fp2, exp2, mant2);
  8838. +
  8839. +!! now both are "normal".
  8840. +
  8841. + MOV D0Re0, #0 ! result
  8842. + TST D1Ar3, #1 ! sign1 ?
  8843. + SUBNZ D0Re0, D0Re0, #1 ! -1
  8844. + ADDZ D0Re0, D0Re0, #1 ! +1
  8845. +
  8846. + CMP D1Ar3, D1Ar5 ! sign1 != sign2
  8847. + MOVNE PC, D1RtP ! yes, return sign1 ? -1 : +1
  8848. +
  8849. + CMP D0Ar4, D0Ar6 ! exp1 > exp2
  8850. + MOVGT PC, D1RtP ! yes, return sign1 ? -1 : +1
  8851. +
  8852. + NEG D0Re0, D0Re0 ! result -= result
  8853. + MOVLT PC, D1RtP ! exp < exp2 return -(sign1 ? -1 : +1)
  8854. +
  8855. + MOV D1Re0, D0Ar2
  8856. + CMP D1Ar1, D1Re0 ! mant1 < mant2
  8857. + MOVLT PC, D1RtP ! yes, return -(sign1 ? -1 : +1)
  8858. +
  8859. + NEG D0Re0, D0Re0 ! result = -result
  8860. + MOVGT PC, D1RtP ! > return sign1 ? -1 : +1
  8861. +
  8862. + MOV D0Re0, #0
  8863. + MOV PC, D1RtP
  8864. + .size ___cmpsf2,.-___cmpsf2
  8865. +#endif
  8866. +
  8867. +#ifdef L_cmpsf2_nan
  8868. +!!
  8869. +!! Filters for Nan arguments before calling ___cmpsf2
  8870. +!!
  8871. +!! If either Arg1 or Arg2 is Nan then return Arg3 (D1Ar3)
  8872. +!! otherwise tail calls ___cmpsf2
  8873. +!!
  8874. + .text
  8875. + .global ___cmpsf2_nan
  8876. + .type ___cmpsf2_nan,function
  8877. + .align 2
  8878. +___cmpsf2_nan:
  8879. + LSR D1Re0, D1Ar1, #23 ! arg1 NAN ?
  8880. + AND D1Re0, D1Re0, #0x00FF
  8881. + CMP D1Re0, #0x00FF ! exp all 1s
  8882. + BNE $L10
  8883. +
  8884. + MOV D1Re0, D1Ar1
  8885. + LSLS D1Re0, D1Re0, #(32-23) ! mantisa non-zero?
  8886. + MOVNZ D0Re0, D1Ar3
  8887. + MOVNZ PC, D1RtP ! return (D1Ar3)
  8888. +
  8889. +$L10:
  8890. + LSR D1Re0, D0Ar2, #23 ! arg2 NAN ?
  8891. + AND D1Re0, D1Re0, #0x00FF
  8892. + CMP D1Re0, #0x00FF ! exp all 1s
  8893. + BNE $L11
  8894. +
  8895. + MOV D1Re0, D0Ar2
  8896. + LSLS D1Re0, D1Re0, #(32-23) ! mantisa non-zero?
  8897. + MOVNZ D0Re0, D1Ar3
  8898. + MOVNZ PC, D1RtP ! return (D1Ar3)
  8899. +
  8900. +$L11:
  8901. +#ifdef __PIC__
  8902. + B ___cmpsf2@PLT
  8903. +#else
  8904. + B ___cmpsf2
  8905. +#endif
  8906. + .size ___cmpsf2_nan,.-___cmpsf2_nan
  8907. +#endif
  8908. +
  8909. +#ifdef L_eqdf2
  8910. +!!
  8911. +!! Floating point - double comparison routines ==,!=,<,<==,>,>=
  8912. +!! Wrapper entry points for common cmpdf2 routine, these entry points
  8913. +!! set up correct return value if either is Nan.
  8914. +!!
  8915. + .text
  8916. + .global ___eqdf2
  8917. + .type ___eqdf2,function
  8918. + .global ___nedf2
  8919. + .type ___nedf2,function
  8920. + .global ___ltdf2
  8921. + .type ___ltdf2,function
  8922. + .global ___ledf2
  8923. + .type ___ledf2,function
  8924. + .align 2
  8925. +___eqdf2:
  8926. +___nedf2:
  8927. +___ltdf2:
  8928. +___ledf2:
  8929. +
  8930. +!! If either is NAN return +1
  8931. +
  8932. + MOV D1Ar5, #1
  8933. +#ifdef __PIC__
  8934. + B ___cmpdf2_nan@PLT
  8935. +#else
  8936. + B ___cmpdf2_nan
  8937. +#endif
  8938. + .size ___eqdf2,.-___eqdf2
  8939. + .size ___nedf2,.-___nedf2
  8940. + .size ___ltdf2,.-___ltdf2
  8941. + .size ___ledf2,.-___ledf2
  8942. +
  8943. + .global ___gedf2
  8944. + .type ___gedf2,function
  8945. + .global ___gtdf2
  8946. + .type ___gtdf2,function
  8947. + .align 2
  8948. +___gedf2:
  8949. +___gtdf2:
  8950. +
  8951. +!! If either is NAN return -1
  8952. +
  8953. + MOV D1Ar5, #-1
  8954. +#ifdef __PIC__
  8955. + B ___cmpdf2_nan@PLT
  8956. +#else
  8957. + B ___cmpdf2_nan
  8958. +#endif
  8959. + .size ___gedf2,.-___gedf2
  8960. + .size ___gtdf2,.-___gtdf2
  8961. +#endif
  8962. +
  8963. +#ifdef L_eqsf2
  8964. +!!
  8965. +!! Floating point - float comparison routines ==,!=,<,<==,>,>=
  8966. +!! Wrapper entry points for common cmpsf2 routine, these entry points
  8967. +!! set up correct return value if either is Nan.
  8968. +!!
  8969. + .text
  8970. + .global ___eqsf2
  8971. + .type ___eqsf2,function
  8972. + .global ___nesf2
  8973. + .type ___nesf2,function
  8974. + .global ___ltsf2
  8975. + .type ___ltsf2,function
  8976. + .global ___lesf2
  8977. + .type ___lesf2,function
  8978. + .align 2
  8979. +___eqsf2:
  8980. +___nesf2:
  8981. +___ltsf2:
  8982. +___lesf2:
  8983. +
  8984. +!! If either is NAN return +1
  8985. +
  8986. + MOV D1Ar3, #1
  8987. +#ifdef __PIC__
  8988. + B ___cmpsf2_nan@PLT
  8989. +#else
  8990. + B ___cmpsf2_nan
  8991. +#endif
  8992. + .size ___eqsf2,.-___eqsf2
  8993. + .size ___nesf2,.-___nesf2
  8994. + .size ___ltsf2,.-___ltsf2
  8995. + .size ___lesf2,.-___lesf2
  8996. +
  8997. + .global ___gesf2
  8998. + .type ___gesf2,function
  8999. + .global ___gtsf2
  9000. + .type ___gtsf2,function
  9001. + .align 2
  9002. +___gesf2:
  9003. +___gtsf2:
  9004. +
  9005. +!! If either is NAN return -1
  9006. +
  9007. + MOV D1Ar3, #-1
  9008. +#ifdef __PIC__
  9009. + B ___cmpsf2_nan@PLT
  9010. +#else
  9011. + B ___cmpsf2_nan
  9012. +#endif
  9013. + .size ___gesf2,.-___gesf2
  9014. + .size ___gtsf2,.-___gtsf2
  9015. +#endif
  9016. +
  9017. +!! Division routines.
  9018. +
  9019. +#ifdef L_divdf3
  9020. +!!
  9021. +!! Function : double divdf3 (double a1, double a2)
  9022. +!!
  9023. +!! Args : a1 - double precision floating point number (D1Ar1:D0Ar2)
  9024. +!! : a2 - double precision floating point number (D1Ar3:D0Ar4)
  9025. +!!
  9026. +!! Description: Returns a1 divided by a2 (D1Re0:D0Re0)
  9027. +!!
  9028. +!! Returns : (+/-)0.0 / (+/-)0.0 = QNaN
  9029. +!! : (+/-)Inf / (+/-)Inf = NaN
  9030. +!! : n / (+/-)Inf = 0.0
  9031. +!! : n / (+/-)0.0 = (+/-)Inf
  9032. +!! : a1 / a2 = n.
  9033. +!!
  9034. +!! Notes : QNaN = 0xFFF80000:00000000 (Quiet NaN)
  9035. +!! : SNan = 0xFFF7FFFF:FFFFFFFF (Signaling Nan)
  9036. +!! : +Inf = 0x7FF00000:00000000
  9037. +!! : -Inf = 0xFFF00000:00000000
  9038. +!! : +0 = 0x00000000:00000000
  9039. +!! : -0 = 0x80000000:00000000
  9040. +!!
  9041. + .text
  9042. + .global ___divdf3
  9043. + .type ___divdf3,function
  9044. + .align 2
  9045. +___divdf3:
  9046. + XOR D1Re0, D1Ar1, D1Ar3 ! sign1 ^ sign2
  9047. + ANDT D1Re0, D1Re0, #0x8000 ! extract sign result
  9048. +
  9049. + ! Test if a1 == 0.0
  9050. + LSL D0Re0, D1Ar1, #1 ! Ignore sign bit
  9051. + ORS D0Re0, D0Re0, D0Ar2 ! a1 == 0 ?
  9052. + BZ $A1IsZero
  9053. +
  9054. + ! Test if a2 == 0.0
  9055. + LSL D0Re0, D1Ar3, #1 ! Ignore sign bit
  9056. + ORS D0Re0, D0Re0, D0Ar4 ! a2 == 0 ?
  9057. + BNZ $DoDivision
  9058. +
  9059. + ! a1 != 0.0 and a2 == 0.0, so return +/-Inf
  9060. + ORT D1Re0, D1Re0, #0x7FF0 ! Set exponent for (+/-)Inf
  9061. + MOV PC, D1RtP
  9062. +
  9063. +$A1IsZero:
  9064. + LSL D0Re0, D1Ar3, #1 ! Ignore sign bit
  9065. + ORS D0Re0, D0Re0, D0Ar4 ! a2 == 0 ?
  9066. + MOV D0Re0, #0
  9067. +
  9068. + ! a1 == 0.0 and a2 != 0.0, so return +/-Zero
  9069. + SUBNZ D0Re0, D0Re0, D0Re0
  9070. + MOVNZ PC, D1RtP ! (zero return already set up)
  9071. +
  9072. + ! a1 == 0.0 and a2 == 0.0, so return QNaN.
  9073. + MOVT D1Re0, #0xFFF8 ! maybe sign depends on sign1 ^ sign2
  9074. + MOV PC, D1RtP
  9075. +
  9076. +$DoDivision:
  9077. + MOV A0.3, D1Re0 ! sign -> A0.3
  9078. +
  9079. + MOV D1Ar5, D1Ar1
  9080. + ANDMT D1Ar5, D1Ar5, #0x7FFF
  9081. + LSR D1Ar5, D1Ar5, #20 ! exp1
  9082. +
  9083. + MOV D1Re0, D1Ar3
  9084. + ANDMT D1Re0, D1Re0, #0x7FFF
  9085. + LSR D1Re0, D1Re0, #20 ! exp2
  9086. +
  9087. + SUB D1Ar5, D1Ar5, D1Re0 ! exp = exp1 - exp2 + 1022
  9088. + ADD D1Ar5, D1Ar5, #1022 ! exp ---> D1Ar5
  9089. + MOV A0.2, D1Ar5 ! exp ---> A0.2
  9090. +
  9091. + ANDMT D1Ar1, D1Ar1, #0x000F
  9092. + ORT D1Ar1, D1Ar1, #0x0010 ! man1 --->D1Ar1, D0Ar2
  9093. +
  9094. + ANDMT D1Ar3, D1Ar3, #0x000F
  9095. + ORT D1Ar3, D1Ar3, #0x0010 ! man2 --->D1Ar3, D0Ar4
  9096. +
  9097. + CMP D1Ar1, D1Ar3 ! man1 < man2
  9098. + BGT $L2
  9099. + BLT $L3
  9100. +
  9101. + CMP D0Ar2, D0Ar4
  9102. + BGE $L2
  9103. +
  9104. +$L3:
  9105. + LSL D1Ar1, D1Ar1, #1 ! man1 <<= 1
  9106. + LSR D1Ar5, D0Ar2, #(32-1)
  9107. + OR D1Ar1, D1Ar1, D1Ar5
  9108. + LSL D0Ar2, D0Ar2, #1
  9109. +
  9110. + SUB A0.2, A0.2, #1 ! exp -= 1
  9111. +
  9112. +$L2:
  9113. + MOV D0Re0, #0 ! prepare the result in D1Re0, D0Re0
  9114. + ! mask = 1<<53 split into 21 + 31
  9115. + MOVT D0Ar6, #(1<<(21-16)) ! 1<< 21
  9116. + MOV D1Ar5, #2
  9117. +
  9118. +$L5:
  9119. + ! while (mask)
  9120. + CMP D0Ar6, #0
  9121. + BZ $L4
  9122. +
  9123. + CMP D1Ar1, D1Ar3 ! man1 >= man2
  9124. + BLT $L5_1
  9125. + BGT $L5_2
  9126. +
  9127. + CMP D0Ar2, D0Ar4
  9128. + BLT $L5_1
  9129. +
  9130. +$L5_2:
  9131. + OR D0Re0, D0Re0, D0Ar6 ! result |= mask
  9132. +
  9133. + SUB D1Ar1, D1Ar1, D1Ar3 ! man1 - man2
  9134. + SUBS D0Ar2, D0Ar2, D0Ar4
  9135. + SUBCS D1Ar1, D1Ar1, #1
  9136. +
  9137. +$L5_1:
  9138. + LSL D1Ar1, D1Ar1, #1 ! man1 <<= 1
  9139. + TSTT D0Ar2, #0x8000
  9140. + ORNZ D1Ar1, D1Ar1, #1 ! MSBit -> LSBit
  9141. + LSL D0Ar2, D0Ar2, #1
  9142. +
  9143. + LSR D0Ar6, D0Ar6, #1 ! mask >>= 1
  9144. + B $L5
  9145. +
  9146. +$L4:
  9147. + SUBS D1Ar5, D1Ar5, #1
  9148. + BZ $L6
  9149. +
  9150. + MOV D1Re0, D0Re0
  9151. + MOV D0Re0, #0
  9152. + MOVT D0Ar6, #(1<<(31-16)) ! 1 << 31
  9153. + B $L5
  9154. +
  9155. +$L6:
  9156. + ADDS D0Re0, D0Re0, #1 ! result += 1
  9157. + ADDCS D1Re0, D1Re0, #1
  9158. +
  9159. + ADD D1Ar3, A0.2, #1 ! exp += 1
  9160. +
  9161. + LSR D0Re0, D0Re0, #1 ! result <<= 1
  9162. + LSL D0Ar2, D1Re0, #(32-1)
  9163. + OR D0Re0, D0Re0, D0Ar2
  9164. + LSR D1Re0, D1Re0, #1
  9165. +
  9166. + MOV D1Ar1, A0.3
  9167. + ANDMT D1Re0, D1Re0, #0x000F ! discard hidden bit
  9168. + OR D1Re0, D1Re0, D1Ar1 ! combine sign
  9169. +
  9170. + MOV D1Ar5, #0
  9171. + MAX D1Ar3, D1Ar3, D1Ar5 ! exp < 0 ?
  9172. + SUBLT D0Re0, D0Re0, D0Re0 ! < 0 return +/-Zero
  9173. + MOVLT D1Re0, D1Ar1
  9174. + MOVLT PC, D1RtP
  9175. +
  9176. + SUBEQ D0Re0, D0Re0, D0Re0 ! Don(t) currently handle
  9177. + MOVEQ D1Re0, D1Ar1 ! denormals, so return
  9178. + MOVEQ PC, D1RtP ! +/-Zero
  9179. +
  9180. + MOV D1Ar5, #0x7FF
  9181. + MIN D1Ar3, D1Ar3, D1Ar5 ! exp >= 0x7FF
  9182. + SUBGE D0Re0, D0Re0, D0Re0 ! >= return +/- Inf
  9183. + MOVGE D1Re0, D1Ar1
  9184. +
  9185. + LSL D1Ar3, D1Ar3, #20 ! postion exp
  9186. + OR D1Re0, D1Re0, D1Ar3 ! combine exp
  9187. +
  9188. + MOV PC, D1RtP
  9189. + .size ___divdf3,.-___divdf3
  9190. +#endif
  9191. +
  9192. +#ifdef L_divsf3
  9193. +!!
  9194. +!! Function : float divsf3 (float a1, float a2)
  9195. +!!
  9196. +!! Args : a1 - single precision floating point number (D1Ar1)
  9197. +!! : a2 - single precision floating point number (D0Ar2)
  9198. +!!
  9199. +!! Description: Returns a1 divided by a2 (D0Re0)
  9200. +!!
  9201. +!! Returns : (+/-)0.0 / (+/-)0.0 = QNaN
  9202. +!! : (+/-)Inf / (+/-)Inf = NaN
  9203. +!! : n / (+/-)Inf = 0.0
  9204. +!! : n / (+/-)0.0 = (+/-)Inf
  9205. +!! : a1 / a2 = n.
  9206. +!!
  9207. +!! Notes : QNaN = 0xFFC00000 (Quiet NaN)
  9208. +!! : SNan = 0xFFBFFFFF (Signaling Nan)
  9209. +!! : +Inf = 0x7F800000
  9210. +!! : -Inf = 0xFF800000
  9211. +!! : +0 = 0x00000000
  9212. +!! : -0 = 0x80000000
  9213. +!!
  9214. + .text
  9215. + .global ___divsf3
  9216. + .type ___divsf3,function
  9217. + .align 2
  9218. +___divsf3:
  9219. + MOV D0Re0, D1Ar1
  9220. + XOR D0Re0, D0Re0, D0Ar2 ! sign1 ^ sign2
  9221. + ANDT D0Re0, D0Re0, #0x8000 ! extract sign
  9222. +
  9223. + ! Test if a1 == 0.0
  9224. + LSLS D1Re0, D1Ar1, #1 ! Ignore sign bit
  9225. + BZ $L1
  9226. +
  9227. + ! Test if a2 == 0.0
  9228. + LSLS D0Ar4, D0Ar2, #1 ! Ignore sign bit
  9229. + BNZ $L2
  9230. +
  9231. + ! a1 != 0.0 and a2 == 0.0 so return +/-Inf
  9232. + ORT D0Re0, D0Re0, #0x7F80
  9233. + MOV PC, D1RtP
  9234. +
  9235. +$L1:
  9236. + ! 0 / X return QNan or +/-Zero
  9237. + LSLS D0Ar4, D0Ar2, #1 ! Ignore sign bit (D0Ar4)
  9238. +
  9239. + ! a1 == 0.0 and a2 != 0.0, so return +/-Zero
  9240. + MOVNZ PC, D1RtP ! (zero return already set up)
  9241. +
  9242. + ! a1 == 0.0 and a2 == 0.0, so return QNAN
  9243. + MOVT D0Re0, #0xFFC0 ! maybe sign depends on sign1 ^ sign2
  9244. + MOV PC, D1RtP
  9245. +
  9246. +$L2:
  9247. + MOV D0Ar4, D0Re0 ! sign bit
  9248. +
  9249. + MOV D1Ar5, D1Ar1
  9250. + ANDMT D1Ar5, D1Ar5, #0x7FFF
  9251. + LSR D1Ar5, D1Ar5, #23 ! exp1
  9252. +
  9253. + MOV D1Re0, D0Ar2
  9254. + ANDMT D1Re0, D1Re0, #0x7FFF
  9255. + LSR D1Re0, D1Re0, #23 ! exp2
  9256. +
  9257. + SUB D1Ar5, D1Ar5, D1Re0
  9258. + ADD D1Ar5, D1Ar5, #126 ! exp = exp1 - exp2 + 126
  9259. +
  9260. + MOV D0Ar6, D1Ar1
  9261. + ANDMT D0Ar6, D0Ar6, #0x007F
  9262. + ORT D0Ar6, D0Ar6, #0x0080 ! man1 -->D0Ar6
  9263. +
  9264. + MOV D0Re0, D0Ar2
  9265. + ANDMT D0Re0, D0Re0, #0x007F
  9266. + ORT D0Re0, D0Re0, #0x0080 ! man2 --> D0Re0
  9267. +
  9268. + CMP D0Ar6, D0Re0 ! man1 < man2
  9269. + BGE $L3
  9270. +
  9271. + LSL D0Ar6, D0Ar6, #1 ! man1 <<= 1
  9272. + SUB D1Ar5, D1Ar5, #1 ! exp -= 1
  9273. +
  9274. +$L3:
  9275. + !mask = 0x01000000
  9276. + MOVT D1Ar1, #0x0100
  9277. + MOV D1Re0, #0 ! result = 0
  9278. +
  9279. +$L4:
  9280. + CMP D0Ar6, D0Re0
  9281. + ORGE D1Re0, D1Re0, D1Ar1 ! result |= mask
  9282. + SUBGE D0Ar6, D0Ar6, D0Re0
  9283. +
  9284. + LSL D0Ar6, D0Ar6, #1 ! man1 <<= 1
  9285. + LSRS D1Ar1, D1Ar1, #1 ! mask >>= 1
  9286. + BNZ $L4
  9287. +
  9288. + ADD D1Ar1, D1Re0, #1 ! result += 1
  9289. +
  9290. + ADD D1Ar5, D1Ar5, #1 ! exp += 1
  9291. + LSR D1Ar1, D1Ar1, #1 ! result >>= 1
  9292. +
  9293. + ANDMT D1Ar1, D1Ar1, #0x007F ! remove hidden bit
  9294. +
  9295. + MOV D1Ar3, #0
  9296. + MAX D1Ar5, D1Ar5, D1Ar3 ! exp < 0 ?
  9297. + MOVLT D0Re0, D0Ar4 ! < 0 return +/-Zero
  9298. + MOVLT PC, D1RtP
  9299. +
  9300. + MOVEQ D0Re0, D0Ar4 ! Don(t) currently handle
  9301. + MOVEQ PC, D1RtP ! denormals, so return +/-Zero
  9302. +
  9303. + MOV D1Ar3, #0xFF
  9304. + MIN D1Ar5, D1Ar5, D1Ar3 ! exp >= 0xFF
  9305. + SUBGE D1Ar1, D1Ar1, D1Ar1 ! >= return +/-Inf
  9306. +
  9307. + LSL D1Ar5, D1Ar5, #23
  9308. + OR D0Re0, D1Ar1, D1Ar5 ! man|exp
  9309. + OR D0Re0, D0Re0, D0Ar4 ! |sign ->D0Re0
  9310. +
  9311. + MOV PC, D1RtP
  9312. + .size ___divsf3,.-___divsf3
  9313. +#endif
  9314. +
  9315. +!! Floating point multiplication
  9316. +
  9317. +#ifdef L_muldf3
  9318. +!!
  9319. +!! Floating point - double multiplicatiion
  9320. +!!
  9321. + .text
  9322. + .global ___muldf3
  9323. + .type ___muldf3,function
  9324. + .align 2
  9325. +___muldf3:
  9326. + XOR D1Re0, D1Ar1, D1Ar3 ! sign1 ^ sign2
  9327. + ANDT D1Re0, D1Re0, #0x8000 ! extract sign bit
  9328. + LSL D0Re0, D1Ar1, #1 ! Ignore sign
  9329. + ORS D0Re0, D0Re0, D0Ar2 ! zero * ...
  9330. + MOVZ PC, D1RtP ! return 0
  9331. +
  9332. + LSL D0Re0, D1Ar3, #1 ! Ignore sign
  9333. + ORS D0Re0, D0Re0, D0Ar4 ! ... * zero
  9334. + MOVZ PC, D1RtP ! return 0
  9335. +
  9336. + MSETL [A0StP], D0.4, D0.5, D0.6, D0.7
  9337. +
  9338. + MOV D1Ar5, D1Ar1
  9339. + ANDMT D1Ar5, D1Ar5, #0x7FFF
  9340. + LSR D1Ar5, D1Ar5, #20 ! exp1
  9341. +
  9342. + MOV D1.5, D1Ar3
  9343. + ANDMT D1.5, D1.5, #0x7FFF
  9344. + LSR D1.5, D1.5, #20 ! exp2
  9345. +
  9346. + SUB D1Ar5, D1Ar5, #1022
  9347. + ADD D1Ar5, D1Ar5, D1.5 ! exp = exp1 + exp2 - 1022
  9348. +
  9349. + MOV D1.5, D1Ar1
  9350. + ANDMT D1.5, D1.5, #0x000F
  9351. + ORT D1.5, D1.5, #0x0010 ! man1 --->D1.5, D0.5
  9352. + MOV D0.5, D0Ar2
  9353. +
  9354. + MOV D1.6, D1Ar3
  9355. + ANDMT D1.6, D1.6, #0x000F
  9356. + ORT D1.6, D1.6, #0x0010 ! man2 --->D1.6, D0.6
  9357. + MOV D0.6, D0Ar4
  9358. +
  9359. + XOR D1Re0, D1Ar1, D1Ar3 ! store the sign bit
  9360. + MOV D0Re0, D1Ar5
  9361. +
  9362. + SETL [A0StP+#8++], D0Re0,D1Re0 ! XXX
  9363. +
  9364. + LSR D0Ar6, D0.5, #21 ! D1Ar1:D0Ar2 = man1 >> 21
  9365. + LSL D0Ar2, D1.5, #(32-21)
  9366. + MOV D1Ar1, #0 ! top 32 bits are zero
  9367. + OR D0Ar2, D0Ar2, D0Ar6
  9368. +
  9369. + LSR D0Ar6, D0.6, #21 ! D1Ar3:D0Ar4 = man2 >> 21
  9370. + LSL D0Ar4, D1.6, #(32-21)
  9371. + MOV D1Ar3, #0 ! top 32 bits are zero
  9372. + OR D0Ar4, D0Ar4, D0Ar6
  9373. +
  9374. + CALLR D1RtP, ___muldi3_
  9375. +
  9376. + MOV D1.7, D1Re0
  9377. + MOV D0.7, D0Re0
  9378. +
  9379. + LSR D0Ar6, D0.5, #21 ! man1 >> 21
  9380. + LSL D0Ar2, D1.5, #(32-21)
  9381. + MOV D1Ar1, #0
  9382. + OR D0Ar2, D0Ar2, D0Ar6
  9383. +
  9384. + MOV D0Ar4, D0.6
  9385. + ANDMT D0Ar4, D0Ar4, #0x001F
  9386. + MOV D1Ar3, #0
  9387. +
  9388. + CALLR D1RtP, ___muldi3_
  9389. +
  9390. + LSR D0Re0, D0Re0, #21 ! >> 21
  9391. + LSL D0Ar6, D1Re0, #(32-21)
  9392. + LSR D1Re0, D1Re0, #21
  9393. + OR D0Re0, D0Re0, D0Ar6
  9394. +
  9395. + ADDS D0.7, D0.7, D0Re0 ! D1.7:D0.7 + D1Re0:D0Re0
  9396. + ADD D1.7, D1.7, D1Re0
  9397. + ADDCS D1.7, D1.7, #1
  9398. +
  9399. + MOV D1Ar1, #0
  9400. + LSL D0Ar2, D1.6, #(32-21) ! man2 >> 21
  9401. + LSR D0Ar6, D0.6, #21
  9402. + OR D0Ar2, D0Ar2, D0Ar6
  9403. +
  9404. + MOV D0Ar4, D0.5
  9405. + ANDMT D0Ar4, D0Ar4, #0x001F
  9406. + MOV D1Ar3, #0
  9407. +
  9408. + CALLR D1RtP, ___muldi3_
  9409. +
  9410. + LSR D0Re0, D0Re0, #21 ! >> 21
  9411. + LSL D0Ar6, D1Re0, #(32-21)
  9412. + LSR D1Re0, D1Re0, #21
  9413. + OR D0Re0, D0Re0, D0Ar6
  9414. +
  9415. + ADDS D0.7, D0.7, D0Re0 ! D1.7:D0.7 + D1Re0:D0Re0
  9416. + ADD D1.7, D1.7, D1Re0
  9417. + ADDCS D1.7, D1.7, #1
  9418. +
  9419. + GETL D0Re0,D1Re0, [A0StP++#-8] ! prepare to recover D1Re0, D1Ar5
  9420. +
  9421. + MOV D1.6, D1.7
  9422. + MOV D0.6, D0.7
  9423. +
  9424. + LSR D0.6, D0.6, #2 ! man >> 2 (d1.6, d0.6)
  9425. + LSL D0.5, D1.6, #(32-2)
  9426. + LSR D1.6, D1.6, #2
  9427. + OR D0.6, D0.6, D0.5
  9428. +
  9429. + MOV D1Ar5, D0Re0
  9430. +
  9431. + MOV D0Re0, D1.6
  9432. + ANDT D0Re0, D0Re0, #0x2000 ! 1 << 61
  9433. + CMP D0Re0, #0 ! round ...
  9434. + BZ $L11
  9435. +
  9436. + ADDS D0.6, D0.6, #0x100 ! D1.6:D0.6 + 0x100
  9437. + ADDCS D1.6, D1.6, #1
  9438. +
  9439. + LSL D0.5, D1.6, #(32-9) ! >> 9
  9440. + LSR D0.6, D0.6, #9
  9441. + LSR D1.6, D1.6, #9
  9442. + OR D0.6, D0.6, D0.5
  9443. + B $L13
  9444. +
  9445. +$L11:
  9446. + ADDS D0.6, D0.6, #0x80 ! +128
  9447. + ADDCS D1.6, D1.6, #1
  9448. +
  9449. + LSR D0.6, D0.6, #8 ! >> 8
  9450. + LSL D0.5, D1.6, #(32-8)
  9451. + LSR D1.6, D1.6, #8
  9452. + OR D0.6, D0.6, D0.5
  9453. +
  9454. + SUB D1Ar5, D1Ar5, #1 ! exp -= 1
  9455. +
  9456. +$L13:
  9457. + MOV D0Re0, D1.6
  9458. + ANDT D0Re0, D0Re0, #0x0020
  9459. + CMP D0Re0, #0
  9460. + BZ $L14
  9461. +
  9462. + LSR D0.6, D0.6, #1 ! man >> 1
  9463. + LSL D0.5, D1.6, #(32-1)
  9464. + LSR D1.6, D1.6, #1
  9465. + OR D0.6, D0.6, D0.5
  9466. +
  9467. + ADD D1Ar5, D1Ar5, #1 ! exp += 1
  9468. +
  9469. +$L14:
  9470. + ANDT D1Re0, D1Re0, #0x8000 ! get the sign bit
  9471. + MOV D1Ar1, D1Re0 ! remember sign
  9472. + ANDMT D1.6, D1.6, #0x000F ! remove hidden bit
  9473. + OR D1Re0, D1Re0, D1.6 ! sign | HI(mantisa)
  9474. + MOV D0Re0, D0.6 ! LO(mantisa)
  9475. +
  9476. + SUB A0.3, A0StP, #32
  9477. + MGETL D0.4, D0.5, D0.6, D0.7, [A0.3]
  9478. + SUB A0StP, A0StP, #32
  9479. +
  9480. + MOV D1Ar3, #0
  9481. + MAX D1Ar5, D1Ar5, D1Ar3 ! exp < 0 ?
  9482. + SUBLT D0Re0, D0Re0, D0Re0 ! < 0 return +/-Zero
  9483. + MOVLT D1Re0, D1Ar1
  9484. + MOVLT PC, D1RtP
  9485. +
  9486. + SUBEQ D0Re0, D0Re0, D0Re0 ! Don(t) currently handle
  9487. + MOVEQ D1Re0, D1Ar1 ! denormals, so return
  9488. + MOVEQ PC, D1RtP ! +/-Zero
  9489. +
  9490. + MOV D1Ar3, #0x7FF
  9491. + MIN D1Ar5, D1Ar5, D1Ar3 ! exp >= 0x7FF ?
  9492. + SUBGE D0Re0, D0Re0, D0Re0 ! >= return +/-Inf
  9493. + MOVGE D1Re0, D1Ar1
  9494. +
  9495. + LSL D1Ar5, D1Ar5, #20 ! position exp
  9496. + OR D1Re0, D1Re0, D1Ar5 ! add exp
  9497. +
  9498. + MOV PC, D1RtP
  9499. +
  9500. +!!
  9501. +!! 32-bit x 32-bit -> 64-bit
  9502. +!!
  9503. + .align 2
  9504. +___muldi3_:
  9505. + MOV A0.2, D0Ar6
  9506. + MOV A0.3, D1Ar5
  9507. +
  9508. + LSR D1Ar1, D0Ar2, #16 ! h1
  9509. + LSR D1Ar3, D0Ar4, #16 ! high 2
  9510. + MULW D1Re0, D1Ar1, D1Ar3 ! h1 * h2
  9511. +
  9512. + MOV D0Ar6, #0xFFFF
  9513. + AND D1Ar5, D0Ar2, D0Ar6 ! l1
  9514. + MULW D0Re0, D1Ar5, D1Ar3 ! l1 * h2
  9515. +
  9516. + AND D0Ar2, D0Ar4, D0Ar6 ! l2
  9517. + MOV D0Ar4, D1Ar1 ! h1
  9518. + MULW D1Ar1, D0Ar4, D0Ar2 ! h1 * l2
  9519. +
  9520. + MOV D0Ar4, D1Ar5 ! l1
  9521. + LSR D1Ar5, D0Re0, #16
  9522. + LSL D0Re0, D0Re0, #16
  9523. + ADD D1Re0, D1Re0, D1Ar5
  9524. + LSR D1Ar5, D1Ar1, #16
  9525. + ADD D1Re0, D1Re0, D1Ar5
  9526. + LSL D0Ar6, D1Ar1, #16
  9527. +
  9528. + ADDS D0Re0, D0Re0, D0Ar6
  9529. + ADDCS D1Re0, D1Re0, #1
  9530. +
  9531. + MULW D0Ar6, D0Ar2, D0Ar4
  9532. +
  9533. + ADDS D0Re0, D0Re0, D0Ar6
  9534. + ADDCS D1Re0, D1Re0, #1
  9535. +
  9536. + MOV D0Ar6, A0.2
  9537. + MOV D1Ar5, A0.3
  9538. +
  9539. + MOV PC, D1RtP
  9540. + .size ___muldf3,.-___muldf3
  9541. +#endif
  9542. +
  9543. +#ifdef L_mulsf3
  9544. +!!
  9545. +!! Floating point - float multiplication
  9546. +!!
  9547. + .text
  9548. + .global ___mulsf3
  9549. + .type ___mulsf3,function
  9550. + .align 2
  9551. +___mulsf3:
  9552. + MOV D0Re0, D1Ar1
  9553. + XOR D0Re0, D0Re0, D0Ar2 ! sign1 ^ sign2
  9554. + ANDT D0Re0, D0Re0, #0x8000 ! extract sign bit
  9555. + LSLS D1Re0, D1Ar1, #1 ! Ignore sign
  9556. + MOVZ PC, D1RtP ! +/-Zero * ... return Zero
  9557. +
  9558. + LSLS D1Re0, D0Ar2, D0Ar2 ! Ignore sign
  9559. + MOVZ PC, D1RtP ! ... * +/-Zero return Zero
  9560. +
  9561. + MOV D1Ar5, D1Ar1
  9562. + ANDMT D1Ar5, D1Ar5, #0x7fff
  9563. + LSR D1Ar5, D1Ar5, #23 ! exp1
  9564. +
  9565. + MOV D1Re0, D0Ar2
  9566. + ANDMT D1Re0, D1Re0, #0x7fff
  9567. + LSR D1Re0, D1Re0, #23 ! exp2
  9568. +
  9569. + SUB D1Ar5, D1Ar5, #126 ! exp = exp1 - 126
  9570. + ADD D1Ar5, D1Ar5, D1Re0 ! exp += exp2
  9571. +
  9572. + MOV D0Ar6, D1Ar1
  9573. + ANDMT D0Ar6, D0Ar6, #0x7f
  9574. + ORT D0Ar6, D0Ar6, #0x80 ! man1
  9575. +
  9576. + MOV D0Re0, D0Ar2
  9577. + ANDMT D0Re0, D0Re0, #0x7f
  9578. + ORT D0Re0, D0Re0, #0x80 ! man2
  9579. +
  9580. + MOV D1Re0, D0Ar2
  9581. + XOR D1Re0, D1Ar1, D1Re0 ! store the sign bit in D1Re0
  9582. +
  9583. + LSR D0Ar2, D0Ar6, #8
  9584. + LSR D0Ar4, D0Re0, #8
  9585. + MULW D1Ar1, D0Ar2, D0Ar4 ! one 16X16
  9586. +
  9587. + MOV D0Ar2, D0Ar6
  9588. + AND D0Ar2, D0Ar2, #0xff
  9589. + MULW D1Ar3, D0Ar2, D0Ar4 ! one 8X16
  9590. +
  9591. + LSR D0Ar2, D0Ar6, #8
  9592. + MOV D0Ar4, D0Re0
  9593. + AND D0Ar4, D0Ar4, #0xff
  9594. + MULW D0Re0, D0Ar2, D0Ar4 ! another 16X8
  9595. +
  9596. + SWAP D1Re0, D0Re0
  9597. + ADD D1Ar3, D1Ar3, D1Re0 ! add 16x8(s) partial results
  9598. + LSR D1Ar3, D1Ar3, #8
  9599. + ADD D1Ar1, D1Ar1, D1Ar3 ! accumulate partial result
  9600. +
  9601. + LSR D1Ar1, D1Ar1, #2 ! man >> 2
  9602. + TSTT D1Ar1, #0x2000 ! round ...
  9603. +
  9604. + ADDNZ D1Ar1, D1Ar1, #0x20
  9605. + LSRNZ D1Ar1, D1Ar1, #6
  9606. +
  9607. + ADDZ D1Ar1, D1Ar1, #0x10
  9608. + LSRZ D1Ar1, D1Ar1, #5
  9609. + SUBZ D1Ar5, D1Ar5, #1
  9610. +
  9611. + TSTT D1Ar1, #0x100
  9612. +
  9613. + LSRNZ D1Ar1, D1Ar1, #1
  9614. + ADDNZ D1Ar5, D1Ar5, #1
  9615. +
  9616. + ANDT D0Re0, D0Re0, #0x8000 ! get the sign bit
  9617. + ANDMT D1Ar1, D1Ar1, #0x7f ! remove hidden hit
  9618. +
  9619. + MOV D1Ar3, #0
  9620. + MAX D1Ar5, D1Ar5, D1Ar3 ! exp < 0 ?
  9621. + MOVLT PC, D1RtP ! < 0 return +/-Zero
  9622. + ! Don(t) currently handle
  9623. + MOVEQ PC, D1RtP ! denormals, so return +/-Zero
  9624. +
  9625. + MOV D1Ar3, #0xFF
  9626. + MIN D1Ar5, D1Ar5, D1Ar3 ! exp >= 0xFF ?
  9627. + SUBGE D1Ar1, D1Ar1, D1Ar1 ! >= return +/-Inf
  9628. +
  9629. + MOV D1Re0, D0Re0
  9630. + LSL D1Ar5, D1Ar5, #23
  9631. + OR D1Re0, D1Re0, D1Ar5 ! sign|exp
  9632. + OR D0Re0, D1Re0, D1Ar1 ! |man ->D0Re0
  9633. +
  9634. + MOV PC, D1RtP
  9635. + .size ___mulsf3,.-___mulsf3
  9636. +#endif
  9637. +
  9638. +!! Floating point conversion routines
  9639. +
  9640. +#ifdef L_extendsfdf2
  9641. +!!
  9642. +!! float -> double conversion
  9643. +!!
  9644. + .text
  9645. + .global ___extendsfdf2
  9646. + .type ___extendsfdf2,function
  9647. + .align 2
  9648. +___extendsfdf2:
  9649. + LSLS D0Re0, D1Ar1, #1 ! Ignore sign bit
  9650. + MOVZ D1Re0, D1Ar1 ! +/- Zero
  9651. + MOVZ PC, D1RtP ! return +/- Zero
  9652. +
  9653. + MOV D1Ar3, D1Ar1
  9654. + ANDT D1Ar3, D1Ar3, #0x8000 ! extract sign (D1Ar3)
  9655. +
  9656. + MOV D0Ar2, D1Ar1 ! extract mant (D0Ar2)
  9657. + ANDMT D0Ar2, D0Ar2, #0x007F
  9658. +
  9659. + LSR D1Re0, D1Ar1, #23 ! extract exp (D1Re0)
  9660. + AND D1Re0, D1Re0, #0x00FF
  9661. +
  9662. + ADD D1Re0, D1Re0, #(1023-127) ! exp += ...
  9663. +
  9664. + LSL D1Re0, D1Re0, #(52-32) ! position exp MSWord
  9665. +
  9666. + OR D1Re0, D1Re0, D1Ar3 ! combine with sign | exp
  9667. +
  9668. + MOV D1Ar3, D0Ar2 ! extract mant MSWord
  9669. + LSR D1Ar3, D1Ar3, #(23-(52-32))
  9670. +
  9671. + OR D1Re0, D1Re0, D1Ar3 ! combine sign | exp | mant
  9672. + LSL D0Re0, D0Ar2, #(32 - 3) ! 3 = (23-(52-32))
  9673. +
  9674. + MOV PC, D1RtP
  9675. + .size ___extendsfdf2,.-___extendsfdf2
  9676. +#endif
  9677. +
  9678. +#ifdef L_truncdfsf2
  9679. +!!
  9680. +!! double -> float conversion
  9681. +!!
  9682. + .text
  9683. + .global ___truncdfsf2
  9684. + .type ___truncdfsf2,function
  9685. + .align 2
  9686. +___truncdfsf2: ! has round solution
  9687. + LSL D0Re0, D1Ar1, #1 ! Ignore sign bit
  9688. + ORS D0Re0, D0Re0, D0Ar2 ! zero?
  9689. + MOVZ D0Re0, D1Ar1
  9690. + MOVZ PC, D1RtP ! return +/-Zero
  9691. +
  9692. +!! extract sign
  9693. + MOV D0Ar6, D1Ar1
  9694. + ANDT D0Ar6, D0Ar6, #0x8000 ! save sign
  9695. +
  9696. +!! extract exponent
  9697. + MOV D1Re0, D1Ar1
  9698. + ANDMT D1Re0, D1Re0, #0x7FFF ! remove the sign bit
  9699. + LSR D1Re0, D1Re0, #20
  9700. + SUB D1Re0, D1Re0, #(1023-127)
  9701. +
  9702. +!! extract mantisa
  9703. + ANDMT D1Ar1, D1Ar1, #0x000F
  9704. +
  9705. +!! add hidden bit
  9706. + ORT D1Ar1, D1Ar1, #0x0010
  9707. +
  9708. +!! position significand for rounding
  9709. + LSL D0Re0, D1Ar1, #4 ! (24 - (52 - 32))
  9710. + LSR D0Ar2, D0Ar2, #(32 - 4)
  9711. + OR D0Re0, D0Re0, D0Ar2
  9712. +
  9713. + ADD D0Re0, D0Re0, #1 ! round + 1
  9714. + TSTT D0Re0, #0xFE00 ! test round overflowed?
  9715. + ADDNZ D1Re0, D1Re0, #1
  9716. + LSR D0Re0, D0Re0, #1
  9717. +
  9718. +!! check biased exponent within range 0 .. 254
  9719. + CMP D1Re0, #0
  9720. + MOVLT D0Re0, D0Ar6 ! return +/- Zero
  9721. + MOVLT PC, D1RtP ! return 0
  9722. +
  9723. + MOVT D0Ar4, #0x7F80 ! Inf
  9724. + OR D0Ar4, D0Ar4, D0Ar6 ! +/-Inf
  9725. +
  9726. + CMP D1Re0, #254
  9727. + MOVGT D0Re0, D0Ar4
  9728. + MOVGT PC, D1RtP ! return +/Inf
  9729. +
  9730. +!! pack sign , exp, mantisa
  9731. + ANDMT D0Re0, D0Re0, #0x007F ! remove hidden bit
  9732. + LSL D0Ar2, D1Re0, #23 ! align exp
  9733. + OR D0Re0, D0Re0, D0Ar2 ! exp | mantisa
  9734. + OR D0Re0, D0Re0, D0Ar6 ! sign | exp | mantisa
  9735. + MOV PC, D1RtP ! done
  9736. + .size ___truncdfsf2,.-___truncdfsf2
  9737. +#endif
  9738. +
  9739. +!! Floating point -> integer conversion.
  9740. +
  9741. +#ifdef L_fixdfdi
  9742. +!!
  9743. +!! Floating point - double -> signed long long
  9744. +!!
  9745. + .text
  9746. + .global ___fixdfdi
  9747. + .type ___fixdfdi,function
  9748. + .align 2
  9749. +___fixdfdi:
  9750. + MOV D0Re0, D1Ar1
  9751. + ORS D0Re0, D0Re0, D0Ar2
  9752. + MOVZ D1Re0, D0Re0
  9753. + MOVZ PC, D1RtP
  9754. +
  9755. + MOV D1Re0, D1Ar1
  9756. + ANDMT D1Re0, D1Re0, #0x7FFF ! discard sign bit
  9757. +
  9758. + LSR D1Re0, D1Re0, #20
  9759. + SUBS D1Re0, D1Re0, #1085 ! exp
  9760. + BLE $L3
  9761. +
  9762. +!! exp > 0 not representable (overflow)
  9763. +
  9764. + TSTT D1Ar1, #0x8000 ! signed?
  9765. + MOVT D1Re0, #0x8000 ! yes, result
  9766. + MOV D0Re0, #0 ! MIN_INT
  9767. + SUBZ D1Re0, D1Re0, #1 ! else result
  9768. + SUBZ D0Re0, D0Re0, #1 ! MAX_INT
  9769. + MOV PC, D1RtP ! return
  9770. +
  9771. +$L3:
  9772. + CMP D1Re0, #-62 ! -(BITS_PER_DI - 2)
  9773. + SUBLT D0Re0, D0Re0, D0Re0
  9774. + MOVLT D1Re0, D0Re0
  9775. + MOVLT PC, D1RtP ! underflow
  9776. +
  9777. + MOV D0Ar6, D1Re0 ! exp
  9778. +
  9779. + MOV D0Re0, D0Ar2
  9780. + MOV D1Re0, D1Ar1 ! man -> D1Re0, D0Re0
  9781. +
  9782. + ANDMT D1Re0, D1Re0, #0x000F
  9783. + ORT D1Re0, D1Re0, #0x0010
  9784. +
  9785. + LSL D1Re0, D1Re0, #10 ! man <<=10
  9786. +
  9787. + LSR D1Ar5, D0Re0, #22
  9788. + OR D1Re0, D1Re0, D1Ar5 ! mantissa
  9789. +
  9790. + LSL D0Re0, D0Re0, #10
  9791. +
  9792. + CMP D0Ar6, #0
  9793. + BZ $L5
  9794. +
  9795. + CMP D0Ar6, #-32
  9796. + BGT $L5_1
  9797. + BLT $L5_2
  9798. +
  9799. +!! >> 32 bits.
  9800. + MOV D0Re0, D1Re0
  9801. + MOV D1Re0, #0
  9802. + B $L5
  9803. +
  9804. +$L5_2:
  9805. +!! >> more than 32 bits
  9806. +
  9807. + ADD D0Ar6, D0Ar6, #32
  9808. + CMP D0Ar6, #-32
  9809. +
  9810. +!! >> more than 64 bits, return 0
  9811. + ADDLE D0Re0, D0Re0, D0Re0
  9812. + MOVLE PC, D1RtP
  9813. +
  9814. + MOV D0Re0, D1Re0
  9815. + MOV D1Re0, #0
  9816. + NEG D0Ar6, D0Ar6
  9817. + LSR D0Re0, D0Re0, D0Ar6
  9818. + B $L5
  9819. +
  9820. +$L5_1:
  9821. +!! >> less than 32 bits
  9822. + CMP D0Ar6, #0 ! shift >>0 ?
  9823. + BEQ $L5
  9824. +
  9825. + ADD D1Ar5, D0Ar6, #32 ! (32 + (-exp))
  9826. + LSL D0Ar2, D1Re0, D1Ar5
  9827. +
  9828. + NEG D0Ar6, D0Ar6
  9829. + LSR D0Re0, D0Re0, D0Ar6
  9830. +
  9831. + MOV D1Ar5, D0Ar6
  9832. + LSR D1Re0, D1Re0, D1Ar5
  9833. +
  9834. + OR D0Re0, D0Re0, D0Ar2
  9835. +
  9836. +$L5:
  9837. + TSTT D1Ar1, #0x8000 ! test sign
  9838. + MOVZ PC, D1RtP
  9839. +
  9840. + NEGS D0Re0, D0Re0 ! change sign
  9841. + NEG D1Re0, D1Re0
  9842. + SUBNZ D1Re0, D1Re0, #1
  9843. + MOV PC, D1RtP
  9844. + .size ___fixdfdi,.-___fixdfdi
  9845. +#endif
  9846. +
  9847. +#ifdef L_fixdfsi
  9848. +!!
  9849. +!! Floating point - double -> signed long long
  9850. +!!
  9851. + .text
  9852. + .global ___fixdfsi
  9853. + .type ___fixdfsi,function
  9854. + .align 2
  9855. +___fixdfsi:
  9856. + MOV D0Re0, D1Ar1
  9857. + ORS D0Re0, D0Re0, D0Ar2 ! zero?
  9858. + MOVZ PC, D1RtP ! return 0
  9859. +
  9860. + MOV D1Re0, D1Ar1 ! keep sign bit
  9861. +
  9862. + LSR D0Ar6, D1Ar1, #20 ! extact exponent (D0Ar6)
  9863. + AND D0Ar6, D0Ar6, #0x07FF
  9864. + SUBS D0Ar6, D0Ar6, #1053 ! exp -= (1023 + 30)
  9865. + BLE $L1
  9866. +
  9867. +!! exp > 0 not representable (overflow)
  9868. +
  9869. + TSTT D1Re0, #0x8000 ! signed ?
  9870. + MOVT D0Re0, #0x8000 ! yes, result MIN INT
  9871. + SUBZ D0Re0, D0Re0, #1 ! no, result MAX INT
  9872. + MOV PC, D1RtP ! return
  9873. +
  9874. +$L1:
  9875. + ANDMT D1Ar1, D1Ar1, #0x000F ! extract mantisa
  9876. + ORT D1Ar1, D1Ar1, #0x0010 ! add hidden bit
  9877. + LSR D1Ar3, D0Ar2, #22 ! (32 - 10)
  9878. + LSL D0Ar2, D0Ar2, #10
  9879. + LSL D1Ar1, D1Ar1, #10
  9880. + OR D1Ar1, D1Ar1, D1Ar3
  9881. +
  9882. + CMP D0Ar6, #-30 ! -(BITS_PER_SI - 2)
  9883. +
  9884. + SUBLT D0Re0, D0Re0, D0Re0 ! < -30 underflow
  9885. + MOVLT PC, D1RtP ! return 0
  9886. +
  9887. + MOV D0Re0, D1Ar1
  9888. + NEG D0Ar6, D0Ar6
  9889. + LSR D0Re0, D0Re0, D0Ar6 ! mant >>= exp
  9890. + TSTT D1Re0, #0x8000 ! signed?
  9891. +
  9892. + MOVZ PC, D1RtP ! return mant
  9893. + NEG D0Re0, D0Re0
  9894. + MOV PC, D1RtP ! return -mant
  9895. + .size ___fixdfsi,.-___fixdfsi
  9896. +#endif
  9897. +
  9898. +#ifdef L_fixsfdi
  9899. +!!
  9900. +!! Floating point - float -> signed long long
  9901. +!!
  9902. + .text
  9903. + .global ___fixsfdi
  9904. + .type ___fixsfdi,function
  9905. + .align 2
  9906. +___fixsfdi:
  9907. + SETL [A0StP+#8++], D0.4, D1RtP
  9908. +#ifdef __PIC__
  9909. + CALLR D1RtP, ___extendsfdf2@PLT
  9910. +#else
  9911. + CALLR D1RtP, ___extendsfdf2
  9912. +#endif
  9913. + MOV D1Ar1, D1Re0
  9914. + MOV D0Ar2, D0Re0
  9915. +
  9916. + GETL D0.4, D1RtP, [A0StP++#-8]
  9917. +
  9918. +#ifdef __PIC__
  9919. + B ___fixdfdi@PLT
  9920. +#else
  9921. + B ___fixdfdi
  9922. +#endif
  9923. + .size ___fixsfdi,.-___fixsfdi
  9924. +#endif
  9925. +
  9926. +#ifdef L_fixsfsi
  9927. +!!
  9928. +!! Floating point - float -> signed int/long
  9929. +!!
  9930. + .text
  9931. + .global ___fixsfsi
  9932. + .type ___fixsfsi,function
  9933. + .align 2
  9934. +___fixsfsi:
  9935. + LSLS D0Re0, D1Ar1, #1 ! Ignore sign bit
  9936. + MOVZ PC, D1RtP ! Zero? return 0
  9937. +
  9938. + MOV D1Re0, D1Ar1
  9939. + ANDMT D1Re0, D1Re0, #0x7FFF ! remove sign bit
  9940. + LSR D1Re0, D1Re0, #23
  9941. + SUBS D1Re0, D1Re0, #(127 + 30)
  9942. +
  9943. + BLE $L3
  9944. +
  9945. +!! exp > 0 (overflow) return MIN_INT or MAX_INT
  9946. +
  9947. + MOVT D0Re0, #0x8000 ! MIN_INT (0x80000000)
  9948. + TSTT D1Ar1, #0x8000
  9949. + SUBZ D0Re0, D0Re0, #1 ! MAX_INT (0x7FFFFFFF)
  9950. + MOV PC, D1RtP
  9951. +
  9952. +$L3:
  9953. + CMP D1Re0, #-30 ! -(BITS_PER_SI - 2)
  9954. +
  9955. + SUBLT D0Re0, D0Re0, D0Re0 ! underflow?
  9956. + MOVLT PC, D1RtP ! return 0
  9957. +
  9958. + MOV D0Re0, D1Ar1
  9959. + ANDMT D1Ar1, D1Ar1, #0x007F ! extract mantisa
  9960. + ORT D1Ar1, D1Ar1, #0x0080 ! add hidden bit
  9961. + LSL D1Ar1, D1Ar1, #7
  9962. +
  9963. + CMP D1Re0, #0
  9964. + BZ $L5
  9965. +
  9966. + NEG D1Re0, D1Re0
  9967. + LSR D1Ar1, D1Ar1, D1Re0
  9968. +$L5:
  9969. +
  9970. + TSTT D0Re0, #0x8000 ! signed?
  9971. + MOV D0Re0, D1Ar1
  9972. + MOVZ PC, D1RtP
  9973. + NEG D0Re0, D0Re0
  9974. + MOV PC, D1RtP
  9975. + .size ___fixsfsi,.-___fixsfsi
  9976. +#endif
  9977. +
  9978. +#ifdef L_fixunsdfdi
  9979. +!!
  9980. +!! Floating point - double -> unsigned long long
  9981. +!!
  9982. + .text
  9983. + .global ___fixunsdfdi
  9984. + .type ___fixunsdfdi,function
  9985. + .align 2
  9986. +___fixunsdfdi:
  9987. + LSL D0Re0, D1Ar1, #1 ! Ignore sign bit
  9988. + ORS D0Re0, D0Re0, D0Ar2 ! zero?
  9989. + MOVZ D1Re0, D0Re0
  9990. + MOVZ PC, D1RtP ! return 0
  9991. +
  9992. + TSTT D1Ar1, #0x8000 ! Negative?
  9993. + SUBNZ D0Re0, D0Re0, D0Re0 ! < 0
  9994. + MOVNZ D1Re0, D0Re0
  9995. + MOVNZ PC, D1RtP ! return 0
  9996. +
  9997. + LSR D1Ar3, D1Ar1, #20 ! extract exponent (D1Ar3)
  9998. + SUBS D1Ar3, D1Ar3, #1086 ! exp -= (1023 + 32 + 31)
  9999. +
  10000. + SUBGT D0Re0, D0Re0, D0Re0 ! exp > 0
  10001. + SUBGT D0Re0, D0Re0, #1
  10002. + MOVGT D1Re0, D0Re0
  10003. + MOVGT PC, D1RtP ! return MAX_UDI
  10004. +
  10005. + ANDMT D1Ar1, D1Ar1, #0x000F ! extract mantisa
  10006. + LSR D1Ar5, D0Ar2, #21 ! (32 - 11)
  10007. + LSL D0Ar2, D0Ar2, #11
  10008. + LSL D1Ar1, D1Ar1, #11
  10009. + OR D1Ar1, D1Ar1, D1Ar5
  10010. + ORT D1Ar1, D1Ar1, #0x8000 ! add hidden bit
  10011. +
  10012. + CMP D1Ar3, #-32 ! -exp >= 32
  10013. + BLE $L9 ! branch
  10014. +
  10015. + CMP D1Ar3, #0 ! exp == 0?
  10016. + MOVEQ D1Re0, D1Ar1
  10017. + MOVEQ D0Re0, D0Ar2
  10018. + MOVEQ PC, D1RtP
  10019. +
  10020. +!! Shift < 32 bits
  10021. +
  10022. + ADD D1Re0, D1Ar3, #32 ! (32 + (-exp))
  10023. + LSL D0Re0, D1Ar1, D1Re0 ! H << (exp - 32)
  10024. + NEG D1Ar3, D1Ar3 ! exp = -exp
  10025. + MOV D1Ar5, D0Ar2
  10026. + LSR D1Re0, D1Ar1, D1Ar3 ! H >> exp
  10027. + LSR D0Ar6, D1Ar5, D1Ar3 ! L >> exp
  10028. + OR D0Re0, D0Re0, D0Ar6
  10029. + MOV PC, D1RtP
  10030. +
  10031. +$L9:
  10032. +
  10033. +!! Shift >= 32 bits
  10034. +
  10035. + MOV D1Re0, #0 ! shifting >= 32 (MSWord result 0)
  10036. + ADD D1Ar3, D1Ar3, #32
  10037. + CMP D1Ar3, #-31 ! -((BITS_PER_DI - 32) - 1)
  10038. +
  10039. + MOVLT D0Re0, D1Re0 ! underflow?
  10040. + MOVLT PC, D1RtP ! return 0
  10041. +
  10042. + NEG D1Ar3, D1Ar3 ! exp = -exp
  10043. + LSR D1Ar1, D1Ar1, D1Ar3 ! >>(exp - 32)
  10044. + MOV D0Re0, D1Ar1
  10045. + MOV PC, D1RtP
  10046. + .size ___fixunsdfdi,.-___fixunsdfdi
  10047. +#endif
  10048. +
  10049. +#ifdef L_fixunsdfsi
  10050. +!!
  10051. +!! Floating point - double -> unsigned int/long
  10052. +!!
  10053. + .text
  10054. + .global ___fixunsdfsi
  10055. + .type ___fixunsdfsi,function
  10056. +___fixunsdfsi:
  10057. + LSL D0Re0, D1Ar1, #1 ! Ignore sign bit
  10058. + ORS D0Re0, D0Re0, D0Ar2 ! zero?
  10059. + MOVZ PC, D1RtP ! return 0
  10060. +
  10061. + TSTT D1Ar1, #0x8000 ! Negative?
  10062. + SUBNZ D0Re0, D0Re0, D0Re0 ! < 0
  10063. + MOVNZ PC, D1RtP ! return 0
  10064. +
  10065. + LSR D0Ar6, D1Ar1, #20 ! extract exponent (D0Ar6)
  10066. + SUBS D0Ar6, D0Ar6, #(1023+32+31) ! exp -= (1023 + 32 + 31)
  10067. +
  10068. + SUBGT D0Re0, D0Re0, D0Re0 ! exp > 0 (overflow)
  10069. + SUBGT D0Re0, D0Re0, #1
  10070. + MOVGT PC, D1RtP ! return MAX_USI
  10071. +
  10072. + ANDMT D1Ar1, D1Ar1, #0x000F ! extract mantisa
  10073. + LSR D1Ar3, D0Ar2, #21 ! (32 - 11)
  10074. + LSL D0Ar2, D0Ar2, #11
  10075. + LSL D1Ar1, D1Ar1, #11
  10076. + OR D1Ar1, D1Ar1, D1Ar3
  10077. + ORT D1Ar1, D1Ar1, #0x8000 ! add hidden bit
  10078. +
  10079. + NEG D0Ar6, D0Ar6 ! exp = -exp
  10080. + CMP D0Ar6, #64 ! exp >= BITS_PER_DI ?
  10081. +
  10082. + SUBGE D0Re0, D0Re0, D0Re0 ! >= underflow
  10083. + MOVGE PC, D1RtP ! return 0
  10084. +
  10085. + CMP D0Ar6, #32 ! exp > (BITS_PER_DI - BITS_PER_SI)
  10086. + SUBLT D0Re0, D0Re0, D0Re0 ! < overflow
  10087. + SUBLT D0Re0, D0Re0, #1
  10088. + MOVLT PC, D1RtP ! return MAX_USI_INT
  10089. +
  10090. + SUB D0Ar6, D0Ar6, #32 ! exp -= (BITS_PER_DI - BITS_PER_SI)
  10091. +
  10092. + MOV D0Re0, D1Ar1
  10093. + LSR D0Re0, D0Re0, D0Ar6 ! return mant >> exp
  10094. + MOV PC, D1RtP
  10095. + .size ___fixunsdfsi,.-___fixunsdfsi
  10096. +#endif
  10097. +
  10098. +#ifdef L_fixunssfdi
  10099. +!!
  10100. +!! Floating point - float -> unsigned long long
  10101. +!!
  10102. + .text
  10103. + .global ___fixunssfdi
  10104. + .type ___fixunssfdi,function
  10105. + .align 2
  10106. +___fixunssfdi:
  10107. + LSLS D0Re0, D1Ar1, #1 ! Ignore sign bit
  10108. + MOVZ PC, D1RtP ! Zero? return 0
  10109. +
  10110. + TSTT D1Ar1, #0x8000 ! Negative?
  10111. + SUBNZ D0Re0, D0Re0, D0Re0 ! < 0
  10112. + MOVNZ D1Re0, D0Re0
  10113. + MOVNZ PC, D1RtP ! return 0
  10114. +
  10115. + LSR D0Ar6, D1Ar1, #23 ! extract exponent (D0Ar6)
  10116. + SUBS D0Ar6, D0Ar6, #(127+63)
  10117. +
  10118. + SUBGT D0Re0, D0Re0, D0Re0 ! exp > 0 (overflow)
  10119. + SUBGT D0Re0, D0Re0, #1
  10120. + MOVGT D1Re0, D0Re0
  10121. + MOVGT PC, D1RtP ! return MAX_UDI
  10122. +
  10123. + CMP D0Ar6, #-(64-1) ! -exp > (BITS_PER_DI - 1)
  10124. +
  10125. + SUBLT D0Re0, D0Re0, D0Re0 ! underflow
  10126. + MOVLT D1Re0, D0Re0
  10127. + MOVLT PC, D1RtP ! return 0
  10128. +
  10129. + LSL D1Re0, D1Ar1, #(63-32-23) ! extract mantisa MSWord
  10130. + ORT D1Re0, D1Re0, #0x8000 ! add hidden bit
  10131. +
  10132. + CMP D0Ar6, #-32
  10133. + NEG D0Ar4, D0Ar6
  10134. + MOV D1Ar3, D0Ar4
  10135. + BLE $L1
  10136. +
  10137. +!! Shift < 32 bits
  10138. +
  10139. + ORS D0Re0, D1Ar3, D1Ar3 ! shifting 0 ?
  10140. + MOVZ PC, D1RtP !
  10141. +
  10142. + ADD D1Ar5, D0Ar6, #32 ! (-exp) + 32
  10143. +
  10144. + LSL D0Re0, D1Re0, D1Ar5 ! mant >> exp
  10145. + LSR D1Re0, D1Re0, D1Ar3
  10146. +
  10147. + MOV PC, D1RtP
  10148. +$L1:
  10149. +!! Shift > 32 bits
  10150. + SUB D1Ar3, D1Ar3, #32 ! exp -= 32
  10151. +
  10152. + LSR D0Re0, D1Re0, D1Ar3
  10153. + MOV D1Re0, #0
  10154. +
  10155. + MOV PC, D1RtP
  10156. + .size ___fixunssfdi,.-___fixunssfdi
  10157. +#endif
  10158. +
  10159. +#ifdef L_fixunssfsi
  10160. +!!
  10161. +!! Floating point - float -> unsigned int/long
  10162. +!!
  10163. + .text
  10164. + .global ___fixunssfsi
  10165. + .type ___fixunssfsi,function
  10166. + .align 2
  10167. +___fixunssfsi:
  10168. + LSLS D0Re0, D1Ar1, #1 ! Ignore sign bit
  10169. + MOVZ PC, D1RtP ! Zero? return 0
  10170. +
  10171. + TSTT D1Ar1, #0x8000 ! Negative?
  10172. + SUBNZ D0Re0, D0Re0, D0Re0 ! < 0
  10173. + MOVNZ PC, D1RtP ! return 0
  10174. +
  10175. + LSR D0Ar6, D1Ar1, #23 ! extract exponent (D0Ar6)
  10176. + SUBS D0Ar6, D0Ar6, #(127+31)
  10177. +
  10178. + SUBGT D0Re0, D0Re0, D0Re0 ! exp > 0 (overflow)
  10179. + SUBGT D0Re0, D0Re0, #1
  10180. + MOVGT PC, D1RtP ! return MAX_USI
  10181. +
  10182. + CMP D0Ar6, #-(32-1) ! -exp > (BITS_PER_SI - 1)
  10183. +
  10184. + SUBLT D0Re0, D0Re0, D0Re0 ! underflow
  10185. + MOVLT PC, D1RtP ! return 0
  10186. +
  10187. + LSL D0Re0, D1Ar1, #(31-23) ! extract mantisa
  10188. + ORT D0Re0, D0Re0, #0x8000 ! add hidden bit
  10189. +
  10190. + NEG D0Ar6, D0Ar6
  10191. +
  10192. + LSR D0Re0, D0Re0, D0Ar6 ! mant >> exp
  10193. +
  10194. + MOV PC, D1RtP
  10195. + .size ___fixunssfsi,.-___fixunssfsi
  10196. +#endif
  10197. +
  10198. +!! Integer -> Floating point conversion
  10199. +
  10200. +#ifdef L_floatdidf
  10201. +!!
  10202. +!! signed long long -> double conversion
  10203. +!!
  10204. + .text
  10205. + .global ___floatdidf
  10206. + .type ___floatdidf,function
  10207. + .align 2
  10208. +___floatdidf:
  10209. +
  10210. + MOV D1Ar3, #(1023+32+30) ! exp
  10211. + MOV D0Ar6, #0 ! sign, assume +ve
  10212. +
  10213. + ORS D1Re0, D1Ar1, D1Ar1
  10214. + BLT $L1
  10215. + BGT $L2
  10216. +
  10217. + ORS D0Re0, D0Ar2, D0Ar2
  10218. + BNE $L2
  10219. +
  10220. + MOV PC, D1RtP
  10221. +
  10222. +$L1:
  10223. + ! <0
  10224. + MOVT D0Ar6, #0x8000 ! sign, -ve
  10225. +
  10226. + NEGS D0Ar2, D0Ar2 ! negate
  10227. + NEG D1Re0, D1Ar1
  10228. + SUBNZ D1Re0, D1Re0, #1
  10229. +
  10230. + CMP D1Re0, #0 ! negative?
  10231. + BGT $L2 ! branch, not MIN DI
  10232. +
  10233. +! Handle most negative value
  10234. +
  10235. + LSR D0Ar2, D0Ar2, #1 ! significand >>= 1
  10236. + LSL D0Ar4, D1Re0, #(32-1)
  10237. + OR D0Ar2, D0Ar2, D0Ar4
  10238. + LSR D1Re0, D1Re0, #1
  10239. +
  10240. + ADD D1Ar3, D1Ar3, #1 ! exp += 1
  10241. +
  10242. +$L2:
  10243. + MOV D0Re0, D0Ar2 ! mantisa
  10244. + NORM D1Ar1, D1Re0 ! normalize up
  10245. + BZ $L4 ! MSWord zero
  10246. +
  10247. + CMP D1Ar1, #0 ! Already normalised ?
  10248. + BZ $L5 ! yes, skip normalisation
  10249. +
  10250. + MOV D0Ar4, D1Re0
  10251. + FFB D0Ar4, D0Ar4
  10252. +
  10253. + LSL D1Re0, D1Re0, D1Ar1
  10254. + ADD D0Ar4, D0Ar4, #2
  10255. + LSR D1Ar5, D0Re0, D0Ar4
  10256. + OR D1Re0, D1Re0, D1Ar5
  10257. + MOV D0Ar4, D1Ar1
  10258. + LSL D0Re0, D0Re0, D0Ar4
  10259. +
  10260. + SUB D1Ar3, D1Ar3, D1Ar1
  10261. + B $L5
  10262. +
  10263. +$L4:
  10264. + SWAP D1Re0, D0Re0 ! D1Re0 <- D0Re0, D0Re0 <- #0
  10265. + SUB D1Ar3, D1Ar3, #32
  10266. +
  10267. + NORM D1Ar1, D1Re0
  10268. + LSRLT D1Re0, D1Re0, #1 ! Watch out for low 32-bits with MSbit set
  10269. + ADDLT D1Ar3, D1Ar3, #1 ! adjust exp and mantissa
  10270. +
  10271. + LSL D1Re0, D1Re0, D1Ar1
  10272. +
  10273. + SUB D1Ar3, D1Ar3, D1Ar1
  10274. +
  10275. +$L5:
  10276. + TST D0Re0, #(1<<9) ! Test MSbit discared
  10277. + LSR D0Re0, D0Re0, #10 ! Discard excess bits not representable
  10278. + LSL D0Ar4, D1Re0, #(32 - 10)
  10279. + LSR D1Re0, D1Re0, #10
  10280. + OR D0Re0, D0Re0, D0Ar4
  10281. + BZ $L7
  10282. +
  10283. + ADDS D0Re0, D0Re0, #1 ! Round up if MSbit discarded non-zero
  10284. + ADDCS D1Re0, D1Re0, #1
  10285. +
  10286. +$L6:
  10287. + TSTT D1Re0, #0xFFE0 ! Round up overflowed?
  10288. + BZ $L7
  10289. +
  10290. + ADD D1Ar3, D1Ar3, #1 ! yes, adjust exp +=1
  10291. + LSR D0Re0, D0Re0, #1 ! and adjust significand shifting >>1
  10292. + LSL D0Ar4, D1Re0, #(32 - 1)
  10293. + LSR D1Re0, D1Re0, #1
  10294. + OR D0Re0, D0Re0, D0Ar4
  10295. + B $L6
  10296. +
  10297. +$L7:
  10298. + ANDMT D1Re0, D1Re0, #0x000F ! remove hidden bit <- mantisa MSword
  10299. +
  10300. + LSL D1Ar3, D1Ar3, #(52-32) ! position exp in result
  10301. + MOV D1Ar1, D0Ar6 ! sign
  10302. + OR D1Re0, D1Re0, D1Ar1 ! combine with sign -> sign | mant
  10303. + OR D1Re0, D1Re0, D1Ar3 ! combine with exp -> sign | exp | mant
  10304. +
  10305. + MOV PC, D1RtP
  10306. + .size ___floatdidf,.-___floatdidf
  10307. +#endif
  10308. +
  10309. +#ifdef L_floatdisf
  10310. +!!
  10311. +!! signed signed long long -> float conversion
  10312. +!!
  10313. + .text
  10314. + .global ___floatdisf
  10315. + .type ___floatdisf,function
  10316. +___floatdisf:
  10317. +
  10318. + MOV D0Ar6, #(127+32+30) ! exp
  10319. + MOV D0Re0, #0 ! sign
  10320. +
  10321. + CMP D1Ar1, #0
  10322. + BLT $L1
  10323. + BGT $L2
  10324. +
  10325. + CMP D0Ar2, #0
  10326. + BNE $L2
  10327. +
  10328. + MOV PC, D1RtP
  10329. +$L1:
  10330. + ! <0
  10331. + MOVT D0Re0, #0x8000
  10332. +
  10333. + NEGS D0Ar2, D0Ar2 ! negate
  10334. + NEG D1Ar1, D1Ar1
  10335. + SUBNZ D1Ar1, D1Ar1, #1
  10336. +
  10337. + CMP D1Ar1, #0 ! deal min DI
  10338. + BGT $L2 ! branch not min DI
  10339. +
  10340. + LSR D0Ar2, D0Ar2, #1 ! significand >> 1
  10341. + MOV D0Ar4, D1Ar1
  10342. + LSL D0Ar4, D0Ar4, #(32-1)
  10343. + OR D0Ar2, D0Ar2, D0Ar4
  10344. + LSR D1Ar1, D1Ar1, #1
  10345. +
  10346. + ADD D0Ar6, D0Ar6, #1 ! exp += 1
  10347. +
  10348. +$L2: ! normalize up
  10349. + NORM D1Re0, D1Ar1
  10350. + BZ $L4 ! MSWord zero
  10351. +
  10352. + CMP D1Re0, #0 ! Already normalised ?
  10353. + BZ $L5 ! yes, skip normalisation
  10354. +
  10355. + MOV D0Ar4, D1Ar1
  10356. + FFB D0Ar4, D0Ar4
  10357. +
  10358. + LSL D1Ar1, D1Ar1, D1Re0
  10359. + ADD D0Ar4, D0Ar4, #2
  10360. + LSR D1Ar5, D0Ar2, D0Ar4
  10361. + OR D1Ar1, D1Ar1, D1Ar5
  10362. + MOV D0Ar4, D1Re0
  10363. + LSL D0Ar2, D0Ar2, D0Ar4
  10364. +
  10365. + MOV D0Ar4, D1Re0
  10366. + SUB D0Ar6, D0Ar6, D0Ar4
  10367. + B $L5
  10368. +
  10369. +$L4:
  10370. + SWAP D1Ar1, D0Ar2 ! D1Ar1 <- D0Ar2, D0Ar2 <- #0
  10371. + SUB D0Ar6, D0Ar6, #32
  10372. +
  10373. + NORM D1Re0, D1Ar1
  10374. + LSL D1Ar1, D1Ar1, D1Re0
  10375. +
  10376. + MOV D0Ar4, D1Re0
  10377. + SUB D0Ar6, D0Ar6, D0Ar4
  10378. +
  10379. +$L5:
  10380. + MOV D0Ar2, D1Ar1
  10381. + TST D0Ar2, #(1<<6) ! Round before discarding
  10382. + LSR D0Ar2, D0Ar2, #7 ! Discard excess bits not representable
  10383. + ADDNZ D0Ar2, D0Ar2, #1
  10384. +
  10385. +$L6:
  10386. + TSTT D0Ar2, #0xFF00 ! Round up overflowed?
  10387. + BZ $L7
  10388. +
  10389. + ADD D0Ar6, D0Ar6, #1 ! yes, adjust exp += 1
  10390. + LSR D0Ar2, D0Ar2, #1 ! adn adjust significand shifting >>1
  10391. + B $L6
  10392. +
  10393. +$L7:
  10394. + ANDMT D0Ar2, D0Ar2, #0x007F ! remove hidden bit <- mantisa
  10395. +
  10396. + LSL D0Ar6, D0Ar6, #23 ! position exp in result
  10397. + OR D0Re0, D0Re0, D0Ar6 ! combine sign with exp -> sign|exp
  10398. + OR D0Re0, D0Re0, D0Ar2 ! combine sign|exp with mant -> sign|exp|mant
  10399. +
  10400. + MOV PC, D1RtP
  10401. + .size ___floatdisf,.-___floatdisf
  10402. +#endif
  10403. +
  10404. +#ifdef L_floatsidf
  10405. +!!
  10406. +!! signed int/long -> double conversion
  10407. +!!
  10408. + .text
  10409. + .global ___floatsidf
  10410. + .type ___floatsidf,function
  10411. + .align 2
  10412. +___floatsidf:
  10413. +
  10414. + MOV D1Ar5, #(1023+30) ! exp
  10415. + MOV D1Re0, #0 ! assume result +ve
  10416. + CMP D1Ar1, #0 ! num < 0
  10417. + BGT $L2
  10418. +
  10419. + ! <= 0
  10420. + MOVEQ D0Re0, D1Re0
  10421. + MOVEQ PC, D1RtP ! num == 0 return 0
  10422. +
  10423. + ! < 0
  10424. + MOVT D1Re0, #0x8000 ! result will be -ve
  10425. + NEG D1Ar1, D1Ar1 ! num -= num
  10426. + CMP D1Ar1, #0 ! num < 0
  10427. + BGT $L2
  10428. +
  10429. + ! < 0 (num == MIN_INT)
  10430. + LSR D1Ar1, D1Ar1, #1 ! num >>= 1
  10431. + ADD D1Ar5, D1Ar5, #1 ! exp += 1
  10432. +
  10433. +$L2:
  10434. + NORM D1Ar3, D1Ar1 ! Make MSBit non-zero
  10435. + LSL D1Ar1, D1Ar1, D1Ar3 ! num <<= N
  10436. + SUB D1Ar5, D1Ar5, D1Ar3 ! exp -= N
  10437. +
  10438. + MOV D0Re0, D1Ar1 ! position mantisa LSWord
  10439. + LSL D0Re0, D0Re0, #(32-10)
  10440. +
  10441. + LSL D1Ar5, D1Ar5, #(52-32) ! position exponent
  10442. + OR D1Re0, D1Re0, D1Ar5 ! combine sign | exp
  10443. +
  10444. + LSR D1Ar1, D1Ar1, #10 ! position significand MSWord
  10445. + ANDMT D1Ar1, D1Ar1, #0x000F ! discard hidden bit
  10446. + OR D1Re0, D1Re0, D1Ar1 ! combine sign | exp | mantisa
  10447. +
  10448. + MOV PC, D1RtP
  10449. + .size ___floatsidf,.-___floatsidf
  10450. +#endif
  10451. +
  10452. +#ifdef L_floatunsidf
  10453. +!!
  10454. +!! unsigned int/long -> double conversion
  10455. +!!
  10456. + .text
  10457. + .global ___floatunsidf
  10458. + .type ___floatunsidf,function
  10459. + .align 2
  10460. +___floatunsidf:
  10461. +
  10462. + MOV D1Ar5, #(1023+30) ! exp
  10463. + MOV D1Re0, #0 ! assume result +ve
  10464. + CMP D1Ar1, #0 ! num == 0
  10465. +
  10466. + ! == 0
  10467. + MOVEQ D0Re0, D1Re0
  10468. + MOVEQ PC, D1RtP ! num == 0 return 0
  10469. +
  10470. + NORM D1Ar3, D1Ar1 ! Make MSBit non-zero
  10471. + LSL D1Ar1, D1Ar1, D1Ar3 ! num <<= N
  10472. + SUB D1Ar5, D1Ar5, D1Ar3 ! exp -= N
  10473. +
  10474. + MOV D0Re0, D1Ar1 ! position mantisa LSWord
  10475. + LSL D0Re0, D0Re0, #(32-10)
  10476. +
  10477. + LSL D1Ar5, D1Ar5, #(52-32) ! position exponent
  10478. + OR D1Re0, D1Re0, D1Ar5 ! combine sign | exp
  10479. +
  10480. + LSR D1Ar1, D1Ar1, #10 ! position significand MSWord
  10481. + ANDMT D1Ar1, D1Ar1, #0x000F ! discard hidden bit
  10482. + OR D1Re0, D1Re0, D1Ar1 ! combine sign | exp | mantisa
  10483. +
  10484. + MOV PC, D1RtP
  10485. + .size ___floatunsidf,.-___floatunsidf
  10486. +#endif
  10487. +
  10488. +#ifdef L_floatsisf
  10489. +!!
  10490. +!! signed int/long -> float conversion
  10491. +!!
  10492. + .text
  10493. + .global ___floatsisf
  10494. + .type ___floatsisf,function
  10495. + .align 2
  10496. +___floatsisf:
  10497. + MOV D0Ar6, #(127+32-2) ! exp
  10498. + MOV D1Re0, #0 ! sign
  10499. + ORS D0Re0, D1Ar1, D1Ar1 ! num ? -ve, zero, +ve
  10500. + BGT $L2 ! branch, +ve
  10501. + ! <=
  10502. + MOVZ PC, D1RtP ! zero, return 0
  10503. +
  10504. + ! < 0
  10505. + MOVT D1Re0, #0x8000 ! sign
  10506. + NEGS D1Ar1, D1Ar1 ! Make >= 0
  10507. + BGT $L2 ! branch, +ve
  10508. +
  10509. + ! Handle MIN INT
  10510. + LSR D1Ar1, D1Ar1, #1 ! num >>= 1
  10511. + ADD D0Ar6, D0Ar6, #1 ! exp += 1
  10512. +
  10513. +$L2: ! num > 0
  10514. + NORM D1Ar3, D1Ar1 ! Shift up N bits
  10515. + LSL D1Ar1, D1Ar1, D1Ar3 ! num <<= N
  10516. + MOV D0Ar4, D1Ar3
  10517. + SUB D0Ar6, D0Ar6, D0Ar4 ! exp -= N
  10518. +
  10519. + LSR D1Ar1, D1Ar1, #(8-2)
  10520. + ADD D1Ar1, D1Ar1, #1 ! round
  10521. + MOV D0Re0, D1Ar1 ! mantisa --> D0Re0
  10522. +
  10523. + TSTT D1Ar1, #0xFE00 ! rounding overflowed ?
  10524. + ADDNZ D0Ar6, D0Ar6, #1 ! yes, adjust exp++
  10525. + LSR D0Re0, D0Re0, #1 ! position mantisa
  10526. +
  10527. + LSL D0Ar6, D0Ar6, #23 ! position exponent
  10528. + ANDMT D0Re0, D0Re0, #0x007F ! remove hidden bit
  10529. + OR D0Re0, D0Re0, D0Ar6 ! man | exp
  10530. +
  10531. + MOV D0Ar6, D1Re0
  10532. + OR D0Re0, D0Re0, D0Ar6 ! |sign
  10533. +
  10534. + MOV PC, D1RtP
  10535. + .size ___floatsisf,.-___floatsisf
  10536. +#endif
  10537. +
  10538. +#ifdef L_floatunsisf
  10539. +!!
  10540. +!! signed int/long -> float conversion
  10541. +!!
  10542. + .text
  10543. + .global ___floatunsisf
  10544. + .type ___floatunsisf,function
  10545. + .align 2
  10546. +___floatunsisf:
  10547. + MOV D0Ar6, #(127+32-2) ! exp
  10548. + ORS D0Re0, D1Ar1, D1Ar1 ! num ? -ve, zero, +ve
  10549. + ! <=
  10550. + MOVZ PC, D1RtP ! zero, return 0
  10551. +
  10552. + NORM D1Ar3, D1Ar1 ! Shift up N bits
  10553. + LSL D1Ar1, D1Ar1, D1Ar3 ! num <<= N
  10554. + MOV D0Ar4, D1Ar3
  10555. + SUB D0Ar6, D0Ar6, D0Ar4 ! exp -= N
  10556. +
  10557. + LSR D1Ar1, D1Ar1, #(8-2)
  10558. + ADD D1Ar1, D1Ar1, #1 ! round
  10559. + MOV D0Re0, D1Ar1 ! mantisa --> D0Re0
  10560. +
  10561. + TSTT D1Ar1, #0xFE00 ! rounding overflowed ?
  10562. + ADDNZ D0Ar6, D0Ar6, #1 ! yes, adjust exp++
  10563. + LSR D0Re0, D0Re0, #1 ! position mantisa
  10564. +
  10565. + LSL D0Ar6, D0Ar6, #23 ! position exponent
  10566. + ANDMT D0Re0, D0Re0, #0x007F ! remove hidden bit
  10567. + OR D0Re0, D0Re0, D0Ar6 ! man | exp
  10568. +
  10569. + MOV PC, D1RtP
  10570. + .size ___floatunsisf,.-___floatunsisf
  10571. +#endif
  10572. +
  10573. +#ifdef L_unordsf2
  10574. + .text
  10575. + .global ___unordsf2
  10576. + .type ___unordsf2,function
  10577. + .align 2
  10578. +___unordsf2:
  10579. + MOV PC, D1RtP
  10580. +#endif
  10581. +
  10582. +#ifdef L_unorddf2
  10583. + .text
  10584. + .global ___unorddf2
  10585. + .type ___unorddf2,function
  10586. + .align 2
  10587. +___unorddf2:
  10588. + MOV PC, D1RtP
  10589. + .size ___unorddf2,.-___unorddf2
  10590. +#endif
  10591. +
  10592. diff -Nur gcc-4.2.4.orig/gcc/config/metag/linux-atomic.asm gcc-4.2.4/gcc/config/metag/linux-atomic.asm
  10593. --- gcc-4.2.4.orig/gcc/config/metag/linux-atomic.asm 1969-12-31 18:00:00.000000000 -0600
  10594. +++ gcc-4.2.4/gcc/config/metag/linux-atomic.asm 2015-07-03 18:46:05.749283542 -0500
  10595. @@ -0,0 +1,227 @@
  10596. +.macro linkset_check
  10597. + DEFR D0FrT, TXSTAT
  10598. + ANDT D0FrT, D0FrT, #HI(0x3F000000)
  10599. + CMPT D0FrT, #HI(0x02000000)
  10600. +.endm
  10601. +
  10602. +.macro func_start func_name
  10603. + .text
  10604. + .global \func_name
  10605. + .type \func_name,function
  10606. + .align 2
  10607. +\func_name:
  10608. +1:
  10609. +.endm
  10610. +
  10611. +.macro func_end func_name
  10612. + linkset_check
  10613. + BNE 1b
  10614. + cache_flush
  10615. + 2: MOV PC, D1RtP
  10616. + .size \func_name, .-\func_name
  10617. +.endm
  10618. +
  10619. +.macro cache_flush
  10620. + MOV D0FrT, #0
  10621. + DCACHE [D1Ar1], D0FrT
  10622. +.endm
  10623. +
  10624. +.macro sync_fetch_and_op op op_name n mode
  10625. +func_start ___sync_fetch_and_\op_name\()_\n
  10626. + LNKGET\mode D0Re0, [D1Ar1]
  10627. + \op D0FrT, D0Re0, D0Ar2
  10628. + LNKSET\mode [D1Ar1], D0FrT
  10629. +func_end ___sync_fetch_and_\op_name\()_\n
  10630. +.endm
  10631. +
  10632. +.macro sync_fetch_and_op_8 op op_name
  10633. +func_start ___sync_fetch_and_\op_name\()_8
  10634. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10635. + \op A0.2, D0Re0, D0Ar4
  10636. + \op A1.2, D1Re0, D1Ar3
  10637. + LNKSETL [D1Ar1], A0.2, A1.2
  10638. +func_end ___sync_fetch_and_\op_name\()_8
  10639. +.endm
  10640. +
  10641. +.macro sync_fetch_and_alu_op_8 op op_name
  10642. +func_start ___sync_fetch_and_\op_name\()_8
  10643. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10644. + \op\()S A0.2, D0Re0, D0Ar4
  10645. + \op A1.2, D1Re0, D1Ar3
  10646. + \op\()CS A1.2, A1.2, #1
  10647. + LNKSETL [D1Ar1], A0.2, A1.2
  10648. +func_end ___sync_fetch_and_\op_name\()_8
  10649. +.endm
  10650. +
  10651. +.macro sync_op_and_fetch op op_name n mode
  10652. +func_start ___sync_\op_name\()_and_fetch_\n
  10653. + LNKGET\mode D0Re0, [D1Ar1]
  10654. + \op D0Re0, D0Re0, D0Ar2
  10655. + LNKSET\mode [D1Ar1], D0Re0
  10656. +func_end ___sync_\op_name\()_and_fetch_\n
  10657. +.endm
  10658. +
  10659. +.macro sync_op_and_fetch_8 op op_name
  10660. +func_start ___sync_\op_name\()_and_fetch_8
  10661. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10662. + \op D0Re0, D0Re0, D0Ar4
  10663. + \op D1Re0, D1Re0, D1Ar3
  10664. + LNKSETL [D1Ar1], D0Re0, D1Re0
  10665. +func_end ___sync_\op_name\()_and_fetch_8
  10666. +.endm
  10667. +
  10668. +.macro sync_alu_op_and_fetch_8 op op_name
  10669. +func_start ___sync_\op_name\()_and_fetch_8
  10670. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10671. + \op\()S D0Re0, D0Re0, D0Ar4
  10672. + \op D1Re0, D1Re0, D1Ar3
  10673. + \op\()CS D1Re0, D1Re0, #1
  10674. + LNKSETL [D1Ar1], D0Re0, D1Re0
  10675. +func_end ___sync_\op_name\()_and_fetch_8
  10676. +.endm
  10677. +
  10678. +.macro sync_fetch_and_op_neg op op_name n mode
  10679. +func_start ___sync_fetch_and_\op_name\()_\n
  10680. + LNKGET\mode D0Re0, [D1Ar1]
  10681. + \op D0FrT, D0Re0, D0Ar2
  10682. + XOR D0FrT, D0FrT, #-1
  10683. + LNKSET\mode [D1Ar1], D0FrT
  10684. +func_end ___sync_fetch_and_\op_name\()_\n
  10685. +.endm
  10686. +
  10687. +.macro sync_fetch_and_op_neg_8 op op_name
  10688. +func_start ___sync_fetch_and_\op_name\()_8
  10689. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10690. + \op D0Ar6, D0Re0, D0Ar4
  10691. + \op D1Ar5, D1Re0, D1Ar3
  10692. + XOR D0Ar6, D0Ar6, #-1
  10693. + XOR D1Ar5, D1Ar5, #-1
  10694. + LNKSETL [D1Ar1], D0Ar6, D1Ar5
  10695. +func_end ___sync_fetch_and_\op_name\()_8
  10696. +.endm
  10697. +
  10698. +.macro sync_op_neg_and_fetch op op_name n mode
  10699. +func_start ___sync_\op_name\()_and_fetch_\n
  10700. + LNKGET\mode D0Re0, [D1Ar1]
  10701. + \op D0Re0, D0Re0, D0Ar2
  10702. + XOR D0Re0, D0Re0, #-1
  10703. + LNKSET\mode [D1Ar1], D0Re0
  10704. +func_end ___sync_\op_name\()_and_fetch_\n
  10705. +.endm
  10706. +
  10707. +.macro sync_op_neg_and_fetch_8 op op_name
  10708. +func_start ___sync_\op_name\()_and_fetch_8
  10709. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10710. + \op D0Re0, D0Re0, D0Ar4
  10711. + \op D1Re0, D1Re0, D1Ar3
  10712. + XOR D0Re0, D0Re0, #-1
  10713. + XOR D1Re0, D1Re0, #-1
  10714. + LNKSETL [D1Ar1], D0Re0, D1Re0
  10715. +func_end ___sync_\op_name\()_and_fetch_8
  10716. +.endm
  10717. +
  10718. +.macro sync_val_compare_and_swap n mode
  10719. +func_start ___sync_val_compare_and_swap_\n
  10720. + LNKGET\mode D0Re0, [D1Ar1]
  10721. + CMP D0Re0, D0Ar2
  10722. + LNKSET\mode\()EQ [D1Ar1], D1Ar3
  10723. + BNE 2f
  10724. +func_end ___sync_val_compare_and_swap_\n
  10725. +.endm
  10726. +
  10727. +func_start ___sync_val_compare_and_swap_8
  10728. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10729. + CMP D0Re0, D0Ar4
  10730. + CMPEQ D1Re0, D1Ar3
  10731. + LNKSETLEQ [D1Ar1], D0Ar6, D1Ar5
  10732. + BNE 2f
  10733. +func_end ___sync_val_compare_and_swap_8
  10734. +
  10735. +.macro sync_bool_compare_and_swap n mode
  10736. +func_start ___sync_bool_compare_and_swap_\n
  10737. + MOV D0Re0, #1
  10738. + 1: LNKGET\mode D0FrT, [D1Ar1]
  10739. + CMP D0FrT, D0Ar2
  10740. + LNKSET\mode\()EQ [D1Ar1], D1Ar3
  10741. + XORNE D0Re0, D0Re0, D0Re0
  10742. + BNE 2f
  10743. +func_end ___sync_bool_compare_and_swap_\n
  10744. +.endm
  10745. +
  10746. +func_start ___sync_bool_compare_and_swap_8
  10747. + MOV D0Re0, #1
  10748. + 1: LNKGETL A0.2, A1.2, [D1Ar1]
  10749. + CMP D0Ar4, A0.2
  10750. + CMPEQ D1Ar3, A1.2
  10751. + LNKSETLEQ [D1Ar1], D0Ar6, D1Ar5
  10752. + XORNE D0Re0, D0Re0, D0Re0
  10753. + BNE 2f
  10754. +func_end ___sync_bool_compare_and_swap_8
  10755. +
  10756. +.macro sync_lock_test_and_set n mode
  10757. +func_start ___sync_lock_test_and_set_\n
  10758. + LNKGET\mode D0Re0, [D1Ar1]
  10759. + LNKSET\mode [D1Ar1], D0Ar2
  10760. +func_end ___sync_lock_test_and_set_\n
  10761. +.endm
  10762. +
  10763. +func_start ___sync_lock_test_and_set_8
  10764. + LNKGETL D0Re0, D1Re0, [D1Ar1]
  10765. + LNKSETL [D1Ar1], D0Ar4, D1Ar3
  10766. +func_end ___sync_lock_test_and_set_8
  10767. +
  10768. +.macro sync_fetch_and_op_size op op_name
  10769. + sync_fetch_and_op \op \op_name 1 B
  10770. + sync_fetch_and_op \op \op_name 2 W
  10771. + sync_fetch_and_op \op \op_name 4 D
  10772. +
  10773. + sync_op_and_fetch \op \op_name 1 B
  10774. + sync_op_and_fetch \op \op_name 2 W
  10775. + sync_op_and_fetch \op \op_name 4 D
  10776. +.endm
  10777. +
  10778. +.macro sync_fetch_and_op_neg_size op op_name
  10779. + sync_fetch_and_op_neg \op \op_name 1 B
  10780. + sync_fetch_and_op_neg \op \op_name 2 W
  10781. + sync_fetch_and_op_neg \op \op_name 4 D
  10782. + sync_fetch_and_op_neg_8 \op \op_name
  10783. +
  10784. + sync_op_neg_and_fetch \op \op_name 1 B
  10785. + sync_op_neg_and_fetch \op \op_name 2 W
  10786. + sync_op_neg_and_fetch \op \op_name 4 D
  10787. + sync_op_neg_and_fetch_8 \op \op_name
  10788. +.endm
  10789. +
  10790. +sync_fetch_and_op_size ADD add
  10791. +sync_fetch_and_op_size SUB sub
  10792. +sync_fetch_and_op_size OR or
  10793. +sync_fetch_and_op_size AND and
  10794. +sync_fetch_and_op_size XOR xor
  10795. +
  10796. +sync_fetch_and_op_8 OR or
  10797. +sync_fetch_and_op_8 AND and
  10798. +sync_fetch_and_op_8 XOR xor
  10799. +
  10800. +sync_op_and_fetch_8 OR or
  10801. +sync_op_and_fetch_8 AND and
  10802. +sync_op_and_fetch_8 XOR xor
  10803. +
  10804. +sync_fetch_and_alu_op_8 ADD add
  10805. +sync_fetch_and_alu_op_8 SUB sub
  10806. +
  10807. +sync_alu_op_and_fetch_8 ADD add
  10808. +sync_alu_op_and_fetch_8 SUB sub
  10809. +
  10810. +sync_fetch_and_op_neg_size AND nand
  10811. +
  10812. +sync_val_compare_and_swap 1 B
  10813. +sync_val_compare_and_swap 2 W
  10814. +sync_val_compare_and_swap 4 D
  10815. +
  10816. +sync_bool_compare_and_swap 1 B
  10817. +sync_bool_compare_and_swap 2 W
  10818. +sync_bool_compare_and_swap 4 D
  10819. +
  10820. +sync_lock_test_and_set 1 B
  10821. +sync_lock_test_and_set 2 W
  10822. +sync_lock_test_and_set 4 D
  10823. diff -Nur gcc-4.2.4.orig/gcc/config/metag/linux-elf.h gcc-4.2.4/gcc/config/metag/linux-elf.h
  10824. --- gcc-4.2.4.orig/gcc/config/metag/linux-elf.h 1969-12-31 18:00:00.000000000 -0600
  10825. +++ gcc-4.2.4/gcc/config/metag/linux-elf.h 2015-07-03 18:46:05.749283542 -0500
  10826. @@ -0,0 +1,77 @@
  10827. +/* Definitions of target machine for GNU compiler
  10828. + for Meta Linux-based GNU systems using ELF.
  10829. + Copyright (C) 2004, 2007 Free Software Foundation, Inc.
  10830. + Contributed by Imagination Technologies Ltd (toolkit@metagence.com)
  10831. +
  10832. +This file is part of GCC.
  10833. +
  10834. +GCC is free software; you can redistribute it and/or modify it under
  10835. +the terms of the GNU General Public License as published by the Free
  10836. +Software Foundation; either version 3, or (at your option) any later
  10837. +version.
  10838. +
  10839. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10840. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10841. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  10842. +for more details.
  10843. +
  10844. +You should have received a copy of the GNU General Public License
  10845. +along with GCC; see the file COPYING3. If not see
  10846. +<http://www.gnu.org/licenses/>. */
  10847. +
  10848. +#undef TARGET_VERSION
  10849. +#define TARGET_VERSION fputs (" (Metag Linux GNU)", stderr)
  10850. +
  10851. +#undef SUBTARGET_EXTRA_SPECS
  10852. +#define SUBTARGET_EXTRA_SPECS \
  10853. + { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
  10854. +
  10855. +#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  10856. +
  10857. +#define TARGET_OS_CPP_BUILTINS() \
  10858. + do \
  10859. + { \
  10860. + LINUX_TARGET_OS_CPP_BUILTINS (); \
  10861. + } \
  10862. +while (0)
  10863. +
  10864. +#undef LIB_SPEC
  10865. +#define LIB_SPEC \
  10866. + "%{pthread:-lpthread} " \
  10867. + "%{shared:-lc} " \
  10868. + "%{!shared: %{profile:-lc_p} %{!profile:-lc}} "
  10869. +
  10870. +#undef TYPE_OPERAND_FMT
  10871. +#define TYPE_OPERAND_FMT "@%s"
  10872. +
  10873. +#undef GLOBAL_ASM_OP
  10874. +#define GLOBAL_ASM_OP "\t.global\t"
  10875. +
  10876. +
  10877. +/* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
  10878. + (even more) magical crtbegin.o file which provides part of the
  10879. + support for getting C++ file-scope static object constructed before
  10880. + entering `main'.
  10881. +
  10882. + Don't bother seeing crtstuff.c -- there is absolutely no hope of
  10883. + getting that file to understand multiple GPs. GNU Libc provides a
  10884. + hand-coded version that is used on Linux; it could be copied here
  10885. + if there is ever a need. */
  10886. +
  10887. +#undef STARTFILE_SPEC
  10888. +#define STARTFILE_SPEC \
  10889. + "%{!shared: " \
  10890. + "%{pg:crt1.o%s} %{!pg:%{p:crt1.o%s} " \
  10891. + "%{!p:%{profile:crt1.o%s} " \
  10892. + "%{!profile:crt1.o%s}}}} " \
  10893. + "crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s} "
  10894. +
  10895. +/* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
  10896. + magical crtend.o file which provides part of the support for
  10897. + getting C++ file-scope static object constructed before entering
  10898. + `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
  10899. +
  10900. +#undef ENDFILE_SPEC
  10901. +#define ENDFILE_SPEC \
  10902. + "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
  10903. +
  10904. diff -Nur gcc-4.2.4.orig/gcc/config/metag/linux.h gcc-4.2.4/gcc/config/metag/linux.h
  10905. --- gcc-4.2.4.orig/gcc/config/metag/linux.h 1969-12-31 18:00:00.000000000 -0600
  10906. +++ gcc-4.2.4/gcc/config/metag/linux.h 2015-07-03 18:46:05.749283542 -0500
  10907. @@ -0,0 +1,32 @@
  10908. +/* Definitions of target machine for GNU compiler,
  10909. + for Meta Linux-based GNU systems.
  10910. + Copyright (C) 2005, 2007 Free Software Foundation, Inc.
  10911. + Contributed by Imagination Technologies Ltd (toolkit@metagence.com)
  10912. +
  10913. +This file is part of GCC.
  10914. +
  10915. +GCC is free software; you can redistribute it and/or modify it under
  10916. +the terms of the GNU General Public License as published by the Free
  10917. +Software Foundation; either version 3, or (at your option) any later
  10918. +version.
  10919. +
  10920. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10921. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10922. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  10923. +for more details.
  10924. +
  10925. +You should have received a copy of the GNU General Public License
  10926. +along with GCC; see the file COPYING3. If not see
  10927. +<http://www.gnu.org/licenses/>. */
  10928. +
  10929. +#undef CPP_SUBTARGET_SPEC
  10930. +#define CPP_SUBTARGET_SPEC \
  10931. + "%{posix:-D_POSIX_SOURCE} " \
  10932. + "%{pthread:-D_REENTRANT -D_PTHREADS} "
  10933. +
  10934. +#define NO_IMPLICIT_EXTERN_C
  10935. +
  10936. +#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
  10937. +
  10938. +#undef TARGET_C99_FUNCTIONS
  10939. +#define TARGET_C99_FUNCTIONS 1
  10940. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag.c gcc-4.2.4/gcc/config/metag/metag.c
  10941. --- gcc-4.2.4.orig/gcc/config/metag/metag.c 1969-12-31 18:00:00.000000000 -0600
  10942. +++ gcc-4.2.4/gcc/config/metag/metag.c 2015-07-03 18:46:05.765283542 -0500
  10943. @@ -0,0 +1,7661 @@
  10944. +/* Definitions of target machine for GNU compiler.
  10945. + Imagination Technologies Meta version.
  10946. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
  10947. + Imagination Technologies Ltd
  10948. +
  10949. +This file is part of GCC.
  10950. +
  10951. +GCC is free software; you can redistribute it and/or modify it under
  10952. +the terms of the GNU General Public License as published by the Free
  10953. +Software Foundation; either version 3, or (at your option) any later
  10954. +version.
  10955. +
  10956. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10957. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10958. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  10959. +for more details.
  10960. +
  10961. +You should have received a copy of the GNU General Public License
  10962. +along with GCC; see the file COPYING3. If not see
  10963. +<http://www.gnu.org/licenses/>. */
  10964. +
  10965. +#include "config.h"
  10966. +#include "system.h"
  10967. +#include "coretypes.h"
  10968. +#include "tm.h"
  10969. +#include "rtl.h"
  10970. +#include "tree.h"
  10971. +#include "obstack.h"
  10972. +#include "regs.h"
  10973. +#include "hard-reg-set.h"
  10974. +#include "real.h"
  10975. +#include "insn-config.h"
  10976. +#include "conditions.h"
  10977. +#include "insn-flags.h"
  10978. +#include "output.h"
  10979. +#include "insn-attr.h"
  10980. +#include "flags.h"
  10981. +#include "reload.h"
  10982. +#include "function.h"
  10983. +#include "expr.h"
  10984. +#include "optabs.h"
  10985. +#include "toplev.h"
  10986. +#include "recog.h"
  10987. +#include "ggc.h"
  10988. +#include "except.h"
  10989. +#include "c-pragma.h"
  10990. +#include "integrate.h"
  10991. +#include "cfgloop.h"
  10992. +#include "tm_p.h"
  10993. +#include "timevar.h"
  10994. +#include "options.h"
  10995. +#include "cgraph.h"
  10996. +#include "target.h"
  10997. +#include "target-def.h"
  10998. +#include "tm-constrs.h"
  10999. +#include "langhooks.h"
  11000. +#include "version.h"
  11001. +#include <ctype.h>
  11002. +
  11003. +/* Is the given character a logical line separator for the assembler?
  11004. + Set the default to be the gas line separator and allow the embedded
  11005. + backend to override it. */
  11006. +#ifndef IS_ASM_LOGICAL_LINE_SEPARATOR
  11007. +#define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == ';')
  11008. +#endif
  11009. +
  11010. +#define IS_PSEUDO_REGNO(REGNO) \
  11011. + ((REGNO) != INVALID_REGNUM && (REGNO) >= FIRST_PSEUDO_REGISTER)
  11012. +
  11013. +#define IS_HARD_OR_VIRT_REGNO(REGNO) \
  11014. + ((REGNO) != INVALID_REGNUM && (REGNO) < FIRST_PSEUDO_REGISTER)
  11015. +
  11016. +#define NO_FUNCTION_CSE
  11017. +
  11018. +#define REGNO_BIT(REGNO) (1U << ((REGNO) >> 1))
  11019. +
  11020. +#define df_regs_ever_live_p(REGNO) regs_ever_live[(unsigned)(REGNO)]
  11021. +
  11022. +static tree metag_handle_model_decl_attribute (tree *, tree, tree, int, bool *);
  11023. +static int metag_consumer_stalls_from_load_multi (rtx, rtx);
  11024. +static bool metag_consumer_is_o2r (rtx, rtx, int, int);
  11025. +static bool metag_pass_in_reg (CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
  11026. +static bool metag_same_reg_p (rtx, rtx, bool);
  11027. +static long metag_const_double_sfmode (rtx);
  11028. +static unsigned int metag_calculate_ech_ctx (void);
  11029. +static unsigned int metag_adjust_savesize_ech (unsigned int*, unsigned int*,
  11030. + unsigned int*);
  11031. +static void metag_emit_byte_swap16 (rtx, rtx);
  11032. +static void metag_emit_byte_swap32 (rtx, rtx);
  11033. +static int metag_asm_insn_count (rtx);
  11034. +static bool metag_is_label_within_function (rtx);
  11035. +static rtx metag_function_return_reg (enum machine_mode mode);
  11036. +
  11037. +/* METAG specific attribute support.
  11038. +
  11039. + model - select code model used to access data
  11040. +
  11041. + on VAR_DECL effects code that references symbol (weak effect)
  11042. +
  11043. + small: intended to be addressed using A1GbP+OG(..) (1 inst)
  11044. + large: intended to be addresses using A1GbP+HI(..)+LO(..) (3 insts)
  11045. +
  11046. + on FUNCTION_DECL effects code within function concerned (strong effect)
  11047. +
  11048. + small: access all small data using A1GbP+OG(..) (no fn overhead)
  11049. + access all larger data using A1GbP+OLA(..)
  11050. + large: access all data using A1GbP+HI(..)+LO(..) (no fn overhead)
  11051. +
  11052. +*/
  11053. +
  11054. +const struct
  11055. +attribute_spec metag_attribute_table[] =
  11056. +{
  11057. +/*{ name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
  11058. + { "model", 1, 1, true, false, false, metag_handle_model_decl_attribute },
  11059. + { NULL, 0, 0, false, false, false, NULL }
  11060. +};
  11061. +
  11062. +#define DEF_MCC \
  11063. + DEF_MCC_CODES(A, NV, "A"), \
  11064. + DEF_MCC_CODES(NV, A, "NV"), \
  11065. + DEF_MCC_CODES(EQ, NE, "EQ"), \
  11066. + DEF_MCC_CODES(NE, EQ, "NE"), \
  11067. + DEF_MCC_CODES(LO, HS, "LO"), \
  11068. + DEF_MCC_CODES(HS, LO, "HS"), \
  11069. + DEF_MCC_CODES(MI, PL, "MI"), \
  11070. + DEF_MCC_CODES(PL, MI, "PL"), \
  11071. + DEF_MCC_CODES(VS, VC, "VS"), \
  11072. + DEF_MCC_CODES(VC, VS, "VC"), \
  11073. + DEF_MCC_CODES(HI, LS, "HI"), \
  11074. + DEF_MCC_CODES(LS, HI, "LS"), \
  11075. + DEF_MCC_CODES(GE, LT, "GE"), \
  11076. + DEF_MCC_CODES(LT, GE, "LT"), \
  11077. + DEF_MCC_CODES(GT, LE, "GT"), \
  11078. + DEF_MCC_CODES(LE, GT, "LE"), \
  11079. + DEF_MCC_CODES(CS, CC, "CS"), \
  11080. + DEF_MCC_CODES(CC, CS, "CC"), \
  11081. + DEF_MCC_CODES(FEQ, UNE, "FEQ"), \
  11082. + DEF_MCC_CODES(UNE, FEQ, "UNE"), \
  11083. + DEF_MCC_CODES(FGT, NFGT, "FGT"), \
  11084. + DEF_MCC_CODES(FGE, NFGE, "FGE"), \
  11085. + DEF_MCC_CODES(FLT, NFLT, "FLT"), \
  11086. + DEF_MCC_CODES(FLE, NFLE, "FLE"), \
  11087. + DEF_MCC_CODES(U, NU, "UVS"), \
  11088. + DEF_MCC_CODES(FLEG, NFLEG, "FVC"), \
  11089. + DEF_MCC_CODES(UGT, NUGT, "UGT"), \
  11090. + DEF_MCC_CODES(UGE, NUGE, "UGE"), \
  11091. + DEF_MCC_CODES(ULT, NULT, "ULT"), \
  11092. + DEF_MCC_CODES(ULE, NULE, "ULE"), \
  11093. + DEF_MCC_CODES(NFGT, FGT, "ULE"), \
  11094. + DEF_MCC_CODES(NFGE, FGE, "ULT"), \
  11095. + DEF_MCC_CODES(NFLT, FLT, "UGE"), \
  11096. + DEF_MCC_CODES(NFLE, FLE, "UGT"), \
  11097. + DEF_MCC_CODES(NU, U, "FVC"), \
  11098. + DEF_MCC_CODES(NFLEG, FLEG, "UVS"), \
  11099. + DEF_MCC_CODES(NUGT, UGT, "FLE"), \
  11100. + DEF_MCC_CODES(NUGE, UGE, "FLT"), \
  11101. + DEF_MCC_CODES(NULT, ULT, "FGE"), \
  11102. + DEF_MCC_CODES(NULE, ULE, "FGT")
  11103. +
  11104. +#define MCC_MAX MCC_NULE
  11105. +
  11106. +#define DEF_MCC_CODES(CODE, INV, ASMCODE) MCC_##CODE
  11107. +
  11108. +typedef enum /* GCC : META condition codes */
  11109. +{
  11110. + DEF_MCC
  11111. +} metag_cc;
  11112. +
  11113. +static metag_cc get_metag_cc (rtx);
  11114. +static metag_cc get_metag_cc_float (enum rtx_code);
  11115. +static bool metag_is_cc_quiet (metag_cc);
  11116. +
  11117. +#undef DEF_MCC_CODES
  11118. +#define DEF_MCC_CODES(CODE, INV, ASMCODE) MCC_##INV
  11119. +static metag_cc const metag_inv_cc[MCC_MAX + 1] =
  11120. +{
  11121. + DEF_MCC
  11122. +};
  11123. +
  11124. +#undef DEF_MCC_CODES
  11125. +#define DEF_MCC_CODES(CODE, INV, ASMCODE) ASMCODE
  11126. +
  11127. +static const char * const metag_cc_names[MCC_MAX + 1] =
  11128. +{
  11129. + DEF_MCC
  11130. +};
  11131. +
  11132. +rtx metag_compare_op0;
  11133. +rtx metag_compare_op1;
  11134. +
  11135. +enum metag_model metag_model;
  11136. +
  11137. +/* Which META core we're generating code for. */
  11138. +enum metac_target metac_target;
  11139. +
  11140. +/* Which META core we are scheduling for see (define_attr "metacore" ...) */
  11141. +enum attr_metacore metacore;
  11142. +
  11143. +/* What FPU pipeline are we targetting */
  11144. +int metag_fpu_single = 0;
  11145. +
  11146. +/* Are we allowed to use any fpu resources */
  11147. +int metag_fpu_resources = 0;
  11148. +
  11149. +/* How wide is the widest memory access on this core */
  11150. +int metag_memory_width = 64;
  11151. +
  11152. +/* Should MiniM jump tables be emitted short, long or auto detected */
  11153. +enum metag_jump_table_branch metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_AUTO;
  11154. +
  11155. +/* -mextensions flags */
  11156. +bool metag_meta2_bex_enabled = false;
  11157. +
  11158. +/* Force tbictxsave to be enabled */
  11159. +int metag_force_tbictxsave = true;
  11160. +
  11161. +/* A finite state machine takes care of noticing whether or not instructions
  11162. + can be conditionally executed, and thus decrease execution time and code
  11163. + size by deleting branch instructions. The fsm is controlled by
  11164. + final_prescan_insn, and controls the actions of ASM_OUTPUT_OPCODE. */
  11165. +
  11166. +/* For an explanation of these variables, see final_prescan_insn below. */
  11167. +static int metag_ccfsm_state;
  11168. +static metag_cc metag_current_cc;
  11169. +static GTY(()) rtx metag_target_insn = NULL_RTX;
  11170. +static int metag_target_label;
  11171. +static int metag_max_insns_skipped = 10;
  11172. +
  11173. +#define METAG_DEBUG_CCEXEC 0
  11174. +
  11175. +#if METAG_DEBUG_CCEXEC
  11176. +static const char *attr_cond_name (enum attr_cond);
  11177. +static const char *attr_ccstate_name (enum attr_ccstate);
  11178. +static const char *attr_predicale_name (enum attr_predicable);
  11179. +#endif
  11180. +
  11181. +
  11182. +bool
  11183. +metag_datareg_p (unsigned int regno)
  11184. +{
  11185. +#if FIRST_DATA_REG == 0
  11186. + return regno <= LAST_DATA_REG;
  11187. +#else
  11188. + return FIRST_DATA_REG <= regno && regno <= LAST_DATA_REG;
  11189. +#endif
  11190. +}
  11191. +
  11192. +bool
  11193. +metag_addrreg_p (unsigned int regno)
  11194. +{
  11195. + return FIRST_ADDR_REG <= regno && regno <= LAST_ADDR_REG;
  11196. +}
  11197. +
  11198. +bool
  11199. +metag_fpcreg_p (unsigned int regno)
  11200. +{
  11201. + return FIRST_FP_REG <= regno && regno <= LAST_FP_REG;
  11202. +}
  11203. +
  11204. +bool
  11205. +metag_fppreg_p (unsigned int regno)
  11206. +{
  11207. + return FIRST_FP_REG <= regno && regno <= LAST_FP_REG && ((regno - FIRST_FP_REG) & 1) == 0;
  11208. +}
  11209. +
  11210. +#define METAG_DATAREG_UNIT(REGNO) ((REGNO) & 1)
  11211. +#define METAG_DATAREG_REGN(REGNO) ((REGNO) >> 1)
  11212. +
  11213. +static long
  11214. +metag_const_double_sfmode (rtx op)
  11215. +{
  11216. + long l;
  11217. + REAL_VALUE_TYPE rv;
  11218. +
  11219. + REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
  11220. + REAL_VALUE_TO_TARGET_SINGLE (rv, l);
  11221. + return l;
  11222. +}
  11223. +
  11224. +void
  11225. +metag_split_movsi_immediate (rtx operands[])
  11226. +{
  11227. + rtx target= operands[0];
  11228. + rtx imm = operands[1];
  11229. + HOST_WIDE_INT value = INTVAL (imm);
  11230. +
  11231. + if ((value & 0x0000FFFF) == 0)
  11232. + emit_move_insn (target, imm);
  11233. + else if ((value & 0xFFFF0000) == 0)
  11234. + emit_move_insn (target, imm);
  11235. + else if ((value & 0xFFFF8000) == 0xFFFF8000)
  11236. + emit_move_insn (target, imm);
  11237. + else
  11238. + {
  11239. + HOST_WIDE_INT ival;
  11240. +
  11241. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  11242. + emit_move_insn (target, GEN_INT (ival));
  11243. +
  11244. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  11245. + emit_insn (gen_addsi3 (target, target, GEN_INT (ival)));
  11246. + }
  11247. +}
  11248. +
  11249. +void
  11250. +metag_split_movsf_immediate (rtx operands[])
  11251. +{
  11252. + rtx ops[2];
  11253. +
  11254. + ops[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
  11255. + if (CONST_DOUBLE_P (operands[1]))
  11256. + {
  11257. + HOST_WIDE_INT ival = metag_const_double_sfmode (operands[1]);
  11258. +
  11259. + ival = trunc_int_for_mode (ival, SImode);
  11260. + ops[1] = GEN_INT (ival);
  11261. + }
  11262. + else if (CONST_INT_P (operands[1]))
  11263. + ops[1] = operands[1];
  11264. + else
  11265. + gcc_unreachable ();
  11266. +
  11267. + metag_split_movsi_immediate (ops);
  11268. +}
  11269. +
  11270. +void
  11271. +metag_split_movdi (rtx operands[])
  11272. +{
  11273. + unsigned int dst_reg = REGNO (operands[0]);
  11274. + unsigned int src_reg = REGNO (operands[1]);
  11275. +
  11276. + emit_move_insn (gen_rtx_REG (SImode, dst_reg),
  11277. + gen_rtx_REG (SImode, src_reg));
  11278. +
  11279. + emit_move_insn (gen_rtx_REG (SImode, dst_reg + 1),
  11280. + gen_rtx_REG (SImode, src_reg + 1));
  11281. +}
  11282. +
  11283. +void
  11284. +metag_split_movdi_immediate (rtx operands[])
  11285. +{
  11286. + unsigned int dst_reg = REGNO (operands[0]);
  11287. + rtx imm[2];
  11288. + rtx ops[2];
  11289. +
  11290. + split_double (operands[1], &imm[0], &imm[1]);
  11291. +
  11292. + ops[0] = gen_rtx_REG (SImode, dst_reg);
  11293. + ops[1] = imm[0];
  11294. + metag_split_movsi_immediate (ops);
  11295. +
  11296. + ops[0] = gen_rtx_REG (SImode, dst_reg + 1);
  11297. + ops[1] = imm[1];
  11298. + metag_split_movsi_immediate (ops);
  11299. +}
  11300. +
  11301. +void
  11302. +metag_split_movdf (rtx operands[])
  11303. +{
  11304. + unsigned int dst_reg = REGNO (operands[0]);
  11305. + unsigned int src_reg = REGNO (operands[1]);
  11306. +
  11307. + emit_move_insn (gen_rtx_REG (SImode, dst_reg),
  11308. + gen_rtx_REG (SImode, src_reg));
  11309. +
  11310. + emit_move_insn (gen_rtx_REG (SImode, dst_reg + 1),
  11311. + gen_rtx_REG (SImode, src_reg + 1));
  11312. +}
  11313. +
  11314. +void
  11315. +metag_split_movdf_immediate (rtx operands[])
  11316. +{
  11317. + unsigned int dst_reg = REGNO (operands[0]);
  11318. + rtx imm[2];
  11319. + rtx ops[2];
  11320. +
  11321. + split_double (operands[1], &imm[0], &imm[1]);
  11322. +
  11323. + ops[0] = gen_rtx_REG (SImode, dst_reg);
  11324. + ops[1] = imm[0];
  11325. + metag_split_movsi_immediate (ops);
  11326. +
  11327. + ops[0] = gen_rtx_REG (SImode, dst_reg + 1);
  11328. + ops[1] = imm[1];
  11329. +
  11330. + metag_split_movsi_immediate (ops);
  11331. +}
  11332. +
  11333. +#define metag_non_leaf_function_p() \
  11334. + (reload_completed ? cfun->machine->non_leaf : !leaf_function_p ())
  11335. +
  11336. +#define TBICTX_XMCC_BIT 0x0020
  11337. +#define TBICTX_XDX8_BIT 0x0100
  11338. +#define TBICTX_XAX4_BIT 0x0200
  11339. +#define TBICTX_XEXT_BIT 0x1000
  11340. +
  11341. +static unsigned int
  11342. +metag_calculate_ech_ctx (void)
  11343. +{
  11344. + unsigned int ech_ctx = 0;
  11345. +
  11346. + /* Now emit ECH support */
  11347. + if (TARGET_ECH)
  11348. + {
  11349. + int regno;
  11350. +
  11351. + for (regno = FIRST_ECH_DATA_REG ; regno <= LAST_DATA_REG ; regno++)
  11352. + if (df_regs_ever_live_p (regno))
  11353. + {
  11354. + ech_ctx |= (TBICTX_XDX8_BIT << 16);
  11355. + break;
  11356. + }
  11357. +
  11358. + for (regno = FIRST_ECH_ADDR_REG ; regno <= LAST_ADDR_REG ; regno++)
  11359. + if (df_regs_ever_live_p (regno))
  11360. + {
  11361. + ech_ctx |= (TBICTX_XAX4_BIT << 16);
  11362. + break;
  11363. + }
  11364. + }
  11365. +
  11366. + return ech_ctx;
  11367. +}
  11368. +
  11369. +static unsigned int
  11370. +metag_adjust_savesize_ech (unsigned int* savesize_gp, unsigned int* extras_gp,
  11371. + unsigned int* FP_SP_offset)
  11372. +{
  11373. + unsigned int ech_ctx = metag_calculate_ech_ctx ();
  11374. +
  11375. + if (ech_ctx != 0)
  11376. + {
  11377. + *extras_gp |= REGNO_BIT (METAG_ECH_REGNUM);
  11378. + *savesize_gp += UNITS_PER_WORD * 2;
  11379. +
  11380. + if (FP_SP_offset != NULL && METAG_ECH_REGNUM >= MIN_METAG_CSAVE_REGNUM)
  11381. + *FP_SP_offset += UNITS_PER_WORD * 2;
  11382. + }
  11383. +
  11384. + return ech_ctx;
  11385. +}
  11386. +
  11387. +/* function prologue */
  11388. +
  11389. +void
  11390. +metag_function_prologue (FILE *file ATTRIBUTE_UNUSED, HOST_WIDE_INT size)
  11391. +{
  11392. + unsigned int savesize_gp = 0;
  11393. + unsigned int savesize_eh = 0;
  11394. + unsigned int FP_SP_offset = 0;
  11395. + unsigned int pretend_size = ALIGN_ON_STACK_BOUNDARY (current_function_pretend_args_size);
  11396. + unsigned int pretend_regs = pretend_size / UNITS_PER_WORD;
  11397. + bool non_leaf = metag_non_leaf_function_p ();
  11398. + unsigned int extras_gp = 0;
  11399. + unsigned int extras_eh = 0;
  11400. + unsigned int ech_ctx = 0;
  11401. + bool loads_pic_register;
  11402. +
  11403. + if (metag_ccfsm_state || metag_target_insn)
  11404. + gcc_unreachable (); /* Sanity check */
  11405. +
  11406. + /* Track basis for the varargs we save */
  11407. + if (cfun->machine->anonymous_args)
  11408. + fprintf (file, ASM_COMMENT_START " Store varargs in registers %d (%d)\n",
  11409. + current_function_pretend_args_size, pretend_size);
  11410. + else if (current_function_pretend_args_size)
  11411. + fprintf (file, ASM_COMMENT_START " Store partial args in registers %d (%d)\n",
  11412. + current_function_pretend_args_size, pretend_size);
  11413. +
  11414. + /* Add in outgoing sizes */
  11415. + if (size != 0)
  11416. + fprintf (file, ASM_COMMENT_START " Allocate local size %ld\n", (long)size);
  11417. +
  11418. + if (non_leaf)
  11419. + fprintf (file, ASM_COMMENT_START " Allocate outgoing %d\n",
  11420. + current_function_outgoing_args_size);
  11421. +
  11422. + size += current_function_outgoing_args_size;
  11423. +
  11424. + /* Round size of local stack to preserve 64-bit alignments */
  11425. + size = ALIGN_ON_STACK_BOUNDARY (size);
  11426. +
  11427. + /* Make pretend regs into the first non-varargs register number */
  11428. + pretend_regs += MIN_METAG_PARM_REGNUM;
  11429. +
  11430. + {
  11431. + unsigned int regno;
  11432. +
  11433. + for (regno = MIN_METAG_PARM_REGNUM; regno <= MAX_METAG_CSAVE_REGNUM; regno += 2)
  11434. + {
  11435. + if (regno < pretend_regs
  11436. + || (!call_used_regs[regno]
  11437. + && (df_regs_ever_live_p (regno + 0) || df_regs_ever_live_p (regno + 1))))
  11438. + {
  11439. + extras_gp |= REGNO_BIT (regno);
  11440. +
  11441. + /* Push this data register */
  11442. + savesize_gp += UNITS_PER_WORD * 2;
  11443. +
  11444. + if (regno >= MIN_METAG_CSAVE_REGNUM)
  11445. + FP_SP_offset += UNITS_PER_WORD * 2;
  11446. + }
  11447. + }
  11448. + }
  11449. +
  11450. + /* Exception handler bits */
  11451. + if (current_function_calls_eh_return)
  11452. + {
  11453. + unsigned int n;
  11454. +
  11455. + for (n = 0; n < NUM_EH_RETURN_DATA_REGS; n++)
  11456. + {
  11457. + unsigned int regno = EH_RETURN_DATA_REGNO (n);
  11458. +
  11459. + if (regno != INVALID_REGNUM)
  11460. + {
  11461. + unsigned int regbit = REGNO_BIT (regno);
  11462. +
  11463. + if ((extras_eh & regbit) == 0)
  11464. + {
  11465. + extras_eh |= regbit;
  11466. + savesize_eh += UNITS_PER_WORD * 2;
  11467. + FP_SP_offset += UNITS_PER_WORD * 2;
  11468. + }
  11469. + }
  11470. + }
  11471. + }
  11472. +
  11473. + /* Adjust the saved registers for ECH support */
  11474. + ech_ctx = metag_adjust_savesize_ech (&savesize_gp, &extras_gp, &FP_SP_offset);
  11475. +
  11476. + /* Recover original pretend regs */
  11477. + pretend_regs -= MIN_METAG_PARM_REGNUM;
  11478. +
  11479. + /* Can only save frame pointer from D0 temporary */
  11480. + if (cfun->machine->frame_pointer_epilogue)
  11481. + fputs (ASM_COMMENT_START " frame_pointer_needed to optimize epilogue\n", file);
  11482. + else if (frame_pointer_needed)
  11483. + fputs (ASM_COMMENT_START " GCC says frame_pointer_needed\n", file);
  11484. +
  11485. + if (frame_pointer_needed || non_leaf)
  11486. + {
  11487. + if (non_leaf)
  11488. + {
  11489. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  11490. + fputs (ASM_COMMENT_START " Save return address for non_leaf\n", file);
  11491. + }
  11492. + else
  11493. + fputs (ASM_COMMENT_START " Save return address with callers frame\n", file);
  11494. +
  11495. + if (frame_pointer_needed)
  11496. + extras_gp |= REGNO_BIT (TEMP_D0FRT_REGNUM);
  11497. +
  11498. + savesize_gp += UNITS_PER_WORD * 2;
  11499. + FP_SP_offset += UNITS_PER_WORD * 2;
  11500. + }
  11501. + else if (df_regs_ever_live_p (RETURN_POINTER_REGNUM))
  11502. + {
  11503. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  11504. +
  11505. + /* Push this data register */
  11506. + savesize_gp += UNITS_PER_WORD * 2;
  11507. + if (RETURN_POINTER_REGNUM >= MIN_METAG_CSAVE_REGNUM)
  11508. + FP_SP_offset += UNITS_PER_WORD * 2;
  11509. + }
  11510. +
  11511. + loads_pic_register = METAG_CURRENT_FUNCTION_LOADS_PIC_REGISTER ();
  11512. + if (loads_pic_register)
  11513. + FP_SP_offset += UNITS_PER_WORD * 2; /* Save PIC register. */
  11514. +
  11515. + /* Sanity checks between initial_elimination and prologue.
  11516. + If any of these tests fail then the generated code will be wrong so abort. */
  11517. +
  11518. + gcc_assert (cfun->machine->valid);
  11519. + gcc_assert (cfun->machine->savesize_gp == savesize_gp);
  11520. + gcc_assert (cfun->machine->savesize_eh == savesize_eh);
  11521. + gcc_assert (cfun->machine->FP_SP_offset == FP_SP_offset);
  11522. + gcc_assert (cfun->machine->frame_pointer_needed == frame_pointer_needed);
  11523. + gcc_assert (cfun->machine->non_leaf == non_leaf);
  11524. + gcc_assert (cfun->machine->out_local_size == (unsigned HOST_WIDE_INT)size);
  11525. + gcc_assert (cfun->machine->calls_eh_return == current_function_calls_eh_return);
  11526. + gcc_assert (cfun->machine->extras_gp == extras_gp);
  11527. + gcc_assert (cfun->machine->extras_eh == extras_eh);
  11528. + gcc_assert (cfun->machine->uses_pic_offset_table == current_function_uses_pic_offset_table);
  11529. + gcc_assert (cfun->machine->loads_pic_register == loads_pic_register);
  11530. + gcc_assert (cfun->machine->ech_ctx_required == (ech_ctx != 0));
  11531. +}
  11532. +
  11533. +void
  11534. +metag_function_end_prologue (FILE *file)
  11535. +{
  11536. + fputs (ASM_COMMENT_START " End prologue\n", file);
  11537. + return;
  11538. +}
  11539. +
  11540. +void
  11541. +metag_function_begin_epilogue (FILE *file)
  11542. +{
  11543. + fputs (ASM_COMMENT_START " Begin epilogue\n", file);
  11544. + return;
  11545. +}
  11546. +
  11547. +/* function epilogue */
  11548. +
  11549. +void
  11550. +metag_function_epilogue (FILE *file ATTRIBUTE_UNUSED, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
  11551. +{
  11552. + return;
  11553. +}
  11554. +
  11555. +/* Is the return sequence just recover return address and return - two insts */
  11556. +bool
  11557. +metag_cheap_return (bool cond)
  11558. +{
  11559. + unsigned int regno = 0;
  11560. + unsigned int savesize_gp = 0;
  11561. + unsigned int extras_gp = 0;
  11562. + unsigned int ech_ctx = 0;
  11563. + bool non_leaf = metag_non_leaf_function_p ();
  11564. +
  11565. + if (!METAG_USE_RETURN_INSN (cond))
  11566. + return false;
  11567. +
  11568. + if (non_leaf)
  11569. + savesize_gp += UNITS_PER_WORD * 2; /* Must recover return address so return is not that cheap! */
  11570. +
  11571. +
  11572. + /* Adjust the saved registers for ECH support */
  11573. + ech_ctx = metag_adjust_savesize_ech (&savesize_gp, &extras_gp, NULL);
  11574. +
  11575. + for (regno = MIN_METAG_PARM_REGNUM; regno <= MAX_METAG_CSAVE_REGNUM; regno += 2)
  11576. + {
  11577. + if (!call_used_regs[regno]
  11578. + && (df_regs_ever_live_p(regno + 0) || df_regs_ever_live_p(regno + 1)))
  11579. + {
  11580. + /* Cannot do any pops in a conditional return/call */
  11581. + if (cond)
  11582. + return false;
  11583. +
  11584. + /* Cannot do simple return - too many pops! */
  11585. + if (savesize_gp != 0)
  11586. + return false;
  11587. +
  11588. + /* Have to do at least one pop */
  11589. + savesize_gp = UNITS_PER_WORD * 2;
  11590. + }
  11591. + }
  11592. +
  11593. + if (!(frame_pointer_needed || non_leaf) && df_regs_ever_live_p (RETURN_POINTER_REGNUM))
  11594. + {
  11595. + /* Have to do at least one pop */
  11596. + savesize_gp += UNITS_PER_WORD * 2;
  11597. + }
  11598. +
  11599. + if (current_function_calls_eh_return)
  11600. + return false;
  11601. +
  11602. + /* Cannot make the pop conditional! */
  11603. + if (cond && savesize_gp != 0)
  11604. + return false;
  11605. +
  11606. + /* Detect those hardware trace scenarios that lead to three extra instructions */
  11607. + if (cond && cfun->machine->hwtrace)
  11608. + return false;
  11609. +
  11610. + /* We can announce our intentions to optimise returns */
  11611. + return true;
  11612. +}
  11613. +
  11614. +/* All the code we need to perform a function sibcall */
  11615. +const char *
  11616. +output_sibcall (rtx operands[], unsigned int op_offset)
  11617. +{
  11618. + char buf[1024];
  11619. + rtx CallAddr;
  11620. +
  11621. + if (MEM_P (operands[op_offset]))
  11622. + CallAddr = XEXP (operands[op_offset], 0);
  11623. + else
  11624. + CallAddr = operands[op_offset];
  11625. +
  11626. + if (!TARGET_METAC_1_1 && SYMBOL_REF_P (CallAddr))
  11627. + {
  11628. + if (METAG_FLAG_PIC)
  11629. + gcc_unreachable ();
  11630. + else /* !METAG_FLAG_PIC */
  11631. + {
  11632. + /* Calculate return pointer using fast address bank add */
  11633. + sprintf (buf, "MOVT\t%s, #HI(%%c%d)",
  11634. + reg_names[A0_2_REG], op_offset);
  11635. + output_asm_insn (buf, operands);
  11636. +
  11637. + /* The actual call is a branch */
  11638. + sprintf (buf, "JUMP\t%s, #LO(%%c%d)",
  11639. + reg_names[A0_2_REG], op_offset);
  11640. + output_asm_insn (buf, operands);
  11641. + }
  11642. + }
  11643. + else if (SYMBOL_REF_P (CallAddr))
  11644. + {
  11645. + if (METAG_FLAG_PIC)
  11646. + {
  11647. + if (SYMBOL_REF_LOCAL_P (CallAddr))
  11648. + {
  11649. + /* Local funcs go via relative call */
  11650. + if (TARGET_MODEL_SMALL)
  11651. + {
  11652. + sprintf (buf, "B\t%%c%d", op_offset);
  11653. + output_asm_insn (buf, operands);
  11654. + }
  11655. + else
  11656. + {
  11657. + sprintf (buf, "B\t%%c%d", op_offset);
  11658. + output_asm_insn (buf, operands);
  11659. + }
  11660. + }
  11661. + else
  11662. + {
  11663. + /* The actual call is to an external function so goes via the PLT */
  11664. + sprintf (buf, "B\t%%c%d@PLT", op_offset);
  11665. + output_asm_insn (buf, operands);
  11666. + }
  11667. + }
  11668. + else /* !METAG_FLAG_PIC */
  11669. + {
  11670. + sprintf (buf, "B\t%%c%d", op_offset);
  11671. + output_asm_insn (buf, operands);
  11672. + }
  11673. + }
  11674. + else if (REG_P (CallAddr)
  11675. + && REGNO (CallAddr) != RETURN_POINTER_REGNUM)
  11676. + {
  11677. + sprintf (buf, "MOV%%?\tPC, %s", reg_names[REGNO (CallAddr)]);
  11678. + output_asm_insn (buf, operands);
  11679. + }
  11680. + else
  11681. + gcc_unreachable ();
  11682. +
  11683. + return "";
  11684. +}
  11685. +
  11686. +/* All the code we need to perform a function call */
  11687. +const char *
  11688. +output_call (rtx operands[], unsigned int op_offset)
  11689. +{
  11690. + char buf[1024];
  11691. + const char * prefix = "(*call instance ";
  11692. + const char * const no_prefix = "";
  11693. + rtx CallAddr;
  11694. +
  11695. + if (MEM_P (operands[op_offset]))
  11696. + CallAddr = XEXP (operands[op_offset], 0);
  11697. + else
  11698. + CallAddr = operands[op_offset];
  11699. +
  11700. + if (!TARGET_METAC_1_1 && SYMBOL_REF_P (CallAddr))
  11701. + {
  11702. + if (METAG_FLAG_PIC)
  11703. + gcc_unreachable ();
  11704. + else /* !METAG_FLAG_PIC */
  11705. + {
  11706. + /* Calculate return pointer using fast address bank add */
  11707. + sprintf (buf, "MOVT\t%s, #HI(%%c%d)\t%s %s",
  11708. + reg_names[RETURN_POINTER_REGNUM], op_offset, ASM_COMMENT_START, prefix);
  11709. + output_asm_insn (buf, operands);
  11710. + prefix = no_prefix;
  11711. +
  11712. + /* The actual call is a branch */
  11713. + sprintf (buf, "CALL\t%s, #LO(%%c%d)\t%s ... OK)",
  11714. + reg_names[RETURN_POINTER_REGNUM], op_offset, ASM_COMMENT_START);
  11715. + output_asm_insn (buf, operands);
  11716. +
  11717. + /* Some calls need additional padding instructions */
  11718. + metag_pad_function_call (CallAddr);
  11719. + }
  11720. + }
  11721. + else if (SYMBOL_REF_P (CallAddr))
  11722. + {
  11723. + if (METAG_FLAG_PIC)
  11724. + {
  11725. + if (SYMBOL_REF_LOCAL_P (CallAddr))
  11726. + {
  11727. + /* Local funcs go via relative CALL */
  11728. + if (TARGET_MODEL_SMALL)
  11729. + {
  11730. + sprintf (buf, "CALLR\t%s, %%c%d\t%s %s)",
  11731. + reg_names[RETURN_POINTER_REGNUM], op_offset, ASM_COMMENT_START, prefix);
  11732. + output_asm_insn (buf, operands);
  11733. + prefix = no_prefix;
  11734. + }
  11735. + else
  11736. + {
  11737. + sprintf (buf, "CALLR\t%s, %%c%d\t%s %s)",
  11738. + reg_names[RETURN_POINTER_REGNUM], op_offset, ASM_COMMENT_START, prefix);
  11739. + output_asm_insn (buf, operands);
  11740. + prefix = no_prefix;
  11741. + }
  11742. + }
  11743. + else
  11744. + {
  11745. + /* The actual call is to an external function so goes via the PLT */
  11746. + sprintf (buf, "CALLR\t%s, %%c%d@PLT\t%s %s)",
  11747. + reg_names[RETURN_POINTER_REGNUM], op_offset, ASM_COMMENT_START, prefix);
  11748. + output_asm_insn (buf, operands);
  11749. + prefix = no_prefix;
  11750. + }
  11751. + }
  11752. + else /* !METAG_FLAG_PIC */
  11753. + {
  11754. + /* The actual call is a branch */
  11755. + sprintf (buf, "CALLR\t%s, %%c%d\t%s %s)",
  11756. + reg_names[RETURN_POINTER_REGNUM], op_offset, ASM_COMMENT_START, prefix);
  11757. + output_asm_insn (buf, operands);
  11758. + prefix = no_prefix;
  11759. + }
  11760. +
  11761. + /* Some calls need additional padding instructions */
  11762. + metag_pad_function_call (CallAddr);
  11763. + }
  11764. + else if (REG_P (CallAddr)
  11765. + && REGNO (CallAddr) != RETURN_POINTER_REGNUM)
  11766. + {
  11767. + /* Must move the address to call into D1RtP */
  11768. + sprintf (buf, "MOV%%?\t%s, %s\t%s %s ...",
  11769. + reg_names[RETURN_POINTER_REGNUM],
  11770. + reg_names[REGNO (CallAddr)], ASM_COMMENT_START, prefix);
  11771. + output_asm_insn (buf, operands);
  11772. +
  11773. + /* The actual call is a SWAP */
  11774. + sprintf (buf, "SWAP%%?\tPC, %s\t%s ... OK)",
  11775. + reg_names[RETURN_POINTER_REGNUM], ASM_COMMENT_START);
  11776. + output_asm_insn (buf, operands);
  11777. + }
  11778. + else
  11779. + metag_abort (CallAddr);
  11780. +
  11781. + return "";
  11782. +}
  11783. +
  11784. +unsigned int
  11785. +metag_mem_base (rtx op)
  11786. +{
  11787. + rtx ref;
  11788. +
  11789. + /* We only match with MEM operands */
  11790. + if (!MEM_P (op))
  11791. + return INVALID_REGNUM;
  11792. +
  11793. + /* Get root of address expression */
  11794. + ref = XEXP (op, 0);
  11795. +
  11796. + if (SYMBOL_REF_P (ref))
  11797. + {
  11798. + /* Must be a direct access to an atomic symbol */
  11799. + return GLOBAL_POINTER_REGNUM;
  11800. + }
  11801. +
  11802. + if (GET_CODE (ref) == PLUS
  11803. + || GET_CODE (ref) == PRE_INC
  11804. + || GET_CODE (ref) == PRE_DEC
  11805. + || GET_CODE (ref) == POST_INC
  11806. + || GET_CODE (ref) == POST_DEC
  11807. + || GET_CODE (ref) == PRE_MODIFY
  11808. + || GET_CODE (ref) == POST_MODIFY)
  11809. + {
  11810. + /* De-reference first parameter of address expression */
  11811. + ref = XEXP (ref, 0);
  11812. + }
  11813. +
  11814. + if (SUBREG_P (ref)
  11815. + && REG_P (SUBREG_REG (ref)))
  11816. + {
  11817. + unsigned int regno = REGNO (SUBREG_REG (ref));
  11818. +
  11819. + if (IS_HARD_OR_VIRT_REGNO (regno))
  11820. + return regno + SUBREG_BYTE (ref);
  11821. +
  11822. + return regno;
  11823. + }
  11824. +
  11825. + if (REG_P (ref))
  11826. + return REGNO (ref);
  11827. +
  11828. + return INVALID_REGNUM;
  11829. +}
  11830. +
  11831. +bool
  11832. +metag_mem_base_p (rtx op, enum reg_class class)
  11833. +{
  11834. + unsigned int reg_num = metag_mem_base (op);
  11835. +
  11836. + /* We only match with MEM operands */
  11837. + if (reg_num == INVALID_REGNUM)
  11838. + return false;
  11839. +
  11840. + if (reg_renumber != NULL && IS_PSEUDO_REGNO (reg_num))
  11841. + reg_num = reg_renumber[reg_num];
  11842. +
  11843. + if (reg_num == INVALID_REGNUM)
  11844. + return false;
  11845. +
  11846. + return METAG_REGNO_REG_CLASS (reg_num) == class;
  11847. +}
  11848. +
  11849. +int
  11850. +debug_metag_md (void)
  11851. +{
  11852. + static int counter = 0;
  11853. +
  11854. + return counter++;
  11855. +}
  11856. +
  11857. +bool
  11858. +metag_slow_store (rtx mem, rtx reg)
  11859. +{
  11860. + unsigned int regno;
  11861. +
  11862. + if (!MEM_P (mem))
  11863. + return false;
  11864. +
  11865. + if (REG_P (reg))
  11866. + regno = REGNO (reg);
  11867. + else if (SUBREG_P (reg)
  11868. + && REG_P (SUBREG_REG (reg)))
  11869. + {
  11870. + regno = REGNO (SUBREG_REG (reg));
  11871. + if (IS_HARD_OR_VIRT_REGNO (regno))
  11872. + regno += SUBREG_BYTE (reg);
  11873. + }
  11874. + else
  11875. + return false;
  11876. +
  11877. + if (reg_renumber != NULL && IS_PSEUDO_REGNO (regno))
  11878. + regno = reg_renumber[regno];
  11879. +
  11880. + if (IS_PSEUDO_REGNO (regno))
  11881. + return false;
  11882. +
  11883. + if (GET_MODE_SIZE (GET_MODE (mem)) <= UNITS_PER_WORD)
  11884. + return metag_mem_base_p (mem, METAG_REGNO_REG_CLASS (regno));
  11885. + else
  11886. + return (metag_mem_base_p (mem, METAG_REGNO_REG_CLASS (regno))
  11887. + || metag_mem_base_p (mem, METAG_REGNO_REG_CLASS (regno + 1)));
  11888. +}
  11889. +
  11890. +rtx
  11891. +metag_gen_safe_temp (enum machine_mode mode, rtx reg)
  11892. +{
  11893. + unsigned int regno;
  11894. +
  11895. + gcc_assert ( A0_SCRATCH != INVALID_REGNUM && fixed_regs[A0_SCRATCH]
  11896. + && A1_SCRATCH != INVALID_REGNUM && fixed_regs[A1_SCRATCH]);
  11897. +
  11898. + if (REG_P (reg))
  11899. + regno = REGNO (reg);
  11900. + else if (SUBREG_P (reg)
  11901. + && REG_P (SUBREG_REG (reg)))
  11902. + {
  11903. + regno = REGNO (SUBREG_REG (reg));
  11904. + if (IS_HARD_OR_VIRT_REGNO (regno))
  11905. + regno += SUBREG_BYTE (reg);
  11906. + }
  11907. + else
  11908. + regno = INVALID_REGNUM;
  11909. +
  11910. + if (reg_renumber != NULL && IS_PSEUDO_REGNO (regno))
  11911. + regno = reg_renumber[regno];
  11912. +
  11913. + gcc_assert (regno != INVALID_REGNUM);
  11914. +
  11915. + if (METAG_REGNO_REG_CLASS (regno) == A1_REGS
  11916. + && GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
  11917. + {
  11918. + gcc_assert (regno != A0_SCRATCH);
  11919. +
  11920. + /* Not safe to use register in same unit */
  11921. + return gen_rtx_REG (mode, A0_SCRATCH);
  11922. + }
  11923. +
  11924. + /* Provide suitable temp register */
  11925. + if (GET_MODE_SIZE (GET_MODE (reg)) > UNITS_PER_WORD)
  11926. + {
  11927. + gcc_assert (regno != A0_SCRATCH);
  11928. + gcc_assert (regno != A1_SCRATCH);
  11929. +
  11930. + return gen_rtx_REG (mode, A0_SCRATCH);
  11931. + }
  11932. +
  11933. + gcc_assert (regno != A1_SCRATCH);
  11934. +
  11935. + return gen_rtx_REG (mode, A1_SCRATCH);
  11936. +}
  11937. +
  11938. +enum machine_mode
  11939. +metag_select_cc_mode (enum rtx_code code, rtx x, rtx y)
  11940. +{
  11941. +#undef LETS_US_SEE
  11942. +#ifdef LETS_US_SEE
  11943. + fprintf (stderr, "metag_select_cc_mode %s\n", GET_RTX_NAME (code));
  11944. + debug_rtx (x);
  11945. + debug_rtx (y);
  11946. +#endif
  11947. +
  11948. + /* An operation that sets the condition codes as a side-effect, the
  11949. + V flag is not set correctly, so we can only use comparisons where
  11950. + this doesn't matter. (For LT and GE we can use MI and PL instead. */
  11951. + if (GET_MODE (x) == SImode
  11952. + && y == const0_rtx
  11953. + && (code == EQ || code == NE || code == LT || code == GE)
  11954. + && (GET_CODE (x) == PLUS
  11955. + || GET_CODE (x) == MINUS
  11956. + || GET_CODE (x) == AND
  11957. + || GET_CODE (x) == IOR
  11958. + || GET_CODE (x) == XOR
  11959. + || GET_CODE (x) == NOT
  11960. + || GET_CODE (x) == NEG
  11961. + || GET_CODE (x) == LSHIFTRT
  11962. + || GET_CODE (x) == ASHIFT
  11963. + || GET_CODE (x) == ASHIFTRT
  11964. + || GET_CODE (x) == SIGN_EXTEND
  11965. + || GET_CODE (x) == ZERO_EXTEND
  11966. + || GET_CODE (x) == ZERO_EXTRACT))
  11967. + {
  11968. +#ifdef LETS_US_SEE
  11969. + fputs (" return NOOV\n", stderr);
  11970. +#endif
  11971. + return CC_NOOVmode;
  11972. + }
  11973. +
  11974. + /* A special case, Combine likes to generate
  11975. + (compare (reg X) (neg (reg Y))
  11976. + instead of
  11977. + (compare (plus (reg X) (reg y))
  11978. + (const_int 0))
  11979. + */
  11980. + if (GET_MODE (x) == SImode
  11981. + && (code == EQ || code == NE || code == LT || code == GE)
  11982. + && GET_CODE (y) == NEG)
  11983. + {
  11984. +#ifdef LETS_US_SEE
  11985. + fputs (" return NOOV\n", stderr);
  11986. +#endif
  11987. + return CC_NOOVmode;
  11988. + }
  11989. +
  11990. + /* If we're comparingi EQ/NE against 0 then use Zmode */
  11991. + if (GET_MODE (x) == SImode
  11992. + && y == const0_rtx
  11993. + && (code == EQ || code == NE))
  11994. + {
  11995. +#ifdef LETS_US_SEE
  11996. + fputs (" return Z\n", stderr);
  11997. +#endif
  11998. + return CC_Zmode;
  11999. + }
  12000. +
  12001. + if ((GET_MODE (x) == HImode || GET_MODE (x) == QImode)
  12002. + && (code == EQ || code == NE))
  12003. + {
  12004. + /* Enough to trigger the patterns if HI/QI equality involved */
  12005. +#ifdef LETS_US_SEE
  12006. + fputs (" return Z\n", stderr);
  12007. +#endif
  12008. + return CC_Zmode;
  12009. + }
  12010. +
  12011. + if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
  12012. + {
  12013. + if (metag_is_cc_quiet (get_metag_cc_float (code)))
  12014. + {
  12015. +#ifdef LETS_US_SEE
  12016. + fputs (" return FP_Q\n", stderr);
  12017. +#endif
  12018. + return CC_FP_Qmode;
  12019. + }
  12020. + else
  12021. + {
  12022. +#ifdef LETS_US_SEE
  12023. + fputs (" return FP\n", stderr);
  12024. +#endif
  12025. + return CC_FPmode;
  12026. + }
  12027. + }
  12028. +
  12029. +#ifdef LETS_US_SEE
  12030. + fputs (" return CC\n", stderr);
  12031. +#endif
  12032. + return CCmode;
  12033. +}
  12034. +
  12035. +bool
  12036. +gen_metag_compare (enum rtx_code code, rtx operands[], int index)
  12037. +{
  12038. + if (!(code == LTGT || code == UNEQ))
  12039. + {
  12040. + enum machine_mode mode = SELECT_CC_MODE (code, metag_compare_op0,
  12041. + metag_compare_op1);
  12042. +
  12043. + rtx cc_reg = gen_rtx_REG (mode, MCC_REGNUM);
  12044. +
  12045. + emit_insn (gen_rtx_SET (VOIDmode,
  12046. + cc_reg,
  12047. + gen_rtx_COMPARE (mode, metag_compare_op0, metag_compare_op1)));
  12048. +
  12049. + operands[index] = cc_reg;
  12050. +
  12051. + return true;
  12052. + }
  12053. +
  12054. + return false;
  12055. +}
  12056. +
  12057. +static metag_cc
  12058. +get_metag_cc_float (enum rtx_code comp_code)
  12059. +{
  12060. + switch (comp_code)
  12061. + {
  12062. + case NE: return MCC_UNE;
  12063. + case EQ: return MCC_FEQ;
  12064. + case GE: return MCC_FGE;
  12065. + case GT: return MCC_FGT;
  12066. + case LE: return MCC_FLE;
  12067. + case LT: return MCC_FLT;
  12068. +/* LTGT cannot be handled by META */
  12069. +/* UNEQ cannot be handled by META */
  12070. + case UNGE: return MCC_UGE;
  12071. + case UNGT: return MCC_UGT;
  12072. + case UNLE: return MCC_ULE;
  12073. + case UNLT: return MCC_ULT;
  12074. + case UNORDERED: return MCC_U;
  12075. + case ORDERED: return MCC_FLEG;
  12076. + default:
  12077. + break;
  12078. + }
  12079. + gcc_unreachable ();
  12080. +}
  12081. +
  12082. +static metag_cc
  12083. +get_metag_cc (rtx comparison)
  12084. +{
  12085. + enum machine_mode mode = GET_MODE (XEXP (comparison, 0));
  12086. + enum rtx_code comp_code = GET_CODE (comparison);
  12087. +
  12088. + if (GET_MODE_CLASS (mode) != MODE_CC)
  12089. + mode = SELECT_CC_MODE (comp_code, XEXP (comparison, 0),
  12090. + XEXP (comparison, 1));
  12091. +
  12092. + switch (mode)
  12093. + {
  12094. + case CC_NOOVmode:
  12095. + switch (comp_code)
  12096. + {
  12097. + case NE: return MCC_NE;
  12098. + case EQ: return MCC_EQ;
  12099. + case GE: return MCC_PL;
  12100. + case LT: return MCC_MI;
  12101. + case LTU: return MCC_CS;
  12102. + case GEU: return MCC_CC;
  12103. + default:
  12104. + break;
  12105. + }
  12106. + break;
  12107. +
  12108. + case CC_Zmode:
  12109. + switch (comp_code)
  12110. + {
  12111. + case NE: return MCC_NE;
  12112. + case EQ: return MCC_EQ;
  12113. + default:
  12114. + break;
  12115. + }
  12116. + break;
  12117. +
  12118. + case CC_FPmode:
  12119. + case CC_FP_Qmode:
  12120. + return get_metag_cc_float (comp_code);
  12121. +
  12122. + case CCmode:
  12123. + switch (comp_code)
  12124. + {
  12125. + case NE: return MCC_NE;
  12126. + case EQ: return MCC_EQ;
  12127. + case GE: return MCC_GE;
  12128. + case GT: return MCC_GT;
  12129. + case LE: return MCC_LE;
  12130. + case LT: return MCC_LT;
  12131. + case GEU: return MCC_HS;
  12132. + case GTU: return MCC_HI;
  12133. + case LEU: return MCC_LS;
  12134. + case LTU: return MCC_LO;
  12135. + default:
  12136. + break;
  12137. + }
  12138. + break;
  12139. +
  12140. + default:
  12141. + break;
  12142. + }
  12143. +
  12144. + metag_abort (comparison);
  12145. +}
  12146. +
  12147. +static bool
  12148. +metag_is_cc_quiet (metag_cc metag_comp_code)
  12149. +{
  12150. + switch (metag_comp_code)
  12151. + {
  12152. + case MCC_FEQ:
  12153. + case MCC_UNE:
  12154. + case MCC_U:
  12155. + case MCC_UGT:
  12156. + case MCC_UGE:
  12157. + case MCC_ULT:
  12158. + case MCC_ULE:
  12159. + case MCC_NU:
  12160. + case MCC_NUGT:
  12161. + case MCC_NUGE:
  12162. + case MCC_NULT:
  12163. + case MCC_NULE:
  12164. + return true;
  12165. + case MCC_FGT:
  12166. + case MCC_FGE:
  12167. + case MCC_FLT:
  12168. + case MCC_FLE:
  12169. + case MCC_FLEG:
  12170. + case MCC_NFGT:
  12171. + case MCC_NFGE:
  12172. + case MCC_NFLT:
  12173. + case MCC_NFLE:
  12174. + case MCC_NFLEG:
  12175. + return false;
  12176. +/* LTGT cannot be handled by META */
  12177. +/* UNEQ cannot be handled by META */
  12178. + default:
  12179. + gcc_unreachable ();
  12180. + }
  12181. +}
  12182. +
  12183. +/* Recognise VAR_DECL DECL's which are atomics of size <= 8
  12184. +
  12185. + For the metag we only want to mark variables that are atomic and less
  12186. + than 64-bits for optimisation as condidates for direct LOAD/STORE using
  12187. + A1LbP or A1GbP as a base.
  12188. +
  12189. + All other symbols will be accessed indirectly using OGA(), this is true of
  12190. + functions, string constants, or constructors.
  12191. +*/
  12192. +
  12193. +#define SET_SYMBOL_FLAG_SMALL(SYMBOL) \
  12194. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_GLOBAL \
  12195. + & ~METAG_SYMBOL_FLAG_LARGE) \
  12196. + | METAG_SYMBOL_FLAG_SMALL)
  12197. +
  12198. +#define SET_SYMBOL_FLAG_LARGE(SYMBOL) \
  12199. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_GLOBAL \
  12200. + & ~METAG_SYMBOL_FLAG_SMALL) \
  12201. + | METAG_SYMBOL_FLAG_LARGE)
  12202. +
  12203. +#define SET_SYMBOL_FLAG_GLOBAL(SYMBOL) \
  12204. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_SMALL \
  12205. + & ~METAG_SYMBOL_FLAG_LARGE) \
  12206. + | METAG_SYMBOL_FLAG_GLOBAL)
  12207. +
  12208. +#define SET_SYMBOL_FLAG_BYTE(SYMBOL) \
  12209. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_WORD \
  12210. + & ~METAG_SYMBOL_FLAG_DWORD \
  12211. + & ~METAG_SYMBOL_FLAG_LONG) \
  12212. + | METAG_SYMBOL_FLAG_BYTE)
  12213. +
  12214. +#define SET_SYMBOL_FLAG_WORD(SYMBOL) \
  12215. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_BYTE \
  12216. + & ~METAG_SYMBOL_FLAG_DWORD \
  12217. + & ~METAG_SYMBOL_FLAG_LONG) \
  12218. + | METAG_SYMBOL_FLAG_WORD)
  12219. +
  12220. +#define SET_SYMBOL_FLAG_DWORD(SYMBOL) \
  12221. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_BYTE \
  12222. + & ~METAG_SYMBOL_FLAG_WORD \
  12223. + & ~METAG_SYMBOL_FLAG_LONG) \
  12224. + | METAG_SYMBOL_FLAG_DWORD)
  12225. +
  12226. +#define SET_SYMBOL_FLAG_LONG(SYMBOL) \
  12227. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_BYTE \
  12228. + & ~METAG_SYMBOL_FLAG_WORD \
  12229. + & ~METAG_SYMBOL_FLAG_DWORD) \
  12230. + | METAG_SYMBOL_FLAG_LONG)
  12231. +
  12232. +#define SET_SYMBOL_FLAG_UNKN(SYMBOL) \
  12233. + (SYMBOL_REF_FLAGS (SYMBOL) = (SYMBOL_REF_FLAGS (SYMBOL) & ~METAG_SYMBOL_FLAG_BYTE \
  12234. + & ~METAG_SYMBOL_FLAG_WORD \
  12235. + & ~METAG_SYMBOL_FLAG_DWORD \
  12236. + & ~METAG_SYMBOL_FLAG_LONG)
  12237. +
  12238. +/* This macro definition, if any, is executed immediately after the rtl for
  12239. + decl has been created and stored in DECL_RTL (decl). The value of the rtl
  12240. + will be a mem whose address is a symbol_ref.
  12241. +
  12242. + The usual thing for this macro to do is to record a flag in the symbol_ref
  12243. + (such as SYMBOL_REF_FLAG) or to store a modified name string in the
  12244. + symbol_ref (if one bit is not enough information).
  12245. +
  12246. + For META we do both, the METAG_SYMBOL_FLAG_DIRECT is set if-
  12247. +
  12248. + The decl defines the address of an atomic variable <= 8 bytes in size
  12249. + AND either we are targeting SMALL compilation mode
  12250. + AND the decl DOES NOT HAVE __attribute__ ((model(large)))
  12251. + or we are targeting LARGE compilation mode
  12252. + AND the decl HAS __attribute__ ((model(small)))
  12253. +
  12254. + The METAG_SYMBOL_FLAG_DIRECT hence indicates if direct access to the data
  12255. + symbols value is to be supported by the instruction patterns provided the
  12256. + size of the load/store matches the size of atomic value concerned. The access
  12257. + causes the symbol is to be generally accessed using either A1GbP+OG(..) or
  12258. + A1GbP+OGA(...) if the address or value is to be accessed.
  12259. +
  12260. + METAG_SYMBOL_FLAG_SMALL
  12261. + If SYMBOL_REF_FLAG_DIRECT set to directly access data using-
  12262. +
  12263. + GETx Reg, [A1GbP+#OG(Symbol)] ; x set to name[2]
  12264. + SETx [A1GbP+#OG(Symbol)], Reg ; x set to name[2]
  12265. +
  12266. + else and if address of location required-
  12267. +
  12268. + GETD Reg, [A1GbP+#OGA(Symbol)]
  12269. +
  12270. + METAG_SYMBOL_FLAG_LARGE
  12271. + Only support access to a data symbol's address via-
  12272. +
  12273. + MOV Reg, A1GbP ; name[2] will be 'X'
  12274. + ADDT Reg, Reg, #HI(OG(Symbol)) ; 32-bit offset
  12275. + ADD Reg, Reg, #LO(OG(Symbol))
  12276. +
  12277. + METAG_SYMBOL_FLAG_GLOBAL
  12278. + Only support access as a absolute global address-
  12279. +
  12280. + MOVT Reg, #HI(Symbol) ; 32-bit absolute address
  12281. + ADD Reg, Reg, #LO(Symbol)
  12282. +
  12283. + The following flags:
  12284. + METAG_SYMBOL_FLAG_BYTE
  12285. + METAG_SYMBOL_FLAG_WORD
  12286. + METAG_SYMBOL_FLAG_DWORD
  12287. + METAG_SYMBOL_FLAG_LONG
  12288. + are used to indicate either the size of a directly accessible data symbol or
  12289. + that only the address of the item can be accessed directly because it is
  12290. + too large, a small array, a small structure, a small union, or not in the
  12291. + optimised data section at all.
  12292. +*/
  12293. +
  12294. +void
  12295. +metag_encode_section_info (tree decl, rtx rtl, int first)
  12296. +{
  12297. + char SorLorG = '\0';
  12298. + rtx symbol = NULL_RTX;
  12299. + bool direct = false;
  12300. + char size = 'X';
  12301. + default_encode_section_info (decl, rtl, first);
  12302. +
  12303. + /* Grab the symbol from the rtl passed in */
  12304. + symbol = XEXP (rtl, 0);
  12305. +
  12306. + if (METAG_FLAG_PIC)
  12307. + {
  12308. + /* PIC code only needs to deal with functions and variables */
  12309. + if (TREE_CODE (decl) != FUNCTION_DECL
  12310. + && TREE_CODE (decl) != VAR_DECL)
  12311. + return;
  12312. +
  12313. + gcc_assert (SYMBOL_REF_P (symbol));
  12314. +
  12315. + direct = SYMBOL_REF_LOCAL_P (symbol);
  12316. + }
  12317. + else if (metag_bfd_tls_referenced_p (rtl))
  12318. + {
  12319. + if (TREE_CODE (decl) != VAR_DECL)
  12320. + return;
  12321. + }
  12322. + else
  12323. + {
  12324. + /* Note: Binutils toolchain DOESN'T support #OG or #OGA addressing
  12325. + via A1GbP so we ignore the memory model and always use direct
  12326. + 32-bit absolute access. */
  12327. +
  12328. + /* Direct 32-bit absolute access */
  12329. + SorLorG = 'G';
  12330. + size = 'X';
  12331. + direct = false;
  12332. +
  12333. + if (SorLorG == 'S')
  12334. + SET_SYMBOL_FLAG_SMALL (symbol);
  12335. + else if (SorLorG == 'L')
  12336. + SET_SYMBOL_FLAG_LARGE (symbol);
  12337. + else if (SorLorG == 'G')
  12338. + SET_SYMBOL_FLAG_GLOBAL (symbol);
  12339. + else
  12340. + gcc_unreachable ();
  12341. +
  12342. + if (size == 'B')
  12343. + SET_SYMBOL_FLAG_BYTE (symbol);
  12344. + else if (size == 'W')
  12345. + SET_SYMBOL_FLAG_WORD (symbol);
  12346. + else if (size == 'D')
  12347. + SET_SYMBOL_FLAG_DWORD (symbol);
  12348. + else if (size == 'L')
  12349. + SET_SYMBOL_FLAG_LONG (symbol);
  12350. + else if (size == 'X')
  12351. + SET_SYMBOL_FLAG_LONG (symbol);
  12352. + else
  12353. + gcc_unreachable ();
  12354. + }
  12355. +
  12356. + if (direct)
  12357. + SYMBOL_REF_FLAGS (symbol) |= METAG_SYMBOL_FLAG_DIRECT;
  12358. + else
  12359. + SYMBOL_REF_FLAGS (symbol) &= ~METAG_SYMBOL_FLAG_DIRECT;
  12360. +}
  12361. +
  12362. +/* With DSP features enabled, the compiler will use the V2SImode
  12363. + vectors and with FPU features enabled, the compiler will use
  12364. + V2SFmode */
  12365. +
  12366. +bool
  12367. +metag_vector_mode_supported_p (enum machine_mode mode)
  12368. +{
  12369. + return (TARGET_DSP && (mode == V2SImode))
  12370. + || (TARGET_FPU_SIMD && (mode == V2SFmode));
  12371. +}
  12372. +
  12373. +/* Called by OVERRIDE_OPTIONS to initialize various things. */
  12374. +
  12375. +void
  12376. +metag_override_options (void)
  12377. +{
  12378. + static const struct cpu_table {
  12379. + const char *const name;
  12380. + const enum processor_type processor;
  12381. + const enum attr_metacore tune;
  12382. + const enum metac_target cpu;
  12383. + } cpu_table[] = {
  12384. + { "0.1", PROCESSOR_METAC_0_1, METACORE_METAC_0_1, METAC_0_1_ID },
  12385. + { "1.0", PROCESSOR_METAC_1_0, METACORE_METAC_1_0, METAC_1_0_ID },
  12386. + { "1.1", PROCESSOR_METAC_1_1, METACORE_METAC_1_1, METAC_1_1_ID },
  12387. + { "1.2", PROCESSOR_METAC_1_2, METACORE_METAC_1_2, METAC_1_2_ID },
  12388. + { "2.1", PROCESSOR_METAC_2_1, METACORE_METAC_2_1, METAC_2_1_ID },
  12389. + { NULL, 0, 0, 0 }
  12390. + };
  12391. +
  12392. + if (strcmp (metag_model_string, "small") == 0)
  12393. + {
  12394. + warning (0, "Small memory model not supported, using large model");
  12395. + metag_model = METAG_MODEL_LARGE;
  12396. + }
  12397. + else if (strcmp (metag_model_string, "large") == 0)
  12398. + metag_model = METAG_MODEL_LARGE;
  12399. + else
  12400. + error ("bad value %qs for -mmodel switch", metag_model_string);
  12401. +
  12402. + /* If it's not defined or still has the initial value then use METAC_DEFAULT
  12403. + to set the target string. The conversion of string into ID can then take
  12404. + place as normal. */
  12405. + if (strcmp (metag_cpu_string, "") == 0)
  12406. + {
  12407. + if (TARGET_MTX)
  12408. + metag_cpu_string = "1.2";
  12409. + else
  12410. + metag_cpu_string = METAC_DEFAULT;
  12411. + }
  12412. +
  12413. + if (metag_cpu_string)
  12414. + {
  12415. + unsigned int i;
  12416. + bool newer_than_default = false;
  12417. +
  12418. + for (i = 0; cpu_table[i].name != NULL; i++)
  12419. + {
  12420. + if (strcmp (metag_cpu_string, cpu_table[i].name) == 0)
  12421. + {
  12422. + /* This test is present in order to prevent a toolchain built for an old core
  12423. + allowing a newer core to be targetted. The rest of the toolchain may
  12424. + therefore not support the newer core! */
  12425. + if (newer_than_default)
  12426. + {
  12427. + error ("Bad value %qs for -mmetac switch. Must not be more recent than %qs.", metag_cpu_string, METAC_DEFAULT);
  12428. + break;
  12429. + }
  12430. + metac_target = cpu_table[i].cpu;
  12431. + metacore = cpu_table[i].tune;
  12432. + break;
  12433. + }
  12434. +
  12435. + if (strcmp (METAC_DEFAULT, cpu_table[i].name) == 0)
  12436. + newer_than_default = true;
  12437. + }
  12438. +
  12439. + if (cpu_table[i].name == NULL)
  12440. + error ("Bad value %qs for -mmetac switch", metag_cpu_string);
  12441. + }
  12442. +
  12443. + if (metag_tune_string)
  12444. + {
  12445. + unsigned int i;
  12446. +
  12447. + for (i = 0; cpu_table[i].name != NULL; i++)
  12448. + if (strcmp (metag_tune_string, cpu_table[i].name) == 0)
  12449. + {
  12450. + metacore = cpu_table[i].tune;
  12451. + break;
  12452. + }
  12453. +
  12454. + if (cpu_table[i].name == NULL)
  12455. + error ("bad value %qs for -mtune switch", metag_tune_string);
  12456. + }
  12457. +
  12458. + if (TARGET_MTX)
  12459. + {
  12460. + if (metac_target != METAC_1_2_ID)
  12461. + error ("MTX is based on a Meta 1.2 core, use -mmetac=1.2");
  12462. + }
  12463. +
  12464. + if (TARGET_MINIM_CORE)
  12465. + metag_max_insns_skipped = 2;
  12466. +
  12467. + if (TARGET_FPU_SIMD && (!TARGET_FPU
  12468. + || metag_fpu_single))
  12469. + error ("-msimd-float only valid with -mhard-float=D");
  12470. +
  12471. + if (!TARGET_METAC_2_1 && TARGET_FPU)
  12472. + error ("FPU not available on specified processor: %s", metag_cpu_string);
  12473. +
  12474. + if (!TARGET_METAC_2_1 && metag_meta2_bex_enabled)
  12475. + error ("The 'bex' extension is not available for the specified meta core");
  12476. +
  12477. + metag_override_options_per_os();
  12478. + flag_no_function_cse = 1;
  12479. +}
  12480. +
  12481. +bool
  12482. +metag_return_in_memory (tree type)
  12483. +{
  12484. + HOST_WIDE_INT size = int_size_in_bytes (type);
  12485. +
  12486. + return (size < 0 || size > UNITS_PER_WORD * 2);
  12487. +}
  12488. +
  12489. +void
  12490. +metag_abort (rtx val)
  12491. +{
  12492. + debug_rtx (val);
  12493. + gcc_unreachable ();
  12494. +}
  12495. +
  12496. +static void
  12497. +metag_emit_load_post_inc (rtx dstbase, enum machine_mode mode, rtx dst,
  12498. + HOST_WIDE_INT dstoffset, unsigned int reg)
  12499. +{
  12500. +#if 0
  12501. + rtx addrm mem, insn;
  12502. +
  12503. + addr = gen_rtx_POST_INC (Pmode, dst);
  12504. + mem = adjust_automodify_address_nv (dstbase, mode, addr, dstoffset);
  12505. + insn = emit_insn (gen_rtx_SET (VOIDmode,
  12506. + mem,
  12507. + gen_rtx_REG (mode, reg)));
  12508. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (addr, 0), REG_NOTES (insn));
  12509. +#else
  12510. + rtx plus, mem, insn, set1, set2;
  12511. +
  12512. + mem = adjust_automodify_address_nv (dstbase, mode, dst, dstoffset);
  12513. +
  12514. + dst = XEXP (mem, 0);
  12515. + plus = gen_rtx_PLUS (SImode, dst,
  12516. + gen_int_mode (GET_MODE_SIZE (mode), SImode));
  12517. + set1 = gen_rtx_SET (VOIDmode, mem, gen_rtx_REG (mode, reg));
  12518. + set2 = gen_rtx_SET (VOIDmode, dst, plus);
  12519. +
  12520. + insn = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
  12521. + XVECEXP (insn, 0, 0) = set1;
  12522. + XVECEXP (insn, 0, 1) = set2;
  12523. + emit_insn (insn);
  12524. +#endif
  12525. +}
  12526. +
  12527. +rtx
  12528. +metag_gen_load_multiple (unsigned int base_regno,
  12529. + unsigned int count,
  12530. + enum machine_mode mode,
  12531. + rtx from,
  12532. + bool write_back,
  12533. + rtx basemem,
  12534. + HOST_WIDE_INT * offsetp)
  12535. +{
  12536. + HOST_WIDE_INT offset = *offsetp;
  12537. + unsigned int i;
  12538. + unsigned int word_size = GET_MODE_SIZE (mode);
  12539. + unsigned int j;
  12540. + rtx result;
  12541. +
  12542. + if (count < 2)
  12543. + gcc_unreachable ();
  12544. +
  12545. + result = gen_rtx_PARALLEL (VOIDmode,
  12546. + rtvec_alloc (count + (write_back ? 1 : 0)));
  12547. + if (write_back)
  12548. + {
  12549. + XVECEXP (result, 0, 0) = gen_rtx_SET (VOIDmode,
  12550. + from,
  12551. + plus_constant (from, count * word_size));
  12552. + i = 1;
  12553. + count++;
  12554. + }
  12555. + else
  12556. + i = 0;
  12557. +
  12558. + for (j = 0; i < count; i++, j++)
  12559. + {
  12560. + rtx addr = plus_constant (from, j * word_size);
  12561. + rtx mem = adjust_automodify_address_nv (basemem, mode, addr, offset);
  12562. +
  12563. + XVECEXP (result, 0, i) = gen_rtx_SET (VOIDmode,
  12564. + gen_rtx_REG (mode, base_regno + (j * 2)),
  12565. + mem);
  12566. +
  12567. + offset += word_size;
  12568. + }
  12569. +
  12570. + if (write_back)
  12571. + *offsetp = offset;
  12572. +
  12573. + return result;
  12574. +}
  12575. +
  12576. +rtx
  12577. +metag_gen_store_multiple (unsigned int base_regno,
  12578. + unsigned int count,
  12579. + enum machine_mode mode,
  12580. + rtx to,
  12581. + bool write_back,
  12582. + rtx basemem,
  12583. + HOST_WIDE_INT * offsetp)
  12584. +{
  12585. + HOST_WIDE_INT offset = *offsetp;
  12586. + unsigned int i;
  12587. + unsigned int word_size = GET_MODE_SIZE (mode);
  12588. + unsigned int j;
  12589. + rtx result;
  12590. +
  12591. + if (count < 2)
  12592. + gcc_unreachable ();
  12593. +
  12594. + result = gen_rtx_PARALLEL (VOIDmode,
  12595. + rtvec_alloc (count + (write_back ? 1 : 0)));
  12596. +
  12597. + if (write_back)
  12598. + {
  12599. + XVECEXP (result, 0, 0) = gen_rtx_SET (VOIDmode,
  12600. + to,
  12601. + plus_constant (to, count * word_size));
  12602. + i = 1;
  12603. + count++;
  12604. + }
  12605. + else
  12606. + i = 0;
  12607. +
  12608. + for (j = 0; i < count; i++, j++)
  12609. + {
  12610. + rtx addr = plus_constant (to, j * word_size);
  12611. + rtx mem = adjust_automodify_address_nv (basemem, mode, addr, offset);
  12612. +
  12613. + XVECEXP (result, 0, i) = gen_rtx_SET (VOIDmode,
  12614. + mem,
  12615. + gen_rtx_REG (mode, base_regno + (j * 2)));
  12616. + offset += word_size;
  12617. + }
  12618. +
  12619. + if (write_back)
  12620. + *offsetp = offset;
  12621. +
  12622. + return result;
  12623. +}
  12624. +
  12625. +bool
  12626. +metag_gen_movmemqi (rtx operands[])
  12627. +{
  12628. + HOST_WIDE_INT xfer_bytes_to_go; /* # bytes to xfer in big chunks */
  12629. + HOST_WIDE_INT last_bytes; /* # bytes left over */
  12630. + HOST_WIDE_INT srcoffset;
  12631. + HOST_WIDE_INT dstoffset;
  12632. + enum machine_mode word_mode; /* mode in which to do the transfer */
  12633. + unsigned int word_size; /* units in which to transfer */
  12634. + unsigned int do_in_bytes = 0;
  12635. + unsigned int do_in_max; /* max # of bytes to do in on go */
  12636. + rtx src;
  12637. + rtx dst;
  12638. + rtx dstbase;
  12639. + rtx srcbase;
  12640. +
  12641. + if ( !CONST_INT_P (operands[2])
  12642. + || !CONST_INT_P (operands[3])
  12643. + || INTVAL (operands[2]) > 96
  12644. + || INTVAL (operands[2]) < 8
  12645. + || INTVAL (operands[3]) & 3)
  12646. + return false;
  12647. +
  12648. + dstbase = operands[0];
  12649. + srcbase = operands[1];
  12650. +
  12651. + dst = copy_addr_to_reg (XEXP (dstbase, 0));
  12652. + src = copy_addr_to_reg (XEXP (srcbase, 0));
  12653. + if ((INTVAL (operands[3]) & 7) == 0
  12654. + && INTVAL (operands[2]) >= 16)
  12655. + {
  12656. + /* Data 64-bit aligned with enough for two transfers */
  12657. + xfer_bytes_to_go = INTVAL (operands[2]) & ~(UNITS_PER_WORD * 2 - 1);
  12658. + word_mode = DImode;
  12659. + word_size = UNITS_PER_WORD * 2;
  12660. + last_bytes = INTVAL (operands[2]) & (UNITS_PER_WORD * 2 - 1);
  12661. + do_in_max = 4 * word_size;
  12662. +
  12663. + /* Cannot use 64-bit mode if it's too short! */
  12664. + gcc_assert (xfer_bytes_to_go >= 16);
  12665. + }
  12666. + else
  12667. + {
  12668. + /* Data not 64-bit aligned, used paired bursts so still 64-bit organised */
  12669. + xfer_bytes_to_go = INTVAL (operands[2]) & ~(UNITS_PER_WORD - 1);
  12670. + word_mode = SImode;
  12671. + word_size = UNITS_PER_WORD;
  12672. + last_bytes = INTVAL (operands[2]) & (UNITS_PER_WORD - 1);
  12673. + do_in_max = 5 * word_size;
  12674. +
  12675. + if ((xfer_bytes_to_go + last_bytes) > 64)
  12676. + return false;
  12677. + }
  12678. +
  12679. + gcc_assert (do_in_max > 0);
  12680. +
  12681. + dstoffset = srcoffset = 0;
  12682. +
  12683. + while (xfer_bytes_to_go > 0)
  12684. + {
  12685. + unsigned int first_regno;
  12686. +
  12687. + /* Burst loop, transfer upto 32 or 20 bytes each */
  12688. + do_in_bytes = xfer_bytes_to_go;
  12689. +
  12690. + /* On the input side bytes at the end count as an extra word */
  12691. + if (last_bytes != 0)
  12692. + do_in_bytes += word_size;
  12693. +
  12694. + if (do_in_bytes >= do_in_max * 2)
  12695. + {
  12696. + /* At least two full bursts left */
  12697. + do_in_bytes = do_in_max;
  12698. + }
  12699. + else if (do_in_bytes > do_in_max)
  12700. + {
  12701. + /* Don't leave a runt at the end */
  12702. + do_in_bytes |= (word_size * 2) - 1;
  12703. + do_in_bytes >>= 1;
  12704. + do_in_bytes += 1;
  12705. + }
  12706. +#if 0
  12707. + first_regno = D0_0_REG;
  12708. +#else
  12709. + first_regno = D0_2_REG;
  12710. + if (D0_7_REG - 2 * ((do_in_bytes / word_size)-1) < first_regno)
  12711. + first_regno = D0_7_REG - 2 * ((do_in_bytes / word_size)-1);
  12712. +#endif
  12713. +
  12714. + /* Load the data */
  12715. + emit_insn (metag_gen_load_multiple (first_regno, do_in_bytes / word_size,
  12716. + word_mode, src, true,
  12717. + srcbase, &srcoffset));
  12718. +
  12719. + if (xfer_bytes_to_go < (int)do_in_bytes)
  12720. + {
  12721. + /* Replace the rounded up size with the real extra size */
  12722. + do_in_bytes -= word_size;
  12723. + xfer_bytes_to_go = 0;
  12724. + }
  12725. + else
  12726. + {
  12727. + /* Reduce bytes to go */
  12728. + xfer_bytes_to_go -= do_in_bytes;
  12729. + }
  12730. +
  12731. + /* Store the data */
  12732. + if (do_in_bytes >= 2 * word_size)
  12733. + emit_insn (metag_gen_store_multiple (first_regno, do_in_bytes / word_size,
  12734. + word_mode, dst, true,
  12735. + dstbase, &dstoffset));
  12736. + else if (do_in_bytes >= word_size)
  12737. + {
  12738. + metag_emit_load_post_inc (dstbase, word_mode, dst,
  12739. + dstoffset, first_regno);
  12740. + dstoffset += word_size;
  12741. + }
  12742. + else
  12743. + gcc_unreachable ();
  12744. + }
  12745. +
  12746. + /* Are we finished? */
  12747. + if (last_bytes > 0)
  12748. + {
  12749. +#if 0
  12750. + unsigned int last_regno = D0_0_REG + 2 * (do_in_bytes / word_size);
  12751. +#else
  12752. + unsigned int last_regno = D0_2_REG + 2 * (do_in_bytes / word_size);
  12753. + if (D0_7_REG - 2 * (do_in_bytes / word_size) < D0_2_REG)
  12754. + last_regno -= D0_2_REG - (D0_7_REG - 2 * (do_in_bytes / word_size));
  12755. +#endif
  12756. +
  12757. + /* Here we handle and remaining 4-byte chunks left to xfer */
  12758. + if ((last_bytes & 4) != 0)
  12759. + {
  12760. + gcc_assert (word_size == UNITS_PER_WORD * 2);
  12761. + /* Store last 32-bit word and switch remainder into SImode */
  12762. +
  12763. + /* Generate write for bottom SImode subreg of last DImode register,
  12764. + Further manipulation needed on upper part of DImode register */
  12765. + metag_emit_load_post_inc (dstbase, SImode, dst,
  12766. + dstoffset, last_regno);
  12767. +
  12768. + dstoffset += 4;
  12769. +
  12770. + /* If we have any remaing 2-byte or 1-byte chunks left adjust dst */
  12771. + if ((last_bytes & 3) != 0)
  12772. + last_regno = last_regno + 1;
  12773. + }
  12774. +
  12775. + /* Here we handle any remaining 2-byte chunks left to xfer */
  12776. + if ((last_bytes & 2) != 0)
  12777. + {
  12778. + metag_emit_load_post_inc (dstbase, HImode, dst,
  12779. + dstoffset, last_regno);
  12780. +
  12781. + dstoffset += 2;
  12782. +
  12783. + /* If we have any remaing 1-byte chunks left adjust dst */
  12784. + if ((last_bytes & 1) != 0)
  12785. + {
  12786. + rtx tmp = gen_rtx_REG (SImode, last_regno);
  12787. +
  12788. + emit_insn (gen_lshrsi3 (tmp, tmp, GEN_INT (16)));
  12789. + }
  12790. + }
  12791. +
  12792. + /* Here we handle any remaining 1-byte chunks left to xfer */
  12793. + if ((last_bytes & 1) != 0)
  12794. + {
  12795. + metag_emit_load_post_inc (dstbase, QImode, dst,
  12796. + dstoffset, last_regno);
  12797. +
  12798. + dstoffset += 1;
  12799. + }
  12800. + }
  12801. +
  12802. + return true;
  12803. +}
  12804. +
  12805. +#if METAG_DEBUG_CCEXEC
  12806. +static const char *
  12807. +attr_cond_name (enum attr_cond attr)
  12808. +{
  12809. + switch (attr)
  12810. + {
  12811. + case COND_YES:
  12812. + return "yes";
  12813. + case COND_NO:
  12814. + return "no";
  12815. + default:
  12816. + break;
  12817. + }
  12818. +
  12819. + return "??";
  12820. +}
  12821. +
  12822. +static const char *
  12823. +attr_ccstate_name (enum attr_ccstate attr)
  12824. +{
  12825. + switch (attr)
  12826. + {
  12827. + case CCSTATE_XCC:
  12828. + return "xcc";
  12829. + case CCSTATE_SET:
  12830. + return "set";
  12831. + case CCSTATE_FASTSET:
  12832. + return "fastset";
  12833. + case CCSTATE_FASTFASTSET:
  12834. + return "fastfastset";
  12835. + case CCSTATE_CCX:
  12836. + return "ccx";
  12837. + case CCSTATE_NCC:
  12838. + return "ncc";
  12839. + default:
  12840. + break;
  12841. + }
  12842. +
  12843. + return "???";
  12844. +}
  12845. +
  12846. +static const char *
  12847. +attr_predicable_name (enum attr_predicable attr)
  12848. +{
  12849. + switch (attr)
  12850. + {
  12851. + case PREDICABLE_YES:
  12852. + return "yes";
  12853. + case PREDICABLE_NO:
  12854. + return "no";
  12855. + default:
  12856. + break;
  12857. + }
  12858. +
  12859. + return "??";
  12860. +}
  12861. +#endif
  12862. +
  12863. +
  12864. +/* The state of the fsm controlling condition codes are:
  12865. + 0: normal, do nothing special
  12866. + 1: make ASM_OUTPUT_OPCODE not output this instruction
  12867. + 2: make ASM_OUTPUT_OPCODE not output this instruction
  12868. + 3: make instructions conditional
  12869. + 4: make instructions conditional
  12870. +
  12871. + State transitions (state->state by whom under condition):
  12872. + 0 -> 1 final_prescan_insn if the `target' is a label
  12873. + 0 -> 2 final_prescan_insn if the `target' is an unconditional branch
  12874. + 1 -> 3 ASM_OUTPUT_OPCODE after not having output the conditional branch
  12875. + 2 -> 4 ASM_OUTPUT_OPCODE after not having output the conditional branch
  12876. + 3 -> 0 ASM_OUTPUT_INTERNAL_LABEL if the `target' label is reached
  12877. + (the target label has CODE_LABEL_NUMBER equal to metag_target_label).
  12878. + 4 -> 0 final_prescan_insn if the `target' unconditional branch is reached
  12879. + (the target insn is metag_target_insn).
  12880. +
  12881. + If the jump clobbers the conditions then we use states 2 and 4.
  12882. +
  12883. + A similar thing can be done with conditional return insns.
  12884. +
  12885. + XXX In case the `target' is an unconditional branch, this conditionalising
  12886. + of the instructions always reduces code size, but not always execution
  12887. + time. But then, I want to reduce the code size to somewhere near what
  12888. + /bin/cc produces. */
  12889. +
  12890. +void
  12891. +metag_final_prescan_insn (rtx insn)
  12892. +{
  12893. + /* BODY will hold the body of INSN. */
  12894. + rtx body = PATTERN (insn);
  12895. +
  12896. + /* This will be 1 if trying to repeat the trick, and things need to be
  12897. + reversed if it appears to fail. */
  12898. + int reverse = 0;
  12899. +
  12900. + /* START_INSN will hold the insn from where we start looking. This is the
  12901. + first insn after the following code_label if REVERSE is true. */
  12902. + rtx start_insn = insn;
  12903. +
  12904. + /* If in state 4, check if the target branch is reached, in order to
  12905. + change back to state 0. */
  12906. + if (metag_ccfsm_state == 4)
  12907. + {
  12908. + if (insn == metag_target_insn)
  12909. + {
  12910. + metag_target_insn = NULL_RTX;
  12911. + metag_ccfsm_state = 0;
  12912. + }
  12913. + return;
  12914. + }
  12915. +
  12916. + /* If in state 3, it is possible to repeat the trick, if this insn is an
  12917. + unconditional branch to a label, and immediately following this branch
  12918. + is the previous target label which is only used once, and the label this
  12919. + branch jumps to is not too far off. */
  12920. + if (metag_ccfsm_state == 3)
  12921. + {
  12922. + if (simplejump_p (insn))
  12923. + {
  12924. + start_insn = next_nonnote_insn (start_insn);
  12925. + if (BARRIER_P (start_insn))
  12926. + {
  12927. + /* XXX Isn't this always a barrier? */
  12928. + start_insn = next_nonnote_insn (start_insn);
  12929. + }
  12930. +
  12931. + if (GET_CODE (start_insn) == CODE_LABEL
  12932. + && CODE_LABEL_NUMBER (start_insn) == metag_target_label
  12933. + && LABEL_NUSES (start_insn) == 1)
  12934. + reverse = true;
  12935. + else
  12936. + return;
  12937. + }
  12938. + else
  12939. + return;
  12940. + }
  12941. +
  12942. + if (metag_ccfsm_state != 0 && !reverse)
  12943. + gcc_unreachable ();
  12944. +
  12945. + if (!JUMP_P (insn))
  12946. + return;
  12947. +
  12948. + /* This jump might be paralleled with a clobber of the condition codes
  12949. + the jump should always come first */
  12950. + if (GET_CODE (body) == PARALLEL && XVECLEN (body, 0) > 0)
  12951. + body = XVECEXP (body, 0, 0);
  12952. +
  12953. + /* If this jump uses the hardware loop counter, leave it alone */
  12954. + if (reg_mentioned_p (gen_rtx_REG (VOIDmode, TXRPT_REGNUM), body))
  12955. + return;
  12956. +
  12957. + /* If this is a conditional return then we don't want to know */
  12958. + if (GET_CODE (body) == SET && GET_CODE (SET_DEST (body)) == PC
  12959. + && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
  12960. + && (GET_CODE (XEXP (SET_SRC (body), 1)) == RETURN
  12961. + || GET_CODE (XEXP (SET_SRC (body), 2)) == RETURN))
  12962. + return;
  12963. +
  12964. + if (reverse
  12965. + || (GET_CODE (body) == SET && GET_CODE (SET_DEST (body)) == PC
  12966. + && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE))
  12967. + {
  12968. + int insns_skipped = 0;
  12969. + int fail = 0;
  12970. + int quit = false, succeed = false;
  12971. + /* Flag which part of the IF_THEN_ELSE is the LABEL_REF. */
  12972. + int then_not_else = true;
  12973. + rtx this_insn = start_insn;
  12974. + rtx label = NULL_RTX;
  12975. +
  12976. + /* Register the insn jumped to. */
  12977. + if (reverse)
  12978. + label = XEXP (SET_SRC (body), 0);
  12979. + else if (LABEL_REF_P (XEXP (SET_SRC (body), 1)))
  12980. + label = XEXP (XEXP (SET_SRC (body), 1), 0);
  12981. + else if (LABEL_REF_P (XEXP (SET_SRC (body), 2)))
  12982. + {
  12983. + label = XEXP (XEXP (SET_SRC (body), 2), 0);
  12984. + then_not_else = false;
  12985. + }
  12986. + else
  12987. + gcc_unreachable ();
  12988. +
  12989. +#if METAG_DEBUG_CCEXEC
  12990. + fprintf (stderr, "CE =====\n"); debug_rtx (insn);
  12991. +#endif
  12992. + /* See how many insns this branch skips, and what kind of insns. If all
  12993. + insns are okay, and the label or unconditional branch to the same
  12994. + label is not too far away, succeed. */
  12995. + while (!quit && !succeed && insns_skipped < metag_max_insns_skipped)
  12996. + {
  12997. + this_insn = next_nonnote_insn (this_insn);
  12998. + if (!this_insn)
  12999. + break;
  13000. +
  13001. + /* Only count recognised instructions others aren't relevant.*/
  13002. +
  13003. + if (INSN_P (this_insn) && INSN_CODE (this_insn) >= 0)
  13004. + insns_skipped++;
  13005. +
  13006. + switch (GET_CODE (this_insn))
  13007. + {
  13008. + case CODE_LABEL:
  13009. + /* Succeed if it is the target label, otherwise fail since
  13010. + control falls in from somewhere else. */
  13011. + if (this_insn == label)
  13012. + {
  13013. + if (fail == 0)
  13014. + {
  13015. + metag_ccfsm_state = 1;
  13016. + succeed = true;
  13017. +#if METAG_DEBUG_CCEXEC
  13018. + fprintf (stderr, "CE found label after %d successes\n", insns_skipped);
  13019. +#endif
  13020. + }
  13021. + else
  13022. + {
  13023. +#if METAG_DEBUG_CCEXEC
  13024. + fprintf (stderr, "CE found label after %d failures\n", fail);
  13025. +#endif
  13026. + quit = true;
  13027. + }
  13028. + }
  13029. + else
  13030. + {
  13031. +#if METAG_DEBUG_CCEXEC
  13032. + fprintf (stderr, "CE failed CODE_LABEL after %d insns\n", insns_skipped);
  13033. +#endif
  13034. + fail++;
  13035. + }
  13036. +
  13037. + break;
  13038. +
  13039. + case BARRIER:
  13040. + /* Succeed if the following insn is the target label.
  13041. + Otherwise fail.
  13042. + If return insns are used then the last insn in a function
  13043. + will be a barrier. */
  13044. + this_insn = next_nonnote_insn (this_insn);
  13045. + if (this_insn && this_insn == label)
  13046. + {
  13047. + if (fail == 0)
  13048. + {
  13049. + metag_ccfsm_state = 1;
  13050. + succeed = true;
  13051. +#if METAG_DEBUG_CCEXEC
  13052. + fprintf (stderr, "CE found label after %d successes\n", insns_skipped);
  13053. +#endif
  13054. + }
  13055. + else
  13056. + {
  13057. +#if METAG_DEBUG_CCEXEC
  13058. + fprintf (stderr, "CE found label after %d failures\n", fail);
  13059. +#endif
  13060. + quit = true;
  13061. + }
  13062. + }
  13063. + else
  13064. + {
  13065. +#if METAG_DEBUG_CCEXEC
  13066. + fprintf (stderr, "CE failed BARRIER after %d insns\n", insns_skipped);
  13067. +#endif
  13068. + fail++;
  13069. + }
  13070. +
  13071. + break;
  13072. +
  13073. + case CALL_INSN:
  13074. +#if 0
  13075. + if (!(GET_CODE (operands[?]) == REG
  13076. + && REGNO (operands[?]) != RETURN_POINTER_REGNUM))
  13077. +#endif
  13078. + {
  13079. +#if METAG_DEBUG_CCEXEC
  13080. + fprintf (stderr, "CE failed CALL_INSN after %d insns\n", insns_skipped);
  13081. + debug_rtx (this_insn);
  13082. +#endif
  13083. + fail++;
  13084. + }
  13085. + break;
  13086. +
  13087. + case JUMP_INSN:
  13088. + /* If this is an unconditional branch to the same label, succeed.
  13089. + If it is to another label, do nothing. If it is conditional,
  13090. + fail. */
  13091. + /* XXX Probably, the tests for SET and the PC are unnecessary. */
  13092. +
  13093. + {
  13094. + rtx scanbody = PATTERN (this_insn);
  13095. +
  13096. + if (GET_CODE (scanbody) == SET
  13097. + && GET_CODE (SET_DEST (scanbody)) == PC)
  13098. + {
  13099. + if (LABEL_REF_P (SET_SRC (scanbody))
  13100. + && XEXP (SET_SRC (scanbody), 0) == label && !reverse)
  13101. + {
  13102. + if (fail == 0)
  13103. + {
  13104. + metag_ccfsm_state = 2;
  13105. + succeed = true;
  13106. +#if METAG_DEBUG_CCEXEC
  13107. + fprintf (stderr, "CE found jump to target label after %d successes\n", insns_skipped);
  13108. +#endif
  13109. + }
  13110. + else
  13111. + {
  13112. +#if METAG_DEBUG_CCEXEC
  13113. + fprintf (stderr, "CE found uncond branch after %d failures\n", fail);
  13114. +#endif
  13115. + quit = true;
  13116. + }
  13117. + }
  13118. + else if (GET_CODE (SET_SRC (scanbody)) == IF_THEN_ELSE)
  13119. + {
  13120. +#if METAG_DEBUG_CCEXEC
  13121. + fprintf (stderr, "CE failed JUMP_INSN IF_THEN_ELSE after %d insn\n", insns_skipped);
  13122. + debug_rtx (this_insn);
  13123. +#endif
  13124. + fail++;
  13125. + }
  13126. + }
  13127. + else if (GET_CODE (scanbody) == RETURN)
  13128. + {
  13129. + if (!metag_cheap_return (true))
  13130. + {
  13131. +#if METAG_DEBUG_CCEXEC
  13132. + fprintf (stderr, "CE failed JUMP_INSN RETURN (not cheap) after %d insn\n", insns_skipped);
  13133. + debug_rtx (this_insn);
  13134. +#endif
  13135. + fail++;
  13136. + }
  13137. + }
  13138. + else
  13139. + {
  13140. +#if METAG_DEBUG_CCEXEC
  13141. + fprintf (stderr, "CE failed JUMP_INSN not recognised after %d insn\n", insns_skipped);
  13142. + debug_rtx (this_insn);
  13143. +#endif
  13144. + fail++;
  13145. + }
  13146. + }
  13147. +
  13148. + break;
  13149. +
  13150. + case INSN:
  13151. + if (INSN_CODE (this_insn) >= 0)
  13152. + {
  13153. + enum attr_cond cond_attr = get_attr_cond (this_insn);
  13154. + enum attr_predicable predicable_attr = get_attr_predicable (this_insn);
  13155. + enum attr_ccstate ccstate_attr = get_attr_ccstate (this_insn);
  13156. +
  13157. + /* A predicated instruction can't be COND_EXEC unless
  13158. + the predication condition matches the condexec
  13159. + condition. At present we ALWAYS reject predicated
  13160. + instructions which is safe but sub-optimal. */
  13161. + if (predicable_attr == PREDICABLE_YES && GET_CODE (PATTERN (this_insn)) == COND_EXEC)
  13162. + {
  13163. +#if METAG_DEBUG_CCEXEC
  13164. + fprintf (stderr, "CE failed INSN PREDICABLE=%s and COND_EXEC after %d insns\n",
  13165. + attr_predicable_name (predicable_attr),
  13166. + insns_skipped);
  13167. + debug_rtx (this_insn);
  13168. +#endif
  13169. + fail++;
  13170. + }
  13171. +
  13172. + /* Only insns which don't modify CC can be cond-exec */
  13173. + if (cond_attr != COND_YES || ccstate_attr != CCSTATE_NCC)
  13174. + {
  13175. +#if METAG_DEBUG_CCEXEC
  13176. + fprintf (stderr, "CE failed INSN COND=%s CSTATE=%s after %d insns\n",
  13177. + attr_cond_name (cond_attr),
  13178. + attr_ccstate_name (ccstate_attr),
  13179. + insns_skipped);
  13180. + debug_rtx (this_insn);
  13181. +#endif
  13182. + fail++;
  13183. + }
  13184. + }
  13185. + else if (asm_noperands (PATTERN (this_insn)) >= 0)
  13186. + {
  13187. +#if METAG_DEBUG_CCEXEC
  13188. + fprintf (stderr, "CE failed ASM_OPERANDS after %d insns\n",
  13189. + insns_skipped);
  13190. + debug_rtx (this_insn);
  13191. +#endif
  13192. + fail++;
  13193. + }
  13194. + else if (GET_CODE (PATTERN (this_insn)) != USE)
  13195. + {
  13196. + /* Anything else not recognised with the exception of
  13197. + an USE (typically an USE of return register) fails
  13198. + conditional execution. */
  13199. +#if METAG_DEBUG_CCEXEC
  13200. + fprintf (stderr, "CE failed unrecognised after %d insns\n",
  13201. + insns_skipped);
  13202. + debug_rtx (this_insn);
  13203. +#endif
  13204. + fail++;
  13205. + }
  13206. +
  13207. + break;
  13208. +
  13209. + default:
  13210. + break;
  13211. + }
  13212. + }
  13213. +
  13214. + if (succeed)
  13215. + {
  13216. + if (metag_ccfsm_state == 1 || reverse)
  13217. + metag_target_label = CODE_LABEL_NUMBER (label);
  13218. + else if (metag_ccfsm_state == 2)
  13219. + {
  13220. + while (this_insn && GET_CODE (PATTERN (this_insn)) == USE)
  13221. + {
  13222. + this_insn = next_nonnote_insn (this_insn);
  13223. + if (this_insn
  13224. + && (BARRIER_P (this_insn)
  13225. + || GET_CODE (this_insn) == CODE_LABEL))
  13226. + gcc_unreachable ();
  13227. + }
  13228. +
  13229. + if (!this_insn)
  13230. + {
  13231. + /* Oh, dear! we ran off the end.. give up */
  13232. + if (INSN_CODE (insn) >= 0)
  13233. + {
  13234. + recog (PATTERN (insn), insn, NULL);
  13235. + cleanup_subreg_operands (insn);
  13236. + }
  13237. +
  13238. + metag_ccfsm_state = 0;
  13239. + metag_target_insn = NULL_RTX;
  13240. + return;
  13241. + }
  13242. +
  13243. + metag_target_insn = this_insn;
  13244. + }
  13245. + else
  13246. + gcc_unreachable ();
  13247. +
  13248. + /* If REVERSE is true, METAG_CURRENT_CC needs to be inverted
  13249. + * from what it was. */
  13250. + if (!reverse)
  13251. + metag_current_cc = get_metag_cc (XEXP (SET_SRC (body), 0));
  13252. +
  13253. + if (reverse || then_not_else)
  13254. + metag_current_cc = metag_inv_cc [metag_current_cc];
  13255. + }
  13256. +
  13257. + if (INSN_CODE (insn) >= 0)
  13258. + {
  13259. + /* restore recog_operand (getting the attributes of other insns can
  13260. + destroy this array, but final.c assumes that it remains intact
  13261. + across this call; since the insn has been recognized already we
  13262. + call recog direct). */
  13263. + recog (PATTERN (insn), insn, NULL);
  13264. + cleanup_subreg_operands (insn);
  13265. + }
  13266. + }
  13267. +}
  13268. +
  13269. +bool
  13270. +metag_cond_exec_p (void)
  13271. +{
  13272. + return (metag_ccfsm_state == 3 || metag_ccfsm_state == 4);
  13273. +}
  13274. +
  13275. +void
  13276. +metag_print_cc_if_conditional (FILE *stream)
  13277. +{
  13278. + if (metag_cond_exec_p ())
  13279. + {
  13280. + gcc_assert (current_insn_predicate == NULL_RTX);
  13281. + fputs (metag_cc_names[metag_current_cc], stream);
  13282. + }
  13283. + else if (current_insn_predicate != NULL_RTX)
  13284. + fputs (metag_cc_names[get_metag_cc (current_insn_predicate)], stream);
  13285. +
  13286. + return;
  13287. +}
  13288. +
  13289. +bool
  13290. +metag_consume_branch (rtx insn ATTRIBUTE_UNUSED)
  13291. +{
  13292. + if (metag_ccfsm_state == 1 || metag_ccfsm_state == 2)
  13293. + {
  13294. + metag_ccfsm_state += 2;
  13295. + return true;
  13296. + }
  13297. +
  13298. + return false;
  13299. +}
  13300. +
  13301. +
  13302. +/* Output to FILE code to call mcount. */
  13303. +void
  13304. +metag_function_profiler (FILE *file)
  13305. +{
  13306. + if (1 || !TARGET_METAC_1_1)
  13307. + {
  13308. + fprintf (file, "\tMOVT\t%s, #HI(_mcount_wrapper)\n",
  13309. + reg_names[TEMP_D0FRT_REGNUM]);
  13310. + fprintf (file, "\tCALL\t%s, #LO(_mcount_wrapper)\n",
  13311. + reg_names[TEMP_D0FRT_REGNUM]);
  13312. + }
  13313. + else
  13314. + fprintf (file, "\tCALLR\t%s, _mcount_wrapper\n",
  13315. + reg_names[TEMP_D0FRT_REGNUM]);
  13316. +}
  13317. +
  13318. +static bool
  13319. +metag_same_reg_p (rtx reg1, rtx reg2, bool strict)
  13320. +{
  13321. + unsigned int r1 = REGNO (reg1);
  13322. + unsigned int r2 = REGNO (reg2);
  13323. +
  13324. + if (IS_PSEUDO_REGNO (r1) && reg_renumber != NULL)
  13325. + r1 = reg_renumber[r1];
  13326. +
  13327. + if (IS_PSEUDO_REGNO (r2) && reg_renumber != NULL)
  13328. + r2 = reg_renumber[r2];
  13329. +
  13330. + return strict ? IS_HARD_OR_VIRT_REGNO (r1) && IS_HARD_OR_VIRT_REGNO (r2) && r1 == r2
  13331. + : r1 != INVALID_REGNUM && r1 != INVALID_REGNUM && r1 == r2;
  13332. +}
  13333. +
  13334. +static bool
  13335. +metag_regs_same_regclass_p (rtx reg1, rtx reg2, bool strict)
  13336. +{
  13337. + unsigned int r1 = REGNO (reg1);
  13338. + unsigned int r2 = REGNO (reg2);
  13339. + enum reg_class class1;
  13340. + enum reg_class class2;
  13341. +
  13342. + if (IS_PSEUDO_REGNO (r1) && reg_renumber != NULL)
  13343. + r1 = reg_renumber[r1];
  13344. +
  13345. + if (IS_PSEUDO_REGNO (r2) && reg_renumber != NULL)
  13346. + r2 = reg_renumber[r2];
  13347. +
  13348. + class1 = METAG_REGNO_REG_CLASS (r1);
  13349. + class2 = METAG_REGNO_REG_CLASS (r2);
  13350. +
  13351. + return strict ? class1 != NO_REGS && class2 != NO_REGS && class1 == class2
  13352. + : class1 != NO_REGS && class2 != NO_REGS && class1 == class2;
  13353. +}
  13354. +
  13355. +bool
  13356. +metag_same_regclass_p (rtx reg1, rtx reg2)
  13357. +{
  13358. + return metag_regs_same_regclass_p (reg1, reg2, true);
  13359. +}
  13360. +
  13361. +/* Return true iff the registers are in the same function unit
  13362. + (i.e. D0, D1, A0, A1, CTRL). */
  13363. +
  13364. +bool
  13365. +metag_regno_same_unit_p (unsigned int regno1, unsigned int regno2)
  13366. +{
  13367. + enum reg_class class1 = METAG_REGNO_REG_CLASS (regno1);
  13368. + enum reg_class class2 = METAG_REGNO_REG_CLASS (regno2);
  13369. +
  13370. + return class1 != NO_REGS && class2 != NO_REGS && class1 == class2;
  13371. +}
  13372. +
  13373. +/* (post_modify (REG ...)
  13374. + (plus (REG ...)
  13375. + (REG ...)))
  13376. + or
  13377. +
  13378. + (post_modify (REG ...)
  13379. + (plus (REG ...)
  13380. + (CONST_INT ...)))
  13381. +*/
  13382. +bool
  13383. +metag_legitimate_modify_p (rtx addr, enum machine_mode mode, bool strict)
  13384. +{
  13385. + rtx op0 = XEXP (addr, 0);
  13386. + rtx op1 = XEXP (addr, 1);
  13387. + rtx op2;
  13388. + rtx op3;
  13389. +
  13390. + if (GET_CODE (op1) != PLUS)
  13391. + return false;
  13392. +
  13393. + if (!METAG_LEGITIMATE_REG_P (op0, strict))
  13394. + return false;
  13395. +
  13396. + op2 = XEXP (op1, 0);
  13397. + op3 = XEXP (op1, 1);
  13398. + if (!METAG_LEGITIMATE_REG_P (op2, strict))
  13399. + return false;
  13400. +
  13401. + if (!metag_same_reg_p (op0, op2, strict))
  13402. + return false;
  13403. +
  13404. + if (REG_P (op3))
  13405. + return METAG_LEGITIMATE_TWIN_P (op2, op3, mode, strict);
  13406. +
  13407. + if (CONST_INT_P (op3) && metag_offset6_mode (op3, mode))
  13408. + return true;
  13409. +
  13410. + return false;
  13411. +}
  13412. +
  13413. +long
  13414. +metag_const_double_to_hp (rtx op, bool *inexact)
  13415. +{
  13416. + REAL_VALUE_TYPE rv;
  13417. + long half = 0;
  13418. + bool dummy_inexact;
  13419. +
  13420. + if (!inexact)
  13421. + inexact = &dummy_inexact;
  13422. +
  13423. + REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
  13424. +
  13425. + *inexact = false;
  13426. +
  13427. + if (GET_MODE(op) == SFmode)
  13428. + {
  13429. + long tgsingle;
  13430. + bool tgsgn;
  13431. + long tgexp;
  13432. + long tgman;
  13433. +
  13434. + REAL_VALUE_TO_TARGET_SINGLE (rv, tgsingle);
  13435. +
  13436. + /* Split the parts */
  13437. + tgsgn = ((tgsingle & 0x80000000ul) != 0);
  13438. + tgexp = (tgsingle & 0x7F800000) >> 23;
  13439. + tgman = tgsingle & 0x007FFFFF;
  13440. +
  13441. + /* If the fractional part would need rounding, raise inexact */
  13442. + if (tgman & 0x00001FFF)
  13443. + *inexact = true;
  13444. +
  13445. + /* Convert to HF (truncate) */
  13446. +
  13447. + /* Exp == MAX we must preserve the Inf or NaN */
  13448. + if (tgexp == 0xFF)
  13449. + half = tgman ? 0x7C01 : 0x7C00;
  13450. + /* Exp == 0 is special we must not bias adjust it */
  13451. + else if (tgexp == 0x00)
  13452. + half = tgman >> (23 - 10);
  13453. + else
  13454. + {
  13455. + tgexp -= 127; /* Remove SF bias */
  13456. + tgexp += 15; /* Add HF bias */
  13457. + tgman >>= 23 - 10;
  13458. +
  13459. + if (tgexp >= 32)
  13460. + {
  13461. + *inexact = true;
  13462. + half = 0x7C00; /* Overflow to inf */
  13463. + }
  13464. + else if (tgexp < 0)
  13465. + {
  13466. + *inexact = true;
  13467. + half = 0x0000; /* Underflow to 0 */
  13468. + }
  13469. + else
  13470. + half = (tgexp & 0x01F) << 10
  13471. + | (tgman & 0x3FF);
  13472. + }
  13473. +
  13474. + /* Copy the sign */
  13475. + if (tgsgn)
  13476. + half |= 0x8000;
  13477. + }
  13478. + else if (GET_MODE(op) == DFmode)
  13479. + {
  13480. + long tgdouble[2];
  13481. + bool tgsgn;
  13482. + long tgexp;
  13483. + long tgman[2];
  13484. +
  13485. + REAL_VALUE_TO_TARGET_DOUBLE (rv, tgdouble);
  13486. +
  13487. + /* Split the parts */
  13488. + tgsgn = ((tgdouble[1] & 0x80000000ul) != 0);
  13489. + tgexp = (tgdouble[1] & 0x7FF00000) >> (52-32);
  13490. + tgman[1] = (tgdouble[1] & 0x000FFFFF);
  13491. + tgman[0] = tgdouble[0];
  13492. +
  13493. + /* If the fractional part would need rounding, reject */
  13494. + if (tgman[1] & 0x0000FFFF || tgman[0])
  13495. + *inexact = true;
  13496. +
  13497. + /* Convert to HF (truncate) */
  13498. +
  13499. + /* Exp == MAX we must preserve the Inf or NaN */
  13500. + if (tgexp == 0x7FF)
  13501. + half = tgman[1] || tgman[0] ? 0x7C01 : 0x7C00;
  13502. + /* Exp == 0 is special we must not bias adjust it */
  13503. + else if (tgexp == 0x00)
  13504. + half = tgman[1] >> (52 - 10 - 32);
  13505. + else
  13506. + {
  13507. + tgexp -= 1023; /* Remove SF bias */
  13508. + tgexp += 15; /* Add HF bias */
  13509. + tgman[0] = tgman[1] >> (52 - 10 - 32);
  13510. + tgman[1] = 0;
  13511. +
  13512. + if (tgexp >= 32)
  13513. + {
  13514. + *inexact = true;
  13515. + half = 0x7C00; /* Overflow to inf */
  13516. + }
  13517. + else if (tgexp < 0)
  13518. + {
  13519. + *inexact = true;
  13520. + half = 0x0000; /* Underflow to 0 */
  13521. + }
  13522. + else
  13523. + half = (tgexp & 0x01F) << 10
  13524. + | (tgman[0] & 0x3FF);
  13525. + }
  13526. +
  13527. + /* Copy the sign */
  13528. + if (tgsgn)
  13529. + half |= 0x8000;
  13530. + }
  13531. +
  13532. + return half;
  13533. +}
  13534. +
  13535. +void
  13536. +metag_print_operand (FILE * file, rtx op, enum rtx_code code)
  13537. +{
  13538. + if (code == '?')
  13539. + metag_print_cc_if_conditional (file);
  13540. + else if (code == '@')
  13541. + fputs (ASM_COMMENT_START, file);
  13542. + else if (code == 'z')
  13543. + fputs (metag_cc_names[get_metag_cc (op)], file);
  13544. + else if (code == 'Z')
  13545. + fputs (metag_cc_names[metag_inv_cc [get_metag_cc (op)]], file);
  13546. + else if (code == 'h')
  13547. + {
  13548. + if (GET_CODE (op) == CONST_VECTOR)
  13549. + {
  13550. + gcc_assert (GET_MODE_INNER (GET_MODE (op)) == SFmode);
  13551. + gcc_assert (rtx_equal_p (CONST_VECTOR_ELT (op, 0),
  13552. + CONST_VECTOR_ELT (op, 1)));
  13553. + op = CONST_VECTOR_ELT (op, 0);
  13554. + }
  13555. + fprintf (file, "0x%04lX", metag_const_double_to_hp (op, NULL));
  13556. + }
  13557. + else if (REG_P (op))
  13558. + {
  13559. + if (code == 't')
  13560. + fputs (reg_names[REGNO (op) + 1], file);
  13561. + else
  13562. + fputs (reg_names[REGNO (op)], file);
  13563. + }
  13564. + else
  13565. + {
  13566. + if (MEM_P (op))
  13567. + {
  13568. + if (SYMBOL_REF_P (XEXP (op, 0)))
  13569. + {
  13570. + /* Abort if we're about to generate #OG addressing. */
  13571. + debug_rtx (op);
  13572. + gcc_unreachable ();
  13573. + }
  13574. + else
  13575. + output_address (op);
  13576. + }
  13577. + else
  13578. + {
  13579. + if (CONST_DOUBLE_P (op) && GET_MODE (op) == SFmode)
  13580. + {
  13581. + long value = metag_const_double_sfmode (op);
  13582. +
  13583. + if (code != 'c')
  13584. + fputc ('#', file);
  13585. + fprintf (file, "0x%08lx", value);
  13586. + }
  13587. + else
  13588. + {
  13589. + if (code != 'c')
  13590. + {
  13591. + rtx itemp = op;
  13592. +
  13593. + fputc ('#', file);
  13594. + if (CONST_INT_P (op)
  13595. + && (INTVAL (op) < -32768 || INTVAL (op) > 0x0000FFFF))
  13596. + itemp = GEN_INT (((INTVAL (op)) >> 16) & 0x0000FFFF);
  13597. +
  13598. + output_addr_const (file, itemp);
  13599. + }
  13600. + else if (CONST_INT_P (op)
  13601. + && (INTVAL (op) < -32768 || INTVAL (op) > 0x0000FFFF))
  13602. + fprintf (file, "0x%08lx", (long)INTVAL (op));
  13603. + else
  13604. + output_addr_const (file, op);
  13605. + }
  13606. + }
  13607. + }
  13608. +}
  13609. +
  13610. +static void
  13611. +metag_output_pic_addr_const (FILE *file, rtx addr)
  13612. +{
  13613. + output_addr_const (file, XVECEXP (addr, 0, 0));
  13614. + switch (XINT (addr, 1))
  13615. + {
  13616. + case UNSPEC_GOT:
  13617. + fputs ("@GOT", file);
  13618. + break;
  13619. + case UNSPEC_GOTOFF:
  13620. + fputs ("@GOTOFF", file);
  13621. + break;
  13622. + case UNSPEC_PLT:
  13623. + fputs ("@PLT", file);
  13624. + break;
  13625. + default:
  13626. + metag_abort (addr);
  13627. + break;
  13628. + }
  13629. +}
  13630. +
  13631. +void
  13632. +metag_print_operand_address (FILE *file, rtx op)
  13633. +{
  13634. + rtx addr = MEM_P (op) ? XEXP (op, 0) : op;
  13635. + rtx offset;
  13636. + rtx reg;
  13637. + int inc;
  13638. +
  13639. + switch (GET_CODE (addr))
  13640. + {
  13641. + case SYMBOL_REF:
  13642. + /* Abort if we're about to generate #OG addressing. */
  13643. + gcc_unreachable ();
  13644. + break;
  13645. + case REG:
  13646. + fprintf (file, "[%s]", reg_names[REGNO (addr)]);
  13647. + break;
  13648. + case PRE_INC:
  13649. + reg = XEXP (addr, 0);
  13650. + inc = GET_MODE_SIZE (GET_MODE (op));
  13651. + fprintf (file, "[%s ++#%d]", reg_names[REGNO (reg)], inc);
  13652. + break;
  13653. + case POST_INC:
  13654. + reg = XEXP (addr, 0);
  13655. + inc = GET_MODE_SIZE (GET_MODE (op));
  13656. + fprintf (file, "[%s+#%d++]", reg_names[REGNO (reg)], inc);
  13657. + break;
  13658. + case PRE_DEC:
  13659. + reg = XEXP (addr, 0);
  13660. + inc = GET_MODE_SIZE (GET_MODE (op));
  13661. + fprintf (file, "[%s ++#(-%d)]", reg_names[REGNO (reg)], inc);
  13662. + break;
  13663. + case POST_DEC:
  13664. + reg = XEXP (addr, 0);
  13665. + inc = GET_MODE_SIZE (GET_MODE (op));
  13666. + fprintf (file, "[%s+#(-%d)++]", reg_names[REGNO (reg)], inc);
  13667. + break;
  13668. + case PRE_MODIFY:
  13669. + reg = XEXP (addr, 0);
  13670. + if (GET_CODE (XEXP (addr, 1)) != PLUS)
  13671. + metag_abort (op);
  13672. + else
  13673. + {
  13674. + rtx op0 = XEXP (XEXP (addr, 1), 0);
  13675. +
  13676. + if (!REG_P (op0))
  13677. + metag_abort (op);
  13678. + else if (REGNO (reg) != REGNO (op0))
  13679. + metag_abort (op);
  13680. + else
  13681. + {
  13682. + rtx op1 = XEXP (XEXP (addr, 1), 1);
  13683. +
  13684. + if (REG_P (op1))
  13685. + fprintf (file, "[%s++%s]",
  13686. + reg_names[REGNO (op0)], reg_names[REGNO (op1)]);
  13687. + else if (CONST_INT_P (op1))
  13688. + fprintf (file, "[%s++#(%ld)]",
  13689. + reg_names[REGNO (op0)], INTVAL (op1));
  13690. + else
  13691. + metag_abort (op);
  13692. + }
  13693. + }
  13694. + break;
  13695. + case POST_MODIFY:
  13696. + reg = XEXP (addr, 0);
  13697. + if (GET_CODE (XEXP (addr, 1)) != PLUS)
  13698. + metag_abort (op);
  13699. + else
  13700. + {
  13701. + rtx op0 = XEXP (XEXP (addr, 1), 0);
  13702. +
  13703. + if (!REG_P (op0))
  13704. + metag_abort (op);
  13705. + else if (REGNO (reg) != REGNO (op0))
  13706. + metag_abort (op);
  13707. + else
  13708. + {
  13709. + rtx op1 = XEXP (XEXP (addr, 1), 1);
  13710. +
  13711. + if (REG_P (op1))
  13712. + fprintf (file, "[%s+%s++]",
  13713. + reg_names[REGNO (op0)], reg_names[REGNO (op1)]);
  13714. + else if (CONST_INT_P (op1))
  13715. + fprintf (file, "[%s+#(%ld)++]",
  13716. + reg_names[REGNO (op0)], INTVAL (op1));
  13717. + else
  13718. + metag_abort (op);
  13719. + }
  13720. + }
  13721. + break;
  13722. + case PLUS:
  13723. + reg = XEXP (addr, 0);
  13724. + if (CONST_INT_P (reg))
  13725. + {
  13726. + offset = reg;
  13727. + reg = XEXP (addr, 1);
  13728. + }
  13729. + else
  13730. + offset = XEXP (addr, 1);
  13731. +
  13732. + if (!REG_P (reg))
  13733. + metag_abort (addr);
  13734. +
  13735. + if (REG_P (offset))
  13736. + fprintf (file, "[%s + %s]",
  13737. + reg_names[REGNO (reg)], reg_names[REGNO (offset)]);
  13738. + else if (CONST_INT_P (offset))
  13739. + fprintf (file, "[%s + #%ld]", reg_names[REGNO (reg)], INTVAL (offset));
  13740. + else if (METAG_FLAG_PIC
  13741. + && reg == pic_offset_table_rtx
  13742. + && GET_CODE (offset) == CONST
  13743. + && GET_CODE (XEXP (offset, 0)) == UNSPEC
  13744. + && XVECLEN (XEXP (offset, 0), 0) == 1
  13745. + && (XINT (XEXP (offset, 0), 1) == UNSPEC_GOT
  13746. + || XINT (XEXP (offset, 0), 1) == UNSPEC_PLT))
  13747. + {
  13748. + fprintf (file, "[%s + #(", reg_names[REGNO (reg)]);
  13749. + metag_output_pic_addr_const (file, XEXP (offset, 0));
  13750. + fputs (")]", file);
  13751. + }
  13752. + else
  13753. + metag_abort (addr);
  13754. + break;
  13755. + default:
  13756. + if (CONSTANT_ADDRESS_P (addr))
  13757. + output_addr_const (file, addr);
  13758. + else
  13759. + metag_abort (addr);
  13760. + break;
  13761. + }
  13762. +}
  13763. +
  13764. +int
  13765. +metag_arg_partial_bytes (CUMULATIVE_ARGS * cum, enum machine_mode mode, tree type, bool named)
  13766. +{
  13767. + unsigned int acum;
  13768. + unsigned int aarg;
  13769. + unsigned int nbytes;
  13770. +
  13771. + /* variadic arguments a.k.a named are ALWAYS passed on the stack */
  13772. +
  13773. + if (!named)
  13774. + return 0;
  13775. +
  13776. + acum = ROUND_ADVANCE_CUM (cum->narg, mode, type);
  13777. + aarg = ROUND_ADVANCE_ARG (mode, type);
  13778. +
  13779. + nbytes = ((acum < MAX_METAG_PARM_BYTES && MAX_METAG_PARM_BYTES < (acum + aarg))
  13780. + ? (MAX_METAG_PARM_BYTES - acum)
  13781. + : 0);
  13782. +
  13783. + if (cum->partial == 0)
  13784. + {
  13785. + if (nbytes > 0)
  13786. + {
  13787. + int size = METAG_ARG_SIZE (mode, type);
  13788. + int nstack = size - nbytes;
  13789. +
  13790. + gcc_assert ((nstack & (STACK_BOUNDARY_BYTES - 1)) == 0);
  13791. + }
  13792. +
  13793. + cum->partial = nbytes;
  13794. + }
  13795. + else
  13796. + gcc_assert (nbytes == 0);
  13797. +
  13798. + return nbytes;
  13799. +}
  13800. +
  13801. +bool
  13802. +metag_pass_by_reference (CUMULATIVE_ARGS * cum ATTRIBUTE_UNUSED,
  13803. + enum machine_mode mode ATTRIBUTE_UNUSED,
  13804. + tree type ATTRIBUTE_UNUSED,
  13805. + bool named ATTRIBUTE_UNUSED)
  13806. +{
  13807. + return false;
  13808. +}
  13809. +
  13810. +static bool
  13811. +metag_pass_in_reg (CUMULATIVE_ARGS * cum,
  13812. + enum machine_mode mode,
  13813. + tree type,
  13814. + bool named ATTRIBUTE_UNUSED)
  13815. +{
  13816. + int rcum;
  13817. +
  13818. + if (!named)
  13819. + return false;
  13820. +
  13821. + if (cum->narg >= MAX_METAG_PARM_BYTES)
  13822. + return false;
  13823. +
  13824. + rcum = ROUND_ADVANCE_CUM (cum->narg, mode, type);
  13825. + if (rcum >= MAX_METAG_PARM_BYTES)
  13826. + return false;
  13827. +
  13828. + return true;
  13829. +}
  13830. +
  13831. +bool
  13832. +metag_must_pass_in_stack (enum machine_mode mode ATTRIBUTE_UNUSED,
  13833. + tree type ATTRIBUTE_UNUSED)
  13834. +{
  13835. + return false;
  13836. +}
  13837. +
  13838. +rtx
  13839. +metag_function_arg (CUMULATIVE_ARGS * cum, enum machine_mode mode, tree type, bool named)
  13840. +{
  13841. + bool pass_in_reg = metag_pass_in_reg (cum, mode, type, named);
  13842. + int reg;
  13843. +
  13844. + if (!pass_in_reg)
  13845. + return NULL_RTX;
  13846. +
  13847. + reg = CALCULATE_REG (MAX_METAG_PARM_REGNUM, cum->narg, mode, type);
  13848. + if (reg < MIN_METAG_PARM_REGNUM)
  13849. + reg = MIN_METAG_PARM_REGNUM;
  13850. +
  13851. + return gen_rtx_REG (mode, reg);
  13852. +}
  13853. +
  13854. +void
  13855. +metag_function_arg_advance (CUMULATIVE_ARGS * cum, enum machine_mode mode, tree type, bool named ATTRIBUTE_UNUSED)
  13856. +{
  13857. + cum->narg = ROUND_ADVANCE_CUM (cum->narg, mode, type) + ROUND_ADVANCE_ARG (mode, type);
  13858. + return;
  13859. +}
  13860. +
  13861. +/* Define the offset between two registers, one to be eliminated,
  13862. + and the other its replacement, at the start of a routine.
  13863. +
  13864. + To kick things off we work out OFFSET as the size of the frame save
  13865. + area. Then we need to apply the following-
  13866. +
  13867. + ARG_POINTER = STACK_POINTER - (PRETEND + SAVE + PIC_SAVE + LOCAL + OUT_GOING)
  13868. + ARG_POINTER = HARD_FRAME_POINTER - (PRETEND )
  13869. + FRAME_POINTER = STACK_POINTER - ( + SAVE + PIC_SAVE + LOCAL + OUT_GOING)
  13870. + FRAME_POINTER = HARD_FRAME_POINTER + ( + SAVE + PIC_SAVE )
  13871. + */
  13872. +
  13873. +int
  13874. +metag_initial_elimination_offset (int from, int to)
  13875. +{
  13876. + /* This section of code and output_fn_prologue/epilogue
  13877. + * MUST agree on how the stack is going to be layedout.
  13878. + * Any discrepancy will result in wrong code being
  13879. + * generated.
  13880. + */
  13881. +
  13882. + HOST_WIDE_INT out_local_size = get_frame_size ();
  13883. + bool non_leaf = metag_non_leaf_function_p ();
  13884. + unsigned int savesize_gp = 0;
  13885. + unsigned int savesize_eh = 0;
  13886. + unsigned int FP_SP_offset = 0;
  13887. + unsigned int pic_save_size = 0;
  13888. + unsigned int pretend_size = ALIGN_ON_STACK_BOUNDARY (current_function_pretend_args_size);
  13889. + unsigned int extras_gp = 0;
  13890. + unsigned int extras_eh = 0;
  13891. + unsigned int ech_ctx = 0;
  13892. + unsigned int pretend_regs;
  13893. + int delta;
  13894. + bool loads_pic_register;
  13895. +
  13896. + if (pretend_size != 0)
  13897. + {
  13898. + /* Determine # register pairs needed for pretend args. */
  13899. + pretend_regs = pretend_size / UNITS_PER_WORD;
  13900. + }
  13901. + else
  13902. + pretend_regs = 0;
  13903. +
  13904. + out_local_size = ALIGN_ON_STACK_BOUNDARY (out_local_size + current_function_outgoing_args_size);
  13905. +
  13906. + /* Make pretend regs into the first non-varargs register number */
  13907. + pretend_regs += MIN_METAG_PARM_REGNUM;
  13908. +
  13909. + {
  13910. + unsigned int regno;
  13911. +
  13912. + for (regno = MIN_METAG_PARM_REGNUM;
  13913. + regno <= MAX_METAG_CSAVE_REGNUM;
  13914. + regno += 2)
  13915. + {
  13916. + if (regno < pretend_regs
  13917. + || (!call_used_regs[regno]
  13918. + && (df_regs_ever_live_p (regno + 0) || df_regs_ever_live_p (regno + 1))))
  13919. + {
  13920. + extras_gp |= REGNO_BIT (regno);
  13921. + savesize_gp += UNITS_PER_WORD * 2;
  13922. +
  13923. + if (regno >= MIN_METAG_CSAVE_REGNUM)
  13924. + FP_SP_offset += UNITS_PER_WORD * 2;
  13925. + }
  13926. + }
  13927. + }
  13928. +
  13929. + /* Adjust the saved registers for ECH support */
  13930. + ech_ctx = metag_adjust_savesize_ech (&savesize_gp, &extras_gp, &FP_SP_offset);
  13931. +
  13932. + if (current_function_calls_eh_return)
  13933. + {
  13934. + unsigned int n;
  13935. +
  13936. + for (n = 0; n < NUM_EH_RETURN_DATA_REGS; n++)
  13937. + {
  13938. + unsigned int regno = EH_RETURN_DATA_REGNO (n);
  13939. +
  13940. + if (regno != INVALID_REGNUM)
  13941. + {
  13942. + unsigned int regbit = REGNO_BIT (regno);
  13943. +
  13944. + if ((extras_eh & regbit) == 0)
  13945. + {
  13946. + extras_eh |= regbit;
  13947. + savesize_eh += UNITS_PER_WORD * 2;
  13948. + FP_SP_offset += UNITS_PER_WORD * 2;
  13949. + }
  13950. + }
  13951. + }
  13952. + }
  13953. +
  13954. + if (frame_pointer_needed || non_leaf)
  13955. + {
  13956. + savesize_gp += UNITS_PER_WORD * 2, FP_SP_offset += UNITS_PER_WORD * 2;
  13957. +
  13958. + if (non_leaf)
  13959. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  13960. +
  13961. + if (frame_pointer_needed)
  13962. + extras_gp |= REGNO_BIT (TEMP_D0FRT_REGNUM);
  13963. + }
  13964. + else if (df_regs_ever_live_p (RETURN_POINTER_REGNUM))
  13965. + {
  13966. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  13967. +
  13968. + /* Have to do at least one pop */
  13969. + savesize_gp += UNITS_PER_WORD * 2;
  13970. + }
  13971. +
  13972. + loads_pic_register = METAG_CURRENT_FUNCTION_LOADS_PIC_REGISTER ();
  13973. + if (loads_pic_register)
  13974. + pic_save_size += UNITS_PER_WORD * 2;
  13975. +
  13976. + cfun->machine->frame_pointer_needed = frame_pointer_needed;
  13977. + cfun->machine->non_leaf = non_leaf;
  13978. + cfun->machine->savesize_gp = savesize_gp;
  13979. + cfun->machine->savesize_eh = savesize_eh;
  13980. + cfun->machine->FP_SP_offset = FP_SP_offset + pic_save_size;
  13981. + cfun->machine->pic_save_size = pic_save_size;
  13982. + cfun->machine->out_local_size = out_local_size;
  13983. + cfun->machine->calls_eh_return = current_function_calls_eh_return;
  13984. + cfun->machine->extras_gp = extras_gp;
  13985. + cfun->machine->extras_eh = extras_eh;
  13986. + cfun->machine->uses_pic_offset_table = current_function_uses_pic_offset_table;
  13987. + cfun->machine->loads_pic_register = loads_pic_register;
  13988. + cfun->machine->ech_ctx_required = (ech_ctx != 0);
  13989. + cfun->machine->arg_adjust_delta = 0;
  13990. + cfun->machine->frame_adjust_delta = 0;
  13991. + cfun->machine->can_use_short_branch = false;
  13992. + cfun->machine->valid = true;
  13993. +
  13994. + switch (from)
  13995. + {
  13996. + case ARG_POINTER_REGNUM:
  13997. + switch (to)
  13998. + {
  13999. + case STACK_POINTER_REGNUM:
  14000. + delta = -savesize_gp - savesize_eh - pic_save_size - out_local_size;
  14001. + if (cfun->machine->anonymous_args)
  14002. + delta += ALIGN_ON_STACK_BOUNDARY (cfun->machine->anonymous_args_size);
  14003. + cfun->machine->arg_adjust_delta = delta;
  14004. + return delta;
  14005. + case HARD_FRAME_POINTER_REGNUM:
  14006. + delta = -pretend_size;
  14007. + if (cfun->machine->anonymous_args)
  14008. + delta += ALIGN_ON_STACK_BOUNDARY (cfun->machine->anonymous_args_size);
  14009. + cfun->machine->arg_adjust_delta = delta;
  14010. + return delta;
  14011. + default:
  14012. + gcc_unreachable ();
  14013. + }
  14014. + break;
  14015. + case FRAME_POINTER_REGNUM:
  14016. + switch (to)
  14017. + {
  14018. + case STACK_POINTER_REGNUM:
  14019. + delta = -out_local_size;
  14020. + cfun->machine->frame_adjust_delta = delta;
  14021. + return delta;
  14022. + case HARD_FRAME_POINTER_REGNUM:
  14023. + delta = -pretend_size + savesize_gp + savesize_eh + pic_save_size;
  14024. + cfun->machine->frame_adjust_delta = delta;
  14025. + return delta;
  14026. + default:
  14027. + gcc_unreachable ();
  14028. + break;
  14029. + }
  14030. + break;
  14031. + default:
  14032. + gcc_unreachable ();
  14033. + break;
  14034. + }
  14035. +
  14036. + gcc_unreachable ();
  14037. +}
  14038. +
  14039. +typedef struct hwtrace_fn
  14040. +{
  14041. + const char * name;
  14042. + int onoff;
  14043. + struct hwtrace_fn *next;
  14044. +} hwtrace_fn;
  14045. +
  14046. +/* A simple linked list records info about "#pragma hwtrace_function (name, 0|1) */
  14047. +static hwtrace_fn *hwtrace_function_list = NULL;
  14048. +/* records default if #pragma hwtrace_function (*, 0|1) */
  14049. +static int hwtrace_function_default = -1; /* < 0 none, 0 off > 1 on */
  14050. +
  14051. +static bool
  14052. +hwtrace_function_enabled (tree function_decl)
  14053. +{
  14054. + if (function_decl)
  14055. + {
  14056. + const char * fnname = IDENTIFIER_POINTER (DECL_NAME (function_decl));
  14057. + hwtrace_fn *next = hwtrace_function_list;
  14058. +
  14059. + while (next != NULL)
  14060. + {
  14061. + if (strcmp (next->name, fnname) == 0)
  14062. + return next->onoff;
  14063. +
  14064. + next = next->next;
  14065. + }
  14066. +
  14067. + if (hwtrace_function_default < 0)
  14068. + return true;
  14069. +
  14070. + if (hwtrace_function_default > 0)
  14071. + return true;
  14072. +
  14073. + return false;
  14074. + }
  14075. +
  14076. + return true;
  14077. +}
  14078. +
  14079. +static struct machine_function *
  14080. +metag_init_machine_status (void)
  14081. +{
  14082. + struct machine_function *machine
  14083. + = (machine_function *) ggc_alloc_cleared (sizeof (*machine));
  14084. + bool enabled = hwtrace_function_enabled (current_function_decl);
  14085. +
  14086. + machine->valid = false;
  14087. + machine->hwtrace = TARGET_HWTRACE && enabled;
  14088. + machine->hwtrace_leaf = TARGET_HWTRACE_LEAF && enabled;
  14089. + machine->hwtrace_retpc = TARGET_HWTRACE_RETPC && enabled;
  14090. +
  14091. + machine->cond_return_state = METAG_COND_RETURN_NONE;
  14092. + return machine;
  14093. +}
  14094. +
  14095. +void
  14096. +metag_init_expanders (void)
  14097. +{
  14098. + init_machine_status = metag_init_machine_status;
  14099. +}
  14100. +
  14101. +bool
  14102. +metag_legitimate_address_p (rtx addr, enum machine_mode mode, bool strict)
  14103. +{
  14104. + rtx tmp;
  14105. +
  14106. + if (METAG_FLAG_PIC && SYMBOLIC_CONST (addr))
  14107. + return metag_legitimate_pic_address_disp_p (addr);
  14108. +
  14109. + if (SYMBOL_REF_P (addr) && METAG_SYMBOL_FLAG_DIRECT_P (addr))
  14110. + return true;
  14111. +
  14112. + tmp = addr;
  14113. +
  14114. + if (SUBREG_P (tmp)
  14115. + && (GET_MODE_SIZE (GET_MODE (tmp))
  14116. + < GET_MODE_SIZE (GET_MODE (SUBREG_REG (tmp)))))
  14117. + tmp = SUBREG_REG (tmp);
  14118. +
  14119. + if (METAG_LEGITIMATE_REG_P (tmp, strict))
  14120. + return true;
  14121. +
  14122. + if (METAG_LEGITIMATE_PRE_INCDEC_P (addr, mode, strict))
  14123. + return true;
  14124. +
  14125. + if (METAG_LEGITIMATE_POST_INCDEC_P (addr, mode, strict))
  14126. + return true;
  14127. +
  14128. + if (METAG_LEGITIMATE_PRE_MODIFY_P (addr, mode, strict))
  14129. + return true;
  14130. +
  14131. + if (METAG_LEGITIMATE_POST_MODIFY_P (addr, mode, strict))
  14132. + return true;
  14133. +
  14134. + if (GET_CODE (addr) == PLUS)
  14135. + {
  14136. + rtx op0 = XEXP (addr, 0);
  14137. + rtx op1 = XEXP (addr, 1);
  14138. +
  14139. + if (SUBREG_P (op0)
  14140. + && (GET_MODE_SIZE (GET_MODE (op0))
  14141. + < GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)))))
  14142. + op0 = SUBREG_REG (op0);
  14143. +
  14144. + if (METAG_LEGITIMATE_REG_P (op0, strict))
  14145. + {
  14146. + if (REG_P (op1)
  14147. + && METAG_LEGITIMATE_TWIN_P (op0, op1, mode, strict))
  14148. + return true;
  14149. +
  14150. + if (CONST_INT_P (op1)
  14151. + && METAG_LEGITIMATE_OFF_P (op0, op1, mode, strict))
  14152. + return true;
  14153. + }
  14154. +
  14155. + if (METAG_FLAG_PIC && op0 == pic_offset_table_rtx)
  14156. + return metag_legitimate_pic_address_disp_p (op1);
  14157. + }
  14158. +
  14159. + if (0 && GET_CODE (addr) == PLUS)
  14160. + {
  14161. + rtx op0 = XEXP (addr, 0);
  14162. + rtx op1 = XEXP (addr, 1);
  14163. +
  14164. + if (GET_CODE (op0) == PLUS
  14165. + && GET_CODE (op1) == CONST_INT)
  14166. + {
  14167. + rtx op3 = XEXP (op0, 0);
  14168. + rtx op4 = XEXP (op0, 1);
  14169. +
  14170. + if (CONST_INT_P (op4))
  14171. + {
  14172. + if (SUBREG_P (op3)
  14173. + && (GET_MODE_SIZE (GET_MODE (op3))
  14174. + < GET_MODE_SIZE (GET_MODE (SUBREG_REG (op3)))))
  14175. + op3 = SUBREG_REG (op3);
  14176. +
  14177. + op4 = GEN_INT (INTVAL (op1) + INTVAL (op4));
  14178. + if (METAG_LEGITIMATE_REG_P (op3, strict)
  14179. + && METAG_LEGITIMATE_OFF_P (op3, op4, mode, strict))
  14180. + return true;
  14181. + }
  14182. + }
  14183. + }
  14184. +
  14185. + return false;
  14186. +}
  14187. +
  14188. +bool
  14189. +metag_legitimate_regno_p (unsigned int regno, bool strict)
  14190. +{
  14191. + if (strict)
  14192. + {
  14193. + if (IS_PSEUDO_REGNO (regno) && reg_renumber != NULL)
  14194. + regno = reg_renumber [regno];
  14195. +
  14196. + return regno <= FRAME_POINTER_REGNUM || regno == ARG_POINTER_REGNUM;
  14197. + }
  14198. +
  14199. + return regno != INVALID_REGNUM;
  14200. +}
  14201. +
  14202. +bool
  14203. +metag_legitimate_reg_p (rtx reg, bool strict)
  14204. +{
  14205. + return REG_P (reg) ? metag_legitimate_regno_p (REGNO (reg), strict)
  14206. + : false;
  14207. +}
  14208. +
  14209. +/* Return true iff BASE and OFF are valid for Reg + Reg addressing.
  14210. + If STRICT is true then we need to be strict w.r.t pseduo registers
  14211. + */
  14212. +bool
  14213. +metag_regs_ok_for_base_offset_p (rtx base_reg, rtx off_reg, bool strict)
  14214. +{
  14215. + if (!METAG_LEGITIMATE_REG_P (base_reg, strict))
  14216. + return false;
  14217. +
  14218. + if (!METAG_LEGITIMATE_REG_P (off_reg, strict))
  14219. + return false;
  14220. +
  14221. + return metag_regs_same_regclass_p (base_reg, off_reg, strict);
  14222. +}
  14223. +
  14224. +bool
  14225. +metag_reg_ok_for_base_p (rtx reg ATTRIBUTE_UNUSED, bool strict)
  14226. +{
  14227. + return strict ? STRICT_REG_OK_FOR_BASE_P (reg)
  14228. + : NONSTRICT_REG_OK_FOR_BASE_P (reg);
  14229. +}
  14230. +
  14231. +bool
  14232. +metag_reg_ok_for_offset_p (rtx reg, bool strict)
  14233. +{
  14234. + return strict ? STRICT_REG_OK_FOR_OFFSET_P (reg)
  14235. + : NONSTRICT_REG_OK_FOR_OFFSET_P (reg);
  14236. +}
  14237. +
  14238. +bool
  14239. +metag_reg_ok_for_index_p (rtx reg ATTRIBUTE_UNUSED, bool strict)
  14240. +{
  14241. + return strict ? STRICT_REG_OK_FOR_INDEX_P (reg)
  14242. + : NONSTRICT_REG_OK_FOR_INDEX_P (reg);
  14243. +}
  14244. +
  14245. +bool
  14246. +metag_legitimate_post_incdec_p (rtx addr, enum machine_mode mode ATTRIBUTE_UNUSED, bool strict)
  14247. +{
  14248. + return (GET_CODE (addr) == POST_INC || GET_CODE (addr) == POST_DEC)
  14249. + && METAG_LEGITIMATE_REG_P (XEXP (addr, 0), strict)
  14250. + && !METAG_ELIMINABLE_REG_P (XEXP (addr, 0));
  14251. +}
  14252. +
  14253. +bool
  14254. +metag_legitimate_pre_incdec_p (rtx addr, enum machine_mode mode ATTRIBUTE_UNUSED, bool strict)
  14255. +{
  14256. + return (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC)
  14257. + && METAG_LEGITIMATE_REG_P (XEXP (addr, 0), strict)
  14258. + && !METAG_ELIMINABLE_REG_P (XEXP (addr, 0));
  14259. +}
  14260. +
  14261. +bool
  14262. +metag_legitimate_off_p (rtx base, rtx off, enum machine_mode mode, bool strict ATTRIBUTE_UNUSED)
  14263. +{
  14264. + if (CONST_INT_P (off))
  14265. + {
  14266. + HOST_WIDE_INT value = INTVAL (off);
  14267. + unsigned int modesize = GET_MODE_SIZE (mode);
  14268. +
  14269. + if ((value & (modesize - 1)) == 0)
  14270. + {
  14271. + unsigned int regno = REGNO (base);
  14272. + HOST_WIDE_INT limit;
  14273. +
  14274. + if (reg_renumber != NULL && IS_PSEUDO_REGNO (regno))
  14275. + regno = reg_renumber[regno];
  14276. +
  14277. + if (metag_regno12bit_p (regno)
  14278. + && (!metag_fpu_resources
  14279. + || (GET_MODE_CLASS (mode) != MODE_FLOAT)))
  14280. + limit = 2048;
  14281. + else if (cfun && regno == ARG_POINTER_REGNUM)
  14282. + value += cfun->machine->arg_adjust_delta, limit = 2048;
  14283. + else if (cfun && regno == FRAME_POINTER_REGNUM)
  14284. + {
  14285. + if (reload_in_progress)
  14286. + return true;
  14287. +
  14288. + value += cfun->machine->frame_adjust_delta, limit = 2048;
  14289. + }
  14290. + else if (!strict && !reload_in_progress && !reload_completed
  14291. + && (regno == ARG_POINTER_REGNUM
  14292. + || regno == FRAME_POINTER_REGNUM))
  14293. + limit = 2048;
  14294. + else if (!strict && !reload_in_progress && !reload_completed && IS_PSEUDO_REGNO (regno)
  14295. + && (!metag_fpu_resources
  14296. + || (GET_MODE_CLASS (mode) != MODE_FLOAT)))
  14297. + limit = 2048;
  14298. + else
  14299. + limit = 32;
  14300. +
  14301. + limit *= modesize;
  14302. +
  14303. + return (-limit <= value && value < limit);
  14304. + }
  14305. + }
  14306. +
  14307. + return false;
  14308. +}
  14309. +
  14310. +bool
  14311. +metag_legitimate_twin_p (rtx base, rtx off, enum machine_mode mode ATTRIBUTE_UNUSED, bool strict)
  14312. +{
  14313. + return METAG_REGS_OK_FOR_BASE_OFFSET_P (base, off, strict);
  14314. +}
  14315. +
  14316. +bool
  14317. +metag_frame_related_rtx (rtx op)
  14318. +{
  14319. + return (REG_P (op)
  14320. + && (op == frame_pointer_rtx
  14321. + || op == arg_pointer_rtx
  14322. + || op == virtual_incoming_args_rtx
  14323. + || op == virtual_stack_vars_rtx
  14324. + || op == virtual_stack_dynamic_rtx
  14325. + || op == virtual_outgoing_args_rtx
  14326. + || op == virtual_cfa_rtx
  14327. + || REGNO (op) == FRAME_POINTER_REGNUM
  14328. + || REGNO (op) == ARG_POINTER_REGNUM));
  14329. +}
  14330. +
  14331. +
  14332. +/* Returns 1 if OP contains a symbol reference */
  14333. +
  14334. +bool
  14335. +metag_symbolic_reference_mentioned_p (rtx op)
  14336. +{
  14337. + const char *fmt;
  14338. + int i;
  14339. +
  14340. + if (SYMBOL_REF_P (op) || LABEL_REF_P (op))
  14341. + return true;
  14342. +
  14343. + fmt = GET_RTX_FORMAT (GET_CODE (op));
  14344. + for (i = GET_RTX_LENGTH (GET_CODE (op)) - 1; i >= 0; i--)
  14345. + {
  14346. + if (fmt[i] == 'E')
  14347. + {
  14348. + int j;
  14349. +
  14350. + for (j = XVECLEN (op, i) - 1; j >= 0; j--)
  14351. + if (metag_symbolic_reference_mentioned_p (XVECEXP (op, i, j)))
  14352. + return true;
  14353. + }
  14354. + else if (fmt[i] == 'e' && metag_symbolic_reference_mentioned_p (XEXP (op, i)))
  14355. + return true;
  14356. + }
  14357. +
  14358. + return false;
  14359. +}
  14360. +
  14361. +bool
  14362. +metag_legitimate_pic_address_disp_p (rtx disp)
  14363. +{
  14364. + if (GET_CODE (disp) != CONST)
  14365. + return false;
  14366. +
  14367. + disp = XEXP (disp, 0);
  14368. +
  14369. + if (GET_CODE (disp) == PLUS)
  14370. + {
  14371. + if (!CONST_INT_P (XEXP (disp, 1)))
  14372. + return false;
  14373. +
  14374. + disp = XEXP (disp, 0);
  14375. + }
  14376. +
  14377. + if (GET_CODE (disp) != UNSPEC
  14378. + || XVECLEN (disp, 0) != 1)
  14379. + return false;
  14380. +
  14381. + /* Must be @GOT but not @GOTOFF */
  14382. + if (XINT (disp, 1) != UNSPEC_GOT)
  14383. + return false;
  14384. +
  14385. + if (!SYMBOL_REF_P (XVECEXP (disp, 0, 0))
  14386. + && !LABEL_REF_P (XVECEXP (disp, 0, 0)))
  14387. + return false;
  14388. +
  14389. + return true;
  14390. +}
  14391. +
  14392. +/* Try machine-dependent ways of modifying an illegitimate address
  14393. + to be legitimate. If we find one, return the new, valid address.
  14394. + This macro is used in only one place: `memory_address' in explow.c.
  14395. +
  14396. + OLDX is the address as it was before break_out_memory_refs was called.
  14397. + In some cases it is useful to look at this to decide what needs to be done.
  14398. +
  14399. + MODE and WIN are passed so that this macro can use
  14400. + GO_IF_LEGITIMATE_ADDRESS.
  14401. +
  14402. + It is always safe for this macro to do nothing. It exists to recognize
  14403. + opportunities to optimize the output.
  14404. +*/
  14405. +
  14406. +rtx
  14407. +metag_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
  14408. + enum machine_mode mode ATTRIBUTE_UNUSED)
  14409. +{
  14410. +
  14411. + /* We currently only have support for thread local storage (TLS)
  14412. + under META Linux. There is no TLS support for the embedded
  14413. + toolchain */
  14414. +
  14415. + if (tls_symbolic_operand_p (x))
  14416. + return metag_bfd_legitimize_tls_address (x);
  14417. +
  14418. + if (METAG_FLAG_PIC)
  14419. + return SYMBOLIC_CONST (x) ? metag_legitimize_pic_address (x, 0) : x;
  14420. +
  14421. + return x;
  14422. +}
  14423. +
  14424. +/* This function has been created by using the output template from the movsi
  14425. + insn in metag.md */
  14426. +
  14427. +void
  14428. +metag_emit_move_sequence (rtx operands[],
  14429. + enum machine_mode mode ATTRIBUTE_UNUSED)
  14430. +{
  14431. +
  14432. + if (metag_bfd_tls_referenced_p (operands[1]))
  14433. + {
  14434. + rtx tmp = operands[1];
  14435. + rtx addend = NULL;
  14436. +
  14437. + /* All TLS symbols should be wrapped in an UNSPEC prior to reload (the
  14438. + check is performed by metag_bfd_tls_referenced_p) if they are still
  14439. + symbols raise an error */
  14440. + if (reload_in_progress)
  14441. + gcc_unreachable ();
  14442. + else
  14443. + {
  14444. + /* Catch and fix the case where GCC is trying to offset a TLS symbol */
  14445. + if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
  14446. + {
  14447. + addend = XEXP (XEXP (tmp, 0), 1);
  14448. + tmp = XEXP (XEXP (tmp, 0), 0);
  14449. + }
  14450. +
  14451. + gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
  14452. + gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
  14453. +
  14454. + tmp = metag_bfd_legitimize_tls_address (tmp);
  14455. +
  14456. + if (addend)
  14457. + {
  14458. + tmp = gen_rtx_PLUS (mode, tmp, addend);
  14459. + tmp = force_operand (tmp, operands[0]);
  14460. + }
  14461. +
  14462. + operands[1] = tmp;
  14463. +
  14464. + if (MEM_P (operands[0]))
  14465. + {
  14466. + /* All except mem = const, mem = mem, or mem = addr can be done quickly */
  14467. + operands[1] = force_reg (SImode, operands[1]);
  14468. + }
  14469. + }
  14470. + }
  14471. + else if (METAG_FLAG_PIC && SYMBOLIC_CONST (operands[1]))
  14472. + {
  14473. + if (MEM_P (operands[0]) && SYMBOLIC_CONST (operands[1]))
  14474. + operands[1] = force_reg (Pmode, operands[1]);
  14475. + else
  14476. + {
  14477. + rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
  14478. +
  14479. + operands[1] = metag_legitimize_pic_address (operands[1], temp);
  14480. + }
  14481. + }
  14482. + else if (MEM_P (operands[0]))
  14483. + {
  14484. + /* All except mem = const, mem = mem, or mem = addr can be done quickly */
  14485. + operands[1] = force_reg (SImode, operands[1]);
  14486. + }
  14487. +
  14488. + if (REG_P (operands[0])
  14489. + && REGNO (operands[0]) == TXRPT_REGNUM)
  14490. + {
  14491. + if (CONST_INT_P (operands[1])
  14492. + && !(METAG_CONST_OK_FOR_LETTERS_KPIJ (operands[1])))
  14493. + {
  14494. + operands[1] = force_reg (SImode, operands[1]);
  14495. + }
  14496. + }
  14497. +}
  14498. +
  14499. +/* Return a legitimate reference for ORIG (an address) using the
  14500. + register REG. If REG is 0, a new pseudo is generated.
  14501. +
  14502. + There are two types of references that must be handled:
  14503. +
  14504. + 1. Global data references must load the address from the GOT, via
  14505. + the PIC reg. An insn is emitted to do this load, and the reg is
  14506. + returned.
  14507. +
  14508. + 2. Static data references, constant pool addresses, and code labels
  14509. + compute the address as an offset from the GOT, whose base is in
  14510. + the PIC reg. Static data objects have SYMBOL_REF_FLAG set to
  14511. + differentiate them from global data objects. The returned
  14512. + address is the PIC reg + an unspec constant.
  14513. +*/
  14514. +
  14515. +rtx
  14516. +metag_legitimize_pic_address (rtx orig, rtx reg)
  14517. +{
  14518. + rtx addr = orig;
  14519. + rtx new = orig;
  14520. + rtx base;
  14521. +
  14522. + if (LABEL_REF_P (addr)
  14523. + || (SYMBOL_REF_P (addr)
  14524. + && (CONSTANT_POOL_ADDRESS_P (addr)
  14525. + || METAG_SYMBOL_FLAG_DIRECT_P (addr)
  14526. + || SYMBOL_REF_LOCAL_P (addr))))
  14527. + {
  14528. + /* This symbol may be referenced via a displacement from the PIC
  14529. + base address (@GOTOFF). */
  14530. +
  14531. + /* Only mark this function as needing pic if we are not being called
  14532. + as part of a cost-estimation process */
  14533. + if (!ir_type ())
  14534. + current_function_uses_pic_offset_table = 1;
  14535. +
  14536. + new = gen_rtx_UNSPEC (VOIDmode, gen_rtvec (1, addr), UNSPEC_GOTOFF);
  14537. + new = gen_rtx_CONST (VOIDmode, new);
  14538. + new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new);
  14539. +
  14540. + if (reg != 0)
  14541. + {
  14542. + emit_move_insn (reg, new);
  14543. + new = reg;
  14544. + }
  14545. + }
  14546. + else if (SYMBOL_REF_P (addr))
  14547. + {
  14548. + /* This symbol must be referenced via a load from the
  14549. + Global Offset Table (@GOT). */
  14550. +
  14551. + /* Only mark this function as needing pic if we are not being called
  14552. + as part of a cost-estimation process */
  14553. + if (!ir_type ())
  14554. + current_function_uses_pic_offset_table = 1;
  14555. +
  14556. + new = gen_rtx_UNSPEC (VOIDmode, gen_rtvec (1, addr), UNSPEC_GOT);
  14557. + new = gen_rtx_CONST (VOIDmode, new);
  14558. + new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new);
  14559. + new = gen_rtx_MEM (Pmode, new);
  14560. +
  14561. + if (reg == 0)
  14562. + reg = gen_reg_rtx (Pmode);
  14563. +
  14564. + emit_move_insn (reg, new);
  14565. + new = reg;
  14566. + }
  14567. + else
  14568. + {
  14569. + if (GET_CODE (addr) == CONST)
  14570. + {
  14571. + addr = XEXP (addr, 0);
  14572. + if (GET_CODE (addr) == UNSPEC)
  14573. + {
  14574. + /* Check that the unspec is one of the ones we generate? */
  14575. + }
  14576. + else if (GET_CODE (addr) != PLUS)
  14577. + abort();
  14578. + }
  14579. +
  14580. + if (GET_CODE (addr) == PLUS)
  14581. + {
  14582. + rtx op0 = XEXP (addr, 0), op1 = XEXP (addr, 1);
  14583. +
  14584. + /* Check first to see if this is a constant offset from a @GOTOFF
  14585. + symbol reference. */
  14586. + if ((LABEL_REF_P (op0)
  14587. + || (SYMBOL_REF_P (op0)
  14588. + && (CONSTANT_POOL_ADDRESS_P (op0)
  14589. + || METAG_SYMBOL_FLAG_DIRECT_P (op0))))
  14590. + && CONST_INT_P (op1))
  14591. + {
  14592. + /* Only mark this function as needing pic if we are not being called
  14593. + as part of a cost-estimation process */
  14594. + if (!ir_type ())
  14595. + current_function_uses_pic_offset_table = 1;
  14596. +
  14597. + new = gen_rtx_UNSPEC (VOIDmode, gen_rtvec (1, op0), UNSPEC_GOTOFF);
  14598. + new = gen_rtx_PLUS (Pmode, new, op1);
  14599. + new = gen_rtx_CONST (VOIDmode, new);
  14600. + new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new);
  14601. +
  14602. + if (reg != 0)
  14603. + {
  14604. + emit_move_insn (reg, new);
  14605. + new = reg;
  14606. + }
  14607. + }
  14608. + else
  14609. + {
  14610. + base = metag_legitimize_pic_address (XEXP (addr, 0), reg);
  14611. + new = metag_legitimize_pic_address (XEXP (addr, 1),
  14612. + base == reg ? NULL_RTX : reg);
  14613. +
  14614. + if (CONST_INT_P (new))
  14615. + new = plus_constant (base, INTVAL (new));
  14616. + else
  14617. + {
  14618. + if (GET_CODE (new) == PLUS && CONSTANT_P (XEXP (new, 1)))
  14619. + {
  14620. + base = gen_rtx_PLUS (Pmode, base, XEXP (new, 0));
  14621. + new = XEXP (new, 1);
  14622. + }
  14623. +
  14624. + new = gen_rtx_PLUS (Pmode, base, new);
  14625. + }
  14626. + }
  14627. + }
  14628. + }
  14629. +
  14630. + return new;
  14631. +}
  14632. +
  14633. +/* Compute a (partial) cost for rtx X. Return true if the complete
  14634. + cost has been computed, and false if subexpressions should be
  14635. + scanned. In either case, *TOTAL contains the cost result. */
  14636. +
  14637. +bool
  14638. +metag_rtx_costs (rtx x, int code, int outer_code, int *total)
  14639. +{
  14640. + switch (code)
  14641. + {
  14642. + case CONST_INT:
  14643. + if (satisfies_constraint_K (x))
  14644. + *total = (outer_code == SET ? COSTS_N_INSNS (1) :
  14645. + outer_code == PLUS ? 0 :
  14646. + outer_code == MINUS ? 0 :
  14647. + outer_code == AND ? 0 :
  14648. + outer_code == IOR ? 0 :
  14649. + outer_code == XOR ? 0 :
  14650. + outer_code == COMPARE ? 0 :
  14651. + COSTS_N_INSNS (1));
  14652. + else if (satisfies_constraint_P (x))
  14653. + *total = (outer_code == SET ? COSTS_N_INSNS (1) :
  14654. + outer_code == PLUS ? 0 :
  14655. + outer_code == MINUS ? 0 :
  14656. + outer_code == AND ? 0 :
  14657. + outer_code == IOR ? 0 :
  14658. + outer_code == XOR ? 0 :
  14659. + outer_code == COMPARE ? 0 :
  14660. + COSTS_N_INSNS (1));
  14661. + else if ((INTVAL (x) & 0xffff) == 0xffff
  14662. + && (outer_code == AND || outer_code == IOR || outer_code == XOR))
  14663. + *total = COSTS_N_INSNS (1);
  14664. + else if ((INTVAL (x) & 0xffff0000) == 0xffff0000
  14665. + && (outer_code == AND || outer_code == IOR || outer_code == XOR))
  14666. + *total = COSTS_N_INSNS (1);
  14667. + else if (INTVAL (x) >= -32768 && INTVAL (x) <= 65535)
  14668. + *total = COSTS_N_INSNS (1);
  14669. + else if ((INTVAL (x) & 0xffff) == 0)
  14670. + *total = COSTS_N_INSNS (2);
  14671. + else
  14672. + *total = COSTS_N_INSNS (5);
  14673. + break;
  14674. + case CONST:
  14675. + if (outer_code == MEM)
  14676. + {
  14677. + *total = COSTS_N_INSNS (1);
  14678. + return true;
  14679. + }
  14680. + *total = COSTS_N_INSNS (2);
  14681. + break;
  14682. + case LABEL_REF:
  14683. + case SYMBOL_REF:
  14684. + *total = COSTS_N_INSNS (6);
  14685. + break;
  14686. + case CONST_DOUBLE:
  14687. + *total = COSTS_N_INSNS (10);
  14688. + break;
  14689. + case MULT:
  14690. + *total = COSTS_N_INSNS (2);
  14691. + break;
  14692. + case DIV:
  14693. + case UDIV:
  14694. + case MOD:
  14695. + case UMOD:
  14696. + *total = COSTS_N_INSNS (50);
  14697. + break;
  14698. + case PLUS:
  14699. + case MINUS:
  14700. + if (GET_MODE (x) == SImode)
  14701. + {
  14702. + rtx exp = XEXP (x, 0);
  14703. + unsigned int reg0 = REG_P (XEXP (x, 0)) ? REGNO (XEXP (x, 0)) : INVALID_REGNUM;
  14704. + unsigned int reg1 = REG_P (XEXP (x, 1)) ? REGNO (XEXP (x, 1)) : INVALID_REGNUM;
  14705. +
  14706. + if (reg_renumber != NULL && IS_PSEUDO_REGNO (reg0))
  14707. + reg0 = reg_renumber[reg0];
  14708. +
  14709. + if (reg_renumber != NULL && IS_PSEUDO_REGNO (reg1))
  14710. + reg1 = reg_renumber[reg1];
  14711. +
  14712. + if (IS_HARD_OR_VIRT_REGNO (reg0)
  14713. + && IS_HARD_OR_VIRT_REGNO (reg1)
  14714. + && METAG_REGNO_REG_CLASS (reg0) != METAG_REGNO_REG_CLASS (reg1))
  14715. + {
  14716. + /* Cannot really add/sub registers in different units */
  14717. + *total = COSTS_N_INSNS (50);
  14718. + }
  14719. + else if (exp != frame_pointer_rtx
  14720. + && exp != stack_pointer_rtx
  14721. + && exp != arg_pointer_rtx)
  14722. + *total = COSTS_N_INSNS (1);
  14723. + else
  14724. + *total = COSTS_N_INSNS (2);
  14725. + }
  14726. + else
  14727. + *total = COSTS_N_INSNS (4);
  14728. +
  14729. + break;
  14730. + case COMPARE:
  14731. + *total = COSTS_N_INSNS (1);
  14732. + break;
  14733. + case MEM:
  14734. + if (outer_code == SIGN_EXTEND)
  14735. + *total = COSTS_N_INSNS (2);
  14736. + else
  14737. + *total = COSTS_N_INSNS (1);
  14738. + break;
  14739. + case SIGN_EXTEND:
  14740. + *total = COSTS_N_INSNS (1);
  14741. + break;
  14742. + default:
  14743. + *total = COSTS_N_INSNS (1);
  14744. + break;
  14745. + }
  14746. +
  14747. + return false;
  14748. +}
  14749. +
  14750. +int
  14751. +metag_sched_adjust_cost (rtx insn, rtx link,
  14752. + rtx dep_insn, int cost)
  14753. +{
  14754. + switch (REG_NOTE_KIND (link))
  14755. + {
  14756. + case REG_DEP_ANTI:
  14757. + case REG_DEP_OUTPUT:
  14758. + return 0;
  14759. + case REG_DEP_TRUE:
  14760. + if (recog_memoized (insn) >= 0 && recog_memoized (dep_insn) >= 0)
  14761. + {
  14762. + enum attr_type type_attr = get_attr_type (dep_insn);
  14763. + enum attr_memaccess memaccess_attr = get_attr_memaccess (dep_insn);
  14764. +
  14765. + /* Match the twox|threex|fourx|fivex loads */
  14766. + if ((type_attr == TYPE_TWOX || type_attr == TYPE_THREEX
  14767. + || type_attr == TYPE_FOURX || type_attr == TYPE_FIVEX)
  14768. + && memaccess_attr == MEMACCESS_LOAD)
  14769. + {
  14770. + /* If the dependency is based on either of the last 2 registers
  14771. + * loaded, the latency increases. */
  14772. + cost += metag_consumer_stalls_from_load_multi (dep_insn, insn);
  14773. + }
  14774. +
  14775. + /* If there is an o2rhint then the insn may have an o2r operand which
  14776. + * may stall. */
  14777. + switch (get_attr_o2rhint (insn))
  14778. + {
  14779. + case O2RHINT_NONE:
  14780. + break;
  14781. + case O2RHINT_OP2OP1:
  14782. + /* insn has an o2r operand if units of operands 2 and 1 differ. */
  14783. + if (metag_consumer_is_o2r (dep_insn, insn, 2, 1))
  14784. + return cost + 1;
  14785. +
  14786. + break;
  14787. + case O2RHINT_OP1OP0:
  14788. + /* insn has an o2r operand if units of operands 1 and 0 differ. */
  14789. + if (metag_consumer_is_o2r (dep_insn, insn, 1, 0))
  14790. + return cost + 1;
  14791. +
  14792. + break;
  14793. + default:
  14794. + /* Bad o2rhint, missing a case for the hint. */
  14795. + gcc_unreachable ();
  14796. + }
  14797. +
  14798. + break;
  14799. + }
  14800. + break;
  14801. + default:
  14802. + break;
  14803. + }
  14804. +
  14805. + return cost;
  14806. +}
  14807. +
  14808. +int
  14809. +metag_address_cost (rtx x)
  14810. +{
  14811. + switch (GET_CODE (x))
  14812. + {
  14813. + case REG:
  14814. + return 0;
  14815. + case LABEL_REF:
  14816. + case SYMBOL_REF:
  14817. + case CONST:
  14818. + case MEM:
  14819. + return 10;
  14820. + case PRE_INC:
  14821. + case POST_INC:
  14822. + case PRE_DEC:
  14823. + case POST_DEC:
  14824. + case PRE_MODIFY:
  14825. + case POST_MODIFY:
  14826. + return 0;
  14827. + case PLUS:
  14828. + if (REG_P (XEXP (x, 0))
  14829. + && (REG_P (XEXP (x, 1)) || CONST_INT_P (XEXP (x, 1))))
  14830. + return 2;
  14831. + break;
  14832. + default:
  14833. + break;
  14834. + }
  14835. +
  14836. + return 6;
  14837. +}
  14838. +
  14839. +#define add_builtin_function(NAME, TYPE, CODE, CLASS, LIBNAME, ATTR) \
  14840. + lang_hooks.builtin_function (NAME, TYPE, CODE, CLASS, LIBNAME, ATTR)
  14841. +
  14842. +void
  14843. +metag_init_builtins(void)
  14844. +{
  14845. + tree nothrow = tree_cons (get_identifier ("nothrow"), NULL, NULL);
  14846. +#if 0
  14847. + tree const_throw = tree_cons (get_identifier ("const"), NULL, nothrow);
  14848. +#endif
  14849. + tree endlink = void_list_node;
  14850. + tree ftdcache_preload
  14851. + = build_function_type (ptr_type_node,
  14852. + tree_cons (NULL_TREE, ptr_type_node,
  14853. + endlink));
  14854. +
  14855. + tree ftdcache_flush
  14856. + = build_function_type (void_type_node,
  14857. + tree_cons (NULL_TREE, ptr_type_node,
  14858. + endlink));
  14859. +
  14860. + tree ftdcache_refresh
  14861. + = build_function_type (ptr_type_node,
  14862. + tree_cons (NULL_TREE, ptr_type_node,
  14863. + endlink));
  14864. +
  14865. + tree ftmeta2_cacherd
  14866. + = build_function_type (unsigned_intSI_type_node,
  14867. + tree_cons (NULL_TREE, ptr_type_node,
  14868. + endlink));
  14869. +
  14870. + tree ftmeta2_cacherl
  14871. + = build_function_type (unsigned_intDI_type_node,
  14872. + tree_cons (NULL_TREE, ptr_type_node,
  14873. + endlink));
  14874. +
  14875. + tree ftmeta2_cachewd
  14876. + = build_function_type (void_type_node,
  14877. + tree_cons (NULL_TREE, ptr_type_node,
  14878. + tree_cons (NULL_TREE, unsigned_intSI_type_node,
  14879. + endlink)));
  14880. +
  14881. + tree ftmeta2_cachewl
  14882. + = build_function_type (void_type_node,
  14883. + tree_cons (NULL_TREE, ptr_type_node,
  14884. + tree_cons (NULL_TREE, unsigned_intDI_type_node,
  14885. + endlink)));
  14886. +
  14887. + tree ftmetag_bswap
  14888. + = build_function_type (intSI_type_node,
  14889. + tree_cons (NULL_TREE, intSI_type_node,
  14890. + endlink));
  14891. +
  14892. + tree ftmetag_bswaps
  14893. + = build_function_type (intHI_type_node,
  14894. + tree_cons (NULL_TREE, intHI_type_node,
  14895. + endlink));
  14896. +
  14897. + tree ftmetag_bswapll
  14898. + = build_function_type (intDI_type_node,
  14899. + tree_cons (NULL_TREE, intDI_type_node,
  14900. + endlink));
  14901. +
  14902. + tree ftmetag_wswap
  14903. + = build_function_type (intSI_type_node,
  14904. + tree_cons (NULL_TREE, intSI_type_node,
  14905. + endlink));
  14906. +
  14907. + tree ftmetag_wswapll
  14908. + = build_function_type (intDI_type_node,
  14909. + tree_cons (NULL_TREE, intDI_type_node,
  14910. + endlink));
  14911. +
  14912. + tree ftmetag_dswapll
  14913. + = build_function_type (intDI_type_node,
  14914. + tree_cons (NULL_TREE, intDI_type_node,
  14915. + endlink));
  14916. +
  14917. +
  14918. +
  14919. + add_builtin_function ("__builtin_dcache_preload", ftdcache_preload,
  14920. + METAG_BUILTIN_DCACHE_PRELOAD,
  14921. + BUILT_IN_MD,
  14922. + NULL, nothrow);
  14923. +
  14924. + add_builtin_function ("__builtin_dcache_flush", ftdcache_flush,
  14925. + METAG_BUILTIN_DCACHE_FLUSH,
  14926. + BUILT_IN_MD,
  14927. + NULL, nothrow);
  14928. +
  14929. + add_builtin_function ("__builtin_dcache_refresh",
  14930. + ftdcache_refresh,
  14931. + METAG_BUILTIN_DCACHE_REFRESH,
  14932. + BUILT_IN_MD,
  14933. + NULL, nothrow);
  14934. +
  14935. + add_builtin_function ("__builtin_meta2_cacherd",
  14936. + ftmeta2_cacherd,
  14937. + METAG_BUILTIN_META2_CACHERD,
  14938. + BUILT_IN_MD,
  14939. + NULL, nothrow);
  14940. +
  14941. + add_builtin_function ("__builtin_meta2_cacherl",
  14942. + ftmeta2_cacherl,
  14943. + METAG_BUILTIN_META2_CACHERL,
  14944. + BUILT_IN_MD,
  14945. + NULL, nothrow);
  14946. +
  14947. + add_builtin_function ("__builtin_meta2_cachewd",
  14948. + ftmeta2_cachewd,
  14949. + METAG_BUILTIN_META2_CACHEWD,
  14950. + BUILT_IN_MD,
  14951. + NULL, nothrow);
  14952. +
  14953. + add_builtin_function ("__builtin_meta2_cachewl",
  14954. + ftmeta2_cachewl,
  14955. + METAG_BUILTIN_META2_CACHEWL,
  14956. + BUILT_IN_MD,
  14957. + NULL, nothrow);
  14958. +
  14959. + add_builtin_function ("__builtin_metag_bswaps",
  14960. + ftmetag_bswaps,
  14961. + METAG_BUILTIN_METAG_BSWAPS,
  14962. + BUILT_IN_MD,
  14963. + NULL, nothrow);
  14964. +
  14965. + add_builtin_function ("__builtin_metag_bswap",
  14966. + ftmetag_bswap,
  14967. + METAG_BUILTIN_METAG_BSWAP,
  14968. + BUILT_IN_MD,
  14969. + NULL, nothrow);
  14970. +
  14971. + add_builtin_function ("__builtin_metag_bswapll",
  14972. + ftmetag_bswapll,
  14973. + METAG_BUILTIN_METAG_BSWAPLL,
  14974. + BUILT_IN_MD,
  14975. + NULL, nothrow);
  14976. +
  14977. + add_builtin_function ("__builtin_metag_wswap",
  14978. + ftmetag_wswap,
  14979. + METAG_BUILTIN_METAG_WSWAP,
  14980. + BUILT_IN_MD,
  14981. + NULL, nothrow);
  14982. +
  14983. + add_builtin_function ("__builtin_metag_wswapll",
  14984. + ftmetag_wswapll,
  14985. + METAG_BUILTIN_METAG_WSWAPLL,
  14986. + BUILT_IN_MD,
  14987. + NULL, nothrow);
  14988. +
  14989. + add_builtin_function ("__builtin_metag_dswapll",
  14990. + ftmetag_dswapll,
  14991. + METAG_BUILTIN_METAG_DSWAPLL,
  14992. + BUILT_IN_MD,
  14993. + NULL, nothrow);
  14994. + /* Initialise the builtin functions for the operating system gcc
  14995. + is targeting code for */
  14996. + metag_init_builtins_per_os ();
  14997. +
  14998. +}
  14999. +
  15000. +/* Emit the optimal byte swap sequence for a 16 bit byte swap */
  15001. +
  15002. +static void
  15003. +metag_emit_byte_swap16 (rtx out, rtx in)
  15004. +{
  15005. + rtx tmp = gen_reg_rtx (SImode);
  15006. +
  15007. + emit_insn (gen_andsi3 (out, in,
  15008. + gen_int_mode (0x0000FFFF, SImode)));
  15009. + emit_insn (gen_lshrsi3 (tmp, out, GEN_INT (BITS_PER_UNIT)));
  15010. + emit_insn (gen_ashlsi3 (out, out, GEN_INT (BITS_PER_UNIT * 3)));
  15011. + emit_insn (gen_ashrsi3 (out, out, GEN_INT (BITS_PER_UNIT * 2)));
  15012. + emit_insn (gen_iorsi3 (out, out, tmp));
  15013. +}
  15014. +
  15015. +/* Emit the optimal byte swap sequence for a 32 bit byte swap */
  15016. +
  15017. +static void
  15018. +metag_emit_byte_swap32 (rtx out, rtx in)
  15019. +{
  15020. + rtx tmp = gen_reg_rtx (SImode);
  15021. +
  15022. + emit_insn (gen_rotsi2_16 (tmp, in));
  15023. + emit_insn (gen_lshrsi3 (out, tmp, GEN_INT (8)));
  15024. + emit_insn (gen_andsi3 (tmp, tmp,
  15025. + gen_int_mode (0xFFFF00FF, SImode)));
  15026. + emit_insn (gen_andsi3 (out, out,
  15027. + gen_int_mode (0xFFFF00FF, SImode)));
  15028. + emit_insn (gen_ashlsi3 (tmp, tmp, GEN_INT (8)));
  15029. + emit_insn (gen_iorsi3 (out, out, tmp));
  15030. +}
  15031. +
  15032. +/* Expand an expression EXP that calls a built-in function,
  15033. + with result going to TARGET if that's convenient
  15034. + (and in mode MODE if that's convenient).
  15035. + SUBTARGET may be used as the target for computing one of EXP's operands.
  15036. + IGNORE is nonzero if the value is to be ignored. */
  15037. +
  15038. +rtx
  15039. +metag_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED,
  15040. + rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
  15041. + int ignore ATTRIBUTE_UNUSED)
  15042. +{
  15043. + tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  15044. + tree arglist = TREE_OPERAND (exp, 1);
  15045. + int fcode = DECL_FUNCTION_CODE (fndecl);
  15046. +
  15047. + switch (fcode)
  15048. + {
  15049. + case METAG_BUILTIN_DCACHE_PRELOAD: /* void * __builtin_dcache_preload (void *) */
  15050. + if ( TARGET_BUILTINS_METAC_1_1
  15051. + || TARGET_BUILTINS_METAC_1_2
  15052. + || TARGET_BUILTINS_METAC_2_1)
  15053. + {
  15054. + tree arg0 = TREE_VALUE (arglist);
  15055. + rtx op0 = expand_normal (arg0);
  15056. + enum machine_mode mode0 = insn_data[CODE_FOR_dcache_preload].operand[0].mode;
  15057. + rtx pat;
  15058. +
  15059. + if (! (*insn_data[CODE_FOR_dcache_preload].operand[0].predicate)(op0, mode0))
  15060. + op0 = copy_to_mode_reg (mode0, op0);
  15061. +
  15062. + pat = GEN_FCN (CODE_FOR_dcache_preload)(op0);
  15063. +
  15064. + if (!pat)
  15065. + return NULL_RTX;
  15066. + emit_insn (pat);
  15067. + return op0;
  15068. + }
  15069. + else
  15070. + error ("__builtin_dcache_preload not supported for metac %s", metag_cpu_string);
  15071. + break;
  15072. + case METAG_BUILTIN_DCACHE_FLUSH: /* void __builtin_dcache_flush (void *) */
  15073. + if ( TARGET_BUILTINS_METAC_1_2
  15074. + || TARGET_BUILTINS_METAC_2_1)
  15075. + {
  15076. + tree arg0 = TREE_VALUE (arglist);
  15077. + rtx op0 = expand_normal (arg0);
  15078. + rtx op1;
  15079. + enum machine_mode mode0 = insn_data[CODE_FOR_dcache_flush].operand[0].mode;
  15080. + enum machine_mode mode1 = insn_data[CODE_FOR_dcache_flush].operand[1].mode;
  15081. + rtx pat;
  15082. +
  15083. + if (! (*insn_data[CODE_FOR_dcache_flush].operand[0].predicate)(op0, mode0))
  15084. + op0 = copy_to_mode_reg (mode0, op0);
  15085. +
  15086. + op1 = gen_reg_rtx (mode1);
  15087. +
  15088. + pat = GEN_FCN (CODE_FOR_dcache_flush)(op0, op1);
  15089. +
  15090. + if (!pat)
  15091. + return NULL_RTX;
  15092. +
  15093. + emit_move_insn (op1, const0_rtx);
  15094. + emit_insn (pat);
  15095. + return const1_rtx;
  15096. + }
  15097. + else
  15098. + error ("__builtin_dcache_flush not supported for metac %s", metag_cpu_string);
  15099. + break;
  15100. + case METAG_BUILTIN_DCACHE_REFRESH: /* void * __builtin_dcache_refresh (void *) */
  15101. + if ( TARGET_BUILTINS_METAC_1_1
  15102. + || TARGET_BUILTINS_METAC_1_2
  15103. + || TARGET_BUILTINS_METAC_2_1)
  15104. + {
  15105. + tree arg0 = TREE_VALUE (arglist);
  15106. + rtx op0 = expand_normal (arg0);
  15107. + rtx op1;
  15108. + enum machine_mode mode0 = insn_data[CODE_FOR_dcache_refresh].operand[0].mode;
  15109. + enum machine_mode mode1 = insn_data[CODE_FOR_dcache_refresh].operand[1].mode;
  15110. + rtx pat;
  15111. +
  15112. + if (! (*insn_data[CODE_FOR_dcache_refresh].operand[0].predicate)(op0, mode0))
  15113. + op0 = copy_to_mode_reg (mode0, op0);
  15114. +
  15115. + op1 = gen_reg_rtx (mode1);
  15116. +
  15117. + pat = GEN_FCN (CODE_FOR_dcache_refresh)(op0, op1);
  15118. +
  15119. + if (!pat)
  15120. + return NULL_RTX;
  15121. +
  15122. + emit_move_insn (op1, const0_rtx);
  15123. + emit_insn (pat);
  15124. + return op0;
  15125. + }
  15126. + else
  15127. + error ("__builtin_dcache_refresh not supported for metac %s", metag_cpu_string);
  15128. + break;
  15129. + case METAG_BUILTIN_META2_CACHERD: /* unsigned long __builtin_meta2_cacherd (void *) */
  15130. + case METAG_BUILTIN_META2_CACHERL: /* unsigned long long __builtin_meta2_cacherl (void *) */
  15131. + if (TARGET_BUILTINS_METAC_2_1)
  15132. + {
  15133. + tree arg0 = TREE_VALUE (arglist);
  15134. + rtx op1 = expand_normal (arg0);
  15135. + enum machine_mode tgtmode;
  15136. + enum machine_mode mode1;
  15137. + enum insn_code icode = CODE_FOR_meta2_cacherd;
  15138. + rtx pat;
  15139. +
  15140. + if (fcode == METAG_BUILTIN_META2_CACHERL)
  15141. + icode = CODE_FOR_meta2_cacherl;
  15142. +
  15143. + tgtmode = insn_data[icode].operand[0].mode;
  15144. + mode1 = insn_data[icode].operand[1].mode;
  15145. +
  15146. + if (target == 0 || !insn_data[icode].operand[0].predicate (target, tgtmode))
  15147. + target = gen_reg_rtx (tgtmode);
  15148. +
  15149. + if (! (*insn_data[icode].operand[1].predicate)(op1, mode1))
  15150. + op1 = copy_to_mode_reg (mode1, op1);
  15151. +
  15152. + pat = GEN_FCN (icode)(target, op1);
  15153. +
  15154. + if (!pat)
  15155. + return NULL_RTX;
  15156. +
  15157. + emit_insn (pat);
  15158. + return target;
  15159. + }
  15160. + else
  15161. + error ("__builtin_meta2_cacher[dl] not supported for metac %s", metag_cpu_string);
  15162. + break;
  15163. + case METAG_BUILTIN_META2_CACHEWD: /* void __builtin_meta2_cachewd (void *, unsigned lon) */
  15164. + case METAG_BUILTIN_META2_CACHEWL: /* void __builtin_meta2_cachewl (void *, unsigned long long) */
  15165. + if (TARGET_BUILTINS_METAC_2_1)
  15166. + {
  15167. + tree arg0 = TREE_VALUE (arglist);
  15168. + tree arg1 = TREE_VALUE (TREE_CHAIN (arglist));
  15169. + rtx op0 = expand_normal (arg0);
  15170. + rtx op1 = expand_normal (arg1);
  15171. +
  15172. + enum machine_mode mode0;
  15173. + enum machine_mode mode1;
  15174. + enum insn_code icode = CODE_FOR_meta2_cachewd;
  15175. + rtx pat;
  15176. +
  15177. + if (fcode == METAG_BUILTIN_META2_CACHEWL)
  15178. + icode = CODE_FOR_meta2_cachewl;
  15179. +
  15180. + mode0 = insn_data[icode].operand[0].mode;
  15181. + mode1 = insn_data[icode].operand[1].mode;
  15182. +
  15183. + if (! (*insn_data[icode].operand[0].predicate)(op0, mode0))
  15184. + op0 = copy_to_mode_reg (mode0, op0);
  15185. +
  15186. + if (! (*insn_data[icode].operand[1].predicate)(op1, mode1))
  15187. + op1 = copy_to_mode_reg (mode1, op1);
  15188. +
  15189. + pat = GEN_FCN (icode)(op0, op1);
  15190. +
  15191. + if (!pat)
  15192. + return NULL_RTX;
  15193. +
  15194. + emit_insn (pat);
  15195. + return const1_rtx;
  15196. + }
  15197. + else
  15198. + error ("__builtin_meta2_cachew[dl] not supported for metac %s (or extension disabled)", metag_cpu_string);
  15199. + break;
  15200. + case METAG_BUILTIN_METAG_BSWAPS: /* short __builtin_metag_bswaps (short) */
  15201. + case METAG_BUILTIN_METAG_BSWAP: /* int __builtin_metag_bswap (int) */
  15202. + case METAG_BUILTIN_METAG_BSWAPLL: /* long long __builtin_metag_bswap (long long) */
  15203. + if (!TARGET_BUILTINS_METAC_2_1 && metag_meta2_bex_enabled)
  15204. + error ("The 'bex' extension is only available on a META 2.1 core");
  15205. + else
  15206. + {
  15207. + tree arg0 = TREE_VALUE (arglist);
  15208. + rtx op1 = expand_normal (arg0);
  15209. +
  15210. + enum machine_mode mode;
  15211. +
  15212. + if (fcode == METAG_BUILTIN_METAG_BSWAPS)
  15213. + /* This looks like it should be HImode, but type promotion on the arguments causes
  15214. + shorts to become ints so SImode actually needs to be used */
  15215. + mode = SImode;
  15216. + else if (fcode == METAG_BUILTIN_METAG_BSWAP)
  15217. + mode = SImode;
  15218. + else
  15219. + mode = DImode;
  15220. +
  15221. + if (target == 0 || !metag_register_op (target, mode))
  15222. + target = gen_reg_rtx (mode);
  15223. +
  15224. + if (!metag_register_op (op1, mode))
  15225. + op1 = copy_to_mode_reg (mode, op1);
  15226. +
  15227. + if (metag_meta2_bex_enabled)
  15228. + {
  15229. + if (fcode == METAG_BUILTIN_METAG_BSWAPS)
  15230. + {
  15231. + emit_insn (gen_metag_bswap (target, op1));
  15232. + emit_insn (gen_ashrsi3 (target, target, GEN_INT ((UNITS_PER_WORD / 2) * BITS_PER_UNIT)));
  15233. + }
  15234. + else if (fcode == METAG_BUILTIN_METAG_BSWAP)
  15235. + emit_insn (gen_metag_bswap (target, op1));
  15236. + else
  15237. + emit_insn (gen_metag_bswapll (target, op1));
  15238. + }
  15239. + else
  15240. + {
  15241. + /* Generate the optimal byte swap sequence */
  15242. + if (fcode == METAG_BUILTIN_METAG_BSWAPS)
  15243. + metag_emit_byte_swap16 (target, op1);
  15244. + else if (fcode == METAG_BUILTIN_METAG_BSWAP)
  15245. + metag_emit_byte_swap32 (target, op1);
  15246. + else
  15247. + {
  15248. + rtx target_lo = gen_rtx_SUBREG (SImode, target, 0);
  15249. + rtx target_hi = gen_rtx_SUBREG (SImode, target, 4);
  15250. + rtx op1_lo = gen_rtx_SUBREG (SImode, op1, 0);
  15251. + rtx op1_hi = gen_rtx_SUBREG (SImode, op1, 4);
  15252. +
  15253. + metag_emit_byte_swap32 (target_lo, op1_hi);
  15254. + metag_emit_byte_swap32 (target_hi, op1_lo);
  15255. + }
  15256. + }
  15257. +
  15258. + return target;
  15259. + }
  15260. + break;
  15261. + case METAG_BUILTIN_METAG_WSWAP: /* int __builtin_metag_wswap (int) */
  15262. + case METAG_BUILTIN_METAG_WSWAPLL: /* long long __builtin_metag_wswapll (long long) */
  15263. + case METAG_BUILTIN_METAG_DSWAPLL: /* long long __builtin_metag_dswapll (long long) */
  15264. + {
  15265. +
  15266. + tree arg0 = TREE_VALUE (arglist);
  15267. + rtx op1 = expand_normal (arg0);
  15268. +
  15269. + enum machine_mode mode;
  15270. +
  15271. + if (fcode == METAG_BUILTIN_METAG_WSWAP)
  15272. + mode = SImode;
  15273. + else
  15274. + mode = DImode;
  15275. +
  15276. + if (target == 0 || !metag_register_op (target, mode))
  15277. + target = gen_reg_rtx (mode);
  15278. +
  15279. + if (!metag_register_op (op1, mode))
  15280. + op1 = copy_to_mode_reg (mode, op1);
  15281. +
  15282. + if (fcode == METAG_BUILTIN_METAG_WSWAP)
  15283. + {
  15284. + emit_insn (gen_rotsi2_16 (target, op1));
  15285. + }
  15286. + else if (fcode == METAG_BUILTIN_METAG_WSWAPLL)
  15287. + {
  15288. + rtx target_lo = gen_rtx_SUBREG (SImode, target, 0);
  15289. + rtx target_hi = gen_rtx_SUBREG (SImode, target, 4);
  15290. + if (TARGET_DSP)
  15291. + {
  15292. + emit_insn (gen_parallel_rotsi2_16 (target, op1));
  15293. + emit_insn (gen_swapsi (target_hi, target_lo));
  15294. + }
  15295. + else
  15296. + {
  15297. + rtx op1_lo = gen_rtx_SUBREG (SImode, op1, 0);
  15298. + rtx op1_hi = gen_rtx_SUBREG (SImode, op1, 4);
  15299. + emit_insn (gen_rotsi2_16 (target_lo, op1_lo));
  15300. + emit_insn (gen_rotsi2_16 (target_hi, op1_hi));
  15301. + emit_insn (gen_swapsi (target_hi, target_lo));
  15302. + }
  15303. + }
  15304. + else if (fcode == METAG_BUILTIN_METAG_DSWAPLL)
  15305. + {
  15306. + rtx target_lo = gen_rtx_SUBREG (SImode, target, 0);
  15307. + rtx target_hi = gen_rtx_SUBREG (SImode, target, 4);
  15308. + emit_insn (gen_movdi (target, op1));
  15309. + emit_insn (gen_swapsi (target_hi, target_lo));
  15310. + }
  15311. + return target;
  15312. + }
  15313. + break;
  15314. + default:
  15315. + break;
  15316. + }
  15317. +
  15318. + /* Expand any operating system specific builtin functions */
  15319. + return metag_expand_builtin_per_os (exp, target);
  15320. +}
  15321. +
  15322. +static tree
  15323. +metag_handle_model_decl_attribute (tree *node ATTRIBUTE_UNUSED,
  15324. + tree name ATTRIBUTE_UNUSED,
  15325. + tree args ATTRIBUTE_UNUSED,
  15326. + int flags ATTRIBUTE_UNUSED,
  15327. + bool *no_add_attrs ATTRIBUTE_UNUSED)
  15328. +{
  15329. + tree value = TREE_VALUE (args);
  15330. +
  15331. + if (strcmp (IDENTIFIER_POINTER (name), "model") == 0)
  15332. + {
  15333. + if (TREE_CODE (value) != STRING_CST)
  15334. + {
  15335. + warning (OPT_Wattributes,
  15336. + "argument of %qs attribute is not a string constant",
  15337. + IDENTIFIER_POINTER (name));
  15338. + *no_add_attrs = true;
  15339. + }
  15340. + else if ( strcmp (TREE_STRING_POINTER (value), "small") != 0
  15341. + && strcmp (TREE_STRING_POINTER (value), "large") != 0)
  15342. + {
  15343. + warning (OPT_Wattributes,
  15344. + "argument %qs of %qs is not \"small\" or \"large\"",
  15345. + TREE_STRING_POINTER (value), IDENTIFIER_POINTER (name));
  15346. + *no_add_attrs = true;
  15347. + }
  15348. + }
  15349. +
  15350. + return NULL_TREE;
  15351. +}
  15352. +
  15353. +tree
  15354. +metag_merge_decl_attributes (tree decl1, tree decl2)
  15355. +{
  15356. + return merge_decl_attributes (decl1, decl2);
  15357. +}
  15358. +
  15359. +tree
  15360. +metag_merge_type_attributes (tree type1, tree type2)
  15361. +{
  15362. + return merge_type_attributes (type1, type2);
  15363. +}
  15364. +
  15365. +int
  15366. +metag_comp_type_attributes (tree type1, tree type2)
  15367. +{
  15368. + tree m1 = lookup_attribute ("model", TYPE_ATTRIBUTES (type1));
  15369. + tree m2 = lookup_attribute ("model", TYPE_ATTRIBUTES (type2));
  15370. +
  15371. + if (m1 != NULL_TREE)
  15372. + m1 = TREE_VALUE (m1);
  15373. +
  15374. + if (m2 != NULL_TREE)
  15375. + m2 = TREE_VALUE (m2);
  15376. +
  15377. + if (m1 && m2 && TREE_CODE (m1) == STRING_CST && TREE_CODE (m2) == STRING_CST)
  15378. + return strcmp (TREE_STRING_POINTER (m1), TREE_STRING_POINTER (m2)) == 0 ? 1 : 0;
  15379. +
  15380. + return 1;
  15381. +}
  15382. +
  15383. +int
  15384. +metag_letter_for_const (rtx value)
  15385. +{
  15386. + if (satisfies_constraint_L (value))
  15387. + return 'L';
  15388. + else if (satisfies_constraint_P (value))
  15389. + return 'P';
  15390. + else if (satisfies_constraint_K (value))
  15391. + return 'K';
  15392. + else if (satisfies_constraint_I (value))
  15393. + return 'I';
  15394. + else if (satisfies_constraint_J (value))
  15395. + return 'J';
  15396. + else if (satisfies_constraint_M (value))
  15397. + return 'M';
  15398. + else if (satisfies_constraint_N (value))
  15399. + return 'N';
  15400. + else
  15401. + return 0;
  15402. +}
  15403. +
  15404. +bool
  15405. +metag_const_ok_for_letters_p (rtx value, const char letters[])
  15406. +{
  15407. + char c;
  15408. +
  15409. + while ((c = *letters++) != '\0')
  15410. + {
  15411. + switch (c)
  15412. + {
  15413. + case 'L':
  15414. + if (satisfies_constraint_L (value))
  15415. + return true;
  15416. + break;
  15417. + case 'P':
  15418. + if (satisfies_constraint_P (value))
  15419. + return true;
  15420. + break;
  15421. + case 'K':
  15422. + if (satisfies_constraint_K (value))
  15423. + return true;
  15424. + break;
  15425. + case 'I':
  15426. + if (satisfies_constraint_I (value))
  15427. + return true;
  15428. + break;
  15429. + case 'J':
  15430. + if (satisfies_constraint_J (value))
  15431. + return true;
  15432. + break;
  15433. + case 'M':
  15434. + if (satisfies_constraint_M (value))
  15435. + return true;
  15436. + break;
  15437. + case 'N':
  15438. + if (satisfies_constraint_N (value))
  15439. + return true;
  15440. + break;
  15441. + case 'O':
  15442. + switch (*letters)
  15443. + {
  15444. + case '0':
  15445. + letters++;
  15446. + if (satisfies_constraint_O0 (value))
  15447. + return true;
  15448. + break;
  15449. + case '1':
  15450. + letters++;
  15451. + if (satisfies_constraint_O1 (value))
  15452. + return true;
  15453. + break;
  15454. + case '2':
  15455. + letters++;
  15456. + if (satisfies_constraint_O2 (value))
  15457. + return true;
  15458. + break;
  15459. + case '3':
  15460. + letters++;
  15461. + if (satisfies_constraint_O3 (value))
  15462. + return true;
  15463. + break;
  15464. + case '4':
  15465. + letters++;
  15466. + if (satisfies_constraint_O4 (value))
  15467. + return true;
  15468. + break;
  15469. + case '5':
  15470. + gcc_unreachable ();
  15471. + break;
  15472. + case '6':
  15473. + gcc_unreachable ();
  15474. + break;
  15475. + case '7':
  15476. + gcc_unreachable ();
  15477. + break;
  15478. + case '8':
  15479. + letters++;
  15480. + if (satisfies_constraint_O8 (value))
  15481. + return true;
  15482. + break;
  15483. + case '9':
  15484. + gcc_unreachable ();
  15485. + break;
  15486. + default:
  15487. + break;
  15488. + }
  15489. + break;
  15490. + default:
  15491. + gcc_unreachable ();
  15492. + }
  15493. + }
  15494. +
  15495. + return false;
  15496. +}
  15497. +
  15498. +void
  15499. +metag_machine_dependent_reorg (void)
  15500. +{
  15501. + return;
  15502. +}
  15503. +
  15504. +void
  15505. +metag_setup_incoming_varargs (CUMULATIVE_ARGS *cum, enum machine_mode mode ATTRIBUTE_UNUSED,
  15506. + tree type, int *pretend_size,
  15507. + int no_rtl ATTRIBUTE_UNUSED)
  15508. +{
  15509. + int narg = ROUND_ADVANCE_CUM (cum->narg, mode, type);
  15510. +
  15511. + cfun->machine->anonymous_args = true;
  15512. +
  15513. + if (narg < MAX_METAG_PARM_BYTES)
  15514. + {
  15515. + *pretend_size = MAX_METAG_PARM_BYTES - narg;
  15516. + cfun->machine->anonymous_args_size = *pretend_size;
  15517. + }
  15518. +}
  15519. +
  15520. +bool
  15521. +metag_function_ok_for_sibcall (tree fndecl, tree exp)
  15522. +{
  15523. + return (current_function_outgoing_args_size == 0
  15524. + && !current_function_calls_alloca
  15525. + && !current_function_stdarg
  15526. + && current_function_pretend_args_size == 0
  15527. + && (fndecl == NULL_TREE || metag_function_ok_for_sibcall_per_os (fndecl, exp)));
  15528. +}
  15529. +
  15530. +#define PARM_BYTE_BOUNDARY (PARM_BOUNDARY / BITS_PER_UNIT)
  15531. +
  15532. +tree
  15533. +metag_gimplify_va_arg_expr (tree valist, tree type,
  15534. + tree *pre_p ATTRIBUTE_UNUSED,
  15535. + tree *post_p ATTRIBUTE_UNUSED)
  15536. +{
  15537. + tree ptr;
  15538. + tree valist_type = TREE_TYPE (valist);
  15539. + tree t;
  15540. + int size;
  15541. + bool indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
  15542. + HOST_WIDE_INT boundary;
  15543. +
  15544. + if (indirect)
  15545. + type = build_pointer_type (type);
  15546. +
  15547. + ptr = build_pointer_type (type);
  15548. +
  15549. + boundary = FUNCTION_ARG_BOUNDARY (TYPE_MODE (type), type);
  15550. +
  15551. + if (boundary < (int)TYPE_ALIGN (type))
  15552. + {
  15553. + type = build_variant_type_copy (type);
  15554. + TYPE_ALIGN (type) = boundary;
  15555. + }
  15556. +
  15557. + size = int_size_in_bytes (type);
  15558. +
  15559. + boundary /= BITS_PER_UNIT;
  15560. + if (boundary > PARM_BYTE_BOUNDARY && size > 0)
  15561. + {
  15562. + tree u;
  15563. +
  15564. + u = fold_convert (valist_type, size_int (size));
  15565. + t = build2 (MINUS_EXPR, valist_type, valist, u);
  15566. +
  15567. + u = fold_convert (valist_type, size_int (-boundary));
  15568. + t = build2 (BIT_AND_EXPR, valist_type, t, u);
  15569. + }
  15570. + else if (boundary == PARM_BYTE_BOUNDARY && size > 0)
  15571. + {
  15572. + tree u;
  15573. +
  15574. + u = fold_convert (valist_type, size_int (PARM_BYTE_BOUNDARY));
  15575. + t = build2 (MINUS_EXPR, valist_type, valist, u);
  15576. + }
  15577. + else if (boundary == PARM_BYTE_BOUNDARY && size == 0)
  15578. + t = valist;
  15579. + else
  15580. + gcc_unreachable ();
  15581. +
  15582. + t = build2 (MODIFY_EXPR, valist_type, valist, t);
  15583. +
  15584. + t = fold_convert (ptr, t);
  15585. +
  15586. + if (indirect)
  15587. + t = build_va_arg_indirect_ref (t);
  15588. +
  15589. + return build_va_arg_indirect_ref (t);
  15590. +}
  15591. +
  15592. +#undef PARM_BYTE_BOUNDARY
  15593. +
  15594. +/* True if MODE is valid for the target. By "valid", we mean able to
  15595. + be manipulated in non-trivial ways. In particular, this means all
  15596. + the arithmetic is supported.
  15597. +
  15598. + Currently, TImode is not valid
  15599. + Thus, we return false when PRECISION is 2 * BITS_PER_WORD and
  15600. + 2 * BITS_PER_WORD isn't equal LONG_LONG_TYPE_SIZE.
  15601. +*/
  15602. +
  15603. +bool
  15604. +metag_scalar_mode_supported_p (enum machine_mode mode)
  15605. +{
  15606. + int precision = GET_MODE_PRECISION (mode);
  15607. +
  15608. + switch (GET_MODE_CLASS (mode))
  15609. + {
  15610. + case MODE_PARTIAL_INT:
  15611. + case MODE_INT:
  15612. + if (precision == CHAR_TYPE_SIZE)
  15613. + return true;
  15614. + if (precision == SHORT_TYPE_SIZE)
  15615. + return true;
  15616. + if (precision == INT_TYPE_SIZE)
  15617. + return true;
  15618. + if (precision == LONG_TYPE_SIZE)
  15619. + return true;
  15620. + if (precision == LONG_LONG_TYPE_SIZE)
  15621. + return true;
  15622. + return false;
  15623. +
  15624. + case MODE_FLOAT:
  15625. + if (precision == FLOAT_TYPE_SIZE)
  15626. + return true;
  15627. + if (precision == DOUBLE_TYPE_SIZE)
  15628. + return true;
  15629. + if (precision == LONG_DOUBLE_TYPE_SIZE)
  15630. + return true;
  15631. + return false;
  15632. +
  15633. + case MODE_DECIMAL_FLOAT:
  15634. + return false;
  15635. +
  15636. + default:
  15637. + gcc_unreachable ();
  15638. + }
  15639. +}
  15640. +
  15641. +enum reg_class
  15642. +metag_secondary_reload (bool in_p, rtx x, enum reg_class class,
  15643. + enum machine_mode mode, secondary_reload_info *sri)
  15644. +{
  15645. + return default_secondary_reload (in_p, x, class, mode, sri);
  15646. +}
  15647. +
  15648. +enum reg_class
  15649. +metag_secondary_reload_class (enum reg_class class, enum machine_mode mode, rtx x, bool in_p)
  15650. +{
  15651. + if (in_p)
  15652. + {
  15653. + if (reg_class_subset_p (FPC_REGS, class))
  15654. + {
  15655. + switch (GET_CODE (x))
  15656. + {
  15657. + case SYMBOL_REF:
  15658. + case CONST_INT:
  15659. + case CONST:
  15660. + return GENERAL_REGS;
  15661. +
  15662. + case SUBREG:
  15663. + if (metag_fpu_resources)
  15664. + {
  15665. + x = SUBREG_REG (x);
  15666. +
  15667. + if (!metag_hard_genreg_op (x, VOIDmode))
  15668. + return D_REGS;
  15669. + }
  15670. +
  15671. + break;
  15672. +
  15673. + /* We can only reload from memory if it's 32 or 64 bit */
  15674. + /* 12bit offsets are not supported for FX registers either */
  15675. + case MEM:
  15676. + if (mode != SImode && mode != DImode
  15677. + && GET_MODE_CLASS (mode) != MODE_FLOAT)
  15678. + return D_REGS;
  15679. +
  15680. + if (GET_CODE (XEXP (x, 0)) == PLUS
  15681. + && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
  15682. + {
  15683. + HOST_WIDE_INT offset = INTVAL (XEXP (XEXP (x, 0), 1));
  15684. +
  15685. + if (offset / GET_MODE_SIZE (mode) >= 32
  15686. + || offset / GET_MODE_SIZE (mode) < -32)
  15687. + return D_REGS;
  15688. + }
  15689. +
  15690. + if (metag_fpu_resources && SYMBOL_REF_P (XEXP (x, 0)))
  15691. + return D_REGS;
  15692. +
  15693. + /* With only single precision hard-float we must not reload
  15694. + direct to FX registers for DFmode values*/
  15695. + if (metag_fpu_resources && metag_fpu_single && mode == DFmode)
  15696. + return D_REGS;
  15697. +
  15698. + break;
  15699. +
  15700. + /* We can reload const_double to FX but only if it's a half precision,
  15701. + * otherwise we must use GENERAL_REGS
  15702. + */
  15703. + case CONST_DOUBLE:
  15704. + if (metag_fpu_resources
  15705. + && (GET_MODE_CLASS (mode) != MODE_FLOAT
  15706. + || !metag_fphalf_imm_op (x, mode)
  15707. + || (metag_fpu_single
  15708. + && mode == DFmode)))
  15709. + return D_REGS;
  15710. +
  15711. + break;
  15712. +
  15713. + /* Theres no connection from A0/A1 to/from FX */
  15714. + case REG:
  15715. + if (metag_fpu_resources && METAG_ADDR_REG_P (true_regnum (x)))
  15716. + return D_REGS;
  15717. +
  15718. + break;
  15719. +
  15720. + case PLUS:
  15721. + if (metag_fpu_resources && GET_MODE_CLASS (mode) != MODE_FLOAT)
  15722. + return DA_REGS;
  15723. +
  15724. + break;
  15725. +
  15726. + default:
  15727. + break;
  15728. + }
  15729. + }
  15730. + else if (reg_class_subset_p (A0_REGS, class)
  15731. + || reg_class_subset_p (A1_REGS, class))
  15732. + {
  15733. + /* We have some restrictions on copying to A0/A1 with respect
  15734. + * to floating point
  15735. + */
  15736. + switch (GET_CODE (x))
  15737. + {
  15738. + /* Theres no connection from A0/A1 to/from FX */
  15739. + case REG:
  15740. + if (metag_fpu_resources && METAG_FPC_REG_P (true_regnum (x)))
  15741. + return D_REGS;
  15742. +
  15743. + break;
  15744. +
  15745. + default:
  15746. + break;
  15747. + }
  15748. + }
  15749. + }
  15750. + else
  15751. + {
  15752. + if (reg_class_subset_p (FPC_REGS, class))
  15753. + {
  15754. + switch (GET_CODE (x))
  15755. + {
  15756. + /* Theres no connection from A0/A1 to/from FX */
  15757. + case REG:
  15758. + if (metag_fpu_resources && METAG_ADDR_REG_P (true_regnum (x)))
  15759. + return D_REGS;
  15760. +
  15761. + break;
  15762. +
  15763. + case SUBREG:
  15764. + if (metag_fpu_resources)
  15765. + {
  15766. + x = SUBREG_REG (x);
  15767. +
  15768. + if (!metag_hard_genreg_op (x, VOIDmode))
  15769. + return D_REGS;
  15770. + }
  15771. +
  15772. + break;
  15773. +
  15774. + /* We can only reload to memory if it's 32 or 64 bit */
  15775. + /* 12bit offsets are not supported for FX registers either */
  15776. + case MEM:
  15777. + if (mode != SImode && mode != DImode
  15778. + && GET_MODE_CLASS (mode) != MODE_FLOAT)
  15779. + return D_REGS;
  15780. +
  15781. + if (GET_CODE (XEXP (x, 0)) == PLUS
  15782. + && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
  15783. + {
  15784. + HOST_WIDE_INT offset = INTVAL (XEXP (XEXP (x, 0), 1));
  15785. +
  15786. + if (offset / GET_MODE_SIZE (mode) >= 32
  15787. + || offset / GET_MODE_SIZE (mode) < -32)
  15788. + return D_REGS;
  15789. + }
  15790. +
  15791. + if (metag_fpu_resources && SYMBOL_REF_P (XEXP (x, 0)))
  15792. + return D_REGS;
  15793. +
  15794. + /* With only single precision hard-float we must not reload
  15795. + direct to FX registers for DFmode values*/
  15796. + if (metag_fpu_resources && metag_fpu_single && mode == DFmode)
  15797. + return D_REGS;
  15798. +
  15799. + break;
  15800. +
  15801. + case PLUS:
  15802. + if (metag_fpu_resources && GET_MODE_CLASS (mode) != MODE_FLOAT)
  15803. + return DA_REGS;
  15804. +
  15805. + break;
  15806. +
  15807. + default:
  15808. + break;
  15809. + }
  15810. + }
  15811. + else if (reg_class_subset_p (A0_REGS, class)
  15812. + || reg_class_subset_p (A1_REGS, class))
  15813. + {
  15814. + /* We have some restrictions on copying to A0/A1 with respect
  15815. + * to floating point
  15816. + */
  15817. + switch (GET_CODE (x))
  15818. + {
  15819. + /* Theres no connection from A0/A1 to/from FX */
  15820. + case REG:
  15821. + if (metag_fpu_resources && METAG_FPC_REG_P (true_regnum (x)))
  15822. + return D_REGS;
  15823. +
  15824. + break;
  15825. +
  15826. + default:
  15827. + break;
  15828. + }
  15829. + }
  15830. +
  15831. + if (MEM_P (x))
  15832. + {
  15833. + rtx addr = XEXP (x, 0);
  15834. +
  15835. + switch (GET_CODE (addr))
  15836. + {
  15837. + case PRE_MODIFY:
  15838. + case POST_MODIFY:
  15839. + addr = XEXP (addr, 0);
  15840. + break;
  15841. + default:
  15842. + break;
  15843. + }
  15844. +
  15845. + if (GET_CODE (addr) == PLUS)
  15846. + {
  15847. + rtx op0 = XEXP (addr, 0);
  15848. + rtx op1 = XEXP (addr, 1);
  15849. +
  15850. + if (REG_P (op0) && REG_P (op1))
  15851. + {
  15852. + int regno = true_regnum (op0);
  15853. +
  15854. + switch (METAG_REGNO_REG_CLASS (regno))
  15855. + {
  15856. + case A0_REGS:
  15857. + if (reg_class_subset_p (A0_REGS, class))
  15858. + {
  15859. + switch (mode)
  15860. + {
  15861. + case QImode:
  15862. + case HImode:
  15863. + case SImode:
  15864. + case SFmode:
  15865. + return nA0_REGS;
  15866. + case V2SFmode:
  15867. + return FPC_REGS;
  15868. + default:
  15869. + break;
  15870. + }
  15871. +
  15872. + return D_REGS;
  15873. + }
  15874. + break;
  15875. + case A1_REGS:
  15876. + if (reg_class_subset_p (A1_REGS, class))
  15877. + {
  15878. + switch (mode)
  15879. + {
  15880. + case QImode:
  15881. + case HImode:
  15882. + case SImode:
  15883. + case SFmode:
  15884. + return nA1_REGS;
  15885. + case V2SFmode:
  15886. + return FPC_REGS;
  15887. + default:
  15888. + break;
  15889. + }
  15890. +
  15891. + return D_REGS;
  15892. + }
  15893. + break;
  15894. + case D0_REGS:
  15895. + if (reg_class_subset_p (D0_REGS, class))
  15896. + {
  15897. + switch (mode)
  15898. + {
  15899. + case QImode:
  15900. + case HImode:
  15901. + case SImode:
  15902. + case SFmode:
  15903. + return nD0_REGS;
  15904. + case V2SFmode:
  15905. + return FPC_REGS;
  15906. + default:
  15907. + break;
  15908. + }
  15909. +
  15910. + return A_REGS;
  15911. + }
  15912. + break;
  15913. + case D1_REGS:
  15914. + if (reg_class_subset_p (D1_REGS, class))
  15915. + {
  15916. + switch (mode)
  15917. + {
  15918. + case QImode:
  15919. + case HImode:
  15920. + case SImode:
  15921. + case SFmode:
  15922. + return nD1_REGS;
  15923. + case V2SFmode:
  15924. + return FPC_REGS;
  15925. + default:
  15926. + break;
  15927. + }
  15928. +
  15929. + return A_REGS;
  15930. + }
  15931. + break;
  15932. + default:
  15933. + break;
  15934. + }
  15935. + }
  15936. + }
  15937. + }
  15938. + }
  15939. +
  15940. + return NO_REGS;
  15941. +}
  15942. +
  15943. +/* Output code to add DELTA to the first argument, and then jump
  15944. + to FUNCTION. Used for C++ multiple inheritance. */
  15945. +
  15946. +void
  15947. +metag_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
  15948. + HOST_WIDE_INT delta,
  15949. + HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
  15950. + tree function)
  15951. +{
  15952. + unsigned int this_regno = MAX_METAG_PARM_REGNUM; /* "this" */
  15953. +
  15954. + /* This 1st argument is "this" unless thunk returns the result in memory,
  15955. + in which case there is a hidden 1st argument we contains a pointer to
  15956. + where the result should be stored. */
  15957. + if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)), function))
  15958. + this_regno--;
  15959. +
  15960. + /* Add delta to "this" */
  15961. + if (satisfies_constraint_I (GEN_INT (delta)))
  15962. + asm_fprintf (file, "\tADD\t%r, %r, #%wd\n", this_regno, this_regno, delta);
  15963. + else if (satisfies_constraint_I (GEN_INT (-delta)))
  15964. + asm_fprintf (file, "\tSUB\t%r, %r, #%wd\n", this_regno, this_regno, -delta);
  15965. + else if (satisfies_constraint_K (GEN_INT (delta)))
  15966. + asm_fprintf (file, "\tADD\t%r, %r, #%wd\n", this_regno, this_regno, delta);
  15967. + else if (satisfies_constraint_K (GEN_INT (-delta)))
  15968. + asm_fprintf (file, "\tSUB\t%r, %r, #%wd\n", this_regno, this_regno, -delta);
  15969. + else if ((delta & 0x0000FFFF) == 0)
  15970. + asm_fprintf (file, "\tADDT\t%r, %r, #HI(%wd)\n", this_regno, this_regno, delta);
  15971. + else if (((-delta) & 0x0000FFFF) == 0)
  15972. + asm_fprintf (file, "\tSUBT\t%r, %r, #HI(%wd)\n", this_regno, this_regno, -delta);
  15973. + else if ((delta & 0xFFFF0000) == 0)
  15974. + asm_fprintf (file, "\tADD\t%r, %r, #LO(%wd)\n", this_regno, this_regno, delta);
  15975. + else if (((-delta) & 0xFFFF0000) == 0)
  15976. + asm_fprintf (file, "\tSUB\t%r, %r, #LO(%wd)\n", this_regno, this_regno, -delta);
  15977. + else
  15978. + {
  15979. + asm_fprintf (file, "\tADDT\t%r, %r, #HI(%wd)\n", this_regno, this_regno, delta);
  15980. + asm_fprintf (file, "\tADD\t%r, %r, #LO(%wd)\n", this_regno, this_regno, delta);
  15981. + }
  15982. +
  15983. + /* If needed, add *(*THIS + VCALL_OFFSET) to THIS. */
  15984. + if (vcall_offset != 0)
  15985. + {
  15986. + unsigned int temp1 = D0_0_REG;
  15987. + unsigned int temp2 = D1_0_REG;
  15988. +
  15989. + /* Set TEMP1 to *THIS. */
  15990. + asm_fprintf (file, "\tGETD\t%r, [%r]\n", temp1, this_regno);
  15991. +
  15992. + /* Load the offset from (TEMP1 + VCALL_OFFSET) in TEMP2 ... */
  15993. + if (-128 <= vcall_offset && vcall_offset <= 124)
  15994. + asm_fprintf (file, "\tGETD\t%r, [%r+#(%wd)]\n", temp2, temp1, vcall_offset);
  15995. + else
  15996. + {
  15997. + if (satisfies_constraint_I (GEN_INT (vcall_offset)))
  15998. + asm_fprintf (file, "\tADD\t%r, %r, #%wd\n", temp1, temp1, vcall_offset);
  15999. + else if (satisfies_constraint_I (GEN_INT (-vcall_offset)))
  16000. + asm_fprintf (file, "\tSUB\t%r, %r, #%wd\n", temp1, temp1, -vcall_offset);
  16001. + else if (satisfies_constraint_K (GEN_INT (vcall_offset)))
  16002. + asm_fprintf (file, "\tADD\t%r, %r, #%wd\n", temp1, temp1, vcall_offset);
  16003. + else if (satisfies_constraint_K (GEN_INT (-vcall_offset)))
  16004. + asm_fprintf (file, "\tSUB\t%r, %r, #%wd\n", temp1, temp1, -vcall_offset);
  16005. + else if ((vcall_offset & 0x0000FFFF) == 0)
  16006. + asm_fprintf (file, "\tADDT\t%r, %r, #HI(%wd)\n", temp1, temp1, vcall_offset);
  16007. + else if (((-vcall_offset) & 0x0000FFFF) == 0)
  16008. + asm_fprintf (file, "\tSUBT\t%r, %r, #HI(%wd)\n", temp1, temp1, -vcall_offset);
  16009. + else if ((vcall_offset & 0xFFFF0000) == 0)
  16010. + asm_fprintf (file, "\tADD\t%r, %r, #LO(%wd)\n", temp1, temp1, vcall_offset);
  16011. + else if (((-vcall_offset) & 0xFFFF0000) == 0)
  16012. + asm_fprintf (file, "\tSUB\t%r, %r, #LO(%wd)\n", temp1, temp1, -vcall_offset);
  16013. + else
  16014. + {
  16015. + asm_fprintf (file, "\tADDT\t%r, %r, #HI(%wd)\n", temp1, temp1, vcall_offset);
  16016. + asm_fprintf (file, "\tADD\t%r, %r, #LO(%wd)\n", temp1, temp1, vcall_offset);
  16017. + }
  16018. +
  16019. + asm_fprintf (file, "\tGETD\t%r, [%r]\n", temp2, temp1);
  16020. + }
  16021. +
  16022. + /* ... and add it to THIS. */
  16023. + asm_fprintf (file, "\tADD\t%r, %r, %r\n", this_regno, this_regno, temp2);
  16024. + }
  16025. +
  16026. + fputs ("\tB\t", file);
  16027. + {
  16028. + rtx symbol = XEXP (DECL_RTL (function), 0);
  16029. +
  16030. + gcc_assert (SYMBOL_REF_P (symbol));
  16031. +
  16032. + assemble_name (file, XSTR (symbol, 0));
  16033. + if (METAG_FLAG_PIC && !SYMBOL_REF_LOCAL_P (symbol))
  16034. + fputs ("@PLT", file);
  16035. + }
  16036. + fputc ('\n', file);
  16037. +}
  16038. +
  16039. +bool
  16040. +metag_can_output_mi_thunk (tree thunk_decl ATTRIBUTE_UNUSED,
  16041. + HOST_WIDE_INT delta ATTRIBUTE_UNUSED,
  16042. + HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
  16043. + tree function_decl ATTRIBUTE_UNUSED)
  16044. +{
  16045. + return true;
  16046. +}
  16047. +
  16048. +bool
  16049. +metag_handle_option (size_t code, const char *arg, int value)
  16050. +{
  16051. + switch (code)
  16052. + {
  16053. + case OPT_mhard_float:
  16054. + {
  16055. + int length = strlen(arg);
  16056. +
  16057. + metag_fpureg_string = "16";
  16058. + metag_fpu_resources = 1;
  16059. +
  16060. + /* Turn off SIMD float whenever we see a hardfloat option */
  16061. + target_flags &= ~MASK_FPU_SIMD;
  16062. +
  16063. + if (length == 0)
  16064. + metag_fpu_single = 0;
  16065. + else if (length == 2 && arg[0] == '=')
  16066. + if (arg[1] == 'S')
  16067. + metag_fpu_single = 1;
  16068. + else if (arg[1] == 'D')
  16069. + metag_fpu_single = 0;
  16070. + else
  16071. + error("-mhard-float takes an optional argument of S or D. E.g. -mhard-float=S");
  16072. + /* If set to none then just use soft float */
  16073. + else if (length == 5 && strncmp ("none", &arg[1], 4) == 0)
  16074. + {
  16075. + metag_fpu_resources = 0;
  16076. + metag_fpureg_string = "";
  16077. + target_flags &= ~MASK_FPU;
  16078. + }
  16079. + else
  16080. + error("-mhard-float takes an optional argument of S or D. E.g. -mhard-float=S");
  16081. + }
  16082. + break;
  16083. +
  16084. + case OPT_msoft_float:
  16085. + target_flags &= ~MASK_FPU_SIMD;
  16086. + break;
  16087. +
  16088. + case OPT_mdsp:
  16089. + if (value)
  16090. + metag_extreg_string = "8844";
  16091. + else
  16092. + metag_extreg_string = "0000";
  16093. + break;
  16094. +
  16095. + case OPT_mwidth_:
  16096. + {
  16097. + metag_memory_width = strtol (metag_width_string, NULL, 10);
  16098. + if (metag_memory_width != 32
  16099. + && metag_memory_width != 64)
  16100. + error ("Invalid memory width specified. Permitted widths are 32 or 64.");
  16101. + }
  16102. + break;
  16103. +
  16104. + case OPT_mjump_table_branch_:
  16105. + {
  16106. + if (strncmp (metag_jump_table_string, "short", 5) == 0)
  16107. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_SHORT;
  16108. + else if (strncmp (metag_jump_table_string, "long", 4) == 0)
  16109. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_LONG;
  16110. + else if (strncmp (metag_jump_table_string, "auto", 4) == 0)
  16111. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_AUTO;
  16112. + else
  16113. + error ("-mjump-table-branch must be either 'long', 'short' or 'auto'");
  16114. + }
  16115. + break;
  16116. +
  16117. + case OPT_mcond_exec:
  16118. + return true;
  16119. +
  16120. + case OPT_mextensions_:
  16121. + {
  16122. + char* extension = (char*)metag_extensions_string;
  16123. + int extension_length = 0;
  16124. + unsigned int i;
  16125. + char* comma_position;
  16126. +
  16127. + for (i = 0 ; i < strlen(extension) ; i++)
  16128. + extension[i] = tolower (extension[i]);
  16129. +
  16130. + while (strlen(extension) != 0)
  16131. + {
  16132. + comma_position = strchr (metag_extensions_string, ',');
  16133. +
  16134. + if (comma_position == NULL)
  16135. + extension_length = strlen (extension);
  16136. + else
  16137. + extension_length = (comma_position-extension);
  16138. +
  16139. + if (strncmp (extension, "bex", (extension_length > 3) ? extension_length : 3) == 0)
  16140. + metag_meta2_bex_enabled = true;
  16141. + else /* Print the rest of the list in the warning */
  16142. + warning (0, "Instruction set extension not known in list: %s", extension);
  16143. +
  16144. + extension += extension_length;
  16145. + }
  16146. + }
  16147. + break;
  16148. +
  16149. + case OPT_mtbictxsave:
  16150. + metag_force_tbictxsave = value;
  16151. + break;
  16152. +
  16153. + case OPT_mhwtrace:
  16154. + if (!value)
  16155. + {
  16156. + target_flags &= ~MASK_HWTRACE_RETPC;
  16157. + target_flags &= ~MASK_HWTRACE_LEAF;
  16158. + }
  16159. + break;
  16160. +
  16161. + case OPT_mhwtrace_retpc:
  16162. + case OPT_mhwtrace_leaf:
  16163. + if (value)
  16164. + target_flags |= MASK_HWTRACE;
  16165. + break;
  16166. +
  16167. + default:
  16168. + break;
  16169. + }
  16170. +
  16171. + return metag_handle_option_per_os (code, arg, value);
  16172. +}
  16173. +
  16174. +bool
  16175. +metag_zeroextract_mask_p (rtx op0, rtx op1)
  16176. +{
  16177. + rtx value = GEN_INT (((1 << INTVAL (op0)) - 1) << INTVAL (op1));
  16178. +
  16179. + return satisfies_constraint_I (value) ||
  16180. + satisfies_constraint_P (value) ||
  16181. + satisfies_constraint_K (value) ||
  16182. + satisfies_constraint_J (value) ||
  16183. + satisfies_constraint_M (value) ||
  16184. + satisfies_constraint_N (value);
  16185. +}
  16186. +
  16187. +rtx
  16188. +metag_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED)
  16189. +{
  16190. + if (count != 0)
  16191. + return NULL_RTX;
  16192. +
  16193. + return get_hard_reg_initial_val (Pmode, RETURN_POINTER_REGNUM);
  16194. +}
  16195. +
  16196. +HOST_WIDE_INT
  16197. +metag_function_arg_boundary (enum machine_mode mode, tree type)
  16198. +{
  16199. + HOST_WIDE_INT size;
  16200. +
  16201. + if (type != NULL_TREE)
  16202. + size = int_size_in_bytes (type);
  16203. + else
  16204. + size = GET_MODE_BITSIZE (mode);
  16205. +
  16206. + if (size < 0)
  16207. + return BIGGEST_ALIGNMENT;
  16208. + else if (size > UNITS_PER_WORD)
  16209. + return BIGGEST_ALIGNMENT;
  16210. + else
  16211. + return PARM_BOUNDARY;
  16212. +}
  16213. +
  16214. +int
  16215. +metag_first_parm_offset (tree fndecl ATTRIBUTE_UNUSED)
  16216. +{
  16217. + if (cfun->machine->anonymous_args)
  16218. + return current_function_pretend_args_size
  16219. + - ALIGN_ON_STACK_BOUNDARY (current_function_pretend_args_size);
  16220. +
  16221. + return 0;
  16222. +}
  16223. +
  16224. +/* WORK NEEDED: Check that the condition for consumer is not always or never */
  16225. +
  16226. +bool
  16227. +metag_consumer_is_cond_p (rtx producer, rtx consumer)
  16228. +{
  16229. + return (GET_CODE (PATTERN (consumer)) == COND_EXEC)
  16230. + && (get_attr_ccstate (producer) == CCSTATE_SET);
  16231. +}
  16232. +
  16233. +bool
  16234. +metag_bypass_before_reload_p (rtx producer ATTRIBUTE_UNUSED, rtx consumer ATTRIBUTE_UNUSED)
  16235. +{
  16236. + return !reload_in_progress && !reload_completed;
  16237. +}
  16238. +
  16239. +int
  16240. +metag_consumer_stalls_from_load_multi (rtx producer, rtx consumer)
  16241. +{
  16242. + int opno;
  16243. + bool firstoperand = true;
  16244. + unsigned int penultimate_reg = INVALID_REGNUM;
  16245. + unsigned int last_reg = INVALID_REGNUM;
  16246. + int stalls = 0; /* Zero stalls to begin with */
  16247. +
  16248. + /* Extract the insn to iterate over the output operands */
  16249. + extract_insn (producer);
  16250. +
  16251. + for (opno = 0 ; opno < recog_data.n_operands ; opno++)
  16252. + {
  16253. + if (recog_data.operand_type[opno] == OP_OUT)
  16254. + {
  16255. + rtx op;
  16256. +
  16257. + /* Ignore the first output as it refers to the offset addition */
  16258. + if (firstoperand)
  16259. + {
  16260. + firstoperand = false;
  16261. + continue;
  16262. + }
  16263. +
  16264. + /* Find the output register number*/
  16265. + op = recog_data.operand[opno];
  16266. + if (SUBREG_P (op))
  16267. + op = SUBREG_REG (op);
  16268. +
  16269. + if (REG_P (op))
  16270. + {
  16271. + unsigned int regno = REGNO (op);
  16272. +
  16273. + if (IS_HARD_OR_VIRT_REGNO (regno))
  16274. + {
  16275. + /* Save the two highest numbered load destination register numbers. */
  16276. + if (last_reg == INVALID_REGNUM || regno > last_reg)
  16277. + {
  16278. + penultimate_reg = last_reg;
  16279. + last_reg = regno;
  16280. + }
  16281. + else if (penultimate_reg == INVALID_REGNUM || regno > penultimate_reg)
  16282. + penultimate_reg = regno;
  16283. + }
  16284. + }
  16285. + }
  16286. + }
  16287. +
  16288. + /* Both penultimate_reg and last_reg should have values now, if not there
  16289. + * is a big problem. */
  16290. + gcc_assert (penultimate_reg != INVALID_REGNUM && last_reg != INVALID_REGNUM);
  16291. +
  16292. + /* Extract the consumer to examine its operands. */
  16293. + extract_insn (consumer);
  16294. +
  16295. + /* If the consumer is an MSET it has to be handled differently... */
  16296. + if (store_multiop (PATTERN (consumer), VOIDmode))
  16297. + {
  16298. + unsigned int first_reg = INVALID_REGNUM;
  16299. + unsigned int second_reg = INVALID_REGNUM;
  16300. +
  16301. + /* For MSET instructions stalls only occur if:
  16302. + * 1) The penultimate load collides with the initial store
  16303. + * 2) The last load collides with the initial store
  16304. + * 3) The last load collides with the 2nd store
  16305. + */
  16306. + firstoperand = true;
  16307. + for (opno = 0 ; opno < recog_data.n_operands ; opno++)
  16308. + {
  16309. + if (recog_data.operand_type[opno] == OP_IN)
  16310. + {
  16311. + rtx op;
  16312. +
  16313. + /* Ignore the first input as it refers to the offset
  16314. + * addition. */
  16315. + if (firstoperand)
  16316. + {
  16317. + firstoperand = false;
  16318. + continue;
  16319. + }
  16320. +
  16321. + /* Find the input register number. */
  16322. + op = recog_data.operand[opno];
  16323. + if (SUBREG_P (op))
  16324. + op = SUBREG_REG (op);
  16325. +
  16326. + if (REG_P (op))
  16327. + {
  16328. + unsigned int regno = REGNO (op);
  16329. +
  16330. + if (IS_HARD_OR_VIRT_REGNO (regno))
  16331. + {
  16332. + /* Save the two lowest numbered store source register numbers. */
  16333. + if (first_reg == INVALID_REGNUM || regno < first_reg)
  16334. + {
  16335. + second_reg = first_reg;
  16336. + first_reg = regno;
  16337. + }
  16338. + else if (second_reg == INVALID_REGNUM || regno < second_reg)
  16339. + second_reg = regno;
  16340. + }
  16341. + }
  16342. + }
  16343. + }
  16344. +
  16345. + /* First and second regs should have valid numbers now. */
  16346. + gcc_assert (first_reg != INVALID_REGNUM
  16347. + && second_reg != INVALID_REGNUM);
  16348. +
  16349. + if (last_reg == first_reg)
  16350. + stalls = 2;
  16351. + else if (last_reg == second_reg || penultimate_reg == first_reg)
  16352. + stalls = 1;
  16353. + }
  16354. + else
  16355. + {
  16356. + /* For anything other than MSET we examine all input operands
  16357. + * and return a stall count if any operand collides with the
  16358. + * penultimate or last value loaded. */
  16359. + for (opno = 0 ; opno < recog_data.n_operands ; opno++)
  16360. + {
  16361. + if (recog_data.operand_type[opno] == OP_IN)
  16362. + {
  16363. + rtx op;
  16364. +
  16365. + /* Find the register number. */
  16366. + op = recog_data.operand[opno];
  16367. + if (SUBREG_P (op))
  16368. + op = SUBREG_REG (op);
  16369. +
  16370. + if (REG_P (op))
  16371. + {
  16372. + unsigned int regno = REGNO (op);
  16373. +
  16374. + if (IS_HARD_OR_VIRT_REGNO (regno))
  16375. + {
  16376. + /*
  16377. + * The consumer will stall for 2 cycles if it uses the last
  16378. + * register and 1 cycle if it uses the penultimate
  16379. + * register.
  16380. + */
  16381. + if (regno == last_reg)
  16382. + {
  16383. + stalls = 2;
  16384. + /* Maximum stalls, no point checking further. */
  16385. + break;
  16386. + }
  16387. + else if (regno == penultimate_reg)
  16388. + stalls = 1;
  16389. + }
  16390. + }
  16391. + }
  16392. + }
  16393. + }
  16394. +
  16395. + return stalls;
  16396. + }
  16397. +
  16398. +/* Detect if any of the output registers of producer are used
  16399. + * as an O2R input of consumer
  16400. + *
  16401. + * op1 identifies the operand that may be o2r
  16402. + * op2 identifies the operand to check for a mismatch in units. */
  16403. +
  16404. +bool
  16405. +metag_consumer_is_o2r (rtx producer, rtx consumer, int op1, int op2)
  16406. +{
  16407. + enum reg_class o2rregclass = NO_REGS;
  16408. + enum reg_class op2regclass = NO_REGS;
  16409. + unsigned int o2rregno = INVALID_REGNUM;
  16410. + unsigned int op2regno = INVALID_REGNUM;
  16411. + rtx op;
  16412. +
  16413. + /* The registers aren't known until reload has completed. */
  16414. +
  16415. + if (!reload_completed)
  16416. + return false;
  16417. +
  16418. + extract_insn (consumer);
  16419. +
  16420. + if (recog_data.n_operands <= ((op1 > op2) ? op1 : op2)
  16421. + || recog_data.operand_type[op1] == OP_OUT)
  16422. + {
  16423. + /* Bad insn pattern. o2rhint attribute incorrect
  16424. + * o2rhint should say which operands must be in different units for
  16425. + * insn to have an O2R operand generated. both operands must be
  16426. + * IN or INOUT. */
  16427. + gcc_unreachable ();
  16428. + }
  16429. +
  16430. + /* Find the register class for op2. */
  16431. + op = recog_data.operand[op2];
  16432. + if (SUBREG_P (op))
  16433. + op = SUBREG_REG (op);
  16434. +
  16435. + if (REG_P (op))
  16436. + op2regno = REGNO (op);
  16437. +
  16438. + /* We should know the registers at this point. */
  16439. + gcc_assert (IS_HARD_OR_VIRT_REGNO (op2regno));
  16440. +
  16441. + op2regclass = METAG_REGNO_REG_CLASS (op2regno);
  16442. +
  16443. + /* Find the register number for op1. */
  16444. + op = recog_data.operand[op1];
  16445. + if (SUBREG_P (op))
  16446. + op = SUBREG_REG (op);
  16447. +
  16448. + if (REG_P (op))
  16449. + o2rregno = REGNO (op);
  16450. +
  16451. + /* We should know the register at this point. */
  16452. + gcc_assert (IS_HARD_OR_VIRT_REGNO (o2rregno));
  16453. +
  16454. + o2rregclass = METAG_REGNO_REG_CLASS (o2rregno);
  16455. +
  16456. + /* Check if op1 and op2 have different class registers. */
  16457. + if (op2regclass != o2rregclass)
  16458. + {
  16459. + int opno;
  16460. +
  16461. + /* We have an O2R operand in op1, check it against all OUT / INOUT
  16462. + * operands of producer. */
  16463. + extract_insn (producer);
  16464. +
  16465. + for (opno = 0 ; opno < recog_data.n_operands ; opno++)
  16466. + {
  16467. + if (recog_data.operand_type[opno] != OP_INOUT)
  16468. + {
  16469. + op = recog_data.operand[opno];
  16470. + if (SUBREG_P (op))
  16471. + op = SUBREG_REG (op);
  16472. +
  16473. + if (REG_P (op))
  16474. + {
  16475. + unsigned int regno = REGNO (op);
  16476. +
  16477. + /* We should know the register at this point. */
  16478. + gcc_assert (IS_HARD_OR_VIRT_REGNO (regno));
  16479. +
  16480. + if (regno == o2rregno)
  16481. + return true; /* Producer has output reg that feeds o2r
  16482. + operand in consumer. */
  16483. + }
  16484. + }
  16485. + }
  16486. + }
  16487. +
  16488. + return false;
  16489. +}
  16490. +
  16491. +bool
  16492. +metag_hard_regno_rename_ok_p (rtx insn,
  16493. + unsigned int from,
  16494. + unsigned int to)
  16495. +{
  16496. + /* Insn must have been recognised and rename permitted */
  16497. + if (INSN_CODE (insn) >= 0 && get_attr_rename (insn))
  16498. + {
  16499. + if (cfun->machine->ech_ctx_required)
  16500. + /* Where an ECH context has been allocated, allow any
  16501. + hard register to be renamed */
  16502. + return from <= LAST_ADDR_REG && to <= LAST_ADDR_REG;
  16503. + else
  16504. + {
  16505. + /* When an ECH context has not been allocated, restrict
  16506. + rename to the GP register set, regardless of what
  16507. + registers are available */
  16508. + return from <= LAST_ADDR_REG
  16509. + && ((to < FIRST_ECH_DATA_REG)
  16510. + || (to >= FIRST_ADDR_REG
  16511. + && to < FIRST_ECH_ADDR_REG));
  16512. + }
  16513. + }
  16514. + else
  16515. + return false;
  16516. +}
  16517. +
  16518. +enum reg_class
  16519. +metag_regno_reg_class_minimal (unsigned int regno)
  16520. +{
  16521. + if (regno == D0_0_REG || regno == D0_1_REG)
  16522. + return Ye_REGS;
  16523. +
  16524. + if (regno == D1_0_REG || regno == D1_1_REG)
  16525. + return Yf_REGS;
  16526. +
  16527. + if (regno == A0_0_REG || regno == A0_1_REG)
  16528. + return Yh_REGS;
  16529. +
  16530. + if (regno == A1_0_REG || regno == A1_1_REG)
  16531. + return Yl_REGS;
  16532. +
  16533. + if (regno == A0_2_REG || regno == A0_3_REG)
  16534. + return WQh_REGS;
  16535. +
  16536. + if (regno == A1_2_REG || regno == A1_3_REG)
  16537. + return WQl_REGS;
  16538. +
  16539. + if (regno == ARG_POINTER_REGNUM || regno == FRAME_POINTER_REGNUM)
  16540. + return Yh_REGS;
  16541. +
  16542. + return metag_regno_reg_class_unit (regno);
  16543. +}
  16544. +
  16545. +enum reg_class
  16546. +metag_regno_reg_class_unit (unsigned int regno)
  16547. +{
  16548. + if (regno == HARD_FRAME_POINTER_REGNUM
  16549. + || regno == STACK_POINTER_REGNUM
  16550. + || regno == ARG_POINTER_REGNUM
  16551. + || regno == FRAME_POINTER_REGNUM)
  16552. + return A0_REGS;
  16553. +
  16554. + if (METAG_DATA_REG_P (regno))
  16555. + return (regno & 1) ? D1_REGS : D0_REGS;
  16556. +
  16557. + if (METAG_ADDR_REG_P (regno))
  16558. + return (regno & 1) ? A1_REGS : A0_REGS;
  16559. +
  16560. + if (METAG_FPC_REG_P (regno))
  16561. + return FPC_REGS;
  16562. +
  16563. + if (regno == CPC0_REG)
  16564. + return A0_REGS;
  16565. +
  16566. + if (regno == CPC1_REG)
  16567. + return A1_REGS;
  16568. +
  16569. + if (regno == PC_REG)
  16570. + return A_REGS;
  16571. +
  16572. + if (regno == TXRPT_REG || regno == TTREC_REG)
  16573. + return Wx_REGS;
  16574. +
  16575. + return NO_REGS;
  16576. +}
  16577. +
  16578. +/* Make the last instruction frame related and note that it performs
  16579. + the operation described by FRAME_PATTERN. */
  16580. +
  16581. +static void
  16582. +metag_set_frame_expr (rtx frame_pattern)
  16583. +{
  16584. + rtx insn = get_last_insn ();
  16585. +
  16586. + RTX_FRAME_RELATED_P (insn) = 1;
  16587. + if (frame_pattern != NULL_RTX)
  16588. + REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR,
  16589. + frame_pattern,
  16590. + REG_NOTES (insn));
  16591. +}
  16592. +
  16593. +/* Make the last instruction frame related. */
  16594. +
  16595. +static void
  16596. +metag_set_frame_related (void)
  16597. +{
  16598. + metag_set_frame_expr (NULL_RTX);
  16599. +}
  16600. +
  16601. +static void
  16602. +metag_push_frameregs (unsigned extras, unsigned int first_reg, unsigned int last_reg)
  16603. +{
  16604. + rtx basemem = gen_rtx_MEM (DImode, stack_pointer_rtx);
  16605. + unsigned int count = 0;
  16606. + unsigned int RegList[8];
  16607. + unsigned int *pRegList = RegList;
  16608. +
  16609. + {
  16610. + unsigned int regno;
  16611. +
  16612. + for (regno = first_reg; regno <= last_reg; regno += 2)
  16613. + if ((extras & REGNO_BIT (regno)) != 0)
  16614. + {
  16615. + gcc_assert (pRegList < &RegList[sizeof(RegList)/sizeof(RegList[0])]);
  16616. +
  16617. + *pRegList++ = regno;
  16618. + }
  16619. + }
  16620. +
  16621. + count = pRegList - RegList;
  16622. + gcc_assert (0 < count && count <= sizeof(RegList)/sizeof(RegList[0]));
  16623. +
  16624. + if (count == 1)
  16625. + {
  16626. + rtx frame_expr = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (3));
  16627. + rtx set;
  16628. +
  16629. + emit_insn (gen_rtx_SET (VOIDmode,
  16630. + gen_rtx_MEM (DImode,
  16631. + gen_rtx_POST_INC (Pmode,
  16632. + stack_pointer_rtx)),
  16633. + gen_rtx_REG (DImode, RegList[0])));
  16634. +
  16635. + /* Describe the above instruction to the Drwarf2 call frame unwinder. */
  16636. + set = gen_rtx_SET (VOIDmode,
  16637. + gen_rtx_MEM (SImode, stack_pointer_rtx),
  16638. + gen_rtx_REG (SImode, RegList[0]));
  16639. + XVECEXP (frame_expr, 0, 0) = set;
  16640. + RTX_FRAME_RELATED_P (set) = 1;
  16641. +
  16642. + set = gen_rtx_SET (VOIDmode,
  16643. + gen_rtx_MEM (SImode,
  16644. + plus_constant (stack_pointer_rtx,
  16645. + UNITS_PER_WORD)),
  16646. + gen_rtx_REG (SImode, RegList[0] + 1));
  16647. + XVECEXP (frame_expr, 0, 1) = set;
  16648. + RTX_FRAME_RELATED_P (set) = 1;
  16649. +
  16650. + set = gen_rtx_SET (VOIDmode,
  16651. + stack_pointer_rtx,
  16652. + plus_constant (stack_pointer_rtx,
  16653. + UNITS_PER_WORD * 2));
  16654. + XVECEXP (frame_expr, 0, 2) = set;
  16655. + RTX_FRAME_RELATED_P (set) = 1;
  16656. +
  16657. + metag_set_frame_expr (frame_expr);
  16658. + }
  16659. + else
  16660. + {
  16661. + rtx result = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (1 + count));
  16662. + rtx frame_expr = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (1 + count * 2));
  16663. + rtx set;
  16664. +
  16665. + set = gen_rtx_SET (VOIDmode,
  16666. + stack_pointer_rtx,
  16667. + plus_constant (stack_pointer_rtx,
  16668. + count * UNITS_PER_WORD * 2));
  16669. + XVECEXP (result, 0, 0) = set;
  16670. +
  16671. + set = copy_rtx (set);
  16672. + XVECEXP (frame_expr, 0, count * 2) = set;
  16673. + RTX_FRAME_RELATED_P (set) = 1;
  16674. +
  16675. + {
  16676. + unsigned int offset = 0;
  16677. + unsigned int i;
  16678. +
  16679. + for (i = 0; i < count; i++)
  16680. + {
  16681. + rtx addr = plus_constant (stack_pointer_rtx, i * UNITS_PER_WORD * 2);
  16682. + rtx mem = adjust_automodify_address_nv (basemem, DImode, addr, offset);
  16683. + rtx set;
  16684. + int j;
  16685. +
  16686. + set = gen_rtx_SET (VOIDmode, mem, gen_rtx_REG (DImode, RegList[i]));
  16687. + XVECEXP (result, 0, 1 + i) = set;
  16688. +
  16689. + for (j = 0; j < 2; j++)
  16690. + {
  16691. + set = gen_rtx_SET (VOIDmode,
  16692. + gen_rtx_MEM (SImode,
  16693. + plus_constant (stack_pointer_rtx,
  16694. + offset)),
  16695. + gen_rtx_REG (SImode, RegList[i] + j));
  16696. + XVECEXP (frame_expr, 0, i * 2 + j) = set;
  16697. + RTX_FRAME_RELATED_P (set) = 1;
  16698. +
  16699. + offset += UNITS_PER_WORD;
  16700. + }
  16701. + }
  16702. +
  16703. + emit_insn (result);
  16704. +
  16705. + metag_set_frame_expr (frame_expr);
  16706. + }
  16707. + }
  16708. +}
  16709. +
  16710. +void
  16711. +metag_expand_prologue (void)
  16712. +{
  16713. + unsigned int savesize_gp = 0;
  16714. + unsigned int savesize_eh = 0;
  16715. + unsigned int FP_SP_offset = 0;
  16716. + HOST_WIDE_INT size = get_frame_size ();
  16717. + unsigned int pretend_size = ALIGN_ON_STACK_BOUNDARY (current_function_pretend_args_size);
  16718. + unsigned int pretend_regs = pretend_size / UNITS_PER_WORD;
  16719. + unsigned int extras_gp = 0;
  16720. + unsigned int extras_eh = 0;
  16721. + unsigned int ech_ctx = 0;
  16722. + bool non_leaf = metag_non_leaf_function_p ();
  16723. + rtx use = NULL_RTX;
  16724. + bool loads_pic_register;
  16725. +
  16726. + /* Round size of local stack to preserve 64-bit alignments */
  16727. + size = ALIGN_ON_STACK_BOUNDARY (size + current_function_outgoing_args_size);
  16728. +
  16729. + /* Make pretend regs into the first non-varargs register number */
  16730. + pretend_regs += MIN_METAG_PARM_REGNUM;
  16731. +
  16732. + {
  16733. + unsigned int regno;
  16734. +
  16735. + for (regno = MIN_METAG_PARM_REGNUM; regno <= MAX_METAG_CSAVE_REGNUM; regno += 2)
  16736. + {
  16737. + if (regno < pretend_regs
  16738. + || (!call_used_regs[regno]
  16739. + && (df_regs_ever_live_p (regno + 0) || df_regs_ever_live_p (regno + 1))))
  16740. + {
  16741. + /* Push this data register */
  16742. + savesize_gp += UNITS_PER_WORD * 2;
  16743. + extras_gp |= REGNO_BIT (regno);
  16744. +
  16745. + if (regno >= MIN_METAG_CSAVE_REGNUM)
  16746. + FP_SP_offset += UNITS_PER_WORD * 2;
  16747. + }
  16748. + }
  16749. + }
  16750. +
  16751. + /* Adjust the saved registers for ECH support */
  16752. + ech_ctx = metag_adjust_savesize_ech (&savesize_gp, &extras_gp, &FP_SP_offset);
  16753. +
  16754. + /* Recover original pretend regs */
  16755. + pretend_regs -= MIN_METAG_PARM_REGNUM;
  16756. +
  16757. + if (cfun->tail_call_emit && cfun->machine->hwtrace_leaf)
  16758. + {
  16759. + /* The entry point of a function that ends in a tail call needs to be
  16760. + marked up when tracing all functions */
  16761. +
  16762. + emit_insn (gen_ttmov_si (gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM),
  16763. + gen_rtx_REG (SImode, RETURN_POINTER_REGNUM)));
  16764. + }
  16765. + else if (!frame_pointer_needed && cfun->machine->hwtrace_leaf)
  16766. + {
  16767. + /* The entry point of all functions need to be marked up when tracing
  16768. + all functions regardless of whether the frame pointer is omitted.
  16769. + Handle the case where the frame pointer is omitted here. See below
  16770. + for other case. */
  16771. +
  16772. + emit_insn (gen_ttmov_si (gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM),
  16773. + hard_frame_pointer_rtx));
  16774. +
  16775. + /* This is NOT frame related because there is no frame pointer really */
  16776. + }
  16777. +
  16778. + if (frame_pointer_needed || non_leaf)
  16779. + {
  16780. + if (non_leaf)
  16781. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  16782. +
  16783. + /* Save return address and maybe frame pointer via {D0Frt,D1RtP} pair */
  16784. + savesize_gp += UNITS_PER_WORD * 2;
  16785. + FP_SP_offset += UNITS_PER_WORD * 2;
  16786. +
  16787. + if (frame_pointer_needed)
  16788. + {
  16789. + /* Need to spill A0FrP ready for saving and calc new frame */
  16790. + if (cfun->machine->hwtrace)
  16791. + {
  16792. + rtx frame_expr;
  16793. + /* Mark up function entry when frame pointer is not omitted, for all
  16794. + types of H/W tracing */
  16795. + emit_insn (gen_ttmov_si (gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM),
  16796. + hard_frame_pointer_rtx));
  16797. + frame_expr = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM),
  16798. + hard_frame_pointer_rtx);
  16799. + RTX_FRAME_RELATED_P (frame_expr) = 1;
  16800. + metag_set_frame_expr (frame_expr);
  16801. + }
  16802. + else
  16803. + {
  16804. + emit_insn (gen_rtx_SET (VOIDmode,
  16805. + gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM),
  16806. + hard_frame_pointer_rtx));
  16807. +
  16808. + metag_set_frame_related ();
  16809. + }
  16810. +
  16811. + /* Save return address and frame pointer via (D0FrT,D1RtP) pair */
  16812. + extras_gp |= REGNO_BIT (TEMP_D0FRT_REGNUM);
  16813. +
  16814. + emit_insn (gen_addsi3 (hard_frame_pointer_rtx,
  16815. + stack_pointer_rtx,
  16816. + gen_int_mode (pretend_size, SImode)));
  16817. + metag_set_frame_related ();
  16818. +
  16819. + use = hard_frame_pointer_rtx;
  16820. + }
  16821. + }
  16822. + else if (df_regs_ever_live_p (RETURN_POINTER_REGNUM))
  16823. + {
  16824. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  16825. +
  16826. + /* Have to do at least ine pop */
  16827. + savesize_gp += UNITS_PER_WORD * 2;
  16828. +
  16829. + if (RETURN_POINTER_REGNUM >= MIN_METAG_CSAVE_REGNUM)
  16830. + FP_SP_offset += UNITS_PER_WORD * 2;
  16831. + }
  16832. +
  16833. + if (current_function_calls_eh_return)
  16834. + {
  16835. + unsigned int n;
  16836. +
  16837. + for (n = 0; n < NUM_EH_RETURN_DATA_REGS; n++)
  16838. + {
  16839. + unsigned int regno = EH_RETURN_DATA_REGNO (n);
  16840. +
  16841. + if (regno != INVALID_REGNUM)
  16842. + {
  16843. + unsigned int regbit = REGNO_BIT (regno);
  16844. +
  16845. + if ((extras_eh & regbit) == 0)
  16846. + {
  16847. + extras_eh |= regbit;
  16848. + savesize_eh += UNITS_PER_WORD * 2;
  16849. + FP_SP_offset += UNITS_PER_WORD * 2;
  16850. + }
  16851. + }
  16852. + }
  16853. + }
  16854. +
  16855. + loads_pic_register = METAG_CURRENT_FUNCTION_LOADS_PIC_REGISTER ();
  16856. + if (loads_pic_register)
  16857. + FP_SP_offset += UNITS_PER_WORD * 2;/* Save PIC register. */
  16858. +
  16859. + /* Sanity checks between initial_elimination and prologue. If these
  16860. + tests fail then the generated code will be wrong so abort. */
  16861. +
  16862. + gcc_assert (cfun->machine->valid);
  16863. +
  16864. + gcc_assert (cfun->machine->savesize_gp == savesize_gp);
  16865. + gcc_assert (cfun->machine->savesize_eh == savesize_eh);
  16866. + gcc_assert (cfun->machine->FP_SP_offset == FP_SP_offset);
  16867. + gcc_assert (cfun->machine->frame_pointer_needed == frame_pointer_needed);
  16868. + gcc_assert (cfun->machine->non_leaf == non_leaf);
  16869. + gcc_assert (cfun->machine->extras_gp == extras_gp);
  16870. + gcc_assert (cfun->machine->extras_eh == extras_eh);
  16871. + gcc_assert (cfun->machine->calls_eh_return == current_function_calls_eh_return);
  16872. + gcc_assert (cfun->machine->uses_pic_offset_table == current_function_uses_pic_offset_table);
  16873. + gcc_assert (cfun->machine->loads_pic_register == loads_pic_register);
  16874. + gcc_assert (cfun->machine->ech_ctx_required == (ech_ctx != 0));
  16875. +
  16876. + /* When ECH support is enabled, the register pair including D0.8 may be saved
  16877. + therefore include it in the initial push */
  16878. + if (extras_gp != 0)
  16879. + metag_push_frameregs (extras_gp, MIN_METAG_PARM_REGNUM, TARGET_ECH ?
  16880. + METAG_ECH_REGNUM :
  16881. + MAX_METAG_CSAVE_REGNUM);
  16882. +
  16883. + if (extras_eh != 0)
  16884. + metag_push_frameregs (extras_eh, EH_RETURN_FIRST_DATA_REG, EH_RETURN_LAST_DATA_REG);
  16885. +
  16886. + if (loads_pic_register)
  16887. + {
  16888. + rtx frame_expr = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
  16889. + rtx set;
  16890. +
  16891. + emit_insn (gen_rtx_SET (VOIDmode,
  16892. + gen_rtx_MEM (DImode,
  16893. + gen_rtx_POST_INC (Pmode,
  16894. + stack_pointer_rtx)),
  16895. + gen_rtx_UNSPEC (DImode,
  16896. + gen_rtvec (2,
  16897. + hard_frame_pointer_rtx,
  16898. + pic_offset_table_rtx),
  16899. + UNSPEC_CONCAT)));
  16900. +
  16901. + /* Describe the above instruction to the Dwarf2 call frame unwinder. */
  16902. +
  16903. + set = gen_rtx_SET (VOIDmode,
  16904. + gen_rtx_MEM (SImode,
  16905. + plus_constant (stack_pointer_rtx,
  16906. + UNITS_PER_WORD)),
  16907. + pic_offset_table_rtx);
  16908. + XVECEXP (frame_expr, 0, 0) = set;
  16909. + RTX_FRAME_RELATED_P (set) = 1;
  16910. +
  16911. + set = gen_rtx_SET (VOIDmode,
  16912. + stack_pointer_rtx,
  16913. + plus_constant (stack_pointer_rtx,
  16914. + 2 * UNITS_PER_WORD));
  16915. + XVECEXP (frame_expr, 0, 1) = set;
  16916. + RTX_FRAME_RELATED_P (set) = 1;
  16917. +
  16918. + metag_set_frame_expr (frame_expr);
  16919. + }
  16920. +
  16921. + /* Allocate local stack based storage */
  16922. + if (size != 0)
  16923. + {
  16924. + rtx frame_expr = gen_rtx_SET (VOIDmode,
  16925. + stack_pointer_rtx,
  16926. + plus_constant (stack_pointer_rtx,
  16927. + size));
  16928. +
  16929. + emit_insn (gen_addsi3 (stack_pointer_rtx,
  16930. + stack_pointer_rtx,
  16931. + gen_int_mode (size, SImode)));
  16932. +
  16933. + metag_set_frame_expr (frame_expr);
  16934. + }
  16935. +
  16936. + /* Initialise PIC register. */
  16937. + if (loads_pic_register)
  16938. + {
  16939. + emit_insn (gen_load_pic (pic_offset_table_rtx,
  16940. + gen_rtx_REG (SImode, CPC1_REG)));
  16941. + emit_insn (gen_prologue_use (pic_offset_table_rtx));
  16942. + }
  16943. +
  16944. + if (use != NULL_RTX)
  16945. + emit_insn (gen_prologue_use (use));
  16946. +
  16947. + if (ech_ctx != 0)
  16948. + {
  16949. + rtx reg_ech = gen_rtx_REG (SImode, METAG_ECH_REGNUM);
  16950. +
  16951. + /* Only store context if we used a register. The ECH register will be
  16952. + reset to zero by any system supporting ECH contexts prior to
  16953. + restoring the context for a process using ECH.
  16954. +
  16955. + We must always store the DX8 part of the context as ECH implicitly
  16956. + uses D0.8. */
  16957. +
  16958. + ech_ctx |= ((TBICTX_XMCC_BIT | TBICTX_XEXT_BIT | TBICTX_XDX8_BIT) << 16);
  16959. +
  16960. + /* GCC does not use DSP RAM so the lower 16 bits will be zero */
  16961. + gcc_assert ((ech_ctx & 0xFFFF) == 0);
  16962. +
  16963. + /* Guaranteed to have bottom 16bits zero, and hence will be set in a
  16964. + single instruction */
  16965. + emit_insn (gen_rtx_SET (SImode, reg_ech,
  16966. + gen_int_mode (ech_ctx, SImode)));
  16967. + emit_insn (gen_prologue_use (reg_ech));
  16968. +
  16969. + }
  16970. +
  16971. + emit_insn (gen_blockage ());
  16972. +}
  16973. +
  16974. +void
  16975. +metag_expand_epilogue (bool epilogue_for_tailcall)
  16976. +{
  16977. + unsigned int savesize_gp = 0;
  16978. + unsigned int savesize_eh = 0;
  16979. + unsigned int picsize = 0;
  16980. + unsigned int num_saved_regs = 0;
  16981. + unsigned int extras_gp = 0;
  16982. + unsigned int extras_eh = 0;
  16983. + unsigned int ech_ctx = 0;
  16984. + bool non_leaf = metag_non_leaf_function_p ();
  16985. + int pretend_size = ALIGN_ON_STACK_BOUNDARY (current_function_pretend_args_size);
  16986. + HOST_WIDE_INT size = get_frame_size ();
  16987. + unsigned int RegList[8];
  16988. + unsigned int *pRegList = RegList;
  16989. + bool loads_pic_register;
  16990. +
  16991. + emit_insn (gen_blockage ());
  16992. +
  16993. + /* Round size of local stack to preserve 64-bit alignments */
  16994. + size = ALIGN_ON_STACK_BOUNDARY (size + current_function_outgoing_args_size);
  16995. +
  16996. + /* Calculate number of registers to restore
  16997. + if they contain pretend args save all, else save registers with data in them */
  16998. + {
  16999. + unsigned int regno;
  17000. +
  17001. + for (regno = MIN_METAG_CSAVE_REGNUM; regno <= MAX_METAG_CSAVE_REGNUM; regno += 2)
  17002. + {
  17003. + if (!call_used_regs[regno]
  17004. + && (df_regs_ever_live_p(regno + 0) || df_regs_ever_live_p(regno + 1)))
  17005. + {
  17006. + /* Need to restore all normal Dx register pairs required */
  17007. + savesize_gp += UNITS_PER_WORD * 2;
  17008. + extras_gp |= REGNO_BIT (regno);
  17009. + }
  17010. + }
  17011. + }
  17012. +
  17013. + /* Adjust the saved registers for ECH support */
  17014. + ech_ctx = metag_adjust_savesize_ech (&savesize_gp, &extras_gp, NULL);
  17015. +
  17016. + /* No registers so far for MGETL|GETL */
  17017. +
  17018. + if (frame_pointer_needed || non_leaf)
  17019. + {
  17020. + /* Restore frame pointer via D0FRT or restore return address */
  17021. +
  17022. + if (non_leaf)
  17023. + {
  17024. + /* Have to get D1RtP back */
  17025. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  17026. + }
  17027. +
  17028. + if (frame_pointer_needed)
  17029. + {
  17030. + /* Must restore callers frame pointer */
  17031. + extras_gp |= REGNO_BIT (TEMP_D0FRT_REGNUM);
  17032. + }
  17033. +
  17034. + savesize_gp += UNITS_PER_WORD * 2;
  17035. + }
  17036. + else if (df_regs_ever_live_p (RETURN_POINTER_REGNUM))
  17037. + {
  17038. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  17039. +
  17040. + /* Have to do at least one pop */
  17041. + savesize_gp += UNITS_PER_WORD * 2;
  17042. + }
  17043. +
  17044. + if (current_function_calls_eh_return)
  17045. + {
  17046. + unsigned int n;
  17047. +
  17048. + for (n = 0; n < NUM_EH_RETURN_DATA_REGS; n++)
  17049. + {
  17050. + unsigned int regno = EH_RETURN_DATA_REGNO (n);
  17051. +
  17052. + if (regno != INVALID_REGNUM)
  17053. + {
  17054. + unsigned int regbit = REGNO_BIT (regno);
  17055. +
  17056. + if ((extras_eh & regbit) == 0)
  17057. + {
  17058. + extras_eh |= regbit;
  17059. + savesize_eh += UNITS_PER_WORD * 2;
  17060. + }
  17061. + }
  17062. + }
  17063. + }
  17064. +
  17065. + loads_pic_register = METAG_CURRENT_FUNCTION_LOADS_PIC_REGISTER ();
  17066. + if (loads_pic_register)
  17067. + picsize += UNITS_PER_WORD * 2;
  17068. +
  17069. + if (!frame_pointer_needed && size > 16352)
  17070. + {
  17071. + HOST_WIDE_INT excess = size & 0xFFFF0000;
  17072. +
  17073. + /* LCS is too big to use as direct offset for recovery */
  17074. + if (excess != 0)
  17075. + {
  17076. + emit_insn (gen_addsi3 (stack_pointer_rtx,
  17077. + stack_pointer_rtx,
  17078. + GEN_INT (-trunc_int_for_mode (excess, SImode))));
  17079. + size &= 0xFFFF;
  17080. + }
  17081. +
  17082. + if (size > 16352)
  17083. + {
  17084. + emit_insn (gen_addsi3 (stack_pointer_rtx,
  17085. + stack_pointer_rtx,
  17086. + GEN_INT (-trunc_int_for_mode (size, SImode))));
  17087. + size = 0;
  17088. + }
  17089. + }
  17090. +
  17091. + if (loads_pic_register)
  17092. + {
  17093. + if (frame_pointer_needed)
  17094. + emit_insn (gen_rtx_SET (VOIDmode,
  17095. + gen_rtx_UNSPEC (DImode,
  17096. + gen_rtvec (2,
  17097. + hard_frame_pointer_rtx,
  17098. + pic_offset_table_rtx),
  17099. + UNSPEC_CONCAT),
  17100. + gen_rtx_MEM (DImode,
  17101. + plus_constant (hard_frame_pointer_rtx,
  17102. + savesize_gp + savesize_eh))));
  17103. + else
  17104. + emit_insn (gen_rtx_SET (VOIDmode,
  17105. + gen_rtx_UNSPEC (DImode,
  17106. + gen_rtvec (2,
  17107. + hard_frame_pointer_rtx,
  17108. + pic_offset_table_rtx),
  17109. + UNSPEC_CONCAT),
  17110. + gen_rtx_MEM (DImode,
  17111. + plus_constant (stack_pointer_rtx,
  17112. + -(HOST_WIDE_INT)(size + picsize)))));
  17113. + }
  17114. +
  17115. + if (extras_eh != 0)
  17116. + {
  17117. + unsigned int delta = 0;
  17118. + unsigned int regno;
  17119. +
  17120. + for (regno = 0; regno < 32; regno += 2)
  17121. + {
  17122. + if ((extras_eh & REGNO_BIT (regno)) != 0)
  17123. + {
  17124. + if (frame_pointer_needed)
  17125. + {
  17126. + emit_insn (gen_rtx_SET (VOIDmode,
  17127. + gen_rtx_REG (DImode, regno),
  17128. + gen_rtx_MEM (DImode,
  17129. + plus_constant (hard_frame_pointer_rtx,
  17130. + savesize_gp + delta))));
  17131. + }
  17132. + else
  17133. + {
  17134. + HOST_WIDE_INT offset = -(HOST_WIDE_INT)(size + picsize + savesize_eh);
  17135. +
  17136. + emit_insn (gen_rtx_SET (VOIDmode,
  17137. + gen_rtx_REG (DImode, regno),
  17138. + gen_rtx_MEM (DImode,
  17139. + plus_constant (stack_pointer_rtx,
  17140. + offset + delta))));
  17141. + }
  17142. +
  17143. + delta += UNITS_PER_WORD * 2;
  17144. + }
  17145. + }
  17146. + }
  17147. +
  17148. + if (extras_gp != 0)
  17149. + {
  17150. + unsigned int regno;
  17151. +
  17152. + for (regno = MIN_METAG_PARM_REGNUM; regno < 32; regno += 2)
  17153. + {
  17154. + if ((extras_gp & REGNO_BIT (regno)) != 0)
  17155. + {
  17156. + HOST_WIDE_INT offset = -(HOST_WIDE_INT)(size + picsize + savesize_eh + savesize_gp);
  17157. +
  17158. + gcc_assert (pRegList < &RegList[sizeof(RegList)/sizeof(RegList[0])]);
  17159. +
  17160. + if (!frame_pointer_needed
  17161. + && (savesize_gp != UNITS_PER_WORD * 2 || pretend_size != 0 || (size + picsize) >= 256))
  17162. + {
  17163. + offset += num_saved_regs * UNITS_PER_WORD * 2;
  17164. +
  17165. + emit_insn (gen_rtx_SET (VOIDmode,
  17166. + gen_rtx_REG (DImode, regno),
  17167. + gen_rtx_MEM (DImode,
  17168. + plus_constant (stack_pointer_rtx,
  17169. + offset))));
  17170. + pRegList = RegList;
  17171. + }
  17172. + else if (!frame_pointer_needed)
  17173. + {
  17174. + /* Only one pair and no pretend args, pre-decrement stack! */
  17175. + emit_insn (gen_rtx_SET (VOIDmode,
  17176. + gen_rtx_REG (DImode, regno),
  17177. + gen_rtx_MEM (DImode,
  17178. + gen_rtx_PRE_MODIFY (Pmode,
  17179. + stack_pointer_rtx,
  17180. + plus_constant (stack_pointer_rtx,
  17181. + offset)))));
  17182. + pRegList = RegList;
  17183. +
  17184. + /* Stack predecremented above */
  17185. + size = -(HOST_WIDE_INT)(savesize_gp + savesize_eh + picsize);
  17186. + }
  17187. + else
  17188. + *pRegList++ = regno;
  17189. +
  17190. + /* Count them */
  17191. + num_saved_regs++;
  17192. + }
  17193. + }
  17194. + }
  17195. +
  17196. + /* Take account of pretend args stored on the stack by the prologue */
  17197. + savesize_gp += pretend_size;
  17198. +
  17199. + if (pRegList != RegList)
  17200. + {
  17201. + rtx basemem = gen_rtx_MEM (DImode, hard_frame_pointer_rtx);
  17202. + unsigned int count = pRegList - RegList;
  17203. +
  17204. + gcc_assert (count > 0);
  17205. +
  17206. + /* Use frame pointer to recover caller-saved regs */
  17207. + if (count == 1)
  17208. + {
  17209. + /* Only one pair needed, advance frame pointer */
  17210. + emit_insn (gen_rtx_SET (VOIDmode,
  17211. + gen_rtx_REG (DImode, RegList[0]),
  17212. + gen_rtx_MEM (DImode,
  17213. + gen_rtx_POST_INC (Pmode,
  17214. + hard_frame_pointer_rtx))));
  17215. + }
  17216. + else
  17217. + {
  17218. + rtx result = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (1 + count));
  17219. + unsigned int offset = 0;
  17220. + unsigned int i;
  17221. +
  17222. + XVECEXP (result, 0, 0) = gen_rtx_SET (VOIDmode,
  17223. + hard_frame_pointer_rtx,
  17224. + plus_constant (hard_frame_pointer_rtx,
  17225. + count * UNITS_PER_WORD * 2));
  17226. +
  17227. + for (i = 0; i < count; i++)
  17228. + {
  17229. + rtx addr = plus_constant (hard_frame_pointer_rtx, i * UNITS_PER_WORD * 2);
  17230. + rtx mem = adjust_automodify_address_nv (basemem, DImode, addr, offset);
  17231. +
  17232. + gcc_assert (i <= count);
  17233. +
  17234. + XVECEXP (result, 0, 1 + i) = gen_rtx_SET (VOIDmode,
  17235. + gen_rtx_REG (DImode, RegList[i]),
  17236. + mem);
  17237. + offset += UNITS_PER_WORD * 2;
  17238. + }
  17239. +
  17240. + emit_insn (result);
  17241. + }
  17242. +
  17243. + /* Use frame pointer to recover stack pointer */
  17244. + emit_insn (gen_addsi3 (stack_pointer_rtx,
  17245. + hard_frame_pointer_rtx,
  17246. + GEN_INT (-trunc_int_for_mode (savesize_gp, SImode))));
  17247. + }
  17248. + else if (frame_pointer_needed)
  17249. + {
  17250. + /* Use unmolested frame pointer to recover stack pointer */
  17251. + emit_insn (gen_addsi3 (stack_pointer_rtx,
  17252. + hard_frame_pointer_rtx,
  17253. + GEN_INT (-trunc_int_for_mode (pretend_size, SImode))));
  17254. + }
  17255. + else
  17256. + {
  17257. + HOST_WIDE_INT adjust = size + picsize + savesize_eh + savesize_gp;
  17258. +
  17259. + /* Calculate return stack adjustment directly including savesize */
  17260. +
  17261. + if (adjust != 0)
  17262. + emit_insn (gen_addsi3 (stack_pointer_rtx,
  17263. + stack_pointer_rtx,
  17264. + GEN_INT (-trunc_int_for_mode (adjust, SImode))));
  17265. + }
  17266. +
  17267. + /* We should be able to insert code here for EPILOGUE delay-slots if
  17268. + frame_pointer_needed. The next instruction will stall waiting
  17269. + for return data from the MGETL or GETL done above in this case. */
  17270. +
  17271. + if (frame_pointer_needed)
  17272. + {
  17273. + if (!cfun->machine->hwtrace || cfun->machine->hwtrace_retpc)
  17274. + {
  17275. + /* Restore callers frame pointer. The HWTRACE code below will take
  17276. + care of this when enabled, unless the RETPC method is being used,
  17277. + in which case it must be done here as normal. */
  17278. +
  17279. + emit_insn (gen_rtx_SET (VOIDmode,
  17280. + hard_frame_pointer_rtx,
  17281. + gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM)));
  17282. + }
  17283. + }
  17284. + else if ((!cfun->tail_call_emit || !epilogue_for_tailcall)
  17285. + && cfun->machine->hwtrace_leaf && cfun->machine->hwtrace_retpc
  17286. + && !non_leaf && df_regs_ever_live_p (TEMP_D0FRT_REGNUM))
  17287. + {
  17288. + /* When tracing all leaf functions with the RETPC method, and we are
  17289. + in a leaf function that has clobbered D0FrT and the frame pointer
  17290. + is not needed (and this function doesn't end in a sibcall)...
  17291. + Then D0FrT must be recovered from the frame pointer ready to be used
  17292. + below */
  17293. +
  17294. + emit_insn (gen_rtx_SET (VOIDmode,
  17295. + gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM),
  17296. + hard_frame_pointer_rtx));
  17297. + }
  17298. +
  17299. + if ((!cfun->tail_call_emit || !epilogue_for_tailcall)
  17300. + && cfun->machine->hwtrace_retpc)
  17301. + {
  17302. + /* The RETPC method of tracing is a MOVL TTREC, x,y. Emit one when
  17303. + the function does not end in a sibcall*/
  17304. +
  17305. + emit_insn (gen_ttrec (gen_rtx_REG (DImode, TTREC_REGNUM),
  17306. + gen_rtx_REG (DImode, TEMP_D0FRT_REGNUM)));
  17307. + }
  17308. + else if ((!cfun->tail_call_emit || !epilogue_for_tailcall)
  17309. + && cfun->machine->hwtrace
  17310. + && (frame_pointer_needed || cfun->machine->hwtrace_leaf))
  17311. + {
  17312. + /* The standard method of tracing is to mark up the FP restore with a
  17313. + TTMOV.
  17314. + This is done when tracing leaf functions or the frame pointer is
  17315. + needed. In the latter case this replaces the normal frame pointer
  17316. + restore from above. */
  17317. +
  17318. + emit_insn (gen_ttmov_si (hard_frame_pointer_rtx,
  17319. + gen_rtx_REG (SImode, TEMP_D0FRT_REGNUM)));
  17320. + }
  17321. +
  17322. + /* Returns to exception handlers require an additional stack adjustment. */
  17323. + if (current_function_calls_eh_return)
  17324. + emit_insn (gen_subsi3 (stack_pointer_rtx,
  17325. + stack_pointer_rtx,
  17326. + EH_RETURN_STACKADJ_RTX));
  17327. +
  17328. + return;
  17329. +}
  17330. +
  17331. +/* Return TRUE if it is possible to return using a simple return
  17332. + sequence instruction, possibly conditional. */
  17333. +
  17334. +bool
  17335. +metag_use_return_insn (bool cond)
  17336. +{
  17337. + if (! reload_completed)
  17338. + return false;
  17339. +
  17340. + if (current_function_profile)
  17341. + return false;
  17342. +
  17343. + if (current_function_calls_alloca)
  17344. + return false;
  17345. +
  17346. + if (current_function_calls_eh_return)
  17347. + return false;
  17348. +
  17349. + if (current_function_outgoing_args_size != 0)
  17350. + return false;
  17351. +
  17352. + if (current_function_pretend_args_size != 0)
  17353. + return false;
  17354. +
  17355. + if (cfun->machine->anonymous_args_size != 0)
  17356. + return false;
  17357. +
  17358. + if (cfun->machine->out_local_size != 0)
  17359. + return false;
  17360. +
  17361. + if (cfun->machine->savesize_gp != 0)
  17362. + return false;
  17363. +
  17364. + if (cfun->machine->loads_pic_register != 0)
  17365. + return false;
  17366. +
  17367. + if (cond && cfun->machine->hwtrace)
  17368. + return false;
  17369. +
  17370. + return true;
  17371. +}
  17372. +
  17373. +/* Verify that any instruction that supports conditional execution
  17374. + * includes the '%?' placeholder if that instruction has been
  17375. + * marked as conditional. */
  17376. +void
  17377. +metag_asm_output_opcode (FILE *file ATTRIBUTE_UNUSED, const char * opcode)
  17378. +{
  17379. + if (metag_cond_exec_p () || current_insn_predicate != NULL_RTX)
  17380. + {
  17381. + if (strchr (opcode, '?') == NULL)
  17382. + gcc_unreachable ();
  17383. + }
  17384. +}
  17385. +
  17386. +const char *
  17387. +metag_invalid_within_doloop (rtx insn)
  17388. +{
  17389. + if (CALL_P (insn))
  17390. + return "Function call in the loop.";
  17391. +
  17392. + if (INSN_P (insn) && asm_noperands (PATTERN (insn)) >= 0 &&
  17393. + regno_clobbered_p (TXRPT_REGNUM, insn, SImode, 0))
  17394. + return "In-line assembler clobbering TXRPT.";
  17395. +
  17396. + return NULL;
  17397. +}
  17398. +
  17399. +/* Return TRUE iff the frame-pointer is required to efficiently restore
  17400. + * the stack frame during the epilogue. */
  17401. +
  17402. +static bool
  17403. +metag_frame_pointer_required_for_epilogue_restore (void)
  17404. +{
  17405. + return cfun->machine->frame_pointer_epilogue
  17406. + = metag_non_leaf_function_p ()
  17407. + && (ALIGN_ON_STACK_BOUNDARY (get_frame_size ()
  17408. + + current_function_outgoing_args_size) > 16352);
  17409. +}
  17410. +
  17411. +/* Return TRUE if the frame-pointer is required. */
  17412. +
  17413. +bool
  17414. +metag_frame_pointer_required (void)
  17415. +{
  17416. + return (current_function_calls_alloca
  17417. + || current_function_has_nonlocal_label
  17418. + || profile_flag
  17419. + || (cfun->machine->valid && cfun->machine->frame_pointer_epilogue)
  17420. + || cfun->machine->accesses_prev_frame
  17421. + || metag_frame_pointer_required_for_epilogue_restore ());
  17422. +}
  17423. +
  17424. +void
  17425. +metag_setup_frame_addresses (void)
  17426. +{
  17427. + cfun->machine->accesses_prev_frame = true;
  17428. +}
  17429. +
  17430. +void
  17431. +metag_expand_set_return_address (rtx source)
  17432. +{
  17433. + unsigned int savesize_gp = 0;
  17434. + unsigned int savesize_eh = 0;
  17435. + unsigned int picsize = 0;
  17436. + unsigned int extras_gp = 0;
  17437. + unsigned int extras_eh = 0;
  17438. + unsigned int ech_ctx = 0;
  17439. + bool non_leaf = metag_non_leaf_function_p ();
  17440. + HOST_WIDE_INT size = get_frame_size ();
  17441. + bool loads_pic_register;
  17442. +
  17443. + /* Round size of local stack to preserve 64-bit alignments */
  17444. + size = ALIGN_ON_STACK_BOUNDARY (size + current_function_outgoing_args_size);
  17445. +
  17446. + /* Calculate number of registers to restore
  17447. + if they contain pretend args save all, else save registers with data in them */
  17448. + {
  17449. + unsigned int regno;
  17450. +
  17451. + for (regno = MIN_METAG_CSAVE_REGNUM; regno <= MAX_METAG_CSAVE_REGNUM; regno += 2)
  17452. + {
  17453. + if (!call_used_regs[regno]
  17454. + && (df_regs_ever_live_p (regno + 0) || df_regs_ever_live_p (regno + 1)))
  17455. + {
  17456. + /* Need to restore all normal Dx register pairs required */
  17457. + savesize_gp += UNITS_PER_WORD * 2;
  17458. + extras_gp |= REGNO_BIT (regno);
  17459. + }
  17460. + }
  17461. + }
  17462. +
  17463. + /* Adjust the saved registers for ECH support */
  17464. + ech_ctx = metag_adjust_savesize_ech (&savesize_gp, &extras_gp, NULL);
  17465. +
  17466. + if (frame_pointer_needed || non_leaf)
  17467. + {
  17468. + /* Restore frame pointer via D0FRT or restore return address */
  17469. +
  17470. + if (non_leaf)
  17471. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  17472. +
  17473. + if (frame_pointer_needed)
  17474. + extras_gp |= REGNO_BIT (TEMP_D0FRT_REGNUM);
  17475. +
  17476. + savesize_gp += UNITS_PER_WORD * 2;
  17477. + }
  17478. + else if (df_regs_ever_live_p (RETURN_POINTER_REGNUM))
  17479. + {
  17480. + extras_gp |= REGNO_BIT (RETURN_POINTER_REGNUM);
  17481. +
  17482. + /* Have to do at least one pop */
  17483. + savesize_gp += UNITS_PER_WORD * 2;
  17484. + }
  17485. +
  17486. + if (current_function_calls_eh_return)
  17487. + {
  17488. + unsigned int n;
  17489. +
  17490. + for (n = 0; n < NUM_EH_RETURN_DATA_REGS; n++)
  17491. + {
  17492. + unsigned int regno = EH_RETURN_DATA_REGNO (n);
  17493. +
  17494. + if (regno != INVALID_REGNUM)
  17495. + {
  17496. + unsigned int regbit = REGNO_BIT (regno);
  17497. +
  17498. + if ((extras_eh & regbit) == 0)
  17499. + {
  17500. + extras_eh |= regbit;
  17501. + savesize_eh += UNITS_PER_WORD * 2;
  17502. + }
  17503. + }
  17504. + }
  17505. + }
  17506. +
  17507. + loads_pic_register = METAG_CURRENT_FUNCTION_LOADS_PIC_REGISTER ();
  17508. + if (loads_pic_register)
  17509. + picsize += UNITS_PER_WORD * 2;
  17510. +
  17511. + gcc_assert (cfun->machine->valid);
  17512. + gcc_assert (cfun->machine->savesize_gp == savesize_gp);
  17513. + gcc_assert (cfun->machine->savesize_eh == savesize_eh);
  17514. + gcc_assert (cfun->machine->extras_gp == extras_gp);
  17515. + gcc_assert (cfun->machine->extras_eh == extras_eh);
  17516. + gcc_assert (cfun->machine->pic_save_size == picsize);
  17517. + gcc_assert (cfun->machine->uses_pic_offset_table == current_function_uses_pic_offset_table);
  17518. + gcc_assert (cfun->machine->loads_pic_register == loads_pic_register);
  17519. +
  17520. + if ((extras_gp & REGNO_BIT (RETURN_POINTER_REGNUM)) != 0)
  17521. + {
  17522. + rtx base;
  17523. +
  17524. + /* The return address is @ hard frame pointer + UNITS_PER_WORD */
  17525. + if (frame_pointer_needed)
  17526. + base = plus_constant (hard_frame_pointer_rtx, UNITS_PER_WORD);
  17527. + else
  17528. + base = plus_constant (stack_pointer_rtx,
  17529. + -(HOST_WIDE_INT)(size + picsize + savesize_eh + savesize_gp - UNITS_PER_WORD));
  17530. +
  17531. + emit_insn (gen_rtx_SET (VOIDmode,
  17532. + gen_rtx_MEM (SImode, base),
  17533. + source));
  17534. + }
  17535. + else
  17536. + emit_insn (gen_rtx_SET (VOIDmode,
  17537. + gen_rtx_REG (SImode, RETURN_POINTER_REGNUM),
  17538. + source));
  17539. +
  17540. + return;
  17541. +}
  17542. +
  17543. +bool
  17544. +metag_doloop_loop_nest_optimized (struct loop * loop, struct doloopnest * nest)
  17545. +{
  17546. + for ( ; nest != NULL ; nest = nest->next)
  17547. + if (nest->inner == loop)
  17548. + return true;
  17549. +
  17550. + return false;
  17551. +}
  17552. +
  17553. +bool
  17554. +metag_doloop_check_any_nest_optimized (struct loop * loop, struct doloopnest * nest)
  17555. +{
  17556. + if (loop->inner == NULL)
  17557. + /* Check if nest already has an optimized loop */
  17558. + return metag_doloop_loop_nest_optimized (loop, nest);
  17559. + else
  17560. + {
  17561. + struct loop* innerloops = loop->inner;
  17562. +
  17563. + for ( ; innerloops != NULL ; innerloops = innerloops->next)
  17564. + if (metag_doloop_check_any_nest_optimized (innerloops, nest))
  17565. + return true;
  17566. + }
  17567. +
  17568. + return false;
  17569. +}
  17570. +
  17571. +void
  17572. +metag_doloop_mark_nests_optimized (struct loop * loop, struct doloopnest ** nest_p)
  17573. +{
  17574. + /* Check if the nest already has an optimized loop */
  17575. + if (loop->inner == NULL)
  17576. + {
  17577. + while (*nest_p != NULL)
  17578. + /* Find the end of the list of nests */
  17579. + nest_p = &((*nest_p)->next);
  17580. +
  17581. + /* Add the new loop nest (innermost loop) to the list */
  17582. + *nest_p = (struct doloopnest *)xmalloc (sizeof (struct doloopnest));
  17583. + (*nest_p)->next = NULL;
  17584. + (*nest_p)->inner = loop;
  17585. + }
  17586. + else
  17587. + {
  17588. + /* Process all inner siblings if this loop is not innermost */
  17589. + struct loop* innerloops = loop->inner;
  17590. +
  17591. + for ( ; innerloops != NULL ; innerloops = innerloops->next)
  17592. + metag_doloop_mark_nests_optimized (innerloops, nest_p);
  17593. + }
  17594. +}
  17595. +
  17596. +bool
  17597. +metag_current_function_loads_pic_register (void)
  17598. +{
  17599. +#if 0
  17600. + /* We need to perform more analysis and house keeping
  17601. + before we can optimize the loading of PIC register
  17602. + based on local/global properties of functions.
  17603. +
  17604. + At present we only mark functions to load the pic
  17605. + register if it uses the PIC register, but this
  17606. + doesn't interact correctly with the intended local/
  17607. + global optimization.
  17608. +
  17609. + Consider
  17610. +
  17611. + extern int a;
  17612. +
  17613. + static void s(void) { a = 1; }
  17614. +
  17615. + void g (void) { s (); }
  17616. +
  17617. + We need g() to load/restore the PIC and s() to
  17618. + inherit the PIC from g();
  17619. +
  17620. + */
  17621. + if (flag_unit_at_a_time)
  17622. + {
  17623. + struct cgraph_local_info * local_info
  17624. + = cgraph_local_info (current_function_decl);
  17625. +
  17626. + if (local_info && local_info->local)
  17627. + return false;
  17628. + }
  17629. +#endif
  17630. +
  17631. + return current_function_uses_pic_offset_table;
  17632. +}
  17633. +
  17634. +#define MODE_BASE_REG_CLASS(MODE) (MODE)
  17635. +
  17636. +rtx
  17637. +metag_legitimize_reload_address (rtx x, enum machine_mode mode,
  17638. + int opnum, int type,
  17639. + int ind_levels ATTRIBUTE_UNUSED)
  17640. +{
  17641. + if (GET_CODE (x) == PLUS
  17642. + && REG_P (XEXP (x, 0))
  17643. + && IS_HARD_OR_VIRT_REGNO (REGNO (XEXP (x, 0)))
  17644. + && METAG_LEGITIMATE_REG_P (XEXP (x, 0), TRUE)
  17645. + && CONST_INT_P (XEXP (x, 1)))
  17646. + {
  17647. + if (!strict_memory_address_p (mode, x))
  17648. + {
  17649. +#if 0
  17650. + unsigned int modesize = GET_MODE_SIZE (mode);
  17651. + HOST_WIDE_INT value = INTVAL (XEXP (x, 1));
  17652. + HOST_WIDE_INT limit_top;
  17653. + HOST_WIDE_INT limit_bot;
  17654. + HOST_WIDE_INT delta;
  17655. +
  17656. + if (metag_reg12bit_op (XEXP (x, 0), mode))
  17657. + limit_top = 2048 * modesize;
  17658. + else
  17659. + limit_top = 32 * modesize;
  17660. +
  17661. + limit_bot = -limit_top;
  17662. + limit_top = (limit_top - 1) & ~(modesize - 1);
  17663. +
  17664. + if (limit_top <= value && value < limit_top + 255)
  17665. + delta = limit_top;
  17666. + else if (limit_bot - 255 <= value && value < -limit_bot)
  17667. + delta = limit_bot;
  17668. + else
  17669. + delta = 0;
  17670. +#endif
  17671. +
  17672. + x = gen_rtx_PLUS (GET_MODE (x),
  17673. + gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0),
  17674. + XEXP (x, 1)),
  17675. + GEN_INT (0));
  17676. + push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
  17677. + MODE_BASE_REG_CLASS (mode), GET_MODE (x),
  17678. + VOIDmode, 0, 0, opnum, type);
  17679. +
  17680. + return x;
  17681. + }
  17682. + }
  17683. +
  17684. + return NULL_RTX;
  17685. +}
  17686. +
  17687. +bool
  17688. +metag_offset6_mode (rtx op, enum machine_mode mode)
  17689. +{
  17690. + gcc_assert (CONST_INT_P (op));
  17691. +
  17692. + switch (mode)
  17693. + {
  17694. + case DImode:
  17695. + return metag_offset6_di (op, mode);
  17696. +
  17697. + case SImode:
  17698. + return metag_offset6_si (op, mode);
  17699. +
  17700. + case HImode:
  17701. + return metag_offset6_hi (op, mode);
  17702. +
  17703. + case QImode:
  17704. + return metag_offset6_qi (op, mode);
  17705. +
  17706. + case DFmode:
  17707. + return metag_offset6_df (op, mode);
  17708. +
  17709. + case SFmode:
  17710. + return metag_offset6_sf (op, mode);
  17711. +
  17712. + case V2SImode:
  17713. + return metag_offset6_v2si (op, mode);
  17714. +
  17715. + case V2SFmode:
  17716. + return metag_offset6_v2sf (op, mode);
  17717. +
  17718. + default:
  17719. + gcc_unreachable ();
  17720. + }
  17721. +
  17722. + return false;
  17723. +}
  17724. +
  17725. +bool
  17726. +metag_offset12_mode (rtx op, enum machine_mode mode)
  17727. +{
  17728. + gcc_assert (CONST_INT_P (op));
  17729. +
  17730. + switch (mode)
  17731. + {
  17732. + case DImode:
  17733. + return metag_offset12_di (op, mode);
  17734. +
  17735. + case SImode:
  17736. + return metag_offset12_si (op, mode);
  17737. +
  17738. + case HImode:
  17739. + return metag_offset12_hi (op, mode);
  17740. +
  17741. + case QImode:
  17742. + return metag_offset12_qi (op, mode);
  17743. +
  17744. + case DFmode:
  17745. + return metag_offset12_df (op, mode);
  17746. +
  17747. + case SFmode:
  17748. + return metag_offset12_sf (op, mode);
  17749. +
  17750. + case V2SImode:
  17751. + return metag_offset12_v2si (op, mode);
  17752. +
  17753. + case V2SFmode:
  17754. + return metag_offset12_v2sf (op, mode);
  17755. +
  17756. + default:
  17757. + gcc_unreachable ();
  17758. + }
  17759. +
  17760. + return false;
  17761. +}
  17762. +
  17763. +bool
  17764. +metag_regno12bit_p (unsigned int regno)
  17765. +{
  17766. + return regno == D0_0_REG || regno == D0_1_REG
  17767. + || regno == D1_0_REG || regno == D1_1_REG
  17768. + || regno == A0_0_REG || regno == A0_1_REG
  17769. + || regno == A1_0_REG || regno == A1_1_REG;
  17770. +}
  17771. +
  17772. +bool
  17773. +metag_split_early (void)
  17774. +{
  17775. + return reload_completed;
  17776. +}
  17777. +
  17778. +bool
  17779. +metag_split_hi_lo_sum_early (void)
  17780. +{
  17781. + return reload_completed;
  17782. +}
  17783. +
  17784. +void
  17785. +metag_internal_label (FILE *file, const char *prefix, unsigned long labelno)
  17786. +{
  17787. + if (metag_ccfsm_state == 3
  17788. + && (unsigned)metag_target_label == labelno
  17789. + && strcmp (prefix, "L") == 0)
  17790. + {
  17791. + metag_ccfsm_state = 0;
  17792. + metag_target_insn = NULL;
  17793. + }
  17794. +
  17795. + default_internal_label (file, prefix, labelno);
  17796. + return;
  17797. +}
  17798. +
  17799. +bool
  17800. +metag_hard_regno_mode_ok (unsigned int regno, enum machine_mode mode)
  17801. +{
  17802. + if (GET_MODE_CLASS (mode) == MODE_CC)
  17803. + return regno == MCC_REGNUM;
  17804. + else if (regno == MCC_REGNUM)
  17805. + return false;
  17806. +
  17807. + if (LAST_ADDR_REG < regno && regno < FIRST_FP_REG)
  17808. + return mode == SImode;
  17809. +
  17810. + if (FIRST_FP_REG <= regno && regno <= LAST_FP_REG)
  17811. + {
  17812. + /* FP regs can hold anything that fits in a single reg or a pair */
  17813. + if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
  17814. + return true;
  17815. + else
  17816. + return ((regno - FIRST_FP_REG) & 1) == 0 && ((regno + HARD_REGNO_NREGS (regno, mode) - 1) <= LAST_FP_REG);
  17817. + }
  17818. +
  17819. + if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
  17820. + return true;
  17821. + else
  17822. + {
  17823. + unsigned int last_permitted_reg = LAST_ADDR_REG;
  17824. +
  17825. + /* V2SI can only use data registers */
  17826. + if (mode == V2SImode || mode == V2SFmode)
  17827. + last_permitted_reg = LAST_DATA_REG;
  17828. +
  17829. + return ((regno <= last_permitted_reg && (regno & 1) == 0)) && ((regno + HARD_REGNO_NREGS (regno, mode) - 1) <= last_permitted_reg);
  17830. + }
  17831. +
  17832. + return false;
  17833. +}
  17834. +
  17835. +bool
  17836. +metag_dsp_ri16_operands (rtx operands[])
  17837. +{
  17838. + int dunit0, dunit2;
  17839. + int regno0, regno2;
  17840. +
  17841. + /* Reject if not all registers and also in DATA register class. */
  17842. + if (!(REG_P (operands[0 ])
  17843. + && METAG_DATA_REG_P (REGNO (operands[0 ]))
  17844. + && REG_P (operands[0+2])
  17845. + && METAG_DATA_REG_P (REGNO (operands[0+2]))
  17846. + && GET_CODE (operands[1 ]) == CONST_INT
  17847. + && metag_16bit_op (operands[1], GET_MODE (operands[1]))))
  17848. + return false;
  17849. +
  17850. + dunit0 = METAG_DATAREG_UNIT (REGNO (operands[0 ]));
  17851. + dunit2 = METAG_DATAREG_UNIT (REGNO (operands[0+2]));
  17852. +
  17853. + regno0 = METAG_DATAREG_REGN (REGNO (operands[0 ]));
  17854. + regno2 = METAG_DATAREG_REGN (REGNO (operands[0+2]));
  17855. +
  17856. + /* Accept if register units and regno's match. */
  17857. + return (dunit0 != dunit2 && regno0 == regno2);
  17858. +
  17859. +}
  17860. +
  17861. +bool
  17862. +metag_dsp_rri5_operands (rtx operands[])
  17863. +{
  17864. + int dunit0, dunit1, dunit3, dunit4;
  17865. + int regno0, regno1, regno3, regno4;
  17866. +
  17867. + /* Reject if not all registers and also in DATA register class. */
  17868. + if (!(REG_P (operands[0 ])
  17869. + && METAG_DATA_REG_P (REGNO (operands[0 ]))
  17870. + && REG_P (operands[0+1])
  17871. + && METAG_DATA_REG_P (REGNO (operands[0+1]))
  17872. + && REG_P (operands[3+0])
  17873. + && METAG_DATA_REG_P (REGNO (operands[3+0]))
  17874. + && REG_P (operands[3+1])
  17875. + && METAG_DATA_REG_P (REGNO (operands[3+1]))
  17876. + && GET_CODE (operands[2 ]) == CONST_INT
  17877. + && metag_5bit_op (operands[2], GET_MODE (operands[2]))))
  17878. + return false;
  17879. +
  17880. + dunit0 = METAG_DATAREG_UNIT (REGNO (operands[0 ]));
  17881. + dunit1 = METAG_DATAREG_UNIT (REGNO (operands[0+1]));
  17882. + dunit3 = METAG_DATAREG_UNIT (REGNO (operands[3 ]));
  17883. + dunit4 = METAG_DATAREG_UNIT (REGNO (operands[3+1]));
  17884. +
  17885. + regno0 = METAG_DATAREG_REGN (REGNO (operands[0 ]));
  17886. + regno1 = METAG_DATAREG_REGN (REGNO (operands[0+1]));
  17887. + regno3 = METAG_DATAREG_REGN (REGNO (operands[3 ]));
  17888. + regno4 = METAG_DATAREG_REGN (REGNO (operands[3+1]));
  17889. +
  17890. + /* Reject if register units don't match. */
  17891. + if (dunit0 != dunit1
  17892. + || dunit3 != dunit4
  17893. + || dunit0 == dunit3)
  17894. + return false;
  17895. +
  17896. + /* Reject is dest registers don't match. */
  17897. + if (regno0 != regno3)
  17898. + return false;
  17899. +
  17900. + /* Accept if src register match. */
  17901. + return (regno1 == regno4);
  17902. +}
  17903. +
  17904. +bool
  17905. +metag_dsp_rrr_operands (rtx operands[], bool commutable)
  17906. +{
  17907. + int dunit0, dunit1, dunit2, dunit3, dunit4, dunit5;
  17908. + int regno0, regno1, regno2, regno3, regno4, regno5;
  17909. +
  17910. + /* Reject if not operands DATA registers. */
  17911. + if (!(REG_P (operands[0 ])
  17912. + && METAG_DATA_REG_P (REGNO (operands[0 ]))
  17913. + && REG_P (operands[0+3])
  17914. + && METAG_DATA_REG_P (REGNO (operands[0+3]))
  17915. + && REG_P (operands[1 ])
  17916. + && METAG_DATA_REG_P (REGNO (operands[1 ]))
  17917. + && REG_P (operands[1+3])
  17918. + && METAG_DATA_REG_P (REGNO (operands[1+3]))
  17919. + && REG_P (operands[2])
  17920. + && METAG_DATA_REG_P (REGNO (operands[2 ]))
  17921. + && REG_P (operands[2+3])
  17922. + && METAG_DATA_REG_P (REGNO (operands[2+3]))))
  17923. + return false;
  17924. +
  17925. + dunit0 = METAG_DATAREG_UNIT (REGNO (operands[0 ]));
  17926. + dunit1 = METAG_DATAREG_UNIT (REGNO (operands[1 ]));
  17927. + dunit2 = METAG_DATAREG_UNIT (REGNO (operands[2 ]));
  17928. +
  17929. + dunit3 = METAG_DATAREG_UNIT (REGNO (operands[0+3]));
  17930. + dunit4 = METAG_DATAREG_UNIT (REGNO (operands[1+3]));
  17931. + dunit5 = METAG_DATAREG_UNIT (REGNO (operands[2+3]));
  17932. +
  17933. + regno0 = METAG_DATAREG_REGN (REGNO (operands[0 ]));
  17934. + regno1 = METAG_DATAREG_REGN (REGNO (operands[1 ]));
  17935. + regno2 = METAG_DATAREG_REGN (REGNO (operands[2 ]));
  17936. +
  17937. + regno3 = METAG_DATAREG_REGN (REGNO (operands[0+3]));
  17938. + regno4 = METAG_DATAREG_REGN (REGNO (operands[1+3]));
  17939. + regno5 = METAG_DATAREG_REGN (REGNO (operands[2+3]));
  17940. +
  17941. + /* Reject if register units don't match. */
  17942. + if (dunit0 != dunit1
  17943. + || dunit1 != dunit2
  17944. + || dunit3 != dunit4
  17945. + || dunit4 != dunit5
  17946. + || dunit0 == dunit3)
  17947. + return false;
  17948. +
  17949. + /* Reject is dest registers don't match. */
  17950. + if (regno0 != regno3)
  17951. + return false;
  17952. +
  17953. + /* Accept if src register match. */
  17954. + return ((regno1 == regno4 && regno2 == regno5)
  17955. + || (commutable
  17956. + && (regno1 == regno5 && regno2 == regno4)));
  17957. +}
  17958. +
  17959. +bool
  17960. +metag_dsp_rrr_mov_operands (rtx operands[], bool commutable)
  17961. +{
  17962. + int dunit1, dunit2, dunit4, dunit5, dunit6, dunit7;
  17963. + int regno1, regno2, regno4, regno5, regno6, regno7;
  17964. +
  17965. + /* Reject if not operands DATA registers. */
  17966. + if (!(REG_P (operands[0 ])
  17967. + && REG_P (operands[0+3])
  17968. + && REG_P (operands[1 ])
  17969. + && METAG_DATA_REG_P (REGNO (operands[1 ]))
  17970. + && REG_P (operands[1+3])
  17971. + && METAG_DATA_REG_P (REGNO (operands[1+3]))
  17972. + && REG_P (operands[2])
  17973. + && METAG_DATA_REG_P (REGNO (operands[2 ]))
  17974. + && REG_P (operands[2+3])
  17975. + && METAG_DATA_REG_P (REGNO (operands[2+3]))
  17976. + && REG_P (operands[0+6])
  17977. + && METAG_DATA_REG_P (REGNO (operands[0+6]))
  17978. + && REG_P (operands[1+6])
  17979. + && METAG_DATA_REG_P (REGNO (operands[1+6]))))
  17980. + return false;
  17981. +
  17982. + dunit1 = METAG_DATAREG_UNIT (REGNO (operands[1 ]));
  17983. + dunit2 = METAG_DATAREG_UNIT (REGNO (operands[2 ]));
  17984. + dunit4 = METAG_DATAREG_UNIT (REGNO (operands[1+3]));
  17985. + dunit5 = METAG_DATAREG_UNIT (REGNO (operands[2+3]));
  17986. + dunit6 = METAG_DATAREG_UNIT (REGNO (operands[6 ]));
  17987. + dunit7 = METAG_DATAREG_UNIT (REGNO (operands[7 ]));
  17988. +
  17989. + regno1 = METAG_DATAREG_REGN (REGNO (operands[1 ]));
  17990. + regno2 = METAG_DATAREG_REGN (REGNO (operands[2 ]));
  17991. + regno4 = METAG_DATAREG_REGN (REGNO (operands[1+3]));
  17992. + regno5 = METAG_DATAREG_REGN (REGNO (operands[2+3]));
  17993. + regno6 = METAG_DATAREG_REGN (REGNO (operands[0+6]));
  17994. + regno7 = METAG_DATAREG_REGN (REGNO (operands[1+6]));
  17995. +
  17996. + /* Reject if register units don't match */
  17997. + if ( dunit1 != dunit2
  17998. + || dunit1 != dunit6
  17999. + || dunit4 != dunit5
  18000. + || dunit4 != dunit7
  18001. + || dunit6 == dunit7)
  18002. + return false;
  18003. +
  18004. + /* Reject is dest registers don't match. */
  18005. + if (regno6 != regno7)
  18006. + return false;
  18007. +
  18008. + /* Accept if src register's match. */
  18009. + return ((regno1 == regno4 && regno2 == regno5)
  18010. + || (commutable
  18011. + && (regno1 == regno5 && regno2 == regno4)));
  18012. +}
  18013. +
  18014. +bool
  18015. +metag_dsp_rr_operands (rtx operands[])
  18016. +{
  18017. + int dunit0, dunit1, dunit2, dunit3;
  18018. + int regno0, regno1, regno2, regno3;
  18019. +
  18020. + /* Reject if not all are registers and also in DATA register class. */
  18021. + if (!(REG_P (operands[0 ])
  18022. + && METAG_DATA_REG_P (REGNO (operands[0 ]))
  18023. + && REG_P (operands[0+2])
  18024. + && METAG_DATA_REG_P (REGNO (operands[0+2]))
  18025. + && REG_P (operands[1 ])
  18026. + && METAG_DATA_REG_P (REGNO (operands[1 ]))
  18027. + && REG_P (operands[1+2])
  18028. + && METAG_DATA_REG_P (REGNO (operands[1+2]))))
  18029. + return false;
  18030. +
  18031. + dunit0 = METAG_DATAREG_UNIT (REGNO (operands[0 ]));
  18032. + dunit1 = METAG_DATAREG_UNIT (REGNO (operands[1 ]));
  18033. + dunit2 = METAG_DATAREG_UNIT (REGNO (operands[0+2]));
  18034. + dunit3 = METAG_DATAREG_UNIT (REGNO (operands[1+2]));
  18035. +
  18036. + regno0 = METAG_DATAREG_REGN (REGNO (operands[0 ]));
  18037. + regno1 = METAG_DATAREG_REGN (REGNO (operands[1 ]));
  18038. + regno2 = METAG_DATAREG_REGN (REGNO (operands[0+2]));
  18039. + regno3 = METAG_DATAREG_REGN (REGNO (operands[1+2]));
  18040. +
  18041. + /* Accept if register units and regno's match. */
  18042. + return ( dunit0 == dunit1
  18043. + && dunit2 == dunit3
  18044. + && dunit0 != dunit2
  18045. + && regno0 == regno2
  18046. + && regno1 == regno3);
  18047. +}
  18048. +
  18049. +bool
  18050. +metag_dsp_rr_rr_mov_operands (rtx operands[])
  18051. +{
  18052. + int dunit1, dunit3, dunit4, dunit5;
  18053. + int regno1, regno3, regno4, regno5;
  18054. +
  18055. + /* Reject if not operands DATA registers. */
  18056. + if (!(REG_P (operands[0 ])
  18057. + && REG_P (operands[0+2])
  18058. + && REG_P (operands[1 ])
  18059. + && METAG_DATA_REG_P (REGNO (operands[1 ]))
  18060. + && REG_P (operands[1+2])
  18061. + && METAG_DATA_REG_P (REGNO (operands[1+2]))
  18062. + && REG_P (operands[0+4])
  18063. + && METAG_DATA_REG_P (REGNO (operands[0+4]))
  18064. + && REG_P (operands[1+4])
  18065. + && METAG_DATA_REG_P (REGNO (operands[1+4]))))
  18066. + return false;
  18067. +
  18068. + dunit1 = METAG_DATAREG_UNIT (REGNO (operands[1 ]));
  18069. + dunit3 = METAG_DATAREG_UNIT (REGNO (operands[1+2]));
  18070. + dunit4 = METAG_DATAREG_UNIT (REGNO (operands[4 ]));
  18071. + dunit5 = METAG_DATAREG_UNIT (REGNO (operands[5 ]));
  18072. +
  18073. + regno1 = METAG_DATAREG_REGN (REGNO (operands[1 ]));
  18074. + regno3 = METAG_DATAREG_REGN (REGNO (operands[1+2]));
  18075. + regno4 = METAG_DATAREG_REGN (REGNO (operands[0+4]));
  18076. + regno5 = METAG_DATAREG_REGN (REGNO (operands[1+4]));
  18077. +
  18078. + /* Accept if register units and regno's match. */
  18079. + return ( dunit4 == dunit1
  18080. + && dunit5 == dunit3
  18081. + && dunit4 != dunit5
  18082. + && regno4 == regno5
  18083. + && regno5 == regno3
  18084. + && regno4 == regno5);
  18085. +}
  18086. +
  18087. +/* This function sets operands 2,3 to support both flag setting and non flag
  18088. + setting dsp peephole 2 transformations */
  18089. +void
  18090. +metag_dsp_peephole2_rr_convert (rtx operands[])
  18091. +{
  18092. + int adjust = 0;
  18093. +
  18094. + if (REGNO (operands[0]) > REGNO (operands[0+2]))
  18095. + adjust = 2;
  18096. +
  18097. + operands[2] = gen_rtx_REG (V2SImode, REGNO (operands[0 + adjust]));
  18098. + operands[3] = gen_rtx_REG (V2SImode, REGNO (operands[1 + adjust]));
  18099. +}
  18100. +
  18101. +void
  18102. +metag_dsp_peephole2_rr_mov_convert (rtx operands[])
  18103. +{
  18104. + int adjustin = 0;
  18105. + int adjustout = 0;
  18106. +
  18107. + if (REGNO (operands[1]) > REGNO (operands[1+2]))
  18108. + {
  18109. + adjustin = 2;
  18110. + adjustout = 1;
  18111. + }
  18112. + operands[4] = gen_rtx_REG (V2SImode, REGNO (operands[4 + adjustout]));
  18113. + operands[1] = gen_rtx_REG (V2SImode, REGNO (operands[1 + adjustin]));
  18114. +}
  18115. +
  18116. +/* This function sets operands 3,4,5 to support both flag setting and non flag
  18117. + setting dsp peephole 2 transformations */
  18118. +void
  18119. +metag_dsp_peephole2_rrr_convert (rtx operands[])
  18120. +{
  18121. + int adjust = 0;
  18122. +
  18123. + if (REGNO (operands[0]) > REGNO (operands[0+3]))
  18124. + adjust = 3;
  18125. +
  18126. + operands[3] = gen_rtx_REG (V2SImode, REGNO (operands[0 + adjust]));
  18127. + operands[4] = gen_rtx_REG (V2SImode, REGNO (operands[1 + adjust]));
  18128. + operands[5] = gen_rtx_REG (V2SImode, REGNO (operands[2 + adjust]));
  18129. +}
  18130. +
  18131. +void
  18132. +metag_dsp_peephole2_rrr_mov_convert (rtx operands[])
  18133. +{
  18134. + int adjustin = 0;
  18135. + int adjustout = 0;
  18136. +
  18137. + /* Operands 0 and 3 are not related in this case */
  18138. + if (REGNO (operands[1]) > REGNO (operands[1+3]))
  18139. + {
  18140. + adjustin = 3;
  18141. + adjustout = 1;
  18142. + }
  18143. + operands[6] = gen_rtx_REG (V2SImode, REGNO (operands[6 + adjustout]));
  18144. + operands[1] = gen_rtx_REG (V2SImode, REGNO (operands[1 + adjustin]));
  18145. + operands[2] = gen_rtx_REG (V2SImode, REGNO (operands[2 + adjustin]));
  18146. +}
  18147. +
  18148. +/* This function sets operands 2 and 3 to support both flag setting and non flag
  18149. + setting dsp peephole 2 transformations */
  18150. +void
  18151. +metag_dsp_peephole2_ri16_convert (rtx operands[])
  18152. +{
  18153. + int adjust = 0;
  18154. +
  18155. + if (REGNO (operands[0]) > REGNO (operands[0+2]))
  18156. + adjust = 2;
  18157. +
  18158. + operands[2] = gen_rtx_REG (V2SImode, REGNO (operands[0 + adjust]));
  18159. + operands[3] = gen_rtx_CONST_VECTOR (V2SImode,
  18160. + gen_rtvec (2, operands[1], operands[1]));
  18161. +}
  18162. +
  18163. +/* This function sets operands 3,4,5 to support both flag setting and non flag
  18164. + setting dsp peephole 2 transformations */
  18165. +void
  18166. +metag_dsp_peephole2_rri5_convert (rtx operands[])
  18167. +{
  18168. + int adjust = 0;
  18169. +
  18170. + if (REGNO (operands[0]) > REGNO (operands[0+3]))
  18171. + adjust = 3;
  18172. +
  18173. + operands[3] = gen_rtx_REG (V2SImode, REGNO (operands[0 + adjust]));
  18174. + operands[4] = gen_rtx_REG (V2SImode, REGNO (operands[1 + adjust]));
  18175. + operands[5] = gen_rtx_CONST_VECTOR (V2SImode,
  18176. + gen_rtvec (2, operands[2], operands[2]));
  18177. +}
  18178. +
  18179. +bool
  18180. +metag_move_valid_p (rtx to, rtx from)
  18181. +{
  18182. + gcc_assert (reload_completed);
  18183. +
  18184. + if (REG_P (from))
  18185. + {
  18186. + if (METAG_FPC_REG_P (REGNO (from)) && METAG_ADDR_REG_P (REGNO (to)))
  18187. + return false;
  18188. + else if (METAG_ADDR_REG_P (REGNO (from)) && METAG_FPC_REG_P (REGNO (to)))
  18189. + return false;
  18190. + }
  18191. + else if (CONST_INT_P (from))
  18192. + {
  18193. + if (METAG_FPC_REG_P (REGNO (to)))
  18194. + return false;
  18195. + }
  18196. +
  18197. + return true;
  18198. +}
  18199. +
  18200. +#define builtin_define(TXT) cpp_define (pfile, TXT)
  18201. +#define builtin_assert(TXT) cpp_assert (pfile, TXT)
  18202. +
  18203. +void
  18204. +metag_cpu_cpp_builtins (cpp_reader *pfile)
  18205. +{
  18206. + switch (metac_target)
  18207. + {
  18208. + case METAC_0_1_ID:
  18209. + builtin_define ("METAC_0_1");
  18210. + break;
  18211. + case METAC_1_0_ID:
  18212. + builtin_define ("METAC_1_0");
  18213. + break;
  18214. + case METAC_1_1_ID:
  18215. + builtin_define ("METAC_1_1");
  18216. + break;
  18217. + case METAC_1_2_ID:
  18218. + builtin_define ("METAC_1_2");
  18219. + break;
  18220. + case METAC_2_1_ID:
  18221. + builtin_define ("METAC_2_1");
  18222. + break;
  18223. + }
  18224. +
  18225. + switch (metacore)
  18226. + {
  18227. + case METACORE_METAC_0_1:
  18228. + builtin_define ("METAC_TUNE_0_1");
  18229. + break;
  18230. + case METACORE_METAC_1_0:
  18231. + builtin_define ("METAC_TUNE_1_0");
  18232. + break;
  18233. + case METACORE_METAC_1_1:
  18234. + builtin_define ("METAC_TUNE_1_1");
  18235. + break;
  18236. + case METACORE_METAC_1_2:
  18237. + builtin_define ("METAC_TUNE_1_2");
  18238. + break;
  18239. + case METACORE_METAC_2_1:
  18240. + builtin_define ("METAC_TUNE_2_1");
  18241. + break;
  18242. + }
  18243. +
  18244. + if (TARGET_FPU)
  18245. + {
  18246. + builtin_define ("METAC_FPU_FLOAT");
  18247. +
  18248. + if (TARGET_FPU_SIMD)
  18249. + builtin_define ("METAC_FPU_LFLOAT");
  18250. +
  18251. + if (!metag_fpu_single)
  18252. + builtin_define ("METAC_FPU_DOUBLE");
  18253. + }
  18254. +
  18255. + if (strcmp (metag_charset_string, "basic") == 0)
  18256. + builtin_define ("strcmp=strcmpbcs");
  18257. +
  18258. + if (TARGET_MINIM)
  18259. + builtin_define ("METAC_MINIM_ENC");
  18260. +
  18261. + if (metag_memory_width == 32)
  18262. + builtin_define ("METAC_MEMW_32");
  18263. + else if (metag_memory_width == 64)
  18264. + builtin_define ("METAC_MEMW_64");
  18265. +
  18266. + builtin_define ("__metag__");
  18267. + builtin_define ("__METAG__");
  18268. + builtin_define ("__METAG");
  18269. +
  18270. + builtin_define ("METAG");
  18271. +
  18272. + builtin_assert ("cpu=metag");
  18273. + builtin_assert ("machine=metag");
  18274. +}
  18275. +
  18276. +void
  18277. +metag_expand_didf2 (rtx out, rtx in)
  18278. +{
  18279. + rtx dscr = gen_reg_rtx (DImode);
  18280. + rtx dscrhi = gen_rtx_SUBREG (SImode, dscr, 4);
  18281. + rtx fscr2 = gen_reg_rtx (DFmode);
  18282. + rtx fscr2hi_as_si = gen_rtx_SUBREG (SImode, fscr2, 4);
  18283. + rtx fscr2lo_as_si = gen_rtx_SUBREG (SImode, fscr2, 0);
  18284. + rtx operands[1];
  18285. +
  18286. + /* Test to see if rs is in the difficult range (> 2^63) */
  18287. + emit_move_insn (dscr, in);
  18288. + metag_compare_op0 = gen_rtx_AND (SImode, dscrhi,
  18289. + gen_int_mode (0x80000000, SImode));
  18290. + metag_compare_op1 = const0_rtx;
  18291. + gen_metag_compare (NE, operands, 0);
  18292. +
  18293. + /* Drop the 2^63 component */
  18294. + emit_insn (gen_andsi3 (dscrhi, dscrhi,
  18295. + gen_int_mode (0x7fffffff, SImode)));
  18296. +
  18297. + /* Convert to double */
  18298. + emit_insn (gen_floatdidf2 (out, dscr));
  18299. +
  18300. + /* Prepare 2^63 in double precision */
  18301. + emit_move_insn (fscr2hi_as_si,
  18302. + gen_int_mode (0x43e00000, SImode));
  18303. + emit_move_insn (fscr2lo_as_si, GEN_INT (0x0));
  18304. +
  18305. + /* Add on the missing 2^63 if requried */
  18306. + emit_insn (gen_rtx_SET (VOIDmode, out,
  18307. + gen_rtx_IF_THEN_ELSE (DFmode,
  18308. + gen_rtx_NE (VOIDmode, operands[0],
  18309. + const0_rtx),
  18310. + gen_rtx_PLUS (DFmode, out, fscr2),
  18311. + out)));
  18312. +
  18313. +
  18314. +}
  18315. +
  18316. +#define PRAGMA_JUMP_TABLE_BRANCH_WARNING() \
  18317. + do { \
  18318. + warning (OPT_Wpragmas, "Incorrect syntax for '#pragma mjump-table-branch=small|large|auto'"); \
  18319. + return; \
  18320. + } while (0)
  18321. +
  18322. +void
  18323. +metag_pragma_jump_table_branch (struct cpp_reader* pFile ATTRIBUTE_UNUSED)
  18324. +{
  18325. + tree x;
  18326. + const char * option = NULL;
  18327. +
  18328. + if (pragma_lex (&x) != CPP_MINUS)
  18329. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18330. +
  18331. + if (pragma_lex (&x) != CPP_NAME || strncmp (IDENTIFIER_POINTER (x), "table", 5) != 0)
  18332. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18333. +
  18334. + if (pragma_lex (&x) != CPP_MINUS)
  18335. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18336. +
  18337. + if (pragma_lex (&x) != CPP_NAME || strncmp (IDENTIFIER_POINTER (x), "branch", 6) != 0)
  18338. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18339. +
  18340. + if (pragma_lex (&x) != CPP_EQ)
  18341. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18342. +
  18343. + if (pragma_lex (&x) != CPP_NAME)
  18344. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18345. +
  18346. + option = IDENTIFIER_POINTER (x);
  18347. +
  18348. + if (pragma_lex (&x) != CPP_EOF)
  18349. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18350. +
  18351. + if (strncmp (option, "short", 5) == 0)
  18352. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_SHORT;
  18353. + else if (strncmp (option, "long", 4) == 0)
  18354. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_LONG;
  18355. + else if (strncmp (option, "auto", 4) == 0)
  18356. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_AUTO;
  18357. + else if (strncmp (option, "default", 7) == 0)
  18358. + {
  18359. + if (strncmp (metag_jump_table_string, "short", 5) == 0)
  18360. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_SHORT;
  18361. + else if (strncmp (metag_jump_table_string, "long", 4) == 0)
  18362. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_LONG;
  18363. + else if (strncmp (metag_jump_table_string, "auto", 4) == 0)
  18364. + metag_jump_table_branch = METAG_MINIM_JUMP_TABLE_BRANCH_AUTO;
  18365. + }
  18366. + else
  18367. + PRAGMA_JUMP_TABLE_BRANCH_WARNING ();
  18368. +}
  18369. +
  18370. +#define PRAGMA_HWTRACE_SYNTAX_ERROR() \
  18371. + do { \
  18372. + warning (OPT_Wpragmas, "Incorrect syntax for '#pragma hwtrace_function (func|*,0|1)"); \
  18373. + return; \
  18374. + } while (0)
  18375. +
  18376. +
  18377. +void
  18378. +metag_pragma_hwtrace_function (struct cpp_reader* pFile ATTRIBUTE_UNUSED)
  18379. +{
  18380. + tree x;
  18381. + const char * name = NULL;
  18382. + int onoff;
  18383. +
  18384. + if (pragma_lex (&x) != CPP_OPEN_PAREN)
  18385. + PRAGMA_HWTRACE_SYNTAX_ERROR ();
  18386. +
  18387. + switch (pragma_lex (&x))
  18388. + {
  18389. + case CPP_MULT:
  18390. + name = "*";
  18391. + break;
  18392. + case CPP_NAME:
  18393. + name = IDENTIFIER_POINTER (x);
  18394. + break;
  18395. + default:
  18396. + PRAGMA_HWTRACE_SYNTAX_ERROR ();
  18397. + }
  18398. +
  18399. + if (pragma_lex (&x) != CPP_COMMA)
  18400. + PRAGMA_HWTRACE_SYNTAX_ERROR ();
  18401. +
  18402. + if (pragma_lex (&x) != CPP_NUMBER)
  18403. + PRAGMA_HWTRACE_SYNTAX_ERROR ();
  18404. +
  18405. + if (TREE_CODE (x) != INTEGER_CST)
  18406. + PRAGMA_HWTRACE_SYNTAX_ERROR ();
  18407. +
  18408. + onoff = TREE_INT_CST_LOW (x);
  18409. +
  18410. + if (pragma_lex (&x) != CPP_CLOSE_PAREN)
  18411. + PRAGMA_HWTRACE_SYNTAX_ERROR ();
  18412. +
  18413. + if (pragma_lex (&x) != CPP_EOF)
  18414. + PRAGMA_HWTRACE_SYNTAX_ERROR ();
  18415. +
  18416. + if (strcmp (name, "*") == 0)
  18417. + hwtrace_function_default = onoff ? 1 : 0;
  18418. + else
  18419. + {
  18420. + hwtrace_fn * new_fn = xmalloc (sizeof (hwtrace_fn));
  18421. +
  18422. + new_fn->name = xstrdup (name);
  18423. + new_fn->onoff = onoff ? 1 : 0;
  18424. + new_fn->next = hwtrace_function_list;
  18425. +
  18426. + hwtrace_function_list = new_fn;
  18427. + }
  18428. +}
  18429. +
  18430. +/* Determine if 'label_ref' refers to a label in the current function */
  18431. +void
  18432. +metag_can_use_short_branch (void)
  18433. +{
  18434. + /* Once we have determined that we can use a short branch there is no need
  18435. + to check again. We re-do the check if only long branches are allowed
  18436. + even though the decision will not change */
  18437. + if (!cfun->machine->can_use_short_branch)
  18438. + {
  18439. + /* Do the analysis */
  18440. + rtx insn = next_active_insn (get_insns());
  18441. + int count = 0;
  18442. +
  18443. + while (insn)
  18444. + {
  18445. + rtx body = PATTERN (insn);
  18446. + /* Inline assembler... Take a best guess at the instruction count
  18447. + then multiply by 8 to assume all insns need long encodings */
  18448. + if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
  18449. + count += (metag_asm_insn_count (body) << 3);
  18450. + else if (GET_CODE (body) == ADDR_DIFF_VEC)
  18451. + {
  18452. + int i;
  18453. + /* Add in the branches in jump tables */
  18454. + for (i = 0 ; i < XVECLEN (body, 1) ; i++)
  18455. + {
  18456. + /* If a label is within the function it 'can' be short
  18457. + encoded therefore it takes up 4 bytes of PC address
  18458. + space. If a label is not within the function then
  18459. + branch tables must be long encoded */
  18460. + if (metag_is_label_within_function (XVECEXP (body, 1, i)))
  18461. + count += 4;
  18462. + else
  18463. + {
  18464. + count += 2049;
  18465. + break;
  18466. + }
  18467. + }
  18468. + }
  18469. + else if (GET_CODE (body) != UNSPEC_VOLATILE
  18470. + || XINT (body, 1) != VUNSPEC_BLOCKAGE)
  18471. + /* *2 for each instruction to make them 'long' */
  18472. + count += (get_attr_length (insn) << 1);
  18473. +
  18474. + insn = next_active_insn (insn);
  18475. +
  18476. + if (count > 2048)
  18477. + break;
  18478. + }
  18479. +
  18480. + /* 2048 is the number of bytes in PC address space that a short
  18481. + branch can jump forward or backwards to. The 'count' variable
  18482. + conservatively counts the number of bytes in the function
  18483. + assuming all instructions will be double their stated size,
  18484. + (double being a long MiniM encoding) */
  18485. +
  18486. + cfun->machine->can_use_short_branch = (count <= 2048);
  18487. + }
  18488. +}
  18489. +
  18490. +static bool
  18491. +metag_is_label_within_function (rtx label_ref)
  18492. +{
  18493. + rtx insn = get_insns();
  18494. +
  18495. + while ((insn = next_label (insn)) != 0)
  18496. + if (CODE_LABEL_NUMBER (insn) == CODE_LABEL_NUMBER (XEXP (label_ref, 0)))
  18497. + return true;
  18498. +
  18499. + return false;
  18500. +}
  18501. +
  18502. +static int
  18503. +metag_asm_insn_count (rtx body)
  18504. +{
  18505. + const char *template;
  18506. + int count = 1;
  18507. +
  18508. + if (GET_CODE (body) == ASM_INPUT)
  18509. + template = XSTR (body, 0);
  18510. + else
  18511. + template = decode_asm_operands (body, NULL, NULL, NULL, NULL);
  18512. +
  18513. + for (; *template; template++)
  18514. + if (IS_ASM_LOGICAL_LINE_SEPARATOR (*template) || *template == '\n')
  18515. + count++;
  18516. +
  18517. + return count;
  18518. +}
  18519. +
  18520. +/* Generate a conditional branch instruction, inserting the label number for
  18521. + the return stub */
  18522. +char *
  18523. +metag_gen_cond_return_branch (const char * pattern)
  18524. +{
  18525. + int length = strlen(pattern) + 21;
  18526. + char * buf = xmalloc (length);
  18527. +
  18528. + snprintf (buf, length, pattern, cfun->funcdef_no);
  18529. +
  18530. + if (cfun->machine->cond_return_state == METAG_COND_RETURN_NONE)
  18531. + cfun->machine->cond_return_state = METAG_COND_RETURN_REQD;
  18532. +
  18533. + return buf;
  18534. +}
  18535. +
  18536. +/* Generate the return stub instruction inserting the label number for the
  18537. + return stub */
  18538. +char *
  18539. +metag_gen_cond_return_stub (void)
  18540. +{
  18541. + static const char * pattern = "$LX%d:\n\tMOV\tPC, D1RtP";
  18542. + int length = strlen(pattern) + 21;
  18543. + char * buf = xmalloc (length);
  18544. +
  18545. + snprintf (buf, length, pattern, cfun->funcdef_no);
  18546. +
  18547. + cfun->machine->cond_return_state = METAG_COND_RETURN_DONE;
  18548. +
  18549. + return buf;
  18550. +}
  18551. +
  18552. +/* Create a stub at the end of a function if one is required and not already
  18553. + emitted. */
  18554. +void
  18555. +metag_emit_cond_return_stub_if_reqd (void)
  18556. +{
  18557. + if (cfun->machine->cond_return_state == METAG_COND_RETURN_REQD)
  18558. + {
  18559. + char * stub = metag_gen_cond_return_stub ();
  18560. +
  18561. + fputs (stub, asm_out_file);
  18562. + fputc ('\n', asm_out_file);
  18563. + cfun->machine->cond_return_state = METAG_COND_RETURN_DONE;
  18564. +
  18565. + free (stub);
  18566. + }
  18567. +}
  18568. +
  18569. +bool
  18570. +metag_output_addr_const_extra (FILE * stream, rtx x)
  18571. +{
  18572. + if (GET_CODE(x) == CONST_VECTOR && GET_MODE(x) == V2SImode)
  18573. + {
  18574. + /* WORK NEEDED: Assert more rigourously that the values are identical */
  18575. + gcc_assert (INTVAL (CONST_VECTOR_ELT (x, 0)) == INTVAL (CONST_VECTOR_ELT (x, 1)));
  18576. + output_addr_const (stream, CONST_VECTOR_ELT (x, 0));
  18577. + return true;
  18578. + }
  18579. + return false;
  18580. +}
  18581. +
  18582. +/* Produces a rtx representing the return register (D0Re0) using the correct mode. */
  18583. +rtx
  18584. +metag_function_return_reg (enum machine_mode mode)
  18585. +{
  18586. + if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) < UNITS_PER_WORD)
  18587. + return gen_rtx_REG (SImode, D0Re0_REG);
  18588. + else
  18589. + return gen_rtx_REG (mode, D0Re0_REG);
  18590. +}
  18591. +
  18592. +rtx
  18593. +metag_libcall_value (enum machine_mode mode)
  18594. +{
  18595. + return metag_function_return_reg (mode);
  18596. +}
  18597. +
  18598. +rtx
  18599. +metag_function_value (tree ret_type, tree fn_decl_or_type ATTRIBUTE_UNUSED, bool outgoing ATTRIBUTE_UNUSED)
  18600. +{
  18601. + return metag_function_return_reg (TYPE_MODE (ret_type));
  18602. +}
  18603. +
  18604. +#include "gt-metag.h"
  18605. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag.h gcc-4.2.4/gcc/config/metag/metag.h
  18606. --- gcc-4.2.4.orig/gcc/config/metag/metag.h 1969-12-31 18:00:00.000000000 -0600
  18607. +++ gcc-4.2.4/gcc/config/metag/metag.h 2015-07-03 18:46:05.765283542 -0500
  18608. @@ -0,0 +1,1955 @@
  18609. +/* Definitions of target machine for GNU compiler.
  18610. + Imagination Technologies Meta version.
  18611. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
  18612. + Imagination Technologies Ltd
  18613. +
  18614. +This file is part of GCC.
  18615. +
  18616. +GCC is free software; you can redistribute it and/or modify it under
  18617. +the terms of the GNU General Public License as published by the Free
  18618. +Software Foundation; either version 3, or (at your option) any later
  18619. +version.
  18620. +
  18621. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  18622. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  18623. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  18624. +for more details.
  18625. +
  18626. +You should have received a copy of the GNU General Public License
  18627. +along with GCC; see the file COPYING3. If not see
  18628. +<http://www.gnu.org/licenses/>. */
  18629. +
  18630. +#ifndef __METAG_H_
  18631. +#define __METAG_H_
  18632. +
  18633. +#define USE_EH_FRAME_REGISTRY
  18634. +
  18635. +/* Which processor to schedule for. The metacore attribute defines a list that
  18636. + mirrors this list, so changes to metag.md must be made at the same time. */
  18637. +
  18638. +enum processor_type
  18639. +{
  18640. + PROCESSOR_METAC_1_0,
  18641. + PROCESSOR_METAC_1_1,
  18642. + PROCESSOR_METAC_1_2,
  18643. + PROCESSOR_METAC_0_1,
  18644. + PROCESSOR_METAC_2_1,
  18645. + PROCESSOR_METAC_MAX
  18646. +};
  18647. +
  18648. +/* Support for a compile-time default CPU, et cetera. The rules are:
  18649. + --with-cpu is ignored if -mmetac is specified.
  18650. + --with-tune is ignored if -mtune is specified. */
  18651. +#define OPTION_DEFAULT_SPECS \
  18652. + {"cpu", "%{!mmetac=*:-mmetac=%(VALUE)}" }, \
  18653. + {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
  18654. + {"fpu", "%{mhard-float|mhard-float=*|msoft-float|msimd-float:; :-mhard-float=%(VALUE)}" } \
  18655. +
  18656. +/* Handle the pragma to alter the default jump_table_branch size. */
  18657. +#define REGISTER_TARGET_PRAGMAS() \
  18658. + do { \
  18659. + c_register_pragma (0, "mjump", metag_pragma_jump_table_branch); \
  18660. + c_register_pragma (0, "hwtrace_function", metag_pragma_hwtrace_function); \
  18661. + } while (0)
  18662. +
  18663. +#define SYMBOL_REF_P(RTX) (GET_CODE (RTX) == SYMBOL_REF)
  18664. +#define LABEL_REF_P(RTX) (GET_CODE (RTX) == LABEL_REF)
  18665. +#define CONST_DOUBLE_P(RTX) (GET_CODE (RTX) == CONST_DOUBLE)
  18666. +#define SUBREG_P(RTX) (GET_CODE (RTX) == SUBREG)
  18667. +
  18668. +#define TARGET_USE_JCR_SECTION 0
  18669. +
  18670. +#define TARGET_LIBGCC_SDATA_SECTION DATA_SECTION_ASM_OP
  18671. +
  18672. +#define TARGET_FAST_MATH fast_math_flags_set_p ()
  18673. +
  18674. +#define DWARF2_UNWIND_INFO 1
  18675. +
  18676. +#define NUM_EH_RETURN_DATA_REGS \
  18677. + (EH_RETURN_LAST_DATA_REG - EH_RETURN_FIRST_DATA_REG + 1)
  18678. +
  18679. +#define EH_RETURN_DATA_REGNO(N) \
  18680. + ((N) < NUM_EH_RETURN_DATA_REGS \
  18681. + ? EH_RETURN_FIRST_DATA_REG + (N) : INVALID_REGNUM)
  18682. +
  18683. +#define EH_RETURN_STACKADJ_RTX \
  18684. + gen_rtx_REG (SImode, EH_RETURN_STACKADJ_REG)
  18685. +
  18686. +#define DWARF_FRAME_REGISTERS (2 + 8 + 3)
  18687. +
  18688. +/* An optimisation for reducing the size of an unwind table. Only registers
  18689. + * that will be present in a frame are included
  18690. + *
  18691. + * D1.0 and D1.1 are present as they are the EH_RETURN data registers
  18692. + * D0FrT and D1RtP because they store the frame pointer and return address
  18693. + * D1Ar1 -> D0Ar6 are the call save registers
  18694. + * A1LbP is present as it is the PIC register for META Linux
  18695. + * A0StP and A0FrP are obvious!
  18696. + *
  18697. + * D0.8 is not included as it is not applicable to Linux and the relevant
  18698. + * code that refers to this table is not currently used in the embedded
  18699. + * toolchain
  18700. + */
  18701. +
  18702. +#define DWARF_REG_TO_UNWIND_COLUMN_TABLE \
  18703. +static signed char const dwarf_reg_to_unwind_column[FIRST_PSEUDO_REGISTER + 1] =\
  18704. +{ \
  18705. + /* D0_0/D1_0 ... D0_7/D1_7 */ \
  18706. + -1, -1, 0, 1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, \
  18707. + /* D0_8/D1_8 ... D0_15/D1_15 */ \
  18708. + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
  18709. + /* A0_0/A1_0 .. A0_7/A1_7 */ \
  18710. + 10, -1, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
  18711. + /* FRAME ... TXRPT */ \
  18712. + -1, -1, -1, -1, -1, -1, -1, -1, -1, \
  18713. + /* FX */ \
  18714. + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
  18715. + /* TTREC(L) */ \
  18716. + -1, -1 \
  18717. +}
  18718. +
  18719. +#define DWARF_REG_TO_UNWIND_COLUMN(REGNO) \
  18720. + dwarf_reg_to_unwind_column[REGNO]
  18721. +
  18722. +/* We're using ELF files */
  18723. +
  18724. +#define OBJECT_FORMAT_ELF
  18725. +
  18726. +#ifndef CPP_SUBTARGET_SPEC
  18727. +#define CPP_SUBTARGET_SPEC ""
  18728. +#endif
  18729. +
  18730. +#undef CPP_SPEC
  18731. +#define CPP_SPEC \
  18732. + "%(cpp_cpu_arch) " \
  18733. + "%(cpp_subtarget) " \
  18734. + "%{pthread: -D_THREAD_SAFE} "
  18735. +
  18736. +#define CPP_CPU_ARCH_SPEC ""
  18737. +
  18738. +#ifndef SUBTARGET_EXTRA_SPECS
  18739. +#define SUBTARGET_EXTRA_SPECS
  18740. +#endif
  18741. +
  18742. +#ifndef SUBTARGET_CPP_SPEC
  18743. +#define SUBTARGET_CPP_SPEC ""
  18744. +#endif
  18745. +
  18746. +/* This macro defines names of additional specifications to put in the specs
  18747. + that can be used in various specifications like CC1_SPEC. Its definition
  18748. + is an initializer with a subgrouping for each command option.
  18749. +
  18750. + Each subgrouping contains a string constant, that defines the
  18751. + specification name, and a string constant that used by the GNU CC driver
  18752. + program.
  18753. +
  18754. + Do not define this macro if it does not need to do anything. */
  18755. +
  18756. +#define EXTRA_SPECS \
  18757. + { "metac_default", METAC_DEFAULT }, \
  18758. + { "cpp_cpu_arch", CPP_CPU_ARCH_SPEC }, \
  18759. + { "cpp_subtarget", CPP_SUBTARGET_SPEC }, \
  18760. + { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
  18761. + SUBTARGET_EXTRA_SPECS
  18762. +
  18763. +/* Run-time compilation parameters selecting different hardware subsets. */
  18764. +
  18765. +extern int frame_pointer_needed;
  18766. +extern int target_flags;
  18767. +
  18768. +/* Define the information needed to expand branch insns. This is stored from
  18769. + the previous compare operation - which we do not expand at all! */
  18770. +extern GTY(()) rtx metag_compare_op0;
  18771. +extern GTY(()) rtx metag_compare_op1;
  18772. +
  18773. +/* Macros used in the machine description to test the flags. */
  18774. +
  18775. +extern int optimize;
  18776. +
  18777. +#define TARGET_COND_EXEC_OPTIMIZE (optimize && TARGET_COND_EXEC)
  18778. +#define TARGET_MINIM_CORE (TARGET_MINIM && TARGET_MINIM_OPTIMISE)
  18779. +
  18780. +enum metag_jump_table_branch
  18781. +{
  18782. + METAG_MINIM_JUMP_TABLE_BRANCH_AUTO,
  18783. + METAG_MINIM_JUMP_TABLE_BRANCH_LONG,
  18784. + METAG_MINIM_JUMP_TABLE_BRANCH_SHORT
  18785. +};
  18786. +
  18787. +extern int metag_fpu_single;
  18788. +extern enum metag_jump_table_branch metag_jump_table_branch;
  18789. +extern int metag_fpu_resources;
  18790. +extern int metag_force_tbictxsave;
  18791. +
  18792. +/* Access Models
  18793. +
  18794. + The __model__ attribute can be used to select the code model to use when
  18795. + accessing particular objects. */
  18796. +
  18797. +enum metag_model { METAG_MODEL_SMALL, METAG_MODEL_LARGE };
  18798. +
  18799. +extern enum metag_model metag_model;
  18800. +#define TARGET_MODEL_SMALL (metag_model == METAG_MODEL_SMALL)
  18801. +#define TARGET_MODEL_LARGE (metag_model == METAG_MODEL_LARGE)
  18802. +
  18803. +/* Target options */
  18804. +enum metac_target
  18805. +{
  18806. + METAC_1_0_ID,
  18807. + METAC_1_1_ID,
  18808. + METAC_1_2_ID,
  18809. + METAC_0_1_ID,
  18810. + METAC_2_1_ID
  18811. +};
  18812. +
  18813. +extern enum metac_target metac_target;
  18814. +
  18815. +#define TARGET_METAC_0_1 \
  18816. + (metac_target == METAC_0_1_ID)
  18817. +
  18818. +#define TARGET_METAC_1_0 \
  18819. + (metac_target == METAC_1_0_ID)
  18820. +
  18821. +#define TARGET_METAC_1_1 \
  18822. + (metac_target == METAC_1_1_ID || metac_target == METAC_1_2_ID || \
  18823. + metac_target == METAC_0_1_ID || metac_target == METAC_2_1_ID)
  18824. +
  18825. +#define TARGET_METAC_1_2 \
  18826. + (metac_target == METAC_1_2_ID || metac_target == METAC_0_1_ID \
  18827. + metac_target == METAC_2_1_ID)
  18828. +
  18829. +#define TARGET_METAC_2_1 \
  18830. + (metac_target == METAC_2_1_ID)
  18831. +
  18832. +/* target machine storage layout */
  18833. +
  18834. +/* Define this if most significant bit is lowest numbered
  18835. + in instructions that operate on numbered bit-fields. */
  18836. +#define BITS_BIG_ENDIAN 0
  18837. +
  18838. +/* Define this if most significant byte of a word is the lowest numbered. */
  18839. +#define BYTES_BIG_ENDIAN 0
  18840. +
  18841. +/* Define this if most significant word of a multiword is lowest numbered. */
  18842. +#define WORDS_BIG_ENDIAN 0
  18843. +
  18844. +/* number of bits in an addressable storage unit */
  18845. +#define BITS_PER_UNIT 8
  18846. +
  18847. +/* Width in bits of a "word", which is the contents of a machine register.
  18848. + Note that this is not necessarily the width of data type `int';
  18849. + if using 16-bit ints on a metag, this would still be 32.
  18850. + But on a machine with 16-bit registers, this would be 16. */
  18851. +#define BITS_PER_WORD 32
  18852. +
  18853. +/* Width of a word, in units (bytes). */
  18854. +#define UNITS_PER_WORD 4
  18855. +
  18856. +/* Width of a SIMD word, in units (bytes). */
  18857. +#define UNITS_PER_SIMD_WORD 8
  18858. +
  18859. +/* Width in bits of a pointer.
  18860. + See also the macro `Pmode' defined below. */
  18861. +#define POINTER_SIZE 32
  18862. +
  18863. +/* Allocation boundary (in *bits*) for storing arguments in argument list. */
  18864. +#define PARM_BOUNDARY 32
  18865. +
  18866. +/* Boundary (in *bits*) on which stack pointer should be aligned. */
  18867. +#define STACK_BOUNDARY 64
  18868. +
  18869. +#define STACK_BOUNDARY_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  18870. +
  18871. +#define ALIGN_ON_STACK_BOUNDARY(X) \
  18872. + (((X) + STACK_BOUNDARY_BYTES - 1) & ~(STACK_BOUNDARY_BYTES - 1))
  18873. +
  18874. +/* Allocation boundary (in *bits*) for the code of a function. */
  18875. +#define FUNCTION_BOUNDARY 32
  18876. +
  18877. +/* Alignment of field after `int : 0' in a structure. */
  18878. +#define EMPTY_FIELD_BOUNDARY 32
  18879. +
  18880. +/* No data type wants to be aligned rounder than this. */
  18881. +/* metag_emb_asm_select_section asserts that BIGGEST_ALIGNMENT is 64. This is
  18882. + because a specific section is required for any alignment bigger than 4
  18883. + bytes. Currently only 8 byte alignment maximum is supported, anything
  18884. + greater is ignored and converted to 8 byte alignment.
  18885. + 1, 2 and 4 byte alignment do not need special sections as the automatic
  18886. + alignment handling in the assembler will correctly align such sections
  18887. + depending on the data contained within. Only 8 byte must be explicitly
  18888. + stated. */
  18889. +#define BIGGEST_ALIGNMENT 64
  18890. +
  18891. +/* Every structure's size must be a multiple of this. */
  18892. +#define STRUCTURE_SIZE_BOUNDARY 32
  18893. +
  18894. +/* The best alignment to use in cases where we have a choice. */
  18895. +#define FASTEST_ALIGNMENT 32
  18896. +
  18897. +/* Make strings 32-bit aligned so strcpy from constants will be faster. */
  18898. +#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
  18899. + ((TREE_CODE (EXP) == STRING_CST && (ALIGN) < FASTEST_ALIGNMENT) \
  18900. + ? FASTEST_ALIGNMENT : (ALIGN))
  18901. +
  18902. +/* Make arrays of chars 32-bit aligned for the same reasons. */
  18903. +#define DATA_ALIGNMENT(TYPE, ALIGN) \
  18904. + (TREE_CODE (TYPE) == ARRAY_TYPE \
  18905. + && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
  18906. + && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
  18907. +
  18908. +/* Make local arrays of chars 32-bit aligned for the same reasons. */
  18909. +#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
  18910. + (TREE_CODE (TYPE) == ARRAY_TYPE \
  18911. + && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
  18912. + && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
  18913. +
  18914. +/* Define this if move instructions will actually fail to work
  18915. + when given unaligned data. */
  18916. +#define STRICT_ALIGNMENT 1
  18917. +
  18918. +/* Define number of bits in most basic integer type.
  18919. + (If undefined, default is BITS_PER_WORD). */
  18920. +#define INT_TYPE_SIZE 32
  18921. +
  18922. +/* Integer bit fields have the same size and alignment as actual integers */
  18923. +#define PCC_BITFIELD_TYPE_MATTERS 1
  18924. +
  18925. +/* Specify the size_t type. */
  18926. +#define SIZE_TYPE "unsigned int"
  18927. +
  18928. +/* Standard register usage. */
  18929. +
  18930. +/* Number of actual hardware registers.
  18931. + The hardware registers are assigned numbers for the compiler
  18932. + from 0 to just below FIRST_PSEUDO_REGISTER.
  18933. + All registers that the compiler knows about must be given numbers,
  18934. + even those that are not normally considered general registers. */
  18935. +#define FIRST_PSEUDO_REGISTER 74
  18936. +
  18937. +/* 1 for registers that have pervasive standard uses
  18938. + and are not available for the register allocator. */
  18939. +#define FIXED_REGISTERS \
  18940. +{ \
  18941. + /* D0.0/D1.0-D0.7/D1.7 */ \
  18942. + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, \
  18943. + /* D0.8/D1.8-D0.15/D1.15 currently reserved */ \
  18944. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18945. + /* A0.0/A1.0-A0.7/A1.7 */ \
  18946. + 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, \
  18947. + /* FRAME, CC, ARGP, RAPF, CPC0, CPC1, PC, TXRPT */ \
  18948. + 1, 1, 1, 1, 1, 1, 1, 1, \
  18949. + /* FX */ \
  18950. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18951. + /* TTREC(L) */ \
  18952. + 1, 1 \
  18953. +}
  18954. +
  18955. +/* 1 for registers not available across function calls.
  18956. + These must include the FIXED_REGISTERS and also any
  18957. + registers that can be used without being saved.
  18958. + The latter must include the registers where values are returned
  18959. + and the register where structure-value addresses are passed.
  18960. + Aside from that, you can include as many other registers as you like. */
  18961. +#define CALL_USED_REGISTERS \
  18962. +{ \
  18963. + /* D0.0/D1.0-D0.7/D1.7 */ \
  18964. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, \
  18965. + /* D0.8-D0.15/D1.8-D1.15 currently reserved */ \
  18966. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18967. + /* A0.0/A1.0-A0.7/A1.7 */ \
  18968. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18969. + /* FRAME, CC, ARGP, RAPF, CPC0, CPC1, PC, TXRPT */ \
  18970. + 1, 1, 1, 1, 1, 1, 1, 1, \
  18971. + /* FX */ \
  18972. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18973. + /* TTREC(L) */ \
  18974. + 1, 1 \
  18975. +}
  18976. +
  18977. +/* Like `CALL_USED_REGISTERS' except this macro doesn't require that
  18978. + the entire set of `FIXED_REGISTERS' be included.
  18979. + (`CALL_USED_REGISTERS' must be a superset of `FIXED_REGISTERS').
  18980. + This macro is optional. If not specified, it defaults to the value
  18981. + of `CALL_USED_REGISTERS'. */
  18982. +
  18983. +#define CALL_REALLY_USED_REGISTERS \
  18984. +{ \
  18985. + /* D0/D1 */ \
  18986. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, \
  18987. + /* D0/D1 currently reserved */ \
  18988. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18989. + /* A0/A1 */ \
  18990. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18991. + /* FRAME, CC, ARGP, RAPF, CPC0, CPC1, PC, TXRPT */ \
  18992. + 1, 1, 1, 1, 1, 1, 1, 0, \
  18993. + /* FX */ \
  18994. + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  18995. + /* TTREC(L) */ \
  18996. + 1, 1 \
  18997. +}
  18998. +
  18999. +/* Make sure everything's fine if we *don't* have a given processor.
  19000. + This assumes that putting a register in fixed_regs will keep the
  19001. + compilers mitt's completely off it. We don't bother to zero it out
  19002. + of register classes. */
  19003. +#define CONDITIONAL_REGISTER_USAGE \
  19004. + do { \
  19005. + static const int bases[] = {16, 17, 40, 41, 0}; \
  19006. + static const int strides[] = { 2, 2, 2, 2, 0}; \
  19007. + static const int limits[] = { 8, 8, 4, 4, 0}; \
  19008. + const char *pmetagopt = metag_extreg_string; \
  19009. + int unit; \
  19010. + long int fpuregs = strtol (metag_fpureg_string, NULL, 10); \
  19011. + bool extended_reg_enabled = false; \
  19012. + \
  19013. + /* Minimum 3 fpu regs, maximum 16 */ \
  19014. + if (fpuregs != 0) \
  19015. + { \
  19016. + /* The compiler may use FX registers so all sections are FPU*/ \
  19017. + metag_fpu_resources = 1; \
  19018. + fpuregs = (fpuregs > 16) ? 16 : (fpuregs < 3) ? 3 : fpuregs; \
  19019. + } \
  19020. + \
  19021. + if (strlen (pmetagopt) != 0 && strlen (pmetagopt) != 4) \
  19022. + error ("-mextreg takes an argument of four digits"); \
  19023. + \
  19024. + if (TARGET_METAC_1_1) \
  19025. + { \
  19026. + /* Don't need temporary registers in AX unit */ \
  19027. + fixed_regs[A0_3_REG] = 0; \
  19028. + fixed_regs[A1_3_REG] = 0; \
  19029. + /* Hence compact default/minimum register set to 8844 for v1.1 */ \
  19030. + fixed_regs[A0_4_REG] = 1; \
  19031. + fixed_regs[A1_4_REG] = 1; \
  19032. + } \
  19033. + \
  19034. + /* Enabled only the extended regs specified in the extreg string */ \
  19035. + for (unit = 0; *pmetagopt != 0 && limits[unit]; unit++) \
  19036. + { \
  19037. + int add = (*pmetagopt++ - '0'); \
  19038. + int reg = bases[unit]; \
  19039. + \
  19040. + if (add > limits[unit]) \
  19041. + add = limits[unit]; \
  19042. + \
  19043. + while (add-- > 0) \
  19044. + { \
  19045. + if (TARGET_MTX) \
  19046. + error ("MTX does not support extended registers\n"); \
  19047. + extended_reg_enabled = true; \
  19048. + fixed_regs[reg] = 0; \
  19049. + reg += strides[unit]; \
  19050. + } \
  19051. + } \
  19052. + \
  19053. + if (extended_reg_enabled && metag_force_tbictxsave) \
  19054. + target_flags |= MASK_ECH; \
  19055. + \
  19056. + if (TARGET_ECH) \
  19057. + { \
  19058. + if (fixed_regs[METAG_ECH_REGNUM] == 0) \
  19059. + fixed_regs[METAG_ECH_REGNUM] = 1; \
  19060. + else \
  19061. + error ("-mtbictxsave cannot be used unless D0.8 is enabled via -mextreg\n" \
  19062. + "Either use -mno-tbictxsave or enable D0.8"); \
  19063. + } \
  19064. + \
  19065. + for ( ; fpuregs > 0 ; fpuregs-- ) \
  19066. + fixed_regs[FIRST_FP_REG+fpuregs-1] = 0; \
  19067. + \
  19068. + if (METAG_FLAG_PIC) \
  19069. + fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1 ; \
  19070. + } while (0)
  19071. +
  19072. +/* Determine which register classes are very likely used by spill registers.
  19073. + local-alloc.c won't allocate pseudos that have these classes as their
  19074. + preferred class unless they are "preferred or nothing". */
  19075. +
  19076. +#define CLASS_LIKELY_SPILLED_P(CLASS) \
  19077. + (reg_class_size[(int) (CLASS)] == 1 \
  19078. + || (CLASS) == A0_REGS \
  19079. + || (CLASS) == A1_REGS \
  19080. + || (CLASS) == A_REGS \
  19081. + || (CLASS) == Ye_REGS \
  19082. + || (CLASS) == Yf_REGS \
  19083. + || (CLASS) == Yd_REGS \
  19084. + || (CLASS) == Yh_REGS \
  19085. + || (CLASS) == Yl_REGS \
  19086. + || (CLASS) == Ya_REGS \
  19087. + || (CLASS) == Yr_REGS)
  19088. +
  19089. +/* The order in which registers should be allocated is defined so that the
  19090. + result registers are treated as the last scratch registers to be used
  19091. + after the argument registers are used in least likely used first order.
  19092. + Then we do the call-saved registers and address unit registers in numeric
  19093. + order - which is the default anyway. */
  19094. +#define REG_ALLOC_ORDER \
  19095. +{ \
  19096. + /* D0.4 happens to be a completely free scratch register */ \
  19097. + D0_4_REG, \
  19098. + /* If we have tons of free scratch data registers use them first */ \
  19099. + D0_8_REG, D1_8_REG, D0_9_REG, D1_9_REG, D0_10_REG, D1_10_REG, \
  19100. + D0_11_REG, D1_11_REG, D0_12_REG, D1_12_REG, D0_13_REG, D1_13_REG, \
  19101. + D0_14_REG, D1_14_REG, D0_15_REG, D1_15_REG, \
  19102. + /* Then use the args and result registers in least-used first order */ \
  19103. + /* The D0.1 and D1.1 are however used for 12bit offsets so are */ \
  19104. + /* towards the end */ \
  19105. + D0_2_REG, D1_2_REG, D0_3_REG, D1_3_REG, \
  19106. + D0_1_REG, D1_1_REG, D1_0_REG, D0_0_REG, \
  19107. + /* Then use the call-saved registers */ \
  19108. + D0_5_REG, D1_5_REG, D0_6_REG, D1_6_REG, D0_7_REG, D1_7_REG, \
  19109. + /* Then use the address unit scratch registers */ \
  19110. + A0_2_REG, A1_2_REG, A0_3_REG, A1_3_REG, A0_4_REG, A1_4_REG, \
  19111. + A0_5_REG, A1_5_REG, A0_6_REG, A1_6_REG, A0_7_REG, A1_7_REG, \
  19112. + /* FX - disuade use of FCC_REGS class */ \
  19113. + FX_0_REG , FX_1_REG , FX_2_REG , FX_3_REG , \
  19114. + FX_4_REG , FX_5_REG , FX_6_REG , FX_7_REG , \
  19115. + FX_8_REG , FX_9_REG , FX_10_REG, FX_11_REG, \
  19116. + FX_12_REG, FX_13_REG, FX_14_REG, FX_15_REG, \
  19117. + TXRPT_REG, TTREC_REG, TTRECL_REG, \
  19118. + /* The remainder can never be allocated by the compiler anyway */ \
  19119. + D1_4_REG, A0_0_REG, A1_0_REG, A0_1_REG, A1_1_REG, \
  19120. + FRAME_REG, CC_REG, ARGP_REG, RAPF_REG, CPC0_REG, CPC1_REG, PC_REG \
  19121. +}
  19122. +
  19123. +/* Specify the registers used for certain standard purposes.
  19124. + The values of these macros are register numbers. */
  19125. +
  19126. +/* Register used for the program counter */
  19127. +#define PC_REGNUM PC_REG
  19128. +
  19129. +/* Logical base register for access to arguments of the function. */
  19130. +#define ARG_POINTER_REGNUM ARGP_REG
  19131. +
  19132. +/* Condition flag register */
  19133. +#define MCC_REGNUM CC_REG
  19134. +
  19135. +/* Extended context support register */
  19136. +#define METAG_ECH_REGNUM D0_8_REG
  19137. +
  19138. +/* Logical base register for access to local variables of the function. */
  19139. +#define FRAME_POINTER_REGNUM FRAME_REG
  19140. +
  19141. +/* Real frame pointer register */
  19142. +#define HARD_FRAME_POINTER_REGNUM A0FrP_REG
  19143. +
  19144. +/* First and last register that accepts function arguments, D1.3 - D0.1 */
  19145. +#define MIN_METAG_PARM_REGNUM D0Ar6_REG /* Actually contains last arg! */
  19146. +#define MAX_METAG_PARM_REGNUM D1Ar1_REG /* Actually contains first arg! */
  19147. +
  19148. +/* The number of registers used for parameter passing. Local to this file. */
  19149. +#define MAX_METAG_PARM_REGS (1 + (MAX_METAG_PARM_REGNUM - MIN_METAG_PARM_REGNUM))
  19150. +#define MAX_METAG_PARM_BYTES (MAX_METAG_PARM_REGS * UNITS_PER_WORD)
  19151. +
  19152. +/* D0.4 is used temporarily to save/restore A0FrP */
  19153. +#define TEMP_D0FRT_REGNUM D0FrT_REG
  19154. +
  19155. +/* First and last register that is call-saved, D0.5 - D1.7 */
  19156. +#define MIN_METAG_CSAVE_REGNUM D0_5_REG
  19157. +#define MAX_METAG_CSAVE_REGNUM D1_7_REG
  19158. +
  19159. +/* Register to use for call/return addresses D1RtP */
  19160. +#define RETURN_POINTER_REGNUM D1RtP_REG
  19161. +
  19162. +/* Register to use for pushing function arguments. */
  19163. +#define STACK_POINTER_REGNUM A0StP_REG
  19164. +
  19165. +/* Register in which static-chain is passed to a function. */
  19166. +#define GLOBAL_POINTER_REGNUM A1GbP_REG
  19167. +#define STATIC_CHAIN_REGNUM D0Re0_REG
  19168. +
  19169. +/* Some temporaries are currently left for internal library/config use */
  19170. +#define A0_SCRATCH (!TARGET_METAC_1_1 ? A0_3_REG : INVALID_REGNUM)
  19171. +#define A1_SCRATCH (!TARGET_METAC_1_1 ? A1_3_REG : INVALID_REGNUM)
  19172. +
  19173. +/* Structure value address is passed is 'hidden' parameter */
  19174. +#define STRUCT_VALUE 0
  19175. +
  19176. +#define RAPF_REGNUM RAPF_REG
  19177. +
  19178. +#define CPC0_REGNUM CPC0_REG
  19179. +#define CPC1_REGNUM CPC1_REG
  19180. +
  19181. +#define TXRPT_REGNUM TXRPT_REG
  19182. +#define TTREC_REGNUM TTREC_REG
  19183. +
  19184. +#define DECREMENT_AND_BRANCH_REG(MODE) gen_rtx_REG (MODE, TXRPT_REGNUM)
  19185. +
  19186. +#define TABLEJUMP_USES_DBRA_REG 0
  19187. +
  19188. +/* Value should be nonzero if functions must have frame pointers.
  19189. + Zero means the frame pointer need not be set up (and parms
  19190. + may be accessed via the stack pointer) in functions that seem suitable.
  19191. + This is computed in `reload', in reload1.c. */
  19192. +#define FRAME_POINTER_REQUIRED \
  19193. + metag_frame_pointer_required ()
  19194. +
  19195. +#define SETUP_FRAME_ADDRESSES() \
  19196. + metag_setup_frame_addresses ()
  19197. +
  19198. +/* Definitions for register eliminations.
  19199. +
  19200. + This is an array of structures. Each structure initializes one pair
  19201. + of eliminable registers. The "from" register number is given first,
  19202. + followed by "to". Eliminations of the same "from" register are listed
  19203. + in order of preference.
  19204. +
  19205. + We have two registers that MUST be eliminated FRAME_POINTER and
  19206. + ARG_POINTER. ARG_POINTER is ALWAYS eliminated to either STACK_POINTER_REGNUM
  19207. + or HARD_FRAME_POINTER_REGNUM. FRAME_POINTER is ALWAYS eliminated to either
  19208. + STACK_POINTER_REGNUM or HARD_FRAME_POINTER_REGNUM.
  19209. +
  19210. + STACK_POINTER_REGUM is the preferred elimination. */
  19211. +
  19212. +#define ELIMINABLE_REGS \
  19213. +{ \
  19214. + {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  19215. + {ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
  19216. + {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  19217. + {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM} \
  19218. +}
  19219. +
  19220. +/* Given FROM and TO register numbers, say whether this elimination is allowed.
  19221. + Frame pointer elimination is automatically handled.
  19222. +
  19223. + Only eliminate down to the HARD_FRAME_POINTER if it's available. */
  19224. +#define CAN_ELIMINATE(FROM, TO) \
  19225. + (((TO) == STACK_POINTER_REGNUM && frame_pointer_needed) ? 0 : 1)
  19226. +
  19227. +/* Define the offset between two registers, one to be eliminated,
  19228. + and the other its replacement, at the start of a routine.
  19229. + */
  19230. +
  19231. +#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
  19232. + ((OFFSET) = metag_initial_elimination_offset (FROM, TO))
  19233. +
  19234. +/* Return number of consecutive hard regs needed starting at reg REGNO
  19235. + to hold something of mode MODE.
  19236. + This is ordinarily the length in words of a value of mode MODE
  19237. + but can be less for certain modes in special long registers. */
  19238. +#define HARD_REGNO_NREGS(REGNO, MODE) \
  19239. + ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  19240. +
  19241. +/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
  19242. +#define HARD_REGNO_MODE_OK(REGNO, MODE) \
  19243. + metag_hard_regno_mode_ok (REGNO, MODE)
  19244. +
  19245. +/* Value is 1 if it is a good idea to tie two pseudo registers
  19246. + when one has mode MODE1 and one has mode MODE2.
  19247. + If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
  19248. + for any hard reg, then this must be 0 for correct output. */
  19249. +#define MODES_TIEABLE_P(MODE1, MODE2) \
  19250. + (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
  19251. +
  19252. +/* Define the classes of registers for register constraints in the
  19253. + machine description. Also define ranges of constants.
  19254. +
  19255. + One of the classes must always be named ALL_REGS and include all hard regs.
  19256. + If there is more than one class, another class must be named NO_REGS
  19257. + and contain no registers.
  19258. +
  19259. + The name GENERAL_REGS must be the name of a class (or an alias for
  19260. + another name such as ALL_REGS). This is the class of registers
  19261. + that is allowed by "g" or "r" in a register constraint.
  19262. + Also, registers outside this class are allocated only when
  19263. + instructions express preferences for them.
  19264. +
  19265. + The classes must be numbered in nondecreasing order; that is,
  19266. + a larger-numbered class must never be contained completely
  19267. + in a smaller-numbered class.
  19268. +
  19269. + For any two classes, it is very desirable that there be another
  19270. + class that represents their union. */
  19271. +
  19272. +enum reg_class
  19273. +{
  19274. + NO_REGS,
  19275. + Wx_REGS,
  19276. + WQh_REGS,
  19277. + WQl_REGS,
  19278. + Ye_REGS,
  19279. + Yf_REGS,
  19280. + Yd_REGS,
  19281. + Yh_REGS,
  19282. + Yl_REGS,
  19283. + Ya_REGS,
  19284. + Yr_REGS,
  19285. + D0_REGS,
  19286. + D1_REGS,
  19287. + D_REGS,
  19288. + A0_REGS,
  19289. + A1_REGS,
  19290. + A_REGS,
  19291. + DA_REGS,
  19292. + Be_REGS,
  19293. + Bf_REGS,
  19294. + Bd_REGS,
  19295. + Bh_REGS,
  19296. + Bl_REGS,
  19297. + Ba_REGS,
  19298. + Br_REGS,
  19299. + nD0_REGS,
  19300. + nD1_REGS,
  19301. + nA0_REGS,
  19302. + nA1_REGS,
  19303. + nBU_REGS,
  19304. + nYe_REGS,
  19305. + nYf_REGS,
  19306. + nYd_REGS,
  19307. + nYh_REGS,
  19308. + nYl_REGS,
  19309. + nYa_REGS,
  19310. + nYr_REGS,
  19311. + GENERAL_REGS,
  19312. + FPP_REGS,
  19313. + FPC_REGS,
  19314. + cD0_REGS,
  19315. + cD1_REGS,
  19316. + cD_REGS,
  19317. + cA0_REGS,
  19318. + cA1_REGS,
  19319. + cA_REGS,
  19320. + cnD0_REGS,
  19321. + cnD1_REGS,
  19322. + cnA0_REGS,
  19323. + cnA1_REGS,
  19324. + cDA_REGS,
  19325. + ALL_REGS,
  19326. + LIM_REG_CLASSES
  19327. +};
  19328. +
  19329. +#define N_REG_CLASSES ((int) LIM_REG_CLASSES)
  19330. +
  19331. +/* Give names of register classes as strings for dump file. */
  19332. +
  19333. +#define REG_CLASS_NAMES \
  19334. +{ \
  19335. + "NO_REGS", \
  19336. + "Wx_REGS", \
  19337. + "WQh_REGS", \
  19338. + "WQl_REGS", \
  19339. + "Ye_REGS", \
  19340. + "Yf_REGS", \
  19341. + "Yd_REGS", \
  19342. + "Yh_REGS", \
  19343. + "Yl_REGS", \
  19344. + "Ya_REGS", \
  19345. + "Yr_REGS", \
  19346. + "D0_REGS", \
  19347. + "D1_REGS", \
  19348. + "D_REGS", \
  19349. + "A0_REGS", \
  19350. + "A1_REGS", \
  19351. + "A_REGS", \
  19352. + "DA_REGS", \
  19353. + "Be_REGS", \
  19354. + "Bf_REGS", \
  19355. + "Bd_REGS", \
  19356. + "Bh_REGS", \
  19357. + "Bl_REGS", \
  19358. + "Ba_REGS", \
  19359. + "Br_REGS", \
  19360. + "nD0_REGS", \
  19361. + "nD1_REGS", \
  19362. + "nA0_REGS", \
  19363. + "nA1_REGS", \
  19364. + "nBU_REGS", \
  19365. + "nYe_REGS", \
  19366. + "nYf_REGS", \
  19367. + "nYd_REGS", \
  19368. + "nYh_REGS", \
  19369. + "nYl_REGS", \
  19370. + "nYa_REGS", \
  19371. + "nYr_REGS", \
  19372. + "GENERAL_REGS", \
  19373. + "FPP_REGS", \
  19374. + "FPC_REGS", \
  19375. + "cD0_REGS", \
  19376. + "cD1_REGS", \
  19377. + "cD_REGS", \
  19378. + "cA0_REGS", \
  19379. + "cA1_REGS", \
  19380. + "cA_REGS", \
  19381. + "cnD0_REGS", \
  19382. + "cnD1_REGS", \
  19383. + "cnA0_REGS", \
  19384. + "cnA1_REGS", \
  19385. + "cDA_REGS", \
  19386. + "ALL_REGS" \
  19387. +}
  19388. +
  19389. +/* Define which registers fit in which classes.
  19390. + This is an initializer for a vector of HARD_REG_SET
  19391. + of length N_REG_CLASSES. */
  19392. +
  19393. +#define REG_CLASS_CONTENTS \
  19394. +{ \
  19395. + { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
  19396. + { 0x00000000, 0x00800000, 0x00000300 }, /* Wx_REGS */ \
  19397. + { 0x00000000, 0x00000050, 0x00000000 }, /* WQh_REGS */ \
  19398. + { 0x00000000, 0x000000a0, 0x00000000 }, /* WQl_REGS */ \
  19399. + { 0x00000005, 0x00000000, 0x00000000 }, /* Ye_REGS */ \
  19400. + { 0x0000000a, 0x00000000, 0x00000000 }, /* Yf_REGS */ \
  19401. + { 0x0000000f, 0x00000000, 0x00000000 }, /* Yd_REGS */ \
  19402. + { 0x00000000, 0x00000005, 0x00000000 }, /* Yh_REGS */ \
  19403. + { 0x00000000, 0x0000000a, 0x00000000 }, /* Yl_REGS */ \
  19404. + { 0x00000000, 0x0000000f, 0x00000000 }, /* Ya_REGS */ \
  19405. + { 0x0000000f, 0x0000000f, 0x00000000 }, /* Yr_REGS */ \
  19406. + { 0x55555555, 0x00000000, 0x00000000 }, /* D0_REGS */ \
  19407. + { 0xaaaaaaaa, 0x00000000, 0x00000000 }, /* D1_REGS */ \
  19408. + { 0xffffffff, 0x00000000, 0x00000000 }, /* D_REGS */ \
  19409. + { 0x00000000, 0x00005555, 0x00000000 }, /* A0_REGS */ \
  19410. + { 0x00000000, 0x0000aaaa, 0x00000000 }, /* A1_REGS */ \
  19411. + { 0x00000000, 0x0000ffff, 0x00000000 }, /* A_REGS */ \
  19412. + { 0xffffffff, 0x0000ffff, 0x00000000 }, /* DA_REGS */ \
  19413. + { 0x5555ffff, 0x0000ffff, 0x00000000 }, /* Be_REGS */ \
  19414. + { 0xaaaaffff, 0x0000ffff, 0x00000000 }, /* Bf_REGS */ \
  19415. + { 0x0000ffff, 0x0000ffff, 0x00000000 }, /* Bd_REGS */ \
  19416. + { 0x0000ffff, 0x0000ffff, 0x00000000 }, /* Bh_REGS */ \
  19417. + { 0x0000ffff, 0x0000ffff, 0x00000000 }, /* Bl_REGS */ \
  19418. + { 0x0000ffff, 0x0000ffff, 0x00000000 }, /* Ba_REGS */ \
  19419. + { 0x0000ffff, 0x0000ffff, 0x00000000 }, /* Br_REGS */ \
  19420. + { 0xaaaaaaaa, 0x0000ffff, 0x00000000 }, /* nD0_REGS */ \
  19421. + { 0x55555555, 0x0000ffff, 0x00000000 }, /* nD1_REGS */ \
  19422. + { 0xffffffff, 0x0000aaaa, 0x00000000 }, /* nA0_REGS */ \
  19423. + { 0xffffffff, 0x00005555, 0x00000000 }, /* nA1_REGS */ \
  19424. + { 0xffff0000, 0x00000000, 0x00000000 }, /* nBU_REGS */ \
  19425. + { 0xfffffffa, 0x0000ffff, 0x00000000 }, /* nYe_REGS */ \
  19426. + { 0xfffffff5, 0x0000ffff, 0x00000000 }, /* nYf_REGS */ \
  19427. + { 0xfffffff0, 0x0000ffff, 0x00000000 }, /* nYd_REGS */ \
  19428. + { 0xffffffff, 0x0000fffa, 0x00000000 }, /* nYh_REGS */ \
  19429. + { 0xffffffff, 0x0000fff5, 0x00000000 }, /* nYl_REGS */ \
  19430. + { 0xffffffff, 0x0000fff0, 0x00000000 }, /* nYa_REGS */ \
  19431. + { 0xfffffff0, 0x0000fff0, 0x00000000 }, /* nYr_REGS */ \
  19432. + { 0xffffffff, 0x0000ffff, 0x00000000 }, /* GENERAL_REGS */ \
  19433. + { 0x00000000, 0x55000000, 0x00000055 }, /* FPP_REGS */ \
  19434. + { 0x00000000, 0xff000000, 0x000000ff }, /* FPC_REGS */ \
  19435. + { 0x55555555, 0xff000000, 0x000000ff }, /* cD0_REGS */ \
  19436. + { 0xaaaaaaaa, 0xff000000, 0x000000ff }, /* cD1_REGS */ \
  19437. + { 0xffffffff, 0xff000000, 0x000000ff }, /* cD_REGS */ \
  19438. + { 0x00000000, 0xff005555, 0x000000ff }, /* cA0_REGS */ \
  19439. + { 0x00000000, 0xff00aaaa, 0x000000ff }, /* cA1_REGS */ \
  19440. + { 0x00000000, 0xff00ffff, 0x000000ff }, /* cA_REGS */ \
  19441. + { 0xaaaaaaaa, 0xff00ffff, 0x000000ff }, /* cnD0_REGS */ \
  19442. + { 0x55555555, 0xff00ffff, 0x000000ff }, /* cnD1_REGS */ \
  19443. + { 0xffffffff, 0xff00aaaa, 0x000000ff }, /* cnA0_REGS */ \
  19444. + { 0xffffffff, 0xff005555, 0x000000ff }, /* cnA1_REGS */ \
  19445. + { 0xffffffff, 0xff00ffff, 0x000000ff }, /* cDA_REGS */ \
  19446. + { 0xffffffff, 0xff80ffff, 0x000003ff } /* ALL_REGS */ \
  19447. +}
  19448. +
  19449. +/* The same information, inverted:
  19450. + Return the class number of the smallest class containing
  19451. + reg number REGNO. This could be a conditional expression
  19452. + or could index an array. */
  19453. +
  19454. +#define REGNO_REG_CLASS(REGNO) \
  19455. + metag_regno_reg_class_minimal (REGNO)
  19456. +
  19457. +#define METAG_REGNO_REG_CLASS(REGNO) \
  19458. + metag_regno_reg_class_unit (REGNO)
  19459. +
  19460. +#define METAG_REGNO_SAME_UNIT(REGNUM1, REGNUM2) \
  19461. + metag_regno_same_unit_p (REGNUM1, REGNUM2)
  19462. +
  19463. +/* The class value for index registers, and the one for base regs. */
  19464. +#define INDEX_REG_CLASS NO_REGS
  19465. +#define BASE_REG_CLASS GENERAL_REGS
  19466. +
  19467. +#define IN_RANGE_P(VALUE, LOW, HIGH) \
  19468. + ((LOW) <= (VALUE) && (VALUE) <= (HIGH))
  19469. +
  19470. +#define METAG_CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0
  19471. +
  19472. +/* Define the cost of moving between registers of various classes. */
  19473. +#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
  19474. + ((int)(CLASS1) == (int)(CLASS2) ? 1 : 4 )
  19475. +
  19476. +/* A C expressions returning the cost of moving data of MODE from a register to
  19477. + or from memory. Keep it higher than max register/register costs */
  19478. +#define MEMORY_MOVE_COST(MODE, CLASS, IN) 8
  19479. +
  19480. +/* Given an rtx X being reloaded into a reg required to be
  19481. + in class CLASS, return the class of reg to actually use.
  19482. + In general this is just CLASS; but on some machines
  19483. + in some cases it is preferable to use a more restrictive class. */
  19484. +#define PREFERRED_RELOAD_CLASS(X, CLASS) (CLASS)
  19485. +
  19486. +#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
  19487. + metag_secondary_reload_class (CLASS, MODE, X, true)
  19488. +
  19489. +#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
  19490. + metag_secondary_reload_class (CLASS, MODE, X, false)
  19491. +
  19492. +/* Return the maximum number of consecutive registers
  19493. + needed to represent mode MODE in a register of class CLASS. */
  19494. +#define CLASS_MAX_NREGS(CLASS, MODE) \
  19495. + ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  19496. +
  19497. +/* Stack layout; function entry, exit and calling. */
  19498. +
  19499. +/* Define this if pushing a word on the stack
  19500. + makes the stack pointer a smaller address. */
  19501. +/*#define STACK_GROWS_DOWNWARD*/
  19502. +
  19503. +/* Define this if the nominal address of the stack frame
  19504. + is at the high-address end of the local variables;
  19505. + that is, each additional local variable allocated
  19506. + goes at a more negative offset in the frame. */
  19507. +/* #define FRAME_GROWS_DOWNWARD */
  19508. +
  19509. +#define ARGS_GROW_DOWNWARD
  19510. +
  19511. +/* We use post increment on metag because of 64-bit vs 32-bit alignments */
  19512. +#define STACK_PUSH_CODE POST_INC
  19513. +
  19514. +/* Offset within stack frame to start allocating local variables at.
  19515. + If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
  19516. + first local allocated. Otherwise, it is the offset to the BEGINNING
  19517. + of the first local allocated. */
  19518. +#define STARTING_FRAME_OFFSET 0
  19519. +
  19520. +/* This points to the location of dynamically allocated memory on the stack
  19521. + immediately after the stack pointer has been adjusted by the amount of
  19522. + memory desired. */
  19523. +#define STACK_DYNAMIC_OFFSET(FNDECL) \
  19524. + (-(current_function_outgoing_args_size + (STACK_POINTER_OFFSET)))
  19525. +
  19526. +/* If we generate an insn to push BYTES bytes,
  19527. + this says how many the stack pointer really advances by.
  19528. + (incompatible with ACCUMULATE_OUTGOING_ARGS)
  19529. +#define PUSH_ROUNDING(BYTES) (((BYTES) + 3) & ~3) */
  19530. +
  19531. +/* If nonzero, the maximum amount of space required for outgoing arguments will be
  19532. + computed and placed into the variable current_function_outgoing_args_size. No space
  19533. + will be pushed onto the stack for each call; instead, the function prologue should
  19534. + increase the stack frame size by this amount. Setting both PUSH_ARGS and
  19535. + ACCUMULATE_OUTGOING_ARGS is not proper.
  19536. +*/
  19537. +#define ACCUMULATE_OUTGOING_ARGS 1
  19538. +
  19539. +/* Offset of first parameter from the argument pointer register value. */
  19540. +#define FIRST_PARM_OFFSET(FNDECL) \
  19541. + metag_first_parm_offset (FNDECL)
  19542. +
  19543. +/* A C expression whose value is RTL representing the value of the return
  19544. + address for the frame COUNT steps up from the current frame. */
  19545. +
  19546. +#define RETURN_ADDR_RTX(COUNT, FRAME) \
  19547. + metag_return_addr_rtx (COUNT, FRAME)
  19548. +
  19549. +/* Value is 1 if returning from a function call automatically
  19550. + pops the arguments described by the number-of-args field in the call.
  19551. + FUNDECL is the declaration node of the function (as a tree),
  19552. + FUNTYPE is the data type of the function (as a tree),
  19553. + or for a library call it is an identifier node for the subroutine name. */
  19554. +
  19555. +#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) (0)
  19556. +
  19557. +/* Define how to find the value returned by a library function
  19558. + assuming the value has mode MODE. */
  19559. +
  19560. +/* On the metag the return value is in D0.0/D1.0 regardless. */
  19561. +
  19562. +#define LIBCALL_VALUE(MODE) metag_libcall_value (MODE)
  19563. +
  19564. +/* 1 if N is a possible register number for a function value.
  19565. + On the metag, D1.0/D1.1 is the only register thus used. */
  19566. +
  19567. +#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
  19568. +
  19569. +/* A C expression which can inhibit the returning of certain function values
  19570. + in registers, based on the type of value. A nonzero value says to return
  19571. + the function value in memory, just as large structures are always
  19572. + returned. Here type will be a C expression of type tree, representing the
  19573. + data type of the value. We target all 64-bit or less structures as return
  19574. + in registers. */
  19575. +#define RETURN_IN_MEMORY(TYPE) metag_return_in_memory (TYPE)
  19576. +
  19577. +/* Define this macro to be 1 if all structure and union return values must be
  19578. + in memory. We want 64-bit structs to return in registers under the control
  19579. + of the RETURN_IN_MEMORY macro. */
  19580. +#define DEFAULT_PCC_STRUCT_RETURN 0
  19581. +
  19582. +/* 1 if N is a possible register number for function argument passing. */
  19583. +#define FUNCTION_ARG_REGNO_P(N) \
  19584. + (MIN_METAG_PARM_REGNUM <= (N) && (N) <= MAX_METAG_PARM_REGNUM)
  19585. +
  19586. +/* Define a data type for recording info about an argument list
  19587. + during the scan of that argument list. This data type should
  19588. + hold all necessary information about the function itself
  19589. + and about the args processed so far, enough to enable macros
  19590. + such as FUNCTION_ARG to determine where the next arg should go.
  19591. +
  19592. + On the metag, this is a single integer, which is a number of bytes
  19593. + of arguments scanned so far. */
  19594. +struct cumulative_args
  19595. +{
  19596. + int narg;
  19597. + int partial;
  19598. +};
  19599. +
  19600. +#define CUMULATIVE_ARGS struct cumulative_args
  19601. +
  19602. +/* Initialize a variable CUM of type CUMULATIVE_ARGS
  19603. + for a call to a function whose data type is FNTYPE.
  19604. + For a library call, FNTYPE is 0. */
  19605. +#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
  19606. + ((CUM).narg = 0, (CUM).partial = 0)
  19607. +
  19608. +/* Round VALUE up to next multiple of SIZE (Assumes SIZE is 2^N for some N */
  19609. +#define ROUND_TO_SIZE(VALUE, SIZE) \
  19610. + (((VALUE) + (SIZE) - 1) & ~((SIZE) - 1))
  19611. +
  19612. +/* Round VALUE up to a double word boundary */
  19613. +#define ROUND_TO_DWORD(VALUE) \
  19614. + ROUND_TO_SIZE (VALUE, 2 * UNITS_PER_WORD)
  19615. +
  19616. +/* Round VALUE up to a word boundary */
  19617. +#define ROUND_TO_WORD(VALUE) \
  19618. + ROUND_TO_SIZE (VALUE, UNITS_PER_WORD)
  19619. +
  19620. +/* Round VALUE up to a word boundary */
  19621. +#define ROUND_ADVANCE(VALUE) \
  19622. + ROUND_TO_WORD (VALUE)
  19623. +
  19624. +/* Argument size rounded up to word size. */
  19625. +#define METAG_ARG_SIZE(MODE, TYPE) \
  19626. + ((MODE) == BLKmode \
  19627. + ? ROUND_TO_WORD (int_size_in_bytes (TYPE)) \
  19628. + : ROUND_TO_WORD (GET_MODE_SIZE (MODE)))
  19629. +
  19630. +/* Round arg MODE/TYPE up to the next word boundary. */
  19631. +#define ROUND_ADVANCE_ARG(MODE, TYPE) \
  19632. + METAG_ARG_SIZE (MODE, TYPE)
  19633. +
  19634. +/* Round CUM up to the necessary point for argument MODE/TYPE. */
  19635. +#define ROUND_ADVANCE_CUM(CUM, MODE, TYPE) \
  19636. + (METAG_ARG_SIZE (MODE, TYPE) > UNITS_PER_WORD \
  19637. + ? (ROUND_TO_DWORD ((CUM) + METAG_ARG_SIZE (MODE, TYPE)) \
  19638. + - METAG_ARG_SIZE (MODE, TYPE)) \
  19639. + : (CUM))
  19640. +
  19641. +/* Offset base register by one for 64-bit atomic values and the whole size of
  19642. + struct/union parameters */
  19643. +#define ROUND_BASEREG_NUM(MODE, TYPE) \
  19644. + ((ROUND_ADVANCE_ARG (MODE, TYPE) / UNITS_PER_WORD) - 1)
  19645. +
  19646. +/* Update the data in CUM to advance over an argument of mode MODE and data
  19647. + type TYPE. TYPE is null for libcalls where that information may not be
  19648. + available. */
  19649. +#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
  19650. + metag_function_arg_advance (&(CUM), MODE, TYPE, NAMED)
  19651. +
  19652. +/* Calculate register to place argument. align correctly for 64-bit data */
  19653. +#define CALCULATE_REG(BASE_REG, CUM, MODE, TYPE) \
  19654. + ((BASE_REG) - ((ROUND_ADVANCE_CUM (CUM, MODE, TYPE) / UNITS_PER_WORD) \
  19655. + + ROUND_BASEREG_NUM (MODE, TYPE)))
  19656. +
  19657. +/* Define where to put the arguments to a function.
  19658. + Value is zero to push the argument on the stack,
  19659. + or a hard register in which to store the argument.
  19660. +
  19661. + MODE is the argument's machine mode.
  19662. + TYPE is the data type of the argument (as a tree).
  19663. + This is null for libcalls where that information may
  19664. + not be available.
  19665. + CUM is a variable of type CUMULATIVE_ARGS which gives info about
  19666. + the preceding args and about the function being called.
  19667. + NAMED is nonzero if this argument is a named parameter
  19668. + (otherwise it is an extra parameter matching an ellipsis). */
  19669. +
  19670. +#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
  19671. + metag_function_arg (&(CUM), MODE, TYPE, NAMED)
  19672. +
  19673. +/* Defined if some argument types need more than PARM_BOUNDARY alignment */
  19674. +#define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
  19675. + metag_function_arg_boundary (MODE, TYPE)
  19676. +
  19677. +/* Perform any actions needed for a function that is receiving a variable number
  19678. + of arguments. CUM is as above. MODE and TYPE are the mode and type of the
  19679. + current parameter. PRETEND_SIZE is a variable that should be set to the amount
  19680. + of stack that must be pushed by the prologue to pretend that our caller pushed
  19681. + it.
  19682. +
  19683. + Normally, this macro will push all remaining incoming registers on the stack
  19684. + and set PRETEND_SIZE to the length of the registers pushed.
  19685. +
  19686. + On Metag, PRETEND_SIZE is set in order to have the prologue push the last
  19687. + named argument and all anonymous arguments onto the stack .*/
  19688. +
  19689. +/* Don't output profile counters. */
  19690. +#define NO_PROFILE_COUNTERS 1
  19691. +
  19692. +/* Output assembler code to FILE to increment profiler label # LABELNO
  19693. + for profiling a function entry. */
  19694. +
  19695. +#define FUNCTION_PROFILER(FILE, LABELNO) \
  19696. + do { \
  19697. + if (!TARGET_HWTRACE) \
  19698. + metag_function_profiler (FILE); \
  19699. + } while (0)
  19700. +
  19701. +/* Output assembler code to FILE to initialize this source file's
  19702. + basic block profiling info, if that has not already been done. */
  19703. +
  19704. +#define FIXME_FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \
  19705. + fprintf (FILE, ASM_COMMENT_START " block profile code %u\n", (LABELNO))
  19706. +
  19707. +/* Output assembler code to FILE to increment the entry-count for
  19708. + the BLOCKNO'th basic block in this source file. */
  19709. +
  19710. +#define FIXME_BLOCK_PROFILER(FILE, BLOCKNO) \
  19711. + fprintf (FILE, ASM_COMMENT_START " profile code %u\n", 4 * (BLOCKNO))
  19712. +
  19713. +/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
  19714. + the stack pointer does not matter. The value is tested only in
  19715. + functions that have frame pointers.
  19716. + No definition is equivalent to always zero. */
  19717. +#define EXIT_IGNORE_STACK 1
  19718. +
  19719. +/* Determine if the epilogue should be output as RTL.
  19720. + You should override this if you define FUNCTION_EXTRA_EPILOGUE. */
  19721. +#define METAG_CHEAP_RETURN metag_cheap_return
  19722. +
  19723. +#if 1
  19724. +#define TRAMPOLINE_SECTION text_section
  19725. +
  19726. +/* Output assembler code for a block containing the constant parts
  19727. + of a trampoline, leaving space for the variable parts. */
  19728. +
  19729. +/* On the metag, the trampoline contains 4 instructions + 2 data words:
  19730. + MOV TEMP_D0FRT_REGNUM, PC
  19731. + GETD STATIC_CHAIN_REGNUM, [TEMP_D0FRT_REGNUM + #(16 - 4)]
  19732. + GETD TEMP_D0FRT_REGNUM, [TEMP_D0FRT_REGNUM + #(20 - 4)]
  19733. + MOV PC, TEMP_D0FRT_REGNUM
  19734. + .long <static-chain>
  19735. + .long <function-address>
  19736. + */
  19737. +
  19738. +/* Define offsets from start of Trampoline for the dynamic static
  19739. + chain and function address data words. */
  19740. +#define TRAMP_SC_OFFSET 16 /* Static chain offset. */
  19741. +#define TRAMP_FN_OFFSET 20 /* Function address offset. */
  19742. +
  19743. +#define TRAMPOLINE_TEMPLATE(FILE) \
  19744. +do { \
  19745. + const char * const scratch = reg_names[TEMP_D0FRT_REGNUM]; \
  19746. + const char * const chain = reg_names[STATIC_CHAIN_REGNUM]; \
  19747. + \
  19748. + fprintf (FILE, "\tMOV\t%s, PC\n", scratch); \
  19749. + fprintf (FILE, "\tGETD\t%s, [%s + #%d]\n", \
  19750. + chain, scratch, TRAMP_SC_OFFSET - 4); \
  19751. + fprintf (FILE, "\tGETD\t%s, [%s + #%d]\n", \
  19752. + scratch, scratch, TRAMP_FN_OFFSET - 4); \
  19753. + fprintf (FILE, "\tMOV\tPC, %s\n", scratch); \
  19754. + fputs (targetm.asm_out.aligned_op.si, FILE); \
  19755. + fputs ("\t0\n", FILE); \
  19756. + fputs (targetm.asm_out.aligned_op.si, FILE); \
  19757. + fputs ("\t0\n", FILE); \
  19758. +} while (0)
  19759. +
  19760. +/* Length in units of the trampoline for entering a nested function. */
  19761. +
  19762. +#define TRAMPOLINE_SIZE (UNITS_PER_WORD * 6)
  19763. +
  19764. +/* Emit RTL insns to initialize the variable parts of a trampoline.
  19765. + FNADDR is an RTX for the address of the function's pure code.
  19766. + CXT is an RTX for the static chain value for the function. */
  19767. +
  19768. +#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
  19769. +do { \
  19770. + if (!TARGET_MTX) \
  19771. + { \
  19772. + if (!TARGET_MINIM) \
  19773. + { \
  19774. + emit_move_insn (gen_rtx_MEM (SImode, \
  19775. + plus_constant (TRAMP, TRAMP_SC_OFFSET)), \
  19776. + CXT); \
  19777. + emit_move_insn (gen_rtx_MEM (SImode, \
  19778. + plus_constant (TRAMP, TRAMP_FN_OFFSET)), \
  19779. + FNADDR); \
  19780. + } \
  19781. + else \
  19782. + error ("GNU C nested C function extension not supported for MiniM.\n");\
  19783. + } \
  19784. + else \
  19785. + error ("GNU C nested C function extension not supported.\n"); \
  19786. +} while (0)
  19787. +
  19788. +#endif
  19789. +
  19790. +
  19791. +/* Initialize data used by insn expanders. This is called from insn_emit,
  19792. + once for every function before code is generated. */
  19793. +
  19794. +#define INIT_EXPANDERS metag_init_expanders ()
  19795. +
  19796. +/* Addressing modes, and classification of registers for them. */
  19797. +
  19798. +#define HAVE_PRE_INCREMENT 1
  19799. +#define HAVE_POST_INCREMENT 1
  19800. +#define HAVE_PRE_DECREMENT 1
  19801. +#define HAVE_POST_DECREMENT 1
  19802. +
  19803. +#define HAVE_PRE_MODIFY_REG 1
  19804. +#define HAVE_POST_MODIFY_REG 1
  19805. +#define HAVE_PRE_MODIFY_DISP 1
  19806. +#define HAVE_POST_MODIFY_DISP 1
  19807. +
  19808. +/* Macros to check register numbers against specific register classes. */
  19809. +
  19810. +/* These assume that REGNO is a hard or pseudo reg number.
  19811. + They give nonzero only if REGNO is a hard reg of the suitable class
  19812. + or a pseudo reg currently allocated to a suitable hard reg.
  19813. + Since they use reg_renumber, they are safe only once reg_renumber
  19814. + has been allocated, which happens in local-alloc.c. */
  19815. +
  19816. +#define REGNO_OK_FOR_INDEX_P(REGNO) \
  19817. + FALSE /* REGNO_OK_FOR_BASE_P (REGNO) */
  19818. +
  19819. +#define TEST_REGNO(R, OP, VALUE) \
  19820. + (((unsigned)(R) OP (VALUE)) || (unsigned)reg_renumber[R] OP (VALUE))
  19821. +
  19822. +#define REGNO_OK_FOR_BASE_P(REGNO) \
  19823. + (TEST_REGNO (REGNO, <=, FRAME_POINTER_REGNUM) \
  19824. + || TEST_REGNO (REGNO, ==, ARG_POINTER_REGNUM))
  19825. +
  19826. +/* Maximum number of registers that can appear in a valid memory address. */
  19827. +#define MAX_REGS_PER_ADDRESS 2
  19828. +
  19829. +/* Recognize any constant value that is a valid address. */
  19830. +
  19831. +#define CONSTANT_ADDRESS_P(X) \
  19832. + (LABEL_REF_P (X) \
  19833. + || SYMBOL_REF_P (X) \
  19834. + || CONST_INT_P (X) \
  19835. + || GET_CODE (X) == CONST)
  19836. +
  19837. +/* Nonzero if the constant value X is a legitimate general operand.
  19838. + It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
  19839. +
  19840. + TODO: This will need to be changed (see definition in metag-linux.h)
  19841. + when implementing TLS for the embedded toolchain.
  19842. + */
  19843. +
  19844. +#define LEGITIMATE_CONSTANT_P(X) 1
  19845. +
  19846. +/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
  19847. + and check its validity for a certain class.
  19848. + We have two alternate definitions for each of them.
  19849. + The usual definition accepts all pseudo regs; the other rejects
  19850. + them unless they have been allocated suitable hard regs.
  19851. + The symbol REG_OK_STRICT causes the latter definition to be used.
  19852. +
  19853. + Most source files want to accept pseudo regs in the hope that
  19854. + they will get allocated to the class that the insn wants them to be in.
  19855. + Source files for reload pass need to be strict.
  19856. + After reload, it makes no difference, since pseudo regs have
  19857. + been eliminated by then. */
  19858. +
  19859. +#ifndef REG_OK_STRICT
  19860. +#define REG_OK_STRICT_FLAG FALSE
  19861. +#else
  19862. +#define REG_OK_STRICT_FLAG TRUE
  19863. +#endif
  19864. +
  19865. +/* -------------------------------- BEGIN NONSTRICT ------------------------ */
  19866. +
  19867. +#define NONSTRICT_REGNO_OK_P(R) \
  19868. + METAG_LEGITIMATE_REGNO_P (R, false)
  19869. +
  19870. +#define NONSTRICT_REG_OK_P(R) \
  19871. + METAG_LEGITIMATE_REG_P (R, false)
  19872. +
  19873. +/* Nonzero if X is a hard reg that can be used as an index
  19874. + or if it is a pseudo reg. */
  19875. +#define NONSTRICT_REG_OK_FOR_INDEX_P(X) \
  19876. + FALSE /* NONSTRICT_REGNO_OK_P (REGNO (X)) */
  19877. +
  19878. +/* Nonzero if X is a hard reg that can be used as a base reg
  19879. + or if it is a pseudo reg. */
  19880. +#define NONSTRICT_REG_OK_FOR_BASE_P(X) \
  19881. + FALSE /* NONSTRICT_REGNO_OK_P (REGNO (X)) */
  19882. +
  19883. +/* Nonzero if X is a hard reg that can be used as a base reg
  19884. + or if it is a pseudo reg. */
  19885. +#define NONSTRICT_REG_OK_FOR_OFFSET_P(X) \
  19886. + NONSTRICT_REG_OK_P (X)
  19887. +
  19888. +/* Nonzero if the pair of hard regs are okay to use as base + offset
  19889. + or if either is a psuedo reg. */
  19890. +#define NONSTRICT_REGS_OK_FOR_BASE_OFFSET_P(X, Y) \
  19891. + METAG_REGS_OK_FOR_BASE_OFFSET_P (X, Y, false)
  19892. +
  19893. +/* ---------------------------------- END NONSTRICT ------------------------ */
  19894. +
  19895. +/* ----------------------------------- BEGIN STRICT ------------------------ */
  19896. +
  19897. +#define STRICT_REGNO_OK_P(R) \
  19898. + METAG_LEGITIMATE_REGNO_P (R, true)
  19899. +
  19900. +#define STRICT_REG_OK_P(R) \
  19901. + METAG_LEGITIMATE_REG_P (R, false)
  19902. +
  19903. +/* Nonzero if X is a hard reg that can be used as an index. */
  19904. +#define STRICT_REG_OK_FOR_INDEX_P(X) \
  19905. + FALSE /* STRICT_REGNO_OK_P (REGNO (X)) */
  19906. +
  19907. +/* Nonzero if X is a hard reg that can be used as a base reg. */
  19908. +#define STRICT_REG_OK_FOR_BASE_P(X) \
  19909. + FALSE /* STRICT_REGNO_OK_P (REGNO (X)) */
  19910. +
  19911. +/* Nonzero if X is a hard reg that can be used as a base reg. */
  19912. +#define STRICT_REG_OK_FOR_OFFSET_P(X) \
  19913. + STRICT_REG_OK_P (X)
  19914. +
  19915. +/* Nonzero if the pair of hard regs is okay to use as base + offset */
  19916. +#define STRICT_REGS_OK_FOR_BASE_OFFSET_P(X, Y) \
  19917. + METAG_REGS_OK_FOR_BASE_OFFSET_P (X, Y, true)
  19918. +
  19919. +/* ------------------------------------ END STRICT ------------------------- */
  19920. +
  19921. +/* Nonzero if X is a hard reg that can be used as an index
  19922. + or if it is a pseudo reg. */
  19923. +#define REG_OK_FOR_INDEX_P(X) \
  19924. + METAG_REG_OK_FOR_INDEX_P (X, REG_OK_STRICT_FLAG)
  19925. +
  19926. +#define METAG_REG_OK_FOR_INDEX_P(X, STRICT) \
  19927. + metag_reg_ok_for_index_p (X, STRICT)
  19928. +
  19929. +/* Nonzero if X is a hard reg that can be used as a base reg. */
  19930. +#define REG_OK_FOR_BASE_P(X) \
  19931. + METAG_REG_OK_FOR_BASE_P (X, REG_OK_STRICT_FLAG)
  19932. +
  19933. +#define METAG_REG_OK_FOR_BASE_P(X, STRICT) \
  19934. + metag_reg_ok_for_base_p (X, STRICT)
  19935. +
  19936. +/* Nonzero if X is a hard reg that can be used as a base reg. */
  19937. +#define REG_OK_FOR_OFFSET_P(X) \
  19938. + METAG_REG_OK_FOR_OFFSET_P (X, REG_OK_STRICT_FLAG)
  19939. +
  19940. +#define METAG_REG_OK_FOR_OFFSET_P(X, STRICT) \
  19941. + metag_reg_ok_for_offset_p (X, STRICT)
  19942. +
  19943. +/* Nonzero if the pair of hard regs is okay to use as base + offset */
  19944. +#define METAG_REGS_OK_FOR_BASE_OFFSET_P(X, Y, STRICT) \
  19945. + metag_regs_ok_for_base_offset_p (X, Y, STRICT)
  19946. +
  19947. +/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
  19948. + that is a valid memory address for an instruction.
  19949. + The MODE argument is the machine mode for the MEM expression
  19950. + that wants to use this address. */
  19951. +
  19952. +#define METAG_LEGITIMATE_REGNO_P(REGNUM, STRICT) \
  19953. + metag_legitimate_regno_p (REGNUM, STRICT)
  19954. +
  19955. +#define METAG_LEGITIMATE_REG_P(REG, STRICT) \
  19956. + metag_legitimate_reg_p (REG, STRICT)
  19957. +
  19958. +/* PRE_MODIFY */
  19959. +#define METAG_LEGITIMATE_PRE_MODIFY_P(ADDR, MODE, STRICT) \
  19960. + (GET_CODE (ADDR) == PRE_MODIFY \
  19961. + && metag_legitimate_modify_p (ADDR, MODE, STRICT))
  19962. +
  19963. +/* POST_MODIFY */
  19964. +#define METAG_LEGITIMATE_POST_MODIFY_P(ADDR, MODE, STRICT) \
  19965. + (GET_CODE (ADDR) == POST_MODIFY \
  19966. + && metag_legitimate_modify_p (ADDR, MODE, STRICT))
  19967. +
  19968. +/* PRE_INC/PRE_DEC supportable */
  19969. +#define METAG_LEGITIMATE_PRE_INCDEC_P(ADDR, MODE, STRICT) \
  19970. + metag_legitimate_pre_incdec_p (ADDR, MODE, STRICT)
  19971. +
  19972. +/* POST_INC/POST_DEC supportable */
  19973. +#define METAG_LEGITIMATE_POST_INCDEC_P(ADDR, MODE, STRICT) \
  19974. + metag_legitimate_post_incdec_p (ADDR, MODE, STRICT)
  19975. +
  19976. +/* Two ranges of offset are supported dependant on base & mode */
  19977. +#define METAG_LEGITIMATE_OFF_P(BASE, OFF, MODE, STRICT) \
  19978. + metag_legitimate_off_p (BASE, OFF, MODE, STRICT)
  19979. +
  19980. +/* [ Rb + Ro ] */
  19981. +#define METAG_LEGITIMATE_TWIN_P(BASE, OFF, MODE, STRICT) \
  19982. + metag_legitimate_twin_p (BASE, OFF, MODE, STRICT)
  19983. +
  19984. +#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
  19985. + do { \
  19986. + if (metag_legitimate_address_p (X, MODE, REG_OK_STRICT_FLAG)) \
  19987. + goto LABEL; \
  19988. + } while (0)
  19989. +
  19990. +#define SYMBOLIC_CONST(X) \
  19991. + (SYMBOL_REF_P (X) \
  19992. + || LABEL_REF_P (X) \
  19993. + || (GET_CODE (X) == CONST && metag_symbolic_reference_mentioned_p (X)))
  19994. +
  19995. +/* Go to LABEL if ADDR (a legitimate address expression)
  19996. + has an effect that depends on the machine mode it is used for. */
  19997. +#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
  19998. + do { \
  19999. + if ( GET_CODE (ADDR) == PRE_DEC \
  20000. + || GET_CODE (ADDR) == POST_DEC \
  20001. + || GET_CODE (ADDR) == PRE_INC \
  20002. + || GET_CODE (ADDR) == POST_INC \
  20003. + || GET_CODE (ADDR) == PRE_MODIFY \
  20004. + || GET_CODE (ADDR) == POST_MODIFY) \
  20005. + goto LABEL; \
  20006. + } while (0)
  20007. +
  20008. +/* Specify the machine mode that this machine uses
  20009. + for the index in the tablejump instruction. */
  20010. +#define CASE_VECTOR_MODE SImode
  20011. +
  20012. +/* Define as C expression which evaluates to nonzero if the tablejump
  20013. + instruction expects the table to contain offsets from the address of the
  20014. + table. */
  20015. +#define CASE_VECTOR_PC_RELATIVE 1
  20016. +
  20017. +/* Define this as 1 if `char' should by default be signed; else as 0. */
  20018. +#define DEFAULT_SIGNED_CHAR 0
  20019. +
  20020. +/* Max number of bytes we can move from memory to memory
  20021. + in one reasonably fast instruction. */
  20022. +#define MOVE_MAX 4
  20023. +
  20024. +/* Nonzero if access to memory by bytes is the same speed as words */
  20025. +#define SLOW_BYTE_ACCESS 1
  20026. +
  20027. +/* Define this to be nonzero if shift instructions ignore all but the low-order
  20028. + few bits. */
  20029. +#define SHIFT_COUNT_TRUNCATED 1
  20030. +
  20031. +/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
  20032. + is done just by pretending it is already truncated. */
  20033. +#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
  20034. +
  20035. +/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
  20036. + will either zero-extend or sign-extend. The value of this macro should
  20037. + be the code that says which one of the two operations is implicitly
  20038. + done, NIL if none. */
  20039. +#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
  20040. +
  20041. +/* We assume that the store-condition-codes instructions store 0 for false
  20042. + and some other value for true. This is the value stored for true. */
  20043. +/* #define STORE_FLAG_VALUE -1 */
  20044. +
  20045. +/* Define this macro if it is advisable to hold scalars in registers
  20046. + in a wider mode than that declared by the program. In such cases,
  20047. + the value is constrained to be within the bounds of the declared
  20048. + type, but kept valid in the wider mode. The signedness of the
  20049. + extension may differ from that of the type. It is faster to
  20050. + zero extend chars than to sign extend them on META, with 16 bit
  20051. + values it's less obvious */
  20052. +#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
  20053. + do { \
  20054. + if (GET_MODE_CLASS (MODE) == MODE_INT \
  20055. + && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
  20056. + (MODE) = SImode; \
  20057. + } while (0)
  20058. +
  20059. +/* Specify the machine mode that pointers have.
  20060. + After generation of rtl, the compiler makes no further distinction
  20061. + between pointers and any other objects of this machine mode. */
  20062. +#define Pmode SImode
  20063. +
  20064. +/* A function address in a call instruction
  20065. + is a byte address (for indexing purposes)
  20066. + so give the MEM rtx a byte's mode. */
  20067. +#define FUNCTION_MODE QImode
  20068. +
  20069. +/* Try to generate sequences that don't involve branches; enables cc insts */
  20070. +#define BRANCH_COST 3
  20071. +
  20072. +/* Comparison extensions-
  20073. +
  20074. + CC_NOOVmode is used when the state of the overflow flag is irrelavent to
  20075. + the compare case - e.g. comparison against zero is required.
  20076. +
  20077. + CC_Zmode is used as a more refined case of CC_NOOVmode where only the zero
  20078. + flag is relevant. For example if a HI or QI source value is being tested
  20079. + directly and the condition in EQ or NE in this case it's left to the
  20080. + pattern to check for other factors like zero as rhs of comparison.
  20081. +
  20082. +*/
  20083. +
  20084. +#define SELECT_CC_MODE(OP, X, Y) \
  20085. + metag_select_cc_mode ((OP), (X), (Y))
  20086. +
  20087. +#define REVERSIBLE_CC_MODE(MODE) (1)
  20088. +
  20089. +#define REVERSE_CONDITION(CODE, MODE) \
  20090. + (((MODE) != CC_FPmode && (MODE) != CC_FP_Qmode) ? reverse_condition (CODE) \
  20091. + : reverse_condition_maybe_unordered (CODE))
  20092. +
  20093. +/* Output to assembler file text saying following lines
  20094. + may contain character constants, extra white space, comments, etc. */
  20095. +
  20096. +#define ASM_APP_ON ""
  20097. +
  20098. +/* Output to assembler file text saying following lines
  20099. + no longer contain unusual constructs. */
  20100. +
  20101. +#define ASM_APP_OFF ""
  20102. +
  20103. +
  20104. +
  20105. +#define METAG_SYMBOL_FLAG_DIRECT (SYMBOL_FLAG_MACH_DEP << 0)
  20106. +#define METAG_SYMBOL_FLAG_DIRECT_P(SYMBOL) \
  20107. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_DIRECT) != 0)
  20108. +
  20109. +#define METAG_SYMBOL_FLAG_SMALL (SYMBOL_FLAG_MACH_DEP << 1)
  20110. +#define METAG_SYMBOL_FLAG_SMALL_P(SYMBOL) \
  20111. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_SMALL) != 0)
  20112. +
  20113. +#define METAG_SYMBOL_FLAG_LARGE (SYMBOL_FLAG_MACH_DEP << 2)
  20114. +#define METAG_SYMBOL_FLAG_LARGE_P(SYMBOL) \
  20115. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_LARGE) != 0)
  20116. +
  20117. +#define METAG_SYMBOL_FLAG_GLOBAL (SYMBOL_FLAG_MACH_DEP << 3)
  20118. +#define METAG_SYMBOL_FLAG_GLOBAL_P(SYMBOL) \
  20119. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_GLOBAL) != 0)
  20120. +
  20121. +#define METAG_SYMBOL_FLAG_BYTE (SYMBOL_FLAG_MACH_DEP << 4)
  20122. +#define METAG_SYMBOL_FLAG_BYTE_P(SYMBOL) \
  20123. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_BYTE) != 0)
  20124. +
  20125. +#define METAG_SYMBOL_FLAG_WORD (SYMBOL_FLAG_MACH_DEP << 5)
  20126. +#define METAG_SYMBOL_FLAG_WORD_P(SYMBOL) \
  20127. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_WORD) != 0)
  20128. +
  20129. +#define METAG_SYMBOL_FLAG_DWORD (SYMBOL_FLAG_MACH_DEP << 6)
  20130. +#define METAG_SYMBOL_FLAG_DWORD_P(SYMBOL) \
  20131. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_DWORD) != 0)
  20132. +
  20133. +#define METAG_SYMBOL_FLAG_LONG (SYMBOL_FLAG_MACH_DEP << 7)
  20134. +#define METAG_SYMBOL_FLAG_LONG_P(SYMBOL) \
  20135. + ((SYMBOL_REF_FLAGS (SYMBOL) & METAG_SYMBOL_FLAG_LONG) != 0)
  20136. +
  20137. +#define OVERRIDE_OPTIONS \
  20138. + metag_override_options ()
  20139. +
  20140. +/* How to refer to registers in assembler output.
  20141. + This sequence is indexed by compiler's hard-register-number (see above). */
  20142. +
  20143. +#define REGISTER_NAMES \
  20144. +{ \
  20145. + /* D0/D1 */ \
  20146. + "D0Re0", "D1Re0", "D0Ar6", "D1Ar5", "D0Ar4", "D1Ar3", "D0Ar2", "D1Ar1", \
  20147. + "D0.4", "D1RtP", "D0.5", "D1.5", "D0.6", "D1.6", "D0.7", "D1.7", \
  20148. + /* D0/D1 reserved */ \
  20149. + "D0.8", "D1.8", "D0.9", "D1.9", "D0.10", "D1.10", "D0.11", "D1.11", \
  20150. + "D0.12", "D1.12", "D0.13", "D1.13", "D0.14", "D1.14", "D0.15", "D1.15", \
  20151. + /* A0/A1 */ \
  20152. + "A0StP", "A1GbP", "A0FrP", "A1LbP", "A0.2", "A1.2", "A0.3", "A1.3", \
  20153. + "A0.4", "A1.4", "A0.5", "A1.5", "A0.6", "A1.6", "A0.7", "A1.7", \
  20154. + /* Fakes may be seen in RTL */ \
  20155. + "FRAMEP","MCC", "ARGP", "RAPF", "CPC0", "CPC1", "PC", "TXRPT", \
  20156. + /* FX */ \
  20157. + "FX.0", "FX.1", "FX.2" , "FX.3" , "FX.4" , "FX.5" , "FX.6" , "FX.7" , \
  20158. + "FX.8", "FX.9", "FX.10", "FX.11", "FX.12", "FX.13", "FX.14", "FX.15", \
  20159. + /* TTREC(L) */ \
  20160. + "TTREC", "TTRECL" \
  20161. +}
  20162. +
  20163. +#define ADDITIONAL_REGISTER_NAMES \
  20164. +{ \
  20165. + {"D0.0", D0_0_REG}, \
  20166. + {"D1.0", D1_0_REG}, \
  20167. + {"D0.1", D0_1_REG}, \
  20168. + {"D1.1", D1_1_REG}, \
  20169. + {"D0.2", D0_2_REG}, \
  20170. + {"D1.2", D1_2_REG}, \
  20171. + {"D0.3", D0_3_REG}, \
  20172. + {"D1.3", D1_3_REG}, \
  20173. + {"D1.4", D1_4_REG}, \
  20174. + {"A0.0", A0_0_REG}, \
  20175. + {"A1.0", A1_0_REG}, \
  20176. + {"A0.1", A0_1_REG}, \
  20177. + {"A1.1", A1_1_REG}, \
  20178. + {"D0FrT", D0_4_REG}, \
  20179. + {"cc", CC_REG} \
  20180. +}
  20181. +
  20182. +#define ASM_IDENTIFY_CPU ".cpu"
  20183. +
  20184. +#define META_IDENTIFY_CPU(FILE) \
  20185. + fprintf (FILE, "!\t%s\tmeta%s\n", ASM_IDENTIFY_CPU, metag_cpu_string)
  20186. +
  20187. +/* A FILE comment and register declaration section should always
  20188. + begin the output. */
  20189. +
  20190. +/* Use direct B xx jump tables in code */
  20191. +#define JUMP_TABLES_IN_TEXT_SECTION 1
  20192. +
  20193. +/* How to renumber registers for dbx and gdb. */
  20194. +
  20195. +#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
  20196. +
  20197. +#undef DWARF2_DENUGGING_INFO
  20198. +#define DWARF2_DEBUGGING_INFO 1
  20199. +#define CAN_DEBUG_WITHOUT_FP
  20200. +
  20201. +#define SUPPORTS_INIT_PRIORITY 0
  20202. +
  20203. +/* The prefix to add to internally generated labels. */
  20204. +#undef LOCAL_LABEL_PREFIX
  20205. +#define LOCAL_LABEL_PREFIX "$"
  20206. +
  20207. +#undef IMMEDIATE_PREFIX
  20208. +#define IMMEDIATE_PREFIX "#"
  20209. +
  20210. +/* This is how to output an insn to push a register on the stack.
  20211. + It need not be very fast code. */
  20212. +
  20213. +#define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
  20214. + fprintf (FILE, "\tSETD\t[%s+#4++], %s\n", \
  20215. + reg_names[STACK_POINTER_REGNUM], reg_names[REGNO])
  20216. +
  20217. +/* This is how to output an insn to pop a register from the stack.
  20218. + It need not be very fast code. */
  20219. +#define ASM_OUTPUT_REG_POP(FILE, REGNO) \
  20220. + fprintf (FILE, "\tGETD\t%s, [%s+#(-4)++]\n", reg_names[REGNO], \
  20221. + reg_names[STACK_POINTER_REGNUM])
  20222. +
  20223. +/* This is how to output an element of a case-vector that is absolute. */
  20224. +#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
  20225. + asm_fprintf (FILE, "\t%s\t%L%d\t" ASM_COMMENT_START \
  20226. + " (abs table not expected)\n", \
  20227. + targetm.asm_out.aligned_op.si, \
  20228. + VALUE)
  20229. +
  20230. +
  20231. +/* This is how to output an element of a case-vector that is relative. */
  20232. +/* This is the first implementation of MiniM short branches. There is no check
  20233. + to ensure jump targets are in range of a short encoding yet. Short is used
  20234. + if requested otherwise long is used */
  20235. +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
  20236. + asm_fprintf (FILE, "\t%sB\t%LL%d\t\t" ASM_COMMENT_START \
  20237. + " (table %LL%d OK)\n", \
  20238. + (!TARGET_MINIM) ? "" : \
  20239. + ((metag_jump_table_branch == METAG_MINIM_JUMP_TABLE_BRANCH_AUTO \
  20240. + && cfun->machine->can_use_short_branch) \
  20241. + || metag_jump_table_branch == METAG_MINIM_JUMP_TABLE_BRANCH_SHORT) \
  20242. + ? "XS\t" : "XL\t", \
  20243. + VALUE, REL)
  20244. +
  20245. +#define PRINT_OPERAND(FILE, X, CODE) \
  20246. + metag_print_operand (FILE, X, CODE)
  20247. +
  20248. +#ifdef ENABLE_ASSERT_CHECKING
  20249. +#define ASM_OUTPUT_OPCODE(FILE, OPCODE) \
  20250. + metag_asm_output_opcode (FILE, OPCODE)
  20251. +#endif /* ENABLE_ASSERT_CHECKING */
  20252. +
  20253. +#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
  20254. + metag_print_operand_address (FILE, ADDR)
  20255. +
  20256. +#define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \
  20257. + do { \
  20258. + if (!metag_output_addr_const_extra (FILE, X)) \
  20259. + goto FAIL; \
  20260. + } while (0)
  20261. +
  20262. +/* On the META we want to pass partial stack/reg arguments such that
  20263. + * the first N bytes of the argument are passed on the stack and the
  20264. + * remaining M bytes of the argument are passed in registers.
  20265. + *
  20266. + * This allows the function prologue to just push the partial registers
  20267. + * onto the stack, which can be combined with the normal stack frame
  20268. + * setup.
  20269. + *
  20270. + * This macro is used in the machine independent files expr.c and function.c
  20271. + * to enable some META specific code for handling partial args.
  20272. + */
  20273. +#define METAG_PARTIAL_ARGS 1
  20274. +
  20275. +/* Only perform branch elimination (by making instructions conditional) if
  20276. + we're optimising. Otherwise it's of no use anyway. */
  20277. +#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
  20278. + do { \
  20279. + if (TARGET_COND_EXEC_OPTIMIZE) \
  20280. + { \
  20281. + int saved_alternative = which_alternative; \
  20282. + \
  20283. + metag_final_prescan_insn (INSN); \
  20284. + which_alternative = saved_alternative; \
  20285. + } \
  20286. + } while (0)
  20287. +
  20288. +#define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '?' || (CODE) == '@')
  20289. +
  20290. +enum metag_builtins
  20291. +{
  20292. + METAG_BUILTIN_DCACHE_PRELOAD,
  20293. + METAG_BUILTIN_DCACHE_FLUSH,
  20294. + METAG_BUILTIN_DCACHE_REFRESH,
  20295. + METAG_BUILTIN_META2_CACHERD,
  20296. + METAG_BUILTIN_META2_CACHERL,
  20297. + METAG_BUILTIN_META2_CACHEWD,
  20298. + METAG_BUILTIN_META2_CACHEWL,
  20299. + METAG_BUILTIN_METAG_BSWAPS,
  20300. + METAG_BUILTIN_METAG_BSWAP,
  20301. + METAG_BUILTIN_METAG_BSWAPLL,
  20302. + METAG_BUILTIN_METAG_WSWAP,
  20303. + METAG_BUILTIN_METAG_WSWAPLL,
  20304. + METAG_BUILTIN_METAG_DSWAPLL,
  20305. + METAG_BUILTIN_THREAD_POINTER
  20306. +};
  20307. +
  20308. +#define TARGET_BUILTINS_METAC_1_0 \
  20309. + (metac_target == METAC_1_0_ID)
  20310. +
  20311. +#define TARGET_BUILTINS_METAC_1_1 \
  20312. + (metac_target == METAC_1_1_ID)
  20313. +
  20314. +#define TARGET_BUILTINS_METAC_1_2 \
  20315. + (metac_target == METAC_1_2_ID || metac_target == METAC_0_1_ID)
  20316. +
  20317. +#define TARGET_BUILTINS_METAC_2_1 \
  20318. + (metac_target == METAC_2_1_ID)
  20319. +
  20320. +#define METAG_CURRENT_FUNCTION_LOADS_PIC_REGISTER() \
  20321. + metag_current_function_loads_pic_register ()
  20322. +
  20323. +#define ASSEMBLE_SYMBOL_REF(STREAM, X) \
  20324. + assemble_name (STREAM, XSTR (X, 0))
  20325. +
  20326. +/* The architecture define. */
  20327. +extern char metag_arch_name[];
  20328. +
  20329. +/* Target CPU builtins. */
  20330. +#define TARGET_CPU_CPP_BUILTINS() \
  20331. + metag_cpu_cpp_builtins (pfile)
  20332. +
  20333. +#define METAG_CONST_OK_FOR_LETTERS_KPIJ(VALUE) \
  20334. + metag_const_ok_for_letters_p (VALUE, "KIPJ")
  20335. +
  20336. +#define METAG_CONST_OK_FOR_LETTERS_KPIJO3(VALUE) \
  20337. + metag_const_ok_for_letters_p (VALUE, "KIPJO3")
  20338. +
  20339. +#define METAG_LETTER_FOR_CONST(VALUE) \
  20340. + metag_letter_for_const (VALUE)
  20341. +
  20342. +#define METAG_DATA_REG_P(REGNUM) \
  20343. + metag_datareg_p (REGNUM)
  20344. +
  20345. +#define METAG_ADDR_REG_P(REGNUM) \
  20346. + metag_addrreg_p (REGNUM)
  20347. +
  20348. +#define METAG_FPC_REG_P(REGNUM) \
  20349. + metag_fpcreg_p (REGNUM)
  20350. +
  20351. +#define METAG_FPP_REG_P(REGNUM) \
  20352. + metag_fppreg_p (REGNUM)
  20353. +
  20354. +extern char * metag_gen_cond_return_branch (const char *);
  20355. +extern char * metag_gen_cond_return_stub (void);
  20356. +extern void metag_emit_cond_return_stub_if_reqd (void);
  20357. +
  20358. +/* Track the status of condition returns. 'REQD' means that a stub is
  20359. + required at the end of the function. 'DONE' means the stub has been emitted
  20360. + and should not be emitted again */
  20361. +enum metag_cond_return_state
  20362. +{
  20363. + METAG_COND_RETURN_NONE,
  20364. + METAG_COND_RETURN_REQD,
  20365. + METAG_COND_RETURN_DONE
  20366. +};
  20367. +
  20368. +typedef struct machine_function GTY(())
  20369. +{
  20370. + int valid;
  20371. + int can_use_short_branch;
  20372. + int pretend_regs;
  20373. + int anonymous_args;
  20374. + int anonymous_args_size;
  20375. + int uses_pic_offset_table;
  20376. + int loads_pic_register;
  20377. + unsigned int savesize_gp;
  20378. + unsigned int savesize_eh;
  20379. + unsigned int FP_SP_offset;
  20380. + unsigned int pic_save_size;
  20381. + unsigned int out_local_size;
  20382. + int ech_ctx_required;
  20383. + int frame_pointer_needed;
  20384. + int non_leaf;
  20385. + int frame_pointer_epilogue;
  20386. + int accesses_prev_frame;
  20387. + unsigned int extras_gp;
  20388. + unsigned int extras_eh;
  20389. + unsigned int calls_eh_return;
  20390. + int arg_adjust_delta;
  20391. + int frame_adjust_delta;
  20392. + int hwtrace;
  20393. + int hwtrace_leaf;
  20394. + int hwtrace_retpc;
  20395. + enum metag_cond_return_state cond_return_state;
  20396. +} machine_function;
  20397. +
  20398. +#define INCOMING_RETURN_ADDR_RTX \
  20399. + gen_rtx_REG (SImode, RETURN_POINTER_REGNUM)
  20400. +
  20401. +#define DWARF_FRAME_RETURN_COLUMN \
  20402. + DWARF_FRAME_REGNUM (RETURN_POINTER_REGNUM)
  20403. +
  20404. +#define ASM_FPRINTF_EXTENSIONS(FILE, ARGS, P) \
  20405. + case '@': \
  20406. + fputs (ASM_COMMENT_START, FILE); \
  20407. + break; \
  20408. + \
  20409. + case 'r': \
  20410. + fputs (reg_names [va_arg (ARGS, unsigned int)], file); \
  20411. + break;
  20412. +
  20413. +#define HARD_REGNO_RENAME_OK_FOR_INSN(INSN, FROM, TO) \
  20414. + metag_hard_regno_rename_ok_p (INSN, FROM, TO)
  20415. +
  20416. +#define EPILOGUE_USES(REGNO) \
  20417. + ((REGNO) == D1RtP_REG || (REGNO) == A0FrP_REG \
  20418. + || (TARGET_ECH && (REGNO) == METAG_ECH_REGNUM))
  20419. +
  20420. +#define METAG_USE_RETURN_INSN(ISCOND) \
  20421. + metag_use_return_insn (ISCOND)
  20422. +
  20423. +/* A stucture to support counting the number of doloop optimised loops per nest */
  20424. +struct doloopnest
  20425. +{
  20426. + struct loop* inner;
  20427. + struct doloopnest* next;
  20428. +};
  20429. +
  20430. +#define DOLOOP_OPTIMIZE_INIT() \
  20431. + struct doloopnest * nests = NULL
  20432. +
  20433. +#define DOLOOP_OPTIMIZE_LOOP(LOOP) \
  20434. + do { \
  20435. + /* Determine if any inner loop nests are already optimized */ \
  20436. + if (!metag_doloop_check_any_nest_optimized (LOOP, nests)) \
  20437. + /* If we doloop optimize this loop, mark all inner loops as optimized */ \
  20438. + if (doloop_optimize (LOOP)) \
  20439. + metag_doloop_mark_nests_optimized (LOOP, &nests); \
  20440. + } while (0)
  20441. +
  20442. +
  20443. +#define DOLOOP_OPTIMIZE_FINI() \
  20444. + do { \
  20445. + /* Free the doloop nest counters */ \
  20446. + while (nests != NULL) \
  20447. + { \
  20448. + struct doloopnest * next = nests->next; \
  20449. + \
  20450. + free (nests); \
  20451. + nests = next; \
  20452. + } \
  20453. + } while (0)
  20454. +
  20455. +/* Try a machine-dependent way of reloading an illegitimate address
  20456. + operand. If we find one, push the reload and jump to WIN. This
  20457. + macro is used in only one place: `find_reloads_address' in reload.c.
  20458. +
  20459. + For the META, we wish to handle large displacements off a base
  20460. + register by splitting the addend across a MOV and the mem insn.
  20461. + This can cut the number of reloads needed. */
  20462. +#define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND, WIN) \
  20463. + do { \
  20464. + rtx new ## X = metag_legitimize_reload_address (X, MODE, OPNUM, TYPE, IND); \
  20465. + \
  20466. + if (new ## X) \
  20467. + { \
  20468. + (X) = new ## X; \
  20469. + goto WIN; \
  20470. + } \
  20471. + } while (0)
  20472. +
  20473. +#define METAG_ELIMINABLE_REG_P(X) \
  20474. + (REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM)
  20475. +
  20476. +
  20477. +#define SPLIT_EARLY \
  20478. + metag_split_early ()
  20479. +
  20480. +#define SPLIT_HI_LO_SUM_EARLY \
  20481. + metag_split_hi_lo_sum_early ()
  20482. +
  20483. +#define CALLER_SAVE_INSN_CODE(CODE) (-1)
  20484. +
  20485. +/* In driver-metag.c. */
  20486. +extern const char *metag_reduce_options (int argc, const char **argv);
  20487. +extern const char *metag_emb_asm_preprocessor (int argc, const char **argv);
  20488. +extern const char *metag_emb_onlylast (int argc, const char **argv);
  20489. +extern const char *metag_emb_change_suffix (int argc, const char **argv);
  20490. +#define EXTRA_SPEC_FUNCTIONS \
  20491. + { "meta_preprocessor", metag_emb_asm_preprocessor }, \
  20492. + { "meta_reduce_options", metag_reduce_options }, \
  20493. + { "meta_onlylast", metag_emb_onlylast }, \
  20494. + { "meta_change_suffix", metag_emb_change_suffix },
  20495. +
  20496. +
  20497. +/* Do not re-invent the wheel!
  20498. + Instead of writing our very own option file expander, get gcc to do it
  20499. + convert the -mcpu-config=file option to be @file and expand */
  20500. +
  20501. +#define GCC_DRIVER_HOST_INITIALIZATION \
  20502. + do { \
  20503. + int i; \
  20504. + char * inject_options = getenv ("METAG_COMPILER_OPTIONS"); \
  20505. + \
  20506. + /* Allow option injection from the environment primarily to reduce the \
  20507. + build system logic required when building GCC with its library code and \
  20508. + data in sections with non-standard names. This feature may find uses \
  20509. + outside of this initial purpose but it's general use is discouraged. */ \
  20510. + \
  20511. + if (inject_options != NULL) \
  20512. + { \
  20513. + int env_argc = 0; \
  20514. + int new_argc = 0; \
  20515. + char** new_argv = NULL; \
  20516. + char** env_argv = buildargv (inject_options); \
  20517. + \
  20518. + if (env_argv == NULL) \
  20519. + { \
  20520. + fputs ("\nout of memory\n", stderr); \
  20521. + xexit (1); \
  20522. + } \
  20523. + \
  20524. + /* Count the number of arguments. */ \
  20525. + while (env_argv[env_argc] && *env_argv[env_argc]) \
  20526. + ++env_argc; \
  20527. + \
  20528. + /* Make space for the new arguments */ \
  20529. + new_argc = argc + env_argc; \
  20530. + new_argv = (char **)xmalloc (sizeof (char*) * (new_argc + 1)); \
  20531. + \
  20532. + /* Fill in the new argv */ \
  20533. + new_argv[0] = argv[0]; \
  20534. + memcpy (new_argv + 1, env_argv, sizeof (char *) * env_argc); \
  20535. + memcpy (new_argv + env_argc + 1, argv + 1, \
  20536. + sizeof (char *) * (argc - 1)); \
  20537. + new_argv[new_argc] = NULL; \
  20538. + \
  20539. + /* Swap in the new argv */ \
  20540. + argv = new_argv; \
  20541. + argc = new_argc; \
  20542. + \
  20543. + /* Free the env_argv */ \
  20544. + free (env_argv); \
  20545. + } \
  20546. + \
  20547. + for (i = 1 ; i < argc ; i++) \
  20548. + { \
  20549. + if (strncmp ("-mcpu-config=", argv[i], 13) == 0) \
  20550. + { \
  20551. + argv[i] = argv[i]+12; \
  20552. + *argv[i] = '@'; \
  20553. + } \
  20554. + } \
  20555. + \
  20556. + expandargv (&argc, &argv); \
  20557. + \
  20558. + prune_options (&argc, &argv); \
  20559. + } while (0)
  20560. +
  20561. +#endif /* __METAG_H */
  20562. +
  20563. +#define METAG_HAVE_TLS targetm.have_tls
  20564. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag-linux.c gcc-4.2.4/gcc/config/metag/metag-linux.c
  20565. --- gcc-4.2.4.orig/gcc/config/metag/metag-linux.c 1969-12-31 18:00:00.000000000 -0600
  20566. +++ gcc-4.2.4/gcc/config/metag/metag-linux.c 2015-07-03 18:46:05.749283542 -0500
  20567. @@ -0,0 +1,660 @@
  20568. +/* Definitions of target machine for GNU compiler.
  20569. + Imagination Technologies Meta version.
  20570. + Copyright (C) 2008
  20571. + Imagination Technologies Ltd
  20572. +
  20573. +This file is part of GCC.
  20574. +
  20575. +GCC is free software; you can redistribute it and/or modify it under
  20576. +the terms of the GNU General Public License as published by the Free
  20577. +Software Foundation; either version 3, or (at your option) any later
  20578. +version.
  20579. +
  20580. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  20581. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  20582. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  20583. +for more details.
  20584. +
  20585. +You should have received a copy of the GNU General Public License
  20586. +along with GCC; see the file COPYING3. If not see
  20587. +<http://www.gnu.org/licenses/>. */
  20588. +
  20589. +#include "config.h"
  20590. +#include "system.h"
  20591. +#include "coretypes.h"
  20592. +#include "tm.h"
  20593. +#include "rtl.h"
  20594. +#include "tree.h"
  20595. +#include "obstack.h"
  20596. +#include "regs.h"
  20597. +#include "hard-reg-set.h"
  20598. +#include "real.h"
  20599. +#include "insn-config.h"
  20600. +#include "conditions.h"
  20601. +#include "insn-flags.h"
  20602. +#include "output.h"
  20603. +#include "insn-attr.h"
  20604. +#include "flags.h"
  20605. +#include "reload.h"
  20606. +#include "function.h"
  20607. +#include "expr.h"
  20608. +#include "optabs.h"
  20609. +#include "toplev.h"
  20610. +#include "recog.h"
  20611. +#include "ggc.h"
  20612. +#include "except.h"
  20613. +#include "c-pragma.h"
  20614. +#include "integrate.h"
  20615. +#include "cfgloop.h"
  20616. +#include "tm_p.h"
  20617. +#include "timevar.h"
  20618. +#include "options.h"
  20619. +#include "cgraph.h"
  20620. +#include "target.h"
  20621. +#include "target-def.h"
  20622. +#include "tm-constrs.h"
  20623. +#include "langhooks.h"
  20624. +#include "version.h"
  20625. +
  20626. +/* --------------------------- begin target defines --------------------------*/
  20627. +/* --------------------------- begin asm_out section -------------------------*/
  20628. +
  20629. +#undef TARGET_ASM_ALIGNED_DI_OP
  20630. +#define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
  20631. +
  20632. +#undef TARGET_ASM_INTERNAL_LABEL
  20633. +#define TARGET_ASM_INTERNAL_LABEL metag_internal_label
  20634. +
  20635. +#undef TARGET_ASM_FUNCTION_PROLOGUE
  20636. +#define TARGET_ASM_FUNCTION_PROLOGUE metag_function_prologue
  20637. +
  20638. +#undef TARGET_ASM_FUNCTION_END_PROLOGUE
  20639. +#define TARGET_ASM_FUNCTION_END_PROLOGUE metag_function_end_prologue
  20640. +
  20641. +#undef TARGET_ASM_FUNCTION_BEGIN_EPILOGUE
  20642. +#define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE metag_function_begin_epilogue
  20643. +
  20644. +#undef TARGET_ASM_FUNCTION_EPILOGUE
  20645. +#define TARGET_ASM_FUNCTION_EPILOGUE metag_function_epilogue
  20646. +
  20647. +static section * metag_bfd_select_section (tree, int, unsigned HOST_WIDE_INT);
  20648. +#undef TARGET_ASM_SELECT_SECTION
  20649. +#define TARGET_ASM_SELECT_SECTION metag_bfd_select_section
  20650. +
  20651. +static void metag_bfd_asm_unique_section (tree, int);
  20652. +#undef TARGET_ASM_UNIQUE_SECTION
  20653. +#define TARGET_ASM_UNIQUE_SECTION metag_bfd_asm_unique_section
  20654. +
  20655. +#undef TARGET_ASM_OUTPUT_MI_THUNK
  20656. +#define TARGET_ASM_OUTPUT_MI_THUNK metag_output_mi_thunk
  20657. +
  20658. +#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
  20659. +#define TARGET_ASM_CAN_OUTPUT_MI_THUNK metag_can_output_mi_thunk
  20660. +
  20661. +/* A FILE comment and register declaration section must always
  20662. + * begin the output. */
  20663. +static void metag_bfd_asm_file_start (void);
  20664. +#undef TARGET_ASM_FILE_START
  20665. +#define TARGET_ASM_FILE_START metag_bfd_asm_file_start
  20666. +
  20667. +/* Tidies everything up at the end of the file. */
  20668. +static void metag_bfd_asm_file_end (void);
  20669. +#undef TARGET_ASM_FILE_END
  20670. +#define TARGET_ASM_FILE_END metag_bfd_asm_file_end
  20671. +
  20672. +/* ---------------------------- end asm_out section --------------------------*/
  20673. +/* ---------------------------- begin sched section --------------------------*/
  20674. +
  20675. +#undef TARGET_SCHED_ADJUST_COST
  20676. +#define TARGET_SCHED_ADJUST_COST metag_sched_adjust_cost
  20677. +
  20678. +/* ----------------------------- end sched section ---------------------------*/
  20679. +/* ---------------------------- begin vector section -------------------------*/
  20680. +/* ----------------------------- end vector section --------------------------*/
  20681. +/* ------------------------------- begin section -----------------------------*/
  20682. +
  20683. +#undef TARGET_DEFAULT_TARGET_FLAGS
  20684. +#ifdef MINIM_DEFAULT
  20685. +#define TARGET_DEFAULT_TARGET_FLAGS ((MASK_COND_EXEC) | (MASK_MINIM) | (MASK_MINIM_OPTIMISE) | (MASK_FLUSH_TO_ZERO))
  20686. +#else
  20687. +#define TARGET_DEFAULT_TARGET_FLAGS ((MASK_COND_EXEC) | (MASK_MINIM_OPTIMISE) | (MASK_FLUSH_TO_ZERO))
  20688. +#endif
  20689. +
  20690. +#undef TARGET_HANDLE_OPTION
  20691. +#define TARGET_HANDLE_OPTION metag_handle_option
  20692. +
  20693. +#undef TARGET_MERGE_DECL_ATTRIBUTES
  20694. +#define TARGET_MERGE_DECL_ATTRIBUTES metag_merge_decl_attributes
  20695. +
  20696. +#undef TARGET_MERGE_TYPE_ATTRIBUTES
  20697. +#define TARGET_MERGE_TYPE_ATTRIBUTES metag_merge_type_attributes
  20698. +
  20699. +#undef TARGET_ATTRIBUTE_TABLE
  20700. +#define TARGET_ATTRIBUTE_TABLE metag_attribute_table
  20701. +
  20702. +#undef TARGET_COMP_TYPE_ATTRIBUTES
  20703. +#define TARGET_COMP_TYPE_ATTRIBUTES metag_comp_type_attributes
  20704. +
  20705. +#undef TARGET_INIT_BUILTINS
  20706. +#define TARGET_INIT_BUILTINS metag_init_builtins
  20707. +
  20708. +#undef TARGET_EXPAND_BUILTIN
  20709. +#define TARGET_EXPAND_BUILTIN metag_expand_builtin
  20710. +
  20711. +#undef TARGET_FUNCTION_OK_FOR_SIBCALL
  20712. +#define TARGET_FUNCTION_OK_FOR_SIBCALL metag_function_ok_for_sibcall
  20713. +
  20714. +#undef TARGET_ENCODE_SECTION_INFO
  20715. +#define TARGET_ENCODE_SECTION_INFO metag_encode_section_info
  20716. +
  20717. +static const char *metag_bfd_strip_name_encoding (const char *);
  20718. +#undef TARGET_STRIP_NAME_ENCODING
  20719. +#define TARGET_STRIP_NAME_ENCODING metag_bfd_strip_name_encoding
  20720. +
  20721. +#undef TARGET_SCALAR_MODE_SUPPORTED_P
  20722. +#define TARGET_SCALAR_MODE_SUPPORTED_P metag_scalar_mode_supported_p
  20723. +
  20724. +#undef TARGET_VECTOR_MODE_SUPPORTED_P
  20725. +#define TARGET_VECTOR_MODE_SUPPORTED_P metag_vector_mode_supported_p
  20726. +
  20727. +#undef TARGET_RTX_COSTS
  20728. +#define TARGET_RTX_COSTS metag_rtx_costs
  20729. +
  20730. +#undef TARGET_ADDRESS_COST
  20731. +#define TARGET_ADDRESS_COST metag_address_cost
  20732. +
  20733. +#undef TARGET_MACHINE_DEPENDENT_REORG
  20734. +#define TARGET_MACHINE_DEPENDENT_REORG metag_machine_dependent_reorg
  20735. +
  20736. +#undef TARGET_GIMPLIFY_VA_ARG_EXPR
  20737. +#define TARGET_GIMPLIFY_VA_ARG_EXPR metag_gimplify_va_arg_expr
  20738. +
  20739. +#undef TARGET_INVALID_WITHIN_DOLOOP
  20740. +#define TARGET_INVALID_WITHIN_DOLOOP metag_invalid_within_doloop
  20741. +
  20742. +/* -------------------------------- end section ------------------------------*/
  20743. +/* ---------------------------- begin calls section --------------------------*/
  20744. +
  20745. +#undef TARGET_PROMOTE_FUNCTION_ARGS
  20746. +#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
  20747. +
  20748. +#undef TARGET_PROMOTE_FUNCTION_RETURN
  20749. +#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
  20750. +
  20751. +#undef TARGET_FUNCTION_VALUE
  20752. +#define TARGET_FUNCTION_VALUE metag_function_value
  20753. +
  20754. +#undef TARGET_PROMOTE_PROTOTYPES
  20755. +#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
  20756. +
  20757. +#undef TARGET_PASS_BY_REFERENCE
  20758. +#define TARGET_PASS_BY_REFERENCE metag_pass_by_reference
  20759. +
  20760. +#undef TARGET_SETUP_INCOMING_VARARGS
  20761. +#define TARGET_SETUP_INCOMING_VARARGS metag_setup_incoming_varargs
  20762. +
  20763. +#undef TARGET_MUST_PASS_IN_STACK
  20764. +#define TARGET_MUST_PASS_IN_STACK metag_must_pass_in_stack
  20765. +
  20766. +#undef TARGET_ARG_PARTIAL_BYTES
  20767. +#define TARGET_ARG_PARTIAL_BYTES metag_arg_partial_bytes
  20768. +
  20769. +/* ----------------------------- end calls section ---------------------------*/
  20770. +/* ------------------------------- begin section -----------------------------*/
  20771. +
  20772. +#undef TARGET_SECONDARY_RELOAD
  20773. +#define TARGET_SECONDARY_RELOAD metag_secondary_reload
  20774. +
  20775. +/* -------------------------------- end section ------------------------------*/
  20776. +/* ----------------------------- begin cxx section ---------------------------*/
  20777. +
  20778. +/* C++ specific macros */
  20779. +
  20780. +/* ------------------------------ end cxx section ----------------------------*/
  20781. +/* ------------------------------- begin section -----------------------------*/
  20782. +
  20783. +#undef TARGET_HAVE_NAMED_SECTIONS
  20784. +#define TARGET_HAVE_NAMED_SECTIONS true
  20785. +
  20786. +#undef TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
  20787. +#define TARGET_HAVE_SWITCHABLE_BSS_SECTIONS false
  20788. +
  20789. +/* -------------------------------- end section ------------------------------*/
  20790. +
  20791. +#undef TARGET_CANNOT_FORCE_CONST_MEM
  20792. +#define TARGET_CANNOT_FORCE_CONST_MEM metag_bfd_tls_referenced_p
  20793. +
  20794. +struct gcc_target targetm = TARGET_INITIALIZER;
  20795. +
  20796. +/* ---------------------------- end target defines ---------------------------*/
  20797. +
  20798. +static void
  20799. +metag_bfd_asm_file_start (void)
  20800. +{
  20801. + fprintf (asm_out_file, "%s Generated by gcc %s for Meta(Linux)/elf\n",
  20802. + ASM_COMMENT_START, version_string);
  20803. +
  20804. + fputc ('\n', asm_out_file);
  20805. + output_file_directive (asm_out_file, main_input_filename);
  20806. +
  20807. + fputc ('\n', asm_out_file);
  20808. + META_IDENTIFY_CPU (asm_out_file);
  20809. + fputc ('\n', asm_out_file);
  20810. +}
  20811. +
  20812. +static void
  20813. +metag_bfd_asm_file_end (void)
  20814. +{
  20815. + return;
  20816. +}
  20817. +
  20818. +static const char *
  20819. +metag_bfd_strip_name_encoding (const char *str)
  20820. +{
  20821. + gcc_assert (str[0] != '&');
  20822. +
  20823. + return str + (str[0] == '*');
  20824. +}
  20825. +
  20826. +/* Construct a unique section name based on the decl name and the
  20827. + categorization performed above. */
  20828. +
  20829. +static void
  20830. +metag_bfd_asm_unique_section (tree decl, int reloc)
  20831. +{
  20832. + /* We only need to use .gnu.linkonce if we don't have COMDAT groups. */
  20833. + bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP;
  20834. + const char *prefix, *name;
  20835. + size_t nlen, plen;
  20836. + char *string;
  20837. +
  20838. + switch (categorize_decl_for_section (decl, reloc))
  20839. + {
  20840. + case SECCAT_TEXT:
  20841. + prefix = one_only ? ".gnu.linkonce.t." : ".text.";
  20842. + break;
  20843. + case SECCAT_RODATA:
  20844. + prefix = one_only ? ".gnu.linkonce.r." : ".rodata.";
  20845. + break;
  20846. + case SECCAT_RODATA_MERGE_STR:
  20847. + case SECCAT_RODATA_MERGE_STR_INIT:
  20848. + case SECCAT_RODATA_MERGE_CONST:
  20849. + prefix = one_only ? ".gnu.linkonce.r." : ".rodata.";
  20850. + break;
  20851. + case SECCAT_SRODATA:
  20852. + prefix = one_only ? ".gnu.linkonce.s2." : ".sdata2.";
  20853. + break;
  20854. + case SECCAT_DATA:
  20855. + prefix = one_only ? ".gnu.linkonce.d." : ".data.";
  20856. + break;
  20857. + case SECCAT_DATA_REL:
  20858. + prefix = one_only ? ".gnu.linkonce.d.rel." : ".data.rel.";
  20859. + break;
  20860. + case SECCAT_DATA_REL_LOCAL:
  20861. + prefix = one_only ? ".gnu.linkonce.d.rel.local" : ".data.rel.local.";
  20862. + break;
  20863. + case SECCAT_DATA_REL_RO:
  20864. + prefix = one_only ? ".gnu.linkonce.d.rel.ro." : ".data.rel.ro.";
  20865. + break;
  20866. + case SECCAT_DATA_REL_RO_LOCAL:
  20867. + prefix = one_only ? ".gnu.linkonce.d.rel.ro.local." : ".data.rel.ro.local.";
  20868. + break;
  20869. + case SECCAT_SDATA:
  20870. + prefix = one_only ? ".gnu.linkonce.s." : ".sdata.";
  20871. + break;
  20872. + case SECCAT_BSS:
  20873. + prefix = one_only ? ".gnu.linkonce.d." : ".data.";
  20874. + break;
  20875. + case SECCAT_SBSS:
  20876. + prefix = one_only ? ".gnu.linkonce.s." : ".sdata.";
  20877. + break;
  20878. + /* Add default handlers to deal with tdata and tbss sections */
  20879. + case SECCAT_TDATA:
  20880. + prefix = one_only ? ".gnu.linkonce.td." : ".tdata.";
  20881. + break;
  20882. + case SECCAT_TBSS:
  20883. + prefix = one_only ? ".gnu.linkonce.tb." : ".tbss.";
  20884. + break;
  20885. + default:
  20886. + gcc_unreachable ();
  20887. + }
  20888. + plen = strlen (prefix);
  20889. +
  20890. + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
  20891. + name = targetm.strip_name_encoding (name);
  20892. + nlen = strlen (name);
  20893. +
  20894. + string = alloca (nlen + plen + 1);
  20895. + memcpy (string, prefix, plen);
  20896. + memcpy (string + plen, name, nlen + 1);
  20897. +
  20898. + DECL_SECTION_NAME (decl) = build_string (nlen + plen, string);
  20899. +}
  20900. +
  20901. +static section *
  20902. +metag_bfd_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
  20903. +{
  20904. + const char *sname;
  20905. +
  20906. + switch (categorize_decl_for_section (decl, reloc))
  20907. + {
  20908. + case SECCAT_TEXT:
  20909. + /* We're not supposed to be called on FUNCTION_DECLs. */
  20910. + gcc_unreachable ();
  20911. + case SECCAT_RODATA:
  20912. + return readonly_data_section;
  20913. + case SECCAT_RODATA_MERGE_STR:
  20914. + return mergeable_string_section (decl, align, 0);
  20915. + case SECCAT_RODATA_MERGE_STR_INIT:
  20916. + return mergeable_string_section (DECL_INITIAL (decl), align, 0);
  20917. + case SECCAT_RODATA_MERGE_CONST:
  20918. + return mergeable_constant_section (DECL_MODE (decl), align, 0);
  20919. + case SECCAT_SRODATA:
  20920. + sname = ".sdata2";
  20921. + break;
  20922. + case SECCAT_DATA:
  20923. + return data_section;
  20924. + case SECCAT_DATA_REL:
  20925. + sname = ".data.rel";
  20926. + break;
  20927. + case SECCAT_DATA_REL_LOCAL:
  20928. + sname = ".data.rel.local";
  20929. + break;
  20930. + case SECCAT_DATA_REL_RO:
  20931. + sname = ".data.rel.ro";
  20932. + break;
  20933. + case SECCAT_DATA_REL_RO_LOCAL:
  20934. + sname = ".data.rel.ro.local";
  20935. + break;
  20936. + case SECCAT_SDATA:
  20937. + sname = ".sdata";
  20938. + break;
  20939. + /* Add default handler to deal with tdata sections */
  20940. + case SECCAT_TDATA:
  20941. + sname = ".tdata";
  20942. + break;
  20943. + case SECCAT_BSS:
  20944. + return data_section;
  20945. + case SECCAT_SBSS:
  20946. + return sdata_section;
  20947. + /* Add default handler to deal with tbss sections */
  20948. + case SECCAT_TBSS:
  20949. + sname = ".tbss";
  20950. + break;
  20951. + default:
  20952. + gcc_unreachable ();
  20953. + }
  20954. + if (!DECL_P (decl))
  20955. + decl = NULL_TREE;
  20956. + return get_named_section (decl, sname, reloc);
  20957. +}
  20958. +
  20959. +bool
  20960. +metag_handle_option_per_os (size_t code ATTRIBUTE_UNUSED, const char *arg ATTRIBUTE_UNUSED, int value ATTRIBUTE_UNUSED)
  20961. +{
  20962. + return true;
  20963. +}
  20964. +
  20965. +void
  20966. +metag_override_options_per_os (void)
  20967. +{
  20968. + if (TARGET_MTX)
  20969. + error ("Meta Linux does not have MTX support");
  20970. +
  20971. + if (metac_target == METAC_1_0_ID
  20972. + || metac_target == METAC_1_1_ID
  20973. + || metac_target == METAC_0_1_ID)
  20974. + error ("Meta Linux does not have support for the specified core");
  20975. +}
  20976. +
  20977. +/* Return 1 if X is a thread local symbol */
  20978. +
  20979. +static int
  20980. +metag_tls_symbol_ref_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
  20981. +{
  20982. + if (GET_CODE (*x) == SYMBOL_REF)
  20983. + return SYMBOL_REF_TLS_MODEL (*x) != 0;
  20984. +
  20985. + /* Don't recurse into UNSPEC_TLS looking for TLS symbols; these are
  20986. + TLS offsets, not real symbol references. */
  20987. + if (GET_CODE (*x) == UNSPEC
  20988. + && XINT (*x, 1) >= UNSPEC_FIRST_TLS
  20989. + && XINT (*x, 1) <= UNSPEC_LAST_TLS)
  20990. + return -1;
  20991. +
  20992. + return 0;
  20993. +}
  20994. +
  20995. +/* Return 1 if X contains a thread-local symbol. */
  20996. +
  20997. +bool
  20998. +metag_bfd_tls_referenced_p (rtx x)
  20999. +{
  21000. + if (!METAG_HAVE_TLS)
  21001. + return false;
  21002. +
  21003. + return for_each_rtx (&x, &metag_tls_symbol_ref_1, 0);
  21004. +}
  21005. +
  21006. +bool
  21007. +metag_function_ok_for_sibcall_per_os (tree fndecl ATTRIBUTE_UNUSED, tree exp ATTRIBUTE_UNUSED)
  21008. +{
  21009. + return true;
  21010. +}
  21011. +
  21012. +void
  21013. +metag_pad_function_call (rtx symbol_ref ATTRIBUTE_UNUSED)
  21014. +{
  21015. + return;
  21016. +}
  21017. +
  21018. +bool
  21019. +metag_tbiassert_p (rtx symbol_ref ATTRIBUTE_UNUSED)
  21020. +{
  21021. + return false;
  21022. +}
  21023. +
  21024. +/* Construct the SYMBOL_REF for the __tls_get_addr function. */
  21025. +
  21026. +static GTY(()) rtx metag_tls_symbol;
  21027. +
  21028. +static rtx
  21029. +metag_tls_get_addr (void)
  21030. +{
  21031. + if (!metag_tls_symbol)
  21032. + metag_tls_symbol = gen_rtx_SYMBOL_REF (Pmode, "__tls_get_addr");
  21033. +
  21034. + return metag_tls_symbol;
  21035. +}
  21036. +
  21037. +/* Construct the SYMBOL_REF for the __metag_load_tp function. */
  21038. +
  21039. +static GTY(()) rtx metag_tp_symbol;
  21040. +
  21041. +static rtx
  21042. +metag_load_tp (void)
  21043. +{
  21044. + if (!metag_tp_symbol)
  21045. + metag_tp_symbol = gen_rtx_SYMBOL_REF (Pmode, "__metag_load_tp");
  21046. +
  21047. + return metag_tp_symbol;
  21048. +}
  21049. +
  21050. +/* Generates rtl to call the metag_load_tp function to get the address of the
  21051. + thread pointer. The rtx representing the register containing this address
  21052. + is then returned. */
  21053. +
  21054. +static rtx
  21055. +gen_metag_load_tp (void)
  21056. +{
  21057. + rtx ret0, ret, tp, tmp, insn, eqv;
  21058. + ret0 = gen_rtx_REG (Pmode, D0Re0_REG);
  21059. + ret = gen_reg_rtx (Pmode);
  21060. + tp = gen_reg_rtx (Pmode);
  21061. +
  21062. + start_sequence ();
  21063. + tmp = gen_rtx_MEM (QImode, metag_load_tp ());
  21064. + insn = gen_call_value (ret0, tmp, const0_rtx);
  21065. + insn = emit_call_insn (insn);
  21066. + CONST_OR_PURE_CALL_P (insn) = 1;
  21067. + insn = get_insns ();
  21068. + end_sequence ();
  21069. +
  21070. + /* We need this equivalence expression so that the RTL optimiser
  21071. + can figure out it only needs to place one call to
  21072. + __metag_load_tp regardless of how many thread-local variables
  21073. + are present. */
  21074. + eqv = gen_rtx_UNSPEC (VOIDmode,
  21075. + gen_rtvec (1, metag_load_tp ()),
  21076. + UNSPEC_TLS);
  21077. + emit_libcall_block (insn, tp, ret0, eqv);
  21078. +
  21079. + return tp;
  21080. +}
  21081. +
  21082. +/* Return the TLS type for TLS symbols, 0 otherwise. */
  21083. +
  21084. +bool
  21085. +tls_symbolic_operand_p (rtx op)
  21086. +{
  21087. + return ((GET_CODE (op) == SYMBOL_REF) && (SYMBOL_REF_TLS_MODEL (op) != 0));
  21088. +}
  21089. +
  21090. +/* These functions are part of a framework to allow the support of OS
  21091. + specific builtin functions within GCC.
  21092. + The only builtin function for META Linux is __builtin_thread_pointer
  21093. + which returns the address of the thread pointer. */
  21094. +
  21095. +void
  21096. +metag_init_builtins_per_os (void)
  21097. +{
  21098. + tree nothrow = tree_cons (get_identifier ("nothrow"), NULL, NULL);
  21099. + tree ftmetag_tp = build_function_type (ptr_type_node, void_list_node);
  21100. +
  21101. + lang_hooks.builtin_function ("__builtin_thread_pointer",
  21102. + ftmetag_tp,
  21103. + METAG_BUILTIN_THREAD_POINTER,
  21104. + BUILT_IN_MD,
  21105. + NULL,
  21106. + nothrow);
  21107. +}
  21108. +
  21109. +/* Performs the expansion of the META Linux builtin functions */
  21110. +
  21111. +rtx
  21112. +metag_expand_builtin_per_os (tree exp, rtx target)
  21113. +{
  21114. + tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  21115. + int fcode = DECL_FUNCTION_CODE (fndecl);
  21116. +
  21117. + switch(fcode)
  21118. + {
  21119. + case METAG_BUILTIN_THREAD_POINTER: /* void * __builtin_thread_pointer (void) */
  21120. + target = gen_metag_load_tp ();
  21121. + return target;
  21122. + default:
  21123. + break;
  21124. + }
  21125. +
  21126. + return NULL_RTX;
  21127. +}
  21128. +
  21129. +/* Adds code to calculate the address of a TLS operand */
  21130. +
  21131. +rtx
  21132. +metag_bfd_legitimize_tls_address (rtx addr)
  21133. +{
  21134. + rtx tmp, tga, ret, tp, arg1, insn, ret0, eqv;
  21135. +
  21136. + gcc_assert (!no_new_pseudos);
  21137. + gcc_assert (SYMBOL_REF_P(addr));
  21138. +
  21139. + switch (SYMBOL_REF_TLS_MODEL (addr))
  21140. + {
  21141. + case TLS_MODEL_GLOBAL_DYNAMIC:
  21142. +
  21143. + current_function_uses_pic_offset_table = 1;
  21144. + arg1 = gen_rtx_REG (Pmode, D1Ar1_REG);
  21145. + ret0 = gen_rtx_REG (Pmode, D0Re0_REG);
  21146. + ret = gen_reg_rtx (Pmode);
  21147. +
  21148. + start_sequence ();
  21149. + emit_insn (gen_tls_gd (arg1, pic_offset_table_rtx, addr));
  21150. + tga = gen_rtx_MEM (QImode, metag_tls_get_addr ());
  21151. + insn = gen_call_value (ret0, tga, const0_rtx);
  21152. + insn = emit_call_insn (insn);
  21153. + CONST_OR_PURE_CALL_P (insn) = 1;
  21154. + use_reg (&CALL_INSN_FUNCTION_USAGE (insn), arg1);
  21155. + insn = get_insns ();
  21156. + end_sequence ();
  21157. +
  21158. + emit_libcall_block (insn, ret, ret0, addr);
  21159. +
  21160. + return ret;
  21161. +
  21162. + case TLS_MODEL_LOCAL_DYNAMIC:
  21163. +
  21164. + current_function_uses_pic_offset_table = 1;
  21165. + arg1 = gen_rtx_REG (Pmode, D1Ar1_REG);
  21166. + ret0 = gen_rtx_REG (Pmode, D0Re0_REG);
  21167. + tmp = gen_reg_rtx (Pmode);
  21168. + ret = gen_reg_rtx (Pmode);
  21169. +
  21170. + start_sequence ();
  21171. + emit_insn (gen_tls_ldm (arg1, pic_offset_table_rtx, addr));
  21172. + tga = gen_rtx_MEM (QImode, metag_tls_get_addr ());
  21173. + insn = gen_call_value (ret0, tga, const0_rtx);
  21174. + insn = emit_call_insn (insn);
  21175. + CONST_OR_PURE_CALL_P (insn) = 1;
  21176. + use_reg (&CALL_INSN_FUNCTION_USAGE (insn), arg1);
  21177. + insn = get_insns ();
  21178. + end_sequence ();
  21179. +
  21180. + /* We need this equivalence expression so that the RTL optimiser
  21181. + can figure out it only needs to place one call to
  21182. + __tls_get_addr regardless of how many local-dynamic model
  21183. + variables are present. */
  21184. + eqv = gen_rtx_UNSPEC (VOIDmode,
  21185. + gen_rtvec (1, metag_tls_get_addr ()),
  21186. + UNSPEC_TLSLDM);
  21187. +
  21188. + emit_libcall_block (insn, tmp, ret0, eqv);
  21189. +
  21190. + insn = gen_tls_ldo (ret, tmp, addr);
  21191. + emit_insn (insn);
  21192. +
  21193. + return ret;
  21194. +
  21195. + case TLS_MODEL_INITIAL_EXEC:
  21196. +
  21197. + tmp = gen_reg_rtx (Pmode);
  21198. +
  21199. + /* Produce different relocations depending on if PIC is enabled or not */
  21200. + if (METAG_FLAG_PIC)
  21201. + {
  21202. + current_function_uses_pic_offset_table = 1;
  21203. + emit_insn (gen_tls_ie (tmp, pic_offset_table_rtx, addr));
  21204. + }
  21205. + else
  21206. + {
  21207. + current_function_uses_pic_offset_table = 0;
  21208. + emit_insn (gen_tls_non_pic_ie (tmp, addr));
  21209. + }
  21210. +
  21211. + tp = gen_metag_load_tp ();
  21212. +
  21213. + return gen_rtx_PLUS (Pmode, tp, tmp);
  21214. +
  21215. + case TLS_MODEL_LOCAL_EXEC:
  21216. +
  21217. + tmp = gen_reg_rtx (Pmode);
  21218. + tp = gen_metag_load_tp ();
  21219. +
  21220. + emit_insn (gen_tls_le (tmp, tp, addr));
  21221. +
  21222. + return tmp;
  21223. +
  21224. + default:
  21225. + gcc_unreachable ();
  21226. + }
  21227. +}
  21228. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag-linux.h gcc-4.2.4/gcc/config/metag/metag-linux.h
  21229. --- gcc-4.2.4.orig/gcc/config/metag/metag-linux.h 1969-12-31 18:00:00.000000000 -0600
  21230. +++ gcc-4.2.4/gcc/config/metag/metag-linux.h 2015-07-03 18:46:05.749283542 -0500
  21231. @@ -0,0 +1,177 @@
  21232. +/* Definitions of target machine for GNU compiler.
  21233. + Imagination Technologies Meta version.
  21234. + Copyright (C) 2008
  21235. + Imagination Technologies Ltd
  21236. +
  21237. +This file is part of GCC.
  21238. +
  21239. +GCC is free software; you can redistribute it and/or modify it under
  21240. +the terms of the GNU General Public License as published by the Free
  21241. +Software Foundation; either version 3, or (at your option) any later
  21242. +version.
  21243. +
  21244. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  21245. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  21246. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  21247. +for more details.
  21248. +
  21249. +You should have received a copy of the GNU General Public License
  21250. +along with GCC; see the file COPYING3. If not see
  21251. +<http://www.gnu.org/licenses/>. */
  21252. +
  21253. +#include "metag.h"
  21254. +
  21255. +/* OG and OGA addressing are not available */
  21256. +#define OG_ENABLED false
  21257. +
  21258. +#define METAG_FLAG_PIC flag_pic
  21259. +
  21260. +/* The prefix to add to user-visible assembler symbols. */
  21261. +#undef USER_LABEL_PREFIX
  21262. +#define USER_LABEL_PREFIX "_"
  21263. +
  21264. +#ifdef MINIM_DEFAULT
  21265. +#define DEFAULT_MINIM_ASM_SPEC "%{!mno-minim:-minim} "
  21266. +#else
  21267. +#define DEFAULT_MINIM_ASM_SPEC
  21268. +#endif
  21269. +
  21270. +#define ASM_SPEC \
  21271. + "%:meta_reduce_options(%{mmetac=*&mhard-float*&msoft-float&msimd-float}) " \
  21272. + "%{mdsp:%{mmetac=1.2:-mdsp=metac12}%{mmetac=2.1:-mdsp=metac21}} " \
  21273. + "%{mmetac=0.1:-mcpu=metac01} " \
  21274. + "%{mmetac=1.0:-mcpu=metac10} " \
  21275. + "%{mmetac=1.1:-mcpu=metac11} " \
  21276. + "%{mmetac=1.2:-mcpu=metac12} " \
  21277. + "%{mmetac=2.1:-mcpu=metac21} " \
  21278. + "%{mhard-float*:%{mmetac=2.1:-mfpu=metac21}%{!mmetac=2.1:%eThe floating point unit is only available on a META 2.1}} " \
  21279. + "%{mminim:-minim} " \
  21280. + DEFAULT_MINIM_ASM_SPEC
  21281. +
  21282. +/* This is how to output an assembler line for a numeric constant byte. */
  21283. +
  21284. +#define ASM_OUTPUT_BYTE(FILE, VALUE) \
  21285. + fprintf (FILE, "\t.byte\t0x%x\n", (int) ((VALUE) & 0xff))
  21286. +
  21287. +/* There has been some confusion over the meaning of the .align directive
  21288. + in gas over the last few years. However there is now a new directive
  21289. + called .balign that is explicitly defined as taking an absolute alignment
  21290. + value rather than a log2 value. We will now use this by default if
  21291. + available and leave the old implementation as is (even though it is wrong) */
  21292. +#ifdef HAVE_GAS_BALIGN_AND_P2ALIGN
  21293. +
  21294. +#undef ASM_OUTPUT_ALIGN
  21295. +#define ASM_OUTPUT_ALIGN(FILE, LOG) \
  21296. + do { \
  21297. + if ((LOG)!=0) \
  21298. + fprintf ((FILE), "\t.balign %d\n", 1<<(LOG)); \
  21299. + } while (0)
  21300. +
  21301. +#else
  21302. +
  21303. +#undef ASM_OUTPUT_ALIGN
  21304. +#define ASM_OUTPUT_ALIGN(FILE, LOG) \
  21305. + do { \
  21306. + if ((LOG) != 0) \
  21307. + fprintf (FILE, "%s%u\n", ALIGN_ASM_OP, LOG); \
  21308. + } while (0)
  21309. +
  21310. +#endif
  21311. +
  21312. +/* This says how to output an assembler line
  21313. + to define a global common symbol. */
  21314. +
  21315. +#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
  21316. + do { \
  21317. + fputs ("\t.comm\t", FILE); \
  21318. + assemble_name (FILE, (NAME)); \
  21319. + fprintf (FILE, ",%u\n", (SIZE)); \
  21320. + } while (0)
  21321. +
  21322. +/* This says how to output an assembler line
  21323. + to define a local common symbol. */
  21324. +
  21325. +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \
  21326. + do { \
  21327. + fputs ("\t.lcomm\t", FILE); \
  21328. + assemble_name (FILE, (NAME)); \
  21329. + fprintf (FILE, ",%u\n", (SIZE)); \
  21330. + } while (0)
  21331. +
  21332. +#define TEXT_SECTION_ASM_OP ".text"
  21333. +
  21334. +#define DATA_SECTION_ASM_OP ".data"
  21335. +
  21336. +#define DATA_SECTION DATA_SECTION_ASM_OP
  21337. +
  21338. +/* Try machine-dependent ways of modifying an illegitimate address
  21339. + to be legitimate. If we find one, return the new, valid address.
  21340. + This macro is used in only one place: `memory_address' in explow.c.
  21341. +
  21342. + OLDX is the address as it was before break_out_memory_refs was called.
  21343. + In some cases it is useful to look at this to decide what needs to be done.
  21344. +
  21345. + MODE and WIN are passed so that this macro can use
  21346. + GO_IF_LEGITIMATE_ADDRESS.
  21347. +
  21348. + It is always safe for this macro to do nothing. It exists to recognize
  21349. + opportunities to optimize the output. */
  21350. +
  21351. +#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
  21352. + do { \
  21353. + (X) = metag_legitimize_address (X, OLDX, MODE); \
  21354. + if (memory_address_p (MODE, X)) \
  21355. + goto WIN; \
  21356. + } while (0)
  21357. +
  21358. +#undef ASM_GENERATE_INTERNAL_LABEL
  21359. +#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
  21360. + sprintf (LABEL, "*%s%s%u", LOCAL_LABEL_PREFIX, PREFIX, (unsigned)(NUM))
  21361. +
  21362. +/* Register to hold the addressing base for position independent
  21363. + code access to data items. */
  21364. +#define PIC_OFFSET_TABLE_REGNUM PIC_REG
  21365. +
  21366. +/* Nonzero if the constant value X is a legitimate general operand
  21367. + when generating PIC code. It is given that flag_pic is on and
  21368. + that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
  21369. +
  21370. +#define LEGITIMATE_PIC_OPERAND_P(X) \
  21371. + (! SYMBOLIC_CONST (X) || metag_legitimate_pic_address_disp_p (X))
  21372. +
  21373. +/* The `FINALIZE_PIC' macro serves as a hook to emit these special
  21374. + codes once the function is being compiled into assembly code, but
  21375. + not before. (It is not done before, because in the case of
  21376. + compiling an inline function, it would lead to multiple PIC
  21377. + prologues being included in functions which used inline functions
  21378. + and were compiled to assembly language.) */
  21379. +
  21380. +#define FIXME_FINALIZE_PIC \
  21381. + do \
  21382. + { \
  21383. + extern int current_function_uses_pic_offset_table; \
  21384. + \
  21385. + current_function_uses_pic_offset_table \
  21386. + |= profile_flag | profile_block_flag; \
  21387. + } \
  21388. + while (0)
  21389. +
  21390. +#define ASSEMBLE_END_FUNCTION(DECL,FNNAME) \
  21391. + do { \
  21392. + metag_emit_cond_return_stub_if_reqd (); \
  21393. + } while (0)
  21394. +
  21395. +#ifdef HAVE_AS_TLS
  21396. +#undef TARGET_HAVE_TLS
  21397. +#define TARGET_HAVE_TLS HAVE_AS_TLS
  21398. +#endif
  21399. +
  21400. +/* Nonzero if the constant value X is a legitimate general operand.
  21401. + It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
  21402. +
  21403. + This is true apart from cases where the symbol represents a TLS
  21404. + symbol. */
  21405. +
  21406. +#undef LEGITIMATE_CONSTANT_P
  21407. +#define LEGITIMATE_CONSTANT_P(X) \
  21408. + (!tls_symbolic_operand_p (X))
  21409. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag-linux.opt gcc-4.2.4/gcc/config/metag/metag-linux.opt
  21410. --- gcc-4.2.4.orig/gcc/config/metag/metag-linux.opt 1969-12-31 18:00:00.000000000 -0600
  21411. +++ gcc-4.2.4/gcc/config/metag/metag-linux.opt 2015-07-03 18:46:05.749283542 -0500
  21412. @@ -0,0 +1,25 @@
  21413. +; Copyright (C) 2008 Imagination Technologies Ltd
  21414. +
  21415. +; This file is part of GCC.
  21416. +
  21417. +; GCC is free software; you can redistribute it and/or modify it under
  21418. +; the terms of the GNU General Public License as published by the Free
  21419. +; Software Foundation; either version 3, or (at your option) any later
  21420. +; version.
  21421. +
  21422. +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  21423. +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  21424. +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  21425. +; for more details.
  21426. +
  21427. +; You should have received a copy of the GNU General Public License
  21428. +; along with GCC; see the file COPYING3. If not see
  21429. +; <http://www.gnu.org/licenses/>.
  21430. +
  21431. +
  21432. +; Default model is large (small model is 'better' but not supported
  21433. +; in binutils toolchain
  21434. +mmodel=
  21435. +Target RejectNegative Joined Var(metag_model_string) Init("large")
  21436. +Memory access model (small|large) [NOTE: small not supported]
  21437. +
  21438. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag.md gcc-4.2.4/gcc/config/metag/metag.md
  21439. --- gcc-4.2.4.orig/gcc/config/metag/metag.md 1969-12-31 18:00:00.000000000 -0600
  21440. +++ gcc-4.2.4/gcc/config/metag/metag.md 2015-07-03 18:46:05.773283541 -0500
  21441. @@ -0,0 +1,8255 @@
  21442. +;; Machine description for GNU compiler,
  21443. +;; Imagination Technologies Meta version.
  21444. +;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
  21445. +;; Imagination Technologies Ltd
  21446. +
  21447. +;; This file is part of GCC.
  21448. +
  21449. +;; GCC is free software; you can redistribute it and/or modify it under
  21450. +;; the terms of the GNU General Public License as published by the Free
  21451. +;; Software Foundation; either version 3, or (at your option) any later
  21452. +;; version.
  21453. +
  21454. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  21455. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  21456. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  21457. +;; for more details.
  21458. +
  21459. +;; You should have received a copy of the GNU General Public License
  21460. +;; along with GCC; see the file COPYING3. If not see
  21461. +;; <http://www.gnu.org/licenses/>.
  21462. +
  21463. +;;- instruction definitions
  21464. +
  21465. +;;- @@The original PO technology requires these to be ordered by speed,
  21466. +;;- @@ so that assigner will pick the fastest.
  21467. +
  21468. +;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  21469. +
  21470. +;;- When naming insn's (operand 0 of define_insn) be careful about using
  21471. +;;- names from other targets machine descriptions.
  21472. +
  21473. +
  21474. +;; MODE macros
  21475. +(define_mode_macro CCALL [CC_FP CC_FP_Q CC CC_NOOV CC_Z])
  21476. +
  21477. +(define_mode_macro CCFP [CC_FP CC_FP_Q])
  21478. +
  21479. +(define_mode_macro CCANY [CC CC_NOOV CC_Z])
  21480. +
  21481. +(define_mode_macro CCZNC [CC_NOOV CC_Z])
  21482. +
  21483. +(define_mode_macro IMODES [QI HI SI DI])
  21484. +
  21485. +(define_mode_macro FMODES [SF DF])
  21486. +
  21487. +(define_mode_macro FLMODES [SF DF V2SF])
  21488. +
  21489. +; Floating point storage modes
  21490. +; This is same as FMODES at the moment but HF would go here when it's supported
  21491. +; WHen HF is added some insns need to be split as HF conversions have a single
  21492. +; cycle stall whereas others have 5 cycle stalls
  21493. +(define_mode_macro FSMODES [SF DF])
  21494. +
  21495. +(define_mode_macro MODES [QI HI SI DI SF DF V2SF V2SI])
  21496. +
  21497. +(define_mode_macro EXTDI [QI HI SI])
  21498. +
  21499. +(define_mode_macro EXTSI [QI HI])
  21500. +
  21501. +(define_mode_macro EXTHI [QI])
  21502. +
  21503. +(define_mode_macro MEMOP [QI HI SI])
  21504. +
  21505. +;; MODE attrs
  21506. +
  21507. +(define_mode_attr S [(DI "8") (SI "4") (HI "2") (QI "1") (SF "4") (DF "8") (V2SF "8") (V2SI "8")])
  21508. +
  21509. +(define_mode_attr W [(DI "L") (SI "D") (HI "W") (QI "B") (SF "D") (DF "L") (V2SF "L") (V2SI "L")])
  21510. +
  21511. +(define_mode_attr P [(DI "l") (SI "d") (HI "w") (QI "b") (SF "d") (DF "l") (V2SF "l") (V2SI "l")])
  21512. +
  21513. +(define_mode_attr O [(DI "O8") (SI "O4") (HI "O2") (QI "O1") (SF "O4") (DF "O8") (V2SF "O8") (V2SI "O8")])
  21514. +
  21515. +(define_mode_attr Z [(DI "Z8") (SI "Z4") (HI "Z2") (QI "Z1") (SF "Z4") (DF "Z8") (V2SF "Z8") (V2SI "Z8")])
  21516. +
  21517. +(define_mode_attr FT [(SF "F") (DF "D")])
  21518. +(define_mode_attr FW [(SF "" ) (DF "D") (DI "D") (V2SF "L")])
  21519. +(define_mode_attr fcondition [(SF "TARGET_FPU") (DF "TARGET_FPU && !metag_fpu_single") (V2SF "TARGET_FPU_SIMD")])
  21520. +
  21521. +(define_mode_attr CCQ [(CC_FP "") (CC_FP_Q "Q")])
  21522. +
  21523. +;; CODE macros
  21524. +
  21525. +(define_code_macro CCCOND [eq ne gt gtu lt ltu ge geu le leu])
  21526. +
  21527. +(define_code_macro CCFPCOND [eq ne
  21528. + gt ge lt le unordered ltgt ordered
  21529. + ungt unge unlt unle uneq])
  21530. +
  21531. +(define_code_macro CCANYCOND [eq ne
  21532. + gtu ltu geu leu
  21533. + gt ge lt le unordered ordered
  21534. + ungt unge unlt unle])
  21535. +
  21536. +;; These code macros significantly simplify the peephole and vector patterns required
  21537. +;; for supporting dual unit DSP operations
  21538. +
  21539. +(define_code_macro 3OPREG [plus minus and ior xor ashift ashiftrt lshiftrt])
  21540. +(define_code_macro 3OPIMM16 [plus minus and ior xor])
  21541. +(define_code_macro 3OPIMM5 [ashift ashiftrt lshiftrt])
  21542. +(define_code_macro MINMAX [smin smax])
  21543. +
  21544. +;; CODE attrs
  21545. +
  21546. +;; These code attributes are used for peephole and vector patterns that support
  21547. +;; dual unit DSP operations
  21548. +
  21549. +(define_code_attr MNEMONIC [(plus "ADD") (minus "SUB") (and "AND") (ior "OR") (xor "XOR")
  21550. + (ashift "LSL") (ashiftrt "ASR") (lshiftrt "LSR") (smin "MIN")
  21551. + (smax "MAX")])
  21552. +
  21553. +(define_code_attr commutative [(plus "true") (minus "false") (and "true") (ior "true") (xor "true")
  21554. + (ashift "false") (ashiftrt "false") (lshiftrt "false") (smin "true")
  21555. + (smax "true")])
  21556. +
  21557. +(define_code_attr expander [(plus "add") (minus "sub") (and "and") (ior "ior") (xor "xor")
  21558. + (ashift "ashl") (ashiftrt "ashr") (lshiftrt "lshr") (smin "smin")
  21559. + (smax "smax")])
  21560. +
  21561. +(define_code_attr dualunitimmcondition [(plus "&& !(TARGET_METAC_1_0 && (INTVAL (operands[1]) & 1) == 1)")
  21562. + (minus "&& !(TARGET_METAC_1_0 && (INTVAL (operands[1]) & 1) == 1)")
  21563. + (and "") (ior "") (xor "") (ashift "") (ashiftrt "") (lshiftrt "")
  21564. + (smin "") (smax "")])
  21565. +
  21566. +;; constants
  21567. +
  21568. +
  21569. +(include "constants.md")
  21570. +(include "predicates.md")
  21571. +(include "constraints.md")
  21572. +(include "pipeline.md")
  21573. +
  21574. +;; Insn type. Used to default other attribute values.
  21575. +(define_attr "type"
  21576. + "fast,swap,slow,two,twox,three,threex,\
  21577. + load,read,four,fourx,five,fivex,sixx,\
  21578. + sevenx,mult,slowslow,nop,block,branch,\
  21579. + FPfast,FPrecip,FPmas,FPrecipmas,unknown,invalid"
  21580. + (const_string "unknown"))
  21581. +
  21582. +;; Indiate of insn is suitable for register renaming
  21583. +(define_attr "rename" "no,yes" (const_string "yes"))
  21584. +
  21585. +;; Indicate if insn is conditional
  21586. +(define_attr "cond" "no,yes" (const_string "no"))
  21587. +
  21588. +;; Conditional execution attribute, implicitly used when creating predicated insns
  21589. +(define_attr "predicable" "no,yes" (const_string "no"))
  21590. +
  21591. +;; Type of memory operation
  21592. +(define_attr "memaccess" "load,store,none" (const_string "none"))
  21593. +
  21594. +;; O2R hints
  21595. +;; op2op1 - operand 2 is O2R if not in the same unit as operand 1
  21596. +;; op1op0 - operand 1 is O2R if not in the same unit as operand 0
  21597. +(define_attr "o2rhint" "op2op1,op1op0,none" (const_string "none"))
  21598. +
  21599. +;; Insn ccstate. Used to track interaction with the condition flags
  21600. +
  21601. +; xcc means that the condition codes are used by the insn in the process of
  21602. +; outputting code
  21603. +
  21604. +; set means that the purpose of the insn is to set the condition codes.
  21605. +
  21606. +; ccx means that the condition codes are altered in an undefined manner, if
  21607. +; they are altered at all
  21608. +
  21609. +; ncc means that the condition codes are neither altered nor affect the
  21610. +; output of this insn
  21611. +
  21612. +(define_attr "ccstate" "xcc,set,fastset,fastfastset,ccx,ncc" (const_string "ncc"))
  21613. +
  21614. +;; Length (in # of insns).
  21615. +(define_attr "length" ""
  21616. + (cond [(eq_attr "type" "two,slowslow,read") (const_int 8)
  21617. + (eq_attr "type" "three") (const_int 12)
  21618. + (eq_attr "type" "four") (const_int 16)
  21619. + (eq_attr "type" "five") (const_int 20)]
  21620. + (const_int 4)))
  21621. +
  21622. +;; User supplied instructions
  21623. +(define_asm_attributes
  21624. + [(set_attr "type" "unknown")
  21625. + (set_attr "ccstate" "ccx")
  21626. + (set_attr "length" "4")
  21627. + (set_attr "cond" "no")
  21628. + (set_attr "predicable" "no")
  21629. + (set_attr "memaccess" "none")
  21630. + (set_attr "o2rhint" "none")
  21631. + (set_attr "rename" "no")])
  21632. +
  21633. +
  21634. +;; Metac core revision.
  21635. +;; Used to select meta core revision specific insn scheduling.
  21636. +;; this attribute must exactly match the processor_type enumeration in metag.h
  21637. +
  21638. +(define_attr "metacore" "metac_1_0,metac_1_1,metac_1_2,metac_0_1,metac_2_1"
  21639. + (const (symbol_ref "metacore")))
  21640. +
  21641. +;; prologue/epilogue
  21642. +(define_expand "prologue"
  21643. + [(clobber (const_int 0))]
  21644. + ""
  21645. + {
  21646. + metag_expand_prologue ();
  21647. + DONE;
  21648. + }
  21649. +)
  21650. +
  21651. +(define_expand "epilogue"
  21652. + [(return)]
  21653. + ""
  21654. + {
  21655. + metag_expand_epilogue (false);
  21656. + emit_jump_insn (gen_return_internal ());
  21657. + DONE;
  21658. + }
  21659. +)
  21660. +
  21661. +(define_expand "sibcall_epilogue"
  21662. + [(return)]
  21663. + ""
  21664. + {
  21665. + metag_expand_epilogue (true);
  21666. + DONE;
  21667. + }
  21668. +)
  21669. +
  21670. +(define_insn "prologue_use"
  21671. + [(unspec:SI [(match_operand:SI 0 "register_operand" "r")] UNSPEC_PROLOGUE_USE)]
  21672. + ""
  21673. + "%@%@ %0 needed for prologue"
  21674. +)
  21675. +
  21676. +;; Patterns for exception handling
  21677. +
  21678. +(define_expand "eh_return"
  21679. + [(use (match_operand:SI 0 "register_operand" "r"))]
  21680. + ""
  21681. + {
  21682. + emit_insn (gen_eh_return_internal (operands[0]));
  21683. + DONE;
  21684. + }
  21685. +)
  21686. +
  21687. +(define_insn_and_split "eh_return_internal"
  21688. + [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] VUNSPEC_EH_RETURN)]
  21689. + ""
  21690. + "#"
  21691. + "reload_completed"
  21692. + [(const_int 0)]
  21693. + {
  21694. + metag_expand_set_return_address (operands[0]);
  21695. + DONE;
  21696. + }
  21697. +)
  21698. +
  21699. +
  21700. +(define_insn "blockage"
  21701. + [(unspec_volatile [(const_int 0)] VUNSPEC_BLOCKAGE)]
  21702. + ""
  21703. + ""
  21704. + [(set_attr "length" "0")
  21705. + (set_attr "type" "block")])
  21706. +
  21707. +
  21708. +;; move instructions
  21709. +
  21710. +(define_insn "swapsi"
  21711. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "+e,f,h,l")
  21712. + (match_operand:SI 1 "metag_reg_nofloat_op" "+t,u,y,z"))
  21713. + (set (match_dup 1)
  21714. + (match_dup 0))]
  21715. + ""
  21716. + "SWAP%?\\t%0, %1\\t%@ (*swap SI OK)"
  21717. + [(set_attr "type" "swap")
  21718. + (set_attr "predicable" "yes")
  21719. + (set_attr "cond" "yes")])
  21720. +
  21721. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  21722. +;; movsi is made up of many parts.. ;;
  21723. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  21724. +(define_expand "movsi"
  21725. + [(set (match_operand:SI 0 "nonimmediate_operand" "")
  21726. + (match_operand:SI 1 "general_operand" ""))]
  21727. + ""
  21728. + {
  21729. +
  21730. + /* The output template that was here has been moved in the
  21731. + metag_emit_move_sequence function in metag.c */
  21732. + metag_emit_move_sequence (operands, SImode);
  21733. + }
  21734. +)
  21735. +
  21736. +;; The problem:
  21737. +;; GCC cannot differentiate a legitimate address from an illegitimate one when the only
  21738. +;; factor affecting the split is the class that the register being loaded to or stored
  21739. +;; from belongs to.
  21740. +
  21741. +;; This problem affects FX registers with SImode values in them. FX registers can only
  21742. +;; be stored and loaded from register+6bit offset whereas all other registers can be
  21743. +;; stored and loaded from register+12bit offset if the base register supports it.
  21744. +
  21745. +;; The solution:
  21746. +;; Prevent reload from having a free-for-all on determining legitimate addresses. The
  21747. +;; fallback case in mov_si therefore DOES NOT contain the FP register class in either
  21748. +;; of the memory constraint alternatives. Reload will fix this by reloading any FX
  21749. +;; register into another register as required.
  21750. +
  21751. +;; The caveat:
  21752. +;; This solution prevents FX registers being reloaded directly to and from memory. To
  21753. +;; solve this, the 6 and 12 bit load/store insns are above the fallback mov_si
  21754. +;; pattern so as to allow FX registers to be reloaded to and from memory directly.
  21755. +
  21756. +;; WORK NEEDED: Prove this does actually allow FX registers holding SImode values to
  21757. +;; be directly loaded and stored to base+6bit offset addresses.
  21758. +
  21759. +(define_insn "*sto_si_1_1_off12"
  21760. + [(set (mem:SI (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "da,Yr")
  21761. + (match_operand:SI 1 "metag_offset12_si" "O4,Z4")))
  21762. + (match_operand:SI 2 "metag_reg_nofloat_op" "da,da"))]
  21763. + "TARGET_METAC_1_1"
  21764. + "SETD\\t[%0+%1], %2"
  21765. + [(set_attr "type" "fast")])
  21766. +
  21767. +(define_insn "*sto_si_1_1_off6"
  21768. + [(set (mem:SI (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  21769. + (match_operand:SI 1 "metag_offset6_si" "O4")))
  21770. + (match_operand:SI 2 "metag_register_op" "cr"))]
  21771. + "TARGET_METAC_1_1"
  21772. + {
  21773. + static const char fmt[] = "F\\tSETD\\t[%0+%1], %2\\t%@ (*sto SI off6 OK)";
  21774. +
  21775. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  21776. + }
  21777. + [(set_attr "type" "fast")])
  21778. +
  21779. +(define_insn "*lod_si_off12"
  21780. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da,da")
  21781. + (mem:SI (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "da,Yr")
  21782. + (match_operand:SI 2 "metag_offset12_si" "O4,Z4"))))]
  21783. + ""
  21784. + "GETD\\t%0, [%1+%2]"
  21785. + [(set_attr "type" "load")])
  21786. +
  21787. +(define_insn "*lod_si_off"
  21788. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  21789. + (mem:SI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  21790. + (match_operand:SI 2 "metag_offset6_si" "O4"))))]
  21791. + ""
  21792. + {
  21793. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2]\\t%@ (*lod SI off6 OK)";
  21794. +
  21795. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  21796. + }
  21797. + [(set_attr "type" "load")])
  21798. +
  21799. +;; This instruction gets used by reload to generate reload instruction
  21800. +;; which is why it needs to handle r -> mem and mem -> r alternatives.
  21801. +;; Do not handle TXRPT as it cannot handle base + 12bit offsets loads/stores
  21802. +;; Patterns below handle txrpt moving between R_REGS and Wx_REGS
  21803. +
  21804. +(define_insn "*mov_si"
  21805. + [(set (match_operand:SI 0 "metag_register_op" "=e,f,h,l,r,?*cx, r,!*m,*cx,!d")
  21806. + (match_operand:SI 1 "metag_register_op" "e,f,h,l,r,?*cx,!*m, r,!d, *cx"))]
  21807. + ""
  21808. + {
  21809. + switch (which_alternative)
  21810. + {
  21811. + case 0:
  21812. + case 1:
  21813. + case 2:
  21814. + case 3:
  21815. + case 4:
  21816. + case 5:
  21817. + case 8:
  21818. + case 9:
  21819. + if (METAG_FPC_REG_P (REGNO (operands[0]))
  21820. + && METAG_FPC_REG_P (REGNO (operands[1])))
  21821. + return "F\\tMOV%?\\t%0, %1";
  21822. + else
  21823. + return "MOV%?\\t%0, %1";
  21824. + case 6:
  21825. + if (METAG_FPC_REG_P (REGNO (operands[0])))
  21826. + return "F\\tGETD\\t%0, %1";
  21827. + else
  21828. + return "GETD\\t%0, %1";
  21829. + case 7:
  21830. + if (METAG_FPC_REG_P (REGNO (operands[1])))
  21831. + return "F\\tSETD\\t%0, %1";
  21832. + else
  21833. + return "SETD\\t%0, %1";
  21834. + default:
  21835. + gcc_unreachable ();
  21836. + }
  21837. + }
  21838. + [(set_attr "type" "fast,fast,fast,fast,slow,fast,load,fast,slow,slow")
  21839. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,no,no,yes,yes")
  21840. + (set_attr "memaccess" "none,none,none,none,none,none,load,store,none,none")
  21841. + (set_attr "predicable" "yes")])
  21842. +
  21843. +(define_insn "ttmov_si"
  21844. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21845. + (unspec_volatile:SI [(match_operand:SI 1 "metag_reg_nofloat_op" "da")] VUNSPEC_TTMOV))]
  21846. + ""
  21847. + "TTMOV%?\\t%0, %1 %@ H/W Tracing. Normal MOV but with value also sent to trace port"
  21848. + [(set_attr "type" "fast")
  21849. + (set_attr "cond" "yes")
  21850. + (set_attr "predicable" "yes")
  21851. + (set_attr "rename" "no")])
  21852. +
  21853. +(define_insn "ttrec"
  21854. + [(set (match_operand:DI 0 "metag_ttrec_op" "=Wx")
  21855. + (unspec_volatile:DI [(match_operand:DI 1 "metag_reg_nofloat_op" "da")] VUNSPEC_TTREC))]
  21856. + ""
  21857. + "MOVL%?\\t%0, %1, %t1 %@ H/W Tracing. Functionally a NOP. Values sent to trace port"
  21858. + [(set_attr "type" "fast")
  21859. + (set_attr "cond" "yes")
  21860. + (set_attr "predicable" "yes")
  21861. + (set_attr "rename" "no")])
  21862. +
  21863. +(define_insn "*mov_si_rxrpt_r"
  21864. + [(set (match_operand:SI 0 "metag_txrpt_op" "=Wx")
  21865. + (match_operand:SI 1 "metag_register_op" "r"))]
  21866. + ""
  21867. + "MOV%?\\t%0, %1"
  21868. + [(set_attr "type" "fast")
  21869. + (set_attr "predicable" "yes")])
  21870. +
  21871. +(define_insn "*mov_si_r_txrpt"
  21872. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  21873. + (match_operand:SI 1 "metag_txrpt_op" "Wx"))]
  21874. + ""
  21875. + "MOV%?\\t%0, %1"
  21876. + [(set_attr "type" "fast")
  21877. + (set_attr "predicable" "yes")])
  21878. +
  21879. +(define_insn "*mov_si_txrpt_ri"
  21880. + [(set (match_operand:SI 0 "metag_txrpt_op" "=Wx,Wx,Wx")
  21881. + (match_operand:SI 1 "metag_txrpt_src_op" "KIP,J, r"))]
  21882. + ""
  21883. + "@
  21884. + MOV\\t%0, %1
  21885. + MOVT\\t%0, %1
  21886. + MOV%?\\t%0, %1"
  21887. + [(set_attr "type" "fast,fast,fast")
  21888. + (set_attr "cond" "no,no,yes")])
  21889. +
  21890. +;; movsi - all the immediate to register sets
  21891. +(define_insn "*cond_<mode>_mov_si_zero"
  21892. + [(cond_exec
  21893. + (match_operator 1 "comparison_operator"
  21894. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  21895. + (const_int 0)])
  21896. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "=d,a")
  21897. + (const_int 0)))]
  21898. + "TARGET_COND_EXEC_OPTIMIZE"
  21899. + "SUB%?\\t%0, %0, %0"
  21900. + [(set_attr "type" "fast,slow")])
  21901. +
  21902. +(define_insn "*mov_si_zero"
  21903. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=d,a")
  21904. + (const_int 0))]
  21905. + "TARGET_COND_EXEC_OPTIMIZE"
  21906. + {
  21907. + if (metag_cond_exec_p ())
  21908. + return "SUB%?\\t%0, %0, %0";
  21909. + else
  21910. + return "MOV\\t%0, #0";
  21911. + }
  21912. + [(set_attr "type" "fast,slow")
  21913. + (set_attr "cond" "yes")])
  21914. +
  21915. +(define_insn "*set_si_KIP"
  21916. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21917. + (match_operand:SI 1 "metag_KIP_operand" "KIP"))]
  21918. + ""
  21919. + "MOV\\t%0, %1\\t\\t%@ (*set si rKIP OK)"
  21920. + [(set_attr "type" "fast")])
  21921. +
  21922. +(define_insn "*set_si_J"
  21923. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21924. + (match_operand:SI 1 "metag_J_operand" "J"))]
  21925. + ""
  21926. + "MOVT\\t%0, %1\\t\\t%@ (*set si rJ OK)"
  21927. + [(set_attr "type" "fast")])
  21928. +
  21929. +(define_insn "*set_si_HI"
  21930. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21931. + (match_operand:SI 1 "metag_O0_operand" "O0"))]
  21932. + ""
  21933. + "MOVT\\t%0, #HI(%c1)\\t%@ (*set si rO0 OK)"
  21934. + [(set_attr "type" "fast")])
  21935. +
  21936. +(define_insn "*set_si_LO"
  21937. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21938. + (match_operand:SI 1 "metag_O3_operand" "O3"))]
  21939. + ""
  21940. + "MOVT\\t%0, #LO(%c1)\\t%@ (*set si rO3 OK)"
  21941. + [(set_attr "type" "fast")])
  21942. +
  21943. +(define_insn_and_split "*set_si"
  21944. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da, da,da")
  21945. + (match_operand:SI 1 "metag_bigint_op" "IPK,J, n"))]
  21946. + ""
  21947. + "#"
  21948. + "reload_completed"
  21949. + [(const_int 0)]
  21950. + {
  21951. + metag_split_movsi_immediate (operands);
  21952. + DONE;
  21953. + }
  21954. + [(set_attr "type" "fast,fast,two")])
  21955. +
  21956. +;; movsi - symbol_ref to register sets
  21957. +(define_insn "*set_si_symbol_got"
  21958. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21959. + (mem:SI (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  21960. + (const (unspec [(match_operand:SI 2 "symbolic_operand" "")] UNSPEC_GOT)))))]
  21961. + "METAG_FLAG_PIC&& operands[1] == pic_offset_table_rtx"
  21962. + "GETD\\t%0, [%1+#(%c2@GOT)]\\t%@ (*set si r-picsym OK)"
  21963. + [(set_attr "type" "load")])
  21964. +
  21965. +(define_insn "*add_si_HI_symbol_gotoff"
  21966. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21967. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  21968. + (high:SI (const (unspec [(match_operand:SI 2 "symbolic_operand" "")] UNSPEC_GOTOFF)))))]
  21969. + "METAG_FLAG_PIC"
  21970. + "ADDT\\t%0, %1, #HI(%c2@GOTOFF)"
  21971. + [(set_attr "type" "fast")])
  21972. +
  21973. +(define_insn "*mov_si_HI_symbol_gotoff"
  21974. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21975. + (high:SI (const (unspec [(match_operand:SI 1 "symbolic_operand" "")] UNSPEC_GOTOFF))))]
  21976. + "METAG_FLAG_PIC"
  21977. + "MOVT\\t%0, #HI(%c1@GOTOFF)"
  21978. + [(set_attr "type" "fast")])
  21979. +
  21980. +(define_insn "*add_si_LO_symbol_gotoff"
  21981. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  21982. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  21983. + (const (unspec [(match_operand:SI 2 "symbolic_operand" "")] UNSPEC_GOTOFF))))]
  21984. + "METAG_FLAG_PIC"
  21985. + "ADD\\t%0, %1, #LO(%c2@GOTOFF)"
  21986. + [(set_attr "type" "fast")])
  21987. +
  21988. +(define_insn_and_split "*set_si_symbol_gotoff"
  21989. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  21990. + (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  21991. + (const (unspec [(match_operand:SI 2 "symbolic_operand" "")] UNSPEC_GOTOFF))))]
  21992. + "METAG_FLAG_PIC&& operands[1] == pic_offset_table_rtx"
  21993. + "#"
  21994. + "&& SPLIT_HI_LO_SUM_EARLY"
  21995. + [(set (match_dup 0)
  21996. + (match_dup 1))
  21997. + (set (match_dup 0)
  21998. + (plus:SI (match_dup 0)
  21999. + (high:SI (const (unspec [(match_dup 2)] UNSPEC_GOTOFF)))))
  22000. + (set (match_dup 0)
  22001. + (lo_sum:SI (match_dup 0)
  22002. + (const (unspec [(match_dup 2)] UNSPEC_GOTOFF))))]
  22003. + ""
  22004. + [(set_attr "type" "three")])
  22005. +
  22006. +(define_insn_and_split "*set_si_symbol_gotoff_val"
  22007. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  22008. + (const (unspec [(match_operand:SI 1 "symbolic_operand" "")] UNSPEC_GOTOFF)))]
  22009. + "METAG_FLAG_PIC"
  22010. + "#"
  22011. + "&& SPLIT_HI_LO_SUM_EARLY"
  22012. + [(set (match_dup 0)
  22013. + (high:SI (const (unspec [(match_dup 1)] UNSPEC_GOTOFF))))
  22014. + (set (match_dup 0)
  22015. + (lo_sum:SI (match_dup 0)
  22016. + (const (unspec [(match_dup 1)] UNSPEC_GOTOFF))))]
  22017. + ""
  22018. + [(set_attr "type" "two")])
  22019. +
  22020. +(define_insn "*add_si_HI_symbol_large"
  22021. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22022. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22023. + (high:SI (match_operand 2 "metag_symlarge_op" ""))))]
  22024. + "OG_ENABLED"
  22025. + "ADDT\\t%0, %1, #HI(OG(%c2))"
  22026. + [(set_attr "type" "fast")])
  22027. +
  22028. +(define_insn "*add_si_LO_symbol_large"
  22029. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22030. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22031. + (match_operand 2 "metag_symlarge_op" "")))]
  22032. + "OG_ENABLED"
  22033. + "ADD\\t%0, %1, #LO(OG(%c2))"
  22034. + [(set_attr "type" "fast")])
  22035. +
  22036. +(define_insn_and_split "*set_si_symbol_large"
  22037. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&l,!&da")
  22038. + (match_operand:SI 1 "metag_symlarge_op" ""))]
  22039. + "OG_ENABLED"
  22040. + "#"
  22041. + "&& SPLIT_HI_LO_SUM_EARLY"
  22042. + [(set (match_dup 0)
  22043. + (match_dup 2))
  22044. + (set (match_dup 0)
  22045. + (plus:SI (match_dup 0)
  22046. + (high:SI (match_dup 1))))
  22047. + (set (match_dup 0)
  22048. + (lo_sum:SI (match_dup 0)
  22049. + (match_dup 1)))]
  22050. + {
  22051. + operands[2] = gen_rtx_REG (SImode, A1GbP_REG);
  22052. + }
  22053. + [(set_attr "type" "three")])
  22054. +
  22055. +(define_insn "*set_si_HI_symbol_global"
  22056. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22057. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))]
  22058. + "!METAG_FLAG_PIC"
  22059. + "MOVT\\t%0,#HI(%c1)"
  22060. + [(set_attr "type" "fast")])
  22061. +
  22062. +(define_insn "*add_si_LO_symbol_global"
  22063. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22064. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22065. + (match_operand:SI 2 "metag_symglobal_op" "" )))]
  22066. + "!METAG_FLAG_PIC"
  22067. + "ADD\\t%0, %1, #LO(%c2)"
  22068. + [(set_attr "type" "fast")])
  22069. +
  22070. +(define_insn_and_split "*set_si_symbol_global"
  22071. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22072. + (match_operand:SI 1 "metag_symglobal_op" ""))]
  22073. + "!METAG_FLAG_PIC"
  22074. + "#"
  22075. + "&& SPLIT_HI_LO_SUM_EARLY"
  22076. + [(set (match_dup 0)
  22077. + (high:SI (match_dup 1)))
  22078. + (set (match_dup 0)
  22079. + (lo_sum:SI (match_dup 0)
  22080. + (match_dup 1)))]
  22081. + ""
  22082. + [(set_attr "type" "two")])
  22083. +
  22084. +(define_insn "*set_si_symbol_small"
  22085. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22086. + (match_operand:SI 1 "metag_symsmall_op" ""))]
  22087. + "OG_ENABLED"
  22088. + "GETD\\t%0, [A1GbP+#OGA(%c1)]\\t%@ (*set si r-ssym OK)"
  22089. + [(set_attr "type" "load")])
  22090. +
  22091. +(define_insn "*set_si_symbol_off_small"
  22092. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22093. + (const:SI (plus:SI (match_operand:SI 1 "metag_symsmall_op" "")
  22094. + (match_operand:SI 2 "const_int_operand" ""))))]
  22095. + "OG_ENABLED"
  22096. + "GETD\\t%0, [A1GbP+#OGA(%c1+%c2)]\\t%@ (*set si r-ssym OK)"
  22097. + [(set_attr "type" "load")])
  22098. +
  22099. +(define_insn "*add_si_HI_symbol_off_pic"
  22100. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22101. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22102. + (high:SI (const
  22103. + (plus:SI (unspec [(match_operand:SI 2 "symbolic_operand" "")] UNSPEC_GOTOFF)
  22104. + (match_operand:SI 3 "const_int_operand" ""))))))]
  22105. + "METAG_FLAG_PIC"
  22106. + "ADDT\\t%0, %1, #HI(%c2@GOTOFF+%c3)"
  22107. + [(set_attr "type" "fast")])
  22108. +
  22109. +(define_insn "*mov_si_HI_symbol_off_pic"
  22110. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22111. + (high:SI (const
  22112. + (plus:SI (unspec [(match_operand:SI 1 "symbolic_operand" "")] UNSPEC_GOTOFF)
  22113. + (match_operand:SI 2 "const_int_operand" "")))))]
  22114. + "METAG_FLAG_PIC"
  22115. + "MOVT\\t%0, #HI(%c1@GOTOFF+%c2)"
  22116. + [(set_attr "type" "fast")])
  22117. +
  22118. +(define_insn "*add_si_LO_symbol_off_pic"
  22119. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22120. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22121. + (const
  22122. + (plus:SI (unspec [(match_operand:SI 2 "symbolic_operand" "")] UNSPEC_GOTOFF)
  22123. + (match_operand:SI 3 "const_int_operand" "")))))]
  22124. + "METAG_FLAG_PIC"
  22125. + "ADD\\t%0, %1, #LO(%c2@GOTOFF+%c3)"
  22126. + [(set_attr "type" "fast")])
  22127. +
  22128. +(define_insn_and_split "*set_si_symbol_off_pic"
  22129. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  22130. + (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  22131. + (const
  22132. + (plus:SI (unspec [(match_operand:SI 2 "symbolic_operand" "")] UNSPEC_GOTOFF)
  22133. + (match_operand:SI 3 "const_int_operand" "")))))]
  22134. + "METAG_FLAG_PIC&& operands[1] == pic_offset_table_rtx"
  22135. + "#"
  22136. + "&& SPLIT_HI_LO_SUM_EARLY"
  22137. + [(set (match_dup 0)
  22138. + (match_dup 1))
  22139. + (set (match_dup 0)
  22140. + (plus:SI (match_dup 0)
  22141. + (high:SI (const
  22142. + (plus:SI (unspec [(match_dup 2)] UNSPEC_GOTOFF)
  22143. + (match_dup 3))))))
  22144. + (set (match_dup 0)
  22145. + (lo_sum:SI (match_dup 0)
  22146. + (const
  22147. + (plus:SI (unspec [(match_dup 2)] UNSPEC_GOTOFF)
  22148. + (match_dup 3)))))]
  22149. + ""
  22150. + [(set_attr "type" "three")])
  22151. +
  22152. +(define_insn_and_split "*set_si_symbol_off_pic_val"
  22153. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  22154. + (const
  22155. + (plus:SI (unspec [(match_operand:SI 1 "symbolic_operand" "")] UNSPEC_GOTOFF)
  22156. + (match_operand:SI 2 "const_int_operand" ""))))]
  22157. + "METAG_FLAG_PIC"
  22158. + "#"
  22159. + "&& SPLIT_HI_LO_SUM_EARLY"
  22160. + [(set (match_dup 0)
  22161. + (high:SI (const
  22162. + (plus:SI (unspec [(match_dup 1)] UNSPEC_GOTOFF)
  22163. + (match_dup 2)))))
  22164. + (set (match_dup 0)
  22165. + (lo_sum:SI (match_dup 0)
  22166. + (const
  22167. + (plus:SI (unspec [(match_dup 1)] UNSPEC_GOTOFF)
  22168. + (match_dup 2)))))]
  22169. + ""
  22170. + [(set_attr "type" "two")])
  22171. +
  22172. +(define_insn "*add_si_HI_symbol_off_large"
  22173. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22174. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22175. + (high:SI (const:SI (plus:SI (match_operand:SI 2 "metag_symlarge_op" "")
  22176. + (match_operand:SI 3 "const_int_operand" ""))))))]
  22177. + "OG_ENABLED"
  22178. + "ADDT\\t%0, %1, #HI(OG(%c2+%c3))"
  22179. + [(set_attr "type" "fast")])
  22180. +
  22181. +(define_insn "*add_si_LO_symbol_off_large"
  22182. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22183. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22184. + (const:SI (plus:SI (match_operand:SI 2 "metag_symlarge_op" "")
  22185. + (match_operand:SI 3 "const_int_operand" "")))))]
  22186. + "OG_ENABLED"
  22187. + "ADD\\t%0, %1, #LO(OG(%c2+%c3))"
  22188. + [(set_attr "type" "fast")])
  22189. +
  22190. +(define_insn_and_split "*set_si_symbol_off_large"
  22191. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=l,!da")
  22192. + (const:SI (plus:SI (match_operand:SI 1 "metag_symlarge_op" "")
  22193. + (match_operand:SI 2 "const_int_operand" ""))))]
  22194. + "OG_ENABLED"
  22195. + "#"
  22196. + "&& SPLIT_HI_LO_SUM_EARLY"
  22197. + [(set (match_dup 0)
  22198. + (match_dup 3))
  22199. + (set (match_dup 0)
  22200. + (plus:SI (match_dup 0)
  22201. + (high:SI (match_dup 4))))
  22202. + (set (match_dup 0)
  22203. + (lo_sum:SI (match_dup 0)
  22204. + (match_dup 4)))]
  22205. + {
  22206. + operands[3] = gen_rtx_REG (SImode, A1GbP_REG);
  22207. + operands[4] = gen_rtx_CONST (SImode,
  22208. + gen_rtx_PLUS (SImode,
  22209. + operands[1],
  22210. + operands[2]));
  22211. + }
  22212. + [(set_attr "type" "three,four")])
  22213. +
  22214. +(define_insn "*set_si_HI_symbol_off_global"
  22215. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22216. + (high:SI (const:SI (plus:SI (match_operand:SI 1 "metag_symglobal_op" "")
  22217. + (match_operand:SI 2 "const_int_operand" "")))))]
  22218. + "!METAG_FLAG_PIC"
  22219. + "MOVT\\t%0,#HI(%c1+%c2)"
  22220. + [(set_attr "type" "fast")])
  22221. +
  22222. +(define_insn "*add_si_LO_symbol_off_global"
  22223. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22224. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22225. + (const:SI (plus:SI (match_operand:SI 2 "metag_symglobal_op" "" )
  22226. + (match_operand:SI 3 "const_int_operand" "" )))))]
  22227. + "!METAG_FLAG_PIC"
  22228. + "ADD\\t%0, %1, #LO(%c2+%c3)"
  22229. + [(set_attr "type" "fast")])
  22230. +
  22231. +(define_insn_and_split "*set_si_symbol_off_global"
  22232. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22233. + (const:SI (plus:SI (match_operand:SI 1 "metag_symglobal_op" "")
  22234. + (match_operand:SI 2 "const_int_operand" ""))))]
  22235. + "!METAG_FLAG_PIC"
  22236. + "#"
  22237. + "&& SPLIT_HI_LO_SUM_EARLY"
  22238. + [(set (match_dup 0)
  22239. + (high:SI (match_dup 3)))
  22240. + (set (match_dup 0)
  22241. + (lo_sum:SI (match_dup 0)
  22242. + (match_dup 3)))]
  22243. + {
  22244. + operands[3] = gen_rtx_CONST (SImode,
  22245. + gen_rtx_PLUS (SImode,
  22246. + operands[1],
  22247. + operands[2]));
  22248. + }
  22249. + [(set_attr "type" "two")])
  22250. +
  22251. +;; movsi - code address to register sets
  22252. +(define_insn "*set_si_HI_label"
  22253. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22254. + (high:SI (match_operand:SI 1 "code_address" "")))]
  22255. + "!METAG_FLAG_PIC"
  22256. + "MOVT\\t%0,#HI(%c1)"
  22257. + [(set_attr "type" "fast")])
  22258. +
  22259. +(define_insn "*add_si_LO_label"
  22260. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22261. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22262. + (match_operand:SI 2 "code_address" "" )))]
  22263. + "!METAG_FLAG_PIC"
  22264. + "ADD\\t%0, %1, #LO(%c2)"
  22265. + [(set_attr "type" "fast")])
  22266. +
  22267. +(define_insn_and_split "*set_si_label"
  22268. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22269. + (match_operand:SI 1 "code_address" ""))]
  22270. + "!METAG_FLAG_PIC"
  22271. + "#"
  22272. + "&& SPLIT_HI_LO_SUM_EARLY"
  22273. + [(set (match_dup 0)
  22274. + (high:SI (match_dup 1)))
  22275. + (set (match_dup 0)
  22276. + (lo_sum:SI (match_dup 0)
  22277. + (match_dup 1)))]
  22278. + ""
  22279. + [(set_attr "type" "two")])
  22280. +
  22281. +(define_insn "*set_si_HI_label_off"
  22282. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22283. + (high:SI (const:SI (plus:SI (match_operand:SI 1 "code_address" "")
  22284. + (match_operand:SI 2 "const_int_operand" "")))))]
  22285. + "!METAG_FLAG_PIC"
  22286. + "MOVT\\t%0,#HI(%c1+%c2)"
  22287. + [(set_attr "type" "fast")])
  22288. +
  22289. +(define_insn "*add_si_LO_label_off"
  22290. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22291. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22292. + (const:SI (plus:SI (match_operand:SI 2 "code_address" "" )
  22293. + (match_operand:SI 3 "const_int_operand" "" )))))]
  22294. + "!METAG_FLAG_PIC"
  22295. + "ADD\\t%0, %1, #LO(%c2+%c3)"
  22296. + [(set_attr "type" "fast")])
  22297. +
  22298. +(define_insn_and_split "*set_si_label_off"
  22299. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22300. + (const:SI (plus:SI (match_operand:SI 1 "code_address" "")
  22301. + (match_operand:SI 2 "const_int_operand" ""))))]
  22302. + "!METAG_FLAG_PIC"
  22303. + "#"
  22304. + "&& SPLIT_HI_LO_SUM_EARLY"
  22305. + [(set (match_dup 0)
  22306. + (high:SI (match_dup 3)))
  22307. + (set (match_dup 0)
  22308. + (lo_sum:SI (match_dup 0)
  22309. + (match_dup 3)))]
  22310. + {
  22311. + operands[3] = gen_rtx_CONST (SImode,
  22312. + gen_rtx_PLUS (SImode,
  22313. + operands[1],
  22314. + operands[2]));
  22315. + }
  22316. + [(set_attr "type" "two")])
  22317. +
  22318. +(define_insn "*add_si_HI_label_pic"
  22319. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22320. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22321. + (high:SI (const (unspec [(label_ref:SI (match_operand 2 "" ""))] UNSPEC_GOTOFF)))))]
  22322. + "METAG_FLAG_PIC"
  22323. + "ADDT\\t%0, %0, #HI(%c2@GOTOFF)"
  22324. + [(set_attr "type" "fast")])
  22325. +
  22326. +(define_insn "*mov_si_HI_label_pic"
  22327. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22328. + (high:SI (const (unspec [(label_ref:SI (match_operand 1 "" ""))] UNSPEC_GOTOFF))))]
  22329. + "METAG_FLAG_PIC"
  22330. + "MOVT\\t%0, #HI(%c1@GOTOFF)"
  22331. + [(set_attr "type" "fast")])
  22332. +
  22333. +(define_insn "*add_si_LO_label_pic"
  22334. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22335. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22336. + (const (unspec [(label_ref:SI (match_operand 2 "" ""))] UNSPEC_GOTOFF))))]
  22337. + "METAG_FLAG_PIC"
  22338. + "ADD\\t%0, %0, #LO(%c2@GOTOFF)"
  22339. + [(set_attr "type" "fast")])
  22340. +
  22341. +(define_insn_and_split "*set_si_label_pic"
  22342. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  22343. + (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  22344. + (const (unspec [(label_ref:SI (match_operand 2 "" ""))] UNSPEC_GOTOFF))))]
  22345. + "METAG_FLAG_PIC&& operands[1] == pic_offset_table_rtx"
  22346. + "#"
  22347. + "&& SPLIT_HI_LO_SUM_EARLY"
  22348. + [(set (match_dup 0)
  22349. + (match_dup 1))
  22350. + (set (match_dup 0)
  22351. + (plus:SI (match_dup 0)
  22352. + (high:SI (const (unspec [(label_ref:SI (match_dup 2))] UNSPEC_GOTOFF)))))
  22353. + (set (match_dup 0)
  22354. + (lo_sum:SI (match_dup 0)
  22355. + (const (unspec [(label_ref:SI (match_dup 2))] UNSPEC_GOTOFF))))]
  22356. + ""
  22357. + [(set_attr "type" "three")])
  22358. +
  22359. +(define_insn_and_split "*set_si_label_pic_val"
  22360. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  22361. + (const (unspec [(label_ref:SI (match_operand 1 "" ""))] UNSPEC_GOTOFF)))]
  22362. + "METAG_FLAG_PIC"
  22363. + "#"
  22364. + "&& SPLIT_HI_LO_SUM_EARLY"
  22365. + [(set (match_dup 0)
  22366. + (high:SI (const (unspec [(label_ref:SI (match_dup 1))] UNSPEC_GOTOFF))))
  22367. + (set (match_dup 0)
  22368. + (lo_sum:SI (match_dup 0)
  22369. + (const (unspec [(label_ref:SI (match_dup 1))] UNSPEC_GOTOFF))))]
  22370. + ""
  22371. + [(set_attr "type" "two")])
  22372. +
  22373. +(define_insn "*add_si_HI_label_off_pic"
  22374. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22375. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22376. + (high:SI (const
  22377. + (plus:SI (unspec [(label_ref:SI (match_operand 2 "" ""))] UNSPEC_GOTOFF)
  22378. + (match_operand:SI 3 "const_int_operand" ""))))))]
  22379. + "METAG_FLAG_PIC"
  22380. + "ADDT\\t%0, %1, #HI(%c2@GOTOFF+%c3)"
  22381. + [(set_attr "type" "fast")])
  22382. +
  22383. +(define_insn "*mov_si_HI_label_off_pic"
  22384. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22385. + (high:SI (const
  22386. + (plus:SI (unspec [(label_ref:SI (match_operand 1 "" ""))] UNSPEC_GOTOFF)
  22387. + (match_operand:SI 2 "const_int_operand" "")))))]
  22388. + "METAG_FLAG_PIC"
  22389. + "MOVT\\t%0, #HI(%c1@GOTOFF+%c2)"
  22390. + [(set_attr "type" "fast")])
  22391. +
  22392. +(define_insn "*add_si_LO_label_off_pic"
  22393. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22394. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  22395. + (const
  22396. + (plus:SI (unspec [(label_ref:SI (match_operand 2 "" ""))] UNSPEC_GOTOFF)
  22397. + (match_operand:SI 3 "const_int_operand" "")))))]
  22398. + "METAG_FLAG_PIC"
  22399. + "ADD\\t%0, %0, #LO(%c2@GOTOFF+%c3)"
  22400. + [(set_attr "type" "fast")])
  22401. +
  22402. +(define_insn_and_split "*set_si_label_off_pic"
  22403. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  22404. + (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  22405. + (const
  22406. + (plus:SI (unspec [(label_ref:SI (match_operand 2 "" ""))] UNSPEC_GOTOFF)
  22407. + (match_operand:SI 3 "const_int_operand" "")))))]
  22408. + "METAG_FLAG_PIC"
  22409. + "#"
  22410. + "&& SPLIT_HI_LO_SUM_EARLY"
  22411. + [(set (match_dup 0)
  22412. + (match_dup 1))
  22413. + (set (match_dup 0)
  22414. + (plus:SI (match_dup 0)
  22415. + (high:SI (const
  22416. + (plus:SI (unspec [(label_ref:SI (match_dup 2))] UNSPEC_GOTOFF)
  22417. + (match_dup 3))))))
  22418. + (set (match_dup 0)
  22419. + (lo_sum:SI (match_dup 0)
  22420. + (const
  22421. + (plus:SI (unspec [(label_ref:SI (match_dup 2))] UNSPEC_GOTOFF)
  22422. + (match_dup 3)))))]
  22423. + ""
  22424. + [(set_attr "type" "three")])
  22425. +
  22426. +(define_insn_and_split "*set_si_label_off_pic_val"
  22427. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=&da")
  22428. + (const
  22429. + (plus:SI (unspec [(label_ref:SI (match_operand 1 "" ""))] UNSPEC_GOTOFF)
  22430. + (match_operand:SI 2 "const_int_operand" ""))))]
  22431. + "METAG_FLAG_PIC"
  22432. + "#"
  22433. + "&& SPLIT_HI_LO_SUM_EARLY"
  22434. + [(set (match_dup 0)
  22435. + (high:SI (const
  22436. + (plus:SI (unspec [(label_ref:SI (match_dup 1))] UNSPEC_GOTOFF)
  22437. + (match_dup 2)))))
  22438. + (set (match_dup 0)
  22439. + (lo_sum:SI (match_dup 0)
  22440. + (const
  22441. + (plus:SI (unspec [(label_ref:SI (match_dup 1))] UNSPEC_GOTOFF)
  22442. + (match_dup 2)))))]
  22443. + ""
  22444. + [(set_attr "type" "two")])
  22445. +
  22446. +;; -----------------------------------------------------------------------------
  22447. +;; | Matching SI store post/pre_inc/dec/modify and emitting ASM |
  22448. +;; | ** These rules MUST come before the put_si_1_1 rule ** |
  22449. +;; -----------------------------------------------------------------------------
  22450. +
  22451. +(define_insn "*sto_si_post_inc"
  22452. + [(set (mem:SI (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22453. + (match_operand:SI 1 "metag_register_op" "cr"))]
  22454. + "TARGET_METAC_1_1"
  22455. + {
  22456. + static const char fmt[] = "F\\tSETD\\t[%0++], %1\\t%@ (*store SI post_inc OK)";
  22457. +
  22458. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  22459. + }
  22460. + [(set_attr "type" "fast")])
  22461. +
  22462. +(define_insn "*sto_si_post_dec"
  22463. + [(set (mem:SI (post_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22464. + (match_operand:SI 1 "metag_register_op" "cr"))]
  22465. + "TARGET_METAC_1_1"
  22466. + {
  22467. + static const char fmt[] = "F\\tSETD\\t[%0--], %1\\t%@ (*store SI post_dec OK)";
  22468. +
  22469. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  22470. + }
  22471. + [(set_attr "type" "fast")])
  22472. +
  22473. +(define_insn "*sto_si_pre_inc"
  22474. + [(set (mem:SI (pre_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22475. + (match_operand:SI 1 "metag_register_op" "cr"))]
  22476. + "TARGET_METAC_1_1"
  22477. + {
  22478. + static const char fmt[] = "F\\tSETD\\t[++%0], %1\\t%@ (*store SI pre_inc OK)";
  22479. +
  22480. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  22481. + }
  22482. + [(set_attr "type" "fast")])
  22483. +
  22484. +(define_insn "*sto_si_pre_dec"
  22485. + [(set (mem:SI (pre_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22486. + (match_operand:SI 1 "metag_register_op" "cr"))]
  22487. + "TARGET_METAC_1_1"
  22488. + {
  22489. + static const char fmt[] = "F\\tSETD\\t[--%0], %1\\t%@ (*store SI pre_dec OK)";
  22490. +
  22491. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  22492. + }
  22493. + [(set_attr "type" "fast")])
  22494. +
  22495. +(define_insn "*sto_si_post_modify_disp"
  22496. + [(set (mem:SI (post_modify:SI
  22497. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  22498. + (plus:SI (match_dup 0)
  22499. + (match_operand:SI 1 "metag_offset6_si" "O4,O4,O4,O4"))))
  22500. + (match_operand:SI 2 "metag_register_op" "t, u, y, z"))]
  22501. + "!TARGET_METAC_1_1"
  22502. + "SETD\\t[%0+%1++], %2\\t%@ (*store SI post_modify_disp OK)"
  22503. + [(set_attr "type" "fast")])
  22504. +
  22505. +(define_insn "*sto_si_post_modify_disp_1_1"
  22506. + [(set (mem:SI (post_modify:SI
  22507. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  22508. + (plus:SI (match_dup 0)
  22509. + (match_operand:SI 1 "metag_offset6_si" "O4"))))
  22510. + (match_operand:SI 2 "metag_register_op" "cr"))]
  22511. + "TARGET_METAC_1_1"
  22512. + {
  22513. + static const char fmt[] = "F\\tSETD\\t[%0+%1++], %2\\t%@ (*store SI post_modify_disp OK)";
  22514. +
  22515. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  22516. + }
  22517. + [(set_attr "type" "fast")])
  22518. +
  22519. +(define_insn "*sto_si_post_modify_reg"
  22520. + [(set (mem:SI (post_modify:SI
  22521. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  22522. + (plus:SI (match_dup 0)
  22523. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  22524. + (match_operand:SI 2 "metag_register_op" "ct,cu,cy,cz"))]
  22525. + "TARGET_METAC_1_1"
  22526. + {
  22527. + static const char fmt[] = "F\\tSETD\\t[%0+%1++], %2\\t%@ (*store SI post_modify_reg OK)";
  22528. +
  22529. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  22530. + }
  22531. + [(set_attr "type" "fast")])
  22532. +
  22533. +(define_insn "*sto_si_pre_modify_disp"
  22534. + [(set (mem:SI (pre_modify:SI
  22535. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  22536. + (plus:SI (match_dup 0)
  22537. + (match_operand:SI 1 "metag_offset6_si" "O4,O4,O4,O4"))))
  22538. + (match_operand:SI 2 "metag_reg_nofloat_op" "t, u, y, z"))]
  22539. + "!TARGET_METAC_1_1"
  22540. + "SETD\\t[%0++%1], %2\\t%@ (*store SI pre_modify_disp OK)"
  22541. + [(set_attr "type" "fast,fast,fast,fast")])
  22542. +
  22543. +(define_insn "*sto_si_pre_modify_disp_1_1"
  22544. + [(set (mem:SI (pre_modify:SI
  22545. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  22546. + (plus:SI (match_dup 0)
  22547. + (match_operand:SI 1 "metag_offset6_si" "O4"))))
  22548. + (match_operand:SI 2 "metag_register_op" "cr"))]
  22549. + "TARGET_METAC_1_1"
  22550. + {
  22551. + static const char fmt[] = "F\\tSETD\\t[%0++%1], %2\\t%@ (*store SI pre_modify_disp OK)";
  22552. +
  22553. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  22554. + }
  22555. + [(set_attr "type" "fast")])
  22556. +
  22557. +(define_insn "*sto_si_pre_modify_reg_1_1"
  22558. + [(set (mem:SI (pre_modify:SI
  22559. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  22560. + (plus:SI (match_dup 0)
  22561. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  22562. + (match_operand:SI 2 "metag_register_op" "ct,cu,cy,cz"))]
  22563. + ""
  22564. + {
  22565. + static const char fmt[] = "F\\tSETD\\t[%0++%1], %2\\t%@ (*store SI pre_modify_reg OK)";
  22566. +
  22567. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  22568. + }
  22569. + [(set_attr "type" "fast")])
  22570. +
  22571. +;; -----------------------------------------------------------------------------
  22572. +
  22573. +;; -----------------------------------------------------------------------------
  22574. +;; | Non-side effecting base+offset store SI and catchall store SI cases |
  22575. +;; -----------------------------------------------------------------------------
  22576. +
  22577. +;; movsi - base+index register to memory (stors's)
  22578. +(define_insn "*sto_si_mar"
  22579. + [(set (mem:SI (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "%e, f, h, l")
  22580. + (match_operand:SI 1 "metag_regnofrm_op" " e, f, h, l")))
  22581. + (match_operand:SI 2 "metag_register_op" "ct,cu,cy,cz"))]
  22582. + ""
  22583. + {
  22584. + static const char fmt[] = "F\\tSETD\\t[%0+%1], %2\\t%@ (*sto si mar OK)";
  22585. +
  22586. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  22587. + }
  22588. + [(set_attr "type" "fast")
  22589. + (set_attr "length" "4,4,4,4")])
  22590. +
  22591. +;; movsi - register to memory (stores) some are fast, rest match spillsi below
  22592. +(define_insn "*sto_si_reg_indirect"
  22593. + [(set (mem:SI (match_operand:SI 0 "metag_reg_nofloat_op" "e,f,h,l,!*da"))
  22594. + (match_operand:SI 1 "metag_register_op" "t,u,y,z, *da"))]
  22595. + "TARGET_COND_EXEC_OPTIMIZE && !TARGET_METAC_1_1"
  22596. + "@
  22597. + SETD%?\\t[%0], %1\\t%@ (*sto si [e]t OK)
  22598. + SETD%?\\t[%0], %1\\t%@ (*sto si [f]u OK)
  22599. + SETD%?\\t[%0], %1\\t%@ (*sto si [h]y OK)
  22600. + SETD%?\\t[%0], %1\\t%@ (*sto si [l]z OK)
  22601. + #"
  22602. + [(set_attr "type" "fast,fast,fast,fast,invalid")
  22603. + (set_attr "cond" "yes,yes,yes,yes,no")])
  22604. +
  22605. +(define_insn "*sto_si"
  22606. + [(set (match_operand:SI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  22607. + (match_operand:SI 1 "metag_register_op" "r, t, u, y, z, !*da"))]
  22608. + "!TARGET_METAC_1_1 && !reload_completed"
  22609. + "@
  22610. + SETD\\t%0, %1\\t%@ (*sto si [r]r OK)
  22611. + SETD\\t%0, %1\\t%@ (*sto si [e]t OK)
  22612. + SETD\\t%0, %1\\t%@ (*sto si [f]u OK)
  22613. + SETD\\t%0, %1\\t%@ (*sto si [h]y OK)
  22614. + SETD\\t%0, %1\\t%@ (*sto si [l]z OK)
  22615. + SETD\\t%0, %1\\t%@ (*sto si [m]r OK)"
  22616. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  22617. +
  22618. +(define_insn "*sto_si_postreload"
  22619. + [(set (match_operand:SI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  22620. + (match_operand:SI 1 "metag_register_op" "r, t, u, y, z"))]
  22621. + "!TARGET_METAC_1_1 && reload_completed"
  22622. + "@
  22623. + SETD\\t%0, %1\\t%@ (*sto si [r]r OK)
  22624. + SETD\\t%0, %1\\t%@ (*sto si [e]r OK)
  22625. + SETD\\t%0, %1\\t%@ (*sto si [f]r OK)
  22626. + SETD\\t%0, %1\\t%@ (*sto si [h]r OK)
  22627. + SETD\\t%0, %1\\t%@ (*sto si [l]r OK)"
  22628. + [(set_attr "type" "fast")])
  22629. +
  22630. +;; movsi - all the register to register|memory moves
  22631. +(define_insn "*sto_si_reg_indirect_1_1"
  22632. + [(set (mem:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  22633. + (match_operand:SI 1 "metag_register_op" "cr"))]
  22634. + "TARGET_COND_EXEC_OPTIMIZE && TARGET_METAC_1_1"
  22635. + {
  22636. + static const char fmt[] = "F\\tSETD%?\\t[%0], %1\\t%@ (*sto si [r]r OK)";
  22637. +
  22638. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  22639. + }
  22640. + [(set_attr "type" "fast")
  22641. + (set_attr "cond" "yes")
  22642. + (set_attr "predicable" "yes")])
  22643. +
  22644. +(define_insn "*sto_si_1_1"
  22645. + [(set (match_operand:SI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  22646. + (match_operand:SI 1 "metag_reg_nofloat_op" "r, t, u, y, z, !*da"))]
  22647. + "TARGET_METAC_1_1 && !reload_completed"
  22648. + "@
  22649. + SETD\\t%0, %1\\t%@ (*sto si [r]r OK)
  22650. + SETD\\t%0, %1\\t%@ (*sto si [e]t OK)
  22651. + SETD\\t%0, %1\\t%@ (*sto si [f]u OK)
  22652. + SETD\\t%0, %1\\t%@ (*sto si [h]y OK)
  22653. + SETD\\t%0, %1\\t%@ (*sto si [l]z OK)
  22654. + SETD\\t%0, %1\\t%@ (*sto si [m]r OK)"
  22655. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  22656. +
  22657. +(define_insn "*sto_si_1_1_postreload"
  22658. + [(set (match_operand:SI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  22659. + (match_operand:SI 1 "metag_reg_nofloat_op" "r, t, u, y, z"))]
  22660. + "TARGET_METAC_1_1 && reload_completed"
  22661. + "@
  22662. + SETD\\t%0, %1\\t%@ (*sto si [r]r OK)
  22663. + SETD\\t%0, %1\\t%@ (*sto si [e]t OK)
  22664. + SETD\\t%0, %1\\t%@ (*sto si [f]u OK)
  22665. + SETD\\t%0, %1\\t%@ (*sto si [h]y OK)
  22666. + SETD\\t%0, %1\\t%@ (*sto si [l]z OK)"
  22667. + [(set_attr "type" "fast")])
  22668. +
  22669. +;; spillsi - register to memory (stores) from source/dest in same bank
  22670. +(define_split
  22671. + [(set (match_operand:SI 0 "memory_operand" "")
  22672. + (match_operand:SI 1 "metag_register_op" ""))]
  22673. + "!TARGET_METAC_1_1
  22674. + && reload_completed
  22675. + && metag_slow_store (operands[0], operands[1])"
  22676. + [(set (match_dup 2)
  22677. + (match_dup 1))
  22678. + (set (match_dup 0)
  22679. + (match_dup 2))]
  22680. + {
  22681. + operands[2] = metag_gen_safe_temp (SImode, operands[1]);
  22682. + }
  22683. +)
  22684. +
  22685. +;; -----------------------------------------------------------------------------
  22686. +
  22687. +;; -----------------------------------------------------------------------------
  22688. +;; | Matching SI load post/pre_inc/dec/modify and emitting ASM |
  22689. +;; -----------------------------------------------------------------------------
  22690. +
  22691. +(define_insn "*lod_si_post_inc"
  22692. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  22693. + (mem:SI (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  22694. + "TARGET_METAC_1_1"
  22695. + {
  22696. + static const char fmt[] = "F\\tGETD\\t%0, [%1++]\\t%@ (*load SI post_inc OK)";
  22697. +
  22698. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22699. + }
  22700. + [(set_attr "type" "load")])
  22701. +
  22702. +(define_insn "*lod_si_post_dec"
  22703. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  22704. + (mem:SI (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  22705. + "TARGET_METAC_1_1"
  22706. + {
  22707. + static const char fmt[] = "F\\tGETD\\t%0, [%1--]\\t%@ (*load SI post_dec OK)";
  22708. +
  22709. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22710. + }
  22711. + [(set_attr "type" "load")])
  22712. +
  22713. +(define_insn "*lod_si_pre_inc"
  22714. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  22715. + (mem:SI (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  22716. + "TARGET_METAC_1_1"
  22717. + {
  22718. + static const char fmt[] = "F\\tGETD\\t%0, [++%1]\\t%@ (*load SI pre_inc OK)";
  22719. +
  22720. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22721. + }
  22722. + [(set_attr "type" "load")])
  22723. +
  22724. +(define_insn "*lod_si_pre_dec"
  22725. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  22726. + (mem:SI (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  22727. + "TARGET_METAC_1_1"
  22728. + {
  22729. + static const char fmt[] = "F\\tGETD\\t%0, [--%1]\\t%@ (*load SI pre_dec OK)";
  22730. +
  22731. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22732. + }
  22733. + [(set_attr "type" "load")])
  22734. +
  22735. +(define_insn "*lod_si_post_modify_disp"
  22736. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  22737. + (mem:SI (post_modify:SI
  22738. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  22739. + (plus:SI (match_dup 1)
  22740. + (match_operand:SI 2 "metag_offset6_si" "O4")))))]
  22741. + ""
  22742. + {
  22743. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2++]\\t%@ (*load SI post_modify_disp OK)";
  22744. +
  22745. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22746. + }
  22747. + [(set_attr "type" "load")])
  22748. +
  22749. +(define_insn "*lod_si_post_modify_reg"
  22750. + [(set (match_operand:SI 0 "metag_register_op" "=cr,cr,cr,cr")
  22751. + (mem:SI (post_modify:SI
  22752. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  22753. + (plus:SI (match_dup 1)
  22754. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  22755. + ""
  22756. + {
  22757. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2++]\\t%@ (*load SI post_modify_reg OK)";
  22758. +
  22759. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22760. + }
  22761. + [(set_attr "type" "load")])
  22762. +
  22763. +(define_insn "*lod_si_pre_modify_disp"
  22764. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  22765. + (mem:SI (pre_modify:SI
  22766. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  22767. + (plus:SI (match_dup 1)
  22768. + (match_operand:SI 2 "metag_offset6_si" "O4")))))]
  22769. + ""
  22770. + {
  22771. + static const char fmt[] = "F\\tGETD\\t%0, [%1++%2]\\t%@ (*load SI pre_modify_disp OK)";
  22772. +
  22773. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22774. + }
  22775. + [(set_attr "type" "load")])
  22776. +
  22777. +(define_insn "*lod_si_pre_modify_reg"
  22778. + [(set (match_operand:SI 0 "metag_register_op" "=cr,cr,cr,cr")
  22779. + (mem:SI (pre_modify:SI
  22780. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  22781. + (plus:SI (match_dup 1)
  22782. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  22783. + ""
  22784. + {
  22785. + static const char fmt[] = "F\\tGETD\\t%0, [%1++%2]\\t%@ (*load SI pre_modify_reg OK)";
  22786. +
  22787. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22788. + }
  22789. + [(set_attr "type" "load")])
  22790. +
  22791. +;; -----------------------------------------------------------------------------
  22792. +
  22793. +;; -----------------------------------------------------------------------------
  22794. +;; | Non-side effecting base+offset load SI and catchall load SI |
  22795. +;; -----------------------------------------------------------------------------
  22796. +
  22797. +(define_insn "*lod_si"
  22798. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  22799. + (mem:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")))]
  22800. + ""
  22801. + {
  22802. + static const char fmt[] = "F\\tGETD\\t%0, [%1]";
  22803. +
  22804. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22805. + }
  22806. + [(set_attr "type" "load")])
  22807. +
  22808. +;; movsi - base+index memory to register (loads)
  22809. +(define_insn "*lod_si_rma"
  22810. + [(set (match_operand:SI 0 "metag_register_op" "=cr,cr,cr,cr")
  22811. + (mem:SI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "e, f, h, l")
  22812. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l"))))]
  22813. + ""
  22814. + {
  22815. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2]\\t%@ (*lod si rma OK)";
  22816. +
  22817. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  22818. + }
  22819. + [(set_attr "type" "load")])
  22820. +
  22821. +;; Removed FPC alternative owing to lack of 12bit offset support
  22822. +;; base+12bit load to FX occurs during conversion of virtual_stack_args
  22823. +(define_insn "*lod_si_mem"
  22824. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  22825. + (match_operand:SI 1 "memory_operand" "m"))]
  22826. + ""
  22827. + "GETD\\t%0, %1\\t%@ (*lod si rm OK)"
  22828. + [(set_attr "type" "load")])
  22829. +
  22830. +;; -----------------------------------------------------------------------------
  22831. +
  22832. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  22833. +;; movhi is made up of many parts.. ;;
  22834. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  22835. +(define_expand "movhi"
  22836. + [(set (match_operand:HI 0 "nonimmediate_operand" "")
  22837. + (match_operand:HI 1 "general_operand" ""))]
  22838. + ""
  22839. + {
  22840. + if (MEM_P (operands[0]))
  22841. + {
  22842. + /* All except mem = const or mem = mem can be done quickly */
  22843. + operands[1] = force_reg (HImode, operands[1]);
  22844. + }
  22845. + }
  22846. +)
  22847. +
  22848. +;; movhi - all the register to register moves
  22849. +(define_insn "*mov_hi"
  22850. + [(set (match_operand:HI 0 "metag_register_op" "=e,f,h,l,cx,d, cx,da")
  22851. + (match_operand:HI 1 "metag_register_op" "e,f,h,l,cx,cx,d, da"))]
  22852. + ""
  22853. + "MOV%?\\t%0, %1\\t\\t%@ (*mov hi rr OK)"
  22854. + [(set_attr "type" "fast,fast,fast,fast,fast,slow,slow,slow")
  22855. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes,yes")
  22856. + (set_attr "predicable" "yes")])
  22857. +
  22858. +;; movhi - all the immediate to register sets
  22859. +(define_insn "*set_hi"
  22860. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  22861. + (match_operand:HI 1 "metag_int_operand" "KIP"))]
  22862. + ""
  22863. + "MOV\\t%0, %1\\t\\t%@ (*set hi rI OK)"
  22864. + [(set_attr "type" "fast")])
  22865. +
  22866. +;; -----------------------------------------------------------------------------
  22867. +
  22868. +;; -----------------------------------------------------------------------------
  22869. +;; | Matching HI store post/pre_inc/dec/modify and emitting ASM |
  22870. +;; -----------------------------------------------------------------------------
  22871. +
  22872. +(define_insn "*sto_hi_post_inc"
  22873. + [(set (mem:HI (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22874. + (match_operand:HI 1 "metag_reg_nofloat_op" "da"))]
  22875. + "TARGET_METAC_1_1"
  22876. + "SETW\\t[%0++], %1\\t%@ (*store HI post_inc OK)"
  22877. + [(set_attr "type" "fast")])
  22878. +
  22879. +(define_insn "*sto_hi_post_dec"
  22880. + [(set (mem:HI (post_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22881. + (match_operand:HI 1 "metag_reg_nofloat_op" "da"))]
  22882. + "TARGET_METAC_1_1"
  22883. + "SETW\\t[%0--], %1\\t%@ (*store HI post_dec OK)"
  22884. + [(set_attr "type" "fast")])
  22885. +
  22886. +(define_insn "*sto_hi_pre_inc"
  22887. + [(set (mem:HI (pre_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22888. + (match_operand:HI 1 "metag_reg_nofloat_op" "da"))]
  22889. + "TARGET_METAC_1_1"
  22890. + "SETW\\t[++%0], %1\\t%@ (*store HI pre_inc OK)"
  22891. + [(set_attr "type" "fast")])
  22892. +
  22893. +(define_insn "*sto_hi_pre_dec"
  22894. + [(set (mem:HI (pre_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  22895. + (match_operand:HI 1 "metag_reg_nofloat_op" "da"))]
  22896. + "TARGET_METAC_1_1"
  22897. + "SETW\\t[--%0], %1\\t%@ (*store HI pre_dec OK)"
  22898. + [(set_attr "type" "fast")])
  22899. +
  22900. +(define_insn "*sto_hi_post_modify_disp"
  22901. + [(set (mem:HI (post_modify:SI
  22902. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  22903. + (plus:SI (match_dup 0)
  22904. + (match_operand:SI 1 "metag_offset6_hi" "O2,O2,O2,O2"))))
  22905. + (match_operand:HI 2 "metag_reg_nofloat_op" "t, u, y, z"))]
  22906. + "!TARGET_METAC_1_1"
  22907. + "SETW\\t[%0+%1++], %2\\t%@ (*store HI post_modify_disp OK)"
  22908. + [(set_attr "type" "fast,fast,fast,fast")])
  22909. +
  22910. +(define_insn "*sto_hi_post_modify_disp_1_1"
  22911. + [(set (mem:HI (post_modify:SI
  22912. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  22913. + (plus:SI (match_dup 0)
  22914. + (match_operand:SI 1 "metag_offset6_hi" "O2"))))
  22915. + (match_operand:HI 2 "metag_reg_nofloat_op" "da"))]
  22916. + "TARGET_METAC_1_1"
  22917. + "SETW\\t[%0+%1++], %2\\t%@ (*store HI post_modify_disp OK)"
  22918. + [(set_attr "type" "fast")])
  22919. +
  22920. +(define_insn "*sto_hi_post_modify_reg"
  22921. + [(set (mem:HI (post_modify:SI
  22922. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e,f,h,l")
  22923. + (plus:SI (match_dup 0)
  22924. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,f,h,l"))))
  22925. + (match_operand:HI 2 "metag_reg_nofloat_op" "t,u,y,z"))]
  22926. + ""
  22927. + "SETW\\t[%0+%1++], %2\\t%@ (*store HI post_modify_reg OK)"
  22928. + [(set_attr "type" "fast,fast,fast,fast")])
  22929. +
  22930. +(define_insn "*sto_hi_pre_modify_disp"
  22931. + [(set (mem:HI (pre_modify:SI
  22932. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  22933. + (plus:SI (match_dup 0)
  22934. + (match_operand:SI 1 "metag_offset6_hi" "O2,O2,O2,O2"))))
  22935. + (match_operand:HI 2 "metag_reg_nofloat_op" "t, u, y, z"))]
  22936. + "!TARGET_METAC_1_1"
  22937. + "SETW\\t[%0++%1], %2\\t%@ (*store HI pre_modify_disp OK)"
  22938. + [(set_attr "type" "fast,fast,fast,fast")])
  22939. +
  22940. +(define_insn "*sto_hi_pre_modify_disp_1_1"
  22941. + [(set (mem:HI (pre_modify:SI
  22942. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  22943. + (plus:SI (match_dup 0)
  22944. + (match_operand:SI 1 "metag_offset6_hi" "O2"))))
  22945. + (match_operand:HI 2 "metag_reg_nofloat_op" "da"))]
  22946. + "TARGET_METAC_1_1"
  22947. + "SETW\\t[%0++%1], %2\\t%@ (*store HI pre_modify_disp OK)"
  22948. + [(set_attr "type" "fast")])
  22949. +
  22950. +(define_insn "*sto_hi_pre_modify_reg"
  22951. + [(set (mem:HI (pre_modify:SI
  22952. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e,f,h,l")
  22953. + (plus:SI (match_dup 0)
  22954. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,f,h,l"))))
  22955. + (match_operand:HI 2 "metag_reg_nofloat_op" "t,u,y,z"))]
  22956. + ""
  22957. + "SETW\\t[%0++%1], %2\\t%@ (*store HI pre_modify_reg OK)"
  22958. + [(set_attr "type" "fast,fast,fast,fast")])
  22959. +
  22960. +;; -----------------------------------------------------------------------------
  22961. +
  22962. +;; -----------------------------------------------------------------------------
  22963. +;; | Non-side effecting base+offset store HI and catchall store HI cases |
  22964. +;; -----------------------------------------------------------------------------
  22965. +
  22966. +;; movhi - base+index register to memory (stors's)
  22967. +(define_insn "*sto_hi_mar"
  22968. + [(set (mem:HI (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "%e,f,h,l")
  22969. + (match_operand:SI 1 "metag_regnofrm_op" " e,f,h,l")))
  22970. + (match_operand:HI 2 "metag_reg_nofloat_op" " t,u,y,z"))]
  22971. + ""
  22972. + "SETW\\t[%0+%1], %2\\t%@ (*sto hi mar OK)"
  22973. + [(set_attr "type" "fast")
  22974. + (set_attr "length" "4,4,4,4")])
  22975. +
  22976. +;; movhi - register to memory (stores) some are fast, rest match spillhi below
  22977. +(define_insn "*sto_hi_reg_indirect"
  22978. + [(set (mem:HI (match_operand:SI 0 "metag_reg_nofloat_op" "e,f,h,l,!*da"))
  22979. + (match_operand:HI 1 "metag_reg_nofloat_op" "t,u,y,z, *da"))]
  22980. + "TARGET_COND_EXEC_OPTIMIZE && !TARGET_METAC_1_1"
  22981. + "@
  22982. + SETW%?\\t[%0], %1\\t%@ (*sto hi [e]t OK)
  22983. + SETW%?\\t[%0], %1\\t%@ (*sto hi [f]u OK)
  22984. + SETW%?\\t[%0], %1\\t%@ (*sto hi [h]y OK)
  22985. + SETW%?\\t[%0], %1\\t%@ (*sto hi [l]z OK)
  22986. + #"
  22987. + [(set_attr "type" "fast,fast,fast,fast,invalid")
  22988. + (set_attr "cond" "yes,yes,yes,yes,no")])
  22989. +
  22990. +(define_insn "*sto_hi"
  22991. + [(set (match_operand:HI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  22992. + (match_operand:HI 1 "metag_reg_nofloat_op" "r, t, u, y, z, !*da"))]
  22993. + "!TARGET_METAC_1_1 && !reload_completed"
  22994. + "@
  22995. + SETW\\t%0, %1\\t%@ (*sto hi [r]r OK)
  22996. + SETW\\t%0, %1\\t%@ (*sto hi [e]t OK)
  22997. + SETW\\t%0, %1\\t%@ (*sto hi [f]u OK)
  22998. + SETW\\t%0, %1\\t%@ (*sto hi [h]y OK)
  22999. + SETW\\t%0, %1\\t%@ (*sto hi [l]z OK)
  23000. + SETW\\t%0, %1\\t%@ (*sto hi [m]r OK)"
  23001. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  23002. +
  23003. +(define_insn "*sto_hi_postreload"
  23004. + [(set (match_operand:HI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  23005. + (match_operand:HI 1 "metag_reg_nofloat_op" "r, t, u, y, z"))]
  23006. + "!TARGET_METAC_1_1 && reload_completed"
  23007. + "@
  23008. + SETW\\t%0, %1\\t%@ (*sto hi [r]r OK)
  23009. + SETW\\t%0, %1\\t%@ (*sto hi [e]t OK)
  23010. + SETW\\t%0, %1\\t%@ (*sto hi [f]u OK)
  23011. + SETW\\t%0, %1\\t%@ (*sto hi [h]y OK)
  23012. + SETW\\t%0, %1\\t%@ (*sto hi [l]z OK)"
  23013. + [(set_attr "type" "fast")])
  23014. +
  23015. +(define_insn "*sto_hi_reg_indirect_1_1"
  23016. + [(set (mem:HI (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  23017. + (match_operand:HI 1 "metag_reg_nofloat_op" "da"))]
  23018. + "TARGET_COND_EXEC_OPTIMIZE && TARGET_METAC_1_1"
  23019. + "SETW%?\\t[%0], %1\\t%@ (*sto hi [r]r OK)"
  23020. + [(set_attr "type" "fast")
  23021. + (set_attr "cond" "yes")
  23022. + (set_attr "predicable" "yes")])
  23023. +
  23024. +(define_insn "*sto_hi_1_1_off12"
  23025. + [(set (mem:HI (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "da,Yr")
  23026. + (match_operand:SI 1 "metag_offset12_hi" "O2,Z2")))
  23027. + (match_operand:HI 2 "metag_reg_nofloat_op" "da,da"))]
  23028. + "TARGET_METAC_1_1"
  23029. + "SETW\\t[%0+%1], %2"
  23030. + [(set_attr "type" "fast")])
  23031. +
  23032. +(define_insn "*sto_hi_1_1_off6"
  23033. + [(set (mem:HI (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  23034. + (match_operand:SI 1 "metag_offset6_hi" "O2")))
  23035. + (match_operand:HI 2 "metag_reg_nofloat_op" "da"))]
  23036. + "TARGET_METAC_1_1"
  23037. + "SETW\\t[%0+%1], %2"
  23038. + [(set_attr "type" "fast")])
  23039. +
  23040. +(define_insn "*sto_hi_1_1"
  23041. + [(set (match_operand:HI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  23042. + (match_operand:HI 1 "metag_reg_nofloat_op" "r, t, u, y, z, !*da"))]
  23043. + "TARGET_METAC_1_1 && !reload_completed"
  23044. + "@
  23045. + SETW\\t%0, %1\\t%@ (*sto hi [r]r OK)
  23046. + SETW\\t%0, %1\\t%@ (*sto hi [e]r OK)
  23047. + SETW\\t%0, %1\\t%@ (*sto hi [f]r OK)
  23048. + SETW\\t%0, %1\\t%@ (*sto hi [h]r OK)
  23049. + SETW\\t%0, %1\\t%@ (*sto hi [l]r OK)
  23050. + SETW\\t%0, %1\\t%@ (*sto hi [m]r OK)"
  23051. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  23052. +
  23053. +(define_insn "*sto_hi_1_1_postreload"
  23054. + [(set (match_operand:HI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  23055. + (match_operand:HI 1 "metag_reg_nofloat_op" "r, t, u, y, z"))]
  23056. + "TARGET_METAC_1_1 && reload_completed"
  23057. + "@
  23058. + SETW\\t%0, %1\\t%@ (*sto hi [r]r OK)
  23059. + SETW\\t%0, %1\\t%@ (*sto hi [e]r OK)
  23060. + SETW\\t%0, %1\\t%@ (*sto hi [f]r OK)
  23061. + SETW\\t%0, %1\\t%@ (*sto hi [h]r OK)
  23062. + SETW\\t%0, %1\\t%@ (*sto hi [l]r OK)"
  23063. + [(set_attr "type" "fast")])
  23064. +
  23065. +;; spillhi - register to memory (stores) from source/dest in same bank
  23066. +(define_split
  23067. + [(set (match_operand:HI 0 "memory_operand" "")
  23068. + (match_operand:HI 1 "metag_register_op" ""))]
  23069. + "!TARGET_METAC_1_1
  23070. + && reload_completed
  23071. + && metag_slow_store (operands[0], operands[1])"
  23072. + [(set (match_dup 2)
  23073. + (match_dup 1))
  23074. + (set (match_dup 0)
  23075. + (match_dup 2))]
  23076. + {
  23077. + operands[2] = metag_gen_safe_temp (HImode, operands[1]);
  23078. + }
  23079. +)
  23080. +
  23081. +;; -----------------------------------------------------------------------------
  23082. +
  23083. +;; -----------------------------------------------------------------------------
  23084. +;; | Matching HI load post/pre_inc/dec/modify and emitting ASM |
  23085. +;; -----------------------------------------------------------------------------
  23086. +
  23087. +(define_insn "*lod_hi_post_inc"
  23088. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23089. + (mem:HI (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23090. + "TARGET_METAC_1_1"
  23091. + "GETW\\t%0, [%1++]\\t%@ (*load HI post_inc OK)"
  23092. + [(set_attr "type" "load")])
  23093. +
  23094. +(define_insn "*lod_hi_post_dec"
  23095. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23096. + (mem:HI (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23097. + "TARGET_METAC_1_1"
  23098. + "GETW\\t%0, [%1--]\\t%@ (*load HI post_dec OK)"
  23099. + [(set_attr "type" "load")])
  23100. +
  23101. +(define_insn "*lod_hi_pre_inc"
  23102. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23103. + (mem:HI (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23104. + "TARGET_METAC_1_1"
  23105. + "GETW\\t%0, [++%1]\\t%@ (*load HI pre_inc OK)"
  23106. + [(set_attr "type" "load")])
  23107. +
  23108. +(define_insn "*lod_hi_pre_dec"
  23109. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23110. + (mem:HI (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23111. + "TARGET_METAC_1_1"
  23112. + "GETW\\t%0, [--%1]\\t%@ (*load HI pre_dec OK)"
  23113. + [(set_attr "type" "load")])
  23114. +
  23115. +(define_insn "*lod_hi_post_modify_disp"
  23116. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23117. + (mem:HI (post_modify:SI
  23118. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  23119. + (plus:SI (match_dup 1)
  23120. + (match_operand:SI 2 "metag_offset6_hi" "O2")))))]
  23121. + ""
  23122. + "GETW\\t%0, [%1+%2++]\\t%@ (*load HI post_modify_disp OK)"
  23123. + [(set_attr "type" "load")])
  23124. +
  23125. +(define_insn "*lod_hi_post_modify_reg"
  23126. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da,da,da,da")
  23127. + (mem:HI (post_modify:SI
  23128. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  23129. + (plus:SI (match_dup 1)
  23130. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  23131. + ""
  23132. + "GETW\\t%0, [%1+%2++]\\t%@ (*load HI post_modify_reg OK)"
  23133. + [(set_attr "type" "load")])
  23134. +
  23135. +(define_insn "*lod_hi_pre_modify_disp"
  23136. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23137. + (mem:HI (pre_modify:SI
  23138. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  23139. + (plus:SI (match_dup 1)
  23140. + (match_operand:SI 2 "metag_offset6_hi" "O2")))))]
  23141. + ""
  23142. + "GETW\\t%0, [%1++%2]\\t%@ (*load HI pre_modify_disp OK)"
  23143. + [(set_attr "type" "load")])
  23144. +
  23145. +(define_insn "*lod_hi_pre_modify_reg"
  23146. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da,da,da,da")
  23147. + (mem:HI (pre_modify:SI
  23148. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e,f,h,l")
  23149. + (plus:SI (match_dup 1)
  23150. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,h,l")))))]
  23151. + ""
  23152. + "GETW\\t%0, [%1++%2]\\t%@ (*load HI pre_modify_reg OK)"
  23153. + [(set_attr "type" "load")])
  23154. +
  23155. +;; -----------------------------------------------------------------------------
  23156. +
  23157. +;; -----------------------------------------------------------------------------
  23158. +;; | Non-side effecting base+offset load HI and catchall load HI |
  23159. +;; -----------------------------------------------------------------------------
  23160. +
  23161. +(define_insn "*lod_hi"
  23162. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23163. + (mem:HI (match_operand:SI 1 "metag_reg_nofloat_op" "da")))]
  23164. + ""
  23165. + "GETW\\t%0, [%1]\\t%@ (*lod hi rma OK)"
  23166. + [(set_attr "type" "load")])
  23167. +
  23168. +;; movhi - base+index memory to register (loads)
  23169. +(define_insn "*lod_hi_rma"
  23170. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da,da,da,da")
  23171. + (mem:HI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e, f, h, l ")
  23172. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l "))))]
  23173. + ""
  23174. + "GETW\\t%0, [%1+%2]\\t%@ (*lod hi rma OK)"
  23175. + [(set_attr "type" "load")])
  23176. +
  23177. +(define_insn "*lod_hi_off12"
  23178. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da,da")
  23179. + (mem:HI (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "da,Yr")
  23180. + (match_operand:SI 2 "metag_offset12_hi" "O2,Z2"))))]
  23181. + ""
  23182. + "GETW\\t%0, [%1+%2]"
  23183. + [(set_attr "type" "load")])
  23184. +
  23185. +(define_insn "*lod_hi_off"
  23186. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23187. + (mem:HI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  23188. + (match_operand:SI 2 "metag_offset6_hi" "O2"))))]
  23189. + ""
  23190. + "GETW\\t%0, [%1+%2]"
  23191. + [(set_attr "type" "load")])
  23192. +
  23193. +(define_insn "*lod_hi_mem"
  23194. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  23195. + (match_operand:HI 1 "memory_operand" "m"))]
  23196. + ""
  23197. + "GETW\\t%0, %1\\t%@ (*lod hi rm OK)"
  23198. + [(set_attr "type" "load")])
  23199. +
  23200. +;; -----------------------------------------------------------------------------
  23201. +
  23202. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  23203. +;; movqi is made up of many parts.. ;;
  23204. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  23205. +(define_expand "movqi"
  23206. + [(set (match_operand:QI 0 "nonimmediate_operand" "")
  23207. + (match_operand:QI 1 "general_operand" ""))]
  23208. + ""
  23209. + {
  23210. + if (MEM_P (operands[0]))
  23211. + {
  23212. + /* All except mem = const or mem = mem can be done quickly */
  23213. + operands[1] = force_reg (QImode, operands[1]);
  23214. + }
  23215. + }
  23216. +)
  23217. +
  23218. +;; movqi - all the register to register moves
  23219. +(define_insn "*mov_qi"
  23220. + [(set (match_operand:QI 0 "metag_register_op" "=e,f,h,l,cx,cd,?da")
  23221. + (match_operand:QI 1 "metag_register_op" "e,f,h,l,cx,cd,?da"))]
  23222. + ""
  23223. + "MOV%?\\t%0, %1\\t\\t%@ (*mov qi rr OK)"
  23224. + [(set_attr "type" "fast,fast,fast,fast,fast,slow,slow")
  23225. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes")
  23226. + (set_attr "predicable" "yes")])
  23227. +
  23228. +;; movqi - all the immediate to register sets
  23229. +(define_insn "*set_qi"
  23230. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23231. + (match_operand:QI 1 "metag_int_operand" "KP"))]
  23232. + ""
  23233. + "MOV\\t%0, %1\\t\\t%@ (*set qi rI OK)"
  23234. + [(set_attr "type" "fast")])
  23235. +
  23236. +;; -----------------------------------------------------------------------------
  23237. +;; | Matching QI store post/pre_inc/dec/modify and emitting ASM |
  23238. +;; -----------------------------------------------------------------------------
  23239. +
  23240. +(define_insn "*sto_qi_post_inc"
  23241. + [(set (mem:QI (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23242. + (match_operand:QI 1 "metag_reg_nofloat_op" "da"))]
  23243. + "TARGET_METAC_1_1"
  23244. + "SETB\\t[%0++], %1\\t%@ (*store QI post_inc OK)"
  23245. + [(set_attr "type" "fast")])
  23246. +
  23247. +(define_insn "*sto_qi_post_dec"
  23248. + [(set (mem:QI (post_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23249. + (match_operand:QI 1 "metag_reg_nofloat_op" "da"))]
  23250. + "TARGET_METAC_1_1"
  23251. + "SETB\\t[%0--], %1\\t%@ (*store QI post_dec OK)"
  23252. + [(set_attr "type" "fast")])
  23253. +
  23254. +(define_insn "*sto_qi_pre_inc"
  23255. + [(set (mem:QI (pre_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23256. + (match_operand:QI 1 "metag_reg_nofloat_op" "da"))]
  23257. + "TARGET_METAC_1_1"
  23258. + "SETB\\t[++%0], %1\\t%@ (*store QI pre_inc OK)"
  23259. + [(set_attr "type" "fast")])
  23260. +
  23261. +(define_insn "*sto_qi_pre_dec"
  23262. + [(set (mem:QI (pre_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23263. + (match_operand:QI 1 "metag_reg_nofloat_op" "da"))]
  23264. + "TARGET_METAC_1_1"
  23265. + "SETB\\t[--%0], %1\\t%@ (*store QI pre_dec OK)"
  23266. + [(set_attr "type" "fast")])
  23267. +
  23268. +(define_insn "*sto_qi_post_modify_disp"
  23269. + [(set (mem:QI (post_modify:SI
  23270. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  23271. + (plus:SI (match_dup 0)
  23272. + (match_operand:SI 1 "metag_offset6_qi" "O1,O1,O1,O1"))))
  23273. + (match_operand:QI 2 "metag_reg_nofloat_op" "t, u, y, z"))]
  23274. + "!TARGET_METAC_1_1"
  23275. + "SETB\\t[%0+%1++], %2\\t%@ (*store QI post_modify_disp OK)"
  23276. + [(set_attr "type" "fast,fast,fast,fast")])
  23277. +
  23278. +(define_insn "*sto_qi_post_modify_disp_1_1"
  23279. + [(set (mem:QI (post_modify:SI
  23280. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  23281. + (plus:SI (match_dup 0)
  23282. + (match_operand:SI 1 "metag_offset6_qi" "O1"))))
  23283. + (match_operand:QI 2 "metag_reg_nofloat_op" "da"))]
  23284. + "TARGET_METAC_1_1"
  23285. + "SETB\\t[%0+%1++], %2\\t%@ (*store QI post_modify_disp OK)"
  23286. + [(set_attr "type" "fast")])
  23287. +
  23288. +(define_insn "*sto_qi_post_modify_reg"
  23289. + [(set (mem:QI (post_modify:SI
  23290. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e,f,h,l")
  23291. + (plus:SI (match_dup 0)
  23292. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,f,h,l"))))
  23293. + (match_operand:QI 2 "metag_reg_nofloat_op" "t,u,y,z"))]
  23294. + ""
  23295. + "SETB\\t[%0+%1++], %2\\t%@ (*store QI post_modify_reg OK)"
  23296. + [(set_attr "type" "fast,fast,fast,fast")])
  23297. +
  23298. +(define_insn "*sto_qi_pre_modify_disp"
  23299. + [(set (mem:QI (pre_modify:SI
  23300. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  23301. + (plus:SI (match_dup 0)
  23302. + (match_operand:SI 1 "metag_offset6_qi" "O1,O1,O1,O1"))))
  23303. + (match_operand:QI 2 "metag_reg_nofloat_op" "t, u, y, z"))]
  23304. + "!TARGET_METAC_1_1"
  23305. + "SETB\\t[%0++%1], %2\\t%@ (*store QI pre_modify_disp OK) @2"
  23306. + [(set_attr "type" "fast,fast,fast,fast")])
  23307. +
  23308. +(define_insn "*sto_qi_pre_modify_disp_1_1"
  23309. + [(set (mem:QI (pre_modify:SI
  23310. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  23311. + (plus:SI (match_dup 0)
  23312. + (match_operand:SI 1 "metag_offset6_qi" "O1"))))
  23313. + (match_operand:QI 2 "metag_reg_nofloat_op" "da"))]
  23314. + "TARGET_METAC_1_1"
  23315. + "SETB\\t[%0++%1], %2\\t%@ (*store QI pre_modify_disp OK)"
  23316. + [(set_attr "type" "fast")])
  23317. +
  23318. +(define_insn "*sto_qi_pre_modify_reg"
  23319. + [(set (mem:QI (pre_modify:SI
  23320. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e,f,h,l")
  23321. + (plus:SI (match_dup 0)
  23322. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,f,h,l"))))
  23323. + (match_operand:QI 2 "metag_reg_nofloat_op" "t,u,y,z"))]
  23324. + ""
  23325. + "SETB\\t[%0++%1], %2\\t%@ (*store QI pre_modify_reg OK)"
  23326. + [(set_attr "type" "fast,fast,fast,fast")])
  23327. +
  23328. +;; -----------------------------------------------------------------------------
  23329. +
  23330. +;; -----------------------------------------------------------------------------
  23331. +;; | Non-side effecting base+offset store QI and catchall store QI cases |
  23332. +;; -----------------------------------------------------------------------------
  23333. +
  23334. +;; movqi - base+index register to memory (stors's)
  23335. +(define_insn "*sto_qi_mar"
  23336. + [(set (mem:QI (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "%e,f,h,l")
  23337. + (match_operand:SI 1 "metag_regnofrm_op" " e,f,h,l")))
  23338. + (match_operand:QI 2 "metag_reg_nofloat_op" " t,u,y,z"))]
  23339. + ""
  23340. + "SETB\\t[%0+%1], %2\\t%@ (*sto qi mar OK)"
  23341. + [(set_attr "type" "fast")
  23342. + (set_attr "length" "4,4,4,4")])
  23343. +
  23344. +;; movqi - register to memory (stores) some are fast, rest match spillqi below
  23345. +(define_insn "*sto_qi_reg_indirect"
  23346. + [(set (mem:QI (match_operand:SI 0 "metag_reg_nofloat_op" "e,f,h,l,!*da"))
  23347. + (match_operand:QI 1 "metag_reg_nofloat_op" "t,u,y,z, *da"))]
  23348. + "TARGET_COND_EXEC_OPTIMIZE && !TARGET_METAC_1_1"
  23349. + "@
  23350. + SETB%?\\t[%0], %1\\t%@ (*sto qi [e]t OK)
  23351. + SETB%?\\t[%0], %1\\t%@ (*sto qi [f]u OK)
  23352. + SETB%?\\t[%0], %1\\t%@ (*sto qi [h]y OK)
  23353. + SETB%?\\t[%0], %1\\t%@ (*sto qi [l]z OK)
  23354. + #"
  23355. + [(set_attr "type" "fast,fast,fast,fast,invalid")
  23356. + (set_attr "cond" "yes,yes,yes,yes,no")])
  23357. +
  23358. +(define_insn "*sto_qi"
  23359. + [(set (match_operand:QI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  23360. + (match_operand:QI 1 "metag_reg_nofloat_op" "r, t, u, y, z, !*da"))]
  23361. + "!TARGET_METAC_1_1 && !reload_completed"
  23362. + "@
  23363. + SETB\\t%0, %1\\t%@ (*sto qi [r]r OK)
  23364. + SETB\\t%0, %1\\t%@ (*sto qi [e]r OK)
  23365. + SETB\\t%0, %1\\t%@ (*sto qi [f]r OK)
  23366. + SETB\\t%0, %1\\t%@ (*sto qi [h]r OK)
  23367. + SETB\\t%0, %1\\t%@ (*sto qi [l]r OK)
  23368. + SETB\\t%0, %1\\t%@ (*sto qi [m]r OK)"
  23369. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  23370. +
  23371. +(define_insn "*sto_qi_postreload"
  23372. + [(set (match_operand:QI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  23373. + (match_operand:QI 1 "metag_reg_nofloat_op" "r, t, u, y, z"))]
  23374. + "!TARGET_METAC_1_1 && reload_completed"
  23375. + "@
  23376. + SETB\\t%0, %1\\t%@ (*sto qi [r]r OK)
  23377. + SETB\\t%0, %1\\t%@ (*sto qi [e]r OK)
  23378. + SETB\\t%0, %1\\t%@ (*sto qi [f]r OK)
  23379. + SETB\\t%0, %1\\t%@ (*sto qi [h]r OK)
  23380. + SETB\\t%0, %1\\t%@ (*sto qi [l]r OK)"
  23381. + [(set_attr "type" "fast")])
  23382. +
  23383. +(define_insn "*sto_qi_1_1_reg_indirect"
  23384. + [(set (mem:QI (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  23385. + (match_operand:QI 1 "metag_reg_nofloat_op" "da"))]
  23386. + "TARGET_COND_EXEC_OPTIMIZE && TARGET_METAC_1_1"
  23387. + "SETB%?\\t[%0], %1\\t%@ (*sto qi [r]r OK)"
  23388. + [(set_attr "type" "fast")
  23389. + (set_attr "cond" "yes")
  23390. + (set_attr "predicable" "yes")])
  23391. +
  23392. +(define_insn "*sto_qi_1_1_off12"
  23393. + [(set (mem:QI (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "da,Yr")
  23394. + (match_operand:SI 1 "metag_offset12_qi" "O1,Z1")))
  23395. + (match_operand:QI 2 "metag_reg_nofloat_op" "da,da"))]
  23396. + "TARGET_METAC_1_1"
  23397. + "SETB\\t[%0+%1], %2"
  23398. + [(set_attr "type" "fast")])
  23399. +
  23400. +(define_insn "*sto_qi_1_1_off6"
  23401. + [(set (mem:QI (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  23402. + (match_operand:SI 1 "metag_offset6_qi" "O1")))
  23403. + (match_operand:QI 2 "metag_reg_nofloat_op" "da"))]
  23404. + "TARGET_METAC_1_1"
  23405. + "SETB\\t[%0+%1], %2"
  23406. + [(set_attr "type" "fast")])
  23407. +
  23408. +(define_insn "*sto_qi_1_1"
  23409. + [(set (match_operand:QI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  23410. + (match_operand:QI 1 "metag_reg_nofloat_op" "r, t, u, y, z, !*da"))]
  23411. + "TARGET_METAC_1_1 && !reload_completed"
  23412. + "@
  23413. + SETB\\t%0, %1\\t%@ (*sto qi [r]r OK)
  23414. + SETB\\t%0, %1\\t%@ (*sto qi [e]r OK)
  23415. + SETB\\t%0, %1\\t%@ (*sto qi [f]r OK)
  23416. + SETB\\t%0, %1\\t%@ (*sto qi [h]r OK)
  23417. + SETB\\t%0, %1\\t%@ (*sto qi [l]r OK)
  23418. + SETB\\t%0, %1\\t%@ (*sto qi [m]r OK)"
  23419. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  23420. +
  23421. +(define_insn "*sto_qi_1_1_postreload"
  23422. + [(set (match_operand:QI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  23423. + (match_operand:QI 1 "metag_reg_nofloat_op" "r, t, u, y, z"))]
  23424. + "TARGET_METAC_1_1 && reload_completed"
  23425. + "@
  23426. + SETB\\t%0, %1\\t%@ (*sto qi [r]r OK)
  23427. + SETB\\t%0, %1\\t%@ (*sto qi [e]r OK)
  23428. + SETB\\t%0, %1\\t%@ (*sto qi [f]r OK)
  23429. + SETB\\t%0, %1\\t%@ (*sto qi [h]r OK)
  23430. + SETB\\t%0, %1\\t%@ (*sto qi [l]r OK)"
  23431. + [(set_attr "type" "fast")])
  23432. +
  23433. +;; spillqi - register to memory (stores) from source/dest in same bank
  23434. +(define_split
  23435. + [(set (match_operand:QI 0 "memory_operand" "")
  23436. + (match_operand:QI 1 "metag_register_op" ""))]
  23437. + "!TARGET_METAC_1_1
  23438. + && reload_completed
  23439. + && metag_slow_store (operands[0], operands[1])"
  23440. + [(set (match_dup 2)
  23441. + (match_dup 1))
  23442. + (set (match_dup 0)
  23443. + (match_dup 2))]
  23444. + {
  23445. + operands[2] = metag_gen_safe_temp (QImode, operands[1]);
  23446. + }
  23447. +)
  23448. +
  23449. +;; -----------------------------------------------------------------------------
  23450. +;; | Matching QI load post/pre_inc/dec/modify and emitting ASM |
  23451. +;; -----------------------------------------------------------------------------
  23452. +
  23453. +(define_insn "*lod_qi_post_inc"
  23454. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23455. + (mem:QI (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23456. + "TARGET_METAC_1_1"
  23457. + "GETB\\t%0, [%1++]\\t%@ (*load QI post_inc OK)"
  23458. + [(set_attr "type" "load")])
  23459. +
  23460. +(define_insn "*lod_qi_post_dec"
  23461. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23462. + (mem:QI (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23463. + "TARGET_METAC_1_1"
  23464. + "GETB\\t%0, [%1--]\\t%@ (*load QI post_dec OK)"
  23465. + [(set_attr "type" "load")])
  23466. +
  23467. +(define_insn "*lod_qi_pre_inc"
  23468. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23469. + (mem:QI (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23470. + "TARGET_METAC_1_1"
  23471. + "GETB\\t%0, [++%1]\\t%@ (*load QI pre_inc OK)"
  23472. + [(set_attr "type" "load")])
  23473. +
  23474. +(define_insn "*lod_qi_pre_dec"
  23475. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23476. + (mem:QI (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23477. + "TARGET_METAC_1_1"
  23478. + "GETB\\t%0, [--%1]\\t%@ (*load QI pre_dec OK)"
  23479. + [(set_attr "type" "load")])
  23480. +
  23481. +(define_insn "*lod_qi_post_modify_disp"
  23482. + [(set (match_operand:QI 0 "metag_register_op" "=da")
  23483. + (mem:QI (post_modify:SI
  23484. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  23485. + (plus:SI (match_dup 1)
  23486. + (match_operand:SI 2 "metag_offset6_qi" "O1")))))]
  23487. + ""
  23488. + "GETB\\t%0, [%1+%2++]\\t%@ (*load QI post_modify_disp OK)"
  23489. + [(set_attr "type" "load")])
  23490. +
  23491. +(define_insn "*lod_qi_post_modify_reg"
  23492. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da,da,da,da")
  23493. + (mem:QI (post_modify:SI
  23494. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  23495. + (plus:SI (match_dup 1)
  23496. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  23497. + ""
  23498. + "GETB\\t%0, [%1+%2++]\\t%@ (*load QI post_modify_reg OK)"
  23499. + [(set_attr "type" "load")])
  23500. +
  23501. +(define_insn "*lod_qi_pre_modify_disp"
  23502. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23503. + (mem:QI (pre_modify:SI
  23504. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  23505. + (plus:SI (match_dup 1)
  23506. + (match_operand:SI 2 "metag_offset6_qi" "O1")))))]
  23507. + ""
  23508. + "GETB\\t%0, [%1++%2]\\t%@ (*load QI pre_modify_disp OK)"
  23509. + [(set_attr "type" "load")])
  23510. +
  23511. +(define_insn "*lod_qi_pre_modify_reg"
  23512. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da,da,da,da")
  23513. + (mem:QI (pre_modify:SI
  23514. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  23515. + (plus:SI (match_dup 1)
  23516. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  23517. + ""
  23518. + "GETB\\t%0, [%1++%2]\\t%@ (*load QI pre_modify_reg OK)"
  23519. + [(set_attr "type" "load")])
  23520. +
  23521. +;; -----------------------------------------------------------------------------
  23522. +
  23523. +;; -----------------------------------------------------------------------------
  23524. +;; | Non-side effecting base+offset load QI and catchall load QI |
  23525. +;; -----------------------------------------------------------------------------
  23526. +
  23527. +(define_insn "*lod_qi"
  23528. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23529. + (mem:QI (match_operand:SI 1 "metag_reg_nofloat_op" "da")))]
  23530. + ""
  23531. + "GETB\\t%0, [%1]\\t%@ (*lod qi rma OK)"
  23532. + [(set_attr "type" "load")])
  23533. +
  23534. +;; movqi - base+index memory to register (loads)
  23535. +(define_insn "*lod_qi_rma"
  23536. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da,da,da,da")
  23537. + (mem:QI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "e, f, h, l")
  23538. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l"))))]
  23539. + ""
  23540. + "GETB\\t%0, [%1+%2]\\t%@ (*lod qi rma OK)"
  23541. + [(set_attr "type" "load")])
  23542. +
  23543. +(define_insn "*lod_qi_off12"
  23544. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da,da")
  23545. + (mem:QI (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "da,Yr")
  23546. + (match_operand:SI 2 "metag_offset12_qi" "O1,Z1"))))]
  23547. + ""
  23548. + "GETB\\t%0, [%1+%2]"
  23549. + [(set_attr "type" "load")])
  23550. +
  23551. +(define_insn "*lod_qi_off"
  23552. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23553. + (mem:QI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  23554. + (match_operand:SI 2 "metag_offset6_qi" "O1"))))]
  23555. + ""
  23556. + "GETB\\t%0, [%1+%2]"
  23557. + [(set_attr "type" "load")])
  23558. +
  23559. +(define_insn "*lod_qi_mem"
  23560. + [(set (match_operand:QI 0 "metag_reg_nofloat_op" "=da")
  23561. + (match_operand:QI 1 "memory_operand" "m"))]
  23562. + ""
  23563. + "GETB\\t%0, %1"
  23564. + [(set_attr "type" "load")])
  23565. +
  23566. +;; -----------------------------------------------------------------------------
  23567. +
  23568. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  23569. +;; movsf is made up of many parts.. ;;
  23570. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  23571. +(define_expand "movsf"
  23572. + [(set (match_operand:SF 0 "nonimmediate_operand" "")
  23573. + (match_operand:SF 1 "general_operand" ""))]
  23574. + ""
  23575. + {
  23576. + if (MEM_P (operands[0]))
  23577. + {
  23578. + /* All except mem = const or mem = mem can be done quickly */
  23579. + operands[1] = force_reg (SFmode, operands[1]);
  23580. + }
  23581. + }
  23582. +)
  23583. +
  23584. +;; movsf - all the register to register moves
  23585. +(define_insn "*mov_sf"
  23586. + [(set (match_operand:SF 0 "metag_register_op" "=cx,cx,d ,d,a,da")
  23587. + (match_operand:SF 1 "metag_register_op" "cx,d, cx,d,a,da"))]
  23588. + ""
  23589. + "MOV%?\\t%0, %1\\t\\t%@ (*mov sf rr OK)"
  23590. + [(set_attr "type" "fast,slow,slow,fast,fast,slow")
  23591. + (set_attr "cond" "yes")
  23592. + (set_attr "predicable" "yes")])
  23593. +
  23594. +;; movsf - all the immediate to register sets
  23595. +(define_insn_and_split "*set_sf"
  23596. + [(set (match_operand:SF 0 "metag_register_op" "=da,cx")
  23597. + (match_operand:SF 1 "immediate_operand" "i, ci"))]
  23598. + ""
  23599. + "@
  23600. + #
  23601. + F\\tMOV\\t%0,#%h1"
  23602. + "&& reload_completed
  23603. + && (!METAG_FPC_REG_P (REGNO (operands[0]))
  23604. + || !metag_fphalf_imm_op (operands[1], SFmode))"
  23605. + [(const_int 0)]
  23606. + {
  23607. + metag_split_movsf_immediate (operands);
  23608. + DONE;
  23609. + }
  23610. + [(set_attr "type" "two")])
  23611. +
  23612. +;; movsf - register to memory (stores) some are fast, rest match spillsf below
  23613. +(define_insn "*sto_sf_reg_indirect"
  23614. + [(set (mem:SF (match_operand:SI 0 "metag_reg_nofloat_op" "e,f,h,l,!*da"))
  23615. + (match_operand:SF 1 "metag_register_op" "t,u,y,z, *da"))]
  23616. + "TARGET_COND_EXEC_OPTIMIZE && !TARGET_METAC_1_1"
  23617. + "@
  23618. + SETD%?\\t[%0], %1\\t%@ (*sto sf [e]t OK)
  23619. + SETD%?\\t[%0], %1\\t%@ (*sto sf [f]u OK)
  23620. + SETD%?\\t[%0], %1\\t%@ (*sto sf [h]y OK)
  23621. + SETD%?\\t[%0], %1\\t%@ (*sto sf [l]z OK)
  23622. + #"
  23623. + [(set_attr "type" "fast,fast,fast,fast,invalid")
  23624. + (set_attr "cond" "yes,yes,yes,yes,no")])
  23625. +
  23626. +(define_insn "*sto_sf_post_inc"
  23627. + [(set (mem:SF (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23628. + (match_operand:SF 1 "metag_register_op" "cr"))]
  23629. + "TARGET_METAC_1_1"
  23630. + {
  23631. + static const char fmt[] = "F\\tSETD\\t[%0++], %1\\t%@ (*store SF post_inc OK)";
  23632. +
  23633. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  23634. + }
  23635. + [(set_attr "type" "fast")])
  23636. +
  23637. +(define_insn "*sto_sf_post_dec"
  23638. + [(set (mem:SF (post_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23639. + (match_operand:SF 1 "metag_register_op" "cr"))]
  23640. + "TARGET_METAC_1_1"
  23641. + {
  23642. + static const char fmt[] = "F\\tSETD\\t[%0--], %1\\t%@ (*store SF post_dec OK)";
  23643. +
  23644. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  23645. + }
  23646. + [(set_attr "type" "fast")])
  23647. +
  23648. +(define_insn "*sto_sf_pre_inc"
  23649. + [(set (mem:SF (pre_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23650. + (match_operand:SF 1 "metag_register_op" "cr"))]
  23651. + "TARGET_METAC_1_1"
  23652. + {
  23653. + static const char fmt[] = "F\\tSETD\\t[++%0], %1\\t%@ (*store SF pre_inc OK)";
  23654. +
  23655. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  23656. + }
  23657. + [(set_attr "type" "fast")])
  23658. +
  23659. +(define_insn "*sto_sf_pre_dec"
  23660. + [(set (mem:SF (pre_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  23661. + (match_operand:SF 1 "metag_reg_nofloat_op" "cr"))]
  23662. + "TARGET_METAC_1_1"
  23663. + {
  23664. + static const char fmt[] = "F\\tSETD\\t[--%0], %1\\t%@ (*store SF pre_dec OK)";
  23665. +
  23666. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  23667. + }
  23668. + [(set_attr "type" "fast")])
  23669. +
  23670. +(define_insn "*sto_sf_post_modify_disp"
  23671. + [(set (mem:SF (post_modify:SI
  23672. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  23673. + (plus:SI (match_dup 0)
  23674. + (match_operand:SI 1 "metag_offset6_sf" "O4,O4,O4,O4"))))
  23675. + (match_operand:SF 2 "metag_register_op" "t, u, y, z"))]
  23676. + "!TARGET_METAC_1_1"
  23677. + "SETD\\t[%0+%1++], %2\\t%@ (*store SF post_modify_disp OK)"
  23678. + [(set_attr "type" "fast")])
  23679. +
  23680. +(define_insn "*sto_sf_post_modify_disp_1_1"
  23681. + [(set (mem:SF (post_modify:SI
  23682. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  23683. + (plus:SI (match_dup 0)
  23684. + (match_operand:SI 1 "metag_offset6_sf" "O4"))))
  23685. + (match_operand:SF 2 "metag_register_op" "cr"))]
  23686. + "TARGET_METAC_1_1"
  23687. + {
  23688. + static const char fmt[] = "F\\tSETD\\t[%0+%1++], %2\\t%@ (*store SF post_modify_disp OK)";
  23689. +
  23690. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  23691. + }
  23692. + [(set_attr "type" "fast")])
  23693. +
  23694. +(define_insn "*sto_sf_post_modify_reg"
  23695. + [(set (mem:SF (post_modify:SI
  23696. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l ")
  23697. + (plus:SI (match_dup 0)
  23698. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  23699. + (match_operand:SF 2 "metag_register_op" "ct,cu,cy,cz"))]
  23700. + ""
  23701. + {
  23702. + static const char fmt[] = "F\\tSETD\\t[%0+%1++], %2\\t%@ (*store SF post_modify_reg OK)";
  23703. +
  23704. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  23705. + }
  23706. + [(set_attr "type" "fast")])
  23707. +
  23708. +(define_insn "*sto_sf_pre_modify_disp"
  23709. + [(set (mem:SF (pre_modify:SI
  23710. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  23711. + (plus:SI (match_dup 0)
  23712. + (match_operand:SI 1 "metag_offset6_sf" "O4,O4,O4,O4"))))
  23713. + (match_operand:SF 2 "metag_reg_nofloat_op" "t, u, y, z"))]
  23714. + "!TARGET_METAC_1_1"
  23715. + "SETD\\t[%0++%1], %2\\t%@ (*store SF pre_modify_disp OK)"
  23716. + [(set_attr "type" "fast,fast,fast,fast")])
  23717. +
  23718. +(define_insn "*sto_sf_pre_modify_disp_1_1"
  23719. + [(set (mem:SF (pre_modify:SI
  23720. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  23721. + (plus:SI (match_dup 0)
  23722. + (match_operand:SI 1 "metag_offset6_sf" "O4"))))
  23723. + (match_operand:SF 2 "metag_register_op" "cr"))]
  23724. + "TARGET_METAC_1_1"
  23725. + {
  23726. + static const char fmt[] = "F\\tSETD\\t[%0++%1], %2\\t%@ (*store SF pre_modify_disp OK)";
  23727. +
  23728. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  23729. + }
  23730. + [(set_attr "type" "fast")])
  23731. +
  23732. +(define_insn "*sto_sf_pre_modify_reg"
  23733. + [(set (mem:SF (pre_modify:SI
  23734. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  23735. + (plus:SI (match_dup 0)
  23736. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  23737. + (match_operand:SF 2 "metag_register_op" "ct,cu,cy,cz"))]
  23738. + ""
  23739. + {
  23740. + static const char fmt[] = "F\\tSETD\\t[%0++%1], %2\\t%@ (*store SF pre_modify_reg OK)";
  23741. +
  23742. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  23743. + }
  23744. + [(set_attr "type" "fast")])
  23745. +
  23746. +;; -----------------------------------------------------------------------------
  23747. +
  23748. +;; movsf - register to memory (stores) some are fast, rest match spillsf below
  23749. +(define_insn "*sto_sf"
  23750. + [(set (match_operand:SF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  23751. + (match_operand:SF 1 "metag_reg_nofloat_op" "da,t, u, y, z, !*da"))]
  23752. + "!TARGET_METAC_1_1 && !reload_completed"
  23753. + "@
  23754. + SETD\\t%0, %1\\t%@ (*sto sf [r]da OK)
  23755. + SETD\\t%0, %1\\t%@ (*sto sf [e]t OK)
  23756. + SETD\\t%0, %1\\t%@ (*sto sf [f]u OK)
  23757. + SETD\\t%0, %1\\t%@ (*sto sf [h]y OK)
  23758. + SETD\\t%0, %1\\t%@ (*sto sf [l]z OK)
  23759. + SETD\\t%0, %1\\t%@ (*sto sf [m]da OK)"
  23760. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  23761. +
  23762. +(define_insn "*sto_sf_postreload"
  23763. + [(set (match_operand:SF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  23764. + (match_operand:SF 1 "metag_reg_nofloat_op" "da,t, u, y, z"))]
  23765. + "!TARGET_METAC_1_1 && reload_completed"
  23766. + "@
  23767. + SETD\\t%0, %1\\t%@ (*sto sf [r]da OK)
  23768. + SETD\\t%0, %1\\t%@ (*sto sf [e]t OK)
  23769. + SETD\\t%0, %1\\t%@ (*sto sf [f]u OK)
  23770. + SETD\\t%0, %1\\t%@ (*sto sf [h]y OK)
  23771. + SETD\\t%0, %1\\t%@ (*sto sf [l]z OK)"
  23772. + [(set_attr "type" "fast")])
  23773. +
  23774. +(define_insn "*sto_sf_1_1_reg_indirect"
  23775. + [(set (mem:SF (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  23776. + (match_operand:SF 1 "metag_register_op" "cr"))]
  23777. + "TARGET_COND_EXEC_OPTIMIZE && TARGET_METAC_1_1"
  23778. + {
  23779. + static const char fmt[] = "F\\tSETD%?\\t[%0], %1\\t%@ (*sto sf [r]r OK)";
  23780. +
  23781. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  23782. + }
  23783. + [(set_attr "type" "fast")
  23784. + (set_attr "cond" "yes")
  23785. + (set_attr "predicable" "yes")])
  23786. +
  23787. +(define_insn "*sto_sf_1_1_off12"
  23788. + [(set (mem:SF (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "da,Yr")
  23789. + (match_operand:SI 1 "metag_offset12_sf" "O4,Z4")))
  23790. + (match_operand:SF 2 "metag_reg_nofloat_op" "da,da"))]
  23791. + "TARGET_METAC_1_1"
  23792. + "SETD\\t[%0+%1], %2"
  23793. + [(set_attr "type" "fast")])
  23794. +
  23795. +(define_insn "*sto_sf_1_1_off6"
  23796. + [(set (mem:SF (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  23797. + (match_operand:SI 1 "metag_offset6_sf" "O4")))
  23798. + (match_operand:SF 2 "metag_register_op" "cr"))]
  23799. + "TARGET_METAC_1_1"
  23800. + {
  23801. + static const char fmt[] = "F\\tSETD\\t[%0+%1], %2";
  23802. +
  23803. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  23804. + }
  23805. + [(set_attr "type" "fast")])
  23806. +
  23807. +(define_insn "*sto_sf_1_1"
  23808. + [(set (match_operand:SF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  23809. + (match_operand:SF 1 "metag_register_op" "da,t ,u, y, z, !*da"))]
  23810. + "TARGET_METAC_1_1 && !reload_completed"
  23811. + "SETD\\t%0, %1\\t%@ (*sto sf [m]r OK)"
  23812. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  23813. +
  23814. +(define_insn "*sto_sf_1_1_postreload"
  23815. + [(set (match_operand:SF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  23816. + (match_operand:SF 1 "metag_register_op" "da,t, u, y, z"))]
  23817. + "TARGET_METAC_1_1 && reload_completed"
  23818. + "SETD\\t%0, %1\\t%@ (*sto sf [m]r OK)"
  23819. + [(set_attr "type" "fast")])
  23820. +
  23821. +;; spillsf - register to memory (stores) from source/dest in same bank
  23822. +(define_split
  23823. + [(set (match_operand:SF 0 "memory_operand" "")
  23824. + (match_operand:SF 1 "metag_register_op" ""))]
  23825. + "!TARGET_METAC_1_1
  23826. + && reload_completed
  23827. + && metag_slow_store (operands[0], operands[1])"
  23828. + [(set (match_dup 2)
  23829. + (match_dup 1))
  23830. + (set (match_dup 0)
  23831. + (match_dup 2))]
  23832. + {
  23833. + operands[2] = metag_gen_safe_temp (SFmode, operands[1]);
  23834. + }
  23835. +)
  23836. +
  23837. +;; -----------------------------------------------------------------------------
  23838. +;; | Matching SF load post/pre_inc/dec/modify and emitting ASM |
  23839. +;; -----------------------------------------------------------------------------
  23840. +
  23841. +(define_insn "*lod_sf_post_inc"
  23842. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23843. + (mem:SF (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23844. + "TARGET_METAC_1_1"
  23845. + {
  23846. + static const char fmt[] = "F\\tGETD\\t%0, [%1++]\\t%@ (*load SF post_inc OK)";
  23847. +
  23848. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23849. + }
  23850. + [(set_attr "type" "load")])
  23851. +
  23852. +(define_insn "*lod_sf_post_dec"
  23853. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23854. + (mem:SF (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23855. + "TARGET_METAC_1_1"
  23856. + {
  23857. + static const char fmt[] = "F\\tGETD\\t%0, [%1--]\\t%@ (*load SF post_dec OK)";
  23858. +
  23859. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23860. + }
  23861. + [(set_attr "type" "load")])
  23862. +
  23863. +(define_insn "*lod_sf_pre_inc"
  23864. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23865. + (mem:SF (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23866. + "TARGET_METAC_1_1"
  23867. + {
  23868. + static const char fmt[] = "F\\tGETD\\t%0, [++%1]\\t%@ (*load SF pre_inc OK)";
  23869. +
  23870. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23871. + }
  23872. + [(set_attr "type" "load")])
  23873. +
  23874. +(define_insn "*lod_sf_pre_dec"
  23875. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23876. + (mem:SF (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  23877. + "TARGET_METAC_1_1"
  23878. + {
  23879. + static const char fmt[] = "F\\tGETD\\t%0, [--%1]\\t%@ (*load SF pre_dec OK)";
  23880. +
  23881. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23882. + }
  23883. + [(set_attr "type" "load")])
  23884. +
  23885. +(define_insn "*lod_sf_post_modify_disp"
  23886. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23887. + (mem:SF (post_modify:SI
  23888. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  23889. + (plus:SI (match_dup 1)
  23890. + (match_operand:SI 2 "metag_offset6_sf" "O4")))))]
  23891. + ""
  23892. + {
  23893. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2++]\\t%@ (*load SF post_modify_disp OK)";
  23894. +
  23895. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23896. + }
  23897. + [(set_attr "type" "load")])
  23898. +
  23899. +(define_insn "*lod_sf_post_modify_reg"
  23900. + [(set (match_operand:SF 0 "metag_register_op" "=cr,cr,cr,cr")
  23901. + (mem:SF (post_modify:SI
  23902. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  23903. + (plus:SI (match_dup 1)
  23904. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  23905. + ""
  23906. + {
  23907. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2++]\\t%@ (*load SF post_modify_reg OK)";
  23908. +
  23909. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23910. + }
  23911. + [(set_attr "type" "load")])
  23912. +
  23913. +(define_insn "*lod_sf_pre_modify_disp"
  23914. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23915. + (mem:SF (pre_modify:SI
  23916. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  23917. + (plus:SI (match_dup 1)
  23918. + (match_operand:SI 2 "metag_offset6_sf" "O4")))))]
  23919. + ""
  23920. + {
  23921. + static const char fmt[] = "F\\tGETD\\t%0, [%1++%2]\\t%@ (*load SF pre_modify_disp OK)";
  23922. +
  23923. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23924. + }
  23925. + [(set_attr "type" "load")])
  23926. +
  23927. +(define_insn "*lod_sf_pre_modify_reg"
  23928. + [(set (match_operand:SF 0 "metag_register_op" "=cr,cr,cr,cr")
  23929. + (mem:SF (pre_modify:SI
  23930. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  23931. + (plus:SI (match_dup 1)
  23932. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  23933. + ""
  23934. + {
  23935. + static const char fmt[] = "F\\tGETD\\t%0, [%1++%2]\\t%@ (*load SF pre_modify_reg OK)";
  23936. +
  23937. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23938. + }
  23939. + [(set_attr "type" "load")])
  23940. +
  23941. +;; -----------------------------------------------------------------------------
  23942. +
  23943. +;; movsf - memory to register (loads)
  23944. +(define_insn "*lod_sf_rma"
  23945. + [(set (match_operand:SF 0 "metag_register_op" "=cr,cr,cr,cr")
  23946. + (mem:SF (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "e, f, h, l")
  23947. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l"))))]
  23948. + ""
  23949. + {
  23950. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2]";
  23951. +
  23952. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23953. + }
  23954. + [(set_attr "type" "load")])
  23955. +
  23956. +(define_insn "*lod_sf_off12"
  23957. + [(set (match_operand:SF 0 "metag_reg_nofloat_op" "=da,da")
  23958. + (mem:SF (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "da,Yr")
  23959. + (match_operand:SI 2 "metag_offset12_sf" "O4,Z4"))))]
  23960. + ""
  23961. + "GETD\\t%0, [%1+%2]"
  23962. + [(set_attr "type" "load")])
  23963. +
  23964. +(define_insn "*lod_sf_off"
  23965. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23966. + (mem:SF (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  23967. + (match_operand:SI 2 "metag_offset6_sf" "O4"))))]
  23968. + ""
  23969. + {
  23970. + static const char fmt[] = "F\\tGETD\\t%0, [%1+%2]";
  23971. +
  23972. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23973. + }
  23974. + [(set_attr "type" "load")])
  23975. +
  23976. +(define_insn "*lod_sf"
  23977. + [(set (match_operand:SF 0 "metag_register_op" "=cr")
  23978. + (mem:SF (match_operand:SI 1 "metag_reg_nofloat_op" "da")))]
  23979. + ""
  23980. + {
  23981. + static const char fmt[] = "F\\tGETD\\t%0, [%1]";
  23982. +
  23983. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  23984. + }
  23985. + [(set_attr "type" "load")])
  23986. +
  23987. +(define_insn "*lod_sf_mem"
  23988. + [(set (match_operand:SF 0 "metag_reg_nofloat_op" "=da")
  23989. + (match_operand:SF 1 "memory_operand" "m"))]
  23990. + ""
  23991. + "GETD\\t%0, %1\\t%@ (*lod sf rm OK)"
  23992. + [(set_attr "type" "load")])
  23993. +
  23994. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  23995. +;; movdi is made up of many parts.. ;;
  23996. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  23997. +(define_expand "movdi"
  23998. + [(set (match_operand:DI 0 "nonimmediate_operand" "")
  23999. + (match_operand:DI 1 "general_operand" ""))]
  24000. + ""
  24001. + {
  24002. + if (MEM_P (operands[0]))
  24003. + {
  24004. + if (!no_new_pseudos)
  24005. + {
  24006. + /* All except mem = const or mem = mem can be done quickly */
  24007. + operands[1] = force_reg (DImode, operands[1]);
  24008. + }
  24009. + }
  24010. + }
  24011. +)
  24012. +
  24013. +;; movdi - register to register forms
  24014. +(define_insn_and_split "*mov_di"
  24015. + [(set (match_operand:DI 0 "metag_register_op" "=d,a,d, cx,cx,?da")
  24016. + (match_operand:DI 1 "metag_register_op" "d,a,cx,d, cx,?da"))]
  24017. + ""
  24018. + {
  24019. + switch (which_alternative)
  24020. + {
  24021. + case 0:
  24022. + case 1:
  24023. + case 5:
  24024. + return "#";
  24025. + case 2:
  24026. + case 3:
  24027. + case 4:
  24028. + if (metag_fpu_single)
  24029. + return "#";
  24030. + else
  24031. + return "FD\\tMOV\\t%0,%1";
  24032. + default:
  24033. + gcc_unreachable();
  24034. + }
  24035. + }
  24036. + "reload_completed"
  24037. + [(const_int 0)]
  24038. + {
  24039. + /* WORK NEEDED: When in hard-float mode, FL MOV will do a dual
  24040. + unit MOV to FCC regs */
  24041. + if (TARGET_DSP
  24042. + && metag_datareg_p (REGNO (operands[0]))
  24043. + && metag_datareg_p (REGNO (operands[1])))
  24044. + {
  24045. + operands[0] = gen_rtx_REG (V2SImode, REGNO (operands[0]));
  24046. + operands[1] = gen_rtx_REG (V2SImode, REGNO (operands[1]));
  24047. + emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
  24048. + }
  24049. + else
  24050. + metag_split_movdi (operands);
  24051. + DONE;
  24052. + }
  24053. + [(set_attr "type" "two,two,two,two,two,slowslow")
  24054. + (set_attr "cond" "yes,yes,yes,yes,yes,yes")
  24055. + (set_attr "predicable" "yes")])
  24056. +
  24057. +(define_insn_and_split "*set_di"
  24058. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "=d,a")
  24059. + (match_operand:DI 1 "immediate_operand" "i,i"))]
  24060. + ""
  24061. + "#"
  24062. + "reload_completed"
  24063. + [(const_int 0)]
  24064. + {
  24065. + metag_split_movdi_immediate (operands);
  24066. + DONE;
  24067. + }
  24068. + [(set_attr "type" "four")])
  24069. +
  24070. +
  24071. +;; -----------------------------------------------------------------------------
  24072. +;; | Matching DI store post/pre_inc/dec/modify and emitting ASM |
  24073. +;; -----------------------------------------------------------------------------
  24074. +
  24075. +(define_insn "*sto_di_post_inc_concat"
  24076. + [(set (mem:DI (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da,da")))
  24077. + (unspec:DI [(match_operand:SI 1 "metag_reg_nofloat_op" "e, h")
  24078. + (match_operand:SI 2 "metag_reg_nofloat_op" "f, l")] UNSPEC_CONCAT))]
  24079. + "TARGET_METAC_1_1"
  24080. + "SETL\\t[%0++], %1, %2"
  24081. + [(set_attr "type" "fast")])
  24082. +
  24083. +(define_insn "*sto_di_post_inc"
  24084. + [(set (mem:DI (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24085. + (match_operand:DI 1 "metag_register_op" "cr"))]
  24086. + "TARGET_METAC_1_1"
  24087. + {
  24088. + static const char fmt[] = "F\\tSETL\\t[%0++], %1, %t1\\t%@ (*store DI post_inc OK)";
  24089. +
  24090. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24091. + }
  24092. + [(set_attr "type" "fast")])
  24093. +
  24094. +(define_insn "*sto_di_post_dec"
  24095. + [(set (mem:DI (post_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24096. + (match_operand:DI 1 "metag_register_op" "cr"))]
  24097. + "TARGET_METAC_1_1"
  24098. + {
  24099. + static const char fmt[] = "F\\tSETL\\t[%0--], %1, %t1\\t%@ (*store DI post_dec OK)";
  24100. +
  24101. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24102. + }
  24103. + [(set_attr "type" "fast")])
  24104. +
  24105. +(define_insn "*sto_di_pre_inc"
  24106. + [(set (mem:DI (pre_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24107. + (match_operand:DI 1 "metag_register_op" "cr"))]
  24108. + "TARGET_METAC_1_1"
  24109. + {
  24110. + static const char fmt[] = "F\\tSETL\\t[++%0], %1, %t1\\t%@ (*store DI pre_inc OK)";
  24111. +
  24112. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24113. + }
  24114. + [(set_attr "type" "fast")])
  24115. +
  24116. +(define_insn "*sto_di_pre_dec"
  24117. + [(set (mem:DI (pre_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24118. + (match_operand:DI 1 "metag_register_op" "cr"))]
  24119. + "TARGET_METAC_1_1"
  24120. + {
  24121. + static const char fmt[] = "F\\tSETL\\t[--%0], %1, %t1\\t%@ (*store DI pre_dec OK)";
  24122. +
  24123. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24124. + }
  24125. + [(set_attr "type" "fast")])
  24126. +
  24127. +(define_insn "*sto_di_post_modify_disp"
  24128. + [(set (mem:DI (post_modify:SI
  24129. + (match_operand:SI 0 "metag_reg_nofloat_op" "+d, a")
  24130. + (plus:SI (match_dup 0)
  24131. + (match_operand:SI 1 "metag_offset6_di" "O8,O8"))))
  24132. + (match_operand:DI 2 "metag_register_op" "a, d"))]
  24133. + "!TARGET_METAC_1_1"
  24134. + "SETL\\t[%0+%1++], %2, %t2\\t%@ (*store DI post_modify_disp OK)"
  24135. + [(set_attr "type" "fast")])
  24136. +
  24137. +(define_insn "*sto_di_post_modify_disp_1_1"
  24138. + [(set (mem:DI (post_modify:SI
  24139. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  24140. + (plus:SI (match_dup 0)
  24141. + (match_operand:SI 1 "metag_offset6_di" "O8"))))
  24142. + (match_operand:DI 2 "metag_register_op" "cr"))]
  24143. + "TARGET_METAC_1_1"
  24144. + {
  24145. + static const char fmt[] = "F\\tSETL\\t[%0+%1++], %2, %t2\\t%@ (*store DI post_modify_disp_1_1 OK)";
  24146. +
  24147. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24148. + }
  24149. + [(set_attr "type" "fast")])
  24150. +
  24151. +(define_insn "*sto_di_post_modify_reg"
  24152. + [(set (mem:DI (post_modify:SI
  24153. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  24154. + (plus:SI (match_dup 0)
  24155. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  24156. + (match_operand:DI 2 "metag_register_op" "ca,ca,cd,cd"))]
  24157. + "TARGET_METAC_1_1"
  24158. + {
  24159. + static const char fmt[] = "F\\tSETL\\t[%0+%1++], %2, %t2\\t%@ (*store DI post_modify_reg OK)";
  24160. +
  24161. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24162. + }
  24163. + [(set_attr "type" "fast")])
  24164. +
  24165. +(define_insn "*sto_di_pre_modify_disp"
  24166. + [(set (mem:DI (pre_modify:SI
  24167. + (match_operand:SI 0 "metag_reg_nofloat_op" "+d, a")
  24168. + (plus:SI (match_dup 0)
  24169. + (match_operand:SI 1 "metag_offset6_di" "O8,O8"))))
  24170. + (match_operand:DI 2 "metag_reg_nofloat_op" "a, d"))]
  24171. + "!TARGET_METAC_1_1"
  24172. + "SETL\\t[%0++%1], %2, %t2\\t%@ (*store DI pre_modify_disp OK)"
  24173. + [(set_attr "type" "fast")])
  24174. +
  24175. +(define_insn "*sto_di_pre_modify_disp_1_1"
  24176. + [(set (mem:DI (pre_modify:SI
  24177. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  24178. + (plus:SI (match_dup 0)
  24179. + (match_operand:SI 1 "metag_offset6_di" "O8"))))
  24180. + (match_operand:DI 2 "metag_reg_nofloat_op" "cr"))]
  24181. + "TARGET_METAC_1_1"
  24182. + {
  24183. + static const char fmt[] = "F\\tSETL\\t[%0++%1], %2, %t2\\t%@ (*store DI pre_modify_disp_1_1 OK)";
  24184. +
  24185. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24186. + }
  24187. + [(set_attr "type" "fast")])
  24188. +
  24189. +(define_insn "*sto_di_pre_modify_reg"
  24190. + [(set (mem:DI (pre_modify:SI
  24191. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  24192. + (plus:SI (match_dup 0)
  24193. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  24194. + (match_operand:DI 2 "metag_register_op" "ca,ca,cd,cd"))]
  24195. + ""
  24196. + {
  24197. + static const char fmt[] = "F\\tSETL\\t[%0++%1], %2, %t2\\t%@ (*store DI pre_modify_reg OK)";
  24198. +
  24199. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24200. + }
  24201. + [(set_attr "type" "fast")])
  24202. +
  24203. +;; -----------------------------------------------------------------------------
  24204. +
  24205. +;; -----------------------------------------------------------------------------
  24206. +;; | Non-side effecting base+offset store DI and catchall store DI cases |
  24207. +;; -----------------------------------------------------------------------------
  24208. +
  24209. +;; movdi - register to memory (stores) some are fast, rest match spilldi below
  24210. +(define_insn "*sto_di_cond_exec_concat"
  24211. + [(set (mem:DI (match_operand:SI 0 "metag_reg_nofloat_op" "a,d,!da"))
  24212. + (unspec:DI [(match_operand:SI 1 "metag_reg_nofloat_op" "d,a, da")
  24213. + (match_operand:SI 2 "metag_reg_nofloat_op" "d,a, da")] UNSPEC_CONCAT))]
  24214. + "TARGET_COND_EXEC_OPTIMIZE
  24215. + && !TARGET_METAC_1_1
  24216. + && reload_completed
  24217. + && !( metag_regno_same_unit_p (REGNO (operands[0]), REGNO (operands[1]))
  24218. + || metag_regno_same_unit_p (REGNO (operands[0]), REGNO (operands[2])))"
  24219. + "SETL%?\\t[%0], %1, %2\\t%@ (*sto di OK)"
  24220. + [(set_attr "type" "fast")
  24221. + (set_attr "cond" "yes")
  24222. + (set_attr "predicable" "yes")])
  24223. +
  24224. +(define_insn "*sto_di_cond_exec"
  24225. + [(set (mem:DI (match_operand:SI 0 "metag_reg_nofloat_op" "a,d,!da"))
  24226. + (match_operand:DI 1 "metag_reg_nofloat_op" "d,a, da"))]
  24227. + "TARGET_COND_EXEC_OPTIMIZE
  24228. + && !TARGET_METAC_1_1
  24229. + && reload_completed
  24230. + && !( metag_regno_same_unit_p (REGNO (operands[0]), REGNO (operands[1]))
  24231. + || metag_regno_same_unit_p (REGNO (operands[0]), REGNO (operands[1]) + 1))"
  24232. + "SETL%?\\t[%0], %1, %t1\\t%@ (*sto di OK)"
  24233. + [(set_attr "type" "fast")
  24234. + (set_attr "cond" "yes")
  24235. + (set_attr "predicable" "yes")])
  24236. +
  24237. +(define_insn "*sto_di_concat"
  24238. + [(set (match_operand:DI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!m")
  24239. + (unspec:DI [(match_operand:SI 1 "metag_reg_nofloat_op" "r, a, a, d, d, da")
  24240. + (match_operand:SI 2 "metag_reg_nofloat_op" "r, a, a, d, d, da")] UNSPEC_CONCAT))]
  24241. + "!TARGET_METAC_1_1"
  24242. + "SETL\\t%0, %1, %2"
  24243. + [(set_attr "type" "fast")])
  24244. +
  24245. +(define_insn "*sto_di_off12"
  24246. + [(set (mem:DI (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "e, f, h, l, Ye,Yf,Yh,Yl")
  24247. + (match_operand:SI 1 "metag_offset12_di" "O8,O8,O8,O8,Z8,Z8,Z8,Z8")))
  24248. + (match_operand:DI 2 "metag_reg_nofloat_op" "a, a, d, d, a, a, d, d"))]
  24249. + "!TARGET_METAC_1_1"
  24250. + "SETL\\t[%0+%1], %2, %t2"
  24251. + [(set_attr "type" "fast")])
  24252. +
  24253. +(define_insn "*sto_di_off6"
  24254. + [(set (mem:DI (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "e, f, h, l")
  24255. + (match_operand:SI 1 "metag_offset6_di" "O8,O8,O8,O8")))
  24256. + (match_operand:DI 2 "metag_register_op" "a, a, d, d"))]
  24257. + "!TARGET_METAC_1_1"
  24258. + "SETL\\t[%0+%1], %2, %t2"
  24259. + [(set_attr "type" "fast")])
  24260. +
  24261. +(define_insn "*sto_di"
  24262. + [(set (match_operand:DI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  24263. + (match_operand:DI 1 "metag_reg_nofloat_op" "r, a, a, d, d, !*da"))]
  24264. + "!TARGET_METAC_1_1 && !reload_completed"
  24265. + "SETL\\t%0, %1, %t1"
  24266. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  24267. +
  24268. +(define_insn "*sto_di_postreload"
  24269. + [(set (match_operand:DI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  24270. + (match_operand:DI 1 "metag_reg_nofloat_op" "r, a, a, d, d"))]
  24271. + "!TARGET_METAC_1_1 && reload_completed"
  24272. + "SETL\\t%0, %1, %t1"
  24273. + [(set_attr "type" "fast")])
  24274. +
  24275. +;; movdi - base+index register to memory (stores)
  24276. +(define_insn "*sto_di_mar"
  24277. + [(set (mem:DI (plus:SI (match_operand:SI 0 "metag_regnofrm_op" "%e, f, h, l")
  24278. + (match_operand:SI 1 "metag_regnofrm_op" " e, f, h, l")))
  24279. + (match_operand:DI 2 "metag_register_op" "ca,ca,cd,cd"))]
  24280. + "TARGET_METAC_1_1"
  24281. + {
  24282. + static const char fmt[] = "F\\tSETL\\t[%0+%1], %2, %t2\\t\\t%@ (*sto di mar OK)";
  24283. +
  24284. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24285. + }
  24286. + [(set_attr "type" "fast")
  24287. + (set_attr "length" "4,4,4,4")])
  24288. +
  24289. +(define_insn "*sto_di_reg_indirect_concat_1_1"
  24290. + [(set (mem:DI (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  24291. + (unspec:DI [(match_operand:SI 1 "metag_reg_nofloat_op" "da")
  24292. + (match_operand:SI 2 "metag_reg_nofloat_op" "da")] UNSPEC_CONCAT))]
  24293. + "TARGET_COND_EXEC_OPTIMIZE && TARGET_METAC_1_1"
  24294. + "SETL%?\\t[%0], %1, %2\\t%@ (*sto di OK)"
  24295. + [(set_attr "type" "fast")
  24296. + (set_attr "cond" "yes")
  24297. + (set_attr "predicable" "yes")])
  24298. +
  24299. +(define_insn "*sto_di_reg_indirect_1_1"
  24300. + [(set (mem:DI (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  24301. + (match_operand:DI 1 "metag_reg_nofloat_op" "da"))]
  24302. + "TARGET_COND_EXEC_OPTIMIZE && TARGET_METAC_1_1"
  24303. + "SETL%?\\t[%0], %1, %t1\\t%@ (*sto di OK)"
  24304. + [(set_attr "type" "fast")
  24305. + (set_attr "cond" "yes")
  24306. + (set_attr "predicable" "yes")])
  24307. +
  24308. +(define_insn "*sto_di_concat_1_1"
  24309. + [(set (match_operand:DI 0 "memory_operand" "=m, m")
  24310. + (unspec:DI [(match_operand:SI 1 "metag_register_op" "da,cx")
  24311. + (match_operand:SI 2 "metag_register_op" "da,cx")] UNSPEC_CONCAT))]
  24312. + "TARGET_METAC_1_1"
  24313. + {
  24314. + static const char fmt[] = "F\\tSETL\\t%0, %1, %2\\t\\t%@ (*sto di [r]r OK)";
  24315. +
  24316. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24317. + }
  24318. + [(set_attr "type" "fast")])
  24319. +
  24320. +(define_insn "*sto_di_1_1_off12"
  24321. + [(set (mem:DI (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "da,Yr")
  24322. + (match_operand:SI 1 "metag_offset12_di" "O8,Z8")))
  24323. + (match_operand:DI 2 "metag_reg_nofloat_op" "da,da"))]
  24324. + "TARGET_METAC_1_1"
  24325. + "SETL\\t[%0+%1], %2, %t2"
  24326. + [(set_attr "type" "fast")])
  24327. +
  24328. +(define_insn "*sto_di_1_1_off6"
  24329. + [(set (mem:DI (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  24330. + (match_operand:SI 1 "metag_offset6_di" "O8")))
  24331. + (match_operand:DI 2 "metag_register_op" "cr"))]
  24332. + "TARGET_METAC_1_1"
  24333. + {
  24334. + static const char fmt[] = "F\\tSETL\\t[%0+%1], %2, %t2";
  24335. +
  24336. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24337. + }
  24338. + [(set_attr "type" "fast")])
  24339. +
  24340. +(define_insn "*sto_di_1_1"
  24341. + [(set (match_operand:DI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  24342. + (match_operand:DI 1 "metag_reg_nofloat_op" "r, a, a, d, d, !*da"))]
  24343. + "TARGET_METAC_1_1 && !reload_completed"
  24344. + "SETL\\t%0, %1, %t1\\t\\t%@ (*sto di [r]r OK)"
  24345. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  24346. +
  24347. +(define_insn "*sto_di_1_1_postreload"
  24348. + [(set (match_operand:DI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  24349. + (match_operand:DI 1 "metag_reg_nofloat_op" "r, a, a, d, d"))]
  24350. + "TARGET_METAC_1_1 && reload_completed"
  24351. + "SETL\\t%0, %1, %t1\\t\\t%@ (*sto di [r]r OK)"
  24352. + [(set_attr "type" "fast")])
  24353. +
  24354. +;; spilldi - register to memory (stores) from source/dest in same bank
  24355. +(define_split
  24356. + [(set (match_operand:DI 0 "memory_operand" "")
  24357. + (match_operand:DI 1 "metag_register_op" ""))]
  24358. + "!TARGET_METAC_1_1
  24359. + && reload_completed
  24360. + && metag_slow_store (operands[0], operands[1])"
  24361. + [(set (match_dup 2)
  24362. + (match_dup 1))
  24363. + (set (match_dup 0)
  24364. + (match_dup 2))]
  24365. + {
  24366. + operands[2] = metag_gen_safe_temp (DImode, operands[1]);
  24367. + }
  24368. +)
  24369. +
  24370. +;; -----------------------------------------------------------------------------
  24371. +
  24372. +;; movdi - memory to register (loads)
  24373. +
  24374. +;; -----------------------------------------------------------------------------
  24375. +;; | Matching DI store [post/pre]_[inc/dec/modify] and emitting ASM |
  24376. +;; -----------------------------------------------------------------------------
  24377. +
  24378. +(define_insn "*lod_di_concat_post_inc"
  24379. + [(set (unspec:DI [(match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  24380. + (match_operand:SI 1 "metag_reg_nofloat_op" "=da")] UNSPEC_CONCAT)
  24381. + (mem:DI (post_inc:SI (match_operand:SI 2 "metag_reg_nofloat_op" "+da"))))]
  24382. + "TARGET_METAC_1_1"
  24383. + "GETL\\t%0, %1, [%2++]\\t%@ (*load DI post_inc OK)"
  24384. + [(set_attr "type" "load")])
  24385. +
  24386. +(define_insn "*lod_di_post_inc"
  24387. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24388. + (mem:DI (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  24389. + "TARGET_METAC_1_1"
  24390. + {
  24391. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1++]\\t%@ (*load DI post_inc OK)";
  24392. +
  24393. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24394. + }
  24395. + [(set_attr "type" "load")])
  24396. +
  24397. +(define_insn "*lod_di_post_dec"
  24398. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24399. + (mem:DI (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  24400. + "TARGET_METAC_1_1"
  24401. + {
  24402. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1--]\\t%@ (*load DI post_dec OK)";
  24403. +
  24404. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24405. + }
  24406. + [(set_attr "type" "load")])
  24407. +
  24408. +(define_insn "*lod_di_pre_inc"
  24409. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24410. + (mem:DI (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  24411. + "TARGET_METAC_1_1"
  24412. + {
  24413. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [++%1]\\t%@ (*load DI pre_inc OK)";
  24414. +
  24415. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24416. + }
  24417. + [(set_attr "type" "load")])
  24418. +
  24419. +(define_insn "*lod_di_pre_dec"
  24420. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24421. + (mem:DI (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da"))))]
  24422. + "TARGET_METAC_1_1"
  24423. + {
  24424. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [--%1]\\t%@ (*load DI pre_dec OK)";
  24425. +
  24426. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24427. + }
  24428. + [(set_attr "type" "load")])
  24429. +
  24430. +(define_insn "*lod_di_post_modify_disp"
  24431. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24432. + (mem:DI (post_modify:SI
  24433. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  24434. + (plus:SI (match_dup 1)
  24435. + (match_operand:SI 2 "metag_offset6_di" "O8")))))]
  24436. + ""
  24437. + {
  24438. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DI post_modify_disp OK)";
  24439. +
  24440. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24441. + }
  24442. + [(set_attr "type" "load")])
  24443. +
  24444. +(define_insn "*lod_di_post_modify_reg"
  24445. + [(set (match_operand:DI 0 "metag_register_op" "=cr,cr,cr,cr")
  24446. + (mem:DI (post_modify:SI
  24447. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  24448. + (plus:SI (match_dup 1)
  24449. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  24450. + ""
  24451. + {
  24452. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DI post_modify_reg OK)";
  24453. +
  24454. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24455. + }
  24456. + [(set_attr "type" "load")])
  24457. +
  24458. +(define_insn "*lod_di_pre_modify_disp"
  24459. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24460. + (mem:DI (pre_modify:SI
  24461. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  24462. + (plus:SI (match_dup 1)
  24463. + (match_operand:SI 2 "metag_offset6_di" "O8")))))]
  24464. + ""
  24465. + {
  24466. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load DI pre_modify_disp OK)";
  24467. +
  24468. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24469. + }
  24470. + [(set_attr "type" "load")])
  24471. +
  24472. +(define_insn "*lod_di_pre_modify_reg"
  24473. + [(set (match_operand:DI 0 "metag_register_op" "=cr,cr,cr,cr")
  24474. + (mem:DI (pre_modify:SI
  24475. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  24476. + (plus:SI (match_dup 1)
  24477. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l")))))]
  24478. + ""
  24479. + {
  24480. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load DI pre_modify_reg OK)";
  24481. +
  24482. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24483. + }
  24484. + [(set_attr "type" "load")])
  24485. +
  24486. +;; -----------------------------------------------------------------------------
  24487. +
  24488. +;; -----------------------------------------------------------------------------
  24489. +;; | Non-side effecting base+offset load DI and catchall load DI |
  24490. +;; -----------------------------------------------------------------------------
  24491. +
  24492. +(define_insn "*lod_di"
  24493. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24494. + (mem:DI (match_operand:SI 1 "metag_regnofrm_op" "da")))]
  24495. + ""
  24496. + {
  24497. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1]\\t%@ (*lod di rma OK)";
  24498. +
  24499. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24500. + }
  24501. + [(set_attr "type" "load")])
  24502. +
  24503. +;; movdi - base+index memory to register (loads)
  24504. +(define_insn "*lod_di_rma"
  24505. + [(set (match_operand:DI 0 "metag_register_op" "=cr,cr,cr,cr")
  24506. + (mem:DI (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e, f, h, l")
  24507. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l"))))]
  24508. + ""
  24509. + {
  24510. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1+%2]\\t%@ (*lod qi rma OK)";
  24511. +
  24512. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24513. + }
  24514. + [(set_attr "type" "load")])
  24515. +
  24516. +(define_insn "*lod_di_concat"
  24517. + [(set (unspec:DI [(match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  24518. + (match_operand:SI 1 "metag_reg_nofloat_op" "=da")] UNSPEC_CONCAT)
  24519. + (match_operand:DI 2 "memory_operand" "m"))]
  24520. + ""
  24521. + "GETL\\t%0, %1, %2"
  24522. + [(set_attr "type" "load")])
  24523. +
  24524. +(define_insn "*lod_di_off12"
  24525. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "=da,da")
  24526. + (mem:DI (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "da,Yr")
  24527. + (match_operand:SI 2 "metag_offset12_di" "O8,Z8"))))]
  24528. + ""
  24529. + "GETL\\t%0, %t0, [%1+%2]"
  24530. + [(set_attr "type" "load")])
  24531. +
  24532. +(define_insn "*lod_di_off6"
  24533. + [(set (match_operand:DI 0 "metag_register_op" "=cr")
  24534. + (mem:DI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  24535. + (match_operand:SI 2 "metag_offset6_di" "O8"))))]
  24536. + ""
  24537. + {
  24538. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1+%2]";
  24539. +
  24540. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  24541. + }
  24542. + [(set_attr "type" "load")])
  24543. +
  24544. +(define_insn "*lod_di_mem"
  24545. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "=da")
  24546. + (match_operand:DI 1 "memory_operand" "m"))]
  24547. + ""
  24548. + "GETL\\t%0, %t0, %1\\t%@ (*lod di rm)"
  24549. + [(set_attr "type" "load")])
  24550. +
  24551. +;; -----------------------------------------------------------------------------
  24552. +
  24553. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  24554. +;; movdf is made up of many parts.. ;;
  24555. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  24556. +(define_expand "movdf"
  24557. + [(set (match_operand:DF 0 "nonimmediate_operand" "")
  24558. + (match_operand:DF 1 "general_operand" ""))]
  24559. + ""
  24560. + {
  24561. + if (MEM_P (operands[0]))
  24562. + {
  24563. + /* All except mem = const or mem = mem can be done quickly */
  24564. + operands[1] = force_reg (DFmode, operands[1]);
  24565. + }
  24566. +
  24567. + if (metag_fpu_single
  24568. + && REG_P (operands[0])
  24569. + && METAG_FPC_REG_P (REGNO (operands[0]))
  24570. + && CONST_DOUBLE_P (operands[1]))
  24571. + FAIL;
  24572. + }
  24573. +)
  24574. +
  24575. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  24576. +;; and these are the movdf parts.. ;;
  24577. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  24578. +
  24579. +;; movdf - register to register forms
  24580. +(define_insn_and_split "*mov_df"
  24581. + [(set (match_operand:DF 0 "metag_register_op" "=cx,d, cx,d,a,da")
  24582. + (match_operand:DF 1 "metag_register_op" "cx,cx,d, d,a,da"))]
  24583. + ""
  24584. + {
  24585. + switch (which_alternative)
  24586. + {
  24587. + case 0:
  24588. + if (!metag_fpu_single)
  24589. + return "FL\\tMOV%?\\t%0,%1";
  24590. + else
  24591. + return "#";
  24592. + case 1:
  24593. + case 2:
  24594. + return "F\\tMOVL\\t%0,%1";
  24595. + case 3:
  24596. + if (TARGET_DSP)
  24597. + return "DL\\tMOV\\t%0, %1";
  24598. + /* Fall through */
  24599. + case 4:
  24600. + case 5:
  24601. + return "#";
  24602. + default:
  24603. + gcc_unreachable();
  24604. + }
  24605. + }
  24606. + "&& reload_completed"
  24607. + [(const_int 0)]
  24608. + {
  24609. + metag_split_movdf (operands);
  24610. + DONE;
  24611. + }
  24612. + [(set_attr "type" "fast,fast,fast,two,two,slowslow")
  24613. + (set_attr "cond" "yes,no,no,yes,yes,yes")
  24614. + (set_attr "predicable" "no")])
  24615. +
  24616. +;; movdf - immediate to register forms
  24617. +(define_insn_and_split "*set_df"
  24618. + [(set (match_operand:DF 0 "metag_register_op" "=d,a,cx")
  24619. + (match_operand:DF 1 "immediate_operand" "i,i,ci"))]
  24620. + "!metag_fpu_single"
  24621. + {
  24622. + switch (which_alternative)
  24623. + {
  24624. + case 0:
  24625. + case 1:
  24626. + return "#";
  24627. + case 2:
  24628. + return "FD\\tMOV\\t%0,#%h1";
  24629. + default:
  24630. + gcc_unreachable();
  24631. + }
  24632. + }
  24633. + "&& reload_completed
  24634. + && (!METAG_FPC_REG_P (REGNO (operands[0]))
  24635. + || !metag_fphalf_imm_op (operands[1], DFmode))"
  24636. + [(const_int 0)]
  24637. + {
  24638. + metag_split_movdf_immediate (operands);
  24639. + DONE;
  24640. + }
  24641. + [(set_attr "type" "four")])
  24642. +
  24643. +(define_insn_and_split "*set_df_fpu_single"
  24644. + [(set (match_operand:DF 0 "metag_register_op" "=d,a")
  24645. + (match_operand:DF 1 "immediate_operand" "i,i"))]
  24646. + "metag_fpu_single"
  24647. + "#"
  24648. + "&& reload_completed"
  24649. + [(const_int 0)]
  24650. + {
  24651. + metag_split_movdf_immediate (operands);
  24652. + DONE;
  24653. + }
  24654. + [(set_attr "type" "four")])
  24655. +
  24656. +;; -----------------------------------------------------------------------------
  24657. +
  24658. +(define_insn "*sto_df_post_inc"
  24659. + [(set (mem:DF (post_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24660. + (match_operand:DF 1 "metag_register_op" "cr"))]
  24661. + "TARGET_METAC_1_1"
  24662. + {
  24663. + static const char fmt[] = "F\\tSETL\\t[%0++], %1, %t1\\t%@ (*store DF post_inc OK)";
  24664. +
  24665. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24666. + }
  24667. + [(set_attr "type" "fast")])
  24668. +
  24669. +(define_insn "*sto_df_post_dec"
  24670. + [(set (mem:DF (post_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24671. + (match_operand:DF 1 "metag_register_op" "cr"))]
  24672. + "TARGET_METAC_1_1"
  24673. + {
  24674. + static const char fmt[] = "F\\tSETL\\t[%0--], %1, %t1\\t%@ (*store DF post_dec OK)";
  24675. +
  24676. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24677. + }
  24678. + [(set_attr "type" "fast")])
  24679. +
  24680. +(define_insn "*sto_df_pre_inc"
  24681. + [(set (mem:DF (pre_inc:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24682. + (match_operand:DF 1 "metag_register_op" "cr"))]
  24683. + "TARGET_METAC_1_1"
  24684. + {
  24685. + static const char fmt[] = "F\\tSETL\\t[++%0], %1, %t1\\t%@ (*store DF pre_inc OK)";
  24686. +
  24687. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24688. + }
  24689. + [(set_attr "type" "fast")])
  24690. +
  24691. +(define_insn "*sto_df_pre_dec"
  24692. + [(set (mem:DF (pre_dec:SI (match_operand:SI 0 "metag_reg_nofloat_op" "+da")))
  24693. + (match_operand:DF 1 "metag_register_op" "cr"))]
  24694. + "TARGET_METAC_1_1"
  24695. + {
  24696. + static const char fmt[] = "F\\tSETL\\t[--%0], %1, %t1\\t%@ (*store DF pre_dec OK)";
  24697. +
  24698. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24699. + }
  24700. + [(set_attr "type" "fast")])
  24701. +
  24702. +(define_insn "*sto_df_post_modify_disp"
  24703. + [(set (mem:DF (post_modify:SI
  24704. + (match_operand:SI 0 "metag_reg_nofloat_op" "+d, a")
  24705. + (plus:SI (match_dup 0)
  24706. + (match_operand:SI 1 "metag_offset6_df" "O8,O8"))))
  24707. + (match_operand:DF 2 "metag_register_op" "a, d"))]
  24708. + "!TARGET_METAC_1_1"
  24709. + "SETL\\t[%0+%1++], %2, %t2\\t%@ (*store DF post_modify_disp OK)"
  24710. + [(set_attr "type" "fast")])
  24711. +
  24712. +(define_insn "*sto_df_post_modify_disp_1_1"
  24713. + [(set (mem:DF (post_modify:SI
  24714. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  24715. + (plus:SI (match_dup 0)
  24716. + (match_operand:SI 1 "metag_offset6_df" "O8"))))
  24717. + (match_operand:DF 2 "metag_register_op" "cr"))]
  24718. + "TARGET_METAC_1_1"
  24719. + {
  24720. + static const char fmt[] = "F\\tSETL\\t[%0+%1++], %2, %t2\\t%@ (*store DF post_modify_disp_1_1 OK)";
  24721. +
  24722. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24723. + }
  24724. + [(set_attr "type" "fast")])
  24725. +
  24726. +(define_insn "*sto_df_post_modify_reg"
  24727. + [(set (mem:DF (post_modify:SI
  24728. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  24729. + (plus:SI (match_dup 0)
  24730. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  24731. + (match_operand:DF 2 "metag_register_op" "ca,ca,cd,cd"))]
  24732. + ""
  24733. + {
  24734. + static const char fmt[] = "F\\tSETL\\t[%0+%1++], %2, %t2\\t%@ (*store DF post_modify_reg OK)";
  24735. +
  24736. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24737. + }
  24738. + [(set_attr "type" "fast")])
  24739. +
  24740. +(define_insn "*sto_df_pre_modify_disp"
  24741. + [(set (mem:DF (pre_modify:SI
  24742. + (match_operand:SI 0 "metag_reg_nofloat_op" "+d, a")
  24743. + (plus:SI (match_dup 0)
  24744. + (match_operand:SI 1 "metag_offset6_df" "O8,O8"))))
  24745. + (match_operand:DF 2 "metag_reg_nofloat_op" "a, d"))]
  24746. + "!TARGET_METAC_1_1"
  24747. + "SETL\\t[%0++%1], %2, %t2\\t%@ (*store DF pre_modify_disp OK)"
  24748. + [(set_attr "type" "fast")])
  24749. +
  24750. +(define_insn "*sto_df_pre_modify_disp_1_1"
  24751. + [(set (mem:DF (pre_modify:SI
  24752. + (match_operand:SI 0 "metag_reg_nofloat_op" "+da")
  24753. + (plus:SI (match_dup 0)
  24754. + (match_operand:SI 1 "metag_offset6_df" "O8"))))
  24755. + (match_operand:DF 2 "metag_register_op" "cr"))]
  24756. + "TARGET_METAC_1_1"
  24757. + {
  24758. + static const char fmt[] = "F\\tSETL\\t[%0++%1], %2, %t2\\t%@ (*store DF pre_modify_disp_1_1 OK)";
  24759. +
  24760. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24761. + }
  24762. + [(set_attr "type" "fast")])
  24763. +
  24764. +(define_insn "*sto_df_pre_modify_reg"
  24765. + [(set (mem:DF (pre_modify:SI
  24766. + (match_operand:SI 0 "metag_reg_nofloat_op" "+e, f, h, l")
  24767. + (plus:SI (match_dup 0)
  24768. + (match_operand:SI 1 "metag_reg_nofloat_op" "e, f, h, l"))))
  24769. + (match_operand:DF 2 "metag_register_op" "ca,ca,cd,cd"))]
  24770. + ""
  24771. + {
  24772. + static const char fmt[] = "F\\tSETL\\t[%0++%1], %2, %t2\\t%@ (*store DF pre_modify_reg OK)";
  24773. +
  24774. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24775. + }
  24776. + [(set_attr "type" "fast")])
  24777. +
  24778. +;; -----------------------------------------------------------------------------
  24779. +
  24780. +;; movdf - register to memory forms (stores)
  24781. +(define_insn "*sto_df_reg_indirect"
  24782. + [(set (mem:DF (match_operand:SI 0 "metag_reg_nofloat_op" "a,d,ad,!da"))
  24783. + (match_operand:DF 1 "metag_register_op" "d,a,cx, da"))]
  24784. + "TARGET_COND_EXEC_OPTIMIZE
  24785. + && !TARGET_METAC_1_1
  24786. + && reload_completed
  24787. + && !( metag_regno_same_unit_p (REGNO (operands[0]), REGNO (operands[1]))
  24788. + || metag_regno_same_unit_p (REGNO (operands[0]), REGNO (operands[1]) + 1))"
  24789. + {
  24790. + static const char fmt[] = "F\\tSETL%?\\t[%0], %1, %t1\\t%@ (*sto df OK)";
  24791. +
  24792. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24793. + }
  24794. + [(set_attr "type" "fast")
  24795. + (set_attr "cond" "yes")
  24796. + (set_attr "predicable" "yes")])
  24797. +
  24798. +(define_insn "*sto_df"
  24799. + [(set (match_operand:DF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  24800. + (match_operand:DF 1 "metag_register_op" "da,a, a, d, d, !*da"))]
  24801. + "!TARGET_METAC_1_1 && !reload_completed"
  24802. + "SETL\\t%0, %1, %t1"
  24803. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  24804. +
  24805. +(define_insn "*sto_df_postreload"
  24806. + [(set (match_operand:DF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  24807. + (match_operand:DF 1 "metag_register_op" "da,a, a, d, d"))]
  24808. + "!TARGET_METAC_1_1 && reload_completed"
  24809. + "SETL\\t%0, %1, %t1"
  24810. + [(set_attr "type" "fast")])
  24811. +
  24812. +(define_insn "*sto_df_1_1_reg_indirect"
  24813. + [(set (mem:DF (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  24814. + (match_operand:DF 1 "metag_register_op" "cr"))]
  24815. + "TARGET_COND_EXEC_OPTIMIZE && TARGET_METAC_1_1"
  24816. + {
  24817. + static const char fmt[] = "F\\tSETL%?\\t[%0], %1, %t1\\t%@ (*sto df [r]r OK)";
  24818. +
  24819. + return &fmt[METAG_FPC_REG_P (REGNO (operands[1])) ? 0 : 2];
  24820. + }
  24821. + [(set_attr "type" "fast")
  24822. + (set_attr "cond" "yes")
  24823. + (set_attr "predicable" "yes")])
  24824. +
  24825. +(define_insn "*sto_df_1_1_off12"
  24826. + [(set (mem:DF (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "da,Yr")
  24827. + (match_operand:SI 1 "metag_offset12_df" "O8,Z8")))
  24828. + (match_operand:DF 2 "metag_reg_nofloat_op" "da,da"))]
  24829. + "TARGET_METAC_1_1"
  24830. + "SETL\\t[%0+%1], %2, %t2"
  24831. + [(set_attr "type" "fast")])
  24832. +
  24833. +(define_insn "*sto_df_1_1_off6"
  24834. + [(set (mem:DF (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  24835. + (match_operand:SI 1 "metag_offset6_df" "O8")))
  24836. + (match_operand:DF 2 "metag_register_op" "cr"))]
  24837. + "TARGET_METAC_1_1"
  24838. + {
  24839. + static const char fmt[] = "F\\tSETL\\t[%0+%1], %2, %t2";
  24840. +
  24841. + return &fmt[METAG_FPC_REG_P (REGNO (operands[2])) ? 0 : 2];
  24842. + }
  24843. + [(set_attr "type" "fast")])
  24844. +
  24845. +;; movdf - register to memory forms (stores)
  24846. +(define_insn "*sto_df_1_1"
  24847. + [(set (match_operand:DF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  24848. + (match_operand:DF 1 "metag_reg_nofloat_op" "da, a, a, d, d,!*da"))]
  24849. + "TARGET_METAC_1_1 && !reload_completed"
  24850. + "SETL\\t%0, %1, %t1\\t\\t%@ (*sto df [r]r OK)"
  24851. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  24852. +
  24853. +(define_insn "*sto_df_1_1_postreload"
  24854. + [(set (match_operand:DF 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  24855. + (match_operand:DF 1 "metag_reg_nofloat_op" "da, a, a, d, d"))]
  24856. + "TARGET_METAC_1_1 && reload_completed"
  24857. + "SETL\\t%0, %1, %t1\\t\\t%@ (*sto df [r]r OK)"
  24858. + [(set_attr "type" "fast")])
  24859. +
  24860. +;; spilldf - register to memory (stores) from source/dest in same bank
  24861. +(define_split
  24862. + [(set (match_operand:DF 0 "memory_operand" "")
  24863. + (match_operand:DF 1 "metag_register_op" ""))]
  24864. + "!TARGET_METAC_1_1
  24865. + && reload_completed
  24866. + && metag_slow_store (operands[0], operands[1])"
  24867. + [(set (match_dup 2)
  24868. + (match_dup 1))
  24869. + (set (match_dup 0)
  24870. + (match_dup 2))]
  24871. + {
  24872. + operands[2] = metag_gen_safe_temp (DFmode, operands[1]);
  24873. + }
  24874. +)
  24875. +
  24876. +;; -----------------------------------------------------------------------------
  24877. +
  24878. +;; movdf - memory to register (loads)
  24879. +
  24880. +;; -----------------------------------------------------------------------------
  24881. +;; | Matching DF store [post/pre]_[inc/dec/modify]
  24882. +;; -----------------------------------------------------------------------------
  24883. +
  24884. +(define_insn "*lod_df_post_inc"
  24885. + [(set (match_operand:DF 0 "metag_register_op" "=da,cx")
  24886. + (mem:DF (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da,da"))))]
  24887. + "TARGET_METAC_1_1"
  24888. + "@
  24889. + GETL\\t%0, %t0, [%1++]\\t%@ (*load DF post_inc OK)
  24890. + F\\tGETL\\t%0, %t0, [%1++]\\t%@ (*load DF post_inc OK)"
  24891. + [(set_attr "type" "load")])
  24892. +
  24893. +(define_insn "*lod_df_post_dec"
  24894. + [(set (match_operand:DF 0 "metag_register_op" "=da,cx")
  24895. + (mem:DF (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da,da"))))]
  24896. + "TARGET_METAC_1_1"
  24897. + "@
  24898. + GETL\\t%0, %t0, [%1--]\\t%@ (*load DF post_dec OK)
  24899. + F\\tGETL\\t%0, %t0, [%1--]\\t%@ (*load DF post_dec OK)"
  24900. + [(set_attr "type" "load")])
  24901. +
  24902. +(define_insn "*lod_df_pre_inc"
  24903. + [(set (match_operand:DF 0 "metag_register_op" "=da,cx")
  24904. + (mem:DF (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da,da"))))]
  24905. + "TARGET_METAC_1_1"
  24906. + "@
  24907. + GETL\\t%0, %t0, [++%1]\\t%@ (*load DF pre_inc OK)
  24908. + F\\tGETL\\t%0, %t0, [++%1]\\t%@ (*load DF pre_inc OK)"
  24909. + [(set_attr "type" "load")])
  24910. +
  24911. +(define_insn "*lod_df_pre_dec"
  24912. + [(set (match_operand:DF 0 "metag_register_op" "=da,cx")
  24913. + (mem:DF (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da,da"))))]
  24914. + "TARGET_METAC_1_1"
  24915. + "@
  24916. + GETL\\t%0, %t0, [--%1]\\t%@ (*load DF pre_dec OK)
  24917. + F\\tGETL\\t%0, %t0, [--%1]\\t%@ (*load DF pre_dec OK)"
  24918. + [(set_attr "type" "load")])
  24919. +
  24920. +(define_insn "*lod_df_post_modify_disp"
  24921. + [(set (match_operand:DF 0 "metag_register_op" "=da,cx")
  24922. + (mem:DF (post_modify:SI
  24923. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da,da")
  24924. + (plus:SI (match_dup 1)
  24925. + (match_operand:SI 2 "metag_offset6_df" "O8,O8")))))]
  24926. + ""
  24927. + "@
  24928. + GETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_disp OK)
  24929. + F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_disp OK)"
  24930. + [(set_attr "type" "load")])
  24931. +
  24932. +(define_insn "*lod_df_post_modify_reg"
  24933. + [(set (match_operand:DF 0 "metag_register_op" "=da,da,da,da,cx,cx,cx,cx")
  24934. + (mem:DF (post_modify:SI
  24935. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l, e, f, h, l")
  24936. + (plus:SI (match_dup 1)
  24937. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l, e, f, h, l")))))]
  24938. + ""
  24939. + "@
  24940. + GETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)
  24941. + GETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)
  24942. + GETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)
  24943. + GETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)
  24944. + F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)
  24945. + F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)
  24946. + F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)
  24947. + F\\tGETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DF post_modify_reg OK)"
  24948. + [(set_attr "type" "load")])
  24949. +
  24950. +(define_insn "*lod_df_pre_modify_disp"
  24951. + [(set (match_operand:DF 0 "metag_register_op" "=da,cx")
  24952. + (mem:DF (pre_modify:SI
  24953. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da,da")
  24954. + (plus:SI (match_dup 1)
  24955. + (match_operand:SI 2 "metag_offset6_df" "O8,O8")))))]
  24956. + ""
  24957. + "@
  24958. + GETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_disp OK)
  24959. + F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_disp OK)"
  24960. + [(set_attr "type" "load")])
  24961. +
  24962. +(define_insn "*lod_df_pre_modify_reg"
  24963. + [(set (match_operand:DF 0 "metag_register_op" "=da,da,da,da,cx,cx,cx,cx")
  24964. + (mem:DF (pre_modify:SI
  24965. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l, e, f, h, l")
  24966. + (plus:SI (match_dup 1)
  24967. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l, e, f, h, l")))))]
  24968. + ""
  24969. + "@
  24970. + GETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)
  24971. + GETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)
  24972. + GETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)
  24973. + GETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)
  24974. + F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)
  24975. + F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)
  24976. + F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)
  24977. + F\\tGETL\\t%0, %t0, [%1++%2]\\t%@ (*load DF pre_modify_reg OK)"
  24978. + [(set_attr "type" "load")])
  24979. +
  24980. +;; -----------------------------------------------------------------------------
  24981. +
  24982. +(define_insn "*lod_df_concat"
  24983. + [(set (unspec:DF [(match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  24984. + (match_operand:SI 1 "metag_reg_nofloat_op" "=da")] UNSPEC_CONCAT)
  24985. + (match_operand:DF 2 "memory_operand" "m"))]
  24986. + ""
  24987. + "GETL\\t%0, %1, %2"
  24988. + [(set_attr "type" "load")])
  24989. +
  24990. +(define_insn "*lod_df_off12"
  24991. + [(set (match_operand:DF 0 "metag_reg_nofloat_op" "=da,da")
  24992. + (mem:DF (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "da,Yr")
  24993. + (match_operand:SI 2 "metag_offset12_df" "O8,Z8"))))]
  24994. + ""
  24995. + "GETL\\t%0, %t0, [%1+%2]"
  24996. + [(set_attr "type" "load")])
  24997. +
  24998. +(define_insn "*lod_df_off6"
  24999. + [(set (match_operand:DF 0 "metag_register_op" "=da,cx")
  25000. + (mem:DF (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da,da")
  25001. + (match_operand:SI 2 "metag_offset6_df" "O8,O8"))))]
  25002. + ""
  25003. + "@
  25004. + GETL\\t%0, %t0, [%1+%2]
  25005. + F\\tGETL\\t%0, %t0, [%1+%2]"
  25006. + [(set_attr "type" "load")])
  25007. +
  25008. +(define_insn "*lod_df"
  25009. + [(set (match_operand:DF 0 "metag_register_op" "=cr")
  25010. + (mem:DF (match_operand:SI 1 "metag_reg_nofloat_op" "da")))]
  25011. + ""
  25012. + {
  25013. + static const char fmt[] = "F\\tGETL\\t%0, %t0, [%1]";
  25014. +
  25015. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  25016. + }
  25017. + [(set_attr "type" "load")])
  25018. +
  25019. +(define_insn "*lod_df_mem"
  25020. + [(set (match_operand:DF 0 "metag_reg_nofloat_op" "=da")
  25021. + (match_operand:DF 1 "memory_operand" "m"))]
  25022. + ""
  25023. + "GETL\\t%0, %t0, %1\\t%@ (*lod df rm OK)"
  25024. + [(set_attr "type" "load")])
  25025. +
  25026. +;; Memory bloc xfer insn
  25027. +
  25028. +(define_expand "movmemqi"
  25029. + [(match_operand:BLK 0 "general_operand" "")
  25030. + (match_operand:BLK 1 "general_operand" "")
  25031. + (match_operand:SI 2 "const_int_operand" "")
  25032. + (match_operand:SI 3 "const_int_operand" "")]
  25033. + ""
  25034. + {
  25035. + if (metag_gen_movmemqi (operands))
  25036. + DONE;
  25037. + FAIL;
  25038. + }
  25039. +)
  25040. +
  25041. +;; Transfer instructions 64-bit and 32-bit
  25042. +
  25043. +;; loads DImode
  25044. +
  25045. +(define_insn "*ldmdi_7"
  25046. + [(match_parallel 0 "load_multiop"
  25047. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25048. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25049. + (const_int 56)))
  25050. + (set (match_operand:DI 3 "metag_hard_datareg_op" "=d")
  25051. + (mem:DI (match_dup 2)))
  25052. + (set (match_operand:DI 4 "metag_hard_datareg_op" "=d")
  25053. + (mem:DI (plus:SI (match_dup 2)
  25054. + (const_int 8))))
  25055. + (set (match_operand:DI 5 "metag_hard_datareg_op" "=d")
  25056. + (mem:DI (plus:SI (match_dup 2)
  25057. + (const_int 16))))
  25058. + (set (match_operand:DI 6 "metag_hard_datareg_op" "=d")
  25059. + (mem:DI (plus:SI (match_dup 2)
  25060. + (const_int 24))))
  25061. + (set (match_operand:DI 7 "metag_hard_datareg_op" "=d")
  25062. + (mem:DI (plus:SI (match_dup 2)
  25063. + (const_int 32))))
  25064. + (set (match_operand:DI 8 "metag_hard_datareg_op" "=d")
  25065. + (mem:DI (plus:SI (match_dup 2)
  25066. + (const_int 40))))
  25067. + (set (match_operand:DI 9 "metag_hard_datareg_op" "=d")
  25068. + (mem:DI (plus:SI (match_dup 2)
  25069. + (const_int 48))))])]
  25070. + "XVECLEN (operands[0], 0) == 7 + 1"
  25071. + "MGETL\\t%3, %4, %5, %6, %7, %8, %9, [%1++]\\t%@ (lodmr di OK)"
  25072. + [(set_attr "type" "fivex")
  25073. + (set_attr "memaccess" "load")
  25074. + (set_attr "rename" "no")])
  25075. +
  25076. +(define_insn "*ldmdi_6"
  25077. + [(match_parallel 0 "load_multiop"
  25078. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25079. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25080. + (const_int 48)))
  25081. + (set (match_operand:DI 3 "metag_hard_datareg_op" "=d")
  25082. + (mem:DI (match_dup 2)))
  25083. + (set (match_operand:DI 4 "metag_hard_datareg_op" "=d")
  25084. + (mem:DI (plus:SI (match_dup 2)
  25085. + (const_int 8))))
  25086. + (set (match_operand:DI 5 "metag_hard_datareg_op" "=d")
  25087. + (mem:DI (plus:SI (match_dup 2)
  25088. + (const_int 16))))
  25089. + (set (match_operand:DI 6 "metag_hard_datareg_op" "=d")
  25090. + (mem:DI (plus:SI (match_dup 2)
  25091. + (const_int 24))))
  25092. + (set (match_operand:DI 7 "metag_hard_datareg_op" "=d")
  25093. + (mem:DI (plus:SI (match_dup 2)
  25094. + (const_int 32))))
  25095. + (set (match_operand:DI 8 "metag_hard_datareg_op" "=d")
  25096. + (mem:DI (plus:SI (match_dup 2)
  25097. + (const_int 40))))])]
  25098. + "XVECLEN (operands[0], 0) == 6 + 1"
  25099. + "MGETL\\t%3, %4, %5, %6, %7, %8, [%1++]\\t%@ (lodmr di OK)"
  25100. + [(set_attr "type" "fivex")
  25101. + (set_attr "memaccess" "load")
  25102. + (set_attr "rename" "no")])
  25103. +
  25104. +(define_insn "*ldmdi_5"
  25105. + [(match_parallel 0 "load_multiop"
  25106. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25107. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25108. + (const_int 40)))
  25109. + (set (match_operand:DI 3 "metag_hard_datareg_op" "=d")
  25110. + (mem:DI (match_dup 2)))
  25111. + (set (match_operand:DI 4 "metag_hard_datareg_op" "=d")
  25112. + (mem:DI (plus:SI (match_dup 2)
  25113. + (const_int 8))))
  25114. + (set (match_operand:DI 5 "metag_hard_datareg_op" "=d")
  25115. + (mem:DI (plus:SI (match_dup 2)
  25116. + (const_int 16))))
  25117. + (set (match_operand:DI 6 "metag_hard_datareg_op" "=d")
  25118. + (mem:DI (plus:SI (match_dup 2)
  25119. + (const_int 24))))
  25120. + (set (match_operand:DI 7 "metag_hard_datareg_op" "=d")
  25121. + (mem:DI (plus:SI (match_dup 2)
  25122. + (const_int 32))))])]
  25123. + "XVECLEN (operands[0], 0) == 5 + 1"
  25124. + "MGETL\\t%3, %4, %5, %6, %7, [%1++]\\t%@ (lodmr di OK)"
  25125. + [(set_attr "type" "fivex")
  25126. + (set_attr "memaccess" "load")
  25127. + (set_attr "rename" "no")])
  25128. +
  25129. +(define_insn "*ldmdi_4"
  25130. + [(match_parallel 0 "load_multiop"
  25131. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25132. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25133. + (const_int 32)))
  25134. + (set (match_operand:DI 3 "metag_hard_datareg_op" "=d")
  25135. + (mem:DI (match_dup 2)))
  25136. + (set (match_operand:DI 4 "metag_hard_datareg_op" "=d")
  25137. + (mem:DI (plus:SI (match_dup 2)
  25138. + (const_int 8))))
  25139. + (set (match_operand:DI 5 "metag_hard_datareg_op" "=d")
  25140. + (mem:DI (plus:SI (match_dup 2)
  25141. + (const_int 16))))
  25142. + (set (match_operand:DI 6 "metag_hard_datareg_op" "=d")
  25143. + (mem:DI (plus:SI (match_dup 2)
  25144. + (const_int 24))))])]
  25145. + "XVECLEN (operands[0], 0) == 4 + 1"
  25146. + "MGETL\\t%3, %4, %5, %6, [%1++]\\t%@ (lodmr di OK)"
  25147. + [(set_attr "type" "fourx")
  25148. + (set_attr "memaccess" "load")
  25149. + (set_attr "rename" "no")])
  25150. +
  25151. +(define_insn "*ldmdi_3"
  25152. + [(match_parallel 0 "load_multiop"
  25153. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25154. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25155. + (const_int 24)))
  25156. + (set (match_operand:DI 3 "metag_hard_datareg_op" "=d")
  25157. + (mem:DI (match_dup 2)))
  25158. + (set (match_operand:DI 4 "metag_hard_datareg_op" "=d")
  25159. + (mem:DI (plus:SI (match_dup 2)
  25160. + (const_int 8))))
  25161. + (set (match_operand:DI 5 "metag_hard_datareg_op" "=d")
  25162. + (mem:DI (plus:SI (match_dup 2)
  25163. + (const_int 16))))])]
  25164. + "XVECLEN (operands[0], 0) == 3 + 1"
  25165. + "MGETL\\t%3, %4, %5, [%1++]\\t%@ (lodmr di OK)"
  25166. + [(set_attr "type" "threex")
  25167. + (set_attr "memaccess" "load")
  25168. + (set_attr "rename" "no")])
  25169. +
  25170. +(define_insn "*ldmdi_2"
  25171. + [(match_parallel 0 "load_multiop"
  25172. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25173. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25174. + (const_int 16)))
  25175. + (set (match_operand:DI 3 "metag_hard_datareg_op" "=d")
  25176. + (mem:DI (match_dup 2)))
  25177. + (set (match_operand:DI 4 "metag_hard_datareg_op" "=d")
  25178. + (mem:DI (plus:SI (match_dup 2)
  25179. + (const_int 8))))])]
  25180. + "XVECLEN (operands[0], 0) == 2 + 1"
  25181. + "MGETL\\t%3, %4, [%1++]\\t%@ (lodmr di OK)"
  25182. + [(set_attr "type" "twox")
  25183. + (set_attr "memaccess" "load")
  25184. + (set_attr "rename" "no")])
  25185. +
  25186. +;; Loads SImode
  25187. +
  25188. +(define_insn "*ldmsi_7"
  25189. + [(match_parallel 0 "load_multiop"
  25190. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25191. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25192. + (const_int 28)))
  25193. + (set (match_operand:SI 3 "metag_hard_datareg_op" "=d")
  25194. + (mem:SI (match_dup 2)))
  25195. + (set (match_operand:SI 4 "metag_hard_datareg_op" "=d")
  25196. + (mem:SI (plus:SI (match_dup 2)
  25197. + (const_int 4))))
  25198. + (set (match_operand:SI 5 "metag_hard_datareg_op" "=d")
  25199. + (mem:SI (plus:SI (match_dup 2)
  25200. + (const_int 8))))
  25201. + (set (match_operand:SI 6 "metag_hard_datareg_op" "=d")
  25202. + (mem:SI (plus:SI (match_dup 2)
  25203. + (const_int 12))))
  25204. + (set (match_operand:SI 7 "metag_hard_datareg_op" "=d")
  25205. + (mem:SI (plus:SI (match_dup 2)
  25206. + (const_int 16))))
  25207. + (set (match_operand:SI 8 "metag_hard_datareg_op" "=d")
  25208. + (mem:SI (plus:SI (match_dup 2)
  25209. + (const_int 20))))
  25210. + (set (match_operand:SI 9 "metag_hard_datareg_op" "=d")
  25211. + (mem:SI (plus:SI (match_dup 2)
  25212. + (const_int 24))))])]
  25213. + "XVECLEN (operands[0], 0) == 7 + 1"
  25214. + "MGETD\\t%3, %4, %5, %6, %7, %8, %9, [%1]\\t%@ (lodmr si OK)"
  25215. + [(set_attr "type" "fivex")
  25216. + (set_attr "memaccess" "load")
  25217. + (set_attr "rename" "no")])
  25218. +
  25219. +(define_insn "*ldmsi_6"
  25220. + [(match_parallel 0 "load_multiop"
  25221. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25222. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25223. + (const_int 24)))
  25224. + (set (match_operand:SI 3 "metag_hard_datareg_op" "=d")
  25225. + (mem:SI (match_dup 2)))
  25226. + (set (match_operand:SI 4 "metag_hard_datareg_op" "=d")
  25227. + (mem:SI (plus:SI (match_dup 2)
  25228. + (const_int 4))))
  25229. + (set (match_operand:SI 5 "metag_hard_datareg_op" "=d")
  25230. + (mem:SI (plus:SI (match_dup 2)
  25231. + (const_int 8))))
  25232. + (set (match_operand:SI 6 "metag_hard_datareg_op" "=d")
  25233. + (mem:SI (plus:SI (match_dup 2)
  25234. + (const_int 12))))
  25235. + (set (match_operand:SI 7 "metag_hard_datareg_op" "=d")
  25236. + (mem:SI (plus:SI (match_dup 2)
  25237. + (const_int 16))))
  25238. + (set (match_operand:SI 8 "metag_hard_datareg_op" "=d")
  25239. + (mem:SI (plus:SI (match_dup 2)
  25240. + (const_int 20))))])]
  25241. + "XVECLEN (operands[0], 0) == 6 + 1"
  25242. + "MGETD\\t%3, %4, %5, %6, %7, [%1]\\t%@ (lodmr si OK)"
  25243. + [(set_attr "type" "fivex")
  25244. + (set_attr "memaccess" "load")
  25245. + (set_attr "rename" "no")])
  25246. +
  25247. +(define_insn "*ldmsi_5"
  25248. + [(match_parallel 0 "load_multiop"
  25249. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25250. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25251. + (const_int 20)))
  25252. + (set (match_operand:SI 3 "metag_hard_datareg_op" "=d")
  25253. + (mem:SI (match_dup 2)))
  25254. + (set (match_operand:SI 4 "metag_hard_datareg_op" "=d")
  25255. + (mem:SI (plus:SI (match_dup 2)
  25256. + (const_int 4))))
  25257. + (set (match_operand:SI 5 "metag_hard_datareg_op" "=d")
  25258. + (mem:SI (plus:SI (match_dup 2)
  25259. + (const_int 8))))
  25260. + (set (match_operand:SI 6 "metag_hard_datareg_op" "=d")
  25261. + (mem:SI (plus:SI (match_dup 2)
  25262. + (const_int 12))))
  25263. + (set (match_operand:SI 7 "metag_hard_datareg_op" "=d")
  25264. + (mem:SI (plus:SI (match_dup 2)
  25265. + (const_int 16))))])]
  25266. + "XVECLEN (operands[0], 0) == 5 + 1"
  25267. + "MGETD\\t%3, %4, %5, %6, %7, [%1]\\t%@ (lodmr si OK)"
  25268. + [(set_attr "type" "fivex")
  25269. + (set_attr "memaccess" "load")
  25270. + (set_attr "rename" "no")])
  25271. +
  25272. +(define_insn "*ldmsi_4"
  25273. + [(match_parallel 0 "load_multiop"
  25274. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25275. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25276. + (const_int 16)))
  25277. + (set (match_operand:SI 3 "metag_hard_datareg_op" "=d")
  25278. + (mem:SI (match_dup 2)))
  25279. + (set (match_operand:SI 4 "metag_hard_datareg_op" "=d")
  25280. + (mem:SI (plus:SI (match_dup 2)
  25281. + (const_int 4))))
  25282. + (set (match_operand:SI 5 "metag_hard_datareg_op" "=d")
  25283. + (mem:SI (plus:SI (match_dup 2)
  25284. + (const_int 8))))
  25285. + (set (match_operand:SI 6 "metag_hard_datareg_op" "=d")
  25286. + (mem:SI (plus:SI (match_dup 2)
  25287. + (const_int 12))))])]
  25288. + "XVECLEN (operands[0], 0) == 4 + 1"
  25289. + "MGETD\\t%3, %4, %5, %6, [%1]\\t%@ (lodmr si OK)"
  25290. + [(set_attr "type" "fourx")
  25291. + (set_attr "memaccess" "load")
  25292. + (set_attr "rename" "no")])
  25293. +
  25294. +(define_insn "*ldmsi_3"
  25295. + [(match_parallel 0 "load_multiop"
  25296. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25297. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25298. + (const_int 12)))
  25299. + (set (match_operand:SI 3 "metag_hard_datareg_op" "=d")
  25300. + (mem:SI (match_dup 2)))
  25301. + (set (match_operand:SI 4 "metag_hard_datareg_op" "=d")
  25302. + (mem:SI (plus:SI (match_dup 2)
  25303. + (const_int 4))))
  25304. + (set (match_operand:SI 5 "metag_hard_datareg_op" "=d")
  25305. + (mem:SI (plus:SI (match_dup 2)
  25306. + (const_int 8))))])]
  25307. + "XVECLEN (operands[0], 0) == 3 + 1"
  25308. + "MGETD\\t%3, %4, %5, [%1]\\t%@ (lodmr si OK)"
  25309. + [(set_attr "type" "threex")
  25310. + (set_attr "memaccess" "load")
  25311. + (set_attr "rename" "no")])
  25312. +
  25313. +(define_insn "*ldmsi_2"
  25314. + [(match_parallel 0 "load_multiop"
  25315. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25316. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25317. + (const_int 8)))
  25318. + (set (match_operand:SI 3 "metag_hard_datareg_op" "=d")
  25319. + (mem:SI (match_dup 2)))
  25320. + (set (match_operand:SI 4 "metag_hard_datareg_op" "=d")
  25321. + (mem:SI (plus:SI (match_dup 2)
  25322. + (const_int 4))))])]
  25323. + "XVECLEN (operands[0], 0) == 2 + 1"
  25324. + "MGETD\\t%3, %4, [%1]\\t%@ (lodmr si OK)"
  25325. + [(set_attr "type" "twox")
  25326. + (set_attr "memaccess" "load")
  25327. + (set_attr "rename" "no")])
  25328. +
  25329. +;; stores DImode
  25330. +(define_insn "*stmdi_8"
  25331. + [(match_parallel 0 "store_multiop"
  25332. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25333. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25334. + (const_int 64)))
  25335. + (set (mem:DI (match_dup 2))
  25336. + (match_operand:DI 3 "metag_hard_datareg_op" "d"))
  25337. + (set (mem:DI (plus:SI (match_dup 2)
  25338. + (const_int 8)))
  25339. + (match_operand:DI 4 "metag_hard_datareg_op" "d"))
  25340. + (set (mem:DI (plus:SI (match_dup 2)
  25341. + (const_int 16)))
  25342. + (match_operand:DI 5 "metag_hard_datareg_op" "d"))
  25343. + (set (mem:DI (plus:SI (match_dup 2)
  25344. + (const_int 24)))
  25345. + (match_operand:DI 6 "metag_hard_datareg_op" "d"))
  25346. + (set (mem:DI (plus:SI (match_dup 2)
  25347. + (const_int 32)))
  25348. + (match_operand:DI 7 "metag_hard_datareg_op" "d"))
  25349. + (set (mem:DI (plus:SI (match_dup 2)
  25350. + (const_int 40)))
  25351. + (match_operand:DI 8 "metag_hard_datareg_op" "d"))
  25352. + (set (mem:DI (plus:SI (match_dup 2)
  25353. + (const_int 48)))
  25354. + (match_operand:DI 9 "metag_hard_datareg_op" "d"))
  25355. + (set (mem:DI (plus:SI (match_dup 2)
  25356. + (const_int 56)))
  25357. + (match_operand:DI 10 "metag_hard_datareg_op" "d"))])]
  25358. + "XVECLEN (operands[0], 0) == 8 + 1"
  25359. + "MSETL\\t[%1++], %3, %4, %5, %6, %7, %8, %9, %10\\t%@ (*stomr di OK)"
  25360. + [(set_attr "type" "fivex")
  25361. + (set_attr "memaccess" "store")
  25362. + (set_attr "rename" "no")])
  25363. +
  25364. +(define_insn "*stmdi_7"
  25365. + [(match_parallel 0 "store_multiop"
  25366. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25367. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25368. + (const_int 56)))
  25369. + (set (mem:DI (match_dup 2))
  25370. + (match_operand:DI 3 "metag_hard_datareg_op" "d"))
  25371. + (set (mem:DI (plus:SI (match_dup 2)
  25372. + (const_int 8)))
  25373. + (match_operand:DI 4 "metag_hard_datareg_op" "d"))
  25374. + (set (mem:DI (plus:SI (match_dup 2)
  25375. + (const_int 16)))
  25376. + (match_operand:DI 5 "metag_hard_datareg_op" "d"))
  25377. + (set (mem:DI (plus:SI (match_dup 2)
  25378. + (const_int 24)))
  25379. + (match_operand:DI 6 "metag_hard_datareg_op" "d"))
  25380. + (set (mem:DI (plus:SI (match_dup 2)
  25381. + (const_int 32)))
  25382. + (match_operand:DI 7 "metag_hard_datareg_op" "d"))
  25383. + (set (mem:DI (plus:SI (match_dup 2)
  25384. + (const_int 40)))
  25385. + (match_operand:DI 8 "metag_hard_datareg_op" "d"))
  25386. + (set (mem:DI (plus:SI (match_dup 2)
  25387. + (const_int 48)))
  25388. + (match_operand:DI 9 "metag_hard_datareg_op" "d"))])]
  25389. + "XVECLEN (operands[0], 0) == 7 + 1"
  25390. + "MSETL\\t[%1++], %3, %4, %5, %6, %7, %8, %9\\t%@ (*stomr di OK)"
  25391. + [(set_attr "type" "fivex")
  25392. + (set_attr "memaccess" "store")
  25393. + (set_attr "rename" "no")])
  25394. +
  25395. +(define_insn "*stmdi_6"
  25396. + [(match_parallel 0 "store_multiop"
  25397. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25398. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25399. + (const_int 48)))
  25400. + (set (mem:DI (match_dup 2))
  25401. + (match_operand:DI 3 "metag_hard_datareg_op" "d"))
  25402. + (set (mem:DI (plus:SI (match_dup 2)
  25403. + (const_int 8)))
  25404. + (match_operand:DI 4 "metag_hard_datareg_op" "d"))
  25405. + (set (mem:DI (plus:SI (match_dup 2)
  25406. + (const_int 16)))
  25407. + (match_operand:DI 5 "metag_hard_datareg_op" "d"))
  25408. + (set (mem:DI (plus:SI (match_dup 2)
  25409. + (const_int 24)))
  25410. + (match_operand:DI 6 "metag_hard_datareg_op" "d"))
  25411. + (set (mem:DI (plus:SI (match_dup 2)
  25412. + (const_int 32)))
  25413. + (match_operand:DI 7 "metag_hard_datareg_op" "d"))
  25414. + (set (mem:DI (plus:SI (match_dup 2)
  25415. + (const_int 40)))
  25416. + (match_operand:DI 8 "metag_hard_datareg_op" "d"))])]
  25417. + "XVECLEN (operands[0], 0) == 6 + 1"
  25418. + "MSETL\\t[%1++], %3, %4, %5, %6, %7, %8\\t%@ (*stomr di OK)"
  25419. + [(set_attr "type" "fivex")
  25420. + (set_attr "memaccess" "store")
  25421. + (set_attr "rename" "no")])
  25422. +
  25423. +(define_insn "*stmdi_5"
  25424. + [(match_parallel 0 "store_multiop"
  25425. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25426. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25427. + (const_int 40)))
  25428. + (set (mem:DI (match_dup 2))
  25429. + (match_operand:DI 3 "metag_hard_datareg_op" "d"))
  25430. + (set (mem:DI (plus:SI (match_dup 2)
  25431. + (const_int 8)))
  25432. + (match_operand:DI 4 "metag_hard_datareg_op" "d"))
  25433. + (set (mem:DI (plus:SI (match_dup 2)
  25434. + (const_int 16)))
  25435. + (match_operand:DI 5 "metag_hard_datareg_op" "d"))
  25436. + (set (mem:DI (plus:SI (match_dup 2)
  25437. + (const_int 24)))
  25438. + (match_operand:DI 6 "metag_hard_datareg_op" "d"))
  25439. + (set (mem:DI (plus:SI (match_dup 2)
  25440. + (const_int 32)))
  25441. + (match_operand:DI 7 "metag_hard_datareg_op" "d"))])]
  25442. + "XVECLEN (operands[0], 0) == 5 + 1"
  25443. + "MSETL\\t[%1++], %3, %4, %5, %6, %7\\t%@ (*stomr di OK)"
  25444. + [(set_attr "type" "fivex")
  25445. + (set_attr "memaccess" "store")
  25446. + (set_attr "rename" "no")])
  25447. +
  25448. +(define_insn "*stmdi_4"
  25449. + [(match_parallel 0 "store_multiop"
  25450. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25451. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25452. + (const_int 32)))
  25453. + (set (mem:DI (match_dup 2))
  25454. + (match_operand:DI 3 "metag_hard_datareg_op" "d"))
  25455. + (set (mem:DI (plus:SI (match_dup 2)
  25456. + (const_int 8)))
  25457. + (match_operand:DI 4 "metag_hard_datareg_op" "d"))
  25458. + (set (mem:DI (plus:SI (match_dup 2)
  25459. + (const_int 16)))
  25460. + (match_operand:DI 5 "metag_hard_datareg_op" "d"))
  25461. + (set (mem:DI (plus:SI (match_dup 2)
  25462. + (const_int 24)))
  25463. + (match_operand:DI 6 "metag_hard_datareg_op" "d"))])]
  25464. + "XVECLEN (operands[0], 0) == 4 + 1"
  25465. + "MSETL\\t[%1++], %3, %4, %5, %6\\t%@ (*stomr di OK)"
  25466. + [(set_attr "type" "fourx")
  25467. + (set_attr "memaccess" "store")
  25468. + (set_attr "rename" "no")])
  25469. +
  25470. +(define_insn "*stmdi_3"
  25471. + [(match_parallel 0 "store_multiop"
  25472. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25473. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25474. + (const_int 24)))
  25475. + (set (mem:DI (match_dup 2))
  25476. + (match_operand:DI 3 "metag_hard_datareg_op" "d"))
  25477. + (set (mem:DI (plus:SI (match_dup 2)
  25478. + (const_int 8)))
  25479. + (match_operand:DI 4 "metag_hard_datareg_op" "d"))
  25480. + (set (mem:DI (plus:SI (match_dup 2)
  25481. + (const_int 16)))
  25482. + (match_operand:DI 5 "metag_hard_datareg_op" "d"))])]
  25483. + "XVECLEN (operands[0], 0) == 3 + 1"
  25484. + "MSETL\\t[%1++], %3, %4, %5\\t%@ (*stomr di OK)"
  25485. + [(set_attr "type" "threex")
  25486. + (set_attr "memaccess" "store")
  25487. + (set_attr "rename" "no")])
  25488. +
  25489. +(define_insn "*stmdi_2"
  25490. + [(match_parallel 0 "store_multiop"
  25491. + [(set (match_operand:SI 1 "metag_reg_nofloat_op" "=da")
  25492. + (plus:SI (match_operand:SI 2 "metag_reg_nofloat_op" "1")
  25493. + (const_int 16)))
  25494. + (set (mem:DI (match_dup 2))
  25495. + (match_operand:DI 3 "metag_hard_datareg_op" "d"))
  25496. + (set (mem:DI (plus:SI (match_dup 2)
  25497. + (const_int 8)))
  25498. + (match_operand:DI 4 "metag_hard_datareg_op" "d"))])]
  25499. + "XVECLEN (operands[0], 0) == 2 + 1"
  25500. + "MSETL\\t[%1++], %3, %4\\t%@ (*stomr di OK)"
  25501. + [(set_attr "type" "twox")
  25502. + (set_attr "memaccess" "store")
  25503. + (set_attr "rename" "no")])
  25504. +
  25505. +;; Stores SImode
  25506. +
  25507. +(define_insn "*stmsi_5"
  25508. + [(match_parallel 0 "store_multiop"
  25509. + [(set (match_operand:SI 1 "metag_addrreg_op" "=a")
  25510. + (plus:SI (match_operand:SI 2 "metag_addrreg_op" "1")
  25511. + (const_int 20)))
  25512. + (set (mem:SI (match_dup 2))
  25513. + (match_operand:SI 3 "metag_hard_datareg_op" "d"))
  25514. + (set (mem:SI (plus:SI (match_dup 2)
  25515. + (const_int 4)))
  25516. + (match_operand:SI 4 "metag_hard_datareg_op" "d"))
  25517. + (set (mem:SI (plus:SI (match_dup 2)
  25518. + (const_int 8)))
  25519. + (match_operand:SI 5 "metag_hard_datareg_op" "d"))
  25520. + (set (mem:SI (plus:SI (match_dup 2)
  25521. + (const_int 12)))
  25522. + (match_operand:SI 6 "metag_hard_datareg_op" "d"))
  25523. + (set (mem:SI (plus:SI (match_dup 2)
  25524. + (const_int 16)))
  25525. + (match_operand:SI 7 "metag_hard_datareg_op" "d"))])]
  25526. + "XVECLEN (operands[0], 0) == 5 + 1"
  25527. + "MSETD\\t[%1], %3, %4, %5, %6, %7\\t%@ (*stomr si OK)"
  25528. + [(set_attr "type" "fivex")
  25529. + (set_attr "memaccess" "store")
  25530. + (set_attr "rename" "no")])
  25531. +
  25532. +(define_insn "*stmsi_4"
  25533. + [(match_parallel 0 "store_multiop"
  25534. + [(set (match_operand:SI 1 "metag_addrreg_op" "=a")
  25535. + (plus:SI (match_operand:SI 2 "metag_addrreg_op" "1")
  25536. + (const_int 16)))
  25537. + (set (mem:SI (match_dup 2))
  25538. + (match_operand:SI 3 "metag_hard_datareg_op" "d"))
  25539. + (set (mem:SI (plus:SI (match_dup 2)
  25540. + (const_int 4)))
  25541. + (match_operand:SI 4 "metag_hard_datareg_op" "d"))
  25542. + (set (mem:SI (plus:SI (match_dup 2)
  25543. + (const_int 8)))
  25544. + (match_operand:SI 5 "metag_hard_datareg_op" "d"))
  25545. + (set (mem:SI (plus:SI (match_dup 2)
  25546. + (const_int 12)))
  25547. + (match_operand:SI 6 "metag_hard_datareg_op" "d"))])]
  25548. + "XVECLEN (operands[0], 0) == 4 + 1"
  25549. + "MSETD\\t[%1], %3, %4, %5, %6\\t%@ (*stomr si OK)"
  25550. + [(set_attr "type" "fourx")
  25551. + (set_attr "memaccess" "store")
  25552. + (set_attr "rename" "no")])
  25553. +
  25554. +(define_insn "*stmsi_3"
  25555. + [(match_parallel 0 "store_multiop"
  25556. + [(set (match_operand:SI 1 "metag_addrreg_op" "=a")
  25557. + (plus:SI (match_operand:SI 2 "metag_addrreg_op" "1")
  25558. + (const_int 12)))
  25559. + (set (mem:SI (match_dup 2))
  25560. + (match_operand:SI 3 "metag_hard_datareg_op" "d"))
  25561. + (set (mem:SI (plus:SI (match_dup 2)
  25562. + (const_int 4)))
  25563. + (match_operand:SI 4 "metag_hard_datareg_op" "d"))
  25564. + (set (mem:SI (plus:SI (match_dup 2)
  25565. + (const_int 8)))
  25566. + (match_operand:SI 5 "metag_hard_datareg_op" "d"))])]
  25567. + "XVECLEN (operands[0], 0) == 3 + 1"
  25568. + "MSETD\\t[%1], %3, %4, %5\\t%@ (*stomr si OK)"
  25569. + [(set_attr "type" "threex")
  25570. + (set_attr "memaccess" "store")
  25571. + (set_attr "rename" "no")])
  25572. +
  25573. +(define_insn "*stmsi_2"
  25574. + [(match_parallel 0 "store_multiop"
  25575. + [(set (match_operand:SI 1 "metag_addrreg_op" "=a")
  25576. + (plus:SI (match_operand:SI 2 "metag_addrreg_op" "1")
  25577. + (const_int 8)))
  25578. + (set (mem:SI (match_dup 2))
  25579. + (match_operand:SI 3 "metag_hard_datareg_op" "d"))
  25580. + (set (mem:SI (plus:SI (match_dup 2)
  25581. + (const_int 4)))
  25582. + (match_operand:SI 4 "metag_hard_datareg_op" "d"))])]
  25583. + "XVECLEN (operands[0], 0) == 2 + 1"
  25584. + "MSETD\\t[%1], %3, %4\\t%@ (*stomr si OK)"
  25585. + [(set_attr "type" "twox")
  25586. + (set_attr "memaccess" "store")
  25587. + (set_attr "rename" "no")])
  25588. +
  25589. +;; add instructions
  25590. +
  25591. +;; Addition insns.
  25592. +
  25593. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  25594. +;; adddi3 ;;
  25595. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  25596. +(define_expand "adddi3"
  25597. + [(parallel
  25598. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "")
  25599. + (plus:DI (match_operand:DI 1 "metag_reg_nofloat_op" "")
  25600. + (match_operand:DI 2 "metag_reg_nofloat_op" "")))
  25601. + (clobber (reg:CC CC_REG))])]
  25602. + ""
  25603. + "")
  25604. +
  25605. +(define_insn "*adddi3_dsp"
  25606. + [(set (match_operand:DI 0 "metag_datareg_op" "=d")
  25607. + (plus:DI (match_operand:DI 1 "metag_datareg_op" "%d")
  25608. + (match_operand:DI 2 "metag_datareg_op" "d")))
  25609. + (clobber (reg:CC CC_REG))]
  25610. + "TARGET_DSP"
  25611. + "DL\\tADDS\\t%0, %1, %2\\t%@ (*ADD\\t%t0, %t1, %t2)\;ADDCS\\t%t0, %t0, #1"
  25612. + [(set_attr "type" "two")
  25613. + (set_attr "ccstate" "ccx")])
  25614. +
  25615. +(define_insn_and_split "*adddi3"
  25616. + [(set (match_operand:DI 0 "metag_datareg_op" "=d")
  25617. + (plus:DI (match_operand:DI 1 "metag_datareg_op" "%d")
  25618. + (match_operand:DI 2 "metag_datareg_op" "d")))
  25619. + (clobber (reg:CC CC_REG))]
  25620. + ""
  25621. + "#"
  25622. + "SPLIT_EARLY"
  25623. + [(parallel
  25624. + [(set (reg:CC_NOOV CC_REG)
  25625. + (compare:CC_NOOV
  25626. + (plus:SI (match_dup 5)
  25627. + (match_dup 7))
  25628. + (const_int 0)))
  25629. + (set (match_dup 3)
  25630. + (plus:SI (match_dup 5)
  25631. + (match_dup 7)))])
  25632. + (set (match_dup 4)
  25633. + (plus:SI (match_dup 6)
  25634. + (match_dup 8)))
  25635. + (set (match_dup 4)
  25636. + (if_then_else:SI (ltu (reg:CC_NOOV CC_REG)
  25637. + (const_int 0))
  25638. + (plus:SI (match_dup 4)
  25639. + (const_int 1))
  25640. + (match_dup 4)))]
  25641. + {
  25642. + if (reload_completed)
  25643. + {
  25644. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]));
  25645. + operands[4] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  25646. +
  25647. + operands[5] = gen_rtx_REG (SImode, REGNO (operands[1]));
  25648. + operands[6] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  25649. +
  25650. + operands[7] = gen_rtx_REG (SImode, REGNO (operands[2]));
  25651. + operands[8] = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
  25652. + }
  25653. + else
  25654. + {
  25655. + operands[3] = gen_rtx_SUBREG (SImode, operands[0], 0);
  25656. + operands[4] = gen_rtx_SUBREG (SImode, operands[0], UNITS_PER_WORD);
  25657. +
  25658. + operands[5] = gen_rtx_SUBREG (SImode, operands[1], 0);
  25659. + operands[6] = gen_rtx_SUBREG (SImode, operands[1], UNITS_PER_WORD);
  25660. +
  25661. + operands[7] = gen_rtx_SUBREG (SImode, operands[2], 0);
  25662. + operands[8] = gen_rtx_SUBREG (SImode, operands[2], UNITS_PER_WORD);
  25663. + }
  25664. + }
  25665. + [(set_attr "type" "three")
  25666. + (set_attr "ccstate" "ccx")])
  25667. +
  25668. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  25669. +;; addsi3 is made up of many parts.. ;;
  25670. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  25671. +(define_expand "addsi3"
  25672. + [(set (match_operand:SI 0 "metag_register_op" "")
  25673. + (plus:SI (match_operand:SI 1 "metag_register_op" "")
  25674. + (match_operand:SI 2 "metag_regorint_op" "")))]
  25675. + ""
  25676. + {
  25677. + if (metag_frame_related_rtx (operands[2]))
  25678. + {
  25679. + /* Put the magic frame registers first */
  25680. + rtx temp = operands[1];
  25681. +
  25682. + operands[1] = operands[2];
  25683. + operands[2] = temp;
  25684. + }
  25685. +
  25686. + if (!reload_completed
  25687. + && !reload_in_progress
  25688. + && metag_frame_related_rtx (operands[1]))
  25689. + {
  25690. + /* Ensure reg+reg adds do not combine regs that may be eliminated */
  25691. + operands[1] = force_reg (SImode, operands[1]);
  25692. + }
  25693. + }
  25694. +)
  25695. +
  25696. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  25697. +;; these are the addsi3 parts.. ;;
  25698. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  25699. +
  25700. +;; control register = datareg + smallint
  25701. +(define_insn "*add_si_cdi"
  25702. + [(set (match_operand:SI 0 "metag_txrpt_op" "=Wx,Wx")
  25703. + (plus:SI (match_operand:SI 1 "metag_datareg_op" "%d, d")
  25704. + (match_operand:SI 2 "metag_smallint_op" "K, P")))]
  25705. + ""
  25706. + "@
  25707. + ADD\\t%0, %1, %2\\t%@ (*add si cdK OK)
  25708. + SUB\\t%0, %1, #%n2\\t%@ (*add si cdP OK)"
  25709. + [(set_attr "type" "slow,slow")])
  25710. +
  25711. +;; control register = reg +/- reg
  25712. +(define_insn "*sub_si_crr"
  25713. + [(set (match_operand:SI 0 "metag_txrpt_op" "=Wx,Wx,Wx,Wx")
  25714. + (minus:SI (match_operand:SI 1 "metag_regnofrm_op" "e, f, h, l")
  25715. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l")))]
  25716. + ""
  25717. + "SUB\\t%0, %1, %2\\t%@ (*sub si crr OK)"
  25718. + [(set_attr "type" "slow,slow,slow,slow")])
  25719. +
  25720. +(define_insn "*add_si_crr"
  25721. + [(set (match_operand:SI 0 "metag_txrpt_op" "=Wx,Wx,Wx,Wx")
  25722. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e, f, h, l")
  25723. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l")))]
  25724. + ""
  25725. + "ADD\\t%0, %1, %2\\t%@ (*add si crr OK)"
  25726. + [(set_attr "type" "slow,slow,slow,slow")])
  25727. +
  25728. +;; register + register ops - generic case
  25729. +(define_insn "*add_si_rrr"
  25730. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,h,l,da,da,da,da")
  25731. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e,f,h,l,e, f, h, l")
  25732. + (match_operand:SI 2 "metag_regnofrm_op" "e,f,h,l,e, f, h, l")))]
  25733. + "!TARGET_METAC_1_1"
  25734. + "ADD%?\\t%0, %1, %2"
  25735. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  25736. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes,yes")
  25737. + (set_attr "predicable" "yes")])
  25738. +
  25739. +;; register + register ops - v1.1 case
  25740. +(define_insn "*add_si_rrb_1_1"
  25741. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e, f, h, l, da,da,da,da")
  25742. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e, f, h, l, e, f, h, l")
  25743. + (match_operand:SI 2 "metag_regnofrm_op" "be,bf,bh,bl,be,bf,bh,bl")))]
  25744. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  25745. + "ADD%?\\t%0, %1, %2"
  25746. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  25747. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes,yes")
  25748. + (set_attr "predicable" "yes")])
  25749. +
  25750. +(define_insn "*add_si_rrb_1_1_if_<mode>"
  25751. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e, f, h, l, da,da,da,da")
  25752. + (if_then_else:SI (match_operator 1 "comparison_operator"
  25753. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  25754. + (const_int 0)])
  25755. + (plus:SI (match_operand:SI 3 "metag_regnofrm_op" "%e, f, h, l, e, f, h, l")
  25756. + (match_operand:SI 4 "metag_regnofrm_op" "be,bf,bh,bl,be,bf,bh,bl"))
  25757. + (match_operand:SI 5 "metag_reg_nofloat_op" "0, 0, 0, 0, 0, 0, 0, 0")))]
  25758. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  25759. + "ADD%z1\\t%0, %3, %4"
  25760. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  25761. + (set_attr "ccstate" "xcc")])
  25762. +
  25763. +;; register + register ops - minim case
  25764. +(define_insn "*add_si_rrb_minim"
  25765. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,!e, f,!f, h,!h, l,!l, da,!da,da,!da,da,!da,da,!da")
  25766. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e, e, f, f, h, h, l, l, e, e, f, f, h, h, l, l")
  25767. + (match_operand:SI 2 "metag_regnofrm_op" "e, be,f, bf,h, bh,l, bl,e, be,f, bf,h, bh,l, bl")))]
  25768. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  25769. + "ADD%?\\t%0, %1, %2"
  25770. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,fast,slow,slow,slow,slow,slow,slow,slow,slow")
  25771. + (set_attr "cond" "yes")
  25772. + (set_attr "predicable" "yes")])
  25773. +
  25774. +(define_insn "*add_si_rrb_minim_if_<mode>"
  25775. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,!e, f,!f, h,!h, l,!l, da,!da,da,!da,da,!da,da,!da")
  25776. + (if_then_else:SI (match_operator 1 "comparison_operator"
  25777. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  25778. + (const_int 0)])
  25779. + (plus:SI (match_operand:SI 3 "metag_regnofrm_op" "%e, e, f, f, h, h, l, l, e, e, f, f, h, h, l, l")
  25780. + (match_operand:SI 4 "metag_regnofrm_op" "e, be,f, bf,h, bh,l, bl,e, be,f, bf,h, bh,l, bl"))
  25781. + (match_operand:SI 5 "metag_reg_nofloat_op" "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0")))]
  25782. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  25783. + "ADD%z1\\t%0, %3, %4"
  25784. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,fast,slow,slow,slow,slow,slow,slow,slow,slow")
  25785. + (set_attr "ccstate" "xcc")])
  25786. +
  25787. +;; Seperate stack frame related register+register adds
  25788. +(define_insn "*add_si_index_frame"
  25789. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,da,!da")
  25790. + (plus:SI (match_operand:SI 1 "metag_regframe_op" "%h,h, h")
  25791. + (match_operand:SI 2 "metag_regnofrm_op" "h,h, bh")))]
  25792. + "!TARGET_METAC_1_1"
  25793. + "ADD%?\\t%0, %1, %2\\t%@ (*add si rfrmh OK)"
  25794. + [(set_attr "type" "fast,slow,three")
  25795. + (set_attr "cond" "yes,yes,yes")
  25796. + (set_attr "predicable" "yes")])
  25797. +
  25798. +;; Sadly instantiate_virtual_regs can be really dumb some times
  25799. +(define_insn "*add_si_index_frame2"
  25800. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,da,!da")
  25801. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%h,h, h")
  25802. + (match_operand:SI 2 "metag_regframe_op" "h,h, bh")))]
  25803. + "!TARGET_METAC_1_1"
  25804. + "ADD%?\\t%0, %1, %2\\t%@ (*add si rhfrm OK)"
  25805. + [(set_attr "type" "fast,slow,three")
  25806. + (set_attr "cond" "yes,yes,yes")
  25807. + (set_attr "predicable" "yes")])
  25808. +
  25809. +;; Seperate stack frame related register+register adds - v1.1 case
  25810. +(define_insn "*add_si_index_frame_1_1"
  25811. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h, da")
  25812. + (plus:SI (match_operand:SI 1 "metag_regframe_op" "%h, h")
  25813. + (match_operand:SI 2 "metag_regnofrm_op" "bh,bh")))]
  25814. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  25815. + "ADD%?\\t%0, %1, %2\\t%@ (*add si rfrmb OK)"
  25816. + [(set_attr "type" "fast,slow")
  25817. + (set_attr "cond" "yes,yes")
  25818. + (set_attr "predicable" "yes")])
  25819. +
  25820. +;; Seperate stack frame related register+register adds - minim case
  25821. +(define_insn "*add_si_index_frame_minim"
  25822. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,!h, da,!da")
  25823. + (plus:SI (match_operand:SI 1 "metag_regframe_op" "%h, h, h, h")
  25824. + (match_operand:SI 2 "metag_regnofrm_op" "h, bh,h, bh")))]
  25825. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  25826. + "ADD%?\\t%0, %1, %2\\t%@ (*add si rfrmb OK)"
  25827. + [(set_attr "type" "fast,fast,slow,slow")
  25828. + (set_attr "cond" "yes")
  25829. + (set_attr "predicable" "yes")])
  25830. +
  25831. +;; Sadly instantiate_virtual_regs can be really dumb some times - v1.1 case
  25832. +(define_insn "*add_si_index_frame2_1_1"
  25833. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h, da")
  25834. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%h, h")
  25835. + (match_operand:SI 2 "metag_regframe_op" "bh,bh")))]
  25836. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  25837. + "ADD%?\\t%0, %1, %2\\t%@ (*add si rbfrm OK)"
  25838. + [(set_attr "type" "fast,slow")
  25839. + (set_attr "cond" "yes,yes")
  25840. + (set_attr "predicable" "yes")])
  25841. +
  25842. +;; Sadly instantiate_virtual_regs can be really dumb some times - minim case
  25843. +(define_insn "*add_si_index_frame2_minim"
  25844. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,!h, da,!da")
  25845. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%h, h, h, h")
  25846. + (match_operand:SI 2 "metag_regframe_op" "h, bh,h, bh")))]
  25847. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  25848. + "ADD%?\\t%0, %1, %2\\t%@ (*add si rbfrm OK)"
  25849. + [(set_attr "type" "fast,fast,slow,slow")
  25850. + (set_attr "cond" "yes")
  25851. + (set_attr "predicable" "yes")])
  25852. +
  25853. +;; spill_frame - cannot really add frame value to something else
  25854. +(define_split
  25855. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  25856. + (plus:SI (match_operand:SI 1 "metag_regframe_op" "")
  25857. + (match_operand:SI 2 "metag_reg_nofloat_op" "")))]
  25858. + "!TARGET_METAC_1_1
  25859. + && reload_completed
  25860. + && METAG_REGNO_REG_CLASS (REGNO (operands[2])) != A0_REGS"
  25861. + [(set (match_dup 3)
  25862. + (match_dup 2))
  25863. + (set (match_dup 0)
  25864. + (plus:SI (match_dup 1)
  25865. + (match_dup 3)))]
  25866. + {
  25867. + gcc_assert (A0_SCRATCH != INVALID_REGNUM && fixed_regs[A0_SCRATCH]);
  25868. + operands[3] = gen_rtx_REG (SImode, A0_SCRATCH);
  25869. + }
  25870. +)
  25871. +
  25872. +(define_split
  25873. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  25874. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  25875. + (match_operand:SI 2 "metag_regframe_op" "")))]
  25876. + "!TARGET_METAC_1_1
  25877. + && reload_completed
  25878. + && METAG_REGNO_REG_CLASS (REGNO (operands[1])) != A0_REGS"
  25879. + [(set (match_dup 3)
  25880. + (match_dup 1))
  25881. + (set (match_dup 0)
  25882. + (plus:SI (match_dup 3)
  25883. + (match_dup 2)))]
  25884. + {
  25885. + gcc_assert (A0_SCRATCH != INVALID_REGNUM && fixed_regs[A0_SCRATCH]);
  25886. + operands[3] = gen_rtx_REG (SImode, A0_SCRATCH);
  25887. + }
  25888. +)
  25889. +
  25890. +;; register + immediate ops
  25891. +(define_insn "*add_si_rri"
  25892. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,e,f,f,h,h,l,l,da,da,da,da,da,da,da,da")
  25893. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,e,f,f,h,h,l,l,d, d, a, a, 0, 0, 0, 0")
  25894. + (match_operand:SI 2 "const_int_operand" "K,P,K,P,K,P,K,P,K, P, K, P, I, J, O3,i")))]
  25895. + "!TARGET_MINIM_CORE"
  25896. + "@
  25897. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si eeK OK)
  25898. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si eeP)
  25899. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si ffK OK)
  25900. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si ffP)
  25901. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si hhK OK)
  25902. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si hhP OK)
  25903. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si llK OK)
  25904. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si llP OK)
  25905. + ADD\\t%0, %1, %2\\t\\t%@ (*add si rdK OK)
  25906. + SUB\\t%0, %1, #%n2\\t\\t%@ (*add si rdP OK)
  25907. + ADD\\t%0, %1, %2\\t\\t%@ (*add si daaK OK)
  25908. + SUB\\t%0, %1, #%n2\\t\\t%@ (*add si daaP OK)
  25909. + ADD\\t%0, %1, %2\\t%@ (*add si da0I OK)
  25910. + ADDT\\t%0, %1, #HI(%c2)\\t%@ (*add si da0J OK)
  25911. + ADDT\\t%0, %1, #LO(%c2)\\t%@ (*add si da03 OK)
  25912. + #"
  25913. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,fast,slow,slow,slow,slow,fast,fast,fast,two")
  25914. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes,yes,no,no,no,no,no,no,no,no")])
  25915. +
  25916. +;; register + immediate ops
  25917. +(define_insn "*add_si_rri"
  25918. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da,da,!e,!e,!f,!f,!h,!h,!l,!l,da,da,da,da,da,da,da,da")
  25919. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%0, 0, e, e, f, f, h, h, l, l,d, d, a, a, 0, 0, 0, 0")
  25920. + (match_operand:SI 2 "const_int_operand" "K, P, K, P, K, P, K, P, K, P,K, P, K, P, I, J, O3,i")))]
  25921. + "TARGET_MINIM_CORE"
  25922. + "@
  25923. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si r0K OK)
  25924. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si r0P)
  25925. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si eeK OK)
  25926. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si eeP)
  25927. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si ffK OK)
  25928. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si ffP)
  25929. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si hhK OK)
  25930. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si hhP OK)
  25931. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si llK OK)
  25932. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si llP OK)
  25933. + ADD\\t%0, %1, %2\\t\\t%@ (*add si rdK OK)
  25934. + SUB\\t%0, %1, #%n2\\t\\t%@ (*add si rdP OK)
  25935. + ADD\\t%0, %1, %2\\t\\t%@ (*add si daaK OK)
  25936. + SUB\\t%0, %1, #%n2\\t\\t%@ (*add si daaP OK)
  25937. + ADD\\t%0, %1, %2\\t%@ (*add si da0I OK)
  25938. + ADDT\\t%0, %1, #HI(%c2)\\t%@ (*add si da0J OK)
  25939. + ADDT\\t%0, %1, #LO(%c2)\\t%@ (*add si da03 OK)
  25940. + #"
  25941. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,fast,fast,fast,slow,slow,slow,slow,fast,fast,fast,two")
  25942. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes,yes,yes,yes,no,no,no,no,no,no,no,no")])
  25943. +
  25944. +;; Split the above add_si_rri if it needs more than one insn
  25945. +(define_split
  25946. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  25947. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  25948. + (match_operand:SI 2 "const_int_operand" "")))]
  25949. + "reload_completed
  25950. + && REGNO (operands[0]) == REGNO (operands[1]) && !METAG_CONST_OK_FOR_LETTERS_KPIJO3 (operands[2])"
  25951. + [(set (match_dup 0)
  25952. + (plus:SI (match_dup 1)
  25953. + (match_dup 3)))
  25954. + (set (match_dup 0)
  25955. + (plus:SI (match_dup 0)
  25956. + (match_dup 4)))]
  25957. + {
  25958. + HOST_WIDE_INT value = INTVAL (operands[2]);
  25959. + HOST_WIDE_INT ival;
  25960. +
  25961. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  25962. + operands[3] = GEN_INT (ival);
  25963. +
  25964. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  25965. + operands[4] = GEN_INT (ival);
  25966. + }
  25967. +)
  25968. +
  25969. +;; conditional version for specific cases of add_si_rri
  25970. +(define_insn "*cond_<mode>_add_si_rri"
  25971. + [(cond_exec
  25972. + (match_operator 3 "comparison_operator"
  25973. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  25974. + (const_int 0)])
  25975. + (set (match_operand:SI 0 "metag_hard_genreg_op" "=e,e,f,f,h,h,l,l")
  25976. + (plus:SI (match_operand:SI 1 "metag_hard_genreg_op" "%e,e,f,f,h,h,l,l")
  25977. + (match_operand:SI 2 "metag_KP_operand" "K,P,K,P,K,P,K,P"))))]
  25978. + "reload_completed
  25979. + && metag_same_regclass_p (operands[0], operands[1])"
  25980. + "@
  25981. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si eeK OK)
  25982. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si eeP)
  25983. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si ffK OK)
  25984. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si ffP)
  25985. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si hhK OK)
  25986. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si hhP OK)
  25987. + ADD%?\\t%0, %1, %2\\t\\t%@ (*add si llK OK)
  25988. + SUB%?\\t%0, %1, #%n2\\t\\t%@ (*add si llP OK)"
  25989. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,fast")
  25990. + (set_attr "cond" "no")])
  25991. +
  25992. +(define_insn_and_split"*adds_si_neg_<mode>_rr"
  25993. + [(set (reg:<MODE> CC_REG)
  25994. + (compare:CCZNC
  25995. + (match_operand:SI 1 "metag_datareg_op" "e, f, e, f")
  25996. + (neg:SI (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))))
  25997. + (clobber (match_scratch:SI 0 "=e, f, r, r"))]
  25998. + "TARGET_METAC_1_1"
  25999. + "#"
  26000. + "&& reload_completed"
  26001. + [(parallel
  26002. + [(set (reg:<MODE> CC_REG)
  26003. + (compare:<MODE>
  26004. + (plus:SI (match_dup 1)
  26005. + (match_dup 2))
  26006. + (const_int 0)))
  26007. + (set (match_dup 0)
  26008. + (plus:SI (match_dup 1)
  26009. + (match_dup 2)))])]
  26010. + ""
  26011. + [(set_attr "type" "fast")
  26012. + (set_attr "ccstate" "set")])
  26013. +
  26014. +;; register + register|immediate ops that set the flags
  26015. +(define_insn "*adds_<mode>_si_rrr"
  26016. + [(set (reg:<MODE> CC_REG)
  26017. + (compare:CCZNC
  26018. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e,f,e,f")
  26019. + (match_operand:SI 2 "metag_regnofrm_op" "e,f,e,f"))
  26020. + (const_int 0)))
  26021. + (set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  26022. + (plus:SI (match_dup 1)
  26023. + (match_dup 2)))]
  26024. + "!TARGET_METAC_1_1"
  26025. + "ADDS\\t%0, %1, %2\\t%@ (*adds si rrr OK)"
  26026. + [(set_attr "type" "fast,fast,slow,slow")
  26027. + (set_attr "ccstate" "set,set,set,set")])
  26028. +
  26029. +;; register + register|immediate ops that set the flags - v1.1 case
  26030. +(define_insn "*adds_<mode>_si_rrr_1_1"
  26031. + [(set (reg:<MODE> CC_REG)
  26032. + (compare:CCZNC
  26033. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e, f, e, f")
  26034. + (match_operand:SI 2 "metag_regnofrm_op" "be,bf,be,bf"))
  26035. + (const_int 0)))
  26036. + (set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  26037. + (plus:SI (match_dup 1)
  26038. + (match_dup 2)))]
  26039. + "TARGET_METAC_1_1"
  26040. + "ADDS\\t%0, %1, %2\\t%@ (*adds si rrr OK)"
  26041. + [(set_attr "type" "fast,fast,slow,slow")
  26042. + (set_attr "ccstate" "set,set,set,set")])
  26043. +
  26044. +(define_insn_and_split "*adds_si_r_<mode>_symglobal_1_1"
  26045. + [(set (reg:<MODE> CC_REG)
  26046. + (compare:CCZNC
  26047. + (match_operand:SI 1 "metag_symglobal_op" "")
  26048. + (const_int 0)))
  26049. + (set (match_operand:SI 0 "metag_datareg_op" "=d")
  26050. + (match_dup 1))]
  26051. + "TARGET_METAC_1_1"
  26052. + "#"
  26053. + "&& reload_completed"
  26054. + [(set (match_dup 0)
  26055. + (high:SI (match_dup 1)))
  26056. + (parallel
  26057. + [(set (reg:<MODE> CC_REG)
  26058. + (compare:<MODE>
  26059. + (lo_sum:SI (match_dup 0)
  26060. + (match_dup 1))
  26061. + (const_int 0)))
  26062. + (set (match_dup 0)
  26063. + (lo_sum:SI (match_dup 0)
  26064. + (match_dup 1)))])]
  26065. + ""
  26066. + [(set_attr "type" "fast")
  26067. + (set_attr "ccstate" "set")])
  26068. +
  26069. +(define_insn "*adds_<mode>_si_txrpt_ri"
  26070. + [(set (reg:<MODE> CC_REG)
  26071. + (compare:CCZNC
  26072. + (plus:SI (match_operand:SI 1 "metag_datareg_op" "%d, d")
  26073. + (match_operand:SI 2 "metag_smallint_op" "K, P"))
  26074. + (const_int 0)))
  26075. + (set (match_operand:SI 0 "metag_txrpt_op" "=Wx,Wx")
  26076. + (plus:SI (match_dup 1)
  26077. + (match_dup 2)))]
  26078. + "reload_completed"
  26079. + "@
  26080. + ADDS\\t%0, %1, #%2
  26081. + SUBS\\t%0, %1, #%n2"
  26082. + [(set_attr "type" "fast,fast")
  26083. + (set_attr "ccstate" "set,set")])
  26084. +
  26085. +(define_insn "*adds_<mode>_si_rri"
  26086. + [(set (reg:<MODE> CC_REG)
  26087. + (compare:CCZNC
  26088. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,e,f,f,d,d,0,0,0, 0")
  26089. + (match_operand:SI 2 "const_int_operand" "K,P,K,P,K,P,I,J,O3,i"))
  26090. + (const_int 0)))
  26091. + (set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,d,d,d, d")
  26092. + (plus:SI (match_dup 1)
  26093. + (match_dup 2)))]
  26094. + ""
  26095. + "@
  26096. + ADDS\\t%0, %1, %2\\t\\t%@ (*adds si eeK OK)
  26097. + SUBS\\t%0, %1, #%n2\\t\\t%@ (*adds si eeP OK)
  26098. + ADDS\\t%0, %1, %2\\t\\t%@ (*adds si ffK OK)
  26099. + SUBS\\t%0, %1, #%n2\\t\\t%@ (*adds si ffP OK)
  26100. + ADDS\\t%0, %1, %2\\t\\t%@ (*adds si rdK OK)
  26101. + SUBS\\t%0, %1, #%n2\\t\\t%@ (*adds si rdP OK)
  26102. + ADDS\\t%0, %1, %2\\t%@ (*adds si d0I OK)
  26103. + ADDST\\t%0, %1, #HI(%c2)\\t%@ (*adds si d0J OK)
  26104. + ADDS\\t%0, %1, #LO(%c2)\\t%@ (*adds si d0O3 OK)
  26105. + #"
  26106. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,fast,fast,fast,two")
  26107. + (set_attr "ccstate" "set,set,set,set,set,set,set,set,set,fastset")])
  26108. +
  26109. +;; Split the above insn if it needs more than one insn
  26110. +(define_split
  26111. + [(set (reg:<MODE> CC_REG)
  26112. + (compare:CCZNC
  26113. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26114. + (match_operand:SI 2 "const_int_operand" ""))
  26115. + (const_int 0)))
  26116. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26117. + (plus:SI (match_dup 1)
  26118. + (match_dup 2)))]
  26119. + "reload_completed
  26120. + && REGNO (operands[0]) == REGNO (operands[1]) && !METAG_CONST_OK_FOR_LETTERS_KPIJO3 (operands[2])"
  26121. + [(set (match_dup 0)
  26122. + (plus:SI (match_dup 1)
  26123. + (match_dup 3)))
  26124. + (parallel
  26125. + [(set (reg:<MODE> CC_REG)
  26126. + (compare:<MODE>
  26127. + (plus:SI (match_dup 0)
  26128. + (match_dup 4))
  26129. + (const_int 0)))
  26130. + (set (match_dup 0)
  26131. + (plus:SI (match_dup 0)
  26132. + (match_dup 4)))])]
  26133. + {
  26134. + HOST_WIDE_INT value = INTVAL (operands[2]);
  26135. + HOST_WIDE_INT ival;
  26136. +
  26137. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  26138. + operands[3] = GEN_INT (ival);
  26139. +
  26140. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  26141. + operands[4] = GEN_INT (ival);
  26142. + }
  26143. +)
  26144. +
  26145. +;; register + register|immediate ops that set the flags using a scratch
  26146. +(define_insn "*tadds_<mode>_si_rrr"
  26147. + [(set (reg:<MODE> CC_REG)
  26148. + (compare:CCZNC
  26149. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e,f,e,f")
  26150. + (match_operand:SI 2 "metag_regnofrm_op" "e,f,e,f"))
  26151. + (const_int 0)))
  26152. + (clobber (match_scratch:SI 0 "=e,f,r,r"))]
  26153. + "!TARGET_METAC_1_1"
  26154. + "ADDS\\t%0, %1, %2\\t%@ (*tadd si rrr OK)"
  26155. + [(set_attr "type" "fast,fast,slow,slow")
  26156. + (set_attr "ccstate" "set,set,set,set")])
  26157. +
  26158. +;; register + register|immediate ops that set the flags using a scratch - v1.1
  26159. +(define_insn "*tadds_<mode>_si_rrr_1_1"
  26160. + [(set (reg:<MODE> CC_REG)
  26161. + (compare:CCZNC
  26162. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%e, f, e, f")
  26163. + (match_operand:SI 2 "metag_regnofrm_op" "be,bf,be,bf"))
  26164. + (const_int 0)))
  26165. + (clobber (match_scratch:SI 0 "=e, f, r, r"))]
  26166. + "TARGET_METAC_1_1"
  26167. + "ADDS\\t%0, %1, %2\\t%@ (*tadd si rrb OK)"
  26168. + [(set_attr "type" "fast,fast,slow,slow")
  26169. + (set_attr "ccstate" "set,set,set,set")])
  26170. +
  26171. +(define_insn "*tadds_rr_cc_noov_address_1_1"
  26172. + [(set (reg:<MODE> CC_REG)
  26173. + (compare:CCZNC
  26174. + (lo_sum:SI (match_operand:SI 1 "metag_datareg_op" "0")
  26175. + (match_operand:SI 2 "code_address" ""))
  26176. + (const_int 0)))
  26177. + (set (match_operand:SI 0 "metag_datareg_op" "=d")
  26178. + (lo_sum:SI (match_dup 1)
  26179. + (match_dup 2)))]
  26180. + "TARGET_METAC_1_1"
  26181. + "ADDS\\t%0, %1, #LO(%c2)"
  26182. + [(set_attr "type" "fast")
  26183. + (set_attr "ccstate" "set")])
  26184. +
  26185. +(define_insn_and_split "*tadds_si_cc_noov_address"
  26186. + [(set (reg:<MODE> CC_REG)
  26187. + (compare:CCZNC
  26188. + (match_operand:SI 1 "code_address" "")
  26189. + (const_int 0)))
  26190. + (clobber (match_scratch:SI 0 "=d"))]
  26191. + "TARGET_METAC_1_1 && 1"
  26192. + "#"
  26193. + "&& reload_completed"
  26194. + [(set (match_dup 0)
  26195. + (high:SI (match_dup 1)))
  26196. + (parallel
  26197. + [(set (reg:<MODE> CC_REG)
  26198. + (compare:CCZNC
  26199. + (lo_sum:SI (match_dup 0)
  26200. + (match_dup 1))
  26201. + (const_int 0)))
  26202. + (set (match_dup 0)
  26203. + (lo_sum:SI (match_dup 0)
  26204. + (match_dup 1)))])]
  26205. + ""
  26206. + [(set_attr "type" "two")
  26207. + (set_attr "ccstate" "set")])
  26208. +
  26209. +(define_insn "*tadds_rr_<mode>_symglobal_1_1"
  26210. + [(set (reg:<MODE> CC_REG)
  26211. + (compare:CCZNC
  26212. + (lo_sum:SI (match_operand:SI 1 "metag_datareg_op" "0")
  26213. + (match_operand:SI 2 "metag_symglobal_op" ""))
  26214. + (const_int 0)))
  26215. + (set (match_operand:SI 0 "metag_datareg_op" "=d")
  26216. + (lo_sum:SI (match_dup 1)
  26217. + (match_dup 2)))]
  26218. + "TARGET_METAC_1_1"
  26219. + "ADDS\\t%0, %1, #LO(%c2)"
  26220. + [(set_attr "type" "fast")
  26221. + (set_attr "ccstate" "set")])
  26222. +
  26223. +(define_insn_and_split "*tadds_<mode>_si_symglobal_1_1"
  26224. + [(set (reg:<MODE> CC_REG)
  26225. + (compare:CCZNC
  26226. + (match_operand:SI 1 "metag_symglobal_op" "")
  26227. + (const_int 0)))
  26228. + (clobber (match_scratch:SI 0 "=d"))]
  26229. + "TARGET_METAC_1_1 && 0"
  26230. + "#"
  26231. + "&& reload_completed"
  26232. + [(set (match_dup 0)
  26233. + (high:SI (match_dup 1)))
  26234. + (parallel
  26235. + [(set (reg:<MODE> CC_REG)
  26236. + (compare:CCZNC
  26237. + (lo_sum:SI (match_dup 0)
  26238. + (match_dup 1))
  26239. + (const_int 0)))
  26240. + (set (match_dup 0)
  26241. + (lo_sum:SI (match_dup 0)
  26242. + (match_dup 1)))])]
  26243. + ""
  26244. + [(set_attr "type" "fast")
  26245. + (set_attr "ccstate" "set")])
  26246. +
  26247. +(define_insn "*tadds_si_cc_rri"
  26248. + [(set (reg:<MODE> CC_REG)
  26249. + (compare:CCZNC
  26250. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,e,f,f,d,d,0,0,0, 0")
  26251. + (match_operand:SI 2 "const_int_operand" "K,P,K,P,K,P,I,J,O3,i"))
  26252. + (const_int 0)))
  26253. + (clobber (match_scratch:SI 0 "=e,e,f,f,r,r,d,d,d, d"))]
  26254. + ""
  26255. + "@
  26256. + ADDS\\t%0, %1, %2\\t\\t%@ (*tadd si eeK OK)
  26257. + SUBS\\t%0, %1, #%n2\\t\\t%@ (*tadd si eeP OK)
  26258. + ADDS\\t%0, %1, %2\\t\\t%@ (*tadd si ffK OK)
  26259. + SUBS\\t%0, %1, #%n2\\t\\t%@ (*tadd si ffP OK)
  26260. + ADDS\\t%0, %1, %2\\t\\t%@ (*tadd si rdK OK)
  26261. + SUBS\\t%0, %1, #%n2\\t\\t%@ (*tadd si rdP OK)
  26262. + ADDS\\t%0, %1, %2\\t%@ (*tadd si d0I OK)
  26263. + ADDST\\t%0, %1, #HI(%c2)\\t%@ (*tadd si d0J OK)
  26264. + ADDS\\t%0, %1, #LO(%c2)\\t%@ (*tadd si d0O3 OK)
  26265. + #"
  26266. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,fast,fast,fast,two")
  26267. + (set_attr "ccstate" "set,set,set,set,set,set,set,set,set,fastset")])
  26268. +
  26269. +;; Split the above insn if it needs more that one insn.
  26270. +(define_split
  26271. + [(set (reg:<MODE> CC_REG)
  26272. + (compare:CCZNC
  26273. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26274. + (match_operand:SI 2 "const_int_operand" ""))
  26275. + (const_int 0)))
  26276. + (clobber (match_scratch:SI 0 ""))]
  26277. + "reload_completed
  26278. + && REGNO (operands[0]) == REGNO (operands[1]) && !METAG_CONST_OK_FOR_LETTERS_KPIJO3 (operands[2])"
  26279. + [(set (match_dup 0)
  26280. + (plus:SI (match_dup 1)
  26281. + (match_dup 3)))
  26282. + (parallel
  26283. + [(set (reg:<MODE> CC_REG)
  26284. + (compare:<MODE>
  26285. + (plus:SI (match_dup 0)
  26286. + (match_dup 4))
  26287. + (const_int 0)))
  26288. + (clobber (match_dup 0))])]
  26289. + {
  26290. + HOST_WIDE_INT value = INTVAL (operands[2]);
  26291. + HOST_WIDE_INT ival;
  26292. +
  26293. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  26294. + operands[3] = GEN_INT (ival);
  26295. +
  26296. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  26297. + operands[4] = GEN_INT (ival);
  26298. + }
  26299. +)
  26300. +
  26301. +;; subtract instructions
  26302. +
  26303. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26304. +;; subdi3 expander ;;
  26305. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26306. +(define_expand "subdi3"
  26307. + [(parallel
  26308. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "")
  26309. + (minus:DI (match_operand:DI 1 "metag_reg_nofloat_op" "")
  26310. + (match_operand:DI 2 "metag_reg_nofloat_op" "")))
  26311. + (clobber (reg:CC CC_REG))])]
  26312. + ""
  26313. + "")
  26314. +
  26315. +(define_insn "*subdi3_dsp"
  26316. + [(set (match_operand:DI 0 "metag_datareg_op" "=d")
  26317. + (minus:DI (match_operand:DI 1 "metag_datareg_op" "d")
  26318. + (match_operand:DI 2 "metag_datareg_op" "d")))
  26319. + (clobber (reg:CC CC_REG))]
  26320. + "TARGET_DSP"
  26321. + "DL\\tSUBS\\t%0, %1, %2\\t%@ (*SUB\\t%t0, %t1, %t2)\;SUBCS\\t%t0, %t0, #1"
  26322. + [(set_attr "type" "two")
  26323. + (set_attr "ccstate" "ccx")])
  26324. +
  26325. +(define_insn_and_split "*subdi3"
  26326. + [(set (match_operand:DI 0 "metag_datareg_op" "=d")
  26327. + (minus:DI (match_operand:DI 1 "metag_datareg_op" "d")
  26328. + (match_operand:DI 2 "metag_datareg_op" "d")))
  26329. + (clobber (reg:CC CC_REG))]
  26330. + ""
  26331. + "#"
  26332. + "SPLIT_EARLY"
  26333. + [(parallel
  26334. + [(set (reg:CC_NOOV CC_REG)
  26335. + (compare:CC_NOOV
  26336. + (minus:SI (match_dup 5)
  26337. + (match_dup 7))
  26338. + (const_int 0)))
  26339. + (set (match_dup 3)
  26340. + (minus:SI (match_dup 5)
  26341. + (match_dup 7)))])
  26342. + (set (match_dup 4)
  26343. + (minus:SI (match_dup 6)
  26344. + (match_dup 8)))
  26345. + (set (match_dup 4)
  26346. + (if_then_else:SI (ltu (reg:CC_NOOV CC_REG)
  26347. + (const_int 0))
  26348. + (plus:SI (match_dup 4)
  26349. + (const_int -1))
  26350. + (match_dup 4)))]
  26351. + {
  26352. + if (reload_completed)
  26353. + {
  26354. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]));
  26355. + operands[4] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  26356. +
  26357. + operands[5] = gen_rtx_REG (SImode, REGNO (operands[1]));
  26358. + operands[6] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  26359. +
  26360. + operands[7] = gen_rtx_REG (SImode, REGNO (operands[2]));
  26361. + operands[8] = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
  26362. + }
  26363. + else
  26364. + {
  26365. + operands[3] = gen_rtx_SUBREG (SImode, operands[0], 0);
  26366. + operands[4] = gen_rtx_SUBREG (SImode, operands[0], UNITS_PER_WORD);
  26367. +
  26368. + operands[5] = gen_rtx_SUBREG (SImode, operands[1], 0);
  26369. + operands[6] = gen_rtx_SUBREG (SImode, operands[1], UNITS_PER_WORD);
  26370. +
  26371. + operands[7] = gen_rtx_SUBREG (SImode, operands[2], 0);
  26372. + operands[8] = gen_rtx_SUBREG (SImode, operands[2], UNITS_PER_WORD);
  26373. + }
  26374. + }
  26375. + [(set_attr "type" "three")
  26376. + (set_attr "ccstate" "ccx")])
  26377. +
  26378. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26379. +;; subsi3 is made up of many parts.. ;;
  26380. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26381. +(define_expand "subsi3"
  26382. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26383. + (minus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26384. + (match_operand:SI 2 "metag_reg_nofloat_op" "")))]
  26385. + ""
  26386. + {
  26387. + if (!reload_completed
  26388. + && !reload_in_progress
  26389. + && REG_P (operands[2]))
  26390. + {
  26391. + if (metag_frame_related_rtx (operands[1]))
  26392. + {
  26393. + /* Ensure reg-reg adds do not combine regs that may be eliminated */
  26394. + rtx reg = gen_reg_rtx (SImode);
  26395. +
  26396. + emit_move_insn (reg, operands[1]);
  26397. + operands[1] = force_reg (SImode, reg);
  26398. + }
  26399. + else if (metag_frame_related_rtx (operands[2]))
  26400. + {
  26401. + /* Ensure reg-reg adds do not combine regs that may be eliminated */
  26402. + rtx reg = gen_reg_rtx (SImode);
  26403. +
  26404. + emit_move_insn (reg, operands[2]);
  26405. + operands[2] = force_reg (SImode, reg);
  26406. + }
  26407. + }
  26408. + }
  26409. +)
  26410. +
  26411. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26412. +;; and these are the subsi3 parts.. ;;
  26413. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26414. +
  26415. +;; register - register ops
  26416. +(define_insn "*sub_si_rrr"
  26417. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,h,l,da,da,da,da")
  26418. + (minus:SI (match_operand:SI 1 "metag_regnofrm_op" "e,f,h,l,e, f, h, l")
  26419. + (match_operand:SI 2 "metag_regnofrm_op" "e,f,h,l,e, f, h, l")))]
  26420. + "!TARGET_METAC_1_1"
  26421. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rrr OK)"
  26422. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  26423. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes,yes")
  26424. + (set_attr "predicable" "yes")])
  26425. +
  26426. +;; register - register ops - v1.1 case
  26427. +(define_insn "*sub_si_rrr_1_1"
  26428. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e, f, h, l, da,da,da,da")
  26429. + (minus:SI (match_operand:SI 1 "metag_regnofrm_op" "e, f, h, l, e, f, h, l")
  26430. + (match_operand:SI 2 "metag_regnofrm_op" "be,bf,bh,bl,be,bf,bh,bl")))]
  26431. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  26432. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rrb OK)"
  26433. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  26434. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,yes,yes")
  26435. + (set_attr "predicable" "yes")])
  26436. +
  26437. +;; register - register ops - minim case
  26438. +(define_insn "*sub_si_rrr_minim"
  26439. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,!e, f,!f, h,!h, l,!l, da,!da, da,!da, da,!da, da,!da")
  26440. + (minus:SI (match_operand:SI 1 "metag_regnofrm_op" "e, e, f, f, h, h, l, l, e, e, f, f, h, h, l, l")
  26441. + (match_operand:SI 2 "metag_regnofrm_op" "e, be,f, bf,h, bh,l, bl,e, be, f, bf, h, bh, l, bl")))]
  26442. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  26443. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rrb OK)"
  26444. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,fast,slow,slow,slow,slow,slow,slow,slow,slow")
  26445. + (set_attr "cond" "yes")
  26446. + (set_attr "predicable" "yes")])
  26447. +
  26448. +;; Seperate stack frame related register-register subs
  26449. +(define_insn "*sub_si_index_frame"
  26450. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,da,!da")
  26451. + (minus:SI (match_operand:SI 1 "metag_regframe_op" "h,h, h")
  26452. + (match_operand:SI 2 "metag_regnofrm_op" "h,h, bh")))]
  26453. + "!TARGET_METAC_1_1"
  26454. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rfrmh OK)"
  26455. + [(set_attr "type" "fast,slow,three")
  26456. + (set_attr "cond" "yes,yes,yes")
  26457. + (set_attr "predicable" "yes")])
  26458. +
  26459. +;; Subs are not commutative so second case required
  26460. +(define_insn "*sub_si_index_frame2"
  26461. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,da,!da")
  26462. + (minus:SI (match_operand:SI 1 "metag_regnofrm_op" "h,h, h")
  26463. + (match_operand:SI 2 "metag_regframe_op" "h,h, bh")))]
  26464. + "!TARGET_METAC_1_1"
  26465. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rhfrm OK)"
  26466. + [(set_attr "type" "fast,slow,three")
  26467. + (set_attr "cond" "yes,yes,yes")
  26468. + (set_attr "predicable" "yes")])
  26469. +
  26470. +;; Seperate stack frame related register-register subs - v1.1 case
  26471. +(define_insn "*sub_si_index_frame_1_1"
  26472. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h, da")
  26473. + (minus:SI (match_operand:SI 1 "metag_regframe_op" "h, h")
  26474. + (match_operand:SI 2 "metag_regnofrm_op" "bh,bh")))]
  26475. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  26476. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rfrmb OK)"
  26477. + [(set_attr "type" "fast,slow")
  26478. + (set_attr "cond" "yes,yes")
  26479. + (set_attr "predicable" "yes")])
  26480. +
  26481. +;; Seperate stack frame related register-register subs - minim case
  26482. +(define_insn "*sub_si_index_frame_minim"
  26483. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,!h, da,!da")
  26484. + (minus:SI (match_operand:SI 1 "metag_regframe_op" "h, h, h, h")
  26485. + (match_operand:SI 2 "metag_regnofrm_op" "h, bh,h, bh")))]
  26486. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  26487. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rfrmb OK)"
  26488. + [(set_attr "type" "fast,fast,slow,slow")
  26489. + (set_attr "cond" "yes")
  26490. + (set_attr "predicable" "yes")])
  26491. +
  26492. +;; Subs are not commutative so second case required - v1.1 case
  26493. +(define_insn "*sub_si_index_frame2_1_1"
  26494. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h, da")
  26495. + (minus:SI (match_operand:SI 1 "metag_regnofrm_op" "h, h")
  26496. + (match_operand:SI 2 "metag_regframe_op" "bh,bh")))]
  26497. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  26498. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rbfrm OK)"
  26499. + [(set_attr "type" "fast,slow")
  26500. + (set_attr "cond" "yes,yes")
  26501. + (set_attr "predicable" "yes")])
  26502. +
  26503. +;; Subs are not commutative so second case required - minim case
  26504. +(define_insn "*sub_si_index_frame2_minim"
  26505. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=h,!h, da,!da")
  26506. + (minus:SI (match_operand:SI 1 "metag_regnofrm_op" "h, h, h, h")
  26507. + (match_operand:SI 2 "metag_regframe_op" "h, bh,h, bh")))]
  26508. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  26509. + "SUB%?\\t%0, %1, %2\\t%@ (*sub si rbfrm OK)"
  26510. + [(set_attr "type" "fast,fast,slow,slow")
  26511. + (set_attr "cond" "yes")
  26512. + (set_attr "predicable" "yes")])
  26513. +
  26514. +;; spill_frame - cannot really sub frame value to something else
  26515. +(define_split
  26516. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26517. + (minus:SI (match_operand:SI 1 "metag_regframe_op" "")
  26518. + (match_operand:SI 2 "metag_reg_nofloat_op" "")))]
  26519. + "!TARGET_METAC_1_1
  26520. + && reload_completed
  26521. + && METAG_REGNO_REG_CLASS (REGNO (operands[2])) != A0_REGS"
  26522. + [(set (match_dup 3)
  26523. + (match_dup 2))
  26524. + (set (match_dup 0)
  26525. + (minus:SI (match_dup 1)
  26526. + (match_dup 3)))]
  26527. + {
  26528. + gcc_assert (A0_SCRATCH != INVALID_REGNUM && fixed_regs[A0_SCRATCH]);
  26529. + operands[3] = gen_rtx_REG (SImode, A0_SCRATCH);
  26530. + }
  26531. +)
  26532. +
  26533. +(define_split
  26534. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26535. + (minus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26536. + (match_operand:SI 2 "metag_regframe_op" "")))]
  26537. + "!TARGET_METAC_1_1
  26538. + && reload_completed
  26539. + && METAG_REGNO_REG_CLASS (REGNO (operands[1])) != A0_REGS"
  26540. + [(set (match_dup 3)
  26541. + (match_dup 1))
  26542. + (set (match_dup 0)
  26543. + (minus:SI (match_dup 3)
  26544. + (match_dup 2)))]
  26545. + {
  26546. + gcc_assert (A0_SCRATCH != INVALID_REGNUM && fixed_regs[A0_SCRATCH]);
  26547. + operands[3] = gen_rtx_REG (SImode, A0_SCRATCH);
  26548. + }
  26549. +)
  26550. +
  26551. +;; register - register|immediate ops that set the flags
  26552. +(define_insn "*subs_<mode>_si_rrr"
  26553. + [(set (reg:<MODE> CC_REG)
  26554. + (compare:CCZNC
  26555. + (minus:SI (match_operand:SI 1 "metag_datareg_op" "e,f,e,f")
  26556. + (match_operand:SI 2 "metag_datareg_op" "e,f,e,f"))
  26557. + (const_int 0)))
  26558. + (set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  26559. + (minus:SI (match_dup 1)
  26560. + (match_dup 2)))]
  26561. + "!TARGET_METAC_1_1"
  26562. + "SUBS\\t%0, %1, %2\\t%@ (*subs si rrr OK)"
  26563. + [(set_attr "type" "fast,fast,slow,slow")
  26564. + (set_attr "ccstate" "set,set,set,set")])
  26565. +
  26566. +;; register - register|immediate ops that set the flags - v1.1 case
  26567. +(define_insn "*subs_<mode>_si_rrr_1_1"
  26568. + [(set (reg:<MODE> CC_REG)
  26569. + (compare:CCZNC
  26570. + (minus:SI (match_operand:SI 1 "metag_datareg_op" "e, f, e, f")
  26571. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))
  26572. + (const_int 0)))
  26573. + (set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  26574. + (minus:SI (match_dup 1)
  26575. + (match_dup 2)))]
  26576. + "TARGET_METAC_1_1"
  26577. + "SUBS\\t%0, %1, %2\\t%@ (*subs si rrb OK)"
  26578. + [(set_attr "type" "fast,fast,slow,slow")
  26579. + (set_attr "ccstate" "set,set,set,set")
  26580. + (set_attr "o2rhint" "op2op1")])
  26581. +
  26582. +;; register - register|immediate ops that set the flags only -> compares
  26583. +(define_insn "*tsub_<mode>_si_rrr"
  26584. + [(set (reg:<MODE> CC_REG)
  26585. + (compare:CCZNC
  26586. + (minus:SI (match_operand:SI 0 "metag_datareg_op" "e,f")
  26587. + (match_operand:SI 1 "metag_datareg_op" "e,f"))
  26588. + (const_int 0)))]
  26589. + "!TARGET_METAC_1_1"
  26590. + "CMP\\t%0, %1\\t%@ (*tsub si dd OK)"
  26591. + [(set_attr "type" "fast,fast")
  26592. + (set_attr "ccstate" "set,set")])
  26593. +
  26594. +;; register - register ops that set the flags only -> compares - v1.1 case
  26595. +(define_insn "*tsub_<mode>_si_rrr_1_1"
  26596. + [(set (reg:<MODE> CC_REG)
  26597. + (compare:CCZNC
  26598. + (minus:SI (match_operand:SI 0 "metag_datareg_op" "e, f")
  26599. + (match_operand:SI 1 "metag_datareg_op" "be,bf"))
  26600. + (const_int 0)))]
  26601. + "TARGET_METAC_1_1"
  26602. + "CMP\\t%0, %1\\t%@ (*tsub si db OK)"
  26603. + [(set_attr "type" "fast,fast")
  26604. + (set_attr "ccstate" "set,set")
  26605. + (set_attr "o2rhint" "op1op0")])
  26606. +
  26607. +;; signed multiply instructions
  26608. +
  26609. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26610. +;; mulsi3 is made up of many parts.. ;;
  26611. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26612. +(define_expand "mulsi3"
  26613. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26614. + (mult:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26615. + (match_operand:SI 2 "metag_regorint_op" "")))]
  26616. + ""
  26617. + {
  26618. + if (metag_frame_related_rtx (operands[2]))
  26619. + {
  26620. + /* Put the magic frame registers first */
  26621. + rtx temp = operands[1];
  26622. +
  26623. + operands[1] = operands[2];
  26624. + operands[2] = temp;
  26625. + }
  26626. +
  26627. + if (!TARGET_METAC_1_1 && !reload_completed && !reload_in_progress)
  26628. + {
  26629. + if (CONST_INT_P (operands[2])
  26630. + && metag_frame_related_rtx (operands[1]))
  26631. + {
  26632. + /* Ensure reg*const do not combine reg that may be eliminated */
  26633. + rtx reg = gen_reg_rtx (SImode);
  26634. +
  26635. + emit_move_insn (reg, operands[1]);
  26636. + operands[1] = force_reg (SImode, reg);
  26637. + }
  26638. + }
  26639. +
  26640. + if (!CONST_INT_P (operands[2])
  26641. + || ( !satisfies_constraint_I (operands[2])
  26642. + && !satisfies_constraint_J (operands[2])
  26643. + && !satisfies_constraint_K (operands[2])
  26644. + && !satisfies_constraint_P (operands[2])
  26645. + && !satisfies_constraint_O3(operands[2])))
  26646. + {
  26647. + /* All except reg = (reg * bigconst) can be done quickly */
  26648. + operands[2] = force_reg (SImode, operands[2]);
  26649. + }
  26650. + }
  26651. +)
  26652. +
  26653. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26654. +;; and these are the mulsi3 parts.. ;;
  26655. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26656. +
  26657. +;; register * register ops - v1.0 bug disables MULD Dn.x, Dm.x, Dm.y
  26658. +(define_insn "*mul_si_rrr"
  26659. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,a,a")
  26660. + (mult:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  26661. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f")))]
  26662. + "!TARGET_METAC_1_1"
  26663. + "MULD\\t%0, %1, %2\\t%@ (*mul si rrr OK)"
  26664. + [(set_attr "type" "mult,mult,slowslow,slowslow")])
  26665. +
  26666. +;; register * register ops v1.1
  26667. +(define_insn "*mul_si_rrr_1_1"
  26668. + [(set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  26669. + (mult:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  26670. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf")))]
  26671. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  26672. + "MULD\\t%0, %1, %2\\t%@ (*mul si rrr OK)"
  26673. + [(set_attr "type" "mult,mult,slowslow,slowslow")
  26674. + (set_attr "o2rhint" "op2op1")])
  26675. +
  26676. +;; register * register ops minim
  26677. +(define_insn "*mul_si_rrr_minim"
  26678. + [(set (match_operand:SI 0 "metag_register_op" "=e,!e, f,!f, r,!r, r,!r")
  26679. + (mult:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, e, f, f, e, e, f, f")
  26680. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, be,f, bf,e, be,f, bf")))]
  26681. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  26682. + "MULD\\t%0, %1, %2\\t%@ (*mul si rrr OK)"
  26683. + [(set_attr "type" "mult,mult,mult,mult,slowslow,slowslow,slowslow,slowslow")
  26684. + (set_attr "o2rhint" "op2op1")])
  26685. +
  26686. +;; register * immediate ops - v1.0 bug disables MULD Dn.x, Dm.x, #0xnn
  26687. +(define_insn "*mul_si_rri"
  26688. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,d, d,d, a,a,&e,&f")
  26689. + (mult:SI (match_operand:SI 1 "metag_regnofrm_op" "e,f,0, 0,0, e,f, e, f")
  26690. + (match_operand:SI 2 "metag_int_operand" "K,K,IP,J,O3,K,K, i, i")))]
  26691. + "!TARGET_METAC_1_1"
  26692. + "@
  26693. + MULD\\t%0, %1, %2\\t\\t%@ (*mul si eeK OK)
  26694. + MULD\\t%0, %1, %2\\t\\t%@ (*mul si ffK OK)
  26695. + MULD\\t%0, %1, %2\\t%@ (*mul si d0I OK)
  26696. + MULDT\\t%0, %1, #HI(%c2)\\t%@ (*mul si d0J OK)
  26697. + MULD\\t%0, %1, #LO(%c2)\\t%@ (*mul si d0O3 OK)
  26698. + MULD\\t%0, %1, %2\\t\\t%@ (*mul si reK OK)
  26699. + MULD\\t%0, %1, %2\\t\\t%@ (*mul si rfK OK)
  26700. + #
  26701. + #"
  26702. + [(set_attr "type" "mult,mult,mult,mult,mult,slowslow,slowslow,four,four")])
  26703. +
  26704. +;; Split the above insn if it needs more than one insn
  26705. +(define_split
  26706. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26707. + (mult:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26708. + (match_operand:SI 2 "metag_int_operand" "")))]
  26709. + "!TARGET_METAC_1_1
  26710. + && reload_completed
  26711. + && REGNO (operands[0]) == REGNO (operands[1]) && !METAG_CONST_OK_FOR_LETTERS_KPIJO3 (operands[2])"
  26712. + [(set (match_dup 0)
  26713. + (match_dup 3))
  26714. + (set (match_dup 0)
  26715. + (plus:SI (match_dup 0)
  26716. + (match_dup 4)))
  26717. + (set (match_dup 0)
  26718. + (mult:SI (match_dup 1)
  26719. + (match_dup 0)))]
  26720. + {
  26721. + HOST_WIDE_INT value = INTVAL (operands[2]);
  26722. + HOST_WIDE_INT ival;
  26723. +
  26724. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  26725. + operands[3] = GEN_INT (ival);
  26726. +
  26727. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  26728. + operands[4] = GEN_INT (ival);
  26729. + }
  26730. +)
  26731. +
  26732. +;; register * immediate ops
  26733. +(define_insn "*mul_si_rri_1_1"
  26734. + [(set (match_operand:SI 0 "metag_register_op" "=r,d, d,d, &e,&f")
  26735. + (mult:SI (match_operand:SI 1 "metag_reg_nofloat_op" "d,0, 0,0, e, f")
  26736. + (match_operand:SI 2 "metag_int_operand" "K,IP,J,O3, i, i")))]
  26737. + "TARGET_METAC_1_1"
  26738. + "@
  26739. + MULD\\t%0, %1, %2\\t\\t%@ (*mul si rdK OK)
  26740. + MULD\\t%0, %1, %2\\t%@ (*mul si d0I OK)
  26741. + MULDT\\t%0, %1, #HI(%c2)\\t%@ (*mul si d0J OK)
  26742. + MULD \\t%0, %1, #LO(%c2)\\t%@ (*mul si d0J OK)
  26743. + #
  26744. + #"
  26745. + [(set_attr "type" "slowslow,mult,mult,mult,four,four")])
  26746. +
  26747. +;; Split the above insn if it needs more than one insn
  26748. +(define_split
  26749. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26750. + (mult:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26751. + (match_operand:SI 2 "metag_int_operand" "")))]
  26752. + "TARGET_METAC_1_1
  26753. + && reload_completed
  26754. + && REGNO (operands[0]) != REGNO (operands[1]) && !satisfies_constraint_K (operands[2])"
  26755. + [(set (match_dup 0)
  26756. + (match_dup 3))
  26757. + (set (match_dup 0)
  26758. + (plus:SI (match_dup 0)
  26759. + (match_dup 4)))
  26760. + (set (match_dup 0)
  26761. + (mult:SI (match_dup 1)
  26762. + (match_dup 0)))]
  26763. + {
  26764. + HOST_WIDE_INT value = INTVAL (operands[2]);
  26765. + HOST_WIDE_INT ival;
  26766. +
  26767. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  26768. + operands[3] = GEN_INT (ival);
  26769. +
  26770. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  26771. + operands[4] = GEN_INT (ival);
  26772. + }
  26773. +)
  26774. +
  26775. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26776. +;; umulhisi3 is made up of many parts.. ;;
  26777. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26778. +(define_expand "umulhisi3"
  26779. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26780. + (mult:SI (zero_extend:SI (match_operand:HI 1 "metag_reg_nofloat_op" ""))
  26781. + (zero_extend:SI (match_operand:HI 2 "metag_regorint_op" ""))))]
  26782. + ""
  26783. + {
  26784. + if (CONST_INT_P (operands[2]))
  26785. + {
  26786. + /* Mask off the unsigned immediate to zero extend */
  26787. + HOST_WIDE_INT ival = INTVAL (operands[2]) & GET_MODE_MASK (HImode);
  26788. +
  26789. + emit_move_insn (operands[0],
  26790. + gen_rtx_MULT (SImode,
  26791. + gen_rtx_ZERO_EXTEND (SImode, operands[1]),
  26792. + GEN_INT (ival)));
  26793. + DONE;
  26794. + }
  26795. + }
  26796. +)
  26797. +
  26798. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26799. +;; and these are the umulhisi3 parts.. ;;
  26800. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26801. +
  26802. +;; register * register ops
  26803. +(define_insn "*umul_hisi_rrr"
  26804. + [(set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  26805. + (mult:SI (zero_extend:SI
  26806. + (match_operand:HI 1 "metag_reg_nofloat_op" "%e,f,e,f"))
  26807. + (zero_extend:SI
  26808. + (match_operand:HI 2 "metag_reg_nofloat_op" "e,f,e,f"))))]
  26809. + "!TARGET_METAC_1_1"
  26810. + "MULW%?\\t%0, %1, %2\\t%@ (*umul hisi rrr OK)"
  26811. + [(set_attr "type" "fast,fast,slow,slow")
  26812. + (set_attr "cond" "yes,yes,yes,yes")
  26813. + (set_attr "predicable" "yes")])
  26814. +
  26815. +;; register * register ops - v1.1 case
  26816. +(define_insn "*umul_hisi_rrr_1_1"
  26817. + [(set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  26818. + (mult:SI (zero_extend:SI
  26819. + (match_operand:HI 1 "metag_reg_nofloat_op" "%e, f, e, f"))
  26820. + (zero_extend:SI
  26821. + (match_operand:HI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))))]
  26822. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  26823. + "MULW%?\\t%0, %1, %2\\t%@ (*umul hisi rrr OK)"
  26824. + [(set_attr "type" "fast,fast,slow,slow")
  26825. + (set_attr "cond" "yes,yes,yes,yes")
  26826. + (set_attr "predicable" "yes")
  26827. + (set_attr "o2rhint" "op2op1")])
  26828. +
  26829. +;; register * register ops - minim case
  26830. +(define_insn "*umul_hisi_rrr_minim"
  26831. + [(set (match_operand:SI 0 "metag_register_op" "=e,!e, f,!f, r,!r, r,!r")
  26832. + (mult:SI (zero_extend:SI
  26833. + (match_operand:HI 1 "metag_reg_nofloat_op" "%e, e, f, f, e, e, f, f"))
  26834. + (zero_extend:SI
  26835. + (match_operand:HI 2 "metag_reg_nofloat_op" "e, be,f, bf,e, be,f, bf"))))]
  26836. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  26837. + "MULW%?\\t%0, %1, %2\\t%@ (*umul hisi rrr OK)"
  26838. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  26839. + (set_attr "cond" "yes")
  26840. + (set_attr "predicable" "yes")
  26841. + (set_attr "o2rhint" "op2op1")])
  26842. +
  26843. +;; register * immediate ops
  26844. +(define_insn "*umul_hisi_rri"
  26845. + [(set (match_operand:SI 0 "metag_register_op" "=e,f,r,d")
  26846. + (mult:SI (zero_extend:SI
  26847. + (match_operand:HI 1 "metag_reg_nofloat_op" "e,f,d,0"))
  26848. + (match_operand:SI 2 "metag_int_operand" "K,K,K,IP")))]
  26849. + ""
  26850. + "@
  26851. + MULW%?\\t%0, %1, %2\\t\\t%@ (*umul hisi eeK OK)
  26852. + MULW%?\\t%0, %1, %2\\t\\t%@ (*umul hisi ffK OK)
  26853. + MULW\\t%0, %1, %2\\t\\t%@ (*umul hisi rdK OK)
  26854. + MULW\\t%0, %1, %2\\t%@ (*umul hisi d0I OK)"
  26855. + [(set_attr "type" "fast,fast,slow,fast")
  26856. + (set_attr "cond" "yes,yes,no,no")])
  26857. +
  26858. +;; conditional version for specific cases of umul_hisi_rri
  26859. +(define_insn "*cond_<mode>_umul_hisi_rri"
  26860. + [(cond_exec
  26861. + (match_operator 3 "comparison_operator"
  26862. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  26863. + (const_int 0)])
  26864. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  26865. + (mult:SI (zero_extend:SI
  26866. + (match_operand:HI 1 "metag_datareg_op" "e,f"))
  26867. + (match_operand:SI 2 "metag_K_operand" "K,K"))))]
  26868. + "reload_completed
  26869. + && metag_same_regclass_p (operands[0], operands[1])"
  26870. + "@
  26871. + MULW%?\\t%0, %1, %2\\t\\t%@ (*umul hisi eeK OK)
  26872. + MULW%?\\t%0, %1, %2\\t\\t%@ (*umul hisi ffK OK)"
  26873. + [(set_attr "type" "fast")
  26874. + (set_attr "cond" "no")])
  26875. +
  26876. +;; signed divide instructions
  26877. +
  26878. +; we don't have one..
  26879. +
  26880. +;; signed modulus instruction
  26881. +
  26882. +; we don't have one..
  26883. +
  26884. +;; unsigned divide instruction
  26885. +
  26886. +; we don't have one..
  26887. +
  26888. +;; logical-and instructions
  26889. +
  26890. +(define_insn "*anddi3_dsp"
  26891. + [(set (match_operand:DI 0 "metag_register_op" "=d")
  26892. + (and:DI (match_dup 0)
  26893. + (match_operand:DI 1 "metag_16bit_op" "KIP")))]
  26894. + "TARGET_DSP"
  26895. + "DL\\tAND\\t%0, %0, %1\\t%@ (*AND\\t%t0, %t0, %1)"
  26896. + [(set_attr "type" "fast")])
  26897. +
  26898. +(define_insn "*anddi3"
  26899. + [(set (match_operand:DI 0 "metag_register_op" "=d")
  26900. + (and:DI (match_operand:DI 1 "metag_register_op" "d")
  26901. + (match_operand:DI 2 "metag_register_op" "d")))]
  26902. + "TARGET_DSP"
  26903. + "DL\\tAND\\t%0, %1, %2\\t%@ (*AND\\t%t0, %t1, %t2)"
  26904. + [(set_attr "type" "fast")])
  26905. +
  26906. +(define_expand "anddi3"
  26907. + [(set (match_operand:DI 0 "metag_register_op" "=d")
  26908. + (and:DI (match_operand:DI 1 "metag_register_op" "d")
  26909. + (match_operand:DI 2 "metag_register_op" "d")))]
  26910. + ""
  26911. + {
  26912. + if (!TARGET_DSP)
  26913. + FAIL;
  26914. + }
  26915. + )
  26916. +
  26917. +
  26918. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26919. +;; andsi3 is made up of many parts.. ;;
  26920. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26921. +(define_expand "andsi3"
  26922. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  26923. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  26924. + (match_operand:SI 2 "metag_regorint_op" "")))]
  26925. + ""
  26926. + {
  26927. + if (CONST_INT_P (operands[2])
  26928. + && METAG_LETTER_FOR_CONST (operands[2]) == 0)
  26929. + {
  26930. + /* Need to use M,N cases to implement op */
  26931. + rtx temp = (reload_in_progress || reload_completed)
  26932. + ? operands[0] : gen_reg_rtx (SImode);
  26933. + HOST_WIDE_INT value = INTVAL (operands[2]);
  26934. + HOST_WIDE_INT ival;
  26935. +
  26936. + ival = trunc_int_for_mode (value | 0xFFFF0000, SImode);
  26937. + emit_insn (gen_rtx_SET (VOIDmode, temp,
  26938. + gen_rtx_AND (SImode, operands[1],
  26939. + GEN_INT (ival))));
  26940. + ival = trunc_int_for_mode (value | 0x0000FFFF, SImode);
  26941. + emit_insn (gen_rtx_SET (VOIDmode, operands[0],
  26942. + gen_rtx_AND (SImode, temp,
  26943. + GEN_INT (ival))));
  26944. + DONE;
  26945. + }
  26946. + }
  26947. +)
  26948. +
  26949. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26950. +;; and these are the andsi3 parts.. ;;
  26951. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  26952. +
  26953. +;; register & register ops
  26954. +(define_insn "*and_si_rrr"
  26955. + [(set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  26956. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  26957. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f")))]
  26958. + "!TARGET_METAC_1_1 || TARGET_MTX"
  26959. + "AND%?\\t%0, %1, %2\\t%@ (*and si rrr OK)"
  26960. + [(set_attr "type" "fast,fast,slow,slow")
  26961. + (set_attr "cond" "yes,yes,yes,yes")
  26962. + (set_attr "predicable" "yes")])
  26963. +
  26964. +;; register & register ops - v1.1 case
  26965. +(define_insn "*and_si_rrr_1_1"
  26966. + [(set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  26967. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  26968. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf")))]
  26969. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE && !TARGET_MTX"
  26970. + "AND%?\\t%0, %1, %2\\t%@ (*and si rrr OK)"
  26971. + [(set_attr "type" "fast,fast,slow,slow")
  26972. + (set_attr "cond" "yes,yes,yes,yes")
  26973. + (set_attr "predicable" "yes")
  26974. + (set_attr "o2rhint" "op2op1")])
  26975. +
  26976. +;; register & register ops - minim case
  26977. +(define_insn "*and_si_rrr_minim"
  26978. + [(set (match_operand:SI 0 "metag_register_op" "=e,!e, f,!f, r,!r, r,!r")
  26979. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, e, f, f, e, e, f, f")
  26980. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, be,f, bf,e, be,f, bf")))]
  26981. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE && !TARGET_MTX"
  26982. + "AND%?\\t%0, %1, %2\\t%@ (*and si rrr OK)"
  26983. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  26984. + (set_attr "cond" "yes")
  26985. + (set_attr "predicable" "yes")
  26986. + (set_attr "o2rhint" "op2op1")])
  26987. +
  26988. +;; register & immediate ops
  26989. +(define_insn "*and_si_rri"
  26990. + [(set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,e,f,r")
  26991. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,e,f,d")
  26992. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K,K")))]
  26993. + "!TARGET_MINIM_CORE"
  26994. + "@
  26995. + AND\\t%0, %1, %2\\t%@ (*and si r0I OK)
  26996. + ANDT\\t%0, %1, #HI(%c2)\\t%@ (*and si d0J OK)
  26997. + ANDMB\\t%0, %1, #LO(%c2)\\t%@ (*and si d0M OK)
  26998. + ANDMT\\t%0, %1, #HI(%c2)\\t%@ (*and si d0N OK)
  26999. + AND%?\\t%0, %1, %2\\t\\t%@ (*and si eeK OK)
  27000. + AND%?\\t%0, %1, %2\\t\\t%@ (*and si ffK OK)
  27001. + AND\\t%0, %1, %2\\t\\t%@ (*and si rdK OK)"
  27002. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow")
  27003. + (set_attr "cond" "no,no,no,no,yes,yes,no")])
  27004. +
  27005. +;; register & immediate ops
  27006. +(define_insn "*and_si_rri"
  27007. + [(set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,d,!e,!f,!r")
  27008. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,0, e, f, d")
  27009. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K, K, K, K")))]
  27010. + "TARGET_MINIM_CORE"
  27011. + "@
  27012. + AND\\t%0, %1, %2\\t%@ (*and si r0I OK)
  27013. + ANDT\\t%0, %1, #HI(%c2)\\t%@ (*and si d0J OK)
  27014. + ANDMB\\t%0, %1, #LO(%c2)\\t%@ (*and si d0M OK)
  27015. + ANDMT\\t%0, %1, #HI(%c2)\\t%@ (*and si d0N OK)
  27016. + AND%?\\t%0, %1, %2\\t\\t%@ (*and si d0K OK)
  27017. + AND%?\\t%0, %1, %2\\t\\t%@ (*and si eeK OK)
  27018. + AND%?\\t%0, %1, %2\\t\\t%@ (*and si ffK OK)
  27019. + AND\\t%0, %1, %2\\t\\t%@ (*and si rdK OK)"
  27020. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,slow")
  27021. + (set_attr "cond" "no,no,no,no,yes,yes,yes,no")])
  27022. +
  27023. +;; conditional version for specific cases of and_si_rri
  27024. +(define_insn "*cond_<mode>_and_si_rri"
  27025. + [(cond_exec
  27026. + (match_operator 3 "comparison_operator"
  27027. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27028. + (const_int 0)])
  27029. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27030. + (and:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27031. + (match_operand:SI 2 "metag_K_operand" "K,K"))))]
  27032. + "reload_completed
  27033. + && metag_same_regclass_p (operands[0], operands[1])"
  27034. + "@
  27035. + AND%?\\t%0, %1, %2\\t\\t%@ (*and si eeK OK)
  27036. + AND%?\\t%0, %1, %2\\t\\t%@ (*and si ffK OK)"
  27037. + [(set_attr "type" "fast")
  27038. + (set_attr "cond" "no")])
  27039. +
  27040. +;; test register ops setting the NOOV flags
  27041. +(define_insn "*tst_<mode>_si_rr"
  27042. + [(set (reg:<MODE> CC_REG)
  27043. + (compare:CCZNC
  27044. + (and:SI (match_operand:SI 0 "metag_datareg_op" "%e,f")
  27045. + (match_operand:SI 1 "metag_datareg_op" "e,f"))
  27046. + (const_int 0)))]
  27047. + "!TARGET_METAC_1_1"
  27048. + "TST\\t%0, %1\\t%@ (*tst si dd OK)"
  27049. + [(set_attr "type" "fast,fast")
  27050. + (set_attr "ccstate" "set,set")])
  27051. +
  27052. +;; test register ops setting the NOOV flags - v1.1 case
  27053. +(define_insn "*tst_<mode>_si_rr_1_1"
  27054. + [(set (reg:<MODE> CC_REG)
  27055. + (compare:CCZNC
  27056. + (and:SI (match_operand:SI 0 "metag_datareg_op" "%e, f")
  27057. + (match_operand:SI 1 "metag_reg_nofloat_op" "be,bf"))
  27058. + (const_int 0)))]
  27059. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  27060. + "TST\\t%0, %1\\t%@ (*tst si db OK)"
  27061. + [(set_attr "type" "fast,fast")
  27062. + (set_attr "ccstate" "set,set")
  27063. + (set_attr "o2rhint" "op1op0")])
  27064. +
  27065. +;; test register ops setting the NOOV flags - minim case
  27066. +(define_insn "*tst_<mode>_si_rr_minim"
  27067. + [(set (reg:<MODE> CC_REG)
  27068. + (compare:CCZNC
  27069. + (and:SI (match_operand:SI 0 "metag_datareg_op" "%e,!e, f,!f")
  27070. + (match_operand:SI 1 "metag_register_op" "e, be,f, bf"))
  27071. + (const_int 0)))]
  27072. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  27073. + "TST\\t%0, %1\\t%@ (*tst si db OK)"
  27074. + [(set_attr "type" "fast,fast,fast,fast")
  27075. + (set_attr "ccstate" "set")
  27076. + (set_attr "o2rhint" "op1op0")])
  27077. +
  27078. +(define_insn "*tst_<mode>_si_ri"
  27079. + [(set (reg:<MODE> CC_REG)
  27080. + (compare:CCZNC
  27081. + (and:SI (match_operand:SI 0 "metag_reg_nofloat_op" "d,d, d,d,d")
  27082. + (match_operand:SI 1 "metag_int_operand" "K,IP,J,M,N"))
  27083. + (const_int 0)))]
  27084. + ""
  27085. + "@
  27086. + TST\\t%0, %1\\t%@ (*tst si dI OK)
  27087. + TST\\t%0, %1\\t%@ (*tst si dI OK)
  27088. + TSTT\\t%0, %1\\t%@ (*tst si dJ OK)
  27089. + TSTMB\\t%0, #LO(%c1)\\t%@ (*tst si dM OK)
  27090. + TSTMT\\t%0, #HI(%c1)\\t%@ (*tst si dN OK)"
  27091. + [(set_attr "type" "fast,fast,fast,fast,fast")
  27092. + (set_attr "ccstate" "set,set,set,set,set")])
  27093. +
  27094. +;; and register ops combined with test cases
  27095. +(define_insn "*ands_si_rrr"
  27096. + [(set (reg:<MODE> CC_REG)
  27097. + (compare:CCZNC
  27098. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  27099. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f"))
  27100. + (const_int 0)))
  27101. + (set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  27102. + (and:SI (match_dup 1)
  27103. + (match_dup 2)))]
  27104. + "!TARGET_METAC_1_1 || TARGET_MTX"
  27105. + "ANDS\\t%0, %1, %2\\t%@ (*ands si xdd OK)"
  27106. + [(set_attr "type" "fast,fast,slow,slow")
  27107. + (set_attr "ccstate" "set,set,set,set")])
  27108. +
  27109. +(define_insn "*ands_<mode>_si_rri"
  27110. + [(set (reg:<MODE> CC_REG)
  27111. + (compare:CCZNC
  27112. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,e,f,d")
  27113. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K,K"))
  27114. + (const_int 0)))
  27115. + (set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,e,f,r")
  27116. + (and:SI (match_dup 1)
  27117. + (match_dup 2)))]
  27118. + ""
  27119. + "@
  27120. + ANDS\\t%0, %1, %2\\t%@ (*ands si r0I OK)
  27121. + ANDST\\t%0, %1, #HI(%c2)\\t%@ (*ands si r0J OK)
  27122. + ANDSMB\\t%0, %1, #LO(%c2)\\t%@ (*ands si r0M OK)
  27123. + ANDSMT\\t%0, %1, #HI(%c2)\\t%@ (*ands si r0N OK)
  27124. + ANDS\\t%0, %1, %2\\t\\t%@ (*ands si eeK OK)
  27125. + ANDS\\t%0, %1, %2\\t\\t%@ (*ands si ffK OK)
  27126. + ANDS\\t%0, %1, %2\\t\\t%@ (*ands si ddK OK)"
  27127. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow")
  27128. + (set_attr "ccstate" "set,set,set,set,set,set,set")])
  27129. +
  27130. +;; and register ops combined with test cases - v1.1 case
  27131. +(define_insn "*ands_si_rrr_1_1"
  27132. + [(set (reg:<MODE> CC_REG)
  27133. + (compare:CCZNC
  27134. + (and:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  27135. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))
  27136. + (const_int 0)))
  27137. + (set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  27138. + (and:SI (match_dup 1)
  27139. + (match_dup 2)))]
  27140. + "TARGET_METAC_1_1 && !TARGET_MTX"
  27141. + "ANDS\\t%0, %1, %2\\t%@ (*ands si xdb OK)"
  27142. + [(set_attr "type" "fast,fast,slow,slow")
  27143. + (set_attr "ccstate" "set,set,set,set")
  27144. + (set_attr "o2rhint" "op2op1")])
  27145. +
  27146. +;; bitextract - matched during combine
  27147. +(define_insn_and_split "*zeroextractsi_<mode>_compare0"
  27148. + [(set (reg:<MODE> CC_REG)
  27149. + (compare:CCZNC
  27150. + (zero_extract:SI (match_operand:SI 0 "metag_reg_nofloat_op" "")
  27151. + (match_operand 1 "const_int_operand" "")
  27152. + (match_operand 2 "const_int_operand" ""))
  27153. + (const_int 0)))]
  27154. + "metag_zeroextract_mask_p (operands[1], operands[2])"
  27155. + "#"
  27156. + ""
  27157. + [(set (reg:<MODE> CC_REG)
  27158. + (compare:CCZNC
  27159. + (and:SI (match_dup 0)
  27160. + (match_dup 3))
  27161. + (const_int 0)))]
  27162. + {
  27163. + operands[3] = GEN_INT (((1 << INTVAL (operands[1])) -1) << INTVAL (operands[2]));
  27164. + }
  27165. + [(set_attr "type" "fast")
  27166. + (set_attr "ccstate" "set")])
  27167. +
  27168. +;; inclusive-or instructions
  27169. +
  27170. +(define_insn "iordi3"
  27171. + [(set (match_operand:DI 0 "metag_register_op" "=d")
  27172. + (ior:DI (match_operand:DI 1 "metag_register_op" "d")
  27173. + (match_operand:DI 2 "metag_register_op" "d")))]
  27174. + "TARGET_DSP"
  27175. + "DL\\tOR\\t%0, %1, %2\\t%@ (*OR\\t%t0, %t1, %t2)"
  27176. + [(set_attr "type" "fast")])
  27177. +
  27178. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27179. +;; iorsi3 is made up of many parts.. ;;
  27180. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27181. +(define_expand "iorsi3"
  27182. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  27183. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  27184. + (match_operand:SI 2 "metag_regorint_op" "")))]
  27185. + ""
  27186. + {
  27187. + if (CONST_INT_P (operands[2])
  27188. + && METAG_LETTER_FOR_CONST (operands[2]) == 0)
  27189. + {
  27190. + /* Need to use I,J cases to implement op */
  27191. + rtx temp = (reload_in_progress || reload_completed)
  27192. + ? operands[0] : gen_reg_rtx (SImode);
  27193. + HOST_WIDE_INT value = INTVAL (operands[2]);
  27194. + HOST_WIDE_INT ival;
  27195. +
  27196. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  27197. + emit_insn (gen_rtx_SET (VOIDmode, temp,
  27198. + gen_rtx_IOR (SImode, operands[1],
  27199. + GEN_INT (ival))));
  27200. +
  27201. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  27202. + emit_insn (gen_rtx_SET (VOIDmode, operands[0],
  27203. + gen_rtx_IOR (SImode, temp,
  27204. + GEN_INT (ival))));
  27205. + DONE;
  27206. + }
  27207. + }
  27208. +)
  27209. +
  27210. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27211. +;; and these are the iorsi3 parts.. ;;
  27212. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27213. +
  27214. +;; register | register ops
  27215. +(define_insn "*ior_si_rrr"
  27216. + [(set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  27217. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  27218. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f")))]
  27219. + "!TARGET_METAC_1_1 || TARGET_MTX"
  27220. + "OR%?\\t%0, %1, %2\\t%@ (*ior si xdd OK)"
  27221. + [(set_attr "type" "fast,fast,slow,slow")
  27222. + (set_attr "cond" "yes,yes,yes,yes")
  27223. + (set_attr "predicable" "yes")])
  27224. +
  27225. +;; register | register ops - v1.1 case
  27226. +(define_insn "*ior_si_rrr_1_1"
  27227. + [(set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  27228. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  27229. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf")))]
  27230. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE && !TARGET_MTX"
  27231. + "OR%?\\t%0, %1, %2\\t%@ (*ior si xdb OK)"
  27232. + [(set_attr "type" "fast,fast,slow,slow")
  27233. + (set_attr "cond" "yes,yes,yes,yes")
  27234. + (set_attr "predicable" "yes")
  27235. + (set_attr "o2rhint" "op2op1")])
  27236. +
  27237. +;; register | register ops - minim case
  27238. +(define_insn "*ior_si_rrr_minim"
  27239. + [(set (match_operand:SI 0 "metag_register_op" "=e,!e, f,!f, r,!r, r,!r")
  27240. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, e, f, f, e, e, f, f")
  27241. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, be,f, bf,e, be,f, bf")))]
  27242. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE && !TARGET_MTX"
  27243. + "OR%?\\t%0, %1, %2\\t%@ (*ior si xdb OK)"
  27244. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27245. + (set_attr "cond" "yes")
  27246. + (set_attr "predicable" "yes")
  27247. + (set_attr "o2rhint" "op2op1")])
  27248. +
  27249. +;; register | immediate ops
  27250. +(define_insn "*ior_si_rri"
  27251. + [(set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,e,f,r")
  27252. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,e,f,d")
  27253. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K,K")))]
  27254. + "!TARGET_MINIM_CORE"
  27255. + "@
  27256. + OR\\t%0, %1, %2\\t%@ (*ior si r0I OK)
  27257. + ORT\\t%0, %1, #HI(%c2)\\t%@ (*ior si r0J OK)
  27258. + ORMB\\t%0, %1, #LO(%c2)\\t%@ (*ior si r0M OK)
  27259. + ORMT\\t%0, %1, #HI(%c2)\\t%@ (*ior si r0N OK)
  27260. + OR%?\\t%0, %1, %2\\t\\t%@ (*ior si eeK OK)
  27261. + OR%?\\t%0, %1, %2\\t\\t%@ (*ior si ffK OK)
  27262. + OR\\t%0, %1, %2\\t\\t%@ (*ior si rdK OK)"
  27263. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow")
  27264. + (set_attr "cond" "no,no,no,no,yes,yes,no")])
  27265. +
  27266. +;; register | immediate ops
  27267. +(define_insn "*ior_si_rri"
  27268. + [(set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,d,!e,!f,!r")
  27269. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,0, e, f, d")
  27270. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K, K, K, K")))]
  27271. + "TARGET_MINIM_CORE"
  27272. + "@
  27273. + OR\\t%0, %1, %2\\t%@ (*ior si r0I OK)
  27274. + ORT\\t%0, %1, #HI(%c2)\\t%@ (*ior si r0J OK)
  27275. + ORMB\\t%0, %1, #LO(%c2)\\t%@ (*ior si r0M OK)
  27276. + ORMT\\t%0, %1, #HI(%c2)\\t%@ (*ior si r0N OK)
  27277. + OR%?\\t%0, %1, %2\\t\\t%@ (*ior si d0K OK)
  27278. + OR%?\\t%0, %1, %2\\t\\t%@ (*ior si eeK OK)
  27279. + OR%?\\t%0, %1, %2\\t\\t%@ (*ior si ffK OK)
  27280. + OR\\t%0, %1, %2\\t\\t%@ (*ior si rdK OK)"
  27281. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,slow")
  27282. + (set_attr "cond" "no,no,no,no,yes,yes,yes,no")])
  27283. +
  27284. +;; conditional version for specific cases of ior_si_rri
  27285. +(define_insn "*cond_<mode>_ior_si_rri"
  27286. + [(cond_exec
  27287. + (match_operator 3 "comparison_operator"
  27288. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27289. + (const_int 0)])
  27290. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27291. + (ior:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27292. + (match_operand:SI 2 "metag_K_operand" "K,K"))))]
  27293. + "reload_completed
  27294. + && metag_same_regclass_p (operands[0], operands[1])"
  27295. + "@
  27296. + OR%?\\t%0, %1, %2\\t\\t%@ (*ior si eeK OK)
  27297. + OR%?\\t%0, %1, %2\\t\\t%@ (*ior si ffK OK)"
  27298. + [(set_attr "type" "fast")
  27299. + (set_attr "cond" "no")])
  27300. +
  27301. +;; ior register ops combined with test cases
  27302. +(define_insn "*iors_<mode>_si_rrr"
  27303. + [(set (reg:<MODE> CC_REG)
  27304. + (compare:CCZNC
  27305. + (ior:SI (match_operand:SI 1 "metag_datareg_op" "%e,f,e,f")
  27306. + (match_operand:SI 2 "metag_datareg_op" "e,f,e,f"))
  27307. + (const_int 0)))
  27308. + (set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  27309. + (ior:SI (match_dup 1)
  27310. + (match_dup 2)))]
  27311. + "!TARGET_METAC_1_1 || TARGET_MTX"
  27312. + "ORS\\t%0, %1, %2\\t%@ (*iors si xdd OK)"
  27313. + [(set_attr "type" "fast,fast,slow,slow")
  27314. + (set_attr "ccstate" "set,set,set,set")])
  27315. +
  27316. +(define_insn "*iors_<mode>_si_rri"
  27317. + [(set (reg:<MODE> CC_REG)
  27318. + (compare:CCZNC
  27319. + (ior:SI (match_operand:SI 1 "metag_datareg_op" "0, 0,0,0,e,f,d")
  27320. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K,K"))
  27321. + (const_int 0)))
  27322. + (set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,e,f,r")
  27323. + (ior:SI (match_dup 1)
  27324. + (match_dup 2)))]
  27325. + ""
  27326. + "@
  27327. + ORS\\t%0, %1, %2\\t%@ (*iors si d0I OK)
  27328. + ORST\\t%0, %1, #HI(%c2)\\t%@ (*ands si d0J OK)
  27329. + ORSMB\\t%0, %1, #LO(%c2)\\t%@ (*iors si d0M OK)
  27330. + ORSMT\\t%0, %1, #HI(%c2)\\t%@ (*ands si d0N OK)
  27331. + ORS\\t%0, %1, %2\\t\\t%@ (*iors si eeK OK)
  27332. + ORS\\t%0, %1, %2\\t\\t%@ (*iors si ffK OK)
  27333. + ORS\\t%0, %1, %2\\t\\t%@ (*iors si ddK OK)"
  27334. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow")
  27335. + (set_attr "ccstate" "set,set,set,set,set,set,set")])
  27336. +
  27337. +;; ior register ops combined with test cases - v1.1 case
  27338. +(define_insn "*iors_<mode>_si_rrr_1_1"
  27339. + [(set (reg:<MODE> CC_REG)
  27340. + (compare:CCZNC
  27341. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  27342. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))
  27343. + (const_int 0)))
  27344. + (set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  27345. + (ior:SI (match_dup 1)
  27346. + (match_dup 2)))]
  27347. + "TARGET_METAC_1_1 && !TARGET_MTX"
  27348. + "ORS\\t%0, %1, %2\\t%@ (*iors si xdb OK)"
  27349. + [(set_attr "type" "fast,fast,slow,slow")
  27350. + (set_attr "ccstate" "set,set,set,set")
  27351. + (set_attr "o2rhint" "op2op1")])
  27352. +
  27353. +;; scratch ior register ops setting the NOOV flags - needed to enable combines
  27354. +(define_insn "*tior_<mode>_si_rr"
  27355. + [(set (reg:<MODE> CC_REG)
  27356. + (compare:CCZNC
  27357. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  27358. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f"))
  27359. + (const_int 0)))
  27360. + (clobber (match_scratch:SI 0 "=e,f,r,r"))]
  27361. + "!TARGET_METAC_1_1 || TARGET_MTX"
  27362. + "ORS\\t%0, %1, %2\\t%@ (*tior si xdd OK)"
  27363. + [(set_attr "type" "fast,fast,slow,slow")
  27364. + (set_attr "ccstate" "set,set,set,set")])
  27365. +
  27366. +(define_insn "*tior_<mode>_si_ri"
  27367. + [(set (reg:<MODE> CC_REG)
  27368. + (compare:CCZNC
  27369. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,e,f")
  27370. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K"))
  27371. + (const_int 0)))
  27372. + (clobber (match_scratch:SI 0 "=d, d,d,d,e,f"))]
  27373. + ""
  27374. + "@
  27375. + ORS\\t%0, %1, %2\\t%@ (*tior si dI OK)
  27376. + ORST\\t%0, %1, #HI(%c2)\\t%@ (*tior si dJ OK)
  27377. + ORSMB\\t%0, %1, #LO(%c2)\\t%@ (*tior si dM OK)
  27378. + ORSMT\\t%0, %1, #HI(%c2)\\t%@ (*tior si dN OK)
  27379. + ORS\\t%0, %1, %2\\t\\t%@ (*tior si eK OK)
  27380. + ORS\\t%0, %1, %2\\t\\t%@ (*tior si fK OK)"
  27381. + [(set_attr "type" "fast,fast,fast,fast,fast,fast")
  27382. + (set_attr "ccstate" "set,set,set,set,set,set")])
  27383. +
  27384. +;; scratch ior register ops setting the NOOV flags - v1.1 case
  27385. +(define_insn "*tior_<mode>_si_rr_1_1"
  27386. + [(set (reg:<MODE> CC_REG)
  27387. + (compare:CCZNC
  27388. + (ior:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  27389. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))
  27390. + (const_int 0)))
  27391. + (clobber (match_scratch:SI 0 "=e, f, r, r"))]
  27392. + "TARGET_METAC_1_1 && !TARGET_MTX"
  27393. + "ORS\\t%0, %1, %2\\t%@ (*tior si xdb OK)"
  27394. + [(set_attr "type" "fast,fast,slow,slow")
  27395. + (set_attr "ccstate" "set,set,set,set")
  27396. + (set_attr "o2rhint" "op2op1")])
  27397. +
  27398. +;; exclusive-or instructions
  27399. +
  27400. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27401. +;; and these are the xordi3 parts.. ;;
  27402. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27403. +
  27404. +(define_insn "*xordi3_rri"
  27405. + [(set (match_operand:DI 0 "metag_register_op" "+d")
  27406. + (xor:DI (match_dup 0)
  27407. + (match_operand:DI 1 "metag_16bit_op" "KIP")))]
  27408. + "TARGET_DSP"
  27409. + "DL\\tXOR\\t%0, %0, %1\\t%@ (*OR\\t%t0, %t0, %1)"
  27410. + [(set_attr "type" "fast")])
  27411. +
  27412. +(define_insn "xordi3"
  27413. + [(set (match_operand:DI 0 "metag_register_op" "=d")
  27414. + (xor:DI (match_operand:DI 1 "metag_register_op" "d")
  27415. + (match_operand:DI 2 "metag_register_op" "d")))]
  27416. + "TARGET_DSP"
  27417. + "DL\\tXOR\\t%0, %1, %2\\t%@ (*OR\\t%t0, %t1, %t2)"
  27418. + [(set_attr "type" "fast")])
  27419. +
  27420. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27421. +;; xorsi3 is made up of many parts.. ;;
  27422. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27423. +(define_expand "xorsi3"
  27424. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  27425. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")
  27426. + (match_operand:SI 2 "metag_regorint_op" "")))]
  27427. + ""
  27428. + {
  27429. + if (CONST_INT_P (operands[2])
  27430. + && METAG_LETTER_FOR_CONST (operands[2]) == 0)
  27431. + {
  27432. + /* Need to use I,J cases to implement op */
  27433. + rtx temp = (reload_in_progress || reload_completed)
  27434. + ? operands[0] : gen_reg_rtx (SImode);
  27435. + HOST_WIDE_INT value = INTVAL (operands[2]);
  27436. + HOST_WIDE_INT ival;
  27437. +
  27438. + ival = trunc_int_for_mode (value & 0xFFFF0000, SImode);
  27439. + emit_insn (gen_rtx_SET (VOIDmode, temp,
  27440. + gen_rtx_XOR (SImode, operands[1],
  27441. + GEN_INT (ival))));
  27442. +
  27443. + ival = trunc_int_for_mode (value & 0x0000FFFF, SImode);
  27444. + emit_insn (gen_rtx_SET (VOIDmode, operands[0],
  27445. + gen_rtx_XOR (SImode, temp,
  27446. + GEN_INT (ival))));
  27447. + DONE;
  27448. + }
  27449. + }
  27450. +)
  27451. +
  27452. +;; register ^ register ops
  27453. +
  27454. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27455. +;; and these are the xorsi3 parts.. ;;
  27456. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  27457. +
  27458. +;; register ^ register ops
  27459. +(define_insn "*xor_si_rrr"
  27460. + [(set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  27461. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  27462. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f")))]
  27463. + "!TARGET_METAC_1_1 || TARGET_MTX"
  27464. + "XOR%?\\t%0, %1, %2\\t%@ (*xor si xdd OK)"
  27465. + [(set_attr "type" "fast,fast,slow,slow")
  27466. + (set_attr "cond" "yes,yes,yes,yes")
  27467. + (set_attr "predicable" "yes")])
  27468. +
  27469. +;; register ^ register ops - v1.1 case
  27470. +(define_insn "*xor_si_rrr_1_1"
  27471. + [(set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  27472. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  27473. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf")))]
  27474. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE && !TARGET_MTX"
  27475. + "XOR%?\\t%0, %1, %2\\t%@ (*xor si xdb OK)"
  27476. + [(set_attr "type" "fast,fast,slow,slow")
  27477. + (set_attr "cond" "yes,yes,yes,yes")
  27478. + (set_attr "predicable" "yes")
  27479. + (set_attr "o2rhint" "op2op1")])
  27480. +
  27481. +;; register ^ register ops - minim case
  27482. +(define_insn "*xor_si_rrr_minim"
  27483. + [(set (match_operand:SI 0 "metag_register_op" "=e,!e, f,!f, r,!r, r,!r")
  27484. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, e, f, f, e, e, f, f")
  27485. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, be,f, bf,e, be,f, bf")))]
  27486. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE && !TARGET_MTX"
  27487. + "XOR%?\\t%0, %1, %2\\t%@ (*xor si xdb OK)"
  27488. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27489. + (set_attr "cond" "yes")
  27490. + (set_attr "predicable" "yes")
  27491. + (set_attr "o2rhint" "op2op1")])
  27492. +
  27493. +;; same register ^ immediate ops
  27494. +(define_insn "*xor_si_rri"
  27495. + [(set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,e,f,r")
  27496. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,e,f,d")
  27497. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K,K")))]
  27498. + "!TARGET_MINIM_CORE"
  27499. + "@
  27500. + XOR\\t%0, %1, %2\\t%@ (*xor si d0I OK)
  27501. + XORT\\t%0, %1, #HI(%c2)\\t%@ (*xor si d0J OK)
  27502. + XORMB\\t%0, %1, #LO(%c2)\\t%@ (*xor si d0M OK)
  27503. + XORMT\\t%0, %1, #HI(%c2)\\t%@ (*xor si d0N OK)
  27504. + XOR%?\\t%0, %1, %2\\t\\t%@ (*xor si eeK OK)
  27505. + XOR%?\\t%0, %1, %2\\t\\t%@ (*xor si ffK OK)
  27506. + XOR\\t%0, %1, %2\\t\\t%@ (*xor si rdK OK)"
  27507. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow")
  27508. + (set_attr "cond" "no,no,no,no,yes,yes,no")])
  27509. +
  27510. +;; same register ^ immediate ops
  27511. +(define_insn "*xor_si_rri"
  27512. + [(set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,d,e,f,r")
  27513. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,0,e,f,d")
  27514. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K,K,K")))]
  27515. + "TARGET_MINIM_CORE"
  27516. + "@
  27517. + XOR\\t%0, %1, %2\\t%@ (*xor si d0I OK)
  27518. + XORT\\t%0, %1, #HI(%c2)\\t%@ (*xor si d0J OK)
  27519. + XORMB\\t%0, %1, #LO(%c2)\\t%@ (*xor si d0M OK)
  27520. + XORMT\\t%0, %1, #HI(%c2)\\t%@ (*xor si d0N OK)
  27521. + XOR%?\\t%0, %1, %2\\t\\t%@ (*xor si d0K OK)
  27522. + XOR%?\\t%0, %1, %2\\t\\t%@ (*xor si eeK OK)
  27523. + XOR%?\\t%0, %1, %2\\t\\t%@ (*xor si ffK OK)
  27524. + XOR\\t%0, %1, %2\\t\\t%@ (*xor si rdK OK)"
  27525. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,slow")
  27526. + (set_attr "cond" "no,no,no,no,yes,yes,yes,no")])
  27527. +
  27528. +;; conditional version for specific cases of xor_si_rri
  27529. +(define_insn "*cond_<mode>_xor_si_rri"
  27530. + [(cond_exec
  27531. + (match_operator 3 "comparison_operator"
  27532. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27533. + (const_int 0)])
  27534. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27535. + (xor:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27536. + (match_operand:SI 2 "metag_K_operand" "K,K"))))]
  27537. + "reload_completed
  27538. + && metag_same_regclass_p (operands[0], operands[1])"
  27539. + "@
  27540. + XOR%?\\t%0, %1, %2\\t\\t%@ (*xor si eeK OK)
  27541. + XOR%?\\t%0, %1, %2\\t\\t%@ (*xor si ffK OK)"
  27542. + [(set_attr "type" "fast")
  27543. + (set_attr "cond" "no")])
  27544. +
  27545. +;; xor register ops combined with test cases
  27546. +(define_insn "*xors_<mode>_si_rrr"
  27547. + [(set (reg:<MODE> CC_REG)
  27548. + (compare:CCZNC
  27549. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  27550. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f"))
  27551. + (const_int 0)))
  27552. + (set (match_operand:SI 0 "metag_register_op" "=e,f,r,r")
  27553. + (xor:SI (match_dup 1)
  27554. + (match_dup 2)))]
  27555. + "!TARGET_METAC_1_1 || TARGET_MTX"
  27556. + "XORS\\t%0, %1, %2\\t%@ (*xors si xdd OK)"
  27557. + [(set_attr "type" "fast,fast,slow,slow")
  27558. + (set_attr "ccstate" "set,set,set,set")])
  27559. +
  27560. +(define_insn "*xors_<mode>_si_rri"
  27561. + [(set (reg:<MODE> CC_REG)
  27562. + (compare:CCZNC
  27563. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,e,f,d")
  27564. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K,K"))
  27565. + (const_int 0)))
  27566. + (set (match_operand:SI 0 "metag_register_op" "=d, d,d,d,e,f,r")
  27567. + (xor:SI (match_dup 1)
  27568. + (match_dup 2)))]
  27569. + ""
  27570. + "@
  27571. + XORS\\t%0, %1, %2\\t%@ (*xors si d0I OK)
  27572. + XORST\\t%0, %1, #HI(%c2)\\t%@ (*xors si d0J OK)
  27573. + XORSMB\\t%0, %1, #LO(%c2)\\t%@ (*xors si d0M OK)
  27574. + XORSMT\\t%0, %1, #HI(%c2)\\t%@ (*xors si d0N OK)
  27575. + XORS\\t%0, %1, %2\\t\\t%@ (*xors si eeK OK)
  27576. + XORS\\t%0, %1, %2\\t\\t%@ (*xors si ffK OK)
  27577. + XORS\\t%0, %1, %2\\t\\t%@ (*xors si rdK OK)"
  27578. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow")
  27579. + (set_attr "ccstate" "set,set,set,set,set,set,set")])
  27580. +
  27581. +;; xor register ops combined with test cases - v1.1 case
  27582. +(define_insn "*xors_<mode>_si_rrr_1_1"
  27583. + [(set (reg:<MODE> CC_REG)
  27584. + (compare:CCZNC
  27585. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  27586. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))
  27587. + (const_int 0)))
  27588. + (set (match_operand:SI 0 "metag_register_op" "=e, f, r, r")
  27589. + (xor:SI (match_dup 1)
  27590. + (match_dup 2)))]
  27591. + "TARGET_METAC_1_1 && !TARGET_MTX"
  27592. + "XORS\\t%0, %1, %2\\t%@ (*xors si xdb OK)"
  27593. + [(set_attr "type" "fast,fast,slow,slow")
  27594. + (set_attr "ccstate" "set,set,set,set")
  27595. + (set_attr "o2rhint" "op2op1")])
  27596. +
  27597. +;; scratch xor register ops setting the NOOV flags - needed to enable combines
  27598. +(define_insn "*txor_<mode>_si_rr"
  27599. + [(set (reg:<MODE> CC_REG)
  27600. + (compare:CCZNC
  27601. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f,e,f")
  27602. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f,e,f"))
  27603. + (const_int 0)))
  27604. + (clobber (match_scratch:SI 0 "=e,f,r,r"))]
  27605. + "!TARGET_METAC_1_1 || TARGET_MTX"
  27606. + "XORS\\t%0, %1, %2\\t%@ (*txor si xdd OK)"
  27607. + [(set_attr "type" "fast,fast,slow,slow")
  27608. + (set_attr "ccstate" "set,set,set,set")])
  27609. +
  27610. +(define_insn "*txor_<mode>_si_ri"
  27611. + [(set (reg:<MODE> CC_REG)
  27612. + (compare:CCZNC
  27613. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0, 0,0,0,e,f")
  27614. + (match_operand:SI 2 "metag_int_operand" "IP,J,M,N,K,K"))
  27615. + (const_int 0)))
  27616. + (clobber (match_scratch:SI 0 "=d, d,d,d,e,f"))]
  27617. + ""
  27618. + "@
  27619. + XORS\\t%0, %1, %2\\t%@ (*txor si dI OK)
  27620. + XORST\\t%0, %1, #HI(%c2)\\t%@ (*txor si dJ OK)
  27621. + XORSMB\\t%0, %1, #LO(%c2)\\t%@ (*txor si dM OK)
  27622. + XORSMT\\t%0, %1, #HI(%c2)\\t%@ (*txor si dN OK)
  27623. + XORS\\t%0, %1, %2\\t\\t%@ (*txor si eK OK)
  27624. + XORS\\t%0, %1, %2\\t\\t%@ (*txor si fK OK)"
  27625. + [(set_attr "type" "fast,fast,fast,fast,fast,fast")
  27626. + (set_attr "ccstate" "set,set,set,set,set,set")])
  27627. +
  27628. +;; scratch xor register ops setting the NOOV flags - v1.1 case
  27629. +(define_insn "*txor_<mode>_si_rr_1_1"
  27630. + [(set (reg:<MODE> CC_REG)
  27631. + (compare:CCZNC
  27632. + (xor:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e, f, e, f")
  27633. + (match_operand:SI 2 "metag_reg_nofloat_op" "be,bf,be,bf"))
  27634. + (const_int 0)))
  27635. + (clobber (match_scratch:SI 0 "=e, f, r, r"))]
  27636. + "TARGET_METAC_1_1 && !TARGET_MTX"
  27637. + "XORS\\t%0, %1, %2\\t%@ (*txor si xdd OK)"
  27638. + [(set_attr "type" "fast,fast,slow,slow")
  27639. + (set_attr "ccstate" "set,set,set,set")
  27640. + (set_attr "o2rhint" "op2op1")])
  27641. +
  27642. +;; rotate instructions
  27643. +(define_insn "rotsi2_16"
  27644. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=d,e,f")
  27645. + (rotate:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0,e,f")
  27646. + (const_int 16)))]
  27647. + ""
  27648. + "RTDW\\t%0, %1"
  27649. + [(set_attr "type" "fast,fast,fast")])
  27650. +
  27651. +(define_insn "parallel_rotsi2_16"
  27652. + [(parallel
  27653. + [(set (subreg:SI (match_operand:DI 0 "metag_datareg_op" "=d") 0)
  27654. + (rotate:SI (subreg:SI (match_operand:DI 1 "metag_datareg_op" "d") 0)
  27655. + (const_int 16)))
  27656. + (set (subreg:SI (match_dup 0) 4)
  27657. + (rotate:SI (subreg:SI (match_dup 1) 4)
  27658. + (const_int 16)))])]
  27659. + "TARGET_DSP"
  27660. + "DL\\tRTDW\\t%0, %1"
  27661. + [(set_attr "type" "fast")])
  27662. +
  27663. +;; arithmetic shift instructions
  27664. +
  27665. +(define_expand "ashlsi3"
  27666. + [(set (match_operand:SI 0 "metag_register_op" "")
  27667. + (ashift:SI (match_operand:SI 1 "metag_register_op" "")
  27668. + (match_operand:SI 2 "metag_regorint_op" "")))]
  27669. + ""
  27670. + "")
  27671. +
  27672. +(define_insn "*ashlsi3"
  27673. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27674. + (ashift:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27675. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L")))]
  27676. + "!TARGET_MINIM_CORE"
  27677. + "LSL%?\\t%0, %1, %2\\t%@ (*ashl si rrx OK)"
  27678. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27679. + (set_attr "cond" "yes,yes,yes,yes,no,no,no,no")])
  27680. +
  27681. +(define_insn "*ashlsi3_minim"
  27682. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,!e,f,f,!f,r,r,r,r")
  27683. + (ashift:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,0, e,f,0, f,e,e,f,f")
  27684. + (match_operand:SI 2 "metag_regorint_op" "e,L, L,f,L, L,e,L,f,L")))]
  27685. + "TARGET_MINIM_CORE"
  27686. + "LSL%?\\t%0, %1, %2\\t%@ (*ashl si rrx OK)"
  27687. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow,slow,slow,slow")
  27688. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,no,no,no,no")])
  27689. +
  27690. +;; conditional version for specific cases of ashlsi3
  27691. +(define_insn "*cond_<mode>_ashlsi3_rrr"
  27692. + [(cond_exec
  27693. + (match_operator 3 "comparison_operator"
  27694. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27695. + (const_int 0)])
  27696. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27697. + (ashift:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27698. + (match_operand:SI 2 "metag_datareg_op" "e,f"))))]
  27699. + "reload_completed
  27700. + && metag_same_regclass_p (operands[0], operands[1])
  27701. + && metag_same_regclass_p (operands[0], operands[2])"
  27702. + "@
  27703. + LSL%?\\t%0, %1, %2\\t%@ (*ashl si eee OK)
  27704. + LSL%?\\t%0, %1, %2\\t%@ (*ashl si fff OK)"
  27705. + [(set_attr "type" "fast,fast")
  27706. + (set_attr "cond" "no")])
  27707. +
  27708. +(define_insn "*cond_<mode>_ashlsi3_rrL"
  27709. + [(cond_exec
  27710. + (match_operator 3 "comparison_operator"
  27711. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27712. + (const_int 0)])
  27713. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27714. + (ashift:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27715. + (match_operand:SI 2 "metag_L_operand" "L,L"))))]
  27716. + "reload_completed
  27717. + && metag_same_regclass_p (operands[0], operands[1])"
  27718. + "@
  27719. + LSL%?\\t%0, %1, %2\\t%@ (*ashl si eeL OK)
  27720. + LSL%?\\t%0, %1, %2\\t%@ (*ashl si ffL OK)"
  27721. + [(set_attr "type" "fast,fast")
  27722. + (set_attr "cond" "no")])
  27723. +
  27724. +(define_expand "ashrsi3"
  27725. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27726. + (ashiftrt:SI (match_operand:SI 1 "metag_datareg_op" "e,e,f,f,e,e,f,f")
  27727. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L")))]
  27728. + ""
  27729. + "")
  27730. +
  27731. +(define_insn "*ashrsi3"
  27732. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27733. + (ashiftrt:SI (match_operand:SI 1 "metag_datareg_op" "e,e,f,f,e,e,f,f")
  27734. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L")))]
  27735. + "!TARGET_MINIM_CORE"
  27736. + "ASR%?\\t%0, %1, %2\\t%@ (*ashr si rrx OK)"
  27737. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27738. + (set_attr "cond" "yes,yes,yes,yes,no,no,no,no")])
  27739. +
  27740. +(define_insn "*ashrsi3_minim"
  27741. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,!e,f,f,!f,r,r,r,r")
  27742. + (ashiftrt:SI (match_operand:SI 1 "metag_datareg_op" "e,0, e,f,0, f,e,e,f,f")
  27743. + (match_operand:SI 2 "metag_regorint_op" "e,L, L,f,L, L,e,L,f,L")))]
  27744. + "TARGET_MINIM_CORE"
  27745. + "ASR%?\\t%0, %1, %2\\t%@ (*ashr si rrx OK)"
  27746. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow,slow,slow,slow")
  27747. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,no,no,no,no")])
  27748. +
  27749. +;; conditional version for specific cases of ashrsi3
  27750. +(define_insn "*cond_<mode>_ashrsi3_rrr"
  27751. + [(cond_exec
  27752. + (match_operator 3 "comparison_operator"
  27753. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27754. + (const_int 0)])
  27755. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27756. + (ashiftrt:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27757. + (match_operand:SI 2 "metag_datareg_op" "e,f"))))]
  27758. + "reload_completed
  27759. + && metag_same_regclass_p (operands[0], operands[1])
  27760. + && metag_same_regclass_p (operands[0], operands[2])"
  27761. + "@
  27762. + ASR%?\\t%0, %1, %2\\t%@ (*ashr si eee OK)
  27763. + ASR%?\\t%0, %1, %2\\t%@ (*ashr si fff OK)"
  27764. + [(set_attr "type" "fast,fast")
  27765. + (set_attr "cond" "no")])
  27766. +
  27767. +(define_insn "*cond_<mode>_ashrsi3_rrL"
  27768. + [(cond_exec
  27769. + (match_operator 3 "comparison_operator"
  27770. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27771. + (const_int 0)])
  27772. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27773. + (ashiftrt:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27774. + (match_operand:SI 2 "metag_L_operand" "L,L"))))]
  27775. + "reload_completed
  27776. + && metag_same_regclass_p (operands[0], operands[1])"
  27777. + "@
  27778. + ASR%?\\t%0, %1, %2\\t%@ (*ashr si eeL OK)
  27779. + ASR%?\\t%0, %1, %2\\t%@ (*ashr si ffL OK)"
  27780. + [(set_attr "type" "fast,fast")
  27781. + (set_attr "cond" "no")])
  27782. +
  27783. +(define_insn_and_split "*ashrdi3_32"
  27784. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "=d,a")
  27785. + (ashiftrt:DI (match_operand:DI 1 "metag_datareg_op" "d,d")
  27786. + (const_int 32)))]
  27787. + ""
  27788. + "#"
  27789. + "SPLIT_EARLY"
  27790. + [(set (match_dup 2)
  27791. + (match_dup 4))
  27792. + (set (match_dup 3)
  27793. + (ashiftrt:SI (match_dup 4)
  27794. + (const_int 31)))]
  27795. + {
  27796. + if (reload_completed)
  27797. + {
  27798. + operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));
  27799. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  27800. +
  27801. + operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  27802. + }
  27803. + else
  27804. + {
  27805. + operands[2] = gen_rtx_SUBREG (SImode, operands[0], 0);
  27806. + operands[3] = gen_rtx_SUBREG (SImode, operands[0], UNITS_PER_WORD);
  27807. +
  27808. + operands[4] = gen_rtx_SUBREG (SImode, operands[1], UNITS_PER_WORD);
  27809. + }
  27810. + }
  27811. + [(set_attr "type" "two,slowslow")])
  27812. +
  27813. +;; logical shift instructions
  27814. +
  27815. +(define_expand "lshrsi3"
  27816. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27817. + (lshiftrt:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27818. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L")))]
  27819. + ""
  27820. + "")
  27821. +
  27822. +(define_insn "*lshrsi3"
  27823. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27824. + (lshiftrt:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27825. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L")))]
  27826. + "!TARGET_MINIM_CORE"
  27827. + "LSR%?\\t%0, %1, %2\\t%@ (lshr si rrx OK)"
  27828. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27829. + (set_attr "cond" "yes,yes,yes,yes,no,no,no,no")])
  27830. +
  27831. +(define_insn "*lshrsi3_minim"
  27832. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,!e,f,f,!f,r,r,r,r")
  27833. + (lshiftrt:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,0, e,f,0, f,e,e,f,f")
  27834. + (match_operand:SI 2 "metag_regorint_op" "e,L, L,f,L, L,e,L,f,L")))]
  27835. + "TARGET_MINIM_CORE"
  27836. + "LSR%?\\t%0, %1, %2\\t%@ (lshr si rrx OK)"
  27837. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,slow,slow,slow,slow")
  27838. + (set_attr "cond" "yes,yes,yes,yes,yes,yes,no,no,no,no")])
  27839. +
  27840. +;; conditional version for specific cases of lshrsi3
  27841. +(define_insn "*cond_<mode>_lshrsi3_rrr"
  27842. + [(cond_exec
  27843. + (match_operator 3 "comparison_operator"
  27844. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27845. + (const_int 0)])
  27846. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27847. + (lshiftrt:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27848. + (match_operand:SI 2 "metag_datareg_op" "e,f"))))]
  27849. + "reload_completed
  27850. + && metag_same_regclass_p (operands[0], operands[1])
  27851. + && metag_same_regclass_p (operands[0], operands[2])"
  27852. + "@
  27853. + LSR%?\\t%0, %1, %2\\t%@ (lshr si eee OK)
  27854. + LSR%?\\t%0, %1, %2\\t%@ (lshr si fff OK)"
  27855. + [(set_attr "type" "fast,fast")
  27856. + (set_attr "cond" "no")])
  27857. +
  27858. +(define_insn "*cond_<mode>_lshrsi3_rrL"
  27859. + [(cond_exec
  27860. + (match_operator 3 "comparison_operator"
  27861. + [(match_operand:CCALL 4 "metag_<mode>_reg" "")
  27862. + (const_int 0)])
  27863. + (set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  27864. + (lshiftrt:SI (match_operand:SI 1 "metag_datareg_op" "e,f")
  27865. + (match_operand:SI 2 "metag_L_operand" "L,L"))))]
  27866. + "reload_completed
  27867. + && metag_same_regclass_p (operands[0], operands[1])"
  27868. + "@
  27869. + LSR%?\\t%0, %1, %2\\t%@ (lshr si eeL OK)
  27870. + LSR%?\\t%0, %1, %2\\t%@ (lshr si ffL OK)"
  27871. + [(set_attr "type" "fast,fast")
  27872. + (set_attr "cond" "no")])
  27873. +
  27874. +;; shift instructions combined with setting NOOV flags
  27875. +
  27876. +(define_insn "*ashls_<mode>_si_rrx"
  27877. + [(set (reg:<MODE> CC_REG)
  27878. + (compare:CCZNC
  27879. + (ashift:SI
  27880. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27881. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L"))
  27882. + (const_int 0)))
  27883. + (set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27884. + (ashift:SI (match_dup 1)
  27885. + (match_dup 2)))]
  27886. + ""
  27887. + "LSLS\\t%0, %1, %2\\t%@ (*ashls si rrx OK)"
  27888. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27889. + (set_attr "ccstate" "set,set,set,set,set,set,set,set")])
  27890. +
  27891. +(define_insn "*ashrs_<mode>_si_rrx"
  27892. + [(set (reg:<MODE> CC_REG)
  27893. + (compare:CCZNC
  27894. + (ashiftrt:SI
  27895. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27896. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L"))
  27897. + (const_int 0)))
  27898. + (set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27899. + (ashiftrt:SI (match_dup 1)
  27900. + (match_dup 2)))]
  27901. + ""
  27902. + "ASRS\\t%0, %1, %2\\t%@ (*ashrs si rrx OK)"
  27903. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27904. + (set_attr "ccstate" "set,set,set,set,set,set,set,set")])
  27905. +
  27906. +(define_insn "*lshrs_<mode>_si_rrx"
  27907. + [(set (reg:<MODE> CC_REG)
  27908. + (compare:CCZNC
  27909. + (lshiftrt:SI
  27910. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27911. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L"))
  27912. + (const_int 0)))
  27913. + (set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  27914. + (lshiftrt:SI (match_dup 1)
  27915. + (match_dup 2)))]
  27916. + ""
  27917. + "LSRS\\t%0, %1, %2\\t%@ (lshrs si rrx OK)"
  27918. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27919. + (set_attr "ccstate" "set,set,set,set,set,set,set,set")])
  27920. +
  27921. +;; shift instructions setting NOOV flags using scratch
  27922. +(define_insn "*tashls_<mode>_si_rrx"
  27923. + [(set (reg:<MODE> CC_REG)
  27924. + (compare:CCZNC
  27925. + (ashift:SI
  27926. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27927. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L"))
  27928. + (const_int 0)))
  27929. + (clobber (match_scratch:SI 0 "=e,e,f,f,r,r,r,r"))]
  27930. + ""
  27931. + "LSLS\\t%0, %1, %2\\t%@ (tashls si rrx OK)"
  27932. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27933. + (set_attr "ccstate" "set,set,set,set,set,set,set,set")])
  27934. +
  27935. +(define_insn "*tashrs_<mode>_si_rrx"
  27936. + [(set (reg:<MODE> CC_REG)
  27937. + (compare:CCZNC
  27938. + (ashiftrt:SI
  27939. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27940. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L"))
  27941. + (const_int 0)))
  27942. + (clobber (match_scratch:SI 0 "=e,e,f,f,r,r,r,r"))]
  27943. + ""
  27944. + "ASRS\\t%0, %1, %2\\t%@ (tashrs si rrx OK)"
  27945. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27946. + (set_attr "ccstate" "set,set,set,set,set,set,set,set")])
  27947. +
  27948. +(define_insn "*tlshrs_<mode>_si_rrx"
  27949. + [(set (reg:<MODE> CC_REG)
  27950. + (compare:CCZNC
  27951. + (lshiftrt:SI
  27952. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  27953. + (match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L"))
  27954. + (const_int 0)))
  27955. + (clobber (match_scratch:SI 0 "=e,e,f,f,r,r,r,r"))]
  27956. + ""
  27957. + "LSRS\\t%0, %1, %2\\t%@ (tlshrs si rrx OK)"
  27958. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  27959. + (set_attr "ccstate" "set,set,set,set,set,set,set,set")])
  27960. +
  27961. +;; negate instructions
  27962. +
  27963. +;; DImode negate
  27964. +(define_expand "negdi2"
  27965. + [(parallel
  27966. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "")
  27967. + (neg:DI (match_operand:DI 1 "metag_reg_nofloat_op" "")))
  27968. + (clobber (reg:CC CC_REG))])]
  27969. + ""
  27970. + "")
  27971. +
  27972. +(define_insn_and_split "*negdi2"
  27973. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "=d")
  27974. + (neg:DI (match_operand:DI 1 "metag_reg_nofloat_op" "d")))
  27975. + (clobber (reg:CC CC_REG))]
  27976. + ""
  27977. + "#"
  27978. + "SPLIT_EARLY"
  27979. + [(parallel
  27980. + [(set (reg:CC_Z CC_REG)
  27981. + (compare:CC_Z (neg:SI (match_dup 5))
  27982. + (const_int 0)))
  27983. + (set (match_dup 3)
  27984. + (neg:SI (match_dup 5)))])
  27985. + (set (match_dup 4)
  27986. + (neg:SI (match_dup 6)))
  27987. + (set (match_dup 4)
  27988. + (if_then_else:SI (ne (reg:CC_Z CC_REG)
  27989. + (const_int 0))
  27990. + (plus:SI (match_dup 4)
  27991. + (const_int -1))
  27992. + (match_dup 4)))]
  27993. + {
  27994. + if (reload_completed)
  27995. + {
  27996. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]));
  27997. + operands[4] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  27998. +
  27999. + operands[5] = gen_rtx_REG (SImode, REGNO (operands[1]));
  28000. + operands[6] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  28001. + }
  28002. + else
  28003. + {
  28004. + operands[3] = gen_rtx_SUBREG (SImode, operands[0], 0);
  28005. + operands[4] = gen_rtx_SUBREG (SImode, operands[0], UNITS_PER_WORD);
  28006. +
  28007. + operands[5] = gen_rtx_SUBREG (SImode, operands[1], 0);
  28008. + operands[6] = gen_rtx_SUBREG (SImode, operands[1], UNITS_PER_WORD);
  28009. + }
  28010. + }
  28011. + [(set_attr "type" "three")
  28012. + (set_attr "ccstate" "ccx")])
  28013. +
  28014. +;; SImode negate
  28015. +(define_expand "negsi2"
  28016. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  28017. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")))]
  28018. + ""
  28019. + "")
  28020. +
  28021. +(define_insn "*negsi2"
  28022. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f")
  28023. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,f")))]
  28024. + "!TARGET_METAC_1_1"
  28025. + "NEG\\t%0, %1\\t\\t%@ (neg si dd OK)"
  28026. + [(set_attr "type" "fast,fast")])
  28027. +
  28028. +(define_insn "*negs_<mode>_si_rr"
  28029. + [(set (reg:<MODE> CC_REG)
  28030. + (compare:CCZNC
  28031. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,f"))
  28032. + (const_int 0)))
  28033. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f")
  28034. + (neg:SI (match_dup 1)))]
  28035. + "!TARGET_METAC_1_1"
  28036. + "NEGS\\t%0, %1\\t\\t%@ (negs si dd OK)"
  28037. + [(set_attr "type" "fast,fast")
  28038. + (set_attr "ccstate" "set,set")])
  28039. +
  28040. +(define_insn "*tneg_<mode>_si_rr"
  28041. + [(set (reg:<MODE> CC_REG)
  28042. + (compare:CCZNC
  28043. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,f"))
  28044. + (const_int 0)))
  28045. + (clobber (match_scratch:SI 0 "=e,f"))]
  28046. + "!TARGET_METAC_1_1"
  28047. + "NEGS\\t%0, %1\\t\\t%@ (tneg si dd OK)"
  28048. + [(set_attr "type" "fast,fast")
  28049. + (set_attr "ccstate" "set,set")])
  28050. +
  28051. +;; negate instructions - v1.1 case
  28052. +(define_insn "*negsi2_1_1"
  28053. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e, f")
  28054. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "be,bf")))]
  28055. + "TARGET_METAC_1_1 && !TARGET_MINIM_CORE"
  28056. + "NEG\\t%0, %1\\t\\t%@ (neg si db OK)"
  28057. + [(set_attr "type" "fast,fast")
  28058. + (set_attr "o2rhint" "op1op0")])
  28059. +
  28060. +;; negate instructions - minim case
  28061. +(define_insn "*negsi2_minim"
  28062. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,!e, f,!f")
  28063. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e, be,f, bf")))]
  28064. + "TARGET_METAC_1_1 && TARGET_MINIM_CORE"
  28065. + "NEG\\t%0, %1\\t\\t%@ (neg si db OK)"
  28066. + [(set_attr "type" "fast,fast,fast,fast")
  28067. + (set_attr "o2rhint" "op1op0")])
  28068. +
  28069. +(define_insn "*negs_<mode>_si_rr_1_1"
  28070. + [(set (reg:<MODE> CC_REG)
  28071. + (compare:CCZNC
  28072. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "be,bf"))
  28073. + (const_int 0)))
  28074. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "=e, f")
  28075. + (neg:SI (match_dup 1)))]
  28076. + "TARGET_METAC_1_1"
  28077. + "NEGS\\t%0, %1\\t\\t%@ (negs si db OK)"
  28078. + [(set_attr "type" "fast,fast")
  28079. + (set_attr "ccstate" "set,set")
  28080. + (set_attr "o2rhint" "op1op0")])
  28081. +
  28082. +(define_insn "*tneg_<mode>_si_rr_1_1"
  28083. + [(set (reg:<MODE> CC_REG)
  28084. + (compare:CCZNC
  28085. + (neg:SI (match_operand:SI 1 "metag_reg_nofloat_op" "be,bf"))
  28086. + (const_int 0)))
  28087. + (clobber (match_scratch:SI 0 "=e, f"))]
  28088. + "TARGET_METAC_1_1"
  28089. + "NEGS\\t%0, %1\\t\\t%@ (tneg si dx OK)"
  28090. + [(set_attr "type" "fast,fast")
  28091. + (set_attr "ccstate" "set,set")
  28092. + (set_attr "o2rhint" "op1op0")])
  28093. +
  28094. +;; complement instructions
  28095. +(define_insn "one_cmplsi2"
  28096. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,&e,&f")
  28097. + (not:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0,0, e, f")))]
  28098. + ""
  28099. + "@
  28100. + XOR\\t%0, %1, #-1\\t%@ (not si e0 OK)
  28101. + XOR\\t%0, %1, #-1\\t%@ (not si f0 OK)
  28102. + #
  28103. + #"
  28104. + [(set_attr "type" "fast,fast,two,two")])
  28105. +
  28106. +;; Split the above insn if it needs more than one insn
  28107. +(define_split
  28108. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  28109. + (not:SI (match_operand:SI 1 "metag_reg_nofloat_op" "")))]
  28110. + "reload_completed
  28111. + && REGNO (operands[0]) != REGNO (operands[1])"
  28112. + [(set (match_dup 0)
  28113. + (const_int -1))
  28114. + (set (match_dup 0)
  28115. + (xor:SI (match_dup 0)
  28116. + (match_dup 1)))]
  28117. + "")
  28118. +
  28119. +(define_insn "*nots_<mode>_si_rr"
  28120. + [(set (reg:<MODE> CC_REG)
  28121. + (compare:CCZNC
  28122. + (not:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0,0, e, f"))
  28123. + (const_int 0)))
  28124. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,&e,&f")
  28125. + (not:SI (match_dup 1)))]
  28126. + ""
  28127. + "@
  28128. + XORS\\t%0, %1, #-1\\t%@ (nots si e0 OK)
  28129. + XORS\\t%0, %1, #-1\\t%@ (nots si f0 OK)
  28130. + #
  28131. + #"
  28132. + [(set_attr "type" "fast,fast,two,two")
  28133. + (set_attr "ccstate" "set,set,fastset,fastset")])
  28134. +
  28135. +;; Split the above insn if it needs more than one insn
  28136. +(define_split
  28137. + [(set (reg:<MODE> CC_REG)
  28138. + (compare:CCZNC
  28139. + (not:SI (match_operand:SI 1 "metag_reg_nofloat_op" ""))
  28140. + (const_int 0)))
  28141. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  28142. + (not:SI (match_dup 1)))]
  28143. + "reload_completed
  28144. + && REGNO (operands[0]) != REGNO (operands[1])"
  28145. + [(set (match_dup 0)
  28146. + (const_int -1))
  28147. + (parallel
  28148. + [(set (reg:<MODE> CC_REG)
  28149. + (compare:<MODE>
  28150. + (xor:SI (match_dup 0)
  28151. + (match_dup 1))
  28152. + (const_int 0)))
  28153. + (set (match_dup 0)
  28154. + (xor:SI (match_dup 0)
  28155. + (match_dup 1)))])]
  28156. + "")
  28157. +
  28158. +(define_insn "*tnot_<mode>_si_rr"
  28159. + [(set (reg:<MODE> CC_REG)
  28160. + (compare:CCZNC
  28161. + (not:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0,0, e, f"))
  28162. + (const_int 0)))
  28163. + (clobber (match_scratch:SI 0 "=e,f,&e,&f"))]
  28164. + ""
  28165. + "@
  28166. + XORS\\t%0, %1, #-1\\t%@ (tnot si e0 OK)
  28167. + XORS\\t%0, %1, #-1\\t%@ (tnot si f0 OK)
  28168. + #
  28169. + #"
  28170. + [(set_attr "type" "fast,fast,two,two")
  28171. + (set_attr "ccstate" "set,set,fastset,fastset")])
  28172. +
  28173. +;; Split the above insn if it needs more than one insn.
  28174. +(define_split
  28175. + [(set (reg:<MODE> CC_REG)
  28176. + (compare:CCZNC
  28177. + (not:SI (match_operand:SI 1 "metag_reg_nofloat_op" ""))
  28178. + (const_int 0)))
  28179. + (clobber (match_scratch:SI 0 ""))]
  28180. + "reload_completed
  28181. + && REGNO (operands[0]) != REGNO (operands[1])"
  28182. + [(set (match_dup 0)
  28183. + (const_int -1))
  28184. + (parallel
  28185. + [(set (reg:<MODE> CC_REG)
  28186. + (compare:<MODE>
  28187. + (xor:SI (match_dup 0)
  28188. + (match_dup 1))
  28189. + (const_int 0)))
  28190. + (set (match_dup 0)
  28191. + (xor:SI (match_dup 0)
  28192. + (match_dup 1)))])]
  28193. + "")
  28194. +
  28195. +
  28196. +;; Comparison operations
  28197. +
  28198. +(define_expand "cmpsi"
  28199. + [(match_operand:SI 0 "metag_reg_nofloat_op" "")
  28200. + (match_operand:SI 1 "metag_regorint_op" "")]
  28201. + ""
  28202. + {
  28203. + /* These are processed via the conditional branch define_expand's later */
  28204. + metag_compare_op0 = operands[0];
  28205. + metag_compare_op1 = operands[1];
  28206. +
  28207. + if (CONST_INT_P (operands[1])
  28208. + && METAG_LETTER_FOR_CONST (operands[1]) == 0)
  28209. + {
  28210. + /* Have to do register to register comparison for big constants */
  28211. + metag_compare_op1 = force_reg (SImode, operands[1]);
  28212. + }
  28213. +
  28214. + DONE;
  28215. + }
  28216. +)
  28217. +
  28218. +;; compare si instruction
  28219. +(define_insn "*cmpsi_<mode>_rr"
  28220. + [(set (reg:<MODE> CC_REG)
  28221. + (compare:CCANY
  28222. + (match_operand:SI 0 "metag_reg_nofloat_op" "e,f")
  28223. + (match_operand:SI 1 "metag_reg_nofloat_op" "e,f")))]
  28224. + "!TARGET_METAC_1_1"
  28225. + "@
  28226. + CMP\\t%0, %1\\t\\t%@ (*cmpsi ee OK)
  28227. + CMP\\t%0, %1\\t\\t%@ (*cmpsi ff OK)"
  28228. + [(set_attr "type" "fast,fast")
  28229. + (set_attr "ccstate" "set,set")])
  28230. +
  28231. +(define_insn "*cmpsi_<mode>_ri"
  28232. + [(set (reg:<MODE> CC_REG)
  28233. + (compare:CCANY
  28234. + (match_operand:SI 0 "metag_reg_nofloat_op" "d,d, d,d,d")
  28235. + (match_operand:SI 1 "metag_int_operand" "K,IP,J,M,N")))]
  28236. + ""
  28237. + "@
  28238. + CMP\\t%0, %1\\t\\t%@ (*cmpsi dI OK)
  28239. + CMP\\t%0, %1\\t\\t%@ (*cmpsi dI OK)
  28240. + CMPT\\t%0, #HI(%c1)\\t\\t%@ (*cmpsi dJ OK)
  28241. + CMPMB\\t%0, #LO(%c1)\\t\\t%@ (*cmpsi dM OK)
  28242. + CMPMT\\t%0, #HI(%c1)\\t\\t%@ (*cmpsi dN OK)"
  28243. + [(set_attr "type" "fast,fast,fast,fast,fast")
  28244. + (set_attr "ccstate" "set,set,set,set,set")])
  28245. +
  28246. +;; compare si instruction - v1.1 case
  28247. +(define_insn "*cmpsi_rr_1_1"
  28248. + [(set (reg:<MODE> CC_REG)
  28249. + (compare:CCANY
  28250. + (match_operand:SI 0 "metag_reg_nofloat_op" "e, f")
  28251. + (match_operand:SI 1 "metag_reg_nofloat_op" "be,bf")))]
  28252. + "TARGET_METAC_1_1"
  28253. + "@
  28254. + CMP\\t%0, %1\\t\\t%@ (*cmpsi eb OK)
  28255. + CMP\\t%0, %1\\t\\t%@ (*cmpsi fb OK)"
  28256. + [(set_attr "type" "fast,fast")
  28257. + (set_attr "ccstate" "set,set")
  28258. + (set_attr "o2rhint" "op1op0")])
  28259. +
  28260. +;; compare hi instruction for zero flag
  28261. +(define_insn "*tst_zhi"
  28262. + [(set (reg:CC_Z CC_REG)
  28263. + (compare:CC_Z
  28264. + (match_operand:HI 0 "metag_datareg_op" "d")
  28265. + (const_int 0)))]
  28266. + ""
  28267. + "TST\\t%0, #0xFFFF\\t%@ (*tst zhi d OK)"
  28268. + [(set_attr "type" "fast")
  28269. + (set_attr "ccstate" "set")])
  28270. +
  28271. +;; compare qi instruction for zero flag
  28272. +(define_insn "*tst_zqi"
  28273. + [(set (reg:CC_Z CC_REG)
  28274. + (compare:CC_Z
  28275. + (match_operand:QI 0 "metag_datareg_op" "d")
  28276. + (const_int 0)))]
  28277. + ""
  28278. + "TST\\t%0, #255\\t%@ (*tst zqi d OK)"
  28279. + [(set_attr "type" "fast")
  28280. + (set_attr "ccstate" "set")])
  28281. +
  28282. +;; Copy and compare combines the flag setup with a move
  28283. +;; Note MOVS/ADDS for DU -> FX is allowed but FX -> DU is not
  28284. +(define_insn "*cmpsi_movsi_<mode>_eq0"
  28285. + [(set (reg:<MODE> CC_REG)
  28286. + (compare:CCZNC
  28287. + (match_operand:SI 1 "metag_datareg_op" "e,f,d")
  28288. + (const_int 0)))
  28289. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,da")
  28290. + (match_dup 1))]
  28291. + ""
  28292. + "ADDS\\t%0, %1, #0\\t\\t%@ (*movs si rr OK)"
  28293. + [(set_attr "type" "fast,fast,slow")
  28294. + (set_attr "ccstate" "set")])
  28295. +
  28296. +(define_insn "*cmpsi_movsi_cc_eq0"
  28297. + [(set (reg:CC CC_REG)
  28298. + (compare:CC
  28299. + (match_operand:SI 1 "metag_datareg_op" "e,f,d")
  28300. + (const_int 0)))
  28301. + (set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,da")
  28302. + (match_dup 1))]
  28303. + ""
  28304. + "SUBS\\t%0, %1, #0\\t\\t%@ (*movs si rr OK)"
  28305. + [(set_attr "type" "fast,fast,slow")
  28306. + (set_attr "ccstate" "set")])
  28307. +
  28308. +;; min instruction
  28309. +
  28310. +(define_insn "sminsi3"
  28311. + [(set (match_operand:SI 0 "metag_datareg_op" "=e,f")
  28312. + (smin:SI (match_operand:SI 1 "metag_datareg_op" "%e,f")
  28313. + (match_operand:SI 2 "metag_datareg_op" "e,f")))
  28314. + (clobber (reg:CC CC_REG))]
  28315. + "!TARGET_METAC_0_1"
  28316. + "MIN\\t%0, %1, %2\\t%@ (*min si ddd OK)"
  28317. + [(set_attr "type" "fast")
  28318. + (set_attr "ccstate" "ccx")])
  28319. +
  28320. +;; max instruction
  28321. +
  28322. +(define_insn "smaxsi3"
  28323. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f")
  28324. + (smax:SI (match_operand:SI 1 "metag_reg_nofloat_op" "%e,f")
  28325. + (match_operand:SI 2 "metag_reg_nofloat_op" "e,f")))
  28326. + (clobber (reg:CC CC_REG))]
  28327. + "!TARGET_METAC_0_1"
  28328. + "MAX\\t%0, %1, %2\\t%@ (*max si ddd OK)"
  28329. + [(set_attr "type" "fast")
  28330. + (set_attr "ccstate" "ccx")])
  28331. +
  28332. +;; abs instruction
  28333. +
  28334. +(define_insn "abssi2"
  28335. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f")
  28336. + (abs:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,f")))
  28337. + (clobber (reg:CC CC_REG))]
  28338. + "!TARGET_METAC_0_1"
  28339. + "ABS\\t%0, %1\\t%@ (*abs si dd OK)"
  28340. + [(set_attr "type" "fast")
  28341. + (set_attr "ccstate" "ccx")])
  28342. +
  28343. +;; Conditional move support
  28344. +(define_expand "movsicc"
  28345. + [(set (match_operand:SI 0 "metag_register_op" "")
  28346. + (if_then_else:SI (match_operand 1 "comparison_operator" "")
  28347. + (match_operand:SI 2 "metag_regorint_op" "")
  28348. + (match_operand:SI 3 "metag_regorint_op" "")))]
  28349. + ""
  28350. + {
  28351. + enum rtx_code code = GET_CODE (operands[1]);
  28352. + enum machine_mode mode;
  28353. + rtx ccreg;
  28354. +
  28355. + if (CONST_INT_P (operands[2]) && CONST_INT_P (operands[3]))
  28356. + {
  28357. + /* Can only support -255 to 255 delta between constants */
  28358. + HOST_WIDE_INT op2_mi_op3 = INTVAL (operands[2]) - INTVAL (operands[3]);
  28359. + rtx value = GEN_INT (op2_mi_op3);
  28360. +
  28361. + if (satisfies_constraint_P (value)
  28362. + || satisfies_constraint_K (value))
  28363. + {
  28364. + rtx temp = (reload_in_progress || reload_completed)
  28365. + ? operands[0] : gen_reg_rtx (SImode);
  28366. +
  28367. + emit_move_insn (temp, operands[3]);
  28368. + operands[2] = gen_rtx_PLUS (SImode, temp, value);
  28369. + operands[3] = temp;
  28370. + }
  28371. + }
  28372. +
  28373. + if (CONST_INT_P (operands[3]))
  28374. + {
  28375. + /* Make second source operand a register */
  28376. + operands[3] = force_reg (SImode, operands[3]);
  28377. + }
  28378. +
  28379. + if (CONST_INT_P (operands[2]))
  28380. + {
  28381. + /* Make first source operand a register! */
  28382. + operands[2] = force_reg (SImode, operands[2]);
  28383. + }
  28384. +
  28385. + /* Generate correct comparison insn */
  28386. + mode = SELECT_CC_MODE (code, metag_compare_op0, metag_compare_op1);
  28387. + ccreg = gen_rtx_REG (mode, CC_REG);
  28388. + emit_insn (gen_rtx_SET (VOIDmode, ccreg,
  28389. + gen_rtx_COMPARE (mode, metag_compare_op0, metag_compare_op1)));
  28390. +
  28391. + /* Expand condition to act on result */
  28392. + operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
  28393. + }
  28394. +)
  28395. +
  28396. +(define_insn "*mov_if_<mode>_rr0"
  28397. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,h,l,da")
  28398. + (if_then_else:SI (match_operator 1 "comparison_operator"
  28399. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  28400. + (const_int 0)])
  28401. + (match_operand:SI 3 "metag_reg_nofloat_op" "e,f,h,l,da")
  28402. + (match_operand:SI 4 "metag_reg_nofloat_op" "0,0,0,0,0")))]
  28403. + ""
  28404. + "MOV%z1\\t%0, %3\\t%@ (*mov if <mode> rr0 OK)"
  28405. + [(set_attr "type" "fast,fast,fast,fast,slow")
  28406. + (set_attr "ccstate" "xcc,xcc,xcc,xcc,xcc")])
  28407. +
  28408. +;; Conditional add is targeted by expansion of if_then_else(const, const)
  28409. +(define_insn "*add_if_<mode>_r0KP"
  28410. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=e,f,h,l,e,f,h,l")
  28411. + (if_then_else:SI (match_operator 1 "comparison_operator"
  28412. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  28413. + (const_int 0)])
  28414. + (plus:SI (match_operand:SI 3 "metag_regnofrm_op" "e,f,h,l,e,f,h,l")
  28415. + (match_operand:SI 4 "metag_smallint_op" "K,K,K,K,P,P,P,P"))
  28416. + (match_operand:SI 5 "metag_reg_nofloat_op" "0,0,0,0,0,0,0,0")))]
  28417. + ""
  28418. + "@
  28419. + ADD%z1\\t%0, %3, %4\\t\\t%@ (*add if eeK OK)
  28420. + ADD%z1\\t%0, %3, %4\\t\\t%@ (*add if ffK OK)
  28421. + ADD%z1\\t%0, %3, %4\\t\\t%@ (*add if hhK OK)
  28422. + ADD%z1\\t%0, %3, %4\\t\\t%@ (*add if llK OK)
  28423. + SUB%z1\\t%0, %3, #%n4\\t\\t%@ (*sub if eeP OK)
  28424. + SUB%z1\\t%0, %3, #%n4\\t\\t%@ (*sub if ffP OK)
  28425. + SUB%z1\\t%0, %3, #%n4\\t\\t%@ (*sub if hhP OK)
  28426. + SUB%z1\\t%0, %3, #%n4\\t\\t%@ (*sub if llP OK)"
  28427. + [(set_attr "type" "fast,fast,fast,fast,fast,fast,fast,fast")
  28428. + (set_attr "ccstate" "xcc,xcc,xcc,xcc,xcc,xcc,xcc,xcc")])
  28429. +
  28430. +
  28431. +;; zero/sign extend instructions
  28432. +
  28433. +(define_insn_and_split "zero_extendsidi2"
  28434. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "=da")
  28435. + (zero_extend:DI
  28436. + (match_operand:SI 1 "metag_reg_nofloat_op" "da")))]
  28437. + ""
  28438. + "#"
  28439. + "SPLIT_EARLY"
  28440. + [(set (match_dup 2)
  28441. + (match_dup 1))
  28442. + (set (match_dup 3)
  28443. + (const_int 0))]
  28444. + {
  28445. + if (reload_completed)
  28446. + {
  28447. + operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));
  28448. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  28449. + }
  28450. + else
  28451. + {
  28452. + operands[2] = gen_rtx_SUBREG (SImode, operands[0], 0);
  28453. + operands[3] = gen_rtx_SUBREG (SImode, operands[0], UNITS_PER_WORD);
  28454. + }
  28455. + }
  28456. + [(set_attr "type" "two")]
  28457. +)
  28458. +
  28459. +(define_expand "zero_extendhisi2"
  28460. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  28461. + (zero_extend:SI
  28462. + (match_operand:HI 1 "metag_datareg_op" "")))]
  28463. + ""
  28464. + {
  28465. + }
  28466. +)
  28467. +
  28468. +(define_insn_and_split "*zero_extendhisi2"
  28469. + [(set (match_operand:SI 0 "metag_datareg_op" "=d")
  28470. + (zero_extend:SI
  28471. + (match_operand:HI 1 "metag_datareg_op" "0")))]
  28472. + ""
  28473. + "#"
  28474. + "SPLIT_EARLY"
  28475. + [(set (match_dup 0)
  28476. + (and:SI (match_dup 1)
  28477. + (match_dup 2)))]
  28478. + {
  28479. + operands[1] = gen_lowpart (SImode, operands[1]);
  28480. + operands[2] = gen_int_mode (0xFFFF, SImode);
  28481. + })
  28482. +
  28483. +(define_expand "zero_extendqisi2"
  28484. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  28485. + (zero_extend:SI
  28486. + (match_operand:QI 1 "metag_datareg_op" "")))]
  28487. + ""
  28488. + {
  28489. + }
  28490. +)
  28491. +
  28492. +(define_insn_and_split "*zero_extendqisi2"
  28493. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  28494. + (zero_extend:SI
  28495. + (match_operand:QI 1 "metag_datareg_op" "d")))]
  28496. + ""
  28497. + "#"
  28498. + "SPLIT_EARLY"
  28499. + [(set (match_dup 0)
  28500. + (and:SI (match_dup 1)
  28501. + (match_dup 2)))]
  28502. + {
  28503. + operands[1] = gen_lowpart (SImode, operands[1]);
  28504. + operands[2] = gen_int_mode (0xFF, SImode);
  28505. + })
  28506. +
  28507. +(define_insn_and_split "extendsidi2"
  28508. + [(set (match_operand:DI 0 "metag_reg_nofloat_op" "=d,d,a")
  28509. + (sign_extend:DI
  28510. + (match_operand:SI 1 "metag_datareg_op" "f,e,d")))]
  28511. + ""
  28512. + "#"
  28513. + "SPLIT_EARLY"
  28514. + [(set (match_dup 2)
  28515. + (match_dup 1))
  28516. + (set (match_dup 3)
  28517. + (ashiftrt:SI (match_dup 1)
  28518. + (const_int 31)))]
  28519. + {
  28520. + if (reload_completed)
  28521. + {
  28522. + operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));
  28523. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  28524. + }
  28525. + else
  28526. + {
  28527. + operands[2] = gen_rtx_SUBREG (SImode, operands[0], 0);
  28528. + operands[3] = gen_rtx_SUBREG (SImode, operands[0], UNITS_PER_WORD);
  28529. + }
  28530. + }
  28531. + [(set_attr "type" "two,slowslow,slowslow")]
  28532. +)
  28533. +
  28534. +(define_expand "extendhisi2"
  28535. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  28536. + (sign_extend:SI
  28537. + (match_operand:HI 1 "metag_datareg_op" "")))]
  28538. + ""
  28539. + {
  28540. + }
  28541. +)
  28542. +
  28543. +(define_expand "extendqisi2"
  28544. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  28545. + (sign_extend:SI
  28546. + (match_operand:QI 1 "metag_datareg_op" "")))]
  28547. + ""
  28548. + {
  28549. + }
  28550. +)
  28551. +
  28552. +;; -----------------------------------------------------------------------------
  28553. +;; | Matching zero extends loads to HI post/pre_inc/dec/modify
  28554. +;; -----------------------------------------------------------------------------
  28555. +
  28556. +(define_insn "*lodz_<mode>hi_post_inc"
  28557. + [(set (match_operand:HI 0 "metag_register_op" "=cr")
  28558. + (zero_extend:HI
  28559. + (mem:EXTHI
  28560. + (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28561. + "TARGET_METAC_1_1"
  28562. + {
  28563. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1++]\\t%@ (*lodz <MODE> HI post_inc OK)";
  28564. +
  28565. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28566. + }
  28567. + [(set_attr "type" "load")])
  28568. +
  28569. +(define_insn "*lodz_<mode>hi_post_dec"
  28570. + [(set (match_operand:HI 0 "metag_register_op" "=cr")
  28571. + (zero_extend:HI
  28572. + (mem:EXTHI
  28573. + (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28574. + "TARGET_METAC_1_1"
  28575. + {
  28576. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1--]\\t%@ (*lodz <MODE> HI post_dec OK)";
  28577. +
  28578. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28579. + }
  28580. + [(set_attr "type" "load")])
  28581. +
  28582. +(define_insn "*lodz_<mode>hi_pre_inc"
  28583. + [(set (match_operand:HI 0 "metag_register_op" "=cr")
  28584. + (zero_extend:HI
  28585. + (mem:EXTHI
  28586. + (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28587. + "TARGET_METAC_1_1"
  28588. + {
  28589. + static const char fmt[] = "F\\tGET<W>\\t%0, [++%1]\\t%@ (*lodz <MODE> HI pre_inc OK)";
  28590. +
  28591. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28592. + }
  28593. + [(set_attr "type" "load")])
  28594. +
  28595. +(define_insn "*lodz_<mode>hi_pre_dec"
  28596. + [(set (match_operand:HI 0 "metag_register_op" "=cr")
  28597. + (zero_extend:HI
  28598. + (mem:EXTHI
  28599. + (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28600. + "TARGET_METAC_1_1"
  28601. + {
  28602. + static const char fmt[] = "F\\tGET<W>\\t%0, [--%1]\\t%@ (*lodz <MODE> HI pre_dec OK)";
  28603. +
  28604. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28605. + }
  28606. + [(set_attr "type" "load")])
  28607. +
  28608. +(define_insn "*lodz_<mode>hi_post_modify_disp"
  28609. + [(set (match_operand:HI 0 "metag_register_op" "=cr")
  28610. + (zero_extend:HI
  28611. + (mem:EXTHI
  28612. + (post_modify:SI
  28613. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  28614. + (plus:SI (match_dup 1)
  28615. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>"))))))]
  28616. + ""
  28617. + {
  28618. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1+%2++]\\t%@ (*load <MODE> HI post_modify_disp OK)";
  28619. +
  28620. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28621. + }
  28622. + [(set_attr "type" "load")])
  28623. +
  28624. +(define_insn "*lodz_<mode>hi_post_modify_reg"
  28625. + [(set (match_operand:HI 0 "metag_register_op" "=cr,cr,cr,cr")
  28626. + (zero_extend:HI
  28627. + (mem:EXTHI
  28628. + (post_modify:SI
  28629. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  28630. + (plus:SI (match_dup 1)
  28631. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l"))))))]
  28632. + ""
  28633. + {
  28634. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1+%2++]\\t%@ (*lodz <MODE> HI post_modify_reg OK)";
  28635. +
  28636. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28637. + }
  28638. + [(set_attr "type" "load")])
  28639. +
  28640. +(define_insn "*lodz_<mode>hi_pre_modify_disp"
  28641. + [(set (match_operand:HI 0 "metag_reg_nofloat_op" "=da")
  28642. + (zero_extend:HI
  28643. + (mem:EXTHI
  28644. + (pre_modify:SI
  28645. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  28646. + (plus:SI (match_dup 1)
  28647. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>"))))))]
  28648. + ""
  28649. + "GET<W>\\t%0, [%1++%2]\\t%@ (*lodz <MODE> HI pre_modify_disp OK)"
  28650. + [(set_attr "type" "load")])
  28651. +
  28652. +(define_insn "*lodz_<mode>hi_pre_modify_reg"
  28653. + [(set (match_operand:HI 0 "metag_register_op" "=cr,cr,cr,cr")
  28654. + (zero_extend:HI
  28655. + (mem:EXTHI
  28656. + (pre_modify:SI
  28657. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  28658. + (plus:SI (match_dup 1)
  28659. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l"))))))]
  28660. + ""
  28661. + {
  28662. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1++%2]\\t%@ (*lodz <MODE> HI pre_modify_reg OK)";
  28663. +
  28664. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28665. + }
  28666. + [(set_attr "type" "load")])
  28667. +
  28668. +;; -----------------------------------------------------------------------------
  28669. +
  28670. +;; zero_extend loads to SI from EXTSI mode using base+index
  28671. +(define_insn "*lodz_<mode>si_rma"
  28672. + [(set (match_operand:SI 0 "metag_register_op" "=cr,cr,cr,cr")
  28673. + (zero_extend:SI
  28674. + (mem:EXTSI
  28675. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "e, f, h, l")
  28676. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l")))))]
  28677. + ""
  28678. + {
  28679. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1+%2]\\t%@ (*lodz <MODE> SI rma OK)";
  28680. +
  28681. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28682. + }
  28683. + [(set_attr "type" "load")])
  28684. +
  28685. +;; zero_extend loads to SI from EXTSI mode using base+offset6
  28686. +(define_insn "*lodz_<mode>si_rmi"
  28687. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  28688. + (zero_extend:SI
  28689. + (mem:EXTSI
  28690. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "da")
  28691. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>")))))]
  28692. + ""
  28693. + {
  28694. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1+%2]\\t%@ (*lodz <MODE> SI rmi OK)";
  28695. +
  28696. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28697. + }
  28698. + [(set_attr "type" "load")])
  28699. +
  28700. +;; zero_extend loads to SI from EXTSI mode using base+offset12
  28701. +(define_insn "*lodz_<mode>si_rmi"
  28702. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da, da")
  28703. + (zero_extend:SI
  28704. + (mem:EXTSI
  28705. + (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "da, Yr")
  28706. + (match_operand:SI 2 "metag_offset12_<mode>" "<O>,<Z>")))))]
  28707. + ""
  28708. + "GET<W>\\t%0, [%1+%2]\\t%@ (*lodz <MODE> SI rmi OK)"
  28709. + [(set_attr "type" "load")])
  28710. +
  28711. +;; zero_extend loads to SI from EXTSI mode using base++index
  28712. +(define_insn "*lodz_<mode>si_rmab"
  28713. + [(set (match_operand:SI 3 "metag_register_op" "=cr,cr,cr,cr")
  28714. + (zero_extend:SI
  28715. + (mem:EXTSI
  28716. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "%0, 0, 0, 0")
  28717. + (match_operand:SI 2 "metag_regnofrm_op" "e, f, h, l")))))
  28718. + (set (match_operand:SI 0 "metag_regnofrm_op" "=e, f, h, l")
  28719. + (plus:SI (match_dup 1)
  28720. + (match_dup 2)))]
  28721. + "0"
  28722. + {
  28723. + static const char fmt[] = "F\\tGET<W>\\t%3, [%1++%2]\\t%@ (*lodz <MODE> SI rmab OK)";
  28724. +
  28725. + return &fmt[METAG_FPC_REG_P (REGNO (operands[3])) ? 0 : 2];
  28726. + }
  28727. + [(set_attr "type" "load")])
  28728. +
  28729. +;; zero_extend loads to SI from EXTSI mode using base++increment
  28730. +(define_insn "*lodz_<mode>si_rmib"
  28731. + [(set (match_operand:SI 3 "metag_register_op" "=cr")
  28732. + (zero_extend:SI
  28733. + (mem:EXTSI
  28734. + (plus:SI (match_operand:SI 1 "metag_regnofrm_op" "0")
  28735. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>")))))
  28736. + (set (match_operand:SI 0 "metag_regnofrm_op" "=da")
  28737. + (plus:SI (match_dup 1)
  28738. + (match_dup 2)))]
  28739. + "0"
  28740. + {
  28741. + static const char fmt[] = "F\\tGET<W>\\t%3, [%1++%2]\\t%@ (*lodz <MODE> SI rmib OK)";
  28742. +
  28743. + return &fmt[METAG_FPC_REG_P (REGNO (operands[3])) ? 0 : 2];
  28744. + }
  28745. + [(set_attr "type" "load")])
  28746. +
  28747. +;; -----------------------------------------------------------------------------
  28748. +
  28749. +;; -----------------------------------------------------------------------------
  28750. +;; | Matching zero extend loads to SI post/pre_inc/dec/modify |
  28751. +;; -----------------------------------------------------------------------------
  28752. +
  28753. +(define_insn "*lodz_<mode>si_post_inc"
  28754. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  28755. + (zero_extend:SI (mem:EXTSI
  28756. + (post_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28757. + "TARGET_METAC_1_1"
  28758. + {
  28759. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1++]\\t%@ (*lodz <MODE> SI post_inc OK)";
  28760. +
  28761. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28762. + }
  28763. + [(set_attr "type" "load")])
  28764. +
  28765. +(define_insn "*lodz_<mode>si_post_dec"
  28766. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  28767. + (zero_extend:SI (mem:EXTSI
  28768. + (post_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28769. + "TARGET_METAC_1_1"
  28770. + {
  28771. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1--]\\t%@ (*lodz <MODE> SI post_dec OK)";
  28772. +
  28773. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28774. + }
  28775. + [(set_attr "type" "load")])
  28776. +
  28777. +(define_insn "*lodz_<mode>si_pre_inc"
  28778. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  28779. + (zero_extend:SI (mem:EXTSI
  28780. + (pre_inc:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28781. + "TARGET_METAC_1_1"
  28782. + {
  28783. + static const char fmt[] = "F\\tGET<W>\\t%0, [++%1]\\t%@ (*lodz <MODE> SI pre_inc OK)";
  28784. +
  28785. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28786. + }
  28787. + [(set_attr "type" "load")])
  28788. +
  28789. +(define_insn "*lodz_<mode>si_pre_dec"
  28790. + [(set (match_operand:SI 0 "metag_register_op" "=cr")
  28791. + (zero_extend:SI (mem:EXTSI
  28792. + (pre_dec:SI (match_operand:SI 1 "metag_reg_nofloat_op" "+da")))))]
  28793. + "TARGET_METAC_1_1"
  28794. + {
  28795. + static const char fmt[] = "F\\tGET<W>\\t%0, [--%1]\\t%@ (*lodz <MODE> SI pre_dec OK)";
  28796. +
  28797. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28798. + }
  28799. + [(set_attr "type" "load")])
  28800. +
  28801. +(define_insn "*lodz_<mode>si_post_modify_disp"
  28802. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  28803. + (zero_extend:SI (mem:EXTSI
  28804. + (post_modify:SI
  28805. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  28806. + (plus:SI (match_dup 1)
  28807. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>"))))))]
  28808. + ""
  28809. + "GET<W>\\t%0, [%1+%2++]\\t%@ (*lodz <MODE> SI post_modify_disp OK)"
  28810. + [(set_attr "type" "load")])
  28811. +
  28812. +(define_insn "*lodz_<mode>si_post_modify_reg"
  28813. + [(set (match_operand:SI 0 "metag_register_op" "=cr,cr,cr,cr")
  28814. + (zero_extend:SI (mem:EXTSI
  28815. + (post_modify:SI
  28816. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  28817. + (plus:SI (match_dup 1)
  28818. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l"))))))]
  28819. + ""
  28820. + {
  28821. + static const char fmt[] = "F\\tGET<W>\\t%0, [%1+%2++]\\t%@ (*lodz <MODE> SI post_modify_reg OK)";
  28822. +
  28823. + return &fmt[METAG_FPC_REG_P (REGNO (operands[0])) ? 0 : 2];
  28824. + }
  28825. + [(set_attr "type" "load")])
  28826. +
  28827. +(define_insn "*lodz_<mode>si_pre_modify_disp"
  28828. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  28829. + (zero_extend:SI (mem:EXTSI
  28830. + (pre_modify:SI
  28831. + (match_operand:SI 1 "metag_reg_nofloat_op" "+da")
  28832. + (plus:SI (match_dup 1)
  28833. + (match_operand:SI 2 "metag_offset6_<mode>" "<O>"))))))]
  28834. + ""
  28835. + "GET<W>\\t%0, [%1++%2]\\t%@ (*load <MODE> SI pre_modify_disp OK)"
  28836. + [(set_attr "type" "load")])
  28837. +
  28838. +(define_insn "*lodz_<mode>si_pre_modify_reg"
  28839. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da,da,da,da")
  28840. + (zero_extend:SI (mem:EXTSI
  28841. + (pre_modify:SI
  28842. + (match_operand:SI 1 "metag_reg_nofloat_op" "+e, f, h, l")
  28843. + (plus:SI (match_dup 1)
  28844. + (match_operand:SI 2 "metag_reg_nofloat_op" "e, f, h, l"))))))]
  28845. + ""
  28846. + "GET<W>\\t%0, [%1++%2]\\t%@ (*loadz <MODE> SI pre_modify_reg OK)"
  28847. + [(set_attr "type" "load")])
  28848. +
  28849. +;; zero_extend loads to SI from EXTSI mode - rest expanded as AND operations
  28850. +(define_insn "*lodz_<mode>si"
  28851. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  28852. + (zero_extend:SI (match_operand:EXTSI 1 "memory_operand" "m")))]
  28853. + ""
  28854. + "GET<W>\\t%0, %1\\t%@ (*lodz <MODE> SI rm OK)"
  28855. + [(set_attr "type" "load")])
  28856. +
  28857. +;; -----------------------------------------------------------------------------
  28858. +
  28859. +;; Sign extend register to SI mode register moves
  28860. +(define_insn "*sign_extend_<mode>si"
  28861. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=d,e,f")
  28862. + (sign_extend:SI (match_operand:EXTSI 1 "metag_reg_nofloat_op" "0,e,f")))]
  28863. + ""
  28864. + "@
  28865. + XSD<W>\\t%0, %1\\t\\t%@ (*ext <MODE> SI d0 OK)
  28866. + XSD<W>\\t%0, %1\\t\\t%@ (*ext <MODE> SI ee OK)
  28867. + XSD<W>\\t%0, %1\\t\\t%@ (*ext <MODE> SI ff OK)"
  28868. + [(set_attr "type" "fast,fast,fast")])
  28869. +
  28870. +(define_insn "*sign_extend_hisi_<mode>"
  28871. + [(set (reg:<MODE> CC_REG)
  28872. + (compare:CCZNC
  28873. + (sign_extend:SI (match_operand:HI 1 "metag_datareg_op" "0,e,f"))
  28874. + (const_int 0)))
  28875. + (set (match_operand:SI 0 "metag_datareg_op" "=d,e,f")
  28876. + (sign_extend:SI (match_dup 1)))]
  28877. + ""
  28878. + "XSDSW\\t%0, %1\\t\\t%@ (*exts HI SI dd OK)"
  28879. + [(set_attr "type" "fast")
  28880. + (set_attr "ccstate" "set")])
  28881. +
  28882. +(define_insn "*sign_extend_qisi_<mode>"
  28883. + [(set (reg:<MODE> CC_REG)
  28884. + (compare:CCZNC
  28885. + (sign_extend:SI (match_operand:QI 1 "metag_datareg_op" "0,e,f"))
  28886. + (const_int 0)))
  28887. + (set (match_operand:SI 0 "metag_datareg_op" "=d,e,f")
  28888. + (sign_extend:SI (match_dup 1)))]
  28889. + ""
  28890. + "XSDSB\\t%0, %1\\t\\t%@ (*exts QI SI dd OK)"
  28891. + [(set_attr "type" "fast")
  28892. + (set_attr "ccstate" "set")])
  28893. +
  28894. +;; bit field instructions
  28895. +
  28896. +
  28897. +;; Low overhead loop support
  28898. +;; operand 0 is the loop count pseudo register
  28899. +;; operand 1 is the number of loop iterations or 0 if it is unknown
  28900. +;; operand 2 is the maximum number of loop iterations or -1 if unknown
  28901. +;; operand 3 is the number of levels of enclosed loops
  28902. +;; operand 4 is the label to jump to at the top of the loop
  28903. +(define_expand "doloop_end"
  28904. + [(use (match_operand 0 "" ""))
  28905. + (use (match_operand:SI 1 "const_int_operand" ""))
  28906. + (use (match_operand:SI 2 "const_int_operand" ""))
  28907. + (use (match_operand:SI 3 "const_int_operand" ""))
  28908. + (use (label_ref (match_operand 4 "" "")))]
  28909. + ""
  28910. + {
  28911. + enum machine_mode mode = GET_MODE (operands[0]);
  28912. +
  28913. + if (mode == SImode && INTVAL (operands[3]) != -1)
  28914. + {
  28915. + unsigned HOST_WIDE_INT mask = GET_MODE_MASK (mode);
  28916. + unsigned HOST_WIDE_INT num_iterations = INTVAL (operands[1]) & mask;
  28917. + unsigned HOST_WIDE_INT max_iterations = INTVAL (operands[2]) & mask;
  28918. + unsigned HOST_WIDE_INT limit = INTVAL (gen_int_mode (0xFFFFFFFF, SImode)) & mask;
  28919. +
  28920. + if (!(num_iterations > limit || (num_iterations == 0 && max_iterations > limit)))
  28921. + {
  28922. + emit_jump_insn (gen_br_si_txrpt (operands[4], operands[0]));
  28923. + DONE;
  28924. + }
  28925. + }
  28926. +
  28927. + FAIL;
  28928. + }
  28929. +)
  28930. +
  28931. +(define_insn "br_si_txrpt"
  28932. + [(set (pc)
  28933. + (if_then_else (ne (match_operand:SI 1 "metag_txrpt_op" "+Wx")
  28934. + (const_int 0))
  28935. + (label_ref (match_operand 0 "" ""))
  28936. + (pc)))
  28937. + (set (match_dup 1)
  28938. + (plus:SI (match_dup 1)
  28939. + (const_int -1)))
  28940. + (clobber (reg:CC_NOOV CC_REG))]
  28941. + ""
  28942. + "BR\\t%c0"
  28943. + [(set_attr "type" "branch")
  28944. + (set_attr "ccstate" "ccx")])
  28945. +
  28946. +
  28947. +;; conditional branch instruction generators; expand previous compare
  28948. +
  28949. +(define_expand "b<code>"
  28950. + [(set (pc)
  28951. + (if_then_else (CCANYCOND (match_dup 1)
  28952. + (const_int 0))
  28953. + (label_ref (match_operand 0 "" ""))
  28954. + (pc)))]
  28955. + ""
  28956. + {
  28957. + if (!gen_metag_compare (<CODE>, operands, 1))
  28958. + FAIL;
  28959. + }
  28960. +)
  28961. +
  28962. +;; patterns to match conditional branch insns
  28963. +
  28964. +(define_insn "*b<mode>"
  28965. + [(set (pc)
  28966. + (if_then_else (match_operator 1 "comparison_operator"
  28967. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  28968. + (const_int 0)])
  28969. + (label_ref (match_operand 0 "" ""))
  28970. + (pc)))]
  28971. + ""
  28972. + {
  28973. + if (metag_consume_branch (insn))
  28974. + return "";
  28975. +
  28976. + return "B%z1\\t%c0\\t\\t\\t%@ (*b<mode> OK)";
  28977. + }
  28978. + [(set_attr "type" "branch")
  28979. + (set_attr "ccstate" "xcc")])
  28980. +
  28981. +(define_insn "*b<mode>_reversed"
  28982. + [(set (pc)
  28983. + (if_then_else (match_operator 1 "comparison_operator"
  28984. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  28985. + (const_int 0)])
  28986. + (pc)
  28987. + (label_ref (match_operand 0 "" ""))))]
  28988. + ""
  28989. + {
  28990. + if (metag_consume_branch (insn))
  28991. + return "";
  28992. +
  28993. + return "B%Z1\\t%c0\\t\\t\\t%@ (*b<mode> rev OK)";
  28994. + }
  28995. + [(set_attr "type" "branch")
  28996. + (set_attr "ccstate" "xcc")])
  28997. +
  28998. +;; condition status evaluation
  28999. +(define_expand "s<code>"
  29000. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  29001. + (CCANYCOND:SI (match_dup 1)
  29002. + (const_int 0)))]
  29003. + ""
  29004. + {
  29005. + if (!gen_metag_compare (<CODE>, operands, 1))
  29006. + FAIL;
  29007. + }
  29008. +)
  29009. +
  29010. +;; patterns to match condition status insns
  29011. +(define_insn_and_split "*movsi_m<mode>"
  29012. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  29013. + (match_operator:SI 1 "comparison_operator"
  29014. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  29015. + (const_int 0)]))]
  29016. + ""
  29017. + "#"
  29018. + "reload_completed"
  29019. + [(set (match_dup 0)
  29020. + (const_int 0))
  29021. + (set (match_dup 0)
  29022. + (if_then_else:SI (match_op_dup 1 [(match_dup 2)
  29023. + (const_int 0)])
  29024. + (plus:SI (match_dup 0)
  29025. + (const_int 1))
  29026. + (match_dup 0)))]
  29027. + ""
  29028. + [(set_attr "type" "two")
  29029. + (set_attr "ccstate" "xcc")])
  29030. +
  29031. +(define_insn_and_split "*movsi_negm<mode>"
  29032. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  29033. + (neg:SI (match_operator:SI 1 "comparison_operator"
  29034. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  29035. + (const_int 0)])))]
  29036. + ""
  29037. + "#"
  29038. + "reload_completed"
  29039. + [(set (match_dup 0)
  29040. + (const_int 0))
  29041. + (set (match_dup 0)
  29042. + (if_then_else:SI (match_op_dup 1 [(match_dup 2)
  29043. + (const_int 0)])
  29044. + (plus:SI (match_dup 0)
  29045. + (const_int -1))
  29046. + (match_dup 0)))]
  29047. + ""
  29048. + [(set_attr "type" "two")
  29049. + (set_attr "ccstate" "xcc")])
  29050. +
  29051. +(define_insn_and_split "*movsi_notm<mode>"
  29052. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  29053. + (not:SI (match_operator:SI 1 "comparison_operator"
  29054. + [(match_operand:CCALL 2 "metag_<mode>_reg" "")
  29055. + (const_int 0)])))]
  29056. + ""
  29057. + "#"
  29058. + "reload_completed"
  29059. + [(set (match_dup 0)
  29060. + (const_int 0))
  29061. + (set (match_dup 0)
  29062. + (if_then_else:SI (match_op_dup 1 [(match_dup 2)
  29063. + (const_int 0)])
  29064. + (plus:SI (match_dup 0)
  29065. + (const_int -2))
  29066. + (match_dup 0)))]
  29067. + ""
  29068. + [(set_attr "type" "two")
  29069. + (set_attr "ccstate" "xcc")])
  29070. +
  29071. +;; call instructions - can handle call to symbol hence special predicate
  29072. +(define_expand "sibcall"
  29073. + [(parallel [(call (match_operand:QI 0 "metag_call_addr" "")
  29074. + (match_operand 1 "" ""))
  29075. + (unspec [(const_int 0)] UNSPEC_SIBCALL)])]
  29076. + ""
  29077. + {
  29078. + if (GET_CODE (operands[0]) != MEM)
  29079. + {
  29080. + rtx tmp = gen_rtx_REG (SImode, D0Re0_REG);
  29081. +
  29082. + emit_move_insn (tmp, operands[0]);
  29083. + operands[0] = tmp;
  29084. + }
  29085. + }
  29086. +)
  29087. +
  29088. +(define_expand "call"
  29089. + [(call (match_operand:QI 0 "metag_call_addr" "")
  29090. + (match_operand 1 "" ""))]
  29091. + ""
  29092. + "")
  29093. +
  29094. +(define_expand "call_value"
  29095. + [(set (match_operand 0 "metag_reg_nofloat_op" "")
  29096. + (call (match_operand:QI 1 "metag_call_addr" "")
  29097. + (match_operand 2 "" "")))]
  29098. + ""
  29099. + "")
  29100. +
  29101. +(define_expand "sibcall_value"
  29102. + [(parallel [(set (match_operand 0 "metag_reg_nofloat_op" "")
  29103. + (call (match_operand:QI 1 "metag_call_addr" "")
  29104. + (match_operand 2 "" "")))
  29105. + (unspec [(const_int 0)] UNSPEC_SIBCALL_VALUE)])]
  29106. + ""
  29107. + {
  29108. + if (GET_CODE (operands[1]) != MEM)
  29109. + {
  29110. + rtx tmp = gen_rtx_REG (SImode, D1Re0_REG);
  29111. +
  29112. + emit_move_insn (tmp, operands[1]);
  29113. + operands[1] = tmp;
  29114. + }
  29115. + }
  29116. +)
  29117. +
  29118. +(define_insn "*sibcall_reg"
  29119. + [(call (mem:QI (match_operand:SI 0 "metag_addrreg_op" "a"))
  29120. + (match_operand:SI 1 "immediate_operand" ""))
  29121. + (unspec [(const_int 0)] UNSPEC_SIBCALL)]
  29122. + ""
  29123. + "MOV\\tPC, %0"
  29124. + [(set_attr "type" "unknown")])
  29125. +
  29126. +(define_insn "*call_reg"
  29127. + [(call (mem:QI (match_operand:SI 0 "metag_reg_nofloat_op" "da"))
  29128. + (match_operand:SI 1 "immediate_operand" ""))]
  29129. + ""
  29130. + "*
  29131. + return output_call (operands, 0);"
  29132. + [(set_attr "type" "unknown")
  29133. + (set_attr "length" "8")])
  29134. +
  29135. +(define_insn "*sibcall_value_reg"
  29136. + [(set (match_operand 0 "metag_reg_nofloat_op" "=da")
  29137. + (call (mem:QI (match_operand:SI 1 "metag_addrreg_op" "a"))
  29138. + (match_operand:SI 2 "immediate_operand" "")))
  29139. + (unspec [(const_int 0)] UNSPEC_SIBCALL_VALUE)]
  29140. + ""
  29141. + "MOV\\tPC, %1"
  29142. + [(set_attr "type" "unknown")])
  29143. +
  29144. +(define_insn "*call_value_reg"
  29145. + [(set (match_operand 0 "metag_reg_nofloat_op" "=da")
  29146. + (call (mem:QI (match_operand:SI 1 "metag_reg_nofloat_op" "da"))
  29147. + (match_operand:SI 2 "immediate_operand" "")))]
  29148. + ""
  29149. + "*
  29150. + return output_call (operands, 1);"
  29151. + [(set_attr "type" "unknown")
  29152. + (set_attr "length" "8")])
  29153. +
  29154. +(define_insn "*sibcall_sym"
  29155. + [(call (mem:QI (match_operand:SI 0 "symbolic_operand" ""))
  29156. + (match_operand:SI 1 "immediate_operand" ""))
  29157. + (unspec [(const_int 0)] UNSPEC_SIBCALL)]
  29158. + ""
  29159. + "*
  29160. + return output_sibcall (operands, 0);"
  29161. + [(set_attr "type" "branch")
  29162. + (set_attr "length" "8")])
  29163. +
  29164. +(define_insn "*call_sym"
  29165. + [(call (mem:QI (match_operand:SI 0 "symbolic_operand" ""))
  29166. + (match_operand:SI 1 "immediate_operand" ""))]
  29167. + ""
  29168. + "*
  29169. + return output_call (operands, 0);"
  29170. + [(set_attr "type" "unknown")
  29171. + (set (attr "length")
  29172. + (if_then_else
  29173. + (eq (symbol_ref "metag_tbiassert_p (operands[0])") (const_int 0))
  29174. + (const_int 8)
  29175. + (const_int 12)))])
  29176. +
  29177. +(define_insn "*sibcall_value_sym"
  29178. + [(set (match_operand 0 "metag_reg_nofloat_op" "=da")
  29179. + (call (mem:QI (match_operand:SI 1 "symbolic_operand" ""))
  29180. + (match_operand:SI 2 "immediate_operand" "")))
  29181. + (unspec [(const_int 0)] UNSPEC_SIBCALL_VALUE)]
  29182. + ""
  29183. + "*
  29184. + return output_sibcall (operands, 1);"
  29185. + [(set_attr "type" "branch")
  29186. + (set_attr "length" "8")])
  29187. +
  29188. +(define_insn "*call_value_sym"
  29189. + [(set (match_operand 0 "metag_reg_nofloat_op" "=da")
  29190. + (call (mem:QI (match_operand:SI 1 "symbolic_operand" ""))
  29191. + (match_operand:SI 2 "immediate_operand" "")))]
  29192. + ""
  29193. + "*
  29194. + return output_call (operands, 1);"
  29195. + [(set_attr "type" "unknown")
  29196. + (set (attr "length")
  29197. + (if_then_else
  29198. + (eq (symbol_ref "metag_tbiassert_p (operands[1])") (const_int 0))
  29199. + (const_int 8)
  29200. + (const_int 12)))])
  29201. +
  29202. +;; Return instruction
  29203. +(define_insn "return_internal"
  29204. + [(use (reg:SI D1RtP_REG))
  29205. + (return)]
  29206. + ""
  29207. + {
  29208. + /* META 2 and unconditional return and no return stub emitted */
  29209. + if (!metag_cond_exec_p ()
  29210. + && current_insn_predicate == NULL_RTX
  29211. + && TARGET_METAC_2_1
  29212. + && cfun->machine->cond_return_state != METAG_COND_RETURN_DONE)
  29213. + return metag_gen_cond_return_stub ();
  29214. + else if (!TARGET_METAC_2_1 /* META 1.2 or unconditional returns */
  29215. + || (!metag_cond_exec_p ()
  29216. + && current_insn_predicate == NULL_RTX))
  29217. + return "MOV%?\\tPC, D1RtP";
  29218. + else
  29219. + return metag_gen_cond_return_branch ("B%%?\\t$LX%d %%@\\t(* cond return stub)");
  29220. + }
  29221. + [(set_attr "type" "unknown")
  29222. + (set_attr "cond" "yes")])
  29223. +
  29224. +(define_insn "return_internal_cond_<mode>"
  29225. + [(set (pc)
  29226. + (if_then_else (match_operator 0 "comparison_operator"
  29227. + [(match_operand:CCANY 1 "metag_<mode>_reg" "")
  29228. + (unspec [(const_int 0)] UNSPEC_RET_COND)])
  29229. + (return)
  29230. + (pc)))]
  29231. + ""
  29232. + {
  29233. + if (!TARGET_METAC_2_1)
  29234. + return "MOV%z0\\tPC, D1RtP";
  29235. + else
  29236. + return metag_gen_cond_return_branch ("B%%z0\\t$LX%d %%@\\t(* cond return stub)");
  29237. + }
  29238. + [(set_attr "type" "unknown")])
  29239. +
  29240. +(define_insn "return_internal_cond_inverted_<mode>"
  29241. + [(set (pc)
  29242. + (if_then_else (match_operator 0 "comparison_operator"
  29243. + [(match_operand:CCANY 1 "metag_<mode>_reg" "")
  29244. + (unspec [(const_int 0)] UNSPEC_RET_COND_INVERTED)])
  29245. + (pc)
  29246. + (return)))]
  29247. + ""
  29248. + {
  29249. + if (!TARGET_METAC_2_1)
  29250. + return "MOV%Z0\\tPC, D1RtP";
  29251. + else
  29252. + return metag_gen_cond_return_branch ("B%%Z0\\t$LX%d %%@\\t(* cond return stub)");
  29253. + }
  29254. + [(set_attr "type" "unknown")
  29255. + (set_attr "cond" "yes")])
  29256. +
  29257. +(define_insn_and_split "return"
  29258. + [(return)]
  29259. + "METAG_USE_RETURN_INSN (false)"
  29260. + "#"
  29261. + "&& TRUE"
  29262. + [(const_int 0)]
  29263. + {
  29264. + metag_expand_epilogue (false);
  29265. + emit_jump_insn (gen_return_internal ());
  29266. + DONE;
  29267. + }
  29268. + [(set_attr "type" "unknown")])
  29269. +
  29270. +(define_insn_and_split "*cond_<mode>_return"
  29271. + [(set (pc)
  29272. + (if_then_else (match_operator 0 "comparison_operator"
  29273. + [(match_operand:CCANY 1 "metag_<mode>_reg" "")
  29274. + (const_int 0)])
  29275. + (return)
  29276. + (pc)))]
  29277. + "METAG_USE_RETURN_INSN (true)"
  29278. + "#"
  29279. + "&& TRUE"
  29280. + [(const_int 0)]
  29281. + {
  29282. + metag_expand_epilogue (false);
  29283. + emit_jump_insn (gen_return_internal_cond_<mode> (operands[0], operands[1]));
  29284. + DONE;
  29285. + }
  29286. + [(set_attr "type" "unknown")
  29287. + (set_attr "ccstate" "xcc")])
  29288. +
  29289. +(define_insn_and_split "*cond_<mode>_return_inverted"
  29290. + [(set (pc)
  29291. + (if_then_else (match_operator 0 "comparison_operator"
  29292. + [(match_operand:CCANY 1 "metag_<mode>_reg" "")
  29293. + (const_int 0)])
  29294. + (pc)
  29295. + (return)))]
  29296. + "METAG_USE_RETURN_INSN (true)"
  29297. + "#"
  29298. + "&& TRUE"
  29299. + [(const_int 0)]
  29300. + {
  29301. + metag_expand_epilogue (false);
  29302. + emit_jump_insn (gen_return_internal_cond_inverted_<mode> (operands[0], operands[1]));
  29303. + DONE;
  29304. + }
  29305. + [(set_attr "type" "unknown")
  29306. + (set_attr "ccstate" "xcc")])
  29307. +
  29308. +;; No-op instruction
  29309. +
  29310. +(define_insn "nop"
  29311. + [(const_int 0)]
  29312. + ""
  29313. + "NOP\\t\\t! (*nop OK)"
  29314. + [(set_attr "type" "nop")])
  29315. +
  29316. +(define_expand "casesi"
  29317. + [(match_operand:SI 0 "metag_reg_nofloat_op" "") ; index to jump on
  29318. + (match_operand:SI 1 "const_int_operand" "") ; lower bound
  29319. + (match_operand:SI 2 "const_int_operand" "") ; total range
  29320. + (match_operand:SI 3 "" "") ; table label
  29321. + (match_operand:SI 4 "" "")] ; Out of range label
  29322. + ""
  29323. + {
  29324. + rtx op5 = gen_reg_rtx (SImode);
  29325. + rtx op6 = gen_reg_rtx (SImode);
  29326. +
  29327. + emit_insn (gen_addsi3 (op5, operands[0], gen_int_mode (-INTVAL (operands[1]), SImode)));
  29328. + emit_insn (gen_cmpsi (op5, operands[2]));
  29329. + emit_jump_insn (gen_bgtu (operands[4]));
  29330. +
  29331. + /* This code is intricate...
  29332. + MiniM code can behave in three ways with respect to jump tables:
  29333. + 1) Automatic analysis and branch instruction sizing (default)
  29334. + 2) Forced short branch instructions
  29335. + 3) Forced long branch instructions
  29336. +
  29337. + META code looks like MiniM short branches have been used but they are in fact
  29338. + long branches.
  29339. +
  29340. + The first part of the following if block deals with all META cases and all MiniM
  29341. + cases, unless long branches have been forced on.
  29342. +
  29343. + The second part of the if block deals with MTX 0.1 and MTX 1.2 without MiniM
  29344. + enabled (this is 'classic MiniM') and also MiniM cases where long branches have
  29345. + been forced.
  29346. + */
  29347. +
  29348. + if ((TARGET_METAC_1_0 || TARGET_METAC_1_1) /* A Meta 1.0, 1.1, 1.2 or 2.1 */
  29349. + && !TARGET_METAC_0_1 /* Not an MTX 0.1 */
  29350. + /* MiniM code but with short or automatic branches */
  29351. + && (!TARGET_MINIM || metag_jump_table_branch != METAG_MINIM_JUMP_TABLE_BRANCH_LONG)
  29352. + && (!TARGET_MTX || TARGET_MINIM)) /* Either not an MTX 1.2
  29353. + or is an MTX 1.2 with MiniM */
  29354. + {
  29355. + int offset = 4;
  29356. +
  29357. + /* The instruction that is 'jumped over' ADD PC, CPCx, <reg|int> is
  29358. + always long encoded (see casesi_jmp) and can't be short encoded
  29359. + so the initial jump is 8 rather than 4 in MiniM mode */
  29360. +
  29361. + if (TARGET_MINIM)
  29362. + offset = 8;
  29363. +
  29364. + /* For automatic jump table analysis use the special ashlsi insn */
  29365. + if (TARGET_MINIM && metag_jump_table_branch == METAG_MINIM_JUMP_TABLE_BRANCH_AUTO)
  29366. + emit_insn (gen_jump_table_check_ashlsi3 (op6, op5, GEN_INT (2)));
  29367. + else
  29368. + emit_move_insn (op6,
  29369. + gen_rtx_ASHIFT (SImode, op5, GEN_INT (2)));
  29370. +
  29371. + emit_insn (gen_addsi3 (op6, op6, gen_int_mode (offset, SImode)));
  29372. + }
  29373. + /* An MTX 0.1 or MiniM code with long branches or an MTX 1.2 (without MiniM) */
  29374. + else if (TARGET_METAC_0_1 || TARGET_MINIM || TARGET_MTX)
  29375. + {
  29376. + emit_move_insn (op6,
  29377. + gen_rtx_ASHIFT (SImode, op5, GEN_INT (3)));
  29378. + emit_insn (gen_addsi3 (op6, op6, GEN_INT (8)));
  29379. + }
  29380. + else
  29381. + gcc_unreachable ();
  29382. +
  29383. + emit_jump_insn (gen_casesi_jmp (op6, operands[3]));
  29384. +
  29385. + DONE;
  29386. + }
  29387. +)
  29388. +
  29389. +(define_insn "jump_table_check_ashlsi3"
  29390. + [(set (match_operand:SI 0 "metag_register_op" "=e,e,f,f,r,r,r,r")
  29391. + (ashift:SI (match_operand:SI 1 "metag_reg_nofloat_op" "e,e,f,f,e,e,f,f")
  29392. + (unspec:SI [(match_operand:SI 2 "metag_regorint_op" "e,L,f,L,e,L,f,L")] UNSPEC_MINIM_JUMP_TABLE)))]
  29393. + "TARGET_MINIM"
  29394. + {
  29395. + /* Detect if short branches are permitted in this function */
  29396. + /* WORK NEEDED: This only needs to take place once per function just
  29397. + before emitting instructions */
  29398. + metag_can_use_short_branch ();
  29399. +
  29400. + operands[2] = GEN_INT (cfun->machine->can_use_short_branch ? 2 : 3);
  29401. +
  29402. + return "LSL%?\\t%0, %1, %2\\t%@ (*ashl si rrx OK)";
  29403. + }
  29404. + [(set_attr "type" "fast,fast,fast,fast,slow,slow,slow,slow")
  29405. + (set_attr "cond" "yes,yes,yes,yes,no,no,no,no")])
  29406. +
  29407. +;; The USE in this pattern is needed to tell flow analysis that this is
  29408. +;; a CASESI insn. It has no other purpose.
  29409. +(define_insn "casesi_jmp"
  29410. + [(parallel
  29411. + [(set (pc)
  29412. + (plus:SI (pc)
  29413. + (match_operand:SI 0 "metag_addrreg_op" "h,l")))
  29414. + (use (label_ref (match_operand 1 "" "")))])]
  29415. + ""
  29416. + {
  29417. + /* These instructions are guaranteed to be long encoded as there are
  29418. + no possible short encodings. However for clarity they are forced
  29419. + long */
  29420. + static const char* fmt;
  29421. +
  29422. + if (which_alternative == 0)
  29423. + fmt = "XL\\tADD\\tPC, CPC0, %0\\t%@ ... OK)";
  29424. + else
  29425. + fmt = "XL\\tADD\\tPC, CPC1, %0\\t%@ ... OK)";
  29426. +
  29427. + return &fmt[TARGET_MINIM ? 0 : 3];
  29428. + }
  29429. + [(set_attr "type" "branch")])
  29430. +
  29431. +;; jump instructions
  29432. +(define_insn "jump"
  29433. + [(set (pc)
  29434. + (label_ref (match_operand 0 "" "")))]
  29435. + ""
  29436. + {
  29437. + if (metag_consume_branch (insn))
  29438. + return "";
  29439. +
  29440. + return "B%?\\t%c0\\t\\t\\t%@ (*b ... OK)";
  29441. + }
  29442. + [(set_attr "type" "branch")
  29443. + (set_attr "cond" "yes")
  29444. + (set_attr "predicable" "yes")])
  29445. +
  29446. +(define_expand "indirect_jump"
  29447. + [(set (pc)
  29448. + (match_operand:SI 0 "address_operand" "p"))]
  29449. + ""
  29450. + {
  29451. + if (!REG_P (operands[0]))
  29452. + {
  29453. + /* Can only jump to register, see reg_jump below */
  29454. + rtx reg = gen_reg_rtx (SImode);
  29455. +
  29456. + emit_move_insn (reg, operands[0]);
  29457. + operands[0] = reg;
  29458. + }
  29459. + }
  29460. +)
  29461. +
  29462. +(define_insn "*reg_jump"
  29463. + [(set (pc)
  29464. + (match_operand:SI 0 "metag_register_op" "r"))]
  29465. + ""
  29466. + "MOV%?\\tPC, %0\\t\\t%@ (*j r OK)"
  29467. + [(set_attr "type" "branch")
  29468. + (set_attr "cond" "yes")
  29469. + (set_attr "predicable" "yes")])
  29470. +
  29471. +(define_insn "load_pic"
  29472. + [(set (match_operand:SI 0 "register_operand" "=X")
  29473. + (unspec:SI [(match_operand:SI 1 "register_operand" "X")] UNSPEC_PIC_BASE))]
  29474. + ""
  29475. + "ADDT\\t%0, %1, #HI(__GLOBAL_OFFSET_TABLE__)\\t\\n\\tADD\\t%0, %0, #LO(__GLOBAL_OFFSET_TABLE__ + 4)"
  29476. + [(set_attr "type" "two")
  29477. + (set_attr "ccstate" "ncc")
  29478. + (set_attr "rename" "no")])
  29479. +
  29480. +(include "vector.md")
  29481. +(include "builtins.md")
  29482. +
  29483. +(include "peephole2.md")
  29484. +(include "dsppeephole2.md")
  29485. +
  29486. +(include "peephole.md")
  29487. +(include "dsppeephole.md")
  29488. +
  29489. +(include "combines.md")
  29490. +(include "fp.md")
  29491. +
  29492. +(include "tls.md")
  29493. +
  29494. +;; The 6bit frame elimination insns below intentionally have 12bit predicates on
  29495. +;; their operands in the hope that the sum 'reduces' this value to fit a 6bit
  29496. +;; value
  29497. +
  29498. +;; stores
  29499. +(define_insn_and_split "*store_<mode>_via_frame_elimination_6bit"
  29500. + [(set (mem:MODES (plus:SI (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  29501. + (match_operand:SI 1 "metag_offset12_<mode>" "<Z>"))
  29502. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>")))
  29503. + (match_operand:<MODE> 3 "metag_register_op" "r"))]
  29504. + "(reload_in_progress || reload_completed)
  29505. + && metag_offset6_<mode> (GEN_INT (INTVAL (operands[1]) + INTVAL (operands[2])), SImode)"
  29506. + "#"
  29507. + "reload_completed"
  29508. + [(set (mem:<MODE> (plus:SI (match_dup 0)
  29509. + (match_dup 4)))
  29510. + (match_dup 3))]
  29511. + {
  29512. + operands[4] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[2]));
  29513. + }
  29514. +)
  29515. +
  29516. +(define_insn_and_split "*store_<mode>_via_frame_elimination_12bit"
  29517. + [(set (mem:MODES (plus:SI (plus:SI (match_operand:SI 0 "metag_reg12bit_op" "Yr")
  29518. + (match_operand:SI 1 "metag_offset12_<mode>" "<Z>"))
  29519. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>")))
  29520. + (match_operand:<MODE> 3 "metag_register_op" "r"))]
  29521. + "(reload_in_progress || reload_completed)
  29522. + && metag_offset12_<mode> (GEN_INT (INTVAL (operands[1]) + INTVAL (operands[2])), SImode)"
  29523. + "#"
  29524. + "reload_completed"
  29525. + [(set (mem:<MODE> (plus:SI (match_dup 0)
  29526. + (match_dup 4)))
  29527. + (match_dup 3))]
  29528. + {
  29529. + operands[4] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[2]));
  29530. + }
  29531. +)
  29532. +
  29533. +;; loads
  29534. +
  29535. +(define_insn_and_split "*load_<mode>_frame_elimination_6bit"
  29536. + [(set (match_operand:<MODE> 0 "metag_register_op" "=r")
  29537. + (mem:MODES (plus:SI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  29538. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>"))
  29539. + (match_operand:SI 3 "metag_offset12_<mode>" "<Z>"))))]
  29540. + "(reload_in_progress || reload_completed)
  29541. + && metag_offset6_<mode> (GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3])), SImode)"
  29542. + "#"
  29543. + "reload_completed"
  29544. + [(set (match_dup 0)
  29545. + (mem:<MODE> (plus:SI (match_dup 1)
  29546. + (match_dup 4))))]
  29547. + {
  29548. + operands[4] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]));
  29549. + }
  29550. +)
  29551. +
  29552. +(define_insn_and_split "*load_<mode>_frame_elimination_12bit"
  29553. + [(set (match_operand:<MODE> 0 "metag_register_op" "=r")
  29554. + (mem:MODES (plus:SI (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "Yr")
  29555. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>"))
  29556. + (match_operand:SI 3 "metag_offset12_<mode>" "<Z>"))))]
  29557. + "(reload_in_progress || reload_completed)
  29558. + && metag_offset12_<mode> (GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3])), SImode)"
  29559. + "#"
  29560. + "reload_completed"
  29561. + [(set (match_dup 0)
  29562. + (mem:<MODE> (plus:SI (match_dup 1)
  29563. + (match_dup 4))))]
  29564. + {
  29565. + operands[4] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]));
  29566. + }
  29567. +)
  29568. +
  29569. +;; load zero extend to SI
  29570. +(define_insn_and_split "*loadz_<mode>si_frame_elimination_6bit"
  29571. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  29572. + (zero_extend:SI
  29573. + (mem:EXTSI (plus:SI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  29574. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>"))
  29575. + (match_operand:SI 3 "metag_offset12_<mode>" "<Z>")))))]
  29576. + "(reload_in_progress || reload_completed)
  29577. + && metag_offset6_<mode> (GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3])), SImode)"
  29578. + "#"
  29579. + "reload_completed"
  29580. + [(set (match_dup 0)
  29581. + (zero_extend:SI
  29582. + (mem:<MODE> (plus:SI (match_dup 1)
  29583. + (match_dup 4)))))]
  29584. + {
  29585. + operands[4] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]));
  29586. + }
  29587. +)
  29588. +
  29589. +(define_insn_and_split "*loadz_<mode>si_frame_elimination_12bit"
  29590. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  29591. + (zero_extend:SI
  29592. + (mem:EXTSI (plus:SI (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "Yr")
  29593. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>"))
  29594. + (match_operand:SI 3 "metag_offset12_<mode>" "<Z>")))))]
  29595. + "(reload_in_progress || reload_completed)
  29596. + && metag_offset12_<mode> (GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3])), SImode)"
  29597. + "#"
  29598. + "reload_completed"
  29599. + [(set (match_dup 0)
  29600. + (zero_extend:SI
  29601. + (mem:<MODE> (plus:SI (match_dup 1)
  29602. + (match_dup 4)))))]
  29603. + {
  29604. + operands[4] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]));
  29605. + }
  29606. +)
  29607. +
  29608. +;; load zero extend to HI
  29609. +(define_insn_and_split "*loadz_<mode>hi_frame_elimination_6bit"
  29610. + [(set (match_operand:HI 0 "metag_register_op" "=r")
  29611. + (zero_extend:HI
  29612. + (mem:EXTHI (plus:SI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  29613. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>"))
  29614. + (match_operand:SI 3 "metag_offset12_<mode>" "<Z>")))))]
  29615. + "(reload_in_progress || reload_completed)
  29616. + && metag_offset6_<mode> (GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3])), SImode)"
  29617. + "#"
  29618. + "reload_completed"
  29619. + [(set (match_dup 0)
  29620. + (zero_extend:HI
  29621. + (mem:<MODE> (plus:SI (match_dup 1)
  29622. + (match_dup 4)))))]
  29623. + {
  29624. + operands[4] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]));
  29625. + }
  29626. +)
  29627. +
  29628. +(define_insn_and_split "*loadz_<mode>hi_frame_elimination_12bit"
  29629. + [(set (match_operand:HI 0 "metag_register_op" "=r")
  29630. + (zero_extend:HI
  29631. + (mem:EXTHI (plus:SI (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "Yr")
  29632. + (match_operand:SI 2 "metag_offset12_<mode>" "<Z>"))
  29633. + (match_operand:SI 3 "metag_offset12_<mode>" "<Z>")))))]
  29634. + "(reload_in_progress || reload_completed)
  29635. + && metag_offset12_<mode> (GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3])), SImode)"
  29636. + "#"
  29637. + "reload_completed"
  29638. + [(set (match_dup 0)
  29639. + (zero_extend:HI
  29640. + (mem:<MODE> (plus:SI (match_dup 1)
  29641. + (match_dup 4)))))]
  29642. + {
  29643. + operands[4] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]));
  29644. + }
  29645. +)
  29646. +
  29647. +(define_insn "*sto_<mode>_reload"
  29648. + [(set (mem:MODES (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "e,f,h,l")
  29649. + (match_operand:SI 1 "const_int_operand" "n,n,n,n")))
  29650. + (match_operand:<MODE> 2 "metag_register_op" "t,u,y,z"))]
  29651. + "!TARGET_METAC_1_1 && reload_in_progress && REGNO (operands[0]) == FRAME_POINTER_REGNUM"
  29652. + "#"
  29653. + [(set_attr "type" "fast")])
  29654. +
  29655. +(define_insn "*sto_<mode>_1_1_reload"
  29656. + [(set (mem:MODES (plus:SI (match_operand:SI 0 "metag_reg_nofloat_op" "da")
  29657. + (match_operand:SI 1 "const_int_operand" "n")))
  29658. + (match_operand:<MODE> 2 "metag_register_op" "r"))]
  29659. + "TARGET_METAC_1_1 && reload_in_progress && REGNO (operands[0]) == FRAME_POINTER_REGNUM"
  29660. + "#"
  29661. + [(set_attr "type" "fast")])
  29662. +
  29663. +(define_insn "*load_<mode>_reload"
  29664. + [(set (match_operand:<MODE> 0 "metag_register_op" "=r")
  29665. + (mem:MODES (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  29666. + (match_operand:SI 2 "const_int_operand" "n"))))]
  29667. + "reload_in_progress && REGNO (operands[1]) == FRAME_POINTER_REGNUM"
  29668. + "#"
  29669. + [(set_attr "type" "load")])
  29670. +
  29671. +(define_insn "*loadz_<mode>si_reload"
  29672. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  29673. + (zero_extend:SI
  29674. + (mem:EXTSI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  29675. + (match_operand:SI 2 "const_int_operand" "n")))))]
  29676. + "reload_in_progress && REGNO (operands[1]) == FRAME_POINTER_REGNUM"
  29677. + "#"
  29678. + [(set_attr "type" "load")])
  29679. +
  29680. +(define_insn "*loadz_<mode>hi_reload"
  29681. + [(set (match_operand:HI 0 "metag_register_op" "=r")
  29682. + (zero_extend:HI
  29683. + (mem:EXTHI (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  29684. + (match_operand:SI 2 "const_int_operand" "n")))))]
  29685. + "reload_in_progress && REGNO (operands[1]) == FRAME_POINTER_REGNUM"
  29686. + "#"
  29687. + [(set_attr "type" "load")])
  29688. +
  29689. +(define_cond_exec
  29690. + [(match_operator 0 "comparison_operator"
  29691. + [(match_operand:CC 1 "metag_cc_reg" "")
  29692. + (const_int 0)])]
  29693. + "!metag_cond_exec_p ()"
  29694. + "")
  29695. +
  29696. +;; end of file
  29697. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag-modes.def gcc-4.2.4/gcc/config/metag/metag-modes.def
  29698. --- gcc-4.2.4.orig/gcc/config/metag/metag-modes.def 1969-12-31 18:00:00.000000000 -0600
  29699. +++ gcc-4.2.4/gcc/config/metag/metag-modes.def 2015-07-03 18:46:05.749283542 -0500
  29700. @@ -0,0 +1,37 @@
  29701. +/* Definitions of target machine for GNU compiler, for META
  29702. + Copyright (C) 2007, 2008 Imagination Technologies Ltd
  29703. +
  29704. +This file is part of GCC.
  29705. +
  29706. +GCC is free software; you can redistribute it and/or modify it under
  29707. +the terms of the GNU General Public License as published by the Free
  29708. +Software Foundation; either version 3, or (at your option) any later
  29709. +version.
  29710. +
  29711. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  29712. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  29713. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  29714. +for more details.
  29715. +
  29716. +You should have received a copy of the GNU General Public License
  29717. +along with GCC; see the file COPYING3. If not see
  29718. +<http://www.gnu.org/licenses/>. */
  29719. +
  29720. +
  29721. +/* CC_NOOV mode should be used with SImode integer equalities.
  29722. + CC_Z mode should be used if only the Z zero flag is set correctly
  29723. + CC_N mode should be used if only the N sign flag is set correctly
  29724. + CC_O mode should be used if only the O overflow flag is set correctly
  29725. + CC_C mode should be used if only the C carry flag is set correctly
  29726. + CC mode should be used otherwise. */
  29727. +
  29728. +CC_MODE (CC_NOOV);
  29729. +CC_MODE (CC_Z);
  29730. +CC_MODE (CC_N);
  29731. +CC_MODE (CC_O);
  29732. +CC_MODE (CC_C);
  29733. +CC_MODE (CC_FP);
  29734. +CC_MODE (CC_FP_Q);
  29735. +
  29736. +VECTOR_MODE (INT, SI, 2);
  29737. +VECTOR_MODE (FLOAT, SF, 2);
  29738. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag.opt gcc-4.2.4/gcc/config/metag/metag.opt
  29739. --- gcc-4.2.4.orig/gcc/config/metag/metag.opt 1969-12-31 18:00:00.000000000 -0600
  29740. +++ gcc-4.2.4/gcc/config/metag/metag.opt 2015-07-03 18:46:05.773283541 -0500
  29741. @@ -0,0 +1,135 @@
  29742. +; Copyright (C) 2007, 2008 Imagination Technologies Ltd
  29743. +
  29744. +; This file is part of GCC.
  29745. +
  29746. +; GCC is free software; you can redistribute it and/or modify it under
  29747. +; the terms of the GNU General Public License as published by the Free
  29748. +; Software Foundation; either version 3, or (at your option) any later
  29749. +; version.
  29750. +
  29751. +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  29752. +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  29753. +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  29754. +; for more details.
  29755. +
  29756. +; You should have received a copy of the GNU General Public License
  29757. +; along with GCC; see the file COPYING3. If not see
  29758. +; <http://www.gnu.org/licenses/>.
  29759. +
  29760. +
  29761. +; Conditional execution can be checked for using TARGET_COND_EXEC_OPTIMIZE
  29762. +; This allows the optimize flag to be checked as well as the COND_EXEC
  29763. +; flag
  29764. +
  29765. +mcond-exec
  29766. +Target Mask(COND_EXEC)
  29767. +Enable conditional instructions.
  29768. +
  29769. +mbr-txrpt
  29770. +Target Var(flag_branch_on_count_reg) VarExists
  29771. +Enable use of low overhead loop instructions
  29772. +Default: Enabled
  29773. +
  29774. +mhwloop
  29775. +Target Var(flag_branch_on_count_reg) VarExists
  29776. +Enable use of low overhead loop instructions
  29777. +Default: Enabled
  29778. +
  29779. +mcharset=
  29780. +Target RejectNegative Joined Var(metag_charset_string) Init("")
  29781. +Specify the character set used by strcmp
  29782. +
  29783. +mextreg=
  29784. +Target RejectNegative Joined Var(metag_extreg_string) Init("")
  29785. +Specify the allowed extended registers in each unit (D0D1A0A1)
  29786. +Default: 0000
  29787. +
  29788. +mmetac=
  29789. +Target RejectNegative Joined Var(metag_cpu_string) Init("")
  29790. +Select Meta Core (0.1,1.0,1.1,1.2,2.1)
  29791. +
  29792. +mtune=
  29793. +Target RejectNegative Joined Var(metag_tune_string)
  29794. +Schedule for Meta Core (0.1,1.0,1.1,1.2,2.1)
  29795. +
  29796. +mmtx
  29797. +Target RejectNegative Mask(MTX) UnDocumented
  29798. +Target the MTX core family
  29799. +
  29800. +mminim
  29801. +Target Mask(MINIM)
  29802. +Optimise toward the core 16 bit MiniM instruction set and apply jump compression
  29803. +
  29804. +mminim-optimise
  29805. +Target Mask(MINIM_OPTIMISE)
  29806. +Apply MiniM optimisations.
  29807. +
  29808. +mhard-float
  29809. +Target JoinedOrMissing Mask(FPU) Negative(msoft-float) RejectNegative
  29810. +Enable generation of FPU instructions
  29811. +=D Double precision support (default)
  29812. +=S Single precision support
  29813. +Implies -mregs-float=16
  29814. +
  29815. +mflush-to-zero
  29816. +Target Mask(FLUSH_TO_ZERO)
  29817. +Disable instructions flushing to zero
  29818. +
  29819. +msoft-float
  29820. +Target InverseMask(FPU) Negative(mhard-float)
  29821. +Disable generation of FPU instructions (default)
  29822. +
  29823. +msimd-float
  29824. +Target Mask(FPU_SIMD)
  29825. +Enable SIMD FPU instructions (dual single precision operations)
  29826. +Only permitted with -mhard-float[=D]
  29827. +
  29828. +maccumfp
  29829. +Target Mask(FPU_ACCUM)
  29830. +Enable generation of FPU accumulator instructions
  29831. +Meta GCC does not use the FPU accumulator regardless of this option
  29832. +
  29833. +mregs-float=
  29834. +Target RejectNegative Joined Var(metag_fpureg_string) Init("")
  29835. +Specify the allowed floating point registers
  29836. +Default: 0
  29837. +
  29838. +mdsp
  29839. +Target Mask(DSP)
  29840. +Enable SIMD instructions (Requires DSP hardware thread).
  29841. +Implies -mextreg=8844
  29842. +
  29843. +mwidth=
  29844. +Target RejectNegative Joined Var(metag_width_string) Init("")
  29845. +Specify maximum width of a single memory access (32|64)
  29846. +
  29847. +mjump-table-branch=
  29848. +Target RejectNegative Joined Var(metag_jump_table_string) Init("auto") UnDocumented
  29849. +Specify the default branch size for jump tables in MiniM code
  29850. +Only permitted with -mminim
  29851. +
  29852. +mtbictxsave
  29853. +Target Mask(ECH)
  29854. +Enable extended context saving
  29855. +Allows DSP resources to be preserved in pre-emptive environments
  29856. +
  29857. +mcpu-config=
  29858. +Target RejectNegative Joined Var(metag_config_file) Init("")
  29859. +Specify a configuration file for setting default options
  29860. +
  29861. +mextensions=
  29862. +Target RejectNegative Joined Var(metag_extensions_string) Init("")
  29863. +Specify the permitted extensions to the core instruction set
  29864. +
  29865. +mhwtrace
  29866. +Target Mask(HWTRACE)
  29867. +Enable H/W instrumented tracing.
  29868. +
  29869. +mhwtrace-retpc
  29870. +Target Mask(HWTRACE_RETPC)
  29871. +Enable H/W instrumented tracing, including return addresses
  29872. +
  29873. +mhwtrace-leaf
  29874. +Target Mask(HWTRACE_LEAF)
  29875. +Enable H/W instrumented tracing, for all functions
  29876. +
  29877. diff -Nur gcc-4.2.4.orig/gcc/config/metag/metag-protos.h gcc-4.2.4/gcc/config/metag/metag-protos.h
  29878. --- gcc-4.2.4.orig/gcc/config/metag/metag-protos.h 1969-12-31 18:00:00.000000000 -0600
  29879. +++ gcc-4.2.4/gcc/config/metag/metag-protos.h 2015-07-03 18:46:05.749283542 -0500
  29880. @@ -0,0 +1,265 @@
  29881. +/* Definitions of target machine for GNU compiler.
  29882. + Imagination Technologies Meta version.
  29883. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
  29884. + Imagination Technologies Ltd
  29885. +
  29886. +This file is part of GCC.
  29887. +
  29888. +GCC is free software; you can redistribute it and/or modify it under
  29889. +the terms of the GNU General Public License as published by the Free
  29890. +Software Foundation; either version 3, or (at your option) any later
  29891. +version.
  29892. +
  29893. +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  29894. +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  29895. +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  29896. +for more details.
  29897. +
  29898. +You should have received a copy of the GNU General Public License
  29899. +along with GCC; see the file COPYING3. If not see
  29900. +<http://www.gnu.org/licenses/>. */
  29901. +
  29902. +#include "target.h"
  29903. +#include "tree.h"
  29904. +#include "cpplib.h"
  29905. +
  29906. +#ifdef HAVE_ATTR_metacore
  29907. +extern enum attr_metacore metacore;
  29908. +#endif
  29909. +
  29910. +extern void metag_split_movsi_immediate (rtx []);
  29911. +extern void metag_split_movdi (rtx []);
  29912. +extern void metag_split_movdi_immediate (rtx []);
  29913. +extern void metag_split_movdf (rtx []);
  29914. +extern void metag_split_movdf_immediate (rtx []);
  29915. +extern void metag_split_movsf (rtx []);
  29916. +extern void metag_split_movsf_immediate (rtx []);
  29917. +extern void metag_abort (rtx val) ATTRIBUTE_NORETURN;
  29918. +extern int metag_search_rhs (rtx);
  29919. +extern bool metag_cheap_return (bool);
  29920. +extern int debug_metag_md (void);
  29921. +extern unsigned int metag_mem_base (rtx);
  29922. +extern bool metag_mem_base_p (rtx, enum reg_class);
  29923. +extern void metag_override_options (void);
  29924. +extern bool metag_valid_machine_decl_attribute (tree, tree, tree, tree);
  29925. +extern bool metag_cond_exec_p (void);
  29926. +extern void metag_print_cc_if_conditional (FILE *);
  29927. +extern void metag_ccexec_label (const char *);
  29928. +extern bool metag_consume_branch (rtx);
  29929. +
  29930. +extern void metag_init_expanders (void);
  29931. +
  29932. +extern bool metag_legitimate_reg_p (rtx, bool);
  29933. +
  29934. +extern bool metag_legitimate_regno_p (unsigned int, bool);
  29935. +
  29936. +extern bool metag_regs_ok_for_base_offset_p (rtx, rtx, bool);
  29937. +extern bool metag_reg_ok_for_index_p (rtx, bool);
  29938. +
  29939. +extern bool metag_reg_ok_for_base_p (rtx, bool);
  29940. +extern bool metag_reg_ok_for_offset_p (rtx, bool);
  29941. +
  29942. +extern bool metag_legitimate_address_p (rtx, enum machine_mode, bool);
  29943. +
  29944. +extern bool metag_legitimate_post_incdec_p (rtx, enum machine_mode, bool);
  29945. +extern bool metag_legitimate_pre_incdec_p (rtx, enum machine_mode, bool);
  29946. +
  29947. +extern bool metag_legitimate_off_p (rtx, rtx, enum machine_mode, bool);
  29948. +
  29949. +extern bool metag_legitimate_twin_p (rtx, rtx, enum machine_mode, bool);
  29950. +
  29951. +extern bool metag_return_in_memory (tree);
  29952. +
  29953. +extern void output_fn_prologue (FILE *, int);
  29954. +extern void output_fn_epilogue (FILE *, int);
  29955. +
  29956. +extern bool output_call_addr (rtx, enum machine_mode);
  29957. +extern const char * output_sibcall (rtx [], unsigned int);
  29958. +extern const char * output_call (rtx [], unsigned int);
  29959. +extern bool metag_slow_store (rtx, rtx);
  29960. +extern rtx metag_gen_safe_temp (enum machine_mode, rtx);
  29961. +#ifdef RTX_CODE
  29962. +extern enum machine_mode metag_select_cc_mode (RTX_CODE, rtx, rtx);
  29963. +extern bool gen_metag_compare (RTX_CODE, rtx[], int);
  29964. +#endif
  29965. +
  29966. +extern rtx metag_gen_load_multiple (unsigned int, unsigned int, enum machine_mode, rtx, bool, rtx, HOST_WIDE_INT *);
  29967. +extern rtx metag_gen_store_multiple (unsigned int, unsigned int, enum machine_mode, rtx, bool, rtx, HOST_WIDE_INT *);
  29968. +extern bool metag_gen_movmemqi (rtx []);
  29969. +
  29970. +extern void metag_final_prescan_insn (rtx);
  29971. +extern int metag_initial_elimination_offset (int, int);
  29972. +#ifdef CUMULATIVE_ARGS
  29973. +extern void metag_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
  29974. +extern rtx metag_function_arg (CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
  29975. +#endif
  29976. +
  29977. +extern long metag_const_double_to_hp (rtx op, bool *inexact);
  29978. +
  29979. +extern void metag_function_profiler (FILE *);
  29980. +#ifdef RTX_CODE
  29981. +extern void metag_print_operand (FILE *, rtx, RTX_CODE);
  29982. +#endif
  29983. +extern void metag_print_operand_address (FILE *, rtx);
  29984. +
  29985. +extern void metag_asm_output_opcode (FILE *, const char *);
  29986. +
  29987. +extern bool metag_frame_related_rtx (rtx);
  29988. +extern bool metag_symbolic_reference_mentioned_p (rtx);
  29989. +extern bool metag_legitimate_pic_address_disp_p (rtx);
  29990. +extern rtx metag_legitimize_pic_address (rtx, rtx);
  29991. +extern rtx metag_legitimize_address (rtx, rtx, enum machine_mode);
  29992. +extern int metag_letter_for_const (rtx);
  29993. +extern bool metag_const_ok_for_letters_p (rtx, const char []);
  29994. +extern bool metag_datareg_p (unsigned int);
  29995. +extern bool metag_addrreg_p (unsigned int);
  29996. +extern bool metag_fpcreg_p (unsigned int);
  29997. +extern bool metag_fppreg_p (unsigned int);
  29998. +extern bool metag_legitimate_modify_p (rtx, enum machine_mode, bool);
  29999. +
  30000. +extern bool metag_same_regclass_p (rtx, rtx);
  30001. +
  30002. +extern bool metag_regno_same_unit_p (unsigned int, unsigned int);
  30003. +
  30004. +extern bool metag_zeroextract_mask_p (rtx, rtx);
  30005. +
  30006. +extern rtx metag_return_addr_rtx (int, rtx);
  30007. +
  30008. +extern HOST_WIDE_INT metag_function_arg_boundary (enum machine_mode, tree);
  30009. +
  30010. +extern int metag_first_parm_offset (tree);
  30011. +
  30012. +extern bool metag_consumer_is_cond_p (rtx, rtx);
  30013. +
  30014. +extern bool metag_bypass_before_reload_p (rtx, rtx);
  30015. +
  30016. +extern bool metag_hard_regno_rename_ok_p (rtx, unsigned int, unsigned int);
  30017. +
  30018. +extern void metag_expand_prologue (void);
  30019. +extern void metag_expand_epilogue (bool);
  30020. +
  30021. +extern enum reg_class metag_regno_reg_class_minimal (unsigned int);
  30022. +
  30023. +extern enum reg_class metag_regno_reg_class_unit (unsigned int);
  30024. +
  30025. +extern bool metag_use_return_insn (bool);
  30026. +
  30027. +extern bool metag_frame_pointer_required (void);
  30028. +
  30029. +extern void metag_setup_frame_addresses (void);
  30030. +
  30031. +extern void metag_expand_set_return_address (rtx);
  30032. +
  30033. +extern bool metag_doloop_loop_nest_optimized(struct loop *, struct doloopnest *);
  30034. +
  30035. +extern bool metag_doloop_check_any_nest_optimized (struct loop *, struct doloopnest *);
  30036. +
  30037. +extern void metag_doloop_mark_nests_optimized (struct loop *, struct doloopnest **);
  30038. +
  30039. +extern bool metag_current_function_loads_pic_register (void);
  30040. +
  30041. +extern rtx metag_legitimize_reload_address (rtx, enum machine_mode, int, int, int);
  30042. +
  30043. +extern bool metag_offset6_mode (rtx, enum machine_mode);
  30044. +
  30045. +extern bool metag_offset12_mode (rtx, enum machine_mode);
  30046. +
  30047. +extern bool metag_regno12bit_p (unsigned int);
  30048. +
  30049. +extern bool metag_split_early (void);
  30050. +
  30051. +extern bool metag_split_hi_lo_sum_early (void);
  30052. +
  30053. +extern bool metag_hard_regno_mode_ok (unsigned int, enum machine_mode);
  30054. +
  30055. +extern void metag_override_options_per_os (void);
  30056. +extern bool metag_handle_option_per_os (size_t, const char *, int);
  30057. +extern bool metag_function_ok_for_sibcall_per_os (tree, tree);
  30058. +
  30059. +/* These functions are part of a framework to allow the support of OS
  30060. + specific builtin functions within GCC. */
  30061. +extern void metag_init_builtins_per_os (void);
  30062. +extern rtx metag_expand_builtin_per_os (tree, rtx);
  30063. +extern void metag_pad_function_call (rtx);
  30064. +extern bool metag_tbiassert_p (rtx);
  30065. +
  30066. +extern void metag_internal_label (FILE *, const char *, unsigned long);
  30067. +extern void metag_function_prologue (FILE *, HOST_WIDE_INT);
  30068. +extern void metag_function_end_prologue (FILE *);
  30069. +extern void metag_function_begin_epilogue (FILE *);
  30070. +extern void metag_function_epilogue (FILE *, HOST_WIDE_INT);
  30071. +extern void metag_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
  30072. + tree);
  30073. +extern bool metag_can_output_mi_thunk (tree, HOST_WIDE_INT, HOST_WIDE_INT,
  30074. + tree);
  30075. +extern int metag_sched_adjust_cost (rtx, rtx, rtx, int);
  30076. +extern bool metag_handle_option (size_t, const char *, int);
  30077. +extern tree metag_merge_decl_attributes (tree, tree);
  30078. +extern tree metag_merge_type_attributes (tree, tree);
  30079. +extern const struct attribute_spec metag_attribute_table[];
  30080. +extern int metag_comp_type_attributes (tree, tree);
  30081. +extern void metag_init_builtins (void);
  30082. +extern rtx metag_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
  30083. +extern bool metag_function_ok_for_sibcall (tree, tree);
  30084. +extern void metag_encode_section_info (tree, rtx, int);
  30085. +extern bool metag_scalar_mode_supported_p (enum machine_mode);
  30086. +extern bool metag_rtx_costs (rtx, int, int, int *);
  30087. +extern int metag_address_cost (rtx);
  30088. +extern void metag_machine_dependent_reorg (void);
  30089. +extern tree metag_gimplify_va_arg_expr (tree, tree, tree *, tree *);
  30090. +extern const char * metag_invalid_within_doloop (rtx);
  30091. +extern bool metag_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, tree,
  30092. + bool);
  30093. +extern void metag_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
  30094. + tree, int *, int);
  30095. +extern bool metag_must_pass_in_stack (enum machine_mode, tree);
  30096. +extern int metag_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode, tree,
  30097. + bool);
  30098. +extern enum reg_class metag_secondary_reload (bool, rtx, enum reg_class,
  30099. + enum machine_mode,
  30100. + secondary_reload_info *);
  30101. +extern bool metag_vector_mode_supported_p (enum machine_mode);
  30102. +extern enum reg_class metag_secondary_reload_class (enum reg_class,
  30103. + enum machine_mode,
  30104. + rtx, bool);
  30105. +
  30106. +extern bool metag_output_addr_const_extra (FILE *, rtx);
  30107. +
  30108. +extern bool metag_dsp_ri16_operands (rtx[]);
  30109. +extern bool metag_dsp_ri5_operands (rtx[]);
  30110. +extern bool metag_dsp_rrr_operands (rtx[], bool);
  30111. +extern bool metag_dsp_cmp_rrr_operands (rtx[], bool);
  30112. +extern bool metag_dsp_cmp_ri16_operands (rtx[]);
  30113. +extern bool metag_dsp_rrr_mov_operands (rtx[], bool);
  30114. +extern bool metag_dsp_rri5_operands (rtx[]);
  30115. +extern bool metag_dsp_rr_operands (rtx[]);
  30116. +extern bool metag_dsp_cmp_rri5_operands (rtx[]);
  30117. +extern bool metag_dsp_rr_rr_mov_operands (rtx[]);
  30118. +
  30119. +extern void metag_dsp_peephole2_rr_convert (rtx[]);
  30120. +extern void metag_dsp_peephole2_rr_mov_convert (rtx[]);
  30121. +extern void metag_dsp_peephole2_rrr_convert (rtx[]);
  30122. +extern void metag_dsp_peephole2_rrr_mov_convert (rtx[]);
  30123. +extern void metag_dsp_peephole2_ri16_convert (rtx[]);
  30124. +extern void metag_dsp_peephole2_rri5_convert (rtx[]);
  30125. +
  30126. +extern bool metag_move_valid_p (rtx, rtx);
  30127. +extern void metag_cpu_cpp_builtins (cpp_reader *);
  30128. +
  30129. +extern void metag_expand_didf2 (rtx, rtx);
  30130. +
  30131. +/* Handle the jump_table_branch pragma */
  30132. +extern void metag_pragma_jump_table_branch (struct cpp_reader *);
  30133. +/* Handle the hwtrace_function pragma */
  30134. +extern void metag_pragma_hwtrace_function (struct cpp_reader *);
  30135. +
  30136. +extern bool metag_meta2_bex_enabled;
  30137. +extern void metag_can_use_short_branch (void);
  30138. +extern void metag_emit_move_sequence (rtx[], enum machine_mode);
  30139. +
  30140. +extern rtx metag_libcall_value (enum machine_mode);
  30141. +extern rtx metag_function_value (tree, tree, bool);
  30142. +
  30143. +extern bool tls_symbolic_operand_p (rtx);
  30144. +extern bool metag_bfd_tls_referenced_p (rtx);
  30145. +extern rtx metag_bfd_legitimize_tls_address (rtx);
  30146. diff -Nur gcc-4.2.4.orig/gcc/config/metag/peephole2.md gcc-4.2.4/gcc/config/metag/peephole2.md
  30147. --- gcc-4.2.4.orig/gcc/config/metag/peephole2.md 1969-12-31 18:00:00.000000000 -0600
  30148. +++ gcc-4.2.4/gcc/config/metag/peephole2.md 2015-07-03 18:46:05.773283541 -0500
  30149. @@ -0,0 +1,1324 @@
  30150. +;; Machine description for GNU compiler,
  30151. +;; Imagination Technologies Meta version.
  30152. +;; Copyright (C) 2007
  30153. +;; Imagination Technologies Ltd
  30154. +
  30155. +;; This file is part of GCC.
  30156. +
  30157. +;; GCC is free software; you can redistribute it and/or modify it under
  30158. +;; the terms of the GNU General Public License as published by the Free
  30159. +;; Software Foundation; either version 3, or (at your option) any later
  30160. +;; version.
  30161. +
  30162. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  30163. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  30164. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  30165. +;; for more details.
  30166. +
  30167. +;; You should have received a copy of the GNU General Public License
  30168. +;; along with GCC; see the file COPYING3. If not see
  30169. +;; <http://www.gnu.org/licenses/>.
  30170. +
  30171. +
  30172. +;; ====PRE_INC
  30173. +
  30174. +;; ----------------------------------------------------------------------------
  30175. +;; Recognising DI/SI/HI/QI store pre-inc/dec/modify
  30176. +;; ----------------------------------------------------------------------------
  30177. +
  30178. +(define_peephole2
  30179. + [(set (match_operand:SI 0 "metag_register_op" "")
  30180. + (plus:SI (match_dup 0)
  30181. + (match_operand:SI 1 "metag_register_op" "")))
  30182. + (set (match_operand:MODES 2 "memory_operand" "")
  30183. + (match_operand:<MODE> 3 "metag_register_op" ""))]
  30184. + "metag_same_regclass_p (operands[0], operands[1])
  30185. + && !metag_same_regclass_p (operands[0], operands[3])
  30186. + && rtx_equal_p (operands[0], XEXP (operands[2], 0))
  30187. + && (GET_MODE_SIZE (<MODE>mode) <= UNITS_PER_WORD
  30188. + || !metag_same_regclass_p (operands[0], gen_rtx_REG (SImode, REGNO (operands[3]) + 1)))"
  30189. + [(const_int 0)]
  30190. + {
  30191. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30192. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30193. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  30194. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[3]));
  30195. +
  30196. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[2]);
  30197. + if (auto_inc_p (pre_modify))
  30198. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  30199. + DONE;
  30200. + }
  30201. +)
  30202. +
  30203. +(define_peephole2
  30204. + [(set (match_operand:SI 0 "metag_register_op" "")
  30205. + (plus:SI (match_dup 0)
  30206. + (match_operand:SI 1 "metag_offset6_<mode>" "")))
  30207. + (set (match_operand:MODES 2 "memory_operand" "")
  30208. + (match_operand:<MODE> 3 "metag_register_op" ""))]
  30209. + "rtx_equal_p (operands[0], XEXP (operands[2], 0))"
  30210. + [(const_int 0)]
  30211. + {
  30212. + rtx pre, mem, insn;
  30213. +
  30214. + if (INTVAL (operands[1]) == GET_MODE_SIZE (<MODE>mode))
  30215. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  30216. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (<MODE>mode))
  30217. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  30218. + else
  30219. + {
  30220. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30221. +
  30222. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30223. + }
  30224. +
  30225. + mem = gen_rtx_MEM (<MODE>mode, pre);
  30226. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[2]);
  30227. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[3]));
  30228. +
  30229. + if (auto_inc_p (pre))
  30230. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  30231. + DONE;
  30232. + }
  30233. +)
  30234. +
  30235. +;; ----------------------------------------------------------------------------
  30236. +
  30237. +;; ----------------------------------------------------------------------------
  30238. +;; Recognising DI/SI/HI/QI load pre-inc/dec/modify
  30239. +;; ----------------------------------------------------------------------------
  30240. +
  30241. +(define_peephole2
  30242. + [(set (match_operand:SI 0 "metag_register_op" "")
  30243. + (plus:SI (match_dup 0)
  30244. + (match_operand:SI 1 "metag_register_op" "")))
  30245. + (set (match_operand:<MODE> 2 "metag_register_op" "")
  30246. + (match_operand:MODES 3 "memory_operand" ""))]
  30247. + "metag_same_regclass_p (operands[0], operands[1])
  30248. + && rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  30249. + [(const_int 0)]
  30250. + {
  30251. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30252. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30253. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  30254. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], mem));
  30255. +
  30256. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  30257. +
  30258. + if (auto_inc_p (pre_modify))
  30259. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  30260. + DONE;
  30261. + }
  30262. +)
  30263. +
  30264. +(define_peephole2
  30265. + [(set (match_operand:SI 0 "metag_register_op" "")
  30266. + (plus:SI (match_dup 0)
  30267. + (match_operand:SI 1 "metag_offset6_<mode>" "")))
  30268. + (set (match_operand:<MODE> 2 "metag_register_op" "")
  30269. + (match_operand:MODES 3 "memory_operand" ""))]
  30270. + "rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  30271. + [(const_int 0)]
  30272. + {
  30273. + rtx pre, mem, insn;
  30274. +
  30275. + if (INTVAL (operands[1]) == GET_MODE_SIZE (<MODE>mode))
  30276. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  30277. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (<MODE>mode))
  30278. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  30279. + else
  30280. + {
  30281. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30282. +
  30283. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30284. + }
  30285. +
  30286. + mem = gen_rtx_MEM (<MODE>mode, pre);
  30287. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  30288. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], mem));
  30289. +
  30290. + if (auto_inc_p (pre))
  30291. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  30292. + DONE;
  30293. + }
  30294. +)
  30295. +
  30296. +;; ----------------------------------------------------------------------------
  30297. +
  30298. +;; ----------------------------------------------------------------------------
  30299. +;; Recognising zero extend SI load pre-inc/dec/modify
  30300. +;; ----------------------------------------------------------------------------
  30301. +
  30302. +(define_peephole2
  30303. + [(set (match_operand:SI 0 "metag_register_op" "")
  30304. + (plus:SI (match_dup 0)
  30305. + (match_operand:SI 1 "metag_register_op" "")))
  30306. + (set (match_operand:SI 2 "metag_register_op" "")
  30307. + (zero_extend:SI
  30308. + (match_operand:EXTSI 3 "memory_operand" "")))]
  30309. + "metag_same_regclass_p (operands[0], operands[1])
  30310. + && rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  30311. + [(const_int 0)]
  30312. + {
  30313. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30314. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30315. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  30316. + rtx zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  30317. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], zextend));
  30318. +
  30319. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  30320. +
  30321. + if (auto_inc_p (pre_modify))
  30322. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  30323. + DONE;
  30324. + }
  30325. +)
  30326. +
  30327. +(define_peephole2
  30328. + [(set (match_operand:SI 0 "metag_register_op" "")
  30329. + (plus:SI (match_dup 0)
  30330. + (match_operand:SI 1 "metag_offset6_<mode>" "")))
  30331. + (set (match_operand:SI 2 "metag_register_op" "")
  30332. + (zero_extend:SI
  30333. + (match_operand:EXTSI 3 "memory_operand" "")))]
  30334. + "rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  30335. + [(const_int 0)]
  30336. + {
  30337. + rtx pre, mem, zextend, insn;
  30338. +
  30339. + if (INTVAL (operands[1]) == GET_MODE_SIZE (<MODE>mode))
  30340. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  30341. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (<MODE>mode))
  30342. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  30343. + else
  30344. + {
  30345. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30346. +
  30347. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30348. + }
  30349. +
  30350. + mem = gen_rtx_MEM (<MODE>mode, pre);
  30351. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  30352. + zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  30353. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], zextend));
  30354. +
  30355. + if (auto_inc_p (pre))
  30356. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  30357. + DONE;
  30358. + }
  30359. +)
  30360. +
  30361. +;; ----------------------------------------------------------------------------
  30362. +;; Recognising zero extend HI load pre-inc/dec/modify
  30363. +;; ----------------------------------------------------------------------------
  30364. +
  30365. +(define_peephole2
  30366. + [(set (match_operand:SI 0 "metag_register_op" "")
  30367. + (plus:SI (match_dup 0)
  30368. + (match_operand:SI 1 "metag_register_op" "")))
  30369. + (set (match_operand:HI 2 "metag_register_op" "")
  30370. + (zero_extend:HI
  30371. + (match_operand:EXTHI 3 "memory_operand" "")))]
  30372. + "metag_same_regclass_p (operands[0], operands[1])
  30373. + && rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  30374. + [(const_int 0)]
  30375. + {
  30376. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30377. + rtx pre_modify = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30378. + rtx mem = gen_rtx_MEM (<MODE>mode, pre_modify);
  30379. + rtx zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  30380. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], zextend));
  30381. +
  30382. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  30383. +
  30384. + if (auto_inc_p (pre_modify))
  30385. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre_modify, 0), REG_NOTES (insn));
  30386. + DONE;
  30387. + }
  30388. +)
  30389. +
  30390. +(define_peephole2
  30391. + [(set (match_operand:SI 0 "metag_register_op" "")
  30392. + (plus:SI (match_dup 0)
  30393. + (match_operand:SI 1 "metag_offset6_<mode>" "")))
  30394. + (set (match_operand:HI 2 "metag_register_op" "")
  30395. + (zero_extend:HI
  30396. + (match_operand:EXTHI 3 "memory_operand" "")))]
  30397. + "rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  30398. + [(const_int 0)]
  30399. + {
  30400. + rtx pre, mem, zextend, insn;
  30401. +
  30402. + if (INTVAL (operands[1]) == GET_MODE_SIZE (<MODE>mode))
  30403. + pre = gen_rtx_PRE_INC (SImode, operands[0]);
  30404. + else if (INTVAL (operands[1]) == -GET_MODE_SIZE (<MODE>mode))
  30405. + pre = gen_rtx_PRE_DEC (SImode, operands[0]);
  30406. + else
  30407. + {
  30408. + rtx plus = gen_rtx_PLUS (SImode, operands[0], operands[1]);
  30409. +
  30410. + pre = gen_rtx_PRE_MODIFY (SImode, operands[0], plus);
  30411. + }
  30412. +
  30413. + mem = gen_rtx_MEM (<MODE>mode, pre);
  30414. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  30415. + zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  30416. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[2], zextend));
  30417. +
  30418. + if (auto_inc_p (pre))
  30419. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (pre, 0), REG_NOTES (insn));
  30420. + DONE;
  30421. + }
  30422. +)
  30423. +;; ====PRE_INC
  30424. +
  30425. +;; ====POST_INC
  30426. +
  30427. +;; ----------------------------------------------------------------------------
  30428. +;; Recognising DF/SF/DI/SI/HI/QI store post-inc/dec/modify
  30429. +;; ----------------------------------------------------------------------------
  30430. +
  30431. +(define_peephole2
  30432. + [(set (match_operand:MODES 0 "memory_operand" "")
  30433. + (match_operand:<MODE> 1 "metag_register_op" ""))
  30434. + (set (match_operand:SI 2 "metag_register_op" "")
  30435. + (plus:SI (match_dup 2)
  30436. + (match_operand:SI 3 "metag_register_op" "")))]
  30437. + "metag_same_regclass_p (operands[3], operands[2])
  30438. + && !metag_same_regclass_p (operands[2], operands[1])
  30439. + && rtx_equal_p (operands[2], XEXP (operands[0], 0))
  30440. + && (GET_MODE_SIZE (<MODE>mode) <= UNITS_PER_WORD
  30441. + || !metag_same_regclass_p (operands[2], gen_rtx_REG (SImode, REGNO (operands[1]) + 1)))"
  30442. + [(const_int 0)]
  30443. + {
  30444. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30445. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30446. + rtx mem = gen_rtx_MEM (<MODE>mode, post_modify);
  30447. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  30448. +
  30449. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[0]);
  30450. +
  30451. + if (auto_inc_p (post_modify))
  30452. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  30453. + DONE;
  30454. + }
  30455. +)
  30456. +
  30457. +(define_peephole2
  30458. + [(set (match_operand:MODES 0 "memory_operand" "")
  30459. + (match_operand:<MODE> 1 "metag_register_op" ""))
  30460. + (set (match_operand:SI 2 "metag_register_op" "")
  30461. + (plus:SI (match_dup 2)
  30462. + (match_operand:SI 3 "metag_offset6_<mode>" "")))]
  30463. + "rtx_equal_p (operands[2], XEXP (operands[0], 0))"
  30464. + [(const_int 0)]
  30465. + {
  30466. + rtx post, mem, insn;
  30467. +
  30468. + if (INTVAL (operands[3]) == GET_MODE_SIZE (<MODE>mode))
  30469. + post = gen_rtx_POST_INC (SImode, operands[2]);
  30470. + else if (INTVAL (operands[3]) == -GET_MODE_SIZE (<MODE>mode))
  30471. + post = gen_rtx_POST_DEC (SImode, operands[2]);
  30472. + else
  30473. + {
  30474. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30475. +
  30476. + post = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30477. + }
  30478. +
  30479. + mem = gen_rtx_MEM (<MODE>mode, post);
  30480. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[0]);
  30481. + insn = emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
  30482. +
  30483. + if (auto_inc_p (post))
  30484. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  30485. + DONE;
  30486. + }
  30487. +)
  30488. +
  30489. +;; ----------------------------------------------------------------------------
  30490. +
  30491. +;; ----------------------------------------------------------------------------
  30492. +;; Recognising DI/SI/HI/QI load post-inc/dec/modify
  30493. +;; ----------------------------------------------------------------------------
  30494. +
  30495. +(define_peephole2
  30496. + [(set (match_operand:<MODE> 0 "metag_register_op" "")
  30497. + (match_operand:MODES 1 "memory_operand" ""))
  30498. + (set (match_operand:SI 2 "metag_register_op" "")
  30499. + (plus:SI (match_dup 2)
  30500. + (match_operand:SI 3 "metag_register_op" "")))]
  30501. + "metag_same_regclass_p (operands[3], operands[2])
  30502. + && rtx_equal_p (operands[2], XEXP (operands[1], 0))
  30503. + && REGNO (operands[0]) != REGNO (operands[3])
  30504. + && REGNO (operands[0]) != REGNO (operands[2])"
  30505. + [(const_int 0)]
  30506. + {
  30507. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30508. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30509. + rtx mem = gen_rtx_MEM (<MODE>mode, post_modify);
  30510. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  30511. +
  30512. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[1]);
  30513. +
  30514. + if (auto_inc_p (post_modify))
  30515. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  30516. + DONE;
  30517. + }
  30518. +)
  30519. +
  30520. +(define_peephole2
  30521. + [(set (match_operand:<MODE> 0 "metag_register_op" "")
  30522. + (match_operand:MODES 1 "memory_operand" ""))
  30523. + (set (match_operand:SI 2 "metag_register_op" "")
  30524. + (plus:SI (match_dup 2)
  30525. + (match_operand:SI 3 "metag_offset6_<mode>" "")))]
  30526. + "REGNO (operands[0]) != REGNO (operands[2])
  30527. + && rtx_equal_p (operands[2], XEXP (operands[1], 0))"
  30528. + [(const_int 0)]
  30529. + {
  30530. + rtx post, mem, insn;
  30531. +
  30532. + if (INTVAL (operands[3]) == GET_MODE_SIZE (<MODE>mode))
  30533. + post = gen_rtx_POST_INC (SImode, operands[2]);
  30534. + else if (INTVAL (operands[3]) == -GET_MODE_SIZE (<MODE>mode))
  30535. + post = gen_rtx_POST_DEC (SImode, operands[2]);
  30536. + else
  30537. + {
  30538. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30539. +
  30540. + post = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30541. + }
  30542. +
  30543. + mem = gen_rtx_MEM (<MODE>mode, post);
  30544. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[1]);
  30545. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
  30546. +
  30547. + if (auto_inc_p (post))
  30548. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  30549. + DONE;
  30550. + }
  30551. +)
  30552. +
  30553. +;; ----------------------------------------------------------------------------
  30554. +
  30555. +;; ----------------------------------------------------------------------------
  30556. +;; Recognising zero extend SI load post-modify
  30557. +;; ----------------------------------------------------------------------------
  30558. +
  30559. +(define_peephole2
  30560. + [(set (match_operand:SI 0 "metag_register_op" "")
  30561. + (zero_extend:SI
  30562. + (match_operand:EXTSI 1 "memory_operand" "")))
  30563. + (set (match_operand:SI 2 "metag_register_op" "")
  30564. + (plus:SI (match_dup 2)
  30565. + (match_operand:SI 3 "metag_register_op" "")))]
  30566. + "metag_same_regclass_p (operands[3], operands[2])
  30567. + && REGNO (operands[0]) != REGNO (operands[3])
  30568. + && REGNO (operands[0]) != REGNO (operands[2])
  30569. + && rtx_equal_p (operands[2], XEXP (operands[1], 0))"
  30570. + [(const_int 0)]
  30571. + {
  30572. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30573. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30574. + rtx mem = gen_rtx_MEM (<MODE>mode, post_modify);
  30575. + rtx zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  30576. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  30577. +
  30578. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[1]);
  30579. +
  30580. + if (auto_inc_p (post_modify))
  30581. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  30582. + DONE;
  30583. + }
  30584. +)
  30585. +
  30586. +(define_peephole2
  30587. + [(set (match_operand:SI 0 "metag_register_op" "")
  30588. + (zero_extend:SI
  30589. + (match_operand:EXTSI 1 "memory_operand" "")))
  30590. + (set (match_operand:SI 2 "metag_register_op" "")
  30591. + (plus:SI (match_dup 2)
  30592. + (match_operand:SI 3 "metag_offset6_<mode>" "")))]
  30593. + "REGNO (operands[0]) != REGNO (operands[2])
  30594. + && rtx_equal_p (operands[2], XEXP (operands[1], 0))"
  30595. + [(const_int 0)]
  30596. + {
  30597. + rtx post, mem, zextend, insn;
  30598. +
  30599. + if (INTVAL (operands[3]) == GET_MODE_SIZE (<MODE>mode))
  30600. + post = gen_rtx_POST_INC (SImode, operands[2]);
  30601. + else if (INTVAL (operands[3]) == -GET_MODE_SIZE (<MODE>mode))
  30602. + post = gen_rtx_POST_DEC (SImode, operands[2]);
  30603. + else
  30604. + {
  30605. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30606. +
  30607. + post = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30608. + }
  30609. +
  30610. + mem = gen_rtx_MEM (<MODE>mode, post);
  30611. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[1]);
  30612. + zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  30613. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  30614. +
  30615. + if (auto_inc_p (post))
  30616. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  30617. + DONE;
  30618. + }
  30619. +)
  30620. +
  30621. +;; ----------------------------------------------------------------------------
  30622. +;; Recognising zero extend HI load post-inc/dec/modify
  30623. +;; ----------------------------------------------------------------------------
  30624. +
  30625. +(define_peephole2
  30626. + [(set (match_operand:HI 0 "metag_register_op" "")
  30627. + (zero_extend:HI
  30628. + (match_operand:EXTHI 1 "memory_operand" "")))
  30629. + (set (match_operand:SI 2 "metag_register_op" "")
  30630. + (plus:SI (match_dup 2)
  30631. + (match_operand:SI 3 "metag_register_op" "")))]
  30632. + "metag_same_regclass_p (operands[3], operands[2])
  30633. + && REGNO (operands[0]) != REGNO (operands[3])
  30634. + && REGNO (operands[0]) != REGNO (operands[2])
  30635. + && rtx_equal_p (operands[2], XEXP (operands[1], 0))"
  30636. + [(const_int 0)]
  30637. + {
  30638. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30639. + rtx post_modify = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30640. + rtx mem = gen_rtx_MEM (<MODE>mode, post_modify);
  30641. + rtx zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  30642. + rtx insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  30643. +
  30644. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[1]);
  30645. +
  30646. + if (auto_inc_p (post_modify))
  30647. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post_modify, 0), REG_NOTES (insn));
  30648. + DONE;
  30649. + }
  30650. +)
  30651. +
  30652. +(define_peephole2
  30653. + [(set (match_operand:HI 0 "metag_register_op" "")
  30654. + (zero_extend:HI
  30655. + (match_operand:EXTHI 1 "memory_operand" "")))
  30656. + (set (match_operand:SI 2 "metag_register_op" "")
  30657. + (plus:SI (match_dup 2)
  30658. + (match_operand:SI 3 "metag_offset6_<mode>" "")))]
  30659. + "REGNO (operands[0]) != REGNO (operands[2])
  30660. + && rtx_equal_p (operands[2], XEXP (operands[1], 0))"
  30661. + [(const_int 0)]
  30662. + {
  30663. + rtx post, mem, zextend, insn;
  30664. +
  30665. + if (INTVAL (operands[3]) == GET_MODE_SIZE (<MODE>mode))
  30666. + post = gen_rtx_POST_INC (SImode, operands[2]);
  30667. + else if (INTVAL (operands[3]) == -GET_MODE_SIZE (<MODE>mode))
  30668. + post = gen_rtx_POST_DEC (SImode, operands[2]);
  30669. + else
  30670. + {
  30671. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[3]);
  30672. +
  30673. + post = gen_rtx_POST_MODIFY (SImode, operands[2], plus);
  30674. + }
  30675. +
  30676. + mem = gen_rtx_MEM (<MODE>mode, post);
  30677. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[1]);
  30678. + zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  30679. + insn = emit_insn (gen_rtx_SET (VOIDmode, operands[0], zextend));
  30680. +
  30681. + if (auto_inc_p (post))
  30682. + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, XEXP (post, 0), REG_NOTES (insn));
  30683. + DONE;
  30684. + }
  30685. +)
  30686. +
  30687. +;; ====POST_INC
  30688. +
  30689. +;; ----------------------------------------------------------------------------
  30690. +;; Fixup some obvious reg alloc losage for loads
  30691. +;; ----------------------------------------------------------------------------
  30692. +
  30693. +(define_peephole2
  30694. + [(set (match_operand:MEMOP 0 "metag_register_op" "")
  30695. + (match_operand:<MODE> 1 "memory_operand" ""))
  30696. + (set (match_operand:<MODE> 2 "metag_reg_nofloat_op" "")
  30697. + (match_dup 0))]
  30698. + "peep2_reg_dead_p (2, operands[0])"
  30699. + [(set (match_dup 2)
  30700. + (match_dup 1))]
  30701. + "")
  30702. +
  30703. +;; ----------------------------------------------------------------------------
  30704. +
  30705. +;; misc peephole2s
  30706. +
  30707. +(define_peephole2
  30708. + [(set (match_operand:SI 0 "metag_register_op" "")
  30709. + (match_operand:SI 1 "metag_datareg_op" ""))
  30710. + (set (reg:CCANY CC_REG)
  30711. + (compare:<MODE>
  30712. + (match_dup 0)
  30713. + (match_operand:SI 2 "metag_int_operand" "")))]
  30714. + "peep2_reg_dead_p (2, operands[0])"
  30715. + [(set (reg:<MODE> CC_REG)
  30716. + (compare:<MODE>
  30717. + (match_dup 1)
  30718. + (match_dup 2)))]
  30719. + "")
  30720. +
  30721. +;;
  30722. +(define_peephole2
  30723. + [(set (match_operand:SI 0 "metag_register_op" "")
  30724. + (match_operand:SI 1 "metag_datareg_op" ""))
  30725. + (set (reg:CCANY CC_REG)
  30726. + (compare:<MODE>
  30727. + (match_dup 0)
  30728. + (match_operand:SI 2 "metag_datareg_op" "")))]
  30729. + "peep2_reg_dead_p (2, operands[0])
  30730. + && metag_same_regclass_p (operands[0], operands[1])
  30731. + && !rtx_equal_p (operands[0], operands[2])"
  30732. + [(set (reg:<MODE> CC_REG)
  30733. + (compare:<MODE>
  30734. + (match_dup 1)
  30735. + (match_dup 2)))]
  30736. + "")
  30737. +
  30738. +;; SImode swap
  30739. +(define_peephole2
  30740. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  30741. + (match_operand:SI 1 "metag_reg_nofloat_op" ""))
  30742. + (set (match_dup 1)
  30743. + (match_operand:SI 2 "metag_reg_nofloat_op" ""))
  30744. + (set (match_dup 2)
  30745. + (match_dup 0))]
  30746. + "!metag_same_regclass_p (operands[1], operands[2])
  30747. + && peep2_reg_dead_p (3, operands[0])"
  30748. + [(parallel
  30749. + [(set (match_dup 1)
  30750. + (match_dup 2))
  30751. + (set (match_dup 2)
  30752. + (match_dup 1))])]
  30753. + "")
  30754. +
  30755. +;; DImode swap
  30756. +(define_peephole2
  30757. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  30758. + (match_operand:SI 1 "metag_reg_nofloat_op" ""))
  30759. + (set (match_operand:SI 2 "metag_reg_nofloat_op" "")
  30760. + (match_operand:SI 3 "metag_reg_nofloat_op" ""))
  30761. + (set (match_dup 1)
  30762. + (match_operand:SI 4 "metag_reg_nofloat_op" ""))
  30763. + (set (match_dup 3)
  30764. + (match_operand:SI 5 "metag_reg_nofloat_op" ""))
  30765. + (set (match_dup 4)
  30766. + (match_dup 0))
  30767. + (set (match_dup 5)
  30768. + (match_dup 2))]
  30769. + " !metag_same_regclass_p (operands[3], operands[4])
  30770. + && !metag_same_regclass_p (operands[1], operands[5])
  30771. + && !metag_same_regclass_p (operands[4], operands[5])
  30772. + && !metag_same_regclass_p (operands[1], operands[3])
  30773. + && peep2_reg_dead_p (5, operands[0])
  30774. + && peep2_reg_dead_p (6, operands[2])"
  30775. + [(parallel
  30776. + [(set (match_dup 3)
  30777. + (match_dup 4))
  30778. + (set (match_dup 4)
  30779. + (match_dup 3))])
  30780. + (parallel
  30781. + [(set (match_dup 1)
  30782. + (match_dup 5))
  30783. + (set (match_dup 5)
  30784. + (match_dup 1))])
  30785. + (parallel
  30786. + [(set (match_dup 4)
  30787. + (match_dup 5))
  30788. + (set (match_dup 5)
  30789. + (match_dup 4))])
  30790. + (parallel
  30791. + [(set (match_dup 1)
  30792. + (match_dup 3))
  30793. + (set (match_dup 3)
  30794. + (match_dup 1))])]
  30795. + "")
  30796. +
  30797. +(define_peephole2
  30798. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  30799. + (match_operand:SI 1 "metag_reg_nofloat_op" ""))
  30800. + (set (match_dup 1)
  30801. + (match_operand:SI 2 "metag_reg_nofloat_op" ""))
  30802. + (set (match_dup 2)
  30803. + (match_dup 0))]
  30804. + "!metag_same_regclass_p (operands[1], operands[2])"
  30805. + [(set (match_dup 0)
  30806. + (match_dup 1))
  30807. + (parallel
  30808. + [(set (match_dup 1)
  30809. + (match_dup 2))
  30810. + (set (match_dup 2)
  30811. + (match_dup 1))])]
  30812. + "")
  30813. +
  30814. +;; set full condition flags during move, flags from source value
  30815. +(define_peephole2
  30816. + [(set (match_operand:SI 0 "metag_register_op" "")
  30817. + (match_operand:SI 1 "metag_datareg_op" ""))
  30818. + (set (reg:CCANY CC_REG)
  30819. + (compare:<MODE>
  30820. + (match_dup 1)
  30821. + (const_int 0)))]
  30822. + "REGNO (operands[0]) <= LAST_ADDR_REG"
  30823. + [(parallel
  30824. + [(set (reg:<MODE> CC_REG)
  30825. + (compare:<MODE>
  30826. + (match_dup 1)
  30827. + (const_int 0)))
  30828. + (set (match_dup 0)
  30829. + (match_dup 1))])]
  30830. + "")
  30831. +
  30832. +;; set full condition flags during move, flags from dest value
  30833. +(define_peephole2
  30834. + [(set (match_operand:SI 0 "metag_register_op" "")
  30835. + (match_operand:SI 1 "metag_datareg_op" ""))
  30836. + (set (reg:CCANY CC_REG)
  30837. + (compare:<MODE>
  30838. + (match_dup 0)
  30839. + (const_int 0)))]
  30840. + "REGNO (operands[0]) <= LAST_ADDR_REG"
  30841. + [(parallel
  30842. + [(set (reg:<MODE> CC_REG)
  30843. + (compare:<MODE>
  30844. + (match_dup 1)
  30845. + (const_int 0)))
  30846. + (set (match_dup 0)
  30847. + (match_dup 1))])]
  30848. + "")
  30849. +
  30850. +;; set condition flags during sign extension of a hi value
  30851. +(define_peephole2
  30852. + [(set (match_operand:SI 0 "metag_register_op" "")
  30853. + (sign_extend:SI (match_operand:HI 1 "metag_register_op" "")))
  30854. + (set (reg:CCZNC CC_REG)
  30855. + (compare:<MODE>
  30856. + (match_dup 0)
  30857. + (const_int 0)))]
  30858. + ""
  30859. + [(parallel
  30860. + [(set (reg:<MODE> CC_REG)
  30861. + (compare:<MODE>
  30862. + (sign_extend:SI (match_dup 1))
  30863. + (const_int 0)))
  30864. + (set (match_dup 0)
  30865. + (sign_extend:SI (match_dup 1)))])]
  30866. + "")
  30867. +
  30868. +;; set condition flags during sign extension of a qi value
  30869. +(define_peephole2
  30870. + [(set (match_operand:SI 0 "metag_register_op" "")
  30871. + (sign_extend:SI (match_operand:QI 1 "metag_register_op" "")))
  30872. + (set (reg:CCZNC CC_REG)
  30873. + (compare:<MODE>
  30874. + (match_dup 0)
  30875. + (const_int 0)))]
  30876. + ""
  30877. + [(parallel
  30878. + [(set (reg:<MODE> CC_REG)
  30879. + (compare:<MODE>
  30880. + (sign_extend:SI (match_dup 1))
  30881. + (const_int 0)))
  30882. + (set (match_dup 0)
  30883. + (sign_extend:SI (match_dup 1)))])]
  30884. + "")
  30885. +
  30886. +;; eliminate redundant move
  30887. +(define_peephole2
  30888. + [(set (match_operand:MEMOP 0 "metag_register_op" "")
  30889. + (match_operand:<MODE> 1 "metag_regorint_op" ""))
  30890. + (set (match_operand:<MODE> 2 "metag_register_op" "")
  30891. + (match_dup 0))]
  30892. + "peep2_reg_dead_p (2, operands[0])
  30893. + && metag_move_valid_p (operands[2], operands[1])"
  30894. + [(set (match_dup 2)
  30895. + (match_dup 1))]
  30896. + "")
  30897. +
  30898. +;;
  30899. +(define_peephole2
  30900. + [(set (match_operand:SI 0 "metag_register_op" "")
  30901. + (plus:SI (match_operand:SI 1 "metag_datareg_op" "")
  30902. + (match_operand:SI 2 "metag_register_op" "")))
  30903. + (set (reg:CCZNC CC_REG)
  30904. + (compare:<MODE>
  30905. + (match_dup 0)
  30906. + (const_int 0)))]
  30907. + ""
  30908. + [(parallel
  30909. + [(set (reg:<MODE> CC_REG)
  30910. + (compare:<MODE>
  30911. + (plus:SI (match_dup 1)
  30912. + (match_dup 2))
  30913. + (const_int 0)))
  30914. + (set (match_dup 0)
  30915. + (plus:SI (match_dup 1)
  30916. + (match_dup 2)))])]
  30917. + "")
  30918. +
  30919. +;;
  30920. +(define_peephole2
  30921. + [(set (match_operand:SI 0 "metag_register_op" "")
  30922. + (minus:SI (match_operand:SI 1 "metag_datareg_op" "")
  30923. + (match_operand:SI 2 "metag_register_op" "")))
  30924. + (set (reg:CCZNC CC_REG)
  30925. + (compare:<MODE>
  30926. + (match_dup 0)
  30927. + (const_int 0)))]
  30928. + ""
  30929. + [(parallel
  30930. + [(set (reg:<MODE> CC_REG)
  30931. + (compare:<MODE>
  30932. + (minus:SI (match_dup 1)
  30933. + (match_dup 2))
  30934. + (const_int 0)))
  30935. + (set (match_dup 0)
  30936. + (minus:SI (match_dup 1)
  30937. + (match_dup 2)))])]
  30938. + "")
  30939. +;;
  30940. +(define_peephole2
  30941. + [(set (match_operand:SI 0 "metag_register_op" "")
  30942. + (plus:SI (match_operand:SI 1 "metag_datareg_op" "")
  30943. + (match_operand:SI 2 "metag_smallint_op" "")))
  30944. + (set (reg:CCZNC CC_REG)
  30945. + (compare:<MODE>
  30946. + (match_dup 0)
  30947. + (const_int 0)))]
  30948. + ""
  30949. + [(parallel
  30950. + [(set (reg:<MODE> CC_REG)
  30951. + (compare:<MODE>
  30952. + (plus:SI (match_dup 1)
  30953. + (match_dup 2))
  30954. + (const_int 0)))
  30955. + (set (match_dup 0)
  30956. + (plus:SI (match_dup 1)
  30957. + (match_dup 2)))])]
  30958. + "")
  30959. +
  30960. +(define_peephole2
  30961. + [(set (match_operand:SI 0 "metag_register_op" "")
  30962. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))
  30963. + (set (match_dup 0)
  30964. + (lo_sum:SI (match_dup 0)
  30965. + (match_dup 1)))
  30966. + (set (match_dup 0)
  30967. + (plus:SI (match_dup 0)
  30968. + (match_operand:SI 2 "const_int_operand" "")))]
  30969. + "!METAG_FLAG_PIC"
  30970. + [(set (match_dup 0)
  30971. + (high:SI (match_dup 3)))
  30972. + (set (match_dup 0)
  30973. + (lo_sum:SI (match_dup 0)
  30974. + (match_dup 3)))]
  30975. + "operands[3] = gen_rtx_CONST (SImode,
  30976. + gen_rtx_PLUS (SImode,
  30977. + operands[1],
  30978. + operands[2]));")
  30979. +
  30980. +(define_peephole2
  30981. + [(set (match_operand:SI 0 "metag_register_op" "")
  30982. + (high:SI (const:SI (plus:SI (match_operand:SI 1 "metag_symglobal_op" "")
  30983. + (match_operand:SI 2 "const_int_operand" "")))))
  30984. + (set (match_dup 0)
  30985. + (lo_sum:SI (match_dup 0)
  30986. + (const:SI (plus:SI (match_dup 1)
  30987. + (match_dup 2)))))
  30988. + (set (match_dup 0)
  30989. + (plus:SI (match_dup 0)
  30990. + (match_operand:SI 3 "const_int_operand" "")))]
  30991. + "!METAG_FLAG_PIC"
  30992. + [(set (match_dup 0)
  30993. + (high:SI (match_dup 4)))
  30994. + (set (match_dup 0)
  30995. + (lo_sum:SI (match_dup 0)
  30996. + (match_dup 4)))]
  30997. + "operands[4] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]));
  30998. + operands[4] = gen_rtx_CONST (SImode,
  30999. + gen_rtx_PLUS (SImode,
  31000. + operands[1],
  31001. + operands[4]));")
  31002. +
  31003. +;; Combine a load/store with pre address arithmetic into
  31004. +;; a load/store with base + offset addressing.
  31005. +;; Where the intermidiate address register dies in the load/store
  31006. +
  31007. +;; loads
  31008. +(define_peephole2
  31009. + [(set (match_operand:SI 0 "metag_register_op" "")
  31010. + (plus:SI (match_operand:SI 1 "metag_register_op" "")
  31011. + (match_operand:SI 2 "metag_offset6_<mode>" "")))
  31012. + (set (match_operand:<MODE> 3 "metag_register_op" "")
  31013. + (match_operand:MEMOP 4 "memory_operand" ""))]
  31014. + "peep2_reg_dead_p (2, operands[0])
  31015. + && rtx_equal_p (operands[0], XEXP (operands[4], 0))"
  31016. + [(const_int 0)]
  31017. + {
  31018. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31019. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31020. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31021. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], mem));
  31022. +
  31023. + DONE;
  31024. + }
  31025. +)
  31026. +
  31027. +(define_peephole2
  31028. + [(set (match_operand:SI 0 "metag_register_op" "")
  31029. + (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "")
  31030. + (match_operand:SI 2 "metag_offset12_<mode>" "")))
  31031. + (set (match_operand:<MODE> 3 "metag_reg_nofloat_op" "")
  31032. + (match_operand:MEMOP 4 "memory_operand" ""))]
  31033. + "peep2_reg_dead_p (2, operands[0])
  31034. + && rtx_equal_p (operands[0], XEXP (operands[4], 0))"
  31035. + [(const_int 0)]
  31036. + {
  31037. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31038. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31039. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31040. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], mem));
  31041. +
  31042. + DONE;
  31043. + }
  31044. +)
  31045. +
  31046. +;; load zero_extend HI
  31047. +(define_peephole2
  31048. + [(set (match_operand:SI 0 "metag_register_op" "")
  31049. + (plus:SI (match_operand:SI 1 "metag_register_op" "")
  31050. + (match_operand:SI 2 "metag_offset6_<mode>" "")))
  31051. + (set (match_operand:HI 3 "metag_register_op" "")
  31052. + (zero_extend:HI
  31053. + (match_operand:EXTHI 4 "memory_operand" "")))]
  31054. + "peep2_reg_dead_p (2, operands[0])
  31055. + && rtx_equal_p (operands[0], XEXP (operands[4], 0))"
  31056. + [(const_int 0)]
  31057. + {
  31058. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31059. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31060. + rtx zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  31061. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31062. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], zextend));
  31063. +
  31064. + DONE;
  31065. + }
  31066. +)
  31067. +
  31068. +(define_peephole2
  31069. + [(set (match_operand:SI 0 "metag_register_op" "")
  31070. + (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "")
  31071. + (match_operand:SI 2 "metag_offset12_<mode>" "")))
  31072. + (set (match_operand:HI 3 "metag_reg_nofloat_op" "")
  31073. + (zero_extend:HI
  31074. + (match_operand:EXTHI 4 "memory_operand" "")))]
  31075. + "peep2_reg_dead_p (2, operands[0])
  31076. + && rtx_equal_p (operands[0], XEXP (operands[4], 0))"
  31077. + [(const_int 0)]
  31078. + {
  31079. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31080. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31081. + rtx zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  31082. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31083. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], zextend));
  31084. +
  31085. + DONE;
  31086. + }
  31087. +)
  31088. +
  31089. +;; load zero_extend SI
  31090. +(define_peephole2
  31091. + [(set (match_operand:SI 0 "metag_register_op" "")
  31092. + (plus:SI (match_operand:SI 1 "metag_register_op" "")
  31093. + (match_operand:SI 2 "metag_offset6_<mode>" "")))
  31094. + (set (match_operand:SI 3 "metag_register_op" "")
  31095. + (zero_extend:SI
  31096. + (match_operand:EXTSI 4 "memory_operand" "")))]
  31097. + "peep2_reg_dead_p (2, operands[0])
  31098. + && rtx_equal_p (operands[0], XEXP (operands[4], 0))"
  31099. + [(const_int 0)]
  31100. + {
  31101. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31102. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31103. + rtx zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  31104. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31105. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], zextend));
  31106. +
  31107. + DONE;
  31108. + }
  31109. +)
  31110. +
  31111. +(define_peephole2
  31112. + [(set (match_operand:SI 0 "metag_register_op" "")
  31113. + (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "")
  31114. + (match_operand:SI 2 "metag_offset12_<mode>" "")))
  31115. + (set (match_operand:SI 3 "metag_reg_nofloat_op" "")
  31116. + (zero_extend:SI
  31117. + (match_operand:EXTSI 4 "memory_operand" "")))]
  31118. + "peep2_reg_dead_p (2, operands[0])
  31119. + && rtx_equal_p (operands[0], XEXP (operands[4], 0))"
  31120. + [(const_int 0)]
  31121. + {
  31122. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31123. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31124. + rtx zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  31125. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31126. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], zextend));
  31127. +
  31128. + DONE;
  31129. + }
  31130. +)
  31131. +
  31132. +;; store QI/HI/SI
  31133. +(define_peephole2
  31134. + [(set (match_operand:SI 0 "metag_register_op" "")
  31135. + (plus:SI (match_operand:SI 1 "metag_register_op" "")
  31136. + (match_operand:SI 2 "metag_offset6_<mode>" "")))
  31137. + (set (match_operand:MEMOP 3 "memory_operand" "")
  31138. + (match_operand:<MODE> 4 "metag_register_op" ""))]
  31139. + "peep2_reg_dead_p (2, operands[0])
  31140. + && REGNO (operands[0]) != REGNO (operands[4])
  31141. + && rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  31142. + [(const_int 0)]
  31143. + {
  31144. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31145. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31146. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  31147. + emit_insn (gen_rtx_SET (VOIDmode, mem, operands[4]));
  31148. +
  31149. + DONE;
  31150. + }
  31151. +)
  31152. +
  31153. +(define_peephole2
  31154. + [(set (match_operand:SI 0 "metag_register_op" "")
  31155. + (plus:SI (match_operand:SI 1 "metag_reg12bit_op" "")
  31156. + (match_operand:SI 2 "metag_offset12_<mode>" "")))
  31157. + (set (match_operand:MEMOP 3 "memory_operand" "")
  31158. + (match_operand:<MODE> 4 "metag_reg_nofloat_op" ""))]
  31159. + "peep2_reg_dead_p (2, operands[0])
  31160. + && REGNO (operands[0]) != REGNO (operands[4])
  31161. + && rtx_equal_p (operands[0], XEXP (operands[3], 0))"
  31162. + [(const_int 0)]
  31163. + {
  31164. + rtx plus = gen_rtx_PLUS (SImode, operands[1], operands[2]);
  31165. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31166. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  31167. + emit_insn (gen_rtx_SET (VOIDmode, mem, operands[4]));
  31168. +
  31169. + DONE;
  31170. + }
  31171. +)
  31172. +
  31173. +;; QI/HI->SI zero_extend load removing unneccessary temporary
  31174. +
  31175. +(define_peephole2
  31176. + [(set (match_operand:SI 0 "metag_register_op" "")
  31177. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))
  31178. + (set (match_dup 0)
  31179. + (lo_sum:SI (match_dup 0)
  31180. + (match_dup 1)))
  31181. + (set (match_operand:SI 2 "metag_register_op" "")
  31182. + (plus:SI (match_dup 2)
  31183. + (match_dup 0)))
  31184. + (set (match_operand:SI 3 "metag_register_op" "")
  31185. + (zero_extend:SI
  31186. + (match_operand:EXTSI 4 "memory_operand" "")))]
  31187. + "!METAG_FLAG_PIC
  31188. + && peep2_reg_dead_p (4, operands[2])
  31189. + && peep2_reg_dead_p (3, operands[0])
  31190. + && GET_MODE (XEXP (operands[4], 0)) == SImode
  31191. + && GET_CODE (XEXP (operands[4], 0)) == PLUS
  31192. + && rtx_equal_p (operands[2], XEXP (XEXP (operands[4], 0), 0))
  31193. + && const_int_operand (XEXP (XEXP (operands[4], 0), 1), SImode)
  31194. + && metag_regno_same_unit_p (REGNO (operands[2]), REGNO (operands[0]))"
  31195. +
  31196. + [(const_int 0)]
  31197. + {
  31198. + rtx plus, mem, zextend;
  31199. + operands[5] = XEXP (XEXP (operands[4], 0), 1);
  31200. + operands[6] = gen_rtx_CONST (SImode,
  31201. + gen_rtx_PLUS (SImode,
  31202. + operands[1],
  31203. + operands[5]));
  31204. +
  31205. + emit_insn (gen_rtx_SET (VOIDmode,
  31206. + operands[0],
  31207. + gen_rtx_HIGH (SImode,
  31208. + operands[6])));
  31209. +
  31210. + emit_insn (gen_rtx_SET (VOIDmode,
  31211. + operands[0],
  31212. + gen_rtx_LO_SUM (SImode,
  31213. + operands[0],
  31214. + operands[6])));
  31215. +
  31216. + plus = gen_rtx_PLUS (SImode, operands[2], operands[0]);
  31217. + mem = gen_rtx_MEM (<MODE>mode, plus);
  31218. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31219. + zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  31220. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], zextend));
  31221. + DONE;
  31222. + }
  31223. +)
  31224. +
  31225. +;; QI->HI zero_extend load removing unneccessary temporary
  31226. +
  31227. +(define_peephole2
  31228. + [(set (match_operand:SI 0 "metag_register_op" "")
  31229. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))
  31230. + (set (match_dup 0)
  31231. + (lo_sum:SI (match_dup 0)
  31232. + (match_dup 1)))
  31233. + (set (match_operand:SI 2 "metag_register_op" "")
  31234. + (plus:SI (match_dup 2)
  31235. + (match_dup 0)))
  31236. + (set (match_operand:HI 3 "metag_register_op" "")
  31237. + (zero_extend:HI
  31238. + (match_operand:EXTHI 4 "memory_operand" "")))]
  31239. + "!METAG_FLAG_PIC
  31240. + && peep2_reg_dead_p (4, operands[2])
  31241. + && peep2_reg_dead_p (3, operands[0])
  31242. + && GET_MODE (XEXP (operands[4], 0)) == SImode
  31243. + && GET_CODE (XEXP (operands[4], 0)) == PLUS
  31244. + && rtx_equal_p (operands[2], XEXP (XEXP (operands[4], 0), 0))
  31245. + && const_int_operand (XEXP (XEXP (operands[4], 0), 1), SImode)
  31246. + && metag_regno_same_unit_p (REGNO (operands[2]), REGNO (operands[0]))"
  31247. + [(const_int 0)]
  31248. + {
  31249. + rtx plus, mem, zextend;
  31250. + operands[5] = XEXP (XEXP (operands[4], 0), 1);
  31251. + operands[6] = gen_rtx_CONST (SImode,
  31252. + gen_rtx_PLUS (SImode,
  31253. + operands[1],
  31254. + operands[5]));
  31255. +
  31256. + emit_insn (gen_rtx_SET (VOIDmode,
  31257. + operands[0],
  31258. + gen_rtx_HIGH (SImode,
  31259. + operands[6])));
  31260. +
  31261. + emit_insn (gen_rtx_SET (VOIDmode,
  31262. + operands[0],
  31263. + gen_rtx_LO_SUM (SImode,
  31264. + operands[0],
  31265. + operands[6])));
  31266. +
  31267. + plus = gen_rtx_PLUS (SImode, operands[2], operands[0]);
  31268. + mem = gen_rtx_MEM (<MODE>mode, plus);
  31269. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31270. + zextend = gen_rtx_ZERO_EXTEND (HImode, mem);
  31271. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], zextend));
  31272. + DONE;
  31273. + }
  31274. +)
  31275. +
  31276. +;; QI, HI and SI mode load, removing unneccessary temporary
  31277. +
  31278. +(define_peephole2
  31279. + [(set (match_operand:SI 0 "metag_register_op" "")
  31280. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))
  31281. + (set (match_dup 0)
  31282. + (lo_sum:SI (match_dup 0)
  31283. + (match_dup 1)))
  31284. + (set (match_operand:SI 2 "metag_register_op" "")
  31285. + (plus:SI (match_dup 2)
  31286. + (match_dup 0)))
  31287. + (set (match_operand:<MODE> 3 "metag_register_op" "")
  31288. + (match_operand:MEMOP 4 "memory_operand" ""))]
  31289. + "!METAG_FLAG_PIC
  31290. + && peep2_reg_dead_p (4, operands[2])
  31291. + && peep2_reg_dead_p (3, operands[0])
  31292. + && GET_MODE (XEXP (operands[4], 0)) == SImode
  31293. + && GET_CODE (XEXP (operands[4], 0)) == PLUS
  31294. + && rtx_equal_p (operands[2], XEXP (XEXP (operands[4], 0), 0))
  31295. + && const_int_operand (XEXP (XEXP (operands[4], 0), 1), SImode)
  31296. + && metag_regno_same_unit_p (REGNO (operands[2]), REGNO (operands[0]))"
  31297. + [(const_int 0)]
  31298. + {
  31299. + rtx plus, mem;
  31300. + operands[5] = XEXP (XEXP (operands[4], 0), 1);
  31301. + operands[6] = gen_rtx_CONST (SImode,
  31302. + gen_rtx_PLUS (SImode,
  31303. + operands[1],
  31304. + operands[5]));
  31305. +
  31306. + emit_insn (gen_rtx_SET (VOIDmode,
  31307. + operands[0],
  31308. + gen_rtx_HIGH (SImode,
  31309. + operands[6])));
  31310. +
  31311. + emit_insn (gen_rtx_SET (VOIDmode,
  31312. + operands[0],
  31313. + gen_rtx_LO_SUM (SImode,
  31314. + operands[0],
  31315. + operands[6])));
  31316. +
  31317. + plus = gen_rtx_PLUS (SImode, operands[2], operands[0]);
  31318. + mem = gen_rtx_MEM (<MODE>mode, plus);
  31319. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31320. + emit_insn (gen_rtx_SET (VOIDmode, operands[3], mem));
  31321. + DONE;
  31322. + }
  31323. +)
  31324. +
  31325. +;; QI/HI->SI zero_extend when result register same as temporary address register
  31326. +
  31327. +(define_peephole2
  31328. + [(set (match_operand:SI 0 "metag_register_op" "")
  31329. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))
  31330. + (set (match_dup 0)
  31331. + (lo_sum:SI (match_dup 0)
  31332. + (match_dup 1)))
  31333. + (set (match_operand:SI 2 "metag_register_op" "")
  31334. + (plus:SI (match_dup 2)
  31335. + (match_dup 0)))
  31336. + (set (match_dup 2)
  31337. + (zero_extend:SI
  31338. + (match_operand:EXTSI 3 "memory_operand" "")))]
  31339. + "!METAG_FLAG_PIC
  31340. + && peep2_reg_dead_p (3, operands[0])
  31341. + && GET_MODE (XEXP (operands[3], 0)) == SImode
  31342. + && GET_CODE (XEXP (operands[3], 0)) == PLUS
  31343. + && rtx_equal_p (operands[2], XEXP (XEXP (operands[3], 0), 0))
  31344. + && const_int_operand (XEXP (XEXP (operands[3], 0), 1), SImode)
  31345. + && metag_regno_same_unit_p (REGNO (operands[2]), REGNO (operands[0]))"
  31346. + [(const_int 0)]
  31347. + {
  31348. + rtx plus, mem, zextend;
  31349. + operands[4] = XEXP (XEXP (operands[3], 0), 1);
  31350. + operands[5] = gen_rtx_CONST (SImode,
  31351. + gen_rtx_PLUS (SImode,
  31352. + operands[1],
  31353. + operands[4]));
  31354. +
  31355. + emit_insn (gen_rtx_SET (VOIDmode,
  31356. + operands[0],
  31357. + gen_rtx_HIGH (SImode,
  31358. + operands[5])));
  31359. +
  31360. + emit_insn (gen_rtx_SET (VOIDmode,
  31361. + operands[0],
  31362. + gen_rtx_LO_SUM (SImode,
  31363. + operands[0],
  31364. + operands[5])));
  31365. +
  31366. + plus = gen_rtx_PLUS (SImode, operands[2], operands[0]);
  31367. + mem = gen_rtx_MEM (<MODE>mode, plus);
  31368. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  31369. + zextend = gen_rtx_ZERO_EXTEND (SImode, mem);
  31370. + emit_insn (gen_rtx_SET (VOIDmode, operands[2], zextend));
  31371. + DONE;
  31372. + }
  31373. +)
  31374. +
  31375. +;; result register same as temporary address.
  31376. +
  31377. +(define_peephole2
  31378. + [(set (match_operand:SI 0 "metag_register_op" "")
  31379. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))
  31380. + (set (match_dup 0)
  31381. + (lo_sum:SI (match_dup 0)
  31382. + (match_dup 1)))
  31383. + (set (match_operand:SI 2 "metag_register_op" "")
  31384. + (plus:SI (match_dup 2)
  31385. + (match_dup 0)))
  31386. + (set (match_operand:<MODE> 3 "metag_register_op" "")
  31387. + (match_operand:MEMOP 4 "memory_operand" ""))]
  31388. +
  31389. + "!METAG_FLAG_PIC
  31390. + && peep2_reg_dead_p (3, operands[0])
  31391. + && REGNO (operands[3]) == REGNO (operands[2])
  31392. + && GET_MODE (XEXP (operands[4], 0)) == SImode
  31393. + && GET_CODE (XEXP (operands[4], 0)) == PLUS
  31394. + && rtx_equal_p (operands[2], XEXP (XEXP (operands[4], 0), 0))
  31395. + && const_int_operand (XEXP (XEXP (operands[4], 0), 1), SImode)
  31396. + && metag_regno_same_unit_p (REGNO (operands[2]), REGNO (operands[0]))"
  31397. + [(const_int 0)]
  31398. + {
  31399. + rtx plus, mem;
  31400. + operands[5] = XEXP (XEXP (operands[4], 0), 1);
  31401. + operands[6] = gen_rtx_CONST (SImode,
  31402. + gen_rtx_PLUS (SImode,
  31403. + operands[1],
  31404. + operands[5]));
  31405. + operands[7] = gen_rtx_REG (<MODE>mode, REGNO (operands[2]));
  31406. +
  31407. + emit_insn (gen_rtx_SET (VOIDmode,
  31408. + operands[0],
  31409. + gen_rtx_HIGH (SImode,
  31410. + operands[6])));
  31411. +
  31412. + emit_insn (gen_rtx_SET (VOIDmode,
  31413. + operands[0],
  31414. + gen_rtx_LO_SUM (SImode,
  31415. + operands[0],
  31416. + operands[6])));
  31417. +
  31418. + plus = gen_rtx_PLUS (SImode, operands[2], operands[0]);
  31419. + mem = gen_rtx_MEM (<MODE>mode, plus);
  31420. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[4]);
  31421. + emit_insn (gen_rtx_SET (VOIDmode, operands[7], mem));
  31422. + DONE;
  31423. + }
  31424. +)
  31425. +
  31426. +;; QI, HI and SI mode store, removing unneccessary temporary
  31427. +
  31428. +(define_peephole2
  31429. + [(set (match_operand:SI 0 "metag_register_op" "")
  31430. + (high:SI (match_operand:SI 1 "metag_symglobal_op" "")))
  31431. + (set (match_dup 0)
  31432. + (lo_sum:SI (match_dup 0)
  31433. + (match_dup 1)))
  31434. + (set (match_operand:SI 2 "metag_register_op" "")
  31435. + (plus:SI (match_dup 2)
  31436. + (match_dup 0)))
  31437. + (set (match_operand:MEMOP 3 "memory_operand" "")
  31438. + (match_operand:<MODE> 4 "metag_register_op" "") )]
  31439. + "!METAG_FLAG_PIC
  31440. + && peep2_reg_dead_p (4, operands[2])
  31441. + && peep2_reg_dead_p (3, operands[0])
  31442. + && GET_MODE (XEXP (operands[3], 0)) == SImode
  31443. + && GET_CODE (XEXP (operands[3], 0)) == PLUS
  31444. + && rtx_equal_p (operands[2], XEXP (XEXP (operands[3], 0), 0))
  31445. + && const_int_operand (XEXP (XEXP (operands[3], 0), 1), SImode)
  31446. + && metag_regno_same_unit_p (REGNO (operands[2]), REGNO (operands[0]))
  31447. + && !metag_regno_same_unit_p (REGNO (operands[2]), REGNO (operands[4]))"
  31448. + [(const_int 0)]
  31449. + {
  31450. + operands[5] = XEXP (XEXP (operands[3], 0), 1);
  31451. + operands[6] = gen_rtx_CONST (SImode,
  31452. + gen_rtx_PLUS (SImode,
  31453. + operands[1],
  31454. + operands[5]));
  31455. +
  31456. + emit_insn (gen_rtx_SET (VOIDmode,
  31457. + operands[0],
  31458. + gen_rtx_HIGH (SImode,
  31459. + operands[6])));
  31460. +
  31461. + emit_insn (gen_rtx_SET (VOIDmode,
  31462. + operands[0],
  31463. + gen_rtx_LO_SUM (SImode,
  31464. + operands[0],
  31465. + operands[6])));
  31466. +
  31467. + rtx plus = gen_rtx_PLUS (SImode, operands[2], operands[0]);
  31468. + rtx mem = gen_rtx_MEM (<MODE>mode, plus);
  31469. + MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (operands[3]);
  31470. + emit_insn (gen_rtx_SET (VOIDmode, mem, operands[4]));
  31471. + DONE;
  31472. + }
  31473. +)
  31474. diff -Nur gcc-4.2.4.orig/gcc/config/metag/peephole.md gcc-4.2.4/gcc/config/metag/peephole.md
  31475. --- gcc-4.2.4.orig/gcc/config/metag/peephole.md 1969-12-31 18:00:00.000000000 -0600
  31476. +++ gcc-4.2.4/gcc/config/metag/peephole.md 2015-07-03 18:46:05.773283541 -0500
  31477. @@ -0,0 +1,491 @@
  31478. +;; Machine description for GNU compiler,
  31479. +;; Imagination Technologies Meta version.
  31480. +;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
  31481. +;; Imagination Technologies Ltd
  31482. +
  31483. +;; This file is part of GCC.
  31484. +
  31485. +;; GCC is free software; you can redistribute it and/or modify it under
  31486. +;; the terms of the GNU General Public License as published by the Free
  31487. +;; Software Foundation; either version 3, or (at your option) any later
  31488. +;; version.
  31489. +
  31490. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  31491. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  31492. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  31493. +;; for more details.
  31494. +
  31495. +;; You should have received a copy of the GNU General Public License
  31496. +;; along with GCC; see the file COPYING3. If not see
  31497. +;; <http://www.gnu.org/licenses/>.
  31498. +
  31499. +;;- peephole patterns
  31500. +
  31501. +;; set full condition flags during move, flags from source value
  31502. +(define_peephole
  31503. + [(set (match_operand:SI 0 "metag_register_op" "")
  31504. + (match_operand:SI 1 "metag_datareg_op" ""))
  31505. + (set (reg:<MODE> CC_REG)
  31506. + (compare:CCANY
  31507. + (match_dup 1)
  31508. + (const_int 0)))]
  31509. + "!metag_cond_exec_p ()
  31510. + && REGNO (operands[0]) <= LAST_ADDR_REG
  31511. + && METAG_DATA_REG_P (REGNO (operands[1]))"
  31512. + "SUBS\\t%0, %1, #0\\t\\t%@ (*movs rd 1 OK)"
  31513. + [(set_attr "type" "fast")
  31514. + (set_attr "ccstate" "set")])
  31515. +
  31516. +;; set full condition flags during move, flags from dest value
  31517. +(define_peephole
  31518. + [(set (match_operand:SI 0 "metag_register_op" "")
  31519. + (match_operand:SI 1 "metag_datareg_op" ""))
  31520. + (set (reg:<MODE> CC_REG)
  31521. + (compare:CCANY
  31522. + (match_dup 0)
  31523. + (const_int 0)))]
  31524. + "!metag_cond_exec_p ()
  31525. + && REGNO (operands[0]) <= LAST_ADDR_REG
  31526. + && METAG_DATA_REG_P (REGNO (operands[1]))"
  31527. + "SUBS\\t%0, %1, #0\\t\\t%@ (*movs rd 0 OK)"
  31528. + [(set_attr "type" "fast")
  31529. + (set_attr "ccstate" "set")])
  31530. +
  31531. +;; set condition flags during sign extension of a hi value
  31532. +(define_peephole
  31533. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  31534. + (sign_extend:SI (match_operand:HI 1 "metag_datareg_op" "")))
  31535. + (set (reg:CCZNC CC_REG)
  31536. + (compare:<MODE>
  31537. + (match_dup 0)
  31538. + (const_int 0)))]
  31539. + "!metag_cond_exec_p ()"
  31540. + "XSDSW\\t%0, %1\\t\\t%@ (*exts hisi dd OK)"
  31541. + [(set_attr "type" "fast")
  31542. + (set_attr "ccstate" "set")])
  31543. +
  31544. +;; set condition flags during sign extension of a qi value
  31545. +(define_peephole
  31546. + [(set (match_operand:SI 0 "metag_datareg_op" "")
  31547. + (sign_extend:SI (match_operand:QI 1 "metag_datareg_op" "")))
  31548. + (set (reg:CCZNC CC_REG)
  31549. + (compare:<MODE>
  31550. + (match_dup 0)
  31551. + (const_int 0)))]
  31552. + "!metag_cond_exec_p ()"
  31553. + "XSDSB\\t%0, %1\\t\\t%@ (*exts qisi dd OK)"
  31554. + [(set_attr "type" "fast")
  31555. + (set_attr "ccstate" "set")])
  31556. +
  31557. +;; Detect oppurtunities for post-increments of DI mode stores
  31558. +(define_peephole
  31559. + [(set (mem:DI (match_operand:SI 0 "metag_register_op" ""))
  31560. + (match_operand:DI 1 "metag_register_op" ""))
  31561. + (set (match_dup 0)
  31562. + (plus:SI (match_dup 0)
  31563. + (match_operand:SI 2 "metag_offset6_di" "")))]
  31564. + "TARGET_METAC_1_1 && !metag_cond_exec_p ()"
  31565. + "SETL\\t[%0+%2++], %1, %t1\\t%@ (*store DI post_inc OK)"
  31566. + [(set_attr "type" "fast")])
  31567. +
  31568. +(define_peephole
  31569. + [(set (match_operand:SI 0 "metag_register_op" "")
  31570. + (plus:SI (match_dup 0)
  31571. + (match_operand:SI 2 "metag_offset6_di" "")))
  31572. + (set (mem:DI (match_dup 0))
  31573. + (match_operand:DI 1 "metag_register_op" ""))]
  31574. + "TARGET_METAC_1_1 && !metag_cond_exec_p ()"
  31575. + "SETL\\t[%0++%2], %1, %t1\\t%@ (*store DI pre_inc OK)"
  31576. + [(set_attr "type" "fast")])
  31577. +
  31578. +;; Detect oppurtunities for post-increments of stores - not 1_1
  31579. +(define_peephole
  31580. + [(set (mem:SI (match_operand:SI 0 "metag_register_op" ""))
  31581. + (match_operand:SI 2 "metag_register_op" ""))
  31582. + (set (match_dup 0)
  31583. + (plus:SI (match_dup 0)
  31584. + (match_operand:SI 1 "metag_register_op" "")))]
  31585. + "0 && !metag_cond_exec_p ()
  31586. + && !TARGET_METAC_1_1"
  31587. + "SETD\\t[%0+%1++], %2\\t%@ (*sto si maar OK)"
  31588. + [(set_attr "type" "fast")])
  31589. +
  31590. +(define_peephole
  31591. + [(set (mem:SI (match_operand:SI 0 "metag_register_op" ""))
  31592. + (match_operand:SI 2 "metag_register_op" ""))
  31593. + (set (match_dup 0)
  31594. + (plus:SI (match_dup 0)
  31595. + (match_operand:SI 1 "metag_offset6_si" "")))]
  31596. + "0 && !metag_cond_exec_p ()
  31597. + && !TARGET_METAC_1_1"
  31598. + "SETD\\t[%0+%1++], %2\\t%@ (*sto si miar OK)"
  31599. + [(set_attr "type" "fast")])
  31600. +
  31601. +(define_peephole
  31602. + [(set (mem:HI (match_operand:SI 0 "metag_register_op" ""))
  31603. + (match_operand:HI 2 "metag_register_op" ""))
  31604. + (set (match_dup 0)
  31605. + (plus:SI (match_dup 0)
  31606. + (match_operand:SI 1 "metag_register_op" "")))]
  31607. + "0 && !metag_cond_exec_p ()
  31608. + && !TARGET_METAC_1_1"
  31609. + "SETW\\t[%0+%1++], %2\\t%@ (*sto hi maar OK)"
  31610. + [(set_attr "type" "fast")])
  31611. +
  31612. +(define_peephole
  31613. + [(set (mem:HI (match_operand:SI 0 "metag_register_op" ""))
  31614. + (match_operand:HI 2 "metag_register_op" ""))
  31615. + (set (match_dup 0)
  31616. + (plus:SI (match_dup 0)
  31617. + (match_operand:SI 1 "metag_offset6_hi" "")))]
  31618. + "0 && !metag_cond_exec_p ()
  31619. + && !TARGET_METAC_1_1"
  31620. + "SETW\\t[%0+%1++], %2\\t%@ (*sto hi miar OK)"
  31621. + [(set_attr "type" "fast")])
  31622. +
  31623. +(define_peephole
  31624. + [(set (mem:QI (match_operand:SI 0 "metag_register_op" ""))
  31625. + (match_operand:QI 2 "metag_register_op" ""))
  31626. + (set (match_dup 0)
  31627. + (plus:SI (match_dup 0)
  31628. + (match_operand:SI 1 "metag_register_op" "")))]
  31629. + "0 && !metag_cond_exec_p ()
  31630. + && !TARGET_METAC_1_1"
  31631. + "SETB\\t[%0+%1++], %2\\t%@ (*sto qi maar OK)"
  31632. + [(set_attr "type" "fast")])
  31633. +
  31634. +(define_peephole
  31635. + [(set (mem:QI (match_operand:SI 0 "metag_register_op" ""))
  31636. + (match_operand:QI 2 "metag_register_op" ""))
  31637. + (set (match_dup 0)
  31638. + (plus:SI (match_dup 0)
  31639. + (match_operand:SI 1 "metag_offset6_qi" "")))]
  31640. + "0 && !metag_cond_exec_p ()
  31641. + && !TARGET_METAC_1_1"
  31642. + "SETB\\t[%0+%1++], %2\\t%@ (*sto qi miar OK)"
  31643. + [(set_attr "type" "fast")])
  31644. +
  31645. +;; Detect oppurtunities for post-increments of stores - 1_1
  31646. +(define_peephole
  31647. + [(set (mem:SI (match_operand:SI 0 "metag_register_op" ""))
  31648. + (match_operand:SI 2 "metag_register_op" ""))
  31649. + (set (match_dup 0)
  31650. + (plus:SI (match_dup 0)
  31651. + (match_operand:SI 1 "metag_register_op" "")))]
  31652. + "!metag_cond_exec_p ()
  31653. + && TARGET_METAC_1_1
  31654. + && metag_same_regclass_p (operands[0], operands[1])
  31655. + && !metag_same_regclass_p (operands[0], operands[2])"
  31656. + "SETD\\t[%0+%1++], %2\\t%@ (*sto si maar OK)"
  31657. + [(set_attr "type" "fast")])
  31658. +
  31659. +(define_peephole
  31660. + [(set (mem:SI (match_operand:SI 0 "metag_register_op" ""))
  31661. + (match_operand:SI 2 "metag_register_op" ""))
  31662. + (set (match_dup 0)
  31663. + (plus:SI (match_dup 0)
  31664. + (match_operand:SI 1 "metag_offset6_si" "")))]
  31665. + "!metag_cond_exec_p ()
  31666. + && TARGET_METAC_1_1"
  31667. + "SETD\\t[%0+%1++], %2\\t%@ (*sto si miar OK)"
  31668. + [(set_attr "type" "fast")])
  31669. +
  31670. +(define_peephole
  31671. + [(set (mem:HI (match_operand:SI 0 "metag_register_op" ""))
  31672. + (match_operand:HI 2 "metag_register_op" ""))
  31673. + (set (match_dup 0)
  31674. + (plus:SI (match_dup 0)
  31675. + (match_operand:SI 1 "metag_register_op" "")))]
  31676. + "!metag_cond_exec_p ()
  31677. + && TARGET_METAC_1_1
  31678. + && metag_same_regclass_p (operands[0], operands[1])
  31679. + && !metag_same_regclass_p (operands[0], operands[2])"
  31680. + "SETW\\t[%0+%1++], %2\\t%@ (*sto hi maar OK)"
  31681. + [(set_attr "type" "fast")])
  31682. +
  31683. +(define_peephole
  31684. + [(set (mem:HI (match_operand:SI 0 "metag_register_op" ""))
  31685. + (match_operand:HI 2 "metag_register_op" ""))
  31686. + (set (match_dup 0)
  31687. + (plus:SI (match_dup 0)
  31688. + (match_operand:SI 1 "metag_offset6_hi" "")))]
  31689. + "!metag_cond_exec_p ()
  31690. + && TARGET_METAC_1_1"
  31691. + "SETW\\t[%0+%1++], %2\\t%@ (*sto hi miar OK)"
  31692. + [(set_attr "type" "fast")])
  31693. +
  31694. +(define_peephole
  31695. + [(set (mem:QI (match_operand:SI 0 "metag_register_op" ""))
  31696. + (match_operand:QI 2 "metag_register_op" ""))
  31697. + (set (match_dup 0)
  31698. + (plus:SI (match_dup 0)
  31699. + (match_operand:SI 1 "metag_register_op" "")))]
  31700. + "!metag_cond_exec_p ()
  31701. + && TARGET_METAC_1_1
  31702. + && metag_same_regclass_p (operands[0], operands[1])
  31703. + && !metag_same_regclass_p (operands[0], operands[2])"
  31704. + "SETB\\t[%0+%1++], %2\\t%@ (*sto qi maar OK)"
  31705. + [(set_attr "type" "fast")])
  31706. +
  31707. +(define_peephole
  31708. + [(set (mem:QI (match_operand:SI 0 "metag_register_op" ""))
  31709. + (match_operand:QI 2 "metag_register_op" ""))
  31710. + (set (match_dup 0)
  31711. + (plus:SI (match_dup 0)
  31712. + (match_operand:SI 1 "metag_offset6_qi" "")))]
  31713. + "!metag_cond_exec_p ()
  31714. + && TARGET_METAC_1_1"
  31715. + "SETB\\t[%0+%1++], %2\\t%@ (*sto qi miar OK)"
  31716. + [(set_attr "type" "fast")])
  31717. +
  31718. +;; Detect oppurtunities for post-increments of loads
  31719. +
  31720. +(define_peephole
  31721. + [(set (match_operand:DI 0 "metag_register_op" "")
  31722. + (mem:DI (match_operand:SI 1 "metag_register_op" "")))
  31723. + (set (match_dup 1)
  31724. + (plus:SI (match_dup 1)
  31725. + (match_operand:SI 2 "metag_offset6_di" "")))]
  31726. + "!metag_cond_exec_p ()"
  31727. + "GETL\\t%0, %t0, [%1+%2++]\\t%@ (*load DI post_inc OK)"
  31728. + [(set_attr "type" "load")])
  31729. +
  31730. +(define_peephole
  31731. + [(set (match_operand:SI 1 "metag_register_op" "")
  31732. + (plus:SI (match_dup 1)
  31733. + (match_operand:SI 2 "metag_offset6_di" "")))
  31734. + (set (match_operand:DI 0 "metag_register_op" "")
  31735. + (mem:DI (match_dup 1)))]
  31736. + "!metag_cond_exec_p ()"
  31737. + "GETL\\t%0, %t0, [%1++%2]\\t%@ (*load DI pre_inc OK)"
  31738. + [(set_attr "type" "load")])
  31739. +
  31740. +(define_peephole
  31741. + [(set (match_operand:SI 0 "metag_register_op" "")
  31742. + (mem:SI (match_operand:SI 1 "metag_register_op" "")))
  31743. + (set (match_dup 1)
  31744. + (plus:SI (match_dup 1)
  31745. + (match_operand:SI 2 "metag_register_op" "")))]
  31746. + "!metag_cond_exec_p ()
  31747. + && REGNO (operands[0]) != REGNO (operands[1])
  31748. + && REGNO (operands[0]) != REGNO (operands[2])
  31749. + && metag_same_regclass_p (operands[1], operands[2])"
  31750. + "GETD\\t%0, [%1+%2++]\\t%@ (*lod si rmaa OK)"
  31751. + [(set_attr "type" "load")])
  31752. +
  31753. +(define_peephole
  31754. + [(set (match_operand:SI 0 "metag_register_op" "")
  31755. + (mem:SI (match_operand:SI 1 "metag_register_op" "")))
  31756. + (set (match_dup 1)
  31757. + (plus:SI (match_dup 1)
  31758. + (match_operand:SI 2 "metag_offset6_si" "")))]
  31759. + "!metag_cond_exec_p ()
  31760. + && REGNO (operands[0]) != REGNO (operands[1])"
  31761. + "GETD\\t%0, [%1+%2++]\\t%@ (*lod si rmia OK)"
  31762. + [(set_attr "type" "load")])
  31763. +
  31764. +(define_peephole
  31765. + [(set (match_operand:HI 0 "metag_register_op" "")
  31766. + (mem:HI (match_operand:SI 1 "metag_register_op" "")))
  31767. + (set (match_dup 1)
  31768. + (plus:SI (match_dup 1)
  31769. + (match_operand:SI 2 "metag_register_op" "")))]
  31770. + "!metag_cond_exec_p ()
  31771. + && REGNO (operands[0]) != REGNO (operands[1])
  31772. + && REGNO (operands[0]) != REGNO (operands[2])
  31773. + && metag_same_regclass_p (operands[1], operands[2])"
  31774. + "GETW\\t%0, [%1+%2++]\\t%@ (*lod hi rmaa OK)"
  31775. + [(set_attr "type" "load")])
  31776. +
  31777. +(define_peephole
  31778. + [(set (match_operand:HI 0 "metag_register_op" "")
  31779. + (mem:HI (match_operand:SI 1 "metag_register_op" "")))
  31780. + (set (match_dup 1)
  31781. + (plus:SI (match_dup 1)
  31782. + (match_operand:SI 2 "metag_offset6_hi" "")))]
  31783. + "!metag_cond_exec_p ()
  31784. + && REGNO (operands[0]) != REGNO (operands[1])"
  31785. + "GETW\\t%0, [%1+%2++]\\t%@ (*lod hi rmia OK)"
  31786. + [(set_attr "type" "load")])
  31787. +
  31788. +(define_peephole
  31789. + [(set (match_operand:SI 0 "metag_register_op" "")
  31790. + (zero_extend:SI
  31791. + (mem:HI (match_operand:SI 1 "metag_register_op" ""))))
  31792. + (set (match_dup 1)
  31793. + (plus:SI (match_dup 1)
  31794. + (match_operand:SI 2 "metag_register_op" "")))]
  31795. + "!metag_cond_exec_p ()
  31796. + && REGNO (operands[0]) != REGNO (operands[1])
  31797. + && REGNO (operands[0]) != REGNO (operands[2])
  31798. + && metag_same_regclass_p (operands[1], operands[2])"
  31799. + "GETW\\t%0, [%1+%2++]\\t%@ (*lodz hi rmaa OK)"
  31800. + [(set_attr "type" "load")])
  31801. +
  31802. +(define_peephole
  31803. + [(set (match_operand:SI 0 "metag_register_op" "")
  31804. + (zero_extend:SI
  31805. + (mem:HI (match_operand:SI 1 "metag_register_op" ""))))
  31806. + (set (match_dup 1)
  31807. + (plus:SI (match_dup 1)
  31808. + (match_operand:SI 2 "metag_offset6_hi" "")))]
  31809. + "!metag_cond_exec_p ()
  31810. + && REGNO (operands[0]) != REGNO (operands[1])"
  31811. + "GETW\\t%0, [%1+%2++]\\t%@ (*lodz hi rmia OK)"
  31812. + [(set_attr "type" "load")])
  31813. +
  31814. +(define_peephole
  31815. + [(set (match_operand:QI 0 "metag_register_op" "")
  31816. + (mem:QI (match_operand:SI 1 "metag_register_op" "")))
  31817. + (set (match_dup 1)
  31818. + (plus:SI (match_dup 1)
  31819. + (match_operand:SI 2 "metag_register_op" "")))]
  31820. + "!metag_cond_exec_p ()
  31821. + && REGNO (operands[0]) != REGNO (operands[1])
  31822. + && REGNO (operands[0]) != REGNO (operands[2])
  31823. + && metag_same_regclass_p (operands[1], operands[2])"
  31824. + "GETB\\t%0, [%1+%2++]\\t%@ (*lod qi rmaa OK)"
  31825. + [(set_attr "type" "load")])
  31826. +
  31827. +(define_peephole
  31828. + [(set (match_operand:QI 0 "metag_register_op" "")
  31829. + (mem:QI (match_operand:SI 1 "metag_register_op" "")))
  31830. + (set (match_dup 1)
  31831. + (plus:SI (match_dup 1)
  31832. + (match_operand:SI 2 "metag_offset6_qi" "")))]
  31833. + "!metag_cond_exec_p ()
  31834. + && REGNO (operands[0]) != REGNO (operands[1])"
  31835. + "GETB\\t%0, [%1+%2++]\\t%@ (*lod qi rmia OK)"
  31836. + [(set_attr "type" "load")])
  31837. +
  31838. +(define_peephole
  31839. + [(set (match_operand:SI 0 "metag_register_op" "")
  31840. + (zero_extend:SI
  31841. + (mem:QI (match_operand:SI 1 "metag_register_op" ""))))
  31842. + (set (match_dup 1)
  31843. + (plus:SI (match_dup 1)
  31844. + (match_operand:SI 2 "metag_register_op" "")))]
  31845. + "!metag_cond_exec_p ()
  31846. + && REGNO (operands[0]) != REGNO (operands[1])
  31847. + && REGNO (operands[0]) != REGNO (operands[2])
  31848. + && metag_same_regclass_p (operands[1], operands[2])"
  31849. + "GETB\\t%0, [%1+%2++]\\t%@ (*lodz qi rmaa OK)"
  31850. + [(set_attr "type" "load")])
  31851. +
  31852. +(define_peephole
  31853. + [(set (match_operand:SI 0 "metag_register_op" "")
  31854. + (zero_extend:SI
  31855. + (mem:QI (match_operand:SI 1 "metag_register_op" ""))))
  31856. + (set (match_dup 1)
  31857. + (plus:SI (match_dup 1)
  31858. + (match_operand:SI 2 "metag_offset6_qi" "")))]
  31859. + "!metag_cond_exec_p ()
  31860. + && REGNO (operands[0]) != REGNO (operands[1])"
  31861. + "GETB\\t%0, [%1+%2++]\\t%@ (*lodz qi rmia OK)"
  31862. + [(set_attr "type" "load")])
  31863. +
  31864. +(define_peephole
  31865. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  31866. + (match_operand:SI 1 "metag_reg_nofloat_op" ""))
  31867. + (set (match_dup 1)
  31868. + (match_operand:SI 2 "metag_reg_nofloat_op" ""))
  31869. + (set (match_dup 2)
  31870. + (match_dup 0))]
  31871. + "!metag_same_regclass_p (operands[1], operands[2])
  31872. + && dead_or_set_p (insn, operands[0])"
  31873. + "SWAP%?\\t%1, %2"
  31874. + [(set_attr "type" "fast")
  31875. + (set_attr "cond" "yes")])
  31876. +
  31877. +(define_peephole
  31878. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "")
  31879. + (match_operand:SI 1 "metag_reg_nofloat_op" ""))
  31880. + (set (match_dup 1)
  31881. + (match_operand:SI 2 "metag_reg_nofloat_op" ""))
  31882. + (set (match_dup 2)
  31883. + (match_dup 0))]
  31884. + "!metag_same_regclass_p (operands[1], operands[2])"
  31885. + "SWAP%?\\t%1, %2\\t\;MOV%?\\t%0, %2"
  31886. + [(set_attr "type" "two")
  31887. + (set_attr "cond" "yes")])
  31888. +
  31889. +;; Fixup some obvious reg alloc losage for loads
  31890. +
  31891. +(define_peephole
  31892. + [(set (match_operand:QI 0 "metag_register_op" "")
  31893. + (match_operand:QI 1 "memory_operand" ""))
  31894. + (set (match_operand:QI 2 "metag_reg_nofloat_op" "")
  31895. + (match_dup 0))]
  31896. + "!metag_cond_exec_p ()
  31897. + && dead_or_set_p (insn, operands[0])"
  31898. + "GETB\\t%2, %1"
  31899. + [(set_attr "type" "load")])
  31900. +
  31901. +(define_peephole
  31902. + [(set (match_operand:HI 0 "metag_register_op" "")
  31903. + (match_operand:HI 1 "memory_operand" ""))
  31904. + (set (match_operand:HI 2 "metag_reg_nofloat_op" "")
  31905. + (match_dup 0))]
  31906. + "!metag_cond_exec_p ()
  31907. + && dead_or_set_p (insn, operands[0])"
  31908. + "GETW\\t%2, %1"
  31909. + [(set_attr "type" "load")])
  31910. +
  31911. +(define_peephole
  31912. + [(set (match_operand:SI 0 "metag_register_op" "")
  31913. + (match_operand:SI 1 "memory_operand" ""))
  31914. + (set (match_operand:SI 2 "metag_reg_nofloat_op" "")
  31915. + (match_dup 0))]
  31916. + "!metag_cond_exec_p ()
  31917. + && dead_or_set_p (insn, operands[0])"
  31918. + "GETD\\t%2, %1"
  31919. + [(set_attr "type" "load")])
  31920. +
  31921. +;; misc peepholes
  31922. +(define_peephole
  31923. + [(set (match_operand:SI 0 "metag_register_op" "")
  31924. + (match_operand:SI 1 "metag_datareg_op" ""))
  31925. + (set (reg:<MODE> CC_REG)
  31926. + (compare:CCANY
  31927. + (match_dup 0)
  31928. + (match_operand:SI 2 "metag_int_operand" "")))]
  31929. + "dead_or_set_p (insn, operands[0])"
  31930. + "CMP%?\\t%1, %2"
  31931. + [(set_attr "type" "fast")
  31932. + (set_attr "cond" "yes")])
  31933. +
  31934. +(define_peephole
  31935. + [(set (match_operand:SI 0 "metag_register_op" "")
  31936. + (match_operand:SI 1 "metag_datareg_op" ""))
  31937. + (set (reg:<MODE> CC_REG)
  31938. + (compare:CCANY
  31939. + (match_dup 0)
  31940. + (match_operand:SI 2 "metag_datareg_op" "")))]
  31941. + "dead_or_set_p (insn, operands[0])
  31942. + && metag_same_regclass_p (operands[0], operands[1])"
  31943. + "CMP%?\\t%1, %2"
  31944. + [(set_attr "type" "fast")
  31945. + (set_attr "cond" "yes")])
  31946. +
  31947. +;; This is an EVIL peephole. We should delete it!
  31948. +(define_peephole
  31949. + [(set (match_operand:SI 0 "metag_register_op" "")
  31950. + (match_operand:SI 1 "metag_regorint_op" ""))
  31951. + (set (match_operand:SI 2 "metag_register_op" "")
  31952. + (match_dup 0))]
  31953. + "!metag_cond_exec_p ()
  31954. + && dead_or_set_p (insn, operands[0])
  31955. + && metag_move_valid_p (operands[2], operands[1])"
  31956. + {
  31957. + if ((REG_P (operands[1]) && metag_fpcreg_p (REGNO (operands[1])))
  31958. + || metag_fpcreg_p (REGNO (operands[2])))
  31959. + return "F\\tMOV%?\\t%2, %1";
  31960. + else if (metag_J_operand (operands[1], SImode))
  31961. + return "MOVT%?\\t%2, %1";
  31962. + else
  31963. + return "MOV%?\\t%2, %1";
  31964. + }
  31965. + [(set_attr "type" "fast")
  31966. + (set_attr "cond" "yes")])
  31967. +
  31968. +;; end of file
  31969. diff -Nur gcc-4.2.4.orig/gcc/config/metag/pipeline.md gcc-4.2.4/gcc/config/metag/pipeline.md
  31970. --- gcc-4.2.4.orig/gcc/config/metag/pipeline.md 1969-12-31 18:00:00.000000000 -0600
  31971. +++ gcc-4.2.4/gcc/config/metag/pipeline.md 2015-07-03 18:46:05.773283541 -0500
  31972. @@ -0,0 +1,335 @@
  31973. +;; Machine description for GNU compiler,
  31974. +;; Imagination Technologies Meta version.
  31975. +;; Copyright (C) 2007
  31976. +;; Imagination Technologies Ltd
  31977. +
  31978. +;; This file is part of GCC.
  31979. +
  31980. +;; GCC is free software; you can redistribute it and/or modify it under
  31981. +;; the terms of the GNU General Public License as published by the Free
  31982. +;; Software Foundation; either version 3, or (at your option) any later
  31983. +;; version.
  31984. +
  31985. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  31986. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  31987. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  31988. +;; for more details.
  31989. +
  31990. +;; You should have received a copy of the GNU General Public License
  31991. +;; along with GCC; see the file COPYING3. If not see
  31992. +;; <http://www.gnu.org/licenses/>.
  31993. +
  31994. +(define_automaton "metag")
  31995. +
  31996. +;; The UI and U2U instuctions have different ports to write results
  31997. +(define_cpu_unit "UI_port, U2U_port, load_port" "metag")
  31998. +
  31999. +;; The FPU ports to write results
  32000. +(define_cpu_unit "FP_port1, FP_port2" "metag")
  32001. +
  32002. +;; The FPU pipeline
  32003. +(define_cpu_unit "mas1, mas2, mas3, mas4, mas5, recip1, recip2, recip3" "metag")
  32004. +
  32005. +;; All instructions have to be fetched!
  32006. +(define_cpu_unit "issue" "metag")
  32007. +
  32008. +;; Multi-cycle operation stages
  32009. +(define_cpu_unit "opfetch, execute" "metag")
  32010. +
  32011. +(define_cpu_unit "branch, load, read, mult" "metag")
  32012. +
  32013. +;; Simple case, single cycle operations
  32014. +(define_insn_reservation "UI" 1
  32015. + (eq_attr "type" "fast")
  32016. + "issue, UI_port")
  32017. +
  32018. +;; WORK NEEDED: This needs checking, does a swap need to write each register on separate cycles?
  32019. +(define_insn_reservation "UIswap" 1
  32020. + (eq_attr "type" "swap")
  32021. + "issue, UI_port, UI_port")
  32022. +
  32023. +;; Unknown type insns are user supplied ASM, invalid should not occur and nop is...
  32024. +(define_insn_reservation "UIother" 1
  32025. + (eq_attr "type" "unknown, invalid, nop, block")
  32026. + "issue, UI_port")
  32027. +
  32028. +;; Multiply has 2 cycle latency (only MULD comes through here)
  32029. +(define_insn_reservation "UImult" 2
  32030. + (eq_attr "type" "mult")
  32031. + "issue, mult, UI_port")
  32032. +
  32033. +;; Multiple UI instruction have a complex latency
  32034. +(define_insn_reservation "UIUI" 2
  32035. + (eq_attr "type" "two")
  32036. + "issue, issue + UI_port, UI_port")
  32037. +
  32038. +(define_insn_reservation "UIUIUI" 3
  32039. + (eq_attr "type" "three")
  32040. + "issue, issue + UI_port, issue + UI_port, UI_port")
  32041. +
  32042. +(define_insn_reservation "UIUIUIUI" 4
  32043. + (eq_attr "type" "four")
  32044. + "issue, issue + UI_port, issue + UI_port, issue + UI_port, UI_port")
  32045. +
  32046. +(define_insn_reservation "UIUIUIUIUI" 5
  32047. + (eq_attr "type" "five")
  32048. + "issue, issue + UI_port, issue + UI_port, issue + UI_port, issue + UI_port, UI_port")
  32049. +
  32050. +;; Inter unit operations
  32051. +;; Results are written on 3rd cycle but are ready to be used on 2nd cycle using feedback path
  32052. +(define_insn_reservation "U2U" 2
  32053. + (eq_attr "type" "slow")
  32054. + "issue, opfetch, execute, U2U_port")
  32055. +
  32056. +(define_insn_reservation "U2UU2U" 3
  32057. + (eq_attr "type" "slowslow")
  32058. + "issue, issue + opfetch, opfetch + execute, execute + U2U_port, U2U_port")
  32059. +
  32060. +;; META 2 FPU
  32061. +
  32062. +(define_reservation "FP_ports" "FP_port1 | FP_port2")
  32063. +(define_reservation "mas" "mas1, mas2, mas3, mas4, mas5")
  32064. +(define_reservation "recip" "recip1, recip2, recip3")
  32065. +
  32066. +(define_insn_reservation "FP" 1
  32067. + (eq_attr "type" "FPfast")
  32068. + "issue, FP_ports")
  32069. +
  32070. +(define_insn_reservation "FPmas" 5
  32071. + (eq_attr "type" "FPmas")
  32072. + "issue, mas, FP_ports")
  32073. +
  32074. +(define_insn_reservation "FPrecip" 3
  32075. + (eq_attr "type" "FPrecip")
  32076. + "issue, recip, FP_ports")
  32077. +
  32078. +(define_insn_reservation "FPrecipmas" 8
  32079. + (eq_attr "type" "FPrecipmas")
  32080. + "issue, recip, FP_ports + issue, mas, FP_ports")
  32081. +
  32082. +;; META 2_1
  32083. +(define_insn_reservation "branch_2_1" 5
  32084. + (and (eq_attr "metacore" "metac_2_1")
  32085. + (eq_attr "type" "branch"))
  32086. + "issue, branch*3, UI_port")
  32087. +
  32088. +(define_insn_reservation "load_2_1" 3
  32089. + (and (eq_attr "metacore" "metac_2_1")
  32090. + (eq_attr "type" "load"))
  32091. + "issue, load, load_port")
  32092. +
  32093. +(define_insn_reservation "read_2_1" 3
  32094. + (and (eq_attr "metacore" "metac_2_1")
  32095. + (eq_attr "type" "read"))
  32096. + "issue, read, load_port")
  32097. +
  32098. +;; META 1_2
  32099. +(define_insn_reservation "branch_1_2" 5
  32100. + (and (eq_attr "metacore" "metac_1_2")
  32101. + (eq_attr "type" "branch"))
  32102. + "issue, branch*3, UI_port")
  32103. +
  32104. +(define_insn_reservation "load_1_2" 3
  32105. + (and (eq_attr "metacore" "metac_1_2")
  32106. + (eq_attr "type" "load"))
  32107. + "issue, load, load_port")
  32108. +
  32109. +(define_insn_reservation "read_1_2" 3
  32110. + (and (eq_attr "metacore" "metac_1_2")
  32111. + (eq_attr "type" "read"))
  32112. + "issue, read, load_port")
  32113. +;; META 1_1
  32114. +(define_insn_reservation "branch_1_1" 6
  32115. + (and (eq_attr "metacore" "metac_1_1")
  32116. + (eq_attr "type" "branch"))
  32117. + "issue, branch*4, UI_port")
  32118. +
  32119. +(define_insn_reservation "load_1_1" 8
  32120. + (and (eq_attr "metacore" "metac_1_1")
  32121. + (eq_attr "type" "load"))
  32122. + "issue, load, load_port")
  32123. +
  32124. +(define_insn_reservation "read_1_1" 8
  32125. + (and (eq_attr "metacore" "metac_1_1")
  32126. + (eq_attr "type" "read"))
  32127. + "issue, read, load_port")
  32128. +;; META 1_0
  32129. +(define_insn_reservation "branch_1_0" 7
  32130. + (and (eq_attr "metacore" "metac_1_0")
  32131. + (eq_attr "type" "branch"))
  32132. + "issue, branch*5, UI_port")
  32133. +
  32134. +(define_insn_reservation "load_1_0" 10
  32135. + (and (eq_attr "metacore" "metac_1_0")
  32136. + (eq_attr "type" "load"))
  32137. + "issue, load, load_port")
  32138. +
  32139. +(define_insn_reservation "read_1_0" 9
  32140. + (and (eq_attr "metacore" "metac_1_0")
  32141. + (eq_attr "type" "read"))
  32142. + "issue, read, load_port")
  32143. +
  32144. +;; MGET latencies are complex... The minimum latency is specified here
  32145. +;; and the more complex work is done in metag_sched_adjust_cost
  32146. +
  32147. +;; META 1_2 and 2_1
  32148. +(define_insn_reservation "UI2xld_2_1" 1
  32149. + (and (ior (eq_attr "metacore" "metac_1_2")
  32150. + (eq_attr "metacore" "metac_2_1"))
  32151. + (and (eq_attr "type" "twox")
  32152. + (eq_attr "memaccess" "load")))
  32153. + "issue, issue, load_port, load_port")
  32154. +
  32155. +(define_insn_reservation "UI3xld_2_1" 1
  32156. + (and (ior (eq_attr "metacore" "metac_1_2")
  32157. + (eq_attr "metacore" "metac_2_1"))
  32158. + (and (eq_attr "type" "threex")
  32159. + (eq_attr "memaccess" "load")))
  32160. + "issue, issue, issue + load_port, load_port, load_port")
  32161. +
  32162. +(define_insn_reservation "UI4xld_2_1" 1
  32163. + (and (ior (eq_attr "metacore" "metac_1_2")
  32164. + (eq_attr "metacore" "metac_2_1"))
  32165. + (and (eq_attr "type" "fourx")
  32166. + (eq_attr "memaccess" "load")))
  32167. + "issue, issue, issue + load_port, issue + load_port, load_port, load_port")
  32168. +
  32169. +(define_insn_reservation "UI5xld_2_1" 1
  32170. + (and (ior (eq_attr "metacore" "metac_1_2")
  32171. + (eq_attr "metacore" "metac_2_1"))
  32172. + (and (eq_attr "type" "fivex")
  32173. + (eq_attr "memaccess" "load")))
  32174. + "issue, issue, issue + load_port, issue + load_port, issue + load_port, load_port, load_port")
  32175. +
  32176. +;; META 1_1 - The stalls are not accurately modelled here
  32177. +(define_insn_reservation "UI2xld_1_1" 7
  32178. + (and (eq_attr "metacore" "metac_1_1")
  32179. + (and (eq_attr "type" "twox")
  32180. + (eq_attr "memaccess" "load")))
  32181. + "issue, issue, load*5, load_port, load_port")
  32182. +
  32183. +(define_insn_reservation "UI3xld_1_1" 7
  32184. + (and (eq_attr "metacore" "metac_1_1")
  32185. + (and (eq_attr "type" "threex")
  32186. + (eq_attr "memaccess" "load")))
  32187. + "issue, issue, issue, load *4, load_port, load_port, load_port")
  32188. +
  32189. +(define_insn_reservation "UI4xld_1_1" 7
  32190. + (and (eq_attr "metacore" "metac_1_1")
  32191. + (and (eq_attr "type" "fourx")
  32192. + (eq_attr "memaccess" "load")))
  32193. + "issue, issue, issue, issue, load*3, load_port, load_port, load_port, load_port")
  32194. +
  32195. +(define_insn_reservation "UI5xld_1_1" 7
  32196. + (and (eq_attr "metacore" "metac_1_1")
  32197. + (and (eq_attr "type" "fivex")
  32198. + (eq_attr "memaccess" "load")))
  32199. + "issue, issue, issue, issue, issue, load*2, load_port, load_port, load_port, load_port, load_port")
  32200. +
  32201. +;; META 1_0 - The stalls are not accurately modelled here
  32202. +(define_insn_reservation "UI2xld_1_0" 9
  32203. + (and (eq_attr "metacore" "metac_1_0")
  32204. + (and (eq_attr "type" "twox")
  32205. + (eq_attr "memaccess" "load")))
  32206. + "issue, issue, load*8, load_port, load_port")
  32207. +
  32208. +(define_insn_reservation "UI3xld_1_0" 9
  32209. + (and (eq_attr "metacore" "metac_1_0")
  32210. + (and (eq_attr "type" "threex")
  32211. + (eq_attr "memaccess" "load")))
  32212. + "issue, issue, issue, load*7, load_port, load_port, load_port")
  32213. +
  32214. +(define_insn_reservation "UI4xld_1_0" 9
  32215. + (and (eq_attr "metacore" "metac_1_0")
  32216. + (and (eq_attr "type" "fourx")
  32217. + (eq_attr "memaccess" "load")))
  32218. + "issue, issue, issue, issue, load*6, load_port, load_port, load_port, load_port")
  32219. +
  32220. +(define_insn_reservation "UI5xld_1_0" 9
  32221. + (and (eq_attr "metacore" "metac_1_0")
  32222. + (and (eq_attr "type" "fivex")
  32223. + (eq_attr "memaccess" "load")))
  32224. + "issue, issue, issue, issue, issue, load*5, load_port, load_port, load_port, load_port, load_port")
  32225. +
  32226. +(define_insn_reservation "UI2xst" 1
  32227. + (and (eq_attr "type" "twox")
  32228. + (eq_attr "memaccess" "store"))
  32229. + "issue, issue")
  32230. +
  32231. +(define_insn_reservation "UI3xst" 1
  32232. + (and (eq_attr "type" "threex")
  32233. + (eq_attr "memaccess" "store"))
  32234. + "issue, issue, issue")
  32235. +
  32236. +(define_insn_reservation "UI4xst" 1
  32237. + (and (eq_attr "type" "fourx")
  32238. + (eq_attr "memaccess" "store"))
  32239. + "issue, issue, issue, issue")
  32240. +
  32241. +(define_insn_reservation "UI5xst" 1
  32242. + (and (eq_attr "type" "fivex")
  32243. + (eq_attr "memaccess" "store"))
  32244. + "issue, issue, issue, issue, issue")
  32245. +
  32246. +;; Catch all the cond_exec cases that will cause single cycle ops to become 3 cycle
  32247. +;; WORK NEEDED: optimize those cases where the condition is ALWAYS or NONE or if the
  32248. +;; condition value is known at issue (no updates to CC in the pipeline).
  32249. +;; In such cases the instruction becomes UI (if it were UI to start with).
  32250. +(define_bypass 2 "UI, FP"
  32251. + "UIother,UI,UIswap,UImult, \
  32252. + UIUI,UIUIUI,UIUIUIUI,UIUIUIUIUI,U2U,U2UU2U, \
  32253. + branch_2_1,load_2_1,read_2_1, \
  32254. + branch_1_2,load_1_2,read_1_2, \
  32255. + branch_1_1,load_1_1,read_1_1, \
  32256. + branch_1_0,load_1_0,read_1_0, \
  32257. + UI2xld_2_1,UI3xld_2_1,UI4xld_2_1,UI5xld_2_1, \
  32258. + UI2xld_1_1,UI3xld_1_1,UI4xld_1_1,UI5xld_1_1, \
  32259. + UI2xld_1_0,UI3xld_1_0,UI4xld_1_0,UI5xld_1_0, \
  32260. + UI2xst,UI3xst,UI4xst,UI5xst,\
  32261. + FP, FPmas, FPrecip, FPrecipmas"
  32262. + "metag_consumer_is_cond_p")
  32263. +
  32264. +;; SWAP has to write two registers so in effect takes 2 cycles rather than one so it is
  32265. +;; a slightly slower case.
  32266. +(define_bypass 4 "UIswap"
  32267. + "UIother,UI,UIswap,UImult, \
  32268. + UIUI,UIUIUI,UIUIUIUI,UIUIUIUIUI,U2U,U2UU2U, \
  32269. + branch_2_1,load_2_1,read_2_1, \
  32270. + branch_1_2,load_1_2,read_1_2, \
  32271. + branch_1_1,load_1_1,read_1_1, \
  32272. + branch_1_0,load_1_0,read_1_0, \
  32273. + UI2xld_2_1,UI3xld_2_1,UI4xld_2_1,UI5xld_2_1, \
  32274. + UI2xld_1_1,UI3xld_1_1,UI4xld_1_1,UI5xld_1_1, \
  32275. + UI2xld_1_0,UI3xld_1_0,UI4xld_1_0,UI5xld_1_0, \
  32276. + UI2xst,UI3xst,UI4xst,UI5xst, \
  32277. + FP, FPmas, FPrecip, FPrecipmas"
  32278. + "metag_consumer_is_cond_p")
  32279. +
  32280. +;; Regalloc/reload needs registers to have the shortest possible lifetime in order to
  32281. +;; successfully allocate registers. D0Re0, D1Re0, D1Ar6, D0Ar5 are very popular
  32282. +;; especially with modes that require 2 registers, load/store multiops,
  32283. +;; base + 12bit offset memory operations, argument registers, return registers...
  32284. +
  32285. +;; The automata is very pessimistic when it comes across insns with multiple opcodes
  32286. +;; it assumes that they will never be split. In reality almost all are split and
  32287. +;; therefore scheduling them as one block before reload has a negative effect on
  32288. +;; the associated registers lifetime (it increases). To counter this we bypass the
  32289. +;; automata prior to reload to say that multi opcode insns actually have no latency,
  32290. +;; i.e. ignore them completely, there is nothing that can be inferred.
  32291. +;; After reload they are treated as proper insns.
  32292. +
  32293. +;; The reduced lifetime gives the register allocator and reload more scope to fulfil
  32294. +;; insns constraints.
  32295. +(define_bypass 0 "UIUI,UIUIUI,UIUIUIUI,UIUIUIUIUI,U2U,U2UU2U"
  32296. + "UI,UIswap,UIother,UImult,UIUI,UIUIUI,UIUIUIUI,UIUIUIUIUI, \
  32297. + U2U,U2UU2U,FP,FPmas,FPrecip,FPrecipmas, \
  32298. + branch_2_1,load_2_1,read_2_1, \
  32299. + branch_1_2,load_1_2,read_1_2, \
  32300. + branch_1_1,load_1_1,read_1_1, \
  32301. + branch_1_0,load_1_0,read_1_0, \
  32302. + UI2xld_2_1,UI3xld_2_1,UI4xld_2_1,UI5xld_2_1, \
  32303. + UI2xld_1_1,UI3xld_1_1,UI4xld_1_1,UI5xld_1_1, \
  32304. + UI2xld_1_0,UI3xld_1_0,UI4xld_1_0,UI5xld_1_0, \
  32305. + UI2xst,UI3xst,UI4xst,UI5xst"
  32306. + "metag_bypass_before_reload_p")
  32307. +
  32308. diff -Nur gcc-4.2.4.orig/gcc/config/metag/predicates.md gcc-4.2.4/gcc/config/metag/predicates.md
  32309. --- gcc-4.2.4.orig/gcc/config/metag/predicates.md 1969-12-31 18:00:00.000000000 -0600
  32310. +++ gcc-4.2.4/gcc/config/metag/predicates.md 2015-07-03 18:46:05.773283541 -0500
  32311. @@ -0,0 +1,815 @@
  32312. +;; Predicate definitions for META
  32313. +;; Copyright (C) 2007, 2010 Imagination Technologies Ltd
  32314. +
  32315. +;; This file is part of GCC.
  32316. +
  32317. +;; GCC is free software; you can redistribute it and/or modify it under
  32318. +;; the terms of the GNU General Public License as published by the Free
  32319. +;; Software Foundation; either version 3, or (at your option) any later
  32320. +;; version.
  32321. +
  32322. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  32323. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  32324. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  32325. +;; for more details.
  32326. +
  32327. +;; You should have received a copy of the GNU General Public License
  32328. +;; along with GCC; see the file COPYING3. If not see
  32329. +;; <http://www.gnu.org/licenses/>.
  32330. +
  32331. +(define_predicate "metag_register_op"
  32332. +(match_code "subreg,reg")
  32333. +{
  32334. + if (!register_operand (op, mode))
  32335. + return false;
  32336. +
  32337. + if (SUBREG_P (op))
  32338. + op = SUBREG_REG (op);
  32339. +
  32340. + return !REG_P (op) || (REGNO (op) != TXRPT_REG
  32341. + && REGNO (op) != TTREC_REG);
  32342. +})
  32343. +
  32344. +(define_predicate "metag_reg_nofloat_op"
  32345. +(match_code "subreg,reg")
  32346. +{
  32347. + if (!register_operand (op, mode))
  32348. + return false;
  32349. +
  32350. + if (SUBREG_P (op))
  32351. + op = SUBREG_REG (op);
  32352. +
  32353. + return (!REG_P (op) || (REGNO (op) != TXRPT_REG
  32354. + && REGNO (op) != TTREC_REG))
  32355. + && !METAG_FPC_REG_P (REGNO (op));
  32356. +})
  32357. +
  32358. +;; Any hard data register
  32359. +(define_predicate "metag_hard_datareg_op"
  32360. +(match_code "reg")
  32361. +{
  32362. + unsigned int regno = REGNO (op);
  32363. +
  32364. + return mode == GET_MODE (op)
  32365. + && METAG_DATA_REG_P (regno);
  32366. +})
  32367. +
  32368. +;; Any hard address register
  32369. +(define_predicate "metag_hard_addrreg_op"
  32370. +(match_code "reg")
  32371. +{
  32372. + unsigned int regno = REGNO (op);
  32373. +
  32374. + return mode == GET_MODE (op)
  32375. + && METAG_ADDR_REG_P (regno);
  32376. +})
  32377. +
  32378. +;; Any hard gen register
  32379. +(define_predicate "metag_hard_genreg_op"
  32380. +(ior (match_operand 0 "metag_hard_datareg_op")
  32381. + (match_operand 0 "metag_hard_addrreg_op")))
  32382. +
  32383. +(define_predicate "metag_regnofrm_op"
  32384. +(match_code "subreg,reg")
  32385. +{
  32386. + if (metag_reg_nofloat_op (op, mode))
  32387. + {
  32388. + /* Subreg can hide a lot of non-reg things that we don't want! */
  32389. + if (SUBREG_P (op))
  32390. + op = SUBREG_REG (op);
  32391. +
  32392. + /* Reject all stack frame related pointers. */
  32393. + return !metag_frame_related_rtx (op);
  32394. + }
  32395. +
  32396. + return false;
  32397. +})
  32398. +
  32399. +
  32400. +(define_predicate "metag_regframe_op"
  32401. +(match_code "subreg,reg")
  32402. +{
  32403. + if (metag_register_op (op, mode))
  32404. + {
  32405. + /* Subreg can hide a lot of non-reg things that we don't want! */
  32406. + if (SUBREG_P (op))
  32407. + op = SUBREG_REG (op);
  32408. +
  32409. + /* Accept only stack relasted pointers */
  32410. + return metag_frame_related_rtx (op);
  32411. + }
  32412. +
  32413. + return false;
  32414. +})
  32415. +
  32416. +(define_predicate "metag_regorint_op"
  32417. +(match_code "subreg,reg,const_int")
  32418. +{
  32419. + /* Integer constants are allowed */
  32420. + if (CONST_INT_P (op))
  32421. + return true;
  32422. +
  32423. + return metag_register_op (op, mode);
  32424. +})
  32425. +
  32426. +(define_predicate "metag_okbindex_op"
  32427. +(and (match_code "const_int")
  32428. + (match_test "satisfies_constraint_O1 (op)")))
  32429. +
  32430. +(define_predicate "metag_okwindex_op"
  32431. +(and (match_code "const_int")
  32432. + (match_test "satisfies_constraint_O2 (op)")))
  32433. +
  32434. +(define_predicate "metag_okdindex_op"
  32435. +(and (match_code "const_int")
  32436. + (match_test "satisfies_constraint_O4 (op)")))
  32437. +
  32438. +(define_predicate "metag_oklindex_op"
  32439. +(and (match_code "const_int")
  32440. + (match_test "satisfies_constraint_O8 (op)")))
  32441. +
  32442. +(define_predicate "metag_int_operand"
  32443. +(and (match_code "const_int")
  32444. + (match_test "METAG_LETTER_FOR_CONST (op) != 0")))
  32445. +
  32446. +(define_predicate "metag_smallint_op"
  32447. +(and (match_code "const_int")
  32448. + (match_test "(INTVAL (op) >= -255 && INTVAL (op) <= 255)")))
  32449. +
  32450. +(define_predicate "metag_bigint_op"
  32451. +(match_code "const_int"))
  32452. +
  32453. +(define_predicate "symbolic_operand"
  32454. +(match_code "symbol_ref"))
  32455. +
  32456. +(define_predicate "metag_symsmall_op"
  32457. +(and (match_code "symbol_ref")
  32458. + (match_test "METAG_SYMBOL_FLAG_SMALL_P (op)")))
  32459. +
  32460. +(define_predicate "metag_symlarge_op"
  32461. +(and (match_code "symbol_ref")
  32462. + (match_test "METAG_SYMBOL_FLAG_LARGE_P (op)")))
  32463. +
  32464. +(define_predicate "metag_symglobal_op"
  32465. +(and (match_code "symbol_ref")
  32466. + (match_test "METAG_SYMBOL_FLAG_GLOBAL_P (op)")))
  32467. +
  32468. +(define_predicate "metag_symdirect_op"
  32469. +(and (match_code "symbol_ref")
  32470. + (match_test "METAG_SYMBOL_FLAG_DIRECT_P (op)")))
  32471. +
  32472. +(define_predicate "metag_call_addr"
  32473. +(and (match_code "mem")
  32474. + (ior (match_test "SYMBOL_REF_P (XEXP (op, 0))")
  32475. + (match_test "REG_P (XEXP (op, 0))"))))
  32476. +
  32477. +(define_predicate "code_address"
  32478. +(match_code "label_ref,symbol_ref")
  32479. +{
  32480. + /* Label references are the easy bit */
  32481. + if (LABEL_REF_P (op))
  32482. + return true;
  32483. +
  32484. + if (METAG_FLAG_PIC)
  32485. + return false;
  32486. +
  32487. + return SYMBOL_REF_P (op)
  32488. + && !METAG_SYMBOL_FLAG_SMALL_P (op)
  32489. + && !METAG_SYMBOL_FLAG_LARGE_P (op)
  32490. + && !METAG_SYMBOL_FLAG_GLOBAL_P (op)
  32491. + && (SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_NONE);
  32492. +})
  32493. +
  32494. +(define_predicate "metag_cc_reg"
  32495. +(match_code "reg")
  32496. +{
  32497. + if (mode == VOIDmode)
  32498. + {
  32499. + mode = GET_MODE (op);
  32500. + if (GET_MODE_CLASS (mode) != MODE_CC)
  32501. + return false;
  32502. + }
  32503. +
  32504. + return (mode == GET_MODE (op)
  32505. + && REG_P (op)
  32506. + && REGNO (op) == MCC_REGNUM);
  32507. +})
  32508. +
  32509. +(define_predicate "metag_cc_noov_reg"
  32510. +(match_code "reg")
  32511. +{
  32512. + if (mode == VOIDmode)
  32513. + {
  32514. + mode = GET_MODE (op);
  32515. + if (GET_MODE_CLASS (mode) != MODE_CC)
  32516. + return false;
  32517. + }
  32518. +
  32519. + return (mode == GET_MODE (op)
  32520. + && REG_P (op)
  32521. + && REGNO (op) == MCC_REGNUM);
  32522. +})
  32523. +
  32524. +(define_predicate "metag_cc_z_reg"
  32525. +(match_code "reg")
  32526. +{
  32527. + if (mode == VOIDmode)
  32528. + {
  32529. + mode = GET_MODE (op);
  32530. + if (GET_MODE_CLASS (mode) != MODE_CC)
  32531. + return false;
  32532. + }
  32533. +
  32534. + return (mode == GET_MODE (op)
  32535. + && REG_P (op)
  32536. + && REGNO (op) == MCC_REGNUM);
  32537. +})
  32538. +
  32539. +(define_predicate "metag_cc_fp_reg"
  32540. +(match_code "reg")
  32541. +{
  32542. + if (mode == VOIDmode)
  32543. + {
  32544. + mode = GET_MODE (op);
  32545. + if (GET_MODE_CLASS (mode) != MODE_CC)
  32546. + return false;
  32547. + }
  32548. +
  32549. + return (mode == GET_MODE (op)
  32550. + && REG_P (op)
  32551. + && REGNO (op) == MCC_REGNUM);
  32552. +})
  32553. +
  32554. +(define_predicate "metag_cc_fp_q_reg"
  32555. +(match_code "reg")
  32556. +{
  32557. + if (mode == VOIDmode)
  32558. + {
  32559. + mode = GET_MODE (op);
  32560. + if (GET_MODE_CLASS (mode) != MODE_CC)
  32561. + return false;
  32562. + }
  32563. +
  32564. + return (mode == GET_MODE (op)
  32565. + && REG_P (op)
  32566. + && REGNO (op) == MCC_REGNUM);
  32567. +})
  32568. +
  32569. +(define_predicate "load_multiop"
  32570. +(match_code "parallel")
  32571. +{
  32572. + HOST_WIDE_INT count = XVECLEN (op, 0);
  32573. + unsigned int dst_regno;
  32574. + enum machine_mode xfer_mode;
  32575. + unsigned int word_size;
  32576. + unsigned int lastreg;
  32577. + rtx src_addr;
  32578. + enum reg_class dst_regclass;
  32579. + HOST_WIDE_INT i;
  32580. + rtx elt;
  32581. + rtx src;
  32582. + rtx dst;
  32583. +
  32584. + elt = XVECEXP (op, 0, 0);
  32585. + if (count < 2 || count > 8 || GET_CODE (elt) != SET)
  32586. + return false;
  32587. +
  32588. + src = SET_SRC (elt);
  32589. + dst = SET_DEST (elt);
  32590. +
  32591. + if (GET_CODE (src) != PLUS)
  32592. + return false;
  32593. +
  32594. + elt = XVECEXP (op, 0, 1);
  32595. + if (GET_CODE (elt) != SET)
  32596. + return false;
  32597. +
  32598. + /* Work out if this is SImode or DImode case */
  32599. + xfer_mode = GET_MODE (SET_SRC (elt));
  32600. + word_size = GET_MODE_SIZE (xfer_mode);
  32601. +
  32602. + if (word_size == 4 && count <= 2)
  32603. + return false;
  32604. +
  32605. + /* Now check it more carefully */
  32606. + if (!REG_P (dst)
  32607. + || !REG_P (XEXP (src, 0))
  32608. + || REGNO (XEXP (src, 0)) != REGNO (dst)
  32609. + || !CONST_INT_P (XEXP (src, 1))
  32610. + || INTVAL (XEXP (src, 1)) != (HOST_WIDE_INT)((count - 1) * word_size))
  32611. + return false;
  32612. +
  32613. + src = SET_SRC (elt);
  32614. + dst = SET_DEST (elt);
  32615. +
  32616. + /* Perform a quick check so we don't blow up below. */
  32617. + if (!REG_P (dst) || !MEM_P (src))
  32618. + return false;
  32619. +
  32620. + lastreg = REGNO (dst);
  32621. + dst_regno = REGNO (dst);
  32622. + src_addr = XEXP (src, 0);
  32623. + dst_regclass = METAG_REGNO_REG_CLASS (dst_regno);
  32624. +
  32625. + for (i = 2; i < count; i++)
  32626. + {
  32627. + elt = XVECEXP (op, 0, i);
  32628. + if (GET_CODE (elt) != SET)
  32629. + return false;
  32630. +
  32631. + src = SET_SRC (elt);
  32632. + dst = SET_DEST (elt);
  32633. +
  32634. + if (!REG_P (dst)
  32635. + || GET_MODE (dst) != xfer_mode
  32636. + || REGNO (dst) - dst_regno > 2 * word_size
  32637. + || REGNO (dst) <= lastreg
  32638. + || METAG_REGNO_REG_CLASS (REGNO (dst)) != dst_regclass
  32639. + || !MEM_P (src)
  32640. + || GET_MODE (src) != xfer_mode
  32641. + || GET_CODE (XEXP (src, 0)) != PLUS
  32642. + || !rtx_equal_p (XEXP (XEXP (src, 0), 0), src_addr)
  32643. + || !CONST_INT_P (XEXP (XEXP (src, 0), 1))
  32644. + || INTVAL (XEXP (XEXP (src, 0), 1)) != (HOST_WIDE_INT)((i - 1) * word_size))
  32645. + return false;
  32646. +
  32647. + lastreg = REGNO (dst);
  32648. + }
  32649. +
  32650. + return true;
  32651. +})
  32652. +
  32653. +(define_predicate "store_multiop"
  32654. +(match_code "parallel")
  32655. +{
  32656. + HOST_WIDE_INT count = XVECLEN (op, 0);
  32657. + unsigned int src_regno;
  32658. + enum machine_mode xfer_mode;
  32659. + unsigned int word_size;
  32660. + unsigned int lastreg;
  32661. + enum reg_class src_regclass;
  32662. + rtx dst_addr;
  32663. + HOST_WIDE_INT i;
  32664. + rtx elt;
  32665. + rtx src;
  32666. + rtx dst;
  32667. +
  32668. + elt = XVECEXP (op, 0, 0);
  32669. + if (count <= 2 || count > 9 || GET_CODE (elt) != SET)
  32670. + return false;
  32671. +
  32672. + dst = SET_DEST (elt);
  32673. + src = SET_SRC (elt);
  32674. +
  32675. + if (GET_CODE (src) != PLUS)
  32676. + return false;
  32677. +
  32678. + elt = XVECEXP (op, 0, 1);
  32679. + if (GET_CODE (elt) != SET)
  32680. + return false;
  32681. +
  32682. + /* Work out if this is SImode or DImode case */
  32683. + xfer_mode = GET_MODE (SET_DEST (elt));
  32684. + word_size = GET_MODE_SIZE (xfer_mode);
  32685. +
  32686. + /* Now check it more carefully */
  32687. + if (!REG_P (dst)
  32688. + || !REG_P (XEXP (src, 0))
  32689. + || REGNO (XEXP (src, 0)) != REGNO (dst)
  32690. + || !CONST_INT_P (XEXP (src, 1))
  32691. + || INTVAL (XEXP (src, 1)) != (HOST_WIDE_INT)((count - 1) * word_size))
  32692. + return false;
  32693. +
  32694. + src = SET_SRC (elt);
  32695. + dst = SET_DEST (elt);
  32696. +
  32697. + /* Perform a quick check so we don't blow up below. */
  32698. + if (!MEM_P (dst) || !REG_P (src))
  32699. + return false;
  32700. +
  32701. + lastreg = REGNO (src);
  32702. + src_regno = REGNO (src);
  32703. + dst_addr = XEXP (dst, 0);
  32704. + src_regclass = METAG_REGNO_REG_CLASS (src_regno);
  32705. +
  32706. + for (i = 2; i < count; i++)
  32707. + {
  32708. + elt = XVECEXP (op, 0, i);
  32709. + if (GET_CODE (elt) != SET)
  32710. + return false;
  32711. +
  32712. + src = SET_SRC (elt);
  32713. + dst = SET_DEST (elt);
  32714. +
  32715. + if (!REG_P (src)
  32716. + || GET_MODE (src) != xfer_mode
  32717. + || REGNO (src) - src_regno > 2 * word_size
  32718. + || REGNO (src) <= lastreg
  32719. + || METAG_REGNO_REG_CLASS (REGNO (src)) != src_regclass
  32720. + || !MEM_P (dst)
  32721. + || GET_MODE (dst) != xfer_mode
  32722. + || GET_CODE (XEXP (dst, 0)) != PLUS
  32723. + || !rtx_equal_p (XEXP (XEXP (dst, 0), 0), dst_addr)
  32724. + || !CONST_INT_P (XEXP (XEXP (dst, 0), 1))
  32725. + || INTVAL (XEXP (XEXP (dst, 0), 1)) != (HOST_WIDE_INT)((i - 1) * word_size))
  32726. + return false;
  32727. +
  32728. + lastreg = REGNO (src);
  32729. + }
  32730. +
  32731. + return true;
  32732. +})
  32733. +
  32734. +(define_predicate "metag_datareg_op"
  32735. +(and (match_code "subreg,reg")
  32736. + (match_operand 0 "metag_register_op"))
  32737. +{
  32738. + unsigned int regno;
  32739. +
  32740. + if (SUBREG_P (op))
  32741. + op = SUBREG_REG (op);
  32742. +
  32743. + /* A subreg may refer to a mem before reload, metag_register_op ensures
  32744. + that reload has not completed if it is a mem */
  32745. + if (!REG_P (op))
  32746. + return true;
  32747. +
  32748. + regno = REGNO (op);
  32749. +
  32750. + if (regno >= FIRST_PSEUDO_REGISTER)
  32751. + return true;
  32752. +
  32753. + return METAG_DATA_REG_P (regno);
  32754. +})
  32755. +
  32756. +(define_predicate "metag_addrreg_op"
  32757. +(and (match_code "subreg,reg")
  32758. + (match_operand 0 "metag_register_op"))
  32759. +{
  32760. + unsigned int regno;
  32761. +
  32762. + if (SUBREG_P (op))
  32763. + op = SUBREG_REG (op);
  32764. +
  32765. + /* A subreg may refer to a mem before reload, metag_register_op ensures
  32766. + that reload has not completed if it is a mem */
  32767. + if (!REG_P (op))
  32768. + return true;
  32769. +
  32770. + regno = REGNO (op);
  32771. +
  32772. + if (regno >= FIRST_PSEUDO_REGISTER)
  32773. + return true;
  32774. +
  32775. + return METAG_ADDR_REG_P (regno);
  32776. +})
  32777. +
  32778. +(define_predicate "metag_fpreg_op"
  32779. +(and (match_code "subreg,reg")
  32780. + (match_operand 0 "metag_register_op"))
  32781. +{
  32782. + unsigned int regno;
  32783. +
  32784. + if (SUBREG_P (op))
  32785. + op = SUBREG_REG (op);
  32786. +
  32787. + /* A subreg may refer to a mem before reload, metag_register_op ensures
  32788. + that reload has not completed if it is a mem */
  32789. + if (!REG_P (op))
  32790. + return true;
  32791. +
  32792. + regno = REGNO (op);
  32793. +
  32794. + if (regno >= FIRST_PSEUDO_REGISTER)
  32795. + return true;
  32796. +
  32797. + return METAG_FPC_REG_P (regno);
  32798. +})
  32799. +
  32800. +(define_predicate "metag_fpreg_or_dreg_op"
  32801. +(and (match_code "subreg,reg")
  32802. + (match_operand 0 "metag_register_op"))
  32803. +{
  32804. + unsigned int regno;
  32805. +
  32806. + if (SUBREG_P (op))
  32807. + op = SUBREG_REG (op);
  32808. +
  32809. + /* A subreg may refer to a mem before reload, metag_register_op ensures
  32810. + that reload has not completed if it is a mem */
  32811. + if (!REG_P (op))
  32812. + return true;
  32813. +
  32814. + regno = REGNO (op);
  32815. +
  32816. + if (regno >= FIRST_PSEUDO_REGISTER)
  32817. + return true;
  32818. +
  32819. + return METAG_FPC_REG_P (regno) || METAG_DATA_REG_P (regno);
  32820. +})
  32821. +
  32822. +(define_predicate "metag_txrpt_op"
  32823. +(and (match_code "reg")
  32824. + (match_test "REGNO (op) == TXRPT_REGNUM")))
  32825. +
  32826. +(define_predicate "metag_ttrec_op"
  32827. +(and (match_code "reg")
  32828. + (match_test "REGNO (op) == TTREC_REGNUM")))
  32829. +
  32830. +;; Return true if OP is a valid TXRPT_REGNUM
  32831. +;; source operand that can be loaded quickly for the given mode
  32832. +(define_predicate "metag_txrpt_src_op"
  32833. +(ior (and (match_code "const_int")
  32834. + (match_test "satisfies_constraint_I (op)
  32835. + || satisfies_constraint_K (op)
  32836. + || satisfies_constraint_P (op)
  32837. + || satisfies_constraint_J (op)"))
  32838. + (match_code "reg")))
  32839. +
  32840. +(define_predicate "metag_16bit_op"
  32841. +(and (match_code "const_int")
  32842. + (match_test "-32768 <= INTVAL (op) && INTVAL (op) <= 32767")))
  32843. +
  32844. +(define_predicate "metag_vector_float_op"
  32845. +(match_code "const_vector")
  32846. +{
  32847. + int nunits = GET_MODE_NUNITS (mode);
  32848. +
  32849. + if (GET_CODE (op) == CONST_VECTOR
  32850. + && CONST_VECTOR_NUNITS (op) == nunits)
  32851. + {
  32852. + int i;
  32853. + for (i = 0; i < nunits; ++i)
  32854. + {
  32855. + rtx x = CONST_VECTOR_ELT (op, i);
  32856. + if (!metag_fphalf_imm_op (x, GET_MODE_INNER (mode)))
  32857. + return false;
  32858. + }
  32859. + return true;
  32860. + }
  32861. + return false;
  32862. +})
  32863. +
  32864. +(define_predicate "metag_vector_int_op"
  32865. +(match_code "const_vector")
  32866. +{
  32867. + int nunits = GET_MODE_NUNITS (mode);
  32868. +
  32869. + if (GET_CODE (op) == CONST_VECTOR
  32870. + && CONST_VECTOR_NUNITS (op) == nunits)
  32871. + {
  32872. + int i;
  32873. + for (i = 0; i < nunits; ++i)
  32874. + {
  32875. + rtx x = CONST_VECTOR_ELT (op, i);
  32876. + if (!CONST_INT_P (x))
  32877. + return false;
  32878. + }
  32879. + return true;
  32880. + }
  32881. + return false;
  32882. +})
  32883. +
  32884. +(define_predicate "metag_vector_16bit_op"
  32885. + (match_code "const_vector")
  32886. +{
  32887. + int nunits = GET_MODE_NUNITS (mode);
  32888. +
  32889. + if (GET_CODE (op) == CONST_VECTOR
  32890. + && CONST_VECTOR_NUNITS (op) == nunits)
  32891. + {
  32892. + int i;
  32893. + HOST_WIDE_INT val = INTVAL (CONST_VECTOR_ELT (op, 0));
  32894. + for (i = 0; i < nunits; ++i)
  32895. + {
  32896. + rtx x = CONST_VECTOR_ELT (op, i);
  32897. + if (!metag_16bit_op (x, GET_MODE_INNER (mode)))
  32898. + return false;
  32899. + if (val != INTVAL (x))
  32900. + return false;
  32901. + }
  32902. + return true;
  32903. + }
  32904. + return false;
  32905. +})
  32906. +
  32907. +(define_predicate "metag_5bit_op"
  32908. +(and (match_code "const_int")
  32909. + (match_test "0 <= INTVAL (op) && INTVAL (op) <= 31")))
  32910. +
  32911. +(define_predicate "metag_vector_5bit_op"
  32912. + (match_code "const_vector")
  32913. +{
  32914. + int nunits = GET_MODE_NUNITS (mode);
  32915. +
  32916. + if (GET_CODE (op) == CONST_VECTOR
  32917. + && CONST_VECTOR_NUNITS (op) == nunits)
  32918. + {
  32919. + int i;
  32920. + HOST_WIDE_INT val = INTVAL (CONST_VECTOR_ELT (op, 0));
  32921. + for (i = 0; i < nunits; ++i)
  32922. + {
  32923. + rtx x = CONST_VECTOR_ELT (op, i);
  32924. + if (!metag_5bit_op (x, GET_MODE_INNER (mode)))
  32925. + return false;
  32926. + if (val != INTVAL (x))
  32927. + return false;
  32928. + }
  32929. + return true;
  32930. + }
  32931. + return false;
  32932. +})
  32933. +
  32934. +(define_predicate "metag_K_operand"
  32935. +(and (match_code "const_int")
  32936. + (match_test "satisfies_constraint_K (op)")))
  32937. +
  32938. +(define_predicate "metag_L_operand"
  32939. +(and (match_code "const_int")
  32940. + (match_test "satisfies_constraint_L (op)")))
  32941. +
  32942. +(define_predicate "metag_J_operand"
  32943. +(and (match_code "const_int")
  32944. + (match_test "satisfies_constraint_J (op)")))
  32945. +
  32946. +(define_predicate "metag_O0_operand"
  32947. +(and (match_code "const_int")
  32948. + (match_test "satisfies_constraint_O0 (op)")))
  32949. +
  32950. +(define_predicate "metag_O3_operand"
  32951. +(and (match_code "const_int")
  32952. + (match_test "satisfies_constraint_O3 (op)")))
  32953. +
  32954. +(define_predicate "metag_P_operand"
  32955. +(and (match_code "const_int")
  32956. + (match_test "satisfies_constraint_P (op)")))
  32957. +
  32958. +(define_predicate "metag_KP_operand"
  32959. +(and (match_code "const_int")
  32960. + (ior (match_test "satisfies_constraint_K (op)")
  32961. + (match_test "satisfies_constraint_P (op)"))))
  32962. +
  32963. +(define_predicate "metag_KIP_operand"
  32964. +(and (match_code "const_int")
  32965. + (ior (match_test "satisfies_constraint_K (op)")
  32966. + (ior (match_test "satisfies_constraint_P (op)")
  32967. + (match_test "satisfies_constraint_I (op)")))))
  32968. +
  32969. +(define_predicate "metag_pic_reg"
  32970. +(and (match_code "reg")
  32971. + (ior (match_test "op == pic_offset_table_rtx")
  32972. + (and (match_code "reg")
  32973. + (match_test "REGNO (op) == PIC_OFFSET_TABLE_REGNUM")))))
  32974. +
  32975. +(define_predicate "metag_offset12_qi"
  32976. +(and (match_code "const_int")
  32977. + (match_test "satisfies_constraint_Z1 (op)")))
  32978. +
  32979. +(define_predicate "metag_offset12_hi"
  32980. +(and (match_code "const_int")
  32981. + (match_test "satisfies_constraint_Z2 (op)")))
  32982. +
  32983. +(define_predicate "metag_offset12_si"
  32984. +(and (match_code "const_int")
  32985. + (match_test "satisfies_constraint_Z4 (op)")))
  32986. +
  32987. +(define_predicate "metag_offset12_di"
  32988. +(and (match_code "const_int")
  32989. + (match_test "satisfies_constraint_Z8 (op)")))
  32990. +
  32991. +(define_predicate "metag_offset12_sf"
  32992. +(and (match_code "const_int")
  32993. + (match_test "satisfies_constraint_Z4 (op)")))
  32994. +
  32995. +(define_predicate "metag_offset12_df"
  32996. +(and (match_code "const_int")
  32997. + (match_test "satisfies_constraint_Z8 (op)")))
  32998. +
  32999. +(define_predicate "metag_offset12_v2si"
  33000. +(and (match_code "const_int")
  33001. + (match_test "satisfies_constraint_Z8 (op)")))
  33002. +
  33003. +(define_predicate "metag_offset12_v2sf"
  33004. +(and (match_code "const_int")
  33005. + (match_test "satisfies_constraint_Z8 (op)")))
  33006. +
  33007. +(define_predicate "metag_offset6_qi"
  33008. +(and (match_code "const_int")
  33009. + (match_test "satisfies_constraint_O1 (op)")))
  33010. +
  33011. +(define_predicate "metag_offset6_hi"
  33012. +(and (match_code "const_int")
  33013. + (match_test "satisfies_constraint_O2 (op)")))
  33014. +
  33015. +(define_predicate "metag_offset6_si"
  33016. +(and (match_code "const_int")
  33017. + (match_test "satisfies_constraint_O4 (op)")))
  33018. +
  33019. +(define_predicate "metag_offset6_di"
  33020. +(and (match_code "const_int")
  33021. + (match_test "satisfies_constraint_O8 (op)")))
  33022. +
  33023. +(define_predicate "metag_offset6_sf"
  33024. +(and (match_code "const_int")
  33025. + (match_test "satisfies_constraint_O4 (op)")))
  33026. +
  33027. +(define_predicate "metag_offset6_df"
  33028. +(and (match_code "const_int")
  33029. + (match_test "satisfies_constraint_O8 (op)")))
  33030. +
  33031. +(define_predicate "metag_offset6_v2si"
  33032. +(and (match_code "const_int")
  33033. + (match_test "satisfies_constraint_O8 (op)")))
  33034. +
  33035. +(define_predicate "metag_offset6_v2sf"
  33036. +(and (match_code "const_int")
  33037. + (match_test "satisfies_constraint_O8 (op)")))
  33038. +
  33039. +(define_predicate "metag_reg12bit_op"
  33040. +(match_code "subreg,reg")
  33041. +{
  33042. + if (metag_register_op (op, mode))
  33043. + {
  33044. + if (SUBREG_P (op))
  33045. + op = SUBREG_REG (op);
  33046. +
  33047. + if (REG_P (op))
  33048. + {
  33049. + unsigned regno = REGNO (op);
  33050. +
  33051. + if (regno == INVALID_REGNUM)
  33052. + return false;
  33053. + else if (regno >= FIRST_PSEUDO_REGISTER)
  33054. + return !reload_completed;
  33055. + else if (metag_regno12bit_p (regno))
  33056. + return true;
  33057. + else if (!reload_completed && !reload_in_progress)
  33058. + return (regno == FRAME_REG || regno == ARGP_REG);
  33059. + }
  33060. + }
  33061. +
  33062. + return false;
  33063. +})
  33064. +
  33065. +(define_predicate "metag_fphalf_imm_op"
  33066. +(match_code "const_double")
  33067. +{
  33068. + bool inexact = false;
  33069. +
  33070. + if (mode != SFmode && mode != DFmode)
  33071. + return false;
  33072. +
  33073. + metag_const_double_to_hp (op, &inexact);
  33074. + return !inexact;
  33075. +})
  33076. +
  33077. +(define_predicate "metag_fpreg_or_imm_op"
  33078. +(ior (and (match_code "subreg,reg")
  33079. + (match_operand 0 "metag_register_op"))
  33080. + (match_code "const_double"))
  33081. +{
  33082. + if (SUBREG_P (op))
  33083. + op = SUBREG_REG (op);
  33084. +
  33085. + if (REG_P(op))
  33086. + {
  33087. + unsigned int regno = REGNO (op);
  33088. +
  33089. + if (regno >= FIRST_PSEUDO_REGISTER)
  33090. + return true;
  33091. +
  33092. + return METAG_FPC_REG_P (regno);
  33093. + }
  33094. + else
  33095. + return GET_CODE (op) == CONST_DOUBLE
  33096. + && GET_MODE_CLASS (mode) == MODE_FLOAT;
  33097. +})
  33098. +
  33099. +(define_predicate "metag_fpreg_or_fpzero_imm_op"
  33100. +(ior (and (match_code "subreg,reg")
  33101. + (match_operand 0 "metag_register_op"))
  33102. + (match_code "const_double"))
  33103. +{
  33104. + if (SUBREG_P (op))
  33105. + op = SUBREG_REG (op);
  33106. +
  33107. + if (REG_P (op))
  33108. + {
  33109. + unsigned int regno = REGNO (op);
  33110. +
  33111. + if (regno >= FIRST_PSEUDO_REGISTER)
  33112. + return true;
  33113. +
  33114. + return METAG_FPC_REG_P (regno);
  33115. + }
  33116. + else
  33117. + return GET_CODE (op) == CONST_DOUBLE
  33118. + && GET_MODE_CLASS (mode) == MODE_FLOAT
  33119. + && op == CONST0_RTX (mode);
  33120. +})
  33121. +
  33122. +(define_predicate "metag_fpone_imm_op"
  33123. + (match_code "const_double")
  33124. +{
  33125. + return satisfies_constraint_H (op);
  33126. +})
  33127. diff -Nur gcc-4.2.4.orig/gcc/config/metag/t-linux gcc-4.2.4/gcc/config/metag/t-linux
  33128. --- gcc-4.2.4.orig/gcc/config/metag/t-linux 1969-12-31 18:00:00.000000000 -0600
  33129. +++ gcc-4.2.4/gcc/config/metag/t-linux 2015-07-03 18:46:05.773283541 -0500
  33130. @@ -0,0 +1,46 @@
  33131. +# t-linux
  33132. +# Copyright (C) 2011 Imagination Technologies Ltd
  33133. +
  33134. +# This file is part of GCC.
  33135. +
  33136. +# GCC is free software; you can redistribute it and/or modify it under
  33137. +# the terms of the GNU General Public License as published by the Free
  33138. +# Software Foundation; either version 3, or (at your option) any later
  33139. +# version.
  33140. +#
  33141. +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33142. +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33143. +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33144. +# for more details.
  33145. +#
  33146. +# You should have received a copy of the GNU General Public License
  33147. +# along with GCC; see the file COPYING3. If not see
  33148. +# <http://www.gnu.org/licenses/>.
  33149. +
  33150. +# Don't run fixproto
  33151. +STMP_FIXPROTO =
  33152. +
  33153. +# Don't install "assert.h" in gcc. We use the one in uClibc.
  33154. +INSTALL_ASSERT_H =
  33155. +
  33156. +# Compile crtbeginS.o and crtendS.o with pic.
  33157. +CRTSTUFF_T_CFLAGS_S = -fPIC
  33158. +
  33159. +# Compile crtbegin.o and crtend.o without pic.
  33160. +CRTSTUFF_T_CFLAGS =
  33161. +
  33162. +# Compile libgcc2.a
  33163. +TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC
  33164. +LIBGCC2_DEBUG_CFLAGS = -g0
  33165. +
  33166. +CROSS_LIBGCC1 = libgcc1-asm.a
  33167. +LIBGCC1 = libgcc1-asm.a
  33168. +LIB1ASMSRC = metag/lib1funcs.asm
  33169. +LIB1ASMFUNCS = _udivsi3 \
  33170. + _divsi3 \
  33171. + _umodsi3 \
  33172. + _modsi3 \
  33173. +
  33174. +# Don't make libgcc1-test since it will fail because it tries to link with liblow.a which doesn't exist for linux toolchain!
  33175. +LIBGCC1_TEST =
  33176. +
  33177. diff -Nur gcc-4.2.4.orig/gcc/config/metag/t-linux-2.1 gcc-4.2.4/gcc/config/metag/t-linux-2.1
  33178. --- gcc-4.2.4.orig/gcc/config/metag/t-linux-2.1 1969-12-31 18:00:00.000000000 -0600
  33179. +++ gcc-4.2.4/gcc/config/metag/t-linux-2.1 2015-07-03 18:46:05.773283541 -0500
  33180. @@ -0,0 +1,20 @@
  33181. +# t-linux-2.1
  33182. +# Copyright (C) 2012 Imagination Technologies Ltd
  33183. +
  33184. +# This file is part of GCC.
  33185. +
  33186. +# GCC is free software; you can redistribute it and/or modify it under
  33187. +# the terms of the GNU General Public License as published by the Free
  33188. +# Software Foundation; either version 3, or (at your option) any later
  33189. +# version.
  33190. +#
  33191. +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33192. +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33193. +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33194. +# for more details.
  33195. +#
  33196. +# You should have received a copy of the GNU General Public License
  33197. +# along with GCC; see the file COPYING3. If not see
  33198. +# <http://www.gnu.org/licenses/>.
  33199. +
  33200. +LIB2FUNCS_STATIC_EXTRA += $(srcdir)/config/metag/linux-atomic.asm
  33201. diff -Nur gcc-4.2.4.orig/gcc/config/metag/tls.md gcc-4.2.4/gcc/config/metag/tls.md
  33202. --- gcc-4.2.4.orig/gcc/config/metag/tls.md 1969-12-31 18:00:00.000000000 -0600
  33203. +++ gcc-4.2.4/gcc/config/metag/tls.md 2015-07-03 18:46:05.773283541 -0500
  33204. @@ -0,0 +1,205 @@
  33205. +;; Machine description for Thread-Local Storage,
  33206. +;; Imagination Technologies Meta version.
  33207. +;; Copyright (C) 2009, 2010
  33208. +;; Imagination Technologies Ltd
  33209. +
  33210. +;; This file is part of GCC.
  33211. +
  33212. +;; GCC is free software; you can redistribute it and/or modify it under
  33213. +;; the terms of the GNU General Public License as published by the Free
  33214. +;; Software Foundation; either version 3, or (at your option) any later
  33215. +;; version.
  33216. +
  33217. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33218. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33219. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33220. +;; for more details.
  33221. +
  33222. +;; You should have received a copy of the GNU General Public License
  33223. +;; along with GCC; see the file COPYING3. If not see
  33224. +;; <http://www.gnu.org/licenses/>.
  33225. +
  33226. +;;Global dynamic insns to set up the call to __tls_get_addr
  33227. +;;These insns will generate the same code for PIC and non PIC cases
  33228. +(define_insn "*tls_gd_sum"
  33229. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33230. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  33231. + (const:SI (unspec [(match_operand:SI 2 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))))]
  33232. + "METAG_HAVE_TLS"
  33233. + "ADD\\t%0, %1, #(%c2@TLSGD)"
  33234. + [(set_attr "type" "fast")])
  33235. +
  33236. +(define_insn_and_split "tls_gd"
  33237. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33238. + (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  33239. + (const:SI (unspec [(match_operand:SI 2 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))))]
  33240. + "METAG_HAVE_TLS && operands[1] == pic_offset_table_rtx"
  33241. + "#"
  33242. + "&& SPLIT_HI_LO_SUM_EARLY"
  33243. + [(set (match_dup 0)
  33244. + (match_dup 1))
  33245. + (set (match_dup 0)
  33246. + (plus:SI (match_dup 0)
  33247. + (const:SI (unspec [(match_dup 2)] UNSPEC_TLSGD))))]
  33248. + ""
  33249. + [])
  33250. +
  33251. +;;Local dynamic insns to set up the call to __tls_get_addr to get the address of the start of the current module.
  33252. +;;These insns will generate the same code for PIC and non PIC cases
  33253. +(define_insn "*tls_ldm_sum"
  33254. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33255. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  33256. + (const:SI (unspec [(match_operand:SI 2 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))))]
  33257. + "METAG_HAVE_TLS"
  33258. + "ADD\\t%0, %1, #(%c2@TLSLDM)"
  33259. + [(set_attr "type" "fast")])
  33260. +
  33261. +(define_insn_and_split "tls_ldm"
  33262. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33263. + (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  33264. + (const:SI (unspec [(match_operand:SI 2 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))))]
  33265. + "METAG_HAVE_TLS && operands[1] == pic_offset_table_rtx"
  33266. + "#"
  33267. + "&& SPLIT_HI_LO_SUM_EARLY"
  33268. + [(set (match_dup 0)
  33269. + (match_dup 1))
  33270. + (set (match_dup 0)
  33271. + (plus:SI (match_dup 0)
  33272. + (const:SI (unspec [(match_dup 2)] UNSPEC_TLSLDM))))]
  33273. + ""
  33274. + [])
  33275. +
  33276. +;;Local dynamic insns to compute the location of the TLS object from the start of the current TLS block.
  33277. +(define_insn "*tls_ldo_high"
  33278. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33279. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  33280. + (high:SI (const:SI (unspec [(match_operand:SI 2 "tld_symbolic_operand" "")] UNSPEC_TLSLDO)))))]
  33281. + "METAG_HAVE_TLS"
  33282. + "ADDT\\t%0, %1, #HI(%c2@TLSLDO)"
  33283. + [(set_attr "type" "fast")])
  33284. +
  33285. +(define_insn "*tls_ldo_lo_sum"
  33286. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33287. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  33288. + (const:SI (unspec [(match_operand:SI 2 "tld_symbolic_operand" "")] UNSPEC_TLSLDO))))]
  33289. + "METAG_HAVE_TLS"
  33290. + "ADD\\t%0, %1, #LO(%c2@TLSLDO)"
  33291. + [(set_attr "type" "fast")])
  33292. +
  33293. +(define_insn_and_split "tls_ldo"
  33294. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33295. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  33296. + (const:SI (unspec [(match_operand:SI 2 "tld_symbolic_operand" "")] UNSPEC_TLSLDO))))]
  33297. + "METAG_HAVE_TLS"
  33298. + "#"
  33299. + "&& SPLIT_HI_LO_SUM_EARLY"
  33300. + [(set (match_dup 0)
  33301. + (match_dup 1))
  33302. + (set (match_dup 0)
  33303. + (plus:SI (match_dup 0)
  33304. + (high:SI (const:SI (unspec [(match_dup 2)] UNSPEC_TLSLDO)))))
  33305. + (set (match_dup 0)
  33306. + (lo_sum:SI (match_dup 0)
  33307. + (const:SI (unspec [(match_dup 2)] UNSPEC_TLSLDO))))]
  33308. + ""
  33309. + [])
  33310. +
  33311. +;;Initial exec insn for PIC.
  33312. +(define_insn "tls_ie"
  33313. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33314. + (mem:SI (plus:SI (match_operand:SI 1 "metag_pic_reg" "a")
  33315. + (const:SI (unspec [(match_operand:SI 2 "tie_symbolic_operand" "")] UNSPEC_TLSIE)))))]
  33316. + "METAG_HAVE_TLS && METAG_FLAG_PIC && operands[1] == pic_offset_table_rtx"
  33317. + "GETD\t%0, [A1LbP+#(%c2@TLSIE)]")
  33318. +
  33319. +;;Initial exec insns for non-PIC.
  33320. +(define_insn "*tls_non_pic_ie_high"
  33321. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33322. + (high:SI (const:SI (unspec [(match_operand:SI 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))))]
  33323. + "METAG_HAVE_TLS"
  33324. + "MOVT\\t%0, #HI(%c1@TLSIENONPIC)"
  33325. + [(set_attr "type" "fast")])
  33326. +
  33327. +(define_insn "*tls_non_pic_ie_lo_sum"
  33328. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33329. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  33330. + (const:SI (unspec [(match_operand:SI 2 "tie_symbolic_operand" "")] UNSPEC_TLSIE))))]
  33331. + "METAG_HAVE_TLS"
  33332. + "ADD\\t%0, %1, #LO(%c2@TLSIENONPIC)"
  33333. + [(set_attr "type" "fast")])
  33334. +
  33335. +(define_insn_and_split "tls_non_pic_ie"
  33336. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33337. + (const:SI (unspec [(match_operand:SI 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE)))]
  33338. + "METAG_HAVE_TLS"
  33339. + "#"
  33340. + "&& SPLIT_HI_LO_SUM_EARLY"
  33341. + [(set (match_dup 0)
  33342. + (high:SI (const:SI (unspec [(match_dup 1)] UNSPEC_TLSIE))))
  33343. + (set (match_dup 0)
  33344. + (lo_sum:SI (match_dup 0)
  33345. + (const:SI (unspec [(match_dup 1)] UNSPEC_TLSIE))))]
  33346. + ""
  33347. + [])
  33348. +
  33349. +;;Local exec insns
  33350. +(define_insn "*tls_le_high"
  33351. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33352. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  33353. + (high:SI (const:SI (unspec [(match_operand:SI 2 "tle_symbolic_operand" "")] UNSPEC_TLSLE)))))]
  33354. + "METAG_HAVE_TLS"
  33355. + "ADDT\\t%0, %1, #HI(%c2@TLSLE)"
  33356. + [(set_attr "type" "fast")])
  33357. +
  33358. +(define_insn "*tls_le_lo_sum"
  33359. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33360. + (lo_sum:SI (match_operand:SI 1 "metag_reg_nofloat_op" "0")
  33361. + (const:SI (unspec [(match_operand:SI 2 "tle_symbolic_operand" "")] UNSPEC_TLSLE))))]
  33362. + "METAG_HAVE_TLS"
  33363. + "ADD\\t%0, %1, #LO(%c2@TLSLE)"
  33364. + [(set_attr "type" "fast")])
  33365. +
  33366. +(define_insn_and_split "tls_le"
  33367. + [(set (match_operand:SI 0 "metag_reg_nofloat_op" "=da")
  33368. + (plus:SI (match_operand:SI 1 "metag_reg_nofloat_op" "da")
  33369. + (const:SI (unspec [(match_operand:SI 2 "tle_symbolic_operand" "")] UNSPEC_TLSLE))))]
  33370. + "METAG_HAVE_TLS"
  33371. + "#"
  33372. + "&& SPLIT_HI_LO_SUM_EARLY"
  33373. + [(set (match_dup 0)
  33374. + (match_dup 1))
  33375. + (set (match_dup 0)
  33376. + (plus:SI (match_dup 0)
  33377. + (high:SI (const:SI (unspec [(match_dup 2)] UNSPEC_TLSLE)))))
  33378. + (set (match_dup 0)
  33379. + (lo_sum:SI (match_dup 0)
  33380. + (const:SI (unspec [(match_dup 2)] UNSPEC_TLSLE))))]
  33381. + ""
  33382. + [])
  33383. +
  33384. +;;
  33385. +;; Predicates
  33386. +;;
  33387. +
  33388. +;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
  33389. +(define_predicate "tgd_symbolic_operand"
  33390. + (and (match_code "symbol_ref")
  33391. + (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))
  33392. +
  33393. +;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
  33394. +(define_predicate "tld_symbolic_operand"
  33395. + (and (match_code "symbol_ref")
  33396. + (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))
  33397. +
  33398. +;; Return true if OP is a symbolic operand for the TLS Initial Exec model.
  33399. +(define_predicate "tie_symbolic_operand"
  33400. + (and (match_code "symbol_ref")
  33401. + (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")))
  33402. +
  33403. +;; Return true if OP is a symbolic operand for the TLS Local Exec model.
  33404. +(define_predicate "tle_symbolic_operand"
  33405. + (and (match_code "symbol_ref")
  33406. + (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))
  33407. +
  33408. +;; end of file
  33409. +
  33410. diff -Nur gcc-4.2.4.orig/gcc/config/metag/t-metag gcc-4.2.4/gcc/config/metag/t-metag
  33411. --- gcc-4.2.4.orig/gcc/config/metag/t-metag 1969-12-31 18:00:00.000000000 -0600
  33412. +++ gcc-4.2.4/gcc/config/metag/t-metag 2015-07-03 18:46:05.773283541 -0500
  33413. @@ -0,0 +1,39 @@
  33414. +# Rules common to all metag targets
  33415. +# Copyright (C) 2011 Imagination Technologies Ltd
  33416. +
  33417. +# This file is part of GCC.
  33418. +
  33419. +# GCC is free software; you can redistribute it and/or modify it under
  33420. +# the terms of the GNU General Public License as published by the Free
  33421. +# Software Foundation; either version 3, or (at your option) any later
  33422. +# version.
  33423. +#
  33424. +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33425. +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33426. +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33427. +# for more details.
  33428. +#
  33429. +# You should have received a copy of the GNU General Public License
  33430. +# along with GCC; see the file COPYING3. If not see
  33431. +# <http://www.gnu.org/licenses/>.
  33432. +
  33433. +MD_INCLUDES=$(srcdir)/config/metag/constants.md \
  33434. + $(srcdir)/config/metag/predicates.md \
  33435. + $(srcdir)/config/metag/peephole2.md \
  33436. + $(srcdir)/config/metag/dsppeephole2.md \
  33437. + $(srcdir)/config/metag/constraints.md \
  33438. + $(srcdir)/config/metag/pipeline.md \
  33439. + $(srcdir)/config/metag/builtins.md \
  33440. + $(srcdir)/config/metag/peephole.md \
  33441. + $(srcdir)/config/metag/dsppeephole.md \
  33442. + $(srcdir)/config/metag/combines.md \
  33443. + $(srcdir)/config/metag/fp.md \
  33444. + $(srcdir)/config/metag/vector.md
  33445. +
  33446. +s-config s-conditions s-flags s-codes s-constants s-emit s-recog s-preds \
  33447. + s-opinit s-extract s-peep s-attr s-attrtab s-output: $(MD_INCLUDES)
  33448. +
  33449. +$(out_object_file): s-gtype
  33450. +
  33451. +driver-metag.o : $(srcdir)/config/metag/driver-metag.c
  33452. + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
  33453. diff -Nur gcc-4.2.4.orig/gcc/config/metag/t-metag-linux gcc-4.2.4/gcc/config/metag/t-metag-linux
  33454. --- gcc-4.2.4.orig/gcc/config/metag/t-metag-linux 1969-12-31 18:00:00.000000000 -0600
  33455. +++ gcc-4.2.4/gcc/config/metag/t-metag-linux 2015-07-03 18:46:05.773283541 -0500
  33456. @@ -0,0 +1,44 @@
  33457. +# t-metag-linux
  33458. +# Copyright (C) 2011 Imagination Technologies Ltd
  33459. +
  33460. +# This file is part of GCC.
  33461. +
  33462. +# GCC is free software; you can redistribute it and/or modify it under
  33463. +# the terms of the GNU General Public License as published by the Free
  33464. +# Software Foundation; either version 3, or (at your option) any later
  33465. +# version.
  33466. +#
  33467. +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33468. +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33469. +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33470. +# for more details.
  33471. +#
  33472. +# You should have received a copy of the GNU General Public License
  33473. +# along with GCC; see the file COPYING3. If not see
  33474. +# <http://www.gnu.org/licenses/>.
  33475. +
  33476. +# WORK NEEDED: We have to have minim versions of libraries but will also need
  33477. +# hardfloat variants
  33478. +MULTILIB_OPTIONS= mminim
  33479. +MULTILIB_DIRNAMES= minim
  33480. +MULTILIB_EXCEPTIONS=
  33481. +MULTILIB_MATCHES=
  33482. +
  33483. +# We want fine grained libraries, so use the new code to build the
  33484. +# floating point emulation libraries.
  33485. +FPBIT = fp-bit.c
  33486. +DPBIT = dp-bit.c
  33487. +
  33488. +fp-bit.c: $(srcdir)/config/fp-bit.c
  33489. + echo '#define FLOAT' >> fp-bit.c
  33490. + cat $(srcdir)/config/fp-bit.c >> fp-bit.c
  33491. +
  33492. +dp-bit.c: $(srcdir)/config/fp-bit.c
  33493. + cat $(srcdir)/config/fp-bit.c >> dp-bit.c
  33494. +
  33495. +metag-linux.o: $(srcdir)/config/metag/metag-linux.c $(CONFIG_H) $(SYSTEM_H) \
  33496. + coretypes.h $(TM_H) $(RTL_H) output.h flags.h $(TREE_H) \
  33497. + expr.h toplev.h $(TM_P_H)
  33498. + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
  33499. + $(srcdir)/config/metag/metag-linux.c
  33500. +
  33501. diff -Nur gcc-4.2.4.orig/gcc/config/metag/t-metag-slibgcc-elf-ver gcc-4.2.4/gcc/config/metag/t-metag-slibgcc-elf-ver
  33502. --- gcc-4.2.4.orig/gcc/config/metag/t-metag-slibgcc-elf-ver 1969-12-31 18:00:00.000000000 -0600
  33503. +++ gcc-4.2.4/gcc/config/metag/t-metag-slibgcc-elf-ver 2015-07-03 18:46:05.773283541 -0500
  33504. @@ -0,0 +1,37 @@
  33505. +# Build a shared libgcc library for ELF with symbol versioning
  33506. +# with the GNU linker.
  33507. +
  33508. +SHLIB_EXT = .so
  33509. +SHLIB_SOLINK = @shlib_base_name@.so
  33510. +SHLIB_SOVERSION = 1
  33511. +SHLIB_SONAME = @shlib_base_name@.so.$(SHLIB_SOVERSION)
  33512. +SHLIB_MAP = @shlib_map_file@
  33513. +SHLIB_OBJS = @shlib_objs@
  33514. +SHLIB_DIR = @multilib_dir@
  33515. +SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@
  33516. +SHLIB_LC = -lc
  33517. +
  33518. +SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
  33519. + -Wl,--soname=$(SHLIB_SONAME) \
  33520. + -Wl,--version-script=$(SHLIB_MAP) \
  33521. + -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
  33522. + $(SHLIB_OBJS) $(SHLIB_LC) && \
  33523. + rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
  33524. + if [ -f $(SHLIB_DIR)/$(SHLIB_SONAME) ]; then \
  33525. + mv -f $(SHLIB_DIR)/$(SHLIB_SONAME) \
  33526. + $(SHLIB_DIR)/$(SHLIB_SONAME).backup; \
  33527. + else true; fi && \
  33528. + mv $(SHLIB_DIR)/$(SHLIB_SONAME).tmp $(SHLIB_DIR)/$(SHLIB_SONAME) && \
  33529. + $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK)
  33530. +# $(slibdir) double quoted to protect it from expansion while building
  33531. +# libgcc.mk. We want this delayed until actual install time.
  33532. +SHLIB_INSTALL = \
  33533. + $$(mkinstalldirs) $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL); \
  33534. + $(INSTALL_DATA) $(SHLIB_DIR)/$(SHLIB_SONAME) \
  33535. + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SONAME); \
  33536. + rm -f $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK); \
  33537. + $(LN_S) $(SHLIB_SONAME) \
  33538. + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
  33539. +SHLIB_MKMAP = $(srcdir)/mkmap-symver.awk
  33540. +SHLIB_MKMAP_OPTS = -v leading_underscore=1 -v no_show_underscore=1
  33541. +SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver
  33542. diff -Nur gcc-4.2.4.orig/gcc/config/metag/vector.md gcc-4.2.4/gcc/config/metag/vector.md
  33543. --- gcc-4.2.4.orig/gcc/config/metag/vector.md 1969-12-31 18:00:00.000000000 -0600
  33544. +++ gcc-4.2.4/gcc/config/metag/vector.md 2015-07-03 18:46:05.773283541 -0500
  33545. @@ -0,0 +1,282 @@
  33546. +;; Machine description for GNU compiler,
  33547. +;; Imagination Technologies Meta version.
  33548. +;; Copyright (C) 2008
  33549. +;; Imagination Technologies Ltd
  33550. +
  33551. +;; This file is part of GCC.
  33552. +
  33553. +;; GCC is free software; you can redistribute it and/or modify it under
  33554. +;; the terms of the GNU General Public License as published by the Free
  33555. +;; Software Foundation; either version 3, or (at your option) any later
  33556. +;; version.
  33557. +
  33558. +;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33559. +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33560. +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33561. +;; for more details.
  33562. +
  33563. +;; You should have received a copy of the GNU General Public License
  33564. +;; along with GCC; see the file COPYING3. If not see
  33565. +;; <http://www.gnu.org/licenses/>.
  33566. +
  33567. +;; See comment at the top of dsppeephole.md for information about
  33568. +;; dual unit DSP support in the metag backend.
  33569. +
  33570. +(define_insn "*movv2sirr"
  33571. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33572. + (match_operand:V2SI 1 "metag_datareg_op" "d"))]
  33573. + "TARGET_DSP"
  33574. + "DL\\tMOV\\t%0,%1\\t%@ (*mov v2si rr)"
  33575. + [(set_attr "type" "fast")])
  33576. +
  33577. +(define_insn_and_split "*movv2siri"
  33578. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33579. + (match_operand:V2SI 1 "metag_vector_int_op" "vci"))]
  33580. + "TARGET_DSP
  33581. + && !reload_completed
  33582. + && !reload_in_progress"
  33583. + "#"
  33584. + ""
  33585. + [(set (match_dup 2)
  33586. + (match_dup 4))
  33587. + (set (match_dup 3)
  33588. + (match_dup 5))]
  33589. + {
  33590. + operands[2] = gen_rtx_SUBREG (SImode, operands[0], 0);
  33591. + operands[3] = gen_rtx_SUBREG (SImode, operands[0], UNITS_PER_WORD);
  33592. + operands[4] = XVECEXP (operands[1], 0, 0);
  33593. + operands[5] = XVECEXP (operands[1], 0, 1);
  33594. + }
  33595. + [(set_attr "type" "fast")])
  33596. +
  33597. +(define_expand "movv2si"
  33598. + [(set (match_operand:V2SI 0 "nonimmediate_operand" "")
  33599. + (match_operand:V2SI 1 "general_operand" ""))]
  33600. + "TARGET_DSP"
  33601. + {
  33602. + if (MEM_P (operands[0]) && !REG_P (operands[1]))
  33603. + {
  33604. + /* All except mem = const, mem = mem, or mem = addr can be done quickly */
  33605. + if (!no_new_pseudos)
  33606. + operands[1] = force_reg (V2SImode, operands[1]);
  33607. + }
  33608. +
  33609. + }
  33610. +)
  33611. +
  33612. +(define_insn "*lod_v2si"
  33613. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33614. + (match_operand:V2SI 1 "memory_operand" "m"))]
  33615. + "TARGET_DSP"
  33616. + "GETL\\t%0, %t0, %1\\t%@ (*lod v2si rm OK)"
  33617. + [(set_attr "memaccess" "load")])
  33618. +
  33619. +(define_insn "*sto_v2si"
  33620. + [(set (match_operand:V2SI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl,!*m")
  33621. + (match_operand:V2SI 1 "metag_datareg_op" "r, a, a, d, d, !*da"))]
  33622. + "TARGET_DSP && !reload_completed"
  33623. + "SETL\\t%0, %1, %t1\\t%@ (*sto v2si rm OK)"
  33624. + [(set_attr "type" "fast,fast,fast,fast,fast,invalid")])
  33625. +
  33626. +(define_insn "*sto_v2si_postreload"
  33627. + [(set (match_operand:V2SI 0 "memory_operand" "=Tr,Te,Tf,Th,Tl")
  33628. + (match_operand:V2SI 1 "metag_datareg_op" "r, a, a, d, d"))]
  33629. + "TARGET_DSP && reload_completed"
  33630. + "SETL\\t%0, %1, %t1\\t%@ (*sto v2si rm OK)"
  33631. + [(set_attr "type" "fast")])
  33632. +
  33633. +(define_expand "vec_setv2si"
  33634. + [(match_operand:V2SI 0 "metag_datareg_op" "=d")
  33635. + (match_operand:SI 1 "metag_register_op" "da")
  33636. + (match_operand 2 "const_int_operand" "i")]
  33637. + "TARGET_DSP"
  33638. + {
  33639. + rtx tmp = gen_reg_rtx (SImode);
  33640. +
  33641. + rtx tmp2 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (1, GEN_INT (1 - INTVAL (operands[2]))));
  33642. + tmp2 = gen_rtx_VEC_SELECT (SImode, operands[0], tmp2);
  33643. + emit_insn (gen_rtx_SET (VOIDmode, tmp, tmp2));
  33644. +
  33645. + if (INTVAL (operands[2]) == 0)
  33646. + tmp = gen_rtx_VEC_CONCAT (V2SImode, tmp, operands[1]);
  33647. + else
  33648. + tmp = gen_rtx_VEC_CONCAT (V2SImode, operands[1], tmp);
  33649. + emit_insn (gen_rtx_SET (VOIDmode, operands[0], tmp));
  33650. + DONE;
  33651. + })
  33652. +
  33653. +(define_insn_and_split "*vec_concatv2si"
  33654. + [(set (match_operand:V2SI 0 "metag_register_op" "=d")
  33655. + (vec_concat:V2SI (match_operand:SI 1 "metag_register_op" "d")
  33656. + (match_operand:SI 2 "metag_register_op" "d")))]
  33657. + "TARGET_DSP"
  33658. + "#"
  33659. + "&& reload_completed"
  33660. + [(set (match_dup 0)
  33661. + (match_dup 1))
  33662. + (set (match_dup 3)
  33663. + (match_dup 2))]
  33664. + {
  33665. + operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  33666. + operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
  33667. + }
  33668. + [(set_attr "type" "two")])
  33669. +
  33670. +(define_expand "vec_extractv2si"
  33671. + [(match_operand:SI 0 "metag_register_op" "=da")
  33672. + (match_operand:V2SI 1 "metag_register_op" "d")
  33673. + (match_operand 2 "const_int_operand" "i")]
  33674. + "TARGET_DSP"
  33675. + {
  33676. + rtx tmp = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (1, operands[2]));
  33677. + tmp = gen_rtx_VEC_SELECT (SImode, operands[1], tmp);
  33678. + emit_insn (gen_rtx_SET (VOIDmode, operands[0], tmp));
  33679. + DONE;
  33680. + })
  33681. +
  33682. +(define_insn "*vec_selectv2si"
  33683. + [(set (match_operand:SI 0 "metag_register_op" "=r")
  33684. + (vec_select:SI (match_operand:V2SI 1 "metag_datareg_op" "d")
  33685. + (parallel [(match_operand 2 "const_int_operand" "i")])))]
  33686. + "TARGET_DSP"
  33687. + {
  33688. + switch (INTVAL (operands[2]))
  33689. + {
  33690. + case 0:
  33691. + return "MOV\\t%0, %1\\t%@ (*vec_select v2si 0)";
  33692. + case 1:
  33693. + return "MOV\\t%0, %t1\\t%@ (*vec_select v2si 1)";
  33694. + default:
  33695. + gcc_unreachable ();
  33696. + }
  33697. + }
  33698. + [(set_attr "type" "fast")])
  33699. +
  33700. +(define_expand "vec_initv2si"
  33701. + [(match_operand:V2SI 0 "metag_datareg_op" "=d")
  33702. + (match_operand 1 "" "")]
  33703. + "TARGET_DSP"
  33704. + {
  33705. + rtx val0 = force_reg (SImode, XVECEXP (operands[1], 0, 0));
  33706. + rtx val1 = force_reg (SImode, XVECEXP (operands[1], 0, 1));
  33707. + rtx tmp = gen_rtx_VEC_CONCAT (V2SImode, val0, val1);
  33708. + emit_insn (gen_rtx_SET (VOIDmode, operands[0], tmp));
  33709. + DONE;
  33710. + })
  33711. +
  33712. +(define_insn "*<expander>v2siddi16"
  33713. + [(set (match_operand:V2SI 0 "metag_datareg_op" "+d")
  33714. + (3OPIMM16:V2SI (match_dup 0)
  33715. + (match_operand:V2SI 1 "metag_vector_16bit_op" "v16")))]
  33716. + "TARGET_DSP"
  33717. + "DL\\t<MNEMONIC>\\t\\t%0,%0,%1\\t%@(*<MNEMONIC> v2si ddi)"
  33718. + [(set_attr "type" "fast")])
  33719. +
  33720. +(define_insn "*<expander>v2siddi5"
  33721. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33722. + (3OPIMM5:V2SI (match_operand:V2SI 1 "metag_datareg_op" "d")
  33723. + (match_operand:V2SI 2 "metag_vector_5bit_op" "vc5")))]
  33724. + "TARGET_DSP"
  33725. + "DL\\t<MNEMONIC>\\t\\t%0,%1,%2\\t%@(*<MNEMONIC> v2si ddi)"
  33726. + [(set_attr "type" "fast")])
  33727. +
  33728. +(define_insn "<expander>v2si3"
  33729. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33730. + (3OPREG:V2SI (match_operand:V2SI 1 "metag_datareg_op" "d")
  33731. + (match_operand:V2SI 2 "metag_datareg_op" "d")))]
  33732. + "TARGET_DSP"
  33733. + "DL\\t<MNEMONIC>\\t\\t%0,%1,%2\\t%@(*<MNEMONIC> v2si ddd)"
  33734. + [(set_attr "type" "fast")])
  33735. +
  33736. +(define_insn "absv2si2"
  33737. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33738. + (abs:V2SI (match_operand:V2SI 1 "metag_datareg_op" "d")))
  33739. + (clobber (reg:CC CC_REG))]
  33740. + "TARGET_DSP"
  33741. + "DL\\tABS\\t\\t%0,%1\\t%@(*abs v2si dd)"
  33742. + [(set_attr "type" "fast")
  33743. + (set_attr "ccstate" "ccx")])
  33744. +
  33745. +(define_insn "negv2si2"
  33746. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33747. + (neg:V2SI (match_operand:V2SI 1 "metag_datareg_op" "d")))]
  33748. + "TARGET_DSP"
  33749. + "DL\\tNEG\\t\\t%0,%1\\t%@(*neg v2si dd)"
  33750. + [(set_attr "type" "fast")])
  33751. +
  33752. +(define_insn "<expander>v2si3"
  33753. + [(set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33754. + (MINMAX:V2SI (match_operand:V2SI 1 "metag_datareg_op" "d")
  33755. + (match_operand:V2SI 2 "metag_datareg_op" "d")))
  33756. + (clobber (reg:CC CC_REG))]
  33757. + "TARGET_DSP"
  33758. + "DL\\t<MNEMONIC>\\t\\t%0,%1,%2\\t%@(*<MNEMONIC> v2si ddd)"
  33759. + [(set_attr "type" "fast")
  33760. + (set_attr "ccstate" "ccx")])
  33761. +
  33762. +;; OP + flag set
  33763. +
  33764. +(define_insn "*<expander>sv2siddi16"
  33765. + [(set (reg:CC_NOOV CC_REG)
  33766. + (compare:CC_NOOV
  33767. + (3OPIMM16:SI (match_operand:SI 2 "metag_datareg_op" "d")
  33768. + (match_operand:SI 3 "metag_16bit_op" "KIP"))
  33769. + (const_int 0)))
  33770. + (set (match_operand:V2SI 0 "metag_datareg_op" "+d")
  33771. + (3OPIMM16:V2SI (match_dup 0)
  33772. + (match_operand:V2SI 1 "metag_vector_16bit_op" "v16")))]
  33773. + "TARGET_DSP
  33774. + && (REGNO (operands[2]) == REGNO (operands[0])
  33775. + || (REGNO (operands[2]) == REGNO (operands[0]) + 1))
  33776. + && INTVAL (operands[3]) == INTVAL (CONST_VECTOR_ELT (operands[1], 0))"
  33777. + {
  33778. + if (REGNO (operands[3]) == REGNO (operands[1]))
  33779. + return "DL\\t<MNEMONIC>S\\t\\t%0,%0,%1\\t%@(*<MNEMONIC>S v2si ddi)";
  33780. + else
  33781. + return "DL\\t<MNEMONIC>S\\t\\t%t0,%t0,%t1\\t%@(*<MNEMONIC>S v2si ddi)";
  33782. + }
  33783. + [(set_attr "type" "fast")])
  33784. +
  33785. +(define_insn "*<expander>sv2siddi5"
  33786. + [(set (reg:CC_NOOV CC_REG)
  33787. + (compare:CC_NOOV
  33788. + (3OPIMM5:SI (match_operand:SI 3 "metag_datareg_op" "d")
  33789. + (match_operand:SI 4 "metag_5bit_op" "L"))
  33790. + (const_int 0)))
  33791. + (set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33792. + (3OPIMM5:V2SI (match_operand:V2SI 1 "metag_datareg_op" "d")
  33793. + (match_operand:V2SI 2 "metag_vector_5bit_op" "v16")))]
  33794. + "TARGET_DSP
  33795. + && (REGNO (operands[3]) == REGNO (operands[1])
  33796. + || (REGNO (operands[3]) == REGNO (operands[1]) + 1))
  33797. + && INTVAL (operands[4]) == INTVAL (CONST_VECTOR_ELT (operands[2], 0))"
  33798. + {
  33799. + if (REGNO (operands[3]) == REGNO (operands[1]))
  33800. + return "DL\\t<MNEMONIC>S\\t\\t%0,%1,%2\\t%@(*<MNEMONIC>S v2si di)";
  33801. + else
  33802. + return "DL\\t<MNEMONIC>S\\t\\t%t0,%t1,%t2\\t%@(*<MNEMONIC>S v2si di)";
  33803. + }
  33804. + [(set_attr "type" "fast")])
  33805. +
  33806. +(define_insn "*<expander>sv2si3"
  33807. + [(set (reg:CC_NOOV CC_REG)
  33808. + (compare:CC_NOOV
  33809. + (3OPREG:SI (match_operand:SI 3 "metag_datareg_op" "d")
  33810. + (match_operand:SI 4 "metag_datareg_op" "d"))
  33811. + (const_int 0)))
  33812. + (set (match_operand:V2SI 0 "metag_datareg_op" "=d")
  33813. + (3OPREG:V2SI (match_operand:V2SI 1 "metag_datareg_op" "d")
  33814. + (match_operand:V2SI 2 "metag_datareg_op" "d")))]
  33815. + "TARGET_DSP
  33816. + && ((REGNO (operands[3]) == REGNO (operands[1])
  33817. + && REGNO (operands[4]) == REGNO (operands[2]))
  33818. + || (REGNO (operands[3]) == REGNO (operands[1]) + 1
  33819. + && REGNO (operands[4]) == REGNO (operands[2]) + 1))"
  33820. + {
  33821. + if (REGNO (operands[3]) == REGNO (operands[1]))
  33822. + return "DL\\t<MNEMONIC>S\\t\\t%0,%1,%2\\t%@(*<MNEMONIC>S v2si ddd)";
  33823. + else
  33824. + return "DL\\t<MNEMONIC>S\\t\\t%t0,%t1,%t2\\t%@(*<MNEMONIC>S v2si ddd)";
  33825. + }
  33826. + [(set_attr "type" "fast")])
  33827. +
  33828. diff -Nur gcc-4.2.4.orig/gcc/config/metag/x-metag-linux gcc-4.2.4/gcc/config/metag/x-metag-linux
  33829. --- gcc-4.2.4.orig/gcc/config/metag/x-metag-linux 1969-12-31 18:00:00.000000000 -0600
  33830. +++ gcc-4.2.4/gcc/config/metag/x-metag-linux 2015-07-03 18:46:05.773283541 -0500
  33831. @@ -0,0 +1,20 @@
  33832. +# Configuration for GNU C-compiler.
  33833. +# Imagination Technologies Meta version.
  33834. +# Copyright (C) 2001, 2004, 2007 Imagination Technologies Ltd
  33835. +
  33836. +# This file is part of GCC.
  33837. +
  33838. +# GCC is free software; you can redistribute it and/or modify it under
  33839. +# the terms of the GNU General Public License as published by the Free
  33840. +# Software Foundation; either version 3, or (at your option) any later
  33841. +# version.
  33842. +
  33843. +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33844. +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33845. +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33846. +# for more details.
  33847. +
  33848. +# You should have received a copy of the GNU General Public License
  33849. +# along with GCC; see the file COPYING3. If not see
  33850. +# <http://www.gnu.org/licenses/>.
  33851. +
  33852. diff -Nur gcc-4.2.4.orig/gcc/config/metag/xm-metag-linux gcc-4.2.4/gcc/config/metag/xm-metag-linux
  33853. --- gcc-4.2.4.orig/gcc/config/metag/xm-metag-linux 1969-12-31 18:00:00.000000000 -0600
  33854. +++ gcc-4.2.4/gcc/config/metag/xm-metag-linux 2015-07-03 18:46:05.773283541 -0500
  33855. @@ -0,0 +1,20 @@
  33856. +# Configuration for GNU C-compiler.
  33857. +# Imagination Technologies Meta version.
  33858. +# Copyright (C) 2001, 2004, 2007 Imagination Technologies Ltd
  33859. +
  33860. +# This file is part of GCC.
  33861. +
  33862. +# GCC is free software; you can redistribute it and/or modify it under
  33863. +# the terms of the GNU General Public License as published by the Free
  33864. +# Software Foundation; either version 3, or (at your option) any later
  33865. +# version.
  33866. +
  33867. +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  33868. +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
  33869. +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  33870. +# for more details.
  33871. +
  33872. +# You should have received a copy of the GNU General Public License
  33873. +# along with GCC; see the file COPYING3. If not see
  33874. +# <http://www.gnu.org/licenses/>.
  33875. +
  33876. diff -Nur gcc-4.2.4.orig/gcc/config.gcc gcc-4.2.4/gcc/config.gcc
  33877. --- gcc-4.2.4.orig/gcc/config.gcc 2008-03-13 14:11:43.000000000 -0500
  33878. +++ gcc-4.2.4/gcc/config.gcc 2015-07-03 18:46:05.717283542 -0500
  33879. @@ -291,6 +291,9 @@
  33880. m68k-*-*)
  33881. extra_headers=math-68881.h
  33882. ;;
  33883. +metag*-*-*)
  33884. + cpu_type=metag
  33885. + ;;
  33886. mips*-*-*)
  33887. cpu_type=mips
  33888. need_64bit_hwint=yes
  33889. @@ -332,6 +335,74 @@
  33890. ;;
  33891. esac
  33892. +case ${cpu_type} in
  33893. +metag)
  33894. + tm_defines="${tm_defines} METAG_EXEC_PREFIX=\\\"\$(exec_prefix)/\\\""
  33895. +
  33896. + # Set the default core if with_cpu is not defined
  33897. + if test x${with_cpu} = x
  33898. + then
  33899. + if test x${cpu_type} = xmetag
  33900. + then
  33901. + with_cpu=2.1
  33902. + else
  33903. + with_cpu=1.2
  33904. + fi
  33905. + fi
  33906. +
  33907. + # Set the default tune if with_tune is not defined
  33908. + if test x${with_tune} = x
  33909. + then
  33910. + if test x${cpu_type} = xmetag
  33911. + then
  33912. + with_tune=2.1
  33913. + fi
  33914. + fi
  33915. +
  33916. + # Set the default fpu if with_fpu is not defined
  33917. + if test x${with_fpu} = x
  33918. + then
  33919. + if test x${cpu_type} = xmetag
  33920. + then
  33921. + with_fpu=none
  33922. + fi
  33923. + fi
  33924. +
  33925. + case x${with_cpu} in
  33926. + x2.1)
  33927. + tm_defines="${tm_defines} METAC_DEFAULT=\\\"2.1\\\" METAC_DEFAULT_AS=\\\"METAC_2_1\\\""
  33928. + ;;
  33929. + x1.2)
  33930. + tm_defines="${tm_defines} METAC_DEFAULT=\\\"1.2\\\" METAC_DEFAULT_AS=\\\"METAC_1_2\\\""
  33931. + ;;
  33932. + x1.1)
  33933. + tm_defines="${tm_defines} METAC_DEFAULT=\\\"1.1\\\" METAC_DEFAULT_AS=\\\"METAC_1_1\\\""
  33934. + ;;
  33935. + x1.0)
  33936. + tm_defines="${tm_defines} METAC_DEFAULT=\\\"1.0\\\" METAC_DEFAULT_AS=\\\"METAC_1_0\\\""
  33937. + ;;
  33938. + x0.1)
  33939. + tm_defines="${tm_defines} METAC_DEFAULT=\\\"0.1\\\" METAC_DEFAULT_AS=\\\"METAC_0_1\\\""
  33940. + ;;
  33941. + x*)
  33942. + echo "--with-cpu=\"${with_cpu}\" not recognised",
  33943. + exit 1;
  33944. + ;;
  33945. + esac
  33946. +
  33947. + case x${enable_meta_default} in
  33948. + xyes)
  33949. + # Nothing
  33950. + ;;
  33951. + x*)
  33952. + # When not explicitly META, enable MiniM
  33953. + tm_defines="${tm_defines} MINIM_DEFAULT"
  33954. + ;;
  33955. + esac
  33956. + ;;
  33957. +esac
  33958. +
  33959. +
  33960. tm_file=${cpu_type}/${cpu_type}.h
  33961. if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-protos.h
  33962. then
  33963. @@ -481,6 +552,15 @@
  33964. # Assume that glibc or uClibc are being used and so __cxa_atexit is provided.
  33965. default_use_cxa_atexit=yes
  33966. ;;
  33967. +metag*-linux-uclibc*)
  33968. + gas=yes
  33969. + gnu_ld=yes
  33970. + case ${enable_threads} in
  33971. + "" | yes | posix) thread_file='posix' ;;
  33972. + esac
  33973. + # uClibc provides __cxa_atexit
  33974. + default_use_cxa_atexit=yes
  33975. + ;;
  33976. *-*-gnu*)
  33977. # On the Hurd, the setup is just about the same on
  33978. # each different CPU. The specific machines that we
  33979. @@ -1518,6 +1598,31 @@
  33980. tmake_file=mcore/t-mcore-pe
  33981. use_fixproto=yes
  33982. ;;
  33983. +metag*-linux-uclibc*)
  33984. + tm_file="dbxelf.h elfos.h metag/metag.h metag/metag-linux.h linux.h metag/linux.h metag/elf.h metag/linux-elf.h"
  33985. + tmake_file="metag/t-metag-slibgcc-elf-ver metag/t-metag metag/t-metag-linux metag/t-linux"
  33986. + target_cpu_default=""
  33987. + tm_defines="${tm_defines} METAG_BFD"
  33988. + extra_gcc_objs="driver-metag.o"
  33989. + out_file=metag/metag.c
  33990. + use_fixproto=no
  33991. + use_collect2=no
  33992. + extra_objs="metag-linux.o"
  33993. + extra_options="${extra_options} metag/metag-linux.opt"
  33994. + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
  33995. +
  33996. + case x${enable_link_global} in
  33997. + xyes)
  33998. + tm_defines="${tm_defines} METAG_LINK_GLOBAL"
  33999. + ;;
  34000. + esac
  34001. +
  34002. + case x${with_cpu} in
  34003. + x2.1)
  34004. + tmake_file="${tmake_file} metag/t-linux-2.1"
  34005. + ;;
  34006. + esac
  34007. + ;;
  34008. mips-sgi-irix[56]*)
  34009. tm_file="elfos.h ${tm_file} mips/iris.h"
  34010. tmake_file="mips/t-iris mips/t-slibgcc-irix"
  34011. @@ -2757,6 +2862,46 @@
  34012. esac
  34013. ;;
  34014. + metag*)
  34015. + supported_defaults="cpu tune fpu"
  34016. + case "$with_cpu" in
  34017. + "" | 1.0 | 1.1 | 1.2 | 2.1 | 0.1)
  34018. + # OK
  34019. + ;;
  34020. + *)
  34021. + echo "Unknown CPU used in --with-cpu=$with_cpu, known values:" 1>&2
  34022. + echo "1.0 1.1 1.2 2.1 0.1" 1>&2
  34023. + exit 1
  34024. + ;;
  34025. + esac
  34026. +
  34027. + case "$with_tune" in
  34028. + "" | 1.0 | 1.1 | 1.2 | 2.1 | 0.1)
  34029. + # OK
  34030. + ;;
  34031. + *)
  34032. + echo "Unknown CPU used in --with-tune=$with_tune, known values:" 1>&2
  34033. + echo "1.0 1.1 1.2 2.1 0.1" 1>&2
  34034. + exit 1
  34035. + ;;
  34036. + esac
  34037. +
  34038. + case "$with_fpu" in
  34039. + none | S | D)
  34040. + # OK
  34041. + ;;
  34042. + yes)
  34043. + with_fpu=D
  34044. + ;;
  34045. + *)
  34046. + echo "Unknown FPU precision used in --with-fpu=$with_fpu, known values:" 1>&2
  34047. + echo "S D" 1>&2
  34048. + exit 1
  34049. + ;;
  34050. + esac
  34051. +
  34052. + ;;
  34053. +
  34054. hppa*-*-* | parisc*-*-*)
  34055. supported_defaults="arch schedule"
  34056. diff -Nur gcc-4.2.4.orig/gcc/crtstuff.c gcc-4.2.4/gcc/crtstuff.c
  34057. --- gcc-4.2.4.orig/gcc/crtstuff.c 2006-05-15 22:49:57.000000000 -0500
  34058. +++ gcc-4.2.4/gcc/crtstuff.c 2015-07-03 18:46:05.717283542 -0500
  34059. @@ -207,7 +207,7 @@
  34060. = { };
  34061. #endif /* USE_EH_FRAME_REGISTRY */
  34062. -#ifdef JCR_SECTION_NAME
  34063. +#if TARGET_USE_JCR_SECTION && defined(JCR_SECTION_NAME)
  34064. /* Stick a label at the beginning of the java class registration info
  34065. so we can register them properly. */
  34066. STATIC void *__JCR_LIST__[]
  34067. @@ -242,6 +242,20 @@
  34068. extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK;
  34069. /* Run all the global destructors on exit from the program. */
  34070. +
  34071. +#ifndef DO_GLOBAL_DTORS_AUX_BODY
  34072. +#define DO_GLOBAL_DTORS_AUX_BODY \
  34073. +do { \
  34074. + static func_ptr *p = __DTOR_LIST__ + 1; \
  34075. + func_ptr f; \
  34076. + \
  34077. + while ((f = *p)) \
  34078. + { \
  34079. + p++; \
  34080. + f (); \
  34081. + } \
  34082. +} while (0)
  34083. +#endif
  34084. /* Some systems place the number of pointers in the first word of the
  34085. table. On SVR4 however, that word is -1. In all cases, the table is
  34086. @@ -263,10 +277,6 @@
  34087. static void __attribute__((used))
  34088. __do_global_dtors_aux (void)
  34089. {
  34090. -#ifndef FINI_ARRAY_SECTION_ASM_OP
  34091. - static func_ptr *p = __DTOR_LIST__ + 1;
  34092. - func_ptr f;
  34093. -#endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */
  34094. static _Bool completed;
  34095. if (__builtin_expect (completed, 0))
  34096. @@ -281,11 +291,7 @@
  34097. /* If we are using .fini_array then destructors will be run via that
  34098. mechanism. */
  34099. #else /* !defined (FINI_ARRAY_SECTION_ASM_OP) */
  34100. - while ((f = *p))
  34101. - {
  34102. - p++;
  34103. - f ();
  34104. - }
  34105. + DO_GLOBAL_DTORS_AUX_BODY;
  34106. #endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */
  34107. #ifdef USE_EH_FRAME_REGISTRY
  34108. @@ -312,7 +318,7 @@
  34109. = { __do_global_dtors_aux };
  34110. #endif /* !defined(FINI_SECTION_ASM_OP) */
  34111. -#if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
  34112. +#if defined(USE_EH_FRAME_REGISTRY) || (TARGET_USE_JCR_SECTION && defined(JCR_SECTION_NAME))
  34113. /* Stick a call to __register_frame_info into the .init section. For some
  34114. reason calls with no arguments work more reliably in .init, so stick the
  34115. call in another function. */
  34116. @@ -333,7 +339,7 @@
  34117. __register_frame_info (__EH_FRAME_BEGIN__, &object);
  34118. #endif /* CRT_GET_RFIB_DATA */
  34119. #endif /* USE_EH_FRAME_REGISTRY */
  34120. -#ifdef JCR_SECTION_NAME
  34121. +#if TARGET_USE_JCR_SEVTION && defined(JCR_SECTION_NAME)
  34122. if (__JCR_LIST__[0])
  34123. {
  34124. void (*register_classes) (void *) = _Jv_RegisterClasses;
  34125. @@ -397,6 +403,15 @@
  34126. extern void __do_global_dtors (void);
  34127. +#ifndef DO_GLOBAL_DTORS_BODY
  34128. +#define DO_GLOBAL_DTORS_BODY \
  34129. +do { \
  34130. + func_ptr *p, f; \
  34131. + for (p = __DTOR_LIST__ + 1; (f = *p); p++) \
  34132. + f (); \
  34133. +} while (0)
  34134. +#endif
  34135. +
  34136. /* This case is used by the Irix 6 port, which supports named sections but
  34137. not an SVR4-style .fini section. __do_global_dtors can be non-static
  34138. in this case because we protect it with -hidden_symbol. */
  34139. @@ -404,9 +419,7 @@
  34140. void
  34141. __do_global_dtors (void)
  34142. {
  34143. - func_ptr *p, f;
  34144. - for (p = __DTOR_LIST__ + 1; (f = *p); p++)
  34145. - f ();
  34146. + DO_GLOBAL_DTORS_BODY;
  34147. #ifdef USE_EH_FRAME_REGISTRY
  34148. if (__deregister_frame_info)
  34149. @@ -414,7 +427,7 @@
  34150. #endif
  34151. }
  34152. -#if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
  34153. +#if defined(USE_EH_FRAME_REGISTRY) || (TARGET_USE_JCR_SECTION && defined(JCR_SECTION_NAME))
  34154. /* A helper function for __do_global_ctors, which is in crtend.o. Here
  34155. in crtbegin.o, we can reference a couple of symbols not visible there.
  34156. Plus, since we're before libgcc.a, we have no problems referencing
  34157. @@ -427,7 +440,7 @@
  34158. if (__register_frame_info)
  34159. __register_frame_info (__EH_FRAME_BEGIN__, &object);
  34160. #endif
  34161. -#ifdef JCR_SECTION_NAME
  34162. +#if TARGET_USE_JCR_SECTION && defined (JCR_SECTION_NAME)
  34163. if (__JCR_LIST__[0])
  34164. {
  34165. void (*register_classes) (void *) = _Jv_RegisterClasses;
  34166. @@ -498,7 +511,7 @@
  34167. = { 0 };
  34168. #endif /* EH_FRAME_SECTION_NAME */
  34169. -#ifdef JCR_SECTION_NAME
  34170. +#if TARGET_USE_JCR_SECTION && defined(JCR_SECTION_NAME)
  34171. /* Null terminate the .jcr section array. */
  34172. STATIC void *__JCR_END__[1]
  34173. __attribute__ ((unused, section(JCR_SECTION_NAME),
  34174. @@ -513,12 +526,20 @@
  34175. #elif defined(INIT_SECTION_ASM_OP)
  34176. #ifdef OBJECT_FORMAT_ELF
  34177. +
  34178. +#ifndef DO_GLOBAL_CTORS_AUX_BODY
  34179. +#define DO_GLOBAL_CTORS_AUX_BODY \
  34180. +do { \
  34181. + func_ptr *p; \
  34182. + for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--) \
  34183. + (*p)(); \
  34184. +} while (0)
  34185. +#endif
  34186. +
  34187. static void __attribute__((used))
  34188. __do_global_ctors_aux (void)
  34189. {
  34190. - func_ptr *p;
  34191. - for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
  34192. - (*p) ();
  34193. + DO_GLOBAL_CTORS_AUX_BODY;
  34194. }
  34195. /* Stick a call to __do_global_ctors_aux into the .init section. */
  34196. @@ -561,6 +582,16 @@
  34197. #elif defined(HAS_INIT_SECTION) /* ! INIT_SECTION_ASM_OP */
  34198. +#ifndef DO_GLOBAL_CTORS_BODY
  34199. +#define DO_GLOBAL_CTORS_BODY \
  34200. +do { \
  34201. + func_ptr *p; \
  34202. + \
  34203. + for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--) \
  34204. + (*p) (); \
  34205. +} while (0)
  34206. +#endif
  34207. +
  34208. extern void __do_global_ctors (void);
  34209. /* This case is used by the Irix 6 port, which supports named sections but
  34210. @@ -573,8 +604,7 @@
  34211. #if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
  34212. __do_global_ctors_1();
  34213. #endif
  34214. - for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
  34215. - (*p) ();
  34216. + DO_GLOBAL_CTORS_BODY;
  34217. }
  34218. #else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */
  34219. diff -Nur gcc-4.2.4.orig/gcc/cse.c gcc-4.2.4/gcc/cse.c
  34220. --- gcc-4.2.4.orig/gcc/cse.c 2008-01-14 06:18:30.000000000 -0600
  34221. +++ gcc-4.2.4/gcc/cse.c 2015-07-03 18:46:05.721283542 -0500
  34222. @@ -4881,6 +4881,17 @@
  34223. }
  34224. }
  34225. +#ifdef AUTO_INC_DEC
  34226. + /* Invalidate all AUTO inc registers. */
  34227. + {
  34228. + rtx link;
  34229. +
  34230. + for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
  34231. + if (REG_NOTE_KIND (link) == REG_INC)
  34232. + invalidate (XEXP (link, 0), VOIDmode);
  34233. + }
  34234. +#endif
  34235. +
  34236. if (GET_CODE (x) == SET)
  34237. {
  34238. sets = alloca (sizeof (struct set));
  34239. diff -Nur gcc-4.2.4.orig/gcc/expr.c gcc-4.2.4/gcc/expr.c
  34240. --- gcc-4.2.4.orig/gcc/expr.c 2008-02-04 16:03:09.000000000 -0600
  34241. +++ gcc-4.2.4/gcc/expr.c 2015-07-03 18:46:05.721283542 -0500
  34242. @@ -3652,9 +3652,23 @@
  34243. /* USED is now the # of bytes we need not copy to the stack
  34244. because registers will take care of them. */
  34245. -
  34246. if (partial != 0)
  34247. - xinner = adjust_address (xinner, BLKmode, used);
  34248. + {
  34249. +#ifdef METAG_PARTIAL_ARGS
  34250. + if (GET_CODE (size) == CONST_INT)
  34251. + {
  34252. + HOST_WIDE_INT onstack = INTVAL (size) - partial;
  34253. +
  34254. + onstack = (onstack + (STACK_BOUNDARY_BYTES - 1)) & ~(STACK_BOUNDARY_BYTES - 1);
  34255. +
  34256. + size = GEN_INT (onstack + partial);
  34257. + }
  34258. + else
  34259. + gcc_unreachable ();
  34260. +#else
  34261. + xinner = adjust_address (xinner, BLKmode, used);
  34262. +#endif
  34263. + }
  34264. /* If the partial register-part of the arg counts in its stack size,
  34265. skip the part of stack space corresponding to the registers.
  34266. @@ -3765,6 +3779,8 @@
  34267. int offset = partial % (PARM_BOUNDARY / BITS_PER_UNIT);
  34268. int args_offset = INTVAL (args_so_far);
  34269. int skip;
  34270. + int begin_on_stack;
  34271. + int end_on_stack;
  34272. /* Push padding now if padding above and stack grows down,
  34273. or if padding below and stack grows up.
  34274. @@ -3784,11 +3800,19 @@
  34275. not_stack = (partial - offset) / UNITS_PER_WORD;
  34276. offset /= UNITS_PER_WORD;
  34277. +#ifdef METAG_PARTIAL_ARGS
  34278. + begin_on_stack = 0;
  34279. + end_on_stack = size - not_stack;
  34280. +#else
  34281. + begin_on_stack = not_stack;
  34282. + end_on_stack = size;
  34283. +#endif
  34284. +
  34285. /* If the partial register-part of the arg counts in its stack size,
  34286. skip the part of stack space corresponding to the registers.
  34287. Otherwise, start copying to the beginning of the stack space,
  34288. by setting SKIP to 0. */
  34289. - skip = (reg_parm_stack_space == 0) ? 0 : not_stack;
  34290. + skip = (reg_parm_stack_space == 0) ? 0 : begin_on_stack;
  34291. if (CONSTANT_P (x) && ! LEGITIMATE_CONSTANT_P (x))
  34292. x = validize_mem (force_const_mem (mode, x));
  34293. @@ -3803,15 +3827,15 @@
  34294. /* We can do it by words, because any scalar bigger than a word
  34295. has a size a multiple of a word. */
  34296. #ifndef PUSH_ARGS_REVERSED
  34297. - for (i = not_stack; i < size; i++)
  34298. + for (i = begin_on_stack; i < end_on_stack; i++)
  34299. #else
  34300. - for (i = size - 1; i >= not_stack; i--)
  34301. + for (i = end_on_stack - 1; i >= begin_on_stack; i--)
  34302. #endif
  34303. - if (i >= not_stack + offset)
  34304. + if (i >= begin_on_stack + offset)
  34305. emit_push_insn (operand_subword_force (x, i, mode),
  34306. word_mode, NULL_TREE, NULL_RTX, align, 0, NULL_RTX,
  34307. 0, args_addr,
  34308. - GEN_INT (args_offset + ((i - not_stack + skip)
  34309. + GEN_INT (args_offset + ((i - begin_on_stack + skip)
  34310. * UNITS_PER_WORD)),
  34311. reg_parm_stack_space, alignment_pad);
  34312. }
  34313. @@ -3867,8 +3891,32 @@
  34314. emit_group_load (reg, x, type, -1);
  34315. else
  34316. {
  34317. + xinner = x;
  34318. +
  34319. +#ifdef METAG_PARTIAL_ARGS
  34320. + if (mode != BLKmode)
  34321. + size = GEN_INT (GET_MODE_SIZE (mode) - partial);
  34322. +
  34323. + gcc_assert (size && GET_CODE (size) == CONST_INT);
  34324. +
  34325. + if (GET_CODE (xinner) == CONCAT)
  34326. + {
  34327. + xinner = XEXP (xinner, 1);
  34328. + mode = GET_MODE (xinner);
  34329. +
  34330. + gcc_assert (INTVAL (size) == GET_MODE_SIZE (mode));
  34331. + }
  34332. + else if (GET_CODE (xinner) == MEM)
  34333. + {
  34334. + gcc_assert ((INTVAL (size) & (STACK_BOUNDARY_BYTES - 1)) == 0);
  34335. + xinner = adjust_address (xinner, mode, INTVAL (size) );
  34336. + }
  34337. + else
  34338. + gcc_unreachable ();
  34339. +#endif
  34340. +
  34341. gcc_assert (partial % UNITS_PER_WORD == 0);
  34342. - move_block_to_reg (REGNO (reg), x, partial / UNITS_PER_WORD, mode);
  34343. + move_block_to_reg (REGNO (reg), xinner, partial / UNITS_PER_WORD, mode);
  34344. }
  34345. }
  34346. @@ -4779,7 +4827,14 @@
  34347. case UNION_TYPE:
  34348. case QUAL_UNION_TYPE:
  34349. - return -1;
  34350. + {
  34351. + /* Ho hum. How in the world do we guess here? Clearly it isn't
  34352. + right to count the fields. Guess based on the number of words. */
  34353. + HOST_WIDE_INT n = int_size_in_bytes (type);
  34354. + if (n < 0)
  34355. + return -1;
  34356. + return n / UNITS_PER_WORD;
  34357. + }
  34358. case COMPLEX_TYPE:
  34359. return 2;
  34360. diff -Nur gcc-4.2.4.orig/gcc/function.c gcc-4.2.4/gcc/function.c
  34361. --- gcc-4.2.4.orig/gcc/function.c 2007-09-01 10:28:30.000000000 -0500
  34362. +++ gcc-4.2.4/gcc/function.c 2015-07-03 18:46:05.721283542 -0500
  34363. @@ -2245,7 +2245,11 @@
  34364. gcc_assert (!all->extra_pretend_bytes && !all->pretend_args_size);
  34365. pretend_bytes = partial;
  34366. +#ifdef METAG_PARTIAL_ARGS
  34367. + all->pretend_args_size = pretend_bytes;
  34368. +#else
  34369. all->pretend_args_size = CEIL_ROUND (pretend_bytes, STACK_BYTES);
  34370. +#endif
  34371. /* We want to align relative to the actual stack pointer, so
  34372. don't include this in the stack size until later. */
  34373. @@ -2259,8 +2263,13 @@
  34374. /* Adjust offsets to include the pretend args. */
  34375. pretend_bytes = all->extra_pretend_bytes - pretend_bytes;
  34376. - data->locate.slot_offset.constant += pretend_bytes;
  34377. - data->locate.offset.constant += pretend_bytes;
  34378. +#ifdef METAG_PARTIAL_ARGS
  34379. + if (data->partial != 0)
  34380. +#endif
  34381. + {
  34382. + data->locate.slot_offset.constant += pretend_bytes;
  34383. + data->locate.offset.constant += pretend_bytes;
  34384. + }
  34385. data->entry_parm = entry_parm;
  34386. }
  34387. @@ -2369,8 +2378,10 @@
  34388. else
  34389. {
  34390. gcc_assert (data->partial % UNITS_PER_WORD == 0);
  34391. +#ifndef METAG_PARTIAL_ARGS
  34392. move_block_from_reg (REGNO (entry_parm), validize_mem (stack_parm),
  34393. data->partial / UNITS_PER_WORD);
  34394. +#endif
  34395. }
  34396. entry_parm = stack_parm;
  34397. @@ -3062,8 +3073,10 @@
  34398. /* We have aligned all the args, so add space for the pretend args. */
  34399. current_function_pretend_args_size = all.pretend_args_size;
  34400. +#ifndef METAG_PARTIAL_ARGS
  34401. all.stack_args_size.constant += all.extra_pretend_bytes;
  34402. current_function_args_size = all.stack_args_size.constant;
  34403. +#endif
  34404. /* Adjust function incoming argument size for alignment and
  34405. minimum length. */
  34406. diff -Nur gcc-4.2.4.orig/gcc/genattrtab.c gcc-4.2.4/gcc/genattrtab.c
  34407. --- gcc-4.2.4.orig/gcc/genattrtab.c 2007-09-01 10:28:30.000000000 -0500
  34408. +++ gcc-4.2.4/gcc/genattrtab.c 2015-07-03 18:46:05.721283542 -0500
  34409. @@ -4582,7 +4582,6 @@
  34410. printf ("#include \"coretypes.h\"\n");
  34411. printf ("#include \"tm.h\"\n");
  34412. printf ("#include \"rtl.h\"\n");
  34413. - printf ("#include \"tm_p.h\"\n");
  34414. printf ("#include \"insn-config.h\"\n");
  34415. printf ("#include \"recog.h\"\n");
  34416. printf ("#include \"regs.h\"\n");
  34417. @@ -4592,6 +4591,7 @@
  34418. printf ("#include \"toplev.h\"\n");
  34419. printf ("#include \"flags.h\"\n");
  34420. printf ("#include \"function.h\"\n");
  34421. + printf ("#include \"tm_p.h\"\n");
  34422. printf ("\n");
  34423. printf ("#define operands recog_data.operand\n\n");
  34424. diff -Nur gcc-4.2.4.orig/gcc/genmodes.c gcc-4.2.4/gcc/genmodes.c
  34425. --- gcc-4.2.4.orig/gcc/genmodes.c 2007-09-01 10:28:30.000000000 -0500
  34426. +++ gcc-4.2.4/gcc/genmodes.c 2015-07-03 18:46:05.725283542 -0500
  34427. @@ -785,8 +785,7 @@
  34428. /* Output routines. */
  34429. #define tagged_printf(FMT, ARG, TAG) do { \
  34430. - int count_; \
  34431. - printf (" " FMT ",%n", ARG, &count_); \
  34432. + int count_ = printf (" " FMT ",", ARG); \
  34433. printf ("%*s/* %s */\n", 27 - count_, "", TAG); \
  34434. } while (0)
  34435. @@ -820,8 +819,7 @@
  34436. for (c = 0; c < MAX_MODE_CLASS; c++)
  34437. for (m = modes[c]; m; m = m->next)
  34438. {
  34439. - int count_;
  34440. - printf (" %smode,%n", m->name, &count_);
  34441. + int count_ = printf (" %smode,", m->name);
  34442. printf ("%*s/* %s:%d */\n", 27 - count_, "",
  34443. trim_filename (m->file), m->line);
  34444. }
  34445. diff -Nur gcc-4.2.4.orig/gcc/genopinit.c gcc-4.2.4/gcc/genopinit.c
  34446. --- gcc-4.2.4.orig/gcc/genopinit.c 2007-09-01 10:28:30.000000000 -0500
  34447. +++ gcc-4.2.4/gcc/genopinit.c 2015-07-03 18:46:05.725283542 -0500
  34448. @@ -1,6 +1,7 @@
  34449. /* Generate code to initialize optabs from machine description.
  34450. Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
  34451. - 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
  34452. + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010
  34453. + Free Software Foundation, Inc.
  34454. This file is part of GCC.
  34455. @@ -414,7 +415,8 @@
  34456. printf ("#include \"recog.h\"\n");
  34457. printf ("#include \"expr.h\"\n");
  34458. printf ("#include \"optabs.h\"\n");
  34459. - printf ("#include \"reload.h\"\n\n");
  34460. + printf ("#include \"reload.h\"\n");
  34461. + printf ("#include \"toplev.h\"\n\n");
  34462. printf ("void\ninit_all_optabs (void)\n{\n");
  34463. diff -Nur gcc-4.2.4.orig/gcc/loop-doloop.c gcc-4.2.4/gcc/loop-doloop.c
  34464. --- gcc-4.2.4.orig/gcc/loop-doloop.c 2007-09-01 10:28:30.000000000 -0500
  34465. +++ gcc-4.2.4/gcc/loop-doloop.c 2015-07-03 18:46:05.725283542 -0500
  34466. @@ -65,6 +65,10 @@
  34467. #ifdef HAVE_doloop_end
  34468. +#ifndef DECREMENT_AND_BRANCH_REG
  34469. +#define DECREMENT_AND_BRANCH_REG(MODE) gen_reg_rtx (MODE)
  34470. +#endif
  34471. +
  34472. /* Return the loop termination condition for PATTERN or zero
  34473. if it is not a decrement and branch jump insn. */
  34474. @@ -358,6 +362,10 @@
  34475. if (increment_count)
  34476. count = simplify_gen_binary (PLUS, mode, count, const1_rtx);
  34477. + /* CONST_INT's must be correctly sign-extended for mode. */
  34478. + if (CONST_INT_P (count))
  34479. + count = gen_int_mode (INTVAL (count), mode);
  34480. +
  34481. /* Insert initialization of the count register into the loop header. */
  34482. start_sequence ();
  34483. tmp = force_operand (count, counter_reg);
  34484. @@ -544,7 +552,7 @@
  34485. to modify the loop since there is some aspect the back-end does
  34486. not like. */
  34487. start_label = block_label (desc->in_edge->dest);
  34488. - doloop_reg = gen_reg_rtx (mode);
  34489. + doloop_reg = DECREMENT_AND_BRANCH_REG (mode);
  34490. doloop_seq = gen_doloop_end (doloop_reg, iterations, iterations_max,
  34491. GEN_INT (level), start_label);
  34492. @@ -612,6 +620,18 @@
  34493. return true;
  34494. }
  34495. +#ifndef DOLOOP_OPTIMIZE_INIT
  34496. +#define DOLOOP_OPTIMIZE_INIT()
  34497. +#endif
  34498. +
  34499. +#ifndef DOLOOP_OPTIMIZE_LOOP
  34500. +#define DOLOOP_OPTIMIZE_LOOP(LOOP) doloop_optimize (LOOP)
  34501. +#endif
  34502. +
  34503. +#ifndef DOLOOP_OPTIMIZE_FINI
  34504. +#define DOLOOP_OPTIMIZE_FINI()
  34505. +#endif
  34506. +
  34507. /* This is the main entry point. Process all LOOPS using doloop_optimize. */
  34508. void
  34509. @@ -620,15 +640,19 @@
  34510. unsigned i;
  34511. struct loop *loop;
  34512. + DOLOOP_OPTIMIZE_INIT ();
  34513. +
  34514. for (i = 1; i < loops->num; i++)
  34515. {
  34516. loop = loops->parray[i];
  34517. if (!loop)
  34518. continue;
  34519. - doloop_optimize (loop);
  34520. + DOLOOP_OPTIMIZE_LOOP (loop);
  34521. }
  34522. + DOLOOP_OPTIMIZE_FINI ();
  34523. +
  34524. iv_analysis_done ();
  34525. #ifdef ENABLE_CHECKING
  34526. diff -Nur gcc-4.2.4.orig/gcc/mkmap-symver.awk gcc-4.2.4/gcc/mkmap-symver.awk
  34527. --- gcc-4.2.4.orig/gcc/mkmap-symver.awk 2007-09-01 10:28:30.000000000 -0500
  34528. +++ gcc-4.2.4/gcc/mkmap-symver.awk 2015-07-03 18:46:05.725283542 -0500
  34529. @@ -21,8 +21,13 @@
  34530. BEGIN {
  34531. state = "nm";
  34532. sawsymbol = 0;
  34533. + showprefix = "_";
  34534. if (leading_underscore)
  34535. + {
  34536. + if (no_show_underscore)
  34537. + showprefix = "";
  34538. prefix = "_";
  34539. + }
  34540. else
  34541. prefix = "";
  34542. }
  34543. @@ -81,7 +86,7 @@
  34544. }
  34545. {
  34546. - sym = prefix $1;
  34547. + sym = $1;
  34548. if (thislib != "%exclude")
  34549. ver[sym] = thislib;
  34550. else
  34551. @@ -108,7 +113,7 @@
  34552. empty=1
  34553. for (sym in ver)
  34554. - if ((ver[sym] == lib) && (sym in def))
  34555. + if (((ver[sym]) == lib) && ((prefix sym) in def))
  34556. {
  34557. if (empty)
  34558. {
  34559. @@ -116,7 +121,7 @@
  34560. printf(" global:\n");
  34561. empty = 0;
  34562. }
  34563. - printf("\t%s;\n", sym);
  34564. + printf("\t%s;\n", showprefix sym);
  34565. }
  34566. if (empty)
  34567. diff -Nur gcc-4.2.4.orig/gcc/output.h gcc-4.2.4/gcc/output.h
  34568. --- gcc-4.2.4.orig/gcc/output.h 2007-09-01 10:28:30.000000000 -0500
  34569. +++ gcc-4.2.4/gcc/output.h 2015-07-03 18:46:05.725283542 -0500
  34570. @@ -490,7 +490,7 @@
  34571. /* The callback used to switch to the section, and the data that
  34572. should be passed to the callback. */
  34573. unnamed_section_callback GTY ((skip)) callback;
  34574. - const void *GTY ((skip)) data;
  34575. + const char *GTY (()) data;
  34576. /* The next entry in the chain of unnamed sections. */
  34577. section *next;
  34578. @@ -557,6 +557,9 @@
  34579. extern void place_block_symbol (rtx);
  34580. extern rtx get_section_anchor (struct object_block *, HOST_WIDE_INT,
  34581. enum tls_model);
  34582. +extern section *mergeable_string_section (tree,
  34583. + unsigned HOST_WIDE_INT,
  34584. + unsigned int);
  34585. extern section *mergeable_constant_section (enum machine_mode,
  34586. unsigned HOST_WIDE_INT,
  34587. unsigned int);
  34588. diff -Nur gcc-4.2.4.orig/gcc/print-rtl.c gcc-4.2.4/gcc/print-rtl.c
  34589. --- gcc-4.2.4.orig/gcc/print-rtl.c 2007-09-01 10:28:30.000000000 -0500
  34590. +++ gcc-4.2.4/gcc/print-rtl.c 2015-07-03 18:46:05.725283542 -0500
  34591. @@ -428,11 +428,11 @@
  34592. const char *name;
  34593. #ifndef GENERATOR_FILE
  34594. - if (REG_P (in_rtx) && value < FIRST_PSEUDO_REGISTER)
  34595. + if (REG_P (in_rtx) && (unsigned)value < FIRST_PSEUDO_REGISTER)
  34596. fprintf (outfile, " %d %s", REGNO (in_rtx),
  34597. reg_names[REGNO (in_rtx)]);
  34598. else if (REG_P (in_rtx)
  34599. - && value <= LAST_VIRTUAL_REGISTER)
  34600. + && (unsigned)value <= LAST_VIRTUAL_REGISTER)
  34601. {
  34602. if (value == VIRTUAL_INCOMING_ARGS_REGNUM)
  34603. fprintf (outfile, " %d virtual-incoming-args", value);
  34604. diff -Nur gcc-4.2.4.orig/gcc/regmove.c gcc-4.2.4/gcc/regmove.c
  34605. --- gcc-4.2.4.orig/gcc/regmove.c 2007-09-01 10:28:30.000000000 -0500
  34606. +++ gcc-4.2.4/gcc/regmove.c 2015-07-03 18:46:05.725283542 -0500
  34607. @@ -80,6 +80,10 @@
  34608. static int regclass_compatible_p (int, int);
  34609. static int replacement_quality (rtx);
  34610. static int fixup_match_2 (rtx, rtx, rtx, rtx);
  34611. +#ifdef AUTO_INC_DEC
  34612. +static void update_auto_inc_notes (rtx);
  34613. +static void remove_auto_inc_notes (rtx);
  34614. +#endif
  34615. /* Return nonzero if registers with CLASS1 and CLASS2 can be merged without
  34616. causing too much register allocation problems. */
  34617. @@ -1043,6 +1047,52 @@
  34618. return 0;
  34619. }
  34620. +#ifdef AUTO_INC_DEC
  34621. +/* Remove all REG_INC notes from INSN. */
  34622. +
  34623. +static void
  34624. +remove_auto_inc_notes (rtx insn)
  34625. +{
  34626. + rtx prev = NULL_RTX;
  34627. + rtx link;
  34628. +
  34629. + gcc_assert (insn);
  34630. +
  34631. + link = REG_NOTES (insn);
  34632. + while (link)
  34633. + {
  34634. + rtx next = XEXP (link, 1);
  34635. +
  34636. + if (REG_NOTE_KIND (link) == REG_INC)
  34637. + {
  34638. + if (link == REG_NOTES (insn))
  34639. + REG_NOTES (insn) = next;
  34640. + else
  34641. + XEXP (prev, 1) = next;
  34642. + }
  34643. +
  34644. + prev = link;
  34645. + link = next;
  34646. + }
  34647. +}
  34648. +
  34649. +/* Updates REG_INC notes for all insns in the sequence starting at FIRST. */
  34650. +
  34651. +static void
  34652. +update_auto_inc_notes (rtx first)
  34653. +{
  34654. + rtx insn;
  34655. +
  34656. + for (insn = first; insn; insn = NEXT_INSN (insn))
  34657. + if (INSN_P (insn))
  34658. + {
  34659. + remove_auto_inc_notes (insn);
  34660. +
  34661. + add_auto_inc_notes (insn, PATTERN (insn));
  34662. + }
  34663. +}
  34664. +#endif
  34665. +
  34666. /* Main entry for the register move optimization.
  34667. F is the first instruction.
  34668. NREGS is one plus the highest pseudo-reg number used in the instruction.
  34669. @@ -2491,6 +2541,11 @@
  34670. rest_of_handle_regmove (void)
  34671. {
  34672. regmove_optimize (get_insns (), max_reg_num ());
  34673. +#ifdef AUTO_INC_DEC
  34674. + /* The regmove optimization may invalidate existing REG_INC notes
  34675. + so update the REG_INC note afterwards. */
  34676. + update_auto_inc_notes (get_insns ());
  34677. +#endif
  34678. cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
  34679. return 0;
  34680. }
  34681. diff -Nur gcc-4.2.4.orig/gcc/regrename.c gcc-4.2.4/gcc/regrename.c
  34682. --- gcc-4.2.4.orig/gcc/regrename.c 2007-09-01 10:28:30.000000000 -0500
  34683. +++ gcc-4.2.4/gcc/regrename.c 2015-07-03 18:46:05.725283542 -0500
  34684. @@ -182,6 +182,11 @@
  34685. }
  34686. }
  34687. +#if !defined(HARD_REGNO_RENAME_OK_FOR_INSN) && defined(HARD_REGNO_RENAME_OK)
  34688. +#define HARD_REGNO_RENAME_OK_FOR_INSN(INSN, FROM, TOO) \
  34689. + HARD_REGNO_RENAME_OK (FROM, TOO)
  34690. +#endif
  34691. +
  34692. /* Perform register renaming on the current function. */
  34693. static void
  34694. @@ -303,8 +308,8 @@
  34695. || (current_function_is_leaf
  34696. && !LEAF_REGISTERS[new_reg + i])
  34697. #endif
  34698. -#ifdef HARD_REGNO_RENAME_OK
  34699. - || ! HARD_REGNO_RENAME_OK (reg + i, new_reg + i)
  34700. +#ifdef HARD_REGNO_RENAME_OK_FOR_INSN
  34701. + || ! HARD_REGNO_RENAME_OK_FOR_INSN (this->insn, reg + i, new_reg + i)
  34702. #endif
  34703. )
  34704. break;
  34705. @@ -1546,13 +1551,13 @@
  34706. case PRE_INC:
  34707. case PRE_DEC:
  34708. case PRE_MODIFY:
  34709. - return false;
  34710. + return changed;
  34711. case MEM:
  34712. - return replace_oldest_value_mem (x, insn, vd);
  34713. + return changed | replace_oldest_value_mem (x, insn, vd);
  34714. case REG:
  34715. - return replace_oldest_value_reg (loc, cl, insn, vd);
  34716. + return changed | replace_oldest_value_reg (loc, cl, insn, vd);
  34717. default:
  34718. break;
  34719. @@ -1674,14 +1679,18 @@
  34720. if (REG_P (SET_DEST (set)))
  34721. {
  34722. new = find_oldest_value_reg (REGNO_REG_CLASS (regno), src, vd);
  34723. - if (new && validate_change (insn, &SET_SRC (set), new, 0))
  34724. + if (new)
  34725. {
  34726. - if (dump_file)
  34727. - fprintf (dump_file,
  34728. - "insn %u: replaced reg %u with %u\n",
  34729. - INSN_UID (insn), regno, REGNO (new));
  34730. - changed = true;
  34731. - goto did_replacement;
  34732. + if (validate_change (insn, &SET_SRC (set), new, 0))
  34733. + {
  34734. + if (dump_file)
  34735. + fprintf (dump_file,
  34736. + "insn %u: replaced reg %u with %u\n",
  34737. + INSN_UID (insn), regno, REGNO (new));
  34738. + changed = true;
  34739. + goto did_replacement;
  34740. + }
  34741. + extract_insn (insn);
  34742. }
  34743. }
  34744. @@ -1704,6 +1713,7 @@
  34745. changed = true;
  34746. goto did_replacement;
  34747. }
  34748. + extract_insn (insn);
  34749. }
  34750. }
  34751. }
  34752. @@ -1711,6 +1721,8 @@
  34753. any_replacements = false;
  34754. + gcc_assert (n_ops == recog_data.n_operands);
  34755. +
  34756. /* For each input operand, replace a hard register with the
  34757. eldest live copy that's in an appropriate register class. */
  34758. for (i = 0; i < n_ops; i++)
  34759. diff -Nur gcc-4.2.4.orig/gcc/reload1.c gcc-4.2.4/gcc/reload1.c
  34760. --- gcc-4.2.4.orig/gcc/reload1.c 2007-09-01 10:28:30.000000000 -0500
  34761. +++ gcc-4.2.4/gcc/reload1.c 2015-07-03 18:46:05.725283542 -0500
  34762. @@ -438,9 +438,6 @@
  34763. static void delete_address_reloads (rtx, rtx);
  34764. static void delete_address_reloads_1 (rtx, rtx, rtx);
  34765. static rtx inc_for_reload (rtx, rtx, rtx, int);
  34766. -#ifdef AUTO_INC_DEC
  34767. -static void add_auto_inc_notes (rtx, rtx);
  34768. -#endif
  34769. static void copy_eh_notes (rtx, rtx);
  34770. static int reloads_conflict (int, int);
  34771. static rtx gen_reload (rtx, rtx, int, enum reload_type);
  34772. @@ -653,6 +650,10 @@
  34773. struct elim_table *ep;
  34774. basic_block bb;
  34775. +#ifdef ENABLE_CHECKING
  34776. + verify_auto_inc_notes_p (first);
  34777. +#endif
  34778. +
  34779. /* Make sure even insns with volatile mem refs are recognizable. */
  34780. init_recog ();
  34781. @@ -8296,34 +8297,6 @@
  34782. return store;
  34783. }
  34784. -#ifdef AUTO_INC_DEC
  34785. -static void
  34786. -add_auto_inc_notes (rtx insn, rtx x)
  34787. -{
  34788. - enum rtx_code code = GET_CODE (x);
  34789. - const char *fmt;
  34790. - int i, j;
  34791. -
  34792. - if (code == MEM && auto_inc_p (XEXP (x, 0)))
  34793. - {
  34794. - REG_NOTES (insn)
  34795. - = gen_rtx_EXPR_LIST (REG_INC, XEXP (XEXP (x, 0), 0), REG_NOTES (insn));
  34796. - return;
  34797. - }
  34798. -
  34799. - /* Scan all the operand sub-expressions. */
  34800. - fmt = GET_RTX_FORMAT (code);
  34801. - for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  34802. - {
  34803. - if (fmt[i] == 'e')
  34804. - add_auto_inc_notes (insn, XEXP (x, i));
  34805. - else if (fmt[i] == 'E')
  34806. - for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  34807. - add_auto_inc_notes (insn, XVECEXP (x, i, j));
  34808. - }
  34809. -}
  34810. -#endif
  34811. -
  34812. /* Copy EH notes from an insn to its reloads. */
  34813. static void
  34814. copy_eh_notes (rtx insn, rtx x)
  34815. diff -Nur gcc-4.2.4.orig/gcc/rtlanal.c gcc-4.2.4/gcc/rtlanal.c
  34816. --- gcc-4.2.4.orig/gcc/rtlanal.c 2007-09-01 10:28:30.000000000 -0500
  34817. +++ gcc-4.2.4/gcc/rtlanal.c 2015-07-03 18:46:05.729283542 -0500
  34818. @@ -1042,6 +1042,11 @@
  34819. a special insn which should not be considered a no-op. */
  34820. if (find_reg_note (insn, REG_RETVAL, NULL_RTX))
  34821. return 0;
  34822. +
  34823. + /* Extract the code of a cond_exec as a conditional noop is no
  34824. + more useful than a noop itself */
  34825. + if (GET_CODE (pat) == COND_EXEC)
  34826. + pat = COND_EXEC_CODE (pat);
  34827. if (GET_CODE (pat) == SET && set_noop_p (pat))
  34828. return 1;
  34829. @@ -2832,6 +2837,74 @@
  34830. return 0;
  34831. }
  34832. +/* If X has autoincrement side effects then add required REG_INC notes. */
  34833. +void
  34834. +add_auto_inc_notes (rtx insn, rtx x)
  34835. +{
  34836. + enum rtx_code code = GET_CODE (x);
  34837. + const char *fmt;
  34838. + int i, j;
  34839. +
  34840. + if (code == MEM && auto_inc_p (XEXP (x, 0)))
  34841. + {
  34842. + REG_NOTES (insn)
  34843. + = gen_rtx_EXPR_LIST (REG_INC, XEXP (XEXP (x, 0), 0), REG_NOTES (insn));
  34844. + return;
  34845. + }
  34846. +
  34847. + /* Scan all the operand sub-expressions. */
  34848. + fmt = GET_RTX_FORMAT (code);
  34849. + for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  34850. + {
  34851. + if (fmt[i] == 'e')
  34852. + add_auto_inc_notes (insn, XEXP (x, i));
  34853. + else if (fmt[i] == 'E')
  34854. + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  34855. + add_auto_inc_notes (insn, XVECEXP (x, i, j));
  34856. + }
  34857. +}
  34858. +
  34859. +/* Verify if INSN has required REG_INC notes. */
  34860. +
  34861. +void
  34862. +verify_auto_inc_notes_for_insn_p (rtx insn, rtx x)
  34863. +{
  34864. + enum rtx_code code = GET_CODE (x);
  34865. + const char *fmt;
  34866. + int i, j;
  34867. +
  34868. + if (code == MEM && auto_inc_p (XEXP (x, 0)))
  34869. + {
  34870. + if (find_reg_note (insn, REG_INC, XEXP (XEXP (x, 0), 0)) == NULL_RTX)
  34871. + fatal_insn ("Insn missing REG_INC note:", insn);
  34872. + }
  34873. +
  34874. + /* Scan all the operand sub-expressions. */
  34875. + fmt = GET_RTX_FORMAT (code);
  34876. + for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  34877. + {
  34878. + if (fmt[i] == 'e')
  34879. + verify_auto_inc_notes_for_insn_p (insn, XEXP (x, i));
  34880. + else if (fmt[i] == 'E')
  34881. + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  34882. + verify_auto_inc_notes_for_insn_p (insn, XVECEXP (x, i, j));
  34883. + }
  34884. +
  34885. + return;
  34886. +}
  34887. +
  34888. +/* Verify that all insns in the sequence starting at FIRST
  34889. + have required REG_INC notes. */
  34890. +void
  34891. +verify_auto_inc_notes_p (rtx first)
  34892. +{
  34893. + rtx insn;
  34894. +
  34895. + for (insn = first; insn; insn = NEXT_INSN (insn))
  34896. + if (INSN_P (insn))
  34897. + verify_auto_inc_notes_for_insn_p (insn, PATTERN (insn));
  34898. +}
  34899. +
  34900. /* Return nonzero if IN contains a piece of rtl that has the address LOC. */
  34901. int
  34902. loc_mentioned_in_p (rtx *loc, rtx in)
  34903. diff -Nur gcc-4.2.4.orig/gcc/rtl.h gcc-4.2.4/gcc/rtl.h
  34904. --- gcc-4.2.4.orig/gcc/rtl.h 2007-11-07 14:48:38.000000000 -0600
  34905. +++ gcc-4.2.4/gcc/rtl.h 2015-07-03 18:46:05.729283542 -0500
  34906. @@ -1722,6 +1722,9 @@
  34907. extern int for_each_rtx (rtx *, rtx_function, void *);
  34908. extern rtx regno_use_in (unsigned int, rtx);
  34909. extern int auto_inc_p (rtx);
  34910. +extern void add_auto_inc_notes (rtx, rtx);
  34911. +extern void verify_auto_inc_notes_p (rtx);
  34912. +extern void verify_auto_inc_notes_for_insn_p (rtx, rtx);
  34913. extern int in_expr_list_p (rtx, rtx);
  34914. extern void remove_node_from_expr_list (rtx, rtx *);
  34915. extern int loc_mentioned_in_p (rtx *, rtx);
  34916. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c gcc-4.2.4/gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c
  34917. --- gcc-4.2.4.orig/gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c 2005-06-27 07:17:39.000000000 -0500
  34918. +++ gcc-4.2.4/gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c 2015-07-03 18:46:05.777283542 -0500
  34919. @@ -448,6 +448,10 @@
  34920. return ret;
  34921. }
  34922. +/* This doesn't work on a target which uses uclibc.
  34923. + This is because in uclibc vsprint is implemented by use vsnprintf
  34924. + so this code will end up recusing itself to death. */
  34925. +#ifndef __metag__
  34926. int
  34927. vsnprintf (char *str, __SIZE_TYPE__ len, const char *fmt, va_list ap)
  34928. {
  34929. @@ -470,3 +474,4 @@
  34930. }
  34931. return ret;
  34932. }
  34933. +#endif
  34934. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.c-torture/execute/pr36093.x gcc-4.2.4/gcc/testsuite/gcc.c-torture/execute/pr36093.x
  34935. --- gcc-4.2.4.orig/gcc/testsuite/gcc.c-torture/execute/pr36093.x 1969-12-31 18:00:00.000000000 -0600
  34936. +++ gcc-4.2.4/gcc/testsuite/gcc.c-torture/execute/pr36093.x 2015-07-03 18:46:05.777283542 -0500
  34937. @@ -0,0 +1,10 @@
  34938. +# The META and MTX linkers require data aligned more than 64 bytes to be
  34939. +# placed in a named section.
  34940. +if { [istarget "metag*-local"] } {
  34941. + set torture_compile_xfail "metag*-local"
  34942. +}
  34943. +
  34944. +if { [istarget "mtxg*-local"] } {
  34945. + set torture_compile_xfail "mtxg*-local"
  34946. +}
  34947. +return 0
  34948. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.dg/20020312-2.c gcc-4.2.4/gcc/testsuite/gcc.dg/20020312-2.c
  34949. --- gcc-4.2.4.orig/gcc/testsuite/gcc.dg/20020312-2.c 2006-04-13 18:14:25.000000000 -0500
  34950. +++ gcc-4.2.4/gcc/testsuite/gcc.dg/20020312-2.c 2015-07-03 18:46:05.789283541 -0500
  34951. @@ -72,6 +72,8 @@
  34952. /* No pic register. */
  34953. #elif defined(__m32c__)
  34954. /* No pic register. */
  34955. +#elif defined(__metag__)
  34956. +# define PIC_REG "A1LbP"
  34957. #else
  34958. # error "Modify the test for your target."
  34959. #endif
  34960. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret1.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret1.c
  34961. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret1.c 1969-12-31 18:00:00.000000000 -0600
  34962. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret1.c 2015-07-03 18:46:05.789283541 -0500
  34963. @@ -0,0 +1,38 @@
  34964. +/* { dg-options "-mmetac=2.1 -O2" } */
  34965. +/* { dg-skip-if "" { *-*-* } { "-mmetac=1.2" } { "" } } */
  34966. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  34967. +
  34968. +/*
  34969. + * Check that conditional returns are not used
  34970. + * for META 2 code
  34971. + */
  34972. +
  34973. +extern int bar;
  34974. +extern int bar2;
  34975. +extern int zee(int);
  34976. +int mainly(int foo)
  34977. +{
  34978. + if (bar2 == 0)
  34979. + {
  34980. + return 0;
  34981. + }
  34982. + if (foo >5)
  34983. + {
  34984. + foo+=bar;
  34985. + return foo;
  34986. + }
  34987. + else if (foo >2)
  34988. + {
  34989. + foo+=bar2;
  34990. + return foo+34;
  34991. + }
  34992. + else
  34993. + {
  34994. + foo-=bar;
  34995. + return zee(foo);
  34996. + }
  34997. +}
  34998. +
  34999. +/* { dg-final { scan-assembler-times "\\\$LX\[0-9\]\+:" 1 } }*/
  35000. +/* { dg-final { scan-assembler-times "MOV\tPC, D1RtP" 2 } }*/
  35001. +/* { dg-final { scan-assembler-not "MOV\[A-Z\]\[A-Z\]\tPC, D1RtP" } }*/
  35002. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret2.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret2.c
  35003. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret2.c 1969-12-31 18:00:00.000000000 -0600
  35004. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret2.c 2015-07-03 18:46:05.789283541 -0500
  35005. @@ -0,0 +1,37 @@
  35006. +/* { dg-options "-mmetac=1.2 -O2" } */
  35007. +/* { dg-skip-if "" { *-*-* } { "-mmetac=2.1" } { "" } } */
  35008. +
  35009. +/*
  35010. + * Check that conditional returns are used
  35011. + * for META 1 code
  35012. + */
  35013. +
  35014. +extern int bar;
  35015. +extern int bar2;
  35016. +extern int zee(int);
  35017. +int mainly(int foo)
  35018. +{
  35019. + if (bar2 == 0)
  35020. + {
  35021. + return 0;
  35022. + }
  35023. + if (foo >5)
  35024. + {
  35025. + foo+=bar;
  35026. + return foo;
  35027. + }
  35028. + else if (foo >2)
  35029. + {
  35030. + foo+=bar2;
  35031. + return foo+34;
  35032. + }
  35033. + else
  35034. + {
  35035. + foo-=bar;
  35036. + return zee(foo);
  35037. + }
  35038. +}
  35039. +
  35040. +/* { dg-final { scan-assembler-not "\\\$LX\[0-9\]+:" } }*/
  35041. +/* { dg-final { scan-assembler-times "MOV\tPC, D1RtP" 1 } }*/
  35042. +/* { dg-final { scan-assembler-times "MOV\[A-Z\]\[A-Z\]\tPC, D1RtP" 2 } }*/
  35043. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret3.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret3.c
  35044. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret3.c 1969-12-31 18:00:00.000000000 -0600
  35045. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret3.c 2015-07-03 18:46:05.789283541 -0500
  35046. @@ -0,0 +1,21 @@
  35047. +/* { dg-options "-mmetac=2.1 -O2" } */
  35048. +/* { dg-skip-if "" { *-*-* } { "-mmetac=1.2" } { "" } } */
  35049. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  35050. +
  35051. +/*
  35052. + * Check that conditional returns are not used
  35053. + * for META 2 code
  35054. + */
  35055. +
  35056. +typedef void (*my_func)(int);
  35057. +int cond;
  35058. +
  35059. +int no_unconditional_return (my_func *f)
  35060. +{
  35061. + if (cond)
  35062. + (*f) (3);
  35063. +}
  35064. +
  35065. +/* { dg-final { scan-assembler-times "\\\$LX\[0-9\]+:" 1 } }*/
  35066. +/* { dg-final { scan-assembler-times "MOV\tPC, D1RtP" 1 } }*/
  35067. +/* { dg-final { scan-assembler-not "MOV\[A-Z\]\[A-Z\]\tPC, D1RtP" } }*/
  35068. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret4.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret4.c
  35069. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/condret4.c 1969-12-31 18:00:00.000000000 -0600
  35070. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/condret4.c 2015-07-03 18:46:05.789283541 -0500
  35071. @@ -0,0 +1,19 @@
  35072. +/* { dg-options "-mmetac=1.2 -O2" } */
  35073. +/* { dg-skip-if "" { *-*-* } { "-mmetac=2.1" } { "" } } */
  35074. +
  35075. +/*
  35076. + * Check that conditional returns are not used
  35077. + * for META 1 code
  35078. + */
  35079. +
  35080. +typedef void (*my_func)(int);
  35081. +int cond;
  35082. +
  35083. +int no_unconditional_return (my_func *f)
  35084. +{
  35085. + if (cond)
  35086. + (*f) (3);
  35087. +}
  35088. +
  35089. +/* { dg-final { scan-assembler-not "\\\$LX\[0-9\]+:" } }*/
  35090. +/* { dg-final { scan-assembler-times "MOV\[A-Z\]\[A-Z\]\tPC, D1RtP" 1 } }*/
  35091. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech1.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech1.c
  35092. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech1.c 1969-12-31 18:00:00.000000000 -0600
  35093. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech1.c 2015-07-03 18:46:05.789283541 -0500
  35094. @@ -0,0 +1,16 @@
  35095. +/* { dg-options "-O2" } */
  35096. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  35097. +
  35098. +/*
  35099. + * Check that ECH is not used when no dsp resources are enabled
  35100. + * ECH is implemented using D0.8 so it will not be referred to
  35101. + * when ECH is disabled
  35102. + */
  35103. +int glob;
  35104. +
  35105. +void test_func()
  35106. +{
  35107. + glob++;
  35108. +}
  35109. +
  35110. +/* { dg-final { scan-assembler-not "D0.8" } }*/
  35111. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech2.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech2.c
  35112. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech2.c 1969-12-31 18:00:00.000000000 -0600
  35113. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech2.c 2015-07-03 18:46:05.789283541 -0500
  35114. @@ -0,0 +1,15 @@
  35115. +/* { dg-options "-O2 -mdsp" } */
  35116. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  35117. +
  35118. +/*
  35119. + * Check that ECH status is not changed by a function that uses no
  35120. + * dsp resources
  35121. + */
  35122. +int glob;
  35123. +
  35124. +void test_func()
  35125. +{
  35126. + glob++;
  35127. +}
  35128. +
  35129. +/* { dg-final { scan-assembler-not "D0.8" } }*/
  35130. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech3.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech3.c
  35131. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech3.c 1969-12-31 18:00:00.000000000 -0600
  35132. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech3.c 2015-07-03 18:46:05.789283541 -0500
  35133. @@ -0,0 +1,15 @@
  35134. +/* { dg-options "-O2 -mdsp" } */
  35135. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  35136. +
  35137. +/*
  35138. + * Check that ECH status is set when a dsp register is used
  35139. + */
  35140. +int glob;
  35141. +
  35142. +void test_func()
  35143. +{
  35144. + glob++;
  35145. + asm ("":::"D0.9");
  35146. +}
  35147. +
  35148. +/* { dg-final { scan-assembler "MOVT\tD0.8, #4384" } }*/
  35149. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech4.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech4.c
  35150. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech4.c 1969-12-31 18:00:00.000000000 -0600
  35151. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech4.c 2015-07-03 18:46:05.789283541 -0500
  35152. @@ -0,0 +1,16 @@
  35153. +/* { dg-options "-O2 -mdsp -mno-tbictxsave" } */
  35154. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  35155. +
  35156. +/*
  35157. + * Check that ECH is disabled when requested even if DSP resources
  35158. + * are used
  35159. + */
  35160. +int glob;
  35161. +
  35162. +void test_func()
  35163. +{
  35164. + glob++;
  35165. + asm ("":::"D0.9");
  35166. +}
  35167. +
  35168. +/* { dg-final { scan-assembler-not "D0.8" } }*/
  35169. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech5.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech5.c
  35170. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech5.c 1969-12-31 18:00:00.000000000 -0600
  35171. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech5.c 2015-07-03 18:46:05.789283541 -0500
  35172. @@ -0,0 +1,17 @@
  35173. +/* { dg-options "-O2 -mdsp" } */
  35174. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  35175. +
  35176. +/*
  35177. + * Check that ECH status is set when a dsp register is used from
  35178. + * both A and D units
  35179. + */
  35180. +int glob;
  35181. +
  35182. +void test_func()
  35183. +{
  35184. + glob++;
  35185. + asm ("":::"D0.9");
  35186. + asm ("":::"A0.4");
  35187. +}
  35188. +
  35189. +/* { dg-final { scan-assembler "MOVT\tD0.8, #4896" } }*/
  35190. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech6.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech6.c
  35191. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/ech6.c 1969-12-31 18:00:00.000000000 -0600
  35192. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/ech6.c 2015-07-03 18:46:05.789283541 -0500
  35193. @@ -0,0 +1,17 @@
  35194. +/* { dg-options "-O2 -mdsp" } */
  35195. +/* { dg-skip-if "" { mtxg*-local } { "*" } { "" } } */
  35196. +
  35197. +/*
  35198. + * Check that ECH status is set when a dsp register is used from
  35199. + * just A unit. This should also result in D registers being saved
  35200. + * as D0.8 is in that range.
  35201. + */
  35202. +int glob;
  35203. +
  35204. +void test_func()
  35205. +{
  35206. + glob++;
  35207. + asm ("":::"A0.4");
  35208. +}
  35209. +
  35210. +/* { dg-final { scan-assembler "MOVT\tD0.8, #4896" } }*/
  35211. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/metag.exp gcc-4.2.4/gcc/testsuite/gcc.target/metag/metag.exp
  35212. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/metag.exp 1969-12-31 18:00:00.000000000 -0600
  35213. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/metag.exp 2015-07-03 18:46:05.789283541 -0500
  35214. @@ -0,0 +1,41 @@
  35215. +# Copyright (C) 2010 Free Software Foundation, Inc.
  35216. +
  35217. +# This program is free software; you can redistribute it and/or modify
  35218. +# it under the terms of the GNU General Public License as published by
  35219. +# the Free Software Foundation; either version 3 of the License, or
  35220. +# (at your option) any later version.
  35221. +#
  35222. +# This program is distributed in the hope that it will be useful,
  35223. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  35224. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  35225. +# GNU General Public License for more details.
  35226. +#
  35227. +# You should have received a copy of the GNU General Public License
  35228. +# along with GCC; see the file COPYING3. If not see
  35229. +# <http://www.gnu.org/licenses/>.
  35230. +
  35231. +# GCC testsuite that uses the `dg.exp' driver.
  35232. +
  35233. +# Exit immediately if this isn't an METAG target.
  35234. +if ![istarget metag*-*-*] then {
  35235. + return
  35236. +}
  35237. +
  35238. +# Load support procs.
  35239. +load_lib gcc-dg.exp
  35240. +
  35241. +# If a testcase doesn't have special options, use these.
  35242. +global DEFAULT_CFLAGS
  35243. +if ![info exists DEFAULT_CFLAGS] then {
  35244. + set DEFAULT_CFLAGS " -ansi -pedantic-errors"
  35245. +}
  35246. +
  35247. +# Initialize `dg'.
  35248. +dg-init
  35249. +
  35250. +# Main loop.
  35251. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
  35252. + "" $DEFAULT_CFLAGS
  35253. +
  35254. +# All done.
  35255. +dg-finish
  35256. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/strcmpbcs.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/strcmpbcs.c
  35257. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/strcmpbcs.c 1969-12-31 18:00:00.000000000 -0600
  35258. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/strcmpbcs.c 2015-07-03 18:46:05.789283541 -0500
  35259. @@ -0,0 +1,20 @@
  35260. +/* { dg-do compile } */
  35261. +/* { dg-options "-mcharset=basic" } */
  35262. +#include <stdio.h>
  35263. +
  35264. +char c [100];
  35265. +char f [100];
  35266. +
  35267. +int main(void)
  35268. +{
  35269. + if(strcmp (c,f) == 0)
  35270. + {
  35271. + return 1;
  35272. + }
  35273. + else
  35274. + {
  35275. + return 0;
  35276. + }
  35277. +}
  35278. +
  35279. +/* { dg-final { scan-assembler "strcmpbcs" } } */
  35280. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/thread_pointer_builtin.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/thread_pointer_builtin.c
  35281. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/thread_pointer_builtin.c 1969-12-31 18:00:00.000000000 -0600
  35282. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/thread_pointer_builtin.c 2015-07-03 18:46:05.789283541 -0500
  35283. @@ -0,0 +1,11 @@
  35284. +/* { dg-do compile } */
  35285. +/* { dg-options "-O2 -fpic" } */
  35286. +/* { dg-require-effective-target tls } */
  35287. +
  35288. +void *foo(void)
  35289. +{
  35290. + return __builtin_thread_pointer();
  35291. +}
  35292. +
  35293. +/* { dg-final { scan-assembler-times "___metag_load_tp@PLT" 1 } } */
  35294. +/* { dg-final { scan-assembler-not "___metag_load_tp$" } } */
  35295. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/thread_pointer_builtin-non-pic.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/thread_pointer_builtin-non-pic.c
  35296. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/thread_pointer_builtin-non-pic.c 1969-12-31 18:00:00.000000000 -0600
  35297. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/thread_pointer_builtin-non-pic.c 2015-07-03 18:46:05.789283541 -0500
  35298. @@ -0,0 +1,11 @@
  35299. +/* { dg-do compile } */
  35300. +/* { dg-options "-O2" } */
  35301. +/* { dg-require-effective-target tls } */
  35302. +
  35303. +void *foo(void)
  35304. +{
  35305. + return __builtin_thread_pointer();
  35306. +}
  35307. +
  35308. +/* { dg-final { scan-assembler-not "___metag_load_tp@PLT" } } */
  35309. +/* { dg-final { scan-assembler-times "___metag_load_tp" 1 } } */
  35310. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/tls.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/tls.c
  35311. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/tls.c 1969-12-31 18:00:00.000000000 -0600
  35312. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/tls.c 2015-07-03 18:46:05.789283541 -0500
  35313. @@ -0,0 +1,47 @@
  35314. +/* { dg-do compile } */
  35315. +/* { dg-options "-O2 -fpic" } */
  35316. +/* { dg-require-effective-target tls } */
  35317. +
  35318. +extern __thread int a __attribute__ ((tls_model ("global-dynamic")));
  35319. +static __thread int b __attribute__ ((tls_model ("local-dynamic")));
  35320. +extern __thread int c __attribute__ ((tls_model ("initial-exec")));
  35321. +static __thread int d __attribute__ ((tls_model ("local-exec")));
  35322. +
  35323. +int*
  35324. +test (void)
  35325. +{
  35326. + a=a+7;
  35327. + return &a;
  35328. +}
  35329. +
  35330. +int*
  35331. +test2 (void)
  35332. +{
  35333. + b=b+10;
  35334. + return &b;
  35335. +}
  35336. +
  35337. +int*
  35338. +test3 (void)
  35339. +{
  35340. + c=c+7;
  35341. + return &c;
  35342. +}
  35343. +
  35344. +int*
  35345. +test4 (void)
  35346. +{
  35347. + d=d+10;
  35348. + return &d;
  35349. +}
  35350. +
  35351. +/* { dg-final { scan-assembler-times "\\(_a@TLSGD\\)" 1 } } */
  35352. +/* { dg-final { scan-assembler-times "\\(_b@TLSLDM\\)" 1 } } */
  35353. +/* { dg-final { scan-assembler-times "#HI\\(_b@TLSLDO\\)" 1 } } */
  35354. +/* { dg-final { scan-assembler-times "#LO\\(_b@TLSLDO\\)" 1 } } */
  35355. +/* { dg-final { scan-assembler-times "\\(_c@TLSIE\\)" 1 } } */
  35356. +/* { dg-final { scan-assembler-times "#HI\\(_d@TLSLE\\)" 1 } } */
  35357. +/* { dg-final { scan-assembler-times "#LO\\(_d@TLSLE\\)" 1 } } */
  35358. +/* { dg-final { scan-assembler-times "___metag_load_tp@PLT" 2 } } */
  35359. +/* { dg-final { scan-assembler-times "___tls_get_addr@PLT" 2 } } */
  35360. +/* { dg-final { scan-assembler-not "_c@TLSIENONPIC\\)" } } */
  35361. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/tls-non-pic.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/tls-non-pic.c
  35362. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/tls-non-pic.c 1969-12-31 18:00:00.000000000 -0600
  35363. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/tls-non-pic.c 2015-07-03 18:46:05.789283541 -0500
  35364. @@ -0,0 +1,50 @@
  35365. +/* { dg-do compile } */
  35366. +/* { dg-options "-O2" } */
  35367. +/* { dg-require-effective-target tls } */
  35368. +
  35369. +extern __thread int a __attribute__ ((tls_model ("global-dynamic")));
  35370. +static __thread int b __attribute__ ((tls_model ("local-dynamic")));
  35371. +extern __thread int c __attribute__ ((tls_model ("initial-exec")));
  35372. +static __thread int d __attribute__ ((tls_model ("local-exec")));
  35373. +
  35374. +int*
  35375. +test (void)
  35376. +{
  35377. + a=a+7;
  35378. + return &a;
  35379. +}
  35380. +
  35381. +int*
  35382. +test2 (void)
  35383. +{
  35384. + b=b+10;
  35385. + return &b;
  35386. +}
  35387. +
  35388. +int*
  35389. +test3 (void)
  35390. +{
  35391. + c=c+7;
  35392. + return &c;
  35393. +}
  35394. +
  35395. +int*
  35396. +test4 (void)
  35397. +{
  35398. + d=d+10;
  35399. + return &d;
  35400. +}
  35401. +
  35402. +/* { dg-final { scan-assembler-not "_c@TLSIE\\)" } } */
  35403. +/* { dg-final { scan-assembler-times "#HI\\(_c@TLSIENONPIC\\)" 1 } } */
  35404. +/* { dg-final { scan-assembler-times "#LO\\(_c@TLSIENONPIC\\)" 1 } } */
  35405. +/* { dg-final { scan-assembler-times "\\(_a@TLSGD\\)" 1 } } */
  35406. +/* { dg-final { scan-assembler-times "\\(_b@TLSLDM\\)" 1 } } */
  35407. +/* { dg-final { scan-assembler-times "#HI\\(_b@TLSLDO\\)" 1 } } */
  35408. +/* { dg-final { scan-assembler-times "#LO\\(_b@TLSLDO\\)" 1 } } */
  35409. +/* { dg-final { scan-assembler-times "#HI\\(_d@TLSLE\\)" 1 } } */
  35410. +/* { dg-final { scan-assembler-times "#LO\\(_d@TLSLE\\)" 1 } } */
  35411. +/* { dg-final { scan-assembler-not "___metag_load_tp@PLT" } } */
  35412. +/* { dg-final { scan-assembler-not "___tls_get_addr@PLT" } } */
  35413. +/* { dg-final { scan-assembler-times "___metag_load_tp" 2 } } */
  35414. +/* { dg-final { scan-assembler-times "___tls_get_addr" 2 } } */
  35415. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/txrpt-clobber.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/txrpt-clobber.c
  35416. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/txrpt-clobber.c 1969-12-31 18:00:00.000000000 -0600
  35417. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/txrpt-clobber.c 2015-07-03 18:46:05.789283541 -0500
  35418. @@ -0,0 +1,12 @@
  35419. +/* { dg-do compile } */
  35420. +/* { dg-options "-O2" } */
  35421. +int wibble()
  35422. +{
  35423. + int i;
  35424. + for (i = 0 ; i < 100 ; i++)
  35425. + {
  35426. + asm volatile ("foo":::"TXRPT");
  35427. + }
  35428. +}
  35429. +
  35430. +/* { dg-final { scan-assembler-not "BR" } } */
  35431. diff -Nur gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/umulhisi1.c gcc-4.2.4/gcc/testsuite/gcc.target/metag/umulhisi1.c
  35432. --- gcc-4.2.4.orig/gcc/testsuite/gcc.target/metag/umulhisi1.c 1969-12-31 18:00:00.000000000 -0600
  35433. +++ gcc-4.2.4/gcc/testsuite/gcc.target/metag/umulhisi1.c 2015-07-03 18:46:05.789283541 -0500
  35434. @@ -0,0 +1,18 @@
  35435. +/* { dg-options "-O2" } */
  35436. +/* { dg-final { scan-assembler-times "47662" 1 } }*/
  35437. +
  35438. +/*
  35439. + * Check that the unsigned 16 bit multiply by constant
  35440. + * optimisation copes with numbers greater than 2^15
  35441. + */
  35442. +
  35443. +#define CONSTANT (47662)
  35444. +
  35445. +unsigned int
  35446. +test(unsigned short in)
  35447. +{
  35448. + unsigned int out = 0;
  35449. + out = (in * CONSTANT);
  35450. + return out;
  35451. +}
  35452. +
  35453. diff -Nur gcc-4.2.4.orig/gcc/testsuite/g++.dg/other/PR23205.C gcc-4.2.4/gcc/testsuite/g++.dg/other/PR23205.C
  35454. --- gcc-4.2.4.orig/gcc/testsuite/g++.dg/other/PR23205.C 2005-10-05 19:47:21.000000000 -0500
  35455. +++ gcc-4.2.4/gcc/testsuite/g++.dg/other/PR23205.C 2015-07-03 18:46:05.777283542 -0500
  35456. @@ -1,5 +1,5 @@
  35457. /* { dg-do compile } */
  35458. -/* { dg-skip-if "No stabs" { mmix-*-* *-*-aix* *-*-netware* alpha*-*-* hppa*64*-*-* ia64-*-* } { "*" } { "" } } */
  35459. +/* { dg-skip-if "No stabs" { mmix-*-* *-*-aix* *-*-netware* alpha*-*-* hppa*64*-*-* ia64-*-* metag*-*-* } { "*" } { "" } } */
  35460. /* { dg-options "-gstabs+ -fno-eliminate-unused-debug-types" } */
  35461. const int foobar = 4;
  35462. diff -Nur gcc-4.2.4.orig/gcc/testsuite/lib/file-format.exp gcc-4.2.4/gcc/testsuite/lib/file-format.exp
  35463. --- gcc-4.2.4.orig/gcc/testsuite/lib/file-format.exp 2007-08-31 03:27:50.000000000 -0500
  35464. +++ gcc-4.2.4/gcc/testsuite/lib/file-format.exp 2015-07-03 18:46:05.789283541 -0500
  35465. @@ -39,6 +39,9 @@
  35466. } else {
  35467. set gcc_target_object_format_saved som
  35468. }
  35469. + } elseif { [string match "metag*-linux-uclibc*" $target_triplet] } {
  35470. + # META we deduce the object format from the target_triplet, so hand-code it.
  35471. + set gcc_target_object_format_saved elf
  35472. } else {
  35473. set objdump_name [find_binutils_prog objdump]
  35474. set open_file [open objfmtst.c w]
  35475. diff -Nur gcc-4.2.4.orig/gcc/testsuite/lib/target-supports.exp gcc-4.2.4/gcc/testsuite/lib/target-supports.exp
  35476. --- gcc-4.2.4.orig/gcc/testsuite/lib/target-supports.exp 2008-01-08 22:47:27.000000000 -0600
  35477. +++ gcc-4.2.4/gcc/testsuite/lib/target-supports.exp 2015-07-03 18:46:05.789283541 -0500
  35478. @@ -332,6 +332,13 @@
  35479. return 0
  35480. }
  35481. + # uClibc does not have gcrt1.o
  35482. + if { [check_effective_target_uclibc]
  35483. + && ([lindex $test_what 1] == "-p"
  35484. + || [lindex $test_what 1] == "-pg") } {
  35485. + return 0
  35486. + }
  35487. +
  35488. # Now examine the cache variable.
  35489. if {![info exists profiling_available_saved]} {
  35490. # Some targets don't have any implementation of __bb_init_func or are
  35491. @@ -346,6 +353,7 @@
  35492. || [istarget cris-*-*]
  35493. || [istarget h8300-*-*]
  35494. || [istarget m32c-*-elf]
  35495. + || [istarget metag-*-uclibc]
  35496. || [istarget m68k-*-elf]
  35497. || [istarget mips*-*-elf]
  35498. || [istarget xtensa-*-elf]
  35499. @@ -1900,6 +1908,17 @@
  35500. return $et_sync_char_short_saved
  35501. }
  35502. +# Return true if this is a uClibc target.
  35503. +
  35504. +proc check_effective_target_uclibc {} {
  35505. + return [check_no_compiler_messages uclibc object {
  35506. + #include <features.h>
  35507. + #if !defined (__UCLIBC__)
  35508. + #error FOO
  35509. + #endif
  35510. + }]
  35511. +}
  35512. +
  35513. # Return 1 if the target matches the effective target 'arg', 0 otherwise.
  35514. # This can be used with any check_* proc that takes no argument and
  35515. # returns only 1 or 0. It could be used with check_* procs that take
  35516. diff -Nur gcc-4.2.4.orig/gcc/toplev.c gcc-4.2.4/gcc/toplev.c
  35517. --- gcc-4.2.4.orig/gcc/toplev.c 2007-09-01 10:28:30.000000000 -0500
  35518. +++ gcc-4.2.4/gcc/toplev.c 2015-07-03 18:46:05.741283542 -0500
  35519. @@ -1787,12 +1787,6 @@
  35520. }
  35521. }
  35522. - if (flag_function_sections && profile_flag)
  35523. - {
  35524. - warning (0, "-ffunction-sections disabled; it makes profiling impossible");
  35525. - flag_function_sections = 0;
  35526. - }
  35527. -
  35528. #ifndef HAVE_prefetch
  35529. if (flag_prefetch_loop_arrays)
  35530. {
  35531. diff -Nur gcc-4.2.4.orig/gcc/tree-ssa-loop-ivopts.c gcc-4.2.4/gcc/tree-ssa-loop-ivopts.c
  35532. --- gcc-4.2.4.orig/gcc/tree-ssa-loop-ivopts.c 2007-10-12 17:26:47.000000000 -0500
  35533. +++ gcc-4.2.4/gcc/tree-ssa-loop-ivopts.c 2015-07-03 18:46:05.741283542 -0500
  35534. @@ -3377,6 +3377,7 @@
  35535. HOST_WIDE_INT s_offset;
  35536. unsigned HOST_WIDE_INT mask;
  35537. unsigned bits;
  35538. + int start_offset = (STRICT_ALIGNMENT ? GET_MODE_SIZE (Pmode) : 1);
  35539. if (!initialized)
  35540. {
  35541. @@ -3391,7 +3392,7 @@
  35542. reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1);
  35543. addr = gen_rtx_fmt_ee (PLUS, Pmode, reg1, NULL_RTX);
  35544. - for (i = 1; i <= 1 << 20; i <<= 1)
  35545. + for (i = start_offset; i <= 1 << 20; i <<= 1)
  35546. {
  35547. XEXP (addr, 1) = gen_int_mode (i, Pmode);
  35548. if (!memory_address_p (Pmode, addr))
  35549. @@ -3400,7 +3401,7 @@
  35550. max_offset = i >> 1;
  35551. off = max_offset;
  35552. - for (i = 1; i <= 1 << 20; i <<= 1)
  35553. + for (i = start_offset; i <= 1 << 20; i <<= 1)
  35554. {
  35555. XEXP (addr, 1) = gen_int_mode (-i, Pmode);
  35556. if (!memory_address_p (Pmode, addr))
  35557. @@ -3541,7 +3542,8 @@
  35558. cost = 0;
  35559. offset_p = (s_offset != 0
  35560. - && min_offset <= s_offset && s_offset <= max_offset);
  35561. + && min_offset <= s_offset && s_offset <= max_offset
  35562. + && (s_offset <= -start_offset || s_offset >= start_offset));
  35563. ratio_p = (ratio != 1
  35564. && multiplier_allowed_in_address_p (ratio));
  35565. diff -Nur gcc-4.2.4.orig/gcc/unwind-dw2.c gcc-4.2.4/gcc/unwind-dw2.c
  35566. --- gcc-4.2.4.orig/gcc/unwind-dw2.c 2007-01-25 01:13:44.000000000 -0600
  35567. +++ gcc-4.2.4/gcc/unwind-dw2.c 2015-07-03 18:46:05.741283542 -0500
  35568. @@ -56,6 +56,11 @@
  35569. #define PRE_GCC3_DWARF_FRAME_REGISTERS DWARF_FRAME_REGISTERS
  35570. #endif
  35571. +/* Table to map Dwarf registers to unwind column. */
  35572. +#ifdef DWARF_REG_TO_UNWIND_COLUMN_TABLE
  35573. +DWARF_REG_TO_UNWIND_COLUMN_TABLE;
  35574. +#endif
  35575. +
  35576. #ifndef DWARF_REG_TO_UNWIND_COLUMN
  35577. #define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
  35578. #endif
  35579. @@ -153,23 +158,22 @@
  35580. /* Get the value of register INDEX as saved in CONTEXT. */
  35581. -inline _Unwind_Word
  35582. -_Unwind_GetGR (struct _Unwind_Context *context, int index)
  35583. +static inline _Unwind_Word
  35584. +_Unwind_ByColumn_GetGR (struct _Unwind_Context *context, int column)
  35585. {
  35586. int size;
  35587. void *ptr;
  35588. #ifdef DWARF_ZERO_REG
  35589. - if (index == DWARF_ZERO_REG)
  35590. + if (column == DWARF_REG_TO_UNWIND_COLUMN (DWARF_ZERO_REG))
  35591. return 0;
  35592. #endif
  35593. - index = DWARF_REG_TO_UNWIND_COLUMN (index);
  35594. - gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
  35595. - size = dwarf_reg_size_table[index];
  35596. - ptr = context->reg[index];
  35597. + gcc_assert (0 <= column && column < (int) sizeof(dwarf_reg_size_table));
  35598. + size = dwarf_reg_size_table[column];
  35599. + ptr = context->reg[column];
  35600. - if (_Unwind_IsExtendedContext (context) && context->by_value[index])
  35601. + if (_Unwind_IsExtendedContext (context) && context->by_value[column])
  35602. return (_Unwind_Word) (_Unwind_Internal_Ptr) ptr;
  35603. /* This will segfault if the register hasn't been saved. */
  35604. @@ -182,6 +186,15 @@
  35605. }
  35606. }
  35607. +/* Get the value of register INDEX as saved in CONTEXT. */
  35608. +
  35609. +inline _Unwind_Word
  35610. +_Unwind_GetGR (struct _Unwind_Context *context, int index)
  35611. +{
  35612. + gcc_assert (0 <= index && index < FIRST_PSEUDO_REGISTER + 1);
  35613. + return _Unwind_ByColumn_GetGR (context, DWARF_REG_TO_UNWIND_COLUMN (index));
  35614. +}
  35615. +
  35616. static inline void *
  35617. _Unwind_GetPtr (struct _Unwind_Context *context, int index)
  35618. {
  35619. @@ -198,23 +211,22 @@
  35620. /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
  35621. -inline void
  35622. -_Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
  35623. +static inline void
  35624. +_Unwind_ByColumn_SetGR (struct _Unwind_Context *context, int column, _Unwind_Word val)
  35625. {
  35626. int size;
  35627. void *ptr;
  35628. - index = DWARF_REG_TO_UNWIND_COLUMN (index);
  35629. - gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
  35630. - size = dwarf_reg_size_table[index];
  35631. + gcc_assert (0 <= column && column < (int) sizeof(dwarf_reg_size_table));
  35632. + size = dwarf_reg_size_table[column];
  35633. - if (_Unwind_IsExtendedContext (context) && context->by_value[index])
  35634. + if (_Unwind_IsExtendedContext (context) && context->by_value[column])
  35635. {
  35636. - context->reg[index] = (void *) (_Unwind_Internal_Ptr) val;
  35637. + context->reg[column] = (void *) (_Unwind_Internal_Ptr) val;
  35638. return;
  35639. }
  35640. - ptr = context->reg[index];
  35641. + ptr = context->reg[column];
  35642. if (size == sizeof(_Unwind_Ptr))
  35643. * (_Unwind_Ptr *) ptr = val;
  35644. @@ -225,15 +237,44 @@
  35645. }
  35646. }
  35647. +/* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
  35648. +
  35649. +inline void
  35650. +_Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
  35651. +{
  35652. + gcc_assert (0 <= index && index < FIRST_PSEUDO_REGISTER + 1);
  35653. + return _Unwind_ByColumn_SetGR (context, DWARF_REG_TO_UNWIND_COLUMN (index), val);
  35654. +}
  35655. +
  35656. +/* Get the pointer to a register COLUMN as saved in CONTEXT. */
  35657. +
  35658. +static inline void *
  35659. +_Unwind_ByColumn_GetGRPtr (struct _Unwind_Context *context, int column)
  35660. +{
  35661. + gcc_assert (0 <= column && column < DWARF_FRAME_REGISTERS + 1);
  35662. + if (_Unwind_IsExtendedContext (context) && context->by_value[column])
  35663. + return &context->reg[column];
  35664. + return context->reg[column];
  35665. +}
  35666. +
  35667. /* Get the pointer to a register INDEX as saved in CONTEXT. */
  35668. static inline void *
  35669. _Unwind_GetGRPtr (struct _Unwind_Context *context, int index)
  35670. {
  35671. - index = DWARF_REG_TO_UNWIND_COLUMN (index);
  35672. - if (_Unwind_IsExtendedContext (context) && context->by_value[index])
  35673. - return &context->reg[index];
  35674. - return context->reg[index];
  35675. + gcc_assert (0 <= index && index < FIRST_PSEUDO_REGISTER + 1);
  35676. + return _Unwind_ByColumn_GetGRPtr (context, DWARF_REG_TO_UNWIND_COLUMN (index));
  35677. +}
  35678. +
  35679. +/* Set the pointer to a register COLUMN as saved in CONTEXT. */
  35680. +
  35681. +static inline void
  35682. +_Unwind_ByColumn_SetGRPtr (struct _Unwind_Context *context, int column, void *p)
  35683. +{
  35684. + gcc_assert (0 <= column && column < DWARF_FRAME_REGISTERS + 1);
  35685. + if (_Unwind_IsExtendedContext (context))
  35686. + context->by_value[column] = 0;
  35687. + context->reg[column] = p;
  35688. }
  35689. /* Set the pointer to a register INDEX as saved in CONTEXT. */
  35690. @@ -241,24 +282,41 @@
  35691. static inline void
  35692. _Unwind_SetGRPtr (struct _Unwind_Context *context, int index, void *p)
  35693. {
  35694. - index = DWARF_REG_TO_UNWIND_COLUMN (index);
  35695. - if (_Unwind_IsExtendedContext (context))
  35696. - context->by_value[index] = 0;
  35697. - context->reg[index] = p;
  35698. + gcc_assert (0 <= index && index < FIRST_PSEUDO_REGISTER + 1);
  35699. + _Unwind_ByColumn_SetGRPtr (context, DWARF_REG_TO_UNWIND_COLUMN (index), p);
  35700. }
  35701. +/* Overwrite the saved value for register COLUMN in CONTEXT with VAL. */
  35702. +
  35703. +static inline void
  35704. +_Unwind_ByColumn_SetGRValue (struct _Unwind_Context *context, int column,
  35705. + _Unwind_Word val)
  35706. +{
  35707. + gcc_assert (0 <= column && column < (int) sizeof(dwarf_reg_size_table));
  35708. + gcc_assert (dwarf_reg_size_table[column] == sizeof (_Unwind_Ptr));
  35709. +
  35710. + context->by_value[column] = 1;
  35711. + context->reg[column] = (void *) (_Unwind_Internal_Ptr) val;
  35712. +}
  35713. /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
  35714. static inline void
  35715. _Unwind_SetGRValue (struct _Unwind_Context *context, int index,
  35716. _Unwind_Word val)
  35717. {
  35718. - index = DWARF_REG_TO_UNWIND_COLUMN (index);
  35719. - gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
  35720. - gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Ptr));
  35721. + gcc_assert (0 <= index && index < FIRST_PSEUDO_REGISTER + 1);
  35722. + _Unwind_ByColumn_SetGRValue (context, DWARF_REG_TO_UNWIND_COLUMN (index), val);
  35723. +}
  35724. +
  35725. +/* Return nonzero if register COLUMN is stored by value rather than
  35726. + by reference. */
  35727. +
  35728. +static inline int
  35729. +_Unwind_ByColumn_GRByValue (struct _Unwind_Context *context, int column)
  35730. +{
  35731. - context->by_value[index] = 1;
  35732. - context->reg[index] = (void *) (_Unwind_Internal_Ptr) val;
  35733. + gcc_assert (0 <= column && column < DWARF_FRAME_REGISTERS + 1);
  35734. + return context->by_value[column];
  35735. }
  35736. /* Return nonzero if register INDEX is stored by value rather than
  35737. @@ -267,8 +325,8 @@
  35738. static inline int
  35739. _Unwind_GRByValue (struct _Unwind_Context *context, int index)
  35740. {
  35741. - index = DWARF_REG_TO_UNWIND_COLUMN (index);
  35742. - return context->by_value[index];
  35743. + gcc_assert (0 <= index && index < FIRST_PSEUDO_REGISTER + 1);
  35744. + return _Unwind_ByColumn_GRByValue (context, DWARF_REG_TO_UNWIND_COLUMN (index));
  35745. }
  35746. /* Retrieve the return address for CONTEXT. */
  35747. @@ -1225,8 +1283,12 @@
  35748. _Unwind_SetSpColumn (struct _Unwind_Context *context, void *cfa,
  35749. _Unwind_SpTmp *tmp_sp)
  35750. {
  35751. - int size = dwarf_reg_size_table[__builtin_dwarf_sp_column ()];
  35752. -
  35753. + int column = DWARF_REG_TO_UNWIND_COLUMN (__builtin_dwarf_sp_column ());
  35754. + int size;
  35755. +
  35756. + gcc_assert (0 <= column && column < (int)sizeof (dwarf_reg_size_table));
  35757. +
  35758. + size = dwarf_reg_size_table[column];
  35759. if (size == sizeof(_Unwind_Ptr))
  35760. tmp_sp->ptr = (_Unwind_Ptr) cfa;
  35761. else
  35762. @@ -1234,7 +1296,8 @@
  35763. gcc_assert (size == sizeof(_Unwind_Word));
  35764. tmp_sp->word = (_Unwind_Ptr) cfa;
  35765. }
  35766. - _Unwind_SetGRPtr (context, __builtin_dwarf_sp_column (), tmp_sp);
  35767. +
  35768. + _Unwind_ByColumn_SetGRPtr (context, column, tmp_sp);
  35769. }
  35770. static void
  35771. @@ -1299,19 +1362,19 @@
  35772. break;
  35773. case REG_SAVED_OFFSET:
  35774. - _Unwind_SetGRPtr (context, i,
  35775. + _Unwind_ByColumn_SetGRPtr (context, i,
  35776. (void *) (cfa + fs->regs.reg[i].loc.offset));
  35777. break;
  35778. case REG_SAVED_REG:
  35779. if (_Unwind_GRByValue (&orig_context, fs->regs.reg[i].loc.reg))
  35780. - _Unwind_SetGRValue (context, i,
  35781. - _Unwind_GetGR (&orig_context,
  35782. - fs->regs.reg[i].loc.reg));
  35783. + _Unwind_ByColumn_SetGRValue (context, i,
  35784. + _Unwind_GetGR (&orig_context,
  35785. + fs->regs.reg[i].loc.reg));
  35786. else
  35787. - _Unwind_SetGRPtr (context, i,
  35788. - _Unwind_GetGRPtr (&orig_context,
  35789. - fs->regs.reg[i].loc.reg));
  35790. + _Unwind_ByColumn_SetGRPtr (context, i,
  35791. + _Unwind_GetGRPtr (&orig_context,
  35792. + fs->regs.reg[i].loc.reg));
  35793. break;
  35794. case REG_SAVED_EXP:
  35795. @@ -1323,14 +1386,14 @@
  35796. exp = read_uleb128 (exp, &len);
  35797. val = execute_stack_op (exp, exp + len, &orig_context,
  35798. (_Unwind_Ptr) cfa);
  35799. - _Unwind_SetGRPtr (context, i, (void *) val);
  35800. + _Unwind_ByColumn_SetGRPtr (context, i, (void *) val);
  35801. }
  35802. break;
  35803. case REG_SAVED_VAL_OFFSET:
  35804. - _Unwind_SetGRValue (context, i,
  35805. - (_Unwind_Internal_Ptr)
  35806. - (cfa + fs->regs.reg[i].loc.offset));
  35807. + _Unwind_ByColumn_SetGRValue (context, i,
  35808. + (_Unwind_Internal_Ptr)
  35809. + (cfa + fs->regs.reg[i].loc.offset));
  35810. break;
  35811. case REG_SAVED_VAL_EXP:
  35812. @@ -1342,7 +1405,7 @@
  35813. exp = read_uleb128 (exp, &len);
  35814. val = execute_stack_op (exp, exp + len, &orig_context,
  35815. (_Unwind_Ptr) cfa);
  35816. - _Unwind_SetGRValue (context, i, val);
  35817. + _Unwind_ByColumn_SetGRValue (context, i, val);
  35818. }
  35819. break;
  35820. }
  35821. diff -Nur gcc-4.2.4.orig/gcc/varasm.c gcc-4.2.4/gcc/varasm.c
  35822. --- gcc-4.2.4.orig/gcc/varasm.c 2008-02-01 19:42:03.000000000 -0600
  35823. +++ gcc-4.2.4/gcc/varasm.c 2015-07-03 18:46:05.741283542 -0500
  35824. @@ -58,6 +58,22 @@
  35825. declarations for e.g. AIX 4.x. */
  35826. #endif
  35827. +
  35828. +/* Hooks to allow target specific control over the start/end of each
  35829. + function or variable definition */
  35830. +#ifndef ASSEMBLE_START_FUNCTION
  35831. +#define ASSEMBLE_START_FUNCTION(DECL,FNNAME)
  35832. +#endif
  35833. +#ifndef ASSEMBLE_END_FUNCTION
  35834. +#define ASSEMBLE_END_FUNCTION(DECL,FNNAME)
  35835. +#endif
  35836. +#ifndef ASSEMBLE_START_VARIABLE
  35837. +#define ASSEMBLE_START_VARIABLE(DECL)
  35838. +#endif
  35839. +#ifndef ASSEMBLE_END_VARIABLE
  35840. +#define ASSEMBLE_END_VARIABLE(DECL)
  35841. +#endif
  35842. +
  35843. /* The (assembler) name of the first globally-visible object output. */
  35844. extern GTY(()) const char *first_global_object_name;
  35845. extern GTY(()) const char *weak_global_object_name;
  35846. @@ -649,7 +665,7 @@
  35847. /* Return the section to use for string merging. */
  35848. -static section *
  35849. +section *
  35850. mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
  35851. unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
  35852. unsigned int flags ATTRIBUTE_UNUSED)
  35853. @@ -1416,6 +1432,9 @@
  35854. in_cold_section_p = first_function_block_is_cold;
  35855. + /* Prepare to emit a function */
  35856. + ASSEMBLE_START_FUNCTION (decl, fnname);
  35857. +
  35858. /* Switch to the correct text section for the start of the function. */
  35859. switch_to_section (function_section (decl));
  35860. @@ -1508,6 +1527,9 @@
  35861. ASM_OUTPUT_LABEL (asm_out_file, cfun->hot_section_end_label);
  35862. switch_to_section (save_text_section);
  35863. }
  35864. +
  35865. + /* Clean up after outputting a function */
  35866. + ASSEMBLE_END_FUNCTION (decl, fnname);
  35867. }
  35868. /* Assemble code to leave SIZE bytes of zeros. */
  35869. @@ -1826,6 +1848,9 @@
  35870. if (sect && (sect->common.flags & SECTION_CODE) != 0)
  35871. DECL_IN_TEXT_SECTION (decl) = 1;
  35872. + /* Prepare to output a variable */
  35873. + ASSEMBLE_START_VARIABLE (decl);
  35874. +
  35875. /* If the decl is part of an object_block, make sure that the decl
  35876. has been positioned within its block, but do not write out its
  35877. definition yet. output_object_blocks will do that later. */
  35878. @@ -1843,6 +1868,9 @@
  35879. ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (DECL_ALIGN_UNIT (decl)));
  35880. assemble_variable_contents (decl, name, dont_output_data);
  35881. }
  35882. +
  35883. + /* Clean up after outputting a variable */
  35884. + ASSEMBLE_END_VARIABLE (decl);
  35885. }
  35886. /* Return 1 if type TYPE contains any pointers. */
  35887. @@ -5872,10 +5900,9 @@
  35888. else if (DECL_WEAK (exp))
  35889. local_p = false;
  35890. /* If PIC, then assume that any global name can be overridden by
  35891. - symbols resolved from other modules, unless we are compiling with
  35892. - -fwhole-program, which assumes that names are local. */
  35893. + symbols resolved from other modules. */
  35894. else if (shlib)
  35895. - local_p = flag_whole_program;
  35896. + local_p = false;
  35897. /* Uninitialized COMMON variable may be unified with symbols
  35898. resolved from other modules. */
  35899. else if (DECL_COMMON (exp)
  35900. diff -Nur gcc-4.2.4.orig/gcc/var-tracking.c gcc-4.2.4/gcc/var-tracking.c
  35901. --- gcc-4.2.4.orig/gcc/var-tracking.c 2007-11-07 14:48:38.000000000 -0600
  35902. +++ gcc-4.2.4/gcc/var-tracking.c 2015-07-03 18:46:05.741283542 -0500
  35903. @@ -105,6 +105,7 @@
  35904. #include "expr.h"
  35905. #include "timevar.h"
  35906. #include "tree-pass.h"
  35907. +#include "tm_p.h"
  35908. /* Type of micro operation. */
  35909. enum micro_operation_type
  35910. diff -Nur gcc-4.2.4.orig/gcc/version.c gcc-4.2.4/gcc/version.c
  35911. --- gcc-4.2.4.orig/gcc/version.c 2005-03-16 00:04:10.000000000 -0600
  35912. +++ gcc-4.2.4/gcc/version.c 2015-07-03 18:46:05.741283542 -0500
  35913. @@ -1,4 +1,5 @@
  35914. #include "version.h"
  35915. +#include "../ccs_version.h"
  35916. /* This is the trailing component of the string reported as the
  35917. version number by all components of the compiler. For an official
  35918. @@ -8,7 +9,23 @@
  35919. in parentheses. You may also wish to include a number indicating
  35920. the revision of your modified compiler. */
  35921. -#define VERSUFFIX ""
  35922. +#ifndef CCS_BRANCH0_VN
  35923. +#define CCS_BRANCH0_VN 0
  35924. +#endif
  35925. +
  35926. +#ifndef CCS_STEP0_VN
  35927. +#define CCS_STEP0_VN 0
  35928. +#endif
  35929. +
  35930. +#define LIT(S) #S
  35931. +#define STR(N) LIT(N)
  35932. +
  35933. +#define VERSUFFIX " (IMG-" STR (CCS_MAJOR_VN) "." \
  35934. + STR (CCS_MINOR_VN) "." \
  35935. + STR (CCS_RELEASE_VN) "." \
  35936. + STR (CCS_BUILD_VN) \
  35937. + STR (CCS_BRANCH0_VN) \
  35938. + STR (CCS_STEP0_VN) ")"
  35939. /* This is the location of the online document giving instructions for
  35940. reporting bugs. If you distribute a modified version of GCC,
  35941. @@ -17,7 +34,7 @@
  35942. forward us bugs reported to you, if you determine that they are
  35943. not bugs in your modifications.) */
  35944. -const char bug_report_url[] = "<URL:http://gcc.gnu.org/bugs.html>";
  35945. +const char bug_report_url[] = "toolkit@metagence.com";
  35946. /* The complete version string, assembled from several pieces.
  35947. BASEVER, DATESTAMP, and DEVPHASE are defined by the Makefile. */
  35948. diff -Nur gcc-4.2.4.orig/gcc/web.c gcc-4.2.4/gcc/web.c
  35949. --- gcc-4.2.4.orig/gcc/web.c 2007-09-01 10:28:30.000000000 -0500
  35950. +++ gcc-4.2.4/gcc/web.c 2015-07-03 18:46:05.741283542 -0500
  35951. @@ -106,20 +106,20 @@
  35952. {
  35953. rtx insn = DF_REF_INSN (use);
  35954. struct df_link *link = DF_REF_CHAIN (use);
  35955. - struct df_ref *use_link;
  35956. - struct df_ref *def_link;
  35957. + struct df_ref *USE_link;
  35958. + struct df_ref *DEF_link;
  35959. rtx set;
  35960. if (insn)
  35961. {
  35962. - use_link = DF_INSN_USES (df, insn);
  35963. - def_link = DF_INSN_DEFS (df, insn);
  35964. + USE_link = DF_INSN_USES (df, insn);
  35965. + DEF_link = DF_INSN_DEFS (df, insn);
  35966. set = single_set (insn);
  35967. }
  35968. else
  35969. {
  35970. - use_link = NULL;
  35971. - def_link = NULL;
  35972. + USE_link = NULL;
  35973. + DEF_link = NULL;
  35974. set = NULL;
  35975. }
  35976. @@ -128,14 +128,35 @@
  35977. invalid instructions, so union all uses of the same operand for each
  35978. insn. */
  35979. - while (use_link)
  35980. - {
  35981. - if (use != use_link
  35982. - && DF_REF_REAL_REG (use) == DF_REF_REAL_REG (use_link))
  35983. - (*fun) (use_entry + DF_REF_ID (use),
  35984. + /* First handle any uses that are match_dup's of this use ... */
  35985. + {
  35986. + struct df_ref *use_link = USE_link;
  35987. +
  35988. + while (use_link)
  35989. + {
  35990. + if (use != use_link
  35991. + && DF_REF_REAL_REG (use) == DF_REF_REAL_REG (use_link))
  35992. + (*fun) (use_entry + DF_REF_ID (use),
  35993. use_entry + DF_REF_ID (use_link));
  35994. - use_link = use_link->next_ref;
  35995. - }
  35996. +
  35997. + use_link = use_link->next_ref;
  35998. + }
  35999. + }
  36000. +
  36001. + /* then handle any defs that are match_dup's of this use ... */
  36002. + {
  36003. + struct df_ref *def_link = DEF_link;
  36004. +
  36005. + while (def_link)
  36006. + {
  36007. + if (use != def_link
  36008. + && DF_REF_REAL_REG (use) == DF_REF_REAL_REG (def_link))
  36009. + (*fun) (use_entry + DF_REF_ID (use),
  36010. + def_entry + DF_REF_ID (def_link));
  36011. +
  36012. + def_link = def_link->next_ref;
  36013. + }
  36014. + }
  36015. /* Recognize trivial noop moves and attempt to keep them as noop.
  36016. While most of noop moves should be removed, we still keep some
  36017. @@ -145,6 +166,8 @@
  36018. && SET_SRC (set) == DF_REF_REG (use)
  36019. && SET_SRC (set) == SET_DEST (set))
  36020. {
  36021. + struct df_ref *def_link = DEF_link;
  36022. +
  36023. while (def_link)
  36024. {
  36025. if (DF_REF_REAL_REG (use) == DF_REF_REAL_REG (def_link))
  36026. @@ -153,6 +176,7 @@
  36027. def_link = def_link->next_ref;
  36028. }
  36029. }
  36030. +
  36031. while (link)
  36032. {
  36033. (*fun) (use_entry + DF_REF_ID (use),
  36034. @@ -236,6 +260,7 @@
  36035. if (dump_file)
  36036. fprintf (dump_file, "Updating insn %i (%i->%i)\n",
  36037. INSN_UID (DF_REF_INSN (ref)), REGNO (oldreg), REGNO (reg));
  36038. +
  36039. *loc = reg;
  36040. }
  36041. @@ -273,6 +298,7 @@
  36042. for (i = 0; i < DF_USES_SIZE (df); i++)
  36043. replace_ref (DF_USES_GET (df, i),
  36044. entry_register (use_entry + i, DF_USES_GET (df, i), used));
  36045. +
  36046. for (i = 0; i < DF_DEFS_SIZE (df); i++)
  36047. replace_ref (DF_DEFS_GET (df, i),
  36048. entry_register (def_entry + i, DF_DEFS_GET (df, i), used));
  36049. diff -Nur gcc-4.2.4.orig/libstdc++-v3/configure.host gcc-4.2.4/libstdc++-v3/configure.host
  36050. --- gcc-4.2.4.orig/libstdc++-v3/configure.host 2006-07-14 17:41:43.000000000 -0500
  36051. +++ gcc-4.2.4/libstdc++-v3/configure.host 2015-07-03 18:46:05.789283541 -0500
  36052. @@ -97,6 +97,9 @@
  36053. m680[246]0)
  36054. try_cpu=m68k
  36055. ;;
  36056. + metag*)
  36057. + try_cpu=metag
  36058. + ;;
  36059. powerpc* | rs6000)
  36060. try_cpu=powerpc
  36061. ;;
  36062. @@ -231,6 +234,9 @@
  36063. atomicity_dir=os/irix
  36064. atomic_word_dir=os/irix
  36065. ;;
  36066. + metag*)
  36067. + os_include_dir="os/generic"
  36068. + ;;
  36069. mingw32*)
  36070. os_include_dir="os/mingw32"
  36071. ;;
  36072. @@ -297,6 +303,9 @@
  36073. fi
  36074. esac
  36075. ;;
  36076. + metag*)
  36077. + atomicity_dir="cpu/generic"
  36078. + ;;
  36079. mips*-*-*)
  36080. case "${host_os}" in
  36081. gnu* | linux* | irix*)
  36082. diff -Nur gcc-4.2.4.orig/libstdc++-v3/include/c_std/std_cstring.h gcc-4.2.4/libstdc++-v3/include/c_std/std_cstring.h
  36083. --- gcc-4.2.4.orig/libstdc++-v3/include/c_std/std_cstring.h 2006-12-07 03:33:51.000000000 -0600
  36084. +++ gcc-4.2.4/libstdc++-v3/include/c_std/std_cstring.h 2015-07-03 18:46:05.789283541 -0500
  36085. @@ -75,6 +75,8 @@
  36086. #undef strerror
  36087. #undef strlen
  36088. +#undef index
  36089. +
  36090. _GLIBCXX_BEGIN_NAMESPACE(std)
  36091. using ::memcpy;
  36092. diff -Nur gcc-4.2.4.orig/libstdc++-v3/include/Makefile.in gcc-4.2.4/libstdc++-v3/include/Makefile.in
  36093. --- gcc-4.2.4.orig/libstdc++-v3/include/Makefile.in 2007-07-05 06:46:00.000000000 -0500
  36094. +++ gcc-4.2.4/libstdc++-v3/include/Makefile.in 2015-07-03 18:46:05.789283541 -0500
  36095. @@ -974,6 +974,7 @@
  36096. ${host_builddir}/gthr.h \
  36097. ${host_builddir}/gthr-single.h \
  36098. ${host_builddir}/gthr-posix.h \
  36099. + ${host_builddir}/gthr-posix95.h \
  36100. ${host_builddir}/gthr-tpf.h \
  36101. ${host_builddir}/gthr-default.h
  36102. @@ -1413,6 +1414,14 @@
  36103. -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \
  36104. < ${toplevel_srcdir}/gcc/gthr-posix.h > $@
  36105. +${host_builddir}/gthr-posix95.h: ${toplevel_srcdir}/gcc/gthr-posix95.h \
  36106. + stamp-${host_alias}
  36107. + sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
  36108. + -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \
  36109. + -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \
  36110. + -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \
  36111. + < ${toplevel_srcdir}/gcc/gthr-posix95.h > $@
  36112. +
  36113. ${host_builddir}/gthr-tpf.h: ${toplevel_srcdir}/gcc/gthr-tpf.h \
  36114. stamp-${host_alias}
  36115. sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \