Commit 82068a66 authored by Matthias Braun's avatar Matthias Braun
Browse files

ia32: improve immediate dumping

parent 48cecce4
......@@ -104,7 +104,9 @@ static void amd64_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
fprintf(F, "size = %s\n", get_insn_mode_string(addr_attr->insn_mode));
fprintf(F, "base input: %d\n", addr_attr->addr.base_input);
fprintf(F, "index input: %d\n", addr_attr->addr.index_input);
ir_fprintf(F, "am imm: %+F%+" PRId32 "\n", addr_attr->addr.immediate.entity, addr_attr->addr.immediate.offset);
fputs("am imm: ", F);
x86_dump_imm32(&addr_attr->addr.immediate, F);
fputc('\n', F);
break;
}
}
......
......@@ -217,23 +217,15 @@ static void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
break;
}
/* dump AM offset */
if (get_ia32_am_offs_int(n) != 0) {
fprintf(F, "AM offset = %d\n", get_ia32_am_offs_int(n));
}
/* dump AM entity */
ir_entity *ent = get_ia32_am_ent(n);
if (ent != NULL) {
ident *id = get_entity_ld_ident(ent);
fprintf(F, "AM entity = %s\n", get_id_str(id));
}
const ia32_attr_t *attr = get_ia32_attr_const(n);
fputs("AM immediate = ", F);
x86_dump_imm32(&attr->am_imm, F);
fputc('\n', F);
/* dump AM scale */
fprintf(F, "AM scale = %u\n", get_ia32_am_scale(n));
/* dump pn code */
const ia32_attr_t *attr = get_ia32_attr_const(n);
if (has_ia32_condcode_attr(n)) {
const char *cc_name = condition_code_name(get_ia32_condcode(n));
if (cc_name) {
......@@ -256,27 +248,6 @@ static void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
fprintf(F, "is reload = %s\n", be_dump_yesno(is_ia32_is_reload(n)));
fprintf(F, "latency = %u\n", get_ia32_latency(n));
/* dump frame entity */
fprintf(F, "frame use = %s\n", get_frame_use_str(n));
if (attr->am_imm.kind == X86_IMM_FRAMEOFFSET
#ifndef NDEBUG
|| attr->old_frame_ent != NULL
#endif
) {
fprintf(F, "frame entity = ");
ir_entity *entity = attr->am_imm.entity;
#ifndef NDEBUG
if (entity == NULL)
entity = attr->old_frame_ent;
#endif
if (entity != NULL) {
ir_fprintf(F, "%+F", entity);
} else {
fprintf(F, "n/a");
}
fprintf(F, "\n");
}
/* dump modes */
fprintf(F, "ls_mode = ");
if (get_ia32_ls_mode(n)) {
......@@ -287,6 +258,17 @@ static void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
fprintf(F, "\n");
#ifndef NDEBUG
/* dump frame entity */
fprintf(F, "frame use = %s\n", get_frame_use_str(n));
if (attr->old_frame_ent != NULL) {
fprintf(F, "frame entity = ");
ir_entity *entity = attr->am_imm.entity;
if (entity != NULL) {
ir_fprintf(F, "%+F", entity);
} else {
fprintf(F, "n/a");
}
}
/* dump original ir node name */
char const *orig = get_ia32_attr_const(n)->orig_node;
fprintf(F, "orig node = %s\n", orig ? orig : "n/a");
......
......@@ -10,10 +10,13 @@
*/
#include "x86_imm.h"
#include <inttypes.h>
#include "bediagnostic.h"
#include "betranshlp.h"
#include "irmode_t.h"
#include "irnode_t.h"
#include "irprintf.h"
#include "panic.h"
#include "tv_t.h"
......@@ -73,3 +76,27 @@ bool x86_match_immediate(x86_imm32_t *immediate, const ir_node *node,
immediate->kind = kind;
return true;
}
char const *x86_get_immediate_kind_str(x86_immediate_kind_t const kind)
{
switch (kind) {
case X86_IMM_VALUE: return "value";
case X86_IMM_ADDR: return "addr";
case X86_IMM_PICBASE_REL: return "picbase_rel";
case X86_IMM_TLS_IE: return "tls_ie";
case X86_IMM_TLS_LE: return "tls_le";
case X86_IMM_GOTPCREL: return "gotpcrel";
case X86_IMM_FRAMEOFFSET: return "frameoffset";
}
return "invalid";
}
void x86_dump_imm32(x86_imm32_t const *const imm, FILE *const F)
{
if (imm->entity != NULL)
ir_fprintf(F, "%+F", imm->entity);
if (imm->offset != 0 || imm->entity == NULL)
fprintf(F, imm->entity != NULL ? "%+"PRId32 : "%"PRId32, imm->offset);
if (imm->kind != X86_IMM_VALUE && imm->kind != X86_IMM_ADDR)
fprintf(F, " [%s]", x86_get_immediate_kind_str(imm->kind));
}
......@@ -13,6 +13,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "compiler.h"
#include "firm_types.h"
......@@ -36,6 +37,10 @@ typedef struct x86_imm32_t {
bool x86_match_immediate(x86_imm32_t *immediate, const ir_node *node,
char constraint);
char const *x86_get_immediate_kind_str(x86_immediate_kind_t const kind);
void x86_dump_imm32(x86_imm32_t const *imm, FILE *F);
static inline bool x86_imm32_equal(x86_imm32_t const *const imm0,
x86_imm32_t const *const imm1)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment