From 5301cceee3baa298a3534b26eda47addd13e2183 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Mon, 13 Nov 2017 14:23:44 -0500 Subject: [PATCH] Declare machine-dependent functions in mach/proto/ncg This breaks all machines because the declared return type void disagrees with the implicit return type int (when I compile mach.c with clang). Unbreak i386, i80, i86, m68020, powerpc, vc4 by adding the return types to mach.c. We don't build any other machines; they are broken since commit a46ee91 (May 19, 2013) declared void prolog() and commit fd91851 (Nov 10, 2016) declared void mes(), with both declarations in mach/proto/ncg/fillem.c. Also fix mach/vc4/ncg/mach.c where type full is long, so fprintf() must use "%ld" not "%d" to print full nlocals. --- h/con_float | 1 + mach/i386/ncg/mach.c | 8 ++++++++ mach/i80/ncg/mach.c | 7 +++++-- mach/i86/ncg/mach.c | 7 +++++++ mach/m68020/ncg/mach.c | 8 ++++++++ mach/powerpc/ncg/mach.c | 6 ++++++ mach/proto/ncg/codegen.c | 3 +++ mach/proto/ncg/fillem.c | 3 +++ mach/proto/ncg/regvar.h | 7 +++++++ mach/proto/ncg/types.h | 4 ++++ mach/vc4/ncg/mach.c | 6 +++--- 11 files changed, 55 insertions(+), 5 deletions(-) diff --git a/h/con_float b/h/con_float index 903c2ce5b..b2ad2908b 100644 --- a/h/con_float +++ b/h/con_float @@ -237,6 +237,7 @@ float_cst(str, sz, buf) #endif /* USE_FLT */ #ifdef CODE_GENERATOR +void con_float() { char buf[8]; diff --git a/mach/i386/ncg/mach.c b/mach/i386/ncg/mach.c index 7514d6775..1497974be 100644 --- a/mach/i386/ncg/mach.c +++ b/mach/i386/ncg/mach.c @@ -15,6 +15,7 @@ static char rcs_mh[]= ID_MH ; * machine dependent back end routines for the Intel 80386 */ +void con_part(sz,w) register sz; word w; { while (part_size % sz) @@ -32,6 +33,7 @@ con_part(sz,w) register sz; word w; { part_size += sz; } +void con_mult(sz) word sz; { long l; @@ -92,6 +94,7 @@ long si_off; long di_off; int firstreg; +int regscore(off, size, typ, score, totyp) long off; { @@ -104,6 +107,7 @@ regscore(off, size, typ, score, totyp) return score; } +void i_regsave() { si_off = -1; @@ -111,6 +115,7 @@ i_regsave() firstreg = 0; } +void f_regsave() { if (si_off != di_off) { @@ -133,6 +138,7 @@ f_regsave() fprintf(codefile, "mov edi,%ld(ebp)\n", di_off); } +void regsave(regstr, off, size) char *regstr; long off; @@ -147,6 +153,7 @@ regsave(regstr, off, size) } } +void regreturn() { if (firstreg == 1) { @@ -165,6 +172,7 @@ regreturn() static int gdb_flag = 0; static char *fp_hook_nam; +void mach_option(s) char *s; { diff --git a/mach/i80/ncg/mach.c b/mach/i80/ncg/mach.c index 9f952f0d9..89d7b0149 100644 --- a/mach/i80/ncg/mach.c +++ b/mach/i80/ncg/mach.c @@ -12,6 +12,9 @@ static char rcsid[]= "$Id$" ; * machine dependent back end routines for the Intel 8080. */ +#include /* atol */ + +void con_part(sz,w) register sz; word w; { while (part_size % sz) @@ -30,8 +33,7 @@ con_part(sz,w) register sz; word w; { part_size += sz; } -long atol(); - +void con_mult(sz) word sz; { if (argval != 4) @@ -39,6 +41,7 @@ con_mult(sz) word sz; { fprintf(codefile,".data4\t%ld\n",atol(str)); } +void con_float() { static int warning_given; int i = argval; diff --git a/mach/i86/ncg/mach.c b/mach/i86/ncg/mach.c index a305d6d9a..817599147 100644 --- a/mach/i86/ncg/mach.c +++ b/mach/i86/ncg/mach.c @@ -13,6 +13,7 @@ static char rcs_mh[]= ID_MH ; * machine dependent back end routines for the Intel 8086 */ +void con_part(sz,w) register sz; word w; { while (part_size % sz) @@ -31,6 +32,7 @@ con_part(sz,w) register sz; word w; { part_size += sz; } +void con_mult(sz) word sz; { long l; @@ -83,6 +85,7 @@ long si_off; long di_off; int firstreg; +int regscore(off, size, typ, score, totyp) long off; { @@ -95,6 +98,7 @@ regscore(off, size, typ, score, totyp) return score; } +void i_regsave() { si_off = -1; @@ -102,6 +106,7 @@ i_regsave() firstreg = 0; } +void f_regsave() { if (si_off != di_off) { @@ -130,6 +135,7 @@ f_regsave() fprintf(codefile, "mov si,%ld(bp)\n", si_off); } +void regsave(regstr, off, size) char *regstr; long off; @@ -144,6 +150,7 @@ regsave(regstr, off, size) } } +void regreturn() { if (firstreg == 1) { diff --git a/mach/m68020/ncg/mach.c b/mach/m68020/ncg/mach.c index 915b4f6e2..4f710348d 100644 --- a/mach/m68020/ncg/mach.c +++ b/mach/m68020/ncg/mach.c @@ -17,6 +17,7 @@ #include +void con_part(sz,w) register sz; word w; { while (part_size % sz) @@ -43,6 +44,7 @@ con_part(sz,w) register sz; word w; { part_size += sz; } +void con_mult(sz) word sz; { if (sz != 4) @@ -57,6 +59,7 @@ con_mult(sz) word sz; { #define FL_MSB_AT_LOW_ADDRESS 1 #include +int regscore(off,size,typ,score,totyp) long off; { @@ -93,6 +96,7 @@ struct regsav_t { int regnr; +void i_regsave() { regnr = 0; @@ -100,6 +104,7 @@ i_regsave() full nlocals; +void regreturn() { register struct regsav_t *p; @@ -127,6 +132,7 @@ regreturn() fputs("unlk a6\nrts\n", codefile); } +void f_regsave() { register struct regsav_t *p; @@ -176,6 +182,7 @@ f_regsave() } } +void regsave(s,off,size) char *s; long off; @@ -196,6 +203,7 @@ prolog(n) full n; { #ifdef MACH_OPTIONS static int gdb_flag = 0; +void mach_option(s) char *s; { diff --git a/mach/powerpc/ncg/mach.c b/mach/powerpc/ncg/mach.c index 6e0eef98b..b67903b0a 100644 --- a/mach/powerpc/ncg/mach.c +++ b/mach/powerpc/ncg/mach.c @@ -13,6 +13,7 @@ static long framesize; +void con_part(int sz, word w) { while (part_size % sz) @@ -34,6 +35,7 @@ con_part(int sz, word w) part_size += sz; } +void con_mult(word sz) { @@ -146,6 +148,7 @@ regscore(long offset, int size, int type, int frequency, int totype) /* Initialise regvar system for one function. */ +void i_regsave(void) { int i; @@ -163,6 +166,7 @@ i_regsave(void) /* Mark a register as being saved. */ +void regsave(const char* regname, long offset, int size) { int regnum = atoi(regname + 1); @@ -223,6 +227,7 @@ saveloadregs(const char* ops, const char* opm, const char *opf) } } +void f_regsave(void) { int reg; @@ -248,6 +253,7 @@ f_regsave(void) /* Restore all saved registers. */ +void regreturn(void) { saveloadregs("lwz", "lmw", "lfd"); diff --git a/mach/proto/ncg/codegen.c b/mach/proto/ncg/codegen.c index 7339265b7..3a2d60d1a 100644 --- a/mach/proto/ncg/codegen.c +++ b/mach/proto/ncg/codegen.c @@ -14,6 +14,9 @@ static char rcsid[] = "$Id$"; #include "state.h" #include "equiv.h" #include "extern.h" +#ifdef REGVARS +#include "regvar.h" /* regreturn */ +#endif /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index c9f3fb5b3..07e6c9331 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -81,6 +81,9 @@ extern char em_flag[]; extern short em_ptyp[]; /* machine dependent */ +void con_part(int, word); +void con_mult(word); +void con_float(void); void prolog(full nlocals); void mes(word); diff --git a/mach/proto/ncg/regvar.h b/mach/proto/ncg/regvar.h index 2f3bfecd0..06c3e1207 100644 --- a/mach/proto/ncg/regvar.h +++ b/mach/proto/ncg/regvar.h @@ -36,3 +36,10 @@ void unlinkregs(void); #else #define PICK_REGVAR(off, size) isregvar(off) #endif + +/* machine dependent */ +int regscore(long, int, int, int, int); +void i_regsave(void); +void regsave(const char *, long, int); +void f_regsave(void); +void regreturn(void); diff --git a/mach/proto/ncg/types.h b/mach/proto/ncg/types.h index 2f88bfbb6..35b848e82 100644 --- a/mach/proto/ncg/types.h +++ b/mach/proto/ncg/types.h @@ -66,3 +66,7 @@ void garbage_collect(void); void itokcost(void); void error(const char *s, ...); void fatal(const char *s, ...); + +#ifdef MACH_OPTIONS +void mach_option(char *); /* machine dependent */ +#endif diff --git a/mach/vc4/ncg/mach.c b/mach/vc4/ncg/mach.c index 8832f744f..16ca94f35 100644 --- a/mach/vc4/ncg/mach.c +++ b/mach/vc4/ncg/mach.c @@ -12,7 +12,7 @@ int framesize; /* Write out a constant data section. */ -con_part(int sz, word w) +void con_part(int sz, word w) { while (part_size % sz) part_size++; @@ -29,7 +29,7 @@ con_part(int sz, word w) part_size += sz; } -con_mult(word sz) +void con_mult(word sz) { if (argval != 4) fatal("bad icon/ucon size"); @@ -49,7 +49,7 @@ void prolog(full nlocals) fprintf(codefile, "push fp, lr\n"); fprintf(codefile, "mov fp, sp\n"); if (nlocals > 0) - fprintf(codefile, "sub sp, #%d\n", nlocals); + fprintf(codefile, "sub sp, #%ld\n", nlocals); framesize = nlocals; }