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

Side by Side Diff: src/IceOperand.h

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.h - High-level operands -----------*- C++ -*-===// 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- 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 // This file declares the Operand class and its target-independent 10 // This file declares the Operand class and its target-independent
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 using Constant::dump; 153 using Constant::dump;
154 void dump(const Cfg *, Ostream &Str) const override { 154 void dump(const Cfg *, Ostream &Str) const override {
155 if (ALLOW_DUMP) 155 if (ALLOW_DUMP)
156 Str << getValue(); 156 Str << getValue();
157 } 157 }
158 158
159 static bool classof(const Operand *Operand) { 159 static bool classof(const Operand *Operand) {
160 return Operand->getKind() == K; 160 return Operand->getKind() == K;
161 } 161 }
162 162
163 // Judge if this given immediate should be randomized or pooled
Jim Stichnoth 2015/06/12 23:48:17 End this and the next sentence with a period.
qining 2015/06/17 04:28:53 Done.
164 // By default should return false, only constant integers should
165 // truely go through this method
Jim Stichnoth 2015/06/12 23:48:17 truly
qining 2015/06/17 04:28:53 Done.
166 bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) { return false; }
167
163 private: 168 private:
164 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) 169 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID)
165 : Constant(K, Ty, PoolEntryID), Value(Value) {} 170 : Constant(K, Ty, PoolEntryID), Value(Value) {}
166 ~ConstantPrimitive() override {} 171 ~ConstantPrimitive() override {}
167 const PrimType Value; 172 const PrimType Value;
168 }; 173 };
169 174
170 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; 175 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32;
171 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; 176 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64;
172 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; 177 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat;
173 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; 178 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
174 179
175 template <> 180 template <>
176 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { 181 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
177 if (!ALLOW_DUMP) 182 if (!ALLOW_DUMP)
178 return; 183 return;
179 if (getType() == IceType_i1) 184 if (getType() == IceType_i1)
180 Str << (getValue() ? "true" : "false"); 185 Str << (getValue() ? "true" : "false");
181 else 186 else
182 Str << static_cast<int32_t>(getValue()); 187 Str << static_cast<int32_t>(getValue());
183 } 188 }
184 189
190 // Specialization of the template member function for ConstantInteger32
191 template <>
192 bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx);
Jim Stichnoth 2015/06/12 23:48:17 I'm not sure it's sufficient to limit blinding to
qining 2015/06/17 04:28:53 Done. We now support randomizing and pooling of i8
193
185 template <> 194 template <>
186 inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { 195 inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const {
187 if (!ALLOW_DUMP) 196 if (!ALLOW_DUMP)
188 return; 197 return;
189 assert(getType() == IceType_i64); 198 assert(getType() == IceType_i64);
190 Str << static_cast<int64_t>(getValue()); 199 Str << static_cast<int64_t>(getValue());
191 } 200 }
192 201
193 // RelocatableTuple bundles the parameters that are used to 202 // RelocatableTuple bundles the parameters that are used to
194 // construct an ConstantRelocatable. It is done this way so that 203 // construct an ConstantRelocatable. It is done this way so that
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 private: 640 private:
632 const Cfg *Func; 641 const Cfg *Func;
633 MetadataKind Kind; 642 MetadataKind Kind;
634 std::vector<VariableTracking> Metadata; 643 std::vector<VariableTracking> Metadata;
635 const static InstDefList NoDefinitions; 644 const static InstDefList NoDefinitions;
636 }; 645 };
637 646
638 } // end of namespace Ice 647 } // end of namespace Ice
639 648
640 #endif // SUBZERO_SRC_ICEOPERAND_H 649 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698