Skip to content

Commit

Permalink
i#2626 a64 decoder: escape sequences in codec.py rejected by Python 3…
Browse files Browse the repository at this point in the history
….12 (#7130)

Python 3.12 is strict about escape characters - '\\^' is not a valid
escape sequence.

Add the 'r' prefix to strings containing '\\^' so they are treated as
raw strings.

Issue: #2626
  • Loading branch information
philramsey-arm authored Dec 16, 2024
1 parent 73aae26 commit eb4a4b8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/ir/aarch64/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,9 @@ def read_codec_file(path):
# Syntax: pattern opcode opndtype* : opndtype*
pattern, nzcv_rw_flag, enum, feat, opcode, args = line.split(None, 5)
dsts, srcs = [a.split() for a in args.split(':')]
opcode_bits = int(re.sub('[\^x]', '0', pattern), 2)
opnd_bits = int(re.sub('x', '1', re.sub('[1\^]', '0', pattern)), 2)
high_soft_bits = int(re.sub('\^', '1', re.sub('[10x]', '0', pattern)), 2)
opcode_bits = int(re.sub(r'[\^x]', '0', pattern), 2)
opnd_bits = int(re.sub('x', '1', re.sub(r'[1\^]', '0', pattern)), 2)
high_soft_bits = int(re.sub(r'\^', '1', re.sub('[10x]', '0', pattern)), 2)
patterns.append(Pattern(pattern, opcode_bits, opnd_bits, high_soft_bits, opcode, (dsts, srcs), enum, feat))
opc_props[opcode] = Opcode(opcode, nzcv_rw_flag, feat)
continue
Expand All @@ -572,7 +572,7 @@ def read_codec_file(path):
pattern, nzcv_rw_flag, enum, feat, opcode, opndset = line.split()
opcode_bits = int(re.sub('x', '0', pattern), 2)
opnd_bits = int(re.sub('x', '1', re.sub('1', '0', pattern)), 2)
high_soft_bits = int(re.sub('\^', '1', re.sub('[10x]', '0', pattern)), 2)
high_soft_bits = int(re.sub(r'\^', '1', re.sub('[10x]', '0', pattern)), 2)
patterns.append(Pattern(pattern, opcode_bits, opnd_bits, high_soft_bits, opcode, opndset, enum, feat))
opc_props[opcode] = Opcode(opcode, nzcv_rw_flag, feat)
continue
Expand Down

0 comments on commit eb4a4b8

Please sign in to comment.