static const arch_env_t *arch_env = NULL;
+char *ia32_emit_binop(ir_node *irn) {
+ return "R1, R2";
+}
+
+char *ia32_emit_unop(ir_node *irn) {
+ return "R";
+}
+
+char *ia32_emit_am(ir_node *irn) {
+ return "AM";
+}
/*************************************************************
* _ _ __ _ _
* Return node's tarval as string.
*/
const char *node_const_to_str(ir_node *n) {
- char *buf;
- tarval *tv = get_ia32_Immop_tarval(n);
+ char *s = get_ia32_cnst(n);
- if (tv) {
- buf = xmalloc(SNPRINTF_BUF_LEN);
- tarval_snprintf(buf, SNPRINTF_BUF_LEN, tv);
- return buf;
- }
- else if (get_ia32_old_ir(n)) {
- return get_sc_name(get_ia32_old_ir(n));
- }
- else
- return "0";
+ if (!s)
+ s = "NULL";
+
+ return s;
}
/**
* Returns node's offset as string.
*/
char *node_offset_to_str(ir_node *n) {
- char *buf;
- tarval *tv = get_ia32_am_offs(n);
+ char *s = get_ia32_am_offs(n);
- if (tv) {
- buf = xmalloc(SNPRINTF_BUF_LEN);
- tarval_snprintf(buf, SNPRINTF_BUF_LEN, tv);
- return buf;
- }
- else
- return "";
+ if (!s)
+ s = "";
+
+ return s;
}
/* We always pass the ir_node which is a pointer. */
ir_node **args = get_Sync_preds_arr(sync);
for (i = 0; i < get_Sync_n_preds(sync); i++) {
- lc_efprintf(env, F, "\tpush %1D\t\t\t\t/* push %+F on stack */\n", args[i], args[i]);
+ ir_node *n = get_irn_n(args[i], 1);
+ lc_efprintf(env, F, "\tpush %1D\t\t\t\t/* push %+F(%+F) on stack */\n", n, args[i], n);
- if (mode_is_int(get_irn_mode(args[i]))) {
+ if (mode_is_float(get_irn_mode(n))) {
args_size += 4;
}
else {
/* We had stack arguments: clear the stack */
fprintf(F, "\tadd %d, ", args_size);
if (emit_env->cg->has_alloca) {
- fprintf(F, "%ebp");
+ fprintf(F, "%%ebp");
}
else {
- fprintf(F, "%esp");
+ fprintf(F, "%%esp");
}
fprintf(F, "\t\t\t\t/* clear stack after call */\n");
}
#define EMIT(a) if (get_irn_opcode(irn) == iro_##a) { emit_##a(irn, emit_env); return; }
/* generated int emitter functions */
- IA32_EMIT(Copy);
- IA32_EMIT(Perm);
-
IA32_EMIT(Const);
IA32_EMIT(Add);
- IA32_EMIT(Add_i);
IA32_EMIT(Sub);
- IA32_EMIT(Sub_i);
IA32_EMIT(Minus);
IA32_EMIT(Inc);
IA32_EMIT(Dec);
IA32_EMIT(Min);
IA32_EMIT(And);
- IA32_EMIT(And_i);
IA32_EMIT(Or);
- IA32_EMIT(Or_i);
IA32_EMIT(Eor);
- IA32_EMIT(Eor_i);
IA32_EMIT(Not);
IA32_EMIT(Shl);
- IA32_EMIT(Shl_i);
IA32_EMIT(Shr);
- IA32_EMIT(Shr_i);
IA32_EMIT(Shrs);
- IA32_EMIT(Shrs_i);
IA32_EMIT(RotL);
- IA32_EMIT(RotL_i);
IA32_EMIT(RotR);
IA32_EMIT(Lea);
- IA32_EMIT(Lea_i);
IA32_EMIT(Mul);
- IA32_EMIT(Mul_i);
- IA32_EMIT(Cltd);
+ IA32_EMIT(Cdq);
IA32_EMIT(DivMod);
IA32_EMIT(Store);
IA32_EMIT(fAdd);
IA32_EMIT(fSub);
- IA32_EMIT(fMinus);
IA32_EMIT(fMul);
IA32_EMIT(fDiv);
/* other emitter functions */
IA32_EMIT(CondJmp);
- IA32_EMIT(CondJmp_i);
IA32_EMIT(SwitchJmp);
IA32_EMIT(Call);
- IA32_EMIT(Alloca);
- IA32_EMIT(Alloca_i);
EMIT(Jmp);
EMIT(Proj);
emit_env.arch_env = cg->arch_env;
emit_env.cg = cg;
+ /* set the global arch_env (needed by print hooks) */
+ arch_env = cg->arch_env;
+
ia32_emit_start(F, irg);
irg_block_walk_graph(irg, ia32_gen_labels, NULL, &emit_env);
irg_walk_blkwise_graph(irg, NULL, ia32_gen_block, &emit_env);