DxilInstructions.h 163 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilInstructions.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // This file provides a library of instruction helper classes. //
  9. // MUCH WORK YET TO BE DONE - EXPECT THIS WILL CHANGE - GENERATED FILE //
  10. // //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #pragma once
  13. #include "llvm/IR/Constants.h"
  14. #include "llvm/IR/Instruction.h"
  15. #include "llvm/IR/Instructions.h"
  16. // TODO: add correct include directives
  17. // TODO: add accessors with values
  18. // TODO: add validation support code, including calling into right fn
  19. // TODO: add type hierarchy
  20. namespace hlsl {
  21. /* <py>
  22. import hctdb_instrhelp
  23. </py> */
  24. /* <py::lines('INSTR-HELPER')>hctdb_instrhelp.get_instrhelper()</py>*/
  25. // INSTR-HELPER:BEGIN
  26. /// This instruction returns a value (possibly void), from a function.
  27. struct LlvmInst_Ret {
  28. llvm::Instruction *Instr;
  29. // Construction and identification
  30. LlvmInst_Ret(llvm::Instruction *pInstr) : Instr(pInstr) {}
  31. operator bool() const {
  32. return Instr->getOpcode() == llvm::Instruction::Ret;
  33. }
  34. // Validation support
  35. bool isAllowed() const { return true; }
  36. };
  37. /// This instruction branches (conditional or unconditional)
  38. struct LlvmInst_Br {
  39. llvm::Instruction *Instr;
  40. // Construction and identification
  41. LlvmInst_Br(llvm::Instruction *pInstr) : Instr(pInstr) {}
  42. operator bool() const {
  43. return Instr->getOpcode() == llvm::Instruction::Br;
  44. }
  45. // Validation support
  46. bool isAllowed() const { return true; }
  47. };
  48. /// This instruction performs a multiway switch
  49. struct LlvmInst_Switch {
  50. llvm::Instruction *Instr;
  51. // Construction and identification
  52. LlvmInst_Switch(llvm::Instruction *pInstr) : Instr(pInstr) {}
  53. operator bool() const {
  54. return Instr->getOpcode() == llvm::Instruction::Switch;
  55. }
  56. // Validation support
  57. bool isAllowed() const { return true; }
  58. };
  59. /// This instruction branches indirectly
  60. struct LlvmInst_IndirectBr {
  61. llvm::Instruction *Instr;
  62. // Construction and identification
  63. LlvmInst_IndirectBr(llvm::Instruction *pInstr) : Instr(pInstr) {}
  64. operator bool() const {
  65. return Instr->getOpcode() == llvm::Instruction::IndirectBr;
  66. }
  67. // Validation support
  68. bool isAllowed() const { return false; }
  69. };
  70. /// This instruction invokes function with normal and exceptional returns
  71. struct LlvmInst_Invoke {
  72. llvm::Instruction *Instr;
  73. // Construction and identification
  74. LlvmInst_Invoke(llvm::Instruction *pInstr) : Instr(pInstr) {}
  75. operator bool() const {
  76. return Instr->getOpcode() == llvm::Instruction::Invoke;
  77. }
  78. // Validation support
  79. bool isAllowed() const { return false; }
  80. };
  81. /// This instruction resumes the propagation of an exception
  82. struct LlvmInst_Resume {
  83. llvm::Instruction *Instr;
  84. // Construction and identification
  85. LlvmInst_Resume(llvm::Instruction *pInstr) : Instr(pInstr) {}
  86. operator bool() const {
  87. return Instr->getOpcode() == llvm::Instruction::Resume;
  88. }
  89. // Validation support
  90. bool isAllowed() const { return false; }
  91. };
  92. /// This instruction is unreachable
  93. struct LlvmInst_Unreachable {
  94. llvm::Instruction *Instr;
  95. // Construction and identification
  96. LlvmInst_Unreachable(llvm::Instruction *pInstr) : Instr(pInstr) {}
  97. operator bool() const {
  98. return Instr->getOpcode() == llvm::Instruction::Unreachable;
  99. }
  100. // Validation support
  101. bool isAllowed() const { return false; }
  102. };
  103. /// This instruction returns the sum of its two operands
  104. struct LlvmInst_Add {
  105. llvm::Instruction *Instr;
  106. // Construction and identification
  107. LlvmInst_Add(llvm::Instruction *pInstr) : Instr(pInstr) {}
  108. operator bool() const {
  109. return Instr->getOpcode() == llvm::Instruction::Add;
  110. }
  111. // Validation support
  112. bool isAllowed() const { return true; }
  113. };
  114. /// This instruction returns the sum of its two operands
  115. struct LlvmInst_FAdd {
  116. llvm::Instruction *Instr;
  117. // Construction and identification
  118. LlvmInst_FAdd(llvm::Instruction *pInstr) : Instr(pInstr) {}
  119. operator bool() const {
  120. return Instr->getOpcode() == llvm::Instruction::FAdd;
  121. }
  122. // Validation support
  123. bool isAllowed() const { return true; }
  124. };
  125. /// This instruction returns the difference of its two operands
  126. struct LlvmInst_Sub {
  127. llvm::Instruction *Instr;
  128. // Construction and identification
  129. LlvmInst_Sub(llvm::Instruction *pInstr) : Instr(pInstr) {}
  130. operator bool() const {
  131. return Instr->getOpcode() == llvm::Instruction::Sub;
  132. }
  133. // Validation support
  134. bool isAllowed() const { return true; }
  135. };
  136. /// This instruction returns the difference of its two operands
  137. struct LlvmInst_FSub {
  138. llvm::Instruction *Instr;
  139. // Construction and identification
  140. LlvmInst_FSub(llvm::Instruction *pInstr) : Instr(pInstr) {}
  141. operator bool() const {
  142. return Instr->getOpcode() == llvm::Instruction::FSub;
  143. }
  144. // Validation support
  145. bool isAllowed() const { return true; }
  146. };
  147. /// This instruction returns the product of its two operands
  148. struct LlvmInst_Mul {
  149. llvm::Instruction *Instr;
  150. // Construction and identification
  151. LlvmInst_Mul(llvm::Instruction *pInstr) : Instr(pInstr) {}
  152. operator bool() const {
  153. return Instr->getOpcode() == llvm::Instruction::Mul;
  154. }
  155. // Validation support
  156. bool isAllowed() const { return true; }
  157. };
  158. /// This instruction returns the product of its two operands
  159. struct LlvmInst_FMul {
  160. llvm::Instruction *Instr;
  161. // Construction and identification
  162. LlvmInst_FMul(llvm::Instruction *pInstr) : Instr(pInstr) {}
  163. operator bool() const {
  164. return Instr->getOpcode() == llvm::Instruction::FMul;
  165. }
  166. // Validation support
  167. bool isAllowed() const { return true; }
  168. };
  169. /// This instruction returns the quotient of its two unsigned operands
  170. struct LlvmInst_UDiv {
  171. llvm::Instruction *Instr;
  172. // Construction and identification
  173. LlvmInst_UDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}
  174. operator bool() const {
  175. return Instr->getOpcode() == llvm::Instruction::UDiv;
  176. }
  177. // Validation support
  178. bool isAllowed() const { return true; }
  179. };
  180. /// This instruction returns the quotient of its two signed operands
  181. struct LlvmInst_SDiv {
  182. llvm::Instruction *Instr;
  183. // Construction and identification
  184. LlvmInst_SDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}
  185. operator bool() const {
  186. return Instr->getOpcode() == llvm::Instruction::SDiv;
  187. }
  188. // Validation support
  189. bool isAllowed() const { return true; }
  190. };
  191. /// This instruction returns the quotient of its two operands
  192. struct LlvmInst_FDiv {
  193. llvm::Instruction *Instr;
  194. // Construction and identification
  195. LlvmInst_FDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}
  196. operator bool() const {
  197. return Instr->getOpcode() == llvm::Instruction::FDiv;
  198. }
  199. // Validation support
  200. bool isAllowed() const { return true; }
  201. };
  202. /// This instruction returns the remainder from the unsigned division of its two operands
  203. struct LlvmInst_URem {
  204. llvm::Instruction *Instr;
  205. // Construction and identification
  206. LlvmInst_URem(llvm::Instruction *pInstr) : Instr(pInstr) {}
  207. operator bool() const {
  208. return Instr->getOpcode() == llvm::Instruction::URem;
  209. }
  210. // Validation support
  211. bool isAllowed() const { return true; }
  212. };
  213. /// This instruction returns the remainder from the signed division of its two operands
  214. struct LlvmInst_SRem {
  215. llvm::Instruction *Instr;
  216. // Construction and identification
  217. LlvmInst_SRem(llvm::Instruction *pInstr) : Instr(pInstr) {}
  218. operator bool() const {
  219. return Instr->getOpcode() == llvm::Instruction::SRem;
  220. }
  221. // Validation support
  222. bool isAllowed() const { return true; }
  223. };
  224. /// This instruction returns the remainder from the division of its two operands
  225. struct LlvmInst_FRem {
  226. llvm::Instruction *Instr;
  227. // Construction and identification
  228. LlvmInst_FRem(llvm::Instruction *pInstr) : Instr(pInstr) {}
  229. operator bool() const {
  230. return Instr->getOpcode() == llvm::Instruction::FRem;
  231. }
  232. // Validation support
  233. bool isAllowed() const { return true; }
  234. };
  235. /// This instruction shifts left (logical)
  236. struct LlvmInst_Shl {
  237. llvm::Instruction *Instr;
  238. // Construction and identification
  239. LlvmInst_Shl(llvm::Instruction *pInstr) : Instr(pInstr) {}
  240. operator bool() const {
  241. return Instr->getOpcode() == llvm::Instruction::Shl;
  242. }
  243. // Validation support
  244. bool isAllowed() const { return true; }
  245. };
  246. /// This instruction shifts right (logical), with zero bit fill
  247. struct LlvmInst_LShr {
  248. llvm::Instruction *Instr;
  249. // Construction and identification
  250. LlvmInst_LShr(llvm::Instruction *pInstr) : Instr(pInstr) {}
  251. operator bool() const {
  252. return Instr->getOpcode() == llvm::Instruction::LShr;
  253. }
  254. // Validation support
  255. bool isAllowed() const { return true; }
  256. };
  257. /// This instruction shifts right (arithmetic), with 'a' operand sign bit fill
  258. struct LlvmInst_AShr {
  259. llvm::Instruction *Instr;
  260. // Construction and identification
  261. LlvmInst_AShr(llvm::Instruction *pInstr) : Instr(pInstr) {}
  262. operator bool() const {
  263. return Instr->getOpcode() == llvm::Instruction::AShr;
  264. }
  265. // Validation support
  266. bool isAllowed() const { return true; }
  267. };
  268. /// This instruction returns a bitwise logical and of its two operands
  269. struct LlvmInst_And {
  270. llvm::Instruction *Instr;
  271. // Construction and identification
  272. LlvmInst_And(llvm::Instruction *pInstr) : Instr(pInstr) {}
  273. operator bool() const {
  274. return Instr->getOpcode() == llvm::Instruction::And;
  275. }
  276. // Validation support
  277. bool isAllowed() const { return true; }
  278. };
  279. /// This instruction returns a bitwise logical or of its two operands
  280. struct LlvmInst_Or {
  281. llvm::Instruction *Instr;
  282. // Construction and identification
  283. LlvmInst_Or(llvm::Instruction *pInstr) : Instr(pInstr) {}
  284. operator bool() const {
  285. return Instr->getOpcode() == llvm::Instruction::Or;
  286. }
  287. // Validation support
  288. bool isAllowed() const { return true; }
  289. };
  290. /// This instruction returns a bitwise logical xor of its two operands
  291. struct LlvmInst_Xor {
  292. llvm::Instruction *Instr;
  293. // Construction and identification
  294. LlvmInst_Xor(llvm::Instruction *pInstr) : Instr(pInstr) {}
  295. operator bool() const {
  296. return Instr->getOpcode() == llvm::Instruction::Xor;
  297. }
  298. // Validation support
  299. bool isAllowed() const { return true; }
  300. };
  301. /// This instruction allocates memory on the stack frame of the currently executing function
  302. struct LlvmInst_Alloca {
  303. llvm::Instruction *Instr;
  304. // Construction and identification
  305. LlvmInst_Alloca(llvm::Instruction *pInstr) : Instr(pInstr) {}
  306. operator bool() const {
  307. return Instr->getOpcode() == llvm::Instruction::Alloca;
  308. }
  309. // Validation support
  310. bool isAllowed() const { return true; }
  311. };
  312. /// This instruction reads from memory
  313. struct LlvmInst_Load {
  314. llvm::Instruction *Instr;
  315. // Construction and identification
  316. LlvmInst_Load(llvm::Instruction *pInstr) : Instr(pInstr) {}
  317. operator bool() const {
  318. return Instr->getOpcode() == llvm::Instruction::Load;
  319. }
  320. // Validation support
  321. bool isAllowed() const { return true; }
  322. };
  323. /// This instruction writes to memory
  324. struct LlvmInst_Store {
  325. llvm::Instruction *Instr;
  326. // Construction and identification
  327. LlvmInst_Store(llvm::Instruction *pInstr) : Instr(pInstr) {}
  328. operator bool() const {
  329. return Instr->getOpcode() == llvm::Instruction::Store;
  330. }
  331. // Validation support
  332. bool isAllowed() const { return true; }
  333. };
  334. /// This instruction gets the address of a subelement of an aggregate value
  335. struct LlvmInst_GetElementPtr {
  336. llvm::Instruction *Instr;
  337. // Construction and identification
  338. LlvmInst_GetElementPtr(llvm::Instruction *pInstr) : Instr(pInstr) {}
  339. operator bool() const {
  340. return Instr->getOpcode() == llvm::Instruction::GetElementPtr;
  341. }
  342. // Validation support
  343. bool isAllowed() const { return true; }
  344. };
  345. /// This instruction introduces happens-before edges between operations
  346. struct LlvmInst_Fence {
  347. llvm::Instruction *Instr;
  348. // Construction and identification
  349. LlvmInst_Fence(llvm::Instruction *pInstr) : Instr(pInstr) {}
  350. operator bool() const {
  351. return Instr->getOpcode() == llvm::Instruction::Fence;
  352. }
  353. // Validation support
  354. bool isAllowed() const { return false; }
  355. };
  356. /// This instruction atomically modifies memory
  357. struct LlvmInst_AtomicCmpXchg {
  358. llvm::Instruction *Instr;
  359. // Construction and identification
  360. LlvmInst_AtomicCmpXchg(llvm::Instruction *pInstr) : Instr(pInstr) {}
  361. operator bool() const {
  362. return Instr->getOpcode() == llvm::Instruction::AtomicCmpXchg;
  363. }
  364. // Validation support
  365. bool isAllowed() const { return true; }
  366. };
  367. /// This instruction atomically modifies memory
  368. struct LlvmInst_AtomicRMW {
  369. llvm::Instruction *Instr;
  370. // Construction and identification
  371. LlvmInst_AtomicRMW(llvm::Instruction *pInstr) : Instr(pInstr) {}
  372. operator bool() const {
  373. return Instr->getOpcode() == llvm::Instruction::AtomicRMW;
  374. }
  375. // Validation support
  376. bool isAllowed() const { return true; }
  377. };
  378. /// This instruction truncates an integer
  379. struct LlvmInst_Trunc {
  380. llvm::Instruction *Instr;
  381. // Construction and identification
  382. LlvmInst_Trunc(llvm::Instruction *pInstr) : Instr(pInstr) {}
  383. operator bool() const {
  384. return Instr->getOpcode() == llvm::Instruction::Trunc;
  385. }
  386. // Validation support
  387. bool isAllowed() const { return true; }
  388. };
  389. /// This instruction zero extends an integer
  390. struct LlvmInst_ZExt {
  391. llvm::Instruction *Instr;
  392. // Construction and identification
  393. LlvmInst_ZExt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  394. operator bool() const {
  395. return Instr->getOpcode() == llvm::Instruction::ZExt;
  396. }
  397. // Validation support
  398. bool isAllowed() const { return true; }
  399. };
  400. /// This instruction sign extends an integer
  401. struct LlvmInst_SExt {
  402. llvm::Instruction *Instr;
  403. // Construction and identification
  404. LlvmInst_SExt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  405. operator bool() const {
  406. return Instr->getOpcode() == llvm::Instruction::SExt;
  407. }
  408. // Validation support
  409. bool isAllowed() const { return true; }
  410. };
  411. /// This instruction converts a floating point to UInt
  412. struct LlvmInst_FPToUI {
  413. llvm::Instruction *Instr;
  414. // Construction and identification
  415. LlvmInst_FPToUI(llvm::Instruction *pInstr) : Instr(pInstr) {}
  416. operator bool() const {
  417. return Instr->getOpcode() == llvm::Instruction::FPToUI;
  418. }
  419. // Validation support
  420. bool isAllowed() const { return true; }
  421. };
  422. /// This instruction converts a floating point to SInt
  423. struct LlvmInst_FPToSI {
  424. llvm::Instruction *Instr;
  425. // Construction and identification
  426. LlvmInst_FPToSI(llvm::Instruction *pInstr) : Instr(pInstr) {}
  427. operator bool() const {
  428. return Instr->getOpcode() == llvm::Instruction::FPToSI;
  429. }
  430. // Validation support
  431. bool isAllowed() const { return true; }
  432. };
  433. /// This instruction converts a UInt to floating point
  434. struct LlvmInst_UIToFP {
  435. llvm::Instruction *Instr;
  436. // Construction and identification
  437. LlvmInst_UIToFP(llvm::Instruction *pInstr) : Instr(pInstr) {}
  438. operator bool() const {
  439. return Instr->getOpcode() == llvm::Instruction::UIToFP;
  440. }
  441. // Validation support
  442. bool isAllowed() const { return true; }
  443. };
  444. /// This instruction converts a SInt to floating point
  445. struct LlvmInst_SIToFP {
  446. llvm::Instruction *Instr;
  447. // Construction and identification
  448. LlvmInst_SIToFP(llvm::Instruction *pInstr) : Instr(pInstr) {}
  449. operator bool() const {
  450. return Instr->getOpcode() == llvm::Instruction::SIToFP;
  451. }
  452. // Validation support
  453. bool isAllowed() const { return true; }
  454. };
  455. /// This instruction truncates a floating point
  456. struct LlvmInst_FPTrunc {
  457. llvm::Instruction *Instr;
  458. // Construction and identification
  459. LlvmInst_FPTrunc(llvm::Instruction *pInstr) : Instr(pInstr) {}
  460. operator bool() const {
  461. return Instr->getOpcode() == llvm::Instruction::FPTrunc;
  462. }
  463. // Validation support
  464. bool isAllowed() const { return true; }
  465. };
  466. /// This instruction extends a floating point
  467. struct LlvmInst_FPExt {
  468. llvm::Instruction *Instr;
  469. // Construction and identification
  470. LlvmInst_FPExt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  471. operator bool() const {
  472. return Instr->getOpcode() == llvm::Instruction::FPExt;
  473. }
  474. // Validation support
  475. bool isAllowed() const { return true; }
  476. };
  477. /// This instruction converts a pointer to integer
  478. struct LlvmInst_PtrToInt {
  479. llvm::Instruction *Instr;
  480. // Construction and identification
  481. LlvmInst_PtrToInt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  482. operator bool() const {
  483. return Instr->getOpcode() == llvm::Instruction::PtrToInt;
  484. }
  485. // Validation support
  486. bool isAllowed() const { return false; }
  487. };
  488. /// This instruction converts an integer to Pointer
  489. struct LlvmInst_IntToPtr {
  490. llvm::Instruction *Instr;
  491. // Construction and identification
  492. LlvmInst_IntToPtr(llvm::Instruction *pInstr) : Instr(pInstr) {}
  493. operator bool() const {
  494. return Instr->getOpcode() == llvm::Instruction::IntToPtr;
  495. }
  496. // Validation support
  497. bool isAllowed() const { return false; }
  498. };
  499. /// This instruction performs a bit-preserving type cast
  500. struct LlvmInst_BitCast {
  501. llvm::Instruction *Instr;
  502. // Construction and identification
  503. LlvmInst_BitCast(llvm::Instruction *pInstr) : Instr(pInstr) {}
  504. operator bool() const {
  505. return Instr->getOpcode() == llvm::Instruction::BitCast;
  506. }
  507. // Validation support
  508. bool isAllowed() const { return true; }
  509. };
  510. /// This instruction casts a value addrspace
  511. struct LlvmInst_AddrSpaceCast {
  512. llvm::Instruction *Instr;
  513. // Construction and identification
  514. LlvmInst_AddrSpaceCast(llvm::Instruction *pInstr) : Instr(pInstr) {}
  515. operator bool() const {
  516. return Instr->getOpcode() == llvm::Instruction::AddrSpaceCast;
  517. }
  518. // Validation support
  519. bool isAllowed() const { return true; }
  520. };
  521. /// This instruction compares integers
  522. struct LlvmInst_ICmp {
  523. llvm::Instruction *Instr;
  524. // Construction and identification
  525. LlvmInst_ICmp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  526. operator bool() const {
  527. return Instr->getOpcode() == llvm::Instruction::ICmp;
  528. }
  529. // Validation support
  530. bool isAllowed() const { return true; }
  531. };
  532. /// This instruction compares floating points
  533. struct LlvmInst_FCmp {
  534. llvm::Instruction *Instr;
  535. // Construction and identification
  536. LlvmInst_FCmp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  537. operator bool() const {
  538. return Instr->getOpcode() == llvm::Instruction::FCmp;
  539. }
  540. // Validation support
  541. bool isAllowed() const { return true; }
  542. };
  543. /// This instruction is a PHI node instruction
  544. struct LlvmInst_PHI {
  545. llvm::Instruction *Instr;
  546. // Construction and identification
  547. LlvmInst_PHI(llvm::Instruction *pInstr) : Instr(pInstr) {}
  548. operator bool() const {
  549. return Instr->getOpcode() == llvm::Instruction::PHI;
  550. }
  551. // Validation support
  552. bool isAllowed() const { return true; }
  553. };
  554. /// This instruction calls a function
  555. struct LlvmInst_Call {
  556. llvm::Instruction *Instr;
  557. // Construction and identification
  558. LlvmInst_Call(llvm::Instruction *pInstr) : Instr(pInstr) {}
  559. operator bool() const {
  560. return Instr->getOpcode() == llvm::Instruction::Call;
  561. }
  562. // Validation support
  563. bool isAllowed() const { return true; }
  564. };
  565. /// This instruction selects an instruction
  566. struct LlvmInst_Select {
  567. llvm::Instruction *Instr;
  568. // Construction and identification
  569. LlvmInst_Select(llvm::Instruction *pInstr) : Instr(pInstr) {}
  570. operator bool() const {
  571. return Instr->getOpcode() == llvm::Instruction::Select;
  572. }
  573. // Validation support
  574. bool isAllowed() const { return true; }
  575. };
  576. /// This instruction may be used internally in a pass
  577. struct LlvmInst_UserOp1 {
  578. llvm::Instruction *Instr;
  579. // Construction and identification
  580. LlvmInst_UserOp1(llvm::Instruction *pInstr) : Instr(pInstr) {}
  581. operator bool() const {
  582. return Instr->getOpcode() == llvm::Instruction::UserOp1;
  583. }
  584. // Validation support
  585. bool isAllowed() const { return false; }
  586. };
  587. /// This instruction internal to passes only
  588. struct LlvmInst_UserOp2 {
  589. llvm::Instruction *Instr;
  590. // Construction and identification
  591. LlvmInst_UserOp2(llvm::Instruction *pInstr) : Instr(pInstr) {}
  592. operator bool() const {
  593. return Instr->getOpcode() == llvm::Instruction::UserOp2;
  594. }
  595. // Validation support
  596. bool isAllowed() const { return false; }
  597. };
  598. /// This instruction vaarg instruction
  599. struct LlvmInst_VAArg {
  600. llvm::Instruction *Instr;
  601. // Construction and identification
  602. LlvmInst_VAArg(llvm::Instruction *pInstr) : Instr(pInstr) {}
  603. operator bool() const {
  604. return Instr->getOpcode() == llvm::Instruction::VAArg;
  605. }
  606. // Validation support
  607. bool isAllowed() const { return false; }
  608. };
  609. /// This instruction extracts from aggregate
  610. struct LlvmInst_ExtractValue {
  611. llvm::Instruction *Instr;
  612. // Construction and identification
  613. LlvmInst_ExtractValue(llvm::Instruction *pInstr) : Instr(pInstr) {}
  614. operator bool() const {
  615. return Instr->getOpcode() == llvm::Instruction::ExtractValue;
  616. }
  617. // Validation support
  618. bool isAllowed() const { return true; }
  619. };
  620. /// This instruction represents a landing pad
  621. struct LlvmInst_LandingPad {
  622. llvm::Instruction *Instr;
  623. // Construction and identification
  624. LlvmInst_LandingPad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  625. operator bool() const {
  626. return Instr->getOpcode() == llvm::Instruction::LandingPad;
  627. }
  628. // Validation support
  629. bool isAllowed() const { return false; }
  630. };
  631. /// This instruction Helper load operation
  632. struct DxilInst_TempRegLoad {
  633. llvm::Instruction *Instr;
  634. // Construction and identification
  635. DxilInst_TempRegLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  636. operator bool() const {
  637. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TempRegLoad);
  638. }
  639. // Validation support
  640. bool isAllowed() const { return true; }
  641. bool isArgumentListValid() const {
  642. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  643. return true;
  644. }
  645. // Operand indexes
  646. enum OperandIdx {
  647. arg_index = 1,
  648. };
  649. // Accessors
  650. llvm::Value *get_index() const { return Instr->getOperand(1); }
  651. void set_index(llvm::Value *val) { Instr->setOperand(1, val); }
  652. };
  653. /// This instruction Helper store operation
  654. struct DxilInst_TempRegStore {
  655. llvm::Instruction *Instr;
  656. // Construction and identification
  657. DxilInst_TempRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {}
  658. operator bool() const {
  659. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TempRegStore);
  660. }
  661. // Validation support
  662. bool isAllowed() const { return true; }
  663. bool isArgumentListValid() const {
  664. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  665. return true;
  666. }
  667. // Operand indexes
  668. enum OperandIdx {
  669. arg_index = 1,
  670. arg_value = 2,
  671. };
  672. // Accessors
  673. llvm::Value *get_index() const { return Instr->getOperand(1); }
  674. void set_index(llvm::Value *val) { Instr->setOperand(1, val); }
  675. llvm::Value *get_value() const { return Instr->getOperand(2); }
  676. void set_value(llvm::Value *val) { Instr->setOperand(2, val); }
  677. };
  678. /// This instruction Helper load operation for minprecision
  679. struct DxilInst_MinPrecXRegLoad {
  680. llvm::Instruction *Instr;
  681. // Construction and identification
  682. DxilInst_MinPrecXRegLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  683. operator bool() const {
  684. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegLoad);
  685. }
  686. // Validation support
  687. bool isAllowed() const { return true; }
  688. bool isArgumentListValid() const {
  689. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  690. return true;
  691. }
  692. // Operand indexes
  693. enum OperandIdx {
  694. arg_regIndex = 1,
  695. arg_index = 2,
  696. arg_component = 3,
  697. };
  698. // Accessors
  699. llvm::Value *get_regIndex() const { return Instr->getOperand(1); }
  700. void set_regIndex(llvm::Value *val) { Instr->setOperand(1, val); }
  701. llvm::Value *get_index() const { return Instr->getOperand(2); }
  702. void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
  703. llvm::Value *get_component() const { return Instr->getOperand(3); }
  704. void set_component(llvm::Value *val) { Instr->setOperand(3, val); }
  705. };
  706. /// This instruction Helper store operation for minprecision
  707. struct DxilInst_MinPrecXRegStore {
  708. llvm::Instruction *Instr;
  709. // Construction and identification
  710. DxilInst_MinPrecXRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {}
  711. operator bool() const {
  712. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegStore);
  713. }
  714. // Validation support
  715. bool isAllowed() const { return true; }
  716. bool isArgumentListValid() const {
  717. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  718. return true;
  719. }
  720. // Operand indexes
  721. enum OperandIdx {
  722. arg_regIndex = 1,
  723. arg_index = 2,
  724. arg_component = 3,
  725. arg_value = 4,
  726. };
  727. // Accessors
  728. llvm::Value *get_regIndex() const { return Instr->getOperand(1); }
  729. void set_regIndex(llvm::Value *val) { Instr->setOperand(1, val); }
  730. llvm::Value *get_index() const { return Instr->getOperand(2); }
  731. void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
  732. llvm::Value *get_component() const { return Instr->getOperand(3); }
  733. void set_component(llvm::Value *val) { Instr->setOperand(3, val); }
  734. llvm::Value *get_value() const { return Instr->getOperand(4); }
  735. void set_value(llvm::Value *val) { Instr->setOperand(4, val); }
  736. };
  737. /// This instruction Loads the value from shader input
  738. struct DxilInst_LoadInput {
  739. llvm::Instruction *Instr;
  740. // Construction and identification
  741. DxilInst_LoadInput(llvm::Instruction *pInstr) : Instr(pInstr) {}
  742. operator bool() const {
  743. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadInput);
  744. }
  745. // Validation support
  746. bool isAllowed() const { return true; }
  747. bool isArgumentListValid() const {
  748. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  749. return true;
  750. }
  751. // Operand indexes
  752. enum OperandIdx {
  753. arg_inputSigId = 1,
  754. arg_rowIndex = 2,
  755. arg_colIndex = 3,
  756. arg_gsVertexAxis = 4,
  757. };
  758. // Accessors
  759. llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }
  760. void set_inputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  761. llvm::Value *get_rowIndex() const { return Instr->getOperand(2); }
  762. void set_rowIndex(llvm::Value *val) { Instr->setOperand(2, val); }
  763. llvm::Value *get_colIndex() const { return Instr->getOperand(3); }
  764. void set_colIndex(llvm::Value *val) { Instr->setOperand(3, val); }
  765. llvm::Value *get_gsVertexAxis() const { return Instr->getOperand(4); }
  766. void set_gsVertexAxis(llvm::Value *val) { Instr->setOperand(4, val); }
  767. };
  768. /// This instruction Stores the value to shader output
  769. struct DxilInst_StoreOutput {
  770. llvm::Instruction *Instr;
  771. // Construction and identification
  772. DxilInst_StoreOutput(llvm::Instruction *pInstr) : Instr(pInstr) {}
  773. operator bool() const {
  774. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StoreOutput);
  775. }
  776. // Validation support
  777. bool isAllowed() const { return true; }
  778. bool isArgumentListValid() const {
  779. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  780. return true;
  781. }
  782. // Operand indexes
  783. enum OperandIdx {
  784. arg_outputSigId = 1,
  785. arg_rowIndex = 2,
  786. arg_colIndex = 3,
  787. arg_value = 4,
  788. };
  789. // Accessors
  790. llvm::Value *get_outputSigId() const { return Instr->getOperand(1); }
  791. void set_outputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  792. llvm::Value *get_rowIndex() const { return Instr->getOperand(2); }
  793. void set_rowIndex(llvm::Value *val) { Instr->setOperand(2, val); }
  794. llvm::Value *get_colIndex() const { return Instr->getOperand(3); }
  795. void set_colIndex(llvm::Value *val) { Instr->setOperand(3, val); }
  796. llvm::Value *get_value() const { return Instr->getOperand(4); }
  797. void set_value(llvm::Value *val) { Instr->setOperand(4, val); }
  798. };
  799. /// This instruction returns the absolute value of the input value.
  800. struct DxilInst_FAbs {
  801. llvm::Instruction *Instr;
  802. // Construction and identification
  803. DxilInst_FAbs(llvm::Instruction *pInstr) : Instr(pInstr) {}
  804. operator bool() const {
  805. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FAbs);
  806. }
  807. // Validation support
  808. bool isAllowed() const { return true; }
  809. bool isArgumentListValid() const {
  810. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  811. return true;
  812. }
  813. // Operand indexes
  814. enum OperandIdx {
  815. arg_value = 1,
  816. };
  817. // Accessors
  818. llvm::Value *get_value() const { return Instr->getOperand(1); }
  819. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  820. };
  821. /// This instruction clamps the result of a single or double precision floating point value to [0.0f...1.0f]
  822. struct DxilInst_Saturate {
  823. llvm::Instruction *Instr;
  824. // Construction and identification
  825. DxilInst_Saturate(llvm::Instruction *pInstr) : Instr(pInstr) {}
  826. operator bool() const {
  827. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Saturate);
  828. }
  829. // Validation support
  830. bool isAllowed() const { return true; }
  831. bool isArgumentListValid() const {
  832. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  833. return true;
  834. }
  835. // Operand indexes
  836. enum OperandIdx {
  837. arg_value = 1,
  838. };
  839. // Accessors
  840. llvm::Value *get_value() const { return Instr->getOperand(1); }
  841. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  842. };
  843. /// This instruction Returns true if x is NAN or QNAN, false otherwise.
  844. struct DxilInst_IsNaN {
  845. llvm::Instruction *Instr;
  846. // Construction and identification
  847. DxilInst_IsNaN(llvm::Instruction *pInstr) : Instr(pInstr) {}
  848. operator bool() const {
  849. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsNaN);
  850. }
  851. // Validation support
  852. bool isAllowed() const { return true; }
  853. bool isArgumentListValid() const {
  854. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  855. return true;
  856. }
  857. // Operand indexes
  858. enum OperandIdx {
  859. arg_value = 1,
  860. };
  861. // Accessors
  862. llvm::Value *get_value() const { return Instr->getOperand(1); }
  863. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  864. };
  865. /// This instruction Returns true if x is +INF or -INF, false otherwise.
  866. struct DxilInst_IsInf {
  867. llvm::Instruction *Instr;
  868. // Construction and identification
  869. DxilInst_IsInf(llvm::Instruction *pInstr) : Instr(pInstr) {}
  870. operator bool() const {
  871. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsInf);
  872. }
  873. // Validation support
  874. bool isAllowed() const { return true; }
  875. bool isArgumentListValid() const {
  876. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  877. return true;
  878. }
  879. // Operand indexes
  880. enum OperandIdx {
  881. arg_value = 1,
  882. };
  883. // Accessors
  884. llvm::Value *get_value() const { return Instr->getOperand(1); }
  885. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  886. };
  887. /// This instruction Returns true if x is finite, false otherwise.
  888. struct DxilInst_IsFinite {
  889. llvm::Instruction *Instr;
  890. // Construction and identification
  891. DxilInst_IsFinite(llvm::Instruction *pInstr) : Instr(pInstr) {}
  892. operator bool() const {
  893. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsFinite);
  894. }
  895. // Validation support
  896. bool isAllowed() const { return true; }
  897. bool isArgumentListValid() const {
  898. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  899. return true;
  900. }
  901. // Operand indexes
  902. enum OperandIdx {
  903. arg_value = 1,
  904. };
  905. // Accessors
  906. llvm::Value *get_value() const { return Instr->getOperand(1); }
  907. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  908. };
  909. /// This instruction returns IsNormal
  910. struct DxilInst_IsNormal {
  911. llvm::Instruction *Instr;
  912. // Construction and identification
  913. DxilInst_IsNormal(llvm::Instruction *pInstr) : Instr(pInstr) {}
  914. operator bool() const {
  915. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsNormal);
  916. }
  917. // Validation support
  918. bool isAllowed() const { return true; }
  919. bool isArgumentListValid() const {
  920. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  921. return true;
  922. }
  923. // Operand indexes
  924. enum OperandIdx {
  925. arg_value = 1,
  926. };
  927. // Accessors
  928. llvm::Value *get_value() const { return Instr->getOperand(1); }
  929. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  930. };
  931. /// This instruction returns cosine(theta) for theta in radians.
  932. struct DxilInst_Cos {
  933. llvm::Instruction *Instr;
  934. // Construction and identification
  935. DxilInst_Cos(llvm::Instruction *pInstr) : Instr(pInstr) {}
  936. operator bool() const {
  937. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Cos);
  938. }
  939. // Validation support
  940. bool isAllowed() const { return true; }
  941. bool isArgumentListValid() const {
  942. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  943. return true;
  944. }
  945. // Operand indexes
  946. enum OperandIdx {
  947. arg_value = 1,
  948. };
  949. // Accessors
  950. llvm::Value *get_value() const { return Instr->getOperand(1); }
  951. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  952. };
  953. /// This instruction returns sine(theta) for theta in radians.
  954. struct DxilInst_Sin {
  955. llvm::Instruction *Instr;
  956. // Construction and identification
  957. DxilInst_Sin(llvm::Instruction *pInstr) : Instr(pInstr) {}
  958. operator bool() const {
  959. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Sin);
  960. }
  961. // Validation support
  962. bool isAllowed() const { return true; }
  963. bool isArgumentListValid() const {
  964. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  965. return true;
  966. }
  967. // Operand indexes
  968. enum OperandIdx {
  969. arg_value = 1,
  970. };
  971. // Accessors
  972. llvm::Value *get_value() const { return Instr->getOperand(1); }
  973. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  974. };
  975. /// This instruction returns tan(theta) for theta in radians.
  976. struct DxilInst_Tan {
  977. llvm::Instruction *Instr;
  978. // Construction and identification
  979. DxilInst_Tan(llvm::Instruction *pInstr) : Instr(pInstr) {}
  980. operator bool() const {
  981. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Tan);
  982. }
  983. // Validation support
  984. bool isAllowed() const { return true; }
  985. bool isArgumentListValid() const {
  986. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  987. return true;
  988. }
  989. // Operand indexes
  990. enum OperandIdx {
  991. arg_value = 1,
  992. };
  993. // Accessors
  994. llvm::Value *get_value() const { return Instr->getOperand(1); }
  995. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  996. };
  997. /// This instruction Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1.
  998. struct DxilInst_Acos {
  999. llvm::Instruction *Instr;
  1000. // Construction and identification
  1001. DxilInst_Acos(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1002. operator bool() const {
  1003. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Acos);
  1004. }
  1005. // Validation support
  1006. bool isAllowed() const { return true; }
  1007. bool isArgumentListValid() const {
  1008. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1009. return true;
  1010. }
  1011. // Operand indexes
  1012. enum OperandIdx {
  1013. arg_value = 1,
  1014. };
  1015. // Accessors
  1016. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1017. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1018. };
  1019. /// This instruction Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1
  1020. struct DxilInst_Asin {
  1021. llvm::Instruction *Instr;
  1022. // Construction and identification
  1023. DxilInst_Asin(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1024. operator bool() const {
  1025. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Asin);
  1026. }
  1027. // Validation support
  1028. bool isAllowed() const { return true; }
  1029. bool isArgumentListValid() const {
  1030. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1031. return true;
  1032. }
  1033. // Operand indexes
  1034. enum OperandIdx {
  1035. arg_value = 1,
  1036. };
  1037. // Accessors
  1038. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1039. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1040. };
  1041. /// This instruction Returns the arctangent of the specified value. The return value is within the range of -PI/2 to PI/2.
  1042. struct DxilInst_Atan {
  1043. llvm::Instruction *Instr;
  1044. // Construction and identification
  1045. DxilInst_Atan(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1046. operator bool() const {
  1047. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Atan);
  1048. }
  1049. // Validation support
  1050. bool isAllowed() const { return true; }
  1051. bool isArgumentListValid() const {
  1052. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1053. return true;
  1054. }
  1055. // Operand indexes
  1056. enum OperandIdx {
  1057. arg_value = 1,
  1058. };
  1059. // Accessors
  1060. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1061. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1062. };
  1063. /// This instruction returns the hyperbolic cosine of the specified value.
  1064. struct DxilInst_Hcos {
  1065. llvm::Instruction *Instr;
  1066. // Construction and identification
  1067. DxilInst_Hcos(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1068. operator bool() const {
  1069. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Hcos);
  1070. }
  1071. // Validation support
  1072. bool isAllowed() const { return true; }
  1073. bool isArgumentListValid() const {
  1074. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1075. return true;
  1076. }
  1077. // Operand indexes
  1078. enum OperandIdx {
  1079. arg_value = 1,
  1080. };
  1081. // Accessors
  1082. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1083. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1084. };
  1085. /// This instruction returns the hyperbolic sine of the specified value.
  1086. struct DxilInst_Hsin {
  1087. llvm::Instruction *Instr;
  1088. // Construction and identification
  1089. DxilInst_Hsin(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1090. operator bool() const {
  1091. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Hsin);
  1092. }
  1093. // Validation support
  1094. bool isAllowed() const { return true; }
  1095. bool isArgumentListValid() const {
  1096. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1097. return true;
  1098. }
  1099. // Operand indexes
  1100. enum OperandIdx {
  1101. arg_value = 1,
  1102. };
  1103. // Accessors
  1104. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1105. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1106. };
  1107. /// This instruction returns the hyperbolic tangent of the specified value.
  1108. struct DxilInst_Htan {
  1109. llvm::Instruction *Instr;
  1110. // Construction and identification
  1111. DxilInst_Htan(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1112. operator bool() const {
  1113. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Htan);
  1114. }
  1115. // Validation support
  1116. bool isAllowed() const { return true; }
  1117. bool isArgumentListValid() const {
  1118. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1119. return true;
  1120. }
  1121. // Operand indexes
  1122. enum OperandIdx {
  1123. arg_value = 1,
  1124. };
  1125. // Accessors
  1126. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1127. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1128. };
  1129. /// This instruction returns 2^exponent
  1130. struct DxilInst_Exp {
  1131. llvm::Instruction *Instr;
  1132. // Construction and identification
  1133. DxilInst_Exp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1134. operator bool() const {
  1135. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Exp);
  1136. }
  1137. // Validation support
  1138. bool isAllowed() const { return true; }
  1139. bool isArgumentListValid() const {
  1140. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1141. return true;
  1142. }
  1143. // Operand indexes
  1144. enum OperandIdx {
  1145. arg_value = 1,
  1146. };
  1147. // Accessors
  1148. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1149. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1150. };
  1151. /// This instruction extract fracitonal component.
  1152. struct DxilInst_Frc {
  1153. llvm::Instruction *Instr;
  1154. // Construction and identification
  1155. DxilInst_Frc(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1156. operator bool() const {
  1157. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Frc);
  1158. }
  1159. // Validation support
  1160. bool isAllowed() const { return true; }
  1161. bool isArgumentListValid() const {
  1162. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1163. return true;
  1164. }
  1165. // Operand indexes
  1166. enum OperandIdx {
  1167. arg_value = 1,
  1168. };
  1169. // Accessors
  1170. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1171. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1172. };
  1173. /// This instruction returns log base 2.
  1174. struct DxilInst_Log {
  1175. llvm::Instruction *Instr;
  1176. // Construction and identification
  1177. DxilInst_Log(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1178. operator bool() const {
  1179. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Log);
  1180. }
  1181. // Validation support
  1182. bool isAllowed() const { return true; }
  1183. bool isArgumentListValid() const {
  1184. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1185. return true;
  1186. }
  1187. // Operand indexes
  1188. enum OperandIdx {
  1189. arg_value = 1,
  1190. };
  1191. // Accessors
  1192. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1193. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1194. };
  1195. /// This instruction returns square root
  1196. struct DxilInst_Sqrt {
  1197. llvm::Instruction *Instr;
  1198. // Construction and identification
  1199. DxilInst_Sqrt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1200. operator bool() const {
  1201. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Sqrt);
  1202. }
  1203. // Validation support
  1204. bool isAllowed() const { return true; }
  1205. bool isArgumentListValid() const {
  1206. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1207. return true;
  1208. }
  1209. // Operand indexes
  1210. enum OperandIdx {
  1211. arg_value = 1,
  1212. };
  1213. // Accessors
  1214. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1215. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1216. };
  1217. /// This instruction returns reciprocal square root (1 / sqrt(src)
  1218. struct DxilInst_Rsqrt {
  1219. llvm::Instruction *Instr;
  1220. // Construction and identification
  1221. DxilInst_Rsqrt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1222. operator bool() const {
  1223. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Rsqrt);
  1224. }
  1225. // Validation support
  1226. bool isAllowed() const { return true; }
  1227. bool isArgumentListValid() const {
  1228. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1229. return true;
  1230. }
  1231. // Operand indexes
  1232. enum OperandIdx {
  1233. arg_value = 1,
  1234. };
  1235. // Accessors
  1236. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1237. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1238. };
  1239. /// This instruction floating-point round to integral float.
  1240. struct DxilInst_Round_ne {
  1241. llvm::Instruction *Instr;
  1242. // Construction and identification
  1243. DxilInst_Round_ne(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1244. operator bool() const {
  1245. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_ne);
  1246. }
  1247. // Validation support
  1248. bool isAllowed() const { return true; }
  1249. bool isArgumentListValid() const {
  1250. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1251. return true;
  1252. }
  1253. // Operand indexes
  1254. enum OperandIdx {
  1255. arg_value = 1,
  1256. };
  1257. // Accessors
  1258. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1259. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1260. };
  1261. /// This instruction floating-point round to integral float.
  1262. struct DxilInst_Round_ni {
  1263. llvm::Instruction *Instr;
  1264. // Construction and identification
  1265. DxilInst_Round_ni(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1266. operator bool() const {
  1267. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_ni);
  1268. }
  1269. // Validation support
  1270. bool isAllowed() const { return true; }
  1271. bool isArgumentListValid() const {
  1272. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1273. return true;
  1274. }
  1275. // Operand indexes
  1276. enum OperandIdx {
  1277. arg_value = 1,
  1278. };
  1279. // Accessors
  1280. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1281. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1282. };
  1283. /// This instruction floating-point round to integral float.
  1284. struct DxilInst_Round_pi {
  1285. llvm::Instruction *Instr;
  1286. // Construction and identification
  1287. DxilInst_Round_pi(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1288. operator bool() const {
  1289. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_pi);
  1290. }
  1291. // Validation support
  1292. bool isAllowed() const { return true; }
  1293. bool isArgumentListValid() const {
  1294. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1295. return true;
  1296. }
  1297. // Operand indexes
  1298. enum OperandIdx {
  1299. arg_value = 1,
  1300. };
  1301. // Accessors
  1302. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1303. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1304. };
  1305. /// This instruction floating-point round to integral float.
  1306. struct DxilInst_Round_z {
  1307. llvm::Instruction *Instr;
  1308. // Construction and identification
  1309. DxilInst_Round_z(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1310. operator bool() const {
  1311. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_z);
  1312. }
  1313. // Validation support
  1314. bool isAllowed() const { return true; }
  1315. bool isArgumentListValid() const {
  1316. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1317. return true;
  1318. }
  1319. // Operand indexes
  1320. enum OperandIdx {
  1321. arg_value = 1,
  1322. };
  1323. // Accessors
  1324. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1325. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1326. };
  1327. /// This instruction Reverses the order of the bits.
  1328. struct DxilInst_Bfrev {
  1329. llvm::Instruction *Instr;
  1330. // Construction and identification
  1331. DxilInst_Bfrev(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1332. operator bool() const {
  1333. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Bfrev);
  1334. }
  1335. // Validation support
  1336. bool isAllowed() const { return true; }
  1337. bool isArgumentListValid() const {
  1338. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1339. return true;
  1340. }
  1341. // Operand indexes
  1342. enum OperandIdx {
  1343. arg_value = 1,
  1344. };
  1345. // Accessors
  1346. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1347. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1348. };
  1349. /// This instruction Counts the number of bits in the input integer.
  1350. struct DxilInst_Countbits {
  1351. llvm::Instruction *Instr;
  1352. // Construction and identification
  1353. DxilInst_Countbits(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1354. operator bool() const {
  1355. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Countbits);
  1356. }
  1357. // Validation support
  1358. bool isAllowed() const { return true; }
  1359. bool isArgumentListValid() const {
  1360. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1361. return true;
  1362. }
  1363. // Operand indexes
  1364. enum OperandIdx {
  1365. arg_value = 1,
  1366. };
  1367. // Accessors
  1368. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1369. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1370. };
  1371. /// This instruction Returns the location of the first set bit starting from the lowest order bit and working upward.
  1372. struct DxilInst_FirstbitLo {
  1373. llvm::Instruction *Instr;
  1374. // Construction and identification
  1375. DxilInst_FirstbitLo(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1376. operator bool() const {
  1377. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FirstbitLo);
  1378. }
  1379. // Validation support
  1380. bool isAllowed() const { return true; }
  1381. bool isArgumentListValid() const {
  1382. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1383. return true;
  1384. }
  1385. // Operand indexes
  1386. enum OperandIdx {
  1387. arg_value = 1,
  1388. };
  1389. // Accessors
  1390. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1391. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1392. };
  1393. /// This instruction Returns the location of the first set bit starting from the highest order bit and working downward.
  1394. struct DxilInst_FirstbitHi {
  1395. llvm::Instruction *Instr;
  1396. // Construction and identification
  1397. DxilInst_FirstbitHi(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1398. operator bool() const {
  1399. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FirstbitHi);
  1400. }
  1401. // Validation support
  1402. bool isAllowed() const { return true; }
  1403. bool isArgumentListValid() const {
  1404. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1405. return true;
  1406. }
  1407. // Operand indexes
  1408. enum OperandIdx {
  1409. arg_value = 1,
  1410. };
  1411. // Accessors
  1412. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1413. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1414. };
  1415. /// This instruction Returns the location of the first set bit from the highest order bit based on the sign.
  1416. struct DxilInst_FirstbitSHi {
  1417. llvm::Instruction *Instr;
  1418. // Construction and identification
  1419. DxilInst_FirstbitSHi(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1420. operator bool() const {
  1421. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FirstbitSHi);
  1422. }
  1423. // Validation support
  1424. bool isAllowed() const { return true; }
  1425. bool isArgumentListValid() const {
  1426. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1427. return true;
  1428. }
  1429. // Operand indexes
  1430. enum OperandIdx {
  1431. arg_value = 1,
  1432. };
  1433. // Accessors
  1434. llvm::Value *get_value() const { return Instr->getOperand(1); }
  1435. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  1436. };
  1437. /// This instruction returns a if a >= b, else b
  1438. struct DxilInst_FMax {
  1439. llvm::Instruction *Instr;
  1440. // Construction and identification
  1441. DxilInst_FMax(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1442. operator bool() const {
  1443. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FMax);
  1444. }
  1445. // Validation support
  1446. bool isAllowed() const { return true; }
  1447. bool isArgumentListValid() const {
  1448. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1449. return true;
  1450. }
  1451. // Operand indexes
  1452. enum OperandIdx {
  1453. arg_a = 1,
  1454. arg_b = 2,
  1455. };
  1456. // Accessors
  1457. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1458. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1459. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1460. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1461. };
  1462. /// This instruction returns a if a < b, else b
  1463. struct DxilInst_FMin {
  1464. llvm::Instruction *Instr;
  1465. // Construction and identification
  1466. DxilInst_FMin(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1467. operator bool() const {
  1468. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FMin);
  1469. }
  1470. // Validation support
  1471. bool isAllowed() const { return true; }
  1472. bool isArgumentListValid() const {
  1473. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1474. return true;
  1475. }
  1476. // Operand indexes
  1477. enum OperandIdx {
  1478. arg_a = 1,
  1479. arg_b = 2,
  1480. };
  1481. // Accessors
  1482. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1483. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1484. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1485. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1486. };
  1487. /// This instruction IMax(a,b) returns a if a > b, else b
  1488. struct DxilInst_IMax {
  1489. llvm::Instruction *Instr;
  1490. // Construction and identification
  1491. DxilInst_IMax(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1492. operator bool() const {
  1493. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMax);
  1494. }
  1495. // Validation support
  1496. bool isAllowed() const { return true; }
  1497. bool isArgumentListValid() const {
  1498. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1499. return true;
  1500. }
  1501. // Operand indexes
  1502. enum OperandIdx {
  1503. arg_a = 1,
  1504. arg_b = 2,
  1505. };
  1506. // Accessors
  1507. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1508. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1509. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1510. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1511. };
  1512. /// This instruction IMin(a,b) returns a if a < b, else b
  1513. struct DxilInst_IMin {
  1514. llvm::Instruction *Instr;
  1515. // Construction and identification
  1516. DxilInst_IMin(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1517. operator bool() const {
  1518. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMin);
  1519. }
  1520. // Validation support
  1521. bool isAllowed() const { return true; }
  1522. bool isArgumentListValid() const {
  1523. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1524. return true;
  1525. }
  1526. // Operand indexes
  1527. enum OperandIdx {
  1528. arg_a = 1,
  1529. arg_b = 2,
  1530. };
  1531. // Accessors
  1532. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1533. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1534. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1535. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1536. };
  1537. /// This instruction unsigned integer maximum. UMax(a,b) = a > b ? a : b
  1538. struct DxilInst_UMax {
  1539. llvm::Instruction *Instr;
  1540. // Construction and identification
  1541. DxilInst_UMax(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1542. operator bool() const {
  1543. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMax);
  1544. }
  1545. // Validation support
  1546. bool isAllowed() const { return true; }
  1547. bool isArgumentListValid() const {
  1548. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1549. return true;
  1550. }
  1551. // Operand indexes
  1552. enum OperandIdx {
  1553. arg_a = 1,
  1554. arg_b = 2,
  1555. };
  1556. // Accessors
  1557. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1558. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1559. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1560. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1561. };
  1562. /// This instruction unsigned integer minimum. UMin(a,b) = a < b ? a : b
  1563. struct DxilInst_UMin {
  1564. llvm::Instruction *Instr;
  1565. // Construction and identification
  1566. DxilInst_UMin(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1567. operator bool() const {
  1568. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMin);
  1569. }
  1570. // Validation support
  1571. bool isAllowed() const { return true; }
  1572. bool isArgumentListValid() const {
  1573. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1574. return true;
  1575. }
  1576. // Operand indexes
  1577. enum OperandIdx {
  1578. arg_a = 1,
  1579. arg_b = 2,
  1580. };
  1581. // Accessors
  1582. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1583. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1584. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1585. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1586. };
  1587. /// This instruction multiply of 32-bit operands to produce the correct full 64-bit result.
  1588. struct DxilInst_IMul {
  1589. llvm::Instruction *Instr;
  1590. // Construction and identification
  1591. DxilInst_IMul(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1592. operator bool() const {
  1593. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMul);
  1594. }
  1595. // Validation support
  1596. bool isAllowed() const { return true; }
  1597. bool isArgumentListValid() const {
  1598. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1599. return true;
  1600. }
  1601. // Operand indexes
  1602. enum OperandIdx {
  1603. arg_a = 1,
  1604. arg_b = 2,
  1605. };
  1606. // Accessors
  1607. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1608. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1609. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1610. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1611. };
  1612. /// This instruction multiply of 32-bit operands to produce the correct full 64-bit result.
  1613. struct DxilInst_UMul {
  1614. llvm::Instruction *Instr;
  1615. // Construction and identification
  1616. DxilInst_UMul(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1617. operator bool() const {
  1618. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMul);
  1619. }
  1620. // Validation support
  1621. bool isAllowed() const { return true; }
  1622. bool isArgumentListValid() const {
  1623. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1624. return true;
  1625. }
  1626. // Operand indexes
  1627. enum OperandIdx {
  1628. arg_a = 1,
  1629. arg_b = 2,
  1630. };
  1631. // Accessors
  1632. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1633. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1634. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1635. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1636. };
  1637. /// This instruction unsigned divide of the 32-bit operand src0 by the 32-bit operand src1.
  1638. struct DxilInst_UDiv {
  1639. llvm::Instruction *Instr;
  1640. // Construction and identification
  1641. DxilInst_UDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1642. operator bool() const {
  1643. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UDiv);
  1644. }
  1645. // Validation support
  1646. bool isAllowed() const { return true; }
  1647. bool isArgumentListValid() const {
  1648. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1649. return true;
  1650. }
  1651. // Operand indexes
  1652. enum OperandIdx {
  1653. arg_a = 1,
  1654. arg_b = 2,
  1655. };
  1656. // Accessors
  1657. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1658. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1659. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1660. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1661. };
  1662. /// This instruction unsigned add of 32-bit operand with the carry
  1663. struct DxilInst_UAddc {
  1664. llvm::Instruction *Instr;
  1665. // Construction and identification
  1666. DxilInst_UAddc(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1667. operator bool() const {
  1668. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UAddc);
  1669. }
  1670. // Validation support
  1671. bool isAllowed() const { return true; }
  1672. bool isArgumentListValid() const {
  1673. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1674. return true;
  1675. }
  1676. // Operand indexes
  1677. enum OperandIdx {
  1678. arg_a = 1,
  1679. arg_b = 2,
  1680. };
  1681. // Accessors
  1682. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1683. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1684. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1685. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1686. };
  1687. /// This instruction unsigned subtract of 32-bit operands with the borrow
  1688. struct DxilInst_USubb {
  1689. llvm::Instruction *Instr;
  1690. // Construction and identification
  1691. DxilInst_USubb(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1692. operator bool() const {
  1693. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::USubb);
  1694. }
  1695. // Validation support
  1696. bool isAllowed() const { return true; }
  1697. bool isArgumentListValid() const {
  1698. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1699. return true;
  1700. }
  1701. // Operand indexes
  1702. enum OperandIdx {
  1703. arg_a = 1,
  1704. arg_b = 2,
  1705. };
  1706. // Accessors
  1707. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1708. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1709. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1710. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1711. };
  1712. /// This instruction floating point multiply & add
  1713. struct DxilInst_FMad {
  1714. llvm::Instruction *Instr;
  1715. // Construction and identification
  1716. DxilInst_FMad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1717. operator bool() const {
  1718. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FMad);
  1719. }
  1720. // Validation support
  1721. bool isAllowed() const { return true; }
  1722. bool isArgumentListValid() const {
  1723. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1724. return true;
  1725. }
  1726. // Operand indexes
  1727. enum OperandIdx {
  1728. arg_a = 1,
  1729. arg_b = 2,
  1730. arg_c = 3,
  1731. };
  1732. // Accessors
  1733. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1734. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1735. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1736. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1737. llvm::Value *get_c() const { return Instr->getOperand(3); }
  1738. void set_c(llvm::Value *val) { Instr->setOperand(3, val); }
  1739. };
  1740. /// This instruction fused multiply-add
  1741. struct DxilInst_Fma {
  1742. llvm::Instruction *Instr;
  1743. // Construction and identification
  1744. DxilInst_Fma(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1745. operator bool() const {
  1746. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Fma);
  1747. }
  1748. // Validation support
  1749. bool isAllowed() const { return true; }
  1750. bool isArgumentListValid() const {
  1751. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1752. return true;
  1753. }
  1754. // Operand indexes
  1755. enum OperandIdx {
  1756. arg_a = 1,
  1757. arg_b = 2,
  1758. arg_c = 3,
  1759. };
  1760. // Accessors
  1761. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1762. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1763. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1764. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1765. llvm::Value *get_c() const { return Instr->getOperand(3); }
  1766. void set_c(llvm::Value *val) { Instr->setOperand(3, val); }
  1767. };
  1768. /// This instruction Signed integer multiply & add
  1769. struct DxilInst_IMad {
  1770. llvm::Instruction *Instr;
  1771. // Construction and identification
  1772. DxilInst_IMad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1773. operator bool() const {
  1774. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMad);
  1775. }
  1776. // Validation support
  1777. bool isAllowed() const { return true; }
  1778. bool isArgumentListValid() const {
  1779. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1780. return true;
  1781. }
  1782. // Operand indexes
  1783. enum OperandIdx {
  1784. arg_a = 1,
  1785. arg_b = 2,
  1786. arg_c = 3,
  1787. };
  1788. // Accessors
  1789. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1790. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1791. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1792. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1793. llvm::Value *get_c() const { return Instr->getOperand(3); }
  1794. void set_c(llvm::Value *val) { Instr->setOperand(3, val); }
  1795. };
  1796. /// This instruction Unsigned integer multiply & add
  1797. struct DxilInst_UMad {
  1798. llvm::Instruction *Instr;
  1799. // Construction and identification
  1800. DxilInst_UMad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1801. operator bool() const {
  1802. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMad);
  1803. }
  1804. // Validation support
  1805. bool isAllowed() const { return true; }
  1806. bool isArgumentListValid() const {
  1807. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1808. return true;
  1809. }
  1810. // Operand indexes
  1811. enum OperandIdx {
  1812. arg_a = 1,
  1813. arg_b = 2,
  1814. arg_c = 3,
  1815. };
  1816. // Accessors
  1817. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1818. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1819. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1820. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1821. llvm::Value *get_c() const { return Instr->getOperand(3); }
  1822. void set_c(llvm::Value *val) { Instr->setOperand(3, val); }
  1823. };
  1824. /// This instruction masked Sum of Absolute Differences.
  1825. struct DxilInst_Msad {
  1826. llvm::Instruction *Instr;
  1827. // Construction and identification
  1828. DxilInst_Msad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1829. operator bool() const {
  1830. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Msad);
  1831. }
  1832. // Validation support
  1833. bool isAllowed() const { return true; }
  1834. bool isArgumentListValid() const {
  1835. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1836. return true;
  1837. }
  1838. // Operand indexes
  1839. enum OperandIdx {
  1840. arg_a = 1,
  1841. arg_b = 2,
  1842. arg_c = 3,
  1843. };
  1844. // Accessors
  1845. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1846. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1847. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1848. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1849. llvm::Value *get_c() const { return Instr->getOperand(3); }
  1850. void set_c(llvm::Value *val) { Instr->setOperand(3, val); }
  1851. };
  1852. /// This instruction Integer bitfield extract
  1853. struct DxilInst_Ibfe {
  1854. llvm::Instruction *Instr;
  1855. // Construction and identification
  1856. DxilInst_Ibfe(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1857. operator bool() const {
  1858. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Ibfe);
  1859. }
  1860. // Validation support
  1861. bool isAllowed() const { return true; }
  1862. bool isArgumentListValid() const {
  1863. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1864. return true;
  1865. }
  1866. // Operand indexes
  1867. enum OperandIdx {
  1868. arg_a = 1,
  1869. arg_b = 2,
  1870. arg_c = 3,
  1871. };
  1872. // Accessors
  1873. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1874. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1875. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1876. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1877. llvm::Value *get_c() const { return Instr->getOperand(3); }
  1878. void set_c(llvm::Value *val) { Instr->setOperand(3, val); }
  1879. };
  1880. /// This instruction Unsigned integer bitfield extract
  1881. struct DxilInst_Ubfe {
  1882. llvm::Instruction *Instr;
  1883. // Construction and identification
  1884. DxilInst_Ubfe(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1885. operator bool() const {
  1886. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Ubfe);
  1887. }
  1888. // Validation support
  1889. bool isAllowed() const { return true; }
  1890. bool isArgumentListValid() const {
  1891. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1892. return true;
  1893. }
  1894. // Operand indexes
  1895. enum OperandIdx {
  1896. arg_a = 1,
  1897. arg_b = 2,
  1898. arg_c = 3,
  1899. };
  1900. // Accessors
  1901. llvm::Value *get_a() const { return Instr->getOperand(1); }
  1902. void set_a(llvm::Value *val) { Instr->setOperand(1, val); }
  1903. llvm::Value *get_b() const { return Instr->getOperand(2); }
  1904. void set_b(llvm::Value *val) { Instr->setOperand(2, val); }
  1905. llvm::Value *get_c() const { return Instr->getOperand(3); }
  1906. void set_c(llvm::Value *val) { Instr->setOperand(3, val); }
  1907. };
  1908. /// This instruction Given a bit range from the LSB of a number, places that number of bits in another number at any offset
  1909. struct DxilInst_Bfi {
  1910. llvm::Instruction *Instr;
  1911. // Construction and identification
  1912. DxilInst_Bfi(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1913. operator bool() const {
  1914. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Bfi);
  1915. }
  1916. // Validation support
  1917. bool isAllowed() const { return true; }
  1918. bool isArgumentListValid() const {
  1919. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1920. return true;
  1921. }
  1922. // Operand indexes
  1923. enum OperandIdx {
  1924. arg_width = 1,
  1925. arg_offset = 2,
  1926. arg_value = 3,
  1927. arg_replacedValue = 4,
  1928. };
  1929. // Accessors
  1930. llvm::Value *get_width() const { return Instr->getOperand(1); }
  1931. void set_width(llvm::Value *val) { Instr->setOperand(1, val); }
  1932. llvm::Value *get_offset() const { return Instr->getOperand(2); }
  1933. void set_offset(llvm::Value *val) { Instr->setOperand(2, val); }
  1934. llvm::Value *get_value() const { return Instr->getOperand(3); }
  1935. void set_value(llvm::Value *val) { Instr->setOperand(3, val); }
  1936. llvm::Value *get_replacedValue() const { return Instr->getOperand(4); }
  1937. void set_replacedValue(llvm::Value *val) { Instr->setOperand(4, val); }
  1938. };
  1939. /// This instruction Two-dimensional vector dot-product
  1940. struct DxilInst_Dot2 {
  1941. llvm::Instruction *Instr;
  1942. // Construction and identification
  1943. DxilInst_Dot2(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1944. operator bool() const {
  1945. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot2);
  1946. }
  1947. // Validation support
  1948. bool isAllowed() const { return true; }
  1949. bool isArgumentListValid() const {
  1950. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1951. return true;
  1952. }
  1953. // Operand indexes
  1954. enum OperandIdx {
  1955. arg_ax = 1,
  1956. arg_ay = 2,
  1957. arg_bx = 3,
  1958. arg_by = 4,
  1959. };
  1960. // Accessors
  1961. llvm::Value *get_ax() const { return Instr->getOperand(1); }
  1962. void set_ax(llvm::Value *val) { Instr->setOperand(1, val); }
  1963. llvm::Value *get_ay() const { return Instr->getOperand(2); }
  1964. void set_ay(llvm::Value *val) { Instr->setOperand(2, val); }
  1965. llvm::Value *get_bx() const { return Instr->getOperand(3); }
  1966. void set_bx(llvm::Value *val) { Instr->setOperand(3, val); }
  1967. llvm::Value *get_by() const { return Instr->getOperand(4); }
  1968. void set_by(llvm::Value *val) { Instr->setOperand(4, val); }
  1969. };
  1970. /// This instruction Three-dimensional vector dot-product
  1971. struct DxilInst_Dot3 {
  1972. llvm::Instruction *Instr;
  1973. // Construction and identification
  1974. DxilInst_Dot3(llvm::Instruction *pInstr) : Instr(pInstr) {}
  1975. operator bool() const {
  1976. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot3);
  1977. }
  1978. // Validation support
  1979. bool isAllowed() const { return true; }
  1980. bool isArgumentListValid() const {
  1981. if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  1982. return true;
  1983. }
  1984. // Operand indexes
  1985. enum OperandIdx {
  1986. arg_ax = 1,
  1987. arg_ay = 2,
  1988. arg_az = 3,
  1989. arg_bx = 4,
  1990. arg_by = 5,
  1991. arg_bz = 6,
  1992. };
  1993. // Accessors
  1994. llvm::Value *get_ax() const { return Instr->getOperand(1); }
  1995. void set_ax(llvm::Value *val) { Instr->setOperand(1, val); }
  1996. llvm::Value *get_ay() const { return Instr->getOperand(2); }
  1997. void set_ay(llvm::Value *val) { Instr->setOperand(2, val); }
  1998. llvm::Value *get_az() const { return Instr->getOperand(3); }
  1999. void set_az(llvm::Value *val) { Instr->setOperand(3, val); }
  2000. llvm::Value *get_bx() const { return Instr->getOperand(4); }
  2001. void set_bx(llvm::Value *val) { Instr->setOperand(4, val); }
  2002. llvm::Value *get_by() const { return Instr->getOperand(5); }
  2003. void set_by(llvm::Value *val) { Instr->setOperand(5, val); }
  2004. llvm::Value *get_bz() const { return Instr->getOperand(6); }
  2005. void set_bz(llvm::Value *val) { Instr->setOperand(6, val); }
  2006. };
  2007. /// This instruction Four-dimensional vector dot-product
  2008. struct DxilInst_Dot4 {
  2009. llvm::Instruction *Instr;
  2010. // Construction and identification
  2011. DxilInst_Dot4(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2012. operator bool() const {
  2013. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot4);
  2014. }
  2015. // Validation support
  2016. bool isAllowed() const { return true; }
  2017. bool isArgumentListValid() const {
  2018. if (9 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2019. return true;
  2020. }
  2021. // Operand indexes
  2022. enum OperandIdx {
  2023. arg_ax = 1,
  2024. arg_ay = 2,
  2025. arg_az = 3,
  2026. arg_aw = 4,
  2027. arg_bx = 5,
  2028. arg_by = 6,
  2029. arg_bz = 7,
  2030. arg_bw = 8,
  2031. };
  2032. // Accessors
  2033. llvm::Value *get_ax() const { return Instr->getOperand(1); }
  2034. void set_ax(llvm::Value *val) { Instr->setOperand(1, val); }
  2035. llvm::Value *get_ay() const { return Instr->getOperand(2); }
  2036. void set_ay(llvm::Value *val) { Instr->setOperand(2, val); }
  2037. llvm::Value *get_az() const { return Instr->getOperand(3); }
  2038. void set_az(llvm::Value *val) { Instr->setOperand(3, val); }
  2039. llvm::Value *get_aw() const { return Instr->getOperand(4); }
  2040. void set_aw(llvm::Value *val) { Instr->setOperand(4, val); }
  2041. llvm::Value *get_bx() const { return Instr->getOperand(5); }
  2042. void set_bx(llvm::Value *val) { Instr->setOperand(5, val); }
  2043. llvm::Value *get_by() const { return Instr->getOperand(6); }
  2044. void set_by(llvm::Value *val) { Instr->setOperand(6, val); }
  2045. llvm::Value *get_bz() const { return Instr->getOperand(7); }
  2046. void set_bz(llvm::Value *val) { Instr->setOperand(7, val); }
  2047. llvm::Value *get_bw() const { return Instr->getOperand(8); }
  2048. void set_bw(llvm::Value *val) { Instr->setOperand(8, val); }
  2049. };
  2050. /// This instruction creates the handle to a resource
  2051. struct DxilInst_CreateHandle {
  2052. llvm::Instruction *Instr;
  2053. // Construction and identification
  2054. DxilInst_CreateHandle(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2055. operator bool() const {
  2056. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandle);
  2057. }
  2058. // Validation support
  2059. bool isAllowed() const { return true; }
  2060. bool isArgumentListValid() const {
  2061. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2062. return true;
  2063. }
  2064. // Operand indexes
  2065. enum OperandIdx {
  2066. arg_resourceClass = 1,
  2067. arg_rangeId = 2,
  2068. arg_index = 3,
  2069. arg_nonUniformIndex = 4,
  2070. };
  2071. // Accessors
  2072. llvm::Value *get_resourceClass() const { return Instr->getOperand(1); }
  2073. void set_resourceClass(llvm::Value *val) { Instr->setOperand(1, val); }
  2074. int8_t get_resourceClass_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))->getZExtValue()); }
  2075. void set_resourceClass_val(int8_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  2076. llvm::Value *get_rangeId() const { return Instr->getOperand(2); }
  2077. void set_rangeId(llvm::Value *val) { Instr->setOperand(2, val); }
  2078. int32_t get_rangeId_val() const { return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }
  2079. void set_rangeId_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); }
  2080. llvm::Value *get_index() const { return Instr->getOperand(3); }
  2081. void set_index(llvm::Value *val) { Instr->setOperand(3, val); }
  2082. llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(4); }
  2083. void set_nonUniformIndex(llvm::Value *val) { Instr->setOperand(4, val); }
  2084. bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(4))->getZExtValue()); }
  2085. void set_nonUniformIndex_val(bool val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); }
  2086. };
  2087. /// This instruction loads a value from a constant buffer resource
  2088. struct DxilInst_CBufferLoad {
  2089. llvm::Instruction *Instr;
  2090. // Construction and identification
  2091. DxilInst_CBufferLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2092. operator bool() const {
  2093. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CBufferLoad);
  2094. }
  2095. // Validation support
  2096. bool isAllowed() const { return true; }
  2097. bool isArgumentListValid() const {
  2098. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2099. return true;
  2100. }
  2101. // Operand indexes
  2102. enum OperandIdx {
  2103. arg_handle = 1,
  2104. arg_byteOffset = 2,
  2105. arg_alignment = 3,
  2106. };
  2107. // Accessors
  2108. llvm::Value *get_handle() const { return Instr->getOperand(1); }
  2109. void set_handle(llvm::Value *val) { Instr->setOperand(1, val); }
  2110. llvm::Value *get_byteOffset() const { return Instr->getOperand(2); }
  2111. void set_byteOffset(llvm::Value *val) { Instr->setOperand(2, val); }
  2112. llvm::Value *get_alignment() const { return Instr->getOperand(3); }
  2113. void set_alignment(llvm::Value *val) { Instr->setOperand(3, val); }
  2114. uint32_t get_alignment_val() const { return (uint32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(3))->getZExtValue()); }
  2115. void set_alignment_val(uint32_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); }
  2116. };
  2117. /// This instruction loads a value from a constant buffer resource
  2118. struct DxilInst_CBufferLoadLegacy {
  2119. llvm::Instruction *Instr;
  2120. // Construction and identification
  2121. DxilInst_CBufferLoadLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2122. operator bool() const {
  2123. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CBufferLoadLegacy);
  2124. }
  2125. // Validation support
  2126. bool isAllowed() const { return true; }
  2127. bool isArgumentListValid() const {
  2128. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2129. return true;
  2130. }
  2131. // Operand indexes
  2132. enum OperandIdx {
  2133. arg_handle = 1,
  2134. arg_regIndex = 2,
  2135. };
  2136. // Accessors
  2137. llvm::Value *get_handle() const { return Instr->getOperand(1); }
  2138. void set_handle(llvm::Value *val) { Instr->setOperand(1, val); }
  2139. llvm::Value *get_regIndex() const { return Instr->getOperand(2); }
  2140. void set_regIndex(llvm::Value *val) { Instr->setOperand(2, val); }
  2141. };
  2142. /// This instruction samples a texture
  2143. struct DxilInst_Sample {
  2144. llvm::Instruction *Instr;
  2145. // Construction and identification
  2146. DxilInst_Sample(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2147. operator bool() const {
  2148. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Sample);
  2149. }
  2150. // Validation support
  2151. bool isAllowed() const { return true; }
  2152. bool isArgumentListValid() const {
  2153. if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2154. return true;
  2155. }
  2156. // Operand indexes
  2157. enum OperandIdx {
  2158. arg_srv = 1,
  2159. arg_sampler = 2,
  2160. arg_coord0 = 3,
  2161. arg_coord1 = 4,
  2162. arg_coord2 = 5,
  2163. arg_coord3 = 6,
  2164. arg_offset0 = 7,
  2165. arg_offset1 = 8,
  2166. arg_offset2 = 9,
  2167. arg_clamp = 10,
  2168. };
  2169. // Accessors
  2170. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2171. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2172. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2173. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2174. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2175. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2176. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2177. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2178. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2179. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2180. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2181. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2182. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2183. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2184. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2185. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2186. llvm::Value *get_offset2() const { return Instr->getOperand(9); }
  2187. void set_offset2(llvm::Value *val) { Instr->setOperand(9, val); }
  2188. llvm::Value *get_clamp() const { return Instr->getOperand(10); }
  2189. void set_clamp(llvm::Value *val) { Instr->setOperand(10, val); }
  2190. };
  2191. /// This instruction samples a texture after applying the input bias to the mipmap level
  2192. struct DxilInst_SampleBias {
  2193. llvm::Instruction *Instr;
  2194. // Construction and identification
  2195. DxilInst_SampleBias(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2196. operator bool() const {
  2197. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleBias);
  2198. }
  2199. // Validation support
  2200. bool isAllowed() const { return true; }
  2201. bool isArgumentListValid() const {
  2202. if (12 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2203. return true;
  2204. }
  2205. // Operand indexes
  2206. enum OperandIdx {
  2207. arg_srv = 1,
  2208. arg_sampler = 2,
  2209. arg_coord0 = 3,
  2210. arg_coord1 = 4,
  2211. arg_coord2 = 5,
  2212. arg_coord3 = 6,
  2213. arg_offset0 = 7,
  2214. arg_offset1 = 8,
  2215. arg_offset2 = 9,
  2216. arg_bias = 10,
  2217. arg_clamp = 11,
  2218. };
  2219. // Accessors
  2220. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2221. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2222. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2223. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2224. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2225. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2226. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2227. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2228. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2229. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2230. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2231. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2232. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2233. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2234. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2235. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2236. llvm::Value *get_offset2() const { return Instr->getOperand(9); }
  2237. void set_offset2(llvm::Value *val) { Instr->setOperand(9, val); }
  2238. llvm::Value *get_bias() const { return Instr->getOperand(10); }
  2239. void set_bias(llvm::Value *val) { Instr->setOperand(10, val); }
  2240. llvm::Value *get_clamp() const { return Instr->getOperand(11); }
  2241. void set_clamp(llvm::Value *val) { Instr->setOperand(11, val); }
  2242. };
  2243. /// This instruction samples a texture using a mipmap-level offset
  2244. struct DxilInst_SampleLevel {
  2245. llvm::Instruction *Instr;
  2246. // Construction and identification
  2247. DxilInst_SampleLevel(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2248. operator bool() const {
  2249. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleLevel);
  2250. }
  2251. // Validation support
  2252. bool isAllowed() const { return true; }
  2253. bool isArgumentListValid() const {
  2254. if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2255. return true;
  2256. }
  2257. // Operand indexes
  2258. enum OperandIdx {
  2259. arg_srv = 1,
  2260. arg_sampler = 2,
  2261. arg_coord0 = 3,
  2262. arg_coord1 = 4,
  2263. arg_coord2 = 5,
  2264. arg_coord3 = 6,
  2265. arg_offset0 = 7,
  2266. arg_offset1 = 8,
  2267. arg_offset2 = 9,
  2268. arg_LOD = 10,
  2269. };
  2270. // Accessors
  2271. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2272. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2273. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2274. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2275. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2276. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2277. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2278. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2279. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2280. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2281. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2282. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2283. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2284. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2285. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2286. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2287. llvm::Value *get_offset2() const { return Instr->getOperand(9); }
  2288. void set_offset2(llvm::Value *val) { Instr->setOperand(9, val); }
  2289. llvm::Value *get_LOD() const { return Instr->getOperand(10); }
  2290. void set_LOD(llvm::Value *val) { Instr->setOperand(10, val); }
  2291. };
  2292. /// This instruction samples a texture using a gradient to influence the way the sample location is calculated
  2293. struct DxilInst_SampleGrad {
  2294. llvm::Instruction *Instr;
  2295. // Construction and identification
  2296. DxilInst_SampleGrad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2297. operator bool() const {
  2298. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleGrad);
  2299. }
  2300. // Validation support
  2301. bool isAllowed() const { return true; }
  2302. bool isArgumentListValid() const {
  2303. if (17 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2304. return true;
  2305. }
  2306. // Operand indexes
  2307. enum OperandIdx {
  2308. arg_srv = 1,
  2309. arg_sampler = 2,
  2310. arg_coord0 = 3,
  2311. arg_coord1 = 4,
  2312. arg_coord2 = 5,
  2313. arg_coord3 = 6,
  2314. arg_offset0 = 7,
  2315. arg_offset1 = 8,
  2316. arg_offset2 = 9,
  2317. arg_ddx0 = 10,
  2318. arg_ddx1 = 11,
  2319. arg_ddx2 = 12,
  2320. arg_ddy0 = 13,
  2321. arg_ddy1 = 14,
  2322. arg_ddy2 = 15,
  2323. arg_clamp = 16,
  2324. };
  2325. // Accessors
  2326. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2327. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2328. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2329. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2330. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2331. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2332. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2333. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2334. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2335. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2336. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2337. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2338. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2339. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2340. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2341. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2342. llvm::Value *get_offset2() const { return Instr->getOperand(9); }
  2343. void set_offset2(llvm::Value *val) { Instr->setOperand(9, val); }
  2344. llvm::Value *get_ddx0() const { return Instr->getOperand(10); }
  2345. void set_ddx0(llvm::Value *val) { Instr->setOperand(10, val); }
  2346. llvm::Value *get_ddx1() const { return Instr->getOperand(11); }
  2347. void set_ddx1(llvm::Value *val) { Instr->setOperand(11, val); }
  2348. llvm::Value *get_ddx2() const { return Instr->getOperand(12); }
  2349. void set_ddx2(llvm::Value *val) { Instr->setOperand(12, val); }
  2350. llvm::Value *get_ddy0() const { return Instr->getOperand(13); }
  2351. void set_ddy0(llvm::Value *val) { Instr->setOperand(13, val); }
  2352. llvm::Value *get_ddy1() const { return Instr->getOperand(14); }
  2353. void set_ddy1(llvm::Value *val) { Instr->setOperand(14, val); }
  2354. llvm::Value *get_ddy2() const { return Instr->getOperand(15); }
  2355. void set_ddy2(llvm::Value *val) { Instr->setOperand(15, val); }
  2356. llvm::Value *get_clamp() const { return Instr->getOperand(16); }
  2357. void set_clamp(llvm::Value *val) { Instr->setOperand(16, val); }
  2358. };
  2359. /// This instruction samples a texture and compares a single component against the specified comparison value
  2360. struct DxilInst_SampleCmp {
  2361. llvm::Instruction *Instr;
  2362. // Construction and identification
  2363. DxilInst_SampleCmp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2364. operator bool() const {
  2365. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmp);
  2366. }
  2367. // Validation support
  2368. bool isAllowed() const { return true; }
  2369. bool isArgumentListValid() const {
  2370. if (12 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2371. return true;
  2372. }
  2373. // Operand indexes
  2374. enum OperandIdx {
  2375. arg_srv = 1,
  2376. arg_sampler = 2,
  2377. arg_coord0 = 3,
  2378. arg_coord1 = 4,
  2379. arg_coord2 = 5,
  2380. arg_coord3 = 6,
  2381. arg_offset0 = 7,
  2382. arg_offset1 = 8,
  2383. arg_offset2 = 9,
  2384. arg_compareValue = 10,
  2385. arg_clamp = 11,
  2386. };
  2387. // Accessors
  2388. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2389. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2390. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2391. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2392. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2393. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2394. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2395. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2396. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2397. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2398. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2399. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2400. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2401. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2402. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2403. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2404. llvm::Value *get_offset2() const { return Instr->getOperand(9); }
  2405. void set_offset2(llvm::Value *val) { Instr->setOperand(9, val); }
  2406. llvm::Value *get_compareValue() const { return Instr->getOperand(10); }
  2407. void set_compareValue(llvm::Value *val) { Instr->setOperand(10, val); }
  2408. llvm::Value *get_clamp() const { return Instr->getOperand(11); }
  2409. void set_clamp(llvm::Value *val) { Instr->setOperand(11, val); }
  2410. };
  2411. /// This instruction samples a texture and compares a single component against the specified comparison value
  2412. struct DxilInst_SampleCmpLevelZero {
  2413. llvm::Instruction *Instr;
  2414. // Construction and identification
  2415. DxilInst_SampleCmpLevelZero(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2416. operator bool() const {
  2417. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpLevelZero);
  2418. }
  2419. // Validation support
  2420. bool isAllowed() const { return true; }
  2421. bool isArgumentListValid() const {
  2422. if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2423. return true;
  2424. }
  2425. // Operand indexes
  2426. enum OperandIdx {
  2427. arg_srv = 1,
  2428. arg_sampler = 2,
  2429. arg_coord0 = 3,
  2430. arg_coord1 = 4,
  2431. arg_coord2 = 5,
  2432. arg_coord3 = 6,
  2433. arg_offset0 = 7,
  2434. arg_offset1 = 8,
  2435. arg_offset2 = 9,
  2436. arg_compareValue = 10,
  2437. };
  2438. // Accessors
  2439. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2440. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2441. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2442. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2443. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2444. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2445. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2446. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2447. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2448. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2449. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2450. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2451. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2452. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2453. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2454. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2455. llvm::Value *get_offset2() const { return Instr->getOperand(9); }
  2456. void set_offset2(llvm::Value *val) { Instr->setOperand(9, val); }
  2457. llvm::Value *get_compareValue() const { return Instr->getOperand(10); }
  2458. void set_compareValue(llvm::Value *val) { Instr->setOperand(10, val); }
  2459. };
  2460. /// This instruction reads texel data without any filtering or sampling
  2461. struct DxilInst_TextureLoad {
  2462. llvm::Instruction *Instr;
  2463. // Construction and identification
  2464. DxilInst_TextureLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2465. operator bool() const {
  2466. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureLoad);
  2467. }
  2468. // Validation support
  2469. bool isAllowed() const { return true; }
  2470. bool isArgumentListValid() const {
  2471. if (9 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2472. return true;
  2473. }
  2474. // Operand indexes
  2475. enum OperandIdx {
  2476. arg_srv = 1,
  2477. arg_mipLevelOrSampleCount = 2,
  2478. arg_coord0 = 3,
  2479. arg_coord1 = 4,
  2480. arg_coord2 = 5,
  2481. arg_offset0 = 6,
  2482. arg_offset1 = 7,
  2483. arg_offset2 = 8,
  2484. };
  2485. // Accessors
  2486. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2487. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2488. llvm::Value *get_mipLevelOrSampleCount() const { return Instr->getOperand(2); }
  2489. void set_mipLevelOrSampleCount(llvm::Value *val) { Instr->setOperand(2, val); }
  2490. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2491. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2492. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2493. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2494. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2495. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2496. llvm::Value *get_offset0() const { return Instr->getOperand(6); }
  2497. void set_offset0(llvm::Value *val) { Instr->setOperand(6, val); }
  2498. llvm::Value *get_offset1() const { return Instr->getOperand(7); }
  2499. void set_offset1(llvm::Value *val) { Instr->setOperand(7, val); }
  2500. llvm::Value *get_offset2() const { return Instr->getOperand(8); }
  2501. void set_offset2(llvm::Value *val) { Instr->setOperand(8, val); }
  2502. };
  2503. /// This instruction reads texel data without any filtering or sampling
  2504. struct DxilInst_TextureStore {
  2505. llvm::Instruction *Instr;
  2506. // Construction and identification
  2507. DxilInst_TextureStore(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2508. operator bool() const {
  2509. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureStore);
  2510. }
  2511. // Validation support
  2512. bool isAllowed() const { return true; }
  2513. bool isArgumentListValid() const {
  2514. if (10 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2515. return true;
  2516. }
  2517. // Operand indexes
  2518. enum OperandIdx {
  2519. arg_srv = 1,
  2520. arg_coord0 = 2,
  2521. arg_coord1 = 3,
  2522. arg_coord2 = 4,
  2523. arg_value0 = 5,
  2524. arg_value1 = 6,
  2525. arg_value2 = 7,
  2526. arg_value3 = 8,
  2527. arg_mask = 9,
  2528. };
  2529. // Accessors
  2530. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2531. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2532. llvm::Value *get_coord0() const { return Instr->getOperand(2); }
  2533. void set_coord0(llvm::Value *val) { Instr->setOperand(2, val); }
  2534. llvm::Value *get_coord1() const { return Instr->getOperand(3); }
  2535. void set_coord1(llvm::Value *val) { Instr->setOperand(3, val); }
  2536. llvm::Value *get_coord2() const { return Instr->getOperand(4); }
  2537. void set_coord2(llvm::Value *val) { Instr->setOperand(4, val); }
  2538. llvm::Value *get_value0() const { return Instr->getOperand(5); }
  2539. void set_value0(llvm::Value *val) { Instr->setOperand(5, val); }
  2540. llvm::Value *get_value1() const { return Instr->getOperand(6); }
  2541. void set_value1(llvm::Value *val) { Instr->setOperand(6, val); }
  2542. llvm::Value *get_value2() const { return Instr->getOperand(7); }
  2543. void set_value2(llvm::Value *val) { Instr->setOperand(7, val); }
  2544. llvm::Value *get_value3() const { return Instr->getOperand(8); }
  2545. void set_value3(llvm::Value *val) { Instr->setOperand(8, val); }
  2546. llvm::Value *get_mask() const { return Instr->getOperand(9); }
  2547. void set_mask(llvm::Value *val) { Instr->setOperand(9, val); }
  2548. };
  2549. /// This instruction reads from a TypedBuffer
  2550. struct DxilInst_BufferLoad {
  2551. llvm::Instruction *Instr;
  2552. // Construction and identification
  2553. DxilInst_BufferLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2554. operator bool() const {
  2555. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferLoad);
  2556. }
  2557. // Validation support
  2558. bool isAllowed() const { return true; }
  2559. bool isArgumentListValid() const {
  2560. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2561. return true;
  2562. }
  2563. // Operand indexes
  2564. enum OperandIdx {
  2565. arg_srv = 1,
  2566. arg_index = 2,
  2567. arg_wot = 3,
  2568. };
  2569. // Accessors
  2570. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2571. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2572. llvm::Value *get_index() const { return Instr->getOperand(2); }
  2573. void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
  2574. llvm::Value *get_wot() const { return Instr->getOperand(3); }
  2575. void set_wot(llvm::Value *val) { Instr->setOperand(3, val); }
  2576. };
  2577. /// This instruction writes to a RWTypedBuffer
  2578. struct DxilInst_BufferStore {
  2579. llvm::Instruction *Instr;
  2580. // Construction and identification
  2581. DxilInst_BufferStore(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2582. operator bool() const {
  2583. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferStore);
  2584. }
  2585. // Validation support
  2586. bool isAllowed() const { return true; }
  2587. bool isArgumentListValid() const {
  2588. if (9 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2589. return true;
  2590. }
  2591. // Operand indexes
  2592. enum OperandIdx {
  2593. arg_uav = 1,
  2594. arg_coord0 = 2,
  2595. arg_coord1 = 3,
  2596. arg_value0 = 4,
  2597. arg_value1 = 5,
  2598. arg_value2 = 6,
  2599. arg_value3 = 7,
  2600. arg_mask = 8,
  2601. };
  2602. // Accessors
  2603. llvm::Value *get_uav() const { return Instr->getOperand(1); }
  2604. void set_uav(llvm::Value *val) { Instr->setOperand(1, val); }
  2605. llvm::Value *get_coord0() const { return Instr->getOperand(2); }
  2606. void set_coord0(llvm::Value *val) { Instr->setOperand(2, val); }
  2607. llvm::Value *get_coord1() const { return Instr->getOperand(3); }
  2608. void set_coord1(llvm::Value *val) { Instr->setOperand(3, val); }
  2609. llvm::Value *get_value0() const { return Instr->getOperand(4); }
  2610. void set_value0(llvm::Value *val) { Instr->setOperand(4, val); }
  2611. llvm::Value *get_value1() const { return Instr->getOperand(5); }
  2612. void set_value1(llvm::Value *val) { Instr->setOperand(5, val); }
  2613. llvm::Value *get_value2() const { return Instr->getOperand(6); }
  2614. void set_value2(llvm::Value *val) { Instr->setOperand(6, val); }
  2615. llvm::Value *get_value3() const { return Instr->getOperand(7); }
  2616. void set_value3(llvm::Value *val) { Instr->setOperand(7, val); }
  2617. llvm::Value *get_mask() const { return Instr->getOperand(8); }
  2618. void set_mask(llvm::Value *val) { Instr->setOperand(8, val); }
  2619. };
  2620. /// This instruction atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV
  2621. struct DxilInst_BufferUpdateCounter {
  2622. llvm::Instruction *Instr;
  2623. // Construction and identification
  2624. DxilInst_BufferUpdateCounter(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2625. operator bool() const {
  2626. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferUpdateCounter);
  2627. }
  2628. // Validation support
  2629. bool isAllowed() const { return true; }
  2630. bool isArgumentListValid() const {
  2631. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2632. return true;
  2633. }
  2634. // Operand indexes
  2635. enum OperandIdx {
  2636. arg_uav = 1,
  2637. arg_inc = 2,
  2638. };
  2639. // Accessors
  2640. llvm::Value *get_uav() const { return Instr->getOperand(1); }
  2641. void set_uav(llvm::Value *val) { Instr->setOperand(1, val); }
  2642. llvm::Value *get_inc() const { return Instr->getOperand(2); }
  2643. void set_inc(llvm::Value *val) { Instr->setOperand(2, val); }
  2644. };
  2645. /// This instruction determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource
  2646. struct DxilInst_CheckAccessFullyMapped {
  2647. llvm::Instruction *Instr;
  2648. // Construction and identification
  2649. DxilInst_CheckAccessFullyMapped(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2650. operator bool() const {
  2651. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CheckAccessFullyMapped);
  2652. }
  2653. // Validation support
  2654. bool isAllowed() const { return true; }
  2655. bool isArgumentListValid() const {
  2656. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2657. return true;
  2658. }
  2659. // Operand indexes
  2660. enum OperandIdx {
  2661. arg_status = 1,
  2662. };
  2663. // Accessors
  2664. llvm::Value *get_status() const { return Instr->getOperand(1); }
  2665. void set_status(llvm::Value *val) { Instr->setOperand(1, val); }
  2666. };
  2667. /// This instruction gets texture size information
  2668. struct DxilInst_GetDimensions {
  2669. llvm::Instruction *Instr;
  2670. // Construction and identification
  2671. DxilInst_GetDimensions(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2672. operator bool() const {
  2673. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetDimensions);
  2674. }
  2675. // Validation support
  2676. bool isAllowed() const { return true; }
  2677. bool isArgumentListValid() const {
  2678. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2679. return true;
  2680. }
  2681. // Operand indexes
  2682. enum OperandIdx {
  2683. arg_handle = 1,
  2684. arg_mipLevel = 2,
  2685. };
  2686. // Accessors
  2687. llvm::Value *get_handle() const { return Instr->getOperand(1); }
  2688. void set_handle(llvm::Value *val) { Instr->setOperand(1, val); }
  2689. llvm::Value *get_mipLevel() const { return Instr->getOperand(2); }
  2690. void set_mipLevel(llvm::Value *val) { Instr->setOperand(2, val); }
  2691. };
  2692. /// This instruction gathers the four texels that would be used in a bi-linear filtering operation
  2693. struct DxilInst_TextureGather {
  2694. llvm::Instruction *Instr;
  2695. // Construction and identification
  2696. DxilInst_TextureGather(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2697. operator bool() const {
  2698. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGather);
  2699. }
  2700. // Validation support
  2701. bool isAllowed() const { return true; }
  2702. bool isArgumentListValid() const {
  2703. if (10 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2704. return true;
  2705. }
  2706. // Operand indexes
  2707. enum OperandIdx {
  2708. arg_srv = 1,
  2709. arg_sampler = 2,
  2710. arg_coord0 = 3,
  2711. arg_coord1 = 4,
  2712. arg_coord2 = 5,
  2713. arg_coord3 = 6,
  2714. arg_offset0 = 7,
  2715. arg_offset1 = 8,
  2716. arg_channel = 9,
  2717. };
  2718. // Accessors
  2719. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2720. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2721. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2722. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2723. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2724. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2725. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2726. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2727. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2728. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2729. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2730. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2731. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2732. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2733. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2734. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2735. llvm::Value *get_channel() const { return Instr->getOperand(9); }
  2736. void set_channel(llvm::Value *val) { Instr->setOperand(9, val); }
  2737. };
  2738. /// This instruction same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp
  2739. struct DxilInst_TextureGatherCmp {
  2740. llvm::Instruction *Instr;
  2741. // Construction and identification
  2742. DxilInst_TextureGatherCmp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2743. operator bool() const {
  2744. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGatherCmp);
  2745. }
  2746. // Validation support
  2747. bool isAllowed() const { return true; }
  2748. bool isArgumentListValid() const {
  2749. if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2750. return true;
  2751. }
  2752. // Operand indexes
  2753. enum OperandIdx {
  2754. arg_srv = 1,
  2755. arg_sampler = 2,
  2756. arg_coord0 = 3,
  2757. arg_coord1 = 4,
  2758. arg_coord2 = 5,
  2759. arg_coord3 = 6,
  2760. arg_offset0 = 7,
  2761. arg_offset1 = 8,
  2762. arg_channel = 9,
  2763. arg_compareVale = 10,
  2764. };
  2765. // Accessors
  2766. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2767. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2768. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2769. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2770. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2771. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2772. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2773. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2774. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2775. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2776. llvm::Value *get_coord3() const { return Instr->getOperand(6); }
  2777. void set_coord3(llvm::Value *val) { Instr->setOperand(6, val); }
  2778. llvm::Value *get_offset0() const { return Instr->getOperand(7); }
  2779. void set_offset0(llvm::Value *val) { Instr->setOperand(7, val); }
  2780. llvm::Value *get_offset1() const { return Instr->getOperand(8); }
  2781. void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); }
  2782. llvm::Value *get_channel() const { return Instr->getOperand(9); }
  2783. void set_channel(llvm::Value *val) { Instr->setOperand(9, val); }
  2784. llvm::Value *get_compareVale() const { return Instr->getOperand(10); }
  2785. void set_compareVale(llvm::Value *val) { Instr->setOperand(10, val); }
  2786. };
  2787. /// This instruction gets the position of the specified sample
  2788. struct DxilInst_Texture2DMSGetSamplePosition {
  2789. llvm::Instruction *Instr;
  2790. // Construction and identification
  2791. DxilInst_Texture2DMSGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2792. operator bool() const {
  2793. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Texture2DMSGetSamplePosition);
  2794. }
  2795. // Validation support
  2796. bool isAllowed() const { return true; }
  2797. bool isArgumentListValid() const {
  2798. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2799. return true;
  2800. }
  2801. // Operand indexes
  2802. enum OperandIdx {
  2803. arg_srv = 1,
  2804. arg_index = 2,
  2805. };
  2806. // Accessors
  2807. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  2808. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  2809. llvm::Value *get_index() const { return Instr->getOperand(2); }
  2810. void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
  2811. };
  2812. /// This instruction gets the position of the specified sample
  2813. struct DxilInst_RenderTargetGetSamplePosition {
  2814. llvm::Instruction *Instr;
  2815. // Construction and identification
  2816. DxilInst_RenderTargetGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2817. operator bool() const {
  2818. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSamplePosition);
  2819. }
  2820. // Validation support
  2821. bool isAllowed() const { return true; }
  2822. bool isArgumentListValid() const {
  2823. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2824. return true;
  2825. }
  2826. // Operand indexes
  2827. enum OperandIdx {
  2828. arg_index = 1,
  2829. };
  2830. // Accessors
  2831. llvm::Value *get_index() const { return Instr->getOperand(1); }
  2832. void set_index(llvm::Value *val) { Instr->setOperand(1, val); }
  2833. };
  2834. /// This instruction gets the number of samples for a render target
  2835. struct DxilInst_RenderTargetGetSampleCount {
  2836. llvm::Instruction *Instr;
  2837. // Construction and identification
  2838. DxilInst_RenderTargetGetSampleCount(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2839. operator bool() const {
  2840. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSampleCount);
  2841. }
  2842. // Validation support
  2843. bool isAllowed() const { return true; }
  2844. bool isArgumentListValid() const {
  2845. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2846. return true;
  2847. }
  2848. };
  2849. /// This instruction performs an atomic operation on two operands
  2850. struct DxilInst_AtomicBinOp {
  2851. llvm::Instruction *Instr;
  2852. // Construction and identification
  2853. DxilInst_AtomicBinOp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2854. operator bool() const {
  2855. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AtomicBinOp);
  2856. }
  2857. // Validation support
  2858. bool isAllowed() const { return true; }
  2859. bool isArgumentListValid() const {
  2860. if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2861. return true;
  2862. }
  2863. // Operand indexes
  2864. enum OperandIdx {
  2865. arg_handle = 1,
  2866. arg_atomicOp = 2,
  2867. arg_offset0 = 3,
  2868. arg_offset1 = 4,
  2869. arg_offset2 = 5,
  2870. arg_newValue = 6,
  2871. };
  2872. // Accessors
  2873. llvm::Value *get_handle() const { return Instr->getOperand(1); }
  2874. void set_handle(llvm::Value *val) { Instr->setOperand(1, val); }
  2875. llvm::Value *get_atomicOp() const { return Instr->getOperand(2); }
  2876. void set_atomicOp(llvm::Value *val) { Instr->setOperand(2, val); }
  2877. llvm::Value *get_offset0() const { return Instr->getOperand(3); }
  2878. void set_offset0(llvm::Value *val) { Instr->setOperand(3, val); }
  2879. llvm::Value *get_offset1() const { return Instr->getOperand(4); }
  2880. void set_offset1(llvm::Value *val) { Instr->setOperand(4, val); }
  2881. llvm::Value *get_offset2() const { return Instr->getOperand(5); }
  2882. void set_offset2(llvm::Value *val) { Instr->setOperand(5, val); }
  2883. llvm::Value *get_newValue() const { return Instr->getOperand(6); }
  2884. void set_newValue(llvm::Value *val) { Instr->setOperand(6, val); }
  2885. };
  2886. /// This instruction atomic compare and exchange to memory
  2887. struct DxilInst_AtomicCompareExchange {
  2888. llvm::Instruction *Instr;
  2889. // Construction and identification
  2890. DxilInst_AtomicCompareExchange(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2891. operator bool() const {
  2892. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AtomicCompareExchange);
  2893. }
  2894. // Validation support
  2895. bool isAllowed() const { return true; }
  2896. bool isArgumentListValid() const {
  2897. if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2898. return true;
  2899. }
  2900. // Operand indexes
  2901. enum OperandIdx {
  2902. arg_handle = 1,
  2903. arg_offset0 = 2,
  2904. arg_offset1 = 3,
  2905. arg_offset2 = 4,
  2906. arg_compareValue = 5,
  2907. arg_newValue = 6,
  2908. };
  2909. // Accessors
  2910. llvm::Value *get_handle() const { return Instr->getOperand(1); }
  2911. void set_handle(llvm::Value *val) { Instr->setOperand(1, val); }
  2912. llvm::Value *get_offset0() const { return Instr->getOperand(2); }
  2913. void set_offset0(llvm::Value *val) { Instr->setOperand(2, val); }
  2914. llvm::Value *get_offset1() const { return Instr->getOperand(3); }
  2915. void set_offset1(llvm::Value *val) { Instr->setOperand(3, val); }
  2916. llvm::Value *get_offset2() const { return Instr->getOperand(4); }
  2917. void set_offset2(llvm::Value *val) { Instr->setOperand(4, val); }
  2918. llvm::Value *get_compareValue() const { return Instr->getOperand(5); }
  2919. void set_compareValue(llvm::Value *val) { Instr->setOperand(5, val); }
  2920. llvm::Value *get_newValue() const { return Instr->getOperand(6); }
  2921. void set_newValue(llvm::Value *val) { Instr->setOperand(6, val); }
  2922. };
  2923. /// This instruction inserts a memory barrier in the shader
  2924. struct DxilInst_Barrier {
  2925. llvm::Instruction *Instr;
  2926. // Construction and identification
  2927. DxilInst_Barrier(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2928. operator bool() const {
  2929. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Barrier);
  2930. }
  2931. // Validation support
  2932. bool isAllowed() const { return true; }
  2933. bool isArgumentListValid() const {
  2934. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2935. return true;
  2936. }
  2937. // Operand indexes
  2938. enum OperandIdx {
  2939. arg_barrierMode = 1,
  2940. };
  2941. // Accessors
  2942. llvm::Value *get_barrierMode() const { return Instr->getOperand(1); }
  2943. void set_barrierMode(llvm::Value *val) { Instr->setOperand(1, val); }
  2944. int32_t get_barrierMode_val() const { return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))->getZExtValue()); }
  2945. void set_barrierMode_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); }
  2946. };
  2947. /// This instruction calculates the level of detail
  2948. struct DxilInst_CalculateLOD {
  2949. llvm::Instruction *Instr;
  2950. // Construction and identification
  2951. DxilInst_CalculateLOD(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2952. operator bool() const {
  2953. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CalculateLOD);
  2954. }
  2955. // Validation support
  2956. bool isAllowed() const { return true; }
  2957. bool isArgumentListValid() const {
  2958. if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2959. return true;
  2960. }
  2961. // Operand indexes
  2962. enum OperandIdx {
  2963. arg_handle = 1,
  2964. arg_sampler = 2,
  2965. arg_coord0 = 3,
  2966. arg_coord1 = 4,
  2967. arg_coord2 = 5,
  2968. arg_clamped = 6,
  2969. };
  2970. // Accessors
  2971. llvm::Value *get_handle() const { return Instr->getOperand(1); }
  2972. void set_handle(llvm::Value *val) { Instr->setOperand(1, val); }
  2973. llvm::Value *get_sampler() const { return Instr->getOperand(2); }
  2974. void set_sampler(llvm::Value *val) { Instr->setOperand(2, val); }
  2975. llvm::Value *get_coord0() const { return Instr->getOperand(3); }
  2976. void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); }
  2977. llvm::Value *get_coord1() const { return Instr->getOperand(4); }
  2978. void set_coord1(llvm::Value *val) { Instr->setOperand(4, val); }
  2979. llvm::Value *get_coord2() const { return Instr->getOperand(5); }
  2980. void set_coord2(llvm::Value *val) { Instr->setOperand(5, val); }
  2981. llvm::Value *get_clamped() const { return Instr->getOperand(6); }
  2982. void set_clamped(llvm::Value *val) { Instr->setOperand(6, val); }
  2983. };
  2984. /// This instruction discard the current pixel
  2985. struct DxilInst_Discard {
  2986. llvm::Instruction *Instr;
  2987. // Construction and identification
  2988. DxilInst_Discard(llvm::Instruction *pInstr) : Instr(pInstr) {}
  2989. operator bool() const {
  2990. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Discard);
  2991. }
  2992. // Validation support
  2993. bool isAllowed() const { return true; }
  2994. bool isArgumentListValid() const {
  2995. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  2996. return true;
  2997. }
  2998. // Operand indexes
  2999. enum OperandIdx {
  3000. arg_condition = 1,
  3001. };
  3002. // Accessors
  3003. llvm::Value *get_condition() const { return Instr->getOperand(1); }
  3004. void set_condition(llvm::Value *val) { Instr->setOperand(1, val); }
  3005. };
  3006. /// This instruction computes the rate of change per stamp in x direction.
  3007. struct DxilInst_DerivCoarseX {
  3008. llvm::Instruction *Instr;
  3009. // Construction and identification
  3010. DxilInst_DerivCoarseX(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3011. operator bool() const {
  3012. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseX);
  3013. }
  3014. // Validation support
  3015. bool isAllowed() const { return true; }
  3016. bool isArgumentListValid() const {
  3017. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3018. return true;
  3019. }
  3020. // Operand indexes
  3021. enum OperandIdx {
  3022. arg_value = 1,
  3023. };
  3024. // Accessors
  3025. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3026. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3027. };
  3028. /// This instruction computes the rate of change per stamp in y direction.
  3029. struct DxilInst_DerivCoarseY {
  3030. llvm::Instruction *Instr;
  3031. // Construction and identification
  3032. DxilInst_DerivCoarseY(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3033. operator bool() const {
  3034. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseY);
  3035. }
  3036. // Validation support
  3037. bool isAllowed() const { return true; }
  3038. bool isArgumentListValid() const {
  3039. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3040. return true;
  3041. }
  3042. // Operand indexes
  3043. enum OperandIdx {
  3044. arg_value = 1,
  3045. };
  3046. // Accessors
  3047. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3048. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3049. };
  3050. /// This instruction computes the rate of change per pixel in x direction.
  3051. struct DxilInst_DerivFineX {
  3052. llvm::Instruction *Instr;
  3053. // Construction and identification
  3054. DxilInst_DerivFineX(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3055. operator bool() const {
  3056. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivFineX);
  3057. }
  3058. // Validation support
  3059. bool isAllowed() const { return true; }
  3060. bool isArgumentListValid() const {
  3061. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3062. return true;
  3063. }
  3064. // Operand indexes
  3065. enum OperandIdx {
  3066. arg_value = 1,
  3067. };
  3068. // Accessors
  3069. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3070. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3071. };
  3072. /// This instruction computes the rate of change per pixel in y direction.
  3073. struct DxilInst_DerivFineY {
  3074. llvm::Instruction *Instr;
  3075. // Construction and identification
  3076. DxilInst_DerivFineY(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3077. operator bool() const {
  3078. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivFineY);
  3079. }
  3080. // Validation support
  3081. bool isAllowed() const { return true; }
  3082. bool isArgumentListValid() const {
  3083. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3084. return true;
  3085. }
  3086. // Operand indexes
  3087. enum OperandIdx {
  3088. arg_value = 1,
  3089. };
  3090. // Accessors
  3091. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3092. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3093. };
  3094. /// This instruction evaluates an input attribute at pixel center with an offset
  3095. struct DxilInst_EvalSnapped {
  3096. llvm::Instruction *Instr;
  3097. // Construction and identification
  3098. DxilInst_EvalSnapped(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3099. operator bool() const {
  3100. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalSnapped);
  3101. }
  3102. // Validation support
  3103. bool isAllowed() const { return true; }
  3104. bool isArgumentListValid() const {
  3105. if (6 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3106. return true;
  3107. }
  3108. // Operand indexes
  3109. enum OperandIdx {
  3110. arg_inputSigId = 1,
  3111. arg_inputRowIndex = 2,
  3112. arg_inputColIndex = 3,
  3113. arg_offsetX = 4,
  3114. arg_offsetY = 5,
  3115. };
  3116. // Accessors
  3117. llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }
  3118. void set_inputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  3119. llvm::Value *get_inputRowIndex() const { return Instr->getOperand(2); }
  3120. void set_inputRowIndex(llvm::Value *val) { Instr->setOperand(2, val); }
  3121. llvm::Value *get_inputColIndex() const { return Instr->getOperand(3); }
  3122. void set_inputColIndex(llvm::Value *val) { Instr->setOperand(3, val); }
  3123. llvm::Value *get_offsetX() const { return Instr->getOperand(4); }
  3124. void set_offsetX(llvm::Value *val) { Instr->setOperand(4, val); }
  3125. llvm::Value *get_offsetY() const { return Instr->getOperand(5); }
  3126. void set_offsetY(llvm::Value *val) { Instr->setOperand(5, val); }
  3127. };
  3128. /// This instruction evaluates an input attribute at a sample location
  3129. struct DxilInst_EvalSampleIndex {
  3130. llvm::Instruction *Instr;
  3131. // Construction and identification
  3132. DxilInst_EvalSampleIndex(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3133. operator bool() const {
  3134. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalSampleIndex);
  3135. }
  3136. // Validation support
  3137. bool isAllowed() const { return true; }
  3138. bool isArgumentListValid() const {
  3139. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3140. return true;
  3141. }
  3142. // Operand indexes
  3143. enum OperandIdx {
  3144. arg_inputSigId = 1,
  3145. arg_inputRowIndex = 2,
  3146. arg_inputColIndex = 3,
  3147. arg_sampleIndex = 4,
  3148. };
  3149. // Accessors
  3150. llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }
  3151. void set_inputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  3152. llvm::Value *get_inputRowIndex() const { return Instr->getOperand(2); }
  3153. void set_inputRowIndex(llvm::Value *val) { Instr->setOperand(2, val); }
  3154. llvm::Value *get_inputColIndex() const { return Instr->getOperand(3); }
  3155. void set_inputColIndex(llvm::Value *val) { Instr->setOperand(3, val); }
  3156. llvm::Value *get_sampleIndex() const { return Instr->getOperand(4); }
  3157. void set_sampleIndex(llvm::Value *val) { Instr->setOperand(4, val); }
  3158. };
  3159. /// This instruction evaluates an input attribute at pixel center
  3160. struct DxilInst_EvalCentroid {
  3161. llvm::Instruction *Instr;
  3162. // Construction and identification
  3163. DxilInst_EvalCentroid(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3164. operator bool() const {
  3165. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalCentroid);
  3166. }
  3167. // Validation support
  3168. bool isAllowed() const { return true; }
  3169. bool isArgumentListValid() const {
  3170. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3171. return true;
  3172. }
  3173. // Operand indexes
  3174. enum OperandIdx {
  3175. arg_inputSigId = 1,
  3176. arg_inputRowIndex = 2,
  3177. arg_inputColIndex = 3,
  3178. };
  3179. // Accessors
  3180. llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }
  3181. void set_inputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  3182. llvm::Value *get_inputRowIndex() const { return Instr->getOperand(2); }
  3183. void set_inputRowIndex(llvm::Value *val) { Instr->setOperand(2, val); }
  3184. llvm::Value *get_inputColIndex() const { return Instr->getOperand(3); }
  3185. void set_inputColIndex(llvm::Value *val) { Instr->setOperand(3, val); }
  3186. };
  3187. /// This instruction returns the sample index in a sample-frequency pixel shader
  3188. struct DxilInst_SampleIndex {
  3189. llvm::Instruction *Instr;
  3190. // Construction and identification
  3191. DxilInst_SampleIndex(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3192. operator bool() const {
  3193. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleIndex);
  3194. }
  3195. // Validation support
  3196. bool isAllowed() const { return true; }
  3197. bool isArgumentListValid() const {
  3198. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3199. return true;
  3200. }
  3201. };
  3202. /// This instruction returns the coverage mask input in a pixel shader
  3203. struct DxilInst_Coverage {
  3204. llvm::Instruction *Instr;
  3205. // Construction and identification
  3206. DxilInst_Coverage(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3207. operator bool() const {
  3208. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Coverage);
  3209. }
  3210. // Validation support
  3211. bool isAllowed() const { return true; }
  3212. bool isArgumentListValid() const {
  3213. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3214. return true;
  3215. }
  3216. };
  3217. /// This instruction returns underestimated coverage input from conservative rasterization in a pixel shader
  3218. struct DxilInst_InnerCoverage {
  3219. llvm::Instruction *Instr;
  3220. // Construction and identification
  3221. DxilInst_InnerCoverage(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3222. operator bool() const {
  3223. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::InnerCoverage);
  3224. }
  3225. // Validation support
  3226. bool isAllowed() const { return true; }
  3227. bool isArgumentListValid() const {
  3228. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3229. return true;
  3230. }
  3231. };
  3232. /// This instruction reads the thread ID
  3233. struct DxilInst_ThreadId {
  3234. llvm::Instruction *Instr;
  3235. // Construction and identification
  3236. DxilInst_ThreadId(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3237. operator bool() const {
  3238. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ThreadId);
  3239. }
  3240. // Validation support
  3241. bool isAllowed() const { return true; }
  3242. bool isArgumentListValid() const {
  3243. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3244. return true;
  3245. }
  3246. // Operand indexes
  3247. enum OperandIdx {
  3248. arg_component = 1,
  3249. };
  3250. // Accessors
  3251. llvm::Value *get_component() const { return Instr->getOperand(1); }
  3252. void set_component(llvm::Value *val) { Instr->setOperand(1, val); }
  3253. };
  3254. /// This instruction reads the group ID (SV_GroupID)
  3255. struct DxilInst_GroupId {
  3256. llvm::Instruction *Instr;
  3257. // Construction and identification
  3258. DxilInst_GroupId(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3259. operator bool() const {
  3260. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GroupId);
  3261. }
  3262. // Validation support
  3263. bool isAllowed() const { return true; }
  3264. bool isArgumentListValid() const {
  3265. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3266. return true;
  3267. }
  3268. // Operand indexes
  3269. enum OperandIdx {
  3270. arg_component = 1,
  3271. };
  3272. // Accessors
  3273. llvm::Value *get_component() const { return Instr->getOperand(1); }
  3274. void set_component(llvm::Value *val) { Instr->setOperand(1, val); }
  3275. };
  3276. /// This instruction reads the thread ID within the group (SV_GroupThreadID)
  3277. struct DxilInst_ThreadIdInGroup {
  3278. llvm::Instruction *Instr;
  3279. // Construction and identification
  3280. DxilInst_ThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3281. operator bool() const {
  3282. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ThreadIdInGroup);
  3283. }
  3284. // Validation support
  3285. bool isAllowed() const { return true; }
  3286. bool isArgumentListValid() const {
  3287. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3288. return true;
  3289. }
  3290. // Operand indexes
  3291. enum OperandIdx {
  3292. arg_component = 1,
  3293. };
  3294. // Accessors
  3295. llvm::Value *get_component() const { return Instr->getOperand(1); }
  3296. void set_component(llvm::Value *val) { Instr->setOperand(1, val); }
  3297. };
  3298. /// This instruction provides a flattened index for a given thread within a given group (SV_GroupIndex)
  3299. struct DxilInst_FlattenedThreadIdInGroup {
  3300. llvm::Instruction *Instr;
  3301. // Construction and identification
  3302. DxilInst_FlattenedThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3303. operator bool() const {
  3304. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FlattenedThreadIdInGroup);
  3305. }
  3306. // Validation support
  3307. bool isAllowed() const { return true; }
  3308. bool isArgumentListValid() const {
  3309. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3310. return true;
  3311. }
  3312. };
  3313. /// This instruction emits a vertex to a given stream
  3314. struct DxilInst_EmitStream {
  3315. llvm::Instruction *Instr;
  3316. // Construction and identification
  3317. DxilInst_EmitStream(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3318. operator bool() const {
  3319. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EmitStream);
  3320. }
  3321. // Validation support
  3322. bool isAllowed() const { return true; }
  3323. bool isArgumentListValid() const {
  3324. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3325. return true;
  3326. }
  3327. // Operand indexes
  3328. enum OperandIdx {
  3329. arg_streamId = 1,
  3330. };
  3331. // Accessors
  3332. llvm::Value *get_streamId() const { return Instr->getOperand(1); }
  3333. void set_streamId(llvm::Value *val) { Instr->setOperand(1, val); }
  3334. };
  3335. /// This instruction completes the current primitive topology at the specified stream
  3336. struct DxilInst_CutStream {
  3337. llvm::Instruction *Instr;
  3338. // Construction and identification
  3339. DxilInst_CutStream(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3340. operator bool() const {
  3341. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CutStream);
  3342. }
  3343. // Validation support
  3344. bool isAllowed() const { return true; }
  3345. bool isArgumentListValid() const {
  3346. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3347. return true;
  3348. }
  3349. // Operand indexes
  3350. enum OperandIdx {
  3351. arg_streamId = 1,
  3352. };
  3353. // Accessors
  3354. llvm::Value *get_streamId() const { return Instr->getOperand(1); }
  3355. void set_streamId(llvm::Value *val) { Instr->setOperand(1, val); }
  3356. };
  3357. /// This instruction equivalent to an EmitStream followed by a CutStream
  3358. struct DxilInst_EmitThenCutStream {
  3359. llvm::Instruction *Instr;
  3360. // Construction and identification
  3361. DxilInst_EmitThenCutStream(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3362. operator bool() const {
  3363. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EmitThenCutStream);
  3364. }
  3365. // Validation support
  3366. bool isAllowed() const { return true; }
  3367. bool isArgumentListValid() const {
  3368. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3369. return true;
  3370. }
  3371. // Operand indexes
  3372. enum OperandIdx {
  3373. arg_streamId = 1,
  3374. };
  3375. // Accessors
  3376. llvm::Value *get_streamId() const { return Instr->getOperand(1); }
  3377. void set_streamId(llvm::Value *val) { Instr->setOperand(1, val); }
  3378. };
  3379. /// This instruction GSInstanceID
  3380. struct DxilInst_GSInstanceID {
  3381. llvm::Instruction *Instr;
  3382. // Construction and identification
  3383. DxilInst_GSInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3384. operator bool() const {
  3385. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GSInstanceID);
  3386. }
  3387. // Validation support
  3388. bool isAllowed() const { return true; }
  3389. bool isArgumentListValid() const {
  3390. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3391. return true;
  3392. }
  3393. };
  3394. /// This instruction creates a double value
  3395. struct DxilInst_MakeDouble {
  3396. llvm::Instruction *Instr;
  3397. // Construction and identification
  3398. DxilInst_MakeDouble(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3399. operator bool() const {
  3400. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MakeDouble);
  3401. }
  3402. // Validation support
  3403. bool isAllowed() const { return true; }
  3404. bool isArgumentListValid() const {
  3405. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3406. return true;
  3407. }
  3408. // Operand indexes
  3409. enum OperandIdx {
  3410. arg_lo = 1,
  3411. arg_hi = 2,
  3412. };
  3413. // Accessors
  3414. llvm::Value *get_lo() const { return Instr->getOperand(1); }
  3415. void set_lo(llvm::Value *val) { Instr->setOperand(1, val); }
  3416. llvm::Value *get_hi() const { return Instr->getOperand(2); }
  3417. void set_hi(llvm::Value *val) { Instr->setOperand(2, val); }
  3418. };
  3419. /// This instruction splits a double into low and high parts
  3420. struct DxilInst_SplitDouble {
  3421. llvm::Instruction *Instr;
  3422. // Construction and identification
  3423. DxilInst_SplitDouble(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3424. operator bool() const {
  3425. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SplitDouble);
  3426. }
  3427. // Validation support
  3428. bool isAllowed() const { return true; }
  3429. bool isArgumentListValid() const {
  3430. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3431. return true;
  3432. }
  3433. // Operand indexes
  3434. enum OperandIdx {
  3435. arg_value = 1,
  3436. };
  3437. // Accessors
  3438. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3439. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3440. };
  3441. /// This instruction LoadOutputControlPoint
  3442. struct DxilInst_LoadOutputControlPoint {
  3443. llvm::Instruction *Instr;
  3444. // Construction and identification
  3445. DxilInst_LoadOutputControlPoint(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3446. operator bool() const {
  3447. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadOutputControlPoint);
  3448. }
  3449. // Validation support
  3450. bool isAllowed() const { return true; }
  3451. bool isArgumentListValid() const {
  3452. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3453. return true;
  3454. }
  3455. // Operand indexes
  3456. enum OperandIdx {
  3457. arg_inputSigId = 1,
  3458. arg_row = 2,
  3459. arg_col = 3,
  3460. arg_index = 4,
  3461. };
  3462. // Accessors
  3463. llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }
  3464. void set_inputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  3465. llvm::Value *get_row() const { return Instr->getOperand(2); }
  3466. void set_row(llvm::Value *val) { Instr->setOperand(2, val); }
  3467. llvm::Value *get_col() const { return Instr->getOperand(3); }
  3468. void set_col(llvm::Value *val) { Instr->setOperand(3, val); }
  3469. llvm::Value *get_index() const { return Instr->getOperand(4); }
  3470. void set_index(llvm::Value *val) { Instr->setOperand(4, val); }
  3471. };
  3472. /// This instruction LoadPatchConstant
  3473. struct DxilInst_LoadPatchConstant {
  3474. llvm::Instruction *Instr;
  3475. // Construction and identification
  3476. DxilInst_LoadPatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3477. operator bool() const {
  3478. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadPatchConstant);
  3479. }
  3480. // Validation support
  3481. bool isAllowed() const { return true; }
  3482. bool isArgumentListValid() const {
  3483. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3484. return true;
  3485. }
  3486. // Operand indexes
  3487. enum OperandIdx {
  3488. arg_inputSigId = 1,
  3489. arg_row = 2,
  3490. arg_col = 3,
  3491. };
  3492. // Accessors
  3493. llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }
  3494. void set_inputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  3495. llvm::Value *get_row() const { return Instr->getOperand(2); }
  3496. void set_row(llvm::Value *val) { Instr->setOperand(2, val); }
  3497. llvm::Value *get_col() const { return Instr->getOperand(3); }
  3498. void set_col(llvm::Value *val) { Instr->setOperand(3, val); }
  3499. };
  3500. /// This instruction DomainLocation
  3501. struct DxilInst_DomainLocation {
  3502. llvm::Instruction *Instr;
  3503. // Construction and identification
  3504. DxilInst_DomainLocation(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3505. operator bool() const {
  3506. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DomainLocation);
  3507. }
  3508. // Validation support
  3509. bool isAllowed() const { return true; }
  3510. bool isArgumentListValid() const {
  3511. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3512. return true;
  3513. }
  3514. // Operand indexes
  3515. enum OperandIdx {
  3516. arg_component = 1,
  3517. };
  3518. // Accessors
  3519. llvm::Value *get_component() const { return Instr->getOperand(1); }
  3520. void set_component(llvm::Value *val) { Instr->setOperand(1, val); }
  3521. int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))->getZExtValue()); }
  3522. void set_component_val(int8_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  3523. };
  3524. /// This instruction StorePatchConstant
  3525. struct DxilInst_StorePatchConstant {
  3526. llvm::Instruction *Instr;
  3527. // Construction and identification
  3528. DxilInst_StorePatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3529. operator bool() const {
  3530. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StorePatchConstant);
  3531. }
  3532. // Validation support
  3533. bool isAllowed() const { return true; }
  3534. bool isArgumentListValid() const {
  3535. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3536. return true;
  3537. }
  3538. // Operand indexes
  3539. enum OperandIdx {
  3540. arg_outputSigID = 1,
  3541. arg_row = 2,
  3542. arg_col = 3,
  3543. arg_value = 4,
  3544. };
  3545. // Accessors
  3546. llvm::Value *get_outputSigID() const { return Instr->getOperand(1); }
  3547. void set_outputSigID(llvm::Value *val) { Instr->setOperand(1, val); }
  3548. llvm::Value *get_row() const { return Instr->getOperand(2); }
  3549. void set_row(llvm::Value *val) { Instr->setOperand(2, val); }
  3550. llvm::Value *get_col() const { return Instr->getOperand(3); }
  3551. void set_col(llvm::Value *val) { Instr->setOperand(3, val); }
  3552. llvm::Value *get_value() const { return Instr->getOperand(4); }
  3553. void set_value(llvm::Value *val) { Instr->setOperand(4, val); }
  3554. };
  3555. /// This instruction OutputControlPointID
  3556. struct DxilInst_OutputControlPointID {
  3557. llvm::Instruction *Instr;
  3558. // Construction and identification
  3559. DxilInst_OutputControlPointID(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3560. operator bool() const {
  3561. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OutputControlPointID);
  3562. }
  3563. // Validation support
  3564. bool isAllowed() const { return true; }
  3565. bool isArgumentListValid() const {
  3566. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3567. return true;
  3568. }
  3569. };
  3570. /// This instruction PrimitiveID
  3571. struct DxilInst_PrimitiveID {
  3572. llvm::Instruction *Instr;
  3573. // Construction and identification
  3574. DxilInst_PrimitiveID(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3575. operator bool() const {
  3576. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::PrimitiveID);
  3577. }
  3578. // Validation support
  3579. bool isAllowed() const { return true; }
  3580. bool isArgumentListValid() const {
  3581. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3582. return true;
  3583. }
  3584. };
  3585. /// This instruction CycleCounterLegacy
  3586. struct DxilInst_CycleCounterLegacy {
  3587. llvm::Instruction *Instr;
  3588. // Construction and identification
  3589. DxilInst_CycleCounterLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3590. operator bool() const {
  3591. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CycleCounterLegacy);
  3592. }
  3593. // Validation support
  3594. bool isAllowed() const { return true; }
  3595. bool isArgumentListValid() const {
  3596. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3597. return true;
  3598. }
  3599. };
  3600. /// This instruction returns 1 for the first lane in the wave
  3601. struct DxilInst_WaveIsFirstLane {
  3602. llvm::Instruction *Instr;
  3603. // Construction and identification
  3604. DxilInst_WaveIsFirstLane(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3605. operator bool() const {
  3606. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveIsFirstLane);
  3607. }
  3608. // Validation support
  3609. bool isAllowed() const { return true; }
  3610. bool isArgumentListValid() const {
  3611. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3612. return true;
  3613. }
  3614. };
  3615. /// This instruction returns the index of the current lane in the wave
  3616. struct DxilInst_WaveGetLaneIndex {
  3617. llvm::Instruction *Instr;
  3618. // Construction and identification
  3619. DxilInst_WaveGetLaneIndex(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3620. operator bool() const {
  3621. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneIndex);
  3622. }
  3623. // Validation support
  3624. bool isAllowed() const { return true; }
  3625. bool isArgumentListValid() const {
  3626. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3627. return true;
  3628. }
  3629. };
  3630. /// This instruction returns the number of lanes in the wave
  3631. struct DxilInst_WaveGetLaneCount {
  3632. llvm::Instruction *Instr;
  3633. // Construction and identification
  3634. DxilInst_WaveGetLaneCount(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3635. operator bool() const {
  3636. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneCount);
  3637. }
  3638. // Validation support
  3639. bool isAllowed() const { return true; }
  3640. bool isArgumentListValid() const {
  3641. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3642. return true;
  3643. }
  3644. };
  3645. /// This instruction returns 1 if any of the lane evaluates the value to true
  3646. struct DxilInst_WaveAnyTrue {
  3647. llvm::Instruction *Instr;
  3648. // Construction and identification
  3649. DxilInst_WaveAnyTrue(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3650. operator bool() const {
  3651. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAnyTrue);
  3652. }
  3653. // Validation support
  3654. bool isAllowed() const { return true; }
  3655. bool isArgumentListValid() const {
  3656. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3657. return true;
  3658. }
  3659. // Operand indexes
  3660. enum OperandIdx {
  3661. arg_cond = 1,
  3662. };
  3663. // Accessors
  3664. llvm::Value *get_cond() const { return Instr->getOperand(1); }
  3665. void set_cond(llvm::Value *val) { Instr->setOperand(1, val); }
  3666. };
  3667. /// This instruction returns 1 if all the lanes evaluate the value to true
  3668. struct DxilInst_WaveAllTrue {
  3669. llvm::Instruction *Instr;
  3670. // Construction and identification
  3671. DxilInst_WaveAllTrue(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3672. operator bool() const {
  3673. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAllTrue);
  3674. }
  3675. // Validation support
  3676. bool isAllowed() const { return true; }
  3677. bool isArgumentListValid() const {
  3678. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3679. return true;
  3680. }
  3681. // Operand indexes
  3682. enum OperandIdx {
  3683. arg_cond = 1,
  3684. };
  3685. // Accessors
  3686. llvm::Value *get_cond() const { return Instr->getOperand(1); }
  3687. void set_cond(llvm::Value *val) { Instr->setOperand(1, val); }
  3688. };
  3689. /// This instruction returns 1 if all the lanes have the same value
  3690. struct DxilInst_WaveActiveAllEqual {
  3691. llvm::Instruction *Instr;
  3692. // Construction and identification
  3693. DxilInst_WaveActiveAllEqual(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3694. operator bool() const {
  3695. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveAllEqual);
  3696. }
  3697. // Validation support
  3698. bool isAllowed() const { return true; }
  3699. bool isArgumentListValid() const {
  3700. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3701. return true;
  3702. }
  3703. // Operand indexes
  3704. enum OperandIdx {
  3705. arg_value = 1,
  3706. };
  3707. // Accessors
  3708. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3709. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3710. };
  3711. /// This instruction returns a struct with a bit set for each lane where the condition is true
  3712. struct DxilInst_WaveActiveBallot {
  3713. llvm::Instruction *Instr;
  3714. // Construction and identification
  3715. DxilInst_WaveActiveBallot(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3716. operator bool() const {
  3717. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBallot);
  3718. }
  3719. // Validation support
  3720. bool isAllowed() const { return true; }
  3721. bool isArgumentListValid() const {
  3722. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3723. return true;
  3724. }
  3725. // Operand indexes
  3726. enum OperandIdx {
  3727. arg_cond = 1,
  3728. };
  3729. // Accessors
  3730. llvm::Value *get_cond() const { return Instr->getOperand(1); }
  3731. void set_cond(llvm::Value *val) { Instr->setOperand(1, val); }
  3732. };
  3733. /// This instruction returns the value from the specified lane
  3734. struct DxilInst_WaveReadLaneAt {
  3735. llvm::Instruction *Instr;
  3736. // Construction and identification
  3737. DxilInst_WaveReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3738. operator bool() const {
  3739. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneAt);
  3740. }
  3741. // Validation support
  3742. bool isAllowed() const { return true; }
  3743. bool isArgumentListValid() const {
  3744. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3745. return true;
  3746. }
  3747. // Operand indexes
  3748. enum OperandIdx {
  3749. arg_value = 1,
  3750. arg_lane = 2,
  3751. };
  3752. // Accessors
  3753. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3754. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3755. llvm::Value *get_lane() const { return Instr->getOperand(2); }
  3756. void set_lane(llvm::Value *val) { Instr->setOperand(2, val); }
  3757. };
  3758. /// This instruction returns the value from the first lane
  3759. struct DxilInst_WaveReadLaneFirst {
  3760. llvm::Instruction *Instr;
  3761. // Construction and identification
  3762. DxilInst_WaveReadLaneFirst(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3763. operator bool() const {
  3764. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneFirst);
  3765. }
  3766. // Validation support
  3767. bool isAllowed() const { return true; }
  3768. bool isArgumentListValid() const {
  3769. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3770. return true;
  3771. }
  3772. // Operand indexes
  3773. enum OperandIdx {
  3774. arg_value = 1,
  3775. };
  3776. // Accessors
  3777. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3778. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3779. };
  3780. /// This instruction returns the result the operation across waves
  3781. struct DxilInst_WaveActiveOp {
  3782. llvm::Instruction *Instr;
  3783. // Construction and identification
  3784. DxilInst_WaveActiveOp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3785. operator bool() const {
  3786. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveOp);
  3787. }
  3788. // Validation support
  3789. bool isAllowed() const { return true; }
  3790. bool isArgumentListValid() const {
  3791. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3792. return true;
  3793. }
  3794. // Operand indexes
  3795. enum OperandIdx {
  3796. arg_value = 1,
  3797. arg_op = 2,
  3798. arg_sop = 3,
  3799. };
  3800. // Accessors
  3801. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3802. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3803. llvm::Value *get_op() const { return Instr->getOperand(2); }
  3804. void set_op(llvm::Value *val) { Instr->setOperand(2, val); }
  3805. int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }
  3806. void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  3807. llvm::Value *get_sop() const { return Instr->getOperand(3); }
  3808. void set_sop(llvm::Value *val) { Instr->setOperand(3, val); }
  3809. int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(3))->getZExtValue()); }
  3810. void set_sop_val(int8_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  3811. };
  3812. /// This instruction returns the result of the operation across all lanes
  3813. struct DxilInst_WaveActiveBit {
  3814. llvm::Instruction *Instr;
  3815. // Construction and identification
  3816. DxilInst_WaveActiveBit(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3817. operator bool() const {
  3818. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBit);
  3819. }
  3820. // Validation support
  3821. bool isAllowed() const { return true; }
  3822. bool isArgumentListValid() const {
  3823. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3824. return true;
  3825. }
  3826. // Operand indexes
  3827. enum OperandIdx {
  3828. arg_value = 1,
  3829. arg_op = 2,
  3830. };
  3831. // Accessors
  3832. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3833. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3834. llvm::Value *get_op() const { return Instr->getOperand(2); }
  3835. void set_op(llvm::Value *val) { Instr->setOperand(2, val); }
  3836. int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }
  3837. void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  3838. };
  3839. /// This instruction returns the result of the operation on prior lanes
  3840. struct DxilInst_WavePrefixOp {
  3841. llvm::Instruction *Instr;
  3842. // Construction and identification
  3843. DxilInst_WavePrefixOp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3844. operator bool() const {
  3845. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixOp);
  3846. }
  3847. // Validation support
  3848. bool isAllowed() const { return true; }
  3849. bool isArgumentListValid() const {
  3850. if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3851. return true;
  3852. }
  3853. // Operand indexes
  3854. enum OperandIdx {
  3855. arg_value = 1,
  3856. arg_op = 2,
  3857. arg_sop = 3,
  3858. };
  3859. // Accessors
  3860. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3861. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3862. llvm::Value *get_op() const { return Instr->getOperand(2); }
  3863. void set_op(llvm::Value *val) { Instr->setOperand(2, val); }
  3864. int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }
  3865. void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  3866. llvm::Value *get_sop() const { return Instr->getOperand(3); }
  3867. void set_sop(llvm::Value *val) { Instr->setOperand(3, val); }
  3868. int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(3))->getZExtValue()); }
  3869. void set_sop_val(int8_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  3870. };
  3871. /// This instruction reads from a lane in the quad
  3872. struct DxilInst_QuadReadLaneAt {
  3873. llvm::Instruction *Instr;
  3874. // Construction and identification
  3875. DxilInst_QuadReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3876. operator bool() const {
  3877. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::QuadReadLaneAt);
  3878. }
  3879. // Validation support
  3880. bool isAllowed() const { return true; }
  3881. bool isArgumentListValid() const {
  3882. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3883. return true;
  3884. }
  3885. // Operand indexes
  3886. enum OperandIdx {
  3887. arg_value = 1,
  3888. arg_quadLane = 2,
  3889. };
  3890. // Accessors
  3891. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3892. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3893. llvm::Value *get_quadLane() const { return Instr->getOperand(2); }
  3894. void set_quadLane(llvm::Value *val) { Instr->setOperand(2, val); }
  3895. uint32_t get_quadLane_val() const { return (uint32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }
  3896. void set_quadLane_val(uint32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); }
  3897. };
  3898. /// This instruction returns the result of a quad-level operation
  3899. struct DxilInst_QuadOp {
  3900. llvm::Instruction *Instr;
  3901. // Construction and identification
  3902. DxilInst_QuadOp(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3903. operator bool() const {
  3904. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::QuadOp);
  3905. }
  3906. // Validation support
  3907. bool isAllowed() const { return true; }
  3908. bool isArgumentListValid() const {
  3909. if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3910. return true;
  3911. }
  3912. // Operand indexes
  3913. enum OperandIdx {
  3914. arg_value = 1,
  3915. arg_op = 2,
  3916. };
  3917. // Accessors
  3918. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3919. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3920. llvm::Value *get_op() const { return Instr->getOperand(2); }
  3921. void set_op(llvm::Value *val) { Instr->setOperand(2, val); }
  3922. int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }
  3923. void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  3924. };
  3925. /// This instruction bitcast between different sizes
  3926. struct DxilInst_BitcastI16toF16 {
  3927. llvm::Instruction *Instr;
  3928. // Construction and identification
  3929. DxilInst_BitcastI16toF16(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3930. operator bool() const {
  3931. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI16toF16);
  3932. }
  3933. // Validation support
  3934. bool isAllowed() const { return true; }
  3935. bool isArgumentListValid() const {
  3936. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3937. return true;
  3938. }
  3939. // Operand indexes
  3940. enum OperandIdx {
  3941. arg_value = 1,
  3942. };
  3943. // Accessors
  3944. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3945. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3946. };
  3947. /// This instruction bitcast between different sizes
  3948. struct DxilInst_BitcastF16toI16 {
  3949. llvm::Instruction *Instr;
  3950. // Construction and identification
  3951. DxilInst_BitcastF16toI16(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3952. operator bool() const {
  3953. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF16toI16);
  3954. }
  3955. // Validation support
  3956. bool isAllowed() const { return true; }
  3957. bool isArgumentListValid() const {
  3958. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3959. return true;
  3960. }
  3961. // Operand indexes
  3962. enum OperandIdx {
  3963. arg_value = 1,
  3964. };
  3965. // Accessors
  3966. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3967. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3968. };
  3969. /// This instruction bitcast between different sizes
  3970. struct DxilInst_BitcastI32toF32 {
  3971. llvm::Instruction *Instr;
  3972. // Construction and identification
  3973. DxilInst_BitcastI32toF32(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3974. operator bool() const {
  3975. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI32toF32);
  3976. }
  3977. // Validation support
  3978. bool isAllowed() const { return true; }
  3979. bool isArgumentListValid() const {
  3980. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  3981. return true;
  3982. }
  3983. // Operand indexes
  3984. enum OperandIdx {
  3985. arg_value = 1,
  3986. };
  3987. // Accessors
  3988. llvm::Value *get_value() const { return Instr->getOperand(1); }
  3989. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  3990. };
  3991. /// This instruction bitcast between different sizes
  3992. struct DxilInst_BitcastF32toI32 {
  3993. llvm::Instruction *Instr;
  3994. // Construction and identification
  3995. DxilInst_BitcastF32toI32(llvm::Instruction *pInstr) : Instr(pInstr) {}
  3996. operator bool() const {
  3997. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF32toI32);
  3998. }
  3999. // Validation support
  4000. bool isAllowed() const { return true; }
  4001. bool isArgumentListValid() const {
  4002. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4003. return true;
  4004. }
  4005. // Operand indexes
  4006. enum OperandIdx {
  4007. arg_value = 1,
  4008. };
  4009. // Accessors
  4010. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4011. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4012. };
  4013. /// This instruction bitcast between different sizes
  4014. struct DxilInst_BitcastI64toF64 {
  4015. llvm::Instruction *Instr;
  4016. // Construction and identification
  4017. DxilInst_BitcastI64toF64(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4018. operator bool() const {
  4019. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI64toF64);
  4020. }
  4021. // Validation support
  4022. bool isAllowed() const { return true; }
  4023. bool isArgumentListValid() const {
  4024. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4025. return true;
  4026. }
  4027. // Operand indexes
  4028. enum OperandIdx {
  4029. arg_value = 1,
  4030. };
  4031. // Accessors
  4032. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4033. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4034. };
  4035. /// This instruction bitcast between different sizes
  4036. struct DxilInst_BitcastF64toI64 {
  4037. llvm::Instruction *Instr;
  4038. // Construction and identification
  4039. DxilInst_BitcastF64toI64(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4040. operator bool() const {
  4041. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF64toI64);
  4042. }
  4043. // Validation support
  4044. bool isAllowed() const { return true; }
  4045. bool isArgumentListValid() const {
  4046. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4047. return true;
  4048. }
  4049. // Operand indexes
  4050. enum OperandIdx {
  4051. arg_value = 1,
  4052. };
  4053. // Accessors
  4054. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4055. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4056. };
  4057. /// This instruction legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision)
  4058. struct DxilInst_LegacyF32ToF16 {
  4059. llvm::Instruction *Instr;
  4060. // Construction and identification
  4061. DxilInst_LegacyF32ToF16(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4062. operator bool() const {
  4063. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF32ToF16);
  4064. }
  4065. // Validation support
  4066. bool isAllowed() const { return true; }
  4067. bool isArgumentListValid() const {
  4068. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4069. return true;
  4070. }
  4071. // Operand indexes
  4072. enum OperandIdx {
  4073. arg_value = 1,
  4074. };
  4075. // Accessors
  4076. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4077. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4078. };
  4079. /// This instruction legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision)
  4080. struct DxilInst_LegacyF16ToF32 {
  4081. llvm::Instruction *Instr;
  4082. // Construction and identification
  4083. DxilInst_LegacyF16ToF32(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4084. operator bool() const {
  4085. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF16ToF32);
  4086. }
  4087. // Validation support
  4088. bool isAllowed() const { return true; }
  4089. bool isArgumentListValid() const {
  4090. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4091. return true;
  4092. }
  4093. // Operand indexes
  4094. enum OperandIdx {
  4095. arg_value = 1,
  4096. };
  4097. // Accessors
  4098. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4099. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4100. };
  4101. /// This instruction legacy fuction to convert double to float
  4102. struct DxilInst_LegacyDoubleToFloat {
  4103. llvm::Instruction *Instr;
  4104. // Construction and identification
  4105. DxilInst_LegacyDoubleToFloat(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4106. operator bool() const {
  4107. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToFloat);
  4108. }
  4109. // Validation support
  4110. bool isAllowed() const { return true; }
  4111. bool isArgumentListValid() const {
  4112. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4113. return true;
  4114. }
  4115. // Operand indexes
  4116. enum OperandIdx {
  4117. arg_value = 1,
  4118. };
  4119. // Accessors
  4120. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4121. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4122. };
  4123. /// This instruction legacy fuction to convert double to int32
  4124. struct DxilInst_LegacyDoubleToSInt32 {
  4125. llvm::Instruction *Instr;
  4126. // Construction and identification
  4127. DxilInst_LegacyDoubleToSInt32(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4128. operator bool() const {
  4129. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToSInt32);
  4130. }
  4131. // Validation support
  4132. bool isAllowed() const { return true; }
  4133. bool isArgumentListValid() const {
  4134. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4135. return true;
  4136. }
  4137. // Operand indexes
  4138. enum OperandIdx {
  4139. arg_value = 1,
  4140. };
  4141. // Accessors
  4142. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4143. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4144. };
  4145. /// This instruction legacy fuction to convert double to uint32
  4146. struct DxilInst_LegacyDoubleToUInt32 {
  4147. llvm::Instruction *Instr;
  4148. // Construction and identification
  4149. DxilInst_LegacyDoubleToUInt32(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4150. operator bool() const {
  4151. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToUInt32);
  4152. }
  4153. // Validation support
  4154. bool isAllowed() const { return true; }
  4155. bool isArgumentListValid() const {
  4156. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4157. return true;
  4158. }
  4159. // Operand indexes
  4160. enum OperandIdx {
  4161. arg_value = 1,
  4162. };
  4163. // Accessors
  4164. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4165. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4166. };
  4167. /// This instruction returns the count of bits set to 1 across the wave
  4168. struct DxilInst_WaveAllBitCount {
  4169. llvm::Instruction *Instr;
  4170. // Construction and identification
  4171. DxilInst_WaveAllBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4172. operator bool() const {
  4173. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAllBitCount);
  4174. }
  4175. // Validation support
  4176. bool isAllowed() const { return true; }
  4177. bool isArgumentListValid() const {
  4178. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4179. return true;
  4180. }
  4181. // Operand indexes
  4182. enum OperandIdx {
  4183. arg_value = 1,
  4184. };
  4185. // Accessors
  4186. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4187. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4188. };
  4189. /// This instruction returns the count of bits set to 1 on prior lanes
  4190. struct DxilInst_WavePrefixBitCount {
  4191. llvm::Instruction *Instr;
  4192. // Construction and identification
  4193. DxilInst_WavePrefixBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4194. operator bool() const {
  4195. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixBitCount);
  4196. }
  4197. // Validation support
  4198. bool isAllowed() const { return true; }
  4199. bool isArgumentListValid() const {
  4200. if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4201. return true;
  4202. }
  4203. // Operand indexes
  4204. enum OperandIdx {
  4205. arg_value = 1,
  4206. };
  4207. // Accessors
  4208. llvm::Value *get_value() const { return Instr->getOperand(1); }
  4209. void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
  4210. };
  4211. /// This instruction returns the values of the attributes at the vertex.
  4212. struct DxilInst_AttributeAtVertex {
  4213. llvm::Instruction *Instr;
  4214. // Construction and identification
  4215. DxilInst_AttributeAtVertex(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4216. operator bool() const {
  4217. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AttributeAtVertex);
  4218. }
  4219. // Validation support
  4220. bool isAllowed() const { return true; }
  4221. bool isArgumentListValid() const {
  4222. if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4223. return true;
  4224. }
  4225. // Operand indexes
  4226. enum OperandIdx {
  4227. arg_inputSigId = 1,
  4228. arg_inputRowIndex = 2,
  4229. arg_inputColIndex = 3,
  4230. arg_VertexID = 4,
  4231. };
  4232. // Accessors
  4233. llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }
  4234. void set_inputSigId(llvm::Value *val) { Instr->setOperand(1, val); }
  4235. llvm::Value *get_inputRowIndex() const { return Instr->getOperand(2); }
  4236. void set_inputRowIndex(llvm::Value *val) { Instr->setOperand(2, val); }
  4237. llvm::Value *get_inputColIndex() const { return Instr->getOperand(3); }
  4238. void set_inputColIndex(llvm::Value *val) { Instr->setOperand(3, val); }
  4239. llvm::Value *get_VertexID() const { return Instr->getOperand(4); }
  4240. void set_VertexID(llvm::Value *val) { Instr->setOperand(4, val); }
  4241. };
  4242. /// This instruction returns the view index
  4243. struct DxilInst_ViewID {
  4244. llvm::Instruction *Instr;
  4245. // Construction and identification
  4246. DxilInst_ViewID(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4247. operator bool() const {
  4248. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ViewID);
  4249. }
  4250. // Validation support
  4251. bool isAllowed() const { return true; }
  4252. bool isArgumentListValid() const {
  4253. if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4254. return true;
  4255. }
  4256. };
  4257. /// This instruction reads from a raw buffer and structured buffer
  4258. struct DxilInst_RawBufferLoad {
  4259. llvm::Instruction *Instr;
  4260. // Construction and identification
  4261. DxilInst_RawBufferLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4262. operator bool() const {
  4263. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferLoad);
  4264. }
  4265. // Validation support
  4266. bool isAllowed() const { return true; }
  4267. bool isArgumentListValid() const {
  4268. if (6 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4269. return true;
  4270. }
  4271. // Operand indexes
  4272. enum OperandIdx {
  4273. arg_srv = 1,
  4274. arg_index = 2,
  4275. arg_elementOffset = 3,
  4276. arg_mask = 4,
  4277. arg_alignment = 5,
  4278. };
  4279. // Accessors
  4280. llvm::Value *get_srv() const { return Instr->getOperand(1); }
  4281. void set_srv(llvm::Value *val) { Instr->setOperand(1, val); }
  4282. llvm::Value *get_index() const { return Instr->getOperand(2); }
  4283. void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
  4284. llvm::Value *get_elementOffset() const { return Instr->getOperand(3); }
  4285. void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); }
  4286. llvm::Value *get_mask() const { return Instr->getOperand(4); }
  4287. void set_mask(llvm::Value *val) { Instr->setOperand(4, val); }
  4288. int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(4))->getZExtValue()); }
  4289. void set_mask_val(int8_t val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  4290. llvm::Value *get_alignment() const { return Instr->getOperand(5); }
  4291. void set_alignment(llvm::Value *val) { Instr->setOperand(5, val); }
  4292. int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(5))->getZExtValue()); }
  4293. void set_alignment_val(int32_t val) { Instr->setOperand(5, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); }
  4294. };
  4295. /// This instruction writes to a RWByteAddressBuffer or RWStructuredBuffer
  4296. struct DxilInst_RawBufferStore {
  4297. llvm::Instruction *Instr;
  4298. // Construction and identification
  4299. DxilInst_RawBufferStore(llvm::Instruction *pInstr) : Instr(pInstr) {}
  4300. operator bool() const {
  4301. return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferStore);
  4302. }
  4303. // Validation support
  4304. bool isAllowed() const { return true; }
  4305. bool isArgumentListValid() const {
  4306. if (10 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
  4307. return true;
  4308. }
  4309. // Operand indexes
  4310. enum OperandIdx {
  4311. arg_uav = 1,
  4312. arg_index = 2,
  4313. arg_elementOffset = 3,
  4314. arg_value0 = 4,
  4315. arg_value1 = 5,
  4316. arg_value2 = 6,
  4317. arg_value3 = 7,
  4318. arg_mask = 8,
  4319. arg_alignment = 9,
  4320. };
  4321. // Accessors
  4322. llvm::Value *get_uav() const { return Instr->getOperand(1); }
  4323. void set_uav(llvm::Value *val) { Instr->setOperand(1, val); }
  4324. llvm::Value *get_index() const { return Instr->getOperand(2); }
  4325. void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
  4326. llvm::Value *get_elementOffset() const { return Instr->getOperand(3); }
  4327. void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); }
  4328. llvm::Value *get_value0() const { return Instr->getOperand(4); }
  4329. void set_value0(llvm::Value *val) { Instr->setOperand(4, val); }
  4330. llvm::Value *get_value1() const { return Instr->getOperand(5); }
  4331. void set_value1(llvm::Value *val) { Instr->setOperand(5, val); }
  4332. llvm::Value *get_value2() const { return Instr->getOperand(6); }
  4333. void set_value2(llvm::Value *val) { Instr->setOperand(6, val); }
  4334. llvm::Value *get_value3() const { return Instr->getOperand(7); }
  4335. void set_value3(llvm::Value *val) { Instr->setOperand(7, val); }
  4336. llvm::Value *get_mask() const { return Instr->getOperand(8); }
  4337. void set_mask(llvm::Value *val) { Instr->setOperand(8, val); }
  4338. int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(8))->getZExtValue()); }
  4339. void set_mask_val(int8_t val) { Instr->setOperand(8, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
  4340. llvm::Value *get_alignment() const { return Instr->getOperand(9); }
  4341. void set_alignment(llvm::Value *val) { Instr->setOperand(9, val); }
  4342. int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(9))->getZExtValue()); }
  4343. void set_alignment_val(int32_t val) { Instr->setOperand(9, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); }
  4344. };
  4345. // INSTR-HELPER:END
  4346. } // namespace hlsl