From 508dc3a95de50de4a4d07d0a72a18e40d55b0e2e Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Aug 2023 06:05:26 +0800 Subject: Allow bitwise or expressions and numeric literals in spirv_asm blocks (#3157) * Add -spirv-core-grammar option to load alternate spirv defs Also embed a version to use by default * Use perfect hash for spv op lookup * Neaten perfect hash embedding * Refactor spirv grammar lookup in preperation for more kinds of lookups * Load spirv capability list from spec * Add all SPIR-V enums to lookup table * regenerate vs projects * appease msvc * Use string slices for spir-v core grammar lookups * wiggle * comment * Add OpInfo for spv ops * regenerate vs projects * Embed op names * Add min/max operand counts and enum categories to spirv info * neaten * Operand kinds for spirv ops * Store and embed all information relating to spirv enums and qualifiers * Use SPIR-V spec to position instructions in spirv_asm blocks * Neaten spir-v info embedding * Neaten perfect hash embedding * Add assignment syntax to spirv_asm snippets * Better errors for spirv_asm parser * Add warning for too many operands in spirv asm * squash warnings * neaten * test wiggle * Lookup enums for spirv * Put OpCapability and OpExtension in the correct place for spirv_asm blocks * Tests for OpCapability and OpExtension * ci wiggle * Add expected failure * Allow raising immediate values to constant ids where necessary in spirv_asm blocks * Allow bitwise or expressions and numeric literals in spirv_asm blocks * test numeric literals * Fix memory issues. * fix. --------- Co-authored-by: Yong He --- .../spirv-asm/wrong-assignment-opcode.slang | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/language-feature/spirv-asm/wrong-assignment-opcode.slang (limited to 'tests/language-feature/spirv-asm/wrong-assignment-opcode.slang') diff --git a/tests/language-feature/spirv-asm/wrong-assignment-opcode.slang b/tests/language-feature/spirv-asm/wrong-assignment-opcode.slang new file mode 100644 index 000000000..4afbb0417 --- /dev/null +++ b/tests/language-feature/spirv-asm/wrong-assignment-opcode.slang @@ -0,0 +1,41 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +RWStructuredBuffer buf; + +// +// This test checks that we correctly diagnose trying to use the assignment and +// typed assignment syntax with operands with no result type or id. +// +// By virtue of these tests being in the same file, we also check the error +// recovery for the asm block parser. +// +int foo(const int constParam) +{ + // Doesn't have a result type + spirv_asm + { + %bar : %wrong = OpTypeInt 32 0 + // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 29104: cannot use this 'x : = OpTypeInt...' syntax because OpTypeInt does not have a operand + + }; + + // Doesn't have a result value + spirv_asm + { + %foo = OpStore 1 2; + // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 29104: cannot use this 'x = OpStore...' syntax because OpStore does not have a operand + }; + + // garbage + spirv_asm + { + %foo =; + // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20003: unexpected ';' + %foo :; + // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20003: unexpected ';' + %foo : bar; + // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20001: unexpected ';', expected '=' + %foo : bar =; + // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20003: unexpected ';' + }; +} -- cgit v1.2.3