From: Lei Zhang Date: Tue, 20 Sep 2016 20:44:24 +0000 (-0400) Subject: Change BuildModule() to accept pointer-size pair for binary. X-Git-Tag: upstream/2018.6~1041 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8dbed0455c04e42ef6b833dbd70a8c79a12ec0c;p=platform%2Fupstream%2FSPIRV-Tools.git Change BuildModule() to accept pointer-size pair for binary. --- diff --git a/source/opt/build_module.cpp b/source/opt/build_module.cpp index d42c7f8..ba4d1f3 100644 --- a/source/opt/build_module.cpp +++ b/source/opt/build_module.cpp @@ -44,16 +44,16 @@ spv_result_t SetSpvInst(void* builder, const spv_parsed_instruction_t* inst) { std::unique_ptr BuildModule(spv_target_env env, MessageConsumer consumer, - const std::vector& binary) { + const uint32_t* binary, + const size_t size) { auto context = spvContextCreate(env); SetContextMessageConsumer(context, consumer); auto module = MakeUnique(); ir::IrLoader loader(context->consumer, module.get()); - spv_result_t status = - spvBinaryParse(context, &loader, binary.data(), binary.size(), - SetSpvHeader, SetSpvInst, nullptr); + spv_result_t status = spvBinaryParse(context, &loader, binary, size, + SetSpvHeader, SetSpvInst, nullptr); loader.EndModule(); spvContextDestroy(context); @@ -68,7 +68,7 @@ std::unique_ptr BuildModule(spv_target_env env, t.SetMessageConsumer(consumer); std::vector binary; if (!t.Assemble(text, &binary)) return nullptr; - return BuildModule(env, consumer, binary); + return BuildModule(env, consumer, binary.data(), binary.size()); } } // namespace spvtools diff --git a/source/opt/build_module.h b/source/opt/build_module.h index 65d5107..e3464c8 100644 --- a/source/opt/build_module.h +++ b/source/opt/build_module.h @@ -25,12 +25,13 @@ namespace spvtools { -// Builds and returns an ir::Module from the given SPIR-V |binary|. The |binary| -// will be decoded according to the given target |env|. Returns nullptr if erors -// occur and sends the errors to |consumer|. +// Builds and returns an ir::Module from the given SPIR-V |binary|. |size| +// specifies number of words in |binary|. The |binary| will be decoded +// according to the given target |env|. Returns nullptr if erors occur and +// sends the errors to |consumer|. std::unique_ptr BuildModule(spv_target_env env, MessageConsumer consumer, - const std::vector& binary); + const uint32_t* binary, size_t size); // Builds and returns an ir::Module from the given SPIR-V assembly |text|. // The |text| will be encoded according to the given target |env|. Returns diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 5f51669..cc10dfc 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -140,8 +140,8 @@ int main(int argc, char** argv) { spvDiagnosticDestroy(diagnostic); spvContextDestroy(context); - std::unique_ptr module = - BuildModule(target_env, pass_manager.consumer(), source); + std::unique_ptr module = BuildModule( + target_env, pass_manager.consumer(), source.data(), source.size()); pass_manager.Run(module.get()); std::vector target;