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

Side by Side Diff: src/IceOperand.h

Issue 837393005: Subzero: Write float/double constant pools directly to the ELF file. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: use WriteAmt everywhere Created 5 years, 11 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/IceELFObjectWriter.cpp ('k') | src/IceTargetLoweringX8632.cpp » ('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.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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const uint32_t PoolEntryID; 132 const uint32_t PoolEntryID;
133 }; 133 };
134 134
135 // ConstantPrimitive<> wraps a primitive type. 135 // ConstantPrimitive<> wraps a primitive type.
136 template <typename T, Operand::OperandKind K> 136 template <typename T, Operand::OperandKind K>
137 class ConstantPrimitive : public Constant { 137 class ConstantPrimitive : public Constant {
138 ConstantPrimitive(const ConstantPrimitive &) = delete; 138 ConstantPrimitive(const ConstantPrimitive &) = delete;
139 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete; 139 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete;
140 140
141 public: 141 public:
142 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, 142 typedef T PrimType;
143
144 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, PrimType Value,
143 uint32_t PoolEntryID) { 145 uint32_t PoolEntryID) {
144 assert(!Ctx->isIRGenerationDisabled() && 146 assert(!Ctx->isIRGenerationDisabled() &&
145 "Attempt to build primitive constant when IR generation disabled"); 147 "Attempt to build primitive constant when IR generation disabled");
146 return new (Ctx->allocate<ConstantPrimitive>()) 148 return new (Ctx->allocate<ConstantPrimitive>())
147 ConstantPrimitive(Ty, Value, PoolEntryID); 149 ConstantPrimitive(Ty, Value, PoolEntryID);
148 } 150 }
149 T getValue() const { return Value; } 151 PrimType getValue() const { return Value; }
150 using Constant::emit; 152 using Constant::emit;
151 // The target needs to implement this for each ConstantPrimitive 153 // The target needs to implement this for each ConstantPrimitive
152 // specialization. 154 // specialization.
153 void emit(GlobalContext *Ctx) const override; 155 void emit(GlobalContext *Ctx) const override;
154 using Constant::dump; 156 using Constant::dump;
155 void dump(const Cfg *, Ostream &Str) const override { 157 void dump(const Cfg *, Ostream &Str) const override {
156 if (ALLOW_DUMP) 158 if (ALLOW_DUMP)
157 Str << getValue(); 159 Str << getValue();
158 } 160 }
159 161
160 static bool classof(const Operand *Operand) { 162 static bool classof(const Operand *Operand) {
161 return Operand->getKind() == K; 163 return Operand->getKind() == K;
162 } 164 }
163 165
164 private: 166 private:
165 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) 167 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID)
166 : Constant(K, Ty, PoolEntryID), Value(Value) {} 168 : Constant(K, Ty, PoolEntryID), Value(Value) {}
167 ~ConstantPrimitive() override {} 169 ~ConstantPrimitive() override {}
168 const T Value; 170 const PrimType Value;
169 }; 171 };
170 172
171 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; 173 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32;
172 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; 174 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64;
173 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; 175 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat;
174 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; 176 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
175 177
176 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { 178 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
177 if (!ALLOW_DUMP) 179 if (!ALLOW_DUMP)
178 return; 180 return;
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 private: 630 private:
629 const Cfg *Func; 631 const Cfg *Func;
630 MetadataKind Kind; 632 MetadataKind Kind;
631 std::vector<VariableTracking> Metadata; 633 std::vector<VariableTracking> Metadata;
632 const static InstDefList NoDefinitions; 634 const static InstDefList NoDefinitions;
633 }; 635 };
634 636
635 } // end of namespace Ice 637 } // end of namespace Ice
636 638
637 #endif // SUBZERO_SRC_ICEOPERAND_H 639 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« no previous file with comments | « src/IceELFObjectWriter.cpp ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698