mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-10-26 02:35:27 +00:00
Updated spirv-tools.
This commit is contained in:
+22
-23
@@ -25,11 +25,9 @@
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
const uint32_t kLoopMergeContinueBlockIdInIdx = 1;
|
||||
const uint32_t kLoopMergeMergeBlockIdInIdx = 0;
|
||||
const uint32_t kSelectionMergeMergeBlockIdInIdx = 0;
|
||||
|
||||
constexpr uint32_t kLoopMergeContinueBlockIdInIdx = 1;
|
||||
constexpr uint32_t kLoopMergeMergeBlockIdInIdx = 0;
|
||||
constexpr uint32_t kSelectionMergeMergeBlockIdInIdx = 0;
|
||||
} // namespace
|
||||
|
||||
BasicBlock* BasicBlock::Clone(IRContext* context) const {
|
||||
@@ -58,7 +56,7 @@ const Instruction* BasicBlock::GetMergeInst() const {
|
||||
if (iter != cbegin()) {
|
||||
--iter;
|
||||
const auto opcode = iter->opcode();
|
||||
if (opcode == SpvOpLoopMerge || opcode == SpvOpSelectionMerge) {
|
||||
if (opcode == spv::Op::OpLoopMerge || opcode == spv::Op::OpSelectionMerge) {
|
||||
result = &*iter;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +71,7 @@ Instruction* BasicBlock::GetMergeInst() {
|
||||
if (iter != begin()) {
|
||||
--iter;
|
||||
const auto opcode = iter->opcode();
|
||||
if (opcode == SpvOpLoopMerge || opcode == SpvOpSelectionMerge) {
|
||||
if (opcode == spv::Op::OpLoopMerge || opcode == spv::Op::OpSelectionMerge) {
|
||||
result = &*iter;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +80,7 @@ Instruction* BasicBlock::GetMergeInst() {
|
||||
|
||||
const Instruction* BasicBlock::GetLoopMergeInst() const {
|
||||
if (auto* merge = GetMergeInst()) {
|
||||
if (merge->opcode() == SpvOpLoopMerge) {
|
||||
if (merge->opcode() == spv::Op::OpLoopMerge) {
|
||||
return merge;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +89,7 @@ const Instruction* BasicBlock::GetLoopMergeInst() const {
|
||||
|
||||
Instruction* BasicBlock::GetLoopMergeInst() {
|
||||
if (auto* merge = GetMergeInst()) {
|
||||
if (merge->opcode() == SpvOpLoopMerge) {
|
||||
if (merge->opcode() == spv::Op::OpLoopMerge) {
|
||||
return merge;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +98,7 @@ Instruction* BasicBlock::GetLoopMergeInst() {
|
||||
|
||||
void BasicBlock::KillAllInsts(bool killLabel) {
|
||||
ForEachInst([killLabel](Instruction* ip) {
|
||||
if (killLabel || ip->opcode() != SpvOpLabel) {
|
||||
if (killLabel || ip->opcode() != spv::Op::OpLabel) {
|
||||
ip->context()->KillInst(ip);
|
||||
}
|
||||
});
|
||||
@@ -118,10 +116,10 @@ bool BasicBlock::WhileEachSuccessorLabel(
|
||||
const std::function<bool(const uint32_t)>& f) const {
|
||||
const auto br = &insts_.back();
|
||||
switch (br->opcode()) {
|
||||
case SpvOpBranch:
|
||||
case spv::Op::OpBranch:
|
||||
return f(br->GetOperand(0).words[0]);
|
||||
case SpvOpBranchConditional:
|
||||
case SpvOpSwitch: {
|
||||
case spv::Op::OpBranchConditional:
|
||||
case spv::Op::OpSwitch: {
|
||||
bool is_first = true;
|
||||
return br->WhileEachInId([&is_first, &f](const uint32_t* idp) {
|
||||
if (!is_first) return f(*idp);
|
||||
@@ -138,13 +136,13 @@ void BasicBlock::ForEachSuccessorLabel(
|
||||
const std::function<void(uint32_t*)>& f) {
|
||||
auto br = &insts_.back();
|
||||
switch (br->opcode()) {
|
||||
case SpvOpBranch: {
|
||||
case spv::Op::OpBranch: {
|
||||
uint32_t tmp_id = br->GetOperand(0).words[0];
|
||||
f(&tmp_id);
|
||||
if (tmp_id != br->GetOperand(0).words[0]) br->SetOperand(0, {tmp_id});
|
||||
} break;
|
||||
case SpvOpBranchConditional:
|
||||
case SpvOpSwitch: {
|
||||
case spv::Op::OpBranchConditional:
|
||||
case spv::Op::OpSwitch: {
|
||||
bool is_first = true;
|
||||
br->ForEachInId([&is_first, &f](uint32_t* idp) {
|
||||
if (!is_first) f(idp);
|
||||
@@ -171,7 +169,8 @@ void BasicBlock::ForMergeAndContinueLabel(
|
||||
--ii;
|
||||
if (ii == insts_.begin()) return;
|
||||
--ii;
|
||||
if (ii->opcode() == SpvOpSelectionMerge || ii->opcode() == SpvOpLoopMerge) {
|
||||
if (ii->opcode() == spv::Op::OpSelectionMerge ||
|
||||
ii->opcode() == spv::Op::OpLoopMerge) {
|
||||
ii->ForEachInId([&f](const uint32_t* idp) { f(*idp); });
|
||||
}
|
||||
}
|
||||
@@ -182,9 +181,9 @@ uint32_t BasicBlock::MergeBlockIdIfAny() const {
|
||||
uint32_t mbid = 0;
|
||||
if (merge_ii != cbegin()) {
|
||||
--merge_ii;
|
||||
if (merge_ii->opcode() == SpvOpLoopMerge) {
|
||||
if (merge_ii->opcode() == spv::Op::OpLoopMerge) {
|
||||
mbid = merge_ii->GetSingleWordInOperand(kLoopMergeMergeBlockIdInIdx);
|
||||
} else if (merge_ii->opcode() == SpvOpSelectionMerge) {
|
||||
} else if (merge_ii->opcode() == spv::Op::OpSelectionMerge) {
|
||||
mbid = merge_ii->GetSingleWordInOperand(kSelectionMergeMergeBlockIdInIdx);
|
||||
}
|
||||
}
|
||||
@@ -204,7 +203,7 @@ uint32_t BasicBlock::ContinueBlockIdIfAny() const {
|
||||
uint32_t cbid = 0;
|
||||
if (merge_ii != cbegin()) {
|
||||
--merge_ii;
|
||||
if (merge_ii->opcode() == SpvOpLoopMerge) {
|
||||
if (merge_ii->opcode() == spv::Op::OpLoopMerge) {
|
||||
cbid = merge_ii->GetSingleWordInOperand(kLoopMergeContinueBlockIdInIdx);
|
||||
}
|
||||
}
|
||||
@@ -241,9 +240,9 @@ BasicBlock* BasicBlock::SplitBasicBlock(IRContext* context, uint32_t label_id,
|
||||
iterator iter) {
|
||||
assert(!insts_.empty());
|
||||
|
||||
std::unique_ptr<BasicBlock> new_block_temp =
|
||||
MakeUnique<BasicBlock>(MakeUnique<Instruction>(
|
||||
context, SpvOpLabel, 0, label_id, std::initializer_list<Operand>{}));
|
||||
std::unique_ptr<BasicBlock> new_block_temp = MakeUnique<BasicBlock>(
|
||||
MakeUnique<Instruction>(context, spv::Op::OpLabel, 0, label_id,
|
||||
std::initializer_list<Operand>{}));
|
||||
BasicBlock* new_block = new_block_temp.get();
|
||||
function_->InsertBasicBlockAfter(std::move(new_block_temp), this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user