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.
This commit is contained in:
George Koehler 2017-11-13 14:23:44 -05:00
parent e04166b85d
commit 5301cceee3
11 changed files with 55 additions and 5 deletions

View file

@ -237,6 +237,7 @@ float_cst(str, sz, buf)
#endif /* USE_FLT */ #endif /* USE_FLT */
#ifdef CODE_GENERATOR #ifdef CODE_GENERATOR
void
con_float() con_float()
{ {
char buf[8]; char buf[8];

View file

@ -15,6 +15,7 @@ static char rcs_mh[]= ID_MH ;
* machine dependent back end routines for the Intel 80386 * machine dependent back end routines for the Intel 80386
*/ */
void
con_part(sz,w) register sz; word w; { con_part(sz,w) register sz; word w; {
while (part_size % sz) while (part_size % sz)
@ -32,6 +33,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz; part_size += sz;
} }
void
con_mult(sz) word sz; { con_mult(sz) word sz; {
long l; long l;
@ -92,6 +94,7 @@ long si_off;
long di_off; long di_off;
int firstreg; int firstreg;
int
regscore(off, size, typ, score, totyp) regscore(off, size, typ, score, totyp)
long off; long off;
{ {
@ -104,6 +107,7 @@ regscore(off, size, typ, score, totyp)
return score; return score;
} }
void
i_regsave() i_regsave()
{ {
si_off = -1; si_off = -1;
@ -111,6 +115,7 @@ i_regsave()
firstreg = 0; firstreg = 0;
} }
void
f_regsave() f_regsave()
{ {
if (si_off != di_off) { if (si_off != di_off) {
@ -133,6 +138,7 @@ f_regsave()
fprintf(codefile, "mov edi,%ld(ebp)\n", di_off); fprintf(codefile, "mov edi,%ld(ebp)\n", di_off);
} }
void
regsave(regstr, off, size) regsave(regstr, off, size)
char *regstr; char *regstr;
long off; long off;
@ -147,6 +153,7 @@ regsave(regstr, off, size)
} }
} }
void
regreturn() regreturn()
{ {
if (firstreg == 1) { if (firstreg == 1) {
@ -165,6 +172,7 @@ regreturn()
static int gdb_flag = 0; static int gdb_flag = 0;
static char *fp_hook_nam; static char *fp_hook_nam;
void
mach_option(s) mach_option(s)
char *s; char *s;
{ {

View file

@ -12,6 +12,9 @@ static char rcsid[]= "$Id$" ;
* machine dependent back end routines for the Intel 8080. * machine dependent back end routines for the Intel 8080.
*/ */
#include <stdlib.h> /* atol */
void
con_part(sz,w) register sz; word w; { con_part(sz,w) register sz; word w; {
while (part_size % sz) while (part_size % sz)
@ -30,8 +33,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz; part_size += sz;
} }
long atol(); void
con_mult(sz) word sz; { con_mult(sz) word sz; {
if (argval != 4) if (argval != 4)
@ -39,6 +41,7 @@ con_mult(sz) word sz; {
fprintf(codefile,".data4\t%ld\n",atol(str)); fprintf(codefile,".data4\t%ld\n",atol(str));
} }
void
con_float() { con_float() {
static int warning_given; static int warning_given;
int i = argval; int i = argval;

View file

@ -13,6 +13,7 @@ static char rcs_mh[]= ID_MH ;
* machine dependent back end routines for the Intel 8086 * machine dependent back end routines for the Intel 8086
*/ */
void
con_part(sz,w) register sz; word w; { con_part(sz,w) register sz; word w; {
while (part_size % sz) while (part_size % sz)
@ -31,6 +32,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz; part_size += sz;
} }
void
con_mult(sz) word sz; { con_mult(sz) word sz; {
long l; long l;
@ -83,6 +85,7 @@ long si_off;
long di_off; long di_off;
int firstreg; int firstreg;
int
regscore(off, size, typ, score, totyp) regscore(off, size, typ, score, totyp)
long off; long off;
{ {
@ -95,6 +98,7 @@ regscore(off, size, typ, score, totyp)
return score; return score;
} }
void
i_regsave() i_regsave()
{ {
si_off = -1; si_off = -1;
@ -102,6 +106,7 @@ i_regsave()
firstreg = 0; firstreg = 0;
} }
void
f_regsave() f_regsave()
{ {
if (si_off != di_off) { if (si_off != di_off) {
@ -130,6 +135,7 @@ f_regsave()
fprintf(codefile, "mov si,%ld(bp)\n", si_off); fprintf(codefile, "mov si,%ld(bp)\n", si_off);
} }
void
regsave(regstr, off, size) regsave(regstr, off, size)
char *regstr; char *regstr;
long off; long off;
@ -144,6 +150,7 @@ regsave(regstr, off, size)
} }
} }
void
regreturn() regreturn()
{ {
if (firstreg == 1) { if (firstreg == 1) {

View file

@ -17,6 +17,7 @@
#include <stb.h> #include <stb.h>
void
con_part(sz,w) register sz; word w; { con_part(sz,w) register sz; word w; {
while (part_size % sz) while (part_size % sz)
@ -43,6 +44,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz; part_size += sz;
} }
void
con_mult(sz) word sz; { con_mult(sz) word sz; {
if (sz != 4) if (sz != 4)
@ -57,6 +59,7 @@ con_mult(sz) word sz; {
#define FL_MSB_AT_LOW_ADDRESS 1 #define FL_MSB_AT_LOW_ADDRESS 1
#include <con_float> #include <con_float>
int
regscore(off,size,typ,score,totyp) regscore(off,size,typ,score,totyp)
long off; long off;
{ {
@ -93,6 +96,7 @@ struct regsav_t {
int regnr; int regnr;
void
i_regsave() i_regsave()
{ {
regnr = 0; regnr = 0;
@ -100,6 +104,7 @@ i_regsave()
full nlocals; full nlocals;
void
regreturn() regreturn()
{ {
register struct regsav_t *p; register struct regsav_t *p;
@ -127,6 +132,7 @@ regreturn()
fputs("unlk a6\nrts\n", codefile); fputs("unlk a6\nrts\n", codefile);
} }
void
f_regsave() f_regsave()
{ {
register struct regsav_t *p; register struct regsav_t *p;
@ -176,6 +182,7 @@ f_regsave()
} }
} }
void
regsave(s,off,size) regsave(s,off,size)
char *s; char *s;
long off; long off;
@ -196,6 +203,7 @@ prolog(n) full n; {
#ifdef MACH_OPTIONS #ifdef MACH_OPTIONS
static int gdb_flag = 0; static int gdb_flag = 0;
void
mach_option(s) mach_option(s)
char *s; char *s;
{ {

View file

@ -13,6 +13,7 @@
static long framesize; static long framesize;
void
con_part(int sz, word w) con_part(int sz, word w)
{ {
while (part_size % sz) while (part_size % sz)
@ -34,6 +35,7 @@ con_part(int sz, word w)
part_size += sz; part_size += sz;
} }
void
con_mult(word sz) 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. */ /* Initialise regvar system for one function. */
void
i_regsave(void) i_regsave(void)
{ {
int i; int i;
@ -163,6 +166,7 @@ i_regsave(void)
/* Mark a register as being saved. */ /* Mark a register as being saved. */
void
regsave(const char* regname, long offset, int size) regsave(const char* regname, long offset, int size)
{ {
int regnum = atoi(regname + 1); int regnum = atoi(regname + 1);
@ -223,6 +227,7 @@ saveloadregs(const char* ops, const char* opm, const char *opf)
} }
} }
void
f_regsave(void) f_regsave(void)
{ {
int reg; int reg;
@ -248,6 +253,7 @@ f_regsave(void)
/* Restore all saved registers. */ /* Restore all saved registers. */
void
regreturn(void) regreturn(void)
{ {
saveloadregs("lwz", "lmw", "lfd"); saveloadregs("lwz", "lmw", "lfd");

View file

@ -14,6 +14,9 @@ static char rcsid[] = "$Id$";
#include "state.h" #include "state.h"
#include "equiv.h" #include "equiv.h"
#include "extern.h" #include "extern.h"
#ifdef REGVARS
#include "regvar.h" /* regreturn */
#endif
/* /*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.

View file

@ -81,6 +81,9 @@ extern char em_flag[];
extern short em_ptyp[]; extern short em_ptyp[];
/* machine dependent */ /* machine dependent */
void con_part(int, word);
void con_mult(word);
void con_float(void);
void prolog(full nlocals); void prolog(full nlocals);
void mes(word); void mes(word);

View file

@ -36,3 +36,10 @@ void unlinkregs(void);
#else #else
#define PICK_REGVAR(off, size) isregvar(off) #define PICK_REGVAR(off, size) isregvar(off)
#endif #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);

View file

@ -66,3 +66,7 @@ void garbage_collect(void);
void itokcost(void); void itokcost(void);
void error(const char *s, ...); void error(const char *s, ...);
void fatal(const char *s, ...); void fatal(const char *s, ...);
#ifdef MACH_OPTIONS
void mach_option(char *); /* machine dependent */
#endif

View file

@ -12,7 +12,7 @@ int framesize;
/* Write out a constant data section. */ /* Write out a constant data section. */
con_part(int sz, word w) void con_part(int sz, word w)
{ {
while (part_size % sz) while (part_size % sz)
part_size++; part_size++;
@ -29,7 +29,7 @@ con_part(int sz, word w)
part_size += sz; part_size += sz;
} }
con_mult(word sz) void con_mult(word sz)
{ {
if (argval != 4) if (argval != 4)
fatal("bad icon/ucon size"); fatal("bad icon/ucon size");
@ -49,7 +49,7 @@ void prolog(full nlocals)
fprintf(codefile, "push fp, lr\n"); fprintf(codefile, "push fp, lr\n");
fprintf(codefile, "mov fp, sp\n"); fprintf(codefile, "mov fp, sp\n");
if (nlocals > 0) if (nlocals > 0)
fprintf(codefile, "sub sp, #%d\n", nlocals); fprintf(codefile, "sub sp, #%ld\n", nlocals);
framesize = nlocals; framesize = nlocals;
} }