LLVM API Documentation
00001 //===-- ValueTypes.cpp - Implementation of MVT::ValueType methods ---------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements methods in the CodeGen/ValueTypes.h header. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "llvm/CodeGen/ValueTypes.h" 00015 #include "llvm/Type.h" 00016 using namespace llvm; 00017 00018 /// MVT::getValueTypeString - This function returns value type as a string, 00019 /// e.g. "i32". 00020 const char *MVT::getValueTypeString(MVT::ValueType VT) { 00021 switch (VT) { 00022 default: assert(0 && "Invalid ValueType!"); 00023 case MVT::i1: return "i1"; 00024 case MVT::i8: return "i8"; 00025 case MVT::i16: return "i16"; 00026 case MVT::i32: return "i32"; 00027 case MVT::i64: return "i64"; 00028 case MVT::i128: return "i128"; 00029 case MVT::f32: return "f32"; 00030 case MVT::f64: return "f64"; 00031 case MVT::f80: return "f80"; 00032 case MVT::f128: return "f128"; 00033 case MVT::isVoid:return "isVoid"; 00034 case MVT::Other: return "ch"; 00035 case MVT::Flag: return "flag"; 00036 case MVT::Vector:return "vec"; 00037 case MVT::v8i8: return "v8i8"; 00038 case MVT::v4i16: return "v4i16"; 00039 case MVT::v2i32: return "v2i32"; 00040 case MVT::v16i8: return "v16i8"; 00041 case MVT::v8i16: return "v8i16"; 00042 case MVT::v4i32: return "v4i32"; 00043 case MVT::v2i64: return "v2i64"; 00044 case MVT::v4f32: return "v4f32"; 00045 case MVT::v2f64: return "v2f64"; 00046 } 00047 } 00048 00049 /// MVT::getTypeForValueType - This method returns an LLVM type corresponding 00050 /// to the specified ValueType. For integer types, this returns an unsigned 00051 /// type. Note that this will abort for types that cannot be represented. 00052 const Type *MVT::getTypeForValueType(MVT::ValueType VT) { 00053 switch (VT) { 00054 default: assert(0 && "ValueType does not correspond to LLVM type!"); 00055 case MVT::isVoid:return Type::VoidTy; 00056 case MVT::i1: return Type::BoolTy; 00057 case MVT::i8: return Type::UByteTy; 00058 case MVT::i16: return Type::UShortTy; 00059 case MVT::i32: return Type::UIntTy; 00060 case MVT::i64: return Type::ULongTy; 00061 case MVT::f32: return Type::FloatTy; 00062 case MVT::f64: return Type::DoubleTy; 00063 } 00064 }