Update lexer to not include `-` in numbers.
This CL removes the parsing of a `-` in front of numerics when lexed. This will cause the number to become a UnaryOperator negation then the number instead of a negative number. Bug: tint:1679, tint:1141, tint:1570 Change-Id: I217c0ffcbe5be934c8d56bd83141b47ade83bc60 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106463 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
63463c2f77
commit
b3b027d3cd
|
@ -203,7 +203,7 @@ TEST(ChangeUnaryOperatorTest, Signed_Integer_Types_Applicable2) {
|
||||||
ASSERT_TRUE(result.success) << result.error;
|
ASSERT_TRUE(result.success) << result.error;
|
||||||
|
|
||||||
std::string expected_shader = R"(fn main() {
|
std::string expected_shader = R"(fn main() {
|
||||||
let b : vec3<i32> = vec3<i32>(1, 3, -1);
|
let b : vec3<i32> = vec3<i32>(1, 3, -(1));
|
||||||
var comp_b : vec3<i32> = -(b);
|
var comp_b : vec3<i32> = -(b);
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
@ -246,7 +246,7 @@ TEST(ChangeUnaryOperatorTest, Signed_Integer_Types_Applicable3) {
|
||||||
ASSERT_TRUE(result.success) << result.error;
|
ASSERT_TRUE(result.success) << result.error;
|
||||||
|
|
||||||
std::string expected_shader = R"(fn main() {
|
std::string expected_shader = R"(fn main() {
|
||||||
var a = -5;
|
var a = -(5);
|
||||||
var neg_a = ~(a);
|
var neg_a = ~(a);
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
@ -288,7 +288,7 @@ TEST(ChangeUnaryOperatorTest, Signed_Integer_Types_Applicable4) {
|
||||||
ASSERT_TRUE(result.success) << result.error;
|
ASSERT_TRUE(result.success) << result.error;
|
||||||
|
|
||||||
std::string expected_shader = R"(fn main() {
|
std::string expected_shader = R"(fn main() {
|
||||||
var b : vec3<i32> = vec3<i32>(1, 3, -1);
|
var b : vec3<i32> = vec3<i32>(1, 3, -(1));
|
||||||
let neg_b : vec3<i32> = ~(b);
|
let neg_b : vec3<i32> = ~(b);
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
|
@ -260,7 +260,7 @@ TEST(WrapUnaryOperatorTest, Applicable6) {
|
||||||
ASSERT_TRUE(result.success) << result.error;
|
ASSERT_TRUE(result.success) << result.error;
|
||||||
|
|
||||||
std::string expected_shader = R"(fn main() {
|
std::string expected_shader = R"(fn main() {
|
||||||
var a : vec4<f32> = -(vec4<f32>(-1.0, -1.0, -1.0, -1.0));
|
var a : vec4<f32> = -(vec4<f32>(-(1.0), -(1.0), -(1.0), -(1.0)));
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
ASSERT_EQ(expected_shader, result.wgsl);
|
ASSERT_EQ(expected_shader, result.wgsl);
|
||||||
|
@ -345,7 +345,7 @@ TEST(WrapUnaryOperatorTest, Applicable8) {
|
||||||
ASSERT_TRUE(result.success) << result.error;
|
ASSERT_TRUE(result.success) << result.error;
|
||||||
|
|
||||||
std::string expected_shader = R"(fn main() {
|
std::string expected_shader = R"(fn main() {
|
||||||
var a : vec4<i32> = ~(vec4<i32>(1, 0, -1, 0));
|
var a : vec4<i32> = ~(vec4<i32>(1, 0, -(1), 0));
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
ASSERT_EQ(expected_shader, result.wgsl);
|
ASSERT_EQ(expected_shader, result.wgsl);
|
||||||
|
|
|
@ -328,9 +328,6 @@ Token Lexer::try_float() {
|
||||||
auto source = begin_source();
|
auto source = begin_source();
|
||||||
bool has_mantissa_digits = false;
|
bool has_mantissa_digits = false;
|
||||||
|
|
||||||
if (matches(end, '-')) {
|
|
||||||
end++;
|
|
||||||
}
|
|
||||||
while (end < length() && is_digit(at(end))) {
|
while (end < length() && is_digit(at(end))) {
|
||||||
has_mantissa_digits = true;
|
has_mantissa_digits = true;
|
||||||
end++;
|
end++;
|
||||||
|
@ -426,7 +423,6 @@ Token Lexer::try_hex_float() {
|
||||||
constexpr uint64_t kExponentMask = (1 << kExponentBits) - 1;
|
constexpr uint64_t kExponentMask = (1 << kExponentBits) - 1;
|
||||||
constexpr int64_t kExponentMax = kExponentMask; // Including NaN / inf
|
constexpr int64_t kExponentMax = kExponentMask; // Including NaN / inf
|
||||||
constexpr uint64_t kExponentLeftShift = kMantissaBits;
|
constexpr uint64_t kExponentLeftShift = kMantissaBits;
|
||||||
constexpr uint64_t kSignBit = kTotalBits - 1;
|
|
||||||
constexpr uint64_t kOne = 1;
|
constexpr uint64_t kOne = 1;
|
||||||
|
|
||||||
auto start = pos();
|
auto start = pos();
|
||||||
|
@ -434,16 +430,8 @@ Token Lexer::try_hex_float() {
|
||||||
|
|
||||||
auto source = begin_source();
|
auto source = begin_source();
|
||||||
|
|
||||||
// clang-format off
|
// 0[xX]([0-9a-fA-F]*.?[0-9a-fA-F]+ | [0-9a-fA-F]+.[0-9a-fA-F]*)(p|P)(+|-)?[0-9]+ // NOLINT
|
||||||
// -?0[xX]([0-9a-fA-F]*.?[0-9a-fA-F]+ | [0-9a-fA-F]+.[0-9a-fA-F]*)(p|P)(+|-)?[0-9]+ // NOLINT
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
// -?
|
|
||||||
uint64_t sign_bit = 0;
|
|
||||||
if (matches(end, '-')) {
|
|
||||||
sign_bit = 1;
|
|
||||||
end++;
|
|
||||||
}
|
|
||||||
// 0[xX]
|
// 0[xX]
|
||||||
if (matches(end, '0') && (matches(end + 1, 'x') || matches(end + 1, 'X'))) {
|
if (matches(end, '0') && (matches(end + 1, 'x') || matches(end + 1, 'X'))) {
|
||||||
end += 2;
|
end += 2;
|
||||||
|
@ -696,7 +684,7 @@ Token Lexer::try_hex_float() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Combine sign, mantissa, and exponent
|
// Combine sign, mantissa, and exponent
|
||||||
uint64_t result_u64 = sign_bit << kSignBit;
|
uint64_t result_u64 = 0;
|
||||||
result_u64 |= mantissa;
|
result_u64 |= mantissa;
|
||||||
result_u64 |= (static_cast<uint64_t>(signed_exponent) & kExponentMask) << kExponentLeftShift;
|
result_u64 |= (static_cast<uint64_t>(signed_exponent) & kExponentMask) << kExponentLeftShift;
|
||||||
|
|
||||||
|
@ -856,10 +844,6 @@ Token Lexer::try_hex_integer() {
|
||||||
|
|
||||||
auto source = begin_source();
|
auto source = begin_source();
|
||||||
|
|
||||||
if (matches(curr, '-')) {
|
|
||||||
curr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matches(curr, '0') && (matches(curr + 1, 'x') || matches(curr + 1, 'X'))) {
|
if (matches(curr, '0') && (matches(curr + 1, 'x') || matches(curr + 1, 'X'))) {
|
||||||
curr += 2;
|
curr += 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -880,10 +864,6 @@ Token Lexer::try_integer() {
|
||||||
|
|
||||||
auto source = begin_source();
|
auto source = begin_source();
|
||||||
|
|
||||||
if (matches(curr, '-')) {
|
|
||||||
curr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curr >= length() || !is_digit(at(curr))) {
|
if (curr >= length() || !is_digit(at(curr))) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,57 +426,35 @@ INSTANTIATE_TEST_SUITE_P(LexerTest,
|
||||||
// No decimal, with 'f' suffix
|
// No decimal, with 'f' suffix
|
||||||
FloatData{"0f", 0.0},
|
FloatData{"0f", 0.0},
|
||||||
FloatData{"1f", 1.0},
|
FloatData{"1f", 1.0},
|
||||||
FloatData{"-0f", 0.0},
|
|
||||||
FloatData{"-1f", -1.0},
|
|
||||||
// No decimal, with 'h' suffix
|
// No decimal, with 'h' suffix
|
||||||
FloatData{"0h", 0.0},
|
FloatData{"0h", 0.0},
|
||||||
FloatData{"1h", 1.0},
|
FloatData{"1h", 1.0},
|
||||||
FloatData{"-0h", 0.0},
|
|
||||||
FloatData{"-1h", -1.0},
|
|
||||||
|
|
||||||
// Zero, with decimal.
|
// Zero, with decimal.
|
||||||
FloatData{"0.0", 0.0},
|
FloatData{"0.0", 0.0},
|
||||||
FloatData{"0.", 0.0},
|
FloatData{"0.", 0.0},
|
||||||
FloatData{".0", 0.0},
|
FloatData{".0", 0.0},
|
||||||
FloatData{"-0.0", 0.0},
|
|
||||||
FloatData{"-0.", 0.0},
|
|
||||||
FloatData{"-.0", 0.0},
|
|
||||||
// Zero, with decimal and 'f' suffix
|
// Zero, with decimal and 'f' suffix
|
||||||
FloatData{"0.0f", 0.0},
|
FloatData{"0.0f", 0.0},
|
||||||
FloatData{"0.f", 0.0},
|
FloatData{"0.f", 0.0},
|
||||||
FloatData{".0f", 0.0},
|
FloatData{".0f", 0.0},
|
||||||
FloatData{"-0.0f", 0.0},
|
|
||||||
FloatData{"-0.f", 0.0},
|
|
||||||
FloatData{"-.0f", 0.0},
|
|
||||||
// Zero, with decimal and 'h' suffix
|
// Zero, with decimal and 'h' suffix
|
||||||
FloatData{"0.0h", 0.0},
|
FloatData{"0.0h", 0.0},
|
||||||
FloatData{"0.h", 0.0},
|
FloatData{"0.h", 0.0},
|
||||||
FloatData{".0h", 0.0},
|
FloatData{".0h", 0.0},
|
||||||
FloatData{"-0.0h", 0.0},
|
|
||||||
FloatData{"-0.h", 0.0},
|
|
||||||
FloatData{"-.0h", 0.0},
|
|
||||||
|
|
||||||
// Non-zero with decimal
|
// Non-zero with decimal
|
||||||
FloatData{"5.7", 5.7},
|
FloatData{"5.7", 5.7},
|
||||||
FloatData{"5.", 5.},
|
FloatData{"5.", 5.},
|
||||||
FloatData{".7", .7},
|
FloatData{".7", .7},
|
||||||
FloatData{"-5.7", -5.7},
|
|
||||||
FloatData{"-5.", -5.},
|
|
||||||
FloatData{"-.7", -.7},
|
|
||||||
// Non-zero with decimal and 'f' suffix
|
// Non-zero with decimal and 'f' suffix
|
||||||
FloatData{"5.7f", static_cast<double>(5.7f)},
|
FloatData{"5.7f", static_cast<double>(5.7f)},
|
||||||
FloatData{"5.f", static_cast<double>(5.f)},
|
FloatData{"5.f", static_cast<double>(5.f)},
|
||||||
FloatData{".7f", static_cast<double>(.7f)},
|
FloatData{".7f", static_cast<double>(.7f)},
|
||||||
FloatData{"-5.7f", static_cast<double>(-5.7f)},
|
|
||||||
FloatData{"-5.f", static_cast<double>(-5.f)},
|
|
||||||
FloatData{"-.7f", static_cast<double>(-.7f)},
|
|
||||||
// Non-zero with decimal and 'h' suffix
|
// Non-zero with decimal and 'h' suffix
|
||||||
FloatData{"5.7h", static_cast<double>(f16::Quantize(5.7f))},
|
FloatData{"5.7h", static_cast<double>(f16::Quantize(5.7f))},
|
||||||
FloatData{"5.h", static_cast<double>(f16::Quantize(5.f))},
|
FloatData{"5.h", static_cast<double>(f16::Quantize(5.f))},
|
||||||
FloatData{".7h", static_cast<double>(f16::Quantize(.7f))},
|
FloatData{".7h", static_cast<double>(f16::Quantize(.7f))},
|
||||||
FloatData{"-5.7h", static_cast<double>(f16::Quantize(-5.7f))},
|
|
||||||
FloatData{"-5.h", static_cast<double>(f16::Quantize(-5.f))},
|
|
||||||
FloatData{"-.7h", static_cast<double>(f16::Quantize(-.7f))},
|
|
||||||
|
|
||||||
// No decimal, with exponent
|
// No decimal, with exponent
|
||||||
FloatData{"1e5", 1e5},
|
FloatData{"1e5", 1e5},
|
||||||
|
@ -532,7 +510,6 @@ TEST_P(FloatTest_Invalid, Handles) {
|
||||||
INSTANTIATE_TEST_SUITE_P(LexerTest,
|
INSTANTIATE_TEST_SUITE_P(LexerTest,
|
||||||
FloatTest_Invalid,
|
FloatTest_Invalid,
|
||||||
testing::Values(".",
|
testing::Values(".",
|
||||||
"-.",
|
|
||||||
// Need a mantissa digit
|
// Need a mantissa digit
|
||||||
".e5",
|
".e5",
|
||||||
".E5",
|
".E5",
|
||||||
|
@ -545,9 +522,7 @@ INSTANTIATE_TEST_SUITE_P(LexerTest,
|
||||||
".e-",
|
".e-",
|
||||||
// Overflow
|
// Overflow
|
||||||
"2.5e+256f",
|
"2.5e+256f",
|
||||||
"-2.5e+127f",
|
|
||||||
"6.5520e+4h",
|
"6.5520e+4h",
|
||||||
"-6.5e+12h",
|
|
||||||
// Decimal exponent must immediately
|
// Decimal exponent must immediately
|
||||||
// follow the 'e'.
|
// follow the 'e'.
|
||||||
"2.5e 12",
|
"2.5e 12",
|
||||||
|
@ -791,12 +766,9 @@ INSTANTIATE_TEST_SUITE_P(Dec_AInt,
|
||||||
testing::Combine(testing::Values('\0'), // No suffix
|
testing::Combine(testing::Values('\0'), // No suffix
|
||||||
testing::ValuesIn(std::vector<ParseIntegerCase>{
|
testing::ValuesIn(std::vector<ParseIntegerCase>{
|
||||||
{"0", 0},
|
{"0", 0},
|
||||||
{"-2", -2},
|
|
||||||
{"2", 2},
|
{"2", 2},
|
||||||
{"123", 123},
|
{"123", 123},
|
||||||
{"2147483647", 2147483647},
|
{"2147483647", 2147483647},
|
||||||
{"-2147483648", -2147483648LL},
|
|
||||||
{"-9223372036854775808", -9223372036854775807LL - 1},
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Dec_u32,
|
INSTANTIATE_TEST_SUITE_P(Dec_u32,
|
||||||
|
@ -813,11 +785,8 @@ INSTANTIATE_TEST_SUITE_P(Dec_i32,
|
||||||
testing::Combine(testing::Values('i'), // Suffix
|
testing::Combine(testing::Values('i'), // Suffix
|
||||||
testing::ValuesIn(std::vector<ParseIntegerCase>{
|
testing::ValuesIn(std::vector<ParseIntegerCase>{
|
||||||
{"0i", 0u},
|
{"0i", 0u},
|
||||||
{"-0i", 0u},
|
|
||||||
{"123i", 123},
|
{"123i", 123},
|
||||||
{"-123i", -123},
|
|
||||||
{"2147483647i", 2147483647},
|
{"2147483647i", 2147483647},
|
||||||
{"-2147483647i", -2147483647ll},
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Hex_AInt,
|
INSTANTIATE_TEST_SUITE_P(Hex_AInt,
|
||||||
|
@ -828,16 +797,10 @@ INSTANTIATE_TEST_SUITE_P(Hex_AInt,
|
||||||
{"0X0", 0},
|
{"0X0", 0},
|
||||||
{"0x42", 66},
|
{"0x42", 66},
|
||||||
{"0X42", 66},
|
{"0X42", 66},
|
||||||
{"-0x42", -66},
|
|
||||||
{"-0X42", -66},
|
|
||||||
{"0xeF1Abc9", 0xeF1Abc9},
|
{"0xeF1Abc9", 0xeF1Abc9},
|
||||||
{"0XeF1Abc9", 0xeF1Abc9},
|
{"0XeF1Abc9", 0xeF1Abc9},
|
||||||
{"-0xeF1Abc9", -0xeF1Abc9},
|
|
||||||
{"-0XeF1Abc9", -0xeF1Abc9},
|
|
||||||
{"0x80000000", 0x80000000},
|
{"0x80000000", 0x80000000},
|
||||||
{"0X80000000", 0X80000000},
|
{"0X80000000", 0X80000000},
|
||||||
{"-0x80000000", -0x80000000ll},
|
|
||||||
{"-0X80000000", -0X80000000ll},
|
|
||||||
{"0x7FFFFFFF", 0x7fffffff},
|
{"0x7FFFFFFF", 0x7fffffff},
|
||||||
{"0X7FFFFFFF", 0x7fffffff},
|
{"0X7FFFFFFF", 0x7fffffff},
|
||||||
{"0x7fffffff", 0x7fffffff},
|
{"0x7fffffff", 0x7fffffff},
|
||||||
|
@ -845,7 +808,6 @@ INSTANTIATE_TEST_SUITE_P(Hex_AInt,
|
||||||
{"0x7FfFfFfF", 0x7fffffff},
|
{"0x7FfFfFfF", 0x7fffffff},
|
||||||
{"0X7FfFfFfF", 0x7fffffff},
|
{"0X7FfFfFfF", 0x7fffffff},
|
||||||
{"0x7fffffffffffffff", 0x7fffffffffffffffll},
|
{"0x7fffffffffffffff", 0x7fffffffffffffffll},
|
||||||
{"-0x7fffffffffffffff", -0x7fffffffffffffffll},
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Hex_u32,
|
INSTANTIATE_TEST_SUITE_P(Hex_u32,
|
||||||
|
@ -869,22 +831,13 @@ INSTANTIATE_TEST_SUITE_P(Hex_i32,
|
||||||
testing::ValuesIn(std::vector<ParseIntegerCase>{
|
testing::ValuesIn(std::vector<ParseIntegerCase>{
|
||||||
{"0x0i", 0},
|
{"0x0i", 0},
|
||||||
{"0x42i", 66},
|
{"0x42i", 66},
|
||||||
{"-0x0i", 0},
|
|
||||||
{"-0x42i", -66},
|
|
||||||
{"0xeF1Abc9i", 250719177},
|
{"0xeF1Abc9i", 250719177},
|
||||||
{"-0xeF1Abc9i", -250719177},
|
|
||||||
{"0x7FFFFFFFi", 0x7fffffff},
|
{"0x7FFFFFFFi", 0x7fffffff},
|
||||||
{"-0x7FFFFFFFi", -0x7fffffff},
|
|
||||||
{"0X7FFFFFFFi", 0x7fffffff},
|
{"0X7FFFFFFFi", 0x7fffffff},
|
||||||
{"-0X7FFFFFFFi", -0x7fffffff},
|
|
||||||
{"0x7fffffffi", 0x7fffffff},
|
{"0x7fffffffi", 0x7fffffff},
|
||||||
{"-0x7fffffffi", -0x7fffffff},
|
|
||||||
{"0X7fffffffi", 0x7fffffff},
|
{"0X7fffffffi", 0x7fffffff},
|
||||||
{"-0X7fffffffi", -0x7fffffff},
|
|
||||||
{"0x7FfFfFfFi", 0x7fffffff},
|
{"0x7FfFfFfFi", 0x7fffffff},
|
||||||
{"-0x7FfFfFfFi", -0x7fffffff},
|
|
||||||
{"0X7FfFfFfFi", 0x7fffffff},
|
{"0X7FfFfFfFi", 0x7fffffff},
|
||||||
{"-0X7FfFfFfFi", -0x7fffffff},
|
|
||||||
})));
|
})));
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ParseIntegerTest_CannotBeRepresented
|
// ParseIntegerTest_CannotBeRepresented
|
||||||
|
@ -921,8 +874,7 @@ INSTANTIATE_TEST_SUITE_P(i32,
|
||||||
INSTANTIATE_TEST_SUITE_P(u32,
|
INSTANTIATE_TEST_SUITE_P(u32,
|
||||||
ParseIntegerTest_CannotBeRepresented,
|
ParseIntegerTest_CannotBeRepresented,
|
||||||
testing::Combine(testing::Values("u32"), // type
|
testing::Combine(testing::Values("u32"), // type
|
||||||
testing::Values("4294967296u", //
|
testing::Values("4294967296u")));
|
||||||
"-1u")));
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ParseIntegerTest_LeadingZeros
|
// ParseIntegerTest_LeadingZeros
|
||||||
|
@ -942,7 +894,7 @@ TEST_P(ParseIntegerTest_LeadingZeros, Parse) {
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(LeadingZero,
|
INSTANTIATE_TEST_SUITE_P(LeadingZero,
|
||||||
ParseIntegerTest_LeadingZeros,
|
ParseIntegerTest_LeadingZeros,
|
||||||
testing::Values("01234", "0000", "-00", "00u"));
|
testing::Values("01234", "0000", "00u"));
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ParseIntegerTest_NoSignificantDigits
|
// ParseIntegerTest_NoSignificantDigits
|
||||||
|
@ -962,18 +914,7 @@ TEST_P(ParseIntegerTest_NoSignificantDigits, Parse) {
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(LeadingZero,
|
INSTANTIATE_TEST_SUITE_P(LeadingZero,
|
||||||
ParseIntegerTest_NoSignificantDigits,
|
ParseIntegerTest_NoSignificantDigits,
|
||||||
testing::Values("0x",
|
testing::Values("0x", "0X", "0xu", "0Xu", "0xi", "0Xi"));
|
||||||
"0X",
|
|
||||||
"-0x",
|
|
||||||
"-0X",
|
|
||||||
"0xu",
|
|
||||||
"0Xu",
|
|
||||||
"-0xu",
|
|
||||||
"-0Xu",
|
|
||||||
"0xi",
|
|
||||||
"0Xi",
|
|
||||||
"-0xi",
|
|
||||||
"-0Xi"));
|
|
||||||
|
|
||||||
struct TokenData {
|
struct TokenData {
|
||||||
const char* input;
|
const char* input;
|
||||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(ParserImplTest, ArgumentExpressionList_ParsesEmptyList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, ArgumentExpressionList_ParsesMultiple) {
|
TEST_F(ParserImplTest, ArgumentExpressionList_ParsesMultiple) {
|
||||||
auto p = parser("(a, -33, 1+2)");
|
auto p = parser("(a, 33, 1+2)");
|
||||||
auto e = p->expect_argument_expression_list("argument list");
|
auto e = p->expect_argument_expression_list("argument list");
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
ASSERT_FALSE(e.errored);
|
ASSERT_FALSE(e.errored);
|
||||||
|
|
|
@ -67,32 +67,6 @@ TEST_F(ParserImplTest, ConstLiteral_Int) {
|
||||||
ast::IntLiteralExpression::Suffix::kI);
|
ast::IntLiteralExpression::Suffix::kI);
|
||||||
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 5u}}));
|
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 5u}}));
|
||||||
}
|
}
|
||||||
{
|
|
||||||
auto p = parser("-234");
|
|
||||||
auto c = p->const_literal();
|
|
||||||
EXPECT_TRUE(c.matched);
|
|
||||||
EXPECT_FALSE(c.errored);
|
|
||||||
EXPECT_FALSE(p->has_error()) << p->error();
|
|
||||||
ASSERT_NE(c.value, nullptr);
|
|
||||||
ASSERT_TRUE(c->Is<ast::IntLiteralExpression>());
|
|
||||||
EXPECT_EQ(c->As<ast::IntLiteralExpression>()->value, -234);
|
|
||||||
EXPECT_EQ(c->As<ast::IntLiteralExpression>()->suffix,
|
|
||||||
ast::IntLiteralExpression::Suffix::kNone);
|
|
||||||
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 5u}}));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
auto p = parser("-234i");
|
|
||||||
auto c = p->const_literal();
|
|
||||||
EXPECT_TRUE(c.matched);
|
|
||||||
EXPECT_FALSE(c.errored);
|
|
||||||
EXPECT_FALSE(p->has_error()) << p->error();
|
|
||||||
ASSERT_NE(c.value, nullptr);
|
|
||||||
ASSERT_TRUE(c->Is<ast::IntLiteralExpression>());
|
|
||||||
EXPECT_EQ(c->As<ast::IntLiteralExpression>()->value, -234);
|
|
||||||
EXPECT_EQ(c->As<ast::IntLiteralExpression>()->suffix,
|
|
||||||
ast::IntLiteralExpression::Suffix::kI);
|
|
||||||
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 6u}}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, ConstLiteral_Uint) {
|
TEST_F(ParserImplTest, ConstLiteral_Uint) {
|
||||||
|
@ -108,15 +82,6 @@ TEST_F(ParserImplTest, ConstLiteral_Uint) {
|
||||||
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 5u}}));
|
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 5u}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, ConstLiteral_Uint_Negative) {
|
|
||||||
auto p = parser("-234u");
|
|
||||||
auto c = p->const_literal();
|
|
||||||
EXPECT_FALSE(c.matched);
|
|
||||||
EXPECT_TRUE(c.errored);
|
|
||||||
EXPECT_EQ(p->error(), "1:1: value cannot be represented as 'u32'");
|
|
||||||
ASSERT_EQ(c.value, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ParserImplTest, ConstLiteral_InvalidFloat_IncompleteExponent) {
|
TEST_F(ParserImplTest, ConstLiteral_InvalidFloat_IncompleteExponent) {
|
||||||
auto p = parser("1.0e+");
|
auto p = parser("1.0e+");
|
||||||
auto c = p->const_literal();
|
auto c = p->const_literal();
|
||||||
|
@ -176,13 +141,9 @@ INSTANTIATE_TEST_SUITE_P(ParserImplFloatLiteralTest_Float,
|
||||||
testing::ValuesIn(FloatLiteralTestCaseList{
|
testing::ValuesIn(FloatLiteralTestCaseList{
|
||||||
{"0.0", 0.0}, // Zero
|
{"0.0", 0.0}, // Zero
|
||||||
{"1.0", 1.0}, // One
|
{"1.0", 1.0}, // One
|
||||||
{"-1.0", -1.0}, // MinusOne
|
|
||||||
{"1000000000.0", 1e9}, // Billion
|
{"1000000000.0", 1e9}, // Billion
|
||||||
{"-0.0", std::copysign(0.0, -5.0)}, // NegativeZero
|
|
||||||
{"0.0", MakeDouble(0, 0, 0)}, // Zero
|
{"0.0", MakeDouble(0, 0, 0)}, // Zero
|
||||||
{"-0.0", MakeDouble(1, 0, 0)}, // NegativeZero
|
|
||||||
{"1.0", MakeDouble(0, 1023, 0)}, // One
|
{"1.0", MakeDouble(0, 1023, 0)}, // One
|
||||||
{"-1.0", MakeDouble(1, 1023, 0)}, // NegativeOne
|
|
||||||
|
|
||||||
{"234.e12", 234.e12},
|
{"234.e12", 234.e12},
|
||||||
{"234.e12f", static_cast<double>(234.e12f)},
|
{"234.e12f", static_cast<double>(234.e12f)},
|
||||||
|
@ -190,47 +151,29 @@ INSTANTIATE_TEST_SUITE_P(ParserImplFloatLiteralTest_Float,
|
||||||
|
|
||||||
// Tiny cases
|
// Tiny cases
|
||||||
{"1e-5000", 0.0},
|
{"1e-5000", 0.0},
|
||||||
{"-1e-5000", 0.0},
|
|
||||||
{"1e-5000f", 0.0},
|
{"1e-5000f", 0.0},
|
||||||
{"-1e-5000f", 0.0},
|
|
||||||
{"1e-50f", 0.0},
|
{"1e-50f", 0.0},
|
||||||
{"-1e-50f", 0.0},
|
|
||||||
{"1e-5000h", 0.0},
|
{"1e-5000h", 0.0},
|
||||||
{"-1e-5000h", 0.0},
|
|
||||||
{"1e-50h", 0.0},
|
{"1e-50h", 0.0},
|
||||||
{"-1e-50h", 0.0},
|
|
||||||
{"1e-8h", 0.0}, // The smallest positive subnormal f16 is 5.96e-8
|
{"1e-8h", 0.0}, // The smallest positive subnormal f16 is 5.96e-8
|
||||||
{"-1e-8h", 0.0},
|
|
||||||
|
|
||||||
// Nearly overflow
|
// Nearly overflow
|
||||||
{"1.e308", 1.e308},
|
{"1.e308", 1.e308},
|
||||||
{"-1.e308", -1.e308},
|
|
||||||
{"1.8e307", 1.8e307},
|
{"1.8e307", 1.8e307},
|
||||||
{"-1.8e307", -1.8e307},
|
|
||||||
{"1.798e307", 1.798e307},
|
{"1.798e307", 1.798e307},
|
||||||
{"-1.798e307", -1.798e307},
|
|
||||||
{"1.7977e307", 1.7977e307},
|
{"1.7977e307", 1.7977e307},
|
||||||
{"-1.7977e307", -1.7977e307},
|
|
||||||
|
|
||||||
// Nearly overflow
|
// Nearly overflow
|
||||||
{"1e38f", static_cast<double>(1e38f)},
|
{"1e38f", static_cast<double>(1e38f)},
|
||||||
{"-1e38f", static_cast<double>(-1e38f)},
|
|
||||||
{"4.0e37f", static_cast<double>(4.0e37f)},
|
{"4.0e37f", static_cast<double>(4.0e37f)},
|
||||||
{"-4.0e37f", static_cast<double>(-4.0e37f)},
|
|
||||||
{"3.5e37f", static_cast<double>(3.5e37f)},
|
{"3.5e37f", static_cast<double>(3.5e37f)},
|
||||||
{"-3.5e37f", static_cast<double>(-3.5e37f)},
|
|
||||||
{"3.403e37f", static_cast<double>(3.403e37f)},
|
{"3.403e37f", static_cast<double>(3.403e37f)},
|
||||||
{"-3.403e37f", static_cast<double>(-3.403e37f)},
|
|
||||||
|
|
||||||
// Nearly overflow
|
// Nearly overflow
|
||||||
{"6e4h", 6e4},
|
{"6e4h", 6e4},
|
||||||
{"-6e4h", -6e4},
|
|
||||||
{"8.0e3h", 8.0e3},
|
{"8.0e3h", 8.0e3},
|
||||||
{"-8.0e3h", -8.0e3},
|
|
||||||
{"3.5e3h", 3.5e3},
|
{"3.5e3h", 3.5e3},
|
||||||
{"-3.5e3h", -3.5e3},
|
|
||||||
{"3.403e3h", 3.402e3}, // Quantized
|
{"3.403e3h", 3.402e3}, // Quantized
|
||||||
{"-3.403e3h", -3.402e3}, // Quantized
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const double NegInf = MakeDouble(1, 0x7FF, 0);
|
const double NegInf = MakeDouble(1, 0x7FF, 0);
|
||||||
|
@ -246,11 +189,6 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x1p-1", 0x1p-1},
|
{"0x1p-1", 0x1p-1},
|
||||||
{"0x1p-2", 0x1p-2},
|
{"0x1p-2", 0x1p-2},
|
||||||
{"0x1.8p-1", 0x1.8p-1},
|
{"0x1.8p-1", 0x1.8p-1},
|
||||||
{"-0x0p+0", -0x0p+0},
|
|
||||||
{"-0x1p+0", -0x1p+0},
|
|
||||||
{"-0x1p-1", -0x1p-1},
|
|
||||||
{"-0x1p-2", -0x1p-2},
|
|
||||||
{"-0x1.8p-1", -0x1.8p-1},
|
|
||||||
{"0x0.4p+1", 0x0.4p+1},
|
{"0x0.4p+1", 0x0.4p+1},
|
||||||
{"0x0.02p+3", 0x0.02p+3},
|
{"0x0.02p+3", 0x0.02p+3},
|
||||||
{"0x4.4p+1", 0x4.4p+1},
|
{"0x4.4p+1", 0x4.4p+1},
|
||||||
|
@ -260,43 +198,28 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x1p+9", 0x1p+9},
|
{"0x1p+9", 0x1p+9},
|
||||||
{"0x1p+10", 0x1p+10},
|
{"0x1p+10", 0x1p+10},
|
||||||
{"0x1.02p+10", 0x1.02p+10},
|
{"0x1.02p+10", 0x1.02p+10},
|
||||||
{"-0x1p+9", -0x1p+9},
|
|
||||||
{"-0x1p+10", -0x1p+10},
|
|
||||||
{"-0x1.02p+10", -0x1.02p+10},
|
|
||||||
|
|
||||||
// Small numbers
|
// Small numbers
|
||||||
{"0x1p-9", 0x1p-9},
|
{"0x1p-9", 0x1p-9},
|
||||||
{"0x1p-10", 0x1p-10},
|
{"0x1p-10", 0x1p-10},
|
||||||
{"0x1.02p-3", 0x1.02p-3},
|
{"0x1.02p-3", 0x1.02p-3},
|
||||||
{"-0x1p-9", -0x1p-9},
|
|
||||||
{"-0x1p-10", -0x1p-10},
|
|
||||||
{"-0x1.02p-3", -0x1.02p-3},
|
|
||||||
|
|
||||||
// Near lowest non-denorm
|
// Near lowest non-denorm
|
||||||
{"0x1p-1020", 0x1p-1020},
|
{"0x1p-1020", 0x1p-1020},
|
||||||
{"0x1p-1021", 0x1p-1021},
|
{"0x1p-1021", 0x1p-1021},
|
||||||
{"-0x1p-1020", -0x1p-1020},
|
|
||||||
{"-0x1p-1021", -0x1p-1021},
|
|
||||||
|
|
||||||
{"0x1p-124f", 0x1p-124},
|
{"0x1p-124f", 0x1p-124},
|
||||||
{"0x1p-125f", 0x1p-125},
|
{"0x1p-125f", 0x1p-125},
|
||||||
{"-0x1p-124f", -0x1p-124},
|
|
||||||
{"-0x1p-125f", -0x1p-125},
|
|
||||||
|
|
||||||
{"0x1p-12h", 0x1p-12},
|
{"0x1p-12h", 0x1p-12},
|
||||||
{"0x1p-13h", 0x1p-13},
|
{"0x1p-13h", 0x1p-13},
|
||||||
{"-0x1p-12h", -0x1p-12},
|
|
||||||
{"-0x1p-13h", -0x1p-13},
|
|
||||||
|
|
||||||
// Lowest non-denorm
|
// Lowest non-denorm
|
||||||
{"0x1p-1022", 0x1p-1022},
|
{"0x1p-1022", 0x1p-1022},
|
||||||
{"-0x1p-1022", -0x1p-1022},
|
|
||||||
|
|
||||||
{"0x1p-126f", 0x1p-126},
|
{"0x1p-126f", 0x1p-126},
|
||||||
{"-0x1p-126f", -0x1p-126},
|
|
||||||
|
|
||||||
{"0x1p-14h", 0x1p-14},
|
{"0x1p-14h", 0x1p-14},
|
||||||
{"-0x1p-14h", -0x1p-14},
|
|
||||||
|
|
||||||
// Denormalized values
|
// Denormalized values
|
||||||
{"0x1p-1023", 0x1p-1023},
|
{"0x1p-1023", 0x1p-1023},
|
||||||
|
@ -305,10 +228,6 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x0.2p-1021", 0x0.2p-1021},
|
{"0x0.2p-1021", 0x0.2p-1021},
|
||||||
{"0x1p-1025", 0x1p-1025},
|
{"0x1p-1025", 0x1p-1025},
|
||||||
{"0x1p-1026", 0x1p-1026},
|
{"0x1p-1026", 0x1p-1026},
|
||||||
{"-0x1p-1023", -0x1p-1023},
|
|
||||||
{"-0x1p-1024", -0x1p-1024},
|
|
||||||
{"-0x1p-1025", -0x1p-1025},
|
|
||||||
{"-0x1p-1026", -0x1p-1026},
|
|
||||||
{"0x1.8p-1023", 0x1.8p-1023},
|
{"0x1.8p-1023", 0x1.8p-1023},
|
||||||
{"0x1.8p-1024", 0x1.8p-1024},
|
{"0x1.8p-1024", 0x1.8p-1024},
|
||||||
|
|
||||||
|
@ -318,10 +237,6 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x0.2p-125f", 0x0.2p-125},
|
{"0x0.2p-125f", 0x0.2p-125},
|
||||||
{"0x1p-129f", 0x1p-129},
|
{"0x1p-129f", 0x1p-129},
|
||||||
{"0x1p-130f", 0x1p-130},
|
{"0x1p-130f", 0x1p-130},
|
||||||
{"-0x1p-127f", -0x1p-127},
|
|
||||||
{"-0x1p-128f", -0x1p-128},
|
|
||||||
{"-0x1p-129f", -0x1p-129},
|
|
||||||
{"-0x1p-130f", -0x1p-130},
|
|
||||||
{"0x1.8p-127f", 0x1.8p-127},
|
{"0x1.8p-127f", 0x1.8p-127},
|
||||||
{"0x1.8p-128f", 0x1.8p-128},
|
{"0x1.8p-128f", 0x1.8p-128},
|
||||||
|
|
||||||
|
@ -331,10 +246,6 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x0.2p-13h", 0x0.2p-13},
|
{"0x0.2p-13h", 0x0.2p-13},
|
||||||
{"0x1p-17h", 0x1p-17},
|
{"0x1p-17h", 0x1p-17},
|
||||||
{"0x1p-18h", 0x1p-18},
|
{"0x1p-18h", 0x1p-18},
|
||||||
{"-0x1p-15h", -0x1p-15},
|
|
||||||
{"-0x1p-16h", -0x1p-16},
|
|
||||||
{"-0x1p-17h", -0x1p-17},
|
|
||||||
{"-0x1p-18h", -0x1p-18},
|
|
||||||
{"0x1.8p-15h", 0x1.8p-15},
|
{"0x1.8p-15h", 0x1.8p-15},
|
||||||
{"0x1.8p-16h", 0x1.8p-16},
|
{"0x1.8p-16h", 0x1.8p-16},
|
||||||
|
|
||||||
|
@ -343,19 +254,11 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x1p-1073", 0x1p-1073}, // +BiggerDenormal
|
{"0x1p-1073", 0x1p-1073}, // +BiggerDenormal
|
||||||
{"0x1.ffffffffffffep-1023", 0x1.ffffffffffffep-1023}, // +LargestDenormal
|
{"0x1.ffffffffffffep-1023", 0x1.ffffffffffffep-1023}, // +LargestDenormal
|
||||||
{"0x0.fffffffffffffp-1022", 0x0.fffffffffffffp-1022}, // +LargestDenormal
|
{"0x0.fffffffffffffp-1022", 0x0.fffffffffffffp-1022}, // +LargestDenormal
|
||||||
{"-0x1p-1074", -0x1p-1074}, // -SmallestDenormal
|
|
||||||
{"-0x1p-1073", -0x1p-1073}, // -BiggerDenormal
|
|
||||||
{"-0x1.ffffffffffffep-1023", -0x1.ffffffffffffep-1023}, // -LargestDenormal
|
|
||||||
{"-0x0.fffffffffffffp-1022", -0x0.fffffffffffffp-1022}, // -LargestDenormal
|
|
||||||
|
|
||||||
{"0x0.cafebeeff000dp-1022", 0x0.cafebeeff000dp-1022}, // +Subnormal
|
{"0x0.cafebeeff000dp-1022", 0x0.cafebeeff000dp-1022}, // +Subnormal
|
||||||
{"-0x0.cafebeeff000dp-1022", -0x0.cafebeeff000dp-1022}, // -Subnormal
|
|
||||||
{"0x1.2bfaf8p-1052", 0x1.2bfaf8p-1052}, // +Subnormal
|
{"0x1.2bfaf8p-1052", 0x1.2bfaf8p-1052}, // +Subnormal
|
||||||
{"-0x1.2bfaf8p-1052", -0x1.2bfaf8p-1052}, // +Subnormal
|
|
||||||
{"0x1.55554p-1055", 0x1.55554p-1055}, // +Subnormal
|
{"0x1.55554p-1055", 0x1.55554p-1055}, // +Subnormal
|
||||||
{"-0x1.55554p-1055", -0x1.55554p-1055}, // -Subnormal
|
|
||||||
{"0x1.fffffffffffp-1027", 0x1.fffffffffffp-1027}, // +Subnormal, = 0x0.0fffffffffff8p-1022
|
{"0x1.fffffffffffp-1027", 0x1.fffffffffffp-1027}, // +Subnormal, = 0x0.0fffffffffff8p-1022
|
||||||
{"-0x1.fffffffffffp-1027", -0x1.fffffffffffp-1027}, // -Subnormal
|
|
||||||
|
|
||||||
// F32 extremities
|
// F32 extremities
|
||||||
{"0x1p-149f", 0x1p-149}, // +SmallestDenormal
|
{"0x1p-149f", 0x1p-149}, // +SmallestDenormal
|
||||||
|
@ -364,19 +267,10 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x0.fffffep-126f", 0x0.fffffep-126}, // +LargestDenormal
|
{"0x0.fffffep-126f", 0x0.fffffep-126}, // +LargestDenormal
|
||||||
{"0x1.0p-126f", 0x1.0p-126}, // +SmallestNormal
|
{"0x1.0p-126f", 0x1.0p-126}, // +SmallestNormal
|
||||||
{"0x8.0p-129f", 0x8.0p-129}, // +SmallestNormal
|
{"0x8.0p-129f", 0x8.0p-129}, // +SmallestNormal
|
||||||
{"-0x1p-149f", -0x1p-149}, // -SmallestDenormal
|
|
||||||
{"-0x1p-148f", -0x1p-148}, // -BiggerDenormal
|
|
||||||
{"-0x1.fffffcp-127f", -0x1.fffffcp-127}, // -LargestDenormal
|
|
||||||
{"-0x0.fffffep-126f", -0x0.fffffep-126}, // -LargestDenormal
|
|
||||||
{"-0x1.0p-126f", -0x1.0p-126}, // -SmallestNormal
|
|
||||||
{"-0x8.0p-129f", -0x8.0p-129}, // -SmallestNormal
|
|
||||||
|
|
||||||
{"0x0.cafebp-129f", 0x0.cafebp-129}, // +Subnormal
|
{"0x0.cafebp-129f", 0x0.cafebp-129}, // +Subnormal
|
||||||
{"-0x0.cafebp-129f", -0x0.cafebp-129}, // -Subnormal
|
|
||||||
{"0x1.2bfaf8p-127f", 0x1.2bfaf8p-127}, // +Subnormal
|
{"0x1.2bfaf8p-127f", 0x1.2bfaf8p-127}, // +Subnormal
|
||||||
{"-0x1.2bfaf8p-127f", -0x1.2bfaf8p-127}, // -Subnormal
|
|
||||||
{"0x1.55554p-130f", 0x1.55554p-130}, // +Subnormal
|
{"0x1.55554p-130f", 0x1.55554p-130}, // +Subnormal
|
||||||
{"-0x1.55554p-130f", -0x1.55554p-130}, // -Subnormal
|
|
||||||
|
|
||||||
// F32 exactly representable
|
// F32 exactly representable
|
||||||
{"0x1.000002p+0f", 0x1.000002p+0},
|
{"0x1.000002p+0f", 0x1.000002p+0},
|
||||||
|
@ -386,9 +280,7 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x2.123p+0f", 0x2.123p+0},
|
{"0x2.123p+0f", 0x2.123p+0},
|
||||||
{"0x2.cafefp+0f", 0x2.cafefp+0},
|
{"0x2.cafefp+0f", 0x2.cafefp+0},
|
||||||
{"0x0.0000fep-126f", 0x0.0000fep-126}, // Subnormal
|
{"0x0.0000fep-126f", 0x0.0000fep-126}, // Subnormal
|
||||||
{"-0x0.0000fep-126f", -0x0.0000fep-126}, // Subnormal
|
|
||||||
{"0x3.f8p-144f", 0x3.f8p-144}, // Subnormal
|
{"0x3.f8p-144f", 0x3.f8p-144}, // Subnormal
|
||||||
{"-0x3.f8p-144f", -0x3.f8p-144}, // Subnormal
|
|
||||||
|
|
||||||
// F16 extremities
|
// F16 extremities
|
||||||
{"0x1p-24h", 0x1p-24}, // +SmallestDenormal
|
{"0x1p-24h", 0x1p-24}, // +SmallestDenormal
|
||||||
|
@ -397,19 +289,10 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x0.ffcp-14h", 0x0.ffcp-14}, // +LargestDenormal
|
{"0x0.ffcp-14h", 0x0.ffcp-14}, // +LargestDenormal
|
||||||
{"0x1.0p-14h", 0x1.0p-14}, // +SmallestNormal
|
{"0x1.0p-14h", 0x1.0p-14}, // +SmallestNormal
|
||||||
{"0x8.0p-17h", 0x8.0p-17}, // +SmallestNormal
|
{"0x8.0p-17h", 0x8.0p-17}, // +SmallestNormal
|
||||||
{"-0x1p-24h", -0x1p-24}, // -SmallestDenormal
|
|
||||||
{"-0x1p-23h", -0x1p-23}, // -BiggerDenormal
|
|
||||||
{"-0x1.ff8p-15h", -0x1.ff8p-15}, // -LargestDenormal
|
|
||||||
{"-0x0.ffcp-14h", -0x0.ffcp-14}, // -LargestDenormal
|
|
||||||
{"-0x1.0p-14h", -0x1.0p-14}, // -SmallestNormal
|
|
||||||
{"-0x8.0p-17h", -0x8.0p-17}, // -SmallestNormal
|
|
||||||
|
|
||||||
{"0x0.a8p-19h", 0x0.a8p-19}, // +Subnormal
|
{"0x0.a8p-19h", 0x0.a8p-19}, // +Subnormal
|
||||||
{"-0x0.a8p-19h", -0x0.a8p-19}, // -Subnormal
|
|
||||||
{"0x1.7ap-17h", 0x1.7ap-17}, // +Subnormal
|
{"0x1.7ap-17h", 0x1.7ap-17}, // +Subnormal
|
||||||
{"-0x1.7ap-17h", -0x1.7ap-17}, // -Subnormal
|
|
||||||
{"0x1.dp-20h", 0x1.dp-20}, // +Subnormal
|
{"0x1.dp-20h", 0x1.dp-20}, // +Subnormal
|
||||||
{"-0x1.dp-20h", -0x1.dp-20}, // -Subnormal
|
|
||||||
|
|
||||||
// F16 exactly representable
|
// F16 exactly representable
|
||||||
{"0x1.004p+0h", 0x1.004p+0},
|
{"0x1.004p+0h", 0x1.004p+0},
|
||||||
|
@ -419,19 +302,13 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x2.128p+0h", 0x2.128p+0},
|
{"0x2.128p+0h", 0x2.128p+0},
|
||||||
{"0x2.ca8p+0h", 0x2.ca8p+0},
|
{"0x2.ca8p+0h", 0x2.ca8p+0},
|
||||||
{"0x0.0fcp-14h", 0x0.0fcp-14}, // Subnormal
|
{"0x0.0fcp-14h", 0x0.0fcp-14}, // Subnormal
|
||||||
{"-0x0.0fcp-14h", -0x0.0fcp-14}, // Subnormal
|
|
||||||
{"0x3.f00p-20h", 0x3.f00p-20}, // Subnormal
|
{"0x3.f00p-20h", 0x3.f00p-20}, // Subnormal
|
||||||
{"-0x3.f00p-20h", -0x3.f00p-20}, // Subnormal
|
|
||||||
|
|
||||||
// Underflow -> Zero
|
// Underflow -> Zero
|
||||||
{"0x1p-1075", 0.0}, // Exponent underflows
|
{"0x1p-1075", 0.0}, // Exponent underflows
|
||||||
{"-0x1p-1075", 0.0},
|
|
||||||
{"0x1p-5000", 0.0},
|
{"0x1p-5000", 0.0},
|
||||||
{"-0x1p-5000", 0.0},
|
|
||||||
{"0x0.00000000000000000000001p-1022", 0.0}, // Fraction causes underflow
|
{"0x0.00000000000000000000001p-1022", 0.0}, // Fraction causes underflow
|
||||||
{"-0x0.0000000000000000000001p-1023", -0.0},
|
|
||||||
{"0x0.01p-1073", -0.0},
|
{"0x0.01p-1073", -0.0},
|
||||||
{"-0x0.01p-1073", -0.0}, // Fraction causes additional underflow
|
|
||||||
|
|
||||||
{"0x1.0p-9223372036854774784", 0}, // -(INT64_MAX - 1023) (smallest valid exponent)
|
{"0x1.0p-9223372036854774784", 0}, // -(INT64_MAX - 1023) (smallest valid exponent)
|
||||||
|
|
||||||
|
@ -445,20 +322,12 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
// if the mantissa were non-zero.
|
// if the mantissa were non-zero.
|
||||||
{"0x0p+10000000000000000000", 0.0}, // 10 quintillion (10,000,000,000,000,000,000)
|
{"0x0p+10000000000000000000", 0.0}, // 10 quintillion (10,000,000,000,000,000,000)
|
||||||
{"0x0p+100000000000000000000", 0.0}, // 100 quintillion (100,000,000,000,000,000,000)
|
{"0x0p+100000000000000000000", 0.0}, // 100 quintillion (100,000,000,000,000,000,000)
|
||||||
{"-0x0p+100000000000000000000", 0.0}, // As above 2, but negative mantissa
|
|
||||||
{"-0x0p+1000000000000000000000", 0.0},
|
|
||||||
{"0x0.00p+10000000000000000000", 0.0}, // As above 4, but with fractional part
|
{"0x0.00p+10000000000000000000", 0.0}, // As above 4, but with fractional part
|
||||||
{"0x0.00p+100000000000000000000", 0.0},
|
{"0x0.00p+100000000000000000000", 0.0},
|
||||||
{"-0x0.00p+100000000000000000000", 0.0},
|
|
||||||
{"-0x0.00p+1000000000000000000000", 0.0},
|
|
||||||
{"0x0p-10000000000000000000", 0.0}, // As above 8, but with negative exponents
|
{"0x0p-10000000000000000000", 0.0}, // As above 8, but with negative exponents
|
||||||
{"0x0p-100000000000000000000", 0.0},
|
{"0x0p-100000000000000000000", 0.0},
|
||||||
{"-0x0p-100000000000000000000", 0.0},
|
|
||||||
{"-0x0p-1000000000000000000000", 0.0},
|
|
||||||
{"0x0.00p-10000000000000000000", 0.0},
|
{"0x0.00p-10000000000000000000", 0.0},
|
||||||
{"0x0.00p-100000000000000000000", 0.0},
|
{"0x0.00p-100000000000000000000", 0.0},
|
||||||
{"-0x0.00p-100000000000000000000", 0.0},
|
|
||||||
{"-0x0.00p-1000000000000000000000", 0.0},
|
|
||||||
|
|
||||||
// Test parsing
|
// Test parsing
|
||||||
{"0x0p0", 0.0},
|
{"0x0p0", 0.0},
|
||||||
|
@ -476,37 +345,24 @@ FloatLiteralTestCaseList HexFloatCases() {
|
||||||
{"0x0.4p+1", 2 * 0.25},
|
{"0x0.4p+1", 2 * 0.25},
|
||||||
{"0x0.4p+2", 4 * 0.25},
|
{"0x0.4p+2", 4 * 0.25},
|
||||||
{"0x123Ep+1", 9340.0},
|
{"0x123Ep+1", 9340.0},
|
||||||
{"-0x123Ep+1", -9340.0},
|
|
||||||
{"0x1a2b3cP12", 7.024656384e+09},
|
{"0x1a2b3cP12", 7.024656384e+09},
|
||||||
{"-0x1a2b3cP12", -7.024656384e+09},
|
|
||||||
|
|
||||||
// Examples without a binary exponent part.
|
// Examples without a binary exponent part.
|
||||||
{"0x1.", 1.0},
|
{"0x1.", 1.0},
|
||||||
{"0x.8", 0.5},
|
{"0x.8", 0.5},
|
||||||
{"0x1.8", 1.5},
|
{"0x1.8", 1.5},
|
||||||
{"-0x1.", -1.0},
|
|
||||||
{"-0x.8", -0.5},
|
|
||||||
{"-0x1.8", -1.5},
|
|
||||||
|
|
||||||
// Examples with a binary exponent and a 'f' suffix.
|
// Examples with a binary exponent and a 'f' suffix.
|
||||||
{"0x1.p0f", 1.0},
|
{"0x1.p0f", 1.0},
|
||||||
{"0x.8p2f", 2.0},
|
{"0x.8p2f", 2.0},
|
||||||
{"0x1.8p-1f", 0.75},
|
{"0x1.8p-1f", 0.75},
|
||||||
{"0x2p-2f", 0.5}, // No binary point
|
{"0x2p-2f", 0.5}, // No binary point
|
||||||
{"-0x1.p0f", -1.0},
|
|
||||||
{"-0x.8p2f", -2.0},
|
|
||||||
{"-0x1.8p-1f", -0.75},
|
|
||||||
{"-0x2p-2f", -0.5}, // No binary point
|
|
||||||
|
|
||||||
// Examples with a binary exponent and a 'h' suffix.
|
// Examples with a binary exponent and a 'h' suffix.
|
||||||
{"0x1.p0h", 1.0},
|
{"0x1.p0h", 1.0},
|
||||||
{"0x.8p2h", 2.0},
|
{"0x.8p2h", 2.0},
|
||||||
{"0x1.8p-1h", 0.75},
|
{"0x1.8p-1h", 0.75},
|
||||||
{"0x2p-2h", 0.5}, // No binary point
|
{"0x2p-2h", 0.5}, // No binary point
|
||||||
{"-0x1.p0h", -1.0},
|
|
||||||
{"-0x.8p2h", -2.0},
|
|
||||||
{"-0x1.8p-1h", -0.75},
|
|
||||||
{"-0x2p-2h", -0.5}, // No binary point
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_SUITE_P(ParserImplFloatLiteralTest_HexFloat,
|
INSTANTIATE_TEST_SUITE_P(ParserImplFloatLiteralTest_HexFloat,
|
||||||
|
@ -532,11 +388,9 @@ std::vector<FloatLiteralTestCase> UpperCase0X(const ARR& cases) {
|
||||||
using UpperCase0XTest = ::testing::Test;
|
using UpperCase0XTest = ::testing::Test;
|
||||||
TEST_F(UpperCase0XTest, Samples) {
|
TEST_F(UpperCase0XTest, Samples) {
|
||||||
const auto cases = FloatLiteralTestCaseList{
|
const auto cases = FloatLiteralTestCaseList{
|
||||||
{"absent", 0.0}, {"0x", 1.0}, {"0X", 2.0}, {"-0x", 3.0},
|
{"absent", 0.0}, {"0x", 1.0}, {"0X", 2.0}, {" 0x1p1", 5.0}, {" examine ", 7.0}};
|
||||||
{"-0X", 4.0}, {" 0x1p1", 5.0}, {" -0x1p", 6.0}, {" examine ", 7.0}};
|
|
||||||
const auto expected = FloatLiteralTestCaseList{
|
const auto expected = FloatLiteralTestCaseList{
|
||||||
{"absent", 0.0}, {"0X", 1.0}, {"0X", 2.0}, {"-0X", 3.0},
|
{"absent", 0.0}, {"0X", 1.0}, {"0X", 2.0}, {" 0X1p1", 5.0}, {" examine ", 7.0}};
|
||||||
{"-0X", 4.0}, {" 0X1p1", 5.0}, {" -0X1p", 6.0}, {" examine ", 7.0}};
|
|
||||||
|
|
||||||
auto result = UpperCase0X(cases);
|
auto result = UpperCase0X(cases);
|
||||||
EXPECT_THAT(result, ::testing::ElementsAreArray(expected));
|
EXPECT_THAT(result, ::testing::ElementsAreArray(expected));
|
||||||
|
@ -625,11 +479,6 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"0x1.0018p+1024",
|
"0x1.0018p+1024",
|
||||||
"0x1.01ep+1024",
|
"0x1.01ep+1024",
|
||||||
"0x1.fffffep+1024",
|
"0x1.fffffep+1024",
|
||||||
"-0x1.8p+1024",
|
|
||||||
"-0x1.0002p+1024",
|
|
||||||
"-0x1.0018p+1024",
|
|
||||||
"-0x1.01ep+1024",
|
|
||||||
"-0x1.fffffep+1024",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -642,11 +491,6 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"0x1.0018p+128f",
|
"0x1.0018p+128f",
|
||||||
"0x1.01ep+128f",
|
"0x1.01ep+128f",
|
||||||
"0x1.fffffep+128f",
|
"0x1.fffffep+128f",
|
||||||
"-0x1.8p+128f",
|
|
||||||
"-0x1.0002p+128f",
|
|
||||||
"-0x1.0018p+128f",
|
|
||||||
"-0x1.01ep+128f",
|
|
||||||
"-0x1.fffffep+128f",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -659,11 +503,6 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"0x1.018p+16h",
|
"0x1.018p+16h",
|
||||||
"0x1.1ep+16h",
|
"0x1.1ep+16h",
|
||||||
"0x1.ffcp+16h",
|
"0x1.ffcp+16h",
|
||||||
"-0x1.8p+16h",
|
|
||||||
"-0x1.004p+16h",
|
|
||||||
"-0x1.018p+16h",
|
|
||||||
"-0x1.1ep+16h",
|
|
||||||
"-0x1.ffcp+16h",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -672,17 +511,11 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
testing::Combine(testing::Values("1:1: value cannot be represented as 'abstract-float'"),
|
testing::Combine(testing::Values("1:1: value cannot be represented as 'abstract-float'"),
|
||||||
testing::ValuesIn(std::vector<const char*>{
|
testing::ValuesIn(std::vector<const char*>{
|
||||||
"0x1p+1024",
|
"0x1p+1024",
|
||||||
"-0x1p+1024",
|
|
||||||
"0x1.1p+1024",
|
"0x1.1p+1024",
|
||||||
"-0x1.1p+1024",
|
|
||||||
"0x1p+1025",
|
"0x1p+1025",
|
||||||
"-0x1p+1025",
|
|
||||||
"0x32p+1023",
|
"0x32p+1023",
|
||||||
"-0x32p+1023",
|
|
||||||
"0x32p+5000",
|
"0x32p+5000",
|
||||||
"-0x32p+5000",
|
|
||||||
"0x1.0p9223372036854774784",
|
"0x1.0p9223372036854774784",
|
||||||
"-0x1.0p9223372036854774784",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -691,15 +524,10 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
testing::Combine(testing::Values("1:1: value cannot be represented as 'f32'"),
|
testing::Combine(testing::Values("1:1: value cannot be represented as 'f32'"),
|
||||||
testing::ValuesIn(std::vector<const char*>{
|
testing::ValuesIn(std::vector<const char*>{
|
||||||
"0x1p+128f",
|
"0x1p+128f",
|
||||||
"-0x1p+128f",
|
|
||||||
"0x1.1p+128f",
|
"0x1.1p+128f",
|
||||||
"-0x1.1p+128f",
|
|
||||||
"0x1p+129f",
|
"0x1p+129f",
|
||||||
"-0x1p+129f",
|
|
||||||
"0x32p+127f",
|
"0x32p+127f",
|
||||||
"-0x32p+127f",
|
|
||||||
"0x32p+500f",
|
"0x32p+500f",
|
||||||
"-0x32p+500f",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -708,15 +536,10 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
testing::Combine(testing::Values("1:1: value cannot be represented as 'f16'"),
|
testing::Combine(testing::Values("1:1: value cannot be represented as 'f16'"),
|
||||||
testing::ValuesIn(std::vector<const char*>{
|
testing::ValuesIn(std::vector<const char*>{
|
||||||
"0x1p+16h",
|
"0x1p+16h",
|
||||||
"-0x1p+16h",
|
|
||||||
"0x1.1p+16h",
|
"0x1.1p+16h",
|
||||||
"-0x1.1p+16h",
|
|
||||||
"0x1p+17h",
|
"0x1p+17h",
|
||||||
"-0x1p+17h",
|
|
||||||
"0x32p+15h",
|
"0x32p+15h",
|
||||||
"-0x32p+15h",
|
|
||||||
"0x32p+500h",
|
"0x32p+500h",
|
||||||
"-0x32p+500h",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -732,24 +555,14 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"0x2.cafef00dp+0f", // Quantizes to 0x2.cafefp+0
|
"0x2.cafef00dp+0f", // Quantizes to 0x2.cafefp+0
|
||||||
"0x0.0000ffp-126f", // Subnormal, quantizes to 0x0.0000fep-126
|
"0x0.0000ffp-126f", // Subnormal, quantizes to 0x0.0000fep-126
|
||||||
"0x3.fcp-144f", // Subnormal, quantizes to 0x3.f8p-144
|
"0x3.fcp-144f", // Subnormal, quantizes to 0x3.f8p-144
|
||||||
"-0x0.0000ffp-126f", // Subnormal, quantizes to -0x0.0000fep-126
|
|
||||||
"-0x3.fcp-144f", // Subnormal, quantizes to -0x3.f8p-144
|
|
||||||
"0x0.ffffffp-126f", // Subnormal, quantizes to 0x0.fffffep-144
|
"0x0.ffffffp-126f", // Subnormal, quantizes to 0x0.fffffep-144
|
||||||
"0x0.fffffe0000001p-126f", // Subnormal, quantizes to 0x0.fffffep-144
|
"0x0.fffffe0000001p-126f", // Subnormal, quantizes to 0x0.fffffep-144
|
||||||
"-0x0.ffffffp-126f", // Subnormal, quantizes to -0x0.fffffep-144
|
|
||||||
"-0x0.fffffe0000001p-126f", // Subnormal, quantizes to -0x0.fffffep-144
|
|
||||||
"0x1.8p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
"0x1.8p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
||||||
"0x1.4p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
"0x1.4p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
||||||
"0x1.000002p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
"0x1.000002p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
||||||
"0x1.0000000000001p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
"0x1.0000000000001p-149f", // Subnormal, quantizes to 0x1.0p-149f
|
||||||
"-0x1.8p-149f", // Subnormal, quantizes to -0x1.0p-149f
|
|
||||||
"-0x1.4p-149f", // Subnormal, quantizes to -0x1.0p-149f
|
|
||||||
"-0x1.000002p-149f", // Subnormal, quantizes to -0x1.0p-149f
|
|
||||||
"-0x1.0000000000001p-149f", // Subnormal, quantizes to -0x1.0p-149f
|
|
||||||
"0x1.0p-150f", // Smaller than the smallest subnormal, quantizes to 0.0
|
"0x1.0p-150f", // Smaller than the smallest subnormal, quantizes to 0.0
|
||||||
"0x1.8p-150f", // Smaller than the smallest subnormal, quantizes to 0.0
|
"0x1.8p-150f", // Smaller than the smallest subnormal, quantizes to 0.0
|
||||||
"-0x1.0p-150f", // Smaller than the smallest subnormal, quantizes to -0.0
|
|
||||||
"-0x1.8p-150f", // Smaller than the smallest subnormal, quantizes to -0.0
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -768,26 +581,15 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"0x4.011p+0h", // Quantizes to 0x4.01p+0
|
"0x4.011p+0h", // Quantizes to 0x4.01p+0
|
||||||
"0x0.0fep-14h", // Subnormal, quantizes to 0x0.0fcp-14
|
"0x0.0fep-14h", // Subnormal, quantizes to 0x0.0fcp-14
|
||||||
"0x3.f8p-20h", // Subnormal, quantizes to 0x3.f0p-20
|
"0x3.f8p-20h", // Subnormal, quantizes to 0x3.f0p-20
|
||||||
"-0x0.0fep-14h", // Subnormal, quantizes to -0x0.0fcp-14
|
|
||||||
"-0x3.f8p-20h", // Subnormal, quantizes to -0x3.f0p-20
|
|
||||||
"0x0.ffep-14h", // Subnormal, quantizes to 0x0.ffcp-14
|
"0x0.ffep-14h", // Subnormal, quantizes to 0x0.ffcp-14
|
||||||
"0x0.ffe0000000001p-14h", // Subnormal, quantizes to 0x0.ffcp-14
|
"0x0.ffe0000000001p-14h", // Subnormal, quantizes to 0x0.ffcp-14
|
||||||
"0x0.fffffffffffffp-14h", // Subnormal, quantizes to 0x0.ffcp-14
|
"0x0.fffffffffffffp-14h", // Subnormal, quantizes to 0x0.ffcp-14
|
||||||
"-0x0.ffep-14h", // Subnormal, quantizes to -0x0.ffcp-14
|
|
||||||
"-0x0.ffe0000000001p-14h", // Subnormal, quantizes to -0x0.ffcp-14
|
|
||||||
"-0x0.fffffffffffffp-14h", // Subnormal, quantizes to -0x0.ffcp-14
|
|
||||||
"0x1.8p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
"0x1.8p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
||||||
"0x1.4p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
"0x1.4p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
||||||
"0x1.004p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
"0x1.004p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
||||||
"0x1.0000000000001p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
"0x1.0000000000001p-24h", // Subnormal, quantizes to 0x1.0p-24f
|
||||||
"-0x1.8p-24h", // Subnormal, quantizes to -0x1.0p-24f
|
|
||||||
"-0x1.4p-24h", // Subnormal, quantizes to -0x1.0p-24f
|
|
||||||
"-0x1.004p-24h", // Subnormal, quantizes to -0x1.0p-24f
|
|
||||||
"-0x1.0000000000001p-24h", // Subnormal, quantizes to -0x1.0p-24f
|
|
||||||
"0x1.0p-25h", // Smaller than the smallest subnormal, quantizes to 0.0
|
"0x1.0p-25h", // Smaller than the smallest subnormal, quantizes to 0.0
|
||||||
"0x1.8p-25h", // Smaller than the smallest subnormal, quantizes to 0.0
|
"0x1.8p-25h", // Smaller than the smallest subnormal, quantizes to 0.0
|
||||||
"-0x1.0p-25h", // Smaller than the smallest subnormal, quantizes to -0.0
|
|
||||||
"-0x1.8p-25h", // Smaller than the smallest subnormal, quantizes to -0.0
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -796,15 +598,10 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
testing::Combine(testing::Values("1:1: value cannot be represented as 'abstract-float'"),
|
testing::Combine(testing::Values("1:1: value cannot be represented as 'abstract-float'"),
|
||||||
testing::ValuesIn(std::vector<const char*>{
|
testing::ValuesIn(std::vector<const char*>{
|
||||||
"1.e309",
|
"1.e309",
|
||||||
"-1.e309",
|
|
||||||
"1.8e308",
|
"1.8e308",
|
||||||
"-1.8e308",
|
|
||||||
"1.798e308",
|
"1.798e308",
|
||||||
"-1.798e308",
|
|
||||||
"1.7977e308",
|
"1.7977e308",
|
||||||
"-1.7977e308",
|
|
||||||
"1.2e+5000",
|
"1.2e+5000",
|
||||||
"-1.2e+5000",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -813,15 +610,10 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
testing::Combine(testing::Values("1:1: value cannot be represented as 'f32'"),
|
testing::Combine(testing::Values("1:1: value cannot be represented as 'f32'"),
|
||||||
testing::ValuesIn(std::vector<const char*>{
|
testing::ValuesIn(std::vector<const char*>{
|
||||||
"1e39f",
|
"1e39f",
|
||||||
"-1e39f",
|
|
||||||
"4.0e38f",
|
"4.0e38f",
|
||||||
"-4.0e38f",
|
|
||||||
"3.5e38f",
|
"3.5e38f",
|
||||||
"-3.5e38f",
|
|
||||||
"3.403e38f",
|
"3.403e38f",
|
||||||
"-3.403e38f",
|
|
||||||
"1.2e+256f",
|
"1.2e+256f",
|
||||||
"-1.2e+256f",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -830,17 +622,11 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
testing::Combine(testing::Values("1:1: value cannot be represented as 'f16'"),
|
testing::Combine(testing::Values("1:1: value cannot be represented as 'f16'"),
|
||||||
testing::ValuesIn(std::vector<const char*>{
|
testing::ValuesIn(std::vector<const char*>{
|
||||||
"1.0e5h",
|
"1.0e5h",
|
||||||
"-1.0e5h",
|
|
||||||
"7.0e4h",
|
"7.0e4h",
|
||||||
"-7.0e4h",
|
|
||||||
"6.6e4h",
|
"6.6e4h",
|
||||||
"-6.6e4h",
|
|
||||||
"6.56e4h",
|
"6.56e4h",
|
||||||
"-6.56e4h",
|
|
||||||
"6.554e4h",
|
"6.554e4h",
|
||||||
"-6.554e4h",
|
|
||||||
"1.2e+32h",
|
"1.2e+32h",
|
||||||
"-1.2e+32h",
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
TEST_F(ParserImplTest, ConstLiteral_FloatHighest) {
|
TEST_F(ParserImplTest, ConstLiteral_FloatHighest) {
|
||||||
|
@ -863,29 +649,6 @@ TEST_F(ParserImplTest, ConstLiteral_FloatHighest) {
|
||||||
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 42u}}));
|
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 42u}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, ConstLiteral_FloatLowest) {
|
|
||||||
// Some compilers complain if you test floating point numbers for equality.
|
|
||||||
// So say it via two inequalities.
|
|
||||||
const auto lowest = std::numeric_limits<float>::lowest();
|
|
||||||
const auto expected_lowest = -340282346638528859811704183484516925440.0f;
|
|
||||||
if (lowest < expected_lowest || lowest > expected_lowest) {
|
|
||||||
GTEST_SKIP() << "std::numeric_limits<float>::lowest() is not as expected for "
|
|
||||||
"this target";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto p = parser("-340282346638528859811704183484516925440.0");
|
|
||||||
auto c = p->const_literal();
|
|
||||||
EXPECT_TRUE(c.matched);
|
|
||||||
EXPECT_FALSE(c.errored);
|
|
||||||
EXPECT_FALSE(p->has_error()) << p->error();
|
|
||||||
ASSERT_NE(c.value, nullptr);
|
|
||||||
ASSERT_TRUE(c->Is<ast::FloatLiteralExpression>());
|
|
||||||
EXPECT_EQ(c->As<ast::FloatLiteralExpression>()->value, std::numeric_limits<float>::lowest());
|
|
||||||
EXPECT_EQ(c->As<ast::FloatLiteralExpression>()->suffix,
|
|
||||||
ast::FloatLiteralExpression::Suffix::kNone);
|
|
||||||
EXPECT_EQ(c->source.range, (Source::Range{{1u, 1u}, {1u, 43u}}));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ParserImplTest, ConstLiteral_True) {
|
TEST_F(ParserImplTest, ConstLiteral_True) {
|
||||||
auto p = parser("true");
|
auto p = parser("true");
|
||||||
auto c = p->const_literal();
|
auto c = p->const_literal();
|
||||||
|
|
|
@ -269,6 +269,124 @@ TEST_F(ParserImplTest, Expression_InvalidAssociativity) {
|
||||||
EXPECT_EQ(p->error(), R"(1:7: mixing '&&' and '||' requires parenthesis)");
|
EXPECT_EQ(p->error(), R"(1:7: mixing '&&' and '||' requires parenthesis)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplTest, Expression_SubtractionNoSpace) {
|
||||||
|
auto p = parser("(2-1)");
|
||||||
|
auto e = p->expression();
|
||||||
|
EXPECT_TRUE(e.matched);
|
||||||
|
EXPECT_FALSE(e.errored);
|
||||||
|
EXPECT_FALSE(p->has_error()) << p->error();
|
||||||
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
ASSERT_TRUE(e->Is<ast::BinaryExpression>());
|
||||||
|
auto* b = e->As<ast::BinaryExpression>();
|
||||||
|
EXPECT_TRUE(b->IsSubtract());
|
||||||
|
|
||||||
|
ASSERT_TRUE(b->lhs->Is<ast::IntLiteralExpression>());
|
||||||
|
ASSERT_TRUE(b->rhs->Is<ast::IntLiteralExpression>());
|
||||||
|
|
||||||
|
EXPECT_EQ(b->lhs->As<ast::IntLiteralExpression>()->value, 2);
|
||||||
|
EXPECT_EQ(b->rhs->As<ast::IntLiteralExpression>()->value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplTest, Expression_NegatedNumber) {
|
||||||
|
auto p = parser("-1");
|
||||||
|
auto e = p->expression();
|
||||||
|
EXPECT_TRUE(e.matched);
|
||||||
|
EXPECT_FALSE(e.errored);
|
||||||
|
EXPECT_FALSE(p->has_error()) << p->error();
|
||||||
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
|
ASSERT_TRUE(e->Is<ast::UnaryOpExpression>());
|
||||||
|
auto* b = e->As<ast::UnaryOpExpression>();
|
||||||
|
EXPECT_EQ(b->op, ast::UnaryOp::kNegation);
|
||||||
|
|
||||||
|
ASSERT_TRUE(b->expr->Is<ast::IntLiteralExpression>());
|
||||||
|
EXPECT_EQ(b->expr->As<ast::IntLiteralExpression>()->value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplTest, Expression_MaxI32) {
|
||||||
|
auto p = parser("2147483647");
|
||||||
|
auto e = p->expression();
|
||||||
|
EXPECT_TRUE(e.matched);
|
||||||
|
EXPECT_FALSE(e.errored);
|
||||||
|
EXPECT_FALSE(p->has_error()) << p->error();
|
||||||
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
|
ASSERT_TRUE(e->Is<ast::IntLiteralExpression>());
|
||||||
|
EXPECT_EQ(e->As<ast::IntLiteralExpression>()->value, 2147483647);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplTest, Expression_MinI32) {
|
||||||
|
auto p = parser("-2147483648");
|
||||||
|
auto e = p->expression();
|
||||||
|
EXPECT_TRUE(e.matched);
|
||||||
|
EXPECT_FALSE(e.errored);
|
||||||
|
EXPECT_FALSE(p->has_error()) << p->error();
|
||||||
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
|
ASSERT_TRUE(e->Is<ast::UnaryOpExpression>());
|
||||||
|
auto* b = e->As<ast::UnaryOpExpression>();
|
||||||
|
EXPECT_EQ(b->op, ast::UnaryOp::kNegation);
|
||||||
|
|
||||||
|
ASSERT_TRUE(b->expr->Is<ast::IntLiteralExpression>());
|
||||||
|
EXPECT_EQ(b->expr->As<ast::IntLiteralExpression>()->value, 2147483648);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplTest, Expression_MaxU32) {
|
||||||
|
auto p = parser("4294967295");
|
||||||
|
auto e = p->expression();
|
||||||
|
EXPECT_TRUE(e.matched);
|
||||||
|
EXPECT_FALSE(e.errored);
|
||||||
|
EXPECT_FALSE(p->has_error()) << p->error();
|
||||||
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
|
ASSERT_TRUE(e->Is<ast::IntLiteralExpression>());
|
||||||
|
EXPECT_EQ(e->As<ast::IntLiteralExpression>()->value, 4294967295);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplTest, Expression_MaxF32) {
|
||||||
|
const auto highest = std::numeric_limits<float>::max();
|
||||||
|
const auto expected_highest = 340282346638528859811704183484516925440.0f;
|
||||||
|
if (highest < expected_highest || highest > expected_highest) {
|
||||||
|
GTEST_SKIP() << "std::numeric_limits<float>::max() is not as expected for "
|
||||||
|
"this target";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto p = parser("340282346638528859811704183484516925440.0f");
|
||||||
|
auto e = p->expression();
|
||||||
|
EXPECT_TRUE(e.matched);
|
||||||
|
EXPECT_FALSE(e.errored);
|
||||||
|
EXPECT_FALSE(p->has_error()) << p->error();
|
||||||
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
|
ASSERT_TRUE(e->Is<ast::FloatLiteralExpression>());
|
||||||
|
EXPECT_EQ(e->As<ast::FloatLiteralExpression>()->value,
|
||||||
|
340282346638528859811704183484516925440.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplTest, Expression_MinF32) {
|
||||||
|
const auto lowest = std::numeric_limits<float>::lowest();
|
||||||
|
const auto expected_lowest = -340282346638528859811704183484516925440.0f;
|
||||||
|
if (lowest < expected_lowest || lowest > expected_lowest) {
|
||||||
|
GTEST_SKIP() << "std::numeric_limits<float>::lowest() is not as expected for "
|
||||||
|
"this target";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto p = parser("-340282346638528859811704183484516925440.0f");
|
||||||
|
auto e = p->expression();
|
||||||
|
EXPECT_TRUE(e.matched);
|
||||||
|
EXPECT_FALSE(e.errored);
|
||||||
|
EXPECT_FALSE(p->has_error()) << p->error();
|
||||||
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
|
ASSERT_TRUE(e->Is<ast::UnaryOpExpression>());
|
||||||
|
auto* b = e->As<ast::UnaryOpExpression>();
|
||||||
|
EXPECT_EQ(b->op, ast::UnaryOp::kNegation);
|
||||||
|
|
||||||
|
ASSERT_TRUE(b->expr->Is<ast::FloatLiteralExpression>());
|
||||||
|
EXPECT_EQ(b->expr->As<ast::FloatLiteralExpression>()->value,
|
||||||
|
340282346638528859811704183484516925440.0f);
|
||||||
|
}
|
||||||
|
|
||||||
namespace mixing_binary_ops {
|
namespace mixing_binary_ops {
|
||||||
|
|
||||||
struct BinaryOperatorInfo {
|
struct BinaryOperatorInfo {
|
||||||
|
|
|
@ -1405,6 +1405,27 @@ TEST_F(ResolverTest, Expr_Initializer_Cast_Pointer) {
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: type is not constructible");
|
EXPECT_EQ(r()->error(), "12:34 error: type is not constructible");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ResolverTest, I32_Overflow) {
|
||||||
|
GlobalVar("v", ty.i32(), ast::AddressSpace::kPrivate, Expr(Source{{12, 24}}, 2147483648_a));
|
||||||
|
|
||||||
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
EXPECT_EQ(r()->error(), "12:24 error: value 2147483648 cannot be represented as 'i32'");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ResolverTest, I32_Underflow) {
|
||||||
|
GlobalVar("v", ty.i32(), ast::AddressSpace::kPrivate, Expr(Source{{12, 24}}, -2147483649_a));
|
||||||
|
|
||||||
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
EXPECT_EQ(r()->error(), "12:24 error: value -2147483649 cannot be represented as 'i32'");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ResolverTest, U32_Overflow) {
|
||||||
|
GlobalVar("v", ty.u32(), ast::AddressSpace::kPrivate, Expr(Source{{12, 24}}, 4294967296_a));
|
||||||
|
|
||||||
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
EXPECT_EQ(r()->error(), "12:24 error: value 4294967296 cannot be represented as 'u32'");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::resolver
|
} // namespace tint::resolver
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fn g() -> vec4<i32> {
|
fn g() -> vec4<i32> {
|
||||||
return (vec4(0) << vec4(2147483649));
|
return (vec4(-(0)) << vec4(2147483649));
|
||||||
}
|
}
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
|
|
|
@ -14,14 +14,14 @@ struct VertexOutputs {
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vs_main(@builtin(vertex_index) VertexIndex : u32) -> VertexOutputs {
|
fn vs_main(@builtin(vertex_index) VertexIndex : u32) -> VertexOutputs {
|
||||||
var texcoord = array<vec2<f32>, 3>(vec2<f32>(-0.5, 0.0), vec2<f32>(1.5, 0.0), vec2<f32>(0.5, 2.0));
|
var texcoord = array<vec2<f32>, 3>(vec2<f32>(-(0.5), 0.0), vec2<f32>(1.5, 0.0), vec2<f32>(0.5, 2.0));
|
||||||
var output : VertexOutputs;
|
var output : VertexOutputs;
|
||||||
output.position = vec4<f32>(((texcoord[VertexIndex] * 2.0) - vec2<f32>(1.0, 1.0)), 0.0, 1.0);
|
output.position = vec4<f32>(((texcoord[VertexIndex] * 2.0) - vec2<f32>(1.0, 1.0)), 0.0, 1.0);
|
||||||
var flipY = (uniforms.u_scale.y < 0.0);
|
var flipY = (uniforms.u_scale.y < 0.0);
|
||||||
if (flipY) {
|
if (flipY) {
|
||||||
output.texcoords = ((((texcoord[VertexIndex] * uniforms.u_scale) + uniforms.u_offset) * vec2<f32>(1.0, -1.0)) + vec2<f32>(0.0, 1.0));
|
output.texcoords = ((((texcoord[VertexIndex] * uniforms.u_scale) + uniforms.u_offset) * vec2<f32>(1.0, -(1.0))) + vec2<f32>(0.0, 1.0));
|
||||||
} else {
|
} else {
|
||||||
output.texcoords = ((((texcoord[VertexIndex] * vec2<f32>(1.0, -1.0)) + vec2<f32>(0.0, 1.0)) * uniforms.u_scale) + uniforms.u_offset);
|
output.texcoords = ((((texcoord[VertexIndex] * vec2<f32>(1.0, -(1.0))) + vec2<f32>(0.0, 1.0)) * uniforms.u_scale) + uniforms.u_offset);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ fn main_create_lut(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var numTriangles = atomicLoad(&(counters.values[voxelIndex]));
|
var numTriangles = atomicLoad(&(counters.values[voxelIndex]));
|
||||||
var offset = -1;
|
var offset = -(1);
|
||||||
if ((numTriangles > 0u)) {
|
if ((numTriangles > 0u)) {
|
||||||
offset = i32(atomicAdd(&(dbg.offsetCounter), numTriangles));
|
offset = i32(atomicAdd(&(dbg.offsetCounter), numTriangles));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||||
lightsBuffer.lights[index].position.y = uniforms.max.y;
|
lightsBuffer.lights[index].position.y = uniforms.max.y;
|
||||||
}
|
}
|
||||||
var M : mat4x4<f32> = uniforms.projectionMatrix;
|
var M : mat4x4<f32> = uniforms.projectionMatrix;
|
||||||
var viewNear : f32 = (-(M[3][2]) / (-1.0 + M[2][2]));
|
var viewNear : f32 = (-(M[3][2]) / (-(1.0) + M[2][2]));
|
||||||
var viewFar : f32 = (-(M[3][2]) / (1.0 + M[2][2]));
|
var viewFar : f32 = (-(M[3][2]) / (1.0 + M[2][2]));
|
||||||
var lightPos = lightsBuffer.lights[index].position;
|
var lightPos = lightsBuffer.lights[index].position;
|
||||||
lightPos = (uniforms.viewMatrix * lightPos);
|
lightPos = (uniforms.viewMatrix * lightPos);
|
||||||
|
@ -62,7 +62,7 @@ fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||||
var boxMin : vec4<f32> = (lightPos - vec4<f32>(vec3<f32>(lightRadius), 0.0));
|
var boxMin : vec4<f32> = (lightPos - vec4<f32>(vec3<f32>(lightRadius), 0.0));
|
||||||
var boxMax : vec4<f32> = (lightPos + vec4<f32>(vec3<f32>(lightRadius), 0.0));
|
var boxMax : vec4<f32> = (lightPos + vec4<f32>(vec3<f32>(lightRadius), 0.0));
|
||||||
var frustumPlanes : array<vec4<f32>, 6>;
|
var frustumPlanes : array<vec4<f32>, 6>;
|
||||||
frustumPlanes[4] = vec4<f32>(0.0, 0.0, -1.0, viewNear);
|
frustumPlanes[4] = vec4<f32>(0.0, 0.0, -(1.0), viewNear);
|
||||||
frustumPlanes[5] = vec4<f32>(0.0, 0.0, 1.0, -(viewFar));
|
frustumPlanes[5] = vec4<f32>(0.0, 0.0, 1.0, -(viewFar));
|
||||||
let TILE_SIZE : i32 = 16;
|
let TILE_SIZE : i32 = 16;
|
||||||
let TILE_COUNT_X : i32 = 2;
|
let TILE_COUNT_X : i32 = 2;
|
||||||
|
@ -75,9 +75,9 @@ fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||||
var viewFloorCoord : vec2<f32> = vec2<f32>((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
var viewFloorCoord : vec2<f32> = vec2<f32>((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
||||||
var viewCeilCoord : vec2<f32> = vec2<f32>((((-(viewNear) * ceilCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * ceilCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
var viewCeilCoord : vec2<f32> = vec2<f32>((((-(viewNear) * ceilCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * ceilCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
||||||
frustumPlanes[0] = vec4<f32>(1.0, 0.0, (-(viewFloorCoord.x) / viewNear), 0.0);
|
frustumPlanes[0] = vec4<f32>(1.0, 0.0, (-(viewFloorCoord.x) / viewNear), 0.0);
|
||||||
frustumPlanes[1] = vec4<f32>(-1.0, 0.0, (viewCeilCoord.x / viewNear), 0.0);
|
frustumPlanes[1] = vec4<f32>(-(1.0), 0.0, (viewCeilCoord.x / viewNear), 0.0);
|
||||||
frustumPlanes[2] = vec4<f32>(0.0, 1.0, (-(viewFloorCoord.y) / viewNear), 0.0);
|
frustumPlanes[2] = vec4<f32>(0.0, 1.0, (-(viewFloorCoord.y) / viewNear), 0.0);
|
||||||
frustumPlanes[3] = vec4<f32>(0.0, -1.0, (viewCeilCoord.y / viewNear), 0.0);
|
frustumPlanes[3] = vec4<f32>(0.0, -(1.0), (viewCeilCoord.y / viewNear), 0.0);
|
||||||
var dp : f32 = 0.0;
|
var dp : f32 = 0.0;
|
||||||
for(var i : u32 = 0u; (i < 6u); i = (i + 1u)) {
|
for(var i : u32 = 0u; (i < 6u); i = (i + 1u)) {
|
||||||
var p : vec4<f32>;
|
var p : vec4<f32>;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
fn func_3() -> bool {
|
fn func_3() -> bool {
|
||||||
for(var i = 0; (i < b); i++) {
|
for(var i = 0; (i < b); i++) {
|
||||||
for(var j = -1; (j == 1); j++) {
|
for(var j = -(1); (j == 1); j++) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,5 @@ fn f0() {
|
||||||
|
|
||||||
fn f1() {
|
fn f1() {
|
||||||
let a = 1;
|
let a = 1;
|
||||||
let b = (-2147483648 - a);
|
let b = (-(2147483648) - a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ fn fixed_size_array() {
|
||||||
@group(0) @binding(0) var<storage> rarr : array<f32>;
|
@group(0) @binding(0) var<storage> rarr : array<f32>;
|
||||||
|
|
||||||
fn runtime_size_array() {
|
fn runtime_size_array() {
|
||||||
let idx = -1;
|
let idx = -(1);
|
||||||
let x = rarr[idx];
|
let x = rarr[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ var<private> my_global : vec4<f32>;
|
||||||
fn foo_member_initialize() {
|
fn foo_member_initialize() {
|
||||||
var vb2 : vec2<bool>;
|
var vb2 : vec2<bool>;
|
||||||
vb2.x = (my_global.z != 0);
|
vb2.x = (my_global.z != 0);
|
||||||
vb2.x = (my_uniform == -1.0f);
|
vb2.x = (my_uniform == -(1.0f));
|
||||||
vb2 = vec2((my_uniform == -1.0f), false);
|
vb2 = vec2((my_uniform == -(1.0f)), false);
|
||||||
if (vb2.x) {
|
if (vb2.x) {
|
||||||
let r : vec4<f32> = textureSampleBias(my_texture, my_sampler, vec2<f32>(), 0.0);
|
let r : vec4<f32> = textureSampleBias(my_texture, my_sampler, vec2<f32>(), 0.0);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ fn foo_member_initialize() {
|
||||||
fn foo_default_initialize() {
|
fn foo_default_initialize() {
|
||||||
var vb2 : vec2<bool>;
|
var vb2 : vec2<bool>;
|
||||||
vb2.x = (my_global.z != 0);
|
vb2.x = (my_global.z != 0);
|
||||||
vb2.x = (my_uniform == -1.0f);
|
vb2.x = (my_uniform == -(1.0f));
|
||||||
vb2 = vec2<bool>();
|
vb2 = vec2<bool>();
|
||||||
if (vb2.x) {
|
if (vb2.x) {
|
||||||
let r : vec4<f32> = textureSampleBias(my_texture, my_sampler, vec2<f32>(), 0.0);
|
let r : vec4<f32> = textureSampleBias(my_texture, my_sampler, vec2<f32>(), 0.0);
|
||||||
|
|
|
@ -16,7 +16,7 @@ fn main(@builtin(vertex_index) gl_VertexIndex : u32) -> @builtin(position) vec4<
|
||||||
let x_23 : mat2x2<f32> = x_20.transform1;
|
let x_23 : mat2x2<f32> = x_20.transform1;
|
||||||
let x_28 : mat2x2<f32> = x_26.transform2;
|
let x_28 : mat2x2<f32> = x_26.transform2;
|
||||||
let x_46 : u32 = gl_VertexIndex;
|
let x_46 : u32 = gl_VertexIndex;
|
||||||
indexable = array<vec2<f32>, 3>(vec2<f32>(-1.0, 1.0), vec2<f32>(1.0, 1.0), vec2<f32>(-1.0, -1.0));
|
indexable = array<vec2<f32>, 3>(vec2<f32>(-(1.0), 1.0), vec2<f32>(1.0, 1.0), vec2<f32>(-(1.0), -(1.0)));
|
||||||
let x_51 : vec2<f32> = indexable[x_46];
|
let x_51 : vec2<f32> = indexable[x_46];
|
||||||
let x_52 : vec2<f32> = (mat2x2<f32>((x_23[0u] + x_28[0u]), (x_23[1u] + x_28[1u])) * x_51);
|
let x_52 : vec2<f32> = (mat2x2<f32>((x_23[0u] + x_28[0u]), (x_23[1u] + x_28[1u])) * x_51);
|
||||||
return vec4<f32>(x_52.x, x_52.y, 0.0, 1.0);
|
return vec4<f32>(x_52.x, x_52.y, 0.0, 1.0);
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct Output {
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn main(@builtin(vertex_index) VertexIndex : u32, @builtin(instance_index) InstanceIndex : u32) -> Output {
|
fn main(@builtin(vertex_index) VertexIndex : u32, @builtin(instance_index) InstanceIndex : u32) -> Output {
|
||||||
let zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(vec2<f32>(0.2, 0.2), vec2<f32>(0.3, 0.3), vec2<f32>(-0.1, -0.1), vec2<f32>(1.1, 1.1));
|
let zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(vec2<f32>(0.2, 0.2), vec2<f32>(0.3, 0.3), vec2<f32>(-(0.1), -(0.1)), vec2<f32>(1.1, 1.1));
|
||||||
let z : f32 = zv[InstanceIndex].x;
|
let z : f32 = zv[InstanceIndex].x;
|
||||||
var output : Output;
|
var output : Output;
|
||||||
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
|
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
|
||||||
|
|
|
@ -305,7 +305,7 @@ fn main_1() {
|
||||||
let x_362 : vec3<f32> = output5;
|
let x_362 : vec3<f32> = output5;
|
||||||
let x_365 : mat3x3<f32> = invTBN;
|
let x_365 : mat3x3<f32> = invTBN;
|
||||||
let x_366 : vec4<f32> = v_output2;
|
let x_366 : vec4<f32> = v_output2;
|
||||||
numSamples = (15.0 + (dot((x_361 * -(x_362)), (x_365 * vec3<f32>(x_366.x, x_366.y, x_366.z))) * -11.0));
|
numSamples = (15.0 + (dot((x_361 * -(x_362)), (x_365 * vec3<f32>(x_366.x, x_366.y, x_366.z))) * -(11.0)));
|
||||||
let x_374 : f32 = numSamples;
|
let x_374 : f32 = numSamples;
|
||||||
stepSize = (1.0 / x_374);
|
stepSize = (1.0 / x_374);
|
||||||
currRayHeight = 1.0;
|
currRayHeight = 1.0;
|
||||||
|
|
|
@ -3,6 +3,6 @@ enable f16;
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat3x3<f16>(vec3<f16>(1.0h, 2.0h, 3.0h), vec3<f16>(4.0h, 5.0h, 6.0h), vec3<f16>(7.0h, 8.0h, 9.0h));
|
let a = mat3x3<f16>(vec3<f16>(1.0h, 2.0h, 3.0h), vec3<f16>(4.0h, 5.0h, 6.0h), vec3<f16>(7.0h, 8.0h, 9.0h));
|
||||||
let b = mat3x3<f16>(vec3<f16>(-1.0h, -2.0h, -3.0h), vec3<f16>(-4.0h, -5.0h, -6.0h), vec3<f16>(-7.0h, -8.0h, -9.0h));
|
let b = mat3x3<f16>(vec3<f16>(-(1.0h), -(2.0h), -(3.0h)), vec3<f16>(-(4.0h), -(5.0h), -(6.0h)), vec3<f16>(-(7.0h), -(8.0h), -(9.0h)));
|
||||||
let r : mat3x3<f16> = (a + b);
|
let r : mat3x3<f16> = (a + b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat3x3<f32>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0), vec3<f32>(7.0, 8.0, 9.0));
|
let a = mat3x3<f32>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0), vec3<f32>(7.0, 8.0, 9.0));
|
||||||
let b = mat3x3<f32>(vec3<f32>(-1.0, -2.0, -3.0), vec3<f32>(-4.0, -5.0, -6.0), vec3<f32>(-7.0, -8.0, -9.0));
|
let b = mat3x3<f32>(vec3<f32>(-(1.0), -(2.0), -(3.0)), vec3<f32>(-(4.0), -(5.0), -(6.0)), vec3<f32>(-(7.0), -(8.0), -(9.0)));
|
||||||
let r : mat3x3<f32> = (a + b);
|
let r : mat3x3<f32> = (a + b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ enable f16;
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat2x4<f16>(vec4<f16>(1.0h, 2.0h, 3.0h, 4.0h), vec4<f16>(5.0h, 6.0h, 7.0h, 8.0h));
|
let a = mat2x4<f16>(vec4<f16>(1.0h, 2.0h, 3.0h, 4.0h), vec4<f16>(5.0h, 6.0h, 7.0h, 8.0h));
|
||||||
let b = mat4x2<f16>(vec2<f16>(-1.0h, -2.0h), vec2<f16>(-3.0h, -4.0h), vec2<f16>(-5.0h, -6.0h), vec2<f16>(-7.0h, -8.0h));
|
let b = mat4x2<f16>(vec2<f16>(-(1.0h), -(2.0h)), vec2<f16>(-(3.0h), -(4.0h)), vec2<f16>(-(5.0h), -(6.0h)), vec2<f16>(-(7.0h), -(8.0h)));
|
||||||
let r : mat4x4<f16> = (a * b);
|
let r : mat4x4<f16> = (a * b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat2x4<f32>(vec4<f32>(1.0, 2.0, 3.0, 4.0), vec4<f32>(5.0, 6.0, 7.0, 8.0));
|
let a = mat2x4<f32>(vec4<f32>(1.0, 2.0, 3.0, 4.0), vec4<f32>(5.0, 6.0, 7.0, 8.0));
|
||||||
let b = mat4x2<f32>(vec2<f32>(-1.0, -2.0), vec2<f32>(-3.0, -4.0), vec2<f32>(-5.0, -6.0), vec2<f32>(-7.0, -8.0));
|
let b = mat4x2<f32>(vec2<f32>(-(1.0), -(2.0)), vec2<f32>(-(3.0), -(4.0)), vec2<f32>(-(5.0), -(6.0)), vec2<f32>(-(7.0), -(8.0)));
|
||||||
let r : mat4x4<f32> = (a * b);
|
let r : mat4x4<f32> = (a * b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ enable f16;
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat3x3<f16>(vec3<f16>(1.0h, 2.0h, 3.0h), vec3<f16>(4.0h, 5.0h, 6.0h), vec3<f16>(7.0h, 8.0h, 9.0h));
|
let a = mat3x3<f16>(vec3<f16>(1.0h, 2.0h, 3.0h), vec3<f16>(4.0h, 5.0h, 6.0h), vec3<f16>(7.0h, 8.0h, 9.0h));
|
||||||
let b = mat3x3<f16>(vec3<f16>(-1.0h, -2.0h, -3.0h), vec3<f16>(-4.0h, -5.0h, -6.0h), vec3<f16>(-7.0h, -8.0h, -9.0h));
|
let b = mat3x3<f16>(vec3<f16>(-(1.0h), -(2.0h), -(3.0h)), vec3<f16>(-(4.0h), -(5.0h), -(6.0h)), vec3<f16>(-(7.0h), -(8.0h), -(9.0h)));
|
||||||
let r : mat3x3<f16> = (a * b);
|
let r : mat3x3<f16> = (a * b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat3x3<f32>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0), vec3<f32>(7.0, 8.0, 9.0));
|
let a = mat3x3<f32>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0), vec3<f32>(7.0, 8.0, 9.0));
|
||||||
let b = mat3x3<f32>(vec3<f32>(-1.0, -2.0, -3.0), vec3<f32>(-4.0, -5.0, -6.0), vec3<f32>(-7.0, -8.0, -9.0));
|
let b = mat3x3<f32>(vec3<f32>(-(1.0), -(2.0), -(3.0)), vec3<f32>(-(4.0), -(5.0), -(6.0)), vec3<f32>(-(7.0), -(8.0), -(9.0)));
|
||||||
let r : mat3x3<f32> = (a * b);
|
let r : mat3x3<f32> = (a * b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ enable f16;
|
||||||
|
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat4x2<f16>(vec2<f16>(-1.0h, -2.0h), vec2<f16>(-3.0h, -4.0h), vec2<f16>(-5.0h, -6.0h), vec2<f16>(-7.0h, -8.0h));
|
let a = mat4x2<f16>(vec2<f16>(-(1.0h), -(2.0h)), vec2<f16>(-(3.0h), -(4.0h)), vec2<f16>(-(5.0h), -(6.0h)), vec2<f16>(-(7.0h), -(8.0h)));
|
||||||
let b = mat2x4<f16>(vec4<f16>(1.0h, 2.0h, 3.0h, 4.0h), vec4<f16>(5.0h, 6.0h, 7.0h, 8.0h));
|
let b = mat2x4<f16>(vec4<f16>(1.0h, 2.0h, 3.0h, 4.0h), vec4<f16>(5.0h, 6.0h, 7.0h, 8.0h));
|
||||||
let r : mat2x2<f16> = (a * b);
|
let r : mat2x2<f16> = (a * b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat4x2<f32>(vec2<f32>(-1.0, -2.0), vec2<f32>(-3.0, -4.0), vec2<f32>(-5.0, -6.0), vec2<f32>(-7.0, -8.0));
|
let a = mat4x2<f32>(vec2<f32>(-(1.0), -(2.0)), vec2<f32>(-(3.0), -(4.0)), vec2<f32>(-(5.0), -(6.0)), vec2<f32>(-(7.0), -(8.0)));
|
||||||
let b = mat2x4<f32>(vec4<f32>(1.0, 2.0, 3.0, 4.0), vec4<f32>(5.0, 6.0, 7.0, 8.0));
|
let b = mat2x4<f32>(vec4<f32>(1.0, 2.0, 3.0, 4.0), vec4<f32>(5.0, 6.0, 7.0, 8.0));
|
||||||
let r : mat2x2<f32> = (a * b);
|
let r : mat2x2<f32> = (a * b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ enable f16;
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat3x3<f16>(vec3<f16>(1.0h, 2.0h, 3.0h), vec3<f16>(4.0h, 5.0h, 6.0h), vec3<f16>(7.0h, 8.0h, 9.0h));
|
let a = mat3x3<f16>(vec3<f16>(1.0h, 2.0h, 3.0h), vec3<f16>(4.0h, 5.0h, 6.0h), vec3<f16>(7.0h, 8.0h, 9.0h));
|
||||||
let b = mat3x3<f16>(vec3<f16>(-1.0h, -2.0h, -3.0h), vec3<f16>(-4.0h, -5.0h, -6.0h), vec3<f16>(-7.0h, -8.0h, -9.0h));
|
let b = mat3x3<f16>(vec3<f16>(-(1.0h), -(2.0h), -(3.0h)), vec3<f16>(-(4.0h), -(5.0h), -(6.0h)), vec3<f16>(-(7.0h), -(8.0h), -(9.0h)));
|
||||||
let r : mat3x3<f16> = (a - b);
|
let r : mat3x3<f16> = (a - b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let a = mat3x3<f32>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0), vec3<f32>(7.0, 8.0, 9.0));
|
let a = mat3x3<f32>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0), vec3<f32>(7.0, 8.0, 9.0));
|
||||||
let b = mat3x3<f32>(vec3<f32>(-1.0, -2.0, -3.0), vec3<f32>(-4.0, -5.0, -6.0), vec3<f32>(-7.0, -8.0, -9.0));
|
let b = mat3x3<f32>(vec3<f32>(-(1.0), -(2.0), -(3.0)), vec3<f32>(-(4.0), -(5.0), -(6.0)), vec3<f32>(-(7.0), -(8.0), -(9.0)));
|
||||||
let r : mat3x3<f32> = (a - b);
|
let r : mat3x3<f32> = (a - b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@compute @workgroup_size(1)
|
@compute @workgroup_size(1)
|
||||||
fn f() {
|
fn f() {
|
||||||
let b : u32 = bitcast<u32>(-2147483648);
|
let b : u32 = bitcast<u32>(-(2147483648));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn add_int_min_explicit() -> i32 {
|
fn add_int_min_explicit() -> i32 {
|
||||||
var a = -2147483648;
|
var a = -(2147483648);
|
||||||
var b = (a + 1);
|
var b = (a + 1);
|
||||||
var c = (-2147483648 + 1);
|
var c = (-(2147483648) + 1);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,17 +77,17 @@ fn comp_main(@builtin(global_invocation_id) gl_GlobalInvocationID : vec3<u32>) {
|
||||||
vVel = (((vVel + (cMass * params.rule1Scale)) + (colVel * params.rule2Scale)) + (cVel * params.rule3Scale));
|
vVel = (((vVel + (cMass * params.rule1Scale)) + (colVel * params.rule2Scale)) + (cVel * params.rule3Scale));
|
||||||
vVel = (normalize(vVel) * clamp(length(vVel), 0.0, 0.1));
|
vVel = (normalize(vVel) * clamp(length(vVel), 0.0, 0.1));
|
||||||
vPos = (vPos + (vVel * params.deltaT));
|
vPos = (vPos + (vVel * params.deltaT));
|
||||||
if ((vPos.x < -1.0)) {
|
if ((vPos.x < -(1.0))) {
|
||||||
vPos.x = 1.0;
|
vPos.x = 1.0;
|
||||||
}
|
}
|
||||||
if ((vPos.x > 1.0)) {
|
if ((vPos.x > 1.0)) {
|
||||||
vPos.x = -1.0;
|
vPos.x = -(1.0);
|
||||||
}
|
}
|
||||||
if ((vPos.y < -1.0)) {
|
if ((vPos.y < -(1.0))) {
|
||||||
vPos.y = 1.0;
|
vPos.y = 1.0;
|
||||||
}
|
}
|
||||||
if ((vPos.y > 1.0)) {
|
if ((vPos.y > 1.0)) {
|
||||||
vPos.y = -1.0;
|
vPos.y = -(1.0);
|
||||||
}
|
}
|
||||||
particlesB.particles[index].pos = vPos;
|
particlesB.particles[index].pos = vPos;
|
||||||
particlesB.particles[index].vel = vVel;
|
particlesB.particles[index].vel = vVel;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const pos = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));
|
const pos = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-(0.5), -(0.5)), vec2(0.5, -(0.5)));
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vtx_main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
fn vtx_main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||||
|
|
Loading…
Reference in New Issue