From 5494dd43342b19a3f5760e1d809c482526426590 Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 15 Sep 2015 16:41:38 -0400 Subject: [PATCH] Assembler test for Storage Class enum values This covers the storage classes in SPIR-V Rev31. Rev32 has more. --- source/operand.cpp | 1 + test/TextToBinary.Memory.cpp | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/source/operand.cpp b/source/operand.cpp index 91814b0..372cfd7 100644 --- a/source/operand.cpp +++ b/source/operand.cpp @@ -294,6 +294,7 @@ static const spv_operand_desc_t executionModeEntries[] = { }; static const spv_operand_desc_t storageClassEntries[] = { + // TODO(dneto): There are more storage classes in Rev32 and later. {"UniformConstant", StorageClassUniformConstant, SPV_OPCODE_FLAGS_NONE, diff --git a/test/TextToBinary.Memory.cpp b/test/TextToBinary.Memory.cpp index 812aa39..53c0b05 100644 --- a/test/TextToBinary.Memory.cpp +++ b/test/TextToBinary.Memory.cpp @@ -73,9 +73,40 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryMemoryAccessTest, MemoryAccessTest, #undef CASE // clang-format on +// Test Storage Class enum values + +using StorageClassTest = test_fixture::TextToBinaryTestBase< + ::testing::TestWithParam>>; + +TEST_P(StorageClassTest, AnyStorageClass) { + std::string input = "%1 = OpVariable %2 " + GetParam().name; + EXPECT_THAT(CompiledInstructions(input), + Eq(MakeInstruction(spv::OpVariable, {2, 1, GetParam().value}))); +} + +// clang-format off +#define CASE(NAME) { spv::StorageClass##NAME, #NAME, {} } +INSTANTIATE_TEST_CASE_P(TextToBinaryStorageClassTest, StorageClassTest, + ::testing::ValuesIn(std::vector>{ + // TODO(dneto): There are more storage classes in Rev32 and later. + CASE(UniformConstant), + CASE(Input), + CASE(Uniform), + CASE(Output), + CASE(WorkgroupLocal), + CASE(WorkgroupGlobal), + CASE(PrivateGlobal), + CASE(Function), + CASE(Generic), + CASE(AtomicCounter), + CASE(Image), + })); +#undef CASE +// clang-format on + // TODO(dneto): Combination of memory access masks. -// TODO(dneto): OpVariable +// TODO(dneto): OpVariable with initializers // TODO(dneto): OpImageTexelPointer // TODO(dneto): OpLoad // TODO(dneto): OpStore -- 2.7.4