summaryrefslogtreecommitdiff
path: root/template/insns_info.inc.tmpl
blob: 8f63cea9ea1f03dfe7d93138e512fcf61bfd623a (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
/** -*-c-*-
  This file contains instruction information for yarv instruction sequence.
  
  ----
  This file is auto generated by insns2vm.rb
  DO NOT TOUCH!
  
  If you want to fix something, you must edit 'template/insns_info.inc.tmpl'
  or insns2vm.rb
 */

<%= insn_type_chars %>

static char *insn_name_info[] = {
<%= insn_names %>
};

static char *insn_operand_info[] = {
<%= operands_info %>
};

static int insn_len_info[] = {
<%= operands_num_info %>
};

static int insn_stack_push_num_info[] = {
<%= stack_num_info %>
};

static int
insn_stack_increase(int depth, int insn, VALUE *opes)
{
  switch(insn){
<%= stack_increase %>
  default:
    rb_bug("insn_sp_increase: unreachable");
  }
  return 0;
}

/* some utilities */

static int
insn_len(int insn)
{
  return insn_len_info[insn];
}

static char *
insn_name(int insn)
{
  return insn_name_info[insn];
}

static char *
insn_op_types(int insn)
{
  return insn_operand_info[insn];
}

static int
insn_op_type(int insn, int pos)
{
  int len = insn_len(insn) - 1;
  if(pos < len){
    return insn_operand_info[insn][pos];
  }
  else{
    return 0;
  }
}

static int
insn_ret_num(int insn)
{
  return insn_stack_push_num_info[insn];
}