std::unique_ptr<ir::Module> BuildModule(spv_target_env env,
MessageConsumer consumer,
- const std::vector<uint32_t>& binary) {
+ const uint32_t* binary,
+ const size_t size) {
auto context = spvContextCreate(env);
SetContextMessageConsumer(context, consumer);
auto module = MakeUnique<ir::Module>();
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);
t.SetMessageConsumer(consumer);
std::vector<uint32_t> binary;
if (!t.Assemble(text, &binary)) return nullptr;
- return BuildModule(env, consumer, binary);
+ return BuildModule(env, consumer, binary.data(), binary.size());
}
} // namespace spvtools
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<ir::Module> BuildModule(spv_target_env env,
MessageConsumer consumer,
- const std::vector<uint32_t>& 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
spvDiagnosticDestroy(diagnostic);
spvContextDestroy(context);
- std::unique_ptr<ir::Module> module =
- BuildModule(target_env, pass_manager.consumer(), source);
+ std::unique_ptr<ir::Module> module = BuildModule(
+ target_env, pass_manager.consumer(), source.data(), source.size());
pass_manager.Run(module.get());
std::vector<uint32_t> target;