44# ------------------------------------------------------------------------------
55# The MIT License (MIT)
66#
7- # Copyright (c) 2021-2022 Aarno Labs LLC
7+ # Copyright (c) 2021-2025 Aarno Labs LLC
88#
99# Permission is hereby granted, free of charge, to any person obtaining a copy
1010# of this software and associated documentation files (the "Software"), to deal
2525# SOFTWARE.
2626# ------------------------------------------------------------------------------
2727
28- from typing import List , TYPE_CHECKING
28+ from typing import List , Tuple , TYPE_CHECKING
2929
3030from chb .app .InstrXData import InstrXData
3131
3232from chb .arm .ARMDictionaryRecord import armregistry
33- from chb .arm .ARMOpcode import ARMOpcode , simplify_result
33+ from chb .arm .ARMOpcode import ARMOpcode , ARMOpcodeXData , simplify_result
3434from chb .arm .ARMOperand import ARMOperand
3535
3636import chb .util .fileutil as UF
37-
3837from chb .util .IndexedTable import IndexedTableValue
38+ from chb .util .loggingutil import chklogger
3939
4040if TYPE_CHECKING :
4141 from chb .arm .ARMDictionary import ARMDictionary
42+ from chb .invariants .XVariable import XVariable
43+ from chb .invariants .XXpr import XXpr
44+
45+
46+ class ARMSignedBitFieldExtractXData (ARMOpcodeXData ):
47+
48+ def __init__ (self , xdata : InstrXData ) -> None :
49+ ARMOpcodeXData .__init__ (self , xdata )
50+
51+ @property
52+ def vrd (self ) -> "XVariable" :
53+ return self .var (0 , "vrd" )
54+
55+ @property
56+ def xrn (self ) -> "XXpr" :
57+ return self .xpr (0 , "xrn" )
58+
59+ @property
60+ def xxrn (self ) -> "XXpr" :
61+ return self .xpr (1 , "xxrn" )
62+
63+ @property
64+ def result_simplified (self ) -> str :
65+ return simplify_result (
66+ self .xdata .args [1 ], self .xdata .args [2 ], self .xrn , self .xxrn )
67+
68+ @property
69+ def annotation (self ) -> str :
70+ assignment = str (self .vrd ) + " := " + self .result_simplified
71+ return self .add_instruction_condition (assignment )
4272
4373
4474@armregistry .register_tag ("SBFX" , ARMOpcode )
@@ -64,15 +94,8 @@ def operands(self) -> List[ARMOperand]:
6494 return [self .armd .arm_operand (i ) for i in self .args ]
6595
6696 def annotation (self , xdata : InstrXData ) -> str :
67- """xdata format: a:vxx .
68-
69- vars[0]: lhs
70- xprs[0]: rhs1
71- xprs[1]: value to be stored (syntactic)
72- """
73-
74- lhs = str (xdata .vars [0 ])
75- result = xdata .xprs [0 ]
76- rresult = xdata .xprs [1 ]
77- xresult = simplify_result (xdata .args [1 ], xdata .args [2 ], result , rresult )
78- return lhs + " := " + xresult
97+ xd = ARMSignedBitFieldExtractXData (xdata )
98+ if xd .is_ok :
99+ return xd .annotation
100+ else :
101+ return "Error value"
0 commit comments