[codegen] Unify cross-platform conditions

This is useful to have cross-platform conditional jumps.

LiftOff, Sparkplug and Maglev all contain their cross-platform
condition that we cast/convert back-and-forth to the architecture one.

This unifies names (as alias) and avoids the back-and-forth.
The CL only adds the conditions, it does not use them yet.

Bug: v8:11461
Change-Id: I79a71bd7fa9d11903c9722fccde239eb3da8dba9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4194731
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85490}
This commit is contained in:
Victor Gomes 2023-01-26 11:40:14 +01:00 committed by V8 LUCI CQ
parent d60b62b0af
commit 949bd4467d
10 changed files with 151 additions and 7 deletions

View File

@ -104,6 +104,22 @@ constexpr Condition kNumberOfConditions = 16;
constexpr Condition hs = cs; // C set Unsigned higher or same.
constexpr Condition lo = cc; // C clear Unsigned lower.
// Unified cross-platform condition names/aliases.
constexpr Condition kEqual = eq;
constexpr Condition kNotEqual = ne;
constexpr Condition kLessThan = lt;
constexpr Condition kGreaterThan = gt;
constexpr Condition kLessThanEqual = le;
constexpr Condition kGreaterThanEqual = ge;
constexpr Condition kUnsignedLessThan = lo;
constexpr Condition kUnsignedGreaterThan = hi;
constexpr Condition kUnsignedLessThanEqual = ls;
constexpr Condition kUnsignedGreaterThanEqual = hs;
constexpr Condition kOverflow = vs;
constexpr Condition kNoOverflow = vc;
constexpr Condition kZero = eq;
constexpr Condition kNotZero = ne;
inline Condition NegateCondition(Condition cond) {
DCHECK(cond != al);
return static_cast<Condition>(cond ^ ne);

View File

@ -318,7 +318,23 @@ enum Condition : uint8_t {
gt = 12, // Signed greater than
le = 13, // Signed less than or equal
al = 14, // Always executed
nv = 15 // Behaves as always/al.
nv = 15, // Behaves as always/al.
// Unified cross-platform condition names/aliases.
kEqual = eq,
kNotEqual = ne,
kLessThan = lt,
kGreaterThan = gt,
kLessThanEqual = le,
kGreaterThanEqual = ge,
kUnsignedLessThan = lo,
kUnsignedGreaterThan = hi,
kUnsignedLessThanEqual = ls,
kUnsignedGreaterThanEqual = hs,
kOverflow = vs,
kNoOverflow = vc,
kZero = eq,
kNotZero = ne,
};
inline Condition NegateCondition(Condition cond) {

View File

@ -79,7 +79,23 @@ enum Condition {
zero = equal,
not_zero = not_equal,
sign = negative,
not_sign = positive
not_sign = positive,
// Unified cross-platform condition names/aliases.
kEqual = equal,
kNotEqual = not_equal,
kLessThan = less,
kGreaterThan = greater,
kLessThanEqual = less_equal,
kGreaterThanEqual = greater_equal,
kUnsignedLessThan = below,
kUnsignedGreaterThan = above,
kUnsignedLessThanEqual = below_equal,
kUnsignedGreaterThanEqual = above_equal,
kOverflow = overflow,
kNoOverflow = no_overflow,
kZero = equal,
kNotZero = not_equal,
};
// Returns the equivalent of !cc.

View File

@ -580,6 +580,22 @@ enum Condition {
uge = Ugreater_equal,
ule = Uless_equal,
ugt = Ugreater,
// Unified cross-platform condition names/aliases.
kEqual = equal,
kNotEqual = not_equal,
kLessThan = less,
kGreaterThan = greater,
kLessThanEqual = less_equal,
kGreaterThanEqual = greater_equal,
kUnsignedLessThan = Uless,
kUnsignedGreaterThan = Ugreater,
kUnsignedLessThanEqual = Uless_equal,
kUnsignedGreaterThanEqual = Ugreater_equal,
kOverflow = overflow,
kNoOverflow = no_overflow,
kZero = equal,
kNotZero = not_equal,
};
// Returns the equivalent of !cc.

View File

@ -1100,6 +1100,22 @@ enum Condition {
uge = Ugreater_equal,
ule = Uless_equal,
ugt = Ugreater,
// Unified cross-platform condition names/aliases.
kEqual = equal,
kNotEqual = not_equal,
kLessThan = less,
kGreaterThan = greater,
kLessThanEqual = less_equal,
kGreaterThanEqual = greater_equal,
kUnsignedLessThan = Uless,
kUnsignedGreaterThan = Ugreater,
kUnsignedLessThanEqual = Uless_equal,
kUnsignedGreaterThanEqual = Ugreater_equal,
kOverflow = overflow,
kNoOverflow = no_overflow,
kZero = equal,
kNotZero = not_equal,
};
// Returns the equivalent of !cc.

View File

@ -129,7 +129,23 @@ enum Condition {
ordered = 7,
overflow = 8, // Summary overflow
nooverflow = 9,
al = 10 // Always.
al = 10, // Always.
// Unified cross-platform condition names/aliases.
kEqual = eq,
kNotEqual = ne,
kLessThan = lt,
kGreaterThan = gt,
kLessThanEqual = le,
kGreaterThanEqual = ge,
kUnsignedLessThan = lt,
kUnsignedGreaterThan = gt,
kUnsignedLessThanEqual = le,
kUnsignedGreaterThanEqual = ge,
kOverflow = overflow,
kNoOverflow = nooverflow,
kZero = eq,
kNotZero = ne,
};
inline Condition NegateCondition(Condition cond) {

View File

@ -441,6 +441,22 @@ enum Condition { // Any value < 0 is considered no_condition.
uge = Ugreater_equal,
ule = Uless_equal,
ugt = Ugreater,
// Unified cross-platform condition names/aliases.
kEqual = equal,
kNotEqual = not_equal,
kLessThan = less,
kGreaterThan = greater,
kLessThanEqual = less_equal,
kGreaterThanEqual = greater_equal,
kUnsignedLessThan = Uless,
kUnsignedGreaterThan = Ugreater,
kUnsignedLessThanEqual = Uless_equal,
kUnsignedGreaterThanEqual = Ugreater_equal,
kOverflow = overflow,
kNoOverflow = no_overflow,
kZero = equal,
kNotZero = not_equal,
};
// Returns the equivalent of !cc.

View File

@ -101,7 +101,23 @@ enum Condition {
mask0xC = 12,
mask0xD = 13,
mask0xE = 14,
mask0xF = 15
mask0xF = 15,
// Unified cross-platform condition names/aliases.
kEqual = eq,
kNotEqual = ne,
kLessThan = lt,
kGreaterThan = gt,
kLessThanEqual = le,
kGreaterThanEqual = ge,
kUnsignedLessThan = lt,
kUnsignedGreaterThan = gt,
kUnsignedLessThanEqual = le,
kUnsignedGreaterThanEqual = ge,
kOverflow = overflow,
kNoOverflow = nooverflow,
kZero = eq,
kNotZero = ne,
};
inline Condition NegateCondition(Condition cond) {

View File

@ -88,6 +88,22 @@ enum Condition : uint8_t {
not_zero = not_equal,
sign = negative,
not_sign = positive,
// Unified cross-platform condition names/aliases.
kEqual = equal,
kNotEqual = not_equal,
kLessThan = less,
kGreaterThan = greater,
kLessThanEqual = less_equal,
kGreaterThanEqual = greater_equal,
kUnsignedLessThan = below,
kUnsignedGreaterThan = above,
kUnsignedLessThanEqual = below_equal,
kUnsignedGreaterThanEqual = above_equal,
kOverflow = overflow,
kNoOverflow = no_overflow,
kZero = equal,
kNotZero = not_equal,
};
// Returns the equivalent of !cc.

View File

@ -253,7 +253,7 @@ void AtomicsWaitWakeHandle::Wake() {
isolate_->futex_wait_list_node()->NotifyWake();
}
enum WaitReturnValue : int { kOk = 0, kNotEqual = 1, kTimedOut = 2 };
enum WaitReturnValue : int { kOk = 0, kNotEqualValue = 1, kTimedOut = 2 };
namespace {
@ -263,7 +263,7 @@ Object WaitJsTranslateReturn(Isolate* isolate, Object res) {
switch (val) {
case WaitReturnValue::kOk:
return ReadOnlyRoots(isolate).ok_string();
case WaitReturnValue::kNotEqual:
case WaitReturnValue::kNotEqualValue:
return ReadOnlyRoots(isolate).not_equal_string();
case WaitReturnValue::kTimedOut:
return ReadOnlyRoots(isolate).timed_out_string();
@ -408,7 +408,7 @@ Object FutexEmulation::WaitSync(Isolate* isolate,
}
#endif
if (loaded_value != value) {
result = handle(Smi::FromInt(WaitReturnValue::kNotEqual), isolate);
result = handle(Smi::FromInt(WaitReturnValue::kNotEqualValue), isolate);
callback_result = AtomicsWaitEvent::kNotEqual;
break;
}