Commits

Iain Buclaw committed 62c8038

64bit testsuite fixes - passes all tests 32bit linux passes.

  • Participants
  • Parent commits 0066ecf

Comments (0)

Files changed (7)

File d/Make-lang.in

 D_GLUE_OBJS = d/d-lang.glue.o d/d-decls.glue.o d/d-codegen.glue.o \
               d/d-objfile.glue.o d/d-irstate.glue.o d/d-glue.glue.o \
               d/d-convert.glue.o d/d-todt.glue.o d/d-gcc-real.glue.o \
-              d/d-gt.cglue.o d/d-builtins.cglue.o d/d-misc.cglue.o \
-              d/d-builtins2.glue.o d/symbol.glue.o d/asmstmt.glue.o \
-              d/dt.glue.o d/d-incpath.glue.o
+              d/d-gt.cglue.o d/d-builtins.cglue.o d/d-builtins2.glue.o \
+              d/symbol.glue.o d/asmstmt.glue.o d/dt.glue.o \
+              d/d-incpath.glue.o
+
 ifeq ($(D_LANGUAGE_VERSION),2)
 D_GLUE_OBJS += d/d-cppmngl.glue.o
 endif

File d/d-asm-i386.h

         }
         return searchOpdata(opIdent, opData, N_ents);
     }
