OLD | NEW |
---|---|
(Empty) | |
1 //===- subzero/src/IceTypes.cpp - Primitive type properties ---------------===// | |
2 // | |
3 // The Subzero Code Generator | |
4 // | |
5 // This file is distributed under the University of Illinois Open Source | |
6 // License. See LICENSE.TXT for details. | |
7 // | |
8 //===----------------------------------------------------------------------===// | |
9 // | |
10 // This file defines a few attributes of Subzero primitive types. | |
11 // | |
12 //===----------------------------------------------------------------------===// | |
13 | |
14 #include "IceDefs.h" | |
15 #include "IceTypes.h" | |
16 | |
17 uint32_t iceTypeWidth(IceType T) { | |
18 switch (T) { | |
19 case IceType_i1: | |
20 return 1; | |
21 case IceType_i8: | |
22 return 1; | |
23 case IceType_i16: | |
24 return 2; | |
25 case IceType_i32: | |
26 return 4; | |
27 case IceType_i64: | |
28 return 8; | |
29 case IceType_f32: | |
30 return 4; | |
31 case IceType_f64: | |
32 return 8; | |
33 case IceType_void: | |
34 case IceType_NUM: | |
35 break; | |
JF
2014/04/04 04:05:26
This would be a great use of xmacros. Put the enum
Jim Stichnoth
2014/04/06 02:16:09
Done, but using tables instead for now. (I can ch
| |
36 } | |
37 assert(0 && "Invalid type for iceTypeWidth()"); | |
38 return 0; | |
39 } | |
40 | |
41 // ======================== Dump routines ======================== // | |
42 | |
43 IceOstream &operator<<(IceOstream &Str, IceType T) { | |
44 switch (T) { | |
45 case IceType_void: | |
46 Str << "void"; | |
47 return Str; | |
48 case IceType_i1: | |
49 Str << "i1"; | |
50 return Str; | |
51 case IceType_i8: | |
52 Str << "i8"; | |
53 return Str; | |
54 case IceType_i16: | |
55 Str << "i16"; | |
56 return Str; | |
57 case IceType_i32: | |
58 Str << "i32"; | |
59 return Str; | |
60 case IceType_i64: | |
61 Str << "i64"; | |
62 return Str; | |
63 case IceType_f32: | |
64 Str << "float"; | |
65 return Str; | |
66 case IceType_f64: | |
67 Str << "double"; | |
68 return Str; | |
69 case IceType_NUM: | |
70 default: | |
71 assert(0 && "Invalid type for printing"); | |
72 break; | |
73 } | |
74 Str << "???"; | |
75 return Str; | |
76 } | |
OLD | NEW |