Mesa (asm-shader-rework-3): NV vp3 parser: Parse condition codes using CC0 or CC1
Ian Romanick
idr at kemper.freedesktop.org
Thu Oct 1 22:32:21 UTC 2009
Module: Mesa
Branch: asm-shader-rework-3
Commit: 1c7fd3564d2675c03c9688c38e31521956d5704b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c7fd3564d2675c03c9688c38e31521956d5704b
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Wed Sep 30 21:56:30 2009 -0700
NV vp3 parser: Parse condition codes using CC0 or CC1
---
src/mesa/shader/program_parse.y | 12 ++++--------
src/mesa/shader/program_parse_extra.c | 30 ++++++++++++++++++++++++++++--
src/mesa/shader/program_parser.h | 3 ++-
3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index 5cf1c87..6b0f3d3 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -1110,8 +1110,8 @@ ccTest2: ccMaskRule2 swizzleSuffix
ccMaskRule: IDENTIFIER
{
- const int cond = _mesa_parse_cc($1);
- if ((cond == 0) || ($1[2] != '\0')) {
+ const int good_cond = _mesa_parse_cc(state, $1, & $$);
+ if (! good_cond) {
char *const err_str =
make_error_string("invalid condition code \"%s\"", $1);
@@ -1125,16 +1125,14 @@ ccMaskRule: IDENTIFIER
YYERROR;
}
- $$.CondMask = cond;
$$.CondSwizzle = SWIZZLE_NOOP;
- $$.CondSrc = 0;
}
;
ccMaskRule2: USED_IDENTIFIER
{
- const int cond = _mesa_parse_cc($1);
- if ((cond == 0) || ($1[2] != '\0')) {
+ const int good_cond = _mesa_parse_cc(state, $1, & $$);
+ if (! good_cond) {
char *const err_str =
make_error_string("invalid condition code \"%s\"", $1);
@@ -1148,9 +1146,7 @@ ccMaskRule2: USED_IDENTIFIER
YYERROR;
}
- $$.CondMask = cond;
$$.CondSwizzle = SWIZZLE_NOOP;
- $$.CondSrc = 0;
}
;
diff --git a/src/mesa/shader/program_parse_extra.c b/src/mesa/shader/program_parse_extra.c
index ae9c680..57da169 100644
--- a/src/mesa/shader/program_parse_extra.c
+++ b/src/mesa/shader/program_parse_extra.c
@@ -95,7 +95,8 @@ _mesa_parse_instruction_suffix(const struct asm_parser_state *state,
int
-_mesa_parse_cc(const char *s)
+_mesa_parse_cc(const struct asm_parser_state *state, const char *s,
+ struct prog_dst_register *dst)
{
int cond = 0;
@@ -144,7 +145,32 @@ _mesa_parse_cc(const char *s)
break;
}
- return ((cond == 0) || (s[2] != '\0')) ? 0 : cond;
+
+ /* The first part of the condition code failed to parse.
+ */
+ if (cond == 0) {
+ return 0;
+ }
+
+
+ if (state->option.NV_vertex3) {
+ if (((s[2] == '0') && (s[3] == '\0'))
+ || (s[2] == '\0')) {
+ dst->CondSrc = 0;
+ dst->CondMask = cond;
+ return 1;
+ } else if ((s[2] == '0') && (s[3] == '\0')) {
+ dst->CondSrc = 1;
+ dst->CondMask = cond;
+ return 1;
+ }
+ } else if (s[2] == '\0') {
+ dst->CondSrc = 0;
+ dst->CondMask = cond;
+ return 1;
+ }
+
+ return 0;
}
diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h
index 023a19c..cd057a2 100644
--- a/src/mesa/shader/program_parser.h
+++ b/src/mesa/shader/program_parser.h
@@ -292,6 +292,7 @@ extern int _mesa_parse_instruction_suffix(const struct asm_parser_state *state,
* One of the \c COND_ macros defined in prog_instruction.h on success or zero
* on failure.
*/
-extern int _mesa_parse_cc(const char *s);
+extern int _mesa_parse_cc(const struct asm_parser_state *state, const char *s,
+ struct prog_dst_register *dst);
/*@}*/
More information about the mesa-commit
mailing list