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

Side by Side Diff: src/IceTargetLoweringX86BaseImpl.h

Issue 1385433002: Subzero: Use register availability during lowering to improve the code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add comments Created 5 years, 2 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/IceTargetLowering.cpp ('k') | tests_lit/llvm2ice_tests/callindirect.pnacl.ll » ('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/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- 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 4978 matching lines...) Expand 10 before | Expand all | Expand 10 after
4989 // Assert that a physical register is allowed. To date, all calls to 4989 // Assert that a physical register is allowed. To date, all calls to
4990 // legalize() allow a physical register. If a physical register needs to be 4990 // legalize() allow a physical register. If a physical register needs to be
4991 // explicitly disallowed, then new code will need to be written to force a 4991 // explicitly disallowed, then new code will need to be written to force a
4992 // spill. 4992 // spill.
4993 assert(Allowed & Legal_Reg); 4993 assert(Allowed & Legal_Reg);
4994 // If we're asking for a specific physical register, make sure we're not 4994 // If we're asking for a specific physical register, make sure we're not
4995 // allowing any other operand kinds. (This could be future work, e.g. allow 4995 // allowing any other operand kinds. (This could be future work, e.g. allow
4996 // the shl shift amount to be either an immediate or in ecx.) 4996 // the shl shift amount to be either an immediate or in ecx.)
4997 assert(RegNum == Variable::NoRegister || Allowed == Legal_Reg); 4997 assert(RegNum == Variable::NoRegister || Allowed == Legal_Reg);
4998 4998
4999 // Substitute with an available infinite-weight variable if possible. Only do
5000 // this when we are not asking for a specific register, and when the
5001 // substitution is not locked to a specific register, and when the types
5002 // match, in order to capture the vast majority of opportunities and avoid
5003 // corner cases in the lowering.
5004 if (RegNum == Variable::NoRegister) {
5005 if (Variable *Subst = getContext().availabilityGet(From)) {
5006 // At this point we know there is a potential substitution available.
5007 if (Subst->mustHaveReg() && !Subst->hasReg()) {
5008 // At this point we know the substitution will have a register.
5009 if (From->getType() == Subst->getType()) {
5010 // At this point we know the substitution's register is compatible.
5011 return Subst;
5012 }
5013 }
5014 }
5015 }
5016
4999 if (auto Mem = llvm::dyn_cast<typename Traits::X86OperandMem>(From)) { 5017 if (auto Mem = llvm::dyn_cast<typename Traits::X86OperandMem>(From)) {
5000 // Before doing anything with a Mem operand, we need to ensure that the 5018 // Before doing anything with a Mem operand, we need to ensure that the
5001 // Base and Index components are in physical registers. 5019 // Base and Index components are in physical registers.
5002 Variable *Base = Mem->getBase(); 5020 Variable *Base = Mem->getBase();
5003 Variable *Index = Mem->getIndex(); 5021 Variable *Index = Mem->getIndex();
5004 Variable *RegBase = nullptr; 5022 Variable *RegBase = nullptr;
5005 Variable *RegIndex = nullptr; 5023 Variable *RegIndex = nullptr;
5006 if (Base) { 5024 if (Base) {
5007 RegBase = legalizeToReg(Base); 5025 RegBase = legalizeToReg(Base);
5008 } 5026 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
5212 uint32_t MaxIndex = MaxSize == NoSizeLimit 5230 uint32_t MaxIndex = MaxSize == NoSizeLimit
5213 ? llvm::array_lengthof(TypeForSize) - 1 5231 ? llvm::array_lengthof(TypeForSize) - 1
5214 : llvm::findLastSet(MaxSize, llvm::ZB_Undefined); 5232 : llvm::findLastSet(MaxSize, llvm::ZB_Undefined);
5215 return TypeForSize[std::min(TyIndex, MaxIndex)]; 5233 return TypeForSize[std::min(TyIndex, MaxIndex)];
5216 } 5234 }
5217 5235
5218 template <class Machine> void TargetX86Base<Machine>::postLower() { 5236 template <class Machine> void TargetX86Base<Machine>::postLower() {
5219 if (Ctx->getFlags().getOptLevel() == Opt_m1) 5237 if (Ctx->getFlags().getOptLevel() == Opt_m1)
5220 return; 5238 return;
5221 markRedefinitions(); 5239 markRedefinitions();
5240 Context.availabilityUpdate();
5222 } 5241 }
5223 5242
5224 template <class Machine> 5243 template <class Machine>
5225 void TargetX86Base<Machine>::makeRandomRegisterPermutation( 5244 void TargetX86Base<Machine>::makeRandomRegisterPermutation(
5226 llvm::SmallVectorImpl<int32_t> &Permutation, 5245 llvm::SmallVectorImpl<int32_t> &Permutation,
5227 const llvm::SmallBitVector &ExcludeRegisters, uint64_t Salt) const { 5246 const llvm::SmallBitVector &ExcludeRegisters, uint64_t Salt) const {
5228 Traits::makeRandomRegisterPermutation(Ctx, Func, Permutation, 5247 Traits::makeRandomRegisterPermutation(Ctx, Func, Permutation,
5229 ExcludeRegisters, Salt); 5248 ExcludeRegisters, Salt);
5230 } 5249 }
5231 5250
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5456 } 5475 }
5457 // the offset is not eligible for blinding or pooling, return the original 5476 // the offset is not eligible for blinding or pooling, return the original
5458 // mem operand 5477 // mem operand
5459 return MemOperand; 5478 return MemOperand;
5460 } 5479 }
5461 5480
5462 } // end of namespace X86Internal 5481 } // end of namespace X86Internal
5463 } // end of namespace Ice 5482 } // end of namespace Ice
5464 5483
5465 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H 5484 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H
OLDNEW
« no previous file with comments | « src/IceTargetLowering.cpp ('k') | tests_lit/llvm2ice_tests/callindirect.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698