Commit 64d19472 authored by Junliang Yan's avatar Junliang Yan Committed by V8 LUCI CQ

ppc: Add CNTTZW/CNTTZD instructions

Change-Id: I99448ed94e8ef0cb2ea9fdf6e629757bda595d54
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3054472Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#75930}
parent 28661339
......@@ -1172,6 +1172,10 @@ using Instr = uint32_t;
V(cntlzw, CNTLZWX, 0x7C000034) \
/* Count Leading Zeros Doubleword */ \
V(cntlzd, CNTLZDX, 0x7C000074) \
/* Count Tailing Zeros Word */ \
V(cnttzw, CNTTZWX, 0x7C000434) \
/* Count Tailing Zeros Doubleword */ \
V(cnttzd, CNTTZDX, 0x7C000474) \
/* Population Count Byte-wise */ \
V(popcntb, POPCNTB, 0x7C0000F4) \
/* Population Count Words */ \
......
......@@ -891,12 +891,18 @@ void Decoder::DecodeExt2(Instruction* instr) {
Format(instr, "cntlzw'. 'ra, 'rs");
return;
}
#if V8_TARGET_ARCH_PPC64
case CNTLZDX: {
Format(instr, "cntlzd'. 'ra, 'rs");
return;
}
#endif
case CNTTZWX: {
Format(instr, "cnttzw'. 'ra, 'rs");
return;
}
case CNTTZDX: {
Format(instr, "cnttzd'. 'ra, 'rs");
return;
}
case ANDX: {
Format(instr, "and'. 'ra, 'rs, 'rb");
return;
......
......@@ -2523,7 +2523,6 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
}
break;
}
#if V8_TARGET_ARCH_PPC64
case CNTLZDX: {
int rs = instr->RSValue();
int ra = instr->RAValue();
......@@ -2549,7 +2548,42 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
}
break;
}
#endif
case CNTTZWX: {
int rs = instr->RSValue();
int ra = instr->RAValue();
uint32_t rs_val = static_cast<uint32_t>(get_register(rs));
uintptr_t count = __builtin_ctz(rs_val);
set_register(ra, count);
if (instr->Bit(0)) { // RC Bit set
int bf = 0;
if (count > 0) {
bf |= 0x40000000;
}
if (count == 0) {
bf |= 0x20000000;
}
condition_reg_ = (condition_reg_ & ~0xF0000000) | bf;
}
break;
}
case CNTTZDX: {
int rs = instr->RSValue();
int ra = instr->RAValue();
uint64_t rs_val = get_register(rs);
uintptr_t count = __builtin_ctz(rs_val);
set_register(ra, count);
if (instr->Bit(0)) { // RC Bit set
int bf = 0;
if (count > 0) {
bf |= 0x40000000;
}
if (count == 0) {
bf |= 0x20000000;
}
condition_reg_ = (condition_reg_ & ~0xF0000000) | bf;
}
break;
}
case ANDX: {
int rs = instr->RSValue();
int ra = instr->RAValue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment