Skip to content

Commit e2a7d08

Browse files
authored
[mypyc] Clean up unused int op definitions (python#9276)
This PR cleans up unused int op definitions including unsafe_short_add and int_compare_op. unsafe_short_add's usages have been replaced with low-level integer op in python#9108 and int_compare_op has no usages since all comparison operators are now built in irbuild.
1 parent 68763ae commit e2a7d08

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

mypyc/primitives/int_ops.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
from typing import Dict, NamedTuple
1010
from mypyc.ir.ops import ERR_NEVER, ERR_MAGIC, BinaryIntOp
1111
from mypyc.ir.rtypes import (
12-
int_rprimitive, bool_rprimitive, float_rprimitive, object_rprimitive, short_int_rprimitive,
12+
int_rprimitive, bool_rprimitive, float_rprimitive, object_rprimitive,
1313
str_rprimitive, RType
1414
)
1515
from mypyc.primitives.registry import (
16-
name_ref_op, binary_op, custom_op, simple_emit, name_emit,
16+
name_ref_op, name_emit,
1717
c_unary_op, CFunctionDescription, c_function_op, c_binary_op, c_custom_op
1818
)
1919

@@ -81,20 +81,6 @@ def int_binary_op(name: str, c_function_name: str,
8181
error_kind=error_kind)
8282

8383

84-
def int_compare_op(name: str, c_function_name: str) -> None:
85-
int_binary_op(name, c_function_name, bool_rprimitive)
86-
# Generate a straight compare if we know both sides are short
87-
op = name
88-
binary_op(op=op,
89-
arg_types=[short_int_rprimitive, short_int_rprimitive],
90-
result_type=bool_rprimitive,
91-
error_kind=ERR_NEVER,
92-
format_str='{dest} = {args[0]} %s {args[1]} :: short_int' % op,
93-
emit=simple_emit(
94-
'{dest} = (Py_ssize_t){args[0]} %s (Py_ssize_t){args[1]};' % op),
95-
priority=2)
96-
97-
9884
# Binary, unary and augmented assignment operations that operate on CPyTagged ints.
9985

10086
int_binary_op('+', 'CPyTagged_Add')
@@ -114,15 +100,6 @@ def int_compare_op(name: str, c_function_name: str) -> None:
114100
int_binary_op('//=', 'CPyTagged_FloorDivide', error_kind=ERR_MAGIC)
115101
int_binary_op('%=', 'CPyTagged_Remainder', error_kind=ERR_MAGIC)
116102

117-
# Add short integers and assume that it doesn't overflow or underflow.
118-
# Assume that the operands are not big integers.
119-
unsafe_short_add = custom_op(
120-
arg_types=[int_rprimitive, int_rprimitive],
121-
result_type=short_int_rprimitive,
122-
error_kind=ERR_NEVER,
123-
format_str='{dest} = {args[0]} + {args[1]} :: short_int',
124-
emit=simple_emit('{dest} = {args[0]} + {args[1]};'))
125-
126103

127104
def int_unary_op(name: str, c_function_name: str) -> CFunctionDescription:
128105
return c_unary_op(name=name,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy