mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
target-i386: Implement PDEP, PEXT
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
5f1f4b1771
commit
0592f74a75
3 changed files with 71 additions and 0 deletions
|
@ -488,6 +488,38 @@ target_ulong helper_bsr(target_ulong t0)
|
|||
return helper_lzcnt(t0, 0);
|
||||
}
|
||||
|
||||
#if TARGET_LONG_BITS == 32
|
||||
# define ctztl ctz32
|
||||
#else
|
||||
# define ctztl ctz64
|
||||
#endif
|
||||
|
||||
target_ulong helper_pdep(target_ulong src, target_ulong mask)
|
||||
{
|
||||
target_ulong dest = 0;
|
||||
int i, o;
|
||||
|
||||
for (i = 0; mask != 0; i++) {
|
||||
o = ctztl(mask);
|
||||
mask &= mask - 1;
|
||||
dest |= ((src >> i) & 1) << o;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
target_ulong helper_pext(target_ulong src, target_ulong mask)
|
||||
{
|
||||
target_ulong dest = 0;
|
||||
int i, o;
|
||||
|
||||
for (o = 0; mask != 0; o++) {
|
||||
i = ctztl(mask);
|
||||
mask &= mask - 1;
|
||||
dest |= ((src >> i) & 1) << o;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
#define SHIFT 0
|
||||
#include "shift_helper_template.h"
|
||||
#undef SHIFT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue