Implement BITWIDTH and TZCOUNT functions (#1450)

This commit is contained in:
Sylvie
2024-08-07 10:39:30 -04:00
committed by GitHub
parent 7435630d6a
commit e93190d491
10 changed files with 105 additions and 18 deletions

View File

@@ -8,7 +8,7 @@
#include <variant>
#include <vector>
#include "helpers.hpp" // assume
#include "helpers.hpp" // assume, clz, ctz
#include "linkdefs.hpp"
#include "opmath.hpp"
@@ -146,6 +146,15 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
value = popRPN(patch) & 0xFF;
break;
case RPN_BITWIDTH:
value = popRPN(patch);
value = value != 0 ? 32 - clz((uint32_t)value) : 0;
break;
case RPN_TZCOUNT:
value = popRPN(patch);
value = value != 0 ? ctz((uint32_t)value) : 32;
break;
case RPN_OR:
value = popRPN(patch) | popRPN(patch);
break;