1 //===-- ValueTypes.cpp - Implementation of MVT::ValueType methods ---------===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file implements methods in the CodeGen/ValueTypes.h header.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/ValueTypes.h"
15 #include "llvm/Type.h"
18 /// MVT::getValueTypeString - This function returns value type as a string,
20 const char *MVT::getValueTypeString(MVT::ValueType 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 case MVT::Flag: return "flag";
39 /// MVT::getTypeForValueType - This method returns an LLVM type corresponding
40 /// to the specified ValueType. For integer types, this returns an unsigned
41 /// type. Note that this will abort for types that cannot be represented.
42 const Type *MVT::getTypeForValueType(MVT::ValueType VT) {
44 default: assert(0 && "ValueType does not correspond to LLVM type!");
45 case MVT::isVoid:return Type::VoidTy;
46 case MVT::i1: return Type::BoolTy;
47 case MVT::i8: return Type::UByteTy;
48 case MVT::i16: return Type::UShortTy;
49 case MVT::i32: return Type::UIntTy;
50 case MVT::i64: return Type::ULongTy;
51 case MVT::f32: return Type::FloatTy;
52 case MVT::f64: return Type::DoubleTy;