extend.texi 756 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320
  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. @node C Extensions
  5. @chapter Extensions to the C Language Family
  6. @cindex extensions, C language
  7. @cindex C language extensions
  8. @opindex pedantic
  9. GNU C provides several language features not found in ISO standard C@.
  10. (The @option{-pedantic} option directs GCC to print a warning message if
  11. any of these features is used.) To test for the availability of these
  12. features in conditional compilation, check for a predefined macro
  13. @code{__GNUC__}, which is always defined under GCC@.
  14. These extensions are available in C and Objective-C@. Most of them are
  15. also available in C++. @xref{C++ Extensions,,Extensions to the
  16. C++ Language}, for extensions that apply @emph{only} to C++.
  17. Some features that are in ISO C99 but not C90 or C++ are also, as
  18. extensions, accepted by GCC in C90 mode and in C++.
  19. @menu
  20. * Statement Exprs:: Putting statements and declarations inside expressions.
  21. * Local Labels:: Labels local to a block.
  22. * Labels as Values:: Getting pointers to labels, and computed gotos.
  23. * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
  24. * Constructing Calls:: Dispatching a call to another function.
  25. * Typeof:: @code{typeof}: referring to the type of an expression.
  26. * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
  27. * __int128:: 128-bit integers---@code{__int128}.
  28. * Long Long:: Double-word integers---@code{long long int}.
  29. * Complex:: Data types for complex numbers.
  30. * Floating Types:: Additional Floating Types.
  31. * Half-Precision:: Half-Precision Floating Point.
  32. * Decimal Float:: Decimal Floating Types.
  33. * Hex Floats:: Hexadecimal floating-point constants.
  34. * Fixed-Point:: Fixed-Point Types.
  35. * Named Address Spaces::Named address spaces.
  36. * Zero Length:: Zero-length arrays.
  37. * Empty Structures:: Structures with no members.
  38. * Variable Length:: Arrays whose length is computed at run time.
  39. * Variadic Macros:: Macros with a variable number of arguments.
  40. * Escaped Newlines:: Slightly looser rules for escaped newlines.
  41. * Subscripting:: Any array can be subscripted, even if not an lvalue.
  42. * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
  43. * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
  44. * Initializers:: Non-constant initializers.
  45. * Compound Literals:: Compound literals give structures, unions
  46. or arrays as values.
  47. * Designated Inits:: Labeling elements of initializers.
  48. * Case Ranges:: `case 1 ... 9' and such.
  49. * Cast to Union:: Casting to union type from any member of the union.
  50. * Mixed Declarations:: Mixing declarations and code.
  51. * Function Attributes:: Declaring that functions have no side effects,
  52. or that they can never return.
  53. * Label Attributes:: Specifying attributes on labels.
  54. * Attribute Syntax:: Formal syntax for attributes.
  55. * Function Prototypes:: Prototype declarations and old-style definitions.
  56. * C++ Comments:: C++ comments are recognized.
  57. * Dollar Signs:: Dollar sign is allowed in identifiers.
  58. * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
  59. * Variable Attributes:: Specifying attributes of variables.
  60. * Type Attributes:: Specifying attributes of types.
  61. * Alignment:: Inquiring about the alignment of a type or variable.
  62. * Inline:: Defining inline functions (as fast as macros).
  63. * Volatiles:: What constitutes an access to a volatile object.
  64. * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
  65. * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
  66. * Incomplete Enums:: @code{enum foo;}, with details to follow.
  67. * Function Names:: Printable strings which are the name of the current
  68. function.
  69. * Return Address:: Getting the return or frame address of a function.
  70. * Vector Extensions:: Using vector instructions through built-in functions.
  71. * Offsetof:: Special syntax for implementing @code{offsetof}.
  72. * __sync Builtins:: Legacy built-in functions for atomic memory access.
  73. * __atomic Builtins:: Atomic built-in functions with memory model.
  74. * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
  75. arithmetic overflow checking.
  76. * x86 specific memory model extensions for transactional memory:: x86 memory models.
  77. * Object Size Checking:: Built-in functions for limited buffer overflow
  78. checking.
  79. * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
  80. * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
  81. * Other Builtins:: Other built-in functions.
  82. * Target Builtins:: Built-in functions specific to particular targets.
  83. * Target Format Checks:: Format checks specific to particular targets.
  84. * Pragmas:: Pragmas accepted by GCC.
  85. * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
  86. * Thread-Local:: Per-thread variables.
  87. * Binary constants:: Binary constants using the @samp{0b} prefix.
  88. @end menu
  89. @node Statement Exprs
  90. @section Statements and Declarations in Expressions
  91. @cindex statements inside expressions
  92. @cindex declarations inside expressions
  93. @cindex expressions containing statements
  94. @cindex macros, statements in expressions
  95. @c the above section title wrapped and causes an underfull hbox.. i
  96. @c changed it from "within" to "in". --mew 4feb93
  97. A compound statement enclosed in parentheses may appear as an expression
  98. in GNU C@. This allows you to use loops, switches, and local variables
  99. within an expression.
  100. Recall that a compound statement is a sequence of statements surrounded
  101. by braces; in this construct, parentheses go around the braces. For
  102. example:
  103. @smallexample
  104. (@{ int y = foo (); int z;
  105. if (y > 0) z = y;
  106. else z = - y;
  107. z; @})
  108. @end smallexample
  109. @noindent
  110. is a valid (though slightly more complex than necessary) expression
  111. for the absolute value of @code{foo ()}.
  112. The last thing in the compound statement should be an expression
  113. followed by a semicolon; the value of this subexpression serves as the
  114. value of the entire construct. (If you use some other kind of statement
  115. last within the braces, the construct has type @code{void}, and thus
  116. effectively no value.)
  117. This feature is especially useful in making macro definitions ``safe'' (so
  118. that they evaluate each operand exactly once). For example, the
  119. ``maximum'' function is commonly defined as a macro in standard C as
  120. follows:
  121. @smallexample
  122. #define max(a,b) ((a) > (b) ? (a) : (b))
  123. @end smallexample
  124. @noindent
  125. @cindex side effects, macro argument
  126. But this definition computes either @var{a} or @var{b} twice, with bad
  127. results if the operand has side effects. In GNU C, if you know the
  128. type of the operands (here taken as @code{int}), you can define
  129. the macro safely as follows:
  130. @smallexample
  131. #define maxint(a,b) \
  132. (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
  133. @end smallexample
  134. Embedded statements are not allowed in constant expressions, such as
  135. the value of an enumeration constant, the width of a bit-field, or
  136. the initial value of a static variable.
  137. If you don't know the type of the operand, you can still do this, but you
  138. must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
  139. In G++, the result value of a statement expression undergoes array and
  140. function pointer decay, and is returned by value to the enclosing
  141. expression. For instance, if @code{A} is a class, then
  142. @smallexample
  143. A a;
  144. (@{a;@}).Foo ()
  145. @end smallexample
  146. @noindent
  147. constructs a temporary @code{A} object to hold the result of the
  148. statement expression, and that is used to invoke @code{Foo}.
  149. Therefore the @code{this} pointer observed by @code{Foo} is not the
  150. address of @code{a}.
  151. In a statement expression, any temporaries created within a statement
  152. are destroyed at that statement's end. This makes statement
  153. expressions inside macros slightly different from function calls. In
  154. the latter case temporaries introduced during argument evaluation are
  155. destroyed at the end of the statement that includes the function
  156. call. In the statement expression case they are destroyed during
  157. the statement expression. For instance,
  158. @smallexample
  159. #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
  160. template<typename T> T function(T a) @{ T b = a; return b + 3; @}
  161. void foo ()
  162. @{
  163. macro (X ());
  164. function (X ());
  165. @}
  166. @end smallexample
  167. @noindent
  168. has different places where temporaries are destroyed. For the
  169. @code{macro} case, the temporary @code{X} is destroyed just after
  170. the initialization of @code{b}. In the @code{function} case that
  171. temporary is destroyed when the function returns.
  172. These considerations mean that it is probably a bad idea to use
  173. statement expressions of this form in header files that are designed to
  174. work with C++. (Note that some versions of the GNU C Library contained
  175. header files using statement expressions that lead to precisely this
  176. bug.)
  177. Jumping into a statement expression with @code{goto} or using a
  178. @code{switch} statement outside the statement expression with a
  179. @code{case} or @code{default} label inside the statement expression is
  180. not permitted. Jumping into a statement expression with a computed
  181. @code{goto} (@pxref{Labels as Values}) has undefined behavior.
  182. Jumping out of a statement expression is permitted, but if the
  183. statement expression is part of a larger expression then it is
  184. unspecified which other subexpressions of that expression have been
  185. evaluated except where the language definition requires certain
  186. subexpressions to be evaluated before or after the statement
  187. expression. In any case, as with a function call, the evaluation of a
  188. statement expression is not interleaved with the evaluation of other
  189. parts of the containing expression. For example,
  190. @smallexample
  191. foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
  192. @end smallexample
  193. @noindent
  194. calls @code{foo} and @code{bar1} and does not call @code{baz} but
  195. may or may not call @code{bar2}. If @code{bar2} is called, it is
  196. called after @code{foo} and before @code{bar1}.
  197. @node Local Labels
  198. @section Locally Declared Labels
  199. @cindex local labels
  200. @cindex macros, local labels
  201. GCC allows you to declare @dfn{local labels} in any nested block
  202. scope. A local label is just like an ordinary label, but you can
  203. only reference it (with a @code{goto} statement, or by taking its
  204. address) within the block in which it is declared.
  205. A local label declaration looks like this:
  206. @smallexample
  207. __label__ @var{label};
  208. @end smallexample
  209. @noindent
  210. or
  211. @smallexample
  212. __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
  213. @end smallexample
  214. Local label declarations must come at the beginning of the block,
  215. before any ordinary declarations or statements.
  216. The label declaration defines the label @emph{name}, but does not define
  217. the label itself. You must do this in the usual way, with
  218. @code{@var{label}:}, within the statements of the statement expression.
  219. The local label feature is useful for complex macros. If a macro
  220. contains nested loops, a @code{goto} can be useful for breaking out of
  221. them. However, an ordinary label whose scope is the whole function
  222. cannot be used: if the macro can be expanded several times in one
  223. function, the label is multiply defined in that function. A
  224. local label avoids this problem. For example:
  225. @smallexample
  226. #define SEARCH(value, array, target) \
  227. do @{ \
  228. __label__ found; \
  229. typeof (target) _SEARCH_target = (target); \
  230. typeof (*(array)) *_SEARCH_array = (array); \
  231. int i, j; \
  232. int value; \
  233. for (i = 0; i < max; i++) \
  234. for (j = 0; j < max; j++) \
  235. if (_SEARCH_array[i][j] == _SEARCH_target) \
  236. @{ (value) = i; goto found; @} \
  237. (value) = -1; \
  238. found:; \
  239. @} while (0)
  240. @end smallexample
  241. This could also be written using a statement expression:
  242. @smallexample
  243. #define SEARCH(array, target) \
  244. (@{ \
  245. __label__ found; \
  246. typeof (target) _SEARCH_target = (target); \
  247. typeof (*(array)) *_SEARCH_array = (array); \
  248. int i, j; \
  249. int value; \
  250. for (i = 0; i < max; i++) \
  251. for (j = 0; j < max; j++) \
  252. if (_SEARCH_array[i][j] == _SEARCH_target) \
  253. @{ value = i; goto found; @} \
  254. value = -1; \
  255. found: \
  256. value; \
  257. @})
  258. @end smallexample
  259. Local label declarations also make the labels they declare visible to
  260. nested functions, if there are any. @xref{Nested Functions}, for details.
  261. @node Labels as Values
  262. @section Labels as Values
  263. @cindex labels as values
  264. @cindex computed gotos
  265. @cindex goto with computed label
  266. @cindex address of a label
  267. You can get the address of a label defined in the current function
  268. (or a containing function) with the unary operator @samp{&&}. The
  269. value has type @code{void *}. This value is a constant and can be used
  270. wherever a constant of that type is valid. For example:
  271. @smallexample
  272. void *ptr;
  273. /* @r{@dots{}} */
  274. ptr = &&foo;
  275. @end smallexample
  276. To use these values, you need to be able to jump to one. This is done
  277. with the computed goto statement@footnote{The analogous feature in
  278. Fortran is called an assigned goto, but that name seems inappropriate in
  279. C, where one can do more than simply store label addresses in label
  280. variables.}, @code{goto *@var{exp};}. For example,
  281. @smallexample
  282. goto *ptr;
  283. @end smallexample
  284. @noindent
  285. Any expression of type @code{void *} is allowed.
  286. One way of using these constants is in initializing a static array that
  287. serves as a jump table:
  288. @smallexample
  289. static void *array[] = @{ &&foo, &&bar, &&hack @};
  290. @end smallexample
  291. @noindent
  292. Then you can select a label with indexing, like this:
  293. @smallexample
  294. goto *array[i];
  295. @end smallexample
  296. @noindent
  297. Note that this does not check whether the subscript is in bounds---array
  298. indexing in C never does that.
  299. Such an array of label values serves a purpose much like that of the
  300. @code{switch} statement. The @code{switch} statement is cleaner, so
  301. use that rather than an array unless the problem does not fit a
  302. @code{switch} statement very well.
  303. Another use of label values is in an interpreter for threaded code.
  304. The labels within the interpreter function can be stored in the
  305. threaded code for super-fast dispatching.
  306. You may not use this mechanism to jump to code in a different function.
  307. If you do that, totally unpredictable things happen. The best way to
  308. avoid this is to store the label address only in automatic variables and
  309. never pass it as an argument.
  310. An alternate way to write the above example is
  311. @smallexample
  312. static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
  313. &&hack - &&foo @};
  314. goto *(&&foo + array[i]);
  315. @end smallexample
  316. @noindent
  317. This is more friendly to code living in shared libraries, as it reduces
  318. the number of dynamic relocations that are needed, and by consequence,
  319. allows the data to be read-only.
  320. This alternative with label differences is not supported for the AVR target,
  321. please use the first approach for AVR programs.
  322. The @code{&&foo} expressions for the same label might have different
  323. values if the containing function is inlined or cloned. If a program
  324. relies on them being always the same,
  325. @code{__attribute__((__noinline__,__noclone__))} should be used to
  326. prevent inlining and cloning. If @code{&&foo} is used in a static
  327. variable initializer, inlining and cloning is forbidden.
  328. @node Nested Functions
  329. @section Nested Functions
  330. @cindex nested functions
  331. @cindex downward funargs
  332. @cindex thunks
  333. A @dfn{nested function} is a function defined inside another function.
  334. Nested functions are supported as an extension in GNU C, but are not
  335. supported by GNU C++.
  336. The nested function's name is local to the block where it is defined.
  337. For example, here we define a nested function named @code{square}, and
  338. call it twice:
  339. @smallexample
  340. @group
  341. foo (double a, double b)
  342. @{
  343. double square (double z) @{ return z * z; @}
  344. return square (a) + square (b);
  345. @}
  346. @end group
  347. @end smallexample
  348. The nested function can access all the variables of the containing
  349. function that are visible at the point of its definition. This is
  350. called @dfn{lexical scoping}. For example, here we show a nested
  351. function which uses an inherited variable named @code{offset}:
  352. @smallexample
  353. @group
  354. bar (int *array, int offset, int size)
  355. @{
  356. int access (int *array, int index)
  357. @{ return array[index + offset]; @}
  358. int i;
  359. /* @r{@dots{}} */
  360. for (i = 0; i < size; i++)
  361. /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
  362. @}
  363. @end group
  364. @end smallexample
  365. Nested function definitions are permitted within functions in the places
  366. where variable definitions are allowed; that is, in any block, mixed
  367. with the other declarations and statements in the block.
  368. It is possible to call the nested function from outside the scope of its
  369. name by storing its address or passing the address to another function:
  370. @smallexample
  371. hack (int *array, int size)
  372. @{
  373. void store (int index, int value)
  374. @{ array[index] = value; @}
  375. intermediate (store, size);
  376. @}
  377. @end smallexample
  378. Here, the function @code{intermediate} receives the address of
  379. @code{store} as an argument. If @code{intermediate} calls @code{store},
  380. the arguments given to @code{store} are used to store into @code{array}.
  381. But this technique works only so long as the containing function
  382. (@code{hack}, in this example) does not exit.
  383. If you try to call the nested function through its address after the
  384. containing function exits, all hell breaks loose. If you try
  385. to call it after a containing scope level exits, and if it refers
  386. to some of the variables that are no longer in scope, you may be lucky,
  387. but it's not wise to take the risk. If, however, the nested function
  388. does not refer to anything that has gone out of scope, you should be
  389. safe.
  390. GCC implements taking the address of a nested function using a technique
  391. called @dfn{trampolines}. This technique was described in
  392. @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
  393. C++ Conference Proceedings, October 17-21, 1988).
  394. A nested function can jump to a label inherited from a containing
  395. function, provided the label is explicitly declared in the containing
  396. function (@pxref{Local Labels}). Such a jump returns instantly to the
  397. containing function, exiting the nested function that did the
  398. @code{goto} and any intermediate functions as well. Here is an example:
  399. @smallexample
  400. @group
  401. bar (int *array, int offset, int size)
  402. @{
  403. __label__ failure;
  404. int access (int *array, int index)
  405. @{
  406. if (index > size)
  407. goto failure;
  408. return array[index + offset];
  409. @}
  410. int i;
  411. /* @r{@dots{}} */
  412. for (i = 0; i < size; i++)
  413. /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
  414. /* @r{@dots{}} */
  415. return 0;
  416. /* @r{Control comes here from @code{access}
  417. if it detects an error.} */
  418. failure:
  419. return -1;
  420. @}
  421. @end group
  422. @end smallexample
  423. A nested function always has no linkage. Declaring one with
  424. @code{extern} or @code{static} is erroneous. If you need to declare the nested function
  425. before its definition, use @code{auto} (which is otherwise meaningless
  426. for function declarations).
  427. @smallexample
  428. bar (int *array, int offset, int size)
  429. @{
  430. __label__ failure;
  431. auto int access (int *, int);
  432. /* @r{@dots{}} */
  433. int access (int *array, int index)
  434. @{
  435. if (index > size)
  436. goto failure;
  437. return array[index + offset];
  438. @}
  439. /* @r{@dots{}} */
  440. @}
  441. @end smallexample
  442. @node Constructing Calls
  443. @section Constructing Function Calls
  444. @cindex constructing calls
  445. @cindex forwarding calls
  446. Using the built-in functions described below, you can record
  447. the arguments a function received, and call another function
  448. with the same arguments, without knowing the number or types
  449. of the arguments.
  450. You can also record the return value of that function call,
  451. and later return that value, without knowing what data type
  452. the function tried to return (as long as your caller expects
  453. that data type).
  454. However, these built-in functions may interact badly with some
  455. sophisticated features or other extensions of the language. It
  456. is, therefore, not recommended to use them outside very simple
  457. functions acting as mere forwarders for their arguments.
  458. @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
  459. This built-in function returns a pointer to data
  460. describing how to perform a call with the same arguments as are passed
  461. to the current function.
  462. The function saves the arg pointer register, structure value address,
  463. and all registers that might be used to pass arguments to a function
  464. into a block of memory allocated on the stack. Then it returns the
  465. address of that block.
  466. @end deftypefn
  467. @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
  468. This built-in function invokes @var{function}
  469. with a copy of the parameters described by @var{arguments}
  470. and @var{size}.
  471. The value of @var{arguments} should be the value returned by
  472. @code{__builtin_apply_args}. The argument @var{size} specifies the size
  473. of the stack argument data, in bytes.
  474. This function returns a pointer to data describing
  475. how to return whatever value is returned by @var{function}. The data
  476. is saved in a block of memory allocated on the stack.
  477. It is not always simple to compute the proper value for @var{size}. The
  478. value is used by @code{__builtin_apply} to compute the amount of data
  479. that should be pushed on the stack and copied from the incoming argument
  480. area.
  481. @end deftypefn
  482. @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
  483. This built-in function returns the value described by @var{result} from
  484. the containing function. You should specify, for @var{result}, a value
  485. returned by @code{__builtin_apply}.
  486. @end deftypefn
  487. @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
  488. This built-in function represents all anonymous arguments of an inline
  489. function. It can be used only in inline functions that are always
  490. inlined, never compiled as a separate function, such as those using
  491. @code{__attribute__ ((__always_inline__))} or
  492. @code{__attribute__ ((__gnu_inline__))} extern inline functions.
  493. It must be only passed as last argument to some other function
  494. with variable arguments. This is useful for writing small wrapper
  495. inlines for variable argument functions, when using preprocessor
  496. macros is undesirable. For example:
  497. @smallexample
  498. extern int myprintf (FILE *f, const char *format, ...);
  499. extern inline __attribute__ ((__gnu_inline__)) int
  500. myprintf (FILE *f, const char *format, ...)
  501. @{
  502. int r = fprintf (f, "myprintf: ");
  503. if (r < 0)
  504. return r;
  505. int s = fprintf (f, format, __builtin_va_arg_pack ());
  506. if (s < 0)
  507. return s;
  508. return r + s;
  509. @}
  510. @end smallexample
  511. @end deftypefn
  512. @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
  513. This built-in function returns the number of anonymous arguments of
  514. an inline function. It can be used only in inline functions that
  515. are always inlined, never compiled as a separate function, such
  516. as those using @code{__attribute__ ((__always_inline__))} or
  517. @code{__attribute__ ((__gnu_inline__))} extern inline functions.
  518. For example following does link- or run-time checking of open
  519. arguments for optimized code:
  520. @smallexample
  521. #ifdef __OPTIMIZE__
  522. extern inline __attribute__((__gnu_inline__)) int
  523. myopen (const char *path, int oflag, ...)
  524. @{
  525. if (__builtin_va_arg_pack_len () > 1)
  526. warn_open_too_many_arguments ();
  527. if (__builtin_constant_p (oflag))
  528. @{
  529. if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
  530. @{
  531. warn_open_missing_mode ();
  532. return __open_2 (path, oflag);
  533. @}
  534. return open (path, oflag, __builtin_va_arg_pack ());
  535. @}
  536. if (__builtin_va_arg_pack_len () < 1)
  537. return __open_2 (path, oflag);
  538. return open (path, oflag, __builtin_va_arg_pack ());
  539. @}
  540. #endif
  541. @end smallexample
  542. @end deftypefn
  543. @node Typeof
  544. @section Referring to a Type with @code{typeof}
  545. @findex typeof
  546. @findex sizeof
  547. @cindex macros, types of arguments
  548. Another way to refer to the type of an expression is with @code{typeof}.
  549. The syntax of using of this keyword looks like @code{sizeof}, but the
  550. construct acts semantically like a type name defined with @code{typedef}.
  551. There are two ways of writing the argument to @code{typeof}: with an
  552. expression or with a type. Here is an example with an expression:
  553. @smallexample
  554. typeof (x[0](1))
  555. @end smallexample
  556. @noindent
  557. This assumes that @code{x} is an array of pointers to functions;
  558. the type described is that of the values of the functions.
  559. Here is an example with a typename as the argument:
  560. @smallexample
  561. typeof (int *)
  562. @end smallexample
  563. @noindent
  564. Here the type described is that of pointers to @code{int}.
  565. If you are writing a header file that must work when included in ISO C
  566. programs, write @code{__typeof__} instead of @code{typeof}.
  567. @xref{Alternate Keywords}.
  568. A @code{typeof} construct can be used anywhere a typedef name can be
  569. used. For example, you can use it in a declaration, in a cast, or inside
  570. of @code{sizeof} or @code{typeof}.
  571. The operand of @code{typeof} is evaluated for its side effects if and
  572. only if it is an expression of variably modified type or the name of
  573. such a type.
  574. @code{typeof} is often useful in conjunction with
  575. statement expressions (@pxref{Statement Exprs}).
  576. Here is how the two together can
  577. be used to define a safe ``maximum'' macro which operates on any
  578. arithmetic type and evaluates each of its arguments exactly once:
  579. @smallexample
  580. #define max(a,b) \
  581. (@{ typeof (a) _a = (a); \
  582. typeof (b) _b = (b); \
  583. _a > _b ? _a : _b; @})
  584. @end smallexample
  585. @cindex underscores in variables in macros
  586. @cindex @samp{_} in variables in macros
  587. @cindex local variables in macros
  588. @cindex variables, local, in macros
  589. @cindex macros, local variables in
  590. The reason for using names that start with underscores for the local
  591. variables is to avoid conflicts with variable names that occur within the
  592. expressions that are substituted for @code{a} and @code{b}. Eventually we
  593. hope to design a new form of declaration syntax that allows you to declare
  594. variables whose scopes start only after their initializers; this will be a
  595. more reliable way to prevent such conflicts.
  596. @noindent
  597. Some more examples of the use of @code{typeof}:
  598. @itemize @bullet
  599. @item
  600. This declares @code{y} with the type of what @code{x} points to.
  601. @smallexample
  602. typeof (*x) y;
  603. @end smallexample
  604. @item
  605. This declares @code{y} as an array of such values.
  606. @smallexample
  607. typeof (*x) y[4];
  608. @end smallexample
  609. @item
  610. This declares @code{y} as an array of pointers to characters:
  611. @smallexample
  612. typeof (typeof (char *)[4]) y;
  613. @end smallexample
  614. @noindent
  615. It is equivalent to the following traditional C declaration:
  616. @smallexample
  617. char *y[4];
  618. @end smallexample
  619. To see the meaning of the declaration using @code{typeof}, and why it
  620. might be a useful way to write, rewrite it with these macros:
  621. @smallexample
  622. #define pointer(T) typeof(T *)
  623. #define array(T, N) typeof(T [N])
  624. @end smallexample
  625. @noindent
  626. Now the declaration can be rewritten this way:
  627. @smallexample
  628. array (pointer (char), 4) y;
  629. @end smallexample
  630. @noindent
  631. Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
  632. pointers to @code{char}.
  633. @end itemize
  634. In GNU C, but not GNU C++, you may also declare the type of a variable
  635. as @code{__auto_type}. In that case, the declaration must declare
  636. only one variable, whose declarator must just be an identifier, the
  637. declaration must be initialized, and the type of the variable is
  638. determined by the initializer; the name of the variable is not in
  639. scope until after the initializer. (In C++, you should use C++11
  640. @code{auto} for this purpose.) Using @code{__auto_type}, the
  641. ``maximum'' macro above could be written as:
  642. @smallexample
  643. #define max(a,b) \
  644. (@{ __auto_type _a = (a); \
  645. __auto_type _b = (b); \
  646. _a > _b ? _a : _b; @})
  647. @end smallexample
  648. Using @code{__auto_type} instead of @code{typeof} has two advantages:
  649. @itemize @bullet
  650. @item Each argument to the macro appears only once in the expansion of
  651. the macro. This prevents the size of the macro expansion growing
  652. exponentially when calls to such macros are nested inside arguments of
  653. such macros.
  654. @item If the argument to the macro has variably modified type, it is
  655. evaluated only once when using @code{__auto_type}, but twice if
  656. @code{typeof} is used.
  657. @end itemize
  658. @node Conditionals
  659. @section Conditionals with Omitted Operands
  660. @cindex conditional expressions, extensions
  661. @cindex omitted middle-operands
  662. @cindex middle-operands, omitted
  663. @cindex extensions, @code{?:}
  664. @cindex @code{?:} extensions
  665. The middle operand in a conditional expression may be omitted. Then
  666. if the first operand is nonzero, its value is the value of the conditional
  667. expression.
  668. Therefore, the expression
  669. @smallexample
  670. x ? : y
  671. @end smallexample
  672. @noindent
  673. has the value of @code{x} if that is nonzero; otherwise, the value of
  674. @code{y}.
  675. This example is perfectly equivalent to
  676. @smallexample
  677. x ? x : y
  678. @end smallexample
  679. @cindex side effect in @code{?:}
  680. @cindex @code{?:} side effect
  681. @noindent
  682. In this simple case, the ability to omit the middle operand is not
  683. especially useful. When it becomes useful is when the first operand does,
  684. or may (if it is a macro argument), contain a side effect. Then repeating
  685. the operand in the middle would perform the side effect twice. Omitting
  686. the middle operand uses the value already computed without the undesirable
  687. effects of recomputing it.
  688. @node __int128
  689. @section 128-bit Integers
  690. @cindex @code{__int128} data types
  691. As an extension the integer scalar type @code{__int128} is supported for
  692. targets which have an integer mode wide enough to hold 128 bits.
  693. Simply write @code{__int128} for a signed 128-bit integer, or
  694. @code{unsigned __int128} for an unsigned 128-bit integer. There is no
  695. support in GCC for expressing an integer constant of type @code{__int128}
  696. for targets with @code{long long} integer less than 128 bits wide.
  697. @node Long Long
  698. @section Double-Word Integers
  699. @cindex @code{long long} data types
  700. @cindex double-word arithmetic
  701. @cindex multiprecision arithmetic
  702. @cindex @code{LL} integer suffix
  703. @cindex @code{ULL} integer suffix
  704. ISO C99 supports data types for integers that are at least 64 bits wide,
  705. and as an extension GCC supports them in C90 mode and in C++.
  706. Simply write @code{long long int} for a signed integer, or
  707. @code{unsigned long long int} for an unsigned integer. To make an
  708. integer constant of type @code{long long int}, add the suffix @samp{LL}
  709. to the integer. To make an integer constant of type @code{unsigned long
  710. long int}, add the suffix @samp{ULL} to the integer.
  711. You can use these types in arithmetic like any other integer types.
  712. Addition, subtraction, and bitwise boolean operations on these types
  713. are open-coded on all types of machines. Multiplication is open-coded
  714. if the machine supports a fullword-to-doubleword widening multiply
  715. instruction. Division and shifts are open-coded only on machines that
  716. provide special support. The operations that are not open-coded use
  717. special library routines that come with GCC@.
  718. There may be pitfalls when you use @code{long long} types for function
  719. arguments without function prototypes. If a function
  720. expects type @code{int} for its argument, and you pass a value of type
  721. @code{long long int}, confusion results because the caller and the
  722. subroutine disagree about the number of bytes for the argument.
  723. Likewise, if the function expects @code{long long int} and you pass
  724. @code{int}. The best way to avoid such problems is to use prototypes.
  725. @node Complex
  726. @section Complex Numbers
  727. @cindex complex numbers
  728. @cindex @code{_Complex} keyword
  729. @cindex @code{__complex__} keyword
  730. ISO C99 supports complex floating data types, and as an extension GCC
  731. supports them in C90 mode and in C++. GCC also supports complex integer data
  732. types which are not part of ISO C99. You can declare complex types
  733. using the keyword @code{_Complex}. As an extension, the older GNU
  734. keyword @code{__complex__} is also supported.
  735. For example, @samp{_Complex double x;} declares @code{x} as a
  736. variable whose real part and imaginary part are both of type
  737. @code{double}. @samp{_Complex short int y;} declares @code{y} to
  738. have real and imaginary parts of type @code{short int}; this is not
  739. likely to be useful, but it shows that the set of complex types is
  740. complete.
  741. To write a constant with a complex data type, use the suffix @samp{i} or
  742. @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
  743. has type @code{_Complex float} and @code{3i} has type
  744. @code{_Complex int}. Such a constant always has a pure imaginary
  745. value, but you can form any complex value you like by adding one to a
  746. real constant. This is a GNU extension; if you have an ISO C99
  747. conforming C library (such as the GNU C Library), and want to construct complex
  748. constants of floating type, you should include @code{<complex.h>} and
  749. use the macros @code{I} or @code{_Complex_I} instead.
  750. @cindex @code{__real__} keyword
  751. @cindex @code{__imag__} keyword
  752. To extract the real part of a complex-valued expression @var{exp}, write
  753. @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
  754. extract the imaginary part. This is a GNU extension; for values of
  755. floating type, you should use the ISO C99 functions @code{crealf},
  756. @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
  757. @code{cimagl}, declared in @code{<complex.h>} and also provided as
  758. built-in functions by GCC@.
  759. @cindex complex conjugation
  760. The operator @samp{~} performs complex conjugation when used on a value
  761. with a complex type. This is a GNU extension; for values of
  762. floating type, you should use the ISO C99 functions @code{conjf},
  763. @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
  764. provided as built-in functions by GCC@.
  765. GCC can allocate complex automatic variables in a noncontiguous
  766. fashion; it's even possible for the real part to be in a register while
  767. the imaginary part is on the stack (or vice versa). Only the DWARF 2
  768. debug info format can represent this, so use of DWARF 2 is recommended.
  769. If you are using the stabs debug info format, GCC describes a noncontiguous
  770. complex variable as if it were two separate variables of noncomplex type.
  771. If the variable's actual name is @code{foo}, the two fictitious
  772. variables are named @code{foo$real} and @code{foo$imag}. You can
  773. examine and set these two fictitious variables with your debugger.
  774. @node Floating Types
  775. @section Additional Floating Types
  776. @cindex additional floating types
  777. @cindex @code{__float80} data type
  778. @cindex @code{__float128} data type
  779. @cindex @code{w} floating point suffix
  780. @cindex @code{q} floating point suffix
  781. @cindex @code{W} floating point suffix
  782. @cindex @code{Q} floating point suffix
  783. As an extension, GNU C supports additional floating
  784. types, @code{__float80} and @code{__float128} to support 80-bit
  785. (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
  786. Support for additional types includes the arithmetic operators:
  787. add, subtract, multiply, divide; unary arithmetic operators;
  788. relational operators; equality operators; and conversions to and from
  789. integer and other floating types. Use a suffix @samp{w} or @samp{W}
  790. in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
  791. for @code{_float128}. You can declare complex types using the
  792. corresponding internal complex type, @code{XCmode} for @code{__float80}
  793. type and @code{TCmode} for @code{__float128} type:
  794. @smallexample
  795. typedef _Complex float __attribute__((mode(TC))) _Complex128;
  796. typedef _Complex float __attribute__((mode(XC))) _Complex80;
  797. @end smallexample
  798. Not all targets support additional floating-point types. @code{__float80}
  799. and @code{__float128} types are supported on x86 and IA-64 targets.
  800. The @code{__float128} type is supported on hppa HP-UX targets.
  801. @node Half-Precision
  802. @section Half-Precision Floating Point
  803. @cindex half-precision floating point
  804. @cindex @code{__fp16} data type
  805. On ARM targets, GCC supports half-precision (16-bit) floating point via
  806. the @code{__fp16} type. You must enable this type explicitly
  807. with the @option{-mfp16-format} command-line option in order to use it.
  808. ARM supports two incompatible representations for half-precision
  809. floating-point values. You must choose one of the representations and
  810. use it consistently in your program.
  811. Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
  812. This format can represent normalized values in the range of @math{2^{-14}} to 65504.
  813. There are 11 bits of significand precision, approximately 3
  814. decimal digits.
  815. Specifying @option{-mfp16-format=alternative} selects the ARM
  816. alternative format. This representation is similar to the IEEE
  817. format, but does not support infinities or NaNs. Instead, the range
  818. of exponents is extended, so that this format can represent normalized
  819. values in the range of @math{2^{-14}} to 131008.
  820. The @code{__fp16} type is a storage format only. For purposes
  821. of arithmetic and other operations, @code{__fp16} values in C or C++
  822. expressions are automatically promoted to @code{float}. In addition,
  823. you cannot declare a function with a return value or parameters
  824. of type @code{__fp16}.
  825. Note that conversions from @code{double} to @code{__fp16}
  826. involve an intermediate conversion to @code{float}. Because
  827. of rounding, this can sometimes produce a different result than a
  828. direct conversion.
  829. ARM provides hardware support for conversions between
  830. @code{__fp16} and @code{float} values
  831. as an extension to VFP and NEON (Advanced SIMD). GCC generates
  832. code using these hardware instructions if you compile with
  833. options to select an FPU that provides them;
  834. for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
  835. in addition to the @option{-mfp16-format} option to select
  836. a half-precision format.
  837. Language-level support for the @code{__fp16} data type is
  838. independent of whether GCC generates code using hardware floating-point
  839. instructions. In cases where hardware support is not specified, GCC
  840. implements conversions between @code{__fp16} and @code{float} values
  841. as library calls.
  842. @node Decimal Float
  843. @section Decimal Floating Types
  844. @cindex decimal floating types
  845. @cindex @code{_Decimal32} data type
  846. @cindex @code{_Decimal64} data type
  847. @cindex @code{_Decimal128} data type
  848. @cindex @code{df} integer suffix
  849. @cindex @code{dd} integer suffix
  850. @cindex @code{dl} integer suffix
  851. @cindex @code{DF} integer suffix
  852. @cindex @code{DD} integer suffix
  853. @cindex @code{DL} integer suffix
  854. As an extension, GNU C supports decimal floating types as
  855. defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
  856. floating types in GCC will evolve as the draft technical report changes.
  857. Calling conventions for any target might also change. Not all targets
  858. support decimal floating types.
  859. The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
  860. @code{_Decimal128}. They use a radix of ten, unlike the floating types
  861. @code{float}, @code{double}, and @code{long double} whose radix is not
  862. specified by the C standard but is usually two.
  863. Support for decimal floating types includes the arithmetic operators
  864. add, subtract, multiply, divide; unary arithmetic operators;
  865. relational operators; equality operators; and conversions to and from
  866. integer and other floating types. Use a suffix @samp{df} or
  867. @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
  868. or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
  869. @code{_Decimal128}.
  870. GCC support of decimal float as specified by the draft technical report
  871. is incomplete:
  872. @itemize @bullet
  873. @item
  874. When the value of a decimal floating type cannot be represented in the
  875. integer type to which it is being converted, the result is undefined
  876. rather than the result value specified by the draft technical report.
  877. @item
  878. GCC does not provide the C library functionality associated with
  879. @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
  880. @file{wchar.h}, which must come from a separate C library implementation.
  881. Because of this the GNU C compiler does not define macro
  882. @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
  883. the technical report.
  884. @end itemize
  885. Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
  886. are supported by the DWARF 2 debug information format.
  887. @node Hex Floats
  888. @section Hex Floats
  889. @cindex hex floats
  890. ISO C99 supports floating-point numbers written not only in the usual
  891. decimal notation, such as @code{1.55e1}, but also numbers such as
  892. @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
  893. supports this in C90 mode (except in some cases when strictly
  894. conforming) and in C++. In that format the
  895. @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
  896. mandatory. The exponent is a decimal number that indicates the power of
  897. 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
  898. @tex
  899. $1 {15\over16}$,
  900. @end tex
  901. @ifnottex
  902. 1 15/16,
  903. @end ifnottex
  904. @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
  905. is the same as @code{1.55e1}.
  906. Unlike for floating-point numbers in the decimal notation the exponent
  907. is always required in the hexadecimal notation. Otherwise the compiler
  908. would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
  909. could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
  910. extension for floating-point constants of type @code{float}.
  911. @node Fixed-Point
  912. @section Fixed-Point Types
  913. @cindex fixed-point types
  914. @cindex @code{_Fract} data type
  915. @cindex @code{_Accum} data type
  916. @cindex @code{_Sat} data type
  917. @cindex @code{hr} fixed-suffix
  918. @cindex @code{r} fixed-suffix
  919. @cindex @code{lr} fixed-suffix
  920. @cindex @code{llr} fixed-suffix
  921. @cindex @code{uhr} fixed-suffix
  922. @cindex @code{ur} fixed-suffix
  923. @cindex @code{ulr} fixed-suffix
  924. @cindex @code{ullr} fixed-suffix
  925. @cindex @code{hk} fixed-suffix
  926. @cindex @code{k} fixed-suffix
  927. @cindex @code{lk} fixed-suffix
  928. @cindex @code{llk} fixed-suffix
  929. @cindex @code{uhk} fixed-suffix
  930. @cindex @code{uk} fixed-suffix
  931. @cindex @code{ulk} fixed-suffix
  932. @cindex @code{ullk} fixed-suffix
  933. @cindex @code{HR} fixed-suffix
  934. @cindex @code{R} fixed-suffix
  935. @cindex @code{LR} fixed-suffix
  936. @cindex @code{LLR} fixed-suffix
  937. @cindex @code{UHR} fixed-suffix
  938. @cindex @code{UR} fixed-suffix
  939. @cindex @code{ULR} fixed-suffix
  940. @cindex @code{ULLR} fixed-suffix
  941. @cindex @code{HK} fixed-suffix
  942. @cindex @code{K} fixed-suffix
  943. @cindex @code{LK} fixed-suffix
  944. @cindex @code{LLK} fixed-suffix
  945. @cindex @code{UHK} fixed-suffix
  946. @cindex @code{UK} fixed-suffix
  947. @cindex @code{ULK} fixed-suffix
  948. @cindex @code{ULLK} fixed-suffix
  949. As an extension, GNU C supports fixed-point types as
  950. defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
  951. types in GCC will evolve as the draft technical report changes.
  952. Calling conventions for any target might also change. Not all targets
  953. support fixed-point types.
  954. The fixed-point types are
  955. @code{short _Fract},
  956. @code{_Fract},
  957. @code{long _Fract},
  958. @code{long long _Fract},
  959. @code{unsigned short _Fract},
  960. @code{unsigned _Fract},
  961. @code{unsigned long _Fract},
  962. @code{unsigned long long _Fract},
  963. @code{_Sat short _Fract},
  964. @code{_Sat _Fract},
  965. @code{_Sat long _Fract},
  966. @code{_Sat long long _Fract},
  967. @code{_Sat unsigned short _Fract},
  968. @code{_Sat unsigned _Fract},
  969. @code{_Sat unsigned long _Fract},
  970. @code{_Sat unsigned long long _Fract},
  971. @code{short _Accum},
  972. @code{_Accum},
  973. @code{long _Accum},
  974. @code{long long _Accum},
  975. @code{unsigned short _Accum},
  976. @code{unsigned _Accum},
  977. @code{unsigned long _Accum},
  978. @code{unsigned long long _Accum},
  979. @code{_Sat short _Accum},
  980. @code{_Sat _Accum},
  981. @code{_Sat long _Accum},
  982. @code{_Sat long long _Accum},
  983. @code{_Sat unsigned short _Accum},
  984. @code{_Sat unsigned _Accum},
  985. @code{_Sat unsigned long _Accum},
  986. @code{_Sat unsigned long long _Accum}.
  987. Fixed-point data values contain fractional and optional integral parts.
  988. The format of fixed-point data varies and depends on the target machine.
  989. Support for fixed-point types includes:
  990. @itemize @bullet
  991. @item
  992. prefix and postfix increment and decrement operators (@code{++}, @code{--})
  993. @item
  994. unary arithmetic operators (@code{+}, @code{-}, @code{!})
  995. @item
  996. binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
  997. @item
  998. binary shift operators (@code{<<}, @code{>>})
  999. @item
  1000. relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
  1001. @item
  1002. equality operators (@code{==}, @code{!=})
  1003. @item
  1004. assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
  1005. @code{<<=}, @code{>>=})
  1006. @item
  1007. conversions to and from integer, floating-point, or fixed-point types
  1008. @end itemize
  1009. Use a suffix in a fixed-point literal constant:
  1010. @itemize
  1011. @item @samp{hr} or @samp{HR} for @code{short _Fract} and
  1012. @code{_Sat short _Fract}
  1013. @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
  1014. @item @samp{lr} or @samp{LR} for @code{long _Fract} and
  1015. @code{_Sat long _Fract}
  1016. @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
  1017. @code{_Sat long long _Fract}
  1018. @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
  1019. @code{_Sat unsigned short _Fract}
  1020. @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
  1021. @code{_Sat unsigned _Fract}
  1022. @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
  1023. @code{_Sat unsigned long _Fract}
  1024. @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
  1025. and @code{_Sat unsigned long long _Fract}
  1026. @item @samp{hk} or @samp{HK} for @code{short _Accum} and
  1027. @code{_Sat short _Accum}
  1028. @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
  1029. @item @samp{lk} or @samp{LK} for @code{long _Accum} and
  1030. @code{_Sat long _Accum}
  1031. @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
  1032. @code{_Sat long long _Accum}
  1033. @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
  1034. @code{_Sat unsigned short _Accum}
  1035. @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
  1036. @code{_Sat unsigned _Accum}
  1037. @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
  1038. @code{_Sat unsigned long _Accum}
  1039. @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
  1040. and @code{_Sat unsigned long long _Accum}
  1041. @end itemize
  1042. GCC support of fixed-point types as specified by the draft technical report
  1043. is incomplete:
  1044. @itemize @bullet
  1045. @item
  1046. Pragmas to control overflow and rounding behaviors are not implemented.
  1047. @end itemize
  1048. Fixed-point types are supported by the DWARF 2 debug information format.
  1049. @node Named Address Spaces
  1050. @section Named Address Spaces
  1051. @cindex Named Address Spaces
  1052. As an extension, GNU C supports named address spaces as
  1053. defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
  1054. address spaces in GCC will evolve as the draft technical report
  1055. changes. Calling conventions for any target might also change. At
  1056. present, only the AVR, SPU, M32C, and RL78 targets support address
  1057. spaces other than the generic address space.
  1058. Address space identifiers may be used exactly like any other C type
  1059. qualifier (e.g., @code{const} or @code{volatile}). See the N1275
  1060. document for more details.
  1061. @anchor{AVR Named Address Spaces}
  1062. @subsection AVR Named Address Spaces
  1063. On the AVR target, there are several address spaces that can be used
  1064. in order to put read-only data into the flash memory and access that
  1065. data by means of the special instructions @code{LPM} or @code{ELPM}
  1066. needed to read from flash.
  1067. Per default, any data including read-only data is located in RAM
  1068. (the generic address space) so that non-generic address spaces are
  1069. needed to locate read-only data in flash memory
  1070. @emph{and} to generate the right instructions to access this data
  1071. without using (inline) assembler code.
  1072. @table @code
  1073. @item __flash
  1074. @cindex @code{__flash} AVR Named Address Spaces
  1075. The @code{__flash} qualifier locates data in the
  1076. @code{.progmem.data} section. Data is read using the @code{LPM}
  1077. instruction. Pointers to this address space are 16 bits wide.
  1078. @item __flash1
  1079. @itemx __flash2
  1080. @itemx __flash3
  1081. @itemx __flash4
  1082. @itemx __flash5
  1083. @cindex @code{__flash1} AVR Named Address Spaces
  1084. @cindex @code{__flash2} AVR Named Address Spaces
  1085. @cindex @code{__flash3} AVR Named Address Spaces
  1086. @cindex @code{__flash4} AVR Named Address Spaces
  1087. @cindex @code{__flash5} AVR Named Address Spaces
  1088. These are 16-bit address spaces locating data in section
  1089. @code{.progmem@var{N}.data} where @var{N} refers to
  1090. address space @code{__flash@var{N}}.
  1091. The compiler sets the @code{RAMPZ} segment register appropriately
  1092. before reading data by means of the @code{ELPM} instruction.
  1093. @item __memx
  1094. @cindex @code{__memx} AVR Named Address Spaces
  1095. This is a 24-bit address space that linearizes flash and RAM:
  1096. If the high bit of the address is set, data is read from
  1097. RAM using the lower two bytes as RAM address.
  1098. If the high bit of the address is clear, data is read from flash
  1099. with @code{RAMPZ} set according to the high byte of the address.
  1100. @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
  1101. Objects in this address space are located in @code{.progmemx.data}.
  1102. @end table
  1103. @b{Example}
  1104. @smallexample
  1105. char my_read (const __flash char ** p)
  1106. @{
  1107. /* p is a pointer to RAM that points to a pointer to flash.
  1108. The first indirection of p reads that flash pointer
  1109. from RAM and the second indirection reads a char from this
  1110. flash address. */
  1111. return **p;
  1112. @}
  1113. /* Locate array[] in flash memory */
  1114. const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
  1115. int i = 1;
  1116. int main (void)
  1117. @{
  1118. /* Return 17 by reading from flash memory */
  1119. return array[array[i]];
  1120. @}
  1121. @end smallexample
  1122. @noindent
  1123. For each named address space supported by avr-gcc there is an equally
  1124. named but uppercase built-in macro defined.
  1125. The purpose is to facilitate testing if respective address space
  1126. support is available or not:
  1127. @smallexample
  1128. #ifdef __FLASH
  1129. const __flash int var = 1;
  1130. int read_var (void)
  1131. @{
  1132. return var;
  1133. @}
  1134. #else
  1135. #include <avr/pgmspace.h> /* From AVR-LibC */
  1136. const int var PROGMEM = 1;
  1137. int read_var (void)
  1138. @{
  1139. return (int) pgm_read_word (&var);
  1140. @}
  1141. #endif /* __FLASH */
  1142. @end smallexample
  1143. @noindent
  1144. Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
  1145. locates data in flash but
  1146. accesses to these data read from generic address space, i.e.@:
  1147. from RAM,
  1148. so that you need special accessors like @code{pgm_read_byte}
  1149. from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
  1150. together with attribute @code{progmem}.
  1151. @noindent
  1152. @b{Limitations and caveats}
  1153. @itemize
  1154. @item
  1155. Reading across the 64@tie{}KiB section boundary of
  1156. the @code{__flash} or @code{__flash@var{N}} address spaces
  1157. shows undefined behavior. The only address space that
  1158. supports reading across the 64@tie{}KiB flash segment boundaries is
  1159. @code{__memx}.
  1160. @item
  1161. If you use one of the @code{__flash@var{N}} address spaces
  1162. you must arrange your linker script to locate the
  1163. @code{.progmem@var{N}.data} sections according to your needs.
  1164. @item
  1165. Any data or pointers to the non-generic address spaces must
  1166. be qualified as @code{const}, i.e.@: as read-only data.
  1167. This still applies if the data in one of these address
  1168. spaces like software version number or calibration lookup table are intended to
  1169. be changed after load time by, say, a boot loader. In this case
  1170. the right qualification is @code{const} @code{volatile} so that the compiler
  1171. must not optimize away known values or insert them
  1172. as immediates into operands of instructions.
  1173. @item
  1174. The following code initializes a variable @code{pfoo}
  1175. located in static storage with a 24-bit address:
  1176. @smallexample
  1177. extern const __memx char foo;
  1178. const __memx void *pfoo = &foo;
  1179. @end smallexample
  1180. @noindent
  1181. Such code requires at least binutils 2.23, see
  1182. @w{@uref{http://sourceware.org/PR13503,PR13503}}.
  1183. @end itemize
  1184. @subsection M32C Named Address Spaces
  1185. @cindex @code{__far} M32C Named Address Spaces
  1186. On the M32C target, with the R8C and M16C CPU variants, variables
  1187. qualified with @code{__far} are accessed using 32-bit addresses in
  1188. order to access memory beyond the first 64@tie{}Ki bytes. If
  1189. @code{__far} is used with the M32CM or M32C CPU variants, it has no
  1190. effect.
  1191. @subsection RL78 Named Address Spaces
  1192. @cindex @code{__far} RL78 Named Address Spaces
  1193. On the RL78 target, variables qualified with @code{__far} are accessed
  1194. with 32-bit pointers (20-bit addresses) rather than the default 16-bit
  1195. addresses. Non-far variables are assumed to appear in the topmost
  1196. 64@tie{}KiB of the address space.
  1197. @subsection SPU Named Address Spaces
  1198. @cindex @code{__ea} SPU Named Address Spaces
  1199. On the SPU target variables may be declared as
  1200. belonging to another address space by qualifying the type with the
  1201. @code{__ea} address space identifier:
  1202. @smallexample
  1203. extern int __ea i;
  1204. @end smallexample
  1205. @noindent
  1206. The compiler generates special code to access the variable @code{i}.
  1207. It may use runtime library
  1208. support, or generate special machine instructions to access that address
  1209. space.
  1210. @node Zero Length
  1211. @section Arrays of Length Zero
  1212. @cindex arrays of length zero
  1213. @cindex zero-length arrays
  1214. @cindex length-zero arrays
  1215. @cindex flexible array members
  1216. Zero-length arrays are allowed in GNU C@. They are very useful as the
  1217. last element of a structure that is really a header for a variable-length
  1218. object:
  1219. @smallexample
  1220. struct line @{
  1221. int length;
  1222. char contents[0];
  1223. @};
  1224. struct line *thisline = (struct line *)
  1225. malloc (sizeof (struct line) + this_length);
  1226. thisline->length = this_length;
  1227. @end smallexample
  1228. In ISO C90, you would have to give @code{contents} a length of 1, which
  1229. means either you waste space or complicate the argument to @code{malloc}.
  1230. In ISO C99, you would use a @dfn{flexible array member}, which is
  1231. slightly different in syntax and semantics:
  1232. @itemize @bullet
  1233. @item
  1234. Flexible array members are written as @code{contents[]} without
  1235. the @code{0}.
  1236. @item
  1237. Flexible array members have incomplete type, and so the @code{sizeof}
  1238. operator may not be applied. As a quirk of the original implementation
  1239. of zero-length arrays, @code{sizeof} evaluates to zero.
  1240. @item
  1241. Flexible array members may only appear as the last member of a
  1242. @code{struct} that is otherwise non-empty.
  1243. @item
  1244. A structure containing a flexible array member, or a union containing
  1245. such a structure (possibly recursively), may not be a member of a
  1246. structure or an element of an array. (However, these uses are
  1247. permitted by GCC as extensions.)
  1248. @end itemize
  1249. Non-empty initialization of zero-length
  1250. arrays is treated like any case where there are more initializer
  1251. elements than the array holds, in that a suitable warning about ``excess
  1252. elements in array'' is given, and the excess elements (all of them, in
  1253. this case) are ignored.
  1254. GCC allows static initialization of flexible array members.
  1255. This is equivalent to defining a new structure containing the original
  1256. structure followed by an array of sufficient size to contain the data.
  1257. E.g.@: in the following, @code{f1} is constructed as if it were declared
  1258. like @code{f2}.
  1259. @smallexample
  1260. struct f1 @{
  1261. int x; int y[];
  1262. @} f1 = @{ 1, @{ 2, 3, 4 @} @};
  1263. struct f2 @{
  1264. struct f1 f1; int data[3];
  1265. @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
  1266. @end smallexample
  1267. @noindent
  1268. The convenience of this extension is that @code{f1} has the desired
  1269. type, eliminating the need to consistently refer to @code{f2.f1}.
  1270. This has symmetry with normal static arrays, in that an array of
  1271. unknown size is also written with @code{[]}.
  1272. Of course, this extension only makes sense if the extra data comes at
  1273. the end of a top-level object, as otherwise we would be overwriting
  1274. data at subsequent offsets. To avoid undue complication and confusion
  1275. with initialization of deeply nested arrays, we simply disallow any
  1276. non-empty initialization except when the structure is the top-level
  1277. object. For example:
  1278. @smallexample
  1279. struct foo @{ int x; int y[]; @};
  1280. struct bar @{ struct foo z; @};
  1281. struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
  1282. struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
  1283. struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
  1284. struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
  1285. @end smallexample
  1286. @node Empty Structures
  1287. @section Structures with No Members
  1288. @cindex empty structures
  1289. @cindex zero-size structures
  1290. GCC permits a C structure to have no members:
  1291. @smallexample
  1292. struct empty @{
  1293. @};
  1294. @end smallexample
  1295. The structure has size zero. In C++, empty structures are part
  1296. of the language. G++ treats empty structures as if they had a single
  1297. member of type @code{char}.
  1298. @node Variable Length
  1299. @section Arrays of Variable Length
  1300. @cindex variable-length arrays
  1301. @cindex arrays of variable length
  1302. @cindex VLAs
  1303. Variable-length automatic arrays are allowed in ISO C99, and as an
  1304. extension GCC accepts them in C90 mode and in C++. These arrays are
  1305. declared like any other automatic arrays, but with a length that is not
  1306. a constant expression. The storage is allocated at the point of
  1307. declaration and deallocated when the block scope containing the declaration
  1308. exits. For
  1309. example:
  1310. @smallexample
  1311. FILE *
  1312. concat_fopen (char *s1, char *s2, char *mode)
  1313. @{
  1314. char str[strlen (s1) + strlen (s2) + 1];
  1315. strcpy (str, s1);
  1316. strcat (str, s2);
  1317. return fopen (str, mode);
  1318. @}
  1319. @end smallexample
  1320. @cindex scope of a variable length array
  1321. @cindex variable-length array scope
  1322. @cindex deallocating variable length arrays
  1323. Jumping or breaking out of the scope of the array name deallocates the
  1324. storage. Jumping into the scope is not allowed; you get an error
  1325. message for it.
  1326. @cindex variable-length array in a structure
  1327. As an extension, GCC accepts variable-length arrays as a member of
  1328. a structure or a union. For example:
  1329. @smallexample
  1330. void
  1331. foo (int n)
  1332. @{
  1333. struct S @{ int x[n]; @};
  1334. @}
  1335. @end smallexample
  1336. @cindex @code{alloca} vs variable-length arrays
  1337. You can use the function @code{alloca} to get an effect much like
  1338. variable-length arrays. The function @code{alloca} is available in
  1339. many other C implementations (but not in all). On the other hand,
  1340. variable-length arrays are more elegant.
  1341. There are other differences between these two methods. Space allocated
  1342. with @code{alloca} exists until the containing @emph{function} returns.
  1343. The space for a variable-length array is deallocated as soon as the array
  1344. name's scope ends. (If you use both variable-length arrays and
  1345. @code{alloca} in the same function, deallocation of a variable-length array
  1346. also deallocates anything more recently allocated with @code{alloca}.)
  1347. You can also use variable-length arrays as arguments to functions:
  1348. @smallexample
  1349. struct entry
  1350. tester (int len, char data[len][len])
  1351. @{
  1352. /* @r{@dots{}} */
  1353. @}
  1354. @end smallexample
  1355. The length of an array is computed once when the storage is allocated
  1356. and is remembered for the scope of the array in case you access it with
  1357. @code{sizeof}.
  1358. If you want to pass the array first and the length afterward, you can
  1359. use a forward declaration in the parameter list---another GNU extension.
  1360. @smallexample
  1361. struct entry
  1362. tester (int len; char data[len][len], int len)
  1363. @{
  1364. /* @r{@dots{}} */
  1365. @}
  1366. @end smallexample
  1367. @cindex parameter forward declaration
  1368. The @samp{int len} before the semicolon is a @dfn{parameter forward
  1369. declaration}, and it serves the purpose of making the name @code{len}
  1370. known when the declaration of @code{data} is parsed.
  1371. You can write any number of such parameter forward declarations in the
  1372. parameter list. They can be separated by commas or semicolons, but the
  1373. last one must end with a semicolon, which is followed by the ``real''
  1374. parameter declarations. Each forward declaration must match a ``real''
  1375. declaration in parameter name and data type. ISO C99 does not support
  1376. parameter forward declarations.
  1377. @node Variadic Macros
  1378. @section Macros with a Variable Number of Arguments.
  1379. @cindex variable number of arguments
  1380. @cindex macro with variable arguments
  1381. @cindex rest argument (in macro)
  1382. @cindex variadic macros
  1383. In the ISO C standard of 1999, a macro can be declared to accept a
  1384. variable number of arguments much as a function can. The syntax for
  1385. defining the macro is similar to that of a function. Here is an
  1386. example:
  1387. @smallexample
  1388. #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
  1389. @end smallexample
  1390. @noindent
  1391. Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
  1392. such a macro, it represents the zero or more tokens until the closing
  1393. parenthesis that ends the invocation, including any commas. This set of
  1394. tokens replaces the identifier @code{__VA_ARGS__} in the macro body
  1395. wherever it appears. See the CPP manual for more information.
  1396. GCC has long supported variadic macros, and used a different syntax that
  1397. allowed you to give a name to the variable arguments just like any other
  1398. argument. Here is an example:
  1399. @smallexample
  1400. #define debug(format, args...) fprintf (stderr, format, args)
  1401. @end smallexample
  1402. @noindent
  1403. This is in all ways equivalent to the ISO C example above, but arguably
  1404. more readable and descriptive.
  1405. GNU CPP has two further variadic macro extensions, and permits them to
  1406. be used with either of the above forms of macro definition.
  1407. In standard C, you are not allowed to leave the variable argument out
  1408. entirely; but you are allowed to pass an empty argument. For example,
  1409. this invocation is invalid in ISO C, because there is no comma after
  1410. the string:
  1411. @smallexample
  1412. debug ("A message")
  1413. @end smallexample
  1414. GNU CPP permits you to completely omit the variable arguments in this
  1415. way. In the above examples, the compiler would complain, though since
  1416. the expansion of the macro still has the extra comma after the format
  1417. string.
  1418. To help solve this problem, CPP behaves specially for variable arguments
  1419. used with the token paste operator, @samp{##}. If instead you write
  1420. @smallexample
  1421. #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
  1422. @end smallexample
  1423. @noindent
  1424. and if the variable arguments are omitted or empty, the @samp{##}
  1425. operator causes the preprocessor to remove the comma before it. If you
  1426. do provide some variable arguments in your macro invocation, GNU CPP
  1427. does not complain about the paste operation and instead places the
  1428. variable arguments after the comma. Just like any other pasted macro
  1429. argument, these arguments are not macro expanded.
  1430. @node Escaped Newlines
  1431. @section Slightly Looser Rules for Escaped Newlines
  1432. @cindex escaped newlines
  1433. @cindex newlines (escaped)
  1434. The preprocessor treatment of escaped newlines is more relaxed
  1435. than that specified by the C90 standard, which requires the newline
  1436. to immediately follow a backslash.
  1437. GCC's implementation allows whitespace in the form
  1438. of spaces, horizontal and vertical tabs, and form feeds between the
  1439. backslash and the subsequent newline. The preprocessor issues a
  1440. warning, but treats it as a valid escaped newline and combines the two
  1441. lines to form a single logical line. This works within comments and
  1442. tokens, as well as between tokens. Comments are @emph{not} treated as
  1443. whitespace for the purposes of this relaxation, since they have not
  1444. yet been replaced with spaces.
  1445. @node Subscripting
  1446. @section Non-Lvalue Arrays May Have Subscripts
  1447. @cindex subscripting
  1448. @cindex arrays, non-lvalue
  1449. @cindex subscripting and function values
  1450. In ISO C99, arrays that are not lvalues still decay to pointers, and
  1451. may be subscripted, although they may not be modified or used after
  1452. the next sequence point and the unary @samp{&} operator may not be
  1453. applied to them. As an extension, GNU C allows such arrays to be
  1454. subscripted in C90 mode, though otherwise they do not decay to
  1455. pointers outside C99 mode. For example,
  1456. this is valid in GNU C though not valid in C90:
  1457. @smallexample
  1458. @group
  1459. struct foo @{int a[4];@};
  1460. struct foo f();
  1461. bar (int index)
  1462. @{
  1463. return f().a[index];
  1464. @}
  1465. @end group
  1466. @end smallexample
  1467. @node Pointer Arith
  1468. @section Arithmetic on @code{void}- and Function-Pointers
  1469. @cindex void pointers, arithmetic
  1470. @cindex void, size of pointer to
  1471. @cindex function pointers, arithmetic
  1472. @cindex function, size of pointer to
  1473. In GNU C, addition and subtraction operations are supported on pointers to
  1474. @code{void} and on pointers to functions. This is done by treating the
  1475. size of a @code{void} or of a function as 1.
  1476. A consequence of this is that @code{sizeof} is also allowed on @code{void}
  1477. and on function types, and returns 1.
  1478. @opindex Wpointer-arith
  1479. The option @option{-Wpointer-arith} requests a warning if these extensions
  1480. are used.
  1481. @node Pointers to Arrays
  1482. @section Pointers to Arrays with Qualifiers Work as Expected
  1483. @cindex pointers to arrays
  1484. @cindex const qualifier
  1485. In GNU C, pointers to arrays with qualifiers work similar to pointers
  1486. to other qualified types. For example, a value of type @code{int (*)[5]}
  1487. can be used to initialize a variable of type @code{const int (*)[5]}.
  1488. These types are incompatible in ISO C because the @code{const} qualifier
  1489. is formally attached to the element type of the array and not the
  1490. array itself.
  1491. @smallexample
  1492. extern void
  1493. transpose (int N, int M, double out[M][N], const double in[N][M]);
  1494. double x[3][2];
  1495. double y[2][3];
  1496. @r{@dots{}}
  1497. transpose(3, 2, y, x);
  1498. @end smallexample
  1499. @node Initializers
  1500. @section Non-Constant Initializers
  1501. @cindex initializers, non-constant
  1502. @cindex non-constant initializers
  1503. As in standard C++ and ISO C99, the elements of an aggregate initializer for an
  1504. automatic variable are not required to be constant expressions in GNU C@.
  1505. Here is an example of an initializer with run-time varying elements:
  1506. @smallexample
  1507. foo (float f, float g)
  1508. @{
  1509. float beat_freqs[2] = @{ f-g, f+g @};
  1510. /* @r{@dots{}} */
  1511. @}
  1512. @end smallexample
  1513. @node Compound Literals
  1514. @section Compound Literals
  1515. @cindex constructor expressions
  1516. @cindex initializations in expressions
  1517. @cindex structures, constructor expression
  1518. @cindex expressions, constructor
  1519. @cindex compound literals
  1520. @c The GNU C name for what C99 calls compound literals was "constructor expressions".
  1521. ISO C99 supports compound literals. A compound literal looks like
  1522. a cast containing an initializer. Its value is an object of the
  1523. type specified in the cast, containing the elements specified in
  1524. the initializer; it is an lvalue. As an extension, GCC supports
  1525. compound literals in C90 mode and in C++, though the semantics are
  1526. somewhat different in C++.
  1527. Usually, the specified type is a structure. Assume that
  1528. @code{struct foo} and @code{structure} are declared as shown:
  1529. @smallexample
  1530. struct foo @{int a; char b[2];@} structure;
  1531. @end smallexample
  1532. @noindent
  1533. Here is an example of constructing a @code{struct foo} with a compound literal:
  1534. @smallexample
  1535. structure = ((struct foo) @{x + y, 'a', 0@});
  1536. @end smallexample
  1537. @noindent
  1538. This is equivalent to writing the following:
  1539. @smallexample
  1540. @{
  1541. struct foo temp = @{x + y, 'a', 0@};
  1542. structure = temp;
  1543. @}
  1544. @end smallexample
  1545. You can also construct an array, though this is dangerous in C++, as
  1546. explained below. If all the elements of the compound literal are
  1547. (made up of) simple constant expressions, suitable for use in
  1548. initializers of objects of static storage duration, then the compound
  1549. literal can be coerced to a pointer to its first element and used in
  1550. such an initializer, as shown here:
  1551. @smallexample
  1552. char **foo = (char *[]) @{ "x", "y", "z" @};
  1553. @end smallexample
  1554. Compound literals for scalar types and union types are
  1555. also allowed, but then the compound literal is equivalent
  1556. to a cast.
  1557. As a GNU extension, GCC allows initialization of objects with static storage
  1558. duration by compound literals (which is not possible in ISO C99, because
  1559. the initializer is not a constant).
  1560. It is handled as if the object is initialized only with the bracket
  1561. enclosed list if the types of the compound literal and the object match.
  1562. The initializer list of the compound literal must be constant.
  1563. If the object being initialized has array type of unknown size, the size is
  1564. determined by compound literal size.
  1565. @smallexample
  1566. static struct foo x = (struct foo) @{1, 'a', 'b'@};
  1567. static int y[] = (int []) @{1, 2, 3@};
  1568. static int z[] = (int [3]) @{1@};
  1569. @end smallexample
  1570. @noindent
  1571. The above lines are equivalent to the following:
  1572. @smallexample
  1573. static struct foo x = @{1, 'a', 'b'@};
  1574. static int y[] = @{1, 2, 3@};
  1575. static int z[] = @{1, 0, 0@};
  1576. @end smallexample
  1577. In C, a compound literal designates an unnamed object with static or
  1578. automatic storage duration. In C++, a compound literal designates a
  1579. temporary object, which only lives until the end of its
  1580. full-expression. As a result, well-defined C code that takes the
  1581. address of a subobject of a compound literal can be undefined in C++,
  1582. so the C++ compiler rejects the conversion of a temporary array to a pointer.
  1583. For instance, if the array compound literal example above appeared
  1584. inside a function, any subsequent use of @samp{foo} in C++ has
  1585. undefined behavior because the lifetime of the array ends after the
  1586. declaration of @samp{foo}.
  1587. As an optimization, the C++ compiler sometimes gives array compound
  1588. literals longer lifetimes: when the array either appears outside a
  1589. function or has const-qualified type. If @samp{foo} and its
  1590. initializer had elements of @samp{char *const} type rather than
  1591. @samp{char *}, or if @samp{foo} were a global variable, the array
  1592. would have static storage duration. But it is probably safest just to
  1593. avoid the use of array compound literals in code compiled as C++.
  1594. @node Designated Inits
  1595. @section Designated Initializers
  1596. @cindex initializers with labeled elements
  1597. @cindex labeled elements in initializers
  1598. @cindex case labels in initializers
  1599. @cindex designated initializers
  1600. Standard C90 requires the elements of an initializer to appear in a fixed
  1601. order, the same as the order of the elements in the array or structure
  1602. being initialized.
  1603. In ISO C99 you can give the elements in any order, specifying the array
  1604. indices or structure field names they apply to, and GNU C allows this as
  1605. an extension in C90 mode as well. This extension is not
  1606. implemented in GNU C++.
  1607. To specify an array index, write
  1608. @samp{[@var{index}] =} before the element value. For example,
  1609. @smallexample
  1610. int a[6] = @{ [4] = 29, [2] = 15 @};
  1611. @end smallexample
  1612. @noindent
  1613. is equivalent to
  1614. @smallexample
  1615. int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
  1616. @end smallexample
  1617. @noindent
  1618. The index values must be constant expressions, even if the array being
  1619. initialized is automatic.
  1620. An alternative syntax for this that has been obsolete since GCC 2.5 but
  1621. GCC still accepts is to write @samp{[@var{index}]} before the element
  1622. value, with no @samp{=}.
  1623. To initialize a range of elements to the same value, write
  1624. @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
  1625. extension. For example,
  1626. @smallexample
  1627. int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
  1628. @end smallexample
  1629. @noindent
  1630. If the value in it has side-effects, the side-effects happen only once,
  1631. not for each initialized field by the range initializer.
  1632. @noindent
  1633. Note that the length of the array is the highest value specified
  1634. plus one.
  1635. In a structure initializer, specify the name of a field to initialize
  1636. with @samp{.@var{fieldname} =} before the element value. For example,
  1637. given the following structure,
  1638. @smallexample
  1639. struct point @{ int x, y; @};
  1640. @end smallexample
  1641. @noindent
  1642. the following initialization
  1643. @smallexample
  1644. struct point p = @{ .y = yvalue, .x = xvalue @};
  1645. @end smallexample
  1646. @noindent
  1647. is equivalent to
  1648. @smallexample
  1649. struct point p = @{ xvalue, yvalue @};
  1650. @end smallexample
  1651. Another syntax that has the same meaning, obsolete since GCC 2.5, is
  1652. @samp{@var{fieldname}:}, as shown here:
  1653. @smallexample
  1654. struct point p = @{ y: yvalue, x: xvalue @};
  1655. @end smallexample
  1656. Omitted field members are implicitly initialized the same as objects
  1657. that have static storage duration.
  1658. @cindex designators
  1659. The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
  1660. @dfn{designator}. You can also use a designator (or the obsolete colon
  1661. syntax) when initializing a union, to specify which element of the union
  1662. should be used. For example,
  1663. @smallexample
  1664. union foo @{ int i; double d; @};
  1665. union foo f = @{ .d = 4 @};
  1666. @end smallexample
  1667. @noindent
  1668. converts 4 to a @code{double} to store it in the union using
  1669. the second element. By contrast, casting 4 to type @code{union foo}
  1670. stores it into the union as the integer @code{i}, since it is
  1671. an integer. (@xref{Cast to Union}.)
  1672. You can combine this technique of naming elements with ordinary C
  1673. initialization of successive elements. Each initializer element that
  1674. does not have a designator applies to the next consecutive element of the
  1675. array or structure. For example,
  1676. @smallexample
  1677. int a[6] = @{ [1] = v1, v2, [4] = v4 @};
  1678. @end smallexample
  1679. @noindent
  1680. is equivalent to
  1681. @smallexample
  1682. int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
  1683. @end smallexample
  1684. Labeling the elements of an array initializer is especially useful
  1685. when the indices are characters or belong to an @code{enum} type.
  1686. For example:
  1687. @smallexample
  1688. int whitespace[256]
  1689. = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
  1690. ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
  1691. @end smallexample
  1692. @cindex designator lists
  1693. You can also write a series of @samp{.@var{fieldname}} and
  1694. @samp{[@var{index}]} designators before an @samp{=} to specify a
  1695. nested subobject to initialize; the list is taken relative to the
  1696. subobject corresponding to the closest surrounding brace pair. For
  1697. example, with the @samp{struct point} declaration above:
  1698. @smallexample
  1699. struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
  1700. @end smallexample
  1701. @noindent
  1702. If the same field is initialized multiple times, it has the value from
  1703. the last initialization. If any such overridden initialization has
  1704. side-effect, it is unspecified whether the side-effect happens or not.
  1705. Currently, GCC discards them and issues a warning.
  1706. @node Case Ranges
  1707. @section Case Ranges
  1708. @cindex case ranges
  1709. @cindex ranges in case statements
  1710. You can specify a range of consecutive values in a single @code{case} label,
  1711. like this:
  1712. @smallexample
  1713. case @var{low} ... @var{high}:
  1714. @end smallexample
  1715. @noindent
  1716. This has the same effect as the proper number of individual @code{case}
  1717. labels, one for each integer value from @var{low} to @var{high}, inclusive.
  1718. This feature is especially useful for ranges of ASCII character codes:
  1719. @smallexample
  1720. case 'A' ... 'Z':
  1721. @end smallexample
  1722. @strong{Be careful:} Write spaces around the @code{...}, for otherwise
  1723. it may be parsed wrong when you use it with integer values. For example,
  1724. write this:
  1725. @smallexample
  1726. case 1 ... 5:
  1727. @end smallexample
  1728. @noindent
  1729. rather than this:
  1730. @smallexample
  1731. case 1...5:
  1732. @end smallexample
  1733. @node Cast to Union
  1734. @section Cast to a Union Type
  1735. @cindex cast to a union
  1736. @cindex union, casting to a
  1737. A cast to union type is similar to other casts, except that the type
  1738. specified is a union type. You can specify the type either with
  1739. @code{union @var{tag}} or with a typedef name. A cast to union is actually
  1740. a constructor, not a cast, and hence does not yield an lvalue like
  1741. normal casts. (@xref{Compound Literals}.)
  1742. The types that may be cast to the union type are those of the members
  1743. of the union. Thus, given the following union and variables:
  1744. @smallexample
  1745. union foo @{ int i; double d; @};
  1746. int x;
  1747. double y;
  1748. @end smallexample
  1749. @noindent
  1750. both @code{x} and @code{y} can be cast to type @code{union foo}.
  1751. Using the cast as the right-hand side of an assignment to a variable of
  1752. union type is equivalent to storing in a member of the union:
  1753. @smallexample
  1754. union foo u;
  1755. /* @r{@dots{}} */
  1756. u = (union foo) x @equiv{} u.i = x
  1757. u = (union foo) y @equiv{} u.d = y
  1758. @end smallexample
  1759. You can also use the union cast as a function argument:
  1760. @smallexample
  1761. void hack (union foo);
  1762. /* @r{@dots{}} */
  1763. hack ((union foo) x);
  1764. @end smallexample
  1765. @node Mixed Declarations
  1766. @section Mixed Declarations and Code
  1767. @cindex mixed declarations and code
  1768. @cindex declarations, mixed with code
  1769. @cindex code, mixed with declarations
  1770. ISO C99 and ISO C++ allow declarations and code to be freely mixed
  1771. within compound statements. As an extension, GNU C also allows this in
  1772. C90 mode. For example, you could do:
  1773. @smallexample
  1774. int i;
  1775. /* @r{@dots{}} */
  1776. i++;
  1777. int j = i + 2;
  1778. @end smallexample
  1779. Each identifier is visible from where it is declared until the end of
  1780. the enclosing block.
  1781. @node Function Attributes
  1782. @section Declaring Attributes of Functions
  1783. @cindex function attributes
  1784. @cindex declaring attributes of functions
  1785. @cindex functions that never return
  1786. @cindex functions that return more than once
  1787. @cindex functions that have no side effects
  1788. @cindex functions in arbitrary sections
  1789. @cindex functions that behave like malloc
  1790. @cindex @code{volatile} applied to function
  1791. @cindex @code{const} applied to function
  1792. @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
  1793. @cindex functions with non-null pointer arguments
  1794. @cindex functions that are passed arguments in registers on x86-32
  1795. @cindex functions that pop the argument stack on x86-32
  1796. @cindex functions that do not pop the argument stack on x86-32
  1797. @cindex functions that have different compilation options on x86-32
  1798. @cindex functions that have different optimization options
  1799. @cindex functions that are dynamically resolved
  1800. In GNU C, you declare certain things about functions called in your program
  1801. which help the compiler optimize function calls and check your code more
  1802. carefully.
  1803. The keyword @code{__attribute__} allows you to specify special
  1804. attributes when making a declaration. This keyword is followed by an
  1805. attribute specification inside double parentheses. The following
  1806. attributes are currently defined for functions on all targets:
  1807. @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
  1808. @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
  1809. @code{no_icf},
  1810. @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
  1811. @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
  1812. @code{no_instrument_function}, @code{no_split_stack},
  1813. @code{section}, @code{constructor},
  1814. @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
  1815. @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
  1816. @code{warn_unused_result}, @code{nonnull},
  1817. @code{returns_nonnull}, @code{gnu_inline},
  1818. @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
  1819. @code{no_sanitize_address}, @code{no_address_safety_analysis},
  1820. @code{no_sanitize_thread},
  1821. @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
  1822. @code{bnd_instrument}, @code{stack_protect},
  1823. @code{error} and @code{warning}.
  1824. Several other attributes are defined for functions on particular
  1825. target systems. Other attributes, including @code{section} are
  1826. supported for variables declarations (@pxref{Variable Attributes}),
  1827. labels (@pxref{Label Attributes})
  1828. and for types (@pxref{Type Attributes}).
  1829. GCC plugins may provide their own attributes.
  1830. You may also specify attributes with @samp{__} preceding and following
  1831. each keyword. This allows you to use them in header files without
  1832. being concerned about a possible macro of the same name. For example,
  1833. you may use @code{__noreturn__} instead of @code{noreturn}.
  1834. @xref{Attribute Syntax}, for details of the exact syntax for using
  1835. attributes.
  1836. @table @code
  1837. @c Keep this table alphabetized by attribute name. Treat _ as space.
  1838. @item alias ("@var{target}")
  1839. @cindex @code{alias} function attribute
  1840. The @code{alias} attribute causes the declaration to be emitted as an
  1841. alias for another symbol, which must be specified. For instance,
  1842. @smallexample
  1843. void __f () @{ /* @r{Do something.} */; @}
  1844. void f () __attribute__ ((weak, alias ("__f")));
  1845. @end smallexample
  1846. @noindent
  1847. defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
  1848. mangled name for the target must be used. It is an error if @samp{__f}
  1849. is not defined in the same translation unit.
  1850. Not all target machines support this attribute.
  1851. @item aligned (@var{alignment})
  1852. @cindex @code{aligned} function attribute
  1853. This attribute specifies a minimum alignment for the function,
  1854. measured in bytes.
  1855. You cannot use this attribute to decrease the alignment of a function,
  1856. only to increase it. However, when you explicitly specify a function
  1857. alignment this overrides the effect of the
  1858. @option{-falign-functions} (@pxref{Optimize Options}) option for this
  1859. function.
  1860. Note that the effectiveness of @code{aligned} attributes may be
  1861. limited by inherent limitations in your linker. On many systems, the
  1862. linker is only able to arrange for functions to be aligned up to a
  1863. certain maximum alignment. (For some linkers, the maximum supported
  1864. alignment may be very very small.) See your linker documentation for
  1865. further information.
  1866. The @code{aligned} attribute can also be used for variables and fields
  1867. (@pxref{Variable Attributes}.)
  1868. @item alloc_size
  1869. @cindex @code{alloc_size} function attribute
  1870. The @code{alloc_size} attribute is used to tell the compiler that the
  1871. function return value points to memory, where the size is given by
  1872. one or two of the functions parameters. GCC uses this
  1873. information to improve the correctness of @code{__builtin_object_size}.
  1874. The function parameter(s) denoting the allocated size are specified by
  1875. one or two integer arguments supplied to the attribute. The allocated size
  1876. is either the value of the single function argument specified or the product
  1877. of the two function arguments specified. Argument numbering starts at
  1878. one.
  1879. For instance,
  1880. @smallexample
  1881. void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
  1882. void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
  1883. @end smallexample
  1884. @noindent
  1885. declares that @code{my_calloc} returns memory of the size given by
  1886. the product of parameter 1 and 2 and that @code{my_realloc} returns memory
  1887. of the size given by parameter 2.
  1888. @item alloc_align
  1889. @cindex @code{alloc_align} function attribute
  1890. The @code{alloc_align} attribute is used to tell the compiler that the
  1891. function return value points to memory, where the returned pointer minimum
  1892. alignment is given by one of the functions parameters. GCC uses this
  1893. information to improve pointer alignment analysis.
  1894. The function parameter denoting the allocated alignment is specified by
  1895. one integer argument, whose number is the argument of the attribute.
  1896. Argument numbering starts at one.
  1897. For instance,
  1898. @smallexample
  1899. void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
  1900. @end smallexample
  1901. @noindent
  1902. declares that @code{my_memalign} returns memory with minimum alignment
  1903. given by parameter 1.
  1904. @item assume_aligned
  1905. @cindex @code{assume_aligned} function attribute
  1906. The @code{assume_aligned} attribute is used to tell the compiler that the
  1907. function return value points to memory, where the returned pointer minimum
  1908. alignment is given by the first argument.
  1909. If the attribute has two arguments, the second argument is misalignment offset.
  1910. For instance
  1911. @smallexample
  1912. void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
  1913. void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
  1914. @end smallexample
  1915. @noindent
  1916. declares that @code{my_alloc1} returns 16-byte aligned pointer and
  1917. that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
  1918. to 8.
  1919. @item always_inline
  1920. @cindex @code{always_inline} function attribute
  1921. Generally, functions are not inlined unless optimization is specified.
  1922. For functions declared inline, this attribute inlines the function
  1923. independent of any restrictions that otherwise apply to inlining.
  1924. Failure to inline such a function is diagnosed as an error.
  1925. Note that if such a function is called indirectly the compiler may
  1926. or may not inline it depending on optimization level and a failure
  1927. to inline an indirect call may or may not be diagnosed.
  1928. @item gnu_inline
  1929. @cindex @code{gnu_inline} function attribute
  1930. This attribute should be used with a function that is also declared
  1931. with the @code{inline} keyword. It directs GCC to treat the function
  1932. as if it were defined in gnu90 mode even when compiling in C99 or
  1933. gnu99 mode.
  1934. If the function is declared @code{extern}, then this definition of the
  1935. function is used only for inlining. In no case is the function
  1936. compiled as a standalone function, not even if you take its address
  1937. explicitly. Such an address becomes an external reference, as if you
  1938. had only declared the function, and had not defined it. This has
  1939. almost the effect of a macro. The way to use this is to put a
  1940. function definition in a header file with this attribute, and put
  1941. another copy of the function, without @code{extern}, in a library
  1942. file. The definition in the header file causes most calls to the
  1943. function to be inlined. If any uses of the function remain, they
  1944. refer to the single copy in the library. Note that the two
  1945. definitions of the functions need not be precisely the same, although
  1946. if they do not have the same effect your program may behave oddly.
  1947. In C, if the function is neither @code{extern} nor @code{static}, then
  1948. the function is compiled as a standalone function, as well as being
  1949. inlined where possible.
  1950. This is how GCC traditionally handled functions declared
  1951. @code{inline}. Since ISO C99 specifies a different semantics for
  1952. @code{inline}, this function attribute is provided as a transition
  1953. measure and as a useful feature in its own right. This attribute is
  1954. available in GCC 4.1.3 and later. It is available if either of the
  1955. preprocessor macros @code{__GNUC_GNU_INLINE__} or
  1956. @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
  1957. Function is As Fast As a Macro}.
  1958. In C++, this attribute does not depend on @code{extern} in any way,
  1959. but it still requires the @code{inline} keyword to enable its special
  1960. behavior.
  1961. @item artificial
  1962. @cindex @code{artificial} function attribute
  1963. This attribute is useful for small inline wrappers that if possible
  1964. should appear during debugging as a unit. Depending on the debug
  1965. info format it either means marking the function as artificial
  1966. or using the caller location for all instructions within the inlined
  1967. body.
  1968. @item bank_switch
  1969. @cindex @code{bank_switch} function attribute, M32C
  1970. When added to an interrupt handler with the M32C port, causes the
  1971. prologue and epilogue to use bank switching to preserve the registers
  1972. rather than saving them on the stack.
  1973. @item flatten
  1974. @cindex @code{flatten} function attribute
  1975. Generally, inlining into a function is limited. For a function marked with
  1976. this attribute, every call inside this function is inlined, if possible.
  1977. Whether the function itself is considered for inlining depends on its size and
  1978. the current inlining parameters.
  1979. @item error ("@var{message}")
  1980. @cindex @code{error} function attribute
  1981. If this attribute is used on a function declaration and a call to such a function
  1982. is not eliminated through dead code elimination or other optimizations, an error
  1983. that includes @var{message} is diagnosed. This is useful
  1984. for compile-time checking, especially together with @code{__builtin_constant_p}
  1985. and inline functions where checking the inline function arguments is not
  1986. possible through @code{extern char [(condition) ? 1 : -1];} tricks.
  1987. While it is possible to leave the function undefined and thus invoke
  1988. a link failure, when using this attribute the problem is diagnosed
  1989. earlier and with exact location of the call even in presence of inline
  1990. functions or when not emitting debugging information.
  1991. @item warning ("@var{message}")
  1992. @cindex @code{warning} function attribute
  1993. If this attribute is used on a function declaration and a call to such a function
  1994. is not eliminated through dead code elimination or other optimizations, a warning
  1995. that includes @var{message} is diagnosed. This is useful
  1996. for compile-time checking, especially together with @code{__builtin_constant_p}
  1997. and inline functions. While it is possible to define the function with
  1998. a message in @code{.gnu.warning*} section, when using this attribute the problem
  1999. is diagnosed earlier and with exact location of the call even in presence
  2000. of inline functions or when not emitting debugging information.
  2001. @item cdecl
  2002. @cindex @code{cdecl} function attribute, x86-32
  2003. @cindex functions that do pop the argument stack on x86-32
  2004. @opindex mrtd
  2005. On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
  2006. assume that the calling function pops off the stack space used to
  2007. pass arguments. This is
  2008. useful to override the effects of the @option{-mrtd} switch.
  2009. @item const
  2010. @cindex @code{const} function attribute
  2011. Many functions do not examine any values except their arguments, and
  2012. have no effects except the return value. Basically this is just slightly
  2013. more strict class than the @code{pure} attribute below, since function is not
  2014. allowed to read global memory.
  2015. @cindex pointer arguments
  2016. Note that a function that has pointer arguments and examines the data
  2017. pointed to must @emph{not} be declared @code{const}. Likewise, a
  2018. function that calls a non-@code{const} function usually must not be
  2019. @code{const}. It does not make sense for a @code{const} function to
  2020. return @code{void}.
  2021. @item constructor
  2022. @itemx destructor
  2023. @itemx constructor (@var{priority})
  2024. @itemx destructor (@var{priority})
  2025. @cindex @code{constructor} function attribute
  2026. @cindex @code{destructor} function attribute
  2027. The @code{constructor} attribute causes the function to be called
  2028. automatically before execution enters @code{main ()}. Similarly, the
  2029. @code{destructor} attribute causes the function to be called
  2030. automatically after @code{main ()} completes or @code{exit ()} is
  2031. called. Functions with these attributes are useful for
  2032. initializing data that is used implicitly during the execution of
  2033. the program.
  2034. You may provide an optional integer priority to control the order in
  2035. which constructor and destructor functions are run. A constructor
  2036. with a smaller priority number runs before a constructor with a larger
  2037. priority number; the opposite relationship holds for destructors. So,
  2038. if you have a constructor that allocates a resource and a destructor
  2039. that deallocates the same resource, both functions typically have the
  2040. same priority. The priorities for constructor and destructor
  2041. functions are the same as those specified for namespace-scope C++
  2042. objects (@pxref{C++ Attributes}).
  2043. These attributes are not currently implemented for Objective-C@.
  2044. @item deprecated
  2045. @itemx deprecated (@var{msg})
  2046. @cindex @code{deprecated} function attribute
  2047. The @code{deprecated} attribute results in a warning if the function
  2048. is used anywhere in the source file. This is useful when identifying
  2049. functions that are expected to be removed in a future version of a
  2050. program. The warning also includes the location of the declaration
  2051. of the deprecated function, to enable users to easily find further
  2052. information about why the function is deprecated, or what they should
  2053. do instead. Note that the warnings only occurs for uses:
  2054. @smallexample
  2055. int old_fn () __attribute__ ((deprecated));
  2056. int old_fn ();
  2057. int (*fn_ptr)() = old_fn;
  2058. @end smallexample
  2059. @noindent
  2060. results in a warning on line 3 but not line 2. The optional @var{msg}
  2061. argument, which must be a string, is printed in the warning if
  2062. present.
  2063. The @code{deprecated} attribute can also be used for variables and
  2064. types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
  2065. @item disinterrupt
  2066. @cindex @code{disinterrupt} function attribute, Epiphany
  2067. @cindex @code{disinterrupt} function attribute, MeP
  2068. On Epiphany and MeP targets, this attribute causes the compiler to emit
  2069. instructions to disable interrupts for the duration of the given
  2070. function.
  2071. @item dllexport
  2072. @cindex @code{dllexport} function attribute
  2073. @cindex @code{__declspec(dllexport)}
  2074. On Microsoft Windows targets and Symbian OS targets the
  2075. @code{dllexport} attribute causes the compiler to provide a global
  2076. pointer to a pointer in a DLL, so that it can be referenced with the
  2077. @code{dllimport} attribute. On Microsoft Windows targets, the pointer
  2078. name is formed by combining @code{_imp__} and the function or variable
  2079. name.
  2080. You can use @code{__declspec(dllexport)} as a synonym for
  2081. @code{__attribute__ ((dllexport))} for compatibility with other
  2082. compilers.
  2083. On systems that support the @code{visibility} attribute, this
  2084. attribute also implies ``default'' visibility. It is an error to
  2085. explicitly specify any other visibility.
  2086. GCC's default behavior is to emit all inline functions with the
  2087. @code{dllexport} attribute. Since this can cause object file-size bloat,
  2088. you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
  2089. ignore the attribute for inlined functions unless the
  2090. @option{-fkeep-inline-functions} flag is used instead.
  2091. The attribute is ignored for undefined symbols.
  2092. When applied to C++ classes, the attribute marks defined non-inlined
  2093. member functions and static data members as exports. Static consts
  2094. initialized in-class are not marked unless they are also defined
  2095. out-of-class.
  2096. For Microsoft Windows targets there are alternative methods for
  2097. including the symbol in the DLL's export table such as using a
  2098. @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
  2099. the @option{--export-all} linker flag.
  2100. @item dllimport
  2101. @cindex @code{dllimport} function attribute
  2102. @cindex @code{__declspec(dllimport)}
  2103. On Microsoft Windows and Symbian OS targets, the @code{dllimport}
  2104. attribute causes the compiler to reference a function or variable via
  2105. a global pointer to a pointer that is set up by the DLL exporting the
  2106. symbol. The attribute implies @code{extern}. On Microsoft Windows
  2107. targets, the pointer name is formed by combining @code{_imp__} and the
  2108. function or variable name.
  2109. You can use @code{__declspec(dllimport)} as a synonym for
  2110. @code{__attribute__ ((dllimport))} for compatibility with other
  2111. compilers.
  2112. On systems that support the @code{visibility} attribute, this
  2113. attribute also implies ``default'' visibility. It is an error to
  2114. explicitly specify any other visibility.
  2115. Currently, the attribute is ignored for inlined functions. If the
  2116. attribute is applied to a symbol @emph{definition}, an error is reported.
  2117. If a symbol previously declared @code{dllimport} is later defined, the
  2118. attribute is ignored in subsequent references, and a warning is emitted.
  2119. The attribute is also overridden by a subsequent declaration as
  2120. @code{dllexport}.
  2121. When applied to C++ classes, the attribute marks non-inlined
  2122. member functions and static data members as imports. However, the
  2123. attribute is ignored for virtual methods to allow creation of vtables
  2124. using thunks.
  2125. On the SH Symbian OS target the @code{dllimport} attribute also has
  2126. another affect---it can cause the vtable and run-time type information
  2127. for a class to be exported. This happens when the class has a
  2128. dllimported constructor or a non-inline, non-pure virtual function
  2129. and, for either of those two conditions, the class also has an inline
  2130. constructor or destructor and has a key function that is defined in
  2131. the current translation unit.
  2132. For Microsoft Windows targets the use of the @code{dllimport}
  2133. attribute on functions is not necessary, but provides a small
  2134. performance benefit by eliminating a thunk in the DLL@. The use of the
  2135. @code{dllimport} attribute on imported variables can be avoided by passing the
  2136. @option{--enable-auto-import} switch to the GNU linker. As with
  2137. functions, using the attribute for a variable eliminates a thunk in
  2138. the DLL@.
  2139. One drawback to using this attribute is that a pointer to a
  2140. @emph{variable} marked as @code{dllimport} cannot be used as a constant
  2141. address. However, a pointer to a @emph{function} with the
  2142. @code{dllimport} attribute can be used as a constant initializer; in
  2143. this case, the address of a stub function in the import lib is
  2144. referenced. On Microsoft Windows targets, the attribute can be disabled
  2145. for functions by setting the @option{-mnop-fun-dllimport} flag.
  2146. @item exception
  2147. @cindex @code{exception} function attribute
  2148. @cindex exception handler functions, NDS32
  2149. Use this attribute on the NDS32 target to indicate that the specified function
  2150. is an exception handler. The compiler will generate corresponding sections
  2151. for use in an exception handler.
  2152. @item exception_handler
  2153. @cindex @code{exception_handler} function attribute
  2154. @cindex exception handler functions, Blackfin
  2155. Use this attribute on the Blackfin to indicate that the specified function
  2156. is an exception handler. The compiler generates function entry and
  2157. exit sequences suitable for use in an exception handler when this
  2158. attribute is present.
  2159. @item externally_visible
  2160. @cindex @code{externally_visible} function attribute
  2161. This attribute, attached to a global variable or function, nullifies
  2162. the effect of the @option{-fwhole-program} command-line option, so the
  2163. object remains visible outside the current compilation unit.
  2164. If @option{-fwhole-program} is used together with @option{-flto} and
  2165. @command{gold} is used as the linker plugin,
  2166. @code{externally_visible} attributes are automatically added to functions
  2167. (not variable yet due to a current @command{gold} issue)
  2168. that are accessed outside of LTO objects according to resolution file
  2169. produced by @command{gold}.
  2170. For other linkers that cannot generate resolution file,
  2171. explicit @code{externally_visible} attributes are still necessary.
  2172. @item far
  2173. @cindex @code{far} function attribute
  2174. On MeP targets this causes the compiler to use a calling convention
  2175. that assumes the called function is too far away for the built-in
  2176. addressing modes.
  2177. @item fast_interrupt
  2178. @cindex @code{fast_interrupt} function attribute, M32C
  2179. @cindex @code{fast_interrupt} function attribute, RX
  2180. Use this attribute on the M32C and RX ports to indicate that the specified
  2181. function is a fast interrupt handler. This is just like the
  2182. @code{interrupt} attribute, except that @code{freit} is used to return
  2183. instead of @code{reit}.
  2184. @item fastcall
  2185. @cindex @code{fastcall} function attribute, x86-32
  2186. @cindex functions that pop the argument stack on x86-32
  2187. On x86-32 targets, the @code{fastcall} attribute causes the compiler to
  2188. pass the first argument (if of integral type) in the register ECX and
  2189. the second argument (if of integral type) in the register EDX@. Subsequent
  2190. and other typed arguments are passed on the stack. The called function
  2191. pops the arguments off the stack. If the number of arguments is variable all
  2192. arguments are pushed on the stack.
  2193. @item thiscall
  2194. @cindex @code{thiscall} function attribute, x86-32
  2195. @cindex functions that pop the argument stack on x86-32
  2196. On x86-32 targets, the @code{thiscall} attribute causes the compiler to
  2197. pass the first argument (if of integral type) in the register ECX.
  2198. Subsequent and other typed arguments are passed on the stack. The called
  2199. function pops the arguments off the stack.
  2200. If the number of arguments is variable all arguments are pushed on the
  2201. stack.
  2202. The @code{thiscall} attribute is intended for C++ non-static member functions.
  2203. As a GCC extension, this calling convention can be used for C functions
  2204. and for static member methods.
  2205. @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
  2206. @cindex @code{format} function attribute
  2207. @opindex Wformat
  2208. The @code{format} attribute specifies that a function takes @code{printf},
  2209. @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
  2210. should be type-checked against a format string. For example, the
  2211. declaration:
  2212. @smallexample
  2213. extern int
  2214. my_printf (void *my_object, const char *my_format, ...)
  2215. __attribute__ ((format (printf, 2, 3)));
  2216. @end smallexample
  2217. @noindent
  2218. causes the compiler to check the arguments in calls to @code{my_printf}
  2219. for consistency with the @code{printf} style format string argument
  2220. @code{my_format}.
  2221. The parameter @var{archetype} determines how the format string is
  2222. interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
  2223. @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
  2224. @code{strfmon}. (You can also use @code{__printf__},
  2225. @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
  2226. MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
  2227. @code{ms_strftime} are also present.
  2228. @var{archetype} values such as @code{printf} refer to the formats accepted
  2229. by the system's C runtime library,
  2230. while values prefixed with @samp{gnu_} always refer
  2231. to the formats accepted by the GNU C Library. On Microsoft Windows
  2232. targets, values prefixed with @samp{ms_} refer to the formats accepted by the
  2233. @file{msvcrt.dll} library.
  2234. The parameter @var{string-index}
  2235. specifies which argument is the format string argument (starting
  2236. from 1), while @var{first-to-check} is the number of the first
  2237. argument to check against the format string. For functions
  2238. where the arguments are not available to be checked (such as
  2239. @code{vprintf}), specify the third parameter as zero. In this case the
  2240. compiler only checks the format string for consistency. For
  2241. @code{strftime} formats, the third parameter is required to be zero.
  2242. Since non-static C++ methods have an implicit @code{this} argument, the
  2243. arguments of such methods should be counted from two, not one, when
  2244. giving values for @var{string-index} and @var{first-to-check}.
  2245. In the example above, the format string (@code{my_format}) is the second
  2246. argument of the function @code{my_print}, and the arguments to check
  2247. start with the third argument, so the correct parameters for the format
  2248. attribute are 2 and 3.
  2249. @opindex ffreestanding
  2250. @opindex fno-builtin
  2251. The @code{format} attribute allows you to identify your own functions
  2252. that take format strings as arguments, so that GCC can check the
  2253. calls to these functions for errors. The compiler always (unless
  2254. @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
  2255. for the standard library functions @code{printf}, @code{fprintf},
  2256. @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
  2257. @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
  2258. warnings are requested (using @option{-Wformat}), so there is no need to
  2259. modify the header file @file{stdio.h}. In C99 mode, the functions
  2260. @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
  2261. @code{vsscanf} are also checked. Except in strictly conforming C
  2262. standard modes, the X/Open function @code{strfmon} is also checked as
  2263. are @code{printf_unlocked} and @code{fprintf_unlocked}.
  2264. @xref{C Dialect Options,,Options Controlling C Dialect}.
  2265. For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
  2266. recognized in the same context. Declarations including these format attributes
  2267. are parsed for correct syntax, however the result of checking of such format
  2268. strings is not yet defined, and is not carried out by this version of the
  2269. compiler.
  2270. The target may also provide additional types of format checks.
  2271. @xref{Target Format Checks,,Format Checks Specific to Particular
  2272. Target Machines}.
  2273. @item format_arg (@var{string-index})
  2274. @cindex @code{format_arg} function attribute
  2275. @opindex Wformat-nonliteral
  2276. The @code{format_arg} attribute specifies that a function takes a format
  2277. string for a @code{printf}, @code{scanf}, @code{strftime} or
  2278. @code{strfmon} style function and modifies it (for example, to translate
  2279. it into another language), so the result can be passed to a
  2280. @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
  2281. function (with the remaining arguments to the format function the same
  2282. as they would have been for the unmodified string). For example, the
  2283. declaration:
  2284. @smallexample
  2285. extern char *
  2286. my_dgettext (char *my_domain, const char *my_format)
  2287. __attribute__ ((format_arg (2)));
  2288. @end smallexample
  2289. @noindent
  2290. causes the compiler to check the arguments in calls to a @code{printf},
  2291. @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
  2292. format string argument is a call to the @code{my_dgettext} function, for
  2293. consistency with the format string argument @code{my_format}. If the
  2294. @code{format_arg} attribute had not been specified, all the compiler
  2295. could tell in such calls to format functions would be that the format
  2296. string argument is not constant; this would generate a warning when
  2297. @option{-Wformat-nonliteral} is used, but the calls could not be checked
  2298. without the attribute.
  2299. The parameter @var{string-index} specifies which argument is the format
  2300. string argument (starting from one). Since non-static C++ methods have
  2301. an implicit @code{this} argument, the arguments of such methods should
  2302. be counted from two.
  2303. The @code{format_arg} attribute allows you to identify your own
  2304. functions that modify format strings, so that GCC can check the
  2305. calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
  2306. type function whose operands are a call to one of your own function.
  2307. The compiler always treats @code{gettext}, @code{dgettext}, and
  2308. @code{dcgettext} in this manner except when strict ISO C support is
  2309. requested by @option{-ansi} or an appropriate @option{-std} option, or
  2310. @option{-ffreestanding} or @option{-fno-builtin}
  2311. is used. @xref{C Dialect Options,,Options
  2312. Controlling C Dialect}.
  2313. For Objective-C dialects, the @code{format-arg} attribute may refer to an
  2314. @code{NSString} reference for compatibility with the @code{format} attribute
  2315. above.
  2316. The target may also allow additional types in @code{format-arg} attributes.
  2317. @xref{Target Format Checks,,Format Checks Specific to Particular
  2318. Target Machines}.
  2319. @item function_vector
  2320. @cindex @code{function_vector} function attribute, H8/300
  2321. @cindex @code{function_vector} function attribute, M16C/M32C
  2322. @cindex @code{function_vector} function attribute, SH
  2323. @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
  2324. Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
  2325. function should be called through the function vector. Calling a
  2326. function through the function vector reduces code size, however;
  2327. the function vector has a limited size (maximum 128 entries on the H8/300
  2328. and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
  2329. On SH2A targets, this attribute declares a function to be called using the
  2330. TBR relative addressing mode. The argument to this attribute is the entry
  2331. number of the same function in a vector table containing all the TBR
  2332. relative addressable functions. For correct operation the TBR must be setup
  2333. accordingly to point to the start of the vector table before any functions with
  2334. this attribute are invoked. Usually a good place to do the initialization is
  2335. the startup routine. The TBR relative vector table can have at max 256 function
  2336. entries. The jumps to these functions are generated using a SH2A specific,
  2337. non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
  2338. from GNU binutils version 2.7 or later for this attribute to work correctly.
  2339. Please refer the example of M16C target, to see the use of this
  2340. attribute while declaring a function,
  2341. In an application, for a function being called once, this attribute
  2342. saves at least 8 bytes of code; and if other successive calls are being
  2343. made to the same function, it saves 2 bytes of code per each of these
  2344. calls.
  2345. On M16C/M32C targets, the @code{function_vector} attribute declares a
  2346. special page subroutine call function. Use of this attribute reduces
  2347. the code size by 2 bytes for each call generated to the
  2348. subroutine. The argument to the attribute is the vector number entry
  2349. from the special page vector table which contains the 16 low-order
  2350. bits of the subroutine's entry address. Each vector table has special
  2351. page number (18 to 255) that is used in @code{jsrs} instructions.
  2352. Jump addresses of the routines are generated by adding 0x0F0000 (in
  2353. case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
  2354. 2-byte addresses set in the vector table. Therefore you need to ensure
  2355. that all the special page vector routines should get mapped within the
  2356. address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
  2357. (for M32C).
  2358. In the following example 2 bytes are saved for each call to
  2359. function @code{foo}.
  2360. @smallexample
  2361. void foo (void) __attribute__((function_vector(0x18)));
  2362. void foo (void)
  2363. @{
  2364. @}
  2365. void bar (void)
  2366. @{
  2367. foo();
  2368. @}
  2369. @end smallexample
  2370. If functions are defined in one file and are called in another file,
  2371. then be sure to write this declaration in both files.
  2372. This attribute is ignored for R8C target.
  2373. @item ifunc ("@var{resolver}")
  2374. @cindex @code{ifunc} function attribute
  2375. The @code{ifunc} attribute is used to mark a function as an indirect
  2376. function using the STT_GNU_IFUNC symbol type extension to the ELF
  2377. standard. This allows the resolution of the symbol value to be
  2378. determined dynamically at load time, and an optimized version of the
  2379. routine can be selected for the particular processor or other system
  2380. characteristics determined then. To use this attribute, first define
  2381. the implementation functions available, and a resolver function that
  2382. returns a pointer to the selected implementation function. The
  2383. implementation functions' declarations must match the API of the
  2384. function being implemented, the resolver's declaration is be a
  2385. function returning pointer to void function returning void:
  2386. @smallexample
  2387. void *my_memcpy (void *dst, const void *src, size_t len)
  2388. @{
  2389. @dots{}
  2390. @}
  2391. static void (*resolve_memcpy (void)) (void)
  2392. @{
  2393. return my_memcpy; // we'll just always select this routine
  2394. @}
  2395. @end smallexample
  2396. @noindent
  2397. The exported header file declaring the function the user calls would
  2398. contain:
  2399. @smallexample
  2400. extern void *memcpy (void *, const void *, size_t);
  2401. @end smallexample
  2402. @noindent
  2403. allowing the user to call this as a regular function, unaware of the
  2404. implementation. Finally, the indirect function needs to be defined in
  2405. the same translation unit as the resolver function:
  2406. @smallexample
  2407. void *memcpy (void *, const void *, size_t)
  2408. __attribute__ ((ifunc ("resolve_memcpy")));
  2409. @end smallexample
  2410. Indirect functions cannot be weak. Binutils version 2.20.1 or higher
  2411. and GNU C Library version 2.11.1 are required to use this feature.
  2412. @item interrupt
  2413. @cindex @code{interrupt} function attribute, ARC
  2414. @cindex @code{interrupt} function attribute, ARM
  2415. @cindex @code{interrupt} function attribute, AVR
  2416. @cindex @code{interrupt} function attribute, CR16
  2417. @cindex @code{interrupt} function attribute, Epiphany
  2418. @cindex @code{interrupt} function attribute, M32C
  2419. @cindex @code{interrupt} function attribute, M32R/D
  2420. @cindex @code{interrupt} function attribute, m68k
  2421. @cindex @code{interrupt} function attribute, MeP
  2422. @cindex @code{interrupt} function attribute, MIPS
  2423. @cindex @code{interrupt} function attribute, MSP430
  2424. @cindex @code{interrupt} function attribute, NDS32
  2425. @cindex @code{interrupt} function attribute, RL78
  2426. @cindex @code{interrupt} function attribute, RX
  2427. @cindex @code{interrupt} function attribute, Visium
  2428. @cindex @code{interrupt} function attribute, Xstormy16
  2429. Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
  2430. m68k, MeP, MIPS, MSP430, NDS32, RL78, RX, Visium and Xstormy16 ports to indicate
  2431. that the specified function is an interrupt handler. The compiler generates
  2432. function entry and exit sequences suitable for use in an interrupt handler
  2433. when this attribute is present. With Epiphany targets it may also generate
  2434. a special section with code to initialize the interrupt vector table.
  2435. Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
  2436. and SH processors can be specified via the @code{interrupt_handler} attribute.
  2437. Note, on the ARC, you must specify the kind of interrupt to be handled
  2438. in a parameter to the interrupt attribute like this:
  2439. @smallexample
  2440. void f () __attribute__ ((interrupt ("ilink1")));
  2441. @end smallexample
  2442. Permissible values for this parameter are: @w{@code{ilink1}} and
  2443. @w{@code{ilink2}}.
  2444. Note, on the AVR, the hardware globally disables interrupts when an
  2445. interrupt is executed. The first instruction of an interrupt handler
  2446. declared with this attribute is a @code{SEI} instruction to
  2447. re-enable interrupts. See also the @code{signal} function attribute
  2448. that does not insert a @code{SEI} instruction. If both @code{signal} and
  2449. @code{interrupt} are specified for the same function, @code{signal}
  2450. is silently ignored.
  2451. Note, for the ARM, you can specify the kind of interrupt to be handled by
  2452. adding an optional parameter to the interrupt attribute like this:
  2453. @smallexample
  2454. void f () __attribute__ ((interrupt ("IRQ")));
  2455. @end smallexample
  2456. @noindent
  2457. Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
  2458. @code{SWI}, @code{ABORT} and @code{UNDEF}.
  2459. On ARMv7-M the interrupt type is ignored, and the attribute means the function
  2460. may be called with a word-aligned stack pointer.
  2461. Note, for the MSP430 you can provide an argument to the interrupt
  2462. attribute which specifies a name or number. If the argument is a
  2463. number it indicates the slot in the interrupt vector table (0 - 31) to
  2464. which this handler should be assigned. If the argument is a name it
  2465. is treated as a symbolic name for the vector slot. These names should
  2466. match up with appropriate entries in the linker script. By default
  2467. the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
  2468. @code{reset} for vector 31 are recognized.
  2469. You can also use the following function attributes to modify how
  2470. normal functions interact with interrupt functions:
  2471. @table @code
  2472. @item critical
  2473. @cindex @code{critical} function attribute, MSP430
  2474. Critical functions disable interrupts upon entry and restore the
  2475. previous interrupt state upon exit. Critical functions cannot also
  2476. have the @code{naked} or @code{reentrant} attributes. They can have
  2477. the @code{interrupt} attribute.
  2478. @item reentrant
  2479. @cindex @code{reentrant} function attribute, MSP430
  2480. Reentrant functions disable interrupts upon entry and enable them
  2481. upon exit. Reentrant functions cannot also have the @code{naked}
  2482. or @code{critical} attributes. They can have the @code{interrupt}
  2483. attribute.
  2484. @item wakeup
  2485. @cindex @code{wakeup} function attribute, MSP430
  2486. This attribute only applies to interrupt functions. It is silently
  2487. ignored if applied to a non-interrupt function. A wakeup interrupt
  2488. function will rouse the processor from any low-power state that it
  2489. might be in when the function exits.
  2490. @end table
  2491. On Epiphany targets one or more optional parameters can be added like this:
  2492. @smallexample
  2493. void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
  2494. @end smallexample
  2495. Permissible values for these parameters are: @w{@code{reset}},
  2496. @w{@code{software_exception}}, @w{@code{page_miss}},
  2497. @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
  2498. @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
  2499. Multiple parameters indicate that multiple entries in the interrupt
  2500. vector table should be initialized for this function, i.e.@: for each
  2501. parameter @w{@var{name}}, a jump to the function is emitted in
  2502. the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
  2503. entirely, in which case no interrupt vector table entry is provided.
  2504. Note, on Epiphany targets, interrupts are enabled inside the function
  2505. unless the @code{disinterrupt} attribute is also specified.
  2506. On Epiphany targets, you can also use the following attribute to
  2507. modify the behavior of an interrupt handler:
  2508. @table @code
  2509. @item forwarder_section
  2510. @cindex @code{forwarder_section} function attribute, Epiphany
  2511. The interrupt handler may be in external memory which cannot be
  2512. reached by a branch instruction, so generate a local memory trampoline
  2513. to transfer control. The single parameter identifies the section where
  2514. the trampoline is placed.
  2515. @end table
  2516. The following examples are all valid uses of these attributes on
  2517. Epiphany targets:
  2518. @smallexample
  2519. void __attribute__ ((interrupt)) universal_handler ();
  2520. void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
  2521. void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
  2522. void __attribute__ ((interrupt ("timer0"), disinterrupt))
  2523. fast_timer_handler ();
  2524. void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
  2525. external_dma_handler ();
  2526. @end smallexample
  2527. On MIPS targets, you can use the following attributes to modify the behavior
  2528. of an interrupt handler:
  2529. @table @code
  2530. @item use_shadow_register_set
  2531. @cindex @code{use_shadow_register_set} function attribute, MIPS
  2532. Assume that the handler uses a shadow register set, instead of
  2533. the main general-purpose registers.
  2534. @item keep_interrupts_masked
  2535. @cindex @code{keep_interrupts_masked} function attribute, MIPS
  2536. Keep interrupts masked for the whole function. Without this attribute,
  2537. GCC tries to reenable interrupts for as much of the function as it can.
  2538. @item use_debug_exception_return
  2539. @cindex @code{use_debug_exception_return} function attribute, MIPS
  2540. Return using the @code{deret} instruction. Interrupt handlers that don't
  2541. have this attribute return using @code{eret} instead.
  2542. @end table
  2543. You can use any combination of these attributes, as shown below:
  2544. @smallexample
  2545. void __attribute__ ((interrupt)) v0 ();
  2546. void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
  2547. void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
  2548. void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
  2549. void __attribute__ ((interrupt, use_shadow_register_set,
  2550. keep_interrupts_masked)) v4 ();
  2551. void __attribute__ ((interrupt, use_shadow_register_set,
  2552. use_debug_exception_return)) v5 ();
  2553. void __attribute__ ((interrupt, keep_interrupts_masked,
  2554. use_debug_exception_return)) v6 ();
  2555. void __attribute__ ((interrupt, use_shadow_register_set,
  2556. keep_interrupts_masked,
  2557. use_debug_exception_return)) v7 ();
  2558. @end smallexample
  2559. On NDS32 target, this attribute indicates that the specified function
  2560. is an interrupt handler. The compiler generates corresponding sections
  2561. for use in an interrupt handler. You can use the following attributes
  2562. to modify the behavior:
  2563. @table @code
  2564. @item nested
  2565. @cindex @code{nested} function attribute, NDS32
  2566. This interrupt service routine is interruptible.
  2567. @item not_nested
  2568. @cindex @code{not_nested} function attribute, NDS32
  2569. This interrupt service routine is not interruptible.
  2570. @item nested_ready
  2571. @cindex @code{nested_ready} function attribute, NDS32
  2572. This interrupt service routine is interruptible after @code{PSW.GIE}
  2573. (global interrupt enable) is set. This allows interrupt service routine to
  2574. finish some short critical code before enabling interrupts.
  2575. @item save_all
  2576. @cindex @code{save_all} function attribute, NDS32
  2577. The system will help save all registers into stack before entering
  2578. interrupt handler.
  2579. @item partial_save
  2580. @cindex @code{partial_save} function attribute, NDS32
  2581. The system will help save caller registers into stack before entering
  2582. interrupt handler.
  2583. @end table
  2584. @cindex @code{brk_interrupt} function attribute, RL78
  2585. On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
  2586. handlers intended to be used with the @code{BRK} opcode (i.e.@: those
  2587. that must end with @code{RETB} instead of @code{RETI}).
  2588. On RX targets, you may specify one or more vector numbers as arguments
  2589. to the attribute, as well as naming an alternate table name.
  2590. Parameters are handled sequentially, so one handler can be assigned to
  2591. multiple entries in multiple tables. One may also pass the magic
  2592. string @code{"$default"} which causes the function to be used for any
  2593. unfilled slots in the current table.
  2594. This example shows a simple assignment of a function to one vector in
  2595. the default table (note that preprocessor macros may be used for
  2596. chip-specific symbolic vector names):
  2597. @smallexample
  2598. void __attribute__ ((interrupt (5))) txd1_handler ();
  2599. @end smallexample
  2600. This example assigns a function to two slots in the default table
  2601. (using preprocessor macros defined elsewhere) and makes it the default
  2602. for the @code{dct} table:
  2603. @smallexample
  2604. void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
  2605. txd1_handler ();
  2606. @end smallexample
  2607. @item interrupt_handler
  2608. @cindex @code{interrupt_handler} function attribute, Blackfin
  2609. @cindex @code{interrupt_handler} function attribute, m68k
  2610. @cindex @code{interrupt_handler} function attribute, H8/300
  2611. @cindex @code{interrupt_handler} function attribute, SH
  2612. Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
  2613. indicate that the specified function is an interrupt handler. The compiler
  2614. generates function entry and exit sequences suitable for use in an
  2615. interrupt handler when this attribute is present.
  2616. @item interrupt_thread
  2617. @cindex @code{interrupt_thread} function attribute, fido
  2618. Use this attribute on fido, a subarchitecture of the m68k, to indicate
  2619. that the specified function is an interrupt handler that is designed
  2620. to run as a thread. The compiler omits generate prologue/epilogue
  2621. sequences and replaces the return instruction with a @code{sleep}
  2622. instruction. This attribute is available only on fido.
  2623. @item isr
  2624. @cindex @code{isr} function attribute, ARM
  2625. Use this attribute on ARM to write Interrupt Service Routines. This is an
  2626. alias to the @code{interrupt} attribute above.
  2627. @item kspisusp
  2628. @cindex @code{kspisusp} function attribute, Blackfin
  2629. @cindex User stack pointer in interrupts on the Blackfin
  2630. When used together with @code{interrupt_handler}, @code{exception_handler}
  2631. or @code{nmi_handler}, code is generated to load the stack pointer
  2632. from the USP register in the function prologue.
  2633. @item l1_text
  2634. @cindex @code{l1_text} function attribute, Blackfin
  2635. This attribute specifies a function to be placed into L1 Instruction
  2636. SRAM@. The function is put into a specific section named @code{.l1.text}.
  2637. With @option{-mfdpic}, function calls with a such function as the callee
  2638. or caller uses inlined PLT.
  2639. @item l2
  2640. @cindex @code{l2} function attribute, Blackfin
  2641. On the Blackfin, this attribute specifies a function to be placed into L2
  2642. SRAM. The function is put into a specific section named
  2643. @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
  2644. an inlined PLT.
  2645. @item leaf
  2646. @cindex @code{leaf} function attribute
  2647. Calls to external functions with this attribute must return to the current
  2648. compilation unit only by return or by exception handling. In particular, leaf
  2649. functions are not allowed to call callback function passed to it from the current
  2650. compilation unit or directly call functions exported by the unit or longjmp
  2651. into the unit. Leaf function might still call functions from other compilation
  2652. units and thus they are not necessarily leaf in the sense that they contain no
  2653. function calls at all.
  2654. The attribute is intended for library functions to improve dataflow analysis.
  2655. The compiler takes the hint that any data not escaping the current compilation unit can
  2656. not be used or modified by the leaf function. For example, the @code{sin} function
  2657. is a leaf function, but @code{qsort} is not.
  2658. Note that leaf functions might invoke signals and signal handlers might be
  2659. defined in the current compilation unit and use static variables. The only
  2660. compliant way to write such a signal handler is to declare such variables
  2661. @code{volatile}.
  2662. The attribute has no effect on functions defined within the current compilation
  2663. unit. This is to allow easy merging of multiple compilation units into one,
  2664. for example, by using the link-time optimization. For this reason the
  2665. attribute is not allowed on types to annotate indirect calls.
  2666. @item long_call
  2667. @itemx medium_call
  2668. @itemx short_call
  2669. @cindex @code{long_call} function attribute, ARC
  2670. @cindex @code{long_call} function attribute, ARM
  2671. @cindex @code{long_call} function attribute, Epiphany
  2672. @cindex @code{medium_call} function attribute, ARC
  2673. @cindex @code{short_call} function attribute, ARC
  2674. @cindex @code{short_call} function attribute, ARM
  2675. @cindex @code{short_call} function attribute, Epiphany
  2676. @cindex indirect calls, ARC
  2677. @cindex indirect calls, ARM
  2678. @cindex indirect calls, Epiphany
  2679. These attributes specify how a particular function is called on
  2680. ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
  2681. These attributes override the
  2682. @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
  2683. and @option{-mmedium-calls} (@pxref{ARC Options})
  2684. command-line switches and @code{#pragma long_calls} settings. For ARM, the
  2685. @code{long_call} attribute indicates that the function might be far
  2686. away from the call site and require a different (more expensive)
  2687. calling sequence. The @code{short_call} attribute always places
  2688. the offset to the function from the call site into the @samp{BL}
  2689. instruction directly.
  2690. For ARC, a function marked with the @code{long_call} attribute is
  2691. always called using register-indirect jump-and-link instructions,
  2692. thereby enabling the called function to be placed anywhere within the
  2693. 32-bit address space. A function marked with the @code{medium_call}
  2694. attribute will always be close enough to be called with an unconditional
  2695. branch-and-link instruction, which has a 25-bit offset from
  2696. the call site. A function marked with the @code{short_call}
  2697. attribute will always be close enough to be called with a conditional
  2698. branch-and-link instruction, which has a 21-bit offset from
  2699. the call site.
  2700. @item longcall
  2701. @itemx shortcall
  2702. @cindex indirect calls, Blackfin
  2703. @cindex indirect calls, PowerPC
  2704. @cindex @code{longcall} function attribute, Blackfin
  2705. @cindex @code{longcall} function attribute, PowerPC
  2706. @cindex @code{shortcall} function attribute, Blackfin
  2707. @cindex @code{shortcall} function attribute, PowerPC
  2708. On Blackfin and PowerPC, the @code{longcall} attribute
  2709. indicates that the function might be far away from the call site and
  2710. require a different (more expensive) calling sequence. The
  2711. @code{shortcall} attribute indicates that the function is always close
  2712. enough for the shorter calling sequence to be used. These attributes
  2713. override both the @option{-mlongcall} switch and, on the RS/6000 and
  2714. PowerPC, the @code{#pragma longcall} setting.
  2715. @xref{RS/6000 and PowerPC Options}, for more information on whether long
  2716. calls are necessary.
  2717. @item long_call
  2718. @itemx near
  2719. @itemx far
  2720. @cindex indirect calls, MIPS
  2721. @cindex @code{long_call} function attribute, MIPS
  2722. @cindex @code{near} function attribute, MIPS
  2723. @cindex @code{far} function attribute, MIPS
  2724. These attributes specify how a particular function is called on MIPS@.
  2725. The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
  2726. command-line switch. The @code{long_call} and @code{far} attributes are
  2727. synonyms, and cause the compiler to always call
  2728. the function by first loading its address into a register, and then using
  2729. the contents of that register. The @code{near} attribute has the opposite
  2730. effect; it specifies that non-PIC calls should be made using the more
  2731. efficient @code{jal} instruction.
  2732. @item malloc
  2733. @cindex @code{malloc} function attribute
  2734. This tells the compiler that a function is @code{malloc}-like, i.e.,
  2735. that the pointer @var{P} returned by the function cannot alias any
  2736. other pointer valid when the function returns, and moreover no
  2737. pointers to valid objects occur in any storage addressed by @var{P}.
  2738. Using this attribute can improve optimization. Functions like
  2739. @code{malloc} and @code{calloc} have this property because they return
  2740. a pointer to uninitialized or zeroed-out storage. However, functions
  2741. like @code{realloc} do not have this property, as they can return a
  2742. pointer to storage containing pointers.
  2743. @item mips16
  2744. @itemx nomips16
  2745. @cindex @code{mips16} function attribute, MIPS
  2746. @cindex @code{nomips16} function attribute, MIPS
  2747. On MIPS targets, you can use the @code{mips16} and @code{nomips16}
  2748. function attributes to locally select or turn off MIPS16 code generation.
  2749. A function with the @code{mips16} attribute is emitted as MIPS16 code,
  2750. while MIPS16 code generation is disabled for functions with the
  2751. @code{nomips16} attribute. These attributes override the
  2752. @option{-mips16} and @option{-mno-mips16} options on the command line
  2753. (@pxref{MIPS Options}).
  2754. When compiling files containing mixed MIPS16 and non-MIPS16 code, the
  2755. preprocessor symbol @code{__mips16} reflects the setting on the command line,
  2756. not that within individual functions. Mixed MIPS16 and non-MIPS16 code
  2757. may interact badly with some GCC extensions such as @code{__builtin_apply}
  2758. (@pxref{Constructing Calls}).
  2759. @item micromips, MIPS
  2760. @itemx nomicromips, MIPS
  2761. @cindex @code{micromips} function attribute
  2762. @cindex @code{nomicromips} function attribute
  2763. On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
  2764. function attributes to locally select or turn off microMIPS code generation.
  2765. A function with the @code{micromips} attribute is emitted as microMIPS code,
  2766. while microMIPS code generation is disabled for functions with the
  2767. @code{nomicromips} attribute. These attributes override the
  2768. @option{-mmicromips} and @option{-mno-micromips} options on the command line
  2769. (@pxref{MIPS Options}).
  2770. When compiling files containing mixed microMIPS and non-microMIPS code, the
  2771. preprocessor symbol @code{__mips_micromips} reflects the setting on the
  2772. command line,
  2773. not that within individual functions. Mixed microMIPS and non-microMIPS code
  2774. may interact badly with some GCC extensions such as @code{__builtin_apply}
  2775. (@pxref{Constructing Calls}).
  2776. @item model (@var{model-name})
  2777. @cindex @code{model} function attribute, M32R/D
  2778. @cindex function addressability on the M32R/D
  2779. On the M32R/D, use this attribute to set the addressability of an
  2780. object, and of the code generated for a function. The identifier
  2781. @var{model-name} is one of @code{small}, @code{medium}, or
  2782. @code{large}, representing each of the code models.
  2783. Small model objects live in the lower 16MB of memory (so that their
  2784. addresses can be loaded with the @code{ld24} instruction), and are
  2785. callable with the @code{bl} instruction.
  2786. Medium model objects may live anywhere in the 32-bit address space (the
  2787. compiler generates @code{seth/add3} instructions to load their addresses),
  2788. and are callable with the @code{bl} instruction.
  2789. Large model objects may live anywhere in the 32-bit address space (the
  2790. compiler generates @code{seth/add3} instructions to load their addresses),
  2791. and may not be reachable with the @code{bl} instruction (the compiler
  2792. generates the much slower @code{seth/add3/jl} instruction sequence).
  2793. @item ms_abi
  2794. @itemx sysv_abi
  2795. @cindex @code{ms_abi} function attribute, x86
  2796. @cindex @code{sysv_abi} function attribute, x86
  2797. On 32-bit and 64-bit x86 targets, you can use an ABI attribute
  2798. to indicate which calling convention should be used for a function. The
  2799. @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
  2800. while the @code{sysv_abi} attribute tells the compiler to use the ABI
  2801. used on GNU/Linux and other systems. The default is to use the Microsoft ABI
  2802. when targeting Windows. On all other systems, the default is the x86/AMD ABI.
  2803. Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
  2804. requires the @option{-maccumulate-outgoing-args} option.
  2805. @item callee_pop_aggregate_return (@var{number})
  2806. @cindex @code{callee_pop_aggregate_return} function attribute, x86
  2807. On x86-32 targets, you can use this attribute to control how
  2808. aggregates are returned in memory. If the caller is responsible for
  2809. popping the hidden pointer together with the rest of the arguments, specify
  2810. @var{number} equal to zero. If callee is responsible for popping the
  2811. hidden pointer, specify @var{number} equal to one.
  2812. The default x86-32 ABI assumes that the callee pops the
  2813. stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
  2814. the compiler assumes that the
  2815. caller pops the stack for hidden pointer.
  2816. @item ms_hook_prologue
  2817. @cindex @code{ms_hook_prologue} function attribute, x86
  2818. On 32-bit and 64-bit x86 targets, you can use
  2819. this function attribute to make GCC generate the ``hot-patching'' function
  2820. prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
  2821. and newer.
  2822. @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
  2823. @cindex @code{hotpatch} function attribute, S/390
  2824. On S/390 System z targets, you can use this function attribute to
  2825. make GCC generate a ``hot-patching'' function prologue. If the
  2826. @option{-mhotpatch=} command-line option is used at the same time,
  2827. the @code{hotpatch} attribute takes precedence. The first of the
  2828. two arguments specifies the number of halfwords to be added before
  2829. the function label. A second argument can be used to specify the
  2830. number of halfwords to be added after the function label. For
  2831. both arguments the maximum allowed value is 1000000.
  2832. If both arguments are zero, hotpatching is disabled.
  2833. @item naked
  2834. @cindex @code{naked} function attribute, ARM
  2835. @cindex @code{naked} function attribute, AVR
  2836. @cindex @code{naked} function attribute, MCORE
  2837. @cindex @code{naked} function attribute, MSP430
  2838. @cindex @code{naked} function attribute, NDS32
  2839. @cindex @code{naked} function attribute, RL78
  2840. @cindex @code{naked} function attribute, RX
  2841. @cindex @code{naked} function attribute, SPU
  2842. @cindex function without prologue/epilogue code
  2843. This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
  2844. RL78, RX and SPU ports. It allows the compiler to construct the
  2845. requisite function declaration, while allowing the body of the
  2846. function to be assembly code. The specified function will not have
  2847. prologue/epilogue sequences generated by the compiler. Only basic
  2848. @code{asm} statements can safely be included in naked functions
  2849. (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
  2850. basic @code{asm} and C code may appear to work, they cannot be
  2851. depended upon to work reliably and are not supported.
  2852. @item near
  2853. @cindex @code{near} function attribute, MeP
  2854. @cindex functions that do not handle memory bank switching on 68HC11/68HC12
  2855. On MeP targets this attribute causes the compiler to assume the called
  2856. function is close enough to use the normal calling convention,
  2857. overriding the @option{-mtf} command-line option.
  2858. @item nesting
  2859. @cindex @code{nesting} function attribute, Blackfin
  2860. @cindex Allow nesting in an interrupt handler on the Blackfin processor
  2861. Use this attribute together with @code{interrupt_handler},
  2862. @code{exception_handler} or @code{nmi_handler} to indicate that the function
  2863. entry code should enable nested interrupts or exceptions.
  2864. @item nmi_handler
  2865. @cindex @code{nmi_handler} function attribute, Blackfin
  2866. @cindex NMI handler functions on the Blackfin processor
  2867. Use this attribute on the Blackfin to indicate that the specified function
  2868. is an NMI handler. The compiler generates function entry and
  2869. exit sequences suitable for use in an NMI handler when this
  2870. attribute is present.
  2871. @item nocompression
  2872. @cindex @code{nocompression} function attribute, MIPS
  2873. On MIPS targets, you can use the @code{nocompression} function attribute
  2874. to locally turn off MIPS16 and microMIPS code generation. This attribute
  2875. overrides the @option{-mips16} and @option{-mmicromips} options on the
  2876. command line (@pxref{MIPS Options}).
  2877. @item no_instrument_function
  2878. @cindex @code{no_instrument_function} function attribute
  2879. @opindex finstrument-functions
  2880. If @option{-finstrument-functions} is given, profiling function calls are
  2881. generated at entry and exit of most user-compiled functions.
  2882. Functions with this attribute are not so instrumented.
  2883. @item no_split_stack
  2884. @cindex @code{no_split_stack} function attribute
  2885. @opindex fsplit-stack
  2886. If @option{-fsplit-stack} is given, functions have a small
  2887. prologue which decides whether to split the stack. Functions with the
  2888. @code{no_split_stack} attribute do not have that prologue, and thus
  2889. may run with only a small amount of stack space available.
  2890. @item stack_protect
  2891. @cindex @code{stack_protect} function attribute
  2892. This function attribute make a stack protection of the function if
  2893. flags @option{fstack-protector} or @option{fstack-protector-strong}
  2894. or @option{fstack-protector-explicit} are set.
  2895. @item noinline
  2896. @cindex @code{noinline} function attribute
  2897. This function attribute prevents a function from being considered for
  2898. inlining.
  2899. @c Don't enumerate the optimizations by name here; we try to be
  2900. @c future-compatible with this mechanism.
  2901. If the function does not have side-effects, there are optimizations
  2902. other than inlining that cause function calls to be optimized away,
  2903. although the function call is live. To keep such calls from being
  2904. optimized away, put
  2905. @smallexample
  2906. asm ("");
  2907. @end smallexample
  2908. @noindent
  2909. (@pxref{Extended Asm}) in the called function, to serve as a special
  2910. side-effect.
  2911. @item noclone
  2912. @cindex @code{noclone} function attribute
  2913. This function attribute prevents a function from being considered for
  2914. cloning---a mechanism that produces specialized copies of functions
  2915. and which is (currently) performed by interprocedural constant
  2916. propagation.
  2917. @item no_icf
  2918. @cindex @code{no_icf} function attribute
  2919. This function attribute prevents a functions from being merged with another
  2920. semantically equivalent function.
  2921. @item nonnull (@var{arg-index}, @dots{})
  2922. @cindex @code{nonnull} function attribute
  2923. The @code{nonnull} attribute specifies that some function parameters should
  2924. be non-null pointers. For instance, the declaration:
  2925. @smallexample
  2926. extern void *
  2927. my_memcpy (void *dest, const void *src, size_t len)
  2928. __attribute__((nonnull (1, 2)));
  2929. @end smallexample
  2930. @noindent
  2931. causes the compiler to check that, in calls to @code{my_memcpy},
  2932. arguments @var{dest} and @var{src} are non-null. If the compiler
  2933. determines that a null pointer is passed in an argument slot marked
  2934. as non-null, and the @option{-Wnonnull} option is enabled, a warning
  2935. is issued. The compiler may also choose to make optimizations based
  2936. on the knowledge that certain function arguments will never be null.
  2937. If no argument index list is given to the @code{nonnull} attribute,
  2938. all pointer arguments are marked as non-null. To illustrate, the
  2939. following declaration is equivalent to the previous example:
  2940. @smallexample
  2941. extern void *
  2942. my_memcpy (void *dest, const void *src, size_t len)
  2943. __attribute__((nonnull));
  2944. @end smallexample
  2945. @item no_reorder
  2946. @cindex @code{no_reorder} function attribute
  2947. Do not reorder functions or variables marked @code{no_reorder}
  2948. against each other or top level assembler statements the executable.
  2949. The actual order in the program will depend on the linker command
  2950. line. Static variables marked like this are also not removed.
  2951. This has a similar effect
  2952. as the @option{-fno-toplevel-reorder} option, but only applies to the
  2953. marked symbols.
  2954. @item returns_nonnull
  2955. @cindex @code{returns_nonnull} function attribute
  2956. The @code{returns_nonnull} attribute specifies that the function
  2957. return value should be a non-null pointer. For instance, the declaration:
  2958. @smallexample
  2959. extern void *
  2960. mymalloc (size_t len) __attribute__((returns_nonnull));
  2961. @end smallexample
  2962. @noindent
  2963. lets the compiler optimize callers based on the knowledge
  2964. that the return value will never be null.
  2965. @item noreturn
  2966. @cindex @code{noreturn} function attribute
  2967. A few standard library functions, such as @code{abort} and @code{exit},
  2968. cannot return. GCC knows this automatically. Some programs define
  2969. their own functions that never return. You can declare them
  2970. @code{noreturn} to tell the compiler this fact. For example,
  2971. @smallexample
  2972. @group
  2973. void fatal () __attribute__ ((noreturn));
  2974. void
  2975. fatal (/* @r{@dots{}} */)
  2976. @{
  2977. /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
  2978. exit (1);
  2979. @}
  2980. @end group
  2981. @end smallexample
  2982. The @code{noreturn} keyword tells the compiler to assume that
  2983. @code{fatal} cannot return. It can then optimize without regard to what
  2984. would happen if @code{fatal} ever did return. This makes slightly
  2985. better code. More importantly, it helps avoid spurious warnings of
  2986. uninitialized variables.
  2987. The @code{noreturn} keyword does not affect the exceptional path when that
  2988. applies: a @code{noreturn}-marked function may still return to the caller
  2989. by throwing an exception or calling @code{longjmp}.
  2990. Do not assume that registers saved by the calling function are
  2991. restored before calling the @code{noreturn} function.
  2992. It does not make sense for a @code{noreturn} function to have a return
  2993. type other than @code{void}.
  2994. @item nothrow
  2995. @cindex @code{nothrow} function attribute
  2996. The @code{nothrow} attribute is used to inform the compiler that a
  2997. function cannot throw an exception. For example, most functions in
  2998. the standard C library can be guaranteed not to throw an exception
  2999. with the notable exceptions of @code{qsort} and @code{bsearch} that
  3000. take function pointer arguments.
  3001. @item nosave_low_regs
  3002. @cindex @code{nosave_low_regs} function attribute, SH
  3003. Use this attribute on SH targets to indicate that an @code{interrupt_handler}
  3004. function should not save and restore registers R0..R7. This can be used on SH3*
  3005. and SH4* targets that have a second R0..R7 register bank for non-reentrant
  3006. interrupt handlers.
  3007. @item optimize
  3008. @cindex @code{optimize} function attribute
  3009. The @code{optimize} attribute is used to specify that a function is to
  3010. be compiled with different optimization options than specified on the
  3011. command line. Arguments can either be numbers or strings. Numbers
  3012. are assumed to be an optimization level. Strings that begin with
  3013. @code{O} are assumed to be an optimization option, while other options
  3014. are assumed to be used with a @code{-f} prefix. You can also use the
  3015. @samp{#pragma GCC optimize} pragma to set the optimization options
  3016. that affect more than one function.
  3017. @xref{Function Specific Option Pragmas}, for details about the
  3018. @samp{#pragma GCC optimize} pragma.
  3019. This can be used for instance to have frequently-executed functions
  3020. compiled with more aggressive optimization options that produce faster
  3021. and larger code, while other functions can be compiled with less
  3022. aggressive options.
  3023. @item OS_main
  3024. @itemx OS_task
  3025. @cindex @code{OS_main} function attribute, AVR
  3026. @cindex @code{OS_task} function attribute, AVR
  3027. On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
  3028. do not save/restore any call-saved register in their prologue/epilogue.
  3029. The @code{OS_main} attribute can be used when there @emph{is
  3030. guarantee} that interrupts are disabled at the time when the function
  3031. is entered. This saves resources when the stack pointer has to be
  3032. changed to set up a frame for local variables.
  3033. The @code{OS_task} attribute can be used when there is @emph{no
  3034. guarantee} that interrupts are disabled at that time when the function
  3035. is entered like for, e@.g@. task functions in a multi-threading operating
  3036. system. In that case, changing the stack pointer register is
  3037. guarded by save/clear/restore of the global interrupt enable flag.
  3038. The differences to the @code{naked} function attribute are:
  3039. @itemize @bullet
  3040. @item @code{naked} functions do not have a return instruction whereas
  3041. @code{OS_main} and @code{OS_task} functions have a @code{RET} or
  3042. @code{RETI} return instruction.
  3043. @item @code{naked} functions do not set up a frame for local variables
  3044. or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
  3045. as needed.
  3046. @end itemize
  3047. @item pcs
  3048. @cindex @code{pcs} function attribute, ARM
  3049. The @code{pcs} attribute can be used to control the calling convention
  3050. used for a function on ARM. The attribute takes an argument that specifies
  3051. the calling convention to use.
  3052. When compiling using the AAPCS ABI (or a variant of it) then valid
  3053. values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
  3054. order to use a variant other than @code{"aapcs"} then the compiler must
  3055. be permitted to use the appropriate co-processor registers (i.e., the
  3056. VFP registers must be available in order to use @code{"aapcs-vfp"}).
  3057. For example,
  3058. @smallexample
  3059. /* Argument passed in r0, and result returned in r0+r1. */
  3060. double f2d (float) __attribute__((pcs("aapcs")));
  3061. @end smallexample
  3062. Variadic functions always use the @code{"aapcs"} calling convention and
  3063. the compiler rejects attempts to specify an alternative.
  3064. @item pure
  3065. @cindex @code{pure} function attribute
  3066. Many functions have no effects except the return value and their
  3067. return value depends only on the parameters and/or global variables.
  3068. Such a function can be subject
  3069. to common subexpression elimination and loop optimization just as an
  3070. arithmetic operator would be. These functions should be declared
  3071. with the attribute @code{pure}. For example,
  3072. @smallexample
  3073. int square (int) __attribute__ ((pure));
  3074. @end smallexample
  3075. @noindent
  3076. says that the hypothetical function @code{square} is safe to call
  3077. fewer times than the program says.
  3078. Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
  3079. Interesting non-pure functions are functions with infinite loops or those
  3080. depending on volatile memory or other system resource, that may change between
  3081. two consecutive calls (such as @code{feof} in a multithreading environment).
  3082. @item hot
  3083. @cindex @code{hot} function attribute
  3084. The @code{hot} attribute on a function is used to inform the compiler that
  3085. the function is a hot spot of the compiled program. The function is
  3086. optimized more aggressively and on many targets it is placed into a special
  3087. subsection of the text section so all hot functions appear close together,
  3088. improving locality.
  3089. When profile feedback is available, via @option{-fprofile-use}, hot functions
  3090. are automatically detected and this attribute is ignored.
  3091. @item cold
  3092. @cindex @code{cold} function attribute
  3093. The @code{cold} attribute on functions is used to inform the compiler that
  3094. the function is unlikely to be executed. The function is optimized for
  3095. size rather than speed and on many targets it is placed into a special
  3096. subsection of the text section so all cold functions appear close together,
  3097. improving code locality of non-cold parts of program. The paths leading
  3098. to calls of cold functions within code are marked as unlikely by the branch
  3099. prediction mechanism. It is thus useful to mark functions used to handle
  3100. unlikely conditions, such as @code{perror}, as cold to improve optimization
  3101. of hot functions that do call marked functions in rare occasions.
  3102. When profile feedback is available, via @option{-fprofile-use}, cold functions
  3103. are automatically detected and this attribute is ignored.
  3104. @item no_sanitize_address
  3105. @itemx no_address_safety_analysis
  3106. @cindex @code{no_sanitize_address} function attribute
  3107. The @code{no_sanitize_address} attribute on functions is used
  3108. to inform the compiler that it should not instrument memory accesses
  3109. in the function when compiling with the @option{-fsanitize=address} option.
  3110. The @code{no_address_safety_analysis} is a deprecated alias of the
  3111. @code{no_sanitize_address} attribute, new code should use
  3112. @code{no_sanitize_address}.
  3113. @item no_sanitize_thread
  3114. @cindex @code{no_sanitize_thread} function attribute
  3115. The @code{no_sanitize_thread} attribute on functions is used
  3116. to inform the compiler that it should not instrument memory accesses
  3117. in the function when compiling with the @option{-fsanitize=thread} option.
  3118. @item no_sanitize_undefined
  3119. @cindex @code{no_sanitize_undefined} function attribute
  3120. The @code{no_sanitize_undefined} attribute on functions is used
  3121. to inform the compiler that it should not check for undefined behavior
  3122. in the function when compiling with the @option{-fsanitize=undefined} option.
  3123. @item bnd_legacy
  3124. @cindex @code{bnd_legacy} function attribute
  3125. @cindex Pointer Bounds Checker attributes
  3126. The @code{bnd_legacy} attribute on functions is used to inform the
  3127. compiler that the function should not be instrumented when compiled
  3128. with the @option{-fcheck-pointer-bounds} option.
  3129. @item bnd_instrument
  3130. @cindex @code{bnd_instrument} function attribute
  3131. The @code{bnd_instrument} attribute on functions is used to inform the
  3132. compiler that the function should be instrumented when compiled
  3133. with the @option{-fchkp-instrument-marked-only} option.
  3134. @item regparm (@var{number})
  3135. @cindex @code{regparm} function attribute, x86
  3136. @cindex functions that are passed arguments in registers on x86-32
  3137. On x86-32 targets, the @code{regparm} attribute causes the compiler to
  3138. pass arguments number one to @var{number} if they are of integral type
  3139. in registers EAX, EDX, and ECX instead of on the stack. Functions that
  3140. take a variable number of arguments continue to be passed all of their
  3141. arguments on the stack.
  3142. Beware that on some ELF systems this attribute is unsuitable for
  3143. global functions in shared libraries with lazy binding (which is the
  3144. default). Lazy binding sends the first call via resolving code in
  3145. the loader, which might assume EAX, EDX and ECX can be clobbered, as
  3146. per the standard calling conventions. Solaris 8 is affected by this.
  3147. Systems with the GNU C Library version 2.1 or higher
  3148. and FreeBSD are believed to be
  3149. safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
  3150. disabled with the linker or the loader if desired, to avoid the
  3151. problem.)
  3152. @item reset
  3153. @cindex @code{reset} function attribute, NDS32
  3154. @cindex reset handler functions
  3155. Use this attribute on the NDS32 target to indicate that the specified function
  3156. is a reset handler. The compiler will generate corresponding sections
  3157. for use in a reset handler. You can use the following attributes
  3158. to provide extra exception handling:
  3159. @table @code
  3160. @item nmi
  3161. @cindex @code{nmi} function attribute, NDS32
  3162. Provide a user-defined function to handle NMI exception.
  3163. @item warm
  3164. @cindex @code{warm} function attribute, NDS32
  3165. Provide a user-defined function to handle warm reset exception.
  3166. @end table
  3167. @item sseregparm
  3168. @cindex @code{sseregparm} function attribute, x86
  3169. On x86-32 targets with SSE support, the @code{sseregparm} attribute
  3170. causes the compiler to pass up to 3 floating-point arguments in
  3171. SSE registers instead of on the stack. Functions that take a
  3172. variable number of arguments continue to pass all of their
  3173. floating-point arguments on the stack.
  3174. @item force_align_arg_pointer
  3175. @cindex @code{force_align_arg_pointer} function attribute, x86
  3176. On x86 targets, the @code{force_align_arg_pointer} attribute may be
  3177. applied to individual function definitions, generating an alternate
  3178. prologue and epilogue that realigns the run-time stack if necessary.
  3179. This supports mixing legacy codes that run with a 4-byte aligned stack
  3180. with modern codes that keep a 16-byte stack for SSE compatibility.
  3181. @item renesas
  3182. @cindex @code{renesas} function attribute, SH
  3183. On SH targets this attribute specifies that the function or struct follows the
  3184. Renesas ABI.
  3185. @item resbank
  3186. @cindex @code{resbank} function attribute, SH
  3187. On the SH2A target, this attribute enables the high-speed register
  3188. saving and restoration using a register bank for @code{interrupt_handler}
  3189. routines. Saving to the bank is performed automatically after the CPU
  3190. accepts an interrupt that uses a register bank.
  3191. The nineteen 32-bit registers comprising general register R0 to R14,
  3192. control register GBR, and system registers MACH, MACL, and PR and the
  3193. vector table address offset are saved into a register bank. Register
  3194. banks are stacked in first-in last-out (FILO) sequence. Restoration
  3195. from the bank is executed by issuing a RESBANK instruction.
  3196. @item returns_twice
  3197. @cindex @code{returns_twice} function attribute
  3198. The @code{returns_twice} attribute tells the compiler that a function may
  3199. return more than one time. The compiler ensures that all registers
  3200. are dead before calling such a function and emits a warning about
  3201. the variables that may be clobbered after the second return from the
  3202. function. Examples of such functions are @code{setjmp} and @code{vfork}.
  3203. The @code{longjmp}-like counterpart of such function, if any, might need
  3204. to be marked with the @code{noreturn} attribute.
  3205. @item saveall
  3206. @cindex @code{saveall} function attribute, Blackfin
  3207. @cindex @code{saveall} function attribute, H8/300
  3208. @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
  3209. Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
  3210. all registers except the stack pointer should be saved in the prologue
  3211. regardless of whether they are used or not.
  3212. @item save_volatiles
  3213. @cindex @code{save_volatiles} function attribute, MicroBlaze
  3214. Use this attribute on the MicroBlaze to indicate that the function is
  3215. an interrupt handler. All volatile registers (in addition to non-volatile
  3216. registers) are saved in the function prologue. If the function is a leaf
  3217. function, only volatiles used by the function are saved. A normal function
  3218. return is generated instead of a return from interrupt.
  3219. @item break_handler
  3220. @cindex @code{break_handler} function attribute, MicroBlaze
  3221. @cindex break handler functions
  3222. Use this attribute on the MicroBlaze ports to indicate that
  3223. the specified function is a break handler. The compiler generates function
  3224. entry and exit sequences suitable for use in an break handler when this
  3225. attribute is present. The return from @code{break_handler} is done through
  3226. the @code{rtbd} instead of @code{rtsd}.
  3227. @smallexample
  3228. void f () __attribute__ ((break_handler));
  3229. @end smallexample
  3230. @item section ("@var{section-name}")
  3231. @cindex @code{section} function attribute
  3232. Normally, the compiler places the code it generates in the @code{text} section.
  3233. Sometimes, however, you need additional sections, or you need certain
  3234. particular functions to appear in special sections. The @code{section}
  3235. attribute specifies that a function lives in a particular section.
  3236. For example, the declaration:
  3237. @smallexample
  3238. extern void foobar (void) __attribute__ ((section ("bar")));
  3239. @end smallexample
  3240. @noindent
  3241. puts the function @code{foobar} in the @code{bar} section.
  3242. Some file formats do not support arbitrary sections so the @code{section}
  3243. attribute is not available on all platforms.
  3244. If you need to map the entire contents of a module to a particular
  3245. section, consider using the facilities of the linker instead.
  3246. @item sentinel
  3247. @cindex @code{sentinel} function attribute
  3248. This function attribute ensures that a parameter in a function call is
  3249. an explicit @code{NULL}. The attribute is only valid on variadic
  3250. functions. By default, the sentinel is located at position zero, the
  3251. last parameter of the function call. If an optional integer position
  3252. argument P is supplied to the attribute, the sentinel must be located at
  3253. position P counting backwards from the end of the argument list.
  3254. @smallexample
  3255. __attribute__ ((sentinel))
  3256. is equivalent to
  3257. __attribute__ ((sentinel(0)))
  3258. @end smallexample
  3259. The attribute is automatically set with a position of 0 for the built-in
  3260. functions @code{execl} and @code{execlp}. The built-in function
  3261. @code{execle} has the attribute set with a position of 1.
  3262. A valid @code{NULL} in this context is defined as zero with any pointer
  3263. type. If your system defines the @code{NULL} macro with an integer type
  3264. then you need to add an explicit cast. GCC replaces @code{stddef.h}
  3265. with a copy that redefines NULL appropriately.
  3266. The warnings for missing or incorrect sentinels are enabled with
  3267. @option{-Wformat}.
  3268. @item short_call
  3269. See @code{long_call}.
  3270. @item shortcall
  3271. See @code{longcall}.
  3272. @item signal
  3273. @cindex @code{signal} function attribute, AVR
  3274. Use this attribute on the AVR to indicate that the specified
  3275. function is an interrupt handler. The compiler generates function
  3276. entry and exit sequences suitable for use in an interrupt handler when this
  3277. attribute is present.
  3278. See also the @code{interrupt} function attribute.
  3279. The AVR hardware globally disables interrupts when an interrupt is executed.
  3280. Interrupt handler functions defined with the @code{signal} attribute
  3281. do not re-enable interrupts. It is save to enable interrupts in a
  3282. @code{signal} handler. This ``save'' only applies to the code
  3283. generated by the compiler and not to the IRQ layout of the
  3284. application which is responsibility of the application.
  3285. If both @code{signal} and @code{interrupt} are specified for the same
  3286. function, @code{signal} is silently ignored.
  3287. @item sp_switch
  3288. @cindex @code{sp_switch} function attribute, SH
  3289. Use this attribute on the SH to indicate an @code{interrupt_handler}
  3290. function should switch to an alternate stack. It expects a string
  3291. argument that names a global variable holding the address of the
  3292. alternate stack.
  3293. @smallexample
  3294. void *alt_stack;
  3295. void f () __attribute__ ((interrupt_handler,
  3296. sp_switch ("alt_stack")));
  3297. @end smallexample
  3298. @item stdcall
  3299. @cindex @code{stdcall} function attribute, x86-32
  3300. @cindex functions that pop the argument stack on x86-32
  3301. On x86-32 targets, the @code{stdcall} attribute causes the compiler to
  3302. assume that the called function pops off the stack space used to
  3303. pass arguments, unless it takes a variable number of arguments.
  3304. @item syscall_linkage
  3305. @cindex @code{syscall_linkage} function attribute, IA-64
  3306. This attribute is used to modify the IA-64 calling convention by marking
  3307. all input registers as live at all function exits. This makes it possible
  3308. to restart a system call after an interrupt without having to save/restore
  3309. the input registers. This also prevents kernel data from leaking into
  3310. application code.
  3311. @item target
  3312. @cindex @code{target} function attribute
  3313. The @code{target} attribute is used to specify that a function is to
  3314. be compiled with different target options than specified on the
  3315. command line. This can be used for instance to have functions
  3316. compiled with a different ISA (instruction set architecture) than the
  3317. default. You can also use the @samp{#pragma GCC target} pragma to set
  3318. more than one function to be compiled with specific target options.
  3319. @xref{Function Specific Option Pragmas}, for details about the
  3320. @samp{#pragma GCC target} pragma.
  3321. For instance on an x86, you could compile one function with
  3322. @code{target("sse4.1,arch=core2")} and another with
  3323. @code{target("sse4a,arch=amdfam10")}. This is equivalent to
  3324. compiling the first function with @option{-msse4.1} and
  3325. @option{-march=core2} options, and the second function with
  3326. @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
  3327. user to make sure that a function is only invoked on a machine that
  3328. supports the particular ISA it is compiled for (for example by using
  3329. @code{cpuid} on x86 to determine what feature bits and architecture
  3330. family are used).
  3331. @smallexample
  3332. int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
  3333. int sse3_func (void) __attribute__ ((__target__ ("sse3")));
  3334. @end smallexample
  3335. You can either use multiple
  3336. strings to specify multiple options, or separate the options
  3337. with a comma (@samp{,}).
  3338. The @code{target} attribute is presently implemented for
  3339. x86, PowerPC, and Nios II targets only.
  3340. The options supported are specific to each target.
  3341. On the x86, the following options are allowed:
  3342. @table @samp
  3343. @item abm
  3344. @itemx no-abm
  3345. @cindex @code{target("abm")} function attribute, x86
  3346. Enable/disable the generation of the advanced bit instructions.
  3347. @item aes
  3348. @itemx no-aes
  3349. @cindex @code{target("aes")} function attribute, x86
  3350. Enable/disable the generation of the AES instructions.
  3351. @item default
  3352. @cindex @code{target("default")} function attribute, x86
  3353. @xref{Function Multiversioning}, where it is used to specify the
  3354. default function version.
  3355. @item mmx
  3356. @itemx no-mmx
  3357. @cindex @code{target("mmx")} function attribute, x86
  3358. Enable/disable the generation of the MMX instructions.
  3359. @item pclmul
  3360. @itemx no-pclmul
  3361. @cindex @code{target("pclmul")} function attribute, x86
  3362. Enable/disable the generation of the PCLMUL instructions.
  3363. @item popcnt
  3364. @itemx no-popcnt
  3365. @cindex @code{target("popcnt")} function attribute, x86
  3366. Enable/disable the generation of the POPCNT instruction.
  3367. @item sse
  3368. @itemx no-sse
  3369. @cindex @code{target("sse")} function attribute, x86
  3370. Enable/disable the generation of the SSE instructions.
  3371. @item sse2
  3372. @itemx no-sse2
  3373. @cindex @code{target("sse2")} function attribute, x86
  3374. Enable/disable the generation of the SSE2 instructions.
  3375. @item sse3
  3376. @itemx no-sse3
  3377. @cindex @code{target("sse3")} function attribute, x86
  3378. Enable/disable the generation of the SSE3 instructions.
  3379. @item sse4
  3380. @itemx no-sse4
  3381. @cindex @code{target("sse4")} function attribute, x86
  3382. Enable/disable the generation of the SSE4 instructions (both SSE4.1
  3383. and SSE4.2).
  3384. @item sse4.1
  3385. @itemx no-sse4.1
  3386. @cindex @code{target("sse4.1")} function attribute, x86
  3387. Enable/disable the generation of the sse4.1 instructions.
  3388. @item sse4.2
  3389. @itemx no-sse4.2
  3390. @cindex @code{target("sse4.2")} function attribute, x86
  3391. Enable/disable the generation of the sse4.2 instructions.
  3392. @item sse4a
  3393. @itemx no-sse4a
  3394. @cindex @code{target("sse4a")} function attribute, x86
  3395. Enable/disable the generation of the SSE4A instructions.
  3396. @item fma4
  3397. @itemx no-fma4
  3398. @cindex @code{target("fma4")} function attribute, x86
  3399. Enable/disable the generation of the FMA4 instructions.
  3400. @item xop
  3401. @itemx no-xop
  3402. @cindex @code{target("xop")} function attribute, x86
  3403. Enable/disable the generation of the XOP instructions.
  3404. @item lwp
  3405. @itemx no-lwp
  3406. @cindex @code{target("lwp")} function attribute, x86
  3407. Enable/disable the generation of the LWP instructions.
  3408. @item ssse3
  3409. @itemx no-ssse3
  3410. @cindex @code{target("ssse3")} function attribute, x86
  3411. Enable/disable the generation of the SSSE3 instructions.
  3412. @item cld
  3413. @itemx no-cld
  3414. @cindex @code{target("cld")} function attribute, x86
  3415. Enable/disable the generation of the CLD before string moves.
  3416. @item fancy-math-387
  3417. @itemx no-fancy-math-387
  3418. @cindex @code{target("fancy-math-387")} function attribute, x86
  3419. Enable/disable the generation of the @code{sin}, @code{cos}, and
  3420. @code{sqrt} instructions on the 387 floating-point unit.
  3421. @item fused-madd
  3422. @itemx no-fused-madd
  3423. @cindex @code{target("fused-madd")} function attribute, x86
  3424. Enable/disable the generation of the fused multiply/add instructions.
  3425. @item ieee-fp
  3426. @itemx no-ieee-fp
  3427. @cindex @code{target("ieee-fp")} function attribute, x86
  3428. Enable/disable the generation of floating point that depends on IEEE arithmetic.
  3429. @item inline-all-stringops
  3430. @itemx no-inline-all-stringops
  3431. @cindex @code{target("inline-all-stringops")} function attribute, x86
  3432. Enable/disable inlining of string operations.
  3433. @item inline-stringops-dynamically
  3434. @itemx no-inline-stringops-dynamically
  3435. @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
  3436. Enable/disable the generation of the inline code to do small string
  3437. operations and calling the library routines for large operations.
  3438. @item align-stringops
  3439. @itemx no-align-stringops
  3440. @cindex @code{target("align-stringops")} function attribute, x86
  3441. Do/do not align destination of inlined string operations.
  3442. @item recip
  3443. @itemx no-recip
  3444. @cindex @code{target("recip")} function attribute, x86
  3445. Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
  3446. instructions followed an additional Newton-Raphson step instead of
  3447. doing a floating-point division.
  3448. @item arch=@var{ARCH}
  3449. @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
  3450. Specify the architecture to generate code for in compiling the function.
  3451. @item tune=@var{TUNE}
  3452. @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
  3453. Specify the architecture to tune for in compiling the function.
  3454. @item fpmath=@var{FPMATH}
  3455. @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
  3456. Specify which floating-point unit to use. The
  3457. @code{target("fpmath=sse,387")} option must be specified as
  3458. @code{target("fpmath=sse+387")} because the comma would separate
  3459. different options.
  3460. @end table
  3461. On the PowerPC, the following options are allowed:
  3462. @table @samp
  3463. @item altivec
  3464. @itemx no-altivec
  3465. @cindex @code{target("altivec")} function attribute, PowerPC
  3466. Generate code that uses (does not use) AltiVec instructions. In
  3467. 32-bit code, you cannot enable AltiVec instructions unless
  3468. @option{-mabi=altivec} is used on the command line.
  3469. @item cmpb
  3470. @itemx no-cmpb
  3471. @cindex @code{target("cmpb")} function attribute, PowerPC
  3472. Generate code that uses (does not use) the compare bytes instruction
  3473. implemented on the POWER6 processor and other processors that support
  3474. the PowerPC V2.05 architecture.
  3475. @item dlmzb
  3476. @itemx no-dlmzb
  3477. @cindex @code{target("dlmzb")} function attribute, PowerPC
  3478. Generate code that uses (does not use) the string-search @samp{dlmzb}
  3479. instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
  3480. generated by default when targeting those processors.
  3481. @item fprnd
  3482. @itemx no-fprnd
  3483. @cindex @code{target("fprnd")} function attribute, PowerPC
  3484. Generate code that uses (does not use) the FP round to integer
  3485. instructions implemented on the POWER5+ processor and other processors
  3486. that support the PowerPC V2.03 architecture.
  3487. @item hard-dfp
  3488. @itemx no-hard-dfp
  3489. @cindex @code{target("hard-dfp")} function attribute, PowerPC
  3490. Generate code that uses (does not use) the decimal floating-point
  3491. instructions implemented on some POWER processors.
  3492. @item isel
  3493. @itemx no-isel
  3494. @cindex @code{target("isel")} function attribute, PowerPC
  3495. Generate code that uses (does not use) ISEL instruction.
  3496. @item mfcrf
  3497. @itemx no-mfcrf
  3498. @cindex @code{target("mfcrf")} function attribute, PowerPC
  3499. Generate code that uses (does not use) the move from condition
  3500. register field instruction implemented on the POWER4 processor and
  3501. other processors that support the PowerPC V2.01 architecture.
  3502. @item mfpgpr
  3503. @itemx no-mfpgpr
  3504. @cindex @code{target("mfpgpr")} function attribute, PowerPC
  3505. Generate code that uses (does not use) the FP move to/from general
  3506. purpose register instructions implemented on the POWER6X processor and
  3507. other processors that support the extended PowerPC V2.05 architecture.
  3508. @item mulhw
  3509. @itemx no-mulhw
  3510. @cindex @code{target("mulhw")} function attribute, PowerPC
  3511. Generate code that uses (does not use) the half-word multiply and
  3512. multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
  3513. These instructions are generated by default when targeting those
  3514. processors.
  3515. @item multiple
  3516. @itemx no-multiple
  3517. @cindex @code{target("multiple")} function attribute, PowerPC
  3518. Generate code that uses (does not use) the load multiple word
  3519. instructions and the store multiple word instructions.
  3520. @item update
  3521. @itemx no-update
  3522. @cindex @code{target("update")} function attribute, PowerPC
  3523. Generate code that uses (does not use) the load or store instructions
  3524. that update the base register to the address of the calculated memory
  3525. location.
  3526. @item popcntb
  3527. @itemx no-popcntb
  3528. @cindex @code{target("popcntb")} function attribute, PowerPC
  3529. Generate code that uses (does not use) the popcount and double-precision
  3530. FP reciprocal estimate instruction implemented on the POWER5
  3531. processor and other processors that support the PowerPC V2.02
  3532. architecture.
  3533. @item popcntd
  3534. @itemx no-popcntd
  3535. @cindex @code{target("popcntd")} function attribute, PowerPC
  3536. Generate code that uses (does not use) the popcount instruction
  3537. implemented on the POWER7 processor and other processors that support
  3538. the PowerPC V2.06 architecture.
  3539. @item powerpc-gfxopt
  3540. @itemx no-powerpc-gfxopt
  3541. @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
  3542. Generate code that uses (does not use) the optional PowerPC
  3543. architecture instructions in the Graphics group, including
  3544. floating-point select.
  3545. @item powerpc-gpopt
  3546. @itemx no-powerpc-gpopt
  3547. @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
  3548. Generate code that uses (does not use) the optional PowerPC
  3549. architecture instructions in the General Purpose group, including
  3550. floating-point square root.
  3551. @item recip-precision
  3552. @itemx no-recip-precision
  3553. @cindex @code{target("recip-precision")} function attribute, PowerPC
  3554. Assume (do not assume) that the reciprocal estimate instructions
  3555. provide higher-precision estimates than is mandated by the PowerPC
  3556. ABI.
  3557. @item string
  3558. @itemx no-string
  3559. @cindex @code{target("string")} function attribute, PowerPC
  3560. Generate code that uses (does not use) the load string instructions
  3561. and the store string word instructions to save multiple registers and
  3562. do small block moves.
  3563. @item vsx
  3564. @itemx no-vsx
  3565. @cindex @code{target("vsx")} function attribute, PowerPC
  3566. Generate code that uses (does not use) vector/scalar (VSX)
  3567. instructions, and also enable the use of built-in functions that allow
  3568. more direct access to the VSX instruction set. In 32-bit code, you
  3569. cannot enable VSX or AltiVec instructions unless
  3570. @option{-mabi=altivec} is used on the command line.
  3571. @item friz
  3572. @itemx no-friz
  3573. @cindex @code{target("friz")} function attribute, PowerPC
  3574. Generate (do not generate) the @code{friz} instruction when the
  3575. @option{-funsafe-math-optimizations} option is used to optimize
  3576. rounding a floating-point value to 64-bit integer and back to floating
  3577. point. The @code{friz} instruction does not return the same value if
  3578. the floating-point number is too large to fit in an integer.
  3579. @item avoid-indexed-addresses
  3580. @itemx no-avoid-indexed-addresses
  3581. @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
  3582. Generate code that tries to avoid (not avoid) the use of indexed load
  3583. or store instructions.
  3584. @item paired
  3585. @itemx no-paired
  3586. @cindex @code{target("paired")} function attribute, PowerPC
  3587. Generate code that uses (does not use) the generation of PAIRED simd
  3588. instructions.
  3589. @item longcall
  3590. @itemx no-longcall
  3591. @cindex @code{target("longcall")} function attribute, PowerPC
  3592. Generate code that assumes (does not assume) that all calls are far
  3593. away so that a longer more expensive calling sequence is required.
  3594. @item cpu=@var{CPU}
  3595. @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
  3596. Specify the architecture to generate code for when compiling the
  3597. function. If you select the @code{target("cpu=power7")} attribute when
  3598. generating 32-bit code, VSX and AltiVec instructions are not generated
  3599. unless you use the @option{-mabi=altivec} option on the command line.
  3600. @item tune=@var{TUNE}
  3601. @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
  3602. Specify the architecture to tune for when compiling the function. If
  3603. you do not specify the @code{target("tune=@var{TUNE}")} attribute and
  3604. you do specify the @code{target("cpu=@var{CPU}")} attribute,
  3605. compilation tunes for the @var{CPU} architecture, and not the
  3606. default tuning specified on the command line.
  3607. @end table
  3608. When compiling for Nios II, the following options are allowed:
  3609. @table @samp
  3610. @item custom-@var{insn}=@var{N}
  3611. @itemx no-custom-@var{insn}
  3612. @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
  3613. @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
  3614. Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
  3615. custom instruction with encoding @var{N} when generating code that uses
  3616. @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
  3617. the custom instruction @var{insn}.
  3618. These target attributes correspond to the
  3619. @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
  3620. command-line options, and support the same set of @var{insn} keywords.
  3621. @xref{Nios II Options}, for more information.
  3622. @item custom-fpu-cfg=@var{name}
  3623. @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
  3624. This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
  3625. command-line option, to select a predefined set of custom instructions
  3626. named @var{name}.
  3627. @xref{Nios II Options}, for more information.
  3628. @end table
  3629. On the x86 and PowerPC back ends, the inliner does not inline a
  3630. function that has different target options than the caller, unless the
  3631. callee has a subset of the target options of the caller. For example
  3632. a function declared with @code{target("sse3")} can inline a function
  3633. with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
  3634. @item trap_exit
  3635. @cindex @code{trap_exit} function attribute, SH
  3636. Use this attribute on the SH for an @code{interrupt_handler} to return using
  3637. @code{trapa} instead of @code{rte}. This attribute expects an integer
  3638. argument specifying the trap number to be used.
  3639. @item trapa_handler
  3640. @cindex @code{trapa_handler} function attribute, SH
  3641. On SH targets this function attribute is similar to @code{interrupt_handler}
  3642. but it does not save and restore all registers.
  3643. @item unused
  3644. @cindex @code{unused} function attribute
  3645. This attribute, attached to a function, means that the function is meant
  3646. to be possibly unused. GCC does not produce a warning for this
  3647. function.
  3648. @item used
  3649. @cindex @code{used} function attribute
  3650. This attribute, attached to a function, means that code must be emitted
  3651. for the function even if it appears that the function is not referenced.
  3652. This is useful, for example, when the function is referenced only in
  3653. inline assembly.
  3654. When applied to a member function of a C++ class template, the
  3655. attribute also means that the function is instantiated if the
  3656. class itself is instantiated.
  3657. @item vector
  3658. @cindex @code{vector} function attribute, RX
  3659. This RX attribute is similar to the @code{interrupt} attribute, including its
  3660. parameters, but does not make the function an interrupt-handler type
  3661. function (i.e. it retains the normal C function calling ABI). See the
  3662. @code{interrupt} attribute for a description of its arguments.
  3663. @item version_id
  3664. @cindex @code{version_id} function attribute, IA-64
  3665. This IA-64 HP-UX attribute, attached to a global variable or function, renames a
  3666. symbol to contain a version string, thus allowing for function level
  3667. versioning. HP-UX system header files may use function level versioning
  3668. for some system calls.
  3669. @smallexample
  3670. extern int foo () __attribute__((version_id ("20040821")));
  3671. @end smallexample
  3672. @noindent
  3673. Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
  3674. @item visibility ("@var{visibility_type}")
  3675. @cindex @code{visibility} function attribute
  3676. This attribute affects the linkage of the declaration to which it is attached.
  3677. There are four supported @var{visibility_type} values: default,
  3678. hidden, protected or internal visibility.
  3679. @smallexample
  3680. void __attribute__ ((visibility ("protected")))
  3681. f () @{ /* @r{Do something.} */; @}
  3682. int i __attribute__ ((visibility ("hidden")));
  3683. @end smallexample
  3684. The possible values of @var{visibility_type} correspond to the
  3685. visibility settings in the ELF gABI.
  3686. @table @dfn
  3687. @c keep this list of visibilities in alphabetical order.
  3688. @item default
  3689. Default visibility is the normal case for the object file format.
  3690. This value is available for the visibility attribute to override other
  3691. options that may change the assumed visibility of entities.
  3692. On ELF, default visibility means that the declaration is visible to other
  3693. modules and, in shared libraries, means that the declared entity may be
  3694. overridden.
  3695. On Darwin, default visibility means that the declaration is visible to
  3696. other modules.
  3697. Default visibility corresponds to ``external linkage'' in the language.
  3698. @item hidden
  3699. Hidden visibility indicates that the entity declared has a new
  3700. form of linkage, which we call ``hidden linkage''. Two
  3701. declarations of an object with hidden linkage refer to the same object
  3702. if they are in the same shared object.
  3703. @item internal
  3704. Internal visibility is like hidden visibility, but with additional
  3705. processor specific semantics. Unless otherwise specified by the
  3706. psABI, GCC defines internal visibility to mean that a function is
  3707. @emph{never} called from another module. Compare this with hidden
  3708. functions which, while they cannot be referenced directly by other
  3709. modules, can be referenced indirectly via function pointers. By
  3710. indicating that a function cannot be called from outside the module,
  3711. GCC may for instance omit the load of a PIC register since it is known
  3712. that the calling function loaded the correct value.
  3713. @item protected
  3714. Protected visibility is like default visibility except that it
  3715. indicates that references within the defining module bind to the
  3716. definition in that module. That is, the declared entity cannot be
  3717. overridden by another module.
  3718. @end table
  3719. All visibilities are supported on many, but not all, ELF targets
  3720. (supported when the assembler supports the @samp{.visibility}
  3721. pseudo-op). Default visibility is supported everywhere. Hidden
  3722. visibility is supported on Darwin targets.
  3723. The visibility attribute should be applied only to declarations that
  3724. would otherwise have external linkage. The attribute should be applied
  3725. consistently, so that the same entity should not be declared with
  3726. different settings of the attribute.
  3727. In C++, the visibility attribute applies to types as well as functions
  3728. and objects, because in C++ types have linkage. A class must not have
  3729. greater visibility than its non-static data member types and bases,
  3730. and class members default to the visibility of their class. Also, a
  3731. declaration without explicit visibility is limited to the visibility
  3732. of its type.
  3733. In C++, you can mark member functions and static member variables of a
  3734. class with the visibility attribute. This is useful if you know a
  3735. particular method or static member variable should only be used from
  3736. one shared object; then you can mark it hidden while the rest of the
  3737. class has default visibility. Care must be taken to avoid breaking
  3738. the One Definition Rule; for example, it is usually not useful to mark
  3739. an inline method as hidden without marking the whole class as hidden.
  3740. A C++ namespace declaration can also have the visibility attribute.
  3741. @smallexample
  3742. namespace nspace1 __attribute__ ((visibility ("protected")))
  3743. @{ /* @r{Do something.} */; @}
  3744. @end smallexample
  3745. This attribute applies only to the particular namespace body, not to
  3746. other definitions of the same namespace; it is equivalent to using
  3747. @samp{#pragma GCC visibility} before and after the namespace
  3748. definition (@pxref{Visibility Pragmas}).
  3749. In C++, if a template argument has limited visibility, this
  3750. restriction is implicitly propagated to the template instantiation.
  3751. Otherwise, template instantiations and specializations default to the
  3752. visibility of their template.
  3753. If both the template and enclosing class have explicit visibility, the
  3754. visibility from the template is used.
  3755. @item vliw
  3756. @cindex @code{vliw} function attribute, MeP
  3757. On MeP, the @code{vliw} attribute tells the compiler to emit
  3758. instructions in VLIW mode instead of core mode. Note that this
  3759. attribute is not allowed unless a VLIW coprocessor has been configured
  3760. and enabled through command-line options.
  3761. @item warn_unused_result
  3762. @cindex @code{warn_unused_result} function attribute
  3763. The @code{warn_unused_result} attribute causes a warning to be emitted
  3764. if a caller of the function with this attribute does not use its
  3765. return value. This is useful for functions where not checking
  3766. the result is either a security problem or always a bug, such as
  3767. @code{realloc}.
  3768. @smallexample
  3769. int fn () __attribute__ ((warn_unused_result));
  3770. int foo ()
  3771. @{
  3772. if (fn () < 0) return -1;
  3773. fn ();
  3774. return 0;
  3775. @}
  3776. @end smallexample
  3777. @noindent
  3778. results in warning on line 5.
  3779. @item weak
  3780. @cindex @code{weak} function attribute
  3781. The @code{weak} attribute causes the declaration to be emitted as a weak
  3782. symbol rather than a global. This is primarily useful in defining
  3783. library functions that can be overridden in user code, though it can
  3784. also be used with non-function declarations. Weak symbols are supported
  3785. for ELF targets, and also for a.out targets when using the GNU assembler
  3786. and linker.
  3787. @item weakref
  3788. @itemx weakref ("@var{target}")
  3789. @cindex @code{weakref} function attribute
  3790. The @code{weakref} attribute marks a declaration as a weak reference.
  3791. Without arguments, it should be accompanied by an @code{alias} attribute
  3792. naming the target symbol. Optionally, the @var{target} may be given as
  3793. an argument to @code{weakref} itself. In either case, @code{weakref}
  3794. implicitly marks the declaration as @code{weak}. Without a
  3795. @var{target}, given as an argument to @code{weakref} or to @code{alias},
  3796. @code{weakref} is equivalent to @code{weak}.
  3797. @smallexample
  3798. static int x() __attribute__ ((weakref ("y")));
  3799. /* is equivalent to... */
  3800. static int x() __attribute__ ((weak, weakref, alias ("y")));
  3801. /* and to... */
  3802. static int x() __attribute__ ((weakref));
  3803. static int x() __attribute__ ((alias ("y")));
  3804. @end smallexample
  3805. A weak reference is an alias that does not by itself require a
  3806. definition to be given for the target symbol. If the target symbol is
  3807. only referenced through weak references, then it becomes a @code{weak}
  3808. undefined symbol. If it is directly referenced, however, then such
  3809. strong references prevail, and a definition is required for the
  3810. symbol, not necessarily in the same translation unit.
  3811. The effect is equivalent to moving all references to the alias to a
  3812. separate translation unit, renaming the alias to the aliased symbol,
  3813. declaring it as weak, compiling the two separate translation units and
  3814. performing a reloadable link on them.
  3815. At present, a declaration to which @code{weakref} is attached can
  3816. only be @code{static}.
  3817. @end table
  3818. You can specify multiple attributes in a declaration by separating them
  3819. by commas within the double parentheses or by immediately following an
  3820. attribute declaration with another attribute declaration.
  3821. @cindex @code{#pragma}, reason for not using
  3822. @cindex pragma, reason for not using
  3823. Some people object to the @code{__attribute__} feature, suggesting that
  3824. ISO C's @code{#pragma} should be used instead. At the time
  3825. @code{__attribute__} was designed, there were two reasons for not doing
  3826. this.
  3827. @enumerate
  3828. @item
  3829. It is impossible to generate @code{#pragma} commands from a macro.
  3830. @item
  3831. There is no telling what the same @code{#pragma} might mean in another
  3832. compiler.
  3833. @end enumerate
  3834. These two reasons applied to almost any application that might have been
  3835. proposed for @code{#pragma}. It was basically a mistake to use
  3836. @code{#pragma} for @emph{anything}.
  3837. The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
  3838. to be generated from macros. In addition, a @code{#pragma GCC}
  3839. namespace is now in use for GCC-specific pragmas. However, it has been
  3840. found convenient to use @code{__attribute__} to achieve a natural
  3841. attachment of attributes to their corresponding declarations, whereas
  3842. @code{#pragma GCC} is of use for constructs that do not naturally form
  3843. part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
  3844. @node Label Attributes
  3845. @section Label Attributes
  3846. @cindex Label Attributes
  3847. GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
  3848. details of the exact syntax for using attributes. Other attributes are
  3849. available for functions (@pxref{Function Attributes}), variables
  3850. (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
  3851. This example uses the @code{cold} label attribute to indicate the
  3852. @code{ErrorHandling} branch is unlikely to be taken and that the
  3853. @code{ErrorHandling} label is unused:
  3854. @smallexample
  3855. asm goto ("some asm" : : : : NoError);
  3856. /* This branch (the fall-through from the asm) is less commonly used */
  3857. ErrorHandling:
  3858. __attribute__((cold, unused)); /* Semi-colon is required here */
  3859. printf("error\n");
  3860. return 0;
  3861. NoError:
  3862. printf("no error\n");
  3863. return 1;
  3864. @end smallexample
  3865. @table @code
  3866. @item unused
  3867. @cindex @code{unused} label attribute
  3868. This feature is intended for program-generated code that may contain
  3869. unused labels, but which is compiled with @option{-Wall}. It is
  3870. not normally appropriate to use in it human-written code, though it
  3871. could be useful in cases where the code that jumps to the label is
  3872. contained within an @code{#ifdef} conditional.
  3873. @item hot
  3874. @cindex @code{hot} label attribute
  3875. The @code{hot} attribute on a label is used to inform the compiler that
  3876. the path following the label is more likely than paths that are not so
  3877. annotated. This attribute is used in cases where @code{__builtin_expect}
  3878. cannot be used, for instance with computed goto or @code{asm goto}.
  3879. @item cold
  3880. @cindex @code{cold} label attribute
  3881. The @code{cold} attribute on labels is used to inform the compiler that
  3882. the path following the label is unlikely to be executed. This attribute
  3883. is used in cases where @code{__builtin_expect} cannot be used, for instance
  3884. with computed goto or @code{asm goto}.
  3885. @end table
  3886. @node Attribute Syntax
  3887. @section Attribute Syntax
  3888. @cindex attribute syntax
  3889. This section describes the syntax with which @code{__attribute__} may be
  3890. used, and the constructs to which attribute specifiers bind, for the C
  3891. language. Some details may vary for C++ and Objective-C@. Because of
  3892. infelicities in the grammar for attributes, some forms described here
  3893. may not be successfully parsed in all cases.
  3894. There are some problems with the semantics of attributes in C++. For
  3895. example, there are no manglings for attributes, although they may affect
  3896. code generation, so problems may arise when attributed types are used in
  3897. conjunction with templates or overloading. Similarly, @code{typeid}
  3898. does not distinguish between types with different attributes. Support
  3899. for attributes in C++ may be restricted in future to attributes on
  3900. declarations only, but not on nested declarators.
  3901. @xref{Function Attributes}, for details of the semantics of attributes
  3902. applying to functions. @xref{Variable Attributes}, for details of the
  3903. semantics of attributes applying to variables. @xref{Type Attributes},
  3904. for details of the semantics of attributes applying to structure, union
  3905. and enumerated types.
  3906. @xref{Label Attributes}, for details of the semantics of attributes
  3907. applying to labels.
  3908. An @dfn{attribute specifier} is of the form
  3909. @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
  3910. is a possibly empty comma-separated sequence of @dfn{attributes}, where
  3911. each attribute is one of the following:
  3912. @itemize @bullet
  3913. @item
  3914. Empty. Empty attributes are ignored.
  3915. @item
  3916. A word (which may be an identifier such as @code{unused}, or a reserved
  3917. word such as @code{const}).
  3918. @item
  3919. A word, followed by, in parentheses, parameters for the attribute.
  3920. These parameters take one of the following forms:
  3921. @itemize @bullet
  3922. @item
  3923. An identifier. For example, @code{mode} attributes use this form.
  3924. @item
  3925. An identifier followed by a comma and a non-empty comma-separated list
  3926. of expressions. For example, @code{format} attributes use this form.
  3927. @item
  3928. A possibly empty comma-separated list of expressions. For example,
  3929. @code{format_arg} attributes use this form with the list being a single
  3930. integer constant expression, and @code{alias} attributes use this form
  3931. with the list being a single string constant.
  3932. @end itemize
  3933. @end itemize
  3934. An @dfn{attribute specifier list} is a sequence of one or more attribute
  3935. specifiers, not separated by any other tokens.
  3936. @subsubheading Label Attributes
  3937. In GNU C, an attribute specifier list may appear after the colon following a
  3938. label, other than a @code{case} or @code{default} label. GNU C++ only permits
  3939. attributes on labels if the attribute specifier is immediately
  3940. followed by a semicolon (i.e., the label applies to an empty
  3941. statement). If the semicolon is missing, C++ label attributes are
  3942. ambiguous, as it is permissible for a declaration, which could begin
  3943. with an attribute list, to be labelled in C++. Declarations cannot be
  3944. labelled in C90 or C99, so the ambiguity does not arise there.
  3945. @subsubheading Type Attributes
  3946. An attribute specifier list may appear as part of a @code{struct},
  3947. @code{union} or @code{enum} specifier. It may go either immediately
  3948. after the @code{struct}, @code{union} or @code{enum} keyword, or after
  3949. the closing brace. The former syntax is preferred.
  3950. Where attribute specifiers follow the closing brace, they are considered
  3951. to relate to the structure, union or enumerated type defined, not to any
  3952. enclosing declaration the type specifier appears in, and the type
  3953. defined is not complete until after the attribute specifiers.
  3954. @c Otherwise, there would be the following problems: a shift/reduce
  3955. @c conflict between attributes binding the struct/union/enum and
  3956. @c binding to the list of specifiers/qualifiers; and "aligned"
  3957. @c attributes could use sizeof for the structure, but the size could be
  3958. @c changed later by "packed" attributes.
  3959. @subsubheading All other attributes
  3960. Otherwise, an attribute specifier appears as part of a declaration,
  3961. counting declarations of unnamed parameters and type names, and relates
  3962. to that declaration (which may be nested in another declaration, for
  3963. example in the case of a parameter declaration), or to a particular declarator
  3964. within a declaration. Where an
  3965. attribute specifier is applied to a parameter declared as a function or
  3966. an array, it should apply to the function or array rather than the
  3967. pointer to which the parameter is implicitly converted, but this is not
  3968. yet correctly implemented.
  3969. Any list of specifiers and qualifiers at the start of a declaration may
  3970. contain attribute specifiers, whether or not such a list may in that
  3971. context contain storage class specifiers. (Some attributes, however,
  3972. are essentially in the nature of storage class specifiers, and only make
  3973. sense where storage class specifiers may be used; for example,
  3974. @code{section}.) There is one necessary limitation to this syntax: the
  3975. first old-style parameter declaration in a function definition cannot
  3976. begin with an attribute specifier, because such an attribute applies to
  3977. the function instead by syntax described below (which, however, is not
  3978. yet implemented in this case). In some other cases, attribute
  3979. specifiers are permitted by this grammar but not yet supported by the
  3980. compiler. All attribute specifiers in this place relate to the
  3981. declaration as a whole. In the obsolescent usage where a type of
  3982. @code{int} is implied by the absence of type specifiers, such a list of
  3983. specifiers and qualifiers may be an attribute specifier list with no
  3984. other specifiers or qualifiers.
  3985. At present, the first parameter in a function prototype must have some
  3986. type specifier that is not an attribute specifier; this resolves an
  3987. ambiguity in the interpretation of @code{void f(int
  3988. (__attribute__((foo)) x))}, but is subject to change. At present, if
  3989. the parentheses of a function declarator contain only attributes then
  3990. those attributes are ignored, rather than yielding an error or warning
  3991. or implying a single parameter of type int, but this is subject to
  3992. change.
  3993. An attribute specifier list may appear immediately before a declarator
  3994. (other than the first) in a comma-separated list of declarators in a
  3995. declaration of more than one identifier using a single list of
  3996. specifiers and qualifiers. Such attribute specifiers apply
  3997. only to the identifier before whose declarator they appear. For
  3998. example, in
  3999. @smallexample
  4000. __attribute__((noreturn)) void d0 (void),
  4001. __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
  4002. d2 (void);
  4003. @end smallexample
  4004. @noindent
  4005. the @code{noreturn} attribute applies to all the functions
  4006. declared; the @code{format} attribute only applies to @code{d1}.
  4007. An attribute specifier list may appear immediately before the comma,
  4008. @code{=} or semicolon terminating the declaration of an identifier other
  4009. than a function definition. Such attribute specifiers apply
  4010. to the declared object or function. Where an
  4011. assembler name for an object or function is specified (@pxref{Asm
  4012. Labels}), the attribute must follow the @code{asm}
  4013. specification.
  4014. An attribute specifier list may, in future, be permitted to appear after
  4015. the declarator in a function definition (before any old-style parameter
  4016. declarations or the function body).
  4017. Attribute specifiers may be mixed with type qualifiers appearing inside
  4018. the @code{[]} of a parameter array declarator, in the C99 construct by
  4019. which such qualifiers are applied to the pointer to which the array is
  4020. implicitly converted. Such attribute specifiers apply to the pointer,
  4021. not to the array, but at present this is not implemented and they are
  4022. ignored.
  4023. An attribute specifier list may appear at the start of a nested
  4024. declarator. At present, there are some limitations in this usage: the
  4025. attributes correctly apply to the declarator, but for most individual
  4026. attributes the semantics this implies are not implemented.
  4027. When attribute specifiers follow the @code{*} of a pointer
  4028. declarator, they may be mixed with any type qualifiers present.
  4029. The following describes the formal semantics of this syntax. It makes the
  4030. most sense if you are familiar with the formal specification of
  4031. declarators in the ISO C standard.
  4032. Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
  4033. D1}, where @code{T} contains declaration specifiers that specify a type
  4034. @var{Type} (such as @code{int}) and @code{D1} is a declarator that
  4035. contains an identifier @var{ident}. The type specified for @var{ident}
  4036. for derived declarators whose type does not include an attribute
  4037. specifier is as in the ISO C standard.
  4038. If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
  4039. and the declaration @code{T D} specifies the type
  4040. ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
  4041. @code{T D1} specifies the type ``@var{derived-declarator-type-list}
  4042. @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
  4043. If @code{D1} has the form @code{*
  4044. @var{type-qualifier-and-attribute-specifier-list} D}, and the
  4045. declaration @code{T D} specifies the type
  4046. ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
  4047. @code{T D1} specifies the type ``@var{derived-declarator-type-list}
  4048. @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
  4049. @var{ident}.
  4050. For example,
  4051. @smallexample
  4052. void (__attribute__((noreturn)) ****f) (void);
  4053. @end smallexample
  4054. @noindent
  4055. specifies the type ``pointer to pointer to pointer to pointer to
  4056. non-returning function returning @code{void}''. As another example,
  4057. @smallexample
  4058. char *__attribute__((aligned(8))) *f;
  4059. @end smallexample
  4060. @noindent
  4061. specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
  4062. Note again that this does not work with most attributes; for example,
  4063. the usage of @samp{aligned} and @samp{noreturn} attributes given above
  4064. is not yet supported.
  4065. For compatibility with existing code written for compiler versions that
  4066. did not implement attributes on nested declarators, some laxity is
  4067. allowed in the placing of attributes. If an attribute that only applies
  4068. to types is applied to a declaration, it is treated as applying to
  4069. the type of that declaration. If an attribute that only applies to
  4070. declarations is applied to the type of a declaration, it is treated
  4071. as applying to that declaration; and, for compatibility with code
  4072. placing the attributes immediately before the identifier declared, such
  4073. an attribute applied to a function return type is treated as
  4074. applying to the function type, and such an attribute applied to an array
  4075. element type is treated as applying to the array type. If an
  4076. attribute that only applies to function types is applied to a
  4077. pointer-to-function type, it is treated as applying to the pointer
  4078. target type; if such an attribute is applied to a function return type
  4079. that is not a pointer-to-function type, it is treated as applying
  4080. to the function type.
  4081. @node Function Prototypes
  4082. @section Prototypes and Old-Style Function Definitions
  4083. @cindex function prototype declarations
  4084. @cindex old-style function definitions
  4085. @cindex promotion of formal parameters
  4086. GNU C extends ISO C to allow a function prototype to override a later
  4087. old-style non-prototype definition. Consider the following example:
  4088. @smallexample
  4089. /* @r{Use prototypes unless the compiler is old-fashioned.} */
  4090. #ifdef __STDC__
  4091. #define P(x) x
  4092. #else
  4093. #define P(x) ()
  4094. #endif
  4095. /* @r{Prototype function declaration.} */
  4096. int isroot P((uid_t));
  4097. /* @r{Old-style function definition.} */
  4098. int
  4099. isroot (x) /* @r{??? lossage here ???} */
  4100. uid_t x;
  4101. @{
  4102. return x == 0;
  4103. @}
  4104. @end smallexample
  4105. Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
  4106. not allow this example, because subword arguments in old-style
  4107. non-prototype definitions are promoted. Therefore in this example the
  4108. function definition's argument is really an @code{int}, which does not
  4109. match the prototype argument type of @code{short}.
  4110. This restriction of ISO C makes it hard to write code that is portable
  4111. to traditional C compilers, because the programmer does not know
  4112. whether the @code{uid_t} type is @code{short}, @code{int}, or
  4113. @code{long}. Therefore, in cases like these GNU C allows a prototype
  4114. to override a later old-style definition. More precisely, in GNU C, a
  4115. function prototype argument type overrides the argument type specified
  4116. by a later old-style definition if the former type is the same as the
  4117. latter type before promotion. Thus in GNU C the above example is
  4118. equivalent to the following:
  4119. @smallexample
  4120. int isroot (uid_t);
  4121. int
  4122. isroot (uid_t x)
  4123. @{
  4124. return x == 0;
  4125. @}
  4126. @end smallexample
  4127. @noindent
  4128. GNU C++ does not support old-style function definitions, so this
  4129. extension is irrelevant.
  4130. @node C++ Comments
  4131. @section C++ Style Comments
  4132. @cindex @code{//}
  4133. @cindex C++ comments
  4134. @cindex comments, C++ style
  4135. In GNU C, you may use C++ style comments, which start with @samp{//} and
  4136. continue until the end of the line. Many other C implementations allow
  4137. such comments, and they are included in the 1999 C standard. However,
  4138. C++ style comments are not recognized if you specify an @option{-std}
  4139. option specifying a version of ISO C before C99, or @option{-ansi}
  4140. (equivalent to @option{-std=c90}).
  4141. @node Dollar Signs
  4142. @section Dollar Signs in Identifier Names
  4143. @cindex $
  4144. @cindex dollar signs in identifier names
  4145. @cindex identifier names, dollar signs in
  4146. In GNU C, you may normally use dollar signs in identifier names.
  4147. This is because many traditional C implementations allow such identifiers.
  4148. However, dollar signs in identifiers are not supported on a few target
  4149. machines, typically because the target assembler does not allow them.
  4150. @node Character Escapes
  4151. @section The Character @key{ESC} in Constants
  4152. You can use the sequence @samp{\e} in a string or character constant to
  4153. stand for the ASCII character @key{ESC}.
  4154. @node Variable Attributes
  4155. @section Specifying Attributes of Variables
  4156. @cindex attribute of variables
  4157. @cindex variable attributes
  4158. The keyword @code{__attribute__} allows you to specify special
  4159. attributes of variables or structure fields. This keyword is followed
  4160. by an attribute specification inside double parentheses. Some
  4161. attributes are currently defined generically for variables.
  4162. Other attributes are defined for variables on particular target
  4163. systems. Other attributes are available for functions
  4164. (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for
  4165. types (@pxref{Type Attributes}).
  4166. Other front ends might define more attributes
  4167. (@pxref{C++ Extensions,,Extensions to the C++ Language}).
  4168. You may also specify attributes with @samp{__} preceding and following
  4169. each keyword. This allows you to use them in header files without
  4170. being concerned about a possible macro of the same name. For example,
  4171. you may use @code{__aligned__} instead of @code{aligned}.
  4172. @xref{Attribute Syntax}, for details of the exact syntax for using
  4173. attributes.
  4174. @table @code
  4175. @cindex @code{aligned} variable attribute
  4176. @item aligned (@var{alignment})
  4177. This attribute specifies a minimum alignment for the variable or
  4178. structure field, measured in bytes. For example, the declaration:
  4179. @smallexample
  4180. int x __attribute__ ((aligned (16))) = 0;
  4181. @end smallexample
  4182. @noindent
  4183. causes the compiler to allocate the global variable @code{x} on a
  4184. 16-byte boundary. On a 68040, this could be used in conjunction with
  4185. an @code{asm} expression to access the @code{move16} instruction which
  4186. requires 16-byte aligned operands.
  4187. You can also specify the alignment of structure fields. For example, to
  4188. create a double-word aligned @code{int} pair, you could write:
  4189. @smallexample
  4190. struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
  4191. @end smallexample
  4192. @noindent
  4193. This is an alternative to creating a union with a @code{double} member,
  4194. which forces the union to be double-word aligned.
  4195. As in the preceding examples, you can explicitly specify the alignment
  4196. (in bytes) that you wish the compiler to use for a given variable or
  4197. structure field. Alternatively, you can leave out the alignment factor
  4198. and just ask the compiler to align a variable or field to the
  4199. default alignment for the target architecture you are compiling for.
  4200. The default alignment is sufficient for all scalar types, but may not be
  4201. enough for all vector types on a target that supports vector operations.
  4202. The default alignment is fixed for a particular target ABI.
  4203. GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
  4204. which is the largest alignment ever used for any data type on the
  4205. target machine you are compiling for. For example, you could write:
  4206. @smallexample
  4207. short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
  4208. @end smallexample
  4209. The compiler automatically sets the alignment for the declared
  4210. variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
  4211. often make copy operations more efficient, because the compiler can
  4212. use whatever instructions copy the biggest chunks of memory when
  4213. performing copies to or from the variables or fields that you have
  4214. aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
  4215. may change depending on command-line options.
  4216. When used on a struct, or struct member, the @code{aligned} attribute can
  4217. only increase the alignment; in order to decrease it, the @code{packed}
  4218. attribute must be specified as well. When used as part of a typedef, the
  4219. @code{aligned} attribute can both increase and decrease alignment, and
  4220. specifying the @code{packed} attribute generates a warning.
  4221. Note that the effectiveness of @code{aligned} attributes may be limited
  4222. by inherent limitations in your linker. On many systems, the linker is
  4223. only able to arrange for variables to be aligned up to a certain maximum
  4224. alignment. (For some linkers, the maximum supported alignment may
  4225. be very very small.) If your linker is only able to align variables
  4226. up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
  4227. in an @code{__attribute__} still only provides you with 8-byte
  4228. alignment. See your linker documentation for further information.
  4229. The @code{aligned} attribute can also be used for functions
  4230. (@pxref{Function Attributes}.)
  4231. @item cleanup (@var{cleanup_function})
  4232. @cindex @code{cleanup} variable attribute
  4233. The @code{cleanup} attribute runs a function when the variable goes
  4234. out of scope. This attribute can only be applied to auto function
  4235. scope variables; it may not be applied to parameters or variables
  4236. with static storage duration. The function must take one parameter,
  4237. a pointer to a type compatible with the variable. The return value
  4238. of the function (if any) is ignored.
  4239. If @option{-fexceptions} is enabled, then @var{cleanup_function}
  4240. is run during the stack unwinding that happens during the
  4241. processing of the exception. Note that the @code{cleanup} attribute
  4242. does not allow the exception to be caught, only to perform an action.
  4243. It is undefined what happens if @var{cleanup_function} does not
  4244. return normally.
  4245. @item common
  4246. @itemx nocommon
  4247. @cindex @code{common} variable attribute
  4248. @cindex @code{nocommon} variable attribute
  4249. @opindex fcommon
  4250. @opindex fno-common
  4251. The @code{common} attribute requests GCC to place a variable in
  4252. ``common'' storage. The @code{nocommon} attribute requests the
  4253. opposite---to allocate space for it directly.
  4254. These attributes override the default chosen by the
  4255. @option{-fno-common} and @option{-fcommon} flags respectively.
  4256. @item deprecated
  4257. @itemx deprecated (@var{msg})
  4258. @cindex @code{deprecated} variable attribute
  4259. The @code{deprecated} attribute results in a warning if the variable
  4260. is used anywhere in the source file. This is useful when identifying
  4261. variables that are expected to be removed in a future version of a
  4262. program. The warning also includes the location of the declaration
  4263. of the deprecated variable, to enable users to easily find further
  4264. information about why the variable is deprecated, or what they should
  4265. do instead. Note that the warning only occurs for uses:
  4266. @smallexample
  4267. extern int old_var __attribute__ ((deprecated));
  4268. extern int old_var;
  4269. int new_fn () @{ return old_var; @}
  4270. @end smallexample
  4271. @noindent
  4272. results in a warning on line 3 but not line 2. The optional @var{msg}
  4273. argument, which must be a string, is printed in the warning if
  4274. present.
  4275. The @code{deprecated} attribute can also be used for functions and
  4276. types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
  4277. @item mode (@var{mode})
  4278. @cindex @code{mode} variable attribute
  4279. This attribute specifies the data type for the declaration---whichever
  4280. type corresponds to the mode @var{mode}. This in effect lets you
  4281. request an integer or floating-point type according to its width.
  4282. You may also specify a mode of @code{byte} or @code{__byte__} to
  4283. indicate the mode corresponding to a one-byte integer, @code{word} or
  4284. @code{__word__} for the mode of a one-word integer, and @code{pointer}
  4285. or @code{__pointer__} for the mode used to represent pointers.
  4286. @item packed
  4287. @cindex @code{packed} variable attribute
  4288. The @code{packed} attribute specifies that a variable or structure field
  4289. should have the smallest possible alignment---one byte for a variable,
  4290. and one bit for a field, unless you specify a larger value with the
  4291. @code{aligned} attribute.
  4292. Here is a structure in which the field @code{x} is packed, so that it
  4293. immediately follows @code{a}:
  4294. @smallexample
  4295. struct foo
  4296. @{
  4297. char a;
  4298. int x[2] __attribute__ ((packed));
  4299. @};
  4300. @end smallexample
  4301. @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
  4302. @code{packed} attribute on bit-fields of type @code{char}. This has
  4303. been fixed in GCC 4.4 but the change can lead to differences in the
  4304. structure layout. See the documentation of
  4305. @option{-Wpacked-bitfield-compat} for more information.
  4306. @item section ("@var{section-name}")
  4307. @cindex @code{section} variable attribute
  4308. Normally, the compiler places the objects it generates in sections like
  4309. @code{data} and @code{bss}. Sometimes, however, you need additional sections,
  4310. or you need certain particular variables to appear in special sections,
  4311. for example to map to special hardware. The @code{section}
  4312. attribute specifies that a variable (or function) lives in a particular
  4313. section. For example, this small program uses several specific section names:
  4314. @smallexample
  4315. struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
  4316. struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
  4317. char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
  4318. int init_data __attribute__ ((section ("INITDATA")));
  4319. main()
  4320. @{
  4321. /* @r{Initialize stack pointer} */
  4322. init_sp (stack + sizeof (stack));
  4323. /* @r{Initialize initialized data} */
  4324. memcpy (&init_data, &data, &edata - &data);
  4325. /* @r{Turn on the serial ports} */
  4326. init_duart (&a);
  4327. init_duart (&b);
  4328. @}
  4329. @end smallexample
  4330. @noindent
  4331. Use the @code{section} attribute with
  4332. @emph{global} variables and not @emph{local} variables,
  4333. as shown in the example.
  4334. You may use the @code{section} attribute with initialized or
  4335. uninitialized global variables but the linker requires
  4336. each object be defined once, with the exception that uninitialized
  4337. variables tentatively go in the @code{common} (or @code{bss}) section
  4338. and can be multiply ``defined''. Using the @code{section} attribute
  4339. changes what section the variable goes into and may cause the
  4340. linker to issue an error if an uninitialized variable has multiple
  4341. definitions. You can force a variable to be initialized with the
  4342. @option{-fno-common} flag or the @code{nocommon} attribute.
  4343. Some file formats do not support arbitrary sections so the @code{section}
  4344. attribute is not available on all platforms.
  4345. If you need to map the entire contents of a module to a particular
  4346. section, consider using the facilities of the linker instead.
  4347. @item shared
  4348. @cindex @code{shared} variable attribute
  4349. On Microsoft Windows, in addition to putting variable definitions in a named
  4350. section, the section can also be shared among all running copies of an
  4351. executable or DLL@. For example, this small program defines shared data
  4352. by putting it in a named section @code{shared} and marking the section
  4353. shareable:
  4354. @smallexample
  4355. int foo __attribute__((section ("shared"), shared)) = 0;
  4356. int
  4357. main()
  4358. @{
  4359. /* @r{Read and write foo. All running
  4360. copies see the same value.} */
  4361. return 0;
  4362. @}
  4363. @end smallexample
  4364. @noindent
  4365. You may only use the @code{shared} attribute along with @code{section}
  4366. attribute with a fully-initialized global definition because of the way
  4367. linkers work. See @code{section} attribute for more information.
  4368. The @code{shared} attribute is only available on Microsoft Windows@.
  4369. @item tls_model ("@var{tls_model}")
  4370. @cindex @code{tls_model} variable attribute
  4371. The @code{tls_model} attribute sets thread-local storage model
  4372. (@pxref{Thread-Local}) of a particular @code{__thread} variable,
  4373. overriding @option{-ftls-model=} command-line switch on a per-variable
  4374. basis.
  4375. The @var{tls_model} argument should be one of @code{global-dynamic},
  4376. @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
  4377. Not all targets support this attribute.
  4378. @item unused
  4379. @cindex @code{unused} variable attribute
  4380. This attribute, attached to a variable, means that the variable is meant
  4381. to be possibly unused. GCC does not produce a warning for this
  4382. variable.
  4383. @item used
  4384. @cindex @code{used} variable attribute
  4385. This attribute, attached to a variable with static storage, means that
  4386. the variable must be emitted even if it appears that the variable is not
  4387. referenced.
  4388. When applied to a static data member of a C++ class template, the
  4389. attribute also means that the member is instantiated if the
  4390. class itself is instantiated.
  4391. @item vector_size (@var{bytes})
  4392. @cindex @code{vector_size} variable attribute
  4393. This attribute specifies the vector size for the variable, measured in
  4394. bytes. For example, the declaration:
  4395. @smallexample
  4396. int foo __attribute__ ((vector_size (16)));
  4397. @end smallexample
  4398. @noindent
  4399. causes the compiler to set the mode for @code{foo}, to be 16 bytes,
  4400. divided into @code{int} sized units. Assuming a 32-bit int (a vector of
  4401. 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
  4402. This attribute is only applicable to integral and float scalars,
  4403. although arrays, pointers, and function return values are allowed in
  4404. conjunction with this construct.
  4405. Aggregates with this attribute are invalid, even if they are of the same
  4406. size as a corresponding scalar. For example, the declaration:
  4407. @smallexample
  4408. struct S @{ int a; @};
  4409. struct S __attribute__ ((vector_size (16))) foo;
  4410. @end smallexample
  4411. @noindent
  4412. is invalid even if the size of the structure is the same as the size of
  4413. the @code{int}.
  4414. @item selectany
  4415. @cindex @code{selectany} variable attribute
  4416. The @code{selectany} attribute causes an initialized global variable to
  4417. have link-once semantics. When multiple definitions of the variable are
  4418. encountered by the linker, the first is selected and the remainder are
  4419. discarded. Following usage by the Microsoft compiler, the linker is told
  4420. @emph{not} to warn about size or content differences of the multiple
  4421. definitions.
  4422. Although the primary usage of this attribute is for POD types, the
  4423. attribute can also be applied to global C++ objects that are initialized
  4424. by a constructor. In this case, the static initialization and destruction
  4425. code for the object is emitted in each translation defining the object,
  4426. but the calls to the constructor and destructor are protected by a
  4427. link-once guard variable.
  4428. The @code{selectany} attribute is only available on Microsoft Windows
  4429. targets. You can use @code{__declspec (selectany)} as a synonym for
  4430. @code{__attribute__ ((selectany))} for compatibility with other
  4431. compilers.
  4432. @item weak
  4433. @cindex @code{weak} variable attribute
  4434. The @code{weak} attribute is described in @ref{Function Attributes}.
  4435. @item dllimport
  4436. @cindex @code{dllimport} variable attribute
  4437. The @code{dllimport} attribute is described in @ref{Function Attributes}.
  4438. @item dllexport
  4439. @cindex @code{dllexport} variable attribute
  4440. The @code{dllexport} attribute is described in @ref{Function Attributes}.
  4441. @end table
  4442. @anchor{AVR Variable Attributes}
  4443. @subsection AVR Variable Attributes
  4444. @table @code
  4445. @item progmem
  4446. @cindex @code{progmem} variable attribute, AVR
  4447. The @code{progmem} attribute is used on the AVR to place read-only
  4448. data in the non-volatile program memory (flash). The @code{progmem}
  4449. attribute accomplishes this by putting respective variables into a
  4450. section whose name starts with @code{.progmem}.
  4451. This attribute works similar to the @code{section} attribute
  4452. but adds additional checking. Notice that just like the
  4453. @code{section} attribute, @code{progmem} affects the location
  4454. of the data but not how this data is accessed.
  4455. In order to read data located with the @code{progmem} attribute
  4456. (inline) assembler must be used.
  4457. @smallexample
  4458. /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
  4459. #include <avr/pgmspace.h>
  4460. /* Locate var in flash memory */
  4461. const int var[2] PROGMEM = @{ 1, 2 @};
  4462. int read_var (int i)
  4463. @{
  4464. /* Access var[] by accessor macro from avr/pgmspace.h */
  4465. return (int) pgm_read_word (& var[i]);
  4466. @}
  4467. @end smallexample
  4468. AVR is a Harvard architecture processor and data and read-only data
  4469. normally resides in the data memory (RAM).
  4470. See also the @ref{AVR Named Address Spaces} section for
  4471. an alternate way to locate and access data in flash memory.
  4472. @item io
  4473. @itemx io (@var{addr})
  4474. @cindex @code{io} variable attribute, AVR
  4475. Variables with the @code{io} attribute are used to address
  4476. memory-mapped peripherals in the io address range.
  4477. If an address is specified, the variable
  4478. is assigned that address, and the value is interpreted as an
  4479. address in the data address space.
  4480. Example:
  4481. @smallexample
  4482. volatile int porta __attribute__((io (0x22)));
  4483. @end smallexample
  4484. The address specified in the address in the data address range.
  4485. Otherwise, the variable it is not assigned an address, but the
  4486. compiler will still use in/out instructions where applicable,
  4487. assuming some other module assigns an address in the io address range.
  4488. Example:
  4489. @smallexample
  4490. extern volatile int porta __attribute__((io));
  4491. @end smallexample
  4492. @item io_low
  4493. @itemx io_low (@var{addr})
  4494. @cindex @code{io_low} variable attribute, AVR
  4495. This is like the @code{io} attribute, but additionally it informs the
  4496. compiler that the object lies in the lower half of the I/O area,
  4497. allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
  4498. instructions.
  4499. @item address
  4500. @itemx address (@var{addr})
  4501. @cindex @code{address} variable attribute, AVR
  4502. Variables with the @code{address} attribute are used to address
  4503. memory-mapped peripherals that may lie outside the io address range.
  4504. @smallexample
  4505. volatile int porta __attribute__((address (0x600)));
  4506. @end smallexample
  4507. @end table
  4508. @subsection Blackfin Variable Attributes
  4509. Three attributes are currently defined for the Blackfin.
  4510. @table @code
  4511. @item l1_data
  4512. @itemx l1_data_A
  4513. @itemx l1_data_B
  4514. @cindex @code{l1_data} variable attribute, Blackfin
  4515. @cindex @code{l1_data_A} variable attribute, Blackfin
  4516. @cindex @code{l1_data_B} variable attribute, Blackfin
  4517. Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
  4518. Variables with @code{l1_data} attribute are put into the specific section
  4519. named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
  4520. the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
  4521. attribute are put into the specific section named @code{.l1.data.B}.
  4522. @item l2
  4523. @cindex @code{l2} variable attribute, Blackfin
  4524. Use this attribute on the Blackfin to place the variable into L2 SRAM.
  4525. Variables with @code{l2} attribute are put into the specific section
  4526. named @code{.l2.data}.
  4527. @end table
  4528. @subsection H8/300 Variable Attributes
  4529. These variable attributes are available for H8/300 targets:
  4530. @table @code
  4531. @item eightbit_data
  4532. @cindex @code{eightbit_data} variable attribute, H8/300
  4533. @cindex eight-bit data on the H8/300, H8/300H, and H8S
  4534. Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
  4535. variable should be placed into the eight-bit data section.
  4536. The compiler generates more efficient code for certain operations
  4537. on data in the eight-bit data area. Note the eight-bit data area is limited to
  4538. 256 bytes of data.
  4539. You must use GAS and GLD from GNU binutils version 2.7 or later for
  4540. this attribute to work correctly.
  4541. @item tiny_data
  4542. @cindex @code{tiny_data} variable attribute, H8/300
  4543. @cindex tiny data section on the H8/300H and H8S
  4544. Use this attribute on the H8/300H and H8S to indicate that the specified
  4545. variable should be placed into the tiny data section.
  4546. The compiler generates more efficient code for loads and stores
  4547. on data in the tiny data section. Note the tiny data area is limited to
  4548. slightly under 32KB of data.
  4549. @end table
  4550. @subsection IA-64 Variable Attributes
  4551. The IA-64 back end supports the following variable attribute:
  4552. @table @code
  4553. @item model (@var{model-name})
  4554. @cindex @code{model} variable attribute, IA-64
  4555. On IA-64, use this attribute to set the addressability of an object.
  4556. At present, the only supported identifier for @var{model-name} is
  4557. @code{small}, indicating addressability via ``small'' (22-bit)
  4558. addresses (so that their addresses can be loaded with the @code{addl}
  4559. instruction). Caveat: such addressing is by definition not position
  4560. independent and hence this attribute must not be used for objects
  4561. defined by shared libraries.
  4562. @end table
  4563. @subsection M32R/D Variable Attributes
  4564. One attribute is currently defined for the M32R/D@.
  4565. @table @code
  4566. @item model (@var{model-name})
  4567. @cindex @code{model-name} variable attribute, M32R/D
  4568. @cindex variable addressability on the M32R/D
  4569. Use this attribute on the M32R/D to set the addressability of an object.
  4570. The identifier @var{model-name} is one of @code{small}, @code{medium},
  4571. or @code{large}, representing each of the code models.
  4572. Small model objects live in the lower 16MB of memory (so that their
  4573. addresses can be loaded with the @code{ld24} instruction).
  4574. Medium and large model objects may live anywhere in the 32-bit address space
  4575. (the compiler generates @code{seth/add3} instructions to load their
  4576. addresses).
  4577. @end table
  4578. @anchor{MeP Variable Attributes}
  4579. @subsection MeP Variable Attributes
  4580. The MeP target has a number of addressing modes and busses. The
  4581. @code{near} space spans the standard memory space's first 16 megabytes
  4582. (24 bits). The @code{far} space spans the entire 32-bit memory space.
  4583. The @code{based} space is a 128-byte region in the memory space that
  4584. is addressed relative to the @code{$tp} register. The @code{tiny}
  4585. space is a 65536-byte region relative to the @code{$gp} register. In
  4586. addition to these memory regions, the MeP target has a separate 16-bit
  4587. control bus which is specified with @code{cb} attributes.
  4588. @table @code
  4589. @item based
  4590. @cindex @code{based} variable attribute, MeP
  4591. Any variable with the @code{based} attribute is assigned to the
  4592. @code{.based} section, and is accessed with relative to the
  4593. @code{$tp} register.
  4594. @item tiny
  4595. @cindex @code{tiny} variable attribute, MeP
  4596. Likewise, the @code{tiny} attribute assigned variables to the
  4597. @code{.tiny} section, relative to the @code{$gp} register.
  4598. @item near
  4599. @cindex @code{near} variable attribute, MeP
  4600. Variables with the @code{near} attribute are assumed to have addresses
  4601. that fit in a 24-bit addressing mode. This is the default for large
  4602. variables (@code{-mtiny=4} is the default) but this attribute can
  4603. override @code{-mtiny=} for small variables, or override @code{-ml}.
  4604. @item far
  4605. @cindex @code{far} variable attribute, MeP
  4606. Variables with the @code{far} attribute are addressed using a full
  4607. 32-bit address. Since this covers the entire memory space, this
  4608. allows modules to make no assumptions about where variables might be
  4609. stored.
  4610. @item io
  4611. @cindex @code{io} variable attribute, MeP
  4612. @itemx io (@var{addr})
  4613. Variables with the @code{io} attribute are used to address
  4614. memory-mapped peripherals. If an address is specified, the variable
  4615. is assigned that address, else it is not assigned an address (it is
  4616. assumed some other module assigns an address). Example:
  4617. @smallexample
  4618. int timer_count __attribute__((io(0x123)));
  4619. @end smallexample
  4620. @item cb
  4621. @itemx cb (@var{addr})
  4622. @cindex @code{cb} variable attribute, MeP
  4623. Variables with the @code{cb} attribute are used to access the control
  4624. bus, using special instructions. @code{addr} indicates the control bus
  4625. address. Example:
  4626. @smallexample
  4627. int cpu_clock __attribute__((cb(0x123)));
  4628. @end smallexample
  4629. @end table
  4630. @subsection PowerPC Variable Attributes
  4631. Three attributes currently are defined for PowerPC configurations:
  4632. @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
  4633. @cindex @code{ms_struct} variable attribute, PowerPC
  4634. @cindex @code{gcc_struct} variable attribute, PowerPC
  4635. For full documentation of the struct attributes please see the
  4636. documentation in @ref{x86 Variable Attributes}.
  4637. @cindex @code{altivec} variable attribute, PowerPC
  4638. For documentation of @code{altivec} attribute please see the
  4639. documentation in @ref{PowerPC Type Attributes}.
  4640. @subsection SPU Variable Attributes
  4641. @cindex @code{spu_vector} variable attribute, SPU
  4642. The SPU supports the @code{spu_vector} attribute for variables. For
  4643. documentation of this attribute please see the documentation in
  4644. @ref{SPU Type Attributes}.
  4645. @anchor{x86 Variable Attributes}
  4646. @subsection x86 Variable Attributes
  4647. Two attributes are currently defined for x86 configurations:
  4648. @code{ms_struct} and @code{gcc_struct}.
  4649. @table @code
  4650. @item ms_struct
  4651. @itemx gcc_struct
  4652. @cindex @code{ms_struct} variable attribute, x86
  4653. @cindex @code{gcc_struct} variable attribute, x86
  4654. If @code{packed} is used on a structure, or if bit-fields are used,
  4655. it may be that the Microsoft ABI lays out the structure differently
  4656. than the way GCC normally does. Particularly when moving packed
  4657. data between functions compiled with GCC and the native Microsoft compiler
  4658. (either via function call or as data in a file), it may be necessary to access
  4659. either format.
  4660. Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
  4661. compilers to match the native Microsoft compiler.
  4662. The Microsoft structure layout algorithm is fairly simple with the exception
  4663. of the bit-field packing.
  4664. The padding and alignment of members of structures and whether a bit-field
  4665. can straddle a storage-unit boundary are determine by these rules:
  4666. @enumerate
  4667. @item Structure members are stored sequentially in the order in which they are
  4668. declared: the first member has the lowest memory address and the last member
  4669. the highest.
  4670. @item Every data object has an alignment requirement. The alignment requirement
  4671. for all data except structures, unions, and arrays is either the size of the
  4672. object or the current packing size (specified with either the
  4673. @code{aligned} attribute or the @code{pack} pragma),
  4674. whichever is less. For structures, unions, and arrays,
  4675. the alignment requirement is the largest alignment requirement of its members.
  4676. Every object is allocated an offset so that:
  4677. @smallexample
  4678. offset % alignment_requirement == 0
  4679. @end smallexample
  4680. @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
  4681. unit if the integral types are the same size and if the next bit-field fits
  4682. into the current allocation unit without crossing the boundary imposed by the
  4683. common alignment requirements of the bit-fields.
  4684. @end enumerate
  4685. MSVC interprets zero-length bit-fields in the following ways:
  4686. @enumerate
  4687. @item If a zero-length bit-field is inserted between two bit-fields that
  4688. are normally coalesced, the bit-fields are not coalesced.
  4689. For example:
  4690. @smallexample
  4691. struct
  4692. @{
  4693. unsigned long bf_1 : 12;
  4694. unsigned long : 0;
  4695. unsigned long bf_2 : 12;
  4696. @} t1;
  4697. @end smallexample
  4698. @noindent
  4699. The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
  4700. zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
  4701. @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
  4702. alignment of the zero-length bit-field is greater than the member that follows it,
  4703. @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
  4704. For example:
  4705. @smallexample
  4706. struct
  4707. @{
  4708. char foo : 4;
  4709. short : 0;
  4710. char bar;
  4711. @} t2;
  4712. struct
  4713. @{
  4714. char foo : 4;
  4715. short : 0;
  4716. double bar;
  4717. @} t3;
  4718. @end smallexample
  4719. @noindent
  4720. For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
  4721. Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
  4722. bit-field does not affect the alignment of @code{bar} or, as a result, the size
  4723. of the structure.
  4724. Taking this into account, it is important to note the following:
  4725. @enumerate
  4726. @item If a zero-length bit-field follows a normal bit-field, the type of the
  4727. zero-length bit-field may affect the alignment of the structure as whole. For
  4728. example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
  4729. normal bit-field, and is of type short.
  4730. @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
  4731. still affect the alignment of the structure:
  4732. @smallexample
  4733. struct
  4734. @{
  4735. char foo : 6;
  4736. long : 0;
  4737. @} t4;
  4738. @end smallexample
  4739. @noindent
  4740. Here, @code{t4} takes up 4 bytes.
  4741. @end enumerate
  4742. @item Zero-length bit-fields following non-bit-field members are ignored:
  4743. @smallexample
  4744. struct
  4745. @{
  4746. char foo;
  4747. long : 0;
  4748. char bar;
  4749. @} t5;
  4750. @end smallexample
  4751. @noindent
  4752. Here, @code{t5} takes up 2 bytes.
  4753. @end enumerate
  4754. @end table
  4755. @subsection Xstormy16 Variable Attributes
  4756. One attribute is currently defined for xstormy16 configurations:
  4757. @code{below100}.
  4758. @table @code
  4759. @item below100
  4760. @cindex @code{below100} variable attribute, Xstormy16
  4761. If a variable has the @code{below100} attribute (@code{BELOW100} is
  4762. allowed also), GCC places the variable in the first 0x100 bytes of
  4763. memory and use special opcodes to access it. Such variables are
  4764. placed in either the @code{.bss_below100} section or the
  4765. @code{.data_below100} section.
  4766. @end table
  4767. @node Type Attributes
  4768. @section Specifying Attributes of Types
  4769. @cindex attribute of types
  4770. @cindex type attributes
  4771. The keyword @code{__attribute__} allows you to specify special
  4772. attributes of @code{struct} and @code{union} types when you define
  4773. such types. This keyword is followed by an attribute specification
  4774. inside double parentheses. Eight attributes are currently defined for
  4775. types: @code{aligned}, @code{packed}, @code{transparent_union},
  4776. @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
  4777. and @code{bnd_variable_size}. Other attributes are defined for
  4778. functions (@pxref{Function Attributes}), labels (@pxref{Label
  4779. Attributes}) and for variables (@pxref{Variable Attributes}).
  4780. You may also specify any one of these attributes with @samp{__}
  4781. preceding and following its keyword. This allows you to use these
  4782. attributes in header files without being concerned about a possible
  4783. macro of the same name. For example, you may use @code{__aligned__}
  4784. instead of @code{aligned}.
  4785. You may specify type attributes in an enum, struct or union type
  4786. declaration or definition, or for other types in a @code{typedef}
  4787. declaration.
  4788. For an enum, struct or union type, you may specify attributes either
  4789. between the enum, struct or union tag and the name of the type, or
  4790. just past the closing curly brace of the @emph{definition}. The
  4791. former syntax is preferred.
  4792. @xref{Attribute Syntax}, for details of the exact syntax for using
  4793. attributes.
  4794. @table @code
  4795. @cindex @code{aligned} type attribute
  4796. @item aligned (@var{alignment})
  4797. This attribute specifies a minimum alignment (in bytes) for variables
  4798. of the specified type. For example, the declarations:
  4799. @smallexample
  4800. struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
  4801. typedef int more_aligned_int __attribute__ ((aligned (8)));
  4802. @end smallexample
  4803. @noindent
  4804. force the compiler to ensure (as far as it can) that each variable whose
  4805. type is @code{struct S} or @code{more_aligned_int} is allocated and
  4806. aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
  4807. variables of type @code{struct S} aligned to 8-byte boundaries allows
  4808. the compiler to use the @code{ldd} and @code{std} (doubleword load and
  4809. store) instructions when copying one variable of type @code{struct S} to
  4810. another, thus improving run-time efficiency.
  4811. Note that the alignment of any given @code{struct} or @code{union} type
  4812. is required by the ISO C standard to be at least a perfect multiple of
  4813. the lowest common multiple of the alignments of all of the members of
  4814. the @code{struct} or @code{union} in question. This means that you @emph{can}
  4815. effectively adjust the alignment of a @code{struct} or @code{union}
  4816. type by attaching an @code{aligned} attribute to any one of the members
  4817. of such a type, but the notation illustrated in the example above is a
  4818. more obvious, intuitive, and readable way to request the compiler to
  4819. adjust the alignment of an entire @code{struct} or @code{union} type.
  4820. As in the preceding example, you can explicitly specify the alignment
  4821. (in bytes) that you wish the compiler to use for a given @code{struct}
  4822. or @code{union} type. Alternatively, you can leave out the alignment factor
  4823. and just ask the compiler to align a type to the maximum
  4824. useful alignment for the target machine you are compiling for. For
  4825. example, you could write:
  4826. @smallexample
  4827. struct S @{ short f[3]; @} __attribute__ ((aligned));
  4828. @end smallexample
  4829. Whenever you leave out the alignment factor in an @code{aligned}
  4830. attribute specification, the compiler automatically sets the alignment
  4831. for the type to the largest alignment that is ever used for any data
  4832. type on the target machine you are compiling for. Doing this can often
  4833. make copy operations more efficient, because the compiler can use
  4834. whatever instructions copy the biggest chunks of memory when performing
  4835. copies to or from the variables that have types that you have aligned
  4836. this way.
  4837. In the example above, if the size of each @code{short} is 2 bytes, then
  4838. the size of the entire @code{struct S} type is 6 bytes. The smallest
  4839. power of two that is greater than or equal to that is 8, so the
  4840. compiler sets the alignment for the entire @code{struct S} type to 8
  4841. bytes.
  4842. Note that although you can ask the compiler to select a time-efficient
  4843. alignment for a given type and then declare only individual stand-alone
  4844. objects of that type, the compiler's ability to select a time-efficient
  4845. alignment is primarily useful only when you plan to create arrays of
  4846. variables having the relevant (efficiently aligned) type. If you
  4847. declare or use arrays of variables of an efficiently-aligned type, then
  4848. it is likely that your program also does pointer arithmetic (or
  4849. subscripting, which amounts to the same thing) on pointers to the
  4850. relevant type, and the code that the compiler generates for these
  4851. pointer arithmetic operations is often more efficient for
  4852. efficiently-aligned types than for other types.
  4853. The @code{aligned} attribute can only increase the alignment; but you
  4854. can decrease it by specifying @code{packed} as well. See below.
  4855. Note that the effectiveness of @code{aligned} attributes may be limited
  4856. by inherent limitations in your linker. On many systems, the linker is
  4857. only able to arrange for variables to be aligned up to a certain maximum
  4858. alignment. (For some linkers, the maximum supported alignment may
  4859. be very very small.) If your linker is only able to align variables
  4860. up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
  4861. in an @code{__attribute__} still only provides you with 8-byte
  4862. alignment. See your linker documentation for further information.
  4863. @item packed
  4864. @cindex @code{packed} type attribute
  4865. This attribute, attached to @code{struct} or @code{union} type
  4866. definition, specifies that each member (other than zero-width bit-fields)
  4867. of the structure or union is placed to minimize the memory required. When
  4868. attached to an @code{enum} definition, it indicates that the smallest
  4869. integral type should be used.
  4870. @opindex fshort-enums
  4871. Specifying this attribute for @code{struct} and @code{union} types is
  4872. equivalent to specifying the @code{packed} attribute on each of the
  4873. structure or union members. Specifying the @option{-fshort-enums}
  4874. flag on the line is equivalent to specifying the @code{packed}
  4875. attribute on all @code{enum} definitions.
  4876. In the following example @code{struct my_packed_struct}'s members are
  4877. packed closely together, but the internal layout of its @code{s} member
  4878. is not packed---to do that, @code{struct my_unpacked_struct} needs to
  4879. be packed too.
  4880. @smallexample
  4881. struct my_unpacked_struct
  4882. @{
  4883. char c;
  4884. int i;
  4885. @};
  4886. struct __attribute__ ((__packed__)) my_packed_struct
  4887. @{
  4888. char c;
  4889. int i;
  4890. struct my_unpacked_struct s;
  4891. @};
  4892. @end smallexample
  4893. You may only specify this attribute on the definition of an @code{enum},
  4894. @code{struct} or @code{union}, not on a @code{typedef} that does not
  4895. also define the enumerated type, structure or union.
  4896. @item transparent_union
  4897. @cindex @code{transparent_union} type attribute
  4898. This attribute, attached to a @code{union} type definition, indicates
  4899. that any function parameter having that union type causes calls to that
  4900. function to be treated in a special way.
  4901. First, the argument corresponding to a transparent union type can be of
  4902. any type in the union; no cast is required. Also, if the union contains
  4903. a pointer type, the corresponding argument can be a null pointer
  4904. constant or a void pointer expression; and if the union contains a void
  4905. pointer type, the corresponding argument can be any pointer expression.
  4906. If the union member type is a pointer, qualifiers like @code{const} on
  4907. the referenced type must be respected, just as with normal pointer
  4908. conversions.
  4909. Second, the argument is passed to the function using the calling
  4910. conventions of the first member of the transparent union, not the calling
  4911. conventions of the union itself. All members of the union must have the
  4912. same machine representation; this is necessary for this argument passing
  4913. to work properly.
  4914. Transparent unions are designed for library functions that have multiple
  4915. interfaces for compatibility reasons. For example, suppose the
  4916. @code{wait} function must accept either a value of type @code{int *} to
  4917. comply with POSIX, or a value of type @code{union wait *} to comply with
  4918. the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
  4919. @code{wait} would accept both kinds of arguments, but it would also
  4920. accept any other pointer type and this would make argument type checking
  4921. less useful. Instead, @code{<sys/wait.h>} might define the interface
  4922. as follows:
  4923. @smallexample
  4924. typedef union __attribute__ ((__transparent_union__))
  4925. @{
  4926. int *__ip;
  4927. union wait *__up;
  4928. @} wait_status_ptr_t;
  4929. pid_t wait (wait_status_ptr_t);
  4930. @end smallexample
  4931. @noindent
  4932. This interface allows either @code{int *} or @code{union wait *}
  4933. arguments to be passed, using the @code{int *} calling convention.
  4934. The program can call @code{wait} with arguments of either type:
  4935. @smallexample
  4936. int w1 () @{ int w; return wait (&w); @}
  4937. int w2 () @{ union wait w; return wait (&w); @}
  4938. @end smallexample
  4939. @noindent
  4940. With this interface, @code{wait}'s implementation might look like this:
  4941. @smallexample
  4942. pid_t wait (wait_status_ptr_t p)
  4943. @{
  4944. return waitpid (-1, p.__ip, 0);
  4945. @}
  4946. @end smallexample
  4947. @item unused
  4948. @cindex @code{unused} type attribute
  4949. When attached to a type (including a @code{union} or a @code{struct}),
  4950. this attribute means that variables of that type are meant to appear
  4951. possibly unused. GCC does not produce a warning for any variables of
  4952. that type, even if the variable appears to do nothing. This is often
  4953. the case with lock or thread classes, which are usually defined and then
  4954. not referenced, but contain constructors and destructors that have
  4955. nontrivial bookkeeping functions.
  4956. @item deprecated
  4957. @itemx deprecated (@var{msg})
  4958. @cindex @code{deprecated} type attribute
  4959. The @code{deprecated} attribute results in a warning if the type
  4960. is used anywhere in the source file. This is useful when identifying
  4961. types that are expected to be removed in a future version of a program.
  4962. If possible, the warning also includes the location of the declaration
  4963. of the deprecated type, to enable users to easily find further
  4964. information about why the type is deprecated, or what they should do
  4965. instead. Note that the warnings only occur for uses and then only
  4966. if the type is being applied to an identifier that itself is not being
  4967. declared as deprecated.
  4968. @smallexample
  4969. typedef int T1 __attribute__ ((deprecated));
  4970. T1 x;
  4971. typedef T1 T2;
  4972. T2 y;
  4973. typedef T1 T3 __attribute__ ((deprecated));
  4974. T3 z __attribute__ ((deprecated));
  4975. @end smallexample
  4976. @noindent
  4977. results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
  4978. warning is issued for line 4 because T2 is not explicitly
  4979. deprecated. Line 5 has no warning because T3 is explicitly
  4980. deprecated. Similarly for line 6. The optional @var{msg}
  4981. argument, which must be a string, is printed in the warning if
  4982. present.
  4983. The @code{deprecated} attribute can also be used for functions and
  4984. variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
  4985. @item may_alias
  4986. @cindex @code{may_alias} type attribute
  4987. Accesses through pointers to types with this attribute are not subject
  4988. to type-based alias analysis, but are instead assumed to be able to alias
  4989. any other type of objects.
  4990. In the context of section 6.5 paragraph 7 of the C99 standard,
  4991. an lvalue expression
  4992. dereferencing such a pointer is treated like having a character type.
  4993. See @option{-fstrict-aliasing} for more information on aliasing issues.
  4994. This extension exists to support some vector APIs, in which pointers to
  4995. one vector type are permitted to alias pointers to a different vector type.
  4996. Note that an object of a type with this attribute does not have any
  4997. special semantics.
  4998. Example of use:
  4999. @smallexample
  5000. typedef short __attribute__((__may_alias__)) short_a;
  5001. int
  5002. main (void)
  5003. @{
  5004. int a = 0x12345678;
  5005. short_a *b = (short_a *) &a;
  5006. b[1] = 0;
  5007. if (a == 0x12345678)
  5008. abort();
  5009. exit(0);
  5010. @}
  5011. @end smallexample
  5012. @noindent
  5013. If you replaced @code{short_a} with @code{short} in the variable
  5014. declaration, the above program would abort when compiled with
  5015. @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
  5016. above.
  5017. @item visibility
  5018. @cindex @code{visibility} type attribute
  5019. In C++, attribute visibility (@pxref{Function Attributes}) can also be
  5020. applied to class, struct, union and enum types. Unlike other type
  5021. attributes, the attribute must appear between the initial keyword and
  5022. the name of the type; it cannot appear after the body of the type.
  5023. Note that the type visibility is applied to vague linkage entities
  5024. associated with the class (vtable, typeinfo node, etc.). In
  5025. particular, if a class is thrown as an exception in one shared object
  5026. and caught in another, the class must have default visibility.
  5027. Otherwise the two shared objects are unable to use the same
  5028. typeinfo node and exception handling will break.
  5029. @item designated_init
  5030. @cindex @code{designated_init} type attribute
  5031. This attribute may only be applied to structure types. It indicates
  5032. that any initialization of an object of this type must use designated
  5033. initializers rather than positional initializers. The intent of this
  5034. attribute is to allow the programmer to indicate that a structure's
  5035. layout may change, and that therefore relying on positional
  5036. initialization will result in future breakage.
  5037. GCC emits warnings based on this attribute by default; use
  5038. @option{-Wno-designated-init} to suppress them.
  5039. @item bnd_variable_size
  5040. @cindex @code{bnd_variable_size} type attribute
  5041. @cindex Pointer Bounds Checker attributes
  5042. When applied to a structure field, this attribute tells Pointer
  5043. Bounds Checker that the size of this field should not be computed
  5044. using static type information. It may be used to mark variably-sized
  5045. static array fields placed at the end of a structure.
  5046. @smallexample
  5047. struct S
  5048. @{
  5049. int size;
  5050. char data[1];
  5051. @}
  5052. S *p = (S *)malloc (sizeof(S) + 100);
  5053. p->data[10] = 0; //Bounds violation
  5054. @end smallexample
  5055. @noindent
  5056. By using an attribute for the field we may avoid unwanted bound
  5057. violation checks:
  5058. @smallexample
  5059. struct S
  5060. @{
  5061. int size;
  5062. char data[1] __attribute__((bnd_variable_size));
  5063. @}
  5064. S *p = (S *)malloc (sizeof(S) + 100);
  5065. p->data[10] = 0; //OK
  5066. @end smallexample
  5067. @end table
  5068. To specify multiple attributes, separate them by commas within the
  5069. double parentheses: for example, @samp{__attribute__ ((aligned (16),
  5070. packed))}.
  5071. @subsection ARM Type Attributes
  5072. @cindex @code{notshared} type attribute, ARM
  5073. On those ARM targets that support @code{dllimport} (such as Symbian
  5074. OS), you can use the @code{notshared} attribute to indicate that the
  5075. virtual table and other similar data for a class should not be
  5076. exported from a DLL@. For example:
  5077. @smallexample
  5078. class __declspec(notshared) C @{
  5079. public:
  5080. __declspec(dllimport) C();
  5081. virtual void f();
  5082. @}
  5083. __declspec(dllexport)
  5084. C::C() @{@}
  5085. @end smallexample
  5086. @noindent
  5087. In this code, @code{C::C} is exported from the current DLL, but the
  5088. virtual table for @code{C} is not exported. (You can use
  5089. @code{__attribute__} instead of @code{__declspec} if you prefer, but
  5090. most Symbian OS code uses @code{__declspec}.)
  5091. @anchor{MeP Type Attributes}
  5092. @subsection MeP Type Attributes
  5093. @cindex @code{based} type attribute, MeP
  5094. @cindex @code{tiny} type attribute, MeP
  5095. @cindex @code{near} type attribute, MeP
  5096. @cindex @code{far} type attribute, MeP
  5097. Many of the MeP variable attributes may be applied to types as well.
  5098. Specifically, the @code{based}, @code{tiny}, @code{near}, and
  5099. @code{far} attributes may be applied to either. The @code{io} and
  5100. @code{cb} attributes may not be applied to types.
  5101. @anchor{PowerPC Type Attributes}
  5102. @subsection PowerPC Type Attributes
  5103. Three attributes currently are defined for PowerPC configurations:
  5104. @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
  5105. @cindex @code{ms_struct} type attribute, PowerPC
  5106. @cindex @code{gcc_struct} type attribute, PowerPC
  5107. For full documentation of the @code{ms_struct} and @code{gcc_struct}
  5108. attributes please see the documentation in @ref{x86 Type Attributes}.
  5109. @cindex @code{altivec} type attribute, PowerPC
  5110. The @code{altivec} attribute allows one to declare AltiVec vector data
  5111. types supported by the AltiVec Programming Interface Manual. The
  5112. attribute requires an argument to specify one of three vector types:
  5113. @code{vector__}, @code{pixel__} (always followed by unsigned short),
  5114. and @code{bool__} (always followed by unsigned).
  5115. @smallexample
  5116. __attribute__((altivec(vector__)))
  5117. __attribute__((altivec(pixel__))) unsigned short
  5118. __attribute__((altivec(bool__))) unsigned
  5119. @end smallexample
  5120. These attributes mainly are intended to support the @code{__vector},
  5121. @code{__pixel}, and @code{__bool} AltiVec keywords.
  5122. @anchor{SPU Type Attributes}
  5123. @subsection SPU Type Attributes
  5124. @cindex @code{spu_vector} type attribute, SPU
  5125. The SPU supports the @code{spu_vector} attribute for types. This attribute
  5126. allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
  5127. Language Extensions Specification. It is intended to support the
  5128. @code{__vector} keyword.
  5129. @anchor{x86 Type Attributes}
  5130. @subsection x86 Type Attributes
  5131. Two attributes are currently defined for x86 configurations:
  5132. @code{ms_struct} and @code{gcc_struct}.
  5133. @table @code
  5134. @item ms_struct
  5135. @itemx gcc_struct
  5136. @cindex @code{ms_struct} type attribute, x86
  5137. @cindex @code{gcc_struct} type attribute, x86
  5138. If @code{packed} is used on a structure, or if bit-fields are used
  5139. it may be that the Microsoft ABI packs them differently
  5140. than GCC normally packs them. Particularly when moving packed
  5141. data between functions compiled with GCC and the native Microsoft compiler
  5142. (either via function call or as data in a file), it may be necessary to access
  5143. either format.
  5144. Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
  5145. compilers to match the native Microsoft compiler.
  5146. @end table
  5147. @node Alignment
  5148. @section Inquiring on Alignment of Types or Variables
  5149. @cindex alignment
  5150. @cindex type alignment
  5151. @cindex variable alignment
  5152. The keyword @code{__alignof__} allows you to inquire about how an object
  5153. is aligned, or the minimum alignment usually required by a type. Its
  5154. syntax is just like @code{sizeof}.
  5155. For example, if the target machine requires a @code{double} value to be
  5156. aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
  5157. This is true on many RISC machines. On more traditional machine
  5158. designs, @code{__alignof__ (double)} is 4 or even 2.
  5159. Some machines never actually require alignment; they allow reference to any
  5160. data type even at an odd address. For these machines, @code{__alignof__}
  5161. reports the smallest alignment that GCC gives the data type, usually as
  5162. mandated by the target ABI.
  5163. If the operand of @code{__alignof__} is an lvalue rather than a type,
  5164. its value is the required alignment for its type, taking into account
  5165. any minimum alignment specified with GCC's @code{__attribute__}
  5166. extension (@pxref{Variable Attributes}). For example, after this
  5167. declaration:
  5168. @smallexample
  5169. struct foo @{ int x; char y; @} foo1;
  5170. @end smallexample
  5171. @noindent
  5172. the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
  5173. alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
  5174. It is an error to ask for the alignment of an incomplete type.
  5175. @node Inline
  5176. @section An Inline Function is As Fast As a Macro
  5177. @cindex inline functions
  5178. @cindex integrating function code
  5179. @cindex open coding
  5180. @cindex macros, inline alternative
  5181. By declaring a function inline, you can direct GCC to make
  5182. calls to that function faster. One way GCC can achieve this is to
  5183. integrate that function's code into the code for its callers. This
  5184. makes execution faster by eliminating the function-call overhead; in
  5185. addition, if any of the actual argument values are constant, their
  5186. known values may permit simplifications at compile time so that not
  5187. all of the inline function's code needs to be included. The effect on
  5188. code size is less predictable; object code may be larger or smaller
  5189. with function inlining, depending on the particular case. You can
  5190. also direct GCC to try to integrate all ``simple enough'' functions
  5191. into their callers with the option @option{-finline-functions}.
  5192. GCC implements three different semantics of declaring a function
  5193. inline. One is available with @option{-std=gnu89} or
  5194. @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
  5195. on all inline declarations, another when
  5196. @option{-std=c99}, @option{-std=c11},
  5197. @option{-std=gnu99} or @option{-std=gnu11}
  5198. (without @option{-fgnu89-inline}), and the third
  5199. is used when compiling C++.
  5200. To declare a function inline, use the @code{inline} keyword in its
  5201. declaration, like this:
  5202. @smallexample
  5203. static inline int
  5204. inc (int *a)
  5205. @{
  5206. return (*a)++;
  5207. @}
  5208. @end smallexample
  5209. If you are writing a header file to be included in ISO C90 programs, write
  5210. @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
  5211. The three types of inlining behave similarly in two important cases:
  5212. when the @code{inline} keyword is used on a @code{static} function,
  5213. like the example above, and when a function is first declared without
  5214. using the @code{inline} keyword and then is defined with
  5215. @code{inline}, like this:
  5216. @smallexample
  5217. extern int inc (int *a);
  5218. inline int
  5219. inc (int *a)
  5220. @{
  5221. return (*a)++;
  5222. @}
  5223. @end smallexample
  5224. In both of these common cases, the program behaves the same as if you
  5225. had not used the @code{inline} keyword, except for its speed.
  5226. @cindex inline functions, omission of
  5227. @opindex fkeep-inline-functions
  5228. When a function is both inline and @code{static}, if all calls to the
  5229. function are integrated into the caller, and the function's address is
  5230. never used, then the function's own assembler code is never referenced.
  5231. In this case, GCC does not actually output assembler code for the
  5232. function, unless you specify the option @option{-fkeep-inline-functions}.
  5233. Some calls cannot be integrated for various reasons (in particular,
  5234. calls that precede the function's definition cannot be integrated, and
  5235. neither can recursive calls within the definition). If there is a
  5236. nonintegrated call, then the function is compiled to assembler code as
  5237. usual. The function must also be compiled as usual if the program
  5238. refers to its address, because that can't be inlined.
  5239. @opindex Winline
  5240. Note that certain usages in a function definition can make it unsuitable
  5241. for inline substitution. Among these usages are: variadic functions, use of
  5242. @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
  5243. use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
  5244. and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
  5245. warns when a function marked @code{inline} could not be substituted,
  5246. and gives the reason for the failure.
  5247. @cindex automatic @code{inline} for C++ member fns
  5248. @cindex @code{inline} automatic for C++ member fns
  5249. @cindex member fns, automatically @code{inline}
  5250. @cindex C++ member fns, automatically @code{inline}
  5251. @opindex fno-default-inline
  5252. As required by ISO C++, GCC considers member functions defined within
  5253. the body of a class to be marked inline even if they are
  5254. not explicitly declared with the @code{inline} keyword. You can
  5255. override this with @option{-fno-default-inline}; @pxref{C++ Dialect
  5256. Options,,Options Controlling C++ Dialect}.
  5257. GCC does not inline any functions when not optimizing unless you specify
  5258. the @samp{always_inline} attribute for the function, like this:
  5259. @smallexample
  5260. /* @r{Prototype.} */
  5261. inline void foo (const char) __attribute__((always_inline));
  5262. @end smallexample
  5263. The remainder of this section is specific to GNU C90 inlining.
  5264. @cindex non-static inline function
  5265. When an inline function is not @code{static}, then the compiler must assume
  5266. that there may be calls from other source files; since a global symbol can
  5267. be defined only once in any program, the function must not be defined in
  5268. the other source files, so the calls therein cannot be integrated.
  5269. Therefore, a non-@code{static} inline function is always compiled on its
  5270. own in the usual fashion.
  5271. If you specify both @code{inline} and @code{extern} in the function
  5272. definition, then the definition is used only for inlining. In no case
  5273. is the function compiled on its own, not even if you refer to its
  5274. address explicitly. Such an address becomes an external reference, as
  5275. if you had only declared the function, and had not defined it.
  5276. This combination of @code{inline} and @code{extern} has almost the
  5277. effect of a macro. The way to use it is to put a function definition in
  5278. a header file with these keywords, and put another copy of the
  5279. definition (lacking @code{inline} and @code{extern}) in a library file.
  5280. The definition in the header file causes most calls to the function
  5281. to be inlined. If any uses of the function remain, they refer to
  5282. the single copy in the library.
  5283. @node Volatiles
  5284. @section When is a Volatile Object Accessed?
  5285. @cindex accessing volatiles
  5286. @cindex volatile read
  5287. @cindex volatile write
  5288. @cindex volatile access
  5289. C has the concept of volatile objects. These are normally accessed by
  5290. pointers and used for accessing hardware or inter-thread
  5291. communication. The standard encourages compilers to refrain from
  5292. optimizations concerning accesses to volatile objects, but leaves it
  5293. implementation defined as to what constitutes a volatile access. The
  5294. minimum requirement is that at a sequence point all previous accesses
  5295. to volatile objects have stabilized and no subsequent accesses have
  5296. occurred. Thus an implementation is free to reorder and combine
  5297. volatile accesses that occur between sequence points, but cannot do
  5298. so for accesses across a sequence point. The use of volatile does
  5299. not allow you to violate the restriction on updating objects multiple
  5300. times between two sequence points.
  5301. Accesses to non-volatile objects are not ordered with respect to
  5302. volatile accesses. You cannot use a volatile object as a memory
  5303. barrier to order a sequence of writes to non-volatile memory. For
  5304. instance:
  5305. @smallexample
  5306. int *ptr = @var{something};
  5307. volatile int vobj;
  5308. *ptr = @var{something};
  5309. vobj = 1;
  5310. @end smallexample
  5311. @noindent
  5312. Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
  5313. that the write to @var{*ptr} occurs by the time the update
  5314. of @var{vobj} happens. If you need this guarantee, you must use
  5315. a stronger memory barrier such as:
  5316. @smallexample
  5317. int *ptr = @var{something};
  5318. volatile int vobj;
  5319. *ptr = @var{something};
  5320. asm volatile ("" : : : "memory");
  5321. vobj = 1;
  5322. @end smallexample
  5323. A scalar volatile object is read when it is accessed in a void context:
  5324. @smallexample
  5325. volatile int *src = @var{somevalue};
  5326. *src;
  5327. @end smallexample
  5328. Such expressions are rvalues, and GCC implements this as a
  5329. read of the volatile object being pointed to.
  5330. Assignments are also expressions and have an rvalue. However when
  5331. assigning to a scalar volatile, the volatile object is not reread,
  5332. regardless of whether the assignment expression's rvalue is used or
  5333. not. If the assignment's rvalue is used, the value is that assigned
  5334. to the volatile object. For instance, there is no read of @var{vobj}
  5335. in all the following cases:
  5336. @smallexample
  5337. int obj;
  5338. volatile int vobj;
  5339. vobj = @var{something};
  5340. obj = vobj = @var{something};
  5341. obj ? vobj = @var{onething} : vobj = @var{anotherthing};
  5342. obj = (@var{something}, vobj = @var{anotherthing});
  5343. @end smallexample
  5344. If you need to read the volatile object after an assignment has
  5345. occurred, you must use a separate expression with an intervening
  5346. sequence point.
  5347. As bit-fields are not individually addressable, volatile bit-fields may
  5348. be implicitly read when written to, or when adjacent bit-fields are
  5349. accessed. Bit-field operations may be optimized such that adjacent
  5350. bit-fields are only partially accessed, if they straddle a storage unit
  5351. boundary. For these reasons it is unwise to use volatile bit-fields to
  5352. access hardware.
  5353. @node Using Assembly Language with C
  5354. @section How to Use Inline Assembly Language in C Code
  5355. @cindex @code{asm} keyword
  5356. @cindex assembly language in C
  5357. @cindex inline assembly language
  5358. @cindex mixing assembly language and C
  5359. The @code{asm} keyword allows you to embed assembler instructions
  5360. within C code. GCC provides two forms of inline @code{asm}
  5361. statements. A @dfn{basic @code{asm}} statement is one with no
  5362. operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
  5363. statement (@pxref{Extended Asm}) includes one or more operands.
  5364. The extended form is preferred for mixing C and assembly language
  5365. within a function, but to include assembly language at
  5366. top level you must use basic @code{asm}.
  5367. You can also use the @code{asm} keyword to override the assembler name
  5368. for a C symbol, or to place a C variable in a specific register.
  5369. @menu
  5370. * Basic Asm:: Inline assembler without operands.
  5371. * Extended Asm:: Inline assembler with operands.
  5372. * Constraints:: Constraints for @code{asm} operands
  5373. * Asm Labels:: Specifying the assembler name to use for a C symbol.
  5374. * Explicit Reg Vars:: Defining variables residing in specified registers.
  5375. * Size of an asm:: How GCC calculates the size of an @code{asm} block.
  5376. @end menu
  5377. @node Basic Asm
  5378. @subsection Basic Asm --- Assembler Instructions Without Operands
  5379. @cindex basic @code{asm}
  5380. @cindex assembly language in C, basic
  5381. A basic @code{asm} statement has the following syntax:
  5382. @example
  5383. asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
  5384. @end example
  5385. The @code{asm} keyword is a GNU extension.
  5386. When writing code that can be compiled with @option{-ansi} and the
  5387. various @option{-std} options, use @code{__asm__} instead of
  5388. @code{asm} (@pxref{Alternate Keywords}).
  5389. @subsubheading Qualifiers
  5390. @table @code
  5391. @item volatile
  5392. The optional @code{volatile} qualifier has no effect.
  5393. All basic @code{asm} blocks are implicitly volatile.
  5394. @end table
  5395. @subsubheading Parameters
  5396. @table @var
  5397. @item AssemblerInstructions
  5398. This is a literal string that specifies the assembler code. The string can
  5399. contain any instructions recognized by the assembler, including directives.
  5400. GCC does not parse the assembler instructions themselves and
  5401. does not know what they mean or even whether they are valid assembler input.
  5402. You may place multiple assembler instructions together in a single @code{asm}
  5403. string, separated by the characters normally used in assembly code for the
  5404. system. A combination that works in most places is a newline to break the
  5405. line, plus a tab character (written as @samp{\n\t}).
  5406. Some assemblers allow semicolons as a line separator. However,
  5407. note that some assembler dialects use semicolons to start a comment.
  5408. @end table
  5409. @subsubheading Remarks
  5410. Using extended @code{asm} typically produces smaller, safer, and more
  5411. efficient code, and in most cases it is a better solution than basic
  5412. @code{asm}. However, there are two situations where only basic @code{asm}
  5413. can be used:
  5414. @itemize @bullet
  5415. @item
  5416. Extended @code{asm} statements have to be inside a C
  5417. function, so to write inline assembly language at file scope (``top-level''),
  5418. outside of C functions, you must use basic @code{asm}.
  5419. You can use this technique to emit assembler directives,
  5420. define assembly language macros that can be invoked elsewhere in the file,
  5421. or write entire functions in assembly language.
  5422. @item
  5423. Functions declared
  5424. with the @code{naked} attribute also require basic @code{asm}
  5425. (@pxref{Function Attributes}).
  5426. @end itemize
  5427. Safely accessing C data and calling functions from basic @code{asm} is more
  5428. complex than it may appear. To access C data, it is better to use extended
  5429. @code{asm}.
  5430. Do not expect a sequence of @code{asm} statements to remain perfectly
  5431. consecutive after compilation. If certain instructions need to remain
  5432. consecutive in the output, put them in a single multi-instruction @code{asm}
  5433. statement. Note that GCC's optimizers can move @code{asm} statements
  5434. relative to other code, including across jumps.
  5435. @code{asm} statements may not perform jumps into other @code{asm} statements.
  5436. GCC does not know about these jumps, and therefore cannot take
  5437. account of them when deciding how to optimize. Jumps from @code{asm} to C
  5438. labels are only supported in extended @code{asm}.
  5439. Under certain circumstances, GCC may duplicate (or remove duplicates of) your
  5440. assembly code when optimizing. This can lead to unexpected duplicate
  5441. symbol errors during compilation if your assembly code defines symbols or
  5442. labels.
  5443. Since GCC does not parse the @var{AssemblerInstructions}, it has no
  5444. visibility of any symbols it references. This may result in GCC discarding
  5445. those symbols as unreferenced.
  5446. The compiler copies the assembler instructions in a basic @code{asm}
  5447. verbatim to the assembly language output file, without
  5448. processing dialects or any of the @samp{%} operators that are available with
  5449. extended @code{asm}. This results in minor differences between basic
  5450. @code{asm} strings and extended @code{asm} templates. For example, to refer to
  5451. registers you might use @samp{%eax} in basic @code{asm} and
  5452. @samp{%%eax} in extended @code{asm}.
  5453. On targets such as x86 that support multiple assembler dialects,
  5454. all basic @code{asm} blocks use the assembler dialect specified by the
  5455. @option{-masm} command-line option (@pxref{x86 Options}).
  5456. Basic @code{asm} provides no
  5457. mechanism to provide different assembler strings for different dialects.
  5458. Here is an example of basic @code{asm} for i386:
  5459. @example
  5460. /* Note that this code will not compile with -masm=intel */
  5461. #define DebugBreak() asm("int $3")
  5462. @end example
  5463. @node Extended Asm
  5464. @subsection Extended Asm - Assembler Instructions with C Expression Operands
  5465. @cindex extended @code{asm}
  5466. @cindex assembly language in C, extended
  5467. With extended @code{asm} you can read and write C variables from
  5468. assembler and perform jumps from assembler code to C labels.
  5469. Extended @code{asm} syntax uses colons (@samp{:}) to delimit
  5470. the operand parameters after the assembler template:
  5471. @example
  5472. asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
  5473. : @var{OutputOperands}
  5474. @r{[} : @var{InputOperands}
  5475. @r{[} : @var{Clobbers} @r{]} @r{]})
  5476. asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
  5477. :
  5478. : @var{InputOperands}
  5479. : @var{Clobbers}
  5480. : @var{GotoLabels})
  5481. @end example
  5482. The @code{asm} keyword is a GNU extension.
  5483. When writing code that can be compiled with @option{-ansi} and the
  5484. various @option{-std} options, use @code{__asm__} instead of
  5485. @code{asm} (@pxref{Alternate Keywords}).
  5486. @subsubheading Qualifiers
  5487. @table @code
  5488. @item volatile
  5489. The typical use of extended @code{asm} statements is to manipulate input
  5490. values to produce output values. However, your @code{asm} statements may
  5491. also produce side effects. If so, you may need to use the @code{volatile}
  5492. qualifier to disable certain optimizations. @xref{Volatile}.
  5493. @item goto
  5494. This qualifier informs the compiler that the @code{asm} statement may
  5495. perform a jump to one of the labels listed in the @var{GotoLabels}.
  5496. @xref{GotoLabels}.
  5497. @end table
  5498. @subsubheading Parameters
  5499. @table @var
  5500. @item AssemblerTemplate
  5501. This is a literal string that is the template for the assembler code. It is a
  5502. combination of fixed text and tokens that refer to the input, output,
  5503. and goto parameters. @xref{AssemblerTemplate}.
  5504. @item OutputOperands
  5505. A comma-separated list of the C variables modified by the instructions in the
  5506. @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
  5507. @item InputOperands
  5508. A comma-separated list of C expressions read by the instructions in the
  5509. @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
  5510. @item Clobbers
  5511. A comma-separated list of registers or other values changed by the
  5512. @var{AssemblerTemplate}, beyond those listed as outputs.
  5513. An empty list is permitted. @xref{Clobbers}.
  5514. @item GotoLabels
  5515. When you are using the @code{goto} form of @code{asm}, this section contains
  5516. the list of all C labels to which the code in the
  5517. @var{AssemblerTemplate} may jump.
  5518. @xref{GotoLabels}.
  5519. @code{asm} statements may not perform jumps into other @code{asm} statements,
  5520. only to the listed @var{GotoLabels}.
  5521. GCC's optimizers do not know about other jumps; therefore they cannot take
  5522. account of them when deciding how to optimize.
  5523. @end table
  5524. The total number of input + output + goto operands is limited to 30.
  5525. @subsubheading Remarks
  5526. The @code{asm} statement allows you to include assembly instructions directly
  5527. within C code. This may help you to maximize performance in time-sensitive
  5528. code or to access assembly instructions that are not readily available to C
  5529. programs.
  5530. Note that extended @code{asm} statements must be inside a function. Only
  5531. basic @code{asm} may be outside functions (@pxref{Basic Asm}).
  5532. Functions declared with the @code{naked} attribute also require basic
  5533. @code{asm} (@pxref{Function Attributes}).
  5534. While the uses of @code{asm} are many and varied, it may help to think of an
  5535. @code{asm} statement as a series of low-level instructions that convert input
  5536. parameters to output parameters. So a simple (if not particularly useful)
  5537. example for i386 using @code{asm} might look like this:
  5538. @example
  5539. int src = 1;
  5540. int dst;
  5541. asm ("mov %1, %0\n\t"
  5542. "add $1, %0"
  5543. : "=r" (dst)
  5544. : "r" (src));
  5545. printf("%d\n", dst);
  5546. @end example
  5547. This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
  5548. @anchor{Volatile}
  5549. @subsubsection Volatile
  5550. @cindex volatile @code{asm}
  5551. @cindex @code{asm} volatile
  5552. GCC's optimizers sometimes discard @code{asm} statements if they determine
  5553. there is no need for the output variables. Also, the optimizers may move
  5554. code out of loops if they believe that the code will always return the same
  5555. result (i.e. none of its input values change between calls). Using the
  5556. @code{volatile} qualifier disables these optimizations. @code{asm} statements
  5557. that have no output operands, including @code{asm goto} statements,
  5558. are implicitly volatile.
  5559. This i386 code demonstrates a case that does not use (or require) the
  5560. @code{volatile} qualifier. If it is performing assertion checking, this code
  5561. uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
  5562. unreferenced by any code. As a result, the optimizers can discard the
  5563. @code{asm} statement, which in turn removes the need for the entire
  5564. @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
  5565. isn't needed you allow the optimizers to produce the most efficient code
  5566. possible.
  5567. @example
  5568. void DoCheck(uint32_t dwSomeValue)
  5569. @{
  5570. uint32_t dwRes;
  5571. // Assumes dwSomeValue is not zero.
  5572. asm ("bsfl %1,%0"
  5573. : "=r" (dwRes)
  5574. : "r" (dwSomeValue)
  5575. : "cc");
  5576. assert(dwRes > 3);
  5577. @}
  5578. @end example
  5579. The next example shows a case where the optimizers can recognize that the input
  5580. (@code{dwSomeValue}) never changes during the execution of the function and can
  5581. therefore move the @code{asm} outside the loop to produce more efficient code.
  5582. Again, using @code{volatile} disables this type of optimization.
  5583. @example
  5584. void do_print(uint32_t dwSomeValue)
  5585. @{
  5586. uint32_t dwRes;
  5587. for (uint32_t x=0; x < 5; x++)
  5588. @{
  5589. // Assumes dwSomeValue is not zero.
  5590. asm ("bsfl %1,%0"
  5591. : "=r" (dwRes)
  5592. : "r" (dwSomeValue)
  5593. : "cc");
  5594. printf("%u: %u %u\n", x, dwSomeValue, dwRes);
  5595. @}
  5596. @}
  5597. @end example
  5598. The following example demonstrates a case where you need to use the
  5599. @code{volatile} qualifier.
  5600. It uses the x86 @code{rdtsc} instruction, which reads
  5601. the computer's time-stamp counter. Without the @code{volatile} qualifier,
  5602. the optimizers might assume that the @code{asm} block will always return the
  5603. same value and therefore optimize away the second call.
  5604. @example
  5605. uint64_t msr;
  5606. asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
  5607. "shl $32, %%rdx\n\t" // Shift the upper bits left.
  5608. "or %%rdx, %0" // 'Or' in the lower bits.
  5609. : "=a" (msr)
  5610. :
  5611. : "rdx");
  5612. printf("msr: %llx\n", msr);
  5613. // Do other work...
  5614. // Reprint the timestamp
  5615. asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
  5616. "shl $32, %%rdx\n\t" // Shift the upper bits left.
  5617. "or %%rdx, %0" // 'Or' in the lower bits.
  5618. : "=a" (msr)
  5619. :
  5620. : "rdx");
  5621. printf("msr: %llx\n", msr);
  5622. @end example
  5623. GCC's optimizers do not treat this code like the non-volatile code in the
  5624. earlier examples. They do not move it out of loops or omit it on the
  5625. assumption that the result from a previous call is still valid.
  5626. Note that the compiler can move even volatile @code{asm} instructions relative
  5627. to other code, including across jump instructions. For example, on many
  5628. targets there is a system register that controls the rounding mode of
  5629. floating-point operations. Setting it with a volatile @code{asm}, as in the
  5630. following PowerPC example, does not work reliably.
  5631. @example
  5632. asm volatile("mtfsf 255, %0" : : "f" (fpenv));
  5633. sum = x + y;
  5634. @end example
  5635. The compiler may move the addition back before the volatile @code{asm}. To
  5636. make it work as expected, add an artificial dependency to the @code{asm} by
  5637. referencing a variable in the subsequent code, for example:
  5638. @example
  5639. asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
  5640. sum = x + y;
  5641. @end example
  5642. Under certain circumstances, GCC may duplicate (or remove duplicates of) your
  5643. assembly code when optimizing. This can lead to unexpected duplicate symbol
  5644. errors during compilation if your asm code defines symbols or labels.
  5645. Using @samp{%=}
  5646. (@pxref{AssemblerTemplate}) may help resolve this problem.
  5647. @anchor{AssemblerTemplate}
  5648. @subsubsection Assembler Template
  5649. @cindex @code{asm} assembler template
  5650. An assembler template is a literal string containing assembler instructions.
  5651. The compiler replaces tokens in the template that refer
  5652. to inputs, outputs, and goto labels,
  5653. and then outputs the resulting string to the assembler. The
  5654. string can contain any instructions recognized by the assembler, including
  5655. directives. GCC does not parse the assembler instructions
  5656. themselves and does not know what they mean or even whether they are valid
  5657. assembler input. However, it does count the statements
  5658. (@pxref{Size of an asm}).
  5659. You may place multiple assembler instructions together in a single @code{asm}
  5660. string, separated by the characters normally used in assembly code for the
  5661. system. A combination that works in most places is a newline to break the
  5662. line, plus a tab character to move to the instruction field (written as
  5663. @samp{\n\t}).
  5664. Some assemblers allow semicolons as a line separator. However, note
  5665. that some assembler dialects use semicolons to start a comment.
  5666. Do not expect a sequence of @code{asm} statements to remain perfectly
  5667. consecutive after compilation, even when you are using the @code{volatile}
  5668. qualifier. If certain instructions need to remain consecutive in the output,
  5669. put them in a single multi-instruction asm statement.
  5670. Accessing data from C programs without using input/output operands (such as
  5671. by using global symbols directly from the assembler template) may not work as
  5672. expected. Similarly, calling functions directly from an assembler template
  5673. requires a detailed understanding of the target assembler and ABI.
  5674. Since GCC does not parse the assembler template,
  5675. it has no visibility of any
  5676. symbols it references. This may result in GCC discarding those symbols as
  5677. unreferenced unless they are also listed as input, output, or goto operands.
  5678. @subsubheading Special format strings
  5679. In addition to the tokens described by the input, output, and goto operands,
  5680. these tokens have special meanings in the assembler template:
  5681. @table @samp
  5682. @item %%
  5683. Outputs a single @samp{%} into the assembler code.
  5684. @item %=
  5685. Outputs a number that is unique to each instance of the @code{asm}
  5686. statement in the entire compilation. This option is useful when creating local
  5687. labels and referring to them multiple times in a single template that
  5688. generates multiple assembler instructions.
  5689. @item %@{
  5690. @itemx %|
  5691. @itemx %@}
  5692. Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
  5693. into the assembler code. When unescaped, these characters have special
  5694. meaning to indicate multiple assembler dialects, as described below.
  5695. @end table
  5696. @subsubheading Multiple assembler dialects in @code{asm} templates
  5697. On targets such as x86, GCC supports multiple assembler dialects.
  5698. The @option{-masm} option controls which dialect GCC uses as its
  5699. default for inline assembler. The target-specific documentation for the
  5700. @option{-masm} option contains the list of supported dialects, as well as the
  5701. default dialect if the option is not specified. This information may be
  5702. important to understand, since assembler code that works correctly when
  5703. compiled using one dialect will likely fail if compiled using another.
  5704. @xref{x86 Options}.
  5705. If your code needs to support multiple assembler dialects (for example, if
  5706. you are writing public headers that need to support a variety of compilation
  5707. options), use constructs of this form:
  5708. @example
  5709. @{ dialect0 | dialect1 | dialect2... @}
  5710. @end example
  5711. This construct outputs @code{dialect0}
  5712. when using dialect #0 to compile the code,
  5713. @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
  5714. braces than the number of dialects the compiler supports, the construct
  5715. outputs nothing.
  5716. For example, if an x86 compiler supports two dialects
  5717. (@samp{att}, @samp{intel}), an
  5718. assembler template such as this:
  5719. @example
  5720. "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
  5721. @end example
  5722. @noindent
  5723. is equivalent to one of
  5724. @example
  5725. "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
  5726. "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
  5727. @end example
  5728. Using that same compiler, this code:
  5729. @example
  5730. "xchg@{l@}\t@{%%@}ebx, %1"
  5731. @end example
  5732. @noindent
  5733. corresponds to either
  5734. @example
  5735. "xchgl\t%%ebx, %1" @r{/* att dialect */}
  5736. "xchg\tebx, %1" @r{/* intel dialect */}
  5737. @end example
  5738. There is no support for nesting dialect alternatives.
  5739. @anchor{OutputOperands}
  5740. @subsubsection Output Operands
  5741. @cindex @code{asm} output operands
  5742. An @code{asm} statement has zero or more output operands indicating the names
  5743. of C variables modified by the assembler code.
  5744. In this i386 example, @code{old} (referred to in the template string as
  5745. @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
  5746. (@code{%2}) is an input:
  5747. @example
  5748. bool old;
  5749. __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
  5750. "sbb %0,%0" // Use the CF to calculate old.
  5751. : "=r" (old), "+rm" (*Base)
  5752. : "Ir" (Offset)
  5753. : "cc");
  5754. return old;
  5755. @end example
  5756. Operands are separated by commas. Each operand has this format:
  5757. @example
  5758. @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
  5759. @end example
  5760. @table @var
  5761. @item asmSymbolicName
  5762. Specifies a symbolic name for the operand.
  5763. Reference the name in the assembler template
  5764. by enclosing it in square brackets
  5765. (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
  5766. that contains the definition. Any valid C variable name is acceptable,
  5767. including names already defined in the surrounding code. No two operands
  5768. within the same @code{asm} statement can use the same symbolic name.
  5769. When not using an @var{asmSymbolicName}, use the (zero-based) position
  5770. of the operand
  5771. in the list of operands in the assembler template. For example if there are
  5772. three output operands, use @samp{%0} in the template to refer to the first,
  5773. @samp{%1} for the second, and @samp{%2} for the third.
  5774. @item constraint
  5775. A string constant specifying constraints on the placement of the operand;
  5776. @xref{Constraints}, for details.
  5777. Output constraints must begin with either @samp{=} (a variable overwriting an
  5778. existing value) or @samp{+} (when reading and writing). When using
  5779. @samp{=}, do not assume the location contains the existing value
  5780. on entry to the @code{asm}, except
  5781. when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
  5782. After the prefix, there must be one or more additional constraints
  5783. (@pxref{Constraints}) that describe where the value resides. Common
  5784. constraints include @samp{r} for register and @samp{m} for memory.
  5785. When you list more than one possible location (for example, @code{"=rm"}),
  5786. the compiler chooses the most efficient one based on the current context.
  5787. If you list as many alternates as the @code{asm} statement allows, you permit
  5788. the optimizers to produce the best possible code.
  5789. If you must use a specific register, but your Machine Constraints do not
  5790. provide sufficient control to select the specific register you want,
  5791. local register variables may provide a solution (@pxref{Local Reg Vars}).
  5792. @item cvariablename
  5793. Specifies a C lvalue expression to hold the output, typically a variable name.
  5794. The enclosing parentheses are a required part of the syntax.
  5795. @end table
  5796. When the compiler selects the registers to use to
  5797. represent the output operands, it does not use any of the clobbered registers
  5798. (@pxref{Clobbers}).
  5799. Output operand expressions must be lvalues. The compiler cannot check whether
  5800. the operands have data types that are reasonable for the instruction being
  5801. executed. For output expressions that are not directly addressable (for
  5802. example a bit-field), the constraint must allow a register. In that case, GCC
  5803. uses the register as the output of the @code{asm}, and then stores that
  5804. register into the output.
  5805. Operands using the @samp{+} constraint modifier count as two operands
  5806. (that is, both as input and output) towards the total maximum of 30 operands
  5807. per @code{asm} statement.
  5808. Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
  5809. operands that must not overlap an input. Otherwise,
  5810. GCC may allocate the output operand in the same register as an unrelated
  5811. input operand, on the assumption that the assembler code consumes its
  5812. inputs before producing outputs. This assumption may be false if the assembler
  5813. code actually consists of more than one instruction.
  5814. The same problem can occur if one output parameter (@var{a}) allows a register
  5815. constraint and another output parameter (@var{b}) allows a memory constraint.
  5816. The code generated by GCC to access the memory address in @var{b} can contain
  5817. registers which @emph{might} be shared by @var{a}, and GCC considers those
  5818. registers to be inputs to the asm. As above, GCC assumes that such input
  5819. registers are consumed before any outputs are written. This assumption may
  5820. result in incorrect behavior if the asm writes to @var{a} before using
  5821. @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
  5822. ensures that modifying @var{a} does not affect the address referenced by
  5823. @var{b}. Otherwise, the location of @var{b}
  5824. is undefined if @var{a} is modified before using @var{b}.
  5825. @code{asm} supports operand modifiers on operands (for example @samp{%k2}
  5826. instead of simply @samp{%2}). Typically these qualifiers are hardware
  5827. dependent. The list of supported modifiers for x86 is found at
  5828. @ref{x86Operandmodifiers,x86 Operand modifiers}.
  5829. If the C code that follows the @code{asm} makes no use of any of the output
  5830. operands, use @code{volatile} for the @code{asm} statement to prevent the
  5831. optimizers from discarding the @code{asm} statement as unneeded
  5832. (see @ref{Volatile}).
  5833. This code makes no use of the optional @var{asmSymbolicName}. Therefore it
  5834. references the first output operand as @code{%0} (were there a second, it
  5835. would be @code{%1}, etc). The number of the first input operand is one greater
  5836. than that of the last output operand. In this i386 example, that makes
  5837. @code{Mask} referenced as @code{%1}:
  5838. @example
  5839. uint32_t Mask = 1234;
  5840. uint32_t Index;
  5841. asm ("bsfl %1, %0"
  5842. : "=r" (Index)
  5843. : "r" (Mask)
  5844. : "cc");
  5845. @end example
  5846. That code overwrites the variable @code{Index} (@samp{=}),
  5847. placing the value in a register (@samp{r}).
  5848. Using the generic @samp{r} constraint instead of a constraint for a specific
  5849. register allows the compiler to pick the register to use, which can result
  5850. in more efficient code. This may not be possible if an assembler instruction
  5851. requires a specific register.
  5852. The following i386 example uses the @var{asmSymbolicName} syntax.
  5853. It produces the
  5854. same result as the code above, but some may consider it more readable or more
  5855. maintainable since reordering index numbers is not necessary when adding or
  5856. removing operands. The names @code{aIndex} and @code{aMask}
  5857. are only used in this example to emphasize which
  5858. names get used where.
  5859. It is acceptable to reuse the names @code{Index} and @code{Mask}.
  5860. @example
  5861. uint32_t Mask = 1234;
  5862. uint32_t Index;
  5863. asm ("bsfl %[aMask], %[aIndex]"
  5864. : [aIndex] "=r" (Index)
  5865. : [aMask] "r" (Mask)
  5866. : "cc");
  5867. @end example
  5868. Here are some more examples of output operands.
  5869. @example
  5870. uint32_t c = 1;
  5871. uint32_t d;
  5872. uint32_t *e = &c;
  5873. asm ("mov %[e], %[d]"
  5874. : [d] "=rm" (d)
  5875. : [e] "rm" (*e));
  5876. @end example
  5877. Here, @code{d} may either be in a register or in memory. Since the compiler
  5878. might already have the current value of the @code{uint32_t} location
  5879. pointed to by @code{e}
  5880. in a register, you can enable it to choose the best location
  5881. for @code{d} by specifying both constraints.
  5882. @anchor{InputOperands}
  5883. @subsubsection Input Operands
  5884. @cindex @code{asm} input operands
  5885. @cindex @code{asm} expressions
  5886. Input operands make values from C variables and expressions available to the
  5887. assembly code.
  5888. Operands are separated by commas. Each operand has this format:
  5889. @example
  5890. @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
  5891. @end example
  5892. @table @var
  5893. @item asmSymbolicName
  5894. Specifies a symbolic name for the operand.
  5895. Reference the name in the assembler template
  5896. by enclosing it in square brackets
  5897. (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
  5898. that contains the definition. Any valid C variable name is acceptable,
  5899. including names already defined in the surrounding code. No two operands
  5900. within the same @code{asm} statement can use the same symbolic name.
  5901. When not using an @var{asmSymbolicName}, use the (zero-based) position
  5902. of the operand
  5903. in the list of operands in the assembler template. For example if there are
  5904. two output operands and three inputs,
  5905. use @samp{%2} in the template to refer to the first input operand,
  5906. @samp{%3} for the second, and @samp{%4} for the third.
  5907. @item constraint
  5908. A string constant specifying constraints on the placement of the operand;
  5909. @xref{Constraints}, for details.
  5910. Input constraint strings may not begin with either @samp{=} or @samp{+}.
  5911. When you list more than one possible location (for example, @samp{"irm"}),
  5912. the compiler chooses the most efficient one based on the current context.
  5913. If you must use a specific register, but your Machine Constraints do not
  5914. provide sufficient control to select the specific register you want,
  5915. local register variables may provide a solution (@pxref{Local Reg Vars}).
  5916. Input constraints can also be digits (for example, @code{"0"}). This indicates
  5917. that the specified input must be in the same place as the output constraint
  5918. at the (zero-based) index in the output constraint list.
  5919. When using @var{asmSymbolicName} syntax for the output operands,
  5920. you may use these names (enclosed in brackets @samp{[]}) instead of digits.
  5921. @item cexpression
  5922. This is the C variable or expression being passed to the @code{asm} statement
  5923. as input. The enclosing parentheses are a required part of the syntax.
  5924. @end table
  5925. When the compiler selects the registers to use to represent the input
  5926. operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
  5927. If there are no output operands but there are input operands, place two
  5928. consecutive colons where the output operands would go:
  5929. @example
  5930. __asm__ ("some instructions"
  5931. : /* No outputs. */
  5932. : "r" (Offset / 8));
  5933. @end example
  5934. @strong{Warning:} Do @emph{not} modify the contents of input-only operands
  5935. (except for inputs tied to outputs). The compiler assumes that on exit from
  5936. the @code{asm} statement these operands contain the same values as they
  5937. had before executing the statement.
  5938. It is @emph{not} possible to use clobbers
  5939. to inform the compiler that the values in these inputs are changing. One
  5940. common work-around is to tie the changing input variable to an output variable
  5941. that never gets used. Note, however, that if the code that follows the
  5942. @code{asm} statement makes no use of any of the output operands, the GCC
  5943. optimizers may discard the @code{asm} statement as unneeded
  5944. (see @ref{Volatile}).
  5945. @code{asm} supports operand modifiers on operands (for example @samp{%k2}
  5946. instead of simply @samp{%2}). Typically these qualifiers are hardware
  5947. dependent. The list of supported modifiers for x86 is found at
  5948. @ref{x86Operandmodifiers,x86 Operand modifiers}.
  5949. In this example using the fictitious @code{combine} instruction, the
  5950. constraint @code{"0"} for input operand 1 says that it must occupy the same
  5951. location as output operand 0. Only input operands may use numbers in
  5952. constraints, and they must each refer to an output operand. Only a number (or
  5953. the symbolic assembler name) in the constraint can guarantee that one operand
  5954. is in the same place as another. The mere fact that @code{foo} is the value of
  5955. both operands is not enough to guarantee that they are in the same place in
  5956. the generated assembler code.
  5957. @example
  5958. asm ("combine %2, %0"
  5959. : "=r" (foo)
  5960. : "0" (foo), "g" (bar));
  5961. @end example
  5962. Here is an example using symbolic names.
  5963. @example
  5964. asm ("cmoveq %1, %2, %[result]"
  5965. : [result] "=r"(result)
  5966. : "r" (test), "r" (new), "[result]" (old));
  5967. @end example
  5968. @anchor{Clobbers}
  5969. @subsubsection Clobbers
  5970. @cindex @code{asm} clobbers
  5971. While the compiler is aware of changes to entries listed in the output
  5972. operands, the inline @code{asm} code may modify more than just the outputs. For
  5973. example, calculations may require additional registers, or the processor may
  5974. overwrite a register as a side effect of a particular assembler instruction.
  5975. In order to inform the compiler of these changes, list them in the clobber
  5976. list. Clobber list items are either register names or the special clobbers
  5977. (listed below). Each clobber list item is a string constant
  5978. enclosed in double quotes and separated by commas.
  5979. Clobber descriptions may not in any way overlap with an input or output
  5980. operand. For example, you may not have an operand describing a register class
  5981. with one member when listing that register in the clobber list. Variables
  5982. declared to live in specific registers (@pxref{Explicit Reg Vars}) and used
  5983. as @code{asm} input or output operands must have no part mentioned in the
  5984. clobber description. In particular, there is no way to specify that input
  5985. operands get modified without also specifying them as output operands.
  5986. When the compiler selects which registers to use to represent input and output
  5987. operands, it does not use any of the clobbered registers. As a result,
  5988. clobbered registers are available for any use in the assembler code.
  5989. Here is a realistic example for the VAX showing the use of clobbered
  5990. registers:
  5991. @example
  5992. asm volatile ("movc3 %0, %1, %2"
  5993. : /* No outputs. */
  5994. : "g" (from), "g" (to), "g" (count)
  5995. : "r0", "r1", "r2", "r3", "r4", "r5");
  5996. @end example
  5997. Also, there are two special clobber arguments:
  5998. @table @code
  5999. @item "cc"
  6000. The @code{"cc"} clobber indicates that the assembler code modifies the flags
  6001. register. On some machines, GCC represents the condition codes as a specific
  6002. hardware register; @code{"cc"} serves to name this register.
  6003. On other machines, condition code handling is different,
  6004. and specifying @code{"cc"} has no effect. But
  6005. it is valid no matter what the target.
  6006. @item "memory"
  6007. The @code{"memory"} clobber tells the compiler that the assembly code
  6008. performs memory
  6009. reads or writes to items other than those listed in the input and output
  6010. operands (for example, accessing the memory pointed to by one of the input
  6011. parameters). To ensure memory contains correct values, GCC may need to flush
  6012. specific register values to memory before executing the @code{asm}. Further,
  6013. the compiler does not assume that any values read from memory before an
  6014. @code{asm} remain unchanged after that @code{asm}; it reloads them as
  6015. needed.
  6016. Using the @code{"memory"} clobber effectively forms a read/write
  6017. memory barrier for the compiler.
  6018. Note that this clobber does not prevent the @emph{processor} from doing
  6019. speculative reads past the @code{asm} statement. To prevent that, you need
  6020. processor-specific fence instructions.
  6021. Flushing registers to memory has performance implications and may be an issue
  6022. for time-sensitive code. You can use a trick to avoid this if the size of
  6023. the memory being accessed is known at compile time. For example, if accessing
  6024. ten bytes of a string, use a memory input like:
  6025. @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
  6026. @end table
  6027. @anchor{GotoLabels}
  6028. @subsubsection Goto Labels
  6029. @cindex @code{asm} goto labels
  6030. @code{asm goto} allows assembly code to jump to one or more C labels. The
  6031. @var{GotoLabels} section in an @code{asm goto} statement contains
  6032. a comma-separated
  6033. list of all C labels to which the assembler code may jump. GCC assumes that
  6034. @code{asm} execution falls through to the next statement (if this is not the
  6035. case, consider using the @code{__builtin_unreachable} intrinsic after the
  6036. @code{asm} statement). Optimization of @code{asm goto} may be improved by
  6037. using the @code{hot} and @code{cold} label attributes (@pxref{Label
  6038. Attributes}).
  6039. An @code{asm goto} statement cannot have outputs.
  6040. This is due to an internal restriction of
  6041. the compiler: control transfer instructions cannot have outputs.
  6042. If the assembler code does modify anything, use the @code{"memory"} clobber
  6043. to force the
  6044. optimizers to flush all register values to memory and reload them if
  6045. necessary after the @code{asm} statement.
  6046. Also note that an @code{asm goto} statement is always implicitly
  6047. considered volatile.
  6048. To reference a label in the assembler template,
  6049. prefix it with @samp{%l} (lowercase @samp{L}) followed
  6050. by its (zero-based) position in @var{GotoLabels} plus the number of input
  6051. operands. For example, if the @code{asm} has three inputs and references two
  6052. labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
  6053. Alternately, you can reference labels using the actual C label name enclosed
  6054. in brackets. For example, to reference a label named @code{carry}, you can
  6055. use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
  6056. section when using this approach.
  6057. Here is an example of @code{asm goto} for i386:
  6058. @example
  6059. asm goto (
  6060. "btl %1, %0\n\t"
  6061. "jc %l2"
  6062. : /* No outputs. */
  6063. : "r" (p1), "r" (p2)
  6064. : "cc"
  6065. : carry);
  6066. return 0;
  6067. carry:
  6068. return 1;
  6069. @end example
  6070. The following example shows an @code{asm goto} that uses a memory clobber.
  6071. @example
  6072. int frob(int x)
  6073. @{
  6074. int y;
  6075. asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
  6076. : /* No outputs. */
  6077. : "r"(x), "r"(&y)
  6078. : "r5", "memory"
  6079. : error);
  6080. return y;
  6081. error:
  6082. return -1;
  6083. @}
  6084. @end example
  6085. @anchor{x86Operandmodifiers}
  6086. @subsubsection x86 Operand Modifiers
  6087. References to input, output, and goto operands in the assembler template
  6088. of extended @code{asm} statements can use
  6089. modifiers to affect the way the operands are formatted in
  6090. the code output to the assembler. For example, the
  6091. following code uses the @samp{h} and @samp{b} modifiers for x86:
  6092. @example
  6093. uint16_t num;
  6094. asm volatile ("xchg %h0, %b0" : "+a" (num) );
  6095. @end example
  6096. @noindent
  6097. These modifiers generate this assembler code:
  6098. @example
  6099. xchg %ah, %al
  6100. @end example
  6101. The rest of this discussion uses the following code for illustrative purposes.
  6102. @example
  6103. int main()
  6104. @{
  6105. int iInt = 1;
  6106. top:
  6107. asm volatile goto ("some assembler instructions here"
  6108. : /* No outputs. */
  6109. : "q" (iInt), "X" (sizeof(unsigned char) + 1)
  6110. : /* No clobbers. */
  6111. : top);
  6112. @}
  6113. @end example
  6114. With no modifiers, this is what the output from the operands would be for the
  6115. @samp{att} and @samp{intel} dialects of assembler:
  6116. @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
  6117. @headitem Operand @tab masm=att @tab masm=intel
  6118. @item @code{%0}
  6119. @tab @code{%eax}
  6120. @tab @code{eax}
  6121. @item @code{%1}
  6122. @tab @code{$2}
  6123. @tab @code{2}
  6124. @item @code{%2}
  6125. @tab @code{$.L2}
  6126. @tab @code{OFFSET FLAT:.L2}
  6127. @end multitable
  6128. The table below shows the list of supported modifiers and their effects.
  6129. @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
  6130. @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
  6131. @item @code{z}
  6132. @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
  6133. @tab @code{%z0}
  6134. @tab @code{l}
  6135. @tab
  6136. @item @code{b}
  6137. @tab Print the QImode name of the register.
  6138. @tab @code{%b0}
  6139. @tab @code{%al}
  6140. @tab @code{al}
  6141. @item @code{h}
  6142. @tab Print the QImode name for a ``high'' register.
  6143. @tab @code{%h0}
  6144. @tab @code{%ah}
  6145. @tab @code{ah}
  6146. @item @code{w}
  6147. @tab Print the HImode name of the register.
  6148. @tab @code{%w0}
  6149. @tab @code{%ax}
  6150. @tab @code{ax}
  6151. @item @code{k}
  6152. @tab Print the SImode name of the register.
  6153. @tab @code{%k0}
  6154. @tab @code{%eax}
  6155. @tab @code{eax}
  6156. @item @code{q}
  6157. @tab Print the DImode name of the register.
  6158. @tab @code{%q0}
  6159. @tab @code{%rax}
  6160. @tab @code{rax}
  6161. @item @code{l}
  6162. @tab Print the label name with no punctuation.
  6163. @tab @code{%l2}
  6164. @tab @code{.L2}
  6165. @tab @code{.L2}
  6166. @item @code{c}
  6167. @tab Require a constant operand and print the constant expression with no punctuation.
  6168. @tab @code{%c1}
  6169. @tab @code{2}
  6170. @tab @code{2}
  6171. @end multitable
  6172. @anchor{x86floatingpointasmoperands}
  6173. @subsubsection x86 Floating-Point @code{asm} Operands
  6174. On x86 targets, there are several rules on the usage of stack-like registers
  6175. in the operands of an @code{asm}. These rules apply only to the operands
  6176. that are stack-like registers:
  6177. @enumerate
  6178. @item
  6179. Given a set of input registers that die in an @code{asm}, it is
  6180. necessary to know which are implicitly popped by the @code{asm}, and
  6181. which must be explicitly popped by GCC@.
  6182. An input register that is implicitly popped by the @code{asm} must be
  6183. explicitly clobbered, unless it is constrained to match an
  6184. output operand.
  6185. @item
  6186. For any input register that is implicitly popped by an @code{asm}, it is
  6187. necessary to know how to adjust the stack to compensate for the pop.
  6188. If any non-popped input is closer to the top of the reg-stack than
  6189. the implicitly popped register, it would not be possible to know what the
  6190. stack looked like---it's not clear how the rest of the stack ``slides
  6191. up''.
  6192. All implicitly popped input registers must be closer to the top of
  6193. the reg-stack than any input that is not implicitly popped.
  6194. It is possible that if an input dies in an @code{asm}, the compiler might
  6195. use the input register for an output reload. Consider this example:
  6196. @smallexample
  6197. asm ("foo" : "=t" (a) : "f" (b));
  6198. @end smallexample
  6199. @noindent
  6200. This code says that input @code{b} is not popped by the @code{asm}, and that
  6201. the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
  6202. deeper after the @code{asm} than it was before. But, it is possible that
  6203. reload may think that it can use the same register for both the input and
  6204. the output.
  6205. To prevent this from happening,
  6206. if any input operand uses the @samp{f} constraint, all output register
  6207. constraints must use the @samp{&} early-clobber modifier.
  6208. The example above is correctly written as:
  6209. @smallexample
  6210. asm ("foo" : "=&t" (a) : "f" (b));
  6211. @end smallexample
  6212. @item
  6213. Some operands need to be in particular places on the stack. All
  6214. output operands fall in this category---GCC has no other way to
  6215. know which registers the outputs appear in unless you indicate
  6216. this in the constraints.
  6217. Output operands must specifically indicate which register an output
  6218. appears in after an @code{asm}. @samp{=f} is not allowed: the operand
  6219. constraints must select a class with a single register.
  6220. @item
  6221. Output operands may not be ``inserted'' between existing stack registers.
  6222. Since no 387 opcode uses a read/write operand, all output operands
  6223. are dead before the @code{asm}, and are pushed by the @code{asm}.
  6224. It makes no sense to push anywhere but the top of the reg-stack.
  6225. Output operands must start at the top of the reg-stack: output
  6226. operands may not ``skip'' a register.
  6227. @item
  6228. Some @code{asm} statements may need extra stack space for internal
  6229. calculations. This can be guaranteed by clobbering stack registers
  6230. unrelated to the inputs and outputs.
  6231. @end enumerate
  6232. This @code{asm}
  6233. takes one input, which is internally popped, and produces two outputs.
  6234. @smallexample
  6235. asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
  6236. @end smallexample
  6237. @noindent
  6238. This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
  6239. and replaces them with one output. The @code{st(1)} clobber is necessary
  6240. for the compiler to know that @code{fyl2xp1} pops both inputs.
  6241. @smallexample
  6242. asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
  6243. @end smallexample
  6244. @lowersections
  6245. @include md.texi
  6246. @raisesections
  6247. @node Asm Labels
  6248. @subsection Controlling Names Used in Assembler Code
  6249. @cindex assembler names for identifiers
  6250. @cindex names used in assembler code
  6251. @cindex identifiers, names in assembler code
  6252. You can specify the name to be used in the assembler code for a C
  6253. function or variable by writing the @code{asm} (or @code{__asm__})
  6254. keyword after the declarator as follows:
  6255. @smallexample
  6256. int foo asm ("myfoo") = 2;
  6257. @end smallexample
  6258. @noindent
  6259. This specifies that the name to be used for the variable @code{foo} in
  6260. the assembler code should be @samp{myfoo} rather than the usual
  6261. @samp{_foo}.
  6262. On systems where an underscore is normally prepended to the name of a C
  6263. function or variable, this feature allows you to define names for the
  6264. linker that do not start with an underscore.
  6265. It does not make sense to use this feature with a non-static local
  6266. variable since such variables do not have assembler names. If you are
  6267. trying to put the variable in a particular register, see @ref{Explicit
  6268. Reg Vars}. GCC presently accepts such code with a warning, but will
  6269. probably be changed to issue an error, rather than a warning, in the
  6270. future.
  6271. You cannot use @code{asm} in this way in a function @emph{definition}; but
  6272. you can get the same effect by writing a declaration for the function
  6273. before its definition and putting @code{asm} there, like this:
  6274. @smallexample
  6275. extern func () asm ("FUNC");
  6276. func (x, y)
  6277. int x, y;
  6278. /* @r{@dots{}} */
  6279. @end smallexample
  6280. It is up to you to make sure that the assembler names you choose do not
  6281. conflict with any other assembler symbols. Also, you must not use a
  6282. register name; that would produce completely invalid assembler code. GCC
  6283. does not as yet have the ability to store static variables in registers.
  6284. Perhaps that will be added.
  6285. @node Explicit Reg Vars
  6286. @subsection Variables in Specified Registers
  6287. @cindex explicit register variables
  6288. @cindex variables in specified registers
  6289. @cindex specified registers
  6290. @cindex registers, global allocation
  6291. GNU C allows you to put a few global variables into specified hardware
  6292. registers. You can also specify the register in which an ordinary
  6293. register variable should be allocated.
  6294. @itemize @bullet
  6295. @item
  6296. Global register variables reserve registers throughout the program.
  6297. This may be useful in programs such as programming language
  6298. interpreters that have a couple of global variables that are accessed
  6299. very often.
  6300. @item
  6301. Local register variables in specific registers do not reserve the
  6302. registers, except at the point where they are used as input or output
  6303. operands in an @code{asm} statement and the @code{asm} statement itself is
  6304. not deleted. The compiler's data flow analysis is capable of determining
  6305. where the specified registers contain live values, and where they are
  6306. available for other uses. Stores into local register variables may be deleted
  6307. when they appear to be dead according to dataflow analysis. References
  6308. to local register variables may be deleted or moved or simplified.
  6309. These local variables are sometimes convenient for use with the extended
  6310. @code{asm} feature (@pxref{Extended Asm}), if you want to write one
  6311. output of the assembler instruction directly into a particular register.
  6312. (This works provided the register you specify fits the constraints
  6313. specified for that operand in the @code{asm}.)
  6314. @end itemize
  6315. @menu
  6316. * Global Reg Vars::
  6317. * Local Reg Vars::
  6318. @end menu
  6319. @node Global Reg Vars
  6320. @subsubsection Defining Global Register Variables
  6321. @cindex global register variables
  6322. @cindex registers, global variables in
  6323. You can define a global register variable in GNU C like this:
  6324. @smallexample
  6325. register int *foo asm ("a5");
  6326. @end smallexample
  6327. @noindent
  6328. Here @code{a5} is the name of the register that should be used. Choose a
  6329. register that is normally saved and restored by function calls on your
  6330. machine, so that library routines will not clobber it.
  6331. Naturally the register name is CPU-dependent, so you need to
  6332. conditionalize your program according to CPU type. The register
  6333. @code{a5} is a good choice on a 68000 for a variable of pointer
  6334. type. On machines with register windows, be sure to choose a ``global''
  6335. register that is not affected magically by the function call mechanism.
  6336. In addition, different operating systems on the same CPU may differ in how they
  6337. name the registers; then you need additional conditionals. For
  6338. example, some 68000 operating systems call this register @code{%a5}.
  6339. Eventually there may be a way of asking the compiler to choose a register
  6340. automatically, but first we need to figure out how it should choose and
  6341. how to enable you to guide the choice. No solution is evident.
  6342. Defining a global register variable in a certain register reserves that
  6343. register entirely for this use, at least within the current compilation.
  6344. The register is not allocated for any other purpose in the functions
  6345. in the current compilation, and is not saved and restored by
  6346. these functions. Stores into this register are never deleted even if they
  6347. appear to be dead, but references may be deleted or moved or
  6348. simplified.
  6349. It is not safe to access the global register variables from signal
  6350. handlers, or from more than one thread of control, because the system
  6351. library routines may temporarily use the register for other things (unless
  6352. you recompile them specially for the task at hand).
  6353. @cindex @code{qsort}, and global register variables
  6354. It is not safe for one function that uses a global register variable to
  6355. call another such function @code{foo} by way of a third function
  6356. @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
  6357. different source file in which the variable isn't declared). This is
  6358. because @code{lose} might save the register and put some other value there.
  6359. For example, you can't expect a global register variable to be available in
  6360. the comparison-function that you pass to @code{qsort}, since @code{qsort}
  6361. might have put something else in that register. (If you are prepared to
  6362. recompile @code{qsort} with the same global register variable, you can
  6363. solve this problem.)
  6364. If you want to recompile @code{qsort} or other source files that do not
  6365. actually use your global register variable, so that they do not use that
  6366. register for any other purpose, then it suffices to specify the compiler
  6367. option @option{-ffixed-@var{reg}}. You need not actually add a global
  6368. register declaration to their source code.
  6369. A function that can alter the value of a global register variable cannot
  6370. safely be called from a function compiled without this variable, because it
  6371. could clobber the value the caller expects to find there on return.
  6372. Therefore, the function that is the entry point into the part of the
  6373. program that uses the global register variable must explicitly save and
  6374. restore the value that belongs to its caller.
  6375. @cindex register variable after @code{longjmp}
  6376. @cindex global register after @code{longjmp}
  6377. @cindex value after @code{longjmp}
  6378. @findex longjmp
  6379. @findex setjmp
  6380. On most machines, @code{longjmp} restores to each global register
  6381. variable the value it had at the time of the @code{setjmp}. On some
  6382. machines, however, @code{longjmp} does not change the value of global
  6383. register variables. To be portable, the function that called @code{setjmp}
  6384. should make other arrangements to save the values of the global register
  6385. variables, and to restore them in a @code{longjmp}. This way, the same
  6386. thing happens regardless of what @code{longjmp} does.
  6387. All global register variable declarations must precede all function
  6388. definitions. If such a declaration could appear after function
  6389. definitions, the declaration would be too late to prevent the register from
  6390. being used for other purposes in the preceding functions.
  6391. Global register variables may not have initial values, because an
  6392. executable file has no means to supply initial contents for a register.
  6393. On the SPARC, there are reports that g3 @dots{} g7 are suitable
  6394. registers, but certain library functions, such as @code{getwd}, as well
  6395. as the subroutines for division and remainder, modify g3 and g4. g1 and
  6396. g2 are local temporaries.
  6397. On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
  6398. Of course, it does not do to use more than a few of those.
  6399. @node Local Reg Vars
  6400. @subsubsection Specifying Registers for Local Variables
  6401. @cindex local variables, specifying registers
  6402. @cindex specifying registers for local variables
  6403. @cindex registers for local variables
  6404. You can define a local register variable with a specified register
  6405. like this:
  6406. @smallexample
  6407. register int *foo asm ("a5");
  6408. @end smallexample
  6409. @noindent
  6410. Here @code{a5} is the name of the register that should be used. Note
  6411. that this is the same syntax used for defining global register
  6412. variables, but for a local variable it appears within a function.
  6413. Naturally the register name is CPU-dependent, but this is not a
  6414. problem, since specific registers are most often useful with explicit
  6415. assembler instructions (@pxref{Extended Asm}). Both of these things
  6416. generally require that you conditionalize your program according to
  6417. CPU type.
  6418. In addition, operating systems on one type of CPU may differ in how they
  6419. name the registers; then you need additional conditionals. For
  6420. example, some 68000 operating systems call this register @code{%a5}.
  6421. Defining such a register variable does not reserve the register; it
  6422. remains available for other uses in places where flow control determines
  6423. the variable's value is not live.
  6424. This option does not guarantee that GCC generates code that has
  6425. this variable in the register you specify at all times. You may not
  6426. code an explicit reference to this register in the assembler
  6427. instruction template part of an @code{asm} statement and assume it
  6428. always refers to this variable.
  6429. However, using the variable as an input or output operand to the @code{asm}
  6430. guarantees that the specified register is used for that operand.
  6431. @xref{Extended Asm}, for more information.
  6432. Stores into local register variables may be deleted when they appear to be dead
  6433. according to dataflow analysis. References to local register variables may
  6434. be deleted or moved or simplified.
  6435. As with global register variables, it is recommended that you choose a
  6436. register that is normally saved and restored by function calls on
  6437. your machine, so that library routines will not clobber it.
  6438. Sometimes when writing inline @code{asm} code, you need to make an operand be a
  6439. specific register, but there's no matching constraint letter for that
  6440. register. To force the operand into that register, create a local variable
  6441. and specify the register in the variable's declaration. Then use the local
  6442. variable for the asm operand and specify any constraint letter that matches
  6443. the register:
  6444. @smallexample
  6445. register int *p1 asm ("r0") = @dots{};
  6446. register int *p2 asm ("r1") = @dots{};
  6447. register int *result asm ("r0");
  6448. asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
  6449. @end smallexample
  6450. @emph{Warning:} In the above example, be aware that a register (for example r0) can be
  6451. call-clobbered by subsequent code, including function calls and library calls
  6452. for arithmetic operators on other variables (for example the initialization
  6453. of p2). In this case, use temporary variables for expressions between the
  6454. register assignments:
  6455. @smallexample
  6456. int t1 = @dots{};
  6457. register int *p1 asm ("r0") = @dots{};
  6458. register int *p2 asm ("r1") = t1;
  6459. register int *result asm ("r0");
  6460. asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
  6461. @end smallexample
  6462. @node Size of an asm
  6463. @subsection Size of an @code{asm}
  6464. Some targets require that GCC track the size of each instruction used
  6465. in order to generate correct code. Because the final length of the
  6466. code produced by an @code{asm} statement is only known by the
  6467. assembler, GCC must make an estimate as to how big it will be. It
  6468. does this by counting the number of instructions in the pattern of the
  6469. @code{asm} and multiplying that by the length of the longest
  6470. instruction supported by that processor. (When working out the number
  6471. of instructions, it assumes that any occurrence of a newline or of
  6472. whatever statement separator character is supported by the assembler --
  6473. typically @samp{;} --- indicates the end of an instruction.)
  6474. Normally, GCC's estimate is adequate to ensure that correct
  6475. code is generated, but it is possible to confuse the compiler if you use
  6476. pseudo instructions or assembler macros that expand into multiple real
  6477. instructions, or if you use assembler directives that expand to more
  6478. space in the object file than is needed for a single instruction.
  6479. If this happens then the assembler may produce a diagnostic saying that
  6480. a label is unreachable.
  6481. @node Alternate Keywords
  6482. @section Alternate Keywords
  6483. @cindex alternate keywords
  6484. @cindex keywords, alternate
  6485. @option{-ansi} and the various @option{-std} options disable certain
  6486. keywords. This causes trouble when you want to use GNU C extensions, or
  6487. a general-purpose header file that should be usable by all programs,
  6488. including ISO C programs. The keywords @code{asm}, @code{typeof} and
  6489. @code{inline} are not available in programs compiled with
  6490. @option{-ansi} or @option{-std} (although @code{inline} can be used in a
  6491. program compiled with @option{-std=c99} or @option{-std=c11}). The
  6492. ISO C99 keyword
  6493. @code{restrict} is only available when @option{-std=gnu99} (which will
  6494. eventually be the default) or @option{-std=c99} (or the equivalent
  6495. @option{-std=iso9899:1999}), or an option for a later standard
  6496. version, is used.
  6497. The way to solve these problems is to put @samp{__} at the beginning and
  6498. end of each problematical keyword. For example, use @code{__asm__}
  6499. instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
  6500. Other C compilers won't accept these alternative keywords; if you want to
  6501. compile with another compiler, you can define the alternate keywords as
  6502. macros to replace them with the customary keywords. It looks like this:
  6503. @smallexample
  6504. #ifndef __GNUC__
  6505. #define __asm__ asm
  6506. #endif
  6507. @end smallexample
  6508. @findex __extension__
  6509. @opindex pedantic
  6510. @option{-pedantic} and other options cause warnings for many GNU C extensions.
  6511. You can
  6512. prevent such warnings within one expression by writing
  6513. @code{__extension__} before the expression. @code{__extension__} has no
  6514. effect aside from this.
  6515. @node Incomplete Enums
  6516. @section Incomplete @code{enum} Types
  6517. You can define an @code{enum} tag without specifying its possible values.
  6518. This results in an incomplete type, much like what you get if you write
  6519. @code{struct foo} without describing the elements. A later declaration
  6520. that does specify the possible values completes the type.
  6521. You can't allocate variables or storage using the type while it is
  6522. incomplete. However, you can work with pointers to that type.
  6523. This extension may not be very useful, but it makes the handling of
  6524. @code{enum} more consistent with the way @code{struct} and @code{union}
  6525. are handled.
  6526. This extension is not supported by GNU C++.
  6527. @node Function Names
  6528. @section Function Names as Strings
  6529. @cindex @code{__func__} identifier
  6530. @cindex @code{__FUNCTION__} identifier
  6531. @cindex @code{__PRETTY_FUNCTION__} identifier
  6532. GCC provides three magic variables that hold the name of the current
  6533. function, as a string. The first of these is @code{__func__}, which
  6534. is part of the C99 standard:
  6535. The identifier @code{__func__} is implicitly declared by the translator
  6536. as if, immediately following the opening brace of each function
  6537. definition, the declaration
  6538. @smallexample
  6539. static const char __func__[] = "function-name";
  6540. @end smallexample
  6541. @noindent
  6542. appeared, where function-name is the name of the lexically-enclosing
  6543. function. This name is the unadorned name of the function.
  6544. @code{__FUNCTION__} is another name for @code{__func__}, provided for
  6545. backward compatibility with old versions of GCC.
  6546. In C, @code{__PRETTY_FUNCTION__} is yet another name for
  6547. @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
  6548. the type signature of the function as well as its bare name. For
  6549. example, this program:
  6550. @smallexample
  6551. extern "C" @{
  6552. extern int printf (char *, ...);
  6553. @}
  6554. class a @{
  6555. public:
  6556. void sub (int i)
  6557. @{
  6558. printf ("__FUNCTION__ = %s\n", __FUNCTION__);
  6559. printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
  6560. @}
  6561. @};
  6562. int
  6563. main (void)
  6564. @{
  6565. a ax;
  6566. ax.sub (0);
  6567. return 0;
  6568. @}
  6569. @end smallexample
  6570. @noindent
  6571. gives this output:
  6572. @smallexample
  6573. __FUNCTION__ = sub
  6574. __PRETTY_FUNCTION__ = void a::sub(int)
  6575. @end smallexample
  6576. These identifiers are variables, not preprocessor macros, and may not
  6577. be used to initialize @code{char} arrays or be concatenated with other string
  6578. literals.
  6579. @node Return Address
  6580. @section Getting the Return or Frame Address of a Function
  6581. These functions may be used to get information about the callers of a
  6582. function.
  6583. @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
  6584. This function returns the return address of the current function, or of
  6585. one of its callers. The @var{level} argument is number of frames to
  6586. scan up the call stack. A value of @code{0} yields the return address
  6587. of the current function, a value of @code{1} yields the return address
  6588. of the caller of the current function, and so forth. When inlining
  6589. the expected behavior is that the function returns the address of
  6590. the function that is returned to. To work around this behavior use
  6591. the @code{noinline} function attribute.
  6592. The @var{level} argument must be a constant integer.
  6593. On some machines it may be impossible to determine the return address of
  6594. any function other than the current one; in such cases, or when the top
  6595. of the stack has been reached, this function returns @code{0} or a
  6596. random value. In addition, @code{__builtin_frame_address} may be used
  6597. to determine if the top of the stack has been reached.
  6598. Additional post-processing of the returned value may be needed, see
  6599. @code{__builtin_extract_return_addr}.
  6600. This function should only be used with a nonzero argument for debugging
  6601. purposes.
  6602. @end deftypefn
  6603. @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
  6604. The address as returned by @code{__builtin_return_address} may have to be fed
  6605. through this function to get the actual encoded address. For example, on the
  6606. 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
  6607. platforms an offset has to be added for the true next instruction to be
  6608. executed.
  6609. If no fixup is needed, this function simply passes through @var{addr}.
  6610. @end deftypefn
  6611. @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
  6612. This function does the reverse of @code{__builtin_extract_return_addr}.
  6613. @end deftypefn
  6614. @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
  6615. This function is similar to @code{__builtin_return_address}, but it
  6616. returns the address of the function frame rather than the return address
  6617. of the function. Calling @code{__builtin_frame_address} with a value of
  6618. @code{0} yields the frame address of the current function, a value of
  6619. @code{1} yields the frame address of the caller of the current function,
  6620. and so forth.
  6621. The frame is the area on the stack that holds local variables and saved
  6622. registers. The frame address is normally the address of the first word
  6623. pushed on to the stack by the function. However, the exact definition
  6624. depends upon the processor and the calling convention. If the processor
  6625. has a dedicated frame pointer register, and the function has a frame,
  6626. then @code{__builtin_frame_address} returns the value of the frame
  6627. pointer register.
  6628. On some machines it may be impossible to determine the frame address of
  6629. any function other than the current one; in such cases, or when the top
  6630. of the stack has been reached, this function returns @code{0} if
  6631. the first frame pointer is properly initialized by the startup code.
  6632. This function should only be used with a nonzero argument for debugging
  6633. purposes.
  6634. @end deftypefn
  6635. @node Vector Extensions
  6636. @section Using Vector Instructions through Built-in Functions
  6637. On some targets, the instruction set contains SIMD vector instructions which
  6638. operate on multiple values contained in one large register at the same time.
  6639. For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
  6640. this way.
  6641. The first step in using these extensions is to provide the necessary data
  6642. types. This should be done using an appropriate @code{typedef}:
  6643. @smallexample
  6644. typedef int v4si __attribute__ ((vector_size (16)));
  6645. @end smallexample
  6646. @noindent
  6647. The @code{int} type specifies the base type, while the attribute specifies
  6648. the vector size for the variable, measured in bytes. For example, the
  6649. declaration above causes the compiler to set the mode for the @code{v4si}
  6650. type to be 16 bytes wide and divided into @code{int} sized units. For
  6651. a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
  6652. corresponding mode of @code{foo} is @acronym{V4SI}.
  6653. The @code{vector_size} attribute is only applicable to integral and
  6654. float scalars, although arrays, pointers, and function return values
  6655. are allowed in conjunction with this construct. Only sizes that are
  6656. a power of two are currently allowed.
  6657. All the basic integer types can be used as base types, both as signed
  6658. and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
  6659. @code{long long}. In addition, @code{float} and @code{double} can be
  6660. used to build floating-point vector types.
  6661. Specifying a combination that is not valid for the current architecture
  6662. causes GCC to synthesize the instructions using a narrower mode.
  6663. For example, if you specify a variable of type @code{V4SI} and your
  6664. architecture does not allow for this specific SIMD type, GCC
  6665. produces code that uses 4 @code{SIs}.
  6666. The types defined in this manner can be used with a subset of normal C
  6667. operations. Currently, GCC allows using the following operators
  6668. on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
  6669. The operations behave like C++ @code{valarrays}. Addition is defined as
  6670. the addition of the corresponding elements of the operands. For
  6671. example, in the code below, each of the 4 elements in @var{a} is
  6672. added to the corresponding 4 elements in @var{b} and the resulting
  6673. vector is stored in @var{c}.
  6674. @smallexample
  6675. typedef int v4si __attribute__ ((vector_size (16)));
  6676. v4si a, b, c;
  6677. c = a + b;
  6678. @end smallexample
  6679. Subtraction, multiplication, division, and the logical operations
  6680. operate in a similar manner. Likewise, the result of using the unary
  6681. minus or complement operators on a vector type is a vector whose
  6682. elements are the negative or complemented values of the corresponding
  6683. elements in the operand.
  6684. It is possible to use shifting operators @code{<<}, @code{>>} on
  6685. integer-type vectors. The operation is defined as following: @code{@{a0,
  6686. a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
  6687. @dots{}, an >> bn@}}@. Vector operands must have the same number of
  6688. elements.
  6689. For convenience, it is allowed to use a binary vector operation
  6690. where one operand is a scalar. In that case the compiler transforms
  6691. the scalar operand into a vector where each element is the scalar from
  6692. the operation. The transformation happens only if the scalar could be
  6693. safely converted to the vector-element type.
  6694. Consider the following code.
  6695. @smallexample
  6696. typedef int v4si __attribute__ ((vector_size (16)));
  6697. v4si a, b, c;
  6698. long l;
  6699. a = b + 1; /* a = b + @{1,1,1,1@}; */
  6700. a = 2 * b; /* a = @{2,2,2,2@} * b; */
  6701. a = l + a; /* Error, cannot convert long to int. */
  6702. @end smallexample
  6703. Vectors can be subscripted as if the vector were an array with
  6704. the same number of elements and base type. Out of bound accesses
  6705. invoke undefined behavior at run time. Warnings for out of bound
  6706. accesses for vector subscription can be enabled with
  6707. @option{-Warray-bounds}.
  6708. Vector comparison is supported with standard comparison
  6709. operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
  6710. vector expressions of integer-type or real-type. Comparison between
  6711. integer-type vectors and real-type vectors are not supported. The
  6712. result of the comparison is a vector of the same width and number of
  6713. elements as the comparison operands with a signed integral element
  6714. type.
  6715. Vectors are compared element-wise producing 0 when comparison is false
  6716. and -1 (constant of the appropriate type where all bits are set)
  6717. otherwise. Consider the following example.
  6718. @smallexample
  6719. typedef int v4si __attribute__ ((vector_size (16)));
  6720. v4si a = @{1,2,3,4@};
  6721. v4si b = @{3,2,1,4@};
  6722. v4si c;
  6723. c = a > b; /* The result would be @{0, 0,-1, 0@} */
  6724. c = a == b; /* The result would be @{0,-1, 0,-1@} */
  6725. @end smallexample
  6726. In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
  6727. @code{b} and @code{c} are vectors of the same type and @code{a} is an
  6728. integer vector with the same number of elements of the same size as @code{b}
  6729. and @code{c}, computes all three arguments and creates a vector
  6730. @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
  6731. OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
  6732. As in the case of binary operations, this syntax is also accepted when
  6733. one of @code{b} or @code{c} is a scalar that is then transformed into a
  6734. vector. If both @code{b} and @code{c} are scalars and the type of
  6735. @code{true?b:c} has the same size as the element type of @code{a}, then
  6736. @code{b} and @code{c} are converted to a vector type whose elements have
  6737. this type and with the same number of elements as @code{a}.
  6738. In C++, the logic operators @code{!, &&, ||} are available for vectors.
  6739. @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
  6740. @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
  6741. For mixed operations between a scalar @code{s} and a vector @code{v},
  6742. @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
  6743. short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
  6744. Vector shuffling is available using functions
  6745. @code{__builtin_shuffle (vec, mask)} and
  6746. @code{__builtin_shuffle (vec0, vec1, mask)}.
  6747. Both functions construct a permutation of elements from one or two
  6748. vectors and return a vector of the same type as the input vector(s).
  6749. The @var{mask} is an integral vector with the same width (@var{W})
  6750. and element count (@var{N}) as the output vector.
  6751. The elements of the input vectors are numbered in memory ordering of
  6752. @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
  6753. elements of @var{mask} are considered modulo @var{N} in the single-operand
  6754. case and modulo @math{2*@var{N}} in the two-operand case.
  6755. Consider the following example,
  6756. @smallexample
  6757. typedef int v4si __attribute__ ((vector_size (16)));
  6758. v4si a = @{1,2,3,4@};
  6759. v4si b = @{5,6,7,8@};
  6760. v4si mask1 = @{0,1,1,3@};
  6761. v4si mask2 = @{0,4,2,5@};
  6762. v4si res;
  6763. res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
  6764. res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
  6765. @end smallexample
  6766. Note that @code{__builtin_shuffle} is intentionally semantically
  6767. compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
  6768. You can declare variables and use them in function calls and returns, as
  6769. well as in assignments and some casts. You can specify a vector type as
  6770. a return type for a function. Vector types can also be used as function
  6771. arguments. It is possible to cast from one vector type to another,
  6772. provided they are of the same size (in fact, you can also cast vectors
  6773. to and from other datatypes of the same size).
  6774. You cannot operate between vectors of different lengths or different
  6775. signedness without a cast.
  6776. @node Offsetof
  6777. @section Support for @code{offsetof}
  6778. @findex __builtin_offsetof
  6779. GCC implements for both C and C++ a syntactic extension to implement
  6780. the @code{offsetof} macro.
  6781. @smallexample
  6782. primary:
  6783. "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
  6784. offsetof_member_designator:
  6785. @code{identifier}
  6786. | offsetof_member_designator "." @code{identifier}
  6787. | offsetof_member_designator "[" @code{expr} "]"
  6788. @end smallexample
  6789. This extension is sufficient such that
  6790. @smallexample
  6791. #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
  6792. @end smallexample
  6793. @noindent
  6794. is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
  6795. may be dependent. In either case, @var{member} may consist of a single
  6796. identifier, or a sequence of member accesses and array references.
  6797. @node __sync Builtins
  6798. @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
  6799. The following built-in functions
  6800. are intended to be compatible with those described
  6801. in the @cite{Intel Itanium Processor-specific Application Binary Interface},
  6802. section 7.4. As such, they depart from the normal GCC practice of using
  6803. the @samp{__builtin_} prefix, and further that they are overloaded such that
  6804. they work on multiple types.
  6805. The definition given in the Intel documentation allows only for the use of
  6806. the types @code{int}, @code{long}, @code{long long} as well as their unsigned
  6807. counterparts. GCC allows any integral scalar or pointer type that is
  6808. 1, 2, 4 or 8 bytes in length.
  6809. Not all operations are supported by all target processors. If a particular
  6810. operation cannot be implemented on the target processor, a warning is
  6811. generated and a call to an external function is generated. The external
  6812. function carries the same name as the built-in version,
  6813. with an additional suffix
  6814. @samp{_@var{n}} where @var{n} is the size of the data type.
  6815. @c ??? Should we have a mechanism to suppress this warning? This is almost
  6816. @c useful for implementing the operation under the control of an external
  6817. @c mutex.
  6818. In most cases, these built-in functions are considered a @dfn{full barrier}.
  6819. That is,
  6820. no memory operand is moved across the operation, either forward or
  6821. backward. Further, instructions are issued as necessary to prevent the
  6822. processor from speculating loads across the operation and from queuing stores
  6823. after the operation.
  6824. All of the routines are described in the Intel documentation to take
  6825. ``an optional list of variables protected by the memory barrier''. It's
  6826. not clear what is meant by that; it could mean that @emph{only} the
  6827. following variables are protected, or it could mean that these variables
  6828. should in addition be protected. At present GCC ignores this list and
  6829. protects all variables that are globally accessible. If in the future
  6830. we make some use of this list, an empty list will continue to mean all
  6831. globally accessible variables.
  6832. @table @code
  6833. @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
  6834. @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
  6835. @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
  6836. @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
  6837. @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
  6838. @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
  6839. @findex __sync_fetch_and_add
  6840. @findex __sync_fetch_and_sub
  6841. @findex __sync_fetch_and_or
  6842. @findex __sync_fetch_and_and
  6843. @findex __sync_fetch_and_xor
  6844. @findex __sync_fetch_and_nand
  6845. These built-in functions perform the operation suggested by the name, and
  6846. returns the value that had previously been in memory. That is,
  6847. @smallexample
  6848. @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
  6849. @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
  6850. @end smallexample
  6851. @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
  6852. as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
  6853. @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
  6854. @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
  6855. @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
  6856. @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
  6857. @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
  6858. @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
  6859. @findex __sync_add_and_fetch
  6860. @findex __sync_sub_and_fetch
  6861. @findex __sync_or_and_fetch
  6862. @findex __sync_and_and_fetch
  6863. @findex __sync_xor_and_fetch
  6864. @findex __sync_nand_and_fetch
  6865. These built-in functions perform the operation suggested by the name, and
  6866. return the new value. That is,
  6867. @smallexample
  6868. @{ *ptr @var{op}= value; return *ptr; @}
  6869. @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
  6870. @end smallexample
  6871. @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
  6872. as @code{*ptr = ~(*ptr & value)} instead of
  6873. @code{*ptr = ~*ptr & value}.
  6874. @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
  6875. @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
  6876. @findex __sync_bool_compare_and_swap
  6877. @findex __sync_val_compare_and_swap
  6878. These built-in functions perform an atomic compare and swap.
  6879. That is, if the current
  6880. value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
  6881. @code{*@var{ptr}}.
  6882. The ``bool'' version returns true if the comparison is successful and
  6883. @var{newval} is written. The ``val'' version returns the contents
  6884. of @code{*@var{ptr}} before the operation.
  6885. @item __sync_synchronize (...)
  6886. @findex __sync_synchronize
  6887. This built-in function issues a full memory barrier.
  6888. @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
  6889. @findex __sync_lock_test_and_set
  6890. This built-in function, as described by Intel, is not a traditional test-and-set
  6891. operation, but rather an atomic exchange operation. It writes @var{value}
  6892. into @code{*@var{ptr}}, and returns the previous contents of
  6893. @code{*@var{ptr}}.
  6894. Many targets have only minimal support for such locks, and do not support
  6895. a full exchange operation. In this case, a target may support reduced
  6896. functionality here by which the @emph{only} valid value to store is the
  6897. immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
  6898. is implementation defined.
  6899. This built-in function is not a full barrier,
  6900. but rather an @dfn{acquire barrier}.
  6901. This means that references after the operation cannot move to (or be
  6902. speculated to) before the operation, but previous memory stores may not
  6903. be globally visible yet, and previous memory loads may not yet be
  6904. satisfied.
  6905. @item void __sync_lock_release (@var{type} *ptr, ...)
  6906. @findex __sync_lock_release
  6907. This built-in function releases the lock acquired by
  6908. @code{__sync_lock_test_and_set}.
  6909. Normally this means writing the constant 0 to @code{*@var{ptr}}.
  6910. This built-in function is not a full barrier,
  6911. but rather a @dfn{release barrier}.
  6912. This means that all previous memory stores are globally visible, and all
  6913. previous memory loads have been satisfied, but following memory reads
  6914. are not prevented from being speculated to before the barrier.
  6915. @end table
  6916. @node __atomic Builtins
  6917. @section Built-in Functions for Memory Model Aware Atomic Operations
  6918. The following built-in functions approximately match the requirements for
  6919. C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
  6920. functions, but all also have a memory model parameter. These are all
  6921. identified by being prefixed with @samp{__atomic}, and most are overloaded
  6922. such that they work with multiple types.
  6923. GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
  6924. bytes in length. 16-byte integral types are also allowed if
  6925. @samp{__int128} (@pxref{__int128}) is supported by the architecture.
  6926. Target architectures are encouraged to provide their own patterns for
  6927. each of these built-in functions. If no target is provided, the original
  6928. non-memory model set of @samp{__sync} atomic built-in functions are
  6929. utilized, along with any required synchronization fences surrounding it in
  6930. order to achieve the proper behavior. Execution in this case is subject
  6931. to the same restrictions as those built-in functions.
  6932. If there is no pattern or mechanism to provide a lock free instruction
  6933. sequence, a call is made to an external routine with the same parameters
  6934. to be resolved at run time.
  6935. The four non-arithmetic functions (load, store, exchange, and
  6936. compare_exchange) all have a generic version as well. This generic
  6937. version works on any data type. If the data type size maps to one
  6938. of the integral sizes that may have lock free support, the generic
  6939. version utilizes the lock free built-in function. Otherwise an
  6940. external call is left to be resolved at run time. This external call is
  6941. the same format with the addition of a @samp{size_t} parameter inserted
  6942. as the first parameter indicating the size of the object being pointed to.
  6943. All objects must be the same size.
  6944. There are 6 different memory models that can be specified. These map
  6945. to the same names in the C++11 standard. Refer there or to the
  6946. @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
  6947. atomic synchronization} for more detailed definitions. These memory
  6948. models integrate both barriers to code motion as well as synchronization
  6949. requirements with other threads. These are listed in approximately
  6950. ascending order of strength. It is also possible to use target specific
  6951. flags for memory model flags, like Hardware Lock Elision.
  6952. @table @code
  6953. @item __ATOMIC_RELAXED
  6954. No barriers or synchronization.
  6955. @item __ATOMIC_CONSUME
  6956. Data dependency only for both barrier and synchronization with another
  6957. thread.
  6958. @item __ATOMIC_ACQUIRE
  6959. Barrier to hoisting of code and synchronizes with release (or stronger)
  6960. semantic stores from another thread.
  6961. @item __ATOMIC_RELEASE
  6962. Barrier to sinking of code and synchronizes with acquire (or stronger)
  6963. semantic loads from another thread.
  6964. @item __ATOMIC_ACQ_REL
  6965. Full barrier in both directions and synchronizes with acquire loads and
  6966. release stores in another thread.
  6967. @item __ATOMIC_SEQ_CST
  6968. Full barrier in both directions and synchronizes with acquire loads and
  6969. release stores in all threads.
  6970. @end table
  6971. When implementing patterns for these built-in functions, the memory model
  6972. parameter can be ignored as long as the pattern implements the most
  6973. restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
  6974. execute correctly with this memory model but they may not execute as
  6975. efficiently as they could with a more appropriate implementation of the
  6976. relaxed requirements.
  6977. Note that the C++11 standard allows for the memory model parameter to be
  6978. determined at run time rather than at compile time. These built-in
  6979. functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
  6980. than invoke a runtime library call or inline a switch statement. This is
  6981. standard compliant, safe, and the simplest approach for now.
  6982. The memory model parameter is a signed int, but only the lower 8 bits are
  6983. reserved for the memory model. The remainder of the signed int is reserved
  6984. for future use and should be 0. Use of the predefined atomic values
  6985. ensures proper usage.
  6986. @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
  6987. This built-in function implements an atomic load operation. It returns the
  6988. contents of @code{*@var{ptr}}.
  6989. The valid memory model variants are
  6990. @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
  6991. and @code{__ATOMIC_CONSUME}.
  6992. @end deftypefn
  6993. @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
  6994. This is the generic version of an atomic load. It returns the
  6995. contents of @code{*@var{ptr}} in @code{*@var{ret}}.
  6996. @end deftypefn
  6997. @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
  6998. This built-in function implements an atomic store operation. It writes
  6999. @code{@var{val}} into @code{*@var{ptr}}.
  7000. The valid memory model variants are
  7001. @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
  7002. @end deftypefn
  7003. @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
  7004. This is the generic version of an atomic store. It stores the value
  7005. of @code{*@var{val}} into @code{*@var{ptr}}.
  7006. @end deftypefn
  7007. @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
  7008. This built-in function implements an atomic exchange operation. It writes
  7009. @var{val} into @code{*@var{ptr}}, and returns the previous contents of
  7010. @code{*@var{ptr}}.
  7011. The valid memory model variants are
  7012. @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
  7013. @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
  7014. @end deftypefn
  7015. @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
  7016. This is the generic version of an atomic exchange. It stores the
  7017. contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
  7018. of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
  7019. @end deftypefn
  7020. @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memmodel, int failure_memmodel)
  7021. This built-in function implements an atomic compare and exchange operation.
  7022. This compares the contents of @code{*@var{ptr}} with the contents of
  7023. @code{*@var{expected}} and if equal, writes @var{desired} into
  7024. @code{*@var{ptr}}. If they are not equal, the current contents of
  7025. @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
  7026. for weak compare_exchange, and false for the strong variation. Many targets
  7027. only offer the strong variation and ignore the parameter. When in doubt, use
  7028. the strong variation.
  7029. True is returned if @var{desired} is written into
  7030. @code{*@var{ptr}} and the execution is considered to conform to the
  7031. memory model specified by @var{success_memmodel}. There are no
  7032. restrictions on what memory model can be used here.
  7033. False is returned otherwise, and the execution is considered to conform
  7034. to @var{failure_memmodel}. This memory model cannot be
  7035. @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
  7036. stronger model than that specified by @var{success_memmodel}.
  7037. @end deftypefn
  7038. @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memmodel, int failure_memmodel)
  7039. This built-in function implements the generic version of
  7040. @code{__atomic_compare_exchange}. The function is virtually identical to
  7041. @code{__atomic_compare_exchange_n}, except the desired value is also a
  7042. pointer.
  7043. @end deftypefn
  7044. @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
  7045. @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
  7046. @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
  7047. @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
  7048. @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
  7049. @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
  7050. These built-in functions perform the operation suggested by the name, and
  7051. return the result of the operation. That is,
  7052. @smallexample
  7053. @{ *ptr @var{op}= val; return *ptr; @}
  7054. @end smallexample
  7055. All memory models are valid.
  7056. @end deftypefn
  7057. @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
  7058. @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
  7059. @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
  7060. @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
  7061. @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
  7062. @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
  7063. These built-in functions perform the operation suggested by the name, and
  7064. return the value that had previously been in @code{*@var{ptr}}. That is,
  7065. @smallexample
  7066. @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
  7067. @end smallexample
  7068. All memory models are valid.
  7069. @end deftypefn
  7070. @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
  7071. This built-in function performs an atomic test-and-set operation on
  7072. the byte at @code{*@var{ptr}}. The byte is set to some implementation
  7073. defined nonzero ``set'' value and the return value is @code{true} if and only
  7074. if the previous contents were ``set''.
  7075. It should be only used for operands of type @code{bool} or @code{char}. For
  7076. other types only part of the value may be set.
  7077. All memory models are valid.
  7078. @end deftypefn
  7079. @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
  7080. This built-in function performs an atomic clear operation on
  7081. @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
  7082. It should be only used for operands of type @code{bool} or @code{char} and
  7083. in conjunction with @code{__atomic_test_and_set}.
  7084. For other types it may only clear partially. If the type is not @code{bool}
  7085. prefer using @code{__atomic_store}.
  7086. The valid memory model variants are
  7087. @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
  7088. @code{__ATOMIC_RELEASE}.
  7089. @end deftypefn
  7090. @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
  7091. This built-in function acts as a synchronization fence between threads
  7092. based on the specified memory model.
  7093. All memory orders are valid.
  7094. @end deftypefn
  7095. @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
  7096. This built-in function acts as a synchronization fence between a thread
  7097. and signal handlers based in the same thread.
  7098. All memory orders are valid.
  7099. @end deftypefn
  7100. @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
  7101. This built-in function returns true if objects of @var{size} bytes always
  7102. generate lock free atomic instructions for the target architecture.
  7103. @var{size} must resolve to a compile-time constant and the result also
  7104. resolves to a compile-time constant.
  7105. @var{ptr} is an optional pointer to the object that may be used to determine
  7106. alignment. A value of 0 indicates typical alignment should be used. The
  7107. compiler may also ignore this parameter.
  7108. @smallexample
  7109. if (_atomic_always_lock_free (sizeof (long long), 0))
  7110. @end smallexample
  7111. @end deftypefn
  7112. @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
  7113. This built-in function returns true if objects of @var{size} bytes always
  7114. generate lock free atomic instructions for the target architecture. If
  7115. it is not known to be lock free a call is made to a runtime routine named
  7116. @code{__atomic_is_lock_free}.
  7117. @var{ptr} is an optional pointer to the object that may be used to determine
  7118. alignment. A value of 0 indicates typical alignment should be used. The
  7119. compiler may also ignore this parameter.
  7120. @end deftypefn
  7121. @node Integer Overflow Builtins
  7122. @section Built-in Functions to Perform Arithmetic with Overflow Checking
  7123. The following built-in functions allow performing simple arithmetic operations
  7124. together with checking whether the operations overflowed.
  7125. @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
  7126. @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
  7127. @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
  7128. @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
  7129. @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
  7130. @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
  7131. @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
  7132. These built-in functions promote the first two operands into infinite precision signed
  7133. type and perform addition on those promoted operands. The result is then
  7134. cast to the type the third pointer argument points to and stored there.
  7135. If the stored result is equal to the infinite precision result, the built-in
  7136. functions return false, otherwise they return true. As the addition is
  7137. performed in infinite signed precision, these built-in functions have fully defined
  7138. behavior for all argument values.
  7139. The first built-in function allows arbitrary integral types for operands and
  7140. the result type must be pointer to some integer type, the rest of the built-in
  7141. functions have explicit integer types.
  7142. The compiler will attempt to use hardware instructions to implement
  7143. these built-in functions where possible, like conditional jump on overflow
  7144. after addition, conditional jump on carry etc.
  7145. @end deftypefn
  7146. @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
  7147. @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
  7148. @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
  7149. @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
  7150. @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
  7151. @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
  7152. @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
  7153. These built-in functions are similar to the add overflow checking built-in
  7154. functions above, except they perform subtraction, subtract the second argument
  7155. from the first one, instead of addition.
  7156. @end deftypefn
  7157. @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
  7158. @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
  7159. @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
  7160. @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
  7161. @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
  7162. @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
  7163. @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
  7164. These built-in functions are similar to the add overflow checking built-in
  7165. functions above, except they perform multiplication, instead of addition.
  7166. @end deftypefn
  7167. @node x86 specific memory model extensions for transactional memory
  7168. @section x86-Specific Memory Model Extensions for Transactional Memory
  7169. The x86 architecture supports additional memory ordering flags
  7170. to mark lock critical sections for hardware lock elision.
  7171. These must be specified in addition to an existing memory model to
  7172. atomic intrinsics.
  7173. @table @code
  7174. @item __ATOMIC_HLE_ACQUIRE
  7175. Start lock elision on a lock variable.
  7176. Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
  7177. @item __ATOMIC_HLE_RELEASE
  7178. End lock elision on a lock variable.
  7179. Memory model must be @code{__ATOMIC_RELEASE} or stronger.
  7180. @end table
  7181. When a lock acquire fails it is required for good performance to abort
  7182. the transaction quickly. This can be done with a @code{_mm_pause}
  7183. @smallexample
  7184. #include <immintrin.h> // For _mm_pause
  7185. int lockvar;
  7186. /* Acquire lock with lock elision */
  7187. while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
  7188. _mm_pause(); /* Abort failed transaction */
  7189. ...
  7190. /* Free lock with lock elision */
  7191. __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
  7192. @end smallexample
  7193. @node Object Size Checking
  7194. @section Object Size Checking Built-in Functions
  7195. @findex __builtin_object_size
  7196. @findex __builtin___memcpy_chk
  7197. @findex __builtin___mempcpy_chk
  7198. @findex __builtin___memmove_chk
  7199. @findex __builtin___memset_chk
  7200. @findex __builtin___strcpy_chk
  7201. @findex __builtin___stpcpy_chk
  7202. @findex __builtin___strncpy_chk
  7203. @findex __builtin___strcat_chk
  7204. @findex __builtin___strncat_chk
  7205. @findex __builtin___sprintf_chk
  7206. @findex __builtin___snprintf_chk
  7207. @findex __builtin___vsprintf_chk
  7208. @findex __builtin___vsnprintf_chk
  7209. @findex __builtin___printf_chk
  7210. @findex __builtin___vprintf_chk
  7211. @findex __builtin___fprintf_chk
  7212. @findex __builtin___vfprintf_chk
  7213. GCC implements a limited buffer overflow protection mechanism
  7214. that can prevent some buffer overflow attacks.
  7215. @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
  7216. is a built-in construct that returns a constant number of bytes from
  7217. @var{ptr} to the end of the object @var{ptr} pointer points to
  7218. (if known at compile time). @code{__builtin_object_size} never evaluates
  7219. its arguments for side-effects. If there are any side-effects in them, it
  7220. returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
  7221. for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
  7222. point to and all of them are known at compile time, the returned number
  7223. is the maximum of remaining byte counts in those objects if @var{type} & 2 is
  7224. 0 and minimum if nonzero. If it is not possible to determine which objects
  7225. @var{ptr} points to at compile time, @code{__builtin_object_size} should
  7226. return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
  7227. for @var{type} 2 or 3.
  7228. @var{type} is an integer constant from 0 to 3. If the least significant
  7229. bit is clear, objects are whole variables, if it is set, a closest
  7230. surrounding subobject is considered the object a pointer points to.
  7231. The second bit determines if maximum or minimum of remaining bytes
  7232. is computed.
  7233. @smallexample
  7234. struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
  7235. char *p = &var.buf1[1], *q = &var.b;
  7236. /* Here the object p points to is var. */
  7237. assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
  7238. /* The subobject p points to is var.buf1. */
  7239. assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
  7240. /* The object q points to is var. */
  7241. assert (__builtin_object_size (q, 0)
  7242. == (char *) (&var + 1) - (char *) &var.b);
  7243. /* The subobject q points to is var.b. */
  7244. assert (__builtin_object_size (q, 1) == sizeof (var.b));
  7245. @end smallexample
  7246. @end deftypefn
  7247. There are built-in functions added for many common string operation
  7248. functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
  7249. built-in is provided. This built-in has an additional last argument,
  7250. which is the number of bytes remaining in object the @var{dest}
  7251. argument points to or @code{(size_t) -1} if the size is not known.
  7252. The built-in functions are optimized into the normal string functions
  7253. like @code{memcpy} if the last argument is @code{(size_t) -1} or if
  7254. it is known at compile time that the destination object will not
  7255. be overflown. If the compiler can determine at compile time the
  7256. object will be always overflown, it issues a warning.
  7257. The intended use can be e.g.@:
  7258. @smallexample
  7259. #undef memcpy
  7260. #define bos0(dest) __builtin_object_size (dest, 0)
  7261. #define memcpy(dest, src, n) \
  7262. __builtin___memcpy_chk (dest, src, n, bos0 (dest))
  7263. char *volatile p;
  7264. char buf[10];
  7265. /* It is unknown what object p points to, so this is optimized
  7266. into plain memcpy - no checking is possible. */
  7267. memcpy (p, "abcde", n);
  7268. /* Destination is known and length too. It is known at compile
  7269. time there will be no overflow. */
  7270. memcpy (&buf[5], "abcde", 5);
  7271. /* Destination is known, but the length is not known at compile time.
  7272. This will result in __memcpy_chk call that can check for overflow
  7273. at run time. */
  7274. memcpy (&buf[5], "abcde", n);
  7275. /* Destination is known and it is known at compile time there will
  7276. be overflow. There will be a warning and __memcpy_chk call that
  7277. will abort the program at run time. */
  7278. memcpy (&buf[6], "abcde", 5);
  7279. @end smallexample
  7280. Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
  7281. @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
  7282. @code{strcat} and @code{strncat}.
  7283. There are also checking built-in functions for formatted output functions.
  7284. @smallexample
  7285. int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
  7286. int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
  7287. const char *fmt, ...);
  7288. int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
  7289. va_list ap);
  7290. int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
  7291. const char *fmt, va_list ap);
  7292. @end smallexample
  7293. The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
  7294. etc.@: functions and can contain implementation specific flags on what
  7295. additional security measures the checking function might take, such as
  7296. handling @code{%n} differently.
  7297. The @var{os} argument is the object size @var{s} points to, like in the
  7298. other built-in functions. There is a small difference in the behavior
  7299. though, if @var{os} is @code{(size_t) -1}, the built-in functions are
  7300. optimized into the non-checking functions only if @var{flag} is 0, otherwise
  7301. the checking function is called with @var{os} argument set to
  7302. @code{(size_t) -1}.
  7303. In addition to this, there are checking built-in functions
  7304. @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
  7305. @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
  7306. These have just one additional argument, @var{flag}, right before
  7307. format string @var{fmt}. If the compiler is able to optimize them to
  7308. @code{fputc} etc.@: functions, it does, otherwise the checking function
  7309. is called and the @var{flag} argument passed to it.
  7310. @node Pointer Bounds Checker builtins
  7311. @section Pointer Bounds Checker Built-in Functions
  7312. @cindex Pointer Bounds Checker builtins
  7313. @findex __builtin___bnd_set_ptr_bounds
  7314. @findex __builtin___bnd_narrow_ptr_bounds
  7315. @findex __builtin___bnd_copy_ptr_bounds
  7316. @findex __builtin___bnd_init_ptr_bounds
  7317. @findex __builtin___bnd_null_ptr_bounds
  7318. @findex __builtin___bnd_store_ptr_bounds
  7319. @findex __builtin___bnd_chk_ptr_lbounds
  7320. @findex __builtin___bnd_chk_ptr_ubounds
  7321. @findex __builtin___bnd_chk_ptr_bounds
  7322. @findex __builtin___bnd_get_ptr_lbound
  7323. @findex __builtin___bnd_get_ptr_ubound
  7324. GCC provides a set of built-in functions to control Pointer Bounds Checker
  7325. instrumentation. Note that all Pointer Bounds Checker builtins can be used
  7326. even if you compile with Pointer Bounds Checker off
  7327. (@option{-fno-check-pointer-bounds}).
  7328. The behavior may differ in such case as documented below.
  7329. @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
  7330. This built-in function returns a new pointer with the value of @var{q}, and
  7331. associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
  7332. Bounds Checker off, the built-in function just returns the first argument.
  7333. @smallexample
  7334. extern void *__wrap_malloc (size_t n)
  7335. @{
  7336. void *p = (void *)__real_malloc (n);
  7337. if (!p) return __builtin___bnd_null_ptr_bounds (p);
  7338. return __builtin___bnd_set_ptr_bounds (p, n);
  7339. @}
  7340. @end smallexample
  7341. @end deftypefn
  7342. @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
  7343. This built-in function returns a new pointer with the value of @var{p}
  7344. and associates it with the narrowed bounds formed by the intersection
  7345. of bounds associated with @var{q} and the bounds
  7346. [@var{p}, @var{p} + @var{size} - 1].
  7347. With Pointer Bounds Checker off, the built-in function just returns the first
  7348. argument.
  7349. @smallexample
  7350. void init_objects (object *objs, size_t size)
  7351. @{
  7352. size_t i;
  7353. /* Initialize objects one-by-one passing pointers with bounds of
  7354. an object, not the full array of objects. */
  7355. for (i = 0; i < size; i++)
  7356. init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
  7357. sizeof(object)));
  7358. @}
  7359. @end smallexample
  7360. @end deftypefn
  7361. @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
  7362. This built-in function returns a new pointer with the value of @var{q},
  7363. and associates it with the bounds already associated with pointer @var{r}.
  7364. With Pointer Bounds Checker off, the built-in function just returns the first
  7365. argument.
  7366. @smallexample
  7367. /* Here is a way to get pointer to object's field but
  7368. still with the full object's bounds. */
  7369. int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
  7370. objptr);
  7371. @end smallexample
  7372. @end deftypefn
  7373. @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
  7374. This built-in function returns a new pointer with the value of @var{q}, and
  7375. associates it with INIT (allowing full memory access) bounds. With Pointer
  7376. Bounds Checker off, the built-in function just returns the first argument.
  7377. @end deftypefn
  7378. @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
  7379. This built-in function returns a new pointer with the value of @var{q}, and
  7380. associates it with NULL (allowing no memory access) bounds. With Pointer
  7381. Bounds Checker off, the built-in function just returns the first argument.
  7382. @end deftypefn
  7383. @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
  7384. This built-in function stores the bounds associated with pointer @var{ptr_val}
  7385. and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
  7386. bounds from legacy code without touching the associated pointer's memory when
  7387. pointers are copied as integers. With Pointer Bounds Checker off, the built-in
  7388. function call is ignored.
  7389. @end deftypefn
  7390. @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
  7391. This built-in function checks if the pointer @var{q} is within the lower
  7392. bound of its associated bounds. With Pointer Bounds Checker off, the built-in
  7393. function call is ignored.
  7394. @smallexample
  7395. extern void *__wrap_memset (void *dst, int c, size_t len)
  7396. @{
  7397. if (len > 0)
  7398. @{
  7399. __builtin___bnd_chk_ptr_lbounds (dst);
  7400. __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
  7401. __real_memset (dst, c, len);
  7402. @}
  7403. return dst;
  7404. @}
  7405. @end smallexample
  7406. @end deftypefn
  7407. @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
  7408. This built-in function checks if the pointer @var{q} is within the upper
  7409. bound of its associated bounds. With Pointer Bounds Checker off, the built-in
  7410. function call is ignored.
  7411. @end deftypefn
  7412. @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
  7413. This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
  7414. the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
  7415. off, the built-in function call is ignored.
  7416. @smallexample
  7417. extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
  7418. @{
  7419. if (n > 0)
  7420. @{
  7421. __bnd_chk_ptr_bounds (dst, n);
  7422. __bnd_chk_ptr_bounds (src, n);
  7423. __real_memcpy (dst, src, n);
  7424. @}
  7425. return dst;
  7426. @}
  7427. @end smallexample
  7428. @end deftypefn
  7429. @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
  7430. This built-in function returns the lower bound associated
  7431. with the pointer @var{q}, as a pointer value.
  7432. This is useful for debugging using @code{printf}.
  7433. With Pointer Bounds Checker off, the built-in function returns 0.
  7434. @smallexample
  7435. void *lb = __builtin___bnd_get_ptr_lbound (q);
  7436. void *ub = __builtin___bnd_get_ptr_ubound (q);
  7437. printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
  7438. @end smallexample
  7439. @end deftypefn
  7440. @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
  7441. This built-in function returns the upper bound (which is a pointer) associated
  7442. with the pointer @var{q}. With Pointer Bounds Checker off,
  7443. the built-in function returns -1.
  7444. @end deftypefn
  7445. @node Cilk Plus Builtins
  7446. @section Cilk Plus C/C++ Language Extension Built-in Functions
  7447. GCC provides support for the following built-in reduction functions if Cilk Plus
  7448. is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
  7449. @itemize @bullet
  7450. @item @code{__sec_implicit_index}
  7451. @item @code{__sec_reduce}
  7452. @item @code{__sec_reduce_add}
  7453. @item @code{__sec_reduce_all_nonzero}
  7454. @item @code{__sec_reduce_all_zero}
  7455. @item @code{__sec_reduce_any_nonzero}
  7456. @item @code{__sec_reduce_any_zero}
  7457. @item @code{__sec_reduce_max}
  7458. @item @code{__sec_reduce_min}
  7459. @item @code{__sec_reduce_max_ind}
  7460. @item @code{__sec_reduce_min_ind}
  7461. @item @code{__sec_reduce_mul}
  7462. @item @code{__sec_reduce_mutating}
  7463. @end itemize
  7464. Further details and examples about these built-in functions are described
  7465. in the Cilk Plus language manual which can be found at
  7466. @uref{http://www.cilkplus.org}.
  7467. @node Other Builtins
  7468. @section Other Built-in Functions Provided by GCC
  7469. @cindex built-in functions
  7470. @findex __builtin_call_with_static_chain
  7471. @findex __builtin_fpclassify
  7472. @findex __builtin_isfinite
  7473. @findex __builtin_isnormal
  7474. @findex __builtin_isgreater
  7475. @findex __builtin_isgreaterequal
  7476. @findex __builtin_isinf_sign
  7477. @findex __builtin_isless
  7478. @findex __builtin_islessequal
  7479. @findex __builtin_islessgreater
  7480. @findex __builtin_isunordered
  7481. @findex __builtin_powi
  7482. @findex __builtin_powif
  7483. @findex __builtin_powil
  7484. @findex _Exit
  7485. @findex _exit
  7486. @findex abort
  7487. @findex abs
  7488. @findex acos
  7489. @findex acosf
  7490. @findex acosh
  7491. @findex acoshf
  7492. @findex acoshl
  7493. @findex acosl
  7494. @findex alloca
  7495. @findex asin
  7496. @findex asinf
  7497. @findex asinh
  7498. @findex asinhf
  7499. @findex asinhl
  7500. @findex asinl
  7501. @findex atan
  7502. @findex atan2
  7503. @findex atan2f
  7504. @findex atan2l
  7505. @findex atanf
  7506. @findex atanh
  7507. @findex atanhf
  7508. @findex atanhl
  7509. @findex atanl
  7510. @findex bcmp
  7511. @findex bzero
  7512. @findex cabs
  7513. @findex cabsf
  7514. @findex cabsl
  7515. @findex cacos
  7516. @findex cacosf
  7517. @findex cacosh
  7518. @findex cacoshf
  7519. @findex cacoshl
  7520. @findex cacosl
  7521. @findex calloc
  7522. @findex carg
  7523. @findex cargf
  7524. @findex cargl
  7525. @findex casin
  7526. @findex casinf
  7527. @findex casinh
  7528. @findex casinhf
  7529. @findex casinhl
  7530. @findex casinl
  7531. @findex catan
  7532. @findex catanf
  7533. @findex catanh
  7534. @findex catanhf
  7535. @findex catanhl
  7536. @findex catanl
  7537. @findex cbrt
  7538. @findex cbrtf
  7539. @findex cbrtl
  7540. @findex ccos
  7541. @findex ccosf
  7542. @findex ccosh
  7543. @findex ccoshf
  7544. @findex ccoshl
  7545. @findex ccosl
  7546. @findex ceil
  7547. @findex ceilf
  7548. @findex ceill
  7549. @findex cexp
  7550. @findex cexpf
  7551. @findex cexpl
  7552. @findex cimag
  7553. @findex cimagf
  7554. @findex cimagl
  7555. @findex clog
  7556. @findex clogf
  7557. @findex clogl
  7558. @findex conj
  7559. @findex conjf
  7560. @findex conjl
  7561. @findex copysign
  7562. @findex copysignf
  7563. @findex copysignl
  7564. @findex cos
  7565. @findex cosf
  7566. @findex cosh
  7567. @findex coshf
  7568. @findex coshl
  7569. @findex cosl
  7570. @findex cpow
  7571. @findex cpowf
  7572. @findex cpowl
  7573. @findex cproj
  7574. @findex cprojf
  7575. @findex cprojl
  7576. @findex creal
  7577. @findex crealf
  7578. @findex creall
  7579. @findex csin
  7580. @findex csinf
  7581. @findex csinh
  7582. @findex csinhf
  7583. @findex csinhl
  7584. @findex csinl
  7585. @findex csqrt
  7586. @findex csqrtf
  7587. @findex csqrtl
  7588. @findex ctan
  7589. @findex ctanf
  7590. @findex ctanh
  7591. @findex ctanhf
  7592. @findex ctanhl
  7593. @findex ctanl
  7594. @findex dcgettext
  7595. @findex dgettext
  7596. @findex drem
  7597. @findex dremf
  7598. @findex dreml
  7599. @findex erf
  7600. @findex erfc
  7601. @findex erfcf
  7602. @findex erfcl
  7603. @findex erff
  7604. @findex erfl
  7605. @findex exit
  7606. @findex exp
  7607. @findex exp10
  7608. @findex exp10f
  7609. @findex exp10l
  7610. @findex exp2
  7611. @findex exp2f
  7612. @findex exp2l
  7613. @findex expf
  7614. @findex expl
  7615. @findex expm1
  7616. @findex expm1f
  7617. @findex expm1l
  7618. @findex fabs
  7619. @findex fabsf
  7620. @findex fabsl
  7621. @findex fdim
  7622. @findex fdimf
  7623. @findex fdiml
  7624. @findex ffs
  7625. @findex floor
  7626. @findex floorf
  7627. @findex floorl
  7628. @findex fma
  7629. @findex fmaf
  7630. @findex fmal
  7631. @findex fmax
  7632. @findex fmaxf
  7633. @findex fmaxl
  7634. @findex fmin
  7635. @findex fminf
  7636. @findex fminl
  7637. @findex fmod
  7638. @findex fmodf
  7639. @findex fmodl
  7640. @findex fprintf
  7641. @findex fprintf_unlocked
  7642. @findex fputs
  7643. @findex fputs_unlocked
  7644. @findex frexp
  7645. @findex frexpf
  7646. @findex frexpl
  7647. @findex fscanf
  7648. @findex gamma
  7649. @findex gammaf
  7650. @findex gammal
  7651. @findex gamma_r
  7652. @findex gammaf_r
  7653. @findex gammal_r
  7654. @findex gettext
  7655. @findex hypot
  7656. @findex hypotf
  7657. @findex hypotl
  7658. @findex ilogb
  7659. @findex ilogbf
  7660. @findex ilogbl
  7661. @findex imaxabs
  7662. @findex index
  7663. @findex isalnum
  7664. @findex isalpha
  7665. @findex isascii
  7666. @findex isblank
  7667. @findex iscntrl
  7668. @findex isdigit
  7669. @findex isgraph
  7670. @findex islower
  7671. @findex isprint
  7672. @findex ispunct
  7673. @findex isspace
  7674. @findex isupper
  7675. @findex iswalnum
  7676. @findex iswalpha
  7677. @findex iswblank
  7678. @findex iswcntrl
  7679. @findex iswdigit
  7680. @findex iswgraph
  7681. @findex iswlower
  7682. @findex iswprint
  7683. @findex iswpunct
  7684. @findex iswspace
  7685. @findex iswupper
  7686. @findex iswxdigit
  7687. @findex isxdigit
  7688. @findex j0
  7689. @findex j0f
  7690. @findex j0l
  7691. @findex j1
  7692. @findex j1f
  7693. @findex j1l
  7694. @findex jn
  7695. @findex jnf
  7696. @findex jnl
  7697. @findex labs
  7698. @findex ldexp
  7699. @findex ldexpf
  7700. @findex ldexpl
  7701. @findex lgamma
  7702. @findex lgammaf
  7703. @findex lgammal
  7704. @findex lgamma_r
  7705. @findex lgammaf_r
  7706. @findex lgammal_r
  7707. @findex llabs
  7708. @findex llrint
  7709. @findex llrintf
  7710. @findex llrintl
  7711. @findex llround
  7712. @findex llroundf
  7713. @findex llroundl
  7714. @findex log
  7715. @findex log10
  7716. @findex log10f
  7717. @findex log10l
  7718. @findex log1p
  7719. @findex log1pf
  7720. @findex log1pl
  7721. @findex log2
  7722. @findex log2f
  7723. @findex log2l
  7724. @findex logb
  7725. @findex logbf
  7726. @findex logbl
  7727. @findex logf
  7728. @findex logl
  7729. @findex lrint
  7730. @findex lrintf
  7731. @findex lrintl
  7732. @findex lround
  7733. @findex lroundf
  7734. @findex lroundl
  7735. @findex malloc
  7736. @findex memchr
  7737. @findex memcmp
  7738. @findex memcpy
  7739. @findex mempcpy
  7740. @findex memset
  7741. @findex modf
  7742. @findex modff
  7743. @findex modfl
  7744. @findex nearbyint
  7745. @findex nearbyintf
  7746. @findex nearbyintl
  7747. @findex nextafter
  7748. @findex nextafterf
  7749. @findex nextafterl
  7750. @findex nexttoward
  7751. @findex nexttowardf
  7752. @findex nexttowardl
  7753. @findex pow
  7754. @findex pow10
  7755. @findex pow10f
  7756. @findex pow10l
  7757. @findex powf
  7758. @findex powl
  7759. @findex printf
  7760. @findex printf_unlocked
  7761. @findex putchar
  7762. @findex puts
  7763. @findex remainder
  7764. @findex remainderf
  7765. @findex remainderl
  7766. @findex remquo
  7767. @findex remquof
  7768. @findex remquol
  7769. @findex rindex
  7770. @findex rint
  7771. @findex rintf
  7772. @findex rintl
  7773. @findex round
  7774. @findex roundf
  7775. @findex roundl
  7776. @findex scalb
  7777. @findex scalbf
  7778. @findex scalbl
  7779. @findex scalbln
  7780. @findex scalblnf
  7781. @findex scalblnf
  7782. @findex scalbn
  7783. @findex scalbnf
  7784. @findex scanfnl
  7785. @findex signbit
  7786. @findex signbitf
  7787. @findex signbitl
  7788. @findex signbitd32
  7789. @findex signbitd64
  7790. @findex signbitd128
  7791. @findex significand
  7792. @findex significandf
  7793. @findex significandl
  7794. @findex sin
  7795. @findex sincos
  7796. @findex sincosf
  7797. @findex sincosl
  7798. @findex sinf
  7799. @findex sinh
  7800. @findex sinhf
  7801. @findex sinhl
  7802. @findex sinl
  7803. @findex snprintf
  7804. @findex sprintf
  7805. @findex sqrt
  7806. @findex sqrtf
  7807. @findex sqrtl
  7808. @findex sscanf
  7809. @findex stpcpy
  7810. @findex stpncpy
  7811. @findex strcasecmp
  7812. @findex strcat
  7813. @findex strchr
  7814. @findex strcmp
  7815. @findex strcpy
  7816. @findex strcspn
  7817. @findex strdup
  7818. @findex strfmon
  7819. @findex strftime
  7820. @findex strlen
  7821. @findex strncasecmp
  7822. @findex strncat
  7823. @findex strncmp
  7824. @findex strncpy
  7825. @findex strndup
  7826. @findex strpbrk
  7827. @findex strrchr
  7828. @findex strspn
  7829. @findex strstr
  7830. @findex tan
  7831. @findex tanf
  7832. @findex tanh
  7833. @findex tanhf
  7834. @findex tanhl
  7835. @findex tanl
  7836. @findex tgamma
  7837. @findex tgammaf
  7838. @findex tgammal
  7839. @findex toascii
  7840. @findex tolower
  7841. @findex toupper
  7842. @findex towlower
  7843. @findex towupper
  7844. @findex trunc
  7845. @findex truncf
  7846. @findex truncl
  7847. @findex vfprintf
  7848. @findex vfscanf
  7849. @findex vprintf
  7850. @findex vscanf
  7851. @findex vsnprintf
  7852. @findex vsprintf
  7853. @findex vsscanf
  7854. @findex y0
  7855. @findex y0f
  7856. @findex y0l
  7857. @findex y1
  7858. @findex y1f
  7859. @findex y1l
  7860. @findex yn
  7861. @findex ynf
  7862. @findex ynl
  7863. GCC provides a large number of built-in functions other than the ones
  7864. mentioned above. Some of these are for internal use in the processing
  7865. of exceptions or variable-length argument lists and are not
  7866. documented here because they may change from time to time; we do not
  7867. recommend general use of these functions.
  7868. The remaining functions are provided for optimization purposes.
  7869. @opindex fno-builtin
  7870. GCC includes built-in versions of many of the functions in the standard
  7871. C library. The versions prefixed with @code{__builtin_} are always
  7872. treated as having the same meaning as the C library function even if you
  7873. specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
  7874. Many of these functions are only optimized in certain cases; if they are
  7875. not optimized in a particular case, a call to the library function is
  7876. emitted.
  7877. @opindex ansi
  7878. @opindex std
  7879. Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
  7880. @option{-std=c99} or @option{-std=c11}), the functions
  7881. @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
  7882. @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
  7883. @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
  7884. @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
  7885. @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
  7886. @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
  7887. @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
  7888. @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
  7889. @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
  7890. @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
  7891. @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
  7892. @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
  7893. @code{signbitd64}, @code{signbitd128}, @code{significandf},
  7894. @code{significandl}, @code{significand}, @code{sincosf},
  7895. @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
  7896. @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
  7897. @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
  7898. @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
  7899. @code{yn}
  7900. may be handled as built-in functions.
  7901. All these functions have corresponding versions
  7902. prefixed with @code{__builtin_}, which may be used even in strict C90
  7903. mode.
  7904. The ISO C99 functions
  7905. @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
  7906. @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
  7907. @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
  7908. @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
  7909. @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
  7910. @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
  7911. @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
  7912. @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
  7913. @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
  7914. @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
  7915. @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
  7916. @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
  7917. @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
  7918. @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
  7919. @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
  7920. @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
  7921. @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
  7922. @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
  7923. @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
  7924. @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
  7925. @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
  7926. @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
  7927. @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
  7928. @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
  7929. @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
  7930. @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
  7931. @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
  7932. @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
  7933. @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
  7934. @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
  7935. @code{nextafterf}, @code{nextafterl}, @code{nextafter},
  7936. @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
  7937. @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
  7938. @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
  7939. @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
  7940. @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
  7941. @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
  7942. @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
  7943. @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
  7944. are handled as built-in functions
  7945. except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
  7946. There are also built-in versions of the ISO C99 functions
  7947. @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
  7948. @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
  7949. @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
  7950. @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
  7951. @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
  7952. @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
  7953. @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
  7954. @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
  7955. @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
  7956. that are recognized in any mode since ISO C90 reserves these names for
  7957. the purpose to which ISO C99 puts them. All these functions have
  7958. corresponding versions prefixed with @code{__builtin_}.
  7959. The ISO C94 functions
  7960. @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
  7961. @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
  7962. @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
  7963. @code{towupper}
  7964. are handled as built-in functions
  7965. except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
  7966. The ISO C90 functions
  7967. @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
  7968. @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
  7969. @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
  7970. @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
  7971. @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
  7972. @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
  7973. @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
  7974. @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
  7975. @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
  7976. @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
  7977. @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
  7978. @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
  7979. @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
  7980. @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
  7981. @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
  7982. @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
  7983. are all recognized as built-in functions unless
  7984. @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
  7985. is specified for an individual function). All of these functions have
  7986. corresponding versions prefixed with @code{__builtin_}.
  7987. GCC provides built-in versions of the ISO C99 floating-point comparison
  7988. macros that avoid raising exceptions for unordered operands. They have
  7989. the same names as the standard macros ( @code{isgreater},
  7990. @code{isgreaterequal}, @code{isless}, @code{islessequal},
  7991. @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
  7992. prefixed. We intend for a library implementor to be able to simply
  7993. @code{#define} each standard macro to its built-in equivalent.
  7994. In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
  7995. @code{isinf_sign} and @code{isnormal} built-ins used with
  7996. @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
  7997. built-in functions appear both with and without the @code{__builtin_} prefix.
  7998. @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
  7999. You can use the built-in function @code{__builtin_types_compatible_p} to
  8000. determine whether two types are the same.
  8001. This built-in function returns 1 if the unqualified versions of the
  8002. types @var{type1} and @var{type2} (which are types, not expressions) are
  8003. compatible, 0 otherwise. The result of this built-in function can be
  8004. used in integer constant expressions.
  8005. This built-in function ignores top level qualifiers (e.g., @code{const},
  8006. @code{volatile}). For example, @code{int} is equivalent to @code{const
  8007. int}.
  8008. The type @code{int[]} and @code{int[5]} are compatible. On the other
  8009. hand, @code{int} and @code{char *} are not compatible, even if the size
  8010. of their types, on the particular architecture are the same. Also, the
  8011. amount of pointer indirection is taken into account when determining
  8012. similarity. Consequently, @code{short *} is not similar to
  8013. @code{short **}. Furthermore, two types that are typedefed are
  8014. considered compatible if their underlying types are compatible.
  8015. An @code{enum} type is not considered to be compatible with another
  8016. @code{enum} type even if both are compatible with the same integer
  8017. type; this is what the C standard specifies.
  8018. For example, @code{enum @{foo, bar@}} is not similar to
  8019. @code{enum @{hot, dog@}}.
  8020. You typically use this function in code whose execution varies
  8021. depending on the arguments' types. For example:
  8022. @smallexample
  8023. #define foo(x) \
  8024. (@{ \
  8025. typeof (x) tmp = (x); \
  8026. if (__builtin_types_compatible_p (typeof (x), long double)) \
  8027. tmp = foo_long_double (tmp); \
  8028. else if (__builtin_types_compatible_p (typeof (x), double)) \
  8029. tmp = foo_double (tmp); \
  8030. else if (__builtin_types_compatible_p (typeof (x), float)) \
  8031. tmp = foo_float (tmp); \
  8032. else \
  8033. abort (); \
  8034. tmp; \
  8035. @})
  8036. @end smallexample
  8037. @emph{Note:} This construct is only available for C@.
  8038. @end deftypefn
  8039. @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
  8040. The @var{call_exp} expression must be a function call, and the
  8041. @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
  8042. is passed to the function call in the target's static chain location.
  8043. The result of builtin is the result of the function call.
  8044. @emph{Note:} This builtin is only available for C@.
  8045. This builtin can be used to call Go closures from C.
  8046. @end deftypefn
  8047. @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
  8048. You can use the built-in function @code{__builtin_choose_expr} to
  8049. evaluate code depending on the value of a constant expression. This
  8050. built-in function returns @var{exp1} if @var{const_exp}, which is an
  8051. integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
  8052. This built-in function is analogous to the @samp{? :} operator in C,
  8053. except that the expression returned has its type unaltered by promotion
  8054. rules. Also, the built-in function does not evaluate the expression
  8055. that is not chosen. For example, if @var{const_exp} evaluates to true,
  8056. @var{exp2} is not evaluated even if it has side-effects.
  8057. This built-in function can return an lvalue if the chosen argument is an
  8058. lvalue.
  8059. If @var{exp1} is returned, the return type is the same as @var{exp1}'s
  8060. type. Similarly, if @var{exp2} is returned, its return type is the same
  8061. as @var{exp2}.
  8062. Example:
  8063. @smallexample
  8064. #define foo(x) \
  8065. __builtin_choose_expr ( \
  8066. __builtin_types_compatible_p (typeof (x), double), \
  8067. foo_double (x), \
  8068. __builtin_choose_expr ( \
  8069. __builtin_types_compatible_p (typeof (x), float), \
  8070. foo_float (x), \
  8071. /* @r{The void expression results in a compile-time error} \
  8072. @r{when assigning the result to something.} */ \
  8073. (void)0))
  8074. @end smallexample
  8075. @emph{Note:} This construct is only available for C@. Furthermore, the
  8076. unused expression (@var{exp1} or @var{exp2} depending on the value of
  8077. @var{const_exp}) may still generate syntax errors. This may change in
  8078. future revisions.
  8079. @end deftypefn
  8080. @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
  8081. The built-in function @code{__builtin_complex} is provided for use in
  8082. implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
  8083. @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
  8084. real binary floating-point type, and the result has the corresponding
  8085. complex type with real and imaginary parts @var{real} and @var{imag}.
  8086. Unlike @samp{@var{real} + I * @var{imag}}, this works even when
  8087. infinities, NaNs and negative zeros are involved.
  8088. @end deftypefn
  8089. @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
  8090. You can use the built-in function @code{__builtin_constant_p} to
  8091. determine if a value is known to be constant at compile time and hence
  8092. that GCC can perform constant-folding on expressions involving that
  8093. value. The argument of the function is the value to test. The function
  8094. returns the integer 1 if the argument is known to be a compile-time
  8095. constant and 0 if it is not known to be a compile-time constant. A
  8096. return of 0 does not indicate that the value is @emph{not} a constant,
  8097. but merely that GCC cannot prove it is a constant with the specified
  8098. value of the @option{-O} option.
  8099. You typically use this function in an embedded application where
  8100. memory is a critical resource. If you have some complex calculation,
  8101. you may want it to be folded if it involves constants, but need to call
  8102. a function if it does not. For example:
  8103. @smallexample
  8104. #define Scale_Value(X) \
  8105. (__builtin_constant_p (X) \
  8106. ? ((X) * SCALE + OFFSET) : Scale (X))
  8107. @end smallexample
  8108. You may use this built-in function in either a macro or an inline
  8109. function. However, if you use it in an inlined function and pass an
  8110. argument of the function as the argument to the built-in, GCC
  8111. never returns 1 when you call the inline function with a string constant
  8112. or compound literal (@pxref{Compound Literals}) and does not return 1
  8113. when you pass a constant numeric value to the inline function unless you
  8114. specify the @option{-O} option.
  8115. You may also use @code{__builtin_constant_p} in initializers for static
  8116. data. For instance, you can write
  8117. @smallexample
  8118. static const int table[] = @{
  8119. __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
  8120. /* @r{@dots{}} */
  8121. @};
  8122. @end smallexample
  8123. @noindent
  8124. This is an acceptable initializer even if @var{EXPRESSION} is not a
  8125. constant expression, including the case where
  8126. @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
  8127. folded to a constant but @var{EXPRESSION} contains operands that are
  8128. not otherwise permitted in a static initializer (for example,
  8129. @code{0 && foo ()}). GCC must be more conservative about evaluating the
  8130. built-in in this case, because it has no opportunity to perform
  8131. optimization.
  8132. @end deftypefn
  8133. @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
  8134. @opindex fprofile-arcs
  8135. You may use @code{__builtin_expect} to provide the compiler with
  8136. branch prediction information. In general, you should prefer to
  8137. use actual profile feedback for this (@option{-fprofile-arcs}), as
  8138. programmers are notoriously bad at predicting how their programs
  8139. actually perform. However, there are applications in which this
  8140. data is hard to collect.
  8141. The return value is the value of @var{exp}, which should be an integral
  8142. expression. The semantics of the built-in are that it is expected that
  8143. @var{exp} == @var{c}. For example:
  8144. @smallexample
  8145. if (__builtin_expect (x, 0))
  8146. foo ();
  8147. @end smallexample
  8148. @noindent
  8149. indicates that we do not expect to call @code{foo}, since
  8150. we expect @code{x} to be zero. Since you are limited to integral
  8151. expressions for @var{exp}, you should use constructions such as
  8152. @smallexample
  8153. if (__builtin_expect (ptr != NULL, 1))
  8154. foo (*ptr);
  8155. @end smallexample
  8156. @noindent
  8157. when testing pointer or floating-point values.
  8158. @end deftypefn
  8159. @deftypefn {Built-in Function} void __builtin_trap (void)
  8160. This function causes the program to exit abnormally. GCC implements
  8161. this function by using a target-dependent mechanism (such as
  8162. intentionally executing an illegal instruction) or by calling
  8163. @code{abort}. The mechanism used may vary from release to release so
  8164. you should not rely on any particular implementation.
  8165. @end deftypefn
  8166. @deftypefn {Built-in Function} void __builtin_unreachable (void)
  8167. If control flow reaches the point of the @code{__builtin_unreachable},
  8168. the program is undefined. It is useful in situations where the
  8169. compiler cannot deduce the unreachability of the code.
  8170. One such case is immediately following an @code{asm} statement that
  8171. either never terminates, or one that transfers control elsewhere
  8172. and never returns. In this example, without the
  8173. @code{__builtin_unreachable}, GCC issues a warning that control
  8174. reaches the end of a non-void function. It also generates code
  8175. to return after the @code{asm}.
  8176. @smallexample
  8177. int f (int c, int v)
  8178. @{
  8179. if (c)
  8180. @{
  8181. return v;
  8182. @}
  8183. else
  8184. @{
  8185. asm("jmp error_handler");
  8186. __builtin_unreachable ();
  8187. @}
  8188. @}
  8189. @end smallexample
  8190. @noindent
  8191. Because the @code{asm} statement unconditionally transfers control out
  8192. of the function, control never reaches the end of the function
  8193. body. The @code{__builtin_unreachable} is in fact unreachable and
  8194. communicates this fact to the compiler.
  8195. Another use for @code{__builtin_unreachable} is following a call a
  8196. function that never returns but that is not declared
  8197. @code{__attribute__((noreturn))}, as in this example:
  8198. @smallexample
  8199. void function_that_never_returns (void);
  8200. int g (int c)
  8201. @{
  8202. if (c)
  8203. @{
  8204. return 1;
  8205. @}
  8206. else
  8207. @{
  8208. function_that_never_returns ();
  8209. __builtin_unreachable ();
  8210. @}
  8211. @}
  8212. @end smallexample
  8213. @end deftypefn
  8214. @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
  8215. This function returns its first argument, and allows the compiler
  8216. to assume that the returned pointer is at least @var{align} bytes
  8217. aligned. This built-in can have either two or three arguments,
  8218. if it has three, the third argument should have integer type, and
  8219. if it is nonzero means misalignment offset. For example:
  8220. @smallexample
  8221. void *x = __builtin_assume_aligned (arg, 16);
  8222. @end smallexample
  8223. @noindent
  8224. means that the compiler can assume @code{x}, set to @code{arg}, is at least
  8225. 16-byte aligned, while:
  8226. @smallexample
  8227. void *x = __builtin_assume_aligned (arg, 32, 8);
  8228. @end smallexample
  8229. @noindent
  8230. means that the compiler can assume for @code{x}, set to @code{arg}, that
  8231. @code{(char *) x - 8} is 32-byte aligned.
  8232. @end deftypefn
  8233. @deftypefn {Built-in Function} int __builtin_LINE ()
  8234. This function is the equivalent to the preprocessor @code{__LINE__}
  8235. macro and returns the line number of the invocation of the built-in.
  8236. In a C++ default argument for a function @var{F}, it gets the line number of
  8237. the call to @var{F}.
  8238. @end deftypefn
  8239. @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
  8240. This function is the equivalent to the preprocessor @code{__FUNCTION__}
  8241. macro and returns the function name the invocation of the built-in is in.
  8242. @end deftypefn
  8243. @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
  8244. This function is the equivalent to the preprocessor @code{__FILE__}
  8245. macro and returns the file name the invocation of the built-in is in.
  8246. In a C++ default argument for a function @var{F}, it gets the file name of
  8247. the call to @var{F}.
  8248. @end deftypefn
  8249. @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
  8250. This function is used to flush the processor's instruction cache for
  8251. the region of memory between @var{begin} inclusive and @var{end}
  8252. exclusive. Some targets require that the instruction cache be
  8253. flushed, after modifying memory containing code, in order to obtain
  8254. deterministic behavior.
  8255. If the target does not require instruction cache flushes,
  8256. @code{__builtin___clear_cache} has no effect. Otherwise either
  8257. instructions are emitted in-line to clear the instruction cache or a
  8258. call to the @code{__clear_cache} function in libgcc is made.
  8259. @end deftypefn
  8260. @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
  8261. This function is used to minimize cache-miss latency by moving data into
  8262. a cache before it is accessed.
  8263. You can insert calls to @code{__builtin_prefetch} into code for which
  8264. you know addresses of data in memory that is likely to be accessed soon.
  8265. If the target supports them, data prefetch instructions are generated.
  8266. If the prefetch is done early enough before the access then the data will
  8267. be in the cache by the time it is accessed.
  8268. The value of @var{addr} is the address of the memory to prefetch.
  8269. There are two optional arguments, @var{rw} and @var{locality}.
  8270. The value of @var{rw} is a compile-time constant one or zero; one
  8271. means that the prefetch is preparing for a write to the memory address
  8272. and zero, the default, means that the prefetch is preparing for a read.
  8273. The value @var{locality} must be a compile-time constant integer between
  8274. zero and three. A value of zero means that the data has no temporal
  8275. locality, so it need not be left in the cache after the access. A value
  8276. of three means that the data has a high degree of temporal locality and
  8277. should be left in all levels of cache possible. Values of one and two
  8278. mean, respectively, a low or moderate degree of temporal locality. The
  8279. default is three.
  8280. @smallexample
  8281. for (i = 0; i < n; i++)
  8282. @{
  8283. a[i] = a[i] + b[i];
  8284. __builtin_prefetch (&a[i+j], 1, 1);
  8285. __builtin_prefetch (&b[i+j], 0, 1);
  8286. /* @r{@dots{}} */
  8287. @}
  8288. @end smallexample
  8289. Data prefetch does not generate faults if @var{addr} is invalid, but
  8290. the address expression itself must be valid. For example, a prefetch
  8291. of @code{p->next} does not fault if @code{p->next} is not a valid
  8292. address, but evaluation faults if @code{p} is not a valid address.
  8293. If the target does not support data prefetch, the address expression
  8294. is evaluated if it includes side effects but no other code is generated
  8295. and GCC does not issue a warning.
  8296. @end deftypefn
  8297. @deftypefn {Built-in Function} double __builtin_huge_val (void)
  8298. Returns a positive infinity, if supported by the floating-point format,
  8299. else @code{DBL_MAX}. This function is suitable for implementing the
  8300. ISO C macro @code{HUGE_VAL}.
  8301. @end deftypefn
  8302. @deftypefn {Built-in Function} float __builtin_huge_valf (void)
  8303. Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
  8304. @end deftypefn
  8305. @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
  8306. Similar to @code{__builtin_huge_val}, except the return
  8307. type is @code{long double}.
  8308. @end deftypefn
  8309. @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
  8310. This built-in implements the C99 fpclassify functionality. The first
  8311. five int arguments should be the target library's notion of the
  8312. possible FP classes and are used for return values. They must be
  8313. constant values and they must appear in this order: @code{FP_NAN},
  8314. @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
  8315. @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
  8316. to classify. GCC treats the last argument as type-generic, which
  8317. means it does not do default promotion from float to double.
  8318. @end deftypefn
  8319. @deftypefn {Built-in Function} double __builtin_inf (void)
  8320. Similar to @code{__builtin_huge_val}, except a warning is generated
  8321. if the target floating-point format does not support infinities.
  8322. @end deftypefn
  8323. @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
  8324. Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
  8325. @end deftypefn
  8326. @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
  8327. Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
  8328. @end deftypefn
  8329. @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
  8330. Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
  8331. @end deftypefn
  8332. @deftypefn {Built-in Function} float __builtin_inff (void)
  8333. Similar to @code{__builtin_inf}, except the return type is @code{float}.
  8334. This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
  8335. @end deftypefn
  8336. @deftypefn {Built-in Function} {long double} __builtin_infl (void)
  8337. Similar to @code{__builtin_inf}, except the return
  8338. type is @code{long double}.
  8339. @end deftypefn
  8340. @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
  8341. Similar to @code{isinf}, except the return value is -1 for
  8342. an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
  8343. Note while the parameter list is an
  8344. ellipsis, this function only accepts exactly one floating-point
  8345. argument. GCC treats this parameter as type-generic, which means it
  8346. does not do default promotion from float to double.
  8347. @end deftypefn
  8348. @deftypefn {Built-in Function} double __builtin_nan (const char *str)
  8349. This is an implementation of the ISO C99 function @code{nan}.
  8350. Since ISO C99 defines this function in terms of @code{strtod}, which we
  8351. do not implement, a description of the parsing is in order. The string
  8352. is parsed as by @code{strtol}; that is, the base is recognized by
  8353. leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
  8354. in the significand such that the least significant bit of the number
  8355. is at the least significant bit of the significand. The number is
  8356. truncated to fit the significand field provided. The significand is
  8357. forced to be a quiet NaN@.
  8358. This function, if given a string literal all of which would have been
  8359. consumed by @code{strtol}, is evaluated early enough that it is considered a
  8360. compile-time constant.
  8361. @end deftypefn
  8362. @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
  8363. Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
  8364. @end deftypefn
  8365. @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
  8366. Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
  8367. @end deftypefn
  8368. @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
  8369. Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
  8370. @end deftypefn
  8371. @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
  8372. Similar to @code{__builtin_nan}, except the return type is @code{float}.
  8373. @end deftypefn
  8374. @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
  8375. Similar to @code{__builtin_nan}, except the return type is @code{long double}.
  8376. @end deftypefn
  8377. @deftypefn {Built-in Function} double __builtin_nans (const char *str)
  8378. Similar to @code{__builtin_nan}, except the significand is forced
  8379. to be a signaling NaN@. The @code{nans} function is proposed by
  8380. @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
  8381. @end deftypefn
  8382. @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
  8383. Similar to @code{__builtin_nans}, except the return type is @code{float}.
  8384. @end deftypefn
  8385. @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
  8386. Similar to @code{__builtin_nans}, except the return type is @code{long double}.
  8387. @end deftypefn
  8388. @deftypefn {Built-in Function} int __builtin_ffs (int x)
  8389. Returns one plus the index of the least significant 1-bit of @var{x}, or
  8390. if @var{x} is zero, returns zero.
  8391. @end deftypefn
  8392. @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
  8393. Returns the number of leading 0-bits in @var{x}, starting at the most
  8394. significant bit position. If @var{x} is 0, the result is undefined.
  8395. @end deftypefn
  8396. @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
  8397. Returns the number of trailing 0-bits in @var{x}, starting at the least
  8398. significant bit position. If @var{x} is 0, the result is undefined.
  8399. @end deftypefn
  8400. @deftypefn {Built-in Function} int __builtin_clrsb (int x)
  8401. Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
  8402. number of bits following the most significant bit that are identical
  8403. to it. There are no special cases for 0 or other values.
  8404. @end deftypefn
  8405. @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
  8406. Returns the number of 1-bits in @var{x}.
  8407. @end deftypefn
  8408. @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
  8409. Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
  8410. modulo 2.
  8411. @end deftypefn
  8412. @deftypefn {Built-in Function} int __builtin_ffsl (long)
  8413. Similar to @code{__builtin_ffs}, except the argument type is
  8414. @code{long}.
  8415. @end deftypefn
  8416. @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
  8417. Similar to @code{__builtin_clz}, except the argument type is
  8418. @code{unsigned long}.
  8419. @end deftypefn
  8420. @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
  8421. Similar to @code{__builtin_ctz}, except the argument type is
  8422. @code{unsigned long}.
  8423. @end deftypefn
  8424. @deftypefn {Built-in Function} int __builtin_clrsbl (long)
  8425. Similar to @code{__builtin_clrsb}, except the argument type is
  8426. @code{long}.
  8427. @end deftypefn
  8428. @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
  8429. Similar to @code{__builtin_popcount}, except the argument type is
  8430. @code{unsigned long}.
  8431. @end deftypefn
  8432. @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
  8433. Similar to @code{__builtin_parity}, except the argument type is
  8434. @code{unsigned long}.
  8435. @end deftypefn
  8436. @deftypefn {Built-in Function} int __builtin_ffsll (long long)
  8437. Similar to @code{__builtin_ffs}, except the argument type is
  8438. @code{long long}.
  8439. @end deftypefn
  8440. @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
  8441. Similar to @code{__builtin_clz}, except the argument type is
  8442. @code{unsigned long long}.
  8443. @end deftypefn
  8444. @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
  8445. Similar to @code{__builtin_ctz}, except the argument type is
  8446. @code{unsigned long long}.
  8447. @end deftypefn
  8448. @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
  8449. Similar to @code{__builtin_clrsb}, except the argument type is
  8450. @code{long long}.
  8451. @end deftypefn
  8452. @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
  8453. Similar to @code{__builtin_popcount}, except the argument type is
  8454. @code{unsigned long long}.
  8455. @end deftypefn
  8456. @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
  8457. Similar to @code{__builtin_parity}, except the argument type is
  8458. @code{unsigned long long}.
  8459. @end deftypefn
  8460. @deftypefn {Built-in Function} double __builtin_powi (double, int)
  8461. Returns the first argument raised to the power of the second. Unlike the
  8462. @code{pow} function no guarantees about precision and rounding are made.
  8463. @end deftypefn
  8464. @deftypefn {Built-in Function} float __builtin_powif (float, int)
  8465. Similar to @code{__builtin_powi}, except the argument and return types
  8466. are @code{float}.
  8467. @end deftypefn
  8468. @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
  8469. Similar to @code{__builtin_powi}, except the argument and return types
  8470. are @code{long double}.
  8471. @end deftypefn
  8472. @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
  8473. Returns @var{x} with the order of the bytes reversed; for example,
  8474. @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
  8475. exactly 8 bits.
  8476. @end deftypefn
  8477. @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
  8478. Similar to @code{__builtin_bswap16}, except the argument and return types
  8479. are 32 bit.
  8480. @end deftypefn
  8481. @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
  8482. Similar to @code{__builtin_bswap32}, except the argument and return types
  8483. are 64 bit.
  8484. @end deftypefn
  8485. @node Target Builtins
  8486. @section Built-in Functions Specific to Particular Target Machines
  8487. On some target machines, GCC supports many built-in functions specific
  8488. to those machines. Generally these generate calls to specific machine
  8489. instructions, but allow the compiler to schedule those calls.
  8490. @menu
  8491. * AArch64 Built-in Functions::
  8492. * Alpha Built-in Functions::
  8493. * Altera Nios II Built-in Functions::
  8494. * ARC Built-in Functions::
  8495. * ARC SIMD Built-in Functions::
  8496. * ARM iWMMXt Built-in Functions::
  8497. * ARM C Language Extensions (ACLE)::
  8498. * ARM Floating Point Status and Control Intrinsics::
  8499. * AVR Built-in Functions::
  8500. * Blackfin Built-in Functions::
  8501. * FR-V Built-in Functions::
  8502. * MIPS DSP Built-in Functions::
  8503. * MIPS Paired-Single Support::
  8504. * MIPS Loongson Built-in Functions::
  8505. * Other MIPS Built-in Functions::
  8506. * MSP430 Built-in Functions::
  8507. * NDS32 Built-in Functions::
  8508. * picoChip Built-in Functions::
  8509. * PowerPC Built-in Functions::
  8510. * PowerPC AltiVec/VSX Built-in Functions::
  8511. * PowerPC Hardware Transactional Memory Built-in Functions::
  8512. * RX Built-in Functions::
  8513. * S/390 System z Built-in Functions::
  8514. * SH Built-in Functions::
  8515. * SPARC VIS Built-in Functions::
  8516. * SPU Built-in Functions::
  8517. * TI C6X Built-in Functions::
  8518. * TILE-Gx Built-in Functions::
  8519. * TILEPro Built-in Functions::
  8520. * x86 Built-in Functions::
  8521. * x86 transactional memory intrinsics::
  8522. @end menu
  8523. @node AArch64 Built-in Functions
  8524. @subsection AArch64 Built-in Functions
  8525. These built-in functions are available for the AArch64 family of
  8526. processors.
  8527. @smallexample
  8528. unsigned int __builtin_aarch64_get_fpcr ()
  8529. void __builtin_aarch64_set_fpcr (unsigned int)
  8530. unsigned int __builtin_aarch64_get_fpsr ()
  8531. void __builtin_aarch64_set_fpsr (unsigned int)
  8532. @end smallexample
  8533. @node Alpha Built-in Functions
  8534. @subsection Alpha Built-in Functions
  8535. These built-in functions are available for the Alpha family of
  8536. processors, depending on the command-line switches used.
  8537. The following built-in functions are always available. They
  8538. all generate the machine instruction that is part of the name.
  8539. @smallexample
  8540. long __builtin_alpha_implver (void)
  8541. long __builtin_alpha_rpcc (void)
  8542. long __builtin_alpha_amask (long)
  8543. long __builtin_alpha_cmpbge (long, long)
  8544. long __builtin_alpha_extbl (long, long)
  8545. long __builtin_alpha_extwl (long, long)
  8546. long __builtin_alpha_extll (long, long)
  8547. long __builtin_alpha_extql (long, long)
  8548. long __builtin_alpha_extwh (long, long)
  8549. long __builtin_alpha_extlh (long, long)
  8550. long __builtin_alpha_extqh (long, long)
  8551. long __builtin_alpha_insbl (long, long)
  8552. long __builtin_alpha_inswl (long, long)
  8553. long __builtin_alpha_insll (long, long)
  8554. long __builtin_alpha_insql (long, long)
  8555. long __builtin_alpha_inswh (long, long)
  8556. long __builtin_alpha_inslh (long, long)
  8557. long __builtin_alpha_insqh (long, long)
  8558. long __builtin_alpha_mskbl (long, long)
  8559. long __builtin_alpha_mskwl (long, long)
  8560. long __builtin_alpha_mskll (long, long)
  8561. long __builtin_alpha_mskql (long, long)
  8562. long __builtin_alpha_mskwh (long, long)
  8563. long __builtin_alpha_msklh (long, long)
  8564. long __builtin_alpha_mskqh (long, long)
  8565. long __builtin_alpha_umulh (long, long)
  8566. long __builtin_alpha_zap (long, long)
  8567. long __builtin_alpha_zapnot (long, long)
  8568. @end smallexample
  8569. The following built-in functions are always with @option{-mmax}
  8570. or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
  8571. later. They all generate the machine instruction that is part
  8572. of the name.
  8573. @smallexample
  8574. long __builtin_alpha_pklb (long)
  8575. long __builtin_alpha_pkwb (long)
  8576. long __builtin_alpha_unpkbl (long)
  8577. long __builtin_alpha_unpkbw (long)
  8578. long __builtin_alpha_minub8 (long, long)
  8579. long __builtin_alpha_minsb8 (long, long)
  8580. long __builtin_alpha_minuw4 (long, long)
  8581. long __builtin_alpha_minsw4 (long, long)
  8582. long __builtin_alpha_maxub8 (long, long)
  8583. long __builtin_alpha_maxsb8 (long, long)
  8584. long __builtin_alpha_maxuw4 (long, long)
  8585. long __builtin_alpha_maxsw4 (long, long)
  8586. long __builtin_alpha_perr (long, long)
  8587. @end smallexample
  8588. The following built-in functions are always with @option{-mcix}
  8589. or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
  8590. later. They all generate the machine instruction that is part
  8591. of the name.
  8592. @smallexample
  8593. long __builtin_alpha_cttz (long)
  8594. long __builtin_alpha_ctlz (long)
  8595. long __builtin_alpha_ctpop (long)
  8596. @end smallexample
  8597. The following built-in functions are available on systems that use the OSF/1
  8598. PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
  8599. PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
  8600. @code{rdval} and @code{wrval}.
  8601. @smallexample
  8602. void *__builtin_thread_pointer (void)
  8603. void __builtin_set_thread_pointer (void *)
  8604. @end smallexample
  8605. @node Altera Nios II Built-in Functions
  8606. @subsection Altera Nios II Built-in Functions
  8607. These built-in functions are available for the Altera Nios II
  8608. family of processors.
  8609. The following built-in functions are always available. They
  8610. all generate the machine instruction that is part of the name.
  8611. @example
  8612. int __builtin_ldbio (volatile const void *)
  8613. int __builtin_ldbuio (volatile const void *)
  8614. int __builtin_ldhio (volatile const void *)
  8615. int __builtin_ldhuio (volatile const void *)
  8616. int __builtin_ldwio (volatile const void *)
  8617. void __builtin_stbio (volatile void *, int)
  8618. void __builtin_sthio (volatile void *, int)
  8619. void __builtin_stwio (volatile void *, int)
  8620. void __builtin_sync (void)
  8621. int __builtin_rdctl (int)
  8622. void __builtin_wrctl (int, int)
  8623. @end example
  8624. The following built-in functions are always available. They
  8625. all generate a Nios II Custom Instruction. The name of the
  8626. function represents the types that the function takes and
  8627. returns. The letter before the @code{n} is the return type
  8628. or void if absent. The @code{n} represents the first parameter
  8629. to all the custom instructions, the custom instruction number.
  8630. The two letters after the @code{n} represent the up to two
  8631. parameters to the function.
  8632. The letters represent the following data types:
  8633. @table @code
  8634. @item <no letter>
  8635. @code{void} for return type and no parameter for parameter types.
  8636. @item i
  8637. @code{int} for return type and parameter type
  8638. @item f
  8639. @code{float} for return type and parameter type
  8640. @item p
  8641. @code{void *} for return type and parameter type
  8642. @end table
  8643. And the function names are:
  8644. @example
  8645. void __builtin_custom_n (void)
  8646. void __builtin_custom_ni (int)
  8647. void __builtin_custom_nf (float)
  8648. void __builtin_custom_np (void *)
  8649. void __builtin_custom_nii (int, int)
  8650. void __builtin_custom_nif (int, float)
  8651. void __builtin_custom_nip (int, void *)
  8652. void __builtin_custom_nfi (float, int)
  8653. void __builtin_custom_nff (float, float)
  8654. void __builtin_custom_nfp (float, void *)
  8655. void __builtin_custom_npi (void *, int)
  8656. void __builtin_custom_npf (void *, float)
  8657. void __builtin_custom_npp (void *, void *)
  8658. int __builtin_custom_in (void)
  8659. int __builtin_custom_ini (int)
  8660. int __builtin_custom_inf (float)
  8661. int __builtin_custom_inp (void *)
  8662. int __builtin_custom_inii (int, int)
  8663. int __builtin_custom_inif (int, float)
  8664. int __builtin_custom_inip (int, void *)
  8665. int __builtin_custom_infi (float, int)
  8666. int __builtin_custom_inff (float, float)
  8667. int __builtin_custom_infp (float, void *)
  8668. int __builtin_custom_inpi (void *, int)
  8669. int __builtin_custom_inpf (void *, float)
  8670. int __builtin_custom_inpp (void *, void *)
  8671. float __builtin_custom_fn (void)
  8672. float __builtin_custom_fni (int)
  8673. float __builtin_custom_fnf (float)
  8674. float __builtin_custom_fnp (void *)
  8675. float __builtin_custom_fnii (int, int)
  8676. float __builtin_custom_fnif (int, float)
  8677. float __builtin_custom_fnip (int, void *)
  8678. float __builtin_custom_fnfi (float, int)
  8679. float __builtin_custom_fnff (float, float)
  8680. float __builtin_custom_fnfp (float, void *)
  8681. float __builtin_custom_fnpi (void *, int)
  8682. float __builtin_custom_fnpf (void *, float)
  8683. float __builtin_custom_fnpp (void *, void *)
  8684. void * __builtin_custom_pn (void)
  8685. void * __builtin_custom_pni (int)
  8686. void * __builtin_custom_pnf (float)
  8687. void * __builtin_custom_pnp (void *)
  8688. void * __builtin_custom_pnii (int, int)
  8689. void * __builtin_custom_pnif (int, float)
  8690. void * __builtin_custom_pnip (int, void *)
  8691. void * __builtin_custom_pnfi (float, int)
  8692. void * __builtin_custom_pnff (float, float)
  8693. void * __builtin_custom_pnfp (float, void *)
  8694. void * __builtin_custom_pnpi (void *, int)
  8695. void * __builtin_custom_pnpf (void *, float)
  8696. void * __builtin_custom_pnpp (void *, void *)
  8697. @end example
  8698. @node ARC Built-in Functions
  8699. @subsection ARC Built-in Functions
  8700. The following built-in functions are provided for ARC targets. The
  8701. built-ins generate the corresponding assembly instructions. In the
  8702. examples given below, the generated code often requires an operand or
  8703. result to be in a register. Where necessary further code will be
  8704. generated to ensure this is true, but for brevity this is not
  8705. described in each case.
  8706. @emph{Note:} Using a built-in to generate an instruction not supported
  8707. by a target may cause problems. At present the compiler is not
  8708. guaranteed to detect such misuse, and as a result an internal compiler
  8709. error may be generated.
  8710. @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
  8711. Return 1 if @var{val} is known to have the byte alignment given
  8712. by @var{alignval}, otherwise return 0.
  8713. Note that this is different from
  8714. @smallexample
  8715. __alignof__(*(char *)@var{val}) >= alignval
  8716. @end smallexample
  8717. because __alignof__ sees only the type of the dereference, whereas
  8718. __builtin_arc_align uses alignment information from the pointer
  8719. as well as from the pointed-to type.
  8720. The information available will depend on optimization level.
  8721. @end deftypefn
  8722. @deftypefn {Built-in Function} void __builtin_arc_brk (void)
  8723. Generates
  8724. @example
  8725. brk
  8726. @end example
  8727. @end deftypefn
  8728. @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
  8729. The operand is the number of a register to be read. Generates:
  8730. @example
  8731. mov @var{dest}, r@var{regno}
  8732. @end example
  8733. where the value in @var{dest} will be the result returned from the
  8734. built-in.
  8735. @end deftypefn
  8736. @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
  8737. The first operand is the number of a register to be written, the
  8738. second operand is a compile time constant to write into that
  8739. register. Generates:
  8740. @example
  8741. mov r@var{regno}, @var{val}
  8742. @end example
  8743. @end deftypefn
  8744. @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
  8745. Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
  8746. Generates:
  8747. @example
  8748. divaw @var{dest}, @var{a}, @var{b}
  8749. @end example
  8750. where the value in @var{dest} will be the result returned from the
  8751. built-in.
  8752. @end deftypefn
  8753. @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
  8754. Generates
  8755. @example
  8756. flag @var{a}
  8757. @end example
  8758. @end deftypefn
  8759. @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
  8760. The operand, @var{auxv}, is the address of an auxiliary register and
  8761. must be a compile time constant. Generates:
  8762. @example
  8763. lr @var{dest}, [@var{auxr}]
  8764. @end example
  8765. Where the value in @var{dest} will be the result returned from the
  8766. built-in.
  8767. @end deftypefn
  8768. @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
  8769. Only available with @option{-mmul64}. Generates:
  8770. @example
  8771. mul64 @var{a}, @var{b}
  8772. @end example
  8773. @end deftypefn
  8774. @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
  8775. Only available with @option{-mmul64}. Generates:
  8776. @example
  8777. mulu64 @var{a}, @var{b}
  8778. @end example
  8779. @end deftypefn
  8780. @deftypefn {Built-in Function} void __builtin_arc_nop (void)
  8781. Generates:
  8782. @example
  8783. nop
  8784. @end example
  8785. @end deftypefn
  8786. @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
  8787. Only valid if the @samp{norm} instruction is available through the
  8788. @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
  8789. Generates:
  8790. @example
  8791. norm @var{dest}, @var{src}
  8792. @end example
  8793. Where the value in @var{dest} will be the result returned from the
  8794. built-in.
  8795. @end deftypefn
  8796. @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
  8797. Only valid if the @samp{normw} instruction is available through the
  8798. @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
  8799. Generates:
  8800. @example
  8801. normw @var{dest}, @var{src}
  8802. @end example
  8803. Where the value in @var{dest} will be the result returned from the
  8804. built-in.
  8805. @end deftypefn
  8806. @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
  8807. Generates:
  8808. @example
  8809. rtie
  8810. @end example
  8811. @end deftypefn
  8812. @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
  8813. Generates:
  8814. @example
  8815. sleep @var{a}
  8816. @end example
  8817. @end deftypefn
  8818. @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
  8819. The first argument, @var{auxv}, is the address of an auxiliary
  8820. register, the second argument, @var{val}, is a compile time constant
  8821. to be written to the register. Generates:
  8822. @example
  8823. sr @var{auxr}, [@var{val}]
  8824. @end example
  8825. @end deftypefn
  8826. @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
  8827. Only valid with @option{-mswap}. Generates:
  8828. @example
  8829. swap @var{dest}, @var{src}
  8830. @end example
  8831. Where the value in @var{dest} will be the result returned from the
  8832. built-in.
  8833. @end deftypefn
  8834. @deftypefn {Built-in Function} void __builtin_arc_swi (void)
  8835. Generates:
  8836. @example
  8837. swi
  8838. @end example
  8839. @end deftypefn
  8840. @deftypefn {Built-in Function} void __builtin_arc_sync (void)
  8841. Only available with @option{-mcpu=ARC700}. Generates:
  8842. @example
  8843. sync
  8844. @end example
  8845. @end deftypefn
  8846. @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
  8847. Only available with @option{-mcpu=ARC700}. Generates:
  8848. @example
  8849. trap_s @var{c}
  8850. @end example
  8851. @end deftypefn
  8852. @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
  8853. Only available with @option{-mcpu=ARC700}. Generates:
  8854. @example
  8855. unimp_s
  8856. @end example
  8857. @end deftypefn
  8858. The instructions generated by the following builtins are not
  8859. considered as candidates for scheduling. They are not moved around by
  8860. the compiler during scheduling, and thus can be expected to appear
  8861. where they are put in the C code:
  8862. @example
  8863. __builtin_arc_brk()
  8864. __builtin_arc_core_read()
  8865. __builtin_arc_core_write()
  8866. __builtin_arc_flag()
  8867. __builtin_arc_lr()
  8868. __builtin_arc_sleep()
  8869. __builtin_arc_sr()
  8870. __builtin_arc_swi()
  8871. @end example
  8872. @node ARC SIMD Built-in Functions
  8873. @subsection ARC SIMD Built-in Functions
  8874. SIMD builtins provided by the compiler can be used to generate the
  8875. vector instructions. This section describes the available builtins
  8876. and their usage in programs. With the @option{-msimd} option, the
  8877. compiler provides 128-bit vector types, which can be specified using
  8878. the @code{vector_size} attribute. The header file @file{arc-simd.h}
  8879. can be included to use the following predefined types:
  8880. @example
  8881. typedef int __v4si __attribute__((vector_size(16)));
  8882. typedef short __v8hi __attribute__((vector_size(16)));
  8883. @end example
  8884. These types can be used to define 128-bit variables. The built-in
  8885. functions listed in the following section can be used on these
  8886. variables to generate the vector operations.
  8887. For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
  8888. @file{arc-simd.h} also provides equivalent macros called
  8889. @code{_@var{someinsn}} that can be used for programming ease and
  8890. improved readability. The following macros for DMA control are also
  8891. provided:
  8892. @example
  8893. #define _setup_dma_in_channel_reg _vdiwr
  8894. #define _setup_dma_out_channel_reg _vdowr
  8895. @end example
  8896. The following is a complete list of all the SIMD built-ins provided
  8897. for ARC, grouped by calling signature.
  8898. The following take two @code{__v8hi} arguments and return a
  8899. @code{__v8hi} result:
  8900. @example
  8901. __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
  8902. __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
  8903. __v8hi __builtin_arc_vand (__v8hi, __v8hi)
  8904. __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
  8905. __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
  8906. __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
  8907. __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
  8908. __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
  8909. __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
  8910. __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
  8911. __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
  8912. __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
  8913. __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
  8914. __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
  8915. __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
  8916. __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
  8917. __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
  8918. __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
  8919. __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
  8920. __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
  8921. __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
  8922. __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
  8923. __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
  8924. __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
  8925. __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
  8926. __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
  8927. __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
  8928. __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
  8929. __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
  8930. __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
  8931. __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
  8932. __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
  8933. __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
  8934. __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
  8935. __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
  8936. __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
  8937. __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
  8938. __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
  8939. __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
  8940. __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
  8941. __v8hi __builtin_arc_vor (__v8hi, __v8hi)
  8942. __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
  8943. __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
  8944. __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
  8945. __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
  8946. __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
  8947. __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
  8948. __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
  8949. @end example
  8950. The following take one @code{__v8hi} and one @code{int} argument and return a
  8951. @code{__v8hi} result:
  8952. @example
  8953. __v8hi __builtin_arc_vbaddw (__v8hi, int)
  8954. __v8hi __builtin_arc_vbmaxw (__v8hi, int)
  8955. __v8hi __builtin_arc_vbminw (__v8hi, int)
  8956. __v8hi __builtin_arc_vbmulaw (__v8hi, int)
  8957. __v8hi __builtin_arc_vbmulfw (__v8hi, int)
  8958. __v8hi __builtin_arc_vbmulw (__v8hi, int)
  8959. __v8hi __builtin_arc_vbrsubw (__v8hi, int)
  8960. __v8hi __builtin_arc_vbsubw (__v8hi, int)
  8961. @end example
  8962. The following take one @code{__v8hi} argument and one @code{int} argument which
  8963. must be a 3-bit compile time constant indicating a register number
  8964. I0-I7. They return a @code{__v8hi} result.
  8965. @example
  8966. __v8hi __builtin_arc_vasrw (__v8hi, const int)
  8967. __v8hi __builtin_arc_vsr8 (__v8hi, const int)
  8968. __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
  8969. @end example
  8970. The following take one @code{__v8hi} argument and one @code{int}
  8971. argument which must be a 6-bit compile time constant. They return a
  8972. @code{__v8hi} result.
  8973. @example
  8974. __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
  8975. __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
  8976. __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
  8977. __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
  8978. __v8hi __builtin_arc_vasrwi (__v8hi, const int)
  8979. __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
  8980. __v8hi __builtin_arc_vsr8i (__v8hi, const int)
  8981. @end example
  8982. The following take one @code{__v8hi} argument and one @code{int} argument which
  8983. must be a 8-bit compile time constant. They return a @code{__v8hi}
  8984. result.
  8985. @example
  8986. __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
  8987. __v8hi __builtin_arc_vmvaw (__v8hi, const int)
  8988. __v8hi __builtin_arc_vmvw (__v8hi, const int)
  8989. __v8hi __builtin_arc_vmvzw (__v8hi, const int)
  8990. @end example
  8991. The following take two @code{int} arguments, the second of which which
  8992. must be a 8-bit compile time constant. They return a @code{__v8hi}
  8993. result:
  8994. @example
  8995. __v8hi __builtin_arc_vmovaw (int, const int)
  8996. __v8hi __builtin_arc_vmovw (int, const int)
  8997. __v8hi __builtin_arc_vmovzw (int, const int)
  8998. @end example
  8999. The following take a single @code{__v8hi} argument and return a
  9000. @code{__v8hi} result:
  9001. @example
  9002. __v8hi __builtin_arc_vabsaw (__v8hi)
  9003. __v8hi __builtin_arc_vabsw (__v8hi)
  9004. __v8hi __builtin_arc_vaddsuw (__v8hi)
  9005. __v8hi __builtin_arc_vexch1 (__v8hi)
  9006. __v8hi __builtin_arc_vexch2 (__v8hi)
  9007. __v8hi __builtin_arc_vexch4 (__v8hi)
  9008. __v8hi __builtin_arc_vsignw (__v8hi)
  9009. __v8hi __builtin_arc_vupbaw (__v8hi)
  9010. __v8hi __builtin_arc_vupbw (__v8hi)
  9011. __v8hi __builtin_arc_vupsbaw (__v8hi)
  9012. __v8hi __builtin_arc_vupsbw (__v8hi)
  9013. @end example
  9014. The following take two @code{int} arguments and return no result:
  9015. @example
  9016. void __builtin_arc_vdirun (int, int)
  9017. void __builtin_arc_vdorun (int, int)
  9018. @end example
  9019. The following take two @code{int} arguments and return no result. The
  9020. first argument must a 3-bit compile time constant indicating one of
  9021. the DR0-DR7 DMA setup channels:
  9022. @example
  9023. void __builtin_arc_vdiwr (const int, int)
  9024. void __builtin_arc_vdowr (const int, int)
  9025. @end example
  9026. The following take an @code{int} argument and return no result:
  9027. @example
  9028. void __builtin_arc_vendrec (int)
  9029. void __builtin_arc_vrec (int)
  9030. void __builtin_arc_vrecrun (int)
  9031. void __builtin_arc_vrun (int)
  9032. @end example
  9033. The following take a @code{__v8hi} argument and two @code{int}
  9034. arguments and return a @code{__v8hi} result. The second argument must
  9035. be a 3-bit compile time constants, indicating one the registers I0-I7,
  9036. and the third argument must be an 8-bit compile time constant.
  9037. @emph{Note:} Although the equivalent hardware instructions do not take
  9038. an SIMD register as an operand, these builtins overwrite the relevant
  9039. bits of the @code{__v8hi} register provided as the first argument with
  9040. the value loaded from the @code{[Ib, u8]} location in the SDM.
  9041. @example
  9042. __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
  9043. __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
  9044. __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
  9045. __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
  9046. @end example
  9047. The following take two @code{int} arguments and return a @code{__v8hi}
  9048. result. The first argument must be a 3-bit compile time constants,
  9049. indicating one the registers I0-I7, and the second argument must be an
  9050. 8-bit compile time constant.
  9051. @example
  9052. __v8hi __builtin_arc_vld128 (const int, const int)
  9053. __v8hi __builtin_arc_vld64w (const int, const int)
  9054. @end example
  9055. The following take a @code{__v8hi} argument and two @code{int}
  9056. arguments and return no result. The second argument must be a 3-bit
  9057. compile time constants, indicating one the registers I0-I7, and the
  9058. third argument must be an 8-bit compile time constant.
  9059. @example
  9060. void __builtin_arc_vst128 (__v8hi, const int, const int)
  9061. void __builtin_arc_vst64 (__v8hi, const int, const int)
  9062. @end example
  9063. The following take a @code{__v8hi} argument and three @code{int}
  9064. arguments and return no result. The second argument must be a 3-bit
  9065. compile-time constant, identifying the 16-bit sub-register to be
  9066. stored, the third argument must be a 3-bit compile time constants,
  9067. indicating one the registers I0-I7, and the fourth argument must be an
  9068. 8-bit compile time constant.
  9069. @example
  9070. void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
  9071. void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
  9072. @end example
  9073. @node ARM iWMMXt Built-in Functions
  9074. @subsection ARM iWMMXt Built-in Functions
  9075. These built-in functions are available for the ARM family of
  9076. processors when the @option{-mcpu=iwmmxt} switch is used:
  9077. @smallexample
  9078. typedef int v2si __attribute__ ((vector_size (8)));
  9079. typedef short v4hi __attribute__ ((vector_size (8)));
  9080. typedef char v8qi __attribute__ ((vector_size (8)));
  9081. int __builtin_arm_getwcgr0 (void)
  9082. void __builtin_arm_setwcgr0 (int)
  9083. int __builtin_arm_getwcgr1 (void)
  9084. void __builtin_arm_setwcgr1 (int)
  9085. int __builtin_arm_getwcgr2 (void)
  9086. void __builtin_arm_setwcgr2 (int)
  9087. int __builtin_arm_getwcgr3 (void)
  9088. void __builtin_arm_setwcgr3 (int)
  9089. int __builtin_arm_textrmsb (v8qi, int)
  9090. int __builtin_arm_textrmsh (v4hi, int)
  9091. int __builtin_arm_textrmsw (v2si, int)
  9092. int __builtin_arm_textrmub (v8qi, int)
  9093. int __builtin_arm_textrmuh (v4hi, int)
  9094. int __builtin_arm_textrmuw (v2si, int)
  9095. v8qi __builtin_arm_tinsrb (v8qi, int, int)
  9096. v4hi __builtin_arm_tinsrh (v4hi, int, int)
  9097. v2si __builtin_arm_tinsrw (v2si, int, int)
  9098. long long __builtin_arm_tmia (long long, int, int)
  9099. long long __builtin_arm_tmiabb (long long, int, int)
  9100. long long __builtin_arm_tmiabt (long long, int, int)
  9101. long long __builtin_arm_tmiaph (long long, int, int)
  9102. long long __builtin_arm_tmiatb (long long, int, int)
  9103. long long __builtin_arm_tmiatt (long long, int, int)
  9104. int __builtin_arm_tmovmskb (v8qi)
  9105. int __builtin_arm_tmovmskh (v4hi)
  9106. int __builtin_arm_tmovmskw (v2si)
  9107. long long __builtin_arm_waccb (v8qi)
  9108. long long __builtin_arm_wacch (v4hi)
  9109. long long __builtin_arm_waccw (v2si)
  9110. v8qi __builtin_arm_waddb (v8qi, v8qi)
  9111. v8qi __builtin_arm_waddbss (v8qi, v8qi)
  9112. v8qi __builtin_arm_waddbus (v8qi, v8qi)
  9113. v4hi __builtin_arm_waddh (v4hi, v4hi)
  9114. v4hi __builtin_arm_waddhss (v4hi, v4hi)
  9115. v4hi __builtin_arm_waddhus (v4hi, v4hi)
  9116. v2si __builtin_arm_waddw (v2si, v2si)
  9117. v2si __builtin_arm_waddwss (v2si, v2si)
  9118. v2si __builtin_arm_waddwus (v2si, v2si)
  9119. v8qi __builtin_arm_walign (v8qi, v8qi, int)
  9120. long long __builtin_arm_wand(long long, long long)
  9121. long long __builtin_arm_wandn (long long, long long)
  9122. v8qi __builtin_arm_wavg2b (v8qi, v8qi)
  9123. v8qi __builtin_arm_wavg2br (v8qi, v8qi)
  9124. v4hi __builtin_arm_wavg2h (v4hi, v4hi)
  9125. v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
  9126. v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
  9127. v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
  9128. v2si __builtin_arm_wcmpeqw (v2si, v2si)
  9129. v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
  9130. v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
  9131. v2si __builtin_arm_wcmpgtsw (v2si, v2si)
  9132. v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
  9133. v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
  9134. v2si __builtin_arm_wcmpgtuw (v2si, v2si)
  9135. long long __builtin_arm_wmacs (long long, v4hi, v4hi)
  9136. long long __builtin_arm_wmacsz (v4hi, v4hi)
  9137. long long __builtin_arm_wmacu (long long, v4hi, v4hi)
  9138. long long __builtin_arm_wmacuz (v4hi, v4hi)
  9139. v4hi __builtin_arm_wmadds (v4hi, v4hi)
  9140. v4hi __builtin_arm_wmaddu (v4hi, v4hi)
  9141. v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
  9142. v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
  9143. v2si __builtin_arm_wmaxsw (v2si, v2si)
  9144. v8qi __builtin_arm_wmaxub (v8qi, v8qi)
  9145. v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
  9146. v2si __builtin_arm_wmaxuw (v2si, v2si)
  9147. v8qi __builtin_arm_wminsb (v8qi, v8qi)
  9148. v4hi __builtin_arm_wminsh (v4hi, v4hi)
  9149. v2si __builtin_arm_wminsw (v2si, v2si)
  9150. v8qi __builtin_arm_wminub (v8qi, v8qi)
  9151. v4hi __builtin_arm_wminuh (v4hi, v4hi)
  9152. v2si __builtin_arm_wminuw (v2si, v2si)
  9153. v4hi __builtin_arm_wmulsm (v4hi, v4hi)
  9154. v4hi __builtin_arm_wmulul (v4hi, v4hi)
  9155. v4hi __builtin_arm_wmulum (v4hi, v4hi)
  9156. long long __builtin_arm_wor (long long, long long)
  9157. v2si __builtin_arm_wpackdss (long long, long long)
  9158. v2si __builtin_arm_wpackdus (long long, long long)
  9159. v8qi __builtin_arm_wpackhss (v4hi, v4hi)
  9160. v8qi __builtin_arm_wpackhus (v4hi, v4hi)
  9161. v4hi __builtin_arm_wpackwss (v2si, v2si)
  9162. v4hi __builtin_arm_wpackwus (v2si, v2si)
  9163. long long __builtin_arm_wrord (long long, long long)
  9164. long long __builtin_arm_wrordi (long long, int)
  9165. v4hi __builtin_arm_wrorh (v4hi, long long)
  9166. v4hi __builtin_arm_wrorhi (v4hi, int)
  9167. v2si __builtin_arm_wrorw (v2si, long long)
  9168. v2si __builtin_arm_wrorwi (v2si, int)
  9169. v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
  9170. v2si __builtin_arm_wsadbz (v8qi, v8qi)
  9171. v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
  9172. v2si __builtin_arm_wsadhz (v4hi, v4hi)
  9173. v4hi __builtin_arm_wshufh (v4hi, int)
  9174. long long __builtin_arm_wslld (long long, long long)
  9175. long long __builtin_arm_wslldi (long long, int)
  9176. v4hi __builtin_arm_wsllh (v4hi, long long)
  9177. v4hi __builtin_arm_wsllhi (v4hi, int)
  9178. v2si __builtin_arm_wsllw (v2si, long long)
  9179. v2si __builtin_arm_wsllwi (v2si, int)
  9180. long long __builtin_arm_wsrad (long long, long long)
  9181. long long __builtin_arm_wsradi (long long, int)
  9182. v4hi __builtin_arm_wsrah (v4hi, long long)
  9183. v4hi __builtin_arm_wsrahi (v4hi, int)
  9184. v2si __builtin_arm_wsraw (v2si, long long)
  9185. v2si __builtin_arm_wsrawi (v2si, int)
  9186. long long __builtin_arm_wsrld (long long, long long)
  9187. long long __builtin_arm_wsrldi (long long, int)
  9188. v4hi __builtin_arm_wsrlh (v4hi, long long)
  9189. v4hi __builtin_arm_wsrlhi (v4hi, int)
  9190. v2si __builtin_arm_wsrlw (v2si, long long)
  9191. v2si __builtin_arm_wsrlwi (v2si, int)
  9192. v8qi __builtin_arm_wsubb (v8qi, v8qi)
  9193. v8qi __builtin_arm_wsubbss (v8qi, v8qi)
  9194. v8qi __builtin_arm_wsubbus (v8qi, v8qi)
  9195. v4hi __builtin_arm_wsubh (v4hi, v4hi)
  9196. v4hi __builtin_arm_wsubhss (v4hi, v4hi)
  9197. v4hi __builtin_arm_wsubhus (v4hi, v4hi)
  9198. v2si __builtin_arm_wsubw (v2si, v2si)
  9199. v2si __builtin_arm_wsubwss (v2si, v2si)
  9200. v2si __builtin_arm_wsubwus (v2si, v2si)
  9201. v4hi __builtin_arm_wunpckehsb (v8qi)
  9202. v2si __builtin_arm_wunpckehsh (v4hi)
  9203. long long __builtin_arm_wunpckehsw (v2si)
  9204. v4hi __builtin_arm_wunpckehub (v8qi)
  9205. v2si __builtin_arm_wunpckehuh (v4hi)
  9206. long long __builtin_arm_wunpckehuw (v2si)
  9207. v4hi __builtin_arm_wunpckelsb (v8qi)
  9208. v2si __builtin_arm_wunpckelsh (v4hi)
  9209. long long __builtin_arm_wunpckelsw (v2si)
  9210. v4hi __builtin_arm_wunpckelub (v8qi)
  9211. v2si __builtin_arm_wunpckeluh (v4hi)
  9212. long long __builtin_arm_wunpckeluw (v2si)
  9213. v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
  9214. v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
  9215. v2si __builtin_arm_wunpckihw (v2si, v2si)
  9216. v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
  9217. v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
  9218. v2si __builtin_arm_wunpckilw (v2si, v2si)
  9219. long long __builtin_arm_wxor (long long, long long)
  9220. long long __builtin_arm_wzero ()
  9221. @end smallexample
  9222. @node ARM C Language Extensions (ACLE)
  9223. @subsection ARM C Language Extensions (ACLE)
  9224. GCC implements extensions for C as described in the ARM C Language
  9225. Extensions (ACLE) specification, which can be found at
  9226. @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
  9227. As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
  9228. the ARM C Language Extensions Specification. The complete list of Advanced SIMD
  9229. intrinsics can be found at
  9230. @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
  9231. The built-in intrinsics for the Advanced SIMD extension are available when
  9232. NEON is enabled.
  9233. Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
  9234. back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
  9235. 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
  9236. AArch64's back end does not have support for 16-bit floating point Advanced SIMD
  9237. intrinsics yet.
  9238. See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
  9239. availability of extensions.
  9240. @node ARM Floating Point Status and Control Intrinsics
  9241. @subsection ARM Floating Point Status and Control Intrinsics
  9242. These built-in functions are available for the ARM family of
  9243. processors with floating-point unit.
  9244. @smallexample
  9245. unsigned int __builtin_arm_get_fpscr ()
  9246. void __builtin_arm_set_fpscr (unsigned int)
  9247. @end smallexample
  9248. @node AVR Built-in Functions
  9249. @subsection AVR Built-in Functions
  9250. For each built-in function for AVR, there is an equally named,
  9251. uppercase built-in macro defined. That way users can easily query if
  9252. or if not a specific built-in is implemented or not. For example, if
  9253. @code{__builtin_avr_nop} is available the macro
  9254. @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
  9255. The following built-in functions map to the respective machine
  9256. instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
  9257. @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
  9258. resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
  9259. as library call if no hardware multiplier is available.
  9260. @smallexample
  9261. void __builtin_avr_nop (void)
  9262. void __builtin_avr_sei (void)
  9263. void __builtin_avr_cli (void)
  9264. void __builtin_avr_sleep (void)
  9265. void __builtin_avr_wdr (void)
  9266. unsigned char __builtin_avr_swap (unsigned char)
  9267. unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
  9268. int __builtin_avr_fmuls (char, char)
  9269. int __builtin_avr_fmulsu (char, unsigned char)
  9270. @end smallexample
  9271. In order to delay execution for a specific number of cycles, GCC
  9272. implements
  9273. @smallexample
  9274. void __builtin_avr_delay_cycles (unsigned long ticks)
  9275. @end smallexample
  9276. @noindent
  9277. @code{ticks} is the number of ticks to delay execution. Note that this
  9278. built-in does not take into account the effect of interrupts that
  9279. might increase delay time. @code{ticks} must be a compile-time
  9280. integer constant; delays with a variable number of cycles are not supported.
  9281. @smallexample
  9282. char __builtin_avr_flash_segment (const __memx void*)
  9283. @end smallexample
  9284. @noindent
  9285. This built-in takes a byte address to the 24-bit
  9286. @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
  9287. the number of the flash segment (the 64 KiB chunk) where the address
  9288. points to. Counting starts at @code{0}.
  9289. If the address does not point to flash memory, return @code{-1}.
  9290. @smallexample
  9291. unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
  9292. @end smallexample
  9293. @noindent
  9294. Insert bits from @var{bits} into @var{val} and return the resulting
  9295. value. The nibbles of @var{map} determine how the insertion is
  9296. performed: Let @var{X} be the @var{n}-th nibble of @var{map}
  9297. @enumerate
  9298. @item If @var{X} is @code{0xf},
  9299. then the @var{n}-th bit of @var{val} is returned unaltered.
  9300. @item If X is in the range 0@dots{}7,
  9301. then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
  9302. @item If X is in the range 8@dots{}@code{0xe},
  9303. then the @var{n}-th result bit is undefined.
  9304. @end enumerate
  9305. @noindent
  9306. One typical use case for this built-in is adjusting input and
  9307. output values to non-contiguous port layouts. Some examples:
  9308. @smallexample
  9309. // same as val, bits is unused
  9310. __builtin_avr_insert_bits (0xffffffff, bits, val)
  9311. @end smallexample
  9312. @smallexample
  9313. // same as bits, val is unused
  9314. __builtin_avr_insert_bits (0x76543210, bits, val)
  9315. @end smallexample
  9316. @smallexample
  9317. // same as rotating bits by 4
  9318. __builtin_avr_insert_bits (0x32107654, bits, 0)
  9319. @end smallexample
  9320. @smallexample
  9321. // high nibble of result is the high nibble of val
  9322. // low nibble of result is the low nibble of bits
  9323. __builtin_avr_insert_bits (0xffff3210, bits, val)
  9324. @end smallexample
  9325. @smallexample
  9326. // reverse the bit order of bits
  9327. __builtin_avr_insert_bits (0x01234567, bits, 0)
  9328. @end smallexample
  9329. @node Blackfin Built-in Functions
  9330. @subsection Blackfin Built-in Functions
  9331. Currently, there are two Blackfin-specific built-in functions. These are
  9332. used for generating @code{CSYNC} and @code{SSYNC} machine insns without
  9333. using inline assembly; by using these built-in functions the compiler can
  9334. automatically add workarounds for hardware errata involving these
  9335. instructions. These functions are named as follows:
  9336. @smallexample
  9337. void __builtin_bfin_csync (void)
  9338. void __builtin_bfin_ssync (void)
  9339. @end smallexample
  9340. @node FR-V Built-in Functions
  9341. @subsection FR-V Built-in Functions
  9342. GCC provides many FR-V-specific built-in functions. In general,
  9343. these functions are intended to be compatible with those described
  9344. by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
  9345. Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
  9346. @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
  9347. pointer rather than by value.
  9348. Most of the functions are named after specific FR-V instructions.
  9349. Such functions are said to be ``directly mapped'' and are summarized
  9350. here in tabular form.
  9351. @menu
  9352. * Argument Types::
  9353. * Directly-mapped Integer Functions::
  9354. * Directly-mapped Media Functions::
  9355. * Raw read/write Functions::
  9356. * Other Built-in Functions::
  9357. @end menu
  9358. @node Argument Types
  9359. @subsubsection Argument Types
  9360. The arguments to the built-in functions can be divided into three groups:
  9361. register numbers, compile-time constants and run-time values. In order
  9362. to make this classification clear at a glance, the arguments and return
  9363. values are given the following pseudo types:
  9364. @multitable @columnfractions .20 .30 .15 .35
  9365. @item Pseudo type @tab Real C type @tab Constant? @tab Description
  9366. @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
  9367. @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
  9368. @item @code{sw1} @tab @code{int} @tab No @tab a signed word
  9369. @item @code{uw2} @tab @code{unsigned long long} @tab No
  9370. @tab an unsigned doubleword
  9371. @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
  9372. @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
  9373. @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
  9374. @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
  9375. @end multitable
  9376. These pseudo types are not defined by GCC, they are simply a notational
  9377. convenience used in this manual.
  9378. Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
  9379. and @code{sw2} are evaluated at run time. They correspond to
  9380. register operands in the underlying FR-V instructions.
  9381. @code{const} arguments represent immediate operands in the underlying
  9382. FR-V instructions. They must be compile-time constants.
  9383. @code{acc} arguments are evaluated at compile time and specify the number
  9384. of an accumulator register. For example, an @code{acc} argument of 2
  9385. selects the ACC2 register.
  9386. @code{iacc} arguments are similar to @code{acc} arguments but specify the
  9387. number of an IACC register. See @pxref{Other Built-in Functions}
  9388. for more details.
  9389. @node Directly-mapped Integer Functions
  9390. @subsubsection Directly-Mapped Integer Functions
  9391. The functions listed below map directly to FR-V I-type instructions.
  9392. @multitable @columnfractions .45 .32 .23
  9393. @item Function prototype @tab Example usage @tab Assembly output
  9394. @item @code{sw1 __ADDSS (sw1, sw1)}
  9395. @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
  9396. @tab @code{ADDSS @var{a},@var{b},@var{c}}
  9397. @item @code{sw1 __SCAN (sw1, sw1)}
  9398. @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
  9399. @tab @code{SCAN @var{a},@var{b},@var{c}}
  9400. @item @code{sw1 __SCUTSS (sw1)}
  9401. @tab @code{@var{b} = __SCUTSS (@var{a})}
  9402. @tab @code{SCUTSS @var{a},@var{b}}
  9403. @item @code{sw1 __SLASS (sw1, sw1)}
  9404. @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
  9405. @tab @code{SLASS @var{a},@var{b},@var{c}}
  9406. @item @code{void __SMASS (sw1, sw1)}
  9407. @tab @code{__SMASS (@var{a}, @var{b})}
  9408. @tab @code{SMASS @var{a},@var{b}}
  9409. @item @code{void __SMSSS (sw1, sw1)}
  9410. @tab @code{__SMSSS (@var{a}, @var{b})}
  9411. @tab @code{SMSSS @var{a},@var{b}}
  9412. @item @code{void __SMU (sw1, sw1)}
  9413. @tab @code{__SMU (@var{a}, @var{b})}
  9414. @tab @code{SMU @var{a},@var{b}}
  9415. @item @code{sw2 __SMUL (sw1, sw1)}
  9416. @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
  9417. @tab @code{SMUL @var{a},@var{b},@var{c}}
  9418. @item @code{sw1 __SUBSS (sw1, sw1)}
  9419. @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
  9420. @tab @code{SUBSS @var{a},@var{b},@var{c}}
  9421. @item @code{uw2 __UMUL (uw1, uw1)}
  9422. @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
  9423. @tab @code{UMUL @var{a},@var{b},@var{c}}
  9424. @end multitable
  9425. @node Directly-mapped Media Functions
  9426. @subsubsection Directly-Mapped Media Functions
  9427. The functions listed below map directly to FR-V M-type instructions.
  9428. @multitable @columnfractions .45 .32 .23
  9429. @item Function prototype @tab Example usage @tab Assembly output
  9430. @item @code{uw1 __MABSHS (sw1)}
  9431. @tab @code{@var{b} = __MABSHS (@var{a})}
  9432. @tab @code{MABSHS @var{a},@var{b}}
  9433. @item @code{void __MADDACCS (acc, acc)}
  9434. @tab @code{__MADDACCS (@var{b}, @var{a})}
  9435. @tab @code{MADDACCS @var{a},@var{b}}
  9436. @item @code{sw1 __MADDHSS (sw1, sw1)}
  9437. @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
  9438. @tab @code{MADDHSS @var{a},@var{b},@var{c}}
  9439. @item @code{uw1 __MADDHUS (uw1, uw1)}
  9440. @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
  9441. @tab @code{MADDHUS @var{a},@var{b},@var{c}}
  9442. @item @code{uw1 __MAND (uw1, uw1)}
  9443. @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
  9444. @tab @code{MAND @var{a},@var{b},@var{c}}
  9445. @item @code{void __MASACCS (acc, acc)}
  9446. @tab @code{__MASACCS (@var{b}, @var{a})}
  9447. @tab @code{MASACCS @var{a},@var{b}}
  9448. @item @code{uw1 __MAVEH (uw1, uw1)}
  9449. @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
  9450. @tab @code{MAVEH @var{a},@var{b},@var{c}}
  9451. @item @code{uw2 __MBTOH (uw1)}
  9452. @tab @code{@var{b} = __MBTOH (@var{a})}
  9453. @tab @code{MBTOH @var{a},@var{b}}
  9454. @item @code{void __MBTOHE (uw1 *, uw1)}
  9455. @tab @code{__MBTOHE (&@var{b}, @var{a})}
  9456. @tab @code{MBTOHE @var{a},@var{b}}
  9457. @item @code{void __MCLRACC (acc)}
  9458. @tab @code{__MCLRACC (@var{a})}
  9459. @tab @code{MCLRACC @var{a}}
  9460. @item @code{void __MCLRACCA (void)}
  9461. @tab @code{__MCLRACCA ()}
  9462. @tab @code{MCLRACCA}
  9463. @item @code{uw1 __Mcop1 (uw1, uw1)}
  9464. @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
  9465. @tab @code{Mcop1 @var{a},@var{b},@var{c}}
  9466. @item @code{uw1 __Mcop2 (uw1, uw1)}
  9467. @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
  9468. @tab @code{Mcop2 @var{a},@var{b},@var{c}}
  9469. @item @code{uw1 __MCPLHI (uw2, const)}
  9470. @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
  9471. @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
  9472. @item @code{uw1 __MCPLI (uw2, const)}
  9473. @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
  9474. @tab @code{MCPLI @var{a},#@var{b},@var{c}}
  9475. @item @code{void __MCPXIS (acc, sw1, sw1)}
  9476. @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
  9477. @tab @code{MCPXIS @var{a},@var{b},@var{c}}
  9478. @item @code{void __MCPXIU (acc, uw1, uw1)}
  9479. @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
  9480. @tab @code{MCPXIU @var{a},@var{b},@var{c}}
  9481. @item @code{void __MCPXRS (acc, sw1, sw1)}
  9482. @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
  9483. @tab @code{MCPXRS @var{a},@var{b},@var{c}}
  9484. @item @code{void __MCPXRU (acc, uw1, uw1)}
  9485. @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
  9486. @tab @code{MCPXRU @var{a},@var{b},@var{c}}
  9487. @item @code{uw1 __MCUT (acc, uw1)}
  9488. @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
  9489. @tab @code{MCUT @var{a},@var{b},@var{c}}
  9490. @item @code{uw1 __MCUTSS (acc, sw1)}
  9491. @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
  9492. @tab @code{MCUTSS @var{a},@var{b},@var{c}}
  9493. @item @code{void __MDADDACCS (acc, acc)}
  9494. @tab @code{__MDADDACCS (@var{b}, @var{a})}
  9495. @tab @code{MDADDACCS @var{a},@var{b}}
  9496. @item @code{void __MDASACCS (acc, acc)}
  9497. @tab @code{__MDASACCS (@var{b}, @var{a})}
  9498. @tab @code{MDASACCS @var{a},@var{b}}
  9499. @item @code{uw2 __MDCUTSSI (acc, const)}
  9500. @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
  9501. @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
  9502. @item @code{uw2 __MDPACKH (uw2, uw2)}
  9503. @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
  9504. @tab @code{MDPACKH @var{a},@var{b},@var{c}}
  9505. @item @code{uw2 __MDROTLI (uw2, const)}
  9506. @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
  9507. @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
  9508. @item @code{void __MDSUBACCS (acc, acc)}
  9509. @tab @code{__MDSUBACCS (@var{b}, @var{a})}
  9510. @tab @code{MDSUBACCS @var{a},@var{b}}
  9511. @item @code{void __MDUNPACKH (uw1 *, uw2)}
  9512. @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
  9513. @tab @code{MDUNPACKH @var{a},@var{b}}
  9514. @item @code{uw2 __MEXPDHD (uw1, const)}
  9515. @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
  9516. @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
  9517. @item @code{uw1 __MEXPDHW (uw1, const)}
  9518. @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
  9519. @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
  9520. @item @code{uw1 __MHDSETH (uw1, const)}
  9521. @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
  9522. @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
  9523. @item @code{sw1 __MHDSETS (const)}
  9524. @tab @code{@var{b} = __MHDSETS (@var{a})}
  9525. @tab @code{MHDSETS #@var{a},@var{b}}
  9526. @item @code{uw1 __MHSETHIH (uw1, const)}
  9527. @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
  9528. @tab @code{MHSETHIH #@var{a},@var{b}}
  9529. @item @code{sw1 __MHSETHIS (sw1, const)}
  9530. @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
  9531. @tab @code{MHSETHIS #@var{a},@var{b}}
  9532. @item @code{uw1 __MHSETLOH (uw1, const)}
  9533. @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
  9534. @tab @code{MHSETLOH #@var{a},@var{b}}
  9535. @item @code{sw1 __MHSETLOS (sw1, const)}
  9536. @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
  9537. @tab @code{MHSETLOS #@var{a},@var{b}}
  9538. @item @code{uw1 __MHTOB (uw2)}
  9539. @tab @code{@var{b} = __MHTOB (@var{a})}
  9540. @tab @code{MHTOB @var{a},@var{b}}
  9541. @item @code{void __MMACHS (acc, sw1, sw1)}
  9542. @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
  9543. @tab @code{MMACHS @var{a},@var{b},@var{c}}
  9544. @item @code{void __MMACHU (acc, uw1, uw1)}
  9545. @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
  9546. @tab @code{MMACHU @var{a},@var{b},@var{c}}
  9547. @item @code{void __MMRDHS (acc, sw1, sw1)}
  9548. @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
  9549. @tab @code{MMRDHS @var{a},@var{b},@var{c}}
  9550. @item @code{void __MMRDHU (acc, uw1, uw1)}
  9551. @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
  9552. @tab @code{MMRDHU @var{a},@var{b},@var{c}}
  9553. @item @code{void __MMULHS (acc, sw1, sw1)}
  9554. @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
  9555. @tab @code{MMULHS @var{a},@var{b},@var{c}}
  9556. @item @code{void __MMULHU (acc, uw1, uw1)}
  9557. @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
  9558. @tab @code{MMULHU @var{a},@var{b},@var{c}}
  9559. @item @code{void __MMULXHS (acc, sw1, sw1)}
  9560. @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
  9561. @tab @code{MMULXHS @var{a},@var{b},@var{c}}
  9562. @item @code{void __MMULXHU (acc, uw1, uw1)}
  9563. @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
  9564. @tab @code{MMULXHU @var{a},@var{b},@var{c}}
  9565. @item @code{uw1 __MNOT (uw1)}
  9566. @tab @code{@var{b} = __MNOT (@var{a})}
  9567. @tab @code{MNOT @var{a},@var{b}}
  9568. @item @code{uw1 __MOR (uw1, uw1)}
  9569. @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
  9570. @tab @code{MOR @var{a},@var{b},@var{c}}
  9571. @item @code{uw1 __MPACKH (uh, uh)}
  9572. @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
  9573. @tab @code{MPACKH @var{a},@var{b},@var{c}}
  9574. @item @code{sw2 __MQADDHSS (sw2, sw2)}
  9575. @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
  9576. @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
  9577. @item @code{uw2 __MQADDHUS (uw2, uw2)}
  9578. @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
  9579. @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
  9580. @item @code{void __MQCPXIS (acc, sw2, sw2)}
  9581. @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
  9582. @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
  9583. @item @code{void __MQCPXIU (acc, uw2, uw2)}
  9584. @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
  9585. @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
  9586. @item @code{void __MQCPXRS (acc, sw2, sw2)}
  9587. @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
  9588. @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
  9589. @item @code{void __MQCPXRU (acc, uw2, uw2)}
  9590. @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
  9591. @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
  9592. @item @code{sw2 __MQLCLRHS (sw2, sw2)}
  9593. @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
  9594. @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
  9595. @item @code{sw2 __MQLMTHS (sw2, sw2)}
  9596. @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
  9597. @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
  9598. @item @code{void __MQMACHS (acc, sw2, sw2)}
  9599. @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
  9600. @tab @code{MQMACHS @var{a},@var{b},@var{c}}
  9601. @item @code{void __MQMACHU (acc, uw2, uw2)}
  9602. @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
  9603. @tab @code{MQMACHU @var{a},@var{b},@var{c}}
  9604. @item @code{void __MQMACXHS (acc, sw2, sw2)}
  9605. @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
  9606. @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
  9607. @item @code{void __MQMULHS (acc, sw2, sw2)}
  9608. @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
  9609. @tab @code{MQMULHS @var{a},@var{b},@var{c}}
  9610. @item @code{void __MQMULHU (acc, uw2, uw2)}
  9611. @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
  9612. @tab @code{MQMULHU @var{a},@var{b},@var{c}}
  9613. @item @code{void __MQMULXHS (acc, sw2, sw2)}
  9614. @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
  9615. @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
  9616. @item @code{void __MQMULXHU (acc, uw2, uw2)}
  9617. @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
  9618. @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
  9619. @item @code{sw2 __MQSATHS (sw2, sw2)}
  9620. @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
  9621. @tab @code{MQSATHS @var{a},@var{b},@var{c}}
  9622. @item @code{uw2 __MQSLLHI (uw2, int)}
  9623. @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
  9624. @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
  9625. @item @code{sw2 __MQSRAHI (sw2, int)}
  9626. @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
  9627. @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
  9628. @item @code{sw2 __MQSUBHSS (sw2, sw2)}
  9629. @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
  9630. @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
  9631. @item @code{uw2 __MQSUBHUS (uw2, uw2)}
  9632. @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
  9633. @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
  9634. @item @code{void __MQXMACHS (acc, sw2, sw2)}
  9635. @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
  9636. @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
  9637. @item @code{void __MQXMACXHS (acc, sw2, sw2)}
  9638. @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
  9639. @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
  9640. @item @code{uw1 __MRDACC (acc)}
  9641. @tab @code{@var{b} = __MRDACC (@var{a})}
  9642. @tab @code{MRDACC @var{a},@var{b}}
  9643. @item @code{uw1 __MRDACCG (acc)}
  9644. @tab @code{@var{b} = __MRDACCG (@var{a})}
  9645. @tab @code{MRDACCG @var{a},@var{b}}
  9646. @item @code{uw1 __MROTLI (uw1, const)}
  9647. @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
  9648. @tab @code{MROTLI @var{a},#@var{b},@var{c}}
  9649. @item @code{uw1 __MROTRI (uw1, const)}
  9650. @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
  9651. @tab @code{MROTRI @var{a},#@var{b},@var{c}}
  9652. @item @code{sw1 __MSATHS (sw1, sw1)}
  9653. @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
  9654. @tab @code{MSATHS @var{a},@var{b},@var{c}}
  9655. @item @code{uw1 __MSATHU (uw1, uw1)}
  9656. @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
  9657. @tab @code{MSATHU @var{a},@var{b},@var{c}}
  9658. @item @code{uw1 __MSLLHI (uw1, const)}
  9659. @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
  9660. @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
  9661. @item @code{sw1 __MSRAHI (sw1, const)}
  9662. @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
  9663. @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
  9664. @item @code{uw1 __MSRLHI (uw1, const)}
  9665. @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
  9666. @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
  9667. @item @code{void __MSUBACCS (acc, acc)}
  9668. @tab @code{__MSUBACCS (@var{b}, @var{a})}
  9669. @tab @code{MSUBACCS @var{a},@var{b}}
  9670. @item @code{sw1 __MSUBHSS (sw1, sw1)}
  9671. @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
  9672. @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
  9673. @item @code{uw1 __MSUBHUS (uw1, uw1)}
  9674. @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
  9675. @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
  9676. @item @code{void __MTRAP (void)}
  9677. @tab @code{__MTRAP ()}
  9678. @tab @code{MTRAP}
  9679. @item @code{uw2 __MUNPACKH (uw1)}
  9680. @tab @code{@var{b} = __MUNPACKH (@var{a})}
  9681. @tab @code{MUNPACKH @var{a},@var{b}}
  9682. @item @code{uw1 __MWCUT (uw2, uw1)}
  9683. @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
  9684. @tab @code{MWCUT @var{a},@var{b},@var{c}}
  9685. @item @code{void __MWTACC (acc, uw1)}
  9686. @tab @code{__MWTACC (@var{b}, @var{a})}
  9687. @tab @code{MWTACC @var{a},@var{b}}
  9688. @item @code{void __MWTACCG (acc, uw1)}
  9689. @tab @code{__MWTACCG (@var{b}, @var{a})}
  9690. @tab @code{MWTACCG @var{a},@var{b}}
  9691. @item @code{uw1 __MXOR (uw1, uw1)}
  9692. @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
  9693. @tab @code{MXOR @var{a},@var{b},@var{c}}
  9694. @end multitable
  9695. @node Raw read/write Functions
  9696. @subsubsection Raw Read/Write Functions
  9697. This sections describes built-in functions related to read and write
  9698. instructions to access memory. These functions generate
  9699. @code{membar} instructions to flush the I/O load and stores where
  9700. appropriate, as described in Fujitsu's manual described above.
  9701. @table @code
  9702. @item unsigned char __builtin_read8 (void *@var{data})
  9703. @item unsigned short __builtin_read16 (void *@var{data})
  9704. @item unsigned long __builtin_read32 (void *@var{data})
  9705. @item unsigned long long __builtin_read64 (void *@var{data})
  9706. @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
  9707. @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
  9708. @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
  9709. @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
  9710. @end table
  9711. @node Other Built-in Functions
  9712. @subsubsection Other Built-in Functions
  9713. This section describes built-in functions that are not named after
  9714. a specific FR-V instruction.
  9715. @table @code
  9716. @item sw2 __IACCreadll (iacc @var{reg})
  9717. Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
  9718. for future expansion and must be 0.
  9719. @item sw1 __IACCreadl (iacc @var{reg})
  9720. Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
  9721. Other values of @var{reg} are rejected as invalid.
  9722. @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
  9723. Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
  9724. is reserved for future expansion and must be 0.
  9725. @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
  9726. Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
  9727. is 1. Other values of @var{reg} are rejected as invalid.
  9728. @item void __data_prefetch0 (const void *@var{x})
  9729. Use the @code{dcpl} instruction to load the contents of address @var{x}
  9730. into the data cache.
  9731. @item void __data_prefetch (const void *@var{x})
  9732. Use the @code{nldub} instruction to load the contents of address @var{x}
  9733. into the data cache. The instruction is issued in slot I1@.
  9734. @end table
  9735. @node MIPS DSP Built-in Functions
  9736. @subsection MIPS DSP Built-in Functions
  9737. The MIPS DSP Application-Specific Extension (ASE) includes new
  9738. instructions that are designed to improve the performance of DSP and
  9739. media applications. It provides instructions that operate on packed
  9740. 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
  9741. GCC supports MIPS DSP operations using both the generic
  9742. vector extensions (@pxref{Vector Extensions}) and a collection of
  9743. MIPS-specific built-in functions. Both kinds of support are
  9744. enabled by the @option{-mdsp} command-line option.
  9745. Revision 2 of the ASE was introduced in the second half of 2006.
  9746. This revision adds extra instructions to the original ASE, but is
  9747. otherwise backwards-compatible with it. You can select revision 2
  9748. using the command-line option @option{-mdspr2}; this option implies
  9749. @option{-mdsp}.
  9750. The SCOUNT and POS bits of the DSP control register are global. The
  9751. WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
  9752. POS bits. During optimization, the compiler does not delete these
  9753. instructions and it does not delete calls to functions containing
  9754. these instructions.
  9755. At present, GCC only provides support for operations on 32-bit
  9756. vectors. The vector type associated with 8-bit integer data is
  9757. usually called @code{v4i8}, the vector type associated with Q7
  9758. is usually called @code{v4q7}, the vector type associated with 16-bit
  9759. integer data is usually called @code{v2i16}, and the vector type
  9760. associated with Q15 is usually called @code{v2q15}. They can be
  9761. defined in C as follows:
  9762. @smallexample
  9763. typedef signed char v4i8 __attribute__ ((vector_size(4)));
  9764. typedef signed char v4q7 __attribute__ ((vector_size(4)));
  9765. typedef short v2i16 __attribute__ ((vector_size(4)));
  9766. typedef short v2q15 __attribute__ ((vector_size(4)));
  9767. @end smallexample
  9768. @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
  9769. initialized in the same way as aggregates. For example:
  9770. @smallexample
  9771. v4i8 a = @{1, 2, 3, 4@};
  9772. v4i8 b;
  9773. b = (v4i8) @{5, 6, 7, 8@};
  9774. v2q15 c = @{0x0fcb, 0x3a75@};
  9775. v2q15 d;
  9776. d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
  9777. @end smallexample
  9778. @emph{Note:} The CPU's endianness determines the order in which values
  9779. are packed. On little-endian targets, the first value is the least
  9780. significant and the last value is the most significant. The opposite
  9781. order applies to big-endian targets. For example, the code above
  9782. sets the lowest byte of @code{a} to @code{1} on little-endian targets
  9783. and @code{4} on big-endian targets.
  9784. @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
  9785. representation. As shown in this example, the integer representation
  9786. of a Q7 value can be obtained by multiplying the fractional value by
  9787. @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
  9788. @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
  9789. @code{0x1.0p31}.
  9790. The table below lists the @code{v4i8} and @code{v2q15} operations for which
  9791. hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
  9792. and @code{c} and @code{d} are @code{v2q15} values.
  9793. @multitable @columnfractions .50 .50
  9794. @item C code @tab MIPS instruction
  9795. @item @code{a + b} @tab @code{addu.qb}
  9796. @item @code{c + d} @tab @code{addq.ph}
  9797. @item @code{a - b} @tab @code{subu.qb}
  9798. @item @code{c - d} @tab @code{subq.ph}
  9799. @end multitable
  9800. The table below lists the @code{v2i16} operation for which
  9801. hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
  9802. @code{v2i16} values.
  9803. @multitable @columnfractions .50 .50
  9804. @item C code @tab MIPS instruction
  9805. @item @code{e * f} @tab @code{mul.ph}
  9806. @end multitable
  9807. It is easier to describe the DSP built-in functions if we first define
  9808. the following types:
  9809. @smallexample
  9810. typedef int q31;
  9811. typedef int i32;
  9812. typedef unsigned int ui32;
  9813. typedef long long a64;
  9814. @end smallexample
  9815. @code{q31} and @code{i32} are actually the same as @code{int}, but we
  9816. use @code{q31} to indicate a Q31 fractional value and @code{i32} to
  9817. indicate a 32-bit integer value. Similarly, @code{a64} is the same as
  9818. @code{long long}, but we use @code{a64} to indicate values that are
  9819. placed in one of the four DSP accumulators (@code{$ac0},
  9820. @code{$ac1}, @code{$ac2} or @code{$ac3}).
  9821. Also, some built-in functions prefer or require immediate numbers as
  9822. parameters, because the corresponding DSP instructions accept both immediate
  9823. numbers and register operands, or accept immediate numbers only. The
  9824. immediate parameters are listed as follows.
  9825. @smallexample
  9826. imm0_3: 0 to 3.
  9827. imm0_7: 0 to 7.
  9828. imm0_15: 0 to 15.
  9829. imm0_31: 0 to 31.
  9830. imm0_63: 0 to 63.
  9831. imm0_255: 0 to 255.
  9832. imm_n32_31: -32 to 31.
  9833. imm_n512_511: -512 to 511.
  9834. @end smallexample
  9835. The following built-in functions map directly to a particular MIPS DSP
  9836. instruction. Please refer to the architecture specification
  9837. for details on what each instruction does.
  9838. @smallexample
  9839. v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
  9840. v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
  9841. q31 __builtin_mips_addq_s_w (q31, q31)
  9842. v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
  9843. v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
  9844. v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
  9845. v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
  9846. q31 __builtin_mips_subq_s_w (q31, q31)
  9847. v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
  9848. v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
  9849. i32 __builtin_mips_addsc (i32, i32)
  9850. i32 __builtin_mips_addwc (i32, i32)
  9851. i32 __builtin_mips_modsub (i32, i32)
  9852. i32 __builtin_mips_raddu_w_qb (v4i8)
  9853. v2q15 __builtin_mips_absq_s_ph (v2q15)
  9854. q31 __builtin_mips_absq_s_w (q31)
  9855. v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
  9856. v2q15 __builtin_mips_precrq_ph_w (q31, q31)
  9857. v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
  9858. v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
  9859. q31 __builtin_mips_preceq_w_phl (v2q15)
  9860. q31 __builtin_mips_preceq_w_phr (v2q15)
  9861. v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
  9862. v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
  9863. v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
  9864. v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
  9865. v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
  9866. v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
  9867. v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
  9868. v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
  9869. v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
  9870. v4i8 __builtin_mips_shll_qb (v4i8, i32)
  9871. v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
  9872. v2q15 __builtin_mips_shll_ph (v2q15, i32)
  9873. v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
  9874. v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
  9875. q31 __builtin_mips_shll_s_w (q31, imm0_31)
  9876. q31 __builtin_mips_shll_s_w (q31, i32)
  9877. v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
  9878. v4i8 __builtin_mips_shrl_qb (v4i8, i32)
  9879. v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
  9880. v2q15 __builtin_mips_shra_ph (v2q15, i32)
  9881. v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
  9882. v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
  9883. q31 __builtin_mips_shra_r_w (q31, imm0_31)
  9884. q31 __builtin_mips_shra_r_w (q31, i32)
  9885. v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
  9886. v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
  9887. v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
  9888. q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
  9889. q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
  9890. a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
  9891. a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
  9892. a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
  9893. a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
  9894. a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
  9895. a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
  9896. a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
  9897. a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
  9898. a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
  9899. a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
  9900. a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
  9901. a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
  9902. a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
  9903. i32 __builtin_mips_bitrev (i32)
  9904. i32 __builtin_mips_insv (i32, i32)
  9905. v4i8 __builtin_mips_repl_qb (imm0_255)
  9906. v4i8 __builtin_mips_repl_qb (i32)
  9907. v2q15 __builtin_mips_repl_ph (imm_n512_511)
  9908. v2q15 __builtin_mips_repl_ph (i32)
  9909. void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
  9910. void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
  9911. void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
  9912. i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
  9913. i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
  9914. i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
  9915. void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
  9916. void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
  9917. void __builtin_mips_cmp_le_ph (v2q15, v2q15)
  9918. v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
  9919. v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
  9920. v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
  9921. i32 __builtin_mips_extr_w (a64, imm0_31)
  9922. i32 __builtin_mips_extr_w (a64, i32)
  9923. i32 __builtin_mips_extr_r_w (a64, imm0_31)
  9924. i32 __builtin_mips_extr_s_h (a64, i32)
  9925. i32 __builtin_mips_extr_rs_w (a64, imm0_31)
  9926. i32 __builtin_mips_extr_rs_w (a64, i32)
  9927. i32 __builtin_mips_extr_s_h (a64, imm0_31)
  9928. i32 __builtin_mips_extr_r_w (a64, i32)
  9929. i32 __builtin_mips_extp (a64, imm0_31)
  9930. i32 __builtin_mips_extp (a64, i32)
  9931. i32 __builtin_mips_extpdp (a64, imm0_31)
  9932. i32 __builtin_mips_extpdp (a64, i32)
  9933. a64 __builtin_mips_shilo (a64, imm_n32_31)
  9934. a64 __builtin_mips_shilo (a64, i32)
  9935. a64 __builtin_mips_mthlip (a64, i32)
  9936. void __builtin_mips_wrdsp (i32, imm0_63)
  9937. i32 __builtin_mips_rddsp (imm0_63)
  9938. i32 __builtin_mips_lbux (void *, i32)
  9939. i32 __builtin_mips_lhx (void *, i32)
  9940. i32 __builtin_mips_lwx (void *, i32)
  9941. a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
  9942. i32 __builtin_mips_bposge32 (void)
  9943. a64 __builtin_mips_madd (a64, i32, i32);
  9944. a64 __builtin_mips_maddu (a64, ui32, ui32);
  9945. a64 __builtin_mips_msub (a64, i32, i32);
  9946. a64 __builtin_mips_msubu (a64, ui32, ui32);
  9947. a64 __builtin_mips_mult (i32, i32);
  9948. a64 __builtin_mips_multu (ui32, ui32);
  9949. @end smallexample
  9950. The following built-in functions map directly to a particular MIPS DSP REV 2
  9951. instruction. Please refer to the architecture specification
  9952. for details on what each instruction does.
  9953. @smallexample
  9954. v4q7 __builtin_mips_absq_s_qb (v4q7);
  9955. v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
  9956. v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
  9957. v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
  9958. v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
  9959. i32 __builtin_mips_append (i32, i32, imm0_31);
  9960. i32 __builtin_mips_balign (i32, i32, imm0_3);
  9961. i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
  9962. i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
  9963. i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
  9964. a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
  9965. a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
  9966. v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
  9967. v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
  9968. q31 __builtin_mips_mulq_rs_w (q31, q31);
  9969. v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
  9970. q31 __builtin_mips_mulq_s_w (q31, q31);
  9971. a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
  9972. v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
  9973. v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
  9974. v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
  9975. i32 __builtin_mips_prepend (i32, i32, imm0_31);
  9976. v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
  9977. v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
  9978. v4i8 __builtin_mips_shra_qb (v4i8, i32);
  9979. v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
  9980. v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
  9981. v2i16 __builtin_mips_shrl_ph (v2i16, i32);
  9982. v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
  9983. v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
  9984. v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
  9985. v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
  9986. v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
  9987. v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
  9988. q31 __builtin_mips_addqh_w (q31, q31);
  9989. q31 __builtin_mips_addqh_r_w (q31, q31);
  9990. v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
  9991. v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
  9992. q31 __builtin_mips_subqh_w (q31, q31);
  9993. q31 __builtin_mips_subqh_r_w (q31, q31);
  9994. a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
  9995. a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
  9996. a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
  9997. a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
  9998. a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
  9999. a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
  10000. @end smallexample
  10001. @node MIPS Paired-Single Support
  10002. @subsection MIPS Paired-Single Support
  10003. The MIPS64 architecture includes a number of instructions that
  10004. operate on pairs of single-precision floating-point values.
  10005. Each pair is packed into a 64-bit floating-point register,
  10006. with one element being designated the ``upper half'' and
  10007. the other being designated the ``lower half''.
  10008. GCC supports paired-single operations using both the generic
  10009. vector extensions (@pxref{Vector Extensions}) and a collection of
  10010. MIPS-specific built-in functions. Both kinds of support are
  10011. enabled by the @option{-mpaired-single} command-line option.
  10012. The vector type associated with paired-single values is usually
  10013. called @code{v2sf}. It can be defined in C as follows:
  10014. @smallexample
  10015. typedef float v2sf __attribute__ ((vector_size (8)));
  10016. @end smallexample
  10017. @code{v2sf} values are initialized in the same way as aggregates.
  10018. For example:
  10019. @smallexample
  10020. v2sf a = @{1.5, 9.1@};
  10021. v2sf b;
  10022. float e, f;
  10023. b = (v2sf) @{e, f@};
  10024. @end smallexample
  10025. @emph{Note:} The CPU's endianness determines which value is stored in
  10026. the upper half of a register and which value is stored in the lower half.
  10027. On little-endian targets, the first value is the lower one and the second
  10028. value is the upper one. The opposite order applies to big-endian targets.
  10029. For example, the code above sets the lower half of @code{a} to
  10030. @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
  10031. @node MIPS Loongson Built-in Functions
  10032. @subsection MIPS Loongson Built-in Functions
  10033. GCC provides intrinsics to access the SIMD instructions provided by the
  10034. ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
  10035. available after inclusion of the @code{loongson.h} header file,
  10036. operate on the following 64-bit vector types:
  10037. @itemize
  10038. @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
  10039. @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
  10040. @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
  10041. @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
  10042. @item @code{int16x4_t}, a vector of four signed 16-bit integers;
  10043. @item @code{int32x2_t}, a vector of two signed 32-bit integers.
  10044. @end itemize
  10045. The intrinsics provided are listed below; each is named after the
  10046. machine instruction to which it corresponds, with suffixes added as
  10047. appropriate to distinguish intrinsics that expand to the same machine
  10048. instruction yet have different argument types. Refer to the architecture
  10049. documentation for a description of the functionality of each
  10050. instruction.
  10051. @smallexample
  10052. int16x4_t packsswh (int32x2_t s, int32x2_t t);
  10053. int8x8_t packsshb (int16x4_t s, int16x4_t t);
  10054. uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
  10055. uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
  10056. uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
  10057. uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
  10058. int32x2_t paddw_s (int32x2_t s, int32x2_t t);
  10059. int16x4_t paddh_s (int16x4_t s, int16x4_t t);
  10060. int8x8_t paddb_s (int8x8_t s, int8x8_t t);
  10061. uint64_t paddd_u (uint64_t s, uint64_t t);
  10062. int64_t paddd_s (int64_t s, int64_t t);
  10063. int16x4_t paddsh (int16x4_t s, int16x4_t t);
  10064. int8x8_t paddsb (int8x8_t s, int8x8_t t);
  10065. uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
  10066. uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
  10067. uint64_t pandn_ud (uint64_t s, uint64_t t);
  10068. uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
  10069. uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
  10070. uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
  10071. int64_t pandn_sd (int64_t s, int64_t t);
  10072. int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
  10073. int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
  10074. int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
  10075. uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
  10076. uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
  10077. uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
  10078. uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
  10079. uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
  10080. int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
  10081. int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
  10082. int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
  10083. uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
  10084. uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
  10085. uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
  10086. int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
  10087. int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
  10088. int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
  10089. uint16x4_t pextrh_u (uint16x4_t s, int field);
  10090. int16x4_t pextrh_s (int16x4_t s, int field);
  10091. uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
  10092. uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
  10093. uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
  10094. uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
  10095. int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
  10096. int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
  10097. int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
  10098. int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
  10099. int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
  10100. int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
  10101. uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
  10102. int16x4_t pminsh (int16x4_t s, int16x4_t t);
  10103. uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
  10104. uint8x8_t pmovmskb_u (uint8x8_t s);
  10105. int8x8_t pmovmskb_s (int8x8_t s);
  10106. uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
  10107. int16x4_t pmulhh (int16x4_t s, int16x4_t t);
  10108. int16x4_t pmullh (int16x4_t s, int16x4_t t);
  10109. int64_t pmuluw (uint32x2_t s, uint32x2_t t);
  10110. uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
  10111. uint16x4_t biadd (uint8x8_t s);
  10112. uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
  10113. uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
  10114. int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
  10115. uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
  10116. int16x4_t psllh_s (int16x4_t s, uint8_t amount);
  10117. uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
  10118. int32x2_t psllw_s (int32x2_t s, uint8_t amount);
  10119. uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
  10120. int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
  10121. uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
  10122. int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
  10123. uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
  10124. int16x4_t psrah_s (int16x4_t s, uint8_t amount);
  10125. uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
  10126. int32x2_t psraw_s (int32x2_t s, uint8_t amount);
  10127. uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
  10128. uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
  10129. uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
  10130. int32x2_t psubw_s (int32x2_t s, int32x2_t t);
  10131. int16x4_t psubh_s (int16x4_t s, int16x4_t t);
  10132. int8x8_t psubb_s (int8x8_t s, int8x8_t t);
  10133. uint64_t psubd_u (uint64_t s, uint64_t t);
  10134. int64_t psubd_s (int64_t s, int64_t t);
  10135. int16x4_t psubsh (int16x4_t s, int16x4_t t);
  10136. int8x8_t psubsb (int8x8_t s, int8x8_t t);
  10137. uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
  10138. uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
  10139. uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
  10140. uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
  10141. uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
  10142. int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
  10143. int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
  10144. int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
  10145. uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
  10146. uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
  10147. uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
  10148. int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
  10149. int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
  10150. int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
  10151. @end smallexample
  10152. @menu
  10153. * Paired-Single Arithmetic::
  10154. * Paired-Single Built-in Functions::
  10155. * MIPS-3D Built-in Functions::
  10156. @end menu
  10157. @node Paired-Single Arithmetic
  10158. @subsubsection Paired-Single Arithmetic
  10159. The table below lists the @code{v2sf} operations for which hardware
  10160. support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
  10161. values and @code{x} is an integral value.
  10162. @multitable @columnfractions .50 .50
  10163. @item C code @tab MIPS instruction
  10164. @item @code{a + b} @tab @code{add.ps}
  10165. @item @code{a - b} @tab @code{sub.ps}
  10166. @item @code{-a} @tab @code{neg.ps}
  10167. @item @code{a * b} @tab @code{mul.ps}
  10168. @item @code{a * b + c} @tab @code{madd.ps}
  10169. @item @code{a * b - c} @tab @code{msub.ps}
  10170. @item @code{-(a * b + c)} @tab @code{nmadd.ps}
  10171. @item @code{-(a * b - c)} @tab @code{nmsub.ps}
  10172. @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
  10173. @end multitable
  10174. Note that the multiply-accumulate instructions can be disabled
  10175. using the command-line option @code{-mno-fused-madd}.
  10176. @node Paired-Single Built-in Functions
  10177. @subsubsection Paired-Single Built-in Functions
  10178. The following paired-single functions map directly to a particular
  10179. MIPS instruction. Please refer to the architecture specification
  10180. for details on what each instruction does.
  10181. @table @code
  10182. @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
  10183. Pair lower lower (@code{pll.ps}).
  10184. @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
  10185. Pair upper lower (@code{pul.ps}).
  10186. @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
  10187. Pair lower upper (@code{plu.ps}).
  10188. @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
  10189. Pair upper upper (@code{puu.ps}).
  10190. @item v2sf __builtin_mips_cvt_ps_s (float, float)
  10191. Convert pair to paired single (@code{cvt.ps.s}).
  10192. @item float __builtin_mips_cvt_s_pl (v2sf)
  10193. Convert pair lower to single (@code{cvt.s.pl}).
  10194. @item float __builtin_mips_cvt_s_pu (v2sf)
  10195. Convert pair upper to single (@code{cvt.s.pu}).
  10196. @item v2sf __builtin_mips_abs_ps (v2sf)
  10197. Absolute value (@code{abs.ps}).
  10198. @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
  10199. Align variable (@code{alnv.ps}).
  10200. @emph{Note:} The value of the third parameter must be 0 or 4
  10201. modulo 8, otherwise the result is unpredictable. Please read the
  10202. instruction description for details.
  10203. @end table
  10204. The following multi-instruction functions are also available.
  10205. In each case, @var{cond} can be any of the 16 floating-point conditions:
  10206. @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
  10207. @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
  10208. @code{lt}, @code{nge}, @code{le} or @code{ngt}.
  10209. @table @code
  10210. @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10211. @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10212. Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
  10213. @code{movt.ps}/@code{movf.ps}).
  10214. The @code{movt} functions return the value @var{x} computed by:
  10215. @smallexample
  10216. c.@var{cond}.ps @var{cc},@var{a},@var{b}
  10217. mov.ps @var{x},@var{c}
  10218. movt.ps @var{x},@var{d},@var{cc}
  10219. @end smallexample
  10220. The @code{movf} functions are similar but use @code{movf.ps} instead
  10221. of @code{movt.ps}.
  10222. @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10223. @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10224. Comparison of two paired-single values (@code{c.@var{cond}.ps},
  10225. @code{bc1t}/@code{bc1f}).
  10226. These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
  10227. and return either the upper or lower half of the result. For example:
  10228. @smallexample
  10229. v2sf a, b;
  10230. if (__builtin_mips_upper_c_eq_ps (a, b))
  10231. upper_halves_are_equal ();
  10232. else
  10233. upper_halves_are_unequal ();
  10234. if (__builtin_mips_lower_c_eq_ps (a, b))
  10235. lower_halves_are_equal ();
  10236. else
  10237. lower_halves_are_unequal ();
  10238. @end smallexample
  10239. @end table
  10240. @node MIPS-3D Built-in Functions
  10241. @subsubsection MIPS-3D Built-in Functions
  10242. The MIPS-3D Application-Specific Extension (ASE) includes additional
  10243. paired-single instructions that are designed to improve the performance
  10244. of 3D graphics operations. Support for these instructions is controlled
  10245. by the @option{-mips3d} command-line option.
  10246. The functions listed below map directly to a particular MIPS-3D
  10247. instruction. Please refer to the architecture specification for
  10248. more details on what each instruction does.
  10249. @table @code
  10250. @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
  10251. Reduction add (@code{addr.ps}).
  10252. @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
  10253. Reduction multiply (@code{mulr.ps}).
  10254. @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
  10255. Convert paired single to paired word (@code{cvt.pw.ps}).
  10256. @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
  10257. Convert paired word to paired single (@code{cvt.ps.pw}).
  10258. @item float __builtin_mips_recip1_s (float)
  10259. @itemx double __builtin_mips_recip1_d (double)
  10260. @itemx v2sf __builtin_mips_recip1_ps (v2sf)
  10261. Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
  10262. @item float __builtin_mips_recip2_s (float, float)
  10263. @itemx double __builtin_mips_recip2_d (double, double)
  10264. @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
  10265. Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
  10266. @item float __builtin_mips_rsqrt1_s (float)
  10267. @itemx double __builtin_mips_rsqrt1_d (double)
  10268. @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
  10269. Reduced-precision reciprocal square root (sequence step 1)
  10270. (@code{rsqrt1.@var{fmt}}).
  10271. @item float __builtin_mips_rsqrt2_s (float, float)
  10272. @itemx double __builtin_mips_rsqrt2_d (double, double)
  10273. @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
  10274. Reduced-precision reciprocal square root (sequence step 2)
  10275. (@code{rsqrt2.@var{fmt}}).
  10276. @end table
  10277. The following multi-instruction functions are also available.
  10278. In each case, @var{cond} can be any of the 16 floating-point conditions:
  10279. @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
  10280. @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
  10281. @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
  10282. @table @code
  10283. @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
  10284. @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
  10285. Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
  10286. @code{bc1t}/@code{bc1f}).
  10287. These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
  10288. or @code{cabs.@var{cond}.d} and return the result as a boolean value.
  10289. For example:
  10290. @smallexample
  10291. float a, b;
  10292. if (__builtin_mips_cabs_eq_s (a, b))
  10293. true ();
  10294. else
  10295. false ();
  10296. @end smallexample
  10297. @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10298. @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10299. Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
  10300. @code{bc1t}/@code{bc1f}).
  10301. These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
  10302. and return either the upper or lower half of the result. For example:
  10303. @smallexample
  10304. v2sf a, b;
  10305. if (__builtin_mips_upper_cabs_eq_ps (a, b))
  10306. upper_halves_are_equal ();
  10307. else
  10308. upper_halves_are_unequal ();
  10309. if (__builtin_mips_lower_cabs_eq_ps (a, b))
  10310. lower_halves_are_equal ();
  10311. else
  10312. lower_halves_are_unequal ();
  10313. @end smallexample
  10314. @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10315. @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10316. Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
  10317. @code{movt.ps}/@code{movf.ps}).
  10318. The @code{movt} functions return the value @var{x} computed by:
  10319. @smallexample
  10320. cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
  10321. mov.ps @var{x},@var{c}
  10322. movt.ps @var{x},@var{d},@var{cc}
  10323. @end smallexample
  10324. The @code{movf} functions are similar but use @code{movf.ps} instead
  10325. of @code{movt.ps}.
  10326. @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10327. @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10328. @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10329. @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
  10330. Comparison of two paired-single values
  10331. (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
  10332. @code{bc1any2t}/@code{bc1any2f}).
  10333. These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
  10334. or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
  10335. result is true and the @code{all} forms return true if both results are true.
  10336. For example:
  10337. @smallexample
  10338. v2sf a, b;
  10339. if (__builtin_mips_any_c_eq_ps (a, b))
  10340. one_is_true ();
  10341. else
  10342. both_are_false ();
  10343. if (__builtin_mips_all_c_eq_ps (a, b))
  10344. both_are_true ();
  10345. else
  10346. one_is_false ();
  10347. @end smallexample
  10348. @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10349. @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10350. @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10351. @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
  10352. Comparison of four paired-single values
  10353. (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
  10354. @code{bc1any4t}/@code{bc1any4f}).
  10355. These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
  10356. to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
  10357. The @code{any} forms return true if any of the four results are true
  10358. and the @code{all} forms return true if all four results are true.
  10359. For example:
  10360. @smallexample
  10361. v2sf a, b, c, d;
  10362. if (__builtin_mips_any_c_eq_4s (a, b, c, d))
  10363. some_are_true ();
  10364. else
  10365. all_are_false ();
  10366. if (__builtin_mips_all_c_eq_4s (a, b, c, d))
  10367. all_are_true ();
  10368. else
  10369. some_are_false ();
  10370. @end smallexample
  10371. @end table
  10372. @node Other MIPS Built-in Functions
  10373. @subsection Other MIPS Built-in Functions
  10374. GCC provides other MIPS-specific built-in functions:
  10375. @table @code
  10376. @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
  10377. Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
  10378. GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
  10379. when this function is available.
  10380. @item unsigned int __builtin_mips_get_fcsr (void)
  10381. @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
  10382. Get and set the contents of the floating-point control and status register
  10383. (FPU control register 31). These functions are only available in hard-float
  10384. code but can be called in both MIPS16 and non-MIPS16 contexts.
  10385. @code{__builtin_mips_set_fcsr} can be used to change any bit of the
  10386. register except the condition codes, which GCC assumes are preserved.
  10387. @end table
  10388. @node MSP430 Built-in Functions
  10389. @subsection MSP430 Built-in Functions
  10390. GCC provides a couple of special builtin functions to aid in the
  10391. writing of interrupt handlers in C.
  10392. @table @code
  10393. @item __bic_SR_register_on_exit (int @var{mask})
  10394. This clears the indicated bits in the saved copy of the status register
  10395. currently residing on the stack. This only works inside interrupt
  10396. handlers and the changes to the status register will only take affect
  10397. once the handler returns.
  10398. @item __bis_SR_register_on_exit (int @var{mask})
  10399. This sets the indicated bits in the saved copy of the status register
  10400. currently residing on the stack. This only works inside interrupt
  10401. handlers and the changes to the status register will only take affect
  10402. once the handler returns.
  10403. @item __delay_cycles (long long @var{cycles})
  10404. This inserts an instruction sequence that takes exactly @var{cycles}
  10405. cycles (between 0 and about 17E9) to complete. The inserted sequence
  10406. may use jumps, loops, or no-ops, and does not interfere with any other
  10407. instructions. Note that @var{cycles} must be a compile-time constant
  10408. integer - that is, you must pass a number, not a variable that may be
  10409. optimized to a constant later. The number of cycles delayed by this
  10410. builtin is exact.
  10411. @end table
  10412. @node NDS32 Built-in Functions
  10413. @subsection NDS32 Built-in Functions
  10414. These built-in functions are available for the NDS32 target:
  10415. @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
  10416. Insert an ISYNC instruction into the instruction stream where
  10417. @var{addr} is an instruction address for serialization.
  10418. @end deftypefn
  10419. @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
  10420. Insert an ISB instruction into the instruction stream.
  10421. @end deftypefn
  10422. @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
  10423. Return the content of a system register which is mapped by @var{sr}.
  10424. @end deftypefn
  10425. @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
  10426. Return the content of a user space register which is mapped by @var{usr}.
  10427. @end deftypefn
  10428. @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
  10429. Move the @var{value} to a system register which is mapped by @var{sr}.
  10430. @end deftypefn
  10431. @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
  10432. Move the @var{value} to a user space register which is mapped by @var{usr}.
  10433. @end deftypefn
  10434. @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
  10435. Enable global interrupt.
  10436. @end deftypefn
  10437. @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
  10438. Disable global interrupt.
  10439. @end deftypefn
  10440. @node picoChip Built-in Functions
  10441. @subsection picoChip Built-in Functions
  10442. GCC provides an interface to selected machine instructions from the
  10443. picoChip instruction set.
  10444. @table @code
  10445. @item int __builtin_sbc (int @var{value})
  10446. Sign bit count. Return the number of consecutive bits in @var{value}
  10447. that have the same value as the sign bit. The result is the number of
  10448. leading sign bits minus one, giving the number of redundant sign bits in
  10449. @var{value}.
  10450. @item int __builtin_byteswap (int @var{value})
  10451. Byte swap. Return the result of swapping the upper and lower bytes of
  10452. @var{value}.
  10453. @item int __builtin_brev (int @var{value})
  10454. Bit reversal. Return the result of reversing the bits in
  10455. @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
  10456. and so on.
  10457. @item int __builtin_adds (int @var{x}, int @var{y})
  10458. Saturating addition. Return the result of adding @var{x} and @var{y},
  10459. storing the value 32767 if the result overflows.
  10460. @item int __builtin_subs (int @var{x}, int @var{y})
  10461. Saturating subtraction. Return the result of subtracting @var{y} from
  10462. @var{x}, storing the value @minus{}32768 if the result overflows.
  10463. @item void __builtin_halt (void)
  10464. Halt. The processor stops execution. This built-in is useful for
  10465. implementing assertions.
  10466. @end table
  10467. @node PowerPC Built-in Functions
  10468. @subsection PowerPC Built-in Functions
  10469. These built-in functions are available for the PowerPC family of
  10470. processors:
  10471. @smallexample
  10472. float __builtin_recipdivf (float, float);
  10473. float __builtin_rsqrtf (float);
  10474. double __builtin_recipdiv (double, double);
  10475. double __builtin_rsqrt (double);
  10476. uint64_t __builtin_ppc_get_timebase ();
  10477. unsigned long __builtin_ppc_mftb ();
  10478. double __builtin_unpack_longdouble (long double, int);
  10479. long double __builtin_pack_longdouble (double, double);
  10480. @end smallexample
  10481. The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
  10482. @code{__builtin_rsqrtf} functions generate multiple instructions to
  10483. implement the reciprocal sqrt functionality using reciprocal sqrt
  10484. estimate instructions.
  10485. The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
  10486. functions generate multiple instructions to implement division using
  10487. the reciprocal estimate instructions.
  10488. The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
  10489. functions generate instructions to read the Time Base Register. The
  10490. @code{__builtin_ppc_get_timebase} function may generate multiple
  10491. instructions and always returns the 64 bits of the Time Base Register.
  10492. The @code{__builtin_ppc_mftb} function always generates one instruction and
  10493. returns the Time Base Register value as an unsigned long, throwing away
  10494. the most significant word on 32-bit environments.
  10495. The following built-in functions are available for the PowerPC family
  10496. of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
  10497. or @option{-mpopcntd}):
  10498. @smallexample
  10499. long __builtin_bpermd (long, long);
  10500. int __builtin_divwe (int, int);
  10501. int __builtin_divweo (int, int);
  10502. unsigned int __builtin_divweu (unsigned int, unsigned int);
  10503. unsigned int __builtin_divweuo (unsigned int, unsigned int);
  10504. long __builtin_divde (long, long);
  10505. long __builtin_divdeo (long, long);
  10506. unsigned long __builtin_divdeu (unsigned long, unsigned long);
  10507. unsigned long __builtin_divdeuo (unsigned long, unsigned long);
  10508. unsigned int cdtbcd (unsigned int);
  10509. unsigned int cbcdtd (unsigned int);
  10510. unsigned int addg6s (unsigned int, unsigned int);
  10511. @end smallexample
  10512. The @code{__builtin_divde}, @code{__builtin_divdeo},
  10513. @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
  10514. 64-bit environment support ISA 2.06 or later.
  10515. The following built-in functions are available for the PowerPC family
  10516. of processors when hardware decimal floating point
  10517. (@option{-mhard-dfp}) is available:
  10518. @smallexample
  10519. _Decimal64 __builtin_dxex (_Decimal64);
  10520. _Decimal128 __builtin_dxexq (_Decimal128);
  10521. _Decimal64 __builtin_ddedpd (int, _Decimal64);
  10522. _Decimal128 __builtin_ddedpdq (int, _Decimal128);
  10523. _Decimal64 __builtin_denbcd (int, _Decimal64);
  10524. _Decimal128 __builtin_denbcdq (int, _Decimal128);
  10525. _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
  10526. _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
  10527. _Decimal64 __builtin_dscli (_Decimal64, int);
  10528. _Decimal128 __builtin_dscliq (_Decimal128, int);
  10529. _Decimal64 __builtin_dscri (_Decimal64, int);
  10530. _Decimal128 __builtin_dscriq (_Decimal128, int);
  10531. unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
  10532. _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
  10533. @end smallexample
  10534. The following built-in functions are available for the PowerPC family
  10535. of processors when the Vector Scalar (vsx) instruction set is
  10536. available:
  10537. @smallexample
  10538. unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
  10539. vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
  10540. unsigned long long);
  10541. @end smallexample
  10542. @node PowerPC AltiVec/VSX Built-in Functions
  10543. @subsection PowerPC AltiVec Built-in Functions
  10544. GCC provides an interface for the PowerPC family of processors to access
  10545. the AltiVec operations described in Motorola's AltiVec Programming
  10546. Interface Manual. The interface is made available by including
  10547. @code{<altivec.h>} and using @option{-maltivec} and
  10548. @option{-mabi=altivec}. The interface supports the following vector
  10549. types.
  10550. @smallexample
  10551. vector unsigned char
  10552. vector signed char
  10553. vector bool char
  10554. vector unsigned short
  10555. vector signed short
  10556. vector bool short
  10557. vector pixel
  10558. vector unsigned int
  10559. vector signed int
  10560. vector bool int
  10561. vector float
  10562. @end smallexample
  10563. If @option{-mvsx} is used the following additional vector types are
  10564. implemented.
  10565. @smallexample
  10566. vector unsigned long
  10567. vector signed long
  10568. vector double
  10569. @end smallexample
  10570. The long types are only implemented for 64-bit code generation, and
  10571. the long type is only used in the floating point/integer conversion
  10572. instructions.
  10573. GCC's implementation of the high-level language interface available from
  10574. C and C++ code differs from Motorola's documentation in several ways.
  10575. @itemize @bullet
  10576. @item
  10577. A vector constant is a list of constant expressions within curly braces.
  10578. @item
  10579. A vector initializer requires no cast if the vector constant is of the
  10580. same type as the variable it is initializing.
  10581. @item
  10582. If @code{signed} or @code{unsigned} is omitted, the signedness of the
  10583. vector type is the default signedness of the base type. The default
  10584. varies depending on the operating system, so a portable program should
  10585. always specify the signedness.
  10586. @item
  10587. Compiling with @option{-maltivec} adds keywords @code{__vector},
  10588. @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
  10589. @code{bool}. When compiling ISO C, the context-sensitive substitution
  10590. of the keywords @code{vector}, @code{pixel} and @code{bool} is
  10591. disabled. To use them, you must include @code{<altivec.h>} instead.
  10592. @item
  10593. GCC allows using a @code{typedef} name as the type specifier for a
  10594. vector type.
  10595. @item
  10596. For C, overloaded functions are implemented with macros so the following
  10597. does not work:
  10598. @smallexample
  10599. vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
  10600. @end smallexample
  10601. @noindent
  10602. Since @code{vec_add} is a macro, the vector constant in the example
  10603. is treated as four separate arguments. Wrap the entire argument in
  10604. parentheses for this to work.
  10605. @end itemize
  10606. @emph{Note:} Only the @code{<altivec.h>} interface is supported.
  10607. Internally, GCC uses built-in functions to achieve the functionality in
  10608. the aforementioned header file, but they are not supported and are
  10609. subject to change without notice.
  10610. The following interfaces are supported for the generic and specific
  10611. AltiVec operations and the AltiVec predicates. In cases where there
  10612. is a direct mapping between generic and specific operations, only the
  10613. generic names are shown here, although the specific operations can also
  10614. be used.
  10615. Arguments that are documented as @code{const int} require literal
  10616. integral values within the range required for that operation.
  10617. @smallexample
  10618. vector signed char vec_abs (vector signed char);
  10619. vector signed short vec_abs (vector signed short);
  10620. vector signed int vec_abs (vector signed int);
  10621. vector float vec_abs (vector float);
  10622. vector signed char vec_abss (vector signed char);
  10623. vector signed short vec_abss (vector signed short);
  10624. vector signed int vec_abss (vector signed int);
  10625. vector signed char vec_add (vector bool char, vector signed char);
  10626. vector signed char vec_add (vector signed char, vector bool char);
  10627. vector signed char vec_add (vector signed char, vector signed char);
  10628. vector unsigned char vec_add (vector bool char, vector unsigned char);
  10629. vector unsigned char vec_add (vector unsigned char, vector bool char);
  10630. vector unsigned char vec_add (vector unsigned char,
  10631. vector unsigned char);
  10632. vector signed short vec_add (vector bool short, vector signed short);
  10633. vector signed short vec_add (vector signed short, vector bool short);
  10634. vector signed short vec_add (vector signed short, vector signed short);
  10635. vector unsigned short vec_add (vector bool short,
  10636. vector unsigned short);
  10637. vector unsigned short vec_add (vector unsigned short,
  10638. vector bool short);
  10639. vector unsigned short vec_add (vector unsigned short,
  10640. vector unsigned short);
  10641. vector signed int vec_add (vector bool int, vector signed int);
  10642. vector signed int vec_add (vector signed int, vector bool int);
  10643. vector signed int vec_add (vector signed int, vector signed int);
  10644. vector unsigned int vec_add (vector bool int, vector unsigned int);
  10645. vector unsigned int vec_add (vector unsigned int, vector bool int);
  10646. vector unsigned int vec_add (vector unsigned int, vector unsigned int);
  10647. vector float vec_add (vector float, vector float);
  10648. vector float vec_vaddfp (vector float, vector float);
  10649. vector signed int vec_vadduwm (vector bool int, vector signed int);
  10650. vector signed int vec_vadduwm (vector signed int, vector bool int);
  10651. vector signed int vec_vadduwm (vector signed int, vector signed int);
  10652. vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
  10653. vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
  10654. vector unsigned int vec_vadduwm (vector unsigned int,
  10655. vector unsigned int);
  10656. vector signed short vec_vadduhm (vector bool short,
  10657. vector signed short);
  10658. vector signed short vec_vadduhm (vector signed short,
  10659. vector bool short);
  10660. vector signed short vec_vadduhm (vector signed short,
  10661. vector signed short);
  10662. vector unsigned short vec_vadduhm (vector bool short,
  10663. vector unsigned short);
  10664. vector unsigned short vec_vadduhm (vector unsigned short,
  10665. vector bool short);
  10666. vector unsigned short vec_vadduhm (vector unsigned short,
  10667. vector unsigned short);
  10668. vector signed char vec_vaddubm (vector bool char, vector signed char);
  10669. vector signed char vec_vaddubm (vector signed char, vector bool char);
  10670. vector signed char vec_vaddubm (vector signed char, vector signed char);
  10671. vector unsigned char vec_vaddubm (vector bool char,
  10672. vector unsigned char);
  10673. vector unsigned char vec_vaddubm (vector unsigned char,
  10674. vector bool char);
  10675. vector unsigned char vec_vaddubm (vector unsigned char,
  10676. vector unsigned char);
  10677. vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
  10678. vector unsigned char vec_adds (vector bool char, vector unsigned char);
  10679. vector unsigned char vec_adds (vector unsigned char, vector bool char);
  10680. vector unsigned char vec_adds (vector unsigned char,
  10681. vector unsigned char);
  10682. vector signed char vec_adds (vector bool char, vector signed char);
  10683. vector signed char vec_adds (vector signed char, vector bool char);
  10684. vector signed char vec_adds (vector signed char, vector signed char);
  10685. vector unsigned short vec_adds (vector bool short,
  10686. vector unsigned short);
  10687. vector unsigned short vec_adds (vector unsigned short,
  10688. vector bool short);
  10689. vector unsigned short vec_adds (vector unsigned short,
  10690. vector unsigned short);
  10691. vector signed short vec_adds (vector bool short, vector signed short);
  10692. vector signed short vec_adds (vector signed short, vector bool short);
  10693. vector signed short vec_adds (vector signed short, vector signed short);
  10694. vector unsigned int vec_adds (vector bool int, vector unsigned int);
  10695. vector unsigned int vec_adds (vector unsigned int, vector bool int);
  10696. vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
  10697. vector signed int vec_adds (vector bool int, vector signed int);
  10698. vector signed int vec_adds (vector signed int, vector bool int);
  10699. vector signed int vec_adds (vector signed int, vector signed int);
  10700. vector signed int vec_vaddsws (vector bool int, vector signed int);
  10701. vector signed int vec_vaddsws (vector signed int, vector bool int);
  10702. vector signed int vec_vaddsws (vector signed int, vector signed int);
  10703. vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
  10704. vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
  10705. vector unsigned int vec_vadduws (vector unsigned int,
  10706. vector unsigned int);
  10707. vector signed short vec_vaddshs (vector bool short,
  10708. vector signed short);
  10709. vector signed short vec_vaddshs (vector signed short,
  10710. vector bool short);
  10711. vector signed short vec_vaddshs (vector signed short,
  10712. vector signed short);
  10713. vector unsigned short vec_vadduhs (vector bool short,
  10714. vector unsigned short);
  10715. vector unsigned short vec_vadduhs (vector unsigned short,
  10716. vector bool short);
  10717. vector unsigned short vec_vadduhs (vector unsigned short,
  10718. vector unsigned short);
  10719. vector signed char vec_vaddsbs (vector bool char, vector signed char);
  10720. vector signed char vec_vaddsbs (vector signed char, vector bool char);
  10721. vector signed char vec_vaddsbs (vector signed char, vector signed char);
  10722. vector unsigned char vec_vaddubs (vector bool char,
  10723. vector unsigned char);
  10724. vector unsigned char vec_vaddubs (vector unsigned char,
  10725. vector bool char);
  10726. vector unsigned char vec_vaddubs (vector unsigned char,
  10727. vector unsigned char);
  10728. vector float vec_and (vector float, vector float);
  10729. vector float vec_and (vector float, vector bool int);
  10730. vector float vec_and (vector bool int, vector float);
  10731. vector bool int vec_and (vector bool int, vector bool int);
  10732. vector signed int vec_and (vector bool int, vector signed int);
  10733. vector signed int vec_and (vector signed int, vector bool int);
  10734. vector signed int vec_and (vector signed int, vector signed int);
  10735. vector unsigned int vec_and (vector bool int, vector unsigned int);
  10736. vector unsigned int vec_and (vector unsigned int, vector bool int);
  10737. vector unsigned int vec_and (vector unsigned int, vector unsigned int);
  10738. vector bool short vec_and (vector bool short, vector bool short);
  10739. vector signed short vec_and (vector bool short, vector signed short);
  10740. vector signed short vec_and (vector signed short, vector bool short);
  10741. vector signed short vec_and (vector signed short, vector signed short);
  10742. vector unsigned short vec_and (vector bool short,
  10743. vector unsigned short);
  10744. vector unsigned short vec_and (vector unsigned short,
  10745. vector bool short);
  10746. vector unsigned short vec_and (vector unsigned short,
  10747. vector unsigned short);
  10748. vector signed char vec_and (vector bool char, vector signed char);
  10749. vector bool char vec_and (vector bool char, vector bool char);
  10750. vector signed char vec_and (vector signed char, vector bool char);
  10751. vector signed char vec_and (vector signed char, vector signed char);
  10752. vector unsigned char vec_and (vector bool char, vector unsigned char);
  10753. vector unsigned char vec_and (vector unsigned char, vector bool char);
  10754. vector unsigned char vec_and (vector unsigned char,
  10755. vector unsigned char);
  10756. vector float vec_andc (vector float, vector float);
  10757. vector float vec_andc (vector float, vector bool int);
  10758. vector float vec_andc (vector bool int, vector float);
  10759. vector bool int vec_andc (vector bool int, vector bool int);
  10760. vector signed int vec_andc (vector bool int, vector signed int);
  10761. vector signed int vec_andc (vector signed int, vector bool int);
  10762. vector signed int vec_andc (vector signed int, vector signed int);
  10763. vector unsigned int vec_andc (vector bool int, vector unsigned int);
  10764. vector unsigned int vec_andc (vector unsigned int, vector bool int);
  10765. vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
  10766. vector bool short vec_andc (vector bool short, vector bool short);
  10767. vector signed short vec_andc (vector bool short, vector signed short);
  10768. vector signed short vec_andc (vector signed short, vector bool short);
  10769. vector signed short vec_andc (vector signed short, vector signed short);
  10770. vector unsigned short vec_andc (vector bool short,
  10771. vector unsigned short);
  10772. vector unsigned short vec_andc (vector unsigned short,
  10773. vector bool short);
  10774. vector unsigned short vec_andc (vector unsigned short,
  10775. vector unsigned short);
  10776. vector signed char vec_andc (vector bool char, vector signed char);
  10777. vector bool char vec_andc (vector bool char, vector bool char);
  10778. vector signed char vec_andc (vector signed char, vector bool char);
  10779. vector signed char vec_andc (vector signed char, vector signed char);
  10780. vector unsigned char vec_andc (vector bool char, vector unsigned char);
  10781. vector unsigned char vec_andc (vector unsigned char, vector bool char);
  10782. vector unsigned char vec_andc (vector unsigned char,
  10783. vector unsigned char);
  10784. vector unsigned char vec_avg (vector unsigned char,
  10785. vector unsigned char);
  10786. vector signed char vec_avg (vector signed char, vector signed char);
  10787. vector unsigned short vec_avg (vector unsigned short,
  10788. vector unsigned short);
  10789. vector signed short vec_avg (vector signed short, vector signed short);
  10790. vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
  10791. vector signed int vec_avg (vector signed int, vector signed int);
  10792. vector signed int vec_vavgsw (vector signed int, vector signed int);
  10793. vector unsigned int vec_vavguw (vector unsigned int,
  10794. vector unsigned int);
  10795. vector signed short vec_vavgsh (vector signed short,
  10796. vector signed short);
  10797. vector unsigned short vec_vavguh (vector unsigned short,
  10798. vector unsigned short);
  10799. vector signed char vec_vavgsb (vector signed char, vector signed char);
  10800. vector unsigned char vec_vavgub (vector unsigned char,
  10801. vector unsigned char);
  10802. vector float vec_copysign (vector float);
  10803. vector float vec_ceil (vector float);
  10804. vector signed int vec_cmpb (vector float, vector float);
  10805. vector bool char vec_cmpeq (vector signed char, vector signed char);
  10806. vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
  10807. vector bool short vec_cmpeq (vector signed short, vector signed short);
  10808. vector bool short vec_cmpeq (vector unsigned short,
  10809. vector unsigned short);
  10810. vector bool int vec_cmpeq (vector signed int, vector signed int);
  10811. vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
  10812. vector bool int vec_cmpeq (vector float, vector float);
  10813. vector bool int vec_vcmpeqfp (vector float, vector float);
  10814. vector bool int vec_vcmpequw (vector signed int, vector signed int);
  10815. vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
  10816. vector bool short vec_vcmpequh (vector signed short,
  10817. vector signed short);
  10818. vector bool short vec_vcmpequh (vector unsigned short,
  10819. vector unsigned short);
  10820. vector bool char vec_vcmpequb (vector signed char, vector signed char);
  10821. vector bool char vec_vcmpequb (vector unsigned char,
  10822. vector unsigned char);
  10823. vector bool int vec_cmpge (vector float, vector float);
  10824. vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
  10825. vector bool char vec_cmpgt (vector signed char, vector signed char);
  10826. vector bool short vec_cmpgt (vector unsigned short,
  10827. vector unsigned short);
  10828. vector bool short vec_cmpgt (vector signed short, vector signed short);
  10829. vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
  10830. vector bool int vec_cmpgt (vector signed int, vector signed int);
  10831. vector bool int vec_cmpgt (vector float, vector float);
  10832. vector bool int vec_vcmpgtfp (vector float, vector float);
  10833. vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
  10834. vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
  10835. vector bool short vec_vcmpgtsh (vector signed short,
  10836. vector signed short);
  10837. vector bool short vec_vcmpgtuh (vector unsigned short,
  10838. vector unsigned short);
  10839. vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
  10840. vector bool char vec_vcmpgtub (vector unsigned char,
  10841. vector unsigned char);
  10842. vector bool int vec_cmple (vector float, vector float);
  10843. vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
  10844. vector bool char vec_cmplt (vector signed char, vector signed char);
  10845. vector bool short vec_cmplt (vector unsigned short,
  10846. vector unsigned short);
  10847. vector bool short vec_cmplt (vector signed short, vector signed short);
  10848. vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
  10849. vector bool int vec_cmplt (vector signed int, vector signed int);
  10850. vector bool int vec_cmplt (vector float, vector float);
  10851. vector float vec_cpsgn (vector float, vector float);
  10852. vector float vec_ctf (vector unsigned int, const int);
  10853. vector float vec_ctf (vector signed int, const int);
  10854. vector double vec_ctf (vector unsigned long, const int);
  10855. vector double vec_ctf (vector signed long, const int);
  10856. vector float vec_vcfsx (vector signed int, const int);
  10857. vector float vec_vcfux (vector unsigned int, const int);
  10858. vector signed int vec_cts (vector float, const int);
  10859. vector signed long vec_cts (vector double, const int);
  10860. vector unsigned int vec_ctu (vector float, const int);
  10861. vector unsigned long vec_ctu (vector double, const int);
  10862. void vec_dss (const int);
  10863. void vec_dssall (void);
  10864. void vec_dst (const vector unsigned char *, int, const int);
  10865. void vec_dst (const vector signed char *, int, const int);
  10866. void vec_dst (const vector bool char *, int, const int);
  10867. void vec_dst (const vector unsigned short *, int, const int);
  10868. void vec_dst (const vector signed short *, int, const int);
  10869. void vec_dst (const vector bool short *, int, const int);
  10870. void vec_dst (const vector pixel *, int, const int);
  10871. void vec_dst (const vector unsigned int *, int, const int);
  10872. void vec_dst (const vector signed int *, int, const int);
  10873. void vec_dst (const vector bool int *, int, const int);
  10874. void vec_dst (const vector float *, int, const int);
  10875. void vec_dst (const unsigned char *, int, const int);
  10876. void vec_dst (const signed char *, int, const int);
  10877. void vec_dst (const unsigned short *, int, const int);
  10878. void vec_dst (const short *, int, const int);
  10879. void vec_dst (const unsigned int *, int, const int);
  10880. void vec_dst (const int *, int, const int);
  10881. void vec_dst (const unsigned long *, int, const int);
  10882. void vec_dst (const long *, int, const int);
  10883. void vec_dst (const float *, int, const int);
  10884. void vec_dstst (const vector unsigned char *, int, const int);
  10885. void vec_dstst (const vector signed char *, int, const int);
  10886. void vec_dstst (const vector bool char *, int, const int);
  10887. void vec_dstst (const vector unsigned short *, int, const int);
  10888. void vec_dstst (const vector signed short *, int, const int);
  10889. void vec_dstst (const vector bool short *, int, const int);
  10890. void vec_dstst (const vector pixel *, int, const int);
  10891. void vec_dstst (const vector unsigned int *, int, const int);
  10892. void vec_dstst (const vector signed int *, int, const int);
  10893. void vec_dstst (const vector bool int *, int, const int);
  10894. void vec_dstst (const vector float *, int, const int);
  10895. void vec_dstst (const unsigned char *, int, const int);
  10896. void vec_dstst (const signed char *, int, const int);
  10897. void vec_dstst (const unsigned short *, int, const int);
  10898. void vec_dstst (const short *, int, const int);
  10899. void vec_dstst (const unsigned int *, int, const int);
  10900. void vec_dstst (const int *, int, const int);
  10901. void vec_dstst (const unsigned long *, int, const int);
  10902. void vec_dstst (const long *, int, const int);
  10903. void vec_dstst (const float *, int, const int);
  10904. void vec_dststt (const vector unsigned char *, int, const int);
  10905. void vec_dststt (const vector signed char *, int, const int);
  10906. void vec_dststt (const vector bool char *, int, const int);
  10907. void vec_dststt (const vector unsigned short *, int, const int);
  10908. void vec_dststt (const vector signed short *, int, const int);
  10909. void vec_dststt (const vector bool short *, int, const int);
  10910. void vec_dststt (const vector pixel *, int, const int);
  10911. void vec_dststt (const vector unsigned int *, int, const int);
  10912. void vec_dststt (const vector signed int *, int, const int);
  10913. void vec_dststt (const vector bool int *, int, const int);
  10914. void vec_dststt (const vector float *, int, const int);
  10915. void vec_dststt (const unsigned char *, int, const int);
  10916. void vec_dststt (const signed char *, int, const int);
  10917. void vec_dststt (const unsigned short *, int, const int);
  10918. void vec_dststt (const short *, int, const int);
  10919. void vec_dststt (const unsigned int *, int, const int);
  10920. void vec_dststt (const int *, int, const int);
  10921. void vec_dststt (const unsigned long *, int, const int);
  10922. void vec_dststt (const long *, int, const int);
  10923. void vec_dststt (const float *, int, const int);
  10924. void vec_dstt (const vector unsigned char *, int, const int);
  10925. void vec_dstt (const vector signed char *, int, const int);
  10926. void vec_dstt (const vector bool char *, int, const int);
  10927. void vec_dstt (const vector unsigned short *, int, const int);
  10928. void vec_dstt (const vector signed short *, int, const int);
  10929. void vec_dstt (const vector bool short *, int, const int);
  10930. void vec_dstt (const vector pixel *, int, const int);
  10931. void vec_dstt (const vector unsigned int *, int, const int);
  10932. void vec_dstt (const vector signed int *, int, const int);
  10933. void vec_dstt (const vector bool int *, int, const int);
  10934. void vec_dstt (const vector float *, int, const int);
  10935. void vec_dstt (const unsigned char *, int, const int);
  10936. void vec_dstt (const signed char *, int, const int);
  10937. void vec_dstt (const unsigned short *, int, const int);
  10938. void vec_dstt (const short *, int, const int);
  10939. void vec_dstt (const unsigned int *, int, const int);
  10940. void vec_dstt (const int *, int, const int);
  10941. void vec_dstt (const unsigned long *, int, const int);
  10942. void vec_dstt (const long *, int, const int);
  10943. void vec_dstt (const float *, int, const int);
  10944. vector float vec_expte (vector float);
  10945. vector float vec_floor (vector float);
  10946. vector float vec_ld (int, const vector float *);
  10947. vector float vec_ld (int, const float *);
  10948. vector bool int vec_ld (int, const vector bool int *);
  10949. vector signed int vec_ld (int, const vector signed int *);
  10950. vector signed int vec_ld (int, const int *);
  10951. vector signed int vec_ld (int, const long *);
  10952. vector unsigned int vec_ld (int, const vector unsigned int *);
  10953. vector unsigned int vec_ld (int, const unsigned int *);
  10954. vector unsigned int vec_ld (int, const unsigned long *);
  10955. vector bool short vec_ld (int, const vector bool short *);
  10956. vector pixel vec_ld (int, const vector pixel *);
  10957. vector signed short vec_ld (int, const vector signed short *);
  10958. vector signed short vec_ld (int, const short *);
  10959. vector unsigned short vec_ld (int, const vector unsigned short *);
  10960. vector unsigned short vec_ld (int, const unsigned short *);
  10961. vector bool char vec_ld (int, const vector bool char *);
  10962. vector signed char vec_ld (int, const vector signed char *);
  10963. vector signed char vec_ld (int, const signed char *);
  10964. vector unsigned char vec_ld (int, const vector unsigned char *);
  10965. vector unsigned char vec_ld (int, const unsigned char *);
  10966. vector signed char vec_lde (int, const signed char *);
  10967. vector unsigned char vec_lde (int, const unsigned char *);
  10968. vector signed short vec_lde (int, const short *);
  10969. vector unsigned short vec_lde (int, const unsigned short *);
  10970. vector float vec_lde (int, const float *);
  10971. vector signed int vec_lde (int, const int *);
  10972. vector unsigned int vec_lde (int, const unsigned int *);
  10973. vector signed int vec_lde (int, const long *);
  10974. vector unsigned int vec_lde (int, const unsigned long *);
  10975. vector float vec_lvewx (int, float *);
  10976. vector signed int vec_lvewx (int, int *);
  10977. vector unsigned int vec_lvewx (int, unsigned int *);
  10978. vector signed int vec_lvewx (int, long *);
  10979. vector unsigned int vec_lvewx (int, unsigned long *);
  10980. vector signed short vec_lvehx (int, short *);
  10981. vector unsigned short vec_lvehx (int, unsigned short *);
  10982. vector signed char vec_lvebx (int, char *);
  10983. vector unsigned char vec_lvebx (int, unsigned char *);
  10984. vector float vec_ldl (int, const vector float *);
  10985. vector float vec_ldl (int, const float *);
  10986. vector bool int vec_ldl (int, const vector bool int *);
  10987. vector signed int vec_ldl (int, const vector signed int *);
  10988. vector signed int vec_ldl (int, const int *);
  10989. vector signed int vec_ldl (int, const long *);
  10990. vector unsigned int vec_ldl (int, const vector unsigned int *);
  10991. vector unsigned int vec_ldl (int, const unsigned int *);
  10992. vector unsigned int vec_ldl (int, const unsigned long *);
  10993. vector bool short vec_ldl (int, const vector bool short *);
  10994. vector pixel vec_ldl (int, const vector pixel *);
  10995. vector signed short vec_ldl (int, const vector signed short *);
  10996. vector signed short vec_ldl (int, const short *);
  10997. vector unsigned short vec_ldl (int, const vector unsigned short *);
  10998. vector unsigned short vec_ldl (int, const unsigned short *);
  10999. vector bool char vec_ldl (int, const vector bool char *);
  11000. vector signed char vec_ldl (int, const vector signed char *);
  11001. vector signed char vec_ldl (int, const signed char *);
  11002. vector unsigned char vec_ldl (int, const vector unsigned char *);
  11003. vector unsigned char vec_ldl (int, const unsigned char *);
  11004. vector float vec_loge (vector float);
  11005. vector unsigned char vec_lvsl (int, const volatile unsigned char *);
  11006. vector unsigned char vec_lvsl (int, const volatile signed char *);
  11007. vector unsigned char vec_lvsl (int, const volatile unsigned short *);
  11008. vector unsigned char vec_lvsl (int, const volatile short *);
  11009. vector unsigned char vec_lvsl (int, const volatile unsigned int *);
  11010. vector unsigned char vec_lvsl (int, const volatile int *);
  11011. vector unsigned char vec_lvsl (int, const volatile unsigned long *);
  11012. vector unsigned char vec_lvsl (int, const volatile long *);
  11013. vector unsigned char vec_lvsl (int, const volatile float *);
  11014. vector unsigned char vec_lvsr (int, const volatile unsigned char *);
  11015. vector unsigned char vec_lvsr (int, const volatile signed char *);
  11016. vector unsigned char vec_lvsr (int, const volatile unsigned short *);
  11017. vector unsigned char vec_lvsr (int, const volatile short *);
  11018. vector unsigned char vec_lvsr (int, const volatile unsigned int *);
  11019. vector unsigned char vec_lvsr (int, const volatile int *);
  11020. vector unsigned char vec_lvsr (int, const volatile unsigned long *);
  11021. vector unsigned char vec_lvsr (int, const volatile long *);
  11022. vector unsigned char vec_lvsr (int, const volatile float *);
  11023. vector float vec_madd (vector float, vector float, vector float);
  11024. vector signed short vec_madds (vector signed short,
  11025. vector signed short,
  11026. vector signed short);
  11027. vector unsigned char vec_max (vector bool char, vector unsigned char);
  11028. vector unsigned char vec_max (vector unsigned char, vector bool char);
  11029. vector unsigned char vec_max (vector unsigned char,
  11030. vector unsigned char);
  11031. vector signed char vec_max (vector bool char, vector signed char);
  11032. vector signed char vec_max (vector signed char, vector bool char);
  11033. vector signed char vec_max (vector signed char, vector signed char);
  11034. vector unsigned short vec_max (vector bool short,
  11035. vector unsigned short);
  11036. vector unsigned short vec_max (vector unsigned short,
  11037. vector bool short);
  11038. vector unsigned short vec_max (vector unsigned short,
  11039. vector unsigned short);
  11040. vector signed short vec_max (vector bool short, vector signed short);
  11041. vector signed short vec_max (vector signed short, vector bool short);
  11042. vector signed short vec_max (vector signed short, vector signed short);
  11043. vector unsigned int vec_max (vector bool int, vector unsigned int);
  11044. vector unsigned int vec_max (vector unsigned int, vector bool int);
  11045. vector unsigned int vec_max (vector unsigned int, vector unsigned int);
  11046. vector signed int vec_max (vector bool int, vector signed int);
  11047. vector signed int vec_max (vector signed int, vector bool int);
  11048. vector signed int vec_max (vector signed int, vector signed int);
  11049. vector float vec_max (vector float, vector float);
  11050. vector float vec_vmaxfp (vector float, vector float);
  11051. vector signed int vec_vmaxsw (vector bool int, vector signed int);
  11052. vector signed int vec_vmaxsw (vector signed int, vector bool int);
  11053. vector signed int vec_vmaxsw (vector signed int, vector signed int);
  11054. vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
  11055. vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
  11056. vector unsigned int vec_vmaxuw (vector unsigned int,
  11057. vector unsigned int);
  11058. vector signed short vec_vmaxsh (vector bool short, vector signed short);
  11059. vector signed short vec_vmaxsh (vector signed short, vector bool short);
  11060. vector signed short vec_vmaxsh (vector signed short,
  11061. vector signed short);
  11062. vector unsigned short vec_vmaxuh (vector bool short,
  11063. vector unsigned short);
  11064. vector unsigned short vec_vmaxuh (vector unsigned short,
  11065. vector bool short);
  11066. vector unsigned short vec_vmaxuh (vector unsigned short,
  11067. vector unsigned short);
  11068. vector signed char vec_vmaxsb (vector bool char, vector signed char);
  11069. vector signed char vec_vmaxsb (vector signed char, vector bool char);
  11070. vector signed char vec_vmaxsb (vector signed char, vector signed char);
  11071. vector unsigned char vec_vmaxub (vector bool char,
  11072. vector unsigned char);
  11073. vector unsigned char vec_vmaxub (vector unsigned char,
  11074. vector bool char);
  11075. vector unsigned char vec_vmaxub (vector unsigned char,
  11076. vector unsigned char);
  11077. vector bool char vec_mergeh (vector bool char, vector bool char);
  11078. vector signed char vec_mergeh (vector signed char, vector signed char);
  11079. vector unsigned char vec_mergeh (vector unsigned char,
  11080. vector unsigned char);
  11081. vector bool short vec_mergeh (vector bool short, vector bool short);
  11082. vector pixel vec_mergeh (vector pixel, vector pixel);
  11083. vector signed short vec_mergeh (vector signed short,
  11084. vector signed short);
  11085. vector unsigned short vec_mergeh (vector unsigned short,
  11086. vector unsigned short);
  11087. vector float vec_mergeh (vector float, vector float);
  11088. vector bool int vec_mergeh (vector bool int, vector bool int);
  11089. vector signed int vec_mergeh (vector signed int, vector signed int);
  11090. vector unsigned int vec_mergeh (vector unsigned int,
  11091. vector unsigned int);
  11092. vector float vec_vmrghw (vector float, vector float);
  11093. vector bool int vec_vmrghw (vector bool int, vector bool int);
  11094. vector signed int vec_vmrghw (vector signed int, vector signed int);
  11095. vector unsigned int vec_vmrghw (vector unsigned int,
  11096. vector unsigned int);
  11097. vector bool short vec_vmrghh (vector bool short, vector bool short);
  11098. vector signed short vec_vmrghh (vector signed short,
  11099. vector signed short);
  11100. vector unsigned short vec_vmrghh (vector unsigned short,
  11101. vector unsigned short);
  11102. vector pixel vec_vmrghh (vector pixel, vector pixel);
  11103. vector bool char vec_vmrghb (vector bool char, vector bool char);
  11104. vector signed char vec_vmrghb (vector signed char, vector signed char);
  11105. vector unsigned char vec_vmrghb (vector unsigned char,
  11106. vector unsigned char);
  11107. vector bool char vec_mergel (vector bool char, vector bool char);
  11108. vector signed char vec_mergel (vector signed char, vector signed char);
  11109. vector unsigned char vec_mergel (vector unsigned char,
  11110. vector unsigned char);
  11111. vector bool short vec_mergel (vector bool short, vector bool short);
  11112. vector pixel vec_mergel (vector pixel, vector pixel);
  11113. vector signed short vec_mergel (vector signed short,
  11114. vector signed short);
  11115. vector unsigned short vec_mergel (vector unsigned short,
  11116. vector unsigned short);
  11117. vector float vec_mergel (vector float, vector float);
  11118. vector bool int vec_mergel (vector bool int, vector bool int);
  11119. vector signed int vec_mergel (vector signed int, vector signed int);
  11120. vector unsigned int vec_mergel (vector unsigned int,
  11121. vector unsigned int);
  11122. vector float vec_vmrglw (vector float, vector float);
  11123. vector signed int vec_vmrglw (vector signed int, vector signed int);
  11124. vector unsigned int vec_vmrglw (vector unsigned int,
  11125. vector unsigned int);
  11126. vector bool int vec_vmrglw (vector bool int, vector bool int);
  11127. vector bool short vec_vmrglh (vector bool short, vector bool short);
  11128. vector signed short vec_vmrglh (vector signed short,
  11129. vector signed short);
  11130. vector unsigned short vec_vmrglh (vector unsigned short,
  11131. vector unsigned short);
  11132. vector pixel vec_vmrglh (vector pixel, vector pixel);
  11133. vector bool char vec_vmrglb (vector bool char, vector bool char);
  11134. vector signed char vec_vmrglb (vector signed char, vector signed char);
  11135. vector unsigned char vec_vmrglb (vector unsigned char,
  11136. vector unsigned char);
  11137. vector unsigned short vec_mfvscr (void);
  11138. vector unsigned char vec_min (vector bool char, vector unsigned char);
  11139. vector unsigned char vec_min (vector unsigned char, vector bool char);
  11140. vector unsigned char vec_min (vector unsigned char,
  11141. vector unsigned char);
  11142. vector signed char vec_min (vector bool char, vector signed char);
  11143. vector signed char vec_min (vector signed char, vector bool char);
  11144. vector signed char vec_min (vector signed char, vector signed char);
  11145. vector unsigned short vec_min (vector bool short,
  11146. vector unsigned short);
  11147. vector unsigned short vec_min (vector unsigned short,
  11148. vector bool short);
  11149. vector unsigned short vec_min (vector unsigned short,
  11150. vector unsigned short);
  11151. vector signed short vec_min (vector bool short, vector signed short);
  11152. vector signed short vec_min (vector signed short, vector bool short);
  11153. vector signed short vec_min (vector signed short, vector signed short);
  11154. vector unsigned int vec_min (vector bool int, vector unsigned int);
  11155. vector unsigned int vec_min (vector unsigned int, vector bool int);
  11156. vector unsigned int vec_min (vector unsigned int, vector unsigned int);
  11157. vector signed int vec_min (vector bool int, vector signed int);
  11158. vector signed int vec_min (vector signed int, vector bool int);
  11159. vector signed int vec_min (vector signed int, vector signed int);
  11160. vector float vec_min (vector float, vector float);
  11161. vector float vec_vminfp (vector float, vector float);
  11162. vector signed int vec_vminsw (vector bool int, vector signed int);
  11163. vector signed int vec_vminsw (vector signed int, vector bool int);
  11164. vector signed int vec_vminsw (vector signed int, vector signed int);
  11165. vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
  11166. vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
  11167. vector unsigned int vec_vminuw (vector unsigned int,
  11168. vector unsigned int);
  11169. vector signed short vec_vminsh (vector bool short, vector signed short);
  11170. vector signed short vec_vminsh (vector signed short, vector bool short);
  11171. vector signed short vec_vminsh (vector signed short,
  11172. vector signed short);
  11173. vector unsigned short vec_vminuh (vector bool short,
  11174. vector unsigned short);
  11175. vector unsigned short vec_vminuh (vector unsigned short,
  11176. vector bool short);
  11177. vector unsigned short vec_vminuh (vector unsigned short,
  11178. vector unsigned short);
  11179. vector signed char vec_vminsb (vector bool char, vector signed char);
  11180. vector signed char vec_vminsb (vector signed char, vector bool char);
  11181. vector signed char vec_vminsb (vector signed char, vector signed char);
  11182. vector unsigned char vec_vminub (vector bool char,
  11183. vector unsigned char);
  11184. vector unsigned char vec_vminub (vector unsigned char,
  11185. vector bool char);
  11186. vector unsigned char vec_vminub (vector unsigned char,
  11187. vector unsigned char);
  11188. vector signed short vec_mladd (vector signed short,
  11189. vector signed short,
  11190. vector signed short);
  11191. vector signed short vec_mladd (vector signed short,
  11192. vector unsigned short,
  11193. vector unsigned short);
  11194. vector signed short vec_mladd (vector unsigned short,
  11195. vector signed short,
  11196. vector signed short);
  11197. vector unsigned short vec_mladd (vector unsigned short,
  11198. vector unsigned short,
  11199. vector unsigned short);
  11200. vector signed short vec_mradds (vector signed short,
  11201. vector signed short,
  11202. vector signed short);
  11203. vector unsigned int vec_msum (vector unsigned char,
  11204. vector unsigned char,
  11205. vector unsigned int);
  11206. vector signed int vec_msum (vector signed char,
  11207. vector unsigned char,
  11208. vector signed int);
  11209. vector unsigned int vec_msum (vector unsigned short,
  11210. vector unsigned short,
  11211. vector unsigned int);
  11212. vector signed int vec_msum (vector signed short,
  11213. vector signed short,
  11214. vector signed int);
  11215. vector signed int vec_vmsumshm (vector signed short,
  11216. vector signed short,
  11217. vector signed int);
  11218. vector unsigned int vec_vmsumuhm (vector unsigned short,
  11219. vector unsigned short,
  11220. vector unsigned int);
  11221. vector signed int vec_vmsummbm (vector signed char,
  11222. vector unsigned char,
  11223. vector signed int);
  11224. vector unsigned int vec_vmsumubm (vector unsigned char,
  11225. vector unsigned char,
  11226. vector unsigned int);
  11227. vector unsigned int vec_msums (vector unsigned short,
  11228. vector unsigned short,
  11229. vector unsigned int);
  11230. vector signed int vec_msums (vector signed short,
  11231. vector signed short,
  11232. vector signed int);
  11233. vector signed int vec_vmsumshs (vector signed short,
  11234. vector signed short,
  11235. vector signed int);
  11236. vector unsigned int vec_vmsumuhs (vector unsigned short,
  11237. vector unsigned short,
  11238. vector unsigned int);
  11239. void vec_mtvscr (vector signed int);
  11240. void vec_mtvscr (vector unsigned int);
  11241. void vec_mtvscr (vector bool int);
  11242. void vec_mtvscr (vector signed short);
  11243. void vec_mtvscr (vector unsigned short);
  11244. void vec_mtvscr (vector bool short);
  11245. void vec_mtvscr (vector pixel);
  11246. void vec_mtvscr (vector signed char);
  11247. void vec_mtvscr (vector unsigned char);
  11248. void vec_mtvscr (vector bool char);
  11249. vector unsigned short vec_mule (vector unsigned char,
  11250. vector unsigned char);
  11251. vector signed short vec_mule (vector signed char,
  11252. vector signed char);
  11253. vector unsigned int vec_mule (vector unsigned short,
  11254. vector unsigned short);
  11255. vector signed int vec_mule (vector signed short, vector signed short);
  11256. vector signed int vec_vmulesh (vector signed short,
  11257. vector signed short);
  11258. vector unsigned int vec_vmuleuh (vector unsigned short,
  11259. vector unsigned short);
  11260. vector signed short vec_vmulesb (vector signed char,
  11261. vector signed char);
  11262. vector unsigned short vec_vmuleub (vector unsigned char,
  11263. vector unsigned char);
  11264. vector unsigned short vec_mulo (vector unsigned char,
  11265. vector unsigned char);
  11266. vector signed short vec_mulo (vector signed char, vector signed char);
  11267. vector unsigned int vec_mulo (vector unsigned short,
  11268. vector unsigned short);
  11269. vector signed int vec_mulo (vector signed short, vector signed short);
  11270. vector signed int vec_vmulosh (vector signed short,
  11271. vector signed short);
  11272. vector unsigned int vec_vmulouh (vector unsigned short,
  11273. vector unsigned short);
  11274. vector signed short vec_vmulosb (vector signed char,
  11275. vector signed char);
  11276. vector unsigned short vec_vmuloub (vector unsigned char,
  11277. vector unsigned char);
  11278. vector float vec_nmsub (vector float, vector float, vector float);
  11279. vector float vec_nor (vector float, vector float);
  11280. vector signed int vec_nor (vector signed int, vector signed int);
  11281. vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
  11282. vector bool int vec_nor (vector bool int, vector bool int);
  11283. vector signed short vec_nor (vector signed short, vector signed short);
  11284. vector unsigned short vec_nor (vector unsigned short,
  11285. vector unsigned short);
  11286. vector bool short vec_nor (vector bool short, vector bool short);
  11287. vector signed char vec_nor (vector signed char, vector signed char);
  11288. vector unsigned char vec_nor (vector unsigned char,
  11289. vector unsigned char);
  11290. vector bool char vec_nor (vector bool char, vector bool char);
  11291. vector float vec_or (vector float, vector float);
  11292. vector float vec_or (vector float, vector bool int);
  11293. vector float vec_or (vector bool int, vector float);
  11294. vector bool int vec_or (vector bool int, vector bool int);
  11295. vector signed int vec_or (vector bool int, vector signed int);
  11296. vector signed int vec_or (vector signed int, vector bool int);
  11297. vector signed int vec_or (vector signed int, vector signed int);
  11298. vector unsigned int vec_or (vector bool int, vector unsigned int);
  11299. vector unsigned int vec_or (vector unsigned int, vector bool int);
  11300. vector unsigned int vec_or (vector unsigned int, vector unsigned int);
  11301. vector bool short vec_or (vector bool short, vector bool short);
  11302. vector signed short vec_or (vector bool short, vector signed short);
  11303. vector signed short vec_or (vector signed short, vector bool short);
  11304. vector signed short vec_or (vector signed short, vector signed short);
  11305. vector unsigned short vec_or (vector bool short, vector unsigned short);
  11306. vector unsigned short vec_or (vector unsigned short, vector bool short);
  11307. vector unsigned short vec_or (vector unsigned short,
  11308. vector unsigned short);
  11309. vector signed char vec_or (vector bool char, vector signed char);
  11310. vector bool char vec_or (vector bool char, vector bool char);
  11311. vector signed char vec_or (vector signed char, vector bool char);
  11312. vector signed char vec_or (vector signed char, vector signed char);
  11313. vector unsigned char vec_or (vector bool char, vector unsigned char);
  11314. vector unsigned char vec_or (vector unsigned char, vector bool char);
  11315. vector unsigned char vec_or (vector unsigned char,
  11316. vector unsigned char);
  11317. vector signed char vec_pack (vector signed short, vector signed short);
  11318. vector unsigned char vec_pack (vector unsigned short,
  11319. vector unsigned short);
  11320. vector bool char vec_pack (vector bool short, vector bool short);
  11321. vector signed short vec_pack (vector signed int, vector signed int);
  11322. vector unsigned short vec_pack (vector unsigned int,
  11323. vector unsigned int);
  11324. vector bool short vec_pack (vector bool int, vector bool int);
  11325. vector bool short vec_vpkuwum (vector bool int, vector bool int);
  11326. vector signed short vec_vpkuwum (vector signed int, vector signed int);
  11327. vector unsigned short vec_vpkuwum (vector unsigned int,
  11328. vector unsigned int);
  11329. vector bool char vec_vpkuhum (vector bool short, vector bool short);
  11330. vector signed char vec_vpkuhum (vector signed short,
  11331. vector signed short);
  11332. vector unsigned char vec_vpkuhum (vector unsigned short,
  11333. vector unsigned short);
  11334. vector pixel vec_packpx (vector unsigned int, vector unsigned int);
  11335. vector unsigned char vec_packs (vector unsigned short,
  11336. vector unsigned short);
  11337. vector signed char vec_packs (vector signed short, vector signed short);
  11338. vector unsigned short vec_packs (vector unsigned int,
  11339. vector unsigned int);
  11340. vector signed short vec_packs (vector signed int, vector signed int);
  11341. vector signed short vec_vpkswss (vector signed int, vector signed int);
  11342. vector unsigned short vec_vpkuwus (vector unsigned int,
  11343. vector unsigned int);
  11344. vector signed char vec_vpkshss (vector signed short,
  11345. vector signed short);
  11346. vector unsigned char vec_vpkuhus (vector unsigned short,
  11347. vector unsigned short);
  11348. vector unsigned char vec_packsu (vector unsigned short,
  11349. vector unsigned short);
  11350. vector unsigned char vec_packsu (vector signed short,
  11351. vector signed short);
  11352. vector unsigned short vec_packsu (vector unsigned int,
  11353. vector unsigned int);
  11354. vector unsigned short vec_packsu (vector signed int, vector signed int);
  11355. vector unsigned short vec_vpkswus (vector signed int,
  11356. vector signed int);
  11357. vector unsigned char vec_vpkshus (vector signed short,
  11358. vector signed short);
  11359. vector float vec_perm (vector float,
  11360. vector float,
  11361. vector unsigned char);
  11362. vector signed int vec_perm (vector signed int,
  11363. vector signed int,
  11364. vector unsigned char);
  11365. vector unsigned int vec_perm (vector unsigned int,
  11366. vector unsigned int,
  11367. vector unsigned char);
  11368. vector bool int vec_perm (vector bool int,
  11369. vector bool int,
  11370. vector unsigned char);
  11371. vector signed short vec_perm (vector signed short,
  11372. vector signed short,
  11373. vector unsigned char);
  11374. vector unsigned short vec_perm (vector unsigned short,
  11375. vector unsigned short,
  11376. vector unsigned char);
  11377. vector bool short vec_perm (vector bool short,
  11378. vector bool short,
  11379. vector unsigned char);
  11380. vector pixel vec_perm (vector pixel,
  11381. vector pixel,
  11382. vector unsigned char);
  11383. vector signed char vec_perm (vector signed char,
  11384. vector signed char,
  11385. vector unsigned char);
  11386. vector unsigned char vec_perm (vector unsigned char,
  11387. vector unsigned char,
  11388. vector unsigned char);
  11389. vector bool char vec_perm (vector bool char,
  11390. vector bool char,
  11391. vector unsigned char);
  11392. vector float vec_re (vector float);
  11393. vector signed char vec_rl (vector signed char,
  11394. vector unsigned char);
  11395. vector unsigned char vec_rl (vector unsigned char,
  11396. vector unsigned char);
  11397. vector signed short vec_rl (vector signed short, vector unsigned short);
  11398. vector unsigned short vec_rl (vector unsigned short,
  11399. vector unsigned short);
  11400. vector signed int vec_rl (vector signed int, vector unsigned int);
  11401. vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
  11402. vector signed int vec_vrlw (vector signed int, vector unsigned int);
  11403. vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
  11404. vector signed short vec_vrlh (vector signed short,
  11405. vector unsigned short);
  11406. vector unsigned short vec_vrlh (vector unsigned short,
  11407. vector unsigned short);
  11408. vector signed char vec_vrlb (vector signed char, vector unsigned char);
  11409. vector unsigned char vec_vrlb (vector unsigned char,
  11410. vector unsigned char);
  11411. vector float vec_round (vector float);
  11412. vector float vec_recip (vector float, vector float);
  11413. vector float vec_rsqrt (vector float);
  11414. vector float vec_rsqrte (vector float);
  11415. vector float vec_sel (vector float, vector float, vector bool int);
  11416. vector float vec_sel (vector float, vector float, vector unsigned int);
  11417. vector signed int vec_sel (vector signed int,
  11418. vector signed int,
  11419. vector bool int);
  11420. vector signed int vec_sel (vector signed int,
  11421. vector signed int,
  11422. vector unsigned int);
  11423. vector unsigned int vec_sel (vector unsigned int,
  11424. vector unsigned int,
  11425. vector bool int);
  11426. vector unsigned int vec_sel (vector unsigned int,
  11427. vector unsigned int,
  11428. vector unsigned int);
  11429. vector bool int vec_sel (vector bool int,
  11430. vector bool int,
  11431. vector bool int);
  11432. vector bool int vec_sel (vector bool int,
  11433. vector bool int,
  11434. vector unsigned int);
  11435. vector signed short vec_sel (vector signed short,
  11436. vector signed short,
  11437. vector bool short);
  11438. vector signed short vec_sel (vector signed short,
  11439. vector signed short,
  11440. vector unsigned short);
  11441. vector unsigned short vec_sel (vector unsigned short,
  11442. vector unsigned short,
  11443. vector bool short);
  11444. vector unsigned short vec_sel (vector unsigned short,
  11445. vector unsigned short,
  11446. vector unsigned short);
  11447. vector bool short vec_sel (vector bool short,
  11448. vector bool short,
  11449. vector bool short);
  11450. vector bool short vec_sel (vector bool short,
  11451. vector bool short,
  11452. vector unsigned short);
  11453. vector signed char vec_sel (vector signed char,
  11454. vector signed char,
  11455. vector bool char);
  11456. vector signed char vec_sel (vector signed char,
  11457. vector signed char,
  11458. vector unsigned char);
  11459. vector unsigned char vec_sel (vector unsigned char,
  11460. vector unsigned char,
  11461. vector bool char);
  11462. vector unsigned char vec_sel (vector unsigned char,
  11463. vector unsigned char,
  11464. vector unsigned char);
  11465. vector bool char vec_sel (vector bool char,
  11466. vector bool char,
  11467. vector bool char);
  11468. vector bool char vec_sel (vector bool char,
  11469. vector bool char,
  11470. vector unsigned char);
  11471. vector signed char vec_sl (vector signed char,
  11472. vector unsigned char);
  11473. vector unsigned char vec_sl (vector unsigned char,
  11474. vector unsigned char);
  11475. vector signed short vec_sl (vector signed short, vector unsigned short);
  11476. vector unsigned short vec_sl (vector unsigned short,
  11477. vector unsigned short);
  11478. vector signed int vec_sl (vector signed int, vector unsigned int);
  11479. vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
  11480. vector signed int vec_vslw (vector signed int, vector unsigned int);
  11481. vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
  11482. vector signed short vec_vslh (vector signed short,
  11483. vector unsigned short);
  11484. vector unsigned short vec_vslh (vector unsigned short,
  11485. vector unsigned short);
  11486. vector signed char vec_vslb (vector signed char, vector unsigned char);
  11487. vector unsigned char vec_vslb (vector unsigned char,
  11488. vector unsigned char);
  11489. vector float vec_sld (vector float, vector float, const int);
  11490. vector signed int vec_sld (vector signed int,
  11491. vector signed int,
  11492. const int);
  11493. vector unsigned int vec_sld (vector unsigned int,
  11494. vector unsigned int,
  11495. const int);
  11496. vector bool int vec_sld (vector bool int,
  11497. vector bool int,
  11498. const int);
  11499. vector signed short vec_sld (vector signed short,
  11500. vector signed short,
  11501. const int);
  11502. vector unsigned short vec_sld (vector unsigned short,
  11503. vector unsigned short,
  11504. const int);
  11505. vector bool short vec_sld (vector bool short,
  11506. vector bool short,
  11507. const int);
  11508. vector pixel vec_sld (vector pixel,
  11509. vector pixel,
  11510. const int);
  11511. vector signed char vec_sld (vector signed char,
  11512. vector signed char,
  11513. const int);
  11514. vector unsigned char vec_sld (vector unsigned char,
  11515. vector unsigned char,
  11516. const int);
  11517. vector bool char vec_sld (vector bool char,
  11518. vector bool char,
  11519. const int);
  11520. vector signed int vec_sll (vector signed int,
  11521. vector unsigned int);
  11522. vector signed int vec_sll (vector signed int,
  11523. vector unsigned short);
  11524. vector signed int vec_sll (vector signed int,
  11525. vector unsigned char);
  11526. vector unsigned int vec_sll (vector unsigned int,
  11527. vector unsigned int);
  11528. vector unsigned int vec_sll (vector unsigned int,
  11529. vector unsigned short);
  11530. vector unsigned int vec_sll (vector unsigned int,
  11531. vector unsigned char);
  11532. vector bool int vec_sll (vector bool int,
  11533. vector unsigned int);
  11534. vector bool int vec_sll (vector bool int,
  11535. vector unsigned short);
  11536. vector bool int vec_sll (vector bool int,
  11537. vector unsigned char);
  11538. vector signed short vec_sll (vector signed short,
  11539. vector unsigned int);
  11540. vector signed short vec_sll (vector signed short,
  11541. vector unsigned short);
  11542. vector signed short vec_sll (vector signed short,
  11543. vector unsigned char);
  11544. vector unsigned short vec_sll (vector unsigned short,
  11545. vector unsigned int);
  11546. vector unsigned short vec_sll (vector unsigned short,
  11547. vector unsigned short);
  11548. vector unsigned short vec_sll (vector unsigned short,
  11549. vector unsigned char);
  11550. vector bool short vec_sll (vector bool short, vector unsigned int);
  11551. vector bool short vec_sll (vector bool short, vector unsigned short);
  11552. vector bool short vec_sll (vector bool short, vector unsigned char);
  11553. vector pixel vec_sll (vector pixel, vector unsigned int);
  11554. vector pixel vec_sll (vector pixel, vector unsigned short);
  11555. vector pixel vec_sll (vector pixel, vector unsigned char);
  11556. vector signed char vec_sll (vector signed char, vector unsigned int);
  11557. vector signed char vec_sll (vector signed char, vector unsigned short);
  11558. vector signed char vec_sll (vector signed char, vector unsigned char);
  11559. vector unsigned char vec_sll (vector unsigned char,
  11560. vector unsigned int);
  11561. vector unsigned char vec_sll (vector unsigned char,
  11562. vector unsigned short);
  11563. vector unsigned char vec_sll (vector unsigned char,
  11564. vector unsigned char);
  11565. vector bool char vec_sll (vector bool char, vector unsigned int);
  11566. vector bool char vec_sll (vector bool char, vector unsigned short);
  11567. vector bool char vec_sll (vector bool char, vector unsigned char);
  11568. vector float vec_slo (vector float, vector signed char);
  11569. vector float vec_slo (vector float, vector unsigned char);
  11570. vector signed int vec_slo (vector signed int, vector signed char);
  11571. vector signed int vec_slo (vector signed int, vector unsigned char);
  11572. vector unsigned int vec_slo (vector unsigned int, vector signed char);
  11573. vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
  11574. vector signed short vec_slo (vector signed short, vector signed char);
  11575. vector signed short vec_slo (vector signed short, vector unsigned char);
  11576. vector unsigned short vec_slo (vector unsigned short,
  11577. vector signed char);
  11578. vector unsigned short vec_slo (vector unsigned short,
  11579. vector unsigned char);
  11580. vector pixel vec_slo (vector pixel, vector signed char);
  11581. vector pixel vec_slo (vector pixel, vector unsigned char);
  11582. vector signed char vec_slo (vector signed char, vector signed char);
  11583. vector signed char vec_slo (vector signed char, vector unsigned char);
  11584. vector unsigned char vec_slo (vector unsigned char, vector signed char);
  11585. vector unsigned char vec_slo (vector unsigned char,
  11586. vector unsigned char);
  11587. vector signed char vec_splat (vector signed char, const int);
  11588. vector unsigned char vec_splat (vector unsigned char, const int);
  11589. vector bool char vec_splat (vector bool char, const int);
  11590. vector signed short vec_splat (vector signed short, const int);
  11591. vector unsigned short vec_splat (vector unsigned short, const int);
  11592. vector bool short vec_splat (vector bool short, const int);
  11593. vector pixel vec_splat (vector pixel, const int);
  11594. vector float vec_splat (vector float, const int);
  11595. vector signed int vec_splat (vector signed int, const int);
  11596. vector unsigned int vec_splat (vector unsigned int, const int);
  11597. vector bool int vec_splat (vector bool int, const int);
  11598. vector signed long vec_splat (vector signed long, const int);
  11599. vector unsigned long vec_splat (vector unsigned long, const int);
  11600. vector signed char vec_splats (signed char);
  11601. vector unsigned char vec_splats (unsigned char);
  11602. vector signed short vec_splats (signed short);
  11603. vector unsigned short vec_splats (unsigned short);
  11604. vector signed int vec_splats (signed int);
  11605. vector unsigned int vec_splats (unsigned int);
  11606. vector float vec_splats (float);
  11607. vector float vec_vspltw (vector float, const int);
  11608. vector signed int vec_vspltw (vector signed int, const int);
  11609. vector unsigned int vec_vspltw (vector unsigned int, const int);
  11610. vector bool int vec_vspltw (vector bool int, const int);
  11611. vector bool short vec_vsplth (vector bool short, const int);
  11612. vector signed short vec_vsplth (vector signed short, const int);
  11613. vector unsigned short vec_vsplth (vector unsigned short, const int);
  11614. vector pixel vec_vsplth (vector pixel, const int);
  11615. vector signed char vec_vspltb (vector signed char, const int);
  11616. vector unsigned char vec_vspltb (vector unsigned char, const int);
  11617. vector bool char vec_vspltb (vector bool char, const int);
  11618. vector signed char vec_splat_s8 (const int);
  11619. vector signed short vec_splat_s16 (const int);
  11620. vector signed int vec_splat_s32 (const int);
  11621. vector unsigned char vec_splat_u8 (const int);
  11622. vector unsigned short vec_splat_u16 (const int);
  11623. vector unsigned int vec_splat_u32 (const int);
  11624. vector signed char vec_sr (vector signed char, vector unsigned char);
  11625. vector unsigned char vec_sr (vector unsigned char,
  11626. vector unsigned char);
  11627. vector signed short vec_sr (vector signed short,
  11628. vector unsigned short);
  11629. vector unsigned short vec_sr (vector unsigned short,
  11630. vector unsigned short);
  11631. vector signed int vec_sr (vector signed int, vector unsigned int);
  11632. vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
  11633. vector signed int vec_vsrw (vector signed int, vector unsigned int);
  11634. vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
  11635. vector signed short vec_vsrh (vector signed short,
  11636. vector unsigned short);
  11637. vector unsigned short vec_vsrh (vector unsigned short,
  11638. vector unsigned short);
  11639. vector signed char vec_vsrb (vector signed char, vector unsigned char);
  11640. vector unsigned char vec_vsrb (vector unsigned char,
  11641. vector unsigned char);
  11642. vector signed char vec_sra (vector signed char, vector unsigned char);
  11643. vector unsigned char vec_sra (vector unsigned char,
  11644. vector unsigned char);
  11645. vector signed short vec_sra (vector signed short,
  11646. vector unsigned short);
  11647. vector unsigned short vec_sra (vector unsigned short,
  11648. vector unsigned short);
  11649. vector signed int vec_sra (vector signed int, vector unsigned int);
  11650. vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
  11651. vector signed int vec_vsraw (vector signed int, vector unsigned int);
  11652. vector unsigned int vec_vsraw (vector unsigned int,
  11653. vector unsigned int);
  11654. vector signed short vec_vsrah (vector signed short,
  11655. vector unsigned short);
  11656. vector unsigned short vec_vsrah (vector unsigned short,
  11657. vector unsigned short);
  11658. vector signed char vec_vsrab (vector signed char, vector unsigned char);
  11659. vector unsigned char vec_vsrab (vector unsigned char,
  11660. vector unsigned char);
  11661. vector signed int vec_srl (vector signed int, vector unsigned int);
  11662. vector signed int vec_srl (vector signed int, vector unsigned short);
  11663. vector signed int vec_srl (vector signed int, vector unsigned char);
  11664. vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
  11665. vector unsigned int vec_srl (vector unsigned int,
  11666. vector unsigned short);
  11667. vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
  11668. vector bool int vec_srl (vector bool int, vector unsigned int);
  11669. vector bool int vec_srl (vector bool int, vector unsigned short);
  11670. vector bool int vec_srl (vector bool int, vector unsigned char);
  11671. vector signed short vec_srl (vector signed short, vector unsigned int);
  11672. vector signed short vec_srl (vector signed short,
  11673. vector unsigned short);
  11674. vector signed short vec_srl (vector signed short, vector unsigned char);
  11675. vector unsigned short vec_srl (vector unsigned short,
  11676. vector unsigned int);
  11677. vector unsigned short vec_srl (vector unsigned short,
  11678. vector unsigned short);
  11679. vector unsigned short vec_srl (vector unsigned short,
  11680. vector unsigned char);
  11681. vector bool short vec_srl (vector bool short, vector unsigned int);
  11682. vector bool short vec_srl (vector bool short, vector unsigned short);
  11683. vector bool short vec_srl (vector bool short, vector unsigned char);
  11684. vector pixel vec_srl (vector pixel, vector unsigned int);
  11685. vector pixel vec_srl (vector pixel, vector unsigned short);
  11686. vector pixel vec_srl (vector pixel, vector unsigned char);
  11687. vector signed char vec_srl (vector signed char, vector unsigned int);
  11688. vector signed char vec_srl (vector signed char, vector unsigned short);
  11689. vector signed char vec_srl (vector signed char, vector unsigned char);
  11690. vector unsigned char vec_srl (vector unsigned char,
  11691. vector unsigned int);
  11692. vector unsigned char vec_srl (vector unsigned char,
  11693. vector unsigned short);
  11694. vector unsigned char vec_srl (vector unsigned char,
  11695. vector unsigned char);
  11696. vector bool char vec_srl (vector bool char, vector unsigned int);
  11697. vector bool char vec_srl (vector bool char, vector unsigned short);
  11698. vector bool char vec_srl (vector bool char, vector unsigned char);
  11699. vector float vec_sro (vector float, vector signed char);
  11700. vector float vec_sro (vector float, vector unsigned char);
  11701. vector signed int vec_sro (vector signed int, vector signed char);
  11702. vector signed int vec_sro (vector signed int, vector unsigned char);
  11703. vector unsigned int vec_sro (vector unsigned int, vector signed char);
  11704. vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
  11705. vector signed short vec_sro (vector signed short, vector signed char);
  11706. vector signed short vec_sro (vector signed short, vector unsigned char);
  11707. vector unsigned short vec_sro (vector unsigned short,
  11708. vector signed char);
  11709. vector unsigned short vec_sro (vector unsigned short,
  11710. vector unsigned char);
  11711. vector pixel vec_sro (vector pixel, vector signed char);
  11712. vector pixel vec_sro (vector pixel, vector unsigned char);
  11713. vector signed char vec_sro (vector signed char, vector signed char);
  11714. vector signed char vec_sro (vector signed char, vector unsigned char);
  11715. vector unsigned char vec_sro (vector unsigned char, vector signed char);
  11716. vector unsigned char vec_sro (vector unsigned char,
  11717. vector unsigned char);
  11718. void vec_st (vector float, int, vector float *);
  11719. void vec_st (vector float, int, float *);
  11720. void vec_st (vector signed int, int, vector signed int *);
  11721. void vec_st (vector signed int, int, int *);
  11722. void vec_st (vector unsigned int, int, vector unsigned int *);
  11723. void vec_st (vector unsigned int, int, unsigned int *);
  11724. void vec_st (vector bool int, int, vector bool int *);
  11725. void vec_st (vector bool int, int, unsigned int *);
  11726. void vec_st (vector bool int, int, int *);
  11727. void vec_st (vector signed short, int, vector signed short *);
  11728. void vec_st (vector signed short, int, short *);
  11729. void vec_st (vector unsigned short, int, vector unsigned short *);
  11730. void vec_st (vector unsigned short, int, unsigned short *);
  11731. void vec_st (vector bool short, int, vector bool short *);
  11732. void vec_st (vector bool short, int, unsigned short *);
  11733. void vec_st (vector pixel, int, vector pixel *);
  11734. void vec_st (vector pixel, int, unsigned short *);
  11735. void vec_st (vector pixel, int, short *);
  11736. void vec_st (vector bool short, int, short *);
  11737. void vec_st (vector signed char, int, vector signed char *);
  11738. void vec_st (vector signed char, int, signed char *);
  11739. void vec_st (vector unsigned char, int, vector unsigned char *);
  11740. void vec_st (vector unsigned char, int, unsigned char *);
  11741. void vec_st (vector bool char, int, vector bool char *);
  11742. void vec_st (vector bool char, int, unsigned char *);
  11743. void vec_st (vector bool char, int, signed char *);
  11744. void vec_ste (vector signed char, int, signed char *);
  11745. void vec_ste (vector unsigned char, int, unsigned char *);
  11746. void vec_ste (vector bool char, int, signed char *);
  11747. void vec_ste (vector bool char, int, unsigned char *);
  11748. void vec_ste (vector signed short, int, short *);
  11749. void vec_ste (vector unsigned short, int, unsigned short *);
  11750. void vec_ste (vector bool short, int, short *);
  11751. void vec_ste (vector bool short, int, unsigned short *);
  11752. void vec_ste (vector pixel, int, short *);
  11753. void vec_ste (vector pixel, int, unsigned short *);
  11754. void vec_ste (vector float, int, float *);
  11755. void vec_ste (vector signed int, int, int *);
  11756. void vec_ste (vector unsigned int, int, unsigned int *);
  11757. void vec_ste (vector bool int, int, int *);
  11758. void vec_ste (vector bool int, int, unsigned int *);
  11759. void vec_stvewx (vector float, int, float *);
  11760. void vec_stvewx (vector signed int, int, int *);
  11761. void vec_stvewx (vector unsigned int, int, unsigned int *);
  11762. void vec_stvewx (vector bool int, int, int *);
  11763. void vec_stvewx (vector bool int, int, unsigned int *);
  11764. void vec_stvehx (vector signed short, int, short *);
  11765. void vec_stvehx (vector unsigned short, int, unsigned short *);
  11766. void vec_stvehx (vector bool short, int, short *);
  11767. void vec_stvehx (vector bool short, int, unsigned short *);
  11768. void vec_stvehx (vector pixel, int, short *);
  11769. void vec_stvehx (vector pixel, int, unsigned short *);
  11770. void vec_stvebx (vector signed char, int, signed char *);
  11771. void vec_stvebx (vector unsigned char, int, unsigned char *);
  11772. void vec_stvebx (vector bool char, int, signed char *);
  11773. void vec_stvebx (vector bool char, int, unsigned char *);
  11774. void vec_stl (vector float, int, vector float *);
  11775. void vec_stl (vector float, int, float *);
  11776. void vec_stl (vector signed int, int, vector signed int *);
  11777. void vec_stl (vector signed int, int, int *);
  11778. void vec_stl (vector unsigned int, int, vector unsigned int *);
  11779. void vec_stl (vector unsigned int, int, unsigned int *);
  11780. void vec_stl (vector bool int, int, vector bool int *);
  11781. void vec_stl (vector bool int, int, unsigned int *);
  11782. void vec_stl (vector bool int, int, int *);
  11783. void vec_stl (vector signed short, int, vector signed short *);
  11784. void vec_stl (vector signed short, int, short *);
  11785. void vec_stl (vector unsigned short, int, vector unsigned short *);
  11786. void vec_stl (vector unsigned short, int, unsigned short *);
  11787. void vec_stl (vector bool short, int, vector bool short *);
  11788. void vec_stl (vector bool short, int, unsigned short *);
  11789. void vec_stl (vector bool short, int, short *);
  11790. void vec_stl (vector pixel, int, vector pixel *);
  11791. void vec_stl (vector pixel, int, unsigned short *);
  11792. void vec_stl (vector pixel, int, short *);
  11793. void vec_stl (vector signed char, int, vector signed char *);
  11794. void vec_stl (vector signed char, int, signed char *);
  11795. void vec_stl (vector unsigned char, int, vector unsigned char *);
  11796. void vec_stl (vector unsigned char, int, unsigned char *);
  11797. void vec_stl (vector bool char, int, vector bool char *);
  11798. void vec_stl (vector bool char, int, unsigned char *);
  11799. void vec_stl (vector bool char, int, signed char *);
  11800. vector signed char vec_sub (vector bool char, vector signed char);
  11801. vector signed char vec_sub (vector signed char, vector bool char);
  11802. vector signed char vec_sub (vector signed char, vector signed char);
  11803. vector unsigned char vec_sub (vector bool char, vector unsigned char);
  11804. vector unsigned char vec_sub (vector unsigned char, vector bool char);
  11805. vector unsigned char vec_sub (vector unsigned char,
  11806. vector unsigned char);
  11807. vector signed short vec_sub (vector bool short, vector signed short);
  11808. vector signed short vec_sub (vector signed short, vector bool short);
  11809. vector signed short vec_sub (vector signed short, vector signed short);
  11810. vector unsigned short vec_sub (vector bool short,
  11811. vector unsigned short);
  11812. vector unsigned short vec_sub (vector unsigned short,
  11813. vector bool short);
  11814. vector unsigned short vec_sub (vector unsigned short,
  11815. vector unsigned short);
  11816. vector signed int vec_sub (vector bool int, vector signed int);
  11817. vector signed int vec_sub (vector signed int, vector bool int);
  11818. vector signed int vec_sub (vector signed int, vector signed int);
  11819. vector unsigned int vec_sub (vector bool int, vector unsigned int);
  11820. vector unsigned int vec_sub (vector unsigned int, vector bool int);
  11821. vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
  11822. vector float vec_sub (vector float, vector float);
  11823. vector float vec_vsubfp (vector float, vector float);
  11824. vector signed int vec_vsubuwm (vector bool int, vector signed int);
  11825. vector signed int vec_vsubuwm (vector signed int, vector bool int);
  11826. vector signed int vec_vsubuwm (vector signed int, vector signed int);
  11827. vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
  11828. vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
  11829. vector unsigned int vec_vsubuwm (vector unsigned int,
  11830. vector unsigned int);
  11831. vector signed short vec_vsubuhm (vector bool short,
  11832. vector signed short);
  11833. vector signed short vec_vsubuhm (vector signed short,
  11834. vector bool short);
  11835. vector signed short vec_vsubuhm (vector signed short,
  11836. vector signed short);
  11837. vector unsigned short vec_vsubuhm (vector bool short,
  11838. vector unsigned short);
  11839. vector unsigned short vec_vsubuhm (vector unsigned short,
  11840. vector bool short);
  11841. vector unsigned short vec_vsubuhm (vector unsigned short,
  11842. vector unsigned short);
  11843. vector signed char vec_vsububm (vector bool char, vector signed char);
  11844. vector signed char vec_vsububm (vector signed char, vector bool char);
  11845. vector signed char vec_vsububm (vector signed char, vector signed char);
  11846. vector unsigned char vec_vsububm (vector bool char,
  11847. vector unsigned char);
  11848. vector unsigned char vec_vsububm (vector unsigned char,
  11849. vector bool char);
  11850. vector unsigned char vec_vsububm (vector unsigned char,
  11851. vector unsigned char);
  11852. vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
  11853. vector unsigned char vec_subs (vector bool char, vector unsigned char);
  11854. vector unsigned char vec_subs (vector unsigned char, vector bool char);
  11855. vector unsigned char vec_subs (vector unsigned char,
  11856. vector unsigned char);
  11857. vector signed char vec_subs (vector bool char, vector signed char);
  11858. vector signed char vec_subs (vector signed char, vector bool char);
  11859. vector signed char vec_subs (vector signed char, vector signed char);
  11860. vector unsigned short vec_subs (vector bool short,
  11861. vector unsigned short);
  11862. vector unsigned short vec_subs (vector unsigned short,
  11863. vector bool short);
  11864. vector unsigned short vec_subs (vector unsigned short,
  11865. vector unsigned short);
  11866. vector signed short vec_subs (vector bool short, vector signed short);
  11867. vector signed short vec_subs (vector signed short, vector bool short);
  11868. vector signed short vec_subs (vector signed short, vector signed short);
  11869. vector unsigned int vec_subs (vector bool int, vector unsigned int);
  11870. vector unsigned int vec_subs (vector unsigned int, vector bool int);
  11871. vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
  11872. vector signed int vec_subs (vector bool int, vector signed int);
  11873. vector signed int vec_subs (vector signed int, vector bool int);
  11874. vector signed int vec_subs (vector signed int, vector signed int);
  11875. vector signed int vec_vsubsws (vector bool int, vector signed int);
  11876. vector signed int vec_vsubsws (vector signed int, vector bool int);
  11877. vector signed int vec_vsubsws (vector signed int, vector signed int);
  11878. vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
  11879. vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
  11880. vector unsigned int vec_vsubuws (vector unsigned int,
  11881. vector unsigned int);
  11882. vector signed short vec_vsubshs (vector bool short,
  11883. vector signed short);
  11884. vector signed short vec_vsubshs (vector signed short,
  11885. vector bool short);
  11886. vector signed short vec_vsubshs (vector signed short,
  11887. vector signed short);
  11888. vector unsigned short vec_vsubuhs (vector bool short,
  11889. vector unsigned short);
  11890. vector unsigned short vec_vsubuhs (vector unsigned short,
  11891. vector bool short);
  11892. vector unsigned short vec_vsubuhs (vector unsigned short,
  11893. vector unsigned short);
  11894. vector signed char vec_vsubsbs (vector bool char, vector signed char);
  11895. vector signed char vec_vsubsbs (vector signed char, vector bool char);
  11896. vector signed char vec_vsubsbs (vector signed char, vector signed char);
  11897. vector unsigned char vec_vsububs (vector bool char,
  11898. vector unsigned char);
  11899. vector unsigned char vec_vsububs (vector unsigned char,
  11900. vector bool char);
  11901. vector unsigned char vec_vsububs (vector unsigned char,
  11902. vector unsigned char);
  11903. vector unsigned int vec_sum4s (vector unsigned char,
  11904. vector unsigned int);
  11905. vector signed int vec_sum4s (vector signed char, vector signed int);
  11906. vector signed int vec_sum4s (vector signed short, vector signed int);
  11907. vector signed int vec_vsum4shs (vector signed short, vector signed int);
  11908. vector signed int vec_vsum4sbs (vector signed char, vector signed int);
  11909. vector unsigned int vec_vsum4ubs (vector unsigned char,
  11910. vector unsigned int);
  11911. vector signed int vec_sum2s (vector signed int, vector signed int);
  11912. vector signed int vec_sums (vector signed int, vector signed int);
  11913. vector float vec_trunc (vector float);
  11914. vector signed short vec_unpackh (vector signed char);
  11915. vector bool short vec_unpackh (vector bool char);
  11916. vector signed int vec_unpackh (vector signed short);
  11917. vector bool int vec_unpackh (vector bool short);
  11918. vector unsigned int vec_unpackh (vector pixel);
  11919. vector bool int vec_vupkhsh (vector bool short);
  11920. vector signed int vec_vupkhsh (vector signed short);
  11921. vector unsigned int vec_vupkhpx (vector pixel);
  11922. vector bool short vec_vupkhsb (vector bool char);
  11923. vector signed short vec_vupkhsb (vector signed char);
  11924. vector signed short vec_unpackl (vector signed char);
  11925. vector bool short vec_unpackl (vector bool char);
  11926. vector unsigned int vec_unpackl (vector pixel);
  11927. vector signed int vec_unpackl (vector signed short);
  11928. vector bool int vec_unpackl (vector bool short);
  11929. vector unsigned int vec_vupklpx (vector pixel);
  11930. vector bool int vec_vupklsh (vector bool short);
  11931. vector signed int vec_vupklsh (vector signed short);
  11932. vector bool short vec_vupklsb (vector bool char);
  11933. vector signed short vec_vupklsb (vector signed char);
  11934. vector float vec_xor (vector float, vector float);
  11935. vector float vec_xor (vector float, vector bool int);
  11936. vector float vec_xor (vector bool int, vector float);
  11937. vector bool int vec_xor (vector bool int, vector bool int);
  11938. vector signed int vec_xor (vector bool int, vector signed int);
  11939. vector signed int vec_xor (vector signed int, vector bool int);
  11940. vector signed int vec_xor (vector signed int, vector signed int);
  11941. vector unsigned int vec_xor (vector bool int, vector unsigned int);
  11942. vector unsigned int vec_xor (vector unsigned int, vector bool int);
  11943. vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
  11944. vector bool short vec_xor (vector bool short, vector bool short);
  11945. vector signed short vec_xor (vector bool short, vector signed short);
  11946. vector signed short vec_xor (vector signed short, vector bool short);
  11947. vector signed short vec_xor (vector signed short, vector signed short);
  11948. vector unsigned short vec_xor (vector bool short,
  11949. vector unsigned short);
  11950. vector unsigned short vec_xor (vector unsigned short,
  11951. vector bool short);
  11952. vector unsigned short vec_xor (vector unsigned short,
  11953. vector unsigned short);
  11954. vector signed char vec_xor (vector bool char, vector signed char);
  11955. vector bool char vec_xor (vector bool char, vector bool char);
  11956. vector signed char vec_xor (vector signed char, vector bool char);
  11957. vector signed char vec_xor (vector signed char, vector signed char);
  11958. vector unsigned char vec_xor (vector bool char, vector unsigned char);
  11959. vector unsigned char vec_xor (vector unsigned char, vector bool char);
  11960. vector unsigned char vec_xor (vector unsigned char,
  11961. vector unsigned char);
  11962. int vec_all_eq (vector signed char, vector bool char);
  11963. int vec_all_eq (vector signed char, vector signed char);
  11964. int vec_all_eq (vector unsigned char, vector bool char);
  11965. int vec_all_eq (vector unsigned char, vector unsigned char);
  11966. int vec_all_eq (vector bool char, vector bool char);
  11967. int vec_all_eq (vector bool char, vector unsigned char);
  11968. int vec_all_eq (vector bool char, vector signed char);
  11969. int vec_all_eq (vector signed short, vector bool short);
  11970. int vec_all_eq (vector signed short, vector signed short);
  11971. int vec_all_eq (vector unsigned short, vector bool short);
  11972. int vec_all_eq (vector unsigned short, vector unsigned short);
  11973. int vec_all_eq (vector bool short, vector bool short);
  11974. int vec_all_eq (vector bool short, vector unsigned short);
  11975. int vec_all_eq (vector bool short, vector signed short);
  11976. int vec_all_eq (vector pixel, vector pixel);
  11977. int vec_all_eq (vector signed int, vector bool int);
  11978. int vec_all_eq (vector signed int, vector signed int);
  11979. int vec_all_eq (vector unsigned int, vector bool int);
  11980. int vec_all_eq (vector unsigned int, vector unsigned int);
  11981. int vec_all_eq (vector bool int, vector bool int);
  11982. int vec_all_eq (vector bool int, vector unsigned int);
  11983. int vec_all_eq (vector bool int, vector signed int);
  11984. int vec_all_eq (vector float, vector float);
  11985. int vec_all_ge (vector bool char, vector unsigned char);
  11986. int vec_all_ge (vector unsigned char, vector bool char);
  11987. int vec_all_ge (vector unsigned char, vector unsigned char);
  11988. int vec_all_ge (vector bool char, vector signed char);
  11989. int vec_all_ge (vector signed char, vector bool char);
  11990. int vec_all_ge (vector signed char, vector signed char);
  11991. int vec_all_ge (vector bool short, vector unsigned short);
  11992. int vec_all_ge (vector unsigned short, vector bool short);
  11993. int vec_all_ge (vector unsigned short, vector unsigned short);
  11994. int vec_all_ge (vector signed short, vector signed short);
  11995. int vec_all_ge (vector bool short, vector signed short);
  11996. int vec_all_ge (vector signed short, vector bool short);
  11997. int vec_all_ge (vector bool int, vector unsigned int);
  11998. int vec_all_ge (vector unsigned int, vector bool int);
  11999. int vec_all_ge (vector unsigned int, vector unsigned int);
  12000. int vec_all_ge (vector bool int, vector signed int);
  12001. int vec_all_ge (vector signed int, vector bool int);
  12002. int vec_all_ge (vector signed int, vector signed int);
  12003. int vec_all_ge (vector float, vector float);
  12004. int vec_all_gt (vector bool char, vector unsigned char);
  12005. int vec_all_gt (vector unsigned char, vector bool char);
  12006. int vec_all_gt (vector unsigned char, vector unsigned char);
  12007. int vec_all_gt (vector bool char, vector signed char);
  12008. int vec_all_gt (vector signed char, vector bool char);
  12009. int vec_all_gt (vector signed char, vector signed char);
  12010. int vec_all_gt (vector bool short, vector unsigned short);
  12011. int vec_all_gt (vector unsigned short, vector bool short);
  12012. int vec_all_gt (vector unsigned short, vector unsigned short);
  12013. int vec_all_gt (vector bool short, vector signed short);
  12014. int vec_all_gt (vector signed short, vector bool short);
  12015. int vec_all_gt (vector signed short, vector signed short);
  12016. int vec_all_gt (vector bool int, vector unsigned int);
  12017. int vec_all_gt (vector unsigned int, vector bool int);
  12018. int vec_all_gt (vector unsigned int, vector unsigned int);
  12019. int vec_all_gt (vector bool int, vector signed int);
  12020. int vec_all_gt (vector signed int, vector bool int);
  12021. int vec_all_gt (vector signed int, vector signed int);
  12022. int vec_all_gt (vector float, vector float);
  12023. int vec_all_in (vector float, vector float);
  12024. int vec_all_le (vector bool char, vector unsigned char);
  12025. int vec_all_le (vector unsigned char, vector bool char);
  12026. int vec_all_le (vector unsigned char, vector unsigned char);
  12027. int vec_all_le (vector bool char, vector signed char);
  12028. int vec_all_le (vector signed char, vector bool char);
  12029. int vec_all_le (vector signed char, vector signed char);
  12030. int vec_all_le (vector bool short, vector unsigned short);
  12031. int vec_all_le (vector unsigned short, vector bool short);
  12032. int vec_all_le (vector unsigned short, vector unsigned short);
  12033. int vec_all_le (vector bool short, vector signed short);
  12034. int vec_all_le (vector signed short, vector bool short);
  12035. int vec_all_le (vector signed short, vector signed short);
  12036. int vec_all_le (vector bool int, vector unsigned int);
  12037. int vec_all_le (vector unsigned int, vector bool int);
  12038. int vec_all_le (vector unsigned int, vector unsigned int);
  12039. int vec_all_le (vector bool int, vector signed int);
  12040. int vec_all_le (vector signed int, vector bool int);
  12041. int vec_all_le (vector signed int, vector signed int);
  12042. int vec_all_le (vector float, vector float);
  12043. int vec_all_lt (vector bool char, vector unsigned char);
  12044. int vec_all_lt (vector unsigned char, vector bool char);
  12045. int vec_all_lt (vector unsigned char, vector unsigned char);
  12046. int vec_all_lt (vector bool char, vector signed char);
  12047. int vec_all_lt (vector signed char, vector bool char);
  12048. int vec_all_lt (vector signed char, vector signed char);
  12049. int vec_all_lt (vector bool short, vector unsigned short);
  12050. int vec_all_lt (vector unsigned short, vector bool short);
  12051. int vec_all_lt (vector unsigned short, vector unsigned short);
  12052. int vec_all_lt (vector bool short, vector signed short);
  12053. int vec_all_lt (vector signed short, vector bool short);
  12054. int vec_all_lt (vector signed short, vector signed short);
  12055. int vec_all_lt (vector bool int, vector unsigned int);
  12056. int vec_all_lt (vector unsigned int, vector bool int);
  12057. int vec_all_lt (vector unsigned int, vector unsigned int);
  12058. int vec_all_lt (vector bool int, vector signed int);
  12059. int vec_all_lt (vector signed int, vector bool int);
  12060. int vec_all_lt (vector signed int, vector signed int);
  12061. int vec_all_lt (vector float, vector float);
  12062. int vec_all_nan (vector float);
  12063. int vec_all_ne (vector signed char, vector bool char);
  12064. int vec_all_ne (vector signed char, vector signed char);
  12065. int vec_all_ne (vector unsigned char, vector bool char);
  12066. int vec_all_ne (vector unsigned char, vector unsigned char);
  12067. int vec_all_ne (vector bool char, vector bool char);
  12068. int vec_all_ne (vector bool char, vector unsigned char);
  12069. int vec_all_ne (vector bool char, vector signed char);
  12070. int vec_all_ne (vector signed short, vector bool short);
  12071. int vec_all_ne (vector signed short, vector signed short);
  12072. int vec_all_ne (vector unsigned short, vector bool short);
  12073. int vec_all_ne (vector unsigned short, vector unsigned short);
  12074. int vec_all_ne (vector bool short, vector bool short);
  12075. int vec_all_ne (vector bool short, vector unsigned short);
  12076. int vec_all_ne (vector bool short, vector signed short);
  12077. int vec_all_ne (vector pixel, vector pixel);
  12078. int vec_all_ne (vector signed int, vector bool int);
  12079. int vec_all_ne (vector signed int, vector signed int);
  12080. int vec_all_ne (vector unsigned int, vector bool int);
  12081. int vec_all_ne (vector unsigned int, vector unsigned int);
  12082. int vec_all_ne (vector bool int, vector bool int);
  12083. int vec_all_ne (vector bool int, vector unsigned int);
  12084. int vec_all_ne (vector bool int, vector signed int);
  12085. int vec_all_ne (vector float, vector float);
  12086. int vec_all_nge (vector float, vector float);
  12087. int vec_all_ngt (vector float, vector float);
  12088. int vec_all_nle (vector float, vector float);
  12089. int vec_all_nlt (vector float, vector float);
  12090. int vec_all_numeric (vector float);
  12091. int vec_any_eq (vector signed char, vector bool char);
  12092. int vec_any_eq (vector signed char, vector signed char);
  12093. int vec_any_eq (vector unsigned char, vector bool char);
  12094. int vec_any_eq (vector unsigned char, vector unsigned char);
  12095. int vec_any_eq (vector bool char, vector bool char);
  12096. int vec_any_eq (vector bool char, vector unsigned char);
  12097. int vec_any_eq (vector bool char, vector signed char);
  12098. int vec_any_eq (vector signed short, vector bool short);
  12099. int vec_any_eq (vector signed short, vector signed short);
  12100. int vec_any_eq (vector unsigned short, vector bool short);
  12101. int vec_any_eq (vector unsigned short, vector unsigned short);
  12102. int vec_any_eq (vector bool short, vector bool short);
  12103. int vec_any_eq (vector bool short, vector unsigned short);
  12104. int vec_any_eq (vector bool short, vector signed short);
  12105. int vec_any_eq (vector pixel, vector pixel);
  12106. int vec_any_eq (vector signed int, vector bool int);
  12107. int vec_any_eq (vector signed int, vector signed int);
  12108. int vec_any_eq (vector unsigned int, vector bool int);
  12109. int vec_any_eq (vector unsigned int, vector unsigned int);
  12110. int vec_any_eq (vector bool int, vector bool int);
  12111. int vec_any_eq (vector bool int, vector unsigned int);
  12112. int vec_any_eq (vector bool int, vector signed int);
  12113. int vec_any_eq (vector float, vector float);
  12114. int vec_any_ge (vector signed char, vector bool char);
  12115. int vec_any_ge (vector unsigned char, vector bool char);
  12116. int vec_any_ge (vector unsigned char, vector unsigned char);
  12117. int vec_any_ge (vector signed char, vector signed char);
  12118. int vec_any_ge (vector bool char, vector unsigned char);
  12119. int vec_any_ge (vector bool char, vector signed char);
  12120. int vec_any_ge (vector unsigned short, vector bool short);
  12121. int vec_any_ge (vector unsigned short, vector unsigned short);
  12122. int vec_any_ge (vector signed short, vector signed short);
  12123. int vec_any_ge (vector signed short, vector bool short);
  12124. int vec_any_ge (vector bool short, vector unsigned short);
  12125. int vec_any_ge (vector bool short, vector signed short);
  12126. int vec_any_ge (vector signed int, vector bool int);
  12127. int vec_any_ge (vector unsigned int, vector bool int);
  12128. int vec_any_ge (vector unsigned int, vector unsigned int);
  12129. int vec_any_ge (vector signed int, vector signed int);
  12130. int vec_any_ge (vector bool int, vector unsigned int);
  12131. int vec_any_ge (vector bool int, vector signed int);
  12132. int vec_any_ge (vector float, vector float);
  12133. int vec_any_gt (vector bool char, vector unsigned char);
  12134. int vec_any_gt (vector unsigned char, vector bool char);
  12135. int vec_any_gt (vector unsigned char, vector unsigned char);
  12136. int vec_any_gt (vector bool char, vector signed char);
  12137. int vec_any_gt (vector signed char, vector bool char);
  12138. int vec_any_gt (vector signed char, vector signed char);
  12139. int vec_any_gt (vector bool short, vector unsigned short);
  12140. int vec_any_gt (vector unsigned short, vector bool short);
  12141. int vec_any_gt (vector unsigned short, vector unsigned short);
  12142. int vec_any_gt (vector bool short, vector signed short);
  12143. int vec_any_gt (vector signed short, vector bool short);
  12144. int vec_any_gt (vector signed short, vector signed short);
  12145. int vec_any_gt (vector bool int, vector unsigned int);
  12146. int vec_any_gt (vector unsigned int, vector bool int);
  12147. int vec_any_gt (vector unsigned int, vector unsigned int);
  12148. int vec_any_gt (vector bool int, vector signed int);
  12149. int vec_any_gt (vector signed int, vector bool int);
  12150. int vec_any_gt (vector signed int, vector signed int);
  12151. int vec_any_gt (vector float, vector float);
  12152. int vec_any_le (vector bool char, vector unsigned char);
  12153. int vec_any_le (vector unsigned char, vector bool char);
  12154. int vec_any_le (vector unsigned char, vector unsigned char);
  12155. int vec_any_le (vector bool char, vector signed char);
  12156. int vec_any_le (vector signed char, vector bool char);
  12157. int vec_any_le (vector signed char, vector signed char);
  12158. int vec_any_le (vector bool short, vector unsigned short);
  12159. int vec_any_le (vector unsigned short, vector bool short);
  12160. int vec_any_le (vector unsigned short, vector unsigned short);
  12161. int vec_any_le (vector bool short, vector signed short);
  12162. int vec_any_le (vector signed short, vector bool short);
  12163. int vec_any_le (vector signed short, vector signed short);
  12164. int vec_any_le (vector bool int, vector unsigned int);
  12165. int vec_any_le (vector unsigned int, vector bool int);
  12166. int vec_any_le (vector unsigned int, vector unsigned int);
  12167. int vec_any_le (vector bool int, vector signed int);
  12168. int vec_any_le (vector signed int, vector bool int);
  12169. int vec_any_le (vector signed int, vector signed int);
  12170. int vec_any_le (vector float, vector float);
  12171. int vec_any_lt (vector bool char, vector unsigned char);
  12172. int vec_any_lt (vector unsigned char, vector bool char);
  12173. int vec_any_lt (vector unsigned char, vector unsigned char);
  12174. int vec_any_lt (vector bool char, vector signed char);
  12175. int vec_any_lt (vector signed char, vector bool char);
  12176. int vec_any_lt (vector signed char, vector signed char);
  12177. int vec_any_lt (vector bool short, vector unsigned short);
  12178. int vec_any_lt (vector unsigned short, vector bool short);
  12179. int vec_any_lt (vector unsigned short, vector unsigned short);
  12180. int vec_any_lt (vector bool short, vector signed short);
  12181. int vec_any_lt (vector signed short, vector bool short);
  12182. int vec_any_lt (vector signed short, vector signed short);
  12183. int vec_any_lt (vector bool int, vector unsigned int);
  12184. int vec_any_lt (vector unsigned int, vector bool int);
  12185. int vec_any_lt (vector unsigned int, vector unsigned int);
  12186. int vec_any_lt (vector bool int, vector signed int);
  12187. int vec_any_lt (vector signed int, vector bool int);
  12188. int vec_any_lt (vector signed int, vector signed int);
  12189. int vec_any_lt (vector float, vector float);
  12190. int vec_any_nan (vector float);
  12191. int vec_any_ne (vector signed char, vector bool char);
  12192. int vec_any_ne (vector signed char, vector signed char);
  12193. int vec_any_ne (vector unsigned char, vector bool char);
  12194. int vec_any_ne (vector unsigned char, vector unsigned char);
  12195. int vec_any_ne (vector bool char, vector bool char);
  12196. int vec_any_ne (vector bool char, vector unsigned char);
  12197. int vec_any_ne (vector bool char, vector signed char);
  12198. int vec_any_ne (vector signed short, vector bool short);
  12199. int vec_any_ne (vector signed short, vector signed short);
  12200. int vec_any_ne (vector unsigned short, vector bool short);
  12201. int vec_any_ne (vector unsigned short, vector unsigned short);
  12202. int vec_any_ne (vector bool short, vector bool short);
  12203. int vec_any_ne (vector bool short, vector unsigned short);
  12204. int vec_any_ne (vector bool short, vector signed short);
  12205. int vec_any_ne (vector pixel, vector pixel);
  12206. int vec_any_ne (vector signed int, vector bool int);
  12207. int vec_any_ne (vector signed int, vector signed int);
  12208. int vec_any_ne (vector unsigned int, vector bool int);
  12209. int vec_any_ne (vector unsigned int, vector unsigned int);
  12210. int vec_any_ne (vector bool int, vector bool int);
  12211. int vec_any_ne (vector bool int, vector unsigned int);
  12212. int vec_any_ne (vector bool int, vector signed int);
  12213. int vec_any_ne (vector float, vector float);
  12214. int vec_any_nge (vector float, vector float);
  12215. int vec_any_ngt (vector float, vector float);
  12216. int vec_any_nle (vector float, vector float);
  12217. int vec_any_nlt (vector float, vector float);
  12218. int vec_any_numeric (vector float);
  12219. int vec_any_out (vector float, vector float);
  12220. @end smallexample
  12221. If the vector/scalar (VSX) instruction set is available, the following
  12222. additional functions are available:
  12223. @smallexample
  12224. vector double vec_abs (vector double);
  12225. vector double vec_add (vector double, vector double);
  12226. vector double vec_and (vector double, vector double);
  12227. vector double vec_and (vector double, vector bool long);
  12228. vector double vec_and (vector bool long, vector double);
  12229. vector long vec_and (vector long, vector long);
  12230. vector long vec_and (vector long, vector bool long);
  12231. vector long vec_and (vector bool long, vector long);
  12232. vector unsigned long vec_and (vector unsigned long, vector unsigned long);
  12233. vector unsigned long vec_and (vector unsigned long, vector bool long);
  12234. vector unsigned long vec_and (vector bool long, vector unsigned long);
  12235. vector double vec_andc (vector double, vector double);
  12236. vector double vec_andc (vector double, vector bool long);
  12237. vector double vec_andc (vector bool long, vector double);
  12238. vector long vec_andc (vector long, vector long);
  12239. vector long vec_andc (vector long, vector bool long);
  12240. vector long vec_andc (vector bool long, vector long);
  12241. vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
  12242. vector unsigned long vec_andc (vector unsigned long, vector bool long);
  12243. vector unsigned long vec_andc (vector bool long, vector unsigned long);
  12244. vector double vec_ceil (vector double);
  12245. vector bool long vec_cmpeq (vector double, vector double);
  12246. vector bool long vec_cmpge (vector double, vector double);
  12247. vector bool long vec_cmpgt (vector double, vector double);
  12248. vector bool long vec_cmple (vector double, vector double);
  12249. vector bool long vec_cmplt (vector double, vector double);
  12250. vector double vec_cpsgn (vector double, vector double);
  12251. vector float vec_div (vector float, vector float);
  12252. vector double vec_div (vector double, vector double);
  12253. vector long vec_div (vector long, vector long);
  12254. vector unsigned long vec_div (vector unsigned long, vector unsigned long);
  12255. vector double vec_floor (vector double);
  12256. vector double vec_ld (int, const vector double *);
  12257. vector double vec_ld (int, const double *);
  12258. vector double vec_ldl (int, const vector double *);
  12259. vector double vec_ldl (int, const double *);
  12260. vector unsigned char vec_lvsl (int, const volatile double *);
  12261. vector unsigned char vec_lvsr (int, const volatile double *);
  12262. vector double vec_madd (vector double, vector double, vector double);
  12263. vector double vec_max (vector double, vector double);
  12264. vector signed long vec_mergeh (vector signed long, vector signed long);
  12265. vector signed long vec_mergeh (vector signed long, vector bool long);
  12266. vector signed long vec_mergeh (vector bool long, vector signed long);
  12267. vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
  12268. vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
  12269. vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
  12270. vector signed long vec_mergel (vector signed long, vector signed long);
  12271. vector signed long vec_mergel (vector signed long, vector bool long);
  12272. vector signed long vec_mergel (vector bool long, vector signed long);
  12273. vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
  12274. vector unsigned long vec_mergel (vector unsigned long, vector bool long);
  12275. vector unsigned long vec_mergel (vector bool long, vector unsigned long);
  12276. vector double vec_min (vector double, vector double);
  12277. vector float vec_msub (vector float, vector float, vector float);
  12278. vector double vec_msub (vector double, vector double, vector double);
  12279. vector float vec_mul (vector float, vector float);
  12280. vector double vec_mul (vector double, vector double);
  12281. vector long vec_mul (vector long, vector long);
  12282. vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
  12283. vector float vec_nearbyint (vector float);
  12284. vector double vec_nearbyint (vector double);
  12285. vector float vec_nmadd (vector float, vector float, vector float);
  12286. vector double vec_nmadd (vector double, vector double, vector double);
  12287. vector double vec_nmsub (vector double, vector double, vector double);
  12288. vector double vec_nor (vector double, vector double);
  12289. vector long vec_nor (vector long, vector long);
  12290. vector long vec_nor (vector long, vector bool long);
  12291. vector long vec_nor (vector bool long, vector long);
  12292. vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
  12293. vector unsigned long vec_nor (vector unsigned long, vector bool long);
  12294. vector unsigned long vec_nor (vector bool long, vector unsigned long);
  12295. vector double vec_or (vector double, vector double);
  12296. vector double vec_or (vector double, vector bool long);
  12297. vector double vec_or (vector bool long, vector double);
  12298. vector long vec_or (vector long, vector long);
  12299. vector long vec_or (vector long, vector bool long);
  12300. vector long vec_or (vector bool long, vector long);
  12301. vector unsigned long vec_or (vector unsigned long, vector unsigned long);
  12302. vector unsigned long vec_or (vector unsigned long, vector bool long);
  12303. vector unsigned long vec_or (vector bool long, vector unsigned long);
  12304. vector double vec_perm (vector double, vector double, vector unsigned char);
  12305. vector long vec_perm (vector long, vector long, vector unsigned char);
  12306. vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
  12307. vector unsigned char);
  12308. vector double vec_rint (vector double);
  12309. vector double vec_recip (vector double, vector double);
  12310. vector double vec_rsqrt (vector double);
  12311. vector double vec_rsqrte (vector double);
  12312. vector double vec_sel (vector double, vector double, vector bool long);
  12313. vector double vec_sel (vector double, vector double, vector unsigned long);
  12314. vector long vec_sel (vector long, vector long, vector long);
  12315. vector long vec_sel (vector long, vector long, vector unsigned long);
  12316. vector long vec_sel (vector long, vector long, vector bool long);
  12317. vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
  12318. vector long);
  12319. vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
  12320. vector unsigned long);
  12321. vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
  12322. vector bool long);
  12323. vector double vec_splats (double);
  12324. vector signed long vec_splats (signed long);
  12325. vector unsigned long vec_splats (unsigned long);
  12326. vector float vec_sqrt (vector float);
  12327. vector double vec_sqrt (vector double);
  12328. void vec_st (vector double, int, vector double *);
  12329. void vec_st (vector double, int, double *);
  12330. vector double vec_sub (vector double, vector double);
  12331. vector double vec_trunc (vector double);
  12332. vector double vec_xor (vector double, vector double);
  12333. vector double vec_xor (vector double, vector bool long);
  12334. vector double vec_xor (vector bool long, vector double);
  12335. vector long vec_xor (vector long, vector long);
  12336. vector long vec_xor (vector long, vector bool long);
  12337. vector long vec_xor (vector bool long, vector long);
  12338. vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
  12339. vector unsigned long vec_xor (vector unsigned long, vector bool long);
  12340. vector unsigned long vec_xor (vector bool long, vector unsigned long);
  12341. int vec_all_eq (vector double, vector double);
  12342. int vec_all_ge (vector double, vector double);
  12343. int vec_all_gt (vector double, vector double);
  12344. int vec_all_le (vector double, vector double);
  12345. int vec_all_lt (vector double, vector double);
  12346. int vec_all_nan (vector double);
  12347. int vec_all_ne (vector double, vector double);
  12348. int vec_all_nge (vector double, vector double);
  12349. int vec_all_ngt (vector double, vector double);
  12350. int vec_all_nle (vector double, vector double);
  12351. int vec_all_nlt (vector double, vector double);
  12352. int vec_all_numeric (vector double);
  12353. int vec_any_eq (vector double, vector double);
  12354. int vec_any_ge (vector double, vector double);
  12355. int vec_any_gt (vector double, vector double);
  12356. int vec_any_le (vector double, vector double);
  12357. int vec_any_lt (vector double, vector double);
  12358. int vec_any_nan (vector double);
  12359. int vec_any_ne (vector double, vector double);
  12360. int vec_any_nge (vector double, vector double);
  12361. int vec_any_ngt (vector double, vector double);
  12362. int vec_any_nle (vector double, vector double);
  12363. int vec_any_nlt (vector double, vector double);
  12364. int vec_any_numeric (vector double);
  12365. vector double vec_vsx_ld (int, const vector double *);
  12366. vector double vec_vsx_ld (int, const double *);
  12367. vector float vec_vsx_ld (int, const vector float *);
  12368. vector float vec_vsx_ld (int, const float *);
  12369. vector bool int vec_vsx_ld (int, const vector bool int *);
  12370. vector signed int vec_vsx_ld (int, const vector signed int *);
  12371. vector signed int vec_vsx_ld (int, const int *);
  12372. vector signed int vec_vsx_ld (int, const long *);
  12373. vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
  12374. vector unsigned int vec_vsx_ld (int, const unsigned int *);
  12375. vector unsigned int vec_vsx_ld (int, const unsigned long *);
  12376. vector bool short vec_vsx_ld (int, const vector bool short *);
  12377. vector pixel vec_vsx_ld (int, const vector pixel *);
  12378. vector signed short vec_vsx_ld (int, const vector signed short *);
  12379. vector signed short vec_vsx_ld (int, const short *);
  12380. vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
  12381. vector unsigned short vec_vsx_ld (int, const unsigned short *);
  12382. vector bool char vec_vsx_ld (int, const vector bool char *);
  12383. vector signed char vec_vsx_ld (int, const vector signed char *);
  12384. vector signed char vec_vsx_ld (int, const signed char *);
  12385. vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
  12386. vector unsigned char vec_vsx_ld (int, const unsigned char *);
  12387. void vec_vsx_st (vector double, int, vector double *);
  12388. void vec_vsx_st (vector double, int, double *);
  12389. void vec_vsx_st (vector float, int, vector float *);
  12390. void vec_vsx_st (vector float, int, float *);
  12391. void vec_vsx_st (vector signed int, int, vector signed int *);
  12392. void vec_vsx_st (vector signed int, int, int *);
  12393. void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
  12394. void vec_vsx_st (vector unsigned int, int, unsigned int *);
  12395. void vec_vsx_st (vector bool int, int, vector bool int *);
  12396. void vec_vsx_st (vector bool int, int, unsigned int *);
  12397. void vec_vsx_st (vector bool int, int, int *);
  12398. void vec_vsx_st (vector signed short, int, vector signed short *);
  12399. void vec_vsx_st (vector signed short, int, short *);
  12400. void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
  12401. void vec_vsx_st (vector unsigned short, int, unsigned short *);
  12402. void vec_vsx_st (vector bool short, int, vector bool short *);
  12403. void vec_vsx_st (vector bool short, int, unsigned short *);
  12404. void vec_vsx_st (vector pixel, int, vector pixel *);
  12405. void vec_vsx_st (vector pixel, int, unsigned short *);
  12406. void vec_vsx_st (vector pixel, int, short *);
  12407. void vec_vsx_st (vector bool short, int, short *);
  12408. void vec_vsx_st (vector signed char, int, vector signed char *);
  12409. void vec_vsx_st (vector signed char, int, signed char *);
  12410. void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
  12411. void vec_vsx_st (vector unsigned char, int, unsigned char *);
  12412. void vec_vsx_st (vector bool char, int, vector bool char *);
  12413. void vec_vsx_st (vector bool char, int, unsigned char *);
  12414. void vec_vsx_st (vector bool char, int, signed char *);
  12415. vector double vec_xxpermdi (vector double, vector double, int);
  12416. vector float vec_xxpermdi (vector float, vector float, int);
  12417. vector long long vec_xxpermdi (vector long long, vector long long, int);
  12418. vector unsigned long long vec_xxpermdi (vector unsigned long long,
  12419. vector unsigned long long, int);
  12420. vector int vec_xxpermdi (vector int, vector int, int);
  12421. vector unsigned int vec_xxpermdi (vector unsigned int,
  12422. vector unsigned int, int);
  12423. vector short vec_xxpermdi (vector short, vector short, int);
  12424. vector unsigned short vec_xxpermdi (vector unsigned short,
  12425. vector unsigned short, int);
  12426. vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
  12427. vector unsigned char vec_xxpermdi (vector unsigned char,
  12428. vector unsigned char, int);
  12429. vector double vec_xxsldi (vector double, vector double, int);
  12430. vector float vec_xxsldi (vector float, vector float, int);
  12431. vector long long vec_xxsldi (vector long long, vector long long, int);
  12432. vector unsigned long long vec_xxsldi (vector unsigned long long,
  12433. vector unsigned long long, int);
  12434. vector int vec_xxsldi (vector int, vector int, int);
  12435. vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
  12436. vector short vec_xxsldi (vector short, vector short, int);
  12437. vector unsigned short vec_xxsldi (vector unsigned short,
  12438. vector unsigned short, int);
  12439. vector signed char vec_xxsldi (vector signed char, vector signed char, int);
  12440. vector unsigned char vec_xxsldi (vector unsigned char,
  12441. vector unsigned char, int);
  12442. @end smallexample
  12443. Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
  12444. generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
  12445. if the VSX instruction set is available. The @samp{vec_vsx_ld} and
  12446. @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
  12447. @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
  12448. If the ISA 2.07 additions to the vector/scalar (power8-vector)
  12449. instruction set is available, the following additional functions are
  12450. available for both 32-bit and 64-bit targets. For 64-bit targets, you
  12451. can use @var{vector long} instead of @var{vector long long},
  12452. @var{vector bool long} instead of @var{vector bool long long}, and
  12453. @var{vector unsigned long} instead of @var{vector unsigned long long}.
  12454. @smallexample
  12455. vector long long vec_abs (vector long long);
  12456. vector long long vec_add (vector long long, vector long long);
  12457. vector unsigned long long vec_add (vector unsigned long long,
  12458. vector unsigned long long);
  12459. int vec_all_eq (vector long long, vector long long);
  12460. int vec_all_eq (vector unsigned long long, vector unsigned long long);
  12461. int vec_all_ge (vector long long, vector long long);
  12462. int vec_all_ge (vector unsigned long long, vector unsigned long long);
  12463. int vec_all_gt (vector long long, vector long long);
  12464. int vec_all_gt (vector unsigned long long, vector unsigned long long);
  12465. int vec_all_le (vector long long, vector long long);
  12466. int vec_all_le (vector unsigned long long, vector unsigned long long);
  12467. int vec_all_lt (vector long long, vector long long);
  12468. int vec_all_lt (vector unsigned long long, vector unsigned long long);
  12469. int vec_all_ne (vector long long, vector long long);
  12470. int vec_all_ne (vector unsigned long long, vector unsigned long long);
  12471. int vec_any_eq (vector long long, vector long long);
  12472. int vec_any_eq (vector unsigned long long, vector unsigned long long);
  12473. int vec_any_ge (vector long long, vector long long);
  12474. int vec_any_ge (vector unsigned long long, vector unsigned long long);
  12475. int vec_any_gt (vector long long, vector long long);
  12476. int vec_any_gt (vector unsigned long long, vector unsigned long long);
  12477. int vec_any_le (vector long long, vector long long);
  12478. int vec_any_le (vector unsigned long long, vector unsigned long long);
  12479. int vec_any_lt (vector long long, vector long long);
  12480. int vec_any_lt (vector unsigned long long, vector unsigned long long);
  12481. int vec_any_ne (vector long long, vector long long);
  12482. int vec_any_ne (vector unsigned long long, vector unsigned long long);
  12483. vector long long vec_eqv (vector long long, vector long long);
  12484. vector long long vec_eqv (vector bool long long, vector long long);
  12485. vector long long vec_eqv (vector long long, vector bool long long);
  12486. vector unsigned long long vec_eqv (vector unsigned long long,
  12487. vector unsigned long long);
  12488. vector unsigned long long vec_eqv (vector bool long long,
  12489. vector unsigned long long);
  12490. vector unsigned long long vec_eqv (vector unsigned long long,
  12491. vector bool long long);
  12492. vector int vec_eqv (vector int, vector int);
  12493. vector int vec_eqv (vector bool int, vector int);
  12494. vector int vec_eqv (vector int, vector bool int);
  12495. vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
  12496. vector unsigned int vec_eqv (vector bool unsigned int,
  12497. vector unsigned int);
  12498. vector unsigned int vec_eqv (vector unsigned int,
  12499. vector bool unsigned int);
  12500. vector short vec_eqv (vector short, vector short);
  12501. vector short vec_eqv (vector bool short, vector short);
  12502. vector short vec_eqv (vector short, vector bool short);
  12503. vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
  12504. vector unsigned short vec_eqv (vector bool unsigned short,
  12505. vector unsigned short);
  12506. vector unsigned short vec_eqv (vector unsigned short,
  12507. vector bool unsigned short);
  12508. vector signed char vec_eqv (vector signed char, vector signed char);
  12509. vector signed char vec_eqv (vector bool signed char, vector signed char);
  12510. vector signed char vec_eqv (vector signed char, vector bool signed char);
  12511. vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
  12512. vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
  12513. vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
  12514. vector long long vec_max (vector long long, vector long long);
  12515. vector unsigned long long vec_max (vector unsigned long long,
  12516. vector unsigned long long);
  12517. vector signed int vec_mergee (vector signed int, vector signed int);
  12518. vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
  12519. vector bool int vec_mergee (vector bool int, vector bool int);
  12520. vector signed int vec_mergeo (vector signed int, vector signed int);
  12521. vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
  12522. vector bool int vec_mergeo (vector bool int, vector bool int);
  12523. vector long long vec_min (vector long long, vector long long);
  12524. vector unsigned long long vec_min (vector unsigned long long,
  12525. vector unsigned long long);
  12526. vector long long vec_nand (vector long long, vector long long);
  12527. vector long long vec_nand (vector bool long long, vector long long);
  12528. vector long long vec_nand (vector long long, vector bool long long);
  12529. vector unsigned long long vec_nand (vector unsigned long long,
  12530. vector unsigned long long);
  12531. vector unsigned long long vec_nand (vector bool long long,
  12532. vector unsigned long long);
  12533. vector unsigned long long vec_nand (vector unsigned long long,
  12534. vector bool long long);
  12535. vector int vec_nand (vector int, vector int);
  12536. vector int vec_nand (vector bool int, vector int);
  12537. vector int vec_nand (vector int, vector bool int);
  12538. vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
  12539. vector unsigned int vec_nand (vector bool unsigned int,
  12540. vector unsigned int);
  12541. vector unsigned int vec_nand (vector unsigned int,
  12542. vector bool unsigned int);
  12543. vector short vec_nand (vector short, vector short);
  12544. vector short vec_nand (vector bool short, vector short);
  12545. vector short vec_nand (vector short, vector bool short);
  12546. vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
  12547. vector unsigned short vec_nand (vector bool unsigned short,
  12548. vector unsigned short);
  12549. vector unsigned short vec_nand (vector unsigned short,
  12550. vector bool unsigned short);
  12551. vector signed char vec_nand (vector signed char, vector signed char);
  12552. vector signed char vec_nand (vector bool signed char, vector signed char);
  12553. vector signed char vec_nand (vector signed char, vector bool signed char);
  12554. vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
  12555. vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
  12556. vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
  12557. vector long long vec_orc (vector long long, vector long long);
  12558. vector long long vec_orc (vector bool long long, vector long long);
  12559. vector long long vec_orc (vector long long, vector bool long long);
  12560. vector unsigned long long vec_orc (vector unsigned long long,
  12561. vector unsigned long long);
  12562. vector unsigned long long vec_orc (vector bool long long,
  12563. vector unsigned long long);
  12564. vector unsigned long long vec_orc (vector unsigned long long,
  12565. vector bool long long);
  12566. vector int vec_orc (vector int, vector int);
  12567. vector int vec_orc (vector bool int, vector int);
  12568. vector int vec_orc (vector int, vector bool int);
  12569. vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
  12570. vector unsigned int vec_orc (vector bool unsigned int,
  12571. vector unsigned int);
  12572. vector unsigned int vec_orc (vector unsigned int,
  12573. vector bool unsigned int);
  12574. vector short vec_orc (vector short, vector short);
  12575. vector short vec_orc (vector bool short, vector short);
  12576. vector short vec_orc (vector short, vector bool short);
  12577. vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
  12578. vector unsigned short vec_orc (vector bool unsigned short,
  12579. vector unsigned short);
  12580. vector unsigned short vec_orc (vector unsigned short,
  12581. vector bool unsigned short);
  12582. vector signed char vec_orc (vector signed char, vector signed char);
  12583. vector signed char vec_orc (vector bool signed char, vector signed char);
  12584. vector signed char vec_orc (vector signed char, vector bool signed char);
  12585. vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
  12586. vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
  12587. vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
  12588. vector int vec_pack (vector long long, vector long long);
  12589. vector unsigned int vec_pack (vector unsigned long long,
  12590. vector unsigned long long);
  12591. vector bool int vec_pack (vector bool long long, vector bool long long);
  12592. vector int vec_packs (vector long long, vector long long);
  12593. vector unsigned int vec_packs (vector unsigned long long,
  12594. vector unsigned long long);
  12595. vector unsigned int vec_packsu (vector long long, vector long long);
  12596. vector unsigned int vec_packsu (vector unsigned long long,
  12597. vector unsigned long long);
  12598. vector long long vec_rl (vector long long,
  12599. vector unsigned long long);
  12600. vector long long vec_rl (vector unsigned long long,
  12601. vector unsigned long long);
  12602. vector long long vec_sl (vector long long, vector unsigned long long);
  12603. vector long long vec_sl (vector unsigned long long,
  12604. vector unsigned long long);
  12605. vector long long vec_sr (vector long long, vector unsigned long long);
  12606. vector unsigned long long char vec_sr (vector unsigned long long,
  12607. vector unsigned long long);
  12608. vector long long vec_sra (vector long long, vector unsigned long long);
  12609. vector unsigned long long vec_sra (vector unsigned long long,
  12610. vector unsigned long long);
  12611. vector long long vec_sub (vector long long, vector long long);
  12612. vector unsigned long long vec_sub (vector unsigned long long,
  12613. vector unsigned long long);
  12614. vector long long vec_unpackh (vector int);
  12615. vector unsigned long long vec_unpackh (vector unsigned int);
  12616. vector long long vec_unpackl (vector int);
  12617. vector unsigned long long vec_unpackl (vector unsigned int);
  12618. vector long long vec_vaddudm (vector long long, vector long long);
  12619. vector long long vec_vaddudm (vector bool long long, vector long long);
  12620. vector long long vec_vaddudm (vector long long, vector bool long long);
  12621. vector unsigned long long vec_vaddudm (vector unsigned long long,
  12622. vector unsigned long long);
  12623. vector unsigned long long vec_vaddudm (vector bool unsigned long long,
  12624. vector unsigned long long);
  12625. vector unsigned long long vec_vaddudm (vector unsigned long long,
  12626. vector bool unsigned long long);
  12627. vector long long vec_vbpermq (vector signed char, vector signed char);
  12628. vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
  12629. vector long long vec_cntlz (vector long long);
  12630. vector unsigned long long vec_cntlz (vector unsigned long long);
  12631. vector int vec_cntlz (vector int);
  12632. vector unsigned int vec_cntlz (vector int);
  12633. vector short vec_cntlz (vector short);
  12634. vector unsigned short vec_cntlz (vector unsigned short);
  12635. vector signed char vec_cntlz (vector signed char);
  12636. vector unsigned char vec_cntlz (vector unsigned char);
  12637. vector long long vec_vclz (vector long long);
  12638. vector unsigned long long vec_vclz (vector unsigned long long);
  12639. vector int vec_vclz (vector int);
  12640. vector unsigned int vec_vclz (vector int);
  12641. vector short vec_vclz (vector short);
  12642. vector unsigned short vec_vclz (vector unsigned short);
  12643. vector signed char vec_vclz (vector signed char);
  12644. vector unsigned char vec_vclz (vector unsigned char);
  12645. vector signed char vec_vclzb (vector signed char);
  12646. vector unsigned char vec_vclzb (vector unsigned char);
  12647. vector long long vec_vclzd (vector long long);
  12648. vector unsigned long long vec_vclzd (vector unsigned long long);
  12649. vector short vec_vclzh (vector short);
  12650. vector unsigned short vec_vclzh (vector unsigned short);
  12651. vector int vec_vclzw (vector int);
  12652. vector unsigned int vec_vclzw (vector int);
  12653. vector signed char vec_vgbbd (vector signed char);
  12654. vector unsigned char vec_vgbbd (vector unsigned char);
  12655. vector long long vec_vmaxsd (vector long long, vector long long);
  12656. vector unsigned long long vec_vmaxud (vector unsigned long long,
  12657. unsigned vector long long);
  12658. vector long long vec_vminsd (vector long long, vector long long);
  12659. vector unsigned long long vec_vminud (vector long long,
  12660. vector long long);
  12661. vector int vec_vpksdss (vector long long, vector long long);
  12662. vector unsigned int vec_vpksdss (vector long long, vector long long);
  12663. vector unsigned int vec_vpkudus (vector unsigned long long,
  12664. vector unsigned long long);
  12665. vector int vec_vpkudum (vector long long, vector long long);
  12666. vector unsigned int vec_vpkudum (vector unsigned long long,
  12667. vector unsigned long long);
  12668. vector bool int vec_vpkudum (vector bool long long, vector bool long long);
  12669. vector long long vec_vpopcnt (vector long long);
  12670. vector unsigned long long vec_vpopcnt (vector unsigned long long);
  12671. vector int vec_vpopcnt (vector int);
  12672. vector unsigned int vec_vpopcnt (vector int);
  12673. vector short vec_vpopcnt (vector short);
  12674. vector unsigned short vec_vpopcnt (vector unsigned short);
  12675. vector signed char vec_vpopcnt (vector signed char);
  12676. vector unsigned char vec_vpopcnt (vector unsigned char);
  12677. vector signed char vec_vpopcntb (vector signed char);
  12678. vector unsigned char vec_vpopcntb (vector unsigned char);
  12679. vector long long vec_vpopcntd (vector long long);
  12680. vector unsigned long long vec_vpopcntd (vector unsigned long long);
  12681. vector short vec_vpopcnth (vector short);
  12682. vector unsigned short vec_vpopcnth (vector unsigned short);
  12683. vector int vec_vpopcntw (vector int);
  12684. vector unsigned int vec_vpopcntw (vector int);
  12685. vector long long vec_vrld (vector long long, vector unsigned long long);
  12686. vector unsigned long long vec_vrld (vector unsigned long long,
  12687. vector unsigned long long);
  12688. vector long long vec_vsld (vector long long, vector unsigned long long);
  12689. vector long long vec_vsld (vector unsigned long long,
  12690. vector unsigned long long);
  12691. vector long long vec_vsrad (vector long long, vector unsigned long long);
  12692. vector unsigned long long vec_vsrad (vector unsigned long long,
  12693. vector unsigned long long);
  12694. vector long long vec_vsrd (vector long long, vector unsigned long long);
  12695. vector unsigned long long char vec_vsrd (vector unsigned long long,
  12696. vector unsigned long long);
  12697. vector long long vec_vsubudm (vector long long, vector long long);
  12698. vector long long vec_vsubudm (vector bool long long, vector long long);
  12699. vector long long vec_vsubudm (vector long long, vector bool long long);
  12700. vector unsigned long long vec_vsubudm (vector unsigned long long,
  12701. vector unsigned long long);
  12702. vector unsigned long long vec_vsubudm (vector bool long long,
  12703. vector unsigned long long);
  12704. vector unsigned long long vec_vsubudm (vector unsigned long long,
  12705. vector bool long long);
  12706. vector long long vec_vupkhsw (vector int);
  12707. vector unsigned long long vec_vupkhsw (vector unsigned int);
  12708. vector long long vec_vupklsw (vector int);
  12709. vector unsigned long long vec_vupklsw (vector int);
  12710. @end smallexample
  12711. If the ISA 2.07 additions to the vector/scalar (power8-vector)
  12712. instruction set is available, the following additional functions are
  12713. available for 64-bit targets. New vector types
  12714. (@var{vector __int128_t} and @var{vector __uint128_t}) are available
  12715. to hold the @var{__int128_t} and @var{__uint128_t} types to use these
  12716. builtins.
  12717. The normal vector extract, and set operations work on
  12718. @var{vector __int128_t} and @var{vector __uint128_t} types,
  12719. but the index value must be 0.
  12720. @smallexample
  12721. vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
  12722. vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
  12723. vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
  12724. vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
  12725. vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
  12726. vector __int128_t);
  12727. vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
  12728. vector __uint128_t);
  12729. vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
  12730. vector __int128_t);
  12731. vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
  12732. vector __uint128_t);
  12733. vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
  12734. vector __int128_t);
  12735. vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
  12736. vector __uint128_t);
  12737. vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
  12738. vector __int128_t);
  12739. vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
  12740. vector __uint128_t);
  12741. vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
  12742. vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
  12743. __int128_t vec_vsubuqm (__int128_t, __int128_t);
  12744. __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
  12745. vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
  12746. int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
  12747. int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
  12748. int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
  12749. int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
  12750. vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
  12751. int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
  12752. int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
  12753. int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
  12754. int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
  12755. @end smallexample
  12756. If the cryptographic instructions are enabled (@option{-mcrypto} or
  12757. @option{-mcpu=power8}), the following builtins are enabled.
  12758. @smallexample
  12759. vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
  12760. vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
  12761. vector unsigned long long);
  12762. vector unsigned long long __builtin_crypto_vcipherlast
  12763. (vector unsigned long long,
  12764. vector unsigned long long);
  12765. vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
  12766. vector unsigned long long);
  12767. vector unsigned long long __builtin_crypto_vncipherlast
  12768. (vector unsigned long long,
  12769. vector unsigned long long);
  12770. vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
  12771. vector unsigned char,
  12772. vector unsigned char);
  12773. vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
  12774. vector unsigned short,
  12775. vector unsigned short);
  12776. vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
  12777. vector unsigned int,
  12778. vector unsigned int);
  12779. vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
  12780. vector unsigned long long,
  12781. vector unsigned long long);
  12782. vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
  12783. vector unsigned char);
  12784. vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
  12785. vector unsigned short);
  12786. vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
  12787. vector unsigned int);
  12788. vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
  12789. vector unsigned long long);
  12790. vector unsigned long long __builtin_crypto_vshasigmad
  12791. (vector unsigned long long, int, int);
  12792. vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
  12793. int, int);
  12794. @end smallexample
  12795. The second argument to the @var{__builtin_crypto_vshasigmad} and
  12796. @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
  12797. integer that is 0 or 1. The third argument to these builtin functions
  12798. must be a constant integer in the range of 0 to 15.
  12799. @node PowerPC Hardware Transactional Memory Built-in Functions
  12800. @subsection PowerPC Hardware Transactional Memory Built-in Functions
  12801. GCC provides two interfaces for accessing the Hardware Transactional
  12802. Memory (HTM) instructions available on some of the PowerPC family
  12803. of processors (eg, POWER8). The two interfaces come in a low level
  12804. interface, consisting of built-in functions specific to PowerPC and a
  12805. higher level interface consisting of inline functions that are common
  12806. between PowerPC and S/390.
  12807. @subsubsection PowerPC HTM Low Level Built-in Functions
  12808. The following low level built-in functions are available with
  12809. @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
  12810. They all generate the machine instruction that is part of the name.
  12811. The HTM builtins (with the exception of @code{__builtin_tbegin}) return
  12812. the full 4-bit condition register value set by their associated hardware
  12813. instruction. The header file @code{htmintrin.h} defines some macros that can
  12814. be used to decipher the return value. The @code{__builtin_tbegin} builtin
  12815. returns a simple true or false value depending on whether a transaction was
  12816. successfully started or not. The arguments of the builtins match exactly the
  12817. type and order of the associated hardware instruction's operands, except for
  12818. the @code{__builtin_tcheck} builtin, which does not take any input arguments.
  12819. Refer to the ISA manual for a description of each instruction's operands.
  12820. @smallexample
  12821. unsigned int __builtin_tbegin (unsigned int)
  12822. unsigned int __builtin_tend (unsigned int)
  12823. unsigned int __builtin_tabort (unsigned int)
  12824. unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
  12825. unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
  12826. unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
  12827. unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
  12828. unsigned int __builtin_tcheck (void)
  12829. unsigned int __builtin_treclaim (unsigned int)
  12830. unsigned int __builtin_trechkpt (void)
  12831. unsigned int __builtin_tsr (unsigned int)
  12832. @end smallexample
  12833. In addition to the above HTM built-ins, we have added built-ins for
  12834. some common extended mnemonics of the HTM instructions:
  12835. @smallexample
  12836. unsigned int __builtin_tendall (void)
  12837. unsigned int __builtin_tresume (void)
  12838. unsigned int __builtin_tsuspend (void)
  12839. @end smallexample
  12840. The following set of built-in functions are available to gain access
  12841. to the HTM specific special purpose registers.
  12842. @smallexample
  12843. unsigned long __builtin_get_texasr (void)
  12844. unsigned long __builtin_get_texasru (void)
  12845. unsigned long __builtin_get_tfhar (void)
  12846. unsigned long __builtin_get_tfiar (void)
  12847. void __builtin_set_texasr (unsigned long);
  12848. void __builtin_set_texasru (unsigned long);
  12849. void __builtin_set_tfhar (unsigned long);
  12850. void __builtin_set_tfiar (unsigned long);
  12851. @end smallexample
  12852. Example usage of these low level built-in functions may look like:
  12853. @smallexample
  12854. #include <htmintrin.h>
  12855. int num_retries = 10;
  12856. while (1)
  12857. @{
  12858. if (__builtin_tbegin (0))
  12859. @{
  12860. /* Transaction State Initiated. */
  12861. if (is_locked (lock))
  12862. __builtin_tabort (0);
  12863. ... transaction code...
  12864. __builtin_tend (0);
  12865. break;
  12866. @}
  12867. else
  12868. @{
  12869. /* Transaction State Failed. Use locks if the transaction
  12870. failure is "persistent" or we've tried too many times. */
  12871. if (num_retries-- <= 0
  12872. || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
  12873. @{
  12874. acquire_lock (lock);
  12875. ... non transactional fallback path...
  12876. release_lock (lock);
  12877. break;
  12878. @}
  12879. @}
  12880. @}
  12881. @end smallexample
  12882. One final built-in function has been added that returns the value of
  12883. the 2-bit Transaction State field of the Machine Status Register (MSR)
  12884. as stored in @code{CR0}.
  12885. @smallexample
  12886. unsigned long __builtin_ttest (void)
  12887. @end smallexample
  12888. This built-in can be used to determine the current transaction state
  12889. using the following code example:
  12890. @smallexample
  12891. #include <htmintrin.h>
  12892. unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
  12893. if (tx_state == _HTM_TRANSACTIONAL)
  12894. @{
  12895. /* Code to use in transactional state. */
  12896. @}
  12897. else if (tx_state == _HTM_NONTRANSACTIONAL)
  12898. @{
  12899. /* Code to use in non-transactional state. */
  12900. @}
  12901. else if (tx_state == _HTM_SUSPENDED)
  12902. @{
  12903. /* Code to use in transaction suspended state. */
  12904. @}
  12905. @end smallexample
  12906. @subsubsection PowerPC HTM High Level Inline Functions
  12907. The following high level HTM interface is made available by including
  12908. @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
  12909. where CPU is `power8' or later. This interface is common between PowerPC
  12910. and S/390, allowing users to write one HTM source implementation that
  12911. can be compiled and executed on either system.
  12912. @smallexample
  12913. long __TM_simple_begin (void)
  12914. long __TM_begin (void* const TM_buff)
  12915. long __TM_end (void)
  12916. void __TM_abort (void)
  12917. void __TM_named_abort (unsigned char const code)
  12918. void __TM_resume (void)
  12919. void __TM_suspend (void)
  12920. long __TM_is_user_abort (void* const TM_buff)
  12921. long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
  12922. long __TM_is_illegal (void* const TM_buff)
  12923. long __TM_is_footprint_exceeded (void* const TM_buff)
  12924. long __TM_nesting_depth (void* const TM_buff)
  12925. long __TM_is_nested_too_deep(void* const TM_buff)
  12926. long __TM_is_conflict(void* const TM_buff)
  12927. long __TM_is_failure_persistent(void* const TM_buff)
  12928. long __TM_failure_address(void* const TM_buff)
  12929. long long __TM_failure_code(void* const TM_buff)
  12930. @end smallexample
  12931. Using these common set of HTM inline functions, we can create
  12932. a more portable version of the HTM example in the previous
  12933. section that will work on either PowerPC or S/390:
  12934. @smallexample
  12935. #include <htmxlintrin.h>
  12936. int num_retries = 10;
  12937. TM_buff_type TM_buff;
  12938. while (1)
  12939. @{
  12940. if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
  12941. @{
  12942. /* Transaction State Initiated. */
  12943. if (is_locked (lock))
  12944. __TM_abort ();
  12945. ... transaction code...
  12946. __TM_end ();
  12947. break;
  12948. @}
  12949. else
  12950. @{
  12951. /* Transaction State Failed. Use locks if the transaction
  12952. failure is "persistent" or we've tried too many times. */
  12953. if (num_retries-- <= 0
  12954. || __TM_is_failure_persistent (TM_buff))
  12955. @{
  12956. acquire_lock (lock);
  12957. ... non transactional fallback path...
  12958. release_lock (lock);
  12959. break;
  12960. @}
  12961. @}
  12962. @}
  12963. @end smallexample
  12964. @node RX Built-in Functions
  12965. @subsection RX Built-in Functions
  12966. GCC supports some of the RX instructions which cannot be expressed in
  12967. the C programming language via the use of built-in functions. The
  12968. following functions are supported:
  12969. @deftypefn {Built-in Function} void __builtin_rx_brk (void)
  12970. Generates the @code{brk} machine instruction.
  12971. @end deftypefn
  12972. @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
  12973. Generates the @code{clrpsw} machine instruction to clear the specified
  12974. bit in the processor status word.
  12975. @end deftypefn
  12976. @deftypefn {Built-in Function} void __builtin_rx_int (int)
  12977. Generates the @code{int} machine instruction to generate an interrupt
  12978. with the specified value.
  12979. @end deftypefn
  12980. @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
  12981. Generates the @code{machi} machine instruction to add the result of
  12982. multiplying the top 16 bits of the two arguments into the
  12983. accumulator.
  12984. @end deftypefn
  12985. @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
  12986. Generates the @code{maclo} machine instruction to add the result of
  12987. multiplying the bottom 16 bits of the two arguments into the
  12988. accumulator.
  12989. @end deftypefn
  12990. @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
  12991. Generates the @code{mulhi} machine instruction to place the result of
  12992. multiplying the top 16 bits of the two arguments into the
  12993. accumulator.
  12994. @end deftypefn
  12995. @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
  12996. Generates the @code{mullo} machine instruction to place the result of
  12997. multiplying the bottom 16 bits of the two arguments into the
  12998. accumulator.
  12999. @end deftypefn
  13000. @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
  13001. Generates the @code{mvfachi} machine instruction to read the top
  13002. 32 bits of the accumulator.
  13003. @end deftypefn
  13004. @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
  13005. Generates the @code{mvfacmi} machine instruction to read the middle
  13006. 32 bits of the accumulator.
  13007. @end deftypefn
  13008. @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
  13009. Generates the @code{mvfc} machine instruction which reads the control
  13010. register specified in its argument and returns its value.
  13011. @end deftypefn
  13012. @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
  13013. Generates the @code{mvtachi} machine instruction to set the top
  13014. 32 bits of the accumulator.
  13015. @end deftypefn
  13016. @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
  13017. Generates the @code{mvtaclo} machine instruction to set the bottom
  13018. 32 bits of the accumulator.
  13019. @end deftypefn
  13020. @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
  13021. Generates the @code{mvtc} machine instruction which sets control
  13022. register number @code{reg} to @code{val}.
  13023. @end deftypefn
  13024. @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
  13025. Generates the @code{mvtipl} machine instruction set the interrupt
  13026. priority level.
  13027. @end deftypefn
  13028. @deftypefn {Built-in Function} void __builtin_rx_racw (int)
  13029. Generates the @code{racw} machine instruction to round the accumulator
  13030. according to the specified mode.
  13031. @end deftypefn
  13032. @deftypefn {Built-in Function} int __builtin_rx_revw (int)
  13033. Generates the @code{revw} machine instruction which swaps the bytes in
  13034. the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
  13035. and also bits 16--23 occupy bits 24--31 and vice versa.
  13036. @end deftypefn
  13037. @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
  13038. Generates the @code{rmpa} machine instruction which initiates a
  13039. repeated multiply and accumulate sequence.
  13040. @end deftypefn
  13041. @deftypefn {Built-in Function} void __builtin_rx_round (float)
  13042. Generates the @code{round} machine instruction which returns the
  13043. floating-point argument rounded according to the current rounding mode
  13044. set in the floating-point status word register.
  13045. @end deftypefn
  13046. @deftypefn {Built-in Function} int __builtin_rx_sat (int)
  13047. Generates the @code{sat} machine instruction which returns the
  13048. saturated value of the argument.
  13049. @end deftypefn
  13050. @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
  13051. Generates the @code{setpsw} machine instruction to set the specified
  13052. bit in the processor status word.
  13053. @end deftypefn
  13054. @deftypefn {Built-in Function} void __builtin_rx_wait (void)
  13055. Generates the @code{wait} machine instruction.
  13056. @end deftypefn
  13057. @node S/390 System z Built-in Functions
  13058. @subsection S/390 System z Built-in Functions
  13059. @deftypefn {Built-in Function} int __builtin_tbegin (void*)
  13060. Generates the @code{tbegin} machine instruction starting a
  13061. non-constraint hardware transaction. If the parameter is non-NULL the
  13062. memory area is used to store the transaction diagnostic buffer and
  13063. will be passed as first operand to @code{tbegin}. This buffer can be
  13064. defined using the @code{struct __htm_tdb} C struct defined in
  13065. @code{htmintrin.h} and must reside on a double-word boundary. The
  13066. second tbegin operand is set to @code{0xff0c}. This enables
  13067. save/restore of all GPRs and disables aborts for FPR and AR
  13068. manipulations inside the transaction body. The condition code set by
  13069. the tbegin instruction is returned as integer value. The tbegin
  13070. instruction by definition overwrites the content of all FPRs. The
  13071. compiler will generate code which saves and restores the FPRs. For
  13072. soft-float code it is recommended to used the @code{*_nofloat}
  13073. variant. In order to prevent a TDB from being written it is required
  13074. to pass an constant zero value as parameter. Passing the zero value
  13075. through a variable is not sufficient. Although modifications of
  13076. access registers inside the transaction will not trigger an
  13077. transaction abort it is not supported to actually modify them. Access
  13078. registers do not get saved when entering a transaction. They will have
  13079. undefined state when reaching the abort code.
  13080. @end deftypefn
  13081. Macros for the possible return codes of tbegin are defined in the
  13082. @code{htmintrin.h} header file:
  13083. @table @code
  13084. @item _HTM_TBEGIN_STARTED
  13085. @code{tbegin} has been executed as part of normal processing. The
  13086. transaction body is supposed to be executed.
  13087. @item _HTM_TBEGIN_INDETERMINATE
  13088. The transaction was aborted due to an indeterminate condition which
  13089. might be persistent.
  13090. @item _HTM_TBEGIN_TRANSIENT
  13091. The transaction aborted due to a transient failure. The transaction
  13092. should be re-executed in that case.
  13093. @item _HTM_TBEGIN_PERSISTENT
  13094. The transaction aborted due to a persistent failure. Re-execution
  13095. under same circumstances will not be productive.
  13096. @end table
  13097. @defmac _HTM_FIRST_USER_ABORT_CODE
  13098. The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
  13099. specifies the first abort code which can be used for
  13100. @code{__builtin_tabort}. Values below this threshold are reserved for
  13101. machine use.
  13102. @end defmac
  13103. @deftp {Data type} {struct __htm_tdb}
  13104. The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
  13105. the structure of the transaction diagnostic block as specified in the
  13106. Principles of Operation manual chapter 5-91.
  13107. @end deftp
  13108. @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
  13109. Same as @code{__builtin_tbegin} but without FPR saves and restores.
  13110. Using this variant in code making use of FPRs will leave the FPRs in
  13111. undefined state when entering the transaction abort handler code.
  13112. @end deftypefn
  13113. @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
  13114. In addition to @code{__builtin_tbegin} a loop for transient failures
  13115. is generated. If tbegin returns a condition code of 2 the transaction
  13116. will be retried as often as specified in the second argument. The
  13117. perform processor assist instruction is used to tell the CPU about the
  13118. number of fails so far.
  13119. @end deftypefn
  13120. @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
  13121. Same as @code{__builtin_tbegin_retry} but without FPR saves and
  13122. restores. Using this variant in code making use of FPRs will leave
  13123. the FPRs in undefined state when entering the transaction abort
  13124. handler code.
  13125. @end deftypefn
  13126. @deftypefn {Built-in Function} void __builtin_tbeginc (void)
  13127. Generates the @code{tbeginc} machine instruction starting a constraint
  13128. hardware transaction. The second operand is set to @code{0xff08}.
  13129. @end deftypefn
  13130. @deftypefn {Built-in Function} int __builtin_tend (void)
  13131. Generates the @code{tend} machine instruction finishing a transaction
  13132. and making the changes visible to other threads. The condition code
  13133. generated by tend is returned as integer value.
  13134. @end deftypefn
  13135. @deftypefn {Built-in Function} void __builtin_tabort (int)
  13136. Generates the @code{tabort} machine instruction with the specified
  13137. abort code. Abort codes from 0 through 255 are reserved and will
  13138. result in an error message.
  13139. @end deftypefn
  13140. @deftypefn {Built-in Function} void __builtin_tx_assist (int)
  13141. Generates the @code{ppa rX,rY,1} machine instruction. Where the
  13142. integer parameter is loaded into rX and a value of zero is loaded into
  13143. rY. The integer parameter specifies the number of times the
  13144. transaction repeatedly aborted.
  13145. @end deftypefn
  13146. @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
  13147. Generates the @code{etnd} machine instruction. The current nesting
  13148. depth is returned as integer value. For a nesting depth of 0 the code
  13149. is not executed as part of an transaction.
  13150. @end deftypefn
  13151. @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
  13152. Generates the @code{ntstg} machine instruction. The second argument
  13153. is written to the first arguments location. The store operation will
  13154. not be rolled-back in case of an transaction abort.
  13155. @end deftypefn
  13156. @node SH Built-in Functions
  13157. @subsection SH Built-in Functions
  13158. The following built-in functions are supported on the SH1, SH2, SH3 and SH4
  13159. families of processors:
  13160. @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
  13161. Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
  13162. used by system code that manages threads and execution contexts. The compiler
  13163. normally does not generate code that modifies the contents of @samp{GBR} and
  13164. thus the value is preserved across function calls. Changing the @samp{GBR}
  13165. value in user code must be done with caution, since the compiler might use
  13166. @samp{GBR} in order to access thread local variables.
  13167. @end deftypefn
  13168. @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
  13169. Returns the value that is currently set in the @samp{GBR} register.
  13170. Memory loads and stores that use the thread pointer as a base address are
  13171. turned into @samp{GBR} based displacement loads and stores, if possible.
  13172. For example:
  13173. @smallexample
  13174. struct my_tcb
  13175. @{
  13176. int a, b, c, d, e;
  13177. @};
  13178. int get_tcb_value (void)
  13179. @{
  13180. // Generate @samp{mov.l @@(8,gbr),r0} instruction
  13181. return ((my_tcb*)__builtin_thread_pointer ())->c;
  13182. @}
  13183. @end smallexample
  13184. @end deftypefn
  13185. @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
  13186. Returns the value that is currently set in the @samp{FPSCR} register.
  13187. @end deftypefn
  13188. @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
  13189. Sets the @samp{FPSCR} register to the specified value @var{val}, while
  13190. preserving the current values of the FR, SZ and PR bits.
  13191. @end deftypefn
  13192. @node SPARC VIS Built-in Functions
  13193. @subsection SPARC VIS Built-in Functions
  13194. GCC supports SIMD operations on the SPARC using both the generic vector
  13195. extensions (@pxref{Vector Extensions}) as well as built-in functions for
  13196. the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
  13197. switch, the VIS extension is exposed as the following built-in functions:
  13198. @smallexample
  13199. typedef int v1si __attribute__ ((vector_size (4)));
  13200. typedef int v2si __attribute__ ((vector_size (8)));
  13201. typedef short v4hi __attribute__ ((vector_size (8)));
  13202. typedef short v2hi __attribute__ ((vector_size (4)));
  13203. typedef unsigned char v8qi __attribute__ ((vector_size (8)));
  13204. typedef unsigned char v4qi __attribute__ ((vector_size (4)));
  13205. void __builtin_vis_write_gsr (int64_t);
  13206. int64_t __builtin_vis_read_gsr (void);
  13207. void * __builtin_vis_alignaddr (void *, long);
  13208. void * __builtin_vis_alignaddrl (void *, long);
  13209. int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
  13210. v2si __builtin_vis_faligndatav2si (v2si, v2si);
  13211. v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
  13212. v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
  13213. v4hi __builtin_vis_fexpand (v4qi);
  13214. v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
  13215. v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
  13216. v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
  13217. v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
  13218. v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
  13219. v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
  13220. v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
  13221. v4qi __builtin_vis_fpack16 (v4hi);
  13222. v8qi __builtin_vis_fpack32 (v2si, v8qi);
  13223. v2hi __builtin_vis_fpackfix (v2si);
  13224. v8qi __builtin_vis_fpmerge (v4qi, v4qi);
  13225. int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
  13226. long __builtin_vis_edge8 (void *, void *);
  13227. long __builtin_vis_edge8l (void *, void *);
  13228. long __builtin_vis_edge16 (void *, void *);
  13229. long __builtin_vis_edge16l (void *, void *);
  13230. long __builtin_vis_edge32 (void *, void *);
  13231. long __builtin_vis_edge32l (void *, void *);
  13232. long __builtin_vis_fcmple16 (v4hi, v4hi);
  13233. long __builtin_vis_fcmple32 (v2si, v2si);
  13234. long __builtin_vis_fcmpne16 (v4hi, v4hi);
  13235. long __builtin_vis_fcmpne32 (v2si, v2si);
  13236. long __builtin_vis_fcmpgt16 (v4hi, v4hi);
  13237. long __builtin_vis_fcmpgt32 (v2si, v2si);
  13238. long __builtin_vis_fcmpeq16 (v4hi, v4hi);
  13239. long __builtin_vis_fcmpeq32 (v2si, v2si);
  13240. v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
  13241. v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
  13242. v2si __builtin_vis_fpadd32 (v2si, v2si);
  13243. v1si __builtin_vis_fpadd32s (v1si, v1si);
  13244. v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
  13245. v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
  13246. v2si __builtin_vis_fpsub32 (v2si, v2si);
  13247. v1si __builtin_vis_fpsub32s (v1si, v1si);
  13248. long __builtin_vis_array8 (long, long);
  13249. long __builtin_vis_array16 (long, long);
  13250. long __builtin_vis_array32 (long, long);
  13251. @end smallexample
  13252. When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
  13253. functions also become available:
  13254. @smallexample
  13255. long __builtin_vis_bmask (long, long);
  13256. int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
  13257. v2si __builtin_vis_bshufflev2si (v2si, v2si);
  13258. v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
  13259. v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
  13260. long __builtin_vis_edge8n (void *, void *);
  13261. long __builtin_vis_edge8ln (void *, void *);
  13262. long __builtin_vis_edge16n (void *, void *);
  13263. long __builtin_vis_edge16ln (void *, void *);
  13264. long __builtin_vis_edge32n (void *, void *);
  13265. long __builtin_vis_edge32ln (void *, void *);
  13266. @end smallexample
  13267. When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
  13268. functions also become available:
  13269. @smallexample
  13270. void __builtin_vis_cmask8 (long);
  13271. void __builtin_vis_cmask16 (long);
  13272. void __builtin_vis_cmask32 (long);
  13273. v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
  13274. v4hi __builtin_vis_fsll16 (v4hi, v4hi);
  13275. v4hi __builtin_vis_fslas16 (v4hi, v4hi);
  13276. v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
  13277. v4hi __builtin_vis_fsra16 (v4hi, v4hi);
  13278. v2si __builtin_vis_fsll16 (v2si, v2si);
  13279. v2si __builtin_vis_fslas16 (v2si, v2si);
  13280. v2si __builtin_vis_fsrl16 (v2si, v2si);
  13281. v2si __builtin_vis_fsra16 (v2si, v2si);
  13282. long __builtin_vis_pdistn (v8qi, v8qi);
  13283. v4hi __builtin_vis_fmean16 (v4hi, v4hi);
  13284. int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
  13285. int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
  13286. v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
  13287. v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
  13288. v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
  13289. v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
  13290. v2si __builtin_vis_fpadds32 (v2si, v2si);
  13291. v1si __builtin_vis_fpadds32s (v1si, v1si);
  13292. v2si __builtin_vis_fpsubs32 (v2si, v2si);
  13293. v1si __builtin_vis_fpsubs32s (v1si, v1si);
  13294. long __builtin_vis_fucmple8 (v8qi, v8qi);
  13295. long __builtin_vis_fucmpne8 (v8qi, v8qi);
  13296. long __builtin_vis_fucmpgt8 (v8qi, v8qi);
  13297. long __builtin_vis_fucmpeq8 (v8qi, v8qi);
  13298. float __builtin_vis_fhadds (float, float);
  13299. double __builtin_vis_fhaddd (double, double);
  13300. float __builtin_vis_fhsubs (float, float);
  13301. double __builtin_vis_fhsubd (double, double);
  13302. float __builtin_vis_fnhadds (float, float);
  13303. double __builtin_vis_fnhaddd (double, double);
  13304. int64_t __builtin_vis_umulxhi (int64_t, int64_t);
  13305. int64_t __builtin_vis_xmulx (int64_t, int64_t);
  13306. int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
  13307. @end smallexample
  13308. @node SPU Built-in Functions
  13309. @subsection SPU Built-in Functions
  13310. GCC provides extensions for the SPU processor as described in the
  13311. Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
  13312. found at @uref{http://cell.scei.co.jp/} or
  13313. @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
  13314. implementation differs in several ways.
  13315. @itemize @bullet
  13316. @item
  13317. The optional extension of specifying vector constants in parentheses is
  13318. not supported.
  13319. @item
  13320. A vector initializer requires no cast if the vector constant is of the
  13321. same type as the variable it is initializing.
  13322. @item
  13323. If @code{signed} or @code{unsigned} is omitted, the signedness of the
  13324. vector type is the default signedness of the base type. The default
  13325. varies depending on the operating system, so a portable program should
  13326. always specify the signedness.
  13327. @item
  13328. By default, the keyword @code{__vector} is added. The macro
  13329. @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
  13330. undefined.
  13331. @item
  13332. GCC allows using a @code{typedef} name as the type specifier for a
  13333. vector type.
  13334. @item
  13335. For C, overloaded functions are implemented with macros so the following
  13336. does not work:
  13337. @smallexample
  13338. spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
  13339. @end smallexample
  13340. @noindent
  13341. Since @code{spu_add} is a macro, the vector constant in the example
  13342. is treated as four separate arguments. Wrap the entire argument in
  13343. parentheses for this to work.
  13344. @item
  13345. The extended version of @code{__builtin_expect} is not supported.
  13346. @end itemize
  13347. @emph{Note:} Only the interface described in the aforementioned
  13348. specification is supported. Internally, GCC uses built-in functions to
  13349. implement the required functionality, but these are not supported and
  13350. are subject to change without notice.
  13351. @node TI C6X Built-in Functions
  13352. @subsection TI C6X Built-in Functions
  13353. GCC provides intrinsics to access certain instructions of the TI C6X
  13354. processors. These intrinsics, listed below, are available after
  13355. inclusion of the @code{c6x_intrinsics.h} header file. They map directly
  13356. to C6X instructions.
  13357. @smallexample
  13358. int _sadd (int, int)
  13359. int _ssub (int, int)
  13360. int _sadd2 (int, int)
  13361. int _ssub2 (int, int)
  13362. long long _mpy2 (int, int)
  13363. long long _smpy2 (int, int)
  13364. int _add4 (int, int)
  13365. int _sub4 (int, int)
  13366. int _saddu4 (int, int)
  13367. int _smpy (int, int)
  13368. int _smpyh (int, int)
  13369. int _smpyhl (int, int)
  13370. int _smpylh (int, int)
  13371. int _sshl (int, int)
  13372. int _subc (int, int)
  13373. int _avg2 (int, int)
  13374. int _avgu4 (int, int)
  13375. int _clrr (int, int)
  13376. int _extr (int, int)
  13377. int _extru (int, int)
  13378. int _abs (int)
  13379. int _abs2 (int)
  13380. @end smallexample
  13381. @node TILE-Gx Built-in Functions
  13382. @subsection TILE-Gx Built-in Functions
  13383. GCC provides intrinsics to access every instruction of the TILE-Gx
  13384. processor. The intrinsics are of the form:
  13385. @smallexample
  13386. unsigned long long __insn_@var{op} (...)
  13387. @end smallexample
  13388. Where @var{op} is the name of the instruction. Refer to the ISA manual
  13389. for the complete list of instructions.
  13390. GCC also provides intrinsics to directly access the network registers.
  13391. The intrinsics are:
  13392. @smallexample
  13393. unsigned long long __tile_idn0_receive (void)
  13394. unsigned long long __tile_idn1_receive (void)
  13395. unsigned long long __tile_udn0_receive (void)
  13396. unsigned long long __tile_udn1_receive (void)
  13397. unsigned long long __tile_udn2_receive (void)
  13398. unsigned long long __tile_udn3_receive (void)
  13399. void __tile_idn_send (unsigned long long)
  13400. void __tile_udn_send (unsigned long long)
  13401. @end smallexample
  13402. The intrinsic @code{void __tile_network_barrier (void)} is used to
  13403. guarantee that no network operations before it are reordered with
  13404. those after it.
  13405. @node TILEPro Built-in Functions
  13406. @subsection TILEPro Built-in Functions
  13407. GCC provides intrinsics to access every instruction of the TILEPro
  13408. processor. The intrinsics are of the form:
  13409. @smallexample
  13410. unsigned __insn_@var{op} (...)
  13411. @end smallexample
  13412. @noindent
  13413. where @var{op} is the name of the instruction. Refer to the ISA manual
  13414. for the complete list of instructions.
  13415. GCC also provides intrinsics to directly access the network registers.
  13416. The intrinsics are:
  13417. @smallexample
  13418. unsigned __tile_idn0_receive (void)
  13419. unsigned __tile_idn1_receive (void)
  13420. unsigned __tile_sn_receive (void)
  13421. unsigned __tile_udn0_receive (void)
  13422. unsigned __tile_udn1_receive (void)
  13423. unsigned __tile_udn2_receive (void)
  13424. unsigned __tile_udn3_receive (void)
  13425. void __tile_idn_send (unsigned)
  13426. void __tile_sn_send (unsigned)
  13427. void __tile_udn_send (unsigned)
  13428. @end smallexample
  13429. The intrinsic @code{void __tile_network_barrier (void)} is used to
  13430. guarantee that no network operations before it are reordered with
  13431. those after it.
  13432. @node x86 Built-in Functions
  13433. @subsection x86 Built-in Functions
  13434. These built-in functions are available for the x86-32 and x86-64 family
  13435. of computers, depending on the command-line switches used.
  13436. If you specify command-line switches such as @option{-msse},
  13437. the compiler could use the extended instruction sets even if the built-ins
  13438. are not used explicitly in the program. For this reason, applications
  13439. that perform run-time CPU detection must compile separate files for each
  13440. supported architecture, using the appropriate flags. In particular,
  13441. the file containing the CPU detection code should be compiled without
  13442. these options.
  13443. The following machine modes are available for use with MMX built-in functions
  13444. (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
  13445. @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
  13446. vector of eight 8-bit integers. Some of the built-in functions operate on
  13447. MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
  13448. If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
  13449. of two 32-bit floating-point values.
  13450. If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
  13451. floating-point values. Some instructions use a vector of four 32-bit
  13452. integers, these use @code{V4SI}. Finally, some instructions operate on an
  13453. entire vector register, interpreting it as a 128-bit integer, these use mode
  13454. @code{TI}.
  13455. In 64-bit mode, the x86-64 family of processors uses additional built-in
  13456. functions for efficient use of @code{TF} (@code{__float128}) 128-bit
  13457. floating point and @code{TC} 128-bit complex floating-point values.
  13458. The following floating-point built-in functions are available in 64-bit
  13459. mode. All of them implement the function that is part of the name.
  13460. @smallexample
  13461. __float128 __builtin_fabsq (__float128)
  13462. __float128 __builtin_copysignq (__float128, __float128)
  13463. @end smallexample
  13464. The following built-in function is always available.
  13465. @table @code
  13466. @item void __builtin_ia32_pause (void)
  13467. Generates the @code{pause} machine instruction with a compiler memory
  13468. barrier.
  13469. @end table
  13470. The following floating-point built-in functions are made available in the
  13471. 64-bit mode.
  13472. @table @code
  13473. @item __float128 __builtin_infq (void)
  13474. Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
  13475. @findex __builtin_infq
  13476. @item __float128 __builtin_huge_valq (void)
  13477. Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
  13478. @findex __builtin_huge_valq
  13479. @end table
  13480. The following built-in functions are always available and can be used to
  13481. check the target platform type.
  13482. @deftypefn {Built-in Function} void __builtin_cpu_init (void)
  13483. This function runs the CPU detection code to check the type of CPU and the
  13484. features supported. This built-in function needs to be invoked along with the built-in functions
  13485. to check CPU type and features, @code{__builtin_cpu_is} and
  13486. @code{__builtin_cpu_supports}, only when used in a function that is
  13487. executed before any constructors are called. The CPU detection code is
  13488. automatically executed in a very high priority constructor.
  13489. For example, this function has to be used in @code{ifunc} resolvers that
  13490. check for CPU type using the built-in functions @code{__builtin_cpu_is}
  13491. and @code{__builtin_cpu_supports}, or in constructors on targets that
  13492. don't support constructor priority.
  13493. @smallexample
  13494. static void (*resolve_memcpy (void)) (void)
  13495. @{
  13496. // ifunc resolvers fire before constructors, explicitly call the init
  13497. // function.
  13498. __builtin_cpu_init ();
  13499. if (__builtin_cpu_supports ("ssse3"))
  13500. return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
  13501. else
  13502. return default_memcpy;
  13503. @}
  13504. void *memcpy (void *, const void *, size_t)
  13505. __attribute__ ((ifunc ("resolve_memcpy")));
  13506. @end smallexample
  13507. @end deftypefn
  13508. @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
  13509. This function returns a positive integer if the run-time CPU
  13510. is of type @var{cpuname}
  13511. and returns @code{0} otherwise. The following CPU names can be detected:
  13512. @table @samp
  13513. @item intel
  13514. Intel CPU.
  13515. @item atom
  13516. Intel Atom CPU.
  13517. @item core2
  13518. Intel Core 2 CPU.
  13519. @item corei7
  13520. Intel Core i7 CPU.
  13521. @item nehalem
  13522. Intel Core i7 Nehalem CPU.
  13523. @item westmere
  13524. Intel Core i7 Westmere CPU.
  13525. @item sandybridge
  13526. Intel Core i7 Sandy Bridge CPU.
  13527. @item amd
  13528. AMD CPU.
  13529. @item amdfam10h
  13530. AMD Family 10h CPU.
  13531. @item barcelona
  13532. AMD Family 10h Barcelona CPU.
  13533. @item shanghai
  13534. AMD Family 10h Shanghai CPU.
  13535. @item istanbul
  13536. AMD Family 10h Istanbul CPU.
  13537. @item btver1
  13538. AMD Family 14h CPU.
  13539. @item amdfam15h
  13540. AMD Family 15h CPU.
  13541. @item bdver1
  13542. AMD Family 15h Bulldozer version 1.
  13543. @item bdver2
  13544. AMD Family 15h Bulldozer version 2.
  13545. @item bdver3
  13546. AMD Family 15h Bulldozer version 3.
  13547. @item bdver4
  13548. AMD Family 15h Bulldozer version 4.
  13549. @item btver2
  13550. AMD Family 16h CPU.
  13551. @end table
  13552. Here is an example:
  13553. @smallexample
  13554. if (__builtin_cpu_is ("corei7"))
  13555. @{
  13556. do_corei7 (); // Core i7 specific implementation.
  13557. @}
  13558. else
  13559. @{
  13560. do_generic (); // Generic implementation.
  13561. @}
  13562. @end smallexample
  13563. @end deftypefn
  13564. @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
  13565. This function returns a positive integer if the run-time CPU
  13566. supports @var{feature}
  13567. and returns @code{0} otherwise. The following features can be detected:
  13568. @table @samp
  13569. @item cmov
  13570. CMOV instruction.
  13571. @item mmx
  13572. MMX instructions.
  13573. @item popcnt
  13574. POPCNT instruction.
  13575. @item sse
  13576. SSE instructions.
  13577. @item sse2
  13578. SSE2 instructions.
  13579. @item sse3
  13580. SSE3 instructions.
  13581. @item ssse3
  13582. SSSE3 instructions.
  13583. @item sse4.1
  13584. SSE4.1 instructions.
  13585. @item sse4.2
  13586. SSE4.2 instructions.
  13587. @item avx
  13588. AVX instructions.
  13589. @item avx2
  13590. AVX2 instructions.
  13591. @item avx512f
  13592. AVX512F instructions.
  13593. @end table
  13594. Here is an example:
  13595. @smallexample
  13596. if (__builtin_cpu_supports ("popcnt"))
  13597. @{
  13598. asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
  13599. @}
  13600. else
  13601. @{
  13602. count = generic_countbits (n); //generic implementation.
  13603. @}
  13604. @end smallexample
  13605. @end deftypefn
  13606. The following built-in functions are made available by @option{-mmmx}.
  13607. All of them generate the machine instruction that is part of the name.
  13608. @smallexample
  13609. v8qi __builtin_ia32_paddb (v8qi, v8qi)
  13610. v4hi __builtin_ia32_paddw (v4hi, v4hi)
  13611. v2si __builtin_ia32_paddd (v2si, v2si)
  13612. v8qi __builtin_ia32_psubb (v8qi, v8qi)
  13613. v4hi __builtin_ia32_psubw (v4hi, v4hi)
  13614. v2si __builtin_ia32_psubd (v2si, v2si)
  13615. v8qi __builtin_ia32_paddsb (v8qi, v8qi)
  13616. v4hi __builtin_ia32_paddsw (v4hi, v4hi)
  13617. v8qi __builtin_ia32_psubsb (v8qi, v8qi)
  13618. v4hi __builtin_ia32_psubsw (v4hi, v4hi)
  13619. v8qi __builtin_ia32_paddusb (v8qi, v8qi)
  13620. v4hi __builtin_ia32_paddusw (v4hi, v4hi)
  13621. v8qi __builtin_ia32_psubusb (v8qi, v8qi)
  13622. v4hi __builtin_ia32_psubusw (v4hi, v4hi)
  13623. v4hi __builtin_ia32_pmullw (v4hi, v4hi)
  13624. v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
  13625. di __builtin_ia32_pand (di, di)
  13626. di __builtin_ia32_pandn (di,di)
  13627. di __builtin_ia32_por (di, di)
  13628. di __builtin_ia32_pxor (di, di)
  13629. v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
  13630. v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
  13631. v2si __builtin_ia32_pcmpeqd (v2si, v2si)
  13632. v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
  13633. v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
  13634. v2si __builtin_ia32_pcmpgtd (v2si, v2si)
  13635. v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
  13636. v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
  13637. v2si __builtin_ia32_punpckhdq (v2si, v2si)
  13638. v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
  13639. v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
  13640. v2si __builtin_ia32_punpckldq (v2si, v2si)
  13641. v8qi __builtin_ia32_packsswb (v4hi, v4hi)
  13642. v4hi __builtin_ia32_packssdw (v2si, v2si)
  13643. v8qi __builtin_ia32_packuswb (v4hi, v4hi)
  13644. v4hi __builtin_ia32_psllw (v4hi, v4hi)
  13645. v2si __builtin_ia32_pslld (v2si, v2si)
  13646. v1di __builtin_ia32_psllq (v1di, v1di)
  13647. v4hi __builtin_ia32_psrlw (v4hi, v4hi)
  13648. v2si __builtin_ia32_psrld (v2si, v2si)
  13649. v1di __builtin_ia32_psrlq (v1di, v1di)
  13650. v4hi __builtin_ia32_psraw (v4hi, v4hi)
  13651. v2si __builtin_ia32_psrad (v2si, v2si)
  13652. v4hi __builtin_ia32_psllwi (v4hi, int)
  13653. v2si __builtin_ia32_pslldi (v2si, int)
  13654. v1di __builtin_ia32_psllqi (v1di, int)
  13655. v4hi __builtin_ia32_psrlwi (v4hi, int)
  13656. v2si __builtin_ia32_psrldi (v2si, int)
  13657. v1di __builtin_ia32_psrlqi (v1di, int)
  13658. v4hi __builtin_ia32_psrawi (v4hi, int)
  13659. v2si __builtin_ia32_psradi (v2si, int)
  13660. @end smallexample
  13661. The following built-in functions are made available either with
  13662. @option{-msse}, or with a combination of @option{-m3dnow} and
  13663. @option{-march=athlon}. All of them generate the machine
  13664. instruction that is part of the name.
  13665. @smallexample
  13666. v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
  13667. v8qi __builtin_ia32_pavgb (v8qi, v8qi)
  13668. v4hi __builtin_ia32_pavgw (v4hi, v4hi)
  13669. v1di __builtin_ia32_psadbw (v8qi, v8qi)
  13670. v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
  13671. v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
  13672. v8qi __builtin_ia32_pminub (v8qi, v8qi)
  13673. v4hi __builtin_ia32_pminsw (v4hi, v4hi)
  13674. int __builtin_ia32_pmovmskb (v8qi)
  13675. void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
  13676. void __builtin_ia32_movntq (di *, di)
  13677. void __builtin_ia32_sfence (void)
  13678. @end smallexample
  13679. The following built-in functions are available when @option{-msse} is used.
  13680. All of them generate the machine instruction that is part of the name.
  13681. @smallexample
  13682. int __builtin_ia32_comieq (v4sf, v4sf)
  13683. int __builtin_ia32_comineq (v4sf, v4sf)
  13684. int __builtin_ia32_comilt (v4sf, v4sf)
  13685. int __builtin_ia32_comile (v4sf, v4sf)
  13686. int __builtin_ia32_comigt (v4sf, v4sf)
  13687. int __builtin_ia32_comige (v4sf, v4sf)
  13688. int __builtin_ia32_ucomieq (v4sf, v4sf)
  13689. int __builtin_ia32_ucomineq (v4sf, v4sf)
  13690. int __builtin_ia32_ucomilt (v4sf, v4sf)
  13691. int __builtin_ia32_ucomile (v4sf, v4sf)
  13692. int __builtin_ia32_ucomigt (v4sf, v4sf)
  13693. int __builtin_ia32_ucomige (v4sf, v4sf)
  13694. v4sf __builtin_ia32_addps (v4sf, v4sf)
  13695. v4sf __builtin_ia32_subps (v4sf, v4sf)
  13696. v4sf __builtin_ia32_mulps (v4sf, v4sf)
  13697. v4sf __builtin_ia32_divps (v4sf, v4sf)
  13698. v4sf __builtin_ia32_addss (v4sf, v4sf)
  13699. v4sf __builtin_ia32_subss (v4sf, v4sf)
  13700. v4sf __builtin_ia32_mulss (v4sf, v4sf)
  13701. v4sf __builtin_ia32_divss (v4sf, v4sf)
  13702. v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
  13703. v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
  13704. v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
  13705. v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
  13706. v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
  13707. v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
  13708. v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
  13709. v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
  13710. v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
  13711. v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
  13712. v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
  13713. v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
  13714. v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
  13715. v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
  13716. v4sf __builtin_ia32_cmpless (v4sf, v4sf)
  13717. v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
  13718. v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
  13719. v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
  13720. v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
  13721. v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
  13722. v4sf __builtin_ia32_maxps (v4sf, v4sf)
  13723. v4sf __builtin_ia32_maxss (v4sf, v4sf)
  13724. v4sf __builtin_ia32_minps (v4sf, v4sf)
  13725. v4sf __builtin_ia32_minss (v4sf, v4sf)
  13726. v4sf __builtin_ia32_andps (v4sf, v4sf)
  13727. v4sf __builtin_ia32_andnps (v4sf, v4sf)
  13728. v4sf __builtin_ia32_orps (v4sf, v4sf)
  13729. v4sf __builtin_ia32_xorps (v4sf, v4sf)
  13730. v4sf __builtin_ia32_movss (v4sf, v4sf)
  13731. v4sf __builtin_ia32_movhlps (v4sf, v4sf)
  13732. v4sf __builtin_ia32_movlhps (v4sf, v4sf)
  13733. v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
  13734. v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
  13735. v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
  13736. v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
  13737. v2si __builtin_ia32_cvtps2pi (v4sf)
  13738. int __builtin_ia32_cvtss2si (v4sf)
  13739. v2si __builtin_ia32_cvttps2pi (v4sf)
  13740. int __builtin_ia32_cvttss2si (v4sf)
  13741. v4sf __builtin_ia32_rcpps (v4sf)
  13742. v4sf __builtin_ia32_rsqrtps (v4sf)
  13743. v4sf __builtin_ia32_sqrtps (v4sf)
  13744. v4sf __builtin_ia32_rcpss (v4sf)
  13745. v4sf __builtin_ia32_rsqrtss (v4sf)
  13746. v4sf __builtin_ia32_sqrtss (v4sf)
  13747. v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
  13748. void __builtin_ia32_movntps (float *, v4sf)
  13749. int __builtin_ia32_movmskps (v4sf)
  13750. @end smallexample
  13751. The following built-in functions are available when @option{-msse} is used.
  13752. @table @code
  13753. @item v4sf __builtin_ia32_loadups (float *)
  13754. Generates the @code{movups} machine instruction as a load from memory.
  13755. @item void __builtin_ia32_storeups (float *, v4sf)
  13756. Generates the @code{movups} machine instruction as a store to memory.
  13757. @item v4sf __builtin_ia32_loadss (float *)
  13758. Generates the @code{movss} machine instruction as a load from memory.
  13759. @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
  13760. Generates the @code{movhps} machine instruction as a load from memory.
  13761. @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
  13762. Generates the @code{movlps} machine instruction as a load from memory
  13763. @item void __builtin_ia32_storehps (v2sf *, v4sf)
  13764. Generates the @code{movhps} machine instruction as a store to memory.
  13765. @item void __builtin_ia32_storelps (v2sf *, v4sf)
  13766. Generates the @code{movlps} machine instruction as a store to memory.
  13767. @end table
  13768. The following built-in functions are available when @option{-msse2} is used.
  13769. All of them generate the machine instruction that is part of the name.
  13770. @smallexample
  13771. int __builtin_ia32_comisdeq (v2df, v2df)
  13772. int __builtin_ia32_comisdlt (v2df, v2df)
  13773. int __builtin_ia32_comisdle (v2df, v2df)
  13774. int __builtin_ia32_comisdgt (v2df, v2df)
  13775. int __builtin_ia32_comisdge (v2df, v2df)
  13776. int __builtin_ia32_comisdneq (v2df, v2df)
  13777. int __builtin_ia32_ucomisdeq (v2df, v2df)
  13778. int __builtin_ia32_ucomisdlt (v2df, v2df)
  13779. int __builtin_ia32_ucomisdle (v2df, v2df)
  13780. int __builtin_ia32_ucomisdgt (v2df, v2df)
  13781. int __builtin_ia32_ucomisdge (v2df, v2df)
  13782. int __builtin_ia32_ucomisdneq (v2df, v2df)
  13783. v2df __builtin_ia32_cmpeqpd (v2df, v2df)
  13784. v2df __builtin_ia32_cmpltpd (v2df, v2df)
  13785. v2df __builtin_ia32_cmplepd (v2df, v2df)
  13786. v2df __builtin_ia32_cmpgtpd (v2df, v2df)
  13787. v2df __builtin_ia32_cmpgepd (v2df, v2df)
  13788. v2df __builtin_ia32_cmpunordpd (v2df, v2df)
  13789. v2df __builtin_ia32_cmpneqpd (v2df, v2df)
  13790. v2df __builtin_ia32_cmpnltpd (v2df, v2df)
  13791. v2df __builtin_ia32_cmpnlepd (v2df, v2df)
  13792. v2df __builtin_ia32_cmpngtpd (v2df, v2df)
  13793. v2df __builtin_ia32_cmpngepd (v2df, v2df)
  13794. v2df __builtin_ia32_cmpordpd (v2df, v2df)
  13795. v2df __builtin_ia32_cmpeqsd (v2df, v2df)
  13796. v2df __builtin_ia32_cmpltsd (v2df, v2df)
  13797. v2df __builtin_ia32_cmplesd (v2df, v2df)
  13798. v2df __builtin_ia32_cmpunordsd (v2df, v2df)
  13799. v2df __builtin_ia32_cmpneqsd (v2df, v2df)
  13800. v2df __builtin_ia32_cmpnltsd (v2df, v2df)
  13801. v2df __builtin_ia32_cmpnlesd (v2df, v2df)
  13802. v2df __builtin_ia32_cmpordsd (v2df, v2df)
  13803. v2di __builtin_ia32_paddq (v2di, v2di)
  13804. v2di __builtin_ia32_psubq (v2di, v2di)
  13805. v2df __builtin_ia32_addpd (v2df, v2df)
  13806. v2df __builtin_ia32_subpd (v2df, v2df)
  13807. v2df __builtin_ia32_mulpd (v2df, v2df)
  13808. v2df __builtin_ia32_divpd (v2df, v2df)
  13809. v2df __builtin_ia32_addsd (v2df, v2df)
  13810. v2df __builtin_ia32_subsd (v2df, v2df)
  13811. v2df __builtin_ia32_mulsd (v2df, v2df)
  13812. v2df __builtin_ia32_divsd (v2df, v2df)
  13813. v2df __builtin_ia32_minpd (v2df, v2df)
  13814. v2df __builtin_ia32_maxpd (v2df, v2df)
  13815. v2df __builtin_ia32_minsd (v2df, v2df)
  13816. v2df __builtin_ia32_maxsd (v2df, v2df)
  13817. v2df __builtin_ia32_andpd (v2df, v2df)
  13818. v2df __builtin_ia32_andnpd (v2df, v2df)
  13819. v2df __builtin_ia32_orpd (v2df, v2df)
  13820. v2df __builtin_ia32_xorpd (v2df, v2df)
  13821. v2df __builtin_ia32_movsd (v2df, v2df)
  13822. v2df __builtin_ia32_unpckhpd (v2df, v2df)
  13823. v2df __builtin_ia32_unpcklpd (v2df, v2df)
  13824. v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
  13825. v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
  13826. v4si __builtin_ia32_paddd128 (v4si, v4si)
  13827. v2di __builtin_ia32_paddq128 (v2di, v2di)
  13828. v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
  13829. v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
  13830. v4si __builtin_ia32_psubd128 (v4si, v4si)
  13831. v2di __builtin_ia32_psubq128 (v2di, v2di)
  13832. v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
  13833. v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
  13834. v2di __builtin_ia32_pand128 (v2di, v2di)
  13835. v2di __builtin_ia32_pandn128 (v2di, v2di)
  13836. v2di __builtin_ia32_por128 (v2di, v2di)
  13837. v2di __builtin_ia32_pxor128 (v2di, v2di)
  13838. v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
  13839. v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
  13840. v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
  13841. v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
  13842. v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
  13843. v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
  13844. v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
  13845. v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
  13846. v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
  13847. v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
  13848. v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
  13849. v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
  13850. v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
  13851. v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
  13852. v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
  13853. v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
  13854. v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
  13855. v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
  13856. v4si __builtin_ia32_punpckldq128 (v4si, v4si)
  13857. v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
  13858. v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
  13859. v8hi __builtin_ia32_packssdw128 (v4si, v4si)
  13860. v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
  13861. v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
  13862. void __builtin_ia32_maskmovdqu (v16qi, v16qi)
  13863. v2df __builtin_ia32_loadupd (double *)
  13864. void __builtin_ia32_storeupd (double *, v2df)
  13865. v2df __builtin_ia32_loadhpd (v2df, double const *)
  13866. v2df __builtin_ia32_loadlpd (v2df, double const *)
  13867. int __builtin_ia32_movmskpd (v2df)
  13868. int __builtin_ia32_pmovmskb128 (v16qi)
  13869. void __builtin_ia32_movnti (int *, int)
  13870. void __builtin_ia32_movnti64 (long long int *, long long int)
  13871. void __builtin_ia32_movntpd (double *, v2df)
  13872. void __builtin_ia32_movntdq (v2df *, v2df)
  13873. v4si __builtin_ia32_pshufd (v4si, int)
  13874. v8hi __builtin_ia32_pshuflw (v8hi, int)
  13875. v8hi __builtin_ia32_pshufhw (v8hi, int)
  13876. v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
  13877. v2df __builtin_ia32_sqrtpd (v2df)
  13878. v2df __builtin_ia32_sqrtsd (v2df)
  13879. v2df __builtin_ia32_shufpd (v2df, v2df, int)
  13880. v2df __builtin_ia32_cvtdq2pd (v4si)
  13881. v4sf __builtin_ia32_cvtdq2ps (v4si)
  13882. v4si __builtin_ia32_cvtpd2dq (v2df)
  13883. v2si __builtin_ia32_cvtpd2pi (v2df)
  13884. v4sf __builtin_ia32_cvtpd2ps (v2df)
  13885. v4si __builtin_ia32_cvttpd2dq (v2df)
  13886. v2si __builtin_ia32_cvttpd2pi (v2df)
  13887. v2df __builtin_ia32_cvtpi2pd (v2si)
  13888. int __builtin_ia32_cvtsd2si (v2df)
  13889. int __builtin_ia32_cvttsd2si (v2df)
  13890. long long __builtin_ia32_cvtsd2si64 (v2df)
  13891. long long __builtin_ia32_cvttsd2si64 (v2df)
  13892. v4si __builtin_ia32_cvtps2dq (v4sf)
  13893. v2df __builtin_ia32_cvtps2pd (v4sf)
  13894. v4si __builtin_ia32_cvttps2dq (v4sf)
  13895. v2df __builtin_ia32_cvtsi2sd (v2df, int)
  13896. v2df __builtin_ia32_cvtsi642sd (v2df, long long)
  13897. v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
  13898. v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
  13899. void __builtin_ia32_clflush (const void *)
  13900. void __builtin_ia32_lfence (void)
  13901. void __builtin_ia32_mfence (void)
  13902. v16qi __builtin_ia32_loaddqu (const char *)
  13903. void __builtin_ia32_storedqu (char *, v16qi)
  13904. v1di __builtin_ia32_pmuludq (v2si, v2si)
  13905. v2di __builtin_ia32_pmuludq128 (v4si, v4si)
  13906. v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
  13907. v4si __builtin_ia32_pslld128 (v4si, v4si)
  13908. v2di __builtin_ia32_psllq128 (v2di, v2di)
  13909. v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
  13910. v4si __builtin_ia32_psrld128 (v4si, v4si)
  13911. v2di __builtin_ia32_psrlq128 (v2di, v2di)
  13912. v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
  13913. v4si __builtin_ia32_psrad128 (v4si, v4si)
  13914. v2di __builtin_ia32_pslldqi128 (v2di, int)
  13915. v8hi __builtin_ia32_psllwi128 (v8hi, int)
  13916. v4si __builtin_ia32_pslldi128 (v4si, int)
  13917. v2di __builtin_ia32_psllqi128 (v2di, int)
  13918. v2di __builtin_ia32_psrldqi128 (v2di, int)
  13919. v8hi __builtin_ia32_psrlwi128 (v8hi, int)
  13920. v4si __builtin_ia32_psrldi128 (v4si, int)
  13921. v2di __builtin_ia32_psrlqi128 (v2di, int)
  13922. v8hi __builtin_ia32_psrawi128 (v8hi, int)
  13923. v4si __builtin_ia32_psradi128 (v4si, int)
  13924. v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
  13925. v2di __builtin_ia32_movq128 (v2di)
  13926. @end smallexample
  13927. The following built-in functions are available when @option{-msse3} is used.
  13928. All of them generate the machine instruction that is part of the name.
  13929. @smallexample
  13930. v2df __builtin_ia32_addsubpd (v2df, v2df)
  13931. v4sf __builtin_ia32_addsubps (v4sf, v4sf)
  13932. v2df __builtin_ia32_haddpd (v2df, v2df)
  13933. v4sf __builtin_ia32_haddps (v4sf, v4sf)
  13934. v2df __builtin_ia32_hsubpd (v2df, v2df)
  13935. v4sf __builtin_ia32_hsubps (v4sf, v4sf)
  13936. v16qi __builtin_ia32_lddqu (char const *)
  13937. void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
  13938. v4sf __builtin_ia32_movshdup (v4sf)
  13939. v4sf __builtin_ia32_movsldup (v4sf)
  13940. void __builtin_ia32_mwait (unsigned int, unsigned int)
  13941. @end smallexample
  13942. The following built-in functions are available when @option{-mssse3} is used.
  13943. All of them generate the machine instruction that is part of the name.
  13944. @smallexample
  13945. v2si __builtin_ia32_phaddd (v2si, v2si)
  13946. v4hi __builtin_ia32_phaddw (v4hi, v4hi)
  13947. v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
  13948. v2si __builtin_ia32_phsubd (v2si, v2si)
  13949. v4hi __builtin_ia32_phsubw (v4hi, v4hi)
  13950. v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
  13951. v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
  13952. v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
  13953. v8qi __builtin_ia32_pshufb (v8qi, v8qi)
  13954. v8qi __builtin_ia32_psignb (v8qi, v8qi)
  13955. v2si __builtin_ia32_psignd (v2si, v2si)
  13956. v4hi __builtin_ia32_psignw (v4hi, v4hi)
  13957. v1di __builtin_ia32_palignr (v1di, v1di, int)
  13958. v8qi __builtin_ia32_pabsb (v8qi)
  13959. v2si __builtin_ia32_pabsd (v2si)
  13960. v4hi __builtin_ia32_pabsw (v4hi)
  13961. @end smallexample
  13962. The following built-in functions are available when @option{-mssse3} is used.
  13963. All of them generate the machine instruction that is part of the name.
  13964. @smallexample
  13965. v4si __builtin_ia32_phaddd128 (v4si, v4si)
  13966. v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
  13967. v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
  13968. v4si __builtin_ia32_phsubd128 (v4si, v4si)
  13969. v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
  13970. v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
  13971. v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
  13972. v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
  13973. v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
  13974. v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
  13975. v4si __builtin_ia32_psignd128 (v4si, v4si)
  13976. v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
  13977. v2di __builtin_ia32_palignr128 (v2di, v2di, int)
  13978. v16qi __builtin_ia32_pabsb128 (v16qi)
  13979. v4si __builtin_ia32_pabsd128 (v4si)
  13980. v8hi __builtin_ia32_pabsw128 (v8hi)
  13981. @end smallexample
  13982. The following built-in functions are available when @option{-msse4.1} is
  13983. used. All of them generate the machine instruction that is part of the
  13984. name.
  13985. @smallexample
  13986. v2df __builtin_ia32_blendpd (v2df, v2df, const int)
  13987. v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
  13988. v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
  13989. v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
  13990. v2df __builtin_ia32_dppd (v2df, v2df, const int)
  13991. v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
  13992. v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
  13993. v2di __builtin_ia32_movntdqa (v2di *);
  13994. v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
  13995. v8hi __builtin_ia32_packusdw128 (v4si, v4si)
  13996. v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
  13997. v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
  13998. v2di __builtin_ia32_pcmpeqq (v2di, v2di)
  13999. v8hi __builtin_ia32_phminposuw128 (v8hi)
  14000. v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
  14001. v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
  14002. v4si __builtin_ia32_pmaxud128 (v4si, v4si)
  14003. v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
  14004. v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
  14005. v4si __builtin_ia32_pminsd128 (v4si, v4si)
  14006. v4si __builtin_ia32_pminud128 (v4si, v4si)
  14007. v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
  14008. v4si __builtin_ia32_pmovsxbd128 (v16qi)
  14009. v2di __builtin_ia32_pmovsxbq128 (v16qi)
  14010. v8hi __builtin_ia32_pmovsxbw128 (v16qi)
  14011. v2di __builtin_ia32_pmovsxdq128 (v4si)
  14012. v4si __builtin_ia32_pmovsxwd128 (v8hi)
  14013. v2di __builtin_ia32_pmovsxwq128 (v8hi)
  14014. v4si __builtin_ia32_pmovzxbd128 (v16qi)
  14015. v2di __builtin_ia32_pmovzxbq128 (v16qi)
  14016. v8hi __builtin_ia32_pmovzxbw128 (v16qi)
  14017. v2di __builtin_ia32_pmovzxdq128 (v4si)
  14018. v4si __builtin_ia32_pmovzxwd128 (v8hi)
  14019. v2di __builtin_ia32_pmovzxwq128 (v8hi)
  14020. v2di __builtin_ia32_pmuldq128 (v4si, v4si)
  14021. v4si __builtin_ia32_pmulld128 (v4si, v4si)
  14022. int __builtin_ia32_ptestc128 (v2di, v2di)
  14023. int __builtin_ia32_ptestnzc128 (v2di, v2di)
  14024. int __builtin_ia32_ptestz128 (v2di, v2di)
  14025. v2df __builtin_ia32_roundpd (v2df, const int)
  14026. v4sf __builtin_ia32_roundps (v4sf, const int)
  14027. v2df __builtin_ia32_roundsd (v2df, v2df, const int)
  14028. v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
  14029. @end smallexample
  14030. The following built-in functions are available when @option{-msse4.1} is
  14031. used.
  14032. @table @code
  14033. @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
  14034. Generates the @code{insertps} machine instruction.
  14035. @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
  14036. Generates the @code{pextrb} machine instruction.
  14037. @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
  14038. Generates the @code{pinsrb} machine instruction.
  14039. @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
  14040. Generates the @code{pinsrd} machine instruction.
  14041. @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
  14042. Generates the @code{pinsrq} machine instruction in 64bit mode.
  14043. @end table
  14044. The following built-in functions are changed to generate new SSE4.1
  14045. instructions when @option{-msse4.1} is used.
  14046. @table @code
  14047. @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
  14048. Generates the @code{extractps} machine instruction.
  14049. @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
  14050. Generates the @code{pextrd} machine instruction.
  14051. @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
  14052. Generates the @code{pextrq} machine instruction in 64bit mode.
  14053. @end table
  14054. The following built-in functions are available when @option{-msse4.2} is
  14055. used. All of them generate the machine instruction that is part of the
  14056. name.
  14057. @smallexample
  14058. v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
  14059. int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
  14060. int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
  14061. int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
  14062. int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
  14063. int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
  14064. int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
  14065. v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
  14066. int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
  14067. int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
  14068. int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
  14069. int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
  14070. int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
  14071. int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
  14072. v2di __builtin_ia32_pcmpgtq (v2di, v2di)
  14073. @end smallexample
  14074. The following built-in functions are available when @option{-msse4.2} is
  14075. used.
  14076. @table @code
  14077. @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
  14078. Generates the @code{crc32b} machine instruction.
  14079. @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
  14080. Generates the @code{crc32w} machine instruction.
  14081. @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
  14082. Generates the @code{crc32l} machine instruction.
  14083. @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
  14084. Generates the @code{crc32q} machine instruction.
  14085. @end table
  14086. The following built-in functions are changed to generate new SSE4.2
  14087. instructions when @option{-msse4.2} is used.
  14088. @table @code
  14089. @item int __builtin_popcount (unsigned int)
  14090. Generates the @code{popcntl} machine instruction.
  14091. @item int __builtin_popcountl (unsigned long)
  14092. Generates the @code{popcntl} or @code{popcntq} machine instruction,
  14093. depending on the size of @code{unsigned long}.
  14094. @item int __builtin_popcountll (unsigned long long)
  14095. Generates the @code{popcntq} machine instruction.
  14096. @end table
  14097. The following built-in functions are available when @option{-mavx} is
  14098. used. All of them generate the machine instruction that is part of the
  14099. name.
  14100. @smallexample
  14101. v4df __builtin_ia32_addpd256 (v4df,v4df)
  14102. v8sf __builtin_ia32_addps256 (v8sf,v8sf)
  14103. v4df __builtin_ia32_addsubpd256 (v4df,v4df)
  14104. v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
  14105. v4df __builtin_ia32_andnpd256 (v4df,v4df)
  14106. v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
  14107. v4df __builtin_ia32_andpd256 (v4df,v4df)
  14108. v8sf __builtin_ia32_andps256 (v8sf,v8sf)
  14109. v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
  14110. v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
  14111. v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
  14112. v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
  14113. v2df __builtin_ia32_cmppd (v2df,v2df,int)
  14114. v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
  14115. v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
  14116. v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
  14117. v2df __builtin_ia32_cmpsd (v2df,v2df,int)
  14118. v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
  14119. v4df __builtin_ia32_cvtdq2pd256 (v4si)
  14120. v8sf __builtin_ia32_cvtdq2ps256 (v8si)
  14121. v4si __builtin_ia32_cvtpd2dq256 (v4df)
  14122. v4sf __builtin_ia32_cvtpd2ps256 (v4df)
  14123. v8si __builtin_ia32_cvtps2dq256 (v8sf)
  14124. v4df __builtin_ia32_cvtps2pd256 (v4sf)
  14125. v4si __builtin_ia32_cvttpd2dq256 (v4df)
  14126. v8si __builtin_ia32_cvttps2dq256 (v8sf)
  14127. v4df __builtin_ia32_divpd256 (v4df,v4df)
  14128. v8sf __builtin_ia32_divps256 (v8sf,v8sf)
  14129. v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
  14130. v4df __builtin_ia32_haddpd256 (v4df,v4df)
  14131. v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
  14132. v4df __builtin_ia32_hsubpd256 (v4df,v4df)
  14133. v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
  14134. v32qi __builtin_ia32_lddqu256 (pcchar)
  14135. v32qi __builtin_ia32_loaddqu256 (pcchar)
  14136. v4df __builtin_ia32_loadupd256 (pcdouble)
  14137. v8sf __builtin_ia32_loadups256 (pcfloat)
  14138. v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
  14139. v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
  14140. v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
  14141. v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
  14142. void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
  14143. void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
  14144. void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
  14145. void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
  14146. v4df __builtin_ia32_maxpd256 (v4df,v4df)
  14147. v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
  14148. v4df __builtin_ia32_minpd256 (v4df,v4df)
  14149. v8sf __builtin_ia32_minps256 (v8sf,v8sf)
  14150. v4df __builtin_ia32_movddup256 (v4df)
  14151. int __builtin_ia32_movmskpd256 (v4df)
  14152. int __builtin_ia32_movmskps256 (v8sf)
  14153. v8sf __builtin_ia32_movshdup256 (v8sf)
  14154. v8sf __builtin_ia32_movsldup256 (v8sf)
  14155. v4df __builtin_ia32_mulpd256 (v4df,v4df)
  14156. v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
  14157. v4df __builtin_ia32_orpd256 (v4df,v4df)
  14158. v8sf __builtin_ia32_orps256 (v8sf,v8sf)
  14159. v2df __builtin_ia32_pd_pd256 (v4df)
  14160. v4df __builtin_ia32_pd256_pd (v2df)
  14161. v4sf __builtin_ia32_ps_ps256 (v8sf)
  14162. v8sf __builtin_ia32_ps256_ps (v4sf)
  14163. int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
  14164. int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
  14165. int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
  14166. v8sf __builtin_ia32_rcpps256 (v8sf)
  14167. v4df __builtin_ia32_roundpd256 (v4df,int)
  14168. v8sf __builtin_ia32_roundps256 (v8sf,int)
  14169. v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
  14170. v8sf __builtin_ia32_rsqrtps256 (v8sf)
  14171. v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
  14172. v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
  14173. v4si __builtin_ia32_si_si256 (v8si)
  14174. v8si __builtin_ia32_si256_si (v4si)
  14175. v4df __builtin_ia32_sqrtpd256 (v4df)
  14176. v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
  14177. v8sf __builtin_ia32_sqrtps256 (v8sf)
  14178. void __builtin_ia32_storedqu256 (pchar,v32qi)
  14179. void __builtin_ia32_storeupd256 (pdouble,v4df)
  14180. void __builtin_ia32_storeups256 (pfloat,v8sf)
  14181. v4df __builtin_ia32_subpd256 (v4df,v4df)
  14182. v8sf __builtin_ia32_subps256 (v8sf,v8sf)
  14183. v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
  14184. v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
  14185. v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
  14186. v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
  14187. v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
  14188. v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
  14189. v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
  14190. v4sf __builtin_ia32_vbroadcastss (pcfloat)
  14191. v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
  14192. v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
  14193. v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
  14194. v4si __builtin_ia32_vextractf128_si256 (v8si,int)
  14195. v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
  14196. v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
  14197. v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
  14198. v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
  14199. v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
  14200. v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
  14201. v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
  14202. v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
  14203. v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
  14204. v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
  14205. v2df __builtin_ia32_vpermilpd (v2df,int)
  14206. v4df __builtin_ia32_vpermilpd256 (v4df,int)
  14207. v4sf __builtin_ia32_vpermilps (v4sf,int)
  14208. v8sf __builtin_ia32_vpermilps256 (v8sf,int)
  14209. v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
  14210. v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
  14211. v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
  14212. v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
  14213. int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
  14214. int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
  14215. int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
  14216. int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
  14217. int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
  14218. int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
  14219. int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
  14220. int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
  14221. int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
  14222. int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
  14223. int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
  14224. int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
  14225. void __builtin_ia32_vzeroall (void)
  14226. void __builtin_ia32_vzeroupper (void)
  14227. v4df __builtin_ia32_xorpd256 (v4df,v4df)
  14228. v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
  14229. @end smallexample
  14230. The following built-in functions are available when @option{-mavx2} is
  14231. used. All of them generate the machine instruction that is part of the
  14232. name.
  14233. @smallexample
  14234. v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
  14235. v32qi __builtin_ia32_pabsb256 (v32qi)
  14236. v16hi __builtin_ia32_pabsw256 (v16hi)
  14237. v8si __builtin_ia32_pabsd256 (v8si)
  14238. v16hi __builtin_ia32_packssdw256 (v8si,v8si)
  14239. v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
  14240. v16hi __builtin_ia32_packusdw256 (v8si,v8si)
  14241. v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
  14242. v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
  14243. v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
  14244. v8si __builtin_ia32_paddd256 (v8si,v8si)
  14245. v4di __builtin_ia32_paddq256 (v4di,v4di)
  14246. v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
  14247. v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
  14248. v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
  14249. v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
  14250. v4di __builtin_ia32_palignr256 (v4di,v4di,int)
  14251. v4di __builtin_ia32_andsi256 (v4di,v4di)
  14252. v4di __builtin_ia32_andnotsi256 (v4di,v4di)
  14253. v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
  14254. v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
  14255. v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
  14256. v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
  14257. v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
  14258. v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
  14259. v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
  14260. v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
  14261. v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
  14262. v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
  14263. v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
  14264. v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
  14265. v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
  14266. v8si __builtin_ia32_phaddd256 (v8si,v8si)
  14267. v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
  14268. v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
  14269. v8si __builtin_ia32_phsubd256 (v8si,v8si)
  14270. v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
  14271. v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
  14272. v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
  14273. v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
  14274. v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
  14275. v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
  14276. v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
  14277. v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
  14278. v8si __builtin_ia32_pmaxud256 (v8si,v8si)
  14279. v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
  14280. v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
  14281. v8si __builtin_ia32_pminsd256 (v8si,v8si)
  14282. v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
  14283. v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
  14284. v8si __builtin_ia32_pminud256 (v8si,v8si)
  14285. int __builtin_ia32_pmovmskb256 (v32qi)
  14286. v16hi __builtin_ia32_pmovsxbw256 (v16qi)
  14287. v8si __builtin_ia32_pmovsxbd256 (v16qi)
  14288. v4di __builtin_ia32_pmovsxbq256 (v16qi)
  14289. v8si __builtin_ia32_pmovsxwd256 (v8hi)
  14290. v4di __builtin_ia32_pmovsxwq256 (v8hi)
  14291. v4di __builtin_ia32_pmovsxdq256 (v4si)
  14292. v16hi __builtin_ia32_pmovzxbw256 (v16qi)
  14293. v8si __builtin_ia32_pmovzxbd256 (v16qi)
  14294. v4di __builtin_ia32_pmovzxbq256 (v16qi)
  14295. v8si __builtin_ia32_pmovzxwd256 (v8hi)
  14296. v4di __builtin_ia32_pmovzxwq256 (v8hi)
  14297. v4di __builtin_ia32_pmovzxdq256 (v4si)
  14298. v4di __builtin_ia32_pmuldq256 (v8si,v8si)
  14299. v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
  14300. v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
  14301. v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
  14302. v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
  14303. v8si __builtin_ia32_pmulld256 (v8si,v8si)
  14304. v4di __builtin_ia32_pmuludq256 (v8si,v8si)
  14305. v4di __builtin_ia32_por256 (v4di,v4di)
  14306. v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
  14307. v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
  14308. v8si __builtin_ia32_pshufd256 (v8si,int)
  14309. v16hi __builtin_ia32_pshufhw256 (v16hi,int)
  14310. v16hi __builtin_ia32_pshuflw256 (v16hi,int)
  14311. v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
  14312. v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
  14313. v8si __builtin_ia32_psignd256 (v8si,v8si)
  14314. v4di __builtin_ia32_pslldqi256 (v4di,int)
  14315. v16hi __builtin_ia32_psllwi256 (16hi,int)
  14316. v16hi __builtin_ia32_psllw256(v16hi,v8hi)
  14317. v8si __builtin_ia32_pslldi256 (v8si,int)
  14318. v8si __builtin_ia32_pslld256(v8si,v4si)
  14319. v4di __builtin_ia32_psllqi256 (v4di,int)
  14320. v4di __builtin_ia32_psllq256(v4di,v2di)
  14321. v16hi __builtin_ia32_psrawi256 (v16hi,int)
  14322. v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
  14323. v8si __builtin_ia32_psradi256 (v8si,int)
  14324. v8si __builtin_ia32_psrad256 (v8si,v4si)
  14325. v4di __builtin_ia32_psrldqi256 (v4di, int)
  14326. v16hi __builtin_ia32_psrlwi256 (v16hi,int)
  14327. v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
  14328. v8si __builtin_ia32_psrldi256 (v8si,int)
  14329. v8si __builtin_ia32_psrld256 (v8si,v4si)
  14330. v4di __builtin_ia32_psrlqi256 (v4di,int)
  14331. v4di __builtin_ia32_psrlq256(v4di,v2di)
  14332. v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
  14333. v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
  14334. v8si __builtin_ia32_psubd256 (v8si,v8si)
  14335. v4di __builtin_ia32_psubq256 (v4di,v4di)
  14336. v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
  14337. v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
  14338. v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
  14339. v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
  14340. v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
  14341. v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
  14342. v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
  14343. v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
  14344. v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
  14345. v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
  14346. v8si __builtin_ia32_punpckldq256 (v8si,v8si)
  14347. v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
  14348. v4di __builtin_ia32_pxor256 (v4di,v4di)
  14349. v4di __builtin_ia32_movntdqa256 (pv4di)
  14350. v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
  14351. v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
  14352. v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
  14353. v4di __builtin_ia32_vbroadcastsi256 (v2di)
  14354. v4si __builtin_ia32_pblendd128 (v4si,v4si)
  14355. v8si __builtin_ia32_pblendd256 (v8si,v8si)
  14356. v32qi __builtin_ia32_pbroadcastb256 (v16qi)
  14357. v16hi __builtin_ia32_pbroadcastw256 (v8hi)
  14358. v8si __builtin_ia32_pbroadcastd256 (v4si)
  14359. v4di __builtin_ia32_pbroadcastq256 (v2di)
  14360. v16qi __builtin_ia32_pbroadcastb128 (v16qi)
  14361. v8hi __builtin_ia32_pbroadcastw128 (v8hi)
  14362. v4si __builtin_ia32_pbroadcastd128 (v4si)
  14363. v2di __builtin_ia32_pbroadcastq128 (v2di)
  14364. v8si __builtin_ia32_permvarsi256 (v8si,v8si)
  14365. v4df __builtin_ia32_permdf256 (v4df,int)
  14366. v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
  14367. v4di __builtin_ia32_permdi256 (v4di,int)
  14368. v4di __builtin_ia32_permti256 (v4di,v4di,int)
  14369. v4di __builtin_ia32_extract128i256 (v4di,int)
  14370. v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
  14371. v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
  14372. v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
  14373. v4si __builtin_ia32_maskloadd (pcv4si,v4si)
  14374. v2di __builtin_ia32_maskloadq (pcv2di,v2di)
  14375. void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
  14376. void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
  14377. void __builtin_ia32_maskstored (pv4si,v4si,v4si)
  14378. void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
  14379. v8si __builtin_ia32_psllv8si (v8si,v8si)
  14380. v4si __builtin_ia32_psllv4si (v4si,v4si)
  14381. v4di __builtin_ia32_psllv4di (v4di,v4di)
  14382. v2di __builtin_ia32_psllv2di (v2di,v2di)
  14383. v8si __builtin_ia32_psrav8si (v8si,v8si)
  14384. v4si __builtin_ia32_psrav4si (v4si,v4si)
  14385. v8si __builtin_ia32_psrlv8si (v8si,v8si)
  14386. v4si __builtin_ia32_psrlv4si (v4si,v4si)
  14387. v4di __builtin_ia32_psrlv4di (v4di,v4di)
  14388. v2di __builtin_ia32_psrlv2di (v2di,v2di)
  14389. v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
  14390. v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
  14391. v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
  14392. v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
  14393. v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
  14394. v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
  14395. v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
  14396. v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
  14397. v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
  14398. v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
  14399. v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
  14400. v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
  14401. v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
  14402. v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
  14403. v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
  14404. v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
  14405. @end smallexample
  14406. The following built-in functions are available when @option{-maes} is
  14407. used. All of them generate the machine instruction that is part of the
  14408. name.
  14409. @smallexample
  14410. v2di __builtin_ia32_aesenc128 (v2di, v2di)
  14411. v2di __builtin_ia32_aesenclast128 (v2di, v2di)
  14412. v2di __builtin_ia32_aesdec128 (v2di, v2di)
  14413. v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
  14414. v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
  14415. v2di __builtin_ia32_aesimc128 (v2di)
  14416. @end smallexample
  14417. The following built-in function is available when @option{-mpclmul} is
  14418. used.
  14419. @table @code
  14420. @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
  14421. Generates the @code{pclmulqdq} machine instruction.
  14422. @end table
  14423. The following built-in function is available when @option{-mfsgsbase} is
  14424. used. All of them generate the machine instruction that is part of the
  14425. name.
  14426. @smallexample
  14427. unsigned int __builtin_ia32_rdfsbase32 (void)
  14428. unsigned long long __builtin_ia32_rdfsbase64 (void)
  14429. unsigned int __builtin_ia32_rdgsbase32 (void)
  14430. unsigned long long __builtin_ia32_rdgsbase64 (void)
  14431. void _writefsbase_u32 (unsigned int)
  14432. void _writefsbase_u64 (unsigned long long)
  14433. void _writegsbase_u32 (unsigned int)
  14434. void _writegsbase_u64 (unsigned long long)
  14435. @end smallexample
  14436. The following built-in function is available when @option{-mrdrnd} is
  14437. used. All of them generate the machine instruction that is part of the
  14438. name.
  14439. @smallexample
  14440. unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
  14441. unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
  14442. unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
  14443. @end smallexample
  14444. The following built-in functions are available when @option{-msse4a} is used.
  14445. All of them generate the machine instruction that is part of the name.
  14446. @smallexample
  14447. void __builtin_ia32_movntsd (double *, v2df)
  14448. void __builtin_ia32_movntss (float *, v4sf)
  14449. v2di __builtin_ia32_extrq (v2di, v16qi)
  14450. v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
  14451. v2di __builtin_ia32_insertq (v2di, v2di)
  14452. v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
  14453. @end smallexample
  14454. The following built-in functions are available when @option{-mxop} is used.
  14455. @smallexample
  14456. v2df __builtin_ia32_vfrczpd (v2df)
  14457. v4sf __builtin_ia32_vfrczps (v4sf)
  14458. v2df __builtin_ia32_vfrczsd (v2df)
  14459. v4sf __builtin_ia32_vfrczss (v4sf)
  14460. v4df __builtin_ia32_vfrczpd256 (v4df)
  14461. v8sf __builtin_ia32_vfrczps256 (v8sf)
  14462. v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
  14463. v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
  14464. v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
  14465. v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
  14466. v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
  14467. v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
  14468. v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
  14469. v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
  14470. v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
  14471. v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
  14472. v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
  14473. v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
  14474. v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
  14475. v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
  14476. v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
  14477. v4si __builtin_ia32_vpcomeqd (v4si, v4si)
  14478. v2di __builtin_ia32_vpcomeqq (v2di, v2di)
  14479. v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
  14480. v4si __builtin_ia32_vpcomequd (v4si, v4si)
  14481. v2di __builtin_ia32_vpcomequq (v2di, v2di)
  14482. v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
  14483. v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
  14484. v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
  14485. v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
  14486. v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
  14487. v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
  14488. v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
  14489. v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
  14490. v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
  14491. v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
  14492. v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
  14493. v4si __builtin_ia32_vpcomged (v4si, v4si)
  14494. v2di __builtin_ia32_vpcomgeq (v2di, v2di)
  14495. v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
  14496. v4si __builtin_ia32_vpcomgeud (v4si, v4si)
  14497. v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
  14498. v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
  14499. v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
  14500. v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
  14501. v4si __builtin_ia32_vpcomgtd (v4si, v4si)
  14502. v2di __builtin_ia32_vpcomgtq (v2di, v2di)
  14503. v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
  14504. v4si __builtin_ia32_vpcomgtud (v4si, v4si)
  14505. v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
  14506. v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
  14507. v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
  14508. v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
  14509. v4si __builtin_ia32_vpcomled (v4si, v4si)
  14510. v2di __builtin_ia32_vpcomleq (v2di, v2di)
  14511. v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
  14512. v4si __builtin_ia32_vpcomleud (v4si, v4si)
  14513. v2di __builtin_ia32_vpcomleuq (v2di, v2di)
  14514. v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
  14515. v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
  14516. v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
  14517. v4si __builtin_ia32_vpcomltd (v4si, v4si)
  14518. v2di __builtin_ia32_vpcomltq (v2di, v2di)
  14519. v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
  14520. v4si __builtin_ia32_vpcomltud (v4si, v4si)
  14521. v2di __builtin_ia32_vpcomltuq (v2di, v2di)
  14522. v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
  14523. v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
  14524. v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
  14525. v4si __builtin_ia32_vpcomned (v4si, v4si)
  14526. v2di __builtin_ia32_vpcomneq (v2di, v2di)
  14527. v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
  14528. v4si __builtin_ia32_vpcomneud (v4si, v4si)
  14529. v2di __builtin_ia32_vpcomneuq (v2di, v2di)
  14530. v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
  14531. v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
  14532. v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
  14533. v4si __builtin_ia32_vpcomtrued (v4si, v4si)
  14534. v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
  14535. v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
  14536. v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
  14537. v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
  14538. v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
  14539. v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
  14540. v4si __builtin_ia32_vphaddbd (v16qi)
  14541. v2di __builtin_ia32_vphaddbq (v16qi)
  14542. v8hi __builtin_ia32_vphaddbw (v16qi)
  14543. v2di __builtin_ia32_vphadddq (v4si)
  14544. v4si __builtin_ia32_vphaddubd (v16qi)
  14545. v2di __builtin_ia32_vphaddubq (v16qi)
  14546. v8hi __builtin_ia32_vphaddubw (v16qi)
  14547. v2di __builtin_ia32_vphaddudq (v4si)
  14548. v4si __builtin_ia32_vphadduwd (v8hi)
  14549. v2di __builtin_ia32_vphadduwq (v8hi)
  14550. v4si __builtin_ia32_vphaddwd (v8hi)
  14551. v2di __builtin_ia32_vphaddwq (v8hi)
  14552. v8hi __builtin_ia32_vphsubbw (v16qi)
  14553. v2di __builtin_ia32_vphsubdq (v4si)
  14554. v4si __builtin_ia32_vphsubwd (v8hi)
  14555. v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
  14556. v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
  14557. v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
  14558. v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
  14559. v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
  14560. v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
  14561. v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
  14562. v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
  14563. v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
  14564. v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
  14565. v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
  14566. v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
  14567. v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
  14568. v16qi __builtin_ia32_vprotb (v16qi, v16qi)
  14569. v4si __builtin_ia32_vprotd (v4si, v4si)
  14570. v2di __builtin_ia32_vprotq (v2di, v2di)
  14571. v8hi __builtin_ia32_vprotw (v8hi, v8hi)
  14572. v16qi __builtin_ia32_vpshab (v16qi, v16qi)
  14573. v4si __builtin_ia32_vpshad (v4si, v4si)
  14574. v2di __builtin_ia32_vpshaq (v2di, v2di)
  14575. v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
  14576. v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
  14577. v4si __builtin_ia32_vpshld (v4si, v4si)
  14578. v2di __builtin_ia32_vpshlq (v2di, v2di)
  14579. v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
  14580. @end smallexample
  14581. The following built-in functions are available when @option{-mfma4} is used.
  14582. All of them generate the machine instruction that is part of the name.
  14583. @smallexample
  14584. v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
  14585. v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
  14586. v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
  14587. v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
  14588. v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
  14589. v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
  14590. v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
  14591. v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
  14592. v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
  14593. v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
  14594. v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
  14595. v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
  14596. v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
  14597. v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
  14598. v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
  14599. v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
  14600. v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
  14601. v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
  14602. v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
  14603. v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
  14604. v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
  14605. v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
  14606. v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
  14607. v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
  14608. v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
  14609. v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
  14610. v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
  14611. v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
  14612. v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
  14613. v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
  14614. v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
  14615. v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
  14616. @end smallexample
  14617. The following built-in functions are available when @option{-mlwp} is used.
  14618. @smallexample
  14619. void __builtin_ia32_llwpcb16 (void *);
  14620. void __builtin_ia32_llwpcb32 (void *);
  14621. void __builtin_ia32_llwpcb64 (void *);
  14622. void * __builtin_ia32_llwpcb16 (void);
  14623. void * __builtin_ia32_llwpcb32 (void);
  14624. void * __builtin_ia32_llwpcb64 (void);
  14625. void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
  14626. void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
  14627. void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
  14628. unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
  14629. unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
  14630. unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
  14631. @end smallexample
  14632. The following built-in functions are available when @option{-mbmi} is used.
  14633. All of them generate the machine instruction that is part of the name.
  14634. @smallexample
  14635. unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
  14636. unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
  14637. @end smallexample
  14638. The following built-in functions are available when @option{-mbmi2} is used.
  14639. All of them generate the machine instruction that is part of the name.
  14640. @smallexample
  14641. unsigned int _bzhi_u32 (unsigned int, unsigned int)
  14642. unsigned int _pdep_u32 (unsigned int, unsigned int)
  14643. unsigned int _pext_u32 (unsigned int, unsigned int)
  14644. unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
  14645. unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
  14646. unsigned long long _pext_u64 (unsigned long long, unsigned long long)
  14647. @end smallexample
  14648. The following built-in functions are available when @option{-mlzcnt} is used.
  14649. All of them generate the machine instruction that is part of the name.
  14650. @smallexample
  14651. unsigned short __builtin_ia32_lzcnt_16(unsigned short);
  14652. unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
  14653. unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
  14654. @end smallexample
  14655. The following built-in functions are available when @option{-mfxsr} is used.
  14656. All of them generate the machine instruction that is part of the name.
  14657. @smallexample
  14658. void __builtin_ia32_fxsave (void *)
  14659. void __builtin_ia32_fxrstor (void *)
  14660. void __builtin_ia32_fxsave64 (void *)
  14661. void __builtin_ia32_fxrstor64 (void *)
  14662. @end smallexample
  14663. The following built-in functions are available when @option{-mxsave} is used.
  14664. All of them generate the machine instruction that is part of the name.
  14665. @smallexample
  14666. void __builtin_ia32_xsave (void *, long long)
  14667. void __builtin_ia32_xrstor (void *, long long)
  14668. void __builtin_ia32_xsave64 (void *, long long)
  14669. void __builtin_ia32_xrstor64 (void *, long long)
  14670. @end smallexample
  14671. The following built-in functions are available when @option{-mxsaveopt} is used.
  14672. All of them generate the machine instruction that is part of the name.
  14673. @smallexample
  14674. void __builtin_ia32_xsaveopt (void *, long long)
  14675. void __builtin_ia32_xsaveopt64 (void *, long long)
  14676. @end smallexample
  14677. The following built-in functions are available when @option{-mtbm} is used.
  14678. Both of them generate the immediate form of the bextr machine instruction.
  14679. @smallexample
  14680. unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
  14681. unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
  14682. @end smallexample
  14683. The following built-in functions are available when @option{-m3dnow} is used.
  14684. All of them generate the machine instruction that is part of the name.
  14685. @smallexample
  14686. void __builtin_ia32_femms (void)
  14687. v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
  14688. v2si __builtin_ia32_pf2id (v2sf)
  14689. v2sf __builtin_ia32_pfacc (v2sf, v2sf)
  14690. v2sf __builtin_ia32_pfadd (v2sf, v2sf)
  14691. v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
  14692. v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
  14693. v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
  14694. v2sf __builtin_ia32_pfmax (v2sf, v2sf)
  14695. v2sf __builtin_ia32_pfmin (v2sf, v2sf)
  14696. v2sf __builtin_ia32_pfmul (v2sf, v2sf)
  14697. v2sf __builtin_ia32_pfrcp (v2sf)
  14698. v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
  14699. v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
  14700. v2sf __builtin_ia32_pfrsqrt (v2sf)
  14701. v2sf __builtin_ia32_pfsub (v2sf, v2sf)
  14702. v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
  14703. v2sf __builtin_ia32_pi2fd (v2si)
  14704. v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
  14705. @end smallexample
  14706. The following built-in functions are available when both @option{-m3dnow}
  14707. and @option{-march=athlon} are used. All of them generate the machine
  14708. instruction that is part of the name.
  14709. @smallexample
  14710. v2si __builtin_ia32_pf2iw (v2sf)
  14711. v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
  14712. v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
  14713. v2sf __builtin_ia32_pi2fw (v2si)
  14714. v2sf __builtin_ia32_pswapdsf (v2sf)
  14715. v2si __builtin_ia32_pswapdsi (v2si)
  14716. @end smallexample
  14717. The following built-in functions are available when @option{-mrtm} is used
  14718. They are used for restricted transactional memory. These are the internal
  14719. low level functions. Normally the functions in
  14720. @ref{x86 transactional memory intrinsics} should be used instead.
  14721. @smallexample
  14722. int __builtin_ia32_xbegin ()
  14723. void __builtin_ia32_xend ()
  14724. void __builtin_ia32_xabort (status)
  14725. int __builtin_ia32_xtest ()
  14726. @end smallexample
  14727. The following built-in functions are available when @option{-mmwaitx} is used.
  14728. All of them generate the machine instruction that is part of the name.
  14729. @smallexample
  14730. void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
  14731. void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
  14732. @end smallexample
  14733. @node x86 transactional memory intrinsics
  14734. @subsection x86 Transactional Memory Intrinsics
  14735. These hardware transactional memory intrinsics for x86 allow you to use
  14736. memory transactions with RTM (Restricted Transactional Memory).
  14737. This support is enabled with the @option{-mrtm} option.
  14738. For using HLE (Hardware Lock Elision) see
  14739. @ref{x86 specific memory model extensions for transactional memory} instead.
  14740. A memory transaction commits all changes to memory in an atomic way,
  14741. as visible to other threads. If the transaction fails it is rolled back
  14742. and all side effects discarded.
  14743. Generally there is no guarantee that a memory transaction ever succeeds
  14744. and suitable fallback code always needs to be supplied.
  14745. @deftypefn {RTM Function} {unsigned} _xbegin ()
  14746. Start a RTM (Restricted Transactional Memory) transaction.
  14747. Returns @code{_XBEGIN_STARTED} when the transaction
  14748. started successfully (note this is not 0, so the constant has to be
  14749. explicitly tested).
  14750. If the transaction aborts, all side-effects
  14751. are undone and an abort code encoded as a bit mask is returned.
  14752. The following macros are defined:
  14753. @table @code
  14754. @item _XABORT_EXPLICIT
  14755. Transaction was explicitly aborted with @code{_xabort}. The parameter passed
  14756. to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
  14757. @item _XABORT_RETRY
  14758. Transaction retry is possible.
  14759. @item _XABORT_CONFLICT
  14760. Transaction abort due to a memory conflict with another thread.
  14761. @item _XABORT_CAPACITY
  14762. Transaction abort due to the transaction using too much memory.
  14763. @item _XABORT_DEBUG
  14764. Transaction abort due to a debug trap.
  14765. @item _XABORT_NESTED
  14766. Transaction abort in an inner nested transaction.
  14767. @end table
  14768. There is no guarantee
  14769. any transaction ever succeeds, so there always needs to be a valid
  14770. fallback path.
  14771. @end deftypefn
  14772. @deftypefn {RTM Function} {void} _xend ()
  14773. Commit the current transaction. When no transaction is active this faults.
  14774. All memory side-effects of the transaction become visible
  14775. to other threads in an atomic manner.
  14776. @end deftypefn
  14777. @deftypefn {RTM Function} {int} _xtest ()
  14778. Return a nonzero value if a transaction is currently active, otherwise 0.
  14779. @end deftypefn
  14780. @deftypefn {RTM Function} {void} _xabort (status)
  14781. Abort the current transaction. When no transaction is active this is a no-op.
  14782. The @var{status} is an 8-bit constant; its value is encoded in the return
  14783. value from @code{_xbegin}.
  14784. @end deftypefn
  14785. Here is an example showing handling for @code{_XABORT_RETRY}
  14786. and a fallback path for other failures:
  14787. @smallexample
  14788. #include <immintrin.h>
  14789. int n_tries, max_tries;
  14790. unsigned status = _XABORT_EXPLICIT;
  14791. ...
  14792. for (n_tries = 0; n_tries < max_tries; n_tries++)
  14793. @{
  14794. status = _xbegin ();
  14795. if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
  14796. break;
  14797. @}
  14798. if (status == _XBEGIN_STARTED)
  14799. @{
  14800. ... transaction code...
  14801. _xend ();
  14802. @}
  14803. else
  14804. @{
  14805. ... non-transactional fallback path...
  14806. @}
  14807. @end smallexample
  14808. @noindent
  14809. Note that, in most cases, the transactional and non-transactional code
  14810. must synchronize together to ensure consistency.
  14811. @node Target Format Checks
  14812. @section Format Checks Specific to Particular Target Machines
  14813. For some target machines, GCC supports additional options to the
  14814. format attribute
  14815. (@pxref{Function Attributes,,Declaring Attributes of Functions}).
  14816. @menu
  14817. * Solaris Format Checks::
  14818. * Darwin Format Checks::
  14819. @end menu
  14820. @node Solaris Format Checks
  14821. @subsection Solaris Format Checks
  14822. Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
  14823. check. @code{cmn_err} accepts a subset of the standard @code{printf}
  14824. conversions, and the two-argument @code{%b} conversion for displaying
  14825. bit-fields. See the Solaris man page for @code{cmn_err} for more information.
  14826. @node Darwin Format Checks
  14827. @subsection Darwin Format Checks
  14828. Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
  14829. attribute context. Declarations made with such attribution are parsed for correct syntax
  14830. and format argument types. However, parsing of the format string itself is currently undefined
  14831. and is not carried out by this version of the compiler.
  14832. Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
  14833. also be used as format arguments. Note that the relevant headers are only likely to be
  14834. available on Darwin (OSX) installations. On such installations, the XCode and system
  14835. documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
  14836. associated functions.
  14837. @node Pragmas
  14838. @section Pragmas Accepted by GCC
  14839. @cindex pragmas
  14840. @cindex @code{#pragma}
  14841. GCC supports several types of pragmas, primarily in order to compile
  14842. code originally written for other compilers. Note that in general
  14843. we do not recommend the use of pragmas; @xref{Function Attributes},
  14844. for further explanation.
  14845. @menu
  14846. * ARM Pragmas::
  14847. * M32C Pragmas::
  14848. * MeP Pragmas::
  14849. * RS/6000 and PowerPC Pragmas::
  14850. * Darwin Pragmas::
  14851. * Solaris Pragmas::
  14852. * Symbol-Renaming Pragmas::
  14853. * Structure-Packing Pragmas::
  14854. * Weak Pragmas::
  14855. * Diagnostic Pragmas::
  14856. * Visibility Pragmas::
  14857. * Push/Pop Macro Pragmas::
  14858. * Function Specific Option Pragmas::
  14859. * Loop-Specific Pragmas::
  14860. @end menu
  14861. @node ARM Pragmas
  14862. @subsection ARM Pragmas
  14863. The ARM target defines pragmas for controlling the default addition of
  14864. @code{long_call} and @code{short_call} attributes to functions.
  14865. @xref{Function Attributes}, for information about the effects of these
  14866. attributes.
  14867. @table @code
  14868. @item long_calls
  14869. @cindex pragma, long_calls
  14870. Set all subsequent functions to have the @code{long_call} attribute.
  14871. @item no_long_calls
  14872. @cindex pragma, no_long_calls
  14873. Set all subsequent functions to have the @code{short_call} attribute.
  14874. @item long_calls_off
  14875. @cindex pragma, long_calls_off
  14876. Do not affect the @code{long_call} or @code{short_call} attributes of
  14877. subsequent functions.
  14878. @end table
  14879. @node M32C Pragmas
  14880. @subsection M32C Pragmas
  14881. @table @code
  14882. @item GCC memregs @var{number}
  14883. @cindex pragma, memregs
  14884. Overrides the command-line option @code{-memregs=} for the current
  14885. file. Use with care! This pragma must be before any function in the
  14886. file, and mixing different memregs values in different objects may
  14887. make them incompatible. This pragma is useful when a
  14888. performance-critical function uses a memreg for temporary values,
  14889. as it may allow you to reduce the number of memregs used.
  14890. @item ADDRESS @var{name} @var{address}
  14891. @cindex pragma, address
  14892. For any declared symbols matching @var{name}, this does three things
  14893. to that symbol: it forces the symbol to be located at the given
  14894. address (a number), it forces the symbol to be volatile, and it
  14895. changes the symbol's scope to be static. This pragma exists for
  14896. compatibility with other compilers, but note that the common
  14897. @code{1234H} numeric syntax is not supported (use @code{0x1234}
  14898. instead). Example:
  14899. @smallexample
  14900. #pragma ADDRESS port3 0x103
  14901. char port3;
  14902. @end smallexample
  14903. @end table
  14904. @node MeP Pragmas
  14905. @subsection MeP Pragmas
  14906. @table @code
  14907. @item custom io_volatile (on|off)
  14908. @cindex pragma, custom io_volatile
  14909. Overrides the command-line option @code{-mio-volatile} for the current
  14910. file. Note that for compatibility with future GCC releases, this
  14911. option should only be used once before any @code{io} variables in each
  14912. file.
  14913. @item GCC coprocessor available @var{registers}
  14914. @cindex pragma, coprocessor available
  14915. Specifies which coprocessor registers are available to the register
  14916. allocator. @var{registers} may be a single register, register range
  14917. separated by ellipses, or comma-separated list of those. Example:
  14918. @smallexample
  14919. #pragma GCC coprocessor available $c0...$c10, $c28
  14920. @end smallexample
  14921. @item GCC coprocessor call_saved @var{registers}
  14922. @cindex pragma, coprocessor call_saved
  14923. Specifies which coprocessor registers are to be saved and restored by
  14924. any function using them. @var{registers} may be a single register,
  14925. register range separated by ellipses, or comma-separated list of
  14926. those. Example:
  14927. @smallexample
  14928. #pragma GCC coprocessor call_saved $c4...$c6, $c31
  14929. @end smallexample
  14930. @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
  14931. @cindex pragma, coprocessor subclass
  14932. Creates and defines a register class. These register classes can be
  14933. used by inline @code{asm} constructs. @var{registers} may be a single
  14934. register, register range separated by ellipses, or comma-separated
  14935. list of those. Example:
  14936. @smallexample
  14937. #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
  14938. asm ("cpfoo %0" : "=B" (x));
  14939. @end smallexample
  14940. @item GCC disinterrupt @var{name} , @var{name} @dots{}
  14941. @cindex pragma, disinterrupt
  14942. For the named functions, the compiler adds code to disable interrupts
  14943. for the duration of those functions. If any functions so named
  14944. are not encountered in the source, a warning is emitted that the pragma is
  14945. not used. Examples:
  14946. @smallexample
  14947. #pragma disinterrupt foo
  14948. #pragma disinterrupt bar, grill
  14949. int foo () @{ @dots{} @}
  14950. @end smallexample
  14951. @item GCC call @var{name} , @var{name} @dots{}
  14952. @cindex pragma, call
  14953. For the named functions, the compiler always uses a register-indirect
  14954. call model when calling the named functions. Examples:
  14955. @smallexample
  14956. extern int foo ();
  14957. #pragma call foo
  14958. @end smallexample
  14959. @end table
  14960. @node RS/6000 and PowerPC Pragmas
  14961. @subsection RS/6000 and PowerPC Pragmas
  14962. The RS/6000 and PowerPC targets define one pragma for controlling
  14963. whether or not the @code{longcall} attribute is added to function
  14964. declarations by default. This pragma overrides the @option{-mlongcall}
  14965. option, but not the @code{longcall} and @code{shortcall} attributes.
  14966. @xref{RS/6000 and PowerPC Options}, for more information about when long
  14967. calls are and are not necessary.
  14968. @table @code
  14969. @item longcall (1)
  14970. @cindex pragma, longcall
  14971. Apply the @code{longcall} attribute to all subsequent function
  14972. declarations.
  14973. @item longcall (0)
  14974. Do not apply the @code{longcall} attribute to subsequent function
  14975. declarations.
  14976. @end table
  14977. @c Describe h8300 pragmas here.
  14978. @c Describe sh pragmas here.
  14979. @c Describe v850 pragmas here.
  14980. @node Darwin Pragmas
  14981. @subsection Darwin Pragmas
  14982. The following pragmas are available for all architectures running the
  14983. Darwin operating system. These are useful for compatibility with other
  14984. Mac OS compilers.
  14985. @table @code
  14986. @item mark @var{tokens}@dots{}
  14987. @cindex pragma, mark
  14988. This pragma is accepted, but has no effect.
  14989. @item options align=@var{alignment}
  14990. @cindex pragma, options align
  14991. This pragma sets the alignment of fields in structures. The values of
  14992. @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
  14993. @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
  14994. properly; to restore the previous setting, use @code{reset} for the
  14995. @var{alignment}.
  14996. @item segment @var{tokens}@dots{}
  14997. @cindex pragma, segment
  14998. This pragma is accepted, but has no effect.
  14999. @item unused (@var{var} [, @var{var}]@dots{})
  15000. @cindex pragma, unused
  15001. This pragma declares variables to be possibly unused. GCC does not
  15002. produce warnings for the listed variables. The effect is similar to
  15003. that of the @code{unused} attribute, except that this pragma may appear
  15004. anywhere within the variables' scopes.
  15005. @end table
  15006. @node Solaris Pragmas
  15007. @subsection Solaris Pragmas
  15008. The Solaris target supports @code{#pragma redefine_extname}
  15009. (@pxref{Symbol-Renaming Pragmas}). It also supports additional
  15010. @code{#pragma} directives for compatibility with the system compiler.
  15011. @table @code
  15012. @item align @var{alignment} (@var{variable} [, @var{variable}]...)
  15013. @cindex pragma, align
  15014. Increase the minimum alignment of each @var{variable} to @var{alignment}.
  15015. This is the same as GCC's @code{aligned} attribute @pxref{Variable
  15016. Attributes}). Macro expansion occurs on the arguments to this pragma
  15017. when compiling C and Objective-C@. It does not currently occur when
  15018. compiling C++, but this is a bug which may be fixed in a future
  15019. release.
  15020. @item fini (@var{function} [, @var{function}]...)
  15021. @cindex pragma, fini
  15022. This pragma causes each listed @var{function} to be called after
  15023. main, or during shared module unloading, by adding a call to the
  15024. @code{.fini} section.
  15025. @item init (@var{function} [, @var{function}]...)
  15026. @cindex pragma, init
  15027. This pragma causes each listed @var{function} to be called during
  15028. initialization (before @code{main}) or during shared module loading, by
  15029. adding a call to the @code{.init} section.
  15030. @end table
  15031. @node Symbol-Renaming Pragmas
  15032. @subsection Symbol-Renaming Pragmas
  15033. GCC supports a @code{#pragma} directive that changes the name used in
  15034. assembly for a given declaration. While this pragma is supported on all
  15035. platforms, it is intended primarily to provide compatibility with the
  15036. Solaris system headers. This effect can also be achieved using the asm
  15037. labels extension (@pxref{Asm Labels}).
  15038. @table @code
  15039. @item redefine_extname @var{oldname} @var{newname}
  15040. @cindex pragma, redefine_extname
  15041. This pragma gives the C function @var{oldname} the assembly symbol
  15042. @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
  15043. is defined if this pragma is available (currently on all platforms).
  15044. @end table
  15045. This pragma and the asm labels extension interact in a complicated
  15046. manner. Here are some corner cases you may want to be aware of:
  15047. @enumerate
  15048. @item This pragma silently applies only to declarations with external
  15049. linkage. Asm labels do not have this restriction.
  15050. @item In C++, this pragma silently applies only to declarations with
  15051. ``C'' linkage. Again, asm labels do not have this restriction.
  15052. @item If either of the ways of changing the assembly name of a
  15053. declaration are applied to a declaration whose assembly name has
  15054. already been determined (either by a previous use of one of these
  15055. features, or because the compiler needed the assembly name in order to
  15056. generate code), and the new name is different, a warning issues and
  15057. the name does not change.
  15058. @item The @var{oldname} used by @code{#pragma redefine_extname} is
  15059. always the C-language name.
  15060. @end enumerate
  15061. @node Structure-Packing Pragmas
  15062. @subsection Structure-Packing Pragmas
  15063. For compatibility with Microsoft Windows compilers, GCC supports a
  15064. set of @code{#pragma} directives that change the maximum alignment of
  15065. members of structures (other than zero-width bit-fields), unions, and
  15066. classes subsequently defined. The @var{n} value below always is required
  15067. to be a small power of two and specifies the new alignment in bytes.
  15068. @enumerate
  15069. @item @code{#pragma pack(@var{n})} simply sets the new alignment.
  15070. @item @code{#pragma pack()} sets the alignment to the one that was in
  15071. effect when compilation started (see also command-line option
  15072. @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
  15073. @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
  15074. setting on an internal stack and then optionally sets the new alignment.
  15075. @item @code{#pragma pack(pop)} restores the alignment setting to the one
  15076. saved at the top of the internal stack (and removes that stack entry).
  15077. Note that @code{#pragma pack([@var{n}])} does not influence this internal
  15078. stack; thus it is possible to have @code{#pragma pack(push)} followed by
  15079. multiple @code{#pragma pack(@var{n})} instances and finalized by a single
  15080. @code{#pragma pack(pop)}.
  15081. @end enumerate
  15082. Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
  15083. @code{#pragma} which lays out a structure as the documented
  15084. @code{__attribute__ ((ms_struct))}.
  15085. @enumerate
  15086. @item @code{#pragma ms_struct on} turns on the layout for structures
  15087. declared.
  15088. @item @code{#pragma ms_struct off} turns off the layout for structures
  15089. declared.
  15090. @item @code{#pragma ms_struct reset} goes back to the default layout.
  15091. @end enumerate
  15092. @node Weak Pragmas
  15093. @subsection Weak Pragmas
  15094. For compatibility with SVR4, GCC supports a set of @code{#pragma}
  15095. directives for declaring symbols to be weak, and defining weak
  15096. aliases.
  15097. @table @code
  15098. @item #pragma weak @var{symbol}
  15099. @cindex pragma, weak
  15100. This pragma declares @var{symbol} to be weak, as if the declaration
  15101. had the attribute of the same name. The pragma may appear before
  15102. or after the declaration of @var{symbol}. It is not an error for
  15103. @var{symbol} to never be defined at all.
  15104. @item #pragma weak @var{symbol1} = @var{symbol2}
  15105. This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
  15106. It is an error if @var{symbol2} is not defined in the current
  15107. translation unit.
  15108. @end table
  15109. @node Diagnostic Pragmas
  15110. @subsection Diagnostic Pragmas
  15111. GCC allows the user to selectively enable or disable certain types of
  15112. diagnostics, and change the kind of the diagnostic. For example, a
  15113. project's policy might require that all sources compile with
  15114. @option{-Werror} but certain files might have exceptions allowing
  15115. specific types of warnings. Or, a project might selectively enable
  15116. diagnostics and treat them as errors depending on which preprocessor
  15117. macros are defined.
  15118. @table @code
  15119. @item #pragma GCC diagnostic @var{kind} @var{option}
  15120. @cindex pragma, diagnostic
  15121. Modifies the disposition of a diagnostic. Note that not all
  15122. diagnostics are modifiable; at the moment only warnings (normally
  15123. controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
  15124. Use @option{-fdiagnostics-show-option} to determine which diagnostics
  15125. are controllable and which option controls them.
  15126. @var{kind} is @samp{error} to treat this diagnostic as an error,
  15127. @samp{warning} to treat it like a warning (even if @option{-Werror} is
  15128. in effect), or @samp{ignored} if the diagnostic is to be ignored.
  15129. @var{option} is a double quoted string that matches the command-line
  15130. option.
  15131. @smallexample
  15132. #pragma GCC diagnostic warning "-Wformat"
  15133. #pragma GCC diagnostic error "-Wformat"
  15134. #pragma GCC diagnostic ignored "-Wformat"
  15135. @end smallexample
  15136. Note that these pragmas override any command-line options. GCC keeps
  15137. track of the location of each pragma, and issues diagnostics according
  15138. to the state as of that point in the source file. Thus, pragmas occurring
  15139. after a line do not affect diagnostics caused by that line.
  15140. @item #pragma GCC diagnostic push
  15141. @itemx #pragma GCC diagnostic pop
  15142. Causes GCC to remember the state of the diagnostics as of each
  15143. @code{push}, and restore to that point at each @code{pop}. If a
  15144. @code{pop} has no matching @code{push}, the command-line options are
  15145. restored.
  15146. @smallexample
  15147. #pragma GCC diagnostic error "-Wuninitialized"
  15148. foo(a); /* error is given for this one */
  15149. #pragma GCC diagnostic push
  15150. #pragma GCC diagnostic ignored "-Wuninitialized"
  15151. foo(b); /* no diagnostic for this one */
  15152. #pragma GCC diagnostic pop
  15153. foo(c); /* error is given for this one */
  15154. #pragma GCC diagnostic pop
  15155. foo(d); /* depends on command-line options */
  15156. @end smallexample
  15157. @end table
  15158. GCC also offers a simple mechanism for printing messages during
  15159. compilation.
  15160. @table @code
  15161. @item #pragma message @var{string}
  15162. @cindex pragma, diagnostic
  15163. Prints @var{string} as a compiler message on compilation. The message
  15164. is informational only, and is neither a compilation warning nor an error.
  15165. @smallexample
  15166. #pragma message "Compiling " __FILE__ "..."
  15167. @end smallexample
  15168. @var{string} may be parenthesized, and is printed with location
  15169. information. For example,
  15170. @smallexample
  15171. #define DO_PRAGMA(x) _Pragma (#x)
  15172. #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
  15173. TODO(Remember to fix this)
  15174. @end smallexample
  15175. @noindent
  15176. prints @samp{/tmp/file.c:4: note: #pragma message:
  15177. TODO - Remember to fix this}.
  15178. @end table
  15179. @node Visibility Pragmas
  15180. @subsection Visibility Pragmas
  15181. @table @code
  15182. @item #pragma GCC visibility push(@var{visibility})
  15183. @itemx #pragma GCC visibility pop
  15184. @cindex pragma, visibility
  15185. This pragma allows the user to set the visibility for multiple
  15186. declarations without having to give each a visibility attribute
  15187. (@pxref{Function Attributes}).
  15188. In C++, @samp{#pragma GCC visibility} affects only namespace-scope
  15189. declarations. Class members and template specializations are not
  15190. affected; if you want to override the visibility for a particular
  15191. member or instantiation, you must use an attribute.
  15192. @end table
  15193. @node Push/Pop Macro Pragmas
  15194. @subsection Push/Pop Macro Pragmas
  15195. For compatibility with Microsoft Windows compilers, GCC supports
  15196. @samp{#pragma push_macro(@var{"macro_name"})}
  15197. and @samp{#pragma pop_macro(@var{"macro_name"})}.
  15198. @table @code
  15199. @item #pragma push_macro(@var{"macro_name"})
  15200. @cindex pragma, push_macro
  15201. This pragma saves the value of the macro named as @var{macro_name} to
  15202. the top of the stack for this macro.
  15203. @item #pragma pop_macro(@var{"macro_name"})
  15204. @cindex pragma, pop_macro
  15205. This pragma sets the value of the macro named as @var{macro_name} to
  15206. the value on top of the stack for this macro. If the stack for
  15207. @var{macro_name} is empty, the value of the macro remains unchanged.
  15208. @end table
  15209. For example:
  15210. @smallexample
  15211. #define X 1
  15212. #pragma push_macro("X")
  15213. #undef X
  15214. #define X -1
  15215. #pragma pop_macro("X")
  15216. int x [X];
  15217. @end smallexample
  15218. @noindent
  15219. In this example, the definition of X as 1 is saved by @code{#pragma
  15220. push_macro} and restored by @code{#pragma pop_macro}.
  15221. @node Function Specific Option Pragmas
  15222. @subsection Function Specific Option Pragmas
  15223. @table @code
  15224. @item #pragma GCC target (@var{"string"}...)
  15225. @cindex pragma GCC target
  15226. This pragma allows you to set target specific options for functions
  15227. defined later in the source file. One or more strings can be
  15228. specified. Each function that is defined after this point is as
  15229. if @code{attribute((target("STRING")))} was specified for that
  15230. function. The parenthesis around the options is optional.
  15231. @xref{Function Attributes}, for more information about the
  15232. @code{target} attribute and the attribute syntax.
  15233. The @code{#pragma GCC target} pragma is presently implemented for
  15234. x86, PowerPC, and Nios II targets only.
  15235. @end table
  15236. @table @code
  15237. @item #pragma GCC optimize (@var{"string"}...)
  15238. @cindex pragma GCC optimize
  15239. This pragma allows you to set global optimization options for functions
  15240. defined later in the source file. One or more strings can be
  15241. specified. Each function that is defined after this point is as
  15242. if @code{attribute((optimize("STRING")))} was specified for that
  15243. function. The parenthesis around the options is optional.
  15244. @xref{Function Attributes}, for more information about the
  15245. @code{optimize} attribute and the attribute syntax.
  15246. @end table
  15247. @table @code
  15248. @item #pragma GCC push_options
  15249. @itemx #pragma GCC pop_options
  15250. @cindex pragma GCC push_options
  15251. @cindex pragma GCC pop_options
  15252. These pragmas maintain a stack of the current target and optimization
  15253. options. It is intended for include files where you temporarily want
  15254. to switch to using a different @samp{#pragma GCC target} or
  15255. @samp{#pragma GCC optimize} and then to pop back to the previous
  15256. options.
  15257. @end table
  15258. @table @code
  15259. @item #pragma GCC reset_options
  15260. @cindex pragma GCC reset_options
  15261. This pragma clears the current @code{#pragma GCC target} and
  15262. @code{#pragma GCC optimize} to use the default switches as specified
  15263. on the command line.
  15264. @end table
  15265. @node Loop-Specific Pragmas
  15266. @subsection Loop-Specific Pragmas
  15267. @table @code
  15268. @item #pragma GCC ivdep
  15269. @cindex pragma GCC ivdep
  15270. @end table
  15271. With this pragma, the programmer asserts that there are no loop-carried
  15272. dependencies which would prevent consecutive iterations of
  15273. the following loop from executing concurrently with SIMD
  15274. (single instruction multiple data) instructions.
  15275. For example, the compiler can only unconditionally vectorize the following
  15276. loop with the pragma:
  15277. @smallexample
  15278. void foo (int n, int *a, int *b, int *c)
  15279. @{
  15280. int i, j;
  15281. #pragma GCC ivdep
  15282. for (i = 0; i < n; ++i)
  15283. a[i] = b[i] + c[i];
  15284. @}
  15285. @end smallexample
  15286. @noindent
  15287. In this example, using the @code{restrict} qualifier had the same
  15288. effect. In the following example, that would not be possible. Assume
  15289. @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
  15290. that it can unconditionally vectorize the following loop:
  15291. @smallexample
  15292. void ignore_vec_dep (int *a, int k, int c, int m)
  15293. @{
  15294. #pragma GCC ivdep
  15295. for (int i = 0; i < m; i++)
  15296. a[i] = a[i + k] * c;
  15297. @}
  15298. @end smallexample
  15299. @node Unnamed Fields
  15300. @section Unnamed Structure and Union Fields
  15301. @cindex @code{struct}
  15302. @cindex @code{union}
  15303. As permitted by ISO C11 and for compatibility with other compilers,
  15304. GCC allows you to define
  15305. a structure or union that contains, as fields, structures and unions
  15306. without names. For example:
  15307. @smallexample
  15308. struct @{
  15309. int a;
  15310. union @{
  15311. int b;
  15312. float c;
  15313. @};
  15314. int d;
  15315. @} foo;
  15316. @end smallexample
  15317. @noindent
  15318. In this example, you are able to access members of the unnamed
  15319. union with code like @samp{foo.b}. Note that only unnamed structs and
  15320. unions are allowed, you may not have, for example, an unnamed
  15321. @code{int}.
  15322. You must never create such structures that cause ambiguous field definitions.
  15323. For example, in this structure:
  15324. @smallexample
  15325. struct @{
  15326. int a;
  15327. struct @{
  15328. int a;
  15329. @};
  15330. @} foo;
  15331. @end smallexample
  15332. @noindent
  15333. it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
  15334. The compiler gives errors for such constructs.
  15335. @opindex fms-extensions
  15336. Unless @option{-fms-extensions} is used, the unnamed field must be a
  15337. structure or union definition without a tag (for example, @samp{struct
  15338. @{ int a; @};}). If @option{-fms-extensions} is used, the field may
  15339. also be a definition with a tag such as @samp{struct foo @{ int a;
  15340. @};}, a reference to a previously defined structure or union such as
  15341. @samp{struct foo;}, or a reference to a @code{typedef} name for a
  15342. previously defined structure or union type.
  15343. @opindex fplan9-extensions
  15344. The option @option{-fplan9-extensions} enables
  15345. @option{-fms-extensions} as well as two other extensions. First, a
  15346. pointer to a structure is automatically converted to a pointer to an
  15347. anonymous field for assignments and function calls. For example:
  15348. @smallexample
  15349. struct s1 @{ int a; @};
  15350. struct s2 @{ struct s1; @};
  15351. extern void f1 (struct s1 *);
  15352. void f2 (struct s2 *p) @{ f1 (p); @}
  15353. @end smallexample
  15354. @noindent
  15355. In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
  15356. converted into a pointer to the anonymous field.
  15357. Second, when the type of an anonymous field is a @code{typedef} for a
  15358. @code{struct} or @code{union}, code may refer to the field using the
  15359. name of the @code{typedef}.
  15360. @smallexample
  15361. typedef struct @{ int a; @} s1;
  15362. struct s2 @{ s1; @};
  15363. s1 f1 (struct s2 *p) @{ return p->s1; @}
  15364. @end smallexample
  15365. These usages are only permitted when they are not ambiguous.
  15366. @node Thread-Local
  15367. @section Thread-Local Storage
  15368. @cindex Thread-Local Storage
  15369. @cindex @acronym{TLS}
  15370. @cindex @code{__thread}
  15371. Thread-local storage (@acronym{TLS}) is a mechanism by which variables
  15372. are allocated such that there is one instance of the variable per extant
  15373. thread. The runtime model GCC uses to implement this originates
  15374. in the IA-64 processor-specific ABI, but has since been migrated
  15375. to other processors as well. It requires significant support from
  15376. the linker (@command{ld}), dynamic linker (@command{ld.so}), and
  15377. system libraries (@file{libc.so} and @file{libpthread.so}), so it
  15378. is not available everywhere.
  15379. At the user level, the extension is visible with a new storage
  15380. class keyword: @code{__thread}. For example:
  15381. @smallexample
  15382. __thread int i;
  15383. extern __thread struct state s;
  15384. static __thread char *p;
  15385. @end smallexample
  15386. The @code{__thread} specifier may be used alone, with the @code{extern}
  15387. or @code{static} specifiers, but with no other storage class specifier.
  15388. When used with @code{extern} or @code{static}, @code{__thread} must appear
  15389. immediately after the other storage class specifier.
  15390. The @code{__thread} specifier may be applied to any global, file-scoped
  15391. static, function-scoped static, or static data member of a class. It may
  15392. not be applied to block-scoped automatic or non-static data member.
  15393. When the address-of operator is applied to a thread-local variable, it is
  15394. evaluated at run time and returns the address of the current thread's
  15395. instance of that variable. An address so obtained may be used by any
  15396. thread. When a thread terminates, any pointers to thread-local variables
  15397. in that thread become invalid.
  15398. No static initialization may refer to the address of a thread-local variable.
  15399. In C++, if an initializer is present for a thread-local variable, it must
  15400. be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
  15401. standard.
  15402. See @uref{http://www.akkadia.org/drepper/tls.pdf,
  15403. ELF Handling For Thread-Local Storage} for a detailed explanation of
  15404. the four thread-local storage addressing models, and how the runtime
  15405. is expected to function.
  15406. @menu
  15407. * C99 Thread-Local Edits::
  15408. * C++98 Thread-Local Edits::
  15409. @end menu
  15410. @node C99 Thread-Local Edits
  15411. @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
  15412. The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
  15413. that document the exact semantics of the language extension.
  15414. @itemize @bullet
  15415. @item
  15416. @cite{5.1.2 Execution environments}
  15417. Add new text after paragraph 1
  15418. @quotation
  15419. Within either execution environment, a @dfn{thread} is a flow of
  15420. control within a program. It is implementation defined whether
  15421. or not there may be more than one thread associated with a program.
  15422. It is implementation defined how threads beyond the first are
  15423. created, the name and type of the function called at thread
  15424. startup, and how threads may be terminated. However, objects
  15425. with thread storage duration shall be initialized before thread
  15426. startup.
  15427. @end quotation
  15428. @item
  15429. @cite{6.2.4 Storage durations of objects}
  15430. Add new text before paragraph 3
  15431. @quotation
  15432. An object whose identifier is declared with the storage-class
  15433. specifier @w{@code{__thread}} has @dfn{thread storage duration}.
  15434. Its lifetime is the entire execution of the thread, and its
  15435. stored value is initialized only once, prior to thread startup.
  15436. @end quotation
  15437. @item
  15438. @cite{6.4.1 Keywords}
  15439. Add @code{__thread}.
  15440. @item
  15441. @cite{6.7.1 Storage-class specifiers}
  15442. Add @code{__thread} to the list of storage class specifiers in
  15443. paragraph 1.
  15444. Change paragraph 2 to
  15445. @quotation
  15446. With the exception of @code{__thread}, at most one storage-class
  15447. specifier may be given [@dots{}]. The @code{__thread} specifier may
  15448. be used alone, or immediately following @code{extern} or
  15449. @code{static}.
  15450. @end quotation
  15451. Add new text after paragraph 6
  15452. @quotation
  15453. The declaration of an identifier for a variable that has
  15454. block scope that specifies @code{__thread} shall also
  15455. specify either @code{extern} or @code{static}.
  15456. The @code{__thread} specifier shall be used only with
  15457. variables.
  15458. @end quotation
  15459. @end itemize
  15460. @node C++98 Thread-Local Edits
  15461. @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
  15462. The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
  15463. that document the exact semantics of the language extension.
  15464. @itemize @bullet
  15465. @item
  15466. @b{[intro.execution]}
  15467. New text after paragraph 4
  15468. @quotation
  15469. A @dfn{thread} is a flow of control within the abstract machine.
  15470. It is implementation defined whether or not there may be more than
  15471. one thread.
  15472. @end quotation
  15473. New text after paragraph 7
  15474. @quotation
  15475. It is unspecified whether additional action must be taken to
  15476. ensure when and whether side effects are visible to other threads.
  15477. @end quotation
  15478. @item
  15479. @b{[lex.key]}
  15480. Add @code{__thread}.
  15481. @item
  15482. @b{[basic.start.main]}
  15483. Add after paragraph 5
  15484. @quotation
  15485. The thread that begins execution at the @code{main} function is called
  15486. the @dfn{main thread}. It is implementation defined how functions
  15487. beginning threads other than the main thread are designated or typed.
  15488. A function so designated, as well as the @code{main} function, is called
  15489. a @dfn{thread startup function}. It is implementation defined what
  15490. happens if a thread startup function returns. It is implementation
  15491. defined what happens to other threads when any thread calls @code{exit}.
  15492. @end quotation
  15493. @item
  15494. @b{[basic.start.init]}
  15495. Add after paragraph 4
  15496. @quotation
  15497. The storage for an object of thread storage duration shall be
  15498. statically initialized before the first statement of the thread startup
  15499. function. An object of thread storage duration shall not require
  15500. dynamic initialization.
  15501. @end quotation
  15502. @item
  15503. @b{[basic.start.term]}
  15504. Add after paragraph 3
  15505. @quotation
  15506. The type of an object with thread storage duration shall not have a
  15507. non-trivial destructor, nor shall it be an array type whose elements
  15508. (directly or indirectly) have non-trivial destructors.
  15509. @end quotation
  15510. @item
  15511. @b{[basic.stc]}
  15512. Add ``thread storage duration'' to the list in paragraph 1.
  15513. Change paragraph 2
  15514. @quotation
  15515. Thread, static, and automatic storage durations are associated with
  15516. objects introduced by declarations [@dots{}].
  15517. @end quotation
  15518. Add @code{__thread} to the list of specifiers in paragraph 3.
  15519. @item
  15520. @b{[basic.stc.thread]}
  15521. New section before @b{[basic.stc.static]}
  15522. @quotation
  15523. The keyword @code{__thread} applied to a non-local object gives the
  15524. object thread storage duration.
  15525. A local variable or class data member declared both @code{static}
  15526. and @code{__thread} gives the variable or member thread storage
  15527. duration.
  15528. @end quotation
  15529. @item
  15530. @b{[basic.stc.static]}
  15531. Change paragraph 1
  15532. @quotation
  15533. All objects that have neither thread storage duration, dynamic
  15534. storage duration nor are local [@dots{}].
  15535. @end quotation
  15536. @item
  15537. @b{[dcl.stc]}
  15538. Add @code{__thread} to the list in paragraph 1.
  15539. Change paragraph 1
  15540. @quotation
  15541. With the exception of @code{__thread}, at most one
  15542. @var{storage-class-specifier} shall appear in a given
  15543. @var{decl-specifier-seq}. The @code{__thread} specifier may
  15544. be used alone, or immediately following the @code{extern} or
  15545. @code{static} specifiers. [@dots{}]
  15546. @end quotation
  15547. Add after paragraph 5
  15548. @quotation
  15549. The @code{__thread} specifier can be applied only to the names of objects
  15550. and to anonymous unions.
  15551. @end quotation
  15552. @item
  15553. @b{[class.mem]}
  15554. Add after paragraph 6
  15555. @quotation
  15556. Non-@code{static} members shall not be @code{__thread}.
  15557. @end quotation
  15558. @end itemize
  15559. @node Binary constants
  15560. @section Binary Constants using the @samp{0b} Prefix
  15561. @cindex Binary constants using the @samp{0b} prefix
  15562. Integer constants can be written as binary constants, consisting of a
  15563. sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
  15564. @samp{0B}. This is particularly useful in environments that operate a
  15565. lot on the bit level (like microcontrollers).
  15566. The following statements are identical:
  15567. @smallexample
  15568. i = 42;
  15569. i = 0x2a;
  15570. i = 052;
  15571. i = 0b101010;
  15572. @end smallexample
  15573. The type of these constants follows the same rules as for octal or
  15574. hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
  15575. can be applied.
  15576. @node C++ Extensions
  15577. @chapter Extensions to the C++ Language
  15578. @cindex extensions, C++ language
  15579. @cindex C++ language extensions
  15580. The GNU compiler provides these extensions to the C++ language (and you
  15581. can also use most of the C language extensions in your C++ programs). If you
  15582. want to write code that checks whether these features are available, you can
  15583. test for the GNU compiler the same way as for C programs: check for a
  15584. predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
  15585. test specifically for GNU C++ (@pxref{Common Predefined Macros,,
  15586. Predefined Macros,cpp,The GNU C Preprocessor}).
  15587. @menu
  15588. * C++ Volatiles:: What constitutes an access to a volatile object.
  15589. * Restricted Pointers:: C99 restricted pointers and references.
  15590. * Vague Linkage:: Where G++ puts inlines, vtables and such.
  15591. * C++ Interface:: You can use a single C++ header file for both
  15592. declarations and definitions.
  15593. * Template Instantiation:: Methods for ensuring that exactly one copy of
  15594. each needed template instantiation is emitted.
  15595. * Bound member functions:: You can extract a function pointer to the
  15596. method denoted by a @samp{->*} or @samp{.*} expression.
  15597. * C++ Attributes:: Variable, function, and type attributes for C++ only.
  15598. * Function Multiversioning:: Declaring multiple function versions.
  15599. * Namespace Association:: Strong using-directives for namespace association.
  15600. * Type Traits:: Compiler support for type traits
  15601. * Java Exceptions:: Tweaking exception handling to work with Java.
  15602. * Deprecated Features:: Things will disappear from G++.
  15603. * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
  15604. @end menu
  15605. @node C++ Volatiles
  15606. @section When is a Volatile C++ Object Accessed?
  15607. @cindex accessing volatiles
  15608. @cindex volatile read
  15609. @cindex volatile write
  15610. @cindex volatile access
  15611. The C++ standard differs from the C standard in its treatment of
  15612. volatile objects. It fails to specify what constitutes a volatile
  15613. access, except to say that C++ should behave in a similar manner to C
  15614. with respect to volatiles, where possible. However, the different
  15615. lvalueness of expressions between C and C++ complicate the behavior.
  15616. G++ behaves the same as GCC for volatile access, @xref{C
  15617. Extensions,,Volatiles}, for a description of GCC's behavior.
  15618. The C and C++ language specifications differ when an object is
  15619. accessed in a void context:
  15620. @smallexample
  15621. volatile int *src = @var{somevalue};
  15622. *src;
  15623. @end smallexample
  15624. The C++ standard specifies that such expressions do not undergo lvalue
  15625. to rvalue conversion, and that the type of the dereferenced object may
  15626. be incomplete. The C++ standard does not specify explicitly that it
  15627. is lvalue to rvalue conversion that is responsible for causing an
  15628. access. There is reason to believe that it is, because otherwise
  15629. certain simple expressions become undefined. However, because it
  15630. would surprise most programmers, G++ treats dereferencing a pointer to
  15631. volatile object of complete type as GCC would do for an equivalent
  15632. type in C@. When the object has incomplete type, G++ issues a
  15633. warning; if you wish to force an error, you must force a conversion to
  15634. rvalue with, for instance, a static cast.
  15635. When using a reference to volatile, G++ does not treat equivalent
  15636. expressions as accesses to volatiles, but instead issues a warning that
  15637. no volatile is accessed. The rationale for this is that otherwise it
  15638. becomes difficult to determine where volatile access occur, and not
  15639. possible to ignore the return value from functions returning volatile
  15640. references. Again, if you wish to force a read, cast the reference to
  15641. an rvalue.
  15642. G++ implements the same behavior as GCC does when assigning to a
  15643. volatile object---there is no reread of the assigned-to object, the
  15644. assigned rvalue is reused. Note that in C++ assignment expressions
  15645. are lvalues, and if used as an lvalue, the volatile object is
  15646. referred to. For instance, @var{vref} refers to @var{vobj}, as
  15647. expected, in the following example:
  15648. @smallexample
  15649. volatile int vobj;
  15650. volatile int &vref = vobj = @var{something};
  15651. @end smallexample
  15652. @node Restricted Pointers
  15653. @section Restricting Pointer Aliasing
  15654. @cindex restricted pointers
  15655. @cindex restricted references
  15656. @cindex restricted this pointer
  15657. As with the C front end, G++ understands the C99 feature of restricted pointers,
  15658. specified with the @code{__restrict__}, or @code{__restrict} type
  15659. qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
  15660. language flag, @code{restrict} is not a keyword in C++.
  15661. In addition to allowing restricted pointers, you can specify restricted
  15662. references, which indicate that the reference is not aliased in the local
  15663. context.
  15664. @smallexample
  15665. void fn (int *__restrict__ rptr, int &__restrict__ rref)
  15666. @{
  15667. /* @r{@dots{}} */
  15668. @}
  15669. @end smallexample
  15670. @noindent
  15671. In the body of @code{fn}, @var{rptr} points to an unaliased integer and
  15672. @var{rref} refers to a (different) unaliased integer.
  15673. You may also specify whether a member function's @var{this} pointer is
  15674. unaliased by using @code{__restrict__} as a member function qualifier.
  15675. @smallexample
  15676. void T::fn () __restrict__
  15677. @{
  15678. /* @r{@dots{}} */
  15679. @}
  15680. @end smallexample
  15681. @noindent
  15682. Within the body of @code{T::fn}, @var{this} has the effective
  15683. definition @code{T *__restrict__ const this}. Notice that the
  15684. interpretation of a @code{__restrict__} member function qualifier is
  15685. different to that of @code{const} or @code{volatile} qualifier, in that it
  15686. is applied to the pointer rather than the object. This is consistent with
  15687. other compilers that implement restricted pointers.
  15688. As with all outermost parameter qualifiers, @code{__restrict__} is
  15689. ignored in function definition matching. This means you only need to
  15690. specify @code{__restrict__} in a function definition, rather than
  15691. in a function prototype as well.
  15692. @node Vague Linkage
  15693. @section Vague Linkage
  15694. @cindex vague linkage
  15695. There are several constructs in C++ that require space in the object
  15696. file but are not clearly tied to a single translation unit. We say that
  15697. these constructs have ``vague linkage''. Typically such constructs are
  15698. emitted wherever they are needed, though sometimes we can be more
  15699. clever.
  15700. @table @asis
  15701. @item Inline Functions
  15702. Inline functions are typically defined in a header file which can be
  15703. included in many different compilations. Hopefully they can usually be
  15704. inlined, but sometimes an out-of-line copy is necessary, if the address
  15705. of the function is taken or if inlining fails. In general, we emit an
  15706. out-of-line copy in all translation units where one is needed. As an
  15707. exception, we only emit inline virtual functions with the vtable, since
  15708. it always requires a copy.
  15709. Local static variables and string constants used in an inline function
  15710. are also considered to have vague linkage, since they must be shared
  15711. between all inlined and out-of-line instances of the function.
  15712. @item VTables
  15713. @cindex vtable
  15714. C++ virtual functions are implemented in most compilers using a lookup
  15715. table, known as a vtable. The vtable contains pointers to the virtual
  15716. functions provided by a class, and each object of the class contains a
  15717. pointer to its vtable (or vtables, in some multiple-inheritance
  15718. situations). If the class declares any non-inline, non-pure virtual
  15719. functions, the first one is chosen as the ``key method'' for the class,
  15720. and the vtable is only emitted in the translation unit where the key
  15721. method is defined.
  15722. @emph{Note:} If the chosen key method is later defined as inline, the
  15723. vtable is still emitted in every translation unit that defines it.
  15724. Make sure that any inline virtuals are declared inline in the class
  15725. body, even if they are not defined there.
  15726. @item @code{type_info} objects
  15727. @cindex @code{type_info}
  15728. @cindex RTTI
  15729. C++ requires information about types to be written out in order to
  15730. implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
  15731. For polymorphic classes (classes with virtual functions), the @samp{type_info}
  15732. object is written out along with the vtable so that @samp{dynamic_cast}
  15733. can determine the dynamic type of a class object at run time. For all
  15734. other types, we write out the @samp{type_info} object when it is used: when
  15735. applying @samp{typeid} to an expression, throwing an object, or
  15736. referring to a type in a catch clause or exception specification.
  15737. @item Template Instantiations
  15738. Most everything in this section also applies to template instantiations,
  15739. but there are other options as well.
  15740. @xref{Template Instantiation,,Where's the Template?}.
  15741. @end table
  15742. When used with GNU ld version 2.8 or later on an ELF system such as
  15743. GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
  15744. these constructs will be discarded at link time. This is known as
  15745. COMDAT support.
  15746. On targets that don't support COMDAT, but do support weak symbols, GCC
  15747. uses them. This way one copy overrides all the others, but
  15748. the unused copies still take up space in the executable.
  15749. For targets that do not support either COMDAT or weak symbols,
  15750. most entities with vague linkage are emitted as local symbols to
  15751. avoid duplicate definition errors from the linker. This does not happen
  15752. for local statics in inlines, however, as having multiple copies
  15753. almost certainly breaks things.
  15754. @xref{C++ Interface,,Declarations and Definitions in One Header}, for
  15755. another way to control placement of these constructs.
  15756. @node C++ Interface
  15757. @section C++ Interface and Implementation Pragmas
  15758. @cindex interface and implementation headers, C++
  15759. @cindex C++ interface and implementation headers
  15760. @cindex pragmas, interface and implementation
  15761. @code{#pragma interface} and @code{#pragma implementation} provide the
  15762. user with a way of explicitly directing the compiler to emit entities
  15763. with vague linkage (and debugging information) in a particular
  15764. translation unit.
  15765. @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
  15766. by COMDAT support and the ``key method'' heuristic
  15767. mentioned in @ref{Vague Linkage}. Using them can actually cause your
  15768. program to grow due to unnecessary out-of-line copies of inline
  15769. functions.
  15770. @table @code
  15771. @item #pragma interface
  15772. @itemx #pragma interface "@var{subdir}/@var{objects}.h"
  15773. @kindex #pragma interface
  15774. Use this directive in @emph{header files} that define object classes, to save
  15775. space in most of the object files that use those classes. Normally,
  15776. local copies of certain information (backup copies of inline member
  15777. functions, debugging information, and the internal tables that implement
  15778. virtual functions) must be kept in each object file that includes class
  15779. definitions. You can use this pragma to avoid such duplication. When a
  15780. header file containing @samp{#pragma interface} is included in a
  15781. compilation, this auxiliary information is not generated (unless
  15782. the main input source file itself uses @samp{#pragma implementation}).
  15783. Instead, the object files contain references to be resolved at link
  15784. time.
  15785. The second form of this directive is useful for the case where you have
  15786. multiple headers with the same name in different directories. If you
  15787. use this form, you must specify the same string to @samp{#pragma
  15788. implementation}.
  15789. @item #pragma implementation
  15790. @itemx #pragma implementation "@var{objects}.h"
  15791. @kindex #pragma implementation
  15792. Use this pragma in a @emph{main input file}, when you want full output from
  15793. included header files to be generated (and made globally visible). The
  15794. included header file, in turn, should use @samp{#pragma interface}.
  15795. Backup copies of inline member functions, debugging information, and the
  15796. internal tables used to implement virtual functions are all generated in
  15797. implementation files.
  15798. @cindex implied @code{#pragma implementation}
  15799. @cindex @code{#pragma implementation}, implied
  15800. @cindex naming convention, implementation headers
  15801. If you use @samp{#pragma implementation} with no argument, it applies to
  15802. an include file with the same basename@footnote{A file's @dfn{basename}
  15803. is the name stripped of all leading path information and of trailing
  15804. suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
  15805. file. For example, in @file{allclass.cc}, giving just
  15806. @samp{#pragma implementation}
  15807. by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
  15808. Use the string argument if you want a single implementation file to
  15809. include code from multiple header files. (You must also use
  15810. @samp{#include} to include the header file; @samp{#pragma
  15811. implementation} only specifies how to use the file---it doesn't actually
  15812. include it.)
  15813. There is no way to split up the contents of a single header file into
  15814. multiple implementation files.
  15815. @end table
  15816. @cindex inlining and C++ pragmas
  15817. @cindex C++ pragmas, effect on inlining
  15818. @cindex pragmas in C++, effect on inlining
  15819. @samp{#pragma implementation} and @samp{#pragma interface} also have an
  15820. effect on function inlining.
  15821. If you define a class in a header file marked with @samp{#pragma
  15822. interface}, the effect on an inline function defined in that class is
  15823. similar to an explicit @code{extern} declaration---the compiler emits
  15824. no code at all to define an independent version of the function. Its
  15825. definition is used only for inlining with its callers.
  15826. @opindex fno-implement-inlines
  15827. Conversely, when you include the same header file in a main source file
  15828. that declares it as @samp{#pragma implementation}, the compiler emits
  15829. code for the function itself; this defines a version of the function
  15830. that can be found via pointers (or by callers compiled without
  15831. inlining). If all calls to the function can be inlined, you can avoid
  15832. emitting the function by compiling with @option{-fno-implement-inlines}.
  15833. If any calls are not inlined, you will get linker errors.
  15834. @node Template Instantiation
  15835. @section Where's the Template?
  15836. @cindex template instantiation
  15837. C++ templates are the first language feature to require more
  15838. intelligence from the environment than one usually finds on a UNIX
  15839. system. Somehow the compiler and linker have to make sure that each
  15840. template instance occurs exactly once in the executable if it is needed,
  15841. and not at all otherwise. There are two basic approaches to this
  15842. problem, which are referred to as the Borland model and the Cfront model.
  15843. @table @asis
  15844. @item Borland model
  15845. Borland C++ solved the template instantiation problem by adding the code
  15846. equivalent of common blocks to their linker; the compiler emits template
  15847. instances in each translation unit that uses them, and the linker
  15848. collapses them together. The advantage of this model is that the linker
  15849. only has to consider the object files themselves; there is no external
  15850. complexity to worry about. This disadvantage is that compilation time
  15851. is increased because the template code is being compiled repeatedly.
  15852. Code written for this model tends to include definitions of all
  15853. templates in the header file, since they must be seen to be
  15854. instantiated.
  15855. @item Cfront model
  15856. The AT&T C++ translator, Cfront, solved the template instantiation
  15857. problem by creating the notion of a template repository, an
  15858. automatically maintained place where template instances are stored. A
  15859. more modern version of the repository works as follows: As individual
  15860. object files are built, the compiler places any template definitions and
  15861. instantiations encountered in the repository. At link time, the link
  15862. wrapper adds in the objects in the repository and compiles any needed
  15863. instances that were not previously emitted. The advantages of this
  15864. model are more optimal compilation speed and the ability to use the
  15865. system linker; to implement the Borland model a compiler vendor also
  15866. needs to replace the linker. The disadvantages are vastly increased
  15867. complexity, and thus potential for error; for some code this can be
  15868. just as transparent, but in practice it can been very difficult to build
  15869. multiple programs in one directory and one program in multiple
  15870. directories. Code written for this model tends to separate definitions
  15871. of non-inline member templates into a separate file, which should be
  15872. compiled separately.
  15873. @end table
  15874. When used with GNU ld version 2.8 or later on an ELF system such as
  15875. GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
  15876. Borland model. On other systems, G++ implements neither automatic
  15877. model.
  15878. You have the following options for dealing with template instantiations:
  15879. @enumerate
  15880. @item
  15881. @opindex frepo
  15882. Compile your template-using code with @option{-frepo}. The compiler
  15883. generates files with the extension @samp{.rpo} listing all of the
  15884. template instantiations used in the corresponding object files that
  15885. could be instantiated there; the link wrapper, @samp{collect2},
  15886. then updates the @samp{.rpo} files to tell the compiler where to place
  15887. those instantiations and rebuild any affected object files. The
  15888. link-time overhead is negligible after the first pass, as the compiler
  15889. continues to place the instantiations in the same files.
  15890. This is your best option for application code written for the Borland
  15891. model, as it just works. Code written for the Cfront model
  15892. needs to be modified so that the template definitions are available at
  15893. one or more points of instantiation; usually this is as simple as adding
  15894. @code{#include <tmethods.cc>} to the end of each template header.
  15895. For library code, if you want the library to provide all of the template
  15896. instantiations it needs, just try to link all of its object files
  15897. together; the link will fail, but cause the instantiations to be
  15898. generated as a side effect. Be warned, however, that this may cause
  15899. conflicts if multiple libraries try to provide the same instantiations.
  15900. For greater control, use explicit instantiation as described in the next
  15901. option.
  15902. @item
  15903. @opindex fno-implicit-templates
  15904. Compile your code with @option{-fno-implicit-templates} to disable the
  15905. implicit generation of template instances, and explicitly instantiate
  15906. all the ones you use. This approach requires more knowledge of exactly
  15907. which instances you need than do the others, but it's less
  15908. mysterious and allows greater control. You can scatter the explicit
  15909. instantiations throughout your program, perhaps putting them in the
  15910. translation units where the instances are used or the translation units
  15911. that define the templates themselves; you can put all of the explicit
  15912. instantiations you need into one big file; or you can create small files
  15913. like
  15914. @smallexample
  15915. #include "Foo.h"
  15916. #include "Foo.cc"
  15917. template class Foo<int>;
  15918. template ostream& operator <<
  15919. (ostream&, const Foo<int>&);
  15920. @end smallexample
  15921. @noindent
  15922. for each of the instances you need, and create a template instantiation
  15923. library from those.
  15924. If you are using Cfront-model code, you can probably get away with not
  15925. using @option{-fno-implicit-templates} when compiling files that don't
  15926. @samp{#include} the member template definitions.
  15927. If you use one big file to do the instantiations, you may want to
  15928. compile it without @option{-fno-implicit-templates} so you get all of the
  15929. instances required by your explicit instantiations (but not by any
  15930. other files) without having to specify them as well.
  15931. The ISO C++ 2011 standard allows forward declaration of explicit
  15932. instantiations (with @code{extern}). G++ supports explicit instantiation
  15933. declarations in C++98 mode and has extended the template instantiation
  15934. syntax to support instantiation of the compiler support data for a
  15935. template class (i.e.@: the vtable) without instantiating any of its
  15936. members (with @code{inline}), and instantiation of only the static data
  15937. members of a template class, without the support data or member
  15938. functions (with @code{static}):
  15939. @smallexample
  15940. extern template int max (int, int);
  15941. inline template class Foo<int>;
  15942. static template class Foo<int>;
  15943. @end smallexample
  15944. @item
  15945. Do nothing. Pretend G++ does implement automatic instantiation
  15946. management. Code written for the Borland model works fine, but
  15947. each translation unit contains instances of each of the templates it
  15948. uses. In a large program, this can lead to an unacceptable amount of code
  15949. duplication.
  15950. @end enumerate
  15951. @node Bound member functions
  15952. @section Extracting the Function Pointer from a Bound Pointer to Member Function
  15953. @cindex pmf
  15954. @cindex pointer to member function
  15955. @cindex bound pointer to member function
  15956. In C++, pointer to member functions (PMFs) are implemented using a wide
  15957. pointer of sorts to handle all the possible call mechanisms; the PMF
  15958. needs to store information about how to adjust the @samp{this} pointer,
  15959. and if the function pointed to is virtual, where to find the vtable, and
  15960. where in the vtable to look for the member function. If you are using
  15961. PMFs in an inner loop, you should really reconsider that decision. If
  15962. that is not an option, you can extract the pointer to the function that
  15963. would be called for a given object/PMF pair and call it directly inside
  15964. the inner loop, to save a bit of time.
  15965. Note that you still pay the penalty for the call through a
  15966. function pointer; on most modern architectures, such a call defeats the
  15967. branch prediction features of the CPU@. This is also true of normal
  15968. virtual function calls.
  15969. The syntax for this extension is
  15970. @smallexample
  15971. extern A a;
  15972. extern int (A::*fp)();
  15973. typedef int (*fptr)(A *);
  15974. fptr p = (fptr)(a.*fp);
  15975. @end smallexample
  15976. For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
  15977. no object is needed to obtain the address of the function. They can be
  15978. converted to function pointers directly:
  15979. @smallexample
  15980. fptr p1 = (fptr)(&A::foo);
  15981. @end smallexample
  15982. @opindex Wno-pmf-conversions
  15983. You must specify @option{-Wno-pmf-conversions} to use this extension.
  15984. @node C++ Attributes
  15985. @section C++-Specific Variable, Function, and Type Attributes
  15986. Some attributes only make sense for C++ programs.
  15987. @table @code
  15988. @item abi_tag ("@var{tag}", ...)
  15989. @cindex @code{abi_tag} function attribute
  15990. @cindex @code{abi_tag} variable attribute
  15991. @cindex @code{abi_tag} type attribute
  15992. The @code{abi_tag} attribute can be applied to a function, variable, or class
  15993. declaration. It modifies the mangled name of the entity to
  15994. incorporate the tag name, in order to distinguish the function or
  15995. class from an earlier version with a different ABI; perhaps the class
  15996. has changed size, or the function has a different return type that is
  15997. not encoded in the mangled name.
  15998. The attribute can also be applied to an inline namespace, but does not
  15999. affect the mangled name of the namespace; in this case it is only used
  16000. for @option{-Wabi-tag} warnings and automatic tagging of functions and
  16001. variables. Tagging inline namespaces is generally preferable to
  16002. tagging individual declarations, but the latter is sometimes
  16003. necessary, such as when only certain members of a class need to be
  16004. tagged.
  16005. The argument can be a list of strings of arbitrary length. The
  16006. strings are sorted on output, so the order of the list is
  16007. unimportant.
  16008. A redeclaration of an entity must not add new ABI tags,
  16009. since doing so would change the mangled name.
  16010. The ABI tags apply to a name, so all instantiations and
  16011. specializations of a template have the same tags. The attribute will
  16012. be ignored if applied to an explicit specialization or instantiation.
  16013. The @option{-Wabi-tag} flag enables a warning about a class which does
  16014. not have all the ABI tags used by its subobjects and virtual functions; for users with code
  16015. that needs to coexist with an earlier ABI, using this option can help
  16016. to find all affected types that need to be tagged.
  16017. When a type involving an ABI tag is used as the type of a variable or
  16018. return type of a function where that tag is not already present in the
  16019. signature of the function, the tag is automatically applied to the
  16020. variable or function. @option{-Wabi-tag} also warns about this
  16021. situation; this warning can be avoided by explicitly tagging the
  16022. variable or function or moving it into a tagged inline namespace.
  16023. @item init_priority (@var{priority})
  16024. @cindex @code{init_priority} variable attribute
  16025. In Standard C++, objects defined at namespace scope are guaranteed to be
  16026. initialized in an order in strict accordance with that of their definitions
  16027. @emph{in a given translation unit}. No guarantee is made for initializations
  16028. across translation units. However, GNU C++ allows users to control the
  16029. order of initialization of objects defined at namespace scope with the
  16030. @code{init_priority} attribute by specifying a relative @var{priority},
  16031. a constant integral expression currently bounded between 101 and 65535
  16032. inclusive. Lower numbers indicate a higher priority.
  16033. In the following example, @code{A} would normally be created before
  16034. @code{B}, but the @code{init_priority} attribute reverses that order:
  16035. @smallexample
  16036. Some_Class A __attribute__ ((init_priority (2000)));
  16037. Some_Class B __attribute__ ((init_priority (543)));
  16038. @end smallexample
  16039. @noindent
  16040. Note that the particular values of @var{priority} do not matter; only their
  16041. relative ordering.
  16042. @item java_interface
  16043. @cindex @code{java_interface} type attribute
  16044. This type attribute informs C++ that the class is a Java interface. It may
  16045. only be applied to classes declared within an @code{extern "Java"} block.
  16046. Calls to methods declared in this interface are dispatched using GCJ's
  16047. interface table mechanism, instead of regular virtual table dispatch.
  16048. @item warn_unused
  16049. @cindex @code{warn_unused} type attribute
  16050. For C++ types with non-trivial constructors and/or destructors it is
  16051. impossible for the compiler to determine whether a variable of this
  16052. type is truly unused if it is not referenced. This type attribute
  16053. informs the compiler that variables of this type should be warned
  16054. about if they appear to be unused, just like variables of fundamental
  16055. types.
  16056. This attribute is appropriate for types which just represent a value,
  16057. such as @code{std::string}; it is not appropriate for types which
  16058. control a resource, such as @code{std::mutex}.
  16059. This attribute is also accepted in C, but it is unnecessary because C
  16060. does not have constructors or destructors.
  16061. @end table
  16062. See also @ref{Namespace Association}.
  16063. @node Function Multiversioning
  16064. @section Function Multiversioning
  16065. @cindex function versions
  16066. With the GNU C++ front end, for x86 targets, you may specify multiple
  16067. versions of a function, where each function is specialized for a
  16068. specific target feature. At runtime, the appropriate version of the
  16069. function is automatically executed depending on the characteristics of
  16070. the execution platform. Here is an example.
  16071. @smallexample
  16072. __attribute__ ((target ("default")))
  16073. int foo ()
  16074. @{
  16075. // The default version of foo.
  16076. return 0;
  16077. @}
  16078. __attribute__ ((target ("sse4.2")))
  16079. int foo ()
  16080. @{
  16081. // foo version for SSE4.2
  16082. return 1;
  16083. @}
  16084. __attribute__ ((target ("arch=atom")))
  16085. int foo ()
  16086. @{
  16087. // foo version for the Intel ATOM processor
  16088. return 2;
  16089. @}
  16090. __attribute__ ((target ("arch=amdfam10")))
  16091. int foo ()
  16092. @{
  16093. // foo version for the AMD Family 0x10 processors.
  16094. return 3;
  16095. @}
  16096. int main ()
  16097. @{
  16098. int (*p)() = &foo;
  16099. assert ((*p) () == foo ());
  16100. return 0;
  16101. @}
  16102. @end smallexample
  16103. In the above example, four versions of function foo are created. The
  16104. first version of foo with the target attribute "default" is the default
  16105. version. This version gets executed when no other target specific
  16106. version qualifies for execution on a particular platform. A new version
  16107. of foo is created by using the same function signature but with a
  16108. different target string. Function foo is called or a pointer to it is
  16109. taken just like a regular function. GCC takes care of doing the
  16110. dispatching to call the right version at runtime. Refer to the
  16111. @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
  16112. Function Multiversioning} for more details.
  16113. @node Namespace Association
  16114. @section Namespace Association
  16115. @strong{Caution:} The semantics of this extension are equivalent
  16116. to C++ 2011 inline namespaces. Users should use inline namespaces
  16117. instead as this extension will be removed in future versions of G++.
  16118. A using-directive with @code{__attribute ((strong))} is stronger
  16119. than a normal using-directive in two ways:
  16120. @itemize @bullet
  16121. @item
  16122. Templates from the used namespace can be specialized and explicitly
  16123. instantiated as though they were members of the using namespace.
  16124. @item
  16125. The using namespace is considered an associated namespace of all
  16126. templates in the used namespace for purposes of argument-dependent
  16127. name lookup.
  16128. @end itemize
  16129. The used namespace must be nested within the using namespace so that
  16130. normal unqualified lookup works properly.
  16131. This is useful for composing a namespace transparently from
  16132. implementation namespaces. For example:
  16133. @smallexample
  16134. namespace std @{
  16135. namespace debug @{
  16136. template <class T> struct A @{ @};
  16137. @}
  16138. using namespace debug __attribute ((__strong__));
  16139. template <> struct A<int> @{ @}; // @r{OK to specialize}
  16140. template <class T> void f (A<T>);
  16141. @}
  16142. int main()
  16143. @{
  16144. f (std::A<float>()); // @r{lookup finds} std::f
  16145. f (std::A<int>());
  16146. @}
  16147. @end smallexample
  16148. @node Type Traits
  16149. @section Type Traits
  16150. The C++ front end implements syntactic extensions that allow
  16151. compile-time determination of
  16152. various characteristics of a type (or of a
  16153. pair of types).
  16154. @table @code
  16155. @item __has_nothrow_assign (type)
  16156. If @code{type} is const qualified or is a reference type then the trait is
  16157. false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
  16158. is true, else if @code{type} is a cv class or union type with copy assignment
  16159. operators that are known not to throw an exception then the trait is true,
  16160. else it is false. Requires: @code{type} shall be a complete type,
  16161. (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16162. @item __has_nothrow_copy (type)
  16163. If @code{__has_trivial_copy (type)} is true then the trait is true, else if
  16164. @code{type} is a cv class or union type with copy constructors that
  16165. are known not to throw an exception then the trait is true, else it is false.
  16166. Requires: @code{type} shall be a complete type, (possibly cv-qualified)
  16167. @code{void}, or an array of unknown bound.
  16168. @item __has_nothrow_constructor (type)
  16169. If @code{__has_trivial_constructor (type)} is true then the trait is
  16170. true, else if @code{type} is a cv class or union type (or array
  16171. thereof) with a default constructor that is known not to throw an
  16172. exception then the trait is true, else it is false. Requires:
  16173. @code{type} shall be a complete type, (possibly cv-qualified)
  16174. @code{void}, or an array of unknown bound.
  16175. @item __has_trivial_assign (type)
  16176. If @code{type} is const qualified or is a reference type then the trait is
  16177. false. Otherwise if @code{__is_pod (type)} is true then the trait is
  16178. true, else if @code{type} is a cv class or union type with a trivial
  16179. copy assignment ([class.copy]) then the trait is true, else it is
  16180. false. Requires: @code{type} shall be a complete type, (possibly
  16181. cv-qualified) @code{void}, or an array of unknown bound.
  16182. @item __has_trivial_copy (type)
  16183. If @code{__is_pod (type)} is true or @code{type} is a reference type
  16184. then the trait is true, else if @code{type} is a cv class or union type
  16185. with a trivial copy constructor ([class.copy]) then the trait
  16186. is true, else it is false. Requires: @code{type} shall be a complete
  16187. type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16188. @item __has_trivial_constructor (type)
  16189. If @code{__is_pod (type)} is true then the trait is true, else if
  16190. @code{type} is a cv class or union type (or array thereof) with a
  16191. trivial default constructor ([class.ctor]) then the trait is true,
  16192. else it is false. Requires: @code{type} shall be a complete
  16193. type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16194. @item __has_trivial_destructor (type)
  16195. If @code{__is_pod (type)} is true or @code{type} is a reference type then
  16196. the trait is true, else if @code{type} is a cv class or union type (or
  16197. array thereof) with a trivial destructor ([class.dtor]) then the trait
  16198. is true, else it is false. Requires: @code{type} shall be a complete
  16199. type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16200. @item __has_virtual_destructor (type)
  16201. If @code{type} is a class type with a virtual destructor
  16202. ([class.dtor]) then the trait is true, else it is false. Requires:
  16203. @code{type} shall be a complete type, (possibly cv-qualified)
  16204. @code{void}, or an array of unknown bound.
  16205. @item __is_abstract (type)
  16206. If @code{type} is an abstract class ([class.abstract]) then the trait
  16207. is true, else it is false. Requires: @code{type} shall be a complete
  16208. type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16209. @item __is_base_of (base_type, derived_type)
  16210. If @code{base_type} is a base class of @code{derived_type}
  16211. ([class.derived]) then the trait is true, otherwise it is false.
  16212. Top-level cv qualifications of @code{base_type} and
  16213. @code{derived_type} are ignored. For the purposes of this trait, a
  16214. class type is considered is own base. Requires: if @code{__is_class
  16215. (base_type)} and @code{__is_class (derived_type)} are true and
  16216. @code{base_type} and @code{derived_type} are not the same type
  16217. (disregarding cv-qualifiers), @code{derived_type} shall be a complete
  16218. type. Diagnostic is produced if this requirement is not met.
  16219. @item __is_class (type)
  16220. If @code{type} is a cv class type, and not a union type
  16221. ([basic.compound]) the trait is true, else it is false.
  16222. @item __is_empty (type)
  16223. If @code{__is_class (type)} is false then the trait is false.
  16224. Otherwise @code{type} is considered empty if and only if: @code{type}
  16225. has no non-static data members, or all non-static data members, if
  16226. any, are bit-fields of length 0, and @code{type} has no virtual
  16227. members, and @code{type} has no virtual base classes, and @code{type}
  16228. has no base classes @code{base_type} for which
  16229. @code{__is_empty (base_type)} is false. Requires: @code{type} shall
  16230. be a complete type, (possibly cv-qualified) @code{void}, or an array
  16231. of unknown bound.
  16232. @item __is_enum (type)
  16233. If @code{type} is a cv enumeration type ([basic.compound]) the trait is
  16234. true, else it is false.
  16235. @item __is_literal_type (type)
  16236. If @code{type} is a literal type ([basic.types]) the trait is
  16237. true, else it is false. Requires: @code{type} shall be a complete type,
  16238. (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16239. @item __is_pod (type)
  16240. If @code{type} is a cv POD type ([basic.types]) then the trait is true,
  16241. else it is false. Requires: @code{type} shall be a complete type,
  16242. (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16243. @item __is_polymorphic (type)
  16244. If @code{type} is a polymorphic class ([class.virtual]) then the trait
  16245. is true, else it is false. Requires: @code{type} shall be a complete
  16246. type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16247. @item __is_standard_layout (type)
  16248. If @code{type} is a standard-layout type ([basic.types]) the trait is
  16249. true, else it is false. Requires: @code{type} shall be a complete
  16250. type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16251. @item __is_trivial (type)
  16252. If @code{type} is a trivial type ([basic.types]) the trait is
  16253. true, else it is false. Requires: @code{type} shall be a complete
  16254. type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
  16255. @item __is_union (type)
  16256. If @code{type} is a cv union type ([basic.compound]) the trait is
  16257. true, else it is false.
  16258. @item __underlying_type (type)
  16259. The underlying type of @code{type}. Requires: @code{type} shall be
  16260. an enumeration type ([dcl.enum]).
  16261. @end table
  16262. @node Java Exceptions
  16263. @section Java Exceptions
  16264. The Java language uses a slightly different exception handling model
  16265. from C++. Normally, GNU C++ automatically detects when you are
  16266. writing C++ code that uses Java exceptions, and handle them
  16267. appropriately. However, if C++ code only needs to execute destructors
  16268. when Java exceptions are thrown through it, GCC guesses incorrectly.
  16269. Sample problematic code is:
  16270. @smallexample
  16271. struct S @{ ~S(); @};
  16272. extern void bar(); // @r{is written in Java, and may throw exceptions}
  16273. void foo()
  16274. @{
  16275. S s;
  16276. bar();
  16277. @}
  16278. @end smallexample
  16279. @noindent
  16280. The usual effect of an incorrect guess is a link failure, complaining of
  16281. a missing routine called @samp{__gxx_personality_v0}.
  16282. You can inform the compiler that Java exceptions are to be used in a
  16283. translation unit, irrespective of what it might think, by writing
  16284. @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
  16285. @samp{#pragma} must appear before any functions that throw or catch
  16286. exceptions, or run destructors when exceptions are thrown through them.
  16287. You cannot mix Java and C++ exceptions in the same translation unit. It
  16288. is believed to be safe to throw a C++ exception from one file through
  16289. another file compiled for the Java exception model, or vice versa, but
  16290. there may be bugs in this area.
  16291. @node Deprecated Features
  16292. @section Deprecated Features
  16293. In the past, the GNU C++ compiler was extended to experiment with new
  16294. features, at a time when the C++ language was still evolving. Now that
  16295. the C++ standard is complete, some of those features are superseded by
  16296. superior alternatives. Using the old features might cause a warning in
  16297. some cases that the feature will be dropped in the future. In other
  16298. cases, the feature might be gone already.
  16299. While the list below is not exhaustive, it documents some of the options
  16300. that are now deprecated:
  16301. @table @code
  16302. @item -fexternal-templates
  16303. @itemx -falt-external-templates
  16304. These are two of the many ways for G++ to implement template
  16305. instantiation. @xref{Template Instantiation}. The C++ standard clearly
  16306. defines how template definitions have to be organized across
  16307. implementation units. G++ has an implicit instantiation mechanism that
  16308. should work just fine for standard-conforming code.
  16309. @item -fstrict-prototype
  16310. @itemx -fno-strict-prototype
  16311. Previously it was possible to use an empty prototype parameter list to
  16312. indicate an unspecified number of parameters (like C), rather than no
  16313. parameters, as C++ demands. This feature has been removed, except where
  16314. it is required for backwards compatibility. @xref{Backwards Compatibility}.
  16315. @end table
  16316. G++ allows a virtual function returning @samp{void *} to be overridden
  16317. by one returning a different pointer type. This extension to the
  16318. covariant return type rules is now deprecated and will be removed from a
  16319. future version.
  16320. The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
  16321. their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
  16322. and are now removed from G++. Code using these operators should be
  16323. modified to use @code{std::min} and @code{std::max} instead.
  16324. The named return value extension has been deprecated, and is now
  16325. removed from G++.
  16326. The use of initializer lists with new expressions has been deprecated,
  16327. and is now removed from G++.
  16328. Floating and complex non-type template parameters have been deprecated,
  16329. and are now removed from G++.
  16330. The implicit typename extension has been deprecated and is now
  16331. removed from G++.
  16332. The use of default arguments in function pointers, function typedefs
  16333. and other places where they are not permitted by the standard is
  16334. deprecated and will be removed from a future version of G++.
  16335. G++ allows floating-point literals to appear in integral constant expressions,
  16336. e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
  16337. This extension is deprecated and will be removed from a future version.
  16338. G++ allows static data members of const floating-point type to be declared
  16339. with an initializer in a class definition. The standard only allows
  16340. initializers for static members of const integral types and const
  16341. enumeration types so this extension has been deprecated and will be removed
  16342. from a future version.
  16343. @node Backwards Compatibility
  16344. @section Backwards Compatibility
  16345. @cindex Backwards Compatibility
  16346. @cindex ARM [Annotated C++ Reference Manual]
  16347. Now that there is a definitive ISO standard C++, G++ has a specification
  16348. to adhere to. The C++ language evolved over time, and features that
  16349. used to be acceptable in previous drafts of the standard, such as the ARM
  16350. [Annotated C++ Reference Manual], are no longer accepted. In order to allow
  16351. compilation of C++ written to such drafts, G++ contains some backwards
  16352. compatibilities. @emph{All such backwards compatibility features are
  16353. liable to disappear in future versions of G++.} They should be considered
  16354. deprecated. @xref{Deprecated Features}.
  16355. @table @code
  16356. @item For scope
  16357. If a variable is declared at for scope, it used to remain in scope until
  16358. the end of the scope that contained the for statement (rather than just
  16359. within the for scope). G++ retains this, but issues a warning, if such a
  16360. variable is accessed outside the for scope.
  16361. @item Implicit C language
  16362. Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
  16363. scope to set the language. On such systems, all header files are
  16364. implicitly scoped inside a C language scope. Also, an empty prototype
  16365. @code{()} is treated as an unspecified number of arguments, rather
  16366. than no arguments, as C++ demands.
  16367. @end table
  16368. @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
  16369. @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr