summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2021-09-14 08:53:32 (GMT)
committerGitHub <noreply@github.com>2021-09-14 08:53:32 (GMT)
commitc2f1e953371c25f6c42b599ba3d8797effbb503e (patch)
tree96c6c27edc2fbd765014187431df79acbf26c271 /Tools
parent9f93018b69d72cb48d3444554261ae3b0ea00c93 (diff)
downloadcpython-c2f1e953371c25f6c42b599ba3d8797effbb503e.zip
cpython-c2f1e953371c25f6c42b599ba3d8797effbb503e.tar.gz
cpython-c2f1e953371c25f6c42b599ba3d8797effbb503e.tar.bz2
bpo-45152: Add HAS_CONST macro and get_const_value() function and useā€¦ (#28262)
Diffstat (limited to 'Tools')
-rw-r--r--Tools/scripts/generate_opcode_h.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Tools/scripts/generate_opcode_h.py b/Tools/scripts/generate_opcode_h.py
index 41ae3fe..48875d2 100644
--- a/Tools/scripts/generate_opcode_h.py
+++ b/Tools/scripts/generate_opcode_h.py
@@ -51,6 +51,7 @@ def main(opcode_py, outfile='Include/opcode.h'):
code = fp.read()
exec(code, opcode)
opmap = opcode['opmap']
+ hasconst = opcode['hasconst']
hasjrel = opcode['hasjrel']
hasjabs = opcode['hasjabs']
used = [ False ] * 256
@@ -65,15 +66,24 @@ def main(opcode_py, outfile='Include/opcode.h'):
if name == 'POP_EXCEPT': # Special entry for HAVE_ARGUMENT
fobj.write("#define %-23s %3d\n" %
('HAVE_ARGUMENT', opcode['HAVE_ARGUMENT']))
+
for name in opcode['_specialized_instructions']:
while used[next_op]:
next_op += 1
fobj.write("#define %-23s %3s\n" % (name, next_op))
used[next_op] = True
+
fobj.write("#ifdef NEED_OPCODE_JUMP_TABLES\n")
write_int_array_from_ops("_PyOpcode_RelativeJump", opcode['hasjrel'], fobj)
write_int_array_from_ops("_PyOpcode_Jump", opcode['hasjrel'] + opcode['hasjabs'], fobj)
fobj.write("#endif /* OPCODE_TABLES */\n")
+
+ fobj.write("\n")
+ fobj.write("#define HAS_CONST(op) (false\\")
+ for op in hasconst:
+ fobj.write(f"\n || ((op) == {op}) \\")
+ fobj.write("\n )\n")
+
fobj.write(footer)