| 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.
|
| + (!(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";
|
| + 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
|
| + // .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";
|
| + 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
|
|
|