llvm.org GIT mirror llvm / 8b43dbf
tblgen: Move mini Type hierarchy to LLVM-style RTTI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165648 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Silva 7 years ago
1 changed file(s) with 22 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1414 //===----------------------------------------------------------------------===//
1515
1616 #include "llvm/CodeGen/ValueTypes.h"
17 #include "llvm/Support/Casting.h"
1718 #include
1819 using namespace llvm;
1920
2021 namespace llvm {
2122
2223 class Type {
24 protected:
25 enum TypeKind {
26 TK_ExtendedIntegerType,
27 TK_ExtendedVectorType
28 };
29 private:
30 TypeKind Kind;
2331 public:
32 TypeKind getKind() const {
33 return Kind;
34 }
35 Type(TypeKind K) : Kind(K) {}
2436 virtual unsigned getSizeInBits() const = 0;
2537 virtual ~Type() {}
2638 };
3143 unsigned BitWidth;
3244 public:
3345 explicit ExtendedIntegerType(unsigned bits)
34 : BitWidth(bits) {}
46 : Type(TK_ExtendedIntegerType), BitWidth(bits) {}
47 static bool classof(const Type *T) {
48 return T->getKind() == TK_ExtendedIntegerType;
49 };
3550 unsigned getSizeInBits() const {
3651 return getBitWidth();
3752 }
4560 unsigned NumElements;
4661 public:
4762 ExtendedVectorType(EVT elty, unsigned num)
48 : ElementType(elty), NumElements(num) {}
63 : Type(TK_ExtendedVectorType), ElementType(elty), NumElements(num) {}
64 static bool classof(const Type *T) {
65 return T->getKind() == TK_ExtendedVectorType;
66 };
4967 unsigned getSizeInBits() const {
5068 return getNumElements() * getElementType().getSizeInBits();
5169 }
7088
7189 bool EVT::isExtendedInteger() const {
7290 assert(isExtended() && "Type is not extended!");
73 return dynamic_cast(LLVMTy) != 0;
91 return isa(LLVMTy);
7492 }
7593
7694 bool EVT::isExtendedVector() const {
7795 assert(isExtended() && "Type is not extended!");
78 return dynamic_cast(LLVMTy) != 0;
96 return isa(LLVMTy);
7997 }
8098
8199 bool EVT::isExtended64BitVector() const {