diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-15 06:52:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-15 06:52:40 +0000 |
commit | 57bf3287dd15a26073be4dae2204463264328e44 (patch) | |
tree | e59462dd8e7d49e243f97080c770c6d7a3ae4f0a | |
parent | 3e68b418725c22db792384652425b75e56b4de3c (diff) | |
download | external_llvm-57bf3287dd15a26073be4dae2204463264328e44.zip external_llvm-57bf3287dd15a26073be4dae2204463264328e44.tar.gz external_llvm-57bf3287dd15a26073be4dae2204463264328e44.tar.bz2 |
implement these methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19571 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/ValueTypes.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/VMCore/ValueTypes.cpp b/lib/VMCore/ValueTypes.cpp new file mode 100644 index 0000000..b11df34 --- /dev/null +++ b/lib/VMCore/ValueTypes.cpp @@ -0,0 +1,52 @@ +//===-- ValueTypes.cpp - Implementation of MVT::ValueType methods ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements methods in the CodeGen/ValueTypes.h header. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/ValueTypes.h" +#include "llvm/Type.h" +using namespace llvm; + +/// MVT::getValueTypeString - This function returns value type as a string, +/// e.g. "i32". +const char *MVT::getValueTypeString(MVT::ValueType VT) { + switch (VT) { + default: assert(0 && "Invalid ValueType!"); + case MVT::i1: return "i1"; + case MVT::i8: return "i8"; + case MVT::i16: return "i16"; + case MVT::i32: return "i32"; + case MVT::i64: return "i64"; + case MVT::i128: return "i128"; + case MVT::f32: return "f32"; + case MVT::f64: return "f64"; + case MVT::f80: return "f80"; + case MVT::f128: return "f128"; + case MVT::Other: return "ch"; + } +} + +/// MVT::getTypeForValueType - This method returns an LLVM type corresponding +/// to the specified ValueType. For integer types, this returns an unsigned +/// type. Note that this will abort for types that cannot be represented. +const Type *MVT::getTypeForValueType(MVT::ValueType VT) { + switch (VT) { + default: assert(0 && "ValueType does not correspond to LLVM type!"); + case MVT::isVoid:return Type::VoidTy; + case MVT::i1: return Type::BoolTy; + case MVT::i8: return Type::UByteTy; + case MVT::i16: return Type::UShortTy; + case MVT::i32: return Type::UIntTy; + case MVT::i64: return Type::ULongTy; + case MVT::f32: return Type::FloatTy; + case MVT::f64: return Type::DoubleTy; + } +} |