Commit 3e804631 authored by Russ Cox's avatar Russ Cox

[dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.cc

This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes.

These are the files that had merge conflicts and have been edited by hand:
        malloc.go
        mem_linux.go
        mgc.go
        os1_linux.go
        proc1.go
        panic1.go
        runtime1.go

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/174180043
parents 9ad6b7e3 743bdf61
...@@ -2,13 +2,13 @@ syntax:glob ...@@ -2,13 +2,13 @@ syntax:glob
.DS_Store .DS_Store
.git .git
.gitignore .gitignore
*.[568ao] *.[5689ao]
*.a[568o] *.a[5689o]
*.so *.so
*.pyc *.pyc
._* ._*
.nfs.* .nfs.*
[568a].out [5689a].out
*~ *~
*.orig *.orig
*.rej *.rej
......
...@@ -54,7 +54,7 @@ struct Addr ...@@ -54,7 +54,7 @@ struct Addr
{ {
char sval[8]; char sval[8];
float64 dval; float64 dval;
Prog* branch; // for 5g, 6g, 8g Prog* branch; // for 5g, 6g, 8g, 9g
} u; } u;
LSym* sym; LSym* sym;
...@@ -62,9 +62,9 @@ struct Addr ...@@ -62,9 +62,9 @@ struct Addr
short type; short type;
uint8 index; uint8 index;
int8 scale; int8 scale;
int8 reg; // for 5l int8 reg; // for 5l, 9l
int8 name; // for 5l int8 name; // for 5l, 9l
int8 class; // for 5l int8 class; // for 5l, 9l
uint8 etype; // for 5g, 6g, 8g uint8 etype; // for 5g, 6g, 8g
int32 offset2; // for 5l, 8l int32 offset2; // for 5l, 8l
struct Node* node; // for 5g, 6g, 8g struct Node* node; // for 5g, 6g, 8g
...@@ -89,9 +89,13 @@ struct Prog ...@@ -89,9 +89,13 @@ struct Prog
int32 lineno; int32 lineno;
Prog* link; Prog* link;
short as; short as;
uchar reg; // arm only uchar scond; // arm only; condition codes
uchar scond; // arm only
// operands
Addr from; Addr from;
uchar reg; // arm, power64 only (e.g., ADD from, reg, to);
// also used for ADATA width on arm, power64
Addr from3; // power64 only (e.g., RLWM/FMADD from, reg, from3, to)
Addr to; Addr to;
// for 5g, 6g, 8g internal use // for 5g, 6g, 8g internal use
...@@ -103,11 +107,11 @@ struct Prog ...@@ -103,11 +107,11 @@ struct Prog
Prog* comefrom; // 6l, 8l Prog* comefrom; // 6l, 8l
Prog* pcrel; // 5l Prog* pcrel; // 5l
int32 spadj; int32 spadj;
uchar mark; uint16 mark;
uint16 optab; // 5l, 9l
uchar back; // 6l, 8l uchar back; // 6l, 8l
uchar ft; /* 6l, 8l oclass cache */ uchar ft; /* 6l, 8l oclass cache */
uchar tt; // 6l, 8l uchar tt; // 6l, 8l
uint16 optab; // 5l
uchar isize; // 6l, 8l uchar isize; // 6l, 8l
char width; /* fake for DATA */ char width; /* fake for DATA */
...@@ -233,10 +237,12 @@ enum ...@@ -233,10 +237,12 @@ enum
enum enum
{ {
R_ADDR = 1, R_ADDR = 1,
R_ADDRPOWER, // relocation for loading 31-bit address using addis and addi/ld/st for Power
R_SIZE, R_SIZE,
R_CALL, // relocation for direct PC-relative call R_CALL, // relocation for direct PC-relative call
R_CALLARM, // relocation for ARM direct call R_CALLARM, // relocation for ARM direct call
R_CALLIND, // marker for indirect call (no actual relocating necessary) R_CALLIND, // marker for indirect call (no actual relocating necessary)
R_CALLPOWER, // relocation for Power direct call
R_CONST, R_CONST,
R_PCREL, R_PCREL,
R_TLS, R_TLS,
...@@ -529,6 +535,9 @@ void span6(Link *ctxt, LSym *s); ...@@ -529,6 +535,9 @@ void span6(Link *ctxt, LSym *s);
// asm8.c // asm8.c
void span8(Link *ctxt, LSym *s); void span8(Link *ctxt, LSym *s);
// asm9.c
void span9(Link *ctxt, LSym *s);
// data.c // data.c
vlong addaddr(Link *ctxt, LSym *s, LSym *t); vlong addaddr(Link *ctxt, LSym *s, LSym *t);
vlong addaddrplus(Link *ctxt, LSym *s, LSym *t, vlong add); vlong addaddrplus(Link *ctxt, LSym *s, LSym *t, vlong add);
...@@ -576,10 +585,11 @@ Prog* copyp(Link*, Prog*); ...@@ -576,10 +585,11 @@ Prog* copyp(Link*, Prog*);
Prog* appendp(Link*, Prog*); Prog* appendp(Link*, Prog*);
vlong atolwhex(char*); vlong atolwhex(char*);
// list[568].c // list[5689].c
void listinit5(void); void listinit5(void);
void listinit6(void); void listinit6(void);
void listinit8(void); void listinit8(void);
void listinit9(void);
// obj.c // obj.c
int linklinefmt(Link *ctxt, Fmt *fp); int linklinefmt(Link *ctxt, Fmt *fp);
...@@ -611,20 +621,24 @@ char* headstr(int); ...@@ -611,20 +621,24 @@ char* headstr(int);
extern char* anames5[]; extern char* anames5[];
extern char* anames6[]; extern char* anames6[];
extern char* anames8[]; extern char* anames8[];
extern char* anames9[];
extern char* cnames5[]; extern char* cnames5[];
extern char* cnames9[];
extern LinkArch link386; extern LinkArch link386;
extern LinkArch linkamd64; extern LinkArch linkamd64;
extern LinkArch linkamd64p32; extern LinkArch linkamd64p32;
extern LinkArch linkarm; extern LinkArch linkarm;
extern LinkArch linkpower64;
extern LinkArch linkpower64le;
#pragma varargck type "A" int #pragma varargck type "A" int
#pragma varargck type "D" Addr* #pragma varargck type "D" Addr*
#pragma varargck type "lD" Addr* #pragma varargck type "lD" Addr*
#pragma varargck type "P" Prog* #pragma varargck type "P" Prog*
#pragma varargck type "R" int #pragma varargck type "R" int
#pragma varargck type "^" int #pragma varargck type "^" int // for 5l/9l, C_* classes (liblink internal)
// TODO(ality): remove this workaround. // TODO(ality): remove this workaround.
// It's here because Pconv in liblink/list?.c references %L. // It's here because Pconv in liblink/list?.c references %L.
......
defaultcc: golang-codereviews@googlegroups.com defaultcc: golang-codereviews@googlegroups.com
contributors: http://go.googlecode.com/hg/CONTRIBUTORS
...@@ -3604,11 +3604,17 @@ class MercurialVCS(VersionControlSystem): ...@@ -3604,11 +3604,17 @@ class MercurialVCS(VersionControlSystem):
if use_hg_shell: if use_hg_shell:
base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], silent_ok=True) base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], silent_ok=True)
else: else:
base_content = str(self.repo[base_rev][oldrelpath].data()) try:
base_content = str(self.repo[base_rev][oldrelpath].data())
except Exception:
pass
is_binary = "\0" in base_content # Mercurial's heuristic is_binary = "\0" in base_content # Mercurial's heuristic
if status != "R": if status != "R":
new_content = open(relpath, "rb").read() try:
is_binary = is_binary or "\0" in new_content new_content = open(relpath, "rb").read()
is_binary = is_binary or "\0" in new_content
except Exception:
pass
if is_binary and base_content and use_hg_shell: if is_binary and base_content and use_hg_shell:
# Fetch again without converting newlines # Fetch again without converting newlines
base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath],
......
...@@ -67,6 +67,7 @@ struct Sym ...@@ -67,6 +67,7 @@ struct Sym
int32 value; int32 value;
ushort type; ushort type;
char *name; char *name;
char* labelname;
char sym; char sym;
}; };
#define S ((Sym*)0) #define S ((Sym*)0)
...@@ -136,6 +137,8 @@ void newio(void); ...@@ -136,6 +137,8 @@ void newio(void);
void newfile(char*, int); void newfile(char*, int);
Sym* slookup(char*); Sym* slookup(char*);
Sym* lookup(void); Sym* lookup(void);
Sym* labellookup(Sym*);
void settext(LSym*);
void syminit(Sym*); void syminit(Sym*);
int32 yylex(void); int32 yylex(void);
int getc(void); int getc(void);
......
...@@ -73,15 +73,11 @@ prog: ...@@ -73,15 +73,11 @@ prog:
line line
line: line:
LLAB ':' LNAME ':'
{
if($1->value != pc)
yyerror("redeclaration of %s", $1->name);
$1->value = pc;
}
line
| LNAME ':'
{ {
$1 = labellookup($1);
if($1->type == LLAB && $1->value != pc)
yyerror("redeclaration of %s", $1->labelname);
$1->type = LLAB; $1->type = LLAB;
$1->value = pc; $1->value = pc;
} }
...@@ -218,18 +214,21 @@ inst: ...@@ -218,18 +214,21 @@ inst:
*/ */
| LTYPEB name ',' imm | LTYPEB name ',' imm
{ {
settext($2.sym);
$4.type = D_CONST2; $4.type = D_CONST2;
$4.offset2 = ArgsSizeUnknown; $4.offset2 = ArgsSizeUnknown;
outcode($1, Always, &$2, 0, &$4); outcode($1, Always, &$2, 0, &$4);
} }
| LTYPEB name ',' con ',' imm | LTYPEB name ',' con ',' imm
{ {
settext($2.sym);
$6.type = D_CONST2; $6.type = D_CONST2;
$6.offset2 = ArgsSizeUnknown; $6.offset2 = ArgsSizeUnknown;
outcode($1, Always, &$2, $4, &$6); outcode($1, Always, &$2, $4, &$6);
} }
| LTYPEB name ',' con ',' imm '-' con | LTYPEB name ',' con ',' imm '-' con
{ {
settext($2.sym);
$6.type = D_CONST2; $6.type = D_CONST2;
$6.offset2 = $8; $6.offset2 = $8;
outcode($1, Always, &$2, $4, &$6); outcode($1, Always, &$2, $4, &$6);
...@@ -373,15 +372,10 @@ rel: ...@@ -373,15 +372,10 @@ rel:
} }
| LNAME offset | LNAME offset
{ {
$1 = labellookup($1);
$$ = nullgen; $$ = nullgen;
if(pass == 2) if(pass == 2 && $1->type != LLAB)
yyerror("undefined label: %s", $1->name); yyerror("undefined label: %s", $1->labelname);
$$.type = D_BRANCH;
$$.offset = $2;
}
| LLAB offset
{
$$ = nullgen;
$$.type = D_BRANCH; $$.type = D_BRANCH;
$$.offset = $1->value + $2; $$.offset = $1->value + $2;
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* A Bison parser, made by GNU Bison 2.3. */
/* Bison interface for Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation; either version 2, or (at your option)
(at your option) any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
...@@ -26,20 +29,10 @@ ...@@ -26,20 +29,10 @@
special exception, which will cause the skeleton and the resulting special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public Bison output files to be licensed under the GNU General Public
License without this special exception. License without this special exception.
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
...@@ -148,41 +141,24 @@ extern int yydebug; ...@@ -148,41 +141,24 @@ extern int yydebug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
{
/* Line 2053 of yacc.c */
#line 39 "a.y" #line 39 "a.y"
{
Sym *sym; Sym *sym;
int32 lval; int32 lval;
double dval; double dval;
char sval[8]; char sval[8];
Addr addr; Addr addr;
}
/* Line 1529 of yacc.c. */
/* Line 2053 of yacc.c */ #line 157 "y.tab.h"
#line 166 "y.tab.h" YYSTYPE;
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_Y_TAB_H_INCLUDED */
...@@ -86,7 +86,7 @@ datagostring(Strlit *sval, Addr *a) ...@@ -86,7 +86,7 @@ datagostring(Strlit *sval, Addr *a)
sym = stringsym(sval->s, sval->len); sym = stringsym(sval->s, sval->len);
a->type = D_OREG; a->type = D_OREG;
a->name = D_EXTERN; a->name = D_EXTERN;
a->etype = TINT32; a->etype = TSTRING;
a->offset = 0; // header a->offset = 0; // header
a->reg = NREG; a->reg = NREG;
a->sym = linksym(sym); a->sym = linksym(sym);
......
...@@ -1353,9 +1353,10 @@ naddr(Node *n, Addr *a, int canemitcode) ...@@ -1353,9 +1353,10 @@ naddr(Node *n, Addr *a, int canemitcode)
case OITAB: case OITAB:
// itable of interface value // itable of interface value
naddr(n->left, a, canemitcode); naddr(n->left, a, canemitcode);
a->etype = TINT32; a->etype = simtype[tptr];
if(a->type == D_CONST && a->offset == 0) if(a->type == D_CONST && a->offset == 0)
break; // len(nil) break; // len(nil)
a->width = widthptr;
break; break;
case OSPTR: case OSPTR:
......
...@@ -63,8 +63,8 @@ enum ...@@ -63,8 +63,8 @@ enum
uint32 BLOAD(Reg*); uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*); uint32 BSTORE(Reg*);
uint32 LOAD(Reg*); uint64 LOAD(Reg*);
uint32 STORE(Reg*); uint64 STORE(Reg*);
*/ */
// A Reg is a wrapper around a single Prog (one instruction) that holds // A Reg is a wrapper around a single Prog (one instruction) that holds
...@@ -145,7 +145,7 @@ void synch(Reg*, Bits); ...@@ -145,7 +145,7 @@ void synch(Reg*, Bits);
uint32 allreg(uint32, Rgn*); uint32 allreg(uint32, Rgn*);
void paint1(Reg*, int); void paint1(Reg*, int);
uint32 paint2(Reg*, int); uint32 paint2(Reg*, int);
void paint3(Reg*, int, int32, int); void paint3(Reg*, int, uint32, int);
void addreg(Adr*, int); void addreg(Adr*, int);
void dumpit(char *str, Flow *r0, int); void dumpit(char *str, Flow *r0, int);
...@@ -156,10 +156,10 @@ void peep(Prog*); ...@@ -156,10 +156,10 @@ void peep(Prog*);
void excise(Flow*); void excise(Flow*);
int copyu(Prog*, Adr*, Adr*); int copyu(Prog*, Adr*, Adr*);
int32 RtoB(int); uint32 RtoB(int);
int32 FtoB(int); uint32 FtoB(int);
int BtoR(int32); int BtoR(uint32);
int BtoF(int32); int BtoF(uint32);
/* /*
* prog.c * prog.c
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "opt.h" #include "opt.h"
#define NREGVAR 32 #define NREGVAR 32
#define REGBITS ((uint32)0xffffffff) #define REGBITS ((uint64)0xffffffffull)
/*c2go enum { /*c2go enum {
NREGVAR = 32, NREGVAR = 32,
REGBITS = 0xffffffff, REGBITS = 0xffffffff,
...@@ -86,7 +86,7 @@ setaddrs(Bits bit) ...@@ -86,7 +86,7 @@ setaddrs(Bits bit)
i = bnum(bit); i = bnum(bit);
node = var[i].node; node = var[i].node;
n = var[i].name; n = var[i].name;
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
// disable all pieces of that variable // disable all pieces of that variable
for(i=0; i<nvar; i++) { for(i=0; i<nvar; i++) {
...@@ -393,7 +393,7 @@ loop2: ...@@ -393,7 +393,7 @@ loop2:
for(z=0; z<BITS; z++) for(z=0; z<BITS; z++)
bit.b[z] = (r->refahead.b[z] | r->calahead.b[z]) & bit.b[z] = (r->refahead.b[z] | r->calahead.b[z]) &
~(externs.b[z] | params.b[z] | addrs.b[z] | consts.b[z]); ~(externs.b[z] | params.b[z] | addrs.b[z] | consts.b[z]);
if(bany(&bit) & !r->f.refset) { if(bany(&bit) && !r->f.refset) {
// should never happen - all variables are preset // should never happen - all variables are preset
if(debug['w']) if(debug['w'])
print("%L: used and not set: %Q\n", r->f.prog->lineno, bit); print("%L: used and not set: %Q\n", r->f.prog->lineno, bit);
...@@ -425,7 +425,7 @@ loop2: ...@@ -425,7 +425,7 @@ loop2:
if(debug['R'] > 1) if(debug['R'] > 1)
print("\n"); print("\n");
paint1(r, i); paint1(r, i);
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
if(change <= 0) { if(change <= 0) {
if(debug['R']) if(debug['R'])
print("%L $%d: %Q\n", print("%L $%d: %Q\n",
...@@ -570,7 +570,7 @@ walkvardef(Node *n, Reg *r, int active) ...@@ -570,7 +570,7 @@ walkvardef(Node *n, Reg *r, int active)
break; break;
for(v=n->opt; v!=nil; v=v->nextinnode) { for(v=n->opt; v!=nil; v=v->nextinnode) {
bn = v - var; bn = v - var;
r1->act.b[bn/32] |= 1L << (bn%32); biset(&r1->act, bn);
} }
if(r1->f.prog->as == ABL) if(r1->f.prog->as == ABL)
break; break;
...@@ -606,7 +606,7 @@ addsplits(void) ...@@ -606,7 +606,7 @@ addsplits(void)
~(r->calahead.b[z] & addrs.b[z]); ~(r->calahead.b[z] & addrs.b[z]);
while(bany(&bit)) { while(bany(&bit)) {
i = bnum(bit); i = bnum(bit);
bit.b[i/32] &= ~(1L << (i%32)); biclr(&bit, i);
} }
} }
} }
...@@ -972,10 +972,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -972,10 +972,10 @@ prop(Reg *r, Bits ref, Bits cal)
for(z=0; z<BITS; z++) { for(z=0; z<BITS; z++) {
if(cal.b[z] == 0) if(cal.b[z] == 0)
continue; continue;
for(i=0; i<32; i++) { for(i=0; i<64; i++) {
if(z*32+i >= nvar || ((cal.b[z]>>i)&1) == 0) if(z*64+i >= nvar || ((cal.b[z]>>i)&1) == 0)
continue; continue;
v = var+z*32+i; v = var+z*64+i;
if(v->node->opt == nil) // v represents fixed register, not Go variable if(v->node->opt == nil) // v represents fixed register, not Go variable
continue; continue;
...@@ -991,10 +991,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -991,10 +991,10 @@ prop(Reg *r, Bits ref, Bits cal)
// This will set the bits at most twice, keeping the overall loop linear. // This will set the bits at most twice, keeping the overall loop linear.
v1 = v->node->opt; v1 = v->node->opt;
j = v1 - var; j = v1 - var;
if(v == v1 || ((cal.b[j/32]>>(j&31))&1) == 0) { if(v == v1 || !btest(&cal, j)) {
for(; v1 != nil; v1 = v1->nextinnode) { for(; v1 != nil; v1 = v1->nextinnode) {
j = v1 - var; j = v1 - var;
cal.b[j/32] |= 1<<(j&31); biset(&cal, j);
} }
} }
} }
...@@ -1115,10 +1115,10 @@ paint1(Reg *r, int bn) ...@@ -1115,10 +1115,10 @@ paint1(Reg *r, int bn)
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L<<(bn%32); bb = 1LL<<(bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1193,10 +1193,10 @@ paint2(Reg *r, int bn) ...@@ -1193,10 +1193,10 @@ paint2(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb, vreg; uint64 bb, vreg;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
vreg = regbits; vreg = regbits;
if(!(r->act.b[z] & bb)) if(!(r->act.b[z] & bb))
return vreg; return vreg;
...@@ -1240,15 +1240,15 @@ paint2(Reg *r, int bn) ...@@ -1240,15 +1240,15 @@ paint2(Reg *r, int bn)
} }
void void
paint3(Reg *r, int bn, int32 rb, int rn) paint3(Reg *r, int bn, uint32 rb, int rn)
{ {
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1333,7 +1333,7 @@ addreg(Adr *a, int rn) ...@@ -1333,7 +1333,7 @@ addreg(Adr *a, int rn)
* 10 R10 * 10 R10
* 12 R12 * 12 R12
*/ */
int32 uint32
RtoB(int r) RtoB(int r)
{ {
if(r >= REGTMP-2 && r != 12) // excluded R9 and R10 for m and g, but not R12 if(r >= REGTMP-2 && r != 12) // excluded R9 and R10 for m and g, but not R12
...@@ -1342,7 +1342,7 @@ RtoB(int r) ...@@ -1342,7 +1342,7 @@ RtoB(int r)
} }
int int
BtoR(int32 b) BtoR(uint32 b)
{ {
b &= 0x11fcL; // excluded R9 and R10 for m and g, but not R12 b &= 0x11fcL; // excluded R9 and R10 for m and g, but not R12
if(b == 0) if(b == 0)
...@@ -1357,7 +1357,7 @@ BtoR(int32 b) ...@@ -1357,7 +1357,7 @@ BtoR(int32 b)
* ... ... * ... ...
* 31 F15 * 31 F15
*/ */
int32 uint32
FtoB(int f) FtoB(int f)
{ {
...@@ -1367,7 +1367,7 @@ FtoB(int f) ...@@ -1367,7 +1367,7 @@ FtoB(int f)
} }
int int
BtoF(int32 b) BtoF(uint32 b)
{ {
b &= 0xfffc0000L; b &= 0xfffc0000L;
......
...@@ -70,6 +70,7 @@ struct Sym ...@@ -70,6 +70,7 @@ struct Sym
vlong value; vlong value;
ushort type; ushort type;
char *name; char *name;
char* labelname;
char sym; char sym;
}; };
#define S ((Sym*)0) #define S ((Sym*)0)
...@@ -148,6 +149,8 @@ void newio(void); ...@@ -148,6 +149,8 @@ void newio(void);
void newfile(char*, int); void newfile(char*, int);
Sym* slookup(char*); Sym* slookup(char*);
Sym* lookup(void); Sym* lookup(void);
Sym* labellookup(Sym*);
void settext(LSym*);
void syminit(Sym*); void syminit(Sym*);
int32 yylex(void); int32 yylex(void);
int getc(void); int getc(void);
......
...@@ -71,15 +71,11 @@ prog: ...@@ -71,15 +71,11 @@ prog:
line line
line: line:
LLAB ':' LNAME ':'
{
if($1->value != pc)
yyerror("redeclaration of %s", $1->name);
$1->value = pc;
}
line
| LNAME ':'
{ {
$1 = labellookup($1);
if($1->type == LLAB && $1->value != pc)
yyerror("redeclaration of %s (%s)", $1->labelname, $1->name);
$1->type = LLAB; $1->type = LLAB;
$1->value = pc; $1->value = pc;
} }
...@@ -197,11 +193,13 @@ spec1: /* DATA */ ...@@ -197,11 +193,13 @@ spec1: /* DATA */
spec2: /* TEXT */ spec2: /* TEXT */
mem ',' imm2 mem ',' imm2
{ {
settext($1.sym);
$$.from = $1; $$.from = $1;
$$.to = $3; $$.to = $3;
} }
| mem ',' con ',' imm2 | mem ',' con ',' imm2
{ {
settext($1.sym);
$$.from = $1; $$.from = $1;
$$.from.scale = $3; $$.from.scale = $3;
$$.to = $5; $$.to = $5;
...@@ -363,15 +361,10 @@ rel: ...@@ -363,15 +361,10 @@ rel:
} }
| LNAME offset | LNAME offset
{ {
$1 = labellookup($1);
$$ = nullgen; $$ = nullgen;
if(pass == 2) if(pass == 2 && $1->type != LLAB)
yyerror("undefined label: %s", $1->name); yyerror("undefined label: %s", $1->labelname);
$$.type = D_BRANCH;
$$.offset = $2;
}
| LLAB offset
{
$$ = nullgen;
$$.type = D_BRANCH; $$.type = D_BRANCH;
$$.offset = $1->value + $2; $$.offset = $1->value + $2;
} }
......
This diff is collapsed.
...@@ -81,7 +81,7 @@ datagostring(Strlit *sval, Addr *a) ...@@ -81,7 +81,7 @@ datagostring(Strlit *sval, Addr *a)
a->sym = linksym(sym); a->sym = linksym(sym);
a->node = sym->def; a->node = sym->def;
a->offset = 0; // header a->offset = 0; // header
a->etype = TINT32; a->etype = TSTRING;
} }
void void
......
...@@ -63,8 +63,8 @@ enum ...@@ -63,8 +63,8 @@ enum
uint32 BLOAD(Reg*); uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*); uint32 BSTORE(Reg*);
uint32 LOAD(Reg*); uint64 LOAD(Reg*);
uint32 STORE(Reg*); uint64 STORE(Reg*);
*/ */
// A Reg is a wrapper around a single Prog (one instruction) that holds // A Reg is a wrapper around a single Prog (one instruction) that holds
...@@ -141,7 +141,7 @@ void synch(Reg*, Bits); ...@@ -141,7 +141,7 @@ void synch(Reg*, Bits);
uint32 allreg(uint32, Rgn*); uint32 allreg(uint32, Rgn*);
void paint1(Reg*, int); void paint1(Reg*, int);
uint32 paint2(Reg*, int); uint32 paint2(Reg*, int);
void paint3(Reg*, int, int32, int); void paint3(Reg*, int, uint32, int);
void addreg(Adr*, int); void addreg(Adr*, int);
void dumpone(Flow*, int); void dumpone(Flow*, int);
void dumpit(char*, Flow*, int); void dumpit(char*, Flow*, int);
...@@ -153,10 +153,10 @@ void peep(Prog*); ...@@ -153,10 +153,10 @@ void peep(Prog*);
void excise(Flow*); void excise(Flow*);
int copyu(Prog*, Adr*, Adr*); int copyu(Prog*, Adr*, Adr*);
int32 RtoB(int); uint32 RtoB(int);
int32 FtoB(int); uint32 FtoB(int);
int BtoR(int32); int BtoR(uint32);
int BtoF(int32); int BtoF(uint32);
/* /*
* prog.c * prog.c
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "opt.h" #include "opt.h"
#define NREGVAR 32 /* 16 general + 16 floating */ #define NREGVAR 32 /* 16 general + 16 floating */
#define REGBITS ((uint32)0xffffffff) #define REGBITS ((uint64)0xffffffffull)
/*c2go enum { /*c2go enum {
NREGVAR = 32, NREGVAR = 32,
REGBITS = 0xffffffff, REGBITS = 0xffffffff,
...@@ -71,7 +71,7 @@ setaddrs(Bits bit) ...@@ -71,7 +71,7 @@ setaddrs(Bits bit)
i = bnum(bit); i = bnum(bit);
node = var[i].node; node = var[i].node;
n = var[i].name; n = var[i].name;
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
// disable all pieces of that variable // disable all pieces of that variable
for(i=0; i<nvar; i++) { for(i=0; i<nvar; i++) {
...@@ -364,7 +364,7 @@ loop2: ...@@ -364,7 +364,7 @@ loop2:
rgp->varno = i; rgp->varno = i;
change = 0; change = 0;
paint1(r, i); paint1(r, i);
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
if(change <= 0) if(change <= 0)
continue; continue;
rgp->cost = change; rgp->cost = change;
...@@ -477,7 +477,7 @@ walkvardef(Node *n, Reg *r, int active) ...@@ -477,7 +477,7 @@ walkvardef(Node *n, Reg *r, int active)
break; break;
for(v=n->opt; v!=nil; v=v->nextinnode) { for(v=n->opt; v!=nil; v=v->nextinnode) {
bn = v - var; bn = v - var;
r1->act.b[bn/32] |= 1L << (bn%32); biset(&r1->act, bn);
} }
if(r1->f.prog->as == ACALL) if(r1->f.prog->as == ACALL)
break; break;
...@@ -621,6 +621,9 @@ mkvar(Reg *r, Adr *a) ...@@ -621,6 +621,9 @@ mkvar(Reg *r, Adr *a)
if(r != R) if(r != R)
r->use1.b[0] |= doregbits(a->index); r->use1.b[0] |= doregbits(a->index);
if(t >= D_INDIR && t < 2*D_INDIR)
goto none;
switch(t) { switch(t) {
default: default:
regu = doregbits(t); regu = doregbits(t);
...@@ -822,10 +825,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -822,10 +825,10 @@ prop(Reg *r, Bits ref, Bits cal)
for(z=0; z<BITS; z++) { for(z=0; z<BITS; z++) {
if(cal.b[z] == 0) if(cal.b[z] == 0)
continue; continue;
for(i=0; i<32; i++) { for(i=0; i<64; i++) {
if(z*32+i >= nvar || ((cal.b[z]>>i)&1) == 0) if(z*64+i >= nvar || ((cal.b[z]>>i)&1) == 0)
continue; continue;
v = var+z*32+i; v = var+z*64+i;
if(v->node->opt == nil) // v represents fixed register, not Go variable if(v->node->opt == nil) // v represents fixed register, not Go variable
continue; continue;
...@@ -841,10 +844,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -841,10 +844,10 @@ prop(Reg *r, Bits ref, Bits cal)
// This will set the bits at most twice, keeping the overall loop linear. // This will set the bits at most twice, keeping the overall loop linear.
v1 = v->node->opt; v1 = v->node->opt;
j = v1 - var; j = v1 - var;
if(v == v1 || ((cal.b[j/32]>>(j&31))&1) == 0) { if(v == v1 || !btest(&cal, j)) {
for(; v1 != nil; v1 = v1->nextinnode) { for(; v1 != nil; v1 = v1->nextinnode) {
j = v1 - var; j = v1 - var;
cal.b[j/32] |= 1UL<<(j&31); biset(&cal, j);
} }
} }
} }
...@@ -959,10 +962,10 @@ paint1(Reg *r, int bn) ...@@ -959,10 +962,10 @@ paint1(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L<<(bn%32); bb = 1LL<<(bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1016,55 +1019,15 @@ paint1(Reg *r, int bn) ...@@ -1016,55 +1019,15 @@ paint1(Reg *r, int bn)
} }
} }
uint32
regset(Reg *r, uint32 bb)
{
uint32 b, set;
Adr v;
int c;
set = 0;
v = zprog.from;
while(b = bb & ~(bb-1)) {
v.type = b & 0xFFFF? BtoR(b): BtoF(b);
if(v.type == 0)
fatal("zero v.type for %#ux", b);
c = copyu(r->f.prog, &v, nil);
if(c == 3)
set |= b;
bb &= ~b;
}
return set;
}
uint32
reguse(Reg *r, uint32 bb)
{
uint32 b, set;
Adr v;
int c;
set = 0;
v = zprog.from;
while(b = bb & ~(bb-1)) {
v.type = b & 0xFFFF? BtoR(b): BtoF(b);
c = copyu(r->f.prog, &v, nil);
if(c == 1 || c == 2 || c == 4)
set |= b;
bb &= ~b;
}
return set;
}
uint32 uint32
paint2(Reg *r, int bn) paint2(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb, vreg, x; uint64 bb, vreg;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
vreg = regbits; vreg = regbits;
if(!(r->act.b[z] & bb)) if(!(r->act.b[z] & bb))
return vreg; return vreg;
...@@ -1105,27 +1068,19 @@ paint2(Reg *r, int bn) ...@@ -1105,27 +1068,19 @@ paint2(Reg *r, int bn)
break; break;
} }
bb = vreg;
for(; r; r=(Reg*)r->f.s1) {
x = r->regu & ~bb;
if(x) {
vreg |= reguse(r, x);
bb |= regset(r, x);
}
}
return vreg; return vreg;
} }
void void
paint3(Reg *r, int bn, int32 rb, int rn) paint3(Reg *r, int bn, uint32 rb, int rn)
{ {
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1198,7 +1153,7 @@ addreg(Adr *a, int rn) ...@@ -1198,7 +1153,7 @@ addreg(Adr *a, int rn)
ostats.ncvtreg++; ostats.ncvtreg++;
} }
int32 uint32
RtoB(int r) RtoB(int r)
{ {
...@@ -1208,7 +1163,7 @@ RtoB(int r) ...@@ -1208,7 +1163,7 @@ RtoB(int r)
} }
int int
BtoR(int32 b) BtoR(uint32 b)
{ {
b &= 0xffffL; b &= 0xffffL;
if(nacl) if(nacl)
...@@ -1224,7 +1179,7 @@ BtoR(int32 b) ...@@ -1224,7 +1179,7 @@ BtoR(int32 b)
* ... * ...
* 31 X15 * 31 X15
*/ */
int32 uint32
FtoB(int f) FtoB(int f)
{ {
if(f < D_X0 || f > D_X15) if(f < D_X0 || f > D_X15)
...@@ -1233,7 +1188,7 @@ FtoB(int f) ...@@ -1233,7 +1188,7 @@ FtoB(int f)
} }
int int
BtoF(int32 b) BtoF(uint32 b)
{ {
b &= 0xFFFF0000L; b &= 0xFFFF0000L;
......
...@@ -70,6 +70,7 @@ struct Sym ...@@ -70,6 +70,7 @@ struct Sym
int32 value; int32 value;
ushort type; ushort type;
char *name; char *name;
char* labelname;
char sym; char sym;
}; };
#define S ((Sym*)0) #define S ((Sym*)0)
...@@ -148,6 +149,8 @@ void newio(void); ...@@ -148,6 +149,8 @@ void newio(void);
void newfile(char*, int); void newfile(char*, int);
Sym* slookup(char*); Sym* slookup(char*);
Sym* lookup(void); Sym* lookup(void);
Sym* labellookup(Sym*);
void settext(LSym*);
void syminit(Sym*); void syminit(Sym*);
int32 yylex(void); int32 yylex(void);
int getc(void); int getc(void);
......
...@@ -74,15 +74,11 @@ prog: ...@@ -74,15 +74,11 @@ prog:
line line
line: line:
LLAB ':' LNAME ':'
{
if($1->value != pc)
yyerror("redeclaration of %s", $1->name);
$1->value = pc;
}
line
| LNAME ':'
{ {
$1 = labellookup($1);
if($1->type == LLAB && $1->value != pc)
yyerror("redeclaration of %s", $1->labelname);
$1->type = LLAB; $1->type = LLAB;
$1->value = pc; $1->value = pc;
} }
...@@ -199,11 +195,13 @@ spec1: /* DATA */ ...@@ -199,11 +195,13 @@ spec1: /* DATA */
spec2: /* TEXT */ spec2: /* TEXT */
mem ',' imm2 mem ',' imm2
{ {
settext($1.sym);
$$.from = $1; $$.from = $1;
$$.to = $3; $$.to = $3;
} }
| mem ',' con ',' imm2 | mem ',' con ',' imm2
{ {
settext($1.sym);
$$.from = $1; $$.from = $1;
$$.from.scale = $3; $$.from.scale = $3;
$$.to = $5; $$.to = $5;
...@@ -362,15 +360,10 @@ rel: ...@@ -362,15 +360,10 @@ rel:
} }
| LNAME offset | LNAME offset
{ {
$1 = labellookup($1);
$$ = nullgen; $$ = nullgen;
if(pass == 2) if(pass == 2 && $1->type != LLAB)
yyerror("undefined label: %s", $1->name); yyerror("undefined label: %s", $1->labelname);
$$.type = D_BRANCH;
$$.offset = $2;
}
| LLAB offset
{
$$ = nullgen;
$$.type = D_BRANCH; $$.type = D_BRANCH;
$$.offset = $1->value + $2; $$.offset = $1->value + $2;
} }
......
This diff is collapsed.
...@@ -81,7 +81,7 @@ datagostring(Strlit *sval, Addr *a) ...@@ -81,7 +81,7 @@ datagostring(Strlit *sval, Addr *a)
a->sym = linksym(sym); a->sym = linksym(sym);
a->node = sym->def; a->node = sym->def;
a->offset = 0; // header a->offset = 0; // header
a->etype = TINT32; a->etype = TSTRING;
} }
void void
......
...@@ -63,8 +63,8 @@ enum ...@@ -63,8 +63,8 @@ enum
uint32 BLOAD(Reg*); uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*); uint32 BSTORE(Reg*);
uint32 LOAD(Reg*); uint64 LOAD(Reg*);
uint32 STORE(Reg*); uint64 STORE(Reg*);
*/ */
// A Reg is a wrapper around a single Prog (one instruction) that holds // A Reg is a wrapper around a single Prog (one instruction) that holds
...@@ -159,7 +159,7 @@ void synch(Reg*, Bits); ...@@ -159,7 +159,7 @@ void synch(Reg*, Bits);
uint32 allreg(uint32, Rgn*); uint32 allreg(uint32, Rgn*);
void paint1(Reg*, int); void paint1(Reg*, int);
uint32 paint2(Reg*, int); uint32 paint2(Reg*, int);
void paint3(Reg*, int, int32, int); void paint3(Reg*, int, uint32, int);
void addreg(Adr*, int); void addreg(Adr*, int);
void dumpone(Flow*, int); void dumpone(Flow*, int);
void dumpit(char*, Flow*, int); void dumpit(char*, Flow*, int);
...@@ -171,10 +171,10 @@ void peep(Prog*); ...@@ -171,10 +171,10 @@ void peep(Prog*);
void excise(Flow*); void excise(Flow*);
int copyu(Prog*, Adr*, Adr*); int copyu(Prog*, Adr*, Adr*);
int32 RtoB(int); uint32 RtoB(int);
int32 FtoB(int); uint32 FtoB(int);
int BtoR(int32); int BtoR(uint32);
int BtoF(int32); int BtoF(uint32);
/* /*
* prog.c * prog.c
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "opt.h" #include "opt.h"
#define NREGVAR 16 /* 8 integer + 8 floating */ #define NREGVAR 16 /* 8 integer + 8 floating */
#define REGBITS ((uint32)0xffff) #define REGBITS ((uint64)0xffffull)
/*c2go enum { /*c2go enum {
NREGVAR = 16, NREGVAR = 16,
REGBITS = (1<<NREGVAR) - 1, REGBITS = (1<<NREGVAR) - 1,
...@@ -71,7 +71,7 @@ setaddrs(Bits bit) ...@@ -71,7 +71,7 @@ setaddrs(Bits bit)
i = bnum(bit); i = bnum(bit);
node = var[i].node; node = var[i].node;
n = var[i].name; n = var[i].name;
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
// disable all pieces of that variable // disable all pieces of that variable
for(i=0; i<nvar; i++) { for(i=0; i<nvar; i++) {
...@@ -336,7 +336,7 @@ loop2: ...@@ -336,7 +336,7 @@ loop2:
rgp->varno = i; rgp->varno = i;
change = 0; change = 0;
paint1(r, i); paint1(r, i);
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
if(change <= 0) if(change <= 0)
continue; continue;
rgp->cost = change; rgp->cost = change;
...@@ -446,7 +446,7 @@ walkvardef(Node *n, Reg *r, int active) ...@@ -446,7 +446,7 @@ walkvardef(Node *n, Reg *r, int active)
break; break;
for(v=n->opt; v!=nil; v=v->nextinnode) { for(v=n->opt; v!=nil; v=v->nextinnode) {
bn = v - var; bn = v - var;
r1->act.b[bn/32] |= 1L << (bn%32); biset(&r1->act, bn);
} }
if(r1->f.prog->as == ACALL) if(r1->f.prog->as == ACALL)
break; break;
...@@ -788,10 +788,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -788,10 +788,10 @@ prop(Reg *r, Bits ref, Bits cal)
for(z=0; z<BITS; z++) { for(z=0; z<BITS; z++) {
if(cal.b[z] == 0) if(cal.b[z] == 0)
continue; continue;
for(i=0; i<32; i++) { for(i=0; i<64; i++) {
if(z*32+i >= nvar || ((cal.b[z]>>i)&1) == 0) if(z*64+i >= nvar || ((cal.b[z]>>i)&1) == 0)
continue; continue;
v = var+z*32+i; v = var+z*64+i;
if(v->node->opt == nil) // v represents fixed register, not Go variable if(v->node->opt == nil) // v represents fixed register, not Go variable
continue; continue;
...@@ -807,10 +807,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -807,10 +807,10 @@ prop(Reg *r, Bits ref, Bits cal)
// This will set the bits at most twice, keeping the overall loop linear. // This will set the bits at most twice, keeping the overall loop linear.
v1 = v->node->opt; v1 = v->node->opt;
j = v1 - var; j = v1 - var;
if(v == v1 || ((cal.b[j/32]>>(j&31))&1) == 0) { if(v == v1 || !btest(&cal, j)) {
for(; v1 != nil; v1 = v1->nextinnode) { for(; v1 != nil; v1 = v1->nextinnode) {
j = v1 - var; j = v1 - var;
cal.b[j/32] |= 1<<(j&31); biset(&cal, j);
} }
} }
} }
...@@ -926,10 +926,10 @@ paint1(Reg *r, int bn) ...@@ -926,10 +926,10 @@ paint1(Reg *r, int bn)
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L<<(bn%32); bb = 1LL<<(bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -995,53 +995,15 @@ paint1(Reg *r, int bn) ...@@ -995,53 +995,15 @@ paint1(Reg *r, int bn)
} }
} }
uint32
regset(Reg *r, uint32 bb)
{
uint32 b, set;
Adr v;
int c;
set = 0;
v = zprog.from;
while(b = bb & ~(bb-1)) {
v.type = b & 0xFF ? BtoR(b): BtoF(b);
c = copyu(r->f.prog, &v, nil);
if(c == 3)
set |= b;
bb &= ~b;
}
return set;
}
uint32
reguse(Reg *r, uint32 bb)
{
uint32 b, set;
Adr v;
int c;
set = 0;
v = zprog.from;
while(b = bb & ~(bb-1)) {
v.type = b & 0xFF ? BtoR(b): BtoF(b);
c = copyu(r->f.prog, &v, nil);
if(c == 1 || c == 2 || c == 4)
set |= b;
bb &= ~b;
}
return set;
}
uint32 uint32
paint2(Reg *r, int bn) paint2(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb, vreg, x; uint64 bb, vreg;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
vreg = regbits; vreg = regbits;
if(!(r->act.b[z] & bb)) if(!(r->act.b[z] & bb))
return vreg; return vreg;
...@@ -1082,27 +1044,19 @@ paint2(Reg *r, int bn) ...@@ -1082,27 +1044,19 @@ paint2(Reg *r, int bn)
break; break;
} }
bb = vreg;
for(; r; r=(Reg*)r->f.s1) {
x = r->regu & ~bb;
if(x) {
vreg |= reguse(r, x);
bb |= regset(r, x);
}
}
return vreg; return vreg;
} }
void void
paint3(Reg *r, int bn, int32 rb, int rn) paint3(Reg *r, int bn, uint32 rb, int rn)
{ {
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1175,7 +1129,7 @@ addreg(Adr *a, int rn) ...@@ -1175,7 +1129,7 @@ addreg(Adr *a, int rn)
ostats.ncvtreg++; ostats.ncvtreg++;
} }
int32 uint32
RtoB(int r) RtoB(int r)
{ {
...@@ -1185,7 +1139,7 @@ RtoB(int r) ...@@ -1185,7 +1139,7 @@ RtoB(int r)
} }
int int
BtoR(int32 b) BtoR(uint32 b)
{ {
b &= 0xffL; b &= 0xffL;
...@@ -1194,7 +1148,7 @@ BtoR(int32 b) ...@@ -1194,7 +1148,7 @@ BtoR(int32 b)
return bitno(b) + D_AX; return bitno(b) + D_AX;
} }
int32 uint32
FtoB(int f) FtoB(int f)
{ {
if(f < D_X0 || f > D_X7) if(f < D_X0 || f > D_X7)
...@@ -1203,7 +1157,7 @@ FtoB(int f) ...@@ -1203,7 +1157,7 @@ FtoB(int f)
} }
int int
BtoF(int32 b) BtoF(uint32 b)
{ {
b &= 0xFF00L; b &= 0xFF00L;
if(b == 0) if(b == 0)
......
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
include ../../Make.dist
install: y.tab.h
y.tab.h: a.y
LANG=C LANGUAGE=en_US.UTF8 bison -d -v -y a.y
// cmd/9a/a.h from Vita Nuova.
//
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
// Portions Copyright © 1997-1999 Vita Nuova Limited
// Portions Copyright © 2000-2008 Vita Nuova Holdings Limited (www.vitanuova.com)
// Portions Copyright © 2004,2006 Bruce Ellis
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
// Revisions Copyright © 2000-2008 Lucent Technologies Inc. and others
// Portions Copyright © 2009 The Go Authors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <bio.h>
#include <link.h>
#include "../9l/9.out.h"
#ifndef EXTERN
#define EXTERN extern
#endif
#undef getc
#undef ungetc
#undef BUFSIZ
#define getc ccgetc
#define ungetc ccungetc
typedef struct Sym Sym;
typedef struct Io Io;
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
#ifndef EOF
#define EOF (-1)
#endif
#define IGN (-2)
#define GETC() ((--fi.c < 0)? filbuf(): *fi.p++ & 0xff)
#define NHASH 503
#define STRINGSZ 200
#define NMACRO 10
struct Sym
{
Sym* link;
char* macro;
vlong value;
ushort type;
char *name;
char* labelname;
char sym;
};
#define S ((Sym*)0)
EXTERN struct
{
char* p;
int c;
} fi;
struct Io
{
Io* link;
char b[BUFSIZ];
char* p;
short c;
short f;
};
#define I ((Io*)0)
enum
{
CLAST,
CMACARG,
CMACRO,
CPREPROC,
};
EXTERN int debug[256];
EXTERN Sym* hash[NHASH];
EXTERN char** Dlist;
EXTERN int nDlist;
EXTERN int newflag;
EXTERN char* hunk;
EXTERN char** include;
EXTERN Io* iofree;
EXTERN Io* ionext;
EXTERN Io* iostack;
EXTERN int32 lineno;
EXTERN int nerrors;
EXTERN int32 nhunk;
EXTERN int nosched;
EXTERN int ninclude;
EXTERN int32 nsymb;
EXTERN Addr nullgen;
EXTERN char* outfile;
EXTERN int pass;
EXTERN int32 pc;
EXTERN int peekc;
EXTERN int sym;
EXTERN char* symb;
EXTERN int thechar;
EXTERN char* thestring;
EXTERN int32 thunk;
EXTERN Biobuf obuf;
EXTERN Link* ctxt;
EXTERN Biobuf bstdout;
void* alloc(int32);
void* allocn(void*, int32, int32);
void ensuresymb(int32);
void errorexit(void);
void pushio(void);
void newio(void);
void newfile(char*, int);
Sym* slookup(char*);
Sym* lookup(void);
Sym* labellookup(Sym*);
void settext(LSym*);
void syminit(Sym*);
int32 yylex(void);
int getc(void);
int getnsc(void);
void unget(int);
int escchar(int);
void cinit(void);
void pinit(char*);
void cclean(void);
void outcode(int, Addr*, int, Addr*);
void outgcode(int, Addr*, int, Addr*, Addr*);
int filbuf(void);
Sym* getsym(void);
void domacro(void);
void macund(void);
void macdef(void);
void macexpand(Sym*, char*);
void macinc(void);
void macprag(void);
void maclin(void);
void macif(int);
void macend(void);
void dodefine(char*);
void prfile(int32);
void linehist(char*, int);
void gethunk(void);
void yyerror(char*, ...);
int yyparse(void);
void setinclude(char*);
int assemble(char*);
This diff is collapsed.
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
/*
9a is a version of the Plan 9 assembler. The original is documented at
http://plan9.bell-labs.com/magic/man2html/1/8a
Go-specific considerations are documented at
http://golang.org/doc/asm
Its target architecture is the Power64, referred to by these tools as
power64 (big endian) or power64le (little endian).
*/
package main
This diff is collapsed.
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
LMOVW = 258,
LMOVB = 259,
LABS = 260,
LLOGW = 261,
LSHW = 262,
LADDW = 263,
LCMP = 264,
LCROP = 265,
LBRA = 266,
LFMOV = 267,
LFCONV = 268,
LFCMP = 269,
LFADD = 270,
LFMA = 271,
LTRAP = 272,
LXORW = 273,
LNOP = 274,
LEND = 275,
LRETT = 276,
LWORD = 277,
LTEXT = 278,
LDATA = 279,
LRETRN = 280,
LCONST = 281,
LSP = 282,
LSB = 283,
LFP = 284,
LPC = 285,
LCREG = 286,
LFLUSH = 287,
LREG = 288,
LFREG = 289,
LR = 290,
LCR = 291,
LF = 292,
LFPSCR = 293,
LLR = 294,
LCTR = 295,
LSPR = 296,
LSPREG = 297,
LSEG = 298,
LMSR = 299,
LPCDAT = 300,
LFUNCDAT = 301,
LSCHED = 302,
LXLD = 303,
LXST = 304,
LXOP = 305,
LXMV = 306,
LRLWM = 307,
LMOVMW = 308,
LMOVEM = 309,
LMOVFL = 310,
LMTFSB = 311,
LMA = 312,
LFCONST = 313,
LSCONST = 314,
LNAME = 315,
LLAB = 316,
LVAR = 317
};
#endif
/* Tokens. */
#define LMOVW 258
#define LMOVB 259
#define LABS 260
#define LLOGW 261
#define LSHW 262
#define LADDW 263
#define LCMP 264
#define LCROP 265
#define LBRA 266
#define LFMOV 267
#define LFCONV 268
#define LFCMP 269
#define LFADD 270
#define LFMA 271
#define LTRAP 272
#define LXORW 273
#define LNOP 274
#define LEND 275
#define LRETT 276
#define LWORD 277
#define LTEXT 278
#define LDATA 279
#define LRETRN 280
#define LCONST 281
#define LSP 282
#define LSB 283
#define LFP 284
#define LPC 285
#define LCREG 286
#define LFLUSH 287
#define LREG 288
#define LFREG 289
#define LR 290
#define LCR 291
#define LF 292
#define LFPSCR 293
#define LLR 294
#define LCTR 295
#define LSPR 296
#define LSPREG 297
#define LSEG 298
#define LMSR 299
#define LPCDAT 300
#define LFUNCDAT 301
#define LSCHED 302
#define LXLD 303
#define LXST 304
#define LXOP 305
#define LXMV 306
#define LRLWM 307
#define LMOVMW 308
#define LMOVEM 309
#define LMOVFL 310
#define LMTFSB 311
#define LMA 312
#define LFCONST 313
#define LSCONST 314
#define LNAME 315
#define LLAB 316
#define LVAR 317
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 38 "a.y"
{
Sym *sym;
vlong lval;
double dval;
char sval[8];
Addr addr;
}
/* Line 1529 of yacc.c. */
#line 181 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
include ../../Make.dist
- effect of register expansion on 32-bit shifts and masks etc
9c
- multab
- floating-point conversions
- conversions of constants
- nodtype for loads
- sign-extension instruction (32-64) when in register?
- double indexing
- SLW (eg, in cat)
- scheduling
9l
- D_QCONST, DWORD
- maskgen
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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