Preliminary vector support

This commit is contained in:
Alexey Prokhin
2012-02-15 17:28:10 +04:00
parent 5af48edec3
commit ae7f0ca7e7
12 changed files with 190 additions and 9 deletions

View File

@@ -233,5 +233,39 @@ llvm::Type * IrTypeArray::array2llvm(Type * t)
return at;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#if DMDV2
IrTypeVector::IrTypeVector(Type* dt)
: IrType(dt, vector2llvm(dt))
{
}
//////////////////////////////////////////////////////////////////////////////
llvm::Type* IrTypeVector::buildType()
{
return type;
}
//////////////////////////////////////////////////////////////////////////////
llvm::Type* IrTypeVector::vector2llvm(Type* dt)
{
assert(dt->ty == Tvector && "not vector type");
TypeVector* tv = (TypeVector*)dt;
assert(tv->basetype->ty == Tsarray);
TypeSArray* tsa = (TypeSArray*)tv->basetype;
dim = (uint64_t)tsa->dim->toUInteger();
LLType* elemType = DtoType(tsa->next);
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
return llvm::VectorType::get(elemType, dim);
}
#endif
//////////////////////////////////////////////////////////////////////////////