NVPTXReplaceImageHandles.cpp 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845
  1. //===-- NVPTXReplaceImageHandles.cpp - Replace image handles for Fermi ----===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // On Fermi, image handles are not supported. To work around this, we traverse
  10. // the machine code and replace image handles with concrete symbols. For this
  11. // to work reliably, inlining of all function call must be performed.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #include "NVPTX.h"
  15. #include "NVPTXMachineFunctionInfo.h"
  16. #include "NVPTXSubtarget.h"
  17. #include "NVPTXTargetMachine.h"
  18. #include "MCTargetDesc/NVPTXBaseInfo.h"
  19. #include "llvm/ADT/DenseSet.h"
  20. #include "llvm/CodeGen/MachineFunction.h"
  21. #include "llvm/CodeGen/MachineFunctionPass.h"
  22. #include "llvm/CodeGen/MachineRegisterInfo.h"
  23. #include "llvm/Support/raw_ostream.h"
  24. using namespace llvm;
  25. namespace {
  26. class NVPTXReplaceImageHandles : public MachineFunctionPass {
  27. private:
  28. static char ID;
  29. DenseSet<MachineInstr *> InstrsToRemove;
  30. public:
  31. NVPTXReplaceImageHandles();
  32. bool runOnMachineFunction(MachineFunction &MF) override;
  33. StringRef getPassName() const override {
  34. return "NVPTX Replace Image Handles";
  35. }
  36. private:
  37. bool processInstr(MachineInstr &MI);
  38. bool replaceImageHandle(MachineOperand &Op, MachineFunction &MF);
  39. bool findIndexForHandle(MachineOperand &Op, MachineFunction &MF,
  40. unsigned &Idx);
  41. };
  42. }
  43. char NVPTXReplaceImageHandles::ID = 0;
  44. NVPTXReplaceImageHandles::NVPTXReplaceImageHandles()
  45. : MachineFunctionPass(ID) {}
  46. bool NVPTXReplaceImageHandles::runOnMachineFunction(MachineFunction &MF) {
  47. bool Changed = false;
  48. InstrsToRemove.clear();
  49. for (MachineBasicBlock &MBB : MF)
  50. for (MachineInstr &MI : MBB)
  51. Changed |= processInstr(MI);
  52. // Now clean up any handle-access instructions
  53. // This is needed in debug mode when code cleanup passes are not executed,
  54. // but we need the handle access to be eliminated because they are not
  55. // valid instructions when image handles are disabled.
  56. for (MachineInstr *MI : InstrsToRemove)
  57. MI->eraseFromParent();
  58. return Changed;
  59. }
  60. static unsigned suldRegisterToIndexOpcode(unsigned RegOC) {
  61. switch (RegOC) {
  62. case NVPTX::SULD_1D_I8_CLAMP_R:
  63. return NVPTX::SULD_1D_I8_CLAMP_I;
  64. case NVPTX::SULD_1D_I16_CLAMP_R:
  65. return NVPTX::SULD_1D_I16_CLAMP_I;
  66. case NVPTX::SULD_1D_I32_CLAMP_R:
  67. return NVPTX::SULD_1D_I32_CLAMP_I;
  68. case NVPTX::SULD_1D_I64_CLAMP_R:
  69. return NVPTX::SULD_1D_I64_CLAMP_I;
  70. case NVPTX::SULD_1D_ARRAY_I8_CLAMP_R:
  71. return NVPTX::SULD_1D_ARRAY_I8_CLAMP_I;
  72. case NVPTX::SULD_1D_ARRAY_I16_CLAMP_R:
  73. return NVPTX::SULD_1D_ARRAY_I16_CLAMP_I;
  74. case NVPTX::SULD_1D_ARRAY_I32_CLAMP_R:
  75. return NVPTX::SULD_1D_ARRAY_I32_CLAMP_I;
  76. case NVPTX::SULD_1D_ARRAY_I64_CLAMP_R:
  77. return NVPTX::SULD_1D_ARRAY_I64_CLAMP_I;
  78. case NVPTX::SULD_2D_I8_CLAMP_R:
  79. return NVPTX::SULD_2D_I8_CLAMP_I;
  80. case NVPTX::SULD_2D_I16_CLAMP_R:
  81. return NVPTX::SULD_2D_I16_CLAMP_I;
  82. case NVPTX::SULD_2D_I32_CLAMP_R:
  83. return NVPTX::SULD_2D_I32_CLAMP_I;
  84. case NVPTX::SULD_2D_I64_CLAMP_R:
  85. return NVPTX::SULD_2D_I64_CLAMP_I;
  86. case NVPTX::SULD_2D_ARRAY_I8_CLAMP_R:
  87. return NVPTX::SULD_2D_ARRAY_I8_CLAMP_I;
  88. case NVPTX::SULD_2D_ARRAY_I16_CLAMP_R:
  89. return NVPTX::SULD_2D_ARRAY_I16_CLAMP_I;
  90. case NVPTX::SULD_2D_ARRAY_I32_CLAMP_R:
  91. return NVPTX::SULD_2D_ARRAY_I32_CLAMP_I;
  92. case NVPTX::SULD_2D_ARRAY_I64_CLAMP_R:
  93. return NVPTX::SULD_2D_ARRAY_I64_CLAMP_I;
  94. case NVPTX::SULD_3D_I8_CLAMP_R:
  95. return NVPTX::SULD_3D_I8_CLAMP_I;
  96. case NVPTX::SULD_3D_I16_CLAMP_R:
  97. return NVPTX::SULD_3D_I16_CLAMP_I;
  98. case NVPTX::SULD_3D_I32_CLAMP_R:
  99. return NVPTX::SULD_3D_I32_CLAMP_I;
  100. case NVPTX::SULD_3D_I64_CLAMP_R:
  101. return NVPTX::SULD_3D_I64_CLAMP_I;
  102. case NVPTX::SULD_1D_V2I8_CLAMP_R:
  103. return NVPTX::SULD_1D_V2I8_CLAMP_I;
  104. case NVPTX::SULD_1D_V2I16_CLAMP_R:
  105. return NVPTX::SULD_1D_V2I16_CLAMP_I;
  106. case NVPTX::SULD_1D_V2I32_CLAMP_R:
  107. return NVPTX::SULD_1D_V2I32_CLAMP_I;
  108. case NVPTX::SULD_1D_V2I64_CLAMP_R:
  109. return NVPTX::SULD_1D_V2I64_CLAMP_I;
  110. case NVPTX::SULD_1D_ARRAY_V2I8_CLAMP_R:
  111. return NVPTX::SULD_1D_ARRAY_V2I8_CLAMP_I;
  112. case NVPTX::SULD_1D_ARRAY_V2I16_CLAMP_R:
  113. return NVPTX::SULD_1D_ARRAY_V2I16_CLAMP_I;
  114. case NVPTX::SULD_1D_ARRAY_V2I32_CLAMP_R:
  115. return NVPTX::SULD_1D_ARRAY_V2I32_CLAMP_I;
  116. case NVPTX::SULD_1D_ARRAY_V2I64_CLAMP_R:
  117. return NVPTX::SULD_1D_ARRAY_V2I64_CLAMP_I;
  118. case NVPTX::SULD_2D_V2I8_CLAMP_R:
  119. return NVPTX::SULD_2D_V2I8_CLAMP_I;
  120. case NVPTX::SULD_2D_V2I16_CLAMP_R:
  121. return NVPTX::SULD_2D_V2I16_CLAMP_I;
  122. case NVPTX::SULD_2D_V2I32_CLAMP_R:
  123. return NVPTX::SULD_2D_V2I32_CLAMP_I;
  124. case NVPTX::SULD_2D_V2I64_CLAMP_R:
  125. return NVPTX::SULD_2D_V2I64_CLAMP_I;
  126. case NVPTX::SULD_2D_ARRAY_V2I8_CLAMP_R:
  127. return NVPTX::SULD_2D_ARRAY_V2I8_CLAMP_I;
  128. case NVPTX::SULD_2D_ARRAY_V2I16_CLAMP_R:
  129. return NVPTX::SULD_2D_ARRAY_V2I16_CLAMP_I;
  130. case NVPTX::SULD_2D_ARRAY_V2I32_CLAMP_R:
  131. return NVPTX::SULD_2D_ARRAY_V2I32_CLAMP_I;
  132. case NVPTX::SULD_2D_ARRAY_V2I64_CLAMP_R:
  133. return NVPTX::SULD_2D_ARRAY_V2I64_CLAMP_I;
  134. case NVPTX::SULD_3D_V2I8_CLAMP_R:
  135. return NVPTX::SULD_3D_V2I8_CLAMP_I;
  136. case NVPTX::SULD_3D_V2I16_CLAMP_R:
  137. return NVPTX::SULD_3D_V2I16_CLAMP_I;
  138. case NVPTX::SULD_3D_V2I32_CLAMP_R:
  139. return NVPTX::SULD_3D_V2I32_CLAMP_I;
  140. case NVPTX::SULD_3D_V2I64_CLAMP_R:
  141. return NVPTX::SULD_3D_V2I64_CLAMP_I;
  142. case NVPTX::SULD_1D_V4I8_CLAMP_R:
  143. return NVPTX::SULD_1D_V4I8_CLAMP_I;
  144. case NVPTX::SULD_1D_V4I16_CLAMP_R:
  145. return NVPTX::SULD_1D_V4I16_CLAMP_I;
  146. case NVPTX::SULD_1D_V4I32_CLAMP_R:
  147. return NVPTX::SULD_1D_V4I32_CLAMP_I;
  148. case NVPTX::SULD_1D_ARRAY_V4I8_CLAMP_R:
  149. return NVPTX::SULD_1D_ARRAY_V4I8_CLAMP_I;
  150. case NVPTX::SULD_1D_ARRAY_V4I16_CLAMP_R:
  151. return NVPTX::SULD_1D_ARRAY_V4I16_CLAMP_I;
  152. case NVPTX::SULD_1D_ARRAY_V4I32_CLAMP_R:
  153. return NVPTX::SULD_1D_ARRAY_V4I32_CLAMP_I;
  154. case NVPTX::SULD_2D_V4I8_CLAMP_R:
  155. return NVPTX::SULD_2D_V4I8_CLAMP_I;
  156. case NVPTX::SULD_2D_V4I16_CLAMP_R:
  157. return NVPTX::SULD_2D_V4I16_CLAMP_I;
  158. case NVPTX::SULD_2D_V4I32_CLAMP_R:
  159. return NVPTX::SULD_2D_V4I32_CLAMP_I;
  160. case NVPTX::SULD_2D_ARRAY_V4I8_CLAMP_R:
  161. return NVPTX::SULD_2D_ARRAY_V4I8_CLAMP_I;
  162. case NVPTX::SULD_2D_ARRAY_V4I16_CLAMP_R:
  163. return NVPTX::SULD_2D_ARRAY_V4I16_CLAMP_I;
  164. case NVPTX::SULD_2D_ARRAY_V4I32_CLAMP_R:
  165. return NVPTX::SULD_2D_ARRAY_V4I32_CLAMP_I;
  166. case NVPTX::SULD_3D_V4I8_CLAMP_R:
  167. return NVPTX::SULD_3D_V4I8_CLAMP_I;
  168. case NVPTX::SULD_3D_V4I16_CLAMP_R:
  169. return NVPTX::SULD_3D_V4I16_CLAMP_I;
  170. case NVPTX::SULD_3D_V4I32_CLAMP_R:
  171. return NVPTX::SULD_3D_V4I32_CLAMP_I;
  172. case NVPTX::SULD_1D_I8_TRAP_R:
  173. return NVPTX::SULD_1D_I8_TRAP_I;
  174. case NVPTX::SULD_1D_I16_TRAP_R:
  175. return NVPTX::SULD_1D_I16_TRAP_I;
  176. case NVPTX::SULD_1D_I32_TRAP_R:
  177. return NVPTX::SULD_1D_I32_TRAP_I;
  178. case NVPTX::SULD_1D_I64_TRAP_R:
  179. return NVPTX::SULD_1D_I64_TRAP_I;
  180. case NVPTX::SULD_1D_ARRAY_I8_TRAP_R:
  181. return NVPTX::SULD_1D_ARRAY_I8_TRAP_I;
  182. case NVPTX::SULD_1D_ARRAY_I16_TRAP_R:
  183. return NVPTX::SULD_1D_ARRAY_I16_TRAP_I;
  184. case NVPTX::SULD_1D_ARRAY_I32_TRAP_R:
  185. return NVPTX::SULD_1D_ARRAY_I32_TRAP_I;
  186. case NVPTX::SULD_1D_ARRAY_I64_TRAP_R:
  187. return NVPTX::SULD_1D_ARRAY_I64_TRAP_I;
  188. case NVPTX::SULD_2D_I8_TRAP_R:
  189. return NVPTX::SULD_2D_I8_TRAP_I;
  190. case NVPTX::SULD_2D_I16_TRAP_R:
  191. return NVPTX::SULD_2D_I16_TRAP_I;
  192. case NVPTX::SULD_2D_I32_TRAP_R:
  193. return NVPTX::SULD_2D_I32_TRAP_I;
  194. case NVPTX::SULD_2D_I64_TRAP_R:
  195. return NVPTX::SULD_2D_I64_TRAP_I;
  196. case NVPTX::SULD_2D_ARRAY_I8_TRAP_R:
  197. return NVPTX::SULD_2D_ARRAY_I8_TRAP_I;
  198. case NVPTX::SULD_2D_ARRAY_I16_TRAP_R:
  199. return NVPTX::SULD_2D_ARRAY_I16_TRAP_I;
  200. case NVPTX::SULD_2D_ARRAY_I32_TRAP_R:
  201. return NVPTX::SULD_2D_ARRAY_I32_TRAP_I;
  202. case NVPTX::SULD_2D_ARRAY_I64_TRAP_R:
  203. return NVPTX::SULD_2D_ARRAY_I64_TRAP_I;
  204. case NVPTX::SULD_3D_I8_TRAP_R:
  205. return NVPTX::SULD_3D_I8_TRAP_I;
  206. case NVPTX::SULD_3D_I16_TRAP_R:
  207. return NVPTX::SULD_3D_I16_TRAP_I;
  208. case NVPTX::SULD_3D_I32_TRAP_R:
  209. return NVPTX::SULD_3D_I32_TRAP_I;
  210. case NVPTX::SULD_3D_I64_TRAP_R:
  211. return NVPTX::SULD_3D_I64_TRAP_I;
  212. case NVPTX::SULD_1D_V2I8_TRAP_R:
  213. return NVPTX::SULD_1D_V2I8_TRAP_I;
  214. case NVPTX::SULD_1D_V2I16_TRAP_R:
  215. return NVPTX::SULD_1D_V2I16_TRAP_I;
  216. case NVPTX::SULD_1D_V2I32_TRAP_R:
  217. return NVPTX::SULD_1D_V2I32_TRAP_I;
  218. case NVPTX::SULD_1D_V2I64_TRAP_R:
  219. return NVPTX::SULD_1D_V2I64_TRAP_I;
  220. case NVPTX::SULD_1D_ARRAY_V2I8_TRAP_R:
  221. return NVPTX::SULD_1D_ARRAY_V2I8_TRAP_I;
  222. case NVPTX::SULD_1D_ARRAY_V2I16_TRAP_R:
  223. return NVPTX::SULD_1D_ARRAY_V2I16_TRAP_I;
  224. case NVPTX::SULD_1D_ARRAY_V2I32_TRAP_R:
  225. return NVPTX::SULD_1D_ARRAY_V2I32_TRAP_I;
  226. case NVPTX::SULD_1D_ARRAY_V2I64_TRAP_R:
  227. return NVPTX::SULD_1D_ARRAY_V2I64_TRAP_I;
  228. case NVPTX::SULD_2D_V2I8_TRAP_R:
  229. return NVPTX::SULD_2D_V2I8_TRAP_I;
  230. case NVPTX::SULD_2D_V2I16_TRAP_R:
  231. return NVPTX::SULD_2D_V2I16_TRAP_I;
  232. case NVPTX::SULD_2D_V2I32_TRAP_R:
  233. return NVPTX::SULD_2D_V2I32_TRAP_I;
  234. case NVPTX::SULD_2D_V2I64_TRAP_R:
  235. return NVPTX::SULD_2D_V2I64_TRAP_I;
  236. case NVPTX::SULD_2D_ARRAY_V2I8_TRAP_R:
  237. return NVPTX::SULD_2D_ARRAY_V2I8_TRAP_I;
  238. case NVPTX::SULD_2D_ARRAY_V2I16_TRAP_R:
  239. return NVPTX::SULD_2D_ARRAY_V2I16_TRAP_I;
  240. case NVPTX::SULD_2D_ARRAY_V2I32_TRAP_R:
  241. return NVPTX::SULD_2D_ARRAY_V2I32_TRAP_I;
  242. case NVPTX::SULD_2D_ARRAY_V2I64_TRAP_R:
  243. return NVPTX::SULD_2D_ARRAY_V2I64_TRAP_I;
  244. case NVPTX::SULD_3D_V2I8_TRAP_R:
  245. return NVPTX::SULD_3D_V2I8_TRAP_I;
  246. case NVPTX::SULD_3D_V2I16_TRAP_R:
  247. return NVPTX::SULD_3D_V2I16_TRAP_I;
  248. case NVPTX::SULD_3D_V2I32_TRAP_R:
  249. return NVPTX::SULD_3D_V2I32_TRAP_I;
  250. case NVPTX::SULD_3D_V2I64_TRAP_R:
  251. return NVPTX::SULD_3D_V2I64_TRAP_I;
  252. case NVPTX::SULD_1D_V4I8_TRAP_R:
  253. return NVPTX::SULD_1D_V4I8_TRAP_I;
  254. case NVPTX::SULD_1D_V4I16_TRAP_R:
  255. return NVPTX::SULD_1D_V4I16_TRAP_I;
  256. case NVPTX::SULD_1D_V4I32_TRAP_R:
  257. return NVPTX::SULD_1D_V4I32_TRAP_I;
  258. case NVPTX::SULD_1D_ARRAY_V4I8_TRAP_R:
  259. return NVPTX::SULD_1D_ARRAY_V4I8_TRAP_I;
  260. case NVPTX::SULD_1D_ARRAY_V4I16_TRAP_R:
  261. return NVPTX::SULD_1D_ARRAY_V4I16_TRAP_I;
  262. case NVPTX::SULD_1D_ARRAY_V4I32_TRAP_R:
  263. return NVPTX::SULD_1D_ARRAY_V4I32_TRAP_I;
  264. case NVPTX::SULD_2D_V4I8_TRAP_R:
  265. return NVPTX::SULD_2D_V4I8_TRAP_I;
  266. case NVPTX::SULD_2D_V4I16_TRAP_R:
  267. return NVPTX::SULD_2D_V4I16_TRAP_I;
  268. case NVPTX::SULD_2D_V4I32_TRAP_R:
  269. return NVPTX::SULD_2D_V4I32_TRAP_I;
  270. case NVPTX::SULD_2D_ARRAY_V4I8_TRAP_R:
  271. return NVPTX::SULD_2D_ARRAY_V4I8_TRAP_I;
  272. case NVPTX::SULD_2D_ARRAY_V4I16_TRAP_R:
  273. return NVPTX::SULD_2D_ARRAY_V4I16_TRAP_I;
  274. case NVPTX::SULD_2D_ARRAY_V4I32_TRAP_R:
  275. return NVPTX::SULD_2D_ARRAY_V4I32_TRAP_I;
  276. case NVPTX::SULD_3D_V4I8_TRAP_R:
  277. return NVPTX::SULD_3D_V4I8_TRAP_I;
  278. case NVPTX::SULD_3D_V4I16_TRAP_R:
  279. return NVPTX::SULD_3D_V4I16_TRAP_I;
  280. case NVPTX::SULD_3D_V4I32_TRAP_R:
  281. return NVPTX::SULD_3D_V4I32_TRAP_I;
  282. case NVPTX::SULD_1D_I8_ZERO_R:
  283. return NVPTX::SULD_1D_I8_ZERO_I;
  284. case NVPTX::SULD_1D_I16_ZERO_R:
  285. return NVPTX::SULD_1D_I16_ZERO_I;
  286. case NVPTX::SULD_1D_I32_ZERO_R:
  287. return NVPTX::SULD_1D_I32_ZERO_I;
  288. case NVPTX::SULD_1D_I64_ZERO_R:
  289. return NVPTX::SULD_1D_I64_ZERO_I;
  290. case NVPTX::SULD_1D_ARRAY_I8_ZERO_R:
  291. return NVPTX::SULD_1D_ARRAY_I8_ZERO_I;
  292. case NVPTX::SULD_1D_ARRAY_I16_ZERO_R:
  293. return NVPTX::SULD_1D_ARRAY_I16_ZERO_I;
  294. case NVPTX::SULD_1D_ARRAY_I32_ZERO_R:
  295. return NVPTX::SULD_1D_ARRAY_I32_ZERO_I;
  296. case NVPTX::SULD_1D_ARRAY_I64_ZERO_R:
  297. return NVPTX::SULD_1D_ARRAY_I64_ZERO_I;
  298. case NVPTX::SULD_2D_I8_ZERO_R:
  299. return NVPTX::SULD_2D_I8_ZERO_I;
  300. case NVPTX::SULD_2D_I16_ZERO_R:
  301. return NVPTX::SULD_2D_I16_ZERO_I;
  302. case NVPTX::SULD_2D_I32_ZERO_R:
  303. return NVPTX::SULD_2D_I32_ZERO_I;
  304. case NVPTX::SULD_2D_I64_ZERO_R:
  305. return NVPTX::SULD_2D_I64_ZERO_I;
  306. case NVPTX::SULD_2D_ARRAY_I8_ZERO_R:
  307. return NVPTX::SULD_2D_ARRAY_I8_ZERO_I;
  308. case NVPTX::SULD_2D_ARRAY_I16_ZERO_R:
  309. return NVPTX::SULD_2D_ARRAY_I16_ZERO_I;
  310. case NVPTX::SULD_2D_ARRAY_I32_ZERO_R:
  311. return NVPTX::SULD_2D_ARRAY_I32_ZERO_I;
  312. case NVPTX::SULD_2D_ARRAY_I64_ZERO_R:
  313. return NVPTX::SULD_2D_ARRAY_I64_ZERO_I;
  314. case NVPTX::SULD_3D_I8_ZERO_R:
  315. return NVPTX::SULD_3D_I8_ZERO_I;
  316. case NVPTX::SULD_3D_I16_ZERO_R:
  317. return NVPTX::SULD_3D_I16_ZERO_I;
  318. case NVPTX::SULD_3D_I32_ZERO_R:
  319. return NVPTX::SULD_3D_I32_ZERO_I;
  320. case NVPTX::SULD_3D_I64_ZERO_R:
  321. return NVPTX::SULD_3D_I64_ZERO_I;
  322. case NVPTX::SULD_1D_V2I8_ZERO_R:
  323. return NVPTX::SULD_1D_V2I8_ZERO_I;
  324. case NVPTX::SULD_1D_V2I16_ZERO_R:
  325. return NVPTX::SULD_1D_V2I16_ZERO_I;
  326. case NVPTX::SULD_1D_V2I32_ZERO_R:
  327. return NVPTX::SULD_1D_V2I32_ZERO_I;
  328. case NVPTX::SULD_1D_V2I64_ZERO_R:
  329. return NVPTX::SULD_1D_V2I64_ZERO_I;
  330. case NVPTX::SULD_1D_ARRAY_V2I8_ZERO_R:
  331. return NVPTX::SULD_1D_ARRAY_V2I8_ZERO_I;
  332. case NVPTX::SULD_1D_ARRAY_V2I16_ZERO_R:
  333. return NVPTX::SULD_1D_ARRAY_V2I16_ZERO_I;
  334. case NVPTX::SULD_1D_ARRAY_V2I32_ZERO_R:
  335. return NVPTX::SULD_1D_ARRAY_V2I32_ZERO_I;
  336. case NVPTX::SULD_1D_ARRAY_V2I64_ZERO_R:
  337. return NVPTX::SULD_1D_ARRAY_V2I64_ZERO_I;
  338. case NVPTX::SULD_2D_V2I8_ZERO_R:
  339. return NVPTX::SULD_2D_V2I8_ZERO_I;
  340. case NVPTX::SULD_2D_V2I16_ZERO_R:
  341. return NVPTX::SULD_2D_V2I16_ZERO_I;
  342. case NVPTX::SULD_2D_V2I32_ZERO_R:
  343. return NVPTX::SULD_2D_V2I32_ZERO_I;
  344. case NVPTX::SULD_2D_V2I64_ZERO_R:
  345. return NVPTX::SULD_2D_V2I64_ZERO_I;
  346. case NVPTX::SULD_2D_ARRAY_V2I8_ZERO_R:
  347. return NVPTX::SULD_2D_ARRAY_V2I8_ZERO_I;
  348. case NVPTX::SULD_2D_ARRAY_V2I16_ZERO_R:
  349. return NVPTX::SULD_2D_ARRAY_V2I16_ZERO_I;
  350. case NVPTX::SULD_2D_ARRAY_V2I32_ZERO_R:
  351. return NVPTX::SULD_2D_ARRAY_V2I32_ZERO_I;
  352. case NVPTX::SULD_2D_ARRAY_V2I64_ZERO_R:
  353. return NVPTX::SULD_2D_ARRAY_V2I64_ZERO_I;
  354. case NVPTX::SULD_3D_V2I8_ZERO_R:
  355. return NVPTX::SULD_3D_V2I8_ZERO_I;
  356. case NVPTX::SULD_3D_V2I16_ZERO_R:
  357. return NVPTX::SULD_3D_V2I16_ZERO_I;
  358. case NVPTX::SULD_3D_V2I32_ZERO_R:
  359. return NVPTX::SULD_3D_V2I32_ZERO_I;
  360. case NVPTX::SULD_3D_V2I64_ZERO_R:
  361. return NVPTX::SULD_3D_V2I64_ZERO_I;
  362. case NVPTX::SULD_1D_V4I8_ZERO_R:
  363. return NVPTX::SULD_1D_V4I8_ZERO_I;
  364. case NVPTX::SULD_1D_V4I16_ZERO_R:
  365. return NVPTX::SULD_1D_V4I16_ZERO_I;
  366. case NVPTX::SULD_1D_V4I32_ZERO_R:
  367. return NVPTX::SULD_1D_V4I32_ZERO_I;
  368. case NVPTX::SULD_1D_ARRAY_V4I8_ZERO_R:
  369. return NVPTX::SULD_1D_ARRAY_V4I8_ZERO_I;
  370. case NVPTX::SULD_1D_ARRAY_V4I16_ZERO_R:
  371. return NVPTX::SULD_1D_ARRAY_V4I16_ZERO_I;
  372. case NVPTX::SULD_1D_ARRAY_V4I32_ZERO_R:
  373. return NVPTX::SULD_1D_ARRAY_V4I32_ZERO_I;
  374. case NVPTX::SULD_2D_V4I8_ZERO_R:
  375. return NVPTX::SULD_2D_V4I8_ZERO_I;
  376. case NVPTX::SULD_2D_V4I16_ZERO_R:
  377. return NVPTX::SULD_2D_V4I16_ZERO_I;
  378. case NVPTX::SULD_2D_V4I32_ZERO_R:
  379. return NVPTX::SULD_2D_V4I32_ZERO_I;
  380. case NVPTX::SULD_2D_ARRAY_V4I8_ZERO_R:
  381. return NVPTX::SULD_2D_ARRAY_V4I8_ZERO_I;
  382. case NVPTX::SULD_2D_ARRAY_V4I16_ZERO_R:
  383. return NVPTX::SULD_2D_ARRAY_V4I16_ZERO_I;
  384. case NVPTX::SULD_2D_ARRAY_V4I32_ZERO_R:
  385. return NVPTX::SULD_2D_ARRAY_V4I32_ZERO_I;
  386. case NVPTX::SULD_3D_V4I8_ZERO_R:
  387. return NVPTX::SULD_3D_V4I8_ZERO_I;
  388. case NVPTX::SULD_3D_V4I16_ZERO_R:
  389. return NVPTX::SULD_3D_V4I16_ZERO_I;
  390. case NVPTX::SULD_3D_V4I32_ZERO_R:
  391. return NVPTX::SULD_3D_V4I32_ZERO_I;
  392. default:
  393. llvm_unreachable("Unhandled SULD opcode");
  394. }
  395. }
  396. static unsigned sustRegisterToIndexOpcode(unsigned RegOC) {
  397. switch (RegOC) {
  398. case NVPTX::SUST_B_1D_B8_CLAMP_R:
  399. return NVPTX::SUST_B_1D_B8_CLAMP_I;
  400. case NVPTX::SUST_B_1D_B16_CLAMP_R:
  401. return NVPTX::SUST_B_1D_B16_CLAMP_I;
  402. case NVPTX::SUST_B_1D_B32_CLAMP_R:
  403. return NVPTX::SUST_B_1D_B32_CLAMP_I;
  404. case NVPTX::SUST_B_1D_B64_CLAMP_R:
  405. return NVPTX::SUST_B_1D_B64_CLAMP_I;
  406. case NVPTX::SUST_B_1D_V2B8_CLAMP_R:
  407. return NVPTX::SUST_B_1D_V2B8_CLAMP_I;
  408. case NVPTX::SUST_B_1D_V2B16_CLAMP_R:
  409. return NVPTX::SUST_B_1D_V2B16_CLAMP_I;
  410. case NVPTX::SUST_B_1D_V2B32_CLAMP_R:
  411. return NVPTX::SUST_B_1D_V2B32_CLAMP_I;
  412. case NVPTX::SUST_B_1D_V2B64_CLAMP_R:
  413. return NVPTX::SUST_B_1D_V2B64_CLAMP_I;
  414. case NVPTX::SUST_B_1D_V4B8_CLAMP_R:
  415. return NVPTX::SUST_B_1D_V4B8_CLAMP_I;
  416. case NVPTX::SUST_B_1D_V4B16_CLAMP_R:
  417. return NVPTX::SUST_B_1D_V4B16_CLAMP_I;
  418. case NVPTX::SUST_B_1D_V4B32_CLAMP_R:
  419. return NVPTX::SUST_B_1D_V4B32_CLAMP_I;
  420. case NVPTX::SUST_B_1D_ARRAY_B8_CLAMP_R:
  421. return NVPTX::SUST_B_1D_ARRAY_B8_CLAMP_I;
  422. case NVPTX::SUST_B_1D_ARRAY_B16_CLAMP_R:
  423. return NVPTX::SUST_B_1D_ARRAY_B16_CLAMP_I;
  424. case NVPTX::SUST_B_1D_ARRAY_B32_CLAMP_R:
  425. return NVPTX::SUST_B_1D_ARRAY_B32_CLAMP_I;
  426. case NVPTX::SUST_B_1D_ARRAY_B64_CLAMP_R:
  427. return NVPTX::SUST_B_1D_ARRAY_B64_CLAMP_I;
  428. case NVPTX::SUST_B_1D_ARRAY_V2B8_CLAMP_R:
  429. return NVPTX::SUST_B_1D_ARRAY_V2B8_CLAMP_I;
  430. case NVPTX::SUST_B_1D_ARRAY_V2B16_CLAMP_R:
  431. return NVPTX::SUST_B_1D_ARRAY_V2B16_CLAMP_I;
  432. case NVPTX::SUST_B_1D_ARRAY_V2B32_CLAMP_R:
  433. return NVPTX::SUST_B_1D_ARRAY_V2B32_CLAMP_I;
  434. case NVPTX::SUST_B_1D_ARRAY_V2B64_CLAMP_R:
  435. return NVPTX::SUST_B_1D_ARRAY_V2B64_CLAMP_I;
  436. case NVPTX::SUST_B_1D_ARRAY_V4B8_CLAMP_R:
  437. return NVPTX::SUST_B_1D_ARRAY_V4B8_CLAMP_I;
  438. case NVPTX::SUST_B_1D_ARRAY_V4B16_CLAMP_R:
  439. return NVPTX::SUST_B_1D_ARRAY_V4B16_CLAMP_I;
  440. case NVPTX::SUST_B_1D_ARRAY_V4B32_CLAMP_R:
  441. return NVPTX::SUST_B_1D_ARRAY_V4B32_CLAMP_I;
  442. case NVPTX::SUST_B_2D_B8_CLAMP_R:
  443. return NVPTX::SUST_B_2D_B8_CLAMP_I;
  444. case NVPTX::SUST_B_2D_B16_CLAMP_R:
  445. return NVPTX::SUST_B_2D_B16_CLAMP_I;
  446. case NVPTX::SUST_B_2D_B32_CLAMP_R:
  447. return NVPTX::SUST_B_2D_B32_CLAMP_I;
  448. case NVPTX::SUST_B_2D_B64_CLAMP_R:
  449. return NVPTX::SUST_B_2D_B64_CLAMP_I;
  450. case NVPTX::SUST_B_2D_V2B8_CLAMP_R:
  451. return NVPTX::SUST_B_2D_V2B8_CLAMP_I;
  452. case NVPTX::SUST_B_2D_V2B16_CLAMP_R:
  453. return NVPTX::SUST_B_2D_V2B16_CLAMP_I;
  454. case NVPTX::SUST_B_2D_V2B32_CLAMP_R:
  455. return NVPTX::SUST_B_2D_V2B32_CLAMP_I;
  456. case NVPTX::SUST_B_2D_V2B64_CLAMP_R:
  457. return NVPTX::SUST_B_2D_V2B64_CLAMP_I;
  458. case NVPTX::SUST_B_2D_V4B8_CLAMP_R:
  459. return NVPTX::SUST_B_2D_V4B8_CLAMP_I;
  460. case NVPTX::SUST_B_2D_V4B16_CLAMP_R:
  461. return NVPTX::SUST_B_2D_V4B16_CLAMP_I;
  462. case NVPTX::SUST_B_2D_V4B32_CLAMP_R:
  463. return NVPTX::SUST_B_2D_V4B32_CLAMP_I;
  464. case NVPTX::SUST_B_2D_ARRAY_B8_CLAMP_R:
  465. return NVPTX::SUST_B_2D_ARRAY_B8_CLAMP_I;
  466. case NVPTX::SUST_B_2D_ARRAY_B16_CLAMP_R:
  467. return NVPTX::SUST_B_2D_ARRAY_B16_CLAMP_I;
  468. case NVPTX::SUST_B_2D_ARRAY_B32_CLAMP_R:
  469. return NVPTX::SUST_B_2D_ARRAY_B32_CLAMP_I;
  470. case NVPTX::SUST_B_2D_ARRAY_B64_CLAMP_R:
  471. return NVPTX::SUST_B_2D_ARRAY_B64_CLAMP_I;
  472. case NVPTX::SUST_B_2D_ARRAY_V2B8_CLAMP_R:
  473. return NVPTX::SUST_B_2D_ARRAY_V2B8_CLAMP_I;
  474. case NVPTX::SUST_B_2D_ARRAY_V2B16_CLAMP_R:
  475. return NVPTX::SUST_B_2D_ARRAY_V2B16_CLAMP_I;
  476. case NVPTX::SUST_B_2D_ARRAY_V2B32_CLAMP_R:
  477. return NVPTX::SUST_B_2D_ARRAY_V2B32_CLAMP_I;
  478. case NVPTX::SUST_B_2D_ARRAY_V2B64_CLAMP_R:
  479. return NVPTX::SUST_B_2D_ARRAY_V2B64_CLAMP_I;
  480. case NVPTX::SUST_B_2D_ARRAY_V4B8_CLAMP_R:
  481. return NVPTX::SUST_B_2D_ARRAY_V4B8_CLAMP_I;
  482. case NVPTX::SUST_B_2D_ARRAY_V4B16_CLAMP_R:
  483. return NVPTX::SUST_B_2D_ARRAY_V4B16_CLAMP_I;
  484. case NVPTX::SUST_B_2D_ARRAY_V4B32_CLAMP_R:
  485. return NVPTX::SUST_B_2D_ARRAY_V4B32_CLAMP_I;
  486. case NVPTX::SUST_B_3D_B8_CLAMP_R:
  487. return NVPTX::SUST_B_3D_B8_CLAMP_I;
  488. case NVPTX::SUST_B_3D_B16_CLAMP_R:
  489. return NVPTX::SUST_B_3D_B16_CLAMP_I;
  490. case NVPTX::SUST_B_3D_B32_CLAMP_R:
  491. return NVPTX::SUST_B_3D_B32_CLAMP_I;
  492. case NVPTX::SUST_B_3D_B64_CLAMP_R:
  493. return NVPTX::SUST_B_3D_B64_CLAMP_I;
  494. case NVPTX::SUST_B_3D_V2B8_CLAMP_R:
  495. return NVPTX::SUST_B_3D_V2B8_CLAMP_I;
  496. case NVPTX::SUST_B_3D_V2B16_CLAMP_R:
  497. return NVPTX::SUST_B_3D_V2B16_CLAMP_I;
  498. case NVPTX::SUST_B_3D_V2B32_CLAMP_R:
  499. return NVPTX::SUST_B_3D_V2B32_CLAMP_I;
  500. case NVPTX::SUST_B_3D_V2B64_CLAMP_R:
  501. return NVPTX::SUST_B_3D_V2B64_CLAMP_I;
  502. case NVPTX::SUST_B_3D_V4B8_CLAMP_R:
  503. return NVPTX::SUST_B_3D_V4B8_CLAMP_I;
  504. case NVPTX::SUST_B_3D_V4B16_CLAMP_R:
  505. return NVPTX::SUST_B_3D_V4B16_CLAMP_I;
  506. case NVPTX::SUST_B_3D_V4B32_CLAMP_R:
  507. return NVPTX::SUST_B_3D_V4B32_CLAMP_I;
  508. case NVPTX::SUST_B_1D_B8_TRAP_R:
  509. return NVPTX::SUST_B_1D_B8_TRAP_I;
  510. case NVPTX::SUST_B_1D_B16_TRAP_R:
  511. return NVPTX::SUST_B_1D_B16_TRAP_I;
  512. case NVPTX::SUST_B_1D_B32_TRAP_R:
  513. return NVPTX::SUST_B_1D_B32_TRAP_I;
  514. case NVPTX::SUST_B_1D_B64_TRAP_R:
  515. return NVPTX::SUST_B_1D_B64_TRAP_I;
  516. case NVPTX::SUST_B_1D_V2B8_TRAP_R:
  517. return NVPTX::SUST_B_1D_V2B8_TRAP_I;
  518. case NVPTX::SUST_B_1D_V2B16_TRAP_R:
  519. return NVPTX::SUST_B_1D_V2B16_TRAP_I;
  520. case NVPTX::SUST_B_1D_V2B32_TRAP_R:
  521. return NVPTX::SUST_B_1D_V2B32_TRAP_I;
  522. case NVPTX::SUST_B_1D_V2B64_TRAP_R:
  523. return NVPTX::SUST_B_1D_V2B64_TRAP_I;
  524. case NVPTX::SUST_B_1D_V4B8_TRAP_R:
  525. return NVPTX::SUST_B_1D_V4B8_TRAP_I;
  526. case NVPTX::SUST_B_1D_V4B16_TRAP_R:
  527. return NVPTX::SUST_B_1D_V4B16_TRAP_I;
  528. case NVPTX::SUST_B_1D_V4B32_TRAP_R:
  529. return NVPTX::SUST_B_1D_V4B32_TRAP_I;
  530. case NVPTX::SUST_B_1D_ARRAY_B8_TRAP_R:
  531. return NVPTX::SUST_B_1D_ARRAY_B8_TRAP_I;
  532. case NVPTX::SUST_B_1D_ARRAY_B16_TRAP_R:
  533. return NVPTX::SUST_B_1D_ARRAY_B16_TRAP_I;
  534. case NVPTX::SUST_B_1D_ARRAY_B32_TRAP_R:
  535. return NVPTX::SUST_B_1D_ARRAY_B32_TRAP_I;
  536. case NVPTX::SUST_B_1D_ARRAY_B64_TRAP_R:
  537. return NVPTX::SUST_B_1D_ARRAY_B64_TRAP_I;
  538. case NVPTX::SUST_B_1D_ARRAY_V2B8_TRAP_R:
  539. return NVPTX::SUST_B_1D_ARRAY_V2B8_TRAP_I;
  540. case NVPTX::SUST_B_1D_ARRAY_V2B16_TRAP_R:
  541. return NVPTX::SUST_B_1D_ARRAY_V2B16_TRAP_I;
  542. case NVPTX::SUST_B_1D_ARRAY_V2B32_TRAP_R:
  543. return NVPTX::SUST_B_1D_ARRAY_V2B32_TRAP_I;
  544. case NVPTX::SUST_B_1D_ARRAY_V2B64_TRAP_R:
  545. return NVPTX::SUST_B_1D_ARRAY_V2B64_TRAP_I;
  546. case NVPTX::SUST_B_1D_ARRAY_V4B8_TRAP_R:
  547. return NVPTX::SUST_B_1D_ARRAY_V4B8_TRAP_I;
  548. case NVPTX::SUST_B_1D_ARRAY_V4B16_TRAP_R:
  549. return NVPTX::SUST_B_1D_ARRAY_V4B16_TRAP_I;
  550. case NVPTX::SUST_B_1D_ARRAY_V4B32_TRAP_R:
  551. return NVPTX::SUST_B_1D_ARRAY_V4B32_TRAP_I;
  552. case NVPTX::SUST_B_2D_B8_TRAP_R:
  553. return NVPTX::SUST_B_2D_B8_TRAP_I;
  554. case NVPTX::SUST_B_2D_B16_TRAP_R:
  555. return NVPTX::SUST_B_2D_B16_TRAP_I;
  556. case NVPTX::SUST_B_2D_B32_TRAP_R:
  557. return NVPTX::SUST_B_2D_B32_TRAP_I;
  558. case NVPTX::SUST_B_2D_B64_TRAP_R:
  559. return NVPTX::SUST_B_2D_B64_TRAP_I;
  560. case NVPTX::SUST_B_2D_V2B8_TRAP_R:
  561. return NVPTX::SUST_B_2D_V2B8_TRAP_I;
  562. case NVPTX::SUST_B_2D_V2B16_TRAP_R:
  563. return NVPTX::SUST_B_2D_V2B16_TRAP_I;
  564. case NVPTX::SUST_B_2D_V2B32_TRAP_R:
  565. return NVPTX::SUST_B_2D_V2B32_TRAP_I;
  566. case NVPTX::SUST_B_2D_V2B64_TRAP_R:
  567. return NVPTX::SUST_B_2D_V2B64_TRAP_I;
  568. case NVPTX::SUST_B_2D_V4B8_TRAP_R:
  569. return NVPTX::SUST_B_2D_V4B8_TRAP_I;
  570. case NVPTX::SUST_B_2D_V4B16_TRAP_R:
  571. return NVPTX::SUST_B_2D_V4B16_TRAP_I;
  572. case NVPTX::SUST_B_2D_V4B32_TRAP_R:
  573. return NVPTX::SUST_B_2D_V4B32_TRAP_I;
  574. case NVPTX::SUST_B_2D_ARRAY_B8_TRAP_R:
  575. return NVPTX::SUST_B_2D_ARRAY_B8_TRAP_I;
  576. case NVPTX::SUST_B_2D_ARRAY_B16_TRAP_R:
  577. return NVPTX::SUST_B_2D_ARRAY_B16_TRAP_I;
  578. case NVPTX::SUST_B_2D_ARRAY_B32_TRAP_R:
  579. return NVPTX::SUST_B_2D_ARRAY_B32_TRAP_I;
  580. case NVPTX::SUST_B_2D_ARRAY_B64_TRAP_R:
  581. return NVPTX::SUST_B_2D_ARRAY_B64_TRAP_I;
  582. case NVPTX::SUST_B_2D_ARRAY_V2B8_TRAP_R:
  583. return NVPTX::SUST_B_2D_ARRAY_V2B8_TRAP_I;
  584. case NVPTX::SUST_B_2D_ARRAY_V2B16_TRAP_R:
  585. return NVPTX::SUST_B_2D_ARRAY_V2B16_TRAP_I;
  586. case NVPTX::SUST_B_2D_ARRAY_V2B32_TRAP_R:
  587. return NVPTX::SUST_B_2D_ARRAY_V2B32_TRAP_I;
  588. case NVPTX::SUST_B_2D_ARRAY_V2B64_TRAP_R:
  589. return NVPTX::SUST_B_2D_ARRAY_V2B64_TRAP_I;
  590. case NVPTX::SUST_B_2D_ARRAY_V4B8_TRAP_R:
  591. return NVPTX::SUST_B_2D_ARRAY_V4B8_TRAP_I;
  592. case NVPTX::SUST_B_2D_ARRAY_V4B16_TRAP_R:
  593. return NVPTX::SUST_B_2D_ARRAY_V4B16_TRAP_I;
  594. case NVPTX::SUST_B_2D_ARRAY_V4B32_TRAP_R:
  595. return NVPTX::SUST_B_2D_ARRAY_V4B32_TRAP_I;
  596. case NVPTX::SUST_B_3D_B8_TRAP_R:
  597. return NVPTX::SUST_B_3D_B8_TRAP_I;
  598. case NVPTX::SUST_B_3D_B16_TRAP_R:
  599. return NVPTX::SUST_B_3D_B16_TRAP_I;
  600. case NVPTX::SUST_B_3D_B32_TRAP_R:
  601. return NVPTX::SUST_B_3D_B32_TRAP_I;
  602. case NVPTX::SUST_B_3D_B64_TRAP_R:
  603. return NVPTX::SUST_B_3D_B64_TRAP_I;
  604. case NVPTX::SUST_B_3D_V2B8_TRAP_R:
  605. return NVPTX::SUST_B_3D_V2B8_TRAP_I;
  606. case NVPTX::SUST_B_3D_V2B16_TRAP_R:
  607. return NVPTX::SUST_B_3D_V2B16_TRAP_I;
  608. case NVPTX::SUST_B_3D_V2B32_TRAP_R:
  609. return NVPTX::SUST_B_3D_V2B32_TRAP_I;
  610. case NVPTX::SUST_B_3D_V2B64_TRAP_R:
  611. return NVPTX::SUST_B_3D_V2B64_TRAP_I;
  612. case NVPTX::SUST_B_3D_V4B8_TRAP_R:
  613. return NVPTX::SUST_B_3D_V4B8_TRAP_I;
  614. case NVPTX::SUST_B_3D_V4B16_TRAP_R:
  615. return NVPTX::SUST_B_3D_V4B16_TRAP_I;
  616. case NVPTX::SUST_B_3D_V4B32_TRAP_R:
  617. return NVPTX::SUST_B_3D_V4B32_TRAP_I;
  618. case NVPTX::SUST_B_1D_B8_ZERO_R:
  619. return NVPTX::SUST_B_1D_B8_ZERO_I;
  620. case NVPTX::SUST_B_1D_B16_ZERO_R:
  621. return NVPTX::SUST_B_1D_B16_ZERO_I;
  622. case NVPTX::SUST_B_1D_B32_ZERO_R:
  623. return NVPTX::SUST_B_1D_B32_ZERO_I;
  624. case NVPTX::SUST_B_1D_B64_ZERO_R:
  625. return NVPTX::SUST_B_1D_B64_ZERO_I;
  626. case NVPTX::SUST_B_1D_V2B8_ZERO_R:
  627. return NVPTX::SUST_B_1D_V2B8_ZERO_I;
  628. case NVPTX::SUST_B_1D_V2B16_ZERO_R:
  629. return NVPTX::SUST_B_1D_V2B16_ZERO_I;
  630. case NVPTX::SUST_B_1D_V2B32_ZERO_R:
  631. return NVPTX::SUST_B_1D_V2B32_ZERO_I;
  632. case NVPTX::SUST_B_1D_V2B64_ZERO_R:
  633. return NVPTX::SUST_B_1D_V2B64_ZERO_I;
  634. case NVPTX::SUST_B_1D_V4B8_ZERO_R:
  635. return NVPTX::SUST_B_1D_V4B8_ZERO_I;
  636. case NVPTX::SUST_B_1D_V4B16_ZERO_R:
  637. return NVPTX::SUST_B_1D_V4B16_ZERO_I;
  638. case NVPTX::SUST_B_1D_V4B32_ZERO_R:
  639. return NVPTX::SUST_B_1D_V4B32_ZERO_I;
  640. case NVPTX::SUST_B_1D_ARRAY_B8_ZERO_R:
  641. return NVPTX::SUST_B_1D_ARRAY_B8_ZERO_I;
  642. case NVPTX::SUST_B_1D_ARRAY_B16_ZERO_R:
  643. return NVPTX::SUST_B_1D_ARRAY_B16_ZERO_I;
  644. case NVPTX::SUST_B_1D_ARRAY_B32_ZERO_R:
  645. return NVPTX::SUST_B_1D_ARRAY_B32_ZERO_I;
  646. case NVPTX::SUST_B_1D_ARRAY_B64_ZERO_R:
  647. return NVPTX::SUST_B_1D_ARRAY_B64_ZERO_I;
  648. case NVPTX::SUST_B_1D_ARRAY_V2B8_ZERO_R:
  649. return NVPTX::SUST_B_1D_ARRAY_V2B8_ZERO_I;
  650. case NVPTX::SUST_B_1D_ARRAY_V2B16_ZERO_R:
  651. return NVPTX::SUST_B_1D_ARRAY_V2B16_ZERO_I;
  652. case NVPTX::SUST_B_1D_ARRAY_V2B32_ZERO_R:
  653. return NVPTX::SUST_B_1D_ARRAY_V2B32_ZERO_I;
  654. case NVPTX::SUST_B_1D_ARRAY_V2B64_ZERO_R:
  655. return NVPTX::SUST_B_1D_ARRAY_V2B64_ZERO_I;
  656. case NVPTX::SUST_B_1D_ARRAY_V4B8_ZERO_R:
  657. return NVPTX::SUST_B_1D_ARRAY_V4B8_ZERO_I;
  658. case NVPTX::SUST_B_1D_ARRAY_V4B16_ZERO_R:
  659. return NVPTX::SUST_B_1D_ARRAY_V4B16_ZERO_I;
  660. case NVPTX::SUST_B_1D_ARRAY_V4B32_ZERO_R:
  661. return NVPTX::SUST_B_1D_ARRAY_V4B32_ZERO_I;
  662. case NVPTX::SUST_B_2D_B8_ZERO_R:
  663. return NVPTX::SUST_B_2D_B8_ZERO_I;
  664. case NVPTX::SUST_B_2D_B16_ZERO_R:
  665. return NVPTX::SUST_B_2D_B16_ZERO_I;
  666. case NVPTX::SUST_B_2D_B32_ZERO_R:
  667. return NVPTX::SUST_B_2D_B32_ZERO_I;
  668. case NVPTX::SUST_B_2D_B64_ZERO_R:
  669. return NVPTX::SUST_B_2D_B64_ZERO_I;
  670. case NVPTX::SUST_B_2D_V2B8_ZERO_R:
  671. return NVPTX::SUST_B_2D_V2B8_ZERO_I;
  672. case NVPTX::SUST_B_2D_V2B16_ZERO_R:
  673. return NVPTX::SUST_B_2D_V2B16_ZERO_I;
  674. case NVPTX::SUST_B_2D_V2B32_ZERO_R:
  675. return NVPTX::SUST_B_2D_V2B32_ZERO_I;
  676. case NVPTX::SUST_B_2D_V2B64_ZERO_R:
  677. return NVPTX::SUST_B_2D_V2B64_ZERO_I;
  678. case NVPTX::SUST_B_2D_V4B8_ZERO_R:
  679. return NVPTX::SUST_B_2D_V4B8_ZERO_I;
  680. case NVPTX::SUST_B_2D_V4B16_ZERO_R:
  681. return NVPTX::SUST_B_2D_V4B16_ZERO_I;
  682. case NVPTX::SUST_B_2D_V4B32_ZERO_R:
  683. return NVPTX::SUST_B_2D_V4B32_ZERO_I;
  684. case NVPTX::SUST_B_2D_ARRAY_B8_ZERO_R:
  685. return NVPTX::SUST_B_2D_ARRAY_B8_ZERO_I;
  686. case NVPTX::SUST_B_2D_ARRAY_B16_ZERO_R:
  687. return NVPTX::SUST_B_2D_ARRAY_B16_ZERO_I;
  688. case NVPTX::SUST_B_2D_ARRAY_B32_ZERO_R:
  689. return NVPTX::SUST_B_2D_ARRAY_B32_ZERO_I;
  690. case NVPTX::SUST_B_2D_ARRAY_B64_ZERO_R:
  691. return NVPTX::SUST_B_2D_ARRAY_B64_ZERO_I;
  692. case NVPTX::SUST_B_2D_ARRAY_V2B8_ZERO_R:
  693. return NVPTX::SUST_B_2D_ARRAY_V2B8_ZERO_I;
  694. case NVPTX::SUST_B_2D_ARRAY_V2B16_ZERO_R:
  695. return NVPTX::SUST_B_2D_ARRAY_V2B16_ZERO_I;
  696. case NVPTX::SUST_B_2D_ARRAY_V2B32_ZERO_R:
  697. return NVPTX::SUST_B_2D_ARRAY_V2B32_ZERO_I;
  698. case NVPTX::SUST_B_2D_ARRAY_V2B64_ZERO_R:
  699. return NVPTX::SUST_B_2D_ARRAY_V2B64_ZERO_I;
  700. case NVPTX::SUST_B_2D_ARRAY_V4B8_ZERO_R:
  701. return NVPTX::SUST_B_2D_ARRAY_V4B8_ZERO_I;
  702. case NVPTX::SUST_B_2D_ARRAY_V4B16_ZERO_R:
  703. return NVPTX::SUST_B_2D_ARRAY_V4B16_ZERO_I;
  704. case NVPTX::SUST_B_2D_ARRAY_V4B32_ZERO_R:
  705. return NVPTX::SUST_B_2D_ARRAY_V4B32_ZERO_I;
  706. case NVPTX::SUST_B_3D_B8_ZERO_R:
  707. return NVPTX::SUST_B_3D_B8_ZERO_I;
  708. case NVPTX::SUST_B_3D_B16_ZERO_R:
  709. return NVPTX::SUST_B_3D_B16_ZERO_I;
  710. case NVPTX::SUST_B_3D_B32_ZERO_R:
  711. return NVPTX::SUST_B_3D_B32_ZERO_I;
  712. case NVPTX::SUST_B_3D_B64_ZERO_R:
  713. return NVPTX::SUST_B_3D_B64_ZERO_I;
  714. case NVPTX::SUST_B_3D_V2B8_ZERO_R:
  715. return NVPTX::SUST_B_3D_V2B8_ZERO_I;
  716. case NVPTX::SUST_B_3D_V2B16_ZERO_R:
  717. return NVPTX::SUST_B_3D_V2B16_ZERO_I;
  718. case NVPTX::SUST_B_3D_V2B32_ZERO_R:
  719. return NVPTX::SUST_B_3D_V2B32_ZERO_I;
  720. case NVPTX::SUST_B_3D_V2B64_ZERO_R:
  721. return NVPTX::SUST_B_3D_V2B64_ZERO_I;
  722. case NVPTX::SUST_B_3D_V4B8_ZERO_R:
  723. return NVPTX::SUST_B_3D_V4B8_ZERO_I;
  724. case NVPTX::SUST_B_3D_V4B16_ZERO_R:
  725. return NVPTX::SUST_B_3D_V4B16_ZERO_I;
  726. case NVPTX::SUST_B_3D_V4B32_ZERO_R:
  727. return NVPTX::SUST_B_3D_V4B32_ZERO_I;
  728. case NVPTX::SUST_P_1D_B8_TRAP_R:
  729. return NVPTX::SUST_P_1D_B8_TRAP_I;
  730. case NVPTX::SUST_P_1D_B16_TRAP_R:
  731. return NVPTX::SUST_P_1D_B16_TRAP_I;
  732. case NVPTX::SUST_P_1D_B32_TRAP_R:
  733. return NVPTX::SUST_P_1D_B32_TRAP_I;
  734. case NVPTX::SUST_P_1D_V2B8_TRAP_R:
  735. return NVPTX::SUST_P_1D_V2B8_TRAP_I;
  736. case NVPTX::SUST_P_1D_V2B16_TRAP_R:
  737. return NVPTX::SUST_P_1D_V2B16_TRAP_I;
  738. case NVPTX::SUST_P_1D_V2B32_TRAP_R:
  739. return NVPTX::SUST_P_1D_V2B32_TRAP_I;
  740. case NVPTX::SUST_P_1D_V4B8_TRAP_R:
  741. return NVPTX::SUST_P_1D_V4B8_TRAP_I;
  742. case NVPTX::SUST_P_1D_V4B16_TRAP_R:
  743. return NVPTX::SUST_P_1D_V4B16_TRAP_I;
  744. case NVPTX::SUST_P_1D_V4B32_TRAP_R:
  745. return NVPTX::SUST_P_1D_V4B32_TRAP_I;
  746. case NVPTX::SUST_P_1D_ARRAY_B8_TRAP_R:
  747. return NVPTX::SUST_P_1D_ARRAY_B8_TRAP_I;
  748. case NVPTX::SUST_P_1D_ARRAY_B16_TRAP_R:
  749. return NVPTX::SUST_P_1D_ARRAY_B16_TRAP_I;
  750. case NVPTX::SUST_P_1D_ARRAY_B32_TRAP_R:
  751. return NVPTX::SUST_P_1D_ARRAY_B32_TRAP_I;
  752. case NVPTX::SUST_P_1D_ARRAY_V2B8_TRAP_R:
  753. return NVPTX::SUST_P_1D_ARRAY_V2B8_TRAP_I;
  754. case NVPTX::SUST_P_1D_ARRAY_V2B16_TRAP_R:
  755. return NVPTX::SUST_P_1D_ARRAY_V2B16_TRAP_I;
  756. case NVPTX::SUST_P_1D_ARRAY_V2B32_TRAP_R:
  757. return NVPTX::SUST_P_1D_ARRAY_V2B32_TRAP_I;
  758. case NVPTX::SUST_P_1D_ARRAY_V4B8_TRAP_R:
  759. return NVPTX::SUST_P_1D_ARRAY_V4B8_TRAP_I;
  760. case NVPTX::SUST_P_1D_ARRAY_V4B16_TRAP_R:
  761. return NVPTX::SUST_P_1D_ARRAY_V4B16_TRAP_I;
  762. case NVPTX::SUST_P_1D_ARRAY_V4B32_TRAP_R:
  763. return NVPTX::SUST_P_1D_ARRAY_V4B32_TRAP_I;
  764. case NVPTX::SUST_P_2D_B8_TRAP_R:
  765. return NVPTX::SUST_P_2D_B8_TRAP_I;
  766. case NVPTX::SUST_P_2D_B16_TRAP_R:
  767. return NVPTX::SUST_P_2D_B16_TRAP_I;
  768. case NVPTX::SUST_P_2D_B32_TRAP_R:
  769. return NVPTX::SUST_P_2D_B32_TRAP_I;
  770. case NVPTX::SUST_P_2D_V2B8_TRAP_R:
  771. return NVPTX::SUST_P_2D_V2B8_TRAP_I;
  772. case NVPTX::SUST_P_2D_V2B16_TRAP_R:
  773. return NVPTX::SUST_P_2D_V2B16_TRAP_I;
  774. case NVPTX::SUST_P_2D_V2B32_TRAP_R:
  775. return NVPTX::SUST_P_2D_V2B32_TRAP_I;
  776. case NVPTX::SUST_P_2D_V4B8_TRAP_R:
  777. return NVPTX::SUST_P_2D_V4B8_TRAP_I;
  778. case NVPTX::SUST_P_2D_V4B16_TRAP_R:
  779. return NVPTX::SUST_P_2D_V4B16_TRAP_I;
  780. case NVPTX::SUST_P_2D_V4B32_TRAP_R:
  781. return NVPTX::SUST_P_2D_V4B32_TRAP_I;
  782. case NVPTX::SUST_P_2D_ARRAY_B8_TRAP_R:
  783. return NVPTX::SUST_P_2D_ARRAY_B8_TRAP_I;
  784. case NVPTX::SUST_P_2D_ARRAY_B16_TRAP_R:
  785. return NVPTX::SUST_P_2D_ARRAY_B16_TRAP_I;
  786. case NVPTX::SUST_P_2D_ARRAY_B32_TRAP_R:
  787. return NVPTX::SUST_P_2D_ARRAY_B32_TRAP_I;
  788. case NVPTX::SUST_P_2D_ARRAY_V2B8_TRAP_R:
  789. return NVPTX::SUST_P_2D_ARRAY_V2B8_TRAP_I;
  790. case NVPTX::SUST_P_2D_ARRAY_V2B16_TRAP_R:
  791. return NVPTX::SUST_P_2D_ARRAY_V2B16_TRAP_I;
  792. case NVPTX::SUST_P_2D_ARRAY_V2B32_TRAP_R:
  793. return NVPTX::SUST_P_2D_ARRAY_V2B32_TRAP_I;
  794. case NVPTX::SUST_P_2D_ARRAY_V4B8_TRAP_R:
  795. return NVPTX::SUST_P_2D_ARRAY_V4B8_TRAP_I;
  796. case NVPTX::SUST_P_2D_ARRAY_V4B16_TRAP_R:
  797. return NVPTX::SUST_P_2D_ARRAY_V4B16_TRAP_I;
  798. case NVPTX::SUST_P_2D_ARRAY_V4B32_TRAP_R:
  799. return NVPTX::SUST_P_2D_ARRAY_V4B32_TRAP_I;
  800. case NVPTX::SUST_P_3D_B8_TRAP_R:
  801. return NVPTX::SUST_P_3D_B8_TRAP_I;
  802. case NVPTX::SUST_P_3D_B16_TRAP_R:
  803. return NVPTX::SUST_P_3D_B16_TRAP_I;
  804. case NVPTX::SUST_P_3D_B32_TRAP_R:
  805. return NVPTX::SUST_P_3D_B32_TRAP_I;
  806. case NVPTX::SUST_P_3D_V2B8_TRAP_R:
  807. return NVPTX::SUST_P_3D_V2B8_TRAP_I;
  808. case NVPTX::SUST_P_3D_V2B16_TRAP_R:
  809. return NVPTX::SUST_P_3D_V2B16_TRAP_I;
  810. case NVPTX::SUST_P_3D_V2B32_TRAP_R:
  811. return NVPTX::SUST_P_3D_V2B32_TRAP_I;
  812. case NVPTX::SUST_P_3D_V4B8_TRAP_R:
  813. return NVPTX::SUST_P_3D_V4B8_TRAP_I;
  814. case NVPTX::SUST_P_3D_V4B16_TRAP_R:
  815. return NVPTX::SUST_P_3D_V4B16_TRAP_I;
  816. case NVPTX::SUST_P_3D_V4B32_TRAP_R:
  817. return NVPTX::SUST_P_3D_V4B32_TRAP_I;
  818. default:
  819. llvm_unreachable("Unhandled SUST opcode");
  820. }
  821. }
  822. static unsigned texRegisterToIndexOpcode(unsigned RegOC) {
  823. switch (RegOC) {
  824. case NVPTX::TEX_1D_F32_S32_RR:
  825. return NVPTX::TEX_1D_F32_S32_IR;
  826. case NVPTX::TEX_1D_F32_S32_RI:
  827. return NVPTX::TEX_1D_F32_S32_II;
  828. case NVPTX::TEX_1D_F32_F32_RR:
  829. return NVPTX::TEX_1D_F32_F32_IR;
  830. case NVPTX::TEX_1D_F32_F32_RI:
  831. return NVPTX::TEX_1D_F32_F32_II;
  832. case NVPTX::TEX_1D_F32_F32_LEVEL_RR:
  833. return NVPTX::TEX_1D_F32_F32_LEVEL_IR;
  834. case NVPTX::TEX_1D_F32_F32_LEVEL_RI:
  835. return NVPTX::TEX_1D_F32_F32_LEVEL_II;
  836. case NVPTX::TEX_1D_F32_F32_GRAD_RR:
  837. return NVPTX::TEX_1D_F32_F32_GRAD_IR;
  838. case NVPTX::TEX_1D_F32_F32_GRAD_RI:
  839. return NVPTX::TEX_1D_F32_F32_GRAD_II;
  840. case NVPTX::TEX_1D_S32_S32_RR:
  841. return NVPTX::TEX_1D_S32_S32_IR;
  842. case NVPTX::TEX_1D_S32_S32_RI:
  843. return NVPTX::TEX_1D_S32_S32_II;
  844. case NVPTX::TEX_1D_S32_F32_RR:
  845. return NVPTX::TEX_1D_S32_F32_IR;
  846. case NVPTX::TEX_1D_S32_F32_RI:
  847. return NVPTX::TEX_1D_S32_F32_II;
  848. case NVPTX::TEX_1D_S32_F32_LEVEL_RR:
  849. return NVPTX::TEX_1D_S32_F32_LEVEL_IR;
  850. case NVPTX::TEX_1D_S32_F32_LEVEL_RI:
  851. return NVPTX::TEX_1D_S32_F32_LEVEL_II;
  852. case NVPTX::TEX_1D_S32_F32_GRAD_RR:
  853. return NVPTX::TEX_1D_S32_F32_GRAD_IR;
  854. case NVPTX::TEX_1D_S32_F32_GRAD_RI:
  855. return NVPTX::TEX_1D_S32_F32_GRAD_II;
  856. case NVPTX::TEX_1D_U32_S32_RR:
  857. return NVPTX::TEX_1D_U32_S32_IR;
  858. case NVPTX::TEX_1D_U32_S32_RI:
  859. return NVPTX::TEX_1D_U32_S32_II;
  860. case NVPTX::TEX_1D_U32_F32_RR:
  861. return NVPTX::TEX_1D_U32_F32_IR;
  862. case NVPTX::TEX_1D_U32_F32_RI:
  863. return NVPTX::TEX_1D_U32_F32_II;
  864. case NVPTX::TEX_1D_U32_F32_LEVEL_RR:
  865. return NVPTX::TEX_1D_U32_F32_LEVEL_IR;
  866. case NVPTX::TEX_1D_U32_F32_LEVEL_RI:
  867. return NVPTX::TEX_1D_U32_F32_LEVEL_II;
  868. case NVPTX::TEX_1D_U32_F32_GRAD_RR:
  869. return NVPTX::TEX_1D_U32_F32_GRAD_IR;
  870. case NVPTX::TEX_1D_U32_F32_GRAD_RI:
  871. return NVPTX::TEX_1D_U32_F32_GRAD_II;
  872. case NVPTX::TEX_1D_ARRAY_F32_S32_RR:
  873. return NVPTX::TEX_1D_ARRAY_F32_S32_IR;
  874. case NVPTX::TEX_1D_ARRAY_F32_S32_RI:
  875. return NVPTX::TEX_1D_ARRAY_F32_S32_II;
  876. case NVPTX::TEX_1D_ARRAY_F32_F32_RR:
  877. return NVPTX::TEX_1D_ARRAY_F32_F32_IR;
  878. case NVPTX::TEX_1D_ARRAY_F32_F32_RI:
  879. return NVPTX::TEX_1D_ARRAY_F32_F32_II;
  880. case NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_RR:
  881. return NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_IR;
  882. case NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_RI:
  883. return NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_II;
  884. case NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_RR:
  885. return NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_IR;
  886. case NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_RI:
  887. return NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_II;
  888. case NVPTX::TEX_1D_ARRAY_S32_S32_RR:
  889. return NVPTX::TEX_1D_ARRAY_S32_S32_IR;
  890. case NVPTX::TEX_1D_ARRAY_S32_S32_RI:
  891. return NVPTX::TEX_1D_ARRAY_S32_S32_II;
  892. case NVPTX::TEX_1D_ARRAY_S32_F32_RR:
  893. return NVPTX::TEX_1D_ARRAY_S32_F32_IR;
  894. case NVPTX::TEX_1D_ARRAY_S32_F32_RI:
  895. return NVPTX::TEX_1D_ARRAY_S32_F32_II;
  896. case NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_RR:
  897. return NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_IR;
  898. case NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_RI:
  899. return NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_II;
  900. case NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_RR:
  901. return NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_IR;
  902. case NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_RI:
  903. return NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_II;
  904. case NVPTX::TEX_1D_ARRAY_U32_S32_RR:
  905. return NVPTX::TEX_1D_ARRAY_U32_S32_IR;
  906. case NVPTX::TEX_1D_ARRAY_U32_S32_RI:
  907. return NVPTX::TEX_1D_ARRAY_U32_S32_II;
  908. case NVPTX::TEX_1D_ARRAY_U32_F32_RR:
  909. return NVPTX::TEX_1D_ARRAY_U32_F32_IR;
  910. case NVPTX::TEX_1D_ARRAY_U32_F32_RI:
  911. return NVPTX::TEX_1D_ARRAY_U32_F32_II;
  912. case NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_RR:
  913. return NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_IR;
  914. case NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_RI:
  915. return NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_II;
  916. case NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_RR:
  917. return NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_IR;
  918. case NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_RI:
  919. return NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_II;
  920. case NVPTX::TEX_2D_F32_S32_RR:
  921. return NVPTX::TEX_2D_F32_S32_IR;
  922. case NVPTX::TEX_2D_F32_S32_RI:
  923. return NVPTX::TEX_2D_F32_S32_II;
  924. case NVPTX::TEX_2D_F32_F32_RR:
  925. return NVPTX::TEX_2D_F32_F32_IR;
  926. case NVPTX::TEX_2D_F32_F32_RI:
  927. return NVPTX::TEX_2D_F32_F32_II;
  928. case NVPTX::TEX_2D_F32_F32_LEVEL_RR:
  929. return NVPTX::TEX_2D_F32_F32_LEVEL_IR;
  930. case NVPTX::TEX_2D_F32_F32_LEVEL_RI:
  931. return NVPTX::TEX_2D_F32_F32_LEVEL_II;
  932. case NVPTX::TEX_2D_F32_F32_GRAD_RR:
  933. return NVPTX::TEX_2D_F32_F32_GRAD_IR;
  934. case NVPTX::TEX_2D_F32_F32_GRAD_RI:
  935. return NVPTX::TEX_2D_F32_F32_GRAD_II;
  936. case NVPTX::TEX_2D_S32_S32_RR:
  937. return NVPTX::TEX_2D_S32_S32_IR;
  938. case NVPTX::TEX_2D_S32_S32_RI:
  939. return NVPTX::TEX_2D_S32_S32_II;
  940. case NVPTX::TEX_2D_S32_F32_RR:
  941. return NVPTX::TEX_2D_S32_F32_IR;
  942. case NVPTX::TEX_2D_S32_F32_RI:
  943. return NVPTX::TEX_2D_S32_F32_II;
  944. case NVPTX::TEX_2D_S32_F32_LEVEL_RR:
  945. return NVPTX::TEX_2D_S32_F32_LEVEL_IR;
  946. case NVPTX::TEX_2D_S32_F32_LEVEL_RI:
  947. return NVPTX::TEX_2D_S32_F32_LEVEL_II;
  948. case NVPTX::TEX_2D_S32_F32_GRAD_RR:
  949. return NVPTX::TEX_2D_S32_F32_GRAD_IR;
  950. case NVPTX::TEX_2D_S32_F32_GRAD_RI:
  951. return NVPTX::TEX_2D_S32_F32_GRAD_II;
  952. case NVPTX::TEX_2D_U32_S32_RR:
  953. return NVPTX::TEX_2D_U32_S32_IR;
  954. case NVPTX::TEX_2D_U32_S32_RI:
  955. return NVPTX::TEX_2D_U32_S32_II;
  956. case NVPTX::TEX_2D_U32_F32_RR:
  957. return NVPTX::TEX_2D_U32_F32_IR;
  958. case NVPTX::TEX_2D_U32_F32_RI:
  959. return NVPTX::TEX_2D_U32_F32_II;
  960. case NVPTX::TEX_2D_U32_F32_LEVEL_RR:
  961. return NVPTX::TEX_2D_U32_F32_LEVEL_IR;
  962. case NVPTX::TEX_2D_U32_F32_LEVEL_RI:
  963. return NVPTX::TEX_2D_U32_F32_LEVEL_II;
  964. case NVPTX::TEX_2D_U32_F32_GRAD_RR:
  965. return NVPTX::TEX_2D_U32_F32_GRAD_IR;
  966. case NVPTX::TEX_2D_U32_F32_GRAD_RI:
  967. return NVPTX::TEX_2D_U32_F32_GRAD_II;
  968. case NVPTX::TEX_2D_ARRAY_F32_S32_RR:
  969. return NVPTX::TEX_2D_ARRAY_F32_S32_IR;
  970. case NVPTX::TEX_2D_ARRAY_F32_S32_RI:
  971. return NVPTX::TEX_2D_ARRAY_F32_S32_II;
  972. case NVPTX::TEX_2D_ARRAY_F32_F32_RR:
  973. return NVPTX::TEX_2D_ARRAY_F32_F32_IR;
  974. case NVPTX::TEX_2D_ARRAY_F32_F32_RI:
  975. return NVPTX::TEX_2D_ARRAY_F32_F32_II;
  976. case NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_RR:
  977. return NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_IR;
  978. case NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_RI:
  979. return NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_II;
  980. case NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_RR:
  981. return NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_IR;
  982. case NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_RI:
  983. return NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_II;
  984. case NVPTX::TEX_2D_ARRAY_S32_S32_RR:
  985. return NVPTX::TEX_2D_ARRAY_S32_S32_IR;
  986. case NVPTX::TEX_2D_ARRAY_S32_S32_RI:
  987. return NVPTX::TEX_2D_ARRAY_S32_S32_II;
  988. case NVPTX::TEX_2D_ARRAY_S32_F32_RR:
  989. return NVPTX::TEX_2D_ARRAY_S32_F32_IR;
  990. case NVPTX::TEX_2D_ARRAY_S32_F32_RI:
  991. return NVPTX::TEX_2D_ARRAY_S32_F32_II;
  992. case NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_RR:
  993. return NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_IR;
  994. case NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_RI:
  995. return NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_II;
  996. case NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_RR:
  997. return NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_IR;
  998. case NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_RI:
  999. return NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_II;
  1000. case NVPTX::TEX_2D_ARRAY_U32_S32_RR:
  1001. return NVPTX::TEX_2D_ARRAY_U32_S32_IR;
  1002. case NVPTX::TEX_2D_ARRAY_U32_S32_RI:
  1003. return NVPTX::TEX_2D_ARRAY_U32_S32_II;
  1004. case NVPTX::TEX_2D_ARRAY_U32_F32_RR:
  1005. return NVPTX::TEX_2D_ARRAY_U32_F32_IR;
  1006. case NVPTX::TEX_2D_ARRAY_U32_F32_RI:
  1007. return NVPTX::TEX_2D_ARRAY_U32_F32_II;
  1008. case NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_RR:
  1009. return NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_IR;
  1010. case NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_RI:
  1011. return NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_II;
  1012. case NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_RR:
  1013. return NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_IR;
  1014. case NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_RI:
  1015. return NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_II;
  1016. case NVPTX::TEX_3D_F32_S32_RR:
  1017. return NVPTX::TEX_3D_F32_S32_IR;
  1018. case NVPTX::TEX_3D_F32_S32_RI:
  1019. return NVPTX::TEX_3D_F32_S32_II;
  1020. case NVPTX::TEX_3D_F32_F32_RR:
  1021. return NVPTX::TEX_3D_F32_F32_IR;
  1022. case NVPTX::TEX_3D_F32_F32_RI:
  1023. return NVPTX::TEX_3D_F32_F32_II;
  1024. case NVPTX::TEX_3D_F32_F32_LEVEL_RR:
  1025. return NVPTX::TEX_3D_F32_F32_LEVEL_IR;
  1026. case NVPTX::TEX_3D_F32_F32_LEVEL_RI:
  1027. return NVPTX::TEX_3D_F32_F32_LEVEL_II;
  1028. case NVPTX::TEX_3D_F32_F32_GRAD_RR:
  1029. return NVPTX::TEX_3D_F32_F32_GRAD_IR;
  1030. case NVPTX::TEX_3D_F32_F32_GRAD_RI:
  1031. return NVPTX::TEX_3D_F32_F32_GRAD_II;
  1032. case NVPTX::TEX_3D_S32_S32_RR:
  1033. return NVPTX::TEX_3D_S32_S32_IR;
  1034. case NVPTX::TEX_3D_S32_S32_RI:
  1035. return NVPTX::TEX_3D_S32_S32_II;
  1036. case NVPTX::TEX_3D_S32_F32_RR:
  1037. return NVPTX::TEX_3D_S32_F32_IR;
  1038. case NVPTX::TEX_3D_S32_F32_RI:
  1039. return NVPTX::TEX_3D_S32_F32_II;
  1040. case NVPTX::TEX_3D_S32_F32_LEVEL_RR:
  1041. return NVPTX::TEX_3D_S32_F32_LEVEL_IR;
  1042. case NVPTX::TEX_3D_S32_F32_LEVEL_RI:
  1043. return NVPTX::TEX_3D_S32_F32_LEVEL_II;
  1044. case NVPTX::TEX_3D_S32_F32_GRAD_RR:
  1045. return NVPTX::TEX_3D_S32_F32_GRAD_IR;
  1046. case NVPTX::TEX_3D_S32_F32_GRAD_RI:
  1047. return NVPTX::TEX_3D_S32_F32_GRAD_II;
  1048. case NVPTX::TEX_3D_U32_S32_RR:
  1049. return NVPTX::TEX_3D_U32_S32_IR;
  1050. case NVPTX::TEX_3D_U32_S32_RI:
  1051. return NVPTX::TEX_3D_U32_S32_II;
  1052. case NVPTX::TEX_3D_U32_F32_RR:
  1053. return NVPTX::TEX_3D_U32_F32_IR;
  1054. case NVPTX::TEX_3D_U32_F32_RI:
  1055. return NVPTX::TEX_3D_U32_F32_II;
  1056. case NVPTX::TEX_3D_U32_F32_LEVEL_RR:
  1057. return NVPTX::TEX_3D_U32_F32_LEVEL_IR;
  1058. case NVPTX::TEX_3D_U32_F32_LEVEL_RI:
  1059. return NVPTX::TEX_3D_U32_F32_LEVEL_II;
  1060. case NVPTX::TEX_3D_U32_F32_GRAD_RR:
  1061. return NVPTX::TEX_3D_U32_F32_GRAD_IR;
  1062. case NVPTX::TEX_3D_U32_F32_GRAD_RI:
  1063. return NVPTX::TEX_3D_U32_F32_GRAD_II;
  1064. case NVPTX::TEX_CUBE_F32_F32_RR:
  1065. return NVPTX::TEX_CUBE_F32_F32_IR;
  1066. case NVPTX::TEX_CUBE_F32_F32_RI:
  1067. return NVPTX::TEX_CUBE_F32_F32_II;
  1068. case NVPTX::TEX_CUBE_F32_F32_LEVEL_RR:
  1069. return NVPTX::TEX_CUBE_F32_F32_LEVEL_IR;
  1070. case NVPTX::TEX_CUBE_F32_F32_LEVEL_RI:
  1071. return NVPTX::TEX_CUBE_F32_F32_LEVEL_II;
  1072. case NVPTX::TEX_CUBE_S32_F32_RR:
  1073. return NVPTX::TEX_CUBE_S32_F32_IR;
  1074. case NVPTX::TEX_CUBE_S32_F32_RI:
  1075. return NVPTX::TEX_CUBE_S32_F32_II;
  1076. case NVPTX::TEX_CUBE_S32_F32_LEVEL_RR:
  1077. return NVPTX::TEX_CUBE_S32_F32_LEVEL_IR;
  1078. case NVPTX::TEX_CUBE_S32_F32_LEVEL_RI:
  1079. return NVPTX::TEX_CUBE_S32_F32_LEVEL_II;
  1080. case NVPTX::TEX_CUBE_U32_F32_RR:
  1081. return NVPTX::TEX_CUBE_U32_F32_IR;
  1082. case NVPTX::TEX_CUBE_U32_F32_RI:
  1083. return NVPTX::TEX_CUBE_U32_F32_II;
  1084. case NVPTX::TEX_CUBE_U32_F32_LEVEL_RR:
  1085. return NVPTX::TEX_CUBE_U32_F32_LEVEL_IR;
  1086. case NVPTX::TEX_CUBE_U32_F32_LEVEL_RI:
  1087. return NVPTX::TEX_CUBE_U32_F32_LEVEL_II;
  1088. case NVPTX::TEX_CUBE_ARRAY_F32_F32_RR:
  1089. return NVPTX::TEX_CUBE_ARRAY_F32_F32_IR;
  1090. case NVPTX::TEX_CUBE_ARRAY_F32_F32_RI:
  1091. return NVPTX::TEX_CUBE_ARRAY_F32_F32_II;
  1092. case NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_RR:
  1093. return NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_IR;
  1094. case NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_RI:
  1095. return NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_II;
  1096. case NVPTX::TEX_CUBE_ARRAY_S32_F32_RR:
  1097. return NVPTX::TEX_CUBE_ARRAY_S32_F32_IR;
  1098. case NVPTX::TEX_CUBE_ARRAY_S32_F32_RI:
  1099. return NVPTX::TEX_CUBE_ARRAY_S32_F32_II;
  1100. case NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_RR:
  1101. return NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_IR;
  1102. case NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_RI:
  1103. return NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_II;
  1104. case NVPTX::TEX_CUBE_ARRAY_U32_F32_RR:
  1105. return NVPTX::TEX_CUBE_ARRAY_U32_F32_IR;
  1106. case NVPTX::TEX_CUBE_ARRAY_U32_F32_RI:
  1107. return NVPTX::TEX_CUBE_ARRAY_U32_F32_II;
  1108. case NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_RR:
  1109. return NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_IR;
  1110. case NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_RI:
  1111. return NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_II;
  1112. case NVPTX::TLD4_R_2D_F32_F32_RR:
  1113. return NVPTX::TLD4_R_2D_F32_F32_IR;
  1114. case NVPTX::TLD4_R_2D_F32_F32_RI:
  1115. return NVPTX::TLD4_R_2D_F32_F32_II;
  1116. case NVPTX::TLD4_G_2D_F32_F32_RR:
  1117. return NVPTX::TLD4_G_2D_F32_F32_IR;
  1118. case NVPTX::TLD4_G_2D_F32_F32_RI:
  1119. return NVPTX::TLD4_G_2D_F32_F32_II;
  1120. case NVPTX::TLD4_B_2D_F32_F32_RR:
  1121. return NVPTX::TLD4_B_2D_F32_F32_IR;
  1122. case NVPTX::TLD4_B_2D_F32_F32_RI:
  1123. return NVPTX::TLD4_B_2D_F32_F32_II;
  1124. case NVPTX::TLD4_A_2D_F32_F32_RR:
  1125. return NVPTX::TLD4_A_2D_F32_F32_IR;
  1126. case NVPTX::TLD4_A_2D_F32_F32_RI:
  1127. return NVPTX::TLD4_A_2D_F32_F32_II;
  1128. case NVPTX::TLD4_R_2D_S32_F32_RR:
  1129. return NVPTX::TLD4_R_2D_S32_F32_IR;
  1130. case NVPTX::TLD4_R_2D_S32_F32_RI:
  1131. return NVPTX::TLD4_R_2D_S32_F32_II;
  1132. case NVPTX::TLD4_G_2D_S32_F32_RR:
  1133. return NVPTX::TLD4_G_2D_S32_F32_IR;
  1134. case NVPTX::TLD4_G_2D_S32_F32_RI:
  1135. return NVPTX::TLD4_G_2D_S32_F32_II;
  1136. case NVPTX::TLD4_B_2D_S32_F32_RR:
  1137. return NVPTX::TLD4_B_2D_S32_F32_IR;
  1138. case NVPTX::TLD4_B_2D_S32_F32_RI:
  1139. return NVPTX::TLD4_B_2D_S32_F32_II;
  1140. case NVPTX::TLD4_A_2D_S32_F32_RR:
  1141. return NVPTX::TLD4_A_2D_S32_F32_IR;
  1142. case NVPTX::TLD4_A_2D_S32_F32_RI:
  1143. return NVPTX::TLD4_A_2D_S32_F32_II;
  1144. case NVPTX::TLD4_R_2D_U32_F32_RR:
  1145. return NVPTX::TLD4_R_2D_U32_F32_IR;
  1146. case NVPTX::TLD4_R_2D_U32_F32_RI:
  1147. return NVPTX::TLD4_R_2D_U32_F32_II;
  1148. case NVPTX::TLD4_G_2D_U32_F32_RR:
  1149. return NVPTX::TLD4_G_2D_U32_F32_IR;
  1150. case NVPTX::TLD4_G_2D_U32_F32_RI:
  1151. return NVPTX::TLD4_G_2D_U32_F32_II;
  1152. case NVPTX::TLD4_B_2D_U32_F32_RR:
  1153. return NVPTX::TLD4_B_2D_U32_F32_IR;
  1154. case NVPTX::TLD4_B_2D_U32_F32_RI:
  1155. return NVPTX::TLD4_B_2D_U32_F32_II;
  1156. case NVPTX::TLD4_A_2D_U32_F32_RR:
  1157. return NVPTX::TLD4_A_2D_U32_F32_IR;
  1158. case NVPTX::TLD4_A_2D_U32_F32_RI:
  1159. return NVPTX::TLD4_A_2D_U32_F32_II;
  1160. case NVPTX::TEX_UNIFIED_1D_F32_S32_R:
  1161. return NVPTX::TEX_UNIFIED_1D_F32_S32_I;
  1162. case NVPTX::TEX_UNIFIED_1D_F32_F32_R:
  1163. return NVPTX::TEX_UNIFIED_1D_F32_F32_I;
  1164. case NVPTX::TEX_UNIFIED_1D_F32_F32_LEVEL_R:
  1165. return NVPTX::TEX_UNIFIED_1D_F32_F32_LEVEL_I;
  1166. case NVPTX::TEX_UNIFIED_1D_F32_F32_GRAD_R:
  1167. return NVPTX::TEX_UNIFIED_1D_F32_F32_GRAD_I;
  1168. case NVPTX::TEX_UNIFIED_1D_S32_S32_R:
  1169. return NVPTX::TEX_UNIFIED_1D_S32_S32_I;
  1170. case NVPTX::TEX_UNIFIED_1D_S32_F32_R:
  1171. return NVPTX::TEX_UNIFIED_1D_S32_F32_I;
  1172. case NVPTX::TEX_UNIFIED_1D_S32_F32_LEVEL_R:
  1173. return NVPTX::TEX_UNIFIED_1D_S32_F32_LEVEL_I;
  1174. case NVPTX::TEX_UNIFIED_1D_S32_F32_GRAD_R:
  1175. return NVPTX::TEX_UNIFIED_1D_S32_F32_GRAD_I;
  1176. case NVPTX::TEX_UNIFIED_1D_U32_S32_R:
  1177. return NVPTX::TEX_UNIFIED_1D_U32_S32_I;
  1178. case NVPTX::TEX_UNIFIED_1D_U32_F32_R:
  1179. return NVPTX::TEX_UNIFIED_1D_U32_F32_I;
  1180. case NVPTX::TEX_UNIFIED_1D_U32_F32_LEVEL_R:
  1181. return NVPTX::TEX_UNIFIED_1D_U32_F32_LEVEL_I;
  1182. case NVPTX::TEX_UNIFIED_1D_U32_F32_GRAD_R:
  1183. return NVPTX::TEX_UNIFIED_1D_U32_F32_GRAD_I;
  1184. case NVPTX::TEX_UNIFIED_1D_ARRAY_F32_S32_R:
  1185. return NVPTX::TEX_UNIFIED_1D_ARRAY_F32_S32_I;
  1186. case NVPTX::TEX_UNIFIED_1D_ARRAY_F32_F32_R:
  1187. return NVPTX::TEX_UNIFIED_1D_ARRAY_F32_F32_I;
  1188. case NVPTX::TEX_UNIFIED_1D_ARRAY_F32_F32_LEVEL_R:
  1189. return NVPTX::TEX_UNIFIED_1D_ARRAY_F32_F32_LEVEL_I;
  1190. case NVPTX::TEX_UNIFIED_1D_ARRAY_F32_F32_GRAD_R:
  1191. return NVPTX::TEX_UNIFIED_1D_ARRAY_F32_F32_GRAD_I;
  1192. case NVPTX::TEX_UNIFIED_1D_ARRAY_S32_S32_R:
  1193. return NVPTX::TEX_UNIFIED_1D_ARRAY_S32_S32_I;
  1194. case NVPTX::TEX_UNIFIED_1D_ARRAY_S32_F32_R:
  1195. return NVPTX::TEX_UNIFIED_1D_ARRAY_S32_F32_I;
  1196. case NVPTX::TEX_UNIFIED_1D_ARRAY_S32_F32_LEVEL_R:
  1197. return NVPTX::TEX_UNIFIED_1D_ARRAY_S32_F32_LEVEL_I;
  1198. case NVPTX::TEX_UNIFIED_1D_ARRAY_S32_F32_GRAD_R:
  1199. return NVPTX::TEX_UNIFIED_1D_ARRAY_S32_F32_GRAD_I;
  1200. case NVPTX::TEX_UNIFIED_1D_ARRAY_U32_S32_R:
  1201. return NVPTX::TEX_UNIFIED_1D_ARRAY_U32_S32_I;
  1202. case NVPTX::TEX_UNIFIED_1D_ARRAY_U32_F32_R:
  1203. return NVPTX::TEX_UNIFIED_1D_ARRAY_U32_F32_I;
  1204. case NVPTX::TEX_UNIFIED_1D_ARRAY_U32_F32_LEVEL_R:
  1205. return NVPTX::TEX_UNIFIED_1D_ARRAY_U32_F32_LEVEL_I;
  1206. case NVPTX::TEX_UNIFIED_1D_ARRAY_U32_F32_GRAD_R:
  1207. return NVPTX::TEX_UNIFIED_1D_ARRAY_U32_F32_GRAD_I;
  1208. case NVPTX::TEX_UNIFIED_2D_F32_S32_R:
  1209. return NVPTX::TEX_UNIFIED_2D_F32_S32_I;
  1210. case NVPTX::TEX_UNIFIED_2D_F32_F32_R:
  1211. return NVPTX::TEX_UNIFIED_2D_F32_F32_I;
  1212. case NVPTX::TEX_UNIFIED_2D_F32_F32_LEVEL_R:
  1213. return NVPTX::TEX_UNIFIED_2D_F32_F32_LEVEL_I;
  1214. case NVPTX::TEX_UNIFIED_2D_F32_F32_GRAD_R:
  1215. return NVPTX::TEX_UNIFIED_2D_F32_F32_GRAD_I;
  1216. case NVPTX::TEX_UNIFIED_2D_S32_S32_R:
  1217. return NVPTX::TEX_UNIFIED_2D_S32_S32_I;
  1218. case NVPTX::TEX_UNIFIED_2D_S32_F32_R:
  1219. return NVPTX::TEX_UNIFIED_2D_S32_F32_I;
  1220. case NVPTX::TEX_UNIFIED_2D_S32_F32_LEVEL_R:
  1221. return NVPTX::TEX_UNIFIED_2D_S32_F32_LEVEL_I;
  1222. case NVPTX::TEX_UNIFIED_2D_S32_F32_GRAD_R:
  1223. return NVPTX::TEX_UNIFIED_2D_S32_F32_GRAD_I;
  1224. case NVPTX::TEX_UNIFIED_2D_U32_S32_R:
  1225. return NVPTX::TEX_UNIFIED_2D_U32_S32_I;
  1226. case NVPTX::TEX_UNIFIED_2D_U32_F32_R:
  1227. return NVPTX::TEX_UNIFIED_2D_U32_F32_I;
  1228. case NVPTX::TEX_UNIFIED_2D_U32_F32_LEVEL_R:
  1229. return NVPTX::TEX_UNIFIED_2D_U32_F32_LEVEL_I;
  1230. case NVPTX::TEX_UNIFIED_2D_U32_F32_GRAD_R:
  1231. return NVPTX::TEX_UNIFIED_2D_U32_F32_GRAD_I;
  1232. case NVPTX::TEX_UNIFIED_2D_ARRAY_F32_S32_R:
  1233. return NVPTX::TEX_UNIFIED_2D_ARRAY_F32_S32_I;
  1234. case NVPTX::TEX_UNIFIED_2D_ARRAY_F32_F32_R:
  1235. return NVPTX::TEX_UNIFIED_2D_ARRAY_F32_F32_I;
  1236. case NVPTX::TEX_UNIFIED_2D_ARRAY_F32_F32_LEVEL_R:
  1237. return NVPTX::TEX_UNIFIED_2D_ARRAY_F32_F32_LEVEL_I;
  1238. case NVPTX::TEX_UNIFIED_2D_ARRAY_F32_F32_GRAD_R:
  1239. return NVPTX::TEX_UNIFIED_2D_ARRAY_F32_F32_GRAD_I;
  1240. case NVPTX::TEX_UNIFIED_2D_ARRAY_S32_S32_R:
  1241. return NVPTX::TEX_UNIFIED_2D_ARRAY_S32_S32_I;
  1242. case NVPTX::TEX_UNIFIED_2D_ARRAY_S32_F32_R:
  1243. return NVPTX::TEX_UNIFIED_2D_ARRAY_S32_F32_I;
  1244. case NVPTX::TEX_UNIFIED_2D_ARRAY_S32_F32_LEVEL_R:
  1245. return NVPTX::TEX_UNIFIED_2D_ARRAY_S32_F32_LEVEL_I;
  1246. case NVPTX::TEX_UNIFIED_2D_ARRAY_S32_F32_GRAD_R:
  1247. return NVPTX::TEX_UNIFIED_2D_ARRAY_S32_F32_GRAD_I;
  1248. case NVPTX::TEX_UNIFIED_2D_ARRAY_U32_S32_R:
  1249. return NVPTX::TEX_UNIFIED_2D_ARRAY_U32_S32_I;
  1250. case NVPTX::TEX_UNIFIED_2D_ARRAY_U32_F32_R:
  1251. return NVPTX::TEX_UNIFIED_2D_ARRAY_U32_F32_I;
  1252. case NVPTX::TEX_UNIFIED_2D_ARRAY_U32_F32_LEVEL_R:
  1253. return NVPTX::TEX_UNIFIED_2D_ARRAY_U32_F32_LEVEL_I;
  1254. case NVPTX::TEX_UNIFIED_2D_ARRAY_U32_F32_GRAD_R:
  1255. return NVPTX::TEX_UNIFIED_2D_ARRAY_U32_F32_GRAD_I;
  1256. case NVPTX::TEX_UNIFIED_3D_F32_S32_R:
  1257. return NVPTX::TEX_UNIFIED_3D_F32_S32_I;
  1258. case NVPTX::TEX_UNIFIED_3D_F32_F32_R:
  1259. return NVPTX::TEX_UNIFIED_3D_F32_F32_I;
  1260. case NVPTX::TEX_UNIFIED_3D_F32_F32_LEVEL_R:
  1261. return NVPTX::TEX_UNIFIED_3D_F32_F32_LEVEL_I;
  1262. case NVPTX::TEX_UNIFIED_3D_F32_F32_GRAD_R:
  1263. return NVPTX::TEX_UNIFIED_3D_F32_F32_GRAD_I;
  1264. case NVPTX::TEX_UNIFIED_3D_S32_S32_R:
  1265. return NVPTX::TEX_UNIFIED_3D_S32_S32_I;
  1266. case NVPTX::TEX_UNIFIED_3D_S32_F32_R:
  1267. return NVPTX::TEX_UNIFIED_3D_S32_F32_I;
  1268. case NVPTX::TEX_UNIFIED_3D_S32_F32_LEVEL_R:
  1269. return NVPTX::TEX_UNIFIED_3D_S32_F32_LEVEL_I;
  1270. case NVPTX::TEX_UNIFIED_3D_S32_F32_GRAD_R:
  1271. return NVPTX::TEX_UNIFIED_3D_S32_F32_GRAD_I;
  1272. case NVPTX::TEX_UNIFIED_3D_U32_S32_R:
  1273. return NVPTX::TEX_UNIFIED_3D_U32_S32_I;
  1274. case NVPTX::TEX_UNIFIED_3D_U32_F32_R:
  1275. return NVPTX::TEX_UNIFIED_3D_U32_F32_I;
  1276. case NVPTX::TEX_UNIFIED_3D_U32_F32_LEVEL_R:
  1277. return NVPTX::TEX_UNIFIED_3D_U32_F32_LEVEL_I;
  1278. case NVPTX::TEX_UNIFIED_3D_U32_F32_GRAD_R:
  1279. return NVPTX::TEX_UNIFIED_3D_U32_F32_GRAD_I;
  1280. case NVPTX::TEX_UNIFIED_CUBE_F32_F32_R:
  1281. return NVPTX::TEX_UNIFIED_CUBE_F32_F32_I;
  1282. case NVPTX::TEX_UNIFIED_CUBE_F32_F32_LEVEL_R:
  1283. return NVPTX::TEX_UNIFIED_CUBE_F32_F32_LEVEL_I;
  1284. case NVPTX::TEX_UNIFIED_CUBE_S32_F32_R:
  1285. return NVPTX::TEX_UNIFIED_CUBE_S32_F32_I;
  1286. case NVPTX::TEX_UNIFIED_CUBE_S32_F32_LEVEL_R:
  1287. return NVPTX::TEX_UNIFIED_CUBE_S32_F32_LEVEL_I;
  1288. case NVPTX::TEX_UNIFIED_CUBE_U32_F32_R:
  1289. return NVPTX::TEX_UNIFIED_CUBE_U32_F32_I;
  1290. case NVPTX::TEX_UNIFIED_CUBE_U32_F32_LEVEL_R:
  1291. return NVPTX::TEX_UNIFIED_CUBE_U32_F32_LEVEL_I;
  1292. case NVPTX::TEX_UNIFIED_CUBE_ARRAY_F32_F32_R:
  1293. return NVPTX::TEX_UNIFIED_CUBE_ARRAY_F32_F32_I;
  1294. case NVPTX::TEX_UNIFIED_CUBE_ARRAY_F32_F32_LEVEL_R:
  1295. return NVPTX::TEX_UNIFIED_CUBE_ARRAY_F32_F32_LEVEL_I;
  1296. case NVPTX::TEX_UNIFIED_CUBE_ARRAY_S32_F32_R:
  1297. return NVPTX::TEX_UNIFIED_CUBE_ARRAY_S32_F32_I;
  1298. case NVPTX::TEX_UNIFIED_CUBE_ARRAY_S32_F32_LEVEL_R:
  1299. return NVPTX::TEX_UNIFIED_CUBE_ARRAY_S32_F32_LEVEL_I;
  1300. case NVPTX::TEX_UNIFIED_CUBE_ARRAY_U32_F32_R:
  1301. return NVPTX::TEX_UNIFIED_CUBE_ARRAY_U32_F32_I;
  1302. case NVPTX::TEX_UNIFIED_CUBE_ARRAY_U32_F32_LEVEL_R:
  1303. return NVPTX::TEX_UNIFIED_CUBE_ARRAY_U32_F32_LEVEL_I;
  1304. case NVPTX::TLD4_UNIFIED_R_2D_F32_F32_R:
  1305. return NVPTX::TLD4_UNIFIED_R_2D_F32_F32_I;
  1306. case NVPTX::TLD4_UNIFIED_G_2D_F32_F32_R:
  1307. return NVPTX::TLD4_UNIFIED_G_2D_F32_F32_I;
  1308. case NVPTX::TLD4_UNIFIED_B_2D_F32_F32_R:
  1309. return NVPTX::TLD4_UNIFIED_B_2D_F32_F32_I;
  1310. case NVPTX::TLD4_UNIFIED_A_2D_F32_F32_R:
  1311. return NVPTX::TLD4_UNIFIED_A_2D_F32_F32_I;
  1312. case NVPTX::TLD4_UNIFIED_R_2D_S32_F32_R:
  1313. return NVPTX::TLD4_UNIFIED_R_2D_S32_F32_I;
  1314. case NVPTX::TLD4_UNIFIED_G_2D_S32_F32_R:
  1315. return NVPTX::TLD4_UNIFIED_G_2D_S32_F32_I;
  1316. case NVPTX::TLD4_UNIFIED_B_2D_S32_F32_R:
  1317. return NVPTX::TLD4_UNIFIED_B_2D_S32_F32_I;
  1318. case NVPTX::TLD4_UNIFIED_A_2D_S32_F32_R:
  1319. return NVPTX::TLD4_UNIFIED_A_2D_S32_F32_I;
  1320. case NVPTX::TLD4_UNIFIED_R_2D_U32_F32_R:
  1321. return NVPTX::TLD4_UNIFIED_R_2D_U32_F32_I;
  1322. case NVPTX::TLD4_UNIFIED_G_2D_U32_F32_R:
  1323. return NVPTX::TLD4_UNIFIED_G_2D_U32_F32_I;
  1324. case NVPTX::TLD4_UNIFIED_B_2D_U32_F32_R:
  1325. return NVPTX::TLD4_UNIFIED_B_2D_U32_F32_I;
  1326. case NVPTX::TLD4_UNIFIED_A_2D_U32_F32_R:
  1327. return NVPTX::TLD4_UNIFIED_A_2D_U32_F32_I;
  1328. default:
  1329. llvm_unreachable("Unhandled TEX opcode");
  1330. };
  1331. }
  1332. static unsigned samplerRegisterToIndexOpcode(unsigned RegOC) {
  1333. switch (RegOC) {
  1334. case NVPTX::TEX_1D_F32_S32_RR:
  1335. return NVPTX::TEX_1D_F32_S32_RI;
  1336. case NVPTX::TEX_1D_F32_S32_IR:
  1337. return NVPTX::TEX_1D_F32_S32_II;
  1338. case NVPTX::TEX_1D_F32_F32_RR:
  1339. return NVPTX::TEX_1D_F32_F32_RI;
  1340. case NVPTX::TEX_1D_F32_F32_IR:
  1341. return NVPTX::TEX_1D_F32_F32_II;
  1342. case NVPTX::TEX_1D_F32_F32_LEVEL_RR:
  1343. return NVPTX::TEX_1D_F32_F32_LEVEL_RI;
  1344. case NVPTX::TEX_1D_F32_F32_LEVEL_IR:
  1345. return NVPTX::TEX_1D_F32_F32_LEVEL_II;
  1346. case NVPTX::TEX_1D_F32_F32_GRAD_RR:
  1347. return NVPTX::TEX_1D_F32_F32_GRAD_RI;
  1348. case NVPTX::TEX_1D_F32_F32_GRAD_IR:
  1349. return NVPTX::TEX_1D_F32_F32_GRAD_II;
  1350. case NVPTX::TEX_1D_S32_S32_RR:
  1351. return NVPTX::TEX_1D_S32_S32_RI;
  1352. case NVPTX::TEX_1D_S32_S32_IR:
  1353. return NVPTX::TEX_1D_S32_S32_II;
  1354. case NVPTX::TEX_1D_S32_F32_RR:
  1355. return NVPTX::TEX_1D_S32_F32_RI;
  1356. case NVPTX::TEX_1D_S32_F32_IR:
  1357. return NVPTX::TEX_1D_S32_F32_II;
  1358. case NVPTX::TEX_1D_S32_F32_LEVEL_RR:
  1359. return NVPTX::TEX_1D_S32_F32_LEVEL_RI;
  1360. case NVPTX::TEX_1D_S32_F32_LEVEL_IR:
  1361. return NVPTX::TEX_1D_S32_F32_LEVEL_II;
  1362. case NVPTX::TEX_1D_S32_F32_GRAD_RR:
  1363. return NVPTX::TEX_1D_S32_F32_GRAD_RI;
  1364. case NVPTX::TEX_1D_S32_F32_GRAD_IR:
  1365. return NVPTX::TEX_1D_S32_F32_GRAD_II;
  1366. case NVPTX::TEX_1D_U32_S32_RR:
  1367. return NVPTX::TEX_1D_U32_S32_RI;
  1368. case NVPTX::TEX_1D_U32_S32_IR:
  1369. return NVPTX::TEX_1D_U32_S32_II;
  1370. case NVPTX::TEX_1D_U32_F32_RR:
  1371. return NVPTX::TEX_1D_U32_F32_RI;
  1372. case NVPTX::TEX_1D_U32_F32_IR:
  1373. return NVPTX::TEX_1D_U32_F32_II;
  1374. case NVPTX::TEX_1D_U32_F32_LEVEL_RR:
  1375. return NVPTX::TEX_1D_U32_F32_LEVEL_RI;
  1376. case NVPTX::TEX_1D_U32_F32_LEVEL_IR:
  1377. return NVPTX::TEX_1D_U32_F32_LEVEL_II;
  1378. case NVPTX::TEX_1D_U32_F32_GRAD_RR:
  1379. return NVPTX::TEX_1D_U32_F32_GRAD_RI;
  1380. case NVPTX::TEX_1D_U32_F32_GRAD_IR:
  1381. return NVPTX::TEX_1D_U32_F32_GRAD_II;
  1382. case NVPTX::TEX_1D_ARRAY_F32_S32_RR:
  1383. return NVPTX::TEX_1D_ARRAY_F32_S32_RI;
  1384. case NVPTX::TEX_1D_ARRAY_F32_S32_IR:
  1385. return NVPTX::TEX_1D_ARRAY_F32_S32_II;
  1386. case NVPTX::TEX_1D_ARRAY_F32_F32_RR:
  1387. return NVPTX::TEX_1D_ARRAY_F32_F32_RI;
  1388. case NVPTX::TEX_1D_ARRAY_F32_F32_IR:
  1389. return NVPTX::TEX_1D_ARRAY_F32_F32_II;
  1390. case NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_RR:
  1391. return NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_RI;
  1392. case NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_IR:
  1393. return NVPTX::TEX_1D_ARRAY_F32_F32_LEVEL_II;
  1394. case NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_RR:
  1395. return NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_RI;
  1396. case NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_IR:
  1397. return NVPTX::TEX_1D_ARRAY_F32_F32_GRAD_II;
  1398. case NVPTX::TEX_1D_ARRAY_S32_S32_RR:
  1399. return NVPTX::TEX_1D_ARRAY_S32_S32_RI;
  1400. case NVPTX::TEX_1D_ARRAY_S32_S32_IR:
  1401. return NVPTX::TEX_1D_ARRAY_S32_S32_II;
  1402. case NVPTX::TEX_1D_ARRAY_S32_F32_RR:
  1403. return NVPTX::TEX_1D_ARRAY_S32_F32_RI;
  1404. case NVPTX::TEX_1D_ARRAY_S32_F32_IR:
  1405. return NVPTX::TEX_1D_ARRAY_S32_F32_II;
  1406. case NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_RR:
  1407. return NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_RI;
  1408. case NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_IR:
  1409. return NVPTX::TEX_1D_ARRAY_S32_F32_LEVEL_II;
  1410. case NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_RR:
  1411. return NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_RI;
  1412. case NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_IR:
  1413. return NVPTX::TEX_1D_ARRAY_S32_F32_GRAD_II;
  1414. case NVPTX::TEX_1D_ARRAY_U32_S32_RR:
  1415. return NVPTX::TEX_1D_ARRAY_U32_S32_RI;
  1416. case NVPTX::TEX_1D_ARRAY_U32_S32_IR:
  1417. return NVPTX::TEX_1D_ARRAY_U32_S32_II;
  1418. case NVPTX::TEX_1D_ARRAY_U32_F32_RR:
  1419. return NVPTX::TEX_1D_ARRAY_U32_F32_RI;
  1420. case NVPTX::TEX_1D_ARRAY_U32_F32_IR:
  1421. return NVPTX::TEX_1D_ARRAY_U32_F32_II;
  1422. case NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_RR:
  1423. return NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_RI;
  1424. case NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_IR:
  1425. return NVPTX::TEX_1D_ARRAY_U32_F32_LEVEL_II;
  1426. case NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_RR:
  1427. return NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_RI;
  1428. case NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_IR:
  1429. return NVPTX::TEX_1D_ARRAY_U32_F32_GRAD_II;
  1430. case NVPTX::TEX_2D_F32_S32_RR:
  1431. return NVPTX::TEX_2D_F32_S32_RI;
  1432. case NVPTX::TEX_2D_F32_S32_IR:
  1433. return NVPTX::TEX_2D_F32_S32_II;
  1434. case NVPTX::TEX_2D_F32_F32_RR:
  1435. return NVPTX::TEX_2D_F32_F32_RI;
  1436. case NVPTX::TEX_2D_F32_F32_IR:
  1437. return NVPTX::TEX_2D_F32_F32_II;
  1438. case NVPTX::TEX_2D_F32_F32_LEVEL_RR:
  1439. return NVPTX::TEX_2D_F32_F32_LEVEL_RI;
  1440. case NVPTX::TEX_2D_F32_F32_LEVEL_IR:
  1441. return NVPTX::TEX_2D_F32_F32_LEVEL_II;
  1442. case NVPTX::TEX_2D_F32_F32_GRAD_RR:
  1443. return NVPTX::TEX_2D_F32_F32_GRAD_RI;
  1444. case NVPTX::TEX_2D_F32_F32_GRAD_IR:
  1445. return NVPTX::TEX_2D_F32_F32_GRAD_II;
  1446. case NVPTX::TEX_2D_S32_S32_RR:
  1447. return NVPTX::TEX_2D_S32_S32_RI;
  1448. case NVPTX::TEX_2D_S32_S32_IR:
  1449. return NVPTX::TEX_2D_S32_S32_II;
  1450. case NVPTX::TEX_2D_S32_F32_RR:
  1451. return NVPTX::TEX_2D_S32_F32_RI;
  1452. case NVPTX::TEX_2D_S32_F32_IR:
  1453. return NVPTX::TEX_2D_S32_F32_II;
  1454. case NVPTX::TEX_2D_S32_F32_LEVEL_RR:
  1455. return NVPTX::TEX_2D_S32_F32_LEVEL_RI;
  1456. case NVPTX::TEX_2D_S32_F32_LEVEL_IR:
  1457. return NVPTX::TEX_2D_S32_F32_LEVEL_II;
  1458. case NVPTX::TEX_2D_S32_F32_GRAD_RR:
  1459. return NVPTX::TEX_2D_S32_F32_GRAD_RI;
  1460. case NVPTX::TEX_2D_S32_F32_GRAD_IR:
  1461. return NVPTX::TEX_2D_S32_F32_GRAD_II;
  1462. case NVPTX::TEX_2D_U32_S32_RR:
  1463. return NVPTX::TEX_2D_U32_S32_RI;
  1464. case NVPTX::TEX_2D_U32_S32_IR:
  1465. return NVPTX::TEX_2D_U32_S32_II;
  1466. case NVPTX::TEX_2D_U32_F32_RR:
  1467. return NVPTX::TEX_2D_U32_F32_RI;
  1468. case NVPTX::TEX_2D_U32_F32_IR:
  1469. return NVPTX::TEX_2D_U32_F32_II;
  1470. case NVPTX::TEX_2D_U32_F32_LEVEL_RR:
  1471. return NVPTX::TEX_2D_U32_F32_LEVEL_RI;
  1472. case NVPTX::TEX_2D_U32_F32_LEVEL_IR:
  1473. return NVPTX::TEX_2D_U32_F32_LEVEL_II;
  1474. case NVPTX::TEX_2D_U32_F32_GRAD_RR:
  1475. return NVPTX::TEX_2D_U32_F32_GRAD_RI;
  1476. case NVPTX::TEX_2D_U32_F32_GRAD_IR:
  1477. return NVPTX::TEX_2D_U32_F32_GRAD_II;
  1478. case NVPTX::TEX_2D_ARRAY_F32_S32_RR:
  1479. return NVPTX::TEX_2D_ARRAY_F32_S32_RI;
  1480. case NVPTX::TEX_2D_ARRAY_F32_S32_IR:
  1481. return NVPTX::TEX_2D_ARRAY_F32_S32_II;
  1482. case NVPTX::TEX_2D_ARRAY_F32_F32_RR:
  1483. return NVPTX::TEX_2D_ARRAY_F32_F32_RI;
  1484. case NVPTX::TEX_2D_ARRAY_F32_F32_IR:
  1485. return NVPTX::TEX_2D_ARRAY_F32_F32_II;
  1486. case NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_RR:
  1487. return NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_RI;
  1488. case NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_IR:
  1489. return NVPTX::TEX_2D_ARRAY_F32_F32_LEVEL_II;
  1490. case NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_RR:
  1491. return NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_RI;
  1492. case NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_IR:
  1493. return NVPTX::TEX_2D_ARRAY_F32_F32_GRAD_II;
  1494. case NVPTX::TEX_2D_ARRAY_S32_S32_RR:
  1495. return NVPTX::TEX_2D_ARRAY_S32_S32_RI;
  1496. case NVPTX::TEX_2D_ARRAY_S32_S32_IR:
  1497. return NVPTX::TEX_2D_ARRAY_S32_S32_II;
  1498. case NVPTX::TEX_2D_ARRAY_S32_F32_RR:
  1499. return NVPTX::TEX_2D_ARRAY_S32_F32_RI;
  1500. case NVPTX::TEX_2D_ARRAY_S32_F32_IR:
  1501. return NVPTX::TEX_2D_ARRAY_S32_F32_II;
  1502. case NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_RR:
  1503. return NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_RI;
  1504. case NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_IR:
  1505. return NVPTX::TEX_2D_ARRAY_S32_F32_LEVEL_II;
  1506. case NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_RR:
  1507. return NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_RI;
  1508. case NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_IR:
  1509. return NVPTX::TEX_2D_ARRAY_S32_F32_GRAD_II;
  1510. case NVPTX::TEX_2D_ARRAY_U32_S32_RR:
  1511. return NVPTX::TEX_2D_ARRAY_U32_S32_RI;
  1512. case NVPTX::TEX_2D_ARRAY_U32_S32_IR:
  1513. return NVPTX::TEX_2D_ARRAY_U32_S32_II;
  1514. case NVPTX::TEX_2D_ARRAY_U32_F32_RR:
  1515. return NVPTX::TEX_2D_ARRAY_U32_F32_RI;
  1516. case NVPTX::TEX_2D_ARRAY_U32_F32_IR:
  1517. return NVPTX::TEX_2D_ARRAY_U32_F32_II;
  1518. case NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_RR:
  1519. return NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_RI;
  1520. case NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_IR:
  1521. return NVPTX::TEX_2D_ARRAY_U32_F32_LEVEL_II;
  1522. case NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_RR:
  1523. return NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_RI;
  1524. case NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_IR:
  1525. return NVPTX::TEX_2D_ARRAY_U32_F32_GRAD_II;
  1526. case NVPTX::TEX_3D_F32_S32_RR:
  1527. return NVPTX::TEX_3D_F32_S32_RI;
  1528. case NVPTX::TEX_3D_F32_S32_IR:
  1529. return NVPTX::TEX_3D_F32_S32_II;
  1530. case NVPTX::TEX_3D_F32_F32_RR:
  1531. return NVPTX::TEX_3D_F32_F32_RI;
  1532. case NVPTX::TEX_3D_F32_F32_IR:
  1533. return NVPTX::TEX_3D_F32_F32_II;
  1534. case NVPTX::TEX_3D_F32_F32_LEVEL_RR:
  1535. return NVPTX::TEX_3D_F32_F32_LEVEL_RI;
  1536. case NVPTX::TEX_3D_F32_F32_LEVEL_IR:
  1537. return NVPTX::TEX_3D_F32_F32_LEVEL_II;
  1538. case NVPTX::TEX_3D_F32_F32_GRAD_RR:
  1539. return NVPTX::TEX_3D_F32_F32_GRAD_RI;
  1540. case NVPTX::TEX_3D_F32_F32_GRAD_IR:
  1541. return NVPTX::TEX_3D_F32_F32_GRAD_II;
  1542. case NVPTX::TEX_3D_S32_S32_RR:
  1543. return NVPTX::TEX_3D_S32_S32_RI;
  1544. case NVPTX::TEX_3D_S32_S32_IR:
  1545. return NVPTX::TEX_3D_S32_S32_II;
  1546. case NVPTX::TEX_3D_S32_F32_RR:
  1547. return NVPTX::TEX_3D_S32_F32_RI;
  1548. case NVPTX::TEX_3D_S32_F32_IR:
  1549. return NVPTX::TEX_3D_S32_F32_II;
  1550. case NVPTX::TEX_3D_S32_F32_LEVEL_RR:
  1551. return NVPTX::TEX_3D_S32_F32_LEVEL_RI;
  1552. case NVPTX::TEX_3D_S32_F32_LEVEL_IR:
  1553. return NVPTX::TEX_3D_S32_F32_LEVEL_II;
  1554. case NVPTX::TEX_3D_S32_F32_GRAD_RR:
  1555. return NVPTX::TEX_3D_S32_F32_GRAD_RI;
  1556. case NVPTX::TEX_3D_S32_F32_GRAD_IR:
  1557. return NVPTX::TEX_3D_S32_F32_GRAD_II;
  1558. case NVPTX::TEX_3D_U32_S32_RR:
  1559. return NVPTX::TEX_3D_U32_S32_RI;
  1560. case NVPTX::TEX_3D_U32_S32_IR:
  1561. return NVPTX::TEX_3D_U32_S32_II;
  1562. case NVPTX::TEX_3D_U32_F32_RR:
  1563. return NVPTX::TEX_3D_U32_F32_RI;
  1564. case NVPTX::TEX_3D_U32_F32_IR:
  1565. return NVPTX::TEX_3D_U32_F32_II;
  1566. case NVPTX::TEX_3D_U32_F32_LEVEL_RR:
  1567. return NVPTX::TEX_3D_U32_F32_LEVEL_RI;
  1568. case NVPTX::TEX_3D_U32_F32_LEVEL_IR:
  1569. return NVPTX::TEX_3D_U32_F32_LEVEL_II;
  1570. case NVPTX::TEX_3D_U32_F32_GRAD_RR:
  1571. return NVPTX::TEX_3D_U32_F32_GRAD_RI;
  1572. case NVPTX::TEX_3D_U32_F32_GRAD_IR:
  1573. return NVPTX::TEX_3D_U32_F32_GRAD_II;
  1574. case NVPTX::TEX_CUBE_F32_F32_RR:
  1575. return NVPTX::TEX_CUBE_F32_F32_RI;
  1576. case NVPTX::TEX_CUBE_F32_F32_IR:
  1577. return NVPTX::TEX_CUBE_F32_F32_II;
  1578. case NVPTX::TEX_CUBE_F32_F32_LEVEL_RR:
  1579. return NVPTX::TEX_CUBE_F32_F32_LEVEL_RI;
  1580. case NVPTX::TEX_CUBE_F32_F32_LEVEL_IR:
  1581. return NVPTX::TEX_CUBE_F32_F32_LEVEL_II;
  1582. case NVPTX::TEX_CUBE_S32_F32_RR:
  1583. return NVPTX::TEX_CUBE_S32_F32_RI;
  1584. case NVPTX::TEX_CUBE_S32_F32_IR:
  1585. return NVPTX::TEX_CUBE_S32_F32_II;
  1586. case NVPTX::TEX_CUBE_S32_F32_LEVEL_RR:
  1587. return NVPTX::TEX_CUBE_S32_F32_LEVEL_RI;
  1588. case NVPTX::TEX_CUBE_S32_F32_LEVEL_IR:
  1589. return NVPTX::TEX_CUBE_S32_F32_LEVEL_II;
  1590. case NVPTX::TEX_CUBE_U32_F32_RR:
  1591. return NVPTX::TEX_CUBE_U32_F32_RI;
  1592. case NVPTX::TEX_CUBE_U32_F32_IR:
  1593. return NVPTX::TEX_CUBE_U32_F32_II;
  1594. case NVPTX::TEX_CUBE_U32_F32_LEVEL_RR:
  1595. return NVPTX::TEX_CUBE_U32_F32_LEVEL_RI;
  1596. case NVPTX::TEX_CUBE_U32_F32_LEVEL_IR:
  1597. return NVPTX::TEX_CUBE_U32_F32_LEVEL_II;
  1598. case NVPTX::TEX_CUBE_ARRAY_F32_F32_RR:
  1599. return NVPTX::TEX_CUBE_ARRAY_F32_F32_RI;
  1600. case NVPTX::TEX_CUBE_ARRAY_F32_F32_IR:
  1601. return NVPTX::TEX_CUBE_ARRAY_F32_F32_II;
  1602. case NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_RR:
  1603. return NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_RI;
  1604. case NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_IR:
  1605. return NVPTX::TEX_CUBE_ARRAY_F32_F32_LEVEL_II;
  1606. case NVPTX::TEX_CUBE_ARRAY_S32_F32_RR:
  1607. return NVPTX::TEX_CUBE_ARRAY_S32_F32_RI;
  1608. case NVPTX::TEX_CUBE_ARRAY_S32_F32_IR:
  1609. return NVPTX::TEX_CUBE_ARRAY_S32_F32_II;
  1610. case NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_RR:
  1611. return NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_RI;
  1612. case NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_IR:
  1613. return NVPTX::TEX_CUBE_ARRAY_S32_F32_LEVEL_II;
  1614. case NVPTX::TEX_CUBE_ARRAY_U32_F32_RR:
  1615. return NVPTX::TEX_CUBE_ARRAY_U32_F32_RI;
  1616. case NVPTX::TEX_CUBE_ARRAY_U32_F32_IR:
  1617. return NVPTX::TEX_CUBE_ARRAY_U32_F32_II;
  1618. case NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_RR:
  1619. return NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_RI;
  1620. case NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_IR:
  1621. return NVPTX::TEX_CUBE_ARRAY_U32_F32_LEVEL_II;
  1622. case NVPTX::TLD4_R_2D_F32_F32_RR:
  1623. return NVPTX::TLD4_R_2D_F32_F32_RI;
  1624. case NVPTX::TLD4_R_2D_F32_F32_IR:
  1625. return NVPTX::TLD4_R_2D_F32_F32_II;
  1626. case NVPTX::TLD4_G_2D_F32_F32_RR:
  1627. return NVPTX::TLD4_G_2D_F32_F32_RI;
  1628. case NVPTX::TLD4_G_2D_F32_F32_IR:
  1629. return NVPTX::TLD4_G_2D_F32_F32_II;
  1630. case NVPTX::TLD4_B_2D_F32_F32_RR:
  1631. return NVPTX::TLD4_B_2D_F32_F32_RI;
  1632. case NVPTX::TLD4_B_2D_F32_F32_IR:
  1633. return NVPTX::TLD4_B_2D_F32_F32_II;
  1634. case NVPTX::TLD4_A_2D_F32_F32_RR:
  1635. return NVPTX::TLD4_A_2D_F32_F32_RI;
  1636. case NVPTX::TLD4_A_2D_F32_F32_IR:
  1637. return NVPTX::TLD4_A_2D_F32_F32_II;
  1638. case NVPTX::TLD4_R_2D_S32_F32_RR:
  1639. return NVPTX::TLD4_R_2D_S32_F32_RI;
  1640. case NVPTX::TLD4_R_2D_S32_F32_IR:
  1641. return NVPTX::TLD4_R_2D_S32_F32_II;
  1642. case NVPTX::TLD4_G_2D_S32_F32_RR:
  1643. return NVPTX::TLD4_G_2D_S32_F32_RI;
  1644. case NVPTX::TLD4_G_2D_S32_F32_IR:
  1645. return NVPTX::TLD4_G_2D_S32_F32_II;
  1646. case NVPTX::TLD4_B_2D_S32_F32_RR:
  1647. return NVPTX::TLD4_B_2D_S32_F32_RI;
  1648. case NVPTX::TLD4_B_2D_S32_F32_IR:
  1649. return NVPTX::TLD4_B_2D_S32_F32_II;
  1650. case NVPTX::TLD4_A_2D_S32_F32_RR:
  1651. return NVPTX::TLD4_A_2D_S32_F32_RI;
  1652. case NVPTX::TLD4_A_2D_S32_F32_IR:
  1653. return NVPTX::TLD4_A_2D_S32_F32_II;
  1654. case NVPTX::TLD4_R_2D_U32_F32_RR:
  1655. return NVPTX::TLD4_R_2D_U32_F32_RI;
  1656. case NVPTX::TLD4_R_2D_U32_F32_IR:
  1657. return NVPTX::TLD4_R_2D_U32_F32_II;
  1658. case NVPTX::TLD4_G_2D_U32_F32_RR:
  1659. return NVPTX::TLD4_G_2D_U32_F32_RI;
  1660. case NVPTX::TLD4_G_2D_U32_F32_IR:
  1661. return NVPTX::TLD4_G_2D_U32_F32_II;
  1662. case NVPTX::TLD4_B_2D_U32_F32_RR:
  1663. return NVPTX::TLD4_B_2D_U32_F32_RI;
  1664. case NVPTX::TLD4_B_2D_U32_F32_IR:
  1665. return NVPTX::TLD4_B_2D_U32_F32_II;
  1666. case NVPTX::TLD4_A_2D_U32_F32_RR:
  1667. return NVPTX::TLD4_A_2D_U32_F32_RI;
  1668. case NVPTX::TLD4_A_2D_U32_F32_IR:
  1669. return NVPTX::TLD4_A_2D_U32_F32_II;
  1670. default:
  1671. llvm_unreachable("Unhandled TEX opcode");
  1672. };
  1673. }
  1674. static unsigned queryRegisterToIndexOpcode(unsigned RegOC) {
  1675. switch (RegOC) {
  1676. case NVPTX::TXQ_CHANNEL_ORDER_R:
  1677. return NVPTX::TXQ_CHANNEL_ORDER_I;
  1678. case NVPTX::TXQ_CHANNEL_DATA_TYPE_R:
  1679. return NVPTX::TXQ_CHANNEL_DATA_TYPE_I;
  1680. case NVPTX::TXQ_WIDTH_R:
  1681. return NVPTX::TXQ_WIDTH_I;
  1682. case NVPTX::TXQ_HEIGHT_R:
  1683. return NVPTX::TXQ_HEIGHT_I;
  1684. case NVPTX::TXQ_DEPTH_R:
  1685. return NVPTX::TXQ_DEPTH_I;
  1686. case NVPTX::TXQ_ARRAY_SIZE_R:
  1687. return NVPTX::TXQ_ARRAY_SIZE_I;
  1688. case NVPTX::TXQ_NUM_SAMPLES_R:
  1689. return NVPTX::TXQ_NUM_SAMPLES_I;
  1690. case NVPTX::TXQ_NUM_MIPMAP_LEVELS_R:
  1691. return NVPTX::TXQ_NUM_MIPMAP_LEVELS_I;
  1692. case NVPTX::SUQ_CHANNEL_ORDER_R:
  1693. return NVPTX::SUQ_CHANNEL_ORDER_I;
  1694. case NVPTX::SUQ_CHANNEL_DATA_TYPE_R:
  1695. return NVPTX::SUQ_CHANNEL_DATA_TYPE_I;
  1696. case NVPTX::SUQ_WIDTH_R:
  1697. return NVPTX::SUQ_WIDTH_I;
  1698. case NVPTX::SUQ_HEIGHT_R:
  1699. return NVPTX::SUQ_HEIGHT_I;
  1700. case NVPTX::SUQ_DEPTH_R:
  1701. return NVPTX::SUQ_DEPTH_I;
  1702. case NVPTX::SUQ_ARRAY_SIZE_R:
  1703. return NVPTX::SUQ_ARRAY_SIZE_I;
  1704. default:
  1705. llvm_unreachable("Unhandled TXQ/SUQ opcode");
  1706. };
  1707. }
  1708. bool NVPTXReplaceImageHandles::processInstr(MachineInstr &MI) {
  1709. MachineFunction &MF = *MI.getParent()->getParent();
  1710. const MCInstrDesc &MCID = MI.getDesc();
  1711. const NVPTXInstrInfo *TII = MF.getSubtarget<NVPTXSubtarget>().getInstrInfo();
  1712. if (MCID.TSFlags & NVPTXII::IsTexFlag) {
  1713. // This is a texture fetch, so operand 4 is a texref and operand 5 is
  1714. // a samplerref
  1715. MachineOperand &TexHandle = MI.getOperand(4);
  1716. if (replaceImageHandle(TexHandle, MF))
  1717. MI.setDesc(TII->get(texRegisterToIndexOpcode(MI.getOpcode())));
  1718. if (!(MCID.TSFlags & NVPTXII::IsTexModeUnifiedFlag)) {
  1719. MachineOperand &SampHandle = MI.getOperand(5);
  1720. if (replaceImageHandle(SampHandle, MF))
  1721. MI.setDesc(TII->get(samplerRegisterToIndexOpcode(MI.getOpcode())));
  1722. }
  1723. return true;
  1724. } else if (MCID.TSFlags & NVPTXII::IsSuldMask) {
  1725. unsigned VecSize =
  1726. 1 << (((MCID.TSFlags & NVPTXII::IsSuldMask) >> NVPTXII::IsSuldShift) - 1);
  1727. // For a surface load of vector size N, the Nth operand will be the surfref
  1728. MachineOperand &SurfHandle = MI.getOperand(VecSize);
  1729. if (replaceImageHandle(SurfHandle, MF))
  1730. MI.setDesc(TII->get(suldRegisterToIndexOpcode(MI.getOpcode())));
  1731. return true;
  1732. } else if (MCID.TSFlags & NVPTXII::IsSustFlag) {
  1733. // This is a surface store, so operand 0 is a surfref
  1734. MachineOperand &SurfHandle = MI.getOperand(0);
  1735. if (replaceImageHandle(SurfHandle, MF))
  1736. MI.setDesc(TII->get(sustRegisterToIndexOpcode(MI.getOpcode())));
  1737. return true;
  1738. } else if (MCID.TSFlags & NVPTXII::IsSurfTexQueryFlag) {
  1739. // This is a query, so operand 1 is a surfref/texref
  1740. MachineOperand &Handle = MI.getOperand(1);
  1741. if (replaceImageHandle(Handle, MF))
  1742. MI.setDesc(TII->get(queryRegisterToIndexOpcode(MI.getOpcode())));
  1743. return true;
  1744. }
  1745. return false;
  1746. }
  1747. bool NVPTXReplaceImageHandles::replaceImageHandle(MachineOperand &Op,
  1748. MachineFunction &MF) {
  1749. unsigned Idx;
  1750. if (findIndexForHandle(Op, MF, Idx)) {
  1751. Op.ChangeToImmediate(Idx);
  1752. return true;
  1753. }
  1754. return false;
  1755. }
  1756. bool NVPTXReplaceImageHandles::
  1757. findIndexForHandle(MachineOperand &Op, MachineFunction &MF, unsigned &Idx) {
  1758. const MachineRegisterInfo &MRI = MF.getRegInfo();
  1759. NVPTXMachineFunctionInfo *MFI = MF.getInfo<NVPTXMachineFunctionInfo>();
  1760. assert(Op.isReg() && "Handle is not in a reg?");
  1761. // Which instruction defines the handle?
  1762. MachineInstr &TexHandleDef = *MRI.getVRegDef(Op.getReg());
  1763. switch (TexHandleDef.getOpcode()) {
  1764. case NVPTX::LD_i64_avar: {
  1765. // The handle is a parameter value being loaded, replace with the
  1766. // parameter symbol
  1767. const NVPTXTargetMachine &TM =
  1768. static_cast<const NVPTXTargetMachine &>(MF.getTarget());
  1769. if (TM.getDrvInterface() == NVPTX::CUDA) {
  1770. // For CUDA, we preserve the param loads coming from function arguments
  1771. return false;
  1772. }
  1773. assert(TexHandleDef.getOperand(6).isSymbol() && "Load is not a symbol!");
  1774. StringRef Sym = TexHandleDef.getOperand(6).getSymbolName();
  1775. std::string ParamBaseName = std::string(MF.getName());
  1776. ParamBaseName += "_param_";
  1777. assert(Sym.startswith(ParamBaseName) && "Invalid symbol reference");
  1778. unsigned Param = atoi(Sym.data()+ParamBaseName.size());
  1779. std::string NewSym;
  1780. raw_string_ostream NewSymStr(NewSym);
  1781. NewSymStr << MF.getName() << "_param_" << Param;
  1782. InstrsToRemove.insert(&TexHandleDef);
  1783. Idx = MFI->getImageHandleSymbolIndex(NewSymStr.str().c_str());
  1784. return true;
  1785. }
  1786. case NVPTX::texsurf_handles: {
  1787. // The handle is a global variable, replace with the global variable name
  1788. assert(TexHandleDef.getOperand(1).isGlobal() && "Load is not a global!");
  1789. const GlobalValue *GV = TexHandleDef.getOperand(1).getGlobal();
  1790. assert(GV->hasName() && "Global sampler must be named!");
  1791. InstrsToRemove.insert(&TexHandleDef);
  1792. Idx = MFI->getImageHandleSymbolIndex(GV->getName().data());
  1793. return true;
  1794. }
  1795. case NVPTX::nvvm_move_i64:
  1796. case TargetOpcode::COPY: {
  1797. bool Res = findIndexForHandle(TexHandleDef.getOperand(1), MF, Idx);
  1798. if (Res) {
  1799. InstrsToRemove.insert(&TexHandleDef);
  1800. }
  1801. return Res;
  1802. }
  1803. default:
  1804. llvm_unreachable("Unknown instruction operating on handle");
  1805. }
  1806. }
  1807. MachineFunctionPass *llvm::createNVPTXReplaceImageHandlesPass() {
  1808. return new NVPTXReplaceImageHandles();
  1809. }