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"
21 #pragma clang diagnostic push
22 #pragma clang diagnostic ignored "-Wweak-vtables"
28 virtual unsigned getSizeInBits() const = 0;
34 class ExtendedIntegerType : public Type {
37 explicit ExtendedIntegerType(unsigned bits)
39 unsigned getSizeInBits() const {
42 unsigned getBitWidth() const {
47 class ExtendedVectorType : public Type {
51 ExtendedVectorType(EVT elty, unsigned num)
52 : ElementType(elty), NumElements(num) {}
53 unsigned getSizeInBits() const {
54 return getNumElements() * getElementType().getSizeInBits();
56 EVT getElementType() const {
59 unsigned getNumElements() const {
64 #pragma clang diagnostic pop
66 static std::map<unsigned, const Type *>
67 ExtendedIntegerTypeMap;
68 static std::map<std::pair<uintptr_t, uintptr_t>, const Type *>
69 ExtendedVectorTypeMap;
71 bool EVT::isExtendedFloatingPoint() const {
72 assert(isExtended() && "Type is not extended!");
73 // Extended floating-point types are not supported yet.
77 bool EVT::isExtendedInteger() const {
78 assert(isExtended() && "Type is not extended!");
79 return dynamic_cast<const ExtendedIntegerType *>(LLVMTy) != 0;
82 bool EVT::isExtendedVector() const {
83 assert(isExtended() && "Type is not extended!");
84 return dynamic_cast<const ExtendedVectorType *>(LLVMTy) != 0;
87 bool EVT::isExtended64BitVector() const {
88 assert(isExtended() && "Type is not extended!");
89 return isExtendedVector() && getSizeInBits() == 64;
92 bool EVT::isExtended128BitVector() const {
93 assert(isExtended() && "Type is not extended!");
94 return isExtendedVector() && getSizeInBits() == 128;
97 EVT EVT::getExtendedVectorElementType() const {
98 assert(isExtendedVector() && "Type is not an extended vector!");
99 return static_cast<const ExtendedVectorType *>(LLVMTy)->getElementType();
102 unsigned EVT::getExtendedVectorNumElements() const {
103 assert(isExtendedVector() && "Type is not an extended vector!");
104 return static_cast<const ExtendedVectorType *>(LLVMTy)->getNumElements();
107 unsigned EVT::getExtendedSizeInBits() const {
108 assert(isExtended() && "Type is not extended!");
109 return LLVMTy->getSizeInBits();