-    
+
     // need clobber information.. use information is good too...
     void doInstruction()
     {
                                 (global.params.isX86_64 && operand->baseReg == Reg_RBP);
                             bool isBaseRegSP = operand->baseReg == Reg_ESP ||
                                 (global.params.isX86_64 && operand->baseReg == Reg_RSP);
-                            
+
                             if (operand->indexReg == Reg_Invalid
                                     && decl->isVarDeclaration()
                                     && ((isBaseRegBP && ! sc->func->naked)

File d/d-builtins2.cc

             for (int i = 0; i < (int) TMAX; i++)
             {
                 d = Type::basic[i];
-                if (d && d->isfloating() && ! d->iscomplex() && ! d->isimaginary() &&
-                    d->size() == sz)
+                if (d && d->isreal() && d->size() == sz)
                 {
                     return d;
                 }
 
         result = irs.call(tf, callee, NULL, arguments);
         result = fold(result);
-        
+
         if (TREE_CONSTANT(result) && TREE_CODE(result) != CALL_EXPR)
         {   // Builtin should be successfully evaluated.
             // Will only return NULL if we can't convert it.

File d/d-codegen.cc

     switch (ebtype->ty)
     {
         case Tdelegate:
-            // %%TODO:NOP/VIEW_CONVERT
             if (tbtype->ty == Tdelegate)
             {
                 exp = maybeMakeTemp(exp);
                     return libCall(LIBCALL_ARRAYCAST, 3, args, target_type->toCtype());
                 }
                 else
-                {   // %% VIEW_CONVERT_EXPR or NOP_EXPR ? (and the two cases below)
-                    // Convert to/from void[] or elements are the same size -- don't change length
-                    return build1(NOP_EXPR, target_type->toCtype(), exp);
+                {   // Convert to/from void[] or elements are the same size -- don't change length
+                    return build1(VIEW_CONVERT_EXPR, target_type->toCtype(), exp);
                 }
             }
 #if V2
             break;
         case Taarray:
             if (tbtype->ty == Taarray)
-                return build1(NOP_EXPR, target_type->toCtype(), exp);
+                return build1(VIEW_CONVERT_EXPR, target_type->toCtype(), exp);
             // else, default conversion, which should product an error
             break;
         case Tpointer:
                 exp = d_convert_basic(d_type_for_size(POINTER_SIZE, 1), exp);
             // Can convert void pointers to associative arrays too...
             else if (tbtype->ty == Taarray && ebtype == Type::tvoidptr)
-                return build1(NOP_EXPR, target_type->toCtype(), exp);
+                return build1(VIEW_CONVERT_EXPR, target_type->toCtype(), exp);
             break;
         default:
         {
                 type = TREE_TYPE(op1);
                 // Could have used mathfn_built_in, but that only returns
                 // implicit built in decls.
-                if (TYPE_MAIN_VARIANT (type) == double_type_node)
+                if (TYPE_MAIN_VARIANT(type) == double_type_node)
                     exp = built_in_decls[BUILT_IN_SQRT];
-                else if (TYPE_MAIN_VARIANT (type) == float_type_node)
+                else if (TYPE_MAIN_VARIANT(type) == float_type_node)
                     exp = built_in_decls[BUILT_IN_SQRTF];
-                else if (TYPE_MAIN_VARIANT (type) == long_double_type_node)
+                else if (TYPE_MAIN_VARIANT(type) == long_double_type_node)
                     exp = built_in_decls[BUILT_IN_SQRTL];
 
                 gcc_assert(exp);    // Should never trigger.
 tree
 IRState::floatMod(tree a, tree b, tree type)
 {
-    tree fmodfn;
+    tree fmodfn = NULL_TREE;
     tree basetype = type;
 
     if (COMPLEX_FLOAT_TYPE_P(basetype))
         basetype = TREE_TYPE(basetype);
 
-    fmodfn = mathfn_built_in(basetype, BUILT_IN_FMOD);
+    if (TYPE_MAIN_VARIANT(basetype) == double_type_node)
+        fmodfn = built_in_decls[BUILT_IN_FMOD];
+    else if (TYPE_MAIN_VARIANT(basetype) == float_type_node)
+        fmodfn = built_in_decls[BUILT_IN_FMODF];
+    else if (TYPE_MAIN_VARIANT(basetype) == long_double_type_node)
+        fmodfn = built_in_decls[BUILT_IN_FMODL];
 
     if (! fmodfn)
     {   // %qT pretty prints the tree type.
         // %% For float element types, warn that NaN is not taken into account ?
         switch (op)
         {
-            case TOKlt: case TOKul: 
+            case TOKlt: case TOKul:
                 out_code = LT_EXPR;
                 break;
 
 PowExp::toElem(IRState * irs)
 {
     tree e1_t, e2_t;
-    tree powtype, powfn;
+    tree powtype, powfn = NULL_TREE;
 
     // Dictates what version of pow() we call.
     powtype = type->toBasetype()->toCtype();
     // If type is int, implicitly convert to double.
     // This allows backend to fold the call into a constant return value.
-    if (!type->isfloating() && type->isintegral())
+    if (type->isintegral())
         powtype = double_type_node;
 
     // Lookup compatible builtin.
-    e1_t = convert(powtype, e1->toElem(irs));
-    e2_t = convert(powtype, e2->toElem(irs));
-    powfn = mathfn_built_in (powtype, BUILT_IN_POW);
+    if (TYPE_MAIN_VARIANT(powtype) == double_type_node)
+        powfn = built_in_decls[BUILT_IN_POW];
+    else if (TYPE_MAIN_VARIANT(powtype) == float_type_node)
+        powfn = built_in_decls[BUILT_IN_POWF];
+    else if (TYPE_MAIN_VARIANT(powtype) == long_double_type_node)
+        powfn = built_in_decls[BUILT_IN_POWL];
 
     if (powfn == NULL_TREE)
     {
         return irs->errorMark(type);
     }
 
+    e1_t = convert(powtype, e1->toElem(irs));
+    e2_t = convert(powtype, e2->toElem(irs));
+
     return convert(type->toCtype(), irs->buildCall(powfn, 2, e1_t, e2_t));
 }
 #endif
     }
     tree t1 = e1->toElem(irs);
     tree t2 = e2->toElem(irs);
-
-    // %% type is NULL, bug in frontend? :-/
-    // probably should be just using void compound anyway...
     tree tt = type ? type->toCtype() : void_type_node;
 
-    gcc_assert(tt != NULL_TREE);
     return build2(COMPOUND_EXPR, tt, t1, t2);
 }
 
     /* This would apply to complex types as well, but GDC currently
        returns complex types as a struct instead of in ST(0) and ST(1).
      */
-    if (inlineAsm && ! naked && type->nextOf()->isfloating() &&
-        ! type->nextOf()->iscomplex())
+    if (inlineAsm && ! naked && type->nextOf()->isreal())
     {
         tree result_var = irs->localVar(TREE_TYPE(result_decl));
 
                 break;
 
             case Terror:
-                ctype = error_mark_node;
-                break;
+                return error_mark_node;
 
                 /* We can get Tident with forward references.  There seems to
                    be a legitame case (dstress:debug_info_03).  I have not seen this
                    happen for an error, so maybe it's okay...
-
-                   A way to handle this would be to partially construct
-                   function types and not complete it until it was actually
-                   used in a call. */
+                   
+                   Update:
+                   Seems to be fixed in the frontend, so changed to an error
+                   to catch potential bugs.
+                 */
             case Tident:
-                ctype = void_type_node;
-                break;
-
-                /* We can get Ttuple from void (T...)(T t) */
+            case Ttypeof:
+                ::error("forward reference of %s\n", this->toChars());
+                return error_mark_node;
+
+                /* Valid case for Ttuple is in CommaExp::toElem, in instances when
+                   a tuple has been expanded as a large chain of comma expressions.
+                 */
             case Ttuple:
                 ctype = void_type_node;
                 break;
 
         TYPE_CONTEXT(ctype) = gen.declContext(sym);
 
+#if V2 && D_GCC_VER >= 45
+        // For aggregates GCC now relies on TYPE_CANONICAL exclusively
+        // to show that two variant types are structurally equal.
+        TYPE_CANONICAL(ctype) = castMod(0)->toCtype();
+#endif
         g.ofile->initTypeDecl(ctype, sym);
 
         AggLayout agg_layout(sym, ctype);
             }
         }
         agg_layout.finish(sym->attributes);
-#if V2
-        // As per TypeDArray::toCtype, don't distinguish const from mutable types.
-        TYPE_MAIN_VARIANT(ctype) = mutableOf()->toCtype();
-#endif
     }
-    return gen.addTypeModifiers(ctype, mod);
+    return ctype;
 }
 
 void
     // This is required or we'll crash pretty early on. %%log
     build_common_tree_nodes (flag_signed_char, false);
 
+
     // This is also required (or the manual equivalent) or crashes
     // will occur later
+    char_type_node = d_type_for_size(CHAR_TYPE_SIZE, 1);
     size_type_node = d_type_for_mode(ptr_mode, 1);
 
-    // c was: TREE_TYPE (identifier_global_value (get_identifier (SIZE_TYPE)));
-    //signed_size_type_node = c_common_signed_type (size_type_node);
-
     // If this is called after the next statements, you'll get an ICE.
     set_sizetype(size_type_node);
 

File d/d-irstate.cc

 IRBase::Flow *
 IRBase::getLoopForLabel(Identifier * ident, bool want_continue)
 {
-    if (ident) {
+    if (ident)
+    {
         LabelStatement * lbl_stmt = func->searchLabel(ident)->statement;
         gcc_assert(lbl_stmt != 0);
         Statement * stmt = lbl_stmt->statement;
         if (scope_stmt)
             stmt = scope_stmt->statement;
 
-        for (int i = loops.dim - 1; i >= 0; i--) {
+        for (int i = loops.dim - 1; i >= 0; i--)
+        {
             Flow * flow = (Flow *) loops.data[i];
 
-            if (flow->statement == stmt) {
+            if (flow->statement == stmt)
+            {
                 if (want_continue)
                     gcc_assert(stmt->hasContinue());
                 return flow;
             }
         }
         gcc_unreachable();
-    } else {
-        for (int i = loops.dim - 1; i >= 0; i--) {
+    }
+    else
+    {
+        for (int i = loops.dim - 1; i >= 0; i--)
+        {
             Flow * flow = (Flow *) loops.data[i];
 
             if (( ! want_continue && flow->statement->hasBreak() ) ||
     {
         tree value = dt2node(dt);
         tree field = d_build_decl(FIELD_DECL, NULL_TREE, TREE_TYPE(value));
+        tree size = size_zero_node;
         DECL_CONTEXT(field) = aggtype;
         DECL_FIELD_OFFSET(field) = offset;
         DECL_FIELD_BIT_OFFSET(field) = bitsize_zero_node;
 
         fields.chain(field);
         elts.cons(field, value);
-        offset = size_binop(PLUS_EXPR, offset, TYPE_SIZE_UNIT(TREE_TYPE(value)));
+
+        if (value != error_mark_node)
+            size = TYPE_SIZE_UNIT(TREE_TYPE(value));
+        offset = size_binop(PLUS_EXPR, offset, size);
 
         dt = dt->DTnext;
     }