mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 09:00:33 +03:00
Simplify vaarg support on X86_64
This commit is contained in:
parent
6e8e466f5f
commit
1e649422d6
2 changed files with 2 additions and 26 deletions
26
gen/toir.cpp
26
gen/toir.cpp
|
@ -933,35 +933,11 @@ DValue* CallExp::toElem(IRState* p)
|
||||||
if (LLValue *argptr = gIR->func()->_argptr) {
|
if (LLValue *argptr = gIR->func()->_argptr) {
|
||||||
DtoStore(DtoLoad(argptr), DtoBitCast(arg, getPtrToType(getVoidPtrType())));
|
DtoStore(DtoLoad(argptr), DtoBitCast(arg, getPtrToType(getVoidPtrType())));
|
||||||
return new DImValue(type, arg);
|
return new DImValue(type, arg);
|
||||||
} else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64) {
|
} else {
|
||||||
LLValue *va_list = DtoAlloca(exp->type->nextOf());
|
|
||||||
DtoStore(va_list, arg);
|
|
||||||
va_list = DtoBitCast(va_list, getVoidPtrType());
|
|
||||||
return new DImValue(type, gIR->ir->CreateCall(GET_INTRINSIC_DECL(vastart), va_list, ""));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
arg = DtoBitCast(arg, getVoidPtrType());
|
arg = DtoBitCast(arg, getVoidPtrType());
|
||||||
return new DImValue(type, gIR->ir->CreateCall(GET_INTRINSIC_DECL(vastart), arg, ""));
|
return new DImValue(type, gIR->ir->CreateCall(GET_INTRINSIC_DECL(vastart), arg, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fndecl->llvmInternal == LLVMva_copy &&
|
|
||||||
global.params.targetTriple.getArch() == llvm::Triple::x86_64) {
|
|
||||||
if (arguments->dim != 2) {
|
|
||||||
error("va_copy instruction expects 2 arguments");
|
|
||||||
fatal();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Expression* exp1 = static_cast<Expression*>(arguments->data[0]);
|
|
||||||
Expression* exp2 = static_cast<Expression*>(arguments->data[1]);
|
|
||||||
LLValue* arg1 = exp1->toElem(p)->getLVal();
|
|
||||||
LLValue* arg2 = exp2->toElem(p)->getLVal();
|
|
||||||
|
|
||||||
LLValue *va_list = DtoAlloca(exp1->type->nextOf());
|
|
||||||
DtoStore(va_list, arg1);
|
|
||||||
|
|
||||||
DtoStore(DtoLoad(DtoLoad(arg2)), DtoLoad(arg1));
|
|
||||||
return new DVarValue(type, arg1);
|
|
||||||
}
|
|
||||||
// va_arg instruction
|
// va_arg instruction
|
||||||
else if (fndecl->llvmInternal == LLVMva_arg) {
|
else if (fndecl->llvmInternal == LLVMva_arg) {
|
||||||
if (arguments->dim != 1) {
|
if (arguments->dim != 1) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c27b18f59f0124f96401bc3c18b39741c3abc0d4
|
Subproject commit db89b5eeaa148dddc16575efdb4a88bbf006fe34
|
Loading…
Add table
Add a link
Reference in a new issue