12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062 |
- #pragma once
- #ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-parameter"
- #endif
- //===- OpenMPClause.h - Classes for OpenMP clauses --------------*- C++ -*-===//
- //
- // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
- // See https://llvm.org/LICENSE.txt for license information.
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- //
- //===----------------------------------------------------------------------===//
- //
- /// \file
- /// This file defines OpenMP AST classes for clauses.
- /// There are clauses for executable directives, clauses for declarative
- /// directives and clauses which can be used in both kinds of directives.
- //
- //===----------------------------------------------------------------------===//
- #ifndef LLVM_CLANG_AST_OPENMPCLAUSE_H
- #define LLVM_CLANG_AST_OPENMPCLAUSE_H
- #include "clang/AST/ASTFwd.h"
- #include "clang/AST/Decl.h"
- #include "clang/AST/DeclarationName.h"
- #include "clang/AST/Expr.h"
- #include "clang/AST/NestedNameSpecifier.h"
- #include "clang/AST/Stmt.h"
- #include "clang/AST/StmtIterator.h"
- #include "clang/Basic/LLVM.h"
- #include "clang/Basic/OpenMPKinds.h"
- #include "clang/Basic/SourceLocation.h"
- #include "llvm/ADT/ArrayRef.h"
- #include "llvm/ADT/MapVector.h"
- #include "llvm/ADT/PointerIntPair.h"
- #include "llvm/ADT/SmallVector.h"
- #include "llvm/ADT/iterator.h"
- #include "llvm/ADT/iterator_range.h"
- #include "llvm/Frontend/OpenMP/OMPAssume.h"
- #include "llvm/Frontend/OpenMP/OMPConstants.h"
- #include "llvm/Frontend/OpenMP/OMPContext.h"
- #include "llvm/Support/Casting.h"
- #include "llvm/Support/Compiler.h"
- #include "llvm/Support/TrailingObjects.h"
- #include <cassert>
- #include <cstddef>
- #include <iterator>
- #include <utility>
- namespace clang {
- class ASTContext;
- //===----------------------------------------------------------------------===//
- // AST classes for clauses.
- //===----------------------------------------------------------------------===//
- /// This is a basic class for representing single OpenMP clause.
- class OMPClause {
- /// Starting location of the clause (the clause keyword).
- SourceLocation StartLoc;
- /// Ending location of the clause.
- SourceLocation EndLoc;
- /// Kind of the clause.
- OpenMPClauseKind Kind;
- protected:
- OMPClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation EndLoc)
- : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {}
- public:
- /// Returns the starting location of the clause.
- SourceLocation getBeginLoc() const { return StartLoc; }
- /// Returns the ending location of the clause.
- SourceLocation getEndLoc() const { return EndLoc; }
- /// Sets the starting location of the clause.
- void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
- /// Sets the ending location of the clause.
- void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
- /// Returns kind of OpenMP clause (private, shared, reduction, etc.).
- OpenMPClauseKind getClauseKind() const { return Kind; }
- bool isImplicit() const { return StartLoc.isInvalid(); }
- using child_iterator = StmtIterator;
- using const_child_iterator = ConstStmtIterator;
- using child_range = llvm::iterator_range<child_iterator>;
- using const_child_range = llvm::iterator_range<const_child_iterator>;
- child_range children();
- const_child_range children() const {
- auto Children = const_cast<OMPClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- /// Get the iterator range for the expressions used in the clauses. Used
- /// expressions include only the children that must be evaluated at the
- /// runtime before entering the construct.
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *) { return true; }
- };
- template <OpenMPClauseKind ClauseKind>
- struct OMPNoChildClause : public OMPClause {
- /// Build '\p ClauseKind' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPNoChildClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(ClauseKind, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPNoChildClause()
- : OMPClause(ClauseKind, SourceLocation(), SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == ClauseKind;
- }
- };
- template <OpenMPClauseKind ClauseKind, class Base>
- class OMPOneStmtClause : public Base {
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Sub-expression.
- Stmt *S = nullptr;
- protected:
- void setStmt(Stmt *S) { this->S = S; }
- public:
- OMPOneStmtClause(Stmt *S, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : Base(ClauseKind, StartLoc, EndLoc), LParenLoc(LParenLoc), S(S) {}
- OMPOneStmtClause() : Base(ClauseKind, SourceLocation(), SourceLocation()) {}
- /// Return the associated statement, potentially casted to \p T.
- template <typename T> T *getStmtAs() const { return cast_or_null<T>(S); }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- using child_iterator = StmtIterator;
- using const_child_iterator = ConstStmtIterator;
- using child_range = llvm::iterator_range<child_iterator>;
- using const_child_range = llvm::iterator_range<const_child_iterator>;
- child_range children() { return child_range(&S, &S + 1); }
- const_child_range children() const { return const_child_range(&S, &S + 1); }
- // TODO: Consider making the getAddrOfExprAsWritten version the default.
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == ClauseKind;
- }
- };
- /// Class that handles pre-initialization statement for some clauses, like
- /// 'shedule', 'firstprivate' etc.
- class OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Pre-initialization statement for the clause.
- Stmt *PreInit = nullptr;
- /// Region that captures the associated stmt.
- OpenMPDirectiveKind CaptureRegion = llvm::omp::OMPD_unknown;
- protected:
- OMPClauseWithPreInit(const OMPClause *This) {
- assert(get(This) && "get is not tuned for pre-init.");
- }
- /// Set pre-initialization statement for the clause.
- void
- setPreInitStmt(Stmt *S,
- OpenMPDirectiveKind ThisRegion = llvm::omp::OMPD_unknown) {
- PreInit = S;
- CaptureRegion = ThisRegion;
- }
- public:
- /// Get pre-initialization statement for the clause.
- const Stmt *getPreInitStmt() const { return PreInit; }
- /// Get pre-initialization statement for the clause.
- Stmt *getPreInitStmt() { return PreInit; }
- /// Get capture region for the stmt in the clause.
- OpenMPDirectiveKind getCaptureRegion() const { return CaptureRegion; }
- static OMPClauseWithPreInit *get(OMPClause *C);
- static const OMPClauseWithPreInit *get(const OMPClause *C);
- };
- /// Class that handles post-update expression for some clauses, like
- /// 'lastprivate', 'reduction' etc.
- class OMPClauseWithPostUpdate : public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Post-update expression for the clause.
- Expr *PostUpdate = nullptr;
- protected:
- OMPClauseWithPostUpdate(const OMPClause *This) : OMPClauseWithPreInit(This) {
- assert(get(This) && "get is not tuned for post-update.");
- }
- /// Set pre-initialization statement for the clause.
- void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
- public:
- /// Get post-update expression for the clause.
- const Expr *getPostUpdateExpr() const { return PostUpdate; }
- /// Get post-update expression for the clause.
- Expr *getPostUpdateExpr() { return PostUpdate; }
- static OMPClauseWithPostUpdate *get(OMPClause *C);
- static const OMPClauseWithPostUpdate *get(const OMPClause *C);
- };
- /// This structure contains most locations needed for by an OMPVarListClause.
- struct OMPVarListLocTy {
- /// Starting location of the clause (the clause keyword).
- SourceLocation StartLoc;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Ending location of the clause.
- SourceLocation EndLoc;
- OMPVarListLocTy() = default;
- OMPVarListLocTy(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : StartLoc(StartLoc), LParenLoc(LParenLoc), EndLoc(EndLoc) {}
- };
- /// This represents clauses with the list of variables like 'private',
- /// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
- /// '#pragma omp ...' directives.
- template <class T> class OMPVarListClause : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Number of variables in the list.
- unsigned NumVars;
- protected:
- /// Build a clause with \a N variables
- ///
- /// \param K Kind of the clause.
- /// \param StartLoc Starting location of the clause (the clause keyword).
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
- : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
- /// Fetches list of variables associated with this clause.
- MutableArrayRef<Expr *> getVarRefs() {
- return MutableArrayRef<Expr *>(
- static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars);
- }
- /// Sets the list of variables for this clause.
- void setVarRefs(ArrayRef<Expr *> VL) {
- assert(VL.size() == NumVars &&
- "Number of variables is not the same as the preallocated buffer");
- std::copy(VL.begin(), VL.end(),
- static_cast<T *>(this)->template getTrailingObjects<Expr *>());
- }
- public:
- using varlist_iterator = MutableArrayRef<Expr *>::iterator;
- using varlist_const_iterator = ArrayRef<const Expr *>::iterator;
- using varlist_range = llvm::iterator_range<varlist_iterator>;
- using varlist_const_range = llvm::iterator_range<varlist_const_iterator>;
- unsigned varlist_size() const { return NumVars; }
- bool varlist_empty() const { return NumVars == 0; }
- varlist_range varlists() {
- return varlist_range(varlist_begin(), varlist_end());
- }
- varlist_const_range varlists() const {
- return varlist_const_range(varlist_begin(), varlist_end());
- }
- varlist_iterator varlist_begin() { return getVarRefs().begin(); }
- varlist_iterator varlist_end() { return getVarRefs().end(); }
- varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
- varlist_const_iterator varlist_end() const { return getVarRefs().end(); }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Fetches list of all variables in the clause.
- ArrayRef<const Expr *> getVarRefs() const {
- return llvm::ArrayRef(
- static_cast<const T *>(this)->template getTrailingObjects<Expr *>(),
- NumVars);
- }
- };
- /// This represents 'allocator' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp allocate(a) allocator(omp_default_mem_alloc)
- /// \endcode
- /// In this example directive '#pragma omp allocate' has simple 'allocator'
- /// clause with the allocator 'omp_default_mem_alloc'.
- class OMPAllocatorClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_allocator, OMPClause> {
- friend class OMPClauseReader;
- /// Set allocator.
- void setAllocator(Expr *A) { setStmt(A); }
- public:
- /// Build 'allocator' clause with the given allocator.
- ///
- /// \param A Allocator.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
- /// Build an empty clause.
- OMPAllocatorClause() : OMPOneStmtClause() {}
- /// Returns allocator.
- Expr *getAllocator() const { return getStmtAs<Expr>(); }
- };
- /// This represents the 'align' clause in the '#pragma omp allocate'
- /// directive.
- ///
- /// \code
- /// #pragma omp allocate(a) allocator(omp_default_mem_alloc) align(8)
- /// \endcode
- /// In this example directive '#pragma omp allocate' has simple 'allocator'
- /// clause with the allocator 'omp_default_mem_alloc' and align clause with
- /// value of 8.
- class OMPAlignClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_align, OMPClause> {
- friend class OMPClauseReader;
- /// Set alignment value.
- void setAlignment(Expr *A) { setStmt(A); }
- /// Build 'align' clause with the given alignment
- ///
- /// \param A Alignment value.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
- /// Build an empty clause.
- OMPAlignClause() : OMPOneStmtClause() {}
- public:
- /// Build 'align' clause with the given alignment
- ///
- /// \param A Alignment value.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- static OMPAlignClause *Create(const ASTContext &C, Expr *A,
- SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc);
- /// Returns alignment
- Expr *getAlignment() const { return getStmtAs<Expr>(); }
- };
- /// This represents clause 'allocate' in the '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has clause 'private'
- /// and clause 'allocate' for the variable 'a'.
- class OMPAllocateClause final
- : public OMPVarListClause<OMPAllocateClause>,
- private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Allocator specified in the clause, or 'nullptr' if the default one is
- /// used.
- Expr *Allocator = nullptr;
- /// Position of the ':' delimiter in the clause;
- SourceLocation ColonLoc;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param Allocator Allocator expression.
- /// \param ColonLoc Location of ':' delimiter.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- Expr *Allocator, SourceLocation ColonLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc,
- LParenLoc, EndLoc, N),
- Allocator(Allocator), ColonLoc(ColonLoc) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPAllocateClause(unsigned N)
- : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- /// Sets location of ':' symbol in clause.
- void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
- void setAllocator(Expr *A) { Allocator = A; }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param Allocator Allocator expression.
- /// \param ColonLoc Location of ':' delimiter.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- static OMPAllocateClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc, Expr *Allocator,
- SourceLocation ColonLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL);
- /// Returns the allocator expression or nullptr, if no allocator is specified.
- Expr *getAllocator() const { return Allocator; }
- /// Returns the location of the ':' delimiter.
- SourceLocation getColonLoc() const { return ColonLoc; }
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPAllocateClause *CreateEmpty(const ASTContext &C, unsigned N);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPAllocateClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_allocate;
- }
- };
- /// This represents 'if' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp parallel if(parallel:a > 5)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has simple 'if' clause with
- /// condition 'a > 5' and directive name modifier 'parallel'.
- class OMPIfClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Condition of the 'if' clause.
- Stmt *Condition = nullptr;
- /// Location of ':' (if any).
- SourceLocation ColonLoc;
- /// Directive name modifier for the clause.
- OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
- /// Name modifier location.
- SourceLocation NameModifierLoc;
- /// Set condition.
- void setCondition(Expr *Cond) { Condition = Cond; }
- /// Set directive name modifier for the clause.
- void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
- /// Set location of directive name modifier for the clause.
- void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
- /// Set location of ':'.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- public:
- /// Build 'if' clause with condition \a Cond.
- ///
- /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
- /// \param Cond Condition of the clause.
- /// \param HelperCond Helper condition for the clause.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param NameModifierLoc Location of directive name modifier.
- /// \param ColonLoc [OpenMP 4.1] Location of ':'.
- /// \param EndLoc Ending location of the clause.
- OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
- OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation NameModifierLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_if, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond),
- ColonLoc(ColonLoc), NameModifier(NameModifier),
- NameModifierLoc(NameModifierLoc) {
- setPreInitStmt(HelperCond, CaptureRegion);
- }
- /// Build an empty clause.
- OMPIfClause()
- : OMPClause(llvm::omp::OMPC_if, SourceLocation(), SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return the location of ':'.
- SourceLocation getColonLoc() const { return ColonLoc; }
- /// Returns condition.
- Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
- /// Return directive name modifier associated with the clause.
- OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
- /// Return the location of directive name modifier.
- SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
- child_range children() { return child_range(&Condition, &Condition + 1); }
- const_child_range children() const {
- return const_child_range(&Condition, &Condition + 1);
- }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPIfClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_if;
- }
- };
- /// This represents 'final' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp task final(a > 5)
- /// \endcode
- /// In this example directive '#pragma omp task' has simple 'final'
- /// clause with condition 'a > 5'.
- class OMPFinalClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_final, OMPClause>,
- public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Set condition.
- void setCondition(Expr *Cond) { setStmt(Cond); }
- public:
- /// Build 'final' clause with condition \a Cond.
- ///
- /// \param Cond Condition of the clause.
- /// \param HelperCond Helper condition for the construct.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPFinalClause(Expr *Cond, Stmt *HelperCond,
- OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc)
- : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
- OMPClauseWithPreInit(this) {
- setPreInitStmt(HelperCond, CaptureRegion);
- }
- /// Build an empty clause.
- OMPFinalClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {}
- /// Returns condition.
- Expr *getCondition() const { return getStmtAs<Expr>(); }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPFinalClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- };
- /// This represents 'num_threads' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp parallel num_threads(6)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has simple 'num_threads'
- /// clause with number of threads '6'.
- class OMPNumThreadsClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_num_threads, OMPClause>,
- public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Set condition.
- void setNumThreads(Expr *NThreads) { setStmt(NThreads); }
- public:
- /// Build 'num_threads' clause with condition \a NumThreads.
- ///
- /// \param NumThreads Number of threads for the construct.
- /// \param HelperNumThreads Helper Number of threads for the construct.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads,
- OpenMPDirectiveKind CaptureRegion,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc),
- OMPClauseWithPreInit(this) {
- setPreInitStmt(HelperNumThreads, CaptureRegion);
- }
- /// Build an empty clause.
- OMPNumThreadsClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {}
- /// Returns number of threads.
- Expr *getNumThreads() const { return getStmtAs<Expr>(); }
- };
- /// This represents 'safelen' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp simd safelen(4)
- /// \endcode
- /// In this example directive '#pragma omp simd' has clause 'safelen'
- /// with single expression '4'.
- /// If the safelen clause is used then no two iterations executed
- /// concurrently with SIMD instructions can have a greater distance
- /// in the logical iteration space than its value. The parameter of
- /// the safelen clause must be a constant positive integer expression.
- class OMPSafelenClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_safelen, OMPClause> {
- friend class OMPClauseReader;
- /// Set safelen.
- void setSafelen(Expr *Len) { setStmt(Len); }
- public:
- /// Build 'safelen' clause.
- ///
- /// \param Len Expression associated with this clause.
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
- /// Build an empty clause.
- explicit OMPSafelenClause() : OMPOneStmtClause() {}
- /// Return safe iteration space distance.
- Expr *getSafelen() const { return getStmtAs<Expr>(); }
- };
- /// This represents 'simdlen' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp simd simdlen(4)
- /// \endcode
- /// In this example directive '#pragma omp simd' has clause 'simdlen'
- /// with single expression '4'.
- /// If the 'simdlen' clause is used then it specifies the preferred number of
- /// iterations to be executed concurrently. The parameter of the 'simdlen'
- /// clause must be a constant positive integer expression.
- class OMPSimdlenClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_simdlen, OMPClause> {
- friend class OMPClauseReader;
- /// Set simdlen.
- void setSimdlen(Expr *Len) { setStmt(Len); }
- public:
- /// Build 'simdlen' clause.
- ///
- /// \param Len Expression associated with this clause.
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
- /// Build an empty clause.
- explicit OMPSimdlenClause() : OMPOneStmtClause() {}
- /// Return safe iteration space distance.
- Expr *getSimdlen() const { return getStmtAs<Expr>(); }
- };
- /// This represents the 'sizes' clause in the '#pragma omp tile' directive.
- ///
- /// \code
- /// #pragma omp tile sizes(5,5)
- /// for (int i = 0; i < 64; ++i)
- /// for (int j = 0; j < 64; ++j)
- /// \endcode
- class OMPSizesClause final
- : public OMPClause,
- private llvm::TrailingObjects<OMPSizesClause, Expr *> {
- friend class OMPClauseReader;
- friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Number of tile sizes in the clause.
- unsigned NumSizes;
- /// Build an empty clause.
- explicit OMPSizesClause(int NumSizes)
- : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()),
- NumSizes(NumSizes) {}
- public:
- /// Build a 'sizes' AST node.
- ///
- /// \param C Context of the AST.
- /// \param StartLoc Location of the 'sizes' identifier.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Location of ')'.
- /// \param Sizes Content of the clause.
- static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc,
- ArrayRef<Expr *> Sizes);
- /// Build an empty 'sizes' AST node for deserialization.
- ///
- /// \param C Context of the AST.
- /// \param NumSizes Number of items in the clause.
- static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes);
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns the number of list items.
- unsigned getNumSizes() const { return NumSizes; }
- /// Returns the tile size expressions.
- MutableArrayRef<Expr *> getSizesRefs() {
- return MutableArrayRef<Expr *>(static_cast<OMPSizesClause *>(this)
- ->template getTrailingObjects<Expr *>(),
- NumSizes);
- }
- ArrayRef<Expr *> getSizesRefs() const {
- return ArrayRef<Expr *>(static_cast<const OMPSizesClause *>(this)
- ->template getTrailingObjects<Expr *>(),
- NumSizes);
- }
- /// Sets the tile size expressions.
- void setSizesRefs(ArrayRef<Expr *> VL) {
- assert(VL.size() == NumSizes);
- std::copy(VL.begin(), VL.end(),
- static_cast<OMPSizesClause *>(this)
- ->template getTrailingObjects<Expr *>());
- }
- child_range children() {
- MutableArrayRef<Expr *> Sizes = getSizesRefs();
- return child_range(reinterpret_cast<Stmt **>(Sizes.begin()),
- reinterpret_cast<Stmt **>(Sizes.end()));
- }
- const_child_range children() const {
- ArrayRef<Expr *> Sizes = getSizesRefs();
- return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()),
- reinterpret_cast<Stmt *const *>(Sizes.end()));
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_sizes;
- }
- };
- /// Representation of the 'full' clause of the '#pragma omp unroll' directive.
- ///
- /// \code
- /// #pragma omp unroll full
- /// for (int i = 0; i < 64; ++i)
- /// \endcode
- class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> {
- friend class OMPClauseReader;
- /// Build an empty clause.
- explicit OMPFullClause() : OMPNoChildClause() {}
- public:
- /// Build an AST node for a 'full' clause.
- ///
- /// \param C Context of the AST.
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation EndLoc);
- /// Build an empty 'full' AST node for deserialization.
- ///
- /// \param C Context of the AST.
- static OMPFullClause *CreateEmpty(const ASTContext &C);
- };
- /// Representation of the 'partial' clause of the '#pragma omp unroll'
- /// directive.
- ///
- /// \code
- /// #pragma omp unroll partial(4)
- /// for (int i = start; i < end; ++i)
- /// \endcode
- class OMPPartialClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Optional argument to the clause (unroll factor).
- Stmt *Factor;
- /// Build an empty clause.
- explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
- /// Set the unroll factor.
- void setFactor(Expr *E) { Factor = E; }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- public:
- /// Build an AST node for a 'partial' clause.
- ///
- /// \param C Context of the AST.
- /// \param StartLoc Location of the 'partial' identifier.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Location of ')'.
- /// \param Factor Clause argument.
- static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc, Expr *Factor);
- /// Build an empty 'partial' AST node for deserialization.
- ///
- /// \param C Context of the AST.
- static OMPPartialClause *CreateEmpty(const ASTContext &C);
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns the argument of the clause or nullptr if not set.
- Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
- child_range children() { return child_range(&Factor, &Factor + 1); }
- const_child_range children() const {
- return const_child_range(&Factor, &Factor + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_partial;
- }
- };
- /// This represents 'collapse' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp simd collapse(3)
- /// \endcode
- /// In this example directive '#pragma omp simd' has clause 'collapse'
- /// with single expression '3'.
- /// The parameter must be a constant positive integer expression, it specifies
- /// the number of nested loops that should be collapsed into a single iteration
- /// space.
- class OMPCollapseClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_collapse, OMPClause> {
- friend class OMPClauseReader;
- /// Set the number of associated for-loops.
- void setNumForLoops(Expr *Num) { setStmt(Num); }
- public:
- /// Build 'collapse' clause.
- ///
- /// \param Num Expression associated with this clause.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPCollapseClause(Expr *Num, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc)
- : OMPOneStmtClause(Num, StartLoc, LParenLoc, EndLoc) {}
- /// Build an empty clause.
- explicit OMPCollapseClause() : OMPOneStmtClause() {}
- /// Return the number of associated for-loops.
- Expr *getNumForLoops() const { return getStmtAs<Expr>(); }
- };
- /// This represents 'default' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp parallel default(shared)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has simple 'default'
- /// clause with kind 'shared'.
- class OMPDefaultClause : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// A kind of the 'default' clause.
- llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown;
- /// Start location of the kind in source code.
- SourceLocation KindKwLoc;
- /// Set kind of the clauses.
- ///
- /// \param K Argument of clause.
- void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; }
- /// Set argument location.
- ///
- /// \param KLoc Argument location.
- void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
- public:
- /// Build 'default' clause with argument \a A ('none' or 'shared').
- ///
- /// \param A Argument of the clause ('none' or 'shared').
- /// \param ALoc Starting location of the argument.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc),
- LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
- /// Build an empty clause.
- OMPDefaultClause()
- : OMPClause(llvm::omp::OMPC_default, SourceLocation(), SourceLocation()) {
- }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns kind of the clause.
- llvm::omp::DefaultKind getDefaultKind() const { return Kind; }
- /// Returns location of clause kind.
- SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_default;
- }
- };
- /// This represents 'proc_bind' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp parallel proc_bind(master)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has simple 'proc_bind'
- /// clause with kind 'master'.
- class OMPProcBindClause : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// A kind of the 'proc_bind' clause.
- llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
- /// Start location of the kind in source code.
- SourceLocation KindKwLoc;
- /// Set kind of the clause.
- ///
- /// \param K Kind of clause.
- void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
- /// Set clause kind location.
- ///
- /// \param KLoc Kind location.
- void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
- public:
- /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
- /// 'spread').
- ///
- /// \param A Argument of the clause ('master', 'close' or 'spread').
- /// \param ALoc Starting location of the argument.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc),
- LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
- /// Build an empty clause.
- OMPProcBindClause()
- : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(),
- SourceLocation()) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns kind of the clause.
- llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
- /// Returns location of clause kind.
- SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_proc_bind;
- }
- };
- /// This represents 'unified_address' clause in the '#pragma omp requires'
- /// directive.
- ///
- /// \code
- /// #pragma omp requires unified_address
- /// \endcode
- /// In this example directive '#pragma omp requires' has 'unified_address'
- /// clause.
- class OMPUnifiedAddressClause final
- : public OMPNoChildClause<llvm::omp::OMPC_unified_address> {
- public:
- friend class OMPClauseReader;
- /// Build 'unified_address' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPUnifiedAddressClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPNoChildClause(StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPUnifiedAddressClause() : OMPNoChildClause() {}
- };
- /// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
- /// directive.
- ///
- /// \code
- /// #pragma omp requires unified_shared_memory
- /// \endcode
- /// In this example directive '#pragma omp requires' has 'unified_shared_memory'
- /// clause.
- class OMPUnifiedSharedMemoryClause final : public OMPClause {
- public:
- friend class OMPClauseReader;
- /// Build 'unified_shared_memory' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPUnifiedSharedMemoryClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPUnifiedSharedMemoryClause()
- : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(),
- SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory;
- }
- };
- /// This represents 'reverse_offload' clause in the '#pragma omp requires'
- /// directive.
- ///
- /// \code
- /// #pragma omp requires reverse_offload
- /// \endcode
- /// In this example directive '#pragma omp requires' has 'reverse_offload'
- /// clause.
- class OMPReverseOffloadClause final : public OMPClause {
- public:
- friend class OMPClauseReader;
- /// Build 'reverse_offload' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPReverseOffloadClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPReverseOffloadClause()
- : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(),
- SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_reverse_offload;
- }
- };
- /// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
- /// directive.
- ///
- /// \code
- /// #pragma omp requires dynamic_allocators
- /// \endcode
- /// In this example directive '#pragma omp requires' has 'dynamic_allocators'
- /// clause.
- class OMPDynamicAllocatorsClause final : public OMPClause {
- public:
- friend class OMPClauseReader;
- /// Build 'dynamic_allocators' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPDynamicAllocatorsClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPDynamicAllocatorsClause()
- : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(),
- SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators;
- }
- };
- /// This represents 'atomic_default_mem_order' clause in the '#pragma omp
- /// requires' directive.
- ///
- /// \code
- /// #pragma omp requires atomic_default_mem_order(seq_cst)
- /// \endcode
- /// In this example directive '#pragma omp requires' has simple
- /// atomic_default_mem_order' clause with kind 'seq_cst'.
- class OMPAtomicDefaultMemOrderClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('
- SourceLocation LParenLoc;
- /// A kind of the 'atomic_default_mem_order' clause.
- OpenMPAtomicDefaultMemOrderClauseKind Kind =
- OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown;
- /// Start location of the kind in source code.
- SourceLocation KindKwLoc;
- /// Set kind of the clause.
- ///
- /// \param K Kind of clause.
- void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
- Kind = K;
- }
- /// Set clause kind location.
- ///
- /// \param KLoc Kind location.
- void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
- KindKwLoc = KLoc;
- }
- public:
- /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
- /// 'acq_rel' or 'relaxed').
- ///
- /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
- /// \param ALoc Starting location of the argument.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPAtomicDefaultMemOrderClause(OpenMPAtomicDefaultMemOrderClauseKind A,
- SourceLocation ALoc, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc),
- LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
- /// Build an empty clause.
- OMPAtomicDefaultMemOrderClause()
- : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(),
- SourceLocation()) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the locaiton of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns kind of the clause.
- OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const {
- return Kind;
- }
- /// Returns location of clause kind.
- SourceLocation getAtomicDefaultMemOrderKindKwLoc() const { return KindKwLoc; }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order;
- }
- };
- /// This represents 'at' clause in the '#pragma omp error' directive
- ///
- /// \code
- /// #pragma omp error at(compilation)
- /// \endcode
- /// In this example directive '#pragma omp error' has simple
- /// 'at' clause with kind 'complilation'.
- class OMPAtClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('
- SourceLocation LParenLoc;
- /// A kind of the 'at' clause.
- OpenMPAtClauseKind Kind = OMPC_AT_unknown;
- /// Start location of the kind in source code.
- SourceLocation KindKwLoc;
- /// Set kind of the clause.
- ///
- /// \param K Kind of clause.
- void setAtKind(OpenMPAtClauseKind K) { Kind = K; }
- /// Set clause kind location.
- ///
- /// \param KLoc Kind location.
- void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- public:
- /// Build 'at' clause with argument \a A ('compilation' or 'execution').
- ///
- /// \param A Argument of the clause ('compilation' or 'execution').
- /// \param ALoc Starting location of the argument.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPAtClause(OpenMPAtClauseKind A, SourceLocation ALoc,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc),
- Kind(A), KindKwLoc(ALoc) {}
- /// Build an empty clause.
- OMPAtClause()
- : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {}
- /// Returns the locaiton of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns kind of the clause.
- OpenMPAtClauseKind getAtKind() const { return Kind; }
- /// Returns location of clause kind.
- SourceLocation getAtKindKwLoc() const { return KindKwLoc; }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_at;
- }
- };
- /// This represents 'severity' clause in the '#pragma omp error' directive
- ///
- /// \code
- /// #pragma omp error severity(fatal)
- /// \endcode
- /// In this example directive '#pragma omp error' has simple
- /// 'severity' clause with kind 'fatal'.
- class OMPSeverityClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('
- SourceLocation LParenLoc;
- /// A kind of the 'severity' clause.
- OpenMPSeverityClauseKind Kind = OMPC_SEVERITY_unknown;
- /// Start location of the kind in source code.
- SourceLocation KindKwLoc;
- /// Set kind of the clause.
- ///
- /// \param K Kind of clause.
- void setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; }
- /// Set clause kind location.
- ///
- /// \param KLoc Kind location.
- void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- public:
- /// Build 'severity' clause with argument \a A ('fatal' or 'warning').
- ///
- /// \param A Argument of the clause ('fatal' or 'warning').
- /// \param ALoc Starting location of the argument.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPSeverityClause(OpenMPSeverityClauseKind A, SourceLocation ALoc,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_severity, StartLoc, EndLoc),
- LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
- /// Build an empty clause.
- OMPSeverityClause()
- : OMPClause(llvm::omp::OMPC_severity, SourceLocation(),
- SourceLocation()) {}
- /// Returns the locaiton of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns kind of the clause.
- OpenMPSeverityClauseKind getSeverityKind() const { return Kind; }
- /// Returns location of clause kind.
- SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_severity;
- }
- };
- /// This represents 'message' clause in the '#pragma omp error' directive
- ///
- /// \code
- /// #pragma omp error message("GNU compiler required.")
- /// \endcode
- /// In this example directive '#pragma omp error' has simple
- /// 'message' clause with user error message of "GNU compiler required.".
- class OMPMessageClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('
- SourceLocation LParenLoc;
- // Expression of the 'message' clause.
- Stmt *MessageString = nullptr;
- /// Set message string of the clause.
- void setMessageString(Expr *MS) { MessageString = MS; }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- public:
- /// Build 'message' clause with message string argument
- ///
- /// \param MS Argument of the clause (message string).
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_message, StartLoc, EndLoc),
- LParenLoc(LParenLoc), MessageString(MS) {}
- /// Build an empty clause.
- OMPMessageClause()
- : OMPClause(llvm::omp::OMPC_message, SourceLocation(), SourceLocation()) {
- }
- /// Returns the locaiton of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns message string of the clause.
- Expr *getMessageString() const { return cast_or_null<Expr>(MessageString); }
- child_range children() {
- return child_range(&MessageString, &MessageString + 1);
- }
- const_child_range children() const {
- return const_child_range(&MessageString, &MessageString + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_message;
- }
- };
- /// This represents 'schedule' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp for schedule(static, 3)
- /// \endcode
- /// In this example directive '#pragma omp for' has 'schedule' clause with
- /// arguments 'static' and '3'.
- class OMPScheduleClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// A kind of the 'schedule' clause.
- OpenMPScheduleClauseKind Kind = OMPC_SCHEDULE_unknown;
- /// Modifiers for 'schedule' clause.
- enum {FIRST, SECOND, NUM_MODIFIERS};
- OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
- /// Locations of modifiers.
- SourceLocation ModifiersLoc[NUM_MODIFIERS];
- /// Start location of the schedule ind in source code.
- SourceLocation KindLoc;
- /// Location of ',' (if any).
- SourceLocation CommaLoc;
- /// Chunk size.
- Expr *ChunkSize = nullptr;
- /// Set schedule kind.
- ///
- /// \param K Schedule kind.
- void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
- /// Set the first schedule modifier.
- ///
- /// \param M Schedule modifier.
- void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
- Modifiers[FIRST] = M;
- }
- /// Set the second schedule modifier.
- ///
- /// \param M Schedule modifier.
- void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
- Modifiers[SECOND] = M;
- }
- /// Set location of the first schedule modifier.
- void setFirstScheduleModifierLoc(SourceLocation Loc) {
- ModifiersLoc[FIRST] = Loc;
- }
- /// Set location of the second schedule modifier.
- void setSecondScheduleModifierLoc(SourceLocation Loc) {
- ModifiersLoc[SECOND] = Loc;
- }
- /// Set schedule modifier location.
- ///
- /// \param M Schedule modifier location.
- void setScheduleModifer(OpenMPScheduleClauseModifier M) {
- if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
- Modifiers[FIRST] = M;
- else {
- assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
- Modifiers[SECOND] = M;
- }
- }
- /// Sets the location of '('.
- ///
- /// \param Loc Location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Set schedule kind start location.
- ///
- /// \param KLoc Schedule kind location.
- void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
- /// Set location of ','.
- ///
- /// \param Loc Location of ','.
- void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
- /// Set chunk size.
- ///
- /// \param E Chunk size.
- void setChunkSize(Expr *E) { ChunkSize = E; }
- public:
- /// Build 'schedule' clause with schedule kind \a Kind and chunk size
- /// expression \a ChunkSize.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param KLoc Starting location of the argument.
- /// \param CommaLoc Location of ','.
- /// \param EndLoc Ending location of the clause.
- /// \param Kind Schedule kind.
- /// \param ChunkSize Chunk size.
- /// \param HelperChunkSize Helper chunk size for combined directives.
- /// \param M1 The first modifier applied to 'schedule' clause.
- /// \param M1Loc Location of the first modifier
- /// \param M2 The second modifier applied to 'schedule' clause.
- /// \param M2Loc Location of the second modifier
- OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation KLoc, SourceLocation CommaLoc,
- SourceLocation EndLoc, OpenMPScheduleClauseKind Kind,
- Expr *ChunkSize, Stmt *HelperChunkSize,
- OpenMPScheduleClauseModifier M1, SourceLocation M1Loc,
- OpenMPScheduleClauseModifier M2, SourceLocation M2Loc)
- : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
- KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
- setPreInitStmt(HelperChunkSize);
- Modifiers[FIRST] = M1;
- Modifiers[SECOND] = M2;
- ModifiersLoc[FIRST] = M1Loc;
- ModifiersLoc[SECOND] = M2Loc;
- }
- /// Build an empty clause.
- explicit OMPScheduleClause()
- : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()),
- OMPClauseWithPreInit(this) {
- Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
- Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
- }
- /// Get kind of the clause.
- OpenMPScheduleClauseKind getScheduleKind() const { return Kind; }
- /// Get the first modifier of the clause.
- OpenMPScheduleClauseModifier getFirstScheduleModifier() const {
- return Modifiers[FIRST];
- }
- /// Get the second modifier of the clause.
- OpenMPScheduleClauseModifier getSecondScheduleModifier() const {
- return Modifiers[SECOND];
- }
- /// Get location of '('.
- SourceLocation getLParenLoc() { return LParenLoc; }
- /// Get kind location.
- SourceLocation getScheduleKindLoc() { return KindLoc; }
- /// Get the first modifier location.
- SourceLocation getFirstScheduleModifierLoc() const {
- return ModifiersLoc[FIRST];
- }
- /// Get the second modifier location.
- SourceLocation getSecondScheduleModifierLoc() const {
- return ModifiersLoc[SECOND];
- }
- /// Get location of ','.
- SourceLocation getCommaLoc() { return CommaLoc; }
- /// Get chunk size.
- Expr *getChunkSize() { return ChunkSize; }
- /// Get chunk size.
- const Expr *getChunkSize() const { return ChunkSize; }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
- reinterpret_cast<Stmt **>(&ChunkSize) + 1);
- }
- const_child_range children() const {
- auto Children = const_cast<OMPScheduleClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_schedule;
- }
- };
- /// This represents 'ordered' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp for ordered (2)
- /// \endcode
- /// In this example directive '#pragma omp for' has 'ordered' clause with
- /// parameter 2.
- class OMPOrderedClause final
- : public OMPClause,
- private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
- friend class OMPClauseReader;
- friend TrailingObjects;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Number of for-loops.
- Stmt *NumForLoops = nullptr;
- /// Real number of loops.
- unsigned NumberOfLoops = 0;
- /// Build 'ordered' clause.
- ///
- /// \param Num Expression, possibly associated with this clause.
- /// \param NumLoops Number of loops, associated with this clause.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc),
- LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {}
- /// Build an empty clause.
- explicit OMPOrderedClause(unsigned NumLoops)
- : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()),
- NumberOfLoops(NumLoops) {}
- /// Set the number of associated for-loops.
- void setNumForLoops(Expr *Num) { NumForLoops = Num; }
- public:
- /// Build 'ordered' clause.
- ///
- /// \param Num Expression, possibly associated with this clause.
- /// \param NumLoops Number of loops, associated with this clause.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
- unsigned NumLoops, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc);
- /// Build an empty clause.
- static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops);
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return the number of associated for-loops.
- Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
- /// Set number of iterations for the specified loop.
- void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
- /// Get number of iterations for all the loops.
- ArrayRef<Expr *> getLoopNumIterations() const;
- /// Set loop counter for the specified loop.
- void setLoopCounter(unsigned NumLoop, Expr *Counter);
- /// Get loops counter for the specified loop.
- Expr *getLoopCounter(unsigned NumLoop);
- const Expr *getLoopCounter(unsigned NumLoop) const;
- child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
- const_child_range children() const {
- return const_child_range(&NumForLoops, &NumForLoops + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_ordered;
- }
- };
- /// This represents 'nowait' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp for nowait
- /// \endcode
- /// In this example directive '#pragma omp for' has 'nowait' clause.
- class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> {
- public:
- /// Build 'nowait' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPNowaitClause(SourceLocation StartLoc = SourceLocation(),
- SourceLocation EndLoc = SourceLocation())
- : OMPNoChildClause(StartLoc, EndLoc) {}
- };
- /// This represents 'untied' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp task untied
- /// \endcode
- /// In this example directive '#pragma omp task' has 'untied' clause.
- class OMPUntiedClause : public OMPClause {
- public:
- /// Build 'untied' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPUntiedClause()
- : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_untied;
- }
- };
- /// This represents 'mergeable' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp task mergeable
- /// \endcode
- /// In this example directive '#pragma omp task' has 'mergeable' clause.
- class OMPMergeableClause : public OMPClause {
- public:
- /// Build 'mergeable' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPMergeableClause()
- : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(),
- SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_mergeable;
- }
- };
- /// This represents 'read' clause in the '#pragma omp atomic' directive.
- ///
- /// \code
- /// #pragma omp atomic read
- /// \endcode
- /// In this example directive '#pragma omp atomic' has 'read' clause.
- class OMPReadClause : public OMPClause {
- public:
- /// Build 'read' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPReadClause()
- : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_read;
- }
- };
- /// This represents 'write' clause in the '#pragma omp atomic' directive.
- ///
- /// \code
- /// #pragma omp atomic write
- /// \endcode
- /// In this example directive '#pragma omp atomic' has 'write' clause.
- class OMPWriteClause : public OMPClause {
- public:
- /// Build 'write' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPWriteClause()
- : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_write;
- }
- };
- /// This represents 'update' clause in the '#pragma omp atomic'
- /// directive.
- ///
- /// \code
- /// #pragma omp atomic update
- /// \endcode
- /// In this example directive '#pragma omp atomic' has 'update' clause.
- /// Also, this class represents 'update' clause in '#pragma omp depobj'
- /// directive.
- ///
- /// \code
- /// #pragma omp depobj(a) update(in)
- /// \endcode
- /// In this example directive '#pragma omp depobj' has 'update' clause with 'in'
- /// dependence kind.
- class OMPUpdateClause final
- : public OMPClause,
- private llvm::TrailingObjects<OMPUpdateClause, SourceLocation,
- OpenMPDependClauseKind> {
- friend class OMPClauseReader;
- friend TrailingObjects;
- /// true if extended version of the clause for 'depobj' directive.
- bool IsExtended = false;
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<SourceLocation>) const {
- // 2 locations: for '(' and argument location.
- return IsExtended ? 2 : 0;
- }
- /// Sets the location of '(' in clause for 'depobj' directive.
- void setLParenLoc(SourceLocation Loc) {
- assert(IsExtended && "Expected extended clause.");
- *getTrailingObjects<SourceLocation>() = Loc;
- }
- /// Sets the location of '(' in clause for 'depobj' directive.
- void setArgumentLoc(SourceLocation Loc) {
- assert(IsExtended && "Expected extended clause.");
- *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc;
- }
- /// Sets the dependence kind for the clause for 'depobj' directive.
- void setDependencyKind(OpenMPDependClauseKind DK) {
- assert(IsExtended && "Expected extended clause.");
- *getTrailingObjects<OpenMPDependClauseKind>() = DK;
- }
- /// Build 'update' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc,
- bool IsExtended)
- : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc),
- IsExtended(IsExtended) {}
- /// Build an empty clause.
- OMPUpdateClause(bool IsExtended)
- : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()),
- IsExtended(IsExtended) {}
- public:
- /// Creates clause for 'atomic' directive.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation EndLoc);
- /// Creates clause for 'depobj' directive.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ArgumentLoc Location of the argument.
- /// \param DK Dependence kind.
- /// \param EndLoc Ending location of the clause.
- static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation ArgumentLoc,
- OpenMPDependClauseKind DK,
- SourceLocation EndLoc);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param IsExtended true if extended clause for 'depobj' directive must be
- /// created.
- static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended);
- /// Checks if the clause is the extended clauses for 'depobj' directive.
- bool isExtended() const { return IsExtended; }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- /// Gets the location of '(' in clause for 'depobj' directive.
- SourceLocation getLParenLoc() const {
- assert(IsExtended && "Expected extended clause.");
- return *getTrailingObjects<SourceLocation>();
- }
- /// Gets the location of argument in clause for 'depobj' directive.
- SourceLocation getArgumentLoc() const {
- assert(IsExtended && "Expected extended clause.");
- return *std::next(getTrailingObjects<SourceLocation>(), 1);
- }
- /// Gets the dependence kind in clause for 'depobj' directive.
- OpenMPDependClauseKind getDependencyKind() const {
- assert(IsExtended && "Expected extended clause.");
- return *getTrailingObjects<OpenMPDependClauseKind>();
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_update;
- }
- };
- /// This represents 'capture' clause in the '#pragma omp atomic'
- /// directive.
- ///
- /// \code
- /// #pragma omp atomic capture
- /// \endcode
- /// In this example directive '#pragma omp atomic' has 'capture' clause.
- class OMPCaptureClause : public OMPClause {
- public:
- /// Build 'capture' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPCaptureClause()
- : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_capture;
- }
- };
- /// This represents 'compare' clause in the '#pragma omp atomic'
- /// directive.
- ///
- /// \code
- /// #pragma omp atomic compare
- /// \endcode
- /// In this example directive '#pragma omp atomic' has 'compare' clause.
- class OMPCompareClause final : public OMPClause {
- public:
- /// Build 'compare' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPCompareClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPCompareClause()
- : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_compare;
- }
- };
- /// This represents 'seq_cst' clause in the '#pragma omp atomic'
- /// directive.
- ///
- /// \code
- /// #pragma omp atomic seq_cst
- /// \endcode
- /// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
- class OMPSeqCstClause : public OMPClause {
- public:
- /// Build 'seq_cst' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPSeqCstClause()
- : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_seq_cst;
- }
- };
- /// This represents 'acq_rel' clause in the '#pragma omp atomic|flush'
- /// directives.
- ///
- /// \code
- /// #pragma omp flush acq_rel
- /// \endcode
- /// In this example directive '#pragma omp flush' has 'acq_rel' clause.
- class OMPAcqRelClause final : public OMPClause {
- public:
- /// Build 'ack_rel' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPAcqRelClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPAcqRelClause()
- : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_acq_rel;
- }
- };
- /// This represents 'acquire' clause in the '#pragma omp atomic|flush'
- /// directives.
- ///
- /// \code
- /// #pragma omp flush acquire
- /// \endcode
- /// In this example directive '#pragma omp flush' has 'acquire' clause.
- class OMPAcquireClause final : public OMPClause {
- public:
- /// Build 'acquire' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPAcquireClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPAcquireClause()
- : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_acquire;
- }
- };
- /// This represents 'release' clause in the '#pragma omp atomic|flush'
- /// directives.
- ///
- /// \code
- /// #pragma omp flush release
- /// \endcode
- /// In this example directive '#pragma omp flush' has 'release' clause.
- class OMPReleaseClause final : public OMPClause {
- public:
- /// Build 'release' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPReleaseClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPReleaseClause()
- : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_release;
- }
- };
- /// This represents 'relaxed' clause in the '#pragma omp atomic'
- /// directives.
- ///
- /// \code
- /// #pragma omp atomic relaxed
- /// \endcode
- /// In this example directive '#pragma omp atomic' has 'relaxed' clause.
- class OMPRelaxedClause final : public OMPClause {
- public:
- /// Build 'relaxed' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPRelaxedClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPRelaxedClause()
- : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_relaxed;
- }
- };
- /// This represents clause 'private' in the '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp parallel private(a,b)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has clause 'private'
- /// with the variables 'a' and 'b'.
- class OMPPrivateClause final
- : public OMPVarListClause<OMPPrivateClause>,
- private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc,
- LParenLoc, EndLoc, N) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPPrivateClause(unsigned N)
- : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- /// Sets the list of references to private copies with initializers for
- /// new private variables.
- /// \param VL List of references.
- void setPrivateCopies(ArrayRef<Expr *> VL);
- /// Gets the list of references to private copies with initializers for
- /// new private variables.
- MutableArrayRef<Expr *> getPrivateCopies() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivateCopies() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- /// \param PrivateVL List of references to private copies with initializers.
- static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL,
- ArrayRef<Expr *> PrivateVL);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
- using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
- using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
- using private_copies_range = llvm::iterator_range<private_copies_iterator>;
- using private_copies_const_range =
- llvm::iterator_range<private_copies_const_iterator>;
- private_copies_range private_copies() {
- return private_copies_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- private_copies_const_range private_copies() const {
- return private_copies_const_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPPrivateClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_private;
- }
- };
- /// This represents clause 'firstprivate' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp parallel firstprivate(a,b)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has clause 'firstprivate'
- /// with the variables 'a' and 'b'.
- class OMPFirstprivateClause final
- : public OMPVarListClause<OMPFirstprivateClause>,
- public OMPClauseWithPreInit,
- private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate,
- StartLoc, LParenLoc, EndLoc, N),
- OMPClauseWithPreInit(this) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPFirstprivateClause(unsigned N)
- : OMPVarListClause<OMPFirstprivateClause>(
- llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(),
- SourceLocation(), N),
- OMPClauseWithPreInit(this) {}
- /// Sets the list of references to private copies with initializers for
- /// new private variables.
- /// \param VL List of references.
- void setPrivateCopies(ArrayRef<Expr *> VL);
- /// Gets the list of references to private copies with initializers for
- /// new private variables.
- MutableArrayRef<Expr *> getPrivateCopies() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivateCopies() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Sets the list of references to initializer variables for new
- /// private variables.
- /// \param VL List of references.
- void setInits(ArrayRef<Expr *> VL);
- /// Gets the list of references to initializer variables for new
- /// private variables.
- MutableArrayRef<Expr *> getInits() {
- return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
- }
- ArrayRef<const Expr *> getInits() const {
- return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the original variables.
- /// \param PrivateVL List of references to private copies with initializers.
- /// \param InitVL List of references to auto generated variables used for
- /// initialization of a single array element. Used if firstprivate variable is
- /// of array type.
- /// \param PreInit Statement that must be executed before entering the OpenMP
- /// region with this clause.
- static OMPFirstprivateClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
- ArrayRef<Expr *> InitVL, Stmt *PreInit);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
- using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
- using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
- using private_copies_range = llvm::iterator_range<private_copies_iterator>;
- using private_copies_const_range =
- llvm::iterator_range<private_copies_const_iterator>;
- private_copies_range private_copies() {
- return private_copies_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- private_copies_const_range private_copies() const {
- return private_copies_const_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- using inits_iterator = MutableArrayRef<Expr *>::iterator;
- using inits_const_iterator = ArrayRef<const Expr *>::iterator;
- using inits_range = llvm::iterator_range<inits_iterator>;
- using inits_const_range = llvm::iterator_range<inits_const_iterator>;
- inits_range inits() {
- return inits_range(getInits().begin(), getInits().end());
- }
- inits_const_range inits() const {
- return inits_const_range(getInits().begin(), getInits().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPFirstprivateClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range used_children() const {
- auto Children = const_cast<OMPFirstprivateClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_firstprivate;
- }
- };
- /// This represents clause 'lastprivate' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp simd lastprivate(a,b)
- /// \endcode
- /// In this example directive '#pragma omp simd' has clause 'lastprivate'
- /// with the variables 'a' and 'b'.
- class OMPLastprivateClause final
- : public OMPVarListClause<OMPLastprivateClause>,
- public OMPClauseWithPostUpdate,
- private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
- // There are 4 additional tail-allocated arrays at the end of the class:
- // 1. Contains list of pseudo variables with the default initialization for
- // each non-firstprivate variables. Used in codegen for initialization of
- // lastprivate copies.
- // 2. List of helper expressions for proper generation of assignment operation
- // required for lastprivate clause. This list represents private variables
- // (for arrays, single array element).
- // 3. List of helper expressions for proper generation of assignment operation
- // required for lastprivate clause. This list represents original variables
- // (for arrays, single array element).
- // 4. List of helper expressions that represents assignment operation:
- // \code
- // DstExprs = SrcExprs;
- // \endcode
- // Required for proper codegen of final assignment performed by the
- // lastprivate clause.
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
- OpenMPLastprivateModifier LPKind;
- /// Optional location of the lasptrivate kind, if specified by user.
- SourceLocation LPKindLoc;
- /// Optional colon location, if specified by user.
- SourceLocation ColonLoc;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, OpenMPLastprivateModifier LPKind,
- SourceLocation LPKindLoc, SourceLocation ColonLoc,
- unsigned N)
- : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate,
- StartLoc, LParenLoc, EndLoc, N),
- OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
- ColonLoc(ColonLoc) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPLastprivateClause(unsigned N)
- : OMPVarListClause<OMPLastprivateClause>(
- llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(),
- SourceLocation(), N),
- OMPClauseWithPostUpdate(this) {}
- /// Get the list of helper expressions for initialization of private
- /// copies for lastprivate variables.
- MutableArrayRef<Expr *> getPrivateCopies() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivateCopies() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent private variables (for arrays, single
- /// array element) in the final assignment statement performed by the
- /// lastprivate clause.
- void setSourceExprs(ArrayRef<Expr *> SrcExprs);
- /// Get the list of helper source expressions.
- MutableArrayRef<Expr *> getSourceExprs() {
- return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
- }
- ArrayRef<const Expr *> getSourceExprs() const {
- return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent original variables (for arrays, single
- /// array element) in the final assignment statement performed by the
- /// lastprivate clause.
- void setDestinationExprs(ArrayRef<Expr *> DstExprs);
- /// Get the list of helper destination expressions.
- MutableArrayRef<Expr *> getDestinationExprs() {
- return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getDestinationExprs() const {
- return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
- }
- /// Set list of helper assignment expressions, required for proper
- /// codegen of the clause. These expressions are assignment expressions that
- /// assign private copy of the variable to original variable.
- void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
- /// Get the list of helper assignment expressions.
- MutableArrayRef<Expr *> getAssignmentOps() {
- return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getAssignmentOps() const {
- return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
- }
- /// Sets lastprivate kind.
- void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
- /// Sets location of the lastprivate kind.
- void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
- /// Sets colon symbol location.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- /// \param SrcExprs List of helper expressions for proper generation of
- /// assignment operation required for lastprivate clause. This list represents
- /// private variables (for arrays, single array element).
- /// \param DstExprs List of helper expressions for proper generation of
- /// assignment operation required for lastprivate clause. This list represents
- /// original variables (for arrays, single array element).
- /// \param AssignmentOps List of helper expressions that represents assignment
- /// operation:
- /// \code
- /// DstExprs = SrcExprs;
- /// \endcode
- /// Required for proper codegen of final assignment performed by the
- /// lastprivate clause.
- /// \param LPKind Lastprivate kind, e.g. 'conditional'.
- /// \param LPKindLoc Location of the lastprivate kind.
- /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
- /// \param PreInit Statement that must be executed before entering the OpenMP
- /// region with this clause.
- /// \param PostUpdate Expression that must be executed after exit from the
- /// OpenMP region with this clause.
- static OMPLastprivateClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
- ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
- OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
- SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
- /// Lastprivate kind.
- OpenMPLastprivateModifier getKind() const { return LPKind; }
- /// Returns the location of the lastprivate kind.
- SourceLocation getKindLoc() const { return LPKindLoc; }
- /// Returns the location of the ':' symbol, if any.
- SourceLocation getColonLoc() const { return ColonLoc; }
- using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
- using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
- using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
- using helper_expr_const_range =
- llvm::iterator_range<helper_expr_const_iterator>;
- /// Set list of helper expressions, required for generation of private
- /// copies of original lastprivate variables.
- void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
- helper_expr_const_range private_copies() const {
- return helper_expr_const_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- helper_expr_range private_copies() {
- return helper_expr_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- helper_expr_const_range source_exprs() const {
- return helper_expr_const_range(getSourceExprs().begin(),
- getSourceExprs().end());
- }
- helper_expr_range source_exprs() {
- return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
- }
- helper_expr_const_range destination_exprs() const {
- return helper_expr_const_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
- helper_expr_range destination_exprs() {
- return helper_expr_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
- helper_expr_const_range assignment_ops() const {
- return helper_expr_const_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
- helper_expr_range assignment_ops() {
- return helper_expr_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPLastprivateClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_lastprivate;
- }
- };
- /// This represents clause 'shared' in the '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp parallel shared(a,b)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has clause 'shared'
- /// with the variables 'a' and 'b'.
- class OMPSharedClause final
- : public OMPVarListClause<OMPSharedClause>,
- private llvm::TrailingObjects<OMPSharedClause, Expr *> {
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc,
- LParenLoc, EndLoc, N) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPSharedClause(unsigned N)
- : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL);
- /// Creates an empty clause with \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPSharedClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_shared;
- }
- };
- /// This represents clause 'reduction' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp parallel reduction(+:a,b)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has clause 'reduction'
- /// with operator '+' and the variables 'a' and 'b'.
- class OMPReductionClause final
- : public OMPVarListClause<OMPReductionClause>,
- public OMPClauseWithPostUpdate,
- private llvm::TrailingObjects<OMPReductionClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Reduction modifier.
- OpenMPReductionClauseModifier Modifier = OMPC_REDUCTION_unknown;
- /// Reduction modifier location.
- SourceLocation ModifierLoc;
- /// Location of ':'.
- SourceLocation ColonLoc;
- /// Nested name specifier for C++.
- NestedNameSpecifierLoc QualifierLoc;
- /// Name of custom operator.
- DeclarationNameInfo NameInfo;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ModifierLoc Modifier location.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- /// \param QualifierLoc The nested-name qualifier with location information
- /// \param NameInfo The full name info for reduction identifier.
- OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ModifierLoc, SourceLocation ColonLoc,
- SourceLocation EndLoc,
- OpenMPReductionClauseModifier Modifier, unsigned N,
- NestedNameSpecifierLoc QualifierLoc,
- const DeclarationNameInfo &NameInfo)
- : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
- StartLoc, LParenLoc, EndLoc, N),
- OMPClauseWithPostUpdate(this), Modifier(Modifier),
- ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
- QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPReductionClause(unsigned N)
- : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N),
- OMPClauseWithPostUpdate(this) {}
- /// Sets reduction modifier.
- void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
- /// Sets location of the modifier.
- void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
- /// Sets location of ':' symbol in clause.
- void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
- /// Sets the name info for specified reduction identifier.
- void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
- /// Sets the nested name specifier.
- void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent private copy of the reduction
- /// variable.
- void setPrivates(ArrayRef<Expr *> Privates);
- /// Get the list of helper privates.
- MutableArrayRef<Expr *> getPrivates() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivates() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent LHS expression in the final
- /// reduction expression performed by the reduction clause.
- void setLHSExprs(ArrayRef<Expr *> LHSExprs);
- /// Get the list of helper LHS expressions.
- MutableArrayRef<Expr *> getLHSExprs() {
- return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
- }
- ArrayRef<const Expr *> getLHSExprs() const {
- return llvm::ArrayRef(getPrivates().end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent RHS expression in the final
- /// reduction expression performed by the reduction clause.
- /// Also, variables in these expressions are used for proper initialization of
- /// reduction copies.
- void setRHSExprs(ArrayRef<Expr *> RHSExprs);
- /// Get the list of helper destination expressions.
- MutableArrayRef<Expr *> getRHSExprs() {
- return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getRHSExprs() const {
- return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
- }
- /// Set list of helper reduction expressions, required for proper
- /// codegen of the clause. These expressions are binary expressions or
- /// operator/custom reduction call that calculates new value from source
- /// helper expressions to destination helper expressions.
- void setReductionOps(ArrayRef<Expr *> ReductionOps);
- /// Get the list of helper reduction expressions.
- MutableArrayRef<Expr *> getReductionOps() {
- return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getReductionOps() const {
- return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
- }
- /// Set list of helper copy operations for inscan reductions.
- /// The form is: Temps[i] = LHS[i];
- void setInscanCopyOps(ArrayRef<Expr *> Ops);
- /// Get the list of helper inscan copy operations.
- MutableArrayRef<Expr *> getInscanCopyOps() {
- return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
- }
- ArrayRef<const Expr *> getInscanCopyOps() const {
- return llvm::ArrayRef(getReductionOps().end(), varlist_size());
- }
- /// Set list of helper temp vars for inscan copy array operations.
- void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps);
- /// Get the list of helper inscan copy temps.
- MutableArrayRef<Expr *> getInscanCopyArrayTemps() {
- return MutableArrayRef<Expr *>(getInscanCopyOps().end(), varlist_size());
- }
- ArrayRef<const Expr *> getInscanCopyArrayTemps() const {
- return llvm::ArrayRef(getInscanCopyOps().end(), varlist_size());
- }
- /// Set list of helper temp elements vars for inscan copy array operations.
- void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems);
- /// Get the list of helper inscan copy temps.
- MutableArrayRef<Expr *> getInscanCopyArrayElems() {
- return MutableArrayRef<Expr *>(getInscanCopyArrayTemps().end(),
- varlist_size());
- }
- ArrayRef<const Expr *> getInscanCopyArrayElems() const {
- return llvm::ArrayRef(getInscanCopyArrayTemps().end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ModifierLoc Modifier location.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param VL The variables in the clause.
- /// \param QualifierLoc The nested-name qualifier with location information
- /// \param NameInfo The full name info for reduction identifier.
- /// \param Privates List of helper expressions for proper generation of
- /// private copies.
- /// \param LHSExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// LHSs of the reduction expressions.
- /// \param RHSExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// RHSs of the reduction expressions.
- /// Also, variables in these expressions are used for proper initialization of
- /// reduction copies.
- /// \param ReductionOps List of helper expressions that represents reduction
- /// expressions:
- /// \code
- /// LHSExprs binop RHSExprs;
- /// operator binop(LHSExpr, RHSExpr);
- /// <CutomReduction>(LHSExpr, RHSExpr);
- /// \endcode
- /// Required for proper codegen of final reduction operation performed by the
- /// reduction clause.
- /// \param CopyOps List of copy operations for inscan reductions:
- /// \code
- /// TempExprs = LHSExprs;
- /// \endcode
- /// \param CopyArrayTemps Temp arrays for prefix sums.
- /// \param CopyArrayElems Temp arrays for prefix sums.
- /// \param PreInit Statement that must be executed before entering the OpenMP
- /// region with this clause.
- /// \param PostUpdate Expression that must be executed after exit from the
- /// OpenMP region with this clause.
- static OMPReductionClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ModifierLoc, SourceLocation ColonLoc,
- SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
- ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
- const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
- ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
- ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
- ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
- Stmt *PreInit, Expr *PostUpdate);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- /// \param Modifier Reduction modifier.
- static OMPReductionClause *
- CreateEmpty(const ASTContext &C, unsigned N,
- OpenMPReductionClauseModifier Modifier);
- /// Returns modifier.
- OpenMPReductionClauseModifier getModifier() const { return Modifier; }
- /// Returns modifier location.
- SourceLocation getModifierLoc() const { return ModifierLoc; }
- /// Gets location of ':' symbol in clause.
- SourceLocation getColonLoc() const { return ColonLoc; }
- /// Gets the name info for specified reduction identifier.
- const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
- /// Gets the nested name specifier.
- NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
- using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
- using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
- using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
- using helper_expr_const_range =
- llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range privates() const {
- return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
- }
- helper_expr_range privates() {
- return helper_expr_range(getPrivates().begin(), getPrivates().end());
- }
- helper_expr_const_range lhs_exprs() const {
- return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
- }
- helper_expr_range lhs_exprs() {
- return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
- }
- helper_expr_const_range rhs_exprs() const {
- return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
- }
- helper_expr_range rhs_exprs() {
- return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
- }
- helper_expr_const_range reduction_ops() const {
- return helper_expr_const_range(getReductionOps().begin(),
- getReductionOps().end());
- }
- helper_expr_range reduction_ops() {
- return helper_expr_range(getReductionOps().begin(),
- getReductionOps().end());
- }
- helper_expr_const_range copy_ops() const {
- return helper_expr_const_range(getInscanCopyOps().begin(),
- getInscanCopyOps().end());
- }
- helper_expr_range copy_ops() {
- return helper_expr_range(getInscanCopyOps().begin(),
- getInscanCopyOps().end());
- }
- helper_expr_const_range copy_array_temps() const {
- return helper_expr_const_range(getInscanCopyArrayTemps().begin(),
- getInscanCopyArrayTemps().end());
- }
- helper_expr_range copy_array_temps() {
- return helper_expr_range(getInscanCopyArrayTemps().begin(),
- getInscanCopyArrayTemps().end());
- }
- helper_expr_const_range copy_array_elems() const {
- return helper_expr_const_range(getInscanCopyArrayElems().begin(),
- getInscanCopyArrayElems().end());
- }
- helper_expr_range copy_array_elems() {
- return helper_expr_range(getInscanCopyArrayElems().begin(),
- getInscanCopyArrayElems().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPReductionClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range used_children() const {
- auto Children = const_cast<OMPReductionClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_reduction;
- }
- };
- /// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
- /// directives.
- ///
- /// \code
- /// #pragma omp taskgroup task_reduction(+:a,b)
- /// \endcode
- /// In this example directive '#pragma omp taskgroup' has clause
- /// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
- class OMPTaskReductionClause final
- : public OMPVarListClause<OMPTaskReductionClause>,
- public OMPClauseWithPostUpdate,
- private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Location of ':'.
- SourceLocation ColonLoc;
- /// Nested name specifier for C++.
- NestedNameSpecifierLoc QualifierLoc;
- /// Name of custom operator.
- DeclarationNameInfo NameInfo;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param ColonLoc Location of ':'.
- /// \param N Number of the variables in the clause.
- /// \param QualifierLoc The nested-name qualifier with location information
- /// \param NameInfo The full name info for reduction identifier.
- OMPTaskReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc,
- unsigned N, NestedNameSpecifierLoc QualifierLoc,
- const DeclarationNameInfo &NameInfo)
- : OMPVarListClause<OMPTaskReductionClause>(
- llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N),
- OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
- QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPTaskReductionClause(unsigned N)
- : OMPVarListClause<OMPTaskReductionClause>(
- llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(),
- SourceLocation(), N),
- OMPClauseWithPostUpdate(this) {}
- /// Sets location of ':' symbol in clause.
- void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
- /// Sets the name info for specified reduction identifier.
- void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
- /// Sets the nested name specifier.
- void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
- /// Set list of helper expressions, required for proper codegen of the clause.
- /// These expressions represent private copy of the reduction variable.
- void setPrivates(ArrayRef<Expr *> Privates);
- /// Get the list of helper privates.
- MutableArrayRef<Expr *> getPrivates() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivates() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the clause.
- /// These expressions represent LHS expression in the final reduction
- /// expression performed by the reduction clause.
- void setLHSExprs(ArrayRef<Expr *> LHSExprs);
- /// Get the list of helper LHS expressions.
- MutableArrayRef<Expr *> getLHSExprs() {
- return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
- }
- ArrayRef<const Expr *> getLHSExprs() const {
- return llvm::ArrayRef(getPrivates().end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the clause.
- /// These expressions represent RHS expression in the final reduction
- /// expression performed by the reduction clause. Also, variables in these
- /// expressions are used for proper initialization of reduction copies.
- void setRHSExprs(ArrayRef<Expr *> RHSExprs);
- /// Get the list of helper destination expressions.
- MutableArrayRef<Expr *> getRHSExprs() {
- return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getRHSExprs() const {
- return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
- }
- /// Set list of helper reduction expressions, required for proper
- /// codegen of the clause. These expressions are binary expressions or
- /// operator/custom reduction call that calculates new value from source
- /// helper expressions to destination helper expressions.
- void setReductionOps(ArrayRef<Expr *> ReductionOps);
- /// Get the list of helper reduction expressions.
- MutableArrayRef<Expr *> getReductionOps() {
- return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getReductionOps() const {
- return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param VL The variables in the clause.
- /// \param QualifierLoc The nested-name qualifier with location information
- /// \param NameInfo The full name info for reduction identifier.
- /// \param Privates List of helper expressions for proper generation of
- /// private copies.
- /// \param LHSExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// LHSs of the reduction expressions.
- /// \param RHSExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// RHSs of the reduction expressions.
- /// Also, variables in these expressions are used for proper initialization of
- /// reduction copies.
- /// \param ReductionOps List of helper expressions that represents reduction
- /// expressions:
- /// \code
- /// LHSExprs binop RHSExprs;
- /// operator binop(LHSExpr, RHSExpr);
- /// <CutomReduction>(LHSExpr, RHSExpr);
- /// \endcode
- /// Required for proper codegen of final reduction operation performed by the
- /// reduction clause.
- /// \param PreInit Statement that must be executed before entering the OpenMP
- /// region with this clause.
- /// \param PostUpdate Expression that must be executed after exit from the
- /// OpenMP region with this clause.
- static OMPTaskReductionClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
- NestedNameSpecifierLoc QualifierLoc,
- const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
- ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
- ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
- /// Gets location of ':' symbol in clause.
- SourceLocation getColonLoc() const { return ColonLoc; }
- /// Gets the name info for specified reduction identifier.
- const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
- /// Gets the nested name specifier.
- NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
- using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
- using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
- using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
- using helper_expr_const_range =
- llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range privates() const {
- return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
- }
- helper_expr_range privates() {
- return helper_expr_range(getPrivates().begin(), getPrivates().end());
- }
- helper_expr_const_range lhs_exprs() const {
- return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
- }
- helper_expr_range lhs_exprs() {
- return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
- }
- helper_expr_const_range rhs_exprs() const {
- return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
- }
- helper_expr_range rhs_exprs() {
- return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
- }
- helper_expr_const_range reduction_ops() const {
- return helper_expr_const_range(getReductionOps().begin(),
- getReductionOps().end());
- }
- helper_expr_range reduction_ops() {
- return helper_expr_range(getReductionOps().begin(),
- getReductionOps().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPTaskReductionClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_task_reduction;
- }
- };
- /// This represents clause 'in_reduction' in the '#pragma omp task' directives.
- ///
- /// \code
- /// #pragma omp task in_reduction(+:a,b)
- /// \endcode
- /// In this example directive '#pragma omp task' has clause 'in_reduction' with
- /// operator '+' and the variables 'a' and 'b'.
- class OMPInReductionClause final
- : public OMPVarListClause<OMPInReductionClause>,
- public OMPClauseWithPostUpdate,
- private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Location of ':'.
- SourceLocation ColonLoc;
- /// Nested name specifier for C++.
- NestedNameSpecifierLoc QualifierLoc;
- /// Name of custom operator.
- DeclarationNameInfo NameInfo;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param ColonLoc Location of ':'.
- /// \param N Number of the variables in the clause.
- /// \param QualifierLoc The nested-name qualifier with location information
- /// \param NameInfo The full name info for reduction identifier.
- OMPInReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc,
- unsigned N, NestedNameSpecifierLoc QualifierLoc,
- const DeclarationNameInfo &NameInfo)
- : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction,
- StartLoc, LParenLoc, EndLoc, N),
- OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
- QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPInReductionClause(unsigned N)
- : OMPVarListClause<OMPInReductionClause>(
- llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(),
- SourceLocation(), N),
- OMPClauseWithPostUpdate(this) {}
- /// Sets location of ':' symbol in clause.
- void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
- /// Sets the name info for specified reduction identifier.
- void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
- /// Sets the nested name specifier.
- void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
- /// Set list of helper expressions, required for proper codegen of the clause.
- /// These expressions represent private copy of the reduction variable.
- void setPrivates(ArrayRef<Expr *> Privates);
- /// Get the list of helper privates.
- MutableArrayRef<Expr *> getPrivates() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivates() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the clause.
- /// These expressions represent LHS expression in the final reduction
- /// expression performed by the reduction clause.
- void setLHSExprs(ArrayRef<Expr *> LHSExprs);
- /// Get the list of helper LHS expressions.
- MutableArrayRef<Expr *> getLHSExprs() {
- return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
- }
- ArrayRef<const Expr *> getLHSExprs() const {
- return llvm::ArrayRef(getPrivates().end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the clause.
- /// These expressions represent RHS expression in the final reduction
- /// expression performed by the reduction clause. Also, variables in these
- /// expressions are used for proper initialization of reduction copies.
- void setRHSExprs(ArrayRef<Expr *> RHSExprs);
- /// Get the list of helper destination expressions.
- MutableArrayRef<Expr *> getRHSExprs() {
- return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getRHSExprs() const {
- return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
- }
- /// Set list of helper reduction expressions, required for proper
- /// codegen of the clause. These expressions are binary expressions or
- /// operator/custom reduction call that calculates new value from source
- /// helper expressions to destination helper expressions.
- void setReductionOps(ArrayRef<Expr *> ReductionOps);
- /// Get the list of helper reduction expressions.
- MutableArrayRef<Expr *> getReductionOps() {
- return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getReductionOps() const {
- return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
- }
- /// Set list of helper reduction taskgroup descriptors.
- void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
- /// Get the list of helper reduction taskgroup descriptors.
- MutableArrayRef<Expr *> getTaskgroupDescriptors() {
- return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
- }
- ArrayRef<const Expr *> getTaskgroupDescriptors() const {
- return llvm::ArrayRef(getReductionOps().end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param VL The variables in the clause.
- /// \param QualifierLoc The nested-name qualifier with location information
- /// \param NameInfo The full name info for reduction identifier.
- /// \param Privates List of helper expressions for proper generation of
- /// private copies.
- /// \param LHSExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// LHSs of the reduction expressions.
- /// \param RHSExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// RHSs of the reduction expressions.
- /// Also, variables in these expressions are used for proper initialization of
- /// reduction copies.
- /// \param ReductionOps List of helper expressions that represents reduction
- /// expressions:
- /// \code
- /// LHSExprs binop RHSExprs;
- /// operator binop(LHSExpr, RHSExpr);
- /// <CutomReduction>(LHSExpr, RHSExpr);
- /// \endcode
- /// Required for proper codegen of final reduction operation performed by the
- /// reduction clause.
- /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
- /// corresponding items in parent taskgroup task_reduction clause.
- /// \param PreInit Statement that must be executed before entering the OpenMP
- /// region with this clause.
- /// \param PostUpdate Expression that must be executed after exit from the
- /// OpenMP region with this clause.
- static OMPInReductionClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
- NestedNameSpecifierLoc QualifierLoc,
- const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
- ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
- ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors,
- Stmt *PreInit, Expr *PostUpdate);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
- /// Gets location of ':' symbol in clause.
- SourceLocation getColonLoc() const { return ColonLoc; }
- /// Gets the name info for specified reduction identifier.
- const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
- /// Gets the nested name specifier.
- NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
- using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
- using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
- using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
- using helper_expr_const_range =
- llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range privates() const {
- return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
- }
- helper_expr_range privates() {
- return helper_expr_range(getPrivates().begin(), getPrivates().end());
- }
- helper_expr_const_range lhs_exprs() const {
- return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
- }
- helper_expr_range lhs_exprs() {
- return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
- }
- helper_expr_const_range rhs_exprs() const {
- return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
- }
- helper_expr_range rhs_exprs() {
- return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
- }
- helper_expr_const_range reduction_ops() const {
- return helper_expr_const_range(getReductionOps().begin(),
- getReductionOps().end());
- }
- helper_expr_range reduction_ops() {
- return helper_expr_range(getReductionOps().begin(),
- getReductionOps().end());
- }
- helper_expr_const_range taskgroup_descriptors() const {
- return helper_expr_const_range(getTaskgroupDescriptors().begin(),
- getTaskgroupDescriptors().end());
- }
- helper_expr_range taskgroup_descriptors() {
- return helper_expr_range(getTaskgroupDescriptors().begin(),
- getTaskgroupDescriptors().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPInReductionClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_in_reduction;
- }
- };
- /// This represents clause 'linear' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp simd linear(a,b : 2)
- /// \endcode
- /// In this example directive '#pragma omp simd' has clause 'linear'
- /// with variables 'a', 'b' and linear step '2'.
- class OMPLinearClause final
- : public OMPVarListClause<OMPLinearClause>,
- public OMPClauseWithPostUpdate,
- private llvm::TrailingObjects<OMPLinearClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Modifier of 'linear' clause.
- OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
- /// Location of linear modifier if any.
- SourceLocation ModifierLoc;
- /// Location of ':'.
- SourceLocation ColonLoc;
- /// Sets the linear step for clause.
- void setStep(Expr *Step) { *(getFinals().end()) = Step; }
- /// Sets the expression to calculate linear step for clause.
- void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
- /// Build 'linear' clause with given number of variables \a NumVars.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param NumVars Number of variables.
- OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc,
- unsigned NumVars)
- : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc,
- LParenLoc, EndLoc, NumVars),
- OMPClauseWithPostUpdate(this), Modifier(Modifier),
- ModifierLoc(ModifierLoc), ColonLoc(ColonLoc) {}
- /// Build an empty clause.
- ///
- /// \param NumVars Number of variables.
- explicit OMPLinearClause(unsigned NumVars)
- : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear,
- SourceLocation(), SourceLocation(),
- SourceLocation(), NumVars),
- OMPClauseWithPostUpdate(this) {}
- /// Gets the list of initial values for linear variables.
- ///
- /// There are NumVars expressions with initial values allocated after the
- /// varlist, they are followed by NumVars update expressions (used to update
- /// the linear variable's value on current iteration) and they are followed by
- /// NumVars final expressions (used to calculate the linear variable's
- /// value after the loop body). After these lists, there are 2 helper
- /// expressions - linear step and a helper to calculate it before the
- /// loop body (used when the linear step is not constant):
- ///
- /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
- /// Finals[]; Step; CalcStep; }
- MutableArrayRef<Expr *> getPrivates() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivates() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- MutableArrayRef<Expr *> getInits() {
- return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
- }
- ArrayRef<const Expr *> getInits() const {
- return llvm::ArrayRef(getPrivates().end(), varlist_size());
- }
- /// Sets the list of update expressions for linear variables.
- MutableArrayRef<Expr *> getUpdates() {
- return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
- }
- ArrayRef<const Expr *> getUpdates() const {
- return llvm::ArrayRef(getInits().end(), varlist_size());
- }
- /// Sets the list of final update expressions for linear variables.
- MutableArrayRef<Expr *> getFinals() {
- return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
- }
- ArrayRef<const Expr *> getFinals() const {
- return llvm::ArrayRef(getUpdates().end(), varlist_size());
- }
- /// Gets the list of used expressions for linear variables.
- MutableArrayRef<Expr *> getUsedExprs() {
- return MutableArrayRef<Expr *>(getFinals().end() + 2, varlist_size() + 1);
- }
- ArrayRef<const Expr *> getUsedExprs() const {
- return llvm::ArrayRef(getFinals().end() + 2, varlist_size() + 1);
- }
- /// Sets the list of the copies of original linear variables.
- /// \param PL List of expressions.
- void setPrivates(ArrayRef<Expr *> PL);
- /// Sets the list of the initial values for linear variables.
- /// \param IL List of expressions.
- void setInits(ArrayRef<Expr *> IL);
- public:
- /// Creates clause with a list of variables \a VL and a linear step
- /// \a Step.
- ///
- /// \param C AST Context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param Modifier Modifier of 'linear' clause.
- /// \param ModifierLoc Modifier location.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- /// \param PL List of private copies of original variables.
- /// \param IL List of initial values for the variables.
- /// \param Step Linear step.
- /// \param CalcStep Calculation of the linear step.
- /// \param PreInit Statement that must be executed before entering the OpenMP
- /// region with this clause.
- /// \param PostUpdate Expression that must be executed after exit from the
- /// OpenMP region with this clause.
- static OMPLinearClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
- ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep,
- Stmt *PreInit, Expr *PostUpdate);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param NumVars Number of variables.
- static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
- /// Set modifier.
- void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
- /// Return modifier.
- OpenMPLinearClauseKind getModifier() const { return Modifier; }
- /// Set modifier location.
- void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
- /// Return modifier location.
- SourceLocation getModifierLoc() const { return ModifierLoc; }
- /// Sets the location of ':'.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- /// Returns the location of ':'.
- SourceLocation getColonLoc() const { return ColonLoc; }
- /// Returns linear step.
- Expr *getStep() { return *(getFinals().end()); }
- /// Returns linear step.
- const Expr *getStep() const { return *(getFinals().end()); }
- /// Returns expression to calculate linear step.
- Expr *getCalcStep() { return *(getFinals().end() + 1); }
- /// Returns expression to calculate linear step.
- const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
- /// Sets the list of update expressions for linear variables.
- /// \param UL List of expressions.
- void setUpdates(ArrayRef<Expr *> UL);
- /// Sets the list of final update expressions for linear variables.
- /// \param FL List of expressions.
- void setFinals(ArrayRef<Expr *> FL);
- /// Sets the list of used expressions for the linear clause.
- void setUsedExprs(ArrayRef<Expr *> UE);
- using privates_iterator = MutableArrayRef<Expr *>::iterator;
- using privates_const_iterator = ArrayRef<const Expr *>::iterator;
- using privates_range = llvm::iterator_range<privates_iterator>;
- using privates_const_range = llvm::iterator_range<privates_const_iterator>;
- privates_range privates() {
- return privates_range(getPrivates().begin(), getPrivates().end());
- }
- privates_const_range privates() const {
- return privates_const_range(getPrivates().begin(), getPrivates().end());
- }
- using inits_iterator = MutableArrayRef<Expr *>::iterator;
- using inits_const_iterator = ArrayRef<const Expr *>::iterator;
- using inits_range = llvm::iterator_range<inits_iterator>;
- using inits_const_range = llvm::iterator_range<inits_const_iterator>;
- inits_range inits() {
- return inits_range(getInits().begin(), getInits().end());
- }
- inits_const_range inits() const {
- return inits_const_range(getInits().begin(), getInits().end());
- }
- using updates_iterator = MutableArrayRef<Expr *>::iterator;
- using updates_const_iterator = ArrayRef<const Expr *>::iterator;
- using updates_range = llvm::iterator_range<updates_iterator>;
- using updates_const_range = llvm::iterator_range<updates_const_iterator>;
- updates_range updates() {
- return updates_range(getUpdates().begin(), getUpdates().end());
- }
- updates_const_range updates() const {
- return updates_const_range(getUpdates().begin(), getUpdates().end());
- }
- using finals_iterator = MutableArrayRef<Expr *>::iterator;
- using finals_const_iterator = ArrayRef<const Expr *>::iterator;
- using finals_range = llvm::iterator_range<finals_iterator>;
- using finals_const_range = llvm::iterator_range<finals_const_iterator>;
- finals_range finals() {
- return finals_range(getFinals().begin(), getFinals().end());
- }
- finals_const_range finals() const {
- return finals_const_range(getFinals().begin(), getFinals().end());
- }
- using used_expressions_iterator = MutableArrayRef<Expr *>::iterator;
- using used_expressions_const_iterator = ArrayRef<const Expr *>::iterator;
- using used_expressions_range =
- llvm::iterator_range<used_expressions_iterator>;
- using used_expressions_const_range =
- llvm::iterator_range<used_expressions_const_iterator>;
- used_expressions_range used_expressions() {
- return finals_range(getUsedExprs().begin(), getUsedExprs().end());
- }
- used_expressions_const_range used_expressions() const {
- return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPLinearClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPLinearClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_linear;
- }
- };
- /// This represents clause 'aligned' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp simd aligned(a,b : 8)
- /// \endcode
- /// In this example directive '#pragma omp simd' has clause 'aligned'
- /// with variables 'a', 'b' and alignment '8'.
- class OMPAlignedClause final
- : public OMPVarListClause<OMPAlignedClause>,
- private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Location of ':'.
- SourceLocation ColonLoc;
- /// Sets the alignment for clause.
- void setAlignment(Expr *A) { *varlist_end() = A; }
- /// Build 'aligned' clause with given number of variables \a NumVars.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param NumVars Number of variables.
- OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc,
- unsigned NumVars)
- : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc,
- LParenLoc, EndLoc, NumVars),
- ColonLoc(ColonLoc) {}
- /// Build an empty clause.
- ///
- /// \param NumVars Number of variables.
- explicit OMPAlignedClause(unsigned NumVars)
- : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned,
- SourceLocation(), SourceLocation(),
- SourceLocation(), NumVars) {}
- public:
- /// Creates clause with a list of variables \a VL and alignment \a A.
- ///
- /// \param C AST Context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- /// \param A Alignment.
- static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation ColonLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL,
- Expr *A);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param NumVars Number of variables.
- static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
- /// Sets the location of ':'.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- /// Returns the location of ':'.
- SourceLocation getColonLoc() const { return ColonLoc; }
- /// Returns alignment.
- Expr *getAlignment() { return *varlist_end(); }
- /// Returns alignment.
- const Expr *getAlignment() const { return *varlist_end(); }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPAlignedClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_aligned;
- }
- };
- /// This represents clause 'copyin' in the '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp parallel copyin(a,b)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has clause 'copyin'
- /// with the variables 'a' and 'b'.
- class OMPCopyinClause final
- : public OMPVarListClause<OMPCopyinClause>,
- private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
- // Class has 3 additional tail allocated arrays:
- // 1. List of helper expressions for proper generation of assignment operation
- // required for copyin clause. This list represents sources.
- // 2. List of helper expressions for proper generation of assignment operation
- // required for copyin clause. This list represents destinations.
- // 3. List of helper expressions that represents assignment operation:
- // \code
- // DstExprs = SrcExprs;
- // \endcode
- // Required for proper codegen of propagation of master's thread values of
- // threadprivate variables to local instances of that variables in other
- // implicit threads.
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc,
- LParenLoc, EndLoc, N) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPCopyinClause(unsigned N)
- : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent source expression in the final
- /// assignment statement performed by the copyin clause.
- void setSourceExprs(ArrayRef<Expr *> SrcExprs);
- /// Get the list of helper source expressions.
- MutableArrayRef<Expr *> getSourceExprs() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getSourceExprs() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent destination expression in the final
- /// assignment statement performed by the copyin clause.
- void setDestinationExprs(ArrayRef<Expr *> DstExprs);
- /// Get the list of helper destination expressions.
- MutableArrayRef<Expr *> getDestinationExprs() {
- return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getDestinationExprs() const {
- return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
- }
- /// Set list of helper assignment expressions, required for proper
- /// codegen of the clause. These expressions are assignment expressions that
- /// assign source helper expressions to destination helper expressions
- /// correspondingly.
- void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
- /// Get the list of helper assignment expressions.
- MutableArrayRef<Expr *> getAssignmentOps() {
- return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getAssignmentOps() const {
- return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- /// \param SrcExprs List of helper expressions for proper generation of
- /// assignment operation required for copyin clause. This list represents
- /// sources.
- /// \param DstExprs List of helper expressions for proper generation of
- /// assignment operation required for copyin clause. This list represents
- /// destinations.
- /// \param AssignmentOps List of helper expressions that represents assignment
- /// operation:
- /// \code
- /// DstExprs = SrcExprs;
- /// \endcode
- /// Required for proper codegen of propagation of master's thread values of
- /// threadprivate variables to local instances of that variables in other
- /// implicit threads.
- static OMPCopyinClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
- ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
- /// Creates an empty clause with \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
- using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
- using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
- using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
- using helper_expr_const_range =
- llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range source_exprs() const {
- return helper_expr_const_range(getSourceExprs().begin(),
- getSourceExprs().end());
- }
- helper_expr_range source_exprs() {
- return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
- }
- helper_expr_const_range destination_exprs() const {
- return helper_expr_const_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
- helper_expr_range destination_exprs() {
- return helper_expr_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
- helper_expr_const_range assignment_ops() const {
- return helper_expr_const_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
- helper_expr_range assignment_ops() {
- return helper_expr_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPCopyinClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_copyin;
- }
- };
- /// This represents clause 'copyprivate' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp single copyprivate(a,b)
- /// \endcode
- /// In this example directive '#pragma omp single' has clause 'copyprivate'
- /// with the variables 'a' and 'b'.
- class OMPCopyprivateClause final
- : public OMPVarListClause<OMPCopyprivateClause>,
- private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate,
- StartLoc, LParenLoc, EndLoc, N) {
- }
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPCopyprivateClause(unsigned N)
- : OMPVarListClause<OMPCopyprivateClause>(
- llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent source expression in the final
- /// assignment statement performed by the copyprivate clause.
- void setSourceExprs(ArrayRef<Expr *> SrcExprs);
- /// Get the list of helper source expressions.
- MutableArrayRef<Expr *> getSourceExprs() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getSourceExprs() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Set list of helper expressions, required for proper codegen of the
- /// clause. These expressions represent destination expression in the final
- /// assignment statement performed by the copyprivate clause.
- void setDestinationExprs(ArrayRef<Expr *> DstExprs);
- /// Get the list of helper destination expressions.
- MutableArrayRef<Expr *> getDestinationExprs() {
- return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getDestinationExprs() const {
- return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
- }
- /// Set list of helper assignment expressions, required for proper
- /// codegen of the clause. These expressions are assignment expressions that
- /// assign source helper expressions to destination helper expressions
- /// correspondingly.
- void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
- /// Get the list of helper assignment expressions.
- MutableArrayRef<Expr *> getAssignmentOps() {
- return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
- }
- ArrayRef<const Expr *> getAssignmentOps() const {
- return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- /// \param SrcExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// sources.
- /// \param DstExprs List of helper expressions for proper generation of
- /// assignment operation required for copyprivate clause. This list represents
- /// destinations.
- /// \param AssignmentOps List of helper expressions that represents assignment
- /// operation:
- /// \code
- /// DstExprs = SrcExprs;
- /// \endcode
- /// Required for proper codegen of final assignment performed by the
- /// copyprivate clause.
- static OMPCopyprivateClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
- ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
- /// Creates an empty clause with \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
- using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
- using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
- using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
- using helper_expr_const_range =
- llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range source_exprs() const {
- return helper_expr_const_range(getSourceExprs().begin(),
- getSourceExprs().end());
- }
- helper_expr_range source_exprs() {
- return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
- }
- helper_expr_const_range destination_exprs() const {
- return helper_expr_const_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
- helper_expr_range destination_exprs() {
- return helper_expr_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
- helper_expr_const_range assignment_ops() const {
- return helper_expr_const_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
- helper_expr_range assignment_ops() {
- return helper_expr_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPCopyprivateClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_copyprivate;
- }
- };
- /// This represents implicit clause 'flush' for the '#pragma omp flush'
- /// directive.
- /// This clause does not exist by itself, it can be only as a part of 'omp
- /// flush' directive. This clause is introduced to keep the original structure
- /// of \a OMPExecutableDirective class and its derivatives and to use the
- /// existing infrastructure of clauses with the list of variables.
- ///
- /// \code
- /// #pragma omp flush(a,b)
- /// \endcode
- /// In this example directive '#pragma omp flush' has implicit clause 'flush'
- /// with the variables 'a' and 'b'.
- class OMPFlushClause final
- : public OMPVarListClause<OMPFlushClause>,
- private llvm::TrailingObjects<OMPFlushClause, Expr *> {
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc,
- LParenLoc, EndLoc, N) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPFlushClause(unsigned N)
- : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc,
- ArrayRef<Expr *> VL);
- /// Creates an empty clause with \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPFlushClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_flush;
- }
- };
- /// This represents implicit clause 'depobj' for the '#pragma omp depobj'
- /// directive.
- /// This clause does not exist by itself, it can be only as a part of 'omp
- /// depobj' directive. This clause is introduced to keep the original structure
- /// of \a OMPExecutableDirective class and its derivatives and to use the
- /// existing infrastructure of clauses with the list of variables.
- ///
- /// \code
- /// #pragma omp depobj(a) destroy
- /// \endcode
- /// In this example directive '#pragma omp depobj' has implicit clause 'depobj'
- /// with the depobj 'a'.
- class OMPDepobjClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Chunk size.
- Expr *Depobj = nullptr;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc),
- LParenLoc(LParenLoc) {}
- /// Build an empty clause.
- ///
- explicit OMPDepobjClause()
- : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {}
- void setDepobj(Expr *E) { Depobj = E; }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- public:
- /// Creates clause.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param Depobj depobj expression associated with the 'depobj' directive.
- static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc, Expr *Depobj);
- /// Creates an empty clause.
- ///
- /// \param C AST context.
- static OMPDepobjClause *CreateEmpty(const ASTContext &C);
- /// Returns depobj expression associated with the clause.
- Expr *getDepobj() { return Depobj; }
- const Expr *getDepobj() const { return Depobj; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(&Depobj),
- reinterpret_cast<Stmt **>(&Depobj) + 1);
- }
- const_child_range children() const {
- auto Children = const_cast<OMPDepobjClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_depobj;
- }
- };
- /// This represents implicit clause 'depend' for the '#pragma omp task'
- /// directive.
- ///
- /// \code
- /// #pragma omp task depend(in:a,b)
- /// \endcode
- /// In this example directive '#pragma omp task' with clause 'depend' with the
- /// variables 'a' and 'b' with dependency 'in'.
- class OMPDependClause final
- : public OMPVarListClause<OMPDependClause>,
- private llvm::TrailingObjects<OMPDependClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- public:
- struct DependDataTy final {
- /// Dependency type (one of in, out, inout).
- OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown;
- /// Dependency type location.
- SourceLocation DepLoc;
- /// Colon location.
- SourceLocation ColonLoc;
- /// Location of 'omp_all_memory'.
- SourceLocation OmpAllMemoryLoc;
- };
- private:
- /// Dependency type and source locations.
- DependDataTy Data;
- /// Number of loops, associated with the depend clause.
- unsigned NumLoops = 0;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- /// \param NumLoops Number of loops that is associated with this depend
- /// clause.
- OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N, unsigned NumLoops)
- : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc,
- LParenLoc, EndLoc, N),
- NumLoops(NumLoops) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- /// \param NumLoops Number of loops that is associated with this depend
- /// clause.
- explicit OMPDependClause(unsigned N, unsigned NumLoops)
- : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N),
- NumLoops(NumLoops) {}
- /// Set dependency kind.
- void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; }
- /// Set dependency kind and its location.
- void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; }
- /// Set colon location.
- void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; }
- /// Set the 'omp_all_memory' location.
- void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; }
- /// Sets optional dependency modifier.
- void setModifier(Expr *DepModifier);
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param Data Dependency type and source locations.
- /// \param VL List of references to the variables.
- /// \param NumLoops Number of loops that is associated with this depend
- /// clause.
- static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc, DependDataTy Data,
- Expr *DepModifier, ArrayRef<Expr *> VL,
- unsigned NumLoops);
- /// Creates an empty clause with \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- /// \param NumLoops Number of loops that is associated with this depend
- /// clause.
- static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N,
- unsigned NumLoops);
- /// Get dependency type.
- OpenMPDependClauseKind getDependencyKind() const { return Data.DepKind; }
- /// Get dependency type location.
- SourceLocation getDependencyLoc() const { return Data.DepLoc; }
- /// Get colon location.
- SourceLocation getColonLoc() const { return Data.ColonLoc; }
- /// Get 'omp_all_memory' location.
- SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; }
- /// Return optional depend modifier.
- Expr *getModifier();
- const Expr *getModifier() const {
- return const_cast<OMPDependClause *>(this)->getModifier();
- }
- /// Get number of loops associated with the clause.
- unsigned getNumLoops() const { return NumLoops; }
- /// Set the loop data for the depend clauses with 'sink|source' kind of
- /// dependency.
- void setLoopData(unsigned NumLoop, Expr *Cnt);
- /// Get the loop data.
- Expr *getLoopData(unsigned NumLoop);
- const Expr *getLoopData(unsigned NumLoop) const;
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPDependClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_depend;
- }
- };
- /// This represents 'device' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp target device(a)
- /// \endcode
- /// In this example directive '#pragma omp target' has clause 'device'
- /// with single expression 'a'.
- class OMPDeviceClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Device clause modifier.
- OpenMPDeviceClauseModifier Modifier = OMPC_DEVICE_unknown;
- /// Location of the modifier.
- SourceLocation ModifierLoc;
- /// Device number.
- Stmt *Device = nullptr;
- /// Set the device number.
- ///
- /// \param E Device number.
- void setDevice(Expr *E) { Device = E; }
- /// Sets modifier.
- void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; }
- /// Setst modifier location.
- void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
- public:
- /// Build 'device' clause.
- ///
- /// \param Modifier Clause modifier.
- /// \param E Expression associated with this clause.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param ModifierLoc Modifier location.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *E, Stmt *HelperE,
- OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation ModifierLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
- ModifierLoc(ModifierLoc), Device(E) {
- setPreInitStmt(HelperE, CaptureRegion);
- }
- /// Build an empty clause.
- OMPDeviceClause()
- : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return device number.
- Expr *getDevice() { return cast<Expr>(Device); }
- /// Return device number.
- Expr *getDevice() const { return cast<Expr>(Device); }
- /// Gets modifier.
- OpenMPDeviceClauseModifier getModifier() const { return Modifier; }
- /// Gets modifier location.
- SourceLocation getModifierLoc() const { return ModifierLoc; }
- child_range children() { return child_range(&Device, &Device + 1); }
- const_child_range children() const {
- return const_child_range(&Device, &Device + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_device;
- }
- };
- /// This represents 'threads' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp ordered threads
- /// \endcode
- /// In this example directive '#pragma omp ordered' has simple 'threads' clause.
- class OMPThreadsClause final
- : public OMPNoChildClause<llvm::omp::OMPC_threads> {
- public:
- /// Build 'threads' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPNoChildClause(StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPThreadsClause() : OMPNoChildClause() {}
- };
- /// This represents 'simd' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp ordered simd
- /// \endcode
- /// In this example directive '#pragma omp ordered' has simple 'simd' clause.
- class OMPSIMDClause : public OMPClause {
- public:
- /// Build 'simd' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPSIMDClause()
- : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {}
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_simd;
- }
- };
- /// Struct that defines common infrastructure to handle mappable
- /// expressions used in OpenMP clauses.
- class OMPClauseMappableExprCommon {
- public:
- /// Class that represents a component of a mappable expression. E.g.
- /// for an expression S.a, the first component is a declaration reference
- /// expression associated with 'S' and the second is a member expression
- /// associated with the field declaration 'a'. If the expression is an array
- /// subscript it may not have any associated declaration. In that case the
- /// associated declaration is set to nullptr.
- class MappableComponent {
- /// Pair of Expression and Non-contiguous pair associated with the
- /// component.
- llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr;
- /// Declaration associated with the declaration. If the component does
- /// not have a declaration (e.g. array subscripts or section), this is set
- /// to nullptr.
- ValueDecl *AssociatedDeclaration = nullptr;
- public:
- explicit MappableComponent() = default;
- explicit MappableComponent(Expr *AssociatedExpression,
- ValueDecl *AssociatedDeclaration,
- bool IsNonContiguous)
- : AssociatedExpressionNonContiguousPr(AssociatedExpression,
- IsNonContiguous),
- AssociatedDeclaration(
- AssociatedDeclaration
- ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
- : nullptr) {}
- Expr *getAssociatedExpression() const {
- return AssociatedExpressionNonContiguousPr.getPointer();
- }
- bool isNonContiguous() const {
- return AssociatedExpressionNonContiguousPr.getInt();
- }
- ValueDecl *getAssociatedDeclaration() const {
- return AssociatedDeclaration;
- }
- };
- // List of components of an expression. This first one is the whole
- // expression and the last one is the base expression.
- using MappableExprComponentList = SmallVector<MappableComponent, 8>;
- using MappableExprComponentListRef = ArrayRef<MappableComponent>;
- // List of all component lists associated to the same base declaration.
- // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
- // their component list but the same base declaration 'S'.
- using MappableExprComponentLists = SmallVector<MappableExprComponentList, 8>;
- using MappableExprComponentListsRef = ArrayRef<MappableExprComponentList>;
- protected:
- // Return the total number of elements in a list of component lists.
- static unsigned
- getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists);
- // Return the total number of elements in a list of declarations. All
- // declarations are expected to be canonical.
- static unsigned
- getUniqueDeclarationsTotalNumber(ArrayRef<const ValueDecl *> Declarations);
- };
- /// This structure contains all sizes needed for by an
- /// OMPMappableExprListClause.
- struct OMPMappableExprListSizeTy {
- /// Number of expressions listed.
- unsigned NumVars;
- /// Number of unique base declarations.
- unsigned NumUniqueDeclarations;
- /// Number of component lists.
- unsigned NumComponentLists;
- /// Total number of expression components.
- unsigned NumComponents;
- OMPMappableExprListSizeTy() = default;
- OMPMappableExprListSizeTy(unsigned NumVars, unsigned NumUniqueDeclarations,
- unsigned NumComponentLists, unsigned NumComponents)
- : NumVars(NumVars), NumUniqueDeclarations(NumUniqueDeclarations),
- NumComponentLists(NumComponentLists), NumComponents(NumComponents) {}
- };
- /// This represents clauses with a list of expressions that are mappable.
- /// Examples of these clauses are 'map' in
- /// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
- /// in '#pragma omp target update...' directives.
- template <class T>
- class OMPMappableExprListClause : public OMPVarListClause<T>,
- public OMPClauseMappableExprCommon {
- friend class OMPClauseReader;
- /// Number of unique declarations in this clause.
- unsigned NumUniqueDeclarations;
- /// Number of component lists in this clause.
- unsigned NumComponentLists;
- /// Total number of components in this clause.
- unsigned NumComponents;
- /// Whether this clause is possible to have user-defined mappers associated.
- /// It should be true for map, to, and from clauses, and false for
- /// use_device_ptr and is_device_ptr.
- const bool SupportsMapper;
- /// C++ nested name specifier for the associated user-defined mapper.
- NestedNameSpecifierLoc MapperQualifierLoc;
- /// The associated user-defined mapper identifier information.
- DeclarationNameInfo MapperIdInfo;
- protected:
- /// Build a clause for \a NumUniqueDeclarations declarations, \a
- /// NumComponentLists total component lists, and \a NumComponents total
- /// components.
- ///
- /// \param K Kind of the clause.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- /// \param SupportsMapper Indicates whether this clause is possible to have
- /// user-defined mappers associated.
- /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
- /// user-defined mapper.
- /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
- OMPMappableExprListClause(
- OpenMPClauseKind K, const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false,
- NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
- DeclarationNameInfo *MapperIdInfoPtr = nullptr)
- : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc,
- Sizes.NumVars),
- NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
- NumComponentLists(Sizes.NumComponentLists),
- NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) {
- if (MapperQualifierLocPtr)
- MapperQualifierLoc = *MapperQualifierLocPtr;
- if (MapperIdInfoPtr)
- MapperIdInfo = *MapperIdInfoPtr;
- }
- /// Get the unique declarations that are in the trailing objects of the
- /// class.
- MutableArrayRef<ValueDecl *> getUniqueDeclsRef() {
- return MutableArrayRef<ValueDecl *>(
- static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
- NumUniqueDeclarations);
- }
- /// Get the unique declarations that are in the trailing objects of the
- /// class.
- ArrayRef<ValueDecl *> getUniqueDeclsRef() const {
- return ArrayRef<ValueDecl *>(
- static_cast<const T *>(this)
- ->template getTrailingObjects<ValueDecl *>(),
- NumUniqueDeclarations);
- }
- /// Set the unique declarations that are in the trailing objects of the
- /// class.
- void setUniqueDecls(ArrayRef<ValueDecl *> UDs) {
- assert(UDs.size() == NumUniqueDeclarations &&
- "Unexpected amount of unique declarations.");
- std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
- }
- /// Get the number of lists per declaration that are in the trailing
- /// objects of the class.
- MutableArrayRef<unsigned> getDeclNumListsRef() {
- return MutableArrayRef<unsigned>(
- static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
- NumUniqueDeclarations);
- }
- /// Get the number of lists per declaration that are in the trailing
- /// objects of the class.
- ArrayRef<unsigned> getDeclNumListsRef() const {
- return ArrayRef<unsigned>(
- static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
- NumUniqueDeclarations);
- }
- /// Set the number of lists per declaration that are in the trailing
- /// objects of the class.
- void setDeclNumLists(ArrayRef<unsigned> DNLs) {
- assert(DNLs.size() == NumUniqueDeclarations &&
- "Unexpected amount of list numbers.");
- std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
- }
- /// Get the cumulative component lists sizes that are in the trailing
- /// objects of the class. They are appended after the number of lists.
- MutableArrayRef<unsigned> getComponentListSizesRef() {
- return MutableArrayRef<unsigned>(
- static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
- NumUniqueDeclarations,
- NumComponentLists);
- }
- /// Get the cumulative component lists sizes that are in the trailing
- /// objects of the class. They are appended after the number of lists.
- ArrayRef<unsigned> getComponentListSizesRef() const {
- return ArrayRef<unsigned>(
- static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
- NumUniqueDeclarations,
- NumComponentLists);
- }
- /// Set the cumulative component lists sizes that are in the trailing
- /// objects of the class.
- void setComponentListSizes(ArrayRef<unsigned> CLSs) {
- assert(CLSs.size() == NumComponentLists &&
- "Unexpected amount of component lists.");
- std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
- }
- /// Get the components that are in the trailing objects of the class.
- MutableArrayRef<MappableComponent> getComponentsRef() {
- return MutableArrayRef<MappableComponent>(
- static_cast<T *>(this)
- ->template getTrailingObjects<MappableComponent>(),
- NumComponents);
- }
- /// Get the components that are in the trailing objects of the class.
- ArrayRef<MappableComponent> getComponentsRef() const {
- return ArrayRef<MappableComponent>(
- static_cast<const T *>(this)
- ->template getTrailingObjects<MappableComponent>(),
- NumComponents);
- }
- /// Set the components that are in the trailing objects of the class.
- /// This requires the list sizes so that it can also fill the original
- /// expressions, which are the first component of each list.
- void setComponents(ArrayRef<MappableComponent> Components,
- ArrayRef<unsigned> CLSs) {
- assert(Components.size() == NumComponents &&
- "Unexpected amount of component lists.");
- assert(CLSs.size() == NumComponentLists &&
- "Unexpected amount of list sizes.");
- std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
- }
- /// Fill the clause information from the list of declarations and
- /// associated component lists.
- void setClauseInfo(ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists) {
- // Perform some checks to make sure the data sizes are consistent with the
- // information available when the clause was created.
- assert(getUniqueDeclarationsTotalNumber(Declarations) ==
- NumUniqueDeclarations &&
- "Unexpected number of mappable expression info entries!");
- assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
- "Unexpected total number of components!");
- assert(Declarations.size() == ComponentLists.size() &&
- "Declaration and component lists size is not consistent!");
- assert(Declarations.size() == NumComponentLists &&
- "Unexpected declaration and component lists size!");
- // Organize the components by declaration and retrieve the original
- // expression. Original expressions are always the first component of the
- // mappable component list.
- llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
- ComponentListMap;
- {
- auto CI = ComponentLists.begin();
- for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
- ++DI, ++CI) {
- assert(!CI->empty() && "Invalid component list!");
- ComponentListMap[*DI].push_back(*CI);
- }
- }
- // Iterators of the target storage.
- auto UniqueDeclarations = getUniqueDeclsRef();
- auto UDI = UniqueDeclarations.begin();
- auto DeclNumLists = getDeclNumListsRef();
- auto DNLI = DeclNumLists.begin();
- auto ComponentListSizes = getComponentListSizesRef();
- auto CLSI = ComponentListSizes.begin();
- auto Components = getComponentsRef();
- auto CI = Components.begin();
- // Variable to compute the accumulation of the number of components.
- unsigned PrevSize = 0u;
- // Scan all the declarations and associated component lists.
- for (auto &M : ComponentListMap) {
- // The declaration.
- auto *D = M.first;
- // The component lists.
- auto CL = M.second;
- // Initialize the entry.
- *UDI = D;
- ++UDI;
- *DNLI = CL.size();
- ++DNLI;
- // Obtain the cumulative sizes and concatenate all the components in the
- // reserved storage.
- for (auto C : CL) {
- // Accumulate with the previous size.
- PrevSize += C.size();
- // Save the size.
- *CLSI = PrevSize;
- ++CLSI;
- // Append components after the current components iterator.
- CI = std::copy(C.begin(), C.end(), CI);
- }
- }
- }
- /// Set the nested name specifier of associated user-defined mapper.
- void setMapperQualifierLoc(NestedNameSpecifierLoc NNSL) {
- MapperQualifierLoc = NNSL;
- }
- /// Set the name of associated user-defined mapper.
- void setMapperIdInfo(DeclarationNameInfo MapperId) {
- MapperIdInfo = MapperId;
- }
- /// Get the user-defined mapper references that are in the trailing objects of
- /// the class.
- MutableArrayRef<Expr *> getUDMapperRefs() {
- assert(SupportsMapper &&
- "Must be a clause that is possible to have user-defined mappers");
- return llvm::MutableArrayRef<Expr *>(
- static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
- OMPVarListClause<T>::varlist_size(),
- OMPVarListClause<T>::varlist_size());
- }
- /// Get the user-defined mappers references that are in the trailing objects
- /// of the class.
- ArrayRef<Expr *> getUDMapperRefs() const {
- assert(SupportsMapper &&
- "Must be a clause that is possible to have user-defined mappers");
- return llvm::ArrayRef<Expr *>(
- static_cast<const T *>(this)->template getTrailingObjects<Expr *>() +
- OMPVarListClause<T>::varlist_size(),
- OMPVarListClause<T>::varlist_size());
- }
- /// Set the user-defined mappers that are in the trailing objects of the
- /// class.
- void setUDMapperRefs(ArrayRef<Expr *> DMDs) {
- assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
- "Unexpected number of user-defined mappers.");
- assert(SupportsMapper &&
- "Must be a clause that is possible to have user-defined mappers");
- std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin());
- }
- public:
- /// Return the number of unique base declarations in this clause.
- unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
- /// Return the number of lists derived from the clause expressions.
- unsigned getTotalComponentListNum() const { return NumComponentLists; }
- /// Return the total number of components in all lists derived from the
- /// clause.
- unsigned getTotalComponentsNum() const { return NumComponents; }
- /// Gets the nested name specifier for associated user-defined mapper.
- NestedNameSpecifierLoc getMapperQualifierLoc() const {
- return MapperQualifierLoc;
- }
- /// Gets the name info for associated user-defined mapper.
- const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
- /// Iterator that browse the components by lists. It also allows
- /// browsing components of a single declaration.
- class const_component_lists_iterator
- : public llvm::iterator_adaptor_base<
- const_component_lists_iterator,
- MappableExprComponentListRef::const_iterator,
- std::forward_iterator_tag, MappableComponent, ptrdiff_t,
- MappableComponent, MappableComponent> {
- // The declaration the iterator currently refers to.
- ArrayRef<ValueDecl *>::iterator DeclCur;
- // The list number associated with the current declaration.
- ArrayRef<unsigned>::iterator NumListsCur;
- // Whether this clause is possible to have user-defined mappers associated.
- const bool SupportsMapper;
- // The user-defined mapper associated with the current declaration.
- ArrayRef<Expr *>::iterator MapperCur;
- // Remaining lists for the current declaration.
- unsigned RemainingLists = 0;
- // The cumulative size of the previous list, or zero if there is no previous
- // list.
- unsigned PrevListSize = 0;
- // The cumulative sizes of the current list - it will delimit the remaining
- // range of interest.
- ArrayRef<unsigned>::const_iterator ListSizeCur;
- ArrayRef<unsigned>::const_iterator ListSizeEnd;
- // Iterator to the end of the components storage.
- MappableExprComponentListRef::const_iterator End;
- public:
- /// Construct an iterator that scans all lists.
- explicit const_component_lists_iterator(
- ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
- ArrayRef<unsigned> CumulativeListSizes,
- MappableExprComponentListRef Components, bool SupportsMapper,
- ArrayRef<Expr *> Mappers)
- : const_component_lists_iterator::iterator_adaptor_base(
- Components.begin()),
- DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
- SupportsMapper(SupportsMapper),
- ListSizeCur(CumulativeListSizes.begin()),
- ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
- assert(UniqueDecls.size() == DeclsListNum.size() &&
- "Inconsistent number of declarations and list sizes!");
- if (!DeclsListNum.empty())
- RemainingLists = *NumListsCur;
- if (SupportsMapper)
- MapperCur = Mappers.begin();
- }
- /// Construct an iterator that scan lists for a given declaration \a
- /// Declaration.
- explicit const_component_lists_iterator(
- const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
- ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
- MappableExprComponentListRef Components, bool SupportsMapper,
- ArrayRef<Expr *> Mappers)
- : const_component_lists_iterator(UniqueDecls, DeclsListNum,
- CumulativeListSizes, Components,
- SupportsMapper, Mappers) {
- // Look for the desired declaration. While we are looking for it, we
- // update the state so that we know the component where a given list
- // starts.
- for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
- if (*DeclCur == Declaration)
- break;
- assert(*NumListsCur > 0 && "No lists associated with declaration??");
- // Skip the lists associated with the current declaration, but save the
- // last list size that was skipped.
- std::advance(ListSizeCur, *NumListsCur - 1);
- PrevListSize = *ListSizeCur;
- ++ListSizeCur;
- if (SupportsMapper)
- ++MapperCur;
- }
- // If we didn't find any declaration, advance the iterator to after the
- // last component and set remaining lists to zero.
- if (ListSizeCur == CumulativeListSizes.end()) {
- this->I = End;
- RemainingLists = 0u;
- return;
- }
- // Set the remaining lists with the total number of lists of the current
- // declaration.
- RemainingLists = *NumListsCur;
- // Adjust the list size end iterator to the end of the relevant range.
- ListSizeEnd = ListSizeCur;
- std::advance(ListSizeEnd, RemainingLists);
- // Given that the list sizes are cumulative, the index of the component
- // that start the list is the size of the previous list.
- std::advance(this->I, PrevListSize);
- }
- // Return the array with the current list. The sizes are cumulative, so the
- // array size is the difference between the current size and previous one.
- std::tuple<const ValueDecl *, MappableExprComponentListRef,
- const ValueDecl *>
- operator*() const {
- assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
- const ValueDecl *Mapper = nullptr;
- if (SupportsMapper && *MapperCur)
- Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl());
- return std::make_tuple(
- *DeclCur,
- MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize),
- Mapper);
- }
- std::tuple<const ValueDecl *, MappableExprComponentListRef,
- const ValueDecl *>
- operator->() const {
- return **this;
- }
- // Skip the components of the current list.
- const_component_lists_iterator &operator++() {
- assert(ListSizeCur != ListSizeEnd && RemainingLists &&
- "Invalid iterator!");
- // If we don't have more lists just skip all the components. Otherwise,
- // advance the iterator by the number of components in the current list.
- if (std::next(ListSizeCur) == ListSizeEnd) {
- this->I = End;
- RemainingLists = 0;
- } else {
- std::advance(this->I, *ListSizeCur - PrevListSize);
- PrevListSize = *ListSizeCur;
- // We are done with a declaration, move to the next one.
- if (!(--RemainingLists)) {
- ++DeclCur;
- ++NumListsCur;
- RemainingLists = *NumListsCur;
- assert(RemainingLists && "No lists in the following declaration??");
- }
- }
- ++ListSizeCur;
- if (SupportsMapper)
- ++MapperCur;
- return *this;
- }
- };
- using const_component_lists_range =
- llvm::iterator_range<const_component_lists_iterator>;
- /// Iterators for all component lists.
- const_component_lists_iterator component_lists_begin() const {
- return const_component_lists_iterator(
- getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(),
- getComponentsRef(), SupportsMapper,
- SupportsMapper ? getUDMapperRefs() : std::nullopt);
- }
- const_component_lists_iterator component_lists_end() const {
- return const_component_lists_iterator(
- ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(),
- MappableExprComponentListRef(getComponentsRef().end(),
- getComponentsRef().end()),
- SupportsMapper, std::nullopt);
- }
- const_component_lists_range component_lists() const {
- return {component_lists_begin(), component_lists_end()};
- }
- /// Iterators for component lists associated with the provided
- /// declaration.
- const_component_lists_iterator
- decl_component_lists_begin(const ValueDecl *VD) const {
- return const_component_lists_iterator(
- VD, getUniqueDeclsRef(), getDeclNumListsRef(),
- getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
- SupportsMapper ? getUDMapperRefs() : std::nullopt);
- }
- const_component_lists_iterator decl_component_lists_end() const {
- return component_lists_end();
- }
- const_component_lists_range decl_component_lists(const ValueDecl *VD) const {
- return {decl_component_lists_begin(VD), decl_component_lists_end()};
- }
- /// Iterators to access all the declarations, number of lists, list sizes, and
- /// components.
- using const_all_decls_iterator = ArrayRef<ValueDecl *>::iterator;
- using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
- const_all_decls_range all_decls() const {
- auto A = getUniqueDeclsRef();
- return const_all_decls_range(A.begin(), A.end());
- }
- using const_all_num_lists_iterator = ArrayRef<unsigned>::iterator;
- using const_all_num_lists_range =
- llvm::iterator_range<const_all_num_lists_iterator>;
- const_all_num_lists_range all_num_lists() const {
- auto A = getDeclNumListsRef();
- return const_all_num_lists_range(A.begin(), A.end());
- }
- using const_all_lists_sizes_iterator = ArrayRef<unsigned>::iterator;
- using const_all_lists_sizes_range =
- llvm::iterator_range<const_all_lists_sizes_iterator>;
- const_all_lists_sizes_range all_lists_sizes() const {
- auto A = getComponentListSizesRef();
- return const_all_lists_sizes_range(A.begin(), A.end());
- }
- using const_all_components_iterator = ArrayRef<MappableComponent>::iterator;
- using const_all_components_range =
- llvm::iterator_range<const_all_components_iterator>;
- const_all_components_range all_components() const {
- auto A = getComponentsRef();
- return const_all_components_range(A.begin(), A.end());
- }
- using mapperlist_iterator = MutableArrayRef<Expr *>::iterator;
- using mapperlist_const_iterator = ArrayRef<const Expr *>::iterator;
- using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
- using mapperlist_const_range =
- llvm::iterator_range<mapperlist_const_iterator>;
- mapperlist_iterator mapperlist_begin() { return getUDMapperRefs().begin(); }
- mapperlist_iterator mapperlist_end() { return getUDMapperRefs().end(); }
- mapperlist_const_iterator mapperlist_begin() const {
- return getUDMapperRefs().begin();
- }
- mapperlist_const_iterator mapperlist_end() const {
- return getUDMapperRefs().end();
- }
- mapperlist_range mapperlists() {
- return mapperlist_range(mapperlist_begin(), mapperlist_end());
- }
- mapperlist_const_range mapperlists() const {
- return mapperlist_const_range(mapperlist_begin(), mapperlist_end());
- }
- };
- /// This represents clause 'map' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp target map(a,b)
- /// \endcode
- /// In this example directive '#pragma omp target' has clause 'map'
- /// with the variables 'a' and 'b'.
- class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
- private llvm::TrailingObjects<
- OMPMapClause, Expr *, ValueDecl *, unsigned,
- OMPClauseMappableExprCommon::MappableComponent> {
- friend class OMPClauseReader;
- friend OMPMappableExprListClause;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- // There are varlist_size() of expressions, and varlist_size() of
- // user-defined mappers.
- return 2 * varlist_size() + 1;
- }
- size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
- return getUniqueDeclarationsNum();
- }
- size_t numTrailingObjects(OverloadToken<unsigned>) const {
- return getUniqueDeclarationsNum() + getTotalComponentListNum();
- }
- private:
- /// Map-type-modifiers for the 'map' clause.
- OpenMPMapModifierKind MapTypeModifiers[NumberOfOMPMapClauseModifiers] = {
- OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown,
- OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown,
- OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown};
- /// Location of map-type-modifiers for the 'map' clause.
- SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];
- /// Map type for the 'map' clause.
- OpenMPMapClauseKind MapType = OMPC_MAP_unknown;
- /// Is this an implicit map type or not.
- bool MapTypeIsImplicit = false;
- /// Location of the map type.
- SourceLocation MapLoc;
- /// Colon location.
- SourceLocation ColonLoc;
- /// Build a clause for \a NumVars listed expressions, \a
- /// NumUniqueDeclarations declarations, \a NumComponentLists total component
- /// lists, and \a NumComponents total expression components.
- ///
- /// \param MapModifiers Map-type-modifiers.
- /// \param MapModifiersLoc Locations of map-type-modifiers.
- /// \param MapperQualifierLoc C++ nested name specifier for the associated
- /// user-defined mapper.
- /// \param MapperIdInfo The identifier of associated user-defined mapper.
- /// \param MapType Map type.
- /// \param MapTypeIsImplicit Map type is inferred implicitly.
- /// \param MapLoc Location of the map type.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
- ArrayRef<SourceLocation> MapModifiersLoc,
- NestedNameSpecifierLoc MapperQualifierLoc,
- DeclarationNameInfo MapperIdInfo,
- OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
- SourceLocation MapLoc, const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes,
- /*SupportsMapper=*/true, &MapperQualifierLoc,
- &MapperIdInfo),
- MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
- assert(std::size(MapTypeModifiers) == MapModifiers.size() &&
- "Unexpected number of map type modifiers.");
- llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
- assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() &&
- "Unexpected number of map type modifier locations.");
- llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
- }
- /// Build an empty clause.
- ///
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes,
- /*SupportsMapper=*/true) {}
- /// Set map-type-modifier for the clause.
- ///
- /// \param I index for map-type-modifier.
- /// \param T map-type-modifier for the clause.
- void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
- assert(I < NumberOfOMPMapClauseModifiers &&
- "Unexpected index to store map type modifier, exceeds array size.");
- MapTypeModifiers[I] = T;
- }
- /// Set location for the map-type-modifier.
- ///
- /// \param I index for map-type-modifier location.
- /// \param TLoc map-type-modifier location.
- void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
- assert(I < NumberOfOMPMapClauseModifiers &&
- "Index to store map type modifier location exceeds array size.");
- MapTypeModifiersLoc[I] = TLoc;
- }
- /// Set type for the clause.
- ///
- /// \param T Type for the clause.
- void setMapType(OpenMPMapClauseKind T) { MapType = T; }
- /// Set type location.
- ///
- /// \param TLoc Type location.
- void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
- /// Set colon location.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- /// Set iterator modifier.
- void setIteratorModifier(Expr *IteratorModifier) {
- getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Vars The original expression used in the clause.
- /// \param Declarations Declarations used in the clause.
- /// \param ComponentLists Component lists used in the clause.
- /// \param UDMapperRefs References to user-defined mappers associated with
- /// expressions used in the clause.
- /// \param IteratorModifier Iterator modifier.
- /// \param MapModifiers Map-type-modifiers.
- /// \param MapModifiersLoc Location of map-type-modifiers.
- /// \param UDMQualifierLoc C++ nested name specifier for the associated
- /// user-defined mapper.
- /// \param MapperId The identifier of associated user-defined mapper.
- /// \param Type Map type.
- /// \param TypeIsImplicit Map type is inferred implicitly.
- /// \param TypeLoc Location of the map type.
- static OMPMapClause *
- Create(const ASTContext &C, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists,
- ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
- ArrayRef<OpenMPMapModifierKind> MapModifiers,
- ArrayRef<SourceLocation> MapModifiersLoc,
- NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
- OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc);
- /// Creates an empty clause with the place for \a NumVars original
- /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
- /// lists, and \a NumComponents expression components.
- ///
- /// \param C AST context.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- static OMPMapClause *CreateEmpty(const ASTContext &C,
- const OMPMappableExprListSizeTy &Sizes);
- /// Fetches Expr * of iterator modifier.
- Expr *getIteratorModifier() {
- return getTrailingObjects<Expr *>()[2 * varlist_size()];
- }
- /// Fetches mapping kind for the clause.
- OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
- /// Is this an implicit map type?
- /// We have to capture 'IsMapTypeImplicit' from the parser for more
- /// informative error messages. It helps distinguish map(r) from
- /// map(tofrom: r), which is important to print more helpful error
- /// messages for some target directives.
- bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
- /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
- ///
- /// \param Cnt index for map-type-modifier.
- OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
- assert(Cnt < NumberOfOMPMapClauseModifiers &&
- "Requested modifier exceeds the total number of modifiers.");
- return MapTypeModifiers[Cnt];
- }
- /// Fetches the map-type-modifier location at 'Cnt' index of array of
- /// modifiers' locations.
- ///
- /// \param Cnt index for map-type-modifier location.
- SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
- assert(Cnt < NumberOfOMPMapClauseModifiers &&
- "Requested modifier location exceeds total number of modifiers.");
- return MapTypeModifiersLoc[Cnt];
- }
- /// Fetches ArrayRef of map-type-modifiers.
- ArrayRef<OpenMPMapModifierKind> getMapTypeModifiers() const LLVM_READONLY {
- return llvm::ArrayRef(MapTypeModifiers);
- }
- /// Fetches ArrayRef of location of map-type-modifiers.
- ArrayRef<SourceLocation> getMapTypeModifiersLoc() const LLVM_READONLY {
- return llvm::ArrayRef(MapTypeModifiersLoc);
- }
- /// Fetches location of clause mapping kind.
- SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
- /// Get colon location.
- SourceLocation getColonLoc() const { return ColonLoc; }
- child_range children() {
- return child_range(
- reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPMapClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- auto Children = const_cast<OMPMapClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_map;
- }
- };
- /// This represents 'num_teams' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp teams num_teams(n)
- /// \endcode
- /// In this example directive '#pragma omp teams' has clause 'num_teams'
- /// with single expression 'n'.
- class OMPNumTeamsClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// NumTeams number.
- Stmt *NumTeams = nullptr;
- /// Set the NumTeams number.
- ///
- /// \param E NumTeams number.
- void setNumTeams(Expr *E) { NumTeams = E; }
- public:
- /// Build 'num_teams' clause.
- ///
- /// \param E Expression associated with this clause.
- /// \param HelperE Helper Expression associated with this clause.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_num_teams, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), NumTeams(E) {
- setPreInitStmt(HelperE, CaptureRegion);
- }
- /// Build an empty clause.
- OMPNumTeamsClause()
- : OMPClause(llvm::omp::OMPC_num_teams, SourceLocation(),
- SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return NumTeams number.
- Expr *getNumTeams() { return cast<Expr>(NumTeams); }
- /// Return NumTeams number.
- Expr *getNumTeams() const { return cast<Expr>(NumTeams); }
- child_range children() { return child_range(&NumTeams, &NumTeams + 1); }
- const_child_range children() const {
- return const_child_range(&NumTeams, &NumTeams + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_num_teams;
- }
- };
- /// This represents 'thread_limit' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp teams thread_limit(n)
- /// \endcode
- /// In this example directive '#pragma omp teams' has clause 'thread_limit'
- /// with single expression 'n'.
- class OMPThreadLimitClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// ThreadLimit number.
- Stmt *ThreadLimit = nullptr;
- /// Set the ThreadLimit number.
- ///
- /// \param E ThreadLimit number.
- void setThreadLimit(Expr *E) { ThreadLimit = E; }
- public:
- /// Build 'thread_limit' clause.
- ///
- /// \param E Expression associated with this clause.
- /// \param HelperE Helper Expression associated with this clause.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPThreadLimitClause(Expr *E, Stmt *HelperE,
- OpenMPDirectiveKind CaptureRegion,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_thread_limit, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) {
- setPreInitStmt(HelperE, CaptureRegion);
- }
- /// Build an empty clause.
- OMPThreadLimitClause()
- : OMPClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
- SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return ThreadLimit number.
- Expr *getThreadLimit() { return cast<Expr>(ThreadLimit); }
- /// Return ThreadLimit number.
- Expr *getThreadLimit() const { return cast<Expr>(ThreadLimit); }
- child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); }
- const_child_range children() const {
- return const_child_range(&ThreadLimit, &ThreadLimit + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_thread_limit;
- }
- };
- /// This represents 'priority' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp task priority(n)
- /// \endcode
- /// In this example directive '#pragma omp teams' has clause 'priority' with
- /// single expression 'n'.
- class OMPPriorityClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Priority number.
- Stmt *Priority = nullptr;
- /// Set the Priority number.
- ///
- /// \param E Priority number.
- void setPriority(Expr *E) { Priority = E; }
- public:
- /// Build 'priority' clause.
- ///
- /// \param Priority Expression associated with this clause.
- /// \param HelperPriority Helper priority for the construct.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPPriorityClause(Expr *Priority, Stmt *HelperPriority,
- OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) {
- setPreInitStmt(HelperPriority, CaptureRegion);
- }
- /// Build an empty clause.
- OMPPriorityClause()
- : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return Priority number.
- Expr *getPriority() { return cast<Expr>(Priority); }
- /// Return Priority number.
- Expr *getPriority() const { return cast<Expr>(Priority); }
- child_range children() { return child_range(&Priority, &Priority + 1); }
- const_child_range children() const {
- return const_child_range(&Priority, &Priority + 1);
- }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPPriorityClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_priority;
- }
- };
- /// This represents 'grainsize' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp taskloop grainsize(4)
- /// \endcode
- /// In this example directive '#pragma omp taskloop' has clause 'grainsize'
- /// with single expression '4'.
- class OMPGrainsizeClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Modifiers for 'grainsize' clause.
- OpenMPGrainsizeClauseModifier Modifier = OMPC_GRAINSIZE_unknown;
- /// Location of the modifier.
- SourceLocation ModifierLoc;
- /// Safe iteration space distance.
- Stmt *Grainsize = nullptr;
- /// Set safelen.
- void setGrainsize(Expr *Size) { Grainsize = Size; }
- /// Sets modifier.
- void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; }
- /// Sets modifier location.
- void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
- public:
- /// Build 'grainsize' clause.
- ///
- /// \param Modifier Clause modifier.
- /// \param Size Expression associated with this clause.
- /// \param HelperSize Helper grainsize for the construct.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param ModifierLoc Modifier location.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size,
- Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ModifierLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
- ModifierLoc(ModifierLoc), Grainsize(Size) {
- setPreInitStmt(HelperSize, CaptureRegion);
- }
- /// Build an empty clause.
- explicit OMPGrainsizeClause()
- : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(),
- SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return safe iteration space distance.
- Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
- /// Gets modifier.
- OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; }
- /// Gets modifier location.
- SourceLocation getModifierLoc() const { return ModifierLoc; }
- child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
- const_child_range children() const {
- return const_child_range(&Grainsize, &Grainsize + 1);
- }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPGrainsizeClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_grainsize;
- }
- };
- /// This represents 'nogroup' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp taskloop nogroup
- /// \endcode
- /// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
- class OMPNogroupClause : public OMPClause {
- public:
- /// Build 'nogroup' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPNogroupClause()
- : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) {
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_nogroup;
- }
- };
- /// This represents 'num_tasks' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp taskloop num_tasks(4)
- /// \endcode
- /// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
- /// with single expression '4'.
- class OMPNumTasksClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Modifiers for 'num_tasks' clause.
- OpenMPNumTasksClauseModifier Modifier = OMPC_NUMTASKS_unknown;
- /// Location of the modifier.
- SourceLocation ModifierLoc;
- /// Safe iteration space distance.
- Stmt *NumTasks = nullptr;
- /// Set safelen.
- void setNumTasks(Expr *Size) { NumTasks = Size; }
- /// Sets modifier.
- void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; }
- /// Sets modifier location.
- void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
- public:
- /// Build 'num_tasks' clause.
- ///
- /// \param Modifier Clause modifier.
- /// \param Size Expression associated with this clause.
- /// \param HelperSize Helper grainsize for the construct.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- /// \param ModifierLoc Modifier location.
- /// \param LParenLoc Location of '('.
- OMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *Size,
- Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ModifierLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
- ModifierLoc(ModifierLoc), NumTasks(Size) {
- setPreInitStmt(HelperSize, CaptureRegion);
- }
- /// Build an empty clause.
- explicit OMPNumTasksClause()
- : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(),
- SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Return safe iteration space distance.
- Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
- /// Gets modifier.
- OpenMPNumTasksClauseModifier getModifier() const { return Modifier; }
- /// Gets modifier location.
- SourceLocation getModifierLoc() const { return ModifierLoc; }
- child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
- const_child_range children() const {
- return const_child_range(&NumTasks, &NumTasks + 1);
- }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPNumTasksClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_num_tasks;
- }
- };
- /// This represents 'hint' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp critical (name) hint(6)
- /// \endcode
- /// In this example directive '#pragma omp critical' has name 'name' and clause
- /// 'hint' with argument '6'.
- class OMPHintClause : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Hint expression of the 'hint' clause.
- Stmt *Hint = nullptr;
- /// Set hint expression.
- void setHint(Expr *H) { Hint = H; }
- public:
- /// Build 'hint' clause with expression \a Hint.
- ///
- /// \param Hint Hint expression.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
- Hint(Hint) {}
- /// Build an empty clause.
- OMPHintClause()
- : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns number of threads.
- Expr *getHint() const { return cast_or_null<Expr>(Hint); }
- child_range children() { return child_range(&Hint, &Hint + 1); }
- const_child_range children() const {
- return const_child_range(&Hint, &Hint + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_hint;
- }
- };
- /// This represents 'dist_schedule' clause in the '#pragma omp ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp distribute dist_schedule(static, 3)
- /// \endcode
- /// In this example directive '#pragma omp distribute' has 'dist_schedule'
- /// clause with arguments 'static' and '3'.
- class OMPDistScheduleClause : public OMPClause, public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// A kind of the 'schedule' clause.
- OpenMPDistScheduleClauseKind Kind = OMPC_DIST_SCHEDULE_unknown;
- /// Start location of the schedule kind in source code.
- SourceLocation KindLoc;
- /// Location of ',' (if any).
- SourceLocation CommaLoc;
- /// Chunk size.
- Expr *ChunkSize = nullptr;
- /// Set schedule kind.
- ///
- /// \param K Schedule kind.
- void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
- /// Sets the location of '('.
- ///
- /// \param Loc Location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Set schedule kind start location.
- ///
- /// \param KLoc Schedule kind location.
- void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
- /// Set location of ','.
- ///
- /// \param Loc Location of ','.
- void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
- /// Set chunk size.
- ///
- /// \param E Chunk size.
- void setChunkSize(Expr *E) { ChunkSize = E; }
- public:
- /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
- /// size expression \a ChunkSize.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param KLoc Starting location of the argument.
- /// \param CommaLoc Location of ','.
- /// \param EndLoc Ending location of the clause.
- /// \param Kind DistSchedule kind.
- /// \param ChunkSize Chunk size.
- /// \param HelperChunkSize Helper chunk size for combined directives.
- OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation KLoc, SourceLocation CommaLoc,
- SourceLocation EndLoc,
- OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
- Stmt *HelperChunkSize)
- : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc),
- OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
- KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
- setPreInitStmt(HelperChunkSize);
- }
- /// Build an empty clause.
- explicit OMPDistScheduleClause()
- : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(),
- SourceLocation()),
- OMPClauseWithPreInit(this) {}
- /// Get kind of the clause.
- OpenMPDistScheduleClauseKind getDistScheduleKind() const { return Kind; }
- /// Get location of '('.
- SourceLocation getLParenLoc() { return LParenLoc; }
- /// Get kind location.
- SourceLocation getDistScheduleKindLoc() { return KindLoc; }
- /// Get location of ','.
- SourceLocation getCommaLoc() { return CommaLoc; }
- /// Get chunk size.
- Expr *getChunkSize() { return ChunkSize; }
- /// Get chunk size.
- const Expr *getChunkSize() const { return ChunkSize; }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
- reinterpret_cast<Stmt **>(&ChunkSize) + 1);
- }
- const_child_range children() const {
- auto Children = const_cast<OMPDistScheduleClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_dist_schedule;
- }
- };
- /// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp target defaultmap(tofrom: scalar)
- /// \endcode
- /// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
- /// 'scalar' with modifier 'tofrom'.
- class OMPDefaultmapClause : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Modifiers for 'defaultmap' clause.
- OpenMPDefaultmapClauseModifier Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown;
- /// Locations of modifiers.
- SourceLocation ModifierLoc;
- /// A kind of the 'defaultmap' clause.
- OpenMPDefaultmapClauseKind Kind = OMPC_DEFAULTMAP_unknown;
- /// Start location of the defaultmap kind in source code.
- SourceLocation KindLoc;
- /// Set defaultmap kind.
- ///
- /// \param K Defaultmap kind.
- void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
- /// Set the defaultmap modifier.
- ///
- /// \param M Defaultmap modifier.
- void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
- Modifier = M;
- }
- /// Set location of the defaultmap modifier.
- void setDefaultmapModifierLoc(SourceLocation Loc) {
- ModifierLoc = Loc;
- }
- /// Sets the location of '('.
- ///
- /// \param Loc Location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Set defaultmap kind start location.
- ///
- /// \param KLoc Defaultmap kind location.
- void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
- public:
- /// Build 'defaultmap' clause with defaultmap kind \a Kind
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param KLoc Starting location of the argument.
- /// \param EndLoc Ending location of the clause.
- /// \param Kind Defaultmap kind.
- /// \param M The modifier applied to 'defaultmap' clause.
- /// \param MLoc Location of the modifier
- OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation MLoc, SourceLocation KLoc,
- SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind,
- OpenMPDefaultmapClauseModifier M)
- : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc),
- LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind),
- KindLoc(KLoc) {}
- /// Build an empty clause.
- explicit OMPDefaultmapClause()
- : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(),
- SourceLocation()) {}
- /// Get kind of the clause.
- OpenMPDefaultmapClauseKind getDefaultmapKind() const { return Kind; }
- /// Get the modifier of the clause.
- OpenMPDefaultmapClauseModifier getDefaultmapModifier() const {
- return Modifier;
- }
- /// Get location of '('.
- SourceLocation getLParenLoc() { return LParenLoc; }
- /// Get kind location.
- SourceLocation getDefaultmapKindLoc() { return KindLoc; }
- /// Get the modifier location.
- SourceLocation getDefaultmapModifierLoc() const {
- return ModifierLoc;
- }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_defaultmap;
- }
- };
- /// This represents clause 'to' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp target update to(a,b)
- /// \endcode
- /// In this example directive '#pragma omp target update' has clause 'to'
- /// with the variables 'a' and 'b'.
- class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
- private llvm::TrailingObjects<
- OMPToClause, Expr *, ValueDecl *, unsigned,
- OMPClauseMappableExprCommon::MappableComponent> {
- friend class OMPClauseReader;
- friend OMPMappableExprListClause;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Motion-modifiers for the 'to' clause.
- OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
- OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
- /// Location of motion-modifiers for the 'to' clause.
- SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
- /// Colon location.
- SourceLocation ColonLoc;
- /// Build clause with number of variables \a NumVars.
- ///
- /// \param TheMotionModifiers Motion-modifiers.
- /// \param TheMotionModifiersLoc Locations of motion-modifiers.
- /// \param MapperQualifierLoc C++ nested name specifier for the associated
- /// user-defined mapper.
- /// \param MapperIdInfo The identifier of associated user-defined mapper.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
- ArrayRef<SourceLocation> TheMotionModifiersLoc,
- NestedNameSpecifierLoc MapperQualifierLoc,
- DeclarationNameInfo MapperIdInfo,
- const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
- /*SupportsMapper=*/true, &MapperQualifierLoc,
- &MapperIdInfo) {
- assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
- "Unexpected number of motion modifiers.");
- llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
- assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
- "Unexpected number of motion modifier locations.");
- llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
- }
- /// Build an empty clause.
- ///
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
- /*SupportsMapper=*/true) {}
- /// Set motion-modifier for the clause.
- ///
- /// \param I index for motion-modifier.
- /// \param T motion-modifier for the clause.
- void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
- assert(I < NumberOfOMPMotionModifiers &&
- "Unexpected index to store motion modifier, exceeds array size.");
- MotionModifiers[I] = T;
- }
- /// Set location for the motion-modifier.
- ///
- /// \param I index for motion-modifier location.
- /// \param TLoc motion-modifier location.
- void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
- assert(I < NumberOfOMPMotionModifiers &&
- "Index to store motion modifier location exceeds array size.");
- MotionModifiersLoc[I] = TLoc;
- }
- /// Set colon location.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- // There are varlist_size() of expressions, and varlist_size() of
- // user-defined mappers.
- return 2 * varlist_size();
- }
- size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
- return getUniqueDeclarationsNum();
- }
- size_t numTrailingObjects(OverloadToken<unsigned>) const {
- return getUniqueDeclarationsNum() + getTotalComponentListNum();
- }
- public:
- /// Creates clause with a list of variables \a Vars.
- ///
- /// \param C AST context.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Vars The original expression used in the clause.
- /// \param Declarations Declarations used in the clause.
- /// \param ComponentLists Component lists used in the clause.
- /// \param MotionModifiers Motion-modifiers.
- /// \param MotionModifiersLoc Location of motion-modifiers.
- /// \param UDMapperRefs References to user-defined mappers associated with
- /// expressions used in the clause.
- /// \param UDMQualifierLoc C++ nested name specifier for the associated
- /// user-defined mapper.
- /// \param MapperId The identifier of associated user-defined mapper.
- static OMPToClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> Vars,
- ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists,
- ArrayRef<Expr *> UDMapperRefs,
- ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
- ArrayRef<SourceLocation> MotionModifiersLoc,
- NestedNameSpecifierLoc UDMQualifierLoc,
- DeclarationNameInfo MapperId);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- static OMPToClause *CreateEmpty(const ASTContext &C,
- const OMPMappableExprListSizeTy &Sizes);
- /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
- ///
- /// \param Cnt index for motion-modifier.
- OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
- assert(Cnt < NumberOfOMPMotionModifiers &&
- "Requested modifier exceeds the total number of modifiers.");
- return MotionModifiers[Cnt];
- }
- /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
- /// locations.
- ///
- /// \param Cnt index for motion-modifier location.
- SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
- assert(Cnt < NumberOfOMPMotionModifiers &&
- "Requested modifier location exceeds total number of modifiers.");
- return MotionModifiersLoc[Cnt];
- }
- /// Fetches ArrayRef of motion-modifiers.
- ArrayRef<OpenMPMotionModifierKind> getMotionModifiers() const LLVM_READONLY {
- return llvm::ArrayRef(MotionModifiers);
- }
- /// Fetches ArrayRef of location of motion-modifiers.
- ArrayRef<SourceLocation> getMotionModifiersLoc() const LLVM_READONLY {
- return llvm::ArrayRef(MotionModifiersLoc);
- }
- /// Get colon location.
- SourceLocation getColonLoc() const { return ColonLoc; }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPToClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_to;
- }
- };
- /// This represents clause 'from' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp target update from(a,b)
- /// \endcode
- /// In this example directive '#pragma omp target update' has clause 'from'
- /// with the variables 'a' and 'b'.
- class OMPFromClause final
- : public OMPMappableExprListClause<OMPFromClause>,
- private llvm::TrailingObjects<
- OMPFromClause, Expr *, ValueDecl *, unsigned,
- OMPClauseMappableExprCommon::MappableComponent> {
- friend class OMPClauseReader;
- friend OMPMappableExprListClause;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Motion-modifiers for the 'from' clause.
- OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
- OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
- /// Location of motion-modifiers for the 'from' clause.
- SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
- /// Colon location.
- SourceLocation ColonLoc;
- /// Build clause with number of variables \a NumVars.
- ///
- /// \param TheMotionModifiers Motion-modifiers.
- /// \param TheMotionModifiersLoc Locations of motion-modifiers.
- /// \param MapperQualifierLoc C++ nested name specifier for the associated
- /// user-defined mapper.
- /// \param MapperIdInfo The identifier of associated user-defined mapper.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
- ArrayRef<SourceLocation> TheMotionModifiersLoc,
- NestedNameSpecifierLoc MapperQualifierLoc,
- DeclarationNameInfo MapperIdInfo,
- const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes,
- /*SupportsMapper=*/true, &MapperQualifierLoc,
- &MapperIdInfo) {
- assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
- "Unexpected number of motion modifiers.");
- llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
- assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
- "Unexpected number of motion modifier locations.");
- llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
- }
- /// Build an empty clause.
- ///
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(),
- Sizes, /*SupportsMapper=*/true) {}
- /// Set motion-modifier for the clause.
- ///
- /// \param I index for motion-modifier.
- /// \param T motion-modifier for the clause.
- void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
- assert(I < NumberOfOMPMotionModifiers &&
- "Unexpected index to store motion modifier, exceeds array size.");
- MotionModifiers[I] = T;
- }
- /// Set location for the motion-modifier.
- ///
- /// \param I index for motion-modifier location.
- /// \param TLoc motion-modifier location.
- void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
- assert(I < NumberOfOMPMotionModifiers &&
- "Index to store motion modifier location exceeds array size.");
- MotionModifiersLoc[I] = TLoc;
- }
- /// Set colon location.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- // There are varlist_size() of expressions, and varlist_size() of
- // user-defined mappers.
- return 2 * varlist_size();
- }
- size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
- return getUniqueDeclarationsNum();
- }
- size_t numTrailingObjects(OverloadToken<unsigned>) const {
- return getUniqueDeclarationsNum() + getTotalComponentListNum();
- }
- public:
- /// Creates clause with a list of variables \a Vars.
- ///
- /// \param C AST context.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Vars The original expression used in the clause.
- /// \param Declarations Declarations used in the clause.
- /// \param ComponentLists Component lists used in the clause.
- /// \param MotionModifiers Motion-modifiers.
- /// \param MotionModifiersLoc Location of motion-modifiers.
- /// \param UDMapperRefs References to user-defined mappers associated with
- /// expressions used in the clause.
- /// \param UDMQualifierLoc C++ nested name specifier for the associated
- /// user-defined mapper.
- /// \param MapperId The identifier of associated user-defined mapper.
- static OMPFromClause *
- Create(const ASTContext &C, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists,
- ArrayRef<Expr *> UDMapperRefs,
- ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
- ArrayRef<SourceLocation> MotionModifiersLoc,
- NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- static OMPFromClause *CreateEmpty(const ASTContext &C,
- const OMPMappableExprListSizeTy &Sizes);
- /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
- ///
- /// \param Cnt index for motion-modifier.
- OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
- assert(Cnt < NumberOfOMPMotionModifiers &&
- "Requested modifier exceeds the total number of modifiers.");
- return MotionModifiers[Cnt];
- }
- /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
- /// locations.
- ///
- /// \param Cnt index for motion-modifier location.
- SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
- assert(Cnt < NumberOfOMPMotionModifiers &&
- "Requested modifier location exceeds total number of modifiers.");
- return MotionModifiersLoc[Cnt];
- }
- /// Fetches ArrayRef of motion-modifiers.
- ArrayRef<OpenMPMotionModifierKind> getMotionModifiers() const LLVM_READONLY {
- return llvm::ArrayRef(MotionModifiers);
- }
- /// Fetches ArrayRef of location of motion-modifiers.
- ArrayRef<SourceLocation> getMotionModifiersLoc() const LLVM_READONLY {
- return llvm::ArrayRef(MotionModifiersLoc);
- }
- /// Get colon location.
- SourceLocation getColonLoc() const { return ColonLoc; }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPFromClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_from;
- }
- };
- /// This represents clause 'use_device_ptr' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp target data use_device_ptr(a,b)
- /// \endcode
- /// In this example directive '#pragma omp target data' has clause
- /// 'use_device_ptr' with the variables 'a' and 'b'.
- class OMPUseDevicePtrClause final
- : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
- private llvm::TrailingObjects<
- OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
- OMPClauseMappableExprCommon::MappableComponent> {
- friend class OMPClauseReader;
- friend OMPMappableExprListClause;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a NumVars.
- ///
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) {
- }
- /// Build an empty clause.
- ///
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPUseDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr,
- OMPVarListLocTy(), Sizes) {}
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- return 3 * varlist_size();
- }
- size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
- return getUniqueDeclarationsNum();
- }
- size_t numTrailingObjects(OverloadToken<unsigned>) const {
- return getUniqueDeclarationsNum() + getTotalComponentListNum();
- }
- /// Sets the list of references to private copies with initializers for new
- /// private variables.
- /// \param VL List of references.
- void setPrivateCopies(ArrayRef<Expr *> VL);
- /// Gets the list of references to private copies with initializers for new
- /// private variables.
- MutableArrayRef<Expr *> getPrivateCopies() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivateCopies() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- /// Sets the list of references to initializer variables for new private
- /// variables.
- /// \param VL List of references.
- void setInits(ArrayRef<Expr *> VL);
- /// Gets the list of references to initializer variables for new private
- /// variables.
- MutableArrayRef<Expr *> getInits() {
- return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
- }
- ArrayRef<const Expr *> getInits() const {
- return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a Vars.
- ///
- /// \param C AST context.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Vars The original expression used in the clause.
- /// \param PrivateVars Expressions referring to private copies.
- /// \param Inits Expressions referring to private copy initializers.
- /// \param Declarations Declarations used in the clause.
- /// \param ComponentLists Component lists used in the clause.
- static OMPUseDevicePtrClause *
- Create(const ASTContext &C, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
- ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- static OMPUseDevicePtrClause *
- CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
- using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
- using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
- using private_copies_range = llvm::iterator_range<private_copies_iterator>;
- using private_copies_const_range =
- llvm::iterator_range<private_copies_const_iterator>;
- private_copies_range private_copies() {
- return private_copies_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- private_copies_const_range private_copies() const {
- return private_copies_const_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
- using inits_iterator = MutableArrayRef<Expr *>::iterator;
- using inits_const_iterator = ArrayRef<const Expr *>::iterator;
- using inits_range = llvm::iterator_range<inits_iterator>;
- using inits_const_range = llvm::iterator_range<inits_const_iterator>;
- inits_range inits() {
- return inits_range(getInits().begin(), getInits().end());
- }
- inits_const_range inits() const {
- return inits_const_range(getInits().begin(), getInits().end());
- }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr;
- }
- };
- /// This represents clause 'use_device_addr' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp target data use_device_addr(a,b)
- /// \endcode
- /// In this example directive '#pragma omp target data' has clause
- /// 'use_device_addr' with the variables 'a' and 'b'.
- class OMPUseDeviceAddrClause final
- : public OMPMappableExprListClause<OMPUseDeviceAddrClause>,
- private llvm::TrailingObjects<
- OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned,
- OMPClauseMappableExprCommon::MappableComponent> {
- friend class OMPClauseReader;
- friend OMPMappableExprListClause;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a NumVars.
- ///
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs,
- Sizes) {}
- /// Build an empty clause.
- ///
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPUseDeviceAddrClause(const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr,
- OMPVarListLocTy(), Sizes) {}
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- return varlist_size();
- }
- size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
- return getUniqueDeclarationsNum();
- }
- size_t numTrailingObjects(OverloadToken<unsigned>) const {
- return getUniqueDeclarationsNum() + getTotalComponentListNum();
- }
- public:
- /// Creates clause with a list of variables \a Vars.
- ///
- /// \param C AST context.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Vars The original expression used in the clause.
- /// \param Declarations Declarations used in the clause.
- /// \param ComponentLists Component lists used in the clause.
- static OMPUseDeviceAddrClause *
- Create(const ASTContext &C, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- static OMPUseDeviceAddrClause *
- CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPUseDeviceAddrClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_use_device_addr;
- }
- };
- /// This represents clause 'is_device_ptr' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp target is_device_ptr(a,b)
- /// \endcode
- /// In this example directive '#pragma omp target' has clause
- /// 'is_device_ptr' with the variables 'a' and 'b'.
- class OMPIsDevicePtrClause final
- : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
- private llvm::TrailingObjects<
- OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
- OMPClauseMappableExprCommon::MappableComponent> {
- friend class OMPClauseReader;
- friend OMPMappableExprListClause;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a NumVars.
- ///
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {}
- /// Build an empty clause.
- ///
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr,
- OMPVarListLocTy(), Sizes) {}
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- return varlist_size();
- }
- size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
- return getUniqueDeclarationsNum();
- }
- size_t numTrailingObjects(OverloadToken<unsigned>) const {
- return getUniqueDeclarationsNum() + getTotalComponentListNum();
- }
- public:
- /// Creates clause with a list of variables \a Vars.
- ///
- /// \param C AST context.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Vars The original expression used in the clause.
- /// \param Declarations Declarations used in the clause.
- /// \param ComponentLists Component lists used in the clause.
- static OMPIsDevicePtrClause *
- Create(const ASTContext &C, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- static OMPIsDevicePtrClause *
- CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr;
- }
- };
- /// This represents clause 'has_device_ptr' in the '#pragma omp ...'
- /// directives.
- ///
- /// \code
- /// #pragma omp target has_device_addr(a,b)
- /// \endcode
- /// In this example directive '#pragma omp target' has clause
- /// 'has_device_ptr' with the variables 'a' and 'b'.
- class OMPHasDeviceAddrClause final
- : public OMPMappableExprListClause<OMPHasDeviceAddrClause>,
- private llvm::TrailingObjects<
- OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned,
- OMPClauseMappableExprCommon::MappableComponent> {
- friend class OMPClauseReader;
- friend OMPMappableExprListClause;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a NumVars.
- ///
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs,
- const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
- Sizes) {}
- /// Build an empty clause.
- ///
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- explicit OMPHasDeviceAddrClause(const OMPMappableExprListSizeTy &Sizes)
- : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
- OMPVarListLocTy(), Sizes) {}
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- return varlist_size();
- }
- size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
- return getUniqueDeclarationsNum();
- }
- size_t numTrailingObjects(OverloadToken<unsigned>) const {
- return getUniqueDeclarationsNum() + getTotalComponentListNum();
- }
- public:
- /// Creates clause with a list of variables \a Vars.
- ///
- /// \param C AST context.
- /// \param Locs Locations needed to build a mappable clause. It includes 1)
- /// StartLoc: starting location of the clause (the clause keyword); 2)
- /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
- /// \param Vars The original expression used in the clause.
- /// \param Declarations Declarations used in the clause.
- /// \param ComponentLists Component lists used in the clause.
- static OMPHasDeviceAddrClause *
- Create(const ASTContext &C, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
- MappableExprComponentListsRef ComponentLists);
- /// Creates an empty clause with the place for \a NumVars variables.
- ///
- /// \param C AST context.
- /// \param Sizes All required sizes to build a mappable clause. It includes 1)
- /// NumVars: number of expressions listed in this clause; 2)
- /// NumUniqueDeclarations: number of unique base declarations in this clause;
- /// 3) NumComponentLists: number of component lists in this clause; and 4)
- /// NumComponents: total number of expression components in the clause.
- static OMPHasDeviceAddrClause *
- CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPHasDeviceAddrClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
- }
- };
- /// This represents clause 'nontemporal' in the '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp simd nontemporal(a)
- /// \endcode
- /// In this example directive '#pragma omp simd' has clause 'nontemporal' for
- /// the variable 'a'.
- class OMPNontemporalClause final
- : public OMPVarListClause<OMPNontemporalClause>,
- private llvm::TrailingObjects<OMPNontemporalClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPNontemporalClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal,
- StartLoc, LParenLoc, EndLoc, N) {
- }
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPNontemporalClause(unsigned N)
- : OMPVarListClause<OMPNontemporalClause>(
- llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- /// Get the list of privatied copies if the member expression was captured by
- /// one of the privatization clauses.
- MutableArrayRef<Expr *> getPrivateRefs() {
- return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
- }
- ArrayRef<const Expr *> getPrivateRefs() const {
- return llvm::ArrayRef(varlist_end(), varlist_size());
- }
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the variables.
- static OMPNontemporalClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N);
- /// Sets the list of references to private copies created in private clauses.
- /// \param VL List of references.
- void setPrivateRefs(ArrayRef<Expr *> VL);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPNontemporalClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range private_refs() {
- return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()),
- reinterpret_cast<Stmt **>(getPrivateRefs().end()));
- }
- const_child_range private_refs() const {
- auto Children = const_cast<OMPNontemporalClause *>(this)->private_refs();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_nontemporal;
- }
- };
- /// This represents 'order' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp simd order(concurrent)
- /// \endcode
- /// In this example directive '#pragma omp parallel' has simple 'order'
- /// clause with kind 'concurrent'.
- class OMPOrderClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// A kind of the 'order' clause.
- OpenMPOrderClauseKind Kind = OMPC_ORDER_unknown;
- /// Start location of the kind in source code.
- SourceLocation KindKwLoc;
- /// A modifier for order clause
- OpenMPOrderClauseModifier Modifier = OMPC_ORDER_MODIFIER_unknown;
- /// Start location of the modifier in source code.
- SourceLocation ModifierKwLoc;
- /// Set kind of the clause.
- ///
- /// \param K Argument of clause.
- void setKind(OpenMPOrderClauseKind K) { Kind = K; }
- /// Set argument location.
- ///
- /// \param KLoc Argument location.
- void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
- /// Set modifier of the clause.
- ///
- /// \param M Argument of clause.
- void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; }
- /// Set modifier location.
- ///
- /// \param MLoc Modifier keyword location.
- void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; }
- public:
- /// Build 'order' clause with argument \p A ('concurrent').
- ///
- /// \param A Argument of the clause ('concurrent').
- /// \param ALoc Starting location of the argument.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param Modifier The modifier applied to 'order' clause.
- /// \param MLoc Location of the modifier
- OMPOrderClause(OpenMPOrderClauseKind A, SourceLocation ALoc,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, OpenMPOrderClauseModifier M,
- SourceLocation MLoc)
- : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc),
- LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(M),
- ModifierKwLoc(MLoc) {}
- /// Build an empty clause.
- OMPOrderClause()
- : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {}
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns kind of the clause.
- OpenMPOrderClauseKind getKind() const { return Kind; }
- /// Returns location of clause kind.
- SourceLocation getKindKwLoc() const { return KindKwLoc; }
- /// Returns Modifier of the clause.
- OpenMPOrderClauseModifier getModifier() const { return Modifier; }
- /// Returns location of clause modifier.
- SourceLocation getModifierKwLoc() const { return ModifierKwLoc; }
- child_range children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_order;
- }
- };
- /// This represents the 'init' clause in '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp interop init(target:obj)
- /// \endcode
- class OMPInitClause final
- : public OMPVarListClause<OMPInitClause>,
- private llvm::TrailingObjects<OMPInitClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Location of interop variable.
- SourceLocation VarLoc;
- bool IsTarget = false;
- bool IsTargetSync = false;
- void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
- void setIsTarget(bool V) { IsTarget = V; }
- void setIsTargetSync(bool V) { IsTargetSync = V; }
- /// Sets the location of the interop variable.
- void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
- /// Build 'init' clause.
- ///
- /// \param IsTarget Uses the 'target' interop-type.
- /// \param IsTargetSync Uses the 'targetsync' interop-type.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param VarLoc Location of the interop variable.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of expressions.
- OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation VarLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
- LParenLoc, EndLoc, N),
- VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
- /// Build an empty clause.
- OMPInitClause(unsigned N)
- : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
- SourceLocation(), SourceLocation(), N) {
- }
- public:
- /// Creates a fully specified clause.
- ///
- /// \param C AST context.
- /// \param InteropVar The interop variable.
- /// \param InteropInfo The interop-type and prefer_type list.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param VarLoc Location of the interop variable.
- /// \param EndLoc Ending location of the clause.
- static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
- OMPInteropInfo &InteropInfo,
- SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation VarLoc,
- SourceLocation EndLoc);
- /// Creates an empty clause with \a N expressions.
- ///
- /// \param C AST context.
- /// \param N Number of expression items.
- static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
- /// Returns the location of the interop variable.
- SourceLocation getVarLoc() const { return VarLoc; }
- /// Returns the interop variable.
- Expr *getInteropVar() { return varlist_begin()[0]; }
- const Expr *getInteropVar() const { return varlist_begin()[0]; }
- /// Returns true is interop-type 'target' is used.
- bool getIsTarget() const { return IsTarget; }
- /// Returns true is interop-type 'targetsync' is used.
- bool getIsTargetSync() const { return IsTargetSync; }
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPInitClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- using prefs_iterator = MutableArrayRef<Expr *>::iterator;
- using const_prefs_iterator = ArrayRef<const Expr *>::iterator;
- using prefs_range = llvm::iterator_range<prefs_iterator>;
- using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
- prefs_range prefs() {
- return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
- reinterpret_cast<Expr **>(varlist_end()));
- }
- const_prefs_range prefs() const {
- auto Prefs = const_cast<OMPInitClause *>(this)->prefs();
- return const_prefs_range(Prefs.begin(), Prefs.end());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_init;
- }
- };
- /// This represents the 'use' clause in '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp interop use(obj)
- /// \endcode
- class OMPUseClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Location of interop variable.
- SourceLocation VarLoc;
- /// The interop variable.
- Stmt *InteropVar = nullptr;
- /// Set the interop variable.
- void setInteropVar(Expr *E) { InteropVar = E; }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Sets the location of the interop variable.
- void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
- public:
- /// Build 'use' clause with and interop variable expression \a InteropVar.
- ///
- /// \param InteropVar The interop variable.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param VarLoc Location of the interop variable.
- /// \param EndLoc Ending location of the clause.
- OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation VarLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
- VarLoc(VarLoc), InteropVar(InteropVar) {}
- /// Build an empty clause.
- OMPUseClause()
- : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns the location of the interop variable.
- SourceLocation getVarLoc() const { return VarLoc; }
- /// Returns the interop variable.
- Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
- child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
- const_child_range children() const {
- return const_child_range(&InteropVar, &InteropVar + 1);
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_use;
- }
- };
- /// This represents 'destroy' clause in the '#pragma omp depobj'
- /// directive or the '#pragma omp interop' directive..
- ///
- /// \code
- /// #pragma omp depobj(a) destroy
- /// #pragma omp interop destroy(obj)
- /// \endcode
- /// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
- /// have a 'destroy' clause. The 'interop' directive includes an object.
- class OMPDestroyClause final : public OMPClause {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Location of interop variable.
- SourceLocation VarLoc;
- /// The interop variable.
- Stmt *InteropVar = nullptr;
- /// Set the interop variable.
- void setInteropVar(Expr *E) { InteropVar = E; }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Sets the location of the interop variable.
- void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
- public:
- /// Build 'destroy' clause with an interop variable expression \a InteropVar.
- ///
- /// \param InteropVar The interop variable.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param VarLoc Location of the interop variable.
- /// \param EndLoc Ending location of the clause.
- OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation VarLoc,
- SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
- LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
- /// Build 'destroy' clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param EndLoc Ending location of the clause.
- OMPDestroyClause(SourceLocation StartLoc, SourceLocation EndLoc)
- : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {}
- /// Build an empty clause.
- OMPDestroyClause()
- : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
- }
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns the location of the interop variable.
- SourceLocation getVarLoc() const { return VarLoc; }
- /// Returns the interop variable.
- Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
- child_range children() {
- if (InteropVar)
- return child_range(&InteropVar, &InteropVar + 1);
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range children() const {
- if (InteropVar)
- return const_child_range(&InteropVar, &InteropVar + 1);
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_destroy;
- }
- };
- /// This represents 'novariants' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp dispatch novariants(a > 5)
- /// \endcode
- /// In this example directive '#pragma omp dispatch' has simple 'novariants'
- /// clause with condition 'a > 5'.
- class OMPNovariantsClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>,
- public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Set condition.
- void setCondition(Expr *Cond) { setStmt(Cond); }
- public:
- /// Build 'novariants' clause with condition \a Cond.
- ///
- /// \param Cond Condition of the clause.
- /// \param HelperCond Helper condition for the construct.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPNovariantsClause(Expr *Cond, Stmt *HelperCond,
- OpenMPDirectiveKind CaptureRegion,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
- OMPClauseWithPreInit(this) {
- setPreInitStmt(HelperCond, CaptureRegion);
- }
- /// Build an empty clause.
- OMPNovariantsClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {}
- /// Returns condition.
- Expr *getCondition() const { return getStmtAs<Expr>(); }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPNovariantsClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- };
- /// This represents 'nocontext' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp dispatch nocontext(a > 5)
- /// \endcode
- /// In this example directive '#pragma omp dispatch' has simple 'nocontext'
- /// clause with condition 'a > 5'.
- class OMPNocontextClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>,
- public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Set condition.
- void setCondition(Expr *Cond) { setStmt(Cond); }
- public:
- /// Build 'nocontext' clause with condition \a Cond.
- ///
- /// \param Cond Condition of the clause.
- /// \param HelperCond Helper condition for the construct.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPNocontextClause(Expr *Cond, Stmt *HelperCond,
- OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc)
- : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
- OMPClauseWithPreInit(this) {
- setPreInitStmt(HelperCond, CaptureRegion);
- }
- /// Build an empty clause.
- OMPNocontextClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {}
- /// Returns condition.
- Expr *getCondition() const { return getStmtAs<Expr>(); }
- child_range used_children();
- const_child_range used_children() const {
- auto Children = const_cast<OMPNocontextClause *>(this)->used_children();
- return const_child_range(Children.begin(), Children.end());
- }
- };
- /// This represents 'detach' clause in the '#pragma omp task' directive.
- ///
- /// \code
- /// #pragma omp task detach(evt)
- /// \endcode
- /// In this example directive '#pragma omp detach' has simple 'detach' clause
- /// with the variable 'evt'.
- class OMPDetachClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> {
- friend class OMPClauseReader;
- /// Set condition.
- void setEventHandler(Expr *E) { setStmt(E); }
- public:
- /// Build 'detach' clause with event-handler \a Evt.
- ///
- /// \param Evt Event handler expression.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {}
- /// Build an empty clause.
- OMPDetachClause() : OMPOneStmtClause() {}
- /// Returns event-handler expression.
- Expr *getEventHandler() const { return getStmtAs<Expr>(); }
- };
- /// This represents clause 'inclusive' in the '#pragma omp scan' directive.
- ///
- /// \code
- /// #pragma omp scan inclusive(a,b)
- /// \endcode
- /// In this example directive '#pragma omp scan' has clause 'inclusive'
- /// with the variables 'a' and 'b'.
- class OMPInclusiveClause final
- : public OMPVarListClause<OMPInclusiveClause>,
- private llvm::TrailingObjects<OMPInclusiveClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPInclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
- StartLoc, LParenLoc, EndLoc, N) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPInclusiveClause(unsigned N)
- : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the original variables.
- static OMPInclusiveClause *Create(const ASTContext &C,
- SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPInclusiveClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_inclusive;
- }
- };
- /// This represents clause 'exclusive' in the '#pragma omp scan' directive.
- ///
- /// \code
- /// #pragma omp scan exclusive(a,b)
- /// \endcode
- /// In this example directive '#pragma omp scan' has clause 'exclusive'
- /// with the variables 'a' and 'b'.
- class OMPExclusiveClause final
- : public OMPVarListClause<OMPExclusiveClause>,
- private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Build clause with number of variables \a N.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of the variables in the clause.
- OMPExclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
- StartLoc, LParenLoc, EndLoc, N) {}
- /// Build an empty clause.
- ///
- /// \param N Number of variables.
- explicit OMPExclusiveClause(unsigned N)
- : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- public:
- /// Creates clause with a list of variables \a VL.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param VL List of references to the original variables.
- static OMPExclusiveClause *Create(const ASTContext &C,
- SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<Expr *> VL);
- /// Creates an empty clause with the place for \a N variables.
- ///
- /// \param C AST context.
- /// \param N The number of variables.
- static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
- child_range children() {
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end()));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPExclusiveClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_exclusive;
- }
- };
- /// This represents clause 'uses_allocators' in the '#pragma omp target'-based
- /// directives.
- ///
- /// \code
- /// #pragma omp target uses_allocators(default_allocator, my_allocator(traits))
- /// \endcode
- /// In this example directive '#pragma omp target' has clause 'uses_allocators'
- /// with the allocators 'default_allocator' and user-defined 'my_allocator'.
- class OMPUsesAllocatorsClause final
- : public OMPClause,
- private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *,
- SourceLocation> {
- public:
- /// Data for list of allocators.
- struct Data {
- /// Allocator.
- Expr *Allocator = nullptr;
- /// Allocator traits.
- Expr *AllocatorTraits = nullptr;
- /// Locations of '(' and ')' symbols.
- SourceLocation LParenLoc, RParenLoc;
- };
- private:
- friend class OMPClauseReader;
- friend TrailingObjects;
- enum class ExprOffsets {
- Allocator,
- AllocatorTraits,
- Total,
- };
- enum class ParenLocsOffsets {
- LParen,
- RParen,
- Total,
- };
- /// Location of '('.
- SourceLocation LParenLoc;
- /// Total number of allocators in the clause.
- unsigned NumOfAllocators = 0;
- /// Build clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of allocators associated with the clause.
- OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, unsigned N)
- : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc),
- LParenLoc(LParenLoc), NumOfAllocators(N) {}
- /// Build an empty clause.
- /// \param N Number of allocators associated with the clause.
- ///
- explicit OMPUsesAllocatorsClause(unsigned N)
- : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(),
- SourceLocation()),
- NumOfAllocators(N) {}
- unsigned numTrailingObjects(OverloadToken<Expr *>) const {
- return NumOfAllocators * static_cast<int>(ExprOffsets::Total);
- }
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Sets the allocators data for the clause.
- void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data);
- public:
- /// Creates clause with a list of allocators \p Data.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- /// \param Data List of allocators.
- static OMPUsesAllocatorsClause *
- Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data);
- /// Creates an empty clause with the place for \p N allocators.
- ///
- /// \param C AST context.
- /// \param N The number of allocators.
- static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N);
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns number of allocators associated with the clause.
- unsigned getNumberOfAllocators() const { return NumOfAllocators; }
- /// Returns data for the specified allocator.
- OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const;
- // Iterators
- child_range children() {
- Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
- return child_range(Begin, Begin + NumOfAllocators *
- static_cast<int>(ExprOffsets::Total));
- }
- const_child_range children() const {
- Stmt *const *Begin =
- reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
- return const_child_range(
- Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total));
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_uses_allocators;
- }
- };
- /// This represents clause 'affinity' in the '#pragma omp task'-based
- /// directives.
- ///
- /// \code
- /// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
- /// \endcode
- /// In this example directive '#pragma omp task' has clause 'affinity' with the
- /// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
- /// and 'c[i]'.
- class OMPAffinityClause final
- : public OMPVarListClause<OMPAffinityClause>,
- private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
- friend class OMPClauseReader;
- friend OMPVarListClause;
- friend TrailingObjects;
- /// Location of ':' symbol.
- SourceLocation ColonLoc;
- /// Build clause.
- ///
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param N Number of locators associated with the clause.
- OMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
- : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
- LParenLoc, EndLoc, N) {}
- /// Build an empty clause.
- /// \param N Number of locators associated with the clause.
- ///
- explicit OMPAffinityClause(unsigned N)
- : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
- SourceLocation(), SourceLocation(),
- SourceLocation(), N) {}
- /// Sets the affinity modifier for the clause, if any.
- void setModifier(Expr *E) {
- getTrailingObjects<Expr *>()[varlist_size()] = E;
- }
- /// Sets the location of ':' symbol.
- void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
- public:
- /// Creates clause with a modifier a list of locator items.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param ColonLoc Location of ':'.
- /// \param EndLoc Ending location of the clause.
- /// \param Locators List of locator items.
- static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation LParenLoc,
- SourceLocation ColonLoc,
- SourceLocation EndLoc, Expr *Modifier,
- ArrayRef<Expr *> Locators);
- /// Creates an empty clause with the place for \p N locator items.
- ///
- /// \param C AST context.
- /// \param N The number of locator items.
- static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N);
- /// Gets affinity modifier.
- Expr *getModifier() { return getTrailingObjects<Expr *>()[varlist_size()]; }
- Expr *getModifier() const {
- return getTrailingObjects<Expr *>()[varlist_size()];
- }
- /// Gets the location of ':' symbol.
- SourceLocation getColonLoc() const { return ColonLoc; }
- // Iterators
- child_range children() {
- int Offset = getModifier() ? 1 : 0;
- return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
- reinterpret_cast<Stmt **>(varlist_end() + Offset));
- }
- const_child_range children() const {
- auto Children = const_cast<OMPAffinityClause *>(this)->children();
- return const_child_range(Children.begin(), Children.end());
- }
- child_range used_children() {
- return child_range(child_iterator(), child_iterator());
- }
- const_child_range used_children() const {
- return const_child_range(const_child_iterator(), const_child_iterator());
- }
- static bool classof(const OMPClause *T) {
- return T->getClauseKind() == llvm::omp::OMPC_affinity;
- }
- };
- /// This represents 'filter' clause in the '#pragma omp ...' directive.
- ///
- /// \code
- /// #pragma omp masked filter(tid)
- /// \endcode
- /// In this example directive '#pragma omp masked' has 'filter' clause with
- /// thread id.
- class OMPFilterClause final
- : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>,
- public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Sets the thread identifier.
- void setThreadID(Expr *TID) { setStmt(TID); }
- public:
- /// Build 'filter' clause with thread-id \a ThreadID.
- ///
- /// \param ThreadID Thread identifier.
- /// \param HelperE Helper expression associated with this clause.
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// clause must be captured.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
- OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc)
- : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc),
- OMPClauseWithPreInit(this) {
- setPreInitStmt(HelperE, CaptureRegion);
- }
- /// Build an empty clause.
- OMPFilterClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {}
- /// Return thread identifier.
- Expr *getThreadID() const { return getStmtAs<Expr>(); }
- /// Return thread identifier.
- Expr *getThreadID() { return getStmtAs<Expr>(); }
- };
- /// This represents 'bind' clause in the '#pragma omp ...' directives.
- ///
- /// \code
- /// #pragma omp loop bind(parallel)
- /// \endcode
- class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> {
- friend class OMPClauseReader;
- /// Location of '('.
- SourceLocation LParenLoc;
- /// The binding kind of 'bind' clause.
- OpenMPBindClauseKind Kind = OMPC_BIND_unknown;
- /// Start location of the kind in source code.
- SourceLocation KindLoc;
- /// Sets the location of '('.
- void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
- /// Set the binding kind.
- void setBindKind(OpenMPBindClauseKind K) { Kind = K; }
- /// Set the binding kind location.
- void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
- /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
- ///
- /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
- /// \param KLoc Starting location of the binding kind.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K),
- KindLoc(KLoc) {}
- /// Build an empty clause.
- OMPBindClause() : OMPNoChildClause() {}
- public:
- /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
- ///
- /// \param C AST context
- /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
- /// \param KLoc Starting location of the binding kind.
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K,
- SourceLocation KLoc, SourceLocation StartLoc,
- SourceLocation LParenLoc, SourceLocation EndLoc);
- /// Build an empty 'bind' clause.
- ///
- /// \param C AST context
- static OMPBindClause *CreateEmpty(const ASTContext &C);
- /// Returns the location of '('.
- SourceLocation getLParenLoc() const { return LParenLoc; }
- /// Returns kind of the clause.
- OpenMPBindClauseKind getBindKind() const { return Kind; }
- /// Returns location of clause kind.
- SourceLocation getBindKindLoc() const { return KindLoc; }
- };
- /// This class implements a simple visitor for OMPClause
- /// subclasses.
- template<class ImplClass, template <typename> class Ptr, typename RetTy>
- class OMPClauseVisitorBase {
- public:
- #define PTR(CLASS) Ptr<CLASS>
- #define DISPATCH(CLASS) \
- return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
- #define GEN_CLANG_CLAUSE_CLASS
- #define CLAUSE_CLASS(Enum, Str, Class) \
- RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
- #include "llvm/Frontend/OpenMP/OMP.inc"
- RetTy Visit(PTR(OMPClause) S) {
- // Top switch clause: visit each OMPClause.
- switch (S->getClauseKind()) {
- #define GEN_CLANG_CLAUSE_CLASS
- #define CLAUSE_CLASS(Enum, Str, Class) \
- case llvm::omp::Clause::Enum: \
- return Visit##Class(static_cast<PTR(Class)>(S));
- #define CLAUSE_NO_CLASS(Enum, Str) \
- case llvm::omp::Clause::Enum: \
- break;
- #include "llvm/Frontend/OpenMP/OMP.inc"
- }
- }
- // Base case, ignore it. :)
- RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
- #undef PTR
- #undef DISPATCH
- };
- template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
- template <class ImplClass, typename RetTy = void>
- class OMPClauseVisitor
- : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
- template<class ImplClass, typename RetTy = void>
- class ConstOMPClauseVisitor :
- public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
- class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
- raw_ostream &OS;
- const PrintingPolicy &Policy;
- /// Process clauses with list of variables.
- template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
- /// Process motion clauses.
- template <typename T> void VisitOMPMotionClause(T *Node);
- public:
- OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
- : OS(OS), Policy(Policy) {}
- #define GEN_CLANG_CLAUSE_CLASS
- #define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
- #include "llvm/Frontend/OpenMP/OMP.inc"
- };
- struct OMPTraitProperty {
- llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
- /// The raw string as we parsed it. This is needed for the `isa` trait set
- /// (which accepts anything) and (later) extensions.
- StringRef RawString;
- };
- struct OMPTraitSelector {
- Expr *ScoreOrCondition = nullptr;
- llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
- llvm::SmallVector<OMPTraitProperty, 1> Properties;
- };
- struct OMPTraitSet {
- llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
- llvm::SmallVector<OMPTraitSelector, 2> Selectors;
- };
- /// Helper data structure representing the traits in a match clause of an
- /// `declare variant` or `metadirective`. The outer level is an ordered
- /// collection of selector sets, each with an associated kind and an ordered
- /// collection of selectors. A selector has a kind, an optional score/condition,
- /// and an ordered collection of properties.
- class OMPTraitInfo {
- /// Private constructor accesible only by ASTContext.
- OMPTraitInfo() {}
- friend class ASTContext;
- public:
- /// Reconstruct a (partial) OMPTraitInfo object from a mangled name.
- OMPTraitInfo(StringRef MangledName);
- /// The outermost level of selector sets.
- llvm::SmallVector<OMPTraitSet, 2> Sets;
- bool anyScoreOrCondition(
- llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
- return llvm::any_of(Sets, [&](OMPTraitSet &Set) {
- return llvm::any_of(
- Set.Selectors, [&](OMPTraitSelector &Selector) {
- return Cond(Selector.ScoreOrCondition,
- /* IsScore */ Selector.Kind !=
- llvm::omp::TraitSelector::user_condition);
- });
- });
- }
- /// Create a variant match info object from this trait info object. While the
- /// former is a flat representation the actual main difference is that the
- /// latter uses clang::Expr to store the score/condition while the former is
- /// independent of clang. Thus, expressions and conditions are evaluated in
- /// this method.
- void getAsVariantMatchInfo(ASTContext &ASTCtx,
- llvm::omp::VariantMatchInfo &VMI) const;
- /// Return a string representation identifying this context selector.
- std::string getMangledName() const;
- /// Check the extension trait \p TP is active.
- bool isExtensionActive(llvm::omp::TraitProperty TP) {
- for (const OMPTraitSet &Set : Sets) {
- if (Set.Kind != llvm::omp::TraitSet::implementation)
- continue;
- for (const OMPTraitSelector &Selector : Set.Selectors) {
- if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
- continue;
- for (const OMPTraitProperty &Property : Selector.Properties) {
- if (Property.Kind == TP)
- return true;
- }
- }
- }
- return false;
- }
- /// Print a human readable representation into \p OS.
- void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
- };
- llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
- llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
- /// Clang specific specialization of the OMPContext to lookup target features.
- struct TargetOMPContext final : public llvm::omp::OMPContext {
- TargetOMPContext(ASTContext &ASTCtx,
- std::function<void(StringRef)> &&DiagUnknownTrait,
- const FunctionDecl *CurrentFunctionDecl,
- ArrayRef<llvm::omp::TraitProperty> ConstructTraits);
- virtual ~TargetOMPContext() = default;
- /// See llvm::omp::OMPContext::matchesISATrait
- bool matchesISATrait(StringRef RawString) const override;
- private:
- std::function<bool(StringRef)> FeatureValidityCheck;
- std::function<void(StringRef)> DiagUnknownTrait;
- llvm::StringMap<bool> FeatureMap;
- };
- /// Contains data for OpenMP directives: clauses, children
- /// expressions/statements (helpers for codegen) and associated statement, if
- /// any.
- class OMPChildren final
- : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> {
- friend TrailingObjects;
- friend class OMPClauseReader;
- friend class OMPExecutableDirective;
- template <typename T> friend class OMPDeclarativeDirective;
- /// Numbers of clauses.
- unsigned NumClauses = 0;
- /// Number of child expressions/stmts.
- unsigned NumChildren = 0;
- /// true if the directive has associated statement.
- bool HasAssociatedStmt = false;
- /// Define the sizes of each trailing object array except the last one. This
- /// is required for TrailingObjects to work properly.
- size_t numTrailingObjects(OverloadToken<OMPClause *>) const {
- return NumClauses;
- }
- OMPChildren() = delete;
- OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt)
- : NumClauses(NumClauses), NumChildren(NumChildren),
- HasAssociatedStmt(HasAssociatedStmt) {}
- static size_t size(unsigned NumClauses, bool HasAssociatedStmt,
- unsigned NumChildren);
- static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses);
- static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S,
- unsigned NumChildren = 0);
- static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses,
- bool HasAssociatedStmt = false,
- unsigned NumChildren = 0);
- public:
- unsigned getNumClauses() const { return NumClauses; }
- unsigned getNumChildren() const { return NumChildren; }
- bool hasAssociatedStmt() const { return HasAssociatedStmt; }
- /// Set associated statement.
- void setAssociatedStmt(Stmt *S) {
- getTrailingObjects<Stmt *>()[NumChildren] = S;
- }
- void setChildren(ArrayRef<Stmt *> Children);
- /// Sets the list of variables for this clause.
- ///
- /// \param Clauses The list of clauses for the directive.
- ///
- void setClauses(ArrayRef<OMPClause *> Clauses);
- /// Returns statement associated with the directive.
- const Stmt *getAssociatedStmt() const {
- return const_cast<OMPChildren *>(this)->getAssociatedStmt();
- }
- Stmt *getAssociatedStmt() {
- assert(HasAssociatedStmt &&
- "Expected directive with the associated statement.");
- return getTrailingObjects<Stmt *>()[NumChildren];
- }
- /// Get the clauses storage.
- MutableArrayRef<OMPClause *> getClauses() {
- return llvm::MutableArrayRef(getTrailingObjects<OMPClause *>(),
- NumClauses);
- }
- ArrayRef<OMPClause *> getClauses() const {
- return const_cast<OMPChildren *>(this)->getClauses();
- }
- /// Returns the captured statement associated with the
- /// component region within the (combined) directive.
- ///
- /// \param RegionKind Component region kind.
- const CapturedStmt *
- getCapturedStmt(OpenMPDirectiveKind RegionKind,
- ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
- assert(llvm::is_contained(CaptureRegions, RegionKind) &&
- "RegionKind not found in OpenMP CaptureRegions.");
- auto *CS = cast<CapturedStmt>(getAssociatedStmt());
- for (auto ThisCaptureRegion : CaptureRegions) {
- if (ThisCaptureRegion == RegionKind)
- return CS;
- CS = cast<CapturedStmt>(CS->getCapturedStmt());
- }
- llvm_unreachable("Incorrect RegionKind specified for directive.");
- }
- /// Get innermost captured statement for the construct.
- CapturedStmt *
- getInnermostCapturedStmt(ArrayRef<OpenMPDirectiveKind> CaptureRegions) {
- assert(hasAssociatedStmt() && "Must have associated captured statement.");
- assert(!CaptureRegions.empty() &&
- "At least one captured statement must be provided.");
- auto *CS = cast<CapturedStmt>(getAssociatedStmt());
- for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
- CS = cast<CapturedStmt>(CS->getCapturedStmt());
- return CS;
- }
- const CapturedStmt *
- getInnermostCapturedStmt(ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
- return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt(
- CaptureRegions);
- }
- MutableArrayRef<Stmt *> getChildren();
- ArrayRef<Stmt *> getChildren() const {
- return const_cast<OMPChildren *>(this)->getChildren();
- }
- Stmt *getRawStmt() {
- assert(HasAssociatedStmt &&
- "Expected directive with the associated statement.");
- if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) {
- Stmt *S = nullptr;
- do {
- S = CS->getCapturedStmt();
- CS = dyn_cast<CapturedStmt>(S);
- } while (CS);
- return S;
- }
- return getAssociatedStmt();
- }
- const Stmt *getRawStmt() const {
- return const_cast<OMPChildren *>(this)->getRawStmt();
- }
- Stmt::child_range getAssociatedStmtAsRange() {
- if (!HasAssociatedStmt)
- return Stmt::child_range(Stmt::child_iterator(), Stmt::child_iterator());
- return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren],
- &getTrailingObjects<Stmt *>()[NumChildren + 1]);
- }
- };
- /// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...'
- /// directive.
- ///
- /// \code
- /// #pragma omp target [...] ompx_dyn_cgroup_mem(N)
- /// \endcode
- class OMPXDynCGroupMemClause
- : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>,
- public OMPClauseWithPreInit {
- friend class OMPClauseReader;
- /// Set size.
- void setSize(Expr *E) { setStmt(E); }
- public:
- /// Build 'ompx_dyn_cgroup_mem' clause.
- ///
- /// \param Size Size expression.
- /// \param HelperSize Helper Size expression
- /// \param CaptureRegion Innermost OpenMP region where expressions in this
- /// \param StartLoc Starting location of the clause.
- /// \param LParenLoc Location of '('.
- /// \param EndLoc Ending location of the clause.
- OMPXDynCGroupMemClause(Expr *Size, Stmt *HelperSize,
- OpenMPDirectiveKind CaptureRegion,
- SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
- : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc),
- OMPClauseWithPreInit(this) {
- setPreInitStmt(HelperSize, CaptureRegion);
- }
- /// Build an empty clause.
- OMPXDynCGroupMemClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {}
- /// Return the size expression.
- Expr *getSize() { return getStmtAs<Expr>(); }
- /// Return the size expression.
- Expr *getSize() const { return getStmtAs<Expr>(); }
- };
- } // namespace clang
- #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
- #ifdef __GNUC__
- #pragma GCC diagnostic pop
- #endif
|