aboutsummaryrefslogtreecommitdiff
path: root/test/opt/fold_test.cpp
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2018-07-09 11:32:29 -0400
committerGitHub <noreply@github.com>2018-07-09 11:32:29 -0400
commite6b953361dd00181e7317eb0efa31fdf6802f79a (patch)
treeaa18af5ee2888ed930bffeb303b1844d69088230 /test/opt/fold_test.cpp
parent50312ca146dfc7d3ee59facb7d2f171b9ea4be51 (diff)
downloadspirv-tools-e6b953361dd00181e7317eb0efa31fdf6802f79a.tar.gz
Move the ir namespace to opt. (#1680)
This CL moves the files in opt/ to consistenly be under the opt:: namespace. This frees up the ir:: namespace so it can be used to make a shared ir represenation.
Diffstat (limited to 'test/opt/fold_test.cpp')
-rw-r--r--test/opt/fold_test.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/test/opt/fold_test.cpp b/test/opt/fold_test.cpp
index c00e95ae..7ee96bda 100644
--- a/test/opt/fold_test.cpp
+++ b/test/opt/fold_test.cpp
@@ -37,7 +37,7 @@ using namespace spvtools;
using spvtools::opt::analysis::DefUseManager;
#ifdef SPIRV_EFFCEE
-std::string Disassemble(const std::string& original, ir::IRContext* context,
+std::string Disassemble(const std::string& original, opt::IRContext* context,
uint32_t disassemble_options = 0) {
std::vector<uint32_t> optimized_bin;
context->module()->ToBinary(&optimized_bin, true);
@@ -51,7 +51,7 @@ std::string Disassemble(const std::string& original, ir::IRContext* context,
return optimized_asm;
}
-void Match(const std::string& original, ir::IRContext* context,
+void Match(const std::string& original, opt::IRContext* context,
uint32_t disassemble_options = 0) {
std::string disassembly = Disassemble(original, context, disassemble_options);
auto match_result = effcee::Match(disassembly, original);
@@ -78,14 +78,14 @@ TEST_P(IntegerInstructionFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
@@ -446,14 +446,14 @@ TEST_P(IntVectorInstructionFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
@@ -510,14 +510,14 @@ TEST_P(BooleanInstructionFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
@@ -1121,14 +1121,14 @@ TEST_P(FloatInstructionFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
@@ -1268,14 +1268,14 @@ TEST_P(DoubleInstructionFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
@@ -2026,14 +2026,14 @@ TEST_P(IntegerInstructionFoldingTestWithMap, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
inst = context->get_instruction_folder().FoldInstructionToConstant(inst,
tc.id_map);
@@ -2074,14 +2074,14 @@ TEST_P(BooleanInstructionFoldingTestWithMap, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
inst = context->get_instruction_folder().FoldInstructionToConstant(inst,
tc.id_map);
@@ -2124,15 +2124,15 @@ TEST_P(GeneralInstructionFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
- std::unique_ptr<ir::Instruction> original_inst(inst->Clone(context.get()));
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
@@ -3630,15 +3630,15 @@ TEST_P(ToNegateFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
- std::unique_ptr<ir::Instruction> original_inst(inst->Clone(context.get()));
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
@@ -3753,15 +3753,15 @@ TEST_P(MatchingInstructionFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
- ir::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
- std::unique_ptr<ir::Instruction> original_inst(inst->Clone(context.get()));
+ opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
+ std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
EXPECT_EQ(succeeded, tc.expected_result);
if (succeeded) {
@@ -5610,23 +5610,23 @@ TEST_P(MatchingInstructionWithNoResultFoldingTest, Case) {
const auto& tc = GetParam();
// Build module.
- std::unique_ptr<ir::IRContext> context =
+ std::unique_ptr<opt::IRContext> context =
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
ASSERT_NE(nullptr, context);
// Fold the instruction to test.
- ir::Instruction* inst = nullptr;
- ir::Function* func = &*context->module()->begin();
+ opt::Instruction* inst = nullptr;
+ opt::Function* func = &*context->module()->begin();
for(auto& bb : *func) {
- ir::Instruction* terminator = bb.terminator();
+ opt::Instruction* terminator = bb.terminator();
if (terminator->IsReturnOrAbort()) {
inst = terminator->PreviousNode();
break;
}
}
assert(inst && "Invalid test. Could not find instruction to fold.");
- std::unique_ptr<ir::Instruction> original_inst(inst->Clone(context.get()));
+ std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
EXPECT_EQ(succeeded, tc.expected_result);
if (succeeded) {