Skip to content

Commit d067693

Browse files
Add arc compiler-rt functions and reloc type for mwdt (#1238)
Add arc compiler-rt functions and reloc type for arc MetaWare Development Toolkit (mwdt), controlled by macro __CCAC__.
1 parent f975a98 commit d067693

File tree

1 file changed

+168
-13
lines changed

1 file changed

+168
-13
lines changed

core/iwasm/aot/arch/aot_reloc_arc.c

Lines changed: 168 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define R_ARC_32_ME 27
1414

1515
/* clang-format off */
16+
#ifndef __CCAC__
1617
void __st_r13_to_r15();
1718
void __st_r13_to_r16();
1819
void __st_r13_to_r17();
@@ -41,29 +42,86 @@ void __divdf3();
4142
void __divdi3();
4243
void __divsf3();
4344
void __divsi3();
44-
void __eqsf2();
4545
void __extendsfdf2();
4646
void __fixdfsi();
4747
void __floatsidf();
4848
void __floatsisf();
49-
void __gedf2();
50-
void __gtdf2();
51-
void __ledf2();
52-
void __lesf2();
53-
void __ltdf2();
5449
void __muldf3();
5550
void __mulsf3();
5651
void __subdf3();
5752
void __subsf3();
5853
void __truncdfsf2();
54+
#else
55+
void __ac_push_13_to_13();
56+
void __ac_push_13_to_14();
57+
void __ac_push_13_to_15();
58+
void __ac_push_13_to_16();
59+
void __ac_push_13_to_17();
60+
void __ac_push_13_to_18();
61+
void __ac_push_13_to_19();
62+
void __ac_push_13_to_20();
63+
void __ac_push_13_to_21();
64+
void __ac_push_13_to_22();
65+
void __ac_push_13_to_23();
66+
void __ac_push_13_to_24();
67+
void __ac_push_13_to_25();
68+
void __ac_push_13_to_26();
69+
void __ac_push_none();
70+
void __ac_pop_13_to_26();
71+
void __ac_pop_13_to_26v();
72+
void __ac_pop_13_to_25();
73+
void __ac_pop_13_to_25v();
74+
void __ac_pop_13_to_24();
75+
void __ac_pop_13_to_24v();
76+
void __ac_pop_13_to_23();
77+
void __ac_pop_13_to_23v();
78+
void __ac_pop_13_to_22();
79+
void __ac_pop_13_to_22v();
80+
void __ac_pop_13_to_21();
81+
void __ac_pop_13_to_21v();
82+
void __ac_pop_13_to_20();
83+
void __ac_pop_13_to_20v();
84+
void __ac_pop_13_to_19();
85+
void __ac_pop_13_to_19v();
86+
void __ac_pop_13_to_18();
87+
void __ac_pop_13_to_18v();
88+
void __ac_pop_13_to_17();
89+
void __ac_pop_13_to_17v();
90+
void __ac_pop_13_to_16();
91+
void __ac_pop_13_to_16v();
92+
void __ac_pop_13_to_15();
93+
void __ac_pop_13_to_15v();
94+
void __ac_pop_13_to_14();
95+
void __ac_pop_13_to_14v();
96+
void __ac_pop_13_to_13();
97+
void __ac_pop_13_to_13v();
98+
void __ac_pop_none();
99+
void __ac_pop_nonev();
100+
void __eqdf2();
101+
void __nedf2();
102+
void __ltsf2();
103+
void __nesf2();
104+
void __gesf2();
105+
void __gtsf2();
106+
void __unordsf2();
107+
void __truncdfhf2();
108+
void __truncsfhf2();
109+
#endif /* end of __CCAC__ */
110+
111+
void __ledf2();
112+
void __ltdf2();
113+
void __gedf2();
114+
void __gtdf2();
115+
void __eqsf2();
116+
void __lesf2();
59117
void __unorddf2();
60118
/* clang-format on */
61119

62120
static SymbolMap target_sym_map[] = {
63121
/* clang-format off */
64122
REG_COMMON_SYMBOLS
123+
#ifndef __CCAC__
65124
REG_SYM(__st_r13_to_r15),
66-
/* clang-format on */
67125
REG_SYM(__st_r13_to_r16),
68126
REG_SYM(__st_r13_to_r17),
69127
REG_SYM(__st_r13_to_r18),
@@ -91,22 +149,80 @@ static SymbolMap target_sym_map[] = {
91149
REG_SYM(__divdi3),
92150
REG_SYM(__divsf3),
93151
REG_SYM(__divsi3),
94-
REG_SYM(__eqsf2),
95152
REG_SYM(__extendsfdf2),
96153
REG_SYM(__fixdfsi),
97154
REG_SYM(__floatsidf),
98155
REG_SYM(__floatsisf),
99-
REG_SYM(__gedf2),
100-
REG_SYM(__gtdf2),
101-
REG_SYM(__ledf2),
102-
REG_SYM(__lesf2),
103-
REG_SYM(__ltdf2),
104156
REG_SYM(__muldf3),
105157
REG_SYM(__mulsf3),
106158
REG_SYM(__subdf3),
107159
REG_SYM(__subsf3),
108160
REG_SYM(__truncdfsf2),
161+
#else
162+
REG_SYM(__ac_push_13_to_13),
163+
REG_SYM(__ac_push_13_to_14),
164+
REG_SYM(__ac_push_13_to_15),
165+
REG_SYM(__ac_push_13_to_16),
166+
REG_SYM(__ac_push_13_to_17),
167+
REG_SYM(__ac_push_13_to_18),
168+
REG_SYM(__ac_push_13_to_19),
169+
REG_SYM(__ac_push_13_to_20),
170+
REG_SYM(__ac_push_13_to_21),
171+
REG_SYM(__ac_push_13_to_22),
172+
REG_SYM(__ac_push_13_to_23),
173+
REG_SYM(__ac_push_13_to_24),
174+
REG_SYM(__ac_push_13_to_25),
175+
REG_SYM(__ac_push_13_to_26),
176+
REG_SYM(__ac_push_none),
177+
REG_SYM(__ac_pop_13_to_26),
178+
REG_SYM(__ac_pop_13_to_26v),
179+
REG_SYM(__ac_pop_13_to_25),
180+
REG_SYM(__ac_pop_13_to_25v),
181+
REG_SYM(__ac_pop_13_to_24),
182+
REG_SYM(__ac_pop_13_to_24v),
183+
REG_SYM(__ac_pop_13_to_23),
184+
REG_SYM(__ac_pop_13_to_23v),
185+
REG_SYM(__ac_pop_13_to_22),
186+
REG_SYM(__ac_pop_13_to_22v),
187+
REG_SYM(__ac_pop_13_to_21),
188+
REG_SYM(__ac_pop_13_to_21v),
189+
REG_SYM(__ac_pop_13_to_20),
190+
REG_SYM(__ac_pop_13_to_20v),
191+
REG_SYM(__ac_pop_13_to_19),
192+
REG_SYM(__ac_pop_13_to_19v),
193+
REG_SYM(__ac_pop_13_to_18),
194+
REG_SYM(__ac_pop_13_to_18v),
195+
REG_SYM(__ac_pop_13_to_17),
196+
REG_SYM(__ac_pop_13_to_17v),
197+
REG_SYM(__ac_pop_13_to_16),
198+
REG_SYM(__ac_pop_13_to_16v),
199+
REG_SYM(__ac_pop_13_to_15),
200+
REG_SYM(__ac_pop_13_to_15v),
201+
REG_SYM(__ac_pop_13_to_14),
202+
REG_SYM(__ac_pop_13_to_14v),
203+
REG_SYM(__ac_pop_13_to_13),
204+
REG_SYM(__ac_pop_13_to_13v),
205+
REG_SYM(__ac_pop_none),
206+
REG_SYM(__ac_pop_nonev),
207+
REG_SYM(__eqdf2),
208+
REG_SYM(__nedf2),
209+
REG_SYM(__ltsf2),
210+
REG_SYM(__nesf2),
211+
REG_SYM(__gesf2),
212+
REG_SYM(__gtsf2),
213+
REG_SYM(__unordsf2),
214+
REG_SYM(__truncdfhf2),
215+
REG_SYM(__truncsfhf2),
216+
#endif /* end of __CCAC__ */
217+
218+
REG_SYM(__ledf2),
219+
REG_SYM(__ltdf2),
220+
REG_SYM(__gedf2),
221+
REG_SYM(__gtdf2),
222+
REG_SYM(__eqsf2),
223+
REG_SYM(__lesf2),
109224
REG_SYM(__unorddf2),
225+
/* clang-format on */
110226
};
111227

112228
static void
@@ -168,6 +284,45 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
168284
int32 symbol_index, char *error_buf, uint32 error_buf_size)
169285
{
170286
switch (reloc_type) {
287+
case R_ARC_S25H_PCREL:
288+
{
289+
uint32 insn = LOAD_I32(target_section_addr + reloc_offset);
290+
int32 addend, value;
291+
uintptr_t S, P;
292+
intptr_t A;
293+
294+
CHECK_RELOC_OFFSET(sizeof(void *));
295+
296+
/* Convert from middle endian */
297+
insn = middle_endian_convert(insn);
298+
299+
addend = ((insn << 28) >> 28) << 10;
300+
/* Extract the next 10 bits from Position 6 to 15 in insn */
301+
addend |= ((insn << 16) >> 22);
302+
addend = addend << 10;
303+
/* Extract the remaining 10 bits from Position 17 to 26 in insn */
304+
addend |= ((insn << 5) >> 22);
305+
/* Fill in 1 bits to get the 25 bit Offset Value */
306+
addend = addend << 1;
307+
308+
/* (S + A) - P */
309+
S = (uintptr_t)(uint8 *)symbol_addr;
310+
A = (intptr_t)reloc_addend;
311+
P = (uintptr_t)(target_section_addr + reloc_offset);
312+
P &= (uintptr_t)~1;
313+
value = (int32)(S + A + addend - P);
314+
315+
insn = insn & 0xf8010030;
316+
insn |= ((((value >> 1) & 0x3ff) << 17)
317+
| (((value >> 1) & 0xffc00) >> 3)
318+
| (((value >> 1) & 0xf00000) >> 19));
319+
320+
/* Convert to middle endian */
321+
insn = middle_endian_convert(insn);
322+
323+
STORE_U32(target_section_addr + reloc_offset, insn);
324+
break;
325+
}
171326
case R_ARC_S25W_PCREL:
172327
{
173328
uint32 insn = LOAD_I32(target_section_addr + reloc_offset);

0 commit comments

Comments
 (0)