Upgrade to C++20 and use std::span

This commit is contained in:
ReinUsesLisp
2020-07-29 05:46:50 -03:00
parent eefca56afd
commit c4ea8f4b76
18 changed files with 119 additions and 102 deletions

View File

@@ -74,13 +74,14 @@ void Module::AddCapability(spv::Capability capability) {
capabilities.insert(capability);
}
void Module::SetMemoryModel(spv::AddressingModel addressing_model_, spv::MemoryModel memory_model_) {
void Module::SetMemoryModel(spv::AddressingModel addressing_model_,
spv::MemoryModel memory_model_) {
this->addressing_model = addressing_model_;
this->memory_model = memory_model_;
}
void Module::AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point,
std::string name, const std::vector<Id>& interfaces) {
void Module::AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, std::string name,
std::span<const Id> interfaces) {
auto op{std::make_unique<Op>(spv::Op::OpEntryPoint)};
op->Add(static_cast<u32>(execution_model));
op->Add(entry_point);
@@ -90,7 +91,7 @@ void Module::AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point,
}
void Module::AddExecutionMode(Id entry_point, spv::ExecutionMode mode,
const std::vector<Literal>& literals) {
std::span<const Literal> literals) {
auto op{std::make_unique<Op>(spv::Op::OpExecutionMode)};
op->Add(entry_point);
op->Add(static_cast<u32>(mode));
@@ -123,14 +124,14 @@ Id Module::AddCode(spv::Op opcode, std::optional<u32> id) {
}
Id Module::AddDeclaration(std::unique_ptr<Op> op) {
const auto& found{std::find_if(declarations.begin(), declarations.end(),
[&op](const auto& other) { return *other == *op; })};
const auto found = std::find_if(declarations.begin(), declarations.end(),
[&op](const auto& other) { return op->Equal(*other); });
if (found != declarations.end()) {
return found->get();
}
const auto id = op.get();
declarations.push_back(std::move(op));
bound++;
++bound;
return id;
}