Adding an unique id to Instruction generated by IRContext
authorAlan Baker <alanbaker@google.com>
Tue, 14 Nov 2017 19:11:50 +0000 (14:11 -0500)
committerDavid Neto <dneto@google.com>
Mon, 20 Nov 2017 22:49:10 +0000 (17:49 -0500)
commita771713e4250358f2248eba95a16e362c8524b41
treec214410385c3783ec7de9e26d90c967ada8765e7
parent3214c3b0cac534a37adcd699ae792d5794752ea2
Adding an unique id to Instruction generated by IRContext

Each instruction is given an unique id that can be used for ordering
purposes. The ids are generated via the IRContext.

Major changes:
* Instructions now contain a uint32_t for unique id and a cached context
pointer
 * Most constructors have been modified to take a context as input
 * unfortunately I cannot remove the default and copy constructors, but
 developers should avoid these
* Added accessors to parents of basic block and function
* Removed the copy constructors for BasicBlock and Function and replaced
them with Clone functions
* Reworked BuildModule to return an IRContext owning the built module
 * Since all instructions require a context, the context now becomes the
basic unit for IR
* Added a constructor to context to create an owned module internally
* Replaced uses of Instruction's copy constructor with Clone whereever I
found them
* Reworked the linker functionality to perform clones into a different
context instead of moves
* Updated many tests to be consistent with the above changes
 * Still need to add new tests to cover added functionality
* Added comparison operators to Instruction
* Added an internal option to LinkerOptions to verify merged ids are
unique
* Added a test for the linker to verify merged ids are unique

* Updated MergeReturnPass to supply a context
* Updated DecorationManager to supply a context for cloned decorations

* Reworked several portions of the def use tests in anticipation of next
set of changes
39 files changed:
include/spirv-tools/linker.hpp
source/link/linker.cpp
source/opt/aggressive_dead_code_elim_pass.cpp
source/opt/basic_block.cpp
source/opt/basic_block.h
source/opt/build_module.cpp
source/opt/build_module.h
source/opt/cfg.cpp
source/opt/common_uniform_elim_pass.cpp
source/opt/dead_branch_elim_pass.cpp
source/opt/decoration_manager.cpp
source/opt/flatten_decoration_pass.cpp
source/opt/fold_spec_constant_op_and_composite_pass.cpp
source/opt/function.cpp
source/opt/function.h
source/opt/inline_pass.cpp
source/opt/instruction.cpp
source/opt/instruction.h
source/opt/ir_context.h
source/opt/ir_loader.cpp
source/opt/ir_loader.h
source/opt/local_access_chain_convert_pass.cpp
source/opt/mem_pass.cpp
source/opt/merge_return_pass.cpp
source/opt/module.cpp
source/opt/module.h
source/opt/optimizer.cpp
source/opt/strength_reduction_pass.cpp
test/link/CMakeLists.txt
test/link/unique_ids_test.cpp [new file with mode: 0644]
test/opt/def_use_test.cpp
test/opt/instruction_test.cpp
test/opt/ir_context_test.cpp
test/opt/ir_loader_test.cpp
test/opt/module_test.cpp
test/opt/pass_fixture.h
test/opt/pass_manager_test.cpp
test/opt/pass_test.cpp
test/opt/type_manager_test.cpp