4 // arg is a literal table index, holding a pair (symbol/dll)
6 // a word or quotation's general entry point
8 // a word's PIC entry point
10 // a word's tail-call PIC entry point
11 RT_ENTRY_POINT_PIC_TAIL,
18 // untagged fixnum literal
20 // address of megamorphic_cache_hits var
21 RT_MEGAMORPHIC_CACHE_HITS,
22 // address of vm object
24 // value of vm->cards_offset
26 // value of vm->decks_offset
29 // arg is a literal table index, holding a pair (symbol/dll)
31 // address of inline_cache_miss function. This is a separate
32 // relocation to reduce compile time and size for PICs.
34 // address of safepoint page in code heap
38 enum relocation_class {
39 // absolute address in a pointer-width location
41 // absolute address in a 4 byte location
43 // relative address in a 4 byte location
45 // absolute address in a PowerPC LIS/ORI sequence
47 // absolute address in a PowerPC LWZ instruction
49 // relative address in a PowerPC LWZ/STW/BC instruction
51 // relative address in a PowerPC B/BL instruction
53 // relative address in an ARM B/BL instruction
55 // pointer to address in an ARM LDR/STR instruction
57 // pointer to address in an ARM LDR/STR instruction offset by 8 bytes
59 // absolute address in a 2 byte location
61 // absolute address in a 1 byte location
63 // absolute address in a PowerPC LIS/ORI/SLDI/ORIS/ORI sequence
64 RC_ABSOLUTE_PPC_2_2_2_2,
67 static const cell rel_absolute_ppc_2_mask = 0x0000ffff;
68 static const cell rel_relative_ppc_2_mask = 0x0000fffc;
69 static const cell rel_relative_ppc_3_mask = 0x03fffffc;
70 static const cell rel_indirect_arm_mask = 0x00000fff;
71 static const cell rel_relative_arm_3_mask = 0x00ffffff;
73 // code relocation table consists of a table of entries for each fixup
74 struct relocation_entry {
77 explicit relocation_entry(uint32_t value) : value(value) {}
79 relocation_entry(relocation_type rel_type, relocation_class rel_class,
81 value = (uint32_t)((rel_type << 28) | (rel_class << 24) | offset);
84 relocation_type type() {
85 return (relocation_type)((value & 0xf0000000) >> 28);
88 relocation_class klass() {
89 return (relocation_class)((value & 0x0f000000) >> 24);
92 cell offset() { return (value & 0x00ffffff); }
94 int number_of_parameters() {
102 case RT_ENTRY_POINT_PIC:
103 case RT_ENTRY_POINT_PIC_TAIL:
108 case RT_MEGAMORPHIC_CACHE_HITS:
109 case RT_CARDS_OFFSET:
110 case RT_DECKS_OFFSET:
111 case RT_INLINE_CACHE_MISS:
115 critical_error("Bad rel type in number_of_parameters()", 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,
130 fixnum load_value_2_2();
131 fixnum load_value_2_2_2_2();
132 fixnum load_value_masked(cell mask, cell bits, cell shift);
133 fixnum load_value(cell relative_to);
134 code_block* load_code_block();
136 void store_value_2_2(fixnum value);
137 void store_value_2_2_2_2(fixnum value);
138 void store_value_masked(fixnum value, cell mask, cell shift);
139 void store_value(fixnum value);