Rename opes to operands on RubyVM::BaseInstruction
This commit is contained in:
parent
8dbddd5bf8
commit
617c9b4656
Notes:
git
2023-03-16 21:17:19 +00:00
@ -21,7 +21,7 @@ class RubyVM::Attribute
|
||||
@key = opts[:name]
|
||||
@expr = RubyVM::CExpr.new location: opts[:location], expr: opts[:expr]
|
||||
@type = opts[:type]
|
||||
@ope_decls = @insn.opes.map do |operand|
|
||||
@ope_decls = @insn.operands.map do |operand|
|
||||
decl = operand[:decl]
|
||||
if @key == 'comptime_sp_inc' && operand[:type] == 'CALL_DATA'
|
||||
decl = decl.gsub('CALL_DATA', 'CALL_INFO').gsub('cd', 'ci')
|
||||
|
@ -16,7 +16,7 @@ require_relative 'typemap'
|
||||
require_relative 'attribute'
|
||||
|
||||
class RubyVM::BareInstructions
|
||||
attr_reader :template, :name, :opes, :pops, :rets, :decls, :expr
|
||||
attr_reader :template, :name, :operands, :pops, :rets, :decls, :expr
|
||||
|
||||
def initialize opts = {}
|
||||
@template = opts[:template]
|
||||
@ -24,7 +24,7 @@ class RubyVM::BareInstructions
|
||||
@loc = opts[:location]
|
||||
@sig = opts[:signature]
|
||||
@expr = RubyVM::CExpr.new opts[:expr]
|
||||
@opes = typesplit @sig[:ope]
|
||||
@operands = typesplit @sig[:ope]
|
||||
@pops = typesplit @sig[:pop].reject {|i| i == '...' }
|
||||
@rets = typesplit @sig[:ret].reject {|i| i == '...' }
|
||||
@attrs = opts[:attributes].map {|i|
|
||||
@ -51,7 +51,7 @@ class RubyVM::BareInstructions
|
||||
|
||||
def call_attribute name
|
||||
return sprintf 'attr_%s_%s(%s)', name, @name, \
|
||||
@opes.map {|i| i[:name] }.compact.join(', ')
|
||||
@operands.map {|i| i[:name] }.compact.join(', ')
|
||||
end
|
||||
|
||||
def has_attribute? k
|
||||
@ -65,7 +65,7 @@ class RubyVM::BareInstructions
|
||||
end
|
||||
|
||||
def width
|
||||
return 1 + opes.size
|
||||
return 1 + operands.size
|
||||
end
|
||||
|
||||
def declarations
|
||||
@ -98,7 +98,7 @@ class RubyVM::BareInstructions
|
||||
end
|
||||
|
||||
def operands_info
|
||||
opes.map {|o|
|
||||
operands.map {|o|
|
||||
c, _ = RubyVM::Typemap.fetch o[:type]
|
||||
next c
|
||||
}.join
|
||||
@ -137,7 +137,7 @@ class RubyVM::BareInstructions
|
||||
end
|
||||
|
||||
def has_ope? var
|
||||
return @opes.any? {|i| i[:name] == var[:name] }
|
||||
return @operands.any? {|i| i[:name] == var[:name] }
|
||||
end
|
||||
|
||||
def has_pop? var
|
||||
@ -180,7 +180,7 @@ class RubyVM::BareInstructions
|
||||
# Beware: order matters here because some attribute depends another.
|
||||
generate_attribute 'const char*', 'name', "insn_name(#{bin})"
|
||||
generate_attribute 'enum ruby_vminsn_type', 'bin', bin
|
||||
generate_attribute 'rb_num_t', 'open', opes.size
|
||||
generate_attribute 'rb_num_t', 'open', operands.size
|
||||
generate_attribute 'rb_num_t', 'popn', pops.size
|
||||
generate_attribute 'rb_num_t', 'retn', rets.size
|
||||
generate_attribute 'rb_num_t', 'width', width
|
||||
@ -191,7 +191,7 @@ class RubyVM::BareInstructions
|
||||
|
||||
def default_definition_of_handles_sp
|
||||
# Insn with ISEQ should yield it; can handle sp.
|
||||
return opes.any? {|o| o[:type] == 'ISEQ' }
|
||||
return operands.any? {|o| o[:type] == 'ISEQ' }
|
||||
end
|
||||
|
||||
def default_definition_of_leaf
|
||||
|
@ -38,8 +38,8 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
|
||||
end
|
||||
|
||||
def operand_shift_of var
|
||||
before = @original.opes.find_index var
|
||||
after = @opes.find_index var
|
||||
before = @original.operands.find_index var
|
||||
after = @operands.find_index var
|
||||
raise "no #{var} for #{@name}" unless before and after
|
||||
return before - after
|
||||
end
|
||||
@ -50,7 +50,7 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
|
||||
case val when '*' then
|
||||
next nil
|
||||
else
|
||||
type = @original.opes[i][:type]
|
||||
type = @original.operands[i][:type]
|
||||
expr = RubyVM::Typemap.typecast_to_VALUE type, val
|
||||
next "#{ptr}[#{i}] == #{expr}"
|
||||
end
|
||||
@ -85,7 +85,7 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
|
||||
def compose location, spec, template
|
||||
name = namegen spec
|
||||
*, argv = *spec
|
||||
opes = @original.opes
|
||||
opes = @original.operands
|
||||
if opes.size != argv.size
|
||||
raise sprintf("operand size mismatch for %s (%s's: %d, given: %d)",
|
||||
name, template[:name], opes.size, argv.size)
|
||||
|
@ -42,7 +42,7 @@ comptime_insn_stack_increase_dispatch(enum ruby_vminsn_type insn, const VALUE *o
|
||||
% end
|
||||
case <%= i.bin %>:
|
||||
return <%= attr_function %>(<%=
|
||||
i.opes.map.with_index do |v, j|
|
||||
i.operands.map.with_index do |v, j|
|
||||
if v[:type] == 'CALL_DATA' && i.has_attribute?('comptime_sp_inc')
|
||||
v = v.dup
|
||||
v[:type] = 'CALL_INFO'
|
||||
|
@ -20,7 +20,7 @@ INSN_ENTRY(<%= insn.name %>)
|
||||
<%= render_c_expr konst -%>
|
||||
% end
|
||||
%
|
||||
% insn.opes.each_with_index do |ope, i|
|
||||
% insn.operands.each_with_index do |ope, i|
|
||||
<%= ope[:decl] %> = (<%= ope[:type] %>)GET_OPERAND(<%= i + 1 %>);
|
||||
% end
|
||||
# define INSN_ATTR(x) <%= insn.call_attribute(' ## x ## ') %>
|
||||
@ -41,7 +41,7 @@ INSN_ENTRY(<%= insn.name %>)
|
||||
% end
|
||||
<%= insn.handle_canary "SETUP_CANARY(leaf)" -%>
|
||||
COLLECT_USAGE_INSN(INSN_ATTR(bin));
|
||||
% insn.opes.each_with_index do |ope, i|
|
||||
% insn.operands.each_with_index do |ope, i|
|
||||
COLLECT_USAGE_OPERAND(INSN_ATTR(bin), <%= i %>, <%= ope[:name] %>);
|
||||
% end
|
||||
% unless body.empty?
|
||||
|
@ -7,7 +7,7 @@ module RubyVM::RJIT # :nodoc: all
|
||||
name: :<%= insn.name %>,
|
||||
bin: <%= i %>, # BIN(<%= insn.name %>)
|
||||
len: <%= insn.width %>, # insn_len
|
||||
operands: <%= (insn.opes unless insn.name.start_with?('trace_')).inspect %>,
|
||||
operands: <%= (insn.operands unless insn.name.start_with?('trace_')).inspect %>,
|
||||
),
|
||||
% end
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ insn_operands_unification(INSN *iobj)
|
||||
|
||||
/* <%= insn.pretty_name %> */
|
||||
if ( <%= insn.condition('op') %> ) {
|
||||
% insn.opes.each_with_index do |o, x|
|
||||
% insn.operands.each_with_index do |o, x|
|
||||
% n = insn.operand_shift_of(o)
|
||||
% if n != 0 then
|
||||
op[<%= x %>] = op[<%= x + n %>];
|
||||
% end
|
||||
% end
|
||||
iobj->insn_id = <%= insn.bin %>;
|
||||
iobj->operand_size = <%= insn.opes.size %>;
|
||||
iobj->operand_size = <%= insn.operands.size %>;
|
||||
break;
|
||||
}
|
||||
% end
|
||||
|
Loading…
x
Reference in New Issue
Block a user