1 /*  GRAPHITE2 LICENSING
2 
3     Copyright 2010, SIL International
4     All rights reserved.
5 
6     This library is free software; you can redistribute it and/or modify
7     it under the terms of the GNU Lesser General Public License as published
8     by the Free Software Foundation; either version 2.1 of License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Lesser General Public License for more details.
15 
16     You should also have received a copy of the GNU Lesser General Public
17     License along with this library in the file named "LICENSE".
18     If not, write to the Free Software Foundation, 51 Franklin Street,
19     Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
20     internet at http://www.fsf.org/licenses/lgpl.html.
21 
22 Alternatively, the contents of this file may be used under the terms of the
23 Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
24 License, as published by the Free Software Foundation, either version 2
25 of the License or (at your option) any later version.
26 */
27 // This file will be pulled into and integrated into a machine implmentation
28 // DO NOT build directly
29 #pragma once
30 
31 #define do2(n)  do_(n) ,do_(n)
32 #define NILOP   0U
33 
34 // types or parameters are: (.. is inclusive)
35 //      number - any byte
36 //      output_class - 0 .. silf.m_nClass
37 //      input_class - 0 .. silf.m_nClass
38 //      sattrnum - 0 .. 29 (gr_slatJWidth) , 55 (gr_slatUserDefn)
39 //      attrid - 0 .. silf.numUser() where sattrnum == 55; 0..silf.m_iMaxComp where sattrnum == 15 otherwise 0
40 //      gattrnum - 0 .. face->getGlyphFaceCache->numAttrs()
41 //      gmetric - 0 .. 11 (kgmetDescent)
42 //      featidx - 0 .. face.numFeatures()
43 //      level - any byte
44 static const opcode_t opcode_table[] =
45 {
46     {{do2(nop)},                                    0, "NOP"},
47 
48     {{do2(push_byte)},                              1, "PUSH_BYTE"},                // number
49     {{do2(push_byte_u)},                            1, "PUSH_BYTE_U"},              // number
50     {{do2(push_short)},                             2, "PUSH_SHORT"},               // number number
51     {{do2(push_short_u)},                           2, "PUSH_SHORT_U"},             // number number
52     {{do2(push_long)},                              4, "PUSH_LONG"},                // number number number number
53 
54     {{do2(add)},                                    0, "ADD"},
55     {{do2(sub)},                                    0, "SUB"},
56     {{do2(mul)},                                    0, "MUL"},
57     {{do2(div_)},                                   0, "DIV"},
58     {{do2(min_)},                                   0, "MIN"},
59     {{do2(max_)},                                   0, "MAX"},
60     {{do2(neg)},                                    0, "NEG"},
61     {{do2(trunc8)},                                 0, "TRUNC8"},
62     {{do2(trunc16)},                                0, "TRUNC16"},
63 
64     {{do2(cond)},                                   0, "COND"},
65     {{do2(and_)},                                   0, "AND"},      // 0x10
66     {{do2(or_)},                                    0, "OR"},
67     {{do2(not_)},                                   0, "NOT"},
68     {{do2(equal)},                                  0, "EQUAL"},
69     {{do2(not_eq_)},                                0, "NOT_EQ"},
70     {{do2(less)},                                   0, "LESS"},
71     {{do2(gtr)},                                    0, "GTR"},
72     {{do2(less_eq)},                                0, "LESS_EQ"},
73     {{do2(gtr_eq)},                                 0, "GTR_EQ"},   // 0x18
74 
75     {{do_(next), NILOP},                            0, "NEXT"},
76     {{NILOP, NILOP},                                1, "NEXT_N"},                   // number <= smap.end - map
77     {{do_(next), NILOP},                            0, "COPY_NEXT"},
78     {{do_(put_glyph_8bit_obs), NILOP},              1, "PUT_GLYPH_8BIT_OBS"},       // output_class
79     {{do_(put_subs_8bit_obs), NILOP},               3, "PUT_SUBS_8BIT_OBS"},        // slot input_class output_class
80     {{do_(put_copy), NILOP},                        1, "PUT_COPY"},                 // slot
81     {{do_(insert), NILOP},                          0, "INSERT"},
82     {{do_(delete_), NILOP},                         0, "DELETE"},   // 0x20
83     {{do_(assoc), NILOP},                     VARARGS, "ASSOC"},
84     {{NILOP ,do_(cntxt_item)},                      2, "CNTXT_ITEM"},               // slot offset
85 
86     {{do_(attr_set), NILOP},                        1, "ATTR_SET"},                 // sattrnum
87     {{do_(attr_add), NILOP},                        1, "ATTR_ADD"},                 // sattrnum
88     {{do_(attr_sub), NILOP},                        1, "ATTR_SUB"},                 // sattrnum
89     {{do_(attr_set_slot), NILOP},                   1, "ATTR_SET_SLOT"},            // sattrnum
90     {{do_(iattr_set_slot), NILOP},                  2, "IATTR_SET_SLOT"},           // sattrnum attrid
91     {{do2(push_slot_attr)},                         2, "PUSH_SLOT_ATTR"},           // sattrnum slot
92     {{do2(push_glyph_attr_obs)},                    2, "PUSH_GLYPH_ATTR_OBS"},      // gattrnum slot
93     {{do2(push_glyph_metric)},                      3, "PUSH_GLYPH_METRIC"},        // gmetric slot level
94     {{do2(push_feat)},                              2, "PUSH_FEAT"},                // featidx slot
95 
96     {{do2(push_att_to_gattr_obs)},                  2, "PUSH_ATT_TO_GATTR_OBS"},    // gattrnum slot
97     {{do2(push_att_to_glyph_metric)},               3, "PUSH_ATT_TO_GLYPH_METRIC"}, // gmetric slot level
98     {{do2(push_islot_attr)},                        3, "PUSH_ISLOT_ATTR"},          // sattrnum slot attrid
99 
100     {{NILOP,NILOP},                                 3, "PUSH_IGLYPH_ATTR"},
101 
102     {{do2(pop_ret)},                                0, "POP_RET"},  // 0x30
103     {{do2(ret_zero)},                               0, "RET_ZERO"},
104     {{do2(ret_true)},                               0, "RET_TRUE"},
105 
106     {{do_(iattr_set), NILOP},                       2, "IATTR_SET"},                // sattrnum attrid
107     {{do_(iattr_add), NILOP},                       2, "IATTR_ADD"},                // sattrnum attrid
108     {{do_(iattr_sub), NILOP},                       2, "IATTR_SUB"},                // sattrnum attrid
109     {{do2(push_proc_state)},                        1, "PUSH_PROC_STATE"},          // dummy
110     {{do2(push_version)},                           0, "PUSH_VERSION"},
111     {{do_(put_subs), NILOP},                        5, "PUT_SUBS"},                 // slot input_class input_class output_class output_class
112     {{NILOP,NILOP},                                 0, "PUT_SUBS2"},
113     {{NILOP,NILOP},                                 0, "PUT_SUBS3"},
114     {{do_(put_glyph), NILOP},                       2, "PUT_GLYPH"},                // output_class output_class
115     {{do2(push_glyph_attr)},                        3, "PUSH_GLYPH_ATTR"},          // gattrnum gattrnum slot
116     {{do2(push_att_to_glyph_attr)},                 3, "PUSH_ATT_TO_GLYPH_ATTR"},   // gattrnum gattrnum slot
117     {{do2(bor)},                                    0, "BITOR"},
118     {{do2(band)},                                   0, "BITAND"},
119     {{do2(bnot)},                                   0, "BITNOT"},   // 0x40
120     {{do2(setbits)},                                4, "BITSET"},
121     {{do_(set_feat), NILOP},                        2, "SET_FEAT"},                 // featidx slot
122     // private opcodes for internal use only, comes after all other on disk opcodes.
123     {{do_(temp_copy), NILOP},                       0, "TEMP_COPY"}
124 };
125