void DtoGetComplexParts(Loc& loc, Type* to, DValue* val, DValue*& re, DValue*& im) { Type* baserety; Type* baseimty; switch (to->toBasetype()->ty) { default: llvm_unreachable("Unexpected complex floating point type"); case Tcomplex32: baserety = Type::tfloat32; baseimty = Type::timaginary32; break; case Tcomplex64: baserety = Type::tfloat64; baseimty = Type::timaginary64; break; case Tcomplex80: baserety = Type::tfloat80; baseimty = Type::timaginary80; break; } Type* t = val->getType()->toBasetype(); if (t->iscomplex()) { DValue* v = DtoCastComplex(loc, val, to); if (to->iscomplex()) { if (v->isLVal()) { LLValue *reVal = DtoGEP(v->getLVal(), DtoConstInt(0), DtoConstInt(0), ".re_part"); LLValue *imVal = DtoGEP(v->getLVal(), DtoConstInt(0), DtoConstInt(1), ".im_part"); re = new DVarValue(baserety, reVal); im = new DVarValue(baseimty, imVal); } else { LLValue *reVal = gIR->ir->CreateExtractValue(v->getRVal(), 0, ".re_part"); LLValue *imVal = gIR->ir->CreateExtractValue(v->getRVal(), 1, ".im_part"); re = new DImValue(baserety, reVal); im = new DImValue(baseimty, imVal); } } else DtoGetComplexParts(loc, to, v, re, im); } else if (t->isimaginary()) { re = NULL; im = DtoCastFloat(loc, val, baseimty); } else if (t->isfloating()) { re = DtoCastFloat(loc, val, baserety); im = NULL; } else if (t->isintegral()) { re = DtoCastInt(loc, val, baserety); im = NULL; } else { assert(0); } }
LLValue *DtoGEPi(LLValue *ptr, unsigned i0, unsigned i1, const char *name, llvm::BasicBlock *bb) { LLValue *indices[] = {DtoConstUint(i0), DtoConstUint(i1)}; return DtoGEP(ptr, indices, /* inBounds = */ true, name, bb); }
LLValue *DtoGEPi1(LLValue *ptr, unsigned i0, const char *name, llvm::BasicBlock *bb) { return DtoGEP(ptr, DtoConstUint(i0), /* inBounds = */ true, name, bb); }
LLValue *DtoGEP(LLValue *ptr, LLValue *i0, LLValue *i1, bool inBounds, const char *name, llvm::BasicBlock *bb) { LLValue *indices[] = {i0, i1}; return DtoGEP(ptr, indices, inBounds, name, bb); }
LLValue *DtoGEP1(LLValue *ptr, LLValue *i0, bool inBounds, const char *name, llvm::BasicBlock *bb) { return DtoGEP(ptr, i0, inBounds, name, bb); }