5 /* arg is a literal table index, holding a pair (symbol/dll) */
7 /* a word or quotation's general entry point */
9 /* a word's PIC entry point */
11 /* a word's tail-call PIC entry point */
12 RT_ENTRY_POINT_PIC_TAIL,
15 /* current code block */
17 /* data heap literal */
19 /* untagged fixnum literal */
21 /* address of megamorphic_cache_hits var */
22 RT_MEGAMORPHIC_CACHE_HITS,
23 /* address of vm object */
25 /* value of vm->cards_offset */
27 /* value of vm->decks_offset */
31 enum relocation_class {
32 /* absolute address in a 64-bit location */
34 /* absolute address in a 32-bit location */
36 /* relative address in a 32-bit location */
38 /* absolute address in a PowerPC LIS/ORI sequence */
40 /* absolute address in a PowerPC LWZ instruction */
42 /* relative address in a PowerPC LWZ/STW/BC instruction */
44 /* relative address in a PowerPC B/BL instruction */
46 /* relative address in an ARM B/BL instruction */
48 /* pointer to address in an ARM LDR/STR instruction */
50 /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */
52 /* absolute address in a 16-bit location */
56 static const cell rel_absolute_ppc_2_mask = 0xffff;
57 static const cell rel_relative_ppc_2_mask = 0xfffc;
58 static const cell rel_relative_ppc_3_mask = 0x3fffffc;
59 static const cell rel_indirect_arm_mask = 0xfff;
60 static const cell rel_relative_arm_3_mask = 0xffffff;
62 /* code relocation table consists of a table of entries for each fixup */
63 struct relocation_entry {
66 explicit relocation_entry(u32 value_) : value(value_) {}
68 relocation_entry(relocation_type rel_type,
69 relocation_class rel_class,
72 value = (u32)((rel_type << 28) | (rel_class << 24) | offset);
75 relocation_type rel_type()
77 return (relocation_type)((value & 0xf0000000) >> 28);
80 relocation_class rel_class()
82 return (relocation_class)((value & 0x0f000000) >> 24);
87 return (value & 0x00ffffff);
90 int number_of_parameters()
99 case RT_ENTRY_POINT_PIC:
100 case RT_ENTRY_POINT_PIC_TAIL:
105 case RT_MEGAMORPHIC_CACHE_HITS:
106 case RT_CARDS_OFFSET:
107 case RT_DECKS_OFFSET:
110 critical_error("Bad rel type",rel_type());
111 return -1; /* Can't happen */
116 struct instruction_operand {
117 relocation_entry rel;
118 code_block *compiled;
122 instruction_operand(relocation_entry rel_, code_block *compiled_, cell index_);
124 relocation_type rel_type()
126 return rel.rel_type();
131 return rel.rel_offset();
134 cell parameter_index()
139 code_block *parent_code_block()
144 fixnum load_value_2_2();
145 fixnum load_value_masked(cell mask, cell bits, cell shift);
146 fixnum load_value(cell relative_to);
148 code_block *load_code_block(cell relative_to);
149 code_block *load_code_block();
151 void store_value_2_2(fixnum value);
152 void store_value_masked(fixnum value, cell mask, cell shift);
153 void store_value(fixnum value);
154 void store_code_block(code_block *compiled);