Skip to content

Commit 97d2ec9

Browse files
eendebakptclaude
andcommitted
Add more kinds to KIND_OP
Eleven kinds, all tier-1 counterparts of existing tier-2 uops or of open specialization proposals: - UNARY_NEGATIVE_INPLACE: negate a uniquely referenced float in place (UNARY_NEGATIVE gains an inline cache) - BINARY_OP_TRUEDIV_FLOAT: float / float when the operands are shared - BINARY_OP_FLOOR_DIVIDE_INT, BINARY_OP_REMAINDER_INT: compact ints, nonzero divisor, floor semantics - BINARY_OP_LSHIFT_INT, BINARY_OP_RSHIFT_INT: compact ints, shift count within range - BINARY_OP_SUBSCR_BYTES_INT, BINARY_OP_SUBSCR_BYTEARRAY_INT, STORE_SUBSCR_BYTEARRAY_INT: byte access with a compact in-range index - UNPACK_SEQUENCE_STEAL_TWO_TUPLE, UNPACK_SEQUENCE_STEAL_TUPLE: a tuple referenced only from the stack gives up its items without refcount traffic; a shared tuple takes the increfing path Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 6afae50 commit 97d2ec9

14 files changed

Lines changed: 3241 additions & 111 deletions

‎Include/internal/pycore_code.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,17 @@ typedef struct {
160160

161161
#define INLINE_CACHE_ENTRIES_TO_BOOL CACHE_ENTRIES(_PyToBoolCache)
162162

163+
typedef struct {
164+
_Py_BackoffCounter counter;
165+
uint16_t kind;
166+
} _PyUnaryNegativeCache;
167+
168+
#define INLINE_CACHE_ENTRIES_UNARY_NEGATIVE CACHE_ENTRIES(_PyUnaryNegativeCache)
169+
170+
enum _PyUnaryNegativeInplaceKind {
171+
UNARY_NEGATIVE_INPLACE_FLOAT = 0,
172+
};
173+
163174
/* TO_BOOL_SIZED: types whose truthiness is a size field at a fixed offset. */
164175
typedef struct {
165176
PyTypeObject *type;
@@ -345,6 +356,7 @@ PyAPI_FUNC(void) _Py_Specialize_UnpackSequence(_PyStackRef seq, _Py_CODEUNIT *in
345356
PyAPI_FUNC(void) _Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT *instr, int oparg);
346357
PyAPI_FUNC(void) _Py_Specialize_Send(_PyStackRef receiver, _Py_CODEUNIT *instr);
347358
PyAPI_FUNC(void) _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
359+
PyAPI_FUNC(void) _Py_Specialize_UnaryNegative(_PyStackRef value, _Py_CODEUNIT *instr);
348360
PyAPI_FUNC(void) _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);
349361
PyAPI_FUNC(void) _Py_GatherStats_GetIter(_PyStackRef iterable);
350362
PyAPI_FUNC(void) _Py_Specialize_CallFunctionEx(_PyStackRef func_st, _Py_CODEUNIT *instr);

‎Include/internal/pycore_magic_number.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ Known values:
304304
Python 3.16a1 3704 (Replace DELETE_ATTR with PUSH_NULL; STORE_ATTR)
305305
Python 3.16a1 3705 (Add INTRINSIC_ADD_CONDITIONAL_ANNOTATION)
306306
Python 3.16a1 3706 (Add INTRINSIC_MATCH_CLASS_ISINSTANCE)
307-
Python 3.16a1 3707 (Add KIND_OP)
307+
Python 3.16a1 3707 (Add KIND_OP, inline cache for UNARY_NEGATIVE)
308308
309309
Python 3.17 will start with 3750
310310

‎Include/internal/pycore_opcode_metadata.h‎

Lines changed: 71 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_uop_ids.h‎

Lines changed: 35 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)