internals.texinfo 273 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851
  1. \input texinfo @c -*-texinfo-*-
  2. @settitle Internals of GNU CC
  3. @setfilename internals
  4. @ifinfo
  5. This file documents the internals of the GNU compiler.
  6. Copyright (C) 1988 Free Software Foundation, Inc.
  7. Permission is granted to make and distribute verbatim copies of
  8. this manual provided the copyright notice and this permission notice
  9. are preserved on all copies.
  10. @ignore
  11. Permission is granted to process this file through Tex and print the
  12. results, provided the printed document carries copying permission
  13. notice identical to this one except for the removal of this paragraph
  14. (this paragraph not being relevant to the printed manual).
  15. @end ignore
  16. Permission is granted to copy and distribute modified versions of this
  17. manual under the conditions for verbatim copying, provided also that the
  18. section entitled ``GNU CC General Public License'' is included exactly as
  19. in the original, and provided that the entire resulting derived work is
  20. distributed under the terms of a permission notice identical to this one.
  21. Permission is granted to copy and distribute translations of this manual
  22. into another language, under the above conditions for modified versions,
  23. except that the section entitled ``GNU CC General Public License'' and
  24. this permission notice may be included in translations approved by the
  25. Free Software Foundation instead of in the original English.
  26. @end ifinfo
  27. @setchapternewpage odd
  28. @titlepage
  29. @center @titlefont{Internals of GNU CC}
  30. @sp 2
  31. @center Richard M. Stallman
  32. @sp 3
  33. @center last updated 24 April 1988
  34. @sp 1
  35. @center for version 1.21
  36. @page
  37. @vskip 0pt plus 1filll
  38. Copyright @copyright{} 1988 Free Software Foundation, Inc.
  39. Permission is granted to make and distribute verbatim copies of
  40. this manual provided the copyright notice and this permission notice
  41. are preserved on all copies.
  42. Permission is granted to copy and distribute modified versions of this
  43. manual under the conditions for verbatim copying, provided also that the
  44. section entitled ``GNU CC General Public License'' is included exactly as
  45. in the original, and provided that the entire resulting derived work is
  46. distributed under the terms of a permission notice identical to this one.
  47. Permission is granted to copy and distribute translations of this manual
  48. into another language, under the above conditions for modified versions,
  49. except that the section entitled ``GNU CC General Public License'' may be
  50. included in a translation approved by the author instead of in the original
  51. English.
  52. @end titlepage
  53. @page
  54. @ifinfo
  55. @node Top, Copying,, (DIR)
  56. @ichapter Introduction
  57. This manual documents how to run, install and port the GNU C compiler, as
  58. well as its new features and incompatibilities, and how to report bugs.
  59. @end ifinfo
  60. @menu
  61. * Copying:: GNU CC General Public License says
  62. how you can copy and share GNU CC.
  63. * Contributors:: People who have contributed to GNU CC.
  64. * Options:: Command options supported by @samp{gcc}.
  65. * Installation:: How to configure, compile and install GNU CC.
  66. * Incompatibilities:: Incompatibilities of GNU CC.
  67. * Extensions:: GNU extensions to the C language.
  68. * Bugs:: How to report bugs (if you want to get them fixed).
  69. * Portability:: Goals of GNU CC's portability features.
  70. * Interface:: Function-call interface of GNU CC output.
  71. * Passes:: Order of passes, what they do, and what each file is for.
  72. * RTL:: The intermediate representation that most passes work on.
  73. * Machine Desc:: How to write machine description instruction patterns.
  74. * Machine Macros:: How to write the machine description C macros.
  75. @end menu
  76. @node Copying, Contributors, Top, Top
  77. @unnumbered GNU CC GENERAL PUBLIC LICENSE
  78. @center (Clarified 11 Feb 1988)
  79. The license agreements of most software companies keep you at the
  80. mercy of those companies. By contrast, our general public license is
  81. intended to give everyone the right to share GNU CC. To make sure that
  82. you get the rights we want you to have, we need to make restrictions
  83. that forbid anyone to deny you these rights or to ask you to surrender
  84. the rights. Hence this license agreement.
  85. Specifically, we want to make sure that you have the right to give
  86. away copies of GNU CC, that you receive source code or else can get it
  87. if you want it, that you can change GNU CC or use pieces of it in new
  88. free programs, and that you know you can do these things.
  89. To make sure that everyone has such rights, we have to forbid you to
  90. deprive anyone else of these rights. For example, if you distribute
  91. copies of GNU CC, you must give the recipients all the rights that you
  92. have. You must make sure that they, too, receive or can get the
  93. source code. And you must tell them their rights.
  94. Also, for our own protection, we must make certain that everyone
  95. finds out that there is no warranty for GNU CC. If GNU CC is modified by
  96. someone else and passed on, we want its recipients to know that what
  97. they have is not what we distributed, so that any problems introduced
  98. by others will not reflect on our reputation.
  99. Therefore we (Richard Stallman and the Free Software Foundation,
  100. Inc.) make the following terms which say what you must do to be
  101. allowed to distribute or change GNU CC.
  102. @unnumberedsec COPYING POLICIES
  103. @enumerate
  104. @item
  105. You may copy and distribute verbatim copies of GNU CC source code as
  106. you receive it, in any medium, provided that you conspicuously and
  107. appropriately publish on each copy a valid copyright notice
  108. ``Copyright @copyright{} 1988 Free Software Foundation, Inc.'' (or
  109. with whatever year is appropriate); keep intact the notices on all
  110. files that refer to this License Agreement and to the absence of any
  111. warranty; and give any other recipients of the GNU CC program a copy
  112. of this License Agreement along with the program. You may charge a
  113. distribution fee for the physical act of transferring a copy.
  114. @item
  115. You may modify your copy or copies of GNU CC or any portion of it,
  116. and copy and distribute such modifications under the terms of
  117. Paragraph 1 above, provided that you also do the following:
  118. @itemize @bullet
  119. @item
  120. cause the modified files to carry prominent notices stating
  121. that you changed the files and the date of any change; and
  122. @item
  123. cause the whole of any work that you distribute or publish, that
  124. in whole or in part contains or is a derivative of GNU CC or any
  125. part thereof, to be licensed at no charge to all third parties on
  126. terms identical to those contained in this License Agreement
  127. (except that you may choose to grant more extensive warranty
  128. protection to some or all third parties, at your option).
  129. @item
  130. You may charge a distribution fee for the physical act of
  131. transferring a copy, and you may at your option offer warranty
  132. protection in exchange for a fee.
  133. @end itemize
  134. Mere aggregation of another unrelated program with this program (or its
  135. derivative) on a volume of a storage or distribution medium does not bring
  136. the other program under the scope of these terms.
  137. @item
  138. You may copy and distribute GNU CC (or a portion or derivative of it,
  139. under Paragraph 2) in object code or executable form under the terms
  140. of Paragraphs 1 and 2 above provided that you also do one of the
  141. following:
  142. @itemize @bullet
  143. @item
  144. accompany it with the complete corresponding machine-readable
  145. source code, which must be distributed under the terms of
  146. Paragraphs 1 and 2 above; or,
  147. @item
  148. accompany it with a written offer, valid for at least three
  149. years, to give any third party free (except for a nominal
  150. shipping charge) a complete machine-readable copy of the
  151. corresponding source code, to be distributed under the terms of
  152. Paragraphs 1 and 2 above; or,
  153. @item
  154. accompany it with the information you received as to where the
  155. corresponding source code may be obtained. (This alternative is
  156. allowed only for noncommercial distribution and only if you
  157. received the program in object code or executable form alone.)
  158. @end itemize
  159. For an executable file, complete source code means all the source code
  160. for all modules it contains; but, as a special exception, it need not
  161. include source code for modules which are standard libraries that
  162. accompany the operating system on which the executable file runs.
  163. @item
  164. You may not copy, sublicense, distribute or transfer GNU CC except as
  165. expressly provided under this License Agreement. Any attempt
  166. otherwise to copy, sublicense, distribute or transfer GNU CC is void
  167. and your rights to use the program under this License agreement shall
  168. be automatically terminated. However, parties who have received
  169. computer software programs from you with this License Agreement will
  170. not have their licenses terminated so long as such parties remain in
  171. full compliance.
  172. @item
  173. If you wish to incorporate parts of GNU CC into other free programs
  174. whose distribution conditions are different, write to the Free Software
  175. Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet worked
  176. out a simple rule that can be stated here, but we will often permit this.
  177. We will be guided by the two goals of preserving the free status of all
  178. derivatives of our free software and of promoting the sharing and reuse of
  179. software.
  180. @end enumerate
  181. Your comments and suggestions about our licensing policies and our
  182. software are welcome! Please contact the Free Software Foundation, Inc.,
  183. 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296.
  184. @unnumberedsec NO WARRANTY
  185. BECAUSE GNU CC IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO
  186. WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
  187. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  188. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GNU CC "AS IS" WITHOUT
  189. WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
  190. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  191. A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
  192. PERFORMANCE OF GNU CC IS WITH YOU. SHOULD GNU CC PROVE DEFECTIVE, YOU
  193. ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  194. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  195. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  196. WHO MAY MODIFY AND REDISTRIBUTE GNU CC AS PERMITTED ABOVE, BE LIABLE TO
  197. YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
  198. SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  199. INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  200. BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  201. FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GNU CC, EVEN
  202. IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR
  203. ANY CLAIM BY ANY OTHER PARTY.
  204. @node Contributors, Options, Copying, Top
  205. @unnumbered Contributors to GNU CC
  206. In addition to Richard Stallman, several people have written parts
  207. of GNU CC.
  208. @itemize @bullet
  209. @item
  210. The idea of using RTL and some of the optimization ideas came from the
  211. U. of Arizona Portable Optimizer, written by Jack Davidson and
  212. Christopher Fraser. See ``Register Allocation and Exhaustive Peephole
  213. Optimization'', Software Practice and Experience 14 (9), Sept. 1984,
  214. 857-866.
  215. @item
  216. Paul Rubin wrote most of the preprocessor.
  217. @item
  218. Leonard Tower wrote parts of the parser, RTL generator, RTL
  219. definitions, and of the Vax machine description.
  220. @item
  221. Ted Lemon wrote parts of the RTL reader and printer.
  222. @item
  223. Nobuyuki Hikichi of Software Research Associates, Tokyo, contributed
  224. the support for the SONY NEWS machine.
  225. @item
  226. Charles LaBrec contributed the support for the Integrated Solutions
  227. 68020 system.
  228. @item
  229. Michael Tiemann of MCC wrote the description of the National
  230. Semiconductor 32000 series cpu, with some contributions from Jan Stein
  231. of the Chalmers Computer Club. Tiemann also wrote the code for inline
  232. function integration.
  233. @item
  234. Michael Kashtan of SRI adapted GNU CC to the Vomit-Making System.
  235. @item
  236. Alex Crain provided changes for the 3b1.
  237. @item
  238. Chris Hanson and another person who should remind me of his name
  239. assisted in making GNU CC work on HP-UX for the 9000 series 300.
  240. @end itemize
  241. @node Options, Installation, Contributors, Top
  242. @chapter GNU CC Command Options
  243. The GNU C compiler uses a command syntax much like the Unix C compiler.
  244. The @code{gcc} program accepts options and file names as operands.
  245. Multiple single-letter options may @emph{not} be grouped: @samp{-dr} is
  246. very different from @samp{-d -r}.
  247. When you invoke GNU CC, it normally does preprocessing, compilation,
  248. assembly and linking. File names which end in @samp{.c} are taken as C
  249. source to be preprocessed and compiled; compiler output files plus any
  250. input files with names ending in @samp{.s} are assembled; then the
  251. resulting object files, plus any other input files, are linked together to
  252. produce an executable.
  253. Command options allow you to stop this process at an intermediate stage.
  254. For example, the @samp{-c} option says not to run the linker. Then the
  255. output consists of object files output by the assembler.
  256. Other command options are passed on to one stage. Some options control
  257. the preprocessor and others the compiler itself. Yet other options
  258. control the assembler and linker; these are not documented here because the
  259. GNU assembler and linker are not yet released.
  260. Here are the options to control the overall compilation process, including
  261. those that say whether to link, whether to assemble, and so on.
  262. @table @samp
  263. @item -o @var{file}
  264. Place output in file @var{file}. This applies regardless to whatever
  265. sort of output is being produced, whether it be an executable file,
  266. an object file, an assembler file or preprocessed C code.
  267. If @samp{-o} is not specified, the default is to put an excutable file
  268. in @file{a.out}, the object file @file{@var{source}.c} in
  269. @file{@var{source}.o}, an assembler file in @file{@var{source}.s}, and
  270. preprocessed C on standard output.@refill
  271. @item -c
  272. Compile or assemble the source files, but do not link. Produce object
  273. files with names made by replacing @samp{.c} or @samp{.s} with
  274. @samp{.o} at the end of the input file names. Do nothing at all for
  275. object files specified as input.
  276. @item -S
  277. Compile into assembler code but do not assemble. The assembler output
  278. file name is made by replacing @samp{.c} with @samp{.s} at the end of
  279. the input file name. Do nothing at all for assembler source files or
  280. object files specified as input.
  281. @item -E
  282. Run only the C preprocessor. Preprocess all the C source files
  283. specified and output the results to standard output.
  284. @item -v
  285. Compiler driver program prints the commands it executes as it runs
  286. the preprocessor, compiler proper, assembler and linker. Some of
  287. these are directed to print their own version numbers.
  288. @item -B@var{prefix}
  289. Compiler driver program tries @var{prefix} as a prefix for each
  290. program it tries to run. These programs are @file{cpp}, @file{cc1},
  291. @file{as} and @file{ld}.
  292. For each subprogram to be run, the compiler driver first tries the
  293. @samp{-B} prefix, if any. If that name is not found, or if @samp{-B}
  294. was not specified, the driver tries two standard prefixes, which are
  295. @file{/usr/lib/gcc-} and @file{/usr/local/lib/gcc-}. If neither of
  296. those results in a file name that is found, the unmodified program
  297. name is searched for using the directories specified in your
  298. @samp{PATH} environment variable.
  299. The run-time support file @file{gnulib} is also searched for using
  300. the @samp{-B} prefix, if needed. If it is not found there, the two
  301. standard prefixes above are tried, and that is all. The file is left
  302. out of the link if it is not found by those means. Most of the time,
  303. on most machines, you can do without it.
  304. @end table
  305. These options control the details of C compilation itself.
  306. @table @samp
  307. @item -ansi
  308. Support all ANSI standard C programs.
  309. This turns off certain features of GNU C that are incompatible with
  310. ANSI C, such as the @code{asm}, @code{inline} and @code{typeof}
  311. keywords, and predefined macros such as @code{unix} and @code{vax}
  312. that identify the type of system you are using. It also enables the
  313. undesirable and rarely used ANSI trigraph feature.
  314. The @samp{-ansi} option does not cause non-ANSI programs to be
  315. rejected gratuitously. For that, @samp{-pedantic} is required in
  316. addition to @samp{-ansi}.
  317. The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi}
  318. option is used. Some header files may notice this macro and refrain
  319. from declaring certain functions or defining certain macros that the
  320. ANSI standard doesn't call for; this is to avoid interfering with
  321. any programs that might use these names for other things.
  322. @item -traditional
  323. Attempt to support some aspects of traditional C compilers.
  324. Specifically:
  325. @itemize @bullet
  326. @item
  327. All @code{extern} declarations take effect globally even if they
  328. are written inside of a function definition. This includes implicit
  329. declarations of functions.
  330. @item
  331. The keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}
  332. and @code{volatile} are not recognized.@refill
  333. @item
  334. Comparisons between pointers and integers are always allowed.
  335. @item
  336. Integer types @code{unsigned short} and @code{unsigned char} promote
  337. to @code{unsigned int}.
  338. @item
  339. In the preprocessor, comments convert to nothing at all, rather than to
  340. a space. This allows traditional token concatenation.
  341. @item
  342. In the preprocessor, single and double quote characters are ignored
  343. when scanning macro definitions, so that macro arguments can be replaced
  344. even within a string or character constant. Quote characters are also
  345. ignored when skipping text inside a failing conditional directive.
  346. @end itemize
  347. @item -O
  348. Optimize. Optimizing compilation takes somewhat more time, and a lot
  349. more memory for a large function.
  350. Without @samp{-O}, the compiler's goal is to reduce the cost of
  351. compilation and to make debugging produce the expected results.
  352. Statements are independent: if you stop the program with a breakpoint
  353. between statements, you can then assign a new value to any variable or
  354. change the program counter to any other statement in the function and
  355. get exactly the results you would expect from the source code.
  356. Without @samp{-O}, only variables declared @code{register} are
  357. allocated in registers. The resulting compiled code is a little worse
  358. than produced by PCC without @samp{-O}.
  359. With @samp{-O}, the compiler tries to reduce code size and execution
  360. time.
  361. Some of the @samp{-f} options described below turn specific kinds of
  362. optimization on or off.
  363. @item -g
  364. Produce debugging information in DBX format.
  365. Unlike most other C compilers, GNU CC allows you to use @samp{-g} with
  366. @samp{-O}. The shortcuts taken by optimized code may occasionally
  367. produce surprising results: some variables you declared may not exist
  368. at all; flow of control may briefly move where you did not expect it;
  369. some statements may not be executed because they compute constant
  370. results or their values were already at hand; some statements may
  371. execute in different places because they were moved out of loops.
  372. Nevertheless it proves possible to debug optimized output. This makes
  373. it reasonable to use the optimizer for programs that might have bugs.
  374. @item -gg
  375. Produce debugging information in GDB's own format. This requires
  376. the GNU assembler and linker in order to work.
  377. @item -w
  378. Inhibit all warning messages.
  379. @item -W
  380. Print extra warning messages for these events:
  381. @itemize @bullet
  382. @item
  383. An automatic variable is used without first being initialized.
  384. These warnings are possible only in optimizing compilation,
  385. because they require data flow information that is computed only
  386. when optimizing. They occur only for variables that are
  387. candidates for register allocation. Therefore, they do not occur
  388. for a variable that is declared @code{volatile}, or whose address
  389. is taken, or whose size is other than 1, 2, 4 or 8 bytes. Also,
  390. they do not occur for structures, unions or arrays, even when
  391. they are in registers.
  392. Note that there may be no warning about a variable that is used
  393. only to compute a value that itself is never used, because such
  394. computations may be deleted by the flow analysis pass before the
  395. warnings are printed.
  396. These warnings are made optional because GNU CC is not smart
  397. enough to see all the reasons why the code might be correct
  398. despite appearing to have an error. Here is one example of how
  399. this can happen:
  400. @example
  401. @{
  402. int x;
  403. switch (y)
  404. @{
  405. case 1: x = 1;
  406. break;
  407. case 2: x = 4;
  408. break;
  409. case 3: x = 5;
  410. @}
  411. foo (x);
  412. @}
  413. @end example
  414. @noindent
  415. If the value of @code{y} is always 1, 2 or 3, then @code{x} is
  416. always initialized, but GNU CC doesn't know this. Here is
  417. another common case:
  418. @example
  419. @{
  420. int save_y;
  421. if (change_y) save_y = y, y = new_y;
  422. @dots{}
  423. if (change_y) y = save_y;
  424. @}
  425. @end example
  426. @noindent
  427. This has no bug because @code{x} is used only if it is set.
  428. @item
  429. A nonvolatile automatic variable might be changed by a call to
  430. @code{longjmp}. These warnings as well are possible only in
  431. optimizing compilation.
  432. The compiler sees only the calls to @code{setjmp}. It cannot know
  433. where @code{longjmp} will be called; in fact, a signal handler could
  434. call it at any point in the code. As a result, you may get a warning
  435. even when there is in fact no problem because @code{longjmp} cannot
  436. in fact be called at the place which would cause a problem.
  437. @item
  438. A function can return either with or without a value. (Falling
  439. off the end of the function body is considered returning without
  440. a value.) For example, this function would inspire such a
  441. warning:
  442. @example
  443. foo (a)
  444. @{
  445. if (a > 0)
  446. return a;
  447. @}
  448. @end example
  449. Spurious warnings can occur because GNU CC does not realize that
  450. certain functions (including @code{abort} and @code{longjmp})
  451. will never return.
  452. @end itemize
  453. In the future, other useful warnings may also be enabled by this
  454. option.
  455. @item -Wimplicit
  456. Warn whenever a function is implicitly declared.
  457. @item -Wreturn-type
  458. Warn whenever a function is defined with a return-type that defaults
  459. to @code{int}. Also warn about any @code{return} statement with no
  460. return-value in a function whose return-type is not @code{void}.
  461. @item -Wcomment
  462. Warn whenever a comment-start sequence @samp{/*} appears in a comment.
  463. @item -p
  464. Generate extra code to write profile information suitable for the
  465. analysis program @code{prof}.
  466. @item -pg
  467. Generate extra code to write profile information suitable for the
  468. analysis program @code{gprof}.
  469. @item -nostdinc
  470. Don't search the standard directories for include files. Only the
  471. directories you specify explicitly with the @samp{-I} option will be
  472. searched.
  473. @item -nostdlib
  474. Don't use the standard system libraries and startup files when
  475. linking. Only the files you specify (plus @file{gnulib}) will be
  476. passed to the linker.
  477. @item -m@var{machinespec}
  478. Machine-dependent option specifying something about the type of target
  479. machine. These options are defined by the macro
  480. @code{TARGET_SWITCHES} in the machine description. The default for
  481. the options is also defined by that macro, which enables you to change
  482. the defaults.@refill
  483. These are the @samp{-m} options defined in the 68000 machine
  484. description:
  485. @table @samp
  486. @item -m68020
  487. Generate output for a 68020 (rather than a 68000). This is the
  488. default if you use the unmodified sources.
  489. @item -m68000
  490. Generate output for a 68000 (rather than a 68020).
  491. @item -m68881
  492. Generate output containing 68881 instructions for floating point.
  493. This is the default if you use the unmodified sources.
  494. @item -msoft-float
  495. Generate output containing library calls for floating point.
  496. @item -mshort
  497. Consider type @code{int} to be 16 bits wide, like @code{short int}.
  498. @item -mnobitfield
  499. Do not use the bit-field instructions. @samp{-m68000} implies
  500. @samp{-mnobitfield}.
  501. @item -mbitfield
  502. Do use the bit-field instructions. @samp{-m68020} implies
  503. @samp{-mbitfield}. This is the default if you use the unmodified
  504. sources.
  505. @item -mrtd
  506. Use a different function-calling convention, in which functions
  507. that take a fixed number of arguments return with the @code{rtd}
  508. instruction, which pops their arguments while returning. This
  509. saves one instruction in the caller since there is no need to pop
  510. the arguments there.
  511. This calling convention is incompatible with the one normally
  512. used on Unix, so you cannot use it if you need to call libraries
  513. compiled with the Unix compiler.
  514. Also, you must provide function prototypes for all functions that
  515. take variable numbers of arguments (including @code{printf});
  516. otherwise incorrect code will be generated for calls to those
  517. functions.
  518. In addition, seriously incorrect code will result if you call a
  519. function with too many arguments. (Normally, extra arguments are
  520. harmlessly ignored.)
  521. The @code{rtd} instruction is supported by the 68010 and 68020
  522. processors, but not by the 68000.
  523. @end table
  524. These @samp{-m} options are defined in the Vax machine description:
  525. @table @samp
  526. @item -munix
  527. Do not output certain jump instructions (@code{aobleq} and so on)
  528. that the Unix assembler for the Vax cannot handle across long
  529. ranges.
  530. @item -mgnu
  531. Do output those jump instructions, on the assumption that you
  532. will assemble with the GNU assembler.
  533. @end table
  534. @item -f@var{flag}
  535. Specify machine-independent flags. These are the flags:
  536. @table @samp
  537. @item -ffloat-store
  538. Do not store floating-point variables in registers. This
  539. prevents undesirable excess precision on machines such as the
  540. 68000 where the floating registers (of the 68881) keep more
  541. precision than a @code{double} is supposed to have.
  542. For most programs, the excess precision does only good, but a few
  543. programs rely on the precise definition of IEEE floating point.
  544. Use @samp{-ffloat-store} for such programs.
  545. @item -fno-asm
  546. Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
  547. keyword. These words may then be used as identifiers.
  548. @item -fno-defer-pop
  549. Always pop the arguments to each function call as soon as that
  550. function returns. Normally the compiler (when optimizing) lets
  551. arguments accumulate on the stack for several function calls and
  552. pops them all at once.
  553. @item -fcombine-regs
  554. Allow the combine pass to combine an instruction that copies one
  555. register into another. This might or might not produce better
  556. code when used in addition to @samp{-O}. I am interested in
  557. hearing about the difference this makes.
  558. @item -fforce-mem
  559. Force memory operands to be copied into registers before doing
  560. arithmetic on them. This may produce better code by making all
  561. memory references potential common subexpressions. When they are
  562. not common subexpressions, instruction combination should
  563. eliminate the separate register-load. I am interested in hearing
  564. about the difference this makes.
  565. @item -fforce-addr
  566. Force memory address constants to be copied into registers before
  567. doing arithmetic on them. This may produce better code just as
  568. @samp{-fforce-mem} may. I am interested in hearing about the
  569. difference this makes.
  570. @item -fomit-frame-pointer
  571. Don't keep the frame pointer in a register for functions that
  572. don't need one. This avoids the instructions to save, set up and
  573. restore frame pointers; it also makes an extra register available
  574. in many functions. @strong{It also makes debugging impossible.}
  575. On some machines, such as the Vax, this flag has no effect,
  576. because the standard calling sequence automatically handles the
  577. frame pointer and nothing is saved by pretending it doesn't
  578. exist. The machine-description macro
  579. @code{FRAME_POINTER_REQUIRED} controls whether a target machine
  580. supports this flag. @xref{Registers}.@refill
  581. @item -finline-functions
  582. Integrate all simple functions into their callers. The compiler
  583. heuristically decides which functions are simple enough to be
  584. worth integrating in this way.
  585. If all calls to a given function are integrated, and the function
  586. is declared @code{static}, then the function is normally not
  587. output as assembler code in its own right.
  588. @item -fkeep-inline-functions
  589. Even if all calls to a given function are integrated, and the
  590. function is declared @code{static}, nevertheless output a
  591. separate run-time callable version of the function.
  592. @item -fwritable-strings
  593. Store string constants in the writable data segment and don't
  594. uniquize them. This is for compatibility with old programs which
  595. assume they can write into string constants. Writing into string
  596. constants is a very bad idea; ``constants'' should be constant.
  597. @item -fno-function-cse
  598. Do not put function addresses in registers; make each instruction
  599. that calls a constant function contain the function's address
  600. explicitly.
  601. This option results in less efficient code, but some strange
  602. hacks that alter the assembler output may be confused by the
  603. optimizations performed when this option is not used.
  604. @item -fvolatile
  605. Consider all memory references through pointers to be volatile.
  606. @item -funsigned-char
  607. Let the type @code{char} be the unsigned, like @code{unsigned
  608. char}.
  609. Each kind of machine has a default for what @code{char} should
  610. be. It is either like @code{unsigned char} by default or like
  611. @code{signed char} by default. (Actually, at present, the
  612. default is always signed.)
  613. The type @code{char} is always a distinct type from either
  614. @code{signed char} or @code{unsigned char}, even though its
  615. behavior is always just like one of those two.
  616. @item -fsigned-char
  617. Let the type @code{char} be signed, like @code{signed char}.
  618. @item -ffixed-@var{reg}
  619. Treat the register named @var{reg} as a fixed register; generated
  620. code should never refer to it (except perhaps as a stack pointer,
  621. frame pointer or in some other fixed role).
  622. @var{reg} must be the name of a register. The register names
  623. accepted are machine-specific and are defined in the
  624. @code{REGISTER_NAMES} macro in the machine description macro
  625. file.
  626. @item -fcall-used-@var{reg}
  627. Treat the register named @var{reg} as an allocatable register
  628. that is clobbered by function calls. It may be allocated for
  629. temporaries or variables that do not live across a call.
  630. Functions compiled this way will not save and restore the
  631. register @var{reg}.
  632. Use of this flag for a register that has a fixed pervasive role
  633. in the machine's execution model, such as the stack pointer or
  634. frame pointer, will produce disastrous results.
  635. @item -fcall-saved-@var{reg}
  636. Treat the register named @var{reg} as an allocatable register
  637. saved by functions. It may be allocated even for temporaries or
  638. variables that live across a call. Functions compiled this way
  639. will save and restore the register @var{reg} if they use it.
  640. Use of this flag for a register that has a fixed pervasive role
  641. in the machine's execution model, such as the stack pointer or
  642. frame pointer, will produce disastrous results.
  643. A different sort of disaster will result from the use of this
  644. flag for a register in which function values are may be returned.
  645. @end table
  646. @item -d@var{letters}
  647. Says to make debugging dumps at times specified by @var{letters}.
  648. Here are the possible letters:
  649. @table @samp
  650. @item r
  651. Dump after RTL generation.
  652. @item j
  653. Dump after first jump optimization.
  654. @item J
  655. Dump after last jump optimization.
  656. @item s
  657. Dump after CSE (including the jump optimization that sometimes
  658. follows CSE).
  659. @item L
  660. Dump after loop optimization.
  661. @item f
  662. Dump after flow analysis.
  663. @item c
  664. Dump after instruction combination.
  665. @item l
  666. Dump after local register allocation.
  667. @item g
  668. Dump after global register allocation.
  669. @item m
  670. Print statistics on memory usage, at the end of the run.
  671. @end table
  672. @item -pedantic
  673. Issue all the warnings demanded by strict ANSI standard C; reject
  674. all programs that use forbidden extensions.
  675. Valid ANSI standard C programs should compile properly with or without
  676. this option (though a rare few will require @samp{-ansi}). However,
  677. without this option, certain GNU extensions and traditional C features
  678. are supported as well. With this option, they are rejected. There is
  679. no reason to @i{use} this option; it exists only to satisfy pedants.
  680. @end table
  681. These options control the C preprocessor, which is run on each C source
  682. file before actual compilation. If you use the @samp{-E} option, nothing
  683. is done except C preprocessing. Some of these options make sense only
  684. together with @samp{-E} because they request preprocessor output that is
  685. not suitable for actual compilation.
  686. @table @samp
  687. @item -C
  688. Tell the preprocessor not to discard comments. Used with the
  689. @samp{-E} option.
  690. @item -I@var{dir}
  691. Search directory @var{dir} for include files.
  692. @item -M
  693. Tell the preprocessor to output a rule suitable for @code{make}
  694. describing the dependencies of each source file. For each source
  695. file, the preprocessor outputs one @code{make}-rule whose target is
  696. the object file name for that source file and whose dependencies are
  697. all the files @samp{#include}d in it. This rule may be a single line
  698. or may be continued with @samp{\}-newline if it is long.
  699. @samp{-M} implies @samp{-E}.
  700. @item -MM
  701. Like @samp{-M} but the output mentions only the user-header files
  702. included with @samp{#include "@var{file}"}. System header files
  703. included with @samp{#include <@var{file}>} are omitted.
  704. @samp{-MM} implies @samp{-E}.
  705. @item -D@var{macro}
  706. Define macro @var{macro} with the empty string as its definition.
  707. @item -D@var{macro}=@var{defn}
  708. Define macro @var{macro} as @var{defn}.
  709. @item -U@var{macro}
  710. Undefine macro @var{macro}.
  711. @item -T
  712. Support ANSI C trigraphs. You don't want to know about this
  713. brain-damage. The @samp{-ansi} option also has this effect.
  714. @end table
  715. @node Installation, Incompatibilities, Options, Top
  716. @chapter Installing GNU CC
  717. Here is the procedure for installing GNU CC on a Unix system.
  718. @menu
  719. * VMS Install:: See below for installation on VMS.
  720. @end menu
  721. @iftex
  722. (See below for VMS.)
  723. @end iftex
  724. @enumerate
  725. @item
  726. Edit @file{Makefile}. If you are using HPUX, you must make a few
  727. changes described in comments at the beginning of the file.
  728. @item
  729. Choose configuration files.
  730. @itemize @bullet
  731. @item
  732. Make a symbolic link named @file{config.h} to the top-level
  733. config file for the machine you are using (@pxref{Config}). This
  734. file is responsible for defining information about the host
  735. machine. It includes @file{tm.h}.
  736. The file's name should be @file{config-@var{machine}.h}. On VMS,
  737. use @file{config-vms.h} rather than @file{config-vax.h}. On the
  738. HP 9000 series 300, use @file{config-hp9k3.h} rather than
  739. @file{config-m68k.h}.@refill
  740. If your system does not support symbolic links, you might want to
  741. set up @file{config.h} to contain a @samp{#include} command which
  742. refers to the appropriate file.
  743. @item
  744. Make a symbolic link named @file{tm.h} to the machine-description
  745. macro file for your machine (its name should be
  746. @file{tm-@var{machine}.h}).
  747. For the 68000/68020, do not use @file{tm-m68k.h} directly;
  748. instead use one of the files @file{tm-sun3.h}, @file{tm-sun2.h},
  749. @file{tm-isi68.h}, @file{tm-news800.h} or @file{tm-3b1.h}. Each
  750. of those files includes @file{tm-m68k.h} but sets up a few things
  751. differently as appropriate to the specific model of
  752. machine.@refill
  753. There are two files you can use for a 680x0 running HPUX:
  754. @file{tm-hp9k320.h} and @file{tm-hp9k320g.h}. Use the former if
  755. you are installing GNU CC alone. The latter is for another option
  756. where GNU CC together with the GNU assembler, linker, debugger
  757. and other utilities are used to replace all of HPUX that deals
  758. with compilation. Not all of the pieces of GNU software needed for
  759. this mode of operation are as yet in distribution; full instructions
  760. will appear here in the future.@refill
  761. For the 32000, use @file{tm-sequent.h} if you are using a Sequent
  762. machine; otherwise, use @file{tm-ns32k.h}.
  763. For the vax, use @file{tm-vax.h} on BSD Unix, @file{tm-ultrix.h}
  764. on Ultrix, or @file{tm-vms.h} on VMS.@refill
  765. @item
  766. Make a symbolic link named @file{md} to the machine description
  767. pattern file (its name should be @file{@var{machine}.md}).
  768. @item
  769. Make a symbolic link named @file{aux-output.c} to the output
  770. subroutine file for your machine (its name should be
  771. @file{output-@var{machine}.c}).
  772. @end itemize
  773. @item
  774. Make sure the Bison parser generator is installed. (This is
  775. unnecessary if the Bison output file @file{parse.tab.c} is more recent
  776. than @file{parse.y} and you do not plan to change @file{parse.y}.)
  777. Note that if you have an old version of Bison you may get an error
  778. from the line with the @samp{%expect} directive. If so, simply remove
  779. that line from @file{parse.y} and proceed.
  780. @item
  781. If you are using a Sun, make sure the environment variable
  782. @code{FLOAT_OPTION} is not set. If this option were set to
  783. @code{f68881} when @file{gnulib} is compiled, the resulting code would
  784. demand to be linked with a special startup file and will not link
  785. properly without special pains.
  786. @item
  787. Build the compiler. Just type @samp{make} in the compiler directory.
  788. @item
  789. Move the first-stage object files and executables into a subdirectory
  790. with this command:
  791. @example
  792. make stage1
  793. @end example
  794. The files are moved into a subdirectory named @file{stage1}.
  795. Once installation is complete, you may wish to delete these files
  796. with @code{rm -r stage1}.
  797. @item
  798. Recompile the compiler with itself, with this command:
  799. @example
  800. make CC=stage1/gcc CFLAGS="-g -O -Bstage1/"
  801. @end example
  802. On a 68000 or 68020 system lacking floating point hardware,
  803. unless you have selected a @file{tm.h} file that expects by default
  804. that there is no such hardware, do this instead:
  805. @example
  806. make CC=stage1/gcc CFLAGS="-g -O -Bstage1/ -msoft-float"
  807. @end example
  808. @item
  809. If you wish to test the compiler by compiling it with itself one more
  810. time, do this:
  811. @example
  812. make stage2
  813. make CC=stage2/gcc CFLAGS="-g -O -Bstage2/"
  814. foreach file (*.o)
  815. cmp $file stage2/$file
  816. end
  817. @end example
  818. This will notify you if any of these stage 3 object files differs from
  819. those of stage 2. Any difference, no matter how innocuous, indicates
  820. that the stage 2 compiler has compiled GNU CC incorrectly, and is
  821. therefore a potentially serious bug which you should investigate and
  822. report (@pxref{Bugs}).
  823. @item
  824. Install the compiler driver, the compiler's passes and run-time support.
  825. You can use the following command:
  826. @example
  827. make install
  828. @end example
  829. @noindent
  830. This copies the files @file{cc1}, @file{cpp} and @file{gnulib} to
  831. files @file{gcc-cc1}, @file{gcc-cpp} and @file{gcc-gnulib} in
  832. directory @file{/usr/local/lib}, which is where the compiler driver
  833. program looks for them. It also copies the driver program @file{gcc}
  834. into the directory @file{/usr/local}, so that it appears in typical
  835. execution search paths.@refill
  836. @strong{Warning: the GNU CPP may not work for @file{ioctl.h},
  837. @file{ttychars.h} and other system header files unless the
  838. @samp{-traditional} option is used.} The bug is in the header files:
  839. at least on some machines, they rely on behavior that is incompatible
  840. with ANSI C. This behavior consists of substituting for macro
  841. argument names when they appear inside of character constants. The
  842. @samp{-traditional} option tells GNU CC to behave the way these
  843. headers expect.
  844. Because of this problem, you might prefer to configure GNU CC to use
  845. the system's own C preprocessor. To do so, make the file
  846. @file{/usr/local/lib/gcc-cpp} a link to @file{/lib/cpp}.
  847. Alternatively, on Sun systems and 4.3BSD at least, you can correct the
  848. include files by running the shell script @file{fixincludes}. This
  849. installs modified, corrected copies of the files @file{ioctl.h} and
  850. @file{ttychars.h} in a special directory where only GNU CC will
  851. normally look for them.
  852. The file @file{/usr/include/vaxuba/qvioctl.h} used in the X window
  853. system needs a similar correction.
  854. @end enumerate
  855. If you cannot install the compiler's passes and run-time support in
  856. @file{/usr/local/lib}, you can alternatively use the @samp{-B} option to
  857. specify a prefix by which they may be found. The compiler concatenates
  858. the prefix with the names @file{cpp}, @file{cc1} and @file{gnulib}.
  859. Thus, you can put the files in a directory @file{/usr/foo/gcc} and
  860. specify @samp{-B/usr/foo/gcc/} when you run GNU CC.
  861. @node VMS Install,, Installation, Installation
  862. @section Installing GNU CC on VMS
  863. The VMS version of GNU CC is normally distributed as a Backup
  864. saveset, so the only installation required is to copy the files.
  865. But here is how to rebuild GNU CC if you change it:
  866. @enumerate
  867. @item
  868. Copy the file @file{tm-vms.h} to @file{tm.h}, @file{config-vms.h} to
  869. @file{config.h}, @file{vax.md} to @file{md.} and @file{output-vax.c}
  870. to @file{aux-output.c}.@refill
  871. @item
  872. Type @samp{@@make} to do recompile everything.
  873. @end enumerate
  874. @node Incompatibilities, Extensions, Installation, Top
  875. @chapter Incompatibilities of GNU CC
  876. There are several noteworthy incompatibilities between GNU C and most
  877. existing (non-ANSI) versions of C.
  878. Ultimately our intention is that the @samp{-traditional} option will
  879. eliminate most of these incompatibilities by telling GNU C to behave
  880. like the other C compilers.
  881. @itemize @bullet
  882. @item
  883. GNU CC normally makes string constants read-only. If several
  884. identical-looking string constants are used, GNU CC stores only one
  885. copy of the string.
  886. One consequence is that you cannot call @code{mktemp} with a string
  887. constant argument. The function @code{mktemp} always alters the
  888. string its argument points to.
  889. Another consequence is that @code{sscanf} does not work on some
  890. systems when passed a string constant as its format control string.
  891. This is because @code{sscanf} incorrectly tries to write into the
  892. string constant.
  893. The best solution to these problems is to change the program to use
  894. @code{char}-array variables with initialization strings for these
  895. purposes instead of string constants. But if this is not possible,
  896. you can use the @samp{-fwritable-strings} flag, which directs GNU CC
  897. to handle string constants the same way most C compilers do.
  898. @item
  899. GNU CC does not substitute macro arguments when they appear inside of
  900. string constants. For example, the following macro in GNU CC
  901. @example
  902. #define foo(a) "a"
  903. @end example
  904. @noindent
  905. will produce output @samp{"a"} regardless of what the argument @var{a} is.
  906. The @samp{-traditional} option directs GNU CC to handle such cases
  907. (among others) in the old-fashioned (non-ANSI) fashion.
  908. @item
  909. When you use @code{setjmp} and @code{longjmp}, the only automatic
  910. variables guaranteed to remain valid are those declared
  911. @code{volatile}. This is a consequence of automatic register
  912. allocation. Consider this function:
  913. @example
  914. jmp_buf j;
  915. foo ()
  916. @{
  917. int a, b;
  918. a = fun1 ();
  919. if (setjmp (j))
  920. return a;
  921. a = fun2 ();
  922. /* @r{@code{longjmp (j)} may be occur in @code{fun3}.} */
  923. return a + fun3 ();
  924. @}
  925. @end example
  926. Here @code{a} may or may not be restored to its first value when the
  927. @code{longjmp} occurs. If @code{a} is allocated in a register, then
  928. its first value is restored; otherwise, it keeps the last value stored
  929. in it.
  930. If you use the @samp{-W} option with the @samp{-O} option, you will
  931. get a warning when GNU CC thinks such a problem might be possible.
  932. @item
  933. Declarations of external variables and functions within a block apply
  934. only to the block containing the declaration. In other words, they
  935. have the same scope as any other declaration in the same place.
  936. In some other C compilers, a @code{extern} declaration affects all the
  937. rest of the file even if it happens within a block.
  938. The @samp{-traditional} option directs GNU C to treat all @code{extern}
  939. declarations as global, like traditional compilers.
  940. @item
  941. In traditional C, you can combine @code{long}, etc., with a typedef name,
  942. as shown here:
  943. @example
  944. typedef int foo;
  945. typedef long foo bar;
  946. @end example
  947. In ANSI C, this is not allowed: @code{long} and other type modifiers
  948. require an explicit @code{int}. Because this criterion is expressed
  949. by Bison grammar rules rather than C code, the @samp{-traditional}
  950. flag cannot alter it.
  951. @item
  952. When compiling functions that return structures or unions, GNU CC
  953. output code uses a method different from that used on most versions of
  954. Unix. As a result, code compiled with GNU CC cannot call a
  955. structure-returning function compiled with PCC, and vice versa.
  956. The method used by GCC is as follows: a structure or union which is 1,
  957. 2, 4 or 8 bytes long is returned like a scalar. A structure or union
  958. with any other size is stored into an address supplied by the caller
  959. in a special, fixed register.
  960. PCC usually handles all sizes of structures and unions by returning
  961. the address of a block of static storage containing the value. This
  962. method is not used in GCC because it is slower and nonreentrant.
  963. On systems where PCC works this way, you may be able to make GCC-compiled
  964. code call such functions that were compiled with PCC by declaring them
  965. to return a pointer to the structure or union instead of the structure
  966. or union itself. For example, instead of this:
  967. @example
  968. struct foo nextfoo ();
  969. @end example
  970. @noindent
  971. write this:
  972. @example
  973. struct foo *nextfoo ();
  974. #define nextfoo *nextfoo
  975. @end example
  976. @noindent
  977. (Note that this assumes you are using the GNU preprocessor, so that
  978. the ANSI antirecursion rules for macro expansions are effective.)
  979. @end itemize
  980. @node Extensions, Bugs, Incompatibilities, Top
  981. @chapter GNU Extensions to the C Language
  982. GNU C provides several language features not found in ANSI standard C.
  983. (The @samp{-pedantic} option directs GNU CC to print a warning message if
  984. any of these features is used.) To test for the availability of these
  985. features in conditional compilation, check for a predefined macro
  986. @code{__GNUC__}, which is always defined under GNU CC.
  987. @menu
  988. * Statement Exprs:: Putting statements and declarations inside expressions.
  989. * Naming Types:: Giving a name to the type of some expression.
  990. * Typeof:: @code{typeof}: referring to the type of an expression.
  991. * Lvalues:: Using @samp{?:}, @samp{,} and casts in lvalues.
  992. * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
  993. * Zero-Length:: Zero-length arrays.
  994. * Variable-Length:: Arrays whose length is computed at run time.
  995. * Subscripting:: Any array can be subscripted, even if not an lvalue.
  996. * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
  997. * Constructors:: Constructor expressions give structures, unions
  998. or arrays as values.
  999. * Dollar Signs:: Dollar sign is allowed in identifiers.
  1000. * Alignment:: Inquiring about the alignment of a type or variable.
  1001. * Inline:: Defining inline functions (as fast as macros).
  1002. * Extended Asm:: Assembler instructions with C expressions as operands.
  1003. (With them you can define ``built-in'' functions.)
  1004. * Asm Labels:: Specifying the assembler name to use for a C symbol.
  1005. @end menu
  1006. @node Statement Exprs, Naming Types, Extensions, Extensions
  1007. @section Statements and Declarations inside of Expressions
  1008. A compound statement in parentheses may appear inside an expression in GNU
  1009. C. This allows you to declare variables within an expression. For
  1010. example:
  1011. @example
  1012. (@{ int y = foo (); int z;
  1013. if (y > 0) z = y;
  1014. else z = - y;
  1015. z; @})
  1016. @end example
  1017. @noindent
  1018. is a valid (though slightly more complex than necessary) expression
  1019. for the absolute value of @code{foo ()}.
  1020. This feature is especially useful in making macro definitions ``safe'' (so
  1021. that they evaluate each operand exactly once). For example, the
  1022. ``maximum'' function is commonly defined as a macro in standard C as
  1023. follows:
  1024. @example
  1025. #define max(a,b) ((a) > (b) ? (a) : (b))
  1026. @end example
  1027. @noindent
  1028. But this definition computes either @var{a} or @var{b} twice, with bad
  1029. results if the operand has side effects. In GNU C, if you know the
  1030. type of the operands (here let's assume @code{int}), you can define
  1031. the macro safely as follows:
  1032. @example
  1033. #define maxint(a,b) \
  1034. (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
  1035. @end example
  1036. Embedded statements are not allowed in constant expressions, such as
  1037. the value of an enumeration constant, the width of a bit field, or
  1038. the initial value of a static variable.
  1039. If you don't know the type of the operand, you can still do this, but you
  1040. must use @code{typeof} (@pxref{Typeof}) or type naming (@pxref{Naming
  1041. Types}).
  1042. @node Naming Types, Typeof, Statement Exprs, Extensions
  1043. @section Naming an Expression's Type
  1044. You can give a name to the type of an expression using a @code{typedef}
  1045. declaration with an initializer. Here is how to define @var{name} as a
  1046. type name for the type of @var{exp}:
  1047. @example
  1048. typedef @var{name} = @var{exp};
  1049. @end example
  1050. This is useful in conjunction with the statements-within-expressions
  1051. feature. Here is how the two together can be used to define a safe
  1052. ``maximum'' macro that operates on any arithmetic type:
  1053. @example
  1054. #define max(a,b) \
  1055. (@{typedef _ta = (a), _tb = (b); \
  1056. _ta _a = (a); _tb _b = (b); \
  1057. _a > _b ? _a : _b; @})
  1058. @end example
  1059. The reason for using names that start with underscores for the local
  1060. variables is to avoid conflicts with variable names that occur within the
  1061. expressions that are substituted for @code{a} and @code{b}. Eventually we
  1062. hope to design a new form of declaration syntax that allows you to declare
  1063. variables whose scopes start only after their initializers; this will be a
  1064. more reliable way to prevent such conflicts.
  1065. @node Typeof, Lvalues, Naming Types, Extensions
  1066. @section Referring to a Type with @code{typeof}
  1067. Another way to refer to the type of an expression is with @code{typeof}.
  1068. The syntax of using of this keyword looks like @code{sizeof}, but the
  1069. construct acts semantically like a type name defined with @code{typedef}.
  1070. There are two ways of writing the argument to @code{typeof}: with an
  1071. expression or with a type. Here is an example with an expression:
  1072. @example
  1073. typeof (x[0](1))
  1074. @end example
  1075. @noindent
  1076. This assumes that @code{x} is an array of functions; the type described
  1077. is that of the values of the functions.
  1078. Here is an example with a typename as the argument:
  1079. @example
  1080. typeof (int *)
  1081. @end example
  1082. @noindent
  1083. Here the type described is that of pointers to @code{int}.
  1084. A @code{typeof}-construct can be used anywhere a typedef name could be
  1085. used. For example, you can use it in a declaration, in a cast, or inside
  1086. of @code{sizeof} or @code{typeof}.
  1087. @itemize @bullet
  1088. @item
  1089. This declares @code{y} with the type of what @code{x} points to.
  1090. @example
  1091. typeof (*x) y;
  1092. @end example
  1093. @item
  1094. This declares @code{y} as an array of such values.
  1095. @example
  1096. typeof (*x) y[4];
  1097. @end example
  1098. @item
  1099. This declares @code{y} as an array of pointers to characters:
  1100. @example
  1101. typeof (typeof (char *)[4]) y;
  1102. @end example
  1103. @noindent
  1104. It is equivalent to the following traditional C declaration:
  1105. @example
  1106. char *y[4];
  1107. @end example
  1108. To see the meaning of the declaration using @code{typeof}, and why it
  1109. might be a useful way to write, let's rewrite it with these macros:
  1110. @example
  1111. #define pointer(T) typeof(T *)
  1112. #define array(T, N) typeof(T [N])
  1113. @end example
  1114. @noindent
  1115. Now the declaration can be rewritten this way:
  1116. @example
  1117. array (pointer (char), 4) y;
  1118. @end example
  1119. @noindent
  1120. Thus, @samp{array (pointer (char), 4)} is the type of arrays of 4
  1121. pointers to @code{char}.
  1122. @end itemize
  1123. @node Lvalues, Conditionals, Typeof, Extensions
  1124. @section Generalized Lvalues
  1125. Compound expressions, conditional expressions and casts are allowed as
  1126. lvalues provided their operands are lvalues. This means that you can take
  1127. their addresses or store values into them.
  1128. For example, a compound expression can be assigned, provided the last
  1129. expression in the sequence is an lvalue. These two expressions are
  1130. equivalent:
  1131. @example
  1132. (a, b) += 5
  1133. a, (b += 5)
  1134. @end example
  1135. Similarly, the address of the compound expression can be taken. These two
  1136. expressions are equivalent:
  1137. @example
  1138. &(a, b)
  1139. a, &b
  1140. @end example
  1141. A conditional expression is a valid lvalue if its type is not void and the
  1142. true and false branches are both valid lvalues. For example, these two
  1143. expressions are equivalent:
  1144. @example
  1145. (a ? b : c) = 5
  1146. (a ? b = 5 : (c = 5))
  1147. @end example
  1148. A cast is a valid lvalue if its operand is valid. Taking the address of
  1149. the cast is the same as taking the address without a cast, except for the
  1150. type of the result. For example, these two expressions are equivalent (but
  1151. the second may be valid when the type of @samp{a} does not permit a cast to
  1152. @samp{int *}).
  1153. @example
  1154. &(int *)a
  1155. (int **)&a
  1156. @end example
  1157. A simple assignment whose left-hand side is a cast works by converting the
  1158. right-hand side first to the specified type, then to the type of the inner
  1159. left-hand side expression. After this is stored, the value is converter
  1160. back to the specified type to become the value of the assignment. Thus, if
  1161. @samp{a} has type @samp{char *}, the following two expressions are
  1162. equivalent:
  1163. @example
  1164. (int)a = 5
  1165. (int)(a = (char *)5)
  1166. @end example
  1167. An assignment-with-arithmetic operation such as @samp{+=} applied to a cast
  1168. performs the arithmetic using the type resulting from the cast, and then
  1169. continues as in the previous case. Therefore, these two expressions are
  1170. equivalent:
  1171. @example
  1172. (int)a += 5
  1173. (int)(a = (char *) ((int)a + 5))
  1174. @end example
  1175. @node Conditionals, Zero-Length, Lvalues, Extensions
  1176. @section Conditional Expressions with Omitted Middle-Operands
  1177. The middle operand in a conditional expression may be omitted. Then
  1178. if the first operand is nonzero, its value is the value of the conditional
  1179. expression.
  1180. Therefore, the expression
  1181. @example
  1182. x ? : y
  1183. @end example
  1184. @noindent
  1185. has the value of @code{x} if that is nonzero; otherwise, the value of
  1186. @code{y}.
  1187. This example is perfectly equivalent to
  1188. @example
  1189. x ? x : y
  1190. @end example
  1191. @noindent
  1192. In this simple case, the ability to omit the middle operand is not
  1193. especially useful. When it becomes useful is when the first operand does,
  1194. or may (if it is a macro argument), contain a side effect. Then repeating
  1195. the operand in the middle would perform the side effect twice. Omitting
  1196. the middle operand uses the value already computed without the undesirable
  1197. effects of recomputing it.
  1198. @node Zero-Length, Variable-Length, Conditionals, Extensions
  1199. @section Arrays of Length Zero
  1200. Zero-length arrays are allowed in GNU C. They are very useful as the last
  1201. element of a structure which is really a header for a variable-length
  1202. object:
  1203. @example
  1204. struct line @{
  1205. int length;
  1206. char contents[0];
  1207. @};
  1208. @{
  1209. struct line *thisline
  1210. = (struct line *) malloc (sizeof (struct line) + this_length);
  1211. thisline->length = thislength;
  1212. @}
  1213. @end example
  1214. In standard C, you would have to give @code{contents} a length of 1, which
  1215. means either you waste space or complicate the argument to @code{malloc}.
  1216. @node Variable-Length, Subscripting, Zero-Length, Extensions
  1217. @section Arrays of Variable Length
  1218. Variable-length automatic arrays are allowed in GNU C. These arrays are
  1219. declared like any other automatic arrays, but with a length that is not a
  1220. constant expression. The storage is allocated at that time and
  1221. deallocated when the brace-level is exited. For example:
  1222. @example
  1223. FILE *concat_fopen (char *s1, char *s2, char *mode)
  1224. @{
  1225. char str[strlen (s1) + strlen (s2) + 1];
  1226. strcpy (str, s1);
  1227. strcat (str, s2);
  1228. return fopen (str, mode);
  1229. @}
  1230. @end example
  1231. You can also define structure types containing variable-length arrays, and
  1232. use them even for arguments or function values, as shown here:
  1233. @example
  1234. int foo;
  1235. struct entry
  1236. @{
  1237. char data[foo];
  1238. @};
  1239. struct entry
  1240. tester (struct entry arg)
  1241. @{
  1242. struct entry new;
  1243. int i;
  1244. for (i = 0; i < foo; i++)
  1245. new.data[i] = arg.data[i] + 1;
  1246. return new;
  1247. @}
  1248. @end example
  1249. @noindent
  1250. (Eventually there will be a way to say that the size of the array is
  1251. another member of the same structure.)
  1252. The length of an array is computed on entry to the brace-level where the
  1253. array is declared and is remembered for the scope of the array in case you
  1254. access it with @code{sizeof}.
  1255. Jumping or breaking out of the scope of the array name will also deallocate
  1256. the storage. Jumping into the scope is not allowed; you will get an error
  1257. message for it.
  1258. You can use the function @code{alloca} to get an effect much like
  1259. variable-length arrays. The function @code{alloca} is available in
  1260. many other C implementations (but not in all). On the other hand,
  1261. variable-length arrays are more elegant.
  1262. There are other differences between these two methods. Space allocated
  1263. with @code{alloca} exists until the containing @emph{function} returns.
  1264. The space for a variable-length array is deallocated as soon as the array
  1265. name's scope ends. (If you use both variable-length arrays and
  1266. @code{alloca} in the same function, deallocation of a variable-length array
  1267. will also deallocate anything more recently allocated with @code{alloca}.)
  1268. @node Subscripting, Pointer Arith, Variable-Length, Extensions
  1269. @section Non-Lvalue Arrays May Have Subscripts
  1270. Subscripting is allowed on arrays that are not lvalues, even though the
  1271. unary @samp{&} operator is not. For example, this is valid in GNU C though
  1272. not valid in other C dialects:
  1273. @example
  1274. struct foo @{int a[4];@};
  1275. struct foo f();
  1276. bar (int index)
  1277. @{
  1278. return f().a[index];
  1279. @}
  1280. @end example
  1281. @node Pointer Arith, Initializers, Subscripting, Extensions
  1282. @section Arithmetic on @code{void}-Pointers and Function Pointers
  1283. In GNU C, addition and subtraction operations are supported on pointers to
  1284. @code{void} and on pointers to functions. This is done by treating the
  1285. size of a @code{void} or of a function as 1.
  1286. A consequence of this is that @code{sizeof} is also allowed on @code{void}
  1287. and on function types, and returns 1.
  1288. @node Initializers, Constructors, Pointer Arith, Extensions
  1289. @section Non-Constant Initializers
  1290. The elements of an aggregate initializer are not required to be constant
  1291. expressions in GNU C. Here is an example of an initializer with run-time
  1292. varying elements:
  1293. @example
  1294. foo (float f, float g)
  1295. @{
  1296. float beat_freqs[2] = @{ f-g, f+g @};
  1297. @dots{}
  1298. @}
  1299. @end example
  1300. @node Constructors, Dollar Signs, Initializers, Extensions
  1301. @section Constructor Expressions
  1302. GNU C supports constructor expressions. A constructor looks like a cast
  1303. containing an initializer. Its value is an object of the type specified in
  1304. the cast, containing the elements specified in the initializer. The type
  1305. must be a structure, union or array type.
  1306. Assume that @code{struct foo} and @code{structure} are declared as shown:
  1307. @example
  1308. struct foo @{int a; char b[2];@} structure;
  1309. @end example
  1310. @noindent
  1311. Here is an example of constructing a @samp{struct foo} with a constructor:
  1312. @example
  1313. structure = ((struct foo) @{x + y, 'a', 0@});
  1314. @end example
  1315. @noindent
  1316. This is equivalent to writing the following:
  1317. @example
  1318. @{
  1319. struct foo temp = @{x + y, 'a', 0@};
  1320. structure = temp;
  1321. @}
  1322. @end example
  1323. You can also construct an array. If all the elements of the constructor
  1324. are (made up of) simple constant expressions, suitable for use in
  1325. initializers, then the constructor is an lvalue and can be coerced to a
  1326. pointer to its first element, as shown here:
  1327. @example
  1328. char **foo = (char *[]) @{ "x", "y", "z" @};
  1329. @end example
  1330. Array constructors whose elements are not simple constants are not very
  1331. useful, because the constructor is not an lvalue. There are only two valid
  1332. ways to use it: to subscript it, or initialize an array variable with it.
  1333. The former is probably slower than a @code{switch} statement, while the
  1334. latter does the same thing an ordinary C initializer would do.
  1335. @example
  1336. output = ((int[]) @{ 2, x, 28 @}) [input];
  1337. @end example
  1338. @node Dollar Signs, Alignment, Constructors, Extensions
  1339. @section Dollar Signs in Identifier Names
  1340. In GNU C, you may use dollar signs in identifier names. This is because
  1341. many traditional C implementations allow such identifiers.
  1342. @node Alignment, Inline, Dollar Signs, Extensions
  1343. @section Inquiring about the Alignment of a Type or Variable
  1344. The keyword @code{__alignof} allows you to inquire about how an object
  1345. is aligned, or the minimum alignment usually required by a type. Its
  1346. syntax is just like @code{sizeof}.
  1347. For example, if the target machine requires a @code{double} value to be
  1348. aligned on an 8-byte boundary, then @code{__alignof (double)} is 8. This
  1349. is true on many RISC machines. On more traditional machine designs,
  1350. @code{__alignof (double)} is 4 or even 2.
  1351. Some machines never actually require alignment; they allow reference to any
  1352. data type even at an odd addresses. For these machines, @code{__alignof}
  1353. reports the @emph{recommended} alignment of a type.
  1354. When the operand of @code{__alignof} is an lvalue rather than a type, the
  1355. value is the largest alignment that the lvalue is known to have. It may
  1356. have this alignment as a result of its data type, or because it is part of
  1357. a structure and inherits alignment from that structure. For example, after
  1358. this declaration:
  1359. @example
  1360. struct foo @{ int x; char y; @} foo1;
  1361. @end example
  1362. @noindent
  1363. the value of @code{__alignof (foo1.y)} is probably 2 or 4, the same as
  1364. @code{__alignof (int)}, even though the data type of @code{foo1.y} does not
  1365. itself demand any alignment.@refill
  1366. @node Inline, Extended Asm, Alignment, Extensions
  1367. @section An Inline Function is As Fast As a Macro
  1368. By declaring a function @code{inline}, you can direct GNU CC to integrate
  1369. that function's code into the code for its callers. This makes execution
  1370. faster by eliminating the function-call overhead; in addition, if any of
  1371. the actual argument values are constant, their known values may permit
  1372. simplifications at compile time so that not all of the inline function's
  1373. code needs to be included.
  1374. To declare a function inline, use the @code{inline} keyword in its
  1375. declaration, like this:
  1376. @example
  1377. inline int
  1378. inc (int *a)
  1379. @{
  1380. (*a)++;
  1381. @}
  1382. @end example
  1383. You can also make all ``simple enough'' functions inline with the
  1384. option @samp{-finline-functions}. Note that certain usages in a
  1385. function definition can make it unsuitable for inline substitution.
  1386. When a function is both inline and @code{static}, if all calls to the
  1387. function are integrated into the caller, then the function's own assembler
  1388. code is never referenced. In this case, GNU CC does not actually output
  1389. assembler code for the function, unless you specify the option
  1390. @samp{-fkeep-inline-functions}. Some calls cannot be integrated for
  1391. various reasons (in particular, calls that precede the function's
  1392. definition cannot be integrated, and neither can recursive calls within the
  1393. definition). If there is a nonintegrated call, then the function is
  1394. compiled to assembler code as usual.
  1395. When an inline function is not @code{static}, then the compiler must assume
  1396. that there may be calls from other source files; since a global symbol can
  1397. be defined only once in any program, the function must not be defined in
  1398. the other source files, so the calls therein cannot be integrated.
  1399. Therefore, a non-@code{static} inline function is always compiled on its
  1400. own in the usual fashion.
  1401. @node Extended Asm, Asm Labels, Inline, Extensions
  1402. @section Assembler Instructions with C Expression Operands
  1403. In an assembler instruction using @code{asm}, you can now specify the
  1404. operands of the instruction using C expressions. This means no more
  1405. guessing which registers or memory locations will contain the data you want
  1406. to use.
  1407. You must specify an assembler instruction template much like what appears
  1408. in a machine description, plus an operand constraint string for each
  1409. operand.
  1410. For example, here is how to use the 68881's @code{fsinx} instruction:
  1411. @example
  1412. asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
  1413. @end example
  1414. @noindent
  1415. Here @code{angle} is the C expression for the input operand while
  1416. @code{result} is that of the output operand. Each has @samp{"f"} as its
  1417. operand constraint, saying that a floating-point register is required. The
  1418. constraints use the same language used in the machine description
  1419. (@pxref{Constraints}).
  1420. Each operand is described by an operand-constraint string followed by the C
  1421. expression in parentheses. A colon separates the assembler template from
  1422. the first output operand, and another separates the last output operand
  1423. from the first input, if any. Commas separate output operands and separate
  1424. inputs. The number of operands is limited to the maximum number of
  1425. operands in any instruction pattern in the machine description.
  1426. Output operand expressions must be lvalues, and there must be at least one
  1427. of them. The compiler can check this. The input operands need not be
  1428. lvalues, and there need not be any. The compiler cannot check whether the
  1429. operands have data types that are reasonable for the instruction being
  1430. executed.
  1431. The output operands must be write-only; GNU CC will assume that the values
  1432. in these operands before the instruction are dead and need not be
  1433. generated. For an operand that is read-write, you must logically split its
  1434. function into two separate operands, one input operand and one write-only
  1435. output operand. The connection between them is expressed by constraints
  1436. which say they need to be in the same location when the instruction
  1437. executes. You can use the same C expression for both operands, or
  1438. different expressions. For example, here we write the (fictitious)
  1439. @samp{combine} instruction with @code{bar} as its read-only source operand
  1440. and @code{foo} as its read-write destination:
  1441. @example
  1442. asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
  1443. @end example
  1444. @noindent
  1445. The constraint @samp{"0"} for operand 1 says that it must occupy the same
  1446. location as operand 0. Therefore it is not necessary to substitute operand
  1447. 1 into the assembler code output.
  1448. Usually the most convenient way to use these @code{asm} instructions is to
  1449. encapsulate them in macros that look like functions. For example,
  1450. @example
  1451. #define sin(x) \
  1452. (@{ double __value, __arg = (x); \
  1453. asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \
  1454. __value; @})
  1455. @end example
  1456. @noindent
  1457. Here the variable @code{__arg} is used to make sure that the instruction
  1458. operates on a proper @code{double} value, and to accept only those
  1459. arguments @code{x} which can convert automatically to a @code{double}.
  1460. Another way to make sure the instruction operates on the correct data type
  1461. is to use a cast in the @code{asm}. This is different from using a
  1462. variable @code{__arg} in that it converts more different types. For
  1463. example, if the desired type were @code{int}, casting the argument to
  1464. @code{int} would accept a pointer with no complaint, while assigning the
  1465. argument to an @code{int} variable named @code{__arg} would warn about
  1466. using a pointer unless the caller explicitly casts it.
  1467. GNU CC assumes for optimization purposes that these instructions have no
  1468. side effects except to change the output operands. This does not mean that
  1469. instructions with a side effect cannot be used, but you must be careful,
  1470. because the compiler may eliminate them if the output operands aren't used,
  1471. or move them out of loops, or replace two with one if they constitute a
  1472. common subexpression. Also, if your instruction does have a side effect on
  1473. a variable that otherwise appears not to change, the old value of the
  1474. variable may be reused later if it happens to be found in a register.
  1475. You can prevent an @code{asm} instruction from being deleted, moved or
  1476. combined by writing the keyword @code{volatile} after the @code{asm}. For
  1477. example:
  1478. @example
  1479. #define set_priority(x) \
  1480. asm volatile ("set_priority %1": \
  1481. "=m" (*(char *)0): "g" (x))
  1482. @end example
  1483. @noindent
  1484. Note that we have supplied an output operand which is not actually used in
  1485. the instruction. This is because @code{asm} requires at least one output
  1486. operand. This requirement exists for internal implementation reasons and
  1487. we might be able to relax it in the future.
  1488. In this case output operand has the additional benefit effect of giving the
  1489. appearance of writing in memory. As a result, GNU CC will assume that data
  1490. previously fetched from memory must be fetched again if needed again later.
  1491. This may be desirable if you have not employed the @code{volatile} keyword
  1492. on all the variable declarations that ought to have it.
  1493. @node Asm Labels,,Extended Asm, Extensions
  1494. @section Controlling Names Used in Assembler Code
  1495. You can specify the name to be used in the assembler code for a C function
  1496. or variable by writing the @code{asm} keyword after the declarator as
  1497. follows:
  1498. @example
  1499. int foo asm ("myfoo") = 2;
  1500. @end example
  1501. @noindent
  1502. This specifies that the name to be used for the variable @code{foo} in
  1503. the assembler code should be @samp{myfoo} rather than the usual
  1504. @samp{_foo}.
  1505. On systems where an underscore is normally prepended to the name of a C
  1506. function or variable, this feature allows you to define names for the
  1507. linker that do not start with an underscore.
  1508. You cannot use @code{asm} in this way in a function @emph{definition}; but
  1509. you can get the same effect by writing a declaration for the function
  1510. before its definition and putting @code{asm} there, like this:
  1511. @example
  1512. extern func () asm ("FUNC");
  1513. func (x, y)
  1514. int x, y;
  1515. @dots{}
  1516. @end example
  1517. It is up to you to make sure that the assembler names you choose do not
  1518. conflict with any other assembler symbols. Also, you must not use a
  1519. register name; that would produce completely invalid assembler code. GNU
  1520. CC does not as yet have the ability to store static variables in registers.
  1521. Perhaps that will be added.
  1522. @node Bugs, Portability, Extensions, Top
  1523. @chapter Reporting Bugs
  1524. Your bug reports play an essential role in making GNU CC reliable.
  1525. Reporting a bug may help you by bringing a solution to your problem, or it
  1526. may not. But in any case the important function of a bug report is to help
  1527. the entire community by making the next version of GNU CC work better. Bug
  1528. reports are your contribution to the maintenance of GNU CC.
  1529. In order for a bug report to serve its purpose, you must include the
  1530. information that makes for fixing the bug.
  1531. @menu
  1532. * Criteria: Bug Criteria. Have you really found a bug?
  1533. * Reporting: Bug Reporting. How to report a bug effectively.
  1534. @end menu
  1535. @node Bug Criteria, Bug Reporting, Bugs, Bugs
  1536. @section Have You Found a Bug?
  1537. If you are not sure whether you have found a bug, here are some guidelines:
  1538. @itemize @bullet
  1539. @item
  1540. If the compiler gets a fatal signal, for any input whatever, that is a
  1541. compiler bug. Reliable compilers never crash.
  1542. @item
  1543. If the compiler produces invalid assembly code, for any input whatever
  1544. (except an @code{asm} statement), that is a compiler bug, unless the
  1545. compiler reports errors (not just warnings) which would ordinarily
  1546. prevent the assembler from being run.
  1547. @item
  1548. If the compiler produces valid assembly code that does not correctly
  1549. execute the input source code, that is a compiler bug.
  1550. However, you must double-check to make sure, because you may have run
  1551. into an incompatibility between GNU C and traditional C
  1552. (@pxref{Incompatibilities}). These incompatibilities might be considered
  1553. bugs, but they are inescapable consequences of features valuable
  1554. features.
  1555. Or you may have a program whose behavior is undefined, which happened
  1556. by chance to give the desired results with another C compiler.
  1557. For example, in many nonoptimizing compilers, you can write @samp{x;}
  1558. at the end of a function instead of @samp{return x;}, with the same
  1559. results. But the value of the function is undefined if @samp{return}
  1560. is omitted; it is not a bug when GNU CC produces different results.
  1561. Problems often result from expressions with two increment operators,
  1562. as in @samp{f (*p++, *p++)}. Your previous compiler might have
  1563. interpreted that expression the way you intended; GNU CC might
  1564. interpret it another way; neither compiler is wrong.
  1565. After you have localized the error to a single source line, it should
  1566. be easy to check for these things. If your program is correct and
  1567. well defined, you have found a compiler bug.
  1568. @item
  1569. If the compiler produces an error message for valid input, that is a
  1570. compiler bug.
  1571. Note that the following is not valid input, and the error message for
  1572. it is not a bug:
  1573. @example
  1574. int foo (char);
  1575. int
  1576. foo (x)
  1577. char x;
  1578. @{ @dots{} @}
  1579. @end example
  1580. @noindent
  1581. The prototype says to pass a @code{char}, while the definition says to
  1582. pass an @code{int} and treat the value as a @code{char}. This is what
  1583. the ANSI standard says, and it makes sense.
  1584. @item
  1585. If the compiler does not produce an error message for invalid input,
  1586. that is a compiler bug. However, you should note that your idea of
  1587. ``invalid input'' might be my idea of ``an extension'' or ``support
  1588. for traditional practice''.
  1589. @item
  1590. If you are an experienced user of C compilers, your suggestions
  1591. for improvement of GNU CC are welcome in any case.
  1592. @end itemize
  1593. @node Bug Reporting,, Bug Criteria, Bugs
  1594. @section How to Report Bugs
  1595. Send bug reports for GNU C to one of these addresses:
  1596. @example
  1597. bug-gcc@@prep.ai.mit.edu
  1598. @{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gcc
  1599. @end example
  1600. As a last resort, snail them to:
  1601. @example
  1602. GNU Compiler Bugs
  1603. 545 Tech Sq
  1604. Cambridge, MA 02139
  1605. @end example
  1606. The fundamental principle of reporting bugs usefully is this:
  1607. @strong{report all the facts}. If you are not sure whether to mention a
  1608. fact or leave it out, mention it!
  1609. Often people omit facts because they think they know what causes the
  1610. problem and they conclude that some details don't matter. Thus, you might
  1611. assume that the name of the variable you use in an example does not matter.
  1612. Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a
  1613. stray memory reference which happens to fetch from the location where that
  1614. name is stored in memory; perhaps, if the name were different, the contents
  1615. of that location would fool the compiler into doing the right thing despite
  1616. the bug. Play it safe and give an exact example.
  1617. If you want to enable me to fix the bug, you should include all these
  1618. things:
  1619. @itemize @bullet
  1620. @item
  1621. The version of GNU CC. You can get this by running it with the
  1622. @samp{-v} option.
  1623. Without this, I won't know whether there is any point in looking for
  1624. the bug in the current version of GNU CC.
  1625. @item
  1626. A complete input file that will reproduce the bug. If the bug is in
  1627. the C preprocessor, send me a source file and any header files that it
  1628. requires. If the bug is in the compiler proper (@file{cc1}), run your
  1629. source file through the C preprocessor by doing @samp{gcc -E
  1630. @var{sourcefile} > @var{outfile}}, then include the contents of
  1631. @var{outfile} in the bug report. (Any @samp{-I}, @samp{-D} or
  1632. @samp{-U} options that you used in actual compilation should also be
  1633. used when doing this.)
  1634. A single statement is not enough of an example. In order to compile
  1635. it, it must be embedded in a function definition; and the bug might
  1636. depend on the details of how this is done.
  1637. Without a real example I can compile, all I can do about your bug
  1638. report is wish you luck. It would be futile to try to guess how to
  1639. provoke the bug. For example, bugs in register allocation and
  1640. reloading frequently depend on every little detail of the function
  1641. they happen in.
  1642. @item
  1643. The command arguments you gave GNU CC to compile that example and
  1644. observe the bug. For example, did you use @samp{-O}? To guarantee
  1645. you won't omit something important, list them all.
  1646. If I were to try to guess the arguments, I would probably guess wrong
  1647. and then I would not encounter the bug.
  1648. @item
  1649. The names of the files that you used for @file{tm.h} and @file{md}
  1650. when you installed the compiler.
  1651. @item
  1652. The type of machine you are using, and the operating system name and
  1653. version number.
  1654. @item
  1655. A description of what behavior you observe that you believe is
  1656. incorrect. For example, ``It gets a fatal signal,'' or, ``There is an
  1657. incorrect assembler instruction in the output.''
  1658. Of course, if the bug is that the compiler gets a fatal signal, then I
  1659. will certainly notice it. But if the bug is incorrect output, I might
  1660. not notice unless it is glaringly wrong. I won't study all the
  1661. assembler code from a 50-line C program just on the off chance that it
  1662. might be wrong.
  1663. Even if the problem you experience is a fatal signal, you should still
  1664. say so explicitly. Suppose something strange is going on, such as,
  1665. your copy of the compiler is out of synch, or you have encountered a
  1666. bug in the C library on your system. (This has happened!) Your copy
  1667. might crash and mine would not. If you @i{told} me to expect a crash,
  1668. then when mine fails to crash, I would know that the bug was not
  1669. happening for me. If you had not told me to expect a crash, then I
  1670. would not be able to draw any conclusion from my observations.
  1671. In cases where GNU CC generates incorrect code, if you send me a small
  1672. complete sample program I will find the error myself by running the
  1673. program under a debugger. If you send me a large example or a part of
  1674. a larger program, I cannot do this; you must debug the compiled
  1675. program and narrow the problem down to one source line. Tell me which
  1676. source line it is, and what you believe is incorrect about the code
  1677. generated for that line.
  1678. @item
  1679. If you send me examples of output from GNU CC, please use @samp{-g}
  1680. when you make them. The debugging information includes source line
  1681. numbers which are essential for correlating the output with the input.
  1682. @end itemize
  1683. Here are some things that are not necessary:
  1684. @itemize @bullet
  1685. @item
  1686. A description of the envelope of the bug.
  1687. Often people who encounter a bug spend a lot of time investigating
  1688. which changes to the input file will make the bug go away and which
  1689. changes will not affect it.
  1690. This is often time consuming and not very useful, because the way I
  1691. will find the bug is by running a single example under the debugger
  1692. with breakpoints, not by pure deduction from a series of examples.
  1693. Of course, it can't hurt if you can find a simpler example that
  1694. triggers the same bug. Errors in the output will be easier to spot,
  1695. running under the debugger will take less time, etc. An easy way
  1696. to simplify an example is to delete all the function definitions
  1697. except the one where the bug occurs. Those earlier in the file
  1698. may be replaced by external declarations.
  1699. However, simplification is not necessary; if you don't want to do
  1700. this, report the bug anyway.
  1701. @item
  1702. A patch for the bug.
  1703. A patch for the bug does help me if it is a good one. But don't omit
  1704. the necessary information, such as the test case, because I might see
  1705. problems with your patch and decide to fix the problem another way.
  1706. Sometimes with a program as complicated as GNU CC it is very hard to
  1707. construct an example that will make the program go through a certain
  1708. point in the code. If you don't send me the example, I won't be able
  1709. to verify that the bug is fixed.
  1710. @item
  1711. A guess about what the bug is or what it depends on.
  1712. Such guesses are usually wrong. Even I can't guess right about such
  1713. things without using the debugger to find the facts. They also don't
  1714. serve a useful purpose.
  1715. @end itemize
  1716. @node Portability, Interface, Bugs, Top
  1717. @chapter GNU CC and Portability
  1718. The main goal of GNU CC was to make a good, fast compiler for machines in
  1719. the class that the GNU system aims to run on: 32-bit machines that address
  1720. 8-bit bytes and have several general registers. Elegance, theoretical
  1721. power and simplicity are only secondary.
  1722. GNU CC gets most of the information about the target machine from a machine
  1723. description which gives an algebraic formula for each of the machine's
  1724. instructions. This is a very clean way to describe the target. But when
  1725. the compiler needs information that is difficult to express in this
  1726. fashion, I have not hesitated to define an ad-hoc parameter to the machine
  1727. description. The purpose of portability is to reduce the total work needed
  1728. on the compiler; it was not of interest for its own sake.
  1729. GNU CC does not contain machine dependent code, but it does contain code
  1730. that depends on machine parameters such as endianness (whether the most
  1731. significant byte has the highest or lowest address of the bytes in a word)
  1732. and the availability of autoincrement addressing. In the RTL-generation
  1733. pass, it is often necessary to have multiple strategies for generating code
  1734. for a particular kind of syntax tree, strategies that are usable for different
  1735. combinations of parameters. Often I have not tried to address all possible
  1736. cases, but only the common ones or only the ones that I have encountered.
  1737. As a result, a new target may require additional strategies. You will know
  1738. if this happens because the compiler will call @code{abort}. Fortunately,
  1739. the new strategies can be added in a machine-independent fashion, and will
  1740. affect only the target machines that need them.
  1741. @node Interface, Passes, Portability, Top
  1742. @chapter Interfacing to GNU CC Output
  1743. GNU CC is normally configured to use the same function calling convention
  1744. normally in use on the target system. This is done with the
  1745. machine-description macros described (@pxref{Machine Macros}).
  1746. However, returning of structure and union values is done differently.
  1747. As a result, functions compiled with PCC returning such types cannot
  1748. be called from code compiled with GNU CC, and vice versa. This usually
  1749. does not cause trouble because the Unix library routines don't return
  1750. structures and unions.
  1751. Structures and unions that are 1, 2, 4 or 8 bytes long are returned in the
  1752. same registers used for @code{int} or @code{double} return values. (GNU CC
  1753. typically allocates variables of such types in registers also.) Structures
  1754. and unions of other sizes are returned by storing them into an address
  1755. passed by the caller in a register. This method is faster than the one
  1756. normally used by PCC and is also reentrant. The register used for passing
  1757. the address is specified by the machine-description macro
  1758. @code{STRUCT_VALUE_REGNUM}.
  1759. GNU CC always passes arguments on the stack. At some point it will be
  1760. extended to pass arguments in registers, for machines which use that as
  1761. the standard calling convention. This will make it possible to use such
  1762. a convention on other machines as well. However, that would render it
  1763. completely incompatible with PCC. We will probably do this once we
  1764. have a complete GNU system so we can compile the libraries with GNU CC.
  1765. If you use @code{longjmp}, beware of automatic variables. ANSI C says that
  1766. automatic variables that are not declared @code{volatile} have undefined
  1767. values after a @code{longjmp}. And this is all GNU CC promises to do,
  1768. because it is very difficult to restore register variables correctly, and
  1769. one of GNU CC's features is that it can put variables in registers without
  1770. your asking it to.
  1771. If you want a variable to be unaltered by @code{longjmp}, and you don't
  1772. want to write @code{volatile} because old C compilers don't accept it,
  1773. just take the address of the variable. If a variable's address is ever
  1774. taken, even if just to compute it and ignore it, then the variable cannot
  1775. go in a register:
  1776. @example
  1777. @{
  1778. int careful;
  1779. &careful;
  1780. @dots{}
  1781. @}
  1782. @end example
  1783. Code compiled with GNU CC may call certain library routines. The routines
  1784. needed on the Vax and 68000 are in the file @file{gnulib.c}. You must
  1785. compile this file with the standard C compiler, not with GNU CC, and then
  1786. link it with each program you compile with GNU CC. (In actuality, many
  1787. programs will not need it.) The usual function call interface is used
  1788. for calling the library routines. Some standard parts of the C library,
  1789. such as @code{bcopy}, are also called automatically.
  1790. @node Passes, RTL, Interface, Top
  1791. @chapter Passes and Files of the Compiler
  1792. The overall control structure of the compiler is in @file{toplev.c}. This
  1793. file is responsible for initialization, decoding arguments, opening and
  1794. closing files, and sequencing the passes.
  1795. The parsing pass is invoked only once, to parse the entire input. The RTL
  1796. intermediate code for a function is generated as the function is parsed, a
  1797. statement at a time. Each statement is read in as a syntax tree and then
  1798. converted to RTL; then the storage for the tree for the statement is
  1799. reclaimed. Storage for types (and the expressions for their sizes),
  1800. declarations, and a representation of the binding contours and how they nest,
  1801. remains until the function is finished being compiled; these are all needed
  1802. to output the debugging information.
  1803. Each time the parsing pass reads a complete function definition or
  1804. top-level declaration, it calls the function
  1805. @code{rest_of_compilation} or @code{rest_of_decl_compilation} in
  1806. @file{toplev.c}, which are responsible for all further processing
  1807. necessary, ending with output of the assembler language. All other
  1808. compiler passes run, in sequence, within @code{rest_of_compilation}.
  1809. When that function returns from compiling a function definition, the
  1810. storage used for that function definition's compilation is entirely
  1811. freed, unless it is an inline function (@pxref{Inline}).
  1812. Here is a list of all the passes of the compiler and their source files.
  1813. Also included is a description of where debugging dumps can be requested
  1814. with @samp{-d} options.
  1815. @itemize @bullet
  1816. @item
  1817. Parsing. This pass reads the entire text of a function definition,
  1818. constructing partial syntax trees. This and RTL generation are no longer
  1819. truly separate passes (formerly they were), but it is easier to think
  1820. of them as separate.
  1821. The tree representation does not entirely follow C syntax, because it is
  1822. intended to support other languages as well.
  1823. C data type analysis is also done in this pass, and every tree node
  1824. that represents an expression has a data type attached. Variables are
  1825. represented as declaration nodes.
  1826. Constant folding and associative-law simplifications are also done
  1827. during this pass.
  1828. The source files for parsing are @file{parse.y}, @file{decl.c},
  1829. @file{typecheck.c}, @file{stor-layout.c}, @file{fold-const.c}, and
  1830. @file{tree.c}. The last three are intended to be language-independent.
  1831. There are also header files @file{parse.h}, @file{c-tree.h},
  1832. @file{tree.h} and @file{tree.def}. The last two define the format of
  1833. the tree representation.@refill
  1834. @item
  1835. RTL generation. This is the conversion of syntax tree into RTL code.
  1836. It is actually done statement-by-statement during parsing, but for
  1837. most purposes it can be thought of as a separate pass.
  1838. This is where the bulk of target-parameter-dependent code is found,
  1839. since often it is necessary for strategies to apply only when certain
  1840. standard kinds of instructions are available. The purpose of named
  1841. instruction patterns is to provide this information to the RTL
  1842. generation pass.
  1843. Optimization is done in this pass for @code{if}-conditions that are
  1844. comparisons, boolean operations or conditional expressions. Tail
  1845. recursion is detected at this time also. Decisions are made about how
  1846. best to arrange loops and how to output @code{switch} statements.
  1847. The source files for RTL generation are @file{stmt.c}, @file{expr.c},
  1848. @file{explow.c}, @file{expmed.c}, @file{optabs.c} and @file{emit-rtl.c}.
  1849. Also, the file @file{insn-emit.c}, generated from the machine description
  1850. by the program @code{genemit}, is used in this pass. The header files
  1851. @file{expr.h} is used for communication within this pass.@refill
  1852. The header files @file{insn-flags.h} and @file{insn-codes.h},
  1853. generated from the machine description by the programs @code{genflags}
  1854. and @code{gencodes}, tell this pass which standard names are available
  1855. for use and which patterns correspond to them.@refill
  1856. Aside from debugging information output, none of the following passes
  1857. refers to the tree structure representation of the function (only
  1858. part of which is saved).
  1859. The decision of whether the function can and should be expanded inline
  1860. in its subsequent callers is made at the end of rtl generation. The
  1861. function must meet certain criteria, currently related to the size of
  1862. the function and the types and number of parameters it has. Note that
  1863. this function may contain loops, recursive calls to itself
  1864. (tail-recursive functions can be inlined!), gotos, in short, all
  1865. constructs supported by GNU CC.
  1866. The option @samp{-dr} causes a debugging dump of the RTL code after
  1867. this pass. This dump file's name is made by appending @samp{.rtl} to
  1868. the input file name.
  1869. @item
  1870. Jump optimization. This pass simplifies jumps to the following
  1871. instruction, jumps across jumps, and jumps to jumps. It deletes
  1872. unreferenced labels and unreachable code, except that unreachable code
  1873. that contains a loop is not recognized as unreachable in this pass.
  1874. (Such loops are deleted later in the basic block analysis.)
  1875. Jump optimization is performed two or three times. The first time is
  1876. immediately following RTL generation. The second time is after CSE,
  1877. but only if CSE says repeated jump optimization is needed. The
  1878. last time is right before the final pass. That time, cross-jumping
  1879. and deletion of no-op move instructions are done together with the
  1880. optimizations described above.
  1881. The source file of this pass is @file{jump.c}.
  1882. The option @samp{-dj} causes a debugging dump of the RTL code after
  1883. this pass is run for the first time. This dump file's name is made by
  1884. appending @samp{.jump} to the input file name.
  1885. @item
  1886. Register scan. This pass finds the first and last use of each
  1887. register, as a guide for common subexpression elimination. Its source
  1888. is in @file{regclass.c}.
  1889. @item
  1890. Common subexpression elimination. This pass also does constant
  1891. propagation. Its source file is @file{cse.c}. If constant
  1892. propagation causes conditional jumps to become unconditional or to
  1893. become no-ops, jump optimization is run again when CSE is finished.
  1894. The option @samp{-ds} causes a debugging dump of the RTL code after
  1895. this pass. This dump file's name is made by appending @samp{.cse} to
  1896. the input file name.
  1897. @item
  1898. Loop optimization. This pass moves constant expressions out of loops.
  1899. Its source file is @file{loop.c}.
  1900. The option @samp{-dL} causes a debugging dump of the RTL code after
  1901. this pass. This dump file's name is made by appending @samp{.loop} to
  1902. the input file name.
  1903. @item
  1904. Stupid register allocation is performed at this point in a
  1905. nonoptimizing compilation. It does a little data flow analysis as
  1906. well. When stupid register allocation is in use, the next pass
  1907. executed is the reloading pass; the others in between are skipped.
  1908. The source file is @file{stupid.c}.
  1909. @item
  1910. Data flow analysis (@file{flow.c}). This pass divides the program
  1911. into basic blocks (and in the process deletes unreachable loops); then
  1912. it computes which pseudo-registers are live at each point in the
  1913. program, and makes the first instruction that uses a value point at
  1914. the instruction that computed the value.
  1915. This pass also deletes computations whose results are never used, and
  1916. combines memory references with add or subtract instructions to make
  1917. autoincrement or autodecrement addressing.
  1918. The option @samp{-df} causes a debugging dump of the RTL code after
  1919. this pass. This dump file's name is made by appending @samp{.flow} to
  1920. the input file name. If stupid register allocation is in use, this
  1921. dump file reflects the full results of such allocation.
  1922. @item
  1923. Instruction combination (@file{combine.c}). This pass attempts to
  1924. combine groups of two or three instructions that are related by data
  1925. flow into single instructions. It combines the RTL expressions for
  1926. the instructions by substitution, simplifies the result using algebra,
  1927. and then attempts to match the result against the machine description.
  1928. The option @samp{-dc} causes a debugging dump of the RTL code after
  1929. this pass. This dump file's name is made by appending @samp{.combine}
  1930. to the input file name.
  1931. @item
  1932. Register class preferencing. The RTL code is scanned to find out
  1933. which register class is best for each pseudo register. The source
  1934. file is @file{regclass.c}.
  1935. @item
  1936. Local register allocation (@file{local-alloc.c}). This pass allocates
  1937. hard registers to pseudo registers that are used only within one basic
  1938. block. Because the basic block is linear, it can use fast and
  1939. powerful techniques to do a very good job.
  1940. The option @samp{-dl} causes a debugging dump of the RTL code after
  1941. this pass. This dump file's name is made by appending @samp{.lreg} to
  1942. the input file name.
  1943. @item
  1944. Global register allocation (@file{global-alloc.c}). This pass
  1945. allocates hard registers for the remaining pseudo registers (those
  1946. whose life spans are not contained in one basic block).
  1947. @item
  1948. Reloading. This pass renumbers pseudo registers with the hardware
  1949. registers numbers they were allocated. Pseudo registers that did not
  1950. get hard registers are replaced with stack slots. Then it finds
  1951. instructions that are invalid because a value has failed to end up in
  1952. a register, or has ended up in a register of the wrong kind. It fixes
  1953. up these instructions by reloading the problematical values
  1954. temporarily into registers. Additional instructions are generated to
  1955. do the copying.
  1956. Source files are @file{reload.c} and @file{reload1.c}, plus the header
  1957. @file{reload.h} used for communication between them.
  1958. The option @samp{-dg} causes a debugging dump of the RTL code after
  1959. this pass. This dump file's name is made by appending @samp{.greg} to
  1960. the input file name.
  1961. @item
  1962. Jump optimization is repeated, this time including cross-jumping
  1963. and deletion of no-op move instructions. Machine-specific peephole
  1964. optimizations are performed at the same time.
  1965. The option @samp{-dJ} causes a debugging dump of the RTL code after
  1966. this pass. This dump file's name is made by appending @samp{.jump2}
  1967. to the input file name.
  1968. @item
  1969. Final. This pass outputs the assembler code for the function. It is
  1970. also responsible for identifying spurious test and compare
  1971. instructions. The function entry and exit sequences are generated
  1972. directly as assembler code in this pass; they never exist as RTL.
  1973. The source files are @file{final.c} plus @file{insn-output.c}; the
  1974. latter is generated automatically from the machine description by the
  1975. tool @file{genoutput}. The header file @file{conditions.h} is used
  1976. for communication between these files.
  1977. @item
  1978. Debugging information output. This is run after final because it must
  1979. output the stack slot offsets for pseudo registers that did not get
  1980. hard registers. Source files are @file{dbxout.c} for DBX symbol table
  1981. format and @file{symout.c} for GDB's own symbol table format.
  1982. @end itemize
  1983. Some additional files are used by all or many passes:
  1984. @itemize @bullet
  1985. @item
  1986. Every pass uses @file{machmode.def}, which defines the machine modes.
  1987. @item
  1988. All the passes that work with RTL use the header files @file{rtl.h}
  1989. and @file{rtl.def}, and subroutines in file @file{rtl.c}. The tools
  1990. @code{gen*} also use these files to read and work with the machine
  1991. description RTL.
  1992. @item
  1993. Several passes refer to the header file @file{insn-config.h} which
  1994. contains a few parameters (C macro definitions) generated
  1995. automatically from the machine description RTL by the tool
  1996. @code{genconfig}.
  1997. @item
  1998. Several passes use the instruction recognizer, which consists of
  1999. @file{recog.c} and @file{recog.h}, plus the files @file{insn-recog.c}
  2000. and @file{insn-extract.c} that are generated automatically from the
  2001. machine description by the tools @file{genrecog} and
  2002. @file{genextract}.@refill
  2003. @item
  2004. Several passes use the header files @file{regs.h} which defines the
  2005. information recorded about pseudo register usage, and @file{basic-block.h}
  2006. which defines the information recorded about basic blocks.
  2007. @item
  2008. @file{hard-reg-set.h} defines the type @code{HARD_REG_SET}, a bit-vector
  2009. with a bit for each hard register, and some macros to manipulate it.
  2010. This type is just @code{int} if the machine has few enough hard registers;
  2011. otherwise it is an array of @code{int} and some of the macros expand
  2012. into loops.
  2013. @end itemize
  2014. @node RTL, Machine Desc, Passes, Top
  2015. @chapter RTL Representation
  2016. Most of the work of the compiler is done on an intermediate representation
  2017. called register transfer language. In this language, the instructions to be
  2018. output are described, pretty much one by one, in an algebraic form that
  2019. describes what the instruction does.
  2020. RTL is inspired by Lisp lists. It has both an internal form, made up of
  2021. structures that point at other structures, and a textual form that is used
  2022. in the machine description and in printed debugging dumps. The textual
  2023. form uses nested parentheses to indicate the pointers in the internal form.
  2024. @menu
  2025. * RTL Objects:: Expressions vs vectors vs strings vs integers.
  2026. * Accessors:: Macros to access expression operands or vector elts.
  2027. * Flags:: Other flags in an RTL expression.
  2028. * Machine Modes:: Describing the size and format of a datum.
  2029. * Constants:: Expressions with constant values.
  2030. * Regs and Memory:: Expressions representing register contents or memory.
  2031. * Arithmetic:: Expressions representing arithmetic on other expressions.
  2032. * Comparisons:: Expressions representing comparison of expressions.
  2033. * Bit Fields:: Expressions representing bit-fields in memory or reg.
  2034. * Conversions:: Extending, truncating, floating or fixing.
  2035. * RTL Declarations:: Declaring volatility, constancy, etc.
  2036. * Side Effects:: Expressions for storing in registers, etc.
  2037. * Incdec:: Embedded side-effects for autoincrement addressing.
  2038. * Assembler:: Representing @code{asm} with operands.
  2039. * Insns:: Expression types for entire insns.
  2040. * Calls:: RTL representation of function call insns.
  2041. * Sharing:: Some expressions are unique; others *must* be copied.
  2042. @end menu
  2043. @node RTL Objects, Accessors, RTL, RTL
  2044. @section RTL Object Types
  2045. RTL uses four kinds of objects: expressions, integers, strings and vectors.
  2046. Expressions are the most important ones. An RTL expression (``RTX'', for
  2047. short) is a C structure, but it is usually referred to with a pointer; a
  2048. type that is given the typedef name @code{rtx}.
  2049. An integer is simply an @code{int}, and a string is a @code{char *}.
  2050. Within RTL code, strings appear only inside @samp{symbol_ref} expressions,
  2051. but they appear in other contexts in the RTL expressions that make up
  2052. machine descriptions. Their written form uses decimal digits.
  2053. A string is a sequence of characters. In core it is represented as a
  2054. @code{char *} in usual C fashion, and it is written in C syntax as well.
  2055. However, strings in RTL may never be null. If you write an empty string in
  2056. a machine description, it is represented in core as a null pointer rather
  2057. than as a pointer to a null character. In certain contexts, these null
  2058. pointers instead of strings are valid.
  2059. A vector contains an arbitrary, specified number of pointers to
  2060. expressions. The number of elements in the vector is explicitly present in
  2061. the vector. The written form of a vector consists of square brackets
  2062. (@samp{[@dots{}]}) surrounding the elements, in sequence and with
  2063. whitespace separating them. Vectors of length zero are not created; null
  2064. pointers are used instead.
  2065. Expressions are classified by @dfn{expression codes} (also called RTX
  2066. codes). The expression code is a name defined in @file{rtl.def}, which is
  2067. also (in upper case) a C enumeration constant. The possible expression
  2068. codes and their meanings are machine-independent. The code of an RTX can
  2069. be extracted with the macro @code{GET_CODE (@var{x})} and altered with
  2070. @code{PUT_CODE (@var{x}, @var{newcode})}.
  2071. The expression code determines how many operands the expression contains,
  2072. and what kinds of objects they are. In RTL, unlike Lisp, you cannot tell
  2073. by looking at an operand what kind of object it is. Instead, you must know
  2074. from its context---from the expression code of the containing expression.
  2075. For example, in an expression of code @samp{subreg}, the first operand is
  2076. to be regarded as an expression and the second operand as an integer. In
  2077. an expression of code @samp{plus}, there are two operands, both of which
  2078. are to be regarded as expressions. In a @samp{symbol_ref} expression,
  2079. there is one operand, which is to be regarded as a string.
  2080. Expressions are written as parentheses containing the name of the
  2081. expression type, its flags and machine mode if any, and then the operands
  2082. of the expression (separated by spaces).
  2083. Expression code names in the @samp{md} file are written in lower case,
  2084. but when they appear in C code they are written in upper case. In this
  2085. manual, they are shown as follows: @samp{const_int}.
  2086. In a few contexts a null pointer is valid where an expression is normally
  2087. wanted. The written form of this is @samp{(nil)}.
  2088. @node Accessors, Flags, RTL Objects, RTL
  2089. @section Access to Operands
  2090. For each expression type @file{rtl.def} specifies the number of contained
  2091. objects and their kinds, with four possibilities: @samp{e} for expression
  2092. (actually a pointer to an expression), @samp{i} for integer, @samp{s} for
  2093. string, and @samp{E} for vector of expressions. The sequence of letters
  2094. for an expression code is called its @dfn{format}. Thus, the format of
  2095. @samp{subreg} is @samp{ei}.@refill
  2096. Two other format characters are used occasionally: @samp{u} and @samp{0}.
  2097. @samp{u} is equivalent to @samp{e} except that it is printed differently in
  2098. debugging dumps, and @samp{0} means a slot whose contents do not fit any
  2099. normal category. @samp{0} slots are not printed at all in dumps, and are
  2100. often used in special ways by small parts of the compiler.@refill
  2101. There are macros to get the number of operands and the format of an
  2102. expression code:
  2103. @table @code
  2104. @item GET_RTX_LENGTH (@var{code})
  2105. Number of operands of an RTX of code @var{code}.
  2106. @item GET_RTX_FORMAT (@var{code})
  2107. The format of an RTX of code @var{code}, as a C string.
  2108. @end table
  2109. Operands of expressions are accessed using the macros @code{XEXP},
  2110. @code{XINT} and @code{XSTR}. Each of these macros takes two arguments: an
  2111. expression-pointer (RTX) and an operand number (counting from zero).
  2112. Thus,@refill
  2113. @example
  2114. XEXP (@var{x}, 2)
  2115. @end example
  2116. @noindent
  2117. accesses operand 2 of expression @var{x}, as an expression.
  2118. @example
  2119. XINT (@var{x}, 2)
  2120. @end example
  2121. @noindent
  2122. accesses the same operand as an integer. @code{XSTR}, used in the same
  2123. fashion, would access it as a string.
  2124. Any operand can be accessed as an integer, as an expression or as a string.
  2125. You must choose the correct method of access for the kind of value actually
  2126. stored in the operand. You would do this based on the expression code of
  2127. the containing expression. That is also how you would know how many
  2128. operands there are.
  2129. For example, if @var{x} is a @samp{subreg} expression, you know that it has
  2130. two operands which can be correctly accessed as @code{XEXP (@var{x}, 0)}
  2131. and @code{XINT (@var{x}, 1)}. If you did @code{XINT (@var{x}, 0)}, you
  2132. would get the address of the expression operand but cast as an integer;
  2133. that might occasionally be useful, but it would be cleaner to write
  2134. @code{(int) XEXP (@var{x}, 0)}. @code{XEXP (@var{x}, 1)} would also
  2135. compile without error, and would return the second, integer operand cast as
  2136. an expression pointer, which would probably result in a crash when
  2137. accessed. Nothing stops you from writing @code{XEXP (@var{x}, 28)} either,
  2138. but this will access memory past the end of the expression with
  2139. unpredictable results.@refill
  2140. Access to operands which are vectors is more complicated. You can use the
  2141. macro @code{XVEC} to get the vector-pointer itself, or the macros
  2142. @code{XVECEXP} and @code{XVECLEN} to access the elements and length of a
  2143. vector.
  2144. @table @code
  2145. @item XVEC (@var{exp}, @var{idx})
  2146. Access the vector-pointer which is operand number @var{idx} in @var{exp}.
  2147. @item XVECLEN (@var{exp}, @var{idx})
  2148. Access the length (number of elements) in the vector which is
  2149. in operand number @var{idx} in @var{exp}. This value is an @code{int}.
  2150. @item XVECEXP (@var{exp}, @var{idx}, @var{eltnum})
  2151. Access element number @var{eltnum} in the vector which is
  2152. in operand number @var{idx} in @var{exp}. This value is an RTX.
  2153. It is up to you to make sure that @var{eltnum} is not negative
  2154. and is less than @code{XVECLEN (@var{exp}, @var{idx})}.
  2155. @end table
  2156. All the macros defined in this section expand into lvalues and therefore
  2157. can be used to assign the operands, lengths and vector elements as well as
  2158. to access them.
  2159. @node Flags, Machine Modes, Accessors, RTL
  2160. @section Flags in an RTL Expression
  2161. RTL expressions contain several flags (one-bit bit-fields) that are used
  2162. in certain types of expression.
  2163. @table @code
  2164. @item used
  2165. This flag is used only momentarily, at the end of RTL generation for a
  2166. function, to count the number of times an expression appears in insns.
  2167. Expressions that appear more than once are copied, according to the
  2168. rules for shared structure (@pxref{Sharing}).
  2169. @item volatil
  2170. This flag is used in @samp{mem} and @samp{reg} expressions and in insns.
  2171. In RTL dump files, it is printed as @samp{/v}.
  2172. In a @samp{mem} expression, it is 1 if the memory reference is volatile.
  2173. Volatile memory references may not be deleted, reordered or combined.
  2174. In a @samp{reg} expression, it is 1 if the value is a user-level variable.
  2175. 0 indicates an internal compiler temporary.
  2176. In an insn, 1 means the insn has been deleted.
  2177. @item in_struct
  2178. This flag is used in @samp{mem} expressions. It is 1 if the memory
  2179. datum referred to is all or part of a structure or array; 0 if it is (or
  2180. might be) a scalar variable. A reference through a C pointer has 0
  2181. because the pointer might point to a scalar variable.
  2182. This information allows the compiler to determine something about possible
  2183. cases of aliasing.
  2184. In an RTL dump, this flag is represented as @samp{/s}.
  2185. @item unchanging
  2186. This flag is used in @samp{reg} and @samp{mem} expressions. 1 means
  2187. that the value of the expression never changes (at least within the
  2188. current function).
  2189. In an RTL dump, this flag is represented as @samp{/u}.
  2190. @end table
  2191. @node Machine Modes, Constants, Flags, RTL
  2192. @section Machine Modes
  2193. A machine mode describes a size of data object and the representation used
  2194. for it. In the C code, machine modes are represented by an enumeration
  2195. type, @code{enum machine_mode}, defined in @file{machmode.def}. Each RTL
  2196. expression has room for a machine mode and so do certain kinds of tree
  2197. expressions (declarations and types, to be precise).
  2198. In debugging dumps and machine descriptions, the machine mode of an RTL
  2199. expression is written after the expression code with a colon to separate
  2200. them. The letters @samp{mode} which appear at the end of each machine mode
  2201. name are omitted. For example, @code{(reg:SI 38)} is a @samp{reg}
  2202. expression with machine mode @code{SImode}. If the mode is
  2203. @code{VOIDmode}, it is not written at all.
  2204. Here is a table of machine modes.
  2205. @table @code
  2206. @item QImode
  2207. ``Quarter-Integer'' mode represents a single byte treated as an integer.
  2208. @item HImode
  2209. ``Half-Integer'' mode represents a two-byte integer.
  2210. @item SImode
  2211. ``Single Integer'' mode represents a four-byte integer.
  2212. @item DImode
  2213. ``Double Integer'' mode represents an eight-byte integer.
  2214. @item TImode
  2215. ``Tetra Integer'' (?) mode represents a sixteen-byte integer.
  2216. @item SFmode
  2217. ``Single Floating'' mode represents a single-precision (four byte) floating
  2218. point number.
  2219. @item DFmode
  2220. ``Double Floating'' mode represents a double-precision (eight byte) floating
  2221. point number.
  2222. @item TFmode
  2223. ``Tetra Floating'' mode represents a quadruple-precision (sixteen byte)
  2224. floating point number.
  2225. @item BLKmode
  2226. ``Block'' mode represents values that are aggregates to which none of
  2227. the other modes apply. In RTL, only memory references can have this mode,
  2228. and only if they appear in string-move or vector instructions. On machines
  2229. which have no such instructions, @code{BLKmode} will not appear in RTL.
  2230. @item VOIDmode
  2231. Void mode means the absence of a mode or an unspecified mode.
  2232. For example, RTL expressions of code @samp{const_int} have mode
  2233. @code{VOIDmode} because they can be taken to have whatever mode the context
  2234. requires. In debugging dumps of RTL, @code{VOIDmode} is expressed by
  2235. the absence of any mode.
  2236. @item EPmode
  2237. ``Entry Pointer'' mode is intended to be used for function variables in
  2238. Pascal and other block structured languages. Such values contain
  2239. both a function address and a static chain pointer for access to
  2240. automatic variables of outer levels. This mode is only partially
  2241. implemented since C does not use it.
  2242. @item CSImode@r{, @dots{}}
  2243. ``Complex Single Integer'' mode stands for a complex number represented
  2244. as a pair of @code{SImode} integers. Any of the integer and floating modes
  2245. may have @samp{C} prefixed to its name to obtain a complex number mode.
  2246. For example, there are @code{CQImode}, @code{CSFmode}, and @code{CDFmode}.
  2247. Since C does not support complex numbers, these machine modes are only
  2248. partially implemented.
  2249. @item BImode
  2250. This is the machine mode of a bit-field in a structure. It is used
  2251. only in the syntax tree, never in RTL, and in the syntax tree it appears
  2252. only in declaration nodes. In C, it appears only in @code{FIELD_DECL}
  2253. nodes for structure fields defined with a bit size.
  2254. @end table
  2255. The machine description defines @code{Pmode} as a C macro which expands
  2256. into the machine mode used for addresses. Normally this is @code{SImode}.
  2257. The only modes which a machine description @i{must} support are
  2258. @code{QImode}, @code{SImode}, @code{SFmode} and @code{DFmode}. The
  2259. compiler will attempt to use @code{DImode} for two-word structures and
  2260. unions, but it would not be hard to program it to avoid this. Likewise,
  2261. you can arrange for the C type @code{short int} to avoid using
  2262. @code{HImode}. In the long term it would be desirable to make the set of
  2263. available machine modes machine-dependent and eliminate all assumptions
  2264. about specific machine modes or their uses from the machine-independent
  2265. code of the compiler.
  2266. Here are some C macros that relate to machine modes:
  2267. @table @code
  2268. @item GET_MODE (@var{x})
  2269. Returns the machine mode of the RTX @var{x}.
  2270. @item PUT_MODE (@var{x}, @var{newmode})
  2271. Alters the machine mode of the RTX @var{x} to be @var{newmode}.
  2272. @item GET_MODE_SIZE (@var{m})
  2273. Returns the size in bytes of a datum of mode @var{m}.
  2274. @item GET_MODE_BITSIZE (@var{m})
  2275. Returns the size in bits of a datum of mode @var{m}.
  2276. @item GET_MODE_UNIT_SIZE (@var{m})
  2277. Returns the size in bits of the subunits of a datum of mode @var{m}.
  2278. This is the same as @code{GET_MODE_SIZE} except in the case of
  2279. complex modes and @code{EPmode}. For them, the unit size is the
  2280. size of the real or imaginary part, or the size of the function
  2281. pointer or the context pointer.
  2282. @end table
  2283. @node Constants, Regs and Memory, Machine Modes, RTL
  2284. @section Constant Expression Types
  2285. The simplest RTL expressions are those that represent constant values.
  2286. @table @code
  2287. @item (const_int @var{i})
  2288. This type of expression represents the integer value @var{i}. @var{i}
  2289. is customarily accessed with the macro @code{INTVAL} as in
  2290. @code{INTVAL (@var{exp})}, which is equivalent to @code{XINT (@var{exp}, 0)}.
  2291. There is only one expression object for the integer value zero;
  2292. it is the value of the variable @code{const0_rtx}. Likewise, the
  2293. only expression for integer value one is found in @code{const1_rtx}.
  2294. Any attempt to create an expression of code @samp{const_int} and
  2295. value zero or one will return @code{const0_rtx} or @code{const1_rtx}
  2296. as appropriate.
  2297. @item (const_double:@var{m} @var{i0} @var{i1})
  2298. Represents a floating point constant value of mode @var{m}. The two
  2299. integers @var{i0} and @var{i1} together contain the bits of a
  2300. @code{double} value. To convert them to a @code{double}, do
  2301. @example
  2302. union @{ double d; int i[2];@} u;
  2303. u.i[0] = XINT (x, 0);
  2304. u.i[1] = XINT (x, 1);
  2305. @end example
  2306. @noindent
  2307. and then refer to @code{u.d}. The value of the constant is
  2308. represented as a double in this fashion even if the value represented
  2309. is single-precision.
  2310. The global variables @code{dconst0_rtx} and @code{fconst0_rtx} hold
  2311. @samp{const_double} expressions with value 0, in modes @code{DFmode} and
  2312. @code{SFmode}, respectively.
  2313. @item (symbol_ref @var{symbol})
  2314. Represents the value of an assembler label for data. @var{symbol} is
  2315. a string that describes the name of the assembler label. If it starts
  2316. with a @samp{*}, the label is the rest of @var{symbol} not including
  2317. the @samp{*}. Otherwise, the label is @var{symbol}, prefixed with
  2318. @samp{_}.
  2319. @item (label_ref @var{label})
  2320. Represents the value of an assembler label for code. It contains one
  2321. operand, an expression, which must be a @samp{code_label} that appears
  2322. in the instruction sequence to identify the place where the label
  2323. should go.
  2324. The reason for using a distinct expression type for code label
  2325. references is so that jump optimization can distinguish them.
  2326. @item (const @var{exp})
  2327. Represents a constant that is the result of an assembly-time
  2328. arithmetic computation. The operand, @var{exp}, is an expression that
  2329. contains only constants (@samp{const_int}, @samp{symbol_ref} and
  2330. @samp{label_ref} expressions) combined with @samp{plus} and
  2331. @samp{minus}. However, not all combinations are valid, since the
  2332. assembler cannot do arbitrary arithmetic on relocatable symbols.
  2333. @end table
  2334. @node Regs and Memory, Arithmetic, Constants, RTL
  2335. @section Registers and Memory
  2336. Here are the RTL expression types for describing access to machine
  2337. registers and to main memory.
  2338. @table @code
  2339. @item (reg:@var{m} @var{n})
  2340. For small values of the integer @var{n} (less than
  2341. @code{FIRST_PSEUDO_REGISTER}), this stands for a reference to machine
  2342. register number @var{n}: a @dfn{hard register}. For larger values of
  2343. @var{n}, it stands for a temporary value or @dfn{pseudo register}.
  2344. The compiler's strategy is to generate code assuming an unlimited
  2345. number of such pseudo registers, and later convert them into hard
  2346. registers or into memory references.
  2347. The symbol @code{FIRST_PSEUDO_REGISTER} is defined by the machine
  2348. description, since the number of hard registers on the machine is an
  2349. invariant characteristic of the machine. Note, however, that not
  2350. all of the machine registers must be general registers. All the
  2351. machine registers that can be used for storage of data are given
  2352. hard register numbers, even those that can be used only in certain
  2353. instructions or can hold only certain types of data.
  2354. Each pseudo register number used in a function's RTL code is
  2355. represented by a unique @samp{reg} expression.
  2356. @var{m} is the machine mode of the reference. It is necessary because
  2357. machines can generally refer to each register in more than one mode.
  2358. For example, a register may contain a full word but there may be
  2359. instructions to refer to it as a half word or as a single byte, as
  2360. well as instructions to refer to it as a floating point number of
  2361. various precisions.
  2362. Even for a register that the machine can access in only one mode,
  2363. the mode must always be specified.
  2364. A hard register may be accessed in various modes throughout one
  2365. function, but each pseudo register is given a natural mode
  2366. and is accessed only in that mode. When it is necessary to describe
  2367. an access to a pseudo register using a nonnatural mode, a @samp{subreg}
  2368. expression is used.
  2369. A @samp{reg} expression with a machine mode that specifies more than
  2370. one word of data may actually stand for several consecutive registers.
  2371. If in addition the register number specifies a hardware register, then
  2372. it actually represents several consecutive hardware registers starting
  2373. with the specified one.
  2374. Such multi-word hardware register @samp{reg} expressions may not be live
  2375. across the boundary of a basic block. The lifetime analysis pass does not
  2376. know how to record properly that several consecutive registers are
  2377. actually live there, and therefore register allocation would be confused.
  2378. The CSE pass must go out of its way to make sure the situation does
  2379. not arise.
  2380. @item (subreg:@var{m} @var{reg} @var{wordnum})
  2381. @samp{subreg} expressions are used to refer to a register in a machine
  2382. mode other than its natural one, or to refer to one register of
  2383. a multi-word @samp{reg} that actually refers to several registers.
  2384. Each pseudo-register has a natural mode. If it is necessary to
  2385. operate on it in a different mode---for example, to perform a fullword
  2386. move instruction on a pseudo-register that contains a single byte---
  2387. the pseudo-register must be enclosed in a @samp{subreg}. In such
  2388. a case, @var{wordnum} is zero.
  2389. The other use of @samp{subreg} is to extract the individual registers
  2390. of a multi-register value. Machine modes such as @code{DImode} and
  2391. @code{EPmode} indicate values longer than a word, values which usually
  2392. require two consecutive registers. To access one of the registers,
  2393. use a @samp{subreg} with mode @code{SImode} and a @var{wordnum} that
  2394. says which register.
  2395. The compilation parameter @code{WORDS_BIG_ENDIAN}, if defined, says
  2396. that word number zero is the most significant part; otherwise, it is
  2397. the least significant part.
  2398. Note that it is not valid to access a @code{DFmode} value in @code{SFmode}
  2399. using a @samp{subreg}. On some machines the most significant part of a
  2400. @code{DFmode} value does not have the same format as a single-precision
  2401. floating value.
  2402. @item (cc0)
  2403. This refers to the machine's condition code register. It has no
  2404. operands and may not have a machine mode. It may be validly used in
  2405. only two contexts: as the destination of an assignment (in test and
  2406. compare instructions) and in comparison operators comparing against
  2407. zero (@samp{const_int} with value zero; that is to say,
  2408. @code{const0_rtx}).
  2409. There is only one expression object of code @samp{cc0}; it is the
  2410. value of the variable @code{cc0_rtx}. Any attempt to create an
  2411. expression of code @samp{cc0} will return @code{cc0_rtx}.
  2412. One special thing about the condition code register is that
  2413. instructions can set it implicitly. On many machines, nearly all
  2414. instructions set the condition code based on the value that they
  2415. compute or store. It is not necessary to record these actions
  2416. explicitly in the RTL because the machine description includes a
  2417. prescription for recognizing the instructions that do so (by means of
  2418. the macro @code{NOTICE_UPDATE_CC}). Only instructions whose sole
  2419. purpose is to set the condition code, and instructions that use the
  2420. condition code, need mention @code{(cc0)}.
  2421. @item (pc)
  2422. This represents the machine's program counter. It has no operands and
  2423. may not have a machine mode. @code{(pc)} may be validly used only in
  2424. certain specific contexts in jump instructions.
  2425. There is only one expression object of code @samp{pc}; it is the value
  2426. of the variable @code{pc_rtx}. Any attempt to create an expression of
  2427. code @samp{pc} will return @code{pc_rtx}.
  2428. All instructions that do not jump alter the program counter implicitly
  2429. by incrementing it, but there is no need to mention this in the RTL.
  2430. @item (mem:@var{m} @var{addr})
  2431. This RTX represents a reference to main memory at an address
  2432. represented by the expression @var{addr}. @var{m} specifies how large
  2433. a unit of memory is accessed.
  2434. @end table
  2435. @node Arithmetic, Comparisons, Regs and Memory, RTL
  2436. @section RTL Expressions for Arithmetic
  2437. @table @code
  2438. @item (plus:@var{m} @var{x} @var{y})
  2439. Represents the sum of the values represented by @var{x} and @var{y}
  2440. carried out in machine mode @var{m}. This is valid only if
  2441. @var{x} and @var{y} both are valid for mode @var{m}.
  2442. @item (minus:@var{m} @var{x} @var{y})
  2443. Like @samp{plus} but represents subtraction.
  2444. @item (minus @var{x} @var{y})
  2445. Represents the result of subtracting @var{y} from @var{x}
  2446. for purposes of comparison. The absence of a machine mode
  2447. in the @samp{minus} expression indicates that the result is
  2448. computed without overflow, as if with infinite precision.
  2449. Of course, machines can't really subtract with infinite precision.
  2450. However, they can pretend to do so when only the sign of the
  2451. result will be used, which is the case when the result is stored
  2452. in @code{(cc0)}. And that is the only way this kind of expression
  2453. may validly be used: as a value to be stored in the condition codes.
  2454. @item (neg:@var{m} @var{x})
  2455. Represents the negation (subtraction from zero) of the value
  2456. represented by @var{x}, carried out in mode @var{m}. @var{x} must be
  2457. valid for mode @var{m}.
  2458. @item (mult:@var{m} @var{x} @var{y})
  2459. Represents the signed product of the values represented by @var{x} and
  2460. @var{y} carried out in machine mode @var{m}. If
  2461. @var{x} and @var{y} are both valid for mode @var{m}, this is ordinary
  2462. size-preserving multiplication. Alternatively, both @var{x} and @var{y}
  2463. may be valid for a different, narrower mode. This represents the
  2464. kind of multiplication that generates a product wider than the operands.
  2465. Widening multiplication and same-size multiplication are completely
  2466. distinct and supported by different machine instructions; machines may
  2467. support one but not the other.@refill
  2468. @samp{mult} may be used for floating point division as well.
  2469. Then @var{m} is a floating point machine mode.
  2470. @item (umult:@var{m} @var{x} @var{y})
  2471. Like @samp{mult} but represents unsigned multiplication. It may be
  2472. used in both same-size and widening forms, like @samp{mult}.
  2473. @samp{umult} is used only for fixed-point multiplication.
  2474. @item (div:@var{m} @var{x} @var{y})
  2475. Represents the quotient in signed division of @var{x} by @var{y},
  2476. carried out in machine mode @var{m}. If @var{m} is a floating-point
  2477. mode, it represents the exact quotient; otherwise, the integerized
  2478. quotient. If @var{x} and @var{y} are both valid for mode @var{m},
  2479. this is ordinary size-preserving division. Some machines have
  2480. division instructions in which the operands and quotient widths are
  2481. not all the same; such instructions are represented by @samp{div}
  2482. expressions in which the machine modes are not all the same.
  2483. @item (udiv:@var{m} @var{x} @var{y})
  2484. Like @samp{div} but represents unsigned division.
  2485. @item (mod:@var{m} @var{x} @var{y})
  2486. @itemx (umod:@var{m} @var{x} @var{y})
  2487. Like @samp{div} and @samp{udiv} but represent the remainder instead of
  2488. the quotient.
  2489. @item (not:@var{m} @var{x})
  2490. Represents the bitwise complement of the value represented by @var{x},
  2491. carried out in mode @var{m}, which must be a fixed-point machine mode.
  2492. @var{x} must be valid for mode @var{m}, which must be a fixed-point mode.
  2493. @item (and:@var{m} @var{x} @var{y})
  2494. Represents the bitwise logical-and of the values represented by
  2495. @var{x} and @var{y}, carried out in machine mode @var{m}. This is
  2496. valid only if @var{x} and @var{y} both are valid for mode @var{m},
  2497. which must be a fixed-point mode.
  2498. @item (ior:@var{m} @var{x} @var{y})
  2499. Represents the bitwise inclusive-or of the values represented by
  2500. @var{x} and @var{y}, carried out in machine mode @var{m}. This is
  2501. valid only if @var{x} and @var{y} both are valid for mode @var{m},
  2502. which must be a fixed-point mode.
  2503. @item (xor:@var{m} @var{x} @var{y})
  2504. Represents the bitwise exclusive-or of the values represented by
  2505. @var{x} and @var{y}, carried out in machine mode @var{m}. This is
  2506. valid only if @var{x} and @var{y} both are valid for mode @var{m},
  2507. which must be a fixed-point mode.
  2508. @item (lshift:@var{m} @var{x} @var{c})
  2509. Represents the result of logically shifting @var{x} left by @var{c}
  2510. places. @var{x} must be valid for the mode @var{m}, a fixed-point
  2511. machine mode. @var{c} must be valid for a fixed-point mode;
  2512. which mode is determined by the mode called for in the machine
  2513. description entry for the left-shift instruction. For example,
  2514. on the Vax, the mode of @var{c} is @code{QImode} regardless of @var{m}.
  2515. On some machines, negative values of @var{c} may be meaningful; this
  2516. is why logical left shift and arithmetic left shift are distinguished.
  2517. For example, Vaxes have no right-shift instructions, and right shifts
  2518. are represented as left-shift instructions whose counts happen
  2519. to be negative constants or else computed (in a previous instruction)
  2520. by negation.
  2521. @item (ashift:@var{m} @var{x} @var{c})
  2522. Like @samp{lshift} but for arithmetic left shift.
  2523. @item (lshiftrt:@var{m} @var{x} @var{c})
  2524. @itemx (ashiftrt:@var{m} @var{x} @var{c})
  2525. Like @samp{lshift} and @samp{ashift} but for right shift.
  2526. @item (rotate:@var{m} @var{x} @var{c})
  2527. @itemx (rotatert:@var{m} @var{x} @var{c})
  2528. Similar but represent left and right rotate.
  2529. @item (abs:@var{m} @var{x})
  2530. Represents the absolute value of @var{x}, computed in mode @var{m}.
  2531. @var{x} must be valid for @var{m}.
  2532. @item (sqrt:@var{m} @var{x})
  2533. Represents the square root of @var{x}, computed in mode @var{m}.
  2534. @var{x} must be valid for @var{m}. Most often @var{m} will be
  2535. a floating point mode.
  2536. @item (ffs:@var{m} @var{x})
  2537. Represents the one plus the index of the least significant 1-bit in
  2538. @var{x}, represented as an integer of mode @var{m}. (The value is
  2539. zero if @var{x} is zero.) The mode of @var{x} need not be @var{m};
  2540. depending on the target machine, various mode combinations may be
  2541. valid.
  2542. @end table
  2543. @node Comparisons, Bit Fields, Arithmetic, RTL
  2544. @section Comparison Operations
  2545. Comparison operators test a relation on two operands and are considered to
  2546. represent the value 1 if the relation holds, or zero if it does not. The
  2547. mode of the comparison is determined by the operands; they must both be
  2548. valid for a common machine mode. A comparison with both operands constant
  2549. would be invalid as the machine mode could not be deduced from it, but such
  2550. a comparison should never exist in RTL due to constant folding.
  2551. Inequality comparisons come in two flavors, signed and unsigned. Thus,
  2552. there are distinct expression codes @samp{gt} and @samp{gtu} for signed and
  2553. unsigned greater-than. These can produce different results for the same
  2554. pair of integer values: for example, 1 is signed greater-than -1 but not
  2555. unsigned greater-than, because -1 when regarded as unsigned is actually
  2556. @code{0xffffffff} which is greater than 1.
  2557. The signed comparisons are also used for floating point values. Floating
  2558. point comparisons are distinguished by the machine modes of the operands.
  2559. The comparison operators may be used to compare the condition codes
  2560. @code{(cc0)} against zero, as in @code{(eq (cc0) (const_int 0))}. Such a
  2561. construct actually refers to the result of the preceding instruction in
  2562. which the condition codes were set. The above example stands for 1 if the
  2563. condition codes were set to say ``zero'' or ``equal'', 0 otherwise.
  2564. Although the same comparison operators are used for this as may be used in
  2565. other contexts on actual data, no confusion can result since the machine
  2566. description would never allow both kinds of uses in the same context.
  2567. @table @code
  2568. @item (eq @var{x} @var{y})
  2569. 1 if the values represented by @var{x} and @var{y} are equal,
  2570. otherwise 0.
  2571. @item (ne @var{x} @var{y})
  2572. 1 if the values represented by @var{x} and @var{y} are not equal,
  2573. otherwise 0.
  2574. @item (gt @var{x} @var{y})
  2575. 1 if the @var{x} is greater than @var{y}. If they are fixed-point,
  2576. the comparison is done in a signed sense.
  2577. @item (gtu @var{x} @var{y})
  2578. Like @samp{gt} but does unsigned comparison, on fixed-point numbers only.
  2579. @item (lt @var{x} @var{y})
  2580. @item (ltu @var{x} @var{y})
  2581. Like @samp{gt} and @samp{gtu} but test for ``less than''.
  2582. @item (ge @var{x} @var{y})
  2583. @item (geu @var{x} @var{y})
  2584. Like @samp{gt} and @samp{gtu} but test for ``greater than or equal''.
  2585. @item (le @var{x} @var{y})
  2586. @item (leu @var{x} @var{y})
  2587. Like @samp{gt} and @samp{gtu} but test for ``less than or equal''.
  2588. @item (if_then_else @var{cond} @var{then} @var{else})
  2589. This is not a comparison operation but is listed here because it is
  2590. always used in conjunction with a comparison operation. To be
  2591. precise, @var{cond} is a comparison expression. This expression
  2592. represents a choice, according to @var{cond}, between the value
  2593. represented by @var{then} and the one represented by @var{else}.
  2594. On most machines, @samp{if_then_else} expressions are valid only
  2595. to express conditional jumps.
  2596. @end table
  2597. @node Bit Fields, Conversions, Comparisons, RTL
  2598. @section Bit-fields
  2599. Special expression codes exist to represent bit-field instructions.
  2600. These types of expressions are lvalues in RTL; they may appear
  2601. on the left side of a assignment, indicating insertion of a value
  2602. into the specified bit field.
  2603. @table @code
  2604. @item (sign_extract:SI @var{loc} @var{size} @var{pos})
  2605. This represents a reference to a sign-extended bit-field contained or
  2606. starting in @var{loc} (a memory or register reference). The bit field
  2607. is @var{size} bits wide and starts at bit @var{pos}. The compilation
  2608. option @code{BITS_BIG_ENDIAN} says which end of the memory unit
  2609. @var{pos} counts from.
  2610. Which machine modes are valid for @var{loc} depends on the machine,
  2611. but typically @var{loc} should be a single byte when in memory
  2612. or a full word in a register.
  2613. @item (zero_extract:SI @var{loc} @var{size} @var{pos})
  2614. Like @samp{sign_extract} but refers to an unsigned or zero-extended
  2615. bit field. The same sequence of bits are extracted, but they
  2616. are filled to an entire word with zeros instead of by sign-extension.
  2617. @end table
  2618. @node Conversions, RTL Declarations, Bit Fields, RTL
  2619. @section Conversions
  2620. All conversions between machine modes must be represented by
  2621. explicit conversion operations. For example, an expression
  2622. which is the sum of a byte and a full word cannot be written as
  2623. @code{(plus:SI (reg:QI 34) (reg:SI 80))} because the @samp{plus}
  2624. operation requires two operands of the same machine mode.
  2625. Therefore, the byte-sized operand is enclosed in a conversion
  2626. operation, as in
  2627. @example
  2628. (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
  2629. @end example
  2630. The conversion operation is not a mere placeholder, because there
  2631. may be more than one way of converting from a given starting mode
  2632. to the desired final mode. The conversion operation code says how
  2633. to do it.
  2634. @table @code
  2635. @item (sign_extend:@var{m} @var{x})
  2636. Represents the result of sign-extending the value @var{x}
  2637. to machine mode @var{m}. @var{m} must be a fixed-point mode
  2638. and @var{x} a fixed-point value of a mode narrower than @var{m}.
  2639. @item (zero_extend:@var{m} @var{x})
  2640. Represents the result of zero-extending the value @var{x}
  2641. to machine mode @var{m}. @var{m} must be a fixed-point mode
  2642. and @var{x} a fixed-point value of a mode narrower than @var{m}.
  2643. @item (float_extend:@var{m} @var{x})
  2644. Represents the result of extending the value @var{x}
  2645. to machine mode @var{m}. @var{m} must be a floating point mode
  2646. and @var{x} a floating point value of a mode narrower than @var{m}.
  2647. @item (truncate:@var{m} @var{x})
  2648. Represents the result of truncating the value @var{x}
  2649. to machine mode @var{m}. @var{m} must be a fixed-point mode
  2650. and @var{x} a fixed-point value of a mode wider than @var{m}.
  2651. @item (float_truncate:@var{m} @var{x})
  2652. Represents the result of truncating the value @var{x}
  2653. to machine mode @var{m}. @var{m} must be a floating point mode
  2654. and @var{x} a floating point value of a mode wider than @var{m}.
  2655. @item (float:@var{m} @var{x})
  2656. Represents the result of converting fixed point value @var{x},
  2657. regarded as signed, to floating point mode @var{m}.
  2658. @item (unsigned_float:@var{m} @var{x})
  2659. Represents the result of converting fixed point value @var{x},
  2660. regarded as unsigned, to floating point mode @var{m}.
  2661. @item (fix:@var{m} @var{x})
  2662. When @var{m} is a fixed point mode, represents the result of
  2663. converting floating point value @var{x} to mode @var{m}, regarded as
  2664. signed. How rounding is done is not specified, so this operation may
  2665. be used validly in compiling C code only for integer-valued operands.
  2666. @item (unsigned_fix:@var{m} @var{x})
  2667. Represents the result of converting floating point value @var{x} to
  2668. fixed point mode @var{m}, regarded as unsigned. How rounding is done
  2669. is not specified.
  2670. @item (fix:@var{m} @var{x})
  2671. When @var{m} is a floating point mode, represents the result of
  2672. converting floating point value @var{x} (valid for mode @var{m}) to an
  2673. integer, still represented in floating point mode @var{m}, by rounding
  2674. towards zero.
  2675. @end table
  2676. @node RTL Declarations, Side Effects, Conversions, RTL
  2677. @section Declarations
  2678. Declaration expression codes do not represent arithmetic operations
  2679. but rather state assertions about their operands.
  2680. @table @code
  2681. @item (strict_low_part (subreg:@var{m} (reg:@var{n} @var{r}) 0))
  2682. This expression code is used in only one context: operand 0 of a
  2683. @samp{set} expression. In addition, the operand of this expression
  2684. must be a @samp{subreg} expression.
  2685. The presence of @samp{strict_low_part} says that the part of the
  2686. register which is meaningful in mode @var{n}, but is not part of
  2687. mode @var{m}, is not to be altered. Normally, an assignment to such
  2688. a subreg is allowed to have undefined effects on the rest of the
  2689. register when @var{m} is less than a word.
  2690. @end table
  2691. @node Side Effects, Incdec, RTL Declarations, RTL
  2692. @section Side Effect Expressions
  2693. The expression codes described so far represent values, not actions.
  2694. But machine instructions never produce values; they are meaningful
  2695. only for their side effects on the state of the machine. Special
  2696. expression codes are used to represent side effects.
  2697. The body of an instruction is always one of these side effect codes;
  2698. the codes described above, which represent values, appear only as
  2699. the operands of these.
  2700. @table @code
  2701. @item (set @var{lval} @var{x})
  2702. Represents the action of storing the value of @var{x} into the place
  2703. represented by @var{lval}. @var{lval} must be an expression
  2704. representing a place that can be stored in: @samp{reg} (or
  2705. @samp{subreg} or @samp{strict_low_part}), @samp{mem}, @samp{pc} or
  2706. @samp{cc0}.@refill
  2707. If @var{lval} is a @samp{reg}, @samp{subreg} or @samp{mem}, it has a
  2708. machine mode; then @var{x} must be valid for that mode.@refill
  2709. If @var{lval} is a @samp{reg} whose machine mode is less than the full
  2710. width of the register, then it means that the part of the register
  2711. specified by the machine mode is given the specified value and the
  2712. rest of the register receives an undefined value. Likewise, if
  2713. @var{lval} is a @samp{subreg} whose machine mode is narrower than
  2714. @code{SImode}, the rest of the register can be changed in an undefined way.
  2715. If @var{lval} is a @samp{strict_low_part} of a @samp{subreg}, then the
  2716. part of the register specified by the machine mode of the
  2717. @samp{subreg} is given the value @var{x} and the rest of the register
  2718. is not changed.@refill
  2719. If @var{lval} is @code{(cc0)}, it has no machine mode, and @var{x} may
  2720. have any mode. This represents a ``test'' or ``compare'' instruction.@refill
  2721. If @var{lval} is @code{(pc)}, we have a jump instruction, and the
  2722. possibilities for @var{x} are very limited. It may be a
  2723. @samp{label_ref} expression (unconditional jump). It may be an
  2724. @samp{if_then_else} (conditional jump), in which case either the
  2725. second or the third operand must be @code{(pc)} (for the case which
  2726. does not jump) and the other of the two must be a @samp{label_ref}
  2727. (for the case which does jump). @var{x} may also be a @samp{mem} or
  2728. @code{(plus:SI (pc) @var{y})}, where @var{y} may be a @samp{reg} or a
  2729. @samp{mem}; these unusual patterns are used to represent jumps through
  2730. branch tables.@refill
  2731. @item (return)
  2732. Represents a return from the current function, on machines where this
  2733. can be done with one instruction, such as Vaxes. On machines where a
  2734. multi-instruction ``epilogue'' must be executed in order to return
  2735. from the function, returning is done by jumping to a label which
  2736. precedes the epilogue, and the @samp{return} expression code is never
  2737. used.
  2738. @item (call @var{function} @var{nargs})
  2739. Represents a function call. @var{function} is a @samp{mem} expression
  2740. whose address is the address of the function to be called. @var{nargs}
  2741. is an expression representing the number of words of argument.
  2742. Each machine has a standard machine mode which @var{function} must
  2743. have. The machine description defines macro @code{FUNCTION_MODE} to
  2744. expand into the requisite mode name. The purpose of this mode is to
  2745. specify what kind of addressing is allowed, on machines where the
  2746. allowed kinds of addressing depend on the machine mode being
  2747. addressed.
  2748. @item (clobber @var{x})
  2749. Represents the storing or possible storing of an unpredictable,
  2750. undescribed value into @var{x}, which must be a @samp{reg} or
  2751. @samp{mem} expression.
  2752. One place this is used is in string instructions that store standard
  2753. values into particular hard registers. It may not be worth the
  2754. trouble to describe the values that are stored, but it is essential to
  2755. inform the compiler that the registers will be altered, lest it
  2756. attempt to keep data in them across the string instruction.
  2757. @var{x} may also be null---a null C pointer, no expression at all.
  2758. Such a @code{(clobber (null))} expression means that all memory
  2759. locations must be presumed clobbered.
  2760. Note that the machine description classifies certain hard registers as
  2761. ``call-clobbered''. All function call instructions are assumed by
  2762. default to clobber these registers, so there is no need to use
  2763. @samp{clobber} expressions to indicate this fact. Also, each function
  2764. call is assumed to have the potential to alter any memory location.
  2765. @item (use @var{x})
  2766. Represents the use of the value of @var{x}. It indicates that the
  2767. value in @var{x} at this point in the program is needed, even though
  2768. it may not be apparent why this is so. Therefore, the compiler will
  2769. not attempt to delete instructions whose only effect is to store a
  2770. value in @var{x}. @var{x} must be a @samp{reg} expression.
  2771. @item (parallel [@var{x0} @var{x1} @dots{}])
  2772. Represents several side effects performed in parallel. The square
  2773. brackets stand for a vector; the operand of @samp{parallel} is a
  2774. vector of expressions. @var{x0}, @var{x1} and so on are individual
  2775. side effects---expressions of code @samp{set}, @samp{call},
  2776. @samp{return}, @samp{clobber} or @samp{use}.@refill
  2777. ``In parallel'' means that first all the values used in the individual
  2778. side-effects are computed, and second all the actual side-effects are
  2779. performed. For example,
  2780. @example
  2781. (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
  2782. (set (mem:SI (reg:SI 1)) (reg:SI 1))])
  2783. @end example
  2784. @noindent
  2785. says unambiguously that the values of hard register 1 and the memory
  2786. location addressed by it are interchanged. In both places where
  2787. @code{(reg:SI 1)} appears as a memory address it refers to the value
  2788. in register 1 @emph{before} the execution of the instruction.
  2789. @item (sequence [@var{insns} @dots{}])
  2790. Represents a sequence of insns. Each of the @var{insns} that appears
  2791. in the vector is suitable for appearing in the chain of insns, so it
  2792. must be an @samp{insn}, @samp{jump_insn}, @samp{call_insn},
  2793. @samp{code_label}, @samp{barrier} or @samp{note}.
  2794. A @samp{sequence} RTX never appears in an actual insn. It represents
  2795. the sequence of insns that result from a @samp{define_expand}
  2796. @emph{before} those insns are passed to @code{emit_insn} to insert
  2797. them in the chain of insns. When actually inserted, the individual
  2798. sub-insns are separated out and the @samp{sequence} is forgotten.
  2799. @end table
  2800. Three expression codes appear in place of a side effect, as the body of an
  2801. insn, though strictly speaking they do not describe side effects as such:
  2802. @table @code
  2803. @item (asm_input @var{s})
  2804. Represents literal assembler code as described by the string @var{s}.
  2805. @item (addr_vec:@var{m} [@var{lr0} @var{lr1} @dots{}])
  2806. Represents a table of jump addresses. The vector elements @var{lr0},
  2807. etc., are @samp{label_ref} expressions. The mode @var{m} specifies
  2808. how much space is given to each address; normally @var{m} would be
  2809. @code{Pmode}.
  2810. @item (addr_diff_vec:@var{m} @var{base} [@var{lr0} @var{lr1} @dots{}])
  2811. Represents a table of jump addresses expressed as offsets from
  2812. @var{base}. The vector elements @var{lr0}, etc., are @samp{label_ref}
  2813. expressions and so is @var{base}. The mode @var{m} specifies how much
  2814. space is given to each address-difference.@refill
  2815. @end table
  2816. @node Incdec, Assembler, Side Effects, RTL
  2817. @section Embedded Side-Effects on Addresses
  2818. Four special side-effect expression codes appear as memory addresses.
  2819. @table @code
  2820. @item (pre_dec:@var{m} @var{x})
  2821. Represents the side effect of decrementing @var{x} by a standard
  2822. amount and represents also the value that @var{x} has after being
  2823. decremented. @var{x} must be a @samp{reg} or @samp{mem}, but most
  2824. machines allow only a @samp{reg}. @var{m} must be the machine mode
  2825. for pointers on the machine in use. The amount @var{x} is decremented
  2826. by is the length in bytes of the machine mode of the containing memory
  2827. reference of which this expression serves as the address. Here is an
  2828. example of its use:@refill
  2829. @example
  2830. (mem:DF (pre_dec:SI (reg:SI 39)))
  2831. @end example
  2832. @noindent
  2833. This says to decrement pseudo register 39 by the length of a @code{DFmode}
  2834. value and use the result to address a @code{DFmode} value.
  2835. @item (pre_inc:@var{m} @var{x})
  2836. Similar, but specifies incrementing @var{x} instead of decrementing it.
  2837. @item (post_dec:@var{m} @var{x})
  2838. Represents the same side effect as @samp{pre_decrement} but a different
  2839. value. The value represented here is the value @var{x} has @i{before}
  2840. being decremented.
  2841. @item (post_inc:@var{m} @var{x})
  2842. Similar, but specifies incrementing @var{x} instead of decrementing it.
  2843. @end table
  2844. These embedded side effect expressions must be used with care. Instruction
  2845. patterns may not use them. Until the @samp{flow} pass of the compiler,
  2846. they may occur only to represent pushes onto the stack. The @samp{flow}
  2847. pass finds cases where registers are incremented or decremented in one
  2848. instruction and used as an address shortly before or after; these cases are
  2849. then transformed to use pre- or post-increment or -decrement.
  2850. Explicit popping of the stack could be represented with these embedded
  2851. side effect operators, but that would not be safe; the instruction
  2852. combination pass could move the popping past pushes, thus changing
  2853. the meaning of the code.
  2854. An instruction that can be represented with an embedded side effect
  2855. could also be represented using @samp{parallel} containing an additional
  2856. @samp{set} to describe how the address register is altered. This is not
  2857. done because machines that allow these operations at all typically
  2858. allow them wherever a memory address is called for. Describing them as
  2859. additional parallel stores would require doubling the number of entries
  2860. in the machine description.
  2861. @node Assembler, Insns, IncDec, RTL
  2862. @section Assembler Instructions as Expressions
  2863. The RTX code @samp{asm_operands} represents a value produced by a
  2864. user-specified assembler instruction. It is used to represent
  2865. an @code{asm} statement with arguments. An @code{asm} statement with
  2866. a single output operand, like this:
  2867. @example
  2868. asm ("foo %1,%2,%0" : "a" (outputvar) : "g" (x + y), "di" (*z));
  2869. @end example
  2870. @noindent
  2871. is represented using a single @samp{asm_operands} RTX which represents
  2872. the value that is stored in @code{outputvar}:
  2873. @example
  2874. (set @var{rtx-for-outputvar}
  2875. (asm_operands "foo %1,%2,%0" "a" 0
  2876. [@var{rtx-for-addition-result} @var{rtx-for-*z}]
  2877. [(asm_input:@var{m1} "g")
  2878. (asm_input:@var{m2} "di")]))
  2879. @end example
  2880. @noindent
  2881. Here the operands of the @samp{asm_operands} RTX are the assembler
  2882. template string, the output-operand's constraint, the index-number of the
  2883. output operand among the output operands specified, a vector of input
  2884. operand RTX's, and a vector of input-operand modes and constraints. The
  2885. mode @var{m1} is the mode of the sum @code{x+y}; @var{m2} is that of
  2886. @code{*z}.
  2887. When an @code{asm} statement has multiple output values, its insn has
  2888. several such @samp{set} RTX's inside of a @samp{parallel}. Each @samp{set}
  2889. contains a @samp{asm_operands}; all of these share the same assembler
  2890. template and vectors, but each contains the constraint for the respective
  2891. output operand. They are also distinguished by the output-operand index
  2892. number, which is 0, 1, @dots{} for successive output operands.
  2893. @node Insns, Calls, Assembler, RTL
  2894. @section Insns
  2895. The RTL representation of the code for a function is a doubly-linked
  2896. chain of objects called @dfn{insns}. Insns are expressions with
  2897. special codes that are used for no other purpose. Some insns are
  2898. actual instructions; others represent dispatch tables for @code{switch}
  2899. statements; others represent labels to jump to or various sorts of
  2900. declarative information.
  2901. In addition to its own specific data, each insn must have a unique id-number
  2902. that distinguishes it from all other insns in the current function, and
  2903. chain pointers to the preceding and following insns. These three fields
  2904. occupy the same position in every insn, independent of the expression code
  2905. of the insn. They could be accessed with @code{XEXP} and @code{XINT},
  2906. but instead three special macros are always used:
  2907. @table @code
  2908. @item INSN_UID (@var{i})
  2909. Accesses the unique id of insn @var{i}.
  2910. @item PREV_INSN (@var{i})
  2911. Accesses the chain pointer to the insn preceding @var{i}.
  2912. If @var{i} is the first insn, this is a null pointer.
  2913. @item NEXT_INSN (@var{i})
  2914. Accesses the chain pointer to the insn following @var{i}.
  2915. If @var{i} is the last insn, this is a null pointer.
  2916. @end table
  2917. The @code{NEXT_INSN} and @code{PREV_INSN} pointers must always
  2918. correspond: if @var{i} is not the first insn,
  2919. @example
  2920. NEXT_INSN (PREV_INSN (@var{insn})) == @var{insn}
  2921. @end example
  2922. @noindent
  2923. is always true.
  2924. Every insn has one of the following six expression codes:
  2925. @table @samp
  2926. @item insn
  2927. The expression code @samp{insn} is used for instructions that do not jump
  2928. and do not do function calls. Insns with code @samp{insn} have four
  2929. additional fields beyond the three mandatory ones listed above.
  2930. These four are described in a table below.
  2931. @item jump_insn
  2932. The expression code @samp{jump_insn} is used for instructions that may jump
  2933. (or, more generally, may contain @samp{label_ref} expressions).
  2934. @samp{jump_insn} insns have the same extra fields as @samp{insn} insns,
  2935. accessed in the same way.
  2936. @item call_insn
  2937. The expression code @samp{call_insn} is used for instructions that may do
  2938. function calls. It is important to distinguish these instructions because
  2939. they imply that certain registers and memory locations may be altered
  2940. unpredictably.
  2941. @samp{call_insn} insns have the same extra fields as @samp{insn} insns,
  2942. accessed in the same way.
  2943. @item code_label
  2944. A @samp{code_label} insn represents a label that a jump insn can jump to.
  2945. It contains one special field of data in addition to the three standard ones.
  2946. It is used to hold the @dfn{label number}, a number that identifies this
  2947. label uniquely among all the labels in the compilation (not just in the
  2948. current function). Ultimately, the label is represented in the assembler
  2949. output as an assembler label @samp{L@var{n}} where @var{n} is the label number.
  2950. @item barrier
  2951. Barriers are placed in the instruction stream after unconditional
  2952. jump instructions to indicate that the jumps are unconditional.
  2953. They contain no information beyond the three standard fields.
  2954. @item note
  2955. @samp{note} insns are used to represent additional debugging and
  2956. declarative information. They contain two nonstandard fields, an
  2957. integer which is accessed with the macro @code{NOTE_LINE_NUMBER} and a
  2958. string accessed with @code{NOTE_SOURCE_FILE}.
  2959. If @code{NOTE_LINE_NUMBER} is positive, the note represents the
  2960. position of a source line and @code{NOTE_SOURCE_FILE} is the source file name
  2961. that the line came from. These notes control generation of line
  2962. number data in the assembler output.
  2963. Otherwise, @code{NOTE_LINE_NUMBER} is not really a line number but a
  2964. code with one of the following values (and @code{NOTE_SOURCE_FILE}
  2965. must contain a null pointer):
  2966. @table @code
  2967. @item NOTE_INSN_DELETED
  2968. Such a note is completely ignorable. Some passes of the compiler
  2969. delete insns by altering them into notes of this kind.
  2970. @item NOTE_INSN_BLOCK_BEG
  2971. @itemx NOTE_INSN_BLOCK_END
  2972. These types of notes indicate the position of the beginning and end
  2973. of a level of scoping of variable names. They control the output
  2974. of debugging information.
  2975. @item NOTE_INSN_LOOP_BEG
  2976. @itemx NOTE_INSN_LOOP_END
  2977. These types of notes indicate the position of the beginning and end
  2978. of a @code{while} or @code{for} loop. They enable the loop optimizer
  2979. to find loops quickly.
  2980. @end table
  2981. @end table
  2982. Here is a table of the extra fields of @samp{insn}, @samp{jump_insn}
  2983. and @samp{call_insn} insns:
  2984. @table @code
  2985. @item PATTERN (@var{i})
  2986. An expression for the side effect performed by this insn.
  2987. @item REG_NOTES (@var{i})
  2988. A list (chain of @samp{expr_list} expressions) giving information
  2989. about the usage of registers in this insn. This list is set up by the
  2990. flow analysis pass; it is a null pointer until then.
  2991. @item LOG_LINKS (@var{i})
  2992. A list (chain of @samp{insn_list} expressions) of previous ``related''
  2993. insns: insns which store into registers values that are used for the
  2994. first time in this insn. (An additional constraint is that neither a
  2995. jump nor a label may come between the related insns). This list is
  2996. set up by the flow analysis pass; it is a null pointer until then.
  2997. @item INSN_CODE (@var{i})
  2998. An integer that says which pattern in the machine description matches
  2999. this insn, or -1 if the matching has not yet been attempted.
  3000. Such matching is never attempted and this field is not used on an insn
  3001. whose pattern consists of a single @samp{use}, @samp{clobber},
  3002. @samp{asm}, @samp{addr_vec} or @samp{addr_diff_vec} expression.
  3003. @end table
  3004. The @code{LOG_LINKS} field of an insn is a chain of @samp{insn_list}
  3005. expressions. Each of these has two operands: the first is an insn,
  3006. and the second is another @samp{insn_list} expression (the next one in
  3007. the chain). The last @samp{insn_list} in the chain has a null pointer
  3008. as second operand. The significant thing about the chain is which
  3009. insns appear in it (as first operands of @samp{insn_list}
  3010. expressions). Their order is not significant.
  3011. The @code{REG_NOTES} field of an insn is a similar chain but of
  3012. @samp{expr_list} expressions instead of @samp{insn_list}. There are four
  3013. kinds of register notes, which are distinguished by the machine mode of the
  3014. @samp{expr_list}, which a register note is really understood as being an
  3015. @code{enum reg_note}. The first operand @var{op} of the @samp{expr_list}
  3016. is data whose meaning depends on the kind of note. Here are the four
  3017. kinds:
  3018. @table @code
  3019. @item REG_DEAD
  3020. The register @var{op} dies in this insn; that is to say, altering the
  3021. value immediately after this insn would not affect the future behavior
  3022. of the program.
  3023. @item REG_INC
  3024. The register @var{op} is incremented (or decremented; at this level
  3025. there is no distinction) by an embedded side effect inside this insn.
  3026. This means it appears in a @code{POST_INC}, @code{PRE_INC},
  3027. @code{POST_DEC} or @code{PRE_DEC} RTX.
  3028. @item REG_EQUIV
  3029. The register that is set by this insn will be equal to @var{op} at run
  3030. time, and could validly be replaced in all its occurrences by
  3031. @var{op}. (``Validly'' here refers to the data flow of the program;
  3032. simple replacement may make some insns invalid.)
  3033. The value which the insn explicitly copies into the register may look
  3034. different from @var{op}, but they will be equal at run time.
  3035. For example, when a constant is loaded into a register that is never
  3036. assigned any other value, this kind of note is used.
  3037. When a parameter is copied into a pseudo-register at entry to a function,
  3038. a note of this kind records that the register is equivalent to the stack
  3039. slot where the parameter was passed. Although in this case the register
  3040. may be set by other insns, it is still valid to replace the register
  3041. by the stack slot throughout the function.
  3042. @item REG_EQUAL
  3043. The register that is set by this insn will be equal to @var{op} at run
  3044. time at the end of this insn (but not necessarily elsewhere in the
  3045. function).
  3046. The RTX @var{op} is typically an arithmetic expression. For example,
  3047. when a sequence of insns such as a library call is used to perform an
  3048. arithmetic operation, this kind of note is attached to the insn that
  3049. produces or copies the final value. It tells the CSE pass how to
  3050. think of that value.
  3051. @item REG_RETVAL
  3052. This insn copies the value of a library call, and @var{op} is the
  3053. first insn that was generated to set up the arguments for the library
  3054. call.
  3055. Flow analysis uses this note to delete all of a library call whose
  3056. result is dead.
  3057. @item REG_WAS_0
  3058. The register @var{op} contained zero before this insn. You can rely
  3059. on this note if it is present; its absence implies nothing.
  3060. @end table
  3061. (The only difference between the expression codes @samp{insn_list} and
  3062. @samp{expr_list} is that the first operand of an @samp{insn_list} is
  3063. assumed to be an insn and is printed in debugging dumps as the insn's
  3064. unique id; the first operand of an @samp{expr_list} is printed in the
  3065. ordinary way as an expression.)
  3066. @node Calls, Sharing, Insns, RTL
  3067. @section RTL Representation of Function-Call Insns
  3068. Insns that call subroutines have the RTL expression code @samp{call_insn}.
  3069. These insns must satisfy special rules, and their bodies must use a special
  3070. RTL expression code, @samp{call}.
  3071. A @samp{call} expression has two operands, as follows:
  3072. @example
  3073. (call @var{nbytes} (mem:@var{fm} @var{addr}))
  3074. @end example
  3075. @noindent
  3076. Here @var{nbytes} is an operand that represents the number of bytes of
  3077. argument data being passed to the subroutine, @var{fm} is a machine mode
  3078. (which must equal as the definition of the @code{FUNCTION_MODE} macro in
  3079. the machine description) and @var{addr} represents the address of the
  3080. subroutine.
  3081. For a subroutine that returns no value, the @samp{call} RTX as shown above
  3082. is the entire body of the insn.
  3083. For a subroutine that returns a value whose mode is not @code{BLKmode},
  3084. the value is returned in a hard register. If this register's number is
  3085. @var{r}, then the body of the call insn looks like this:
  3086. @example
  3087. (set (reg:@var{m} @var{r})
  3088. (call @var{nbytes} (mem:@var{fm} @var{addr})))
  3089. @end example
  3090. @noindent
  3091. This RTL expression makes it clear (to the optimizer passes) that the
  3092. appropriate register receives a useful value in this insn.
  3093. Immediately after RTL generation, if the value of the subroutine is
  3094. actually used, this call insn is always followed closely by an insn which
  3095. refers to the register @var{r}. The following insn has one of two forms.
  3096. Either it copies the value into a pseudo-register, like this:
  3097. @example
  3098. (set (reg:@var{m} @var{p}) (reg:@var{m} @var{r}))
  3099. @end example
  3100. @noindent
  3101. or (in the case where the calling function will simply return whatever
  3102. value the call produced, and no operation is needed to do this):
  3103. @example
  3104. (use (reg:@var{m} @var{r}))
  3105. @end example
  3106. @noindent
  3107. Between the call insn and this insn there may intervene only a
  3108. stack-adjustment insn (and perhaps some @samp{note} insns).
  3109. When a subroutine returns a @code{BLKmode} value, it is handled by
  3110. passing to the subroutine the address of a place to store the value.
  3111. So the call insn itself does not ``return'' any value, and it has the
  3112. same RTL form as a call that returns nothing.
  3113. @node Sharing,, Calls, RTL
  3114. @section Structure Sharing Assumptions
  3115. The compiler assumes that certain kinds of RTL expressions are unique;
  3116. there do not exist two distinct objects representing the same value.
  3117. In other cases, it makes an opposite assumption: that no RTL expression
  3118. object of a certain kind appears in more than one place in the
  3119. containing structure.
  3120. These assumptions refer to a single function; except for the RTL
  3121. objects that describe global variables and external functions,
  3122. no RTL objects are common to two functions.
  3123. @itemize @bullet
  3124. @item
  3125. Each pseudo-register has only a single @samp{reg} object to represent it,
  3126. and therefore only a single machine mode.
  3127. @item
  3128. For any symbolic label, there is only one @samp{symbol_ref} object
  3129. referring to it.
  3130. @item
  3131. There is only one @samp{const_int} expression with value zero,
  3132. and only one with value one.
  3133. @item
  3134. There is only one @samp{pc} expression.
  3135. @item
  3136. There is only one @samp{cc0} expression.
  3137. @item
  3138. There is only one @samp{const_double} expression with mode
  3139. @code{SFmode} and value zero, and only one with mode @code{DFmode} and
  3140. value zero.
  3141. @item
  3142. No @samp{label_ref} appears in more than one place in the RTL
  3143. structure; in other words, it is safe to do a tree-walk of all the
  3144. insns in the function and assume that each time a @samp{label_ref} is
  3145. seen it is distinct from all others that are seen.
  3146. @item
  3147. Only one @samp{mem} object is normally created for each static
  3148. variable or stack slot, so these objects are frequently shared in all
  3149. the places they appear. However, separate but equal objects for these
  3150. variables are occasionally made.
  3151. @item
  3152. No RTL object appears in more than one place in the RTL structure
  3153. except as described above. Many passes of the compiler rely on this
  3154. by assuming that they can modify RTL objects in place without unwanted
  3155. side-effects on other insns.
  3156. @item
  3157. During initial RTL generation, shared structure is freely introduced.
  3158. After all the RTL for a function has been generated, all shared
  3159. structure is copied by @code{unshare_all_rtl} in @file{emit-rtl.c},
  3160. after which the above rules are guaranteed to be followed.
  3161. @item
  3162. During the combiner pass, shared structure with an insn can exist
  3163. temporarily. However, the shared structure is copied before the
  3164. combiner is finished with the insn. This is done by
  3165. @code{copy_substitutions} in @samp{combine.c}.
  3166. @end itemize
  3167. @node Machine Desc, Machine Macros, RTL, Top
  3168. @chapter Machine Descriptions
  3169. A machine description has two parts: a file of instruction patterns
  3170. (@file{.md} file) and a C header file of macro definitions.
  3171. The @file{.md} file for a target machine contains a pattern for each
  3172. instruction that the target machine supports (or at least each instruction
  3173. that is worth telling the compiler about). It may also contain comments.
  3174. A semicolon causes the rest of the line to be a comment, unless the semicolon
  3175. is inside a quoted string.
  3176. See the next chapter for information on the C header file.
  3177. @menu
  3178. * Patterns:: How to write instruction patterns.
  3179. * Example:: An explained example of a @samp{define_insn} pattern.
  3180. * RTL Template:: The RTL template defines what insns match a pattern.
  3181. * Output Template:: The output template says how to make assembler code
  3182. from such an insn.
  3183. * Output Statement:: For more generality, write C code to output
  3184. the assembler code.
  3185. * Constraints:: When not all operands are general operands.
  3186. * Standard Names:: Names mark patterns to use for code generation.
  3187. * Pattern Ordering:: When the order of patterns makes a difference.
  3188. * Dependent Patterns:: Having one pattern may make you need another.
  3189. * Jump Patterns:: Special considerations for patterns for jump insns.
  3190. * Peephole Definitions::Defining machine-specific peephole optimizations.
  3191. * Expander Definitions::Generating a sequence of several RTL insns
  3192. for a standard operation.
  3193. @end menu
  3194. @node Patterns, Example, Machine Desc, Machine Desc
  3195. @section Everything about Instruction Patterns
  3196. Each instruction pattern contains an incomplete RTL expression, with pieces
  3197. to be filled in later, operand constraints that restrict how the pieces can
  3198. be filled in, and an output pattern or C code to generate the assembler
  3199. output, all wrapped up in a @samp{define_insn} expression.
  3200. A @samp{define_insn} is an RTL expression containing four operands:
  3201. @enumerate
  3202. @item
  3203. An optional name. The presence of a name indicate that this instruction
  3204. pattern can perform a certain standard job for the RTL-generation
  3205. pass of the compiler. This pass knows certain names and will use
  3206. the instruction patterns with those names, if the names are defined
  3207. in the machine description.
  3208. The absence of a name is indicated by writing an empty string
  3209. where the name should go. Nameless instruction patterns are never
  3210. used for generating RTL code, but they may permit several simpler insns
  3211. to be combined later on.
  3212. Names that are not thus known and used in RTL-generation have no
  3213. effect; they are equivalent to no name at all.
  3214. @item
  3215. The @dfn{RTL template} (@pxref{RTL Template}) is a vector of
  3216. incomplete RTL expressions which show what the instruction should look
  3217. like. It is incomplete because it may contain @samp{match_operand}
  3218. and @samp{match_dup} expressions that stand for operands of the
  3219. instruction.
  3220. If the vector has only one element, that element is what the
  3221. instruction should look like. If the vector has multiple elements,
  3222. then the instruction looks like a @samp{parallel} expression
  3223. containing that many elements as described.
  3224. @item
  3225. A condition. This is a string which contains a C expression that is
  3226. the final test to decide whether an insn body matches this pattern.
  3227. For a named pattern, the condition (if present) may not depend on
  3228. the data in the insn being matched, but only the target-machine-type
  3229. flags. The compiler needs to test these conditions during
  3230. initialization in order to learn exactly which named instructions are
  3231. available in a particular run.
  3232. For nameless patterns, the condition is applied only when matching an
  3233. individual insn, and only after the insn has matched the pattern's
  3234. recognition template. The insn's operands may be found in the vector
  3235. @code{operands}.
  3236. @item
  3237. The @dfn{output template}: a string that says how to output matching
  3238. insns as assembler code. @samp{%} in this string specifies where
  3239. to substitute the value of an operand. @xref{Output Template}.
  3240. When simple substitution isn't general enough, you can specify a piece
  3241. of C code to compute the output. @xref{Output Statement}.
  3242. @end enumerate
  3243. @node Example, RTL Template, Patterns, Machine Desc
  3244. @section Example of @samp{define_insn}
  3245. Here is an actual example of an instruction pattern, for the 68000/68020.
  3246. @example
  3247. (define_insn "tstsi"
  3248. [(set (cc0)
  3249. (match_operand:SI 0 "general_operand" "rm"))]
  3250. ""
  3251. "*
  3252. @{ if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  3253. return \"tstl %0\";
  3254. return \"cmpl #0,%0\"; @}")
  3255. @end example
  3256. This is an instruction that sets the condition codes based on the value of
  3257. a general operand. It has no condition, so any insn whose RTL description
  3258. has the form shown may be handled according to this pattern. The name
  3259. @samp{tstsi} means ``test a @code{SImode} value'' and tells the RTL generation
  3260. pass that, when it is necessary to test such a value, an insn to do so
  3261. can be constructed using this pattern.
  3262. The output control string is a piece of C code which chooses which
  3263. output template to return based on the kind of operand and the specific
  3264. type of CPU for which code is being generated.
  3265. @samp{"rm"} is an operand constraint. Its meaning is explained below.
  3266. @node RTL Template, Output Template, Example, Machine Desc
  3267. @section RTL Template for Generating and Recognizing Insns
  3268. The RTL template is used to define which insns match the particular pattern
  3269. and how to find their operands. For named patterns, the RTL template also
  3270. says how to construct an insn from specified operands.
  3271. Construction involves substituting specified operands into a copy of the
  3272. template. Matching involves determining the values that serve as the
  3273. operands in the insn being matched. Both of these activities are
  3274. controlled by special expression types that direct matching and
  3275. substitution of the operands.
  3276. @table @code
  3277. @item (match_operand:@var{m} @var{n} @var{testfn} @var{constraint})
  3278. This expression is a placeholder for operand number @var{n} of
  3279. the insn. When constructing an insn, operand number @var{n}
  3280. will be substituted at this point. When matching an insn, whatever
  3281. appears at this position in the insn will be taken as operand
  3282. number @var{n}; but it must satisfy @var{testfn} or this instruction
  3283. pattern will not match at all.
  3284. Operand numbers must be chosen consecutively counting from zero in
  3285. each instruction pattern. There may be only one @samp{match_operand}
  3286. expression in the pattern for each expression number, and they must
  3287. appear in order of increasing expression number.
  3288. @var{testfn} is a string that is the name of a C function that accepts
  3289. two arguments, a machine mode and an expression. During matching,
  3290. the function will be called with @var{m} as the mode argument
  3291. and the putative operand as the other argument. If it returns zero,
  3292. this instruction pattern fails to match. @var{testfn} may be
  3293. an empty string; then it means no test is to be done on the operand.
  3294. Most often, @var{testfn} is @code{"general_operand"}. It checks
  3295. that the putative operand is either a constant, a register or a
  3296. memory reference, and that it is valid for mode @var{m}.
  3297. For an operand that must be a register, @var{testfn} should be
  3298. @code{"register_operand"}. This prevents GNU CC from creating insns
  3299. that have memory references in these operands, insns which would only
  3300. have to be taken apart in the reload pass.
  3301. For an operand that must be a constant, either @var{testfn} should be
  3302. @code{"immediate_operand"}, or the instruction pattern's extra condition
  3303. should check for constants, or both.
  3304. @var{constraint} is explained later (@pxref{Constraints}).
  3305. @item (match_dup @var{n})
  3306. This expression is also a placeholder for operand number @var{n}.
  3307. It is used when the operand needs to appear more than once in the
  3308. insn.
  3309. In construction, @samp{match_dup} behaves exactly like
  3310. @samp{match_operand}: the operand is substituted into the insn being
  3311. constructed. But in matching, @samp{match_dup} behaves differently.
  3312. It assumes that operand number @var{n} has already been determined by
  3313. a @samp{match_operand} appearing earlier in the recognition template,
  3314. and it matches only an identical-looking expression.
  3315. @item (address (match_operand:@var{m} @var{n} "address_operand" ""))
  3316. This complex of expressions is a placeholder for an operand number
  3317. @var{n} in a ``load address'' instruction: an operand which specifies
  3318. a memory location in the usual way, but for which the actual operand
  3319. value used is the address of the location, not the contents of the
  3320. location.
  3321. @samp{address} expressions never appear in RTL code, only in machine
  3322. descriptions. And they are used only in machine descriptions that do
  3323. not use the operand constraint feature. When operand constraints are
  3324. in use, the letter @samp{p} in the constraint serves this purpose.
  3325. @var{m} is the machine mode of the @emph{memory location being
  3326. addressed}, not the machine mode of the address itself. That mode is
  3327. always the same on a given target machine (it is @code{Pmode}, which
  3328. normally is @code{SImode}), so there is no point in mentioning it;
  3329. thus, no machine mode is written in the @samp{address} expression. If
  3330. some day support is added for machines in which addresses of different
  3331. kinds of objects appear differently or are used differently (such as
  3332. the PDP-10), different formats would perhaps need different machine
  3333. modes and these modes might be written in the @samp{address}
  3334. expression.
  3335. @end table
  3336. @node Output Template, Output Statement, RTL Template, Machine Desc
  3337. @section Output Templates and Operand Substitution
  3338. The @dfn{output template} is a string which specifies how to output
  3339. the assembler code for an instruction pattern. Most of the template
  3340. is a fixed string which is output literally. The character @samp{%}
  3341. is used to specify where to substitute an operand; it can also be
  3342. used to identify places different variants of the assembler require
  3343. different syntax.
  3344. In the simplest case, a @samp{%} followed by a digit @var{n} says to output
  3345. operand @var{n} at that point in the string.
  3346. @samp{%} followed by a letter and a digit says to output an operand in an
  3347. alternate fashion. Four letters have standard, built-in meanings described
  3348. below. The machine description macro @code{PRINT_OPERAND} can define
  3349. additional letters with nonstandard meanings.
  3350. @samp{%c@var{digit}} can be used to substitute an operand that is a
  3351. constant value without the syntax that normally indicates an immediate
  3352. operand.
  3353. @samp{%n@var{digit}} is like @samp{%c@var{digit}} except that the value of
  3354. the constant is negated before printing.
  3355. @samp{%a@var{digit}} can be used to substitute an operand as if it were a
  3356. memory reference, with the actual operand treated as the address. This may
  3357. be useful when outputting a ``load address'' instruction, because often the
  3358. assembler syntax for such an instruction requires you to write the operand
  3359. as if it were a memory reference.
  3360. @samp{%l@var{digit}} is used to substitute a @code{label_ref} into a jump
  3361. instruction.
  3362. @samp{%} followed by a punctuation character specifies a substitution that
  3363. does not use an operand. Only one case is standard: @samp{%%} outputs a
  3364. @samp{%} into the assembler code. Other nonstandard cases can be
  3365. defined in the @code{PRINT_OPERAND} macro.
  3366. The template may generate multiple assembler instructions. Write the text
  3367. for the instructions, with @samp{\;} between them.
  3368. When the RTL contains two operand which are required by constraint to match
  3369. each other, the output template must refer only to the lower-numbered operand.
  3370. Matching operands are not always identical, and the rest of the compiler
  3371. arranges to put the proper RTL expression for printing into the lower-numbered
  3372. operand.
  3373. One use of nonstandard letters or punctuation following @samp{%} is to
  3374. distinguish between different assembler languages for the same machine; for
  3375. example, Motorola syntax versus MIT syntax for the 68000. Motorola syntax
  3376. requires periods in most opcode names, while MIT syntax does not. For
  3377. example, the opcode @samp{movel} in MIT syntax is @samp{move.l} in Motorola
  3378. syntax. The same file of patterns is used for both kinds of output syntax,
  3379. but the character sequence @samp{%.} is used in each place where Motorola
  3380. syntax wants a period. The @code{PRINT_OPERAND} macro for Motorola syntax
  3381. defines the sequence to output a period; the macro for MIT syntax defines
  3382. it to do nothing.
  3383. @node Output Statement, Constraints, Output Template, Machine Desc
  3384. @section C Statements for Generating Assembler Output
  3385. Often a single fixed template string cannot produce correct and efficient
  3386. assembler code for all the cases that are recognized by a single
  3387. instruction pattern. For example, the opcodes may depend on the kinds of
  3388. operands; or some unfortunate combinations of operands may require extra
  3389. machine instructions.
  3390. If the output control string starts with a @samp{*}, then it is not an
  3391. output template but rather a piece of C program that should compute a
  3392. template. It should execute a @code{return} statement to return the
  3393. template-string you want. Most such templates use C string literals, which
  3394. require doublequote characters to delimit them. To include these
  3395. doublequote characters in the string, prefix each one with @samp{\}.
  3396. The operands may be found in the array @code{operands}, whose C data type
  3397. is @code{rtx []}.
  3398. It is possible to output an assembler instruction and then go on to output
  3399. or compute more of them, using the subroutine @code{output_asm_insn}. This
  3400. receives two arguments: a template-string and a vector of operands. The
  3401. vector may be @code{operands}, or it may be another array of @code{rtx}
  3402. that you declare locally and initialize yourself.
  3403. When an insn pattern has multiple alternatives in its constraints, often
  3404. the appearance of the assembler code determined mostly by which alternative
  3405. was matched. When this is so, the C code can test the variable
  3406. @code{which_alternative}, which is the ordinal number of the alternative
  3407. that was actually satisfied (0 for the first, 1 for the second alternative,
  3408. etc.).
  3409. For example, suppose there are two opcodes for storing zero, @samp{clrreg}
  3410. for registers and @samp{clrmem} for memory locations. Here is how
  3411. a pattern could use @code{which_alternative} to choose between them:
  3412. @example
  3413. (define_insn ""
  3414. [(set (match_operand:SI 0 "general_operand" "r,m")
  3415. (const_int 0))]
  3416. ""
  3417. "*
  3418. return (which_alternative == 0
  3419. ? \"clrreg %0\" : \"clrmem %0\");
  3420. ")
  3421. @end example
  3422. @node Constraints, Standard Names, Output Statement, Machine Desc
  3423. @section Operand Constraints
  3424. Each @samp{match_operand} in an instruction pattern can specify a
  3425. constraint for the type of operands allowed. Constraints can say whether
  3426. an operand may be in a register, and which kinds of register; whether the
  3427. operand can be a memory reference, and which kinds of address; whether the
  3428. operand may be an immediate constant, and which possible values it may
  3429. have. Constraints can also require two operands to match.
  3430. @menu
  3431. * Simple Constraints:: Basic use of constraints.
  3432. * Multi-Alternative:: When an insn has two alternative constraint-patterns.
  3433. * Class Preferences:: Constraints guide which hard register to put things in.
  3434. * Modifiers:: More precise control over effects of constraints.
  3435. * No Constraints:: Describing a clean machine without constraints.
  3436. @end menu
  3437. @node Simple Constraints, Multi-Alternative, Constraints, Constraints
  3438. @subsection Simple Constraints
  3439. The simplest kind of constraint is a string full of letters, each of
  3440. which describes one kind of operand that is permitted. Here are
  3441. the letters that are allowed:
  3442. @table @asis
  3443. @item @samp{m}
  3444. A memory operand is allowed, with any kind of address that the machine
  3445. supports in general.
  3446. @item @samp{o}
  3447. A memory operand is allowed, but only if the address is
  3448. @dfn{offsetable}. This means that adding a small integer (actually,
  3449. the width in bytes of the operand, as determined by its machine mode)
  3450. may be added to the address and the result is also a valid memory
  3451. address.
  3452. For example, an address which is constant is offsetable; so is an
  3453. address that is the sum of a register and a constant (as long as a
  3454. slightly larger constant is also within the range of address-offsets
  3455. supported by the machine); but an autoincrement or autodecrement
  3456. address is not offsetable. More complicated indirect/indexed
  3457. addresses may or may not be offsetable depending on the other
  3458. addressing modes that the machine supports.
  3459. Note that in an output operand which can be matched by another
  3460. operand, the constraint letter @samp{o} is valid only when accompanied
  3461. by both @samp{<} (if the target machine has predecrement addressing)
  3462. and @samp{>} (if the target machine has preincrement addressing).
  3463. @item @samp{<}
  3464. A memory operand with autodecrement addressing (either predecrement or
  3465. postdecrement) is allowed.
  3466. @item @samp{>}
  3467. A memory operand with autoincrement addressing (either preincrement or
  3468. postincrement) is allowed.
  3469. @item @samp{r}
  3470. A register operand is allowed provided that it is in a general
  3471. register.
  3472. @item @samp{d}, @samp{a}, @samp{f}, @dots{}
  3473. Other letters can be defined in machine-dependent fashion to stand for
  3474. particular classes of registers. @samp{d}, @samp{a} and @samp{f} are
  3475. defined on the 68000/68020 to stand for data, address and floating
  3476. point registers.
  3477. @item @samp{i}
  3478. An immediate integer operand (one with constant value) is allowed.
  3479. This includes symbolic constants whose values will be known only at
  3480. assembly time.
  3481. @item @samp{n}
  3482. An immediate integer operand with a known numeric value is allowed.
  3483. Many systems cannot support assembly-time constants for operands less
  3484. than a word wide. Constraints for these operands should use @samp{n}
  3485. rather than @samp{i}.
  3486. @item @samp{I}, @samp{J}, @samp{K}, @dots{}
  3487. Other letters in the range @samp{I} through @samp{M} may be defined in
  3488. a machine-dependent fashion to permit immediate integer operands with
  3489. explicit integer values in specified ranges. For example, on the
  3490. 68000, @samp{I} is defined to stand for the range of values 1 to 8.
  3491. This is the range permitted as a shift count in the shift
  3492. instructions.
  3493. @item @samp{F}
  3494. An immediate floating operand (expression code @samp{const_double}) is
  3495. allowed.
  3496. @item @samp{G}, @samp{H}
  3497. @samp{G} and @samp{H} may be defined in a machine-dependent fashion to
  3498. permit immediate floating operands in particular ranges of values.
  3499. @item @samp{s}
  3500. An immediate integer operand whose value is not an explicit integer is
  3501. allowed.
  3502. This might appear strange; if an insn allows a constant operand with a
  3503. value not known at compile time, it certainly must allow any known
  3504. value. So why use @samp{s} instead of @samp{i}? Sometimes it allows
  3505. better code to be generated.
  3506. For example, on the 68000 in a fullword instruction it is possible to
  3507. use an immediate operand; but if the immediate value is between -32
  3508. and 31, better code results from loading the value into a register and
  3509. using the register. This is because the load into the register can be
  3510. done with a @samp{moveq} instruction. We arrange for this to happen
  3511. by defining the letter @samp{K} to mean ``any integer outside the
  3512. range -32 to 31'', and then specifying @samp{Ks} in the operand
  3513. constraints.
  3514. @item @samp{g}
  3515. Any register, memory or immediate integer operand is allowed, except for
  3516. registers that are not general registers.
  3517. @item @samp{@var{n}} (a digit)
  3518. An operand that matches operand number @var{n} is allowed.
  3519. If a digit is used together with letters, the digit should come last.
  3520. This is called a @dfn{matching constraint} and what it really means is
  3521. that the assembler has only a single operand that fills two roles
  3522. considered separate in the RTL insn. For example, an add insn has two
  3523. input operands and one output operand in the RTL, but on most machines
  3524. an add instruction really has only two operands, one of them an
  3525. input-output operand.
  3526. Matching constraints work only in circumstances like that add insn.
  3527. More precisely, the matching constraint must appear in an input-only
  3528. operand and the operand that it matches must be an output-only operand
  3529. with a lower number.
  3530. For operands to match in a particular case usually means that they
  3531. are identical-looking RTL expressions. But in a few special cases
  3532. specific kinds of dissimilarity are allowed. For example, @code{*x}
  3533. as an input operand will match @code{*x++} as an output operand.
  3534. For proper results in such cases, the output template should always
  3535. use the output-operand's number when printing the operand.
  3536. @item @samp{p}
  3537. An operand that is a valid memory address is allowed. This is
  3538. for ``load address'' and ``push address'' instructions.
  3539. If @samp{p} is used in the constraint, the test-function in the
  3540. @samp{match_operand} must be @code{address_operand}.
  3541. @end table
  3542. In order to have valid assembler code, each operand must satisfy
  3543. its constraint. But a failure to do so does not prevent the pattern
  3544. from applying to an insn. Instead, it directs the compiler to modify
  3545. the code so that the constraint will be satisfied. Usually this is
  3546. done by copying an operand into a register.
  3547. Contrast, therefore, the two instruction patterns that follow:
  3548. @example
  3549. (define_insn ""
  3550. [(set (match_operand:SI 0 "general_operand" "r")
  3551. (plus:SI (match_dup 0)
  3552. (match_operand:SI 1 "general_operand" "r")))]
  3553. ""
  3554. "@dots{}")
  3555. @end example
  3556. @noindent
  3557. which has two operands, one of which must appear in two places, and
  3558. @example
  3559. (define_insn ""
  3560. [(set (match_operand:SI 0 "general_operand" "r")
  3561. (plus:SI (match_operand:SI 1 "general_operand" "0")
  3562. (match_operand:SI 2 "general_operand" "r")))]
  3563. ""
  3564. "@dots{}")
  3565. @end example
  3566. @noindent
  3567. which has three operands, two of which are required by a constraint to be
  3568. identical. If we are considering an insn of the form
  3569. @example
  3570. (insn @var{n} @var{prev} @var{next}
  3571. (set (reg:SI 3)
  3572. (plus:SI (reg:SI 6) (reg:SI 109)))
  3573. @dots{})
  3574. @end example
  3575. @noindent
  3576. the first pattern would not apply at all, because this insn does not
  3577. contain two identical subexpressions in the right place. The pattern would
  3578. say, ``That does not look like an add instruction; try other patterns.''
  3579. The second pattern would say, ``Yes, that's an add instruction, but there
  3580. is something wrong with it.'' It would direct the reload pass of the
  3581. compiler to generate additional insns to make the constraint true. The
  3582. results might look like this:
  3583. @example
  3584. (insn @var{n2} @var{prev} @var{n}
  3585. (set (reg:SI 3) (reg:SI 6))
  3586. @dots{})
  3587. (insn @var{n} @var{n2} @var{next}
  3588. (set (reg:SI 3)
  3589. (plus:SI (reg:SI 3) (reg:SI 109)))
  3590. @dots{})
  3591. @end example
  3592. Because insns that don't fit the constraints are fixed up by loading
  3593. operands into registers, every instruction pattern's constraints must
  3594. permit the case where all the operands are in registers. It need not
  3595. permit all classes of registers; the compiler knows how to copy registers
  3596. into other registers of the proper class in order to make an instruction
  3597. valid. But if no registers are permitted, the compiler will be stymied: it
  3598. does not know how to save a register in memory in order to make an
  3599. instruction valid. Instruction patterns that reject registers can be
  3600. made valid by attaching a condition-expression that refuses to match
  3601. an insn at all if the crucial operand is a register.
  3602. @node Multi-Alternative, Class Preferences, Simple Constraints, Constraints
  3603. @subsection Multiple Alternative Constraints
  3604. Sometimes a single instruction has multiple alternative sets of possible
  3605. operands. For example, on the 68000, a logical-or instruction can combine
  3606. register or an immediate value into memory, or it can combine any kind of
  3607. operand into a register; but it cannot combine one memory location into
  3608. another.
  3609. These constraints are represented as multiple alternatives. An alternative
  3610. can be described by a series of letters for each operand. The overall
  3611. constraint for an operand is made from the letters for this operand
  3612. from the first alternative, a comma, the letters for this operand from
  3613. the second alternative, a comma, and so on until the last alternative.
  3614. Here is how it is done for fullword logical-or on the 68000:
  3615. @example
  3616. (define_insn "iorsi3"
  3617. [(set (match_operand:SI 0 "general_operand" "=%m,d")
  3618. (ior:SI (match_operand:SI 1 "general_operand" "0,0")
  3619. (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  3620. @dots{})
  3621. @end example
  3622. The first alternative has @samp{m} (memory) for operand 0, @samp{0} for
  3623. operand 1 (meaning it must match operand 0), and @samp{dKs} for operand 2.
  3624. The second alternative has @samp{d} (data register) for operand 0, @samp{0}
  3625. for operand 1, and @samp{dmKs} for operand 2. The @samp{=} and @samp{%} in
  3626. the constraint for operand 0 are not part of any alternative; their meaning
  3627. is explained in the next section.
  3628. If all the operands fit any one alternative, the instruction is valid.
  3629. Otherwise, for each alternative, the compiler counts how many instructions
  3630. must be added to copy the operands so that that alternative applies.
  3631. The alternative requiring the least copying is chosen. If two alternatives
  3632. need the same amount of copying, the one that comes first is chosen.
  3633. These choices can be altered with the @samp{?} and @samp{!} characters:
  3634. @table @samp
  3635. @item ?
  3636. Disparage slightly the alternative that the @samp{?} appears in,
  3637. as a choice when no alternative applies exactly. The compiler regards
  3638. this alternative as one unit more costly for each @samp{?} that appears
  3639. in it.
  3640. @item !
  3641. Disparage severely the alternative that the @samp{!} appears in.
  3642. When operands must be copied into registers, the compiler will
  3643. never choose this alternative as the one to strive for.
  3644. @end table
  3645. When an insn pattern has multiple alternatives in its constraints,
  3646. often the appearance of the assembler code determined mostly by which
  3647. alternative was matched. When this is so, the C code for writing the
  3648. assembler code can use the variable @code{which_alternative}, which is
  3649. the ordinal number of the alternative that was actually satisfied
  3650. (0 for the first, 1 for the second alternative, etc.). For example:
  3651. @example
  3652. (define_insn ""
  3653. [(set (match_operand:SI 0 "general_operand" "r,m")
  3654. (const_int 0))]
  3655. ""
  3656. "*
  3657. return (which_alternative == 0
  3658. ? \"clrreg %0\" : \"clrmem %0\");
  3659. ")
  3660. @end example
  3661. @node Class Preferences, Modifiers, Multi-Alternative, Constraints
  3662. @subsection Register Class Preferences
  3663. The operand constraints have another function: they enable the compiler
  3664. to decide which kind of hardware register a pseudo register is best
  3665. allocated to. The compiler examines the constraints that apply to the
  3666. insns that use the pseudo register, looking for the machine-dependent
  3667. letters such as @samp{d} and @samp{a} that specify classes of registers.
  3668. The pseudo register is put in whichever class gets the most ``votes''.
  3669. The constraint letters @samp{g} and @samp{r} also vote: they vote in
  3670. favor of a general register. The machine description says which registers
  3671. are considered general.
  3672. Of course, on some machines all registers are equivalent, and no register
  3673. classes are defined. Then none of this complexity is relevant.
  3674. @node Modifiers, No Constraints, Class Preferences, Constraints
  3675. @subsection Constraint Modifier Characters
  3676. @table @samp
  3677. @item =
  3678. Means that this operand is write-only for this instruction: the previous
  3679. value is discarded and replaced by output data.
  3680. @item +
  3681. Means that this operand is both read and written by the instruction.
  3682. When the compiler fixes up the operands to satisfy the constraints,
  3683. it needs to know which operands are inputs to the instruction and
  3684. which are outputs from it. @samp{=} identifies an output; @samp{+}
  3685. identifies an operand that is both input and output; all other operands
  3686. are assumed to be input only.
  3687. @item &
  3688. Means (in a particular alternative) that this operand is written
  3689. before the instruction is finished using the input operands.
  3690. Therefore, this operand may not lie in a register that is used as an
  3691. input operand or as part of any memory address.
  3692. @samp{&} applies only to the alternative in which it is written. In
  3693. constraints with multiple alternatives, sometimes one alternative
  3694. requires @samp{&} while others do not. See, for example, the
  3695. @samp{movdf} insn of the 68000.
  3696. @samp{&} does not obviate the need to write @samp{=}.
  3697. @item %
  3698. Declares the instruction to be commutative for this operand and the
  3699. following operand. This means that the compiler may interchange the
  3700. two operands if that is the cheapest way to make all operands fit the
  3701. constraints. This is often used in patterns for addition instructions
  3702. that really have only two operands: the result must go in one of the
  3703. arguments. Here for example, is how the 68000 halfword-add
  3704. instruction is defined:
  3705. @example
  3706. (define_insn "addhi3"
  3707. [(set (match_operand:HI 0 "general_operand" "=m,r")
  3708. (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
  3709. (match_operand:HI 2 "general_operand" "di,g")))]
  3710. @dots{})
  3711. @end example
  3712. Note that in previous versions of GNU CC the @samp{%} constraint
  3713. modifier always applied to operands 1 and 2 regardless of which
  3714. operand it was written in. The usual custom was to write it in
  3715. operand 0. Now it must be in operand 1 if the operands to be
  3716. exchanged are 1 and 2.
  3717. @item #
  3718. Says that all following characters, up to the next comma, are to be
  3719. ignored as a constraint. They are significant only for choosing
  3720. register preferences.
  3721. @item *
  3722. Says that the following character should be ignored when choosing
  3723. register preferences. @samp{*} has no effect on the meaning of the
  3724. constraint as a constraint.
  3725. Here is an example: the 68000 has an instruction to sign-extend a
  3726. halfword in a data register, and can also sign-extend a value by
  3727. copying it into an address register. While either kind of register is
  3728. acceptable, the constraints on an address-register destination are
  3729. less strict, so it is best if register allocation makes an address
  3730. register its goal. Therefore, @samp{*} is used so that the @samp{d}
  3731. constraint letter (for data register) is ignored when computing
  3732. register preferences.
  3733. @example
  3734. (define_insn "extendhisi2"
  3735. [(set (match_operand:SI 0 "general_operand" "=*d,a")
  3736. (sign_extend:SI
  3737. (match_operand:HI 1 "general_operand" "0,g")))]
  3738. @dots{})
  3739. @end example
  3740. @end table
  3741. @node No Constraints,, Modifiers, Constraints
  3742. @subsection Not Using Constraints
  3743. Some machines are so clean that operand constraints are not required. For
  3744. example, on the Vax, an operand valid in one context is valid in any other
  3745. context. On such a machine, every operand constraint would be @samp{g},
  3746. excepting only operands of ``load address'' instructions which are
  3747. written as if they referred to a memory location's contents but actual
  3748. refer to its address. They would have constraint @samp{p}.
  3749. For such machines, instead of writing @samp{g} and @samp{p} for all
  3750. the constraints, you can choose to write a description with empty constraints.
  3751. Then you write @samp{""} for the constraint in every @samp{match_operand}.
  3752. Address operands are identified by writing an @samp{address} expression
  3753. around the @samp{match_operand}, not by their constraints.
  3754. When the machine description has just empty constraints, certain parts
  3755. of compilation are skipped, making the compiler faster.
  3756. @node Standard Names, Pattern Ordering, Constraints, Machine Desc
  3757. @section Standard Names for Patterns Used in Generation
  3758. Here is a table of the instruction names that are meaningful in the RTL
  3759. generation pass of the compiler. Giving one of these names to an
  3760. instruction pattern tells the RTL generation pass that it can use the
  3761. pattern in to accomplish a certain task.
  3762. @table @asis
  3763. @item @samp{mov@var{m}}
  3764. Here @var{m} is a two-letter machine mode name, in lower case. This
  3765. instruction pattern moves data with that machine mode from operand 1 to
  3766. operand 0. For example, @samp{movsi} moves full-word data.
  3767. If operand 0 is a @samp{subreg} with mode @var{m} of a register whose
  3768. natural mode is wider than @var{m}, the effect of this instruction is
  3769. to store the specified value in the part of the register that corresponds
  3770. to mode @var{m}. The effect on the rest of the register is undefined.
  3771. @item @samp{movstrict@var{m}}
  3772. Like @samp{mov@var{m}} except that if operand 0 is a @samp{subreg}
  3773. with mode @var{m} of a register whose natural mode is wider,
  3774. the @samp{movstrict@var{m}} instruction is guaranteed not to alter
  3775. any of the register except the part which belongs to mode @var{m}.
  3776. @item @samp{add@var{m}3}
  3777. Add operand 2 and operand 1, storing the result in operand 0. All operands
  3778. must have mode @var{m}. This can be used even on two-address machines, by
  3779. means of constraints requiring operands 1 and 0 to be the same location.
  3780. @item @samp{sub@var{m}3}, @samp{mul@var{m}3}, @samp{umul@var{m}3}, @samp{div@var{m}3}, @samp{udiv@var{m}3}, @samp{mod@var{m}3}, @samp{umod@var{m}3}, @samp{and@var{m}3}, @samp{ior@var{m}3}, @samp{xor@var{m}3}
  3781. Similar, for other arithmetic operations.
  3782. @item @samp{andcb@var{m}3}
  3783. Bitwise logical-and operand 1 with the complement of operand 2
  3784. and store the result in operand 0.
  3785. @item @samp{mulhisi3}
  3786. Multiply operands 1 and 2, which have mode @code{HImode}, and store
  3787. a @code{SImode} product in operand 0.
  3788. @item @samp{mulqihi3}, @samp{mulsidi3}
  3789. Similar widening-multiplication instructions of other widths.
  3790. @item @samp{umulqihi3}, @samp{umulhisi3}, @samp{umulsidi3}
  3791. Similar widening-multiplication instructions that do unsigned
  3792. multiplication.
  3793. @item @samp{divmod@var{m}4}
  3794. Signed division that produces both a quotient and a remainder.
  3795. Operand 1 is divided by operand 2 to produce a quotient stored
  3796. in operand 0 and a remainder stored in operand 3.
  3797. @item @samp{udivmod@var{m}4}
  3798. Similar, but does unsigned division.
  3799. @item @samp{divmod@var{m}@var{n}4}
  3800. Like @samp{divmod@var{m}4} except that only the dividend has mode
  3801. @var{m}; the divisor, quotient and remainder have mode @var{n}.
  3802. For example, the Vax has a @samp{divmoddisi4} instruction
  3803. (but it is omitted from the machine description, because it
  3804. is so slow that it is faster to compute remainders by the
  3805. circumlocution that the compiler will use if this instruction is
  3806. not available).
  3807. @item @samp{ashl@var{m}3}
  3808. Arithmetic-shift operand 1 left by a number of bits specified by
  3809. operand 2, and store the result in operand 0. Operand 2 has
  3810. mode @code{SImode}, not mode @var{m}.
  3811. @item @samp{ashr@var{m}3}, @samp{lshl@var{m}3}, @samp{lshr@var{m}3}, @samp{rotl@var{m}3}, @samp{rotr@var{m}3}
  3812. Other shift and rotate instructions.
  3813. Logical and arithmetic left shift are the same. Machines that do not
  3814. allow negative shift counts often have only one instruction for
  3815. shifting left. On such machines, you should define a pattern named
  3816. @samp{ashl@var{m}3} and leave @samp{lshl@var{m}3} undefined.
  3817. @item @samp{neg@var{m}2}
  3818. Negate operand 1 and store the result in operand 0.
  3819. @item @samp{abs@var{m}2}
  3820. Store the absolute value of operand 1 into operand 0.
  3821. @item @samp{sqrt@var{m}2}
  3822. Store the square root of operand 1 into operand 0.
  3823. @item @samp{ffs@var{m}2}
  3824. Store into operand 0 one plus the index of the least significant 1-bit
  3825. of operand 1. If operand 1 is zero, store zero. @var{m} is the mode
  3826. of operand 0; operand 1's mode is specified by the instruction
  3827. pattern, and the compiler will convert the operand to that mode before
  3828. generating the instruction.
  3829. @item @samp{one_cmpl@var{m}2}
  3830. Store the bitwise-complement of operand 1 into operand 0.
  3831. @item @samp{cmp@var{m}}
  3832. Compare operand 0 and operand 1, and set the condition codes.
  3833. The RTL pattern should look like this:
  3834. @example
  3835. (set (cc0) (minus (match_operand:@var{m} 0 @dots{})
  3836. (match_operand:@var{m} 1 @dots{})))
  3837. @end example
  3838. Each such definition in the machine description, for integer mode
  3839. @var{m}, must have a corresponding @samp{tst@var{m}} pattern, because
  3840. optimization can simplify the compare into a test when operand 1 is
  3841. zero.
  3842. @item @samp{tst@var{m}}
  3843. Compare operand 0 against zero, and set the condition codes.
  3844. The RTL pattern should look like this:
  3845. @example
  3846. (set (cc0) (match_operand:@var{m} 0 @dots{}))
  3847. @end example
  3848. @item @samp{movstr@var{m}}
  3849. Block move instruction. The addresses of the destination and source
  3850. strings are the first two operands, and both are in mode @code{Pmode}.
  3851. The number of bytes to move is the third operand, in mode @var{m}.
  3852. @item @samp{cmpstr@var{m}}
  3853. Block compare instruction, with operands like @samp{movstr@var{m}}
  3854. except that the two memory blocks are compared byte by byte
  3855. in lexicographic order. The effect of the instruction is to set
  3856. the condition codes.
  3857. @item @samp{float@var{m}@var{n}2}
  3858. Convert operand 1 (valid for fixed point mode @var{m}) to floating
  3859. point mode @var{n} and store in operand 0 (which has mode @var{n}).
  3860. @item @samp{fix@var{m}@var{n}2}
  3861. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  3862. point mode @var{n} as a signed number and store in operand 0 (which
  3863. has mode @var{n}). This instruction's result is defined only when
  3864. the value of operand 1 is an integer.
  3865. @item @samp{fixuns@var{m}@var{n}2}
  3866. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  3867. point mode @var{n} as an unsigned number and store in operand 0 (which
  3868. has mode @var{n}). This instruction's result is defined only when the
  3869. value of operand 1 is an integer.
  3870. @item @samp{ftrunc@var{m}2}
  3871. Convert operand 1 (valid for floating point mode @var{m}) to an
  3872. integer value, still represented in floating point mode @var{m}, and
  3873. store it in operand 0 (valid for floating point mode @var{m}).
  3874. @item @samp{fix_trunc@var{m}@var{n}2}
  3875. Like @samp{fix@var{m}@var{n}2} but works for any floating point value
  3876. of mode @var{m} by converting the value to an integer.
  3877. @item @samp{fixuns_trunc@var{m}@var{n}2}
  3878. Like @samp{fixuns@var{m}@var{n}2} but works for any floating point
  3879. value of mode @var{m} by converting the value to an integer.
  3880. @item @samp{trunc@var{m}@var{n}}
  3881. Truncate operand 1 (valid for mode @var{m}) to mode @var{n} and
  3882. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  3883. point or both floating point.
  3884. @item @samp{extend@var{m}@var{n}}
  3885. Sign-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
  3886. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  3887. point or both floating point.
  3888. @item @samp{zero_extend@var{m}@var{n}}
  3889. Zero-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
  3890. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  3891. point.
  3892. @item @samp{extv}
  3893. Extract a bit-field from operand 1 (a register or memory operand),
  3894. where operand 2 specifies the width in bits and operand 3 the starting
  3895. bit, and store it in operand 0. Operand 0 must have @code{Simode}.
  3896. Operand 1 may have mode @code{QImode} or @code{SImode}; often
  3897. @code{SImode} is allowed only for registers. Operands 2 and 3 must be
  3898. valid for @code{SImode}.
  3899. The RTL generation pass generates this instruction only with constants
  3900. for operands 2 and 3.
  3901. The bit-field value is sign-extended to a full word integer
  3902. before it is stored in operand 0.
  3903. @item @samp{extzv}
  3904. Like @samp{extv} except that the bit-field value is zero-extended.
  3905. @item @samp{insv}
  3906. Store operand 3 (which must be valid for @code{SImode}) into a
  3907. bit-field in operand 0, where operand 1 specifies the width in bits
  3908. and operand 2 the starting bit. Operand 0 may have mode @code{QImode}
  3909. or @code{SImode}; often @code{SImode} is allowed only for registers.
  3910. Operands 1 and 2 must be valid for @code{SImode}.
  3911. The RTL generation pass generates this instruction only with constants
  3912. for operands 1 and 2.
  3913. @item @samp{s@var{cond}}
  3914. Store zero or nonzero in the operand according to the condition codes.
  3915. Value stored is nonzero iff the condition @var{cond} is true.
  3916. @var{cond} is the name of a comparison operation expression code, such
  3917. as @samp{eq}, @samp{lt} or @samp{leu}.
  3918. You specify the mode that the operand must have when you write the
  3919. @code{match_operand} expression. The compiler automatically sees
  3920. which mode you have used and supplies an operand of that mode.
  3921. The value stored for a true condition must have 1 as its low bit.
  3922. Otherwise the instruction is not suitable and must be omitted from the
  3923. machine description. You must tell the compiler exactly which value
  3924. is stored by defining the macro @code{STORE_FLAG_VALUE}.
  3925. @item @samp{b@var{cond}}
  3926. Conditional branch instruction. Operand 0 is a @samp{label_ref}
  3927. that refers to the label to jump to. Jump if the condition codes
  3928. meet condition @var{cond}.
  3929. @item @samp{call}
  3930. Subroutine call instruction. Operand 1 is the number of bytes of
  3931. arguments pushed (in mode @code{SImode}), and operand 0 is the
  3932. function to call. Operand 0 should be a @samp{mem} RTX whose address
  3933. is the address of the function.
  3934. @item @samp{return}
  3935. Subroutine return instruction. This instruction pattern name should be
  3936. defined only if a single instruction can do all the work of returning
  3937. from a function.
  3938. @item @samp{tablejump}
  3939. @item @samp{case@var{m}}
  3940. @end table
  3941. @node Pattern Ordering, Dependent Patterns, Standard Names, Machine Desc
  3942. @section When the Order of Patterns Matters
  3943. Sometimes an insn can match more than one instruction pattern. Then the
  3944. pattern that appears first in the machine description is the one used.
  3945. Therefore, more specific patterns (patterns that will match fewer things)
  3946. and faster instructions (those that will produce better code when they
  3947. do match) should usually go first in the description.
  3948. In some cases the effect of ordering the patterns can be used to hide
  3949. a pattern when it is not valid. For example, the 68000 has an
  3950. instruction for converting a fullword to floating point and another
  3951. for converting a byte to floating point. An instruction converting
  3952. an integer to floating point could match either one. We put the
  3953. pattern to convert the fullword first to make sure that one will
  3954. be used rather than the other. (Otherwise a large integer might
  3955. be generated as a single-byte immediate quantity, which would not work.)
  3956. Instead of using this pattern ordering it would be possible to make the
  3957. pattern for convert-a-byte smart enough to deal properly with any
  3958. constant value.
  3959. @node Dependent Patterns, Jump Patterns, Pattern Ordering, Machine Desc
  3960. @section Interdependence of Patterns
  3961. Every machine description must have a named pattern for each of the
  3962. conditional branch names @samp{b@var{cond}}. The recognition template
  3963. must always have the form
  3964. @example
  3965. (set (pc)
  3966. (if_then_else (@var{cond} (cc0) (const_int 0))
  3967. (label_ref (match_operand 0 "" ""))
  3968. (pc)))
  3969. @end example
  3970. @noindent
  3971. In addition, every machine description must have an anonymous pattern
  3972. for each of the possible reverse-conditional branches. These patterns
  3973. look like
  3974. @example
  3975. (set (pc)
  3976. (if_then_else (@var{cond} (cc0) (const_int 0))
  3977. (pc)
  3978. (label_ref (match_operand 0 "" ""))))
  3979. @end example
  3980. @noindent
  3981. They are necessary because jump optimization can turn direct-conditional
  3982. branches into reverse-conditional branches.
  3983. The compiler does more with RTL than just create it from patterns
  3984. and recognize the patterns: it can perform arithmetic expression codes
  3985. when constant values for their operands can be determined. As a result,
  3986. sometimes having one pattern can require other patterns. For example, the
  3987. Vax has no `and' instruction, but it has `and not' instructions. Here
  3988. is the definition of one of them:
  3989. @example
  3990. (define_insn "andcbsi2"
  3991. [(set (match_operand:SI 0 "general_operand" "")
  3992. (and:SI (match_dup 0)
  3993. (not:SI (match_operand:SI
  3994. 1 "general_operand" ""))))]
  3995. ""
  3996. "bicl2 %1,%0")
  3997. @end example
  3998. @noindent
  3999. If operand 1 is an explicit integer constant, an instruction constructed
  4000. using that pattern can be simplified into an `and' like this:
  4001. @example
  4002. (set (reg:SI 41)
  4003. (and:SI (reg:SI 41)
  4004. (const_int 0xffff7fff)))
  4005. @end example
  4006. @noindent
  4007. (where the integer constant is the one's complement of what
  4008. appeared in the original instruction).
  4009. To avoid a fatal error, the compiler must have a pattern that recognizes
  4010. such an instruction. Here is what is used:
  4011. @example
  4012. (define_insn ""
  4013. [(set (match_operand:SI 0 "general_operand" "")
  4014. (and:SI (match_dup 0)
  4015. (match_operand:SI 1 "general_operand" "")))]
  4016. "GET_CODE (operands[1]) == CONST_INT"
  4017. "*
  4018. @{ operands[1]
  4019. = gen_rtx (CONST_INT, VOIDmode, ~INTVAL (operands[1]));
  4020. return \"bicl2 %1,%0\";
  4021. @}")
  4022. @end example
  4023. @noindent
  4024. Whereas a pattern to match a general `and' instruction is impossible to
  4025. support on the Vax, this pattern is possible because it matches only a
  4026. constant second argument: a special case that can be output as an `and not'
  4027. instruction.
  4028. A ``compare'' instruction whose RTL looks like this:
  4029. @example
  4030. (set (cc0) (minus @var{operand} (const_int 0)))
  4031. @end example
  4032. @noindent
  4033. may be simplified by optimization into a ``test'' like this:
  4034. @example
  4035. (set (cc0) @var{operand})
  4036. @end example
  4037. @noindent
  4038. So in the machine description, each ``compare'' pattern for an integer
  4039. mode must have a corresponding ``test'' pattern that will match the
  4040. result of such simplification.
  4041. In some cases machines support instructions identical except for the
  4042. machine mode of one or more operands. For example, there may be
  4043. ``sign-extend halfword'' and ``sign-extend byte'' instructions whose
  4044. patterns are
  4045. @example
  4046. (set (match_operand:SI 0 @dots{})
  4047. (extend:SI (match_operand:HI 1 @dots{})))
  4048. (set (match_operand:SI 0 @dots{})
  4049. (extend:SI (match_operand:QI 1 @dots{})))
  4050. @end example
  4051. @noindent
  4052. Constant integers do not specify a machine mode, so an instruction to
  4053. extend a constant value could match either pattern. The pattern it
  4054. actually will match is the one that appears first in the file. For correct
  4055. results, this must be the one for the widest possible mode (@code{HImode},
  4056. here). If the pattern matches the @code{QImode} instruction, the results
  4057. will be incorrect if the constant value does not actually fit that mode.
  4058. Such instructions to extend constants are rarely generated because they are
  4059. optimized away, but they do occasionally happen in nonoptimized
  4060. compilations.
  4061. @node Jump Patterns, Peephole Definitions, Dependent Patterns, Machine Desc
  4062. @section Defining Jump Instruction Patterns
  4063. GNU CC assumes that the machine has a condition code. A comparison insn
  4064. sets the condition code, recording the results of both signed and unsigned
  4065. comparison of the given operands. A separate branch insn tests the
  4066. condition code and branches or not according its value. The branch insns
  4067. come in distinct signed and unsigned flavors. Many common machines, such
  4068. as the Vax, the 68000 and the 32000, work this way.
  4069. Some machines have distinct signed and unsigned compare instructions, and
  4070. only one set of conditional branch instructions. The easiest way to handle
  4071. these machines is to treat them just like the others until the final stage
  4072. where assembly code is written. At this time, when outputting code for the
  4073. compare instruction, peek ahead at the following branch using
  4074. @code{NEXT_INSN (insn)}. (The variable @code{insn} refers to the insn
  4075. being output, in the output-writing code in an instruction pattern.) If
  4076. the RTL says that is an unsigned branch, output an unsigned compare;
  4077. otherwise output a signed compare. When the branch itself is output, you
  4078. can treat signed and unsigned branches identically.
  4079. The reason you can do this is that GNU CC always generates a pair of
  4080. consecutive RTL insns, one to set the condition code and one to test it,
  4081. and keeps the pair inviolate until the end.
  4082. To go with this technique, you must define the machine-description macro
  4083. @code{NOTICE_UPDATE_CC} to do @code{CC_STATUS_INIT}; in other words, no
  4084. compare instruction is superfluous.
  4085. Some machines have compare-and-branch instructions and no condition code.
  4086. A similar technique works for them. When it is time to ``output'' a
  4087. compare instruction, record its operands in two static variables. When
  4088. outputting the branch-on-condition-code instruction that follows, actually
  4089. output a compare-and-branch instruction that uses the remembered operands.
  4090. It also works to define patterns for compare-and-branch instructions.
  4091. In optimizing compilation, the pair of compare and branch instructions
  4092. will be combined accoprding to these patterns. But this does not happen
  4093. if optimization is not requested. So you must use one of the solutions
  4094. above in addition to any special patterns you define.
  4095. @node Peephole Definitions, Expander Definitions, Jump Patterns, Machine Desc
  4096. @section Defining Machine-Specific Peephole Optimizers
  4097. In addition to instruction patterns the @file{md} file may contain
  4098. definitions of machine-specific peephole optimizations.
  4099. The combiner does not notice certain peephole optimizations when the data
  4100. flow in the program does not suggest that it should try them. For example,
  4101. sometimes two consecutive insns related in purpose can be combined even
  4102. though the second one does not appear to use a register computed in the
  4103. first one. A machine-specific peephole optimizer can detect such
  4104. opportunities.
  4105. A definition looks like this:
  4106. @example
  4107. (define_peephole
  4108. [@var{insn-pattern-1}
  4109. @var{insn-pattern-2}
  4110. @dots{}]
  4111. "@var{condition}"
  4112. "@var{template}")
  4113. @end example
  4114. In this skeleton, @var{insn-pattern-1} and so on are patterns to match
  4115. consecutive instructions. The optimization applies to a sequence of
  4116. instructions when @var{insn-pattern-1} matches the first one,
  4117. @var{insn-pattern-2} matches the next, and so on.@refill
  4118. @var{insn-pattern-1} and so on look @emph{almost} like the second operand
  4119. of @code{define_insn}. There is one important difference: this pattern is
  4120. an RTX, not a vector. If the @code{define_insn} pattern would be a vector
  4121. of one element, the @var{insn-pattern} should be just that element, no
  4122. vector. If the @code{define_insn} pattern would have multiple elements
  4123. then the @var{insn-pattern} must place the vector inside an explicit
  4124. @code{parallel} RTX.@refill
  4125. The operands of the instructions are matched with @code{match_operands} and
  4126. @code{match_dup}, as usual). What is not usual is that the operand numbers
  4127. apply to all the instruction patterns in the definition. So, you can check
  4128. for identical operands in two instructions by using @code{match_operand}
  4129. in one instruction and @code{match_dup} in the other.
  4130. The operand constraints used in @code{match_operand} patterns do not have
  4131. any direct effect on the applicability of the optimization, but they will
  4132. be validated afterward, so write constraints that are sure to fit whenever
  4133. the optimization is applied. It is safe to use @code{"g"} for each
  4134. operand.
  4135. Once a sequence of instructions matches the patterns, the @var{condition}
  4136. is checked. This is a C expression which makes the final decision whether
  4137. to perform the optimization (do so if the expression is nonzero). If
  4138. @var{condition} is omitted (in other words, the string is empty) then the
  4139. optimization is applied to every sequence of instructions that matches the
  4140. patterns.
  4141. The defined peephole optimizations are applied after register allocation is
  4142. complete. Therefore, the optimizer can check which operands have ended up
  4143. in which kinds of registers, just by looking at the operands.
  4144. The way to refer to the operands in @var{condition} is to write
  4145. @code{operands[@var{i}]} for operand number @var{i} (as matched by
  4146. @code{(match_operand @var{i} @dots{})}). Use the variable @code{insn} to
  4147. refer to the last of the insns being matched; use @code{PREV_INSN} to find
  4148. the preceding insns (but be careful to skip over any @samp{note} insns that
  4149. intervene).@refill
  4150. When optimizing computations with intermediate results, you can use
  4151. @var{condition} to match only when the intermediate results are not used
  4152. elsewhere. Use the C expression @code{dead_or_set_p (@var{insn},
  4153. @var{op})}, where @var{insn} is the insn in which you expect the value to
  4154. be used for the last time (from the value of @code{insn}, together with use
  4155. of @code{PREV_INSN}), and @var{op} is the intermediate value (from
  4156. @code{operands[@var{i}]}).@refill
  4157. Applying the optimization means replacing the sequence of instructions with
  4158. one new instruction. The @var{template} controls ultimate output of
  4159. assembler code for this combined instruction. It works exactly like the
  4160. template of a @code{define_insn}. Operand numbers in this template are the
  4161. same ones used in matching the original sequence of instructions.
  4162. The result of a defined peephole optimizer does not need to match any of
  4163. the instruction patterns, and it does not have an opportunity to match
  4164. them. The peephole optimizer definition itself serves as the instruction
  4165. pattern to control how the instruction is output.
  4166. Defined peephole optimizers are run in the last jump optimization pass, so
  4167. the instructions they produce are never combined or rearranged
  4168. automatically in any way.
  4169. Here is an example, taken from the 68000 machine description:
  4170. @example
  4171. (define_peephole
  4172. [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
  4173. (set (match_operand:DF 0 "register_operand" "f")
  4174. (match_operand:DF 1 "register_operand" "ad"))]
  4175. "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  4176. "*
  4177. @{
  4178. rtx xoperands[2];
  4179. xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  4180. #ifdef MOTOROLA
  4181. output_asm_insn (\"move.l %1,(sp)\", xoperands);
  4182. output_asm_insn (\"move.l %1,-(sp)\", operands);
  4183. return \"fmove.d (sp)+,%0\";
  4184. #else
  4185. output_asm_insn (\"movel %1,sp@@\", xoperands);
  4186. output_asm_insn (\"movel %1,sp@@-\", operands);
  4187. return \"fmoved sp@@+,%0\";
  4188. #endif
  4189. @}
  4190. ")
  4191. @end example
  4192. The effect of this optimization is to change
  4193. @example
  4194. jbsr _foobar
  4195. addql #4,sp
  4196. movel d1,sp@@-
  4197. movel d0,sp@@-
  4198. fmoved sp@@+,fp0
  4199. @end example
  4200. @noindent
  4201. into
  4202. @example
  4203. jbsr _foobar
  4204. movel d1,sp@@
  4205. movel d0,sp@@-
  4206. fmoved sp@@+,fp0
  4207. @end example
  4208. @node Expander Definitions,, Peephole Definitions, Machine Desc
  4209. @section Defining RTL Sequences for Code Generation
  4210. On some target machines, some standard pattern names for RTL generation
  4211. cannot be handled with single insn, but a sequence of RTL insns can
  4212. represent them. For these target machines, you can write a
  4213. @samp{define_expand} to specify how to generate the sequence of RTL.
  4214. A @samp{define_expand} is an RTL expression that looks almost like a
  4215. @samp{define_insn}; but, unlike the latter, a @samp{define_expand} is used
  4216. only for RTL generation and it can produce more than one RTL insn.
  4217. A @samp{define_expand} RTX has four operands:
  4218. @itemize @bullet
  4219. @item
  4220. The name. Each @samp{define_expand} must have a name, since the only
  4221. use for it is to refer to it by name.
  4222. @item
  4223. The RTL template. This is just like the RTL template for a
  4224. @samp{define_peephole} in that it is a vector of RTL expressions
  4225. each being one insn.
  4226. @item
  4227. The condition, a string containing a C expression. This expression is
  4228. used to express how the availability of this pattern depends on
  4229. subclasses of target machine, selected by command-line options when
  4230. GNU CC is run. This is just like the condition of a
  4231. @samp{define_insn} that has a standard name.
  4232. @item
  4233. The preparation statements, a string containing zero or more C
  4234. statements which are to be executed before RTL code is generated from
  4235. the RTL template.
  4236. Usually these statements prepare temporary registers for use as
  4237. internal operands in the RTL template, but they can also generate RTL
  4238. insns directly by calling routines such as @samp{emit_insn}, etc.
  4239. Any such insns precede the ones that come from the RTL template.
  4240. @end itemize
  4241. The RTL template, in addition to controlling generation of RTL insns,
  4242. also describes the operands that need to be specified when this pattern
  4243. is used. In particular, it gives a predicate for each operand.
  4244. A true operand, which need to be specified in order to generate RTL from
  4245. the pattern, should be described with a @samp{match_operand} in its first
  4246. occurrence in the RTL template. This enters information on the operand's
  4247. predicate into the tables that record such things. GNU CC uses the
  4248. information to preload the operand into a register if that is required for
  4249. valid RTL code. If the operand is referred to more than once, subsequent
  4250. references should use @samp{match_dup}.
  4251. The RTL template may also refer to internal ``operands'' which are
  4252. temporary registers or labels used only within the sequence made by the
  4253. @samp{define_expand}. Internal operands are substituted into the RTL
  4254. template with @samp{match_dup}, never with @samp{match_operand}. The
  4255. values of the internal operands are not passed in as arguments by the
  4256. compiler when it requests use of this pattern. Instead, they are computed
  4257. within the pattern, in the preparation statements. These statements
  4258. compute the values and store them into the appropriate elements of
  4259. @code{operands} so that @samp{match_dup} can find them.
  4260. There are two special macros defined for use in the preparation statements:
  4261. @code{DONE} and @code{FAIL}. Use them with a following semicolon,
  4262. as a statement.
  4263. @table @code
  4264. @item DONE
  4265. Use the @code{DONE} macro to end RTL generation for the pattern. The
  4266. only RTL insns resulting from the pattern on this occasion will be
  4267. those already emitted by explicit calls to @code{emit_insn} within the
  4268. preparation statements; the RTL template will not be generated.
  4269. @item FAIL
  4270. Make the pattern fail on this occasion. When a pattern fails, it means
  4271. that the pattern was not truly available. The calling routines in the
  4272. compiler will try other strategies for code generation using other patterns.
  4273. Failure is currently supported only for binary operations (addition,
  4274. multiplication, shifting, etc.).
  4275. Do not emit any insns explicitly with @code{emit_insn} before failing.
  4276. @end table
  4277. Here is an example, the definition of left-shift for the SPUR chip:
  4278. @example
  4279. (define_expand "ashlsi3"
  4280. [(set (match_operand:SI 0 "register_operand" "")
  4281. (ashift:SI
  4282. (match_operand:SI 1 "register_operand" "")
  4283. (match_operand:SI 2 "nonmemory_operand" "")))]
  4284. ""
  4285. "
  4286. @{
  4287. if (GET_CODE (operands[2]) != CONST_INT
  4288. || (unsigned) INTVAL (operands[2]) > 3)
  4289. FAIL;
  4290. @}")
  4291. @end example
  4292. @noindent
  4293. This example uses @samp{define_expand} so that it can generate an RTL insn
  4294. for shifting when the shift-count is in the supported range of 0 to 3 but
  4295. fail in other cases where machine insns aren't available. When it fails,
  4296. the compiler tries another strategy using different patterns (such as, a
  4297. library call).
  4298. If the compiler were able to handle nontrivial condition-strings in
  4299. patterns with names, then there would be possible to use a
  4300. @samp{define_insn} in that case. Here is another case (zero-extension on
  4301. the 68000) which makes more use of the power of @samp{define_expand}:
  4302. @example
  4303. (define_expand "zero_extendhisi2"
  4304. [(set (match_operand:SI 0 "general_operand" "")
  4305. (const_int 0))
  4306. (set (strict_low_part
  4307. (subreg:HI
  4308. (match_operand:SI 0 "general_operand" "")
  4309. 0))
  4310. (match_operand:HI 1 "general_operand" ""))]
  4311. ""
  4312. "operands[1] = make_safe_from (operands[1], operands[0]);")
  4313. @end example
  4314. @noindent
  4315. Here two RTL insns are generated, one to clear the entire output operand
  4316. and the other to copy the input operand into its low half. This sequence
  4317. is incorrect if the input operand refers to [the old value of] the output
  4318. operand, so the preparation statement makes sure this isn't so. The
  4319. function @code{make_safe_from} copies the @code{operands[1]} into a
  4320. temporary register if it refers to @code{operands[0]}. It does this
  4321. by emitting another RTL insn.
  4322. Finally, a third example shows the use of an internal operand.
  4323. Zero-extension on the SPUR chip is done by @samp{and}-ing the result
  4324. against a halfword mask. But this mask cannot be represented by a
  4325. @samp{const_int} because the constant value is too large to be legitimate
  4326. on this machine. So it must be copied into a register with
  4327. @code{force_reg} and then the register used in the @samp{and}.
  4328. @example
  4329. (define_expand "zero_extendhisi2"
  4330. [(set (match_operand:SI 0 "register_operand" "")
  4331. (and:SI (subreg:SI
  4332. (match_operand:HI 1 "register_operand" "")
  4333. 0)
  4334. (match_dup 2)))]
  4335. ""
  4336. "operands[2]
  4337. = force_reg (SImode, gen_rtx (CONST_INT,
  4338. VOIDmode, 65535)); ")
  4339. @end example
  4340. @node Machine Macros, Config, Machine Desc, Top
  4341. @chapter Machine Description Macros
  4342. The other half of the machine description is a C header file conventionally
  4343. given the name @file{tm-@var{machine}.h}. The file @file{tm.h} should be a
  4344. link to it. The header file @file{config.h} includes @file{tm.h} and most
  4345. compiler source files include @file{config.h}.
  4346. @menu
  4347. * Run-time Target:: Defining -m options like -m68000 and -m68020.
  4348. * Storage Layout:: Defining sizes and alignments of data types.
  4349. * Registers:: Naming and describing the hardware registers.
  4350. * Register Classes:: Defining the classes of hardware registers.
  4351. * Stack Layout:: Defining which way the stack grows and by how much.
  4352. * Library Names:: Specifying names of subroutines to call automatically.
  4353. * Addressing Modes:: Defining addressing modes valid for memory operands.
  4354. * Condition Code:: Defining how insns update the condition code.
  4355. * Assembler Format:: Defining how to write insns and pseudo-ops to output.
  4356. * Misc:: Everything else.
  4357. @end menu
  4358. @node Run-time Target, Storage Layout, Machine Macros, Machine Macros
  4359. @section Run-time Target Specification
  4360. @table @code
  4361. @item CPP_PREDEFINES
  4362. Define this to be a string constant containing @samp{-D} options
  4363. to define the predefined macros that identify this machine and system.
  4364. For example, on the Sun, one can use the value
  4365. @example
  4366. "-Dmc68000 -Dsun -Dunix"
  4367. @end example
  4368. @item extern int target_flags;
  4369. This declaration should be present.
  4370. @item TARGET_@dots{}
  4371. This series of macros is to allow compiler command arguments to
  4372. enable or disable the use of optional features of the target machine.
  4373. For example, one machine description serves both the 68000 and
  4374. the 68020; a command argument tells the compiler whether it should
  4375. use 68020-only instructions or not. This command argument works
  4376. by means of a macro @code{TARGET_68020} that tests a bit in
  4377. @code{target_flags}.
  4378. Define a macro @code{TARGET_@var{featurename}} for each such option.
  4379. Its definition should test a bit in @code{target_flags}; for example:
  4380. @example
  4381. #define TARGET_68020 (target_flags & 1)
  4382. @end example
  4383. One place where these macros are used is in the condition-expressions
  4384. of instruction patterns. Note how @code{TARGET_68020} appears
  4385. frequently in the 68000 machine description file, @file{m68k.md}.
  4386. Another place they are used is in the definitions of the other
  4387. macros in the @file{tm-@var{machine}.h} file.
  4388. @item TARGET_SWITCHES
  4389. This macro defines names of command options to set and clear
  4390. bits in @code{target_flags}. Its definition is an initializer
  4391. with a subgrouping for each command option.
  4392. Each subgrouping contains a string constant, that defines the option
  4393. name, and a number, which contains the bits to set in
  4394. @code{target_flags}. A negative number says to clear bits instead;
  4395. the negative of the number is which bits to clear. The actual option
  4396. name is made by appending @samp{-m} to the specified name.
  4397. One of the subgroupings should have a null string. The number in
  4398. this grouping is the default value for @code{target_flags}. Any
  4399. target options act starting with that value.
  4400. Here is an example which defines @samp{-m68000} and @samp{-m68020}
  4401. with opposite meanings, and picks the latter as the default:
  4402. @example
  4403. #define TARGET_SWITCHES \
  4404. @{ @{ "68020", 1@}, \
  4405. @{ "68000", -1@}, \
  4406. @{ "", 1@}@}
  4407. @end example
  4408. @end table
  4409. Sometimes certain combinations of command options do not make sense on a
  4410. particular target machine. You can define a macro @code{OVERRIDE_OPTIONS}
  4411. to take account of this. This macro, if defined, is executed once
  4412. just after all the command options have been parsed.
  4413. @node Storage Layout, Registers, Run-time Target, Machine Macros
  4414. @section Storage Layout
  4415. Note that the definitions of the macros in this table which are sizes or
  4416. alignments measured in bits do not need to be constant. They can be C
  4417. expressions that refer to static variables, such as the @code{target_flags}.
  4418. @xref{Run-time Target}.
  4419. @table @code
  4420. @item BITS_BIG_ENDIAN
  4421. Define this macro if the most significant bit in a byte has the lowest
  4422. number. This means that bit-field instructions count from the most
  4423. significant bit. If the machine has no bit-field instructions, this
  4424. macro is irrelevant.
  4425. @item BYTES_BIG_ENDIAN
  4426. Define this macro if the most significant byte in a word has the
  4427. lowest number.
  4428. @item WORDS_BIG_ENDIAN
  4429. Define this macro if, in a multiword object, the most significant
  4430. word has the lowest number.
  4431. @item BITS_PER_UNIT
  4432. Number of bits in an addressable storage unit (byte); normally 8.
  4433. @item BITS_PER_WORD
  4434. Number of bits in a word; normally 32.
  4435. @item UNITS_PER_WORD
  4436. Number of storage units in a word; normally 4.
  4437. @item POINTER_SIZE
  4438. Width of a pointer, in bits.
  4439. @item PARM_BOUNDARY
  4440. Alignment required for function parameters on the stack, in bits.
  4441. @item STACK_BOUNDARY
  4442. Define this macro if you wish to preserve a certain alignment for
  4443. the stack pointer at all times. The definition is a C expression
  4444. for the desired alignment (measured in bits).
  4445. @item FUNCTION_BOUNDARY
  4446. Alignment required for a function entry point, in bits.
  4447. @item BIGGEST_ALIGNMENT
  4448. Biggest alignment that any data type can require on this machine, in bits.
  4449. @item EMPTY_FIELD_ALIGNMENT
  4450. Alignment in bits to be given to a structure bit field that follows an
  4451. empty field such as @code{int : 0;}.
  4452. @item STRUCTURE_SIZE_BOUNDARY
  4453. Number of bits which any structure or union's size must be a multiple of.
  4454. Each structure or union's size is rounded up to a multiple of this.
  4455. If you do not define this macro, the default is the same as
  4456. @code{BITS_PER_UNIT}.
  4457. @item STRICT_ALIGNMENT
  4458. Define this if instructions will fail to work if given data not
  4459. on the nominal alignment. If instructions will merely go slower
  4460. in that case, do not define this macro.
  4461. @end table
  4462. @node Registers, Register Classes, Storage Layout, Machine Macros
  4463. @section Register Usage
  4464. @table @code
  4465. @item FIRST_PSEUDO_REGISTER
  4466. Number of hardware registers known to the compiler. They receive
  4467. numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
  4468. pseudo register's number really is assigned the number
  4469. @code{FIRST_PSEUDO_REGISTER}.
  4470. @item FIXED_REGISTERS
  4471. An initializer that says which registers are used for fixed purposes
  4472. all throughout the compiled code and are therefore not available for
  4473. general allocation. These would include the stack pointer, the frame
  4474. pointer, the program counter on machines where that is considered one
  4475. of the addressable registers, and any other numbered register with a
  4476. standard use.
  4477. This information is expressed as a sequence of numbers, separated by
  4478. commas and surrounded by braces. The @var{n}th number is 1 if
  4479. register @var{n} is fixed, 0 otherwise.
  4480. The table initialized from this macro, and the table initialized by
  4481. the following one, may be overridden at run time either automatically,
  4482. by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
  4483. the user with the command options @samp{-ffixed-@var{reg}},
  4484. @samp{-fcall-used-@var{reg}} and @samp{-fcall-saved-@var{reg}}.
  4485. @item CALL_USED_REGISTERS
  4486. Like @code{FIXED_REGISTERS} but has 1 for each register that is
  4487. clobbered (in general) by function calls as well as for fixed
  4488. registers. This macro therefore identifies the registers that are not
  4489. available for general allocation of values that must live across
  4490. function calls.
  4491. If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
  4492. automatically saves it on function entry and restores it on function
  4493. exit, if the register is used within the function.
  4494. @item CONDITIONAL_REGISTER_USAGE
  4495. Zero or more C statements that may conditionally modify two variables
  4496. @code{fixed_regs} and @code{call_used_regs} (both of type @code{char
  4497. []}) after they have been initialized from the two preceding macros.
  4498. This is necessary in case the fixed or call-clobbered registers depend
  4499. on target flags.
  4500. You need not define this macro if it has no work to do.
  4501. @item HARD_REGNO_REGS (@var{regno}, @var{mode})
  4502. A C expression for the number of consecutive hard registers, starting
  4503. at register number @var{regno}, required to hold a value of mode
  4504. @var{mode}.
  4505. On a machine where all registers are exactly one word, a suitable
  4506. definition of this macro is
  4507. @example
  4508. #define HARD_REGNO_NREGS(REGNO, MODE) \
  4509. ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
  4510. / UNITS_PER_WORD))
  4511. @end example
  4512. @item HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
  4513. A C expression that is nonzero if it is permissible to store a value
  4514. of mode @var{mode} in hard register number @var{regno} (or in several
  4515. registers starting with that one). For a machine where all registers
  4516. are equivalent, a suitable definition is
  4517. @example
  4518. #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
  4519. @end example
  4520. It is not necessary for this macro to check for fixed register numbers
  4521. because the allocation mechanism considers them to be always occupied.
  4522. Many machines have special registers for floating point arithmetic.
  4523. Often people assume that floating point machine modes are allowed only
  4524. in floating point registers. This is not true. Any registers that
  4525. can hold integers can safely @emph{hold} a floating point machine
  4526. mode, whether or not floating arithmetic can be done on it in those
  4527. registers.
  4528. The true significance of special floating registers is rather than
  4529. non-floating-point machine modes @emph{may not} go in those registers.
  4530. This is true if the floating registers normalize any value stored in
  4531. them, because storing a non-floating value there would garble it. If
  4532. the floating registers do not automatically normalize, if you can
  4533. store any bit pattern in one and retrieve it unchanged without a trap,
  4534. then any machine mode may go in a floating register and this macro
  4535. should say so.
  4536. Sometimes there are floating registers that are especially slow to
  4537. access, so that it is better to store a value in a stack frame than in
  4538. such a register if floating point arithmetic is not being done. As long
  4539. as the floating registers are not in class @code{GENERAL_REGS}, they
  4540. will not be used unless some insn's constraint asks for one.
  4541. It is obligatory to support floating point `move' instructions into
  4542. and out of general registers, because unions and structures (which
  4543. have modes @samp{SImode} or @samp{DImode}) can be in those registers
  4544. and they may have floating point members.
  4545. @item MODES_TIEABLE_P (@var{mode1}, @var{mode2})
  4546. A C expression that is nonzero if it is desirable to choose register
  4547. allocation so as to avoid move instructions between a value of mode
  4548. @var{mode1} and a value of mode @var{mode2}.
  4549. If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
  4550. @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are ever different
  4551. for any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1},
  4552. @var{mode2})} must be zero.
  4553. @item PC_REGNUM
  4554. If the program counter has a register number, define this as that
  4555. register number. Otherwise, do not define it.
  4556. @item STACK_POINTER_REGNUM
  4557. The register number of the stack pointer register, which must also be
  4558. a fixed register according to @code{FIXED_REGISTERS}. On many
  4559. machines, the hardware determines which register this is.
  4560. @item FRAME_POINTER_REGNUM
  4561. The register number of the frame pointer register, which is used to
  4562. access automatic variables in the stack frame. On some machines, the
  4563. hardware determines which register this is. On other machines, you
  4564. can choose any register you wish for this purpose.
  4565. @item FRAME_POINTER_REQUIRED
  4566. A C expression which is nonzero if a function must have and use a
  4567. frame pointer. This expression is evaluated in the reload pass, in
  4568. the function @code{reload}, and it can in principle examine the
  4569. current function and decide according to the facts, but on most
  4570. machines the constant 0 or the constant 1 suffices. Use 0 when the
  4571. machine allows code to be generated with no frame pointer, and doing
  4572. so saves some time or space. Use 1 when there is no possible
  4573. advantage to avoiding a frame pointer.
  4574. In certain cases, the compiler does not know how to do without a frame
  4575. pointer. The compiler recognizes those cases and automatically gives
  4576. the function a frame pointer regardless of what
  4577. @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about
  4578. them.@refill
  4579. In a function that does not require a frame pointer, the frame pointer
  4580. register can be allocated for ordinary usage, provided it is not
  4581. marked as a fixed register. See @code{FIXED_REGISTERS} for more
  4582. information.
  4583. @item ARG_POINTER_REGNUM
  4584. The register number of the arg pointer register, which is used to
  4585. access the function's argument list. On some machines, this is the
  4586. same as the frame pointer register. On some machines, the hardware
  4587. determines which register this is. On other machines, you can choose
  4588. any register you wish for this purpose. It must in any case be a
  4589. fixed register according to @code{FIXED_REGISTERS}.
  4590. @item STATIC_CHAIN_REGNUM
  4591. The register number used for passing a function's static chain
  4592. pointer. This is needed for languages such as Pascal and Algol where
  4593. functions defined within other functions can access the local
  4594. variables of the outer functions; it is not currently used because C
  4595. does not provide this feature.
  4596. The static chain register need not be a fixed register.
  4597. @item STRUCT_VALUE_REGNUM
  4598. When a function's value's mode is @code{BLKmode}, the value is not
  4599. returned according to @code{FUNCTION_VALUE}. Instead, the caller
  4600. passes the address of a block of memory in which the value should be
  4601. stored. @code{STRUCT_VALUE_REGNUM} is the register in which this
  4602. address is passed.
  4603. @end table
  4604. @node Register Classes, Stack Layout, Registers, Machine Macros
  4605. @section Register Classes
  4606. On many machines, the numbered registers are not all equivalent.
  4607. For example, certain registers may not be allowed for indexed addressing;
  4608. certain registers may not be allowed in some instructions. These machine
  4609. restrictions are described to the compiler using @dfn{register classes}.
  4610. You define a number of register classes, giving each one a name and saying
  4611. which of the registers belong to it. Then you can specify register classes
  4612. that are allowed as operands to particular instruction patterns.
  4613. In general, each register will belong to several classes. In fact, one
  4614. class must be named @code{ALL_REGS} and contain all the registers. Another
  4615. class must be named @code{NO_REGS} and contain no registers. Often the
  4616. union of two classes will be another class; however, this is not required.
  4617. One of the classes must be named @code{GENERAL_REGS}. There is nothing
  4618. terribly special about the name, but the operand constraint letters
  4619. @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
  4620. the same as @code{ALL_REGS}, just define it as a macro which expands
  4621. to @code{ALL_REGS}.
  4622. The way classes other than @code{GENERAL_REGS} are specified in operand
  4623. constraints is through machine-dependent operand constraint letters.
  4624. You can define such letters to correspond to various classes, then use
  4625. them in operand constraints.
  4626. You should define a class for the union of two classes whenever some
  4627. instruction allows both classes. For example, if an instruction allows
  4628. either a floating-point (coprocessor) register or a general register for a
  4629. certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
  4630. which includes both of them. Otherwise you will get suboptimal code.
  4631. You must also specify certain redundant information about the register
  4632. classes: for each class, which classes contain it and which ones are
  4633. contained in it; for each pair of classes, the largest class contained
  4634. in their union.
  4635. @table @code
  4636. @item enum reg_class
  4637. An enumeral type that must be defined with all the register class names
  4638. as enumeral values. @code{NO_REGS} must be first. @code{ALL_REGS}
  4639. must be the last register class, followed by one more enumeral value,
  4640. @code{LIM_REG_CLASSES}, which is not a register class but rather
  4641. tells how many classes there are.
  4642. Each register class has a number, which is the value of casting
  4643. the class name to type @code{int}. The number serves as an index
  4644. in many of the tables described below.
  4645. @item REG_CLASS_NAMES
  4646. An initializer containing the names of the register classes as C string
  4647. constants. These names are used in writing some of the debugging dumps.
  4648. @item REG_CLASS_CONTENTS
  4649. An initializer containing the contents of the register classes, as integers
  4650. which are bit masks. The @var{n}th integer specifies the contents of class
  4651. @var{n}. The way the integer @var{mask} is interpreted is that
  4652. register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
  4653. When the machine has more than 32 registers, an integer does not suffice.
  4654. Then the integers are replaced by sub-initializers, braced groupings containing
  4655. several integers. Each sub-initializer must be suitable as an initializer
  4656. for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
  4657. @item REGNO_REG_CLASS (@var{regno})
  4658. A C expression whose value is a register class containing hard register
  4659. @var{regno}. In general there is more that one such class; choose a class
  4660. which is @dfn{minimal}, meaning that no smaller class also contains the
  4661. register.
  4662. @item INDEX_REG_CLASS
  4663. A macro whose definition is the name of the class to which a valid index
  4664. register must belong.
  4665. @item REG_CLASS_FROM_LETTER (@var{char})
  4666. A C expression which defines the machine-dependent operand constraint
  4667. letters for register classes. If @var{char} is such a letter, the value
  4668. should be the register class corresponding to it. Otherwise, the value
  4669. should be @code{NO_REGS}.
  4670. @item REGNO_OK_FOR_BASE_P (@var{num})
  4671. A C expression which is nonzero if register number @var{num} is
  4672. suitable for use as a base register in operand addresses. It may be
  4673. either a suitable hard register or a pseudo register that has been
  4674. allocated such a hard register.
  4675. @item REGNO_OK_FOR_INDEX_P (@var{num})
  4676. A C expression which is nonzero if register number @var{num} is
  4677. suitable for use as an index register in operand addresses. It may be
  4678. either a suitable hard register or a pseudo register that has been
  4679. allocated such a hard register.
  4680. The difference between an index register and a base register is that
  4681. the index register may be scaled. If an address involves the sum of
  4682. two registers, neither one of them scaled, then either one may be
  4683. labeled the ``base'' and the other the ``index''; but whichever
  4684. labeling is used must fit the machine's constraints of which registers
  4685. may serve in each capacity. The compiler will try both labelings,
  4686. looking for one that is valid, and reload one or both registers only
  4687. if neither labeling works.
  4688. @item PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
  4689. A C expression that places additional restrictions on the register class
  4690. to use when it is necessary to copy value @var{x} into a register in class
  4691. @var{class}. The value is a register class; perhaps @var{class}, or perhaps
  4692. another, smaller class. @var{class} is always safe as a value. In fact,
  4693. the definition
  4694. @example
  4695. #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
  4696. @end example
  4697. @noindent
  4698. is always safe. However, sometimes returning a more restrictive class
  4699. makes better code. For example, on the 68000, when @var{x} is an
  4700. integer constant that is in range for a @samp{moveq} instruction,
  4701. the value of this macro is always @code{DATA_REGS} as long as
  4702. @var{class} includes the data registers. Requiring a data register
  4703. guarantees that a @samp{moveq} will be used.
  4704. @item CLASS_MAX_NREGS (@var{class}, @var{mode})
  4705. A C expression for the maximum number of consecutive registers
  4706. of class @var{class} needed to hold a value of mode @var{mode}.
  4707. This is closely related to the macro @code{HARD_REGNO_NREGS}.
  4708. In fact, the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
  4709. should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno}, @var{mode})}
  4710. for all @var{regno} values in the class @var{class}.
  4711. This macro helps control the handling of multiple-word values
  4712. in the reload pass.
  4713. @end table
  4714. Two other special macros describe which constants fit which constraint
  4715. letters.
  4716. @table @code
  4717. @item CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
  4718. A C expression that defines the machine-dependent operand constraint letters
  4719. that specify particular ranges of integer values. If @var{c} is one
  4720. of those letters, the expression should check that @var{value}, an integer,
  4721. is in the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
  4722. not one of those letters, the value should be 0 regardless of @var{value}.
  4723. @item CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
  4724. A C expression that defines the machine-dependent operand constraint
  4725. letters that specify particular ranges of floating values. If @var{c} is
  4726. one of those letters, the expression should check that @var{value}, an RTX
  4727. of code @samp{const_double}, is in the appropriate range and return 1 if
  4728. so, 0 otherwise. If @var{c} is not one of those letters, the value should
  4729. be 0 regardless of @var{value}.
  4730. @end table
  4731. @node Stack Layout, Library Names, Register Classes, Machine Macros
  4732. @section Describing Stack Layout
  4733. @table @code
  4734. @item STACK_GROWS_DOWNWARD
  4735. Define this macro if pushing a word onto the stack moves the stack
  4736. pointer to a smaller address.
  4737. When we say, ``define this macro if @dots{},'' it means that the
  4738. compiler checks this macro only with @code{#ifdef} so the precise
  4739. definition used does not matter.
  4740. @item FRAME_GROWS_DOWNWARD
  4741. Define this macro if the addresses of local variable slots are at negative
  4742. offsets from the frame pointer.
  4743. @item STARTING_FRAME_OFFSET
  4744. Offset from the frame pointer to the first local variable slot to be allocated.
  4745. If @code{FRAME_GROWS_DOWNWARD}, the next slot's offset is found by
  4746. subtracting the length of the first slot from @code{STARTING_FRAME_OFFSET}.
  4747. Otherwise, it is found by adding the length of the first slot to
  4748. the value @code{STARTING_FRAME_OFFSET}.
  4749. @item PUSH_ROUNDING (@var{npushed})
  4750. A C expression that is the number of bytes actually pushed onto the
  4751. stack when an instruction attempts to push @var{npushed} bytes.
  4752. If the target machine does not have a push instruction, do not define
  4753. this macro. That directs GNU CC to use an alternate strategy: to
  4754. allocate the entire argument block and then store the arguments into
  4755. it.
  4756. On some machines, the definition
  4757. @example
  4758. #define PUSH_ROUNDING(BYTES) (BYTES)
  4759. @end example
  4760. @noindent
  4761. will suffice. But on other machines, instructions that appear
  4762. to push one byte actually push two bytes in an attempt to maintain
  4763. alignment. Then the definition should be
  4764. @example
  4765. #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
  4766. @end example
  4767. @item FIRST_PARM_OFFSET
  4768. Offset from the argument pointer register to the first argument's address.
  4769. @item RETURN_POPS_ARGS (@var{funtype})
  4770. A C expression that should be 1 if a function pops its own arguments
  4771. on returning, or 0 if the function pops no arguments and the caller
  4772. must therefore pop them all after the function returns.
  4773. @var{funtype} is a C variable whose value is a tree node that
  4774. describes the function in question. Normally it is a node of type
  4775. @code{FUNCTION_TYPE} that describes the data type of the function.
  4776. From this it is possible to obtain the data types of the value and
  4777. arguments (if known).
  4778. When a call to a library function is being considered, @var{funtype}
  4779. will contain an identifier node for the library function. Thus, if
  4780. you need to distinguish among various library functions, you can do so
  4781. by their names. Note that ``library function'' in this context means
  4782. a function used to perform arithmetic, whose name is known specially
  4783. in the compiler and was not mentioned in the C code being compiled.
  4784. On the Vax, all functions always pop their arguments, so the
  4785. definition of this macro is 1. On the 68000, using the standard
  4786. calling convention, no functions pop their arguments, so the value of
  4787. the macro is always 0 in this case. But an alternative calling
  4788. convention is available in which functions that take a fixed number of
  4789. arguments pop them but other functions (such as @code{printf}) pop
  4790. nothing (the caller pops all). When this convention is in use,
  4791. @var{funtype} is examined to determine whether a function takes a
  4792. fixed number of arguments.
  4793. @item FUNCTION_VALUE (@var{valtype}, @var{func})
  4794. A C expression to create an RTX representing the place where a
  4795. function returns a value of data type @var{valtype}. @var{valtype} is
  4796. a tree node representing a data type. Write @code{TYPE_MODE
  4797. (@var{valtype})} to get the machine mode used to represent that type.
  4798. On many machines, only the mode is relevant. (Actually, on most
  4799. machines, scalar values are returned in the same place regardless of
  4800. mode).@refill
  4801. If the precise function being called is known, @var{func} is a tree
  4802. node (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
  4803. pointer. This makes it possible to use a different value-returning
  4804. convention for specific functions when all their calls are
  4805. known.@refill
  4806. @item FUNCTION_OUTGOING_VALUE (@var{valtype}, @var{func})
  4807. Define this macro if the target machine has ``register windows''
  4808. so that the register in which a function returns its value is not
  4809. the same as the one in which the caller sees the value.
  4810. For such machines, @code{FUNCTION_VALUE} computes the register in
  4811. which the caller will see the value, and
  4812. @code{FUNCTION_OUTGOING_VALUE} should be defined in a similar fashion
  4813. to tell the function where to put the value.@refill
  4814. If @code{FUNCTION_OUTGOING_VALUE} is not defined,
  4815. @code{FUNCTION_VALUE} serves both purposes.@refill
  4816. @item LIBCALL_VALUE (@var{mode})
  4817. A C expression to create an RTX representing the place where a library
  4818. function returns a value of mode @var{mode}. If the precise function
  4819. being called is known, @var{func} is a tree node
  4820. (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
  4821. pointer. This makes it possible to use a different value-returning
  4822. convention for specific functions when all their calls are
  4823. known.@refill
  4824. Note that ``library function'' in this context means a compiler
  4825. support routine, used to perform arithmetic, whose name is known
  4826. specially by the compiler and was not mentioned in the C code being
  4827. compiled.
  4828. @item FUNCTION_VALUE_REGNO_P (@var{regno})
  4829. A C expression that is nonzero if @var{regno} is the number of a hard
  4830. register in which function values are sometimes returned.
  4831. A register whose use for returning values is limited to serving as the
  4832. second of a pair (for a value of type @code{double}, say) need not be
  4833. recognized by this macro. So for most machines, this definition
  4834. suffices:
  4835. @example
  4836. #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
  4837. @end example
  4838. @item FUNCTION_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
  4839. A C expression that controls whether a function argument is passed
  4840. in a register, and which register.
  4841. The arguments are @var{cum}, which summarizes all the previous
  4842. arguments; @var{mode}, the machine mode of the argument; @var{type},
  4843. the data type of the argument as a tree node or 0 if that is not known
  4844. (which happens for C support library functions); and @var{named},
  4845. which is 1 for an ordinary argument and 0 for nameless arguments that
  4846. correspond to @samp{...} in the called function's prototype.
  4847. The value of the expression should either be a @samp{reg} RTX for the
  4848. hard register in which to pass the argument, or zero to pass the
  4849. argument on the stack.
  4850. For the Vax and 68000, where normally all arguments are pushed, zero
  4851. suffices as a definition.
  4852. @item FUNCTION_INCOMING_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
  4853. Define this macro if the target machine has ``register windows'', so
  4854. that the register in which a function sees an arguments is not
  4855. necessarily the same as the one in which the caller passed the
  4856. argument.
  4857. For such machines, @code{FUNCTION_ARG} computes the register in which
  4858. the caller passes the value, and @code{FUNCTION_INCOMING_ARG} should
  4859. be defined in a similar fashion to tell the function being called
  4860. where the arguments will arrive.
  4861. If @code{FUNCTION_INCOMING_ARG} is not defined, @code{FUNCTION_ARG}
  4862. serves both purposes.@refill
  4863. @item FUNCTION_ARG_PARTIAL_NREGS (@var{cum}, @var{mode}, @var{type}, @var{named})
  4864. A C expression for the number of words, at the beginning of an
  4865. argument, must be put in registers. The value must be zero for
  4866. arguments that are passed entirely in registers or that are entirely
  4867. pushed on the stack.
  4868. On some machines, certain arguments must be passed partially in
  4869. registers and partially in memory. On these machines, typically the
  4870. first @var{n} words of arguments are passed in registers, and the rest
  4871. on the stack. If a multi-word argument (a @code{double} or a
  4872. structure) crosses that boundary, its first few words must be passed
  4873. in registers and the rest must be pushed. This macro tells the
  4874. compiler when this occurs, and how many of the words should go in
  4875. registers.
  4876. @code{FUNCTION_ARG} for these arguments should return the first
  4877. register to be used by the caller for this argument; likewise
  4878. @code{FUNCTION_INCOMING_ARG}, for the called function.
  4879. @item CUMULATIVE_ARGS
  4880. A C type for declaring a variable that is used as the first argument
  4881. of @code{FUNCTION_ARG} and other related values. For some target
  4882. machines, the type @code{int} suffices and can hold the number of
  4883. bytes of argument so far.
  4884. @item INIT_CUMULATIVE_ARGS (@var{cum})
  4885. A C statement (sans semicolon) for initializing the variable @var{cum}
  4886. for the state at the beginning of the argument list. The variable has
  4887. type @code{CUMULATIVE_ARGS}.
  4888. @item FUNCTION_ARG_ADVANCE (@var{cum}, @var{mode}, @var{type}, @var{named})
  4889. Update the summarizer variable @var{cum} to advance past an argument
  4890. in the argument list. The values @var{mode}, @var{type} and
  4891. @var{named} describe that argument. Once this is done, the variable
  4892. @var{cum} is suitable for analyzing the @emph{following} argument
  4893. with @code{FUNCTION_ARG}, etc.@refill
  4894. @item FUNCTION_ARG_REGNO_P (@var{regno})
  4895. A C expression that is nonzero if @var{regno} is the number of a hard
  4896. register in which function arguments are sometimes passed. This does
  4897. @emph{not} include implicit arguments such as the static chain and
  4898. the structure-value address. On many machines, no registers can be
  4899. used for this purpose since all function arguments are pushed on the
  4900. stack.
  4901. @item FUNCTION_PROLOGUE (@var{file}, @var{size})
  4902. A C compound statement that outputs the assembler code for entry to a
  4903. function. The prologue is responsible for setting up the stack frame,
  4904. initializing the frame pointer register, saving registers that must be
  4905. saved, and allocating @var{size} additional bytes of storage for the
  4906. local variables. @var{size} is an integer. @var{file} is a stdio
  4907. stream to which the assembler code should be output.
  4908. The label for the beginning of the function need not be output by this
  4909. macro. That has already been done when the macro is run.
  4910. To determine which registers to save, the macro can refer to the array
  4911. @code{regs_ever_live}: element @var{r} is nonzero if hard register
  4912. @var{r} is used anywhere within the function. This implies the
  4913. function prologue should save register @var{r}, but not if it is one
  4914. of the call-used registers.
  4915. On machines where functions may or may not have frame-pointers, the
  4916. function entry code must vary accordingly; it must set up the frame
  4917. pointer if one is wanted, and not otherwise. To determine whether a
  4918. frame pointer is in wanted, the macro can refer to the variable
  4919. @code{frame_pointer_needed}. The variable's value will be 1 at run
  4920. time in a function that needs a frame pointer.
  4921. @item FUNCTION_PROFILER (@var{file}, @var{labelno})
  4922. A C statement or compound statement to output to @var{file} some
  4923. assembler code to call the profiling subroutine @code{mcount}.
  4924. Before calling, the assembler code must load the address of a
  4925. counter variable into a register where @code{mcount} expects to
  4926. find the address. The name of this variable is @samp{LP} followed
  4927. by the number @var{labelno}, so you would generate the name using
  4928. @samp{LP%d} in a @code{fprintf}.
  4929. The details of how the address should be passed to @code{mcount} are
  4930. determined by your operating system environment, not by GNU CC. To
  4931. figure them out, compile a small program for profiling using the
  4932. system's installed C compiler and look at the assembler code that
  4933. results.
  4934. @item EXIT_IGNORES_STACK
  4935. Define this macro as a C expression that is nonzero if the return
  4936. instruction or the function epilogue ignores the value of the stack
  4937. pointer; in other words, if it is safe to delete an instruction to
  4938. adjust the stack pointer before a return from the function.
  4939. Note that this macro's value is relevant only for for which frame
  4940. pointers are maintained. It is never possible to delete a final stack
  4941. adjustment in a function that has no frame pointer, and the compiler
  4942. knows this regardless of @code{EXIT_IGNORES_STACK}.
  4943. @item FUNCTION_EPILOGUE (@var{file}, @var{size})
  4944. A C compound statement that outputs the assembler code for exit from a
  4945. function. The epilogue is responsible for restoring the saved
  4946. registers and stack pointer to their values when the function was
  4947. called, and returning control to the caller. This macro takes the
  4948. same arguments as the macro @code{FUNCTION_PROLOGUE}, and the
  4949. registers to restore are determined from @code{regs_ever_live} and
  4950. @code{CALL_USED_REGISTERS} in the same way.
  4951. On some machines, there is a single instruction that does all the work
  4952. of returning from the function. On these machines, give that
  4953. instruction the name @samp{return} and do not define the macro
  4954. @code{FUNCTION_EPILOGUE} at all.
  4955. On machines where functions may or may not have frame-pointers, the
  4956. function exit code must vary accordingly. Sometimes the code for
  4957. these two cases is completely different. To determine whether a frame
  4958. pointer is in wanted, the macro can refer to the variable
  4959. @code{frame_pointer_needed}. The variable's value will be 1 at run
  4960. time in a function that needs a frame pointer.
  4961. On some machines, some functions pop their arguments on exit while
  4962. others leave that for the caller to do. For example, the 68020 when
  4963. given @samp{-mrtd} pops arguments in functions that take a fixed
  4964. number of arguments.
  4965. Your definition of the macro @code{RETURN_POPS_ARGS} decides which
  4966. functions pop their own arguments. @code{FUNCTION_EPILOGUE} needs to
  4967. know what was decided. The variable @code{current_function_pops_args}
  4968. is nonzero if the function should pop its own arguments. If so, use
  4969. the variable @code{current_function_args_size} as the number of bytes
  4970. to pop.
  4971. @item FIX_FRAME_POINTER_ADDRESS (@var{addr}, @var{depth})
  4972. A C compound statement to alter a memory address that uses the frame
  4973. pointer register so that it uses the stack pointer register instead.
  4974. This must be done in the instructions that load parameter values into
  4975. registers, when the reload pass determines that a frame pointer is not
  4976. necessary for the function. @var{addr} will be a C variable name, and
  4977. the updated address should be stored in that variable. @var{depth}
  4978. will be the current depth of stack temporaries (number of bytes of
  4979. arguments currently pushed). The change in offset between a
  4980. frame-pointer-relative address and a stack-pointer-relative address
  4981. must include @var{depth}.
  4982. Even if your machine description specifies there will always be a
  4983. frame pointer in the frame pointer register, you must still define
  4984. @code{FIX_FRAME_POINTER_ADDRESS}, but the definition will never be
  4985. executed at run time, so it may be empty.
  4986. @end table
  4987. @node Library Names, Addressing Modes, Stack Layout, Machine Macros
  4988. @section Library Subroutine Names
  4989. @table @code
  4990. @item UDIVSI3_LIBCALL
  4991. A C string constant giving the name of the function to call for
  4992. division of a full-word by a full-word. If you do not define this
  4993. macro, the default name is used, which is @code{_udivsi3}, a function
  4994. defined in @file{gnulib}.
  4995. @item UMODSI3_LIBCALL
  4996. A C string constant giving the name of the function to call for the
  4997. remainder in division of a full-word by a full-word. If you do not
  4998. define this macro, the default name is used, which is @code{_umodsi3},
  4999. a function defined in @file{gnulib}.
  5000. @item TARGET_MEM_FUNCTIONS
  5001. Define this macro if GNU CC should generate calls to the System V
  5002. (and ANSI C) library functions @code{memcpy} and @code{memset}
  5003. rather than the BSD functions @code{bcopy} and @code{bzero}.
  5004. @end table
  5005. @node Addressing Modes, Misc, Library Names, Machine Macros
  5006. @section Addressing Modes
  5007. @table @code
  5008. @item HAVE_POST_INCREMENT
  5009. Define this macro if the machine supports post-increment addressing.
  5010. @item HAVE_PRE_INCREMENT
  5011. @itemx HAVE_POST_DECREMENT
  5012. @itemx HAVE_PRE_DECREMENT
  5013. Similar for other kinds of addressing.
  5014. @item CONSTANT_ADDRESS_P (@var{x})
  5015. A C expression that is 1 if the RTX @var{x} is a constant whose value
  5016. is an integer. This includes integers whose values are not explicitly
  5017. known, such as @samp{symbol_ref} and @samp{label_ref} expressions and
  5018. @samp{const} arithmetic expressions.
  5019. On most machines, this can be defined as @code{CONSTANT_P (@var{x})},
  5020. but a few machines are more restrictive in which constant addresses
  5021. are supported.
  5022. @item MAX_REGS_PER_ADDRESS
  5023. A number, the maximum number of registers that can appear in a valid
  5024. memory address.
  5025. @item GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label})
  5026. A C compound statement with a conditional @code{goto @var{label};}
  5027. executed if @var{x} (an RTX) is a legitimate memory address on the
  5028. target machine for a memory operand of mode @var{mode}.
  5029. It usually pays to define several simpler macros to serve as
  5030. subroutines for this one. Otherwise it may be too complicated to
  5031. understand.
  5032. This macro must exist in two variants: a strict variant and a
  5033. non-strict one. The strict variant is used in the reload pass. It
  5034. must be defined so that any pseudo-register that has not been
  5035. allocated a hard register is considered a memory reference. In
  5036. contexts where some kind of register is required, a pseudo-register
  5037. with no hard register must be rejected.
  5038. The non-strict variant is used in other passes. It must be defined to
  5039. accept all pseudo-registers in every context where some kind of
  5040. register is required.
  5041. Compiler source files that want to use the strict variant of this
  5042. macro define the macro @code{REG_OK_STRICT}. You should use an
  5043. @code{#ifdef REG_OK_STRICT} conditional to define the strict variant
  5044. in that case and the non-strict variant otherwise.
  5045. Typically among the subroutines used to define
  5046. @code{GO_IF_LEGITIMATE_ADDRESS} are subroutines to check for
  5047. acceptable registers for various purposes (one for base registers, one
  5048. for index registers, and so on). Then only these subroutine macros
  5049. need have two variants; the higher levels of macros may be the same
  5050. whether strict or not.@refill
  5051. @item LEGITIMIZE_ADDRESS (@var{x}, @var{oldx}, @var{mode}, @var{win})
  5052. A C compound statement that attempts to replace @var{x} with a valid
  5053. memory address for an operand of mode @var{mode}. @var{win} will be a
  5054. C statement label elsewhere in the code; the macro definition may use
  5055. @example
  5056. GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{win});
  5057. @end example
  5058. @noindent
  5059. to avoid further processing if the address has become legitimate.
  5060. @var{x} will always be the result of a call to @code{break_out_memory_refs},
  5061. and @var{oldx} will be the operand that was given to that function to produce
  5062. @var{x}.
  5063. The code generated by this macro should not alter the substructure of
  5064. @var{x}. If it transforms @var{x} into a more legitimate form, it
  5065. should assign @var{x} (which will always be a C variable) a new value.
  5066. It is not necessary for this macro to come up with a legitimate
  5067. address. The compiler has standard ways of doing so in all cases. In
  5068. fact, it is safe for this macro to do nothing. But often a
  5069. machine-dependent strategy can generate better code.
  5070. @item GO_IF_MODE_DEPENDENT_ADDRESS (@var{addr}, @var{label})
  5071. A C statement or compound statement with a conditional @code{goto
  5072. @var{label};} executed if memory address @var{x} (an RTX) can have
  5073. different meanings depending on the machine mode of the memory
  5074. reference it is used for.
  5075. Autoincrement and autodecrement addresses typically have mode-dependent
  5076. effects because the amount of the increment or decrement is the size
  5077. of the operand being addressed. Some machines have other mode-dependent
  5078. addresses. Many RISC machines have no mode-dependent addresses.
  5079. You may assume that @var{addr} is a valid address for the machine.
  5080. @item LEGITIMATE_CONSTANT_P (@var{x})
  5081. A C expression that is nonzero if @var{x} is a legitimate constant for
  5082. an immediate operand on the target machine. You can assume that
  5083. either @var{x} is a @samp{const_double} or it satisfies
  5084. @code{CONSTANT_P}, so you need not check these things. In fact,
  5085. @samp{1} is a suitable definition for this macro on machines where any
  5086. @samp{const_double} is valid and anything @code{CONSTANT_P} is valid.@refill
  5087. @end table
  5088. @node Misc, Condition Code, Addressing Modes, Machine Macros
  5089. @section Miscellaneous Parameters
  5090. @table @code
  5091. @item CASE_VECTOR_MODE
  5092. An alias for a machine mode name. This is the machine mode that
  5093. elements of a jump-table should have.
  5094. @item CASE_VECTOR_PC_RELATIVE
  5095. Define this macro if jump-tables should contain relative addresses.
  5096. @item CASE_DROPS_THROUGH
  5097. Define this if control falls through a @code{case} insn when the index
  5098. value is out of range. This means the specified default-label is
  5099. actually ignored by the @code{case} insn proper.
  5100. @item IMPLICIT_FIX_EXPR
  5101. An alias for a tree code that should be used by default for conversion
  5102. of floating point values to fixed point. Normally,
  5103. @code{FIX_ROUND_EXPR} is used.@refill
  5104. @item FIXUNS_TRUNC_LIKE_FIX_TRUNC
  5105. Define this macro if the same instructions that convert a floating
  5106. point number to a signed fixed point number also convert validly to an
  5107. unsigned one.
  5108. @item EASY_DIV_EXPR
  5109. An alias for a tree code that is the easiest kind of division to
  5110. compile code for in the general case. It may be
  5111. @code{TRUNC_DIV_EXPR}, @code{FLOOR_DIV_EXPR}, @code{CEIL_DIV_EXPR} or
  5112. @code{ROUND_DIV_EXPR}. These four division operators differ in how
  5113. they round the result to an integer. @code{EASY_DIV_EXPR} is used
  5114. when it is permissible to use any of those kinds of division and the
  5115. choice should be made on the basis of efficiency.@refill
  5116. @item DEFAULT_SIGNED_CHAR
  5117. An expression whose value is 1 or 0, according to whether the type
  5118. @code{char} should be signed or unsigned by default. The user can
  5119. always override this default with the options @samp{-fsigned-char}
  5120. and @samp{-funsigned-char}.
  5121. @item SCCS_DIRECTIVE
  5122. Define this if the preprocessor should ignore @code{#sccs} directives
  5123. with no error message.
  5124. @item MOVE_MAX
  5125. The maximum number of bytes that a single instruction can move quickly
  5126. from memory to memory.
  5127. @item INT_TYPE_SIZE
  5128. A C expression for the size in bits of the type @code{int} on the
  5129. target machine.
  5130. @item SLOW_BYTE_ACCESS
  5131. Define this macro as a C expression which is nonzero if accessing less
  5132. than a word of memory (i.e. a @code{char} or a @code{short}) is slow
  5133. (requires more than one instruction).
  5134. @item SLOW_ZERO_EXTEND
  5135. Define this macro if zero-extension (of a @code{char} or @code{short}
  5136. to an @code{int}) can be done faster if the destination is a register
  5137. that is known to be zero.
  5138. If you define this macro, you must have instruction patterns that
  5139. recognize RTL structures like this:
  5140. @example
  5141. (set (strict-low-part (subreg:QI (reg:SI @dots{}) 0)) @dots{})
  5142. @end example
  5143. @noindent
  5144. and likewise for @code{HImode}.
  5145. @item SHIFT_COUNT_TRUNCATED
  5146. Define this macro if shift instructions ignore all but the lowest few
  5147. bits of the shift count. It implies that a sign-extend or zero-extend
  5148. instruction for the shift count can be omitted.
  5149. @item TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec})
  5150. A C expression which is nonzero if on this machine it is safe to
  5151. ``convert'' an integer of @var{inprec} bits to one of @var{outprec}
  5152. bits (where @var{outprec} is smaller than @var{inprec}) by merely
  5153. operating on it as if it had only @var{outprec} bits.
  5154. On many machines, this expression can be 1.
  5155. @item NO_FUNCTION_CSE
  5156. Define this macro if it is as good or better to call a constant
  5157. function address than to call an address kept in a register.
  5158. @item STORE_FLAG_VALUE
  5159. A C expression for the value stored by a store-flag instruction
  5160. (@code{s@var{cond}}) when the condition is true. This is usually 1 or
  5161. -1; it is required to be an odd number.
  5162. Do not define @code{STORE_FLAG_VALUE} if the machine has no store-flag
  5163. instructions.
  5164. @item Pmode
  5165. An alias for the machine mode for pointers. Normally the definition
  5166. can be
  5167. @example
  5168. #define Pmode SImode
  5169. @end example
  5170. @item FUNCTION_MODE
  5171. An alias for the machine mode used for memory references to functions
  5172. being called, in @samp{call} RTL expressions. On most machines this
  5173. should be @code{QImode}.
  5174. @item CONST_COST (@var{x}, @var{code})
  5175. A part of a C @code{switch} statement that describes the relative
  5176. costs of constant RTL expressions. It must contain @code{case} labels
  5177. for expression codes @samp{const_int}, @samp{const}, @samp{symbol_ref}, @samp{label_ref}
  5178. and @samp{const_double}. Each case must ultimately reach a
  5179. @code{return} statement to return the relative cost of the use of that
  5180. kind of constant value in an expression. The cost may depend on the
  5181. precise value of the constant, which is available for examination in
  5182. @var{x}.
  5183. @var{code} is the expression code---redundant, since it can be
  5184. obtained with @code{GET_CODE (@var{x})}.
  5185. @item DOLLARS_IN_IDENTIFIERS
  5186. Define this if the character @samp{$} should be allowed in identifier
  5187. names.
  5188. @end table
  5189. @node Condition Code, Assembler Format, Misc, Machine Macros
  5190. @section Condition Code Information
  5191. The file @file{conditions.h} defines a variable @code{cc_status} to
  5192. describe how the condition code was computed (in case the interpretation of
  5193. the condition code depends on the instruction that it was set by). This
  5194. variable contains the RTL expressions on which the condition code is
  5195. currently based, and several standard flags.
  5196. Sometimes additional machine-specific flags must be defined in the machine
  5197. description header file. It can also add additional machine-specific
  5198. information by defining @code{CC_STATUS_MDEP}.
  5199. @table @code
  5200. @item CC_STATUS_MDEP
  5201. C code for a data type which is used for declaring the @code{mdep}
  5202. component of @code{cc_status}. It defaults to @code{int}.
  5203. @item CC_STATUS_MDEP_INIT
  5204. A C expression for the initial value of the @code{mdep} field. It
  5205. defaults to 0.
  5206. @item NOTICE_UPDATE_CC (@var{exp})
  5207. A C compound statement to set the components of @code{cc_status}
  5208. appropriately for an insn whose body is @var{exp}. It is this macro's
  5209. responsibility to recognize insns that set the condition code as a
  5210. byproduct of other activity as well as those that explicitly set
  5211. @code{(cc0)}.
  5212. If there are insn that do not set the condition code but do alter
  5213. other machine registers, this macro must check to see whether they
  5214. invalidate the expressions that the condition code is recorded as
  5215. reflecting. For example, on the 68000, insns that store in address
  5216. registers do not set the condition code, which means that usually
  5217. @code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such
  5218. insns. But suppose that the previous insn set the condition code
  5219. based on location @samp{a4@@(102)} and the current insn stores a new
  5220. value in @samp{a4}. Although the condition code is not changed by
  5221. this, it will no longer be true that it reflects the contents of
  5222. @samp{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter
  5223. @code{cc_status} in this case to say that nothing is known about the
  5224. condition code value.
  5225. @end table
  5226. @node Assembler Format,, Condition Code, Machine Macros
  5227. @section Output of Assembler Code
  5228. @table @code
  5229. @item ASM_SPEC
  5230. A C string constant that tells the GNU CC driver program options to
  5231. pass to the assembler. It can also specify how to translate options
  5232. you give to GNU CC into options for GNU CC to pass to the assembler.
  5233. See the file @file{tm-sun3.h} for an example of this.
  5234. Do not define this macro if it does not need to do anything.
  5235. @item LINK_SPEC
  5236. A C string constant that tells the GNU CC driver program options to
  5237. pass to the linker. It can also specify how to translate options you
  5238. give to GNU CC into options for GNU CC to pass to the linker.
  5239. Do not define this macro if it does not need to do anything.
  5240. @item ASM_FILE_START
  5241. A C string constant for text to be output at the start of each
  5242. assembler output file. Normally this is @code{"#NO_APP"}, which is a
  5243. comment that has no effect on most assemblers but tells the GNU
  5244. assembler that it can save time by not checking for certain assembler
  5245. constructs.
  5246. @item ASM_APP_ON
  5247. A C string constant for text to be output before each @code{asm}
  5248. statement or group of consecutive ones. Normally this is
  5249. @code{"#APP"}, which is a comment that has no effect on most
  5250. assemblers but tells the GNU assembler that it must check the lines
  5251. that follow for all valid assembler constructs.
  5252. @item ASM_APP_OFF
  5253. A C string constant for text to be output after each @code{asm}
  5254. statement or group of consecutive ones. Normally this is
  5255. @code{"#NO_APP"}, which tells the GNU assembler to resume making the
  5256. time-saving assumptions that are valid for ordinary compiler output.
  5257. @item TEXT_SECTION_ASM_OP
  5258. A C string constant for the assembler operation that should precede
  5259. instructions and read-only data. Normally @code{".text"} is right.
  5260. @item DATA_SECTION_ASM_OP
  5261. A C string constant for the assembler operation to identify the
  5262. following data as writable initialized data. Normally @code{".data"}
  5263. is right.
  5264. @item REGISTER_NAMES
  5265. A C initializer containing the assembler's names for the machine
  5266. registers, each one as a C string constant. This is what translates
  5267. register numbers in the compiler into assembler language.
  5268. @item DBX_REGISTER_NUMBER (@var{regno})
  5269. A C expression that returns the DBX register number for the compiler
  5270. register number @var{regno}. In simple cases, the value of this
  5271. expression may be @var{regno} itself. But sometimes there are some
  5272. registers that the compiler knows about and DBX does not, or vice
  5273. versa. In such cases, some register may need to have one number in
  5274. the compiler and another for DBX.
  5275. @item DBX_NO_XREFS
  5276. Define this macro if DBX on your system does not support the construct
  5277. @samp{xs@var{tagname}}. On some systems, this construct is used to
  5278. describe a forward reference to a structure named @var{tagname}.
  5279. On other systems, this construct is not supported at all.
  5280. @item DBX_CONTIN_LENGTH
  5281. A symbol name in DBX-format debugging information is normally
  5282. continued (split into two separate @code{.stabs} directives) when it
  5283. exceeds a certain length (by default, 80 characters). On some
  5284. operating systems, DBX requires this splitting; on others, splitting
  5285. must not be done. You can inhibit splitting by defining this macro
  5286. with the value zero. You can override the default splitting-length by
  5287. defining this macro as an expression for the length you desire.
  5288. @item DBX_CONTIN_CHAR
  5289. Normally continuation is indicated by adding a @samp{\} character to
  5290. the end of a @code{.stabs} string when a continuation follows. To use
  5291. a different character instead, define this macro as a character
  5292. constant for the character you want to use. Do not define this macro
  5293. if backslash is correct for your system.
  5294. @item ASM_OUTPUT_LABEL (@var{file}, @var{name})
  5295. A C statement (sans semicolon) to output to the stdio stream
  5296. @var{file} the assembler definition of a label named @var{name}. Use
  5297. the expression @code{assemble_name (@var{file}, @var{name})} to output
  5298. the name itself; before and after that, output the additional
  5299. assembler syntax for defining the name, and a newline.
  5300. @item ASM_DECLARE_FUNCTION_NAME (@var{file}, @var{name})
  5301. A C statement (sans semicolon) to output to the stdio stream
  5302. @var{file} any text necessary for declaring the name of a function
  5303. which is being defined. This macro is responsible for outputting
  5304. the label definition (perhaps using @code{ASM_OUTPUT_LABEL}).
  5305. If this macro is not defined, then the function name is defined in the
  5306. usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
  5307. @item ASM_GLOBALIZE_LABEL (@var{file}, @var{name})
  5308. A C statement (sans semicolon) to output to the stdio stream
  5309. @var{file} some commands that will make the label @var{name} global;
  5310. that is, available for reference from other files. Use the expression
  5311. @code{assemble_name (@var{file}, @var{name})} to output the name
  5312. itself; before and after that, output the additional assembler syntax
  5313. for making that name global, and a newline.
  5314. @item ASM_OUTPUT_EXTERNAL (@var{file}, @var{name})
  5315. A C statement (sans semicolon) to output to the stdio stream
  5316. @var{file} any text necessary for declaring the name of an external
  5317. symbol which is referenced in this compilation but not defined.
  5318. This macro need not be defined if it does not need to output anything.
  5319. The GNU assembler and most Unix assemblers don't require anything.
  5320. @item ASM_OUTPUT_LABELREF (@var{file}, @var{name})
  5321. A C statement to output to the stdio stream @var{file} a reference in
  5322. assembler syntax to a label named @var{name}. The character @samp{_}
  5323. should be added to the front of the name, if that is customary on your
  5324. operating system, as it is in most Berkeley Unix systems. This macro
  5325. is used in @code{assemble_name}.
  5326. @item ASM_OUTPUT_INTERNAL_LABEL (@var{file}, @var{prefix}, @var{num})
  5327. A C statement to output to the stdio stream @var{file} a label whose
  5328. name is made from the string @var{prefix} and the number @var{num}.
  5329. These labels are used for internal purposes, and there is no reason
  5330. for them to appear in the symbol table of the object file. On many
  5331. systems, the letter @samp{L} at the beginning of a label has this
  5332. effect. The usual definition of this macro is as follows:
  5333. @example
  5334. fprintf (@var{file}, "L%s%d:\n", @var{prefix}, @var{num})
  5335. @end example
  5336. @item ASM_OUTPUT_CASE_LABEL (@var{file}, @var{prefix}, @var{num}, @var{table})
  5337. Define this if the label before a jump-table needs to be output
  5338. specially. The first three arguments are the same as for
  5339. @code{ASM_OUTPUT_INTERNAL_LABEL}; the fourth argument is the
  5340. jump-table which follows (a @samp{jump_insn} containing an
  5341. @samp{addr_vec} or @samp{addr_diff_vec}).
  5342. This feature is used on system V to output a @code{swbeg} statement
  5343. for the table.
  5344. If this macro is not defined, these labels are output with
  5345. @code{ASM_OUTPUT_INTERNAL_LABEL}.
  5346. @item ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number})
  5347. A C expression to assign to @var{outvar} (which is a variable of type
  5348. @code{char *}) a newly allocated string made from the string
  5349. @var{name} and the number @var{number}, with some suitable punctuation
  5350. added. Use @code{alloca} to get space for the string.
  5351. This string will be used as the argument to @code{ASM_OUTPUT_LABELREF}
  5352. to produce an assembler label for an internal static variable whose
  5353. name is @var{name}. Therefore, the string must be such as to result
  5354. in valid assembler code. The argument @var{number} is different each
  5355. time this macro is executed; it prevents conflicts between
  5356. similarly-named internal static variables in different scopes.
  5357. Ideally this string should not be a valid C identifier, to prevent any
  5358. conflict with the user's own symbols. Most assemblers allow periods
  5359. or percent signs in assembler symbols; putting at least one of these
  5360. between the name and the number will suffice.
  5361. @item ASM_OUTPUT_ADDR_DIFF_ELT (@var{file}, @var{value}, @var{rel})
  5362. This macro should be provided on machines where the addresses
  5363. in a dispatch table are relative to the table's own address.
  5364. The definition should be a C statement to output to the stdio stream
  5365. @var{file} an assembler pseudo-instruction to generate a difference
  5366. between two labels. @var{value} and @var{rel} are the numbers of two
  5367. internal labels. The definitions of these labels are output using
  5368. @code{ASM_OUTPUT_INTERNAL_LABEL}, and they must be printed in the same
  5369. way here. For example,
  5370. @example
  5371. fprintf (@var{file}, "\t.word L%d-L%d\n",
  5372. @var{value}, @var{rel})
  5373. @end example
  5374. @item ASM_OUTPUT_ADDR_VEC_ELT (@var{file}, @var{value})
  5375. This macro should be provided on machines where the addresses
  5376. in a dispatch table are absolute.
  5377. The definition should be a C statement to output to the stdio stream
  5378. @var{file} an assembler pseudo-instruction to generate a reference to
  5379. a label. @var{value} is the number of an internal label whose
  5380. definition is output using @code{ASM_OUTPUT_INTERNAL_LABEL}.
  5381. For example,
  5382. @example
  5383. fprintf (@var{file}, "\t.word L%d\n", @var{value})
  5384. @end example
  5385. @item ASM_OUTPUT_DOUBLE (@var{file}, @var{value})
  5386. A C statement to output to the stdio stream @var{file} an assembler
  5387. instruction to assemble a @code{double} constant whose value is
  5388. @var{value}. @var{value} will be a C expression of type
  5389. @code{double}.
  5390. @item ASM_OUTPUT_FLOAT (@var{file}, @var{value})
  5391. A C statement to output to the stdio stream @var{file} an assembler
  5392. instruction to assemble a @code{float} constant whose value is
  5393. @var{value}. @var{value} will be a C expression of type @code{float}.
  5394. @item ASM_OUTPUT_INT (@var{file}, @var{exp})
  5395. @itemx ASM_OUTPUT_SHORT (@var{file}, @var{exp})
  5396. @itemx ASM_OUTPUT_CHAR (@var{file}, @var{exp})
  5397. A C statement to output to the stdio stream @var{file} an assembler
  5398. instruction to assemble a @code{int}, @code{short} or @code{char}
  5399. constant whose value is @var{value}. The argument @var{exp} will be
  5400. an RTL expression which represents a constant value. Use
  5401. @samp{output_addr_const (@var{exp})} to output this value as an
  5402. assembler expression.@refill
  5403. @item ASM_OUTPUT_BYTE (@var{file}, @var{value})
  5404. A C statement to output to the stdio stream @var{file} an assembler
  5405. instruction to assemble a single byte containing the number @var{value}.
  5406. @item ASM_OUTPUT_ASCII (@var{file}, @var{ptr}, @var{len})
  5407. A C statement to output to the stdio stream @var{file} an assembler
  5408. instruction to assemble a string constant containing the @var{len}
  5409. bytes at @var{ptr}. @var{ptr} will be a C expression of type
  5410. @code{char *} and @var{len} a C expression of type @code{int}.
  5411. If the assembler has a @code{.ascii} pseudo-op as found in the
  5412. Berkeley Unix assembler, do not define the macro
  5413. @code{ASM_OUTPUT_ASCII}.
  5414. @item ASM_OUTPUT_SKIP (@var{file}, @var{nbytes})
  5415. A C statement to output to the stdio stream @var{file} an assembler
  5416. instruction to advance the location counter by @var{nbytes} bytes.
  5417. @var{nbytes} will be a C expression of type @code{int}.
  5418. @item ASM_OUTPUT_ALIGN (@var{file}, @var{power})
  5419. A C statement to output to the stdio stream @var{file} an assembler
  5420. instruction to advance the location counter to a multiple of 2 to the
  5421. @var{power} bytes. @var{power} will be a C expression of type @code{int}.
  5422. @item ASM_OUTPUT_COMMON (@var{file}, @var{name}, @var{size})
  5423. A C statement (sans semicolon) to output to the stdio stream
  5424. @var{file} the assembler definition of a common-label named @var{name}
  5425. whose size is @var{size} bytes. Use the expression
  5426. @code{assemble_name (@var{file}, @var{name})} to output the name
  5427. itself; before and after that, output the additional assembler syntax
  5428. for defining the name, and a newline.
  5429. This macro controls how the assembler definitions of uninitialized
  5430. global variables are output.
  5431. @item ASM_OUTPUT_LOCAL (@var{file}, @var{name}, @var{size})
  5432. A C statement (sans semicolon) to output to the stdio stream
  5433. @var{file} the assembler definition of a local-common-label named
  5434. @var{name} whose size is @var{size} bytes. Use the expression
  5435. @code{assemble_name (@var{file}, @var{name})} to output the name
  5436. itself; before and after that, output the additional assembler syntax
  5437. for defining the name, and a newline.
  5438. This macro controls how the assembler definitions of uninitialized
  5439. static variables are output.
  5440. @item TARGET_BELL
  5441. A C constant expression for the integer value for escape sequence
  5442. @samp{\a}.
  5443. @item TARGET_BS
  5444. @itemx TARGET_TAB
  5445. @itemx TARGET_NEWLINE
  5446. C constant expressions for the integer values for escape sequences
  5447. @samp{\b}, @samp{\t} and @samp{\n}.
  5448. @item TARGET_VT
  5449. @itemx TARGET_FF
  5450. @itemx TARGET_CR
  5451. C constant expressions for the integer values for escape sequences
  5452. @samp{\v}, @samp{\f} and @samp{\r}.
  5453. @item ASM_OUTPUT_OPCODE (@var{file}, @var{ptr})
  5454. Define this macro if you are using an unusual assembler that
  5455. requires different names for the machine instructions.
  5456. The definition is a C statement or statements which output an
  5457. assembler instruction opcode to the stdio stream @var{file}. The
  5458. macro-operand @var{ptr} is a variable of type @code{char *} which
  5459. points to the opcode name in its ``internal'' form---the form that is
  5460. written in the machine description. The definition should output the
  5461. opcode name to @var{file}, performing any translation you desire, and
  5462. increment the variable @var{ptr} to point at the end of the opcode
  5463. so that it will not be output twice.
  5464. In fact, your macro definition may process less than the entire opcode
  5465. name, or more than the opcode name; but if you want to process text
  5466. that includes @samp{%}-sequences to substitute operands, you must take
  5467. care of the substitution yourself. Just be sure to increment
  5468. @var{ptr} over whatever text should not be output normally.
  5469. If the macro definition does nothing, the instruction is output
  5470. in the usual way.
  5471. @item PRINT_OPERAND (@var{file}, @var{x}, @var{code})
  5472. A C compound statement to output to stdio stream @var{file} the
  5473. assembler syntax for an instruction operand @var{x}. @var{x} is an
  5474. RTL expression.
  5475. @var{code} is a value that can be used to specify one of several ways
  5476. of printing the operand. It is used when identical operands must be
  5477. printed differently depending on the context. @var{code} comes from
  5478. the @samp{%} specification that was used to request printing of the
  5479. operand. If the specification was just @samp{%@var{digit}} then
  5480. @var{code} is 0; if the specification was @samp{%@var{ltr}
  5481. @var{digit}} then @var{code} is the ASCII code for @var{ltr}.
  5482. If @var{x} is a register, this macro should print the register's name.
  5483. The names can be found in an array @code{reg_names} whose type is
  5484. @code{char *[]}. @code{reg_names} is initialized from
  5485. @code{REGISTER_NAMES}.
  5486. When the machine description has a specification @samp{%@var{punct}}
  5487. (a @samp{%} followed by a punctuation character), this macro is called
  5488. with a null pointer for @var{x} and the punctuation character for
  5489. @var{code}.
  5490. @item PRINT_OPERAND_ADDRESS (@var{file}, @var{x})
  5491. A C compound statement to output to stdio stream @var{file} the
  5492. assembler syntax for an instruction operand that is a memory reference
  5493. whose address is @var{x}. @var{x} is an RTL expression.
  5494. @item ASM_OPEN_PAREN
  5495. @itemx ASM_CLOSE_PAREN
  5496. These macros are defined as C string constant, describing the syntax
  5497. in the assembler for grouping arithmetic expressions. The following
  5498. definitions are correct for most assemblers:
  5499. @example
  5500. #define ASM_OPEN_PAREN "("
  5501. #define ASM_CLOSE_PAREN ")"
  5502. @end example
  5503. @end table
  5504. @node Config,, Machine Macros, Top
  5505. @chapter The Configuration File
  5506. The configuration file @file{config-@var{machine}.h} contains macro
  5507. definitions that describe the machine and system on which the compiler is
  5508. running. Most of the values in it are actually the same on all machines
  5509. that GNU CC runs on, so most all configuration files are identical. But
  5510. there are some macros that vary:
  5511. @table @code
  5512. @item FAILURE_EXIT_CODE
  5513. A C expression for the status code to be returned when the compiler
  5514. exits after serious errors.
  5515. @item SUCCESS_EXIT_CODE
  5516. A C expression for the status code to be returned when the compiler
  5517. exits without serious errors.
  5518. @end table
  5519. @contents
  5520. @bye