2009-08-10 22:56:29 +00:00
|
|
|
//===----------- ValueTypes.cpp - Implementation of EVT methods -----------===//
|
2005-04-21 22:36:52 +00:00
|
|
|
//
|
2005-01-15 06:52:40 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:36:52 +00:00
|
|
|
//
|
2005-01-15 06:52:40 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements methods in the CodeGen/ValueTypes.h header.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/ValueTypes.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
|
|
|
#include "llvm/IR/LLVMContext.h"
|
|
|
|
#include "llvm/IR/Type.h"
|
2009-07-11 20:10:48 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2005-01-15 06:52:40 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2011-09-06 19:07:46 +00:00
|
|
|
EVT EVT::changeExtendedVectorElementTypeToInteger() const {
|
|
|
|
LLVMContext &Context = LLVMTy->getContext();
|
|
|
|
EVT IntTy = getIntegerVT(Context, getVectorElementType().getSizeInBits());
|
|
|
|
return getVectorVT(Context, IntTy, getVectorNumElements());
|
|
|
|
}
|
|
|
|
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT EVT::getExtendedIntegerVT(LLVMContext &Context, unsigned BitWidth) {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT;
|
2009-08-13 21:58:54 +00:00
|
|
|
VT.LLVMTy = IntegerType::get(Context, BitWidth);
|
2008-11-04 16:03:56 +00:00
|
|
|
assert(VT.isExtended() && "Type is not extended!");
|
2008-11-03 17:56:27 +00:00
|
|
|
return VT;
|
|
|
|
}
|
|
|
|
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT,
|
|
|
|
unsigned NumElements) {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT ResultVT;
|
2009-08-12 00:36:31 +00:00
|
|
|
ResultVT.LLVMTy = VectorType::get(VT.getTypeForEVT(Context), NumElements);
|
2008-11-04 16:03:56 +00:00
|
|
|
assert(ResultVT.isExtended() && "Type is not extended!");
|
2008-11-03 17:56:27 +00:00
|
|
|
return ResultVT;
|
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
bool EVT::isExtendedFloatingPoint() const {
|
2008-11-03 17:56:27 +00:00
|
|
|
assert(isExtended() && "Type is not extended!");
|
2010-02-15 16:12:20 +00:00
|
|
|
return LLVMTy->isFPOrFPVectorTy();
|
2008-11-03 17:56:27 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
bool EVT::isExtendedInteger() const {
|
2008-11-03 17:56:27 +00:00
|
|
|
assert(isExtended() && "Type is not extended!");
|
2010-02-15 16:12:20 +00:00
|
|
|
return LLVMTy->isIntOrIntVectorTy();
|
2008-11-03 17:56:27 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
bool EVT::isExtendedVector() const {
|
2008-11-03 17:56:27 +00:00
|
|
|
assert(isExtended() && "Type is not extended!");
|
2010-02-16 11:11:14 +00:00
|
|
|
return LLVMTy->isVectorTy();
|
2008-11-03 17:56:27 +00:00
|
|
|
}
|
|
|
|
|
2012-09-19 22:47:07 +00:00
|
|
|
bool EVT::isExtended16BitVector() const {
|
2012-09-26 07:11:42 +00:00
|
|
|
return isExtendedVector() && getExtendedSizeInBits() == 16;
|
2012-09-19 22:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EVT::isExtended32BitVector() const {
|
2012-09-26 07:11:42 +00:00
|
|
|
return isExtendedVector() && getExtendedSizeInBits() == 32;
|
2012-09-19 22:47:07 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
bool EVT::isExtended64BitVector() const {
|
2012-09-26 07:11:42 +00:00
|
|
|
return isExtendedVector() && getExtendedSizeInBits() == 64;
|
2008-11-03 17:56:27 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
bool EVT::isExtended128BitVector() const {
|
2012-09-26 07:11:42 +00:00
|
|
|
return isExtendedVector() && getExtendedSizeInBits() == 128;
|
2008-11-03 17:56:27 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
bool EVT::isExtended256BitVector() const {
|
2012-09-26 07:11:42 +00:00
|
|
|
return isExtendedVector() && getExtendedSizeInBits() == 256;
|
2009-06-29 16:47:10 +00:00
|
|
|
}
|
|
|
|
|
2010-05-13 23:55:47 +00:00
|
|
|
bool EVT::isExtended512BitVector() const {
|
2012-09-26 07:11:42 +00:00
|
|
|
return isExtendedVector() && getExtendedSizeInBits() == 512;
|
2010-05-13 23:55:47 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 21:22:00 +00:00
|
|
|
bool EVT::isExtended1024BitVector() const {
|
2012-09-26 07:11:42 +00:00
|
|
|
return isExtendedVector() && getExtendedSizeInBits() == 1024;
|
2012-07-26 21:22:00 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT EVT::getExtendedVectorElementType() const {
|
2008-11-03 17:56:27 +00:00
|
|
|
assert(isExtended() && "Type is not extended!");
|
2009-08-10 22:56:29 +00:00
|
|
|
return EVT::getEVT(cast<VectorType>(LLVMTy)->getElementType());
|
2008-11-03 17:56:27 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
unsigned EVT::getExtendedVectorNumElements() const {
|
2008-11-03 17:56:27 +00:00
|
|
|
assert(isExtended() && "Type is not extended!");
|
|
|
|
return cast<VectorType>(LLVMTy)->getNumElements();
|
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
unsigned EVT::getExtendedSizeInBits() const {
|
2008-11-03 17:56:27 +00:00
|
|
|
assert(isExtended() && "Type is not extended!");
|
2011-07-18 04:54:35 +00:00
|
|
|
if (IntegerType *ITy = dyn_cast<IntegerType>(LLVMTy))
|
2008-11-03 17:56:27 +00:00
|
|
|
return ITy->getBitWidth();
|
2011-07-18 04:54:35 +00:00
|
|
|
if (VectorType *VTy = dyn_cast<VectorType>(LLVMTy))
|
2008-11-03 17:56:27 +00:00
|
|
|
return VTy->getBitWidth();
|
2012-02-05 22:14:15 +00:00
|
|
|
llvm_unreachable("Unrecognized extended type!");
|
2008-11-03 17:56:27 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
/// getEVTString - This function returns value type as a string, e.g. "i32".
|
|
|
|
std::string EVT::getEVTString() const {
|
2009-08-11 20:47:22 +00:00
|
|
|
switch (V.SimpleTy) {
|
2007-06-25 16:23:39 +00:00
|
|
|
default:
|
2008-06-06 12:08:01 +00:00
|
|
|
if (isVector())
|
|
|
|
return "v" + utostr(getVectorNumElements()) +
|
2009-08-10 22:56:29 +00:00
|
|
|
getVectorElementType().getEVTString();
|
2008-06-06 12:08:01 +00:00
|
|
|
if (isInteger())
|
|
|
|
return "i" + utostr(getSizeInBits());
|
2009-08-10 22:56:29 +00:00
|
|
|
llvm_unreachable("Invalid EVT!");
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::i1: return "i1";
|
|
|
|
case MVT::i8: return "i8";
|
|
|
|
case MVT::i16: return "i16";
|
|
|
|
case MVT::i32: return "i32";
|
|
|
|
case MVT::i64: return "i64";
|
|
|
|
case MVT::i128: return "i128";
|
2011-12-20 00:02:33 +00:00
|
|
|
case MVT::f16: return "f16";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::f32: return "f32";
|
|
|
|
case MVT::f64: return "f64";
|
|
|
|
case MVT::f80: return "f80";
|
|
|
|
case MVT::f128: return "f128";
|
|
|
|
case MVT::ppcf128: return "ppcf128";
|
|
|
|
case MVT::isVoid: return "isVoid";
|
|
|
|
case MVT::Other: return "ch";
|
2010-12-21 02:38:05 +00:00
|
|
|
case MVT::Glue: return "glue";
|
2010-09-07 20:03:56 +00:00
|
|
|
case MVT::x86mmx: return "x86mmx";
|
2012-09-19 22:47:07 +00:00
|
|
|
case MVT::v2i1: return "v2i1";
|
|
|
|
case MVT::v4i1: return "v4i1";
|
|
|
|
case MVT::v8i1: return "v8i1";
|
|
|
|
case MVT::v16i1: return "v16i1";
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v32i1: return "v32i1";
|
|
|
|
case MVT::v64i1: return "v64i1";
|
2013-09-24 02:47:27 +00:00
|
|
|
case MVT::v1i8: return "v1i8";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::v2i8: return "v2i8";
|
|
|
|
case MVT::v4i8: return "v4i8";
|
|
|
|
case MVT::v8i8: return "v8i8";
|
|
|
|
case MVT::v16i8: return "v16i8";
|
|
|
|
case MVT::v32i8: return "v32i8";
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v64i8: return "v64i8";
|
2012-09-19 22:47:07 +00:00
|
|
|
case MVT::v1i16: return "v1i16";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::v2i16: return "v2i16";
|
|
|
|
case MVT::v4i16: return "v4i16";
|
|
|
|
case MVT::v8i16: return "v8i16";
|
|
|
|
case MVT::v16i16: return "v16i16";
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v32i16: return "v32i16";
|
2012-09-19 22:47:07 +00:00
|
|
|
case MVT::v1i32: return "v1i32";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::v2i32: return "v2i32";
|
|
|
|
case MVT::v4i32: return "v4i32";
|
|
|
|
case MVT::v8i32: return "v8i32";
|
2012-07-26 21:22:00 +00:00
|
|
|
case MVT::v16i32: return "v16i32";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::v1i64: return "v1i64";
|
|
|
|
case MVT::v2i64: return "v2i64";
|
|
|
|
case MVT::v4i64: return "v4i64";
|
2010-05-13 23:55:47 +00:00
|
|
|
case MVT::v8i64: return "v8i64";
|
2012-07-26 21:22:00 +00:00
|
|
|
case MVT::v16i64: return "v16i64";
|
2015-04-17 16:11:05 +00:00
|
|
|
case MVT::v1i128: return "v1i128";
|
2013-09-24 02:47:27 +00:00
|
|
|
case MVT::v1f32: return "v1f32";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::v2f32: return "v2f32";
|
2012-01-12 23:14:13 +00:00
|
|
|
case MVT::v2f16: return "v2f16";
|
2013-10-03 03:29:21 +00:00
|
|
|
case MVT::v4f16: return "v4f16";
|
2013-08-13 22:34:26 +00:00
|
|
|
case MVT::v8f16: return "v8f16";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::v4f32: return "v4f32";
|
|
|
|
case MVT::v8f32: return "v8f32";
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v16f32: return "v16f32";
|
2013-09-24 02:47:27 +00:00
|
|
|
case MVT::v1f64: return "v1f64";
|
2009-08-11 20:47:22 +00:00
|
|
|
case MVT::v2f64: return "v2f64";
|
|
|
|
case MVT::v4f64: return "v4f64";
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v8f64: return "v8f64";
|
2010-02-26 19:38:59 +00:00
|
|
|
case MVT::Metadata:return "Metadata";
|
2011-11-16 01:02:57 +00:00
|
|
|
case MVT::Untyped: return "Untyped";
|
2005-01-15 06:52:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
/// getTypeForEVT - This method returns an LLVM type corresponding to the
|
|
|
|
/// specified EVT. For integer types, this returns an unsigned type. Note
|
2008-06-06 12:08:01 +00:00
|
|
|
/// that this will abort for types that cannot be represented.
|
2011-07-18 04:54:35 +00:00
|
|
|
Type *EVT::getTypeForEVT(LLVMContext &Context) const {
|
2009-08-11 20:47:22 +00:00
|
|
|
switch (V.SimpleTy) {
|
2007-06-25 16:23:39 +00:00
|
|
|
default:
|
2008-11-04 16:19:44 +00:00
|
|
|
assert(isExtended() && "Type is not extended!");
|
|
|
|
return LLVMTy;
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::isVoid: return Type::getVoidTy(Context);
|
|
|
|
case MVT::i1: return Type::getInt1Ty(Context);
|
|
|
|
case MVT::i8: return Type::getInt8Ty(Context);
|
|
|
|
case MVT::i16: return Type::getInt16Ty(Context);
|
|
|
|
case MVT::i32: return Type::getInt32Ty(Context);
|
|
|
|
case MVT::i64: return Type::getInt64Ty(Context);
|
|
|
|
case MVT::i128: return IntegerType::get(Context, 128);
|
2011-12-20 00:02:33 +00:00
|
|
|
case MVT::f16: return Type::getHalfTy(Context);
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::f32: return Type::getFloatTy(Context);
|
|
|
|
case MVT::f64: return Type::getDoubleTy(Context);
|
|
|
|
case MVT::f80: return Type::getX86_FP80Ty(Context);
|
|
|
|
case MVT::f128: return Type::getFP128Ty(Context);
|
|
|
|
case MVT::ppcf128: return Type::getPPC_FP128Ty(Context);
|
2010-09-10 20:55:01 +00:00
|
|
|
case MVT::x86mmx: return Type::getX86_MMXTy(Context);
|
2012-09-19 22:47:07 +00:00
|
|
|
case MVT::v2i1: return VectorType::get(Type::getInt1Ty(Context), 2);
|
|
|
|
case MVT::v4i1: return VectorType::get(Type::getInt1Ty(Context), 4);
|
|
|
|
case MVT::v8i1: return VectorType::get(Type::getInt1Ty(Context), 8);
|
|
|
|
case MVT::v16i1: return VectorType::get(Type::getInt1Ty(Context), 16);
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v32i1: return VectorType::get(Type::getInt1Ty(Context), 32);
|
|
|
|
case MVT::v64i1: return VectorType::get(Type::getInt1Ty(Context), 64);
|
2013-09-24 02:47:27 +00:00
|
|
|
case MVT::v1i8: return VectorType::get(Type::getInt8Ty(Context), 1);
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::v2i8: return VectorType::get(Type::getInt8Ty(Context), 2);
|
|
|
|
case MVT::v4i8: return VectorType::get(Type::getInt8Ty(Context), 4);
|
|
|
|
case MVT::v8i8: return VectorType::get(Type::getInt8Ty(Context), 8);
|
|
|
|
case MVT::v16i8: return VectorType::get(Type::getInt8Ty(Context), 16);
|
|
|
|
case MVT::v32i8: return VectorType::get(Type::getInt8Ty(Context), 32);
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v64i8: return VectorType::get(Type::getInt8Ty(Context), 64);
|
2012-09-19 22:47:07 +00:00
|
|
|
case MVT::v1i16: return VectorType::get(Type::getInt16Ty(Context), 1);
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::v2i16: return VectorType::get(Type::getInt16Ty(Context), 2);
|
|
|
|
case MVT::v4i16: return VectorType::get(Type::getInt16Ty(Context), 4);
|
|
|
|
case MVT::v8i16: return VectorType::get(Type::getInt16Ty(Context), 8);
|
|
|
|
case MVT::v16i16: return VectorType::get(Type::getInt16Ty(Context), 16);
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v32i16: return VectorType::get(Type::getInt16Ty(Context), 32);
|
2012-09-19 22:47:07 +00:00
|
|
|
case MVT::v1i32: return VectorType::get(Type::getInt32Ty(Context), 1);
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::v2i32: return VectorType::get(Type::getInt32Ty(Context), 2);
|
|
|
|
case MVT::v4i32: return VectorType::get(Type::getInt32Ty(Context), 4);
|
|
|
|
case MVT::v8i32: return VectorType::get(Type::getInt32Ty(Context), 8);
|
2012-07-26 21:22:00 +00:00
|
|
|
case MVT::v16i32: return VectorType::get(Type::getInt32Ty(Context), 16);
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::v1i64: return VectorType::get(Type::getInt64Ty(Context), 1);
|
|
|
|
case MVT::v2i64: return VectorType::get(Type::getInt64Ty(Context), 2);
|
|
|
|
case MVT::v4i64: return VectorType::get(Type::getInt64Ty(Context), 4);
|
2010-05-13 23:55:47 +00:00
|
|
|
case MVT::v8i64: return VectorType::get(Type::getInt64Ty(Context), 8);
|
2012-07-26 21:22:00 +00:00
|
|
|
case MVT::v16i64: return VectorType::get(Type::getInt64Ty(Context), 16);
|
2015-04-17 16:11:05 +00:00
|
|
|
case MVT::v1i128: return VectorType::get(Type::getInt128Ty(Context), 1);
|
2012-01-12 23:14:13 +00:00
|
|
|
case MVT::v2f16: return VectorType::get(Type::getHalfTy(Context), 2);
|
2013-10-03 03:29:21 +00:00
|
|
|
case MVT::v4f16: return VectorType::get(Type::getHalfTy(Context), 4);
|
2013-08-13 22:34:26 +00:00
|
|
|
case MVT::v8f16: return VectorType::get(Type::getHalfTy(Context), 8);
|
2013-09-24 02:47:27 +00:00
|
|
|
case MVT::v1f32: return VectorType::get(Type::getFloatTy(Context), 1);
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::v2f32: return VectorType::get(Type::getFloatTy(Context), 2);
|
|
|
|
case MVT::v4f32: return VectorType::get(Type::getFloatTy(Context), 4);
|
|
|
|
case MVT::v8f32: return VectorType::get(Type::getFloatTy(Context), 8);
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v16f32: return VectorType::get(Type::getFloatTy(Context), 16);
|
2013-09-24 02:47:27 +00:00
|
|
|
case MVT::v1f64: return VectorType::get(Type::getDoubleTy(Context), 1);
|
2009-08-13 21:58:54 +00:00
|
|
|
case MVT::v2f64: return VectorType::get(Type::getDoubleTy(Context), 2);
|
|
|
|
case MVT::v4f64: return VectorType::get(Type::getDoubleTy(Context), 4);
|
2012-12-24 10:03:57 +00:00
|
|
|
case MVT::v8f64: return VectorType::get(Type::getDoubleTy(Context), 8);
|
2009-08-28 23:24:31 +00:00
|
|
|
case MVT::Metadata: return Type::getMetadataTy(Context);
|
2009-06-29 16:47:10 +00:00
|
|
|
}
|
2005-01-15 06:52:40 +00:00
|
|
|
}
|
2007-03-31 04:03:02 +00:00
|
|
|
|
2012-12-19 15:19:11 +00:00
|
|
|
/// Return the value type corresponding to the specified type. This returns all
|
|
|
|
/// pointers as MVT::iPTR. If HandleUnknown is true, unknown types are returned
|
|
|
|
/// as Other, otherwise they are invalid.
|
|
|
|
MVT MVT::getVT(Type *Ty, bool HandleUnknown){
|
2007-03-31 04:03:02 +00:00
|
|
|
switch (Ty->getTypeID()) {
|
2007-04-28 05:38:52 +00:00
|
|
|
default:
|
2009-08-11 20:47:22 +00:00
|
|
|
if (HandleUnknown) return MVT(MVT::Other);
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("Unknown type!");
|
2007-03-31 04:03:02 +00:00
|
|
|
case Type::VoidTyID:
|
2009-08-12 00:36:31 +00:00
|
|
|
return MVT::isVoid;
|
2007-03-31 04:03:02 +00:00
|
|
|
case Type::IntegerTyID:
|
2012-12-19 15:19:11 +00:00
|
|
|
return getIntegerVT(cast<IntegerType>(Ty)->getBitWidth());
|
2011-12-20 00:02:33 +00:00
|
|
|
case Type::HalfTyID: return MVT(MVT::f16);
|
2009-08-11 20:47:22 +00:00
|
|
|
case Type::FloatTyID: return MVT(MVT::f32);
|
|
|
|
case Type::DoubleTyID: return MVT(MVT::f64);
|
|
|
|
case Type::X86_FP80TyID: return MVT(MVT::f80);
|
2010-09-15 00:52:23 +00:00
|
|
|
case Type::X86_MMXTyID: return MVT(MVT::x86mmx);
|
2009-08-11 20:47:22 +00:00
|
|
|
case Type::FP128TyID: return MVT(MVT::f128);
|
|
|
|
case Type::PPC_FP128TyID: return MVT(MVT::ppcf128);
|
|
|
|
case Type::PointerTyID: return MVT(MVT::iPTR);
|
2012-12-19 15:19:11 +00:00
|
|
|
case Type::VectorTyID: {
|
|
|
|
VectorType *VTy = cast<VectorType>(Ty);
|
|
|
|
return getVectorVT(
|
|
|
|
getVT(VTy->getElementType(), false), VTy->getNumElements());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getEVT - Return the value type corresponding to the specified type. This
|
|
|
|
/// returns all pointers as MVT::iPTR. If HandleUnknown is true, unknown types
|
|
|
|
/// are returned as Other, otherwise they are invalid.
|
|
|
|
EVT EVT::getEVT(Type *Ty, bool HandleUnknown){
|
|
|
|
switch (Ty->getTypeID()) {
|
|
|
|
default:
|
|
|
|
return MVT::getVT(Ty, HandleUnknown);
|
|
|
|
case Type::IntegerTyID:
|
|
|
|
return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth());
|
2007-06-25 16:23:39 +00:00
|
|
|
case Type::VectorTyID: {
|
2011-07-18 04:54:35 +00:00
|
|
|
VectorType *VTy = cast<VectorType>(Ty);
|
2009-08-12 00:36:31 +00:00
|
|
|
return getVectorVT(Ty->getContext(), getEVT(VTy->getElementType(), false),
|
2008-06-06 12:08:01 +00:00
|
|
|
VTy->getNumElements());
|
2007-06-25 16:23:39 +00:00
|
|
|
}
|
2007-03-31 04:03:02 +00:00
|
|
|
}
|
2009-07-14 06:06:28 +00:00
|
|
|
}
|