Commit ebce7944 authored by Russ Cox's avatar Russ Cox

build: annotations and modifications for c2go

The main changes fall into a few patterns:

1. Replace #define with enum.

2. Add /*c2go */ comment giving effect of #define.
This is necessary for function-like #defines and
non-enum-able #defined constants.
(Not all compilers handle negative or large enums.)

3. Add extra braces in struct initializer.
(c2go does not implement the full rules.)

This is enough to let c2go typecheck the source tree.
There may be more changes once it is doing
other semantic analyses.

LGTM=minux, iant
R=minux, dave, iant
CC=golang-codereviews
https://golang.org/cl/106860045
parent 4fedb59a
......@@ -129,6 +129,14 @@ int Bungetc(Biobuf*);
int Bungetrune(Biobuf*);
long Bwrite(Biobuf*, void*, long);
int Bvprint(Biobuf*, char*, va_list);
/*c2go
int BGETC(Biobuf*);
int BGETLE2(Biobuf*);
int BGETLE4(Biobuf*);
int BPUTC(Biobuf*, int);
int BPUTLE2(Biobuf*, int);
int BPUTLE4(Biobuf*, int);
*/
#if defined(__cplusplus)
}
......
......@@ -112,6 +112,8 @@ struct Prog
char width; /* fake for DATA */
char mode; /* 16, 32, or 64 in 6l, 8l; internal use in 5g, 6g, 8g */
/*c2go uchar TEXTFLAG; */
};
// prevent incompatible type signatures between liblink and 8l on Plan 9
......@@ -167,7 +169,7 @@ struct LSym
// SDATA, SBSS
uchar* p;
int32 np;
int np;
int32 maxp;
Reloc* r;
int32 nr;
......
......@@ -23,10 +23,10 @@ vlong MAXWIDTH = (1LL<<32) - 1;
*/
Typedef typedefs[] =
{
"int", TINT, TINT32,
"uint", TUINT, TUINT32,
"uintptr", TUINTPTR, TUINT32,
0
{"int", TINT, TINT32},
{"uint", TUINT, TUINT32},
{"uintptr", TUINTPTR, TUINT32},
{0}
};
void
......
......@@ -11,10 +11,13 @@
#define TEXTFLAG reg
#define REGALLOC_R0 0
#define REGALLOC_RMAX REGEXT
#define REGALLOC_F0 NREG
#define REGALLOC_FMAX (REGALLOC_F0 + FREGEXT)
enum
{
REGALLOC_R0 = 0,
REGALLOC_RMAX = REGEXT,
REGALLOC_F0 = NREG,
REGALLOC_FMAX = REGALLOC_F0 + FREGEXT,
};
EXTERN int32 dynloc;
EXTERN uchar reg[REGALLOC_FMAX+1];
......
......@@ -636,6 +636,7 @@ splitclean(void)
}
#define CASE(a,b) (((a)<<16)|((b)<<0))
/*c2go int CASE(int, int); */
void
gmove(Node *f, Node *t)
......
......@@ -49,6 +49,24 @@
typedef struct Reg Reg;
typedef struct Rgn Rgn;
/*c2go
extern Node *Z;
enum
{
D_HI = D_NONE,
D_LO = D_NONE,
CLOAD = 5,
CREF = 5,
CINF = 1000,
LOOP = 3,
};
uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*);
uint32 LOAD(Reg*);
uint32 STORE(Reg*);
*/
// A Reg is a wrapper around a single Prog (one instruction) that holds
// register optimization information while the optimizer runs.
// r->prog is the instruction.
......@@ -71,8 +89,10 @@ struct Reg
int32 regu; // register used bitmap
};
#define R ((Reg*)0)
/*c2go extern Reg *R; */
#define NRGN 600
/*c2go enum { NRGN = 600 }; */
struct Rgn
{
Reg* enter;
......
......@@ -564,6 +564,8 @@ gotit:
* ..
*/
#define FAIL(msg) { if(debug['P']) print("\t%s; FAILURE\n", msg); return 0; }
/*c2go void FAIL(char*); */
int
shiftprop(Flow *r)
{
......
......@@ -36,6 +36,11 @@
#define NREGVAR 32
#define REGBITS ((uint32)0xffffffff)
/*c2go enum {
NREGVAR = 32,
REGBITS = 0xffffffff,
};
*/
void addsplits(void);
static Reg* firstr;
......
......@@ -28,34 +28,43 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#define NSNAME 8
#define NSYM 50
#define NREG 16
enum
{
NSNAME = 8,
NSYM = 50,
NREG = 16,
};
#include "../ld/textflag.h"
#define REGRET 0
/* -1 disables use of REGARG */
#define REGARG -1
/* compiler allocates R1 up as temps */
/* compiler allocates register variables R3 up */
#define REGEXT 10
/* these two registers are declared in runtime.h */
#define REGG (REGEXT-0)
#define REGM (REGEXT-1)
/* compiler allocates external registers R10 down */
#define REGTMP 11
#define REGSP 13
#define REGLINK 14
#define REGPC 15
#define NFREG 16
#define FREGRET 0
#define FREGEXT 7
#define FREGTMP 15
/*c2go enum { REGARG = -1 }; */
enum
{
REGRET = 0,
/* compiler allocates R1 up as temps */
/* compiler allocates register variables R3 up */
/* compiler allocates external registers R10 down */
REGEXT = 10,
/* these two registers are declared in runtime.h */
REGG = REGEXT-0,
REGM = REGEXT-1,
REGTMP = 11,
REGSP = 13,
REGLINK = 14,
REGPC = 15,
NFREG = 16,
FREGRET = 0,
FREGEXT = 7,
FREGTMP = 15,
};
/* compiler allocates register variables F0 up */
/* compiler allocates external registers F7 down */
enum as
enum
{
AXXX,
......@@ -209,35 +218,38 @@ enum as
};
/* scond byte */
#define C_SCOND ((1<<4)-1)
#define C_SBIT (1<<4)
#define C_PBIT (1<<5)
#define C_WBIT (1<<6)
#define C_FBIT (1<<7) /* psr flags-only */
#define C_UBIT (1<<7) /* up bit, unsigned bit */
#define C_SCOND_EQ 0
#define C_SCOND_NE 1
#define C_SCOND_HS 2
#define C_SCOND_LO 3
#define C_SCOND_MI 4
#define C_SCOND_PL 5
#define C_SCOND_VS 6
#define C_SCOND_VC 7
#define C_SCOND_HI 8
#define C_SCOND_LS 9
#define C_SCOND_GE 10
#define C_SCOND_LT 11
#define C_SCOND_GT 12
#define C_SCOND_LE 13
#define C_SCOND_NONE 14
#define C_SCOND_NV 15
/* D_SHIFT type */
#define SHIFT_LL 0<<5
#define SHIFT_LR 1<<5
#define SHIFT_AR 2<<5
#define SHIFT_RR 3<<5
enum
{
C_SCOND = (1<<4)-1,
C_SBIT = 1<<4,
C_PBIT = 1<<5,
C_WBIT = 1<<6,
C_FBIT = 1<<7, /* psr flags-only */
C_UBIT = 1<<7, /* up bit, unsigned bit */
C_SCOND_EQ = 0,
C_SCOND_NE = 1,
C_SCOND_HS = 2,
C_SCOND_LO = 3,
C_SCOND_MI = 4,
C_SCOND_PL = 5,
C_SCOND_VS = 6,
C_SCOND_VC = 7,
C_SCOND_HI = 8,
C_SCOND_LS = 9,
C_SCOND_GE = 10,
C_SCOND_LT = 11,
C_SCOND_GT = 12,
C_SCOND_LE = 13,
C_SCOND_NONE = 14,
C_SCOND_NV = 15,
/* D_SHIFT type */
SHIFT_LL = 0<<5,
SHIFT_LR = 1<<5,
SHIFT_AR = 2<<5,
SHIFT_RR = 3<<5,
};
enum
{
......@@ -279,3 +291,4 @@ enum
* this is the ranlib header
*/
#define SYMDEF "__.GOSYMDEF"
/*c2go extern char SYMDEF[]; */
......@@ -30,10 +30,10 @@ int cmpptr = ACMPQ;
*/
Typedef typedefs[] =
{
"int", TINT, TINT64,
"uint", TUINT, TUINT64,
"uintptr", TUINTPTR, TUINT64,
0
{"int", TINT, TINT64},
{"uint", TUINT, TUINT64},
{"uintptr", TUINTPTR, TUINT64},
{0}
};
void
......
......@@ -584,6 +584,7 @@ ginscon(int as, vlong c, Node *n2)
}
#define CASE(a,b) (((a)<<16)|((b)<<0))
/*c2go int CASE(int, int); */
/*
* Is this node a memory operand?
......
......@@ -49,6 +49,24 @@
typedef struct Reg Reg;
typedef struct Rgn Rgn;
/*c2go
extern Node *Z;
enum
{
D_HI = D_NONE,
D_LO = D_NONE,
CLOAD = 5,
CREF = 5,
CINF = 1000,
LOOP = 3,
};
uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*);
uint32 LOAD(Reg*);
uint32 STORE(Reg*);
*/
// A Reg is a wrapper around a single Prog (one instruction) that holds
// register optimization information while the optimizer runs.
// r->prog is the instruction.
......@@ -71,8 +89,10 @@ struct Reg
int32 regu; // register used bitmap
};
#define R ((Reg*)0)
/*c2go extern Reg *R; */
#define NRGN 600
/*c2go enum { NRGN = 600 }; */
struct Rgn
{
Reg* enter;
......
......@@ -35,6 +35,11 @@
#define NREGVAR 32 /* 16 general + 16 floating */
#define REGBITS ((uint32)0xffffffff)
/*c2go enum {
NREGVAR = 32,
REGBITS = 0xffffffff,
};
*/
static Reg* firstr;
static int first = 1;
......
......@@ -36,7 +36,7 @@
* amd64
*/
enum as
enum
{
AXXX,
AAAA,
......
......@@ -23,10 +23,10 @@ vlong MAXWIDTH = (1LL<<32) - 1;
*/
Typedef typedefs[] =
{
"int", TINT, TINT32,
"uint", TUINT, TUINT32,
"uintptr", TUINTPTR, TUINT32,
0
{"int", TINT, TINT32},
{"uint", TUINT, TUINT32},
{"uintptr", TUINTPTR, TUINT32},
{0}
};
void
......
......@@ -39,6 +39,7 @@
uint32 unmappedzero = 4096;
#define CASE(a,b) (((a)<<16)|((b)<<0))
/*c2go int CASE(int, int);*/
void
clearp(Prog *p)
......@@ -697,6 +698,7 @@ optoas(int op, Type *t)
}
#define FCASE(a, b, c) (((a)<<16)|((b)<<8)|(c))
/*c2go int FCASE(int, int, int); */
int
foptoas(int op, Type *t, int flg)
{
......
......@@ -49,6 +49,24 @@
typedef struct Reg Reg;
typedef struct Rgn Rgn;
/*c2go
extern Node *Z;
enum
{
D_HI = D_NONE,
D_LO = D_NONE,
CLOAD = 5,
CREF = 5,
CINF = 1000,
LOOP = 3,
};
uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*);
uint32 LOAD(Reg*);
uint32 STORE(Reg*);
*/
// A Reg is a wrapper around a single Prog (one instruction) that holds
// register optimization information while the optimizer runs.
// r->prog is the instruction.
......@@ -84,8 +102,10 @@ struct Reg
Prog* prog; // actual instruction
};
#define R ((Reg*)0)
/*c2go extern Reg *R; */
#define NRGN 600
/*c2go enum { NRGN = 600 }; */
struct Rgn
{
Reg* enter;
......
......@@ -33,7 +33,9 @@
#include "gg.h"
#include "opt.h"
#define REGEXT 0
enum {
REGEXT = 0,
};
static void conprop(Flow *r);
static void elimshortmov(Graph*);
......
......@@ -35,6 +35,11 @@
#define NREGVAR 16 /* 8 integer + 8 floating */
#define REGBITS ((uint32)0xffff)
/*c2go enum {
NREGVAR = 16,
REGBITS = (1<<NREGVAR) - 1,
};
*/
static Reg* firstr;
static int first = 1;
......
......@@ -32,7 +32,7 @@
#define NSNAME 8
#include "../ld/textflag.h"
enum as
enum
{
AXXX,
AAAA,
......
......@@ -82,7 +82,16 @@ mkanames(char *dir, char *file)
bprintf(&b, "%s/../cmd/%cl/%c.out.h", dir, ch, ch);
readfile(&in, bstr(&b));
splitlines(&lines, bstr(&in));
bprintf(&out, "char* anames%c[] = {\n", ch);
// Include link.h so that the extern declaration there is
// checked against the non-extern declaration we are generating.
bwritestr(&out, bprintf(&b, "#include <u.h>\n"));
bwritestr(&out, bprintf(&b, "#include <libc.h>\n"));
bwritestr(&out, bprintf(&b, "#include <bio.h>\n"));
bwritestr(&out, bprintf(&b, "#include <link.h>\n"));
bwritestr(&out, bprintf(&b, "\n"));
bwritestr(&out, bprintf(&b, "char* anames%c[] = {\n", ch));
for(i=0; i<lines.len; i++) {
if(hasprefix(lines.p[i], "\tA")) {
p = xstrstr(lines.p[i], ",");
......
......@@ -22,6 +22,7 @@ BEGIN{
bison = 1
grammar = 0
states = 0
open = 0
}
# In Grammar section of y.output,
......@@ -130,11 +131,26 @@ $1 == "%" {
continue
# No shift or reduce applied - found the error.
printf("\t%s, %s,\n", state, tok);
printf("\t{%s, %s,\n", state, tok);
open = 1;
break
}
next
}
# Print other lines verbatim.
open && /,$/ {
s = $0;
sub(",", "},", s)
print s
open = 0
next
}
open && /"$/ {
print $0 "}"
open = 0
next
}
{print}
......@@ -6,6 +6,7 @@
#include <libc.h>
#include "go.h"
#define TUP(x,y) (((x)<<16)|(y))
/*c2go int TUP(int, int); */
static Val tocplx(Val);
static Val toflt(Val);
......
......@@ -1110,6 +1110,7 @@ escflood(EscState *e, Node *dst)
// pass all the tests we have written so far, which we assume matches
// the level of complexity we want the escape analysis code to handle.
#define MinLevel (-2)
/*c2go enum { MinLevel = -2 };*/
static void
escwalk(EscState *e, int level, Node *dst, Node *src)
......
......@@ -139,6 +139,8 @@ yy_isalnum(int c)
#define isalnum use_yy_isalnum_instead_of_isalnum
#define DBG if(!debug['x']){}else print
/*c2go void DBG(char*, ...); */
enum
{
EOF = -1,
......@@ -516,24 +518,18 @@ saveerrors(void)
nerrors = 0;
}
/*
* macro to portably read/write archive header.
* 'cmd' is read/write/Bread/Bwrite, etc.
*/
#define HEADER_IO(cmd, f, h) cmd(f, h.name, sizeof(h.name)) != sizeof(h.name)\
|| cmd(f, h.date, sizeof(h.date)) != sizeof(h.date)\
|| cmd(f, h.uid, sizeof(h.uid)) != sizeof(h.uid)\
|| cmd(f, h.gid, sizeof(h.gid)) != sizeof(h.gid)\
|| cmd(f, h.mode, sizeof(h.mode)) != sizeof(h.mode)\
|| cmd(f, h.size, sizeof(h.size)) != sizeof(h.size)\
|| cmd(f, h.fmag, sizeof(h.fmag)) != sizeof(h.fmag)
static int
arsize(Biobuf *b, char *name)
{
struct ar_hdr a;
if (HEADER_IO(Bread, b, a))
if(Bread(b, a.name, sizeof(a.name)) != sizeof(a.name) ||
Bread(b, a.date, sizeof(a.date)) != sizeof(a.date) ||
Bread(b, a.uid, sizeof(a.uid)) != sizeof(a.uid) ||
Bread(b, a.gid, sizeof(a.gid)) != sizeof(a.gid) ||
Bread(b, a.mode, sizeof(a.mode)) != sizeof(a.mode) ||
Bread(b, a.size, sizeof(a.size)) != sizeof(a.size) ||
Bread(b, a.fmag, sizeof(a.fmag)) != sizeof(a.fmag))
return -1;
if(strncmp(a.name, name, strlen(name)) != 0)
......@@ -1858,74 +1854,74 @@ static struct
/* name lexical etype op
*/
/* basic types */
"int8", LNAME, TINT8, OXXX,
"int16", LNAME, TINT16, OXXX,
"int32", LNAME, TINT32, OXXX,
"int64", LNAME, TINT64, OXXX,
"uint8", LNAME, TUINT8, OXXX,
"uint16", LNAME, TUINT16, OXXX,
"uint32", LNAME, TUINT32, OXXX,
"uint64", LNAME, TUINT64, OXXX,
"float32", LNAME, TFLOAT32, OXXX,
"float64", LNAME, TFLOAT64, OXXX,
"complex64", LNAME, TCOMPLEX64, OXXX,
"complex128", LNAME, TCOMPLEX128, OXXX,
"bool", LNAME, TBOOL, OXXX,
"string", LNAME, TSTRING, OXXX,
"any", LNAME, TANY, OXXX,
"break", LBREAK, Txxx, OXXX,
"case", LCASE, Txxx, OXXX,
"chan", LCHAN, Txxx, OXXX,
"const", LCONST, Txxx, OXXX,
"continue", LCONTINUE, Txxx, OXXX,
"default", LDEFAULT, Txxx, OXXX,
"else", LELSE, Txxx, OXXX,
"defer", LDEFER, Txxx, OXXX,
"fallthrough", LFALL, Txxx, OXXX,
"for", LFOR, Txxx, OXXX,
"func", LFUNC, Txxx, OXXX,
"go", LGO, Txxx, OXXX,
"goto", LGOTO, Txxx, OXXX,
"if", LIF, Txxx, OXXX,
"import", LIMPORT, Txxx, OXXX,
"interface", LINTERFACE, Txxx, OXXX,
"map", LMAP, Txxx, OXXX,
"package", LPACKAGE, Txxx, OXXX,
"range", LRANGE, Txxx, OXXX,
"return", LRETURN, Txxx, OXXX,
"select", LSELECT, Txxx, OXXX,
"struct", LSTRUCT, Txxx, OXXX,
"switch", LSWITCH, Txxx, OXXX,
"type", LTYPE, Txxx, OXXX,
"var", LVAR, Txxx, OXXX,
"append", LNAME, Txxx, OAPPEND,
"cap", LNAME, Txxx, OCAP,
"close", LNAME, Txxx, OCLOSE,
"complex", LNAME, Txxx, OCOMPLEX,
"copy", LNAME, Txxx, OCOPY,
"delete", LNAME, Txxx, ODELETE,
"imag", LNAME, Txxx, OIMAG,
"len", LNAME, Txxx, OLEN,
"make", LNAME, Txxx, OMAKE,
"new", LNAME, Txxx, ONEW,
"panic", LNAME, Txxx, OPANIC,
"print", LNAME, Txxx, OPRINT,
"println", LNAME, Txxx, OPRINTN,
"real", LNAME, Txxx, OREAL,
"recover", LNAME, Txxx, ORECOVER,
"notwithstanding", LIGNORE, Txxx, OXXX,
"thetruthofthematter", LIGNORE, Txxx, OXXX,
"despiteallobjections", LIGNORE, Txxx, OXXX,
"whereas", LIGNORE, Txxx, OXXX,
"insofaras", LIGNORE, Txxx, OXXX,
{"int8", LNAME, TINT8, OXXX},
{"int16", LNAME, TINT16, OXXX},
{"int32", LNAME, TINT32, OXXX},
{"int64", LNAME, TINT64, OXXX},
{"uint8", LNAME, TUINT8, OXXX},
{"uint16", LNAME, TUINT16, OXXX},
{"uint32", LNAME, TUINT32, OXXX},
{"uint64", LNAME, TUINT64, OXXX},
{"float32", LNAME, TFLOAT32, OXXX},
{"float64", LNAME, TFLOAT64, OXXX},
{"complex64", LNAME, TCOMPLEX64, OXXX},
{"complex128", LNAME, TCOMPLEX128, OXXX},
{"bool", LNAME, TBOOL, OXXX},
{"string", LNAME, TSTRING, OXXX},
{"any", LNAME, TANY, OXXX},
{"break", LBREAK, Txxx, OXXX},
{"case", LCASE, Txxx, OXXX},
{"chan", LCHAN, Txxx, OXXX},
{"const", LCONST, Txxx, OXXX},
{"continue", LCONTINUE, Txxx, OXXX},
{"default", LDEFAULT, Txxx, OXXX},
{"else", LELSE, Txxx, OXXX},
{"defer", LDEFER, Txxx, OXXX},
{"fallthrough", LFALL, Txxx, OXXX},
{"for", LFOR, Txxx, OXXX},
{"func", LFUNC, Txxx, OXXX},
{"go", LGO, Txxx, OXXX},
{"goto", LGOTO, Txxx, OXXX},
{"if", LIF, Txxx, OXXX},
{"import", LIMPORT, Txxx, OXXX},
{"interface", LINTERFACE, Txxx, OXXX},
{"map", LMAP, Txxx, OXXX},
{"package", LPACKAGE, Txxx, OXXX},
{"range", LRANGE, Txxx, OXXX},
{"return", LRETURN, Txxx, OXXX},
{"select", LSELECT, Txxx, OXXX},
{"struct", LSTRUCT, Txxx, OXXX},
{"switch", LSWITCH, Txxx, OXXX},
{"type", LTYPE, Txxx, OXXX},
{"var", LVAR, Txxx, OXXX},
{"append", LNAME, Txxx, OAPPEND},
{"cap", LNAME, Txxx, OCAP},
{"close", LNAME, Txxx, OCLOSE},
{"complex", LNAME, Txxx, OCOMPLEX},
{"copy", LNAME, Txxx, OCOPY},
{"delete", LNAME, Txxx, ODELETE},
{"imag", LNAME, Txxx, OIMAG},
{"len", LNAME, Txxx, OLEN},
{"make", LNAME, Txxx, OMAKE},
{"new", LNAME, Txxx, ONEW},
{"panic", LNAME, Txxx, OPANIC},
{"print", LNAME, Txxx, OPRINT},
{"println", LNAME, Txxx, OPRINTN},
{"real", LNAME, Txxx, OREAL},
{"recover", LNAME, Txxx, ORECOVER},
{"notwithstanding", LIGNORE, Txxx, OXXX},
{"thetruthofthematter", LIGNORE, Txxx, OXXX},
{"despiteallobjections", LIGNORE, Txxx, OXXX},
{"whereas", LIGNORE, Txxx, OXXX},
{"insofaras", LIGNORE, Txxx, OXXX},
};
static void
......@@ -2175,50 +2171,50 @@ struct
char* name;
} lexn[] =
{
LANDAND, "ANDAND",
LANDNOT, "ANDNOT",
LASOP, "ASOP",
LBREAK, "BREAK",
LCASE, "CASE",
LCHAN, "CHAN",
LCOLAS, "COLAS",
LCOMM, "<-",
LCONST, "CONST",
LCONTINUE, "CONTINUE",
LDDD, "...",
LDEC, "DEC",
LDEFAULT, "DEFAULT",
LDEFER, "DEFER",
LELSE, "ELSE",
LEQ, "EQ",
LFALL, "FALL",
LFOR, "FOR",
LFUNC, "FUNC",
LGE, "GE",
LGO, "GO",
LGOTO, "GOTO",
LGT, "GT",
LIF, "IF",
LIMPORT, "IMPORT",
LINC, "INC",
LINTERFACE, "INTERFACE",
LLE, "LE",
LLITERAL, "LITERAL",
LLSH, "LSH",
LLT, "LT",
LMAP, "MAP",
LNAME, "NAME",
LNE, "NE",
LOROR, "OROR",
LPACKAGE, "PACKAGE",
LRANGE, "RANGE",
LRETURN, "RETURN",
LRSH, "RSH",
LSELECT, "SELECT",
LSTRUCT, "STRUCT",
LSWITCH, "SWITCH",
LTYPE, "TYPE",
LVAR, "VAR",
{LANDAND, "ANDAND"},
{LANDNOT, "ANDNOT"},
{LASOP, "ASOP"},
{LBREAK, "BREAK"},
{LCASE, "CASE"},
{LCHAN, "CHAN"},
{LCOLAS, "COLAS"},
{LCOMM, "<-"},
{LCONST, "CONST"},
{LCONTINUE, "CONTINUE"},
{LDDD, "..."},
{LDEC, "DEC"},
{LDEFAULT, "DEFAULT"},
{LDEFER, "DEFER"},
{LELSE, "ELSE"},
{LEQ, "EQ"},
{LFALL, "FALL"},
{LFOR, "FOR"},
{LFUNC, "FUNC"},
{LGE, "GE"},
{LGO, "GO"},
{LGOTO, "GOTO"},
{LGT, "GT"},
{LIF, "IF"},
{LIMPORT, "IMPORT"},
{LINC, "INC"},
{LINTERFACE, "INTERFACE"},
{LLE, "LE"},
{LLITERAL, "LITERAL"},
{LLSH, "LSH"},
{LLT, "LT"},
{LMAP, "MAP"},
{LNAME, "NAME"},
{LNE, "NE"},
{LOROR, "OROR"},
{LPACKAGE, "PACKAGE"},
{LRANGE, "RANGE"},
{LRETURN, "RETURN"},
{LRSH, "RSH"},
{LSELECT, "SELECT"},
{LSTRUCT, "STRUCT"},
{LSWITCH, "SWITCH"},
{LTYPE, "TYPE"},
{LVAR, "VAR"},
};
char*
......@@ -2240,56 +2236,56 @@ struct
char *want;
} yytfix[] =
{
"$end", "EOF",
"LLITERAL", "literal",
"LASOP", "op=",
"LBREAK", "break",
"LCASE", "case",
"LCHAN", "chan",
"LCOLAS", ":=",
"LCONST", "const",
"LCONTINUE", "continue",
"LDDD", "...",
"LDEFAULT", "default",
"LDEFER", "defer",
"LELSE", "else",
"LFALL", "fallthrough",
"LFOR", "for",
"LFUNC", "func",
"LGO", "go",
"LGOTO", "goto",
"LIF", "if",
"LIMPORT", "import",
"LINTERFACE", "interface",
"LMAP", "map",
"LNAME", "name",
"LPACKAGE", "package",
"LRANGE", "range",
"LRETURN", "return",
"LSELECT", "select",
"LSTRUCT", "struct",
"LSWITCH", "switch",
"LTYPE", "type",
"LVAR", "var",
"LANDAND", "&&",
"LANDNOT", "&^",
"LBODY", "{",
"LCOMM", "<-",
"LDEC", "--",
"LINC", "++",
"LEQ", "==",
"LGE", ">=",
"LGT", ">",
"LLE", "<=",
"LLT", "<",
"LLSH", "<<",
"LRSH", ">>",
"LOROR", "||",
"LNE", "!=",
{"$end", "EOF"},
{"LLITERAL", "literal"},
{"LASOP", "op="},
{"LBREAK", "break"},
{"LCASE", "case"},
{"LCHAN", "chan"},
{"LCOLAS", ":="},
{"LCONST", "const"},
{"LCONTINUE", "continue"},
{"LDDD", "..."},
{"LDEFAULT", "default"},
{"LDEFER", "defer"},
{"LELSE", "else"},
{"LFALL", "fallthrough"},
{"LFOR", "for"},
{"LFUNC", "func"},
{"LGO", "go"},
{"LGOTO", "goto"},
{"LIF", "if"},
{"LIMPORT", "import"},
{"LINTERFACE", "interface"},
{"LMAP", "map"},
{"LNAME", "name"},
{"LPACKAGE", "package"},
{"LRANGE", "range"},
{"LRETURN", "return"},
{"LSELECT", "select"},
{"LSTRUCT", "struct"},
{"LSWITCH", "switch"},
{"LTYPE", "type"},
{"LVAR", "var"},
{"LANDAND", "&&"},
{"LANDNOT", "&^"},
{"LBODY", "{"},
{"LCOMM", "<-"},
{"LDEC", "--"},
{"LINC", "++"},
{"LEQ", "=="},
{"LGE", ">="},
{"LGT", ">"},
{"LLE", "<="},
{"LLT", "<"},
{"LLSH", "<<"},
{"LRSH", ">>"},
{"LOROR", "||"},
{"LNE", "!="},
// spell out to avoid confusion with punctuation in error messages
"';'", "semicolon or newline",
"','", "comma",
{"';'", "semicolon or newline"},
{"','", "comma"},
};
static void
......
......@@ -20,7 +20,15 @@ enum {
#define _Init1 0xEFCDAB89
#define _Init2 0x98BADCFE
#define _Init3 0x10325476
/*c2go
enum {
_Init0 = 0x67452301,
_Init1 = 0xEFCDAB89,
_Init2 = 0x98BADCFE,
_Init3 = 0x10325476
};
*/
void
md5reset(MD5 *d)
{
......
......@@ -657,8 +657,8 @@ static void
progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit)
{
ProgInfo info;
Adr *from;
Adr *to;
Addr *from;
Addr *to;
Node *node;
int32 i;
int32 pos;
......@@ -1663,6 +1663,13 @@ livenessepilogue(Liveness *lv)
// FNV-1 hash function constants.
#define H0 2166136261UL
#define Hp 16777619UL
/*c2go
enum
{
H0 = 2166136261,
Hp = 16777619,
};
*/
static uint32
hashbitmap(uint32 h, Bvec *bv)
......
......@@ -98,6 +98,10 @@ chasejmp(Prog *p, int *jmploop)
*/
#define alive ((void*)0)
#define dead ((void*)1)
/*c2go
extern void *alive;
extern void *dead;
*/
/* mark all code reachable from firstp as alive */
static void
......
......@@ -3445,7 +3445,7 @@ smagic(Magic *m)
mask = 0xffffffffLL;
break;
case 64:
mask = 0xffffffffffffffffLL;
mask = 0xffffffffffffffffULL;
break;
}
two31 = mask ^ (mask>>1);
......@@ -3543,7 +3543,7 @@ umagic(Magic *m)
mask = 0xffffffffLL;
break;
case 64:
mask = 0xffffffffffffffffLL;
mask = 0xffffffffffffffffULL;
break;
}
two31 = mask ^ (mask>>1);
......
......@@ -34,6 +34,7 @@ struct Case
Case* link; // linked list to link
};
#define C ((Case*)nil)
/*c2go Case *C; */
void
dumpcase(Case *c0)
......
......@@ -14,66 +14,66 @@ static struct {
// is converted by bisonerrors into the yystate and yychar caused
// by that token list.
222, ',',
"unexpected comma during import block",
{222, ',',
"unexpected comma during import block"},
32, ';',
"missing import path; require quoted string",
{32, ';',
"missing import path; require quoted string"},
378, ';',
"missing { after if clause",
{378, ';',
"missing { after if clause"},
399, ';',
"missing { after switch clause",
{399, ';',
"missing { after switch clause"},
238, ';',
"missing { after for clause",
{238, ';',
"missing { after for clause"},
476, LBODY,
"missing { after for clause",
{476, LBODY,
"missing { after for clause"},
22, '{',
"unexpected semicolon or newline before {",
{22, '{',
"unexpected semicolon or newline before {"},
145, ';',
"unexpected semicolon or newline in type declaration",
{145, ';',
"unexpected semicolon or newline in type declaration"},
37, '}',
"unexpected } in channel type",
{37, '}',
"unexpected } in channel type"},
37, ')',
"unexpected ) in channel type",
{37, ')',
"unexpected ) in channel type"},
37, ',',
"unexpected comma in channel type",
{37, ',',
"unexpected comma in channel type"},
439, LELSE,
"unexpected semicolon or newline before else",
{439, LELSE,
"unexpected semicolon or newline before else"},
258, ',',
"name list not allowed in interface type",
{258, ',',
"name list not allowed in interface type"},
238, LVAR,
"var declaration not allowed in for initializer",
{238, LVAR,
"var declaration not allowed in for initializer"},
65, '{',
"unexpected { at end of statement",
{65, '{',
"unexpected { at end of statement"},
377, '{',
"unexpected { at end of statement",
{377, '{',
"unexpected { at end of statement"},
126, ';',
"argument to go/defer must be function call",
{126, ';',
"argument to go/defer must be function call"},
426, ';',
"need trailing comma before newline in composite literal",
{426, ';',
"need trailing comma before newline in composite literal"},
437, ';',
"need trailing comma before newline in composite literal",
{437, ';',
"need trailing comma before newline in composite literal"},
113, LNAME,
"nested func not allowed",
{113, LNAME,
"nested func not allowed"},
645, ';',
"else must be followed by if or statement block"
{645, ';',
"else must be followed by if or statement block"}
};
......@@ -21,3 +21,16 @@
#define WRAPPER 32
// This function uses its incoming context register.
#define NEEDCTXT 64
/*c2go
enum
{
NOPROF = 1,
DUPOK = 2,
NOSPLIT = 4,
RODATA = 8,
NOPTR = 16,
WRAPPER = 32,
NEEDCTXT = 64,
};
*/
......@@ -43,7 +43,7 @@ typedef uchar Opcross[32][2][32];
struct Optab
{
char as;
uchar as;
uchar a1;
char a2;
uchar a3;
......@@ -2038,64 +2038,6 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
out[4] = o5;
out[5] = o6;
return;
#ifdef NOTDEF
v = p->pc;
switch(o->size) {
default:
if(debug['a'])
Bprint(&bso, " %.8ux:\t\t%P\n", v, p);
break;
case 4:
if(debug['a'])
Bprint(&bso, " %.8ux: %.8ux\t%P\n", v, o1, p);
lputl(o1);
break;
case 8:
if(debug['a'])
Bprint(&bso, " %.8ux: %.8ux %.8ux%P\n", v, o1, o2, p);
lputl(o1);
lputl(o2);
break;
case 12:
if(debug['a'])
Bprint(&bso, " %.8ux: %.8ux %.8ux %.8ux%P\n", v, o1, o2, o3, p);
lputl(o1);
lputl(o2);
lputl(o3);
break;
case 16:
if(debug['a'])
Bprint(&bso, " %.8ux: %.8ux %.8ux %.8ux %.8ux%P\n",
v, o1, o2, o3, o4, p);
lputl(o1);
lputl(o2);
lputl(o3);
lputl(o4);
break;
case 20:
if(debug['a'])
Bprint(&bso, " %.8ux: %.8ux %.8ux %.8ux %.8ux %.8ux%P\n",
v, o1, o2, o3, o4, o5, p);
lputl(o1);
lputl(o2);
lputl(o3);
lputl(o4);
lputl(o5);
break;
case 24:
if(debug['a'])
Bprint(&bso, " %.8ux: %.8ux %.8ux %.8ux %.8ux %.8ux %.8ux%P\n",
v, o1, o2, o3, o4, o5, o6, p);
lputl(o1);
lputl(o2);
lputl(o3);
lputl(o4);
lputl(o5);
lputl(o6);
break;
}
#endif
}
static int32
......
This diff is collapsed.
This diff is collapsed.
......@@ -161,7 +161,10 @@ uchar inuxi2[2];
uchar inuxi4[4];
uchar inuxi8[8];
#define LOG 5
enum
{
LOG = 5,
};
void
mkfwd(LSym *sym)
{
......
......@@ -958,7 +958,7 @@ xfol(Link *ctxt, Prog *p, Prog **last)
{
Prog *q;
int i;
enum as a;
int a;
loop:
if(p == nil)
......
......@@ -697,7 +697,7 @@ xfol(Link *ctxt, Prog *p, Prog **last)
{
Prog *q;
int i;
enum as a;
int a;
loop:
if(p == nil)
......
......@@ -44,20 +44,20 @@ static struct {
char *name;
int val;
} headers[] = {
"darwin", Hdarwin,
"dragonfly", Hdragonfly,
"elf", Helf,
"freebsd", Hfreebsd,
"linux", Hlinux,
"android", Hlinux,
"nacl", Hnacl,
"netbsd", Hnetbsd,
"openbsd", Hopenbsd,
"plan9", Hplan9,
"solaris", Hsolaris,
"windows", Hwindows,
"windowsgui", Hwindows,
0, 0
{"android", Hlinux},
{"darwin", Hdarwin},
{"dragonfly", Hdragonfly},
{"elf", Helf},
{"freebsd", Hfreebsd},
{"linux", Hlinux},
{"nacl", Hnacl},
{"netbsd", Hnetbsd},
{"openbsd", Hopenbsd},
{"plan9", Hplan9},
{"solaris", Hsolaris},
{"windows", Hwindows},
{"windowsgui", Hwindows},
{0, 0},
};
int
......
......@@ -22,3 +22,14 @@
// assembly code without an explicit specification).
// This value is generated by the compiler, assembler, or linker.
#define ArgsSizeUnknown 0x80000000
/*c2go
enum {
PCDATA_ArgSize = 0,
PCDATA_StackMapIndex = 1,
FUNCDATA_ArgsPointerMaps = 2,
FUNCDATA_LocalsPointerMaps = 3,
FUNCDATA_DeadValueMaps = 4,
ArgsSizeUnknown = 0x80000000,
};
*/
......@@ -111,3 +111,9 @@ enum {
// Must be greater than any real sp.
// 0xfffffade in hex.
#define StackPreempt ((uint64)-1314)
/*c2go
enum
{
StackPreempt = -1314,
};
*/
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