added prefetch operand

This commit is contained in:
stefandesouza
2024-03-18 22:29:39 +01:00
parent e253638cb7
commit ae2fcfe8bb
5 changed files with 64 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ class BaseParser(object):
segment_ext = "segment_extension"
mnemonic = "instruction"
operands = "operands"
prefetch = "prfop"
_parser_constructed = False
def __init__(self):

View File

@@ -13,6 +13,7 @@ from osaca.parser.identifier import IdentifierOperand
from osaca.parser.immediate import ImmediateOperand
from osaca.parser.condition import ConditionOperand
from osaca.parser.flag import FlagOperand
from osaca.parser.prefetch import PrefetchOperand
class ParserAArch64(BaseParser):
@@ -389,8 +390,17 @@ class ParserAArch64(BaseParser):
return self.process_directive_operand(operand[self.directive_id])
if self.condition_id in operand:
return self.process_condition(operand[self.condition_id])
if self.prefetch in operand:
return self.process_prefetch_operand(operand[self.prefetch])
return operand
def process_prefetch_operand(self, operand):
return PrefetchOperand(
type_id=operand["type"] if "type" in operand else None,
target=operand["target"] if "target" in operand else None,
policy=operand["policy"] if "policy" in operand else None,
)
def process_directive_operand(self, operand):
return (
DirectiveOperand(

40
osaca/parser/prefetch.py Normal file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python3
from osaca.parser.operand import Operand
class PrefetchOperand(Operand):
def __init__(self, type_id=None, target=None, policy=None):
self._type_id = type_id
self._target = target
self._policy = policy
@property
def type_id(self):
return self._type_id
@type_id.setter
def type_id(self, type_id):
self._type_id = type_id
@property
def target(self):
return self._target
@target.setter
def target(self, target):
self._target = target
@property
def policy(self):
return self._policy
@policy.setter
def policy(self, policy):
self._policy = policy
def __str__(self):
return f"Label(type_id={self._type_id},target={self._target},policy={self._policy})"
def __repr__(self):
return self.__str__()