Skip to content

Commit

Permalink
added immediate operand check in class
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesouza committed Mar 19, 2024
1 parent 2c2b867 commit 13cfebe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
9 changes: 9 additions & 0 deletions osaca/parser/immediate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


class ImmediateOperand(Operand):
WILDCARD = "*"

Check failure on line 8 in osaca/parser/immediate.py

View workflow job for this annotation

GitHub Actions / Flake8

osaca/parser/immediate.py#L8

Blank line contains whitespace (W293)
def __init__(
self,
identifier=None,
Expand Down Expand Up @@ -69,3 +71,10 @@ def __eq__(self, other):
and self._shift == other._shift
)
return False

Check failure on line 74 in osaca/parser/immediate.py

View workflow job for this annotation

GitHub Actions / Flake8

osaca/parser/immediate.py#L74

Blank line contains whitespace (W293)
def is_immediate_type(self, other, isa):
if isa == "aarch64":
if isinstance(other, ImmediateOperand):
return (self.imd_type == self.WILDCARD or self.imd_type == other.imd_type) and other.value is not None
elif isa == "x86":
return isinstance(other, ImmediateOperand) and other.imd_type == "int"
35 changes: 5 additions & 30 deletions osaca/semantics/hw_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def __init__(self, arch=None, path_to_yaml=None, isa=None, lazy=False):
if self._path in MachineModel._runtime_cache and not lazy:
self._data = MachineModel._runtime_cache[self._path]
# check if file is cached
#cached = self._get_cached(self._path) if not lazy else False
if False:
cached = self._get_cached(self._path) if not lazy else False
if cached:
self._data = cached
else:
yaml = self._create_yaml_object()
Expand Down Expand Up @@ -771,30 +771,8 @@ def _check_AArch64_operands(self, i_operand, operand):
return False
return operand.is_mem_type(i_operand, self._data["isa"].lower())
# immediate
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.imd_type == "int":
return (
isinstance(operand, ImmediateOperand)
and operand.imd_type == "int"
and operand.value is not None
)

if isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == "float":
return (
isinstance(operand, ImmediateOperand)
and operand.imd_type == "float"
and operand.value is not None
)

if isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == "double":
return (
isinstance(operand, ImmediateOperand)
and operand.imd_type == "double"
and operand.value is not None
)

if isinstance(i_operand, ImmediateOperand):
return i_operand.is_immediate_type(operand, self._data["isa"].lower())
# identifier
if isinstance(operand, IdentifierOperand) or (
isinstance(operand, ImmediateOperand) and operand.identifier is not None
Expand All @@ -812,9 +790,6 @@ def _check_AArch64_operands(self, i_operand, operand):

def _check_x86_operands(self, i_operand, operand):
"""Check if the types of operand ``i_operand`` and ``operand`` match."""
# if "class" in operand.name:
# compare two DB entries
# return self._compare_db_entries(i_operand, operand)
# register
if isinstance(operand, RegisterOperand):
if not isinstance(i_operand, RegisterOperand):
Expand All @@ -827,7 +802,7 @@ def _check_x86_operands(self, i_operand, operand):
return operand.is_mem_type(i_operand, self._data["isa"].lower())
# immediate
if isinstance(operand, ImmediateOperand):
return isinstance(i_operand, ImmediateOperand) and i_operand.imd_type == "int"
return operand.is_immediate_type(i_operand, self._data["isa"].lower())
# identifier (e.g., labels)
if isinstance(operand, IdentifierOperand):
return isinstance(i_operand, IdentifierOperand)
Expand Down

0 comments on commit 13cfebe

Please sign in to comment.