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

Side by Side Diff: src/IceOperand.cpp

Issue 1185703004: Add constant blinding/pooling option for X8632 code translation (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: reformat Created 5 years, 6 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
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 // This file implements the Operand class and its target-independent 10 // This file implements the Operand class and its target-independent
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 if (OtherBegin < I->first) { 85 if (OtherBegin < I->first) {
86 Result = false; 86 Result = false;
87 break; 87 break;
88 } 88 }
89 if (OtherBegin < I->second) { 89 if (OtherBegin < I->second) {
90 Result = true; 90 Result = true;
91 break; 91 break;
92 } 92 }
93 } 93 }
94 #if 0 94 #if 0
95 // An equivalent but less inefficient implementation: 95 » » // An equivalent but less inefficient implementation:
96 LiveRange Temp; 96 » » LiveRange Temp;
97 Temp.addSegment(OtherBegin, OtherBegin + 1); 97 » » Temp.addSegment(OtherBegin, OtherBegin + 1);
98 bool Validation = overlaps(Temp); 98 » » bool Validation = overlaps(Temp);
99 assert(Result == Validation); 99 » » assert(Result == Validation);
100 #endif 100 #endif
JF 2015/06/17 11:29:18 `#if 0` and tabs are sad. Could you make this a co
qining 2015/06/17 18:20:36 Sorry for the unnecessary tabs. I will remove them
Jim Stichnoth 2015/06/19 16:51:02 Let's keep the #if code. This was meant to give a
101 return Result; 101 return Result;
102 } 102 }
103 103
104 // Returns true if the live range contains the given instruction 104 // Returns true if the live range contains the given instruction
105 // number. This is only used for validating the live range 105 // number. This is only used for validating the live range
106 // calculation. The IsDest argument indicates whether the Variable 106 // calculation. The IsDest argument indicates whether the Variable
107 // being tested is used in the Dest position (as opposed to a Src 107 // being tested is used in the Dest position (as opposed to a Src
108 // position). 108 // position).
109 bool LiveRange::containsValue(InstNumberT Value, bool IsDest) const { 109 bool LiveRange::containsValue(InstNumberT Value, bool IsDest) const {
110 for (const RangeElementType &I : Range) { 110 for (const RangeElementType &I : Range) {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 Ostream &operator<<(Ostream &Str, const RegWeight &W) { 484 Ostream &operator<<(Ostream &Str, const RegWeight &W) {
485 if (!ALLOW_DUMP) 485 if (!ALLOW_DUMP)
486 return Str; 486 return Str;
487 if (W.getWeight() == RegWeight::Inf) 487 if (W.getWeight() == RegWeight::Inf)
488 Str << "Inf"; 488 Str << "Inf";
489 else 489 else
490 Str << W.getWeight(); 490 Str << W.getWeight();
491 return Str; 491 return Str;
492 } 492 }
493 493
494 // =========== Immediate Randomization and Pooling routines ==============
495 // Immediates randomization and pooling threshold, we should not
496 // randomize or pool small constants e.g. 2,4 etc.
497 const uint32_t X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD = 0x1;
qining 2015/06/17 04:28:55 The THRESHOLD is set to 0x1.
JF 2015/06/17 11:29:18 This isn't use by other files? It's currently expo
qining 2015/06/17 18:20:36 Yes, you are right, I should confine this to a sma
498
499 // Specialization of the template member function for ConstantInteger32
500 template <>
501 bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx) {
502 if (Ctx->getFlags().getRandomizeAndPoolImmediatesOption() == RPI_None)
503 return false;
504 if (getType() != IceType_i32 && getType() != IceType_i16 &&
505 getType() != IceType_i8)
qining 2015/06/17 04:28:55 Consider i8, 16 constant integers.
506 return false;
507 // if(getType() != IceType_i32) return false;
508 // The Following checks if the signed representation of Value is between
509 // -THRESHOLD/2 and +THRESHOLD/2
510 bool largerThanThreshold =
511 X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD / 2 + Value >=
512 X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD;
513 return largerThanThreshold;
514 }
515
494 } // end of namespace Ice 516 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698