Index: src/IceTargetLoweringX8632.cpp |
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
index ef9bc22f525087d8ac85bd66b4824871ba58fbab..987a59669430e1fed3b153fdb5d16873750bc6af 100644 |
--- a/src/IceTargetLoweringX8632.cpp |
+++ b/src/IceTargetLoweringX8632.cpp |
@@ -1319,7 +1319,9 @@ void TargetX8632::lowerCall(const InstCall *Instr) { |
break; |
} |
} |
- Operand *CallTarget = legalize(Instr->getCallTarget()); |
+ // TODO(stichnot): LEAHACK: remove Legal_All (and use default) once |
+ // a proper emitter is used. |
+ Operand *CallTarget = legalize(Instr->getCallTarget(), Legal_All); |
Inst *NewCall = InstX8632Call::create(Func, eax, CallTarget); |
Context.insert(NewCall); |
if (edx) |
@@ -2447,6 +2449,9 @@ Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed, |
} |
bool NeedsReg = |
!(Allowed & Legal_Imm) || |
+ // TODO(stichnot): LEAHACK: remove Legal_Reloc once a proper |
+ // emitter is used. |
wala
2014/06/27 21:35:25
The condition logic for NeedsReg is starting to ge
Jim Stichnoth
2014/06/28 00:28:13
I made at least a slight improvement by breaking i
|
+ (!(Allowed & Legal_Reloc) && llvm::isa<ConstantRelocatable>(From)) || |
// ConstantFloat and ConstantDouble are actually memory operands. |
(!(Allowed & Legal_Mem) && |
(From->getType() == IceType_f32 || From->getType() == IceType_f64)); |
@@ -2581,4 +2586,87 @@ template <> void ConstantDouble::emit(GlobalContext *Ctx) const { |
Str << "qword ptr [L$" << IceType_f64 << "$" << getPoolEntryID() << "]"; |
} |
+TargetGlobalInitX8632::TargetGlobalInitX8632(GlobalContext *Ctx) |
+ : TargetGlobalInitLowering(Ctx) {} |
+ |
+namespace { |
+char hexdigit(unsigned X) { return X < 10 ? '0' + X : 'A' + X - 10; } |
+} |
+ |
+void TargetGlobalInitX8632::lower(const IceString &Name, SizeT Align, |
+ bool IsInternal, bool IsConst, |
+ bool IsZeroInitializer, SizeT Size, |
+ const char *Data, bool DisableTranslation) { |
+ if (Ctx->isVerbose()) { |
+ // TODO: Consider moving the dump output into the driver to be |
+ // reused for all targets. |
+ Ostream &Str = Ctx->getStrDump(); |
+ Str << "@" << Name << " =" << (IsInternal ? " internal" : ""); |
+ if (IsConst) |
+ Str << " constant"; |
+ else |
+ Str << " global"; |
wala
2014/06/27 21:35:25
Maybe Str << (IsConst ? " constant" : " global");
Jim Stichnoth
2014/06/28 00:28:13
Done.
|
+ Str << " [" << Size << " x i8] "; |
+ if (IsZeroInitializer) { |
+ Str << "zeroinitializer"; |
+ } else { |
+ Str << "c\""; |
+ // Code taken from PrintEscapedString() in AsmWriter.cpp. Keep |
+ // the strings in the same format as the .ll file for practical |
+ // diffing. |
+ for (uint64_t i = 0; i < Size; ++i) { |
+ unsigned char C = Data[i]; |
+ if (isprint(C) && C != '\\' && C != '"') |
+ Str << C; |
+ else |
+ Str << '\\' << hexdigit(C >> 4) << hexdigit(C & 0x0F); |
+ } |
+ Str << "\""; |
+ } |
+ Str << ", align " << Align << "\n"; |
+ } |
+ |
+ if (DisableTranslation) |
+ return; |
+ |
+ Ostream &Str = Ctx->getStrEmit(); |
+ // constant: |
+ // .section .rodata,"a",@progbits |
+ // .align ALIGN |
+ // .byte ... |
+ // .size NAME, SIZE |
+ |
+ // non-constant: |
+ // .data |
+ // .align ALIGN |
+ // .byte ... |
+ // .size NAME, SIZE |
+ |
+ // zeroinitializer: |
+ // (.section or .data as above) |
+ // .comm NAME, SIZE, ALIGN |
jvoung (off chromium)
2014/06/27 19:29:27
Should this be in a .bss instead? Then it can take
Jim Stichnoth
2014/06/28 00:28:13
You may be right, but I haven't yet been able to p
jvoung (off chromium)
2014/06/28 17:00:32
Okay, what you had is right. The difference betwee
Jim Stichnoth
2014/06/29 14:33:46
Added a TODO for now about using a .bss section.
|
+ // .local NAME |
+ |
+ IceString MangledName = Ctx->mangleName(Name); |
+ // Start a new section. |
+ if (IsConst) { |
+ Str << "\t.section\t.rodata,\"a\",@progbits\n"; |
+ } else { |
+ // Str << "\t.globl\t" << MangledName << "\n"; |
jvoung (off chromium)
2014/06/28 17:00:32
If we want to support "external" for cross-testing
Jim Stichnoth
2014/06/29 14:33:46
Changed the emission to unconditionally emit .loca
|
+ Str << "\t.type\t" << MangledName << ",@object\n"; |
+ Str << "\t.data\n"; |
+ } |
+ if (IsZeroInitializer) { |
+ Str << "\t.comm\t" << MangledName << ", " << Size << ", " << Align << "\n"; |
+ Str << "\t.local\t" << MangledName << "\n"; |
+ } else { |
+ Str << "\t.align\t" << Align << "\n"; |
+ Str << MangledName << ":\n"; |
+ for (SizeT i = 0; i < Size; ++i) { |
+ Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; |
+ } |
+ Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
+ } |
+} |
+ |
} // end of namespace Ice |