8000 py/runtime0.h: Put inplace arith ops in front of normal operations. · rlucia/micropython@b8ee7ab · GitHub
[go: up one dir, main page]

Skip to content

Commit b8ee7ab

Browse files
committed
py/runtime0.h: Put inplace arith ops in front of normal operations.
This is to allow to place reverse ops immediately after normal ops, so they can be tested as one range (which is optimization for reverse ops introduction in the next patch).
1 parent c460f6f commit b8ee7ab

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

py/objint_mpz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
221221
return mp_obj_new_float(flhs / frhs);
222222
#endif
223223

224-
} else if (op >= MP_BINARY_OP_OR) {
224+
} else if (op >= MP_BINARY_OP_INPLACE_OR) {
225225
mp_obj_int_t *res = mp_obj_int_new_mpz();
226226

227227
switch (op) {

py/runtime0.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,6 @@ typedef enum {
7070
MP_BINARY_OP_IS_NOT,
7171

7272
// Arithmetic operations
73-
MP_BINARY_OP_OR,
74-
MP_BINARY_OP_XOR,
75-
MP_BINARY_OP_AND,
76-
MP_BINARY_OP_LSHIFT,
77-
MP_BINARY_OP_RSHIFT,
78-
MP_BINARY_OP_ADD,
79-
80-
MP_BINARY_OP_SUBTRACT,
81-
MP_BINARY_OP_MULTIPLY,
82-
MP_BINARY_OP_FLOOR_DIVIDE,
83-
MP_BINARY_OP_TRUE_DIVIDE,
84-
MP_BINARY_OP_MODULO,
85-
MP_BINARY_OP_POWER,
86-
8773
MP_BINARY_OP_INPLACE_OR,
8874
MP_BINARY_OP_INPLACE_XOR,
8975
MP_BINARY_OP_INPLACE_AND,
@@ -98,6 +84,20 @@ typedef enum {
9884
MP_BINARY_OP_INPLACE_MODULO,
9985
MP_BINARY_OP_INPLACE_POWER,
10086

87+
MP_BINARY_OP_OR,
88+
MP_BINARY_OP_XOR,
89+
MP_BINARY_OP_AND,
90+
MP_BINARY_OP_LSHIFT,
91+
MP_BINARY_OP_RSHIFT,
92+
MP_BINARY_OP_ADD,
93+
94+
MP_BINARY_OP_SUBTRACT,
95+
MP_BINARY_OP_MULTIPLY,
96+
MP_BINARY_OP_FLOOR_DIVIDE,
97+
MP_BINARY_OP_TRUE_DIVIDE,
98+
MP_BINARY_OP_MODULO,
99+
MP_BINARY_OP_POWER,
100+
101101
// Operations below this line don't appear in bytecode, they
102102
// just identify special methods.
103103

tests/cmdline/cmd_showbc.py.exp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
4343
bc=\\d\+ line=126
4444
00 LOAD_CONST_NONE
4545
01 LOAD_CONST_FALSE
46-
02 BINARY_OP 16 __add__
46+
02 BINARY_OP 28 __add__
4747
03 LOAD_CONST_TRUE
48-
04 BINARY_OP 16 __add__
48+
04 BINARY_OP 28 __add__
4949
05 STORE_FAST 0
5050
06 LOAD_CONST_SMALL_INT 0
5151
07 STORE_FAST 0
@@ -84,7 +84,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
8484
\\d\+ STORE_FAST 7
8585
\\d\+ LOAD_FAST 0
8686
\\d\+ LOAD_DEREF 14
87-
\\d\+ BINARY_OP 16 __add__
87+
\\d\+ BINARY_OP 28 __add__
8888
\\d\+ STORE_FAST 8
89< 8000 /code>89
\\d\+ LOAD_FAST 0
9090
\\d\+ UNARY_OP 4
@@ -132,7 +132,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
132132
\\d\+ DUP_TOP_TWO
133133
\\d\+ LOAD_SUBSCR
134134
\\d\+ LOAD_FAST 12
135-
\\d\+ BINARY_OP 28 __iadd__
135+
\\d\+ BINARY_OP 16 __iadd__
136136
\\d\+ ROT_THREE
137137
\\d\+ STORE_SUBSCR
138138
\\d\+ LOAD_DEREF 14
@@ -369,7 +369,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
369369
42 STORE_FAST_N 19
370370
44 LOAD_FAST 9
371371
45 LOAD_FAST_N 19
372-
47 BINARY_OP 16 __add__
372+
47 BINARY_OP 28 __add__
373373
48 POP_TOP
374374
49 LOAD_CONST_NONE
375375
50 RETURN_VALUE
@@ -521,7 +521,7 @@ arg names: *
521521
bc=\\d\+ line=113
522522
00 LOAD_DEREF 0
523523
02 LOAD_CONST_SMALL_INT 1
524-
03 BINARY_OP 16 __add__
524+
03 BINARY_OP 28 __add__
525525
04 STORE_FAST 1
526526
05 LOAD_CONST_SMALL_INT 1
527527
06 STORE_DEREF 0
@@ -540,7 +540,7 @@ arg names: * b
540540
bc=\\d\+ line=139
541541
00 LOAD_FAST 1
542542
01 LOAD_DEREF 0
543-
03 BINARY_OP 16 __add__
543+
03 BINARY_OP 28 __add__
544544
04 RETURN_VALUE
545545
mem: total=\\d\+, current=\\d\+, peak=\\d\+
546546
stack: \\d\+ out of \\d\+

0 commit comments

Comments
 (0)
0