summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2014-04-25 20:42:02 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-04-25 20:48:09 +0200
commiteb41b5c3a7c57a8b8a26ffde36d52ef4716f6465 (patch)
treee66681bd07f9c151183e030715d6107e8cef75b9
parent2e779af8ea627b43f7ad7a1e9f611a9c6a877f53 (diff)
downloadorc-eb41b5c3a7c57a8b8a26ffde36d52ef4716f6465.tar.gz
orcprogram-c: Convert shifts in swap opcodes to operations on unsigned integers
Shifting into the sign bit is undefined, so let's stop doing that.
-rw-r--r--orc/orcemulateopcodes.c6
-rw-r--r--orc/orcfunctions.c4
-rw-r--r--orc/orcprogram-c.c6
3 files changed, 8 insertions, 8 deletions
diff --git a/orc/orcemulateopcodes.c b/orc/orcemulateopcodes.c
index 8040173..6724432 100644
--- a/orc/orcemulateopcodes.c
+++ b/orc/orcemulateopcodes.c
@@ -31,8 +31,8 @@
#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX)
#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX)
#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)
-#define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))
-#define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))
+#define ORC_SWAP_W(x) ((((x)&0xffU)<<8) | (((x)&0xff00U)>>8))
+#define ORC_SWAP_L(x) ((((x)&0xffU)<<24) | (((x)&0xff00U)<<8) | (((x)&0xff0000U)>>8) | (((x)&0xff000000U)>>24))
#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56))
#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))
#define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff))
@@ -4066,7 +4066,7 @@ emulate_swapwl (OrcOpcodeExecutor *ex, int offset, int n)
/* 0: loadl */
var32 = ptr4[i];
/* 1: swapwl */
- var33.i = ((var32.i&0x0000ffff) << 16) | ((var32.i&0xffff0000) >> 16);
+ var33.i = ((var32.i&0x0000ffffU) << 16) | ((var32.i&0xffff0000U) >> 16);
/* 2: storel */
ptr0[i] = var33;
}
diff --git a/orc/orcfunctions.c b/orc/orcfunctions.c
index 1e8b6ca..b51630d 100644
--- a/orc/orcfunctions.c
+++ b/orc/orcfunctions.c
@@ -104,8 +104,8 @@ void orc_memset (void * ORC_RESTRICT d1, int p1, int n);
#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX)
#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX)
#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)
-#define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))
-#define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))
+#define ORC_SWAP_W(x) ((((x)&0xffU)<<8) | (((x)&0xff00U)>>8))
+#define ORC_SWAP_L(x) ((((x)&0xffU)<<24) | (((x)&0xff00U)<<8) | (((x)&0xff0000U)>>8) | (((x)&0xff000000U)>>24))
#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56))
#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))
#define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff))
diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c
index e000fee..2afb0cf 100644
--- a/orc/orcprogram-c.c
+++ b/orc/orcprogram-c.c
@@ -126,8 +126,8 @@ orc_target_c_get_asm_preamble (void)
"#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX)\n"
"#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX)\n"
"#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)\n"
- "#define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))\n"
- "#define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))\n"
+ "#define ORC_SWAP_W(x) ((((x)&0xffU)<<8) | (((x)&0xff00U)>>8))\n"
+ "#define ORC_SWAP_L(x) ((((x)&0xffU)<<24) | (((x)&0xff00U)<<8) | (((x)&0xff0000U)>>8) | (((x)&0xff000000U)>>24))\n"
"#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56))\n"
"#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))\n"
"#define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff))\n"
@@ -1410,7 +1410,7 @@ c_rule_swapwl (OrcCompiler *p, void *user, OrcInstruction *insn)
c_get_name_int (dest, p, insn, insn->dest_args[0]);
c_get_name_int (src, p, insn, insn->src_args[0]);
- ORC_ASM_CODE(p," %s = ((%s&0x0000ffff) << 16) | ((%s&0xffff0000) >> 16);\n",
+ ORC_ASM_CODE(p," %s = ((%s&0x0000ffffU) << 16) | ((%s&0xffff0000U) >> 16);\n",
dest, src, src);
}