| 1 | // SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later |
| 2 | // Copyright 2010, SIL International, All rights reserved. |
| 3 | |
| 4 | // This file will be pulled into and integrated into a machine implmentation |
| 5 | // DO NOT build directly |
| 6 | #pragma once |
| 7 | |
| 8 | #define do2(n) do_(n) ,do_(n) |
| 9 | #define NILOP 0U |
| 10 | |
| 11 | // types or parameters are: (.. is inclusive) |
| 12 | // number - any byte |
| 13 | // output_class - 0 .. silf.m_nClass |
| 14 | // input_class - 0 .. silf.m_nClass |
| 15 | // sattrnum - 0 .. 29 (gr_slatJWidth) , 55 (gr_slatUserDefn) |
| 16 | // attrid - 0 .. silf.numUser() where sattrnum == 55; 0..silf.m_iMaxComp where sattrnum == 15 otherwise 0 |
| 17 | // gattrnum - 0 .. face->getGlyphFaceCache->numAttrs() |
| 18 | // gmetric - 0 .. 11 (kgmetDescent) |
| 19 | // featidx - 0 .. face.numFeatures() |
| 20 | // level - any byte |
| 21 | static const opcode_t opcode_table[] = |
| 22 | { |
| 23 | {{do2(nop)}, 0, "NOP" }, |
| 24 | |
| 25 | {{do2(push_byte)}, 1, "PUSH_BYTE" }, // number |
| 26 | {{do2(push_byte_u)}, 1, "PUSH_BYTE_U" }, // number |
| 27 | {{do2(push_short)}, 2, "PUSH_SHORT" }, // number number |
| 28 | {{do2(push_short_u)}, 2, "PUSH_SHORT_U" }, // number number |
| 29 | {{do2(push_long)}, 4, "PUSH_LONG" }, // number number number number |
| 30 | |
| 31 | {{do2(add)}, 0, "ADD" }, |
| 32 | {{do2(sub)}, 0, "SUB" }, |
| 33 | {{do2(mul)}, 0, "MUL" }, |
| 34 | {{do2(div_)}, 0, "DIV" }, |
| 35 | {{do2(min_)}, 0, "MIN" }, |
| 36 | {{do2(max_)}, 0, "MAX" }, |
| 37 | {{do2(neg)}, 0, "NEG" }, |
| 38 | {{do2(trunc8)}, 0, "TRUNC8" }, |
| 39 | {{do2(trunc16)}, 0, "TRUNC16" }, |
| 40 | |
| 41 | {{do2(cond)}, 0, "COND" }, |
| 42 | {{do2(and_)}, 0, "AND" }, // 0x10 |
| 43 | {{do2(or_)}, 0, "OR" }, |
| 44 | {{do2(not_)}, 0, "NOT" }, |
| 45 | {{do2(equal)}, 0, "EQUAL" }, |
| 46 | {{do2(not_eq_)}, 0, "NOT_EQ" }, |
| 47 | {{do2(less)}, 0, "LESS" }, |
| 48 | {{do2(gtr)}, 0, "GTR" }, |
| 49 | {{do2(less_eq)}, 0, "LESS_EQ" }, |
| 50 | {{do2(gtr_eq)}, 0, "GTR_EQ" }, // 0x18 |
| 51 | |
| 52 | {{do_(next), NILOP}, 0, "NEXT" }, |
| 53 | {{NILOP, NILOP}, 1, "NEXT_N" }, // number <= smap.end - map |
| 54 | {{do_(next), NILOP}, 0, "COPY_NEXT" }, |
| 55 | {{do_(put_glyph_8bit_obs), NILOP}, 1, "PUT_GLYPH_8BIT_OBS" }, // output_class |
| 56 | {{do_(put_subs_8bit_obs), NILOP}, 3, "PUT_SUBS_8BIT_OBS" }, // slot input_class output_class |
| 57 | {{do_(put_copy), NILOP}, 1, "PUT_COPY" }, // slot |
| 58 | {{do_(insert), NILOP}, 0, "INSERT" }, |
| 59 | {{do_(delete_), NILOP}, 0, "DELETE" }, // 0x20 |
| 60 | {{do_(assoc), NILOP}, VARARGS, "ASSOC" }, |
| 61 | {{NILOP ,do_(cntxt_item)}, 2, "CNTXT_ITEM" }, // slot offset |
| 62 | |
| 63 | {{do_(attr_set), NILOP}, 1, "ATTR_SET" }, // sattrnum |
| 64 | {{do_(attr_add), NILOP}, 1, "ATTR_ADD" }, // sattrnum |
| 65 | {{do_(attr_sub), NILOP}, 1, "ATTR_SUB" }, // sattrnum |
| 66 | {{do_(attr_set_slot), NILOP}, 1, "ATTR_SET_SLOT" }, // sattrnum |
| 67 | {{do_(iattr_set_slot), NILOP}, 2, "IATTR_SET_SLOT" }, // sattrnum attrid |
| 68 | {{do2(push_slot_attr)}, 2, "PUSH_SLOT_ATTR" }, // sattrnum slot |
| 69 | {{do2(push_glyph_attr_obs)}, 2, "PUSH_GLYPH_ATTR_OBS" }, // gattrnum slot |
| 70 | {{do2(push_glyph_metric)}, 3, "PUSH_GLYPH_METRIC" }, // gmetric slot level |
| 71 | {{do2(push_feat)}, 2, "PUSH_FEAT" }, // featidx slot |
| 72 | |
| 73 | {{do2(push_att_to_gattr_obs)}, 2, "PUSH_ATT_TO_GATTR_OBS" }, // gattrnum slot |
| 74 | {{do2(push_att_to_glyph_metric)}, 3, "PUSH_ATT_TO_GLYPH_METRIC" }, // gmetric slot level |
| 75 | {{do2(push_islot_attr)}, 3, "PUSH_ISLOT_ATTR" }, // sattrnum slot attrid |
| 76 | |
| 77 | {{NILOP,NILOP}, 3, "PUSH_IGLYPH_ATTR" }, |
| 78 | |
| 79 | {{do2(pop_ret)}, 0, "POP_RET" }, // 0x30 |
| 80 | {{do2(ret_zero)}, 0, "RET_ZERO" }, |
| 81 | {{do2(ret_true)}, 0, "RET_TRUE" }, |
| 82 | |
| 83 | {{do_(iattr_set), NILOP}, 2, "IATTR_SET" }, // sattrnum attrid |
| 84 | {{do_(iattr_add), NILOP}, 2, "IATTR_ADD" }, // sattrnum attrid |
| 85 | {{do_(iattr_sub), NILOP}, 2, "IATTR_SUB" }, // sattrnum attrid |
| 86 | {{do2(push_proc_state)}, 1, "PUSH_PROC_STATE" }, // dummy |
| 87 | {{do2(push_version)}, 0, "PUSH_VERSION" }, |
| 88 | {{do_(put_subs), NILOP}, 5, "PUT_SUBS" }, // slot input_class input_class output_class output_class |
| 89 | {{NILOP,NILOP}, 0, "PUT_SUBS2" }, |
| 90 | {{NILOP,NILOP}, 0, "PUT_SUBS3" }, |
| 91 | {{do_(put_glyph), NILOP}, 2, "PUT_GLYPH" }, // output_class output_class |
| 92 | {{do2(push_glyph_attr)}, 3, "PUSH_GLYPH_ATTR" }, // gattrnum gattrnum slot |
| 93 | {{do2(push_att_to_glyph_attr)}, 3, "PUSH_ATT_TO_GLYPH_ATTR" }, // gattrnum gattrnum slot |
| 94 | {{do2(bor)}, 0, "BITOR" }, |
| 95 | {{do2(band)}, 0, "BITAND" }, |
| 96 | {{do2(bnot)}, 0, "BITNOT" }, // 0x40 |
| 97 | {{do2(setbits)}, 4, "BITSET" }, |
| 98 | {{do_(set_feat), NILOP}, 2, "SET_FEAT" }, // featidx slot |
| 99 | // private opcodes for internal use only, comes after all other on disk opcodes. |
| 100 | {{do_(temp_copy), NILOP}, 0, "TEMP_COPY" } |
| 101 | }; |
| 102 | |