gcc-4.1-tigcc-patch.diff 319 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146
  1. diff -Naur gcc-4.1.2.orig/config.guess gcc-4.1.2-src/config.guess
  2. --- gcc-4.1.2.orig/config.guess 2005-11-24 13:49:42.000000000 +0100
  3. +++ gcc-4.1.2-src/config.guess 2007-02-19 02:32:34.000000000 +0100
  4. @@ -770,11 +770,11 @@
  5. echo ${UNAME_MACHINE}-pc-cygwin
  6. exit ;;
  7. i*:MINGW*:*)
  8. - echo ${UNAME_MACHINE}-pc-mingw32
  9. + echo i386-pc-mingw32
  10. exit ;;
  11. i*:windows32*:*)
  12. # uname -m includes "-pc" on this system.
  13. - echo ${UNAME_MACHINE}-mingw32
  14. + echo i386-pc-mingw32
  15. exit ;;
  16. i*:PW*:*)
  17. echo ${UNAME_MACHINE}-pc-pw32
  18. diff -Naur gcc-4.1.2.orig/gcc/attribs.c gcc-4.1.2-src/gcc/attribs.c
  19. --- gcc-4.1.2.orig/gcc/attribs.c 2005-06-25 04:02:01.000000000 +0200
  20. +++ gcc-4.1.2-src/gcc/attribs.c 2007-02-19 02:32:34.000000000 +0100
  21. @@ -131,7 +131,11 @@
  22. information, in the form of a bitwise OR of flags in enum attribute_flags
  23. from tree.h. Depending on these flags, some attributes may be
  24. returned to be applied at a later stage (for example, to apply
  25. - a decl attribute to the declaration rather than to its type). */
  26. + a decl attribute to the declaration rather than to its type). If
  27. + ATTR_FLAG_BUILT_IN is not set and *NODE is a DECL, then also consider
  28. + whether there might be some default attributes to apply to this DECL;
  29. + if so, decl_attributes will be called recursively with those attributes
  30. + and ATTR_FLAG_BUILT_IN set. */
  31. tree
  32. decl_attributes (tree *node, tree attributes, int flags)
  33. @@ -144,6 +148,10 @@
  34. targetm.insert_attributes (*node, &attributes);
  35. + if (DECL_P (*node) && TREE_CODE (*node) == FUNCTION_DECL
  36. + && !(flags & (int) ATTR_FLAG_BUILT_IN))
  37. + (*lang_hooks.insert_default_attributes) (*node);
  38. +
  39. for (a = attributes; a; a = TREE_CHAIN (a))
  40. {
  41. tree name = TREE_PURPOSE (a);
  42. diff -Naur gcc-4.1.2.orig/gcc/builtin-attrs.def gcc-4.1.2-src/gcc/builtin-attrs.def
  43. --- gcc-4.1.2.orig/gcc/builtin-attrs.def 2005-06-27 14:17:39.000000000 +0200
  44. +++ gcc-4.1.2-src/gcc/builtin-attrs.def 2007-02-19 02:32:34.000000000 +0100
  45. @@ -169,6 +169,10 @@
  46. DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
  47. DEF_FORMAT_ATTRIBUTE(SCANF,2,2_0)
  48. DEF_FORMAT_ATTRIBUTE(SCANF,2,2_3)
  49. +DEF_FORMAT_ATTRIBUTE(SCANF,3,3_0)
  50. +DEF_FORMAT_ATTRIBUTE(SCANF,3,3_4)
  51. +DEF_FORMAT_ATTRIBUTE(SCANF,4,4_0)
  52. +DEF_FORMAT_ATTRIBUTE(SCANF,4,4_5)
  53. DEF_FORMAT_ATTRIBUTE(STRFTIME,3,3_0)
  54. DEF_FORMAT_ATTRIBUTE(STRFMON,3,3_4)
  55. #undef DEF_FORMAT_ATTRIBUTE
  56. @@ -181,3 +185,25 @@
  57. DEF_FORMAT_ARG_ATTRIBUTE(2)
  58. #undef DEF_FORMAT_ARG_ATTRIBUTE
  59. +/* (TIGCC 20040219, 20050205) Default attributes. */
  60. +#define DEF_FN_ATTR_IDENT(NAME, ATTRS, PREDICATE) \
  61. + DEF_ATTR_IDENT (ATTR_ ## NAME, #NAME) \
  62. + DEF_FN_ATTR (ATTR_ ## NAME, ATTRS, PREDICATE)
  63. +#define DEF_C89_ATTR(NAME, ATTRS) DEF_FN_ATTR_IDENT (NAME, ATTRS, flag_hosted)
  64. +DEF_C89_ATTR (printf, ATTR_FORMAT_PRINTF_1_2)
  65. +DEF_C89_ATTR (fprintf, ATTR_FORMAT_PRINTF_2_3)
  66. +DEF_C89_ATTR (sprintf, ATTR_FORMAT_PRINTF_2_3)
  67. +DEF_C89_ATTR (scanf, ATTR_FORMAT_SCANF_1_2)
  68. +DEF_C89_ATTR (fscanf, ATTR_FORMAT_SCANF_2_3)
  69. +DEF_C89_ATTR (sscanf, ATTR_FORMAT_SCANF_2_3)
  70. +DEF_C89_ATTR (vprintf, ATTR_FORMAT_PRINTF_1_0)
  71. +DEF_C89_ATTR (vfprintf, ATTR_FORMAT_PRINTF_2_0)
  72. +DEF_C89_ATTR (vsprintf, ATTR_FORMAT_PRINTF_2_0)
  73. +DEF_C89_ATTR (vcbprintf, ATTR_FORMAT_PRINTF_3_0)
  74. +DEF_C89_ATTR (cbprintf, ATTR_FORMAT_PRINTF_3_4)
  75. +DEF_C89_ATTR (vcbscanf, ATTR_FORMAT_SCANF_4_0)
  76. +DEF_C89_ATTR (cbscanf, ATTR_FORMAT_SCANF_4_5)
  77. +DEF_C89_ATTR (vscanf, ATTR_FORMAT_SCANF_1_0)
  78. +DEF_C89_ATTR (vfscanf, ATTR_FORMAT_SCANF_2_0)
  79. +DEF_C89_ATTR (vsscanf, ATTR_FORMAT_SCANF_2_0)
  80. +
  81. diff -Naur gcc-4.1.2.orig/gcc/builtins.c gcc-4.1.2-src/gcc/builtins.c
  82. --- gcc-4.1.2.orig/gcc/builtins.c 2006-10-06 19:06:52.000000000 +0200
  83. +++ gcc-4.1.2-src/gcc/builtins.c 2007-02-19 02:32:34.000000000 +0100
  84. @@ -47,6 +47,7 @@
  85. #include "langhooks.h"
  86. #include "basic-block.h"
  87. #include "tree-mudflap.h"
  88. +#include "ggc.h"
  89. #ifndef PAD_VARARGS_DOWN
  90. #define PAD_VARARGS_DOWN BYTES_BIG_ENDIAN
  91. @@ -76,7 +77,9 @@
  92. static rtx c_readstr (const char *, enum machine_mode);
  93. static int target_char_cast (tree, char *);
  94. static rtx get_memory_rtx (tree, tree);
  95. +#if 0
  96. static tree build_string_literal (int, const char *);
  97. +#endif /* 0 */
  98. static int apply_args_size (void);
  99. static int apply_result_size (void);
  100. #if defined (HAVE_untyped_call) || defined (HAVE_untyped_return)
  101. @@ -91,25 +94,32 @@
  102. static void expand_builtin_return (rtx);
  103. static enum type_class type_to_class (tree);
  104. static rtx expand_builtin_classify_type (tree);
  105. +#if 0
  106. static void expand_errno_check (tree, rtx);
  107. static rtx expand_builtin_mathfn (tree, rtx, rtx);
  108. static rtx expand_builtin_mathfn_2 (tree, rtx, rtx);
  109. static rtx expand_builtin_mathfn_3 (tree, rtx, rtx);
  110. static rtx expand_builtin_int_roundingfn (tree, rtx, rtx);
  111. +#endif /* 0 */
  112. static rtx expand_builtin_args_info (tree);
  113. static rtx expand_builtin_next_arg (void);
  114. static rtx expand_builtin_va_start (tree);
  115. static rtx expand_builtin_va_end (tree);
  116. static rtx expand_builtin_va_copy (tree);
  117. +#if 0
  118. static rtx expand_builtin_memcmp (tree, tree, rtx, enum machine_mode);
  119. static rtx expand_builtin_strcmp (tree, rtx, enum machine_mode);
  120. static rtx expand_builtin_strncmp (tree, rtx, enum machine_mode);
  121. +#endif /* 0 */
  122. static rtx builtin_memcpy_read_str (void *, HOST_WIDE_INT, enum machine_mode);
  123. +#if 0
  124. static rtx expand_builtin_strcat (tree, tree, rtx, enum machine_mode);
  125. static rtx expand_builtin_strncat (tree, rtx, enum machine_mode);
  126. static rtx expand_builtin_strspn (tree, rtx, enum machine_mode);
  127. static rtx expand_builtin_strcspn (tree, rtx, enum machine_mode);
  128. +#endif /* 0 */
  129. static rtx expand_builtin_memcpy (tree, rtx, enum machine_mode);
  130. +#if 0
  131. static rtx expand_builtin_mempcpy (tree, tree, rtx, enum machine_mode, int);
  132. static rtx expand_builtin_memmove (tree, tree, rtx, enum machine_mode, tree);
  133. static rtx expand_builtin_bcopy (tree);
  134. @@ -117,33 +127,43 @@
  135. static rtx expand_builtin_stpcpy (tree, rtx, enum machine_mode);
  136. static rtx builtin_strncpy_read_str (void *, HOST_WIDE_INT, enum machine_mode);
  137. static rtx expand_builtin_strncpy (tree, rtx, enum machine_mode);
  138. +#endif /* 0 */
  139. static rtx builtin_memset_read_str (void *, HOST_WIDE_INT, enum machine_mode);
  140. static rtx builtin_memset_gen_str (void *, HOST_WIDE_INT, enum machine_mode);
  141. static rtx expand_builtin_memset (tree, rtx, enum machine_mode, tree);
  142. +#if 0
  143. static rtx expand_builtin_bzero (tree);
  144. static rtx expand_builtin_strlen (tree, rtx, enum machine_mode);
  145. static rtx expand_builtin_strstr (tree, tree, rtx, enum machine_mode);
  146. static rtx expand_builtin_strpbrk (tree, tree, rtx, enum machine_mode);
  147. static rtx expand_builtin_strchr (tree, tree, rtx, enum machine_mode);
  148. static rtx expand_builtin_strrchr (tree, tree, rtx, enum machine_mode);
  149. +#endif /* 0 */
  150. static rtx expand_builtin_alloca (tree, rtx);
  151. static rtx expand_builtin_unop (enum machine_mode, tree, rtx, rtx, optab);
  152. static rtx expand_builtin_frame_address (tree, tree);
  153. +#if 0
  154. static rtx expand_builtin_fputs (tree, rtx, bool);
  155. static rtx expand_builtin_printf (tree, rtx, enum machine_mode, bool);
  156. static rtx expand_builtin_fprintf (tree, rtx, enum machine_mode, bool);
  157. static rtx expand_builtin_sprintf (tree, rtx, enum machine_mode);
  158. +#endif /* 0 */
  159. static tree stabilize_va_list (tree, int);
  160. static rtx expand_builtin_expect (tree, rtx);
  161. static tree fold_builtin_constant_p (tree);
  162. static tree fold_builtin_classify_type (tree);
  163. +#if 0
  164. static tree fold_builtin_strlen (tree);
  165. static tree fold_builtin_inf (tree, int);
  166. static tree fold_builtin_nan (tree, tree, int);
  167. +#endif /* 0 */
  168. static int validate_arglist (tree, ...);
  169. +#if 0
  170. static bool integer_valued_real_p (tree);
  171. static tree fold_trunc_transparent_mathfn (tree, tree);
  172. +#endif /* 0 */
  173. static bool readonly_data_expr (tree);
  174. +#if 0
  175. static rtx expand_builtin_fabs (tree, rtx, rtx);
  176. static rtx expand_builtin_signbit (tree, rtx);
  177. static tree fold_builtin_cabs (tree, tree);
  178. @@ -161,7 +181,9 @@
  179. static tree fold_builtin_round (tree, tree);
  180. static tree fold_builtin_int_roundingfn (tree, tree);
  181. static tree fold_builtin_bitop (tree, tree);
  182. +#endif /* 0 */
  183. static tree fold_builtin_memcpy (tree, tree);
  184. +#if 0
  185. static tree fold_builtin_mempcpy (tree, tree, int);
  186. static tree fold_builtin_memmove (tree, tree);
  187. static tree fold_builtin_strchr (tree, tree);
  188. @@ -177,8 +199,10 @@
  189. static tree fold_builtin_abs (tree, tree);
  190. static tree fold_builtin_unordered_cmp (tree, tree, enum tree_code,
  191. enum tree_code);
  192. +#endif /* 0 */
  193. static tree fold_builtin_1 (tree, tree, bool);
  194. +#if 0
  195. static tree fold_builtin_strpbrk (tree, tree);
  196. static tree fold_builtin_strstr (tree, tree);
  197. static tree fold_builtin_strrchr (tree, tree);
  198. @@ -208,6 +232,10 @@
  199. static char target_percent_c[3];
  200. static char target_percent_s[3];
  201. static char target_percent_s_newline[4];
  202. +#endif /* 0 */
  203. +
  204. +/* (TIGCC 20050206) Implement ER_throw. */
  205. +static void expand_builtin_ER_throw (tree);
  206. /* Return true if NODE should be considered for inline expansion regardless
  207. of the optimization level. This means whenever a function is invoked with
  208. @@ -1233,7 +1261,13 @@
  209. size += GET_MODE_SIZE (Pmode);
  210. for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  211. - if (FUNCTION_ARG_REGNO_P (regno))
  212. + if (0 /*FUNCTION_ARG_REGNO_P (regno)*/)
  213. + /* (TIGCC) Do NOT use register passing for __builtin_apply since:
  214. + 1. It doesn't work: ALL registers are POSSIBLE registers for
  215. + function parameters, so this code uses up all
  216. + registers.
  217. + 2. It significantly increases code size.
  218. + 3. The default calling convention is stkparm anyway. */
  219. {
  220. mode = reg_raw_mode[regno];
  221. @@ -1686,6 +1720,7 @@
  222. tree
  223. mathfn_built_in (tree type, enum built_in_function fn)
  224. {
  225. +#if 0
  226. enum built_in_function fcode, fcodef, fcodel;
  227. switch (fn)
  228. @@ -1780,9 +1815,11 @@
  229. else if (TYPE_MAIN_VARIANT (type) == long_double_type_node)
  230. return implicit_built_in_decls[fcodel];
  231. else
  232. +#endif /* 0 */
  233. return 0;
  234. }
  235. +#if 0
  236. /* If errno must be maintained, expand the RTL to check if the result,
  237. TARGET, of a built-in function call, EXP, is NaN, and if so set
  238. errno to EDOM. */
  239. @@ -2893,6 +2930,7 @@
  240. }
  241. return 0;
  242. }
  243. +#endif /* 0 */
  244. /* Callback routine for store_by_pieces. Read GET_MODE_BITSIZE (MODE)
  245. bytes from constant string DATA + OFFSET and return it as target
  246. @@ -2986,6 +3024,7 @@
  247. }
  248. }
  249. +#if 0
  250. /* Expand a call to the mempcpy builtin, with arguments in ARGLIST.
  251. Return 0 if we failed; the caller should emit a normal call,
  252. otherwise try to get the result in TARGET, if convenient (and in
  253. @@ -3409,6 +3448,7 @@
  254. }
  255. return 0;
  256. }
  257. +#endif /* 0 */
  258. /* Callback routine for store_by_pieces. Read GET_MODE_BITSIZE (MODE)
  259. bytes from constant string DATA + OFFSET and return it as target
  260. @@ -3577,6 +3617,7 @@
  261. }
  262. }
  263. +#if 0
  264. /* Expand expression EXP, which is a call to the bzero builtin. Return 0
  265. if we failed the caller should emit a normal call. */
  266. @@ -4110,6 +4151,7 @@
  267. }
  268. return 0;
  269. }
  270. +#endif /* 0 */
  271. /* Expand a call to __builtin_saveregs, generating the result in TARGET,
  272. if that's convenient. */
  273. @@ -4664,6 +4706,7 @@
  274. return convert_to_mode (target_mode, target, 0);
  275. }
  276. +#if 0
  277. /* If the string passed to fputs is a constant and is one character
  278. long, we attempt to transform this call into __builtin_fputc(). */
  279. @@ -4680,6 +4723,7 @@
  280. }
  281. return 0;
  282. }
  283. +#endif /* 0 */
  284. /* Expand a call to __builtin_expect. We return our argument and emit a
  285. NOTE_INSN_EXPECTED_VALUE note. This is the expansion of __builtin_expect in
  286. @@ -4852,6 +4896,35 @@
  287. emit_barrier ();
  288. }
  289. +/* (TIGCC 20050206) Implement ER_throw. */
  290. +static void
  291. +expand_builtin_ER_throw (tree arglist)
  292. +{
  293. + tree arg;
  294. + char buffer[40];
  295. +
  296. + if (!validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE))
  297. + {
  298. + error ("invalid argument list for ER_throw");
  299. + return;
  300. + }
  301. +
  302. + arg = TREE_VALUE (arglist);
  303. +
  304. + if (TREE_CODE (arg) != INTEGER_CST)
  305. + {
  306. + error ("argument to ER_throw must be a constant");
  307. + return;
  308. + }
  309. +
  310. + sprintf (buffer, ".word _A_LINE+%d", (int) TREE_INT_CST_LOW (arg));
  311. +
  312. + emit_insn (gen_rtx_ASM_INPUT (VOIDmode, ggc_strdup (buffer)));
  313. +
  314. + emit_barrier ();
  315. +}
  316. +
  317. +#if 0
  318. /* Expand a call to fabs, fabsf or fabsl with arguments ARGLIST.
  319. Return 0 if a normal call should be emitted rather than expanding
  320. the function inline. If convenient, the result should be placed
  321. @@ -5220,6 +5293,7 @@
  322. return 0;
  323. }
  324. +#endif /* 0 */
  325. /* Expand a call to either the entry or exit function profiler. */
  326. @@ -5324,6 +5398,7 @@
  327. return tramp;
  328. }
  329. +#if 0
  330. /* Expand a call to the built-in signbit, signbitf or signbitl function.
  331. Return NULL_RTX if a normal call should be emitted rather than expanding
  332. the function in-line. EXP is the expression that is a call to the builtin
  333. @@ -5667,6 +5742,7 @@
  334. expand_builtin_synchronize ();
  335. emit_move_insn (mem, val);
  336. }
  337. +#endif /* 0 */
  338. /* Expand an expression EXP that calls a built-in function,
  339. with result going to TARGET if that's convenient
  340. @@ -5726,6 +5802,7 @@
  341. switch (fcode)
  342. {
  343. +#if 0
  344. case BUILT_IN_FABS:
  345. case BUILT_IN_FABSF:
  346. case BUILT_IN_FABSL:
  347. @@ -5894,6 +5971,7 @@
  348. if (target)
  349. return target;
  350. break;
  351. +#endif /* 0 */
  352. case BUILT_IN_APPLY_ARGS:
  353. return expand_builtin_apply_args ();
  354. @@ -6030,6 +6108,7 @@
  355. return target;
  356. break;
  357. +#if 0
  358. case BUILT_IN_STRLEN:
  359. target = expand_builtin_strlen (arglist, target, target_mode);
  360. if (target)
  361. @@ -6103,6 +6182,7 @@
  362. if (target)
  363. return target;
  364. break;
  365. +#endif /* 0 */
  366. case BUILT_IN_MEMCPY:
  367. target = expand_builtin_memcpy (exp, target, mode);
  368. @@ -6110,6 +6190,7 @@
  369. return target;
  370. break;
  371. +#if 0
  372. case BUILT_IN_MEMPCPY:
  373. target = expand_builtin_mempcpy (arglist, TREE_TYPE (exp), target, mode, /*endp=*/ 1);
  374. if (target)
  375. @@ -6128,6 +6209,7 @@
  376. if (target)
  377. return target;
  378. break;
  379. +#endif /* 0 */
  380. case BUILT_IN_MEMSET:
  381. target = expand_builtin_memset (arglist, target, mode, exp);
  382. @@ -6135,6 +6217,7 @@
  383. return target;
  384. break;
  385. +#if 0
  386. case BUILT_IN_BZERO:
  387. target = expand_builtin_bzero (exp);
  388. if (target)
  389. @@ -6159,6 +6242,7 @@
  390. if (target)
  391. return target;
  392. break;
  393. +#endif /* 0 */
  394. case BUILT_IN_SETJMP:
  395. target = expand_builtin_setjmp (arglist, target);
  396. @@ -6212,6 +6296,7 @@
  397. expand_builtin_trap ();
  398. return const0_rtx;
  399. +#if 0
  400. case BUILT_IN_PRINTF:
  401. target = expand_builtin_printf (exp, target, mode, false);
  402. if (target)
  403. @@ -6260,6 +6345,7 @@
  404. if (target)
  405. return target;
  406. break;
  407. +#endif /* 0 */
  408. /* Various hooks for the DWARF 2 __throw routine. */
  409. case BUILT_IN_UNWIND_INIT:
  410. @@ -6312,6 +6398,7 @@
  411. case BUILT_IN_ADJUST_TRAMPOLINE:
  412. return expand_builtin_adjust_trampoline (arglist);
  413. +#if 0
  414. case BUILT_IN_FORK:
  415. case BUILT_IN_EXECL:
  416. case BUILT_IN_EXECV:
  417. @@ -6528,6 +6615,11 @@
  418. case BUILT_IN_VSPRINTF_CHK:
  419. maybe_emit_sprintf_chk_warning (exp, fcode);
  420. break;
  421. +#endif /* 0 */
  422. +
  423. + case BUILT_IN_ER_THROW:
  424. + expand_builtin_ER_throw (arglist);
  425. + return const0_rtx;
  426. default: /* just do library call, if unknown builtin */
  427. break;
  428. @@ -6547,6 +6639,7 @@
  429. enum built_in_function
  430. builtin_mathfn_code (tree t)
  431. {
  432. +#if 0
  433. tree fndecl, arglist, parmlist;
  434. tree argtype, parmtype;
  435. @@ -6601,13 +6694,16 @@
  436. return END_BUILTINS;
  437. }
  438. else
  439. +#endif /* 0 */
  440. return END_BUILTINS;
  441. +#if 0
  442. arglist = TREE_CHAIN (arglist);
  443. }
  444. /* Variable-length argument list. */
  445. return DECL_FUNCTION_CODE (fndecl);
  446. +#endif /* 0 */
  447. }
  448. /* Fold a call to __builtin_constant_p, if we know it will evaluate to a
  449. @@ -6707,6 +6803,7 @@
  450. type_to_class (TREE_TYPE (TREE_VALUE (arglist))));
  451. }
  452. +#if 0
  453. /* Fold a call to __builtin_strlen. */
  454. static tree
  455. @@ -7520,6 +7617,7 @@
  456. return fold_fixed_mathfn (fndecl, arglist);
  457. }
  458. +#endif /* 0 */
  459. /* Fold function call to builtin ffs, clz, ctz, popcount and parity
  460. and their long and long long variants (i.e. ffsl and ffsll).
  461. @@ -7625,6 +7723,7 @@
  462. return NULL_TREE;
  463. }
  464. +#if 0
  465. /* Return true if EXPR is the real constant contained in VALUE. */
  466. static bool
  467. @@ -8015,6 +8114,7 @@
  468. return 0;
  469. }
  470. +#endif /* 0 */
  471. /* Fold function call to builtin memcpy. Return
  472. NULL_TREE if no simplification can be made. */
  473. @@ -8043,6 +8143,7 @@
  474. return 0;
  475. }
  476. +#if 0
  477. /* Fold function call to builtin mempcpy. Return
  478. NULL_TREE if no simplification can be made. */
  479. @@ -8776,6 +8877,7 @@
  480. return fold_build1 (TRUTH_NOT_EXPR, type,
  481. fold_build2 (code, type, arg0, arg1));
  482. }
  483. +#endif /* 0 */
  484. /* Used by constant folding to simplify calls to builtin functions. EXP is
  485. the CALL_EXPR of a call to a builtin function. IGNORE is true if the
  486. @@ -8794,6 +8896,7 @@
  487. fcode = DECL_FUNCTION_CODE (fndecl);
  488. switch (fcode)
  489. {
  490. +#if 0
  491. case BUILT_IN_FPUTS:
  492. return fold_builtin_fputs (arglist, ignore, false, NULL_TREE);
  493. @@ -8844,6 +8947,7 @@
  494. case BUILT_IN_SPRINTF:
  495. return fold_builtin_sprintf (arglist, ignore);
  496. +#endif /* 0 */
  497. case BUILT_IN_CONSTANT_P:
  498. {
  499. @@ -8865,6 +8969,7 @@
  500. case BUILT_IN_CLASSIFY_TYPE:
  501. return fold_builtin_classify_type (arglist);
  502. +#if 0
  503. case BUILT_IN_STRLEN:
  504. return fold_builtin_strlen (arglist);
  505. @@ -9055,6 +9160,7 @@
  506. case BUILT_IN_LLRINTF:
  507. case BUILT_IN_LLRINTL:
  508. return fold_fixed_mathfn (fndecl, arglist);
  509. +#endif /* 0 */
  510. case BUILT_IN_FFS:
  511. case BUILT_IN_FFSL:
  512. @@ -9076,6 +9182,7 @@
  513. case BUILT_IN_MEMCPY:
  514. return fold_builtin_memcpy (fndecl, arglist);
  515. +#if 0
  516. case BUILT_IN_MEMPCPY:
  517. return fold_builtin_mempcpy (arglist, type, /*endp=*/1);
  518. @@ -9129,11 +9236,13 @@
  519. case BUILT_IN_ISUNORDERED:
  520. return fold_builtin_unordered_cmp (fndecl, arglist, UNORDERED_EXPR,
  521. NOP_EXPR);
  522. +#endif /* 0 */
  523. /* We do the folding for va_start in the expander. */
  524. case BUILT_IN_VA_START:
  525. break;
  526. +#if 0
  527. case BUILT_IN_OBJECT_SIZE:
  528. return fold_builtin_object_size (arglist);
  529. case BUILT_IN_MEMCPY_CHK:
  530. @@ -9175,6 +9284,7 @@
  531. case BUILT_IN_VFPRINTF_CHK:
  532. return fold_builtin_fprintf (fndecl, arglist, ignore,
  533. DECL_FUNCTION_CODE (fndecl));
  534. +#endif /* 0 */
  535. default:
  536. break;
  537. @@ -9305,6 +9415,7 @@
  538. return false;
  539. }
  540. +#if 0
  541. /* Simplify a call to the strstr builtin.
  542. Return 0 if no simplification was possible, otherwise return the
  543. @@ -9843,6 +9954,7 @@
  544. hence there's no need to cast the result to integer_type_node. */
  545. return build_function_call_expr (fn, arglist);
  546. }
  547. +#endif /* 0 */
  548. /* Fold the new_arg's arguments (ARGLIST). Returns true if there was an error
  549. produced. False otherwise. This is done so that we don't output the error
  550. @@ -9912,6 +10024,7 @@
  551. }
  552. +#if 0
  553. /* Simplify a call to the sprintf builtin.
  554. Return 0 if no simplification was possible, otherwise return the
  555. @@ -11194,3 +11307,5 @@
  556. }
  557. return true;
  558. }
  559. +#endif /* 0 */
  560. +
  561. diff -Naur gcc-4.1.2.orig/gcc/builtins.def gcc-4.1.2-src/gcc/builtins.def
  562. --- gcc-4.1.2.orig/gcc/builtins.def 2006-11-01 06:59:44.000000000 +0100
  563. +++ gcc-4.1.2-src/gcc/builtins.def 2007-02-19 02:32:34.000000000 +0100
  564. @@ -507,6 +507,7 @@
  565. DEF_LIB_BUILTIN (BUILT_IN_STRSPN, "strspn", BT_FN_SIZE_CONST_STRING_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL)
  566. DEF_LIB_BUILTIN (BUILT_IN_STRSTR, "strstr", BT_FN_STRING_CONST_STRING_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL)
  567. +#if 0
  568. /* Category: stdio builtins. */
  569. DEF_LIB_BUILTIN (BUILT_IN_FPRINTF, "fprintf", BT_FN_INT_FILEPTR_CONST_STRING_VAR, ATTR_FORMAT_PRINTF_2_3)
  570. DEF_EXT_LIB_BUILTIN (BUILT_IN_FPRINTF_UNLOCKED, "fprintf_unlocked", BT_FN_INT_FILEPTR_CONST_STRING_VAR, ATTR_FORMAT_PRINTF_2_3)
  571. @@ -568,6 +569,7 @@
  572. DEF_C94_BUILTIN (BUILT_IN_ISWXDIGIT, "iswxdigit", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
  573. DEF_C94_BUILTIN (BUILT_IN_TOWLOWER, "towlower", BT_FN_WINT_WINT, ATTR_PURE_NOTHROW_LIST)
  574. DEF_C94_BUILTIN (BUILT_IN_TOWUPPER, "towupper", BT_FN_WINT_WINT, ATTR_PURE_NOTHROW_LIST)
  575. +#endif /* 0 */
  576. /* Category: miscellaneous builtins. */
  577. DEF_LIB_BUILTIN (BUILT_IN_ABORT, "abort", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LIST)
  578. @@ -577,7 +579,9 @@
  579. DEF_GCC_BUILTIN (BUILT_IN_APPLY, "apply", BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE, ATTR_NULL)
  580. DEF_GCC_BUILTIN (BUILT_IN_APPLY_ARGS, "apply_args", BT_FN_PTR_VAR, ATTR_NULL)
  581. DEF_GCC_BUILTIN (BUILT_IN_ARGS_INFO, "args_info", BT_FN_INT_INT, ATTR_NULL)
  582. +#if 0
  583. DEF_LIB_BUILTIN (BUILT_IN_CALLOC, "calloc", BT_FN_PTR_SIZE_SIZE, ATTR_MALLOC_NOTHROW_LIST)
  584. +#endif /* 0 */
  585. DEF_GCC_BUILTIN (BUILT_IN_CLASSIFY_TYPE, "classify_type", BT_FN_INT_VAR, ATTR_NULL)
  586. DEF_GCC_BUILTIN (BUILT_IN_CLZ, "clz", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST)
  587. DEF_GCC_BUILTIN (BUILT_IN_CLZIMAX, "clzimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST)
  588. @@ -659,6 +663,9 @@
  589. DEF_EXT_LIB_BUILTIN (BUILT_IN__EXIT, "_exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
  590. DEF_C99_BUILTIN (BUILT_IN__EXIT2, "_Exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
  591. +/* (TIGCC 20050206) Implement ER_throw. */
  592. +DEF_GCC_BUILTIN (BUILT_IN_ER_THROW, "ER_throw", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
  593. +
  594. /* Implementing nested functions. */
  595. DEF_BUILTIN_STUB (BUILT_IN_INIT_TRAMPOLINE, "__builtin_init_trampoline")
  596. DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline")
  597. @@ -670,6 +677,7 @@
  598. /* Object size checking builtins. */
  599. DEF_GCC_BUILTIN (BUILT_IN_OBJECT_SIZE, "object_size", BT_FN_SIZE_CONST_PTR_INT, ATTR_PURE_NOTHROW_LIST)
  600. +#if 0
  601. DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMCPY_CHK, "__memcpy_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_NOTHROW_NONNULL)
  602. DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMMOVE_CHK, "__memmove_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_NOTHROW_NONNULL)
  603. DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMPCPY_CHK, "__mempcpy_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_NOTHROW_NONNULL)
  604. @@ -687,6 +695,7 @@
  605. DEF_EXT_LIB_BUILTIN (BUILT_IN_PRINTF_CHK, "__printf_chk", BT_FN_INT_INT_CONST_STRING_VAR, ATTR_FORMAT_PRINTF_2_3)
  606. DEF_EXT_LIB_BUILTIN (BUILT_IN_VFPRINTF_CHK, "__vfprintf_chk", BT_FN_INT_FILEPTR_INT_CONST_STRING_VALIST_ARG, ATTR_FORMAT_PRINTF_3_0)
  607. DEF_EXT_LIB_BUILTIN (BUILT_IN_VPRINTF_CHK, "__vprintf_chk", BT_FN_INT_INT_CONST_STRING_VALIST_ARG, ATTR_FORMAT_PRINTF_2_0)
  608. +#endif /* 0 */
  609. /* Profiling hooks. */
  610. DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter")
  611. diff -Naur gcc-4.1.2.orig/gcc/c-common.c gcc-4.1.2-src/gcc/c-common.c
  612. --- gcc-4.1.2.orig/gcc/c-common.c 2007-01-05 20:44:10.000000000 +0100
  613. +++ gcc-4.1.2-src/gcc/c-common.c 2007-02-19 02:32:34.000000000 +0100
  614. @@ -2934,16 +2934,20 @@
  615. #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
  616. #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
  617. #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
  618. +#define DEF_FN_ATTR(NAME, ATTRS, PREDICATE) /* No entry needed in enum. */
  619. #include "builtin-attrs.def"
  620. #undef DEF_ATTR_NULL_TREE
  621. #undef DEF_ATTR_INT
  622. #undef DEF_ATTR_IDENT
  623. #undef DEF_ATTR_TREE_LIST
  624. +#undef DEF_FN_ATTR
  625. ATTR_LAST
  626. };
  627. static GTY(()) tree built_in_attributes[(int) ATTR_LAST];
  628. +static bool c_attrs_initialized = false;
  629. +
  630. static void c_init_attributes (void);
  631. /* Build tree nodes and builtin functions common to both C and C++ language
  632. @@ -3354,7 +3358,8 @@
  633. #undef DEF_POINTER_TYPE
  634. builtin_types[(int) BT_LAST] = NULL_TREE;
  635. - c_init_attributes ();
  636. + if (!c_attrs_initialized)
  637. + c_init_attributes ();
  638. #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \
  639. NONANSI_P, ATTRS, IMPLICIT, COND) \
  640. @@ -4052,11 +4057,40 @@
  641. = tree_cons (built_in_attributes[(int) PURPOSE], \
  642. built_in_attributes[(int) VALUE], \
  643. built_in_attributes[(int) CHAIN]);
  644. +#define DEF_FN_ATTR(NAME, ATTRS, PREDICATE) /* No initialization needed. */
  645. +#include "builtin-attrs.def"
  646. +#undef DEF_ATTR_NULL_TREE
  647. +#undef DEF_ATTR_INT
  648. +#undef DEF_ATTR_IDENT
  649. +#undef DEF_ATTR_TREE_LIST
  650. +#undef DEF_FN_ATTR
  651. + c_attrs_initialized = true;
  652. +}
  653. +
  654. +/* Depending on the name of DECL, apply default attributes to it. */
  655. +
  656. +void
  657. +c_common_insert_default_attributes (tree decl)
  658. +{
  659. + tree name = DECL_NAME (decl);
  660. +
  661. + if (!c_attrs_initialized)
  662. + c_init_attributes ();
  663. +
  664. +#define DEF_ATTR_NULL_TREE(ENUM) /* Nothing needed after initialization. */
  665. +#define DEF_ATTR_INT(ENUM, VALUE)
  666. +#define DEF_ATTR_IDENT(ENUM, STRING)
  667. +#define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN)
  668. +#define DEF_FN_ATTR(NAME, ATTRS, PREDICATE) \
  669. + if ((PREDICATE) && name == built_in_attributes[(int) NAME]) \
  670. + decl_attributes (&decl, built_in_attributes[(int) ATTRS], \
  671. + ATTR_FLAG_BUILT_IN);
  672. #include "builtin-attrs.def"
  673. #undef DEF_ATTR_NULL_TREE
  674. #undef DEF_ATTR_INT
  675. #undef DEF_ATTR_IDENT
  676. #undef DEF_ATTR_TREE_LIST
  677. +#undef DEF_FN_ATTR
  678. }
  679. /* Attribute handlers common to C front ends. */
  680. diff -Naur gcc-4.1.2.orig/gcc/c-common.h gcc-4.1.2-src/gcc/c-common.h
  681. --- gcc-4.1.2.orig/gcc/c-common.h 2005-12-27 18:18:05.000000000 +0100
  682. +++ gcc-4.1.2-src/gcc/c-common.h 2007-02-19 02:32:34.000000000 +0100
  683. @@ -632,6 +632,7 @@
  684. extern void set_Wformat (int);
  685. extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
  686. extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
  687. +extern void c_common_insert_default_attributes (tree);
  688. extern int c_common_handle_option (size_t code, const char *arg, int value);
  689. extern bool c_common_missing_argument (const char *opt, size_t code);
  690. extern tree c_common_type_for_mode (enum machine_mode, int);
  691. diff -Naur gcc-4.1.2.orig/gcc/c-cppbuiltin.c gcc-4.1.2-src/gcc/c-cppbuiltin.c
  692. --- gcc-4.1.2.orig/gcc/c-cppbuiltin.c 2005-08-13 22:58:02.000000000 +0200
  693. +++ gcc-4.1.2-src/gcc/c-cppbuiltin.c 2007-02-19 02:32:34.000000000 +0100
  694. @@ -51,9 +51,11 @@
  695. static void builtin_define_with_value_n (const char *, const char *,
  696. size_t);
  697. static void builtin_define_with_int_value (const char *, HOST_WIDE_INT);
  698. +#if 0
  699. static void builtin_define_with_hex_fp_value (const char *, tree,
  700. int, const char *,
  701. const char *);
  702. +#endif /* 0 */
  703. static void builtin_define_stdint_macros (void);
  704. static void builtin_define_type_max (const char *, tree, int);
  705. static void builtin_define_type_precision (const char *, tree);
  706. @@ -72,6 +74,7 @@
  707. static void
  708. builtin_define_float_constants (const char *name_prefix, const char *fp_suffix, tree type)
  709. {
  710. +#if 0 /* (TIGCC) Do nothing. We have our own float.h! */
  711. /* Used to convert radix-based values to base 10 values in several cases.
  712. In the max_exp -> max_10_exp conversion for 128-bit IEEE, we need at
  713. @@ -254,6 +257,7 @@
  714. NaN has quiet NaNs. */
  715. sprintf (name, "__%s_HAS_QUIET_NAN__", name_prefix);
  716. builtin_define_with_int_value (name, MODE_HAS_NANS (TYPE_MODE (type)));
  717. +#endif /* 0 */
  718. }
  719. /* Define __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__. */
  720. @@ -571,6 +575,7 @@
  721. cpp_define (parse_in, buf);
  722. }
  723. +#if 0
  724. /* Pass an object-like macro a hexadecimal floating-point value. */
  725. static void
  726. builtin_define_with_hex_fp_value (const char *macro,
  727. @@ -596,6 +601,7 @@
  728. sprintf (buf, "%s=%s%s", macro, dec_str, fp_suffix);
  729. cpp_define (parse_in, buf);
  730. }
  731. +#endif /* 0 */
  732. /* Define MAX for TYPE based on the precision of the type. IS_LONG is
  733. 1 for type "long" and 2 for "long long". We have to handle
  734. diff -Naur gcc-4.1.2.orig/gcc/c-decl.c gcc-4.1.2-src/gcc/c-decl.c
  735. --- gcc-4.1.2.orig/gcc/c-decl.c 2007-01-05 20:44:10.000000000 +0100
  736. +++ gcc-4.1.2-src/gcc/c-decl.c 2007-02-19 03:32:04.000000000 +0100
  737. @@ -2418,7 +2418,6 @@
  738. void
  739. undeclared_variable (tree id, location_t loc)
  740. {
  741. - static bool already = false;
  742. struct c_scope *scope;
  743. if (current_function_decl == 0)
  744. @@ -2430,13 +2429,6 @@
  745. {
  746. error ("%H%qE undeclared (first use in this function)", &loc, id);
  747. - if (!already)
  748. - {
  749. - error ("%H(Each undeclared identifier is reported only once", &loc);
  750. - error ("%Hfor each function it appears in.)", &loc);
  751. - already = true;
  752. - }
  753. -
  754. /* If we are parsing old-style parameter decls, current_function_decl
  755. will be nonnull but current_function_scope will be null. */
  756. scope = current_function_scope ? current_function_scope : current_scope;
  757. @@ -2730,7 +2722,7 @@
  758. input_location = save_loc;
  759. - pedantic_lvalues = true;
  760. + pedantic_lvalues = pedantic;
  761. make_fname_decl = c_make_fname_decl;
  762. start_fname_decls ();
  763. @@ -2825,6 +2817,17 @@
  764. return decl;
  765. }
  766. +
  767. +/* Apply default attributes to a function, if a system function with default
  768. + attributes. */
  769. +
  770. +void
  771. +c_insert_default_attributes (tree decl)
  772. +{
  773. + if (!TREE_PUBLIC (decl))
  774. + return;
  775. + c_common_insert_default_attributes (decl);
  776. +}
  777. /* Called when a declaration is seen that contains no names to declare.
  778. If its type is a reference to a structure, union or enum inherited
  779. @@ -3605,10 +3608,86 @@
  780. push_parm_decl (const struct c_parm *parm)
  781. {
  782. tree decl;
  783. +/* begin-TIGCC-local (regparms): explicit register specification for parameters */
  784. + tree asmspec;
  785. + asmspec = parm->asmspec;
  786. +/* end-TIGCC-local (regparms) */
  787. decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL);
  788. decl_attributes (&decl, parm->attrs, 0);
  789. + /* begin-TIGCC-local (regparms): explicit register specification for parameters */
  790. + if (asmspec)
  791. +#ifdef EXPLICIT_REGPARM
  792. + {
  793. + const char *regname=TREE_STRING_POINTER(asmspec);
  794. + int regnum;
  795. + if ((regnum=decode_reg_name(regname))>=0)
  796. + {
  797. + tree type=TREE_TYPE(decl);
  798. + if (HARD_REGNO_MODE_OK(regnum, TYPE_MODE(type)))
  799. + {
  800. + tree t, attrs;
  801. +/* push_obstacks_nochange();
  802. + end_temporary_allocation(); */
  803. + /* Build tree for __attribute__ ((asm(regnum))). */
  804. +#if 0
  805. + /* This doesn't work well because of a bug in
  806. + attribute_list_contained(), which passes list of arguments to
  807. + simple_cst_equal() instead of passing every argument
  808. + separately. */
  809. + attrs=tree_cons(get_identifier("asm"), tree_cons(NULL_TREE,
  810. + build_int_cstu(NULL_TREE, regnum), NULL_TREE), NULL_TREE);
  811. +#else
  812. + attrs=tree_cons(get_identifier("asm"),
  813. + build_int_cstu(NULL_TREE, regnum), NULL_TREE);
  814. +#endif
  815. +#if 0
  816. + /* build_type_attribute_variant() would seem to be more
  817. + appropriate here. However, that function does not support
  818. + attributes for parameters properly. It modifies
  819. + TYPE_MAIN_VARIANT of a new type. As a result, comptypes()
  820. + thinks that types of parameters in prototype and definition
  821. + are different and issues error messages. See also comment
  822. + below. */
  823. + type=build_type_attribute_variant(type, attrs);
  824. +#else
  825. + /* First check whether such a type already exists - if yes, use
  826. + that one. This is very important, since otherwise
  827. + common_type() would think that it sees two different
  828. + types and would try to merge them - this could result in
  829. + warning messages. */
  830. + for (t=TYPE_MAIN_VARIANT(type); t; t=TYPE_NEXT_VARIANT(t))
  831. + if (comptypes(t, type)==1
  832. + && attribute_list_equal(TYPE_ATTRIBUTES(t), attrs))
  833. + break;
  834. + if (t)
  835. + type=t;
  836. + else
  837. + {
  838. + /* Create a new variant, with differing attributes.
  839. + (Hack! Type with differing attributes should no longer be
  840. + a variant of its main type. See comment above for
  841. + explanation why this was necessary). */
  842. + type=build_variant_type_copy(type);
  843. + TYPE_ATTRIBUTES(type)=attrs;
  844. + }
  845. +#endif
  846. + TREE_TYPE(decl)=type;
  847. +/* pop_obstacks(); */
  848. + }
  849. + else
  850. + error("%Jregister number for `%s' isn't suitable for the data type",
  851. + decl, regname);
  852. + }
  853. + else
  854. + error("invalid register name `%s'", regname);
  855. + }
  856. +#else /* !EXPLICIT_REGPARM */
  857. + error("explicit register specification for parameters is not supported for this target");
  858. +#endif
  859. + /* end-TIGCC-local (regparms) */
  860. +
  861. decl = pushdecl (decl);
  862. finish_decl (decl, NULL_TREE, NULL_TREE);
  863. @@ -3658,7 +3737,11 @@
  864. DECL_CONTEXT (decl) = current_function_decl;
  865. TREE_USED (decl) = 1;
  866. TREE_TYPE (decl) = type;
  867. - TREE_READONLY (decl) = TYPE_READONLY (type);
  868. + /* (TIGCC 20050206) If -fglobal-compound-literals (on by default) is given,
  869. + for constant constructors, the compound literal is written out as if it was
  870. + const, which gets GCC to output it as a global, avoiding the copy. */
  871. + TREE_READONLY (decl) = TYPE_READONLY (type)
  872. + || (flag_global_compound_literals && TREE_CONSTANT (init));
  873. store_init_value (decl, init);
  874. if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
  875. @@ -6900,12 +6983,13 @@
  876. struct c_parm *
  877. build_c_parm (struct c_declspecs *specs, tree attrs,
  878. - struct c_declarator *declarator)
  879. + struct c_declarator *declarator, tree asmspec)
  880. {
  881. struct c_parm *ret = XOBNEW (&parser_obstack, struct c_parm);
  882. ret->specs = specs;
  883. ret->attrs = attrs;
  884. ret->declarator = declarator;
  885. + ret->asmspec = asmspec; /* (TIGCC 20050203) */
  886. return ret;
  887. }
  888. diff -Naur gcc-4.1.2.orig/gcc/cfgexpand.c gcc-4.1.2-src/gcc/cfgexpand.c
  889. --- gcc-4.1.2.orig/gcc/cfgexpand.c 2006-09-01 09:48:22.000000000 +0200
  890. +++ gcc-4.1.2-src/gcc/cfgexpand.c 2007-02-19 02:32:34.000000000 +0100
  891. @@ -1363,6 +1363,23 @@
  892. }
  893. else
  894. {
  895. + /* (TIGCC 20050206) If -fno-function-cse, restore function call
  896. + sequences to their expected form. */
  897. + if (flag_no_function_cse && TREE_CODE (stmt) == MODIFY_EXPR)
  898. + {
  899. + block_stmt_iterator bsi2 = bsi;
  900. + bsi_next (&bsi2);
  901. + if (!bsi_end_p (bsi2))
  902. + {
  903. + tree call = get_call_expr_in (bsi_stmt (bsi2));
  904. + if (call && TREE_OPERAND (stmt, 0) == TREE_OPERAND (call, 0)
  905. + && !TREE_SIDE_EFFECTS (TREE_OPERAND (stmt, 0))
  906. + && !TREE_SIDE_EFFECTS (TREE_OPERAND (stmt, 1)))
  907. + {
  908. + TREE_OPERAND (call, 0) = TREE_OPERAND (stmt, 1);
  909. + }
  910. + }
  911. + }
  912. last = get_last_insn ();
  913. expand_expr_stmt (stmt);
  914. maybe_dump_rtl_for_tree_stmt (stmt, last);
  915. diff -Naur gcc-4.1.2.orig/gcc/c-format.c gcc-4.1.2-src/gcc/c-format.c
  916. --- gcc-4.1.2.orig/gcc/c-format.c 2005-10-26 04:15:02.000000000 +0200
  917. +++ gcc-4.1.2-src/gcc/c-format.c 2007-02-19 02:32:34.000000000 +0100
  918. @@ -281,16 +281,12 @@
  919. } format_wanted_type;
  920. +/* (TIGCC 20040219) AMS doesn't support any C99 or extended modifiers.
  921. + -- Kevin Kofler */
  922. static const format_length_info printf_length_specs[] =
  923. {
  924. - { "h", FMT_LEN_h, STD_C89, "hh", FMT_LEN_hh, STD_C99 },
  925. - { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C9L },
  926. - { "q", FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
  927. - { "L", FMT_LEN_L, STD_C89, NULL, 0, 0 },
  928. - { "z", FMT_LEN_z, STD_C99, NULL, 0, 0 },
  929. - { "Z", FMT_LEN_z, STD_EXT, NULL, 0, 0 },
  930. - { "t", FMT_LEN_t, STD_C99, NULL, 0, 0 },
  931. - { "j", FMT_LEN_j, STD_C99, NULL, 0, 0 },
  932. + { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
  933. + { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
  934. { NULL, 0, 0, NULL, 0, 0 }
  935. };
  936. @@ -315,16 +311,12 @@
  937. #define gcc_cdiag_length_specs gcc_diag_length_specs
  938. #define gcc_cxxdiag_length_specs gcc_diag_length_specs
  939. -/* This differs from printf_length_specs only in that "Z" is not accepted. */
  940. +/* (TIGCC 20040219) My *scanf doesn't support any C99 or extended modifiers.
  941. + -- Kevin Kofler */
  942. static const format_length_info scanf_length_specs[] =
  943. {
  944. - { "h", FMT_LEN_h, STD_C89, "hh", FMT_LEN_hh, STD_C99 },
  945. - { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C9L },
  946. - { "q", FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
  947. - { "L", FMT_LEN_L, STD_C89, NULL, 0, 0 },
  948. - { "z", FMT_LEN_z, STD_C99, NULL, 0, 0 },
  949. - { "t", FMT_LEN_t, STD_C99, NULL, 0, 0 },
  950. - { "j", FMT_LEN_j, STD_C99, NULL, 0, 0 },
  951. + { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
  952. + { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
  953. { NULL, 0, 0, NULL, 0, 0 }
  954. };
  955. @@ -338,6 +330,9 @@
  956. { NULL, 0, 0, NULL, 0, 0 }
  957. };
  958. +/* (TIGCC 20040219) AMS doesn't support any of the GNU extended modifiers.
  959. + However, it supports some of its own.
  960. + -- Kevin Kofler */
  961. static const format_flag_spec printf_flag_specs[] =
  962. {
  963. { ' ', 0, 0, N_("' ' flag"), N_("the ' ' printf flag"), STD_C89 },
  964. @@ -345,8 +340,9 @@
  965. { '#', 0, 0, N_("'#' flag"), N_("the '#' printf flag"), STD_C89 },
  966. { '0', 0, 0, N_("'0' flag"), N_("the '0' printf flag"), STD_C89 },
  967. { '-', 0, 0, N_("'-' flag"), N_("the '-' printf flag"), STD_C89 },
  968. - { '\'', 0, 0, N_("''' flag"), N_("the ''' printf flag"), STD_EXT },
  969. - { 'I', 0, 0, N_("'I' flag"), N_("the 'I' printf flag"), STD_EXT },
  970. + { 'z', 0, 0, N_("'z' flag"), N_("the 'z' printf flag"), STD_EXT },
  971. + { '^', 0, 0, N_("'^' flag"), N_("the '^' printf flag"), STD_EXT },
  972. + { '|', 0, 0, N_("'|' flag"), N_("the '|' printf flag"), STD_EXT },
  973. { 'w', 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 },
  974. { 'p', 0, 0, N_("precision"), N_("precision in printf format"), STD_C89 },
  975. { 'L', 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 },
  976. @@ -419,14 +415,13 @@
  977. { 0, 0, 0, NULL, NULL, 0 }
  978. };
  979. +/* (TIGCC 20040219) My *scanf doesn't support any extended modifiers.
  980. + -- Kevin Kofler */
  981. static const format_flag_spec scanf_flag_specs[] =
  982. {
  983. { '*', 0, 0, N_("assignment suppression"), N_("the assignment suppression scanf feature"), STD_C89 },
  984. - { 'a', 0, 0, N_("'a' flag"), N_("the 'a' scanf flag"), STD_EXT },
  985. { 'w', 0, 0, N_("field width"), N_("field width in scanf format"), STD_C89 },
  986. { 'L', 0, 0, N_("length modifier"), N_("length modifier in scanf format"), STD_C89 },
  987. - { '\'', 0, 0, N_("''' flag"), N_("the ''' scanf flag"), STD_EXT },
  988. - { 'I', 0, 0, N_("'I' flag"), N_("the 'I' scanf flag"), STD_EXT },
  989. { 0, 0, 0, NULL, NULL, 0 }
  990. };
  991. @@ -486,26 +481,22 @@
  992. };
  993. +/* (TIGCC 20040219) AMS doesn't support any of the C99 or GNU extended
  994. + modifiers. However, it supports some of its own.
  995. + -- Kevin Kofler */
  996. static const format_char_info print_char_table[] =
  997. {
  998. /* C89 conversion specifiers. */
  999. - { "di", 0, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "-wp0 +'I", "i", NULL },
  1000. - { "oxX", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0#", "i", NULL },
  1001. - { "u", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0'I", "i", NULL },
  1002. - { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'I", "", NULL },
  1003. - { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#I", "", NULL },
  1004. - { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL },
  1005. - { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL },
  1006. - { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c", NULL },
  1007. - { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W", NULL },
  1008. - /* C99 conversion specifiers. */
  1009. - { "F", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'I", "", NULL },
  1010. - { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL },
  1011. - /* X/Open conversion specifiers. */
  1012. - { "C", 0, STD_EXT, { TEX_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL },
  1013. - { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL },
  1014. - /* GNU conversion specifiers. */
  1015. - { "m", 0, STD_EXT, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "", NULL },
  1016. + { "di", 0, STD_C89, { T89_S, BADLEN, T89_S, T89_L, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +|z", "i", NULL },
  1017. + { "xX", 0, STD_C89, { T89_US, BADLEN, T89_US, T89_UL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0#|z", "i", NULL },
  1018. + { "u", 0, STD_C89, { T89_US, BADLEN, T89_US, T89_UL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0|z", "i", NULL },
  1019. + { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#^|z", "", NULL },
  1020. + { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#^|z", "", NULL },
  1021. + { "rR", 0, STD_EXT, { T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#^|z", "", NULL },
  1022. + { "yY", 0, STD_EXT, { T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#^|z", "", NULL },
  1023. + { "c", 0, STD_C89, { T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w|z", "", NULL },
  1024. + { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp|z", "cR", NULL },
  1025. + { "p", 1, STD_C89, { BADLEN, BADLEN, BADLEN, T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w|z", "c", NULL },
  1026. { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL }
  1027. };
  1028. @@ -641,23 +632,18 @@
  1029. { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL }
  1030. };
  1031. +/* (TIGCC 20040219) My *scanf doesn't support any extended modifiers. -- Kevin Kofler */
  1032. static const format_char_info scan_char_table[] =
  1033. {
  1034. /* C89 conversion specifiers. */
  1035. - { "di", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "*w'I", "W", NULL },
  1036. - { "u", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w'I", "W", NULL },
  1037. - { "oxX", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w", "W", NULL },
  1038. - { "efgEG", 1, STD_C89, { T89_F, BADLEN, BADLEN, T89_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL },
  1039. + { "di", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "*w", "W", NULL },
  1040. + { "u", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w", "W", NULL },
  1041. + { "oxX", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w", "W", NULL },
  1042. + { "efgEG", 1, STD_C89, { T89_F, BADLEN, BADLEN, T89_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL },
  1043. { "c", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "cW", NULL },
  1044. { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW", NULL },
  1045. { "[", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW[", NULL },
  1046. { "p", 2, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL },
  1047. - { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W", NULL },
  1048. - /* C99 conversion specifiers. */
  1049. - { "FaA", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL },
  1050. - /* X/Open conversion specifiers. */
  1051. - { "C", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL },
  1052. - { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "W", NULL },
  1053. { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL }
  1054. };
  1055. @@ -695,9 +681,10 @@
  1056. };
  1057. /* This must be in the same order as enum format_type. */
  1058. +/* (TIGCC 20040219) Changed the flag chars. See the *f_flag_specs comments. */
  1059. static const format_kind_info format_types_orig[] =
  1060. {
  1061. - { "printf", printf_length_specs, print_char_table, " +#0-'I", NULL,
  1062. + { "printf", printf_length_specs, print_char_table, " +#0-z^|", NULL,
  1063. printf_flag_specs, printf_flag_pairs,
  1064. FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK,
  1065. 'w', 0, 'p', 0, 'L',
  1066. @@ -739,7 +726,7 @@
  1067. 0, 0, 0, 0, 0,
  1068. NULL, NULL
  1069. },
  1070. - { "scanf", scanf_length_specs, scan_char_table, "*'I", NULL,
  1071. + { "scanf", scanf_length_specs, scan_char_table, "*", NULL,
  1072. scanf_flag_specs, scanf_flag_pairs,
  1073. FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK,
  1074. 'w', 0, 0, '*', 'L',
  1075. @@ -2215,6 +2202,17 @@
  1076. || cur_type == signed_char_type_node
  1077. || cur_type == unsigned_char_type_node);
  1078. + /* (TIGCC) Account for *printf and *scanf not actually supporting -mlong. */
  1079. + if (!TARGET_SHORT) {
  1080. + if (cur_type == short_integer_type_node
  1081. + || cur_type == integer_type_node)
  1082. + orig_cur_type = cur_type = long_integer_type_node;
  1083. +
  1084. + if (cur_type == short_unsigned_type_node
  1085. + || cur_type == unsigned_type_node)
  1086. + orig_cur_type = cur_type = long_unsigned_type_node;
  1087. + }
  1088. +
  1089. /* Check the type of the "real" argument, if there's a type we want. */
  1090. if (lang_hooks.types_compatible_p (wanted_type, cur_type))
  1091. continue;
  1092. @@ -2229,12 +2227,18 @@
  1093. -pedantic. With -pedantic, warn if the type is a pointer
  1094. target and not a character type, and for character types at
  1095. a second level of indirection. */
  1096. - if (TREE_CODE (wanted_type) == INTEGER_TYPE
  1097. + /* TIGCC Patch: Don't warn about differences in floating point
  1098. + format; they're all the same.
  1099. + (TIGCC 20040728) But do warn if someone passes an integer where a float
  1100. + is expected! -- Kevin Kofler */
  1101. + if ((TREE_CODE (wanted_type) == REAL_TYPE
  1102. + && TREE_CODE (cur_type) == REAL_TYPE)
  1103. + || (TREE_CODE (wanted_type) == INTEGER_TYPE
  1104. && TREE_CODE (cur_type) == INTEGER_TYPE
  1105. && (!pedantic || i == 0 || (i == 1 && char_type_flag))
  1106. && (TYPE_UNSIGNED (wanted_type)
  1107. ? wanted_type == c_common_unsigned_type (cur_type)
  1108. - : wanted_type == c_common_signed_type (cur_type)))
  1109. + : wanted_type == c_common_signed_type (cur_type))))
  1110. continue;
  1111. /* Likewise, "signed char", "unsigned char" and "char" are
  1112. equivalent but the above test won't consider them equivalent. */
  1113. diff -Naur gcc-4.1.2.orig/gcc/c-incpath.c gcc-4.1.2-src/gcc/c-incpath.c
  1114. --- gcc-4.1.2.orig/gcc/c-incpath.c 2005-06-25 04:02:01.000000000 +0200
  1115. +++ gcc-4.1.2-src/gcc/c-incpath.c 2007-02-19 02:32:34.000000000 +0100
  1116. @@ -335,9 +335,13 @@
  1117. function does not recognize a directory that ends in a backslash
  1118. (unless it is a drive root dir, such "c:\"). Forward slashes,
  1119. trailing or otherwise, cause no problems for stat(). */
  1120. + /* (TIGCC 20050206) This is entirely backwards! We need backslashes.
  1121. + Forward-slashes are no good. But we need to get rid of
  1122. + trailing backslashes. -- Kevin Kofler */
  1123. char* c;
  1124. for (c = path; *c; c++)
  1125. - if (*c == '\\') *c = '/';
  1126. + if (*c == '/') *c = '\\';
  1127. + if (c[strlen(c)-1] == '\\') c[strlen(c)-1] = '\0';
  1128. #endif
  1129. p = xmalloc (sizeof (cpp_dir));
  1130. @@ -360,6 +364,7 @@
  1131. const char *iprefix, int stdinc, int cxx_stdinc,
  1132. int verbose)
  1133. {
  1134. +#if 0 /* (TIGCC 20050205) Don't use environment variables. */
  1135. static const char *const lang_env_vars[] =
  1136. { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH",
  1137. "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" };
  1138. @@ -375,11 +380,14 @@
  1139. include chain. */
  1140. add_env_var_paths ("CPATH", BRACKET);
  1141. add_env_var_paths (lang_env_vars[idx], SYSTEM);
  1142. +#endif /* 0 */
  1143. target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
  1144. /* Finally chain on the standard directories. */
  1145. - if (stdinc)
  1146. + /* (TIGCC 20031007) We don't want any "standard" include directories.
  1147. + -- Kevin Kofler */
  1148. + if (0 /*stdinc*/)
  1149. add_standard_paths (sysroot, iprefix, cxx_stdinc);
  1150. target_c_incpath.extra_includes (sysroot, iprefix, stdinc);
  1151. diff -Naur gcc-4.1.2.orig/gcc/c-lang.c gcc-4.1.2-src/gcc/c-lang.c
  1152. --- gcc-4.1.2.orig/gcc/c-lang.c 2005-07-01 01:09:06.000000000 +0200
  1153. +++ gcc-4.1.2-src/gcc/c-lang.c 2007-02-19 02:32:34.000000000 +0100
  1154. @@ -44,6 +44,8 @@
  1155. #define LANG_HOOKS_NAME "GNU C"
  1156. #undef LANG_HOOKS_INIT
  1157. #define LANG_HOOKS_INIT c_objc_common_init
  1158. +#undef LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES
  1159. +#define LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES c_insert_default_attributes
  1160. /* Each front end provides its own lang hook initializer. */
  1161. const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
  1162. diff -Naur gcc-4.1.2.orig/gcc/c-lex.c gcc-4.1.2-src/gcc/c-lex.c
  1163. --- gcc-4.1.2.orig/gcc/c-lex.c 2006-07-01 18:32:00.000000000 +0200
  1164. +++ gcc-4.1.2-src/gcc/c-lex.c 2007-02-19 02:32:34.000000000 +0100
  1165. @@ -434,7 +434,7 @@
  1166. cppchar_t c = tok->val.str.text[0];
  1167. if (c == '"' || c == '\'')
  1168. - error ("missing terminating %c character", (int) c);
  1169. + cpp_unterminated (parse_in, c);
  1170. else if (ISGRAPH (c))
  1171. error ("stray %qc in program", (int) c);
  1172. else
  1173. diff -Naur gcc-4.1.2.orig/gcc/combine.c gcc-4.1.2-src/gcc/combine.c
  1174. --- gcc-4.1.2.orig/gcc/combine.c 2007-01-21 23:34:57.000000000 +0100
  1175. +++ gcc-4.1.2-src/gcc/combine.c 2007-02-19 02:32:34.000000000 +0100
  1176. @@ -4423,8 +4423,10 @@
  1177. /* x - 0 is the same as x unless x's mode has signed zeros and
  1178. allows rounding towards -infinity. Under those conditions,
  1179. 0 - 0 is -0. */
  1180. + /* (TIGCC 20050210) This is invalid independently of the rounding mode
  1181. + for 3-sign-zeros. */
  1182. if (!(HONOR_SIGNED_ZEROS (GET_MODE (XEXP (x, 0)))
  1183. - && HONOR_SIGN_DEPENDENT_ROUNDING (GET_MODE (XEXP (x, 0))))
  1184. + /*&& HONOR_SIGN_DEPENDENT_ROUNDING (GET_MODE (XEXP (x, 0)))*/)
  1185. && XEXP (x, 1) == CONST0_RTX (GET_MODE (XEXP (x, 0))))
  1186. return XEXP (x, 0);
  1187. break;
  1188. diff -Naur gcc-4.1.2.orig/gcc/common.opt gcc-4.1.2-src/gcc/common.opt
  1189. --- gcc-4.1.2.orig/gcc/common.opt 2006-05-17 20:38:58.000000000 +0200
  1190. +++ gcc-4.1.2-src/gcc/common.opt 2007-02-19 02:32:34.000000000 +0100
  1191. @@ -447,6 +447,14 @@
  1192. Perform global common subexpression elimination after register allocation
  1193. has finished
  1194. +fglobal-cast-constructors
  1195. +Common Report Var(flag_global_compound_literals) Init(1)
  1196. +Make compound literals (cast constructors) global for backwards compatibility
  1197. +
  1198. +fglobal-compound-literals
  1199. +Common Report Var(flag_global_compound_literals) VarExists
  1200. +Make compound literals (cast constructors) global for backwards compatibility
  1201. +
  1202. fguess-branch-probability
  1203. Common Report Var(flag_guess_branch_prob)
  1204. Enable guessing of branch probabilities
  1205. @@ -562,6 +570,10 @@
  1206. Common Report Var(flag_merge_constants,2) Init(1)
  1207. Attempt to merge identical constants and constant variables
  1208. +fmerge-constant-pools
  1209. +Common Report Var(flag_merge_constant_pools) Init(1)
  1210. +When merging constants, also merge constant pools
  1211. +
  1212. fmerge-constants
  1213. Common Report Var(flag_merge_constants,1) VarExists
  1214. Attempt to merge identical constants across compilation units
  1215. @@ -590,6 +602,10 @@
  1216. Common RejectNegative Report Var(flag_mudflap_ignore_reads)
  1217. Ignore read operations when inserting mudflap instrumentation
  1218. +freg-relative-
  1219. +Common Joined RejectNegative
  1220. +-freg-relative-<register> Emit code relative to the base register <register>
  1221. +
  1222. freschedule-modulo-scheduled-loops
  1223. Common Report Var(flag_resched_modulo_sched)
  1224. Enable/Disable the traditional scheduling in loops that already passed modulo scheduling
  1225. @@ -1042,7 +1058,7 @@
  1226. Assume signed arithmetic overflow wraps around
  1227. fzero-initialized-in-bss
  1228. -Common Report Var(flag_zero_initialized_in_bss) Init(1)
  1229. +Common Report Var(flag_zero_initialized_in_bss) Init(0)
  1230. Put zero initialized data in the bss section
  1231. g
  1232. diff -Naur gcc-4.1.2.orig/gcc/config/dbxcoff.h gcc-4.1.2-src/gcc/config/dbxcoff.h
  1233. --- gcc-4.1.2.orig/gcc/config/dbxcoff.h 2005-06-25 03:22:41.000000000 +0200
  1234. +++ gcc-4.1.2-src/gcc/config/dbxcoff.h 2007-02-19 02:32:34.000000000 +0100
  1235. @@ -48,8 +48,13 @@
  1236. /* Like block addresses, stabs line numbers are relative to the
  1237. current function. */
  1238. +/* TIGCC Patch: We don't want COFF line numbers to be function-relative.
  1239. + That's why we write '.ln LINE'. This will break support for existing
  1240. + debuggers, but there are none for TIGCC. The line numbers can be
  1241. + extracted from the .s file, plus they are passed on to the object file
  1242. + symbol table. */
  1243. -#define DBX_LINES_FUNCTION_RELATIVE 1
  1244. +#define DBX_LINES_FUNCTION_RELATIVE (!TARGET_COFFABSLINES)
  1245. /* When generating stabs debugging, use N_BINCL entries. */
  1246. diff -Naur gcc-4.1.2.orig/gcc/config/i386/xm-mingw32.h gcc-4.1.2-src/gcc/config/i386/xm-mingw32.h
  1247. --- gcc-4.1.2.orig/gcc/config/i386/xm-mingw32.h 2005-06-25 03:22:41.000000000 +0200
  1248. +++ gcc-4.1.2-src/gcc/config/i386/xm-mingw32.h 2007-02-19 02:32:34.000000000 +0100
  1249. @@ -20,6 +20,10 @@
  1250. Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
  1251. 02110-1301, USA. */
  1252. +/* Mingw32 does not try to hide the underlying DOS-based file system
  1253. + like Cygwin does. */
  1254. +#define HAVE_DOS_BASED_FILE_SYSTEM
  1255. +
  1256. #define HOST_EXECUTABLE_SUFFIX ".exe"
  1257. #undef PATH_SEPARATOR
  1258. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k.c gcc-4.1.2-src/gcc/config/m68k/m68k.c
  1259. --- gcc-4.1.2.orig/gcc/config/m68k/m68k.c 2005-12-29 16:10:35.000000000 +0100
  1260. +++ gcc-4.1.2-src/gcc/config/m68k/m68k.c 2007-02-19 02:32:34.000000000 +0100
  1261. @@ -43,6 +43,11 @@
  1262. #include "target-def.h"
  1263. #include "debug.h"
  1264. #include "flags.h"
  1265. +#include "c-pragma.h"
  1266. +#include "cgraph.h"
  1267. +
  1268. +/* TIGCC register for reg-relative code. */
  1269. +char TARGET_RELATION_REG[10] = "a4";
  1270. enum reg_class regno_reg_class[] =
  1271. {
  1272. @@ -122,10 +127,20 @@
  1273. static bool m68k_save_reg (unsigned int regno, bool interrupt_handler);
  1274. static int const_int_cost (rtx);
  1275. static bool m68k_rtx_costs (rtx, int, int, int *);
  1276. +static bool m68k_cannot_force_const_mem (rtx); /* (TIGCC 20050424) */
  1277. +
  1278. +static int comp_m68k_type_attributes (tree, tree);
  1279. +static int comp_amigaos_type_attributes (tree, tree);
  1280. +static tree m68k_handle_stkparm_attribute (tree *, tree, tree, int, bool *);
  1281. +static tree m68k_handle_regparm_attribute (tree *, tree, tree, int, bool *);
  1282. /* Specify the identification number of the library being built */
  1283. const char *m68k_library_id_string = "_current_shared_library_a5_offset_";
  1284. +/* Specify number of registers for integer, pointer and float arguments. */
  1285. +const char *m68k_regparm_string;
  1286. +/* Specify number of registers for integer, pointer and float arguments. */
  1287. +int m68k_regparm;
  1288. /* Nonzero if the last compare/test insn had FP operands. The
  1289. sCC expanders peek at this to determine what to do for the
  1290. @@ -133,6 +148,8 @@
  1291. int m68k_last_compare_had_fp_operands;
  1292. /* Initialize the GCC target structure. */
  1293. +#undef TARGET_COMP_TYPE_ATTRIBUTES
  1294. +#define TARGET_COMP_TYPE_ATTRIBUTES comp_amigaos_type_attributes
  1295. #if INT_OP_GROUP == INT_OP_DOT_WORD
  1296. #undef TARGET_ASM_ALIGNED_HI_OP
  1297. @@ -186,15 +203,35 @@
  1298. #undef TARGET_ATTRIBUTE_TABLE
  1299. #define TARGET_ATTRIBUTE_TABLE m68k_attribute_table
  1300. +/* Pass the right values to functions whose prototypes contain "char"
  1301. + or "short". */
  1302. +#if 0
  1303. #undef TARGET_PROMOTE_PROTOTYPES
  1304. #define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
  1305. +#endif /* 0 */
  1306. #undef TARGET_STRUCT_VALUE_RTX
  1307. #define TARGET_STRUCT_VALUE_RTX m68k_struct_value_rtx
  1308. +#undef TARGET_ASM_FILE_START
  1309. +#define TARGET_ASM_FILE_START m68k_asm_file_start
  1310. +
  1311. +/* (TIGCC 20050424) Everything which is not a CONST_DOUBLE has no business of
  1312. + being in the constant pool. This is especially valid for
  1313. + expressions containing relocations. -- Kevin Kofler */
  1314. +#undef TARGET_CANNOT_FORCE_CONST_MEM
  1315. +#define TARGET_CANNOT_FORCE_CONST_MEM m68k_cannot_force_const_mem
  1316. +
  1317. static const struct attribute_spec m68k_attribute_table[] =
  1318. {
  1319. /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
  1320. + /* The stkparm attribute means a function takes its parameters on the stack
  1321. + (AMS calling convention). */
  1322. + { "stkparm", 0, 0, false, true, true, m68k_handle_stkparm_attribute },
  1323. + /* The regparm attribute means a function takes its parameters in registers.
  1324. + Its optional argument specifies the maximum number of arguments to be
  1325. + passed in each category of registers (data registers, address registers). */
  1326. + { "regparm", 0, 1, false, true, true, m68k_handle_regparm_attribute },
  1327. { "interrupt_handler", 0, 0, true, false, false, m68k_handle_fndecl_attribute },
  1328. { NULL, 0, 0, false, false, false, NULL }
  1329. };
  1330. @@ -314,6 +351,19 @@
  1331. void
  1332. override_options (void)
  1333. {
  1334. + /* Validate -mregparm and -mregparm= value. */
  1335. + if (m68k_regparm_string)
  1336. + {
  1337. + m68k_regparm = atoi (m68k_regparm_string);
  1338. + if (m68k_regparm < 1 || m68k_regparm > M68K_MAX_REGPARM)
  1339. + error ("-mregparm=%d is not between 1 and %d",
  1340. + m68k_regparm, M68K_MAX_REGPARM);
  1341. + target_flags |= MASK_REGPARM;
  1342. + }
  1343. + else
  1344. + if (TARGET_REGPARM)
  1345. + m68k_regparm = M68K_DEFAULT_REGPARM;
  1346. +
  1347. /* Sanity check to ensure that msep-data and mid-sahred-library are not
  1348. * both specified together. Doing so simply doesn't make sense.
  1349. */
  1350. @@ -349,6 +399,116 @@
  1351. SUBTARGET_OVERRIDE_OPTIONS;
  1352. }
  1353. +/* Handle a "stkparm" attribute;
  1354. + arguments as in struct attribute_spec.handler. */
  1355. +static tree
  1356. +m68k_handle_stkparm_attribute (tree *node, tree name, tree args ATTRIBUTE_UNUSED,
  1357. + int flags ATTRIBUTE_UNUSED, bool *no_add_attrs)
  1358. +{
  1359. + if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
  1360. + {
  1361. + error ("`regparm' and `stkparm' are mutually exclusive");
  1362. + *no_add_attrs = true;
  1363. + }
  1364. +
  1365. + if (TREE_CODE (*node) != FUNCTION_TYPE
  1366. + && TREE_CODE (*node) != METHOD_TYPE
  1367. + && TREE_CODE (*node) != FIELD_DECL
  1368. + && TREE_CODE (*node) != TYPE_DECL)
  1369. + {
  1370. + warning (0, "`%s' attribute only applies to functions",
  1371. + IDENTIFIER_POINTER (name));
  1372. + *no_add_attrs = true;
  1373. + }
  1374. +
  1375. + return NULL_TREE;
  1376. +}
  1377. +
  1378. +/* Handle a "regparm" attribute;
  1379. + arguments as in struct attribute_spec.handler. */
  1380. +static tree
  1381. +m68k_handle_regparm_attribute (tree *node, tree name, tree args,
  1382. + int flags ATTRIBUTE_UNUSED, bool *no_add_attrs)
  1383. +{
  1384. + if (lookup_attribute ("stkparm", TYPE_ATTRIBUTES (*node)))
  1385. + {
  1386. + error ("`regparm' and `stkparm' are mutually exclusive");
  1387. + *no_add_attrs = true;
  1388. + }
  1389. +
  1390. + if (TREE_CODE (*node) != FUNCTION_TYPE
  1391. + && TREE_CODE (*node) != METHOD_TYPE
  1392. + && TREE_CODE (*node) != FIELD_DECL
  1393. + && TREE_CODE (*node) != TYPE_DECL)
  1394. + {
  1395. + warning (0, "`%s' attribute only applies to functions",
  1396. + IDENTIFIER_POINTER (name));
  1397. + *no_add_attrs = true;
  1398. + }
  1399. + else
  1400. + {
  1401. + /* 'regparm' accepts one optional argument - number of registers per
  1402. + single class (data, address) that should be used to pass arguments. */
  1403. + if (args && TREE_CODE (args) == TREE_LIST)
  1404. + {
  1405. + tree numofregs = TREE_VALUE (args);
  1406. + if (numofregs)
  1407. + if (TREE_CODE (numofregs) != INTEGER_CST
  1408. + || TREE_INT_CST_HIGH (numofregs)
  1409. + || TREE_INT_CST_LOW (numofregs) < 1
  1410. + || TREE_INT_CST_LOW (numofregs) > M68K_MAX_REGPARM)
  1411. + {
  1412. + error ("invalid argument to `regparm' attribute");
  1413. + *no_add_attrs = true;
  1414. + }
  1415. + }
  1416. + }
  1417. +
  1418. + return NULL_TREE;
  1419. +}
  1420. +
  1421. +/* Return zero if the attributes on TYPE1 and TYPE2 are incompatible,
  1422. + one if they are compatible, and two if they are nearly compatible
  1423. + (which causes a warning to be generated). */
  1424. +
  1425. +int
  1426. +comp_m68k_type_attributes (tree type1, tree type2)
  1427. +{
  1428. + /* Functions or methods are incompatible if they specify mutually
  1429. + exclusive ways of passing arguments. */
  1430. + if (TREE_CODE (type1) == FUNCTION_TYPE || TREE_CODE (type1) == METHOD_TYPE)
  1431. + {
  1432. + tree arg1, arg2;
  1433. + if (!! lookup_attribute ("stkparm", TYPE_ATTRIBUTES (type1)) !=
  1434. + !! lookup_attribute ("stkparm", TYPE_ATTRIBUTES (type2))
  1435. + || !! lookup_attribute ("regparm", TYPE_ATTRIBUTES (type1)) !=
  1436. + !! lookup_attribute ("regparm", TYPE_ATTRIBUTES (type2)))
  1437. + return 0; /* 'regparm' and 'stkparm' are mutually exclusive. */
  1438. +
  1439. + arg1 = lookup_attribute ("regparm", TYPE_ATTRIBUTES (type1));
  1440. + arg2 = lookup_attribute ("regparm", TYPE_ATTRIBUTES (type2));
  1441. + if (arg1 && arg2)
  1442. + {
  1443. + int num1 = 0, num2 = 0;
  1444. + if (TREE_VALUE (arg1) && TREE_CODE (TREE_VALUE (arg1)) == TREE_LIST)
  1445. + {
  1446. + tree numofregs = TREE_VALUE (TREE_VALUE (arg1));
  1447. + if (numofregs)
  1448. + num1 = TREE_INT_CST_LOW (numofregs);
  1449. + }
  1450. + if (TREE_VALUE (arg2) && TREE_CODE (TREE_VALUE (arg2)) == TREE_LIST)
  1451. + {
  1452. + tree numofregs = TREE_VALUE (TREE_VALUE (arg2));
  1453. + if (numofregs)
  1454. + num2 = TREE_INT_CST_LOW (numofregs);
  1455. + }
  1456. + if (num1 != num2)
  1457. + return 0; /* Different numbers, or no number in one type. */
  1458. + }
  1459. + }
  1460. + return 1;
  1461. +}
  1462. +
  1463. /* Return nonzero if FUNC is an interrupt function as specified by the
  1464. "interrupt_handler" attribute. */
  1465. static bool
  1466. @@ -464,6 +624,11 @@
  1467. static bool
  1468. m68k_save_reg (unsigned int regno, bool interrupt_handler)
  1469. {
  1470. + /* (TIGCC 20050208) Handle OPTIMIZE_ROM_CALLS. Register #13 is %a5. */
  1471. + if (interrupt_handler && regno == 13 && global_regs[13]
  1472. + && cpp_defined (parse_in, (unsigned char *)"OPTIMIZE_ROM_CALLS", 18))
  1473. + return true;
  1474. +
  1475. if (flag_pic && regno == PIC_OFFSET_TABLE_REGNUM)
  1476. {
  1477. if (current_function_uses_pic_offset_table)
  1478. @@ -603,7 +768,8 @@
  1479. if (dwarf2out_do_frame ())
  1480. {
  1481. - cfa_offset += current_frame.size + 4;
  1482. + /* (TIGCC 20050407) This +4 seems wrong from my tests. */
  1483. + cfa_offset += current_frame.size /*+ 4*/;
  1484. dwarf2out_def_cfa ("", STACK_POINTER_REGNUM, cfa_offset);
  1485. }
  1486. } /* !frame_pointer_needed */
  1487. @@ -724,6 +890,11 @@
  1488. }
  1489. }
  1490. }
  1491. +
  1492. + /* (TIGCC 20050208) Handle OPTIMIZE_ROM_CALLS. Register #13 is %a5. */
  1493. + if (global_regs[13] && m68k_interrupt_function_p (current_function_decl)
  1494. + && cpp_defined (parse_in, (unsigned char *)"OPTIMIZE_ROM_CALLS", 18))
  1495. + asm_fprintf (stream, "\tmove.l 200.w,%%a5\n");
  1496. }
  1497. /* Return true if this function's epilogue can be output as RTL. */
  1498. @@ -763,9 +934,11 @@
  1499. insn = prev_nonnote_insn (insn);
  1500. if (insn && GET_CODE (insn) == BARRIER)
  1501. {
  1502. +#if 0 /* (TIGCC 20050206) */
  1503. /* Output just a no-op so that debuggers don't get confused
  1504. about which function the pc is in at this address. */
  1505. fprintf (stream, "\tnop\n");
  1506. +#endif /* 0 */
  1507. return;
  1508. }
  1509. @@ -1052,8 +1225,17 @@
  1510. a shorter one that uses a GOT entry or a longer one that doesn't.
  1511. We use the -Os command-line flag to decide which to generate.
  1512. Both sequences take the same time to execute on the ColdFire. */
  1513. +/* (TIGCC 20040222, 20050204) No long branches please... */
  1514. +/* (TIGCC 20050209) FIXME: This should really be handled fully in one place.
  1515. + Currently, part of this logic is in the patching code
  1516. + and part is in GCC. It should be all in GCC IMHO. */
  1517. + else if (TARGET_PCREL && GET_CODE (dest) == MEM
  1518. + && GET_CODE (XEXP (dest, 0)) == SYMBOL_REF
  1519. + && (!strncmp(XSTR (XEXP (dest, 0), 0),"_ROM_CALL_",10)
  1520. + || !strncmp(XSTR (XEXP (dest, 0), 0),"_RAM_CALL_",10)))
  1521. + out = "jbsr %o0";
  1522. else if (TARGET_PCREL)
  1523. - out = "bsr.l %o0";
  1524. + out = "bsr %o0";
  1525. else if (TARGET_68020)
  1526. #if defined(USE_GAS)
  1527. out = "bsr.l %0@PLTPC";
  1528. @@ -1455,11 +1637,11 @@
  1529. typedef enum { MOVL, SWAP, NEGW, NOTW, NOTB, MOVQ, MVS, MVZ } CONST_METHOD;
  1530. -static CONST_METHOD const_method (rtx);
  1531. +CONST_METHOD const_method (rtx);
  1532. #define USE_MOVQ(i) ((unsigned)((i) + 128) <= 255)
  1533. -static CONST_METHOD
  1534. +CONST_METHOD
  1535. const_method (rtx constant)
  1536. {
  1537. int i;
  1538. @@ -1561,10 +1743,15 @@
  1539. for add and the time for shift, taking away a little more because
  1540. sometimes move insns are needed. */
  1541. /* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
  1542. + /* (TIGCC 20030705) Decrease multiplication/division cost under -Os, so that
  1543. + muls/divs/divu gets preferred over large expansions of
  1544. + shifts & adds.
  1545. + -- Kevin Kofler */
  1546. #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : (TARGET_COLDFIRE && !TARGET_5200) ? 3 : TARGET_COLDFIRE ? 10 : 13)
  1547. -#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
  1548. - (TARGET_COLDFIRE && !TARGET_5200) ? 2 : 5)
  1549. -#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
  1550. +#define MULW_COST (optimize_size ? 3 : (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
  1551. + (TARGET_COLDFIRE && !TARGET_5200) ? 2 : 5))
  1552. +#define DIVW_COST (optimize_size ? 3 : (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12))
  1553. +#define UDIVW_COST (optimize_size ? 6 : (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12))
  1554. case PLUS:
  1555. /* An lea costs about three times as much as a simple add. */
  1556. @@ -1595,11 +1782,15 @@
  1557. {
  1558. if (GET_CODE (XEXP (x, 1)) == CONST_INT)
  1559. {
  1560. +/* (TIGCC 20030705) shifts costs under -Os are instruction counts, not cycle counts -- Kevin Kofler */ \
  1561. +/* (TIGCC 20050210) lsl #2 is cheaper than 2 adds even when optimizing for speed.
  1562. + This ugly hack (making long shifts "cost less" than word
  1563. + shifts) accounts for that. */ \
  1564. if (INTVAL (XEXP (x, 1)) < 16)
  1565. - *total = COSTS_N_INSNS (2) + INTVAL (XEXP (x, 1)) / 2;
  1566. + *total = COSTS_N_INSNS (2) + INTVAL (XEXP (x, 1)) / (optimize_size ? 9 : GET_MODE (x) == SImode ? 3 : 2);
  1567. else
  1568. /* We're using clrw + swap for these cases. */
  1569. - *total = COSTS_N_INSNS (4) + (INTVAL (XEXP (x, 1)) - 16) / 2;
  1570. + *total = COSTS_N_INSNS (4) + (INTVAL (XEXP (x, 1)) - 16) / (optimize_size ? 9 : GET_MODE (x) == SImode ? 3 : 2);
  1571. }
  1572. else
  1573. *total = COSTS_N_INSNS (10); /* worst case */
  1574. @@ -1632,10 +1823,10 @@
  1575. *total = COSTS_N_INSNS (MULL_COST);
  1576. return true;
  1577. +/* (TIGCC 20030705) distinguish signed vs. unsigned division */ \
  1578. +/* - ext is cheaper than the unsigned equivalent -- Kevin Kofler */ \
  1579. case DIV:
  1580. - case UDIV:
  1581. case MOD:
  1582. - case UMOD:
  1583. if (GET_MODE (x) == QImode || GET_MODE (x) == HImode)
  1584. *total = COSTS_N_INSNS (DIVW_COST); /* div.w */
  1585. else if (TARGET_CF_HWDIV)
  1586. @@ -1644,6 +1835,16 @@
  1587. *total = COSTS_N_INSNS (43); /* div.l */
  1588. return true;
  1589. + case UDIV: \
  1590. + case UMOD: \
  1591. + if (GET_MODE (x) == QImode || GET_MODE (x) == HImode)
  1592. + *total = COSTS_N_INSNS (UDIVW_COST); /* div.w */
  1593. + else if (TARGET_CF_HWDIV)
  1594. + *total = COSTS_N_INSNS (18);
  1595. + else
  1596. + *total = COSTS_N_INSNS (43); /* div.l */
  1597. + return true;
  1598. +
  1599. default:
  1600. return false;
  1601. }
  1602. @@ -1860,6 +2061,24 @@
  1603. return "move%.b %1,%0";
  1604. }
  1605. +static const char *
  1606. +output_move_himode_const (rtx *operands)
  1607. +{
  1608. + if (operands[1] == const0_rtx
  1609. + && (DATA_REG_P (operands[0])
  1610. + || GET_CODE (operands[0]) == MEM)
  1611. + /* clr insns on 68000 read before writing.
  1612. + This isn't so on the 68010, but we have no TARGET_68010. */
  1613. + && ((TARGET_68020 || TARGET_5200)
  1614. + || !(GET_CODE (operands[0]) == MEM
  1615. + && MEM_VOLATILE_P (operands[0]))))
  1616. + return "clr%.w %0";
  1617. + else if (operands[1] == const0_rtx
  1618. + && ADDRESS_REG_P (operands[0]))
  1619. + return "sub%.w %0,%0";
  1620. + return "move%.w %1,%0";
  1621. +}
  1622. +
  1623. const char *
  1624. output_move_stricthi (rtx *operands)
  1625. {
  1626. @@ -1884,6 +2103,17 @@
  1627. return "move%.b %1,%0";
  1628. }
  1629. +/* (TIGCC) Return the best assembler insn template
  1630. + for moving operands[1] into operands[0] as a halfword. */
  1631. +
  1632. +static const char *
  1633. +halfsinglemove_string (rtx *operands)
  1634. +{
  1635. + if (GET_CODE (operands[1]) == CONST_INT)
  1636. + return output_move_himode_const (operands);
  1637. + return "move%.w %1,%0";
  1638. +}
  1639. +
  1640. /* Return the best assembler insn template
  1641. for moving operands[1] into operands[0] as a fullword. */
  1642. @@ -1960,10 +2190,14 @@
  1643. operands[0] = XEXP (XEXP (operands[0], 0), 0);
  1644. if (size == 12)
  1645. output_asm_insn ("sub%.l #12,%0", operands);
  1646. + else if (size == 10)
  1647. + output_asm_insn ("sub%.l #10,%0", operands);
  1648. else
  1649. output_asm_insn ("subq%.l #8,%0", operands);
  1650. - if (GET_MODE (operands[1]) == XFmode)
  1651. + if (GET_MODE (operands[0]) == XFmode)
  1652. operands[0] = gen_rtx_MEM (XFmode, operands[0]);
  1653. + else if (GET_MODE (operands[0]) == BFmode)
  1654. + operands[0] = gen_rtx_MEM (BFmode, operands[0]);
  1655. else if (GET_MODE (operands[0]) == DFmode)
  1656. operands[0] = gen_rtx_MEM (DFmode, operands[0]);
  1657. else
  1658. @@ -1975,10 +2209,14 @@
  1659. operands[1] = XEXP (XEXP (operands[1], 0), 0);
  1660. if (size == 12)
  1661. output_asm_insn ("sub%.l #12,%1", operands);
  1662. + else if (size == 10)
  1663. + output_asm_insn ("sub%.l #10,%1", operands);
  1664. else
  1665. output_asm_insn ("subq%.l #8,%1", operands);
  1666. if (GET_MODE (operands[1]) == XFmode)
  1667. operands[1] = gen_rtx_MEM (XFmode, operands[1]);
  1668. + else if (GET_MODE (operands[1]) == BFmode)
  1669. + operands[1] = gen_rtx_MEM (BFmode, operands[1]);
  1670. else if (GET_MODE (operands[1]) == DFmode)
  1671. operands[1] = gen_rtx_MEM (DFmode, operands[1]);
  1672. else
  1673. @@ -2014,7 +2252,7 @@
  1674. else if (optype0 == OFFSOP)
  1675. {
  1676. middlehalf[0] = adjust_address (operands[0], SImode, 4);
  1677. - latehalf[0] = adjust_address (operands[0], SImode, size - 4);
  1678. + latehalf[0] = adjust_address (operands[0], SImode, 8);
  1679. }
  1680. else
  1681. {
  1682. @@ -2030,7 +2268,7 @@
  1683. else if (optype1 == OFFSOP)
  1684. {
  1685. middlehalf[1] = adjust_address (operands[1], SImode, 4);
  1686. - latehalf[1] = adjust_address (operands[1], SImode, size - 4);
  1687. + latehalf[1] = adjust_address (operands[1], SImode, 8);
  1688. }
  1689. else if (optype1 == CNSTOP)
  1690. {
  1691. @@ -2058,8 +2296,66 @@
  1692. latehalf[1] = operands[1];
  1693. }
  1694. }
  1695. - else
  1696. - /* size is not 12: */
  1697. + else if (size == 10)
  1698. + {
  1699. + if (optype0 == REGOP)
  1700. + {
  1701. + latehalf[0] = gen_rtx_REG (HImode, REGNO (operands[0]) + 2);
  1702. + middlehalf[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  1703. + }
  1704. + else if (optype0 == OFFSOP)
  1705. + {
  1706. + middlehalf[0] = adjust_address (operands[0], SImode, 4);
  1707. + latehalf[0] = adjust_address (operands[0], SImode, 8);
  1708. + }
  1709. + else
  1710. + {
  1711. + middlehalf[0] = operands[0];
  1712. + latehalf[0] = operands[0];
  1713. + }
  1714. +
  1715. + if (optype1 == REGOP)
  1716. + {
  1717. + latehalf[1] = gen_rtx_REG (HImode, REGNO (operands[1]) + 2);
  1718. + middlehalf[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  1719. + }
  1720. + else if (optype1 == OFFSOP)
  1721. + {
  1722. + middlehalf[1] = adjust_address (operands[1], SImode, 4);
  1723. + latehalf[1] = adjust_address (operands[1], SImode, 8);
  1724. + }
  1725. + else if (optype1 == CNSTOP)
  1726. + {
  1727. + if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1728. + {
  1729. + REAL_VALUE_TYPE r;
  1730. + long l[3];
  1731. +
  1732. + gcc_unreachable ();
  1733. + REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
  1734. + REAL_VALUE_TO_TARGET_LONG_DOUBLE (r, l);
  1735. + operands[1] = GEN_INT (l[0]);
  1736. + middlehalf[1] = GEN_INT (l[1]);
  1737. + latehalf[1] = GEN_INT (l[2]);
  1738. + }
  1739. + else if (CONSTANT_P (operands[1]))
  1740. + {
  1741. + /* actually, no non-CONST_DOUBLE constant should ever
  1742. + appear here. */
  1743. + gcc_unreachable ();
  1744. + if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) < 0)
  1745. + latehalf[1] = constm1_rtx;
  1746. + else
  1747. + latehalf[1] = const0_rtx;
  1748. + }
  1749. + }
  1750. + else
  1751. + {
  1752. + middlehalf[1] = operands[1];
  1753. + latehalf[1] = operands[1];
  1754. + }
  1755. + }
  1756. + else /* size is neither 12 or 10: */
  1757. {
  1758. if (optype0 == REGOP)
  1759. latehalf[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  1760. @@ -2084,7 +2380,16 @@
  1761. if (optype0 == PUSHOP
  1762. && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
  1763. && reg_overlap_mentioned_p (stack_pointer_rtx, operands[1]))
  1764. + {
  1765. + if (size==10) {
  1766. + /* (TIGCC 20040219) The above is not quite right for size==10. What we
  1767. + have to do here is: (1) move.w operands[1]+8,-(%sp);
  1768. + (2) move.l operands[1]+6,-(%sp); (3) move.l operands[1]+6,-(%sp).
  1769. + -- Kevin Kofler */
  1770. + operands[1] = middlehalf[1] = adjust_address (operands[1], SImode, 6);
  1771. + } else
  1772. operands[1] = middlehalf[1] = latehalf[1];
  1773. + }
  1774. /* For (set (reg:DI N) (mem:DI ... (reg:SI N) ...)),
  1775. if the upper part of reg N does not appear in the MEM, arrange to
  1776. @@ -2112,6 +2417,12 @@
  1777. middlehalf[1] = adjust_address (operands[1], DImode, size - 8);
  1778. latehalf[1] = adjust_address (operands[1], DImode, size - 4);
  1779. }
  1780. + else if( GET_MODE (operands[1]) == BFmode )
  1781. + {
  1782. + operands[1] = gen_rtx_MEM (BFmode, latehalf[0]);
  1783. + middlehalf[1] = adjust_address (operands[1], DImode, 4);
  1784. + latehalf[1] = adjust_address (operands[1], DImode, 8);
  1785. + }
  1786. else
  1787. {
  1788. operands[1] = gen_rtx_MEM (DImode, latehalf[0]);
  1789. @@ -2141,6 +2452,30 @@
  1790. output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1791. return "";
  1792. }
  1793. + else if (size == 10
  1794. + && reg_overlap_mentioned_p (middlehalf[0],
  1795. + XEXP (operands[1], 0)))
  1796. + {
  1797. + /* Check for two regs used by both source and dest.
  1798. + Note that this can't happen if the dest is all data regs.
  1799. + It can happen if the dest is d6, d7, a0.
  1800. + But in that case, latehalf is an addr reg, so
  1801. + the code at compadr does ok. */
  1802. +
  1803. + if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0))
  1804. + || reg_overlap_mentioned_p (latehalf[0], XEXP (operands[1], 0)))
  1805. + goto compadr;
  1806. +
  1807. + /* JRV says this can't happen: */
  1808. + if (addreg0 || addreg1)
  1809. + gcc_unreachable ();
  1810. +
  1811. + /* Only the middle reg conflicts; simply put it last. */
  1812. + output_asm_insn (singlemove_string (operands), operands);
  1813. + output_asm_insn (halfsinglemove_string (latehalf), latehalf);
  1814. + output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1815. + return "";
  1816. + }
  1817. else if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0)))
  1818. /* If the low half of dest is mentioned in the source memory
  1819. address, the arrange to emit the move late half first. */
  1820. @@ -2164,21 +2499,24 @@
  1821. /* Make any unoffsettable addresses point at high-numbered word. */
  1822. if (addreg0)
  1823. {
  1824. - if (size == 12)
  1825. + if (size == 12 || size == 10)
  1826. output_asm_insn ("addq%.l #8,%0", &addreg0);
  1827. else
  1828. output_asm_insn ("addq%.l #4,%0", &addreg0);
  1829. }
  1830. if (addreg1)
  1831. {
  1832. - if (size == 12)
  1833. + if (size == 12 || size == 10)
  1834. output_asm_insn ("addq%.l #8,%0", &addreg1);
  1835. else
  1836. output_asm_insn ("addq%.l #4,%0", &addreg1);
  1837. }
  1838. /* Do that word. */
  1839. - output_asm_insn (singlemove_string (latehalf), latehalf);
  1840. + if (size == 10)
  1841. + output_asm_insn (halfsinglemove_string (latehalf), latehalf);
  1842. + else
  1843. + output_asm_insn (singlemove_string (latehalf), latehalf);
  1844. /* Undo the adds we just did. */
  1845. if (addreg0)
  1846. @@ -2186,7 +2524,7 @@
  1847. if (addreg1)
  1848. output_asm_insn ("subq%.l #4,%0", &addreg1);
  1849. - if (size == 12)
  1850. + if (size == 12 || size == 10)
  1851. {
  1852. output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1853. if (addreg0)
  1854. @@ -2204,7 +2542,7 @@
  1855. output_asm_insn (singlemove_string (operands), operands);
  1856. /* Do the middle one of the three words for long double */
  1857. - if (size == 12)
  1858. + if (size == 12 || size == 10)
  1859. {
  1860. if (addreg0)
  1861. output_asm_insn ("addq%.l #4,%0", &addreg0);
  1862. @@ -2221,19 +2559,22 @@
  1863. output_asm_insn ("addq%.l #4,%0", &addreg1);
  1864. /* Do that word. */
  1865. - output_asm_insn (singlemove_string (latehalf), latehalf);
  1866. + if (size == 10)
  1867. + output_asm_insn (halfsinglemove_string (latehalf), latehalf);
  1868. + else
  1869. + output_asm_insn (singlemove_string (latehalf), latehalf);
  1870. /* Undo the adds we just did. */
  1871. if (addreg0)
  1872. {
  1873. - if (size == 12)
  1874. + if (size == 12 || size == 10)
  1875. output_asm_insn ("subq%.l #8,%0", &addreg0);
  1876. else
  1877. output_asm_insn ("subq%.l #4,%0", &addreg0);
  1878. }
  1879. if (addreg1)
  1880. {
  1881. - if (size == 12)
  1882. + if (size == 12 || size == 10)
  1883. output_asm_insn ("subq%.l #8,%0", &addreg1);
  1884. else
  1885. output_asm_insn ("subq%.l #4,%0", &addreg1);
  1886. @@ -2563,6 +2904,8 @@
  1887. int
  1888. floating_exact_log2 (rtx x)
  1889. {
  1890. +gcc_unreachable();
  1891. +#if 0
  1892. REAL_VALUE_TYPE r, r1;
  1893. int exp;
  1894. @@ -2577,6 +2920,7 @@
  1895. return exp;
  1896. return 0;
  1897. +#endif /* 0 */
  1898. }
  1899. /* A C compound statement to output to stdio stream STREAM the
  1900. @@ -2623,6 +2967,8 @@
  1901. 'x' for float insn (print a CONST_DOUBLE as a float rather than in hex),
  1902. or print pair of registers as rx:ry.
  1903. +(TIGCC 20040222) 'A' like 'o', but for addresses.
  1904. +
  1905. */
  1906. void
  1907. @@ -2663,6 +3009,14 @@
  1908. && TARGET_PCREL);
  1909. output_addr_const (file, XEXP (op, 0));
  1910. }
  1911. + else if (letter == 'A') /* (TIGCC 20040222) */
  1912. + {
  1913. + if (TARGET_PCREL) {
  1914. + target_flags&=~MASK_PCREL; /* ugly hack, but works */
  1915. + print_operand_address(file,op);
  1916. + target_flags|=MASK_PCREL;
  1917. + } else print_operand_address(file,op);
  1918. + }
  1919. else if (GET_CODE (op) == REG)
  1920. {
  1921. if (letter == 'R')
  1922. @@ -2675,13 +3029,24 @@
  1923. else if (GET_CODE (op) == MEM)
  1924. {
  1925. output_address (XEXP (op, 0));
  1926. + /* TIGCC Patch: This is a very bad try to implement addresses relative to a register.
  1927. + Julien Muchembled says this should work.
  1928. + At least it should if only one file is used.
  1929. + (TIGCC 20040808) Added CONST. A MEM(CONST) is used for sym+const addressing. This
  1930. + needs to be made reg-relative too. -- Kevin Kofler */
  1931. + if (TARGET_REG_RELATIVE && (GET_CODE (XEXP (op, 0)) == SYMBOL_REF || GET_CODE (XEXP (op, 0)) == LABEL_REF || GET_CODE (XEXP (op, 0)) == CODE_LABEL || GET_CODE (XEXP (op, 0)) == CONST))
  1932. + fprintf (file, "-__relation(%%%s)", TARGET_RELATION_REG);
  1933. + else
  1934. + {
  1935. if (letter == 'd' && ! TARGET_68020
  1936. && CONSTANT_ADDRESS_P (XEXP (op, 0))
  1937. && !(GET_CODE (XEXP (op, 0)) == CONST_INT
  1938. && INTVAL (XEXP (op, 0)) < 0x8000
  1939. && INTVAL (XEXP (op, 0)) >= -0x8000))
  1940. fprintf (file, MOTOROLA ? ".l" : ":l");
  1941. + }
  1942. }
  1943. +#if 0
  1944. else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == SFmode)
  1945. {
  1946. REAL_VALUE_TYPE r;
  1947. @@ -2700,6 +3065,7 @@
  1948. REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  1949. ASM_OUTPUT_DOUBLE_OPERAND (file, r);
  1950. }
  1951. +#endif /* 0 */
  1952. else
  1953. {
  1954. /* Use `print_operand_address' instead of `output_addr_const'
  1955. @@ -3232,6 +3598,169 @@
  1956. return "eor%.l %2,%0";
  1957. }
  1958. +/* Argument-passing support functions. */
  1959. +
  1960. +/* Initialize a variable CUM of type CUMULATIVE_ARGS
  1961. + for a call to a function whose data type is FNTYPE.
  1962. + For a library call, FNTYPE is 0. */
  1963. +
  1964. +static void
  1965. +m68k_init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, tree fndecl)
  1966. +{
  1967. + cum->last_arg_reg = -1;
  1968. + cum->regs_already_used = 0;
  1969. + if (fntype)
  1970. + {
  1971. + if (lookup_attribute ("stkparm", TYPE_ATTRIBUTES (fntype)))
  1972. + cum->num_of_regs = 0;
  1973. + else
  1974. + {
  1975. + tree ratree = lookup_attribute ("regparm", TYPE_ATTRIBUTES (fntype));
  1976. + if (ratree)
  1977. + {
  1978. + cum->num_of_regs = m68k_regparm ? m68k_regparm
  1979. + : M68K_DEFAULT_REGPARM;
  1980. + if (TREE_VALUE (ratree)
  1981. + && TREE_CODE (TREE_VALUE (ratree)) == TREE_LIST)
  1982. + {
  1983. + tree num_of_regs = TREE_VALUE (TREE_VALUE (ratree));
  1984. + cum->num_of_regs =
  1985. + num_of_regs ? TREE_INT_CST_LOW (num_of_regs) :
  1986. + (m68k_regparm ? m68k_regparm : M68K_DEFAULT_REGPARM);
  1987. + }
  1988. + }
  1989. +/* (TIGCC 20050208) Use register calling convention for local functions when
  1990. + possible. Partially copied from i386.c. */
  1991. + else if (fndecl && flag_unit_at_a_time)
  1992. + {
  1993. + struct cgraph_local_info *i = cgraph_local_info (fndecl);
  1994. + if (i && i->local)
  1995. + {
  1996. + cum->num_of_regs = m68k_regparm ? m68k_regparm
  1997. + : M68K_DEFAULT_REGPARM;
  1998. + }
  1999. + else
  2000. + cum->num_of_regs = m68k_regparm;
  2001. + }
  2002. + else
  2003. + cum->num_of_regs = m68k_regparm;
  2004. + }
  2005. + }
  2006. + else /* Libcall. */
  2007. + cum->num_of_regs = 0;
  2008. +
  2009. + if (cum->num_of_regs)
  2010. + {
  2011. + /* If this is a vararg call, put all arguments on stack. */
  2012. + tree param, next_param;
  2013. + for (param = TYPE_ARG_TYPES (fntype); param; param = next_param)
  2014. + {
  2015. + next_param = TREE_CHAIN (param);
  2016. + if (!next_param && TREE_VALUE (param) != void_type_node)
  2017. + cum->num_of_regs = 0;
  2018. + }
  2019. + }
  2020. +
  2021. +#if ! defined (PCC_STATIC_STRUCT_RETURN) && defined (M68K_STRUCT_VALUE_REGNUM)
  2022. + /* If return value is a structure, and we pass the buffer address in a
  2023. + register, we can't use this register for our own purposes. */
  2024. + if (fntype && aggregate_value_p (TREE_TYPE (fntype), fntype))
  2025. + cum->regs_already_used |= (1 << M68K_STRUCT_VALUE_REGNUM);
  2026. +#endif
  2027. +
  2028. + /* (TIGCC 20060916) Same for static chain. -- Kevin Kofler */
  2029. + if (fndecl && decl_function_context(fndecl) && !DECL_NO_STATIC_CHAIN(fndecl))
  2030. + cum->regs_already_used |= (1 << STATIC_CHAIN_REGNUM);
  2031. +}
  2032. +
  2033. +/* Update the data in CUM to advance over an argument. */
  2034. +
  2035. +static void
  2036. +m68k_function_arg_advance (CUMULATIVE_ARGS *cum)
  2037. +{
  2038. + if (cum->last_arg_reg != -1)
  2039. + {
  2040. + int count;
  2041. + for (count = 0; count < cum->last_arg_len; count++)
  2042. + cum->regs_already_used |= (1 << (cum->last_arg_reg + count));
  2043. + cum->last_arg_reg = -1;
  2044. + }
  2045. +}
  2046. +
  2047. +/* Define where to put the arguments to a function.
  2048. + Value is zero to push the argument on the stack,
  2049. + or a hard register in which to store the argument.
  2050. +
  2051. + MODE is the argument's machine mode.
  2052. + TYPE is the data type of the argument (as a tree).
  2053. + This is null for libcalls where that information may
  2054. + not be available.
  2055. + CUM is a variable of type CUMULATIVE_ARGS which gives info about
  2056. + the preceding args and about the function being called. */
  2057. +
  2058. +static struct rtx_def *
  2059. +m68k_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type)
  2060. +{
  2061. + if (cum->num_of_regs)
  2062. + {
  2063. + int regbegin = -1, altregbegin = -1, len;
  2064. +
  2065. + /* FIXME: The last condition below is a workaround for a bug. */
  2066. + if (TARGET_68881 && FLOAT_MODE_P (mode) &&
  2067. + GET_MODE_UNIT_SIZE (mode) <= 12 &&
  2068. + (GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT || mode == SCmode))
  2069. + {
  2070. + regbegin = 16; /* FPx */
  2071. + len = GET_MODE_NUNITS (mode);
  2072. + }
  2073. + /* FIXME: Two last conditions below are workarounds for bugs. */
  2074. + else if (INTEGRAL_MODE_P (mode) && mode !=CQImode && mode != CHImode)
  2075. + {
  2076. + if (POINTER_TYPE_P (type))
  2077. + regbegin = 8; /* Ax */
  2078. + else
  2079. + regbegin = 0; /* Dx */
  2080. + altregbegin = 8 - regbegin;
  2081. + len = (GET_MODE_SIZE (mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
  2082. + }
  2083. +
  2084. + if (regbegin != -1)
  2085. + {
  2086. + int reg;
  2087. + long mask;
  2088. +
  2089. +look_for_reg:
  2090. + mask = 1 << regbegin;
  2091. + for (reg = 0; reg < cum->num_of_regs; reg++, mask <<= 1)
  2092. + if (!(cum->regs_already_used & mask))
  2093. + {
  2094. + int end;
  2095. + for (end = reg; end < cum->num_of_regs && end < reg + len;
  2096. + end++, mask <<= 1)
  2097. + if (cum->regs_already_used & mask)
  2098. + break;
  2099. + if (end == reg + len)
  2100. + {
  2101. + cum->last_arg_reg = reg + regbegin;
  2102. + cum->last_arg_len = len;
  2103. + break;
  2104. + }
  2105. + }
  2106. +
  2107. + if (reg == cum->num_of_regs && altregbegin != -1)
  2108. + {
  2109. + regbegin = altregbegin;
  2110. + altregbegin = -1;
  2111. + goto look_for_reg;
  2112. + }
  2113. + }
  2114. +
  2115. + if (cum->last_arg_reg != -1)
  2116. + return gen_rtx_REG (mode, cum->last_arg_reg);
  2117. + }
  2118. + return 0;
  2119. +}
  2120. +
  2121. #ifdef M68K_TARGET_COFF
  2122. /* Output assembly to switch to section NAME with attribute FLAGS. */
  2123. @@ -3241,13 +3770,28 @@
  2124. tree decl ATTRIBUTE_UNUSED)
  2125. {
  2126. char flagchar;
  2127. -
  2128. - if (flags & SECTION_WRITE)
  2129. + /* (TIGCC 20040725) Constant/string merging flags for TIGCC-extended COFF.
  2130. + SECTION_STRINGS is abused for the unaligned flag. */
  2131. + const char *xflags = "";
  2132. +
  2133. + /* (TIGCC 20040619) Handle BSS sections properly with -fdata-sections.
  2134. + -- Kevin Kofler*/
  2135. + if ((flags & SECTION_BSS) && !TARGET_NO_BSS)
  2136. + flagchar = 'b';
  2137. + /* (TIGCC 20040620) Handle rodata sections properly with -fdata-sections.
  2138. + -- Kevin Kofler*/
  2139. + else if ((flags & SECTION_WRITE)
  2140. + || (!TARGET_RODATA_TO_TEXT && !(flags & SECTION_CODE)))
  2141. flagchar = 'd';
  2142. else
  2143. flagchar = 'x';
  2144. - fprintf (asm_out_file, "\t.section\t%s,\"%c\"\n", name, flagchar);
  2145. + if (flags & SECTION_MERGE)
  2146. + xflags = (flags & SECTION_STRINGS)?"mu":"m";
  2147. + else if (flags & SECTION_STRINGS)
  2148. + xflags = "u";
  2149. +
  2150. + fprintf (asm_out_file, "\t.section\t%s,\"%c%s\"\n", name, flagchar, xflags);
  2151. }
  2152. #endif /* M68K_TARGET_COFF */
  2153. @@ -3300,7 +3844,7 @@
  2154. if (flag_pic)
  2155. {
  2156. if (TARGET_PCREL)
  2157. - fmt = "bra.l %o0";
  2158. + fmt = "bra %o0"; /* (TIGCC 20040222, 20050204) No long branches please... */
  2159. else if ((flag_pic == 1) || TARGET_68020)
  2160. {
  2161. if (MOTOROLA)
  2162. @@ -3375,7 +3919,10 @@
  2163. {
  2164. /* Address Registers, can't hold bytes, can hold aggregate if
  2165. fits in. */
  2166. - if (GET_MODE_SIZE (mode) == 1)
  2167. + /* (TIGCC 20050924) We can put bytes in address registers on non-Coldfire.
  2168. + GCC just uses word moves where appropriate. This always worked for us.
  2169. + -- Kevin Kofler */
  2170. + if (TARGET_COLDFIRE && GET_MODE_SIZE (mode) == 1)
  2171. return false;
  2172. if (regno + GET_MODE_SIZE (mode) / 4 <= 16)
  2173. return true;
  2174. @@ -3391,3 +3938,127 @@
  2175. }
  2176. return false;
  2177. }
  2178. +
  2179. +/* begin-TIGCC-local (regparms): explicit register specification for parameters */
  2180. +
  2181. +/* Initialize a variable CUM of type CUMULATIVE_ARGS
  2182. + for a call to a function whose data type is FNTYPE.
  2183. + For a library call, FNTYPE is 0. */
  2184. +
  2185. +void
  2186. +amigaos_init_cumulative_args(CUMULATIVE_ARGS *cum, tree fntype, tree fndecl)
  2187. +{
  2188. + m68k_init_cumulative_args(cum, fntype, fndecl);
  2189. +
  2190. + if (fntype)
  2191. + cum->formal_type=TYPE_ARG_TYPES(fntype);
  2192. + else /* Call to compiler-support function. */
  2193. + cum->formal_type=0;
  2194. +}
  2195. +
  2196. +/* Update the data in CUM to advance over an argument. */
  2197. +
  2198. +void
  2199. +amigaos_function_arg_advance(CUMULATIVE_ARGS *cum)
  2200. +{
  2201. + m68k_function_arg_advance(cum);
  2202. +
  2203. + if (cum->formal_type)
  2204. + cum->formal_type=TREE_CHAIN((tree)cum->formal_type);
  2205. +}
  2206. +
  2207. +/* A C expression that controls whether a function argument is passed
  2208. + in a register, and which register. */
  2209. +
  2210. +struct rtx_def *
  2211. +amigaos_function_arg(CUMULATIVE_ARGS *cum, enum machine_mode mode,
  2212. + tree type)
  2213. +{
  2214. + tree asmtree;
  2215. + if (cum->formal_type && TREE_VALUE((tree)cum->formal_type)
  2216. + && (asmtree=lookup_attribute("asm",
  2217. + TYPE_ATTRIBUTES(TREE_VALUE((tree)cum->formal_type)))))
  2218. + {
  2219. + int i;
  2220. +#if 0
  2221. + /* See c-decl.c/push_parm_decl for an explanation why this doesn't work.
  2222. + */
  2223. + cum->last_arg_reg=TREE_INT_CST_LOW(TREE_VALUE(TREE_VALUE(asmtree)));
  2224. +#else
  2225. + cum->last_arg_reg=TREE_INT_CST_LOW(TREE_VALUE(asmtree));
  2226. +#endif
  2227. + cum->last_arg_len=HARD_REGNO_NREGS(cum->last_arg_reg, mode);
  2228. +
  2229. + for (i=0; i<cum->last_arg_len; i++)
  2230. + if (cum->regs_already_used & (1 << (cum->last_arg_reg+i)))
  2231. + {
  2232. + error("two parameters allocated for one register");
  2233. + break;
  2234. + }
  2235. + return gen_rtx_REG (mode, cum->last_arg_reg);
  2236. + }
  2237. + else
  2238. + return (struct rtx_def *)m68k_function_arg(cum, mode, type);
  2239. +}
  2240. +
  2241. +/* Return zero if the attributes on TYPE1 and TYPE2 are incompatible,
  2242. + one if they are compatible, and two if they are nearly compatible
  2243. + (which causes a warning to be generated). */
  2244. +
  2245. +int
  2246. +comp_amigaos_type_attributes(tree type1, tree type2)
  2247. +{
  2248. + int ret;
  2249. + if ((ret=comp_m68k_type_attributes(type1, type2))!=1)
  2250. + return ret;
  2251. +
  2252. + /* Functions or methods are incompatible if they specify mutually exclusive
  2253. + ways of passing arguments. */
  2254. + if (TREE_CODE(type1)==FUNCTION_TYPE || TREE_CODE(type1)==METHOD_TYPE)
  2255. + {
  2256. + tree arg1, arg2;
  2257. + arg1=TYPE_ARG_TYPES(type1);
  2258. + arg2=TYPE_ARG_TYPES(type2);
  2259. + for (; arg1 && arg2; arg1=TREE_CHAIN(arg1), arg2=TREE_CHAIN(arg2))
  2260. + if (TREE_VALUE(arg1) && TREE_VALUE(arg2))
  2261. + {
  2262. + tree asm1, asm2;
  2263. + asm1=lookup_attribute("asm", TYPE_ATTRIBUTES(TREE_VALUE(arg1)));
  2264. + asm2=lookup_attribute("asm", TYPE_ATTRIBUTES(TREE_VALUE(arg2)));
  2265. + if (asm1 && asm2)
  2266. + {
  2267. + if (TREE_INT_CST_LOW(TREE_VALUE(asm1))!=
  2268. + TREE_INT_CST_LOW(TREE_VALUE(asm2)))
  2269. + return 0; /* Two different registers specified. */
  2270. + }
  2271. + else
  2272. + if (asm1 || asm2)
  2273. + return 0; /* "asm" used in only one type. */
  2274. + }
  2275. + }
  2276. + return 1;
  2277. +}
  2278. +
  2279. +/* end-TIGCC-local (regparms) */
  2280. +
  2281. +/* (TIGCC) If TARGET_MERGE_SECTIONS is set (on by default), we need an explicit
  2282. + '.text' or '.data' (depending on TARGET_MERGE_TO_DATA) statement at the
  2283. + beginning of the file. */
  2284. +
  2285. +void m68k_asm_file_start(void)
  2286. +{
  2287. + output_file_directive (asm_out_file, main_input_filename);
  2288. + fprintf (asm_out_file, "#NO_APP\n");
  2289. + if (TARGET_REG_RELATIVE)
  2290. + fprintf (asm_out_file, "\t.set __relation,__ld_entry_point_plus_0x8000\n\t.xdef __ref_all___reg_relative_%s\n", TARGET_RELATION_REG);
  2291. + fprintf (asm_out_file, (TARGET_MERGE_SECTIONS?(TARGET_MERGE_TO_DATA?"\t.data\ntigcc_compiled.:\n":"\t.text\ntigcc_compiled.:\n"):"tigcc_compiled.:\n"));
  2292. +}
  2293. +
  2294. +/* (TIGCC 20050424) Everything which is not a CONST_DOUBLE has no business of
  2295. + being in the constant pool. This is especially valid for
  2296. + expressions containing relocations. -- Kevin Kofler */
  2297. +static bool m68k_cannot_force_const_mem (rtx r)
  2298. +{
  2299. + return (GET_CODE (r) != CONST_DOUBLE);
  2300. +}
  2301. +
  2302. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k.h gcc-4.1.2-src/gcc/config/m68k/m68k.h
  2303. --- gcc-4.1.2.orig/gcc/config/m68k/m68k.h 2005-07-12 01:32:01.000000000 +0200
  2304. +++ gcc-4.1.2-src/gcc/config/m68k/m68k.h 2007-02-19 02:32:34.000000000 +0100
  2305. @@ -113,6 +113,12 @@
  2306. /* Set the default. */
  2307. #define INT_OP_GROUP INT_OP_DOT_WORD
  2308. +/* Access everything in relation to a specific register */
  2309. +#define MASK_REG_RELATIVE (1<<30)
  2310. +#define TARGET_REG_RELATIVE (target_flags & MASK_REG_RELATIVE)
  2311. +
  2312. +#define TARGET_DIRECTFLOAT 0 /* not supported yet */
  2313. +
  2314. /* Compile for a CPU32. A 68020 without bitfields is a good
  2315. heuristic for a CPU32. */
  2316. #define TARGET_CPU32 (TARGET_68020 && !TARGET_BITFIELD)
  2317. @@ -126,6 +132,8 @@
  2318. /* These are meant to be redefined in the host dependent files */
  2319. #define SUBTARGET_OVERRIDE_OPTIONS
  2320. +extern char TARGET_RELATION_REG[];
  2321. +
  2322. /* target machine storage layout */
  2323. #define LONG_DOUBLE_TYPE_SIZE 80
  2324. @@ -141,7 +149,7 @@
  2325. #define UNITS_PER_WORD 4
  2326. -#define PARM_BOUNDARY (TARGET_SHORT ? 16 : 32)
  2327. +#define PARM_BOUNDARY 16
  2328. #define STACK_BOUNDARY 16
  2329. #define FUNCTION_BOUNDARY 16
  2330. #define EMPTY_FIELD_BOUNDARY 16
  2331. @@ -175,7 +183,9 @@
  2332. #define FIRST_PSEUDO_REGISTER 25
  2333. /* All m68k targets (except AmigaOS) use %a5 as the PIC register */
  2334. -#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 13 : INVALID_REGNUM)
  2335. +/* (TIGCC 20050209) TIGCC doesn't use a PIC register, and besides this was
  2336. + forgetting the -mpcrel case. */
  2337. +#define PIC_OFFSET_TABLE_REGNUM (INVALID_REGNUM)
  2338. /* 1 for registers that have pervasive standard uses
  2339. and are not available for the register allocator.
  2340. @@ -375,6 +385,9 @@
  2341. `S' is for operands that satisfy 'm' when -mpcrel is in effect.
  2342. `T' is for operands that satisfy 's' when -mpcrel is not in effect.
  2343. `U' is for register offset addressing. */
  2344. +/* (TIGCC 20040808) Under -freg-relative-an, the same restrictions on 's'/'T' as
  2345. + for -mpcrel apply. We can't use immediates as labels if
  2346. + we need to output reg-relative code. -- Kevin Kofler */
  2347. #define EXTRA_CONSTRAINT(OP,CODE) \
  2348. (((CODE) == 'S') \
  2349. ? (TARGET_PCREL \
  2350. @@ -384,7 +397,7 @@
  2351. || GET_CODE (XEXP (OP, 0)) == CONST)) \
  2352. : \
  2353. (((CODE) == 'T') \
  2354. - ? ( !TARGET_PCREL \
  2355. + ? ( (!TARGET_PCREL && !TARGET_REG_RELATIVE) \
  2356. && (GET_CODE (OP) == SYMBOL_REF \
  2357. || GET_CODE (OP) == LABEL_REF \
  2358. || GET_CODE (OP) == CONST)) \
  2359. @@ -486,24 +499,59 @@
  2360. #define PCC_STATIC_STRUCT_RETURN
  2361. -/* On the m68k, all arguments are usually pushed on the stack. */
  2362. -#define FUNCTION_ARG_REGNO_P(N) 0
  2363. -
  2364. -/* On the m68k, this is a single integer, which is a number of bytes
  2365. - of arguments scanned so far. */
  2366. -#define CUMULATIVE_ARGS int
  2367. -
  2368. -/* On the m68k, the offset starts at 0. */
  2369. -#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
  2370. - ((CUM) = 0)
  2371. +/* Define this if explicit register specification for parameters
  2372. + is supported. */
  2373. +
  2374. +#define EXPLICIT_REGPARM
  2375. +
  2376. +#define FUNCTION_ARG_REGNO_P(N) \
  2377. + (((N) >= 0 && (N) < M68K_MAX_REGPARM) \
  2378. + || ((N) >= 8 && (N) < 8 + M68K_MAX_REGPARM) \
  2379. + || (TARGET_68881 && (N) >= 16 && (N) < 16 + M68K_MAX_REGPARM))
  2380. +
  2381. +/* On the m68k, this is a structure:
  2382. + num_of_regs: number of data, address and float registers to use for
  2383. + arguments passing (if it's 2, than pass arguments in d0, d1, a0, a1,
  2384. + fp0 and fp1). 0 - pass everything on stack. vararg calls are
  2385. + always passed entirely on stack.
  2386. + regs_already_used: bitmask of the already used registers.
  2387. + last_arg_reg: register number of the most recently passed argument.
  2388. + -1 if passed on stack.
  2389. + last_arg_len: number of registers used by the most recently passed
  2390. + argument.
  2391. + formal_type: formal type of the current argument.
  2392. +*/
  2393. +
  2394. +struct m68k_args
  2395. +{
  2396. + int num_of_regs;
  2397. + long regs_already_used;
  2398. + int last_arg_reg;
  2399. + int last_arg_len;
  2400. + void *formal_type;
  2401. +};
  2402. +
  2403. +#define CUMULATIVE_ARGS struct m68k_args
  2404. +
  2405. +/* Max. number of data, address and float registers to be used for passing
  2406. + integer, pointer and float arguments when TARGET_REGPARM.
  2407. + It's 6, so d0-d5, a0-a5 and fp0-fp5 can be used. */
  2408. +
  2409. +#define M68K_MAX_REGPARM 6 /* was 4 in the original patch */
  2410. +
  2411. +/* The default number of data, address and float registers to use when
  2412. + user specified '-mregparm' switch, not '-mregparm=<value>' option. */
  2413. +
  2414. +#define M68K_DEFAULT_REGPARM 2 /* was 2 in the orginial patch */
  2415. +
  2416. +#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
  2417. + (amigaos_init_cumulative_args (&(CUM), (FNTYPE), (FNDECL)))
  2418. #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
  2419. - ((CUM) += ((MODE) != BLKmode \
  2420. - ? (GET_MODE_SIZE (MODE) + 3) & ~3 \
  2421. - : (int_size_in_bytes (TYPE) + 3) & ~3))
  2422. + (amigaos_function_arg_advance (&(CUM)))
  2423. -/* On the m68k all args are always pushed. */
  2424. -#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0
  2425. +#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
  2426. + ((struct rtx_def *)amigaos_function_arg (&(CUM), (MODE), (TYPE)))
  2427. #define FUNCTION_PROFILER(FILE, LABELNO) \
  2428. asm_fprintf (FILE, "\tlea %LLP%d,%Ra0\n\tjsr mcount\n", (LABELNO))
  2429. @@ -639,7 +687,11 @@
  2430. /* Nonzero if the constant value X is a legitimate general operand.
  2431. It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
  2432. -#define LEGITIMATE_CONSTANT_P(X) (GET_MODE (X) != XFmode)
  2433. +/* (TIGCC 20040808) If reg-relative, we need to reject "constants" of the #label
  2434. + or #label+const form. -- Kevin Kofler */
  2435. +
  2436. +#define LEGITIMATE_CONSTANT_P(X) (!TARGET_REG_RELATIVE \
  2437. + || !pcrel_address (X, VOIDmode))
  2438. #ifndef REG_OK_STRICT
  2439. #define PCREL_GENERAL_OPERAND_OK 0
  2440. @@ -950,15 +1002,19 @@
  2441. #define ASM_OUTPUT_SKIP(FILE,SIZE) \
  2442. fprintf (FILE, "\t.skip %u\n", (int)(SIZE))
  2443. +#ifndef ASM_OUTPUT_COMMON
  2444. #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
  2445. ( fputs (".comm ", (FILE)), \
  2446. assemble_name ((FILE), (NAME)), \
  2447. fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
  2448. +#endif
  2449. +#ifndef ASM_OUTPUT_LOCAL
  2450. #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
  2451. ( fputs (".lcomm ", (FILE)), \
  2452. assemble_name ((FILE), (NAME)), \
  2453. fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
  2454. +#endif
  2455. /* Output a float value (represented as a C double) as an immediate operand.
  2456. This macro is m68k-specific. */
  2457. @@ -1030,4 +1086,6 @@
  2458. /* Variables in m68k.c */
  2459. extern const char *m68k_library_id_string;
  2460. +extern const char *m68k_regparm_string;
  2461. +extern int m68k_regparm;
  2462. extern int m68k_last_compare_had_fp_operands;
  2463. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k.md gcc-4.1.2-src/gcc/config/m68k/m68k.md
  2464. --- gcc-4.1.2.orig/gcc/config/m68k/m68k.md 2005-11-22 21:53:08.000000000 +0100
  2465. +++ gcc-4.1.2-src/gcc/config/m68k/m68k.md 2007-02-19 02:32:34.000000000 +0100
  2466. @@ -329,20 +329,22 @@
  2467. (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
  2468. "!TARGET_COLDFIRE"
  2469. {
  2470. +/* (TIGCC 20040222) This used %d0 and %d1 to force absolute addressing, which
  2471. + doesn't make sense and breaks -mpcrel. -- Kevin Kofler */
  2472. if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  2473. return "cmpm%.l %1,%0";
  2474. if (REG_P (operands[1])
  2475. || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  2476. {
  2477. cc_status.flags |= CC_REVERSED;
  2478. - return "cmp%.l %d0,%d1";
  2479. + return "cmp%.l %0,%1";
  2480. }
  2481. if (ADDRESS_REG_P (operands[0])
  2482. && GET_CODE (operands[1]) == CONST_INT
  2483. && INTVAL (operands[1]) < 0x8000
  2484. && INTVAL (operands[1]) >= -0x8000)
  2485. return "cmp%.w %1,%0";
  2486. - return "cmp%.l %d1,%d0";
  2487. + return "cmp%.l %1,%0";
  2488. })
  2489. (define_insn ""
  2490. @@ -360,52 +362,62 @@
  2491. return "cmp%.l %d1,%d0";
  2492. })
  2493. +;; (TIGCC 20040808) Don't allow source-only operands as the destination in the
  2494. +;; compare. We need to use nonimmediate_operand, not
  2495. +;; nonimmediate_src_operand. Otherwise, -mpcrel outputs invalid
  2496. +;; assembly code. The SImode patterns already got this right.
  2497. +;; -- Kevin Kofler
  2498. +
  2499. (define_expand "cmphi"
  2500. [(set (cc0)
  2501. - (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
  2502. + (compare (match_operand:HI 0 "nonimmediate_operand" "")
  2503. (match_operand:HI 1 "general_src_operand" "")))]
  2504. "!TARGET_COLDFIRE"
  2505. "m68k_last_compare_had_fp_operands = 0;")
  2506. (define_insn ""
  2507. [(set (cc0)
  2508. - (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
  2509. + (compare (match_operand:HI 0 "nonimmediate_operand" "rnmS,d,n,mS,>")
  2510. (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
  2511. "!TARGET_COLDFIRE"
  2512. {
  2513. +/* (TIGCC 20040222) This used %d0 and %d1 to force absolute addressing, which
  2514. + doesn't make sense and breaks -mpcrel. -- Kevin Kofler */
  2515. if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  2516. return "cmpm%.w %1,%0";
  2517. if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
  2518. || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  2519. {
  2520. cc_status.flags |= CC_REVERSED;
  2521. - return "cmp%.w %d0,%d1";
  2522. + return "cmp%.w %0,%1";
  2523. }
  2524. - return "cmp%.w %d1,%d0";
  2525. + return "cmp%.w %1,%0";
  2526. })
  2527. (define_expand "cmpqi"
  2528. [(set (cc0)
  2529. - (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
  2530. + (compare (match_operand:QI 0 "nonimmediate_operand" "")
  2531. (match_operand:QI 1 "general_src_operand" "")))]
  2532. "!TARGET_COLDFIRE"
  2533. "m68k_last_compare_had_fp_operands = 0;")
  2534. (define_insn ""
  2535. [(set (cc0)
  2536. - (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
  2537. + (compare (match_operand:QI 0 "nonimmediate_operand" "dn,dmS,>")
  2538. (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
  2539. "!TARGET_COLDFIRE"
  2540. {
  2541. +/* (TIGCC 20040222) This used %d0 and %d1 to force absolute addressing, which
  2542. + doesn't make sense and breaks -mpcrel. -- Kevin Kofler */
  2543. if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  2544. return "cmpm%.b %1,%0";
  2545. if (REG_P (operands[1])
  2546. || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  2547. {
  2548. cc_status.flags |= CC_REVERSED;
  2549. - return "cmp%.b %d0,%d1";
  2550. + return "cmp%.b %0,%1";
  2551. }
  2552. - return "cmp%.b %d1,%d0";
  2553. + return "cmp%.b %1,%0";
  2554. })
  2555. (define_expand "cmpdf"
  2556. @@ -662,6 +674,12 @@
  2557. && symbolic_operand (XEXP (operands[0], 0), SImode))
  2558. operands[0] = gen_rtx_MEM (SImode,
  2559. force_reg (SImode, XEXP (operands[0], 0)));
  2560. + /* (TIGCC 20060105) Don't allow writes of a label directly to memory
  2561. + either. -- Kevin Kofler */
  2562. + else if (GET_CODE (operands[0]) == MEM
  2563. + && !push_operand (operands[0], SImode)
  2564. + && symbolic_operand (operands[1], SImode))
  2565. + operands[1] = force_reg (SImode, operands[1]);
  2566. }
  2567. })
  2568. @@ -693,16 +711,25 @@
  2569. ;; Special case of fullword move, where we need to get a non-GOT PIC
  2570. ;; reference into an address register.
  2571. +;; (TIGCC 20040808) This is also needed for -freg-relative-an. -- Kevin Kofler
  2572. +;; (TIGCC 20060105) Make sure we have an address register or a push operand.
  2573. +;; -- Kevin Kofler
  2574. (define_insn ""
  2575. - [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
  2576. + [(set (match_operand:SI 0 "register_operand" "=a")
  2577. (match_operand:SI 1 "pcrel_address" ""))]
  2578. - "TARGET_PCREL"
  2579. + "TARGET_PCREL || TARGET_REG_RELATIVE"
  2580. {
  2581. - if (push_operand (operands[0], SImode))
  2582. - return "pea %a1";
  2583. return "lea %a1,%0";
  2584. })
  2585. +(define_insn ""
  2586. + [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
  2587. + (match_operand:SI 0 "pcrel_address" ""))]
  2588. + "TARGET_PCREL || TARGET_REG_RELATIVE"
  2589. +{
  2590. + return "pea %a0";
  2591. +})
  2592. +
  2593. (define_expand "movhi"
  2594. [(set (match_operand:HI 0 "nonimmediate_operand" "")
  2595. (match_operand:HI 1 "general_operand" ""))]
  2596. @@ -775,13 +802,63 @@
  2597. "TARGET_COLDFIRE"
  2598. "* return output_move_strictqi (operands);")
  2599. +;; (TIGCC 20050210) Distinguish nonmemory_operand vs. memory_operand here, and
  2600. +;; optimize pushes from nonmemory_operand to word pushes. We
  2601. +;; can't do that for memory operands because of odd addresses.
  2602. +;; The distinction between register_operand and
  2603. +;; const_int_operand is because of paradoxical subreg
  2604. +;; technicalities.
  2605. +;; (TIGCC 20060801) We can accept SUBREGs with the register optimization only
  2606. +;; if the SUBREG_BYTE is odd.
  2607. +
  2608. (define_expand "pushqi1"
  2609. + [(match_operand:QI 0 "general_operand" "")]
  2610. + "!TARGET_COLDFIRE"
  2611. +"{
  2612. + if (const_int_operand (operands[0], QImode))
  2613. + emit_insn (gen_pushqi1_imm (operands[0]));
  2614. + else if (register_operand (operands[0], QImode)
  2615. + && (GET_CODE (operands[0]) != SUBREG
  2616. + || (SUBREG_BYTE(operands[0]) & 1)))
  2617. + emit_insn (gen_pushqi1_reg (operands[0]));
  2618. + else
  2619. + emit_insn (gen_pushqi1_mem (operands[0]));
  2620. + DONE;
  2621. +}")
  2622. +
  2623. +(define_expand "pushqi1_mem"
  2624. [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
  2625. (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
  2626. (match_operand:QI 0 "general_operand" ""))]
  2627. "!TARGET_COLDFIRE"
  2628. "")
  2629. +(define_expand "pushqi1_imm"
  2630. + [(set (mem:HI (pre_dec:SI (reg:SI SP_REG)))
  2631. + (match_operand:HI 0 "const_int_operand" ""))]
  2632. + "!TARGET_COLDFIRE"
  2633. + "")
  2634. +
  2635. +;; Yes, this is a paradoxical subreg.
  2636. +;; (TIGCC 20060801) Well, not always. We could have a true subreg, and then we
  2637. +;; need to adjust SUBREG_BYTE.
  2638. +;; SUBREG_BYTE(operands[0]) - 1 is always positive because
  2639. +;; SUBREG_BYTE(operands[0]) is unsigned and odd.
  2640. +(define_expand "pushqi1_reg"
  2641. + [(set (mem:HI (pre_dec:SI (reg:SI SP_REG)))
  2642. + (match_operand:QI 0 "register_operand" ""))]
  2643. + "!TARGET_COLDFIRE"
  2644. +"{
  2645. + {
  2646. + unsigned offset = 0;
  2647. + if (GET_CODE (operands[0]) == SUBREG) {
  2648. + offset = SUBREG_BYTE(operands[0]) - 1;
  2649. + operands[0] = SUBREG_REG (operands[0]);
  2650. + }
  2651. + operands[0] = gen_rtx_SUBREG (HImode, operands[0], offset);
  2652. + }
  2653. +}")
  2654. +
  2655. (define_expand "movsf"
  2656. [(set (match_operand:SF 0 "nonimmediate_operand" "")
  2657. (match_operand:SF 1 "general_operand" ""))]
  2658. @@ -897,6 +974,34 @@
  2659. ;; constants. Most but not all have output templates that handle constants.
  2660. ;; See also LEGITIMATE_CONSTANT_P.
  2661. +(define_expand "movbf"
  2662. + ;; SMAP BCD
  2663. + [(set (match_operand:BF 0 "nonimmediate_operand" "")
  2664. + (match_operand:BF 1 "general_operand" ""))]
  2665. + ""
  2666. + "
  2667. +{
  2668. + /* We can't rewrite operands during reload. */
  2669. + if (! reload_in_progress)
  2670. + {
  2671. + if (CONSTANT_P (operands[1]))
  2672. + {
  2673. + operands[1] = force_const_mem (BFmode, operands[1]);
  2674. + if (! memory_address_p (BFmode, XEXP (operands[1], 0)))
  2675. + operands[1] = adjust_address (operands[1], BFmode, 0);
  2676. + }
  2677. + if (flag_pic && TARGET_PCREL)
  2678. + {
  2679. + /* Don't allow writes to memory except via a register; the
  2680. + m68k doesn't consider PC-relative addresses to be writable. */
  2681. + if (GET_CODE (operands[0]) == MEM
  2682. + && symbolic_operand (XEXP (operands[0], 0), SImode))
  2683. + operands[0] = gen_rtx_MEM (BFmode,
  2684. + force_reg (SImode, XEXP (operands[0], 0)));
  2685. + }
  2686. + }
  2687. +}")
  2688. +
  2689. (define_expand "movxf"
  2690. [(set (match_operand:XF 0 "nonimmediate_operand" "")
  2691. (match_operand:XF 1 "general_operand" ""))]
  2692. @@ -963,6 +1068,46 @@
  2693. })
  2694. (define_insn ""
  2695. + ;; SMAP BCD
  2696. + [(set (match_operand:BF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
  2697. + (match_operand:BF 1 "nonimmediate_operand" "rf,m,rof<>"))]
  2698. + "! TARGET_68881 && ! TARGET_COLDFIRE"
  2699. +{
  2700. + if (FP_REG_P (operands[0]))
  2701. + {
  2702. + if (FP_REG_P (operands[1]))
  2703. + return "fmove%.x %1,%0";
  2704. + if (REG_P (operands[1]))
  2705. + {
  2706. + rtx xoperands[2];
  2707. + xoperands[1] = gen_rtx_REG (HImode, REGNO (operands[1]) + 2);
  2708. + output_asm_insn ("move%.w %1,%-", xoperands);
  2709. + xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  2710. + output_asm_insn ("move%.l %1,%-", xoperands);
  2711. + output_asm_insn ("move%.l %1,%-", operands);
  2712. + return "fmove%.x %+,%0";
  2713. + }
  2714. + if (GET_CODE (operands[1]) == CONST_DOUBLE)
  2715. + return "fmove%.x %1,%0";
  2716. + return "fmove%.x %f1,%0";
  2717. + }
  2718. + if (FP_REG_P (operands[1]))
  2719. + {
  2720. + if (REG_P (operands[0]))
  2721. + {
  2722. + output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
  2723. + operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
  2724. + output_asm_insn ("move%.l %+,%0", operands);
  2725. + operands[0] = gen_rtx_REG (HImode, REGNO (operands[0]) + 1);
  2726. + return "move%.w %+,%0";
  2727. + }
  2728. + else
  2729. + return "fmove%.x %f1,%0";
  2730. + }
  2731. + return output_move_double (operands);
  2732. +})
  2733. +
  2734. +(define_insn ""
  2735. [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
  2736. (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
  2737. "! TARGET_68881 && ! TARGET_COLDFIRE"
  2738. @@ -1233,9 +1378,12 @@
  2739. "TARGET_CFV4"
  2740. "mvz%.w %1,%0")
  2741. +;; (TIGCC 20050210) We need to mark the register operand as earlyclobber in the
  2742. +;; case of memory operands to avoid having to split (see
  2743. +;; reg_mentioned_p below) things.
  2744. (define_insn "zero_extendhisi2"
  2745. - [(set (match_operand:SI 0 "register_operand" "=d")
  2746. - (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
  2747. + [(set (match_operand:SI 0 "register_operand" "=d,&d")
  2748. + (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "r,mS")))]
  2749. ""
  2750. "#")
  2751. @@ -1258,8 +1406,8 @@
  2752. "mvz%.b %1,%0")
  2753. (define_insn "zero_extendqisi2"
  2754. - [(set (match_operand:SI 0 "register_operand" "=d")
  2755. - (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
  2756. + [(set (match_operand:SI 0 "register_operand" "=d,&d")
  2757. + (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "d,mS")))]
  2758. ""
  2759. "#")
  2760. @@ -4135,7 +4283,11 @@
  2761. output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
  2762. "moveq %2,%1\;asr%.l %1,%0", operands);
  2763. output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
  2764. - return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
  2765. +/* (TIGCC 20040222) The %d0 here was a typo or thinko. It means 'force absolute
  2766. + addressing' in this context, not 'data register'. This
  2767. + doesn't make sense in a context where only data registers
  2768. + are allowed, so I removed it. -- Kevin Kofler */
  2769. + return INTVAL (operands[2]) >= 15 ? "ext%.w %0" :
  2770. TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
  2771. }
  2772. })
  2773. @@ -6320,10 +6472,19 @@
  2774. return "rtd %0";
  2775. })
  2776. +;; (TIGCC 20040222) Use jra instead of jmp here. Also don't add (%pc) under
  2777. +;; -mpcrel. Moreover, we need to handle extended address
  2778. +;; operands here. -- Kevin Kofler
  2779. +;; (TIGCC 20050204) Use plain bra for labels under -mpcrel to guarantee PC-rel
  2780. +;; code.
  2781. (define_insn "indirect_jump"
  2782. - [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
  2783. + [(set (pc) (match_operand:SI 0 "extended_address_operand" "p"))]
  2784. ""
  2785. - "jmp %a0")
  2786. +{
  2787. + return (TARGET_PCREL && GET_CODE (operands[0]) == MEM
  2788. + && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)?
  2789. + "bra %A0":"jra %A0";
  2790. +})
  2791. ;; This should not be used unless the add/sub insns can't be.
  2792. @@ -6417,6 +6578,9 @@
  2793. })
  2794. ;; Speed up stack adjust followed by a fullword fixedpoint push.
  2795. +;; (TIGCC 20050211) Don't do this if pushing an immediate operand in range for
  2796. +;; a pea, and a stack adjust is needed anyway. That would
  2797. +;; generate bigger (or same size) and slower code.
  2798. (define_peephole
  2799. [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
  2800. @@ -6424,7 +6588,8 @@
  2801. (set (match_operand:SI 1 "push_operand" "=m")
  2802. (match_operand:SI 2 "general_operand" "g"))]
  2803. "INTVAL (operands[0]) >= 4
  2804. - && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
  2805. + && ! reg_mentioned_p (stack_pointer_rtx, operands[2])
  2806. + && !(INTVAL (operands[0]) > 4 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) && INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) < 0x8000)"
  2807. {
  2808. if (INTVAL (operands[0]) > 4)
  2809. {
  2810. @@ -6460,6 +6625,77 @@
  2811. return "move%.l %2,%@";
  2812. })
  2813. +;; (TIGCC 20050207) Bundle 2 immediate word pushes to the stack into 1 immediate
  2814. +;; longword push.
  2815. +
  2816. +(define_peephole
  2817. + [(set (match_operand:HI 0 "push_operand" "=m")
  2818. + (match_operand:HI 1 "const_int_operand" "n"))
  2819. + (set (match_operand:HI 2 "push_operand" "=m")
  2820. + (match_operand:HI 3 "const_int_operand" "n"))]
  2821. + ""
  2822. +{
  2823. + rtx xoperands[2];
  2824. + xoperands[0] = operands[0];
  2825. + xoperands[1] = GEN_INT ((INTVAL (operands[1]) & 0xFFFF) + (INTVAL (operands[3]) << 16));
  2826. + output_asm_insn (output_move_simode_const (xoperands), xoperands);
  2827. + CC_STATUS_INIT; /* We clobbered the CC. */
  2828. + return "";
  2829. +})
  2830. +
  2831. +;; (TIGCC 20050210) Same as above, but with a stack adjust.
  2832. +
  2833. +(define_peephole
  2834. + [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
  2835. + (match_operand:SI 0 "const_int_operand" "n")))
  2836. + (set (mem:HI (reg:SI SP_REG))
  2837. + (match_operand:HI 1 "const_int_operand" "n"))
  2838. + (set (match_operand:HI 2 "push_operand" "=m")
  2839. + (match_operand:HI 3 "const_int_operand" "n"))]
  2840. + "INTVAL (operands[0]) >= 2"
  2841. +{
  2842. + HOST_WIDE_INT longword = (INTVAL (operands[1]) & 0xFFFF) + (INTVAL (operands[3]) << 16);
  2843. + bool usepea = longword && longword < 0x8000 && longword >= -0x8000
  2844. + && INTVAL (operands[0]) > 2;
  2845. + rtx xoperands[2];
  2846. + if (INTVAL (operands[0]) > 2)
  2847. + {
  2848. + xoperands[0] = stack_pointer_rtx;
  2849. + xoperands[1] = GEN_INT (INTVAL (operands[0]) + (usepea?2:-2));
  2850. + if (INTVAL (xoperands[1]) <= 8)
  2851. + {
  2852. + if (!TARGET_COLDFIRE)
  2853. + output_asm_insn ("addq%.w %1,%0", xoperands);
  2854. + else
  2855. + output_asm_insn ("addq%.l %1,%0", xoperands);
  2856. + }
  2857. + else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
  2858. + {
  2859. + xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
  2860. + output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
  2861. + }
  2862. + else if (INTVAL (xoperands[1]) <= 0x7FFF)
  2863. + {
  2864. + if (TARGET_68040)
  2865. + output_asm_insn ("add%.w %1,%0", xoperands);
  2866. + else if (MOTOROLA)
  2867. + output_asm_insn ("lea (%c1,%0),%0", xoperands);
  2868. + else
  2869. + output_asm_insn ("lea %0@(%c1),%0", xoperands);
  2870. + }
  2871. + else
  2872. + output_asm_insn ("add%.l %1,%0", xoperands);
  2873. + }
  2874. + if (usepea)
  2875. + xoperands[0] = operands[2];
  2876. + else
  2877. + xoperands[0] = gen_rtx_MEM (SImode, stack_pointer_rtx);
  2878. + xoperands[1] = GEN_INT (longword);
  2879. + output_asm_insn (output_move_simode_const (xoperands), xoperands);
  2880. + CC_STATUS_INIT; /* We clobbered the CC. */
  2881. + return "";
  2882. +})
  2883. +
  2884. ;; Speed up pushing a single byte but leaving four bytes of space.
  2885. (define_peephole
  2886. @@ -7092,3 +7328,166 @@
  2887. default: gcc_unreachable ();
  2888. }
  2889. })
  2890. +
  2891. +;; (TIGCC 20050210) Optimize lea (4,%an),%am; move.l foo,-(%am) into
  2892. +;; move.l %an,%am; move.l foo,(%an)
  2893. +;; (TIGCC 20050211) Don't do this if foo is an immediate operand in range for
  2894. +;; a moveq (because the movsi insn won't like that).
  2895. +(define_peephole2
  2896. + [(set (match_operand:SI 0 "register_operand" "")
  2897. + (plus:SI (match_operand:SI 1 "register_operand" "")
  2898. + (const_int 4)))
  2899. + (set (mem:SI (pre_dec:SI (match_dup 0)))
  2900. + (match_operand:SI 2 "general_operand" ""))]
  2901. + "REG_P(operands[1]) && (REGNO (operands[1]) ^ 010) < 8 && ! reg_mentioned_p (operands[0], operands[2]) && !(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) && INTVAL (operands[2]) >= -128 && INTVAL (operands[2]) < 128)"
  2902. + [(set (match_dup 0) (match_dup 1))
  2903. + (set (mem:SI (match_dup 1)) (match_dup 2))]
  2904. + "")
  2905. +
  2906. +;; (TIGCC 20050211) Optimize lea (4,%an),%am; move.l #foo,-(%am), foo!=0,
  2907. +;; -128<=foo<128 into moveq.l #foo,%dx; move.l %an,%am;
  2908. +;; move.l %dx,(%an) if we have a free data register to do that.
  2909. +(define_peephole2
  2910. + [(match_scratch:SI 0 "d")
  2911. + (set (match_operand:SI 1 "register_operand" "")
  2912. + (plus:SI (match_operand:SI 2 "register_operand" "")
  2913. + (const_int 4)))
  2914. + (match_dup 0)
  2915. + (set (mem:SI (pre_dec:SI (match_dup 1)))
  2916. + (match_operand:SI 3 "const_int_operand" ""))]
  2917. + "REG_P(operands[2]) && (REGNO (operands[2]) ^ 010) < 8 && INTVAL (operands[3]) && INTVAL (operands[3]) >= -128 && INTVAL (operands[3]) < 128"
  2918. + [(set (match_dup 0) (match_dup 3))
  2919. + (set (match_dup 1) (match_dup 2))
  2920. + (set (mem:SI (match_dup 2)) (match_dup 0))]
  2921. + "")
  2922. +
  2923. +;; (TIGCC 20050210) Optimize lea (2,%an),%am; move.w foo,-(%am) into
  2924. +;; move.l %an,%am; move.w foo,(%an)
  2925. +(define_peephole2
  2926. + [(set (match_operand:SI 0 "register_operand" "")
  2927. + (plus:SI (match_operand:SI 1 "register_operand" "")
  2928. + (const_int 2)))
  2929. + (set (mem:HI (pre_dec:SI (match_dup 0)))
  2930. + (match_operand:HI 2 "general_operand" ""))]
  2931. + "REG_P(operands[1]) && (REGNO (operands[1]) ^ 010) < 8 && ! reg_mentioned_p (operands[0], operands[2])"
  2932. + [(set (match_dup 0) (match_dup 1))
  2933. + (set (mem:HI (match_dup 1)) (match_dup 2))]
  2934. + "")
  2935. +
  2936. +;; (TIGCC 20050210) Optimize lea (1,%an),%am; move.w foo,-(%am), m!=7 into
  2937. +;; move.l %an,%am; move.b foo,(%an)
  2938. +(define_peephole2
  2939. + [(set (match_operand:SI 0 "register_operand" "")
  2940. + (plus:SI (match_operand:SI 1 "register_operand" "")
  2941. + (const_int 1)))
  2942. + (set (mem:QI (pre_dec:SI (match_dup 0)))
  2943. + (match_operand:QI 2 "general_operand" ""))]
  2944. + "REG_P(operands[1]) && (REGNO (operands[1]) ^ 010) < 8 && !(REG_P(operands[0]) && REGNO (operands[0]) == STACK_POINTER_REGNUM) && ! reg_mentioned_p (operands[0], operands[2])"
  2945. + [(set (match_dup 0) (match_dup 1))
  2946. + (set (mem:QI (match_dup 1)) (match_dup 2))]
  2947. + "")
  2948. +
  2949. +;; (TIGCC 20050210) Optimize lea (x,%an),%am; move.l foo,-(%am), x!=4,
  2950. +;; x>=-0x7ffc into lea (x-4,%an),%am; move.l foo,(%am)
  2951. +;; (TIGCC 20050211) Don't do this if foo is an immediate operand in range for
  2952. +;; a pea (especially not if in range for a moveq, because the
  2953. +;; movsi insn won't like that).
  2954. +(define_peephole2
  2955. + [(set (match_operand:SI 0 "register_operand" "")
  2956. + (plus:SI (match_operand:SI 1 "register_operand" "")
  2957. + (match_operand:SI 2 "const_int_operand" "")))
  2958. + (set (mem:SI (pre_dec:SI (match_dup 0)))
  2959. + (match_operand:SI 3 "general_operand" ""))]
  2960. + "REG_P(operands[1]) && (REGNO (operands[1]) ^ 010) < 8 && ! reg_mentioned_p (operands[0], operands[3]) && INTVAL (operands[2]) != 4 && INTVAL (operands[2]) >= -0x7ffc && !(GET_CODE (operands[3]) == CONST_INT && INTVAL (operands[3]) && INTVAL (operands[3]) >= -0x8000 && INTVAL (operands[3]) < 0x8000)"
  2961. + [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
  2962. + (set (mem:SI (match_dup 0)) (match_dup 3))]
  2963. + "operands[2] = GEN_INT (INTVAL (operands[2]) - 4);")
  2964. +
  2965. +;; (TIGCC 20050210) Optimize lea (x,%an),%am; move.w foo,-(%am), m!=7, x!=2,
  2966. +;; x>=-0x7ffe into lea (x-2,%an),%am; move.w foo,(%am)
  2967. +(define_peephole2
  2968. + [(set (match_operand:SI 0 "register_operand" "")
  2969. + (plus:SI (match_operand:SI 1 "register_operand" "")
  2970. + (match_operand:SI 2 "const_int_operand" "")))
  2971. + (set (mem:HI (pre_dec:SI (match_dup 0)))
  2972. + (match_operand:HI 3 "general_operand" ""))]
  2973. + "REG_P(operands[1]) && (REGNO (operands[1]) ^ 010) < 8 && ! reg_mentioned_p (operands[0], operands[3]) && INTVAL (operands[2]) != 2 && INTVAL (operands[2]) >= -0x7ffe"
  2974. + [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
  2975. + (set (mem:HI (match_dup 0)) (match_dup 3))]
  2976. + "operands[2] = GEN_INT (INTVAL (operands[2]) - 2);")
  2977. +
  2978. +;; (TIGCC 20050210) Optimize lea (x,%an),%am; move.b foo,-(%am), m!=7, x!=1,
  2979. +;; x>=-0x7fff into lea (x-1,%an),%am; move.b foo,(%am)
  2980. +(define_peephole2
  2981. + [(set (match_operand:SI 0 "register_operand" "")
  2982. + (plus:SI (match_operand:SI 1 "register_operand" "")
  2983. + (match_operand:SI 2 "const_int_operand" "")))
  2984. + (set (mem:QI (pre_dec:SI (match_dup 0)))
  2985. + (match_operand:QI 3 "general_operand" ""))]
  2986. + "REG_P(operands[1]) && (REGNO (operands[1]) ^ 010) < 8 && !(REG_P(operands[0]) && REGNO (operands[0]) == STACK_POINTER_REGNUM) && ! reg_mentioned_p (operands[0], operands[3]) && INTVAL (operands[2]) != 1 && INTVAL (operands[2]) >= -0x7fff"
  2987. + [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
  2988. + (set (mem:QI (match_dup 0)) (match_dup 3))]
  2989. + "operands[2] = GEN_INT (INTVAL (operands[2]) - 1);")
  2990. +
  2991. +;; (TIGCC 20050213) Optimize and #const1,%dn; and #const2,%dn (generated by
  2992. +;; zero_extend) into and #const1&const2,%dn
  2993. +
  2994. +(define_peephole2
  2995. + [(set (match_operand:SI 0 "register_operand" "")
  2996. + (and:SI (match_dup 0)
  2997. + (match_operand:SI 1 "const_int_operand" "")))
  2998. + (set (match_dup 0)
  2999. + (and:SI (match_dup 0)
  3000. + (match_operand:SI 2 "const_int_operand" "")))]
  3001. + ""
  3002. + [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))]
  3003. + "operands[1] = GEN_INT (INTVAL (operands[1]) & INTVAL (operands[2]));")
  3004. +
  3005. +(define_peephole2
  3006. + [(set (match_operand:HI 0 "register_operand" "")
  3007. + (and:HI (match_dup 0)
  3008. + (match_operand:HI 1 "const_int_operand" "")))
  3009. + (set (match_dup 0)
  3010. + (and:HI (match_dup 0)
  3011. + (match_operand:HI 2 "const_int_operand" "")))]
  3012. + ""
  3013. + [(set (match_dup 0) (and:HI (match_dup 0) (match_dup 1)))]
  3014. + "operands[1] = GEN_INT (INTVAL (operands[1]) & INTVAL (operands[2]));")
  3015. +
  3016. +(define_peephole2
  3017. + [(set (match_operand:QI 0 "register_operand" "")
  3018. + (and:QI (match_dup 0)
  3019. + (match_operand:QI 1 "const_int_operand" "")))
  3020. + (set (match_dup 0)
  3021. + (and:QI (match_dup 0)
  3022. + (match_operand:QI 2 "const_int_operand" "")))]
  3023. + ""
  3024. + [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
  3025. + "operands[1] = GEN_INT (INTVAL (operands[1]) & INTVAL (operands[2]));")
  3026. +
  3027. +;; (TIGCC 20050213) Optimize and.l #65535,%dn; clr.w %dn (generated by
  3028. +;; zero_extend) into moveq #0,%dn
  3029. +
  3030. +(define_peephole2
  3031. + [(set (match_operand:SI 0 "register_operand" "")
  3032. + (and:SI (match_dup 0)
  3033. + (const_int 65535)))
  3034. + (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
  3035. + (const_int 0))]
  3036. + "REG_P(operands[0]) && REG_P(operands[1]) && REGNO(operands[0]) == REGNO(operands[1])"
  3037. + [(set (match_dup 0) (const_int 0))]
  3038. + "")
  3039. +
  3040. +;; (TIGCC 20050213) Optimize and.w #255,%dn; clr.b %dn (generated by
  3041. +;; zero_extend) into clr.w %dn
  3042. +
  3043. +(define_peephole2
  3044. + [(set (match_operand:HI 0 "register_operand" "")
  3045. + (and:HI (match_dup 0)
  3046. + (const_int 255)))
  3047. + (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
  3048. + (const_int 0))]
  3049. + "REG_P(operands[0]) && REG_P(operands[1]) && REGNO(operands[0]) == REGNO(operands[1])"
  3050. + [(set (strict_low_part (match_dup 0)) (const_int 0))]
  3051. + "")
  3052. +
  3053. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k-modes.def gcc-4.1.2-src/gcc/config/m68k/m68k-modes.def
  3054. --- gcc-4.1.2.orig/gcc/config/m68k/m68k-modes.def 2005-06-25 03:22:41.000000000 +0200
  3055. +++ gcc-4.1.2-src/gcc/config/m68k/m68k-modes.def 2007-02-19 02:32:34.000000000 +0100
  3056. @@ -18,5 +18,6 @@
  3057. the Free Software Foundation, 51 Franklin Street, Fifth Floor,
  3058. Boston, MA 02110-1301, USA. */
  3059. -/* 80-bit floating point (IEEE extended, in a 96-bit field) */
  3060. -FRACTIONAL_FLOAT_MODE (XF, 80, 12, ieee_extended_motorola_format);
  3061. +FLOAT_MODE (BF, 10, 0);
  3062. +FLOAT_MODE (XF, 12, 0);
  3063. +
  3064. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k-none.h gcc-4.1.2-src/gcc/config/m68k/m68k-none.h
  3065. --- gcc-4.1.2.orig/gcc/config/m68k/m68k-none.h 2005-06-25 03:22:41.000000000 +0200
  3066. +++ gcc-4.1.2-src/gcc/config/m68k/m68k-none.h 2007-02-19 02:32:34.000000000 +0100
  3067. @@ -18,10 +18,12 @@
  3068. the Free Software Foundation, 51 Franklin Street, Fifth Floor,
  3069. Boston, MA 02110-1301, USA. */
  3070. -/* Default to m68k (m68020). */
  3071. -#ifndef TARGET_CPU_DEFAULT
  3072. -#define TARGET_CPU_DEFAULT M68K_CPU_m68k
  3073. -#endif
  3074. +/* Define the appropriate flags for the TI's architecture */
  3075. +#undef TARGET_CPU_DEFAULT
  3076. +#define TARGET_CPU_DEFAULT M68K_CPU_m68000
  3077. +
  3078. +#undef TARGET_DEFAULT
  3079. +#define TARGET_DEFAULT ((TARGET_CPU_DEFAULT >> 4) | MASK_SHORT | MASK_TIOS | MASK_MERGE_SECTIONS)
  3080. /* These are values set by the configure script in TARGET_CPU_DEFAULT.
  3081. They are (sequential integer + (desired value for TARGET_DEFAULT) << 4). */
  3082. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k.opt gcc-4.1.2-src/gcc/config/m68k/m68k.opt
  3083. --- gcc-4.1.2.orig/gcc/config/m68k/m68k.opt 2005-06-25 03:22:41.000000000 +0200
  3084. +++ gcc-4.1.2-src/gcc/config/m68k/m68k.opt 2007-02-19 02:32:34.000000000 +0100
  3085. @@ -92,6 +92,10 @@
  3086. Target Report RejectNegative Mask(BITFIELD)
  3087. Use the bit-field instructions
  3088. +mbss
  3089. +Target Report InverseMask(NO_BSS)
  3090. +Output common/lcomm (BSS) symbols for uninitialized data
  3091. +
  3092. mc68000
  3093. Target RejectNegative
  3094. Generate code for a 68000
  3095. @@ -100,6 +104,10 @@
  3096. Target RejectNegative
  3097. Generate code for a 68020
  3098. +mcoff-abslines
  3099. +Target Report Mask(COFFABSLINES)
  3100. +Use absolute line numbers for COFF debugging
  3101. +
  3102. mcpu32
  3103. Target RejectNegative
  3104. Generate code for a cpu32
  3105. @@ -108,10 +116,30 @@
  3106. Target Report Mask(ID_SHARED_LIBRARY)
  3107. Enable ID based shared library
  3108. +mlong
  3109. +Target InverseMask(SHORT)
  3110. +Consider type 'int' to be 32 bits wide
  3111. +
  3112. +mmerge-sections
  3113. +Target Report Mask(MERGE_SECTIONS)
  3114. +Merge the .text and .data sections
  3115. +
  3116. +mmerge-to-data
  3117. +Target Report Mask(MERGE_TO_DATA)
  3118. +When merging sections, merge to .data rather than to .text
  3119. +
  3120. mnobitfield
  3121. Target RejectNegative InverseMask(BITFIELD)
  3122. Do not use the bit-field instructions
  3123. +mnobss
  3124. +Target Report Mask(NO_BSS)
  3125. +Don't output common/lcomm (BSS) symbols for uninitialized data
  3126. +
  3127. +mnolong
  3128. +Target Report RejectNegative Mask(SHORT) MaskExists
  3129. +Consider type 'int' to be 16 bits wide
  3130. +
  3131. mnortd
  3132. Target RejectNegative InverseMask(RTD)
  3133. Use normal calling convention
  3134. @@ -124,6 +152,18 @@
  3135. Target Report Mask(PCREL)
  3136. Generate pc-relative code
  3137. +mregparm
  3138. +Target Report Mask(REGPARM)
  3139. +Allow passing by registers
  3140. +
  3141. +mregparm=
  3142. +Target Report Joined Var(m68k_regparm_string)
  3143. +Number of register parameters of each register type
  3144. +
  3145. +mrodata-to-text
  3146. +Target Report Mask(RODATA_TO_TEXT)
  3147. +When not merging sections, put read-only data into .text rather than .data
  3148. +
  3149. mrtd
  3150. Target Report RejectNegative Mask(RTD)
  3151. Use different calling convention using 'rtd'
  3152. @@ -137,7 +177,7 @@
  3153. ID of shared library to build
  3154. mshort
  3155. -Target Report RejectNegative Mask(SHORT)
  3156. +Target Report Mask(SHORT)
  3157. Consider type 'int' to be 16 bits wide
  3158. msoft-float
  3159. @@ -147,3 +187,7 @@
  3160. mstrict-align
  3161. Target Report Mask(STRICT_ALIGNMENT)
  3162. Do not use unaligned memory references
  3163. +
  3164. +mtios
  3165. +Target Report Mask(TIOS)
  3166. +Enable TIOS interoperability
  3167. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k-protos.h gcc-4.1.2-src/gcc/config/m68k/m68k-protos.h
  3168. --- gcc-4.1.2.orig/gcc/config/m68k/m68k-protos.h 2005-07-12 01:32:01.000000000 +0200
  3169. +++ gcc-4.1.2-src/gcc/config/m68k/m68k-protos.h 2007-02-19 02:32:34.000000000 +0100
  3170. @@ -44,6 +44,13 @@
  3171. extern int floating_exact_log2 (rtx);
  3172. extern bool strict_low_part_peephole_ok (enum machine_mode mode, rtx first_insn, rtx target);
  3173. +/* begin-TIGCC-local (regparms): explicit register specification for parameters */
  3174. +void amigaos_init_cumulative_args(struct m68k_args *, tree, tree);
  3175. +void amigaos_function_arg_advance(struct m68k_args *);
  3176. +struct rtx_def *amigaos_function_arg(struct m68k_args *, enum machine_mode, tree);
  3177. +/* end-TIGCC-local (regparms) */
  3178. +void m68k_asm_file_start(void);
  3179. +
  3180. /* Functions from m68k.c used in macros. */
  3181. extern int standard_68881_constant_p (rtx);
  3182. extern void print_operand_address (FILE *, rtx);
  3183. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/m68k-ti.h gcc-4.1.2-src/gcc/config/m68k/m68k-ti.h
  3184. --- gcc-4.1.2.orig/gcc/config/m68k/m68k-ti.h 1970-01-01 01:00:00.000000000 +0100
  3185. +++ gcc-4.1.2-src/gcc/config/m68k/m68k-ti.h 2007-02-19 02:32:34.000000000 +0100
  3186. @@ -0,0 +1,215 @@
  3187. +/* Definitions of target machine for GNU compiler.
  3188. + TI-68k architecture (68000),
  3189. + COFF object files and debugging version.
  3190. + Derived in part from m68kemb.h and other files.
  3191. + Copyright (C) 1994 Free Software Foundation, Inc.
  3192. + Copyright (C) 2000 mmu_man (François Revol)
  3193. + (Modified by Sebastian Reichelt for the Windows release of TIGCC)
  3194. +
  3195. +This file is part of TIGCC.
  3196. +
  3197. +GNU CC is free software; you can redistribute it and/or modify
  3198. +it under the terms of the GNU General Public License as published by
  3199. +the Free Software Foundation; either version 2, or (at your option)
  3200. +any later version.
  3201. +
  3202. +GNU CC is distributed in the hope that it will be useful,
  3203. +but WITHOUT ANY WARRANTY; without even the implied warranty of
  3204. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3205. +GNU General Public License for more details.
  3206. +
  3207. +You should have received a copy of the GNU General Public License
  3208. +along with GNU CC; see the file COPYING. If not, write to
  3209. +the Free Software Foundation, 59 Temple Place - Suite 330,
  3210. +Boston, MA 02111-1307, USA. */
  3211. +
  3212. +/* Define the output of the target version */
  3213. +
  3214. +#undef TARGET_VERSION
  3215. +#define TARGET_VERSION fprintf (stderr, " (MC68000 TI with COFF output)");
  3216. +
  3217. +/* Even if we compile with -mlong, we want only 16-bit alignment. */
  3218. +
  3219. +#undef PARM_BOUNDARY
  3220. +#define PARM_BOUNDARY 16
  3221. +
  3222. +/* Don't default to pcc-struct-return, so that we can return small
  3223. + structures and unions in registers, which is slightly more
  3224. + efficient. There are probably no TIOS routines returning structs;
  3225. + if there are, the appropriate program will have to be compiled
  3226. + with the "-fpcc-struct-return" option. But that option will cause
  3227. + problems with ROM_CALLs returning a HSym, which is defined as a
  3228. + structure in TIGCC. */
  3229. +
  3230. +#undef DEFAULT_PCC_STRUCT_RETURN
  3231. +#define DEFAULT_PCC_STRUCT_RETURN 0
  3232. +
  3233. +/* In order for bitfields to work on a 68000, or with -mnobitfield, we must
  3234. + define either PCC_BITFIELD_TYPE_MATTERS or STRUCTURE_SIZE_BOUNDARY.
  3235. + Defining STRUCTURE_SIZE_BOUNDARY results in structure packing problems,
  3236. + so we define PCC_BITFIELD_TYPE_MATTERS. */
  3237. +
  3238. +#define PCC_BITFIELD_TYPE_MATTERS 1
  3239. +
  3240. +/* Undefine PCC_STATIC_STRUCT_RETURN so that we get a re-entrant
  3241. + calling convention (whatever that means). */
  3242. +
  3243. +#undef PCC_STATIC_STRUCT_RETURN
  3244. +
  3245. +/* Define how to generate (in the callee) the output value of a
  3246. + function and how to find (in the caller) the value returned by a
  3247. + function. VALTYPE is the data type of the value (as a tree). If
  3248. + the precise function being called is known, FUNC is its
  3249. + FUNCTION_DECL; otherwise, FUNC is 0. When calling TIOS functions,
  3250. + find the result in d0 or a0 as appropriate. */
  3251. +
  3252. +#undef FUNCTION_VALUE
  3253. +#define FUNCTION_VALUE(VALTYPE, FUNC) \
  3254. + (((TARGET_TIOS) && (POINTER_TYPE_P (VALTYPE))) \
  3255. + ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8) \
  3256. + : LIBCALL_VALUE (TYPE_MODE (VALTYPE)))
  3257. +
  3258. +/* Define how to find a library call return value. Usually the value will be
  3259. + in d0 (thru d1 or d2), but floats should be assumed to be returned in a
  3260. + stack frame. This happens automatically if the specified register (d1 in
  3261. + this case) is not a possible register for returning the value, because
  3262. + floats take up 3 registers. Never use direct floats if d3 is clobbered
  3263. + by function calls. */
  3264. +
  3265. +#undef LIBCALL_VALUE
  3266. +#define LIBCALL_VALUE(MODE) \
  3267. + (((TARGET_DIRECTFLOAT) && ((MODE) == BFmode)) \
  3268. + ? gen_rtx_REG (MODE, 1) \
  3269. + : gen_rtx_REG (MODE, 0))
  3270. +
  3271. +/* 1 if N is a possible register number for a function value. For
  3272. + calling TIOS functions, allow a0 in addition to d0 (see above). */
  3273. +
  3274. +#undef FUNCTION_VALUE_REGNO_P
  3275. +#define FUNCTION_VALUE_REGNO_P(N) \
  3276. + (((N) == 0) || (TARGET_TIOS && ((N) == 8)) || (TARGET_DIRECTFLOAT && ((N) == 1)))
  3277. +
  3278. +/* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
  3279. + more than one register (see above). */
  3280. +
  3281. +#undef NEEDS_UNTYPED_CALL
  3282. +#define NEEDS_UNTYPED_CALL (TARGET_TIOS || TARGET_DIRECTFLOAT)
  3283. +
  3284. +/* This says how to output an assembler line
  3285. + to define a global common symbol. */
  3286. +
  3287. +#undef ASM_OUTPUT_COMMON
  3288. +#define ASM_OUTPUT_COMMON(FILE,NAME,SIZE,ROUNDED) \
  3289. +do { \
  3290. + if (TARGET_NO_BSS && ((NAME) [0] != '_')) \
  3291. + { \
  3292. + long i; \
  3293. + data_section (); \
  3294. + fputs (".globl ", (FILE)); \
  3295. + assemble_name ((FILE), (NAME)); \
  3296. + fputs ("\n\t.even\n", (FILE)); \
  3297. + assemble_name ((FILE), (NAME)); \
  3298. + fputs (":\n", (FILE)); \
  3299. + fprintf ((FILE), "\t.space %u\n", (unsigned)(ROUNDED)); \
  3300. + fputs ("\t.even\n", (FILE)); \
  3301. + } \
  3302. + else \
  3303. + { \
  3304. + fputs (".comm ", (FILE)); \
  3305. + assemble_name ((FILE), (NAME)); \
  3306. + fprintf ((FILE), ",%u\n", (unsigned)(ROUNDED)); \
  3307. + } \
  3308. +} while (0)
  3309. +
  3310. +/* This says how to output an assembler line
  3311. + to define a local common symbol. */
  3312. +
  3313. +#undef ASM_OUTPUT_LOCAL
  3314. +#define ASM_OUTPUT_LOCAL(FILE,NAME,SIZE,ROUNDED) \
  3315. +do { \
  3316. + if (TARGET_NO_BSS) \
  3317. + { \
  3318. + long i; \
  3319. + data_section (); \
  3320. + fputs ("\t.even\n", (FILE)); \
  3321. + assemble_name ((FILE), (NAME)); \
  3322. + fputs (":\n", (FILE)); \
  3323. + fprintf ((FILE), "\t.space %u\n", (unsigned)(ROUNDED)); \
  3324. + fputs ("\t.even\n", (FILE)); \
  3325. + } \
  3326. + else \
  3327. + { \
  3328. + fputs (".lcomm ", (FILE)); \
  3329. + assemble_name ((FILE), (NAME)); \
  3330. + fprintf ((FILE), ",%u\n", (unsigned)(ROUNDED)); \
  3331. + } \
  3332. +} while (0)
  3333. +
  3334. +/* If TARGET_MERGE_SECTIONS is set (on by default): if TARGET_MERGE_TO_DATA is
  3335. + set, only use data sections, otherwise only use text sections. Both code and
  3336. + data in RAM programs on a TI-89/92+/V200 are always writable; that's why it
  3337. + does not make sense to have different data and text sections.
  3338. + Those cannot be set to an empty string, since a number may follow, etc.
  3339. + Anyway, better more than less. */
  3340. +
  3341. +#undef TEXT_SECTION_ASM_OP
  3342. +#define TEXT_SECTION_ASM_OP ((TARGET_MERGE_SECTIONS && TARGET_MERGE_TO_DATA)? \
  3343. + "\t.data":"\t.text")
  3344. +
  3345. +#undef DATA_SECTION_ASM_OP
  3346. +#define DATA_SECTION_ASM_OP ((TARGET_MERGE_SECTIONS && !TARGET_MERGE_TO_DATA)? \
  3347. + "\t.text":"\t.data")
  3348. +
  3349. +/* If TARGET_NO_BSS is set (off by default), use the data section here.
  3350. + Otherwise use the BSS section. */
  3351. +
  3352. +#undef BSS_SECTION_ASM_OP
  3353. +#define BSS_SECTION_ASM_OP (TARGET_NO_BSS?DATA_SECTION_ASM_OP:"\t.section .bss")
  3354. +
  3355. +/* When not merging sections, put read-only data into .data unless
  3356. + TARGET_RODATA_TO_TEXT is set. But jump tables do NOT qualify for going into
  3357. + the data section! */
  3358. +#define READONLY_DATA_SECTION() (TARGET_RODATA_TO_TEXT ? text_section() \
  3359. + : data_section())
  3360. +#define JUMP_TABLES_IN_TEXT_SECTION 1
  3361. +
  3362. +/* Define "__INT_SHORT__" if short ints are set, e.g. if the "-mlong" switch
  3363. + is not used. This is necessary for the TIGCC Library, since INT_MAX and
  3364. + others need to be constants. */
  3365. +
  3366. +#undef CPP_SUBTARGET_SPEC
  3367. +#if (defined(__CYGWIN__) || defined(__WIN32__))
  3368. +#define CPP_SUBTARGET_SPEC "-D__TIGCC_ENV__ -D__TIGCC_WIN_ENV__ %{!mlong:%{!mnoshort:%{!mno-short:-D__INT_SHORT__ }}}"
  3369. +#else
  3370. +#define CPP_SUBTARGET_SPEC "-D__TIGCC_ENV__ %{!mlong:%{!mnoshort:%{!mno-short:-D__INT_SHORT__ }}}"
  3371. +#endif
  3372. +#undef CPP_SPEC
  3373. +#define CPP_SPEC CPP_SUBTARGET_SPEC
  3374. +
  3375. +/* Trampolines are code on the stack, so we need to add 0x40000 to their address
  3376. + for it to work on a TI-89/92+/V200 HW2. On HW3, we should NOT add that
  3377. + address. Moreover, EXECUTE_IN_GHOST_SPACE is required for it to work
  3378. + correctly. Therefore, I am emitting a libcall and letting TIGCCLIB worry
  3379. + about the details.
  3380. + (code partially lifted from gcc/config/sh/sh.h) */
  3381. +#define TRAMPOLINE_ADJUST_ADDRESS(TRAMP) do \
  3382. +{ \
  3383. + (TRAMP) = expand_simple_binop (Pmode, PLUS, (TRAMP), \
  3384. + emit_library_call_value (gen_rtx_SYMBOL_REF (\
  3385. + Pmode, \
  3386. + "__trampoline_offset"), \
  3387. + NULL_RTX, LCT_CONST, \
  3388. + Pmode, 0), \
  3389. + gen_reg_rtx (Pmode), 0, \
  3390. + OPTAB_LIB_WIDEN); \
  3391. +} while (0)
  3392. +
  3393. +/* We want -fomit-frame-pointer by default. */
  3394. +#define CAN_DEBUG_WITHOUT_FP
  3395. +
  3396. +/* We want DWARF2 debugging and unwinding information */
  3397. +#define DWARF2_DEBUGGING_INFO 1
  3398. +#define DWARF2_ASM_LINE_DEBUG_INFO 1
  3399. +#define DWARF2_UNWIND_INFO 1
  3400. +
  3401. +/* end of m68k-ti.h */
  3402. diff -Naur gcc-4.1.2.orig/gcc/config/m68k/predicates.md gcc-4.1.2-src/gcc/config/m68k/predicates.md
  3403. --- gcc-4.1.2.orig/gcc/config/m68k/predicates.md 2005-06-25 03:22:41.000000000 +0200
  3404. +++ gcc-4.1.2-src/gcc/config/m68k/predicates.md 2007-02-19 02:32:34.000000000 +0100
  3405. @@ -88,7 +88,7 @@
  3406. ;; hosted on 64-bit machines.
  3407. (define_predicate "const_uint32_operand"
  3408. - (match_code "const_int,const_double")
  3409. + (match_code "const_int")
  3410. {
  3411. /* It doesn't make sense to ask this question with a mode that is
  3412. not larger than 32 bits. */
  3413. @@ -101,7 +101,7 @@
  3414. && (INTVAL (op) >= 0 && INTVAL (op) <= 0xffffffffL));
  3415. #else
  3416. return (GET_CODE (op) == CONST_INT
  3417. - || (GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_HIGH (op) == 0));
  3418. + && INTVAL (op) >= 0);
  3419. #endif
  3420. })
  3421. @@ -194,3 +194,13 @@
  3422. {
  3423. return MEM_P (op) && GET_CODE (XEXP (op, 0)) == PRE_DEC;
  3424. })
  3425. +
  3426. +;; (TIGCC 20040222) This predicate is used to allow straight labels in the
  3427. +;; indirect_jump pattern. -- Kevin Kofler
  3428. +(define_predicate "extended_address_operand"
  3429. + (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem,plus,minus,mult")
  3430. +{
  3431. + if (TARGET_PCREL && CONSTANT_ADDRESS_P (op))
  3432. + return 1;
  3433. + return address_operand (op, mode);
  3434. +})
  3435. diff -Naur gcc-4.1.2.orig/gcc/config/smapbcd.h gcc-4.1.2-src/gcc/config/smapbcd.h
  3436. --- gcc-4.1.2.orig/gcc/config/smapbcd.h 1970-01-01 01:00:00.000000000 +0100
  3437. +++ gcc-4.1.2-src/gcc/config/smapbcd.h 2007-02-19 02:32:34.000000000 +0100
  3438. @@ -0,0 +1,369 @@
  3439. +/* Definitions for SMAP II BCD support in the GNU C Compiler.
  3440. + These macros implement software BCD floating point support;
  3441. + primary use will be TIGCC.
  3442. + Copyright (C) 1994 Free Software Foundation, Inc.
  3443. + Copyright (C) 2000 Sebastian Reichelt
  3444. + Copyright (C) 2003-2005 Kevin Kofler
  3445. +
  3446. +This file is part of TIGCC.
  3447. +
  3448. +GNU CC is free software; you can redistribute it and/or modify
  3449. +it under the terms of the GNU General Public License as published by
  3450. +the Free Software Foundation; either version 2, or (at your option)
  3451. +any later version.
  3452. +
  3453. +GNU CC is distributed in the hope that it will be useful,
  3454. +but WITHOUT ANY WARRANTY; without even the implied warranty of
  3455. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3456. +GNU General Public License for more details.
  3457. +
  3458. +You should have received a copy of the GNU General Public License
  3459. +along with GNU CC; see the file COPYING. If not, write to
  3460. +the Free Software Foundation, 59 Temple Place - Suite 330,
  3461. +Boston, MA 02111-1307, USA. */
  3462. +
  3463. +#undef TARGET_FLOAT_FORMAT
  3464. +#define TARGET_FLOAT_FORMAT SMAP_BCD_FLOAT_FORMAT
  3465. +
  3466. +#ifndef __SMAP_BCD_FLOAT
  3467. +#define __SMAP_BCD_FLOAT
  3468. +
  3469. +typedef struct real_value smap_bcd_float;
  3470. +
  3471. +#endif
  3472. +
  3473. +#undef REAL_VALUE_TYPE
  3474. +#define REAL_VALUE_TYPE smap_bcd_float
  3475. +
  3476. +#undef FLOAT_TYPE_SIZE
  3477. +#undef DOUBLE_TYPE_SIZE
  3478. +#undef LONG_DOUBLE_TYPE_SIZE
  3479. +
  3480. +/* We have to define a special mode for this; one that handles 10 byte
  3481. + floats. There have to be a lot of changes to other files; due to the
  3482. + fact that they are so countless, it would be too hard to make them
  3483. + compatible with a general-purpose GCC. */
  3484. +#define FLOAT_TYPE_SIZE 80
  3485. +#define DOUBLE_TYPE_SIZE 80
  3486. +#define LONG_DOUBLE_TYPE_SIZE 80
  3487. +
  3488. +#ifndef REAL_IS_NOT_DOUBLE
  3489. +#define REAL_IS_NOT_DOUBLE
  3490. +#endif
  3491. +
  3492. +#define ZERO (__extension__(smap_bcd_float){0x4000,0})
  3493. +#define UNSIGNED_ZERO (__extension__(smap_bcd_float){0x4000,0})
  3494. +#define POSITIVE_ZERO (__extension__(smap_bcd_float){0,0})
  3495. +#define NEGATIVE_ZERO (__extension__(smap_bcd_float){0x8000,0})
  3496. +
  3497. +#define UNSIGNED_INF (__extension__(smap_bcd_float){0x7FFF,0xAA00CC0000000000ull})
  3498. +#define POSITIVE_INF (__extension__(smap_bcd_float){0x7FFF,0xAA00BB0000000000ull})
  3499. +#define NEGATIVE_INF (__extension__(smap_bcd_float){0xFFFF,0xAA00BB0000000000ull})
  3500. +
  3501. +#define NAN (__extension__(smap_bcd_float){0x7FFF,0xAA00000000000000ull})
  3502. +
  3503. +#ifndef REAL_INFINITY
  3504. +#define REAL_INFINITY
  3505. +#endif
  3506. +
  3507. +#undef REAL_VALUE_ISNAN
  3508. +#define REAL_VALUE_ISNAN(x) \
  3509. + (REAL_VALUES_IDENTICAL (x, NAN))
  3510. +
  3511. +#undef REAL_VALUE_ISINF
  3512. +#define REAL_VALUE_ISINF(x) \
  3513. + ((REAL_VALUES_IDENTICAL (x, POSITIVE_INF)) \
  3514. + || (REAL_VALUES_IDENTICAL (x, NEGATIVE_INF)) \
  3515. + || (REAL_VALUES_IDENTICAL (x, UNSIGNED_INF)))
  3516. +
  3517. +#define REAL_VALUE_ISNANUINF(x) \
  3518. + ((REAL_VALUE_ISNAN (x)) \
  3519. + || (REAL_VALUES_IDENTICAL (x, UNSIGNED_INF)))
  3520. +
  3521. +#define REAL_VALUE_ISFINITE(x) \
  3522. + (!(REAL_VALUE_ISNAN (x)) \
  3523. + && !(REAL_VALUE_ISINF (x)))
  3524. +
  3525. +#define REAL_VALUE_ISZERO(x) \
  3526. + (!((x).mantissa))
  3527. +
  3528. +#undef REAL_VALUE_MINUS_ZERO
  3529. +#define REAL_VALUE_MINUS_ZERO(x) \
  3530. + (REAL_VALUES_IDENTICAL (x, NEGATIVE_ZERO))
  3531. +
  3532. +#define REAL_VALUE_ISPOSITIVE(x) \
  3533. + (!(REAL_VALUE_ISNANUINF (x)) \
  3534. + && ((x).exponent < 0x8000) \
  3535. + && !(REAL_VALUE_ISZERO (x)))
  3536. +
  3537. +#define REAL_VALUE_ISNEGATIVE(x) \
  3538. + (!(REAL_VALUE_ISNANUINF (x)) \
  3539. + && ((x).exponent >= 0x8000) \
  3540. + && !(REAL_VALUE_ISZERO (x)))
  3541. +
  3542. +#undef REAL_VALUE_POSITIVE
  3543. +#define REAL_VALUE_POSITIVE(x) \
  3544. + (REAL_VALUE_ISPOSITIVE (x))
  3545. +
  3546. +#undef REAL_VALUE_NEGATIVE
  3547. +#define REAL_VALUE_NEGATIVE(x) \
  3548. + (REAL_VALUE_ISNEGATIVE (x))
  3549. +
  3550. +#define real_isneg(x) \
  3551. + (REAL_VALUE_ISNEGATIVE (*(x)))
  3552. +
  3553. +#undef REAL_VALUES_IDENTICAL
  3554. +#define REAL_VALUES_IDENTICAL(x, y) \
  3555. + ((x).exponent == (y).exponent && (x).mantissa == (y).mantissa)
  3556. +
  3557. +#undef REAL_VALUES_EQUAL
  3558. +#define REAL_VALUES_EQUAL(x,y) \
  3559. + (((REAL_VALUES_IDENTICAL (x, y)) \
  3560. + && !REAL_VALUE_ISNANUINF (x) \
  3561. + && !REAL_VALUE_ISNANUINF (y)) \
  3562. + || (REAL_VALUE_ISZERO (x) \
  3563. + && REAL_VALUE_ISZERO (y)))
  3564. +
  3565. +#undef REAL_VALUES_LESS
  3566. +#define REAL_VALUES_LESS(x,y) \
  3567. +__extension__ ({ \
  3568. + register int result = 0; \
  3569. + if (REAL_VALUE_ISNANUINF (x) \
  3570. + || REAL_VALUE_ISNANUINF (y) \
  3571. + || REAL_VALUES_EQUAL (x, y) \
  3572. + || (REAL_VALUE_ISPOSITIVE (x) && !(REAL_VALUE_ISPOSITIVE (y))) \
  3573. + || (!(REAL_VALUE_ISNEGATIVE (x)) && REAL_VALUE_ISNEGATIVE (y))) \
  3574. + result = 0; \
  3575. + else if ((REAL_VALUE_ISNEGATIVE (x) && !(REAL_VALUE_ISNEGATIVE (y))) \
  3576. + || (!(REAL_VALUE_ISPOSITIVE (x)) && REAL_VALUE_ISPOSITIVE (y))) \
  3577. + result = 1; \
  3578. + else \
  3579. + { \
  3580. + if ((x).exponent == (y).exponent) \
  3581. + { \
  3582. + if (REAL_VALUE_ISNEGATIVE (x)) \
  3583. + result = ((x).mantissa > (y).mantissa); \
  3584. + else \
  3585. + result = ((x).mantissa < (y).mantissa); \
  3586. + } \
  3587. + else \
  3588. + { \
  3589. + if (REAL_VALUE_ISNEGATIVE (x)) \
  3590. + result = ((x).exponent > (y).exponent); \
  3591. + else \
  3592. + result = ((x).exponent < (y).exponent); \
  3593. + } \
  3594. + } \
  3595. + result; \
  3596. +})
  3597. +
  3598. +#undef REAL_VALUE_LDEXP
  3599. +#define REAL_VALUE_LDEXP(x,tempscale) \
  3600. +__extension__ ({ \
  3601. + REAL_VALUE_TYPE __tempx = x; \
  3602. + int scale; \
  3603. + unsigned long long pmul; \
  3604. + signed short carry, help; \
  3605. + if (REAL_VALUE_ISFINITE (__tempx)) \
  3606. + { \
  3607. + if (tempscale > 0) \
  3608. + for (scale = 0; scale < tempscale; scale++) \
  3609. + { \
  3610. + if (__tempx.mantissa >= 0x5000000000000000ull) \
  3611. + { \
  3612. + __tempx.mantissa /= 0x10; \
  3613. + __tempx.exponent++; \
  3614. + } \
  3615. + carry = 0; \
  3616. + for (pmul = 1; 1; pmul *= 0x10) \
  3617. + { \
  3618. + help = (__tempx.mantissa / pmul) & 0xF; \
  3619. + __tempx.mantissa -= ((unsigned long long) help) * pmul; \
  3620. + help *= 2; \
  3621. + help += carry; \
  3622. + carry = help / 10; \
  3623. + __tempx.mantissa += ((unsigned long long) (help % 10)) * pmul; \
  3624. + if (pmul >= 0x1000000000000000ull) \
  3625. + break; \
  3626. + } \
  3627. + } \
  3628. + else if (tempscale < 0) \
  3629. + for (scale = 0; scale > tempscale; scale--) \
  3630. + { \
  3631. + carry = 0; \
  3632. + for (pmul = 0x1000000000000000ull; pmul > 0; pmul /= 0x10) \
  3633. + { \
  3634. + help = (__tempx.mantissa / pmul) & 0xF; \
  3635. + __tempx.mantissa -= ((unsigned long long) help) * pmul; \
  3636. + help += carry; \
  3637. + __tempx.mantissa += ((unsigned long long) (help / 2)) * pmul; \
  3638. + carry = (help % 2) * 10; \
  3639. + } \
  3640. + if (__tempx.mantissa < 0x1000000000000000ull) \
  3641. + { \
  3642. + __tempx.mantissa *= 0x10; \
  3643. + __tempx.mantissa += carry / 2; \
  3644. + __tempx.exponent--; \
  3645. + } \
  3646. + } \
  3647. + } \
  3648. + __tempx; \
  3649. +})
  3650. +
  3651. +#undef REAL_VALUE_FIX
  3652. +#define REAL_VALUE_FIX(x) \
  3653. + ((REAL_VALUE_ISNEGATIVE (x)) \
  3654. + ? (-(REAL_VALUE_UNSIGNED_FIX (REAL_VALUE_NEGATE (x)))) \
  3655. + : (REAL_VALUE_UNSIGNED_FIX (x)))
  3656. +
  3657. +#undef REAL_VALUE_UNSIGNED_FIX
  3658. +#define REAL_VALUE_UNSIGNED_FIX(x) \
  3659. +__extension__ ({ \
  3660. + register unsigned int r = 0; \
  3661. + signed char i; \
  3662. + unsigned long long mpmul = 0x1000000000000000ull; \
  3663. + if (((x.exponent & 0x7FFF) >= 0x4000) && ((x.exponent & 0x7FFF) < 0x4016)) \
  3664. + { \
  3665. + for (i = 0; i <= (x.exponent & 0x7FFF) - 0x4000; i++) \
  3666. + if (mpmul) \
  3667. + { \
  3668. + r *= 10; \
  3669. + r += (x.mantissa / mpmul) & 0xF; \
  3670. + mpmul /= 0x10; \
  3671. + } \
  3672. + } \
  3673. + r; \
  3674. +})
  3675. +
  3676. +#undef REAL_VALUE_RNDZINT
  3677. +#define REAL_VALUE_RNDZINT(x) \
  3678. +__extension__ ({ \
  3679. + REAL_VALUE_TYPE r = ZERO; \
  3680. + signed char i; \
  3681. + unsigned long long mpmul = 0x1000000000000000ull; \
  3682. + r.exponent = (x).exponent; \
  3683. + if (((r.exponent & 0x7FFF) >= 0x4000) && ((r.exponent & 0x7FFF) < 0x4016)) \
  3684. + { \
  3685. + for (i = 0; i <= (r.exponent & 0x7FFF) - 0x4000; i++) \
  3686. + if (mpmul) \
  3687. + { \
  3688. + r.mantissa += x.mantissa & (0xF * mpmul); \
  3689. + mpmul /= 0x10; \
  3690. + } \
  3691. + } \
  3692. + r; \
  3693. +})
  3694. +
  3695. +#undef REAL_VALUE_UNSIGNED_RNDZINT
  3696. +#define REAL_VALUE_UNSIGNED_RNDZINT(x) \
  3697. + ((REAL_VALUE_ISPOSITIVE (x)) \
  3698. + ? (REAL_VALUE_RNDZINT (x)) \
  3699. + : (ZERO))
  3700. +
  3701. +#undef REAL_VALUE_ATOF
  3702. +#define REAL_VALUE_ATOF(string,mode) \
  3703. + real_from_string2((string), (mode))
  3704. +
  3705. +#undef REAL_ARITHMETIC
  3706. +#define REAL_ARITHMETIC(value, code, d1, d2) \
  3707. + real_arithmetic (&(value), (code), &(d1), &(d2))
  3708. +
  3709. +#undef REAL_VALUE_NEGATE
  3710. +#define REAL_VALUE_NEGATE(x) \
  3711. +__extension__ ({ \
  3712. + REAL_VALUE_TYPE __tempx = x; \
  3713. + if ((!(REAL_VALUE_ISNANUINF (__tempx))) && ((__tempx.mantissa) || (__tempx.exponent != 0x4000))) \
  3714. + __tempx.exponent ^= 0x8000; \
  3715. + __tempx; \
  3716. +})
  3717. +
  3718. +#undef REAL_VALUE_TRUNCATE
  3719. +#define REAL_VALUE_TRUNCATE(mode,x) \
  3720. + (x)
  3721. +
  3722. +#define real_convert(r,mode,x) \
  3723. + (*(r)=*(x))
  3724. +
  3725. +#define REAL_VALUE_TO_INT(lo, hi, r) real_to_integer2 ((lo), (hi), &(r))
  3726. +
  3727. +#define REAL_VALUE_FROM_INT(d, lo, hi, mode) \
  3728. + real_from_integer (&(d), (mode), (lo), (hi), 0)
  3729. +
  3730. +#define REAL_VALUE_FROM_UNSIGNED_INT(d, lo, hi, mode) \
  3731. + real_from_integer (&(d), (mode), (lo), (hi), 1)
  3732. +
  3733. +#undef REAL_VALUE_TO_TARGET_SINGLE
  3734. +#define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
  3735. + gcc_unreachable();
  3736. +
  3737. +#undef REAL_VALUE_TO_TARGET_DOUBLE
  3738. +#define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
  3739. + gcc_unreachable();
  3740. +
  3741. +#undef REAL_VALUE_TO_TARGET_LONG_DOUBLE
  3742. +#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT) \
  3743. +do { \
  3744. + REAL_VALUE_TYPE f = (IN); \
  3745. + (OUT)[0] = f.exponent * 0x10000 + ((unsigned short) (f.mantissa / 0x1000000000000ull)), (OUT)[1] = (unsigned long) (f.mantissa / 0x10000), (OUT)[2] = ((unsigned short) (f.mantissa)) * 0x10000; \
  3746. +} while (0)
  3747. +
  3748. +#undef REAL_VALUE_TO_TARGET_SMAP_BCD
  3749. +#define REAL_VALUE_TO_TARGET_SMAP_BCD(IN, OUT) \
  3750. +do { \
  3751. + REAL_VALUE_TYPE f = (IN); \
  3752. + (OUT)[0] = f.exponent, (OUT)[1] = (unsigned long) (f.mantissa / 0x100000000ull), (OUT)[2] = (unsigned long) (f.mantissa); \
  3753. +} while (0)
  3754. +
  3755. +#define REAL_VALUE_TO_STRING(IN, OUT) \
  3756. +do { \
  3757. + REAL_VALUE_TYPE f = (IN); \
  3758. + if (REAL_VALUE_ISNAN (f)) \
  3759. + sprintf ((OUT), "NaN"); \
  3760. + else if (REAL_VALUES_IDENTICAL (f, UNSIGNED_INF)) \
  3761. + sprintf ((OUT), "Inf"); \
  3762. + else if (REAL_VALUES_IDENTICAL (f, POSITIVE_INF)) \
  3763. + sprintf ((OUT), "+Inf"); \
  3764. + else if (REAL_VALUES_IDENTICAL (f, NEGATIVE_INF)) \
  3765. + sprintf ((OUT), "-Inf"); \
  3766. + else if (REAL_VALUES_IDENTICAL (f, UNSIGNED_ZERO)) \
  3767. + sprintf ((OUT), "0.0"); \
  3768. + else if (REAL_VALUES_IDENTICAL (f, POSITIVE_ZERO)) \
  3769. + sprintf ((OUT), "+0.0"); \
  3770. + else if (REAL_VALUES_IDENTICAL (f, NEGATIVE_ZERO)) \
  3771. + sprintf ((OUT), "-0.0"); \
  3772. + else \
  3773. + { \
  3774. + long exp; \
  3775. + int neg = REAL_VALUE_ISNEGATIVE (f); \
  3776. + if (neg) \
  3777. + exp = f.exponent - 0xC000; \
  3778. + else \
  3779. + exp = f.exponent - 0x4000; \
  3780. + sprintf ((OUT), "%s%lx.%07lx%08lxe%d", neg ? "-" : "", (unsigned long) (f.mantissa >> 60), (unsigned long) (f.mantissa >> 32) & 0x0ffffffful, (unsigned long) (f.mantissa), (int) (exp)); \
  3781. + } \
  3782. +} while (0)
  3783. +
  3784. +#define REAL_VALUE_ABS(x) ((REAL_VALUE_ISNEGATIVE((x))\
  3785. + || REAL_VALUE_MINUS_ZERO((x))\
  3786. + || REAL_VALUES_IDENTICAL ((x), NEGATIVE_INF))?\
  3787. + REAL_VALUE_NEGATE((x)):(x))
  3788. +
  3789. +/* WARNING: This is the number of bits we can represent, not the true size of
  3790. + the mantissa. */
  3791. +#define significand_size(dummy) (53)
  3792. +
  3793. +#undef MODE_HAS_NANS
  3794. +#define MODE_HAS_NANS(MODE) ((MODE)==BFmode)
  3795. +
  3796. +#undef MODE_HAS_INFINITIES
  3797. +#define MODE_HAS_INFINITIES(MODE) ((MODE)==BFmode)
  3798. +
  3799. +/* FIXME: GCC expects this to mean that there is only 0 and -0. We actually have
  3800. + 0, +0 and -0. This allows a few optimizations GCC is too cautious to
  3801. + do in the presence of signed zeros. */
  3802. +#undef MODE_HAS_SIGNED_ZEROS
  3803. +#define MODE_HAS_SIGNED_ZEROS(MODE) ((MODE)==BFmode)
  3804. +
  3805. +#define REAL_MODE_FORMAT_COMPOSITE_P(dummy) (0)
  3806. +
  3807. +/* end of smapbcd.h */
  3808. diff -Naur gcc-4.1.2.orig/gcc/config.gcc gcc-4.1.2-src/gcc/config.gcc
  3809. --- gcc-4.1.2.orig/gcc/config.gcc 2006-10-16 01:12:23.000000000 +0200
  3810. +++ gcc-4.1.2-src/gcc/config.gcc 2007-02-19 02:32:34.000000000 +0100
  3811. @@ -1381,7 +1381,7 @@
  3812. m68k-*-coff*)
  3813. tmake_file=m68k/t-m68kbare
  3814. tm_defines="MOTOROLA USE_GAS"
  3815. - tm_file="m68k/m68k.h m68k/m68k-none.h m68k/m68kemb.h dbxcoff.h m68k/coff.h dbx.h"
  3816. + tm_file="m68k/m68k.h m68k/m68k-none.h dbxcoff.h m68k/coff.h smapbcd.h m68k/m68k-ti.h dbx.h"
  3817. use_fixproto=yes
  3818. ;;
  3819. m68020-*-elf* | m68k-*-elf*)
  3820. diff -Naur gcc-4.1.2.orig/gcc/convert.c gcc-4.1.2-src/gcc/convert.c
  3821. --- gcc-4.1.2.orig/gcc/convert.c 2006-11-13 11:18:57.000000000 +0100
  3822. +++ gcc-4.1.2-src/gcc/convert.c 2007-02-19 02:32:34.000000000 +0100
  3823. @@ -73,6 +73,9 @@
  3824. {
  3825. tree sub, expt, subt;
  3826. +/* (TIGCC 20050205) We do not implement exact_real_truncate and there is no
  3827. + narrower float mode anyway. -- Kevin Kofler */
  3828. +#if 0
  3829. /* For floating point constant look up the narrowest type that can hold
  3830. it properly and handle it like (type)(narrowest_type)constant.
  3831. This way we can optimize for instance a=a*2.0 where "a" is float
  3832. @@ -93,6 +96,7 @@
  3833. if (type)
  3834. return build_real (type, real_value_truncate (TYPE_MODE (type), orig));
  3835. }
  3836. +#endif /* 0 */
  3837. if (TREE_CODE (exp) != NOP_EXPR
  3838. && TREE_CODE (exp) != CONVERT_EXPR)
  3839. diff -Naur gcc-4.1.2.orig/gcc/c.opt gcc-4.1.2-src/gcc/c.opt
  3840. --- gcc-4.1.2.orig/gcc/c.opt 2006-01-26 20:06:06.000000000 +0100
  3841. +++ gcc-4.1.2-src/gcc/c.opt 2007-02-19 02:32:34.000000000 +0100
  3842. @@ -446,6 +446,10 @@
  3843. C ObjC C++ ObjC++
  3844. Recognize the \"asm\" keyword
  3845. +fauto-octals
  3846. +C ObjC C++ ObjC++
  3847. +Numbers starting with zero should be octal (default on).
  3848. +
  3849. fbuiltin
  3850. C ObjC C++ ObjC++
  3851. Recognize built-in functions
  3852. diff -Naur gcc-4.1.2.orig/gcc/c-opts.c gcc-4.1.2-src/gcc/c-opts.c
  3853. --- gcc-4.1.2.orig/gcc/c-opts.c 2007-01-05 16:55:45.000000000 +0100
  3854. +++ gcc-4.1.2-src/gcc/c-opts.c 2007-02-19 02:32:34.000000000 +0100
  3855. @@ -222,6 +222,9 @@
  3856. before passing on command-line options to cpplib. */
  3857. cpp_opts->warn_dollars = 0;
  3858. + /* (TIGCC 20050217) Enable -fms-extensions by default. */
  3859. + flag_ms_extensions = 1;
  3860. +
  3861. flag_const_strings = c_dialect_cxx ();
  3862. flag_exceptions = c_dialect_cxx ();
  3863. warn_pointer_arith = c_dialect_cxx ();
  3864. @@ -323,7 +326,9 @@
  3865. error ("-I- specified twice");
  3866. quote_chain_split = true;
  3867. split_quote_chain ();
  3868. +#if 0 /* (TIGCC 20050206) */
  3869. inform ("obsolete option -I- used, please use -iquote instead");
  3870. +#endif /* 0 */
  3871. }
  3872. break;
  3873. @@ -418,8 +423,10 @@
  3874. cpp_opts->warn_num_sign_change = value;
  3875. cpp_opts->warn_multichar = value; /* Was C++ only. */
  3876. +#if 0 /* (TIGCC 20060430) */
  3877. if (warn_pointer_sign == -1)
  3878. warn_pointer_sign = 1;
  3879. +#endif /* 0 */
  3880. break;
  3881. case OPT_Wcomment:
  3882. @@ -881,6 +888,8 @@
  3883. case OPT_pedantic:
  3884. cpp_opts->pedantic = 1;
  3885. cpp_opts->warn_endif_labels = 1;
  3886. + /* (TIGCC 20050217) No Microsoft extensions if -pedantic. */
  3887. + flag_ms_extensions = 0;
  3888. if (warn_pointer_sign == -1)
  3889. warn_pointer_sign = 1;
  3890. break;
  3891. @@ -949,6 +958,10 @@
  3892. case OPT_v:
  3893. verbose = true;
  3894. break;
  3895. +
  3896. + case OPT_fauto_octals:
  3897. + cpp_opts->no_auto_octals = !value;
  3898. + break;
  3899. }
  3900. return result;
  3901. @@ -1029,10 +1042,12 @@
  3902. "-Wformat-security ignored without -Wformat");
  3903. }
  3904. +#if 0 /* (TIGCC 20050306) Disable as we don't have these libcalls. */
  3905. /* C99 requires special handling of complex multiplication and division;
  3906. -ffast-math and -fcx-limited-range are handled in process_options. */
  3907. if (flag_isoc99)
  3908. flag_complex_method = 2;
  3909. +#endif /* 0 */
  3910. if (flag_preprocess_only)
  3911. {
  3912. diff -Naur gcc-4.1.2.orig/gcc/c-parser.c gcc-4.1.2-src/gcc/c-parser.c
  3913. --- gcc-4.1.2.orig/gcc/c-parser.c 2006-08-15 18:55:25.000000000 +0200
  3914. +++ gcc-4.1.2-src/gcc/c-parser.c 2007-02-19 02:32:34.000000000 +0100
  3915. @@ -911,14 +911,14 @@
  3916. struct c_expr *);
  3917. static struct c_expr c_parser_binary_expression (c_parser *, struct c_expr *);
  3918. static struct c_expr c_parser_cast_expression (c_parser *, struct c_expr *);
  3919. -static struct c_expr c_parser_unary_expression (c_parser *);
  3920. +static struct c_expr c_parser_unary_expression (c_parser *, bool in_cast);
  3921. static struct c_expr c_parser_sizeof_expression (c_parser *);
  3922. static struct c_expr c_parser_alignof_expression (c_parser *);
  3923. -static struct c_expr c_parser_postfix_expression (c_parser *);
  3924. +static struct c_expr c_parser_postfix_expression (c_parser *, bool in_cast);
  3925. static struct c_expr c_parser_postfix_expression_after_paren_type (c_parser *,
  3926. struct c_type_name *);
  3927. static struct c_expr c_parser_postfix_expression_after_primary (c_parser *,
  3928. - struct c_expr);
  3929. + struct c_expr, bool in_cast);
  3930. static struct c_expr c_parser_expression (c_parser *);
  3931. static struct c_expr c_parser_expression_conv (c_parser *);
  3932. static tree c_parser_expr_list (c_parser *, bool);
  3933. @@ -2527,6 +2527,7 @@
  3934. struct c_declspecs *specs;
  3935. struct c_declarator *declarator;
  3936. tree prefix_attrs;
  3937. + tree maybeasm = NULL_TREE;
  3938. tree postfix_attrs = NULL_TREE;
  3939. bool dummy = false;
  3940. if (!c_parser_next_token_starts_declspecs (parser))
  3941. @@ -2556,10 +2557,14 @@
  3942. c_parser_skip_until_found (parser, CPP_COMMA, NULL);
  3943. return NULL;
  3944. }
  3945. + /* (TIGCC 20051221) Register parameter support. We accept an ASM
  3946. + at this place to specify a register for the parameter. */
  3947. + if (c_parser_next_token_is_keyword (parser, RID_ASM))
  3948. + maybeasm = c_parser_simple_asm_expr (parser);
  3949. if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
  3950. postfix_attrs = c_parser_attributes (parser);
  3951. return build_c_parm (specs, chainon (postfix_attrs, prefix_attrs),
  3952. - declarator);
  3953. + declarator, maybeasm);
  3954. }
  3955. /* Parse a string literal in an asm expression. It should not be
  3956. @@ -3317,8 +3322,8 @@
  3957. parser->error = false;
  3958. }
  3959. - if (last_label)
  3960. - error ("label at end of compound statement");
  3961. + if (last_label && pedantic)
  3962. + pedwarn ("ISO C doesn't allow labels at the end of compound statements");
  3963. c_parser_consume_token (parser);
  3964. }
  3965. @@ -4463,11 +4468,8 @@
  3966. */
  3967. static struct c_expr
  3968. -c_parser_cast_expression (c_parser *parser, struct c_expr *after)
  3969. +c_parser_cast_expression_1 (c_parser *parser, bool in_cast)
  3970. {
  3971. - gcc_assert (!after || c_dialect_objc ());
  3972. - if (after)
  3973. - return c_parser_postfix_expression_after_primary (parser, *after);
  3974. /* If the expression begins with a parenthesized type name, it may
  3975. be either a cast or a compound literal; we need to see whether
  3976. the next character is '{' to tell the difference. If not, it is
  3977. @@ -4490,14 +4492,28 @@
  3978. if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
  3979. return c_parser_postfix_expression_after_paren_type (parser,
  3980. type_name);
  3981. - expr = c_parser_cast_expression (parser, NULL);
  3982. + expr = c_parser_cast_expression_1 (parser, 1);
  3983. expr = default_function_array_conversion (expr);
  3984. ret.value = c_cast_expr (type_name, expr.value);
  3985. ret.original_code = ERROR_MARK;
  3986. return ret;
  3987. }
  3988. else
  3989. - return c_parser_unary_expression (parser);
  3990. + return c_parser_unary_expression (parser, in_cast);
  3991. +}
  3992. +
  3993. +/* (TIGCC 20051222) Postfix operators apply to casts too. */
  3994. +static struct c_expr
  3995. +c_parser_cast_expression (c_parser *parser, struct c_expr *after)
  3996. +{
  3997. + gcc_assert (!after || c_dialect_objc ());
  3998. + if (after)
  3999. + return c_parser_postfix_expression_after_primary (parser, *after, 0);
  4000. + /* Allow all postfix operators, not just ++ and --. Those with higher
  4001. + priority than casts will already have been parsed first, unless they
  4002. + come after ++ and --, in which case they need to be parsed here. */
  4003. + return c_parser_postfix_expression_after_primary (parser,
  4004. + c_parser_cast_expression_1 (parser, 0), 0);
  4005. }
  4006. /* Parse an unary expression (C90 6.3.3, C99 6.5.3).
  4007. @@ -4528,7 +4544,7 @@
  4008. given later. */
  4009. static struct c_expr
  4010. -c_parser_unary_expression (c_parser *parser)
  4011. +c_parser_unary_expression (c_parser *parser, bool in_cast)
  4012. {
  4013. int ext;
  4014. struct c_expr ret, op;
  4015. @@ -4618,10 +4634,10 @@
  4016. op = default_function_array_conversion (op);
  4017. return parser_build_unary_op (IMAGPART_EXPR, op);
  4018. default:
  4019. - return c_parser_postfix_expression (parser);
  4020. + return c_parser_postfix_expression (parser, in_cast);
  4021. }
  4022. default:
  4023. - return c_parser_postfix_expression (parser);
  4024. + return c_parser_postfix_expression (parser, in_cast);
  4025. }
  4026. }
  4027. @@ -4666,7 +4682,7 @@
  4028. }
  4029. else
  4030. {
  4031. - expr = c_parser_unary_expression (parser);
  4032. + expr = c_parser_unary_expression (parser, 0);
  4033. sizeof_expr:
  4034. skip_evaluation--;
  4035. in_sizeof--;
  4036. @@ -4722,7 +4738,7 @@
  4037. else
  4038. {
  4039. struct c_expr ret;
  4040. - expr = c_parser_unary_expression (parser);
  4041. + expr = c_parser_unary_expression (parser, 0);
  4042. alignof_expr:
  4043. skip_evaluation--;
  4044. in_alignof--;
  4045. @@ -4786,7 +4802,7 @@
  4046. */
  4047. static struct c_expr
  4048. -c_parser_postfix_expression (c_parser *parser)
  4049. +c_parser_postfix_expression (c_parser *parser, bool in_cast)
  4050. {
  4051. struct c_expr expr, e1, e2, e3;
  4052. struct c_type_name *t1, *t2;
  4053. @@ -5183,7 +5199,7 @@
  4054. expr.original_code = ERROR_MARK;
  4055. break;
  4056. }
  4057. - return c_parser_postfix_expression_after_primary (parser, expr);
  4058. + return c_parser_postfix_expression_after_primary (parser, expr, in_cast);
  4059. }
  4060. /* Parse a postfix expression after a parenthesized type name: the
  4061. @@ -5216,7 +5232,7 @@
  4062. pedwarn ("ISO C90 forbids compound literals");
  4063. expr.value = build_compound_literal (type, init.value);
  4064. expr.original_code = ERROR_MARK;
  4065. - return c_parser_postfix_expression_after_primary (parser, expr);
  4066. + return c_parser_postfix_expression_after_primary (parser, expr, 0);
  4067. }
  4068. /* Parse a postfix expression after the initial primary or compound
  4069. @@ -5224,7 +5240,8 @@
  4070. static struct c_expr
  4071. c_parser_postfix_expression_after_primary (c_parser *parser,
  4072. - struct c_expr expr)
  4073. + struct c_expr expr,
  4074. + bool in_cast)
  4075. {
  4076. tree ident, idx, exprlist;
  4077. while (true)
  4078. @@ -5288,6 +5305,9 @@
  4079. expr.original_code = ERROR_MARK;
  4080. break;
  4081. case CPP_PLUS_PLUS:
  4082. + /* (TIGCC 20051222) Postincrement has lower priority than casts. */
  4083. + if (in_cast)
  4084. + return expr;
  4085. /* Postincrement. */
  4086. c_parser_consume_token (parser);
  4087. expr = default_function_array_conversion (expr);
  4088. @@ -5295,6 +5315,9 @@
  4089. expr.original_code = ERROR_MARK;
  4090. break;
  4091. case CPP_MINUS_MINUS:
  4092. + /* (TIGCC 20051222) Postdecrement has lower priority than casts. */
  4093. + if (in_cast)
  4094. + return expr;
  4095. /* Postdecrement. */
  4096. c_parser_consume_token (parser);
  4097. expr = default_function_array_conversion (expr);
  4098. diff -Naur gcc-4.1.2.orig/gcc/cppdefault.c gcc-4.1.2-src/gcc/cppdefault.c
  4099. --- gcc-4.1.2.orig/gcc/cppdefault.c 2005-06-25 04:02:01.000000000 +0200
  4100. +++ gcc-4.1.2-src/gcc/cppdefault.c 2007-02-19 02:32:34.000000000 +0100
  4101. @@ -46,6 +46,7 @@
  4102. = INCLUDE_DEFAULTS;
  4103. #else
  4104. = {
  4105. +#if 0 /* (TIGCC 20040104) Don't hardcode any prefix at compile time. */
  4106. #ifdef GPLUSPLUS_INCLUDE_DIR
  4107. /* Pick up GNU C++ generic include files. */
  4108. { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0 },
  4109. @@ -85,11 +86,12 @@
  4110. /* /usr/include comes dead last. */
  4111. { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0, 1 },
  4112. #endif
  4113. +#endif /* 0 */
  4114. { 0, 0, 0, 0, 0 }
  4115. };
  4116. #endif /* no INCLUDE_DEFAULTS */
  4117. -#ifdef GCC_INCLUDE_DIR
  4118. +#if 0 /* (TIGCC 20040104) Don't hardcode any prefix at compile time. */
  4119. const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
  4120. const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
  4121. #else
  4122. diff -Naur gcc-4.1.2.orig/gcc/c-ppoutput.c gcc-4.1.2-src/gcc/c-ppoutput.c
  4123. --- gcc-4.1.2.orig/gcc/c-ppoutput.c 2005-10-14 16:56:45.000000000 +0200
  4124. +++ gcc-4.1.2-src/gcc/c-ppoutput.c 2007-02-19 02:32:34.000000000 +0100
  4125. @@ -174,7 +174,8 @@
  4126. print.prev = token;
  4127. cpp_output_token (token, print.outf);
  4128. - if (token->type == CPP_COMMENT)
  4129. + if (token->type == CPP_STRING || token->type == CPP_WSTRING
  4130. + || token->type == CPP_COMMENT)
  4131. account_for_newlines (token->val.str.text, token->val.str.len);
  4132. }
  4133. }
  4134. diff -Naur gcc-4.1.2.orig/gcc/c-pretty-print.c gcc-4.1.2-src/gcc/c-pretty-print.c
  4135. --- gcc-4.1.2.orig/gcc/c-pretty-print.c 2006-08-26 00:47:00.000000000 +0200
  4136. +++ gcc-4.1.2-src/gcc/c-pretty-print.c 2007-02-19 02:32:34.000000000 +0100
  4137. @@ -913,8 +913,7 @@
  4138. static void
  4139. pp_c_floating_constant (c_pretty_printer *pp, tree r)
  4140. {
  4141. - real_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_REAL_CST (r),
  4142. - sizeof (pp_buffer (pp)->digit_buffer), 0, 1);
  4143. + REAL_VALUE_TO_STRING (TREE_REAL_CST (r), pp_buffer (pp)->digit_buffer);
  4144. pp_string (pp, pp_buffer(pp)->digit_buffer);
  4145. if (TREE_TYPE (r) == float_type_node)
  4146. pp_character (pp, 'f');
  4147. @@ -1957,6 +1956,17 @@
  4148. pp_postfix_expression (pp, TREE_OPERAND (e, 1));
  4149. break;
  4150. + /* (TIGCC 20050210) Get pp_c_expression to print statement expressions
  4151. + correctly. We only print the last statement of a list,
  4152. + because that's the result of the statement expression. */
  4153. + case BIND_EXPR:
  4154. + pp_c_expression (pp, BIND_EXPR_BODY (e));
  4155. + break;
  4156. +
  4157. + case STATEMENT_LIST:
  4158. + pp_c_expression (pp, STATEMENT_LIST_TAIL (e)->stmt);
  4159. + break;
  4160. +
  4161. default:
  4162. pp_unsupported_tree (pp, e);
  4163. break;
  4164. diff -Naur gcc-4.1.2.orig/gcc/c-tree.h gcc-4.1.2-src/gcc/c-tree.h
  4165. --- gcc-4.1.2.orig/gcc/c-tree.h 2005-11-19 00:40:29.000000000 +0100
  4166. +++ gcc-4.1.2-src/gcc/c-tree.h 2007-02-19 02:32:34.000000000 +0100
  4167. @@ -353,6 +353,8 @@
  4168. tree attrs;
  4169. /* The declarator. */
  4170. struct c_declarator *declarator;
  4171. + /* (TIGCC 20050203) The asmspec. */
  4172. + tree asmspec;
  4173. };
  4174. /* Save and restore the variables in this file and elsewhere
  4175. @@ -431,6 +433,7 @@
  4176. extern tree pushdecl (tree);
  4177. extern void c_expand_body (tree);
  4178. +extern void c_insert_default_attributes (tree);
  4179. extern void c_init_decl_processing (void);
  4180. extern void c_dup_lang_specific_decl (tree);
  4181. extern void c_print_identifier (FILE *, tree, int);
  4182. @@ -478,7 +481,7 @@
  4183. extern struct c_typespec parser_xref_tag (enum tree_code, tree);
  4184. extern int c_expand_decl (tree);
  4185. extern struct c_parm *build_c_parm (struct c_declspecs *, tree,
  4186. - struct c_declarator *);
  4187. + struct c_declarator *, tree /* (TIGCC 20050203) */);
  4188. extern struct c_declarator *build_attrs_declarator (tree,
  4189. struct c_declarator *);
  4190. extern struct c_declarator *build_function_declarator (struct c_arg_info *,
  4191. diff -Naur gcc-4.1.2.orig/gcc/c-typeck.c gcc-4.1.2-src/gcc/c-typeck.c
  4192. --- gcc-4.1.2.orig/gcc/c-typeck.c 2006-10-25 10:11:26.000000000 +0200
  4193. +++ gcc-4.1.2-src/gcc/c-typeck.c 2007-02-19 03:40:55.000000000 +0100
  4194. @@ -83,6 +83,8 @@
  4195. static tree lookup_field (tree, tree);
  4196. static tree convert_arguments (tree, tree, tree, tree);
  4197. static tree pointer_diff (tree, tree);
  4198. +static tree unary_complex_lvalue (enum tree_code, tree, int);
  4199. +static void pedantic_lvalue_warning (enum tree_code);
  4200. static tree convert_for_assignment (tree, tree, enum impl_conv, tree, tree,
  4201. int);
  4202. static tree valid_compound_expr_initializer (tree, tree);
  4203. @@ -2168,6 +2170,7 @@
  4204. /* fntype now gets the type of function pointed to. */
  4205. fntype = TREE_TYPE (fntype);
  4206. +#if 0
  4207. /* Check that the function is called through a compatible prototype.
  4208. If it is not, replace the call by a trap, wrapped up in a compound
  4209. expression if necessary. This has the nice side-effect to prevent
  4210. @@ -2206,6 +2209,7 @@
  4211. return build2 (COMPOUND_EXPR, return_type, trap, rhs);
  4212. }
  4213. }
  4214. +#endif /* 0 */
  4215. /* Convert the parameters to the types declared in the
  4216. function prototype, or apply default promotions. */
  4217. @@ -2780,6 +2784,12 @@
  4218. case POSTINCREMENT_EXPR:
  4219. case PREDECREMENT_EXPR:
  4220. case POSTDECREMENT_EXPR:
  4221. + /* Handle complex lvalues (when permitted)
  4222. + by reduction to simpler cases. */
  4223. +
  4224. + val = unary_complex_lvalue (code, arg, 0);
  4225. + if (val != 0)
  4226. + return val;
  4227. /* Increment or decrement the real part of the value,
  4228. and don't change the imaginary part. */
  4229. @@ -2848,6 +2858,57 @@
  4230. inc = convert (argtype, inc);
  4231. + /* Handle incrementing a cast-expression. */
  4232. +
  4233. + while (1)
  4234. + switch (TREE_CODE (arg))
  4235. + {
  4236. + case NOP_EXPR:
  4237. + case CONVERT_EXPR:
  4238. + case FLOAT_EXPR:
  4239. + case FIX_TRUNC_EXPR:
  4240. + case FIX_FLOOR_EXPR:
  4241. + case FIX_ROUND_EXPR:
  4242. + case FIX_CEIL_EXPR:
  4243. + pedantic_lvalue_warning (CONVERT_EXPR);
  4244. + /* If the real type has the same machine representation
  4245. + as the type it is cast to, we can make better output
  4246. + by adding directly to the inside of the cast. */
  4247. + if ((TREE_CODE (TREE_TYPE (arg))
  4248. + == TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))))
  4249. + && (TYPE_MODE (TREE_TYPE (arg))
  4250. + == TYPE_MODE (TREE_TYPE (TREE_OPERAND (arg, 0)))))
  4251. + arg = TREE_OPERAND (arg, 0);
  4252. + else
  4253. + {
  4254. + tree incremented, modify, value;
  4255. + if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE)
  4256. + value = boolean_increment (code, arg);
  4257. + else
  4258. + {
  4259. + arg = stabilize_reference (arg);
  4260. + if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR)
  4261. + value = arg;
  4262. + else
  4263. + value = save_expr (arg);
  4264. + incremented = build (((code == PREINCREMENT_EXPR
  4265. + || code == POSTINCREMENT_EXPR)
  4266. + ? PLUS_EXPR : MINUS_EXPR),
  4267. + argtype, value, inc);
  4268. + TREE_SIDE_EFFECTS (incremented) = 1;
  4269. + modify = build_modify_expr (arg, NOP_EXPR, incremented);
  4270. + value = build (COMPOUND_EXPR, TREE_TYPE (arg), modify, value);
  4271. + }
  4272. + TREE_USED (value) = 1;
  4273. + return value;
  4274. + }
  4275. + break;
  4276. +
  4277. + default:
  4278. + goto give_up;
  4279. + }
  4280. + give_up:
  4281. +
  4282. /* Complain about anything else that is not a true lvalue. */
  4283. if (!lvalue_or_else (arg, ((code == PREINCREMENT_EXPR
  4284. || code == POSTINCREMENT_EXPR)
  4285. @@ -2898,6 +2959,12 @@
  4286. TREE_OPERAND (arg, 1), 1);
  4287. }
  4288. + /* Handle complex lvalues (when permitted)
  4289. + by reduction to simpler cases. */
  4290. + val = unary_complex_lvalue (code, arg, flag);
  4291. + if (val != 0)
  4292. + return val;
  4293. +
  4294. /* Anything not already handled and not a true memory reference
  4295. or a non-lvalue array is an error. */
  4296. else if (typecode != FUNCTION_TYPE && !flag
  4297. @@ -2988,6 +3055,69 @@
  4298. }
  4299. }
  4300. +/* Apply unary lvalue-demanding operator CODE to the expression ARG
  4301. + for certain kinds of expressions which are not really lvalues
  4302. + but which we can accept as lvalues. If FLAG is nonzero, then
  4303. + non-lvalues are OK since we may be converting a non-lvalue array to
  4304. + a pointer in C99.
  4305. +
  4306. + If ARG is not a kind of expression we can handle, return zero. */
  4307. +
  4308. +static tree
  4309. +unary_complex_lvalue (enum tree_code code, tree arg, int flag)
  4310. +{
  4311. + /* Handle (a, b) used as an "lvalue". */
  4312. + if (TREE_CODE (arg) == COMPOUND_EXPR)
  4313. + {
  4314. + tree real_result = build_unary_op (code, TREE_OPERAND (arg, 1), 0);
  4315. +
  4316. + /* If this returns a function type, it isn't really being used as
  4317. + an lvalue, so don't issue a warning about it. */
  4318. + if (TREE_CODE (TREE_TYPE (arg)) != FUNCTION_TYPE && !flag)
  4319. + pedantic_lvalue_warning (COMPOUND_EXPR);
  4320. +
  4321. + return build (COMPOUND_EXPR, TREE_TYPE (real_result),
  4322. + TREE_OPERAND (arg, 0), real_result);
  4323. + }
  4324. +
  4325. + /* Handle (a ? b : c) used as an "lvalue". */
  4326. + if (TREE_CODE (arg) == COND_EXPR)
  4327. + {
  4328. + if (!flag)
  4329. + pedantic_lvalue_warning (COND_EXPR);
  4330. + if (TREE_CODE (TREE_TYPE (arg)) != FUNCTION_TYPE && !flag)
  4331. + pedantic_lvalue_warning (COMPOUND_EXPR);
  4332. +
  4333. + return (build_conditional_expr
  4334. + (TREE_OPERAND (arg, 0),
  4335. + build_unary_op (code, TREE_OPERAND (arg, 1), flag),
  4336. + build_unary_op (code, TREE_OPERAND (arg, 2), flag)));
  4337. + }
  4338. +
  4339. + return 0;
  4340. +}
  4341. +
  4342. +/* If pedantic, warn about improper lvalue. CODE is either COND_EXPR
  4343. + COMPOUND_EXPR, or CONVERT_EXPR (for casts). */
  4344. +
  4345. +static void
  4346. +pedantic_lvalue_warning (enum tree_code code)
  4347. +{
  4348. + if (pedantic)
  4349. + switch (code)
  4350. + {
  4351. + case COND_EXPR:
  4352. + pedwarn ("ISO C forbids use of conditional expressions as lvalues");
  4353. + break;
  4354. + case COMPOUND_EXPR:
  4355. + pedwarn ("ISO C forbids use of compound expressions as lvalues");
  4356. + break;
  4357. + default:
  4358. + pedwarn ("ISO C forbids use of cast expressions as lvalues");
  4359. + break;
  4360. + }
  4361. +}
  4362. +
  4363. /* Give an error for storing in something that is 'const'. */
  4364. static void
  4365. @@ -3504,8 +3634,8 @@
  4366. }
  4367. }
  4368. - /* Don't let a cast be an lvalue. */
  4369. - if (value == expr)
  4370. + /* If pedantic, don't let a cast be an lvalue. */
  4371. + if (value == expr && pedantic)
  4372. value = non_lvalue (value);
  4373. return value;
  4374. @@ -3549,22 +3679,103 @@
  4375. if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
  4376. return error_mark_node;
  4377. - if (!lvalue_or_else (lhs, lv_assign))
  4378. - return error_mark_node;
  4379. -
  4380. STRIP_TYPE_NOPS (rhs);
  4381. newrhs = rhs;
  4382. + /* Handle control structure constructs used as "lvalues". */
  4383. +
  4384. + switch (TREE_CODE (lhs))
  4385. + {
  4386. + /* Handle (a, b) used as an "lvalue". */
  4387. + case COMPOUND_EXPR:
  4388. + pedantic_lvalue_warning (COMPOUND_EXPR);
  4389. + newrhs = build_modify_expr (TREE_OPERAND (lhs, 1), modifycode, rhs);
  4390. + if (TREE_CODE (newrhs) == ERROR_MARK)
  4391. + return error_mark_node;
  4392. + return build (COMPOUND_EXPR, lhstype,
  4393. + TREE_OPERAND (lhs, 0), newrhs);
  4394. +
  4395. + /* Handle (a ? b : c) used as an "lvalue". */
  4396. + case COND_EXPR:
  4397. + pedantic_lvalue_warning (COND_EXPR);
  4398. + rhs = save_expr (rhs);
  4399. + {
  4400. + /* Produce (a ? (b = rhs) : (c = rhs))
  4401. + except that the RHS goes through a save-expr
  4402. + so the code to compute it is only emitted once. */
  4403. + tree cond
  4404. + = build_conditional_expr (TREE_OPERAND (lhs, 0),
  4405. + build_modify_expr (TREE_OPERAND (lhs, 1),
  4406. + modifycode, rhs),
  4407. + build_modify_expr (TREE_OPERAND (lhs, 2),
  4408. + modifycode, rhs));
  4409. + if (TREE_CODE (cond) == ERROR_MARK)
  4410. + return cond;
  4411. + /* Make sure the code to compute the rhs comes out
  4412. + before the split. */
  4413. + return build (COMPOUND_EXPR, TREE_TYPE (lhs),
  4414. + /* But cast it to void to avoid an "unused" error. */
  4415. + convert (void_type_node, rhs), cond);
  4416. + }
  4417. + default:
  4418. + break;
  4419. + }
  4420. +
  4421. /* If a binary op has been requested, combine the old LHS value with the RHS
  4422. producing the value we should actually store into the LHS. */
  4423. + /* (TIGCC 20070219) Don't do this for FUNCTION_TYPE, as this would trip over
  4424. + a gcc_assert in default_conversion. An error is later
  4425. + produced in lvalue_or_else. See PR 27721. */
  4426. - if (modifycode != NOP_EXPR)
  4427. + if (modifycode != NOP_EXPR && TREE_CODE (TREE_TYPE (lhs)) != FUNCTION_TYPE)
  4428. {
  4429. lhs = stabilize_reference (lhs);
  4430. newrhs = build_binary_op (modifycode, lhs, rhs, 1);
  4431. }
  4432. + /* Handle a cast used as an "lvalue".
  4433. + We have already performed any binary operator using the value as cast.
  4434. + Now convert the result to the cast type of the lhs,
  4435. + and then true type of the lhs and store it there;
  4436. + then convert result back to the cast type to be the value
  4437. + of the assignment. */
  4438. +
  4439. + switch (TREE_CODE (lhs))
  4440. + {
  4441. + case NOP_EXPR:
  4442. + case CONVERT_EXPR:
  4443. + case FLOAT_EXPR:
  4444. + case FIX_TRUNC_EXPR:
  4445. + case FIX_FLOOR_EXPR:
  4446. + case FIX_ROUND_EXPR:
  4447. + case FIX_CEIL_EXPR:
  4448. + {
  4449. + struct c_expr newrhs_expr;
  4450. + tree inner_lhs = TREE_OPERAND (lhs, 0);
  4451. + tree result;
  4452. + newrhs_expr.value = newrhs;
  4453. + newrhs_expr = default_function_array_conversion (newrhs_expr);
  4454. + newrhs = newrhs_expr.value;
  4455. + result = build_modify_expr (inner_lhs, NOP_EXPR,
  4456. + convert (TREE_TYPE (inner_lhs),
  4457. + convert (lhstype, newrhs)));
  4458. + if (TREE_CODE (result) == ERROR_MARK)
  4459. + return result;
  4460. + pedantic_lvalue_warning (CONVERT_EXPR);
  4461. + return convert (TREE_TYPE (lhs), result);
  4462. + }
  4463. +
  4464. + default:
  4465. + break;
  4466. + }
  4467. +
  4468. + /* Now we have handled acceptable kinds of LHS that are not truly lvalues.
  4469. + Reject anything strange now. */
  4470. +
  4471. + if (!lvalue_or_else (lhs, lv_assign))
  4472. + return error_mark_node;
  4473. +
  4474. /* Give an error for storing in something that is 'const'. */
  4475. if (TREE_READONLY (lhs) || TYPE_READONLY (lhstype)
  4476. @@ -4359,10 +4570,11 @@
  4477. {
  4478. char *ofwhat;
  4479. - error ("%s", _(msgid));
  4480. ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
  4481. if (*ofwhat)
  4482. - error ("(near initialization for %qs)", ofwhat);
  4483. + error ("%s (near initialization for %qs)", _(msgid), ofwhat);
  4484. + else
  4485. + error ("%s", _(msgid));
  4486. }
  4487. /* Issue a pedantic warning for a bad initializer component.
  4488. @@ -4374,10 +4586,11 @@
  4489. {
  4490. char *ofwhat;
  4491. - pedwarn ("%s", _(msgid));
  4492. ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
  4493. if (*ofwhat)
  4494. - pedwarn ("(near initialization for %qs)", ofwhat);
  4495. + pedwarn ("%s (near initialization for %qs)", _(msgid), ofwhat);
  4496. + else
  4497. + pedwarn ("%s", _(msgid));
  4498. }
  4499. /* Issue a warning for a bad initializer component.
  4500. @@ -4389,10 +4602,11 @@
  4501. {
  4502. char *ofwhat;
  4503. - warning (0, "%s", _(msgid));
  4504. ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
  4505. if (*ofwhat)
  4506. - warning (0, "(near initialization for %qs)", ofwhat);
  4507. + warning (0, "%s (near initialization for %qs)", _(msgid), ofwhat);
  4508. + else
  4509. + warning (0, "%s", _(msgid));
  4510. }
  4511. /* If TYPE is an array type and EXPR is a parenthesized string
  4512. diff -Naur gcc-4.1.2.orig/gcc/diagnostic.c gcc-4.1.2-src/gcc/diagnostic.c
  4513. --- gcc-4.1.2.orig/gcc/diagnostic.c 2005-11-04 00:08:18.000000000 +0100
  4514. +++ gcc-4.1.2-src/gcc/diagnostic.c 2007-02-19 02:32:34.000000000 +0100
  4515. @@ -252,9 +252,8 @@
  4516. if (context->abort_on_error)
  4517. real_abort ();
  4518. - fnotice (stderr, "Please submit a full bug report,\n"
  4519. - "with preprocessed source if appropriate.\n"
  4520. - "See %s for instructions.\n", bug_report_url);
  4521. + fnotice (stderr, "Please fill out a bug report form at %s.\n",
  4522. + bug_report_url);
  4523. exit (FATAL_EXIT_CODE);
  4524. case DK_FATAL:
  4525. diff -Naur gcc-4.1.2.orig/gcc/dwarf2.h gcc-4.1.2-src/gcc/dwarf2.h
  4526. --- gcc-4.1.2.orig/gcc/dwarf2.h 2005-06-25 04:02:01.000000000 +0200
  4527. +++ gcc-4.1.2-src/gcc/dwarf2.h 2007-02-19 02:32:34.000000000 +0100
  4528. @@ -352,6 +352,7 @@
  4529. DW_AT_body_begin = 0x2105,
  4530. DW_AT_body_end = 0x2106,
  4531. DW_AT_GNU_vector = 0x2107,
  4532. + DW_AT_regparm_location = 0x2120,
  4533. /* VMS extensions. */
  4534. DW_AT_VMS_rtnbeg_pd_address = 0x2201,
  4535. /* UPC extension. */
  4536. diff -Naur gcc-4.1.2.orig/gcc/dwarf2out.c gcc-4.1.2-src/gcc/dwarf2out.c
  4537. --- gcc-4.1.2.orig/gcc/dwarf2out.c 2006-12-27 23:23:55.000000000 +0100
  4538. +++ gcc-4.1.2-src/gcc/dwarf2out.c 2007-02-19 02:32:34.000000000 +0100
  4539. @@ -2182,8 +2182,11 @@
  4540. emit any EH unwind information. Note that if exceptions aren't
  4541. enabled, we won't have collected nothrow information, and if we
  4542. asked for asynchronous tables, we always want this info. */
  4543. + /* (TIGCC 20050507) We want unwinding tables for debugging purposes only,
  4544. + so we don't want an .eh_frame section we didn't ask for. */
  4545. if (for_eh)
  4546. {
  4547. +#if 0
  4548. bool any_eh_needed = !flag_exceptions || flag_asynchronous_unwind_tables;
  4549. for (i = 0; i < fde_table_in_use; i++)
  4550. @@ -2196,6 +2199,7 @@
  4551. any_eh_needed = true;
  4552. if (! any_eh_needed)
  4553. +#endif /* 0 */
  4554. return;
  4555. }
  4556. @@ -4176,7 +4180,7 @@
  4557. static void decls_for_scope (tree, dw_die_ref, int);
  4558. static int is_redundant_typedef (tree);
  4559. static void gen_namespace_die (tree);
  4560. -static void gen_decl_die (tree, dw_die_ref);
  4561. +static dw_die_ref gen_decl_die (tree, dw_die_ref);
  4562. static dw_die_ref force_decl_die (tree);
  4563. static dw_die_ref force_type_die (tree);
  4564. static dw_die_ref setup_namespace_context (tree, dw_die_ref);
  4565. @@ -4677,6 +4681,8 @@
  4566. return "DW_AT_body_end";
  4567. case DW_AT_GNU_vector:
  4568. return "DW_AT_GNU_vector";
  4569. + case DW_AT_regparm_location:
  4570. + return "DW_AT_regparm_location";
  4571. case DW_AT_VMS_rtnbeg_pd_address:
  4572. return "DW_AT_VMS_rtnbeg_pd_address";
  4573. @@ -9779,14 +9785,7 @@
  4574. int i;
  4575. REAL_VALUE_FROM_CONST_DOUBLE (rv, rtl);
  4576. - real_to_target (val, &rv, GET_MODE (rtl));
  4577. -
  4578. - /* real_to_target puts 32-bit pieces in each long. Pack them. */
  4579. - for (i = 0; i < GET_MODE_SIZE (GET_MODE (rtl)) / 4; i++)
  4580. - {
  4581. - insert_int (val[i], 4, array);
  4582. - array += 4;
  4583. - }
  4584. + REAL_VALUE_TO_TARGET_SMAP_BCD (rv, array);
  4585. }
  4586. /* Attach a DW_AT_const_value attribute for a variable or a parameter which
  4587. @@ -9825,7 +9824,7 @@
  4588. unsigned char *array = ggc_alloc (length);
  4589. insert_float (rtl, array);
  4590. - add_AT_vec (die, DW_AT_const_value, length / 4, 4, array);
  4591. + add_AT_vec (die, DW_AT_const_value, 1, length, array); /* (TIGCC 20050403) */
  4592. }
  4593. else
  4594. {
  4595. @@ -11370,6 +11369,10 @@
  4596. DW_TAG_unspecified_parameters DIE) to represent the types of the formal
  4597. parameters as specified in some function type specification (except for
  4598. those which appear as part of a function *definition*). */
  4599. +/* (TIGCC 20050409) We also want to generate DW_AT_regparm_location
  4600. + information for register parameters so GDB can call the function
  4601. + correctly. We don't use DW_AT_location in order not to conflict with
  4602. + the location list support. */
  4603. static void
  4604. gen_formal_types_die (tree function_or_method_type, dw_die_ref context_die)
  4605. @@ -11378,15 +11381,21 @@
  4606. tree formal_type = NULL;
  4607. tree first_parm_type;
  4608. tree arg;
  4609. + tree function_or_method_decl = NULL_TREE;
  4610. + CUMULATIVE_ARGS cum;
  4611. if (TREE_CODE (function_or_method_type) == FUNCTION_DECL)
  4612. {
  4613. + function_or_method_decl = function_or_method_type;
  4614. arg = DECL_ARGUMENTS (function_or_method_type);
  4615. function_or_method_type = TREE_TYPE (function_or_method_type);
  4616. }
  4617. else
  4618. arg = NULL_TREE;
  4619. + if (function_or_method_decl)
  4620. + INIT_CUMULATIVE_ARGS (cum, function_or_method_type, NULL, function_or_method_decl, 0);
  4621. +
  4622. first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
  4623. /* Make our first pass over the list of formal parameter types and output a
  4624. @@ -11406,6 +11415,17 @@
  4625. || (arg && DECL_ARTIFICIAL (arg)))
  4626. add_AT_flag (parm_die, DW_AT_artificial, 1);
  4627. + if (function_or_method_decl)
  4628. + {
  4629. + rtx argrtx = FUNCTION_ARG(cum, TYPE_MODE (formal_type), formal_type, 0);
  4630. + if (argrtx && GET_CODE (argrtx) == REG && REGNO (argrtx) < FIRST_PSEUDO_REGISTER)
  4631. + {
  4632. + add_AT_location_description (parm_die, DW_AT_regparm_location, reg_loc_descriptor (argrtx));
  4633. + }
  4634. +
  4635. + FUNCTION_ARG_ADVANCE(cum, 0, 0, 0);
  4636. + }
  4637. +
  4638. link = TREE_CHAIN (link);
  4639. if (arg)
  4640. arg = TREE_CHAIN (arg);
  4641. @@ -11509,6 +11529,10 @@
  4642. /* Generate a DIE to represent a declared function (either file-scope or
  4643. block-local). */
  4644. +/* (TIGCC 20050409) We also want to generate DW_AT_regparm_location
  4645. + information for register parameters so GDB can call the function
  4646. + correctly. We don't use DW_AT_location in order not to conflict with
  4647. + the location list support. */
  4648. static void
  4649. gen_subprogram_die (tree decl, dw_die_ref context_die)
  4650. @@ -11521,6 +11545,7 @@
  4651. dw_die_ref old_die = lookup_decl_die (decl);
  4652. int declaration = (current_function_decl != decl
  4653. || class_or_namespace_scope_p (context_die));
  4654. + CUMULATIVE_ARGS cum;
  4655. /* It is possible to have both DECL_ABSTRACT and DECLARATION be true if we
  4656. started to generate the abstract instance of an inline, decided to output
  4657. @@ -11759,6 +11784,8 @@
  4658. tree arg_decls = DECL_ARGUMENTS (decl);
  4659. tree parm;
  4660. + INIT_CUMULATIVE_ARGS (cum, TREE_TYPE (decl), NULL, decl, 0);
  4661. +
  4662. /* When generating DIEs, generate the unspecified_parameters DIE
  4663. instead if we come across the arg "__builtin_va_alist" */
  4664. for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
  4665. @@ -11769,7 +11796,16 @@
  4666. "__builtin_va_alist"))
  4667. gen_unspecified_parameters_die (parm, subr_die);
  4668. else
  4669. - gen_decl_die (parm, subr_die);
  4670. + {
  4671. + dw_die_ref parm_die = gen_decl_die (parm, subr_die);
  4672. + rtx argrtx = FUNCTION_ARG(cum, TYPE_MODE (TREE_TYPE (parm)), TREE_TYPE (parm), 0);
  4673. + if (parm_die && argrtx && GET_CODE (argrtx) == REG && REGNO (argrtx) < FIRST_PSEUDO_REGISTER)
  4674. + {
  4675. + add_AT_location_description (parm_die, DW_AT_regparm_location, reg_loc_descriptor (argrtx));
  4676. + }
  4677. + }
  4678. +
  4679. + FUNCTION_ARG_ADVANCE(cum, 0, 0, 0);
  4680. }
  4681. /* Decide whether we need an unspecified_parameters DIE at the end.
  4682. @@ -13002,14 +13038,15 @@
  4683. }
  4684. /* Generate Dwarf debug information for a decl described by DECL. */
  4685. +/* (TIGCC 20050409) Return the DIE for the parameter case. */
  4686. -static void
  4687. +static dw_die_ref
  4688. gen_decl_die (tree decl, dw_die_ref context_die)
  4689. {
  4690. tree origin;
  4691. if (DECL_P (decl) && DECL_IGNORED_P (decl))
  4692. - return;
  4693. + return NULL;
  4694. switch (TREE_CODE (decl))
  4695. {
  4696. @@ -13152,8 +13189,7 @@
  4697. case PARM_DECL:
  4698. gen_type_die (TREE_TYPE (decl), context_die);
  4699. - gen_formal_parameter_die (decl, context_die);
  4700. - break;
  4701. + return gen_formal_parameter_die (decl, context_die);
  4702. case NAMESPACE_DECL:
  4703. gen_namespace_die (decl);
  4704. @@ -13164,6 +13200,8 @@
  4705. gcc_assert ((int)TREE_CODE (decl) > NUM_TREE_CODES);
  4706. break;
  4707. }
  4708. +
  4709. + return NULL;
  4710. }
  4711. /* Add Ada "use" clause information for SGI Workshop debugger. */
  4712. @@ -13486,9 +13524,12 @@
  4713. unused debug types, then we must emit .file here. If we are eliminating
  4714. unused debug types, then this will be done by the maybe_emit_file call in
  4715. prune_unused_types_walk_attribs. */
  4716. + /* (TIGCC 20051220) Don't return the result of maybe_emit_file, it will cause
  4717. + maybe_emit_file to be called twice on the same fileno.
  4718. + -- Kevin Kofler */
  4719. if (DWARF2_ASM_LINE_DEBUG_INFO && ! flag_eliminate_unused_debug_types)
  4720. - return maybe_emit_file (i);
  4721. + /*return*/ maybe_emit_file (i);
  4722. return i;
  4723. }
  4724. @@ -13611,7 +13652,10 @@
  4725. if (debug_info_level >= DINFO_LEVEL_NORMAL
  4726. && line != 0)
  4727. {
  4728. - current_function_section (current_function_decl);
  4729. + /* (TIGCC 20050424) We also get called for top-level ASM with no
  4730. + current_function_decl, so don't crash in that case. */
  4731. + if (current_function_decl)
  4732. + current_function_section (current_function_decl);
  4733. /* If requested, emit something human-readable. */
  4734. if (flag_debug_asm)
  4735. @@ -13631,10 +13675,10 @@
  4736. line_info_table_in_use++;
  4737. /* Indicate that multiple line number tables exist. */
  4738. - if (DECL_SECTION_NAME (current_function_decl))
  4739. + if (current_function_decl && DECL_SECTION_NAME (current_function_decl))
  4740. separate_line_info_table_in_use++;
  4741. }
  4742. - else if (DECL_SECTION_NAME (current_function_decl))
  4743. + else if (current_function_decl && DECL_SECTION_NAME (current_function_decl))
  4744. {
  4745. dw_separate_line_info_ref line_info;
  4746. targetm.asm_out.internal_label (asm_out_file, SEPARATE_LINE_CODE_LABEL,
  4747. diff -Naur gcc-4.1.2.orig/gcc/emit-rtl.c gcc-4.1.2-src/gcc/emit-rtl.c
  4748. --- gcc-4.1.2.orig/gcc/emit-rtl.c 2006-01-03 23:37:46.000000000 +0100
  4749. +++ gcc-4.1.2-src/gcc/emit-rtl.c 2007-02-19 02:32:34.000000000 +0100
  4750. @@ -104,8 +104,10 @@
  4751. REAL_VALUE_TYPE dconstm2;
  4752. REAL_VALUE_TYPE dconsthalf;
  4753. REAL_VALUE_TYPE dconstthird;
  4754. +#if 0
  4755. REAL_VALUE_TYPE dconstpi;
  4756. REAL_VALUE_TYPE dconste;
  4757. +#endif /* 0 */
  4758. /* All references to the following fixed hard registers go through
  4759. these unique rtl objects. On machines where the frame-pointer and
  4760. @@ -240,8 +242,8 @@
  4761. return (CONST_DOUBLE_LOW (a) == CONST_DOUBLE_LOW (b)
  4762. && CONST_DOUBLE_HIGH (a) == CONST_DOUBLE_HIGH (b));
  4763. else
  4764. - return real_identical (CONST_DOUBLE_REAL_VALUE (a),
  4765. - CONST_DOUBLE_REAL_VALUE (b));
  4766. + return REAL_VALUES_IDENTICAL (*CONST_DOUBLE_REAL_VALUE (a),
  4767. + *CONST_DOUBLE_REAL_VALUE (b));
  4768. }
  4769. /* Returns a hash code for X (which is a really a mem_attrs *). */
  4770. @@ -1334,10 +1336,62 @@
  4771. && (GET_MODE_SIZE (mode) < UNITS_PER_WORD))
  4772. return 0;
  4773. - /* If we want a word outside OP, return zero. */
  4774. + /* If we want a word outside OP, return zero, except for special BFmode cases. */
  4775. if (mode != BLKmode
  4776. && (offset + 1) * UNITS_PER_WORD > GET_MODE_SIZE (mode))
  4777. + {
  4778. + if (mode == BFmode)
  4779. + {
  4780. + if (GET_CODE (op) == MEM)
  4781. + {
  4782. + rtx addr = plus_constant (XEXP (op, 0), offset * UNITS_PER_WORD);
  4783. + rtx new;
  4784. +
  4785. + if (validate_address)
  4786. + {
  4787. + if (reload_completed)
  4788. + {
  4789. + if (! strict_memory_address_p (HImode, addr))
  4790. + return 0;
  4791. + }
  4792. + else
  4793. + addr = memory_address (HImode, addr);
  4794. + }
  4795. +
  4796. + new = gen_rtx_MEM (HImode, addr);
  4797. +
  4798. + MEM_COPY_ATTRIBUTES (new, op);
  4799. + MEM_READONLY_P (new) = MEM_READONLY_P (op);
  4800. +
  4801. + return new;
  4802. + }
  4803. + else if (REG_P (op))
  4804. + {
  4805. + if (REGNO (op) < FIRST_PSEUDO_REGISTER
  4806. + && REGNO (op) + offset >= FIRST_PSEUDO_REGISTER)
  4807. + return 0;
  4808. +
  4809. + if (REGNO (op) < FIRST_PSEUDO_REGISTER
  4810. + && (! HARD_REGNO_MODE_OK (REGNO (op), HImode)
  4811. + || ! HARD_REGNO_MODE_OK (REGNO (op) + offset, HImode)))
  4812. + return 0;
  4813. + else if (REGNO (op) >= FIRST_PSEUDO_REGISTER
  4814. + || (REG_FUNCTION_VALUE_P (op))
  4815. + || op == frame_pointer_rtx
  4816. +#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
  4817. + || op == arg_pointer_rtx
  4818. +#endif
  4819. + || op == stack_pointer_rtx)
  4820. + return gen_rtx_SUBREG (HImode, op, offset);
  4821. + else
  4822. + return gen_rtx_REG (HImode, REGNO (op) + offset);
  4823. + }
  4824. + else if (GET_CODE (op) == SUBREG)
  4825. + return gen_rtx_SUBREG (HImode, SUBREG_REG (op), offset + SUBREG_BYTE (op) / UNITS_PER_WORD);
  4826. + }
  4827. + else
  4828. return const0_rtx;
  4829. + }
  4830. /* Form a new MEM at the requested address. */
  4831. if (MEM_P (op))
  4832. @@ -5310,17 +5364,17 @@
  4833. REAL_VALUE_FROM_INT (dconstm1, -1, -1, double_mode);
  4834. REAL_VALUE_FROM_INT (dconstm2, -2, -1, double_mode);
  4835. - dconsthalf = dconst1;
  4836. - SET_REAL_EXP (&dconsthalf, REAL_EXP (&dconsthalf) - 1);
  4837. -
  4838. + real_arithmetic (&dconsthalf, RDIV_EXPR, &dconst1, &dconst2);
  4839. real_arithmetic (&dconstthird, RDIV_EXPR, &dconst1, &dconst3);
  4840. +#if 0
  4841. /* Initialize mathematical constants for constant folding builtins.
  4842. These constants need to be given to at least 160 bits precision. */
  4843. real_from_string (&dconstpi,
  4844. "3.1415926535897932384626433832795028841971693993751058209749445923078");
  4845. real_from_string (&dconste,
  4846. "2.7182818284590452353602874713526624977572470936999595749669676277241");
  4847. +#endif /* 0 */
  4848. for (i = 0; i < (int) ARRAY_SIZE (const_tiny_rtx); i++)
  4849. {
  4850. diff -Naur gcc-4.1.2.orig/gcc/explow.c gcc-4.1.2-src/gcc/explow.c
  4851. --- gcc-4.1.2.orig/gcc/explow.c 2005-08-02 22:39:24.000000000 +0200
  4852. +++ gcc-4.1.2-src/gcc/explow.c 2007-02-19 02:32:34.000000000 +0100
  4853. @@ -569,6 +569,10 @@
  4854. {
  4855. rtx temp = gen_reg_rtx (mode);
  4856. + if (GET_MODE (x) == BFmode && mode != BFmode)
  4857. + convert_move (x, temp, 0);
  4858. + else
  4859. + {
  4860. /* If not an operand, must be an address with PLUS and MULT so
  4861. do the computation. */
  4862. if (! general_operand (x, VOIDmode))
  4863. @@ -577,6 +581,7 @@
  4864. gcc_assert (GET_MODE (x) == mode || GET_MODE (x) == VOIDmode);
  4865. if (x != temp)
  4866. emit_move_insn (temp, x);
  4867. + }
  4868. return temp;
  4869. }
  4870. diff -Naur gcc-4.1.2.orig/gcc/expr.c gcc-4.1.2-src/gcc/expr.c
  4871. --- gcc-4.1.2.orig/gcc/expr.c 2006-11-02 18:18:52.000000000 +0100
  4872. +++ gcc-4.1.2-src/gcc/expr.c 2007-02-19 02:32:34.000000000 +0100
  4873. @@ -748,7 +748,7 @@
  4874. if (GET_MODE (x) != VOIDmode)
  4875. oldmode = GET_MODE (x);
  4876. - if (mode == oldmode)
  4877. + if (mode == oldmode || oldmode == BFmode)
  4878. return x;
  4879. /* There is one case that we must handle specially: If we are converting
  4880. @@ -1351,6 +1351,7 @@
  4881. dst_tree = make_tree (ptr_type_node, dst_addr);
  4882. src_tree = make_tree (ptr_type_node, src_addr);
  4883. +#if 0
  4884. size_mode = TYPE_MODE (sizetype);
  4885. size = convert_to_mode (size_mode, size, 1);
  4886. @@ -1360,8 +1361,8 @@
  4887. memcpy in this context. This could be a user call to memcpy and
  4888. the user may wish to examine the return value from memcpy. For
  4889. targets where libcalls and normal calls have different conventions
  4890. - for returning pointers, we could end up generating incorrect code. */
  4891. -
  4892. + for returning pointers, we could end up generating incorrect code.
  4893. + (TIGCC 20050205) NO, the "incorrect" code is actually correct for us! */
  4894. size_tree = make_tree (sizetype, size);
  4895. fn = emit_block_move_libcall_fn (true);
  4896. @@ -1376,6 +1377,14 @@
  4897. CALL_EXPR_TAILCALL (call_expr) = tailcall;
  4898. retval = expand_expr (call_expr, NULL_RTX, VOIDmode, 0);
  4899. +#endif /* 0 */
  4900. +
  4901. + retval = emit_library_call_value (memcpy_libfunc, NULL_RTX, LCT_NORMAL,
  4902. + VOIDmode, 3, dst_addr, Pmode,
  4903. + src_addr, Pmode,
  4904. + convert_to_mode (TYPE_MODE (sizetype),
  4905. + size, TYPE_UNSIGNED (sizetype)),
  4906. + TYPE_MODE (sizetype));
  4907. return retval;
  4908. }
  4909. @@ -2500,6 +2509,7 @@
  4910. object = copy_to_mode_reg (Pmode, XEXP (object, 0));
  4911. +#if 0
  4912. size_mode = TYPE_MODE (sizetype);
  4913. size = convert_to_mode (size_mode, size, 1);
  4914. size = copy_to_mode_reg (size_mode, size);
  4915. @@ -2508,7 +2518,8 @@
  4916. memset in this context. This could be a user call to memset and
  4917. the user may wish to examine the return value from memset. For
  4918. targets where libcalls and normal calls have different conventions
  4919. - for returning pointers, we could end up generating incorrect code. */
  4920. + for returning pointers, we could end up generating incorrect code.
  4921. + (TIGCC 20050205) NO, the "incorrect" code is actually correct for us! */
  4922. object_tree = make_tree (ptr_type_node, object);
  4923. size_tree = make_tree (sizetype, size);
  4924. @@ -2525,6 +2536,15 @@
  4925. CALL_EXPR_TAILCALL (call_expr) = tailcall;
  4926. retval = expand_expr (call_expr, NULL_RTX, VOIDmode, 0);
  4927. +#endif /* 0 */
  4928. +
  4929. + /* Note: Our memset libcall expects a short integer zero even with -mlong. */
  4930. + retval = emit_library_call_value (memset_libfunc, NULL_RTX, LCT_NORMAL,
  4931. + VOIDmode, 3, object, Pmode,
  4932. + const0_rtx, TYPE_MODE (short_integer_type_node),
  4933. + convert_to_mode (TYPE_MODE (sizetype),
  4934. + size, TYPE_UNSIGNED (sizetype)),
  4935. + TYPE_MODE (sizetype));
  4936. return retval;
  4937. }
  4938. @@ -2543,8 +2563,10 @@
  4939. tree fn, args;
  4940. fn = get_identifier ("memset");
  4941. + /* TIGCC Patch: The memset libcall expects a short integer zero even with
  4942. + -mlong. */
  4943. args = build_function_type_list (ptr_type_node, ptr_type_node,
  4944. - integer_type_node, sizetype,
  4945. + short_integer_type_node, sizetype,
  4946. NULL_TREE);
  4947. fn = build_decl (FUNCTION_DECL, fn, args);
  4948. @@ -2954,14 +2976,21 @@
  4949. if (push_operand (x, mode))
  4950. return emit_move_complex_push (mode, x, y);
  4951. + /* For memory to memory moves, optimal behavior can be had with the
  4952. + existing block move logic. */
  4953. + /* (TIGCC 20050323) ... and this is indeed the case for our target, despite
  4954. + claims to the contrary in PR rtl-optimization/20306. -- Kevin Kofler */
  4955. + if (MEM_P (x) && MEM_P (y))
  4956. + {
  4957. + emit_block_move (x, y, GEN_INT (GET_MODE_SIZE (mode)),
  4958. + BLOCK_OP_NO_LIBCALL);
  4959. + return get_last_insn ();
  4960. + }
  4961. +
  4962. /* See if we can coerce the target into moving both values at once. */
  4963. - /* Move floating point as parts. */
  4964. - if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
  4965. - && mov_optab->handlers[GET_MODE_INNER (mode)].insn_code != CODE_FOR_nothing)
  4966. - try_int = false;
  4967. /* Not possible if the values are inherently not adjacent. */
  4968. - else if (GET_CODE (x) == CONCAT || GET_CODE (y) == CONCAT)
  4969. + if (GET_CODE (x) == CONCAT || GET_CODE (y) == CONCAT)
  4970. try_int = false;
  4971. /* Is possible if both are registers (or subregs of registers). */
  4972. else if (register_operand (x, mode) && register_operand (y, mode))
  4973. @@ -2979,18 +3008,7 @@
  4974. if (try_int)
  4975. {
  4976. - rtx ret;
  4977. -
  4978. - /* For memory to memory moves, optimal behavior can be had with the
  4979. - existing block move logic. */
  4980. - if (MEM_P (x) && MEM_P (y))
  4981. - {
  4982. - emit_block_move (x, y, GEN_INT (GET_MODE_SIZE (mode)),
  4983. - BLOCK_OP_NO_LIBCALL);
  4984. - return get_last_insn ();
  4985. - }
  4986. -
  4987. - ret = emit_move_via_integer (mode, x, y, true);
  4988. + rtx ret = emit_move_via_integer (mode, x, y, true);
  4989. if (ret)
  4990. return ret;
  4991. }
  4992. @@ -3230,6 +3248,9 @@
  4993. else
  4994. oldcost = rtx_cost (force_const_mem (dstmode, y), SET);
  4995. +/* (TIGCC) We do not implement exact_real_truncate and there is no narrower
  4996. + float mode anyway. -- Kevin Kofler */
  4997. +#if 0
  4998. for (srcmode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (orig_srcmode));
  4999. srcmode != orig_srcmode;
  5000. srcmode = GET_MODE_WIDER_MODE (srcmode))
  5001. @@ -3279,6 +3300,7 @@
  5002. return last_insn;
  5003. }
  5004. +#endif /* 0 */
  5005. return NULL_RTX;
  5006. }
  5007. diff -Naur gcc-4.1.2.orig/gcc/final.c gcc-4.1.2-src/gcc/final.c
  5008. --- gcc-4.1.2.orig/gcc/final.c 2005-12-20 05:51:27.000000000 +0100
  5009. +++ gcc-4.1.2-src/gcc/final.c 2007-02-19 02:32:34.000000000 +0100
  5010. @@ -3091,11 +3091,23 @@
  5011. else if (letter == 'l')
  5012. output_asm_label (operands[opnum]);
  5013. else if (letter == 'a')
  5014. + {
  5015. output_address (operands[opnum]);
  5016. + /* TIGCC Patch: This is a very bad try to implement addresses
  5017. + relative to a register. See m68k.c
  5018. + (TIGCC 20040808) Added CONST here (and below) too. -- Kevin Kofler */
  5019. + if (TARGET_REG_RELATIVE && (GET_CODE (operands[opnum]) == SYMBOL_REF || GET_CODE (operands[opnum]) == LABEL_REF || GET_CODE (operands[opnum]) == CODE_LABEL || GET_CODE (operands[opnum]) == CONST))
  5020. + fprintf (asm_out_file, "-__relation(%%%s)", TARGET_RELATION_REG);
  5021. + }
  5022. else if (letter == 'c')
  5023. {
  5024. if (CONSTANT_ADDRESS_P (operands[opnum]))
  5025. + {
  5026. output_addr_const (asm_out_file, operands[opnum]);
  5027. + /* TIGCC Patch: See above */
  5028. + if (TARGET_REG_RELATIVE && (GET_CODE (operands[opnum]) == SYMBOL_REF || GET_CODE (operands[opnum]) == LABEL_REF || GET_CODE (operands[opnum]) == CODE_LABEL || GET_CODE (operands[opnum]) == CONST))
  5029. + fprintf (asm_out_file, "-__relation(%%%s)", TARGET_RELATION_REG);
  5030. + }
  5031. else
  5032. output_operand (operands[opnum], 'c');
  5033. }
  5034. @@ -3108,6 +3120,9 @@
  5035. {
  5036. putc ('-', asm_out_file);
  5037. output_addr_const (asm_out_file, operands[opnum]);
  5038. + /* TIGCC Patch: See above */
  5039. + if (TARGET_REG_RELATIVE && (GET_CODE (operands[opnum]) == SYMBOL_REF || GET_CODE (operands[opnum]) == LABEL_REF || GET_CODE (operands[opnum]) == CODE_LABEL))
  5040. + fprintf (asm_out_file, "-__relation(%%%s)", TARGET_RELATION_REG);
  5041. }
  5042. }
  5043. else
  5044. @@ -3619,6 +3634,8 @@
  5045. }
  5046. else
  5047. {
  5048. + gcc_unreachable ();
  5049. +#if 0
  5050. REAL_VALUE_TYPE r;
  5051. long l[2];
  5052. REAL_VALUE_FROM_CONST_DOUBLE (r, value);
  5053. @@ -3647,6 +3664,7 @@
  5054. *first = GEN_INT (l[0]);
  5055. *second = GEN_INT (l[1]);
  5056. +#endif /* 0 */
  5057. }
  5058. }
  5059. diff -Naur gcc-4.1.2.orig/gcc/flags.h gcc-4.1.2-src/gcc/flags.h
  5060. --- gcc-4.1.2.orig/gcc/flags.h 2005-06-29 05:01:27.000000000 +0200
  5061. +++ gcc-4.1.2-src/gcc/flags.h 2007-02-19 02:32:34.000000000 +0100
  5062. @@ -287,4 +287,10 @@
  5063. #define HONOR_SIGN_DEPENDENT_ROUNDING(MODE) \
  5064. (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) && flag_rounding_math)
  5065. +/* (TIGCC) Make compound literals (cast constructors) global for backwards compatibility. */
  5066. +extern int flag_global_compound_literals;
  5067. +
  5068. +/* (TIGCC 20040727) When merging constants, also merge constant pools. */
  5069. +extern int flag_merge_constant_pools;
  5070. +
  5071. #endif /* ! GCC_FLAGS_H */
  5072. diff -Naur gcc-4.1.2.orig/gcc/fold-const.c gcc-4.1.2-src/gcc/fold-const.c
  5073. --- gcc-4.1.2.orig/gcc/fold-const.c 2007-01-03 09:15:24.000000000 +0100
  5074. +++ gcc-4.1.2-src/gcc/fold-const.c 2007-02-19 02:32:34.000000000 +0100
  5075. @@ -1569,7 +1569,7 @@
  5076. if ((flag_rounding_math
  5077. || (REAL_MODE_FORMAT_COMPOSITE_P (mode)
  5078. && !flag_unsafe_math_optimizations))
  5079. - && (inexact || !real_identical (&result, &value)))
  5080. + && (inexact || !REAL_VALUES_IDENTICAL (result, value)))
  5081. return NULL_TREE;
  5082. t = build_real (type, result);
  5083. @@ -1776,6 +1776,7 @@
  5084. FP-to-integer conversion is unspecified upon overflow. */
  5085. HOST_WIDE_INT high, low;
  5086. +#if 0
  5087. REAL_VALUE_TYPE r;
  5088. REAL_VALUE_TYPE x = TREE_REAL_CST (arg1);
  5089. @@ -1800,9 +1801,12 @@
  5090. default:
  5091. gcc_unreachable ();
  5092. }
  5093. +#else
  5094. + REAL_VALUE_TYPE r = TREE_REAL_CST (arg1);
  5095. +#endif /* 0 */
  5096. /* If R is NaN, return zero and show we have an overflow. */
  5097. - if (REAL_VALUE_ISNAN (r))
  5098. + if (REAL_VALUE_ISNANUINF (r))
  5099. {
  5100. overflow = 1;
  5101. high = 0;
  5102. @@ -2111,7 +2115,7 @@
  5103. /* When pedantic, return an expr equal to X but certainly not valid as a
  5104. pedantic lvalue. Otherwise, return X. */
  5105. -static tree
  5106. +tree
  5107. pedantic_non_lvalue (tree x)
  5108. {
  5109. if (pedantic_lvalues)
  5110. @@ -5717,6 +5721,10 @@
  5111. if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type)))
  5112. return true;
  5113. + /* (TIGCC 20050210) This is invalid independently of the rounding mode and the
  5114. + type of the zero for 3-sign-zeros. */
  5115. + return false;
  5116. +
  5117. /* Treat x + -0 as x - 0 and x - -0 as x + 0. */
  5118. if (TREE_CODE (addend) == REAL_CST
  5119. && REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (addend)))
  5120. @@ -5902,6 +5910,7 @@
  5121. }
  5122. break;
  5123. +#if 0 /* (TIGCC 20050205) */
  5124. case EQ_EXPR:
  5125. case GE_EXPR:
  5126. /* x == +Inf and x >= +Inf are always equal to x > DBL_MAX. */
  5127. @@ -5930,6 +5939,7 @@
  5128. temp = fold_build2 (neg ? LT_EXPR : GT_EXPR, type,
  5129. arg0, build_real (TREE_TYPE (arg0), max));
  5130. return fold_build1 (TRUTH_NOT_EXPR, type, temp);
  5131. +#endif /* 0 */
  5132. default:
  5133. break;
  5134. @@ -7025,6 +7035,21 @@
  5135. } /* switch (code) */
  5136. }
  5137. +/* Return 1 if EXPR is the real constant UNSIGNED_ZERO. */
  5138. +
  5139. +static int
  5140. +real_uzerop (tree expr)
  5141. +{
  5142. + STRIP_NOPS (expr);
  5143. +
  5144. + return ((TREE_CODE (expr) == REAL_CST
  5145. + && ! TREE_CONSTANT_OVERFLOW (expr)
  5146. + && REAL_VALUES_IDENTICAL (TREE_REAL_CST (expr), UNSIGNED_ZERO))
  5147. + || (TREE_CODE (expr) == COMPLEX_CST
  5148. + && real_uzerop (TREE_REALPART (expr))
  5149. + && real_uzerop (TREE_IMAGPART (expr))));
  5150. +}
  5151. +
  5152. /* Fold a binary expression of code CODE and type TYPE with operands
  5153. OP0 and OP1. Return the folded expression if folding is
  5154. successful. Otherwise, return NULL_TREE. */
  5155. @@ -7847,8 +7872,11 @@
  5156. when x is NaN, since x * 0 is also NaN. Nor are they the
  5157. same in modes with signed zeros, since multiplying a
  5158. negative value by 0 gives -0, not +0. */
  5159. + /* (TIGCC 20050210) We can do this for UNSIGNED_ZERO even when honoring
  5160. + signed zeros. */
  5161. if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))
  5162. - && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0)))
  5163. + && (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0)))
  5164. + || real_uzerop (arg1))
  5165. && real_zerop (arg1))
  5166. return omit_one_operand (type, arg1, arg0);
  5167. /* In IEEE floating point, x*1 is not equivalent to x for snans. */
  5168. @@ -9065,7 +9093,7 @@
  5169. build_real (TREE_TYPE (arg1), dconst0));
  5170. /* x != NaN is always true, other ops are always false. */
  5171. - if (REAL_VALUE_ISNAN (cst)
  5172. + if (REAL_VALUE_ISNANUINF (cst)
  5173. && ! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1))))
  5174. {
  5175. tem = (code == NE_EXPR) ? integer_one_node : integer_zero_node;
  5176. @@ -9839,7 +9867,7 @@
  5177. /* If the first operand is NaN, the result is constant. */
  5178. if (TREE_CODE (arg0) == REAL_CST
  5179. - && REAL_VALUE_ISNAN (TREE_REAL_CST (arg0))
  5180. + && REAL_VALUE_ISNANUINF (TREE_REAL_CST (arg0))
  5181. && (code != LTGT_EXPR || ! flag_trapping_math))
  5182. {
  5183. t1 = (code == ORDERED_EXPR || code == LTGT_EXPR)
  5184. @@ -9850,7 +9878,7 @@
  5185. /* If the second operand is NaN, the result is constant. */
  5186. if (TREE_CODE (arg1) == REAL_CST
  5187. - && REAL_VALUE_ISNAN (TREE_REAL_CST (arg1))
  5188. + && REAL_VALUE_ISNANUINF (TREE_REAL_CST (arg1))
  5189. && (code != LTGT_EXPR || ! flag_trapping_math))
  5190. {
  5191. t1 = (code == ORDERED_EXPR || code == LTGT_EXPR)
  5192. @@ -9888,12 +9916,12 @@
  5193. case COMPOUND_EXPR:
  5194. /* When pedantic, a compound expression can be neither an lvalue
  5195. nor an integer constant expression. */
  5196. - if (TREE_SIDE_EFFECTS (arg0) || TREE_CONSTANT (arg1))
  5197. + if (TREE_SIDE_EFFECTS (arg0) || pedantic)
  5198. return NULL_TREE;
  5199. /* Don't let (0, 0) be null pointer constant. */
  5200. - tem = integer_zerop (arg1) ? build1 (NOP_EXPR, type, arg1)
  5201. - : fold_convert (type, arg1);
  5202. - return pedantic_non_lvalue (tem);
  5203. + if (integer_zerop (arg1))
  5204. + return build1 (NOP_EXPR, type, arg1);
  5205. + return convert (type, arg1);
  5206. case COMPLEX_EXPR:
  5207. if (wins)
  5208. @@ -11355,7 +11383,11 @@
  5209. }
  5210. case REAL_CST:
  5211. - t = build_real (type, REAL_VALUE_NEGATE (TREE_REAL_CST (arg0)));
  5212. + {
  5213. + REAL_VALUE_TYPE x = TREE_REAL_CST (arg0);
  5214. + x = REAL_VALUE_NEGATE (x);
  5215. + t = build_real (type, x);
  5216. + }
  5217. break;
  5218. default:
  5219. @@ -11401,10 +11433,14 @@
  5220. break;
  5221. case REAL_CST:
  5222. - if (REAL_VALUE_NEGATIVE (TREE_REAL_CST (arg0)))
  5223. - t = build_real (type, REAL_VALUE_NEGATE (TREE_REAL_CST (arg0)));
  5224. - else
  5225. - t = arg0;
  5226. + {
  5227. + REAL_VALUE_TYPE x = TREE_REAL_CST (arg0);
  5228. + if (REAL_VALUE_NEGATIVE (x))
  5229. + t = build_real (type,
  5230. + REAL_VALUE_NEGATE (x));
  5231. + else
  5232. + t = arg0;
  5233. + }
  5234. break;
  5235. default:
  5236. @@ -11452,7 +11488,7 @@
  5237. const REAL_VALUE_TYPE *c1 = TREE_REAL_CST_PTR (op1);
  5238. /* Handle the cases where either operand is a NaN. */
  5239. - if (real_isnan (c0) || real_isnan (c1))
  5240. + if (REAL_VALUE_ISNANUINF (*c0) || REAL_VALUE_ISNANUINF (*c1))
  5241. {
  5242. switch (code)
  5243. {
  5244. diff -Naur gcc-4.1.2.orig/gcc/function.c gcc-4.1.2-src/gcc/function.c
  5245. --- gcc-4.1.2.orig/gcc/function.c 2006-11-28 13:01:45.000000000 +0100
  5246. +++ gcc-4.1.2-src/gcc/function.c 2007-02-19 02:32:34.000000000 +0100
  5247. @@ -5592,3 +5592,28 @@
  5248. #include "gt-function.h"
  5249. +
  5250. +/* begin-TIGCC-local (regparms): explicit register specification for parameters */
  5251. +/* Return 1 if an argument for the current function was passed in
  5252. + register REGNO. */
  5253. +
  5254. +int
  5255. +function_arg_regno_p (int regno)
  5256. +{
  5257. + tree parm = DECL_ARGUMENTS (current_function_decl);
  5258. + for (; parm; parm = TREE_CHAIN (parm))
  5259. + {
  5260. + rtx incoming = DECL_INCOMING_RTL (parm);
  5261. + if (GET_CODE (incoming) == REG)
  5262. + {
  5263. + int incoming_reg;
  5264. + incoming_reg = REGNO (incoming);
  5265. + if (regno >= incoming_reg &&
  5266. + regno < incoming_reg + HARD_REGNO_NREGS (incoming_reg,
  5267. + GET_MODE (incoming)))
  5268. + return 1;
  5269. + }
  5270. + }
  5271. + return 0;
  5272. +}
  5273. +/* end-TIGCC-local (regparms) */
  5274. diff -Naur gcc-4.1.2.orig/gcc/function.h gcc-4.1.2-src/gcc/function.h
  5275. --- gcc-4.1.2.orig/gcc/function.h 2005-08-19 23:16:20.000000000 +0200
  5276. +++ gcc-4.1.2-src/gcc/function.h 2007-02-19 02:32:34.000000000 +0100
  5277. @@ -574,4 +574,10 @@
  5278. extern bool reference_callee_copied (CUMULATIVE_ARGS *, enum machine_mode,
  5279. tree, bool);
  5280. +/* begin-TIGCC-local (regparms): explicit register specification for parameters */
  5281. +/* Return 1 if an argument for the current function was passed in
  5282. + register REGNO. */
  5283. +int function_arg_regno_p (int regno);
  5284. +/* end-TIGCC-local (regparms) */
  5285. +
  5286. #endif /* GCC_FUNCTION_H */
  5287. diff -Naur gcc-4.1.2.orig/gcc/gcc.c gcc-4.1.2-src/gcc/gcc.c
  5288. --- gcc-4.1.2.orig/gcc/gcc.c 2006-11-07 15:26:21.000000000 +0100
  5289. +++ gcc-4.1.2-src/gcc/gcc.c 2007-02-19 02:32:34.000000000 +0100
  5290. @@ -1458,6 +1458,7 @@
  5291. #define MD_STARTFILE_PREFIX_1 ""
  5292. #endif
  5293. +#if 0 /* (TIGCC 20040104) Don't hardcode any prefix at compile time. */
  5294. static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
  5295. static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/";
  5296. static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/";
  5297. @@ -1475,6 +1476,7 @@
  5298. static const char *tooldir_prefix;
  5299. static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
  5300. +#endif /* 0 */
  5301. static const char *standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX;
  5302. @@ -1546,6 +1548,7 @@
  5303. INIT_STATIC_SPEC ("multilib_options", &multilib_options),
  5304. INIT_STATIC_SPEC ("linker", &linker_name_spec),
  5305. INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec),
  5306. +#if 0 /* (TIGCC 20040104) Don't hardcode any prefix at compile time. */
  5307. INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix),
  5308. INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix),
  5309. INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1),
  5310. @@ -1553,6 +1556,7 @@
  5311. INIT_STATIC_SPEC ("sysroot_spec", &sysroot_spec),
  5312. INIT_STATIC_SPEC ("sysroot_suffix_spec", &sysroot_suffix_spec),
  5313. INIT_STATIC_SPEC ("sysroot_hdrs_suffix_spec", &sysroot_hdrs_suffix_spec),
  5314. +#endif /* 0 */
  5315. };
  5316. #ifdef EXTRA_SPECS /* additional specs needed */
  5317. @@ -2437,11 +2441,21 @@
  5318. if (stat (name, &st) < 0
  5319. || S_ISDIR (st.st_mode))
  5320. return -1;
  5321. +
  5322. +#ifdef _WIN32
  5323. +/* (TIGCC 20070209) Vista's MSVCRT.DLL doesn't like X_OK, so translate to R_OK. */
  5324. + return access (name, R_OK);
  5325. +#endif
  5326. }
  5327. return access (name, mode);
  5328. }
  5329. +#ifdef _WIN32
  5330. +#undef access
  5331. +#define access access_check
  5332. +#endif
  5333. +
  5334. /* Search for NAME using the prefix list PREFIXES. MODE is passed to
  5335. access to check permissions.
  5336. Return 0 if not found, otherwise return its name, allocated with malloc. */
  5337. @@ -3149,7 +3163,9 @@
  5338. process_command (int argc, const char **argv)
  5339. {
  5340. int i;
  5341. +#if 0 /* (TIGCC 20040104) Don't use environment variables. */
  5342. const char *temp;
  5343. +#endif /* 0 */
  5344. char *temp1;
  5345. const char *spec_lang = 0;
  5346. int last_language_n_infiles;
  5347. @@ -3159,7 +3175,9 @@
  5348. int j;
  5349. #endif
  5350. +#if 0 /* (TIGCC 20040104) Don't use environment variables. */
  5351. GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX");
  5352. +#endif /* 0 */
  5353. n_switches = 0;
  5354. n_infiles = 0;
  5355. @@ -3241,7 +3259,7 @@
  5356. see if we can create it from the pathname specified in argv[0]. */
  5357. gcc_libexec_prefix = standard_libexec_prefix;
  5358. -#ifndef VMS
  5359. +#if 0
  5360. /* FIXME: make_relative_prefix doesn't yet work for VMS. */
  5361. if (!gcc_exec_prefix)
  5362. {
  5363. @@ -3260,6 +3278,7 @@
  5364. #else
  5365. #endif
  5366. +#if 0 /* (TIGCC 20040104) Don't use environment variables. */
  5367. if (gcc_exec_prefix)
  5368. {
  5369. int len = strlen (gcc_exec_prefix);
  5370. @@ -3383,6 +3402,7 @@
  5371. endp++;
  5372. }
  5373. }
  5374. +#endif /* 0 */
  5375. /* Convert new-style -- options to old-style. */
  5376. translate_options (&argc, (const char *const **) &argv);
  5377. @@ -3810,6 +3830,7 @@
  5378. /* Set up the search paths before we go looking for config files. */
  5379. +#if 0 /* (TIGCC 20040104) Don't hardcode any prefix at compile time. */
  5380. /* These come before the md prefixes so that we will find gcc's subcommands
  5381. (such as cpp) rather than those of the host system. */
  5382. /* Use 2 as fourth arg meaning try just the machine as a suffix,
  5383. @@ -3871,6 +3892,7 @@
  5384. add_prefix (&startfile_prefixes,
  5385. concat (tooldir_prefix, "lib", dir_separator_str, NULL),
  5386. "BINUTILS", PREFIX_PRIORITY_LAST, 0, 1);
  5387. +#endif /* 0 */
  5388. #if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS)
  5389. /* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix,
  5390. @@ -6149,6 +6171,7 @@
  5391. else
  5392. init_spec ();
  5393. +#if 0
  5394. /* We need to check standard_exec_prefix/just_machine_suffix/specs
  5395. for any override of as, ld and libraries. */
  5396. specs_file = alloca (strlen (standard_exec_prefix)
  5397. @@ -6182,7 +6205,9 @@
  5398. PREFIX_PRIORITY_LAST, 0, 0);
  5399. }
  5400. }
  5401. +#endif /* 0 */
  5402. +#if 0 /* (TIGCC 20040104) Don't hardcode any prefix at compile time. */
  5403. /* Process sysroot_suffix_spec. */
  5404. if (*sysroot_suffix_spec != 0
  5405. && do_spec_2 (sysroot_suffix_spec) == 0)
  5406. @@ -6272,6 +6297,7 @@
  5407. standard_startfile_prefix_2, "BINUTILS",
  5408. PREFIX_PRIORITY_LAST, 0, 1);
  5409. }
  5410. +#endif /* 0 */
  5411. /* Process any user specified specs in the order given on the command
  5412. line. */
  5413. @@ -6282,10 +6308,12 @@
  5414. read_specs (filename ? filename : uptr->filename, FALSE);
  5415. }
  5416. +#if 0 /* (TIGCC 20040104) Don't use environment variables. */
  5417. /* If we have a GCC_EXEC_PREFIX envvar, modify it for cpp's sake. */
  5418. if (gcc_exec_prefix)
  5419. gcc_exec_prefix = concat (gcc_exec_prefix, spec_machine, dir_separator_str,
  5420. spec_version, dir_separator_str, NULL);
  5421. +#endif /* 0 */
  5422. /* Now we have the specs.
  5423. Set the `valid' bits for switches that match anything in any spec. */
  5424. @@ -6306,7 +6334,8 @@
  5425. if (print_search_dirs)
  5426. {
  5427. - printf (_("install: %s%s\n"), standard_exec_prefix, machine_suffix);
  5428. +/* (TIGCC 20040104) Don't hardcode any prefix at compile time. */
  5429. + printf (_("install: relocatable TIGCC installation\n"));
  5430. printf (_("programs: %s\n"), build_search_list (&exec_prefixes, "", 0));
  5431. printf (_("libraries: %s\n"), build_search_list (&startfile_prefixes, "", 0));
  5432. return (0);
  5433. diff -Naur gcc-4.1.2.orig/gcc/gcse.c gcc-4.1.2-src/gcc/gcse.c
  5434. --- gcc-4.1.2.orig/gcc/gcse.c 2006-01-16 10:37:10.000000000 +0100
  5435. +++ gcc-4.1.2-src/gcc/gcse.c 2007-02-19 02:32:34.000000000 +0100
  5436. @@ -3053,11 +3053,14 @@
  5437. rtx newreg = NULL, newcnst = NULL;
  5438. /* Rule out USE instructions and ASM statements as we don't want to
  5439. - change the hard registers mentioned. */
  5440. + change the hard registers mentioned.
  5441. + (TIGCC) The same thing goes for global register variables. CalcRogue gets
  5442. + miscompiled without this patch. */
  5443. if (REG_P (x)
  5444. && (REGNO (x) >= FIRST_PSEUDO_REGISTER
  5445. || (GET_CODE (PATTERN (insn)) != USE
  5446. - && asm_noperands (PATTERN (insn)) < 0)))
  5447. + && asm_noperands (PATTERN (insn)) < 0
  5448. + && ! global_regs[REGNO (x)])))
  5449. {
  5450. cselib_val *val = cselib_lookup (x, GET_MODE (x), 0);
  5451. struct elt_loc_list *l;
  5452. diff -Naur gcc-4.1.2.orig/gcc/genmodes.c gcc-4.1.2-src/gcc/genmodes.c
  5453. --- gcc-4.1.2.orig/gcc/genmodes.c 2005-06-25 04:02:01.000000000 +0200
  5454. +++ gcc-4.1.2-src/gcc/genmodes.c 2007-02-19 02:32:34.000000000 +0100
  5455. @@ -1068,6 +1068,7 @@
  5456. static void
  5457. emit_real_format_for_mode (void)
  5458. {
  5459. +#if 0
  5460. struct mode_data *m;
  5461. /* The entities pointed to by this table are constant, whether
  5462. @@ -1093,6 +1094,7 @@
  5463. tagged_printf ("&%s", m->format, m->name);
  5464. print_closer ();
  5465. +#endif /* 0 */
  5466. }
  5467. static void
  5468. @@ -1177,10 +1179,12 @@
  5469. }
  5470. }
  5471. +#if 0
  5472. /* Real mode formats don't have to propagate anywhere. */
  5473. for (a = adj_format; a; a = a->next)
  5474. printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (%smode) = %s;\n",
  5475. a->file, a->line, a->mode->name, a->adjustment);
  5476. +#endif /* 0 */
  5477. puts ("}");
  5478. }
  5479. diff -Naur gcc-4.1.2.orig/gcc/gimplify.c gcc-4.1.2-src/gcc/gimplify.c
  5480. --- gcc-4.1.2.orig/gcc/gimplify.c 2006-11-19 17:15:47.000000000 +0100
  5481. +++ gcc-4.1.2-src/gcc/gimplify.c 2007-04-17 16:41:54.000000000 +0200
  5482. @@ -1904,6 +1904,7 @@
  5483. /* There is a sequence point before the call, so any side effects in
  5484. the calling expression must occur before the actual call. Force
  5485. gimplify_expr to use an internal post queue. */
  5486. + if (!flag_no_function_cse)
  5487. ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, NULL,
  5488. is_gimple_call_addr, fb_rvalue);
  5489. @@ -1922,6 +1923,12 @@
  5490. if (PUSH_ARGS_REVERSED)
  5491. TREE_OPERAND (*expr_p, 1) = nreverse (TREE_OPERAND (*expr_p, 1));
  5492. + /* (TIGCC 20050206) Gimplify the function expression only after the arguments
  5493. + if -fno-function-cse. */
  5494. + if (flag_no_function_cse)
  5495. + ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, NULL,
  5496. + is_gimple_call_addr, fb_rvalue);
  5497. +
  5498. /* Try this again in case gimplification exposed something. */
  5499. if (ret != GS_ERROR)
  5500. {
  5501. @@ -4234,11 +4241,15 @@
  5502. break;
  5503. }
  5504. - if (VOID_TYPE_P (TREE_TYPE (*expr_p))
  5505. - || fallback == fb_none)
  5506. + if ((VOID_TYPE_P (TREE_TYPE (*expr_p))
  5507. + || fallback == fb_none)
  5508. + && ! TREE_CODE (TREE_OPERAND (*expr_p, 0)) == CALL_EXPR)
  5509. {
  5510. /* Just strip a conversion to void (or in void context) and
  5511. try again. */
  5512. + /* (TIGCC 20070417) But not for function calls, so
  5513. + warn_unused_result doesn't warn if they're cast to void.
  5514. + (Patch by Richard Guenther from PR 25509.) */
  5515. *expr_p = TREE_OPERAND (*expr_p, 0);
  5516. break;
  5517. }
  5518. diff -Naur gcc-4.1.2.orig/gcc/ifcvt.c gcc-4.1.2-src/gcc/ifcvt.c
  5519. --- gcc-4.1.2.orig/gcc/ifcvt.c 2006-11-15 09:11:59.000000000 +0100
  5520. +++ gcc-4.1.2-src/gcc/ifcvt.c 2007-02-19 02:32:34.000000000 +0100
  5521. @@ -2057,6 +2057,16 @@
  5522. if (MEM_P (op))
  5523. return ! side_effects_p (XEXP (op, 0));
  5524. + /* (TIGCC 20040925) Can't if-convert global register variables.
  5525. + -- Kevin Kofler */
  5526. + if (GET_CODE (op) == REG)
  5527. + {
  5528. + int regno;
  5529. + regno = REGNO (op);
  5530. + if (regno < FIRST_PSEUDO_REGISTER && global_regs[regno])
  5531. + return FALSE;
  5532. + }
  5533. +
  5534. if (side_effects_p (op))
  5535. return FALSE;
  5536. @@ -3396,6 +3406,21 @@
  5537. TEST range. */
  5538. if (for_each_rtx (&PATTERN (insn), find_memory, NULL))
  5539. return FALSE;
  5540. +
  5541. + /* (TIGCC 20040925) Can't if-convert global register variables.
  5542. + -- Kevin Kofler */
  5543. + if (GET_CODE (PATTERN (insn)) == SET)
  5544. + {
  5545. + rtx dest;
  5546. + dest = SET_DEST (PATTERN (insn));
  5547. + if (GET_CODE (dest) == REG)
  5548. + {
  5549. + int regno;
  5550. + regno = REGNO (dest);
  5551. + if (regno < FIRST_PSEUDO_REGISTER && global_regs[regno])
  5552. + return FALSE;
  5553. + }
  5554. + }
  5555. }
  5556. if (insn == end)
  5557. break;
  5558. diff -Naur gcc-4.1.2.orig/gcc/langhooks-def.h gcc-4.1.2-src/gcc/langhooks-def.h
  5559. --- gcc-4.1.2.orig/gcc/langhooks-def.h 2005-11-19 00:40:29.000000000 +0100
  5560. +++ gcc-4.1.2-src/gcc/langhooks-def.h 2007-02-19 02:32:34.000000000 +0100
  5561. @@ -107,6 +107,7 @@
  5562. #define LANG_HOOKS_SAFE_FROM_P lhd_safe_from_p
  5563. #define LANG_HOOKS_FINISH_INCOMPLETE_DECL lhd_do_nothing_t
  5564. #define LANG_HOOKS_STATICP lhd_staticp
  5565. +#define LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES lhd_do_nothing_t
  5566. #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL lhd_do_nothing_t
  5567. #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lhd_set_decl_assembler_name
  5568. #define LANG_HOOKS_CAN_USE_BIT_FIELDS_P lhd_can_use_bit_fields_p
  5569. @@ -272,6 +273,7 @@
  5570. LANG_HOOKS_EXPAND_CONSTANT, \
  5571. LANG_HOOKS_EXPAND_EXPR, \
  5572. LANG_HOOKS_EXPAND_DECL, \
  5573. + LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES, \
  5574. LANG_HOOKS_SAFE_FROM_P, \
  5575. LANG_HOOKS_FINISH_INCOMPLETE_DECL, \
  5576. LANG_HOOKS_MARK_ADDRESSABLE, \
  5577. diff -Naur gcc-4.1.2.orig/gcc/langhooks.h gcc-4.1.2-src/gcc/langhooks.h
  5578. --- gcc-4.1.2.orig/gcc/langhooks.h 2005-11-19 00:40:29.000000000 +0100
  5579. +++ gcc-4.1.2-src/gcc/langhooks.h 2007-02-19 02:32:34.000000000 +0100
  5580. @@ -283,6 +283,10 @@
  5581. 1 if handled, 0 otherwise. */
  5582. int (*expand_decl) (tree);
  5583. + /* Possibly apply default attributes to a function (represented by
  5584. + a FUNCTION_DECL). */
  5585. + void (*insert_default_attributes) PARAMS ((tree));
  5586. +
  5587. /* Hook called by safe_from_p for language-specific tree codes. It is
  5588. up to the language front-end to install a hook if it has any such
  5589. codes that safe_from_p needs to know about. Since same_from_p will
  5590. diff -Naur gcc-4.1.2.orig/gcc/loop.c gcc-4.1.2-src/gcc/loop.c
  5591. --- gcc-4.1.2.orig/gcc/loop.c 2006-11-01 13:11:18.000000000 +0100
  5592. +++ gcc-4.1.2-src/gcc/loop.c 2007-02-19 02:32:34.000000000 +0100
  5593. @@ -1297,6 +1297,13 @@
  5594. && REGNO_LAST_UID (regno) == INSN_UID (user)
  5595. && regs->array[regno].set_in_loop == 1
  5596. && GET_CODE (SET_SRC (set)) != ASM_OPERANDS
  5597. + /* (TIGCC 20050206) Patch by Ian Lance Taylor regarding using hard
  5598. + register variables as an asm input
  5599. + See http://gcc.gnu.org/ml/gcc/2004-05/msg00678.html */
  5600. + && (regno >= FIRST_PSEUDO_REGISTER
  5601. + || asm_noperands (PATTERN (regs->array[regno]
  5602. + .single_usage))
  5603. + < 0)
  5604. && ! side_effects_p (SET_SRC (set))
  5605. && ! find_reg_note (p, REG_RETVAL, NULL_RTX)
  5606. && (!SMALL_REGISTER_CLASSES
  5607. diff -Naur gcc-4.1.2.orig/gcc/machmode.def gcc-4.1.2-src/gcc/machmode.def
  5608. --- gcc-4.1.2.orig/gcc/machmode.def 2005-06-25 04:02:01.000000000 +0200
  5609. +++ gcc-4.1.2-src/gcc/machmode.def 2007-02-19 02:32:34.000000000 +0100
  5610. @@ -170,8 +170,8 @@
  5611. These are the IEEE mappings. They can be overridden with
  5612. RESET_FLOAT_FORMAT or at runtime (in OVERRIDE_OPTIONS). */
  5613. -FLOAT_MODE (SF, 4, ieee_single_format);
  5614. -FLOAT_MODE (DF, 8, ieee_double_format);
  5615. +FLOAT_MODE (SF, 4, 0);
  5616. +FLOAT_MODE (DF, 8, 0);
  5617. /* Basic CC modes.
  5618. FIXME define this only for targets that need it. */
  5619. diff -Naur gcc-4.1.2.orig/gcc/optabs.c gcc-4.1.2-src/gcc/optabs.c
  5620. --- gcc-4.1.2.orig/gcc/optabs.c 2006-07-26 15:32:01.000000000 +0200
  5621. +++ gcc-4.1.2-src/gcc/optabs.c 2007-02-19 02:32:34.000000000 +0100
  5622. @@ -1741,7 +1741,7 @@
  5623. /* Look for a wider mode of the same class for which it appears we can do
  5624. the operation. */
  5625. - if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT)
  5626. + if (class == MODE_INT)
  5627. {
  5628. for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode;
  5629. wider_mode = GET_MODE_WIDER_MODE (wider_mode))
  5630. @@ -2037,7 +2037,7 @@
  5631. /* It can't be done in this mode. Can we do it in a wider mode? */
  5632. - if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT)
  5633. + if (class == MODE_INT)
  5634. {
  5635. for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode;
  5636. wider_mode = GET_MODE_WIDER_MODE (wider_mode))
  5637. @@ -2205,6 +2205,7 @@
  5638. return 0;
  5639. }
  5640. +#if 0 /* (TIGCC 20050216) */
  5641. /* Extract the OMODE lowpart from VAL, which has IMODE. Under certain
  5642. conditions, VAL may already be a SUBREG against which we cannot generate
  5643. a further SUBREG. In this case, we expect forcing the value into a
  5644. @@ -2329,6 +2330,7 @@
  5645. return target;
  5646. }
  5647. +#endif /* 0 */
  5648. /* Generate code to perform an operation specified by UNOPTAB
  5649. on operand OP0, with result having machine-mode MODE.
  5650. @@ -2406,7 +2408,7 @@
  5651. goto try_libcall;
  5652. }
  5653. - if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT)
  5654. + if (class == MODE_INT)
  5655. for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode;
  5656. wider_mode = GET_MODE_WIDER_MODE (wider_mode))
  5657. {
  5658. @@ -2482,13 +2484,16 @@
  5659. if (unoptab->code == NEG)
  5660. {
  5661. +#if 0
  5662. /* Try negating floating point values by flipping the sign bit. */
  5663. + /* (TIGCC 20050205) Don't. We have unsigned zero and infinity. */
  5664. if (class == MODE_FLOAT)
  5665. {
  5666. temp = expand_absneg_bit (NEG, mode, op0, target);
  5667. if (temp)
  5668. return temp;
  5669. }
  5670. +#endif /* 0 */
  5671. /* If there is no negation pattern, and we have no negative zero,
  5672. try subtracting from zero. */
  5673. @@ -2545,7 +2550,7 @@
  5674. /* It can't be done in this mode. Can we do it in a wider mode? */
  5675. - if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT)
  5676. + if (class == MODE_INT)
  5677. {
  5678. for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode;
  5679. wider_mode = GET_MODE_WIDER_MODE (wider_mode))
  5680. @@ -2634,13 +2639,16 @@
  5681. if (temp != 0)
  5682. return temp;
  5683. +#if 0
  5684. /* For floating point modes, try clearing the sign bit. */
  5685. + /* (TIGCC 20050205) Don't. We have unsigned zero and infinity. */
  5686. if (GET_MODE_CLASS (mode) == MODE_FLOAT)
  5687. {
  5688. temp = expand_absneg_bit (ABS, mode, op0, target);
  5689. if (temp)
  5690. return temp;
  5691. }
  5692. +#endif /* 0 */
  5693. /* If we have a MAX insn, we can do this as MAX (x, -x). */
  5694. if (smax_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing
  5695. @@ -2733,6 +2741,7 @@
  5696. return target;
  5697. }
  5698. +#if 0
  5699. /* A subroutine of expand_copysign, perform the copysign operation using the
  5700. abs and neg primitives advertised to exist on the target. The assumption
  5701. is that we have a split register file, and leaving op0 in fp registers,
  5702. @@ -2965,6 +2974,7 @@
  5703. return expand_copysign_bit (mode, op0, op1, target,
  5704. fmt->signbit_rw, op0_is_abs);
  5705. }
  5706. +#endif /* 0 */
  5707. /* Generate an instruction whose insn-code is INSN_CODE,
  5708. with two operands: an output TARGET and an input OP0.
  5709. @@ -4351,6 +4361,7 @@
  5710. }
  5711. }
  5712. +#if 0
  5713. /* Unsigned integer, and no way to convert directly.
  5714. Convert as signed, then conditionally adjust the result. */
  5715. if (unsignedp)
  5716. @@ -4455,6 +4466,7 @@
  5717. emit_label (label);
  5718. goto done;
  5719. }
  5720. +#endif /* 0 */
  5721. /* No hardware instruction available; call a library routine. */
  5722. {
  5723. @@ -4545,6 +4557,7 @@
  5724. }
  5725. }
  5726. +#if 0
  5727. /* For an unsigned conversion, there is one more way to do it.
  5728. If we have a signed conversion, we generate code that compares
  5729. the real value to the largest representable positive number. If if
  5730. @@ -4628,6 +4641,7 @@
  5731. return;
  5732. }
  5733. +#endif /* 0 */
  5734. /* We can't do it with an insn, so use a library call. But first ensure
  5735. that the mode of TO is at least as wide as SImode, since those are the
  5736. @@ -5231,6 +5245,9 @@
  5737. /* Conversions. */
  5738. init_interclass_conv_libfuncs (sfloat_optab, "float",
  5739. MODE_INT, MODE_FLOAT);
  5740. + /* (TIGCC 20050208) Someone forgot this one... */
  5741. + init_interclass_conv_libfuncs (ufloat_optab, "floatuns",
  5742. + MODE_INT, MODE_FLOAT);
  5743. init_interclass_conv_libfuncs (sfix_optab, "fix",
  5744. MODE_FLOAT, MODE_INT);
  5745. init_interclass_conv_libfuncs (ufix_optab, "fixuns",
  5746. diff -Naur gcc-4.1.2.orig/gcc/opts.c gcc-4.1.2-src/gcc/opts.c
  5747. --- gcc-4.1.2.orig/gcc/opts.c 2006-05-17 20:38:58.000000000 +0200
  5748. +++ gcc-4.1.2-src/gcc/opts.c 2007-02-19 02:32:34.000000000 +0100
  5749. @@ -570,7 +570,12 @@
  5750. #endif
  5751. flag_regmove = 1;
  5752. flag_strict_aliasing = 1;
  5753. +#if 0 /* (TIGCC 20050213) Null pointer dereferences won't necessarily trigger
  5754. + a trap. When reading, they definitely won't. When writing, they will
  5755. + only when the variable being dereferenced is a scalar or a small
  5756. + enough structure. */
  5757. flag_delete_null_pointer_checks = 1;
  5758. +#endif
  5759. flag_reorder_blocks = 1;
  5760. flag_reorder_functions = 1;
  5761. flag_tree_store_ccp = 1;
  5762. @@ -589,6 +594,10 @@
  5763. flag_inline_functions = 1;
  5764. flag_unswitch_loops = 1;
  5765. flag_gcse_after_reload = 1;
  5766. + /* (TIGCC 20050217) Halve maximum inline insns under -O3. Use -O4 to
  5767. + override this. */
  5768. + if (optimize == 3)
  5769. + set_param_value ("max-inline-insns-auto", 60);
  5770. }
  5771. if (optimize < 2 || optimize_size)
  5772. @@ -609,12 +618,17 @@
  5773. flag_reorder_blocks_and_partition = 0;
  5774. }
  5775. - if (optimize_size)
  5776. + /* (TIGCC 20050217) Do this at -O2 as well, as it improves both size and speed. */
  5777. + if (optimize == 2 || optimize_size)
  5778. {
  5779. /* Inlining of very small functions usually reduces total size. */
  5780. - set_param_value ("max-inline-insns-single", 5);
  5781. set_param_value ("max-inline-insns-auto", 5);
  5782. flag_inline_functions = 1;
  5783. + }
  5784. + if (optimize_size)
  5785. + {
  5786. + /* Inlining of very small functions usually reduces total size. */
  5787. + set_param_value ("max-inline-insns-single", 5);
  5788. /* We want to crossjump as much as possible. */
  5789. set_param_value ("min-crossjump-insns", 1);
  5790. @@ -645,6 +659,11 @@
  5791. if (flag_pic && !flag_pie)
  5792. flag_shlib = 1;
  5793. + /* TIGCC Patch: Register d2 is used by the TIOS calling convention.
  5794. + See "call-used-" further down in this file. */
  5795. + if (TARGET_TIOS)
  5796. + fix_register ("d2", 0, 1);
  5797. +
  5798. if (flag_no_inline == 2)
  5799. flag_no_inline = 0;
  5800. else
  5801. @@ -922,6 +941,12 @@
  5802. flag_profile_values_set = true;
  5803. break;
  5804. + case OPT_freg_relative_:
  5805. + fix_register (arg, 1, 1);
  5806. + target_flags |= MASK_REG_RELATIVE;
  5807. + strcpy (TARGET_RELATION_REG, arg);
  5808. + break;
  5809. +
  5810. case OPT_fvisibility_:
  5811. {
  5812. if (!strcmp(arg, "default"))
  5813. diff -Naur gcc-4.1.2.orig/gcc/output.h gcc-4.1.2-src/gcc/output.h
  5814. --- gcc-4.1.2.orig/gcc/output.h 2005-10-26 09:03:30.000000000 +0200
  5815. +++ gcc-4.1.2-src/gcc/output.h 2007-02-19 02:32:34.000000000 +0100
  5816. @@ -334,7 +334,7 @@
  5817. #define assemble_aligned_integer(SIZE, VALUE) \
  5818. assemble_integer (VALUE, SIZE, (SIZE) * BITS_PER_UNIT, 1)
  5819. -#ifdef REAL_VALUE_TYPE_SIZE
  5820. +#ifdef REAL_WIDTH /* (TIGCC 20050205) */
  5821. /* Assemble the floating-point constant D into an object of size MODE. */
  5822. extern void assemble_real (REAL_VALUE_TYPE, enum machine_mode, unsigned);
  5823. #endif
  5824. diff -Naur gcc-4.1.2.orig/gcc/postreload.c gcc-4.1.2-src/gcc/postreload.c
  5825. --- gcc-4.1.2.orig/gcc/postreload.c 2005-11-18 14:14:39.000000000 +0100
  5826. +++ gcc-4.1.2-src/gcc/postreload.c 2007-02-19 02:32:34.000000000 +0100
  5827. @@ -1189,6 +1189,9 @@
  5828. && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (OUTMODE), \
  5829. GET_MODE_BITSIZE (INMODE))))
  5830. +/* (TIGCC 20050213) Declare this target-dependent function. */
  5831. +int const_method (rtx);
  5832. +
  5833. static void
  5834. reload_cse_move2add (rtx first)
  5835. {
  5836. @@ -1276,11 +1279,17 @@
  5837. && narrow_mode != GET_MODE (reg);
  5838. narrow_mode = GET_MODE_WIDER_MODE (narrow_mode))
  5839. {
  5840. - if (have_insn_for (STRICT_LOW_PART, narrow_mode)
  5841. + /* (TIGCC 20050213) Don't do this for QImode. Byte moves aren't
  5842. + any cheaper than word moves, they just kill chances to use a
  5843. + moveq. Also don't turn long moves which can be done using
  5844. + moveq into word moves. */
  5845. + if (narrow_mode != QImode
  5846. + && have_insn_for (STRICT_LOW_PART, narrow_mode)
  5847. && ((reg_offset[regno]
  5848. & ~GET_MODE_MASK (narrow_mode))
  5849. == (INTVAL (src)
  5850. - & ~GET_MODE_MASK (narrow_mode))))
  5851. + & ~GET_MODE_MASK (narrow_mode)))
  5852. + && (GET_MODE (reg) != SImode || const_method (src)))
  5853. {
  5854. rtx narrow_reg = gen_rtx_REG (narrow_mode,
  5855. REGNO (reg));
  5856. diff -Naur gcc-4.1.2.orig/gcc/print-rtl.c gcc-4.1.2-src/gcc/print-rtl.c
  5857. --- gcc-4.1.2.orig/gcc/print-rtl.c 2005-08-16 02:13:53.000000000 +0200
  5858. +++ gcc-4.1.2-src/gcc/print-rtl.c 2007-02-19 02:32:34.000000000 +0100
  5859. @@ -586,6 +586,9 @@
  5860. {
  5861. char s[60];
  5862. + REAL_VALUE_TO_STRING (*CONST_DOUBLE_REAL_VALUE (in_rtx), s);
  5863. + fprintf (outfile, " %s", s);
  5864. +#if 0
  5865. real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
  5866. sizeof (s), 0, 1);
  5867. fprintf (outfile, " %s", s);
  5868. @@ -593,6 +596,7 @@
  5869. real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
  5870. sizeof (s), 0, 1);
  5871. fprintf (outfile, " [%s]", s);
  5872. +#endif /* 0 */
  5873. }
  5874. break;
  5875. #endif
  5876. diff -Naur gcc-4.1.2.orig/gcc/print-tree.c gcc-4.1.2-src/gcc/print-tree.c
  5877. --- gcc-4.1.2.orig/gcc/print-tree.c 2005-10-13 01:34:09.000000000 +0200
  5878. +++ gcc-4.1.2-src/gcc/print-tree.c 2007-02-19 02:32:34.000000000 +0100
  5879. @@ -134,7 +134,7 @@
  5880. else
  5881. {
  5882. char string[60];
  5883. - real_to_decimal (string, &d, sizeof (string), 0, 1);
  5884. + REAL_VALUE_TO_STRING (d, string);
  5885. fprintf (file, " %s", string);
  5886. }
  5887. }
  5888. @@ -680,7 +680,7 @@
  5889. else
  5890. {
  5891. char string[64];
  5892. - real_to_decimal (string, &d, sizeof (string), 0, 1);
  5893. + REAL_VALUE_TO_STRING (d, string);
  5894. fprintf (file, " %s", string);
  5895. }
  5896. }
  5897. diff -Naur gcc-4.1.2.orig/gcc/real.c gcc-4.1.2-src/gcc/real.c
  5898. --- gcc-4.1.2.orig/gcc/real.c 2005-09-19 19:01:40.000000000 +0200
  5899. +++ gcc-4.1.2-src/gcc/real.c 2007-02-19 02:32:34.000000000 +0100
  5900. @@ -72,6 +72,7 @@
  5901. adjust the significand to match. */
  5902. +#if 0
  5903. /* Used to classify two numbers simultaneously. */
  5904. #define CLASS2(A, B) ((A) << 2 | (B))
  5905. @@ -122,7 +123,9 @@
  5906. static void times_pten (REAL_VALUE_TYPE *, int);
  5907. static void round_for_format (const struct real_format *, REAL_VALUE_TYPE *);
  5908. +#endif /* 0 */
  5909. +#if 0
  5910. /* Initialize R with a positive zero. */
  5911. static inline void
  5912. @@ -973,6 +976,614 @@
  5913. gcc_unreachable ();
  5914. }
  5915. }
  5916. +#endif /* 0 */
  5917. +
  5918. +/* Add 1 unit in the last place to a positive SMAP II BCD float. */
  5919. +static void bcdpadd1ulp(smap_bcd_float *op)
  5920. +{
  5921. + int i;
  5922. + op->mantissa++; /* This will give a digit of 10 in some cases. */
  5923. + for (i=0;i<60;i+=4) { /* for each digit except the first one */
  5924. + int d=(op->mantissa>>i)&15;
  5925. + if (d<10) /* if the digit is <10, we're done */
  5926. + break;
  5927. + op->mantissa += 6ull<<i; /* subtract 10 from the digit, add 1 to the next digit */
  5928. + }
  5929. + /* Now, we should have a carry only in one case: the mantissa was
  5930. + 9999999999999999. So now, we have A000000000000000, where A is 10 in a
  5931. + single digit. We can safely truncate the last digit because it is 0 (so
  5932. + there is no risk of double-rounding here). */
  5933. + if (op->mantissa >= 0xA000000000000000ull) { /* if we have a carry */
  5934. + gcc_assert (op->mantissa == 0xA000000000000000ull); /* sanity check */
  5935. + op->mantissa = 0x1000000000000000ull; /* A -> 10, drop the last digit */
  5936. + op->exponent++; /* adjust the exponent */
  5937. + if (op->exponent > 0x4000+16383) /* exponent too large, overflow to +infinity */
  5938. + *op = POSITIVE_INF;
  5939. + }
  5940. +}
  5941. +
  5942. +/* Add 2 positive SMAP II BCD floats. */
  5943. +static smap_bcd_float bcdppadd(smap_bcd_float op0, smap_bcd_float op1)
  5944. +{
  5945. + int lastdigit=0;
  5946. +
  5947. + if (op0.exponent < op1.exponent) {
  5948. + /* If op0 does not contribute to the result, avoid shift count overflow by
  5949. + returning op1 immediately. */
  5950. + if (op1.exponent-op0.exponent>16) return op1;
  5951. + /* Adjust op0 exponent to fit op1. */
  5952. + op0.mantissa >>= ((op1.exponent-op0.exponent-1)<<2);
  5953. + lastdigit = (op0.mantissa&15); /* save the last digit of op0 */
  5954. + op0.mantissa >>= 4; /* drop the last digit of op0 */
  5955. + op0.exponent = op1.exponent; /* adjust the exponent of op0 */
  5956. + } else if (op1.exponent < op0.exponent) {
  5957. + /* If op1 does not contribute to the result, avoid shift count overflow by
  5958. + returning op0 immediately. */
  5959. + if (op0.exponent-op1.exponent>16) return op0;
  5960. + /* Adjust op1 exponent to fit op0. */
  5961. + op1.mantissa >>= ((op0.exponent-op1.exponent-1)<<2);
  5962. + lastdigit = (op1.mantissa&15); /* save the last digit of op1 */
  5963. + op1.mantissa >>= 4; /* drop the last digit of op1 */
  5964. + op1.exponent = op0.exponent; /* adjust the exponent of op1 */
  5965. + }
  5966. +
  5967. + /* Now do the addition in the BCD-coded mantissa. */
  5968. + {
  5969. + int i,d,carry=0;
  5970. + smap_bcd_float result={0,0};result.exponent=op0.exponent;
  5971. + for (i=0;i<64;i+=4) { /* for each digit */
  5972. + d = (op0.mantissa&15)+(op1.mantissa&15)+carry;
  5973. + carry = (d>=10); /* handle carry */
  5974. + if (carry) d -= 10;
  5975. + /* We are done with this digit of the mantissa. */
  5976. + op0.mantissa >>= 4;
  5977. + op1.mantissa >>= 4;
  5978. + /* Store it into the resulting mantissa. */
  5979. + result.mantissa += ((unsigned long long)d)<<i;
  5980. + }
  5981. + if (carry) { /* The mantissa overflowed, so we need to adjust the exponent. */
  5982. + lastdigit = (result.mantissa&15); /* save the last digit of result,
  5983. + dropping the previously saved last
  5984. + digit */
  5985. + result.mantissa >>= 4; /* drop the last digit of result */
  5986. + result.exponent++; /* adjust the exponent of result */
  5987. + if (result.exponent > 0x4000+16383) /* exponent too large, overflow to */
  5988. + return POSITIVE_INF; /* +infinity */
  5989. + /* prepend the first digit */
  5990. + result.mantissa += ((unsigned long long)carry)<<60;
  5991. + }
  5992. + if (lastdigit>=5) /* now do the correct rounding */
  5993. + bcdpadd1ulp(&result);
  5994. + return result;
  5995. + }
  5996. +}
  5997. +
  5998. +/* Subtract 2 positive SMAP II BCD floats. */
  5999. +static smap_bcd_float bcdppsub(smap_bcd_float op0, smap_bcd_float op1)
  6000. +{
  6001. + unsigned long long lastdigits=0;
  6002. +
  6003. + if (REAL_VALUES_LESS(op0,op1)) /* if op0<op1, subtract the other way round */
  6004. + return REAL_VALUE_NEGATE(bcdppsub(op1,op0));
  6005. + else if (REAL_VALUES_IDENTICAL(op0,op1)) /* if op0=op1, return unsigned 0 */
  6006. + return UNSIGNED_ZERO;
  6007. +
  6008. + /* Now, we can assume op0>op1. */
  6009. + if (op1.exponent < op0.exponent) {
  6010. + /* If op1 does not contribute to the result, avoid shift count overflow by
  6011. + returning op0 immediately. */
  6012. + if (op0.exponent-op1.exponent>16) return op0;
  6013. + /* Adjust op1 exponent to fit op0.
  6014. + Save all dropped digits, so we can round correctly. */
  6015. + lastdigits = op1.mantissa << (64-((op0.exponent-op1.exponent)<<2));
  6016. + if (op0.exponent-op1.exponent==16)
  6017. + op1.mantissa = 0; /* special-cased because shifts by 64 aren't allowed */
  6018. + else
  6019. + op1.mantissa >>= ((op0.exponent-op1.exponent)<<2);
  6020. + op1.exponent = op0.exponent; /* adjust the exponent of op1 */
  6021. + }
  6022. +
  6023. + /* Now do the subtraction in the BCD-coded mantissa. */
  6024. + {
  6025. + int i,d,carry=0;
  6026. + smap_bcd_float result={0,0};result.exponent=op0.exponent;
  6027. + for (i=0;i<64;i+=4) { /* for each digit */
  6028. + d = (op0.mantissa&15)-((op1.mantissa&15)+carry);
  6029. + carry = (d<0); /* handle carry */
  6030. + if (carry) d += 10;
  6031. + /* We are done with this digit of the mantissa. */
  6032. + op0.mantissa >>= 4;
  6033. + op1.mantissa >>= 4;
  6034. + /* Store it into the resulting mantissa. */
  6035. + result.mantissa += ((unsigned long long)d)<<i;
  6036. + }
  6037. + gcc_assert (!carry); /* Carry should be 0 here! */
  6038. + /* Normalize and return the result (which is always positive here, since we
  6039. + assumed op1>op0). Handle rounding and extra digits during normalization.
  6040. + */
  6041. + while ((result.mantissa<0x1000000000000000ull)
  6042. + || ((result.mantissa==0x1000000000000000ull)
  6043. + && ((lastdigits>0x5000000000000000ull)
  6044. + || ((lastdigits>0x500000000000000ull)
  6045. + && (result.exponent>0x4000-16383))))) {
  6046. + /* while mantissa<1 */
  6047. + int c = (result.mantissa==0x1000000000000000ull); /* used by the sanity
  6048. + check below */
  6049. + result.exponent--; /* decrease exponent by 1 */
  6050. + if (result.exponent<0x4000-16383) /* exponent too small, underflow to +0 */
  6051. + return POSITIVE_ZERO;
  6052. + result.mantissa <<= 4; /* left-shift mantissa */
  6053. + carry = !!(lastdigits>>60);
  6054. + result.mantissa -= (lastdigits>>60)+(carry*6); /* Subtract extra digit. If
  6055. + there is a carry, add 10 to the digit, subtract 1 from the next digit.
  6056. + This can give digits of 15 in some cases. */
  6057. + for (i=4;i<64;i+=4) { /* for each digit except the last one */
  6058. + int d=(result.mantissa>>i)&15;
  6059. + if (d<10) /* if the digit is <10, we're done */
  6060. + break;
  6061. + result.mantissa -= 6ull<<i; /* add 10 to the digit, subtract 1 from the
  6062. + next digit */
  6063. + /* There should be no carry in the first digit except if the mantissa
  6064. + was exactly 1. */
  6065. + gcc_assert (c || result.mantissa<0xA000000000000000ull);
  6066. + }
  6067. + lastdigits <<= 4; /* We handled an extra digit. */
  6068. + }
  6069. + /* Now do the rounding. */
  6070. + if (lastdigits>0x5000000000000000ull) {
  6071. + int c = !result.mantissa; /* used by the sanity check below */
  6072. + /* This corner case should have been handled above. */
  6073. + gcc_assert (result.mantissa!=0x1000000000000000ull);
  6074. + result.mantissa--; /* Subtract 1. This can give digits of 15 in some cases. */
  6075. + for (i=0;i<64;i+=4) { /* for each digit */
  6076. + int d=(result.mantissa>>i)&15;
  6077. + if (d<10) /* if the digit is <10, we're done */
  6078. + break;
  6079. + result.mantissa -= 6ull<<i; /* add 10 to the digit, subtract 1 from the
  6080. + next digit */
  6081. + /* There should be no carry in the first digit except if the mantissa was
  6082. + 0 (which actually means 10^16 here). */
  6083. + gcc_assert (c || result.mantissa<0xA000000000000000ull);
  6084. + }
  6085. + }
  6086. + return result;
  6087. + }
  6088. +}
  6089. +
  6090. +/* Add 2 SMAP II BCD floats. */
  6091. +static smap_bcd_float bcdadd(smap_bcd_float op0, smap_bcd_float op1)
  6092. +{
  6093. + if (REAL_VALUE_ISNAN(op0) || REAL_VALUE_ISNAN(op1)) /* keep NAN */
  6094. + return NAN;
  6095. + else if (REAL_VALUE_ISINF(op0) && REAL_VALUE_ISINF(op1)) { /* both operands
  6096. + are infinity */
  6097. + if (!REAL_VALUES_IDENTICAL(op0,op1)
  6098. + || REAL_VALUES_IDENTICAL(op0,UNSIGNED_INF)) /* differing signs or both
  6099. + unsigned yield NAN */
  6100. + return NAN;
  6101. + else /* both positive or both negative */
  6102. + return op0;
  6103. + } else if (REAL_VALUE_ISINF(op0)) /* op0=inf, so op0+op1=inf+op1=inf=op0 */
  6104. + return op0;
  6105. + else if (REAL_VALUE_ISINF(op1)) /* op1=inf, so op0+op1=op0+inf=inf=op1 */
  6106. + return op1;
  6107. + else if (REAL_VALUE_ISZERO(op0) && REAL_VALUE_ISZERO(op1)) { /* both operands
  6108. + are 0 */
  6109. + if (REAL_VALUES_IDENTICAL(op0,op1)) /* both positive, both negative or both
  6110. + unsigned */
  6111. + return op0;
  6112. + else /* differing signs yield unsigned zero */
  6113. + return UNSIGNED_ZERO;
  6114. + } else if (REAL_VALUE_ISZERO(op0)) /* op0=0, so op0+op1=0+op1=op1 */
  6115. + return op1;
  6116. + else if (REAL_VALUE_ISZERO(op1)) /* op1=0, so op0+op1=op0+0=op0 */
  6117. + return op0;
  6118. + else if (REAL_VALUE_ISPOSITIVE(op0) && REAL_VALUE_ISPOSITIVE(op1))
  6119. + return bcdppadd(op0,op1);
  6120. + else if (REAL_VALUE_ISPOSITIVE(op0)) /* and op1 negative */
  6121. + return bcdppsub(op0,REAL_VALUE_NEGATE(op1));
  6122. + else if (REAL_VALUE_ISPOSITIVE(op1)) /* and op0 negative */
  6123. + return bcdppsub(op1,REAL_VALUE_NEGATE(op0));
  6124. + else /* both negative */
  6125. + return REAL_VALUE_NEGATE(bcdppadd(REAL_VALUE_NEGATE(op0),
  6126. + REAL_VALUE_NEGATE(op1)));
  6127. +}
  6128. +
  6129. +/* Subtract 2 SMAP II BCD floats. */
  6130. +static smap_bcd_float bcdsub(smap_bcd_float op0, smap_bcd_float op1)
  6131. +{
  6132. + return bcdadd(op0,REAL_VALUE_NEGATE(op1));
  6133. +}
  6134. +
  6135. +/* Multiply 2 positive SMAP II BCD floats. */
  6136. +static smap_bcd_float bcdppmul(smap_bcd_float op0, smap_bcd_float op1)
  6137. +{
  6138. + /* Compute the result in 2 binary parts. The upper 16 decimal digits and the
  6139. + lower ones. */
  6140. + unsigned long long resulth=0, resultl=0;
  6141. + int i,j,k,d0,d1,d32,exponent;
  6142. + unsigned long long factor=1ull;
  6143. + for (i=0;i<64;i+=4,factor*=10ull) { /* for each result digit <16 */
  6144. + for (j=0;j<64;j+=4) { /* for each digit of op0 */
  6145. + k = i-j; /* corresponding op1 digit */
  6146. + if (k<0 || k>=64) continue; /* digit out of range */
  6147. + d0 = (op0.mantissa>>j)&15; /* jth digit of op0 */
  6148. + d1 = (op1.mantissa>>k)&15; /* kth digit of op0 */
  6149. + resultl += (unsigned long long)(d0*d1)*factor;
  6150. + while (resultl>=10000000000000000ull/*10^16*/) { /* carry into resulth */
  6151. + resultl -= 10000000000000000ull/*10^16*/;
  6152. + resulth++;
  6153. + }
  6154. + }
  6155. + }
  6156. + for (factor=1ull;i<128;i+=4,factor*=10ull) { /* for each result digit >=16 */
  6157. + for (j=0;j<64;j+=4) { /* for each digit of op0 */
  6158. + k = i-j; /* corresponding op1 digit */
  6159. + if (k<0 || k>=64) continue; /* digit out of range */
  6160. + d0 = (op0.mantissa>>j)&15; /* jth digit of op0 */
  6161. + d1 = (op1.mantissa>>k)&15; /* kth digit of op0 */
  6162. + resulth += (unsigned long long)(d0*d1)*factor;
  6163. + }
  6164. + }
  6165. +
  6166. + /* resultl should always be <10^16 */
  6167. + gcc_assert (resultl<10000000000000000ull);
  6168. +
  6169. + /* Because of normalization, the result has either 31 or 32 digits. */
  6170. + d32 = (resulth>=1000000000000000ull/*10^15*/
  6171. + || (resulth==999999999999999ull/*10^15-1*/
  6172. + && resultl>=9500000000000000ull/*9.5*10^15*/));
  6173. + if (!d32) { /* if we have only 15 digits in resulth, take one from resultl */
  6174. + resulth = resulth*10ull+resultl/1000000000000000ull/*10^15*/;
  6175. + resultl = (resultl%1000000000000000ull/*10^15*/)*10ull;
  6176. + }
  6177. + if (resultl>=5000000000000000ull/*5*10^15*/) /* round resultl into resulth */
  6178. + resulth++;
  6179. +
  6180. + /* Now compute the exponent. */
  6181. + exponent=op0.exponent+op1.exponent-0x4000+d32;
  6182. + if (exponent>0x4000+16383) /* exponent too large, overflow to +infinity */
  6183. + return POSITIVE_INF;
  6184. + if (exponent<0x4000-16383) /* exponent too small, underflow to +0 */
  6185. + return POSITIVE_ZERO;
  6186. +
  6187. + /* Now convert resulth into a BCD mantissa. */
  6188. + {
  6189. + unsigned long long d;
  6190. + smap_bcd_float result={0,0};result.exponent=exponent;
  6191. + for (i=0;i<64;i+=4) { /* for each digit */
  6192. + d = resulth%10ull; /* Extract the digit. */
  6193. + resulth /= 10ull; /* We are done with this digit of the mantissa. */
  6194. + result.mantissa += d<<i; /* Store it into the resulting mantissa. */
  6195. + }
  6196. + return result;
  6197. + }
  6198. +}
  6199. +
  6200. +/* Multiply 2 SMAP II BCD floats. */
  6201. +static smap_bcd_float bcdmul(smap_bcd_float op0, smap_bcd_float op1)
  6202. +{
  6203. + if (REAL_VALUE_ISNAN(op0) || REAL_VALUE_ISNAN(op1)
  6204. + || (REAL_VALUE_ISINF(op0) && REAL_VALUE_ISZERO(op1))
  6205. + || (REAL_VALUE_ISZERO(op0) && REAL_VALUE_ISINF(op1))) /* keep NAN,
  6206. + 0*inf=NAN */
  6207. + return NAN;
  6208. + else if (REAL_VALUES_IDENTICAL(op0,UNSIGNED_INF)
  6209. + || REAL_VALUES_IDENTICAL(op1,UNSIGNED_INF)) /* unsigned inf * non-0 =
  6210. + unsigned inf */
  6211. + return UNSIGNED_INF;
  6212. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6213. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF)) /* +inf * +inf = +inf */
  6214. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6215. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF))) /* -inf * -inf = +inf */
  6216. + return POSITIVE_INF;
  6217. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6218. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF)) /* +inf * -inf = -inf */
  6219. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6220. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF))) /* -inf * +inf = -inf */
  6221. + return NEGATIVE_INF;
  6222. + /* Now we can assume that at least 1 value is finite, and that we don't have
  6223. + an unsigned infinity, a NAN or an inf*0 indeterminate form. */
  6224. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6225. + && REAL_VALUE_ISPOSITIVE(op1)) /* +inf * +finite = +inf */
  6226. + || (REAL_VALUE_ISPOSITIVE(op0)
  6227. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF)) /* +finite * +inf = +inf */
  6228. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6229. + && REAL_VALUE_ISNEGATIVE(op1)) /* -inf * -finite = +inf */
  6230. + || (REAL_VALUE_ISNEGATIVE(op0)
  6231. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF))) /* -finite * -inf = +inf */
  6232. + return POSITIVE_INF;
  6233. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6234. + && REAL_VALUE_ISNEGATIVE(op1)) /* +inf * -finite = -inf */
  6235. + || (REAL_VALUE_ISPOSITIVE(op0)
  6236. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF)) /* +finite * -inf = -inf */
  6237. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6238. + && REAL_VALUE_ISPOSITIVE(op1)) /* -inf * +finite = -inf */
  6239. + || (REAL_VALUE_ISNEGATIVE(op0)
  6240. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF))) /* -finite * +inf = -inf */
  6241. + return NEGATIVE_INF;
  6242. + /* Now we can assume that both values are finite. */
  6243. + else if (REAL_VALUES_IDENTICAL(op0,UNSIGNED_ZERO)
  6244. + || REAL_VALUES_IDENTICAL(op1,UNSIGNED_ZERO)) /* unsigned 0 * finite =
  6245. + unsigned 0 */
  6246. + return UNSIGNED_ZERO;
  6247. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6248. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO)) /* +0 * +0 = +0 */
  6249. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6250. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO))) /* -0 * -0 = +0 */
  6251. + return POSITIVE_ZERO;
  6252. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6253. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO)) /* +0 * -0 = -0 */
  6254. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6255. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO))) /* -0 * +0 = -0 */
  6256. + return NEGATIVE_ZERO;
  6257. + /* Now we can assume that both values are finite, at least 1 value is non-0,
  6258. + and that we don't have an unsigned 0. */
  6259. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6260. + && REAL_VALUE_ISPOSITIVE(op1)) /* +0 * +finite = +0 */
  6261. + || (REAL_VALUE_ISPOSITIVE(op0)
  6262. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO)) /* +finite * +0 = +0 */
  6263. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6264. + && REAL_VALUE_ISNEGATIVE(op1)) /* -0 * -finite = +0 */
  6265. + || (REAL_VALUE_ISNEGATIVE(op0)
  6266. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO))) /* -finite * -0 = +0 */
  6267. + return POSITIVE_ZERO;
  6268. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6269. + && REAL_VALUE_ISNEGATIVE(op1)) /* +0 * -finite = -0 */
  6270. + || (REAL_VALUE_ISPOSITIVE(op0)
  6271. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO)) /* +finite * -0 = -0 */
  6272. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6273. + && REAL_VALUE_ISPOSITIVE(op1)) /* -0 * +finite = -0 */
  6274. + || (REAL_VALUE_ISNEGATIVE(op0)
  6275. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO))) /* -finite * +0 = -0 */
  6276. + return NEGATIVE_ZERO;
  6277. + /* Now we can assume that both values are finite and non-0. */
  6278. + else if (REAL_VALUE_ISPOSITIVE(op0) && REAL_VALUE_ISPOSITIVE(op1))
  6279. + return bcdppmul(op0,op1);
  6280. + else if (REAL_VALUE_ISPOSITIVE(op0)) /* and op1 negative */
  6281. + return REAL_VALUE_NEGATE(bcdppmul(op0,REAL_VALUE_NEGATE(op1)));
  6282. + else if (REAL_VALUE_ISPOSITIVE(op1)) /* and op0 negative */
  6283. + return REAL_VALUE_NEGATE(bcdppmul(REAL_VALUE_NEGATE(op0),op1));
  6284. + else /* both negative */
  6285. + return bcdppmul(REAL_VALUE_NEGATE(op0),REAL_VALUE_NEGATE(op1));
  6286. +}
  6287. +
  6288. +/* Divide 2 positive SMAP II BCD floats. Indicate if the computed result was exact. */
  6289. +static smap_bcd_float bcdppdiv(smap_bcd_float op0, smap_bcd_float op1, int *exactresult)
  6290. +{
  6291. + /* The dividend is represented multiplied by 10^16, and in 2 binary parts. The
  6292. + upper 64 bits and the lower ones. The divisor is represented in binary, in
  6293. + 2 parts to allow shifting. Compute the result mantissa in binary. */
  6294. + unsigned long long dividendh, dividendl=0, divisorh, divisorl=0, resultm=0;
  6295. + int i,d17,exponent;
  6296. + unsigned long long factor=1ull;
  6297. + /* Convert the mantissa of op0 to binary. */
  6298. + for (i=0;i<64;i+=4,factor*=10ull) /* for each digit of op0 */
  6299. + dividendl += (unsigned long long)((op0.mantissa>>i)&15)*factor;
  6300. + /* Multiply the dividend with 10^16. */
  6301. + dividendh = dividendl>>48; /* multiply first 16 bits with 2^16 */
  6302. + dividendh *= 152587890625ull; /* and with 5^16 */
  6303. + dividendl &= 0xFFFFFFFFFFFFull; /* remove them from dividendl */
  6304. + dividendl *= 15625ull; /* multiply the remaining 48 bits with 5^6
  6305. + we still have to multiply them by 2^16*5^10 */
  6306. + dividendh += (dividendl>>48)*9765625ull; /* multiply first 16 bits with 2^16*5^10 */
  6307. + dividendl &= 0xFFFFFFFFFFFFull; /* remove them from dividendl */
  6308. + dividendl *= 15625ull; /* multiply the remaining 48 bits with 5^6
  6309. + we still have to multiply them by 2^16*5^4 */
  6310. + dividendh += (dividendl>>48)*625ull; /* multiply first 16 bits with 2^16*5^4 */
  6311. + dividendl &= 0xFFFFFFFFFFFFull; /* remove them from dividendl */
  6312. + dividendl *= 625ull; /* multiply the remaining 48 bits with 5^4
  6313. + we still have to multiply them by 2^16 */
  6314. + dividendh += dividendl>>48; /* multiply first 16 bits with 2^16 */
  6315. + dividendl <<= 16; /* multiply the remaining 48 bits with 2^16 */
  6316. + /* Convert the mantissa of op1 to binary. */
  6317. + for (i=0,factor=1ull;i<64;i+=4,factor*=10ull) /* for each digit of op1 */
  6318. + divisorl += (unsigned long long)((op1.mantissa>>i)&15)*factor;
  6319. + /* Multiply the divisor with 2^56. We know that, due to normalization, the
  6320. + result is always <10^17, which is smaller than 2^57, so we don't have to go
  6321. + through the full 128-bit division. */
  6322. + divisorh = divisorl>>(64-56);
  6323. + divisorl <<= 56;
  6324. + /* Now do the 128-bit division. */
  6325. + for (i=56;i>=0;i--) {
  6326. + /* Shift the result to the left. */
  6327. + resultm <<= 1;
  6328. + /* Check if the divisor fits into the dividend. */
  6329. + if (divisorh<dividendh || (divisorh==dividendh && divisorl<=dividendl)) {
  6330. + /* Add 1 to the result. */
  6331. + resultm++;
  6332. + /* Subtract the divisor from the dividend. */
  6333. + if (dividendl<divisorl) /* handle carry, use unsigned wraparound overflow */
  6334. + dividendh--;
  6335. + dividendl -= divisorl; /* now do the subtraction */
  6336. + dividendh -= divisorh;
  6337. + }
  6338. + if (i) {
  6339. + /* Shift the divisor to the right. */
  6340. + divisorl = ((divisorh&1)<<63)+(divisorl>>1);
  6341. + divisorh >>= 1;
  6342. + }
  6343. + }
  6344. + /* dividendl now contains the remainder. It is always smaller than the
  6345. + divisor, so it always fits into 64 bits. divisorl now contains the original
  6346. + divisor. */
  6347. +
  6348. + if (exactresult)
  6349. + *exactresult = !dividendl; /* if there is a remainder, the result sure is
  6350. + not exact, otherwise, let's assume it is for
  6351. + a moment */
  6352. +
  6353. + /* Because of normalization, the result has either 16 or 17 digits. */
  6354. + d17 = (resultm>=10000000000000000ull/*10^16*/
  6355. + || (resultm==9999999999999999ull/*10^16-1*/
  6356. + && (dividendl<<1)>=divisorl) /* 2r>=d <=> r>=d/2 */);
  6357. + if (d17) { /* if we have 17 digits in the result, drop one */
  6358. + if (exactresult && (resultm%10ull)) /* if we are about to drop a non-0
  6359. + digit, the result is not exact
  6360. + anymore */
  6361. + *exactresult = 0;
  6362. + resultm = (resultm+5ull)/10ull; /* add 5 for correct rounding */
  6363. + } else {
  6364. + if ((dividendl<<1)>=divisorl /* r>=d/2 */) /* round remainder into result */
  6365. + resultm++;
  6366. + }
  6367. +
  6368. + /* Now compute the exponent. */
  6369. + exponent=op0.exponent-op1.exponent+0x4000-(!d17);
  6370. + if (exactresult && (exponent>0x4000+16383 || exponent<0x4000-16383))
  6371. + /* if we overflowed, the result is not exact anymore */
  6372. + *exactresult = 0;
  6373. + if (exponent>0x4000+16383) /* exponent too large, overflow to +infinity */
  6374. + return POSITIVE_INF;
  6375. + if (exponent<0x4000-16383) /* exponent too small, underflow to +0 */
  6376. + return POSITIVE_ZERO;
  6377. +
  6378. + /* Now convert resulth into a BCD mantissa. */
  6379. + {
  6380. + unsigned long long d;
  6381. + smap_bcd_float result={0,0};result.exponent=exponent;
  6382. + for (i=0;i<64;i+=4) { /* for each digit */
  6383. + d = resultm%10ull; /* Extract the digit. */
  6384. + resultm /= 10ull; /* We are done with this digit of the mantissa. */
  6385. + result.mantissa += d<<i; /* Store it into the resulting mantissa. */
  6386. + }
  6387. + return result;
  6388. + }
  6389. +}
  6390. +
  6391. +/* Divide 2 SMAP II BCD floats. Indicate if the computed result was exact. */
  6392. +static smap_bcd_float bcddiv(smap_bcd_float op0, smap_bcd_float op1, int *exactresult)
  6393. +{
  6394. + if (exactresult) *exactresult=1; /* special cases are all exact */
  6395. + if (REAL_VALUE_ISNAN(op0) || REAL_VALUE_ISNAN(op1)
  6396. + || (REAL_VALUE_ISINF(op0) && REAL_VALUE_ISINF(op1))
  6397. + || (REAL_VALUE_ISZERO(op0) && REAL_VALUE_ISZERO(op1))) /* keep NAN,
  6398. + 0/0=inf/inf=NAN */
  6399. + return NAN;
  6400. + else if (REAL_VALUES_IDENTICAL(op0,UNSIGNED_INF)
  6401. + || REAL_VALUES_IDENTICAL(op1,UNSIGNED_ZERO)) /* unsigned inf / finite
  6402. + = non-0 / unsigned 0 = unsigned inf */
  6403. + return UNSIGNED_INF;
  6404. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6405. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO)) /* +inf / +0 = +inf */
  6406. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6407. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO))) /* -inf / -0 = +inf */
  6408. + return POSITIVE_INF;
  6409. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6410. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO)) /* +inf / -0 = -inf */
  6411. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6412. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO))) /* -inf / +0 = -inf */
  6413. + return NEGATIVE_INF;
  6414. + /* Now we can assume that at least 1 of op0 and 1/op1 is finite, and that we
  6415. + don't have op0 = unsigned inf, op1 = unsigned 0, a NAN or an inf/inf or 0/0
  6416. + indeterminate form. */
  6417. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6418. + && REAL_VALUE_ISPOSITIVE(op1)) /* +inf / +non-0 = +inf */
  6419. + || (REAL_VALUE_ISPOSITIVE(op0)
  6420. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO)) /* +finite / +0 = +inf */
  6421. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6422. + && REAL_VALUE_ISNEGATIVE(op1)) /* -inf / -non-0 = +inf */
  6423. + || (REAL_VALUE_ISNEGATIVE(op0)
  6424. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO))) /* -finite / -0 = +inf */
  6425. + return POSITIVE_INF;
  6426. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6427. + && REAL_VALUE_ISNEGATIVE(op1)) /* +inf / -non-0 = -inf */
  6428. + || (REAL_VALUE_ISPOSITIVE(op0)
  6429. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_ZERO)) /* +finite / -0 = -inf */
  6430. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6431. + && REAL_VALUE_ISPOSITIVE(op1)) /* -inf / +non-0 = -inf */
  6432. + || (REAL_VALUE_ISNEGATIVE(op0)
  6433. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_ZERO))) /* -finite / +0 = -inf */
  6434. + return NEGATIVE_INF;
  6435. + /* Now we can assume that both of op0 and 1/op1 are finite. */
  6436. + else if (REAL_VALUES_IDENTICAL(op0,UNSIGNED_ZERO)
  6437. + || REAL_VALUES_IDENTICAL(op1,UNSIGNED_INF)) /* unsigned 0 / non-0 =
  6438. + finite / unsigned inf = unsigned 0 */
  6439. + return UNSIGNED_ZERO;
  6440. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6441. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF)) /* +0 / +inf = +0 */
  6442. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6443. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF))) /* -0 / -inf = +0 */
  6444. + return POSITIVE_ZERO;
  6445. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6446. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF)) /* +0 / -inf = -0 */
  6447. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6448. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF))) /* -0 / +inf = -0 */
  6449. + return NEGATIVE_ZERO;
  6450. + /* Now we can assume that both of op0 and 1/op1 are finite, at least 1 of them
  6451. + is non-0, and that neither of them is an unsigned 0. */
  6452. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6453. + && REAL_VALUE_ISPOSITIVE(op1)) /* +0 / +non-0 = +0 */
  6454. + || (REAL_VALUE_ISPOSITIVE(op0)
  6455. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF)) /* +finite / +inf = +0 */
  6456. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6457. + && REAL_VALUE_ISNEGATIVE(op1)) /* -0 / -non-0 = +0 */
  6458. + || (REAL_VALUE_ISNEGATIVE(op0)
  6459. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF))) /* -finite / -inf = +0 */
  6460. + return POSITIVE_ZERO;
  6461. + else if ((REAL_VALUES_IDENTICAL(op0,POSITIVE_ZERO)
  6462. + && REAL_VALUE_ISNEGATIVE(op1)) /* +0 / -non-0 = -0 */
  6463. + || (REAL_VALUE_ISPOSITIVE(op0)
  6464. + && REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF)) /* +finite / -inf = -0 */
  6465. + || (REAL_VALUES_IDENTICAL(op0,NEGATIVE_ZERO)
  6466. + && REAL_VALUE_ISPOSITIVE(op1)) /* -0 / +non-0 = -0 */
  6467. + || (REAL_VALUE_ISNEGATIVE(op0)
  6468. + && REAL_VALUES_IDENTICAL(op1,POSITIVE_INF))) /* -finite / +inf = -0 */
  6469. + return NEGATIVE_ZERO;
  6470. + /* Now we can assume that both values are finite and non-0. */
  6471. + else if (REAL_VALUE_ISPOSITIVE(op0) && REAL_VALUE_ISPOSITIVE(op1))
  6472. + return bcdppdiv(op0,op1,exactresult);
  6473. + else if (REAL_VALUE_ISPOSITIVE(op0)) /* and op1 negative */
  6474. + return REAL_VALUE_NEGATE(bcdppdiv(op0,REAL_VALUE_NEGATE(op1),exactresult));
  6475. + else if (REAL_VALUE_ISPOSITIVE(op1)) /* and op0 negative */
  6476. + return REAL_VALUE_NEGATE(bcdppdiv(REAL_VALUE_NEGATE(op0),op1,exactresult));
  6477. + else /* both negative */
  6478. + return bcdppdiv(REAL_VALUE_NEGATE(op0),REAL_VALUE_NEGATE(op1),exactresult);
  6479. +}
  6480. +
  6481. +/* Compute min of 2 SMAP II BCD floats. */
  6482. +static smap_bcd_float bcdmin(smap_bcd_float op0, smap_bcd_float op1)
  6483. +{
  6484. + if (REAL_VALUE_ISNANUINF(op0) || REAL_VALUE_ISNANUINF(op1)) /* keep NAN,
  6485. + UNSIGNED_INF is neither smaller nor larger than the other */
  6486. + return NAN;
  6487. + else if (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)
  6488. + || REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF)) /* keep -infinity */
  6489. + return NEGATIVE_INF;
  6490. + else if (REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)) /* all numbers are smaller
  6491. + than +infinity */
  6492. + return op1;
  6493. + else if (REAL_VALUES_IDENTICAL(op1,POSITIVE_INF)) /* all numbers are smaller
  6494. + than +infinity */
  6495. + return op0;
  6496. + /* Now, we can assume that all values are finite. */
  6497. + else if (REAL_VALUES_LESS(op0,op1)) /* if op0<op1, return op0 */
  6498. + return op0;
  6499. + else /* if op0>=op1, return op1 */
  6500. + return op1;
  6501. +}
  6502. +
  6503. +/* Compute max of 2 SMAP II BCD floats. */
  6504. +static smap_bcd_float bcdmax(smap_bcd_float op0, smap_bcd_float op1)
  6505. +{
  6506. + if (REAL_VALUE_ISNANUINF(op0) || REAL_VALUE_ISNANUINF(op1)) /* keep NAN,
  6507. + UNSIGNED_INF is neither smaller nor larger than the other */
  6508. + return NAN;
  6509. + else if (REAL_VALUES_IDENTICAL(op0,POSITIVE_INF)
  6510. + || REAL_VALUES_IDENTICAL(op1,POSITIVE_INF)) /* keep +infinity */
  6511. + return POSITIVE_INF;
  6512. + else if (REAL_VALUES_IDENTICAL(op0,NEGATIVE_INF)) /* all numbers are smaller
  6513. + than -infinity */
  6514. + return op1;
  6515. + else if (REAL_VALUES_IDENTICAL(op1,NEGATIVE_INF)) /* all numbers are smaller
  6516. + than -infinity */
  6517. + return op0;
  6518. + /* Now, we can assume that all values are finite. */
  6519. + else if (REAL_VALUES_LESS(op0,op1)) /* if op0<op1, return op1 */
  6520. + return op1;
  6521. + else /* if op0>=op1, return op0 */
  6522. + return op0;
  6523. +}
  6524. /* Perform the binary or unary operation described by CODE.
  6525. For a unary operation, leave OP1 NULL. This function returns
  6526. @@ -982,6 +1593,37 @@
  6527. real_arithmetic (REAL_VALUE_TYPE *r, int icode, const REAL_VALUE_TYPE *op0,
  6528. const REAL_VALUE_TYPE *op1)
  6529. {
  6530. + switch (icode)
  6531. + {
  6532. + case PLUS_EXPR:
  6533. + *r = bcdadd (*op0, *op1);
  6534. + return true;
  6535. +
  6536. + case MINUS_EXPR:
  6537. + *r = bcdsub (*op0, *op1);
  6538. + return true;
  6539. +
  6540. + case MULT_EXPR:
  6541. + *r = bcdmul (*op0, *op1);
  6542. + return true;
  6543. +
  6544. + case RDIV_EXPR:
  6545. + *r = bcddiv (*op0, *op1, NULL);
  6546. + return true;
  6547. +
  6548. + case MIN_EXPR:
  6549. + *r = bcdmin (*op0, *op1);
  6550. + return false;
  6551. +
  6552. + case MAX_EXPR:
  6553. + *r = bcdmax (*op0, *op1);
  6554. + return false;
  6555. +
  6556. + default:
  6557. + gcc_unreachable ();
  6558. + }
  6559. +
  6560. +#if 0
  6561. enum tree_code code = icode;
  6562. switch (code)
  6563. @@ -1033,9 +1675,11 @@
  6564. default:
  6565. gcc_unreachable ();
  6566. }
  6567. +#endif /* 0 */
  6568. return false;
  6569. }
  6570. +#if 0
  6571. /* Legacy. Similar, but return the result directly. */
  6572. REAL_VALUE_TYPE
  6573. @@ -1046,6 +1690,7 @@
  6574. real_arithmetic (&r, icode, op0, op1);
  6575. return r;
  6576. }
  6577. +#endif /* 0 */
  6578. bool
  6579. real_compare (int icode, const REAL_VALUE_TYPE *op0,
  6580. @@ -1056,39 +1701,40 @@
  6581. switch (code)
  6582. {
  6583. case LT_EXPR:
  6584. - return do_compare (op0, op1, 1) < 0;
  6585. + return REAL_VALUES_LESS (*op0, *op1);
  6586. case LE_EXPR:
  6587. - return do_compare (op0, op1, 1) <= 0;
  6588. + return !real_compare (UNGT_EXPR, op0, op1);
  6589. case GT_EXPR:
  6590. - return do_compare (op0, op1, -1) > 0;
  6591. + return real_compare (LT_EXPR, op1, op0);
  6592. case GE_EXPR:
  6593. - return do_compare (op0, op1, -1) >= 0;
  6594. + return !real_compare (UNLT_EXPR, op0, op1);
  6595. case EQ_EXPR:
  6596. - return do_compare (op0, op1, -1) == 0;
  6597. + return REAL_VALUES_EQUAL (*op0, *op1);
  6598. case NE_EXPR:
  6599. - return do_compare (op0, op1, -1) != 0;
  6600. + return !real_compare (EQ_EXPR, op0, op1);
  6601. case UNORDERED_EXPR:
  6602. - return op0->cl == rvc_nan || op1->cl == rvc_nan;
  6603. + return REAL_VALUE_ISNANUINF (*op0) || REAL_VALUE_ISNANUINF (*op1);
  6604. case ORDERED_EXPR:
  6605. - return op0->cl != rvc_nan && op1->cl != rvc_nan;
  6606. + return !real_compare (UNORDERED_EXPR, op0, op1);
  6607. case UNLT_EXPR:
  6608. - return do_compare (op0, op1, -1) < 0;
  6609. + return real_compare (UNORDERED_EXPR, op0, op1) || real_compare (LT_EXPR, op0, op1);
  6610. case UNLE_EXPR:
  6611. - return do_compare (op0, op1, -1) <= 0;
  6612. + return !real_compare (GT_EXPR, op0, op1);
  6613. case UNGT_EXPR:
  6614. - return do_compare (op0, op1, 1) > 0;
  6615. + return real_compare (UNORDERED_EXPR, op0, op1) || real_compare (GT_EXPR, op0, op1);
  6616. case UNGE_EXPR:
  6617. - return do_compare (op0, op1, 1) >= 0;
  6618. + return !real_compare (LT_EXPR, op0, op1);
  6619. case UNEQ_EXPR:
  6620. - return do_compare (op0, op1, 0) == 0;
  6621. + return real_compare (UNORDERED_EXPR, op0, op1) || real_compare (EQ_EXPR, op0, op1);
  6622. case LTGT_EXPR:
  6623. - return do_compare (op0, op1, 0) != 0;
  6624. + return !real_compare (UNEQ_EXPR, op0, op1);
  6625. default:
  6626. gcc_unreachable ();
  6627. }
  6628. }
  6629. +#if 0
  6630. /* Return floor log2(R). */
  6631. int
  6632. @@ -1209,6 +1855,7 @@
  6633. return true;
  6634. }
  6635. +#endif /* 0 */
  6636. /* Try to change R into its exact multiplicative inverse in machine
  6637. mode MODE. Return true if successful. */
  6638. @@ -1216,6 +1863,13 @@
  6639. bool
  6640. exact_real_inverse (enum machine_mode mode, REAL_VALUE_TYPE *r)
  6641. {
  6642. + int exactresult=0;
  6643. + smap_bcd_float one={0x4000,0x1000000000000000ull}, invr;
  6644. +
  6645. + invr = bcddiv(one,*r,&exactresult);
  6646. + if (exactresult) *r=invr;
  6647. + return exactresult;
  6648. +#if 0
  6649. const REAL_VALUE_TYPE *one = real_digit (1);
  6650. REAL_VALUE_TYPE u;
  6651. int i;
  6652. @@ -1245,8 +1899,10 @@
  6653. *r = u;
  6654. return true;
  6655. +#endif /* 0 */
  6656. }
  6657. +#if 0
  6658. /* Render R as an integer. */
  6659. HOST_WIDE_INT
  6660. @@ -1298,6 +1954,7 @@
  6661. gcc_unreachable ();
  6662. }
  6663. }
  6664. +#endif /* 0 */
  6665. /* Likewise, but to an integer pair, HI+LOW. */
  6666. @@ -1305,6 +1962,59 @@
  6667. real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh,
  6668. const REAL_VALUE_TYPE *r)
  6669. {
  6670. + unsigned short exponent = (r->exponent & 0x7fff);
  6671. + unsigned HOST_WIDE_INT low = 0, high = 0;
  6672. + int e, i;
  6673. + unsigned long long mantissa = r->mantissa;
  6674. +
  6675. + /* Return 0 for transfinite, zero or |*r|<1 */
  6676. + if (!REAL_VALUE_ISFINITE(*r) || REAL_VALUE_ISZERO(*r) || exponent < 0x4000) {
  6677. + *plow = *phigh = 0;
  6678. + return;
  6679. + }
  6680. +
  6681. + /* Compute the effective exponent */
  6682. + e = (int)exponent - (0x4000+15);
  6683. +
  6684. + /* Delete any digits following the decimal point right now */
  6685. + if (e < 0) {
  6686. + mantissa >>= ((-e)<<2);
  6687. + e = 0;
  6688. + } else if (e > 2*HOST_BITS_PER_WIDE_INT) {
  6689. + /* We'll multiply by 10^(2*HBPWI)=5^(2*HBPWI)*2^(2*HBPWI). This will zero
  6690. + out all digits. So avoid the long loop and return 0 right now. */
  6691. + *plow = *phigh = 0;
  6692. + return;
  6693. + }
  6694. +
  6695. + /* Convert the mantissa from BCD to binary */
  6696. + for (i=60;i>=0;i-=4) {
  6697. + /* Multiply by 10 using x*10=(x<<3)+(x<<1) */
  6698. + high = (high<<3) + (low>>(HOST_BITS_PER_WIDE_INT-3)) /* (x<<3) */
  6699. + + (high<<1) + (low>>(HOST_BITS_PER_WIDE_INT-1)) /* (x<<1) */
  6700. + + ((low<<3) + (low<<1) < (low<<1)); /* (carry) */
  6701. + low = (low<<3) + (low<<1);
  6702. + low += (mantissa>>i)&15;
  6703. + }
  6704. +
  6705. + /* Multiply by 10^e */
  6706. + for (i=0;i<e;i++) {
  6707. + /* Multiply by 10 using x*10=(x<<3)+(x<<1) */
  6708. + high = (high<<3) + (low>>(HOST_BITS_PER_WIDE_INT-3)) /* (x<<3) */
  6709. + + (high<<1) + (low>>(HOST_BITS_PER_WIDE_INT-1)) /* (x<<1) */
  6710. + + ((low<<3) + (low<<1) < (low<<1)); /* (carry) */
  6711. + low = (low<<3) + (low<<1);
  6712. + }
  6713. +
  6714. + /* Negate the result if *r was negative */
  6715. + if (r->exponent >= 0x8000) {
  6716. + if (low == 0)
  6717. + high = -high;
  6718. + else
  6719. + low = -low, high = ~high;
  6720. + }
  6721. +
  6722. +#if 0
  6723. REAL_VALUE_TYPE t;
  6724. HOST_WIDE_INT low, high;
  6725. int exp;
  6726. @@ -1370,11 +2080,13 @@
  6727. default:
  6728. gcc_unreachable ();
  6729. }
  6730. +#endif /* 0 */
  6731. *plow = low;
  6732. *phigh = high;
  6733. }
  6734. +#if 0
  6735. /* A subroutine of real_to_decimal. Compute the quotient and remainder
  6736. of NUM / DEN. Return the quotient and place the remainder in NUM.
  6737. It is expected that NUM / DEN are close enough that the quotient is
  6738. @@ -1749,6 +2461,326 @@
  6739. sprintf (p, "p%+d", exp);
  6740. }
  6741. +#endif /* 0 */
  6742. +
  6743. +static void real_value_dtof (REAL_VALUE_TYPE *r, const char *string)
  6744. +{
  6745. + const char *strpart = string;
  6746. + unsigned char state = 0;
  6747. + unsigned long long mpmul = 0x1000000000000000ull;
  6748. + signed short expshift = -1;
  6749. + unsigned short exp = 0;
  6750. + unsigned short expmul = 1;
  6751. + unsigned short expadd = 0;
  6752. + int endrounding = -1;
  6753. + r->mantissa = 0;
  6754. + while (strpart && *strpart)
  6755. + {
  6756. + switch (state)
  6757. + {
  6758. + case 0:
  6759. + if (*strpart == '.')
  6760. + {
  6761. + state = 1;
  6762. + break;
  6763. + }
  6764. + else if (*strpart == '+')
  6765. + expadd = 0;
  6766. + else if (*strpart == '-')
  6767. + expadd = 0x8000;
  6768. + else if (((*strpart) >= '0' && (*strpart) <= '9') && ((r->mantissa) || (*strpart != '0')))
  6769. + expshift++;
  6770. + else if ((*strpart == 'i') || (*strpart == 'I'))
  6771. + {
  6772. + if (expadd == 0x8000)
  6773. + *r = NEGATIVE_INF;
  6774. + else
  6775. + *r = POSITIVE_INF;
  6776. + expadd = 0x3FFF;
  6777. + strpart = 0;
  6778. + }
  6779. + else if ((*strpart == 'n') || (*strpart == 'N'))
  6780. + {
  6781. + *r = NAN;
  6782. + expadd = 0x3FFF;
  6783. + strpart = 0;
  6784. + }
  6785. + case 1:
  6786. + if ((*strpart == 'e') || (*strpart == 'E'))
  6787. + state = 2;
  6788. + else if ((*strpart) >= '0' && (*strpart) <= '9')
  6789. + {
  6790. + if (mpmul)
  6791. + r->mantissa |= (*strpart - '0') * mpmul;
  6792. + else if (endrounding < 0)
  6793. + endrounding = (*strpart >= '5');
  6794. + if (r->mantissa)
  6795. + mpmul /= 0x10;
  6796. + else if (state)
  6797. + expshift--;
  6798. + }
  6799. + break;
  6800. + case 2:
  6801. + if (*strpart == '+')
  6802. + expmul = 1;
  6803. + else if (*strpart == '-')
  6804. + expmul = -1;
  6805. + if ((*strpart) >= '0' && (*strpart) <= '9')
  6806. + {
  6807. + exp *= 10;
  6808. + exp += (*strpart - '0');
  6809. + }
  6810. + break;
  6811. + }
  6812. + if (strpart)
  6813. + strpart++;
  6814. + else
  6815. + break;
  6816. + }
  6817. + if (!(r->mantissa))
  6818. + *r = ZERO;
  6819. + else if (expadd != 0x3FFF)
  6820. + {
  6821. + r->exponent = exp * expmul + 0x4000 + expshift;
  6822. + if (r->exponent>0x4000+16383) /* exponent too large, overflow to +infinity */
  6823. + *r = POSITIVE_INF;
  6824. + else if (r->exponent<0x4000-16383) /* exponent too small, underflow to +0 */
  6825. + *r = POSITIVE_ZERO;
  6826. + else if (endrounding > 0)
  6827. + bcdpadd1ulp (r);
  6828. + r->exponent += expadd;
  6829. + }
  6830. +}
  6831. +
  6832. +typedef struct {
  6833. + int ndigits;
  6834. + unsigned char *digits;
  6835. + long effexp;
  6836. +} arbprec_decimal;
  6837. +
  6838. +static void arbprec_pack (arbprec_decimal *r)
  6839. +{
  6840. + unsigned char *p = r->digits;
  6841. + if (r->ndigits) {
  6842. + while (p < r->digits + r->ndigits && !*p) p++;
  6843. + r->ndigits -= p - r->digits;
  6844. + memmove (r->digits, p, r->ndigits);
  6845. + if (r->ndigits) {
  6846. + p = r->digits + r->ndigits - 1;
  6847. + while (p > r->digits && !*p) {
  6848. + p--;
  6849. + r->effexp++;
  6850. + }
  6851. + r->ndigits = (p + 1) - r->digits;
  6852. + }
  6853. + r->digits = xrealloc (r->digits, r->ndigits);
  6854. + }
  6855. +}
  6856. +
  6857. +static void arbprec_mul2 (arbprec_decimal *r)
  6858. +{
  6859. + unsigned char *p;
  6860. + unsigned char carry = 0;
  6861. + r->ndigits++;
  6862. + r->digits = xrealloc (r->digits, r->ndigits);
  6863. + for (p = r->digits + r->ndigits - 1; p > r->digits; p--) {
  6864. + unsigned char digit = (p[-1]<<1) + carry;
  6865. + *p = digit % 10;
  6866. + carry = digit / 10;
  6867. + }
  6868. + *p = carry;
  6869. + arbprec_pack (r);
  6870. +}
  6871. +
  6872. +static void arbprec_div2 (arbprec_decimal *r)
  6873. +{
  6874. + unsigned char *p;
  6875. + unsigned char carry = 0;
  6876. + r->ndigits++;
  6877. + r->digits = xrealloc (r->digits, r->ndigits);
  6878. + for (p = r->digits; p < r->digits + r->ndigits - 1; p++) {
  6879. + unsigned char digit = (*p>>1) + carry;
  6880. + carry = (*p&1)*5;
  6881. + *p = digit;
  6882. + }
  6883. + *p = carry;
  6884. + r->effexp--;
  6885. + arbprec_pack (r);
  6886. +}
  6887. +
  6888. +static void arbprec_mul16 (arbprec_decimal *r)
  6889. +{
  6890. + arbprec_mul2 (r);
  6891. + arbprec_mul2 (r);
  6892. + arbprec_mul2 (r);
  6893. + arbprec_mul2 (r);
  6894. +}
  6895. +
  6896. +static void arbprec_div16 (arbprec_decimal *r)
  6897. +{
  6898. + arbprec_div2 (r);
  6899. + arbprec_div2 (r);
  6900. + arbprec_div2 (r);
  6901. + arbprec_div2 (r);
  6902. +}
  6903. +
  6904. +static void arbprec_add (arbprec_decimal *r1, arbprec_decimal *r2)
  6905. +{
  6906. + if (!r2->ndigits)
  6907. + return;
  6908. + else if (!r1->ndigits) {
  6909. + r1->digits = xrealloc (r1->digits, r2->ndigits);
  6910. + memcpy (r1->digits, r2->digits, r2->ndigits);
  6911. + r1->ndigits = r2->ndigits;
  6912. + r1->effexp = r2->effexp;
  6913. + } else {
  6914. + if (r1->effexp > r2->effexp) {
  6915. + long effexpdiff = r1->effexp - r2->effexp;
  6916. + r1->digits = xrealloc (r1->digits, r1->ndigits + effexpdiff);
  6917. + memset (r1->digits + r1->ndigits, 0, effexpdiff);
  6918. + r1->ndigits += effexpdiff;
  6919. + r1->effexp = r2->effexp;
  6920. + } else if (r2->effexp > r1->effexp) {
  6921. + long effexpdiff = r2->effexp - r1->effexp;
  6922. + r2->digits = xrealloc (r2->digits, r2->ndigits + effexpdiff);
  6923. + memset (r2->digits + r2->ndigits, 0, effexpdiff);
  6924. + r2->ndigits += effexpdiff;
  6925. + r2->effexp = r1->effexp;
  6926. + }
  6927. +
  6928. + {
  6929. + int ndigits = MAX (r1->ndigits, r2->ndigits) + 1;
  6930. + unsigned char *digits = xmalloc (ndigits);
  6931. + unsigned char *p, *q1, *q2;
  6932. + unsigned char carry = 0;
  6933. + for (p = digits + ndigits - 1, q1 = r1->digits + r1->ndigits - 1,
  6934. + q2 = r2->digits + r2->ndigits - 1; p > digits; p--, q1--, q2--) {
  6935. + unsigned char digit = (q1>=r1->digits?*q1:0) + (q2>=r2->digits?*q2:0)
  6936. + + carry;
  6937. + *p = digit % 10;
  6938. + carry = digit / 10;
  6939. + }
  6940. + *p = carry;
  6941. + free (r1->digits);
  6942. + r1->digits = digits;
  6943. + r1->ndigits = ndigits;
  6944. + arbprec_pack (r1);
  6945. + arbprec_pack (r2);
  6946. + }
  6947. + }
  6948. +}
  6949. +
  6950. +static void arbprec_add_n_times (arbprec_decimal *r1, arbprec_decimal *r2, int n)
  6951. +{
  6952. + int i;
  6953. + for (i = 0; i < n; i++) arbprec_add (r1, r2);
  6954. +}
  6955. +
  6956. +static void arbprec_to_bcd (arbprec_decimal *a, smap_bcd_float *r)
  6957. +{
  6958. + if (a->ndigits) {
  6959. + long exponent = a->effexp + a->ndigits - 1;
  6960. + if (exponent>16383) /* exponent too large, overflow to +infinity */
  6961. + *r = POSITIVE_INF;
  6962. + else if (exponent<-16383) /* exponent too small, underflow to +0 */
  6963. + *r = POSITIVE_ZERO;
  6964. + else {
  6965. + int i;
  6966. + r->exponent = 0x4000 + exponent;
  6967. + r->mantissa = 0;
  6968. + for (i = 0; i < a->ndigits && i < 16; i++) {
  6969. + r->mantissa = (r->mantissa << 4) + a->digits[i];
  6970. + }
  6971. + for (; i < 16; i++) {
  6972. + r->mantissa <<= 4;
  6973. + }
  6974. + if (a->ndigits > 16 && a->digits[16] >= 5)
  6975. + bcdpadd1ulp (r);
  6976. + }
  6977. + } else {
  6978. + *r = UNSIGNED_ZERO;
  6979. + }
  6980. +}
  6981. +
  6982. +static void real_value_htof (REAL_VALUE_TYPE *res, const char *string)
  6983. +{
  6984. + arbprec_decimal r = {0, NULL, 0};
  6985. + const char *strpart = string;
  6986. + signed char state = -1;
  6987. + arbprec_decimal rdiv = {1, NULL, 0};
  6988. + unsigned int negative = 0;
  6989. + unsigned short exp = 0;
  6990. + unsigned short expsign = 1;
  6991. + rdiv.digits = xmalloc (1);
  6992. + *(rdiv.digits) = 1;
  6993. + while (strpart && *strpart)
  6994. + {
  6995. + switch (state)
  6996. + {
  6997. + case -1:
  6998. + if (*strpart == 'x' || *strpart == 'X')
  6999. + state = 0;
  7000. + else if (*strpart == '+')
  7001. + negative = 0;
  7002. + else if (*strpart == '-')
  7003. + negative = 1;
  7004. + break;
  7005. + case 0:
  7006. + if (*strpart == '.')
  7007. + {
  7008. + state = 1;
  7009. + break;
  7010. + }
  7011. + else if ((*strpart >= '0' && *strpart <= '9') || (*strpart >= 'a' && *strpart <= 'f') || (*strpart >= 'A' && *strpart <= 'F'))
  7012. + arbprec_mul16 (&r);
  7013. + case 1:
  7014. + if (state == 1)
  7015. + arbprec_div16 (&rdiv);
  7016. + if ((*strpart == 'p') || (*strpart == 'P'))
  7017. + state = 2;
  7018. + else if (*strpart >= '0' && *strpart <= '9')
  7019. + arbprec_add_n_times (&r, &rdiv, (*strpart - '0'));
  7020. + else if (*strpart >= 'a' && *strpart <= 'f')
  7021. + arbprec_add_n_times (&r, &rdiv, (*strpart - 'a' + 0xA));
  7022. + else if (*strpart >= 'A' && *strpart <= 'F')
  7023. + arbprec_add_n_times (&r, &rdiv, (*strpart - 'A' + 0xA));
  7024. + break;
  7025. + case 2:
  7026. + if (*strpart == '+')
  7027. + expsign = 1;
  7028. + else if (*strpart == '-')
  7029. + expsign = -1;
  7030. + if ((*strpart) >= '0' && (*strpart) <= '9')
  7031. + {
  7032. + exp *= 10;
  7033. + exp += (*strpart - '0');
  7034. + }
  7035. + break;
  7036. + }
  7037. + strpart++;
  7038. + }
  7039. + free (rdiv.digits);
  7040. + if (expsign == 1)
  7041. + {
  7042. + while (exp)
  7043. + {
  7044. + arbprec_mul2 (&r);
  7045. + exp--;
  7046. + }
  7047. + }
  7048. + else
  7049. + {
  7050. + while (exp)
  7051. + {
  7052. + arbprec_div2 (&r);
  7053. + exp--;
  7054. + }
  7055. + }
  7056. + arbprec_to_bcd (&r, res);
  7057. + free (r.digits);
  7058. + if (negative)
  7059. + *res = REAL_VALUE_NEGATE (*res);
  7060. +}
  7061. /* Initialize R from a decimal or hexadecimal string. The string is
  7062. assumed to have been syntax checked already. */
  7063. @@ -1756,6 +2788,17 @@
  7064. void
  7065. real_from_string (REAL_VALUE_TYPE *r, const char *str)
  7066. {
  7067. + const char *p = str;
  7068. +
  7069. + if (*p == '-' || *p == '+')
  7070. + p++;
  7071. +
  7072. + if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X'))
  7073. + real_value_htof (r, str);
  7074. + else
  7075. + real_value_dtof (r, str);
  7076. +
  7077. +#if 0
  7078. int exp = 0;
  7079. bool sign = false;
  7080. @@ -1941,6 +2984,7 @@
  7081. overflow:
  7082. get_inf (r, sign);
  7083. return;
  7084. +#endif /* 0 */
  7085. }
  7086. /* Legacy. Similar, but return the result directly. */
  7087. @@ -1964,6 +3008,67 @@
  7088. unsigned HOST_WIDE_INT low, HOST_WIDE_INT high,
  7089. int unsigned_p)
  7090. {
  7091. + int j, e = -1, lastdigit = 0;
  7092. + bool negative = high < 0 && !unsigned_p;
  7093. + unsigned HOST_WIDE_INT uhigh = (unsigned HOST_WIDE_INT)high;
  7094. + unsigned HOST_WIDE_INT ulow = low;
  7095. + unsigned HOST_WIDE_INT remainderh, remainderl, divisorh, divisorl;
  7096. + unsigned long long mantissa = 0;
  7097. +
  7098. + if (negative) {
  7099. + uhigh = ~uhigh;
  7100. + if (!ulow) uhigh++; else ulow = -ulow;
  7101. + }
  7102. +
  7103. + /* Convert the integer to BCD */
  7104. + while (uhigh || ulow) {
  7105. + remainderh = uhigh; remainderl = ulow;
  7106. + divisorl = uhigh = ulow = 0;
  7107. + divisorh = (HOST_WIDE_INT)10<<(HOST_BITS_PER_WIDE_INT-4);
  7108. + /* Divide the pair of HOST_WIDE_INTs by 10 */
  7109. + for (j=2*HOST_BITS_PER_WIDE_INT-4;j>=0;j--) {
  7110. + /* Shift the result to the left. */
  7111. + uhigh = (uhigh<<1) + (ulow>>(HOST_BITS_PER_WIDE_INT-1));
  7112. + ulow <<= 1;
  7113. + /* Check if the divisor 10 fits into the dividend. */
  7114. + if (divisorh<remainderh || (divisorh==remainderh && divisorl<=remainderl)) {
  7115. + /* Add 1 to the result. */
  7116. + ulow++;
  7117. + if (!ulow) uhigh++; /* handle carry */
  7118. + /* Subtract the divisor from the dividend. */
  7119. + if (remainderl<divisorl) /* handle carry, use unsigned wraparound overflow */
  7120. + remainderh--;
  7121. + remainderl -= divisorl; /* now do the subtraction */
  7122. + remainderh -= divisorh;
  7123. + }
  7124. + if (j) {
  7125. + /* Shift the divisor to the right. */
  7126. + divisorl = ((divisorh&1)<<(HOST_BITS_PER_WIDE_INT-1))+(divisorl>>1);
  7127. + divisorh >>= 1;
  7128. + }
  7129. + }
  7130. + e++;
  7131. + lastdigit = (mantissa&15);
  7132. + mantissa = (mantissa>>4) + ((unsigned long long)remainderl<<60);
  7133. + }
  7134. +
  7135. + if (e >= 0) {
  7136. + /* We have a nonnegative exponent. Do the correct rounding for the last
  7137. + digit. */
  7138. +
  7139. + r->exponent = e+0x4000;
  7140. + r->mantissa = mantissa;
  7141. +
  7142. + if (lastdigit >= 5) bcdpadd1ulp(r);
  7143. + } else {
  7144. + /* We don't have any digit, so our number is actually zero. */
  7145. + *r = UNSIGNED_ZERO;
  7146. + }
  7147. +
  7148. + /* Negate *r if the integer was negative */
  7149. + if (negative) *r = REAL_VALUE_NEGATE (*r);
  7150. +
  7151. +#if 0
  7152. if (low == 0 && high == 0)
  7153. get_zero (r, 0);
  7154. else
  7155. @@ -2001,8 +3106,10 @@
  7156. if (mode != VOIDmode)
  7157. real_convert (r, mode, r);
  7158. +#endif /* 0 */
  7159. }
  7160. +#if 0
  7161. /* Returns 10**2**N. */
  7162. static const REAL_VALUE_TYPE *
  7163. @@ -2490,6 +3597,7 @@
  7164. return fmt->p * fmt->log2_b;
  7165. }
  7166. +#endif /* 0 */
  7167. /* Return a hash value for the given real value. */
  7168. /* ??? The "unsigned int" return value is intended to be hashval_t,
  7169. @@ -2498,6 +3606,12 @@
  7170. unsigned int
  7171. real_hash (const REAL_VALUE_TYPE *r)
  7172. {
  7173. + /* (TIGCC) Very naive hash for lack of something better. -- Kevin Kofler */
  7174. + unsigned int h=r->exponent;
  7175. + return h+(unsigned int)(r->mantissa >>
  7176. + ((sizeof(unsigned long long)-sizeof(unsigned int))*8));
  7177. +
  7178. +#if 0
  7179. unsigned int h;
  7180. size_t i;
  7181. @@ -2534,8 +3648,10 @@
  7182. h ^= r->sig[i];
  7183. return h;
  7184. +#endif /* 0 */
  7185. }
  7186. +#if 0
  7187. /* IEEE single-precision format. */
  7188. static void encode_ieee_single (const struct real_format *fmt,
  7189. @@ -4705,4 +5821,5 @@
  7190. {
  7191. r->sign = x->sign;
  7192. }
  7193. +#endif /* 0 */
  7194. diff -Naur gcc-4.1.2.orig/gcc/real.h gcc-4.1.2-src/gcc/real.h
  7195. --- gcc-4.1.2.orig/gcc/real.h 2005-08-01 23:16:31.000000000 +0200
  7196. +++ gcc-4.1.2-src/gcc/real.h 2007-02-19 02:32:34.000000000 +0100
  7197. @@ -22,6 +22,22 @@
  7198. #ifndef GCC_REAL_H
  7199. #define GCC_REAL_H
  7200. +/* (TIGCC) smapbcd.h need this, but gengtype needs it to be in this file. */
  7201. +/* (TIGCC) Hack to make gengtype shut up while still packing the structure. */
  7202. +#define exponent exponent __attribute__((packed))
  7203. +#define mantissa mantissa __attribute__((packed))
  7204. +__attribute__ ((packed))
  7205. +struct real_value GTY(())
  7206. +{
  7207. + unsigned short exponent;
  7208. + unsigned long long mantissa;
  7209. +};
  7210. +#undef exponent
  7211. +#undef mantissa
  7212. +
  7213. +#include <config/smapbcd.h>
  7214. +#define SMAP_BCD_FLOAT_FORMAT 5
  7215. +
  7216. #include "machmode.h"
  7217. /* An expanded form of the represented number. */
  7218. @@ -40,19 +56,22 @@
  7219. #define SIGSZ (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
  7220. #define SIG_MSB ((unsigned long)1 << (HOST_BITS_PER_LONG - 1))
  7221. +/*
  7222. struct real_value GTY(())
  7223. {
  7224. - /* Use the same underlying type for all bit-fields, so as to make
  7225. + ** Use the same underlying type for all bit-fields, so as to make
  7226. sure they're packed together, otherwise REAL_VALUE_TYPE_SIZE will
  7227. - be miscomputed. */
  7228. - unsigned int /* ENUM_BITFIELD (real_value_class) */ cl : 2;
  7229. + be miscomputed. **
  7230. + unsigned int ** ENUM_BITFIELD (real_value_class) ** cl : 2;
  7231. unsigned int sign : 1;
  7232. unsigned int signalling : 1;
  7233. unsigned int canonical : 1;
  7234. unsigned int uexp : EXP_BITS;
  7235. unsigned long sig[SIGSZ];
  7236. };
  7237. -
  7238. +*/
  7239. +
  7240. +#if 0
  7241. #define REAL_EXP(REAL) \
  7242. ((int)((REAL)->uexp ^ (unsigned int)(1 << (EXP_BITS - 1))) \
  7243. - (1 << (EXP_BITS - 1)))
  7244. @@ -76,6 +95,9 @@
  7245. /* Verify the guess. */
  7246. extern char test_real_width
  7247. [sizeof(REAL_VALUE_TYPE) <= REAL_WIDTH*sizeof(HOST_WIDE_INT) ? 1 : -1];
  7248. +#endif /* 0 */
  7249. +
  7250. +#define REAL_WIDTH (11*8 + HOST_BITS_PER_WIDE_INT)/HOST_BITS_PER_WIDE_INT
  7251. /* Calculate the format for CONST_DOUBLE. We need as many slots as
  7252. are necessary to overlay a REAL_VALUE_TYPE on them. This could be
  7253. @@ -111,6 +133,7 @@
  7254. #endif
  7255. +#if 0
  7256. /* Describes the properties of the specific target format in use. */
  7257. struct real_format
  7258. {
  7259. @@ -167,6 +190,7 @@
  7260. case compile-time FP overflow may not model run-time overflow. */
  7261. #define REAL_MODE_FORMAT_COMPOSITE_P(MODE) \
  7262. ((REAL_MODE_FORMAT(MODE))->pnan < (REAL_MODE_FORMAT (MODE))->p)
  7263. +#endif /* 0 */
  7264. /* Declare functions in real.c. */
  7265. @@ -177,6 +201,7 @@
  7266. /* Compare reals by tree_code. */
  7267. extern bool real_compare (int, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
  7268. +#if 0
  7269. /* Determine whether a floating-point value X is infinite. */
  7270. extern bool real_isinf (const REAL_VALUE_TYPE *);
  7271. @@ -209,6 +234,7 @@
  7272. /* Render R as an integer. */
  7273. extern HOST_WIDE_INT real_to_integer (const REAL_VALUE_TYPE *);
  7274. +#endif /* 0 */
  7275. extern void real_to_integer2 (HOST_WIDE_INT *, HOST_WIDE_INT *,
  7276. const REAL_VALUE_TYPE *);
  7277. @@ -219,6 +245,7 @@
  7278. extern void real_from_integer (REAL_VALUE_TYPE *, enum machine_mode,
  7279. unsigned HOST_WIDE_INT, HOST_WIDE_INT, int);
  7280. +#if 0
  7281. extern long real_to_target_fmt (long *, const REAL_VALUE_TYPE *,
  7282. const struct real_format *);
  7283. extern long real_to_target (long *, const REAL_VALUE_TYPE *, enum machine_mode);
  7284. @@ -235,10 +262,12 @@
  7285. extern void real_maxval (REAL_VALUE_TYPE *, int, enum machine_mode);
  7286. extern void real_2expN (REAL_VALUE_TYPE *, int);
  7287. +#endif /* 0 */
  7288. extern unsigned int real_hash (const REAL_VALUE_TYPE *);
  7289. +#if 0
  7290. /* Target formats defined in real.c. */
  7291. extern const struct real_format ieee_single_format;
  7292. extern const struct real_format mips_single_format;
  7293. @@ -318,9 +347,11 @@
  7294. real_arithmetic2 (ABS_EXPR, &(X), NULL)
  7295. extern int significand_size (enum machine_mode);
  7296. +#endif /* 0 */
  7297. extern REAL_VALUE_TYPE real_from_string2 (const char *, enum machine_mode);
  7298. +#if 0
  7299. #define REAL_VALUE_ATOF(s, m) \
  7300. real_from_string2 (s, m)
  7301. @@ -343,6 +374,7 @@
  7302. extern void real_ldexp (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, int);
  7303. /* **** End of software floating point emulator interface macros **** */
  7304. +#endif /* 0 */
  7305. /* Constant real values 0, 1, 2, 3, 10, -1, -2, 0.5 and 1/3. */
  7306. @@ -355,8 +387,10 @@
  7307. extern REAL_VALUE_TYPE dconstm2;
  7308. extern REAL_VALUE_TYPE dconsthalf;
  7309. extern REAL_VALUE_TYPE dconstthird;
  7310. +#if 0
  7311. extern REAL_VALUE_TYPE dconstpi;
  7312. extern REAL_VALUE_TYPE dconste;
  7313. +#endif /* 0 */
  7314. /* Function to return a real value (not a tree node)
  7315. from a given integer constant. */
  7316. @@ -377,6 +411,7 @@
  7317. /* In tree.c: wrap up a REAL_VALUE_TYPE in a tree node. */
  7318. extern tree build_real (tree, REAL_VALUE_TYPE);
  7319. +#if 0
  7320. /* Calculate R as the square root of X in the given machine mode. */
  7321. extern bool real_sqrt (REAL_VALUE_TYPE *, enum machine_mode,
  7322. const REAL_VALUE_TYPE *);
  7323. @@ -397,5 +432,6 @@
  7324. /* Set the sign of R to the sign of X. */
  7325. extern void real_copysign (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
  7326. +#endif /* 0 */
  7327. #endif /* ! GCC_REAL_H */
  7328. diff -Naur gcc-4.1.2.orig/gcc/rtlanal.c gcc-4.1.2-src/gcc/rtlanal.c
  7329. --- gcc-4.1.2.orig/gcc/rtlanal.c 2006-12-16 20:24:56.000000000 +0100
  7330. +++ gcc-4.1.2-src/gcc/rtlanal.c 2007-02-19 02:49:27.000000000 +0100
  7331. @@ -3164,6 +3164,19 @@
  7332. if (offset == 0 || nregs_xmode == nregs_ymode)
  7333. return 0;
  7334. + /* (TIGCC 20050324) Subregs of a 10-byte mode are special, hardcode them. */
  7335. + if (GET_MODE_SIZE (xmode) == 10)
  7336. + {
  7337. + gcc_assert (nregs_xmode == 3);
  7338. +
  7339. + if (offset < 4)
  7340. + return 0;
  7341. + else if (offset < 8)
  7342. + return 1;
  7343. + else
  7344. + return 2;
  7345. + }
  7346. +
  7347. /* Size of ymode must not be greater than the size of xmode. */
  7348. mode_multiple = GET_MODE_SIZE (xmode) / GET_MODE_SIZE (ymode);
  7349. gcc_assert (mode_multiple != 0);
  7350. @@ -3237,6 +3250,28 @@
  7351. ? WORDS_BIG_ENDIAN : BYTES_BIG_ENDIAN))
  7352. return true;
  7353. + /* (TIGCC 20050324) Subregs of a 10-byte mode are special, hardcode them. */
  7354. + if (GET_MODE_SIZE (xmode) == 10)
  7355. + {
  7356. + switch (GET_MODE_SIZE (ymode))
  7357. + {
  7358. + case 1:
  7359. + return (offset == 3 || offset == 7 || offset == 9);
  7360. +
  7361. + case 2:
  7362. + return (offset == 2 || offset == 6 || offset == 8);
  7363. +
  7364. + case 4:
  7365. + return (offset == 0 || offset == 4);
  7366. +
  7367. + case 8:
  7368. + return !offset;
  7369. +
  7370. + default:
  7371. + return false;
  7372. + }
  7373. + }
  7374. +
  7375. /* If registers store different numbers of bits in the different
  7376. modes, we cannot generally form this subreg. */
  7377. regsize_xmode = GET_MODE_SIZE (xmode) / nregs_xmode;
  7378. diff -Naur gcc-4.1.2.orig/gcc/sdbout.c gcc-4.1.2-src/gcc/sdbout.c
  7379. --- gcc-4.1.2.orig/gcc/sdbout.c 2005-06-25 04:02:01.000000000 +0200
  7380. +++ gcc-4.1.2-src/gcc/sdbout.c 2007-02-19 02:32:34.000000000 +0100
  7381. @@ -1541,9 +1541,7 @@
  7382. #ifdef SDB_OUTPUT_SOURCE_LINE
  7383. SDB_OUTPUT_SOURCE_LINE (asm_out_file, line);
  7384. #else
  7385. - fprintf (asm_out_file, "\t.ln\t%d\n",
  7386. - ((sdb_begin_function_line > -1)
  7387. - ? line - sdb_begin_function_line : 1));
  7388. + fprintf (asm_out_file, "\t.ln\t%d\n", line);
  7389. #endif
  7390. }
  7391. }
  7392. diff -Naur gcc-4.1.2.orig/gcc/simplify-rtx.c gcc-4.1.2-src/gcc/simplify-rtx.c
  7393. --- gcc-4.1.2.orig/gcc/simplify-rtx.c 2006-08-11 09:52:01.000000000 +0200
  7394. +++ gcc-4.1.2-src/gcc/simplify-rtx.c 2007-02-19 02:32:34.000000000 +0100
  7395. @@ -494,13 +494,14 @@
  7396. both +0, (minus Y X) is the same as (minus X Y). If the
  7397. rounding mode is towards +infinity (or -infinity) then the two
  7398. expressions will be rounded differently. */
  7399. + /* (TIGCC 20050210) This identity is valid for us thanks to unsigned 0. */
  7400. if (GET_CODE (op) == MINUS
  7401. - && !HONOR_SIGNED_ZEROS (mode)
  7402. + /*&& !HONOR_SIGNED_ZEROS (mode)*/
  7403. && !HONOR_SIGN_DEPENDENT_ROUNDING (mode))
  7404. return simplify_gen_binary (MINUS, mode, XEXP (op, 1), XEXP (op, 0));
  7405. if (GET_CODE (op) == PLUS
  7406. - && !HONOR_SIGNED_ZEROS (mode)
  7407. + /*&& !HONOR_SIGNED_ZEROS (mode)*/
  7408. && !HONOR_SIGN_DEPENDENT_ROUNDING (mode))
  7409. {
  7410. /* (neg (plus A C)) is simplified to (minus -C A). */
  7411. @@ -701,7 +702,7 @@
  7412. lv = CONST_DOUBLE_LOW (op), hv = CONST_DOUBLE_HIGH (op);
  7413. REAL_VALUE_FROM_INT (d, lv, hv, mode);
  7414. - d = real_value_truncate (mode, d);
  7415. + d = REAL_VALUE_TRUNCATE (mode, d);
  7416. return CONST_DOUBLE_FROM_REAL_VALUE (d, mode);
  7417. }
  7418. else if (code == UNSIGNED_FLOAT && GET_MODE (op) == VOIDmode
  7419. @@ -729,7 +730,7 @@
  7420. hv = 0, lv &= GET_MODE_MASK (op_mode);
  7421. REAL_VALUE_FROM_UNSIGNED_INT (d, lv, hv, mode);
  7422. - d = real_value_truncate (mode, d);
  7423. + d = REAL_VALUE_TRUNCATE (mode, d);
  7424. return CONST_DOUBLE_FROM_REAL_VALUE (d, mode);
  7425. }
  7426. @@ -991,11 +992,7 @@
  7427. switch (code)
  7428. {
  7429. case SQRT:
  7430. - if (HONOR_SNANS (mode) && real_isnan (&d))
  7431. - return 0;
  7432. - real_sqrt (&t, mode, &d);
  7433. - d = t;
  7434. - break;
  7435. + return 0;
  7436. case ABS:
  7437. d = REAL_VALUE_ABS (d);
  7438. break;
  7439. @@ -1003,7 +1000,7 @@
  7440. d = REAL_VALUE_NEGATE (d);
  7441. break;
  7442. case FLOAT_TRUNCATE:
  7443. - d = real_value_truncate (mode, d);
  7444. + d = REAL_VALUE_TRUNCATE (mode, d);
  7445. break;
  7446. case FLOAT_EXTEND:
  7447. /* All this does is change the mode. */
  7448. @@ -1013,6 +1010,7 @@
  7449. break;
  7450. case NOT:
  7451. {
  7452. +#if 0
  7453. long tmp[4];
  7454. int i;
  7455. @@ -1020,6 +1018,11 @@
  7456. for (i = 0; i < 4; i++)
  7457. tmp[i] = ~tmp[i];
  7458. real_from_target (&d, tmp, mode);
  7459. +#else
  7460. + /* (TIGCC 20050205) Use SMAP BCD representation directly. */
  7461. + d.exponent = ~d.exponent;
  7462. + d.mantissa = ~d.mantissa;
  7463. +#endif /* 0 */
  7464. break;
  7465. }
  7466. default:
  7467. @@ -1046,7 +1049,7 @@
  7468. switch (code)
  7469. {
  7470. case FIX:
  7471. - if (REAL_VALUE_ISNAN (x))
  7472. + if (REAL_VALUE_ISNANUINF (x))
  7473. return const0_rtx;
  7474. /* Test against the signed upper bound. */
  7475. @@ -1091,7 +1094,7 @@
  7476. break;
  7477. case UNSIGNED_FIX:
  7478. - if (REAL_VALUE_ISNAN (x) || REAL_VALUE_NEGATIVE (x))
  7479. + if (REAL_VALUE_ISNANUINF (x) || REAL_VALUE_NEGATIVE (x))
  7480. return const0_rtx;
  7481. /* Test against the unsigned upper bound. */
  7482. @@ -1438,8 +1441,10 @@
  7483. /* Subtracting 0 has no effect unless the mode has signed zeros
  7484. and supports rounding towards -infinity. In such a case,
  7485. 0 - 0 is -0. */
  7486. + /* (TIGCC 20050210) This is invalid independently of the rounding mode
  7487. + for 3-sign-zeros. */
  7488. if (!(HONOR_SIGNED_ZEROS (mode)
  7489. - && HONOR_SIGN_DEPENDENT_ROUNDING (mode))
  7490. + /*&& HONOR_SIGN_DEPENDENT_ROUNDING (mode)*/)
  7491. && trueop1 == CONST0_RTX (mode))
  7492. return op0;
  7493. @@ -1575,8 +1580,11 @@
  7494. x is NaN, since x * 0 is then also NaN. Nor is it valid
  7495. when the mode has signed zeros, since multiplying a negative
  7496. number by 0 will give -0, not 0. */
  7497. + /* (TIGCC 20050210) We can do this for UNSIGNED_ZERO even when honoring
  7498. + signed zeros.
  7499. + Note: CONST0_RTX (BFmode) is UNSIGNED_ZERO. */
  7500. if (!HONOR_NANS (mode)
  7501. - && !HONOR_SIGNED_ZEROS (mode)
  7502. + /*&& !HONOR_SIGNED_ZEROS (mode)*/
  7503. && trueop1 == CONST0_RTX (mode)
  7504. && ! side_effects_p (op0))
  7505. return op1;
  7506. @@ -2155,6 +2163,7 @@
  7507. || code == IOR
  7508. || code == XOR)
  7509. {
  7510. +#if 0
  7511. long tmp0[4];
  7512. long tmp1[4];
  7513. REAL_VALUE_TYPE r;
  7514. @@ -2182,6 +2191,31 @@
  7515. }
  7516. }
  7517. real_from_target (&r, tmp0, mode);
  7518. +#else
  7519. + /* (TIGCC 20050205) Use SMAP BCD representation directly. */
  7520. + const REAL_VALUE_TYPE *tmp1;
  7521. + REAL_VALUE_TYPE r;
  7522. +
  7523. + r = *CONST_DOUBLE_REAL_VALUE (op0);
  7524. + tmp1 = CONST_DOUBLE_REAL_VALUE (op1);
  7525. + switch (code)
  7526. + {
  7527. + case AND:
  7528. + r.exponent &= tmp1->exponent;
  7529. + r.mantissa &= tmp1->mantissa;
  7530. + break;
  7531. + case IOR:
  7532. + r.exponent |= tmp1->exponent;
  7533. + r.mantissa |= tmp1->mantissa;
  7534. + break;
  7535. + case XOR:
  7536. + r.exponent ^= tmp1->exponent;
  7537. + r.mantissa ^= tmp1->mantissa;
  7538. + break;
  7539. + default:
  7540. + gcc_unreachable ();
  7541. + }
  7542. +#endif /* 0 */
  7543. return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
  7544. }
  7545. else
  7546. @@ -2261,7 +2295,7 @@
  7547. if ((flag_rounding_math
  7548. || (REAL_MODE_FORMAT_COMPOSITE_P (mode)
  7549. && !flag_unsafe_math_optimizations))
  7550. - && (inexact || !real_identical (&result, &value)))
  7551. + && (inexact || !REAL_VALUES_IDENTICAL (result, value)))
  7552. return NULL_RTX;
  7553. return CONST_DOUBLE_FROM_REAL_VALUE (result, mode);
  7554. @@ -3115,7 +3149,7 @@
  7555. REAL_VALUE_FROM_CONST_DOUBLE (d1, trueop1);
  7556. /* Comparisons are unordered iff at least one of the values is NaN. */
  7557. - if (REAL_VALUE_ISNAN (d0) || REAL_VALUE_ISNAN (d1))
  7558. + if (REAL_VALUE_ISNANUINF (d0) || REAL_VALUE_ISNANUINF (d1))
  7559. switch (code)
  7560. {
  7561. case UNEQ:
  7562. @@ -3638,13 +3672,14 @@
  7563. }
  7564. else
  7565. {
  7566. - long tmp[max_bitsize / 32];
  7567. + const REAL_VALUE_TYPE *tmp;
  7568. int bitsize = GET_MODE_BITSIZE (GET_MODE (el));
  7569. gcc_assert (GET_MODE_CLASS (GET_MODE (el)) == MODE_FLOAT);
  7570. gcc_assert (bitsize <= elem_bitsize);
  7571. gcc_assert (bitsize % value_bit == 0);
  7572. +#if 0
  7573. real_to_target (tmp, CONST_DOUBLE_REAL_VALUE (el),
  7574. GET_MODE (el));
  7575. @@ -3666,6 +3701,14 @@
  7576. zero. */
  7577. for (; i < elem_bitsize; i += value_bit)
  7578. *vp++ = 0;
  7579. +#else
  7580. + /* (TIGCC 20050205) Use SMAP BCD representation directly. */
  7581. + tmp = CONST_DOUBLE_REAL_VALUE (el);
  7582. + *vp++ = tmp->exponent >> 8;
  7583. + *vp++ = tmp->exponent;
  7584. + for (i = 56; i >= 0; i -= 8)
  7585. + *vp++ = tmp->mantissa >> i;
  7586. +#endif /* 0 */
  7587. }
  7588. break;
  7589. @@ -3763,6 +3806,7 @@
  7590. case MODE_FLOAT:
  7591. {
  7592. REAL_VALUE_TYPE r;
  7593. +#if 0
  7594. long tmp[max_bitsize / 32];
  7595. /* real_from_target wants its input in words affected by
  7596. @@ -3782,6 +3826,14 @@
  7597. }
  7598. real_from_target (&r, tmp, outer_submode);
  7599. +#else
  7600. + /* (TIGCC 20050205) Use SMAP BCD representation directly. */
  7601. + r.exponent = (*vp++ << 8);
  7602. + r.exponent += *vp++;
  7603. + r.mantissa = *vp++;
  7604. + for (i = 0; i < 7; i++)
  7605. + r.mantissa = (r.mantissa << 8) + *vp++;
  7606. +#endif /* 0 */
  7607. elems[elem] = CONST_DOUBLE_FROM_REAL_VALUE (r, outer_submode);
  7608. }
  7609. break;
  7610. diff -Naur gcc-4.1.2.orig/gcc/stmt.c gcc-4.1.2-src/gcc/stmt.c
  7611. --- gcc-4.1.2.orig/gcc/stmt.c 2006-05-29 08:50:07.000000000 +0200
  7612. +++ gcc-4.1.2-src/gcc/stmt.c 2007-02-19 02:32:34.000000000 +0100
  7613. @@ -2515,6 +2515,9 @@
  7614. use_cost_table
  7615. = (TREE_CODE (orig_type) != ENUMERAL_TYPE
  7616. && estimate_case_costs (case_list));
  7617. +/* (TIGCC 20030907) Don't balance the tree when optimizing for size. A linear
  7618. + decision tree gives far smaller code. -- Kevin Kofler */
  7619. + if (!optimize_size)
  7620. balance_case_nodes (&case_list, NULL);
  7621. emit_case_nodes (index, case_list, default_label, index_type);
  7622. emit_jump (default_label);
  7623. @@ -3083,10 +3086,17 @@
  7624. does not have any children and is single valued; it would
  7625. cost too much space to save so little time. */
  7626. + /* (TIGCC 20030907) Also omit the conditional branch to default if we are
  7627. + optimizing for size. -- Kevin Kofler
  7628. + (TIGCC 20040719) But don't omit branches which are needed for
  7629. + correctness in case ranges. -- Kevin Kofler */
  7630. +
  7631. if (node->right->right || node->right->left
  7632. || !tree_int_cst_equal (node->right->low, node->right->high))
  7633. {
  7634. - if (!node_has_low_bound (node, index_type))
  7635. + if (!node_has_low_bound (node, index_type)
  7636. + && (!optimize_size
  7637. + || !tree_int_cst_equal (node->right->low, node->right->high)))
  7638. {
  7639. emit_cmp_and_jump_insns (index,
  7640. convert_modes
  7641. diff -Naur gcc-4.1.2.orig/gcc/system.h gcc-4.1.2-src/gcc/system.h
  7642. --- gcc-4.1.2.orig/gcc/system.h 2005-08-16 02:13:53.000000000 +0200
  7643. +++ gcc-4.1.2-src/gcc/system.h 2007-02-19 02:32:34.000000000 +0100
  7644. @@ -732,7 +732,7 @@
  7645. /* Hooks that are no longer used. */
  7646. #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \
  7647. - LANG_HOOKS_MARK_TREE LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES \
  7648. + LANG_HOOKS_MARK_TREE \
  7649. LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS \
  7650. LANG_HOOKS_PUSHLEVEL LANG_HOOKS_SET_BLOCK \
  7651. LANG_HOOKS_MAYBE_BUILD_CLEANUP LANG_HOOKS_UPDATE_DECL_AFTER_SAVING \
  7652. diff -Naur gcc-4.1.2.orig/gcc/toplev.c gcc-4.1.2-src/gcc/toplev.c
  7653. --- gcc-4.1.2.orig/gcc/toplev.c 2006-08-03 13:33:49.000000000 +0200
  7654. +++ gcc-4.1.2-src/gcc/toplev.c 2007-02-19 02:32:34.000000000 +0100
  7655. @@ -415,6 +415,15 @@
  7656. }
  7657. src_pwd = xstrdup (pwd);
  7658. +/* (TIGCC 20050420) Eliminate duplicate backslashes. */
  7659. +#ifdef __WIN32__
  7660. + if (strstr (src_pwd, "\\\\"))
  7661. + {
  7662. + char *p = (char *)src_pwd;
  7663. + while ((p = strstr (p, "\\\\")))
  7664. + memmove (p, p + 1, strlen (p));
  7665. + }
  7666. +#endif
  7667. return true;
  7668. }
  7669. @@ -1760,7 +1769,7 @@
  7670. flag_prefetch_loop_arrays = 0;
  7671. }
  7672. -#ifndef OBJECT_FORMAT_ELF
  7673. +#if 0 /*ndef OBJECT_FORMAT_ELF*/ /* (TIGCC 20040619) Remove pointless warning. */
  7674. if (flag_function_sections && write_symbols != NO_DEBUG)
  7675. warning (0, "-ffunction-sections may affect debugging on some targets");
  7676. #endif
  7677. @@ -1783,6 +1792,11 @@
  7678. if (!flag_stack_protect)
  7679. warn_stack_protect = 0;
  7680. +#if 0 /* (TIGCC 20051224) The unwinding info may not be perfect, but it works
  7681. + well enough for our purposes (remember we only need unwinding for
  7682. + debugging, not EH). Forcing -fno-omit-frame-pointer, on the other
  7683. + hand, really breaks things and defeats the entire purpose of
  7684. + unwinding tables. -- Kevin Kofler */
  7685. /* ??? Unwind info is not correct around the CFG unless either a frame
  7686. pointer is present or A_O_A is set. Fixing this requires rewriting
  7687. unwind info generation to be aware of the CFG and propagating states
  7688. @@ -1794,6 +1808,7 @@
  7689. "for correctness");
  7690. flag_omit_frame_pointer = 0;
  7691. }
  7692. +#endif /* 0 */
  7693. }
  7694. /* Initialize the compiler back end. */
  7695. diff -Naur gcc-4.1.2.orig/gcc/tree.c gcc-4.1.2-src/gcc/tree.c
  7696. --- gcc-4.1.2.orig/gcc/tree.c 2007-01-05 21:59:15.000000000 +0100
  7697. +++ gcc-4.1.2-src/gcc/tree.c 2007-02-19 02:32:34.000000000 +0100
  7698. @@ -1373,7 +1373,7 @@
  7699. return ((TREE_CODE (expr) == REAL_CST
  7700. && ! TREE_CONSTANT_OVERFLOW (expr)
  7701. - && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst0))
  7702. + && REAL_VALUE_ISZERO (TREE_REAL_CST (expr)))
  7703. || (TREE_CODE (expr) == COMPLEX_CST
  7704. && real_zerop (TREE_REALPART (expr))
  7705. && real_zerop (TREE_IMAGPART (expr))));
  7706. @@ -6623,17 +6623,14 @@
  7707. return integer_zerop (init);
  7708. case REAL_CST:
  7709. - /* ??? Note that this is not correct for C4X float formats. There,
  7710. - a bit pattern of all zeros is 1.0; 0.0 is encoded with the most
  7711. - negative exponent. */
  7712. - return real_zerop (init)
  7713. - && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (init));
  7714. + /* (TIGCC 20050210) For AMS, all zeros is POSITIVE_ZERO. This code tried
  7715. + to use it for both POSITIVE_ZERO and UNSIGNED_ZERO. I fixed that. */
  7716. + return REAL_VALUES_IDENTICAL (TREE_REAL_CST (init), POSITIVE_ZERO);
  7717. case COMPLEX_CST:
  7718. return integer_zerop (init)
  7719. - || (real_zerop (init)
  7720. - && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_REALPART (init)))
  7721. - && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init))));
  7722. + || (REAL_VALUES_IDENTICAL (TREE_REAL_CST (TREE_REALPART (init)), POSITIVE_ZERO)
  7723. + && REAL_VALUES_IDENTICAL (TREE_REAL_CST (TREE_IMAGPART (init)), POSITIVE_ZERO));
  7724. case VECTOR_CST:
  7725. for (elt = TREE_VECTOR_CST_ELTS (init); elt; elt = TREE_CHAIN (elt))
  7726. diff -Naur gcc-4.1.2.orig/gcc/tree.h gcc-4.1.2-src/gcc/tree.h
  7727. --- gcc-4.1.2.orig/gcc/tree.h 2007-02-09 03:52:53.000000000 +0100
  7728. +++ gcc-4.1.2-src/gcc/tree.h 2007-02-19 02:32:34.000000000 +0100
  7729. @@ -3497,6 +3497,7 @@
  7730. /* Return an expr equal to X but certainly not valid as an lvalue. */
  7731. extern tree non_lvalue (tree);
  7732. +extern tree pedantic_non_lvalue (tree);
  7733. extern tree convert (tree, tree);
  7734. extern unsigned int expr_align (tree);
  7735. diff -Naur gcc-4.1.2.orig/gcc/tree-inline.c gcc-4.1.2-src/gcc/tree-inline.c
  7736. --- gcc-4.1.2.orig/gcc/tree-inline.c 2007-01-05 14:53:45.000000000 +0100
  7737. +++ gcc-4.1.2-src/gcc/tree-inline.c 2007-02-19 02:32:34.000000000 +0100
  7738. @@ -2078,6 +2078,48 @@
  7739. verify_cgraph_node (cg_edge->callee);
  7740. #endif
  7741. + /* (TIGCC 20040926) The following code by Eric Botcazou fixes an ICE when
  7742. + inlining tries to change the mode of parameters or the return value. Eric
  7743. + Botcazou's comments explain the details. -- Kevin Kofler */
  7744. + /* We can't inline functions at a calling point where they are viewed
  7745. + with too different a prototype than the actual one, because the
  7746. + calling convention may not be the same on both sides. */
  7747. + if (TREE_CODE (TREE_OPERAND (t, 0)) == NOP_EXPR)
  7748. + {
  7749. + tree from_ftype = TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0)));
  7750. + tree to_ftype = TREE_TYPE (fn);
  7751. +
  7752. + if (from_ftype != to_ftype)
  7753. + {
  7754. + tree from_arg, to_arg;
  7755. +
  7756. + /* If the calling point expects a return value and it is too
  7757. + different from the one actually returned, don't inline. */
  7758. + if (! VOID_TYPE_P (TREE_TYPE (from_ftype))
  7759. + && TYPE_MODE (TREE_TYPE (from_ftype))
  7760. + != TYPE_MODE (TREE_TYPE (to_ftype)))
  7761. + goto egress;
  7762. +
  7763. + /* If the calling point doesn't pass at least the correct
  7764. + number of arguments with the correct modes, don't inline.
  7765. + Objective-C appears to add a trailing void parameter at
  7766. + the calling point under certain circumstances. */
  7767. + from_arg = TYPE_ARG_TYPES (from_ftype);
  7768. + to_arg = TYPE_ARG_TYPES (to_ftype);
  7769. +
  7770. + while (to_arg)
  7771. + {
  7772. + if (! from_arg
  7773. + || TYPE_MODE (TREE_VALUE (from_arg))
  7774. + != TYPE_MODE (TREE_VALUE (to_arg)))
  7775. + goto egress;
  7776. +
  7777. + from_arg = TREE_CHAIN (from_arg);
  7778. + to_arg = TREE_CHAIN (to_arg);
  7779. + }
  7780. + }
  7781. + }
  7782. +
  7783. /* We will be inlining this callee. */
  7784. id->eh_region = lookup_stmt_eh_region (stmt);
  7785. diff -Naur gcc-4.1.2.orig/gcc/tree-object-size.c gcc-4.1.2-src/gcc/tree-object-size.c
  7786. --- gcc-4.1.2.orig/gcc/tree-object-size.c 2005-07-03 18:11:42.000000000 +0200
  7787. +++ gcc-4.1.2-src/gcc/tree-object-size.c 2007-02-19 02:32:34.000000000 +0100
  7788. @@ -247,9 +247,11 @@
  7789. arg_mask = 2;
  7790. break;
  7791. */
  7792. +#if 0 /* (TIGCC 20051221) */
  7793. case BUILT_IN_CALLOC:
  7794. arg_mask = 3;
  7795. break;
  7796. +#endif /* 0 */
  7797. default:
  7798. break;
  7799. }
  7800. @@ -297,6 +299,7 @@
  7801. case BUILT_IN_STRNCPY:
  7802. case BUILT_IN_STRCAT:
  7803. case BUILT_IN_STRNCAT:
  7804. +#if 0 /* (TIGCC 20051221) */
  7805. case BUILT_IN_MEMCPY_CHK:
  7806. case BUILT_IN_MEMMOVE_CHK:
  7807. case BUILT_IN_MEMSET_CHK:
  7808. @@ -304,6 +307,7 @@
  7809. case BUILT_IN_STRNCPY_CHK:
  7810. case BUILT_IN_STRCAT_CHK:
  7811. case BUILT_IN_STRNCAT_CHK:
  7812. +#endif /* 0 */
  7813. if (arglist)
  7814. return TREE_VALUE (arglist);
  7815. break;
  7816. diff -Naur gcc-4.1.2.orig/gcc/tree-pretty-print.c gcc-4.1.2-src/gcc/tree-pretty-print.c
  7817. --- gcc-4.1.2.orig/gcc/tree-pretty-print.c 2005-07-31 22:55:41.000000000 +0200
  7818. +++ gcc-4.1.2-src/gcc/tree-pretty-print.c 2007-02-19 02:32:34.000000000 +0100
  7819. @@ -608,7 +608,7 @@
  7820. else
  7821. {
  7822. char string[100];
  7823. - real_to_decimal (string, &d, sizeof (string), 0, 1);
  7824. + REAL_VALUE_TO_STRING (d, string);
  7825. pp_string (buffer, string);
  7826. }
  7827. #else
  7828. diff -Naur gcc-4.1.2.orig/gcc/tree-ssa-ccp.c gcc-4.1.2-src/gcc/tree-ssa-ccp.c
  7829. --- gcc-4.1.2.orig/gcc/tree-ssa-ccp.c 2005-11-22 17:56:48.000000000 +0100
  7830. +++ gcc-4.1.2-src/gcc/tree-ssa-ccp.c 2007-02-19 02:32:34.000000000 +0100
  7831. @@ -2123,6 +2123,7 @@
  7832. static tree
  7833. ccp_fold_builtin (tree stmt, tree fn)
  7834. {
  7835. +#if 0 /* (TIGCC 20050205) */
  7836. tree result, val[3];
  7837. tree callee, arglist, a;
  7838. int arg_mask, i, type;
  7839. @@ -2278,6 +2279,9 @@
  7840. if (result && ignore)
  7841. result = fold_ignored_result (result);
  7842. return result;
  7843. +#else
  7844. + return NULL_TREE;
  7845. +#endif /* 0 */
  7846. }
  7847. diff -Naur gcc-4.1.2.orig/gcc/tree-ssa-dom.c gcc-4.1.2-src/gcc/tree-ssa-dom.c
  7848. --- gcc-4.1.2.orig/gcc/tree-ssa-dom.c 2006-11-17 10:01:31.000000000 +0100
  7849. +++ gcc-4.1.2-src/gcc/tree-ssa-dom.c 2007-02-19 02:32:34.000000000 +0100
  7850. @@ -2980,6 +2980,19 @@
  7851. || TREE_CODE (stmt) == COND_EXPR
  7852. || TREE_CODE (stmt) == SWITCH_EXPR));
  7853. + /* (TIGCC 20050206) If -fno-function-cse, keep function call sequences in
  7854. + their expected form. */
  7855. + if (flag_no_function_cse && may_optimize_p && TREE_CODE (stmt) == MODIFY_EXPR)
  7856. + {
  7857. + block_stmt_iterator bsi2 = si;
  7858. + bsi_next (&bsi2);
  7859. + if (!bsi_end_p (bsi2))
  7860. + {
  7861. + tree call = get_call_expr_in (bsi_stmt (bsi2));
  7862. + if (call && TREE_OPERAND (stmt, 0) == TREE_OPERAND (call, 0)) may_optimize_p = false;
  7863. + }
  7864. + }
  7865. +
  7866. if (may_optimize_p)
  7867. may_have_exposed_new_symbols
  7868. |= eliminate_redundant_computations (stmt, ann);
  7869. diff -Naur gcc-4.1.2.orig/gcc/tree-ssa-pre.c gcc-4.1.2-src/gcc/tree-ssa-pre.c
  7870. --- gcc-4.1.2.orig/gcc/tree-ssa-pre.c 2005-10-19 05:34:50.000000000 +0200
  7871. +++ gcc-4.1.2-src/gcc/tree-ssa-pre.c 2007-02-19 02:32:34.000000000 +0100
  7872. @@ -2394,6 +2394,19 @@
  7873. tree *rhs_p = &TREE_OPERAND (stmt, 1);
  7874. tree sprime;
  7875. + /* (TIGCC 20050216) If -fno-function-cse, keep function call sequences in
  7876. + their expected form. */
  7877. + if (flag_no_function_cse)
  7878. + {
  7879. + block_stmt_iterator bsi2 = i;
  7880. + bsi_next (&bsi2);
  7881. + if (!bsi_end_p (bsi2))
  7882. + {
  7883. + tree call = get_call_expr_in (bsi_stmt (bsi2));
  7884. + if (call && TREE_OPERAND (stmt, 0) == TREE_OPERAND (call, 0)) continue;
  7885. + }
  7886. + }
  7887. +
  7888. sprime = bitmap_find_leader (AVAIL_OUT (b),
  7889. vn_lookup (lhs, NULL));
  7890. if (sprime
  7891. diff -Naur gcc-4.1.2.orig/gcc/varasm.c gcc-4.1.2-src/gcc/varasm.c
  7892. --- gcc-4.1.2.orig/gcc/varasm.c 2006-10-16 11:58:48.000000000 +0200
  7893. +++ gcc-4.1.2-src/gcc/varasm.c 2007-02-19 02:32:34.000000000 +0100
  7894. @@ -681,6 +681,26 @@
  7895. unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
  7896. unsigned int flags ATTRIBUTE_UNUSED)
  7897. {
  7898. +/* (TIGCC 20040725) Implement string merging for TIGCC-extended COFF.
  7899. + We only handle 2 cases: aligned or unaligned.
  7900. + SECTION_STRINGS is abused for the unaligned flag. */
  7901. + if (flag_merge_constants
  7902. + && TREE_CODE (decl) == STRING_CST
  7903. + && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
  7904. + {
  7905. + if (align == 8)
  7906. + {
  7907. + named_section_flags (".rodata.__unalignedstr", flags | SECTION_MERGE | SECTION_STRINGS);
  7908. + return;
  7909. + }
  7910. + else if (align == 16)
  7911. + {
  7912. + named_section_flags (".rodata.__alignedstr", flags | SECTION_MERGE);
  7913. + return;
  7914. + }
  7915. + }
  7916. +
  7917. +#if 0
  7918. HOST_WIDE_INT len;
  7919. if (HAVE_GAS_SHF_MERGE && flag_merge_constants
  7920. @@ -746,6 +766,7 @@
  7921. }
  7922. }
  7923. }
  7924. +#endif
  7925. readonly_data_section ();
  7926. }
  7927. @@ -757,6 +778,25 @@
  7928. unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
  7929. unsigned int flags ATTRIBUTE_UNUSED)
  7930. {
  7931. +/* (TIGCC 20040725) Implement constant merging for TIGCC-extended COFF.
  7932. + We only handle 2 cases: aligned or unaligned.
  7933. + SECTION_STRINGS is abused for the unaligned flag. */
  7934. + if (flag_merge_constants
  7935. + && mode != VOIDmode)
  7936. + {
  7937. + if (align == 8)
  7938. + {
  7939. + named_section_flags (".rodata.__unalignedcst", flags | SECTION_MERGE | SECTION_STRINGS);
  7940. + return;
  7941. + }
  7942. + else if (align == 16)
  7943. + {
  7944. + named_section_flags (".rodata.__alignedcst", flags | SECTION_MERGE);
  7945. + return;
  7946. + }
  7947. + }
  7948. +
  7949. +#if 0
  7950. unsigned int modesize = GET_MODE_BITSIZE (mode);
  7951. if (HAVE_GAS_SHF_MERGE && flag_merge_constants
  7952. @@ -774,6 +814,7 @@
  7953. named_section_flags (name, flags);
  7954. return;
  7955. }
  7956. +#endif
  7957. readonly_data_section ();
  7958. }
  7959. @@ -1051,12 +1092,25 @@
  7960. void
  7961. assemble_asm (tree string)
  7962. {
  7963. + /* (TIGCC 20050424) Emit proper .loc directives for top-level asm statements,
  7964. + so GNU as won't try to make up its own and cause conflicts. */
  7965. + if (debug_hooks == &dwarf2_debug_hooks)
  7966. + (*debug_hooks->source_line) (input_location.line, input_location.file);
  7967. +
  7968. + /* (TIGCC 20050424) Now switch to the text section, so the asm won't end up in
  7969. + some unknown section. */
  7970. + text_section ();
  7971. +
  7972. app_enable ();
  7973. if (TREE_CODE (string) == ADDR_EXPR)
  7974. string = TREE_OPERAND (string, 0);
  7975. fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
  7976. +
  7977. + /* (TIGCC 20050424) And now forget the section we've set. There's no telling
  7978. + what section the asm switched to. */
  7979. + in_section = no_section;
  7980. }
  7981. /* Record an element in the table of global destructors. SYMBOL is
  7982. @@ -1536,9 +1590,18 @@
  7983. destination = asm_dest_common;
  7984. }
  7985. - if (destination != asm_dest_common)
  7986. + /* (TIGCC 20050517) See below for why the TARGET_NO_BSS is necessary here. */
  7987. + if (destination != asm_dest_common || (flag_data_sections && TARGET_NO_BSS))
  7988. {
  7989. - resolve_unique_section (decl, 0, flag_data_sections);
  7990. + /* (TIGCC 20040620) Common symbols are handled by our linker as separate
  7991. + sections, so there is no point in manually creating separate BSS sections
  7992. + under -fdata-sections. The TARGET_NO_BSS check here is a hack (it should
  7993. + not be in supposedly target-independent code), but it is necessary because
  7994. + -mno-bss would otherwise compact everything into a single huge section.
  7995. + -- Kevin Kofler */
  7996. + resolve_unique_section (decl, 0, flag_data_sections
  7997. + && ((destination == asm_dest_bss)
  7998. + || TARGET_NO_BSS));
  7999. /* Custom sections don't belong here. */
  8000. if (DECL_SECTION_NAME (decl))
  8001. return false;
  8002. @@ -1789,7 +1852,24 @@
  8003. }
  8004. /* Switch to the appropriate section. */
  8005. - resolve_unique_section (decl, reloc, flag_data_sections);
  8006. + /* (TIGCC 20040620) See the note about common symbols above. -- Kevin Kofler */
  8007. + /* (TIGCC 20050206) And always emit mergeable constructors into their own
  8008. + sections so the linker can merge them, as GCC fails to do
  8009. + it on its own. */
  8010. + resolve_unique_section (decl, reloc, (flag_data_sections
  8011. + && (!((!TREE_PUBLIC(decl) || DECL_COMMON(decl))
  8012. + && (DECL_INITIAL (decl) == 0
  8013. + || DECL_INITIAL (decl) == error_mark_node
  8014. + || (flag_zero_initialized_in_bss
  8015. + && !TREE_READONLY (decl)
  8016. + && initializer_zerop (DECL_INITIAL (decl)))))
  8017. + || TARGET_NO_BSS))
  8018. + || (DECL_INITIAL (decl)
  8019. + && TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR
  8020. + && (! (reloc
  8021. + || (!TREE_READONLY (decl))
  8022. + || TREE_SIDE_EFFECTS (decl)
  8023. + || !TREE_CONSTANT (DECL_INITIAL (decl))))));
  8024. variable_section (decl, reloc);
  8025. /* dbxout.c needs to know this. */
  8026. @@ -2280,7 +2360,16 @@
  8027. void
  8028. assemble_real (REAL_VALUE_TYPE d, enum machine_mode mode, unsigned int align)
  8029. {
  8030. - long data[4];
  8031. + long data[3];
  8032. + unsigned int nalign = min_align (align, 16);
  8033. +
  8034. + /* This is how to output a SMAP BCD real constant. */
  8035. + REAL_VALUE_TO_TARGET_SMAP_BCD (d, data);
  8036. + assemble_integer (GEN_INT (data[0] & 0xFFFFUL), 2, align, 1);
  8037. + assemble_integer (GEN_INT (data[1] & 0xFFFFFFFFUL), 4, nalign, 1);
  8038. + assemble_integer (GEN_INT (data[2] & 0xFFFFFFFFUL), 4, nalign, 1);
  8039. +
  8040. +#if 0
  8041. int i;
  8042. int bitsize, nelts, nunits, units_per;
  8043. @@ -2315,6 +2404,7 @@
  8044. assemble_integer (GEN_INT (data[i]), MIN (nunits, units_per), align, 1);
  8045. nunits -= units_per;
  8046. }
  8047. +#endif /* 0 */
  8048. }
  8049. /* Given an expression EXP with a constant value,
  8050. @@ -3312,7 +3402,7 @@
  8051. /* Worker function for output_constant_pool. Emit POOL. */
  8052. static void
  8053. -output_constant_pool_1 (struct constant_descriptor_rtx *desc)
  8054. +output_constant_pool_1 (const char *fnname, struct constant_descriptor_rtx *desc)
  8055. {
  8056. rtx x, tmp;
  8057. @@ -3351,8 +3441,19 @@
  8058. }
  8059. /* First switch to correct section. */
  8060. - targetm.asm_out.select_rtx_section (desc->mode, x, desc->align);
  8061. + if (flag_merge_constants && flag_merge_constant_pools)
  8062. + {
  8063. + /* (TIGCC 20040727) If we want to merge constant pools, we need to
  8064. + create a separate section for each constant pool.
  8065. + -- Kevin Kofler */
  8066. + char name[strlen(fnname)+15];
  8067. + sprintf (name, ".rodata.%s.cpool", fnname);
  8068. + named_section_flags (name, SECTION_MERGE);
  8069. + }
  8070. + else
  8071. + targetm.asm_out.select_rtx_section (desc->mode, x, desc->align);
  8072. +
  8073. #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
  8074. ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, desc->mode,
  8075. desc->align, desc->labelno, done);
  8076. @@ -3467,7 +3568,7 @@
  8077. /* Write all the constants in the constant pool. */
  8078. void
  8079. -output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
  8080. +output_constant_pool (const char *fnname,
  8081. tree fndecl ATTRIBUTE_UNUSED)
  8082. {
  8083. struct rtx_constant_pool *pool = cfun->varasm->pool;
  8084. @@ -3483,7 +3584,7 @@
  8085. #endif
  8086. for (desc = pool->first; desc ; desc = desc->next)
  8087. - output_constant_pool_1 (desc);
  8088. + output_constant_pool_1 (fnname, desc);
  8089. #ifdef ASM_OUTPUT_POOL_EPILOGUE
  8090. ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool->offset);
  8091. @@ -3527,10 +3628,18 @@
  8092. case MINUS_EXPR:
  8093. reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
  8094. reloc2 = compute_reloc_for_constant (TREE_OPERAND (exp, 1));
  8095. +#if 0
  8096. /* The difference of two local labels is computable at link time. */
  8097. + /* (TIGCC 20040808) That's true, but it is still not valid in a mergeable
  8098. + section. GCC doesn't seem to accept that as a constant anyway (at least
  8099. + in C), but it is never a good idea to let a latent problem just lie
  8100. + around. And besides, this code is unsafe, consider (addr1+addr2)-addr3.
  8101. + Still a potentially valid expression for the assembler and linker, but
  8102. + mishandled awfully by this code. -- Kevin Kofler */
  8103. if (reloc == 1 && reloc2 == 1)
  8104. reloc = 0;
  8105. else
  8106. +#endif /* 0 */
  8107. reloc |= reloc2;
  8108. break;
  8109. @@ -5128,6 +5237,31 @@
  8110. || strcmp (name, ".preinit_array") == 0))
  8111. flags |= SECTION_NOTYPE;
  8112. +/* (TIGCC 20040725) This was mostly copied out of the ELF section selector. It
  8113. + handles mergeable sections. -- Kevin Kofler */
  8114. + switch (categorize_decl_for_section (decl, reloc, shlib))
  8115. + {
  8116. + case SECCAT_RODATA_MERGE_STR:
  8117. + case SECCAT_RODATA_MERGE_STR_INIT:
  8118. + case SECCAT_RODATA_MERGE_CONST:
  8119. + flags |= SECTION_MERGE;
  8120. + break;
  8121. + default:
  8122. + break;
  8123. + }
  8124. +
  8125. + if (DECL_INITIAL (decl) && TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR)
  8126. + {
  8127. + /* (TIGCC 20040727) Put compound literals in mergeable sections in global
  8128. + compound literal mode. -- Kevin Kofler
  8129. + (TIGCC 20040808) But not if they contain relocations. -- Kevin Kofler */
  8130. + if (! (reloc
  8131. + || (!TREE_READONLY (decl))
  8132. + || TREE_SIDE_EFFECTS (decl)
  8133. + || !TREE_CONSTANT (DECL_INITIAL (decl))))
  8134. + flags |= SECTION_MERGE;
  8135. + }
  8136. +
  8137. return flags;
  8138. }
  8139. @@ -5249,18 +5383,51 @@
  8140. {
  8141. bool readonly = false;
  8142. +/* (TIGCC 20040725) This was copied out of the ELF section selector. It handles
  8143. + mergeable sections. -- Kevin Kofler */
  8144. + switch (categorize_decl_for_section (decl, reloc, flag_pic))
  8145. + {
  8146. + case SECCAT_RODATA_MERGE_STR:
  8147. + mergeable_string_section (decl, align, 0);
  8148. + break;
  8149. + case SECCAT_RODATA_MERGE_STR_INIT:
  8150. + mergeable_string_section (DECL_INITIAL (decl), align, 0);
  8151. + break;
  8152. + case SECCAT_RODATA_MERGE_CONST:
  8153. + mergeable_constant_section (DECL_MODE (decl), align, 0);
  8154. + break;
  8155. + default:
  8156. +
  8157. if (DECL_P (decl))
  8158. {
  8159. +#if 0
  8160. +/* (TIGCC 20050206) This doesn't work very well because GCC doesn't merge
  8161. + the compound literals properly. So I emit them into
  8162. + individual mergeable sections instead. */
  8163. + if (TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR)
  8164. + {
  8165. + /* (TIGCC 20040727) Put compound literals in mergeable sections in global
  8166. + compound literal mode. -- Kevin Kofler
  8167. + (TIGCC 20040808) But not if they contain relocations. -- Kevin Kofler */
  8168. + if (! (reloc
  8169. + || (!TREE_READONLY (decl))
  8170. + || TREE_SIDE_EFFECTS (decl)
  8171. + || !TREE_CONSTANT (DECL_INITIAL (decl))))
  8172. + {
  8173. + mergeable_constant_section (DECL_MODE (decl), align, 0);
  8174. + break;
  8175. + }
  8176. + }
  8177. +#endif /* 0 */
  8178. if (decl_readonly_section (decl, reloc))
  8179. readonly = true;
  8180. }
  8181. - else if (TREE_CODE (decl) == CONSTRUCTOR)
  8182. + /* (TIGCC 20040727) Put complex literals in mergeable sections.
  8183. + -- Kevin Kofler */
  8184. + else if (TREE_CODE (decl) == COMPLEX_CST)
  8185. {
  8186. - if (! ((flag_pic && reloc)
  8187. - || !TREE_READONLY (decl)
  8188. - || TREE_SIDE_EFFECTS (decl)
  8189. - || !TREE_CONSTANT (decl)))
  8190. - readonly = true;
  8191. + mergeable_constant_section (DECL_MODE (decl), align, 0);
  8192. + break;
  8193. }
  8194. else if (TREE_CODE (decl) == STRING_CST)
  8195. readonly = true;
  8196. @@ -5271,6 +5438,7 @@
  8197. readonly_data_section ();
  8198. else
  8199. data_section ();
  8200. + } /* end of switch-case */
  8201. }
  8202. enum section_category
  8203. diff -Naur gcc-4.1.2.orig/gcc/version.c gcc-4.1.2-src/gcc/version.c
  8204. --- gcc-4.1.2.orig/gcc/version.c 2005-03-16 07:04:10.000000000 +0100
  8205. +++ gcc-4.1.2-src/gcc/version.c 2007-10-08 07:41:43.000000000 +0200
  8206. @@ -8,7 +8,7 @@
  8207. in parentheses. You may also wish to include a number indicating
  8208. the revision of your modified compiler. */
  8209. -#define VERSUFFIX ""
  8210. +#define VERSUFFIX " (TIGCC 4.1.2-tigcc-4)"
  8211. /* This is the location of the online document giving instructions for
  8212. reporting bugs. If you distribute a modified version of GCC,
  8213. @@ -17,7 +17,7 @@
  8214. forward us bugs reported to you, if you determine that they are
  8215. not bugs in your modifications.) */
  8216. -const char bug_report_url[] = "<URL:http://gcc.gnu.org/bugs.html>";
  8217. +const char bug_report_url[] = "http://tigcc.ticalc.org/";
  8218. /* The complete version string, assembled from several pieces.
  8219. BASEVER, DATESTAMP, and DEVPHASE are defined by the Makefile. */
  8220. diff -Naur gcc-4.1.2.orig/libcpp/directives.c gcc-4.1.2-src/libcpp/directives.c
  8221. --- gcc-4.1.2.orig/libcpp/directives.c 2006-12-29 09:17:43.000000000 +0100
  8222. +++ gcc-4.1.2-src/libcpp/directives.c 2007-02-19 02:32:34.000000000 +0100
  8223. @@ -1139,6 +1139,7 @@
  8224. _cpp_init_internal_pragmas (cpp_reader *pfile)
  8225. {
  8226. /* Pragmas in the global namespace. */
  8227. + register_pragma (pfile, 0, "poison", do_pragma_poison, false, true); /* (TIGCC) */
  8228. register_pragma (pfile, 0, "once", do_pragma_once, false, true);
  8229. /* New GCC-specific pragmas should be put in the GCC namespace. */
  8230. diff -Naur gcc-4.1.2.orig/libcpp/expr.c gcc-4.1.2-src/libcpp/expr.c
  8231. --- gcc-4.1.2.orig/libcpp/expr.c 2005-06-29 04:34:39.000000000 +0200
  8232. +++ gcc-4.1.2-src/libcpp/expr.c 2007-10-08 07:38:20.000000000 +0200
  8233. @@ -171,6 +171,13 @@
  8234. radix = 16;
  8235. str++;
  8236. }
  8237. + /* Require at least one binary digit to classify it as binary. */
  8238. + else if ((*str == 'b' || *str == 'B') && (str[1]=='0' || str[1]=='1'))
  8239. + {
  8240. + radix = 2;
  8241. + str++;
  8242. + }
  8243. +
  8244. }
  8245. /* Now scan for a well-formed integer or float. */
  8246. @@ -205,14 +212,25 @@
  8247. }
  8248. }
  8249. - if (float_flag != NOT_FLOAT && radix == 8)
  8250. + if ((float_flag != NOT_FLOAT || CPP_OPTION(pfile,no_auto_octals)) && radix == 8)
  8251. radix = 10;
  8252. - if (max_digit >= radix)
  8253. - SYNTAX_ERROR2 ("invalid digit \"%c\" in octal constant", '0' + max_digit);
  8254. + if (max_digit >= radix) {
  8255. + if (radix == 2)
  8256. + SYNTAX_ERROR2 ("invalid digit \"%c\" in binary constant", '0' + max_digit);
  8257. + else
  8258. + SYNTAX_ERROR2 ("invalid digit \"%c\" in octal constant", '0' + max_digit);
  8259. + }
  8260. if (float_flag != NOT_FLOAT)
  8261. {
  8262. + if (radix == 2)
  8263. + {
  8264. + cpp_error (pfile, CPP_DL_ERROR,
  8265. + "invalid prefix \"0b\" for floating constant");
  8266. + return CPP_N_INVALID;
  8267. + }
  8268. +
  8269. if (radix == 16 && CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99))
  8270. cpp_error (pfile, CPP_DL_PEDWARN,
  8271. "use of C99 hexadecimal floating constant");
  8272. @@ -288,11 +306,16 @@
  8273. if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile))
  8274. cpp_error (pfile, CPP_DL_PEDWARN,
  8275. "imaginary constants are a GCC extension");
  8276. + if (radix == 2 && CPP_PEDANTIC (pfile))
  8277. + cpp_error (pfile, CPP_DL_PEDWARN,
  8278. + "binary constants are a GCC extension");
  8279. if (radix == 10)
  8280. result |= CPP_N_DECIMAL;
  8281. else if (radix == 16)
  8282. result |= CPP_N_HEX;
  8283. + else if (radix == 2)
  8284. + result |= CPP_N_BINARY;
  8285. else
  8286. result |= CPP_N_OCTAL;
  8287. @@ -343,6 +366,11 @@
  8288. base = 16;
  8289. p += 2;
  8290. }
  8291. + else if ((type & CPP_N_RADIX) == CPP_N_BINARY)
  8292. + {
  8293. + base = 2;
  8294. + p += 2;
  8295. + }
  8296. /* We can add a digit to numbers strictly less than this without
  8297. needing the precision and slowness of double integers. */
  8298. @@ -398,12 +426,25 @@
  8299. append_digit (cpp_num num, int digit, int base, size_t precision)
  8300. {
  8301. cpp_num result;
  8302. - unsigned int shift = 3 + (base == 16);
  8303. + unsigned int shift;
  8304. bool overflow;
  8305. cpp_num_part add_high, add_low;
  8306. - /* Multiply by 8 or 16. Catching this overflow here means we don't
  8307. + /* Multiply by 2, 8 or 16. Catching this overflow here means we don't
  8308. need to worry about add_high overflowing. */
  8309. + switch (base)
  8310. + {
  8311. + case 2:
  8312. + shift = 1;
  8313. + break;
  8314. +
  8315. + case 16:
  8316. + shift = 4;
  8317. + break;
  8318. +
  8319. + default:
  8320. + shift = 3;
  8321. + }
  8322. overflow = !!(num.high >> (PART_PRECISION - shift));
  8323. result.high = num.high << shift;
  8324. result.low = num.low << shift;
  8325. diff -Naur gcc-4.1.2.orig/libcpp/files.c gcc-4.1.2-src/libcpp/files.c
  8326. --- gcc-4.1.2.orig/libcpp/files.c 2005-11-04 03:10:19.000000000 +0100
  8327. +++ gcc-4.1.2-src/libcpp/files.c 2007-02-19 02:32:34.000000000 +0100
  8328. @@ -48,6 +48,11 @@
  8329. # define set_stdin_to_binary_mode() /* Nothing */
  8330. #endif
  8331. +/* (TIGCC 20050205) FIXME: This should be handled by configure... */
  8332. +#ifdef _WIN32
  8333. +#define ssize_t int
  8334. +#endif
  8335. +
  8336. /* This structure represents a file searched for by CPP, whether it
  8337. exists or not. An instance may be pointed to by more than one
  8338. file_hash_entry; at present no reference count is kept. */
  8339. diff -Naur gcc-4.1.2.orig/libcpp/include/cpplib.h gcc-4.1.2-src/libcpp/include/cpplib.h
  8340. --- gcc-4.1.2.orig/libcpp/include/cpplib.h 2005-11-14 17:28:55.000000000 +0100
  8341. +++ gcc-4.1.2-src/libcpp/include/cpplib.h 2007-02-19 02:32:34.000000000 +0100
  8342. @@ -399,6 +399,9 @@
  8343. /* True if dependencies should be restored from a precompiled header. */
  8344. bool restore_pch_deps;
  8345. + /* (TIGCC) True if numbers starting with zero should NOT be octal. */
  8346. + unsigned char no_auto_octals;
  8347. +
  8348. /* Dependency generation. */
  8349. struct
  8350. {
  8351. @@ -740,6 +743,7 @@
  8352. #define CPP_N_DECIMAL 0x0100
  8353. #define CPP_N_HEX 0x0200
  8354. #define CPP_N_OCTAL 0x0400
  8355. +#define CPP_N_BINARY 0x0800
  8356. #define CPP_N_UNSIGNED 0x1000 /* Properties. */
  8357. #define CPP_N_IMAGINARY 0x2000
  8358. @@ -803,6 +807,7 @@
  8359. string literal. Handles all relevant diagnostics. */
  8360. extern cppchar_t cpp_parse_escape (cpp_reader *, const unsigned char ** pstr,
  8361. const unsigned char *limit, int wide);
  8362. +extern void cpp_unterminated (cpp_reader *, int);
  8363. /* In cpphash.c */
  8364. diff -Naur gcc-4.1.2.orig/libcpp/init.c gcc-4.1.2-src/libcpp/init.c
  8365. --- gcc-4.1.2.orig/libcpp/init.c 2006-01-23 22:51:10.000000000 +0100
  8366. +++ gcc-4.1.2-src/libcpp/init.c 2007-02-19 02:32:34.000000000 +0100
  8367. @@ -160,6 +160,7 @@
  8368. CPP_OPTION (pfile, warn_dollars) = 1;
  8369. CPP_OPTION (pfile, warn_variadic_macros) = 1;
  8370. CPP_OPTION (pfile, warn_normalize) = normalized_C;
  8371. + CPP_OPTION (pfile, no_auto_octals) = 0; /* (TIGCC) */
  8372. /* Default CPP arithmetic to something sensible for the host for the
  8373. benefit of dumb users like fix-header. */
  8374. diff -Naur gcc-4.1.2.orig/libcpp/internal.h gcc-4.1.2-src/libcpp/internal.h
  8375. --- gcc-4.1.2.orig/libcpp/internal.h 2005-10-21 19:54:20.000000000 +0200
  8376. +++ gcc-4.1.2-src/libcpp/internal.h 2007-02-19 02:32:34.000000000 +0100
  8377. @@ -372,6 +372,11 @@
  8378. /* Error counter for exit code. */
  8379. unsigned int errors;
  8380. + /* Line and column where a newline was first seen in a string
  8381. + constant (multi-line strings). */
  8382. + source_location mls_line;
  8383. + unsigned int mls_col;
  8384. +
  8385. /* Buffer to hold macro definition string. */
  8386. unsigned char *macro_buffer;
  8387. unsigned int macro_buffer_len;
  8388. diff -Naur gcc-4.1.2.orig/libcpp/lex.c gcc-4.1.2-src/libcpp/lex.c
  8389. --- gcc-4.1.2.orig/libcpp/lex.c 2005-09-20 22:31:37.000000000 +0200
  8390. +++ gcc-4.1.2-src/libcpp/lex.c 2007-02-19 02:32:34.000000000 +0100
  8391. @@ -212,7 +212,11 @@
  8392. }
  8393. done:
  8394. - *d = '\n';
  8395. + /* (TIGCC 20050212) Don't convert \r to \n, switch them instead. */
  8396. + if (*d=='\r' && d[1]=='\n')
  8397. + {*d='\n'; d[1]='\r';}
  8398. + else
  8399. + *d = '\n';
  8400. /* A sentinel note that should never be processed. */
  8401. add_line_note (buffer, d + 1, '\n');
  8402. buffer->next_line = s + 1;
  8403. @@ -588,10 +592,19 @@
  8404. create_literal (cpp_reader *pfile, cpp_token *token, const uchar *base,
  8405. unsigned int len, enum cpp_ttype type)
  8406. {
  8407. + char *p;
  8408. uchar *dest = _cpp_unaligned_alloc (pfile, len + 1);
  8409. memcpy (dest, base, len);
  8410. dest[len] = '\0';
  8411. + /* (TIGCC 20050206) Delete \r characters in multi-line strings. */
  8412. + p = (char *)dest;
  8413. + while (p < (char *)dest + len) {
  8414. + if (*p == '\r') {
  8415. + memmove (p, p + 1, (char *)dest + len - p);
  8416. + len--;
  8417. + } else p++;
  8418. + }
  8419. token->type = type;
  8420. token->val.str.len = len;
  8421. token->val.str.text = dest;
  8422. @@ -603,7 +616,10 @@
  8423. literal, or CPP_OTHER if it was not properly terminated.
  8424. The spelling is NUL-terminated, but it is not guaranteed that this
  8425. - is the first NUL since embedded NULs are preserved. */
  8426. + is the first NUL since embedded NULs are preserved.
  8427. +
  8428. + Multi-line strings are allowed as a TIGCC extension (removed in the FSF GCC
  8429. + since version 3.3). */
  8430. static void
  8431. lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
  8432. {
  8433. @@ -611,7 +627,11 @@
  8434. const uchar *cur;
  8435. cppchar_t terminator;
  8436. enum cpp_ttype type;
  8437. + cpp_buffer *buffer;
  8438. + unsigned int startcol;
  8439. + buffer = pfile->buffer;
  8440. + startcol = CPP_BUF_COL (buffer);
  8441. cur = base;
  8442. terminator = *cur++;
  8443. if (terminator == 'L')
  8444. @@ -634,9 +654,50 @@
  8445. break;
  8446. else if (c == '\n')
  8447. {
  8448. - cur--;
  8449. - type = CPP_OTHER;
  8450. - break;
  8451. + unsigned int cols;
  8452. +
  8453. + /* In assembly language, silently terminate string and
  8454. + character literals at end of line. This is a kludge
  8455. + around not knowing where comments are. */
  8456. + if (CPP_OPTION (pfile, lang) == CLK_ASM && terminator != '>')
  8457. + {
  8458. + cur--;
  8459. + break;
  8460. + }
  8461. +
  8462. + /* Character constants and header names may not extend over
  8463. + multiple lines. In Standard C, neither may strings.
  8464. + In TIGCC, we accept multiline strings as an
  8465. + extension, except in #include family directives. */
  8466. + if (terminator != '"' || pfile->state.angled_headers)
  8467. + {
  8468. + cur--;
  8469. + type = CPP_OTHER;
  8470. + break;
  8471. + }
  8472. +
  8473. + if (CPP_PEDANTIC (pfile))
  8474. + cpp_error(pfile, CPP_DL_PEDWARN, "ISO C forbids newline in string literal");
  8475. + buffer->cur = cur - 1;
  8476. + _cpp_process_line_notes (pfile, true);
  8477. + if (buffer->next_line >= buffer->rlimit)
  8478. + {
  8479. + cur--;
  8480. + type = CPP_OTHER;
  8481. + break;
  8482. + }
  8483. + _cpp_clean_line (pfile);
  8484. +
  8485. + cols = buffer->next_line - buffer->line_base;
  8486. + CPP_INCREMENT_LINE (pfile, cols);
  8487. +
  8488. + cur = buffer->cur;
  8489. +
  8490. + if (pfile->mls_line == 0)
  8491. + {
  8492. + pfile->mls_line = token->src_loc;
  8493. + pfile->mls_col = startcol;
  8494. + }
  8495. }
  8496. else if (c == '\0')
  8497. saw_NUL = true;
  8498. @@ -1703,3 +1764,18 @@
  8499. return CPP_TOKEN_FLD_NONE;
  8500. }
  8501. }
  8502. +
  8503. +/* Emits error for unterminated strings. */
  8504. +void
  8505. +cpp_unterminated (cpp_reader *pfile, int term)
  8506. +{
  8507. + cpp_error (pfile, CPP_DL_ERROR, "missing terminating %c character", term);
  8508. +
  8509. + if (term == '\"' && pfile->mls_line && pfile->mls_line != pfile->line_table->highest_line)
  8510. + {
  8511. + cpp_error_with_line (pfile, CPP_DL_ERROR, pfile->mls_line, pfile->mls_col,
  8512. + "possible start of unterminated string literal");
  8513. + pfile->mls_line = 0;
  8514. + }
  8515. +}
  8516. +
  8517. diff -Naur gcc-4.1.2.orig/libcpp/macro.c gcc-4.1.2-src/libcpp/macro.c
  8518. --- gcc-4.1.2.orig/libcpp/macro.c 2006-01-23 22:51:10.000000000 +0100
  8519. +++ gcc-4.1.2-src/libcpp/macro.c 2007-02-19 02:32:34.000000000 +0100
  8520. @@ -768,6 +768,11 @@
  8521. macro_arg *arg;
  8522. _cpp_buff *buff;
  8523. + /* (TIGCC) If 'SYMSTR' is used with a string literal, it should be
  8524. + converted automatically to 'SYMSTR_CONST'. */
  8525. + cpp_hashnode *orig_node=node; /* save the original node in case we change it */
  8526. + symstr_const: /* start again from here after changing SYMSTR to SYMSTR_CONST */
  8527. +
  8528. /* First, fully macro-expand arguments, calculating the number of
  8529. tokens in the final expansion as we go. The ordering of the if
  8530. statements below is subtle; we must handle stringification before
  8531. @@ -801,6 +806,33 @@
  8532. }
  8533. }
  8534. + if (!ustrcmp (node->ident.str, U"SYMSTR"))
  8535. + {
  8536. + /* Accept one or more literal strings. If there are multiple ones, they
  8537. + concatenate. Ignore any padding.
  8538. + Refuse any other argument type. */
  8539. + unsigned int i;
  8540. + cpp_hashnode *newnode;
  8541. +
  8542. + for (i=0;i<args->expanded_count;i++)
  8543. + {
  8544. + if ((args->expanded[i]->type != CPP_STRING)
  8545. + && (args->expanded[i]->type != CPP_PADDING)) goto notconststring;
  8546. + }
  8547. +
  8548. + /* Change the macro to SYMSTR_CONST, if it is defined. */
  8549. + newnode = cpp_lookup (pfile, U"SYMSTR_CONST",
  8550. + sizeof ("SYMSTR_CONST") - 1);
  8551. + if (newnode->type == NT_MACRO) {
  8552. + node = newnode;
  8553. + macro = node->value.macro;
  8554. + goto symstr_const; /* Start over from the beginning. */
  8555. + }
  8556. +
  8557. + notconststring:;
  8558. + }
  8559. + /* (END TIGCC) */
  8560. +
  8561. /* Now allocate space for the expansion, copy the tokens and replace
  8562. the arguments. */
  8563. buff = _cpp_get_buff (pfile, total * sizeof (cpp_token *));
  8564. @@ -887,7 +919,10 @@
  8565. if (args[i].expanded)
  8566. free (args[i].expanded);
  8567. - push_ptoken_context (pfile, node, buff, first, dest - first);
  8568. + push_ptoken_context (pfile, orig_node, buff, first, dest - first);
  8569. + /* (TIGCC) Always use the ORIGINAL node here, not the modified one. Doing
  8570. + otherwise would make subsequent expansions of SYMSTR fail after
  8571. + the first conversion to SYMSTR_CONST. */
  8572. }
  8573. /* Return a special padding token, with padding inherited from SOURCE. */