* ld-insn.c (load_insn_table): Terminate error with NL.
[platform/upstream/binutils.git] / sim / igen / gen-icache.c
1 /*  This file is part of the program psim.
2
3     Copyright (C) 1994-1998, Andrew Cagney <cagney@highland.com.au>
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  
19     */
20
21
22 #include "misc.h"
23 #include "lf.h"
24 #include "table.h"
25 #include "filter.h"
26 #include "igen.h"
27
28 #include "ld-insn.h"
29 #include "ld-decode.h"
30
31 #include "gen.h"
32
33 #include "gen-semantics.h"
34 #include "gen-idecode.h"
35 #include "gen-icache.h"
36
37
38
39 static void
40 print_icache_function_header (lf *file,
41                               const char *basename,
42                               const char *format_name,
43                               opcode_bits *expanded_bits,
44                               int is_function_definition,
45                               int nr_prefetched_words)
46 {
47   lf_printf(file, "\n");
48   lf_print__function_type_function (file, print_icache_function_type,
49                                     "EXTERN_ICACHE", " ");
50   print_function_name (file,
51                        basename, format_name, NULL,
52                        expanded_bits,
53                        function_name_prefix_icache);
54   lf_printf (file, "\n(");
55   print_icache_function_formal (file, nr_prefetched_words);
56   lf_printf (file, ")");
57   if (!is_function_definition)
58     lf_printf (file, ";");
59   lf_printf (file, "\n");
60 }
61
62
63 void
64 print_icache_declaration (lf *file,
65                           insn_entry *insn,
66                           opcode_bits *expanded_bits,
67                           insn_opcodes *opcodes,
68                           int nr_prefetched_words)
69 {
70   print_icache_function_header (file,
71                                 insn->name,
72                                 insn->format_name,
73                                 expanded_bits,
74                                 0/* is not function definition */,
75                                 nr_prefetched_words);
76 }
77
78
79
80 static void
81 print_icache_extraction (lf *file,
82                          const char *format_name,
83                          cache_entry_type cache_type,
84                          const char *entry_name,
85                          const char *entry_type,
86                          const char *entry_expression,
87                          char *single_insn_field,
88                          line_ref *line,
89                          insn_field_entry *cur_field,
90                          opcode_bits *expanded_bits,
91                          icache_decl_type what_to_declare,
92                          icache_body_type what_to_do)
93 {
94   const char *expression;
95   opcode_bits *bits;
96   char *reason;
97   ASSERT (format_name != NULL);
98   ASSERT (entry_name != NULL);
99   
100   /* figure out exactly what should be going on here */
101   switch (cache_type)
102     {
103     case scratch_value:
104       if ((what_to_do & put_values_in_icache)
105           || what_to_do == do_not_use_icache)
106         {
107           reason = "scratch";
108           what_to_do = do_not_use_icache;
109         }
110       else
111         return;
112       break;
113     case compute_value:
114       if ((what_to_do & get_values_from_icache)
115           || what_to_do == do_not_use_icache)
116         {
117           reason = "compute";
118           what_to_do = do_not_use_icache;
119         }
120       else
121         return;
122       break;
123     case cache_value:
124       if ((what_to_declare != undef_variables)
125           || !(what_to_do & put_values_in_icache))
126         {
127           reason = "cache";
128           what_to_declare = ((what_to_do & put_values_in_icache)
129                              ? declare_variables
130                              : what_to_declare);
131         }
132       else
133         return;
134       break;
135     }
136   
137   /* For the type, default to a simple unsigned */
138   if (entry_type == NULL || strlen (entry_type) == 0)
139     entry_type = "unsigned";
140   
141   /* look through the set of expanded sub fields to see if this field
142      has been given a constant value */
143   for (bits = expanded_bits;
144        bits != NULL;
145        bits = bits->next)
146     {
147       if (bits->field == cur_field)
148         break;
149     }
150   
151   /* Define a storage area for the cache element */
152   switch (what_to_declare)
153     {
154     case undef_variables:
155       /* We've finished with the #define value - destory it */
156       lf_indent_suppress (file);
157       lf_printf (file, "#undef %s\n", entry_name);
158       return;
159     case define_variables:
160       /* Using direct access for this entry, define it */
161       lf_indent_suppress (file);
162       lf_printf (file, "#define %s ((%s) ", entry_name, entry_type);
163       break;
164     case declare_variables:
165       /* using variables to define the value */
166       if (line != NULL)
167         lf_print__line_ref (file, line);
168       lf_printf (file, "%s const %s UNUSED = ", entry_type, entry_name);
169       break;
170     }
171   
172   
173   /* define a value for that storage area as determined by what is in
174      the cache */
175   if (bits != NULL
176       && single_insn_field != NULL
177       && strcmp (entry_name, single_insn_field) == 0
178       && strcmp (entry_name, cur_field->val_string) == 0
179       && ((bits->opcode->is_boolean && bits->value == 0)
180           || (!bits->opcode->is_boolean)))
181     {
182       /* The cache rule is specifying what to do with a simple
183          instruction field.
184          
185          Because of instruction expansion, the field is either a
186          constant value or equal to the specified constant (boolean
187          comparison). (The latter indicated by bits->value == 0).
188          
189          The case of a field not being equal to the specified boolean
190          value is handled later. */
191       expression = "constant field";
192       ASSERT (bits->field == cur_field);
193       if (bits->opcode->is_boolean)
194         {
195           ASSERT (bits->value == 0);
196           lf_printf (file, "%d", bits->opcode->boolean_constant);
197         }
198       else if (bits->opcode->last < bits->field->last)
199         {
200           lf_printf (file, "%d",
201                      bits->value << (bits->field->last - bits->opcode->last));
202         }
203       else
204         {
205           lf_printf (file, "%d", bits->value);
206         }
207     }
208   else if (bits != NULL
209            && single_insn_field != NULL
210            && strncmp (entry_name,
211                        single_insn_field,
212                        strlen (single_insn_field)) == 0
213            && strncmp (entry_name + strlen (single_insn_field),
214                        "_is_",
215                        strlen ("_is_")) == 0
216            && ((bits->opcode->is_boolean
217                 && ((unsigned) atol (entry_name + strlen (single_insn_field) + strlen ("_is_"))
218                     == bits->opcode->boolean_constant))
219                || (!bits->opcode->is_boolean)))
220     {
221       /* The cache rule defines an entry for the comparison between a
222          single instruction field and a constant.  The value of the
223          comparison in someway matches that of the opcode field that
224          was made constant through expansion. */
225       expression = "constant compare";
226       if (bits->opcode->is_boolean)
227         {
228           lf_printf (file, "%d /* %s == %d */",
229                      bits->value == 0,
230                      single_insn_field,
231                      bits->opcode->boolean_constant);
232         }
233       else if (bits->opcode->last < bits->field->last)
234         {
235           lf_printf (file, "%d /* %s == %d */",
236                      (atol (entry_name + strlen (single_insn_field) + strlen ("_is_"))
237                       == (bits->value << (bits->field->last - bits->opcode->last))),
238                      single_insn_field,
239                      (bits->value << (bits->field->last - bits->opcode->last)));
240         }
241       else
242         {
243           lf_printf (file, "%d /* %s == %d */",
244                      (atol (entry_name + strlen (single_insn_field) + strlen ("_is_"))
245                       == bits->value),
246                      single_insn_field,
247                      bits->value);
248         }
249     }
250   else
251     {
252       /* put the field in the local variable, possibly also enter it
253          into the cache */
254       expression = "extraction";
255       /* handle the cache */
256       if ((what_to_do & get_values_from_icache)
257           || (what_to_do & put_values_in_icache))
258         {
259           lf_printf (file, "cache_entry->crack.%s.%s",
260                      format_name,
261                      entry_name);
262           if (what_to_do & put_values_in_icache) /* also put it in the cache? */
263             {
264               lf_printf (file, " = ");
265             }
266         }
267       if ((what_to_do & put_values_in_icache)
268           || what_to_do == do_not_use_icache)
269         {
270           if (cur_field != NULL)
271             {
272               if (entry_expression != NULL && strlen (entry_expression) > 0)
273                 error (line, "Instruction field entry with nonempty expression\n");
274               if (cur_field->first == 0 && cur_field->last == options.insn_bit_size - 1)
275                 lf_printf (file, "(instruction_%d)",
276                            cur_field->word_nr);
277               else if (cur_field->last == options.insn_bit_size - 1)
278                 lf_printf (file, "MASKED%d (instruction_%d, %d, %d)",
279                            options.insn_bit_size,
280                            cur_field->word_nr,
281                            i2target (options.hi_bit_nr, cur_field->first),
282                            i2target (options.hi_bit_nr, cur_field->last));
283               else
284                 lf_printf (file, "EXTRACTED%d (instruction_%d, %d, %d)",
285                            options.insn_bit_size,
286                            cur_field->word_nr,
287                            i2target (options.hi_bit_nr, cur_field->first),
288                            i2target (options.hi_bit_nr, cur_field->last));
289             }
290           else
291             {
292               lf_printf (file, "%s", entry_expression);
293             }
294         }
295     }
296   
297   switch (what_to_declare)
298     {
299     case define_variables:
300       lf_printf (file, ")");
301       break;
302     case undef_variables:
303       break;
304     case declare_variables:
305       lf_printf (file, ";");
306       break;
307     }
308
309   ASSERT (reason != NULL && expression != NULL);
310   lf_printf (file, " /* %s - %s */\n", reason, expression);
311 }
312
313
314 void
315 print_icache_body (lf *file,
316                    insn_entry *instruction,
317                    opcode_bits *expanded_bits,
318                    cache_entry *cache_rules,
319                    icache_decl_type what_to_declare,
320                    icache_body_type what_to_do,
321                    int nr_prefetched_words)
322 {
323   /* extract instruction fields */
324   lf_printf (file, "/* Extraction: %s\n", instruction->name);
325   lf_printf (file, "     ");
326   switch (what_to_declare)
327     {
328     case define_variables:
329       lf_printf (file, "#define");
330       break;
331     case declare_variables:
332       lf_printf (file, "declare");
333       break;
334     case undef_variables:
335       lf_printf (file, "#undef");
336       break;
337     }
338   lf_printf (file, " ");
339   switch (what_to_do)
340     {
341     case get_values_from_icache:
342       lf_printf (file, "get-values-from-icache");
343       break;
344     case put_values_in_icache:
345       lf_printf (file, "put-values-in-icache");
346       break;
347     case both_values_and_icache:
348       lf_printf (file, "get-values-from-icache|put-values-in-icache");
349       break;
350     case do_not_use_icache:
351       lf_printf (file, "do-not-use-icache");
352       break;
353     }
354   lf_printf (file, "\n     ");
355   print_insn_words (file, instruction);
356   lf_printf(file, " */\n");
357   
358   /* pass zero - fetch from memory any missing instructions.
359
360      Some of the instructions will have already been fetched (in the
361      instruction array), others will still need fetching. */
362   switch (what_to_do)
363     {
364     case get_values_from_icache:
365       break;
366     case put_values_in_icache:
367     case both_values_and_icache:
368     case do_not_use_icache:
369       {
370         int word_nr;
371         switch (what_to_declare)
372           {
373           case undef_variables:
374             break;
375           case define_variables:
376           case declare_variables:
377             for (word_nr = nr_prefetched_words;
378                  word_nr < instruction->nr_words;
379                  word_nr++)
380               {
381                 /* FIXME - should be using print_icache_extraction? */
382                 lf_printf (file, "%sinstruction_word instruction_%d UNUSED = ",
383                            options.module.global.prefix.l,
384                            word_nr);
385                 lf_printf (file, "IMEM%d_IMMED (cia, %d)",
386                            options.insn_bit_size, word_nr);
387                 lf_printf (file, ";\n");
388               }
389           }
390       }
391     }
392
393   /* if putting the instruction words in the cache, define references
394      for them */
395   if (options.gen.insn_in_icache) {
396     /* FIXME: is the instruction_word type correct? */
397     print_icache_extraction (file,
398                              instruction->format_name,
399                              cache_value,
400                              "insn", /* name */
401                              "instruction_word", /* type */
402                              "instruction", /* expression */
403                              NULL, /* origin */
404                              NULL, /* line */
405                              NULL, NULL,
406                              what_to_declare,
407                              what_to_do);
408   }
409   lf_printf(file, "\n");
410
411   /* pass one - process instruction fields.
412
413      If there is no cache rule, the default is to enter the field into
414      the cache */
415   {
416     insn_word_entry *word;
417     for (word = instruction->words;
418          word != NULL;
419          word = word->next)
420       {
421         insn_field_entry *cur_field;
422         for (cur_field = word->first;
423              cur_field->first < options.insn_bit_size;
424              cur_field = cur_field->next)
425           {
426             if (cur_field->type == insn_field_string)
427               {
428                 cache_entry *cache_rule;
429                 cache_entry_type value_type = cache_value;
430                 line_ref *value_line = instruction->line;
431                 /* check the cache table to see if it contains a rule
432                    overriding the default cache action for an
433                    instruction field */
434                 for (cache_rule = cache_rules;
435                      cache_rule != NULL;
436                      cache_rule = cache_rule->next)
437                   {
438                     if (filter_is_subset (instruction->field_names,
439                                           cache_rule->original_fields)
440                         && strcmp (cache_rule->name, cur_field->val_string) == 0)
441                       {
442                         value_type = cache_rule->entry_type;
443                         value_line = cache_rule->line;
444                         if (value_type == compute_value)
445                           {
446                             options.warning (cache_rule->line,
447                                              "instruction field of type `compute' changed to `cache'\n");
448                             cache_rule->entry_type = cache_value;
449                           }
450                         break;
451                       }
452                   }
453                 /* Define an entry for the field within the
454                    instruction */
455                 print_icache_extraction (file,
456                                          instruction->format_name,
457                                          value_type,
458                                          cur_field->val_string, /* name */
459                                          NULL, /* type */
460                                          NULL, /* expression */
461                                          cur_field->val_string, /* insn field */
462                                          value_line,
463                                          cur_field,
464                                          expanded_bits,
465                                          what_to_declare,
466                                          what_to_do);
467               }
468           }
469       }
470   }
471
472   /* pass two - any cache fields not processed above */
473   {
474     cache_entry *cache_rule;
475     for (cache_rule = cache_rules;
476          cache_rule != NULL;
477          cache_rule = cache_rule->next)
478       {
479         if (filter_is_subset (instruction->field_names,
480                               cache_rule->original_fields)
481             && !filter_is_member (instruction->field_names,
482                                   cache_rule->name))
483           {
484             char *single_field = filter_next (cache_rule->original_fields, "");
485             if (filter_next (cache_rule->original_fields, single_field) != NULL)
486               single_field = NULL;
487             print_icache_extraction (file,
488                                      instruction->format_name,
489                                      cache_rule->entry_type,
490                                      cache_rule->name,
491                                      cache_rule->type,
492                                      cache_rule->expression,
493                                      single_field,
494                                      cache_rule->line,
495                                      NULL, /* cur_field */
496                                      expanded_bits,
497                                      what_to_declare,
498                                      what_to_do);
499           }
500       }
501   }
502
503   lf_print__internal_ref (file);
504 }
505
506
507
508 typedef struct _form_fields form_fields;
509 struct _form_fields {
510   char *name;
511   filter *fields;
512   form_fields *next;
513 };
514
515 static form_fields *
516 insn_table_cache_fields (insn_table *isa)
517 {
518   form_fields *forms = NULL;
519   insn_entry *insn;
520   for (insn = isa->insns;
521        insn != NULL;
522        insn = insn->next) {
523     form_fields **form = &forms;
524     while (1)
525       {
526         if (*form == NULL)
527           {
528             /* new format name, add it */
529             form_fields *new_form = ZALLOC (form_fields);
530             new_form->name = insn->format_name;
531             filter_add (&new_form->fields, insn->field_names);
532             *form = new_form;
533             break;
534           }
535         else if (strcmp ((*form)->name, insn->format_name) == 0)
536           {
537             /* already present, add field names to the existing list */
538             filter_add (&(*form)->fields, insn->field_names);
539             break;
540           }
541         form = &(*form)->next;
542       }
543   }
544   return forms;
545 }
546
547
548
549 extern void
550 print_icache_struct (lf *file,
551                      insn_table *isa,
552                      cache_entry *cache_rules)
553 {
554   /* Create a list of all the different instruction formats with their
555      corresponding field names. */
556   form_fields *formats = insn_table_cache_fields (isa);
557   
558   lf_printf (file, "\n");
559   lf_printf (file, "#define WITH_%sIDECODE_CACHE_SIZE %d\n",
560              options.module.global.prefix.u,
561              (options.gen.icache ? options.gen.icache_size : 0));
562   lf_printf (file, "\n");
563   
564   /* create an instruction cache if being used */
565   if (options.gen.icache) {
566     lf_printf (file, "typedef struct _%sidecode_cache {\n",
567                options.module.global.prefix.l);
568     lf_indent (file, +2);
569     {
570       form_fields *format;
571       lf_printf (file, "unsigned_word address;\n");
572       lf_printf (file, "void *semantic;\n");
573       lf_printf (file, "union {\n");
574       lf_indent (file, +2);
575       for (format = formats;
576            format != NULL;
577            format = format->next)
578         {
579           lf_printf (file, "struct {\n");
580           lf_indent (file, +2);
581           {
582             cache_entry *cache_rule;
583             char *field;
584             /* space for any instruction words */
585             if (options.gen.insn_in_icache)
586               lf_printf (file, "instruction_word insn[%d];\n", isa->max_nr_words);
587             /* define an entry for any applicable cache rules */
588             for (cache_rule = cache_rules;
589                  cache_rule != NULL;
590                  cache_rule = cache_rule->next)
591               {
592                 /* nb - sort of correct - should really check against
593                    individual instructions */
594                 if (filter_is_subset (format->fields, cache_rule->original_fields))
595                   {
596                     char *memb;
597                     lf_printf (file, "%s %s;",
598                                (cache_rule->type == NULL
599                                 ? "unsigned" 
600                                 : cache_rule->type),
601                                cache_rule->name);
602                     lf_printf (file, " /*");
603                     for (memb = filter_next (cache_rule->original_fields, "");
604                          memb != NULL;
605                          memb = filter_next (cache_rule->original_fields, memb))
606                       {
607                         lf_printf (file, " %s", memb);
608                       }
609                     lf_printf (file, " */\n");
610                   }
611               }
612             /* define an entry for any fields not covered by a cache rule */
613             for (field = filter_next (format->fields, "");
614                  field != NULL;
615                  field = filter_next (format->fields, field))
616               {
617                 cache_entry *cache_rule;
618                 int found_rule = 0;
619                 for (cache_rule = cache_rules;
620                      cache_rule != NULL;
621                      cache_rule = cache_rule->next)
622                   {
623                     if (strcmp (cache_rule->name, field) == 0)
624                       {
625                         found_rule = 1;
626                         break;
627                       }
628                   }
629                 if (!found_rule)
630                   lf_printf (file, "unsigned %s; /* default */\n", field);
631               }
632           }
633           lf_indent (file, -2);
634           lf_printf (file, "} %s;\n", format->name);
635         }
636       lf_indent (file, -2);
637       lf_printf (file, "} crack;\n");
638     }
639     lf_indent (file, -2);
640     lf_printf (file, "} %sidecode_cache;\n", options.module.global.prefix.l);
641   }
642   else
643     {
644       /* alernativly, since no cache, emit a dummy definition for
645          idecode_cache so that code refering to the type can still compile */
646       lf_printf(file, "typedef void %sidecode_cache;\n",
647                 options.module.global.prefix.l);
648     }
649   lf_printf (file, "\n");
650 }
651
652
653
654 static void
655 print_icache_function (lf *file,
656                        insn_entry *instruction,
657                        opcode_bits *expanded_bits,
658                        insn_opcodes *opcodes,
659                        cache_entry *cache_rules,
660                        int nr_prefetched_words)
661 {
662   int indent;
663
664   /* generate code to enter decoded instruction into the icache */
665   lf_printf(file, "\n");
666   lf_print__function_type_function (file, print_icache_function_type,
667                                     "EXTERN_ICACHE", "\n");
668   indent = print_function_name (file,
669                                 instruction->name,
670                                 instruction->format_name,
671                                 NULL,
672                                 expanded_bits,
673                                 function_name_prefix_icache);
674   indent += lf_printf (file, " ");
675   lf_indent (file, +indent);
676   lf_printf (file, "(");
677   print_icache_function_formal (file, nr_prefetched_words);
678   lf_printf (file, ")\n");
679   lf_indent (file, -indent);
680   
681   /* function header */
682   lf_printf (file, "{\n");
683   lf_indent (file, +2);
684   
685   print_my_defines (file,
686                     instruction->name,
687                     instruction->format_name,
688                     expanded_bits);
689   print_itrace (file, instruction, 1/*putting-value-in-cache*/);
690   
691   print_idecode_validate (file, instruction, opcodes);
692   
693   lf_printf (file, "\n");
694   lf_printf (file, "{\n");
695   lf_indent (file, +2);
696   if (options.gen.semantic_icache)
697     lf_printf (file, "unsigned_word nia;\n");
698   print_icache_body (file,
699                      instruction,
700                      expanded_bits,
701                      cache_rules,
702                      (options.gen.direct_access
703                       ? define_variables
704                       : declare_variables),
705                      (options.gen.semantic_icache
706                       ? both_values_and_icache
707                       : put_values_in_icache),
708                      nr_prefetched_words);
709   
710   lf_printf (file, "\n");
711   lf_printf (file, "cache_entry->address = cia;\n");
712   lf_printf (file, "cache_entry->semantic = ");
713   print_function_name (file,
714                        instruction->name,
715                        instruction->format_name,
716                        NULL,
717                        expanded_bits,
718                        function_name_prefix_semantics);
719   lf_printf (file, ";\n");
720   lf_printf (file, "\n");
721
722   if (options.gen.semantic_icache) {
723     lf_printf (file, "/* semantic routine */\n");
724     print_semantic_body (file,
725                          instruction,
726                          expanded_bits,
727                          opcodes);
728     lf_printf (file, "return nia;\n");
729   }
730   
731   if (!options.gen.semantic_icache)
732     {
733       lf_printf (file, "/* return the function proper */\n");
734       lf_printf (file, "return ");
735       print_function_name (file,
736                            instruction->name,
737                            instruction->format_name,
738                            NULL,
739                            expanded_bits,
740                            function_name_prefix_semantics);
741       lf_printf (file, ";\n");
742     }
743   
744   if (options.gen.direct_access)
745     {
746       print_icache_body (file,
747                          instruction,
748                          expanded_bits,
749                          cache_rules,
750                          undef_variables,
751                          (options.gen.semantic_icache
752                           ? both_values_and_icache
753                           : put_values_in_icache),
754                          nr_prefetched_words);
755     }
756   
757   lf_indent (file, -2);
758   lf_printf (file, "}\n");
759   lf_indent (file, -2);
760   lf_printf (file, "}\n");
761 }
762
763
764 void
765 print_icache_definition (lf *file,
766                          insn_entry *insn,
767                          opcode_bits *expanded_bits,
768                          insn_opcodes *opcodes,
769                          cache_entry *cache_rules,
770                          int nr_prefetched_words)
771 {
772   print_icache_function (file,
773                          insn,
774                          expanded_bits,
775                          opcodes,
776                          cache_rules,
777                          nr_prefetched_words);
778 }
779
780
781
782 void
783 print_icache_internal_function_declaration (lf *file,
784                                             function_entry *function,
785                                             void *data)
786 {
787   ASSERT (options.gen.icache);
788   if (function->is_internal)
789     {
790       lf_printf (file, "\n");
791       lf_print__function_type_function (file, print_icache_function_type,
792                                         "INLINE_ICACHE", "\n");
793       print_function_name (file,
794                            function->name,
795                            NULL,
796                            NULL,
797                            NULL,
798                            function_name_prefix_icache);
799       lf_printf (file, "\n(");
800       print_icache_function_formal (file, 0);
801       lf_printf (file, ");\n");
802     }
803 }
804
805
806 void
807 print_icache_internal_function_definition (lf *file,
808                                            function_entry *function,
809                                            void *data)
810 {
811   ASSERT (options.gen.icache);
812   if (function->is_internal)
813     {
814       lf_printf (file, "\n");
815       lf_print__function_type_function (file, print_icache_function_type,
816                                         "INLINE_ICACHE", "\n");
817       print_function_name (file,
818                            function->name,
819                            NULL,
820                            NULL,
821                            NULL,
822                            function_name_prefix_icache);
823       lf_printf (file, "\n(");
824       print_icache_function_formal (file, 0);
825       lf_printf (file, ")\n");
826       lf_printf (file, "{\n");
827       lf_indent (file, +2);
828       lf_printf (file, "/* semantic routine */\n");
829       if (options.gen.semantic_icache)
830         {
831           lf_print__line_ref (file, function->code->line);
832           table_print_code (file, function->code);
833           lf_printf (file, "error (\"Internal function must longjump\\n\");\n");
834           lf_printf (file, "return 0;\n");
835         }
836       else
837         {
838           lf_printf (file, "return ");
839           print_function_name (file,
840                                function->name,
841                                NULL,
842                                NULL,
843                                NULL,
844                                function_name_prefix_semantics);
845           lf_printf (file, ";\n");
846         }
847       
848       lf_print__internal_ref (file);
849       lf_indent (file, -2);
850       lf_printf (file, "}\n");
851     }
852 }