summaryrefslogtreecommitdiff
path: root/template/optinsn.inc.tmpl
blob: b1fba6dea336a3ab5f2ed4ffe9024a3a2469104c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* -*-c-*- *********************************************************/
/*******************************************************************/
/*******************************************************************/
/**
  This file is for threaded code.

  ----
  This file is auto generated by insns2vm.rb
  DO NOT TOUCH!

  If you want to fix something, you must edit 'template/optinsn.inc.tmpl'
  or tool/insns2vm.rb
 */

static INSN *
insn_operands_unification(INSN *insnobj)
{
#ifdef OPT_OPERANDS_UNIFICATION
    /* optimize rule */
    switch(insnobj->insn_id){
%     opt_insns_map.each do |originsn, optinsns|
      case BIN(<%=originsn.name%>):
%       optinsns.each {|opti|
	if (
%         opti.defopes.each_with_index {|opinfo, i|
%           next if opinfo[1] == '*'
	    insnobj->operands[<%=i%>] == <%=val_as_type(opinfo)%> &&
%         }
	    1) {
%         idx = 0
%         opti.defopes.each_with_index {|opinfo, n|
%           if opinfo[1] == '*'
%             if idx != n
	    insnobj->operands[<%=idx%>] = insnobj->operands[<%=n%>];
%             end
%             idx += 1
%           end
% 	  }
	    insnobj->insn_id = BIN(<%=opti.name%>);
	    insnobj->operand_size = <%=idx%>;
	    break;
	}
%       }
	break;
%     end

      default:
	/* do nothing */;
	break;
    }
#endif
    return insnobj;
}

int
rb_insn_unified_local_var_level(VALUE insn)
{
#ifdef OPT_OPERANDS_UNIFICATION
    /* optimize rule */
    switch (insn) {
% opt_insns_map.each do |originsn, optinsns|
%   optinsns.each {|opti|
      case BIN(<%=opti.name%>):
%     opti.defopes.each {|opinfo|
%       next if opinfo[1] == '*'
	return <%=opinfo[1]%>;
%       break
%     }
%   }
% end

      default:
	/* do nothing */;
	break;
    }
#endif
    return -1;
}