2018-01-12 03:38:09 -05:00
|
|
|
%# -*- mode:c; style:ruby; coding: utf-8; indent-tabs-mode: nil -*-
|
|
|
|
%# Copyright (c) 2017 Urabe, Shyouhei. All rights reserved.
|
|
|
|
%#
|
|
|
|
%# This file is a part of the programming language Ruby. Permission is hereby
|
|
|
|
%# granted, to either redistribute and/or modify this file, provided that the
|
|
|
|
%# conditions mentioned in the file COPYING are met. Consult the file for
|
|
|
|
%# details.
|
|
|
|
%;
|
|
|
|
|
|
|
|
/* insn <%= insn.pretty_name %> */
|
|
|
|
INSN_ENTRY(<%= insn.name %>)
|
|
|
|
{
|
2018-01-29 01:47:05 -05:00
|
|
|
%# NAME_OF_CURRENT_INSN is used in vm_exec.h
|
|
|
|
# define NAME_OF_CURRENT_INSN <%= insn.name %>
|
|
|
|
# define INSN_ATTR(x) <%= insn.call_attribute(' ## x ## ') %>
|
2018-01-12 03:38:09 -05:00
|
|
|
% unless insn.declarations.empty?
|
|
|
|
<%= insn.declarations.join(";\n ") %>;
|
|
|
|
|
|
|
|
% end
|
|
|
|
START_OF_ORIGINAL_INSN(<%= insn.name %>);
|
|
|
|
% insn.preamble.each do |konst|
|
|
|
|
<%= render_c_expr konst -%>
|
|
|
|
% end
|
|
|
|
% insn.opes.each_with_index do |ope, i|
|
|
|
|
<%= ope[:name] %> = (<%= ope[:type] %>)GET_OPERAND(<%= i + 1 %>);
|
|
|
|
% end
|
|
|
|
%
|
|
|
|
% insn.pops.reverse_each.with_index.reverse_each do |pop, i|
|
|
|
|
<%= pop[:name] %> = <%= insn.cast_from_VALUE pop, "TOPN(#{i})"%>;
|
|
|
|
% end
|
2018-01-29 01:47:05 -05:00
|
|
|
DEBUG_ENTER_INSN(INSN_ATTR(name));
|
2018-01-26 01:30:58 -05:00
|
|
|
% if insn.handles_frame?
|
2018-01-29 01:47:05 -05:00
|
|
|
ADD_PC(INSN_ATTR(width));
|
|
|
|
POPN(INSN_ATTR(popn));
|
2018-01-12 03:38:09 -05:00
|
|
|
% end
|
2018-01-29 01:47:05 -05:00
|
|
|
COLLECT_USAGE_INSN(INSN_ATTR(bin));
|
2018-01-12 03:38:09 -05:00
|
|
|
% insn.opes.each_with_index do |ope, i|
|
2018-01-29 01:47:05 -05:00
|
|
|
COLLECT_USAGE_OPERAND(INSN_ATTR(bin), <%= i %>, <%= ope[:name] %>);
|
2018-01-12 03:38:09 -05:00
|
|
|
% end
|
|
|
|
<%= render_c_expr insn.expr -%>
|
2018-01-29 01:47:05 -05:00
|
|
|
CHECK_VM_STACK_OVERFLOW_FOR_INSN(VM_REG_CFP, INSN_ATTR(retn));
|
2018-01-29 01:56:56 -05:00
|
|
|
% if insn.handles_frame?
|
|
|
|
% insn.rets.reverse_each do |ret|
|
2018-01-12 03:38:09 -05:00
|
|
|
PUSH(<%= insn.cast_to_VALUE ret %>);
|
|
|
|
% end
|
2018-01-29 01:56:56 -05:00
|
|
|
% else
|
|
|
|
ADJ_SP(INSN_ATTR(sp_inc));
|
|
|
|
% insn.rets.reverse_each.with_index do |ret, i|
|
|
|
|
TOPN(<%= i %>) = <%= insn.cast_to_VALUE ret %>;
|
|
|
|
% end
|
2018-01-29 01:47:05 -05:00
|
|
|
ADD_PC(INSN_ATTR(width));
|
2018-01-26 01:30:58 -05:00
|
|
|
PREFETCH(GET_PC());
|
|
|
|
% end
|
2018-01-12 03:38:09 -05:00
|
|
|
END_INSN(<%= insn.name %>);
|
2018-01-29 01:47:05 -05:00
|
|
|
# undef INSN_ATTR
|
|
|
|
# undef NAME_OF_CURRENT_INSN
|
2018-01-12 03:38:09 -05:00
|
|
|
}
|