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

Side by Side Diff: src/IceIntrinsics.h

Issue 1347683002: Subzero: Fix off-by-one asserts in intrinsic info lookup routines. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add real uses of getReturnType() and getNumArgs() Created 5 years, 3 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
« no previous file with comments | « no previous file | src/IceIntrinsics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceIntrinsics.h - List of Ice Intrinsics -----*- C++ -*-===// 1 //===- subzero/src/IceIntrinsics.h - List of Ice Intrinsics -----*- 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 /// \file 10 /// \file
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 uint8_t NumTypes; 133 uint8_t NumTypes;
134 134
135 /// Validates that type signature of call matches intrinsic. 135 /// Validates that type signature of call matches intrinsic.
136 /// If WrongArgumentType is returned, ArgIndex is set to corresponding 136 /// If WrongArgumentType is returned, ArgIndex is set to corresponding
137 /// argument index. 137 /// argument index.
138 ValidateCallValue validateCall(const Ice::InstCall *Call, 138 ValidateCallValue validateCall(const Ice::InstCall *Call,
139 SizeT &ArgIndex) const; 139 SizeT &ArgIndex) const;
140 140
141 /// Returns the return type of the intrinsic. 141 /// Returns the return type of the intrinsic.
142 Type getReturnType() const { 142 Type getReturnType() const {
143 assert(NumTypes > 1); 143 assert(NumTypes > 0);
144 return Signature[0]; 144 return Signature[0];
145 } 145 }
146 146
147 /// Returns number of arguments expected. 147 /// Returns number of arguments expected.
148 SizeT getNumArgs() const { 148 SizeT getNumArgs() const {
149 assert(NumTypes > 1); 149 assert(NumTypes > 0);
150 return NumTypes - 1; 150 return NumTypes - 1;
151 } 151 }
152 152
153 /// Returns type of Index-th argument. 153 /// Returns type of Index-th argument.
154 Type getArgType(SizeT Index) const; 154 Type getArgType(SizeT Index) const;
155 }; 155 };
156 156
157 /// Find the information about a given intrinsic, based on function name. If 157 /// Find the information about a given intrinsic, based on function name. If
158 /// the function name does not have the common "llvm." prefix, nullptr is 158 /// the function name does not have the common "llvm." prefix, nullptr is
159 /// returned and Error is set to false. Otherwise, tries to find a reference 159 /// returned and Error is set to false. Otherwise, tries to find a reference
160 /// to a FullIntrinsicInfo entry (valid for the lifetime of the map). If 160 /// to a FullIntrinsicInfo entry (valid for the lifetime of the map). If
161 /// found, sets Error to false and returns the reference. If not found, sets 161 /// found, sets Error to false and returns the reference. If not found, sets
162 /// Error to true and returns nullptr (indicating an unknown "llvm.foo" 162 /// Error to true and returns nullptr (indicating an unknown "llvm.foo"
163 /// intrinsic). 163 /// intrinsic).
164 const FullIntrinsicInfo *find(const IceString &Name, bool &Error) const; 164 const FullIntrinsicInfo *find(const IceString &Name, bool &Error) const;
165 165
166 private: 166 private:
167 // TODO(jvoung): May want to switch to something like LLVM's StringMap. 167 // TODO(jvoung): May want to switch to something like LLVM's StringMap.
168 using IntrinsicMap = std::map<IceString, FullIntrinsicInfo>; 168 using IntrinsicMap = std::map<IceString, FullIntrinsicInfo>;
169 IntrinsicMap Map; 169 IntrinsicMap Map;
170 }; 170 };
171 171
172 } // end of namespace Ice 172 } // end of namespace Ice
173 173
174 #endif // SUBZERO_SRC_ICEINTRINSICS_H 174 #endif // SUBZERO_SRC_ICEINTRINSICS_H
OLDNEW
« no previous file with comments | « no previous file | src/IceIntrinsics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698