build_module.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2016 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef SOURCE_OPT_BUILD_MODULE_H_
  15. #define SOURCE_OPT_BUILD_MODULE_H_
  16. #include <memory>
  17. #include <string>
  18. #include "source/opt/ir_context.h"
  19. #include "source/opt/module.h"
  20. #include "spirv-tools/libspirv.hpp"
  21. namespace spvtools {
  22. // Builds an Module returns the owning IRContext from the given SPIR-V
  23. // |binary|. |size| specifies number of words in |binary|. The |binary| will be
  24. // decoded according to the given target |env|. Returns nullptr if errors occur
  25. // and sends the errors to |consumer|.
  26. std::unique_ptr<opt::IRContext> BuildModule(spv_target_env env,
  27. MessageConsumer consumer,
  28. const uint32_t* binary,
  29. size_t size);
  30. // Builds an Module and returns the owning IRContext from the given
  31. // SPIR-V assembly |text|. The |text| will be encoded according to the given
  32. // target |env|. Returns nullptr if errors occur and sends the errors to
  33. // |consumer|.
  34. std::unique_ptr<opt::IRContext> BuildModule(
  35. spv_target_env env, MessageConsumer consumer, const std::string& text,
  36. uint32_t assemble_options = SpirvTools::kDefaultAssembleOption);
  37. } // namespace spvtools
  38. #endif // SOURCE_OPT_BUILD_MODULE_H_