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 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 invalid combinations for cmpxchg. | |
| 271 switch (OrderOther) { | |
| 272 case MemoryOrderAcquire: | |
| 273 case MemoryOrderSequentiallyConsistent: | |
|
JF
2015/03/18 06:26:30
This is wrong, order can also be relaxed or consum
Jim Stichnoth
2015/03/18 13:50:15
But but, that's covered by the isMemoryOrderValidP
| |
| 274 if (OrderOther > Order) | |
| 275 return false; | |
| 276 if (Order == MemoryOrderRelease && OrderOther != MemoryOrderRelaxed) | |
| 277 return false; | |
| 278 return true; | |
| 279 default: | |
| 280 return false; | |
| 281 } | |
| 282 case AtomicLoad: | |
| 283 switch (Order) { | |
| 284 case MemoryOrderRelease: | |
| 285 case MemoryOrderAcquireRelease: | |
| 286 return false; | |
| 287 default: | |
| 288 return true; | |
| 289 } | |
| 290 case AtomicStore: | |
| 291 switch (Order) { | |
| 292 case MemoryOrderConsume: | |
| 293 case MemoryOrderAcquire: | |
| 294 case MemoryOrderAcquireRelease: | |
| 295 return false; | |
| 296 default: | |
| 297 return true; | |
| 298 } | |
| 299 } | |
| 239 } | 300 } |
| 240 | 301 |
| 241 Intrinsics::ValidateCallValue | 302 Intrinsics::ValidateCallValue |
| 242 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, | 303 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, |
| 243 SizeT &ArgIndex) const { | 304 SizeT &ArgIndex) const { |
| 244 assert(NumTypes >= 1); | 305 assert(NumTypes >= 1); |
| 245 Variable *Result = Call->getDest(); | 306 Variable *Result = Call->getDest(); |
| 246 if (Result == nullptr) { | 307 if (Result == nullptr) { |
| 247 if (Signature[0] != Ice::IceType_void) | 308 if (Signature[0] != Ice::IceType_void) |
| 248 return Intrinsics::BadReturnType; | 309 return Intrinsics::BadReturnType; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 261 return Intrinsics::IsValidCall; | 322 return Intrinsics::IsValidCall; |
| 262 } | 323 } |
| 263 | 324 |
| 264 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { | 325 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { |
| 265 assert(NumTypes > 1); | 326 assert(NumTypes > 1); |
| 266 assert(Index + 1 < NumTypes); | 327 assert(Index + 1 < NumTypes); |
| 267 return Signature[Index + 1]; | 328 return Signature[Index + 1]; |
| 268 } | 329 } |
| 269 | 330 |
| 270 } // end of namespace Ice | 331 } // end of namespace Ice |
| OLD | NEW |