Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 bool Intrinsics::isMemoryOrderValid(IntrinsicID ID, uint64_t Order, |
| 237 // There is only one memory ordering for atomics allowed right now. | 237 uint64_t OrderOther) { |
| 238 return Order == Intrinsics::MemoryOrderSequentiallyConsistent; | 238 // Reject orderings not allowed in PNaCl. |
| 239 switch (Order) { | |
| 240 case Intrinsics::MemoryOrderAcquire: | |
| 241 case Intrinsics::MemoryOrderRelease: | |
| 242 case Intrinsics::MemoryOrderAcquireRelease: | |
| 243 case Intrinsics::MemoryOrderSequentiallyConsistent: | |
| 244 break; | |
| 245 default: | |
| 246 return false; | |
| 247 } | |
| 248 // Reject orderings not allowed by C++11. | |
| 249 switch (ID) { | |
| 250 default: | |
| 251 llvm_unreachable("isMemoryOrderValid: Unknown IntrinsicID"); | |
| 252 return false; | |
| 253 case AtomicFence: | |
| 254 case AtomicFenceAll: | |
| 255 case AtomicRMW: | |
| 256 return true; | |
| 257 case AtomicCmpxchg: | |
| 258 // Reject orderings not allowed in PNaCl or that are invalid | |
| 259 // combinations for cmpxchg. | |
|
JF
2015/03/17 21:18:14
This code should only deal with what's invalid for
Jim Stichnoth
2015/03/18 00:00:25
Done.
| |
| 260 switch (OrderOther) { | |
| 261 case Intrinsics::MemoryOrderAcquire: | |
| 262 case Intrinsics::MemoryOrderSequentiallyConsistent: | |
| 263 if (OrderOther > Order) | |
| 264 return false; | |
| 265 if (Order == Intrinsics::MemoryOrderRelease) | |
| 266 return false; | |
| 267 return true; | |
| 268 default: | |
| 269 return false; | |
| 270 } | |
| 271 case AtomicLoad: | |
| 272 switch (Order) { | |
| 273 case Intrinsics::MemoryOrderRelease: | |
| 274 case Intrinsics::MemoryOrderAcquireRelease: | |
| 275 return false; | |
| 276 default: | |
| 277 return true; | |
| 278 } | |
| 279 case AtomicStore: | |
| 280 switch (Order) { | |
| 281 case Intrinsics::MemoryOrderConsume: | |
| 282 case Intrinsics::MemoryOrderAcquire: | |
| 283 case Intrinsics::MemoryOrderAcquireRelease: | |
| 284 return false; | |
| 285 default: | |
| 286 return true; | |
| 287 } | |
| 288 } | |
| 239 } | 289 } |
| 240 | 290 |
| 241 Intrinsics::ValidateCallValue | 291 Intrinsics::ValidateCallValue |
| 242 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, | 292 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, |
| 243 SizeT &ArgIndex) const { | 293 SizeT &ArgIndex) const { |
| 244 assert(NumTypes >= 1); | 294 assert(NumTypes >= 1); |
| 245 Variable *Result = Call->getDest(); | 295 Variable *Result = Call->getDest(); |
| 246 if (Result == nullptr) { | 296 if (Result == nullptr) { |
| 247 if (Signature[0] != Ice::IceType_void) | 297 if (Signature[0] != Ice::IceType_void) |
| 248 return Intrinsics::BadReturnType; | 298 return Intrinsics::BadReturnType; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 261 return Intrinsics::IsValidCall; | 311 return Intrinsics::IsValidCall; |
| 262 } | 312 } |
| 263 | 313 |
| 264 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { | 314 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { |
| 265 assert(NumTypes > 1); | 315 assert(NumTypes > 1); |
| 266 assert(Index + 1 < NumTypes); | 316 assert(Index + 1 < NumTypes); |
| 267 return Signature[Index + 1]; | 317 return Signature[Index + 1]; |
| 268 } | 318 } |
| 269 | 319 |
| 270 } // end of namespace Ice | 320 } // end of namespace Ice |
| OLD | NEW |