Index: src/IceTargetLoweringX8632.cpp |
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
index 32246c4bef031382ea1e53fe8224c2cfab032ef3..b4e26fd658b62a848520ad54d0c280beb35451d2 100644 |
--- a/src/IceTargetLoweringX8632.cpp |
+++ b/src/IceTargetLoweringX8632.cpp |
@@ -562,6 +562,54 @@ void TargetX8632::addEpilog(CfgNode *Node) { |
} |
} |
+void TargetX8632::emitConstants() const { |
+ Ostream &Str = Ctx->getStrEmit(); |
+ SizeT Align; |
+ Type Ty; |
+ ConstantList Pool; |
+ |
+ // Emit constants from the float pool. |
+ Ty = IceType_f32; |
+ Pool = Ctx->getConstantPool(Ty); |
+ Align = typeAlignInBytes(Ty); |
+ Str << "\t.section\t.rodata.cst" << Align << ",\"aM\",@progbits," << Align |
+ << "\n"; |
+ Str << "\t.align\t" << Align << "\n"; |
+ for (ConstantList::const_iterator I = Pool.begin(), E = Pool.end(); I != E; |
+ ++I) { |
+ ConstantFloat *Const = llvm::cast<ConstantFloat>(*I); |
+ float Value = Const->getValue(); |
+ // Use memcpy() to copy bits from Value into RawValue in a way |
+ // that avoids breaking strict-aliasing rules. |
+ uint32_t RawValue; |
+ memcpy(&RawValue, &Value, sizeof(Value)); |
+ Str << "L$" << Ty << "$" << Const->getPoolEntryID() << ":\n"; |
+ Str << "\t.long\t" << RawValue << "\t# float " << Value << "\n"; |
JF
2014/05/22 21:39:47
Can you use hex format for .long? It would be more
Jim Stichnoth
2014/05/22 23:48:28
Done.
|
+ } |
+ |
+ // Emit constants from the float pool. |
+ Ty = IceType_f64; |
+ Pool = Ctx->getConstantPool(Ty); |
+ Align = typeAlignInBytes(Ty); |
+ Str << "\t.section\t.rodata.cst" << Align << ",\"aM\",@progbits," << Align |
+ << "\n"; |
+ Str << "\t.align\t" << Align << "\n"; |
+ for (ConstantList::const_iterator I = Pool.begin(), E = Pool.end(); I != E; |
+ ++I) { |
+ ConstantDouble *Const = llvm::cast<ConstantDouble>(*I); |
+ double Value = Const->getValue(); |
+ // Use memcpy() to copy bits from Value into RawValue in a way |
+ // that avoids breaking strict-aliasing rules. |
+ uint64_t RawValue; |
+ memcpy(&RawValue, &Value, sizeof(Value)); |
+ Str << "L$" << Ty << "$" << Const->getPoolEntryID() << ":\n"; |
+ Str << "\t.quad\t" << RawValue << "\t# double " << Value << "\n"; |
+ } |
JF
2014/05/22 21:39:47
Those two functions are pretty much the same thing
Jim Stichnoth
2014/05/22 23:48:28
Done. Probably break-even in terms of LOC, but st
|
+ |
+ // No need to emit constants from the int pool since they are |
+ // embedded as immediates in the instructions. |
JF
2014/05/22 21:39:47
That won't always be true on ARM.
Jim Stichnoth
2014/05/22 23:48:28
Yes, but this is in a file with X86 in its name. :
|
+} |
+ |
void TargetX8632::split64(Variable *Var) { |
switch (Var->getType()) { |
default: |
@@ -1878,4 +1926,16 @@ void TargetX8632::postLower() { |
} |
} |
+template <> void ConstantFloat::emit(const Cfg *Func) const { |
+ Ostream &Str = Func->getContext()->getStrEmit(); |
+ // It would be better to prefix with ".L$" instead of "L$", but |
+ // llvm-mc doesn't parse "dword ptr [.L$foo]". |
+ Str << "dword ptr [L$" << IceType_f32 << "$" << getPoolEntryID() << "]"; |
+} |
+ |
+template <> void ConstantDouble::emit(const Cfg *Func) const { |
+ Ostream &Str = Func->getContext()->getStrEmit(); |
+ Str << "qword ptr [L$" << IceType_f64 << "$" << getPoolEntryID() << "]"; |
+} |
+ |
} // end of namespace Ice |