diff options
Diffstat (limited to 'tool/ruby_vm/views/_insn_operand_info.erb')
-rw-r--r-- | tool/ruby_vm/views/_insn_operand_info.erb | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/tool/ruby_vm/views/_insn_operand_info.erb b/tool/ruby_vm/views/_insn_operand_info.erb index 688c466eda..f6b6565d59 100644 --- a/tool/ruby_vm/views/_insn_operand_info.erb +++ b/tool/ruby_vm/views/_insn_operand_info.erb @@ -11,35 +11,40 @@ % c = a.inject([0]) {|r, i| r << (r[-1] + i.length + 1) } % c.pop % -MAYBE_UNUSED(static const char *insn_op_types(VALUE insn)); -MAYBE_UNUSED(static int insn_op_type(VALUE insn, long pos)); +CONSTFUNC(MAYBE_UNUSED(static const char *insn_op_types(VALUE insn))); +CONSTFUNC(MAYBE_UNUSED(static int insn_op_type(VALUE insn, long pos))); +extern const char *rb_vm_insn_op_info; +extern const unsigned short rb_vm_insn_op_offset[]; -const char * -insn_op_types(VALUE i) -{ - static const unsigned short o[] = { +#ifdef RUBY_VM_INSNS_INFO +const unsigned short rb_vm_insn_op_offset[] = { % c.each_slice 14 do |d| - <%= d.map {|i| sprintf("%3d", i) }.join(', ') %>, + <%= d.map {|i| sprintf("%3d", i) }.join(', ') %>, % end - }; +}; +ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_op_offset); - PACKED_STRUCT(static const struct { +PACKED_STRUCT(struct rb_vm_insn_op_info_tag { % b.each_slice 3 do |d| - <%= d.map {|i| - sprintf("const char L%03d[%2d]", i, a[i].length + 1) - }.join('; ') %>; + <%= d.map {|i| + sprintf("const char L%03d[%2d]", i, a[i].length + 1) + }.join('; ') %>; % end +}); - }) t = { +static const struct rb_vm_insn_op_info_tag rb_vm_insn_op_base = { % a.each_slice 8 do |d| - <%= d.map {|i| sprintf("%-6s", cstr(i)) }.join(', ') %>, + <%= d.map {|i| sprintf("%-6s", cstr(i)) }.join(', ') %>, % end - }; +}; - ASSERT_VM_INSTRUCTION_SIZE(o); - static const char *p = (const char *)&t; +const char *rb_vm_insn_op_info = (const char *)&rb_vm_insn_op_base; +#endif - return &p[o[i]]; +const char * +insn_op_types(VALUE i) +{ + return &rb_vm_insn_op_info[rb_vm_insn_op_offset[i]]; } int |