예제 #1
0
파일: complex.cpp 프로젝트: NilsBossung/ldc
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);
    }
}
예제 #2
0
파일: tollvm.cpp 프로젝트: Syniurge/Calypso
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);
}
예제 #3
0
파일: tollvm.cpp 프로젝트: Syniurge/Calypso
LLValue *DtoGEPi1(LLValue *ptr, unsigned i0, const char *name,
                  llvm::BasicBlock *bb) {
  return DtoGEP(ptr, DtoConstUint(i0), /* inBounds = */ true, name, bb);
}
예제 #4
0
파일: tollvm.cpp 프로젝트: Syniurge/Calypso
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);
}
예제 #5
0
파일: tollvm.cpp 프로젝트: Syniurge/Calypso
LLValue *DtoGEP1(LLValue *ptr, LLValue *i0, bool inBounds, const char *name,
                 llvm::BasicBlock *bb) {
  return DtoGEP(ptr, i0, inBounds, name, bb);
}