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";
36 case MVT::Vector:return "vec";
37 case MVT::v8i8: return "v8i8";
38 case MVT::v4i16: return "v4i16";
39 case MVT::v2i32: return "v2i32";
40 case MVT::v16i8: return "v16i8";
41 case MVT::v8i16: return "v8i16";
42 case MVT::v4i32: return "v4i32";
43 case MVT::v2i64: return "v2i64";
44 case MVT::v4f32: return "v4f32";
45 case MVT::v2f64: return "v2f64";
49 /// MVT::getTypeForValueType - This method returns an LLVM type corresponding
50 /// to the specified ValueType. For integer types, this returns an unsigned
51 /// type. Note that this will abort for types that cannot be represented.
52 const Type *MVT::getTypeForValueType(MVT::ValueType VT) {
54 default: assert(0 && "ValueType does not correspond to LLVM type!");
55 case MVT::isVoid:return Type::VoidTy;
56 case MVT::i1: return Type::BoolTy;
57 case MVT::i8: return Type::UByteTy;
58 case MVT::i16: return Type::UShortTy;
59 case MVT::i32: return Type::UIntTy;
60 case MVT::i64: return Type::ULongTy;
61 case MVT::f32: return Type::FloatTy;
62 case MVT::f64: return Type::DoubleTy;