-void XCoreAsmPrinter::
-emitGlobal(const GlobalVariable *GV)
-{
- const TargetData *TD = TM.getTargetData();
-
- if (GV->hasInitializer()) {
- // Check to see if this is a special global used by LLVM, if so, emit it.
- if (EmitSpecialLLVMGlobal(GV))
- return;
-
- SwitchToSection(TAI->SectionForGlobal(GV));
-
- std::string name = Mang->getValueName(GV);
- Constant *C = GV->getInitializer();
- unsigned Align = (unsigned)TD->getPreferredTypeAlignmentShift(C->getType());
-
- // Mark the start of the global
- O << "\t.cc_top " << name << ".data," << name << "\n";
-
- switch (GV->getLinkage()) {
- case GlobalValue::AppendingLinkage:
- cerr << "AppendingLinkage is not supported by this target!\n";
- abort();
- case GlobalValue::LinkOnceAnyLinkage:
- case GlobalValue::LinkOnceODRLinkage:
- case GlobalValue::WeakAnyLinkage:
- case GlobalValue::WeakODRLinkage:
- case GlobalValue::ExternalLinkage:
- emitArrayBound(name, GV);
- emitGlobalDirective(name);
- // TODO Use COMDAT groups for LinkOnceLinkage
- if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
- O << TAI->getWeakDefDirective() << name << "\n";
- }
- // FALL THROUGH
- case GlobalValue::InternalLinkage:
- case GlobalValue::PrivateLinkage:
- break;
- case GlobalValue::GhostLinkage:
- cerr << "Should not have any unmaterialized functions!\n";
- abort();
- case GlobalValue::DLLImportLinkage:
- cerr << "DLLImport linkage is not supported by this target!\n";
- abort();
- case GlobalValue::DLLExportLinkage:
- cerr << "DLLExport linkage is not supported by this target!\n";
- abort();
- default:
- assert(0 && "Unknown linkage type!");
- }
-
- EmitAlignment(Align, GV, 2);
-
- unsigned Size = TD->getTypePaddedSize(C->getType());
- if (GV->isThreadLocal()) {
- Size *= MaxThreads;
- }
- if (TAI->hasDotTypeDotSizeDirective()) {
- O << "\t.type " << name << ",@object\n";
- O << "\t.size " << name << "," << Size << "\n";
- }
- O << name << ":\n";
-
- EmitGlobalConstant(C);
- if (GV->isThreadLocal()) {
- for (unsigned i = 1; i < MaxThreads; ++i) {
- EmitGlobalConstant(C);
- }
- }
- if (Size < 4) {
- // The ABI requires that unsigned scalar types smaller than 32 bits
- // are are padded to 32 bits.
- EmitZeros(4 - Size);
- }
-
- // Mark the end of the global
- O << "\t.cc_bottom " << name << ".data\n";
- } else {
- if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(GV);
- }
-}