summaryrefslogtreecommitdiff
path: root/source/val
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2018-07-09 23:18:44 -0400
committerGitHub <noreply@github.com>2018-07-09 23:18:44 -0400
commit43144e36c15c687e6edc2e5f4f166e1f9ec1d7eb (patch)
tree4bceabf01517f2a23b6e16c25fe863dfee6805c4 /source/val
parent48326d443e434f55eb50a7cfc9acdc968daad5e3 (diff)
Move the validation code into the val:: namespace (#1682)
This CL moves the validation code to the val:: namespace. This makes it clearer which instance of the Instruction and other classes are being referred too.
Diffstat (limited to 'source/val')
-rw-r--r--source/val/basic_block.cpp3
-rw-r--r--source/val/basic_block.h2
-rw-r--r--source/val/construct.cpp2
-rw-r--r--source/val/construct.h2
-rw-r--r--source/val/decoration.h2
-rw-r--r--source/val/function.cpp2
-rw-r--r--source/val/function.h2
-rw-r--r--source/val/instruction.cpp2
-rw-r--r--source/val/instruction.h7
-rw-r--r--source/val/validation_state.cpp6
-rw-r--r--source/val/validation_state.h2
11 files changed, 28 insertions, 4 deletions
diff --git a/source/val/basic_block.cpp b/source/val/basic_block.cpp
index 409af770..d70a3f00 100644
--- a/source/val/basic_block.cpp
+++ b/source/val/basic_block.cpp
@@ -21,6 +21,7 @@
using std::vector;
namespace spvtools {
+namespace val {
BasicBlock::BasicBlock(uint32_t label_id)
: id_(label_id),
@@ -144,4 +145,6 @@ bool operator!=(const BasicBlock::DominatorIterator& lhs,
const BasicBlock*& BasicBlock::DominatorIterator::operator*() {
return current_;
}
+
+} // namespace val
} // namespace spvtools
diff --git a/source/val/basic_block.h b/source/val/basic_block.h
index b3641e59..8c7312f3 100644
--- a/source/val/basic_block.h
+++ b/source/val/basic_block.h
@@ -25,6 +25,7 @@
#include <vector>
namespace spvtools {
+namespace val {
enum BlockType : uint32_t {
kBlockTypeUndefined,
@@ -241,6 +242,7 @@ bool operator==(const BasicBlock::DominatorIterator& lhs,
bool operator!=(const BasicBlock::DominatorIterator& lhs,
const BasicBlock::DominatorIterator& rhs);
+} // namespace val
} // namespace spvtools
#endif /// LIBSPIRV_VAL_BASICBLOCK_H_
diff --git a/source/val/construct.cpp b/source/val/construct.cpp
index c07cc56a..6a70ab25 100644
--- a/source/val/construct.cpp
+++ b/source/val/construct.cpp
@@ -20,6 +20,7 @@
#include <unordered_set>
namespace spvtools {
+namespace val {
Construct::Construct(ConstructType construct_type, BasicBlock* entry,
BasicBlock* exit, std::vector<Construct*> constructs)
@@ -122,4 +123,5 @@ Construct::ConstructBlockSet Construct::blocks(Function* function) const {
return construct_blocks;
}
+} // namespace val
} // namespace spvtools
diff --git a/source/val/construct.h b/source/val/construct.h
index 7cec18d3..0de63f65 100644
--- a/source/val/construct.h
+++ b/source/val/construct.h
@@ -22,6 +22,7 @@
#include <vector>
namespace spvtools {
+namespace val {
/// Functor for ordering BasicBlocks. BasicBlock pointers must not be null.
struct less_than_id {
@@ -144,6 +145,7 @@ class Construct {
BasicBlock* exit_block_;
};
+} // namespace val
} // namespace spvtools
#endif /// LIBSPIRV_VAL_CONSTRUCT_H_
diff --git a/source/val/decoration.h b/source/val/decoration.h
index 6e48ad2a..1c5a57ac 100644
--- a/source/val/decoration.h
+++ b/source/val/decoration.h
@@ -22,6 +22,7 @@
#include "latest_version_spirv_header.h"
namespace spvtools {
+namespace val {
// An object of this class represents a specific decoration including its
// parameters (if any). Decorations are used by OpDecorate and OpMemberDecorate,
@@ -82,6 +83,7 @@ class Decoration {
int struct_member_index_;
};
+} // namespace val
} // namespace spvtools
#endif /// LIBSPIRV_VAL_DECORATION_H_
diff --git a/source/val/function.cpp b/source/val/function.cpp
index 51ee7e45..9f02a489 100644
--- a/source/val/function.cpp
+++ b/source/val/function.cpp
@@ -35,6 +35,7 @@ using std::tie;
using std::vector;
namespace spvtools {
+namespace val {
// Universal Limit of ResultID + 1
static const uint32_t kInvalidId = 0x400000;
@@ -386,4 +387,5 @@ bool Function::IsCompatibleWithExecutionModel(SpvExecutionModel model,
return return_value;
}
+} // namespace val
} // namespace spvtools
diff --git a/source/val/function.h b/source/val/function.h
index 2c567ff1..61f9888d 100644
--- a/source/val/function.h
+++ b/source/val/function.h
@@ -29,6 +29,7 @@
#include "val/construct.h"
namespace spvtools {
+namespace val {
struct bb_constr_type_pair_hash {
std::size_t operator()(
@@ -351,6 +352,7 @@ class Function {
std::set<uint32_t> function_call_targets_;
};
+} // namespace val
} // namespace spvtools
#endif /// LIBSPIRV_VAL_FUNCTION_H_
diff --git a/source/val/instruction.cpp b/source/val/instruction.cpp
index f0e6e3b9..1e2bb76a 100644
--- a/source/val/instruction.cpp
+++ b/source/val/instruction.cpp
@@ -19,6 +19,7 @@
using std::make_pair;
namespace spvtools {
+namespace val {
#define OPERATOR(OP) \
bool operator OP(const Instruction& lhs, const Instruction& rhs) { \
@@ -49,4 +50,5 @@ void Instruction::RegisterUse(const Instruction* inst, uint32_t index) {
uses_.push_back(make_pair(inst, index));
}
+} // namespace val
} // namespace spvtools
diff --git a/source/val/instruction.h b/source/val/instruction.h
index 6636ae96..c47e6bad 100644
--- a/source/val/instruction.h
+++ b/source/val/instruction.h
@@ -25,6 +25,7 @@
#include "table.h"
namespace spvtools {
+namespace val {
class BasicBlock;
class Function;
@@ -113,18 +114,20 @@ OPERATOR(<);
OPERATOR(==);
#undef OPERATOR
+} // namespace val
} // namespace spvtools
// custom specialization of std::hash for Instruction
namespace std {
template <>
-struct hash<spvtools::Instruction> {
- typedef spvtools::Instruction argument_type;
+struct hash<spvtools::val::Instruction> {
+ typedef spvtools::val::Instruction argument_type;
typedef std::size_t result_type;
result_type operator()(const argument_type& inst) const {
return hash<uint32_t>()(inst.id());
}
};
+
} // namespace std
#endif // LIBSPIRV_VAL_INSTRUCTION_H_
diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp
index 31865935..afcc7863 100644
--- a/source/val/validation_state.cpp
+++ b/source/val/validation_state.cpp
@@ -30,8 +30,9 @@ using std::unordered_map;
using std::vector;
namespace spvtools {
-
+namespace val {
namespace {
+
bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) {
// See Section 2.4
bool out = false;
@@ -139,7 +140,7 @@ bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) {
return out;
}
-} // anonymous namespace
+} // namespace
ValidationState_t::ValidationState_t(const spv_const_context ctx,
const spv_const_validator_options opt,
@@ -878,4 +879,5 @@ std::string ValidationState_t::Disassemble(const uint32_t* words,
words_, num_words_, disassembly_options);
}
+} // namespace val
} // namespace spvtools
diff --git a/source/val/validation_state.h b/source/val/validation_state.h
index cb378ba1..463cb232 100644
--- a/source/val/validation_state.h
+++ b/source/val/validation_state.h
@@ -35,6 +35,7 @@
#include "val/instruction.h"
namespace spvtools {
+namespace val {
/// This enum represents the sections of a SPIRV module. See section 2.4
/// of the SPIRV spec for additional details of the order. The enumerant values
@@ -597,6 +598,7 @@ class ValidationState_t {
const std::vector<uint32_t> empty_ids_;
};
+} // namespace val
} // namespace spvtools
#endif /// LIBSPIRV_VAL_VALIDATIONSTATE_H_