!114 ISA/ISAPI minor fixes

Merge pull request !114 from bolshov.maxim/master
This commit is contained in:
openharmony_ci 2022-03-30 10:58:53 +00:00 committed by Gitee
commit 031d76da4d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 54 additions and 12 deletions

View File

@ -49,6 +49,13 @@ def check_option(optparser, options, key)
exit false
end
def check_version
major, minor, = RUBY_VERSION.split('.').map(&:to_i)
major > 2 || (major == 2 && minor >= 5)
end
raise "Update your ruby version, #{RUBY_VERSION} is not supported" unless check_version
options = OpenStruct.new
optparser = OptionParser.new do |opts|

View File

@ -219,7 +219,7 @@ verification:
- tag: compatible_arguments
description: Arguments provided to a method must be of compatible types.
- tag: method_init_obj
description: Method_id must resolve into initializer for a type other than array.
description: Method_id must resolve into initializer for a type other than one-dimensional array.
- tag: branch_target
description: Branch target should point to a beginning of an instruction of the same method.
- tag: field_id_non_static
@ -2109,10 +2109,6 @@ groups:
raise exception(WrongRegisterValue) if false that type_of(@acc) is u32;
acc <~ u32toi64(@acc)
end when
when Op == "u32tou64" do
raise exception(WrongRegisterValue) if false that type_of(@acc) is u32;
acc <~ u32tou64(@acc)
end when
when Op == "u32toi16" do
raise exception(WrongRegisterValue) if false that type_of(@acc) is u32;
acc <~ u32toi16(@acc)
@ -2137,10 +2133,6 @@ groups:
raise exception(WrongRegisterValue) if false that type_of(@acc) is u64;
acc <~ u64tou32(@acc)
end when
when Op == "u64tou8" do
raise exception(WrongRegisterValue) if false that type_of(@acc) is u64;
acc <~ u64tou8(@acc)
end when
else raise exception(UndefinedSemantics)
undefined raise exception(InternalError)
end cases

View File

@ -64,6 +64,30 @@ module Util
end
end
module FreezeMixin
class << self
def included(base)
base.extend ClassMethods
end
end
module ClassMethods
def freeze_defined_methods
@frozen = instance_methods.map { |m| [m, true] }.to_h
end
def frozen?(name)
defined?(@frozen) && @frozen[name]
end
def method_added(name)
raise "Method '#{name}' has been already defined" if frozen?(name)
super
end
end
end
# Methods for YAML instructions
# 'Instruction' instances are created for every format of every isa.yaml
# instruction and inherit properties of its instruction group.
@ -204,6 +228,9 @@ class Invalid
def handler_name
'INVALID'
end
include FreezeMixin
freeze_defined_methods
end
# Methods over format names
@ -254,6 +281,9 @@ class Format
cached def pretty_helper
name.sub('op_', '')
end
include FreezeMixin
freeze_defined_methods
end
# Operand types and encoding
@ -303,6 +333,9 @@ class Operand
def size
@type[1..-1].to_i
end
include FreezeMixin
freeze_defined_methods
end
# Helper class for generating dispatch tables
@ -492,13 +525,23 @@ module Panda
hash
end
private_class_method def merge_group_and_insn(group, insn)
props = group.to_h
props.delete(:instructions)
props.merge(insn.to_h) do |_, old, new|
if old.is_a?(Array) && new.is_a?(Array)
old | new # extend array-like properties instead of overriding
else
new
end
end
end
private_class_method def each_data_instruction
# create separate instance for every instruction format and inherit group properties
@each_data_instruction ||= groups.each_with_object([]) do |g, obj|
g.instructions.each do |i|
props = g.to_h
props.delete(:instructions)
data_insn = props.merge(i.to_h) # instruction may override group props
data_insn = merge_group_and_insn(g, i)
if data_insn[:opcode_idx] && (data_insn[:opcode_idx].size != data_insn[:format].size)
raise 'format and opcode_idx arrays should have equal size'
end