Skip to content

Commit 798066a

Browse files
committed
sim: Use host not target byte order for merging and splitting values
When using writes to memory through a struct to merge and extract multi-word value, it is the endianness of the host, not the target that affects which order the component words need to be written into the structure. Of the 5 functions adjusted here 4 of them are unused. The 5th, JOINSIDF will soon be used by the or1k target. For or1k, simulated on x86-64, this change fixes this function so that the correct bytes are now returned. sim/common/ChangeLog: * cgen-ops.h (SUBWORDXFSI): Compare HOST_BYTE_ORDER not CURRENT_TARGET_BYTE_ORDER. (SUBWORDTFSI): Likewise. (JOINSIDF): Likewise. (JOINSIXF): Likewise. (JOINSITF): Likewise.
1 parent bdc8beb commit 798066a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

sim/common/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2019-04-13 Andrew Burgess <[email protected]>
2+
3+
* cgen-ops.h (SUBWORDXFSI): Compare HOST_BYTE_ORDER not
4+
CURRENT_TARGET_BYTE_ORDER.
5+
(SUBWORDTFSI): Likewise.
6+
(JOINSIDF): Likewise.
7+
(JOINSIXF): Likewise.
8+
(JOINSITF): Likewise.
9+
110
2019-03-28 Andrew Burgess <[email protected]>
211

312
* sim-base.h: Add 'sim-assert.h' include.

sim/common/cgen-ops.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ SUBWORDXFSI (XF in, int word)
404404
/* Note: typedef struct { SI parts[3]; } XF; */
405405
union { XF in; SI out[3]; } x;
406406
x.in = in;
407-
if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
407+
if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
408408
return x.out[word];
409409
else
410410
return x.out[2 - word];
@@ -416,7 +416,7 @@ SUBWORDTFSI (TF in, int word)
416416
/* Note: typedef struct { SI parts[4]; } TF; */
417417
union { TF in; SI out[4]; } x;
418418
x.in = in;
419-
if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
419+
if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
420420
return x.out[word];
421421
else
422422
return x.out[3 - word];
@@ -432,7 +432,7 @@ SEMOPS_INLINE DF
432432
JOINSIDF (SI x0, SI x1)
433433
{
434434
union { SI in[2]; DF out; } x;
435-
if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
435+
if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
436436
x.in[0] = x0, x.in[1] = x1;
437437
else
438438
x.in[1] = x0, x.in[0] = x1;
@@ -443,7 +443,7 @@ SEMOPS_INLINE XF
443443
JOINSIXF (SI x0, SI x1, SI x2)
444444
{
445445
union { SI in[3]; XF out; } x;
446-
if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
446+
if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
447447
x.in[0] = x0, x.in[1] = x1, x.in[2] = x2;
448448
else
449449
x.in[2] = x0, x.in[1] = x1, x.in[0] = x2;
@@ -454,7 +454,7 @@ SEMOPS_INLINE TF
454454
JOINSITF (SI x0, SI x1, SI x2, SI x3)
455455
{
456456
union { SI in[4]; TF out; } x;
457-
if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
457+
if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
458458
x.in[0] = x0, x.in[1] = x1, x.in[2] = x2, x.in[3] = x3;
459459
else
460460
x.in[3] = x0, x.in[2] = x1, x.in[1] = x2, x.in[0] = x3;

0 commit comments

Comments
 (0)