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...) 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 // FuncSigType(const FuncSigType &Ty) = delete; |
| 111 FuncSigType &operator=(const FuncSigType &Ty) = delete; |
| 112 public: |
| 113 typedef std::vector<Type> ArgListType; |
| 114 |
| 115 // Creates a function signature type with the given return type. |
| 116 // Parameter types should be added using calls to appendArgType. |
| 117 FuncSigType() : ReturnType(IceType_void) {} |
| 118 |
| 119 void appendArgType(Type ArgType) { ArgList.push_back(ArgType); } |
| 120 |
| 121 Type getReturnType() const { return ReturnType; } |
| 122 void setReturnType(Type NewType) { ReturnType = NewType; } |
| 123 SizeT getNumArgs() const { return ArgList.size(); } |
| 124 Type getArgType(SizeT Index) const { |
| 125 assert(Index < ArgList.size()); |
| 126 return ArgList[Index]; |
| 127 } |
| 128 const ArgListType &getArgList() const { return ArgList; } |
| 129 void dump(Ostream &Stream) const; |
| 130 |
| 131 private: |
| 132 // The return type. |
| 133 Type ReturnType; |
| 134 // The list of parameters. |
| 135 ArgListType ArgList; |
| 136 }; |
| 137 |
| 138 inline Ostream &operator<<(Ostream &Stream, const FuncSigType &Sig) { |
| 139 Sig.dump(Stream); |
| 140 return Stream; |
| 141 } |
| 142 |
106 } // end of namespace Ice | 143 } // end of namespace Ice |
107 | 144 |
108 #endif // SUBZERO_SRC_ICETYPES_H | 145 #endif // SUBZERO_SRC_ICETYPES_H |
OLD | NEW |