PR26449, PR26450 UBSAN: frv-ibld.c:135 left shift
Eh well, I guess the code didn't quite live up to the comment. 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.
This commit is contained in:
parent
ed2ed4dcf4
commit
a1e60a1bdc
@ -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>
|
2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
|
||||||
|
|
||||||
* csky-dis.c (CSKY_DEFAULT_ISA): Define.
|
* csky-dis.c (CSKY_DEFAULT_ISA): Define.
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -84,13 +84,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -130,13 +130,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -313,7 +315,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -490,7 +492,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
@ -85,13 +85,13 @@ insert_1 (CGEN_CPU_DESC cd,
|
|||||||
int word_length,
|
int word_length,
|
||||||
unsigned char *bufp)
|
unsigned char *bufp)
|
||||||
{
|
{
|
||||||
unsigned long x,mask;
|
unsigned long x, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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)
|
if (CGEN_INSN_LSB0_P)
|
||||||
shift = (start + 1) - length;
|
shift = (start + 1) - length;
|
||||||
else
|
else
|
||||||
@ -131,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd,
|
|||||||
CGEN_INSN_BYTES_PTR buffer)
|
CGEN_INSN_BYTES_PTR buffer)
|
||||||
{
|
{
|
||||||
static char errbuf[100];
|
static char errbuf[100];
|
||||||
/* Written this way to avoid undefined behaviour. */
|
unsigned long mask;
|
||||||
unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
|
||||||
|
|
||||||
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
/* If LENGTH is zero, this operand doesn't contribute to the value. */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Written this way to avoid undefined behaviour. */
|
||||||
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
if (word_length > 8 * sizeof (CGEN_INSN_INT))
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int shift = insn_length - length;
|
int shift = insn_length - length;
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* 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);
|
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ extract_normal (CGEN_CPU_DESC cd,
|
|||||||
#endif /* ! CGEN_INT_INSN_P */
|
#endif /* ! CGEN_INT_INSN_P */
|
||||||
|
|
||||||
/* Written this way to avoid undefined behaviour. */
|
/* Written this way to avoid undefined behaviour. */
|
||||||
mask = (((1L << (length - 1)) - 1) << 1) | 1;
|
mask = (1UL << (length - 1) << 1) - 1;
|
||||||
|
|
||||||
value &= mask;
|
value &= mask;
|
||||||
/* sign extend? */
|
/* sign extend? */
|
||||||
|
Loading…
Reference in New Issue
Block a user