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

Side by Side Diff: src/IceOperand.cpp

Issue 1738443002: Subzero. Performance tweaks. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments -- all of them Created 4 years, 10 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/IceOperand.h ('k') | src/IceRegAlloc.h » ('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/IceOperand.cpp - High-level operand implementation -----===// 1 //===- subzero/src/IceOperand.cpp - High-level operand implementation -----===//
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
11 /// \brief Implements the Operand class and its target-independent subclasses, 11 /// \brief Implements the Operand class and its target-independent subclasses,
12 /// primarily for the methods of the Variable class. 12 /// primarily for the methods of the Variable class.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "IceOperand.h" 16 #include "IceOperand.h"
17 17
18 #include "IceCfg.h" 18 #include "IceCfg.h"
19 #include "IceCfgNode.h" 19 #include "IceCfgNode.h"
20 #include "IceInst.h" 20 #include "IceInst.h"
21 #include "IceInstVarIter.h" 21 #include "IceInstVarIter.h"
22 #include "IceMemory.h"
22 #include "IceTargetLowering.h" // dumping stack/frame pointer register 23 #include "IceTargetLowering.h" // dumping stack/frame pointer register
23 24
24 namespace Ice { 25 namespace Ice {
25 26
26 bool operator==(const RelocatableTuple &A, const RelocatableTuple &B) { 27 bool operator==(const RelocatableTuple &A, const RelocatableTuple &B) {
27 // A and B are the same if: 28 // A and B are the same if:
28 // (1) they have the same name; and 29 // (1) they have the same name; and
29 // (2) they have the same offset. 30 // (2) they have the same offset.
30 // 31 //
31 // (1) is trivial to check, but (2) requires some care. 32 // (1) is trivial to check, but (2) requires some care.
32 // 33 //
33 // For (2): 34 // For (2):
34 // if A and B have known offsets (i.e., no symbolic references), then 35 // if A and B have known offsets (i.e., no symbolic references), then
35 // A == B -> A.Offset == B.Offset. 36 // A == B -> A.Offset == B.Offset.
36 // else each element i in A.OffsetExpr[i] must be the same (or have the same 37 // else each element i in A.OffsetExpr[i] must be the same (or have the same
37 // value) as B.OffsetExpr[i]. 38 // value) as B.OffsetExpr[i].
38 if (A.Name != B.Name) { 39 if (A.Name != B.Name) {
39 return false; 40 return false;
40 } 41 }
41 42
42 bool BothHaveKnownOffsets = true; 43 bool BothHaveKnownOffsets = true;
43 RelocOffsetT OffsetA = 0; 44 RelocOffsetT OffsetA = A.Offset;
44 RelocOffsetT OffsetB = 0; 45 RelocOffsetT OffsetB = B.Offset;
45 for (SizeT i = 0; i < A.OffsetExpr.size() && BothHaveKnownOffsets; ++i) { 46 for (SizeT i = 0; i < A.OffsetExpr.size() && BothHaveKnownOffsets; ++i) {
46 BothHaveKnownOffsets = A.OffsetExpr[i]->hasOffset(); 47 BothHaveKnownOffsets = A.OffsetExpr[i]->hasOffset();
47 if (BothHaveKnownOffsets) { 48 if (BothHaveKnownOffsets) {
48 OffsetA += A.OffsetExpr[i]->getOffset(); 49 OffsetA += A.OffsetExpr[i]->getOffset();
49 } 50 }
50 } 51 }
51 for (SizeT i = 0; i < B.OffsetExpr.size() && BothHaveKnownOffsets; ++i) { 52 for (SizeT i = 0; i < B.OffsetExpr.size() && BothHaveKnownOffsets; ++i) {
52 BothHaveKnownOffsets = B.OffsetExpr[i]->hasOffset(); 53 BothHaveKnownOffsets = B.OffsetExpr[i]->hasOffset();
53 if (BothHaveKnownOffsets) { 54 if (BothHaveKnownOffsets) {
54 OffsetB += B.OffsetExpr[i]->getOffset(); 55 OffsetB += B.OffsetExpr[i]->getOffset();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (Func && NameIndex >= 0) 191 if (Func && NameIndex >= 0)
191 return Func->getIdentifierName(NameIndex); 192 return Func->getIdentifierName(NameIndex);
192 return "__" + std::to_string(getIndex()); 193 return "__" + std::to_string(getIndex());
193 } 194 }
194 195
195 const Variable *Variable::asType(Type Ty, RegNumT NewRegNum) const { 196 const Variable *Variable::asType(Type Ty, RegNumT NewRegNum) const {
196 // Note: This returns a Variable, even if the "this" object is a subclass of 197 // Note: This returns a Variable, even if the "this" object is a subclass of
197 // Variable. 198 // Variable.
198 if (!BuildDefs::dump() || getType() == Ty) 199 if (!BuildDefs::dump() || getType() == Ty)
199 return this; 200 return this;
200 Variable *V = new (getCurrentCfgAllocator()->Allocate<Variable>()) 201 static constexpr SizeT One = 1;
202 Variable *V = new (CfgLocalAllocator<Variable>().allocate(One))
201 Variable(kVariable, Ty, Number); 203 Variable(kVariable, Ty, Number);
202 V->NameIndex = NameIndex; 204 V->NameIndex = NameIndex;
203 V->RegNum = NewRegNum.hasValue() ? NewRegNum : RegNum; 205 V->RegNum = NewRegNum.hasValue() ? NewRegNum : RegNum;
204 V->StackOffset = StackOffset; 206 V->StackOffset = StackOffset;
205 return V; 207 return V;
206 } 208 }
207 209
208 RegWeight Variable::getWeight(const Cfg *Func) const { 210 RegWeight Variable::getWeight(const Cfg *Func) const {
209 VariablesMetadata *VMetadata = Func->getVMetadata(); 211 VariablesMetadata *VMetadata = Func->getVMetadata();
210 return mustHaveReg() ? RegWeight(RegWeight::Inf) 212 return mustHaveReg() ? RegWeight(RegWeight::Inf)
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 if (getType() != IceType_i32 && getType() != IceType_i16 && 618 if (getType() != IceType_i32 && getType() != IceType_i16 &&
617 getType() != IceType_i8) 619 getType() != IceType_i8)
618 return false; 620 return false;
619 // The Following checks if the signed representation of Value is between 621 // The Following checks if the signed representation of Value is between
620 // -Threshold/2 and +Threshold/2 622 // -Threshold/2 and +Threshold/2
621 bool largerThanThreshold = Threshold / 2 + Value >= Threshold; 623 bool largerThanThreshold = Threshold / 2 + Value >= Threshold;
622 return largerThanThreshold; 624 return largerThanThreshold;
623 } 625 }
624 626
625 } // end of namespace Ice 627 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceOperand.h ('k') | src/IceRegAlloc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698