summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opcodes/ChangeLog13
-rw-r--r--opcodes/bpf-ibld.c14
-rw-r--r--opcodes/cgen-ibld.in14
-rw-r--r--opcodes/epiphany-ibld.c14
-rw-r--r--opcodes/fr30-ibld.c14
-rw-r--r--opcodes/frv-ibld.c14
-rw-r--r--opcodes/ip2k-ibld.c14
-rw-r--r--opcodes/iq2000-ibld.c14
-rw-r--r--opcodes/lm32-ibld.c14
-rw-r--r--opcodes/m32c-ibld.c14
-rw-r--r--opcodes/m32r-ibld.c14
-rw-r--r--opcodes/mep-ibld.c14
-rw-r--r--opcodes/mt-ibld.c14
-rw-r--r--opcodes/or1k-ibld.c14
-rw-r--r--opcodes/xc16x-ibld.c14
-rw-r--r--opcodes/xstormy16-ibld.c14
16 files changed, 133 insertions, 90 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 71826bdaea3..6e7b8f4c3e1 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,16 @@
+2020-08-28 Alan Modra <amodra@gmail.com>
+
+ PR 26449
+ PR 26450
+ * cgen-ibld.in (insert_1): Use 1UL in forming mask.
+ (extract_normal): Likewise.
+ (insert_normal): Likewise, and move past zero length test.
+ (put_insn_int_value): Handle mask for zero length, use 1UL.
+ * bpf-ibld.c, * epiphany-ibld.c, * fr30-ibld.c, * frv-ibld.c,
+ * ip2k-ibld.c, * iq2000-ibld.c, * lm32-ibld.c, * m32c-ibld.c,
+ * m32r-ibld.c, * mep-ibld.c, * mt-ibld.c, * or1k-ibld.c,
+ * xc16x-ibld.c, * xstormy16-ibld.c: Regenerate.
+
2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
* csky-dis.c (CSKY_DEFAULT_ISA): Define.
diff --git a/opcodes/bpf-ibld.c b/opcodes/bpf-ibld.c
index 392dcebdd27..0070e410869 100644
--- a/opcodes/bpf-ibld.c
+++ b/opcodes/bpf-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/cgen-ibld.in b/opcodes/cgen-ibld.in
index ae9d20d6f45..7829822b2ca 100644
--- a/opcodes/cgen-ibld.in
+++ b/opcodes/cgen-ibld.in
@@ -84,13 +84,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -130,13 +130,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -313,7 +315,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -490,7 +492,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/epiphany-ibld.c b/opcodes/epiphany-ibld.c
index 4a974edccda..27f0fabd2ae 100644
--- a/opcodes/epiphany-ibld.c
+++ b/opcodes/epiphany-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/fr30-ibld.c b/opcodes/fr30-ibld.c
index 6816154ab27..8cc70209d4f 100644
--- a/opcodes/fr30-ibld.c
+++ b/opcodes/fr30-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/frv-ibld.c b/opcodes/frv-ibld.c
index 43bccbac591..2a7fcb876c3 100644
--- a/opcodes/frv-ibld.c
+++ b/opcodes/frv-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/ip2k-ibld.c b/opcodes/ip2k-ibld.c
index 605d0bde04e..18c2fed67a0 100644
--- a/opcodes/ip2k-ibld.c
+++ b/opcodes/ip2k-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/iq2000-ibld.c b/opcodes/iq2000-ibld.c
index 2a87c709aff..cad26e226e3 100644
--- a/opcodes/iq2000-ibld.c
+++ b/opcodes/iq2000-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/lm32-ibld.c b/opcodes/lm32-ibld.c
index 2b0efdaa3f7..48e894a9ee1 100644
--- a/opcodes/lm32-ibld.c
+++ b/opcodes/lm32-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/m32c-ibld.c b/opcodes/m32c-ibld.c
index 6ad4da967da..67bfb48c0a2 100644
--- a/opcodes/m32c-ibld.c
+++ b/opcodes/m32c-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/m32r-ibld.c b/opcodes/m32r-ibld.c
index 559f47135fa..8e1a7de8141 100644
--- a/opcodes/m32r-ibld.c
+++ b/opcodes/m32r-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/mep-ibld.c b/opcodes/mep-ibld.c
index 66a30e1b456..3de7adea2cc 100644
--- a/opcodes/mep-ibld.c
+++ b/opcodes/mep-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/mt-ibld.c b/opcodes/mt-ibld.c
index 683b76b2b48..924fc90cf77 100644
--- a/opcodes/mt-ibld.c
+++ b/opcodes/mt-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/or1k-ibld.c b/opcodes/or1k-ibld.c
index 7b89260bf53..576a13918b6 100644
--- a/opcodes/or1k-ibld.c
+++ b/opcodes/or1k-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/xc16x-ibld.c b/opcodes/xc16x-ibld.c
index b2802fecb69..ed51a1b4fec 100644
--- a/opcodes/xc16x-ibld.c
+++ b/opcodes/xc16x-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */
diff --git a/opcodes/xstormy16-ibld.c b/opcodes/xstormy16-ibld.c
index eaffbeef90d..06f036fd12e 100644
--- a/opcodes/xstormy16-ibld.c
+++ b/opcodes/xstormy16-ibld.c
@@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x, mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ mask = (1UL << (length - 1) << 1) - 1;
value &= mask;
/* sign extend? */