| OLD | NEW |
| 1 //===- subzero/src/IceTargetLoweringX8664Traits.h - x86-64 traits -*- C++ -*-=// | 1 //===- subzero/src/IceTargetLoweringX8664Traits.h - x86-64 traits -*- 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 REGX8664_TABLE | 368 REGX8664_TABLE |
| 369 | 369 |
| 370 #undef X | 370 #undef X |
| 371 | 371 |
| 372 return Registers; | 372 return Registers; |
| 373 } | 373 } |
| 374 | 374 |
| 375 static void | 375 static void |
| 376 makeRandomRegisterPermutation(GlobalContext *Ctx, Cfg *Func, | 376 makeRandomRegisterPermutation(GlobalContext *Ctx, Cfg *Func, |
| 377 llvm::SmallVectorImpl<int32_t> &Permutation, | 377 llvm::SmallVectorImpl<int32_t> &Permutation, |
| 378 const llvm::SmallBitVector &ExcludeRegisters) { | 378 const llvm::SmallBitVector &ExcludeRegisters, |
| 379 uint64_t Salt) { |
| 379 // TODO(stichnot): Declaring Permutation this way loses type/size | 380 // TODO(stichnot): Declaring Permutation this way loses type/size |
| 380 // information. Fix this in conjunction with the caller-side TODO. | 381 // information. Fix this in conjunction with the caller-side TODO. |
| 381 assert(Permutation.size() >= RegisterSet::Reg_NUM); | 382 assert(Permutation.size() >= RegisterSet::Reg_NUM); |
| 382 // Expected upper bound on the number of registers in a single equivalence | 383 // Expected upper bound on the number of registers in a single equivalence |
| 383 // class. For x86-64, this would comprise the 16 XMM registers. This is | 384 // class. For x86-64, this would comprise the 16 XMM registers. This is |
| 384 // for performance, not correctness. | 385 // for performance, not correctness. |
| 385 static const unsigned MaxEquivalenceClassSize = 8; | 386 static const unsigned MaxEquivalenceClassSize = 8; |
| 386 typedef llvm::SmallVector<int32_t, MaxEquivalenceClassSize> RegisterList; | 387 typedef llvm::SmallVector<int32_t, MaxEquivalenceClassSize> RegisterList; |
| 387 typedef std::map<uint32_t, RegisterList> EquivalenceClassMap; | 388 typedef std::map<uint32_t, RegisterList> EquivalenceClassMap; |
| 388 EquivalenceClassMap EquivalenceClasses; | 389 EquivalenceClassMap EquivalenceClasses; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 399 ++NumPreserved; \ | 400 ++NumPreserved; \ |
| 400 } else { \ | 401 } else { \ |
| 401 const uint32_t Index = (scratch << 0) | (preserved << 1) | \ | 402 const uint32_t Index = (scratch << 0) | (preserved << 1) | \ |
| 402 (/*isI8=*/1 << 2) | (isInt << 3) | (isFP << 4); \ | 403 (/*isI8=*/1 << 2) | (isInt << 3) | (isFP << 4); \ |
| 403 /* val is assigned to an equivalence class based on its properties. */ \ | 404 /* val is assigned to an equivalence class based on its properties. */ \ |
| 404 EquivalenceClasses[Index].push_back(RegisterSet::val); \ | 405 EquivalenceClasses[Index].push_back(RegisterSet::val); \ |
| 405 } | 406 } |
| 406 REGX8664_TABLE | 407 REGX8664_TABLE |
| 407 #undef X | 408 #undef X |
| 408 | 409 |
| 409 RandomNumberGeneratorWrapper RNG(Ctx->getRNG()); | 410 // Create a random number generator for regalloc randomization. |
| 411 RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(), |
| 412 RPE_RegAllocRandomization, Salt); |
| 413 RandomNumberGeneratorWrapper RNGW(RNG); |
| 410 | 414 |
| 411 // Shuffle the resulting equivalence classes. | 415 // Shuffle the resulting equivalence classes. |
| 412 for (auto I : EquivalenceClasses) { | 416 for (auto I : EquivalenceClasses) { |
| 413 const RegisterList &List = I.second; | 417 const RegisterList &List = I.second; |
| 414 RegisterList Shuffled(List); | 418 RegisterList Shuffled(List); |
| 415 RandomShuffle(Shuffled.begin(), Shuffled.end(), RNG); | 419 RandomShuffle(Shuffled.begin(), Shuffled.end(), RNGW); |
| 416 for (size_t SI = 0, SE = Shuffled.size(); SI < SE; ++SI) { | 420 for (size_t SI = 0, SE = Shuffled.size(); SI < SE; ++SI) { |
| 417 Permutation[List[SI]] = Shuffled[SI]; | 421 Permutation[List[SI]] = Shuffled[SI]; |
| 418 ++NumShuffled; | 422 ++NumShuffled; |
| 419 } | 423 } |
| 420 } | 424 } |
| 421 | 425 |
| 422 assert(NumShuffled + NumPreserved == RegisterSet::Reg_NUM); | 426 assert(NumShuffled + NumPreserved == RegisterSet::Reg_NUM); |
| 423 | 427 |
| 424 if (Func->isVerbose(IceV_Random)) { | 428 if (Func->isVerbose(IceV_Random)) { |
| 425 OstreamLocker L(Func->getContext()); | 429 OstreamLocker L(Func->getContext()); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 | 722 |
| 719 } // end of namespace X86Internal | 723 } // end of namespace X86Internal |
| 720 | 724 |
| 721 namespace X8664 { | 725 namespace X8664 { |
| 722 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; | 726 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; |
| 723 } // end of namespace X8664 | 727 } // end of namespace X8664 |
| 724 | 728 |
| 725 } // end of namespace Ice | 729 } // end of namespace Ice |
| 726 | 730 |
| 727 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H | 731 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H |
| OLD | NEW |