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"
26 virtual unsigned getSizeInBits() const = 0;
32 class ExtendedIntegerType : public Type {
35 explicit ExtendedIntegerType(unsigned bits)
37 unsigned getSizeInBits() const {
40 unsigned getBitWidth() const {
45 class ExtendedVectorType : public Type {
49 ExtendedVectorType(EVT elty, unsigned num)
50 : ElementType(elty), NumElements(num) {}
51 unsigned getSizeInBits() const {
52 return getNumElements() * getElementType().getSizeInBits();
54 EVT getElementType() const {
57 unsigned getNumElements() const {
62 static std::map<unsigned, const Type *>
63 ExtendedIntegerTypeMap;
64 static std::map<std::pair<uintptr_t, uintptr_t>, const Type *>
65 ExtendedVectorTypeMap;
67 bool EVT::isExtendedFloatingPoint() const {
68 assert(isExtended() && "Type is not extended!");
69 // Extended floating-point types are not supported yet.
73 bool EVT::isExtendedInteger() const {
74 assert(isExtended() && "Type is not extended!");
75 return dynamic_cast<const ExtendedIntegerType *>(LLVMTy) != 0;
78 bool EVT::isExtendedVector() const {
79 assert(isExtended() && "Type is not extended!");
80 return dynamic_cast<const ExtendedVectorType *>(LLVMTy) != 0;
83 bool EVT::isExtended64BitVector() const {
84 assert(isExtended() && "Type is not extended!");
85 return isExtendedVector() && getSizeInBits() == 64;
88 bool EVT::isExtended128BitVector() const {
89 assert(isExtended() && "Type is not extended!");
90 return isExtendedVector() && getSizeInBits() == 128;
93 EVT EVT::getExtendedVectorElementType() const {
94 assert(isExtendedVector() && "Type is not an extended vector!");
95 return static_cast<const ExtendedVectorType *>(LLVMTy)->getElementType();
98 unsigned EVT::getExtendedVectorNumElements() const {
99 assert(isExtendedVector() && "Type is not an extended vector!");
100 return static_cast<const ExtendedVectorType *>(LLVMTy)->getNumElements();
103 unsigned EVT::getExtendedSizeInBits() const {
104 assert(isExtended() && "Type is not extended!");
105 return LLVMTy->getSizeInBits();