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