1 ; Assembler/disassembler support generator.
2 ; Copyright (C) 2000 Red Hat, Inc.
3 ; This file is part of CGEN.
7 (define (-gen-parse-switch)
8 (logit 2 "Generating parse switch ...\n")
11 /* Main entry point for operand parsing.
13 This function is basically just a big switch statement. Earlier versions
14 used tables to look up the function to use, but
15 - if the table contains both assembler and disassembler functions then
16 the disassembler contains much of the assembler and vice-versa,
17 - there's a lot of inlining possibilities as things grow,
18 - using a switch statement avoids the function call overhead.
20 This function could be moved into `parse_insn_normal', but keeping it
21 separate makes clear the interface between `parse_insn_normal' and each of
26 @arch@_cgen_parse_operand (cd, opindex, strp, fields)
32 const char * errmsg = NULL;
33 /* Used by scalar operands that still need to be parsed. */
34 " (gen-ifield-default-type) " junk;
42 /* xgettext:c-format */
43 fprintf (stderr, _(\"Unrecognized field %d while parsing.\\n\"), opindex);
51 ; Assembler initialization C code
52 ; Code is appended during processing.
54 (define -asm-init-code "")
55 (define (add-asm-init code)
56 (set! -asm-init-code (string-append -asm-init-code code))
59 ; Return C code to define the assembler init function.
60 ; This is called after opcode_open.
62 (define (-gen-init-asm-fn)
66 @arch@_cgen_init_asm (cd)
69 @arch@_cgen_init_opcode_table (cd);
70 @arch@_cgen_init_ibld_table (cd);
71 cd->parse_handlers = & @arch@_cgen_parse_handlers[0];
72 cd->parse_operand = @arch@_cgen_parse_operand;
79 ; Generate C code that is inserted into the assembler source.
82 (logit 1 "Generating " (current-arch-name) "-asm.in ...\n")
84 ; No need for copyright, appended to file with one.
86 (lambda () (gen-extra-asm.c srcdir (current-arch-name))) ; from <arch>.opc
89 (lambda () (gen-handler-table "parse" opc-parse-handlers))
94 ; Disassembler support.
96 (define (-gen-print-switch)
97 (logit 2 "Generating print switch ...\n")
100 /* Main entry point for printing operands.
101 XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
102 of dis-asm.h on cgen.h.
104 This function is basically just a big switch statement. Earlier versions
105 used tables to look up the function to use, but
106 - if the table contains both assembler and disassembler functions then
107 the disassembler contains much of the assembler and vice-versa,
108 - there's a lot of inlining possibilities as things grow,
109 - using a switch statement avoids the function call overhead.
111 This function could be moved into `print_insn_normal', but keeping it
112 separate makes clear the interface between `print_insn_normal' and each of
117 @arch@_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length)
126 disassemble_info *info = (disassemble_info *) xinfo;
134 /* xgettext:c-format */
135 fprintf (stderr, _(\"Unrecognized field %d while printing insn.\\n\"),
142 ; Disassembler initialization C code.
143 ; Code is appended during processing.
145 (define -dis-init-code "")
146 (define (add-dis-init code)
147 (set! -dis-init-code (string-append -dis-init-code code))
150 ; Return C code to define the disassembler init function.
152 (define (-gen-init-dis-fn)
156 @arch@_cgen_init_dis (cd)
159 @arch@_cgen_init_opcode_table (cd);
160 @arch@_cgen_init_ibld_table (cd);
161 cd->print_handlers = & @arch@_cgen_print_handlers[0];
162 cd->print_operand = @arch@_cgen_print_operand;
169 ; Generate C code that is inserted into the disassembler source.
171 (define (cgen-dis.in)
172 (logit 1 "Generating " (current-arch-name) "-dis.in ...\n")
174 ; No need for copyright, appended to file with one.
176 (lambda () (gen-extra-dis.c srcdir (current-arch-name))) ; from <arch>.opc
179 (lambda () (gen-handler-table "print" opc-print-handlers))