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

Unified Diff: src/IceInstX8632.cpp

Issue 543803002: Subzero: Work around another llvm-mc parser bug for relocatable symbols. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | tests_lit/llvm2ice_tests/globalinit.pnacl.ll » ('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 a1a4d68790d22d39fa6eafd5bf9d326d9b6d8e3b..1454778f39907fa6f3a4de86ccb53c1b24d6db46 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -968,16 +968,22 @@ template <> void InstX8632Mov::emit(const Cfg *Func) const {
// 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
+ // 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.
+ //
+ // In addition, llvm-mc doesn't like "lea eax, bp" or "lea eax, Sp"
+ // or "lea eax, flags" etc., when the relocatable constant name is a
+ // reserved word. The hack-on-top-of-hack is to temporarily drop
+ // into AT&T syntax for this lea instruction.
bool UseLeaHack = llvm::isa<ConstantRelocatable>(Src);
- Str << "\t";
- if (UseLeaHack)
- Str << "lea";
- else
- Str << "mov" << TypeX8632Attributes[getDest()->getType()].SdSsString;
+ if (UseLeaHack) {
+ Str << ".att_syntax\n";
+ Str << "\tleal";
+ } else {
+ Str << "\tmov" << 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
@@ -991,10 +997,18 @@ template <> void InstX8632Mov::emit(const Cfg *Func) const {
// Clean this up.
assert(Func->getTarget()->typeWidthInBytesOnStack(getDest()->getType()) ==
Func->getTarget()->typeWidthInBytesOnStack(Src->getType()));
- getDest()->asType(Src->getType()).emit(Func);
- Str << ", ";
- Src->emit(Func);
- Str << "\n";
+ if (UseLeaHack) {
+ Src->emit(Func);
+ Str << ", %";
+ getDest()->emit(Func);
+ Str << "\n";
+ Str << ".intel_syntax\n";
+ } else {
+ getDest()->asType(Src->getType()).emit(Func);
+ Str << ", ";
+ Src->emit(Func);
+ Str << "\n";
+ }
}
template <> void InstX8632Movp::emit(const Cfg *Func) const {
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/globalinit.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698