#ifdef PIPE_ARCH_X86
-#define DISASSEM 0
-
-
-
-
-
static INLINE boolean eq( struct x86_reg a,
struct x86_reg b )
{
}
-struct x86_reg aos_get_internal( struct aos_compilation *cp,
- unsigned imm )
-{
- return get_reg_ptr( cp,
- AOS_FILE_INTERNAL,
- imm );
-}
#define X87_CW_EXCEPTION_INV_OP (1<<0)
#define X87_CW_EXCEPTION_DENORM_OP (1<<1)
float inv = 1.0f/255.0f;
float f255 = 255.0f;
+ ASSIGN_4V(machine->internal[IMM_SWZ], 1.0f, -1.0f, 0.0f, 1.0f);
+ *(unsigned *)&machine->internal[IMM_SWZ][3] = 0xffffffff;
+
ASSIGN_4V(machine->internal[IMM_ONES], 1.0f, 1.0f, 1.0f, 1.0f);
ASSIGN_4V(machine->internal[IMM_NEGS], -1.0f, -1.0f, -1.0f, -1.0f);
ASSIGN_4V(machine->internal[IMM_IDENTITY], 0.0f, 0.0f, 0.0f, 1.0f);
+static struct x86_reg aos_get_shader_reg_xmm( struct aos_compilation *cp,
+ unsigned file,
+ unsigned idx )
+{
+ struct x86_reg reg = aos_get_shader_reg( cp, file, idx );
+
+ if (reg.file != file_XMM) {
+ struct x86_reg tmp = aos_get_xmm_reg(cp);
+ sse_movups(cp->func, tmp, reg);
+ aos_adopt_xmm_reg( cp, tmp, file, idx, FALSE );
+ reg = tmp;
+ }
+
+ return reg;
+}
+
+
+
+struct x86_reg aos_get_internal_xmm( struct aos_compilation *cp,
+ unsigned imm )
+{
+ return aos_get_shader_reg_xmm( cp, AOS_FILE_INTERNAL, imm );
+}
+
+
+struct x86_reg aos_get_internal( struct aos_compilation *cp,
+ unsigned imm )
+{
+ return aos_get_shader_reg( cp, AOS_FILE_INTERNAL, imm );
+}
+
+
+
/* Emulate pshufd insn in regular SSE, if necessary:
arg0 = dst;
}
- if (negs) {
- struct x86_reg imm_negs = aos_get_internal(cp, IMM_NEGS);
+ if (negs && negs != 0xf) {
+ struct x86_reg imm_swz = aos_get_internal_xmm(cp, IMM_SWZ);
struct x86_reg tmp = aos_get_xmm_reg(cp);
/* Load 1,-1,0,0
* Use neg as arg to pshufd
* Multiply
*/
- emit_pshufd(cp, tmp, imm_negs,
+ emit_pshufd(cp, tmp, imm_swz,
SHUF((negs & 1) ? 1 : 0,
(negs & 2) ? 1 : 0,
(negs & 4) ? 1 : 0,
aos_release_xmm_reg(cp, tmp.idx);
arg0 = dst;
}
+ else if (negs) {
+ struct x86_reg imm_negs = aos_get_internal_xmm(cp, IMM_NEGS);
+ sse_mulps(cp->func, dst, imm_negs);
+ arg0 = dst;
+ }
+
if (abs && abs != 0xf) {
ERROR(cp, "unsupported partial abs");
}
-
- if (abs) {
+ else if (abs) {
struct x86_reg neg = aos_get_internal(cp, IMM_NEGS);
struct x86_reg tmp = aos_get_xmm_reg(cp);
#define IMM_ONES 0 /* 1, 1,1,1 */
-#define IMM_NEGS 1 /* 1,-1,0,0 */
+#define IMM_SWZ 1 /* 1,-1,0, 0xffffffff */
#define IMM_IDENTITY 2 /* 0, 0,0,1 */
#define IMM_INV_255 3 /* 1/255, 1/255, 1/255, 1/255 */
#define IMM_255 4 /* 255, 255, 255, 255 */
+#define IMM_NEGS 5 /* -1,-1,-1,-1 */
struct x86_reg aos_get_internal( struct aos_compilation *cp,
unsigned imm );
+struct x86_reg aos_get_internal_xmm( struct aos_compilation *cp,
+ unsigned imm );
#define ERROR(cp, msg) \
struct x86_reg src_ptr )
{
sse_movss(cp->func, data, x86_make_disp(src_ptr, 8));
- sse_shufps(cp->func, data, aos_get_internal( cp, IMM_IDENTITY ), SHUF(X,Y,Z,W) );
+ sse_shufps(cp->func, data, aos_get_internal_xmm( cp, IMM_IDENTITY ), SHUF(X,Y,Z,W) );
sse_shufps(cp->func, data, data, SHUF(Y,Z,X,W) );
sse_movlps(cp->func, data, src_ptr);
}
struct x86_reg data,
struct x86_reg src_ptr )
{
- sse_movups(cp->func, data, aos_get_internal( cp, IMM_IDENTITY ) );
+ sse_movups(cp->func, data, aos_get_internal_xmm( cp, IMM_IDENTITY ) );
sse_movlps(cp->func, data, src_ptr);
}
struct x86_reg src_ptr )
{
sse_movss(cp->func, data, src_ptr);
- sse_orps(cp->func, data, aos_get_internal( cp, IMM_IDENTITY ) );
+ sse_orps(cp->func, data, aos_get_internal_xmm( cp, IMM_IDENTITY ) );
}
struct x86_reg src_ptr )
{
sse_movss(cp->func, data, src_ptr);
- sse2_punpcklbw(cp->func, data, aos_get_internal( cp, IMM_IDENTITY ));
- sse2_punpcklbw(cp->func, data, aos_get_internal( cp, IMM_IDENTITY ));
+ sse2_punpcklbw(cp->func, data, aos_get_internal_xmm( cp, IMM_IDENTITY ));
+ sse2_punpcklbw(cp->func, data, aos_get_internal_xmm( cp, IMM_IDENTITY ));
sse2_cvtdq2ps(cp->func, data, data);
sse_mulps(cp->func, data, aos_get_internal(cp, IMM_INV_255));
}