mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2025-09-01 23:40:17 +02:00
added prefetch operand
This commit is contained in:
@@ -17,6 +17,7 @@ class BaseParser(object):
|
|||||||
segment_ext = "segment_extension"
|
segment_ext = "segment_extension"
|
||||||
mnemonic = "instruction"
|
mnemonic = "instruction"
|
||||||
operands = "operands"
|
operands = "operands"
|
||||||
|
prefetch = "prfop"
|
||||||
_parser_constructed = False
|
_parser_constructed = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@@ -13,6 +13,7 @@ from osaca.parser.identifier import IdentifierOperand
|
|||||||
from osaca.parser.immediate import ImmediateOperand
|
from osaca.parser.immediate import ImmediateOperand
|
||||||
from osaca.parser.condition import ConditionOperand
|
from osaca.parser.condition import ConditionOperand
|
||||||
from osaca.parser.flag import FlagOperand
|
from osaca.parser.flag import FlagOperand
|
||||||
|
from osaca.parser.prefetch import PrefetchOperand
|
||||||
|
|
||||||
|
|
||||||
class ParserAArch64(BaseParser):
|
class ParserAArch64(BaseParser):
|
||||||
@@ -389,8 +390,17 @@ class ParserAArch64(BaseParser):
|
|||||||
return self.process_directive_operand(operand[self.directive_id])
|
return self.process_directive_operand(operand[self.directive_id])
|
||||||
if self.condition_id in operand:
|
if self.condition_id in operand:
|
||||||
return self.process_condition(operand[self.condition_id])
|
return self.process_condition(operand[self.condition_id])
|
||||||
|
if self.prefetch in operand:
|
||||||
|
return self.process_prefetch_operand(operand[self.prefetch])
|
||||||
return operand
|
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):
|
def process_directive_operand(self, operand):
|
||||||
return (
|
return (
|
||||||
DirectiveOperand(
|
DirectiveOperand(
|
||||||
|
40
osaca/parser/prefetch.py
Normal file
40
osaca/parser/prefetch.py
Normal 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__()
|
@@ -21,6 +21,7 @@ from osaca.parser.immediate import ImmediateOperand
|
|||||||
from osaca.parser.identifier import IdentifierOperand
|
from osaca.parser.identifier import IdentifierOperand
|
||||||
from osaca.parser.condition import ConditionOperand
|
from osaca.parser.condition import ConditionOperand
|
||||||
from osaca.parser.flag import FlagOperand
|
from osaca.parser.flag import FlagOperand
|
||||||
|
from osaca.parser.prefetch import PrefetchOperand
|
||||||
from ruamel.yaml.compat import StringIO
|
from ruamel.yaml.compat import StringIO
|
||||||
|
|
||||||
|
|
||||||
@@ -257,6 +258,14 @@ class MachineModel(object):
|
|||||||
destination=o["destination"] if "destination" in o else False,
|
destination=o["destination"] if "destination" in o else False,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
elif o["class"] == "prfop":
|
||||||
|
new_operands.append(
|
||||||
|
PrefetchOperand(
|
||||||
|
type_id=o["type"] if "type" in o else None,
|
||||||
|
target=o["target"] if "target" in o else None,
|
||||||
|
policy=o["policy"] if "policy" in o else None,
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
new_operands.append(o)
|
new_operands.append(o)
|
||||||
|
|
||||||
@@ -798,8 +807,8 @@ class MachineModel(object):
|
|||||||
):
|
):
|
||||||
return isinstance(i_operand, IdentifierOperand)
|
return isinstance(i_operand, IdentifierOperand)
|
||||||
# prefetch option
|
# prefetch option
|
||||||
if not isinstance(operand, Operand) and "prfop" in operand:
|
if isinstance(operand, PrefetchOperand):
|
||||||
return i_operand["class"] == "prfop"
|
return isinstance(i_operand, PrefetchOperand)
|
||||||
# condition
|
# condition
|
||||||
if isinstance(operand, ConditionOperand):
|
if isinstance(operand, ConditionOperand):
|
||||||
if isinstance(i_operand, ConditionOperand):
|
if isinstance(i_operand, ConditionOperand):
|
||||||
|
@@ -14,6 +14,7 @@ from osaca.parser.memory import MemoryOperand
|
|||||||
from osaca.parser.register import RegisterOperand
|
from osaca.parser.register import RegisterOperand
|
||||||
from osaca.parser.immediate import ImmediateOperand
|
from osaca.parser.immediate import ImmediateOperand
|
||||||
from osaca.parser.identifier import IdentifierOperand
|
from osaca.parser.identifier import IdentifierOperand
|
||||||
|
from osaca.parser.prefetch import PrefetchOperand
|
||||||
|
|
||||||
|
|
||||||
class TestParserAArch64(unittest.TestCase):
|
class TestParserAArch64(unittest.TestCase):
|
||||||
@@ -233,7 +234,7 @@ class TestParserAArch64(unittest.TestCase):
|
|||||||
instruction_form_5 = InstructionForm(
|
instruction_form_5 = InstructionForm(
|
||||||
mnemonic="prfm",
|
mnemonic="prfm",
|
||||||
operands=[
|
operands=[
|
||||||
{"prfop": {"type": ["PLD"], "target": ["L1"], "policy": ["KEEP"]}},
|
PrefetchOperand(type_id=["PLD"],target=["L1"],policy=["KEEP"]),
|
||||||
MemoryOperand(
|
MemoryOperand(
|
||||||
offset=ImmediateOperand(value=2048),
|
offset=ImmediateOperand(value=2048),
|
||||||
base=RegisterOperand(prefix="x", name="26"),
|
base=RegisterOperand(prefix="x", name="26"),
|
||||||
|
Reference in New Issue
Block a user