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 */
#ifdef CODE_GENERATOR
void
con_float()
{
char buf[8];

View file

@ -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;
{

View file

@ -12,6 +12,9 @@ static char rcsid[]= "$Id$" ;
* machine dependent back end routines for the Intel 8080.
*/
#include <stdlib.h> /* 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;

View file

@ -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) {

View file

@ -17,6 +17,7 @@
#include <stb.h>
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 <con_float>
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;
{

View file

@ -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");

View file

@ -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.

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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;
}