md.texi 360 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057
  1. @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
  2. @c This is part of the GCC manual.
  3. @c For copying conditions, see the file gcc.texi.
  4. @ifset INTERNALS
  5. @node Machine Desc
  6. @chapter Machine Descriptions
  7. @cindex machine descriptions
  8. A machine description has two parts: a file of instruction patterns
  9. (@file{.md} file) and a C header file of macro definitions.
  10. The @file{.md} file for a target machine contains a pattern for each
  11. instruction that the target machine supports (or at least each instruction
  12. that is worth telling the compiler about). It may also contain comments.
  13. A semicolon causes the rest of the line to be a comment, unless the semicolon
  14. is inside a quoted string.
  15. See the next chapter for information on the C header file.
  16. @menu
  17. * Overview:: How the machine description is used.
  18. * Patterns:: How to write instruction patterns.
  19. * Example:: An explained example of a @code{define_insn} pattern.
  20. * RTL Template:: The RTL template defines what insns match a pattern.
  21. * Output Template:: The output template says how to make assembler code
  22. from such an insn.
  23. * Output Statement:: For more generality, write C code to output
  24. the assembler code.
  25. * Predicates:: Controlling what kinds of operands can be used
  26. for an insn.
  27. * Constraints:: Fine-tuning operand selection.
  28. * Standard Names:: Names mark patterns to use for code generation.
  29. * Pattern Ordering:: When the order of patterns makes a difference.
  30. * Dependent Patterns:: Having one pattern may make you need another.
  31. * Jump Patterns:: Special considerations for patterns for jump insns.
  32. * Looping Patterns:: How to define patterns for special looping insns.
  33. * Insn Canonicalizations::Canonicalization of Instructions
  34. * Expander Definitions::Generating a sequence of several RTL insns
  35. for a standard operation.
  36. * Insn Splitting:: Splitting Instructions into Multiple Instructions.
  37. * Including Patterns:: Including Patterns in Machine Descriptions.
  38. * Peephole Definitions::Defining machine-specific peephole optimizations.
  39. * Insn Attributes:: Specifying the value of attributes for generated insns.
  40. * Conditional Execution::Generating @code{define_insn} patterns for
  41. predication.
  42. * Define Subst:: Generating @code{define_insn} and @code{define_expand}
  43. patterns from other patterns.
  44. * Constant Definitions::Defining symbolic constants that can be used in the
  45. md file.
  46. * Iterators:: Using iterators to generate patterns from a template.
  47. @end menu
  48. @node Overview
  49. @section Overview of How the Machine Description is Used
  50. There are three main conversions that happen in the compiler:
  51. @enumerate
  52. @item
  53. The front end reads the source code and builds a parse tree.
  54. @item
  55. The parse tree is used to generate an RTL insn list based on named
  56. instruction patterns.
  57. @item
  58. The insn list is matched against the RTL templates to produce assembler
  59. code.
  60. @end enumerate
  61. For the generate pass, only the names of the insns matter, from either a
  62. named @code{define_insn} or a @code{define_expand}. The compiler will
  63. choose the pattern with the right name and apply the operands according
  64. to the documentation later in this chapter, without regard for the RTL
  65. template or operand constraints. Note that the names the compiler looks
  66. for are hard-coded in the compiler---it will ignore unnamed patterns and
  67. patterns with names it doesn't know about, but if you don't provide a
  68. named pattern it needs, it will abort.
  69. If a @code{define_insn} is used, the template given is inserted into the
  70. insn list. If a @code{define_expand} is used, one of three things
  71. happens, based on the condition logic. The condition logic may manually
  72. create new insns for the insn list, say via @code{emit_insn()}, and
  73. invoke @code{DONE}. For certain named patterns, it may invoke @code{FAIL} to tell the
  74. compiler to use an alternate way of performing that task. If it invokes
  75. neither @code{DONE} nor @code{FAIL}, the template given in the pattern
  76. is inserted, as if the @code{define_expand} were a @code{define_insn}.
  77. Once the insn list is generated, various optimization passes convert,
  78. replace, and rearrange the insns in the insn list. This is where the
  79. @code{define_split} and @code{define_peephole} patterns get used, for
  80. example.
  81. Finally, the insn list's RTL is matched up with the RTL templates in the
  82. @code{define_insn} patterns, and those patterns are used to emit the
  83. final assembly code. For this purpose, each named @code{define_insn}
  84. acts like it's unnamed, since the names are ignored.
  85. @node Patterns
  86. @section Everything about Instruction Patterns
  87. @cindex patterns
  88. @cindex instruction patterns
  89. @findex define_insn
  90. A @code{define_insn} expression is used to define instruction patterns
  91. to which insns may be matched. A @code{define_insn} expression contains
  92. an incomplete RTL expression, with pieces to be filled in later, operand
  93. constraints that restrict how the pieces can be filled in, and an output
  94. template or C code to generate the assembler output.
  95. A @code{define_insn} is an RTL expression containing four or five operands:
  96. @enumerate
  97. @item
  98. An optional name. The presence of a name indicate that this instruction
  99. pattern can perform a certain standard job for the RTL-generation
  100. pass of the compiler. This pass knows certain names and will use
  101. the instruction patterns with those names, if the names are defined
  102. in the machine description.
  103. The absence of a name is indicated by writing an empty string
  104. where the name should go. Nameless instruction patterns are never
  105. used for generating RTL code, but they may permit several simpler insns
  106. to be combined later on.
  107. Names that are not thus known and used in RTL-generation have no
  108. effect; they are equivalent to no name at all.
  109. For the purpose of debugging the compiler, you may also specify a
  110. name beginning with the @samp{*} character. Such a name is used only
  111. for identifying the instruction in RTL dumps; it is equivalent to having
  112. a nameless pattern for all other purposes. Names beginning with the
  113. @samp{*} character are not required to be unique.
  114. @item
  115. The @dfn{RTL template}: This is a vector of incomplete RTL expressions
  116. which describe the semantics of the instruction (@pxref{RTL Template}).
  117. It is incomplete because it may contain @code{match_operand},
  118. @code{match_operator}, and @code{match_dup} expressions that stand for
  119. operands of the instruction.
  120. If the vector has multiple elements, the RTL template is treated as a
  121. @code{parallel} expression.
  122. @item
  123. @cindex pattern conditions
  124. @cindex conditions, in patterns
  125. The condition: This is a string which contains a C expression. When the
  126. compiler attempts to match RTL against a pattern, the condition is
  127. evaluated. If the condition evaluates to @code{true}, the match is
  128. permitted. The condition may be an empty string, which is treated
  129. as always @code{true}.
  130. @cindex named patterns and conditions
  131. For a named pattern, the condition may not depend on the data in the
  132. insn being matched, but only the target-machine-type flags. The compiler
  133. needs to test these conditions during initialization in order to learn
  134. exactly which named instructions are available in a particular run.
  135. @findex operands
  136. For nameless patterns, the condition is applied only when matching an
  137. individual insn, and only after the insn has matched the pattern's
  138. recognition template. The insn's operands may be found in the vector
  139. @code{operands}.
  140. For an insn where the condition has once matched, it
  141. cannot later be used to control register allocation by excluding
  142. certain register or value combinations.
  143. @item
  144. The @dfn{output template} or @dfn{output statement}: This is either
  145. a string, or a fragment of C code which returns a string.
  146. When simple substitution isn't general enough, you can specify a piece
  147. of C code to compute the output. @xref{Output Statement}.
  148. @item
  149. The @dfn{insn attributes}: This is an optional vector containing the values of
  150. attributes for insns matching this pattern (@pxref{Insn Attributes}).
  151. @end enumerate
  152. @node Example
  153. @section Example of @code{define_insn}
  154. @cindex @code{define_insn} example
  155. Here is an example of an instruction pattern, taken from the machine
  156. description for the 68000/68020.
  157. @smallexample
  158. (define_insn "tstsi"
  159. [(set (cc0)
  160. (match_operand:SI 0 "general_operand" "rm"))]
  161. ""
  162. "*
  163. @{
  164. if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  165. return \"tstl %0\";
  166. return \"cmpl #0,%0\";
  167. @}")
  168. @end smallexample
  169. @noindent
  170. This can also be written using braced strings:
  171. @smallexample
  172. (define_insn "tstsi"
  173. [(set (cc0)
  174. (match_operand:SI 0 "general_operand" "rm"))]
  175. ""
  176. @{
  177. if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  178. return "tstl %0";
  179. return "cmpl #0,%0";
  180. @})
  181. @end smallexample
  182. This describes an instruction which sets the condition codes based on the
  183. value of a general operand. It has no condition, so any insn with an RTL
  184. description of the form shown may be matched to this pattern. The name
  185. @samp{tstsi} means ``test a @code{SImode} value'' and tells the RTL
  186. generation pass that, when it is necessary to test such a value, an insn
  187. to do so can be constructed using this pattern.
  188. The output control string is a piece of C code which chooses which
  189. output template to return based on the kind of operand and the specific
  190. type of CPU for which code is being generated.
  191. @samp{"rm"} is an operand constraint. Its meaning is explained below.
  192. @node RTL Template
  193. @section RTL Template
  194. @cindex RTL insn template
  195. @cindex generating insns
  196. @cindex insns, generating
  197. @cindex recognizing insns
  198. @cindex insns, recognizing
  199. The RTL template is used to define which insns match the particular pattern
  200. and how to find their operands. For named patterns, the RTL template also
  201. says how to construct an insn from specified operands.
  202. Construction involves substituting specified operands into a copy of the
  203. template. Matching involves determining the values that serve as the
  204. operands in the insn being matched. Both of these activities are
  205. controlled by special expression types that direct matching and
  206. substitution of the operands.
  207. @table @code
  208. @findex match_operand
  209. @item (match_operand:@var{m} @var{n} @var{predicate} @var{constraint})
  210. This expression is a placeholder for operand number @var{n} of
  211. the insn. When constructing an insn, operand number @var{n}
  212. will be substituted at this point. When matching an insn, whatever
  213. appears at this position in the insn will be taken as operand
  214. number @var{n}; but it must satisfy @var{predicate} or this instruction
  215. pattern will not match at all.
  216. Operand numbers must be chosen consecutively counting from zero in
  217. each instruction pattern. There may be only one @code{match_operand}
  218. expression in the pattern for each operand number. Usually operands
  219. are numbered in the order of appearance in @code{match_operand}
  220. expressions. In the case of a @code{define_expand}, any operand numbers
  221. used only in @code{match_dup} expressions have higher values than all
  222. other operand numbers.
  223. @var{predicate} is a string that is the name of a function that
  224. accepts two arguments, an expression and a machine mode.
  225. @xref{Predicates}. During matching, the function will be called with
  226. the putative operand as the expression and @var{m} as the mode
  227. argument (if @var{m} is not specified, @code{VOIDmode} will be used,
  228. which normally causes @var{predicate} to accept any mode). If it
  229. returns zero, this instruction pattern fails to match.
  230. @var{predicate} may be an empty string; then it means no test is to be
  231. done on the operand, so anything which occurs in this position is
  232. valid.
  233. Most of the time, @var{predicate} will reject modes other than @var{m}---but
  234. not always. For example, the predicate @code{address_operand} uses
  235. @var{m} as the mode of memory ref that the address should be valid for.
  236. Many predicates accept @code{const_int} nodes even though their mode is
  237. @code{VOIDmode}.
  238. @var{constraint} controls reloading and the choice of the best register
  239. class to use for a value, as explained later (@pxref{Constraints}).
  240. If the constraint would be an empty string, it can be omitted.
  241. People are often unclear on the difference between the constraint and the
  242. predicate. The predicate helps decide whether a given insn matches the
  243. pattern. The constraint plays no role in this decision; instead, it
  244. controls various decisions in the case of an insn which does match.
  245. @findex match_scratch
  246. @item (match_scratch:@var{m} @var{n} @var{constraint})
  247. This expression is also a placeholder for operand number @var{n}
  248. and indicates that operand must be a @code{scratch} or @code{reg}
  249. expression.
  250. When matching patterns, this is equivalent to
  251. @smallexample
  252. (match_operand:@var{m} @var{n} "scratch_operand" @var{constraint})
  253. @end smallexample
  254. but, when generating RTL, it produces a (@code{scratch}:@var{m})
  255. expression.
  256. If the last few expressions in a @code{parallel} are @code{clobber}
  257. expressions whose operands are either a hard register or
  258. @code{match_scratch}, the combiner can add or delete them when
  259. necessary. @xref{Side Effects}.
  260. @findex match_dup
  261. @item (match_dup @var{n})
  262. This expression is also a placeholder for operand number @var{n}.
  263. It is used when the operand needs to appear more than once in the
  264. insn.
  265. In construction, @code{match_dup} acts just like @code{match_operand}:
  266. the operand is substituted into the insn being constructed. But in
  267. matching, @code{match_dup} behaves differently. It assumes that operand
  268. number @var{n} has already been determined by a @code{match_operand}
  269. appearing earlier in the recognition template, and it matches only an
  270. identical-looking expression.
  271. Note that @code{match_dup} should not be used to tell the compiler that
  272. a particular register is being used for two operands (example:
  273. @code{add} that adds one register to another; the second register is
  274. both an input operand and the output operand). Use a matching
  275. constraint (@pxref{Simple Constraints}) for those. @code{match_dup} is for the cases where one
  276. operand is used in two places in the template, such as an instruction
  277. that computes both a quotient and a remainder, where the opcode takes
  278. two input operands but the RTL template has to refer to each of those
  279. twice; once for the quotient pattern and once for the remainder pattern.
  280. @findex match_operator
  281. @item (match_operator:@var{m} @var{n} @var{predicate} [@var{operands}@dots{}])
  282. This pattern is a kind of placeholder for a variable RTL expression
  283. code.
  284. When constructing an insn, it stands for an RTL expression whose
  285. expression code is taken from that of operand @var{n}, and whose
  286. operands are constructed from the patterns @var{operands}.
  287. When matching an expression, it matches an expression if the function
  288. @var{predicate} returns nonzero on that expression @emph{and} the
  289. patterns @var{operands} match the operands of the expression.
  290. Suppose that the function @code{commutative_operator} is defined as
  291. follows, to match any expression whose operator is one of the
  292. commutative arithmetic operators of RTL and whose mode is @var{mode}:
  293. @smallexample
  294. int
  295. commutative_integer_operator (x, mode)
  296. rtx x;
  297. machine_mode mode;
  298. @{
  299. enum rtx_code code = GET_CODE (x);
  300. if (GET_MODE (x) != mode)
  301. return 0;
  302. return (GET_RTX_CLASS (code) == RTX_COMM_ARITH
  303. || code == EQ || code == NE);
  304. @}
  305. @end smallexample
  306. Then the following pattern will match any RTL expression consisting
  307. of a commutative operator applied to two general operands:
  308. @smallexample
  309. (match_operator:SI 3 "commutative_operator"
  310. [(match_operand:SI 1 "general_operand" "g")
  311. (match_operand:SI 2 "general_operand" "g")])
  312. @end smallexample
  313. Here the vector @code{[@var{operands}@dots{}]} contains two patterns
  314. because the expressions to be matched all contain two operands.
  315. When this pattern does match, the two operands of the commutative
  316. operator are recorded as operands 1 and 2 of the insn. (This is done
  317. by the two instances of @code{match_operand}.) Operand 3 of the insn
  318. will be the entire commutative expression: use @code{GET_CODE
  319. (operands[3])} to see which commutative operator was used.
  320. The machine mode @var{m} of @code{match_operator} works like that of
  321. @code{match_operand}: it is passed as the second argument to the
  322. predicate function, and that function is solely responsible for
  323. deciding whether the expression to be matched ``has'' that mode.
  324. When constructing an insn, argument 3 of the gen-function will specify
  325. the operation (i.e.@: the expression code) for the expression to be
  326. made. It should be an RTL expression, whose expression code is copied
  327. into a new expression whose operands are arguments 1 and 2 of the
  328. gen-function. The subexpressions of argument 3 are not used;
  329. only its expression code matters.
  330. When @code{match_operator} is used in a pattern for matching an insn,
  331. it usually best if the operand number of the @code{match_operator}
  332. is higher than that of the actual operands of the insn. This improves
  333. register allocation because the register allocator often looks at
  334. operands 1 and 2 of insns to see if it can do register tying.
  335. There is no way to specify constraints in @code{match_operator}. The
  336. operand of the insn which corresponds to the @code{match_operator}
  337. never has any constraints because it is never reloaded as a whole.
  338. However, if parts of its @var{operands} are matched by
  339. @code{match_operand} patterns, those parts may have constraints of
  340. their own.
  341. @findex match_op_dup
  342. @item (match_op_dup:@var{m} @var{n}[@var{operands}@dots{}])
  343. Like @code{match_dup}, except that it applies to operators instead of
  344. operands. When constructing an insn, operand number @var{n} will be
  345. substituted at this point. But in matching, @code{match_op_dup} behaves
  346. differently. It assumes that operand number @var{n} has already been
  347. determined by a @code{match_operator} appearing earlier in the
  348. recognition template, and it matches only an identical-looking
  349. expression.
  350. @findex match_parallel
  351. @item (match_parallel @var{n} @var{predicate} [@var{subpat}@dots{}])
  352. This pattern is a placeholder for an insn that consists of a
  353. @code{parallel} expression with a variable number of elements. This
  354. expression should only appear at the top level of an insn pattern.
  355. When constructing an insn, operand number @var{n} will be substituted at
  356. this point. When matching an insn, it matches if the body of the insn
  357. is a @code{parallel} expression with at least as many elements as the
  358. vector of @var{subpat} expressions in the @code{match_parallel}, if each
  359. @var{subpat} matches the corresponding element of the @code{parallel},
  360. @emph{and} the function @var{predicate} returns nonzero on the
  361. @code{parallel} that is the body of the insn. It is the responsibility
  362. of the predicate to validate elements of the @code{parallel} beyond
  363. those listed in the @code{match_parallel}.
  364. A typical use of @code{match_parallel} is to match load and store
  365. multiple expressions, which can contain a variable number of elements
  366. in a @code{parallel}. For example,
  367. @smallexample
  368. (define_insn ""
  369. [(match_parallel 0 "load_multiple_operation"
  370. [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
  371. (match_operand:SI 2 "memory_operand" "m"))
  372. (use (reg:SI 179))
  373. (clobber (reg:SI 179))])]
  374. ""
  375. "loadm 0,0,%1,%2")
  376. @end smallexample
  377. This example comes from @file{a29k.md}. The function
  378. @code{load_multiple_operation} is defined in @file{a29k.c} and checks
  379. that subsequent elements in the @code{parallel} are the same as the
  380. @code{set} in the pattern, except that they are referencing subsequent
  381. registers and memory locations.
  382. An insn that matches this pattern might look like:
  383. @smallexample
  384. (parallel
  385. [(set (reg:SI 20) (mem:SI (reg:SI 100)))
  386. (use (reg:SI 179))
  387. (clobber (reg:SI 179))
  388. (set (reg:SI 21)
  389. (mem:SI (plus:SI (reg:SI 100)
  390. (const_int 4))))
  391. (set (reg:SI 22)
  392. (mem:SI (plus:SI (reg:SI 100)
  393. (const_int 8))))])
  394. @end smallexample
  395. @findex match_par_dup
  396. @item (match_par_dup @var{n} [@var{subpat}@dots{}])
  397. Like @code{match_op_dup}, but for @code{match_parallel} instead of
  398. @code{match_operator}.
  399. @end table
  400. @node Output Template
  401. @section Output Templates and Operand Substitution
  402. @cindex output templates
  403. @cindex operand substitution
  404. @cindex @samp{%} in template
  405. @cindex percent sign
  406. The @dfn{output template} is a string which specifies how to output the
  407. assembler code for an instruction pattern. Most of the template is a
  408. fixed string which is output literally. The character @samp{%} is used
  409. to specify where to substitute an operand; it can also be used to
  410. identify places where different variants of the assembler require
  411. different syntax.
  412. In the simplest case, a @samp{%} followed by a digit @var{n} says to output
  413. operand @var{n} at that point in the string.
  414. @samp{%} followed by a letter and a digit says to output an operand in an
  415. alternate fashion. Four letters have standard, built-in meanings described
  416. below. The machine description macro @code{PRINT_OPERAND} can define
  417. additional letters with nonstandard meanings.
  418. @samp{%c@var{digit}} can be used to substitute an operand that is a
  419. constant value without the syntax that normally indicates an immediate
  420. operand.
  421. @samp{%n@var{digit}} is like @samp{%c@var{digit}} except that the value of
  422. the constant is negated before printing.
  423. @samp{%a@var{digit}} can be used to substitute an operand as if it were a
  424. memory reference, with the actual operand treated as the address. This may
  425. be useful when outputting a ``load address'' instruction, because often the
  426. assembler syntax for such an instruction requires you to write the operand
  427. as if it were a memory reference.
  428. @samp{%l@var{digit}} is used to substitute a @code{label_ref} into a jump
  429. instruction.
  430. @samp{%=} outputs a number which is unique to each instruction in the
  431. entire compilation. This is useful for making local labels to be
  432. referred to more than once in a single template that generates multiple
  433. assembler instructions.
  434. @samp{%} followed by a punctuation character specifies a substitution that
  435. does not use an operand. Only one case is standard: @samp{%%} outputs a
  436. @samp{%} into the assembler code. Other nonstandard cases can be
  437. defined in the @code{PRINT_OPERAND} macro. You must also define
  438. which punctuation characters are valid with the
  439. @code{PRINT_OPERAND_PUNCT_VALID_P} macro.
  440. @cindex \
  441. @cindex backslash
  442. The template may generate multiple assembler instructions. Write the text
  443. for the instructions, with @samp{\;} between them.
  444. @cindex matching operands
  445. When the RTL contains two operands which are required by constraint to match
  446. each other, the output template must refer only to the lower-numbered operand.
  447. Matching operands are not always identical, and the rest of the compiler
  448. arranges to put the proper RTL expression for printing into the lower-numbered
  449. operand.
  450. One use of nonstandard letters or punctuation following @samp{%} is to
  451. distinguish between different assembler languages for the same machine; for
  452. example, Motorola syntax versus MIT syntax for the 68000. Motorola syntax
  453. requires periods in most opcode names, while MIT syntax does not. For
  454. example, the opcode @samp{movel} in MIT syntax is @samp{move.l} in Motorola
  455. syntax. The same file of patterns is used for both kinds of output syntax,
  456. but the character sequence @samp{%.} is used in each place where Motorola
  457. syntax wants a period. The @code{PRINT_OPERAND} macro for Motorola syntax
  458. defines the sequence to output a period; the macro for MIT syntax defines
  459. it to do nothing.
  460. @cindex @code{#} in template
  461. As a special case, a template consisting of the single character @code{#}
  462. instructs the compiler to first split the insn, and then output the
  463. resulting instructions separately. This helps eliminate redundancy in the
  464. output templates. If you have a @code{define_insn} that needs to emit
  465. multiple assembler instructions, and there is a matching @code{define_split}
  466. already defined, then you can simply use @code{#} as the output template
  467. instead of writing an output template that emits the multiple assembler
  468. instructions.
  469. If the macro @code{ASSEMBLER_DIALECT} is defined, you can use construct
  470. of the form @samp{@{option0|option1|option2@}} in the templates. These
  471. describe multiple variants of assembler language syntax.
  472. @xref{Instruction Output}.
  473. @node Output Statement
  474. @section C Statements for Assembler Output
  475. @cindex output statements
  476. @cindex C statements for assembler output
  477. @cindex generating assembler output
  478. Often a single fixed template string cannot produce correct and efficient
  479. assembler code for all the cases that are recognized by a single
  480. instruction pattern. For example, the opcodes may depend on the kinds of
  481. operands; or some unfortunate combinations of operands may require extra
  482. machine instructions.
  483. If the output control string starts with a @samp{@@}, then it is actually
  484. a series of templates, each on a separate line. (Blank lines and
  485. leading spaces and tabs are ignored.) The templates correspond to the
  486. pattern's constraint alternatives (@pxref{Multi-Alternative}). For example,
  487. if a target machine has a two-address add instruction @samp{addr} to add
  488. into a register and another @samp{addm} to add a register to memory, you
  489. might write this pattern:
  490. @smallexample
  491. (define_insn "addsi3"
  492. [(set (match_operand:SI 0 "general_operand" "=r,m")
  493. (plus:SI (match_operand:SI 1 "general_operand" "0,0")
  494. (match_operand:SI 2 "general_operand" "g,r")))]
  495. ""
  496. "@@
  497. addr %2,%0
  498. addm %2,%0")
  499. @end smallexample
  500. @cindex @code{*} in template
  501. @cindex asterisk in template
  502. If the output control string starts with a @samp{*}, then it is not an
  503. output template but rather a piece of C program that should compute a
  504. template. It should execute a @code{return} statement to return the
  505. template-string you want. Most such templates use C string literals, which
  506. require doublequote characters to delimit them. To include these
  507. doublequote characters in the string, prefix each one with @samp{\}.
  508. If the output control string is written as a brace block instead of a
  509. double-quoted string, it is automatically assumed to be C code. In that
  510. case, it is not necessary to put in a leading asterisk, or to escape the
  511. doublequotes surrounding C string literals.
  512. The operands may be found in the array @code{operands}, whose C data type
  513. is @code{rtx []}.
  514. It is very common to select different ways of generating assembler code
  515. based on whether an immediate operand is within a certain range. Be
  516. careful when doing this, because the result of @code{INTVAL} is an
  517. integer on the host machine. If the host machine has more bits in an
  518. @code{int} than the target machine has in the mode in which the constant
  519. will be used, then some of the bits you get from @code{INTVAL} will be
  520. superfluous. For proper results, you must carefully disregard the
  521. values of those bits.
  522. @findex output_asm_insn
  523. It is possible to output an assembler instruction and then go on to output
  524. or compute more of them, using the subroutine @code{output_asm_insn}. This
  525. receives two arguments: a template-string and a vector of operands. The
  526. vector may be @code{operands}, or it may be another array of @code{rtx}
  527. that you declare locally and initialize yourself.
  528. @findex which_alternative
  529. When an insn pattern has multiple alternatives in its constraints, often
  530. the appearance of the assembler code is determined mostly by which alternative
  531. was matched. When this is so, the C code can test the variable
  532. @code{which_alternative}, which is the ordinal number of the alternative
  533. that was actually satisfied (0 for the first, 1 for the second alternative,
  534. etc.).
  535. For example, suppose there are two opcodes for storing zero, @samp{clrreg}
  536. for registers and @samp{clrmem} for memory locations. Here is how
  537. a pattern could use @code{which_alternative} to choose between them:
  538. @smallexample
  539. (define_insn ""
  540. [(set (match_operand:SI 0 "general_operand" "=r,m")
  541. (const_int 0))]
  542. ""
  543. @{
  544. return (which_alternative == 0
  545. ? "clrreg %0" : "clrmem %0");
  546. @})
  547. @end smallexample
  548. The example above, where the assembler code to generate was
  549. @emph{solely} determined by the alternative, could also have been specified
  550. as follows, having the output control string start with a @samp{@@}:
  551. @smallexample
  552. @group
  553. (define_insn ""
  554. [(set (match_operand:SI 0 "general_operand" "=r,m")
  555. (const_int 0))]
  556. ""
  557. "@@
  558. clrreg %0
  559. clrmem %0")
  560. @end group
  561. @end smallexample
  562. If you just need a little bit of C code in one (or a few) alternatives,
  563. you can use @samp{*} inside of a @samp{@@} multi-alternative template:
  564. @smallexample
  565. @group
  566. (define_insn ""
  567. [(set (match_operand:SI 0 "general_operand" "=r,<,m")
  568. (const_int 0))]
  569. ""
  570. "@@
  571. clrreg %0
  572. * return stack_mem_p (operands[0]) ? \"push 0\" : \"clrmem %0\";
  573. clrmem %0")
  574. @end group
  575. @end smallexample
  576. @node Predicates
  577. @section Predicates
  578. @cindex predicates
  579. @cindex operand predicates
  580. @cindex operator predicates
  581. A predicate determines whether a @code{match_operand} or
  582. @code{match_operator} expression matches, and therefore whether the
  583. surrounding instruction pattern will be used for that combination of
  584. operands. GCC has a number of machine-independent predicates, and you
  585. can define machine-specific predicates as needed. By convention,
  586. predicates used with @code{match_operand} have names that end in
  587. @samp{_operand}, and those used with @code{match_operator} have names
  588. that end in @samp{_operator}.
  589. All predicates are Boolean functions (in the mathematical sense) of
  590. two arguments: the RTL expression that is being considered at that
  591. position in the instruction pattern, and the machine mode that the
  592. @code{match_operand} or @code{match_operator} specifies. In this
  593. section, the first argument is called @var{op} and the second argument
  594. @var{mode}. Predicates can be called from C as ordinary two-argument
  595. functions; this can be useful in output templates or other
  596. machine-specific code.
  597. Operand predicates can allow operands that are not actually acceptable
  598. to the hardware, as long as the constraints give reload the ability to
  599. fix them up (@pxref{Constraints}). However, GCC will usually generate
  600. better code if the predicates specify the requirements of the machine
  601. instructions as closely as possible. Reload cannot fix up operands
  602. that must be constants (``immediate operands''); you must use a
  603. predicate that allows only constants, or else enforce the requirement
  604. in the extra condition.
  605. @cindex predicates and machine modes
  606. @cindex normal predicates
  607. @cindex special predicates
  608. Most predicates handle their @var{mode} argument in a uniform manner.
  609. If @var{mode} is @code{VOIDmode} (unspecified), then @var{op} can have
  610. any mode. If @var{mode} is anything else, then @var{op} must have the
  611. same mode, unless @var{op} is a @code{CONST_INT} or integer
  612. @code{CONST_DOUBLE}. These RTL expressions always have
  613. @code{VOIDmode}, so it would be counterproductive to check that their
  614. mode matches. Instead, predicates that accept @code{CONST_INT} and/or
  615. integer @code{CONST_DOUBLE} check that the value stored in the
  616. constant will fit in the requested mode.
  617. Predicates with this behavior are called @dfn{normal}.
  618. @command{genrecog} can optimize the instruction recognizer based on
  619. knowledge of how normal predicates treat modes. It can also diagnose
  620. certain kinds of common errors in the use of normal predicates; for
  621. instance, it is almost always an error to use a normal predicate
  622. without specifying a mode.
  623. Predicates that do something different with their @var{mode} argument
  624. are called @dfn{special}. The generic predicates
  625. @code{address_operand} and @code{pmode_register_operand} are special
  626. predicates. @command{genrecog} does not do any optimizations or
  627. diagnosis when special predicates are used.
  628. @menu
  629. * Machine-Independent Predicates:: Predicates available to all back ends.
  630. * Defining Predicates:: How to write machine-specific predicate
  631. functions.
  632. @end menu
  633. @node Machine-Independent Predicates
  634. @subsection Machine-Independent Predicates
  635. @cindex machine-independent predicates
  636. @cindex generic predicates
  637. These are the generic predicates available to all back ends. They are
  638. defined in @file{recog.c}. The first category of predicates allow
  639. only constant, or @dfn{immediate}, operands.
  640. @defun immediate_operand
  641. This predicate allows any sort of constant that fits in @var{mode}.
  642. It is an appropriate choice for instructions that take operands that
  643. must be constant.
  644. @end defun
  645. @defun const_int_operand
  646. This predicate allows any @code{CONST_INT} expression that fits in
  647. @var{mode}. It is an appropriate choice for an immediate operand that
  648. does not allow a symbol or label.
  649. @end defun
  650. @defun const_double_operand
  651. This predicate accepts any @code{CONST_DOUBLE} expression that has
  652. exactly @var{mode}. If @var{mode} is @code{VOIDmode}, it will also
  653. accept @code{CONST_INT}. It is intended for immediate floating point
  654. constants.
  655. @end defun
  656. @noindent
  657. The second category of predicates allow only some kind of machine
  658. register.
  659. @defun register_operand
  660. This predicate allows any @code{REG} or @code{SUBREG} expression that
  661. is valid for @var{mode}. It is often suitable for arithmetic
  662. instruction operands on a RISC machine.
  663. @end defun
  664. @defun pmode_register_operand
  665. This is a slight variant on @code{register_operand} which works around
  666. a limitation in the machine-description reader.
  667. @smallexample
  668. (match_operand @var{n} "pmode_register_operand" @var{constraint})
  669. @end smallexample
  670. @noindent
  671. means exactly what
  672. @smallexample
  673. (match_operand:P @var{n} "register_operand" @var{constraint})
  674. @end smallexample
  675. @noindent
  676. would mean, if the machine-description reader accepted @samp{:P}
  677. mode suffixes. Unfortunately, it cannot, because @code{Pmode} is an
  678. alias for some other mode, and might vary with machine-specific
  679. options. @xref{Misc}.
  680. @end defun
  681. @defun scratch_operand
  682. This predicate allows hard registers and @code{SCRATCH} expressions,
  683. but not pseudo-registers. It is used internally by @code{match_scratch};
  684. it should not be used directly.
  685. @end defun
  686. @noindent
  687. The third category of predicates allow only some kind of memory reference.
  688. @defun memory_operand
  689. This predicate allows any valid reference to a quantity of mode
  690. @var{mode} in memory, as determined by the weak form of
  691. @code{GO_IF_LEGITIMATE_ADDRESS} (@pxref{Addressing Modes}).
  692. @end defun
  693. @defun address_operand
  694. This predicate is a little unusual; it allows any operand that is a
  695. valid expression for the @emph{address} of a quantity of mode
  696. @var{mode}, again determined by the weak form of
  697. @code{GO_IF_LEGITIMATE_ADDRESS}. To first order, if
  698. @samp{@w{(mem:@var{mode} (@var{exp}))}} is acceptable to
  699. @code{memory_operand}, then @var{exp} is acceptable to
  700. @code{address_operand}. Note that @var{exp} does not necessarily have
  701. the mode @var{mode}.
  702. @end defun
  703. @defun indirect_operand
  704. This is a stricter form of @code{memory_operand} which allows only
  705. memory references with a @code{general_operand} as the address
  706. expression. New uses of this predicate are discouraged, because
  707. @code{general_operand} is very permissive, so it's hard to tell what
  708. an @code{indirect_operand} does or does not allow. If a target has
  709. different requirements for memory operands for different instructions,
  710. it is better to define target-specific predicates which enforce the
  711. hardware's requirements explicitly.
  712. @end defun
  713. @defun push_operand
  714. This predicate allows a memory reference suitable for pushing a value
  715. onto the stack. This will be a @code{MEM} which refers to
  716. @code{stack_pointer_rtx}, with a side-effect in its address expression
  717. (@pxref{Incdec}); which one is determined by the
  718. @code{STACK_PUSH_CODE} macro (@pxref{Frame Layout}).
  719. @end defun
  720. @defun pop_operand
  721. This predicate allows a memory reference suitable for popping a value
  722. off the stack. Again, this will be a @code{MEM} referring to
  723. @code{stack_pointer_rtx}, with a side-effect in its address
  724. expression. However, this time @code{STACK_POP_CODE} is expected.
  725. @end defun
  726. @noindent
  727. The fourth category of predicates allow some combination of the above
  728. operands.
  729. @defun nonmemory_operand
  730. This predicate allows any immediate or register operand valid for @var{mode}.
  731. @end defun
  732. @defun nonimmediate_operand
  733. This predicate allows any register or memory operand valid for @var{mode}.
  734. @end defun
  735. @defun general_operand
  736. This predicate allows any immediate, register, or memory operand
  737. valid for @var{mode}.
  738. @end defun
  739. @noindent
  740. Finally, there are two generic operator predicates.
  741. @defun comparison_operator
  742. This predicate matches any expression which performs an arithmetic
  743. comparison in @var{mode}; that is, @code{COMPARISON_P} is true for the
  744. expression code.
  745. @end defun
  746. @defun ordered_comparison_operator
  747. This predicate matches any expression which performs an arithmetic
  748. comparison in @var{mode} and whose expression code is valid for integer
  749. modes; that is, the expression code will be one of @code{eq}, @code{ne},
  750. @code{lt}, @code{ltu}, @code{le}, @code{leu}, @code{gt}, @code{gtu},
  751. @code{ge}, @code{geu}.
  752. @end defun
  753. @node Defining Predicates
  754. @subsection Defining Machine-Specific Predicates
  755. @cindex defining predicates
  756. @findex define_predicate
  757. @findex define_special_predicate
  758. Many machines have requirements for their operands that cannot be
  759. expressed precisely using the generic predicates. You can define
  760. additional predicates using @code{define_predicate} and
  761. @code{define_special_predicate} expressions. These expressions have
  762. three operands:
  763. @itemize @bullet
  764. @item
  765. The name of the predicate, as it will be referred to in
  766. @code{match_operand} or @code{match_operator} expressions.
  767. @item
  768. An RTL expression which evaluates to true if the predicate allows the
  769. operand @var{op}, false if it does not. This expression can only use
  770. the following RTL codes:
  771. @table @code
  772. @item MATCH_OPERAND
  773. When written inside a predicate expression, a @code{MATCH_OPERAND}
  774. expression evaluates to true if the predicate it names would allow
  775. @var{op}. The operand number and constraint are ignored. Due to
  776. limitations in @command{genrecog}, you can only refer to generic
  777. predicates and predicates that have already been defined.
  778. @item MATCH_CODE
  779. This expression evaluates to true if @var{op} or a specified
  780. subexpression of @var{op} has one of a given list of RTX codes.
  781. The first operand of this expression is a string constant containing a
  782. comma-separated list of RTX code names (in lower case). These are the
  783. codes for which the @code{MATCH_CODE} will be true.
  784. The second operand is a string constant which indicates what
  785. subexpression of @var{op} to examine. If it is absent or the empty
  786. string, @var{op} itself is examined. Otherwise, the string constant
  787. must be a sequence of digits and/or lowercase letters. Each character
  788. indicates a subexpression to extract from the current expression; for
  789. the first character this is @var{op}, for the second and subsequent
  790. characters it is the result of the previous character. A digit
  791. @var{n} extracts @samp{@w{XEXP (@var{e}, @var{n})}}; a letter @var{l}
  792. extracts @samp{@w{XVECEXP (@var{e}, 0, @var{n})}} where @var{n} is the
  793. alphabetic ordinal of @var{l} (0 for `a', 1 for 'b', and so on). The
  794. @code{MATCH_CODE} then examines the RTX code of the subexpression
  795. extracted by the complete string. It is not possible to extract
  796. components of an @code{rtvec} that is not at position 0 within its RTX
  797. object.
  798. @item MATCH_TEST
  799. This expression has one operand, a string constant containing a C
  800. expression. The predicate's arguments, @var{op} and @var{mode}, are
  801. available with those names in the C expression. The @code{MATCH_TEST}
  802. evaluates to true if the C expression evaluates to a nonzero value.
  803. @code{MATCH_TEST} expressions must not have side effects.
  804. @item AND
  805. @itemx IOR
  806. @itemx NOT
  807. @itemx IF_THEN_ELSE
  808. The basic @samp{MATCH_} expressions can be combined using these
  809. logical operators, which have the semantics of the C operators
  810. @samp{&&}, @samp{||}, @samp{!}, and @samp{@w{? :}} respectively. As
  811. in Common Lisp, you may give an @code{AND} or @code{IOR} expression an
  812. arbitrary number of arguments; this has exactly the same effect as
  813. writing a chain of two-argument @code{AND} or @code{IOR} expressions.
  814. @end table
  815. @item
  816. An optional block of C code, which should execute
  817. @samp{@w{return true}} if the predicate is found to match and
  818. @samp{@w{return false}} if it does not. It must not have any side
  819. effects. The predicate arguments, @var{op} and @var{mode}, are
  820. available with those names.
  821. If a code block is present in a predicate definition, then the RTL
  822. expression must evaluate to true @emph{and} the code block must
  823. execute @samp{@w{return true}} for the predicate to allow the operand.
  824. The RTL expression is evaluated first; do not re-check anything in the
  825. code block that was checked in the RTL expression.
  826. @end itemize
  827. The program @command{genrecog} scans @code{define_predicate} and
  828. @code{define_special_predicate} expressions to determine which RTX
  829. codes are possibly allowed. You should always make this explicit in
  830. the RTL predicate expression, using @code{MATCH_OPERAND} and
  831. @code{MATCH_CODE}.
  832. Here is an example of a simple predicate definition, from the IA64
  833. machine description:
  834. @smallexample
  835. @group
  836. ;; @r{True if @var{op} is a @code{SYMBOL_REF} which refers to the sdata section.}
  837. (define_predicate "small_addr_symbolic_operand"
  838. (and (match_code "symbol_ref")
  839. (match_test "SYMBOL_REF_SMALL_ADDR_P (op)")))
  840. @end group
  841. @end smallexample
  842. @noindent
  843. And here is another, showing the use of the C block.
  844. @smallexample
  845. @group
  846. ;; @r{True if @var{op} is a register operand that is (or could be) a GR reg.}
  847. (define_predicate "gr_register_operand"
  848. (match_operand 0 "register_operand")
  849. @{
  850. unsigned int regno;
  851. if (GET_CODE (op) == SUBREG)
  852. op = SUBREG_REG (op);
  853. regno = REGNO (op);
  854. return (regno >= FIRST_PSEUDO_REGISTER || GENERAL_REGNO_P (regno));
  855. @})
  856. @end group
  857. @end smallexample
  858. Predicates written with @code{define_predicate} automatically include
  859. a test that @var{mode} is @code{VOIDmode}, or @var{op} has the same
  860. mode as @var{mode}, or @var{op} is a @code{CONST_INT} or
  861. @code{CONST_DOUBLE}. They do @emph{not} check specifically for
  862. integer @code{CONST_DOUBLE}, nor do they test that the value of either
  863. kind of constant fits in the requested mode. This is because
  864. target-specific predicates that take constants usually have to do more
  865. stringent value checks anyway. If you need the exact same treatment
  866. of @code{CONST_INT} or @code{CONST_DOUBLE} that the generic predicates
  867. provide, use a @code{MATCH_OPERAND} subexpression to call
  868. @code{const_int_operand}, @code{const_double_operand}, or
  869. @code{immediate_operand}.
  870. Predicates written with @code{define_special_predicate} do not get any
  871. automatic mode checks, and are treated as having special mode handling
  872. by @command{genrecog}.
  873. The program @command{genpreds} is responsible for generating code to
  874. test predicates. It also writes a header file containing function
  875. declarations for all machine-specific predicates. It is not necessary
  876. to declare these predicates in @file{@var{cpu}-protos.h}.
  877. @end ifset
  878. @c Most of this node appears by itself (in a different place) even
  879. @c when the INTERNALS flag is clear. Passages that require the internals
  880. @c manual's context are conditionalized to appear only in the internals manual.
  881. @ifset INTERNALS
  882. @node Constraints
  883. @section Operand Constraints
  884. @cindex operand constraints
  885. @cindex constraints
  886. Each @code{match_operand} in an instruction pattern can specify
  887. constraints for the operands allowed. The constraints allow you to
  888. fine-tune matching within the set of operands allowed by the
  889. predicate.
  890. @end ifset
  891. @ifclear INTERNALS
  892. @node Constraints
  893. @section Constraints for @code{asm} Operands
  894. @cindex operand constraints, @code{asm}
  895. @cindex constraints, @code{asm}
  896. @cindex @code{asm} constraints
  897. Here are specific details on what constraint letters you can use with
  898. @code{asm} operands.
  899. @end ifclear
  900. Constraints can say whether
  901. an operand may be in a register, and which kinds of register; whether the
  902. operand can be a memory reference, and which kinds of address; whether the
  903. operand may be an immediate constant, and which possible values it may
  904. have. Constraints can also require two operands to match.
  905. Side-effects aren't allowed in operands of inline @code{asm}, unless
  906. @samp{<} or @samp{>} constraints are used, because there is no guarantee
  907. that the side-effects will happen exactly once in an instruction that can update
  908. the addressing register.
  909. @ifset INTERNALS
  910. @menu
  911. * Simple Constraints:: Basic use of constraints.
  912. * Multi-Alternative:: When an insn has two alternative constraint-patterns.
  913. * Class Preferences:: Constraints guide which hard register to put things in.
  914. * Modifiers:: More precise control over effects of constraints.
  915. * Machine Constraints:: Existing constraints for some particular machines.
  916. * Disable Insn Alternatives:: Disable insn alternatives using attributes.
  917. * Define Constraints:: How to define machine-specific constraints.
  918. * C Constraint Interface:: How to test constraints from C code.
  919. @end menu
  920. @end ifset
  921. @ifclear INTERNALS
  922. @menu
  923. * Simple Constraints:: Basic use of constraints.
  924. * Multi-Alternative:: When an insn has two alternative constraint-patterns.
  925. * Modifiers:: More precise control over effects of constraints.
  926. * Machine Constraints:: Special constraints for some particular machines.
  927. @end menu
  928. @end ifclear
  929. @node Simple Constraints
  930. @subsection Simple Constraints
  931. @cindex simple constraints
  932. The simplest kind of constraint is a string full of letters, each of
  933. which describes one kind of operand that is permitted. Here are
  934. the letters that are allowed:
  935. @table @asis
  936. @item whitespace
  937. Whitespace characters are ignored and can be inserted at any position
  938. except the first. This enables each alternative for different operands to
  939. be visually aligned in the machine description even if they have different
  940. number of constraints and modifiers.
  941. @cindex @samp{m} in constraint
  942. @cindex memory references in constraints
  943. @item @samp{m}
  944. A memory operand is allowed, with any kind of address that the machine
  945. supports in general.
  946. Note that the letter used for the general memory constraint can be
  947. re-defined by a back end using the @code{TARGET_MEM_CONSTRAINT} macro.
  948. @cindex offsettable address
  949. @cindex @samp{o} in constraint
  950. @item @samp{o}
  951. A memory operand is allowed, but only if the address is
  952. @dfn{offsettable}. This means that adding a small integer (actually,
  953. the width in bytes of the operand, as determined by its machine mode)
  954. may be added to the address and the result is also a valid memory
  955. address.
  956. @cindex autoincrement/decrement addressing
  957. For example, an address which is constant is offsettable; so is an
  958. address that is the sum of a register and a constant (as long as a
  959. slightly larger constant is also within the range of address-offsets
  960. supported by the machine); but an autoincrement or autodecrement
  961. address is not offsettable. More complicated indirect/indexed
  962. addresses may or may not be offsettable depending on the other
  963. addressing modes that the machine supports.
  964. Note that in an output operand which can be matched by another
  965. operand, the constraint letter @samp{o} is valid only when accompanied
  966. by both @samp{<} (if the target machine has predecrement addressing)
  967. and @samp{>} (if the target machine has preincrement addressing).
  968. @cindex @samp{V} in constraint
  969. @item @samp{V}
  970. A memory operand that is not offsettable. In other words, anything that
  971. would fit the @samp{m} constraint but not the @samp{o} constraint.
  972. @cindex @samp{<} in constraint
  973. @item @samp{<}
  974. A memory operand with autodecrement addressing (either predecrement or
  975. postdecrement) is allowed. In inline @code{asm} this constraint is only
  976. allowed if the operand is used exactly once in an instruction that can
  977. handle the side-effects. Not using an operand with @samp{<} in constraint
  978. string in the inline @code{asm} pattern at all or using it in multiple
  979. instructions isn't valid, because the side-effects wouldn't be performed
  980. or would be performed more than once. Furthermore, on some targets
  981. the operand with @samp{<} in constraint string must be accompanied by
  982. special instruction suffixes like @code{%U0} instruction suffix on PowerPC
  983. or @code{%P0} on IA-64.
  984. @cindex @samp{>} in constraint
  985. @item @samp{>}
  986. A memory operand with autoincrement addressing (either preincrement or
  987. postincrement) is allowed. In inline @code{asm} the same restrictions
  988. as for @samp{<} apply.
  989. @cindex @samp{r} in constraint
  990. @cindex registers in constraints
  991. @item @samp{r}
  992. A register operand is allowed provided that it is in a general
  993. register.
  994. @cindex constants in constraints
  995. @cindex @samp{i} in constraint
  996. @item @samp{i}
  997. An immediate integer operand (one with constant value) is allowed.
  998. This includes symbolic constants whose values will be known only at
  999. assembly time or later.
  1000. @cindex @samp{n} in constraint
  1001. @item @samp{n}
  1002. An immediate integer operand with a known numeric value is allowed.
  1003. Many systems cannot support assembly-time constants for operands less
  1004. than a word wide. Constraints for these operands should use @samp{n}
  1005. rather than @samp{i}.
  1006. @cindex @samp{I} in constraint
  1007. @item @samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}
  1008. Other letters in the range @samp{I} through @samp{P} may be defined in
  1009. a machine-dependent fashion to permit immediate integer operands with
  1010. explicit integer values in specified ranges. For example, on the
  1011. 68000, @samp{I} is defined to stand for the range of values 1 to 8.
  1012. This is the range permitted as a shift count in the shift
  1013. instructions.
  1014. @cindex @samp{E} in constraint
  1015. @item @samp{E}
  1016. An immediate floating operand (expression code @code{const_double}) is
  1017. allowed, but only if the target floating point format is the same as
  1018. that of the host machine (on which the compiler is running).
  1019. @cindex @samp{F} in constraint
  1020. @item @samp{F}
  1021. An immediate floating operand (expression code @code{const_double} or
  1022. @code{const_vector}) is allowed.
  1023. @cindex @samp{G} in constraint
  1024. @cindex @samp{H} in constraint
  1025. @item @samp{G}, @samp{H}
  1026. @samp{G} and @samp{H} may be defined in a machine-dependent fashion to
  1027. permit immediate floating operands in particular ranges of values.
  1028. @cindex @samp{s} in constraint
  1029. @item @samp{s}
  1030. An immediate integer operand whose value is not an explicit integer is
  1031. allowed.
  1032. This might appear strange; if an insn allows a constant operand with a
  1033. value not known at compile time, it certainly must allow any known
  1034. value. So why use @samp{s} instead of @samp{i}? Sometimes it allows
  1035. better code to be generated.
  1036. For example, on the 68000 in a fullword instruction it is possible to
  1037. use an immediate operand; but if the immediate value is between @minus{}128
  1038. and 127, better code results from loading the value into a register and
  1039. using the register. This is because the load into the register can be
  1040. done with a @samp{moveq} instruction. We arrange for this to happen
  1041. by defining the letter @samp{K} to mean ``any integer outside the
  1042. range @minus{}128 to 127'', and then specifying @samp{Ks} in the operand
  1043. constraints.
  1044. @cindex @samp{g} in constraint
  1045. @item @samp{g}
  1046. Any register, memory or immediate integer operand is allowed, except for
  1047. registers that are not general registers.
  1048. @cindex @samp{X} in constraint
  1049. @item @samp{X}
  1050. @ifset INTERNALS
  1051. Any operand whatsoever is allowed, even if it does not satisfy
  1052. @code{general_operand}. This is normally used in the constraint of
  1053. a @code{match_scratch} when certain alternatives will not actually
  1054. require a scratch register.
  1055. @end ifset
  1056. @ifclear INTERNALS
  1057. Any operand whatsoever is allowed.
  1058. @end ifclear
  1059. @cindex @samp{0} in constraint
  1060. @cindex digits in constraint
  1061. @item @samp{0}, @samp{1}, @samp{2}, @dots{} @samp{9}
  1062. An operand that matches the specified operand number is allowed. If a
  1063. digit is used together with letters within the same alternative, the
  1064. digit should come last.
  1065. This number is allowed to be more than a single digit. If multiple
  1066. digits are encountered consecutively, they are interpreted as a single
  1067. decimal integer. There is scant chance for ambiguity, since to-date
  1068. it has never been desirable that @samp{10} be interpreted as matching
  1069. either operand 1 @emph{or} operand 0. Should this be desired, one
  1070. can use multiple alternatives instead.
  1071. @cindex matching constraint
  1072. @cindex constraint, matching
  1073. This is called a @dfn{matching constraint} and what it really means is
  1074. that the assembler has only a single operand that fills two roles
  1075. @ifset INTERNALS
  1076. considered separate in the RTL insn. For example, an add insn has two
  1077. input operands and one output operand in the RTL, but on most CISC
  1078. @end ifset
  1079. @ifclear INTERNALS
  1080. which @code{asm} distinguishes. For example, an add instruction uses
  1081. two input operands and an output operand, but on most CISC
  1082. @end ifclear
  1083. machines an add instruction really has only two operands, one of them an
  1084. input-output operand:
  1085. @smallexample
  1086. addl #35,r12
  1087. @end smallexample
  1088. Matching constraints are used in these circumstances.
  1089. More precisely, the two operands that match must include one input-only
  1090. operand and one output-only operand. Moreover, the digit must be a
  1091. smaller number than the number of the operand that uses it in the
  1092. constraint.
  1093. @ifset INTERNALS
  1094. For operands to match in a particular case usually means that they
  1095. are identical-looking RTL expressions. But in a few special cases
  1096. specific kinds of dissimilarity are allowed. For example, @code{*x}
  1097. as an input operand will match @code{*x++} as an output operand.
  1098. For proper results in such cases, the output template should always
  1099. use the output-operand's number when printing the operand.
  1100. @end ifset
  1101. @cindex load address instruction
  1102. @cindex push address instruction
  1103. @cindex address constraints
  1104. @cindex @samp{p} in constraint
  1105. @item @samp{p}
  1106. An operand that is a valid memory address is allowed. This is
  1107. for ``load address'' and ``push address'' instructions.
  1108. @findex address_operand
  1109. @samp{p} in the constraint must be accompanied by @code{address_operand}
  1110. as the predicate in the @code{match_operand}. This predicate interprets
  1111. the mode specified in the @code{match_operand} as the mode of the memory
  1112. reference for which the address would be valid.
  1113. @cindex other register constraints
  1114. @cindex extensible constraints
  1115. @item @var{other-letters}
  1116. Other letters can be defined in machine-dependent fashion to stand for
  1117. particular classes of registers or other arbitrary operand types.
  1118. @samp{d}, @samp{a} and @samp{f} are defined on the 68000/68020 to stand
  1119. for data, address and floating point registers.
  1120. @end table
  1121. @ifset INTERNALS
  1122. In order to have valid assembler code, each operand must satisfy
  1123. its constraint. But a failure to do so does not prevent the pattern
  1124. from applying to an insn. Instead, it directs the compiler to modify
  1125. the code so that the constraint will be satisfied. Usually this is
  1126. done by copying an operand into a register.
  1127. Contrast, therefore, the two instruction patterns that follow:
  1128. @smallexample
  1129. (define_insn ""
  1130. [(set (match_operand:SI 0 "general_operand" "=r")
  1131. (plus:SI (match_dup 0)
  1132. (match_operand:SI 1 "general_operand" "r")))]
  1133. ""
  1134. "@dots{}")
  1135. @end smallexample
  1136. @noindent
  1137. which has two operands, one of which must appear in two places, and
  1138. @smallexample
  1139. (define_insn ""
  1140. [(set (match_operand:SI 0 "general_operand" "=r")
  1141. (plus:SI (match_operand:SI 1 "general_operand" "0")
  1142. (match_operand:SI 2 "general_operand" "r")))]
  1143. ""
  1144. "@dots{}")
  1145. @end smallexample
  1146. @noindent
  1147. which has three operands, two of which are required by a constraint to be
  1148. identical. If we are considering an insn of the form
  1149. @smallexample
  1150. (insn @var{n} @var{prev} @var{next}
  1151. (set (reg:SI 3)
  1152. (plus:SI (reg:SI 6) (reg:SI 109)))
  1153. @dots{})
  1154. @end smallexample
  1155. @noindent
  1156. the first pattern would not apply at all, because this insn does not
  1157. contain two identical subexpressions in the right place. The pattern would
  1158. say, ``That does not look like an add instruction; try other patterns''.
  1159. The second pattern would say, ``Yes, that's an add instruction, but there
  1160. is something wrong with it''. It would direct the reload pass of the
  1161. compiler to generate additional insns to make the constraint true. The
  1162. results might look like this:
  1163. @smallexample
  1164. (insn @var{n2} @var{prev} @var{n}
  1165. (set (reg:SI 3) (reg:SI 6))
  1166. @dots{})
  1167. (insn @var{n} @var{n2} @var{next}
  1168. (set (reg:SI 3)
  1169. (plus:SI (reg:SI 3) (reg:SI 109)))
  1170. @dots{})
  1171. @end smallexample
  1172. It is up to you to make sure that each operand, in each pattern, has
  1173. constraints that can handle any RTL expression that could be present for
  1174. that operand. (When multiple alternatives are in use, each pattern must,
  1175. for each possible combination of operand expressions, have at least one
  1176. alternative which can handle that combination of operands.) The
  1177. constraints don't need to @emph{allow} any possible operand---when this is
  1178. the case, they do not constrain---but they must at least point the way to
  1179. reloading any possible operand so that it will fit.
  1180. @itemize @bullet
  1181. @item
  1182. If the constraint accepts whatever operands the predicate permits,
  1183. there is no problem: reloading is never necessary for this operand.
  1184. For example, an operand whose constraints permit everything except
  1185. registers is safe provided its predicate rejects registers.
  1186. An operand whose predicate accepts only constant values is safe
  1187. provided its constraints include the letter @samp{i}. If any possible
  1188. constant value is accepted, then nothing less than @samp{i} will do;
  1189. if the predicate is more selective, then the constraints may also be
  1190. more selective.
  1191. @item
  1192. Any operand expression can be reloaded by copying it into a register.
  1193. So if an operand's constraints allow some kind of register, it is
  1194. certain to be safe. It need not permit all classes of registers; the
  1195. compiler knows how to copy a register into another register of the
  1196. proper class in order to make an instruction valid.
  1197. @cindex nonoffsettable memory reference
  1198. @cindex memory reference, nonoffsettable
  1199. @item
  1200. A nonoffsettable memory reference can be reloaded by copying the
  1201. address into a register. So if the constraint uses the letter
  1202. @samp{o}, all memory references are taken care of.
  1203. @item
  1204. A constant operand can be reloaded by allocating space in memory to
  1205. hold it as preinitialized data. Then the memory reference can be used
  1206. in place of the constant. So if the constraint uses the letters
  1207. @samp{o} or @samp{m}, constant operands are not a problem.
  1208. @item
  1209. If the constraint permits a constant and a pseudo register used in an insn
  1210. was not allocated to a hard register and is equivalent to a constant,
  1211. the register will be replaced with the constant. If the predicate does
  1212. not permit a constant and the insn is re-recognized for some reason, the
  1213. compiler will crash. Thus the predicate must always recognize any
  1214. objects allowed by the constraint.
  1215. @end itemize
  1216. If the operand's predicate can recognize registers, but the constraint does
  1217. not permit them, it can make the compiler crash. When this operand happens
  1218. to be a register, the reload pass will be stymied, because it does not know
  1219. how to copy a register temporarily into memory.
  1220. If the predicate accepts a unary operator, the constraint applies to the
  1221. operand. For example, the MIPS processor at ISA level 3 supports an
  1222. instruction which adds two registers in @code{SImode} to produce a
  1223. @code{DImode} result, but only if the registers are correctly sign
  1224. extended. This predicate for the input operands accepts a
  1225. @code{sign_extend} of an @code{SImode} register. Write the constraint
  1226. to indicate the type of register that is required for the operand of the
  1227. @code{sign_extend}.
  1228. @end ifset
  1229. @node Multi-Alternative
  1230. @subsection Multiple Alternative Constraints
  1231. @cindex multiple alternative constraints
  1232. Sometimes a single instruction has multiple alternative sets of possible
  1233. operands. For example, on the 68000, a logical-or instruction can combine
  1234. register or an immediate value into memory, or it can combine any kind of
  1235. operand into a register; but it cannot combine one memory location into
  1236. another.
  1237. These constraints are represented as multiple alternatives. An alternative
  1238. can be described by a series of letters for each operand. The overall
  1239. constraint for an operand is made from the letters for this operand
  1240. from the first alternative, a comma, the letters for this operand from
  1241. the second alternative, a comma, and so on until the last alternative.
  1242. @ifset INTERNALS
  1243. Here is how it is done for fullword logical-or on the 68000:
  1244. @smallexample
  1245. (define_insn "iorsi3"
  1246. [(set (match_operand:SI 0 "general_operand" "=m,d")
  1247. (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
  1248. (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  1249. @dots{})
  1250. @end smallexample
  1251. The first alternative has @samp{m} (memory) for operand 0, @samp{0} for
  1252. operand 1 (meaning it must match operand 0), and @samp{dKs} for operand
  1253. 2. The second alternative has @samp{d} (data register) for operand 0,
  1254. @samp{0} for operand 1, and @samp{dmKs} for operand 2. The @samp{=} and
  1255. @samp{%} in the constraints apply to all the alternatives; their
  1256. meaning is explained in the next section (@pxref{Class Preferences}).
  1257. @end ifset
  1258. @c FIXME Is this ? and ! stuff of use in asm()? If not, hide unless INTERNAL
  1259. If all the operands fit any one alternative, the instruction is valid.
  1260. Otherwise, for each alternative, the compiler counts how many instructions
  1261. must be added to copy the operands so that that alternative applies.
  1262. The alternative requiring the least copying is chosen. If two alternatives
  1263. need the same amount of copying, the one that comes first is chosen.
  1264. These choices can be altered with the @samp{?} and @samp{!} characters:
  1265. @table @code
  1266. @cindex @samp{?} in constraint
  1267. @cindex question mark
  1268. @item ?
  1269. Disparage slightly the alternative that the @samp{?} appears in,
  1270. as a choice when no alternative applies exactly. The compiler regards
  1271. this alternative as one unit more costly for each @samp{?} that appears
  1272. in it.
  1273. @cindex @samp{!} in constraint
  1274. @cindex exclamation point
  1275. @item !
  1276. Disparage severely the alternative that the @samp{!} appears in.
  1277. This alternative can still be used if it fits without reloading,
  1278. but if reloading is needed, some other alternative will be used.
  1279. @cindex @samp{^} in constraint
  1280. @cindex caret
  1281. @item ^
  1282. This constraint is analogous to @samp{?} but it disparages slightly
  1283. the alternative only if the operand with the @samp{^} needs a reload.
  1284. @cindex @samp{$} in constraint
  1285. @cindex dollar sign
  1286. @item $
  1287. This constraint is analogous to @samp{!} but it disparages severely
  1288. the alternative only if the operand with the @samp{$} needs a reload.
  1289. @end table
  1290. @ifset INTERNALS
  1291. When an insn pattern has multiple alternatives in its constraints, often
  1292. the appearance of the assembler code is determined mostly by which
  1293. alternative was matched. When this is so, the C code for writing the
  1294. assembler code can use the variable @code{which_alternative}, which is
  1295. the ordinal number of the alternative that was actually satisfied (0 for
  1296. the first, 1 for the second alternative, etc.). @xref{Output Statement}.
  1297. @end ifset
  1298. @ifset INTERNALS
  1299. @node Class Preferences
  1300. @subsection Register Class Preferences
  1301. @cindex class preference constraints
  1302. @cindex register class preference constraints
  1303. @cindex voting between constraint alternatives
  1304. The operand constraints have another function: they enable the compiler
  1305. to decide which kind of hardware register a pseudo register is best
  1306. allocated to. The compiler examines the constraints that apply to the
  1307. insns that use the pseudo register, looking for the machine-dependent
  1308. letters such as @samp{d} and @samp{a} that specify classes of registers.
  1309. The pseudo register is put in whichever class gets the most ``votes''.
  1310. The constraint letters @samp{g} and @samp{r} also vote: they vote in
  1311. favor of a general register. The machine description says which registers
  1312. are considered general.
  1313. Of course, on some machines all registers are equivalent, and no register
  1314. classes are defined. Then none of this complexity is relevant.
  1315. @end ifset
  1316. @node Modifiers
  1317. @subsection Constraint Modifier Characters
  1318. @cindex modifiers in constraints
  1319. @cindex constraint modifier characters
  1320. @c prevent bad page break with this line
  1321. Here are constraint modifier characters.
  1322. @table @samp
  1323. @cindex @samp{=} in constraint
  1324. @item =
  1325. Means that this operand is written to by this instruction:
  1326. the previous value is discarded and replaced by new data.
  1327. @cindex @samp{+} in constraint
  1328. @item +
  1329. Means that this operand is both read and written by the instruction.
  1330. When the compiler fixes up the operands to satisfy the constraints,
  1331. it needs to know which operands are read by the instruction and
  1332. which are written by it. @samp{=} identifies an operand which is only
  1333. written; @samp{+} identifies an operand that is both read and written; all
  1334. other operands are assumed to only be read.
  1335. If you specify @samp{=} or @samp{+} in a constraint, you put it in the
  1336. first character of the constraint string.
  1337. @cindex @samp{&} in constraint
  1338. @cindex earlyclobber operand
  1339. @item &
  1340. Means (in a particular alternative) that this operand is an
  1341. @dfn{earlyclobber} operand, which is written before the instruction is
  1342. finished using the input operands. Therefore, this operand may not lie
  1343. in a register that is read by the instruction or as part of any memory
  1344. address.
  1345. @samp{&} applies only to the alternative in which it is written. In
  1346. constraints with multiple alternatives, sometimes one alternative
  1347. requires @samp{&} while others do not. See, for example, the
  1348. @samp{movdf} insn of the 68000.
  1349. A operand which is read by the instruction can be tied to an earlyclobber
  1350. operand if its only use as an input occurs before the early result is
  1351. written. Adding alternatives of this form often allows GCC to produce
  1352. better code when only some of the read operands can be affected by the
  1353. earlyclobber. See, for example, the @samp{mulsi3} insn of the ARM@.
  1354. Furthermore, if the @dfn{earlyclobber} operand is also a read/write
  1355. operand, then that operand is written only after it's used.
  1356. @samp{&} does not obviate the need to write @samp{=} or @samp{+}. As
  1357. @dfn{earlyclobber} operands are always written, a read-only
  1358. @dfn{earlyclobber} operand is ill-formed and will be rejected by the
  1359. compiler.
  1360. @cindex @samp{%} in constraint
  1361. @item %
  1362. Declares the instruction to be commutative for this operand and the
  1363. following operand. This means that the compiler may interchange the
  1364. two operands if that is the cheapest way to make all operands fit the
  1365. constraints. @samp{%} applies to all alternatives and must appear as
  1366. the first character in the constraint. Only read-only operands can use
  1367. @samp{%}.
  1368. @ifset INTERNALS
  1369. This is often used in patterns for addition instructions
  1370. that really have only two operands: the result must go in one of the
  1371. arguments. Here for example, is how the 68000 halfword-add
  1372. instruction is defined:
  1373. @smallexample
  1374. (define_insn "addhi3"
  1375. [(set (match_operand:HI 0 "general_operand" "=m,r")
  1376. (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
  1377. (match_operand:HI 2 "general_operand" "di,g")))]
  1378. @dots{})
  1379. @end smallexample
  1380. @end ifset
  1381. GCC can only handle one commutative pair in an asm; if you use more,
  1382. the compiler may fail. Note that you need not use the modifier if
  1383. the two alternatives are strictly identical; this would only waste
  1384. time in the reload pass. The modifier is not operational after
  1385. register allocation, so the result of @code{define_peephole2}
  1386. and @code{define_split}s performed after reload cannot rely on
  1387. @samp{%} to make the intended insn match.
  1388. @cindex @samp{#} in constraint
  1389. @item #
  1390. Says that all following characters, up to the next comma, are to be
  1391. ignored as a constraint. They are significant only for choosing
  1392. register preferences.
  1393. @cindex @samp{*} in constraint
  1394. @item *
  1395. Says that the following character should be ignored when choosing
  1396. register preferences. @samp{*} has no effect on the meaning of the
  1397. constraint as a constraint, and no effect on reloading. For LRA
  1398. @samp{*} additionally disparages slightly the alternative if the
  1399. following character matches the operand.
  1400. @ifset INTERNALS
  1401. Here is an example: the 68000 has an instruction to sign-extend a
  1402. halfword in a data register, and can also sign-extend a value by
  1403. copying it into an address register. While either kind of register is
  1404. acceptable, the constraints on an address-register destination are
  1405. less strict, so it is best if register allocation makes an address
  1406. register its goal. Therefore, @samp{*} is used so that the @samp{d}
  1407. constraint letter (for data register) is ignored when computing
  1408. register preferences.
  1409. @smallexample
  1410. (define_insn "extendhisi2"
  1411. [(set (match_operand:SI 0 "general_operand" "=*d,a")
  1412. (sign_extend:SI
  1413. (match_operand:HI 1 "general_operand" "0,g")))]
  1414. @dots{})
  1415. @end smallexample
  1416. @end ifset
  1417. @end table
  1418. @node Machine Constraints
  1419. @subsection Constraints for Particular Machines
  1420. @cindex machine specific constraints
  1421. @cindex constraints, machine specific
  1422. Whenever possible, you should use the general-purpose constraint letters
  1423. in @code{asm} arguments, since they will convey meaning more readily to
  1424. people reading your code. Failing that, use the constraint letters
  1425. that usually have very similar meanings across architectures. The most
  1426. commonly used constraints are @samp{m} and @samp{r} (for memory and
  1427. general-purpose registers respectively; @pxref{Simple Constraints}), and
  1428. @samp{I}, usually the letter indicating the most common
  1429. immediate-constant format.
  1430. Each architecture defines additional constraints. These constraints
  1431. are used by the compiler itself for instruction generation, as well as
  1432. for @code{asm} statements; therefore, some of the constraints are not
  1433. particularly useful for @code{asm}. Here is a summary of some of the
  1434. machine-dependent constraints available on some particular machines;
  1435. it includes both constraints that are useful for @code{asm} and
  1436. constraints that aren't. The compiler source file mentioned in the
  1437. table heading for each architecture is the definitive reference for
  1438. the meanings of that architecture's constraints.
  1439. @c Please keep this table alphabetized by target!
  1440. @table @emph
  1441. @item AArch64 family---@file{config/aarch64/constraints.md}
  1442. @table @code
  1443. @item k
  1444. The stack pointer register (@code{SP})
  1445. @item w
  1446. Floating point or SIMD vector register
  1447. @item I
  1448. Integer constant that is valid as an immediate operand in an @code{ADD}
  1449. instruction
  1450. @item J
  1451. Integer constant that is valid as an immediate operand in a @code{SUB}
  1452. instruction (once negated)
  1453. @item K
  1454. Integer constant that can be used with a 32-bit logical instruction
  1455. @item L
  1456. Integer constant that can be used with a 64-bit logical instruction
  1457. @item M
  1458. Integer constant that is valid as an immediate operand in a 32-bit @code{MOV}
  1459. pseudo instruction. The @code{MOV} may be assembled to one of several different
  1460. machine instructions depending on the value
  1461. @item N
  1462. Integer constant that is valid as an immediate operand in a 64-bit @code{MOV}
  1463. pseudo instruction
  1464. @item S
  1465. An absolute symbolic address or a label reference
  1466. @item Y
  1467. Floating point constant zero
  1468. @item Z
  1469. Integer constant zero
  1470. @item Ush
  1471. The high part (bits 12 and upwards) of the pc-relative address of a symbol
  1472. within 4GB of the instruction
  1473. @item Q
  1474. A memory address which uses a single base register with no offset
  1475. @item Ump
  1476. A memory address suitable for a load/store pair instruction in SI, DI, SF and
  1477. DF modes
  1478. @end table
  1479. @item ARC ---@file{config/arc/constraints.md}
  1480. @table @code
  1481. @item q
  1482. Registers usable in ARCompact 16-bit instructions: @code{r0}-@code{r3},
  1483. @code{r12}-@code{r15}. This constraint can only match when the @option{-mq}
  1484. option is in effect.
  1485. @item e
  1486. Registers usable as base-regs of memory addresses in ARCompact 16-bit memory
  1487. instructions: @code{r0}-@code{r3}, @code{r12}-@code{r15}, @code{sp}.
  1488. This constraint can only match when the @option{-mq}
  1489. option is in effect.
  1490. @item D
  1491. ARC FPX (dpfp) 64-bit registers. @code{D0}, @code{D1}.
  1492. @item I
  1493. A signed 12-bit integer constant.
  1494. @item Cal
  1495. constant for arithmetic/logical operations. This might be any constant
  1496. that can be put into a long immediate by the assmbler or linker without
  1497. involving a PIC relocation.
  1498. @item K
  1499. A 3-bit unsigned integer constant.
  1500. @item L
  1501. A 6-bit unsigned integer constant.
  1502. @item CnL
  1503. One's complement of a 6-bit unsigned integer constant.
  1504. @item CmL
  1505. Two's complement of a 6-bit unsigned integer constant.
  1506. @item M
  1507. A 5-bit unsigned integer constant.
  1508. @item O
  1509. A 7-bit unsigned integer constant.
  1510. @item P
  1511. A 8-bit unsigned integer constant.
  1512. @item H
  1513. Any const_double value.
  1514. @end table
  1515. @item ARM family---@file{config/arm/constraints.md}
  1516. @table @code
  1517. @item h
  1518. In Thumb state, the core registers @code{r8}-@code{r15}.
  1519. @item k
  1520. The stack pointer register.
  1521. @item l
  1522. In Thumb State the core registers @code{r0}-@code{r7}. In ARM state this
  1523. is an alias for the @code{r} constraint.
  1524. @item t
  1525. VFP floating-point registers @code{s0}-@code{s31}. Used for 32 bit values.
  1526. @item w
  1527. VFP floating-point registers @code{d0}-@code{d31} and the appropriate
  1528. subset @code{d0}-@code{d15} based on command line options.
  1529. Used for 64 bit values only. Not valid for Thumb1.
  1530. @item y
  1531. The iWMMX co-processor registers.
  1532. @item z
  1533. The iWMMX GR registers.
  1534. @item G
  1535. The floating-point constant 0.0
  1536. @item I
  1537. Integer that is valid as an immediate operand in a data processing
  1538. instruction. That is, an integer in the range 0 to 255 rotated by a
  1539. multiple of 2
  1540. @item J
  1541. Integer in the range @minus{}4095 to 4095
  1542. @item K
  1543. Integer that satisfies constraint @samp{I} when inverted (ones complement)
  1544. @item L
  1545. Integer that satisfies constraint @samp{I} when negated (twos complement)
  1546. @item M
  1547. Integer in the range 0 to 32
  1548. @item Q
  1549. A memory reference where the exact address is in a single register
  1550. (`@samp{m}' is preferable for @code{asm} statements)
  1551. @item R
  1552. An item in the constant pool
  1553. @item S
  1554. A symbol in the text segment of the current file
  1555. @item Uv
  1556. A memory reference suitable for VFP load/store insns (reg+constant offset)
  1557. @item Uy
  1558. A memory reference suitable for iWMMXt load/store instructions.
  1559. @item Uq
  1560. A memory reference suitable for the ARMv4 ldrsb instruction.
  1561. @end table
  1562. @item AVR family---@file{config/avr/constraints.md}
  1563. @table @code
  1564. @item l
  1565. Registers from r0 to r15
  1566. @item a
  1567. Registers from r16 to r23
  1568. @item d
  1569. Registers from r16 to r31
  1570. @item w
  1571. Registers from r24 to r31. These registers can be used in @samp{adiw} command
  1572. @item e
  1573. Pointer register (r26--r31)
  1574. @item b
  1575. Base pointer register (r28--r31)
  1576. @item q
  1577. Stack pointer register (SPH:SPL)
  1578. @item t
  1579. Temporary register r0
  1580. @item x
  1581. Register pair X (r27:r26)
  1582. @item y
  1583. Register pair Y (r29:r28)
  1584. @item z
  1585. Register pair Z (r31:r30)
  1586. @item I
  1587. Constant greater than @minus{}1, less than 64
  1588. @item J
  1589. Constant greater than @minus{}64, less than 1
  1590. @item K
  1591. Constant integer 2
  1592. @item L
  1593. Constant integer 0
  1594. @item M
  1595. Constant that fits in 8 bits
  1596. @item N
  1597. Constant integer @minus{}1
  1598. @item O
  1599. Constant integer 8, 16, or 24
  1600. @item P
  1601. Constant integer 1
  1602. @item G
  1603. A floating point constant 0.0
  1604. @item Q
  1605. A memory address based on Y or Z pointer with displacement.
  1606. @end table
  1607. @item Blackfin family---@file{config/bfin/constraints.md}
  1608. @table @code
  1609. @item a
  1610. P register
  1611. @item d
  1612. D register
  1613. @item z
  1614. A call clobbered P register.
  1615. @item q@var{n}
  1616. A single register. If @var{n} is in the range 0 to 7, the corresponding D
  1617. register. If it is @code{A}, then the register P0.
  1618. @item D
  1619. Even-numbered D register
  1620. @item W
  1621. Odd-numbered D register
  1622. @item e
  1623. Accumulator register.
  1624. @item A
  1625. Even-numbered accumulator register.
  1626. @item B
  1627. Odd-numbered accumulator register.
  1628. @item b
  1629. I register
  1630. @item v
  1631. B register
  1632. @item f
  1633. M register
  1634. @item c
  1635. Registers used for circular buffering, i.e. I, B, or L registers.
  1636. @item C
  1637. The CC register.
  1638. @item t
  1639. LT0 or LT1.
  1640. @item k
  1641. LC0 or LC1.
  1642. @item u
  1643. LB0 or LB1.
  1644. @item x
  1645. Any D, P, B, M, I or L register.
  1646. @item y
  1647. Additional registers typically used only in prologues and epilogues: RETS,
  1648. RETN, RETI, RETX, RETE, ASTAT, SEQSTAT and USP.
  1649. @item w
  1650. Any register except accumulators or CC.
  1651. @item Ksh
  1652. Signed 16 bit integer (in the range @minus{}32768 to 32767)
  1653. @item Kuh
  1654. Unsigned 16 bit integer (in the range 0 to 65535)
  1655. @item Ks7
  1656. Signed 7 bit integer (in the range @minus{}64 to 63)
  1657. @item Ku7
  1658. Unsigned 7 bit integer (in the range 0 to 127)
  1659. @item Ku5
  1660. Unsigned 5 bit integer (in the range 0 to 31)
  1661. @item Ks4
  1662. Signed 4 bit integer (in the range @minus{}8 to 7)
  1663. @item Ks3
  1664. Signed 3 bit integer (in the range @minus{}3 to 4)
  1665. @item Ku3
  1666. Unsigned 3 bit integer (in the range 0 to 7)
  1667. @item P@var{n}
  1668. Constant @var{n}, where @var{n} is a single-digit constant in the range 0 to 4.
  1669. @item PA
  1670. An integer equal to one of the MACFLAG_XXX constants that is suitable for
  1671. use with either accumulator.
  1672. @item PB
  1673. An integer equal to one of the MACFLAG_XXX constants that is suitable for
  1674. use only with accumulator A1.
  1675. @item M1
  1676. Constant 255.
  1677. @item M2
  1678. Constant 65535.
  1679. @item J
  1680. An integer constant with exactly a single bit set.
  1681. @item L
  1682. An integer constant with all bits set except exactly one.
  1683. @item H
  1684. @item Q
  1685. Any SYMBOL_REF.
  1686. @end table
  1687. @item CR16 Architecture---@file{config/cr16/cr16.h}
  1688. @table @code
  1689. @item b
  1690. Registers from r0 to r14 (registers without stack pointer)
  1691. @item t
  1692. Register from r0 to r11 (all 16-bit registers)
  1693. @item p
  1694. Register from r12 to r15 (all 32-bit registers)
  1695. @item I
  1696. Signed constant that fits in 4 bits
  1697. @item J
  1698. Signed constant that fits in 5 bits
  1699. @item K
  1700. Signed constant that fits in 6 bits
  1701. @item L
  1702. Unsigned constant that fits in 4 bits
  1703. @item M
  1704. Signed constant that fits in 32 bits
  1705. @item N
  1706. Check for 64 bits wide constants for add/sub instructions
  1707. @item G
  1708. Floating point constant that is legal for store immediate
  1709. @end table
  1710. @item Epiphany---@file{config/epiphany/constraints.md}
  1711. @table @code
  1712. @item U16
  1713. An unsigned 16-bit constant.
  1714. @item K
  1715. An unsigned 5-bit constant.
  1716. @item L
  1717. A signed 11-bit constant.
  1718. @item Cm1
  1719. A signed 11-bit constant added to @minus{}1.
  1720. Can only match when the @option{-m1reg-@var{reg}} option is active.
  1721. @item Cl1
  1722. Left-shift of @minus{}1, i.e., a bit mask with a block of leading ones, the rest
  1723. being a block of trailing zeroes.
  1724. Can only match when the @option{-m1reg-@var{reg}} option is active.
  1725. @item Cr1
  1726. Right-shift of @minus{}1, i.e., a bit mask with a trailing block of ones, the
  1727. rest being zeroes. Or to put it another way, one less than a power of two.
  1728. Can only match when the @option{-m1reg-@var{reg}} option is active.
  1729. @item Cal
  1730. Constant for arithmetic/logical operations.
  1731. This is like @code{i}, except that for position independent code,
  1732. no symbols / expressions needing relocations are allowed.
  1733. @item Csy
  1734. Symbolic constant for call/jump instruction.
  1735. @item Rcs
  1736. The register class usable in short insns. This is a register class
  1737. constraint, and can thus drive register allocation.
  1738. This constraint won't match unless @option{-mprefer-short-insn-regs} is
  1739. in effect.
  1740. @item Rsc
  1741. The the register class of registers that can be used to hold a
  1742. sibcall call address. I.e., a caller-saved register.
  1743. @item Rct
  1744. Core control register class.
  1745. @item Rgs
  1746. The register group usable in short insns.
  1747. This constraint does not use a register class, so that it only
  1748. passively matches suitable registers, and doesn't drive register allocation.
  1749. @ifset INTERNALS
  1750. @item Car
  1751. Constant suitable for the addsi3_r pattern. This is a valid offset
  1752. For byte, halfword, or word addressing.
  1753. @end ifset
  1754. @item Rra
  1755. Matches the return address if it can be replaced with the link register.
  1756. @item Rcc
  1757. Matches the integer condition code register.
  1758. @item Sra
  1759. Matches the return address if it is in a stack slot.
  1760. @item Cfm
  1761. Matches control register values to switch fp mode, which are encapsulated in
  1762. @code{UNSPEC_FP_MODE}.
  1763. @end table
  1764. @item FRV---@file{config/frv/frv.h}
  1765. @table @code
  1766. @item a
  1767. Register in the class @code{ACC_REGS} (@code{acc0} to @code{acc7}).
  1768. @item b
  1769. Register in the class @code{EVEN_ACC_REGS} (@code{acc0} to @code{acc7}).
  1770. @item c
  1771. Register in the class @code{CC_REGS} (@code{fcc0} to @code{fcc3} and
  1772. @code{icc0} to @code{icc3}).
  1773. @item d
  1774. Register in the class @code{GPR_REGS} (@code{gr0} to @code{gr63}).
  1775. @item e
  1776. Register in the class @code{EVEN_REGS} (@code{gr0} to @code{gr63}).
  1777. Odd registers are excluded not in the class but through the use of a machine
  1778. mode larger than 4 bytes.
  1779. @item f
  1780. Register in the class @code{FPR_REGS} (@code{fr0} to @code{fr63}).
  1781. @item h
  1782. Register in the class @code{FEVEN_REGS} (@code{fr0} to @code{fr63}).
  1783. Odd registers are excluded not in the class but through the use of a machine
  1784. mode larger than 4 bytes.
  1785. @item l
  1786. Register in the class @code{LR_REG} (the @code{lr} register).
  1787. @item q
  1788. Register in the class @code{QUAD_REGS} (@code{gr2} to @code{gr63}).
  1789. Register numbers not divisible by 4 are excluded not in the class but through
  1790. the use of a machine mode larger than 8 bytes.
  1791. @item t
  1792. Register in the class @code{ICC_REGS} (@code{icc0} to @code{icc3}).
  1793. @item u
  1794. Register in the class @code{FCC_REGS} (@code{fcc0} to @code{fcc3}).
  1795. @item v
  1796. Register in the class @code{ICR_REGS} (@code{cc4} to @code{cc7}).
  1797. @item w
  1798. Register in the class @code{FCR_REGS} (@code{cc0} to @code{cc3}).
  1799. @item x
  1800. Register in the class @code{QUAD_FPR_REGS} (@code{fr0} to @code{fr63}).
  1801. Register numbers not divisible by 4 are excluded not in the class but through
  1802. the use of a machine mode larger than 8 bytes.
  1803. @item z
  1804. Register in the class @code{SPR_REGS} (@code{lcr} and @code{lr}).
  1805. @item A
  1806. Register in the class @code{QUAD_ACC_REGS} (@code{acc0} to @code{acc7}).
  1807. @item B
  1808. Register in the class @code{ACCG_REGS} (@code{accg0} to @code{accg7}).
  1809. @item C
  1810. Register in the class @code{CR_REGS} (@code{cc0} to @code{cc7}).
  1811. @item G
  1812. Floating point constant zero
  1813. @item I
  1814. 6-bit signed integer constant
  1815. @item J
  1816. 10-bit signed integer constant
  1817. @item L
  1818. 16-bit signed integer constant
  1819. @item M
  1820. 16-bit unsigned integer constant
  1821. @item N
  1822. 12-bit signed integer constant that is negative---i.e.@: in the
  1823. range of @minus{}2048 to @minus{}1
  1824. @item O
  1825. Constant zero
  1826. @item P
  1827. 12-bit signed integer constant that is greater than zero---i.e.@: in the
  1828. range of 1 to 2047.
  1829. @end table
  1830. @item Hewlett-Packard PA-RISC---@file{config/pa/pa.h}
  1831. @table @code
  1832. @item a
  1833. General register 1
  1834. @item f
  1835. Floating point register
  1836. @item q
  1837. Shift amount register
  1838. @item x
  1839. Floating point register (deprecated)
  1840. @item y
  1841. Upper floating point register (32-bit), floating point register (64-bit)
  1842. @item Z
  1843. Any register
  1844. @item I
  1845. Signed 11-bit integer constant
  1846. @item J
  1847. Signed 14-bit integer constant
  1848. @item K
  1849. Integer constant that can be deposited with a @code{zdepi} instruction
  1850. @item L
  1851. Signed 5-bit integer constant
  1852. @item M
  1853. Integer constant 0
  1854. @item N
  1855. Integer constant that can be loaded with a @code{ldil} instruction
  1856. @item O
  1857. Integer constant whose value plus one is a power of 2
  1858. @item P
  1859. Integer constant that can be used for @code{and} operations in @code{depi}
  1860. and @code{extru} instructions
  1861. @item S
  1862. Integer constant 31
  1863. @item U
  1864. Integer constant 63
  1865. @item G
  1866. Floating-point constant 0.0
  1867. @item A
  1868. A @code{lo_sum} data-linkage-table memory operand
  1869. @item Q
  1870. A memory operand that can be used as the destination operand of an
  1871. integer store instruction
  1872. @item R
  1873. A scaled or unscaled indexed memory operand
  1874. @item T
  1875. A memory operand for floating-point loads and stores
  1876. @item W
  1877. A register indirect memory operand
  1878. @end table
  1879. @item Intel IA-64---@file{config/ia64/ia64.h}
  1880. @table @code
  1881. @item a
  1882. General register @code{r0} to @code{r3} for @code{addl} instruction
  1883. @item b
  1884. Branch register
  1885. @item c
  1886. Predicate register (@samp{c} as in ``conditional'')
  1887. @item d
  1888. Application register residing in M-unit
  1889. @item e
  1890. Application register residing in I-unit
  1891. @item f
  1892. Floating-point register
  1893. @item m
  1894. Memory operand. If used together with @samp{<} or @samp{>},
  1895. the operand can have postincrement and postdecrement which
  1896. require printing with @samp{%Pn} on IA-64.
  1897. @item G
  1898. Floating-point constant 0.0 or 1.0
  1899. @item I
  1900. 14-bit signed integer constant
  1901. @item J
  1902. 22-bit signed integer constant
  1903. @item K
  1904. 8-bit signed integer constant for logical instructions
  1905. @item L
  1906. 8-bit adjusted signed integer constant for compare pseudo-ops
  1907. @item M
  1908. 6-bit unsigned integer constant for shift counts
  1909. @item N
  1910. 9-bit signed integer constant for load and store postincrements
  1911. @item O
  1912. The constant zero
  1913. @item P
  1914. 0 or @minus{}1 for @code{dep} instruction
  1915. @item Q
  1916. Non-volatile memory for floating-point loads and stores
  1917. @item R
  1918. Integer constant in the range 1 to 4 for @code{shladd} instruction
  1919. @item S
  1920. Memory operand except postincrement and postdecrement. This is
  1921. now roughly the same as @samp{m} when not used together with @samp{<}
  1922. or @samp{>}.
  1923. @end table
  1924. @item M32C---@file{config/m32c/m32c.c}
  1925. @table @code
  1926. @item Rsp
  1927. @itemx Rfb
  1928. @itemx Rsb
  1929. @samp{$sp}, @samp{$fb}, @samp{$sb}.
  1930. @item Rcr
  1931. Any control register, when they're 16 bits wide (nothing if control
  1932. registers are 24 bits wide)
  1933. @item Rcl
  1934. Any control register, when they're 24 bits wide.
  1935. @item R0w
  1936. @itemx R1w
  1937. @itemx R2w
  1938. @itemx R3w
  1939. $r0, $r1, $r2, $r3.
  1940. @item R02
  1941. $r0 or $r2, or $r2r0 for 32 bit values.
  1942. @item R13
  1943. $r1 or $r3, or $r3r1 for 32 bit values.
  1944. @item Rdi
  1945. A register that can hold a 64 bit value.
  1946. @item Rhl
  1947. $r0 or $r1 (registers with addressable high/low bytes)
  1948. @item R23
  1949. $r2 or $r3
  1950. @item Raa
  1951. Address registers
  1952. @item Raw
  1953. Address registers when they're 16 bits wide.
  1954. @item Ral
  1955. Address registers when they're 24 bits wide.
  1956. @item Rqi
  1957. Registers that can hold QI values.
  1958. @item Rad
  1959. Registers that can be used with displacements ($a0, $a1, $sb).
  1960. @item Rsi
  1961. Registers that can hold 32 bit values.
  1962. @item Rhi
  1963. Registers that can hold 16 bit values.
  1964. @item Rhc
  1965. Registers chat can hold 16 bit values, including all control
  1966. registers.
  1967. @item Rra
  1968. $r0 through R1, plus $a0 and $a1.
  1969. @item Rfl
  1970. The flags register.
  1971. @item Rmm
  1972. The memory-based pseudo-registers $mem0 through $mem15.
  1973. @item Rpi
  1974. Registers that can hold pointers (16 bit registers for r8c, m16c; 24
  1975. bit registers for m32cm, m32c).
  1976. @item Rpa
  1977. Matches multiple registers in a PARALLEL to form a larger register.
  1978. Used to match function return values.
  1979. @item Is3
  1980. @minus{}8 @dots{} 7
  1981. @item IS1
  1982. @minus{}128 @dots{} 127
  1983. @item IS2
  1984. @minus{}32768 @dots{} 32767
  1985. @item IU2
  1986. 0 @dots{} 65535
  1987. @item In4
  1988. @minus{}8 @dots{} @minus{}1 or 1 @dots{} 8
  1989. @item In5
  1990. @minus{}16 @dots{} @minus{}1 or 1 @dots{} 16
  1991. @item In6
  1992. @minus{}32 @dots{} @minus{}1 or 1 @dots{} 32
  1993. @item IM2
  1994. @minus{}65536 @dots{} @minus{}1
  1995. @item Ilb
  1996. An 8 bit value with exactly one bit set.
  1997. @item Ilw
  1998. A 16 bit value with exactly one bit set.
  1999. @item Sd
  2000. The common src/dest memory addressing modes.
  2001. @item Sa
  2002. Memory addressed using $a0 or $a1.
  2003. @item Si
  2004. Memory addressed with immediate addresses.
  2005. @item Ss
  2006. Memory addressed using the stack pointer ($sp).
  2007. @item Sf
  2008. Memory addressed using the frame base register ($fb).
  2009. @item Ss
  2010. Memory addressed using the small base register ($sb).
  2011. @item S1
  2012. $r1h
  2013. @end table
  2014. @item MeP---@file{config/mep/constraints.md}
  2015. @table @code
  2016. @item a
  2017. The $sp register.
  2018. @item b
  2019. The $tp register.
  2020. @item c
  2021. Any control register.
  2022. @item d
  2023. Either the $hi or the $lo register.
  2024. @item em
  2025. Coprocessor registers that can be directly loaded ($c0-$c15).
  2026. @item ex
  2027. Coprocessor registers that can be moved to each other.
  2028. @item er
  2029. Coprocessor registers that can be moved to core registers.
  2030. @item h
  2031. The $hi register.
  2032. @item j
  2033. The $rpc register.
  2034. @item l
  2035. The $lo register.
  2036. @item t
  2037. Registers which can be used in $tp-relative addressing.
  2038. @item v
  2039. The $gp register.
  2040. @item x
  2041. The coprocessor registers.
  2042. @item y
  2043. The coprocessor control registers.
  2044. @item z
  2045. The $0 register.
  2046. @item A
  2047. User-defined register set A.
  2048. @item B
  2049. User-defined register set B.
  2050. @item C
  2051. User-defined register set C.
  2052. @item D
  2053. User-defined register set D.
  2054. @item I
  2055. Offsets for $gp-rel addressing.
  2056. @item J
  2057. Constants that can be used directly with boolean insns.
  2058. @item K
  2059. Constants that can be moved directly to registers.
  2060. @item L
  2061. Small constants that can be added to registers.
  2062. @item M
  2063. Long shift counts.
  2064. @item N
  2065. Small constants that can be compared to registers.
  2066. @item O
  2067. Constants that can be loaded into the top half of registers.
  2068. @item S
  2069. Signed 8-bit immediates.
  2070. @item T
  2071. Symbols encoded for $tp-rel or $gp-rel addressing.
  2072. @item U
  2073. Non-constant addresses for loading/saving coprocessor registers.
  2074. @item W
  2075. The top half of a symbol's value.
  2076. @item Y
  2077. A register indirect address without offset.
  2078. @item Z
  2079. Symbolic references to the control bus.
  2080. @end table
  2081. @item MicroBlaze---@file{config/microblaze/constraints.md}
  2082. @table @code
  2083. @item d
  2084. A general register (@code{r0} to @code{r31}).
  2085. @item z
  2086. A status register (@code{rmsr}, @code{$fcc1} to @code{$fcc7}).
  2087. @end table
  2088. @item MIPS---@file{config/mips/constraints.md}
  2089. @table @code
  2090. @item d
  2091. An address register. This is equivalent to @code{r} unless
  2092. generating MIPS16 code.
  2093. @item f
  2094. A floating-point register (if available).
  2095. @item h
  2096. Formerly the @code{hi} register. This constraint is no longer supported.
  2097. @item l
  2098. The @code{lo} register. Use this register to store values that are
  2099. no bigger than a word.
  2100. @item x
  2101. The concatenated @code{hi} and @code{lo} registers. Use this register
  2102. to store doubleword values.
  2103. @item c
  2104. A register suitable for use in an indirect jump. This will always be
  2105. @code{$25} for @option{-mabicalls}.
  2106. @item v
  2107. Register @code{$3}. Do not use this constraint in new code;
  2108. it is retained only for compatibility with glibc.
  2109. @item y
  2110. Equivalent to @code{r}; retained for backwards compatibility.
  2111. @item z
  2112. A floating-point condition code register.
  2113. @item I
  2114. A signed 16-bit constant (for arithmetic instructions).
  2115. @item J
  2116. Integer zero.
  2117. @item K
  2118. An unsigned 16-bit constant (for logic instructions).
  2119. @item L
  2120. A signed 32-bit constant in which the lower 16 bits are zero.
  2121. Such constants can be loaded using @code{lui}.
  2122. @item M
  2123. A constant that cannot be loaded using @code{lui}, @code{addiu}
  2124. or @code{ori}.
  2125. @item N
  2126. A constant in the range @minus{}65535 to @minus{}1 (inclusive).
  2127. @item O
  2128. A signed 15-bit constant.
  2129. @item P
  2130. A constant in the range 1 to 65535 (inclusive).
  2131. @item G
  2132. Floating-point zero.
  2133. @item R
  2134. An address that can be used in a non-macro load or store.
  2135. @item ZC
  2136. A memory operand whose address is formed by a base register and offset
  2137. that is suitable for use in instructions with the same addressing mode
  2138. as @code{ll} and @code{sc}.
  2139. @item ZD
  2140. An address suitable for a @code{prefetch} instruction, or for any other
  2141. instruction with the same addressing mode as @code{prefetch}.
  2142. @end table
  2143. @item Motorola 680x0---@file{config/m68k/constraints.md}
  2144. @table @code
  2145. @item a
  2146. Address register
  2147. @item d
  2148. Data register
  2149. @item f
  2150. 68881 floating-point register, if available
  2151. @item I
  2152. Integer in the range 1 to 8
  2153. @item J
  2154. 16-bit signed number
  2155. @item K
  2156. Signed number whose magnitude is greater than 0x80
  2157. @item L
  2158. Integer in the range @minus{}8 to @minus{}1
  2159. @item M
  2160. Signed number whose magnitude is greater than 0x100
  2161. @item N
  2162. Range 24 to 31, rotatert:SI 8 to 1 expressed as rotate
  2163. @item O
  2164. 16 (for rotate using swap)
  2165. @item P
  2166. Range 8 to 15, rotatert:HI 8 to 1 expressed as rotate
  2167. @item R
  2168. Numbers that mov3q can handle
  2169. @item G
  2170. Floating point constant that is not a 68881 constant
  2171. @item S
  2172. Operands that satisfy 'm' when -mpcrel is in effect
  2173. @item T
  2174. Operands that satisfy 's' when -mpcrel is not in effect
  2175. @item Q
  2176. Address register indirect addressing mode
  2177. @item U
  2178. Register offset addressing
  2179. @item W
  2180. const_call_operand
  2181. @item Cs
  2182. symbol_ref or const
  2183. @item Ci
  2184. const_int
  2185. @item C0
  2186. const_int 0
  2187. @item Cj
  2188. Range of signed numbers that don't fit in 16 bits
  2189. @item Cmvq
  2190. Integers valid for mvq
  2191. @item Capsw
  2192. Integers valid for a moveq followed by a swap
  2193. @item Cmvz
  2194. Integers valid for mvz
  2195. @item Cmvs
  2196. Integers valid for mvs
  2197. @item Ap
  2198. push_operand
  2199. @item Ac
  2200. Non-register operands allowed in clr
  2201. @end table
  2202. @item Moxie---@file{config/moxie/constraints.md}
  2203. @table @code
  2204. @item A
  2205. An absolute address
  2206. @item B
  2207. An offset address
  2208. @item W
  2209. A register indirect memory operand
  2210. @item I
  2211. A constant in the range of 0 to 255.
  2212. @item N
  2213. A constant in the range of 0 to @minus{}255.
  2214. @end table
  2215. @item MSP430--@file{config/msp430/constraints.md}
  2216. @table @code
  2217. @item R12
  2218. Register R12.
  2219. @item R13
  2220. Register R13.
  2221. @item K
  2222. Integer constant 1.
  2223. @item L
  2224. Integer constant -1^20..1^19.
  2225. @item M
  2226. Integer constant 1-4.
  2227. @item Ya
  2228. Memory references which do not require an extended MOVX instruction.
  2229. @item Yl
  2230. Memory reference, labels only.
  2231. @item Ys
  2232. Memory reference, stack only.
  2233. @end table
  2234. @item NDS32---@file{config/nds32/constraints.md}
  2235. @table @code
  2236. @item w
  2237. LOW register class $r0 to $r7 constraint for V3/V3M ISA.
  2238. @item l
  2239. LOW register class $r0 to $r7.
  2240. @item d
  2241. MIDDLE register class $r0 to $r11, $r16 to $r19.
  2242. @item h
  2243. HIGH register class $r12 to $r14, $r20 to $r31.
  2244. @item t
  2245. Temporary assist register $ta (i.e.@: $r15).
  2246. @item k
  2247. Stack register $sp.
  2248. @item Iu03
  2249. Unsigned immediate 3-bit value.
  2250. @item In03
  2251. Negative immediate 3-bit value in the range of @minus{}7--0.
  2252. @item Iu04
  2253. Unsigned immediate 4-bit value.
  2254. @item Is05
  2255. Signed immediate 5-bit value.
  2256. @item Iu05
  2257. Unsigned immediate 5-bit value.
  2258. @item In05
  2259. Negative immediate 5-bit value in the range of @minus{}31--0.
  2260. @item Ip05
  2261. Unsigned immediate 5-bit value for movpi45 instruction with range 16--47.
  2262. @item Iu06
  2263. Unsigned immediate 6-bit value constraint for addri36.sp instruction.
  2264. @item Iu08
  2265. Unsigned immediate 8-bit value.
  2266. @item Iu09
  2267. Unsigned immediate 9-bit value.
  2268. @item Is10
  2269. Signed immediate 10-bit value.
  2270. @item Is11
  2271. Signed immediate 11-bit value.
  2272. @item Is15
  2273. Signed immediate 15-bit value.
  2274. @item Iu15
  2275. Unsigned immediate 15-bit value.
  2276. @item Ic15
  2277. A constant which is not in the range of imm15u but ok for bclr instruction.
  2278. @item Ie15
  2279. A constant which is not in the range of imm15u but ok for bset instruction.
  2280. @item It15
  2281. A constant which is not in the range of imm15u but ok for btgl instruction.
  2282. @item Ii15
  2283. A constant whose compliment value is in the range of imm15u
  2284. and ok for bitci instruction.
  2285. @item Is16
  2286. Signed immediate 16-bit value.
  2287. @item Is17
  2288. Signed immediate 17-bit value.
  2289. @item Is19
  2290. Signed immediate 19-bit value.
  2291. @item Is20
  2292. Signed immediate 20-bit value.
  2293. @item Ihig
  2294. The immediate value that can be simply set high 20-bit.
  2295. @item Izeb
  2296. The immediate value 0xff.
  2297. @item Izeh
  2298. The immediate value 0xffff.
  2299. @item Ixls
  2300. The immediate value 0x01.
  2301. @item Ix11
  2302. The immediate value 0x7ff.
  2303. @item Ibms
  2304. The immediate value with power of 2.
  2305. @item Ifex
  2306. The immediate value with power of 2 minus 1.
  2307. @item U33
  2308. Memory constraint for 333 format.
  2309. @item U45
  2310. Memory constraint for 45 format.
  2311. @item U37
  2312. Memory constraint for 37 format.
  2313. @end table
  2314. @item Nios II family---@file{config/nios2/constraints.md}
  2315. @table @code
  2316. @item I
  2317. Integer that is valid as an immediate operand in an
  2318. instruction taking a signed 16-bit number. Range
  2319. @minus{}32768 to 32767.
  2320. @item J
  2321. Integer that is valid as an immediate operand in an
  2322. instruction taking an unsigned 16-bit number. Range
  2323. 0 to 65535.
  2324. @item K
  2325. Integer that is valid as an immediate operand in an
  2326. instruction taking only the upper 16-bits of a
  2327. 32-bit number. Range 32-bit numbers with the lower
  2328. 16-bits being 0.
  2329. @item L
  2330. Integer that is valid as an immediate operand for a
  2331. shift instruction. Range 0 to 31.
  2332. @item M
  2333. Integer that is valid as an immediate operand for
  2334. only the value 0. Can be used in conjunction with
  2335. the format modifier @code{z} to use @code{r0}
  2336. instead of @code{0} in the assembly output.
  2337. @item N
  2338. Integer that is valid as an immediate operand for
  2339. a custom instruction opcode. Range 0 to 255.
  2340. @item S
  2341. Matches immediates which are addresses in the small
  2342. data section and therefore can be added to @code{gp}
  2343. as a 16-bit immediate to re-create their 32-bit value.
  2344. @ifset INTERNALS
  2345. @item T
  2346. A @code{const} wrapped @code{UNSPEC} expression,
  2347. representing a supported PIC or TLS relocation.
  2348. @end ifset
  2349. @end table
  2350. @item PDP-11---@file{config/pdp11/constraints.md}
  2351. @table @code
  2352. @item a
  2353. Floating point registers AC0 through AC3. These can be loaded from/to
  2354. memory with a single instruction.
  2355. @item d
  2356. Odd numbered general registers (R1, R3, R5). These are used for
  2357. 16-bit multiply operations.
  2358. @item f
  2359. Any of the floating point registers (AC0 through AC5).
  2360. @item G
  2361. Floating point constant 0.
  2362. @item I
  2363. An integer constant that fits in 16 bits.
  2364. @item J
  2365. An integer constant whose low order 16 bits are zero.
  2366. @item K
  2367. An integer constant that does not meet the constraints for codes
  2368. @samp{I} or @samp{J}.
  2369. @item L
  2370. The integer constant 1.
  2371. @item M
  2372. The integer constant @minus{}1.
  2373. @item N
  2374. The integer constant 0.
  2375. @item O
  2376. Integer constants @minus{}4 through @minus{}1 and 1 through 4; shifts by these
  2377. amounts are handled as multiple single-bit shifts rather than a single
  2378. variable-length shift.
  2379. @item Q
  2380. A memory reference which requires an additional word (address or
  2381. offset) after the opcode.
  2382. @item R
  2383. A memory reference that is encoded within the opcode.
  2384. @end table
  2385. @item PowerPC and IBM RS6000---@file{config/rs6000/constraints.md}
  2386. @table @code
  2387. @item b
  2388. Address base register
  2389. @item d
  2390. Floating point register (containing 64-bit value)
  2391. @item f
  2392. Floating point register (containing 32-bit value)
  2393. @item v
  2394. Altivec vector register
  2395. @item wa
  2396. Any VSX register if the -mvsx option was used or NO_REGS.
  2397. When using any of the register constraints (@code{wa}, @code{wd},
  2398. @code{wf}, @code{wg}, @code{wh}, @code{wi}, @code{wj}, @code{wk},
  2399. @code{wl}, @code{wm}, @code{ws}, @code{wt}, @code{wu}, @code{wv},
  2400. @code{ww}, or @code{wy}) that take VSX registers, you must use
  2401. @code{%x<n>} in the template so that the correct register is used.
  2402. Otherwise the register number output in the assembly file will be
  2403. incorrect if an Altivec register is an operand of a VSX instruction
  2404. that expects VSX register numbering.
  2405. @smallexample
  2406. asm ("xvadddp %x0,%x1,%x2" : "=wa" (v1) : "wa" (v2), "wa" (v3));
  2407. @end smallexample
  2408. is correct, but:
  2409. @smallexample
  2410. asm ("xvadddp %0,%1,%2" : "=wa" (v1) : "wa" (v2), "wa" (v3));
  2411. @end smallexample
  2412. is not correct.
  2413. @item wd
  2414. VSX vector register to hold vector double data or NO_REGS.
  2415. @item wf
  2416. VSX vector register to hold vector float data or NO_REGS.
  2417. @item wg
  2418. If @option{-mmfpgpr} was used, a floating point register or NO_REGS.
  2419. @item wh
  2420. Floating point register if direct moves are available, or NO_REGS.
  2421. @item wi
  2422. FP or VSX register to hold 64-bit integers for VSX insns or NO_REGS.
  2423. @item wj
  2424. FP or VSX register to hold 64-bit integers for direct moves or NO_REGS.
  2425. @item wk
  2426. FP or VSX register to hold 64-bit doubles for direct moves or NO_REGS.
  2427. @item wl
  2428. Floating point register if the LFIWAX instruction is enabled or NO_REGS.
  2429. @item wm
  2430. VSX register if direct move instructions are enabled, or NO_REGS.
  2431. @item wn
  2432. No register (NO_REGS).
  2433. @item wr
  2434. General purpose register if 64-bit instructions are enabled or NO_REGS.
  2435. @item ws
  2436. VSX vector register to hold scalar double values or NO_REGS.
  2437. @item wt
  2438. VSX vector register to hold 128 bit integer or NO_REGS.
  2439. @item wu
  2440. Altivec register to use for float/32-bit int loads/stores or NO_REGS.
  2441. @item wv
  2442. Altivec register to use for double loads/stores or NO_REGS.
  2443. @item ww
  2444. FP or VSX register to perform float operations under @option{-mvsx} or NO_REGS.
  2445. @item wx
  2446. Floating point register if the STFIWX instruction is enabled or NO_REGS.
  2447. @item wy
  2448. FP or VSX register to perform ISA 2.07 float ops or NO_REGS.
  2449. @item wz
  2450. Floating point register if the LFIWZX instruction is enabled or NO_REGS.
  2451. @item wD
  2452. Int constant that is the element number of the 64-bit scalar in a vector.
  2453. @item wQ
  2454. A memory address that will work with the @code{lq} and @code{stq}
  2455. instructions.
  2456. @item h
  2457. @samp{MQ}, @samp{CTR}, or @samp{LINK} register
  2458. @item q
  2459. @samp{MQ} register
  2460. @item c
  2461. @samp{CTR} register
  2462. @item l
  2463. @samp{LINK} register
  2464. @item x
  2465. @samp{CR} register (condition register) number 0
  2466. @item y
  2467. @samp{CR} register (condition register)
  2468. @item z
  2469. @samp{XER[CA]} carry bit (part of the XER register)
  2470. @item I
  2471. Signed 16-bit constant
  2472. @item J
  2473. Unsigned 16-bit constant shifted left 16 bits (use @samp{L} instead for
  2474. @code{SImode} constants)
  2475. @item K
  2476. Unsigned 16-bit constant
  2477. @item L
  2478. Signed 16-bit constant shifted left 16 bits
  2479. @item M
  2480. Constant larger than 31
  2481. @item N
  2482. Exact power of 2
  2483. @item O
  2484. Zero
  2485. @item P
  2486. Constant whose negation is a signed 16-bit constant
  2487. @item G
  2488. Floating point constant that can be loaded into a register with one
  2489. instruction per word
  2490. @item H
  2491. Integer/Floating point constant that can be loaded into a register using
  2492. three instructions
  2493. @item m
  2494. Memory operand.
  2495. Normally, @code{m} does not allow addresses that update the base register.
  2496. If @samp{<} or @samp{>} constraint is also used, they are allowed and
  2497. therefore on PowerPC targets in that case it is only safe
  2498. to use @samp{m<>} in an @code{asm} statement if that @code{asm} statement
  2499. accesses the operand exactly once. The @code{asm} statement must also
  2500. use @samp{%U@var{<opno>}} as a placeholder for the ``update'' flag in the
  2501. corresponding load or store instruction. For example:
  2502. @smallexample
  2503. asm ("st%U0 %1,%0" : "=m<>" (mem) : "r" (val));
  2504. @end smallexample
  2505. is correct but:
  2506. @smallexample
  2507. asm ("st %1,%0" : "=m<>" (mem) : "r" (val));
  2508. @end smallexample
  2509. is not.
  2510. @item es
  2511. A ``stable'' memory operand; that is, one which does not include any
  2512. automodification of the base register. This used to be useful when
  2513. @samp{m} allowed automodification of the base register, but as those are now only
  2514. allowed when @samp{<} or @samp{>} is used, @samp{es} is basically the same
  2515. as @samp{m} without @samp{<} and @samp{>}.
  2516. @item Q
  2517. Memory operand that is an offset from a register (it is usually better
  2518. to use @samp{m} or @samp{es} in @code{asm} statements)
  2519. @item Z
  2520. Memory operand that is an indexed or indirect from a register (it is
  2521. usually better to use @samp{m} or @samp{es} in @code{asm} statements)
  2522. @item R
  2523. AIX TOC entry
  2524. @item a
  2525. Address operand that is an indexed or indirect from a register (@samp{p} is
  2526. preferable for @code{asm} statements)
  2527. @item S
  2528. Constant suitable as a 64-bit mask operand
  2529. @item T
  2530. Constant suitable as a 32-bit mask operand
  2531. @item U
  2532. System V Release 4 small data area reference
  2533. @item t
  2534. AND masks that can be performed by two rldic@{l, r@} instructions
  2535. @item W
  2536. Vector constant that does not require memory
  2537. @item j
  2538. Vector constant that is all zeros.
  2539. @end table
  2540. @item RL78---@file{config/rl78/constraints.md}
  2541. @table @code
  2542. @item Int3
  2543. An integer constant in the range 1 @dots{} 7.
  2544. @item Int8
  2545. An integer constant in the range 0 @dots{} 255.
  2546. @item J
  2547. An integer constant in the range @minus{}255 @dots{} 0
  2548. @item K
  2549. The integer constant 1.
  2550. @item L
  2551. The integer constant -1.
  2552. @item M
  2553. The integer constant 0.
  2554. @item N
  2555. The integer constant 2.
  2556. @item O
  2557. The integer constant -2.
  2558. @item P
  2559. An integer constant in the range 1 @dots{} 15.
  2560. @item Qbi
  2561. The built-in compare types--eq, ne, gtu, ltu, geu, and leu.
  2562. @item Qsc
  2563. The synthetic compare types--gt, lt, ge, and le.
  2564. @item Wab
  2565. A memory reference with an absolute address.
  2566. @item Wbc
  2567. A memory reference using @code{BC} as a base register, with an optional offset.
  2568. @item Wca
  2569. A memory reference using @code{AX}, @code{BC}, @code{DE}, or @code{HL} for the address, for calls.
  2570. @item Wcv
  2571. A memory reference using any 16-bit register pair for the address, for calls.
  2572. @item Wd2
  2573. A memory reference using @code{DE} as a base register, with an optional offset.
  2574. @item Wde
  2575. A memory reference using @code{DE} as a base register, without any offset.
  2576. @item Wfr
  2577. Any memory reference to an address in the far address space.
  2578. @item Wh1
  2579. A memory reference using @code{HL} as a base register, with an optional one-byte offset.
  2580. @item Whb
  2581. A memory reference using @code{HL} as a base register, with @code{B} or @code{C} as the index register.
  2582. @item Whl
  2583. A memory reference using @code{HL} as a base register, without any offset.
  2584. @item Ws1
  2585. A memory reference using @code{SP} as a base register, with an optional one-byte offset.
  2586. @item Y
  2587. Any memory reference to an address in the near address space.
  2588. @item A
  2589. The @code{AX} register.
  2590. @item B
  2591. The @code{BC} register.
  2592. @item D
  2593. The @code{DE} register.
  2594. @item R
  2595. @code{A} through @code{L} registers.
  2596. @item S
  2597. The @code{SP} register.
  2598. @item T
  2599. The @code{HL} register.
  2600. @item Z08W
  2601. The 16-bit @code{R8} register.
  2602. @item Z10W
  2603. The 16-bit @code{R10} register.
  2604. @item Zint
  2605. The registers reserved for interrupts (@code{R24} to @code{R31}).
  2606. @item a
  2607. The @code{A} register.
  2608. @item b
  2609. The @code{B} register.
  2610. @item c
  2611. The @code{C} register.
  2612. @item d
  2613. The @code{D} register.
  2614. @item e
  2615. The @code{E} register.
  2616. @item h
  2617. The @code{H} register.
  2618. @item l
  2619. The @code{L} register.
  2620. @item v
  2621. The virtual registers.
  2622. @item w
  2623. The @code{PSW} register.
  2624. @item x
  2625. The @code{X} register.
  2626. @end table
  2627. @item RX---@file{config/rx/constraints.md}
  2628. @table @code
  2629. @item Q
  2630. An address which does not involve register indirect addressing or
  2631. pre/post increment/decrement addressing.
  2632. @item Symbol
  2633. A symbol reference.
  2634. @item Int08
  2635. A constant in the range @minus{}256 to 255, inclusive.
  2636. @item Sint08
  2637. A constant in the range @minus{}128 to 127, inclusive.
  2638. @item Sint16
  2639. A constant in the range @minus{}32768 to 32767, inclusive.
  2640. @item Sint24
  2641. A constant in the range @minus{}8388608 to 8388607, inclusive.
  2642. @item Uint04
  2643. A constant in the range 0 to 15, inclusive.
  2644. @end table
  2645. @item S/390 and zSeries---@file{config/s390/s390.h}
  2646. @table @code
  2647. @item a
  2648. Address register (general purpose register except r0)
  2649. @item c
  2650. Condition code register
  2651. @item d
  2652. Data register (arbitrary general purpose register)
  2653. @item f
  2654. Floating-point register
  2655. @item I
  2656. Unsigned 8-bit constant (0--255)
  2657. @item J
  2658. Unsigned 12-bit constant (0--4095)
  2659. @item K
  2660. Signed 16-bit constant (@minus{}32768--32767)
  2661. @item L
  2662. Value appropriate as displacement.
  2663. @table @code
  2664. @item (0..4095)
  2665. for short displacement
  2666. @item (@minus{}524288..524287)
  2667. for long displacement
  2668. @end table
  2669. @item M
  2670. Constant integer with a value of 0x7fffffff.
  2671. @item N
  2672. Multiple letter constraint followed by 4 parameter letters.
  2673. @table @code
  2674. @item 0..9:
  2675. number of the part counting from most to least significant
  2676. @item H,Q:
  2677. mode of the part
  2678. @item D,S,H:
  2679. mode of the containing operand
  2680. @item 0,F:
  2681. value of the other parts (F---all bits set)
  2682. @end table
  2683. The constraint matches if the specified part of a constant
  2684. has a value different from its other parts.
  2685. @item Q
  2686. Memory reference without index register and with short displacement.
  2687. @item R
  2688. Memory reference with index register and short displacement.
  2689. @item S
  2690. Memory reference without index register but with long displacement.
  2691. @item T
  2692. Memory reference with index register and long displacement.
  2693. @item U
  2694. Pointer with short displacement.
  2695. @item W
  2696. Pointer with long displacement.
  2697. @item Y
  2698. Shift count operand.
  2699. @end table
  2700. @need 1000
  2701. @item SPARC---@file{config/sparc/sparc.h}
  2702. @table @code
  2703. @item f
  2704. Floating-point register on the SPARC-V8 architecture and
  2705. lower floating-point register on the SPARC-V9 architecture.
  2706. @item e
  2707. Floating-point register. It is equivalent to @samp{f} on the
  2708. SPARC-V8 architecture and contains both lower and upper
  2709. floating-point registers on the SPARC-V9 architecture.
  2710. @item c
  2711. Floating-point condition code register.
  2712. @item d
  2713. Lower floating-point register. It is only valid on the SPARC-V9
  2714. architecture when the Visual Instruction Set is available.
  2715. @item b
  2716. Floating-point register. It is only valid on the SPARC-V9 architecture
  2717. when the Visual Instruction Set is available.
  2718. @item h
  2719. 64-bit global or out register for the SPARC-V8+ architecture.
  2720. @item C
  2721. The constant all-ones, for floating-point.
  2722. @item A
  2723. Signed 5-bit constant
  2724. @item D
  2725. A vector constant
  2726. @item I
  2727. Signed 13-bit constant
  2728. @item J
  2729. Zero
  2730. @item K
  2731. 32-bit constant with the low 12 bits clear (a constant that can be
  2732. loaded with the @code{sethi} instruction)
  2733. @item L
  2734. A constant in the range supported by @code{movcc} instructions (11-bit
  2735. signed immediate)
  2736. @item M
  2737. A constant in the range supported by @code{movrcc} instructions (10-bit
  2738. signed immediate)
  2739. @item N
  2740. Same as @samp{K}, except that it verifies that bits that are not in the
  2741. lower 32-bit range are all zero. Must be used instead of @samp{K} for
  2742. modes wider than @code{SImode}
  2743. @item O
  2744. The constant 4096
  2745. @item G
  2746. Floating-point zero
  2747. @item H
  2748. Signed 13-bit constant, sign-extended to 32 or 64 bits
  2749. @item P
  2750. The constant -1
  2751. @item Q
  2752. Floating-point constant whose integral representation can
  2753. be moved into an integer register using a single sethi
  2754. instruction
  2755. @item R
  2756. Floating-point constant whose integral representation can
  2757. be moved into an integer register using a single mov
  2758. instruction
  2759. @item S
  2760. Floating-point constant whose integral representation can
  2761. be moved into an integer register using a high/lo_sum
  2762. instruction sequence
  2763. @item T
  2764. Memory address aligned to an 8-byte boundary
  2765. @item U
  2766. Even register
  2767. @item W
  2768. Memory address for @samp{e} constraint registers
  2769. @item w
  2770. Memory address with only a base register
  2771. @item Y
  2772. Vector zero
  2773. @end table
  2774. @item SPU---@file{config/spu/spu.h}
  2775. @table @code
  2776. @item a
  2777. An immediate which can be loaded with the il/ila/ilh/ilhu instructions. const_int is treated as a 64 bit value.
  2778. @item c
  2779. An immediate for and/xor/or instructions. const_int is treated as a 64 bit value.
  2780. @item d
  2781. An immediate for the @code{iohl} instruction. const_int is treated as a 64 bit value.
  2782. @item f
  2783. An immediate which can be loaded with @code{fsmbi}.
  2784. @item A
  2785. An immediate which can be loaded with the il/ila/ilh/ilhu instructions. const_int is treated as a 32 bit value.
  2786. @item B
  2787. An immediate for most arithmetic instructions. const_int is treated as a 32 bit value.
  2788. @item C
  2789. An immediate for and/xor/or instructions. const_int is treated as a 32 bit value.
  2790. @item D
  2791. An immediate for the @code{iohl} instruction. const_int is treated as a 32 bit value.
  2792. @item I
  2793. A constant in the range [@minus{}64, 63] for shift/rotate instructions.
  2794. @item J
  2795. An unsigned 7-bit constant for conversion/nop/channel instructions.
  2796. @item K
  2797. A signed 10-bit constant for most arithmetic instructions.
  2798. @item M
  2799. A signed 16 bit immediate for @code{stop}.
  2800. @item N
  2801. An unsigned 16-bit constant for @code{iohl} and @code{fsmbi}.
  2802. @item O
  2803. An unsigned 7-bit constant whose 3 least significant bits are 0.
  2804. @item P
  2805. An unsigned 3-bit constant for 16-byte rotates and shifts
  2806. @item R
  2807. Call operand, reg, for indirect calls
  2808. @item S
  2809. Call operand, symbol, for relative calls.
  2810. @item T
  2811. Call operand, const_int, for absolute calls.
  2812. @item U
  2813. An immediate which can be loaded with the il/ila/ilh/ilhu instructions. const_int is sign extended to 128 bit.
  2814. @item W
  2815. An immediate for shift and rotate instructions. const_int is treated as a 32 bit value.
  2816. @item Y
  2817. An immediate for and/xor/or instructions. const_int is sign extended as a 128 bit.
  2818. @item Z
  2819. An immediate for the @code{iohl} instruction. const_int is sign extended to 128 bit.
  2820. @end table
  2821. @item TI C6X family---@file{config/c6x/constraints.md}
  2822. @table @code
  2823. @item a
  2824. Register file A (A0--A31).
  2825. @item b
  2826. Register file B (B0--B31).
  2827. @item A
  2828. Predicate registers in register file A (A0--A2 on C64X and
  2829. higher, A1 and A2 otherwise).
  2830. @item B
  2831. Predicate registers in register file B (B0--B2).
  2832. @item C
  2833. A call-used register in register file B (B0--B9, B16--B31).
  2834. @item Da
  2835. Register file A, excluding predicate registers (A3--A31,
  2836. plus A0 if not C64X or higher).
  2837. @item Db
  2838. Register file B, excluding predicate registers (B3--B31).
  2839. @item Iu4
  2840. Integer constant in the range 0 @dots{} 15.
  2841. @item Iu5
  2842. Integer constant in the range 0 @dots{} 31.
  2843. @item In5
  2844. Integer constant in the range @minus{}31 @dots{} 0.
  2845. @item Is5
  2846. Integer constant in the range @minus{}16 @dots{} 15.
  2847. @item I5x
  2848. Integer constant that can be the operand of an ADDA or a SUBA insn.
  2849. @item IuB
  2850. Integer constant in the range 0 @dots{} 65535.
  2851. @item IsB
  2852. Integer constant in the range @minus{}32768 @dots{} 32767.
  2853. @item IsC
  2854. Integer constant in the range @math{-2^{20}} @dots{} @math{2^{20} - 1}.
  2855. @item Jc
  2856. Integer constant that is a valid mask for the clr instruction.
  2857. @item Js
  2858. Integer constant that is a valid mask for the set instruction.
  2859. @item Q
  2860. Memory location with A base register.
  2861. @item R
  2862. Memory location with B base register.
  2863. @ifset INTERNALS
  2864. @item S0
  2865. On C64x+ targets, a GP-relative small data reference.
  2866. @item S1
  2867. Any kind of @code{SYMBOL_REF}, for use in a call address.
  2868. @item Si
  2869. Any kind of immediate operand, unless it matches the S0 constraint.
  2870. @item T
  2871. Memory location with B base register, but not using a long offset.
  2872. @item W
  2873. A memory operand with an address that can't be used in an unaligned access.
  2874. @end ifset
  2875. @item Z
  2876. Register B14 (aka DP).
  2877. @end table
  2878. @item TILE-Gx---@file{config/tilegx/constraints.md}
  2879. @table @code
  2880. @item R00
  2881. @itemx R01
  2882. @itemx R02
  2883. @itemx R03
  2884. @itemx R04
  2885. @itemx R05
  2886. @itemx R06
  2887. @itemx R07
  2888. @itemx R08
  2889. @itemx R09
  2890. @itemx R10
  2891. Each of these represents a register constraint for an individual
  2892. register, from r0 to r10.
  2893. @item I
  2894. Signed 8-bit integer constant.
  2895. @item J
  2896. Signed 16-bit integer constant.
  2897. @item K
  2898. Unsigned 16-bit integer constant.
  2899. @item L
  2900. Integer constant that fits in one signed byte when incremented by one
  2901. (@minus{}129 @dots{} 126).
  2902. @item m
  2903. Memory operand. If used together with @samp{<} or @samp{>}, the
  2904. operand can have postincrement which requires printing with @samp{%In}
  2905. and @samp{%in} on TILE-Gx. For example:
  2906. @smallexample
  2907. asm ("st_add %I0,%1,%i0" : "=m<>" (*mem) : "r" (val));
  2908. @end smallexample
  2909. @item M
  2910. A bit mask suitable for the BFINS instruction.
  2911. @item N
  2912. Integer constant that is a byte tiled out eight times.
  2913. @item O
  2914. The integer zero constant.
  2915. @item P
  2916. Integer constant that is a sign-extended byte tiled out as four shorts.
  2917. @item Q
  2918. Integer constant that fits in one signed byte when incremented
  2919. (@minus{}129 @dots{} 126), but excluding -1.
  2920. @item S
  2921. Integer constant that has all 1 bits consecutive and starting at bit 0.
  2922. @item T
  2923. A 16-bit fragment of a got, tls, or pc-relative reference.
  2924. @item U
  2925. Memory operand except postincrement. This is roughly the same as
  2926. @samp{m} when not used together with @samp{<} or @samp{>}.
  2927. @item W
  2928. An 8-element vector constant with identical elements.
  2929. @item Y
  2930. A 4-element vector constant with identical elements.
  2931. @item Z0
  2932. The integer constant 0xffffffff.
  2933. @item Z1
  2934. The integer constant 0xffffffff00000000.
  2935. @end table
  2936. @item TILEPro---@file{config/tilepro/constraints.md}
  2937. @table @code
  2938. @item R00
  2939. @itemx R01
  2940. @itemx R02
  2941. @itemx R03
  2942. @itemx R04
  2943. @itemx R05
  2944. @itemx R06
  2945. @itemx R07
  2946. @itemx R08
  2947. @itemx R09
  2948. @itemx R10
  2949. Each of these represents a register constraint for an individual
  2950. register, from r0 to r10.
  2951. @item I
  2952. Signed 8-bit integer constant.
  2953. @item J
  2954. Signed 16-bit integer constant.
  2955. @item K
  2956. Nonzero integer constant with low 16 bits zero.
  2957. @item L
  2958. Integer constant that fits in one signed byte when incremented by one
  2959. (@minus{}129 @dots{} 126).
  2960. @item m
  2961. Memory operand. If used together with @samp{<} or @samp{>}, the
  2962. operand can have postincrement which requires printing with @samp{%In}
  2963. and @samp{%in} on TILEPro. For example:
  2964. @smallexample
  2965. asm ("swadd %I0,%1,%i0" : "=m<>" (mem) : "r" (val));
  2966. @end smallexample
  2967. @item M
  2968. A bit mask suitable for the MM instruction.
  2969. @item N
  2970. Integer constant that is a byte tiled out four times.
  2971. @item O
  2972. The integer zero constant.
  2973. @item P
  2974. Integer constant that is a sign-extended byte tiled out as two shorts.
  2975. @item Q
  2976. Integer constant that fits in one signed byte when incremented
  2977. (@minus{}129 @dots{} 126), but excluding -1.
  2978. @item T
  2979. A symbolic operand, or a 16-bit fragment of a got, tls, or pc-relative
  2980. reference.
  2981. @item U
  2982. Memory operand except postincrement. This is roughly the same as
  2983. @samp{m} when not used together with @samp{<} or @samp{>}.
  2984. @item W
  2985. A 4-element vector constant with identical elements.
  2986. @item Y
  2987. A 2-element vector constant with identical elements.
  2988. @end table
  2989. @item Visium---@file{config/visium/constraints.md}
  2990. @table @code
  2991. @item b
  2992. EAM register @code{mdb}
  2993. @item c
  2994. EAM register @code{mdc}
  2995. @item f
  2996. Floating point register
  2997. @ifset INTERNALS
  2998. @item k
  2999. Register for sibcall optimization
  3000. @end ifset
  3001. @item l
  3002. General register, but not @code{r29}, @code{r30} and @code{r31}
  3003. @item t
  3004. Register @code{r1}
  3005. @item u
  3006. Register @code{r2}
  3007. @item v
  3008. Register @code{r3}
  3009. @item G
  3010. Floating-point constant 0.0
  3011. @item J
  3012. Integer constant in the range 0 .. 65535 (16-bit immediate)
  3013. @item K
  3014. Integer constant in the range 1 .. 31 (5-bit immediate)
  3015. @item L
  3016. Integer constant in the range @minus{}65535 .. @minus{}1 (16-bit negative immediate)
  3017. @item M
  3018. Integer constant @minus{}1
  3019. @item O
  3020. Integer constant 0
  3021. @item P
  3022. Integer constant 32
  3023. @end table
  3024. @item x86 family---@file{config/i386/constraints.md}
  3025. @table @code
  3026. @item R
  3027. Legacy register---the eight integer registers available on all
  3028. i386 processors (@code{a}, @code{b}, @code{c}, @code{d},
  3029. @code{si}, @code{di}, @code{bp}, @code{sp}).
  3030. @item q
  3031. Any register accessible as @code{@var{r}l}. In 32-bit mode, @code{a},
  3032. @code{b}, @code{c}, and @code{d}; in 64-bit mode, any integer register.
  3033. @item Q
  3034. Any register accessible as @code{@var{r}h}: @code{a}, @code{b},
  3035. @code{c}, and @code{d}.
  3036. @ifset INTERNALS
  3037. @item l
  3038. Any register that can be used as the index in a base+index memory
  3039. access: that is, any general register except the stack pointer.
  3040. @end ifset
  3041. @item a
  3042. The @code{a} register.
  3043. @item b
  3044. The @code{b} register.
  3045. @item c
  3046. The @code{c} register.
  3047. @item d
  3048. The @code{d} register.
  3049. @item S
  3050. The @code{si} register.
  3051. @item D
  3052. The @code{di} register.
  3053. @item A
  3054. The @code{a} and @code{d} registers. This class is used for instructions
  3055. that return double word results in the @code{ax:dx} register pair. Single
  3056. word values will be allocated either in @code{ax} or @code{dx}.
  3057. For example on i386 the following implements @code{rdtsc}:
  3058. @smallexample
  3059. unsigned long long rdtsc (void)
  3060. @{
  3061. unsigned long long tick;
  3062. __asm__ __volatile__("rdtsc":"=A"(tick));
  3063. return tick;
  3064. @}
  3065. @end smallexample
  3066. This is not correct on x86-64 as it would allocate tick in either @code{ax}
  3067. or @code{dx}. You have to use the following variant instead:
  3068. @smallexample
  3069. unsigned long long rdtsc (void)
  3070. @{
  3071. unsigned int tickl, tickh;
  3072. __asm__ __volatile__("rdtsc":"=a"(tickl),"=d"(tickh));
  3073. return ((unsigned long long)tickh << 32)|tickl;
  3074. @}
  3075. @end smallexample
  3076. @item f
  3077. Any 80387 floating-point (stack) register.
  3078. @item t
  3079. Top of 80387 floating-point stack (@code{%st(0)}).
  3080. @item u
  3081. Second from top of 80387 floating-point stack (@code{%st(1)}).
  3082. @item y
  3083. Any MMX register.
  3084. @item x
  3085. Any SSE register.
  3086. @item Yz
  3087. First SSE register (@code{%xmm0}).
  3088. @ifset INTERNALS
  3089. @item Y2
  3090. Any SSE register, when SSE2 is enabled.
  3091. @item Yi
  3092. Any SSE register, when SSE2 and inter-unit moves are enabled.
  3093. @item Ym
  3094. Any MMX register, when inter-unit moves are enabled.
  3095. @end ifset
  3096. @item I
  3097. Integer constant in the range 0 @dots{} 31, for 32-bit shifts.
  3098. @item J
  3099. Integer constant in the range 0 @dots{} 63, for 64-bit shifts.
  3100. @item K
  3101. Signed 8-bit integer constant.
  3102. @item L
  3103. @code{0xFF} or @code{0xFFFF}, for andsi as a zero-extending move.
  3104. @item M
  3105. 0, 1, 2, or 3 (shifts for the @code{lea} instruction).
  3106. @item N
  3107. Unsigned 8-bit integer constant (for @code{in} and @code{out}
  3108. instructions).
  3109. @ifset INTERNALS
  3110. @item O
  3111. Integer constant in the range 0 @dots{} 127, for 128-bit shifts.
  3112. @end ifset
  3113. @item G
  3114. Standard 80387 floating point constant.
  3115. @item C
  3116. Standard SSE floating point constant.
  3117. @item e
  3118. 32-bit signed integer constant, or a symbolic reference known
  3119. to fit that range (for immediate operands in sign-extending x86-64
  3120. instructions).
  3121. @item Z
  3122. 32-bit unsigned integer constant, or a symbolic reference known
  3123. to fit that range (for immediate operands in zero-extending x86-64
  3124. instructions).
  3125. @end table
  3126. @item Xstormy16---@file{config/stormy16/stormy16.h}
  3127. @table @code
  3128. @item a
  3129. Register r0.
  3130. @item b
  3131. Register r1.
  3132. @item c
  3133. Register r2.
  3134. @item d
  3135. Register r8.
  3136. @item e
  3137. Registers r0 through r7.
  3138. @item t
  3139. Registers r0 and r1.
  3140. @item y
  3141. The carry register.
  3142. @item z
  3143. Registers r8 and r9.
  3144. @item I
  3145. A constant between 0 and 3 inclusive.
  3146. @item J
  3147. A constant that has exactly one bit set.
  3148. @item K
  3149. A constant that has exactly one bit clear.
  3150. @item L
  3151. A constant between 0 and 255 inclusive.
  3152. @item M
  3153. A constant between @minus{}255 and 0 inclusive.
  3154. @item N
  3155. A constant between @minus{}3 and 0 inclusive.
  3156. @item O
  3157. A constant between 1 and 4 inclusive.
  3158. @item P
  3159. A constant between @minus{}4 and @minus{}1 inclusive.
  3160. @item Q
  3161. A memory reference that is a stack push.
  3162. @item R
  3163. A memory reference that is a stack pop.
  3164. @item S
  3165. A memory reference that refers to a constant address of known value.
  3166. @item T
  3167. The register indicated by Rx (not implemented yet).
  3168. @item U
  3169. A constant that is not between 2 and 15 inclusive.
  3170. @item Z
  3171. The constant 0.
  3172. @end table
  3173. @item Xtensa---@file{config/xtensa/constraints.md}
  3174. @table @code
  3175. @item a
  3176. General-purpose 32-bit register
  3177. @item b
  3178. One-bit boolean register
  3179. @item A
  3180. MAC16 40-bit accumulator register
  3181. @item I
  3182. Signed 12-bit integer constant, for use in MOVI instructions
  3183. @item J
  3184. Signed 8-bit integer constant, for use in ADDI instructions
  3185. @item K
  3186. Integer constant valid for BccI instructions
  3187. @item L
  3188. Unsigned constant valid for BccUI instructions
  3189. @end table
  3190. @end table
  3191. @ifset INTERNALS
  3192. @node Disable Insn Alternatives
  3193. @subsection Disable insn alternatives using the @code{enabled} attribute
  3194. @cindex enabled
  3195. There are three insn attributes that may be used to selectively disable
  3196. instruction alternatives:
  3197. @table @code
  3198. @item enabled
  3199. Says whether an alternative is available on the current subtarget.
  3200. @item preferred_for_size
  3201. Says whether an enabled alternative should be used in code that is
  3202. optimized for size.
  3203. @item preferred_for_speed
  3204. Says whether an enabled alternative should be used in code that is
  3205. optimized for speed.
  3206. @end table
  3207. All these attributes should use @code{(const_int 1)} to allow an alternative
  3208. or @code{(const_int 0)} to disallow it. The attributes must be a static
  3209. property of the subtarget; they cannot for example depend on the
  3210. current operands, on the current optimization level, on the location
  3211. of the insn within the body of a loop, on whether register allocation
  3212. has finished, or on the current compiler pass.
  3213. The @code{enabled} attribute is a correctness property. It tells GCC to act
  3214. as though the disabled alternatives were never defined in the first place.
  3215. This is useful when adding new instructions to an existing pattern in
  3216. cases where the new instructions are only available for certain cpu
  3217. architecture levels (typically mapped to the @code{-march=} command-line
  3218. option).
  3219. In contrast, the @code{preferred_for_size} and @code{preferred_for_speed}
  3220. attributes are strong optimization hints rather than correctness properties.
  3221. @code{preferred_for_size} tells GCC which alternatives to consider when
  3222. adding or modifying an instruction that GCC wants to optimize for size.
  3223. @code{preferred_for_speed} does the same thing for speed. Note that things
  3224. like code motion can lead to cases where code optimized for size uses
  3225. alternatives that are not preferred for size, and similarly for speed.
  3226. Although @code{define_insn}s can in principle specify the @code{enabled}
  3227. attribute directly, it is often clearer to have subsiduary attributes
  3228. for each architectural feature of interest. The @code{define_insn}s
  3229. can then use these subsiduary attributes to say which alternatives
  3230. require which features. The example below does this for @code{cpu_facility}.
  3231. E.g. the following two patterns could easily be merged using the @code{enabled}
  3232. attribute:
  3233. @smallexample
  3234. (define_insn "*movdi_old"
  3235. [(set (match_operand:DI 0 "register_operand" "=d")
  3236. (match_operand:DI 1 "register_operand" " d"))]
  3237. "!TARGET_NEW"
  3238. "lgr %0,%1")
  3239. (define_insn "*movdi_new"
  3240. [(set (match_operand:DI 0 "register_operand" "=d,f,d")
  3241. (match_operand:DI 1 "register_operand" " d,d,f"))]
  3242. "TARGET_NEW"
  3243. "@@
  3244. lgr %0,%1
  3245. ldgr %0,%1
  3246. lgdr %0,%1")
  3247. @end smallexample
  3248. to:
  3249. @smallexample
  3250. (define_insn "*movdi_combined"
  3251. [(set (match_operand:DI 0 "register_operand" "=d,f,d")
  3252. (match_operand:DI 1 "register_operand" " d,d,f"))]
  3253. ""
  3254. "@@
  3255. lgr %0,%1
  3256. ldgr %0,%1
  3257. lgdr %0,%1"
  3258. [(set_attr "cpu_facility" "*,new,new")])
  3259. @end smallexample
  3260. with the @code{enabled} attribute defined like this:
  3261. @smallexample
  3262. (define_attr "cpu_facility" "standard,new" (const_string "standard"))
  3263. (define_attr "enabled" ""
  3264. (cond [(eq_attr "cpu_facility" "standard") (const_int 1)
  3265. (and (eq_attr "cpu_facility" "new")
  3266. (ne (symbol_ref "TARGET_NEW") (const_int 0)))
  3267. (const_int 1)]
  3268. (const_int 0)))
  3269. @end smallexample
  3270. @end ifset
  3271. @ifset INTERNALS
  3272. @node Define Constraints
  3273. @subsection Defining Machine-Specific Constraints
  3274. @cindex defining constraints
  3275. @cindex constraints, defining
  3276. Machine-specific constraints fall into two categories: register and
  3277. non-register constraints. Within the latter category, constraints
  3278. which allow subsets of all possible memory or address operands should
  3279. be specially marked, to give @code{reload} more information.
  3280. Machine-specific constraints can be given names of arbitrary length,
  3281. but they must be entirely composed of letters, digits, underscores
  3282. (@samp{_}), and angle brackets (@samp{< >}). Like C identifiers, they
  3283. must begin with a letter or underscore.
  3284. In order to avoid ambiguity in operand constraint strings, no
  3285. constraint can have a name that begins with any other constraint's
  3286. name. For example, if @code{x} is defined as a constraint name,
  3287. @code{xy} may not be, and vice versa. As a consequence of this rule,
  3288. no constraint may begin with one of the generic constraint letters:
  3289. @samp{E F V X g i m n o p r s}.
  3290. Register constraints correspond directly to register classes.
  3291. @xref{Register Classes}. There is thus not much flexibility in their
  3292. definitions.
  3293. @deffn {MD Expression} define_register_constraint name regclass docstring
  3294. All three arguments are string constants.
  3295. @var{name} is the name of the constraint, as it will appear in
  3296. @code{match_operand} expressions. If @var{name} is a multi-letter
  3297. constraint its length shall be the same for all constraints starting
  3298. with the same letter. @var{regclass} can be either the
  3299. name of the corresponding register class (@pxref{Register Classes}),
  3300. or a C expression which evaluates to the appropriate register class.
  3301. If it is an expression, it must have no side effects, and it cannot
  3302. look at the operand. The usual use of expressions is to map some
  3303. register constraints to @code{NO_REGS} when the register class
  3304. is not available on a given subarchitecture.
  3305. @var{docstring} is a sentence documenting the meaning of the
  3306. constraint. Docstrings are explained further below.
  3307. @end deffn
  3308. Non-register constraints are more like predicates: the constraint
  3309. definition gives a Boolean expression which indicates whether the
  3310. constraint matches.
  3311. @deffn {MD Expression} define_constraint name docstring exp
  3312. The @var{name} and @var{docstring} arguments are the same as for
  3313. @code{define_register_constraint}, but note that the docstring comes
  3314. immediately after the name for these expressions. @var{exp} is an RTL
  3315. expression, obeying the same rules as the RTL expressions in predicate
  3316. definitions. @xref{Defining Predicates}, for details. If it
  3317. evaluates true, the constraint matches; if it evaluates false, it
  3318. doesn't. Constraint expressions should indicate which RTL codes they
  3319. might match, just like predicate expressions.
  3320. @code{match_test} C expressions have access to the
  3321. following variables:
  3322. @table @var
  3323. @item op
  3324. The RTL object defining the operand.
  3325. @item mode
  3326. The machine mode of @var{op}.
  3327. @item ival
  3328. @samp{INTVAL (@var{op})}, if @var{op} is a @code{const_int}.
  3329. @item hval
  3330. @samp{CONST_DOUBLE_HIGH (@var{op})}, if @var{op} is an integer
  3331. @code{const_double}.
  3332. @item lval
  3333. @samp{CONST_DOUBLE_LOW (@var{op})}, if @var{op} is an integer
  3334. @code{const_double}.
  3335. @item rval
  3336. @samp{CONST_DOUBLE_REAL_VALUE (@var{op})}, if @var{op} is a floating-point
  3337. @code{const_double}.
  3338. @end table
  3339. The @var{*val} variables should only be used once another piece of the
  3340. expression has verified that @var{op} is the appropriate kind of RTL
  3341. object.
  3342. @end deffn
  3343. Most non-register constraints should be defined with
  3344. @code{define_constraint}. The remaining two definition expressions
  3345. are only appropriate for constraints that should be handled specially
  3346. by @code{reload} if they fail to match.
  3347. @deffn {MD Expression} define_memory_constraint name docstring exp
  3348. Use this expression for constraints that match a subset of all memory
  3349. operands: that is, @code{reload} can make them match by converting the
  3350. operand to the form @samp{@w{(mem (reg @var{X}))}}, where @var{X} is a
  3351. base register (from the register class specified by
  3352. @code{BASE_REG_CLASS}, @pxref{Register Classes}).
  3353. For example, on the S/390, some instructions do not accept arbitrary
  3354. memory references, but only those that do not make use of an index
  3355. register. The constraint letter @samp{Q} is defined to represent a
  3356. memory address of this type. If @samp{Q} is defined with
  3357. @code{define_memory_constraint}, a @samp{Q} constraint can handle any
  3358. memory operand, because @code{reload} knows it can simply copy the
  3359. memory address into a base register if required. This is analogous to
  3360. the way an @samp{o} constraint can handle any memory operand.
  3361. The syntax and semantics are otherwise identical to
  3362. @code{define_constraint}.
  3363. @end deffn
  3364. @deffn {MD Expression} define_address_constraint name docstring exp
  3365. Use this expression for constraints that match a subset of all address
  3366. operands: that is, @code{reload} can make the constraint match by
  3367. converting the operand to the form @samp{@w{(reg @var{X})}}, again
  3368. with @var{X} a base register.
  3369. Constraints defined with @code{define_address_constraint} can only be
  3370. used with the @code{address_operand} predicate, or machine-specific
  3371. predicates that work the same way. They are treated analogously to
  3372. the generic @samp{p} constraint.
  3373. The syntax and semantics are otherwise identical to
  3374. @code{define_constraint}.
  3375. @end deffn
  3376. For historical reasons, names beginning with the letters @samp{G H}
  3377. are reserved for constraints that match only @code{const_double}s, and
  3378. names beginning with the letters @samp{I J K L M N O P} are reserved
  3379. for constraints that match only @code{const_int}s. This may change in
  3380. the future. For the time being, constraints with these names must be
  3381. written in a stylized form, so that @code{genpreds} can tell you did
  3382. it correctly:
  3383. @smallexample
  3384. @group
  3385. (define_constraint "[@var{GHIJKLMNOP}]@dots{}"
  3386. "@var{doc}@dots{}"
  3387. (and (match_code "const_int") ; @r{@code{const_double} for G/H}
  3388. @var{condition}@dots{})) ; @r{usually a @code{match_test}}
  3389. @end group
  3390. @end smallexample
  3391. @c the semicolons line up in the formatted manual
  3392. It is fine to use names beginning with other letters for constraints
  3393. that match @code{const_double}s or @code{const_int}s.
  3394. Each docstring in a constraint definition should be one or more complete
  3395. sentences, marked up in Texinfo format. @emph{They are currently unused.}
  3396. In the future they will be copied into the GCC manual, in @ref{Machine
  3397. Constraints}, replacing the hand-maintained tables currently found in
  3398. that section. Also, in the future the compiler may use this to give
  3399. more helpful diagnostics when poor choice of @code{asm} constraints
  3400. causes a reload failure.
  3401. If you put the pseudo-Texinfo directive @samp{@@internal} at the
  3402. beginning of a docstring, then (in the future) it will appear only in
  3403. the internals manual's version of the machine-specific constraint tables.
  3404. Use this for constraints that should not appear in @code{asm} statements.
  3405. @node C Constraint Interface
  3406. @subsection Testing constraints from C
  3407. @cindex testing constraints
  3408. @cindex constraints, testing
  3409. It is occasionally useful to test a constraint from C code rather than
  3410. implicitly via the constraint string in a @code{match_operand}. The
  3411. generated file @file{tm_p.h} declares a few interfaces for working
  3412. with constraints. At present these are defined for all constraints
  3413. except @code{g} (which is equivalent to @code{general_operand}).
  3414. Some valid constraint names are not valid C identifiers, so there is a
  3415. mangling scheme for referring to them from C@. Constraint names that
  3416. do not contain angle brackets or underscores are left unchanged.
  3417. Underscores are doubled, each @samp{<} is replaced with @samp{_l}, and
  3418. each @samp{>} with @samp{_g}. Here are some examples:
  3419. @c the @c's prevent double blank lines in the printed manual.
  3420. @example
  3421. @multitable {Original} {Mangled}
  3422. @item @strong{Original} @tab @strong{Mangled} @c
  3423. @item @code{x} @tab @code{x} @c
  3424. @item @code{P42x} @tab @code{P42x} @c
  3425. @item @code{P4_x} @tab @code{P4__x} @c
  3426. @item @code{P4>x} @tab @code{P4_gx} @c
  3427. @item @code{P4>>} @tab @code{P4_g_g} @c
  3428. @item @code{P4_g>} @tab @code{P4__g_g} @c
  3429. @end multitable
  3430. @end example
  3431. Throughout this section, the variable @var{c} is either a constraint
  3432. in the abstract sense, or a constant from @code{enum constraint_num};
  3433. the variable @var{m} is a mangled constraint name (usually as part of
  3434. a larger identifier).
  3435. @deftp Enum constraint_num
  3436. For each constraint except @code{g}, there is a corresponding
  3437. enumeration constant: @samp{CONSTRAINT_} plus the mangled name of the
  3438. constraint. Functions that take an @code{enum constraint_num} as an
  3439. argument expect one of these constants.
  3440. @end deftp
  3441. @deftypefun {inline bool} satisfies_constraint_@var{m} (rtx @var{exp})
  3442. For each non-register constraint @var{m} except @code{g}, there is
  3443. one of these functions; it returns @code{true} if @var{exp} satisfies the
  3444. constraint. These functions are only visible if @file{rtl.h} was included
  3445. before @file{tm_p.h}.
  3446. @end deftypefun
  3447. @deftypefun bool constraint_satisfied_p (rtx @var{exp}, enum constraint_num @var{c})
  3448. Like the @code{satisfies_constraint_@var{m}} functions, but the
  3449. constraint to test is given as an argument, @var{c}. If @var{c}
  3450. specifies a register constraint, this function will always return
  3451. @code{false}.
  3452. @end deftypefun
  3453. @deftypefun {enum reg_class} reg_class_for_constraint (enum constraint_num @var{c})
  3454. Returns the register class associated with @var{c}. If @var{c} is not
  3455. a register constraint, or those registers are not available for the
  3456. currently selected subtarget, returns @code{NO_REGS}.
  3457. @end deftypefun
  3458. Here is an example use of @code{satisfies_constraint_@var{m}}. In
  3459. peephole optimizations (@pxref{Peephole Definitions}), operand
  3460. constraint strings are ignored, so if there are relevant constraints,
  3461. they must be tested in the C condition. In the example, the
  3462. optimization is applied if operand 2 does @emph{not} satisfy the
  3463. @samp{K} constraint. (This is a simplified version of a peephole
  3464. definition from the i386 machine description.)
  3465. @smallexample
  3466. (define_peephole2
  3467. [(match_scratch:SI 3 "r")
  3468. (set (match_operand:SI 0 "register_operand" "")
  3469. (mult:SI (match_operand:SI 1 "memory_operand" "")
  3470. (match_operand:SI 2 "immediate_operand" "")))]
  3471. "!satisfies_constraint_K (operands[2])"
  3472. [(set (match_dup 3) (match_dup 1))
  3473. (set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))]
  3474. "")
  3475. @end smallexample
  3476. @node Standard Names
  3477. @section Standard Pattern Names For Generation
  3478. @cindex standard pattern names
  3479. @cindex pattern names
  3480. @cindex names, pattern
  3481. Here is a table of the instruction names that are meaningful in the RTL
  3482. generation pass of the compiler. Giving one of these names to an
  3483. instruction pattern tells the RTL generation pass that it can use the
  3484. pattern to accomplish a certain task.
  3485. @table @asis
  3486. @cindex @code{mov@var{m}} instruction pattern
  3487. @item @samp{mov@var{m}}
  3488. Here @var{m} stands for a two-letter machine mode name, in lowercase.
  3489. This instruction pattern moves data with that machine mode from operand
  3490. 1 to operand 0. For example, @samp{movsi} moves full-word data.
  3491. If operand 0 is a @code{subreg} with mode @var{m} of a register whose
  3492. own mode is wider than @var{m}, the effect of this instruction is
  3493. to store the specified value in the part of the register that corresponds
  3494. to mode @var{m}. Bits outside of @var{m}, but which are within the
  3495. same target word as the @code{subreg} are undefined. Bits which are
  3496. outside the target word are left unchanged.
  3497. This class of patterns is special in several ways. First of all, each
  3498. of these names up to and including full word size @emph{must} be defined,
  3499. because there is no other way to copy a datum from one place to another.
  3500. If there are patterns accepting operands in larger modes,
  3501. @samp{mov@var{m}} must be defined for integer modes of those sizes.
  3502. Second, these patterns are not used solely in the RTL generation pass.
  3503. Even the reload pass can generate move insns to copy values from stack
  3504. slots into temporary registers. When it does so, one of the operands is
  3505. a hard register and the other is an operand that can need to be reloaded
  3506. into a register.
  3507. @findex force_reg
  3508. Therefore, when given such a pair of operands, the pattern must generate
  3509. RTL which needs no reloading and needs no temporary registers---no
  3510. registers other than the operands. For example, if you support the
  3511. pattern with a @code{define_expand}, then in such a case the
  3512. @code{define_expand} mustn't call @code{force_reg} or any other such
  3513. function which might generate new pseudo registers.
  3514. This requirement exists even for subword modes on a RISC machine where
  3515. fetching those modes from memory normally requires several insns and
  3516. some temporary registers.
  3517. @findex change_address
  3518. During reload a memory reference with an invalid address may be passed
  3519. as an operand. Such an address will be replaced with a valid address
  3520. later in the reload pass. In this case, nothing may be done with the
  3521. address except to use it as it stands. If it is copied, it will not be
  3522. replaced with a valid address. No attempt should be made to make such
  3523. an address into a valid address and no routine (such as
  3524. @code{change_address}) that will do so may be called. Note that
  3525. @code{general_operand} will fail when applied to such an address.
  3526. @findex reload_in_progress
  3527. The global variable @code{reload_in_progress} (which must be explicitly
  3528. declared if required) can be used to determine whether such special
  3529. handling is required.
  3530. The variety of operands that have reloads depends on the rest of the
  3531. machine description, but typically on a RISC machine these can only be
  3532. pseudo registers that did not get hard registers, while on other
  3533. machines explicit memory references will get optional reloads.
  3534. If a scratch register is required to move an object to or from memory,
  3535. it can be allocated using @code{gen_reg_rtx} prior to life analysis.
  3536. If there are cases which need scratch registers during or after reload,
  3537. you must provide an appropriate secondary_reload target hook.
  3538. @findex can_create_pseudo_p
  3539. The macro @code{can_create_pseudo_p} can be used to determine if it
  3540. is unsafe to create new pseudo registers. If this variable is nonzero, then
  3541. it is unsafe to call @code{gen_reg_rtx} to allocate a new pseudo.
  3542. The constraints on a @samp{mov@var{m}} must permit moving any hard
  3543. register to any other hard register provided that
  3544. @code{HARD_REGNO_MODE_OK} permits mode @var{m} in both registers and
  3545. @code{TARGET_REGISTER_MOVE_COST} applied to their classes returns a value
  3546. of 2.
  3547. It is obligatory to support floating point @samp{mov@var{m}}
  3548. instructions into and out of any registers that can hold fixed point
  3549. values, because unions and structures (which have modes @code{SImode} or
  3550. @code{DImode}) can be in those registers and they may have floating
  3551. point members.
  3552. There may also be a need to support fixed point @samp{mov@var{m}}
  3553. instructions in and out of floating point registers. Unfortunately, I
  3554. have forgotten why this was so, and I don't know whether it is still
  3555. true. If @code{HARD_REGNO_MODE_OK} rejects fixed point values in
  3556. floating point registers, then the constraints of the fixed point
  3557. @samp{mov@var{m}} instructions must be designed to avoid ever trying to
  3558. reload into a floating point register.
  3559. @cindex @code{reload_in} instruction pattern
  3560. @cindex @code{reload_out} instruction pattern
  3561. @item @samp{reload_in@var{m}}
  3562. @itemx @samp{reload_out@var{m}}
  3563. These named patterns have been obsoleted by the target hook
  3564. @code{secondary_reload}.
  3565. Like @samp{mov@var{m}}, but used when a scratch register is required to
  3566. move between operand 0 and operand 1. Operand 2 describes the scratch
  3567. register. See the discussion of the @code{SECONDARY_RELOAD_CLASS}
  3568. macro in @pxref{Register Classes}.
  3569. There are special restrictions on the form of the @code{match_operand}s
  3570. used in these patterns. First, only the predicate for the reload
  3571. operand is examined, i.e., @code{reload_in} examines operand 1, but not
  3572. the predicates for operand 0 or 2. Second, there may be only one
  3573. alternative in the constraints. Third, only a single register class
  3574. letter may be used for the constraint; subsequent constraint letters
  3575. are ignored. As a special exception, an empty constraint string
  3576. matches the @code{ALL_REGS} register class. This may relieve ports
  3577. of the burden of defining an @code{ALL_REGS} constraint letter just
  3578. for these patterns.
  3579. @cindex @code{movstrict@var{m}} instruction pattern
  3580. @item @samp{movstrict@var{m}}
  3581. Like @samp{mov@var{m}} except that if operand 0 is a @code{subreg}
  3582. with mode @var{m} of a register whose natural mode is wider,
  3583. the @samp{movstrict@var{m}} instruction is guaranteed not to alter
  3584. any of the register except the part which belongs to mode @var{m}.
  3585. @cindex @code{movmisalign@var{m}} instruction pattern
  3586. @item @samp{movmisalign@var{m}}
  3587. This variant of a move pattern is designed to load or store a value
  3588. from a memory address that is not naturally aligned for its mode.
  3589. For a store, the memory will be in operand 0; for a load, the memory
  3590. will be in operand 1. The other operand is guaranteed not to be a
  3591. memory, so that it's easy to tell whether this is a load or store.
  3592. This pattern is used by the autovectorizer, and when expanding a
  3593. @code{MISALIGNED_INDIRECT_REF} expression.
  3594. @cindex @code{load_multiple} instruction pattern
  3595. @item @samp{load_multiple}
  3596. Load several consecutive memory locations into consecutive registers.
  3597. Operand 0 is the first of the consecutive registers, operand 1
  3598. is the first memory location, and operand 2 is a constant: the
  3599. number of consecutive registers.
  3600. Define this only if the target machine really has such an instruction;
  3601. do not define this if the most efficient way of loading consecutive
  3602. registers from memory is to do them one at a time.
  3603. On some machines, there are restrictions as to which consecutive
  3604. registers can be stored into memory, such as particular starting or
  3605. ending register numbers or only a range of valid counts. For those
  3606. machines, use a @code{define_expand} (@pxref{Expander Definitions})
  3607. and make the pattern fail if the restrictions are not met.
  3608. Write the generated insn as a @code{parallel} with elements being a
  3609. @code{set} of one register from the appropriate memory location (you may
  3610. also need @code{use} or @code{clobber} elements). Use a
  3611. @code{match_parallel} (@pxref{RTL Template}) to recognize the insn. See
  3612. @file{rs6000.md} for examples of the use of this insn pattern.
  3613. @cindex @samp{store_multiple} instruction pattern
  3614. @item @samp{store_multiple}
  3615. Similar to @samp{load_multiple}, but store several consecutive registers
  3616. into consecutive memory locations. Operand 0 is the first of the
  3617. consecutive memory locations, operand 1 is the first register, and
  3618. operand 2 is a constant: the number of consecutive registers.
  3619. @cindex @code{vec_load_lanes@var{m}@var{n}} instruction pattern
  3620. @item @samp{vec_load_lanes@var{m}@var{n}}
  3621. Perform an interleaved load of several vectors from memory operand 1
  3622. into register operand 0. Both operands have mode @var{m}. The register
  3623. operand is viewed as holding consecutive vectors of mode @var{n},
  3624. while the memory operand is a flat array that contains the same number
  3625. of elements. The operation is equivalent to:
  3626. @smallexample
  3627. int c = GET_MODE_SIZE (@var{m}) / GET_MODE_SIZE (@var{n});
  3628. for (j = 0; j < GET_MODE_NUNITS (@var{n}); j++)
  3629. for (i = 0; i < c; i++)
  3630. operand0[i][j] = operand1[j * c + i];
  3631. @end smallexample
  3632. For example, @samp{vec_load_lanestiv4hi} loads 8 16-bit values
  3633. from memory into a register of mode @samp{TI}@. The register
  3634. contains two consecutive vectors of mode @samp{V4HI}@.
  3635. This pattern can only be used if:
  3636. @smallexample
  3637. TARGET_ARRAY_MODE_SUPPORTED_P (@var{n}, @var{c})
  3638. @end smallexample
  3639. is true. GCC assumes that, if a target supports this kind of
  3640. instruction for some mode @var{n}, it also supports unaligned
  3641. loads for vectors of mode @var{n}.
  3642. @cindex @code{vec_store_lanes@var{m}@var{n}} instruction pattern
  3643. @item @samp{vec_store_lanes@var{m}@var{n}}
  3644. Equivalent to @samp{vec_load_lanes@var{m}@var{n}}, with the memory
  3645. and register operands reversed. That is, the instruction is
  3646. equivalent to:
  3647. @smallexample
  3648. int c = GET_MODE_SIZE (@var{m}) / GET_MODE_SIZE (@var{n});
  3649. for (j = 0; j < GET_MODE_NUNITS (@var{n}); j++)
  3650. for (i = 0; i < c; i++)
  3651. operand0[j * c + i] = operand1[i][j];
  3652. @end smallexample
  3653. for a memory operand 0 and register operand 1.
  3654. @cindex @code{vec_set@var{m}} instruction pattern
  3655. @item @samp{vec_set@var{m}}
  3656. Set given field in the vector value. Operand 0 is the vector to modify,
  3657. operand 1 is new value of field and operand 2 specify the field index.
  3658. @cindex @code{vec_extract@var{m}} instruction pattern
  3659. @item @samp{vec_extract@var{m}}
  3660. Extract given field from the vector value. Operand 1 is the vector, operand 2
  3661. specify field index and operand 0 place to store value into.
  3662. @cindex @code{vec_init@var{m}} instruction pattern
  3663. @item @samp{vec_init@var{m}}
  3664. Initialize the vector to given values. Operand 0 is the vector to initialize
  3665. and operand 1 is parallel containing values for individual fields.
  3666. @cindex @code{vcond@var{m}@var{n}} instruction pattern
  3667. @item @samp{vcond@var{m}@var{n}}
  3668. Output a conditional vector move. Operand 0 is the destination to
  3669. receive a combination of operand 1 and operand 2, which are of mode @var{m},
  3670. dependent on the outcome of the predicate in operand 3 which is a
  3671. vector comparison with operands of mode @var{n} in operands 4 and 5. The
  3672. modes @var{m} and @var{n} should have the same size. Operand 0
  3673. will be set to the value @var{op1} & @var{msk} | @var{op2} & ~@var{msk}
  3674. where @var{msk} is computed by element-wise evaluation of the vector
  3675. comparison with a truth value of all-ones and a false value of all-zeros.
  3676. @cindex @code{vec_perm@var{m}} instruction pattern
  3677. @item @samp{vec_perm@var{m}}
  3678. Output a (variable) vector permutation. Operand 0 is the destination
  3679. to receive elements from operand 1 and operand 2, which are of mode
  3680. @var{m}. Operand 3 is the @dfn{selector}. It is an integral mode
  3681. vector of the same width and number of elements as mode @var{m}.
  3682. The input elements are numbered from 0 in operand 1 through
  3683. @math{2*@var{N}-1} in operand 2. The elements of the selector must
  3684. be computed modulo @math{2*@var{N}}. Note that if
  3685. @code{rtx_equal_p(operand1, operand2)}, this can be implemented
  3686. with just operand 1 and selector elements modulo @var{N}.
  3687. In order to make things easy for a number of targets, if there is no
  3688. @samp{vec_perm} pattern for mode @var{m}, but there is for mode @var{q}
  3689. where @var{q} is a vector of @code{QImode} of the same width as @var{m},
  3690. the middle-end will lower the mode @var{m} @code{VEC_PERM_EXPR} to
  3691. mode @var{q}.
  3692. @cindex @code{vec_perm_const@var{m}} instruction pattern
  3693. @item @samp{vec_perm_const@var{m}}
  3694. Like @samp{vec_perm} except that the permutation is a compile-time
  3695. constant. That is, operand 3, the @dfn{selector}, is a @code{CONST_VECTOR}.
  3696. Some targets cannot perform a permutation with a variable selector,
  3697. but can efficiently perform a constant permutation. Further, the
  3698. target hook @code{vec_perm_ok} is queried to determine if the
  3699. specific constant permutation is available efficiently; the named
  3700. pattern is never expanded without @code{vec_perm_ok} returning true.
  3701. There is no need for a target to supply both @samp{vec_perm@var{m}}
  3702. and @samp{vec_perm_const@var{m}} if the former can trivially implement
  3703. the operation with, say, the vector constant loaded into a register.
  3704. @cindex @code{push@var{m}1} instruction pattern
  3705. @item @samp{push@var{m}1}
  3706. Output a push instruction. Operand 0 is value to push. Used only when
  3707. @code{PUSH_ROUNDING} is defined. For historical reason, this pattern may be
  3708. missing and in such case an @code{mov} expander is used instead, with a
  3709. @code{MEM} expression forming the push operation. The @code{mov} expander
  3710. method is deprecated.
  3711. @cindex @code{add@var{m}3} instruction pattern
  3712. @item @samp{add@var{m}3}
  3713. Add operand 2 and operand 1, storing the result in operand 0. All operands
  3714. must have mode @var{m}. This can be used even on two-address machines, by
  3715. means of constraints requiring operands 1 and 0 to be the same location.
  3716. @cindex @code{addptr@var{m}3} instruction pattern
  3717. @item @samp{addptr@var{m}3}
  3718. Like @code{add@var{m}3} but is guaranteed to only be used for address
  3719. calculations. The expanded code is not allowed to clobber the
  3720. condition code. It only needs to be defined if @code{add@var{m}3}
  3721. sets the condition code. If adds used for address calculations and
  3722. normal adds are not compatible it is required to expand a distinct
  3723. pattern (e.g. using an unspec). The pattern is used by LRA to emit
  3724. address calculations. @code{add@var{m}3} is used if
  3725. @code{addptr@var{m}3} is not defined.
  3726. @cindex @code{ssadd@var{m}3} instruction pattern
  3727. @cindex @code{usadd@var{m}3} instruction pattern
  3728. @cindex @code{sub@var{m}3} instruction pattern
  3729. @cindex @code{sssub@var{m}3} instruction pattern
  3730. @cindex @code{ussub@var{m}3} instruction pattern
  3731. @cindex @code{mul@var{m}3} instruction pattern
  3732. @cindex @code{ssmul@var{m}3} instruction pattern
  3733. @cindex @code{usmul@var{m}3} instruction pattern
  3734. @cindex @code{div@var{m}3} instruction pattern
  3735. @cindex @code{ssdiv@var{m}3} instruction pattern
  3736. @cindex @code{udiv@var{m}3} instruction pattern
  3737. @cindex @code{usdiv@var{m}3} instruction pattern
  3738. @cindex @code{mod@var{m}3} instruction pattern
  3739. @cindex @code{umod@var{m}3} instruction pattern
  3740. @cindex @code{umin@var{m}3} instruction pattern
  3741. @cindex @code{umax@var{m}3} instruction pattern
  3742. @cindex @code{and@var{m}3} instruction pattern
  3743. @cindex @code{ior@var{m}3} instruction pattern
  3744. @cindex @code{xor@var{m}3} instruction pattern
  3745. @item @samp{ssadd@var{m}3}, @samp{usadd@var{m}3}
  3746. @itemx @samp{sub@var{m}3}, @samp{sssub@var{m}3}, @samp{ussub@var{m}3}
  3747. @itemx @samp{mul@var{m}3}, @samp{ssmul@var{m}3}, @samp{usmul@var{m}3}
  3748. @itemx @samp{div@var{m}3}, @samp{ssdiv@var{m}3}
  3749. @itemx @samp{udiv@var{m}3}, @samp{usdiv@var{m}3}
  3750. @itemx @samp{mod@var{m}3}, @samp{umod@var{m}3}
  3751. @itemx @samp{umin@var{m}3}, @samp{umax@var{m}3}
  3752. @itemx @samp{and@var{m}3}, @samp{ior@var{m}3}, @samp{xor@var{m}3}
  3753. Similar, for other arithmetic operations.
  3754. @cindex @code{fma@var{m}4} instruction pattern
  3755. @item @samp{fma@var{m}4}
  3756. Multiply operand 2 and operand 1, then add operand 3, storing the
  3757. result in operand 0 without doing an intermediate rounding step. All
  3758. operands must have mode @var{m}. This pattern is used to implement
  3759. the @code{fma}, @code{fmaf}, and @code{fmal} builtin functions from
  3760. the ISO C99 standard.
  3761. @cindex @code{fms@var{m}4} instruction pattern
  3762. @item @samp{fms@var{m}4}
  3763. Like @code{fma@var{m}4}, except operand 3 subtracted from the
  3764. product instead of added to the product. This is represented
  3765. in the rtl as
  3766. @smallexample
  3767. (fma:@var{m} @var{op1} @var{op2} (neg:@var{m} @var{op3}))
  3768. @end smallexample
  3769. @cindex @code{fnma@var{m}4} instruction pattern
  3770. @item @samp{fnma@var{m}4}
  3771. Like @code{fma@var{m}4} except that the intermediate product
  3772. is negated before being added to operand 3. This is represented
  3773. in the rtl as
  3774. @smallexample
  3775. (fma:@var{m} (neg:@var{m} @var{op1}) @var{op2} @var{op3})
  3776. @end smallexample
  3777. @cindex @code{fnms@var{m}4} instruction pattern
  3778. @item @samp{fnms@var{m}4}
  3779. Like @code{fms@var{m}4} except that the intermediate product
  3780. is negated before subtracting operand 3. This is represented
  3781. in the rtl as
  3782. @smallexample
  3783. (fma:@var{m} (neg:@var{m} @var{op1}) @var{op2} (neg:@var{m} @var{op3}))
  3784. @end smallexample
  3785. @cindex @code{min@var{m}3} instruction pattern
  3786. @cindex @code{max@var{m}3} instruction pattern
  3787. @item @samp{smin@var{m}3}, @samp{smax@var{m}3}
  3788. Signed minimum and maximum operations. When used with floating point,
  3789. if both operands are zeros, or if either operand is @code{NaN}, then
  3790. it is unspecified which of the two operands is returned as the result.
  3791. @cindex @code{reduc_smin_@var{m}} instruction pattern
  3792. @cindex @code{reduc_smax_@var{m}} instruction pattern
  3793. @item @samp{reduc_smin_@var{m}}, @samp{reduc_smax_@var{m}}
  3794. Find the signed minimum/maximum of the elements of a vector. The vector is
  3795. operand 1, and the result is stored in the least significant bits of
  3796. operand 0 (also a vector). The output and input vector should have the same
  3797. modes. These are legacy optabs, and platforms should prefer to implement
  3798. @samp{reduc_smin_scal_@var{m}} and @samp{reduc_smax_scal_@var{m}}.
  3799. @cindex @code{reduc_umin_@var{m}} instruction pattern
  3800. @cindex @code{reduc_umax_@var{m}} instruction pattern
  3801. @item @samp{reduc_umin_@var{m}}, @samp{reduc_umax_@var{m}}
  3802. Find the unsigned minimum/maximum of the elements of a vector. The vector is
  3803. operand 1, and the result is stored in the least significant bits of
  3804. operand 0 (also a vector). The output and input vector should have the same
  3805. modes. These are legacy optabs, and platforms should prefer to implement
  3806. @samp{reduc_umin_scal_@var{m}} and @samp{reduc_umax_scal_@var{m}}.
  3807. @cindex @code{reduc_splus_@var{m}} instruction pattern
  3808. @cindex @code{reduc_uplus_@var{m}} instruction pattern
  3809. @item @samp{reduc_splus_@var{m}}, @samp{reduc_uplus_@var{m}}
  3810. Compute the sum of the signed/unsigned elements of a vector. The vector is
  3811. operand 1, and the result is stored in the least significant bits of operand 0
  3812. (also a vector). The output and input vector should have the same modes.
  3813. These are legacy optabs, and platforms should prefer to implement
  3814. @samp{reduc_plus_scal_@var{m}}.
  3815. @cindex @code{reduc_smin_scal_@var{m}} instruction pattern
  3816. @cindex @code{reduc_smax_scal_@var{m}} instruction pattern
  3817. @item @samp{reduc_smin_scal_@var{m}}, @samp{reduc_smax_scal_@var{m}}
  3818. Find the signed minimum/maximum of the elements of a vector. The vector is
  3819. operand 1, and operand 0 is the scalar result, with mode equal to the mode of
  3820. the elements of the input vector.
  3821. @cindex @code{reduc_umin_scal_@var{m}} instruction pattern
  3822. @cindex @code{reduc_umax_scal_@var{m}} instruction pattern
  3823. @item @samp{reduc_umin_scal_@var{m}}, @samp{reduc_umax_scal_@var{m}}
  3824. Find the unsigned minimum/maximum of the elements of a vector. The vector is
  3825. operand 1, and operand 0 is the scalar result, with mode equal to the mode of
  3826. the elements of the input vector.
  3827. @cindex @code{reduc_plus_scal_@var{m}} instruction pattern
  3828. @item @samp{reduc_plus_scal_@var{m}}
  3829. Compute the sum of the elements of a vector. The vector is operand 1, and
  3830. operand 0 is the scalar result, with mode equal to the mode of the elements of
  3831. the input vector.
  3832. @cindex @code{sdot_prod@var{m}} instruction pattern
  3833. @item @samp{sdot_prod@var{m}}
  3834. @cindex @code{udot_prod@var{m}} instruction pattern
  3835. @itemx @samp{udot_prod@var{m}}
  3836. Compute the sum of the products of two signed/unsigned elements.
  3837. Operand 1 and operand 2 are of the same mode. Their product, which is of a
  3838. wider mode, is computed and added to operand 3. Operand 3 is of a mode equal or
  3839. wider than the mode of the product. The result is placed in operand 0, which
  3840. is of the same mode as operand 3.
  3841. @cindex @code{ssad@var{m}} instruction pattern
  3842. @item @samp{ssad@var{m}}
  3843. @cindex @code{usad@var{m}} instruction pattern
  3844. @item @samp{usad@var{m}}
  3845. Compute the sum of absolute differences of two signed/unsigned elements.
  3846. Operand 1 and operand 2 are of the same mode. Their absolute difference, which
  3847. is of a wider mode, is computed and added to operand 3. Operand 3 is of a mode
  3848. equal or wider than the mode of the absolute difference. The result is placed
  3849. in operand 0, which is of the same mode as operand 3.
  3850. @cindex @code{ssum_widen@var{m3}} instruction pattern
  3851. @item @samp{ssum_widen@var{m3}}
  3852. @cindex @code{usum_widen@var{m3}} instruction pattern
  3853. @itemx @samp{usum_widen@var{m3}}
  3854. Operands 0 and 2 are of the same mode, which is wider than the mode of
  3855. operand 1. Add operand 1 to operand 2 and place the widened result in
  3856. operand 0. (This is used express accumulation of elements into an accumulator
  3857. of a wider mode.)
  3858. @cindex @code{vec_shr_@var{m}} instruction pattern
  3859. @item @samp{vec_shr_@var{m}}
  3860. Whole vector right shift in bits, i.e. towards element 0.
  3861. Operand 1 is a vector to be shifted.
  3862. Operand 2 is an integer shift amount in bits.
  3863. Operand 0 is where the resulting shifted vector is stored.
  3864. The output and input vectors should have the same modes.
  3865. @cindex @code{vec_pack_trunc_@var{m}} instruction pattern
  3866. @item @samp{vec_pack_trunc_@var{m}}
  3867. Narrow (demote) and merge the elements of two vectors. Operands 1 and 2
  3868. are vectors of the same mode having N integral or floating point elements
  3869. of size S@. Operand 0 is the resulting vector in which 2*N elements of
  3870. size N/2 are concatenated after narrowing them down using truncation.
  3871. @cindex @code{vec_pack_ssat_@var{m}} instruction pattern
  3872. @cindex @code{vec_pack_usat_@var{m}} instruction pattern
  3873. @item @samp{vec_pack_ssat_@var{m}}, @samp{vec_pack_usat_@var{m}}
  3874. Narrow (demote) and merge the elements of two vectors. Operands 1 and 2
  3875. are vectors of the same mode having N integral elements of size S.
  3876. Operand 0 is the resulting vector in which the elements of the two input
  3877. vectors are concatenated after narrowing them down using signed/unsigned
  3878. saturating arithmetic.
  3879. @cindex @code{vec_pack_sfix_trunc_@var{m}} instruction pattern
  3880. @cindex @code{vec_pack_ufix_trunc_@var{m}} instruction pattern
  3881. @item @samp{vec_pack_sfix_trunc_@var{m}}, @samp{vec_pack_ufix_trunc_@var{m}}
  3882. Narrow, convert to signed/unsigned integral type and merge the elements
  3883. of two vectors. Operands 1 and 2 are vectors of the same mode having N
  3884. floating point elements of size S@. Operand 0 is the resulting vector
  3885. in which 2*N elements of size N/2 are concatenated.
  3886. @cindex @code{vec_unpacks_hi_@var{m}} instruction pattern
  3887. @cindex @code{vec_unpacks_lo_@var{m}} instruction pattern
  3888. @item @samp{vec_unpacks_hi_@var{m}}, @samp{vec_unpacks_lo_@var{m}}
  3889. Extract and widen (promote) the high/low part of a vector of signed
  3890. integral or floating point elements. The input vector (operand 1) has N
  3891. elements of size S@. Widen (promote) the high/low elements of the vector
  3892. using signed or floating point extension and place the resulting N/2
  3893. values of size 2*S in the output vector (operand 0).
  3894. @cindex @code{vec_unpacku_hi_@var{m}} instruction pattern
  3895. @cindex @code{vec_unpacku_lo_@var{m}} instruction pattern
  3896. @item @samp{vec_unpacku_hi_@var{m}}, @samp{vec_unpacku_lo_@var{m}}
  3897. Extract and widen (promote) the high/low part of a vector of unsigned
  3898. integral elements. The input vector (operand 1) has N elements of size S.
  3899. Widen (promote) the high/low elements of the vector using zero extension and
  3900. place the resulting N/2 values of size 2*S in the output vector (operand 0).
  3901. @cindex @code{vec_unpacks_float_hi_@var{m}} instruction pattern
  3902. @cindex @code{vec_unpacks_float_lo_@var{m}} instruction pattern
  3903. @cindex @code{vec_unpacku_float_hi_@var{m}} instruction pattern
  3904. @cindex @code{vec_unpacku_float_lo_@var{m}} instruction pattern
  3905. @item @samp{vec_unpacks_float_hi_@var{m}}, @samp{vec_unpacks_float_lo_@var{m}}
  3906. @itemx @samp{vec_unpacku_float_hi_@var{m}}, @samp{vec_unpacku_float_lo_@var{m}}
  3907. Extract, convert to floating point type and widen the high/low part of a
  3908. vector of signed/unsigned integral elements. The input vector (operand 1)
  3909. has N elements of size S@. Convert the high/low elements of the vector using
  3910. floating point conversion and place the resulting N/2 values of size 2*S in
  3911. the output vector (operand 0).
  3912. @cindex @code{vec_widen_umult_hi_@var{m}} instruction pattern
  3913. @cindex @code{vec_widen_umult_lo_@var{m}} instruction pattern
  3914. @cindex @code{vec_widen_smult_hi_@var{m}} instruction pattern
  3915. @cindex @code{vec_widen_smult_lo_@var{m}} instruction pattern
  3916. @cindex @code{vec_widen_umult_even_@var{m}} instruction pattern
  3917. @cindex @code{vec_widen_umult_odd_@var{m}} instruction pattern
  3918. @cindex @code{vec_widen_smult_even_@var{m}} instruction pattern
  3919. @cindex @code{vec_widen_smult_odd_@var{m}} instruction pattern
  3920. @item @samp{vec_widen_umult_hi_@var{m}}, @samp{vec_widen_umult_lo_@var{m}}
  3921. @itemx @samp{vec_widen_smult_hi_@var{m}}, @samp{vec_widen_smult_lo_@var{m}}
  3922. @itemx @samp{vec_widen_umult_even_@var{m}}, @samp{vec_widen_umult_odd_@var{m}}
  3923. @itemx @samp{vec_widen_smult_even_@var{m}}, @samp{vec_widen_smult_odd_@var{m}}
  3924. Signed/Unsigned widening multiplication. The two inputs (operands 1 and 2)
  3925. are vectors with N signed/unsigned elements of size S@. Multiply the high/low
  3926. or even/odd elements of the two vectors, and put the N/2 products of size 2*S
  3927. in the output vector (operand 0). A target shouldn't implement even/odd pattern
  3928. pair if it is less efficient than lo/hi one.
  3929. @cindex @code{vec_widen_ushiftl_hi_@var{m}} instruction pattern
  3930. @cindex @code{vec_widen_ushiftl_lo_@var{m}} instruction pattern
  3931. @cindex @code{vec_widen_sshiftl_hi_@var{m}} instruction pattern
  3932. @cindex @code{vec_widen_sshiftl_lo_@var{m}} instruction pattern
  3933. @item @samp{vec_widen_ushiftl_hi_@var{m}}, @samp{vec_widen_ushiftl_lo_@var{m}}
  3934. @itemx @samp{vec_widen_sshiftl_hi_@var{m}}, @samp{vec_widen_sshiftl_lo_@var{m}}
  3935. Signed/Unsigned widening shift left. The first input (operand 1) is a vector
  3936. with N signed/unsigned elements of size S@. Operand 2 is a constant. Shift
  3937. the high/low elements of operand 1, and put the N/2 results of size 2*S in the
  3938. output vector (operand 0).
  3939. @cindex @code{mulhisi3} instruction pattern
  3940. @item @samp{mulhisi3}
  3941. Multiply operands 1 and 2, which have mode @code{HImode}, and store
  3942. a @code{SImode} product in operand 0.
  3943. @cindex @code{mulqihi3} instruction pattern
  3944. @cindex @code{mulsidi3} instruction pattern
  3945. @item @samp{mulqihi3}, @samp{mulsidi3}
  3946. Similar widening-multiplication instructions of other widths.
  3947. @cindex @code{umulqihi3} instruction pattern
  3948. @cindex @code{umulhisi3} instruction pattern
  3949. @cindex @code{umulsidi3} instruction pattern
  3950. @item @samp{umulqihi3}, @samp{umulhisi3}, @samp{umulsidi3}
  3951. Similar widening-multiplication instructions that do unsigned
  3952. multiplication.
  3953. @cindex @code{usmulqihi3} instruction pattern
  3954. @cindex @code{usmulhisi3} instruction pattern
  3955. @cindex @code{usmulsidi3} instruction pattern
  3956. @item @samp{usmulqihi3}, @samp{usmulhisi3}, @samp{usmulsidi3}
  3957. Similar widening-multiplication instructions that interpret the first
  3958. operand as unsigned and the second operand as signed, then do a signed
  3959. multiplication.
  3960. @cindex @code{smul@var{m}3_highpart} instruction pattern
  3961. @item @samp{smul@var{m}3_highpart}
  3962. Perform a signed multiplication of operands 1 and 2, which have mode
  3963. @var{m}, and store the most significant half of the product in operand 0.
  3964. The least significant half of the product is discarded.
  3965. @cindex @code{umul@var{m}3_highpart} instruction pattern
  3966. @item @samp{umul@var{m}3_highpart}
  3967. Similar, but the multiplication is unsigned.
  3968. @cindex @code{madd@var{m}@var{n}4} instruction pattern
  3969. @item @samp{madd@var{m}@var{n}4}
  3970. Multiply operands 1 and 2, sign-extend them to mode @var{n}, add
  3971. operand 3, and store the result in operand 0. Operands 1 and 2
  3972. have mode @var{m} and operands 0 and 3 have mode @var{n}.
  3973. Both modes must be integer or fixed-point modes and @var{n} must be twice
  3974. the size of @var{m}.
  3975. In other words, @code{madd@var{m}@var{n}4} is like
  3976. @code{mul@var{m}@var{n}3} except that it also adds operand 3.
  3977. These instructions are not allowed to @code{FAIL}.
  3978. @cindex @code{umadd@var{m}@var{n}4} instruction pattern
  3979. @item @samp{umadd@var{m}@var{n}4}
  3980. Like @code{madd@var{m}@var{n}4}, but zero-extend the multiplication
  3981. operands instead of sign-extending them.
  3982. @cindex @code{ssmadd@var{m}@var{n}4} instruction pattern
  3983. @item @samp{ssmadd@var{m}@var{n}4}
  3984. Like @code{madd@var{m}@var{n}4}, but all involved operations must be
  3985. signed-saturating.
  3986. @cindex @code{usmadd@var{m}@var{n}4} instruction pattern
  3987. @item @samp{usmadd@var{m}@var{n}4}
  3988. Like @code{umadd@var{m}@var{n}4}, but all involved operations must be
  3989. unsigned-saturating.
  3990. @cindex @code{msub@var{m}@var{n}4} instruction pattern
  3991. @item @samp{msub@var{m}@var{n}4}
  3992. Multiply operands 1 and 2, sign-extend them to mode @var{n}, subtract the
  3993. result from operand 3, and store the result in operand 0. Operands 1 and 2
  3994. have mode @var{m} and operands 0 and 3 have mode @var{n}.
  3995. Both modes must be integer or fixed-point modes and @var{n} must be twice
  3996. the size of @var{m}.
  3997. In other words, @code{msub@var{m}@var{n}4} is like
  3998. @code{mul@var{m}@var{n}3} except that it also subtracts the result
  3999. from operand 3.
  4000. These instructions are not allowed to @code{FAIL}.
  4001. @cindex @code{umsub@var{m}@var{n}4} instruction pattern
  4002. @item @samp{umsub@var{m}@var{n}4}
  4003. Like @code{msub@var{m}@var{n}4}, but zero-extend the multiplication
  4004. operands instead of sign-extending them.
  4005. @cindex @code{ssmsub@var{m}@var{n}4} instruction pattern
  4006. @item @samp{ssmsub@var{m}@var{n}4}
  4007. Like @code{msub@var{m}@var{n}4}, but all involved operations must be
  4008. signed-saturating.
  4009. @cindex @code{usmsub@var{m}@var{n}4} instruction pattern
  4010. @item @samp{usmsub@var{m}@var{n}4}
  4011. Like @code{umsub@var{m}@var{n}4}, but all involved operations must be
  4012. unsigned-saturating.
  4013. @cindex @code{divmod@var{m}4} instruction pattern
  4014. @item @samp{divmod@var{m}4}
  4015. Signed division that produces both a quotient and a remainder.
  4016. Operand 1 is divided by operand 2 to produce a quotient stored
  4017. in operand 0 and a remainder stored in operand 3.
  4018. For machines with an instruction that produces both a quotient and a
  4019. remainder, provide a pattern for @samp{divmod@var{m}4} but do not
  4020. provide patterns for @samp{div@var{m}3} and @samp{mod@var{m}3}. This
  4021. allows optimization in the relatively common case when both the quotient
  4022. and remainder are computed.
  4023. If an instruction that just produces a quotient or just a remainder
  4024. exists and is more efficient than the instruction that produces both,
  4025. write the output routine of @samp{divmod@var{m}4} to call
  4026. @code{find_reg_note} and look for a @code{REG_UNUSED} note on the
  4027. quotient or remainder and generate the appropriate instruction.
  4028. @cindex @code{udivmod@var{m}4} instruction pattern
  4029. @item @samp{udivmod@var{m}4}
  4030. Similar, but does unsigned division.
  4031. @anchor{shift patterns}
  4032. @cindex @code{ashl@var{m}3} instruction pattern
  4033. @cindex @code{ssashl@var{m}3} instruction pattern
  4034. @cindex @code{usashl@var{m}3} instruction pattern
  4035. @item @samp{ashl@var{m}3}, @samp{ssashl@var{m}3}, @samp{usashl@var{m}3}
  4036. Arithmetic-shift operand 1 left by a number of bits specified by operand
  4037. 2, and store the result in operand 0. Here @var{m} is the mode of
  4038. operand 0 and operand 1; operand 2's mode is specified by the
  4039. instruction pattern, and the compiler will convert the operand to that
  4040. mode before generating the instruction. The meaning of out-of-range shift
  4041. counts can optionally be specified by @code{TARGET_SHIFT_TRUNCATION_MASK}.
  4042. @xref{TARGET_SHIFT_TRUNCATION_MASK}. Operand 2 is always a scalar type.
  4043. @cindex @code{ashr@var{m}3} instruction pattern
  4044. @cindex @code{lshr@var{m}3} instruction pattern
  4045. @cindex @code{rotl@var{m}3} instruction pattern
  4046. @cindex @code{rotr@var{m}3} instruction pattern
  4047. @item @samp{ashr@var{m}3}, @samp{lshr@var{m}3}, @samp{rotl@var{m}3}, @samp{rotr@var{m}3}
  4048. Other shift and rotate instructions, analogous to the
  4049. @code{ashl@var{m}3} instructions. Operand 2 is always a scalar type.
  4050. @cindex @code{vashl@var{m}3} instruction pattern
  4051. @cindex @code{vashr@var{m}3} instruction pattern
  4052. @cindex @code{vlshr@var{m}3} instruction pattern
  4053. @cindex @code{vrotl@var{m}3} instruction pattern
  4054. @cindex @code{vrotr@var{m}3} instruction pattern
  4055. @item @samp{vashl@var{m}3}, @samp{vashr@var{m}3}, @samp{vlshr@var{m}3}, @samp{vrotl@var{m}3}, @samp{vrotr@var{m}3}
  4056. Vector shift and rotate instructions that take vectors as operand 2
  4057. instead of a scalar type.
  4058. @cindex @code{bswap@var{m}2} instruction pattern
  4059. @item @samp{bswap@var{m}2}
  4060. Reverse the order of bytes of operand 1 and store the result in operand 0.
  4061. @cindex @code{neg@var{m}2} instruction pattern
  4062. @cindex @code{ssneg@var{m}2} instruction pattern
  4063. @cindex @code{usneg@var{m}2} instruction pattern
  4064. @item @samp{neg@var{m}2}, @samp{ssneg@var{m}2}, @samp{usneg@var{m}2}
  4065. Negate operand 1 and store the result in operand 0.
  4066. @cindex @code{abs@var{m}2} instruction pattern
  4067. @item @samp{abs@var{m}2}
  4068. Store the absolute value of operand 1 into operand 0.
  4069. @cindex @code{sqrt@var{m}2} instruction pattern
  4070. @item @samp{sqrt@var{m}2}
  4071. Store the square root of operand 1 into operand 0.
  4072. The @code{sqrt} built-in function of C always uses the mode which
  4073. corresponds to the C data type @code{double} and the @code{sqrtf}
  4074. built-in function uses the mode which corresponds to the C data
  4075. type @code{float}.
  4076. @cindex @code{fmod@var{m}3} instruction pattern
  4077. @item @samp{fmod@var{m}3}
  4078. Store the remainder of dividing operand 1 by operand 2 into
  4079. operand 0, rounded towards zero to an integer.
  4080. The @code{fmod} built-in function of C always uses the mode which
  4081. corresponds to the C data type @code{double} and the @code{fmodf}
  4082. built-in function uses the mode which corresponds to the C data
  4083. type @code{float}.
  4084. @cindex @code{remainder@var{m}3} instruction pattern
  4085. @item @samp{remainder@var{m}3}
  4086. Store the remainder of dividing operand 1 by operand 2 into
  4087. operand 0, rounded to the nearest integer.
  4088. The @code{remainder} built-in function of C always uses the mode
  4089. which corresponds to the C data type @code{double} and the
  4090. @code{remainderf} built-in function uses the mode which corresponds
  4091. to the C data type @code{float}.
  4092. @cindex @code{cos@var{m}2} instruction pattern
  4093. @item @samp{cos@var{m}2}
  4094. Store the cosine of operand 1 into operand 0.
  4095. The @code{cos} built-in function of C always uses the mode which
  4096. corresponds to the C data type @code{double} and the @code{cosf}
  4097. built-in function uses the mode which corresponds to the C data
  4098. type @code{float}.
  4099. @cindex @code{sin@var{m}2} instruction pattern
  4100. @item @samp{sin@var{m}2}
  4101. Store the sine of operand 1 into operand 0.
  4102. The @code{sin} built-in function of C always uses the mode which
  4103. corresponds to the C data type @code{double} and the @code{sinf}
  4104. built-in function uses the mode which corresponds to the C data
  4105. type @code{float}.
  4106. @cindex @code{sincos@var{m}3} instruction pattern
  4107. @item @samp{sincos@var{m}3}
  4108. Store the cosine of operand 2 into operand 0 and the sine of
  4109. operand 2 into operand 1.
  4110. The @code{sin} and @code{cos} built-in functions of C always use the
  4111. mode which corresponds to the C data type @code{double} and the
  4112. @code{sinf} and @code{cosf} built-in function use the mode which
  4113. corresponds to the C data type @code{float}.
  4114. Targets that can calculate the sine and cosine simultaneously can
  4115. implement this pattern as opposed to implementing individual
  4116. @code{sin@var{m}2} and @code{cos@var{m}2} patterns. The @code{sin}
  4117. and @code{cos} built-in functions will then be expanded to the
  4118. @code{sincos@var{m}3} pattern, with one of the output values
  4119. left unused.
  4120. @cindex @code{exp@var{m}2} instruction pattern
  4121. @item @samp{exp@var{m}2}
  4122. Store the exponential of operand 1 into operand 0.
  4123. The @code{exp} built-in function of C always uses the mode which
  4124. corresponds to the C data type @code{double} and the @code{expf}
  4125. built-in function uses the mode which corresponds to the C data
  4126. type @code{float}.
  4127. @cindex @code{log@var{m}2} instruction pattern
  4128. @item @samp{log@var{m}2}
  4129. Store the natural logarithm of operand 1 into operand 0.
  4130. The @code{log} built-in function of C always uses the mode which
  4131. corresponds to the C data type @code{double} and the @code{logf}
  4132. built-in function uses the mode which corresponds to the C data
  4133. type @code{float}.
  4134. @cindex @code{pow@var{m}3} instruction pattern
  4135. @item @samp{pow@var{m}3}
  4136. Store the value of operand 1 raised to the exponent operand 2
  4137. into operand 0.
  4138. The @code{pow} built-in function of C always uses the mode which
  4139. corresponds to the C data type @code{double} and the @code{powf}
  4140. built-in function uses the mode which corresponds to the C data
  4141. type @code{float}.
  4142. @cindex @code{atan2@var{m}3} instruction pattern
  4143. @item @samp{atan2@var{m}3}
  4144. Store the arc tangent (inverse tangent) of operand 1 divided by
  4145. operand 2 into operand 0, using the signs of both arguments to
  4146. determine the quadrant of the result.
  4147. The @code{atan2} built-in function of C always uses the mode which
  4148. corresponds to the C data type @code{double} and the @code{atan2f}
  4149. built-in function uses the mode which corresponds to the C data
  4150. type @code{float}.
  4151. @cindex @code{floor@var{m}2} instruction pattern
  4152. @item @samp{floor@var{m}2}
  4153. Store the largest integral value not greater than argument.
  4154. The @code{floor} built-in function of C always uses the mode which
  4155. corresponds to the C data type @code{double} and the @code{floorf}
  4156. built-in function uses the mode which corresponds to the C data
  4157. type @code{float}.
  4158. @cindex @code{btrunc@var{m}2} instruction pattern
  4159. @item @samp{btrunc@var{m}2}
  4160. Store the argument rounded to integer towards zero.
  4161. The @code{trunc} built-in function of C always uses the mode which
  4162. corresponds to the C data type @code{double} and the @code{truncf}
  4163. built-in function uses the mode which corresponds to the C data
  4164. type @code{float}.
  4165. @cindex @code{round@var{m}2} instruction pattern
  4166. @item @samp{round@var{m}2}
  4167. Store the argument rounded to integer away from zero.
  4168. The @code{round} built-in function of C always uses the mode which
  4169. corresponds to the C data type @code{double} and the @code{roundf}
  4170. built-in function uses the mode which corresponds to the C data
  4171. type @code{float}.
  4172. @cindex @code{ceil@var{m}2} instruction pattern
  4173. @item @samp{ceil@var{m}2}
  4174. Store the argument rounded to integer away from zero.
  4175. The @code{ceil} built-in function of C always uses the mode which
  4176. corresponds to the C data type @code{double} and the @code{ceilf}
  4177. built-in function uses the mode which corresponds to the C data
  4178. type @code{float}.
  4179. @cindex @code{nearbyint@var{m}2} instruction pattern
  4180. @item @samp{nearbyint@var{m}2}
  4181. Store the argument rounded according to the default rounding mode
  4182. The @code{nearbyint} built-in function of C always uses the mode which
  4183. corresponds to the C data type @code{double} and the @code{nearbyintf}
  4184. built-in function uses the mode which corresponds to the C data
  4185. type @code{float}.
  4186. @cindex @code{rint@var{m}2} instruction pattern
  4187. @item @samp{rint@var{m}2}
  4188. Store the argument rounded according to the default rounding mode and
  4189. raise the inexact exception when the result differs in value from
  4190. the argument
  4191. The @code{rint} built-in function of C always uses the mode which
  4192. corresponds to the C data type @code{double} and the @code{rintf}
  4193. built-in function uses the mode which corresponds to the C data
  4194. type @code{float}.
  4195. @cindex @code{lrint@var{m}@var{n}2}
  4196. @item @samp{lrint@var{m}@var{n}2}
  4197. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  4198. point mode @var{n} as a signed number according to the current
  4199. rounding mode and store in operand 0 (which has mode @var{n}).
  4200. @cindex @code{lround@var{m}@var{n}2}
  4201. @item @samp{lround@var{m}@var{n}2}
  4202. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  4203. point mode @var{n} as a signed number rounding to nearest and away
  4204. from zero and store in operand 0 (which has mode @var{n}).
  4205. @cindex @code{lfloor@var{m}@var{n}2}
  4206. @item @samp{lfloor@var{m}@var{n}2}
  4207. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  4208. point mode @var{n} as a signed number rounding down and store in
  4209. operand 0 (which has mode @var{n}).
  4210. @cindex @code{lceil@var{m}@var{n}2}
  4211. @item @samp{lceil@var{m}@var{n}2}
  4212. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  4213. point mode @var{n} as a signed number rounding up and store in
  4214. operand 0 (which has mode @var{n}).
  4215. @cindex @code{copysign@var{m}3} instruction pattern
  4216. @item @samp{copysign@var{m}3}
  4217. Store a value with the magnitude of operand 1 and the sign of operand
  4218. 2 into operand 0.
  4219. The @code{copysign} built-in function of C always uses the mode which
  4220. corresponds to the C data type @code{double} and the @code{copysignf}
  4221. built-in function uses the mode which corresponds to the C data
  4222. type @code{float}.
  4223. @cindex @code{ffs@var{m}2} instruction pattern
  4224. @item @samp{ffs@var{m}2}
  4225. Store into operand 0 one plus the index of the least significant 1-bit
  4226. of operand 1. If operand 1 is zero, store zero. @var{m} is the mode
  4227. of operand 0; operand 1's mode is specified by the instruction
  4228. pattern, and the compiler will convert the operand to that mode before
  4229. generating the instruction.
  4230. The @code{ffs} built-in function of C always uses the mode which
  4231. corresponds to the C data type @code{int}.
  4232. @cindex @code{clrsb@var{m}2} instruction pattern
  4233. @item @samp{clrsb@var{m}2}
  4234. Count leading redundant sign bits.
  4235. Store into operand 0 the number of redundant sign bits in operand 1, starting
  4236. at the most significant bit position.
  4237. A redundant sign bit is defined as any sign bit after the first. As such,
  4238. this count will be one less than the count of leading sign bits.
  4239. @cindex @code{clz@var{m}2} instruction pattern
  4240. @item @samp{clz@var{m}2}
  4241. Store into operand 0 the number of leading 0-bits in operand 1, starting
  4242. at the most significant bit position. If operand 1 is 0, the
  4243. @code{CLZ_DEFINED_VALUE_AT_ZERO} (@pxref{Misc}) macro defines if
  4244. the result is undefined or has a useful value.
  4245. @var{m} is the mode of operand 0; operand 1's mode is
  4246. specified by the instruction pattern, and the compiler will convert the
  4247. operand to that mode before generating the instruction.
  4248. @cindex @code{ctz@var{m}2} instruction pattern
  4249. @item @samp{ctz@var{m}2}
  4250. Store into operand 0 the number of trailing 0-bits in operand 1, starting
  4251. at the least significant bit position. If operand 1 is 0, the
  4252. @code{CTZ_DEFINED_VALUE_AT_ZERO} (@pxref{Misc}) macro defines if
  4253. the result is undefined or has a useful value.
  4254. @var{m} is the mode of operand 0; operand 1's mode is
  4255. specified by the instruction pattern, and the compiler will convert the
  4256. operand to that mode before generating the instruction.
  4257. @cindex @code{popcount@var{m}2} instruction pattern
  4258. @item @samp{popcount@var{m}2}
  4259. Store into operand 0 the number of 1-bits in operand 1. @var{m} is the
  4260. mode of operand 0; operand 1's mode is specified by the instruction
  4261. pattern, and the compiler will convert the operand to that mode before
  4262. generating the instruction.
  4263. @cindex @code{parity@var{m}2} instruction pattern
  4264. @item @samp{parity@var{m}2}
  4265. Store into operand 0 the parity of operand 1, i.e.@: the number of 1-bits
  4266. in operand 1 modulo 2. @var{m} is the mode of operand 0; operand 1's mode
  4267. is specified by the instruction pattern, and the compiler will convert
  4268. the operand to that mode before generating the instruction.
  4269. @cindex @code{one_cmpl@var{m}2} instruction pattern
  4270. @item @samp{one_cmpl@var{m}2}
  4271. Store the bitwise-complement of operand 1 into operand 0.
  4272. @cindex @code{movmem@var{m}} instruction pattern
  4273. @item @samp{movmem@var{m}}
  4274. Block move instruction. The destination and source blocks of memory
  4275. are the first two operands, and both are @code{mem:BLK}s with an
  4276. address in mode @code{Pmode}.
  4277. The number of bytes to move is the third operand, in mode @var{m}.
  4278. Usually, you specify @code{Pmode} for @var{m}. However, if you can
  4279. generate better code knowing the range of valid lengths is smaller than
  4280. those representable in a full Pmode pointer, you should provide
  4281. a pattern with a
  4282. mode corresponding to the range of values you can handle efficiently
  4283. (e.g., @code{QImode} for values in the range 0--127; note we avoid numbers
  4284. that appear negative) and also a pattern with @code{Pmode}.
  4285. The fourth operand is the known shared alignment of the source and
  4286. destination, in the form of a @code{const_int} rtx. Thus, if the
  4287. compiler knows that both source and destination are word-aligned,
  4288. it may provide the value 4 for this operand.
  4289. Optional operands 5 and 6 specify expected alignment and size of block
  4290. respectively. The expected alignment differs from alignment in operand 4
  4291. in a way that the blocks are not required to be aligned according to it in
  4292. all cases. This expected alignment is also in bytes, just like operand 4.
  4293. Expected size, when unknown, is set to @code{(const_int -1)}.
  4294. Descriptions of multiple @code{movmem@var{m}} patterns can only be
  4295. beneficial if the patterns for smaller modes have fewer restrictions
  4296. on their first, second and fourth operands. Note that the mode @var{m}
  4297. in @code{movmem@var{m}} does not impose any restriction on the mode of
  4298. individually moved data units in the block.
  4299. These patterns need not give special consideration to the possibility
  4300. that the source and destination strings might overlap.
  4301. @cindex @code{movstr} instruction pattern
  4302. @item @samp{movstr}
  4303. String copy instruction, with @code{stpcpy} semantics. Operand 0 is
  4304. an output operand in mode @code{Pmode}. The addresses of the
  4305. destination and source strings are operands 1 and 2, and both are
  4306. @code{mem:BLK}s with addresses in mode @code{Pmode}. The execution of
  4307. the expansion of this pattern should store in operand 0 the address in
  4308. which the @code{NUL} terminator was stored in the destination string.
  4309. This patern has also several optional operands that are same as in
  4310. @code{setmem}.
  4311. @cindex @code{setmem@var{m}} instruction pattern
  4312. @item @samp{setmem@var{m}}
  4313. Block set instruction. The destination string is the first operand,
  4314. given as a @code{mem:BLK} whose address is in mode @code{Pmode}. The
  4315. number of bytes to set is the second operand, in mode @var{m}. The value to
  4316. initialize the memory with is the third operand. Targets that only support the
  4317. clearing of memory should reject any value that is not the constant 0. See
  4318. @samp{movmem@var{m}} for a discussion of the choice of mode.
  4319. The fourth operand is the known alignment of the destination, in the form
  4320. of a @code{const_int} rtx. Thus, if the compiler knows that the
  4321. destination is word-aligned, it may provide the value 4 for this
  4322. operand.
  4323. Optional operands 5 and 6 specify expected alignment and size of block
  4324. respectively. The expected alignment differs from alignment in operand 4
  4325. in a way that the blocks are not required to be aligned according to it in
  4326. all cases. This expected alignment is also in bytes, just like operand 4.
  4327. Expected size, when unknown, is set to @code{(const_int -1)}.
  4328. Operand 7 is the minimal size of the block and operand 8 is the
  4329. maximal size of the block (NULL if it can not be represented as CONST_INT).
  4330. Operand 9 is the probable maximal size (i.e. we can not rely on it for correctness,
  4331. but it can be used for choosing proper code sequence for a given size).
  4332. The use for multiple @code{setmem@var{m}} is as for @code{movmem@var{m}}.
  4333. @cindex @code{cmpstrn@var{m}} instruction pattern
  4334. @item @samp{cmpstrn@var{m}}
  4335. String compare instruction, with five operands. Operand 0 is the output;
  4336. it has mode @var{m}. The remaining four operands are like the operands
  4337. of @samp{movmem@var{m}}. The two memory blocks specified are compared
  4338. byte by byte in lexicographic order starting at the beginning of each
  4339. string. The instruction is not allowed to prefetch more than one byte
  4340. at a time since either string may end in the first byte and reading past
  4341. that may access an invalid page or segment and cause a fault. The
  4342. comparison terminates early if the fetched bytes are different or if
  4343. they are equal to zero. The effect of the instruction is to store a
  4344. value in operand 0 whose sign indicates the result of the comparison.
  4345. @cindex @code{cmpstr@var{m}} instruction pattern
  4346. @item @samp{cmpstr@var{m}}
  4347. String compare instruction, without known maximum length. Operand 0 is the
  4348. output; it has mode @var{m}. The second and third operand are the blocks of
  4349. memory to be compared; both are @code{mem:BLK} with an address in mode
  4350. @code{Pmode}.
  4351. The fourth operand is the known shared alignment of the source and
  4352. destination, in the form of a @code{const_int} rtx. Thus, if the
  4353. compiler knows that both source and destination are word-aligned,
  4354. it may provide the value 4 for this operand.
  4355. The two memory blocks specified are compared byte by byte in lexicographic
  4356. order starting at the beginning of each string. The instruction is not allowed
  4357. to prefetch more than one byte at a time since either string may end in the
  4358. first byte and reading past that may access an invalid page or segment and
  4359. cause a fault. The comparison will terminate when the fetched bytes
  4360. are different or if they are equal to zero. The effect of the
  4361. instruction is to store a value in operand 0 whose sign indicates the
  4362. result of the comparison.
  4363. @cindex @code{cmpmem@var{m}} instruction pattern
  4364. @item @samp{cmpmem@var{m}}
  4365. Block compare instruction, with five operands like the operands
  4366. of @samp{cmpstr@var{m}}. The two memory blocks specified are compared
  4367. byte by byte in lexicographic order starting at the beginning of each
  4368. block. Unlike @samp{cmpstr@var{m}} the instruction can prefetch
  4369. any bytes in the two memory blocks. Also unlike @samp{cmpstr@var{m}}
  4370. the comparison will not stop if both bytes are zero. The effect of
  4371. the instruction is to store a value in operand 0 whose sign indicates
  4372. the result of the comparison.
  4373. @cindex @code{strlen@var{m}} instruction pattern
  4374. @item @samp{strlen@var{m}}
  4375. Compute the length of a string, with three operands.
  4376. Operand 0 is the result (of mode @var{m}), operand 1 is
  4377. a @code{mem} referring to the first character of the string,
  4378. operand 2 is the character to search for (normally zero),
  4379. and operand 3 is a constant describing the known alignment
  4380. of the beginning of the string.
  4381. @cindex @code{float@var{m}@var{n}2} instruction pattern
  4382. @item @samp{float@var{m}@var{n}2}
  4383. Convert signed integer operand 1 (valid for fixed point mode @var{m}) to
  4384. floating point mode @var{n} and store in operand 0 (which has mode
  4385. @var{n}).
  4386. @cindex @code{floatuns@var{m}@var{n}2} instruction pattern
  4387. @item @samp{floatuns@var{m}@var{n}2}
  4388. Convert unsigned integer operand 1 (valid for fixed point mode @var{m})
  4389. to floating point mode @var{n} and store in operand 0 (which has mode
  4390. @var{n}).
  4391. @cindex @code{fix@var{m}@var{n}2} instruction pattern
  4392. @item @samp{fix@var{m}@var{n}2}
  4393. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  4394. point mode @var{n} as a signed number and store in operand 0 (which
  4395. has mode @var{n}). This instruction's result is defined only when
  4396. the value of operand 1 is an integer.
  4397. If the machine description defines this pattern, it also needs to
  4398. define the @code{ftrunc} pattern.
  4399. @cindex @code{fixuns@var{m}@var{n}2} instruction pattern
  4400. @item @samp{fixuns@var{m}@var{n}2}
  4401. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  4402. point mode @var{n} as an unsigned number and store in operand 0 (which
  4403. has mode @var{n}). This instruction's result is defined only when the
  4404. value of operand 1 is an integer.
  4405. @cindex @code{ftrunc@var{m}2} instruction pattern
  4406. @item @samp{ftrunc@var{m}2}
  4407. Convert operand 1 (valid for floating point mode @var{m}) to an
  4408. integer value, still represented in floating point mode @var{m}, and
  4409. store it in operand 0 (valid for floating point mode @var{m}).
  4410. @cindex @code{fix_trunc@var{m}@var{n}2} instruction pattern
  4411. @item @samp{fix_trunc@var{m}@var{n}2}
  4412. Like @samp{fix@var{m}@var{n}2} but works for any floating point value
  4413. of mode @var{m} by converting the value to an integer.
  4414. @cindex @code{fixuns_trunc@var{m}@var{n}2} instruction pattern
  4415. @item @samp{fixuns_trunc@var{m}@var{n}2}
  4416. Like @samp{fixuns@var{m}@var{n}2} but works for any floating point
  4417. value of mode @var{m} by converting the value to an integer.
  4418. @cindex @code{trunc@var{m}@var{n}2} instruction pattern
  4419. @item @samp{trunc@var{m}@var{n}2}
  4420. Truncate operand 1 (valid for mode @var{m}) to mode @var{n} and
  4421. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  4422. point or both floating point.
  4423. @cindex @code{extend@var{m}@var{n}2} instruction pattern
  4424. @item @samp{extend@var{m}@var{n}2}
  4425. Sign-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
  4426. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  4427. point or both floating point.
  4428. @cindex @code{zero_extend@var{m}@var{n}2} instruction pattern
  4429. @item @samp{zero_extend@var{m}@var{n}2}
  4430. Zero-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
  4431. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  4432. point.
  4433. @cindex @code{fract@var{m}@var{n}2} instruction pattern
  4434. @item @samp{fract@var{m}@var{n}2}
  4435. Convert operand 1 of mode @var{m} to mode @var{n} and store in
  4436. operand 0 (which has mode @var{n}). Mode @var{m} and mode @var{n}
  4437. could be fixed-point to fixed-point, signed integer to fixed-point,
  4438. fixed-point to signed integer, floating-point to fixed-point,
  4439. or fixed-point to floating-point.
  4440. When overflows or underflows happen, the results are undefined.
  4441. @cindex @code{satfract@var{m}@var{n}2} instruction pattern
  4442. @item @samp{satfract@var{m}@var{n}2}
  4443. Convert operand 1 of mode @var{m} to mode @var{n} and store in
  4444. operand 0 (which has mode @var{n}). Mode @var{m} and mode @var{n}
  4445. could be fixed-point to fixed-point, signed integer to fixed-point,
  4446. or floating-point to fixed-point.
  4447. When overflows or underflows happen, the instruction saturates the
  4448. results to the maximum or the minimum.
  4449. @cindex @code{fractuns@var{m}@var{n}2} instruction pattern
  4450. @item @samp{fractuns@var{m}@var{n}2}
  4451. Convert operand 1 of mode @var{m} to mode @var{n} and store in
  4452. operand 0 (which has mode @var{n}). Mode @var{m} and mode @var{n}
  4453. could be unsigned integer to fixed-point, or
  4454. fixed-point to unsigned integer.
  4455. When overflows or underflows happen, the results are undefined.
  4456. @cindex @code{satfractuns@var{m}@var{n}2} instruction pattern
  4457. @item @samp{satfractuns@var{m}@var{n}2}
  4458. Convert unsigned integer operand 1 of mode @var{m} to fixed-point mode
  4459. @var{n} and store in operand 0 (which has mode @var{n}).
  4460. When overflows or underflows happen, the instruction saturates the
  4461. results to the maximum or the minimum.
  4462. @cindex @code{extv@var{m}} instruction pattern
  4463. @item @samp{extv@var{m}}
  4464. Extract a bit-field from register operand 1, sign-extend it, and store
  4465. it in operand 0. Operand 2 specifies the width of the field in bits
  4466. and operand 3 the starting bit, which counts from the most significant
  4467. bit if @samp{BITS_BIG_ENDIAN} is true and from the least significant bit
  4468. otherwise.
  4469. Operands 0 and 1 both have mode @var{m}. Operands 2 and 3 have a
  4470. target-specific mode.
  4471. @cindex @code{extvmisalign@var{m}} instruction pattern
  4472. @item @samp{extvmisalign@var{m}}
  4473. Extract a bit-field from memory operand 1, sign extend it, and store
  4474. it in operand 0. Operand 2 specifies the width in bits and operand 3
  4475. the starting bit. The starting bit is always somewhere in the first byte of
  4476. operand 1; it counts from the most significant bit if @samp{BITS_BIG_ENDIAN}
  4477. is true and from the least significant bit otherwise.
  4478. Operand 0 has mode @var{m} while operand 1 has @code{BLK} mode.
  4479. Operands 2 and 3 have a target-specific mode.
  4480. The instruction must not read beyond the last byte of the bit-field.
  4481. @cindex @code{extzv@var{m}} instruction pattern
  4482. @item @samp{extzv@var{m}}
  4483. Like @samp{extv@var{m}} except that the bit-field value is zero-extended.
  4484. @cindex @code{extzvmisalign@var{m}} instruction pattern
  4485. @item @samp{extzvmisalign@var{m}}
  4486. Like @samp{extvmisalign@var{m}} except that the bit-field value is
  4487. zero-extended.
  4488. @cindex @code{insv@var{m}} instruction pattern
  4489. @item @samp{insv@var{m}}
  4490. Insert operand 3 into a bit-field of register operand 0. Operand 1
  4491. specifies the width of the field in bits and operand 2 the starting bit,
  4492. which counts from the most significant bit if @samp{BITS_BIG_ENDIAN}
  4493. is true and from the least significant bit otherwise.
  4494. Operands 0 and 3 both have mode @var{m}. Operands 1 and 2 have a
  4495. target-specific mode.
  4496. @cindex @code{insvmisalign@var{m}} instruction pattern
  4497. @item @samp{insvmisalign@var{m}}
  4498. Insert operand 3 into a bit-field of memory operand 0. Operand 1
  4499. specifies the width of the field in bits and operand 2 the starting bit.
  4500. The starting bit is always somewhere in the first byte of operand 0;
  4501. it counts from the most significant bit if @samp{BITS_BIG_ENDIAN}
  4502. is true and from the least significant bit otherwise.
  4503. Operand 3 has mode @var{m} while operand 0 has @code{BLK} mode.
  4504. Operands 1 and 2 have a target-specific mode.
  4505. The instruction must not read or write beyond the last byte of the bit-field.
  4506. @cindex @code{extv} instruction pattern
  4507. @item @samp{extv}
  4508. Extract a bit-field from operand 1 (a register or memory operand), where
  4509. operand 2 specifies the width in bits and operand 3 the starting bit,
  4510. and store it in operand 0. Operand 0 must have mode @code{word_mode}.
  4511. Operand 1 may have mode @code{byte_mode} or @code{word_mode}; often
  4512. @code{word_mode} is allowed only for registers. Operands 2 and 3 must
  4513. be valid for @code{word_mode}.
  4514. The RTL generation pass generates this instruction only with constants
  4515. for operands 2 and 3 and the constant is never zero for operand 2.
  4516. The bit-field value is sign-extended to a full word integer
  4517. before it is stored in operand 0.
  4518. This pattern is deprecated; please use @samp{extv@var{m}} and
  4519. @code{extvmisalign@var{m}} instead.
  4520. @cindex @code{extzv} instruction pattern
  4521. @item @samp{extzv}
  4522. Like @samp{extv} except that the bit-field value is zero-extended.
  4523. This pattern is deprecated; please use @samp{extzv@var{m}} and
  4524. @code{extzvmisalign@var{m}} instead.
  4525. @cindex @code{insv} instruction pattern
  4526. @item @samp{insv}
  4527. Store operand 3 (which must be valid for @code{word_mode}) into a
  4528. bit-field in operand 0, where operand 1 specifies the width in bits and
  4529. operand 2 the starting bit. Operand 0 may have mode @code{byte_mode} or
  4530. @code{word_mode}; often @code{word_mode} is allowed only for registers.
  4531. Operands 1 and 2 must be valid for @code{word_mode}.
  4532. The RTL generation pass generates this instruction only with constants
  4533. for operands 1 and 2 and the constant is never zero for operand 1.
  4534. This pattern is deprecated; please use @samp{insv@var{m}} and
  4535. @code{insvmisalign@var{m}} instead.
  4536. @cindex @code{mov@var{mode}cc} instruction pattern
  4537. @item @samp{mov@var{mode}cc}
  4538. Conditionally move operand 2 or operand 3 into operand 0 according to the
  4539. comparison in operand 1. If the comparison is true, operand 2 is moved
  4540. into operand 0, otherwise operand 3 is moved.
  4541. The mode of the operands being compared need not be the same as the operands
  4542. being moved. Some machines, sparc64 for example, have instructions that
  4543. conditionally move an integer value based on the floating point condition
  4544. codes and vice versa.
  4545. If the machine does not have conditional move instructions, do not
  4546. define these patterns.
  4547. @cindex @code{add@var{mode}cc} instruction pattern
  4548. @item @samp{add@var{mode}cc}
  4549. Similar to @samp{mov@var{mode}cc} but for conditional addition. Conditionally
  4550. move operand 2 or (operands 2 + operand 3) into operand 0 according to the
  4551. comparison in operand 1. If the comparison is false, operand 2 is moved into
  4552. operand 0, otherwise (operand 2 + operand 3) is moved.
  4553. @cindex @code{cstore@var{mode}4} instruction pattern
  4554. @item @samp{cstore@var{mode}4}
  4555. Store zero or nonzero in operand 0 according to whether a comparison
  4556. is true. Operand 1 is a comparison operator. Operand 2 and operand 3
  4557. are the first and second operand of the comparison, respectively.
  4558. You specify the mode that operand 0 must have when you write the
  4559. @code{match_operand} expression. The compiler automatically sees which
  4560. mode you have used and supplies an operand of that mode.
  4561. The value stored for a true condition must have 1 as its low bit, or
  4562. else must be negative. Otherwise the instruction is not suitable and
  4563. you should omit it from the machine description. You describe to the
  4564. compiler exactly which value is stored by defining the macro
  4565. @code{STORE_FLAG_VALUE} (@pxref{Misc}). If a description cannot be
  4566. found that can be used for all the possible comparison operators, you
  4567. should pick one and use a @code{define_expand} to map all results
  4568. onto the one you chose.
  4569. These operations may @code{FAIL}, but should do so only in relatively
  4570. uncommon cases; if they would @code{FAIL} for common cases involving
  4571. integer comparisons, it is best to restrict the predicates to not
  4572. allow these operands. Likewise if a given comparison operator will
  4573. always fail, independent of the operands (for floating-point modes, the
  4574. @code{ordered_comparison_operator} predicate is often useful in this case).
  4575. If this pattern is omitted, the compiler will generate a conditional
  4576. branch---for example, it may copy a constant one to the target and branching
  4577. around an assignment of zero to the target---or a libcall. If the predicate
  4578. for operand 1 only rejects some operators, it will also try reordering the
  4579. operands and/or inverting the result value (e.g.@: by an exclusive OR).
  4580. These possibilities could be cheaper or equivalent to the instructions
  4581. used for the @samp{cstore@var{mode}4} pattern followed by those required
  4582. to convert a positive result from @code{STORE_FLAG_VALUE} to 1; in this
  4583. case, you can and should make operand 1's predicate reject some operators
  4584. in the @samp{cstore@var{mode}4} pattern, or remove the pattern altogether
  4585. from the machine description.
  4586. @cindex @code{cbranch@var{mode}4} instruction pattern
  4587. @item @samp{cbranch@var{mode}4}
  4588. Conditional branch instruction combined with a compare instruction.
  4589. Operand 0 is a comparison operator. Operand 1 and operand 2 are the
  4590. first and second operands of the comparison, respectively. Operand 3
  4591. is a @code{label_ref} that refers to the label to jump to.
  4592. @cindex @code{jump} instruction pattern
  4593. @item @samp{jump}
  4594. A jump inside a function; an unconditional branch. Operand 0 is the
  4595. @code{label_ref} of the label to jump to. This pattern name is mandatory
  4596. on all machines.
  4597. @cindex @code{call} instruction pattern
  4598. @item @samp{call}
  4599. Subroutine call instruction returning no value. Operand 0 is the
  4600. function to call; operand 1 is the number of bytes of arguments pushed
  4601. as a @code{const_int}; operand 2 is the number of registers used as
  4602. operands.
  4603. On most machines, operand 2 is not actually stored into the RTL
  4604. pattern. It is supplied for the sake of some RISC machines which need
  4605. to put this information into the assembler code; they can put it in
  4606. the RTL instead of operand 1.
  4607. Operand 0 should be a @code{mem} RTX whose address is the address of the
  4608. function. Note, however, that this address can be a @code{symbol_ref}
  4609. expression even if it would not be a legitimate memory address on the
  4610. target machine. If it is also not a valid argument for a call
  4611. instruction, the pattern for this operation should be a
  4612. @code{define_expand} (@pxref{Expander Definitions}) that places the
  4613. address into a register and uses that register in the call instruction.
  4614. @cindex @code{call_value} instruction pattern
  4615. @item @samp{call_value}
  4616. Subroutine call instruction returning a value. Operand 0 is the hard
  4617. register in which the value is returned. There are three more
  4618. operands, the same as the three operands of the @samp{call}
  4619. instruction (but with numbers increased by one).
  4620. Subroutines that return @code{BLKmode} objects use the @samp{call}
  4621. insn.
  4622. @cindex @code{call_pop} instruction pattern
  4623. @cindex @code{call_value_pop} instruction pattern
  4624. @item @samp{call_pop}, @samp{call_value_pop}
  4625. Similar to @samp{call} and @samp{call_value}, except used if defined and
  4626. if @code{RETURN_POPS_ARGS} is nonzero. They should emit a @code{parallel}
  4627. that contains both the function call and a @code{set} to indicate the
  4628. adjustment made to the frame pointer.
  4629. For machines where @code{RETURN_POPS_ARGS} can be nonzero, the use of these
  4630. patterns increases the number of functions for which the frame pointer
  4631. can be eliminated, if desired.
  4632. @cindex @code{untyped_call} instruction pattern
  4633. @item @samp{untyped_call}
  4634. Subroutine call instruction returning a value of any type. Operand 0 is
  4635. the function to call; operand 1 is a memory location where the result of
  4636. calling the function is to be stored; operand 2 is a @code{parallel}
  4637. expression where each element is a @code{set} expression that indicates
  4638. the saving of a function return value into the result block.
  4639. This instruction pattern should be defined to support
  4640. @code{__builtin_apply} on machines where special instructions are needed
  4641. to call a subroutine with arbitrary arguments or to save the value
  4642. returned. This instruction pattern is required on machines that have
  4643. multiple registers that can hold a return value
  4644. (i.e.@: @code{FUNCTION_VALUE_REGNO_P} is true for more than one register).
  4645. @cindex @code{return} instruction pattern
  4646. @item @samp{return}
  4647. Subroutine return instruction. This instruction pattern name should be
  4648. defined only if a single instruction can do all the work of returning
  4649. from a function.
  4650. Like the @samp{mov@var{m}} patterns, this pattern is also used after the
  4651. RTL generation phase. In this case it is to support machines where
  4652. multiple instructions are usually needed to return from a function, but
  4653. some class of functions only requires one instruction to implement a
  4654. return. Normally, the applicable functions are those which do not need
  4655. to save any registers or allocate stack space.
  4656. It is valid for this pattern to expand to an instruction using
  4657. @code{simple_return} if no epilogue is required.
  4658. @cindex @code{simple_return} instruction pattern
  4659. @item @samp{simple_return}
  4660. Subroutine return instruction. This instruction pattern name should be
  4661. defined only if a single instruction can do all the work of returning
  4662. from a function on a path where no epilogue is required. This pattern
  4663. is very similar to the @code{return} instruction pattern, but it is emitted
  4664. only by the shrink-wrapping optimization on paths where the function
  4665. prologue has not been executed, and a function return should occur without
  4666. any of the effects of the epilogue. Additional uses may be introduced on
  4667. paths where both the prologue and the epilogue have executed.
  4668. @findex reload_completed
  4669. @findex leaf_function_p
  4670. For such machines, the condition specified in this pattern should only
  4671. be true when @code{reload_completed} is nonzero and the function's
  4672. epilogue would only be a single instruction. For machines with register
  4673. windows, the routine @code{leaf_function_p} may be used to determine if
  4674. a register window push is required.
  4675. Machines that have conditional return instructions should define patterns
  4676. such as
  4677. @smallexample
  4678. (define_insn ""
  4679. [(set (pc)
  4680. (if_then_else (match_operator
  4681. 0 "comparison_operator"
  4682. [(cc0) (const_int 0)])
  4683. (return)
  4684. (pc)))]
  4685. "@var{condition}"
  4686. "@dots{}")
  4687. @end smallexample
  4688. where @var{condition} would normally be the same condition specified on the
  4689. named @samp{return} pattern.
  4690. @cindex @code{untyped_return} instruction pattern
  4691. @item @samp{untyped_return}
  4692. Untyped subroutine return instruction. This instruction pattern should
  4693. be defined to support @code{__builtin_return} on machines where special
  4694. instructions are needed to return a value of any type.
  4695. Operand 0 is a memory location where the result of calling a function
  4696. with @code{__builtin_apply} is stored; operand 1 is a @code{parallel}
  4697. expression where each element is a @code{set} expression that indicates
  4698. the restoring of a function return value from the result block.
  4699. @cindex @code{nop} instruction pattern
  4700. @item @samp{nop}
  4701. No-op instruction. This instruction pattern name should always be defined
  4702. to output a no-op in assembler code. @code{(const_int 0)} will do as an
  4703. RTL pattern.
  4704. @cindex @code{indirect_jump} instruction pattern
  4705. @item @samp{indirect_jump}
  4706. An instruction to jump to an address which is operand zero.
  4707. This pattern name is mandatory on all machines.
  4708. @cindex @code{casesi} instruction pattern
  4709. @item @samp{casesi}
  4710. Instruction to jump through a dispatch table, including bounds checking.
  4711. This instruction takes five operands:
  4712. @enumerate
  4713. @item
  4714. The index to dispatch on, which has mode @code{SImode}.
  4715. @item
  4716. The lower bound for indices in the table, an integer constant.
  4717. @item
  4718. The total range of indices in the table---the largest index
  4719. minus the smallest one (both inclusive).
  4720. @item
  4721. A label that precedes the table itself.
  4722. @item
  4723. A label to jump to if the index has a value outside the bounds.
  4724. @end enumerate
  4725. The table is an @code{addr_vec} or @code{addr_diff_vec} inside of a
  4726. @code{jump_table_data}. The number of elements in the table is one plus the
  4727. difference between the upper bound and the lower bound.
  4728. @cindex @code{tablejump} instruction pattern
  4729. @item @samp{tablejump}
  4730. Instruction to jump to a variable address. This is a low-level
  4731. capability which can be used to implement a dispatch table when there
  4732. is no @samp{casesi} pattern.
  4733. This pattern requires two operands: the address or offset, and a label
  4734. which should immediately precede the jump table. If the macro
  4735. @code{CASE_VECTOR_PC_RELATIVE} evaluates to a nonzero value then the first
  4736. operand is an offset which counts from the address of the table; otherwise,
  4737. it is an absolute address to jump to. In either case, the first operand has
  4738. mode @code{Pmode}.
  4739. The @samp{tablejump} insn is always the last insn before the jump
  4740. table it uses. Its assembler code normally has no need to use the
  4741. second operand, but you should incorporate it in the RTL pattern so
  4742. that the jump optimizer will not delete the table as unreachable code.
  4743. @cindex @code{decrement_and_branch_until_zero} instruction pattern
  4744. @item @samp{decrement_and_branch_until_zero}
  4745. Conditional branch instruction that decrements a register and
  4746. jumps if the register is nonzero. Operand 0 is the register to
  4747. decrement and test; operand 1 is the label to jump to if the
  4748. register is nonzero. @xref{Looping Patterns}.
  4749. This optional instruction pattern is only used by the combiner,
  4750. typically for loops reversed by the loop optimizer when strength
  4751. reduction is enabled.
  4752. @cindex @code{doloop_end} instruction pattern
  4753. @item @samp{doloop_end}
  4754. Conditional branch instruction that decrements a register and
  4755. jumps if the register is nonzero. Operand 0 is the register to
  4756. decrement and test; operand 1 is the label to jump to if the
  4757. register is nonzero.
  4758. @xref{Looping Patterns}.
  4759. This optional instruction pattern should be defined for machines with
  4760. low-overhead looping instructions as the loop optimizer will try to
  4761. modify suitable loops to utilize it. The target hook
  4762. @code{TARGET_CAN_USE_DOLOOP_P} controls the conditions under which
  4763. low-overhead loops can be used.
  4764. @cindex @code{doloop_begin} instruction pattern
  4765. @item @samp{doloop_begin}
  4766. Companion instruction to @code{doloop_end} required for machines that
  4767. need to perform some initialization, such as loading a special counter
  4768. register. Operand 1 is the associated @code{doloop_end} pattern and
  4769. operand 0 is the register that it decrements.
  4770. If initialization insns do not always need to be emitted, use a
  4771. @code{define_expand} (@pxref{Expander Definitions}) and make it fail.
  4772. @cindex @code{canonicalize_funcptr_for_compare} instruction pattern
  4773. @item @samp{canonicalize_funcptr_for_compare}
  4774. Canonicalize the function pointer in operand 1 and store the result
  4775. into operand 0.
  4776. Operand 0 is always a @code{reg} and has mode @code{Pmode}; operand 1
  4777. may be a @code{reg}, @code{mem}, @code{symbol_ref}, @code{const_int}, etc
  4778. and also has mode @code{Pmode}.
  4779. Canonicalization of a function pointer usually involves computing
  4780. the address of the function which would be called if the function
  4781. pointer were used in an indirect call.
  4782. Only define this pattern if function pointers on the target machine
  4783. can have different values but still call the same function when
  4784. used in an indirect call.
  4785. @cindex @code{save_stack_block} instruction pattern
  4786. @cindex @code{save_stack_function} instruction pattern
  4787. @cindex @code{save_stack_nonlocal} instruction pattern
  4788. @cindex @code{restore_stack_block} instruction pattern
  4789. @cindex @code{restore_stack_function} instruction pattern
  4790. @cindex @code{restore_stack_nonlocal} instruction pattern
  4791. @item @samp{save_stack_block}
  4792. @itemx @samp{save_stack_function}
  4793. @itemx @samp{save_stack_nonlocal}
  4794. @itemx @samp{restore_stack_block}
  4795. @itemx @samp{restore_stack_function}
  4796. @itemx @samp{restore_stack_nonlocal}
  4797. Most machines save and restore the stack pointer by copying it to or
  4798. from an object of mode @code{Pmode}. Do not define these patterns on
  4799. such machines.
  4800. Some machines require special handling for stack pointer saves and
  4801. restores. On those machines, define the patterns corresponding to the
  4802. non-standard cases by using a @code{define_expand} (@pxref{Expander
  4803. Definitions}) that produces the required insns. The three types of
  4804. saves and restores are:
  4805. @enumerate
  4806. @item
  4807. @samp{save_stack_block} saves the stack pointer at the start of a block
  4808. that allocates a variable-sized object, and @samp{restore_stack_block}
  4809. restores the stack pointer when the block is exited.
  4810. @item
  4811. @samp{save_stack_function} and @samp{restore_stack_function} do a
  4812. similar job for the outermost block of a function and are used when the
  4813. function allocates variable-sized objects or calls @code{alloca}. Only
  4814. the epilogue uses the restored stack pointer, allowing a simpler save or
  4815. restore sequence on some machines.
  4816. @item
  4817. @samp{save_stack_nonlocal} is used in functions that contain labels
  4818. branched to by nested functions. It saves the stack pointer in such a
  4819. way that the inner function can use @samp{restore_stack_nonlocal} to
  4820. restore the stack pointer. The compiler generates code to restore the
  4821. frame and argument pointer registers, but some machines require saving
  4822. and restoring additional data such as register window information or
  4823. stack backchains. Place insns in these patterns to save and restore any
  4824. such required data.
  4825. @end enumerate
  4826. When saving the stack pointer, operand 0 is the save area and operand 1
  4827. is the stack pointer. The mode used to allocate the save area defaults
  4828. to @code{Pmode} but you can override that choice by defining the
  4829. @code{STACK_SAVEAREA_MODE} macro (@pxref{Storage Layout}). You must
  4830. specify an integral mode, or @code{VOIDmode} if no save area is needed
  4831. for a particular type of save (either because no save is needed or
  4832. because a machine-specific save area can be used). Operand 0 is the
  4833. stack pointer and operand 1 is the save area for restore operations. If
  4834. @samp{save_stack_block} is defined, operand 0 must not be
  4835. @code{VOIDmode} since these saves can be arbitrarily nested.
  4836. A save area is a @code{mem} that is at a constant offset from
  4837. @code{virtual_stack_vars_rtx} when the stack pointer is saved for use by
  4838. nonlocal gotos and a @code{reg} in the other two cases.
  4839. @cindex @code{allocate_stack} instruction pattern
  4840. @item @samp{allocate_stack}
  4841. Subtract (or add if @code{STACK_GROWS_DOWNWARD} is undefined) operand 1 from
  4842. the stack pointer to create space for dynamically allocated data.
  4843. Store the resultant pointer to this space into operand 0. If you
  4844. are allocating space from the main stack, do this by emitting a
  4845. move insn to copy @code{virtual_stack_dynamic_rtx} to operand 0.
  4846. If you are allocating the space elsewhere, generate code to copy the
  4847. location of the space to operand 0. In the latter case, you must
  4848. ensure this space gets freed when the corresponding space on the main
  4849. stack is free.
  4850. Do not define this pattern if all that must be done is the subtraction.
  4851. Some machines require other operations such as stack probes or
  4852. maintaining the back chain. Define this pattern to emit those
  4853. operations in addition to updating the stack pointer.
  4854. @cindex @code{check_stack} instruction pattern
  4855. @item @samp{check_stack}
  4856. If stack checking (@pxref{Stack Checking}) cannot be done on your system by
  4857. probing the stack, define this pattern to perform the needed check and signal
  4858. an error if the stack has overflowed. The single operand is the address in
  4859. the stack farthest from the current stack pointer that you need to validate.
  4860. Normally, on platforms where this pattern is needed, you would obtain the
  4861. stack limit from a global or thread-specific variable or register.
  4862. @cindex @code{probe_stack_address} instruction pattern
  4863. @item @samp{probe_stack_address}
  4864. If stack checking (@pxref{Stack Checking}) can be done on your system by
  4865. probing the stack but without the need to actually access it, define this
  4866. pattern and signal an error if the stack has overflowed. The single operand
  4867. is the memory address in the stack that needs to be probed.
  4868. @cindex @code{probe_stack} instruction pattern
  4869. @item @samp{probe_stack}
  4870. If stack checking (@pxref{Stack Checking}) can be done on your system by
  4871. probing the stack but doing it with a ``store zero'' instruction is not valid
  4872. or optimal, define this pattern to do the probing differently and signal an
  4873. error if the stack has overflowed. The single operand is the memory reference
  4874. in the stack that needs to be probed.
  4875. @cindex @code{nonlocal_goto} instruction pattern
  4876. @item @samp{nonlocal_goto}
  4877. Emit code to generate a non-local goto, e.g., a jump from one function
  4878. to a label in an outer function. This pattern has four arguments,
  4879. each representing a value to be used in the jump. The first
  4880. argument is to be loaded into the frame pointer, the second is
  4881. the address to branch to (code to dispatch to the actual label),
  4882. the third is the address of a location where the stack is saved,
  4883. and the last is the address of the label, to be placed in the
  4884. location for the incoming static chain.
  4885. On most machines you need not define this pattern, since GCC will
  4886. already generate the correct code, which is to load the frame pointer
  4887. and static chain, restore the stack (using the
  4888. @samp{restore_stack_nonlocal} pattern, if defined), and jump indirectly
  4889. to the dispatcher. You need only define this pattern if this code will
  4890. not work on your machine.
  4891. @cindex @code{nonlocal_goto_receiver} instruction pattern
  4892. @item @samp{nonlocal_goto_receiver}
  4893. This pattern, if defined, contains code needed at the target of a
  4894. nonlocal goto after the code already generated by GCC@. You will not
  4895. normally need to define this pattern. A typical reason why you might
  4896. need this pattern is if some value, such as a pointer to a global table,
  4897. must be restored when the frame pointer is restored. Note that a nonlocal
  4898. goto only occurs within a unit-of-translation, so a global table pointer
  4899. that is shared by all functions of a given module need not be restored.
  4900. There are no arguments.
  4901. @cindex @code{exception_receiver} instruction pattern
  4902. @item @samp{exception_receiver}
  4903. This pattern, if defined, contains code needed at the site of an
  4904. exception handler that isn't needed at the site of a nonlocal goto. You
  4905. will not normally need to define this pattern. A typical reason why you
  4906. might need this pattern is if some value, such as a pointer to a global
  4907. table, must be restored after control flow is branched to the handler of
  4908. an exception. There are no arguments.
  4909. @cindex @code{builtin_setjmp_setup} instruction pattern
  4910. @item @samp{builtin_setjmp_setup}
  4911. This pattern, if defined, contains additional code needed to initialize
  4912. the @code{jmp_buf}. You will not normally need to define this pattern.
  4913. A typical reason why you might need this pattern is if some value, such
  4914. as a pointer to a global table, must be restored. Though it is
  4915. preferred that the pointer value be recalculated if possible (given the
  4916. address of a label for instance). The single argument is a pointer to
  4917. the @code{jmp_buf}. Note that the buffer is five words long and that
  4918. the first three are normally used by the generic mechanism.
  4919. @cindex @code{builtin_setjmp_receiver} instruction pattern
  4920. @item @samp{builtin_setjmp_receiver}
  4921. This pattern, if defined, contains code needed at the site of a
  4922. built-in setjmp that isn't needed at the site of a nonlocal goto. You
  4923. will not normally need to define this pattern. A typical reason why you
  4924. might need this pattern is if some value, such as a pointer to a global
  4925. table, must be restored. It takes one argument, which is the label
  4926. to which builtin_longjmp transferred control; this pattern may be emitted
  4927. at a small offset from that label.
  4928. @cindex @code{builtin_longjmp} instruction pattern
  4929. @item @samp{builtin_longjmp}
  4930. This pattern, if defined, performs the entire action of the longjmp.
  4931. You will not normally need to define this pattern unless you also define
  4932. @code{builtin_setjmp_setup}. The single argument is a pointer to the
  4933. @code{jmp_buf}.
  4934. @cindex @code{eh_return} instruction pattern
  4935. @item @samp{eh_return}
  4936. This pattern, if defined, affects the way @code{__builtin_eh_return},
  4937. and thence the call frame exception handling library routines, are
  4938. built. It is intended to handle non-trivial actions needed along
  4939. the abnormal return path.
  4940. The address of the exception handler to which the function should return
  4941. is passed as operand to this pattern. It will normally need to copied by
  4942. the pattern to some special register or memory location.
  4943. If the pattern needs to determine the location of the target call
  4944. frame in order to do so, it may use @code{EH_RETURN_STACKADJ_RTX},
  4945. if defined; it will have already been assigned.
  4946. If this pattern is not defined, the default action will be to simply
  4947. copy the return address to @code{EH_RETURN_HANDLER_RTX}. Either
  4948. that macro or this pattern needs to be defined if call frame exception
  4949. handling is to be used.
  4950. @cindex @code{prologue} instruction pattern
  4951. @anchor{prologue instruction pattern}
  4952. @item @samp{prologue}
  4953. This pattern, if defined, emits RTL for entry to a function. The function
  4954. entry is responsible for setting up the stack frame, initializing the frame
  4955. pointer register, saving callee saved registers, etc.
  4956. Using a prologue pattern is generally preferred over defining
  4957. @code{TARGET_ASM_FUNCTION_PROLOGUE} to emit assembly code for the prologue.
  4958. The @code{prologue} pattern is particularly useful for targets which perform
  4959. instruction scheduling.
  4960. @cindex @code{window_save} instruction pattern
  4961. @anchor{window_save instruction pattern}
  4962. @item @samp{window_save}
  4963. This pattern, if defined, emits RTL for a register window save. It should
  4964. be defined if the target machine has register windows but the window events
  4965. are decoupled from calls to subroutines. The canonical example is the SPARC
  4966. architecture.
  4967. @cindex @code{epilogue} instruction pattern
  4968. @anchor{epilogue instruction pattern}
  4969. @item @samp{epilogue}
  4970. This pattern emits RTL for exit from a function. The function
  4971. exit is responsible for deallocating the stack frame, restoring callee saved
  4972. registers and emitting the return instruction.
  4973. Using an epilogue pattern is generally preferred over defining
  4974. @code{TARGET_ASM_FUNCTION_EPILOGUE} to emit assembly code for the epilogue.
  4975. The @code{epilogue} pattern is particularly useful for targets which perform
  4976. instruction scheduling or which have delay slots for their return instruction.
  4977. @cindex @code{sibcall_epilogue} instruction pattern
  4978. @item @samp{sibcall_epilogue}
  4979. This pattern, if defined, emits RTL for exit from a function without the final
  4980. branch back to the calling function. This pattern will be emitted before any
  4981. sibling call (aka tail call) sites.
  4982. The @code{sibcall_epilogue} pattern must not clobber any arguments used for
  4983. parameter passing or any stack slots for arguments passed to the current
  4984. function.
  4985. @cindex @code{trap} instruction pattern
  4986. @item @samp{trap}
  4987. This pattern, if defined, signals an error, typically by causing some
  4988. kind of signal to be raised. Among other places, it is used by the Java
  4989. front end to signal `invalid array index' exceptions.
  4990. @cindex @code{ctrap@var{MM}4} instruction pattern
  4991. @item @samp{ctrap@var{MM}4}
  4992. Conditional trap instruction. Operand 0 is a piece of RTL which
  4993. performs a comparison, and operands 1 and 2 are the arms of the
  4994. comparison. Operand 3 is the trap code, an integer.
  4995. A typical @code{ctrap} pattern looks like
  4996. @smallexample
  4997. (define_insn "ctrapsi4"
  4998. [(trap_if (match_operator 0 "trap_operator"
  4999. [(match_operand 1 "register_operand")
  5000. (match_operand 2 "immediate_operand")])
  5001. (match_operand 3 "const_int_operand" "i"))]
  5002. ""
  5003. "@dots{}")
  5004. @end smallexample
  5005. @cindex @code{prefetch} instruction pattern
  5006. @item @samp{prefetch}
  5007. This pattern, if defined, emits code for a non-faulting data prefetch
  5008. instruction. Operand 0 is the address of the memory to prefetch. Operand 1
  5009. is a constant 1 if the prefetch is preparing for a write to the memory
  5010. address, or a constant 0 otherwise. Operand 2 is the expected degree of
  5011. temporal locality of the data and is a value between 0 and 3, inclusive; 0
  5012. means that the data has no temporal locality, so it need not be left in the
  5013. cache after the access; 3 means that the data has a high degree of temporal
  5014. locality and should be left in all levels of cache possible; 1 and 2 mean,
  5015. respectively, a low or moderate degree of temporal locality.
  5016. Targets that do not support write prefetches or locality hints can ignore
  5017. the values of operands 1 and 2.
  5018. @cindex @code{blockage} instruction pattern
  5019. @item @samp{blockage}
  5020. This pattern defines a pseudo insn that prevents the instruction
  5021. scheduler and other passes from moving instructions and using register
  5022. equivalences across the boundary defined by the blockage insn.
  5023. This needs to be an UNSPEC_VOLATILE pattern or a volatile ASM.
  5024. @cindex @code{memory_barrier} instruction pattern
  5025. @item @samp{memory_barrier}
  5026. If the target memory model is not fully synchronous, then this pattern
  5027. should be defined to an instruction that orders both loads and stores
  5028. before the instruction with respect to loads and stores after the instruction.
  5029. This pattern has no operands.
  5030. @cindex @code{sync_compare_and_swap@var{mode}} instruction pattern
  5031. @item @samp{sync_compare_and_swap@var{mode}}
  5032. This pattern, if defined, emits code for an atomic compare-and-swap
  5033. operation. Operand 1 is the memory on which the atomic operation is
  5034. performed. Operand 2 is the ``old'' value to be compared against the
  5035. current contents of the memory location. Operand 3 is the ``new'' value
  5036. to store in the memory if the compare succeeds. Operand 0 is the result
  5037. of the operation; it should contain the contents of the memory
  5038. before the operation. If the compare succeeds, this should obviously be
  5039. a copy of operand 2.
  5040. This pattern must show that both operand 0 and operand 1 are modified.
  5041. This pattern must issue any memory barrier instructions such that all
  5042. memory operations before the atomic operation occur before the atomic
  5043. operation and all memory operations after the atomic operation occur
  5044. after the atomic operation.
  5045. For targets where the success or failure of the compare-and-swap
  5046. operation is available via the status flags, it is possible to
  5047. avoid a separate compare operation and issue the subsequent
  5048. branch or store-flag operation immediately after the compare-and-swap.
  5049. To this end, GCC will look for a @code{MODE_CC} set in the
  5050. output of @code{sync_compare_and_swap@var{mode}}; if the machine
  5051. description includes such a set, the target should also define special
  5052. @code{cbranchcc4} and/or @code{cstorecc4} instructions. GCC will then
  5053. be able to take the destination of the @code{MODE_CC} set and pass it
  5054. to the @code{cbranchcc4} or @code{cstorecc4} pattern as the first
  5055. operand of the comparison (the second will be @code{(const_int 0)}).
  5056. For targets where the operating system may provide support for this
  5057. operation via library calls, the @code{sync_compare_and_swap_optab}
  5058. may be initialized to a function with the same interface as the
  5059. @code{__sync_val_compare_and_swap_@var{n}} built-in. If the entire
  5060. set of @var{__sync} builtins are supported via library calls, the
  5061. target can initialize all of the optabs at once with
  5062. @code{init_sync_libfuncs}.
  5063. For the purposes of C++11 @code{std::atomic::is_lock_free}, it is
  5064. assumed that these library calls do @emph{not} use any kind of
  5065. interruptable locking.
  5066. @cindex @code{sync_add@var{mode}} instruction pattern
  5067. @cindex @code{sync_sub@var{mode}} instruction pattern
  5068. @cindex @code{sync_ior@var{mode}} instruction pattern
  5069. @cindex @code{sync_and@var{mode}} instruction pattern
  5070. @cindex @code{sync_xor@var{mode}} instruction pattern
  5071. @cindex @code{sync_nand@var{mode}} instruction pattern
  5072. @item @samp{sync_add@var{mode}}, @samp{sync_sub@var{mode}}
  5073. @itemx @samp{sync_ior@var{mode}}, @samp{sync_and@var{mode}}
  5074. @itemx @samp{sync_xor@var{mode}}, @samp{sync_nand@var{mode}}
  5075. These patterns emit code for an atomic operation on memory.
  5076. Operand 0 is the memory on which the atomic operation is performed.
  5077. Operand 1 is the second operand to the binary operator.
  5078. This pattern must issue any memory barrier instructions such that all
  5079. memory operations before the atomic operation occur before the atomic
  5080. operation and all memory operations after the atomic operation occur
  5081. after the atomic operation.
  5082. If these patterns are not defined, the operation will be constructed
  5083. from a compare-and-swap operation, if defined.
  5084. @cindex @code{sync_old_add@var{mode}} instruction pattern
  5085. @cindex @code{sync_old_sub@var{mode}} instruction pattern
  5086. @cindex @code{sync_old_ior@var{mode}} instruction pattern
  5087. @cindex @code{sync_old_and@var{mode}} instruction pattern
  5088. @cindex @code{sync_old_xor@var{mode}} instruction pattern
  5089. @cindex @code{sync_old_nand@var{mode}} instruction pattern
  5090. @item @samp{sync_old_add@var{mode}}, @samp{sync_old_sub@var{mode}}
  5091. @itemx @samp{sync_old_ior@var{mode}}, @samp{sync_old_and@var{mode}}
  5092. @itemx @samp{sync_old_xor@var{mode}}, @samp{sync_old_nand@var{mode}}
  5093. These patterns emit code for an atomic operation on memory,
  5094. and return the value that the memory contained before the operation.
  5095. Operand 0 is the result value, operand 1 is the memory on which the
  5096. atomic operation is performed, and operand 2 is the second operand
  5097. to the binary operator.
  5098. This pattern must issue any memory barrier instructions such that all
  5099. memory operations before the atomic operation occur before the atomic
  5100. operation and all memory operations after the atomic operation occur
  5101. after the atomic operation.
  5102. If these patterns are not defined, the operation will be constructed
  5103. from a compare-and-swap operation, if defined.
  5104. @cindex @code{sync_new_add@var{mode}} instruction pattern
  5105. @cindex @code{sync_new_sub@var{mode}} instruction pattern
  5106. @cindex @code{sync_new_ior@var{mode}} instruction pattern
  5107. @cindex @code{sync_new_and@var{mode}} instruction pattern
  5108. @cindex @code{sync_new_xor@var{mode}} instruction pattern
  5109. @cindex @code{sync_new_nand@var{mode}} instruction pattern
  5110. @item @samp{sync_new_add@var{mode}}, @samp{sync_new_sub@var{mode}}
  5111. @itemx @samp{sync_new_ior@var{mode}}, @samp{sync_new_and@var{mode}}
  5112. @itemx @samp{sync_new_xor@var{mode}}, @samp{sync_new_nand@var{mode}}
  5113. These patterns are like their @code{sync_old_@var{op}} counterparts,
  5114. except that they return the value that exists in the memory location
  5115. after the operation, rather than before the operation.
  5116. @cindex @code{sync_lock_test_and_set@var{mode}} instruction pattern
  5117. @item @samp{sync_lock_test_and_set@var{mode}}
  5118. This pattern takes two forms, based on the capabilities of the target.
  5119. In either case, operand 0 is the result of the operand, operand 1 is
  5120. the memory on which the atomic operation is performed, and operand 2
  5121. is the value to set in the lock.
  5122. In the ideal case, this operation is an atomic exchange operation, in
  5123. which the previous value in memory operand is copied into the result
  5124. operand, and the value operand is stored in the memory operand.
  5125. For less capable targets, any value operand that is not the constant 1
  5126. should be rejected with @code{FAIL}. In this case the target may use
  5127. an atomic test-and-set bit operation. The result operand should contain
  5128. 1 if the bit was previously set and 0 if the bit was previously clear.
  5129. The true contents of the memory operand are implementation defined.
  5130. This pattern must issue any memory barrier instructions such that the
  5131. pattern as a whole acts as an acquire barrier, that is all memory
  5132. operations after the pattern do not occur until the lock is acquired.
  5133. If this pattern is not defined, the operation will be constructed from
  5134. a compare-and-swap operation, if defined.
  5135. @cindex @code{sync_lock_release@var{mode}} instruction pattern
  5136. @item @samp{sync_lock_release@var{mode}}
  5137. This pattern, if defined, releases a lock set by
  5138. @code{sync_lock_test_and_set@var{mode}}. Operand 0 is the memory
  5139. that contains the lock; operand 1 is the value to store in the lock.
  5140. If the target doesn't implement full semantics for
  5141. @code{sync_lock_test_and_set@var{mode}}, any value operand which is not
  5142. the constant 0 should be rejected with @code{FAIL}, and the true contents
  5143. of the memory operand are implementation defined.
  5144. This pattern must issue any memory barrier instructions such that the
  5145. pattern as a whole acts as a release barrier, that is the lock is
  5146. released only after all previous memory operations have completed.
  5147. If this pattern is not defined, then a @code{memory_barrier} pattern
  5148. will be emitted, followed by a store of the value to the memory operand.
  5149. @cindex @code{atomic_compare_and_swap@var{mode}} instruction pattern
  5150. @item @samp{atomic_compare_and_swap@var{mode}}
  5151. This pattern, if defined, emits code for an atomic compare-and-swap
  5152. operation with memory model semantics. Operand 2 is the memory on which
  5153. the atomic operation is performed. Operand 0 is an output operand which
  5154. is set to true or false based on whether the operation succeeded. Operand
  5155. 1 is an output operand which is set to the contents of the memory before
  5156. the operation was attempted. Operand 3 is the value that is expected to
  5157. be in memory. Operand 4 is the value to put in memory if the expected
  5158. value is found there. Operand 5 is set to 1 if this compare and swap is to
  5159. be treated as a weak operation. Operand 6 is the memory model to be used
  5160. if the operation is a success. Operand 7 is the memory model to be used
  5161. if the operation fails.
  5162. If memory referred to in operand 2 contains the value in operand 3, then
  5163. operand 4 is stored in memory pointed to by operand 2 and fencing based on
  5164. the memory model in operand 6 is issued.
  5165. If memory referred to in operand 2 does not contain the value in operand 3,
  5166. then fencing based on the memory model in operand 7 is issued.
  5167. If a target does not support weak compare-and-swap operations, or the port
  5168. elects not to implement weak operations, the argument in operand 5 can be
  5169. ignored. Note a strong implementation must be provided.
  5170. If this pattern is not provided, the @code{__atomic_compare_exchange}
  5171. built-in functions will utilize the legacy @code{sync_compare_and_swap}
  5172. pattern with an @code{__ATOMIC_SEQ_CST} memory model.
  5173. @cindex @code{atomic_load@var{mode}} instruction pattern
  5174. @item @samp{atomic_load@var{mode}}
  5175. This pattern implements an atomic load operation with memory model
  5176. semantics. Operand 1 is the memory address being loaded from. Operand 0
  5177. is the result of the load. Operand 2 is the memory model to be used for
  5178. the load operation.
  5179. If not present, the @code{__atomic_load} built-in function will either
  5180. resort to a normal load with memory barriers, or a compare-and-swap
  5181. operation if a normal load would not be atomic.
  5182. @cindex @code{atomic_store@var{mode}} instruction pattern
  5183. @item @samp{atomic_store@var{mode}}
  5184. This pattern implements an atomic store operation with memory model
  5185. semantics. Operand 0 is the memory address being stored to. Operand 1
  5186. is the value to be written. Operand 2 is the memory model to be used for
  5187. the operation.
  5188. If not present, the @code{__atomic_store} built-in function will attempt to
  5189. perform a normal store and surround it with any required memory fences. If
  5190. the store would not be atomic, then an @code{__atomic_exchange} is
  5191. attempted with the result being ignored.
  5192. @cindex @code{atomic_exchange@var{mode}} instruction pattern
  5193. @item @samp{atomic_exchange@var{mode}}
  5194. This pattern implements an atomic exchange operation with memory model
  5195. semantics. Operand 1 is the memory location the operation is performed on.
  5196. Operand 0 is an output operand which is set to the original value contained
  5197. in the memory pointed to by operand 1. Operand 2 is the value to be
  5198. stored. Operand 3 is the memory model to be used.
  5199. If this pattern is not present, the built-in function
  5200. @code{__atomic_exchange} will attempt to preform the operation with a
  5201. compare and swap loop.
  5202. @cindex @code{atomic_add@var{mode}} instruction pattern
  5203. @cindex @code{atomic_sub@var{mode}} instruction pattern
  5204. @cindex @code{atomic_or@var{mode}} instruction pattern
  5205. @cindex @code{atomic_and@var{mode}} instruction pattern
  5206. @cindex @code{atomic_xor@var{mode}} instruction pattern
  5207. @cindex @code{atomic_nand@var{mode}} instruction pattern
  5208. @item @samp{atomic_add@var{mode}}, @samp{atomic_sub@var{mode}}
  5209. @itemx @samp{atomic_or@var{mode}}, @samp{atomic_and@var{mode}}
  5210. @itemx @samp{atomic_xor@var{mode}}, @samp{atomic_nand@var{mode}}
  5211. These patterns emit code for an atomic operation on memory with memory
  5212. model semantics. Operand 0 is the memory on which the atomic operation is
  5213. performed. Operand 1 is the second operand to the binary operator.
  5214. Operand 2 is the memory model to be used by the operation.
  5215. If these patterns are not defined, attempts will be made to use legacy
  5216. @code{sync} patterns, or equivalent patterns which return a result. If
  5217. none of these are available a compare-and-swap loop will be used.
  5218. @cindex @code{atomic_fetch_add@var{mode}} instruction pattern
  5219. @cindex @code{atomic_fetch_sub@var{mode}} instruction pattern
  5220. @cindex @code{atomic_fetch_or@var{mode}} instruction pattern
  5221. @cindex @code{atomic_fetch_and@var{mode}} instruction pattern
  5222. @cindex @code{atomic_fetch_xor@var{mode}} instruction pattern
  5223. @cindex @code{atomic_fetch_nand@var{mode}} instruction pattern
  5224. @item @samp{atomic_fetch_add@var{mode}}, @samp{atomic_fetch_sub@var{mode}}
  5225. @itemx @samp{atomic_fetch_or@var{mode}}, @samp{atomic_fetch_and@var{mode}}
  5226. @itemx @samp{atomic_fetch_xor@var{mode}}, @samp{atomic_fetch_nand@var{mode}}
  5227. These patterns emit code for an atomic operation on memory with memory
  5228. model semantics, and return the original value. Operand 0 is an output
  5229. operand which contains the value of the memory location before the
  5230. operation was performed. Operand 1 is the memory on which the atomic
  5231. operation is performed. Operand 2 is the second operand to the binary
  5232. operator. Operand 3 is the memory model to be used by the operation.
  5233. If these patterns are not defined, attempts will be made to use legacy
  5234. @code{sync} patterns. If none of these are available a compare-and-swap
  5235. loop will be used.
  5236. @cindex @code{atomic_add_fetch@var{mode}} instruction pattern
  5237. @cindex @code{atomic_sub_fetch@var{mode}} instruction pattern
  5238. @cindex @code{atomic_or_fetch@var{mode}} instruction pattern
  5239. @cindex @code{atomic_and_fetch@var{mode}} instruction pattern
  5240. @cindex @code{atomic_xor_fetch@var{mode}} instruction pattern
  5241. @cindex @code{atomic_nand_fetch@var{mode}} instruction pattern
  5242. @item @samp{atomic_add_fetch@var{mode}}, @samp{atomic_sub_fetch@var{mode}}
  5243. @itemx @samp{atomic_or_fetch@var{mode}}, @samp{atomic_and_fetch@var{mode}}
  5244. @itemx @samp{atomic_xor_fetch@var{mode}}, @samp{atomic_nand_fetch@var{mode}}
  5245. These patterns emit code for an atomic operation on memory with memory
  5246. model semantics and return the result after the operation is performed.
  5247. Operand 0 is an output operand which contains the value after the
  5248. operation. Operand 1 is the memory on which the atomic operation is
  5249. performed. Operand 2 is the second operand to the binary operator.
  5250. Operand 3 is the memory model to be used by the operation.
  5251. If these patterns are not defined, attempts will be made to use legacy
  5252. @code{sync} patterns, or equivalent patterns which return the result before
  5253. the operation followed by the arithmetic operation required to produce the
  5254. result. If none of these are available a compare-and-swap loop will be
  5255. used.
  5256. @cindex @code{atomic_test_and_set} instruction pattern
  5257. @item @samp{atomic_test_and_set}
  5258. This pattern emits code for @code{__builtin_atomic_test_and_set}.
  5259. Operand 0 is an output operand which is set to true if the previous
  5260. previous contents of the byte was "set", and false otherwise. Operand 1
  5261. is the @code{QImode} memory to be modified. Operand 2 is the memory
  5262. model to be used.
  5263. The specific value that defines "set" is implementation defined, and
  5264. is normally based on what is performed by the native atomic test and set
  5265. instruction.
  5266. @cindex @code{mem_thread_fence@var{mode}} instruction pattern
  5267. @item @samp{mem_thread_fence@var{mode}}
  5268. This pattern emits code required to implement a thread fence with
  5269. memory model semantics. Operand 0 is the memory model to be used.
  5270. If this pattern is not specified, all memory models except
  5271. @code{__ATOMIC_RELAXED} will result in issuing a @code{sync_synchronize}
  5272. barrier pattern.
  5273. @cindex @code{mem_signal_fence@var{mode}} instruction pattern
  5274. @item @samp{mem_signal_fence@var{mode}}
  5275. This pattern emits code required to implement a signal fence with
  5276. memory model semantics. Operand 0 is the memory model to be used.
  5277. This pattern should impact the compiler optimizers the same way that
  5278. mem_signal_fence does, but it does not need to issue any barrier
  5279. instructions.
  5280. If this pattern is not specified, all memory models except
  5281. @code{__ATOMIC_RELAXED} will result in issuing a @code{sync_synchronize}
  5282. barrier pattern.
  5283. @cindex @code{get_thread_pointer@var{mode}} instruction pattern
  5284. @cindex @code{set_thread_pointer@var{mode}} instruction pattern
  5285. @item @samp{get_thread_pointer@var{mode}}
  5286. @itemx @samp{set_thread_pointer@var{mode}}
  5287. These patterns emit code that reads/sets the TLS thread pointer. Currently,
  5288. these are only needed if the target needs to support the
  5289. @code{__builtin_thread_pointer} and @code{__builtin_set_thread_pointer}
  5290. builtins.
  5291. The get/set patterns have a single output/input operand respectively,
  5292. with @var{mode} intended to be @code{Pmode}.
  5293. @cindex @code{stack_protect_set} instruction pattern
  5294. @item @samp{stack_protect_set}
  5295. This pattern, if defined, moves a @code{ptr_mode} value from the memory
  5296. in operand 1 to the memory in operand 0 without leaving the value in
  5297. a register afterward. This is to avoid leaking the value some place
  5298. that an attacker might use to rewrite the stack guard slot after
  5299. having clobbered it.
  5300. If this pattern is not defined, then a plain move pattern is generated.
  5301. @cindex @code{stack_protect_test} instruction pattern
  5302. @item @samp{stack_protect_test}
  5303. This pattern, if defined, compares a @code{ptr_mode} value from the
  5304. memory in operand 1 with the memory in operand 0 without leaving the
  5305. value in a register afterward and branches to operand 2 if the values
  5306. were equal.
  5307. If this pattern is not defined, then a plain compare pattern and
  5308. conditional branch pattern is used.
  5309. @cindex @code{clear_cache} instruction pattern
  5310. @item @samp{clear_cache}
  5311. This pattern, if defined, flushes the instruction cache for a region of
  5312. memory. The region is bounded to by the Pmode pointers in operand 0
  5313. inclusive and operand 1 exclusive.
  5314. If this pattern is not defined, a call to the library function
  5315. @code{__clear_cache} is used.
  5316. @end table
  5317. @end ifset
  5318. @c Each of the following nodes are wrapped in separate
  5319. @c "@ifset INTERNALS" to work around memory limits for the default
  5320. @c configuration in older tetex distributions. Known to not work:
  5321. @c tetex-1.0.7, known to work: tetex-2.0.2.
  5322. @ifset INTERNALS
  5323. @node Pattern Ordering
  5324. @section When the Order of Patterns Matters
  5325. @cindex Pattern Ordering
  5326. @cindex Ordering of Patterns
  5327. Sometimes an insn can match more than one instruction pattern. Then the
  5328. pattern that appears first in the machine description is the one used.
  5329. Therefore, more specific patterns (patterns that will match fewer things)
  5330. and faster instructions (those that will produce better code when they
  5331. do match) should usually go first in the description.
  5332. In some cases the effect of ordering the patterns can be used to hide
  5333. a pattern when it is not valid. For example, the 68000 has an
  5334. instruction for converting a fullword to floating point and another
  5335. for converting a byte to floating point. An instruction converting
  5336. an integer to floating point could match either one. We put the
  5337. pattern to convert the fullword first to make sure that one will
  5338. be used rather than the other. (Otherwise a large integer might
  5339. be generated as a single-byte immediate quantity, which would not work.)
  5340. Instead of using this pattern ordering it would be possible to make the
  5341. pattern for convert-a-byte smart enough to deal properly with any
  5342. constant value.
  5343. @end ifset
  5344. @ifset INTERNALS
  5345. @node Dependent Patterns
  5346. @section Interdependence of Patterns
  5347. @cindex Dependent Patterns
  5348. @cindex Interdependence of Patterns
  5349. In some cases machines support instructions identical except for the
  5350. machine mode of one or more operands. For example, there may be
  5351. ``sign-extend halfword'' and ``sign-extend byte'' instructions whose
  5352. patterns are
  5353. @smallexample
  5354. (set (match_operand:SI 0 @dots{})
  5355. (extend:SI (match_operand:HI 1 @dots{})))
  5356. (set (match_operand:SI 0 @dots{})
  5357. (extend:SI (match_operand:QI 1 @dots{})))
  5358. @end smallexample
  5359. @noindent
  5360. Constant integers do not specify a machine mode, so an instruction to
  5361. extend a constant value could match either pattern. The pattern it
  5362. actually will match is the one that appears first in the file. For correct
  5363. results, this must be the one for the widest possible mode (@code{HImode},
  5364. here). If the pattern matches the @code{QImode} instruction, the results
  5365. will be incorrect if the constant value does not actually fit that mode.
  5366. Such instructions to extend constants are rarely generated because they are
  5367. optimized away, but they do occasionally happen in nonoptimized
  5368. compilations.
  5369. If a constraint in a pattern allows a constant, the reload pass may
  5370. replace a register with a constant permitted by the constraint in some
  5371. cases. Similarly for memory references. Because of this substitution,
  5372. you should not provide separate patterns for increment and decrement
  5373. instructions. Instead, they should be generated from the same pattern
  5374. that supports register-register add insns by examining the operands and
  5375. generating the appropriate machine instruction.
  5376. @end ifset
  5377. @ifset INTERNALS
  5378. @node Jump Patterns
  5379. @section Defining Jump Instruction Patterns
  5380. @cindex jump instruction patterns
  5381. @cindex defining jump instruction patterns
  5382. GCC does not assume anything about how the machine realizes jumps.
  5383. The machine description should define a single pattern, usually
  5384. a @code{define_expand}, which expands to all the required insns.
  5385. Usually, this would be a comparison insn to set the condition code
  5386. and a separate branch insn testing the condition code and branching
  5387. or not according to its value. For many machines, however,
  5388. separating compares and branches is limiting, which is why the
  5389. more flexible approach with one @code{define_expand} is used in GCC.
  5390. The machine description becomes clearer for architectures that
  5391. have compare-and-branch instructions but no condition code. It also
  5392. works better when different sets of comparison operators are supported
  5393. by different kinds of conditional branches (e.g. integer vs. floating-point),
  5394. or by conditional branches with respect to conditional stores.
  5395. Two separate insns are always used if the machine description represents
  5396. a condition code register using the legacy RTL expression @code{(cc0)},
  5397. and on most machines that use a separate condition code register
  5398. (@pxref{Condition Code}). For machines that use @code{(cc0)}, in
  5399. fact, the set and use of the condition code must be separate and
  5400. adjacent@footnote{@code{note} insns can separate them, though.}, thus
  5401. allowing flags in @code{cc_status} to be used (@pxref{Condition Code}) and
  5402. so that the comparison and branch insns could be located from each other
  5403. by using the functions @code{prev_cc0_setter} and @code{next_cc0_user}.
  5404. Even in this case having a single entry point for conditional branches
  5405. is advantageous, because it handles equally well the case where a single
  5406. comparison instruction records the results of both signed and unsigned
  5407. comparison of the given operands (with the branch insns coming in distinct
  5408. signed and unsigned flavors) as in the x86 or SPARC, and the case where
  5409. there are distinct signed and unsigned compare instructions and only
  5410. one set of conditional branch instructions as in the PowerPC.
  5411. @end ifset
  5412. @ifset INTERNALS
  5413. @node Looping Patterns
  5414. @section Defining Looping Instruction Patterns
  5415. @cindex looping instruction patterns
  5416. @cindex defining looping instruction patterns
  5417. Some machines have special jump instructions that can be utilized to
  5418. make loops more efficient. A common example is the 68000 @samp{dbra}
  5419. instruction which performs a decrement of a register and a branch if the
  5420. result was greater than zero. Other machines, in particular digital
  5421. signal processors (DSPs), have special block repeat instructions to
  5422. provide low-overhead loop support. For example, the TI TMS320C3x/C4x
  5423. DSPs have a block repeat instruction that loads special registers to
  5424. mark the top and end of a loop and to count the number of loop
  5425. iterations. This avoids the need for fetching and executing a
  5426. @samp{dbra}-like instruction and avoids pipeline stalls associated with
  5427. the jump.
  5428. GCC has three special named patterns to support low overhead looping.
  5429. They are @samp{decrement_and_branch_until_zero}, @samp{doloop_begin},
  5430. and @samp{doloop_end}. The first pattern,
  5431. @samp{decrement_and_branch_until_zero}, is not emitted during RTL
  5432. generation but may be emitted during the instruction combination phase.
  5433. This requires the assistance of the loop optimizer, using information
  5434. collected during strength reduction, to reverse a loop to count down to
  5435. zero. Some targets also require the loop optimizer to add a
  5436. @code{REG_NONNEG} note to indicate that the iteration count is always
  5437. positive. This is needed if the target performs a signed loop
  5438. termination test. For example, the 68000 uses a pattern similar to the
  5439. following for its @code{dbra} instruction:
  5440. @smallexample
  5441. @group
  5442. (define_insn "decrement_and_branch_until_zero"
  5443. [(set (pc)
  5444. (if_then_else
  5445. (ge (plus:SI (match_operand:SI 0 "general_operand" "+d*am")
  5446. (const_int -1))
  5447. (const_int 0))
  5448. (label_ref (match_operand 1 "" ""))
  5449. (pc)))
  5450. (set (match_dup 0)
  5451. (plus:SI (match_dup 0)
  5452. (const_int -1)))]
  5453. "find_reg_note (insn, REG_NONNEG, 0)"
  5454. "@dots{}")
  5455. @end group
  5456. @end smallexample
  5457. Note that since the insn is both a jump insn and has an output, it must
  5458. deal with its own reloads, hence the `m' constraints. Also note that
  5459. since this insn is generated by the instruction combination phase
  5460. combining two sequential insns together into an implicit parallel insn,
  5461. the iteration counter needs to be biased by the same amount as the
  5462. decrement operation, in this case @minus{}1. Note that the following similar
  5463. pattern will not be matched by the combiner.
  5464. @smallexample
  5465. @group
  5466. (define_insn "decrement_and_branch_until_zero"
  5467. [(set (pc)
  5468. (if_then_else
  5469. (ge (match_operand:SI 0 "general_operand" "+d*am")
  5470. (const_int 1))
  5471. (label_ref (match_operand 1 "" ""))
  5472. (pc)))
  5473. (set (match_dup 0)
  5474. (plus:SI (match_dup 0)
  5475. (const_int -1)))]
  5476. "find_reg_note (insn, REG_NONNEG, 0)"
  5477. "@dots{}")
  5478. @end group
  5479. @end smallexample
  5480. The other two special looping patterns, @samp{doloop_begin} and
  5481. @samp{doloop_end}, are emitted by the loop optimizer for certain
  5482. well-behaved loops with a finite number of loop iterations using
  5483. information collected during strength reduction.
  5484. The @samp{doloop_end} pattern describes the actual looping instruction
  5485. (or the implicit looping operation) and the @samp{doloop_begin} pattern
  5486. is an optional companion pattern that can be used for initialization
  5487. needed for some low-overhead looping instructions.
  5488. Note that some machines require the actual looping instruction to be
  5489. emitted at the top of the loop (e.g., the TMS320C3x/C4x DSPs). Emitting
  5490. the true RTL for a looping instruction at the top of the loop can cause
  5491. problems with flow analysis. So instead, a dummy @code{doloop} insn is
  5492. emitted at the end of the loop. The machine dependent reorg pass checks
  5493. for the presence of this @code{doloop} insn and then searches back to
  5494. the top of the loop, where it inserts the true looping insn (provided
  5495. there are no instructions in the loop which would cause problems). Any
  5496. additional labels can be emitted at this point. In addition, if the
  5497. desired special iteration counter register was not allocated, this
  5498. machine dependent reorg pass could emit a traditional compare and jump
  5499. instruction pair.
  5500. The essential difference between the
  5501. @samp{decrement_and_branch_until_zero} and the @samp{doloop_end}
  5502. patterns is that the loop optimizer allocates an additional pseudo
  5503. register for the latter as an iteration counter. This pseudo register
  5504. cannot be used within the loop (i.e., general induction variables cannot
  5505. be derived from it), however, in many cases the loop induction variable
  5506. may become redundant and removed by the flow pass.
  5507. @end ifset
  5508. @ifset INTERNALS
  5509. @node Insn Canonicalizations
  5510. @section Canonicalization of Instructions
  5511. @cindex canonicalization of instructions
  5512. @cindex insn canonicalization
  5513. There are often cases where multiple RTL expressions could represent an
  5514. operation performed by a single machine instruction. This situation is
  5515. most commonly encountered with logical, branch, and multiply-accumulate
  5516. instructions. In such cases, the compiler attempts to convert these
  5517. multiple RTL expressions into a single canonical form to reduce the
  5518. number of insn patterns required.
  5519. In addition to algebraic simplifications, following canonicalizations
  5520. are performed:
  5521. @itemize @bullet
  5522. @item
  5523. For commutative and comparison operators, a constant is always made the
  5524. second operand. If a machine only supports a constant as the second
  5525. operand, only patterns that match a constant in the second operand need
  5526. be supplied.
  5527. @item
  5528. For associative operators, a sequence of operators will always chain
  5529. to the left; for instance, only the left operand of an integer @code{plus}
  5530. can itself be a @code{plus}. @code{and}, @code{ior}, @code{xor},
  5531. @code{plus}, @code{mult}, @code{smin}, @code{smax}, @code{umin}, and
  5532. @code{umax} are associative when applied to integers, and sometimes to
  5533. floating-point.
  5534. @item
  5535. @cindex @code{neg}, canonicalization of
  5536. @cindex @code{not}, canonicalization of
  5537. @cindex @code{mult}, canonicalization of
  5538. @cindex @code{plus}, canonicalization of
  5539. @cindex @code{minus}, canonicalization of
  5540. For these operators, if only one operand is a @code{neg}, @code{not},
  5541. @code{mult}, @code{plus}, or @code{minus} expression, it will be the
  5542. first operand.
  5543. @item
  5544. In combinations of @code{neg}, @code{mult}, @code{plus}, and
  5545. @code{minus}, the @code{neg} operations (if any) will be moved inside
  5546. the operations as far as possible. For instance,
  5547. @code{(neg (mult A B))} is canonicalized as @code{(mult (neg A) B)}, but
  5548. @code{(plus (mult (neg B) C) A)} is canonicalized as
  5549. @code{(minus A (mult B C))}.
  5550. @cindex @code{compare}, canonicalization of
  5551. @item
  5552. For the @code{compare} operator, a constant is always the second operand
  5553. if the first argument is a condition code register or @code{(cc0)}.
  5554. @item
  5555. An operand of @code{neg}, @code{not}, @code{mult}, @code{plus}, or
  5556. @code{minus} is made the first operand under the same conditions as
  5557. above.
  5558. @item
  5559. @code{(ltu (plus @var{a} @var{b}) @var{b})} is converted to
  5560. @code{(ltu (plus @var{a} @var{b}) @var{a})}. Likewise with @code{geu} instead
  5561. of @code{ltu}.
  5562. @item
  5563. @code{(minus @var{x} (const_int @var{n}))} is converted to
  5564. @code{(plus @var{x} (const_int @var{-n}))}.
  5565. @item
  5566. Within address computations (i.e., inside @code{mem}), a left shift is
  5567. converted into the appropriate multiplication by a power of two.
  5568. @cindex @code{ior}, canonicalization of
  5569. @cindex @code{and}, canonicalization of
  5570. @cindex De Morgan's law
  5571. @item
  5572. De Morgan's Law is used to move bitwise negation inside a bitwise
  5573. logical-and or logical-or operation. If this results in only one
  5574. operand being a @code{not} expression, it will be the first one.
  5575. A machine that has an instruction that performs a bitwise logical-and of one
  5576. operand with the bitwise negation of the other should specify the pattern
  5577. for that instruction as
  5578. @smallexample
  5579. (define_insn ""
  5580. [(set (match_operand:@var{m} 0 @dots{})
  5581. (and:@var{m} (not:@var{m} (match_operand:@var{m} 1 @dots{}))
  5582. (match_operand:@var{m} 2 @dots{})))]
  5583. "@dots{}"
  5584. "@dots{}")
  5585. @end smallexample
  5586. @noindent
  5587. Similarly, a pattern for a ``NAND'' instruction should be written
  5588. @smallexample
  5589. (define_insn ""
  5590. [(set (match_operand:@var{m} 0 @dots{})
  5591. (ior:@var{m} (not:@var{m} (match_operand:@var{m} 1 @dots{}))
  5592. (not:@var{m} (match_operand:@var{m} 2 @dots{}))))]
  5593. "@dots{}"
  5594. "@dots{}")
  5595. @end smallexample
  5596. In both cases, it is not necessary to include patterns for the many
  5597. logically equivalent RTL expressions.
  5598. @cindex @code{xor}, canonicalization of
  5599. @item
  5600. The only possible RTL expressions involving both bitwise exclusive-or
  5601. and bitwise negation are @code{(xor:@var{m} @var{x} @var{y})}
  5602. and @code{(not:@var{m} (xor:@var{m} @var{x} @var{y}))}.
  5603. @item
  5604. The sum of three items, one of which is a constant, will only appear in
  5605. the form
  5606. @smallexample
  5607. (plus:@var{m} (plus:@var{m} @var{x} @var{y}) @var{constant})
  5608. @end smallexample
  5609. @cindex @code{zero_extract}, canonicalization of
  5610. @cindex @code{sign_extract}, canonicalization of
  5611. @item
  5612. Equality comparisons of a group of bits (usually a single bit) with zero
  5613. will be written using @code{zero_extract} rather than the equivalent
  5614. @code{and} or @code{sign_extract} operations.
  5615. @cindex @code{mult}, canonicalization of
  5616. @item
  5617. @code{(sign_extend:@var{m1} (mult:@var{m2} (sign_extend:@var{m2} @var{x})
  5618. (sign_extend:@var{m2} @var{y})))} is converted to @code{(mult:@var{m1}
  5619. (sign_extend:@var{m1} @var{x}) (sign_extend:@var{m1} @var{y}))}, and likewise
  5620. for @code{zero_extend}.
  5621. @item
  5622. @code{(sign_extend:@var{m1} (mult:@var{m2} (ashiftrt:@var{m2}
  5623. @var{x} @var{s}) (sign_extend:@var{m2} @var{y})))} is converted
  5624. to @code{(mult:@var{m1} (sign_extend:@var{m1} (ashiftrt:@var{m2}
  5625. @var{x} @var{s})) (sign_extend:@var{m1} @var{y}))}, and likewise for
  5626. patterns using @code{zero_extend} and @code{lshiftrt}. If the second
  5627. operand of @code{mult} is also a shift, then that is extended also.
  5628. This transformation is only applied when it can be proven that the
  5629. original operation had sufficient precision to prevent overflow.
  5630. @end itemize
  5631. Further canonicalization rules are defined in the function
  5632. @code{commutative_operand_precedence} in @file{gcc/rtlanal.c}.
  5633. @end ifset
  5634. @ifset INTERNALS
  5635. @node Expander Definitions
  5636. @section Defining RTL Sequences for Code Generation
  5637. @cindex expander definitions
  5638. @cindex code generation RTL sequences
  5639. @cindex defining RTL sequences for code generation
  5640. On some target machines, some standard pattern names for RTL generation
  5641. cannot be handled with single insn, but a sequence of RTL insns can
  5642. represent them. For these target machines, you can write a
  5643. @code{define_expand} to specify how to generate the sequence of RTL@.
  5644. @findex define_expand
  5645. A @code{define_expand} is an RTL expression that looks almost like a
  5646. @code{define_insn}; but, unlike the latter, a @code{define_expand} is used
  5647. only for RTL generation and it can produce more than one RTL insn.
  5648. A @code{define_expand} RTX has four operands:
  5649. @itemize @bullet
  5650. @item
  5651. The name. Each @code{define_expand} must have a name, since the only
  5652. use for it is to refer to it by name.
  5653. @item
  5654. The RTL template. This is a vector of RTL expressions representing
  5655. a sequence of separate instructions. Unlike @code{define_insn}, there
  5656. is no implicit surrounding @code{PARALLEL}.
  5657. @item
  5658. The condition, a string containing a C expression. This expression is
  5659. used to express how the availability of this pattern depends on
  5660. subclasses of target machine, selected by command-line options when GCC
  5661. is run. This is just like the condition of a @code{define_insn} that
  5662. has a standard name. Therefore, the condition (if present) may not
  5663. depend on the data in the insn being matched, but only the
  5664. target-machine-type flags. The compiler needs to test these conditions
  5665. during initialization in order to learn exactly which named instructions
  5666. are available in a particular run.
  5667. @item
  5668. The preparation statements, a string containing zero or more C
  5669. statements which are to be executed before RTL code is generated from
  5670. the RTL template.
  5671. Usually these statements prepare temporary registers for use as
  5672. internal operands in the RTL template, but they can also generate RTL
  5673. insns directly by calling routines such as @code{emit_insn}, etc.
  5674. Any such insns precede the ones that come from the RTL template.
  5675. @item
  5676. Optionally, a vector containing the values of attributes. @xref{Insn
  5677. Attributes}.
  5678. @end itemize
  5679. Every RTL insn emitted by a @code{define_expand} must match some
  5680. @code{define_insn} in the machine description. Otherwise, the compiler
  5681. will crash when trying to generate code for the insn or trying to optimize
  5682. it.
  5683. The RTL template, in addition to controlling generation of RTL insns,
  5684. also describes the operands that need to be specified when this pattern
  5685. is used. In particular, it gives a predicate for each operand.
  5686. A true operand, which needs to be specified in order to generate RTL from
  5687. the pattern, should be described with a @code{match_operand} in its first
  5688. occurrence in the RTL template. This enters information on the operand's
  5689. predicate into the tables that record such things. GCC uses the
  5690. information to preload the operand into a register if that is required for
  5691. valid RTL code. If the operand is referred to more than once, subsequent
  5692. references should use @code{match_dup}.
  5693. The RTL template may also refer to internal ``operands'' which are
  5694. temporary registers or labels used only within the sequence made by the
  5695. @code{define_expand}. Internal operands are substituted into the RTL
  5696. template with @code{match_dup}, never with @code{match_operand}. The
  5697. values of the internal operands are not passed in as arguments by the
  5698. compiler when it requests use of this pattern. Instead, they are computed
  5699. within the pattern, in the preparation statements. These statements
  5700. compute the values and store them into the appropriate elements of
  5701. @code{operands} so that @code{match_dup} can find them.
  5702. There are two special macros defined for use in the preparation statements:
  5703. @code{DONE} and @code{FAIL}. Use them with a following semicolon,
  5704. as a statement.
  5705. @table @code
  5706. @findex DONE
  5707. @item DONE
  5708. Use the @code{DONE} macro to end RTL generation for the pattern. The
  5709. only RTL insns resulting from the pattern on this occasion will be
  5710. those already emitted by explicit calls to @code{emit_insn} within the
  5711. preparation statements; the RTL template will not be generated.
  5712. @findex FAIL
  5713. @item FAIL
  5714. Make the pattern fail on this occasion. When a pattern fails, it means
  5715. that the pattern was not truly available. The calling routines in the
  5716. compiler will try other strategies for code generation using other patterns.
  5717. Failure is currently supported only for binary (addition, multiplication,
  5718. shifting, etc.) and bit-field (@code{extv}, @code{extzv}, and @code{insv})
  5719. operations.
  5720. @end table
  5721. If the preparation falls through (invokes neither @code{DONE} nor
  5722. @code{FAIL}), then the @code{define_expand} acts like a
  5723. @code{define_insn} in that the RTL template is used to generate the
  5724. insn.
  5725. The RTL template is not used for matching, only for generating the
  5726. initial insn list. If the preparation statement always invokes
  5727. @code{DONE} or @code{FAIL}, the RTL template may be reduced to a simple
  5728. list of operands, such as this example:
  5729. @smallexample
  5730. @group
  5731. (define_expand "addsi3"
  5732. [(match_operand:SI 0 "register_operand" "")
  5733. (match_operand:SI 1 "register_operand" "")
  5734. (match_operand:SI 2 "register_operand" "")]
  5735. @end group
  5736. @group
  5737. ""
  5738. "
  5739. @{
  5740. handle_add (operands[0], operands[1], operands[2]);
  5741. DONE;
  5742. @}")
  5743. @end group
  5744. @end smallexample
  5745. Here is an example, the definition of left-shift for the SPUR chip:
  5746. @smallexample
  5747. @group
  5748. (define_expand "ashlsi3"
  5749. [(set (match_operand:SI 0 "register_operand" "")
  5750. (ashift:SI
  5751. @end group
  5752. @group
  5753. (match_operand:SI 1 "register_operand" "")
  5754. (match_operand:SI 2 "nonmemory_operand" "")))]
  5755. ""
  5756. "
  5757. @end group
  5758. @end smallexample
  5759. @smallexample
  5760. @group
  5761. @{
  5762. if (GET_CODE (operands[2]) != CONST_INT
  5763. || (unsigned) INTVAL (operands[2]) > 3)
  5764. FAIL;
  5765. @}")
  5766. @end group
  5767. @end smallexample
  5768. @noindent
  5769. This example uses @code{define_expand} so that it can generate an RTL insn
  5770. for shifting when the shift-count is in the supported range of 0 to 3 but
  5771. fail in other cases where machine insns aren't available. When it fails,
  5772. the compiler tries another strategy using different patterns (such as, a
  5773. library call).
  5774. If the compiler were able to handle nontrivial condition-strings in
  5775. patterns with names, then it would be possible to use a
  5776. @code{define_insn} in that case. Here is another case (zero-extension
  5777. on the 68000) which makes more use of the power of @code{define_expand}:
  5778. @smallexample
  5779. (define_expand "zero_extendhisi2"
  5780. [(set (match_operand:SI 0 "general_operand" "")
  5781. (const_int 0))
  5782. (set (strict_low_part
  5783. (subreg:HI
  5784. (match_dup 0)
  5785. 0))
  5786. (match_operand:HI 1 "general_operand" ""))]
  5787. ""
  5788. "operands[1] = make_safe_from (operands[1], operands[0]);")
  5789. @end smallexample
  5790. @noindent
  5791. @findex make_safe_from
  5792. Here two RTL insns are generated, one to clear the entire output operand
  5793. and the other to copy the input operand into its low half. This sequence
  5794. is incorrect if the input operand refers to [the old value of] the output
  5795. operand, so the preparation statement makes sure this isn't so. The
  5796. function @code{make_safe_from} copies the @code{operands[1]} into a
  5797. temporary register if it refers to @code{operands[0]}. It does this
  5798. by emitting another RTL insn.
  5799. Finally, a third example shows the use of an internal operand.
  5800. Zero-extension on the SPUR chip is done by @code{and}-ing the result
  5801. against a halfword mask. But this mask cannot be represented by a
  5802. @code{const_int} because the constant value is too large to be legitimate
  5803. on this machine. So it must be copied into a register with
  5804. @code{force_reg} and then the register used in the @code{and}.
  5805. @smallexample
  5806. (define_expand "zero_extendhisi2"
  5807. [(set (match_operand:SI 0 "register_operand" "")
  5808. (and:SI (subreg:SI
  5809. (match_operand:HI 1 "register_operand" "")
  5810. 0)
  5811. (match_dup 2)))]
  5812. ""
  5813. "operands[2]
  5814. = force_reg (SImode, GEN_INT (65535)); ")
  5815. @end smallexample
  5816. @emph{Note:} If the @code{define_expand} is used to serve a
  5817. standard binary or unary arithmetic operation or a bit-field operation,
  5818. then the last insn it generates must not be a @code{code_label},
  5819. @code{barrier} or @code{note}. It must be an @code{insn},
  5820. @code{jump_insn} or @code{call_insn}. If you don't need a real insn
  5821. at the end, emit an insn to copy the result of the operation into
  5822. itself. Such an insn will generate no code, but it can avoid problems
  5823. in the compiler.
  5824. @end ifset
  5825. @ifset INTERNALS
  5826. @node Insn Splitting
  5827. @section Defining How to Split Instructions
  5828. @cindex insn splitting
  5829. @cindex instruction splitting
  5830. @cindex splitting instructions
  5831. There are two cases where you should specify how to split a pattern
  5832. into multiple insns. On machines that have instructions requiring
  5833. delay slots (@pxref{Delay Slots}) or that have instructions whose
  5834. output is not available for multiple cycles (@pxref{Processor pipeline
  5835. description}), the compiler phases that optimize these cases need to
  5836. be able to move insns into one-instruction delay slots. However, some
  5837. insns may generate more than one machine instruction. These insns
  5838. cannot be placed into a delay slot.
  5839. Often you can rewrite the single insn as a list of individual insns,
  5840. each corresponding to one machine instruction. The disadvantage of
  5841. doing so is that it will cause the compilation to be slower and require
  5842. more space. If the resulting insns are too complex, it may also
  5843. suppress some optimizations. The compiler splits the insn if there is a
  5844. reason to believe that it might improve instruction or delay slot
  5845. scheduling.
  5846. The insn combiner phase also splits putative insns. If three insns are
  5847. merged into one insn with a complex expression that cannot be matched by
  5848. some @code{define_insn} pattern, the combiner phase attempts to split
  5849. the complex pattern into two insns that are recognized. Usually it can
  5850. break the complex pattern into two patterns by splitting out some
  5851. subexpression. However, in some other cases, such as performing an
  5852. addition of a large constant in two insns on a RISC machine, the way to
  5853. split the addition into two insns is machine-dependent.
  5854. @findex define_split
  5855. The @code{define_split} definition tells the compiler how to split a
  5856. complex insn into several simpler insns. It looks like this:
  5857. @smallexample
  5858. (define_split
  5859. [@var{insn-pattern}]
  5860. "@var{condition}"
  5861. [@var{new-insn-pattern-1}
  5862. @var{new-insn-pattern-2}
  5863. @dots{}]
  5864. "@var{preparation-statements}")
  5865. @end smallexample
  5866. @var{insn-pattern} is a pattern that needs to be split and
  5867. @var{condition} is the final condition to be tested, as in a
  5868. @code{define_insn}. When an insn matching @var{insn-pattern} and
  5869. satisfying @var{condition} is found, it is replaced in the insn list
  5870. with the insns given by @var{new-insn-pattern-1},
  5871. @var{new-insn-pattern-2}, etc.
  5872. The @var{preparation-statements} are similar to those statements that
  5873. are specified for @code{define_expand} (@pxref{Expander Definitions})
  5874. and are executed before the new RTL is generated to prepare for the
  5875. generated code or emit some insns whose pattern is not fixed. Unlike
  5876. those in @code{define_expand}, however, these statements must not
  5877. generate any new pseudo-registers. Once reload has completed, they also
  5878. must not allocate any space in the stack frame.
  5879. Patterns are matched against @var{insn-pattern} in two different
  5880. circumstances. If an insn needs to be split for delay slot scheduling
  5881. or insn scheduling, the insn is already known to be valid, which means
  5882. that it must have been matched by some @code{define_insn} and, if
  5883. @code{reload_completed} is nonzero, is known to satisfy the constraints
  5884. of that @code{define_insn}. In that case, the new insn patterns must
  5885. also be insns that are matched by some @code{define_insn} and, if
  5886. @code{reload_completed} is nonzero, must also satisfy the constraints
  5887. of those definitions.
  5888. As an example of this usage of @code{define_split}, consider the following
  5889. example from @file{a29k.md}, which splits a @code{sign_extend} from
  5890. @code{HImode} to @code{SImode} into a pair of shift insns:
  5891. @smallexample
  5892. (define_split
  5893. [(set (match_operand:SI 0 "gen_reg_operand" "")
  5894. (sign_extend:SI (match_operand:HI 1 "gen_reg_operand" "")))]
  5895. ""
  5896. [(set (match_dup 0)
  5897. (ashift:SI (match_dup 1)
  5898. (const_int 16)))
  5899. (set (match_dup 0)
  5900. (ashiftrt:SI (match_dup 0)
  5901. (const_int 16)))]
  5902. "
  5903. @{ operands[1] = gen_lowpart (SImode, operands[1]); @}")
  5904. @end smallexample
  5905. When the combiner phase tries to split an insn pattern, it is always the
  5906. case that the pattern is @emph{not} matched by any @code{define_insn}.
  5907. The combiner pass first tries to split a single @code{set} expression
  5908. and then the same @code{set} expression inside a @code{parallel}, but
  5909. followed by a @code{clobber} of a pseudo-reg to use as a scratch
  5910. register. In these cases, the combiner expects exactly two new insn
  5911. patterns to be generated. It will verify that these patterns match some
  5912. @code{define_insn} definitions, so you need not do this test in the
  5913. @code{define_split} (of course, there is no point in writing a
  5914. @code{define_split} that will never produce insns that match).
  5915. Here is an example of this use of @code{define_split}, taken from
  5916. @file{rs6000.md}:
  5917. @smallexample
  5918. (define_split
  5919. [(set (match_operand:SI 0 "gen_reg_operand" "")
  5920. (plus:SI (match_operand:SI 1 "gen_reg_operand" "")
  5921. (match_operand:SI 2 "non_add_cint_operand" "")))]
  5922. ""
  5923. [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
  5924. (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
  5925. "
  5926. @{
  5927. int low = INTVAL (operands[2]) & 0xffff;
  5928. int high = (unsigned) INTVAL (operands[2]) >> 16;
  5929. if (low & 0x8000)
  5930. high++, low |= 0xffff0000;
  5931. operands[3] = GEN_INT (high << 16);
  5932. operands[4] = GEN_INT (low);
  5933. @}")
  5934. @end smallexample
  5935. Here the predicate @code{non_add_cint_operand} matches any
  5936. @code{const_int} that is @emph{not} a valid operand of a single add
  5937. insn. The add with the smaller displacement is written so that it
  5938. can be substituted into the address of a subsequent operation.
  5939. An example that uses a scratch register, from the same file, generates
  5940. an equality comparison of a register and a large constant:
  5941. @smallexample
  5942. (define_split
  5943. [(set (match_operand:CC 0 "cc_reg_operand" "")
  5944. (compare:CC (match_operand:SI 1 "gen_reg_operand" "")
  5945. (match_operand:SI 2 "non_short_cint_operand" "")))
  5946. (clobber (match_operand:SI 3 "gen_reg_operand" ""))]
  5947. "find_single_use (operands[0], insn, 0)
  5948. && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
  5949. || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
  5950. [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
  5951. (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
  5952. "
  5953. @{
  5954. /* @r{Get the constant we are comparing against, C, and see what it
  5955. looks like sign-extended to 16 bits. Then see what constant
  5956. could be XOR'ed with C to get the sign-extended value.} */
  5957. int c = INTVAL (operands[2]);
  5958. int sextc = (c << 16) >> 16;
  5959. int xorv = c ^ sextc;
  5960. operands[4] = GEN_INT (xorv);
  5961. operands[5] = GEN_INT (sextc);
  5962. @}")
  5963. @end smallexample
  5964. To avoid confusion, don't write a single @code{define_split} that
  5965. accepts some insns that match some @code{define_insn} as well as some
  5966. insns that don't. Instead, write two separate @code{define_split}
  5967. definitions, one for the insns that are valid and one for the insns that
  5968. are not valid.
  5969. The splitter is allowed to split jump instructions into sequence of
  5970. jumps or create new jumps in while splitting non-jump instructions. As
  5971. the central flowgraph and branch prediction information needs to be updated,
  5972. several restriction apply.
  5973. Splitting of jump instruction into sequence that over by another jump
  5974. instruction is always valid, as compiler expect identical behavior of new
  5975. jump. When new sequence contains multiple jump instructions or new labels,
  5976. more assistance is needed. Splitter is required to create only unconditional
  5977. jumps, or simple conditional jump instructions. Additionally it must attach a
  5978. @code{REG_BR_PROB} note to each conditional jump. A global variable
  5979. @code{split_branch_probability} holds the probability of the original branch in case
  5980. it was a simple conditional jump, @minus{}1 otherwise. To simplify
  5981. recomputing of edge frequencies, the new sequence is required to have only
  5982. forward jumps to the newly created labels.
  5983. @findex define_insn_and_split
  5984. For the common case where the pattern of a define_split exactly matches the
  5985. pattern of a define_insn, use @code{define_insn_and_split}. It looks like
  5986. this:
  5987. @smallexample
  5988. (define_insn_and_split
  5989. [@var{insn-pattern}]
  5990. "@var{condition}"
  5991. "@var{output-template}"
  5992. "@var{split-condition}"
  5993. [@var{new-insn-pattern-1}
  5994. @var{new-insn-pattern-2}
  5995. @dots{}]
  5996. "@var{preparation-statements}"
  5997. [@var{insn-attributes}])
  5998. @end smallexample
  5999. @var{insn-pattern}, @var{condition}, @var{output-template}, and
  6000. @var{insn-attributes} are used as in @code{define_insn}. The
  6001. @var{new-insn-pattern} vector and the @var{preparation-statements} are used as
  6002. in a @code{define_split}. The @var{split-condition} is also used as in
  6003. @code{define_split}, with the additional behavior that if the condition starts
  6004. with @samp{&&}, the condition used for the split will be the constructed as a
  6005. logical ``and'' of the split condition with the insn condition. For example,
  6006. from i386.md:
  6007. @smallexample
  6008. (define_insn_and_split "zero_extendhisi2_and"
  6009. [(set (match_operand:SI 0 "register_operand" "=r")
  6010. (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
  6011. (clobber (reg:CC 17))]
  6012. "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
  6013. "#"
  6014. "&& reload_completed"
  6015. [(parallel [(set (match_dup 0)
  6016. (and:SI (match_dup 0) (const_int 65535)))
  6017. (clobber (reg:CC 17))])]
  6018. ""
  6019. [(set_attr "type" "alu1")])
  6020. @end smallexample
  6021. In this case, the actual split condition will be
  6022. @samp{TARGET_ZERO_EXTEND_WITH_AND && !optimize_size && reload_completed}.
  6023. The @code{define_insn_and_split} construction provides exactly the same
  6024. functionality as two separate @code{define_insn} and @code{define_split}
  6025. patterns. It exists for compactness, and as a maintenance tool to prevent
  6026. having to ensure the two patterns' templates match.
  6027. @end ifset
  6028. @ifset INTERNALS
  6029. @node Including Patterns
  6030. @section Including Patterns in Machine Descriptions.
  6031. @cindex insn includes
  6032. @findex include
  6033. The @code{include} pattern tells the compiler tools where to
  6034. look for patterns that are in files other than in the file
  6035. @file{.md}. This is used only at build time and there is no preprocessing allowed.
  6036. It looks like:
  6037. @smallexample
  6038. (include
  6039. @var{pathname})
  6040. @end smallexample
  6041. For example:
  6042. @smallexample
  6043. (include "filestuff")
  6044. @end smallexample
  6045. Where @var{pathname} is a string that specifies the location of the file,
  6046. specifies the include file to be in @file{gcc/config/target/filestuff}. The
  6047. directory @file{gcc/config/target} is regarded as the default directory.
  6048. Machine descriptions may be split up into smaller more manageable subsections
  6049. and placed into subdirectories.
  6050. By specifying:
  6051. @smallexample
  6052. (include "BOGUS/filestuff")
  6053. @end smallexample
  6054. the include file is specified to be in @file{gcc/config/@var{target}/BOGUS/filestuff}.
  6055. Specifying an absolute path for the include file such as;
  6056. @smallexample
  6057. (include "/u2/BOGUS/filestuff")
  6058. @end smallexample
  6059. is permitted but is not encouraged.
  6060. @subsection RTL Generation Tool Options for Directory Search
  6061. @cindex directory options .md
  6062. @cindex options, directory search
  6063. @cindex search options
  6064. The @option{-I@var{dir}} option specifies directories to search for machine descriptions.
  6065. For example:
  6066. @smallexample
  6067. genrecog -I/p1/abc/proc1 -I/p2/abcd/pro2 target.md
  6068. @end smallexample
  6069. Add the directory @var{dir} to the head of the list of directories to be
  6070. searched for header files. This can be used to override a system machine definition
  6071. file, substituting your own version, since these directories are
  6072. searched before the default machine description file directories. If you use more than
  6073. one @option{-I} option, the directories are scanned in left-to-right
  6074. order; the standard default directory come after.
  6075. @end ifset
  6076. @ifset INTERNALS
  6077. @node Peephole Definitions
  6078. @section Machine-Specific Peephole Optimizers
  6079. @cindex peephole optimizer definitions
  6080. @cindex defining peephole optimizers
  6081. In addition to instruction patterns the @file{md} file may contain
  6082. definitions of machine-specific peephole optimizations.
  6083. The combiner does not notice certain peephole optimizations when the data
  6084. flow in the program does not suggest that it should try them. For example,
  6085. sometimes two consecutive insns related in purpose can be combined even
  6086. though the second one does not appear to use a register computed in the
  6087. first one. A machine-specific peephole optimizer can detect such
  6088. opportunities.
  6089. There are two forms of peephole definitions that may be used. The
  6090. original @code{define_peephole} is run at assembly output time to
  6091. match insns and substitute assembly text. Use of @code{define_peephole}
  6092. is deprecated.
  6093. A newer @code{define_peephole2} matches insns and substitutes new
  6094. insns. The @code{peephole2} pass is run after register allocation
  6095. but before scheduling, which may result in much better code for
  6096. targets that do scheduling.
  6097. @menu
  6098. * define_peephole:: RTL to Text Peephole Optimizers
  6099. * define_peephole2:: RTL to RTL Peephole Optimizers
  6100. @end menu
  6101. @end ifset
  6102. @ifset INTERNALS
  6103. @node define_peephole
  6104. @subsection RTL to Text Peephole Optimizers
  6105. @findex define_peephole
  6106. @need 1000
  6107. A definition looks like this:
  6108. @smallexample
  6109. (define_peephole
  6110. [@var{insn-pattern-1}
  6111. @var{insn-pattern-2}
  6112. @dots{}]
  6113. "@var{condition}"
  6114. "@var{template}"
  6115. "@var{optional-insn-attributes}")
  6116. @end smallexample
  6117. @noindent
  6118. The last string operand may be omitted if you are not using any
  6119. machine-specific information in this machine description. If present,
  6120. it must obey the same rules as in a @code{define_insn}.
  6121. In this skeleton, @var{insn-pattern-1} and so on are patterns to match
  6122. consecutive insns. The optimization applies to a sequence of insns when
  6123. @var{insn-pattern-1} matches the first one, @var{insn-pattern-2} matches
  6124. the next, and so on.
  6125. Each of the insns matched by a peephole must also match a
  6126. @code{define_insn}. Peepholes are checked only at the last stage just
  6127. before code generation, and only optionally. Therefore, any insn which
  6128. would match a peephole but no @code{define_insn} will cause a crash in code
  6129. generation in an unoptimized compilation, or at various optimization
  6130. stages.
  6131. The operands of the insns are matched with @code{match_operands},
  6132. @code{match_operator}, and @code{match_dup}, as usual. What is not
  6133. usual is that the operand numbers apply to all the insn patterns in the
  6134. definition. So, you can check for identical operands in two insns by
  6135. using @code{match_operand} in one insn and @code{match_dup} in the
  6136. other.
  6137. The operand constraints used in @code{match_operand} patterns do not have
  6138. any direct effect on the applicability of the peephole, but they will
  6139. be validated afterward, so make sure your constraints are general enough
  6140. to apply whenever the peephole matches. If the peephole matches
  6141. but the constraints are not satisfied, the compiler will crash.
  6142. It is safe to omit constraints in all the operands of the peephole; or
  6143. you can write constraints which serve as a double-check on the criteria
  6144. previously tested.
  6145. Once a sequence of insns matches the patterns, the @var{condition} is
  6146. checked. This is a C expression which makes the final decision whether to
  6147. perform the optimization (we do so if the expression is nonzero). If
  6148. @var{condition} is omitted (in other words, the string is empty) then the
  6149. optimization is applied to every sequence of insns that matches the
  6150. patterns.
  6151. The defined peephole optimizations are applied after register allocation
  6152. is complete. Therefore, the peephole definition can check which
  6153. operands have ended up in which kinds of registers, just by looking at
  6154. the operands.
  6155. @findex prev_active_insn
  6156. The way to refer to the operands in @var{condition} is to write
  6157. @code{operands[@var{i}]} for operand number @var{i} (as matched by
  6158. @code{(match_operand @var{i} @dots{})}). Use the variable @code{insn}
  6159. to refer to the last of the insns being matched; use
  6160. @code{prev_active_insn} to find the preceding insns.
  6161. @findex dead_or_set_p
  6162. When optimizing computations with intermediate results, you can use
  6163. @var{condition} to match only when the intermediate results are not used
  6164. elsewhere. Use the C expression @code{dead_or_set_p (@var{insn},
  6165. @var{op})}, where @var{insn} is the insn in which you expect the value
  6166. to be used for the last time (from the value of @code{insn}, together
  6167. with use of @code{prev_nonnote_insn}), and @var{op} is the intermediate
  6168. value (from @code{operands[@var{i}]}).
  6169. Applying the optimization means replacing the sequence of insns with one
  6170. new insn. The @var{template} controls ultimate output of assembler code
  6171. for this combined insn. It works exactly like the template of a
  6172. @code{define_insn}. Operand numbers in this template are the same ones
  6173. used in matching the original sequence of insns.
  6174. The result of a defined peephole optimizer does not need to match any of
  6175. the insn patterns in the machine description; it does not even have an
  6176. opportunity to match them. The peephole optimizer definition itself serves
  6177. as the insn pattern to control how the insn is output.
  6178. Defined peephole optimizers are run as assembler code is being output,
  6179. so the insns they produce are never combined or rearranged in any way.
  6180. Here is an example, taken from the 68000 machine description:
  6181. @smallexample
  6182. (define_peephole
  6183. [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
  6184. (set (match_operand:DF 0 "register_operand" "=f")
  6185. (match_operand:DF 1 "register_operand" "ad"))]
  6186. "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  6187. @{
  6188. rtx xoperands[2];
  6189. xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
  6190. #ifdef MOTOROLA
  6191. output_asm_insn ("move.l %1,(sp)", xoperands);
  6192. output_asm_insn ("move.l %1,-(sp)", operands);
  6193. return "fmove.d (sp)+,%0";
  6194. #else
  6195. output_asm_insn ("movel %1,sp@@", xoperands);
  6196. output_asm_insn ("movel %1,sp@@-", operands);
  6197. return "fmoved sp@@+,%0";
  6198. #endif
  6199. @})
  6200. @end smallexample
  6201. @need 1000
  6202. The effect of this optimization is to change
  6203. @smallexample
  6204. @group
  6205. jbsr _foobar
  6206. addql #4,sp
  6207. movel d1,sp@@-
  6208. movel d0,sp@@-
  6209. fmoved sp@@+,fp0
  6210. @end group
  6211. @end smallexample
  6212. @noindent
  6213. into
  6214. @smallexample
  6215. @group
  6216. jbsr _foobar
  6217. movel d1,sp@@
  6218. movel d0,sp@@-
  6219. fmoved sp@@+,fp0
  6220. @end group
  6221. @end smallexample
  6222. @ignore
  6223. @findex CC_REVERSED
  6224. If a peephole matches a sequence including one or more jump insns, you must
  6225. take account of the flags such as @code{CC_REVERSED} which specify that the
  6226. condition codes are represented in an unusual manner. The compiler
  6227. automatically alters any ordinary conditional jumps which occur in such
  6228. situations, but the compiler cannot alter jumps which have been replaced by
  6229. peephole optimizations. So it is up to you to alter the assembler code
  6230. that the peephole produces. Supply C code to write the assembler output,
  6231. and in this C code check the condition code status flags and change the
  6232. assembler code as appropriate.
  6233. @end ignore
  6234. @var{insn-pattern-1} and so on look @emph{almost} like the second
  6235. operand of @code{define_insn}. There is one important difference: the
  6236. second operand of @code{define_insn} consists of one or more RTX's
  6237. enclosed in square brackets. Usually, there is only one: then the same
  6238. action can be written as an element of a @code{define_peephole}. But
  6239. when there are multiple actions in a @code{define_insn}, they are
  6240. implicitly enclosed in a @code{parallel}. Then you must explicitly
  6241. write the @code{parallel}, and the square brackets within it, in the
  6242. @code{define_peephole}. Thus, if an insn pattern looks like this,
  6243. @smallexample
  6244. (define_insn "divmodsi4"
  6245. [(set (match_operand:SI 0 "general_operand" "=d")
  6246. (div:SI (match_operand:SI 1 "general_operand" "0")
  6247. (match_operand:SI 2 "general_operand" "dmsK")))
  6248. (set (match_operand:SI 3 "general_operand" "=d")
  6249. (mod:SI (match_dup 1) (match_dup 2)))]
  6250. "TARGET_68020"
  6251. "divsl%.l %2,%3:%0")
  6252. @end smallexample
  6253. @noindent
  6254. then the way to mention this insn in a peephole is as follows:
  6255. @smallexample
  6256. (define_peephole
  6257. [@dots{}
  6258. (parallel
  6259. [(set (match_operand:SI 0 "general_operand" "=d")
  6260. (div:SI (match_operand:SI 1 "general_operand" "0")
  6261. (match_operand:SI 2 "general_operand" "dmsK")))
  6262. (set (match_operand:SI 3 "general_operand" "=d")
  6263. (mod:SI (match_dup 1) (match_dup 2)))])
  6264. @dots{}]
  6265. @dots{})
  6266. @end smallexample
  6267. @end ifset
  6268. @ifset INTERNALS
  6269. @node define_peephole2
  6270. @subsection RTL to RTL Peephole Optimizers
  6271. @findex define_peephole2
  6272. The @code{define_peephole2} definition tells the compiler how to
  6273. substitute one sequence of instructions for another sequence,
  6274. what additional scratch registers may be needed and what their
  6275. lifetimes must be.
  6276. @smallexample
  6277. (define_peephole2
  6278. [@var{insn-pattern-1}
  6279. @var{insn-pattern-2}
  6280. @dots{}]
  6281. "@var{condition}"
  6282. [@var{new-insn-pattern-1}
  6283. @var{new-insn-pattern-2}
  6284. @dots{}]
  6285. "@var{preparation-statements}")
  6286. @end smallexample
  6287. The definition is almost identical to @code{define_split}
  6288. (@pxref{Insn Splitting}) except that the pattern to match is not a
  6289. single instruction, but a sequence of instructions.
  6290. It is possible to request additional scratch registers for use in the
  6291. output template. If appropriate registers are not free, the pattern
  6292. will simply not match.
  6293. @findex match_scratch
  6294. @findex match_dup
  6295. Scratch registers are requested with a @code{match_scratch} pattern at
  6296. the top level of the input pattern. The allocated register (initially) will
  6297. be dead at the point requested within the original sequence. If the scratch
  6298. is used at more than a single point, a @code{match_dup} pattern at the
  6299. top level of the input pattern marks the last position in the input sequence
  6300. at which the register must be available.
  6301. Here is an example from the IA-32 machine description:
  6302. @smallexample
  6303. (define_peephole2
  6304. [(match_scratch:SI 2 "r")
  6305. (parallel [(set (match_operand:SI 0 "register_operand" "")
  6306. (match_operator:SI 3 "arith_or_logical_operator"
  6307. [(match_dup 0)
  6308. (match_operand:SI 1 "memory_operand" "")]))
  6309. (clobber (reg:CC 17))])]
  6310. "! optimize_size && ! TARGET_READ_MODIFY"
  6311. [(set (match_dup 2) (match_dup 1))
  6312. (parallel [(set (match_dup 0)
  6313. (match_op_dup 3 [(match_dup 0) (match_dup 2)]))
  6314. (clobber (reg:CC 17))])]
  6315. "")
  6316. @end smallexample
  6317. @noindent
  6318. This pattern tries to split a load from its use in the hopes that we'll be
  6319. able to schedule around the memory load latency. It allocates a single
  6320. @code{SImode} register of class @code{GENERAL_REGS} (@code{"r"}) that needs
  6321. to be live only at the point just before the arithmetic.
  6322. A real example requiring extended scratch lifetimes is harder to come by,
  6323. so here's a silly made-up example:
  6324. @smallexample
  6325. (define_peephole2
  6326. [(match_scratch:SI 4 "r")
  6327. (set (match_operand:SI 0 "" "") (match_operand:SI 1 "" ""))
  6328. (set (match_operand:SI 2 "" "") (match_dup 1))
  6329. (match_dup 4)
  6330. (set (match_operand:SI 3 "" "") (match_dup 1))]
  6331. "/* @r{determine 1 does not overlap 0 and 2} */"
  6332. [(set (match_dup 4) (match_dup 1))
  6333. (set (match_dup 0) (match_dup 4))
  6334. (set (match_dup 2) (match_dup 4))
  6335. (set (match_dup 3) (match_dup 4))]
  6336. "")
  6337. @end smallexample
  6338. @noindent
  6339. If we had not added the @code{(match_dup 4)} in the middle of the input
  6340. sequence, it might have been the case that the register we chose at the
  6341. beginning of the sequence is killed by the first or second @code{set}.
  6342. @end ifset
  6343. @ifset INTERNALS
  6344. @node Insn Attributes
  6345. @section Instruction Attributes
  6346. @cindex insn attributes
  6347. @cindex instruction attributes
  6348. In addition to describing the instruction supported by the target machine,
  6349. the @file{md} file also defines a group of @dfn{attributes} and a set of
  6350. values for each. Every generated insn is assigned a value for each attribute.
  6351. One possible attribute would be the effect that the insn has on the machine's
  6352. condition code. This attribute can then be used by @code{NOTICE_UPDATE_CC}
  6353. to track the condition codes.
  6354. @menu
  6355. * Defining Attributes:: Specifying attributes and their values.
  6356. * Expressions:: Valid expressions for attribute values.
  6357. * Tagging Insns:: Assigning attribute values to insns.
  6358. * Attr Example:: An example of assigning attributes.
  6359. * Insn Lengths:: Computing the length of insns.
  6360. * Constant Attributes:: Defining attributes that are constant.
  6361. * Mnemonic Attribute:: Obtain the instruction mnemonic as attribute value.
  6362. * Delay Slots:: Defining delay slots required for a machine.
  6363. * Processor pipeline description:: Specifying information for insn scheduling.
  6364. @end menu
  6365. @end ifset
  6366. @ifset INTERNALS
  6367. @node Defining Attributes
  6368. @subsection Defining Attributes and their Values
  6369. @cindex defining attributes and their values
  6370. @cindex attributes, defining
  6371. @findex define_attr
  6372. The @code{define_attr} expression is used to define each attribute required
  6373. by the target machine. It looks like:
  6374. @smallexample
  6375. (define_attr @var{name} @var{list-of-values} @var{default})
  6376. @end smallexample
  6377. @var{name} is a string specifying the name of the attribute being
  6378. defined. Some attributes are used in a special way by the rest of the
  6379. compiler. The @code{enabled} attribute can be used to conditionally
  6380. enable or disable insn alternatives (@pxref{Disable Insn
  6381. Alternatives}). The @code{predicable} attribute, together with a
  6382. suitable @code{define_cond_exec} (@pxref{Conditional Execution}), can
  6383. be used to automatically generate conditional variants of instruction
  6384. patterns. The @code{mnemonic} attribute can be used to check for the
  6385. instruction mnemonic (@pxref{Mnemonic Attribute}). The compiler
  6386. internally uses the names @code{ce_enabled} and @code{nonce_enabled},
  6387. so they should not be used elsewhere as alternative names.
  6388. @var{list-of-values} is either a string that specifies a comma-separated
  6389. list of values that can be assigned to the attribute, or a null string to
  6390. indicate that the attribute takes numeric values.
  6391. @var{default} is an attribute expression that gives the value of this
  6392. attribute for insns that match patterns whose definition does not include
  6393. an explicit value for this attribute. @xref{Attr Example}, for more
  6394. information on the handling of defaults. @xref{Constant Attributes},
  6395. for information on attributes that do not depend on any particular insn.
  6396. @findex insn-attr.h
  6397. For each defined attribute, a number of definitions are written to the
  6398. @file{insn-attr.h} file. For cases where an explicit set of values is
  6399. specified for an attribute, the following are defined:
  6400. @itemize @bullet
  6401. @item
  6402. A @samp{#define} is written for the symbol @samp{HAVE_ATTR_@var{name}}.
  6403. @item
  6404. An enumerated class is defined for @samp{attr_@var{name}} with
  6405. elements of the form @samp{@var{upper-name}_@var{upper-value}} where
  6406. the attribute name and value are first converted to uppercase.
  6407. @item
  6408. A function @samp{get_attr_@var{name}} is defined that is passed an insn and
  6409. returns the attribute value for that insn.
  6410. @end itemize
  6411. For example, if the following is present in the @file{md} file:
  6412. @smallexample
  6413. (define_attr "type" "branch,fp,load,store,arith" @dots{})
  6414. @end smallexample
  6415. @noindent
  6416. the following lines will be written to the file @file{insn-attr.h}.
  6417. @smallexample
  6418. #define HAVE_ATTR_type 1
  6419. enum attr_type @{TYPE_BRANCH, TYPE_FP, TYPE_LOAD,
  6420. TYPE_STORE, TYPE_ARITH@};
  6421. extern enum attr_type get_attr_type ();
  6422. @end smallexample
  6423. If the attribute takes numeric values, no @code{enum} type will be
  6424. defined and the function to obtain the attribute's value will return
  6425. @code{int}.
  6426. There are attributes which are tied to a specific meaning. These
  6427. attributes are not free to use for other purposes:
  6428. @table @code
  6429. @item length
  6430. The @code{length} attribute is used to calculate the length of emitted
  6431. code chunks. This is especially important when verifying branch
  6432. distances. @xref{Insn Lengths}.
  6433. @item enabled
  6434. The @code{enabled} attribute can be defined to prevent certain
  6435. alternatives of an insn definition from being used during code
  6436. generation. @xref{Disable Insn Alternatives}.
  6437. @item mnemonic
  6438. The @code{mnemonic} attribute can be defined to implement instruction
  6439. specific checks in e.g. the pipeline description.
  6440. @xref{Mnemonic Attribute}.
  6441. @end table
  6442. For each of these special attributes, the corresponding
  6443. @samp{HAVE_ATTR_@var{name}} @samp{#define} is also written when the
  6444. attribute is not defined; in that case, it is defined as @samp{0}.
  6445. @findex define_enum_attr
  6446. @anchor{define_enum_attr}
  6447. Another way of defining an attribute is to use:
  6448. @smallexample
  6449. (define_enum_attr "@var{attr}" "@var{enum}" @var{default})
  6450. @end smallexample
  6451. This works in just the same way as @code{define_attr}, except that
  6452. the list of values is taken from a separate enumeration called
  6453. @var{enum} (@pxref{define_enum}). This form allows you to use
  6454. the same list of values for several attributes without having to
  6455. repeat the list each time. For example:
  6456. @smallexample
  6457. (define_enum "processor" [
  6458. model_a
  6459. model_b
  6460. @dots{}
  6461. ])
  6462. (define_enum_attr "arch" "processor"
  6463. (const (symbol_ref "target_arch")))
  6464. (define_enum_attr "tune" "processor"
  6465. (const (symbol_ref "target_tune")))
  6466. @end smallexample
  6467. defines the same attributes as:
  6468. @smallexample
  6469. (define_attr "arch" "model_a,model_b,@dots{}"
  6470. (const (symbol_ref "target_arch")))
  6471. (define_attr "tune" "model_a,model_b,@dots{}"
  6472. (const (symbol_ref "target_tune")))
  6473. @end smallexample
  6474. but without duplicating the processor list. The second example defines two
  6475. separate C enums (@code{attr_arch} and @code{attr_tune}) whereas the first
  6476. defines a single C enum (@code{processor}).
  6477. @end ifset
  6478. @ifset INTERNALS
  6479. @node Expressions
  6480. @subsection Attribute Expressions
  6481. @cindex attribute expressions
  6482. RTL expressions used to define attributes use the codes described above
  6483. plus a few specific to attribute definitions, to be discussed below.
  6484. Attribute value expressions must have one of the following forms:
  6485. @table @code
  6486. @cindex @code{const_int} and attributes
  6487. @item (const_int @var{i})
  6488. The integer @var{i} specifies the value of a numeric attribute. @var{i}
  6489. must be non-negative.
  6490. The value of a numeric attribute can be specified either with a
  6491. @code{const_int}, or as an integer represented as a string in
  6492. @code{const_string}, @code{eq_attr} (see below), @code{attr},
  6493. @code{symbol_ref}, simple arithmetic expressions, and @code{set_attr}
  6494. overrides on specific instructions (@pxref{Tagging Insns}).
  6495. @cindex @code{const_string} and attributes
  6496. @item (const_string @var{value})
  6497. The string @var{value} specifies a constant attribute value.
  6498. If @var{value} is specified as @samp{"*"}, it means that the default value of
  6499. the attribute is to be used for the insn containing this expression.
  6500. @samp{"*"} obviously cannot be used in the @var{default} expression
  6501. of a @code{define_attr}.
  6502. If the attribute whose value is being specified is numeric, @var{value}
  6503. must be a string containing a non-negative integer (normally
  6504. @code{const_int} would be used in this case). Otherwise, it must
  6505. contain one of the valid values for the attribute.
  6506. @cindex @code{if_then_else} and attributes
  6507. @item (if_then_else @var{test} @var{true-value} @var{false-value})
  6508. @var{test} specifies an attribute test, whose format is defined below.
  6509. The value of this expression is @var{true-value} if @var{test} is true,
  6510. otherwise it is @var{false-value}.
  6511. @cindex @code{cond} and attributes
  6512. @item (cond [@var{test1} @var{value1} @dots{}] @var{default})
  6513. The first operand of this expression is a vector containing an even
  6514. number of expressions and consisting of pairs of @var{test} and @var{value}
  6515. expressions. The value of the @code{cond} expression is that of the
  6516. @var{value} corresponding to the first true @var{test} expression. If
  6517. none of the @var{test} expressions are true, the value of the @code{cond}
  6518. expression is that of the @var{default} expression.
  6519. @end table
  6520. @var{test} expressions can have one of the following forms:
  6521. @table @code
  6522. @cindex @code{const_int} and attribute tests
  6523. @item (const_int @var{i})
  6524. This test is true if @var{i} is nonzero and false otherwise.
  6525. @cindex @code{not} and attributes
  6526. @cindex @code{ior} and attributes
  6527. @cindex @code{and} and attributes
  6528. @item (not @var{test})
  6529. @itemx (ior @var{test1} @var{test2})
  6530. @itemx (and @var{test1} @var{test2})
  6531. These tests are true if the indicated logical function is true.
  6532. @cindex @code{match_operand} and attributes
  6533. @item (match_operand:@var{m} @var{n} @var{pred} @var{constraints})
  6534. This test is true if operand @var{n} of the insn whose attribute value
  6535. is being determined has mode @var{m} (this part of the test is ignored
  6536. if @var{m} is @code{VOIDmode}) and the function specified by the string
  6537. @var{pred} returns a nonzero value when passed operand @var{n} and mode
  6538. @var{m} (this part of the test is ignored if @var{pred} is the null
  6539. string).
  6540. The @var{constraints} operand is ignored and should be the null string.
  6541. @cindex @code{match_test} and attributes
  6542. @item (match_test @var{c-expr})
  6543. The test is true if C expression @var{c-expr} is true. In non-constant
  6544. attributes, @var{c-expr} has access to the following variables:
  6545. @table @var
  6546. @item insn
  6547. The rtl instruction under test.
  6548. @item which_alternative
  6549. The @code{define_insn} alternative that @var{insn} matches.
  6550. @xref{Output Statement}.
  6551. @item operands
  6552. An array of @var{insn}'s rtl operands.
  6553. @end table
  6554. @var{c-expr} behaves like the condition in a C @code{if} statement,
  6555. so there is no need to explicitly convert the expression into a boolean
  6556. 0 or 1 value. For example, the following two tests are equivalent:
  6557. @smallexample
  6558. (match_test "x & 2")
  6559. (match_test "(x & 2) != 0")
  6560. @end smallexample
  6561. @cindex @code{le} and attributes
  6562. @cindex @code{leu} and attributes
  6563. @cindex @code{lt} and attributes
  6564. @cindex @code{gt} and attributes
  6565. @cindex @code{gtu} and attributes
  6566. @cindex @code{ge} and attributes
  6567. @cindex @code{geu} and attributes
  6568. @cindex @code{ne} and attributes
  6569. @cindex @code{eq} and attributes
  6570. @cindex @code{plus} and attributes
  6571. @cindex @code{minus} and attributes
  6572. @cindex @code{mult} and attributes
  6573. @cindex @code{div} and attributes
  6574. @cindex @code{mod} and attributes
  6575. @cindex @code{abs} and attributes
  6576. @cindex @code{neg} and attributes
  6577. @cindex @code{ashift} and attributes
  6578. @cindex @code{lshiftrt} and attributes
  6579. @cindex @code{ashiftrt} and attributes
  6580. @item (le @var{arith1} @var{arith2})
  6581. @itemx (leu @var{arith1} @var{arith2})
  6582. @itemx (lt @var{arith1} @var{arith2})
  6583. @itemx (ltu @var{arith1} @var{arith2})
  6584. @itemx (gt @var{arith1} @var{arith2})
  6585. @itemx (gtu @var{arith1} @var{arith2})
  6586. @itemx (ge @var{arith1} @var{arith2})
  6587. @itemx (geu @var{arith1} @var{arith2})
  6588. @itemx (ne @var{arith1} @var{arith2})
  6589. @itemx (eq @var{arith1} @var{arith2})
  6590. These tests are true if the indicated comparison of the two arithmetic
  6591. expressions is true. Arithmetic expressions are formed with
  6592. @code{plus}, @code{minus}, @code{mult}, @code{div}, @code{mod},
  6593. @code{abs}, @code{neg}, @code{and}, @code{ior}, @code{xor}, @code{not},
  6594. @code{ashift}, @code{lshiftrt}, and @code{ashiftrt} expressions.
  6595. @findex get_attr
  6596. @code{const_int} and @code{symbol_ref} are always valid terms (@pxref{Insn
  6597. Lengths},for additional forms). @code{symbol_ref} is a string
  6598. denoting a C expression that yields an @code{int} when evaluated by the
  6599. @samp{get_attr_@dots{}} routine. It should normally be a global
  6600. variable.
  6601. @findex eq_attr
  6602. @item (eq_attr @var{name} @var{value})
  6603. @var{name} is a string specifying the name of an attribute.
  6604. @var{value} is a string that is either a valid value for attribute
  6605. @var{name}, a comma-separated list of values, or @samp{!} followed by a
  6606. value or list. If @var{value} does not begin with a @samp{!}, this
  6607. test is true if the value of the @var{name} attribute of the current
  6608. insn is in the list specified by @var{value}. If @var{value} begins
  6609. with a @samp{!}, this test is true if the attribute's value is
  6610. @emph{not} in the specified list.
  6611. For example,
  6612. @smallexample
  6613. (eq_attr "type" "load,store")
  6614. @end smallexample
  6615. @noindent
  6616. is equivalent to
  6617. @smallexample
  6618. (ior (eq_attr "type" "load") (eq_attr "type" "store"))
  6619. @end smallexample
  6620. If @var{name} specifies an attribute of @samp{alternative}, it refers to the
  6621. value of the compiler variable @code{which_alternative}
  6622. (@pxref{Output Statement}) and the values must be small integers. For
  6623. example,
  6624. @smallexample
  6625. (eq_attr "alternative" "2,3")
  6626. @end smallexample
  6627. @noindent
  6628. is equivalent to
  6629. @smallexample
  6630. (ior (eq (symbol_ref "which_alternative") (const_int 2))
  6631. (eq (symbol_ref "which_alternative") (const_int 3)))
  6632. @end smallexample
  6633. Note that, for most attributes, an @code{eq_attr} test is simplified in cases
  6634. where the value of the attribute being tested is known for all insns matching
  6635. a particular pattern. This is by far the most common case.
  6636. @findex attr_flag
  6637. @item (attr_flag @var{name})
  6638. The value of an @code{attr_flag} expression is true if the flag
  6639. specified by @var{name} is true for the @code{insn} currently being
  6640. scheduled.
  6641. @var{name} is a string specifying one of a fixed set of flags to test.
  6642. Test the flags @code{forward} and @code{backward} to determine the
  6643. direction of a conditional branch.
  6644. This example describes a conditional branch delay slot which
  6645. can be nullified for forward branches that are taken (annul-true) or
  6646. for backward branches which are not taken (annul-false).
  6647. @smallexample
  6648. (define_delay (eq_attr "type" "cbranch")
  6649. [(eq_attr "in_branch_delay" "true")
  6650. (and (eq_attr "in_branch_delay" "true")
  6651. (attr_flag "forward"))
  6652. (and (eq_attr "in_branch_delay" "true")
  6653. (attr_flag "backward"))])
  6654. @end smallexample
  6655. The @code{forward} and @code{backward} flags are false if the current
  6656. @code{insn} being scheduled is not a conditional branch.
  6657. @code{attr_flag} is only used during delay slot scheduling and has no
  6658. meaning to other passes of the compiler.
  6659. @findex attr
  6660. @item (attr @var{name})
  6661. The value of another attribute is returned. This is most useful
  6662. for numeric attributes, as @code{eq_attr} and @code{attr_flag}
  6663. produce more efficient code for non-numeric attributes.
  6664. @end table
  6665. @end ifset
  6666. @ifset INTERNALS
  6667. @node Tagging Insns
  6668. @subsection Assigning Attribute Values to Insns
  6669. @cindex tagging insns
  6670. @cindex assigning attribute values to insns
  6671. The value assigned to an attribute of an insn is primarily determined by
  6672. which pattern is matched by that insn (or which @code{define_peephole}
  6673. generated it). Every @code{define_insn} and @code{define_peephole} can
  6674. have an optional last argument to specify the values of attributes for
  6675. matching insns. The value of any attribute not specified in a particular
  6676. insn is set to the default value for that attribute, as specified in its
  6677. @code{define_attr}. Extensive use of default values for attributes
  6678. permits the specification of the values for only one or two attributes
  6679. in the definition of most insn patterns, as seen in the example in the
  6680. next section.
  6681. The optional last argument of @code{define_insn} and
  6682. @code{define_peephole} is a vector of expressions, each of which defines
  6683. the value for a single attribute. The most general way of assigning an
  6684. attribute's value is to use a @code{set} expression whose first operand is an
  6685. @code{attr} expression giving the name of the attribute being set. The
  6686. second operand of the @code{set} is an attribute expression
  6687. (@pxref{Expressions}) giving the value of the attribute.
  6688. When the attribute value depends on the @samp{alternative} attribute
  6689. (i.e., which is the applicable alternative in the constraint of the
  6690. insn), the @code{set_attr_alternative} expression can be used. It
  6691. allows the specification of a vector of attribute expressions, one for
  6692. each alternative.
  6693. @findex set_attr
  6694. When the generality of arbitrary attribute expressions is not required,
  6695. the simpler @code{set_attr} expression can be used, which allows
  6696. specifying a string giving either a single attribute value or a list
  6697. of attribute values, one for each alternative.
  6698. The form of each of the above specifications is shown below. In each case,
  6699. @var{name} is a string specifying the attribute to be set.
  6700. @table @code
  6701. @item (set_attr @var{name} @var{value-string})
  6702. @var{value-string} is either a string giving the desired attribute value,
  6703. or a string containing a comma-separated list giving the values for
  6704. succeeding alternatives. The number of elements must match the number
  6705. of alternatives in the constraint of the insn pattern.
  6706. Note that it may be useful to specify @samp{*} for some alternative, in
  6707. which case the attribute will assume its default value for insns matching
  6708. that alternative.
  6709. @findex set_attr_alternative
  6710. @item (set_attr_alternative @var{name} [@var{value1} @var{value2} @dots{}])
  6711. Depending on the alternative of the insn, the value will be one of the
  6712. specified values. This is a shorthand for using a @code{cond} with
  6713. tests on the @samp{alternative} attribute.
  6714. @findex attr
  6715. @item (set (attr @var{name}) @var{value})
  6716. The first operand of this @code{set} must be the special RTL expression
  6717. @code{attr}, whose sole operand is a string giving the name of the
  6718. attribute being set. @var{value} is the value of the attribute.
  6719. @end table
  6720. The following shows three different ways of representing the same
  6721. attribute value specification:
  6722. @smallexample
  6723. (set_attr "type" "load,store,arith")
  6724. (set_attr_alternative "type"
  6725. [(const_string "load") (const_string "store")
  6726. (const_string "arith")])
  6727. (set (attr "type")
  6728. (cond [(eq_attr "alternative" "1") (const_string "load")
  6729. (eq_attr "alternative" "2") (const_string "store")]
  6730. (const_string "arith")))
  6731. @end smallexample
  6732. @need 1000
  6733. @findex define_asm_attributes
  6734. The @code{define_asm_attributes} expression provides a mechanism to
  6735. specify the attributes assigned to insns produced from an @code{asm}
  6736. statement. It has the form:
  6737. @smallexample
  6738. (define_asm_attributes [@var{attr-sets}])
  6739. @end smallexample
  6740. @noindent
  6741. where @var{attr-sets} is specified the same as for both the
  6742. @code{define_insn} and the @code{define_peephole} expressions.
  6743. These values will typically be the ``worst case'' attribute values. For
  6744. example, they might indicate that the condition code will be clobbered.
  6745. A specification for a @code{length} attribute is handled specially. The
  6746. way to compute the length of an @code{asm} insn is to multiply the
  6747. length specified in the expression @code{define_asm_attributes} by the
  6748. number of machine instructions specified in the @code{asm} statement,
  6749. determined by counting the number of semicolons and newlines in the
  6750. string. Therefore, the value of the @code{length} attribute specified
  6751. in a @code{define_asm_attributes} should be the maximum possible length
  6752. of a single machine instruction.
  6753. @end ifset
  6754. @ifset INTERNALS
  6755. @node Attr Example
  6756. @subsection Example of Attribute Specifications
  6757. @cindex attribute specifications example
  6758. @cindex attribute specifications
  6759. The judicious use of defaulting is important in the efficient use of
  6760. insn attributes. Typically, insns are divided into @dfn{types} and an
  6761. attribute, customarily called @code{type}, is used to represent this
  6762. value. This attribute is normally used only to define the default value
  6763. for other attributes. An example will clarify this usage.
  6764. Assume we have a RISC machine with a condition code and in which only
  6765. full-word operations are performed in registers. Let us assume that we
  6766. can divide all insns into loads, stores, (integer) arithmetic
  6767. operations, floating point operations, and branches.
  6768. Here we will concern ourselves with determining the effect of an insn on
  6769. the condition code and will limit ourselves to the following possible
  6770. effects: The condition code can be set unpredictably (clobbered), not
  6771. be changed, be set to agree with the results of the operation, or only
  6772. changed if the item previously set into the condition code has been
  6773. modified.
  6774. Here is part of a sample @file{md} file for such a machine:
  6775. @smallexample
  6776. (define_attr "type" "load,store,arith,fp,branch" (const_string "arith"))
  6777. (define_attr "cc" "clobber,unchanged,set,change0"
  6778. (cond [(eq_attr "type" "load")
  6779. (const_string "change0")
  6780. (eq_attr "type" "store,branch")
  6781. (const_string "unchanged")
  6782. (eq_attr "type" "arith")
  6783. (if_then_else (match_operand:SI 0 "" "")
  6784. (const_string "set")
  6785. (const_string "clobber"))]
  6786. (const_string "clobber")))
  6787. (define_insn ""
  6788. [(set (match_operand:SI 0 "general_operand" "=r,r,m")
  6789. (match_operand:SI 1 "general_operand" "r,m,r"))]
  6790. ""
  6791. "@@
  6792. move %0,%1
  6793. load %0,%1
  6794. store %0,%1"
  6795. [(set_attr "type" "arith,load,store")])
  6796. @end smallexample
  6797. Note that we assume in the above example that arithmetic operations
  6798. performed on quantities smaller than a machine word clobber the condition
  6799. code since they will set the condition code to a value corresponding to the
  6800. full-word result.
  6801. @end ifset
  6802. @ifset INTERNALS
  6803. @node Insn Lengths
  6804. @subsection Computing the Length of an Insn
  6805. @cindex insn lengths, computing
  6806. @cindex computing the length of an insn
  6807. For many machines, multiple types of branch instructions are provided, each
  6808. for different length branch displacements. In most cases, the assembler
  6809. will choose the correct instruction to use. However, when the assembler
  6810. cannot do so, GCC can when a special attribute, the @code{length}
  6811. attribute, is defined. This attribute must be defined to have numeric
  6812. values by specifying a null string in its @code{define_attr}.
  6813. In the case of the @code{length} attribute, two additional forms of
  6814. arithmetic terms are allowed in test expressions:
  6815. @table @code
  6816. @cindex @code{match_dup} and attributes
  6817. @item (match_dup @var{n})
  6818. This refers to the address of operand @var{n} of the current insn, which
  6819. must be a @code{label_ref}.
  6820. @cindex @code{pc} and attributes
  6821. @item (pc)
  6822. For non-branch instructions and backward branch instructions, this refers
  6823. to the address of the current insn. But for forward branch instructions,
  6824. this refers to the address of the next insn, because the length of the
  6825. current insn is to be computed.
  6826. @end table
  6827. @cindex @code{addr_vec}, length of
  6828. @cindex @code{addr_diff_vec}, length of
  6829. For normal insns, the length will be determined by value of the
  6830. @code{length} attribute. In the case of @code{addr_vec} and
  6831. @code{addr_diff_vec} insn patterns, the length is computed as
  6832. the number of vectors multiplied by the size of each vector.
  6833. Lengths are measured in addressable storage units (bytes).
  6834. Note that it is possible to call functions via the @code{symbol_ref}
  6835. mechanism to compute the length of an insn. However, if you use this
  6836. mechanism you must provide dummy clauses to express the maximum length
  6837. without using the function call. You can an example of this in the
  6838. @code{pa} machine description for the @code{call_symref} pattern.
  6839. The following macros can be used to refine the length computation:
  6840. @table @code
  6841. @findex ADJUST_INSN_LENGTH
  6842. @item ADJUST_INSN_LENGTH (@var{insn}, @var{length})
  6843. If defined, modifies the length assigned to instruction @var{insn} as a
  6844. function of the context in which it is used. @var{length} is an lvalue
  6845. that contains the initially computed length of the insn and should be
  6846. updated with the correct length of the insn.
  6847. This macro will normally not be required. A case in which it is
  6848. required is the ROMP@. On this machine, the size of an @code{addr_vec}
  6849. insn must be increased by two to compensate for the fact that alignment
  6850. may be required.
  6851. @end table
  6852. @findex get_attr_length
  6853. The routine that returns @code{get_attr_length} (the value of the
  6854. @code{length} attribute) can be used by the output routine to
  6855. determine the form of the branch instruction to be written, as the
  6856. example below illustrates.
  6857. As an example of the specification of variable-length branches, consider
  6858. the IBM 360. If we adopt the convention that a register will be set to
  6859. the starting address of a function, we can jump to labels within 4k of
  6860. the start using a four-byte instruction. Otherwise, we need a six-byte
  6861. sequence to load the address from memory and then branch to it.
  6862. On such a machine, a pattern for a branch instruction might be specified
  6863. as follows:
  6864. @smallexample
  6865. (define_insn "jump"
  6866. [(set (pc)
  6867. (label_ref (match_operand 0 "" "")))]
  6868. ""
  6869. @{
  6870. return (get_attr_length (insn) == 4
  6871. ? "b %l0" : "l r15,=a(%l0); br r15");
  6872. @}
  6873. [(set (attr "length")
  6874. (if_then_else (lt (match_dup 0) (const_int 4096))
  6875. (const_int 4)
  6876. (const_int 6)))])
  6877. @end smallexample
  6878. @end ifset
  6879. @ifset INTERNALS
  6880. @node Constant Attributes
  6881. @subsection Constant Attributes
  6882. @cindex constant attributes
  6883. A special form of @code{define_attr}, where the expression for the
  6884. default value is a @code{const} expression, indicates an attribute that
  6885. is constant for a given run of the compiler. Constant attributes may be
  6886. used to specify which variety of processor is used. For example,
  6887. @smallexample
  6888. (define_attr "cpu" "m88100,m88110,m88000"
  6889. (const
  6890. (cond [(symbol_ref "TARGET_88100") (const_string "m88100")
  6891. (symbol_ref "TARGET_88110") (const_string "m88110")]
  6892. (const_string "m88000"))))
  6893. (define_attr "memory" "fast,slow"
  6894. (const
  6895. (if_then_else (symbol_ref "TARGET_FAST_MEM")
  6896. (const_string "fast")
  6897. (const_string "slow"))))
  6898. @end smallexample
  6899. The routine generated for constant attributes has no parameters as it
  6900. does not depend on any particular insn. RTL expressions used to define
  6901. the value of a constant attribute may use the @code{symbol_ref} form,
  6902. but may not use either the @code{match_operand} form or @code{eq_attr}
  6903. forms involving insn attributes.
  6904. @end ifset
  6905. @ifset INTERNALS
  6906. @node Mnemonic Attribute
  6907. @subsection Mnemonic Attribute
  6908. @cindex mnemonic attribute
  6909. The @code{mnemonic} attribute is a string type attribute holding the
  6910. instruction mnemonic for an insn alternative. The attribute values
  6911. will automatically be generated by the machine description parser if
  6912. there is an attribute definition in the md file:
  6913. @smallexample
  6914. (define_attr "mnemonic" "unknown" (const_string "unknown"))
  6915. @end smallexample
  6916. The default value can be freely chosen as long as it does not collide
  6917. with any of the instruction mnemonics. This value will be used
  6918. whenever the machine description parser is not able to determine the
  6919. mnemonic string. This might be the case for output templates
  6920. containing more than a single instruction as in
  6921. @code{"mvcle\t%0,%1,0\;jo\t.-4"}.
  6922. The @code{mnemonic} attribute set is not generated automatically if the
  6923. instruction string is generated via C code.
  6924. An existing @code{mnemonic} attribute set in an insn definition will not
  6925. be overriden by the md file parser. That way it is possible to
  6926. manually set the instruction mnemonics for the cases where the md file
  6927. parser fails to determine it automatically.
  6928. The @code{mnemonic} attribute is useful for dealing with instruction
  6929. specific properties in the pipeline description without defining
  6930. additional insn attributes.
  6931. @smallexample
  6932. (define_attr "ooo_expanded" ""
  6933. (cond [(eq_attr "mnemonic" "dlr,dsgr,d,dsgf,stam,dsgfr,dlgr")
  6934. (const_int 1)]
  6935. (const_int 0)))
  6936. @end smallexample
  6937. @end ifset
  6938. @ifset INTERNALS
  6939. @node Delay Slots
  6940. @subsection Delay Slot Scheduling
  6941. @cindex delay slots, defining
  6942. The insn attribute mechanism can be used to specify the requirements for
  6943. delay slots, if any, on a target machine. An instruction is said to
  6944. require a @dfn{delay slot} if some instructions that are physically
  6945. after the instruction are executed as if they were located before it.
  6946. Classic examples are branch and call instructions, which often execute
  6947. the following instruction before the branch or call is performed.
  6948. On some machines, conditional branch instructions can optionally
  6949. @dfn{annul} instructions in the delay slot. This means that the
  6950. instruction will not be executed for certain branch outcomes. Both
  6951. instructions that annul if the branch is true and instructions that
  6952. annul if the branch is false are supported.
  6953. Delay slot scheduling differs from instruction scheduling in that
  6954. determining whether an instruction needs a delay slot is dependent only
  6955. on the type of instruction being generated, not on data flow between the
  6956. instructions. See the next section for a discussion of data-dependent
  6957. instruction scheduling.
  6958. @findex define_delay
  6959. The requirement of an insn needing one or more delay slots is indicated
  6960. via the @code{define_delay} expression. It has the following form:
  6961. @smallexample
  6962. (define_delay @var{test}
  6963. [@var{delay-1} @var{annul-true-1} @var{annul-false-1}
  6964. @var{delay-2} @var{annul-true-2} @var{annul-false-2}
  6965. @dots{}])
  6966. @end smallexample
  6967. @var{test} is an attribute test that indicates whether this
  6968. @code{define_delay} applies to a particular insn. If so, the number of
  6969. required delay slots is determined by the length of the vector specified
  6970. as the second argument. An insn placed in delay slot @var{n} must
  6971. satisfy attribute test @var{delay-n}. @var{annul-true-n} is an
  6972. attribute test that specifies which insns may be annulled if the branch
  6973. is true. Similarly, @var{annul-false-n} specifies which insns in the
  6974. delay slot may be annulled if the branch is false. If annulling is not
  6975. supported for that delay slot, @code{(nil)} should be coded.
  6976. For example, in the common case where branch and call insns require
  6977. a single delay slot, which may contain any insn other than a branch or
  6978. call, the following would be placed in the @file{md} file:
  6979. @smallexample
  6980. (define_delay (eq_attr "type" "branch,call")
  6981. [(eq_attr "type" "!branch,call") (nil) (nil)])
  6982. @end smallexample
  6983. Multiple @code{define_delay} expressions may be specified. In this
  6984. case, each such expression specifies different delay slot requirements
  6985. and there must be no insn for which tests in two @code{define_delay}
  6986. expressions are both true.
  6987. For example, if we have a machine that requires one delay slot for branches
  6988. but two for calls, no delay slot can contain a branch or call insn,
  6989. and any valid insn in the delay slot for the branch can be annulled if the
  6990. branch is true, we might represent this as follows:
  6991. @smallexample
  6992. (define_delay (eq_attr "type" "branch")
  6993. [(eq_attr "type" "!branch,call")
  6994. (eq_attr "type" "!branch,call")
  6995. (nil)])
  6996. (define_delay (eq_attr "type" "call")
  6997. [(eq_attr "type" "!branch,call") (nil) (nil)
  6998. (eq_attr "type" "!branch,call") (nil) (nil)])
  6999. @end smallexample
  7000. @c the above is *still* too long. --mew 4feb93
  7001. @end ifset
  7002. @ifset INTERNALS
  7003. @node Processor pipeline description
  7004. @subsection Specifying processor pipeline description
  7005. @cindex processor pipeline description
  7006. @cindex processor functional units
  7007. @cindex instruction latency time
  7008. @cindex interlock delays
  7009. @cindex data dependence delays
  7010. @cindex reservation delays
  7011. @cindex pipeline hazard recognizer
  7012. @cindex automaton based pipeline description
  7013. @cindex regular expressions
  7014. @cindex deterministic finite state automaton
  7015. @cindex automaton based scheduler
  7016. @cindex RISC
  7017. @cindex VLIW
  7018. To achieve better performance, most modern processors
  7019. (super-pipelined, superscalar @acronym{RISC}, and @acronym{VLIW}
  7020. processors) have many @dfn{functional units} on which several
  7021. instructions can be executed simultaneously. An instruction starts
  7022. execution if its issue conditions are satisfied. If not, the
  7023. instruction is stalled until its conditions are satisfied. Such
  7024. @dfn{interlock (pipeline) delay} causes interruption of the fetching
  7025. of successor instructions (or demands nop instructions, e.g.@: for some
  7026. MIPS processors).
  7027. There are two major kinds of interlock delays in modern processors.
  7028. The first one is a data dependence delay determining @dfn{instruction
  7029. latency time}. The instruction execution is not started until all
  7030. source data have been evaluated by prior instructions (there are more
  7031. complex cases when the instruction execution starts even when the data
  7032. are not available but will be ready in given time after the
  7033. instruction execution start). Taking the data dependence delays into
  7034. account is simple. The data dependence (true, output, and
  7035. anti-dependence) delay between two instructions is given by a
  7036. constant. In most cases this approach is adequate. The second kind
  7037. of interlock delays is a reservation delay. The reservation delay
  7038. means that two instructions under execution will be in need of shared
  7039. processors resources, i.e.@: buses, internal registers, and/or
  7040. functional units, which are reserved for some time. Taking this kind
  7041. of delay into account is complex especially for modern @acronym{RISC}
  7042. processors.
  7043. The task of exploiting more processor parallelism is solved by an
  7044. instruction scheduler. For a better solution to this problem, the
  7045. instruction scheduler has to have an adequate description of the
  7046. processor parallelism (or @dfn{pipeline description}). GCC
  7047. machine descriptions describe processor parallelism and functional
  7048. unit reservations for groups of instructions with the aid of
  7049. @dfn{regular expressions}.
  7050. The GCC instruction scheduler uses a @dfn{pipeline hazard recognizer} to
  7051. figure out the possibility of the instruction issue by the processor
  7052. on a given simulated processor cycle. The pipeline hazard recognizer is
  7053. automatically generated from the processor pipeline description. The
  7054. pipeline hazard recognizer generated from the machine description
  7055. is based on a deterministic finite state automaton (@acronym{DFA}):
  7056. the instruction issue is possible if there is a transition from one
  7057. automaton state to another one. This algorithm is very fast, and
  7058. furthermore, its speed is not dependent on processor
  7059. complexity@footnote{However, the size of the automaton depends on
  7060. processor complexity. To limit this effect, machine descriptions
  7061. can split orthogonal parts of the machine description among several
  7062. automata: but then, since each of these must be stepped independently,
  7063. this does cause a small decrease in the algorithm's performance.}.
  7064. @cindex automaton based pipeline description
  7065. The rest of this section describes the directives that constitute
  7066. an automaton-based processor pipeline description. The order of
  7067. these constructions within the machine description file is not
  7068. important.
  7069. @findex define_automaton
  7070. @cindex pipeline hazard recognizer
  7071. The following optional construction describes names of automata
  7072. generated and used for the pipeline hazards recognition. Sometimes
  7073. the generated finite state automaton used by the pipeline hazard
  7074. recognizer is large. If we use more than one automaton and bind functional
  7075. units to the automata, the total size of the automata is usually
  7076. less than the size of the single automaton. If there is no one such
  7077. construction, only one finite state automaton is generated.
  7078. @smallexample
  7079. (define_automaton @var{automata-names})
  7080. @end smallexample
  7081. @var{automata-names} is a string giving names of the automata. The
  7082. names are separated by commas. All the automata should have unique names.
  7083. The automaton name is used in the constructions @code{define_cpu_unit} and
  7084. @code{define_query_cpu_unit}.
  7085. @findex define_cpu_unit
  7086. @cindex processor functional units
  7087. Each processor functional unit used in the description of instruction
  7088. reservations should be described by the following construction.
  7089. @smallexample
  7090. (define_cpu_unit @var{unit-names} [@var{automaton-name}])
  7091. @end smallexample
  7092. @var{unit-names} is a string giving the names of the functional units
  7093. separated by commas. Don't use name @samp{nothing}, it is reserved
  7094. for other goals.
  7095. @var{automaton-name} is a string giving the name of the automaton with
  7096. which the unit is bound. The automaton should be described in
  7097. construction @code{define_automaton}. You should give
  7098. @dfn{automaton-name}, if there is a defined automaton.
  7099. The assignment of units to automata are constrained by the uses of the
  7100. units in insn reservations. The most important constraint is: if a
  7101. unit reservation is present on a particular cycle of an alternative
  7102. for an insn reservation, then some unit from the same automaton must
  7103. be present on the same cycle for the other alternatives of the insn
  7104. reservation. The rest of the constraints are mentioned in the
  7105. description of the subsequent constructions.
  7106. @findex define_query_cpu_unit
  7107. @cindex querying function unit reservations
  7108. The following construction describes CPU functional units analogously
  7109. to @code{define_cpu_unit}. The reservation of such units can be
  7110. queried for an automaton state. The instruction scheduler never
  7111. queries reservation of functional units for given automaton state. So
  7112. as a rule, you don't need this construction. This construction could
  7113. be used for future code generation goals (e.g.@: to generate
  7114. @acronym{VLIW} insn templates).
  7115. @smallexample
  7116. (define_query_cpu_unit @var{unit-names} [@var{automaton-name}])
  7117. @end smallexample
  7118. @var{unit-names} is a string giving names of the functional units
  7119. separated by commas.
  7120. @var{automaton-name} is a string giving the name of the automaton with
  7121. which the unit is bound.
  7122. @findex define_insn_reservation
  7123. @cindex instruction latency time
  7124. @cindex regular expressions
  7125. @cindex data bypass
  7126. The following construction is the major one to describe pipeline
  7127. characteristics of an instruction.
  7128. @smallexample
  7129. (define_insn_reservation @var{insn-name} @var{default_latency}
  7130. @var{condition} @var{regexp})
  7131. @end smallexample
  7132. @var{default_latency} is a number giving latency time of the
  7133. instruction. There is an important difference between the old
  7134. description and the automaton based pipeline description. The latency
  7135. time is used for all dependencies when we use the old description. In
  7136. the automaton based pipeline description, the given latency time is only
  7137. used for true dependencies. The cost of anti-dependencies is always
  7138. zero and the cost of output dependencies is the difference between
  7139. latency times of the producing and consuming insns (if the difference
  7140. is negative, the cost is considered to be zero). You can always
  7141. change the default costs for any description by using the target hook
  7142. @code{TARGET_SCHED_ADJUST_COST} (@pxref{Scheduling}).
  7143. @var{insn-name} is a string giving the internal name of the insn. The
  7144. internal names are used in constructions @code{define_bypass} and in
  7145. the automaton description file generated for debugging. The internal
  7146. name has nothing in common with the names in @code{define_insn}. It is a
  7147. good practice to use insn classes described in the processor manual.
  7148. @var{condition} defines what RTL insns are described by this
  7149. construction. You should remember that you will be in trouble if
  7150. @var{condition} for two or more different
  7151. @code{define_insn_reservation} constructions is TRUE for an insn. In
  7152. this case what reservation will be used for the insn is not defined.
  7153. Such cases are not checked during generation of the pipeline hazards
  7154. recognizer because in general recognizing that two conditions may have
  7155. the same value is quite difficult (especially if the conditions
  7156. contain @code{symbol_ref}). It is also not checked during the
  7157. pipeline hazard recognizer work because it would slow down the
  7158. recognizer considerably.
  7159. @var{regexp} is a string describing the reservation of the cpu's functional
  7160. units by the instruction. The reservations are described by a regular
  7161. expression according to the following syntax:
  7162. @smallexample
  7163. regexp = regexp "," oneof
  7164. | oneof
  7165. oneof = oneof "|" allof
  7166. | allof
  7167. allof = allof "+" repeat
  7168. | repeat
  7169. repeat = element "*" number
  7170. | element
  7171. element = cpu_function_unit_name
  7172. | reservation_name
  7173. | result_name
  7174. | "nothing"
  7175. | "(" regexp ")"
  7176. @end smallexample
  7177. @itemize @bullet
  7178. @item
  7179. @samp{,} is used for describing the start of the next cycle in
  7180. the reservation.
  7181. @item
  7182. @samp{|} is used for describing a reservation described by the first
  7183. regular expression @strong{or} a reservation described by the second
  7184. regular expression @strong{or} etc.
  7185. @item
  7186. @samp{+} is used for describing a reservation described by the first
  7187. regular expression @strong{and} a reservation described by the
  7188. second regular expression @strong{and} etc.
  7189. @item
  7190. @samp{*} is used for convenience and simply means a sequence in which
  7191. the regular expression are repeated @var{number} times with cycle
  7192. advancing (see @samp{,}).
  7193. @item
  7194. @samp{cpu_function_unit_name} denotes reservation of the named
  7195. functional unit.
  7196. @item
  7197. @samp{reservation_name} --- see description of construction
  7198. @samp{define_reservation}.
  7199. @item
  7200. @samp{nothing} denotes no unit reservations.
  7201. @end itemize
  7202. @findex define_reservation
  7203. Sometimes unit reservations for different insns contain common parts.
  7204. In such case, you can simplify the pipeline description by describing
  7205. the common part by the following construction
  7206. @smallexample
  7207. (define_reservation @var{reservation-name} @var{regexp})
  7208. @end smallexample
  7209. @var{reservation-name} is a string giving name of @var{regexp}.
  7210. Functional unit names and reservation names are in the same name
  7211. space. So the reservation names should be different from the
  7212. functional unit names and can not be the reserved name @samp{nothing}.
  7213. @findex define_bypass
  7214. @cindex instruction latency time
  7215. @cindex data bypass
  7216. The following construction is used to describe exceptions in the
  7217. latency time for given instruction pair. This is so called bypasses.
  7218. @smallexample
  7219. (define_bypass @var{number} @var{out_insn_names} @var{in_insn_names}
  7220. [@var{guard}])
  7221. @end smallexample
  7222. @var{number} defines when the result generated by the instructions
  7223. given in string @var{out_insn_names} will be ready for the
  7224. instructions given in string @var{in_insn_names}. Each of these
  7225. strings is a comma-separated list of filename-style globs and
  7226. they refer to the names of @code{define_insn_reservation}s.
  7227. For example:
  7228. @smallexample
  7229. (define_bypass 1 "cpu1_load_*, cpu1_store_*" "cpu1_load_*")
  7230. @end smallexample
  7231. defines a bypass between instructions that start with
  7232. @samp{cpu1_load_} or @samp{cpu1_store_} and those that start with
  7233. @samp{cpu1_load_}.
  7234. @var{guard} is an optional string giving the name of a C function which
  7235. defines an additional guard for the bypass. The function will get the
  7236. two insns as parameters. If the function returns zero the bypass will
  7237. be ignored for this case. The additional guard is necessary to
  7238. recognize complicated bypasses, e.g.@: when the consumer is only an address
  7239. of insn @samp{store} (not a stored value).
  7240. If there are more one bypass with the same output and input insns, the
  7241. chosen bypass is the first bypass with a guard in description whose
  7242. guard function returns nonzero. If there is no such bypass, then
  7243. bypass without the guard function is chosen.
  7244. @findex exclusion_set
  7245. @findex presence_set
  7246. @findex final_presence_set
  7247. @findex absence_set
  7248. @findex final_absence_set
  7249. @cindex VLIW
  7250. @cindex RISC
  7251. The following five constructions are usually used to describe
  7252. @acronym{VLIW} processors, or more precisely, to describe a placement
  7253. of small instructions into @acronym{VLIW} instruction slots. They
  7254. can be used for @acronym{RISC} processors, too.
  7255. @smallexample
  7256. (exclusion_set @var{unit-names} @var{unit-names})
  7257. (presence_set @var{unit-names} @var{patterns})
  7258. (final_presence_set @var{unit-names} @var{patterns})
  7259. (absence_set @var{unit-names} @var{patterns})
  7260. (final_absence_set @var{unit-names} @var{patterns})
  7261. @end smallexample
  7262. @var{unit-names} is a string giving names of functional units
  7263. separated by commas.
  7264. @var{patterns} is a string giving patterns of functional units
  7265. separated by comma. Currently pattern is one unit or units
  7266. separated by white-spaces.
  7267. The first construction (@samp{exclusion_set}) means that each
  7268. functional unit in the first string can not be reserved simultaneously
  7269. with a unit whose name is in the second string and vice versa. For
  7270. example, the construction is useful for describing processors
  7271. (e.g.@: some SPARC processors) with a fully pipelined floating point
  7272. functional unit which can execute simultaneously only single floating
  7273. point insns or only double floating point insns.
  7274. The second construction (@samp{presence_set}) means that each
  7275. functional unit in the first string can not be reserved unless at
  7276. least one of pattern of units whose names are in the second string is
  7277. reserved. This is an asymmetric relation. For example, it is useful
  7278. for description that @acronym{VLIW} @samp{slot1} is reserved after
  7279. @samp{slot0} reservation. We could describe it by the following
  7280. construction
  7281. @smallexample
  7282. (presence_set "slot1" "slot0")
  7283. @end smallexample
  7284. Or @samp{slot1} is reserved only after @samp{slot0} and unit @samp{b0}
  7285. reservation. In this case we could write
  7286. @smallexample
  7287. (presence_set "slot1" "slot0 b0")
  7288. @end smallexample
  7289. The third construction (@samp{final_presence_set}) is analogous to
  7290. @samp{presence_set}. The difference between them is when checking is
  7291. done. When an instruction is issued in given automaton state
  7292. reflecting all current and planned unit reservations, the automaton
  7293. state is changed. The first state is a source state, the second one
  7294. is a result state. Checking for @samp{presence_set} is done on the
  7295. source state reservation, checking for @samp{final_presence_set} is
  7296. done on the result reservation. This construction is useful to
  7297. describe a reservation which is actually two subsequent reservations.
  7298. For example, if we use
  7299. @smallexample
  7300. (presence_set "slot1" "slot0")
  7301. @end smallexample
  7302. the following insn will be never issued (because @samp{slot1} requires
  7303. @samp{slot0} which is absent in the source state).
  7304. @smallexample
  7305. (define_reservation "insn_and_nop" "slot0 + slot1")
  7306. @end smallexample
  7307. but it can be issued if we use analogous @samp{final_presence_set}.
  7308. The forth construction (@samp{absence_set}) means that each functional
  7309. unit in the first string can be reserved only if each pattern of units
  7310. whose names are in the second string is not reserved. This is an
  7311. asymmetric relation (actually @samp{exclusion_set} is analogous to
  7312. this one but it is symmetric). For example it might be useful in a
  7313. @acronym{VLIW} description to say that @samp{slot0} cannot be reserved
  7314. after either @samp{slot1} or @samp{slot2} have been reserved. This
  7315. can be described as:
  7316. @smallexample
  7317. (absence_set "slot0" "slot1, slot2")
  7318. @end smallexample
  7319. Or @samp{slot2} can not be reserved if @samp{slot0} and unit @samp{b0}
  7320. are reserved or @samp{slot1} and unit @samp{b1} are reserved. In
  7321. this case we could write
  7322. @smallexample
  7323. (absence_set "slot2" "slot0 b0, slot1 b1")
  7324. @end smallexample
  7325. All functional units mentioned in a set should belong to the same
  7326. automaton.
  7327. The last construction (@samp{final_absence_set}) is analogous to
  7328. @samp{absence_set} but checking is done on the result (state)
  7329. reservation. See comments for @samp{final_presence_set}.
  7330. @findex automata_option
  7331. @cindex deterministic finite state automaton
  7332. @cindex nondeterministic finite state automaton
  7333. @cindex finite state automaton minimization
  7334. You can control the generator of the pipeline hazard recognizer with
  7335. the following construction.
  7336. @smallexample
  7337. (automata_option @var{options})
  7338. @end smallexample
  7339. @var{options} is a string giving options which affect the generated
  7340. code. Currently there are the following options:
  7341. @itemize @bullet
  7342. @item
  7343. @dfn{no-minimization} makes no minimization of the automaton. This is
  7344. only worth to do when we are debugging the description and need to
  7345. look more accurately at reservations of states.
  7346. @item
  7347. @dfn{time} means printing time statistics about the generation of
  7348. automata.
  7349. @item
  7350. @dfn{stats} means printing statistics about the generated automata
  7351. such as the number of DFA states, NDFA states and arcs.
  7352. @item
  7353. @dfn{v} means a generation of the file describing the result automata.
  7354. The file has suffix @samp{.dfa} and can be used for the description
  7355. verification and debugging.
  7356. @item
  7357. @dfn{w} means a generation of warning instead of error for
  7358. non-critical errors.
  7359. @item
  7360. @dfn{no-comb-vect} prevents the automaton generator from generating
  7361. two data structures and comparing them for space efficiency. Using
  7362. a comb vector to represent transitions may be better, but it can be
  7363. very expensive to construct. This option is useful if the build
  7364. process spends an unacceptably long time in genautomata.
  7365. @item
  7366. @dfn{ndfa} makes nondeterministic finite state automata. This affects
  7367. the treatment of operator @samp{|} in the regular expressions. The
  7368. usual treatment of the operator is to try the first alternative and,
  7369. if the reservation is not possible, the second alternative. The
  7370. nondeterministic treatment means trying all alternatives, some of them
  7371. may be rejected by reservations in the subsequent insns.
  7372. @item
  7373. @dfn{collapse-ndfa} modifies the behaviour of the generator when
  7374. producing an automaton. An additional state transition to collapse a
  7375. nondeterministic @acronym{NDFA} state to a deterministic @acronym{DFA}
  7376. state is generated. It can be triggered by passing @code{const0_rtx} to
  7377. state_transition. In such an automaton, cycle advance transitions are
  7378. available only for these collapsed states. This option is useful for
  7379. ports that want to use the @code{ndfa} option, but also want to use
  7380. @code{define_query_cpu_unit} to assign units to insns issued in a cycle.
  7381. @item
  7382. @dfn{progress} means output of a progress bar showing how many states
  7383. were generated so far for automaton being processed. This is useful
  7384. during debugging a @acronym{DFA} description. If you see too many
  7385. generated states, you could interrupt the generator of the pipeline
  7386. hazard recognizer and try to figure out a reason for generation of the
  7387. huge automaton.
  7388. @end itemize
  7389. As an example, consider a superscalar @acronym{RISC} machine which can
  7390. issue three insns (two integer insns and one floating point insn) on
  7391. the cycle but can finish only two insns. To describe this, we define
  7392. the following functional units.
  7393. @smallexample
  7394. (define_cpu_unit "i0_pipeline, i1_pipeline, f_pipeline")
  7395. (define_cpu_unit "port0, port1")
  7396. @end smallexample
  7397. All simple integer insns can be executed in any integer pipeline and
  7398. their result is ready in two cycles. The simple integer insns are
  7399. issued into the first pipeline unless it is reserved, otherwise they
  7400. are issued into the second pipeline. Integer division and
  7401. multiplication insns can be executed only in the second integer
  7402. pipeline and their results are ready correspondingly in 8 and 4
  7403. cycles. The integer division is not pipelined, i.e.@: the subsequent
  7404. integer division insn can not be issued until the current division
  7405. insn finished. Floating point insns are fully pipelined and their
  7406. results are ready in 3 cycles. Where the result of a floating point
  7407. insn is used by an integer insn, an additional delay of one cycle is
  7408. incurred. To describe all of this we could specify
  7409. @smallexample
  7410. (define_cpu_unit "div")
  7411. (define_insn_reservation "simple" 2 (eq_attr "type" "int")
  7412. "(i0_pipeline | i1_pipeline), (port0 | port1)")
  7413. (define_insn_reservation "mult" 4 (eq_attr "type" "mult")
  7414. "i1_pipeline, nothing*2, (port0 | port1)")
  7415. (define_insn_reservation "div" 8 (eq_attr "type" "div")
  7416. "i1_pipeline, div*7, div + (port0 | port1)")
  7417. (define_insn_reservation "float" 3 (eq_attr "type" "float")
  7418. "f_pipeline, nothing, (port0 | port1))
  7419. (define_bypass 4 "float" "simple,mult,div")
  7420. @end smallexample
  7421. To simplify the description we could describe the following reservation
  7422. @smallexample
  7423. (define_reservation "finish" "port0|port1")
  7424. @end smallexample
  7425. and use it in all @code{define_insn_reservation} as in the following
  7426. construction
  7427. @smallexample
  7428. (define_insn_reservation "simple" 2 (eq_attr "type" "int")
  7429. "(i0_pipeline | i1_pipeline), finish")
  7430. @end smallexample
  7431. @end ifset
  7432. @ifset INTERNALS
  7433. @node Conditional Execution
  7434. @section Conditional Execution
  7435. @cindex conditional execution
  7436. @cindex predication
  7437. A number of architectures provide for some form of conditional
  7438. execution, or predication. The hallmark of this feature is the
  7439. ability to nullify most of the instructions in the instruction set.
  7440. When the instruction set is large and not entirely symmetric, it
  7441. can be quite tedious to describe these forms directly in the
  7442. @file{.md} file. An alternative is the @code{define_cond_exec} template.
  7443. @findex define_cond_exec
  7444. @smallexample
  7445. (define_cond_exec
  7446. [@var{predicate-pattern}]
  7447. "@var{condition}"
  7448. "@var{output-template}"
  7449. "@var{optional-insn-attribues}")
  7450. @end smallexample
  7451. @var{predicate-pattern} is the condition that must be true for the
  7452. insn to be executed at runtime and should match a relational operator.
  7453. One can use @code{match_operator} to match several relational operators
  7454. at once. Any @code{match_operand} operands must have no more than one
  7455. alternative.
  7456. @var{condition} is a C expression that must be true for the generated
  7457. pattern to match.
  7458. @findex current_insn_predicate
  7459. @var{output-template} is a string similar to the @code{define_insn}
  7460. output template (@pxref{Output Template}), except that the @samp{*}
  7461. and @samp{@@} special cases do not apply. This is only useful if the
  7462. assembly text for the predicate is a simple prefix to the main insn.
  7463. In order to handle the general case, there is a global variable
  7464. @code{current_insn_predicate} that will contain the entire predicate
  7465. if the current insn is predicated, and will otherwise be @code{NULL}.
  7466. @var{optional-insn-attributes} is an optional vector of attributes that gets
  7467. appended to the insn attributes of the produced cond_exec rtx. It can
  7468. be used to add some distinguishing attribute to cond_exec rtxs produced
  7469. that way. An example usage would be to use this attribute in conjunction
  7470. with attributes on the main pattern to disable particular alternatives under
  7471. certain conditions.
  7472. When @code{define_cond_exec} is used, an implicit reference to
  7473. the @code{predicable} instruction attribute is made.
  7474. @xref{Insn Attributes}. This attribute must be a boolean (i.e.@: have
  7475. exactly two elements in its @var{list-of-values}), with the possible
  7476. values being @code{no} and @code{yes}. The default and all uses in
  7477. the insns must be a simple constant, not a complex expressions. It
  7478. may, however, depend on the alternative, by using a comma-separated
  7479. list of values. If that is the case, the port should also define an
  7480. @code{enabled} attribute (@pxref{Disable Insn Alternatives}), which
  7481. should also allow only @code{no} and @code{yes} as its values.
  7482. For each @code{define_insn} for which the @code{predicable}
  7483. attribute is true, a new @code{define_insn} pattern will be
  7484. generated that matches a predicated version of the instruction.
  7485. For example,
  7486. @smallexample
  7487. (define_insn "addsi"
  7488. [(set (match_operand:SI 0 "register_operand" "r")
  7489. (plus:SI (match_operand:SI 1 "register_operand" "r")
  7490. (match_operand:SI 2 "register_operand" "r")))]
  7491. "@var{test1}"
  7492. "add %2,%1,%0")
  7493. (define_cond_exec
  7494. [(ne (match_operand:CC 0 "register_operand" "c")
  7495. (const_int 0))]
  7496. "@var{test2}"
  7497. "(%0)")
  7498. @end smallexample
  7499. @noindent
  7500. generates a new pattern
  7501. @smallexample
  7502. (define_insn ""
  7503. [(cond_exec
  7504. (ne (match_operand:CC 3 "register_operand" "c") (const_int 0))
  7505. (set (match_operand:SI 0 "register_operand" "r")
  7506. (plus:SI (match_operand:SI 1 "register_operand" "r")
  7507. (match_operand:SI 2 "register_operand" "r"))))]
  7508. "(@var{test2}) && (@var{test1})"
  7509. "(%3) add %2,%1,%0")
  7510. @end smallexample
  7511. @end ifset
  7512. @ifset INTERNALS
  7513. @node Define Subst
  7514. @section RTL Templates Transformations
  7515. @cindex define_subst
  7516. For some hardware architectures there are common cases when the RTL
  7517. templates for the instructions can be derived from the other RTL
  7518. templates using simple transformations. E.g., @file{i386.md} contains
  7519. an RTL template for the ordinary @code{sub} instruction---
  7520. @code{*subsi_1}, and for the @code{sub} instruction with subsequent
  7521. zero-extension---@code{*subsi_1_zext}. Such cases can be easily
  7522. implemented by a single meta-template capable of generating a modified
  7523. case based on the initial one:
  7524. @findex define_subst
  7525. @smallexample
  7526. (define_subst "@var{name}"
  7527. [@var{input-template}]
  7528. "@var{condition}"
  7529. [@var{output-template}])
  7530. @end smallexample
  7531. @var{input-template} is a pattern describing the source RTL template,
  7532. which will be transformed.
  7533. @var{condition} is a C expression that is conjunct with the condition
  7534. from the input-template to generate a condition to be used in the
  7535. output-template.
  7536. @var{output-template} is a pattern that will be used in the resulting
  7537. template.
  7538. @code{define_subst} mechanism is tightly coupled with the notion of the
  7539. subst attribute (@pxref{Subst Iterators}). The use of
  7540. @code{define_subst} is triggered by a reference to a subst attribute in
  7541. the transforming RTL template. This reference initiates duplication of
  7542. the source RTL template and substitution of the attributes with their
  7543. values. The source RTL template is left unchanged, while the copy is
  7544. transformed by @code{define_subst}. This transformation can fail in the
  7545. case when the source RTL template is not matched against the
  7546. input-template of the @code{define_subst}. In such case the copy is
  7547. deleted.
  7548. @code{define_subst} can be used only in @code{define_insn} and
  7549. @code{define_expand}, it cannot be used in other expressions (e.g. in
  7550. @code{define_insn_and_split}).
  7551. @menu
  7552. * Define Subst Example:: Example of @code{define_subst} work.
  7553. * Define Subst Pattern Matching:: Process of template comparison.
  7554. * Define Subst Output Template:: Generation of output template.
  7555. @end menu
  7556. @node Define Subst Example
  7557. @subsection @code{define_subst} Example
  7558. @cindex define_subst
  7559. To illustrate how @code{define_subst} works, let us examine a simple
  7560. template transformation.
  7561. Suppose there are two kinds of instructions: one that touches flags and
  7562. the other that does not. The instructions of the second type could be
  7563. generated with the following @code{define_subst}:
  7564. @smallexample
  7565. (define_subst "add_clobber_subst"
  7566. [(set (match_operand:SI 0 "" "")
  7567. (match_operand:SI 1 "" ""))]
  7568. ""
  7569. [(set (match_dup 0)
  7570. (match_dup 1))
  7571. (clobber (reg:CC FLAGS_REG))]
  7572. @end smallexample
  7573. This @code{define_subst} can be applied to any RTL pattern containing
  7574. @code{set} of mode SI and generates a copy with clobber when it is
  7575. applied.
  7576. Assume there is an RTL template for a @code{max} instruction to be used
  7577. in @code{define_subst} mentioned above:
  7578. @smallexample
  7579. (define_insn "maxsi"
  7580. [(set (match_operand:SI 0 "register_operand" "=r")
  7581. (max:SI
  7582. (match_operand:SI 1 "register_operand" "r")
  7583. (match_operand:SI 2 "register_operand" "r")))]
  7584. ""
  7585. "max\t@{%2, %1, %0|%0, %1, %2@}"
  7586. [@dots{}])
  7587. @end smallexample
  7588. To mark the RTL template for @code{define_subst} application,
  7589. subst-attributes are used. They should be declared in advance:
  7590. @smallexample
  7591. (define_subst_attr "add_clobber_name" "add_clobber_subst" "_noclobber" "_clobber")
  7592. @end smallexample
  7593. Here @samp{add_clobber_name} is the attribute name,
  7594. @samp{add_clobber_subst} is the name of the corresponding
  7595. @code{define_subst}, the third argument (@samp{_noclobber}) is the
  7596. attribute value that would be substituted into the unchanged version of
  7597. the source RTL template, and the last argument (@samp{_clobber}) is the
  7598. value that would be substituted into the second, transformed,
  7599. version of the RTL template.
  7600. Once the subst-attribute has been defined, it should be used in RTL
  7601. templates which need to be processed by the @code{define_subst}. So,
  7602. the original RTL template should be changed:
  7603. @smallexample
  7604. (define_insn "maxsi<add_clobber_name>"
  7605. [(set (match_operand:SI 0 "register_operand" "=r")
  7606. (max:SI
  7607. (match_operand:SI 1 "register_operand" "r")
  7608. (match_operand:SI 2 "register_operand" "r")))]
  7609. ""
  7610. "max\t@{%2, %1, %0|%0, %1, %2@}"
  7611. [@dots{}])
  7612. @end smallexample
  7613. The result of the @code{define_subst} usage would look like the following:
  7614. @smallexample
  7615. (define_insn "maxsi_noclobber"
  7616. [(set (match_operand:SI 0 "register_operand" "=r")
  7617. (max:SI
  7618. (match_operand:SI 1 "register_operand" "r")
  7619. (match_operand:SI 2 "register_operand" "r")))]
  7620. ""
  7621. "max\t@{%2, %1, %0|%0, %1, %2@}"
  7622. [@dots{}])
  7623. (define_insn "maxsi_clobber"
  7624. [(set (match_operand:SI 0 "register_operand" "=r")
  7625. (max:SI
  7626. (match_operand:SI 1 "register_operand" "r")
  7627. (match_operand:SI 2 "register_operand" "r")))
  7628. (clobber (reg:CC FLAGS_REG))]
  7629. ""
  7630. "max\t@{%2, %1, %0|%0, %1, %2@}"
  7631. [@dots{}])
  7632. @end smallexample
  7633. @node Define Subst Pattern Matching
  7634. @subsection Pattern Matching in @code{define_subst}
  7635. @cindex define_subst
  7636. All expressions, allowed in @code{define_insn} or @code{define_expand},
  7637. are allowed in the input-template of @code{define_subst}, except
  7638. @code{match_par_dup}, @code{match_scratch}, @code{match_parallel}. The
  7639. meanings of expressions in the input-template were changed:
  7640. @code{match_operand} matches any expression (possibly, a subtree in
  7641. RTL-template), if modes of the @code{match_operand} and this expression
  7642. are the same, or mode of the @code{match_operand} is @code{VOIDmode}, or
  7643. this expression is @code{match_dup}, @code{match_op_dup}. If the
  7644. expression is @code{match_operand} too, and predicate of
  7645. @code{match_operand} from the input pattern is not empty, then the
  7646. predicates are compared. That can be used for more accurate filtering
  7647. of accepted RTL-templates.
  7648. @code{match_operator} matches common operators (like @code{plus},
  7649. @code{minus}), @code{unspec}, @code{unspec_volatile} operators and
  7650. @code{match_operator}s from the original pattern if the modes match and
  7651. @code{match_operator} from the input pattern has the same number of
  7652. operands as the operator from the original pattern.
  7653. @node Define Subst Output Template
  7654. @subsection Generation of output template in @code{define_subst}
  7655. @cindex define_subst
  7656. If all necessary checks for @code{define_subst} application pass, a new
  7657. RTL-pattern, based on the output-template, is created to replace the old
  7658. template. Like in input-patterns, meanings of some RTL expressions are
  7659. changed when they are used in output-patterns of a @code{define_subst}.
  7660. Thus, @code{match_dup} is used for copying the whole expression from the
  7661. original pattern, which matched corresponding @code{match_operand} from
  7662. the input pattern.
  7663. @code{match_dup N} is used in the output template to be replaced with
  7664. the expression from the original pattern, which matched
  7665. @code{match_operand N} from the input pattern. As a consequence,
  7666. @code{match_dup} cannot be used to point to @code{match_operand}s from
  7667. the output pattern, it should always refer to a @code{match_operand}
  7668. from the input pattern.
  7669. In the output template one can refer to the expressions from the
  7670. original pattern and create new ones. For instance, some operands could
  7671. be added by means of standard @code{match_operand}.
  7672. After replacing @code{match_dup} with some RTL-subtree from the original
  7673. pattern, it could happen that several @code{match_operand}s in the
  7674. output pattern have the same indexes. It is unknown, how many and what
  7675. indexes would be used in the expression which would replace
  7676. @code{match_dup}, so such conflicts in indexes are inevitable. To
  7677. overcome this issue, @code{match_operands} and @code{match_operators},
  7678. which were introduced into the output pattern, are renumerated when all
  7679. @code{match_dup}s are replaced.
  7680. Number of alternatives in @code{match_operand}s introduced into the
  7681. output template @code{M} could differ from the number of alternatives in
  7682. the original pattern @code{N}, so in the resultant pattern there would
  7683. be @code{N*M} alternatives. Thus, constraints from the original pattern
  7684. would be duplicated @code{N} times, constraints from the output pattern
  7685. would be duplicated @code{M} times, producing all possible combinations.
  7686. @end ifset
  7687. @ifset INTERNALS
  7688. @node Constant Definitions
  7689. @section Constant Definitions
  7690. @cindex constant definitions
  7691. @findex define_constants
  7692. Using literal constants inside instruction patterns reduces legibility and
  7693. can be a maintenance problem.
  7694. To overcome this problem, you may use the @code{define_constants}
  7695. expression. It contains a vector of name-value pairs. From that
  7696. point on, wherever any of the names appears in the MD file, it is as
  7697. if the corresponding value had been written instead. You may use
  7698. @code{define_constants} multiple times; each appearance adds more
  7699. constants to the table. It is an error to redefine a constant with
  7700. a different value.
  7701. To come back to the a29k load multiple example, instead of
  7702. @smallexample
  7703. (define_insn ""
  7704. [(match_parallel 0 "load_multiple_operation"
  7705. [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
  7706. (match_operand:SI 2 "memory_operand" "m"))
  7707. (use (reg:SI 179))
  7708. (clobber (reg:SI 179))])]
  7709. ""
  7710. "loadm 0,0,%1,%2")
  7711. @end smallexample
  7712. You could write:
  7713. @smallexample
  7714. (define_constants [
  7715. (R_BP 177)
  7716. (R_FC 178)
  7717. (R_CR 179)
  7718. (R_Q 180)
  7719. ])
  7720. (define_insn ""
  7721. [(match_parallel 0 "load_multiple_operation"
  7722. [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
  7723. (match_operand:SI 2 "memory_operand" "m"))
  7724. (use (reg:SI R_CR))
  7725. (clobber (reg:SI R_CR))])]
  7726. ""
  7727. "loadm 0,0,%1,%2")
  7728. @end smallexample
  7729. The constants that are defined with a define_constant are also output
  7730. in the insn-codes.h header file as #defines.
  7731. @cindex enumerations
  7732. @findex define_c_enum
  7733. You can also use the machine description file to define enumerations.
  7734. Like the constants defined by @code{define_constant}, these enumerations
  7735. are visible to both the machine description file and the main C code.
  7736. The syntax is as follows:
  7737. @smallexample
  7738. (define_c_enum "@var{name}" [
  7739. @var{value0}
  7740. @var{value1}
  7741. @dots{}
  7742. @var{valuen}
  7743. ])
  7744. @end smallexample
  7745. This definition causes the equivalent of the following C code to appear
  7746. in @file{insn-constants.h}:
  7747. @smallexample
  7748. enum @var{name} @{
  7749. @var{value0} = 0,
  7750. @var{value1} = 1,
  7751. @dots{}
  7752. @var{valuen} = @var{n}
  7753. @};
  7754. #define NUM_@var{cname}_VALUES (@var{n} + 1)
  7755. @end smallexample
  7756. where @var{cname} is the capitalized form of @var{name}.
  7757. It also makes each @var{valuei} available in the machine description
  7758. file, just as if it had been declared with:
  7759. @smallexample
  7760. (define_constants [(@var{valuei} @var{i})])
  7761. @end smallexample
  7762. Each @var{valuei} is usually an upper-case identifier and usually
  7763. begins with @var{cname}.
  7764. You can split the enumeration definition into as many statements as
  7765. you like. The above example is directly equivalent to:
  7766. @smallexample
  7767. (define_c_enum "@var{name}" [@var{value0}])
  7768. (define_c_enum "@var{name}" [@var{value1}])
  7769. @dots{}
  7770. (define_c_enum "@var{name}" [@var{valuen}])
  7771. @end smallexample
  7772. Splitting the enumeration helps to improve the modularity of each
  7773. individual @code{.md} file. For example, if a port defines its
  7774. synchronization instructions in a separate @file{sync.md} file,
  7775. it is convenient to define all synchronization-specific enumeration
  7776. values in @file{sync.md} rather than in the main @file{.md} file.
  7777. Some enumeration names have special significance to GCC:
  7778. @table @code
  7779. @item unspecv
  7780. @findex unspec_volatile
  7781. If an enumeration called @code{unspecv} is defined, GCC will use it
  7782. when printing out @code{unspec_volatile} expressions. For example:
  7783. @smallexample
  7784. (define_c_enum "unspecv" [
  7785. UNSPECV_BLOCKAGE
  7786. ])
  7787. @end smallexample
  7788. causes GCC to print @samp{(unspec_volatile @dots{} 0)} as:
  7789. @smallexample
  7790. (unspec_volatile ... UNSPECV_BLOCKAGE)
  7791. @end smallexample
  7792. @item unspec
  7793. @findex unspec
  7794. If an enumeration called @code{unspec} is defined, GCC will use
  7795. it when printing out @code{unspec} expressions. GCC will also use
  7796. it when printing out @code{unspec_volatile} expressions unless an
  7797. @code{unspecv} enumeration is also defined. You can therefore
  7798. decide whether to keep separate enumerations for volatile and
  7799. non-volatile expressions or whether to use the same enumeration
  7800. for both.
  7801. @end table
  7802. @findex define_enum
  7803. @anchor{define_enum}
  7804. Another way of defining an enumeration is to use @code{define_enum}:
  7805. @smallexample
  7806. (define_enum "@var{name}" [
  7807. @var{value0}
  7808. @var{value1}
  7809. @dots{}
  7810. @var{valuen}
  7811. ])
  7812. @end smallexample
  7813. This directive implies:
  7814. @smallexample
  7815. (define_c_enum "@var{name}" [
  7816. @var{cname}_@var{cvalue0}
  7817. @var{cname}_@var{cvalue1}
  7818. @dots{}
  7819. @var{cname}_@var{cvaluen}
  7820. ])
  7821. @end smallexample
  7822. @findex define_enum_attr
  7823. where @var{cvaluei} is the capitalized form of @var{valuei}.
  7824. However, unlike @code{define_c_enum}, the enumerations defined
  7825. by @code{define_enum} can be used in attribute specifications
  7826. (@pxref{define_enum_attr}).
  7827. @end ifset
  7828. @ifset INTERNALS
  7829. @node Iterators
  7830. @section Iterators
  7831. @cindex iterators in @file{.md} files
  7832. Ports often need to define similar patterns for more than one machine
  7833. mode or for more than one rtx code. GCC provides some simple iterator
  7834. facilities to make this process easier.
  7835. @menu
  7836. * Mode Iterators:: Generating variations of patterns for different modes.
  7837. * Code Iterators:: Doing the same for codes.
  7838. * Int Iterators:: Doing the same for integers.
  7839. * Subst Iterators:: Generating variations of patterns for define_subst.
  7840. @end menu
  7841. @node Mode Iterators
  7842. @subsection Mode Iterators
  7843. @cindex mode iterators in @file{.md} files
  7844. Ports often need to define similar patterns for two or more different modes.
  7845. For example:
  7846. @itemize @bullet
  7847. @item
  7848. If a processor has hardware support for both single and double
  7849. floating-point arithmetic, the @code{SFmode} patterns tend to be
  7850. very similar to the @code{DFmode} ones.
  7851. @item
  7852. If a port uses @code{SImode} pointers in one configuration and
  7853. @code{DImode} pointers in another, it will usually have very similar
  7854. @code{SImode} and @code{DImode} patterns for manipulating pointers.
  7855. @end itemize
  7856. Mode iterators allow several patterns to be instantiated from one
  7857. @file{.md} file template. They can be used with any type of
  7858. rtx-based construct, such as a @code{define_insn},
  7859. @code{define_split}, or @code{define_peephole2}.
  7860. @menu
  7861. * Defining Mode Iterators:: Defining a new mode iterator.
  7862. * Substitutions:: Combining mode iterators with substitutions
  7863. * Examples:: Examples
  7864. @end menu
  7865. @node Defining Mode Iterators
  7866. @subsubsection Defining Mode Iterators
  7867. @findex define_mode_iterator
  7868. The syntax for defining a mode iterator is:
  7869. @smallexample
  7870. (define_mode_iterator @var{name} [(@var{mode1} "@var{cond1}") @dots{} (@var{moden} "@var{condn}")])
  7871. @end smallexample
  7872. This allows subsequent @file{.md} file constructs to use the mode suffix
  7873. @code{:@var{name}}. Every construct that does so will be expanded
  7874. @var{n} times, once with every use of @code{:@var{name}} replaced by
  7875. @code{:@var{mode1}}, once with every use replaced by @code{:@var{mode2}},
  7876. and so on. In the expansion for a particular @var{modei}, every
  7877. C condition will also require that @var{condi} be true.
  7878. For example:
  7879. @smallexample
  7880. (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
  7881. @end smallexample
  7882. defines a new mode suffix @code{:P}. Every construct that uses
  7883. @code{:P} will be expanded twice, once with every @code{:P} replaced
  7884. by @code{:SI} and once with every @code{:P} replaced by @code{:DI}.
  7885. The @code{:SI} version will only apply if @code{Pmode == SImode} and
  7886. the @code{:DI} version will only apply if @code{Pmode == DImode}.
  7887. As with other @file{.md} conditions, an empty string is treated
  7888. as ``always true''. @code{(@var{mode} "")} can also be abbreviated
  7889. to @code{@var{mode}}. For example:
  7890. @smallexample
  7891. (define_mode_iterator GPR [SI (DI "TARGET_64BIT")])
  7892. @end smallexample
  7893. means that the @code{:DI} expansion only applies if @code{TARGET_64BIT}
  7894. but that the @code{:SI} expansion has no such constraint.
  7895. Iterators are applied in the order they are defined. This can be
  7896. significant if two iterators are used in a construct that requires
  7897. substitutions. @xref{Substitutions}.
  7898. @node Substitutions
  7899. @subsubsection Substitution in Mode Iterators
  7900. @findex define_mode_attr
  7901. If an @file{.md} file construct uses mode iterators, each version of the
  7902. construct will often need slightly different strings or modes. For
  7903. example:
  7904. @itemize @bullet
  7905. @item
  7906. When a @code{define_expand} defines several @code{add@var{m}3} patterns
  7907. (@pxref{Standard Names}), each expander will need to use the
  7908. appropriate mode name for @var{m}.
  7909. @item
  7910. When a @code{define_insn} defines several instruction patterns,
  7911. each instruction will often use a different assembler mnemonic.
  7912. @item
  7913. When a @code{define_insn} requires operands with different modes,
  7914. using an iterator for one of the operand modes usually requires a specific
  7915. mode for the other operand(s).
  7916. @end itemize
  7917. GCC supports such variations through a system of ``mode attributes''.
  7918. There are two standard attributes: @code{mode}, which is the name of
  7919. the mode in lower case, and @code{MODE}, which is the same thing in
  7920. upper case. You can define other attributes using:
  7921. @smallexample
  7922. (define_mode_attr @var{name} [(@var{mode1} "@var{value1}") @dots{} (@var{moden} "@var{valuen}")])
  7923. @end smallexample
  7924. where @var{name} is the name of the attribute and @var{valuei}
  7925. is the value associated with @var{modei}.
  7926. When GCC replaces some @var{:iterator} with @var{:mode}, it will scan
  7927. each string and mode in the pattern for sequences of the form
  7928. @code{<@var{iterator}:@var{attr}>}, where @var{attr} is the name of a
  7929. mode attribute. If the attribute is defined for @var{mode}, the whole
  7930. @code{<@dots{}>} sequence will be replaced by the appropriate attribute
  7931. value.
  7932. For example, suppose an @file{.md} file has:
  7933. @smallexample
  7934. (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
  7935. (define_mode_attr load [(SI "lw") (DI "ld")])
  7936. @end smallexample
  7937. If one of the patterns that uses @code{:P} contains the string
  7938. @code{"<P:load>\t%0,%1"}, the @code{SI} version of that pattern
  7939. will use @code{"lw\t%0,%1"} and the @code{DI} version will use
  7940. @code{"ld\t%0,%1"}.
  7941. Here is an example of using an attribute for a mode:
  7942. @smallexample
  7943. (define_mode_iterator LONG [SI DI])
  7944. (define_mode_attr SHORT [(SI "HI") (DI "SI")])
  7945. (define_insn @dots{}
  7946. (sign_extend:LONG (match_operand:<LONG:SHORT> @dots{})) @dots{})
  7947. @end smallexample
  7948. The @code{@var{iterator}:} prefix may be omitted, in which case the
  7949. substitution will be attempted for every iterator expansion.
  7950. @node Examples
  7951. @subsubsection Mode Iterator Examples
  7952. Here is an example from the MIPS port. It defines the following
  7953. modes and attributes (among others):
  7954. @smallexample
  7955. (define_mode_iterator GPR [SI (DI "TARGET_64BIT")])
  7956. (define_mode_attr d [(SI "") (DI "d")])
  7957. @end smallexample
  7958. and uses the following template to define both @code{subsi3}
  7959. and @code{subdi3}:
  7960. @smallexample
  7961. (define_insn "sub<mode>3"
  7962. [(set (match_operand:GPR 0 "register_operand" "=d")
  7963. (minus:GPR (match_operand:GPR 1 "register_operand" "d")
  7964. (match_operand:GPR 2 "register_operand" "d")))]
  7965. ""
  7966. "<d>subu\t%0,%1,%2"
  7967. [(set_attr "type" "arith")
  7968. (set_attr "mode" "<MODE>")])
  7969. @end smallexample
  7970. This is exactly equivalent to:
  7971. @smallexample
  7972. (define_insn "subsi3"
  7973. [(set (match_operand:SI 0 "register_operand" "=d")
  7974. (minus:SI (match_operand:SI 1 "register_operand" "d")
  7975. (match_operand:SI 2 "register_operand" "d")))]
  7976. ""
  7977. "subu\t%0,%1,%2"
  7978. [(set_attr "type" "arith")
  7979. (set_attr "mode" "SI")])
  7980. (define_insn "subdi3"
  7981. [(set (match_operand:DI 0 "register_operand" "=d")
  7982. (minus:DI (match_operand:DI 1 "register_operand" "d")
  7983. (match_operand:DI 2 "register_operand" "d")))]
  7984. ""
  7985. "dsubu\t%0,%1,%2"
  7986. [(set_attr "type" "arith")
  7987. (set_attr "mode" "DI")])
  7988. @end smallexample
  7989. @node Code Iterators
  7990. @subsection Code Iterators
  7991. @cindex code iterators in @file{.md} files
  7992. @findex define_code_iterator
  7993. @findex define_code_attr
  7994. Code iterators operate in a similar way to mode iterators. @xref{Mode Iterators}.
  7995. The construct:
  7996. @smallexample
  7997. (define_code_iterator @var{name} [(@var{code1} "@var{cond1}") @dots{} (@var{coden} "@var{condn}")])
  7998. @end smallexample
  7999. defines a pseudo rtx code @var{name} that can be instantiated as
  8000. @var{codei} if condition @var{condi} is true. Each @var{codei}
  8001. must have the same rtx format. @xref{RTL Classes}.
  8002. As with mode iterators, each pattern that uses @var{name} will be
  8003. expanded @var{n} times, once with all uses of @var{name} replaced by
  8004. @var{code1}, once with all uses replaced by @var{code2}, and so on.
  8005. @xref{Defining Mode Iterators}.
  8006. It is possible to define attributes for codes as well as for modes.
  8007. There are two standard code attributes: @code{code}, the name of the
  8008. code in lower case, and @code{CODE}, the name of the code in upper case.
  8009. Other attributes are defined using:
  8010. @smallexample
  8011. (define_code_attr @var{name} [(@var{code1} "@var{value1}") @dots{} (@var{coden} "@var{valuen}")])
  8012. @end smallexample
  8013. Here's an example of code iterators in action, taken from the MIPS port:
  8014. @smallexample
  8015. (define_code_iterator any_cond [unordered ordered unlt unge uneq ltgt unle ungt
  8016. eq ne gt ge lt le gtu geu ltu leu])
  8017. (define_expand "b<code>"
  8018. [(set (pc)
  8019. (if_then_else (any_cond:CC (cc0)
  8020. (const_int 0))
  8021. (label_ref (match_operand 0 ""))
  8022. (pc)))]
  8023. ""
  8024. @{
  8025. gen_conditional_branch (operands, <CODE>);
  8026. DONE;
  8027. @})
  8028. @end smallexample
  8029. This is equivalent to:
  8030. @smallexample
  8031. (define_expand "bunordered"
  8032. [(set (pc)
  8033. (if_then_else (unordered:CC (cc0)
  8034. (const_int 0))
  8035. (label_ref (match_operand 0 ""))
  8036. (pc)))]
  8037. ""
  8038. @{
  8039. gen_conditional_branch (operands, UNORDERED);
  8040. DONE;
  8041. @})
  8042. (define_expand "bordered"
  8043. [(set (pc)
  8044. (if_then_else (ordered:CC (cc0)
  8045. (const_int 0))
  8046. (label_ref (match_operand 0 ""))
  8047. (pc)))]
  8048. ""
  8049. @{
  8050. gen_conditional_branch (operands, ORDERED);
  8051. DONE;
  8052. @})
  8053. @dots{}
  8054. @end smallexample
  8055. @node Int Iterators
  8056. @subsection Int Iterators
  8057. @cindex int iterators in @file{.md} files
  8058. @findex define_int_iterator
  8059. @findex define_int_attr
  8060. Int iterators operate in a similar way to code iterators. @xref{Code Iterators}.
  8061. The construct:
  8062. @smallexample
  8063. (define_int_iterator @var{name} [(@var{int1} "@var{cond1}") @dots{} (@var{intn} "@var{condn}")])
  8064. @end smallexample
  8065. defines a pseudo integer constant @var{name} that can be instantiated as
  8066. @var{inti} if condition @var{condi} is true. Each @var{int}
  8067. must have the same rtx format. @xref{RTL Classes}. Int iterators can appear
  8068. in only those rtx fields that have 'i' as the specifier. This means that
  8069. each @var{int} has to be a constant defined using define_constant or
  8070. define_c_enum.
  8071. As with mode and code iterators, each pattern that uses @var{name} will be
  8072. expanded @var{n} times, once with all uses of @var{name} replaced by
  8073. @var{int1}, once with all uses replaced by @var{int2}, and so on.
  8074. @xref{Defining Mode Iterators}.
  8075. It is possible to define attributes for ints as well as for codes and modes.
  8076. Attributes are defined using:
  8077. @smallexample
  8078. (define_int_attr @var{name} [(@var{int1} "@var{value1}") @dots{} (@var{intn} "@var{valuen}")])
  8079. @end smallexample
  8080. Here's an example of int iterators in action, taken from the ARM port:
  8081. @smallexample
  8082. (define_int_iterator QABSNEG [UNSPEC_VQABS UNSPEC_VQNEG])
  8083. (define_int_attr absneg [(UNSPEC_VQABS "abs") (UNSPEC_VQNEG "neg")])
  8084. (define_insn "neon_vq<absneg><mode>"
  8085. [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
  8086. (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
  8087. (match_operand:SI 2 "immediate_operand" "i")]
  8088. QABSNEG))]
  8089. "TARGET_NEON"
  8090. "vq<absneg>.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
  8091. [(set_attr "type" "neon_vqneg_vqabs")]
  8092. )
  8093. @end smallexample
  8094. This is equivalent to:
  8095. @smallexample
  8096. (define_insn "neon_vqabs<mode>"
  8097. [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
  8098. (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
  8099. (match_operand:SI 2 "immediate_operand" "i")]
  8100. UNSPEC_VQABS))]
  8101. "TARGET_NEON"
  8102. "vqabs.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
  8103. [(set_attr "type" "neon_vqneg_vqabs")]
  8104. )
  8105. (define_insn "neon_vqneg<mode>"
  8106. [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
  8107. (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
  8108. (match_operand:SI 2 "immediate_operand" "i")]
  8109. UNSPEC_VQNEG))]
  8110. "TARGET_NEON"
  8111. "vqneg.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
  8112. [(set_attr "type" "neon_vqneg_vqabs")]
  8113. )
  8114. @end smallexample
  8115. @node Subst Iterators
  8116. @subsection Subst Iterators
  8117. @cindex subst iterators in @file{.md} files
  8118. @findex define_subst
  8119. @findex define_subst_attr
  8120. Subst iterators are special type of iterators with the following
  8121. restrictions: they could not be declared explicitly, they always have
  8122. only two values, and they do not have explicit dedicated name.
  8123. Subst-iterators are triggered only when corresponding subst-attribute is
  8124. used in RTL-pattern.
  8125. Subst iterators transform templates in the following way: the templates
  8126. are duplicated, the subst-attributes in these templates are replaced
  8127. with the corresponding values, and a new attribute is implicitly added
  8128. to the given @code{define_insn}/@code{define_expand}. The name of the
  8129. added attribute matches the name of @code{define_subst}. Such
  8130. attributes are declared implicitly, and it is not allowed to have a
  8131. @code{define_attr} named as a @code{define_subst}.
  8132. Each subst iterator is linked to a @code{define_subst}. It is declared
  8133. implicitly by the first appearance of the corresponding
  8134. @code{define_subst_attr}, and it is not allowed to define it explicitly.
  8135. Declarations of subst-attributes have the following syntax:
  8136. @findex define_subst_attr
  8137. @smallexample
  8138. (define_subst_attr "@var{name}"
  8139. "@var{subst-name}"
  8140. "@var{no-subst-value}"
  8141. "@var{subst-applied-value}")
  8142. @end smallexample
  8143. @var{name} is a string with which the given subst-attribute could be
  8144. referred to.
  8145. @var{subst-name} shows which @code{define_subst} should be applied to an
  8146. RTL-template if the given subst-attribute is present in the
  8147. RTL-template.
  8148. @var{no-subst-value} is a value with which subst-attribute would be
  8149. replaced in the first copy of the original RTL-template.
  8150. @var{subst-applied-value} is a value with which subst-attribute would be
  8151. replaced in the second copy of the original RTL-template.
  8152. @end ifset