asm: Fix replacing reg names that are substrings (DAIF etc)

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2023-05-06 00:51:05 +09:00
parent 48db941199
commit 6c005ddd49

View file

@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
import os, tempfile, shutil, subprocess
import os, tempfile, shutil, subprocess, re
from . import sysreg
__all__ = ["AsmException", "ARMAsm"]
@ -55,7 +55,7 @@ class BaseAsm(object):
def compile(self, source):
for name, enc in sysreg.sysreg_fwd.items():
source = source.replace(name, f"s{enc[0]}_{enc[1]}_c{enc[2]}_c{enc[3]}_{enc[4]}")
source = re.sub("\\b" + name + "\\b", f"s{enc[0]}_{enc[1]}_c{enc[2]}_c{enc[3]}_{enc[4]}", source)
self.sfile = self._tmp + "b.S"
with open(self.sfile, "w") as fd: