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

Unified Diff: src/IceInstX8632.cpp

Issue 358013003: Subzero: Partial implementation of global initializers. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: After rebasing from laster master Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crosstest/test_global_main.cpp ('k') | src/IceTargetLowering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInstX8632.cpp
diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp
index 376d4541add697a0643fc1e7d3f585cce5a3ac2f..b983c3e7d6d4737615d412099e3728e3745b505c 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -655,8 +655,21 @@ void InstX8632StoreQ::dump(const Cfg *Func) const {
void InstX8632Mov::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
- Str << "\tmov" << TypeX8632Attributes[getDest()->getType()].SdSsString
- << "\t";
+ Operand *Src = getSrc(0);
+ // The llvm-mc assembler using Intel syntax has a bug in which "mov
+ // reg, RelocatableConstant" does not generate the right instruction
+ // with a relocation. To work around, we emit "lea reg,
+ // [RelocatableConstant]". Also, the lowering and legalization is
+ // changed to allow relocatable constants only in Assign and Call
+ // instructions or in Mem operands. TODO(stichnot): remove LEAHACK
+ // once a proper emitter is used.
+ bool UseLeaHack = llvm::isa<ConstantRelocatable>(Src);
+ Str << "\t";
+ if (UseLeaHack)
+ Str << "lea";
+ else
+ Str << "mov" << TypeX8632Attributes[getDest()->getType()].SdSsString;
+ Str << "\t";
// For an integer truncation operation, src is wider than dest.
// Ideally, we use a mov instruction whose data width matches the
// narrower dest. This is a problem if e.g. src is a register like
@@ -665,10 +678,10 @@ void InstX8632Mov::emit(const Cfg *Func) const {
// for stack-allocated dest variables because typeWidthOnStack()
// pads to a 4-byte boundary even if only a lower portion is used.
assert(Func->getTarget()->typeWidthInBytesOnStack(getDest()->getType()) ==
- Func->getTarget()->typeWidthInBytesOnStack(getSrc(0)->getType()));
- getDest()->asType(getSrc(0)->getType()).emit(Func);
+ Func->getTarget()->typeWidthInBytesOnStack(Src->getType()));
+ getDest()->asType(Src->getType()).emit(Func);
Str << ", ";
- getSrc(0)->emit(Func);
+ Src->emit(Func);
Str << "\n";
}
« no previous file with comments | « crosstest/test_global_main.cpp ('k') | src/IceTargetLowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698