OLD | NEW |
---|---|
1 //===- subzero/src/IceTypes.h - Primitive ICE types -------------*- C++ -*-===// | 1 //===- subzero/src/IceTypes.h - Primitive ICE types -------------*- C++ -*-===// |
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 declares a few properties of the primitive types allowed | 10 // This file declares a few properties of the primitive types allowed |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 assert(result || Ty == IceType_f64); | 96 assert(result || Ty == IceType_f64); |
97 return result; | 97 return result; |
98 } | 98 } |
99 | 99 |
100 template <typename StreamType> | 100 template <typename StreamType> |
101 inline StreamType &operator<<(StreamType &Str, const Type &Ty) { | 101 inline StreamType &operator<<(StreamType &Str, const Type &Ty) { |
102 Str << typeString(Ty); | 102 Str << typeString(Ty); |
103 return Str; | 103 return Str; |
104 } | 104 } |
105 | 105 |
106 /// Models a type signature for a function. | |
107 /// TODO(kschimpf): Consider using arena memory allocation for | |
108 /// the contents of type signatures. | |
109 class FuncSigType { | |
110 public: | |
111 typedef std::vector<Type> ArgListType; | |
112 | |
113 // Creates a function signature type with the given return type. | |
114 // Parameter types should be added using calls to appendArgType. | |
115 explicit FuncSigType() : ReturnType(IceType_void) {} | |
116 | |
117 FuncSigType(const FuncSigType &Ty) | |
118 : ReturnType(Ty.ReturnType), ArgList(Ty.ArgList) {} | |
119 | |
120 FuncSigType &operator=(const FuncSigType &Ty) { | |
121 ReturnType = Ty.ReturnType; | |
122 ArgList = Ty.ArgList; | |
123 return *this; | |
124 } | |
125 | |
126 void appendArgType(Type ArgType) { ArgList.push_back(ArgType); } | |
127 | |
128 Type getReturnType() const { return ReturnType; } | |
129 void setReturnType(Type NewType) { ReturnType = NewType; } | |
130 SizeT getNumArgs() const { return ArgList.size(); } | |
131 Type getArgType(SizeT Index) const { | |
132 assert(Index < ArgList.size()); | |
133 return ArgList[Index]; | |
134 } | |
135 const ArgListType &getArgList() const { return ArgList; } | |
136 void Dump(Ostream &Stream) const; | |
Jim Stichnoth
2014/10/06 22:48:51
lowercase dump
Karl
2014/10/07 20:15:58
Done.
| |
137 void reset() { | |
138 ArgList.clear(); | |
139 ArgList.push_back(IceType_void); | |
140 } | |
141 | |
142 private: | |
143 // The return type. | |
144 Type ReturnType; | |
145 // The list of parameters. | |
146 ArgListType ArgList; | |
147 }; | |
148 | |
149 inline Ostream &operator<<(Ostream &Stream, const FuncSigType &Sig) { | |
150 Sig.Dump(Stream); | |
151 return Stream; | |
152 } | |
153 | |
106 } // end of namespace Ice | 154 } // end of namespace Ice |
107 | 155 |
108 #endif // SUBZERO_SRC_ICETYPES_H | 156 #endif // SUBZERO_SRC_ICETYPES_H |
OLD | NEW |