mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2026-01-10 13:07:06 +01:00
added wildcard mode for mem addressing in ISA DB
This commit is contained in:
@@ -32,10 +32,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: adc
|
||||
@@ -45,10 +45,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: add
|
||||
@@ -78,10 +78,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: add
|
||||
@@ -91,10 +91,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: addsd
|
||||
@@ -144,10 +144,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: and
|
||||
@@ -157,10 +157,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: bts
|
||||
@@ -190,10 +190,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: bts
|
||||
@@ -203,10 +203,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: cmp
|
||||
@@ -226,23 +226,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
source: true
|
||||
destination: true
|
||||
- name: cmp
|
||||
operands:
|
||||
- class: "immediate"
|
||||
imd: "int"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: ~
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: cmp
|
||||
@@ -262,23 +249,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
source: true
|
||||
destination: false
|
||||
- name: cmp
|
||||
operands:
|
||||
- class: "register"
|
||||
name: "gpr"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: ~
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: false
|
||||
- name: dec
|
||||
@@ -290,19 +264,10 @@ instruction_forms:
|
||||
- name: dec
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
source: true
|
||||
destination: true
|
||||
- name: dec
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: ~
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: imul
|
||||
@@ -318,10 +283,10 @@ instruction_forms:
|
||||
- name: imul
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
@@ -337,19 +302,10 @@ instruction_forms:
|
||||
- name: inc
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
source: true
|
||||
destination: true
|
||||
- name: inc
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: ~
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: mulsd
|
||||
@@ -399,10 +355,10 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: sub
|
||||
@@ -412,36 +368,19 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: ~
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
- name: vfmadd132pd
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: ~
|
||||
index: "gpr"
|
||||
scale: 1
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
name: "ymm"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
name: "ymm"
|
||||
source: true
|
||||
destination: true
|
||||
- name: vfmadd132pd
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: "gpr"
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
@@ -455,27 +394,10 @@ instruction_forms:
|
||||
- name: vfmadd213pd
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: ~
|
||||
index: "gpr"
|
||||
scale: 1
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
name: "ymm"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
name: "ymm"
|
||||
source: true
|
||||
destination: true
|
||||
- name: vfmadd213pd
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: "gpr"
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
@@ -489,27 +411,10 @@ instruction_forms:
|
||||
- name: vfmadd231pd
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: "gpr"
|
||||
scale: 1
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
name: "ymm"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
name: "ymm"
|
||||
source: true
|
||||
destination: true
|
||||
- name: vfmadd231pd
|
||||
operands:
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: ~
|
||||
index: "gpr"
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: false
|
||||
- class: "register"
|
||||
@@ -545,9 +450,9 @@ instruction_forms:
|
||||
source: true
|
||||
destination: false
|
||||
- class: "memory"
|
||||
base: "gpr"
|
||||
offset: "imd"
|
||||
index: "gpr"
|
||||
scale: 1
|
||||
base: "*"
|
||||
offset: "*"
|
||||
index: "*"
|
||||
scale: "*"
|
||||
source: true
|
||||
destination: true
|
||||
|
||||
@@ -12,6 +12,8 @@ from osaca.parser import ParserX86ATT
|
||||
|
||||
|
||||
class MachineModel(object):
|
||||
WILDCARD = '*'
|
||||
|
||||
def __init__(self, arch=None, path_to_yaml=None, isa=None, lazy=False):
|
||||
if not arch and not path_to_yaml:
|
||||
if not isa:
|
||||
@@ -280,7 +282,9 @@ class MachineModel(object):
|
||||
operand_string += 'b' if operand['base'] is not None else ''
|
||||
operand_string += 'o' if operand['offset'] is not None else ''
|
||||
operand_string += 'i' if operand['index'] is not None else ''
|
||||
operand_string += 's' if operand['scale'] > 1 else ''
|
||||
operand_string += (
|
||||
's' if operand['scale'] == self.WILDCARD or operand['scale'] > 1 else ''
|
||||
)
|
||||
if 'pre-indexed' in operand:
|
||||
operand_string += 'r' if operand['pre-indexed'] else ''
|
||||
operand_string += 'p' if operand['post-indexed'] else ''
|
||||
@@ -349,7 +353,7 @@ class MachineModel(object):
|
||||
|
||||
def _check_operands(self, i_operand, operand):
|
||||
# check for wildcard
|
||||
if '*' in operand:
|
||||
if self.WILDCARD in operand:
|
||||
if (
|
||||
'class' in i_operand
|
||||
and i_operand['class'] == 'register'
|
||||
@@ -450,10 +454,15 @@ class MachineModel(object):
|
||||
def _is_AArch64_mem_type(self, i_mem, mem):
|
||||
if (
|
||||
# check base
|
||||
mem['base']['prefix'] == i_mem['base']
|
||||
(
|
||||
(mem['base'] is None and i_mem['base'] is None)
|
||||
or i_mem['base'] == self.WILDCARD
|
||||
or mem['base']['prefix'] == i_mem['base']
|
||||
)
|
||||
# check offset
|
||||
and (
|
||||
mem['offset'] == i_mem['offset']
|
||||
or i_mem['offset'] == self.WILDCARD
|
||||
or (
|
||||
mem['offset'] is not None
|
||||
and 'identifier' in mem['offset']
|
||||
@@ -468,15 +477,29 @@ class MachineModel(object):
|
||||
# check index
|
||||
and (
|
||||
mem['index'] == i_mem['index']
|
||||
or i_mem['index'] == self.WILDCARD
|
||||
or (
|
||||
mem['index'] is not None
|
||||
and 'prefix' in mem['index']
|
||||
and mem['index']['prefix'] == i_mem['index']
|
||||
)
|
||||
)
|
||||
and (mem['scale'] == i_mem['scale'] or (mem['scale'] != 1 and i_mem['scale'] != 1))
|
||||
and (('pre_indexed' in mem) == (i_mem['pre-indexed']))
|
||||
and (('post_indexed' in mem) == (i_mem['post-indexed']))
|
||||
# check scale
|
||||
and (
|
||||
mem['scale'] == i_mem['scale']
|
||||
or i_mem['scale'] == self.WILDCARD
|
||||
or (mem['scale'] != 1 and i_mem['scale'] != 1)
|
||||
)
|
||||
# check pre-indexing
|
||||
and (
|
||||
i_mem['pre-indexed'] == self.WILDCARD
|
||||
or ('pre_indexed' in mem) == (i_mem['pre-indexed'])
|
||||
)
|
||||
# check post-indexing
|
||||
and (
|
||||
i_mem['post-indexed'] == self.WILDCARD
|
||||
or ('post_indexed' in mem) == (i_mem['post-indexed'])
|
||||
)
|
||||
):
|
||||
return True
|
||||
return False
|
||||
@@ -484,10 +507,15 @@ class MachineModel(object):
|
||||
def _is_x86_mem_type(self, i_mem, mem):
|
||||
if (
|
||||
# check base
|
||||
self._is_x86_reg_type(i_mem['base'], mem['base'])
|
||||
(
|
||||
(mem['base'] is None and i_mem['base'] is None)
|
||||
or i_mem['base'] == self.WILDCARD
|
||||
or self._is_x86_reg_type(i_mem['base'], mem['base'])
|
||||
)
|
||||
# check offset
|
||||
and (
|
||||
mem['offset'] == i_mem['offset']
|
||||
or i_mem['offset'] == self.WILDCARD
|
||||
or (
|
||||
mem['offset'] is not None
|
||||
and 'identifier' in mem['offset']
|
||||
@@ -510,13 +538,19 @@ class MachineModel(object):
|
||||
# check index
|
||||
and (
|
||||
mem['index'] == i_mem['index']
|
||||
or i_mem['index'] == self.WILDCARD
|
||||
or (
|
||||
mem['index'] is not None
|
||||
and 'name' in mem['index']
|
||||
and self._is_x86_reg_type(i_mem['index'], mem['index'])
|
||||
)
|
||||
)
|
||||
and (mem['scale'] == i_mem['scale'] or (mem['scale'] != 1 and i_mem['scale'] != 1))
|
||||
# check scale
|
||||
and (
|
||||
mem['scale'] == i_mem['scale']
|
||||
or i_mem['scale'] == self.WILDCARD
|
||||
or (mem['scale'] != 1 and i_mem['scale'] != 1)
|
||||
)
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user