Mesa (master): glsl: build without bison
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Apr 13 19:34:47 UTC 2021
Module: Mesa
Branch: master
Commit: a18ac347cf740677c8fb8ca0e51a60545a5b0f00
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a18ac347cf740677c8fb8ca0e51a60545a5b0f00
Author: Ella-0 <23418164+Ella-0 at users.noreply.github.com>
Date: Wed Jan 27 14:16:08 2021 +0000
glsl: build without bison
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8739>
---
meson.build | 9 +++++-
src/compiler/glsl/glcpp/meson.build | 18 ++++++++---
src/compiler/glsl/meson.build | 18 ++++++++---
src/intel/tools/i965_asm.h | 1 -
src/intel/tools/i965_gram.y | 63 ++++++++++++++++++++++---------------
src/intel/tools/meson.build | 18 ++++++++---
src/mesa/program/meson.build | 9 +++++-
7 files changed, 96 insertions(+), 40 deletions(-)
diff --git a/meson.build b/meson.build
index 7a95d87d862..8ef1e5f71aa 100644
--- a/meson.build
+++ b/meson.build
@@ -1724,6 +1724,8 @@ else
asan_c_args = ['-DBUILT_WITH_ASAN=0']
endif
+yacc_is_bison = true
+
if build_machine.system() == 'windows'
# Prefer the winflexbison versions, they're much easier to install and have
# better windows support.
@@ -1746,7 +1748,12 @@ if build_machine.system() == 'windows'
prog_bison = find_program('bison', 'yacc', required : with_any_opengl)
endif
else
- prog_bison = find_program('bison', required : with_any_opengl)
+ prog_bison = find_program('bison', required : false)
+
+ if not prog_bison.found()
+ prog_bison = find_program('byacc', required : with_any_opengl)
+ yacc_is_bison = false
+ endif
# Disable deprecated keyword warnings, since we have to use them for
# old-bison compat. See discussion in
diff --git a/src/compiler/glsl/glcpp/meson.build b/src/compiler/glsl/glcpp/meson.build
index a4789b32c01..0c67d1fa741 100644
--- a/src/compiler/glsl/glcpp/meson.build
+++ b/src/compiler/glsl/glcpp/meson.build
@@ -18,14 +18,24 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+bison_command = []
+if yacc_is_bison
+ bison_command = [
+ prog_bison, '-o', '@OUTPUT0@', '-p', 'glcpp_parser_',
+ '--defines=@OUTPUT1@', '@INPUT@',
+ ]
+else
+ bison_command = [
+ prog_bison, '-o', '@OUTPUT0@', '-p', 'glcpp_parser_',
+ '-H', '@OUTPUT1@', '@INPUT@',
+ ]
+endif
+
glcpp_parse = custom_target(
'glcpp-parse.[ch]',
input : 'glcpp-parse.y',
output : ['glcpp-parse.c', 'glcpp-parse.h'],
- command : [
- prog_bison, '-o', '@OUTPUT0@', '-p', 'glcpp_parser_',
- '--defines=@OUTPUT1@', '@INPUT@',
- ],
+ command : bison_command
)
glcpp_lex = custom_target(
diff --git a/src/compiler/glsl/meson.build b/src/compiler/glsl/meson.build
index 92635958adf..77febac4002 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/compiler/glsl/meson.build
@@ -20,14 +20,24 @@
subdir('glcpp')
+bison_command = []
+if yacc_is_bison
+ bison_command = [
+ prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_', '--defines=@OUTPUT1@',
+ '@INPUT@',
+ ]
+else
+ bison_command = [
+ prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_', '-H', '@OUTPUT1@',
+ '@INPUT@',
+ ]
+endif
+
glsl_parser = custom_target(
'glsl_parser',
input : 'glsl_parser.yy',
output : ['glsl_parser.cpp', 'glsl_parser.h'],
- command : [
- prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_', '--defines=@OUTPUT1@',
- '@INPUT@',
- ],
+ command : bison_command
)
glsl_lexer_cpp = custom_target(
diff --git a/src/intel/tools/i965_asm.h b/src/intel/tools/i965_asm.h
index a7e4e86b36d..200b2248fc5 100644
--- a/src/intel/tools/i965_asm.h
+++ b/src/intel/tools/i965_asm.h
@@ -40,7 +40,6 @@
/* glibc < 2.27 defines OVERFLOW in /usr/include/math.h. */
#undef OVERFLOW
-void yyerror (char *);
int yyparse(void);
int yylex(void);
char *lex_text(void);
diff --git a/src/intel/tools/i965_gram.y b/src/intel/tools/i965_gram.y
index 4e191acc459..bfc875d9714 100644
--- a/src/intel/tools/i965_gram.y
+++ b/src/intel/tools/i965_gram.y
@@ -28,6 +28,14 @@
#include <strings.h>
#include "i965_asm.h"
+#undef yyerror
+#ifdef YYBYACC
+struct YYLTYPE;
+void yyerror (struct YYLTYPE *, char *);
+#else
+void yyerror (char *);
+#endif
+
#undef ALIGN16
#define YYLTYPE YYLTYPE
@@ -467,11 +475,11 @@ add_label(struct brw_codegen *p, const char* label_name, enum instr_label_type t
%token <llint> LONG
%token NULL_TOKEN
-%precedence SUBREGNUM
+%nonassoc SUBREGNUM
%left PLUS MINUS
-%precedence DOT
-%precedence EMPTYEXECSIZE
-%precedence LPAREN
+%nonassoc DOT
+%nonassoc EMPTYEXECSIZE
+%nonassoc LPAREN
%type <integer> execsize simple_int exp
%type <llint> exp2
@@ -1470,7 +1478,7 @@ simple_int:
rellocation:
relativelocation
- | %empty { $$ = 0; }
+ | /* empty */ { $$ = 0; }
;
relativelocation:
@@ -1482,7 +1490,7 @@ relativelocation:
jumplabel:
JUMP_LABEL { $$ = $1; }
- | %empty { $$ = NULL; }
+ | /* empty */ { $$ = NULL; }
;
jumplabeltarget:
@@ -1778,7 +1786,7 @@ exp:
subregnum:
DOT exp { $$ = $2; }
- | %empty %prec SUBREGNUM { $$ = 0; }
+ | /* empty */ %prec SUBREGNUM { $$ = 0; }
;
directgenreg:
@@ -2001,7 +2009,7 @@ immval:
/* Regions */
dstregion:
- %empty
+ /* empty */
{
$$ = BRW_HORIZONTAL_STRIDE_1;
}
@@ -2020,7 +2028,7 @@ indirectregion:
;
region:
- %empty
+ /* empty */
{
$$ = stride($$, 0, 1, 0);
}
@@ -2111,7 +2119,7 @@ imm_type:
;
writemask:
- %empty
+ /* empty */
{
$$ = WRITEMASK_XYZW;
}
@@ -2122,27 +2130,27 @@ writemask:
;
writemask_x:
- %empty { $$ = 0; }
+ /* empty */ { $$ = 0; }
| X { $$ = 1 << BRW_CHANNEL_X; }
;
writemask_y:
- %empty { $$ = 0; }
+ /* empty */ { $$ = 0; }
| Y { $$ = 1 << BRW_CHANNEL_Y; }
;
writemask_z:
- %empty { $$ = 0; }
+ /* empty */ { $$ = 0; }
| Z { $$ = 1 << BRW_CHANNEL_Z; }
;
writemask_w:
- %empty { $$ = 0; }
+ /* empty */ { $$ = 0; }
| W { $$ = 1 << BRW_CHANNEL_W; }
;
swizzle:
- %empty
+ /* empty */
{
$$ = BRW_SWIZZLE_NOOP;
}
@@ -2165,7 +2173,7 @@ chansel:
/* Instruction prediction and modifiers */
predicate:
- %empty
+ /* empty */
{
brw_push_insn_state(p);
brw_set_default_predicate_control(p, BRW_PREDICATE_NONE);
@@ -2182,13 +2190,13 @@ predicate:
;
predstate:
- %empty { $$ = 0; }
+ /* empty */ { $$ = 0; }
| PLUS { $$ = 0; }
| MINUS { $$ = 1; }
;
predctrl:
- %empty { $$ = BRW_PREDICATE_NORMAL; }
+ /* empty */ { $$ = BRW_PREDICATE_NORMAL; }
| DOT X { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_X; }
| DOT Y { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Y; }
| DOT Z { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Z; }
@@ -2209,12 +2217,12 @@ predctrl:
/* Source Modification */
negate:
- %empty { $$ = 0; }
+ /* empty */ { $$ = 0; }
| MINUS { $$ = 1; }
;
abs:
- %empty { $$ = 0; }
+ /* empty */ { $$ = 0; }
| ABS { $$ = 1; }
;
@@ -2235,7 +2243,7 @@ cond_mod:
;
condModifiers:
- %empty { $$ = BRW_CONDITIONAL_NONE; }
+ /* empty */ { $$ = BRW_CONDITIONAL_NONE; }
| ZERO
| EQUAL
| NOT_ZERO
@@ -2250,13 +2258,13 @@ condModifiers:
;
saturate:
- %empty { $$ = BRW_INSTRUCTION_NORMAL; }
+ /* empty */ { $$ = BRW_INSTRUCTION_NORMAL; }
| SATURATE { $$ = BRW_INSTRUCTION_SATURATE; }
;
/* Execution size */
execsize:
- %empty %prec EMPTYEXECSIZE
+ /* empty */ %prec EMPTYEXECSIZE
{
$$ = 0;
}
@@ -2271,7 +2279,7 @@ execsize:
/* Instruction options */
instoptions:
- %empty
+ /* empty */
{
memset(&$$, 0, sizeof($$));
}
@@ -2295,7 +2303,7 @@ instoption_list:
$$ = $1;
add_instruction_option(&$$, $2);
}
- | %empty
+ | /* empty */
{
memset(&$$, 0, sizeof($$));
}
@@ -2334,8 +2342,13 @@ instoption:
extern int yylineno;
+#ifdef YYBYACC
+void
+yyerror(YYLTYPE *ltype, char *msg)
+#else
void
yyerror(char *msg)
+#endif
{
fprintf(stderr, "%s: %d: %s at \"%s\"\n",
input_filename, yylineno, msg, lex_text());
diff --git a/src/intel/tools/meson.build b/src/intel/tools/meson.build
index 7c4cc3e4ccf..3653e1dcfea 100644
--- a/src/intel/tools/meson.build
+++ b/src/intel/tools/meson.build
@@ -161,14 +161,24 @@ if with_tools.contains('intel-ui')
)
endif
+bison_command = []
+if yacc_is_bison
+ bison_command = [
+ prog_bison, '@INPUT@', '--defines=@OUTPUT1@',
+ '--output=@OUTPUT0@'
+ ]
+else
+ bison_command = [
+ prog_bison, '-H', '@OUTPUT1@',
+ '-o', '@OUTPUT0@', '@INPUT@'
+ ]
+endif
+
i965_gram_tab = custom_target(
'i965_gram.tab.[ch]',
input : 'i965_gram.y',
output : ['i965_gram.tab.c', 'i965_gram.tab.h'],
- command : [
- prog_bison, '@INPUT@', '--defines=@OUTPUT1@',
- '--output=@OUTPUT0@'
- ]
+ command : bison_command
)
i965_lex_yy_c = custom_target(
diff --git a/src/mesa/program/meson.build b/src/mesa/program/meson.build
index 5f3325ff53c..1b76d3210b6 100644
--- a/src/mesa/program/meson.build
+++ b/src/mesa/program/meson.build
@@ -18,6 +18,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+bison_command = []
+if yacc_is_bison
+ bison_command = [prog_bison, '-o', '@OUTPUT0@', '--defines=@OUTPUT1@', '@INPUT@']
+else
+ bison_command = [prog_bison, '-o', '@OUTPUT0@', '-H', '@OUTPUT1@', '@INPUT@']
+endif
+
mesa_lex = custom_target(
'mesa_lex',
input : 'program_lexer.l',
@@ -29,5 +36,5 @@ program_parse_tab = custom_target(
'program_parse_tab.[ch]',
input : 'program_parse.y',
output : ['program_parse.tab.c', 'program_parse.tab.h'],
- command : [prog_bison, '-o', '@OUTPUT0@', '--defines=@OUTPUT1@', '@INPUT@'],
+ command : bison_command,
)
More information about the mesa-commit
mailing list