target-tilegx: Implement v*shl, v*shru, and v*shrs instructions

v2sh* are implemented with helper functions; v4sh* are implmeneted
with inline code.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Message-Id: <1442872055-2836-1-git-send-email-gang.chen.5i5j@gmail.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Chen Gang 2015-09-22 05:47:35 +08:00 committed by Richard Henderson
parent 0551301076
commit 0ab0a3d768
3 changed files with 73 additions and 0 deletions

View file

@ -25,6 +25,7 @@
/* Broadcast a value to all elements of a vector. */
#define V1(X) (((X) & 0xff) * 0x0101010101010101ull)
#define V2(X) (((X) & 0xffff) * 0x0001000100010001ull)
uint64_t helper_v1shl(uint64_t a, uint64_t b)
@ -36,6 +37,15 @@ uint64_t helper_v1shl(uint64_t a, uint64_t b)
return (a & m) << b;
}
uint64_t helper_v2shl(uint64_t a, uint64_t b)
{
uint64_t m;
b &= 15;
m = V2(0xffff >> b);
return (a & m) << b;
}
uint64_t helper_v1shru(uint64_t a, uint64_t b)
{
uint64_t m;
@ -45,6 +55,15 @@ uint64_t helper_v1shru(uint64_t a, uint64_t b)
return (a & m) >> b;
}
uint64_t helper_v2shru(uint64_t a, uint64_t b)
{
uint64_t m;
b &= 15;
m = V2(0xffff << b);
return (a & m) >> b;
}
uint64_t helper_v1shrs(uint64_t a, uint64_t b)
{
uint64_t r = 0;
@ -56,3 +75,15 @@ uint64_t helper_v1shrs(uint64_t a, uint64_t b)
}
return r;
}
uint64_t helper_v2shrs(uint64_t a, uint64_t b)
{
uint64_t r = 0;
int i;
b &= 15;
for (i = 0; i < 64; i += 16) {
r = deposit64(r, i, 16, sextract64(a, i + b, 16 - b));
}
return r;
}