LLValue *put(DValue *v) override { LLValue *address = getAddressOf(v); LLType *abiTy = getAbiType(v->getType()); assert(abiTy && "Why are we rewriting a non-rewritten type?"); return loadFromMemory(address, abiTy, ".X86_64_C_struct_rewrite_putResult"); }
// Helper function for rewriteFunctionType. // Return type and parameters are passed here (unless they're already in memory) // to get the rewrite applied (if necessary). void X86_64TargetABI::fixup(IrFuncTyArg& arg) { LLType* abiTy = getAbiType(arg.type); if (abiTy && abiTy != arg.ltype) { assert(arg.type == Type::tcomplex32 || arg.type->ty == Tstruct); arg.ltype = abiTy; arg.rewrite = &struct_rewrite; } }
void X86_64TargetABI::rewriteArgument(IrFuncTyArg &arg, RegCount ®Count) { LLType *originalLType = arg.ltype; Type *t = arg.type->toBasetype(); LLType *abiTy = getAbiType(t); if (abiTy && !LLTypeMemoryLayout::typesAreEquivalent(abiTy, originalLType)) { IF_LOG { Logger::println("Rewriting argument type %s", t->toChars()); LOG_SCOPE; Logger::cout() << *originalLType << " => " << *abiTy << '\n'; } arg.rewrite = &struct_rewrite; arg.ltype = abiTy; }
// Turn a struct into an ABI-mangled representation LLValue* put(Type* dty, DValue* v) { LLValue* lval; if (v->isLVal()) { lval = v->getLVal(); } else { // No memory location, create one. LLValue* rval = v->getRVal(); lval = DtoRawAlloca(rval->getType(), 0); DtoStore(rval, lval); } LLType* abiTy = getAbiType(dty); assert(abiTy && "Why are we rewriting a non-rewritten type?"); LLType* pTy = getPtrToType(abiTy); return DtoLoad(DtoBitCast(lval, pTy), "put-result"); }
/// should return the transformed type for this rewrite LLType* type(Type* dty, LLType* t) { return getAbiType(dty); }
LLType *type(Type *dty, LLType *t) override { return getAbiType(dty); }
LLType *type(Type *t) override { return getAbiType(t); }