5 /* arg is a primitive number */
7 /* arg is a literal table index, holding an array pair (symbol/dll) */
9 /* a pointer to a compiled word reference */
11 /* a word or quotation's general entry point */
13 /* a word's PIC entry point */
15 /* a word's tail-call PIC entry point */
19 /* current code block */
21 /* immediate literal */
23 /* address of ctx var */
25 /* untagged fixnum literal */
27 /* address of megamorphic_cache_hits var */
28 RT_MEGAMORPHIC_CACHE_HITS,
29 /* address of vm object */
31 /* value of vm->cards_offset */
33 /* value of vm->decks_offset */
37 enum relocation_class {
38 /* absolute address in a 64-bit location */
40 /* absolute address in a 32-bit location */
42 /* relative address in a 32-bit location */
44 /* absolute address in a PowerPC LIS/ORI sequence */
46 /* absolute address in a PowerPC LWZ instruction */
48 /* relative address in a PowerPC LWZ/STW/BC instruction */
50 /* relative address in a PowerPC B/BL instruction */
52 /* relative address in an ARM B/BL instruction */
54 /* pointer to address in an ARM LDR/STR instruction */
56 /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */
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 relocation_entry(u32 value_) : value(value_) {}
72 relocation_entry(relocation_type rel_type,
73 relocation_class rel_class,
76 value = (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()
111 case RT_MEGAMORPHIC_CACHE_HITS:
112 case RT_CARDS_OFFSET:
113 case RT_DECKS_OFFSET:
116 critical_error("Bad rel type",rel_type());
117 return -1; /* Can't happen */
122 struct instruction_operand {
126 instruction_operand(cell rel_class_, cell pointer_) :
127 rel_class(rel_class_), pointer(pointer_) {}
129 fixnum load_value_2_2();
130 fixnum load_value_masked(cell mask, fixnum shift);
131 fixnum load_value(cell relative_to);
133 code_block *load_code_block();
135 void store_value_2_2(fixnum value);
136 void store_value_masked(fixnum value, cell mask, fixnum shift);
137 void store_value(fixnum value);
138 void store_code_block(code_block *compiled);