Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic SSA Validation #27

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7acf07c
Update Validate tests to assignment oriented form
umar456 Nov 18, 2015
d6aaa17
Fix isValid for functions with multiple parameters
umar456 Nov 22, 2015
8033cdb
Basic SSA validation.
umar456 Nov 23, 2015
da35d28
Update style to follow the Google C++ style guide
umar456 Nov 24, 2015
b0a5367
Remove color-diagnostics flag.
umar456 Nov 25, 2015
3949bf4
Bugfixes to SSA validation. Additional Tests
umar456 Nov 25, 2015
70b6cf0
Return SPV_ERROR_INVALID_ID for ID related errors
umar456 Nov 26, 2015
3017901
Tests for OpMemberDecorate; Minimize test cases
umar456 Nov 26, 2015
73bfa70
Simplify SSAPass Logic
umar456 Nov 26, 2015
9691d3c
Fix OpGroupDecorate SSAPass. Additional Unit Tests
umar456 Nov 27, 2015
fc71d20
Remove templates for forward declaration function
umar456 Nov 30, 2015
9f8db87
Documentation; Minor formatting fixes
umar456 Nov 30, 2015
92d6b47
Renamed validate file;Extracted common TestFixture
umar456 Nov 30, 2015
ad5add6
Additional unit tests for Device Enqueue ops
umar456 Dec 2, 2015
0fbc35c
Formatting; Style; Documentation; Unit Tests
umar456 Dec 3, 2015
2b61dbd
Update Fixtures to return results;Update unit test
umar456 Dec 4, 2015
be947ef
Fixed OpConstant order in SSA unit tests
umar456 Dec 4, 2015
89c4a21
Remove regex to avoid problems with gcc.
umar456 Dec 6, 2015
ee4c90a
Add OpName support in diag message and unit tests
umar456 Dec 7, 2015
71b49c4
Fix missing label in func;Phi tests;LoopMerge Fix
umar456 Dec 8, 2015
64190ec
Addressed feedback
umar456 Dec 9, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build*
.ycm_extra_conf.py*
compile_commands.json
/external/googletest/
/TAGS
/.clang_complete
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function(default_compile_options TARGET)
target_compile_options(${TARGET} PRIVATE -fno-omit-frame-pointer)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(${TARGET} PRIVATE -fcolor-diagnostics)
set(SPIRV_USE_SANITIZER "" CACHE STRING
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would have been put under a configuration option. But meh, I don't care enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned this in the commit message. This is clang's default argument for terminals that support color. Terminals which do not support color display ASCII escape codes if that option is included. This was causing issues in Emacs which automatically converts the line output into links so color is not necessary.

"Use the clang sanitizer [address|memory|thread|...]")
if(NOT "${SPIRV_USE_SANITIZER}" STREQUAL "")
Expand Down Expand Up @@ -213,7 +212,8 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES})
${CMAKE_CURRENT_SOURCE_DIR}/test/TextToBinary.TypeDeclaration.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/TextWordGet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/UnitSPIRV.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/Validate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/ValidateFixtures.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/Validate.SSA.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/ValidateID.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp)

Expand Down
4 changes: 3 additions & 1 deletion include/libspirv/libspirv.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ typedef enum spv_validate_options_t {
SPV_VALIDATE_LAYOUT_BIT = SPV_BIT(1),
SPV_VALIDATE_ID_BIT = SPV_BIT(2),
SPV_VALIDATE_RULES_BIT = SPV_BIT(3),
SPV_VALIDATE_SSA_BIT = SPV_BIT(4),
SPV_VALIDATE_ALL = SPV_VALIDATE_BASIC_BIT | SPV_VALIDATE_LAYOUT_BIT |
SPV_VALIDATE_ID_BIT | SPV_VALIDATE_RULES_BIT,
SPV_VALIDATE_ID_BIT | SPV_VALIDATE_RULES_BIT |
SPV_VALIDATE_SSA_BIT,
SPV_FORCE_32_BIT_ENUM(spv_validation_options_t)
} spv_validate_options_t;

Expand Down
10 changes: 5 additions & 5 deletions source/binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,17 +444,17 @@ spv_result_t Parser::parseOperand(size_t inst_offset,

switch (type) {
case SPV_OPERAND_TYPE_TYPE_ID:
if (!word) return diagnostic() << "Error: Type Id is 0";
if (!word) return diagnostic(SPV_ERROR_INVALID_ID) << "Error: Type Id is 0";
inst->type_id = word;
break;

case SPV_OPERAND_TYPE_RESULT_ID:
if (!word) return diagnostic() << "Error: Result Id is 0";
if (!word) return diagnostic(SPV_ERROR_INVALID_ID) << "Error: Result Id is 0";
inst->result_id = word;
// Save the result ID to type ID mapping.
// In the grammar, type ID always appears before result ID.
if (_.id_to_type_id.find(inst->result_id) != _.id_to_type_id.end())
return diagnostic() << "Id " << inst->result_id
return diagnostic(SPV_ERROR_INVALID_ID) << "Id " << inst->result_id
<< " is defined more than once";
// Record it.
// A regular value maps to its type. Some instructions (e.g. OpLabel)
Expand All @@ -467,15 +467,15 @@ spv_result_t Parser::parseOperand(size_t inst_offset,

case SPV_OPERAND_TYPE_ID:
case SPV_OPERAND_TYPE_OPTIONAL_ID:
if (!word) return diagnostic() << "Id is 0";
if (!word) return diagnostic(SPV_ERROR_INVALID_ID) << "Id is 0";
parsed_operand.type = SPV_OPERAND_TYPE_ID;

if (inst->opcode == SpvOpExtInst && parsed_operand.offset == 3) {
// The current word is the extended instruction set Id.
// Set the extended instruction set type for the current instruction.
auto ext_inst_type_iter = _.import_id_to_ext_inst_type.find(word);
if (ext_inst_type_iter == _.import_id_to_ext_inst_type.end()) {
return diagnostic()
return diagnostic(SPV_ERROR_INVALID_ID)
<< "OpExtInst set Id " << word
<< " does not reference an OpExtInstImport result Id";
}
Expand Down
Loading