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

Side by Side Diff: src/IceIntrinsics.cpp

Issue 1017453007: Subzero: Support non sequentially consistent memory orderings for atomic ops. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More code review cleanup Created 5 years, 9 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 | « src/IceIntrinsics.h ('k') | src/IceTargetLoweringX8632.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.cpp - Functions related to intrinsics ----===// 1 //===- subzero/src/IceIntrinsics.cpp - Functions related to intrinsics ----===//
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 implements the Intrinsics utilities for matching and 10 // This file implements the Intrinsics utilities for matching and
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return nullptr; 226 return nullptr;
227 IceString NameSuffix = Name.substr(LLVMPrefixLen); 227 IceString NameSuffix = Name.substr(LLVMPrefixLen);
228 auto it = Map.find(NameSuffix); 228 auto it = Map.find(NameSuffix);
229 if (it == Map.end()) { 229 if (it == Map.end()) {
230 Error = true; 230 Error = true;
231 return nullptr; 231 return nullptr;
232 } 232 }
233 return &it->second; 233 return &it->second;
234 } 234 }
235 235
236 bool Intrinsics::VerifyMemoryOrder(uint64_t Order) { 236 namespace {
237 // There is only one memory ordering for atomics allowed right now. 237
238 return Order == Intrinsics::MemoryOrderSequentiallyConsistent; 238 // Returns whether PNaCl allows the given memory ordering in general.
239 bool isMemoryOrderValidPNaCl(uint64_t Order) {
240 switch (Order) {
241 case Intrinsics::MemoryOrderAcquire:
242 case Intrinsics::MemoryOrderRelease:
243 case Intrinsics::MemoryOrderAcquireRelease:
244 case Intrinsics::MemoryOrderSequentiallyConsistent:
245 return true;
246 default:
247 return false;
248 }
249 }
250
251 } // end of anonymous namespace
252
253 bool Intrinsics::isMemoryOrderValid(IntrinsicID ID, uint64_t Order,
254 uint64_t OrderOther) {
255 // Reject orderings not allowed in PNaCl.
256 if (!isMemoryOrderValidPNaCl(Order))
257 return false;
258 if (ID == AtomicCmpxchg && !isMemoryOrderValidPNaCl(OrderOther))
259 return false;
260 // Reject orderings not allowed by C++11.
261 switch (ID) {
262 default:
263 llvm_unreachable("isMemoryOrderValid: Unknown IntrinsicID");
264 return false;
265 case AtomicFence:
266 case AtomicFenceAll:
267 case AtomicRMW:
268 return true;
269 case AtomicCmpxchg:
270 // Reject orderings that are disallowed by C++11 as invalid
271 // combinations for cmpxchg.
272 switch (OrderOther) {
273 case MemoryOrderRelaxed:
274 case MemoryOrderConsume:
275 case MemoryOrderAcquire:
276 case MemoryOrderSequentiallyConsistent:
277 if (OrderOther > Order)
278 return false;
279 if (Order == MemoryOrderRelease && OrderOther != MemoryOrderRelaxed)
280 return false;
281 return true;
282 default:
283 return false;
284 }
285 case AtomicLoad:
286 switch (Order) {
287 case MemoryOrderRelease:
288 case MemoryOrderAcquireRelease:
289 return false;
290 default:
291 return true;
292 }
293 case AtomicStore:
294 switch (Order) {
295 case MemoryOrderConsume:
296 case MemoryOrderAcquire:
297 case MemoryOrderAcquireRelease:
298 return false;
299 default:
300 return true;
301 }
302 }
239 } 303 }
240 304
241 Intrinsics::ValidateCallValue 305 Intrinsics::ValidateCallValue
242 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, 306 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call,
243 SizeT &ArgIndex) const { 307 SizeT &ArgIndex) const {
244 assert(NumTypes >= 1); 308 assert(NumTypes >= 1);
245 Variable *Result = Call->getDest(); 309 Variable *Result = Call->getDest();
246 if (Result == nullptr) { 310 if (Result == nullptr) {
247 if (Signature[0] != Ice::IceType_void) 311 if (Signature[0] != Ice::IceType_void)
248 return Intrinsics::BadReturnType; 312 return Intrinsics::BadReturnType;
(...skipping 12 matching lines...) Expand all
261 return Intrinsics::IsValidCall; 325 return Intrinsics::IsValidCall;
262 } 326 }
263 327
264 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { 328 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const {
265 assert(NumTypes > 1); 329 assert(NumTypes > 1);
266 assert(Index + 1 < NumTypes); 330 assert(Index + 1 < NumTypes);
267 return Signature[Index + 1]; 331 return Signature[Index + 1];
268 } 332 }
269 333
270 } // end of namespace Ice 334 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceIntrinsics.h ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698