From: Dmitry Selyutin Date: Tue, 9 Jan 2024 19:48:26 +0000 (+0300) Subject: oppc: check for special symbols X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=78a1ddbff30282876b2e98330a92c5d3d6f468f4;p=openpower-isa.git oppc: check for special symbols --- diff --git a/src/openpower/oppc/pc_ast.py b/src/openpower/oppc/pc_ast.py index 9812107c..de77765e 100644 --- a/src/openpower/oppc/pc_ast.py +++ b/src/openpower/oppc/pc_ast.py @@ -145,6 +145,26 @@ class XER(Literal, choices=("OV", "OV32", "CA", "CA32", "SO")): pass +class Reserve(Literal, choices=("RESERVE", "RESERVE_LENGTH", "RESERVE_ADDR")): + pass + + +class Overflow(Literal, choices=("overflow",)): + pass + + +class Special(Literal, choices=( + "CR", "LR", "CTR", "TAR", "FPSCR", "MSR", + "SVSTATE", "SVREMAP", "SRR0", "SRR1", + "SVSHAPE0", "SVSHAPE1", "SVSHAPE2", "SVSHAPE3", + )): + pass + + +class XLEN(Literal, choices=("XLEN",)): + pass + + class IntLiteral(Literal): pass diff --git a/src/openpower/oppc/pc_parser.py b/src/openpower/oppc/pc_parser.py index 33d2d8db..d88e67dd 100644 --- a/src/openpower/oppc/pc_parser.py +++ b/src/openpower/oppc/pc_parser.py @@ -441,7 +441,23 @@ class Parser: """ atom : NAME """ - p[0] = p[1] + # Note: GPR and FPR are handled separately. + specials = {frozenset(cls):cls for cls in ( + pc_ast.CR3, + pc_ast.CR5, + pc_ast.XER, + pc_ast.Reserve, + pc_ast.Overflow, + pc_ast.Special, + pc_ast.XLEN, + )} + value = str(p[1]) + for (variants, cls) in specials.items(): + if value in variants: + p[0] = cls(value) + break + else: + p[0] = p[1] def p_atom_number(self, p): """