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::MemoryOrderInvalid: | |
| 241 case Intrinsics::MemoryOrderNum: | |
| 242 case Intrinsics::MemoryOrderRelaxed: | |
| 243 case Intrinsics::MemoryOrderConsume: | |
| 244 return false; | |
| 245 } | |
|
JF
2015/03/17 16:58:53
I'd do the opposite and whitelist acquire/release/
Jim Stichnoth
2015/03/17 18:42:04
Done.
| |
| 246 // Reject orderings not allowed by C++11. | |
| 247 switch (ID) { | |
| 248 default: | |
| 249 llvm_unreachable("isMemoryOrderValid: Unknown IntrinsicID"); | |
| 250 return false; | |
| 251 case AtomicFence: | |
| 252 case AtomicFenceAll: | |
| 253 case AtomicRMW: | |
| 254 return true; | |
| 255 case AtomicCmpxchg: | |
| 256 switch (OrderOther) { | |
| 257 case Intrinsics::MemoryOrderInvalid: | |
| 258 case Intrinsics::MemoryOrderNum: | |
| 259 case Intrinsics::MemoryOrderRelease: | |
| 260 case Intrinsics::MemoryOrderAcquireRelease: | |
| 261 case Intrinsics::MemoryOrderRelaxed: | |
| 262 case Intrinsics::MemoryOrderConsume: | |
| 263 return false; | |
| 264 default: | |
| 265 if (OrderOther > Order) | |
| 266 return false; | |
| 267 if (Order == Intrinsics::MemoryOrderRelease && | |
| 268 OrderOther != Intrinsics::MemoryOrderRelaxed) | |
|
JF
2015/03/17 21:18:14
I would leave this in, otherwise when we add relax
Jim Stichnoth
2015/03/18 00:00:25
OK, yeah, that optimization did seem too good to b
| |
| 269 return false; | |
| 270 return true; | |
| 271 } | |
| 272 case AtomicLoad: | |
| 273 switch (Order) { | |
| 274 case Intrinsics::MemoryOrderRelease: | |
| 275 case Intrinsics::MemoryOrderAcquireRelease: | |
| 276 return false; | |
| 277 default: | |
| 278 return true; | |
| 279 } | |
| 280 case AtomicStore: | |
| 281 switch (Order) { | |
| 282 case Intrinsics::MemoryOrderConsume: | |
| 283 case Intrinsics::MemoryOrderAcquire: | |
| 284 case Intrinsics::MemoryOrderAcquireRelease: | |
| 285 return false; | |
| 286 default: | |
| 287 return true; | |
| 288 } | |
| 289 } | |
| 239 } | 290 } |
| 240 | 291 |
| 241 Intrinsics::ValidateCallValue | 292 Intrinsics::ValidateCallValue |
| 242 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, | 293 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, |
| 243 SizeT &ArgIndex) const { | 294 SizeT &ArgIndex) const { |
| 244 assert(NumTypes >= 1); | 295 assert(NumTypes >= 1); |
| 245 Variable *Result = Call->getDest(); | 296 Variable *Result = Call->getDest(); |
| 246 if (Result == nullptr) { | 297 if (Result == nullptr) { |
| 247 if (Signature[0] != Ice::IceType_void) | 298 if (Signature[0] != Ice::IceType_void) |
| 248 return Intrinsics::BadReturnType; | 299 return Intrinsics::BadReturnType; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 261 return Intrinsics::IsValidCall; | 312 return Intrinsics::IsValidCall; |
| 262 } | 313 } |
| 263 | 314 |
| 264 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { | 315 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { |
| 265 assert(NumTypes > 1); | 316 assert(NumTypes > 1); |
| 266 assert(Index + 1 < NumTypes); | 317 assert(Index + 1 < NumTypes); |
| 267 return Signature[Index + 1]; | 318 return Signature[Index + 1]; |
| 268 } | 319 } |
| 269 | 320 |
| 270 } // end of namespace Ice | 321 } // end of namespace Ice |
| OLD | NEW |