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 */
29 /* address of exception_handler -- this exists as a separate relocation
30 type since its used in a situation where relocation arguments cannot
31 be passed in, and so RT_DLSYM is inappropriate (Windows only) */
35 enum relocation_class {
36 /* absolute address in a 64-bit location */
38 /* absolute address in a 32-bit location */
40 /* relative address in a 32-bit location */
42 /* absolute address in a PowerPC LIS/ORI sequence */
44 /* absolute address in a PowerPC LWZ instruction */
46 /* relative address in a PowerPC LWZ/STW/BC instruction */
48 /* relative address in a PowerPC B/BL instruction */
50 /* relative address in an ARM B/BL instruction */
52 /* pointer to address in an ARM LDR/STR instruction */
54 /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */
56 /* absolute address in a 16-bit location */
60 static const cell rel_absolute_ppc_2_mask = 0xffff;
61 static const cell rel_relative_ppc_2_mask = 0xfffc;
62 static const cell rel_relative_ppc_3_mask = 0x3fffffc;
63 static const cell rel_indirect_arm_mask = 0xfff;
64 static const cell rel_relative_arm_3_mask = 0xffffff;
66 /* code relocation table consists of a table of entries for each fixup */
67 struct relocation_entry {
70 explicit relocation_entry(u32 value_) : value(value_) {}
72 relocation_entry(relocation_type rel_type,
73 relocation_class rel_class,
76 value = (u32)((rel_type << 28) | (rel_class << 24) | offset);
79 relocation_type rel_type()
81 return (relocation_type)((value & 0xf0000000) >> 28);
84 relocation_class rel_class()
86 return (relocation_class)((value & 0x0f000000) >> 24);
91 return (value & 0x00ffffff);
94 int number_of_parameters()
103 case RT_ENTRY_POINT_PIC:
104 case RT_ENTRY_POINT_PIC_TAIL:
109 case RT_MEGAMORPHIC_CACHE_HITS:
110 case RT_CARDS_OFFSET:
111 case RT_DECKS_OFFSET:
112 case RT_EXCEPTION_HANDLER:
115 critical_error("Bad rel type",rel_type());
116 return -1; /* Can't happen */
121 struct instruction_operand {
122 relocation_entry rel;
123 code_block *compiled;
127 instruction_operand(relocation_entry rel_, code_block *compiled_, cell index_);
129 relocation_type rel_type()
131 return rel.rel_type();
136 return rel.rel_offset();
139 cell parameter_index()
144 code_block *parent_code_block()
149 fixnum load_value_2_2();
150 fixnum load_value_masked(cell mask, cell bits, cell shift);
151 fixnum load_value(cell relative_to);
153 code_block *load_code_block(cell relative_to);
154 code_block *load_code_block();
156 void store_value_2_2(fixnum value);
157 void store_value_masked(fixnum value, cell mask, cell shift);
158 void store_value(fixnum value);
159 void store_code_block(code_block *compiled);