summaryrefslogtreecommitdiff
path: root/jni/ruby/optinsn.inc
blob: 960a047720ac695ee5f423824d17274698d0d730 (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
79
80
81
82
83
/* -*-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){

case BIN(getlocal):
  if(
    insnobj->operands[1] == INT2FIX(0)
  ){
    insnobj->insn_id = BIN(getlocal_OP__WC__0);
    insnobj->operand_size = 1;
    break;
  }

  if(
    insnobj->operands[1] == INT2FIX(1)
  ){
    insnobj->insn_id = BIN(getlocal_OP__WC__1);
    insnobj->operand_size = 1;
    break;
  }

  break;
case BIN(setlocal):
  if(
    insnobj->operands[1] == INT2FIX(0)
  ){
    insnobj->insn_id = BIN(setlocal_OP__WC__0);
    insnobj->operand_size = 1;
    break;
  }

  if(
    insnobj->operands[1] == INT2FIX(1)
  ){
    insnobj->insn_id = BIN(setlocal_OP__WC__1);
    insnobj->operand_size = 1;
    break;
  }

  break;
case BIN(putobject):
  if(
    insnobj->operands[0] == INT2FIX(0)
  ){
    insnobj->insn_id = BIN(putobject_OP_INT2FIX_O_0_C_);
    insnobj->operand_size = 0;
    break;
  }

  if(
    insnobj->operands[0] == INT2FIX(1)
  ){
    insnobj->insn_id = BIN(putobject_OP_INT2FIX_O_1_C_);
    insnobj->operand_size = 0;
    break;
  }

  break;

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