mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-06 15:03:13 +01:00
More X86_64 ABI
This commit is contained in:
42
gen/abi.cpp
42
gen/abi.cpp
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user