1 //===-- ValueTypes.cpp - Implementation of MVT::ValueType methods ---------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file was developed by the LLVM research group and is distributed under 6 // the University of Illinois Open Source License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file implements methods in the CodeGen/ValueTypes.h header. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "llvm/CodeGen/ValueTypes.h" 15 #include "llvm/Type.h" 16 using namespace llvm; 17 18 /// MVT::getValueTypeString - This function returns value type as a string, 19 /// e.g. "i32". 20 const char *MVT::getValueTypeString(MVT::ValueType VT) { 21 switch (VT) { 22 default: assert(0 && "Invalid ValueType!"); 23 case MVT::i1: return "i1"; 24 case MVT::i8: return "i8"; 25 case MVT::i16: return "i16"; 26 case MVT::i32: return "i32"; 27 case MVT::i64: return "i64"; 28 case MVT::i128: return "i128"; 29 case MVT::f32: return "f32"; 30 case MVT::f64: return "f64"; 31 case MVT::f80: return "f80"; 32 case MVT::f128: return "f128"; 33 case MVT::isVoid:return "isVoid"; 34 case MVT::Other: return "ch"; 35 } 36 } 37 38 /// MVT::getTypeForValueType - This method returns an LLVM type corresponding 39 /// to the specified ValueType. For integer types, this returns an unsigned 40 /// type. Note that this will abort for types that cannot be represented. 41 const Type *MVT::getTypeForValueType(MVT::ValueType VT) { 42 switch (VT) { 43 default: assert(0 && "ValueType does not correspond to LLVM type!"); 44 case MVT::isVoid:return Type::VoidTy; 45 case MVT::i1: return Type::BoolTy; 46 case MVT::i8: return Type::UByteTy; 47 case MVT::i16: return Type::UShortTy; 48 case MVT::i32: return Type::UIntTy; 49 case MVT::i64: return Type::ULongTy; 50 case MVT::f32: return Type::FloatTy; 51 case MVT::f64: return Type::DoubleTy; 52 } 53 } 54