Checks that after running the given optimizer |opt| on the given |original| source code, we can get the given |optimized| source code.
| 225 | // Checks that after running the given optimizer |opt| on the given |original| |
| 226 | // source code, we can get the given |optimized| source code. |
| 227 | void CheckOptimization(const std::string& original, |
| 228 | const std::string& optimized, const Optimizer& opt) { |
| 229 | SpirvTools t(SPV_ENV_UNIVERSAL_1_1); |
| 230 | std::vector<uint32_t> original_binary; |
| 231 | ASSERT_TRUE(t.Assemble(original, &original_binary)); |
| 232 | |
| 233 | std::vector<uint32_t> optimized_binary; |
| 234 | EXPECT_TRUE(opt.Run(original_binary.data(), original_binary.size(), |
| 235 | &optimized_binary)); |
| 236 | |
| 237 | std::string optimized_text; |
| 238 | EXPECT_TRUE(t.Disassemble(optimized_binary, &optimized_text)); |
| 239 | EXPECT_EQ(optimized, optimized_text); |
| 240 | } |
| 241 | |
| 242 | TEST(CppInterface, OptimizeEmptyModule) { |
| 243 | SpirvTools t(SPV_ENV_UNIVERSAL_1_1); |