More X86_64 ABI

This commit is contained in:
Alexey Prokhin
2011-03-26 19:30:17 +03:00
parent 375dcb095c
commit 7f0ecdf7b9
4 changed files with 135 additions and 246 deletions

View File

@@ -13,6 +13,7 @@
#include "gen/abi-generic.h"
#include "ir/irfunction.h"
#include "ir/irfuncty.h"
//////////////////////////////////////////////////////////////////////////////
@@ -83,47 +84,6 @@ struct X86_cfloat_rewrite : ABIRewrite
//////////////////////////////////////////////////////////////////////////////
// FIXME: try into eliminating the alloca or if at least check
// if it gets optimized away
// convert byval struct
// when
struct X86_struct_to_register : ABIRewrite
{
// int -> struct
LLValue* get(Type* dty, DValue* dv)
{
Logger::println("rewriting int -> struct");
LLValue* mem = DtoAlloca(dty, ".int_to_struct");
LLValue* v = dv->getRVal();
DtoStore(v, DtoBitCast(mem, getPtrToType(v->getType())));
return DtoLoad(mem);
}
// int -> struct (with dst lvalue given)
void getL(Type* dty, DValue* dv, llvm::Value* lval)
{
Logger::println("rewriting int -> struct");
LLValue* v = dv->getRVal();
DtoStore(v, DtoBitCast(lval, getPtrToType(v->getType())));
}
// struct -> int
LLValue* put(Type* dty, DValue* dv)
{
Logger::println("rewriting struct -> int");
assert(dv->isLVal());
LLValue* mem = dv->getLVal();
const LLType* t = LLIntegerType::get(gIR->context(), dty->size()*8);
return DtoLoad(DtoBitCast(mem, getPtrToType(t)));
}
const LLType* type(Type* t, const LLType*)
{
size_t sz = t->size()*8;
return LLIntegerType::get(gIR->context(), sz);
}
};
//////////////////////////////////////////////////////////////////////////////
struct X86TargetABI : TargetABI
{
X87_complex_swap swapComplex;