mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2026-01-06 03:00:11 +01:00
Immediate operand attribute name changes
This commit is contained in:
@@ -6,55 +6,55 @@ from osaca.parser.operand import Operand
|
||||
class ImmediateOperand(Operand):
|
||||
def __init__(
|
||||
self,
|
||||
identifier_id=None,
|
||||
type_id=None,
|
||||
value_id=None,
|
||||
shift_id=None,
|
||||
identifier=None,
|
||||
imd_type=None,
|
||||
value=None,
|
||||
shift=None,
|
||||
source=False,
|
||||
destination=False,
|
||||
):
|
||||
super().__init__(source, destination)
|
||||
self._identifier_id = identifier_id
|
||||
self._type_id = type_id
|
||||
self._value_id = value_id
|
||||
self._shift_id = shift_id
|
||||
self._identifier = identifier
|
||||
self._imd_type = imd_type
|
||||
self._value = value
|
||||
self._shift = shift
|
||||
|
||||
@property
|
||||
def identifier(self):
|
||||
return self._identifier_id
|
||||
return self._identifier
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type_id
|
||||
def imd_type(self):
|
||||
return self._imd_type
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return self._value_id
|
||||
return self._value
|
||||
|
||||
@property
|
||||
def shift(self):
|
||||
return self._type_id
|
||||
return self._imd_type
|
||||
|
||||
@type.setter
|
||||
def type(self, type):
|
||||
self._type_id = type
|
||||
@imd_type.setter
|
||||
def imd_type(self, type):
|
||||
self._imd_type = imd_type
|
||||
|
||||
@identifier.setter
|
||||
def identifier(self, identifier):
|
||||
self._identifier_id = identifier
|
||||
self._identifier = identifier
|
||||
|
||||
@value.setter
|
||||
def value(self, value):
|
||||
self._value_id = value
|
||||
self._value = value
|
||||
|
||||
@shift.setter
|
||||
def index(self, shift):
|
||||
self._shift_id = shift
|
||||
def shift(self, shift):
|
||||
self._shift = shift
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
f"Immediate(identifier_id={self._identifier_id}, type_id={self._type_id}, "
|
||||
f"value_id={self._value_id}, shift_id={self._shift_id}, source={self._source}, destination={self._destination})"
|
||||
f"Immediate(identifier={self._identifier}, imd_type={self._imd_type}, "
|
||||
f"value={self._value}, shift={self._shift}, source={self._source}, destination={self._destination})"
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
@@ -63,9 +63,9 @@ class ImmediateOperand(Operand):
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, ImmediateOperand):
|
||||
return (
|
||||
self._identifier_id == other._identifier_id
|
||||
and self._type_id == other._type_id
|
||||
and self._value_id == other._value_id
|
||||
and self._shift_id == other._shift_id
|
||||
self._identifier == other._identifier
|
||||
and self._imd_type == other._imd_type
|
||||
and self._value == other._value
|
||||
and self._shift == other._shift
|
||||
)
|
||||
return False
|
||||
|
||||
@@ -582,9 +582,9 @@ class ParserAArch64(BaseParser):
|
||||
"""Normalize immediate to decimal based representation"""
|
||||
if isinstance(imd, IdentifierOperand):
|
||||
return imd
|
||||
if imd.value is not None and imd.type == "float":
|
||||
if imd.value is not None and imd.imd_type == "float":
|
||||
return self.ieee_to_float(imd.value)
|
||||
elif imd.value is not None and imd.type == "double":
|
||||
elif imd.value is not None and imd.imd_type == "double":
|
||||
return self.ieee_to_float(imd.value)
|
||||
elif imd.value is not None:
|
||||
if isinstance(imd.value, str):
|
||||
|
||||
@@ -11,6 +11,7 @@ from pathlib import Path
|
||||
|
||||
import ruamel.yaml
|
||||
from osaca import __version__, utils
|
||||
from copy import deepcopy
|
||||
from osaca.parser import ParserX86ATT
|
||||
from osaca.parser.instruction_form import InstructionForm
|
||||
from osaca.parser.operand import Operand
|
||||
@@ -20,6 +21,7 @@ from osaca.parser.immediate import ImmediateOperand
|
||||
from osaca.parser.identifier import IdentifierOperand
|
||||
from osaca.parser.condition import ConditionOperand
|
||||
from osaca.parser.flag import FlagOperand
|
||||
from ruamel.yaml.compat import StringIO
|
||||
|
||||
|
||||
class MachineModel(object):
|
||||
@@ -375,7 +377,7 @@ class MachineModel(object):
|
||||
ld_tp = [m for m in self._data["load_throughput"] if self._match_mem_entries(memory, m[0])]
|
||||
if len(ld_tp) > 0:
|
||||
return ld_tp.copy()
|
||||
return (memory, self._data["load_throughput_default"].copy())
|
||||
return [memory, self._data["load_throughput_default"].copy()]
|
||||
|
||||
def get_store_latency(self, reg_type):
|
||||
"""Return store latency for given register type."""
|
||||
@@ -466,6 +468,8 @@ class MachineModel(object):
|
||||
'''
|
||||
formatted_instruction_forms = deepcopy(self._data["instruction_forms"])
|
||||
for instruction_form in formatted_instruction_forms:
|
||||
for op in instruction_form.operands:
|
||||
op = dict((key.lstrip("_"), value) for key, value in op.__dict__.iteritems() if not callable(value) and not key.startswith('__'))
|
||||
if instruction_form["port_pressure"] is not None:
|
||||
cs = ruamel.yaml.comments.CommentedSeq(instruction_form["port_pressure"])
|
||||
cs.fa.set_flow_style()
|
||||
@@ -474,16 +478,17 @@ class MachineModel(object):
|
||||
# Replace load_throughput with styled version for RoundtripDumper
|
||||
formatted_load_throughput = []
|
||||
for lt in self._data["load_throughput"]:
|
||||
lt = self.operand_to_dict(lt)
|
||||
cm = ruamel.yaml.comments.CommentedMap(lt)
|
||||
cm = dict((key, value) for key, value in lt[0].__dict__.iteritems() if not callable(value) and not key.startswith('__'))
|
||||
cm["port_pressure"] = lt[1]
|
||||
cm = ruamel.yaml.comments.CommentedMap(cm)
|
||||
cm.fa.set_flow_style()
|
||||
formatted_load_throughput.append(cm)
|
||||
|
||||
# Create YAML object
|
||||
# yaml = self._create_yaml_object()
|
||||
yaml = self._create_yaml_object()
|
||||
if not stream:
|
||||
stream = StringIO()
|
||||
"""
|
||||
|
||||
yaml.dump(
|
||||
{
|
||||
k: v
|
||||
@@ -500,20 +505,11 @@ class MachineModel(object):
|
||||
)
|
||||
|
||||
yaml.dump({"load_throughput": formatted_load_throughput}, stream)
|
||||
yaml.dump({"instruction_forms": formatted_instruction_forms }, stream)
|
||||
"""
|
||||
yaml.dump({"instruction_forms": formatted_instruction_forms}, stream)
|
||||
'''
|
||||
if isinstance(stream, StringIO):
|
||||
return stream.getvalue()
|
||||
'''
|
||||
|
||||
def operand_to_dict(self, mem):
|
||||
return {
|
||||
"base": mem.base,
|
||||
"offset": mem.offset,
|
||||
"index": mem.index,
|
||||
"scale": mem.scale,
|
||||
"port_pressure": mem.port_pressure,
|
||||
}
|
||||
|
||||
######################################################
|
||||
|
||||
@@ -716,27 +712,27 @@ class MachineModel(object):
|
||||
return False
|
||||
return self._is_AArch64_mem_type(i_operand, operand)
|
||||
# immediate
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.type == self.WILDCARD:
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == self.WILDCARD:
|
||||
return isinstance(operand, ImmediateOperand) and (operand.value is not None)
|
||||
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.type == "int":
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == "int":
|
||||
return (
|
||||
isinstance(operand, ImmediateOperand)
|
||||
and operand.type == "int"
|
||||
and operand.imd_type == "int"
|
||||
and operand.value is not None
|
||||
)
|
||||
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.type == "float":
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == "float":
|
||||
return (
|
||||
isinstance(operand, ImmediateOperand)
|
||||
and operand.type == "float"
|
||||
and operand.imd_type == "float"
|
||||
and operand.value is not None
|
||||
)
|
||||
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.type == "double":
|
||||
if isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == "double":
|
||||
return (
|
||||
isinstance(operand, ImmediateOperand)
|
||||
and operand.type == "double"
|
||||
and operand.imd_type == "double"
|
||||
and operand.value is not None
|
||||
)
|
||||
|
||||
@@ -773,7 +769,7 @@ class MachineModel(object):
|
||||
# immediate
|
||||
if isinstance(operand, ImmediateOperand):
|
||||
# if "immediate" in operand.name or operand.value != None:
|
||||
return isinstance(i_operand, ImmediateOperand) and i_operand.type == "int"
|
||||
return isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == "int"
|
||||
# identifier (e.g., labels)
|
||||
if isinstance(operand, IdentifierOperand):
|
||||
return isinstance(i_operand, IdentifierOperand)
|
||||
|
||||
Reference in New Issue
Block a user