[Beignet] [PATCH 2/5] GBE: refine longjmp checking.
Yang, Rong R
rong.r.yang at intel.com
Thu Sep 24 00:05:38 PDT 2015
One comment.
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Zhigang Gong
> Sent: Monday, September 14, 2015 14:20
> To: beignet at lists.freedesktop.org
> Cc: Gong, Zhigang
> Subject: [Beignet] [PATCH 2/5] GBE: refine longjmp checking.
>
> Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
> ---
> backend/src/backend/gen_insn_selection.cpp | 2 +-
> backend/src/ir/function.hpp | 17 +++++++++++++++++
> 2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/backend/src/backend/gen_insn_selection.cpp
> b/backend/src/backend/gen_insn_selection.cpp
> index ab00269..57dbec9 100644
> --- a/backend/src/backend/gen_insn_selection.cpp
> +++ b/backend/src/backend/gen_insn_selection.cpp
> @@ -1154,7 +1154,7 @@ namespace gbe
> SelectionInstruction *insn = this->appendInsn(SEL_OP_JMPI, 0, 1);
> insn->src(0) = src;
> insn->index = index.value();
> - insn->extra.longjmp = abs(index - origin) > 800;
> + insn->extra.longjmp = ctx.getFunction().getDistance(origin, index)
> + > 8000;
> return insn->extra.longjmp ? 2 : 1;
> }
>
> diff --git a/backend/src/ir/function.hpp b/backend/src/ir/function.hpp index
> b5f4ba2..b924332 100644
> --- a/backend/src/ir/function.hpp
> +++ b/backend/src/ir/function.hpp
> @@ -487,6 +487,23 @@ namespace ir {
> Register getSurfaceBaseReg(uint8_t bti) const;
> void appendSurface(uint8_t bti, Register reg);
> /*! Output the control flow graph to .dot file */
> + /*! Get instruction distance between two BBs */
> + INLINE uint32_t getDistance(LabelIndex b0, LabelIndex b1) const {
> + int start, end;
> + if (b0.value() < b1.value()) {
> + start = b0.value();
> + end = b1.value() - 1;
> + } else {
> + start = b1.value();
> + end = b0.value() - 1;
> + }
> + uint32_t insnNum = 0;
> + for(int i = start; i <= end; i++) {
> + BasicBlock &bb = getBlock(LabelIndex(i));
> + insnNum += bb.size();
> + }
If front jump, need not include the start and end block's size.
> + return insnNum;
> + }
> void outputCFG();
> private:
> friend class Context; //!< Can freely modify a function
> --
> 1.9.1
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list