Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
static Type *getIRTypeFromMachineType(MVT VT, LLVMContext &Ctx) {
assert(!VT.isScalableVector() && "Not prepared to deal with scalables.");
if (VT.isVector())
return VectorType::get(
getIRTypeFromMachineType(VT.getVectorElementType(), Ctx),
VT.getVectorElementCount());
if (VT.isInteger())
return IntegerType::get(Ctx, VT.getSizeInBits());
if (VT.isFloatingPoint()) {
switch (VT.SimpleTy) {
case MVT::bf16:
return Type::getBFloatTy(Ctx);
case MVT::f16:
return Type::getHalfTy(Ctx);
case MVT::f32:
return Type::getFloatTy(Ctx);
case MVT::f64:
return Type::getDoubleTy(Ctx);
case MVT::f80:
return Type::getX86_FP80Ty(Ctx);
case MVT::f128:
return Type::getFP128Ty(Ctx);
case MVT::ppcf128:
return Type::getPPC_FP128Ty(Ctx);
default:
llvm_unreachable("unknown scalar floating-point type?");
}
}
switch (VT.SimpleTy) {
case MVT::x86mmx:
return Type::getX86_MMXTy(Ctx);
case MVT::x86amx:
return Type::getX86_AMXTy(Ctx);
default:
break;
}
llvm_unreachable("unhandled MVT scalar type!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment