aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlan Baker <alanbaker@google.com>2017-11-14 14:11:50 -0500
committerDavid Neto <dneto@google.com>2017-11-20 17:49:10 -0500
commita771713e4250358f2248eba95a16e362c8524b41 (patch)
treec214410385c3783ec7de9e26d90c967ada8765e7 /include
parent3214c3b0cac534a37adcd699ae792d5794752ea2 (diff)
downloadspirv-tools-a771713e4250358f2248eba95a16e362c8524b41.tar.gz
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
Diffstat (limited to 'include')
-rw-r--r--include/spirv-tools/linker.hpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/spirv-tools/linker.hpp b/include/spirv-tools/linker.hpp
index 43c725da..a36aa75f 100644
--- a/include/spirv-tools/linker.hpp
+++ b/include/spirv-tools/linker.hpp
@@ -26,7 +26,9 @@ namespace spvtools {
class LinkerOptions {
public:
- LinkerOptions() : createLibrary_(false) {}
+ LinkerOptions()
+ : createLibrary_(false),
+ verifyIds_(false) {}
// Returns whether a library or an executable should be produced by the
// linking phase.
@@ -36,13 +38,25 @@ class LinkerOptions {
// The returned value will be true if creating a library, and false if
// creating an executable.
bool GetCreateLibrary() const { return createLibrary_; }
+
// Sets whether a library or an executable should be produced.
void SetCreateLibrary(bool create_library) {
createLibrary_ = create_library;
}
+ // Returns whether to verify the uniqueness of the unique ids in the merged
+ // context.
+ bool GetVerifyIds() const { return verifyIds_; }
+
+ // Sets whether to verify the uniqueness of the unique ids in the merged
+ // context.
+ void SetVerifyIds(bool verifyIds) {
+ verifyIds_ = verifyIds;
+ }
+
private:
bool createLibrary_;
+ bool verifyIds_;
};
class Linker {