$(nodist_or1k_libsim_a_OBJECTS)
ppc_libigen_a_AR = $(AR) $(ARFLAGS)
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_DEPENDENCIES = \
-@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o igen/misc.o
+@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o igen/lf.o \
+@SIM_ENABLE_ARCH_ppc_TRUE@ igen/misc.o
@SIM_ENABLE_ARCH_ppc_TRUE@am_ppc_libigen_a_OBJECTS = \
-@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/table.$(OBJEXT) ppc/lf.$(OBJEXT) \
+@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/table.$(OBJEXT) \
+@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/lf-ppc.$(OBJEXT) \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/dumpf.$(OBJEXT) \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode.$(OBJEXT) \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache.$(OBJEXT) \
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_SOURCES = \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/table.c \
-@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/lf.c \
+@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/lf-ppc.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/dumpf.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_LIBADD = \
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o \
+@SIM_ENABLE_ARCH_ppc_TRUE@ igen/lf.o \
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/misc.o
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_igen_SOURCES = ppc/igen.c
@$(MKDIR_P) ppc/$(DEPDIR)
@: > ppc/$(DEPDIR)/$(am__dirstamp)
ppc/table.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
-ppc/lf.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
+ppc/lf-ppc.$(OBJEXT): ppc/$(am__dirstamp) \
+ ppc/$(DEPDIR)/$(am__dirstamp)
ppc/dumpf.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
ppc/ld-decode.$(OBJEXT): ppc/$(am__dirstamp) \
ppc/$(DEPDIR)/$(am__dirstamp)
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/ld-cache.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/ld-decode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/ld-insn.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/lf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/lf-ppc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/table.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@pru/$(DEPDIR)/modules.Po@am__quote@
#include "misc.h"
#include "lf.h"
+#include "lf-ppc.h"
#include "table.h"
#include "filter.h"
int is_function_definition)
{
lf_printf(file, "\n");
- lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "EXTERN_ICACHE", " ");
+ lf_print__function_type(file, ICACHE_FUNCTION_TYPE, "EXTERN_ICACHE", " ");
print_function_name(file,
basename,
expanded_bits,
}
else {
if (file_name != NULL)
- lf_print__external_reference(file, line_nr, file_name);
+ lf_print__external_ref(file, line_nr, file_name);
lf_printf(file, "%s const %s ATTRIBUTE_UNUSED = ",
entry_type == NULL ? "unsigned" : entry_type,
entry_name);
}
}
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
if ((code & generate_with_insn_in_icache)) {
lf_printf(file, "\n");
/* generate code to enter decoded instruction into the icache */
lf_printf(file, "\n");
- lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "EXTERN_ICACHE", "\n");
+ lf_print__function_type(file, ICACHE_FUNCTION_TYPE, "EXTERN_ICACHE", "\n");
indent = print_function_name(file,
instruction->file_entry->fields[insn_name],
expanded_bits,
ASSERT((code & generate_with_icache) != 0);
if (it_is("internal", function->fields[insn_flags])) {
lf_printf(file, "\n");
- lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
+ lf_print__function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
"\n");
print_function_name(file,
function->fields[insn_name],
ASSERT((code & generate_with_icache) != 0);
if (it_is("internal", function->fields[insn_flags])) {
lf_printf(file, "\n");
- lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
+ lf_print__function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
"\n");
print_function_name(file,
function->fields[insn_name],
lf_printf(file, ";\n");
}
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
lf_indent(file, -2);
lf_printf(file, "}\n");
}
#include "misc.h"
#include "lf.h"
+#include "lf-ppc.h"
#include "table.h"
#include "filter.h"
lf_indent(file, +2);
lf_printf(file, "const unsigned_word cia = nia;\n");
lf_print__c_code(file, function->annex);
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
lf_printf(file, "error(\"Internal function must longjump\\n\");\n");
lf_indent(file, -2);
lf_printf(file, "}\n");
{
int indent;
lf_printf(file, "\n");
- lf_print_function_type(file, "void", "PSIM_INLINE_IDECODE", (is_definition ? " " : "\n"));
+ lf_print__function_type(file, "void", "PSIM_INLINE_IDECODE", (is_definition ? " " : "\n"));
indent = lf_putstr(file, (can_stop ? "idecode_run_until_stop" : "idecode_run"));
if (is_definition)
lf_putstr(file, "\n");
#include "misc.h"
#include "lf.h"
+#include "lf-ppc.h"
#include "table.h"
#include "filter.h"
if (data->annex) {
table_entry_print_cpp_line_nr(file, data);
lf_print__c_code(file, data->annex);
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
lf_printf(file, "\n");
}
}
ERROR("Model function type not specified for %s", function->fields[function_name]);
}
lf_printf(file, "\n");
- lf_print_function_type(file, function->fields[function_type], prefix, " ");
+ lf_print__function_type(file, function->fields[function_type], prefix, " ");
lf_printf(file, "%s\n(%s);\n",
function->fields[function_name],
function->fields[function_param]);
}
if (!model_create_p) {
- lf_print_function_type(file, "model_data *", "INLINE_MODEL", " ");
+ lf_print__function_type(file, "model_data *", "INLINE_MODEL", " ");
lf_printf(file, "model_create\n");
lf_printf(file, "(cpu *processor);\n");
lf_printf(file, "\n");
}
if (!model_init_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
+ lf_print__function_type(file, "void", "INLINE_MODEL", " ");
lf_printf(file, "model_init\n");
lf_printf(file, "(model_data *model_ptr);\n");
lf_printf(file, "\n");
}
if (!model_halt_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
+ lf_print__function_type(file, "void", "INLINE_MODEL", " ");
lf_printf(file, "model_halt\n");
lf_printf(file, "(model_data *model_ptr);\n");
lf_printf(file, "\n");
}
if (!model_mon_info_p) {
- lf_print_function_type(file, "model_print *", "INLINE_MODEL", " ");
+ lf_print__function_type(file, "model_print *", "INLINE_MODEL", " ");
lf_printf(file, "model_mon_info\n");
lf_printf(file, "(model_data *model_ptr);\n");
lf_printf(file, "\n");
}
if (!model_mon_info_free_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
+ lf_print__function_type(file, "void", "INLINE_MODEL", " ");
lf_printf(file, "model_mon_info_free\n");
lf_printf(file, "(model_data *model_ptr,\n");
lf_printf(file, " model_print *info_ptr);\n");
lf_printf(file, "\n");
}
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
+ lf_print__function_type(file, "void", "INLINE_MODEL", " ");
lf_printf(file, "model_set\n");
lf_printf(file, "(const char *name);\n");
}
}
else {
lf_printf(file, "\n");
- lf_print_function_type(file, function->fields[function_type], prefix, "\n");
+ lf_print__function_type(file, function->fields[function_type], prefix, "\n");
lf_printf(file, "%s(%s)\n",
function->fields[function_name],
function->fields[function_param]);
lf_indent(file, -2);
}
lf_printf(file, "}\n");
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
lf_printf(file, "\n");
}
}
if (!model_create_p) {
- lf_print_function_type(file, "model_data *", "INLINE_MODEL", "\n");
+ lf_print__function_type(file, "model_data *", "INLINE_MODEL", "\n");
lf_printf(file, "model_create(cpu *processor)\n");
lf_printf(file, "{\n");
lf_printf(file, " return (model_data *)0;\n");
}
if (!model_init_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
+ lf_print__function_type(file, "void", "INLINE_MODEL", "\n");
lf_printf(file, "model_init(model_data *model_ptr)\n");
lf_printf(file, "{\n");
lf_printf(file, "}\n");
}
if (!model_halt_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
+ lf_print__function_type(file, "void", "INLINE_MODEL", "\n");
lf_printf(file, "model_halt(model_data *model_ptr)\n");
lf_printf(file, "{\n");
lf_printf(file, "}\n");
}
if (!model_mon_info_p) {
- lf_print_function_type(file, "model_print *", "INLINE_MODEL", "\n");
+ lf_print__function_type(file, "model_print *", "INLINE_MODEL", "\n");
lf_printf(file, "model_mon_info(model_data *model_ptr)\n");
lf_printf(file, "{\n");
lf_printf(file, " return (model_print *)0;\n");
}
if (!model_mon_info_free_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
+ lf_print__function_type(file, "void", "INLINE_MODEL", "\n");
lf_printf(file, "model_mon_info_free(model_data *model_ptr,\n");
lf_printf(file, " model_print *info_ptr)\n");
lf_printf(file, "{\n");
lf_printf(file, "#endif\n");
lf_printf(file, "\n");
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
+ lf_print__function_type(file, "void", "INLINE_MODEL", "\n");
lf_printf(file, "model_set(const char *name)\n");
lf_printf(file, "{\n");
if (models) {
#include "misc.h"
#include "lf.h"
+#include "lf-ppc.h"
#include "table.h"
#include "filter.h"
{
int indent;
lf_printf(file, "\n");
- lf_print_function_type(file, SEMANTIC_FUNCTION_TYPE, "PSIM_EXTERN_SEMANTICS",
+ lf_print__function_type(file, SEMANTIC_FUNCTION_TYPE, "PSIM_EXTERN_SEMANTICS",
(is_function_definition ? "\n" : " "));
indent = print_function_name(file,
basename,
lf_print__c_code(file, instruction->file_entry->annex);
lf_indent(file, -2);
lf_printf(file, "}\n");
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
}
else if (it_is("nop", instruction->file_entry->fields[insn_flags])) {
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
}
else {
/* abort so it is implemented now */
table_entry_print_cpp_line_nr(file, instruction->file_entry);
lf_putstr(file, "error(\"%s:%d:0x%08lx:%s unimplemented\\n\",\n");
lf_printf(file, " itable[MY_INDEX].file, itable[MY_INDEX].line_nr, (long)cia, itable[MY_INDEX].name);\n");
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
}
}
#include "misc.h"
#include "lf.h"
+#include "lf-ppc.h"
#include "table.h"
#include "filter.h"
int is_function_definition)
{
if (it_is("internal", function->fields[insn_flags])) {
- lf_print_function_type(file, SEMANTIC_FUNCTION_TYPE, "PSIM_INLINE_SUPPORT",
+ lf_print__function_type(file, SEMANTIC_FUNCTION_TYPE, "PSIM_INLINE_SUPPORT",
(is_function_definition ? "\n" : " "));
print_function_name(file,
function->fields[function_name],
lf_printf(file, "\n");
}
else {
- lf_print_function_type(file,
+ lf_print__function_type(file,
function->fields[function_type],
"PSIM_INLINE_SUPPORT",
(is_function_definition ? "\n" : " "));
}
lf_indent(file, -2);
lf_printf(file, "}\n");
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
lf_printf(file, "\n");
}
table_entry *file_entry,
int idecode)
{
- lf_print__external_reference(file, file_entry->line_nr, file_entry->file_name);
+ lf_print__external_ref(file, file_entry->line_nr, file_entry->file_name);
lf_printf(file, "ITRACE(trace_%s, (\"%s %s\\n\"));\n",
(idecode ? "idecode" : "semantics"),
(idecode ? "idecode" : "semantics"),
file_entry->fields[insn_name]);
- lf_print__internal_reference(file);
+ lf_print__internal_ref(file);
}
}
else {
- lf_print__this_file_is_empty(file);
+ lf_print__this_file_is_empty(file, "generating jumps");
}
}
}
else {
- lf_print__this_file_is_empty(file);
+ lf_print__this_file_is_empty(file, "generating jump engine");
}
}
}
else {
- lf_print__this_file_is_empty(file);
+ lf_print__this_file_is_empty(file, "generating jump engine");
}
}
}
else {
- lf_print__this_file_is_empty(file);
+ lf_print__this_file_is_empty(file, "generating jump engine");
}
}
--- /dev/null
+/* This file is part of the program psim.
+
+ Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "lf.h"
+#include "lf-ppc.h"
+
+int
+lf_print__c_code(lf *file,
+ const char *code)
+{
+ int nr = 0;
+ const char *chp = code;
+ int in_bit_field = 0;
+ while (*chp != '\0') {
+ if (*chp == '\t')
+ chp++;
+ if (*chp == '#')
+ lf_indent_suppress(file);
+ while (*chp != '\0' && *chp != '\n') {
+ if (chp[0] == '{' && !isspace(chp[1])) {
+ in_bit_field = 1;
+ nr += lf_putchr(file, '_');
+ }
+ else if (in_bit_field && chp[0] == ':') {
+ nr += lf_putchr(file, '_');
+ }
+ else if (in_bit_field && *chp == '}') {
+ nr += lf_putchr(file, '_');
+ in_bit_field = 0;
+ }
+ else {
+ nr += lf_putchr(file, *chp);
+ }
+ chp++;
+ }
+ if (in_bit_field)
+ ERROR("bit field paren miss match some where\n");
+ if (*chp == '\n') {
+ nr += lf_putchr(file, '\n');
+ chp++;
+ }
+ }
+ nr += lf_putchr(file, '\n');
+ return nr;
+}
--- /dev/null
+/* This file is part of the program psim.
+
+ Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ */
+
+#ifndef PPC_LF_H
+#define PPC_LF_H
+
+/* LF: Line Numbered Output Stream */
+
+#include "lf.h"
+
+/* TODO: Convert to igen/table.c table_print_code. */
+
+extern int lf_print__c_code
+(lf *file,
+ const char *code);
+
+#endif /* PPC_LF_H */
+++ /dev/null
-/* This file is part of the program psim.
-
- Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-
- */
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-
-#include "misc.h"
-#include "lf.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-struct _lf {
- FILE *stream;
- int line_nr; /* nr complete lines written, curr line is line_nr+1 */
- int indent;
- int line_blank;
- const char *name; /* Output name with diagnostics. */
- const char *filename; /* Output filename. */
- char *tmpname; /* Temporary output filename. */
- const char *program;
- lf_file_references references;
- lf_file_type type;
-};
-
-
-lf *
-lf_open(const char *name,
- const char *real_name,
- lf_file_references references,
- lf_file_type type,
- const char *program)
-{
- /* create a file object */
- lf *new_lf = ZALLOC(lf);
- ASSERT(new_lf != NULL);
- new_lf->references = references;
- new_lf->type = type;
- new_lf->name = (real_name == NULL ? name : real_name);
- new_lf->filename = name;
- new_lf->program = program;
- /* attach to stdout if pipe */
- if (!strcmp(name, "-")) {
- new_lf->stream = stdout;
- }
- else {
- /* create a new file */
- char *tmpname = zalloc (strlen (name) + 5);
- sprintf (tmpname, "%s.tmp", name);
- new_lf->filename = name;
- new_lf->tmpname = tmpname;
- new_lf->stream = fopen(tmpname, "w+");
- if (new_lf->stream == NULL) {
- perror(name);
- exit(1);
- }
- }
- return new_lf;
-}
-
-
-void
-lf_close(lf *file)
-{
- FILE *fp;
- bool update = true;
-
- /* If we wrote to stdout, no house keeping needed. */
- if (file->stream == stdout)
- return;
-
- /* Rename the temp file to the real file if it's changed. */
- fp = fopen (file->filename, "r");
- if (fp != NULL)
- {
- off_t len;
-
- fseek (fp, 0, SEEK_END);
- len = ftell (fp);
-
- if (len == ftell (file->stream))
- {
- off_t off;
- size_t cnt;
- char *oldbuf = zalloc (len);
- char *newbuf = zalloc (len);
-
- rewind (fp);
- off = 0;
- while ((cnt = fread (oldbuf + off, 1, len - off, fp)) > 0)
- off += cnt;
- ASSERT (off == len);
-
- rewind (file->stream);
- off = 0;
- while ((cnt = fread (newbuf + off, 1, len - off, file->stream)) > 0)
- off += cnt;
- ASSERT (off == len);
-
- if (memcmp (oldbuf, newbuf, len) == 0)
- update = false;
- }
-
- fclose (fp);
- }
-
- if (fclose (file->stream))
- {
- perror ("lf_close.fclose");
- exit (1);
- }
-
- if (update)
- {
- if (rename (file->tmpname, file->filename) != 0)
- {
- perror ("lf_close.rename");
- exit (1);
- }
- }
- else
- {
- if (remove (file->tmpname) != 0)
- {
- perror ("lf_close.unlink");
- exit (1);
- }
- }
-
- free (file->tmpname);
- free (file);
-}
-
-
-int
-lf_putchr(lf *file,
- const char chr)
-{
- int nr = 0;
- if (chr == '\n') {
- file->line_nr += 1;
- file->line_blank = 1;
- }
- else if (file->line_blank) {
- int pad;
- for (pad = file->indent; pad > 0; pad--)
- putc(' ', file->stream);
- nr += file->indent;
- file->line_blank = 0;
- }
- putc(chr, file->stream);
- nr += 1;
- return nr;
-}
-
-void
-lf_indent_suppress(lf *file)
-{
- file->line_blank = 0;
-}
-
-
-int
-lf_putstr(lf *file,
- const char *string)
-{
- int nr = 0;
- const char *chp;
- if (string != NULL) {
- for (chp = string; *chp != '\0'; chp++) {
- nr += lf_putchr(file, *chp);
- }
- }
- return nr;
-}
-
-static int
-do_lf_putunsigned(lf *file,
- unsigned u)
-{
- int nr = 0;
- if (u > 0) {
- nr += do_lf_putunsigned(file, u / 10);
- nr += lf_putchr(file, (u % 10) + '0');
- }
- return nr;
-}
-
-
-int
-lf_putint(lf *file,
- int decimal)
-{
- int nr = 0;
- if (decimal == 0)
- nr += lf_putchr(file, '0');
- else if (decimal < 0) {
- nr += lf_putchr(file, '-');
- nr += do_lf_putunsigned(file, -decimal);
- }
- else if (decimal > 0) {
- nr += do_lf_putunsigned(file, decimal);
- }
- else
- ASSERT(0);
- return nr;
-}
-
-
-int
-lf_printf(lf *file,
- const char *fmt,
- ...)
-{
- int nr = 0;
- char buf[1024];
- va_list ap;
-
- va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
- /* FIXME - this is really stuffed but so is vsprintf() on a sun! */
- ASSERT(strlen(buf) > 0 && strlen(buf) < sizeof(buf));
- nr += lf_putstr(file, buf);
- va_end(ap);
- return nr;
-}
-
-
-int
-lf_print__c_code(lf *file,
- const char *code)
-{
- int nr = 0;
- const char *chp = code;
- int in_bit_field = 0;
- while (*chp != '\0') {
- if (*chp == '\t')
- chp++;
- if (*chp == '#')
- lf_indent_suppress(file);
- while (*chp != '\0' && *chp != '\n') {
- if (chp[0] == '{' && !isspace(chp[1])) {
- in_bit_field = 1;
- nr += lf_putchr(file, '_');
- }
- else if (in_bit_field && chp[0] == ':') {
- nr += lf_putchr(file, '_');
- }
- else if (in_bit_field && *chp == '}') {
- nr += lf_putchr(file, '_');
- in_bit_field = 0;
- }
- else {
- nr += lf_putchr(file, *chp);
- }
- chp++;
- }
- if (in_bit_field)
- ERROR("bit field paren miss match some where\n");
- if (*chp == '\n') {
- nr += lf_putchr(file, '\n');
- chp++;
- }
- }
- nr += lf_putchr(file, '\n');
- return nr;
-}
-
-
-int
-lf_print__external_reference(lf *file,
- int line_nr,
- const char *file_name)
-{
- int nr = 0;
- switch (file->references) {
- case lf_include_references:
- lf_indent_suppress(file);
- nr += lf_putstr(file, "#line ");
- nr += lf_putint(file, line_nr);
- nr += lf_putstr(file, " \"");
- nr += lf_putstr(file, file_name);
- nr += lf_putstr(file, "\"\n");
- break;
- case lf_omit_references:
- break;
- }
- return nr;
-}
-
-int
-lf_print__internal_reference(lf *file)
-{
- int nr = 0;
- nr += lf_print__external_reference(file, file->line_nr+2, file->name);
- /* line_nr == last_line, want to number from next */
- return nr;
-}
-
-void
-lf_indent(lf *file, int delta)
-{
- file->indent += delta;
-}
-
-
-int
-lf_print__gnu_copyleft(lf *file)
-{
- int nr = 0;
- switch (file->type) {
- case lf_is_c:
- case lf_is_h:
- nr += lf_printf(file, "\n\
-/* This file is part of the program psim.\n\
-\n\
- Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>\n\
-\n\
- This program is free software; you can redistribute it and/or modify\n\
- it under the terms of the GNU General Public License as published by\n\
- the Free Software Foundation; either version 3 of the License, or\n\
- (at your option) any later version.\n\
-\n\
- This program is distributed in the hope that it will be useful,\n\
- but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
- GNU General Public License for more details.\n\
-\n\
- You should have received a copy of the GNU General Public License\n\
- along with this program; if not, see <http://www.gnu.org/licenses/>.\n\
-\n\
- --\n\
-\n\
- This file was generated by the program %s */\n\
-", filter_filename(file->program));
- break;
- default:
- ASSERT(0);
- break;
- }
- return nr;
-}
-
-
-int
-lf_putbin(lf *file, int decimal, int width)
-{
- int nr = 0;
- int bit;
- ASSERT(width > 0);
- for (bit = 1 << (width-1); bit != 0; bit >>= 1) {
- if (decimal & bit)
- nr += lf_putchr(file, '1');
- else
- nr += lf_putchr(file, '0');
- }
- return nr;
-}
-
-int
-lf_print__this_file_is_empty(lf *file)
-{
- int nr = 0;
- switch (file->type) {
- case lf_is_c:
- case lf_is_h:
- nr += lf_printf(file,
- "/* This generated file (%s) is intentionally left blank */\n",
- file->name);
- break;
- default:
- ASSERT(0);
- }
- return nr;
-}
-
-int
-lf_print__ucase_filename(lf *file)
-{
- int nr = 0;
- const char *chp = file->name;
- while (*chp != '\0') {
- char ch = *chp;
- if (islower(ch)) {
- nr += lf_putchr(file, toupper(ch));
- }
- else if (ch == '.')
- nr += lf_putchr(file, '_');
- else
- nr += lf_putchr(file, ch);
- chp++;
- }
- return nr;
-}
-
-int
-lf_print__file_start(lf *file)
-{
- int nr = 0;
- switch (file->type) {
- case lf_is_h:
- case lf_is_c:
- nr += lf_print__gnu_copyleft(file);
- nr += lf_printf(file, "\n");
- nr += lf_printf(file, "#ifndef _");
- nr += lf_print__ucase_filename(file);
- nr += lf_printf(file, "_\n");
- nr += lf_printf(file, "#define _");
- nr += lf_print__ucase_filename(file);
- nr += lf_printf(file, "_\n");
- nr += lf_printf(file, "\n");
- break;
- default:
- ASSERT(0);
- }
- return nr;
-}
-
-
-int
-lf_print__file_finish(lf *file)
-{
- int nr = 0;
- switch (file->type) {
- case lf_is_h:
- case lf_is_c:
- nr += lf_printf(file, "\n");
- nr += lf_printf(file, "#endif /* _");
- nr += lf_print__ucase_filename(file);
- nr += lf_printf(file, "_*/\n");
- break;
- default:
- ASSERT(0);
- }
- return nr;
-}
-
-
-int
-lf_print_function_type(lf *file,
- const char *type,
- const char *prefix,
- const char *trailing_space)
-{
- int nr = 0;
- nr += lf_printf(file, "%s\\\n(%s)", prefix, type);
- if (trailing_space != NULL)
- nr += lf_printf(file, "%s", trailing_space);
-#if 0
- const char *type_pointer = strrchr(type, '*');
- int type_pointer_offset = (type_pointer != NULL
- ? type_pointer - type
- : 0);
- if (type_pointer == NULL) {
- lf_printf(file, "%s %s", type, prefix);
- }
- else {
- char *munged_type = (char*)zalloc(strlen(type)
- + strlen(prefix)
- + strlen(" * ")
- + 1);
- strcpy(munged_type, type);
- munged_type[type_pointer_offset] = '\0';
- if (type_pointer_offset > 0 && type[type_pointer_offset-1] != ' ')
- strcat(munged_type, " ");
- strcat(munged_type, prefix);
- strcat(munged_type, " ");
- strcat(munged_type, type + type_pointer_offset);
- lf_printf(file, "%s", munged_type);
- free(munged_type);
- }
- if (trailing_space != NULL && type_pointer_offset < strlen(type) - 1)
- lf_printf(file, trailing_space);
-#endif
- return nr;
-}
-
+++ /dev/null
-/* This file is part of the program psim.
-
- Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-
- */
-
-
-/* LF: Line Numbered Output Stream */
-
-#include "ansidecl.h"
-
-typedef struct _lf lf;
-
-typedef enum {
- lf_is_h,
- lf_is_c,
- lf_is_text,
-} lf_file_type;
-
-
-typedef enum {
- lf_include_references,
- lf_omit_references,
-} lf_file_references;
-
-
-/* Open the file NAME for writing. REAL_NAME is to be included in any
- line number outputs. The output of line number information can be
- suppressed with LINE_NUMBERS */
-
-extern lf *lf_open
-(const char *name,
- const char *real_name,
- lf_file_references file_references,
- lf_file_type type,
- const char *program);
-
-extern void lf_close
-(lf *file);
-
-
-/* Basic output functions */
-
-extern int lf_putchr
-(lf *file,
- const char ch);
-
-extern int lf_putstr
-(lf *file,
- const char *string);
-
-extern int lf_putint
-(lf *file,
- int decimal);
-
-extern int lf_putbin
-(lf *file,
- int decimal,
- int width);
-
-extern int lf_printf
-(lf *file,
- const char *fmt,
- ...) ATTRIBUTE_PRINTF_2;
-
-
-/* Indentation control.
-
- lf_indent_suppress suppresses indentation on the next line (current
- line if that has not yet been started) */
-
-extern void lf_indent_suppress
-(lf *file);
-
-extern void lf_indent
-(lf *file,
- int delta);
-
-
-/* Print generic text: */
-
-
-extern int lf_print__gnu_copyleft
-(lf *file);
-
-extern int lf_print__file_start
-(lf *file);
-
-extern int lf_print__this_file_is_empty
-(lf *file);
-
-extern int lf_print__file_finish
-(lf *file);
-
-extern int lf_print__internal_reference
-(lf *file);
-
-extern int lf_print__external_reference
-(lf *file,
- int line_nr,
- const char *file_name);
-
-extern int lf_print__ucase_filename
-(lf *file);
-
-/* Tab prefix is suppressed */
-
-extern int lf_print__c_code
-(lf *file,
- const char *code);
-
-
-extern int lf_print_function_type
-(lf *file,
- const char *type,
- const char *prefix,
- const char *trailing_space);
EXTRA_LIBRARIES += %D%/libigen.a
%C%_libigen_a_SOURCES = \
%D%/table.c \
- %D%/lf.c \
+ %D%/lf-ppc.c \
%D%/dumpf.c \
%D%/ld-decode.c \
%D%/ld-cache.c \
%D%/gen-support.c
%C%_libigen_a_LIBADD = \
igen/filter_host.o \
+ igen/lf.o \
igen/misc.o
%C%_igen_SOURCES = %D%/igen.c
table_entry_print_cpp_line_nr(lf *file,
table_entry *entry)
{
- lf_print__external_reference(file, entry->line_nr, entry->file_name);
+ lf_print__external_ref(file, entry->line_nr, entry->file_name);
}