diff --git a/dmd2/func.c b/dmd2/func.c index b62ba3ea..8bbcbcf5 100644 --- a/dmd2/func.c +++ b/dmd2/func.c @@ -977,6 +977,7 @@ void FuncDeclaration::semantic3(Scope *sc) #else Type *t; +#if !IN_LLVM if (global.params.is64bit) { // Declare save area for varargs registers Type *t = new TypeIdentifier(loc, Id::va_argsave_t); @@ -991,6 +992,7 @@ void FuncDeclaration::semantic3(Scope *sc) v_argsave->parent = this; } } +#endif if (f->linkage == LINKd) { // Declare _arguments[] diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index 4b5aec57..8a72b921 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -360,6 +360,10 @@ namespace x86_64_D_cc { return false; Array* fields = &t->sym->fields; + + if (fields->dim == 0) + return false; + d_uns64 nextbyte = 0; for (d_uns64 i = 0; i < fields->dim; i++) { VarDeclaration* field = (VarDeclaration*) fields->data[i]; @@ -549,9 +553,8 @@ bool X86_64TargetABI::returnInArg(TypeFunction* tf) { Type* rt = tf->next->toBasetype(); if (tf->linkage == LINKd) { - assert(rt->ty != Tsarray && "Update calling convention for static array returns"); - // All non-structs can be returned in registers. + // FIXME: Update calling convention for static array returns if (rt->ty != Tstruct) return false; @@ -678,12 +681,14 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) { } } +#if 0 if (fty.arg_this) { fty.arg_this->attrs |= llvm::Attribute::Nest; } if (fty.arg_nest) { fty.arg_nest->attrs |= llvm::Attribute::Nest; } +#endif Logger::println("x86-64 D ABI: Transforming arguments"); LOG_SCOPE; diff --git a/gen/asm-x86-32.h b/gen/asm-x86-32.h index 54aab415..0625486a 100644 --- a/gen/asm-x86-32.h +++ b/gen/asm-x86-32.h @@ -472,8 +472,8 @@ namespace AsmParserx8632 /* Op_FCmp1 */ { rfp, 0, 0, 0, 0, Next_Form, Op_0 }, /* Op_FCmpP */ { mfp, 0, 0, FP_Types, 0, Next_Form, Op_FCmpP1 }, // pops /* Op_FCmpP1 */ { rfp, 0, 0, 0, 0, Next_Form, Op_F0_P }, // pops - /* Op_FCmpFlg */ { rfp, rfp, 0, 0, Clb_Flags }, - /* Op_FCmpFlgP */ { rfp, rfp, 0, 0, Clb_Flags }, // pops + /* Op_FCmpFlg */ { rfp, 0, 0, 0, Clb_Flags }, + /* Op_FCmpFlgP */ { rfp, 0, 0, 0, Clb_Flags }, // pops /* Op_fld */ { mfp, 0, 0, FP_Types, Clb_ST, Next_Form, Op_fldR }, /* Op_fldR */ { rfp, 0, 0, 0, Clb_ST }, /* Op_fxch */ { D|rfp,D|rfp, 0, 0, Clb_ST, Next_Form, Op_fxch1 }, // not in intel manual?, but DMD allows it (gas won't), second arg must be ST diff --git a/gen/asm-x86-64.h b/gen/asm-x86-64.h index de1c9bd9..bcb32485 100644 --- a/gen/asm-x86-64.h +++ b/gen/asm-x86-64.h @@ -549,8 +549,8 @@ namespace AsmParserx8664 /* Op_FCmp1 */ { rfp, 0, 0, 0, 0, Next_Form, Op_0 }, /* Op_FCmpP */ { mfp, 0, 0, FP_Types, 0, Next_Form, Op_FCmpP1 }, // pops /* Op_FCmpP1 */ { rfp, 0, 0, 0, 0, Next_Form, Op_F0_P }, // pops - /* Op_FCmpFlg */ { rfp, rfp, 0, 0, Clb_Flags }, - /* Op_FCmpFlgP */ { rfp, rfp, 0, 0, Clb_Flags }, // pops + /* Op_FCmpFlg */ { rfp, 0, 0, 0, Clb_Flags }, + /* Op_FCmpFlgP */ { rfp, 0, 0, 0, Clb_Flags }, // pops /* Op_fld */ { mfp, 0, 0, FP_Types, Clb_ST, Next_Form, Op_fldR }, /* Op_fldR */ { rfp, 0, 0, 0, Clb_ST }, /* Op_fxch */ { D|rfp,D|rfp, 0, 0, Clb_ST, Next_Form, Op_fxch1 }, // not in intel manual?, but DMD allows it (gas won't), second arg must be ST @@ -1106,6 +1106,7 @@ namespace AsmParserx8664 { "pmulhw", Op_DstSrcMMX }, { "pmullw", Op_DstSrcMMX }, { "pmuludq", Op_DstSrcMMX }, // also sse + { "pop", Op_DstW }, { "popf", Op_SizedStack }, // rewrite the insn with a special case { "popfq", Op_SizedStack }, { "popq", Op_push }, @@ -1150,6 +1151,7 @@ namespace AsmParserx8664 { "punpckldq", Op_DstSrcMMX }, { "punpcklqdq",Op_DstSrcMMX }, { "punpcklwd", Op_DstSrcMMX }, + { "push", Op_push }, { "pushf", Op_SizedStack }, { "pushfq", Op_SizedStack }, { "pushq", Op_push }, diff --git a/gen/functions.cpp b/gen/functions.cpp index 923f3b58..d1aec882 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -117,12 +117,6 @@ const llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nest lidx++; } } -#if DMDV2 - else - { - fty.c_vararg = true; - } -#else else if (f->linkage == LINKc) { fty.c_vararg = true; @@ -132,7 +126,6 @@ const llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nest type->error(0, "invalid linkage for variadic function"); fatal(); } -#endif } // if this _Dmain() doesn't have an argument, we force it to have one diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index d674bdb0..ed9d65c2 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -1592,9 +1592,9 @@ size_t realignOffset(size_t offset, Type* type) // if it differs we need to insert manual padding as well if (alignsize != alignsize2) { - assert(alignsize > alignsize2 && "this is not good, the D and LLVM " - "type alignments differ, but LLVM's is bigger! This will break " - "aggregate type mapping"); + //assert(alignsize > alignsize2 && "this is not good, the D and LLVM " + // "type alignments differ, but LLVM's is bigger! This will break " + // "aggregate type mapping"); // don't try and align the offset, and let the mappers pad 100% manually return offset; } diff --git a/gen/structs.cpp b/gen/structs.cpp index 505bce87..f3a68e93 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -353,7 +353,7 @@ LLType* DtoUnpaddedStructType(Type* dty) { CacheT::iterator it = cache->find(dty); if (it != cache->end()) return it->second; - + TypeStruct* sty = (TypeStruct*) dty; Array& fields = sty->sym->fields; diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 26cf03c1..fcc9f7a9 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -491,7 +491,10 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* Logger::cout() << "expects: " << *callableTy->getParamType(j) << '\n'; } #endif - arg = DtoBitCast(arg, callableTy->getParamType(j)); + if (isaStruct(arg)) + arg = DtoAggrPaint(arg, callableTy->getParamType(j)); + else + arg = DtoBitCast(arg, callableTy->getParamType(j)); } // param attrs diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 912b9a8f..853093c9 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -682,7 +682,8 @@ void TypeInfoStructDeclaration::llvmDefine() ClassDeclaration* tscd = Type::typeinfostruct; - assert(tscd->fields.dim == 11); + assert((!global.params.is64bit && tscd->fields.dim == 11) || + (global.params.is64bit && tscd->fields.dim == 13)); // const(MemberInfo[]) function(in char[]) xgetMembers; b.push_funcptr(sd->findGetMembers()); @@ -694,7 +695,24 @@ void TypeInfoStructDeclaration::llvmDefine() b.push_funcptr(sd->postblit); //uint m_align; - b.push_uint(0); // FIXME + b.push_uint(tc->alignsize()); + + if (global.params.is64bit) + { + TypeTuple *tup = tc->toArgTypes(); + assert(tup->arguments->dim <= 2); + for (int i = 0; i < 2; i++) + { + if (i < tup->arguments->dim) + { + Type *targ = ((Parameter *)tup->arguments->data[i])->type; + targ = targ->merge(); + b.push_typeinfo(targ); + } + else + b.push_null(Type::typeinfo->type); + } + } #endif diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index 518c85eb..f0d5937d 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -16,7 +16,7 @@ IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, unsigned a) { type = t; - ltype = bref ? DtoType(t->pointerTo()) : DtoType(t); + ltype = t != Type::tvoid && bref ? DtoType(t->pointerTo()) : DtoType(t); attrs = a; byref = bref; rewrite = NULL; diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 451235af..643a4322 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -71,6 +71,7 @@ elseif(D_VERSION EQUAL 2) file(GLOB_RECURSE DCRT_D ${RUNTIME_DC_DIR}/*.d) file(GLOB_RECURSE LDC_D ${RUNTIME_DIR}/src/ldc/*.d) list(REMOVE_ITEM DCRT_D + ${RUNTIME_DC_DIR}/alloca.d ${RUNTIME_DC_DIR}/arraybyte.d ${RUNTIME_DC_DIR}/arraycast.d ${RUNTIME_DC_DIR}/arraycat.d @@ -261,8 +262,6 @@ set_target_properties( LINKER_LANGUAGE C ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/../lib LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/../lib - COMPILE_FLAGS "-m32" - LINK_FLAGS "-m32" ) # BCLIBS is empty if BUILD_BC_LIBS is not selected @@ -280,7 +279,5 @@ if(PHOBOS2_DIR) LINKER_LANGUAGE C ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/../lib LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/../lib - COMPILE_FLAGS "-m32" - LINK_FLAGS "-m32" ) endif(PHOBOS2_DIR)