Commit 47b89a37 authored by Russ Cox's avatar Russ Cox

cmd/5a, cmd/6a, cmd/8a: parse PCDATA

In cmd/5a, also add support for argument size in TEXT instruction.

R=ken2
CC=golang-dev
https://golang.org/cl/11357044
parent 56781822
......@@ -98,6 +98,7 @@ struct Gen
{
Sym* sym;
int32 offset;
int32 offset2;
short type;
short reg;
short name;
......
......@@ -54,7 +54,7 @@
%token <lval> LTYPEG LTYPEH LTYPEI LTYPEJ LTYPEK
%token <lval> LTYPEL LTYPEM LTYPEN LTYPEBX LTYPEPLD
%token <lval> LCONST LSP LSB LFP LPC
%token <lval> LTYPEX LR LREG LF LFREG LC LCREG LPSR LFCR
%token <lval> LTYPEX LTYPEPC LR LREG LF LFREG LC LCREG LPSR LFCR
%token <lval> LCOND LS LAT
%token <dval> LFCONST
%token <sval> LSCONST
......@@ -223,6 +223,16 @@ inst:
{
outcode($1, Always, &$2, $4, &$6);
}
| LTYPEB name ',' con ',' imm '-' con
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($8 == 0)
$8 = 1;
$6.type = D_CONST2;
$6.offset2 = $8;
outcode($1, Always, &$2, $4, &$6);
}
/*
* DATA
*/
......@@ -309,6 +319,13 @@ inst:
{
outcode($1, Always, &$2, NREG, &nullgen);
}
/*
* PCDATA
*/
| LTYPEPC imm ',' imm
{
outcode($1, Always, &$2, NREG, &$4);
}
/*
* END
*/
......
......@@ -414,6 +414,7 @@ struct
"MULAWB", LTYPEN, AMULAWB,
"USEFIELD", LTYPEN, AUSEFIELD,
"PCDATA", LTYPEPC, APCDATA,
0
};
......@@ -523,6 +524,13 @@ zaddr(Gen *a, int s)
Bputc(&obuf, a->offset);
break;
case D_CONST2:
l = a->offset2;
Bputc(&obuf, l);
Bputc(&obuf, l>>8);
Bputc(&obuf, l>>16);
Bputc(&obuf, l>>24);
// fall through
case D_OREG:
case D_CONST:
case D_BRANCH:
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.4.1. */
/* 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
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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, 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
part or all of the Bison parser skeleton and distribute that work
......@@ -28,11 +29,10 @@
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
......@@ -70,22 +70,23 @@
LFP = 286,
LPC = 287,
LTYPEX = 288,
LR = 289,
LREG = 290,
LF = 291,
LFREG = 292,
LC = 293,
LCREG = 294,
LPSR = 295,
LFCR = 296,
LCOND = 297,
LS = 298,
LAT = 299,
LFCONST = 300,
LSCONST = 301,
LNAME = 302,
LLAB = 303,
LVAR = 304
LTYPEPC = 289,
LR = 290,
LREG = 291,
LF = 292,
LFREG = 293,
LC = 294,
LCREG = 295,
LPSR = 296,
LFCR = 297,
LCOND = 298,
LS = 299,
LAT = 300,
LFCONST = 301,
LSCONST = 302,
LNAME = 303,
LLAB = 304,
LVAR = 305
};
#endif
/* Tokens. */
......@@ -120,49 +121,44 @@
#define LFP 286
#define LPC 287
#define LTYPEX 288
#define LR 289
#define LREG 290
#define LF 291
#define LFREG 292
#define LC 293
#define LCREG 294
#define LPSR 295
#define LFCR 296
#define LCOND 297
#define LS 298
#define LAT 299
#define LFCONST 300
#define LSCONST 301
#define LNAME 302
#define LLAB 303
#define LVAR 304
#define LTYPEPC 289
#define LR 290
#define LREG 291
#define LF 292
#define LFREG 293
#define LC 294
#define LCREG 295
#define LPSR 296
#define LFCR 297
#define LCOND 298
#define LS 299
#define LAT 300
#define LFCONST 301
#define LSCONST 302
#define LNAME 303
#define LLAB 304
#define LVAR 305
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
#line 38 "a.y"
{
Sym *sym;
int32 lval;
double dval;
char sval[8];
Gen gen;
/* Line 1676 of yacc.c */
#line 160 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
}
/* Line 1529 of yacc.c. */
#line 157 "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;
......@@ -49,7 +49,7 @@
%left '+' '-'
%left '*' '/' '%'
%token <lval> LTYPE0 LTYPE1 LTYPE2 LTYPE3 LTYPE4
%token <lval> LTYPEC LTYPED LTYPEN LTYPER LTYPET LTYPEG
%token <lval> LTYPEC LTYPED LTYPEN LTYPER LTYPET LTYPEG LTYPEPC
%token <lval> LTYPES LTYPEM LTYPEI LTYPEXC LTYPEX LTYPERT
%token <lval> LCONST LFP LPC LSB
%token <lval> LBREG LLREG LSREG LFREG LMREG LXREG
......@@ -58,7 +58,7 @@
%token <sym> LNAME LLAB LVAR
%type <lval> con con2 expr pointer offset
%type <gen> mem imm imm2 reg nam rel rem rim rom omem nmem
%type <gen2> nonnon nonrel nonrem rimnon rimrem remrim spec10 spec11
%type <gen2> nonnon nonrel nonrem rimnon rimrem remrim spec10 spec11 spec12
%type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9
%%
prog:
......@@ -115,6 +115,7 @@ inst:
| LTYPEX spec9 { outcode($1, &$2); }
| LTYPERT spec10 { outcode($1, &$2); }
| LTYPEG spec11 { outcode($1, &$2); }
| LTYPEPC spec12 { outcode($1, &$2); }
nonnon:
{
......@@ -308,6 +309,13 @@ spec11: /* GLOBL */
$$.to = $5;
}
spec12: /* PCDATA */
imm ',' imm
{
$$.from = $1;
$$.to = $3;
}
rem:
reg
| mem
......@@ -605,11 +613,19 @@ con2:
}
| LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($3 == 0)
$3 = 1;
$$ = ($1 & 0xffffffffLL) +
(($3 & 0xffffLL) << 32);
}
| '-' LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($4 == 0)
$4 = 1;
$$ = (-$2 & 0xffffffffLL) +
(($4 & 0xffffLL) << 32);
}
......
......@@ -1020,7 +1020,7 @@ struct
"PSHUFD", LTYPEX, APSHUFD,
"USEFIELD", LTYPEN, AUSEFIELD,
"PCLMULQDQ", LTYPEX, APCLMULQDQ,
"PCDATA", LTYPEPC, APCDATA,
0
};
......
This diff is collapsed.
......@@ -50,28 +50,29 @@
LTYPER = 266,
LTYPET = 267,
LTYPEG = 268,
LTYPES = 269,
LTYPEM = 270,
LTYPEI = 271,
LTYPEXC = 272,
LTYPEX = 273,
LTYPERT = 274,
LCONST = 275,
LFP = 276,
LPC = 277,
LSB = 278,
LBREG = 279,
LLREG = 280,
LSREG = 281,
LFREG = 282,
LMREG = 283,
LXREG = 284,
LFCONST = 285,
LSCONST = 286,
LSP = 287,
LNAME = 288,
LLAB = 289,
LVAR = 290
LTYPEPC = 269,
LTYPES = 270,
LTYPEM = 271,
LTYPEI = 272,
LTYPEXC = 273,
LTYPEX = 274,
LTYPERT = 275,
LCONST = 276,
LFP = 277,
LPC = 278,
LSB = 279,
LBREG = 280,
LLREG = 281,
LSREG = 282,
LFREG = 283,
LMREG = 284,
LXREG = 285,
LFCONST = 286,
LSCONST = 287,
LSP = 288,
LNAME = 289,
LLAB = 290,
LVAR = 291
};
#endif
/* Tokens. */
......@@ -86,28 +87,29 @@
#define LTYPER 266
#define LTYPET 267
#define LTYPEG 268
#define LTYPES 269
#define LTYPEM 270
#define LTYPEI 271
#define LTYPEXC 272
#define LTYPEX 273
#define LTYPERT 274
#define LCONST 275
#define LFP 276
#define LPC 277
#define LSB 278
#define LBREG 279
#define LLREG 280
#define LSREG 281
#define LFREG 282
#define LMREG 283
#define LXREG 284
#define LFCONST 285
#define LSCONST 286
#define LSP 287
#define LNAME 288
#define LLAB 289
#define LVAR 290
#define LTYPEPC 269
#define LTYPES 270
#define LTYPEM 271
#define LTYPEI 272
#define LTYPEXC 273
#define LTYPEX 274
#define LTYPERT 275
#define LCONST 276
#define LFP 277
#define LPC 278
#define LSB 279
#define LBREG 280
#define LLREG 281
#define LSREG 282
#define LFREG 283
#define LMREG 284
#define LXREG 285
#define LFCONST 286
#define LSCONST 287
#define LSP 288
#define LNAME 289
#define LLAB 290
#define LVAR 291
......@@ -124,7 +126,7 @@ typedef union YYSTYPE
Gen2 gen2;
}
/* Line 1529 of yacc.c. */
#line 128 "y.tab.h"
#line 130 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
......
......@@ -54,7 +54,7 @@
%left '*' '/' '%'
%token <lval> LTYPE0 LTYPE1 LTYPE2 LTYPE3 LTYPE4
%token <lval> LTYPEC LTYPED LTYPEN LTYPER LTYPET LTYPES LTYPEM LTYPEI LTYPEG LTYPEXC
%token <lval> LTYPEX LCONST LFP LPC LSB
%token <lval> LTYPEX LTYPEPC LCONST LFP LPC LSB
%token <lval> LBREG LLREG LSREG LFREG LXREG
%token <dval> LFCONST
%token <sval> LSCONST LSP
......@@ -63,7 +63,7 @@
%type <con2> con2
%type <gen> mem imm imm2 reg nam rel rem rim rom omem nmem
%type <gen2> nonnon nonrel nonrem rimnon rimrem remrim
%type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9 spec10
%type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9 spec10 spec11
%%
prog:
| prog
......@@ -118,6 +118,7 @@ inst:
| LTYPEG spec8 { outcode($1, &$2); }
| LTYPEXC spec9 { outcode($1, &$2); }
| LTYPEX spec10 { outcode($1, &$2); }
| LTYPEPC spec11 { outcode($1, &$2); }
nonnon:
{
......@@ -307,6 +308,13 @@ spec10: /* PINSRD */
$$.to.offset = $1.offset;
}
spec11: /* PCDATA */
imm ',' imm
{
$$.from = $1;
$$.to = $3;
}
rem:
reg
| mem
......@@ -457,11 +465,19 @@ con2:
}
| LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($3 == 0)
$3 = 1;
$$.v1 = $1;
$$.v2 = $3;
}
| '-' LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($4 == 0)
$4 = 1;
$$.v1 = -$2;
$$.v2 = $4;
}
......
......@@ -799,7 +799,7 @@ struct
"XORPD", LTYPE3, AXORPD,
"XORPS", LTYPE3, AXORPS,
"USEFIELD", LTYPEN, AUSEFIELD,
"PCDATA", LTYPEPC, APCDATA,
0
};
......
This diff is collapsed.
......@@ -55,21 +55,22 @@
LTYPEG = 271,
LTYPEXC = 272,
LTYPEX = 273,
LCONST = 274,
LFP = 275,
LPC = 276,
LSB = 277,
LBREG = 278,
LLREG = 279,
LSREG = 280,
LFREG = 281,
LXREG = 282,
LFCONST = 283,
LSCONST = 284,
LSP = 285,
LNAME = 286,
LLAB = 287,
LVAR = 288
LTYPEPC = 274,
LCONST = 275,
LFP = 276,
LPC = 277,
LSB = 278,
LBREG = 279,
LLREG = 280,
LSREG = 281,
LFREG = 282,
LXREG = 283,
LFCONST = 284,
LSCONST = 285,
LSP = 286,
LNAME = 287,
LLAB = 288,
LVAR = 289
};
#endif
/* Tokens. */
......@@ -89,21 +90,22 @@
#define LTYPEG 271
#define LTYPEXC 272
#define LTYPEX 273
#define LCONST 274
#define LFP 275
#define LPC 276
#define LSB 277
#define LBREG 278
#define LLREG 279
#define LSREG 280
#define LFREG 281
#define LXREG 282
#define LFCONST 283
#define LSCONST 284
#define LSP 285
#define LNAME 286
#define LLAB 287
#define LVAR 288
#define LTYPEPC 274
#define LCONST 275
#define LFP 276
#define LPC 277
#define LSB 278
#define LBREG 279
#define LLREG 280
#define LSREG 281
#define LFREG 282
#define LXREG 283
#define LFCONST 284
#define LSCONST 285
#define LSP 286
#define LNAME 287
#define LLAB 288
#define LVAR 289
......@@ -124,7 +126,7 @@ typedef union YYSTYPE
Gen2 gen2;
}
/* Line 1529 of yacc.c. */
#line 128 "y.tab.h"
#line 130 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
......
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