1 //===- ValueTypes.cpp - Tablegen extended ValueType implementation --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // The EVT type is used by tablegen as well as in LLVM. In order to handle
11 // extended types, the EVT type uses support functions that call into
12 // LLVM's type system code. These aren't accessible in tablegen, so this
13 // file provides simple replacements.
15 //===----------------------------------------------------------------------===//
17 #include "llvm/CodeGen/ValueTypes.h"
25 virtual unsigned getSizeInBits() const = 0;
31 class ExtendedIntegerType
: public Type
{
34 explicit ExtendedIntegerType(unsigned bits
)
36 unsigned getSizeInBits() const {
39 unsigned getBitWidth() const {
44 class ExtendedVectorType
: public Type
{
48 ExtendedVectorType(EVT elty
, unsigned num
)
49 : ElementType(elty
), NumElements(num
) {}
50 unsigned getSizeInBits() const {
51 return getNumElements() * getElementType().getSizeInBits();
53 EVT
getElementType() const {
56 unsigned getNumElements() const {
61 static std::map
<unsigned, const Type
*>
62 ExtendedIntegerTypeMap
;
63 static std::map
<std::pair
<uintptr_t, uintptr_t>, const Type
*>
64 ExtendedVectorTypeMap
;
66 bool EVT::isExtendedFloatingPoint() const {
67 assert(isExtended() && "Type is not extended!");
68 // Extended floating-point types are not supported yet.
72 bool EVT::isExtendedInteger() const {
73 assert(isExtended() && "Type is not extended!");
74 return dynamic_cast<const ExtendedIntegerType
*>(LLVMTy
) != 0;
77 bool EVT::isExtendedVector() const {
78 assert(isExtended() && "Type is not extended!");
79 return dynamic_cast<const ExtendedVectorType
*>(LLVMTy
) != 0;
82 bool EVT::isExtended64BitVector() const {
83 assert(isExtended() && "Type is not extended!");
84 return isExtendedVector() && getSizeInBits() == 64;
87 bool EVT::isExtended128BitVector() const {
88 assert(isExtended() && "Type is not extended!");
89 return isExtendedVector() && getSizeInBits() == 128;
92 EVT
EVT::getExtendedVectorElementType() const {
93 assert(isExtendedVector() && "Type is not an extended vector!");
94 return static_cast<const ExtendedVectorType
*>(LLVMTy
)->getElementType();
97 unsigned EVT::getExtendedVectorNumElements() const {
98 assert(isExtendedVector() && "Type is not an extended vector!");
99 return static_cast<const ExtendedVectorType
*>(LLVMTy
)->getNumElements();
102 unsigned EVT::getExtendedSizeInBits() const {
103 assert(isExtended() && "Type is not extended!");
104 return LLVMTy
->getSizeInBits();