or1k-dis.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
  2. /* Disassembler interface for targets using CGEN. -*- C -*-
  3. CGEN: Cpu tools GENerator
  4. THIS FILE IS MACHINE GENERATED WITH CGEN.
  5. - the resultant file is machine generated, cgen-dis.in isn't
  6. Copyright (C) 1996-2022 Free Software Foundation, Inc.
  7. This file is part of libopcodes.
  8. This library is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 3, or (at your option)
  11. any later version.
  12. It is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  14. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  15. License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software Foundation, Inc.,
  18. 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
  19. /* ??? Eventually more and more of this stuff can go to cpu-independent files.
  20. Keep that in mind. */
  21. #include "sysdep.h"
  22. #include <stdio.h>
  23. #include "ansidecl.h"
  24. #include "disassemble.h"
  25. #include "bfd.h"
  26. #include "symcat.h"
  27. #include "libiberty.h"
  28. #include "or1k-desc.h"
  29. #include "or1k-opc.h"
  30. #include "opintl.h"
  31. /* Default text to print if an instruction isn't recognized. */
  32. #define UNKNOWN_INSN_MSG _("*unknown*")
  33. static void print_normal
  34. (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
  35. static void print_address
  36. (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED;
  37. static void print_keyword
  38. (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED;
  39. static void print_insn_normal
  40. (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int);
  41. static int print_insn
  42. (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned);
  43. static int default_print_insn
  44. (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED;
  45. static int read_insn
  46. (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *,
  47. unsigned long *);
  48. /* -- disassembler routines inserted here. */
  49. /* -- dis.c */
  50. static void
  51. print_regpair (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  52. void * dis_info,
  53. long value,
  54. unsigned int attrs ATTRIBUTE_UNUSED,
  55. bfd_vma pc ATTRIBUTE_UNUSED,
  56. int length ATTRIBUTE_UNUSED)
  57. {
  58. disassemble_info *info = dis_info;
  59. char reg1_index;
  60. char reg2_index;
  61. reg1_index = value & 0x1f;
  62. reg2_index = reg1_index + ((value & (1 << 5)) ? 2 : 1);
  63. (*info->fprintf_func) (info->stream, "r%d,r%d", reg1_index, reg2_index);
  64. }
  65. /* -- */
  66. void or1k_cgen_print_operand
  67. (CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, void const *, bfd_vma, int);
  68. /* Main entry point for printing operands.
  69. XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
  70. of dis-asm.h on cgen.h.
  71. This function is basically just a big switch statement. Earlier versions
  72. used tables to look up the function to use, but
  73. - if the table contains both assembler and disassembler functions then
  74. the disassembler contains much of the assembler and vice-versa,
  75. - there's a lot of inlining possibilities as things grow,
  76. - using a switch statement avoids the function call overhead.
  77. This function could be moved into `print_insn_normal', but keeping it
  78. separate makes clear the interface between `print_insn_normal' and each of
  79. the handlers. */
  80. void
  81. or1k_cgen_print_operand (CGEN_CPU_DESC cd,
  82. int opindex,
  83. void * xinfo,
  84. CGEN_FIELDS *fields,
  85. void const *attrs ATTRIBUTE_UNUSED,
  86. bfd_vma pc,
  87. int length)
  88. {
  89. disassemble_info *info = (disassemble_info *) xinfo;
  90. switch (opindex)
  91. {
  92. case OR1K_OPERAND_DISP21 :
  93. print_address (cd, info, fields->f_disp21, 0|(1<<CGEN_OPERAND_ABS_ADDR), pc, length);
  94. break;
  95. case OR1K_OPERAND_DISP26 :
  96. print_address (cd, info, fields->f_disp26, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
  97. break;
  98. case OR1K_OPERAND_RA :
  99. print_keyword (cd, info, & or1k_cgen_opval_h_gpr, fields->f_r2, 0);
  100. break;
  101. case OR1K_OPERAND_RAD32F :
  102. print_regpair (cd, info, fields->f_rad32, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  103. break;
  104. case OR1K_OPERAND_RADI :
  105. print_regpair (cd, info, fields->f_rad32, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  106. break;
  107. case OR1K_OPERAND_RASF :
  108. print_keyword (cd, info, & or1k_cgen_opval_h_fsr, fields->f_r2, 0);
  109. break;
  110. case OR1K_OPERAND_RB :
  111. print_keyword (cd, info, & or1k_cgen_opval_h_gpr, fields->f_r3, 0);
  112. break;
  113. case OR1K_OPERAND_RBD32F :
  114. print_regpair (cd, info, fields->f_rbd32, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  115. break;
  116. case OR1K_OPERAND_RBDI :
  117. print_regpair (cd, info, fields->f_rbd32, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  118. break;
  119. case OR1K_OPERAND_RBSF :
  120. print_keyword (cd, info, & or1k_cgen_opval_h_fsr, fields->f_r3, 0);
  121. break;
  122. case OR1K_OPERAND_RD :
  123. print_keyword (cd, info, & or1k_cgen_opval_h_gpr, fields->f_r1, 0);
  124. break;
  125. case OR1K_OPERAND_RDD32F :
  126. print_regpair (cd, info, fields->f_rdd32, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  127. break;
  128. case OR1K_OPERAND_RDDI :
  129. print_regpair (cd, info, fields->f_rdd32, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  130. break;
  131. case OR1K_OPERAND_RDSF :
  132. print_keyword (cd, info, & or1k_cgen_opval_h_fsr, fields->f_r1, 0);
  133. break;
  134. case OR1K_OPERAND_SIMM16 :
  135. print_normal (cd, info, fields->f_simm16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_SIGN_OPT), pc, length);
  136. break;
  137. case OR1K_OPERAND_SIMM16_SPLIT :
  138. print_normal (cd, info, fields->f_simm16_split, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_SIGN_OPT)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  139. break;
  140. case OR1K_OPERAND_UIMM16 :
  141. print_normal (cd, info, fields->f_uimm16, 0, pc, length);
  142. break;
  143. case OR1K_OPERAND_UIMM16_SPLIT :
  144. print_normal (cd, info, fields->f_uimm16_split, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
  145. break;
  146. case OR1K_OPERAND_UIMM6 :
  147. print_normal (cd, info, fields->f_uimm6, 0, pc, length);
  148. break;
  149. default :
  150. /* xgettext:c-format */
  151. opcodes_error_handler
  152. (_("internal error: unrecognized field %d while printing insn"),
  153. opindex);
  154. abort ();
  155. }
  156. }
  157. cgen_print_fn * const or1k_cgen_print_handlers[] =
  158. {
  159. print_insn_normal,
  160. };
  161. void
  162. or1k_cgen_init_dis (CGEN_CPU_DESC cd)
  163. {
  164. or1k_cgen_init_opcode_table (cd);
  165. or1k_cgen_init_ibld_table (cd);
  166. cd->print_handlers = & or1k_cgen_print_handlers[0];
  167. cd->print_operand = or1k_cgen_print_operand;
  168. }
  169. /* Default print handler. */
  170. static void
  171. print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  172. void *dis_info,
  173. long value,
  174. unsigned int attrs,
  175. bfd_vma pc ATTRIBUTE_UNUSED,
  176. int length ATTRIBUTE_UNUSED)
  177. {
  178. disassemble_info *info = (disassemble_info *) dis_info;
  179. /* Print the operand as directed by the attributes. */
  180. if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
  181. ; /* nothing to do */
  182. else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
  183. (*info->fprintf_func) (info->stream, "%ld", value);
  184. else
  185. (*info->fprintf_func) (info->stream, "0x%lx", value);
  186. }
  187. /* Default address handler. */
  188. static void
  189. print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  190. void *dis_info,
  191. bfd_vma value,
  192. unsigned int attrs,
  193. bfd_vma pc ATTRIBUTE_UNUSED,
  194. int length ATTRIBUTE_UNUSED)
  195. {
  196. disassemble_info *info = (disassemble_info *) dis_info;
  197. /* Print the operand as directed by the attributes. */
  198. if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
  199. ; /* Nothing to do. */
  200. else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
  201. (*info->print_address_func) (value, info);
  202. else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
  203. (*info->print_address_func) (value, info);
  204. else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
  205. (*info->fprintf_func) (info->stream, "%ld", (long) value);
  206. else
  207. (*info->fprintf_func) (info->stream, "0x%lx", (long) value);
  208. }
  209. /* Keyword print handler. */
  210. static void
  211. print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  212. void *dis_info,
  213. CGEN_KEYWORD *keyword_table,
  214. long value,
  215. unsigned int attrs ATTRIBUTE_UNUSED)
  216. {
  217. disassemble_info *info = (disassemble_info *) dis_info;
  218. const CGEN_KEYWORD_ENTRY *ke;
  219. ke = cgen_keyword_lookup_value (keyword_table, value);
  220. if (ke != NULL)
  221. (*info->fprintf_func) (info->stream, "%s", ke->name);
  222. else
  223. (*info->fprintf_func) (info->stream, "???");
  224. }
  225. /* Default insn printer.
  226. DIS_INFO is defined as `void *' so the disassembler needn't know anything
  227. about disassemble_info. */
  228. static void
  229. print_insn_normal (CGEN_CPU_DESC cd,
  230. void *dis_info,
  231. const CGEN_INSN *insn,
  232. CGEN_FIELDS *fields,
  233. bfd_vma pc,
  234. int length)
  235. {
  236. const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
  237. disassemble_info *info = (disassemble_info *) dis_info;
  238. const CGEN_SYNTAX_CHAR_TYPE *syn;
  239. CGEN_INIT_PRINT (cd);
  240. for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
  241. {
  242. if (CGEN_SYNTAX_MNEMONIC_P (*syn))
  243. {
  244. (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
  245. continue;
  246. }
  247. if (CGEN_SYNTAX_CHAR_P (*syn))
  248. {
  249. (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
  250. continue;
  251. }
  252. /* We have an operand. */
  253. or1k_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
  254. fields, CGEN_INSN_ATTRS (insn), pc, length);
  255. }
  256. }
  257. /* Subroutine of print_insn. Reads an insn into the given buffers and updates
  258. the extract info.
  259. Returns 0 if all is well, non-zero otherwise. */
  260. static int
  261. read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
  262. bfd_vma pc,
  263. disassemble_info *info,
  264. bfd_byte *buf,
  265. int buflen,
  266. CGEN_EXTRACT_INFO *ex_info,
  267. unsigned long *insn_value)
  268. {
  269. int status = (*info->read_memory_func) (pc, buf, buflen, info);
  270. if (status != 0)
  271. {
  272. (*info->memory_error_func) (status, pc, info);
  273. return -1;
  274. }
  275. ex_info->dis_info = info;
  276. ex_info->valid = (1 << buflen) - 1;
  277. ex_info->insn_bytes = buf;
  278. *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG);
  279. return 0;
  280. }
  281. /* Utility to print an insn.
  282. BUF is the base part of the insn, target byte order, BUFLEN bytes long.
  283. The result is the size of the insn in bytes or zero for an unknown insn
  284. or -1 if an error occurs fetching data (memory_error_func will have
  285. been called). */
  286. static int
  287. print_insn (CGEN_CPU_DESC cd,
  288. bfd_vma pc,
  289. disassemble_info *info,
  290. bfd_byte *buf,
  291. unsigned int buflen)
  292. {
  293. CGEN_INSN_INT insn_value;
  294. const CGEN_INSN_LIST *insn_list;
  295. CGEN_EXTRACT_INFO ex_info;
  296. int basesize;
  297. /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
  298. basesize = cd->base_insn_bitsize < buflen * 8 ?
  299. cd->base_insn_bitsize : buflen * 8;
  300. insn_value = cgen_get_insn_value (cd, buf, basesize, cd->insn_endian);
  301. /* Fill in ex_info fields like read_insn would. Don't actually call
  302. read_insn, since the incoming buffer is already read (and possibly
  303. modified a la m32r). */
  304. ex_info.valid = (1 << buflen) - 1;
  305. ex_info.dis_info = info;
  306. ex_info.insn_bytes = buf;
  307. /* The instructions are stored in hash lists.
  308. Pick the first one and keep trying until we find the right one. */
  309. insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value);
  310. while (insn_list != NULL)
  311. {
  312. const CGEN_INSN *insn = insn_list->insn;
  313. CGEN_FIELDS fields;
  314. int length;
  315. unsigned long insn_value_cropped;
  316. #ifdef CGEN_VALIDATE_INSN_SUPPORTED
  317. /* Not needed as insn shouldn't be in hash lists if not supported. */
  318. /* Supported by this cpu? */
  319. if (! or1k_cgen_insn_supported (cd, insn))
  320. {
  321. insn_list = CGEN_DIS_NEXT_INSN (insn_list);
  322. continue;
  323. }
  324. #endif
  325. /* Basic bit mask must be correct. */
  326. /* ??? May wish to allow target to defer this check until the extract
  327. handler. */
  328. /* Base size may exceed this instruction's size. Extract the
  329. relevant part from the buffer. */
  330. if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen &&
  331. (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
  332. insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn),
  333. info->endian == BFD_ENDIAN_BIG);
  334. else
  335. insn_value_cropped = insn_value;
  336. if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn))
  337. == CGEN_INSN_BASE_VALUE (insn))
  338. {
  339. /* Printing is handled in two passes. The first pass parses the
  340. machine insn and extracts the fields. The second pass prints
  341. them. */
  342. /* Make sure the entire insn is loaded into insn_value, if it
  343. can fit. */
  344. if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) &&
  345. (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
  346. {
  347. unsigned long full_insn_value;
  348. int rc = read_insn (cd, pc, info, buf,
  349. CGEN_INSN_BITSIZE (insn) / 8,
  350. & ex_info, & full_insn_value);
  351. if (rc != 0)
  352. return rc;
  353. length = CGEN_EXTRACT_FN (cd, insn)
  354. (cd, insn, &ex_info, full_insn_value, &fields, pc);
  355. }
  356. else
  357. length = CGEN_EXTRACT_FN (cd, insn)
  358. (cd, insn, &ex_info, insn_value_cropped, &fields, pc);
  359. /* Length < 0 -> error. */
  360. if (length < 0)
  361. return length;
  362. if (length > 0)
  363. {
  364. CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
  365. /* Length is in bits, result is in bytes. */
  366. return length / 8;
  367. }
  368. }
  369. insn_list = CGEN_DIS_NEXT_INSN (insn_list);
  370. }
  371. return 0;
  372. }
  373. /* Default value for CGEN_PRINT_INSN.
  374. The result is the size of the insn in bytes or zero for an unknown insn
  375. or -1 if an error occured fetching bytes. */
  376. #ifndef CGEN_PRINT_INSN
  377. #define CGEN_PRINT_INSN default_print_insn
  378. #endif
  379. static int
  380. default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info)
  381. {
  382. bfd_byte buf[CGEN_MAX_INSN_SIZE];
  383. int buflen;
  384. int status;
  385. /* Attempt to read the base part of the insn. */
  386. buflen = cd->base_insn_bitsize / 8;
  387. status = (*info->read_memory_func) (pc, buf, buflen, info);
  388. /* Try again with the minimum part, if min < base. */
  389. if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize))
  390. {
  391. buflen = cd->min_insn_bitsize / 8;
  392. status = (*info->read_memory_func) (pc, buf, buflen, info);
  393. }
  394. if (status != 0)
  395. {
  396. (*info->memory_error_func) (status, pc, info);
  397. return -1;
  398. }
  399. return print_insn (cd, pc, info, buf, buflen);
  400. }
  401. /* Main entry point.
  402. Print one instruction from PC on INFO->STREAM.
  403. Return the size of the instruction (in bytes). */
  404. typedef struct cpu_desc_list
  405. {
  406. struct cpu_desc_list *next;
  407. CGEN_BITSET *isa;
  408. int mach;
  409. int endian;
  410. int insn_endian;
  411. CGEN_CPU_DESC cd;
  412. } cpu_desc_list;
  413. int
  414. print_insn_or1k (bfd_vma pc, disassemble_info *info)
  415. {
  416. static cpu_desc_list *cd_list = 0;
  417. cpu_desc_list *cl = 0;
  418. static CGEN_CPU_DESC cd = 0;
  419. static CGEN_BITSET *prev_isa;
  420. static int prev_mach;
  421. static int prev_endian;
  422. static int prev_insn_endian;
  423. int length;
  424. CGEN_BITSET *isa;
  425. int mach;
  426. int endian = (info->endian == BFD_ENDIAN_BIG
  427. ? CGEN_ENDIAN_BIG
  428. : CGEN_ENDIAN_LITTLE);
  429. int insn_endian = (info->endian_code == BFD_ENDIAN_BIG
  430. ? CGEN_ENDIAN_BIG
  431. : CGEN_ENDIAN_LITTLE);
  432. enum bfd_architecture arch;
  433. /* ??? gdb will set mach but leave the architecture as "unknown" */
  434. #ifndef CGEN_BFD_ARCH
  435. #define CGEN_BFD_ARCH bfd_arch_or1k
  436. #endif
  437. arch = info->arch;
  438. if (arch == bfd_arch_unknown)
  439. arch = CGEN_BFD_ARCH;
  440. /* There's no standard way to compute the machine or isa number
  441. so we leave it to the target. */
  442. #ifdef CGEN_COMPUTE_MACH
  443. mach = CGEN_COMPUTE_MACH (info);
  444. #else
  445. mach = info->mach;
  446. #endif
  447. #ifdef CGEN_COMPUTE_ISA
  448. {
  449. static CGEN_BITSET *permanent_isa;
  450. if (!permanent_isa)
  451. permanent_isa = cgen_bitset_create (MAX_ISAS);
  452. isa = permanent_isa;
  453. cgen_bitset_clear (isa);
  454. cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info));
  455. }
  456. #else
  457. isa = info->private_data;
  458. #endif
  459. /* If we've switched cpu's, try to find a handle we've used before */
  460. if (cd
  461. && (cgen_bitset_compare (isa, prev_isa) != 0
  462. || mach != prev_mach
  463. || endian != prev_endian))
  464. {
  465. cd = 0;
  466. for (cl = cd_list; cl; cl = cl->next)
  467. {
  468. if (cgen_bitset_compare (cl->isa, isa) == 0 &&
  469. cl->mach == mach &&
  470. cl->endian == endian)
  471. {
  472. cd = cl->cd;
  473. prev_isa = cd->isas;
  474. break;
  475. }
  476. }
  477. }
  478. /* If we haven't initialized yet, initialize the opcode table. */
  479. if (! cd)
  480. {
  481. const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
  482. const char *mach_name;
  483. if (!arch_type)
  484. abort ();
  485. mach_name = arch_type->printable_name;
  486. prev_isa = cgen_bitset_copy (isa);
  487. prev_mach = mach;
  488. prev_endian = endian;
  489. prev_insn_endian = insn_endian;
  490. cd = or1k_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
  491. CGEN_CPU_OPEN_BFDMACH, mach_name,
  492. CGEN_CPU_OPEN_ENDIAN, prev_endian,
  493. CGEN_CPU_OPEN_INSN_ENDIAN, prev_insn_endian,
  494. CGEN_CPU_OPEN_END);
  495. if (!cd)
  496. abort ();
  497. /* Save this away for future reference. */
  498. cl = xmalloc (sizeof (struct cpu_desc_list));
  499. cl->cd = cd;
  500. cl->isa = prev_isa;
  501. cl->mach = mach;
  502. cl->endian = endian;
  503. cl->next = cd_list;
  504. cd_list = cl;
  505. or1k_cgen_init_dis (cd);
  506. }
  507. /* We try to have as much common code as possible.
  508. But at this point some targets need to take over. */
  509. /* ??? Some targets may need a hook elsewhere. Try to avoid this,
  510. but if not possible try to move this hook elsewhere rather than
  511. have two hooks. */
  512. length = CGEN_PRINT_INSN (cd, pc, info);
  513. if (length > 0)
  514. return length;
  515. if (length < 0)
  516. return -1;
  517. (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
  518. return cd->default_insn_bitsize / 8;
  519. }