Commit ca695ac9 by Jan Brittenson

bytecode

From-SVN: r5379
parent 86d7f2db
......@@ -399,6 +399,9 @@ CPLUS_OBJS = cp-parse.o cp-decl.o cp-decl2.o \
cp-expr.o cp-pt.o cp-edsel.o cp-xref.o \
$(CPLUS_INPUT) cp-spew.o c-common.o
# Files specific to the C interpreter bytecode compiler(s).
BC_OBJS = bc-emit.o bc-optab.o
# Language-independent object files.
OBJS = toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o \
function.o stmt.o expr.o calls.o expmed.o explow.o optabs.o varasm.o \
......@@ -461,6 +464,7 @@ CONFIG_H =
RTL_H = rtl.h rtl.def machmode.h machmode.def
TREE_H = tree.h real.h tree.def machmode.h machmode.def
CPLUS_TREE_H = $(TREE_H) cp-tree.h cp-tree.def
BYTECODE_H = bytecode.h bc-emit.h bc-optab.h
# Avoid a lot of time thinking about remaking Makefile.in and *.def.
.SUFFIXES: .in .def
......@@ -484,7 +488,7 @@ for-bootstrap: start.encap $(LIBGCC)
rest.encap: $(LIBGCC) stmp-headers $(STMP_FIXPROTO) $(EXTRA_PARTS)
# This is what is made with the host's compiler
# whether making a cross compiler or not.
native: config.status cpp $(LANGUAGES) $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2)
native: bytecode config.status cpp $(LANGUAGES) $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2)
# Define the names for selecting languages in LANGUAGES.
C c: cc1
......@@ -545,14 +549,14 @@ g++-cross: $(srcdir)/g++.c
$(CC) $(ALL_CFLAGS) $(INCLUDES) $(LDFLAGS) -o g++-cross \
-DGCC_NAME=\"$(target)-gcc\" $(srcdir)/g++.c version.o $(LIBS)
cc1:$(P) $(C_OBJS) $(OBJS) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1 $(C_OBJS) $(OBJS) $(LIBS)
cc1:$(P) $(C_OBJS) $(OBJS) $(BC_OBJS) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1 $(C_OBJS) $(OBJS) $(BC_OBJS) $(LIBS)
cc1plus:$(P) $(CPLUS_OBJS) $(OBJS) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1plus $(CPLUS_OBJS) $(OBJS) $(LIBS)
cc1plus:$(P) $(CPLUS_OBJS) $(OBJS) $(BC_OBJS) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1plus $(CPLUS_OBJS) $(BC_OBJS) $(OBJS) $(LIBS)
cc1obj:$(P) $(OBJC_OBJS) $(OBJS) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1obj $(OBJC_OBJS) $(OBJS) $(LIBS)
cc1obj:$(P) $(OBJC_OBJS) $(OBJS) $(BC_OBJS) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1obj $(OBJC_OBJS) $(OBJS) $(BC_OBJS) $(LIBS)
# Copy float.h from its source.
gfloat.h: $(FLOAT_H)
......@@ -1247,6 +1251,63 @@ $(HOST_PREFIX_1)malloc.o: malloc.c
$(HOST_PREFIX_1):
touch $(HOST_PREFIX_1)
# Remake bytecode files.
# BI_ALL=bi-run.o
BI_ALL=
BC_ALL=bc-opname.h bc-opcode.h bc-arity.h
BI_OBJ=bi-parser.o bi-lexer.o bi-reverse.o
bc-emit.o : bc-emit.c $(CONFIG_H) $(BYTECODE_H)
bc-optab.o : bc-optab.c bc-typecd.def $(CONFIG_H) $(BYTECODE_H)
bytecode: $(BI_ALL) $(BC_ALL)
bi-arity: bi-arity.o
bi-opcode: bi-opcode.o
bi-opname: bi-opname.o
bi-unparse: bi-unparse.o
bi-lexer: bi-lexer.o
bi-arity bi-opcode bi-opname bi-unparse bi-lexer: $(BI_OBJ)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $^ $(LEXLIB)
bi-run.o: $(srcdir)/bi-run.c $(srcdir)/bi-run.h $(srcdir)/bc-typecd.h bc-opname.h bc-arity.h bc-opcode.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $<
bi-parser.c: $(srcdir)/bi-parser.y $(srcdir)/bi-parser.h
bi-parser.o: $(srcdir)/bi-parser.c $(srcdir)/bi-defs.h
$(CC) $(CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $<
bi-lexer.c: $(srcdir)/bi-lexer.l $(srcdir)/bi-parser.h
bi-lexer.o: bi-lexer.c bi-parser.h
$(CC) $(CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $<
bc-arity.h: $(srcdir)/bytecode.def bi-arity
-rm -f $@
bi-arity <$< >$@
bc-opcode.h: $(srcdir)/bytecode.def bi-opcode
-rm -f $@
bi-opcode <$< >$@
bc-opname.h: $(srcdir)/bytecode.def bi-opname
-rm -f $@
bi-opname <$< >$@
bytecode.mostlyclean:
-rm -f bc-arity.h bc-opcode.h bc-opname.h
bytecode.distclean bytecode.clean: bytecode.mostlyclean
-rm -f bi-arity bi-opcode bi-opname bi-unparse bi-lexer
bytecode.realclean: bytecode.clean
-rm -f bi-parser.c bi-lexer.c bi-parser.h
# Remake cpp and protoize.
# Making the preprocessor
......@@ -1507,7 +1568,7 @@ $(srcdir)/INSTALL: install1.texi install.texi
# `realclean' also deletes everything that could be regenerated automatically.
mostlyclean:
mostlyclean: bytecode.mostlyclean
-rm -f $(STAGESTUFF)
# Clean the objc subdir if we created one.
if [ -d objc ]; then \
......@@ -1545,7 +1606,7 @@ mostlyclean:
# Delete all files made by compilation
# that don't exist in the distribution.
clean: mostlyclean
clean: mostlyclean bytecode.clean
# It may not be quite desirable to delete unprotoize.c here,
# but the spec for `make clean' requires it.
# Using unprotoize.c is not quite right in the first place,
......@@ -1557,7 +1618,7 @@ clean: mostlyclean
# Delete all files that users would normally create
# while building and installing GCC.
distclean: clean
distclean: clean bytecode.distclean
-rm -f tm.h aux-output.c config.h md config.status tconfig.h hconfig.h
-rm -f Makefile *.oaux
-rm -fr stage1 stage2 stage3 stage4
......@@ -1581,7 +1642,7 @@ extraclean: distclean
# Get rid of every file that's generated from some other file.
# Most of these files ARE PRESENT in the GCC distribution.
realclean: distclean
realclean: distclean bytecode.realclean
-rm -f c-parse.y objc-parse.y
-rm -f cp-parse.c cp-parse.h cp-parse.output
-rm -f objc-parse.c objc-parse.output
......
......@@ -20,6 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "config.h"
#include "tree.h"
#include "function.h"
#ifdef HANDLE_SYSV_PRAGMA
......@@ -45,20 +46,7 @@ handle_pragma_token (string, token)
char *string;
tree token;
{
static enum pragma_state
{
ps_start,
ps_done,
ps_bad,
ps_weak,
ps_name,
ps_equals,
ps_value,
ps_pack,
ps_left,
ps_align,
ps_right
} state = ps_start, type;
static enum pragma_state state = ps_start, type;
static char *name;
static char *value;
static int align;
......@@ -76,24 +64,8 @@ handle_pragma_token (string, token)
{
#ifdef HANDLE_PRAGMA_WEAK
if (HANDLE_PRAGMA_WEAK)
{
if (state == ps_name || state == ps_value)
{
fprintf (asm_out_file, "\t%s\t", WEAK_ASM_OP);
ASM_OUTPUT_LABELREF (asm_out_file, name);
fputc ('\n', asm_out_file);
if (state == ps_value)
{
fprintf (asm_out_file, "\t%s\t", SET_ASM_OP);
ASM_OUTPUT_LABELREF (asm_out_file, name);
fputc (',', asm_out_file);
ASM_OUTPUT_LABELREF (asm_out_file, value);
fputc ('\n', asm_out_file);
}
}
else if (! (state == ps_done || state == ps_start))
warning ("malformed `#pragma weak'");
}
handle_pragma_weak (state, asm_out_file, name, value);
#endif /* HANDLE_PRAMA_WEAK */
}
......
......@@ -42,8 +42,29 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "regs.h"
#include "insn-config.h"
#include "real.h"
#include "obstack.h"
#include "bytecode.h"
#include "machmode.h"
#include "bc-opcode.h"
#include "bc-typecd.h"
#include "bc-optab.h"
#include "bc-emit.h"
#include <stdio.h>
/* Opcode names */
#ifdef BCDEBUG_PRINT_CODE
char *opcode_name[] =
{
#include "bc-opname.h"
"***END***"
};
#endif
/* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
After rtl generation, it is 1 plus the largest register number used. */
......@@ -203,6 +224,11 @@ extern int emit_lineno;
rtx change_address ();
void init_emit ();
extern struct obstack *rtl_obstack;
extern int stack_depth;
extern int max_stack_depth;
/* rtx gen_rtx (code, mode, [element1, ..., elementn])
**
** This routine generates an RTX of the size specified by
......@@ -1216,8 +1242,12 @@ change_address (memref, mode, addr)
rtx
gen_label_rtx ()
{
register rtx label = gen_rtx (CODE_LABEL, VOIDmode, 0, 0, 0,
label_num++, NULL_PTR);
register rtx label;
label = output_bytecode
? bc_gen_rtx (0, 0, bc_get_bytecode_label ())
: gen_rtx (CODE_LABEL, VOIDmode, 0, 0, 0, label_num++, NULL_PTR);
LABEL_NUSES (label) = 0;
return label;
}
......@@ -2559,6 +2589,13 @@ emit_line_note (file, line)
char *file;
int line;
{
if (output_bytecode)
{
/* FIXME: for now we do nothing, but eventually we will have to deal with
debugging information. */
return 0;
}
emit_filename = file;
emit_lineno = line;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -32,6 +32,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "integrate.h"
#include "real.h"
#include "function.h"
#include "bytecode.h"
#include "obstack.h"
#define obstack_chunk_alloc xmalloc
......@@ -2850,9 +2851,16 @@ void
output_inline_function (fndecl)
tree fndecl;
{
rtx head = DECL_SAVED_INSNS (fndecl);
rtx head;
rtx last;
if (output_bytecode)
{
warning ("`inline' ignored for bytecode output");
return;
}
head = DECL_SAVED_INSNS (fndecl);
current_function_decl = fndecl;
/* This call is only used to initialize global variables. */
......
......@@ -32,6 +32,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "recog.h"
#include "reload.h"
#include "real.h"
#include "bytecode.h"
#ifndef REGISTER_MOVE_COST
#define REGISTER_MOVE_COST(x, y) 2
......@@ -413,6 +414,13 @@ fix_register (name, fixed, call_used)
{
int i;
if (output_bytecode)
{
warning ("request to mark `%s' as %s ignored by bytecode compiler",
name, call_used ? "call-used" : "fixed");
return;
}
/* Decode the name and update the primary form of
the register info. */
......
......@@ -139,6 +139,22 @@ typedef struct rtx_def
The number of operands and their types are controlled
by the `code' field, according to rtl.def. */
rtunion fld[1];
/* The rest is used instead of the above if bytecode is being output */
/* For static or external objects. */
char *label;
/* From the named label, or the local variable pointer or the
argument pointer, depending on context. */
int offset;
/* For goto labels inside bytecode functions. */
struct bc_label *bc_label;
/* A unique identifier */
int uid;
} *rtx;
/* Add prototype support. */
......@@ -640,6 +656,7 @@ extern rtx gen_rtx PROTO((enum rtx_code, enum machine_mode, ...));
extern rtvec gen_rtvec PROTO((int, ...));
#else
extern rtx bc_gen_rtx ();
extern rtx gen_rtx ();
extern rtvec gen_rtvec ();
#endif
......
......@@ -57,6 +57,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h"
#endif
#include "bytecode.h"
#include "bc-emit.h"
#ifdef VMS
/* The extra parameters substantially improve the I/O performance. */
......@@ -211,6 +214,9 @@ int errorcount = 0;
int warningcount = 0;
int sorrycount = 0;
/* Flag to output bytecode instead of native assembler */
int output_bytecode = 0;
/* Pointer to function to compute the name to use to print a declaration. */
char *(*decl_printable_name) ();
......@@ -515,6 +521,7 @@ struct { char *string; int *variable; int on_value;} f_options[] =
{"inhibit-size-directive", &flag_inhibit_size_directive, 1},
{"verbose-asm", &flag_verbose_asm, 1},
{"gnu-linker", &flag_gnu_linker, 1}
{"bytecode", &output_bytecode, 1}
};
/* Table of language-specific options. */
......@@ -885,11 +892,14 @@ void
fatal_insn_not_found (insn)
rtx insn;
{
if (INSN_CODE (insn) < 0)
error ("internal error--unrecognizable insn:", 0);
else
error ("internal error--insn does not satisfy its constraints:", 0);
debug_rtx (insn);
if (!output_bytecode)
{
if (INSN_CODE (insn) < 0)
error ("internal error--unrecognizable insn:", 0);
else
error ("internal error--insn does not satisfy its constraints:", 0);
debug_rtx (insn);
}
if (asm_out_file)
fflush (asm_out_file);
if (aux_info_file)
......@@ -1585,6 +1595,8 @@ compile_file (name)
init_obstacks ();
init_tree_codes ();
init_lex ();
/* Some of these really don't need to be called when generating bytecode,
but the options would have to be parsed first to know that. -bson */
init_rtl ();
init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
|| debug_info_level == DINFO_LEVEL_VERBOSE);
......@@ -1813,34 +1825,51 @@ compile_file (name)
input_file_stack->next = 0;
input_file_stack->name = input_filename;
ASM_FILE_START (asm_out_file);
if (!output_bytecode)
{
ASM_FILE_START (asm_out_file);
}
/* Output something to inform GDB that this compilation was by GCC. */
/* Output something to inform GDB that this compilation was by GCC. Also
serves to tell GDB file consists of bytecodes. */
if (output_bytecode)
fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
else
{
#ifndef ASM_IDENTIFY_GCC
fprintf (asm_out_file, "gcc2_compiled.:\n");
fprintf (asm_out_file, "gcc2_compiled.:\n");
#else
ASM_IDENTIFY_GCC (asm_out_file);
ASM_IDENTIFY_GCC (asm_out_file);
#endif
}
/* Output something to identify which front-end produced this file. */
#ifdef ASM_IDENTIFY_LANGUAGE
ASM_IDENTIFY_LANGUAGE (asm_out_file);
#endif
/* ??? Note: There used to be a conditional here
to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
This was to guarantee separation between gcc_compiled. and
the first function, for the sake of dbx on Suns.
However, having the extra zero here confused the Emacs
code for unexec, and might confuse other programs too.
Therefore, I took out that change.
In future versions we should find another way to solve
that dbx problem. -- rms, 23 May 93. */
/* Don't let the first function fall at the same address
as gcc_compiled., if profiling. */
if (profile_flag || profile_block_flag)
assemble_zeros (UNITS_PER_WORD);
if (output_bytecode)
{
if (profile_flag || profile_block_flag)
error ("profiling not supported in bytecode compilation");
}
else
{
/* ??? Note: There used to be a conditional here
to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
This was to guarantee separation between gcc_compiled. and
the first function, for the sake of dbx on Suns.
However, having the extra zero here confused the Emacs
code for unexec, and might confuse other programs too.
Therefore, I took out that change.
In future versions we should find another way to solve
that dbx problem. -- rms, 23 May 93. */
/* Don't let the first function fall at the same address
as gcc_compiled., if profiling. */
if (profile_flag || profile_block_flag)
assemble_zeros (UNITS_PER_WORD);
}
/* If dbx symbol table desired, initialize writing it
and output the predefined types. */
......@@ -1861,7 +1890,8 @@ compile_file (name)
/* Initialize yet another pass. */
init_final (main_input_filename);
if (!output_bytecode)
init_final (main_input_filename);
start_time = get_run_time ();
......@@ -2031,11 +2061,14 @@ compile_file (name)
/* Output some stuff at end of file if nec. */
end_final (main_input_filename);
if (!output_bytecode)
{
end_final (main_input_filename);
#ifdef ASM_FILE_END
ASM_FILE_END (asm_out_file);
ASM_FILE_END (asm_out_file);
#endif
}
after_finish_compilation:
......@@ -2113,24 +2146,28 @@ compile_file (name)
{
fprintf (stderr,"\n");
print_time ("parse", parse_time);
print_time ("integration", integration_time);
print_time ("jump", jump_time);
print_time ("cse", cse_time);
print_time ("loop", loop_time);
print_time ("cse2", cse2_time);
print_time ("flow", flow_time);
print_time ("combine", combine_time);
print_time ("sched", sched_time);
print_time ("local-alloc", local_alloc_time);
print_time ("global-alloc", global_alloc_time);
print_time ("sched2", sched2_time);
print_time ("dbranch", dbr_sched_time);
print_time ("shorten-branch", shorten_branch_time);
print_time ("stack-reg", stack_reg_time);
print_time ("final", final_time);
print_time ("varconst", varconst_time);
print_time ("symout", symout_time);
print_time ("dump", dump_time);
if (!output_bytecode)
{
print_time ("integration", integration_time);
print_time ("jump", jump_time);
print_time ("cse", cse_time);
print_time ("loop", loop_time);
print_time ("cse2", cse2_time);
print_time ("flow", flow_time);
print_time ("combine", combine_time);
print_time ("sched", sched_time);
print_time ("local-alloc", local_alloc_time);
print_time ("global-alloc", global_alloc_time);
print_time ("sched2", sched2_time);
print_time ("dbranch", dbr_sched_time);
print_time ("shorten-branch", shorten_branch_time);
print_time ("stack-reg", stack_reg_time);
print_time ("final", final_time);
print_time ("varconst", varconst_time);
print_time ("symout", symout_time);
print_time ("dump", dump_time);
}
}
}
......@@ -2236,6 +2273,9 @@ rest_of_compilation (decl)
tree saved_arguments = 0;
int failure = 0;
if (output_bytecode)
return;
/* If we are reconsidering an inline function
at the end of compilation, skip the stuff for making it inline. */
......@@ -3166,7 +3206,12 @@ main (argc, argv, envp)
error ("Invalid option `%s'", argv[i]);
}
else if (!strcmp (str, "p"))
profile_flag = 1;
{
if (!output_bytecode)
profile_flag = 1;
else
error ("profiling not supported in bytecode compilation");
}
else if (!strcmp (str, "a"))
{
#if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
......@@ -3325,6 +3370,18 @@ You Lose! You must define PREFERRED_DEBUGGING_TYPE!
filename = argv[i];
}
/* Initialize for bytecode output. A good idea to do this as soon as
possible after the "-f" options have been parsed. */
if (output_bytecode)
{
#ifndef TARGET_SUPPORTS_BYTECODE
/* Just die with a fatal error if not supported */
fatal ("-fbytecode can not be used for this target");
#else
bc_initialize ();
#endif
}
if (optimize == 0)
{
/* Inlining does not work if not optimizing,
......@@ -3398,10 +3455,14 @@ You Lose! You must define PREFERRED_DEBUGGING_TYPE!
}
/* Now that register usage is specified, convert it to HARD_REG_SETs. */
init_reg_sets_1 ();
if (!output_bytecode)
init_reg_sets_1 ();
compile_file (filename);
if (output_bytecode)
bc_write_file (stdout);
#ifndef OS2
#ifndef VMS
if (flag_print_mem)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment