- /// This is fixed by the LLVM operations except for the pointer size.
- MVT::ValueType getValueType(const Type *Ty) const {
- switch (Ty->getTypeID()) {
- default: assert(0 && "Unknown type!");
- case Type::VoidTyID: return MVT::isVoid;
- case Type::IntegerTyID:
- switch (cast<IntegerType>(Ty)->getBitWidth()) {
- default: assert(0 && "Invalid width for value type");
- case 1: return MVT::i1;
- case 8: return MVT::i8;
- case 16: return MVT::i16;
- case 32: return MVT::i32;
- case 64: return MVT::i64;
- }
- break;
- case Type::FloatTyID: return MVT::f32;
- case Type::DoubleTyID: return MVT::f64;
- case Type::PointerTyID: return PointerTy;
- case Type::PackedTyID: return MVT::Vector;
+ /// This is fixed by the LLVM operations except for the pointer size. If
+ /// AllowUnknown is true, this will return MVT::Other for types with no MVT
+ /// counterpart (e.g. structs), otherwise it will assert.
+ MVT::ValueType getValueType(const Type *Ty, bool AllowUnknown = false) const {
+ MVT::ValueType VT = MVT::getValueType(Ty, AllowUnknown);
+ return VT == MVT::iPTR ? PointerTy : VT;
+ }
+
+ /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
+ /// function arguments in the caller parameter area.
+ virtual unsigned getByValTypeAlignment(const Type *Ty) const;
+
+ /// getRegisterType - Return the type of registers that this ValueType will
+ /// eventually require.
+ MVT::ValueType getRegisterType(MVT::ValueType VT) const {
+ if (!MVT::isExtendedVT(VT)) {
+ assert(VT < array_lengthof(RegisterTypeForVT));
+ return RegisterTypeForVT[VT];
+ }
+ if (MVT::isVector(VT)) {
+ MVT::ValueType VT1, RegisterVT;
+ unsigned NumIntermediates;
+ (void)getVectorTypeBreakdown(VT, VT1, NumIntermediates, RegisterVT);
+ return RegisterVT;