tilegx.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313
  1. /* TILE-Gx opcode information.
  2. *
  3. * Copyright (C) 2011-2015 Free Software Foundation, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  18. * MA 02110-1301, USA.
  19. */
  20. #ifndef opcode_tile_h
  21. #define opcode_tile_h
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. typedef unsigned long long tilegx_bundle_bits;
  26. enum
  27. {
  28. TILEGX_MAX_OPERANDS = 4 /* bfexts */
  29. };
  30. typedef enum
  31. {
  32. TILEGX_OPC_BPT,
  33. TILEGX_OPC_INFO,
  34. TILEGX_OPC_INFOL,
  35. TILEGX_OPC_LD4S_TLS,
  36. TILEGX_OPC_LD_TLS,
  37. TILEGX_OPC_MOVE,
  38. TILEGX_OPC_MOVEI,
  39. TILEGX_OPC_MOVELI,
  40. TILEGX_OPC_PREFETCH,
  41. TILEGX_OPC_PREFETCH_ADD_L1,
  42. TILEGX_OPC_PREFETCH_ADD_L1_FAULT,
  43. TILEGX_OPC_PREFETCH_ADD_L2,
  44. TILEGX_OPC_PREFETCH_ADD_L2_FAULT,
  45. TILEGX_OPC_PREFETCH_ADD_L3,
  46. TILEGX_OPC_PREFETCH_ADD_L3_FAULT,
  47. TILEGX_OPC_PREFETCH_L1,
  48. TILEGX_OPC_PREFETCH_L1_FAULT,
  49. TILEGX_OPC_PREFETCH_L2,
  50. TILEGX_OPC_PREFETCH_L2_FAULT,
  51. TILEGX_OPC_PREFETCH_L3,
  52. TILEGX_OPC_PREFETCH_L3_FAULT,
  53. TILEGX_OPC_RAISE,
  54. TILEGX_OPC_ADD,
  55. TILEGX_OPC_ADDI,
  56. TILEGX_OPC_ADDLI,
  57. TILEGX_OPC_ADDX,
  58. TILEGX_OPC_ADDXI,
  59. TILEGX_OPC_ADDXLI,
  60. TILEGX_OPC_ADDXSC,
  61. TILEGX_OPC_AND,
  62. TILEGX_OPC_ANDI,
  63. TILEGX_OPC_BEQZ,
  64. TILEGX_OPC_BEQZT,
  65. TILEGX_OPC_BFEXTS,
  66. TILEGX_OPC_BFEXTU,
  67. TILEGX_OPC_BFINS,
  68. TILEGX_OPC_BGEZ,
  69. TILEGX_OPC_BGEZT,
  70. TILEGX_OPC_BGTZ,
  71. TILEGX_OPC_BGTZT,
  72. TILEGX_OPC_BLBC,
  73. TILEGX_OPC_BLBCT,
  74. TILEGX_OPC_BLBS,
  75. TILEGX_OPC_BLBST,
  76. TILEGX_OPC_BLEZ,
  77. TILEGX_OPC_BLEZT,
  78. TILEGX_OPC_BLTZ,
  79. TILEGX_OPC_BLTZT,
  80. TILEGX_OPC_BNEZ,
  81. TILEGX_OPC_BNEZT,
  82. TILEGX_OPC_CLZ,
  83. TILEGX_OPC_CMOVEQZ,
  84. TILEGX_OPC_CMOVNEZ,
  85. TILEGX_OPC_CMPEQ,
  86. TILEGX_OPC_CMPEQI,
  87. TILEGX_OPC_CMPEXCH,
  88. TILEGX_OPC_CMPEXCH4,
  89. TILEGX_OPC_CMPLES,
  90. TILEGX_OPC_CMPLEU,
  91. TILEGX_OPC_CMPLTS,
  92. TILEGX_OPC_CMPLTSI,
  93. TILEGX_OPC_CMPLTU,
  94. TILEGX_OPC_CMPLTUI,
  95. TILEGX_OPC_CMPNE,
  96. TILEGX_OPC_CMUL,
  97. TILEGX_OPC_CMULA,
  98. TILEGX_OPC_CMULAF,
  99. TILEGX_OPC_CMULF,
  100. TILEGX_OPC_CMULFR,
  101. TILEGX_OPC_CMULH,
  102. TILEGX_OPC_CMULHR,
  103. TILEGX_OPC_CRC32_32,
  104. TILEGX_OPC_CRC32_8,
  105. TILEGX_OPC_CTZ,
  106. TILEGX_OPC_DBLALIGN,
  107. TILEGX_OPC_DBLALIGN2,
  108. TILEGX_OPC_DBLALIGN4,
  109. TILEGX_OPC_DBLALIGN6,
  110. TILEGX_OPC_DRAIN,
  111. TILEGX_OPC_DTLBPR,
  112. TILEGX_OPC_EXCH,
  113. TILEGX_OPC_EXCH4,
  114. TILEGX_OPC_FDOUBLE_ADD_FLAGS,
  115. TILEGX_OPC_FDOUBLE_ADDSUB,
  116. TILEGX_OPC_FDOUBLE_MUL_FLAGS,
  117. TILEGX_OPC_FDOUBLE_PACK1,
  118. TILEGX_OPC_FDOUBLE_PACK2,
  119. TILEGX_OPC_FDOUBLE_SUB_FLAGS,
  120. TILEGX_OPC_FDOUBLE_UNPACK_MAX,
  121. TILEGX_OPC_FDOUBLE_UNPACK_MIN,
  122. TILEGX_OPC_FETCHADD,
  123. TILEGX_OPC_FETCHADD4,
  124. TILEGX_OPC_FETCHADDGEZ,
  125. TILEGX_OPC_FETCHADDGEZ4,
  126. TILEGX_OPC_FETCHAND,
  127. TILEGX_OPC_FETCHAND4,
  128. TILEGX_OPC_FETCHOR,
  129. TILEGX_OPC_FETCHOR4,
  130. TILEGX_OPC_FINV,
  131. TILEGX_OPC_FLUSH,
  132. TILEGX_OPC_FLUSHWB,
  133. TILEGX_OPC_FNOP,
  134. TILEGX_OPC_FSINGLE_ADD1,
  135. TILEGX_OPC_FSINGLE_ADDSUB2,
  136. TILEGX_OPC_FSINGLE_MUL1,
  137. TILEGX_OPC_FSINGLE_MUL2,
  138. TILEGX_OPC_FSINGLE_PACK1,
  139. TILEGX_OPC_FSINGLE_PACK2,
  140. TILEGX_OPC_FSINGLE_SUB1,
  141. TILEGX_OPC_ICOH,
  142. TILEGX_OPC_ILL,
  143. TILEGX_OPC_INV,
  144. TILEGX_OPC_IRET,
  145. TILEGX_OPC_J,
  146. TILEGX_OPC_JAL,
  147. TILEGX_OPC_JALR,
  148. TILEGX_OPC_JALRP,
  149. TILEGX_OPC_JR,
  150. TILEGX_OPC_JRP,
  151. TILEGX_OPC_LD,
  152. TILEGX_OPC_LD1S,
  153. TILEGX_OPC_LD1S_ADD,
  154. TILEGX_OPC_LD1U,
  155. TILEGX_OPC_LD1U_ADD,
  156. TILEGX_OPC_LD2S,
  157. TILEGX_OPC_LD2S_ADD,
  158. TILEGX_OPC_LD2U,
  159. TILEGX_OPC_LD2U_ADD,
  160. TILEGX_OPC_LD4S,
  161. TILEGX_OPC_LD4S_ADD,
  162. TILEGX_OPC_LD4U,
  163. TILEGX_OPC_LD4U_ADD,
  164. TILEGX_OPC_LD_ADD,
  165. TILEGX_OPC_LDNA,
  166. TILEGX_OPC_LDNA_ADD,
  167. TILEGX_OPC_LDNT,
  168. TILEGX_OPC_LDNT1S,
  169. TILEGX_OPC_LDNT1S_ADD,
  170. TILEGX_OPC_LDNT1U,
  171. TILEGX_OPC_LDNT1U_ADD,
  172. TILEGX_OPC_LDNT2S,
  173. TILEGX_OPC_LDNT2S_ADD,
  174. TILEGX_OPC_LDNT2U,
  175. TILEGX_OPC_LDNT2U_ADD,
  176. TILEGX_OPC_LDNT4S,
  177. TILEGX_OPC_LDNT4S_ADD,
  178. TILEGX_OPC_LDNT4U,
  179. TILEGX_OPC_LDNT4U_ADD,
  180. TILEGX_OPC_LDNT_ADD,
  181. TILEGX_OPC_LNK,
  182. TILEGX_OPC_MF,
  183. TILEGX_OPC_MFSPR,
  184. TILEGX_OPC_MM,
  185. TILEGX_OPC_MNZ,
  186. TILEGX_OPC_MTSPR,
  187. TILEGX_OPC_MUL_HS_HS,
  188. TILEGX_OPC_MUL_HS_HU,
  189. TILEGX_OPC_MUL_HS_LS,
  190. TILEGX_OPC_MUL_HS_LU,
  191. TILEGX_OPC_MUL_HU_HU,
  192. TILEGX_OPC_MUL_HU_LS,
  193. TILEGX_OPC_MUL_HU_LU,
  194. TILEGX_OPC_MUL_LS_LS,
  195. TILEGX_OPC_MUL_LS_LU,
  196. TILEGX_OPC_MUL_LU_LU,
  197. TILEGX_OPC_MULA_HS_HS,
  198. TILEGX_OPC_MULA_HS_HU,
  199. TILEGX_OPC_MULA_HS_LS,
  200. TILEGX_OPC_MULA_HS_LU,
  201. TILEGX_OPC_MULA_HU_HU,
  202. TILEGX_OPC_MULA_HU_LS,
  203. TILEGX_OPC_MULA_HU_LU,
  204. TILEGX_OPC_MULA_LS_LS,
  205. TILEGX_OPC_MULA_LS_LU,
  206. TILEGX_OPC_MULA_LU_LU,
  207. TILEGX_OPC_MULAX,
  208. TILEGX_OPC_MULX,
  209. TILEGX_OPC_MZ,
  210. TILEGX_OPC_NAP,
  211. TILEGX_OPC_NOP,
  212. TILEGX_OPC_NOR,
  213. TILEGX_OPC_OR,
  214. TILEGX_OPC_ORI,
  215. TILEGX_OPC_PCNT,
  216. TILEGX_OPC_REVBITS,
  217. TILEGX_OPC_REVBYTES,
  218. TILEGX_OPC_ROTL,
  219. TILEGX_OPC_ROTLI,
  220. TILEGX_OPC_SHL,
  221. TILEGX_OPC_SHL16INSLI,
  222. TILEGX_OPC_SHL1ADD,
  223. TILEGX_OPC_SHL1ADDX,
  224. TILEGX_OPC_SHL2ADD,
  225. TILEGX_OPC_SHL2ADDX,
  226. TILEGX_OPC_SHL3ADD,
  227. TILEGX_OPC_SHL3ADDX,
  228. TILEGX_OPC_SHLI,
  229. TILEGX_OPC_SHLX,
  230. TILEGX_OPC_SHLXI,
  231. TILEGX_OPC_SHRS,
  232. TILEGX_OPC_SHRSI,
  233. TILEGX_OPC_SHRU,
  234. TILEGX_OPC_SHRUI,
  235. TILEGX_OPC_SHRUX,
  236. TILEGX_OPC_SHRUXI,
  237. TILEGX_OPC_SHUFFLEBYTES,
  238. TILEGX_OPC_ST,
  239. TILEGX_OPC_ST1,
  240. TILEGX_OPC_ST1_ADD,
  241. TILEGX_OPC_ST2,
  242. TILEGX_OPC_ST2_ADD,
  243. TILEGX_OPC_ST4,
  244. TILEGX_OPC_ST4_ADD,
  245. TILEGX_OPC_ST_ADD,
  246. TILEGX_OPC_STNT,
  247. TILEGX_OPC_STNT1,
  248. TILEGX_OPC_STNT1_ADD,
  249. TILEGX_OPC_STNT2,
  250. TILEGX_OPC_STNT2_ADD,
  251. TILEGX_OPC_STNT4,
  252. TILEGX_OPC_STNT4_ADD,
  253. TILEGX_OPC_STNT_ADD,
  254. TILEGX_OPC_SUB,
  255. TILEGX_OPC_SUBX,
  256. TILEGX_OPC_SUBXSC,
  257. TILEGX_OPC_SWINT0,
  258. TILEGX_OPC_SWINT1,
  259. TILEGX_OPC_SWINT2,
  260. TILEGX_OPC_SWINT3,
  261. TILEGX_OPC_TBLIDXB0,
  262. TILEGX_OPC_TBLIDXB1,
  263. TILEGX_OPC_TBLIDXB2,
  264. TILEGX_OPC_TBLIDXB3,
  265. TILEGX_OPC_V1ADD,
  266. TILEGX_OPC_V1ADDI,
  267. TILEGX_OPC_V1ADDUC,
  268. TILEGX_OPC_V1ADIFFU,
  269. TILEGX_OPC_V1AVGU,
  270. TILEGX_OPC_V1CMPEQ,
  271. TILEGX_OPC_V1CMPEQI,
  272. TILEGX_OPC_V1CMPLES,
  273. TILEGX_OPC_V1CMPLEU,
  274. TILEGX_OPC_V1CMPLTS,
  275. TILEGX_OPC_V1CMPLTSI,
  276. TILEGX_OPC_V1CMPLTU,
  277. TILEGX_OPC_V1CMPLTUI,
  278. TILEGX_OPC_V1CMPNE,
  279. TILEGX_OPC_V1DDOTPU,
  280. TILEGX_OPC_V1DDOTPUA,
  281. TILEGX_OPC_V1DDOTPUS,
  282. TILEGX_OPC_V1DDOTPUSA,
  283. TILEGX_OPC_V1DOTP,
  284. TILEGX_OPC_V1DOTPA,
  285. TILEGX_OPC_V1DOTPU,
  286. TILEGX_OPC_V1DOTPUA,
  287. TILEGX_OPC_V1DOTPUS,
  288. TILEGX_OPC_V1DOTPUSA,
  289. TILEGX_OPC_V1INT_H,
  290. TILEGX_OPC_V1INT_L,
  291. TILEGX_OPC_V1MAXU,
  292. TILEGX_OPC_V1MAXUI,
  293. TILEGX_OPC_V1MINU,
  294. TILEGX_OPC_V1MINUI,
  295. TILEGX_OPC_V1MNZ,
  296. TILEGX_OPC_V1MULTU,
  297. TILEGX_OPC_V1MULU,
  298. TILEGX_OPC_V1MULUS,
  299. TILEGX_OPC_V1MZ,
  300. TILEGX_OPC_V1SADAU,
  301. TILEGX_OPC_V1SADU,
  302. TILEGX_OPC_V1SHL,
  303. TILEGX_OPC_V1SHLI,
  304. TILEGX_OPC_V1SHRS,
  305. TILEGX_OPC_V1SHRSI,
  306. TILEGX_OPC_V1SHRU,
  307. TILEGX_OPC_V1SHRUI,
  308. TILEGX_OPC_V1SUB,
  309. TILEGX_OPC_V1SUBUC,
  310. TILEGX_OPC_V2ADD,
  311. TILEGX_OPC_V2ADDI,
  312. TILEGX_OPC_V2ADDSC,
  313. TILEGX_OPC_V2ADIFFS,
  314. TILEGX_OPC_V2AVGS,
  315. TILEGX_OPC_V2CMPEQ,
  316. TILEGX_OPC_V2CMPEQI,
  317. TILEGX_OPC_V2CMPLES,
  318. TILEGX_OPC_V2CMPLEU,
  319. TILEGX_OPC_V2CMPLTS,
  320. TILEGX_OPC_V2CMPLTSI,
  321. TILEGX_OPC_V2CMPLTU,
  322. TILEGX_OPC_V2CMPLTUI,
  323. TILEGX_OPC_V2CMPNE,
  324. TILEGX_OPC_V2DOTP,
  325. TILEGX_OPC_V2DOTPA,
  326. TILEGX_OPC_V2INT_H,
  327. TILEGX_OPC_V2INT_L,
  328. TILEGX_OPC_V2MAXS,
  329. TILEGX_OPC_V2MAXSI,
  330. TILEGX_OPC_V2MINS,
  331. TILEGX_OPC_V2MINSI,
  332. TILEGX_OPC_V2MNZ,
  333. TILEGX_OPC_V2MULFSC,
  334. TILEGX_OPC_V2MULS,
  335. TILEGX_OPC_V2MULTS,
  336. TILEGX_OPC_V2MZ,
  337. TILEGX_OPC_V2PACKH,
  338. TILEGX_OPC_V2PACKL,
  339. TILEGX_OPC_V2PACKUC,
  340. TILEGX_OPC_V2SADAS,
  341. TILEGX_OPC_V2SADAU,
  342. TILEGX_OPC_V2SADS,
  343. TILEGX_OPC_V2SADU,
  344. TILEGX_OPC_V2SHL,
  345. TILEGX_OPC_V2SHLI,
  346. TILEGX_OPC_V2SHLSC,
  347. TILEGX_OPC_V2SHRS,
  348. TILEGX_OPC_V2SHRSI,
  349. TILEGX_OPC_V2SHRU,
  350. TILEGX_OPC_V2SHRUI,
  351. TILEGX_OPC_V2SUB,
  352. TILEGX_OPC_V2SUBSC,
  353. TILEGX_OPC_V4ADD,
  354. TILEGX_OPC_V4ADDSC,
  355. TILEGX_OPC_V4INT_H,
  356. TILEGX_OPC_V4INT_L,
  357. TILEGX_OPC_V4PACKSC,
  358. TILEGX_OPC_V4SHL,
  359. TILEGX_OPC_V4SHLSC,
  360. TILEGX_OPC_V4SHRS,
  361. TILEGX_OPC_V4SHRU,
  362. TILEGX_OPC_V4SUB,
  363. TILEGX_OPC_V4SUBSC,
  364. TILEGX_OPC_WH64,
  365. TILEGX_OPC_XOR,
  366. TILEGX_OPC_XORI,
  367. TILEGX_OPC_NONE
  368. } tilegx_mnemonic;
  369. /* 64-bit pattern for a { bpt ; nop } bundle. */
  370. #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
  371. static __inline unsigned int
  372. get_BFEnd_X0(tilegx_bundle_bits num)
  373. {
  374. const unsigned int n = (unsigned int)num;
  375. return (((n >> 12)) & 0x3f);
  376. }
  377. static __inline unsigned int
  378. get_BFOpcodeExtension_X0(tilegx_bundle_bits num)
  379. {
  380. const unsigned int n = (unsigned int)num;
  381. return (((n >> 24)) & 0xf);
  382. }
  383. static __inline unsigned int
  384. get_BFStart_X0(tilegx_bundle_bits num)
  385. {
  386. const unsigned int n = (unsigned int)num;
  387. return (((n >> 18)) & 0x3f);
  388. }
  389. static __inline unsigned int
  390. get_BrOff_X1(tilegx_bundle_bits n)
  391. {
  392. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  393. (((unsigned int)(n >> 37)) & 0x0001ffc0);
  394. }
  395. static __inline unsigned int
  396. get_BrType_X1(tilegx_bundle_bits n)
  397. {
  398. return (((unsigned int)(n >> 54)) & 0x1f);
  399. }
  400. static __inline unsigned int
  401. get_Dest_Imm8_X1(tilegx_bundle_bits n)
  402. {
  403. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  404. (((unsigned int)(n >> 43)) & 0x000000c0);
  405. }
  406. static __inline unsigned int
  407. get_Dest_X0(tilegx_bundle_bits num)
  408. {
  409. const unsigned int n = (unsigned int)num;
  410. return (((n >> 0)) & 0x3f);
  411. }
  412. static __inline unsigned int
  413. get_Dest_X1(tilegx_bundle_bits n)
  414. {
  415. return (((unsigned int)(n >> 31)) & 0x3f);
  416. }
  417. static __inline unsigned int
  418. get_Dest_Y0(tilegx_bundle_bits num)
  419. {
  420. const unsigned int n = (unsigned int)num;
  421. return (((n >> 0)) & 0x3f);
  422. }
  423. static __inline unsigned int
  424. get_Dest_Y1(tilegx_bundle_bits n)
  425. {
  426. return (((unsigned int)(n >> 31)) & 0x3f);
  427. }
  428. static __inline unsigned int
  429. get_Imm16_X0(tilegx_bundle_bits num)
  430. {
  431. const unsigned int n = (unsigned int)num;
  432. return (((n >> 12)) & 0xffff);
  433. }
  434. static __inline unsigned int
  435. get_Imm16_X1(tilegx_bundle_bits n)
  436. {
  437. return (((unsigned int)(n >> 43)) & 0xffff);
  438. }
  439. static __inline unsigned int
  440. get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num)
  441. {
  442. const unsigned int n = (unsigned int)num;
  443. return (((n >> 20)) & 0xff);
  444. }
  445. static __inline unsigned int
  446. get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n)
  447. {
  448. return (((unsigned int)(n >> 51)) & 0xff);
  449. }
  450. static __inline unsigned int
  451. get_Imm8_X0(tilegx_bundle_bits num)
  452. {
  453. const unsigned int n = (unsigned int)num;
  454. return (((n >> 12)) & 0xff);
  455. }
  456. static __inline unsigned int
  457. get_Imm8_X1(tilegx_bundle_bits n)
  458. {
  459. return (((unsigned int)(n >> 43)) & 0xff);
  460. }
  461. static __inline unsigned int
  462. get_Imm8_Y0(tilegx_bundle_bits num)
  463. {
  464. const unsigned int n = (unsigned int)num;
  465. return (((n >> 12)) & 0xff);
  466. }
  467. static __inline unsigned int
  468. get_Imm8_Y1(tilegx_bundle_bits n)
  469. {
  470. return (((unsigned int)(n >> 43)) & 0xff);
  471. }
  472. static __inline unsigned int
  473. get_JumpOff_X1(tilegx_bundle_bits n)
  474. {
  475. return (((unsigned int)(n >> 31)) & 0x7ffffff);
  476. }
  477. static __inline unsigned int
  478. get_JumpOpcodeExtension_X1(tilegx_bundle_bits n)
  479. {
  480. return (((unsigned int)(n >> 58)) & 0x1);
  481. }
  482. static __inline unsigned int
  483. get_MF_Imm14_X1(tilegx_bundle_bits n)
  484. {
  485. return (((unsigned int)(n >> 37)) & 0x3fff);
  486. }
  487. static __inline unsigned int
  488. get_MT_Imm14_X1(tilegx_bundle_bits n)
  489. {
  490. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  491. (((unsigned int)(n >> 37)) & 0x00003fc0);
  492. }
  493. static __inline unsigned int
  494. get_Mode(tilegx_bundle_bits n)
  495. {
  496. return (((unsigned int)(n >> 62)) & 0x3);
  497. }
  498. static __inline unsigned int
  499. get_Opcode_X0(tilegx_bundle_bits num)
  500. {
  501. const unsigned int n = (unsigned int)num;
  502. return (((n >> 28)) & 0x7);
  503. }
  504. static __inline unsigned int
  505. get_Opcode_X1(tilegx_bundle_bits n)
  506. {
  507. return (((unsigned int)(n >> 59)) & 0x7);
  508. }
  509. static __inline unsigned int
  510. get_Opcode_Y0(tilegx_bundle_bits num)
  511. {
  512. const unsigned int n = (unsigned int)num;
  513. return (((n >> 27)) & 0xf);
  514. }
  515. static __inline unsigned int
  516. get_Opcode_Y1(tilegx_bundle_bits n)
  517. {
  518. return (((unsigned int)(n >> 58)) & 0xf);
  519. }
  520. static __inline unsigned int
  521. get_Opcode_Y2(tilegx_bundle_bits n)
  522. {
  523. return (((n >> 26)) & 0x00000001) |
  524. (((unsigned int)(n >> 56)) & 0x00000002);
  525. }
  526. static __inline unsigned int
  527. get_RRROpcodeExtension_X0(tilegx_bundle_bits num)
  528. {
  529. const unsigned int n = (unsigned int)num;
  530. return (((n >> 18)) & 0x3ff);
  531. }
  532. static __inline unsigned int
  533. get_RRROpcodeExtension_X1(tilegx_bundle_bits n)
  534. {
  535. return (((unsigned int)(n >> 49)) & 0x3ff);
  536. }
  537. static __inline unsigned int
  538. get_RRROpcodeExtension_Y0(tilegx_bundle_bits num)
  539. {
  540. const unsigned int n = (unsigned int)num;
  541. return (((n >> 18)) & 0x3);
  542. }
  543. static __inline unsigned int
  544. get_RRROpcodeExtension_Y1(tilegx_bundle_bits n)
  545. {
  546. return (((unsigned int)(n >> 49)) & 0x3);
  547. }
  548. static __inline unsigned int
  549. get_ShAmt_X0(tilegx_bundle_bits num)
  550. {
  551. const unsigned int n = (unsigned int)num;
  552. return (((n >> 12)) & 0x3f);
  553. }
  554. static __inline unsigned int
  555. get_ShAmt_X1(tilegx_bundle_bits n)
  556. {
  557. return (((unsigned int)(n >> 43)) & 0x3f);
  558. }
  559. static __inline unsigned int
  560. get_ShAmt_Y0(tilegx_bundle_bits num)
  561. {
  562. const unsigned int n = (unsigned int)num;
  563. return (((n >> 12)) & 0x3f);
  564. }
  565. static __inline unsigned int
  566. get_ShAmt_Y1(tilegx_bundle_bits n)
  567. {
  568. return (((unsigned int)(n >> 43)) & 0x3f);
  569. }
  570. static __inline unsigned int
  571. get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num)
  572. {
  573. const unsigned int n = (unsigned int)num;
  574. return (((n >> 18)) & 0x3ff);
  575. }
  576. static __inline unsigned int
  577. get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n)
  578. {
  579. return (((unsigned int)(n >> 49)) & 0x3ff);
  580. }
  581. static __inline unsigned int
  582. get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num)
  583. {
  584. const unsigned int n = (unsigned int)num;
  585. return (((n >> 18)) & 0x3);
  586. }
  587. static __inline unsigned int
  588. get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n)
  589. {
  590. return (((unsigned int)(n >> 49)) & 0x3);
  591. }
  592. static __inline unsigned int
  593. get_SrcA_X0(tilegx_bundle_bits num)
  594. {
  595. const unsigned int n = (unsigned int)num;
  596. return (((n >> 6)) & 0x3f);
  597. }
  598. static __inline unsigned int
  599. get_SrcA_X1(tilegx_bundle_bits n)
  600. {
  601. return (((unsigned int)(n >> 37)) & 0x3f);
  602. }
  603. static __inline unsigned int
  604. get_SrcA_Y0(tilegx_bundle_bits num)
  605. {
  606. const unsigned int n = (unsigned int)num;
  607. return (((n >> 6)) & 0x3f);
  608. }
  609. static __inline unsigned int
  610. get_SrcA_Y1(tilegx_bundle_bits n)
  611. {
  612. return (((unsigned int)(n >> 37)) & 0x3f);
  613. }
  614. static __inline unsigned int
  615. get_SrcA_Y2(tilegx_bundle_bits num)
  616. {
  617. const unsigned int n = (unsigned int)num;
  618. return (((n >> 20)) & 0x3f);
  619. }
  620. static __inline unsigned int
  621. get_SrcBDest_Y2(tilegx_bundle_bits n)
  622. {
  623. return (((unsigned int)(n >> 51)) & 0x3f);
  624. }
  625. static __inline unsigned int
  626. get_SrcB_X0(tilegx_bundle_bits num)
  627. {
  628. const unsigned int n = (unsigned int)num;
  629. return (((n >> 12)) & 0x3f);
  630. }
  631. static __inline unsigned int
  632. get_SrcB_X1(tilegx_bundle_bits n)
  633. {
  634. return (((unsigned int)(n >> 43)) & 0x3f);
  635. }
  636. static __inline unsigned int
  637. get_SrcB_Y0(tilegx_bundle_bits num)
  638. {
  639. const unsigned int n = (unsigned int)num;
  640. return (((n >> 12)) & 0x3f);
  641. }
  642. static __inline unsigned int
  643. get_SrcB_Y1(tilegx_bundle_bits n)
  644. {
  645. return (((unsigned int)(n >> 43)) & 0x3f);
  646. }
  647. static __inline unsigned int
  648. get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num)
  649. {
  650. const unsigned int n = (unsigned int)num;
  651. return (((n >> 12)) & 0x3f);
  652. }
  653. static __inline unsigned int
  654. get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n)
  655. {
  656. return (((unsigned int)(n >> 43)) & 0x3f);
  657. }
  658. static __inline unsigned int
  659. get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num)
  660. {
  661. const unsigned int n = (unsigned int)num;
  662. return (((n >> 12)) & 0x3f);
  663. }
  664. static __inline unsigned int
  665. get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n)
  666. {
  667. return (((unsigned int)(n >> 43)) & 0x3f);
  668. }
  669. static __inline int
  670. sign_extend(int n, int num_bits)
  671. {
  672. int shift = (int)(sizeof(int) * 8 - num_bits);
  673. return (n << shift) >> shift;
  674. }
  675. static __inline tilegx_bundle_bits
  676. create_BFEnd_X0(int num)
  677. {
  678. const unsigned int n = (unsigned int)num;
  679. return ((n & 0x3f) << 12);
  680. }
  681. static __inline tilegx_bundle_bits
  682. create_BFOpcodeExtension_X0(int num)
  683. {
  684. const unsigned int n = (unsigned int)num;
  685. return ((n & 0xf) << 24);
  686. }
  687. static __inline tilegx_bundle_bits
  688. create_BFStart_X0(int num)
  689. {
  690. const unsigned int n = (unsigned int)num;
  691. return ((n & 0x3f) << 18);
  692. }
  693. static __inline tilegx_bundle_bits
  694. create_BrOff_X1(int num)
  695. {
  696. const unsigned int n = (unsigned int)num;
  697. return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
  698. (((tilegx_bundle_bits)(n & 0x0001ffc0)) << 37);
  699. }
  700. static __inline tilegx_bundle_bits
  701. create_BrType_X1(int num)
  702. {
  703. const unsigned int n = (unsigned int)num;
  704. return (((tilegx_bundle_bits)(n & 0x1f)) << 54);
  705. }
  706. static __inline tilegx_bundle_bits
  707. create_Dest_Imm8_X1(int num)
  708. {
  709. const unsigned int n = (unsigned int)num;
  710. return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
  711. (((tilegx_bundle_bits)(n & 0x000000c0)) << 43);
  712. }
  713. static __inline tilegx_bundle_bits
  714. create_Dest_X0(int num)
  715. {
  716. const unsigned int n = (unsigned int)num;
  717. return ((n & 0x3f) << 0);
  718. }
  719. static __inline tilegx_bundle_bits
  720. create_Dest_X1(int num)
  721. {
  722. const unsigned int n = (unsigned int)num;
  723. return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
  724. }
  725. static __inline tilegx_bundle_bits
  726. create_Dest_Y0(int num)
  727. {
  728. const unsigned int n = (unsigned int)num;
  729. return ((n & 0x3f) << 0);
  730. }
  731. static __inline tilegx_bundle_bits
  732. create_Dest_Y1(int num)
  733. {
  734. const unsigned int n = (unsigned int)num;
  735. return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
  736. }
  737. static __inline tilegx_bundle_bits
  738. create_Imm16_X0(int num)
  739. {
  740. const unsigned int n = (unsigned int)num;
  741. return ((n & 0xffff) << 12);
  742. }
  743. static __inline tilegx_bundle_bits
  744. create_Imm16_X1(int num)
  745. {
  746. const unsigned int n = (unsigned int)num;
  747. return (((tilegx_bundle_bits)(n & 0xffff)) << 43);
  748. }
  749. static __inline tilegx_bundle_bits
  750. create_Imm8OpcodeExtension_X0(int num)
  751. {
  752. const unsigned int n = (unsigned int)num;
  753. return ((n & 0xff) << 20);
  754. }
  755. static __inline tilegx_bundle_bits
  756. create_Imm8OpcodeExtension_X1(int num)
  757. {
  758. const unsigned int n = (unsigned int)num;
  759. return (((tilegx_bundle_bits)(n & 0xff)) << 51);
  760. }
  761. static __inline tilegx_bundle_bits
  762. create_Imm8_X0(int num)
  763. {
  764. const unsigned int n = (unsigned int)num;
  765. return ((n & 0xff) << 12);
  766. }
  767. static __inline tilegx_bundle_bits
  768. create_Imm8_X1(int num)
  769. {
  770. const unsigned int n = (unsigned int)num;
  771. return (((tilegx_bundle_bits)(n & 0xff)) << 43);
  772. }
  773. static __inline tilegx_bundle_bits
  774. create_Imm8_Y0(int num)
  775. {
  776. const unsigned int n = (unsigned int)num;
  777. return ((n & 0xff) << 12);
  778. }
  779. static __inline tilegx_bundle_bits
  780. create_Imm8_Y1(int num)
  781. {
  782. const unsigned int n = (unsigned int)num;
  783. return (((tilegx_bundle_bits)(n & 0xff)) << 43);
  784. }
  785. static __inline tilegx_bundle_bits
  786. create_JumpOff_X1(int num)
  787. {
  788. const unsigned int n = (unsigned int)num;
  789. return (((tilegx_bundle_bits)(n & 0x7ffffff)) << 31);
  790. }
  791. static __inline tilegx_bundle_bits
  792. create_JumpOpcodeExtension_X1(int num)
  793. {
  794. const unsigned int n = (unsigned int)num;
  795. return (((tilegx_bundle_bits)(n & 0x1)) << 58);
  796. }
  797. static __inline tilegx_bundle_bits
  798. create_MF_Imm14_X1(int num)
  799. {
  800. const unsigned int n = (unsigned int)num;
  801. return (((tilegx_bundle_bits)(n & 0x3fff)) << 37);
  802. }
  803. static __inline tilegx_bundle_bits
  804. create_MT_Imm14_X1(int num)
  805. {
  806. const unsigned int n = (unsigned int)num;
  807. return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
  808. (((tilegx_bundle_bits)(n & 0x00003fc0)) << 37);
  809. }
  810. static __inline tilegx_bundle_bits
  811. create_Mode(int num)
  812. {
  813. const unsigned int n = (unsigned int)num;
  814. return (((tilegx_bundle_bits)(n & 0x3)) << 62);
  815. }
  816. static __inline tilegx_bundle_bits
  817. create_Opcode_X0(int num)
  818. {
  819. const unsigned int n = (unsigned int)num;
  820. return ((n & 0x7) << 28);
  821. }
  822. static __inline tilegx_bundle_bits
  823. create_Opcode_X1(int num)
  824. {
  825. const unsigned int n = (unsigned int)num;
  826. return (((tilegx_bundle_bits)(n & 0x7)) << 59);
  827. }
  828. static __inline tilegx_bundle_bits
  829. create_Opcode_Y0(int num)
  830. {
  831. const unsigned int n = (unsigned int)num;
  832. return ((n & 0xf) << 27);
  833. }
  834. static __inline tilegx_bundle_bits
  835. create_Opcode_Y1(int num)
  836. {
  837. const unsigned int n = (unsigned int)num;
  838. return (((tilegx_bundle_bits)(n & 0xf)) << 58);
  839. }
  840. static __inline tilegx_bundle_bits
  841. create_Opcode_Y2(int num)
  842. {
  843. const unsigned int n = (unsigned int)num;
  844. return ((n & 0x00000001) << 26) |
  845. (((tilegx_bundle_bits)(n & 0x00000002)) << 56);
  846. }
  847. static __inline tilegx_bundle_bits
  848. create_RRROpcodeExtension_X0(int num)
  849. {
  850. const unsigned int n = (unsigned int)num;
  851. return ((n & 0x3ff) << 18);
  852. }
  853. static __inline tilegx_bundle_bits
  854. create_RRROpcodeExtension_X1(int num)
  855. {
  856. const unsigned int n = (unsigned int)num;
  857. return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
  858. }
  859. static __inline tilegx_bundle_bits
  860. create_RRROpcodeExtension_Y0(int num)
  861. {
  862. const unsigned int n = (unsigned int)num;
  863. return ((n & 0x3) << 18);
  864. }
  865. static __inline tilegx_bundle_bits
  866. create_RRROpcodeExtension_Y1(int num)
  867. {
  868. const unsigned int n = (unsigned int)num;
  869. return (((tilegx_bundle_bits)(n & 0x3)) << 49);
  870. }
  871. static __inline tilegx_bundle_bits
  872. create_ShAmt_X0(int num)
  873. {
  874. const unsigned int n = (unsigned int)num;
  875. return ((n & 0x3f) << 12);
  876. }
  877. static __inline tilegx_bundle_bits
  878. create_ShAmt_X1(int num)
  879. {
  880. const unsigned int n = (unsigned int)num;
  881. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  882. }
  883. static __inline tilegx_bundle_bits
  884. create_ShAmt_Y0(int num)
  885. {
  886. const unsigned int n = (unsigned int)num;
  887. return ((n & 0x3f) << 12);
  888. }
  889. static __inline tilegx_bundle_bits
  890. create_ShAmt_Y1(int num)
  891. {
  892. const unsigned int n = (unsigned int)num;
  893. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  894. }
  895. static __inline tilegx_bundle_bits
  896. create_ShiftOpcodeExtension_X0(int num)
  897. {
  898. const unsigned int n = (unsigned int)num;
  899. return ((n & 0x3ff) << 18);
  900. }
  901. static __inline tilegx_bundle_bits
  902. create_ShiftOpcodeExtension_X1(int num)
  903. {
  904. const unsigned int n = (unsigned int)num;
  905. return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
  906. }
  907. static __inline tilegx_bundle_bits
  908. create_ShiftOpcodeExtension_Y0(int num)
  909. {
  910. const unsigned int n = (unsigned int)num;
  911. return ((n & 0x3) << 18);
  912. }
  913. static __inline tilegx_bundle_bits
  914. create_ShiftOpcodeExtension_Y1(int num)
  915. {
  916. const unsigned int n = (unsigned int)num;
  917. return (((tilegx_bundle_bits)(n & 0x3)) << 49);
  918. }
  919. static __inline tilegx_bundle_bits
  920. create_SrcA_X0(int num)
  921. {
  922. const unsigned int n = (unsigned int)num;
  923. return ((n & 0x3f) << 6);
  924. }
  925. static __inline tilegx_bundle_bits
  926. create_SrcA_X1(int num)
  927. {
  928. const unsigned int n = (unsigned int)num;
  929. return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
  930. }
  931. static __inline tilegx_bundle_bits
  932. create_SrcA_Y0(int num)
  933. {
  934. const unsigned int n = (unsigned int)num;
  935. return ((n & 0x3f) << 6);
  936. }
  937. static __inline tilegx_bundle_bits
  938. create_SrcA_Y1(int num)
  939. {
  940. const unsigned int n = (unsigned int)num;
  941. return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
  942. }
  943. static __inline tilegx_bundle_bits
  944. create_SrcA_Y2(int num)
  945. {
  946. const unsigned int n = (unsigned int)num;
  947. return ((n & 0x3f) << 20);
  948. }
  949. static __inline tilegx_bundle_bits
  950. create_SrcBDest_Y2(int num)
  951. {
  952. const unsigned int n = (unsigned int)num;
  953. return (((tilegx_bundle_bits)(n & 0x3f)) << 51);
  954. }
  955. static __inline tilegx_bundle_bits
  956. create_SrcB_X0(int num)
  957. {
  958. const unsigned int n = (unsigned int)num;
  959. return ((n & 0x3f) << 12);
  960. }
  961. static __inline tilegx_bundle_bits
  962. create_SrcB_X1(int num)
  963. {
  964. const unsigned int n = (unsigned int)num;
  965. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  966. }
  967. static __inline tilegx_bundle_bits
  968. create_SrcB_Y0(int num)
  969. {
  970. const unsigned int n = (unsigned int)num;
  971. return ((n & 0x3f) << 12);
  972. }
  973. static __inline tilegx_bundle_bits
  974. create_SrcB_Y1(int num)
  975. {
  976. const unsigned int n = (unsigned int)num;
  977. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  978. }
  979. static __inline tilegx_bundle_bits
  980. create_UnaryOpcodeExtension_X0(int num)
  981. {
  982. const unsigned int n = (unsigned int)num;
  983. return ((n & 0x3f) << 12);
  984. }
  985. static __inline tilegx_bundle_bits
  986. create_UnaryOpcodeExtension_X1(int num)
  987. {
  988. const unsigned int n = (unsigned int)num;
  989. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  990. }
  991. static __inline tilegx_bundle_bits
  992. create_UnaryOpcodeExtension_Y0(int num)
  993. {
  994. const unsigned int n = (unsigned int)num;
  995. return ((n & 0x3f) << 12);
  996. }
  997. static __inline tilegx_bundle_bits
  998. create_UnaryOpcodeExtension_Y1(int num)
  999. {
  1000. const unsigned int n = (unsigned int)num;
  1001. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  1002. }
  1003. typedef enum
  1004. {
  1005. TILEGX_PIPELINE_X0,
  1006. TILEGX_PIPELINE_X1,
  1007. TILEGX_PIPELINE_Y0,
  1008. TILEGX_PIPELINE_Y1,
  1009. TILEGX_PIPELINE_Y2,
  1010. } tilegx_pipeline;
  1011. #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
  1012. typedef enum
  1013. {
  1014. TILEGX_OP_TYPE_REGISTER,
  1015. TILEGX_OP_TYPE_IMMEDIATE,
  1016. TILEGX_OP_TYPE_ADDRESS,
  1017. TILEGX_OP_TYPE_SPR
  1018. } tilegx_operand_type;
  1019. /* These are the bits that determine if a bundle is in the X encoding. */
  1020. #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
  1021. enum
  1022. {
  1023. /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
  1024. TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE = 3,
  1025. /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
  1026. TILEGX_NUM_PIPELINE_ENCODINGS = 5,
  1027. /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
  1028. TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES = 3,
  1029. /* Instructions take this many bytes. */
  1030. TILEGX_BUNDLE_SIZE_IN_BYTES = 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES,
  1031. /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
  1032. TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3,
  1033. /* Bundles should be aligned modulo this number of bytes. */
  1034. TILEGX_BUNDLE_ALIGNMENT_IN_BYTES =
  1035. (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES),
  1036. /* Number of registers (some are magic, such as network I/O). */
  1037. TILEGX_NUM_REGISTERS = 64,
  1038. };
  1039. struct tilegx_operand
  1040. {
  1041. /* Is this operand a register, immediate or address? */
  1042. tilegx_operand_type type;
  1043. /* The default relocation type for this operand. */
  1044. signed int default_reloc : 16;
  1045. /* How many bits is this value? (used for range checking) */
  1046. unsigned int num_bits : 5;
  1047. /* Is the value signed? (used for range checking) */
  1048. unsigned int is_signed : 1;
  1049. /* Is this operand a source register? */
  1050. unsigned int is_src_reg : 1;
  1051. /* Is this operand written? (i.e. is it a destination register) */
  1052. unsigned int is_dest_reg : 1;
  1053. /* Is this operand PC-relative? */
  1054. unsigned int is_pc_relative : 1;
  1055. /* By how many bits do we right shift the value before inserting? */
  1056. unsigned int rightshift : 2;
  1057. /* Return the bits for this operand to be ORed into an existing bundle. */
  1058. tilegx_bundle_bits (*insert) (int op);
  1059. /* Extract this operand and return it. */
  1060. unsigned int (*extract) (tilegx_bundle_bits bundle);
  1061. };
  1062. extern const struct tilegx_operand tilegx_operands[];
  1063. /* One finite-state machine per pipe for rapid instruction decoding. */
  1064. extern const unsigned short * const
  1065. tilegx_bundle_decoder_fsms[TILEGX_NUM_PIPELINE_ENCODINGS];
  1066. struct tilegx_opcode
  1067. {
  1068. /* The opcode mnemonic, e.g. "add" */
  1069. const char *name;
  1070. /* The enum value for this mnemonic. */
  1071. tilegx_mnemonic mnemonic;
  1072. /* A bit mask of which of the five pipes this instruction
  1073. is compatible with:
  1074. X0 0x01
  1075. X1 0x02
  1076. Y0 0x04
  1077. Y1 0x08
  1078. Y2 0x10 */
  1079. unsigned char pipes;
  1080. /* How many operands are there? */
  1081. unsigned char num_operands;
  1082. /* Which register does this write implicitly, or TREG_ZERO if none? */
  1083. unsigned char implicitly_written_register;
  1084. /* Can this be bundled with other instructions (almost always true). */
  1085. unsigned char can_bundle;
  1086. /* The description of the operands. Each of these is an
  1087. * index into the tilegx_operands[] table. */
  1088. unsigned char operands[TILEGX_NUM_PIPELINE_ENCODINGS][TILEGX_MAX_OPERANDS];
  1089. #if !defined(__KERNEL__) && !defined(_LIBC)
  1090. /* A mask of which bits have predefined values for each pipeline.
  1091. * This is useful for disassembly. */
  1092. tilegx_bundle_bits fixed_bit_masks[TILEGX_NUM_PIPELINE_ENCODINGS];
  1093. /* For each bit set in fixed_bit_masks, what the value is for this
  1094. * instruction. */
  1095. tilegx_bundle_bits fixed_bit_values[TILEGX_NUM_PIPELINE_ENCODINGS];
  1096. #endif
  1097. };
  1098. extern const struct tilegx_opcode tilegx_opcodes[];
  1099. /* Used for non-textual disassembly into structs. */
  1100. struct tilegx_decoded_instruction
  1101. {
  1102. const struct tilegx_opcode *opcode;
  1103. const struct tilegx_operand *operands[TILEGX_MAX_OPERANDS];
  1104. long long operand_values[TILEGX_MAX_OPERANDS];
  1105. };
  1106. /* Disassemble a bundle into a struct for machine processing. */
  1107. extern int parse_insn_tilegx(tilegx_bundle_bits bits,
  1108. unsigned long long pc,
  1109. struct tilegx_decoded_instruction
  1110. decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]);
  1111. #if !defined(__KERNEL__) && !defined(_LIBC)
  1112. /* Canonical names of all the registers. */
  1113. /* ISSUE: This table lives in "tile-dis.c" */
  1114. extern const char * const tilegx_register_names[];
  1115. /* Descriptor for a special-purpose register. */
  1116. struct tilegx_spr
  1117. {
  1118. /* The number */
  1119. int number;
  1120. /* The name */
  1121. const char *name;
  1122. };
  1123. /* List of all the SPRs; ordered by increasing number. */
  1124. extern const struct tilegx_spr tilegx_sprs[];
  1125. /* Number of special-purpose registers. */
  1126. extern const int tilegx_num_sprs;
  1127. extern const char *
  1128. get_tilegx_spr_name (int num);
  1129. #endif /* !__KERNEL__ && !_LIBC */
  1130. /* Make a few "tile_" variables to simply common code between
  1131. architectures. */
  1132. typedef tilegx_bundle_bits tile_bundle_bits;
  1133. #define TILE_BUNDLE_SIZE_IN_BYTES TILEGX_BUNDLE_SIZE_IN_BYTES
  1134. #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
  1135. #define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
  1136. TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
  1137. #ifdef __cplusplus
  1138. }
  1139. #endif
  1140. #endif /* opcode_tilegx_h */