[Beignet] [PATCH 3/9] support 64bit-integer immediate value
Homer Hsing
homer.xing at intel.com
Sun Aug 4 22:06:37 PDT 2013
Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
backend/src/backend/gen_context.cpp | 1 +
backend/src/backend/gen_encoder.cpp | 16 ++++++++++++++++
backend/src/backend/gen_encoder.hpp | 1 +
backend/src/backend/gen_insn_selection.cpp | 3 +++
backend/src/backend/gen_insn_selection.hxx | 1 +
backend/src/backend/gen_register.hpp | 7 +++++++
6 files changed, 29 insertions(+)
diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index c8c6e49..da21ceb 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -146,6 +146,7 @@ namespace gbe
case SEL_OP_RNDU: p->RNDU(dst, src); break;
case SEL_OP_RNDE: p->RNDE(dst, src); break;
case SEL_OP_RNDZ: p->RNDZ(dst, src); break;
+ case SEL_OP_LOAD_INT64_IMM: p->LOAD_INT64_IMM(dst, src.value.i64); break;
default: NOT_IMPLEMENTED;
}
}
diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp
index 73eebe6..d2e9716 100644
--- a/backend/src/backend/gen_encoder.cpp
+++ b/backend/src/backend/gen_encoder.cpp
@@ -812,6 +812,22 @@ namespace gbe
pop();
}
+ void GenEncoder::LOAD_INT64_IMM(GenRegister dest, int64_t value) {
+ union { int64_t i64; unsigned u[2]; } u;
+ GenRegister xdest = GenRegister::retype(dest, GEN_TYPE_UQ);
+ u.i64 = value;
+ push();
+ curr.quarterControl = 0;
+ curr.nibControl = 0;
+ MOV(xdest.top_half(), GenRegister::immud(u.u[1]));
+ MOV(xdest.bottom_half(), GenRegister::immud(u.u[0]));
+ curr.nibControl = 1;
+ xdest = GenRegister::suboffset(xdest, 4);
+ MOV(xdest.top_half(), GenRegister::immud(u.u[1]));
+ MOV(xdest.bottom_half(), GenRegister::immud(u.u[0]));
+ pop();
+ }
+
void GenEncoder::UPSAMPLE_SHORT(GenRegister dest, GenRegister src0, GenRegister src1) {
dest.type = GEN_TYPE_B;
dest.hstride = GEN_HORIZONTAL_STRIDE_2;
diff --git a/backend/src/backend/gen_encoder.hpp b/backend/src/backend/gen_encoder.hpp
index a272ff8..466fc60 100644
--- a/backend/src/backend/gen_encoder.hpp
+++ b/backend/src/backend/gen_encoder.hpp
@@ -124,6 +124,7 @@ namespace gbe
#undef ALU2
#undef ALU3
void LOAD_DF_IMM(GenRegister dest, GenRegister tmp, double value);
+ void LOAD_INT64_IMM(GenRegister dest, int64_t value);
/*! Barrier message (to synchronize threads of a workgroup) */
void BARRIER(GenRegister src);
/*! Memory fence message (to order loads and stores between threads) */
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 072fc23..3d4d60a 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -415,6 +415,7 @@ namespace gbe
ALU1(MOV)
ALU2(MOV_DF)
ALU2(LOAD_DF_IMM)
+ ALU1(LOAD_INT64_IMM)
ALU1(RNDZ)
ALU1(RNDE)
ALU2(SEL)
@@ -1798,6 +1799,8 @@ namespace gbe
case TYPE_U8: sel.MOV(dst, GenRegister::immuw(imm.data.u8)); break;
case TYPE_S8: sel.MOV(dst, GenRegister::immw(imm.data.s8)); break;
case TYPE_DOUBLE: sel.LOAD_DF_IMM(dst, GenRegister::immdf(imm.data.f64), sel.selReg(sel.reg(FAMILY_QWORD))); break;
+ case TYPE_S64: sel.LOAD_INT64_IMM(dst, GenRegister::immint64(imm.data.s64)); break;
+ case TYPE_U64: sel.LOAD_INT64_IMM(dst, GenRegister::immint64(imm.data.u64)); break;
default: NOT_SUPPORTED;
}
sel.pop();
diff --git a/backend/src/backend/gen_insn_selection.hxx b/backend/src/backend/gen_insn_selection.hxx
index f2b86c4..8eeb19f 100644
--- a/backend/src/backend/gen_insn_selection.hxx
+++ b/backend/src/backend/gen_insn_selection.hxx
@@ -2,6 +2,7 @@ DECL_SELECTION_IR(LABEL, LabelInstruction)
DECL_SELECTION_IR(MOV, UnaryInstruction)
DECL_SELECTION_IR(MOV_DF, BinaryInstruction)
DECL_SELECTION_IR(LOAD_DF_IMM, BinaryInstruction)
+DECL_SELECTION_IR(LOAD_INT64_IMM, UnaryInstruction)
DECL_SELECTION_IR(NOT, UnaryInstruction)
DECL_SELECTION_IR(LZD, UnaryInstruction)
DECL_SELECTION_IR(RNDZ, UnaryInstruction)
diff --git a/backend/src/backend/gen_register.hpp b/backend/src/backend/gen_register.hpp
index 177690b..cd05fa7 100644
--- a/backend/src/backend/gen_register.hpp
+++ b/backend/src/backend/gen_register.hpp
@@ -202,6 +202,7 @@ namespace gbe
int32_t d;
uint32_t ud;
uint16_t reg;
+ int64_t i64;
} value;
uint32_t nr:8; //!< Just for some physical registers (acc, null)
@@ -434,6 +435,12 @@ namespace gbe
GEN_HORIZONTAL_STRIDE_0);
}
+ static INLINE GenRegister immint64(int64_t i) {
+ GenRegister immediate = imm(GEN_TYPE_Q);
+ immediate.value.i64 = i;
+ return immediate;
+ }
+
static INLINE GenRegister immdf(double df) {
GenRegister immediate = imm(GEN_TYPE_DF);
immediate.value.df = df;
--
1.8.1.2
More information about the Beignet
mailing list