mirror of
https://gitee.com/openharmony/ark_runtime_core
synced 2025-02-21 14:12:13 +00:00
!114 ISA/ISAPI minor fixes
Merge pull request !114 from bolshov.maxim/master
This commit is contained in:
commit
031d76da4d
@ -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|
|
||||
|
10
isa/isa.yaml
10
isa/isa.yaml
@ -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
|
||||
|
49
isa/isapi.rb
49
isa/isapi.rb
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user