[Beignet] [Patch v2 1/4] rename endifOffset to needJump to make clear.
xionghu.luo at intel.com
xionghu.luo at intel.com
Fri Jan 6 14:40:40 UTC 2017
From: Luo Xionghu <xionghu.luo at intel.com>
for conditional/unconditional backward jump, need insert JMPI instruction
in block header after LABEL instruction. same for unconditional forward
jump if the target is not the fallthrough block.
Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
backend/src/backend/gen_insn_selection.cpp | 18 +++++++++---------
backend/src/backend/gen_insn_selection.hpp | 3 ++-
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index dd21960..eb9e0ad 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -2496,7 +2496,7 @@ namespace gbe
this->block->hasBranch = bb.getLastInstruction()->getOpcode() == OP_BRA ||
bb.getLastInstruction()->getOpcode() == OP_RET;
if (!this->block->hasBranch)
- this->block->endifOffset = -1;
+ this->block->needJump = -1;
// Build the DAG on the fly
uint32_t insnNum = 0;
@@ -6764,7 +6764,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
// If jump to next label and the endif offset is -1, then
// We don't need to add a jmpi here, as the following IF will do the same
// thing if all channels are disabled.
- (jip != nextLabel || sel.block->endifOffset != -1)) {
+ (jip != nextLabel || sel.block->needJump != -1)) {
// If it is required, insert a JUMP to bypass the block
sel.push();
sel.curr.flag = 0;
@@ -7355,7 +7355,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
sel.curr.predicate = GEN_PREDICATE_NONE;
if (!sel.block->hasBarrier && !sel.block->removeSimpleIfEndif)
sel.ENDIF(GenRegister::immd(0), nextLabel);
- sel.block->endifOffset = -1;
+ sel.block->needJump = -1;
sel.pop();
} else {
// Update the PcIPs
@@ -7371,7 +7371,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
else if(insn.getParent()->needEndif)
sel.ENDIF(GenRegister::immd(0), nextLabel);
}
- sel.block->endifOffset = -1;
+ sel.block->needJump = -1;
if (nextLabel == jip) return;
// Branch to the jump target
sel.push();
@@ -7379,7 +7379,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
sel.curr.noMask = 1;
sel.curr.predicate = GEN_PREDICATE_NONE;
// Actually, the origin of this JMPI should be the beginning of next BB.
- sel.block->endifOffset -= sel.JMPI(GenRegister::immd(0), jip, ir::LabelIndex(curr->getLabelIndex().value() + 1));
+ sel.block->needJump -= sel.JMPI(GenRegister::immd(0), jip, ir::LabelIndex(curr->getLabelIndex().value() + 1));
sel.pop();
}
}
@@ -7413,7 +7413,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
sel.curr.flagIndex = pred.value();
sel.curr.predicate = GEN_PREDICATE_NORMAL;
sel.setBlockIP(ip, dst.value());
- sel.block->endifOffset = -1;
+ sel.block->needJump = -1;
sel.curr.predicate = GEN_PREDICATE_NONE;
if (!sel.block->hasBarrier && !sel.block->removeSimpleIfEndif)
sel.ENDIF(GenRegister::immd(0), next);
@@ -7423,7 +7423,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
else
sel.curr.predicate = GEN_PREDICATE_ALIGN1_ANY8H;
sel.curr.noMask = 1;
- sel.block->endifOffset -= sel.JMPI(GenRegister::immd(0), jip, label);
+ sel.block->needJump -= sel.JMPI(GenRegister::immd(0), jip, label);
sel.pop();
} else {
const LabelIndex next = bb.getNextBlock()->getLabelIndex();
@@ -7432,7 +7432,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
sel.curr.subFlag = 1;
if(insn.getParent()->needEndif)
sel.setBlockIP(ip, dst.value());
- sel.block->endifOffset = -1;
+ sel.block->needJump = -1;
if (!sel.block->hasBarrier && !sel.block->removeSimpleIfEndif) {
if(insn.getParent()->needEndif && !insn.getParent()->needIf)
sel.ENDIF(GenRegister::immd(0), insn.getParent()->endifLabel, insn.getParent()->endifLabel);
@@ -7444,7 +7444,7 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
sel.curr.execWidth = 1;
sel.curr.noMask = 1;
sel.curr.predicate = GEN_PREDICATE_NONE;
- sel.block->endifOffset -= sel.JMPI(GenRegister::immd(0), jip, label);
+ sel.block->needJump -= sel.JMPI(GenRegister::immd(0), jip, label);
sel.pop();
}
}
diff --git a/backend/src/backend/gen_insn_selection.hpp b/backend/src/backend/gen_insn_selection.hpp
index 01999a2..61e2ee1 100644
--- a/backend/src/backend/gen_insn_selection.hpp
+++ b/backend/src/backend/gen_insn_selection.hpp
@@ -259,7 +259,8 @@ namespace gbe
/*! Append a new selection instruction at the beginning of the block */
void prepend(SelectionInstruction *insn);
ir::LabelIndex endifLabel;
- int endifOffset;
+ /*! need insert Jump instruction in block header after label instruction, -1 means not needed. */
+ int needJump;
bool hasBarrier;
bool hasBranch;
bool removeSimpleIfEndif;
--
2.5.0
More information about the Beignet
mailing list