From 2bb83143de54e66d1b1f0bfa8a2aa91654a9b845 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 6 Sep 2010 11:02:56 +0200 Subject: [PATCH] Add 64 bit shlq/shrsq/shruq opcodes --- orc/opcodes.h | 3 +++ orc/orcemulateopcodes.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ orc/orcemulateopcodes.h | 3 +++ orc/orcopcodes.c | 3 +++ 4 files changed, 81 insertions(+) diff --git a/orc/opcodes.h b/orc/opcodes.h index 20cc1bc..568f2d6 100644 --- a/orc/opcodes.h +++ b/orc/opcodes.h @@ -91,6 +91,9 @@ BINARY_SQ(orq, "%s | %s") BINARY_SQ(xorq, "%s ^ %s") BINARY_SQ(addq, "%s + %s") BINARY_SQ(subq, "%s - %s") +BINARY_SQ(shlq, "%s << %s") +BINARY_SQ(shrsq, "%s >> %s") +BINARY_UQ(shruq, "((orc_uint64)%s) >> %s") UNARY_BW(convsbw, "%s") UNARY_BW(convubw, "(orc_uint8)%s") diff --git a/orc/orcemulateopcodes.c b/orc/orcemulateopcodes.c index 785aa6d..654b14e 100644 --- a/orc/orcemulateopcodes.c +++ b/orc/orcemulateopcodes.c @@ -3086,6 +3086,78 @@ emulate_subq (OrcOpcodeExecutor *ex, int offset, int n) } void +emulate_shlq (OrcOpcodeExecutor *ex, int offset, int n) +{ + int i; + orc_union64 * ORC_RESTRICT ptr0; + const orc_union64 * ORC_RESTRICT ptr4; + orc_union64 var32; + orc_union64 var33; + + ptr0 = (orc_union64 *)ex->dest_ptrs[0]; + ptr4 = (orc_union64 *)ex->src_ptrs[0]; + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var32 = ptr4[i]; + /* 1: shlq */ + var33.i = var32.i << ((orc_union32 *)(ex->src_ptrs[1]))->i; + /* 2: storeq */ + ptr0[i] = var33; + } + +} + +void +emulate_shrsq (OrcOpcodeExecutor *ex, int offset, int n) +{ + int i; + orc_union64 * ORC_RESTRICT ptr0; + const orc_union64 * ORC_RESTRICT ptr4; + orc_union64 var32; + orc_union64 var33; + + ptr0 = (orc_union64 *)ex->dest_ptrs[0]; + ptr4 = (orc_union64 *)ex->src_ptrs[0]; + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var32 = ptr4[i]; + /* 1: shrsq */ + var33.i = var32.i >> ((orc_union32 *)(ex->src_ptrs[1]))->i; + /* 2: storeq */ + ptr0[i] = var33; + } + +} + +void +emulate_shruq (OrcOpcodeExecutor *ex, int offset, int n) +{ + int i; + orc_union64 * ORC_RESTRICT ptr0; + const orc_union64 * ORC_RESTRICT ptr4; + orc_union64 var32; + orc_union64 var33; + + ptr0 = (orc_union64 *)ex->dest_ptrs[0]; + ptr4 = (orc_union64 *)ex->src_ptrs[0]; + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var32 = ptr4[i]; + /* 1: shruq */ + var33.i = ((orc_uint64)var32.i) >> ((orc_union32 *)(ex->src_ptrs[1]))->i; + /* 2: storeq */ + ptr0[i] = var33; + } + +} + +void emulate_convsbw (OrcOpcodeExecutor *ex, int offset, int n) { int i; diff --git a/orc/orcemulateopcodes.h b/orc/orcemulateopcodes.h index 4f4df65..26267e3 100644 --- a/orc/orcemulateopcodes.h +++ b/orc/orcemulateopcodes.h @@ -118,6 +118,9 @@ void emulate_orq (OrcOpcodeExecutor *ex, int i, int n); void emulate_xorq (OrcOpcodeExecutor *ex, int i, int n); void emulate_addq (OrcOpcodeExecutor *ex, int i, int n); void emulate_subq (OrcOpcodeExecutor *ex, int i, int n); +void emulate_shlq (OrcOpcodeExecutor *ex, int i, int n); +void emulate_shrsq (OrcOpcodeExecutor *ex, int i, int n); +void emulate_shruq (OrcOpcodeExecutor *ex, int i, int n); void emulate_convsbw (OrcOpcodeExecutor *ex, int i, int n); void emulate_convubw (OrcOpcodeExecutor *ex, int i, int n); void emulate_splatbw (OrcOpcodeExecutor *ex, int i, int n); diff --git a/orc/orcopcodes.c b/orc/orcopcodes.c index 243ff0b..2850ca1 100644 --- a/orc/orcopcodes.c +++ b/orc/orcopcodes.c @@ -405,6 +405,9 @@ static OrcStaticOpcode opcodes[] = { { "xorq", 0, { 8 }, { 8, 8 }, emulate_xorq }, { "addq", 0, { 8 }, { 8, 8 }, emulate_addq }, { "subq", 0, { 8 }, { 8, 8 }, emulate_subq }, + { "shlq", ORC_STATIC_OPCODE_SCALAR, { 8 }, { 8, 8 }, emulate_shlq }, + { "shrsq", ORC_STATIC_OPCODE_SCALAR, { 8 }, { 8, 8 }, emulate_shrsq }, + { "shruq", ORC_STATIC_OPCODE_SCALAR, { 8 }, { 8, 8 }, emulate_shruq }, { "convsbw", 0, { 2 }, { 1 }, emulate_convsbw }, { "convubw", 0, { 2 }, { 1 }, emulate_convubw }, -- 2.7.4