diff --git a/parse.yy b/parse.yy index 106ade17..a485ce55 100644 --- a/parse.yy +++ b/parse.yy @@ -110,6 +110,7 @@ static const char *lBuiltinTokens[] = { Expr *expr; ExprList *exprList; const Type *type; + const AtomicType *atomicType; int typeQualifier; StorageClass storageClass; Stmt *stmt; @@ -176,6 +177,8 @@ static const char *lBuiltinTokens[] = { %type specifier_qualifier_list struct_or_union_specifier %type enum_specifier type_specifier type_name +%type short_vec_specifier +%type atomic_var_type_specifier %type type_qualifier %type storage_class_specifier @@ -534,13 +537,7 @@ storage_class_specifier ; type_specifier - : TOKEN_VOID { $$ = AtomicType::Void; } - | TOKEN_BOOL { $$ = AtomicType::VaryingBool; } -/* | TOKEN_CHAR { UNIMPLEMENTED; } */ - | TOKEN_INT { $$ = AtomicType::VaryingInt32; } - | TOKEN_FLOAT { $$ = AtomicType::VaryingFloat; } - | TOKEN_DOUBLE { $$ = AtomicType::VaryingDouble; } - | TOKEN_INT64 { $$ = AtomicType::VaryingInt64; } + : atomic_var_type_specifier { $$ = $1; } | TOKEN_TYPE_NAME { const Type *t = m->symbolTable->LookupType(yytext); assert(t != NULL); @@ -554,6 +551,25 @@ type_specifier */ ; +atomic_var_type_specifier + : TOKEN_VOID { $$ = AtomicType::Void; } + | TOKEN_BOOL { $$ = AtomicType::VaryingBool; } +/* | TOKEN_CHAR { UNIMPLEMENTED; } */ + | TOKEN_INT { $$ = AtomicType::VaryingInt32; } + | TOKEN_FLOAT { $$ = AtomicType::VaryingFloat; } + | TOKEN_DOUBLE { $$ = AtomicType::VaryingDouble; } + | TOKEN_INT64 { $$ = AtomicType::VaryingInt64; } + ; + +short_vec_specifier + : atomic_var_type_specifier '<' int_constant '>' + { + Type* vt = + new VectorType($1, $3); + $$ = vt; + } + ; + struct_or_union_name : TOKEN_IDENTIFIER { $$ = strdup(yytext); } | TOKEN_TYPE_NAME { $$ = strdup(yytext); } @@ -630,6 +646,7 @@ struct_declaration specifier_qualifier_list : type_specifier specifier_qualifier_list | type_specifier + | short_vec_specifier | type_qualifier specifier_qualifier_list { if ($1 == TYPEQUAL_UNIFORM) diff --git a/tests/struct-test-124.ispc b/tests/struct-test-124.ispc new file mode 100644 index 00000000..0ae72228 --- /dev/null +++ b/tests/struct-test-124.ispc @@ -0,0 +1,15 @@ + +export uniform int width() { return programCount; } + + +export void f_v(uniform float RET[]) { + varying struct { float<2> v; } a; + a.v.x = 1; + a.v.y = 2; + RET[programIndex] = a.v.x + a.v.y; +} + + +export void result(uniform float RET[]) { + RET[programIndex] = 3; +} diff --git a/tests/struct-test-125.ispc b/tests/struct-test-125.ispc new file mode 100644 index 00000000..a4590bc7 --- /dev/null +++ b/tests/struct-test-125.ispc @@ -0,0 +1,15 @@ + +export uniform int width() { return programCount; } + + +export void f_v(uniform float RET[]) { + varying struct { float<2> v; } a; + a.v[0] = 1; + a.v[1] = 2; + RET[programIndex] = a.v[0] + a.v[1]; +} + + +export void result(uniform float RET[]) { + RET[programIndex] = 3; +}