5 /* arg is a primitive number */
7 /* arg is a literal table index, holding an array pair (symbol/dll) */
9 /* a word or quotation's general entry point */
11 /* a word's PIC entry point */
13 /* a word's tail-call PIC entry point */
14 RT_ENTRY_POINT_PIC_TAIL,
17 /* current code block */
19 /* data heap literal */
21 /* untagged fixnum literal */
23 /* address of megamorphic_cache_hits var */
24 RT_MEGAMORPHIC_CACHE_HITS,
25 /* address of vm object */
27 /* value of vm->cards_offset */
29 /* value of vm->decks_offset */
33 enum relocation_class {
34 /* absolute address in a 64-bit location */
36 /* absolute address in a 32-bit location */
38 /* relative address in a 32-bit location */
40 /* absolute address in a PowerPC LIS/ORI sequence */
42 /* absolute address in a PowerPC LWZ instruction */
44 /* relative address in a PowerPC LWZ/STW/BC instruction */
46 /* relative address in a PowerPC B/BL instruction */
48 /* relative address in an ARM B/BL instruction */
50 /* pointer to address in an ARM LDR/STR instruction */
52 /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */
54 /* absolute address in a 16-bit location */
58 static const cell rel_absolute_ppc_2_mask = 0xffff;
59 static const cell rel_relative_ppc_2_mask = 0xfffc;
60 static const cell rel_relative_ppc_3_mask = 0x3fffffc;
61 static const cell rel_indirect_arm_mask = 0xfff;
62 static const cell rel_relative_arm_3_mask = 0xffffff;
64 /* code relocation table consists of a table of entries for each fixup */
65 struct relocation_entry {
68 explicit relocation_entry(u32 value_) : value(value_) {}
70 relocation_entry(relocation_type rel_type,
71 relocation_class rel_class,
74 value = (rel_type << 28) | (rel_class << 24) | offset;
77 relocation_type rel_type()
79 return (relocation_type)((value & 0xf0000000) >> 28);
82 relocation_class rel_class()
84 return (relocation_class)((value & 0x0f000000) >> 24);
89 return (value & 0x00ffffff);
92 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:
113 critical_error("Bad rel type",rel_type());
114 return -1; /* Can't happen */
119 struct instruction_operand {
120 relocation_entry rel;
121 code_block *compiled;
125 instruction_operand(relocation_entry rel_, code_block *compiled_, cell index_);
127 relocation_type rel_type()
129 return rel.rel_type();
134 return rel.rel_offset();
137 cell parameter_index()
142 code_block *parent_code_block()
147 fixnum load_value_2_2();
148 fixnum load_value_masked(cell mask, cell bits, cell shift);
149 fixnum load_value(cell relative_to);
151 code_block *load_code_block(cell relative_to);
152 code_block *load_code_block();
154 void store_value_2_2(fixnum value);
155 void store_value_masked(fixnum value, cell mask, cell shift);
156 void store_value(fixnum value);
157 void store_code_block(code_block *compiled);