9 #include "gen_amd64_emitter.h" 11 #include "beemithlp.h" 12 #include "gen_amd64_new_nodes.h" 13 #include "amd64_emitter.h" 15 static void emit_amd64_add(
ir_node const *
const node)
17 amd64_emitf(node,
"add%M %AM");
20 static void emit_amd64_adds(
ir_node const *
const node)
22 amd64_emitf(node,
"adds%MX %AM");
25 static void emit_amd64_and(
ir_node const *
const node)
27 amd64_emitf(node,
"and%M %AM");
30 static void emit_amd64_bsf(
ir_node const *
const node)
32 amd64_emitf(node,
"bsf%M %AM, %D0");
35 static void emit_amd64_bsr(
ir_node const *
const node)
37 amd64_emitf(node,
"bsr%M %AM, %D0");
40 static void emit_amd64_call(
ir_node const *
const node)
42 amd64_emitf(node,
"call %*AM");
45 static void emit_amd64_cltd(
ir_node const *
const node)
47 amd64_emitf(node,
"cltd");
50 static void emit_amd64_cmp(
ir_node const *
const node)
52 amd64_emitf(node,
"cmp%M %AM");
55 static void emit_amd64_cmpxchg(
ir_node const *
const node)
57 amd64_emitf(node,
"lock cmpxchg%M %AM");
60 static void emit_amd64_cqto(
ir_node const *
const node)
62 amd64_emitf(node,
"cqto");
65 static void emit_amd64_cvtsd2ss(
ir_node const *
const node)
67 amd64_emitf(node,
"cvtsd2ss %AM, %^D0");
70 static void emit_amd64_cvtsi2sd(
ir_node const *
const node)
72 amd64_emitf(node,
"cvtsi2sd %AM, %^D0");
75 static void emit_amd64_cvtsi2ss(
ir_node const *
const node)
77 amd64_emitf(node,
"cvtsi2ss %AM, %^D0");
80 static void emit_amd64_cvtss2sd(
ir_node const *
const node)
82 amd64_emitf(node,
"cvtss2sd %AM, %^D0");
85 static void emit_amd64_cvttsd2si(
ir_node const *
const node)
87 amd64_emitf(node,
"cvttsd2si %AM, %D0");
90 static void emit_amd64_cvttss2si(
ir_node const *
const node)
92 amd64_emitf(node,
"cvttss2si %AM, %D0");
95 static void emit_amd64_div(
ir_node const *
const node)
97 amd64_emitf(node,
"div%M %AM");
100 static void emit_amd64_divs(
ir_node const *
const node)
102 amd64_emitf(node,
"divs%MX %AM");
105 static void emit_amd64_fadd(
ir_node const *
const node)
107 amd64_emitf(node,
"fadd%FP %AF");
110 static void emit_amd64_fchs(
ir_node const *
const node)
112 amd64_emitf(node,
"fchs");
115 static void emit_amd64_fdiv(
ir_node const *
const node)
117 amd64_emitf(node,
"fdiv%FR%FP %AF");
120 static void emit_amd64_fdup(
ir_node const *
const node)
122 amd64_emitf(node,
"fld %F0");
125 static void emit_amd64_fild(
ir_node const *
const node)
127 amd64_emitf(node,
"fild%M %AM");
130 static void emit_amd64_fisttp(
ir_node const *
const node)
132 amd64_emitf(node,
"fisttp%M %AM");
135 static void emit_amd64_fld(
ir_node const *
const node)
137 amd64_emitf(node,
"fld%FM %AM");
140 static void emit_amd64_fld1(
ir_node const *
const node)
142 amd64_emitf(node,
"fld1");
145 static void emit_amd64_fldz(
ir_node const *
const node)
147 amd64_emitf(node,
"fldz");
150 static void emit_amd64_fmul(
ir_node const *
const node)
152 amd64_emitf(node,
"fmul%FP %AF");
155 static void emit_amd64_fpop(
ir_node const *
const node)
157 amd64_emitf(node,
"fstp %F0");
160 static void emit_amd64_fst(
ir_node const *
const node)
162 amd64_emitf(node,
"fst%FP%FM %AM");
165 static void emit_amd64_fstp(
ir_node const *
const node)
167 amd64_emitf(node,
"fstp%FM %AM");
170 static void emit_amd64_fsub(
ir_node const *
const node)
172 amd64_emitf(node,
"fsub%FR%FP %AF");
175 static void emit_amd64_fucomi(
ir_node const *
const node)
177 amd64_emitf(node,
"fucom%FPi %F0");
180 static void emit_amd64_fxch(
ir_node const *
const node)
182 amd64_emitf(node,
"fxch %F0");
185 static void emit_amd64_haddpd(
ir_node const *
const node)
187 amd64_emitf(node,
"haddpd %AM");
190 static void emit_amd64_idiv(
ir_node const *
const node)
192 amd64_emitf(node,
"idiv%M %AM");
195 static void emit_amd64_ijmp(
ir_node const *
const node)
197 amd64_emitf(node,
"jmp %*AM");
200 static void emit_amd64_imul(
ir_node const *
const node)
202 amd64_emitf(node,
"imul%M %AM");
205 static void emit_amd64_imul_1op(
ir_node const *
const node)
207 amd64_emitf(node,
"imul%M %AM");
210 static void emit_amd64_lea(
ir_node const *
const node)
212 amd64_emitf(node,
"lea%M %A, %D0");
215 static void emit_amd64_leave(
ir_node const *
const node)
217 amd64_emitf(node,
"leave");
220 static void emit_amd64_mov_imm(
ir_node const *
const node)
222 amd64_emitf(node,
"mov%M $%C, %D0");
225 static void emit_amd64_mov_store(
ir_node const *
const node)
227 amd64_emitf(node,
"mov%M %AM");
230 static void emit_amd64_movd(
ir_node const *
const node)
232 amd64_emitf(node,
"movd %AM, %D0");
235 static void emit_amd64_movd_gp_xmm(
ir_node const *
const node)
237 amd64_emitf(node,
"movd %S0, %D0");
240 static void emit_amd64_movd_xmm_gp(
ir_node const *
const node)
242 amd64_emitf(node,
"movd %S0, %D0");
245 static void emit_amd64_movdqa(
ir_node const *
const node)
247 amd64_emitf(node,
"movdqa %AM, %D0");
250 static void emit_amd64_movdqu(
ir_node const *
const node)
252 amd64_emitf(node,
"movdqu %AM, %D0");
255 static void emit_amd64_movdqu_store(
ir_node const *
const node)
257 amd64_emitf(node,
"movdqu %^S0, %A");
260 static void emit_amd64_movs(
ir_node const *
const node)
262 amd64_emitf(node,
"movs%Mq %AM, %^D0");
265 static void emit_amd64_movs_store_xmm(
ir_node const *
const node)
267 amd64_emitf(node,
"movs%MX %^S0, %A");
270 static void emit_amd64_movs_xmm(
ir_node const *
const node)
272 amd64_emitf(node,
"movs%MX %AM, %D0");
275 static void emit_amd64_mul(
ir_node const *
const node)
277 amd64_emitf(node,
"mul%M %AM");
280 static void emit_amd64_muls(
ir_node const *
const node)
282 amd64_emitf(node,
"muls%MX %AM");
285 static void emit_amd64_neg(
ir_node const *
const node)
287 amd64_emitf(node,
"neg%M %AM");
290 static void emit_amd64_not(
ir_node const *
const node)
292 amd64_emitf(node,
"not%M %AM");
295 static void emit_amd64_or(
ir_node const *
const node)
297 amd64_emitf(node,
"or%M %AM");
300 static void emit_amd64_pop_am(
ir_node const *
const node)
302 amd64_emitf(node,
"pop%M %A");
305 static void emit_amd64_punpckldq(
ir_node const *
const node)
307 amd64_emitf(node,
"punpckldq %AM");
310 static void emit_amd64_push_am(
ir_node const *
const node)
312 amd64_emitf(node,
"push%M %A");
315 static void emit_amd64_push_reg(
ir_node const *
const node)
317 amd64_emitf(node,
"push%M %^S2");
320 static void emit_amd64_ret(
ir_node const *
const node)
322 amd64_emitf(node,
"ret");
325 static void emit_amd64_sar(
ir_node const *
const node)
327 amd64_emitf(node,
"sar%M %SO");
330 static void emit_amd64_sbb(
ir_node const *
const node)
332 amd64_emitf(node,
"sbb%M %AM");
335 static void emit_amd64_setcc(
ir_node const *
const node)
337 amd64_emitf(node,
"set%P0 %D0");
340 static void emit_amd64_shl(
ir_node const *
const node)
342 amd64_emitf(node,
"shl%M %SO");
345 static void emit_amd64_shr(
ir_node const *
const node)
347 amd64_emitf(node,
"shr%M %SO");
350 static void emit_amd64_sub(
ir_node const *
const node)
352 amd64_emitf(node,
"sub%M %AM");
355 static void emit_amd64_sub_sp(
ir_node const *
const node)
357 amd64_emitf(node,
"subq %AM\nmovq %%rsp, %D1");
360 static void emit_amd64_subpd(
ir_node const *
const node)
362 amd64_emitf(node,
"subpd %AM");
365 static void emit_amd64_subs(
ir_node const *
const node)
367 amd64_emitf(node,
"subs%MX %AM");
370 static void emit_amd64_ucomis(
ir_node const *
const node)
372 amd64_emitf(node,
"ucomis%MX %AM");
375 static void emit_amd64_xor(
ir_node const *
const node)
377 amd64_emitf(node,
"xor%M %AM");
380 static void emit_amd64_xor_0(
ir_node const *
const node)
382 amd64_emitf(node,
"xor%M %3D0, %3D0");
385 static void emit_amd64_xorp(
ir_node const *
const node)
387 amd64_emitf(node,
"xorp%MX %AM");
390 static void emit_amd64_xorp_0(
ir_node const *
const node)
392 amd64_emitf(node,
"xorp%MX %^D0, %^D0");
397 void amd64_register_spec_emitters(
void)
399 be_set_emitter(op_amd64_add, emit_amd64_add);
400 be_set_emitter(op_amd64_adds, emit_amd64_adds);
401 be_set_emitter(op_amd64_and, emit_amd64_and);
402 be_set_emitter(op_amd64_bsf, emit_amd64_bsf);
403 be_set_emitter(op_amd64_bsr, emit_amd64_bsr);
404 be_set_emitter(op_amd64_call, emit_amd64_call);
405 be_set_emitter(op_amd64_cltd, emit_amd64_cltd);
406 be_set_emitter(op_amd64_cmp, emit_amd64_cmp);
407 be_set_emitter(op_amd64_cmpxchg, emit_amd64_cmpxchg);
408 be_set_emitter(op_amd64_cqto, emit_amd64_cqto);
409 be_set_emitter(op_amd64_cvtsd2ss, emit_amd64_cvtsd2ss);
410 be_set_emitter(op_amd64_cvtsi2sd, emit_amd64_cvtsi2sd);
411 be_set_emitter(op_amd64_cvtsi2ss, emit_amd64_cvtsi2ss);
412 be_set_emitter(op_amd64_cvtss2sd, emit_amd64_cvtss2sd);
413 be_set_emitter(op_amd64_cvttsd2si, emit_amd64_cvttsd2si);
414 be_set_emitter(op_amd64_cvttss2si, emit_amd64_cvttss2si);
415 be_set_emitter(op_amd64_div, emit_amd64_div);
416 be_set_emitter(op_amd64_divs, emit_amd64_divs);
417 be_set_emitter(op_amd64_fadd, emit_amd64_fadd);
418 be_set_emitter(op_amd64_fchs, emit_amd64_fchs);
419 be_set_emitter(op_amd64_fdiv, emit_amd64_fdiv);
420 be_set_emitter(op_amd64_fdup, emit_amd64_fdup);
421 be_set_emitter(op_amd64_fild, emit_amd64_fild);
422 be_set_emitter(op_amd64_fisttp, emit_amd64_fisttp);
423 be_set_emitter(op_amd64_fld, emit_amd64_fld);
424 be_set_emitter(op_amd64_fld1, emit_amd64_fld1);
425 be_set_emitter(op_amd64_fldz, emit_amd64_fldz);
426 be_set_emitter(op_amd64_fmul, emit_amd64_fmul);
427 be_set_emitter(op_amd64_fpop, emit_amd64_fpop);
428 be_set_emitter(op_amd64_fst, emit_amd64_fst);
429 be_set_emitter(op_amd64_fstp, emit_amd64_fstp);
430 be_set_emitter(op_amd64_fsub, emit_amd64_fsub);
431 be_set_emitter(op_amd64_fucomi, emit_amd64_fucomi);
432 be_set_emitter(op_amd64_fxch, emit_amd64_fxch);
433 be_set_emitter(op_amd64_haddpd, emit_amd64_haddpd);
434 be_set_emitter(op_amd64_idiv, emit_amd64_idiv);
435 be_set_emitter(op_amd64_ijmp, emit_amd64_ijmp);
436 be_set_emitter(op_amd64_imul, emit_amd64_imul);
437 be_set_emitter(op_amd64_imul_1op, emit_amd64_imul_1op);
438 be_set_emitter(op_amd64_lea, emit_amd64_lea);
439 be_set_emitter(op_amd64_leave, emit_amd64_leave);
440 be_set_emitter(op_amd64_mov_imm, emit_amd64_mov_imm);
441 be_set_emitter(op_amd64_mov_store, emit_amd64_mov_store);
442 be_set_emitter(op_amd64_movd, emit_amd64_movd);
443 be_set_emitter(op_amd64_movd_gp_xmm, emit_amd64_movd_gp_xmm);
444 be_set_emitter(op_amd64_movd_xmm_gp, emit_amd64_movd_xmm_gp);
445 be_set_emitter(op_amd64_movdqa, emit_amd64_movdqa);
446 be_set_emitter(op_amd64_movdqu, emit_amd64_movdqu);
447 be_set_emitter(op_amd64_movdqu_store, emit_amd64_movdqu_store);
448 be_set_emitter(op_amd64_movs, emit_amd64_movs);
449 be_set_emitter(op_amd64_movs_store_xmm, emit_amd64_movs_store_xmm);
450 be_set_emitter(op_amd64_movs_xmm, emit_amd64_movs_xmm);
451 be_set_emitter(op_amd64_mul, emit_amd64_mul);
452 be_set_emitter(op_amd64_muls, emit_amd64_muls);
453 be_set_emitter(op_amd64_neg, emit_amd64_neg);
454 be_set_emitter(op_amd64_not, emit_amd64_not);
455 be_set_emitter(op_amd64_or, emit_amd64_or);
456 be_set_emitter(op_amd64_pop_am, emit_amd64_pop_am);
457 be_set_emitter(op_amd64_punpckldq, emit_amd64_punpckldq);
458 be_set_emitter(op_amd64_push_am, emit_amd64_push_am);
459 be_set_emitter(op_amd64_push_reg, emit_amd64_push_reg);
460 be_set_emitter(op_amd64_ret, emit_amd64_ret);
461 be_set_emitter(op_amd64_sar, emit_amd64_sar);
462 be_set_emitter(op_amd64_sbb, emit_amd64_sbb);
463 be_set_emitter(op_amd64_setcc, emit_amd64_setcc);
464 be_set_emitter(op_amd64_shl, emit_amd64_shl);
465 be_set_emitter(op_amd64_shr, emit_amd64_shr);
466 be_set_emitter(op_amd64_sub, emit_amd64_sub);
467 be_set_emitter(op_amd64_sub_sp, emit_amd64_sub_sp);
468 be_set_emitter(op_amd64_subpd, emit_amd64_subpd);
469 be_set_emitter(op_amd64_subs, emit_amd64_subs);
470 be_set_emitter(op_amd64_ucomis, emit_amd64_ucomis);
471 be_set_emitter(op_amd64_xor, emit_amd64_xor);
472 be_set_emitter(op_amd64_xor_0, emit_amd64_xor_0);
473 be_set_emitter(op_amd64_xorp, emit_amd64_xorp);
474 be_set_emitter(op_amd64_xorp_0, emit_amd64_xorp_0);
478 void amd64_register_spec_binary_emitters(
void)
struct ir_node ir_node
Procedure Graph Node.