Line 1... |
Line 1... |
/* generate.c -- generates file execgen.c from instruction set
|
/* generate.c -- generates file execgen.c from instruction set
|
|
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
|
Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
|
Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
|
|
Copyright (C) 2008 Embecosm Limited
|
|
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
|
|
|
This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
|
|
|
|
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/>. */
|
|
|
This file is part of OpenRISC 1000 Architectural Simulator.
|
/* This program is commented throughout in a fashion suitable for processing
|
|
with Doxygen. */
|
|
|
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 2 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, write to the Free Software
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
|
|
/* Autoconf and/or portability configuration */
|
|
#include "config.h"
|
|
#include "port.h"
|
|
|
|
/* System includes */
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <string.h>
|
|
#include <stdarg.h>
|
#include <stdarg.h>
|
#include <ctype.h>
|
|
|
|
#include "config.h"
|
/* Package includes */
|
#include "opcode/or32.h"
|
#include "opcode/or32.h"
|
|
|
static char *in_file;
|
static char *in_file;
|
static char *out_file;
|
static char *out_file;
|
|
|
/* Whether this instruction stores something in register */
|
/* Whether this instruction stores something in register */
|
static int write_to_reg;
|
static int write_to_reg;
|
|
|
static int out_lines = 0;
|
static int out_lines = 0;
|
|
|
void debug(int level, const char *format, ...)
|
|
{
|
|
#if DEBUG
|
|
char *p;
|
|
va_list ap;
|
|
|
|
if ((p = malloc(1000)) == NULL)
|
|
return;
|
|
va_start(ap, format);
|
|
(void) vsnprintf(p, 1000, format, ap);
|
|
va_end(ap);
|
|
printf("%s\n", p);
|
|
fflush(stdout);
|
|
free(p);
|
|
#endif
|
|
}
|
|
|
|
static int shift_fprintf(int level, FILE *f, const char *fmt, ...)
|
static int shift_fprintf(int level, FILE *f, const char *fmt, ...)
|
{
|
{
|
va_list ap;
|
va_list ap;
|
int i;
|
int i;
|
|
|
Line 275... |
Line 268... |
}
|
}
|
|
|
/* Generates .c file header */
|
/* Generates .c file header */
|
static int generate_header (FILE *fo)
|
static int generate_header (FILE *fo)
|
{
|
{
|
fprintf (fo, "/* This file was automatically generated by generate (see cpu/or32/generate.c) */\n\n");
|
fprintf (fo, "/* execgen.c -- Automatically generated decoder\n");
|
fprintf (fo, "static inline void decode_execute (struct iqueue_entry *current)\n{\n");
|
fprintf (fo, "\n");
|
|
fprintf (fo, " Copyright (C) 1999 Damjan Lampret, lampret@opencores.org\n");
|
|
fprintf (fo, " Copyright (C) 2008 Embecosm Limited\n");
|
|
fprintf (fo, "\n");
|
|
fprintf (fo, " Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>\n");
|
|
fprintf (fo, "\n");
|
|
fprintf (fo, " This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.\n");
|
|
fprintf (fo, "\n");
|
|
fprintf (fo, " This program is free software; you can redistribute it and/or modify it\n");
|
|
fprintf (fo, " under the terms of the GNU General Public License as published by the Free\n");
|
|
fprintf (fo, " Software Foundation; either version 3 of the License, or (at your option)\n");
|
|
fprintf (fo, " any later version.\n");
|
|
fprintf (fo, "\n");
|
|
fprintf (fo, " This program is distributed in the hope that it will be useful, but WITHOUT\n");
|
|
fprintf (fo, " ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n");
|
|
fprintf (fo, " FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n");
|
|
fprintf (fo, " more details.\n");
|
|
fprintf (fo, "\n");
|
|
fprintf (fo, " You should have received a copy of the GNU General Public License along\n");
|
|
fprintf (fo, " with this program. If not, see <http://www.gnu.org/licenses/>. */\n");
|
|
fprintf (fo, "\n");
|
|
fprintf (fo, "/* This program is commented throughout in a fashion suitable for processing\n");
|
|
fprintf (fo, " with Doxygen. */\n");
|
|
fprintf (fo, "\n");
|
|
|
|
fprintf (fo, "/* This file was automatically generated by generate (see\n");
|
|
fprintf (fo, " cpu/or32/generate.c) */\n\n");
|
|
fprintf (fo, "static void decode_execute (struct iqueue_entry *current)\n{\n");
|
fprintf (fo, " uint32_t insn = current->insn;\n");
|
fprintf (fo, " uint32_t insn = current->insn;\n");
|
out_lines = 5;
|
out_lines = 5;
|
return 0;
|
return 0;
|
}
|
}
|
|
|