mt-ibld.c 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755
  1. /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
  2. /* Instruction building/extraction support for mt. -*- C -*-
  3. THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
  4. - the resultant file is machine generated, cgen-ibld.in isn't
  5. Copyright (C) 1996-2022 Free Software Foundation, Inc.
  6. This file is part of libopcodes.
  7. This library is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 3, or (at your option)
  10. any later version.
  11. It is distributed in the hope that it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  13. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  14. License for more details.
  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 Foundation, Inc.,
  17. 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
  18. /* ??? Eventually more and more of this stuff can go to cpu-independent files.
  19. Keep that in mind. */
  20. #include "sysdep.h"
  21. #include <stdio.h>
  22. #include "ansidecl.h"
  23. #include "dis-asm.h"
  24. #include "bfd.h"
  25. #include "symcat.h"
  26. #include "mt-desc.h"
  27. #include "mt-opc.h"
  28. #include "cgen/basic-modes.h"
  29. #include "opintl.h"
  30. #include "safe-ctype.h"
  31. #undef min
  32. #define min(a,b) ((a) < (b) ? (a) : (b))
  33. #undef max
  34. #define max(a,b) ((a) > (b) ? (a) : (b))
  35. /* Used by the ifield rtx function. */
  36. #define FLD(f) (fields->f)
  37. static const char * insert_normal
  38. (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
  39. unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR);
  40. static const char * insert_insn_normal
  41. (CGEN_CPU_DESC, const CGEN_INSN *,
  42. CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
  43. static int extract_normal
  44. (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
  45. unsigned int, unsigned int, unsigned int, unsigned int,
  46. unsigned int, unsigned int, bfd_vma, long *);
  47. static int extract_insn_normal
  48. (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
  49. CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
  50. #if CGEN_INT_INSN_P
  51. static void put_insn_int_value
  52. (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
  53. #endif
  54. #if ! CGEN_INT_INSN_P
  55. static CGEN_INLINE void insert_1
  56. (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
  57. static CGEN_INLINE int fill_cache
  58. (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma);
  59. static CGEN_INLINE long extract_1
  60. (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
  61. #endif
  62. /* Operand insertion. */
  63. #if ! CGEN_INT_INSN_P
  64. /* Subroutine of insert_normal. */
  65. static CGEN_INLINE void
  66. insert_1 (CGEN_CPU_DESC cd,
  67. unsigned long value,
  68. int start,
  69. int length,
  70. int word_length,
  71. unsigned char *bufp)
  72. {
  73. unsigned long x, mask;
  74. int shift;
  75. x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
  76. /* Written this way to avoid undefined behaviour. */
  77. mask = (1UL << (length - 1) << 1) - 1;
  78. if (CGEN_INSN_LSB0_P)
  79. shift = (start + 1) - length;
  80. else
  81. shift = (word_length - (start + length));
  82. x = (x & ~(mask << shift)) | ((value & mask) << shift);
  83. cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x, cd->endian);
  84. }
  85. #endif /* ! CGEN_INT_INSN_P */
  86. /* Default insertion routine.
  87. ATTRS is a mask of the boolean attributes.
  88. WORD_OFFSET is the offset in bits from the start of the insn of the value.
  89. WORD_LENGTH is the length of the word in bits in which the value resides.
  90. START is the starting bit number in the word, architecture origin.
  91. LENGTH is the length of VALUE in bits.
  92. TOTAL_LENGTH is the total length of the insn in bits.
  93. The result is an error message or NULL if success. */
  94. /* ??? This duplicates functionality with bfd's howto table and
  95. bfd_install_relocation. */
  96. /* ??? This doesn't handle bfd_vma's. Create another function when
  97. necessary. */
  98. static const char *
  99. insert_normal (CGEN_CPU_DESC cd,
  100. long value,
  101. unsigned int attrs,
  102. unsigned int word_offset,
  103. unsigned int start,
  104. unsigned int length,
  105. unsigned int word_length,
  106. unsigned int total_length,
  107. CGEN_INSN_BYTES_PTR buffer)
  108. {
  109. static char errbuf[100];
  110. unsigned long mask;
  111. /* If LENGTH is zero, this operand doesn't contribute to the value. */
  112. if (length == 0)
  113. return NULL;
  114. /* Written this way to avoid undefined behaviour. */
  115. mask = (1UL << (length - 1) << 1) - 1;
  116. if (word_length > 8 * sizeof (CGEN_INSN_INT))
  117. abort ();
  118. /* For architectures with insns smaller than the base-insn-bitsize,
  119. word_length may be too big. */
  120. if (cd->min_insn_bitsize < cd->base_insn_bitsize)
  121. {
  122. if (word_offset == 0
  123. && word_length > total_length)
  124. word_length = total_length;
  125. }
  126. /* Ensure VALUE will fit. */
  127. if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
  128. {
  129. long minval = - (1UL << (length - 1));
  130. unsigned long maxval = mask;
  131. if ((value > 0 && (unsigned long) value > maxval)
  132. || value < minval)
  133. {
  134. /* xgettext:c-format */
  135. sprintf (errbuf,
  136. _("operand out of range (%ld not between %ld and %lu)"),
  137. value, minval, maxval);
  138. return errbuf;
  139. }
  140. }
  141. else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
  142. {
  143. unsigned long maxval = mask;
  144. unsigned long val = (unsigned long) value;
  145. /* For hosts with a word size > 32 check to see if value has been sign
  146. extended beyond 32 bits. If so then ignore these higher sign bits
  147. as the user is attempting to store a 32-bit signed value into an
  148. unsigned 32-bit field which is allowed. */
  149. if (sizeof (unsigned long) > 4 && ((value >> 32) == -1))
  150. val &= 0xFFFFFFFF;
  151. if (val > maxval)
  152. {
  153. /* xgettext:c-format */
  154. sprintf (errbuf,
  155. _("operand out of range (0x%lx not between 0 and 0x%lx)"),
  156. val, maxval);
  157. return errbuf;
  158. }
  159. }
  160. else
  161. {
  162. if (! cgen_signed_overflow_ok_p (cd))
  163. {
  164. long minval = - (1UL << (length - 1));
  165. long maxval = (1UL << (length - 1)) - 1;
  166. if (value < minval || value > maxval)
  167. {
  168. sprintf
  169. /* xgettext:c-format */
  170. (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
  171. value, minval, maxval);
  172. return errbuf;
  173. }
  174. }
  175. }
  176. #if CGEN_INT_INSN_P
  177. {
  178. int shift_within_word, shift_to_word, shift;
  179. /* How to shift the value to BIT0 of the word. */
  180. shift_to_word = total_length - (word_offset + word_length);
  181. /* How to shift the value to the field within the word. */
  182. if (CGEN_INSN_LSB0_P)
  183. shift_within_word = start + 1 - length;
  184. else
  185. shift_within_word = word_length - start - length;
  186. /* The total SHIFT, then mask in the value. */
  187. shift = shift_to_word + shift_within_word;
  188. *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
  189. }
  190. #else /* ! CGEN_INT_INSN_P */
  191. {
  192. unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
  193. insert_1 (cd, value, start, length, word_length, bufp);
  194. }
  195. #endif /* ! CGEN_INT_INSN_P */
  196. return NULL;
  197. }
  198. /* Default insn builder (insert handler).
  199. The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
  200. that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
  201. recorded in host byte order, otherwise BUFFER is an array of bytes
  202. and the value is recorded in target byte order).
  203. The result is an error message or NULL if success. */
  204. static const char *
  205. insert_insn_normal (CGEN_CPU_DESC cd,
  206. const CGEN_INSN * insn,
  207. CGEN_FIELDS * fields,
  208. CGEN_INSN_BYTES_PTR buffer,
  209. bfd_vma pc)
  210. {
  211. const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
  212. unsigned long value;
  213. const CGEN_SYNTAX_CHAR_TYPE * syn;
  214. CGEN_INIT_INSERT (cd);
  215. value = CGEN_INSN_BASE_VALUE (insn);
  216. /* If we're recording insns as numbers (rather than a string of bytes),
  217. target byte order handling is deferred until later. */
  218. #if CGEN_INT_INSN_P
  219. put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
  220. CGEN_FIELDS_BITSIZE (fields), value);
  221. #else
  222. cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
  223. (unsigned) CGEN_FIELDS_BITSIZE (fields)),
  224. value, cd->insn_endian);
  225. #endif /* ! CGEN_INT_INSN_P */
  226. /* ??? It would be better to scan the format's fields.
  227. Still need to be able to insert a value based on the operand though;
  228. e.g. storing a branch displacement that got resolved later.
  229. Needs more thought first. */
  230. for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
  231. {
  232. const char *errmsg;
  233. if (CGEN_SYNTAX_CHAR_P (* syn))
  234. continue;
  235. errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
  236. fields, buffer, pc);
  237. if (errmsg)
  238. return errmsg;
  239. }
  240. return NULL;
  241. }
  242. #if CGEN_INT_INSN_P
  243. /* Cover function to store an insn value into an integral insn. Must go here
  244. because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
  245. static void
  246. put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  247. CGEN_INSN_BYTES_PTR buf,
  248. int length,
  249. int insn_length,
  250. CGEN_INSN_INT value)
  251. {
  252. /* For architectures with insns smaller than the base-insn-bitsize,
  253. length may be too big. */
  254. if (length > insn_length)
  255. *buf = value;
  256. else
  257. {
  258. int shift = insn_length - length;
  259. /* Written this way to avoid undefined behaviour. */
  260. CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
  261. *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
  262. }
  263. }
  264. #endif
  265. /* Operand extraction. */
  266. #if ! CGEN_INT_INSN_P
  267. /* Subroutine of extract_normal.
  268. Ensure sufficient bytes are cached in EX_INFO.
  269. OFFSET is the offset in bytes from the start of the insn of the value.
  270. BYTES is the length of the needed value.
  271. Returns 1 for success, 0 for failure. */
  272. static CGEN_INLINE int
  273. fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  274. CGEN_EXTRACT_INFO *ex_info,
  275. int offset,
  276. int bytes,
  277. bfd_vma pc)
  278. {
  279. /* It's doubtful that the middle part has already been fetched so
  280. we don't optimize that case. kiss. */
  281. unsigned int mask;
  282. disassemble_info *info = (disassemble_info *) ex_info->dis_info;
  283. /* First do a quick check. */
  284. mask = (1 << bytes) - 1;
  285. if (((ex_info->valid >> offset) & mask) == mask)
  286. return 1;
  287. /* Search for the first byte we need to read. */
  288. for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
  289. if (! (mask & ex_info->valid))
  290. break;
  291. if (bytes)
  292. {
  293. int status;
  294. pc += offset;
  295. status = (*info->read_memory_func)
  296. (pc, ex_info->insn_bytes + offset, bytes, info);
  297. if (status != 0)
  298. {
  299. (*info->memory_error_func) (status, pc, info);
  300. return 0;
  301. }
  302. ex_info->valid |= ((1 << bytes) - 1) << offset;
  303. }
  304. return 1;
  305. }
  306. /* Subroutine of extract_normal. */
  307. static CGEN_INLINE long
  308. extract_1 (CGEN_CPU_DESC cd,
  309. CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
  310. int start,
  311. int length,
  312. int word_length,
  313. unsigned char *bufp,
  314. bfd_vma pc ATTRIBUTE_UNUSED)
  315. {
  316. unsigned long x;
  317. int shift;
  318. x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
  319. if (CGEN_INSN_LSB0_P)
  320. shift = (start + 1) - length;
  321. else
  322. shift = (word_length - (start + length));
  323. return x >> shift;
  324. }
  325. #endif /* ! CGEN_INT_INSN_P */
  326. /* Default extraction routine.
  327. INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
  328. or sometimes less for cases like the m32r where the base insn size is 32
  329. but some insns are 16 bits.
  330. ATTRS is a mask of the boolean attributes. We only need `SIGNED',
  331. but for generality we take a bitmask of all of them.
  332. WORD_OFFSET is the offset in bits from the start of the insn of the value.
  333. WORD_LENGTH is the length of the word in bits in which the value resides.
  334. START is the starting bit number in the word, architecture origin.
  335. LENGTH is the length of VALUE in bits.
  336. TOTAL_LENGTH is the total length of the insn in bits.
  337. Returns 1 for success, 0 for failure. */
  338. /* ??? The return code isn't properly used. wip. */
  339. /* ??? This doesn't handle bfd_vma's. Create another function when
  340. necessary. */
  341. static int
  342. extract_normal (CGEN_CPU_DESC cd,
  343. #if ! CGEN_INT_INSN_P
  344. CGEN_EXTRACT_INFO *ex_info,
  345. #else
  346. CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
  347. #endif
  348. CGEN_INSN_INT insn_value,
  349. unsigned int attrs,
  350. unsigned int word_offset,
  351. unsigned int start,
  352. unsigned int length,
  353. unsigned int word_length,
  354. unsigned int total_length,
  355. #if ! CGEN_INT_INSN_P
  356. bfd_vma pc,
  357. #else
  358. bfd_vma pc ATTRIBUTE_UNUSED,
  359. #endif
  360. long *valuep)
  361. {
  362. long value, mask;
  363. /* If LENGTH is zero, this operand doesn't contribute to the value
  364. so give it a standard value of zero. */
  365. if (length == 0)
  366. {
  367. *valuep = 0;
  368. return 1;
  369. }
  370. if (word_length > 8 * sizeof (CGEN_INSN_INT))
  371. abort ();
  372. /* For architectures with insns smaller than the insn-base-bitsize,
  373. word_length may be too big. */
  374. if (cd->min_insn_bitsize < cd->base_insn_bitsize)
  375. {
  376. if (word_offset + word_length > total_length)
  377. word_length = total_length - word_offset;
  378. }
  379. /* Does the value reside in INSN_VALUE, and at the right alignment? */
  380. if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
  381. {
  382. if (CGEN_INSN_LSB0_P)
  383. value = insn_value >> ((word_offset + start + 1) - length);
  384. else
  385. value = insn_value >> (total_length - ( word_offset + start + length));
  386. }
  387. #if ! CGEN_INT_INSN_P
  388. else
  389. {
  390. unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
  391. if (word_length > 8 * sizeof (CGEN_INSN_INT))
  392. abort ();
  393. if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
  394. {
  395. *valuep = 0;
  396. return 0;
  397. }
  398. value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
  399. }
  400. #endif /* ! CGEN_INT_INSN_P */
  401. /* Written this way to avoid undefined behaviour. */
  402. mask = (1UL << (length - 1) << 1) - 1;
  403. value &= mask;
  404. /* sign extend? */
  405. if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
  406. && (value & (1UL << (length - 1))))
  407. value |= ~mask;
  408. *valuep = value;
  409. return 1;
  410. }
  411. /* Default insn extractor.
  412. INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
  413. The extracted fields are stored in FIELDS.
  414. EX_INFO is used to handle reading variable length insns.
  415. Return the length of the insn in bits, or 0 if no match,
  416. or -1 if an error occurs fetching data (memory_error_func will have
  417. been called). */
  418. static int
  419. extract_insn_normal (CGEN_CPU_DESC cd,
  420. const CGEN_INSN *insn,
  421. CGEN_EXTRACT_INFO *ex_info,
  422. CGEN_INSN_INT insn_value,
  423. CGEN_FIELDS *fields,
  424. bfd_vma pc)
  425. {
  426. const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
  427. const CGEN_SYNTAX_CHAR_TYPE *syn;
  428. CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
  429. CGEN_INIT_EXTRACT (cd);
  430. for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
  431. {
  432. int length;
  433. if (CGEN_SYNTAX_CHAR_P (*syn))
  434. continue;
  435. length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
  436. ex_info, insn_value, fields, pc);
  437. if (length <= 0)
  438. return length;
  439. }
  440. /* We recognized and successfully extracted this insn. */
  441. return CGEN_INSN_BITSIZE (insn);
  442. }
  443. /* Machine generated code added here. */
  444. const char * mt_cgen_insert_operand
  445. (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
  446. /* Main entry point for operand insertion.
  447. This function is basically just a big switch statement. Earlier versions
  448. used tables to look up the function to use, but
  449. - if the table contains both assembler and disassembler functions then
  450. the disassembler contains much of the assembler and vice-versa,
  451. - there's a lot of inlining possibilities as things grow,
  452. - using a switch statement avoids the function call overhead.
  453. This function could be moved into `parse_insn_normal', but keeping it
  454. separate makes clear the interface between `parse_insn_normal' and each of
  455. the handlers. It's also needed by GAS to insert operands that couldn't be
  456. resolved during parsing. */
  457. const char *
  458. mt_cgen_insert_operand (CGEN_CPU_DESC cd,
  459. int opindex,
  460. CGEN_FIELDS * fields,
  461. CGEN_INSN_BYTES_PTR buffer,
  462. bfd_vma pc ATTRIBUTE_UNUSED)
  463. {
  464. const char * errmsg = NULL;
  465. unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
  466. switch (opindex)
  467. {
  468. case MT_OPERAND_A23 :
  469. errmsg = insert_normal (cd, fields->f_a23, 0, 0, 23, 1, 32, total_length, buffer);
  470. break;
  471. case MT_OPERAND_BALL :
  472. errmsg = insert_normal (cd, fields->f_ball, 0, 0, 19, 1, 32, total_length, buffer);
  473. break;
  474. case MT_OPERAND_BALL2 :
  475. errmsg = insert_normal (cd, fields->f_ball2, 0, 0, 15, 1, 32, total_length, buffer);
  476. break;
  477. case MT_OPERAND_BANKADDR :
  478. errmsg = insert_normal (cd, fields->f_bankaddr, 0, 0, 25, 13, 32, total_length, buffer);
  479. break;
  480. case MT_OPERAND_BRC :
  481. errmsg = insert_normal (cd, fields->f_brc, 0, 0, 18, 3, 32, total_length, buffer);
  482. break;
  483. case MT_OPERAND_BRC2 :
  484. errmsg = insert_normal (cd, fields->f_brc2, 0, 0, 14, 3, 32, total_length, buffer);
  485. break;
  486. case MT_OPERAND_CB1INCR :
  487. errmsg = insert_normal (cd, fields->f_cb1incr, 0|(1<<CGEN_IFLD_SIGNED), 0, 19, 6, 32, total_length, buffer);
  488. break;
  489. case MT_OPERAND_CB1SEL :
  490. errmsg = insert_normal (cd, fields->f_cb1sel, 0, 0, 25, 3, 32, total_length, buffer);
  491. break;
  492. case MT_OPERAND_CB2INCR :
  493. errmsg = insert_normal (cd, fields->f_cb2incr, 0|(1<<CGEN_IFLD_SIGNED), 0, 13, 6, 32, total_length, buffer);
  494. break;
  495. case MT_OPERAND_CB2SEL :
  496. errmsg = insert_normal (cd, fields->f_cb2sel, 0, 0, 22, 3, 32, total_length, buffer);
  497. break;
  498. case MT_OPERAND_CBRB :
  499. errmsg = insert_normal (cd, fields->f_cbrb, 0, 0, 10, 1, 32, total_length, buffer);
  500. break;
  501. case MT_OPERAND_CBS :
  502. errmsg = insert_normal (cd, fields->f_cbs, 0, 0, 19, 2, 32, total_length, buffer);
  503. break;
  504. case MT_OPERAND_CBX :
  505. errmsg = insert_normal (cd, fields->f_cbx, 0, 0, 14, 3, 32, total_length, buffer);
  506. break;
  507. case MT_OPERAND_CCB :
  508. errmsg = insert_normal (cd, fields->f_ccb, 0, 0, 11, 1, 32, total_length, buffer);
  509. break;
  510. case MT_OPERAND_CDB :
  511. errmsg = insert_normal (cd, fields->f_cdb, 0, 0, 10, 1, 32, total_length, buffer);
  512. break;
  513. case MT_OPERAND_CELL :
  514. errmsg = insert_normal (cd, fields->f_cell, 0, 0, 9, 3, 32, total_length, buffer);
  515. break;
  516. case MT_OPERAND_COLNUM :
  517. errmsg = insert_normal (cd, fields->f_colnum, 0, 0, 18, 3, 32, total_length, buffer);
  518. break;
  519. case MT_OPERAND_CONTNUM :
  520. errmsg = insert_normal (cd, fields->f_contnum, 0, 0, 8, 9, 32, total_length, buffer);
  521. break;
  522. case MT_OPERAND_CR :
  523. errmsg = insert_normal (cd, fields->f_cr, 0, 0, 22, 3, 32, total_length, buffer);
  524. break;
  525. case MT_OPERAND_CTXDISP :
  526. errmsg = insert_normal (cd, fields->f_ctxdisp, 0, 0, 5, 6, 32, total_length, buffer);
  527. break;
  528. case MT_OPERAND_DUP :
  529. errmsg = insert_normal (cd, fields->f_dup, 0, 0, 6, 1, 32, total_length, buffer);
  530. break;
  531. case MT_OPERAND_FBDISP :
  532. errmsg = insert_normal (cd, fields->f_fbdisp, 0, 0, 15, 6, 32, total_length, buffer);
  533. break;
  534. case MT_OPERAND_FBINCR :
  535. errmsg = insert_normal (cd, fields->f_fbincr, 0, 0, 23, 4, 32, total_length, buffer);
  536. break;
  537. case MT_OPERAND_FRDR :
  538. errmsg = insert_normal (cd, fields->f_dr, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, buffer);
  539. break;
  540. case MT_OPERAND_FRDRRR :
  541. errmsg = insert_normal (cd, fields->f_drrr, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 15, 4, 32, total_length, buffer);
  542. break;
  543. case MT_OPERAND_FRSR1 :
  544. errmsg = insert_normal (cd, fields->f_sr1, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 23, 4, 32, total_length, buffer);
  545. break;
  546. case MT_OPERAND_FRSR2 :
  547. errmsg = insert_normal (cd, fields->f_sr2, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, buffer);
  548. break;
  549. case MT_OPERAND_ID :
  550. errmsg = insert_normal (cd, fields->f_id, 0, 0, 14, 1, 32, total_length, buffer);
  551. break;
  552. case MT_OPERAND_IMM16 :
  553. {
  554. long value = fields->f_imm16s;
  555. value = ((value) + (0));
  556. errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
  557. }
  558. break;
  559. case MT_OPERAND_IMM16L :
  560. errmsg = insert_normal (cd, fields->f_imm16l, 0, 0, 23, 16, 32, total_length, buffer);
  561. break;
  562. case MT_OPERAND_IMM16O :
  563. {
  564. long value = fields->f_imm16s;
  565. value = ((value) + (0));
  566. errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
  567. }
  568. break;
  569. case MT_OPERAND_IMM16Z :
  570. errmsg = insert_normal (cd, fields->f_imm16u, 0, 0, 15, 16, 32, total_length, buffer);
  571. break;
  572. case MT_OPERAND_INCAMT :
  573. errmsg = insert_normal (cd, fields->f_incamt, 0, 0, 19, 8, 32, total_length, buffer);
  574. break;
  575. case MT_OPERAND_INCR :
  576. errmsg = insert_normal (cd, fields->f_incr, 0, 0, 17, 6, 32, total_length, buffer);
  577. break;
  578. case MT_OPERAND_LENGTH :
  579. errmsg = insert_normal (cd, fields->f_length, 0, 0, 15, 3, 32, total_length, buffer);
  580. break;
  581. case MT_OPERAND_LOOPSIZE :
  582. {
  583. long value = fields->f_loopo;
  584. value = ((USI) (value) >> (2));
  585. errmsg = insert_normal (cd, value, 0, 0, 7, 8, 32, total_length, buffer);
  586. }
  587. break;
  588. case MT_OPERAND_MASK :
  589. errmsg = insert_normal (cd, fields->f_mask, 0, 0, 25, 16, 32, total_length, buffer);
  590. break;
  591. case MT_OPERAND_MASK1 :
  592. errmsg = insert_normal (cd, fields->f_mask1, 0, 0, 22, 3, 32, total_length, buffer);
  593. break;
  594. case MT_OPERAND_MODE :
  595. errmsg = insert_normal (cd, fields->f_mode, 0, 0, 25, 2, 32, total_length, buffer);
  596. break;
  597. case MT_OPERAND_PERM :
  598. errmsg = insert_normal (cd, fields->f_perm, 0, 0, 25, 2, 32, total_length, buffer);
  599. break;
  600. case MT_OPERAND_RBBC :
  601. errmsg = insert_normal (cd, fields->f_rbbc, 0, 0, 25, 2, 32, total_length, buffer);
  602. break;
  603. case MT_OPERAND_RC :
  604. errmsg = insert_normal (cd, fields->f_rc, 0, 0, 15, 1, 32, total_length, buffer);
  605. break;
  606. case MT_OPERAND_RC1 :
  607. errmsg = insert_normal (cd, fields->f_rc1, 0, 0, 11, 1, 32, total_length, buffer);
  608. break;
  609. case MT_OPERAND_RC2 :
  610. errmsg = insert_normal (cd, fields->f_rc2, 0, 0, 6, 1, 32, total_length, buffer);
  611. break;
  612. case MT_OPERAND_RC3 :
  613. errmsg = insert_normal (cd, fields->f_rc3, 0, 0, 7, 1, 32, total_length, buffer);
  614. break;
  615. case MT_OPERAND_RCNUM :
  616. errmsg = insert_normal (cd, fields->f_rcnum, 0, 0, 14, 3, 32, total_length, buffer);
  617. break;
  618. case MT_OPERAND_RDA :
  619. errmsg = insert_normal (cd, fields->f_rda, 0, 0, 25, 1, 32, total_length, buffer);
  620. break;
  621. case MT_OPERAND_ROWNUM :
  622. errmsg = insert_normal (cd, fields->f_rownum, 0, 0, 14, 3, 32, total_length, buffer);
  623. break;
  624. case MT_OPERAND_ROWNUM1 :
  625. errmsg = insert_normal (cd, fields->f_rownum1, 0, 0, 12, 3, 32, total_length, buffer);
  626. break;
  627. case MT_OPERAND_ROWNUM2 :
  628. errmsg = insert_normal (cd, fields->f_rownum2, 0, 0, 9, 3, 32, total_length, buffer);
  629. break;
  630. case MT_OPERAND_SIZE :
  631. errmsg = insert_normal (cd, fields->f_size, 0, 0, 13, 14, 32, total_length, buffer);
  632. break;
  633. case MT_OPERAND_TYPE :
  634. errmsg = insert_normal (cd, fields->f_type, 0, 0, 21, 2, 32, total_length, buffer);
  635. break;
  636. case MT_OPERAND_WR :
  637. errmsg = insert_normal (cd, fields->f_wr, 0, 0, 24, 1, 32, total_length, buffer);
  638. break;
  639. case MT_OPERAND_XMODE :
  640. errmsg = insert_normal (cd, fields->f_xmode, 0, 0, 23, 1, 32, total_length, buffer);
  641. break;
  642. default :
  643. /* xgettext:c-format */
  644. opcodes_error_handler
  645. (_("internal error: unrecognized field %d while building insn"),
  646. opindex);
  647. abort ();
  648. }
  649. return errmsg;
  650. }
  651. int mt_cgen_extract_operand
  652. (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
  653. /* Main entry point for operand extraction.
  654. The result is <= 0 for error, >0 for success.
  655. ??? Actual values aren't well defined right now.
  656. This function is basically just a big switch statement. Earlier versions
  657. used tables to look up the function to use, but
  658. - if the table contains both assembler and disassembler functions then
  659. the disassembler contains much of the assembler and vice-versa,
  660. - there's a lot of inlining possibilities as things grow,
  661. - using a switch statement avoids the function call overhead.
  662. This function could be moved into `print_insn_normal', but keeping it
  663. separate makes clear the interface between `print_insn_normal' and each of
  664. the handlers. */
  665. int
  666. mt_cgen_extract_operand (CGEN_CPU_DESC cd,
  667. int opindex,
  668. CGEN_EXTRACT_INFO *ex_info,
  669. CGEN_INSN_INT insn_value,
  670. CGEN_FIELDS * fields,
  671. bfd_vma pc)
  672. {
  673. /* Assume success (for those operands that are nops). */
  674. int length = 1;
  675. unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
  676. switch (opindex)
  677. {
  678. case MT_OPERAND_A23 :
  679. length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 1, 32, total_length, pc, & fields->f_a23);
  680. break;
  681. case MT_OPERAND_BALL :
  682. length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 1, 32, total_length, pc, & fields->f_ball);
  683. break;
  684. case MT_OPERAND_BALL2 :
  685. length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_ball2);
  686. break;
  687. case MT_OPERAND_BANKADDR :
  688. length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 13, 32, total_length, pc, & fields->f_bankaddr);
  689. break;
  690. case MT_OPERAND_BRC :
  691. length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 3, 32, total_length, pc, & fields->f_brc);
  692. break;
  693. case MT_OPERAND_BRC2 :
  694. length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_brc2);
  695. break;
  696. case MT_OPERAND_CB1INCR :
  697. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 19, 6, 32, total_length, pc, & fields->f_cb1incr);
  698. break;
  699. case MT_OPERAND_CB1SEL :
  700. length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_cb1sel);
  701. break;
  702. case MT_OPERAND_CB2INCR :
  703. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 13, 6, 32, total_length, pc, & fields->f_cb2incr);
  704. break;
  705. case MT_OPERAND_CB2SEL :
  706. length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_cb2sel);
  707. break;
  708. case MT_OPERAND_CBRB :
  709. length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 1, 32, total_length, pc, & fields->f_cbrb);
  710. break;
  711. case MT_OPERAND_CBS :
  712. length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 2, 32, total_length, pc, & fields->f_cbs);
  713. break;
  714. case MT_OPERAND_CBX :
  715. length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_cbx);
  716. break;
  717. case MT_OPERAND_CCB :
  718. length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_ccb);
  719. break;
  720. case MT_OPERAND_CDB :
  721. length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 1, 32, total_length, pc, & fields->f_cdb);
  722. break;
  723. case MT_OPERAND_CELL :
  724. length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_cell);
  725. break;
  726. case MT_OPERAND_COLNUM :
  727. length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 3, 32, total_length, pc, & fields->f_colnum);
  728. break;
  729. case MT_OPERAND_CONTNUM :
  730. length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 9, 32, total_length, pc, & fields->f_contnum);
  731. break;
  732. case MT_OPERAND_CR :
  733. length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_cr);
  734. break;
  735. case MT_OPERAND_CTXDISP :
  736. length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_ctxdisp);
  737. break;
  738. case MT_OPERAND_DUP :
  739. length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_dup);
  740. break;
  741. case MT_OPERAND_FBDISP :
  742. length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_fbdisp);
  743. break;
  744. case MT_OPERAND_FBINCR :
  745. length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 4, 32, total_length, pc, & fields->f_fbincr);
  746. break;
  747. case MT_OPERAND_FRDR :
  748. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, pc, & fields->f_dr);
  749. break;
  750. case MT_OPERAND_FRDRRR :
  751. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 15, 4, 32, total_length, pc, & fields->f_drrr);
  752. break;
  753. case MT_OPERAND_FRSR1 :
  754. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 23, 4, 32, total_length, pc, & fields->f_sr1);
  755. break;
  756. case MT_OPERAND_FRSR2 :
  757. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, pc, & fields->f_sr2);
  758. break;
  759. case MT_OPERAND_ID :
  760. length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 1, 32, total_length, pc, & fields->f_id);
  761. break;
  762. case MT_OPERAND_IMM16 :
  763. {
  764. long value;
  765. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & value);
  766. value = ((value) + (0));
  767. fields->f_imm16s = value;
  768. }
  769. break;
  770. case MT_OPERAND_IMM16L :
  771. length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 16, 32, total_length, pc, & fields->f_imm16l);
  772. break;
  773. case MT_OPERAND_IMM16O :
  774. {
  775. long value;
  776. length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & value);
  777. value = ((value) + (0));
  778. fields->f_imm16s = value;
  779. }
  780. break;
  781. case MT_OPERAND_IMM16Z :
  782. length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm16u);
  783. break;
  784. case MT_OPERAND_INCAMT :
  785. length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 8, 32, total_length, pc, & fields->f_incamt);
  786. break;
  787. case MT_OPERAND_INCR :
  788. length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_incr);
  789. break;
  790. case MT_OPERAND_LENGTH :
  791. length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_length);
  792. break;
  793. case MT_OPERAND_LOOPSIZE :
  794. {
  795. long value;
  796. length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 8, 32, total_length, pc, & value);
  797. value = ((((value) << (2))) + (8));
  798. fields->f_loopo = value;
  799. }
  800. break;
  801. case MT_OPERAND_MASK :
  802. length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 16, 32, total_length, pc, & fields->f_mask);
  803. break;
  804. case MT_OPERAND_MASK1 :
  805. length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_mask1);
  806. break;
  807. case MT_OPERAND_MODE :
  808. length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_mode);
  809. break;
  810. case MT_OPERAND_PERM :
  811. length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_perm);
  812. break;
  813. case MT_OPERAND_RBBC :
  814. length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_rbbc);
  815. break;
  816. case MT_OPERAND_RC :
  817. length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_rc);
  818. break;
  819. case MT_OPERAND_RC1 :
  820. length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_rc1);
  821. break;
  822. case MT_OPERAND_RC2 :
  823. length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_rc2);
  824. break;
  825. case MT_OPERAND_RC3 :
  826. length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_rc3);
  827. break;
  828. case MT_OPERAND_RCNUM :
  829. length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_rcnum);
  830. break;
  831. case MT_OPERAND_RDA :
  832. length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_rda);
  833. break;
  834. case MT_OPERAND_ROWNUM :
  835. length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_rownum);
  836. break;
  837. case MT_OPERAND_ROWNUM1 :
  838. length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rownum1);
  839. break;
  840. case MT_OPERAND_ROWNUM2 :
  841. length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rownum2);
  842. break;
  843. case MT_OPERAND_SIZE :
  844. length = extract_normal (cd, ex_info, insn_value, 0, 0, 13, 14, 32, total_length, pc, & fields->f_size);
  845. break;
  846. case MT_OPERAND_TYPE :
  847. length = extract_normal (cd, ex_info, insn_value, 0, 0, 21, 2, 32, total_length, pc, & fields->f_type);
  848. break;
  849. case MT_OPERAND_WR :
  850. length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 1, 32, total_length, pc, & fields->f_wr);
  851. break;
  852. case MT_OPERAND_XMODE :
  853. length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 1, 32, total_length, pc, & fields->f_xmode);
  854. break;
  855. default :
  856. /* xgettext:c-format */
  857. opcodes_error_handler
  858. (_("internal error: unrecognized field %d while decoding insn"),
  859. opindex);
  860. abort ();
  861. }
  862. return length;
  863. }
  864. cgen_insert_fn * const mt_cgen_insert_handlers[] =
  865. {
  866. insert_insn_normal,
  867. };
  868. cgen_extract_fn * const mt_cgen_extract_handlers[] =
  869. {
  870. extract_insn_normal,
  871. };
  872. int mt_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
  873. bfd_vma mt_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
  874. /* Getting values from cgen_fields is handled by a collection of functions.
  875. They are distinguished by the type of the VALUE argument they return.
  876. TODO: floating point, inlining support, remove cases where result type
  877. not appropriate. */
  878. int
  879. mt_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  880. int opindex,
  881. const CGEN_FIELDS * fields)
  882. {
  883. int value;
  884. switch (opindex)
  885. {
  886. case MT_OPERAND_A23 :
  887. value = fields->f_a23;
  888. break;
  889. case MT_OPERAND_BALL :
  890. value = fields->f_ball;
  891. break;
  892. case MT_OPERAND_BALL2 :
  893. value = fields->f_ball2;
  894. break;
  895. case MT_OPERAND_BANKADDR :
  896. value = fields->f_bankaddr;
  897. break;
  898. case MT_OPERAND_BRC :
  899. value = fields->f_brc;
  900. break;
  901. case MT_OPERAND_BRC2 :
  902. value = fields->f_brc2;
  903. break;
  904. case MT_OPERAND_CB1INCR :
  905. value = fields->f_cb1incr;
  906. break;
  907. case MT_OPERAND_CB1SEL :
  908. value = fields->f_cb1sel;
  909. break;
  910. case MT_OPERAND_CB2INCR :
  911. value = fields->f_cb2incr;
  912. break;
  913. case MT_OPERAND_CB2SEL :
  914. value = fields->f_cb2sel;
  915. break;
  916. case MT_OPERAND_CBRB :
  917. value = fields->f_cbrb;
  918. break;
  919. case MT_OPERAND_CBS :
  920. value = fields->f_cbs;
  921. break;
  922. case MT_OPERAND_CBX :
  923. value = fields->f_cbx;
  924. break;
  925. case MT_OPERAND_CCB :
  926. value = fields->f_ccb;
  927. break;
  928. case MT_OPERAND_CDB :
  929. value = fields->f_cdb;
  930. break;
  931. case MT_OPERAND_CELL :
  932. value = fields->f_cell;
  933. break;
  934. case MT_OPERAND_COLNUM :
  935. value = fields->f_colnum;
  936. break;
  937. case MT_OPERAND_CONTNUM :
  938. value = fields->f_contnum;
  939. break;
  940. case MT_OPERAND_CR :
  941. value = fields->f_cr;
  942. break;
  943. case MT_OPERAND_CTXDISP :
  944. value = fields->f_ctxdisp;
  945. break;
  946. case MT_OPERAND_DUP :
  947. value = fields->f_dup;
  948. break;
  949. case MT_OPERAND_FBDISP :
  950. value = fields->f_fbdisp;
  951. break;
  952. case MT_OPERAND_FBINCR :
  953. value = fields->f_fbincr;
  954. break;
  955. case MT_OPERAND_FRDR :
  956. value = fields->f_dr;
  957. break;
  958. case MT_OPERAND_FRDRRR :
  959. value = fields->f_drrr;
  960. break;
  961. case MT_OPERAND_FRSR1 :
  962. value = fields->f_sr1;
  963. break;
  964. case MT_OPERAND_FRSR2 :
  965. value = fields->f_sr2;
  966. break;
  967. case MT_OPERAND_ID :
  968. value = fields->f_id;
  969. break;
  970. case MT_OPERAND_IMM16 :
  971. value = fields->f_imm16s;
  972. break;
  973. case MT_OPERAND_IMM16L :
  974. value = fields->f_imm16l;
  975. break;
  976. case MT_OPERAND_IMM16O :
  977. value = fields->f_imm16s;
  978. break;
  979. case MT_OPERAND_IMM16Z :
  980. value = fields->f_imm16u;
  981. break;
  982. case MT_OPERAND_INCAMT :
  983. value = fields->f_incamt;
  984. break;
  985. case MT_OPERAND_INCR :
  986. value = fields->f_incr;
  987. break;
  988. case MT_OPERAND_LENGTH :
  989. value = fields->f_length;
  990. break;
  991. case MT_OPERAND_LOOPSIZE :
  992. value = fields->f_loopo;
  993. break;
  994. case MT_OPERAND_MASK :
  995. value = fields->f_mask;
  996. break;
  997. case MT_OPERAND_MASK1 :
  998. value = fields->f_mask1;
  999. break;
  1000. case MT_OPERAND_MODE :
  1001. value = fields->f_mode;
  1002. break;
  1003. case MT_OPERAND_PERM :
  1004. value = fields->f_perm;
  1005. break;
  1006. case MT_OPERAND_RBBC :
  1007. value = fields->f_rbbc;
  1008. break;
  1009. case MT_OPERAND_RC :
  1010. value = fields->f_rc;
  1011. break;
  1012. case MT_OPERAND_RC1 :
  1013. value = fields->f_rc1;
  1014. break;
  1015. case MT_OPERAND_RC2 :
  1016. value = fields->f_rc2;
  1017. break;
  1018. case MT_OPERAND_RC3 :
  1019. value = fields->f_rc3;
  1020. break;
  1021. case MT_OPERAND_RCNUM :
  1022. value = fields->f_rcnum;
  1023. break;
  1024. case MT_OPERAND_RDA :
  1025. value = fields->f_rda;
  1026. break;
  1027. case MT_OPERAND_ROWNUM :
  1028. value = fields->f_rownum;
  1029. break;
  1030. case MT_OPERAND_ROWNUM1 :
  1031. value = fields->f_rownum1;
  1032. break;
  1033. case MT_OPERAND_ROWNUM2 :
  1034. value = fields->f_rownum2;
  1035. break;
  1036. case MT_OPERAND_SIZE :
  1037. value = fields->f_size;
  1038. break;
  1039. case MT_OPERAND_TYPE :
  1040. value = fields->f_type;
  1041. break;
  1042. case MT_OPERAND_WR :
  1043. value = fields->f_wr;
  1044. break;
  1045. case MT_OPERAND_XMODE :
  1046. value = fields->f_xmode;
  1047. break;
  1048. default :
  1049. /* xgettext:c-format */
  1050. opcodes_error_handler
  1051. (_("internal error: unrecognized field %d while getting int operand"),
  1052. opindex);
  1053. abort ();
  1054. }
  1055. return value;
  1056. }
  1057. bfd_vma
  1058. mt_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  1059. int opindex,
  1060. const CGEN_FIELDS * fields)
  1061. {
  1062. bfd_vma value;
  1063. switch (opindex)
  1064. {
  1065. case MT_OPERAND_A23 :
  1066. value = fields->f_a23;
  1067. break;
  1068. case MT_OPERAND_BALL :
  1069. value = fields->f_ball;
  1070. break;
  1071. case MT_OPERAND_BALL2 :
  1072. value = fields->f_ball2;
  1073. break;
  1074. case MT_OPERAND_BANKADDR :
  1075. value = fields->f_bankaddr;
  1076. break;
  1077. case MT_OPERAND_BRC :
  1078. value = fields->f_brc;
  1079. break;
  1080. case MT_OPERAND_BRC2 :
  1081. value = fields->f_brc2;
  1082. break;
  1083. case MT_OPERAND_CB1INCR :
  1084. value = fields->f_cb1incr;
  1085. break;
  1086. case MT_OPERAND_CB1SEL :
  1087. value = fields->f_cb1sel;
  1088. break;
  1089. case MT_OPERAND_CB2INCR :
  1090. value = fields->f_cb2incr;
  1091. break;
  1092. case MT_OPERAND_CB2SEL :
  1093. value = fields->f_cb2sel;
  1094. break;
  1095. case MT_OPERAND_CBRB :
  1096. value = fields->f_cbrb;
  1097. break;
  1098. case MT_OPERAND_CBS :
  1099. value = fields->f_cbs;
  1100. break;
  1101. case MT_OPERAND_CBX :
  1102. value = fields->f_cbx;
  1103. break;
  1104. case MT_OPERAND_CCB :
  1105. value = fields->f_ccb;
  1106. break;
  1107. case MT_OPERAND_CDB :
  1108. value = fields->f_cdb;
  1109. break;
  1110. case MT_OPERAND_CELL :
  1111. value = fields->f_cell;
  1112. break;
  1113. case MT_OPERAND_COLNUM :
  1114. value = fields->f_colnum;
  1115. break;
  1116. case MT_OPERAND_CONTNUM :
  1117. value = fields->f_contnum;
  1118. break;
  1119. case MT_OPERAND_CR :
  1120. value = fields->f_cr;
  1121. break;
  1122. case MT_OPERAND_CTXDISP :
  1123. value = fields->f_ctxdisp;
  1124. break;
  1125. case MT_OPERAND_DUP :
  1126. value = fields->f_dup;
  1127. break;
  1128. case MT_OPERAND_FBDISP :
  1129. value = fields->f_fbdisp;
  1130. break;
  1131. case MT_OPERAND_FBINCR :
  1132. value = fields->f_fbincr;
  1133. break;
  1134. case MT_OPERAND_FRDR :
  1135. value = fields->f_dr;
  1136. break;
  1137. case MT_OPERAND_FRDRRR :
  1138. value = fields->f_drrr;
  1139. break;
  1140. case MT_OPERAND_FRSR1 :
  1141. value = fields->f_sr1;
  1142. break;
  1143. case MT_OPERAND_FRSR2 :
  1144. value = fields->f_sr2;
  1145. break;
  1146. case MT_OPERAND_ID :
  1147. value = fields->f_id;
  1148. break;
  1149. case MT_OPERAND_IMM16 :
  1150. value = fields->f_imm16s;
  1151. break;
  1152. case MT_OPERAND_IMM16L :
  1153. value = fields->f_imm16l;
  1154. break;
  1155. case MT_OPERAND_IMM16O :
  1156. value = fields->f_imm16s;
  1157. break;
  1158. case MT_OPERAND_IMM16Z :
  1159. value = fields->f_imm16u;
  1160. break;
  1161. case MT_OPERAND_INCAMT :
  1162. value = fields->f_incamt;
  1163. break;
  1164. case MT_OPERAND_INCR :
  1165. value = fields->f_incr;
  1166. break;
  1167. case MT_OPERAND_LENGTH :
  1168. value = fields->f_length;
  1169. break;
  1170. case MT_OPERAND_LOOPSIZE :
  1171. value = fields->f_loopo;
  1172. break;
  1173. case MT_OPERAND_MASK :
  1174. value = fields->f_mask;
  1175. break;
  1176. case MT_OPERAND_MASK1 :
  1177. value = fields->f_mask1;
  1178. break;
  1179. case MT_OPERAND_MODE :
  1180. value = fields->f_mode;
  1181. break;
  1182. case MT_OPERAND_PERM :
  1183. value = fields->f_perm;
  1184. break;
  1185. case MT_OPERAND_RBBC :
  1186. value = fields->f_rbbc;
  1187. break;
  1188. case MT_OPERAND_RC :
  1189. value = fields->f_rc;
  1190. break;
  1191. case MT_OPERAND_RC1 :
  1192. value = fields->f_rc1;
  1193. break;
  1194. case MT_OPERAND_RC2 :
  1195. value = fields->f_rc2;
  1196. break;
  1197. case MT_OPERAND_RC3 :
  1198. value = fields->f_rc3;
  1199. break;
  1200. case MT_OPERAND_RCNUM :
  1201. value = fields->f_rcnum;
  1202. break;
  1203. case MT_OPERAND_RDA :
  1204. value = fields->f_rda;
  1205. break;
  1206. case MT_OPERAND_ROWNUM :
  1207. value = fields->f_rownum;
  1208. break;
  1209. case MT_OPERAND_ROWNUM1 :
  1210. value = fields->f_rownum1;
  1211. break;
  1212. case MT_OPERAND_ROWNUM2 :
  1213. value = fields->f_rownum2;
  1214. break;
  1215. case MT_OPERAND_SIZE :
  1216. value = fields->f_size;
  1217. break;
  1218. case MT_OPERAND_TYPE :
  1219. value = fields->f_type;
  1220. break;
  1221. case MT_OPERAND_WR :
  1222. value = fields->f_wr;
  1223. break;
  1224. case MT_OPERAND_XMODE :
  1225. value = fields->f_xmode;
  1226. break;
  1227. default :
  1228. /* xgettext:c-format */
  1229. opcodes_error_handler
  1230. (_("internal error: unrecognized field %d while getting vma operand"),
  1231. opindex);
  1232. abort ();
  1233. }
  1234. return value;
  1235. }
  1236. void mt_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
  1237. void mt_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
  1238. /* Stuffing values in cgen_fields is handled by a collection of functions.
  1239. They are distinguished by the type of the VALUE argument they accept.
  1240. TODO: floating point, inlining support, remove cases where argument type
  1241. not appropriate. */
  1242. void
  1243. mt_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  1244. int opindex,
  1245. CGEN_FIELDS * fields,
  1246. int value)
  1247. {
  1248. switch (opindex)
  1249. {
  1250. case MT_OPERAND_A23 :
  1251. fields->f_a23 = value;
  1252. break;
  1253. case MT_OPERAND_BALL :
  1254. fields->f_ball = value;
  1255. break;
  1256. case MT_OPERAND_BALL2 :
  1257. fields->f_ball2 = value;
  1258. break;
  1259. case MT_OPERAND_BANKADDR :
  1260. fields->f_bankaddr = value;
  1261. break;
  1262. case MT_OPERAND_BRC :
  1263. fields->f_brc = value;
  1264. break;
  1265. case MT_OPERAND_BRC2 :
  1266. fields->f_brc2 = value;
  1267. break;
  1268. case MT_OPERAND_CB1INCR :
  1269. fields->f_cb1incr = value;
  1270. break;
  1271. case MT_OPERAND_CB1SEL :
  1272. fields->f_cb1sel = value;
  1273. break;
  1274. case MT_OPERAND_CB2INCR :
  1275. fields->f_cb2incr = value;
  1276. break;
  1277. case MT_OPERAND_CB2SEL :
  1278. fields->f_cb2sel = value;
  1279. break;
  1280. case MT_OPERAND_CBRB :
  1281. fields->f_cbrb = value;
  1282. break;
  1283. case MT_OPERAND_CBS :
  1284. fields->f_cbs = value;
  1285. break;
  1286. case MT_OPERAND_CBX :
  1287. fields->f_cbx = value;
  1288. break;
  1289. case MT_OPERAND_CCB :
  1290. fields->f_ccb = value;
  1291. break;
  1292. case MT_OPERAND_CDB :
  1293. fields->f_cdb = value;
  1294. break;
  1295. case MT_OPERAND_CELL :
  1296. fields->f_cell = value;
  1297. break;
  1298. case MT_OPERAND_COLNUM :
  1299. fields->f_colnum = value;
  1300. break;
  1301. case MT_OPERAND_CONTNUM :
  1302. fields->f_contnum = value;
  1303. break;
  1304. case MT_OPERAND_CR :
  1305. fields->f_cr = value;
  1306. break;
  1307. case MT_OPERAND_CTXDISP :
  1308. fields->f_ctxdisp = value;
  1309. break;
  1310. case MT_OPERAND_DUP :
  1311. fields->f_dup = value;
  1312. break;
  1313. case MT_OPERAND_FBDISP :
  1314. fields->f_fbdisp = value;
  1315. break;
  1316. case MT_OPERAND_FBINCR :
  1317. fields->f_fbincr = value;
  1318. break;
  1319. case MT_OPERAND_FRDR :
  1320. fields->f_dr = value;
  1321. break;
  1322. case MT_OPERAND_FRDRRR :
  1323. fields->f_drrr = value;
  1324. break;
  1325. case MT_OPERAND_FRSR1 :
  1326. fields->f_sr1 = value;
  1327. break;
  1328. case MT_OPERAND_FRSR2 :
  1329. fields->f_sr2 = value;
  1330. break;
  1331. case MT_OPERAND_ID :
  1332. fields->f_id = value;
  1333. break;
  1334. case MT_OPERAND_IMM16 :
  1335. fields->f_imm16s = value;
  1336. break;
  1337. case MT_OPERAND_IMM16L :
  1338. fields->f_imm16l = value;
  1339. break;
  1340. case MT_OPERAND_IMM16O :
  1341. fields->f_imm16s = value;
  1342. break;
  1343. case MT_OPERAND_IMM16Z :
  1344. fields->f_imm16u = value;
  1345. break;
  1346. case MT_OPERAND_INCAMT :
  1347. fields->f_incamt = value;
  1348. break;
  1349. case MT_OPERAND_INCR :
  1350. fields->f_incr = value;
  1351. break;
  1352. case MT_OPERAND_LENGTH :
  1353. fields->f_length = value;
  1354. break;
  1355. case MT_OPERAND_LOOPSIZE :
  1356. fields->f_loopo = value;
  1357. break;
  1358. case MT_OPERAND_MASK :
  1359. fields->f_mask = value;
  1360. break;
  1361. case MT_OPERAND_MASK1 :
  1362. fields->f_mask1 = value;
  1363. break;
  1364. case MT_OPERAND_MODE :
  1365. fields->f_mode = value;
  1366. break;
  1367. case MT_OPERAND_PERM :
  1368. fields->f_perm = value;
  1369. break;
  1370. case MT_OPERAND_RBBC :
  1371. fields->f_rbbc = value;
  1372. break;
  1373. case MT_OPERAND_RC :
  1374. fields->f_rc = value;
  1375. break;
  1376. case MT_OPERAND_RC1 :
  1377. fields->f_rc1 = value;
  1378. break;
  1379. case MT_OPERAND_RC2 :
  1380. fields->f_rc2 = value;
  1381. break;
  1382. case MT_OPERAND_RC3 :
  1383. fields->f_rc3 = value;
  1384. break;
  1385. case MT_OPERAND_RCNUM :
  1386. fields->f_rcnum = value;
  1387. break;
  1388. case MT_OPERAND_RDA :
  1389. fields->f_rda = value;
  1390. break;
  1391. case MT_OPERAND_ROWNUM :
  1392. fields->f_rownum = value;
  1393. break;
  1394. case MT_OPERAND_ROWNUM1 :
  1395. fields->f_rownum1 = value;
  1396. break;
  1397. case MT_OPERAND_ROWNUM2 :
  1398. fields->f_rownum2 = value;
  1399. break;
  1400. case MT_OPERAND_SIZE :
  1401. fields->f_size = value;
  1402. break;
  1403. case MT_OPERAND_TYPE :
  1404. fields->f_type = value;
  1405. break;
  1406. case MT_OPERAND_WR :
  1407. fields->f_wr = value;
  1408. break;
  1409. case MT_OPERAND_XMODE :
  1410. fields->f_xmode = value;
  1411. break;
  1412. default :
  1413. /* xgettext:c-format */
  1414. opcodes_error_handler
  1415. (_("internal error: unrecognized field %d while setting int operand"),
  1416. opindex);
  1417. abort ();
  1418. }
  1419. }
  1420. void
  1421. mt_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  1422. int opindex,
  1423. CGEN_FIELDS * fields,
  1424. bfd_vma value)
  1425. {
  1426. switch (opindex)
  1427. {
  1428. case MT_OPERAND_A23 :
  1429. fields->f_a23 = value;
  1430. break;
  1431. case MT_OPERAND_BALL :
  1432. fields->f_ball = value;
  1433. break;
  1434. case MT_OPERAND_BALL2 :
  1435. fields->f_ball2 = value;
  1436. break;
  1437. case MT_OPERAND_BANKADDR :
  1438. fields->f_bankaddr = value;
  1439. break;
  1440. case MT_OPERAND_BRC :
  1441. fields->f_brc = value;
  1442. break;
  1443. case MT_OPERAND_BRC2 :
  1444. fields->f_brc2 = value;
  1445. break;
  1446. case MT_OPERAND_CB1INCR :
  1447. fields->f_cb1incr = value;
  1448. break;
  1449. case MT_OPERAND_CB1SEL :
  1450. fields->f_cb1sel = value;
  1451. break;
  1452. case MT_OPERAND_CB2INCR :
  1453. fields->f_cb2incr = value;
  1454. break;
  1455. case MT_OPERAND_CB2SEL :
  1456. fields->f_cb2sel = value;
  1457. break;
  1458. case MT_OPERAND_CBRB :
  1459. fields->f_cbrb = value;
  1460. break;
  1461. case MT_OPERAND_CBS :
  1462. fields->f_cbs = value;
  1463. break;
  1464. case MT_OPERAND_CBX :
  1465. fields->f_cbx = value;
  1466. break;
  1467. case MT_OPERAND_CCB :
  1468. fields->f_ccb = value;
  1469. break;
  1470. case MT_OPERAND_CDB :
  1471. fields->f_cdb = value;
  1472. break;
  1473. case MT_OPERAND_CELL :
  1474. fields->f_cell = value;
  1475. break;
  1476. case MT_OPERAND_COLNUM :
  1477. fields->f_colnum = value;
  1478. break;
  1479. case MT_OPERAND_CONTNUM :
  1480. fields->f_contnum = value;
  1481. break;
  1482. case MT_OPERAND_CR :
  1483. fields->f_cr = value;
  1484. break;
  1485. case MT_OPERAND_CTXDISP :
  1486. fields->f_ctxdisp = value;
  1487. break;
  1488. case MT_OPERAND_DUP :
  1489. fields->f_dup = value;
  1490. break;
  1491. case MT_OPERAND_FBDISP :
  1492. fields->f_fbdisp = value;
  1493. break;
  1494. case MT_OPERAND_FBINCR :
  1495. fields->f_fbincr = value;
  1496. break;
  1497. case MT_OPERAND_FRDR :
  1498. fields->f_dr = value;
  1499. break;
  1500. case MT_OPERAND_FRDRRR :
  1501. fields->f_drrr = value;
  1502. break;
  1503. case MT_OPERAND_FRSR1 :
  1504. fields->f_sr1 = value;
  1505. break;
  1506. case MT_OPERAND_FRSR2 :
  1507. fields->f_sr2 = value;
  1508. break;
  1509. case MT_OPERAND_ID :
  1510. fields->f_id = value;
  1511. break;
  1512. case MT_OPERAND_IMM16 :
  1513. fields->f_imm16s = value;
  1514. break;
  1515. case MT_OPERAND_IMM16L :
  1516. fields->f_imm16l = value;
  1517. break;
  1518. case MT_OPERAND_IMM16O :
  1519. fields->f_imm16s = value;
  1520. break;
  1521. case MT_OPERAND_IMM16Z :
  1522. fields->f_imm16u = value;
  1523. break;
  1524. case MT_OPERAND_INCAMT :
  1525. fields->f_incamt = value;
  1526. break;
  1527. case MT_OPERAND_INCR :
  1528. fields->f_incr = value;
  1529. break;
  1530. case MT_OPERAND_LENGTH :
  1531. fields->f_length = value;
  1532. break;
  1533. case MT_OPERAND_LOOPSIZE :
  1534. fields->f_loopo = value;
  1535. break;
  1536. case MT_OPERAND_MASK :
  1537. fields->f_mask = value;
  1538. break;
  1539. case MT_OPERAND_MASK1 :
  1540. fields->f_mask1 = value;
  1541. break;
  1542. case MT_OPERAND_MODE :
  1543. fields->f_mode = value;
  1544. break;
  1545. case MT_OPERAND_PERM :
  1546. fields->f_perm = value;
  1547. break;
  1548. case MT_OPERAND_RBBC :
  1549. fields->f_rbbc = value;
  1550. break;
  1551. case MT_OPERAND_RC :
  1552. fields->f_rc = value;
  1553. break;
  1554. case MT_OPERAND_RC1 :
  1555. fields->f_rc1 = value;
  1556. break;
  1557. case MT_OPERAND_RC2 :
  1558. fields->f_rc2 = value;
  1559. break;
  1560. case MT_OPERAND_RC3 :
  1561. fields->f_rc3 = value;
  1562. break;
  1563. case MT_OPERAND_RCNUM :
  1564. fields->f_rcnum = value;
  1565. break;
  1566. case MT_OPERAND_RDA :
  1567. fields->f_rda = value;
  1568. break;
  1569. case MT_OPERAND_ROWNUM :
  1570. fields->f_rownum = value;
  1571. break;
  1572. case MT_OPERAND_ROWNUM1 :
  1573. fields->f_rownum1 = value;
  1574. break;
  1575. case MT_OPERAND_ROWNUM2 :
  1576. fields->f_rownum2 = value;
  1577. break;
  1578. case MT_OPERAND_SIZE :
  1579. fields->f_size = value;
  1580. break;
  1581. case MT_OPERAND_TYPE :
  1582. fields->f_type = value;
  1583. break;
  1584. case MT_OPERAND_WR :
  1585. fields->f_wr = value;
  1586. break;
  1587. case MT_OPERAND_XMODE :
  1588. fields->f_xmode = value;
  1589. break;
  1590. default :
  1591. /* xgettext:c-format */
  1592. opcodes_error_handler
  1593. (_("internal error: unrecognized field %d while setting vma operand"),
  1594. opindex);
  1595. abort ();
  1596. }
  1597. }
  1598. /* Function to call before using the instruction builder tables. */
  1599. void
  1600. mt_cgen_init_ibld_table (CGEN_CPU_DESC cd)
  1601. {
  1602. cd->insert_handlers = & mt_cgen_insert_handlers[0];
  1603. cd->extract_handlers = & mt_cgen_extract_handlers[0];
  1604. cd->insert_operand = mt_cgen_insert_operand;
  1605. cd->extract_operand = mt_cgen_extract_operand;
  1606. cd->get_int_operand = mt_cgen_get_int_operand;
  1607. cd->set_int_operand = mt_cgen_set_int_operand;
  1608. cd->get_vma_operand = mt_cgen_get_vma_operand;
  1609. cd->set_vma_operand = mt_cgen_set_vma_operand;
  1610. }