Added support for SymConst(ofs_ent)
[libfirm] / ir / be / ia32 / ia32_new_nodes.c
index ba1e3a6..2a986a2 100644 (file)
@@ -542,14 +542,9 @@ void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour) {
  */
 char *get_ia32_am_offs(const ir_node *node) {
        ia32_attr_t *attr = get_ia32_attr(node);
-       char        *res  = NULL;
+       static char res[64];
 
-       if (! attr->am_offs) {
-               return NULL;
-       }
-
-       res = obstack_alloc(get_irg_obstack(get_irn_irg(node)), 64);
-       snprintf(res, 64, "%+ld", attr->am_offs);
+       snprintf(res, sizeof(res), "%+ld", attr->am_offs);
 
        return res;
 }
@@ -567,17 +562,18 @@ long get_ia32_am_offs_long(const ir_node *node) {
  */
 static void extend_ia32_am_offs(ir_node *node, char *offset, char op) {
        ia32_attr_t *attr = get_ia32_attr(node);
-       int o;
+       int res, o;
 
        if (! offset || strlen(offset) < 1)
                return;
 
-       sscanf(offset, "%d", &o);
+       res = sscanf(offset, "%d", &o);
+       assert(res == 1);
 
        if (op == '-')
                attr->am_offs -= o;
        else if (op == '+')
-               attr->am_offs -= o;
+               attr->am_offs += o;
        else
                assert(0);
 }
@@ -682,7 +678,7 @@ const char *get_ia32_cnst(const ir_node *node) {
 /**
  * Sets the string representation of the internal const.
  */
-void set_ia32_cnst(ir_node *node, char *cnst) {
+void set_ia32_cnst(ir_node *node, const char *cnst) {
        ia32_attr_t *attr = get_ia32_attr(node);
        attr->cnst        = new_id_from_str(cnst);
 }
@@ -1172,8 +1168,9 @@ void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst) {
                        attr->cnst_val.tv = get_Const_tarval(cnst);
                        mode = get_tarval_mode(attr->cnst_val.tv);
                        if (mode_is_reference(mode) &&
-                           get_mode_null(mode) == attr->cnst_val.tv)
-                               attr->cnst_val.tv = get_mode_null(mode_Is);
+                           get_mode_null(mode) == attr->cnst_val.tv) {
+                               attr->cnst_val.tv = get_mode_null(mode_Iu);
+                       }
                        attr->cnst        = get_ident_for_tv(attr->cnst_val.tv);
                        break;
                case iro_SymConst: