Example #1
0
LLConstant* DtoConstComplex(Type* _ty, longdouble re, longdouble im)
{
    Type* base = 0;
    switch (_ty->toBasetype()->ty) {
    default: llvm_unreachable("Unexpected complex floating point type");
    case Tcomplex32: base = Type::tfloat32; break;
    case Tcomplex64: base = Type::tfloat64; break;
    case Tcomplex80: base = Type::tfloat80; break;
    }

    std::vector<LLConstant*> inits;
    inits.push_back(DtoConstFP(base, re));
    inits.push_back(DtoConstFP(base, im));

    return llvm::ConstantStruct::get(DtoComplexType(_ty), inits);
}
Example #2
0
LLConstant *DtoConstComplex(Type *_ty, longdouble re, longdouble im) {
  Type *base = nullptr;
  switch (_ty->toBasetype()->ty) {
  default:
    llvm_unreachable("Unexpected complex floating point type");
  case Tcomplex32:
    base = Type::tfloat32;
    break;
  case Tcomplex64:
    base = Type::tfloat64;
    break;
  case Tcomplex80:
    base = Type::tfloat80;
    break;
  }

  LLConstant *inits[] = {DtoConstFP(base, re), DtoConstFP(base, im)};

  return llvm::ConstantStruct::get(DtoComplexType(_ty),
                                   llvm::ArrayRef<LLConstant *>(inits));
}