summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_code.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-01-11 20:40:43 (GMT)
committerGitHub <noreply@github.com>2023-01-11 20:40:43 (GMT)
commit6e4e14d98fe0868981f29701496d57a8223c5407 (patch)
treed97f9422c02a791511267bf5af45071067d1c848 /Include/internal/pycore_code.h
parent61f12b8ff7073064040ff0e6220150408d24829b (diff)
downloadcpython-6e4e14d98fe0868981f29701496d57a8223c5407.zip
cpython-6e4e14d98fe0868981f29701496d57a8223c5407.tar.gz
cpython-6e4e14d98fe0868981f29701496d57a8223c5407.tar.bz2
GH-100923: Embed jump mask in `COMPARE_OP` oparg (GH-100924)
Diffstat (limited to 'Include/internal/pycore_code.h')
-rw-r--r--Include/internal/pycore_code.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h
index 9e59fc9..b53657a 100644
--- a/Include/internal/pycore_code.h
+++ b/Include/internal/pycore_code.h
@@ -41,7 +41,6 @@ typedef struct {
typedef struct {
uint16_t counter;
- uint16_t mask;
} _PyCompareOpCache;
#define INLINE_CACHE_ENTRIES_COMPARE_OP CACHE_ENTRIES(_PyCompareOpCache)
@@ -477,6 +476,27 @@ _Py_MakeShimCode(const _PyShimCodeDef *code);
extern uint32_t _Py_next_func_version;
+/* Comparison bit masks. */
+
+/* Note this evaluates its arguments twice each */
+#define COMPARISON_BIT(x, y) (1 << (2 * ((x) >= (y)) + ((x) <= (y))))
+
+/*
+ * The following bits are chosen so that the value of
+ * COMPARSION_BIT(left, right)
+ * masked by the values below will be non-zero if the
+ * comparison is true, and zero if it is false */
+
+/* This is for values that are unordered, ie. NaN, not types that are unordered, e.g. sets */
+#define COMPARISON_UNORDERED 1
+
+#define COMPARISON_LESS_THAN 2
+#define COMPARISON_GREATER_THAN 4
+#define COMPARISON_EQUALS 8
+
+#define COMPARISON_NOT_EQUALS (COMPARISON_UNORDERED | COMPARISON_LESS_THAN | COMPARISON_GREATER_THAN)
+
+
#ifdef __cplusplus
}
#endif