Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.257
 
1.258
 
MAIN:gmcgarry:20090408224347
 
pftn.c
_>20832083         return bcon(isconst);
 20842084 }
 20852085 
<> 2086+/*
  2087+ * Take integer absolute value.
  2088+ * Simply does: ((((x)>>(8*sizeof(x)-1))^(x))-((x)>>(8*sizeof(x)-1)))
  2089+ */
  2090+static NODE *
  2091+builtin_abs(NODE *f, NODE *a)
  2092+{
  2093+        NODE *p, *q, *r, *t, *t2, *t3;
  2094+        int tmp1, tmp2, shift;
  2095+
  2096+        if (a == NULL)
  2097+                goto bad;
  2098+
  2099+        if (a->n_type == FLOAT || a->n_type == DOUBLE || a->n_type == LDOUBLE)
  2100+                goto bad;
  2101+
  2102+        tfree(f);
  2103+
  2104+        if (a->n_op == ICON) {
  2105+                if (a->n_lval < 0)
  2106+                        a->n_lval = -a->n_lval;
  2107+                p = a;
  2108+        } else {
  2109+                t = tempnode(0, a->n_type, a->n_df, a->n_sue);
  2110+                tmp1 = regno(t);
  2111+                p = buildtree(ASSIGN, t, a);
  2112+
  2113+                t = tempnode(tmp1, a->n_type, a->n_df, a->n_sue);
  2114+                shift = tsize(a->n_type, a->n_df, a->n_sue) - 1;
  2115+                q = buildtree(RS, t, bcon(shift));
  2116+
  2117+                t2 = tempnode(0, a->n_type, a->n_df, a->n_sue);
  2118+                tmp2 = regno(t2);
  2119+                q = buildtree(ASSIGN, t2, q);
  2120+
  2121+                t = tempnode(tmp1, a->n_type, a->n_df, a->n_sue);
  2122+                t2 = tempnode(tmp2, a->n_type, a->n_df, a->n_sue);
  2123+                t3 = tempnode(tmp2, a->n_type, a->n_df, a->n_sue);
  2124+                r = buildtree(MINUS, buildtree(ER, t, t2), t3);
  2125+
  2126+                p = buildtree(COMOP, p, buildtree(COMOP, q, r));
  2127+        }
  2128+
  2129+        return p;
  2130+
  2131+bad:
  2132+        uerror("bad argument to __builtin_abs");
  2133+        return bcon(0);
  2134+}
  2135+
20862136 #ifndef TARGET_STDARGS
 20872137 static NODE *
 20882138 builtin_stdarg_start(NODE *f, NODE *a)
     
 !
21912241 } bitable[] = {
 21922242         { "__builtin_alloca", builtin_alloca },
 21932243         { "__builtin_constant_p", builtin_constant_p },
<> 2244+        { "__builtin_abs", builtin_abs },
<_21942245 #ifndef TARGET_STDARGS
 21952246         { "__builtin_stdarg_start", builtin_stdarg_start },
 21962247         { "__builtin_va_start", builtin_stdarg_start },
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-10-31 11:43 +0100