2016-09-09 18:45:18 +00:00
|
|
|
// Copyright (c) 2016 Google Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-08-03 12:05:33 +00:00
|
|
|
#ifndef SOURCE_OPT_BUILD_MODULE_H_
|
|
|
|
#define SOURCE_OPT_BUILD_MODULE_H_
|
2016-09-09 18:45:18 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
2018-08-03 19:06:09 +00:00
|
|
|
#include "source/opt/ir_context.h"
|
|
|
|
#include "source/opt/module.h"
|
2016-09-16 20:12:04 +00:00
|
|
|
#include "spirv-tools/libspirv.hpp"
|
2016-09-09 18:45:18 +00:00
|
|
|
|
|
|
|
namespace spvtools {
|
|
|
|
|
2024-06-17 13:54:18 +00:00
|
|
|
// Builds a Module and returns the owning IRContext from the given SPIR-V
|
2017-11-14 19:11:50 +00:00
|
|
|
// |binary|. |size| specifies number of words in |binary|. The |binary| will be
|
|
|
|
// decoded according to the given target |env|. Returns nullptr if errors occur
|
2020-11-25 19:54:32 +00:00
|
|
|
// and sends the errors to |consumer|. When |extra_line_tracking| is true,
|
|
|
|
// extra OpLine instructions are injected to better presere line numbers while
|
|
|
|
// later transforms mutate the module.
|
|
|
|
std::unique_ptr<opt::IRContext> BuildModule(spv_target_env env,
|
|
|
|
MessageConsumer consumer,
|
|
|
|
const uint32_t* binary, size_t size,
|
|
|
|
bool extra_line_tracking);
|
|
|
|
|
|
|
|
// Like above, with extra line tracking turned on.
|
2018-07-09 15:32:29 +00:00
|
|
|
std::unique_ptr<opt::IRContext> BuildModule(spv_target_env env,
|
|
|
|
MessageConsumer consumer,
|
|
|
|
const uint32_t* binary,
|
|
|
|
size_t size);
|
2016-09-09 18:45:18 +00:00
|
|
|
|
2024-06-17 13:54:18 +00:00
|
|
|
// Builds a Module and returns the owning IRContext from the given
|
2017-11-14 19:11:50 +00:00
|
|
|
// SPIR-V assembly |text|. The |text| will be encoded according to the given
|
|
|
|
// target |env|. Returns nullptr if errors occur and sends the errors to
|
|
|
|
// |consumer|.
|
2018-07-09 15:32:29 +00:00
|
|
|
std::unique_ptr<opt::IRContext> BuildModule(
|
2017-04-11 19:11:04 +00:00
|
|
|
spv_target_env env, MessageConsumer consumer, const std::string& text,
|
|
|
|
uint32_t assemble_options = SpirvTools::kDefaultAssembleOption);
|
2016-09-09 18:45:18 +00:00
|
|
|
|
|
|
|
} // namespace spvtools
|
|
|
|
|
2018-08-03 12:05:33 +00:00
|
|
|
#endif // SOURCE_OPT_BUILD_MODULE_H_
|