Skip to content

Commit 66f2dbd

Browse files
rth7680pm215
authored andcommitted
target/arm: Extend vec_reg_offset to larger sizes
Rearrange the arithmetic so that we are agnostic about the total size of the vector and the size of the element. This will allow us to index up to the 32nd byte and with 16-byte elements. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20180613015641.5667-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
1 parent 6d3ede5 commit 66f2dbd

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

target/arm/translate-a64.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,26 @@ static inline void assert_fp_access_checked(DisasContext *s)
6767
static inline int vec_reg_offset(DisasContext *s, int regno,
6868
int element, TCGMemOp size)
6969
{
70-
int offs = 0;
70+
int element_size = 1 << size;
71+
int offs = element * element_size;
7172
#ifdef HOST_WORDS_BIGENDIAN
7273
/* This is complicated slightly because vfp.zregs[n].d[0] is
73-
* still the low half and vfp.zregs[n].d[1] the high half
74-
* of the 128 bit vector, even on big endian systems.
75-
* Calculate the offset assuming a fully bigendian 128 bits,
76-
* then XOR to account for the order of the two 64 bit halves.
74+
* still the lowest and vfp.zregs[n].d[15] the highest of the
75+
* 256 byte vector, even on big endian systems.
76+
*
77+
* Calculate the offset assuming fully little-endian,
78+
* then XOR to account for the order of the 8-byte units.
79+
*
80+
* For 16 byte elements, the two 8 byte halves will not form a
81+
* host int128 if the host is bigendian, since they're in the
82+
* wrong order. However the only 16 byte operation we have is
83+
* a move, so we can ignore this for the moment. More complicated
84+
* operations will have to special case loading and storing from
85+
* the zregs array.
7786
*/
78-
offs += (16 - ((element + 1) * (1 << size)));
79-
offs ^= 8;
80-
#else
81-
offs += element * (1 << size);
87+
if (element_size < 8) {
88+
offs ^= 8 - element_size;
89+
}
8290
#endif
8391
offs += offsetof(CPUARMState, vfp.zregs[regno]);
8492
assert_fp_access_checked(s);

0 commit comments

Comments
 (0)