mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00
A few fixes for 64bit
This commit is contained in:
parent
aa5dfdfd4d
commit
e921998d75
11 changed files with 45 additions and 25 deletions
|
@ -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[]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -491,6 +491,9 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
|||
Logger::cout() << "expects: " << *callableTy->getParamType(j) << '\n';
|
||||
}
|
||||
#endif
|
||||
if (isaStruct(arg))
|
||||
arg = DtoAggrPaint(arg, callableTy->getParamType(j));
|
||||
else
|
||||
arg = DtoBitCast(arg, callableTy->getParamType(j));
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue