#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/Mangler.h"
-#include "Support/Statistic.h"
-#include "Support/StringExtras.h"
-#include "Support/CommandLine.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/CommandLine.h"
#include <cctype>
using namespace llvm;
// Print out the specified constant, without a storage class. Only the
// constants valid in constant expressions can occur here.
void V8Printer::emitConstantValueOnly(const Constant *CV) {
- if (CV->isNullValue())
+ if (CV->isNullValue() || isa<UndefValue> (CV))
O << "0";
else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
assert(CB == ConstantBool::True);
uint64_t UVal;
} U;
U.FVal = Val;
- O << ".quad\t" << U.UVal << "\t! double " << Val << "\n";
+ O << ".word\t0x" << std::hex << (U.UVal >> 32) << std::dec << "\t! double " << Val << "\n";
+ O << ".word\t0x" << std::hex << (U.UVal & 0xffffffffUL) << std::dec << "\t! double " << Val << "\n";
return;
}
}
+ } else if (isa<UndefValue> (CV)) {
+ unsigned size = TD.getTypeSize (CV->getType ());
+ O << "\t.skip\t " << size << "\n";
+ return;
+ } else if (isa<ConstantAggregateZero> (CV)) {
+ unsigned size = TD.getTypeSize (CV->getType ());
+ for (unsigned i = 0; i < size; ++i)
+ O << "\t.byte 0\n";
+ return;
}
const Type *type = CV->getType();
O << ".byte";
break;
case Type::UShortTyID: case Type::ShortTyID:
- O << ".word";
+ O << ".half";
break;
case Type::FloatTyID: case Type::PointerTyID:
case Type::UIntTyID: case Type::IntTyID:
- O << ".long";
+ O << ".word";
break;
case Type::DoubleTyID:
case Type::ULongTyID: case Type::LongTyID:
- O << ".quad";
+ O << ".xword";
break;
default:
assert (0 && "Can't handle printing this type of thing");
if (CP.empty()) return;
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
- O << "\t.section .rodata\n";
+ O << "\t.section \".rodata\"\n";
O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
<< "\n";
O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t!"
if (CurSection != NewSection) {
CurSection = NewSection;
if (!CurSection.empty())
- OS << "\t.section " << NewSection << "\n";
+ OS << "\t.section \"" << NewSection << "\"\n";
}
}
std::string CurSection;
// Print out module-level global variables here.
- for (Module::const_giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
+ for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
if (I->hasInitializer()) { // External global require no code
O << "\n\n";
std::string name = Mang->getValueName(I);
// Nonnull linkonce -> weak
O << "\t.weak " << name << "\n";
SwitchSection(O, CurSection, "");
- O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
+ O << "\t.section\t\".llvm.linkonce.d." << name << "\",\"aw\",@progbits\n";
break;
case GlobalValue::AppendingLinkage:
else
SwitchSection(O, CurSection, ".data");
break;
+ case GlobalValue::GhostLinkage:
+ std::cerr << "Should not have any unmaterialized functions!\n";
+ abort();
}
O << "\t.align " << Align << "\n";