Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: src/IceTypes.cpp

Issue 395193005: Start processing function blocks in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Run format-diff Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceTypes.cpp - Primitive type properties ---------------===// 1 //===- subzero/src/IceTypes.cpp - Primitive type properties ---------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file defines a few attributes of Subzero primitive types. 10 // This file defines a few attributes of Subzero primitive types.
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 #include "IceDefs.h" 14 #include "IceDefs.h"
15 #include "IceTypes.h" 15 #include "IceTypes.h"
16 16
17 namespace Ice { 17 namespace Ice {
18 18
19 namespace { 19 namespace {
20 20
21 const struct { 21 const struct {
22 size_t TypeWidthInBytes; 22 size_t TypeWidthInBytes;
23 size_t TypeAlignInBytes; 23 size_t TypeAlignInBytes;
24 size_t TypeNumElements; 24 size_t TypeNumElements;
25 Type TypeElementType; 25 Type TypeElementType;
26 const char *DisplayString; 26 const char *DisplayString;
27 uint32_t TypeFlags;
27 } TypeAttributes[] = { 28 } TypeAttributes[] = {
28 #define X(tag, size, align, elts, elty, str) \ 29 #define X(tag, size, align, elts, elty, str, flags) \
29 { size, align, elts, elty, str } \ 30 { size, align, elts, elty, str, flags } \
30 , 31 ,
31 ICETYPE_TABLE 32 ICETYPE_TABLE
32 #undef X 33 #undef X
33 }; 34 };
34 35
35 const size_t TypeAttributesSize = 36 const size_t TypeAttributesSize =
36 sizeof(TypeAttributes) / sizeof(*TypeAttributes); 37 sizeof(TypeAttributes) / sizeof(*TypeAttributes);
37 38
38 } // end anonymous namespace 39 } // end anonymous namespace
39 40
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 Type ElementType = IceType_void; 75 Type ElementType = IceType_void;
75 size_t Index = static_cast<size_t>(Ty); 76 size_t Index = static_cast<size_t>(Ty);
76 if (Index < TypeAttributesSize) { 77 if (Index < TypeAttributesSize) {
77 ElementType = TypeAttributes[Index].TypeElementType; 78 ElementType = TypeAttributes[Index].TypeElementType;
78 } else { 79 } else {
79 llvm_unreachable("Invalid type for typeElementType()"); 80 llvm_unreachable("Invalid type for typeElementType()");
80 } 81 }
81 return ElementType; 82 return ElementType;
82 } 83 }
83 84
85 bool isIntegerType(Type Ty) {
86 size_t Index = static_cast<size_t>(Ty);
87 if (Index < TypeAttributesSize)
88 return TypeAttributes[Index].TypeFlags == TypeFlagIsInteger;
89 llvm_unreachable("Invalid type for typeIsInteger()");
90 }
91
92 bool isFloatingType(Type Ty) {
93 size_t Index = static_cast<size_t>(Ty);
94 if (Index < TypeAttributesSize)
95 return TypeAttributes[Index].TypeFlags == TypeFlagIsFloating;
96 llvm_unreachable("Invalid type for typeIsFloating()");
97 }
98
84 // ======================== Dump routines ======================== // 99 // ======================== Dump routines ======================== //
85 100
86 template <> Ostream &operator<<(Ostream &Str, const Type &Ty) { 101 Ostream &operator<<(Ostream &Str, const Type &Ty) {
87 size_t Index = static_cast<size_t>(Ty); 102 size_t Index = static_cast<size_t>(Ty);
88 if (Index < TypeAttributesSize) { 103 if (Index < TypeAttributesSize) {
89 Str << TypeAttributes[Index].DisplayString; 104 Str << TypeAttributes[Index].DisplayString;
90 } else { 105 } else {
91 Str << "???"; 106 Str << "???";
92 llvm_unreachable("Invalid type for printing"); 107 llvm_unreachable("Invalid type for printing");
93 } 108 }
94 109
95 return Str; 110 return Str;
96 } 111 }
97 112
98 } // end of namespace Ice 113 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698