Commit d7d6f688 authored by Michael Büsch's avatar Michael Büsch

cython: Add #+suffix-u annotation

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent 7d43cc55
......@@ -28,6 +28,7 @@ In order to support both compiling the Awlsim core with Cython and running the s
* `#+cdef-foobar-bizz` : Same as `#+cdef`, but also add the additional words `foobar bizz` after `cdef`. Arbitrary words may be specified and the number of words is not limited. The dash `-` will be transformed into a space character.
* `#+likely` : Mark an `if` condition as being likely to evaluate to True. This annotation can only be used in lines with an `if` statement. It helps the C compiler to generate better machine code.
* `#+unlikely` : Mark an `if` condition as being unlikely to evaluate to True. This annotation can only be used in lines with an `if` statement. It helps the C compiler to generate better machine code.
* `#+suffix-u` : Add an `u` suffix to all decimal and hexadecimal immediates in the line.
To disable code coverage tracing an additional special comment is provided:
......
......@@ -187,6 +187,11 @@ def pyCythonPatch(fromFile, toFile):
line = re.sub(r'\bif\s(.*):', r'if ' + likely + r'(\1):', line)
break
# Add an "u" suffix to decimal and hexadecimal numbers.
if "#+suffix-u" in line:
line = re.sub(r'\b([0-9]+)\b', r'\1u', line)
line = re.sub(r'\b(0x[0-9a-fA-F]+)\b', r'\1u', line)
# Comment all lines containing #@nocy
# or #@cyX for the not matching version.
if "#@nocy" in stripLine:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment