Choose type for integer literals to match the target mask size (if possible).
On a target with a 16-bit mask (for example), we would choose the type of an integer literal "1024" to be an int16. Previously, we used an int32, which is a worse fit and leads to less efficient code than an int16 on a 16-bit mask target. (However, we'd still give an integer literal 1000000 the type int32, even in a 16-bit target.) Updated the tests to still pass with 8 and 16-bit targets, given this change.
This commit is contained in:
23
parse.yy
23
parse.yy
@@ -179,6 +179,8 @@ struct ForeachDimension {
|
||||
}
|
||||
|
||||
|
||||
%token TOKEN_INT8_CONSTANT TOKEN_UINT8_CONSTANT
|
||||
%token TOKEN_INT16_CONSTANT TOKEN_UINT16_CONSTANT
|
||||
%token TOKEN_INT32_CONSTANT TOKEN_UINT32_CONSTANT
|
||||
%token TOKEN_INT64_CONSTANT TOKEN_UINT64_CONSTANT
|
||||
%token TOKEN_INT32DOTDOTDOT_CONSTANT TOKEN_UINT32DOTDOTDOT_CONSTANT
|
||||
@@ -291,6 +293,22 @@ primary_expression
|
||||
Error(@1, "Undeclared symbol \"%s\".%s", name, alts.c_str());
|
||||
}
|
||||
}
|
||||
| TOKEN_INT8_CONSTANT {
|
||||
$$ = new ConstExpr(AtomicType::UniformInt8->GetAsConstType(),
|
||||
(int8_t)yylval.intVal, @1);
|
||||
}
|
||||
| TOKEN_UINT8_CONSTANT {
|
||||
$$ = new ConstExpr(AtomicType::UniformUInt8->GetAsConstType(),
|
||||
(uint8_t)yylval.intVal, @1);
|
||||
}
|
||||
| TOKEN_INT16_CONSTANT {
|
||||
$$ = new ConstExpr(AtomicType::UniformInt16->GetAsConstType(),
|
||||
(int16_t)yylval.intVal, @1);
|
||||
}
|
||||
| TOKEN_UINT16_CONSTANT {
|
||||
$$ = new ConstExpr(AtomicType::UniformUInt16->GetAsConstType(),
|
||||
(uint16_t)yylval.intVal, @1);
|
||||
}
|
||||
| TOKEN_INT32_CONSTANT {
|
||||
$$ = new ConstExpr(AtomicType::UniformInt32->GetAsConstType(),
|
||||
(int32_t)yylval.intVal, @1);
|
||||
@@ -1233,7 +1251,10 @@ declarator
|
||||
;
|
||||
|
||||
int_constant
|
||||
: TOKEN_INT32_CONSTANT { $$ = yylval.intVal; }
|
||||
: TOKEN_INT8_CONSTANT { $$ = yylval.intVal; }
|
||||
| TOKEN_INT16_CONSTANT { $$ = yylval.intVal; }
|
||||
| TOKEN_INT32_CONSTANT { $$ = yylval.intVal; }
|
||||
| TOKEN_INT64_CONSTANT { $$ = yylval.intVal; }
|
||||
;
|
||||
|
||||
direct_declarator
|
||||
|
||||
Reference in New Issue
Block a user