mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
switch more stuff onto MCSymbols
llvm-svn: 93608
This commit is contained in:
parent
921cd93e85
commit
ef45b87192
@ -729,9 +729,9 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
if (EmitSpecialLLVMGlobal(GVar))
|
||||
return;
|
||||
|
||||
std::string name = Mang->getMangledName(GVar);
|
||||
MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
|
||||
|
||||
printVisibility(name, GVar->getVisibility());
|
||||
printVisibility(GVarSym, GVar->getVisibility());
|
||||
|
||||
Constant *C = GVar->getInitializer();
|
||||
const Type *Type = C->getType();
|
||||
@ -748,14 +748,23 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||
|
||||
if (GVar->hasExternalLinkage()) {
|
||||
O << "\t.global " << name << '\n';
|
||||
O << "\t.type " << name << ", @object\n";
|
||||
O << name << ":\n";
|
||||
O << "\t.global ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
O << "\t.type ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ", @object\n";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ":\n";
|
||||
O << "\t.zero " << Size << '\n';
|
||||
} else if (GVar->hasLocalLinkage()) {
|
||||
O << MAI->getLCOMMDirective() << name << ',' << Size;
|
||||
O << MAI->getLCOMMDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << ',' << Size;
|
||||
} else {
|
||||
O << ".comm " << name << ',' << Size;
|
||||
O << ".comm ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ',' << Size;
|
||||
}
|
||||
if (VerboseAsm) {
|
||||
O << "\t\t" << MAI->getCommentString() << " '";
|
||||
@ -773,17 +782,24 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
case GlobalValue::CommonLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
O << "\t.global " << name << '\n'
|
||||
<< "\t.type " << name << ", @object\n"
|
||||
<< "\t.weak " << name << '\n';
|
||||
O << "\t.global ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << "\n\t.type ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ", @object\n\t.weak ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
break;
|
||||
case GlobalValue::AppendingLinkage:
|
||||
// FIXME: appending linkage variables should go into a section of
|
||||
// their name or something. For now, just emit them as external.
|
||||
case GlobalValue::ExternalLinkage:
|
||||
// If external or appending, declare as a global symbol
|
||||
O << "\t.global " << name << '\n'
|
||||
<< "\t.type " << name << ", @object\n";
|
||||
O << "\t.global ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << "\n\t.type ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ", @object\n";
|
||||
// FALL THROUGH
|
||||
case GlobalValue::InternalLinkage:
|
||||
case GlobalValue::PrivateLinkage:
|
||||
@ -793,7 +809,8 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
}
|
||||
|
||||
EmitAlignment(Align, GVar);
|
||||
O << name << ":";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ":";
|
||||
if (VerboseAsm) {
|
||||
O << "\t\t\t\t" << MAI->getCommentString() << " '";
|
||||
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
|
||||
@ -967,8 +984,8 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string name = Mang->getMangledName(GVar);
|
||||
printVisibility(name, GVar->getVisibility());
|
||||
MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
|
||||
printVisibility(GVarSym, GVar->getVisibility());
|
||||
|
||||
Constant *C = GVar->getInitializer();
|
||||
const Type *Type = C->getType();
|
||||
@ -989,16 +1006,25 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||
|
||||
if (GVar->hasExternalLinkage()) {
|
||||
O << "\t.globl " << name << '\n';
|
||||
O << "\t.zerofill __DATA, __common, " << name << ", "
|
||||
<< Size << ", " << Align;
|
||||
O << "\t.globl ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
O << "\t.zerofill __DATA, __common, ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ", " << Size << ", " << Align;
|
||||
} else if (GVar->hasLocalLinkage()) {
|
||||
O << MAI->getLCOMMDirective() << name << ',' << Size << ',' << Align;
|
||||
O << MAI->getLCOMMDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << ',' << Size << ',' << Align;
|
||||
} else if (!GVar->hasCommonLinkage()) {
|
||||
O << "\t.globl " << name << '\n'
|
||||
<< MAI->getWeakDefDirective() << name << '\n';
|
||||
O << "\t.globl ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n' << MAI->getWeakDefDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
EmitAlignment(Align, GVar);
|
||||
O << name << ":";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ":";
|
||||
if (VerboseAsm) {
|
||||
O << "\t\t\t\t" << MAI->getCommentString() << " ";
|
||||
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
|
||||
@ -1007,7 +1033,9 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
EmitGlobalConstant(C);
|
||||
return;
|
||||
} else {
|
||||
O << ".comm " << name << ',' << Size;
|
||||
O << ".comm ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ',' << Size;
|
||||
// Darwin 9 and above support aligned common data.
|
||||
if (Subtarget.isDarwin9())
|
||||
O << ',' << Align;
|
||||
@ -1022,31 +1050,37 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
}
|
||||
|
||||
switch (GVar->getLinkage()) {
|
||||
case GlobalValue::LinkOnceAnyLinkage:
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
case GlobalValue::CommonLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
O << "\t.globl " << name << '\n'
|
||||
<< "\t.weak_definition " << name << '\n';
|
||||
case GlobalValue::LinkOnceAnyLinkage:
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
case GlobalValue::CommonLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
O << "\t.globl ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << "\n\t.weak_definition ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
break;
|
||||
case GlobalValue::AppendingLinkage:
|
||||
case GlobalValue::AppendingLinkage:
|
||||
// FIXME: appending linkage variables should go into a section of
|
||||
// their name or something. For now, just emit them as external.
|
||||
case GlobalValue::ExternalLinkage:
|
||||
case GlobalValue::ExternalLinkage:
|
||||
// If external or appending, declare as a global symbol
|
||||
O << "\t.globl " << name << '\n';
|
||||
O << "\t.globl ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
// FALL THROUGH
|
||||
case GlobalValue::InternalLinkage:
|
||||
case GlobalValue::PrivateLinkage:
|
||||
case GlobalValue::InternalLinkage:
|
||||
case GlobalValue::PrivateLinkage:
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
llvm_unreachable("Unknown linkage type!");
|
||||
}
|
||||
|
||||
EmitAlignment(Align, GVar);
|
||||
O << name << ":";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ":";
|
||||
if (VerboseAsm) {
|
||||
O << "\t\t\t\t" << MAI->getCommentString() << " '";
|
||||
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
@ -299,12 +298,12 @@ void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
return;
|
||||
|
||||
O << "\n\n";
|
||||
std::string name = Mang->getMangledName(GVar);
|
||||
MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
|
||||
Constant *C = GVar->getInitializer();
|
||||
unsigned Size = TD->getTypeAllocSize(C->getType());
|
||||
unsigned Align = TD->getPreferredAlignment(GVar);
|
||||
|
||||
printVisibility(name, GVar->getVisibility());
|
||||
printVisibility(GVarSym, GVar->getVisibility());
|
||||
|
||||
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
|
||||
TM));
|
||||
@ -314,10 +313,15 @@ void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
(GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
|
||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||
|
||||
if (GVar->hasLocalLinkage())
|
||||
O << "\t.local " << name << '\n';
|
||||
if (GVar->hasLocalLinkage()) {
|
||||
O << "\t.local ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
O << MAI->getCOMMDirective() << name << ',' << Size;
|
||||
O << MAI->getCOMMDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << ',' << Size;
|
||||
if (MAI->getCOMMDirectiveTakesAlignment())
|
||||
O << ',' << (1 << Align);
|
||||
|
||||
@ -333,14 +337,18 @@ void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak.
|
||||
case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak.
|
||||
// Nonnull linkonce -> weak
|
||||
O << "\t.weak " << name << '\n';
|
||||
O << "\t.weak ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
break;
|
||||
case GlobalValue::AppendingLinkage:
|
||||
// FIXME: appending linkage variables should go into a section of
|
||||
// their name or something. For now, just emit them as external.
|
||||
case GlobalValue::ExternalLinkage:
|
||||
// If external or appending, declare as a global symbol
|
||||
O << MAI->getGlobalDirective() << name << '\n';
|
||||
O << MAI->getGlobalDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
// FALL THROUGH
|
||||
case GlobalValue::PrivateLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
@ -359,11 +367,16 @@ void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
EmitAlignment(Align, GVar);
|
||||
|
||||
if (MAI->hasDotTypeDotSizeDirective()) {
|
||||
O << "\t.type " << name << ",#object\n";
|
||||
O << "\t.size " << name << ',' << Size << '\n';
|
||||
O << "\t.type ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ",#object\n";
|
||||
O << "\t.size ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ',' << Size << '\n';
|
||||
}
|
||||
|
||||
O << name << ":\n";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ":\n";
|
||||
EmitGlobalConstant(C);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
||||
@ -326,14 +325,16 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
if (EmitSpecialLLVMGlobal(GVar))
|
||||
return;
|
||||
|
||||
std::string name = Mang->getMangledName(GVar);
|
||||
MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
|
||||
Constant *C = GVar->getInitializer();
|
||||
unsigned Size = TD->getTypeAllocSize(C->getType());
|
||||
unsigned Align = std::max(1U, TD->getPreferredAlignmentLog(GVar));
|
||||
|
||||
printVisibility(name, GVar->getVisibility());
|
||||
printVisibility(GVarSym, GVar->getVisibility());
|
||||
|
||||
O << "\t.type\t" << name << ",@object\n";
|
||||
O << "\t.type\t";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ",@object\n";
|
||||
|
||||
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
|
||||
TM));
|
||||
@ -344,10 +345,15 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
|
||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||
|
||||
if (GVar->hasLocalLinkage())
|
||||
O << "\t.local\t" << name << '\n';
|
||||
if (GVar->hasLocalLinkage()) {
|
||||
O << "\t.local\t";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
O << MAI->getCOMMDirective() << name << ',' << Size;
|
||||
O << MAI->getCOMMDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << ',' << Size;
|
||||
if (MAI->getCOMMDirectiveTakesAlignment())
|
||||
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
|
||||
|
||||
@ -365,7 +371,9 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
O << "\t.weak\t" << name << '\n';
|
||||
O << "\t.weak\t";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
break;
|
||||
case GlobalValue::DLLExportLinkage:
|
||||
case GlobalValue::AppendingLinkage:
|
||||
@ -373,7 +381,9 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
// their name or something. For now, just emit them as external.
|
||||
case GlobalValue::ExternalLinkage:
|
||||
// If external or appending, declare as a global symbol
|
||||
O << "\t.globl " << name << '\n';
|
||||
O << "\t.globl ";
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
// FALL THROUGH
|
||||
case GlobalValue::PrivateLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
@ -385,14 +395,18 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
|
||||
// Use 16-bit alignment by default to simplify bunch of stuff
|
||||
EmitAlignment(Align, GVar, 1);
|
||||
O << name << ":";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ":";
|
||||
if (VerboseAsm) {
|
||||
O << "\t\t\t\t" << MAI->getCommentString() << ' ';
|
||||
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
|
||||
}
|
||||
O << '\n';
|
||||
if (MAI->hasDotTypeDotSizeDirective())
|
||||
O << "\t.size\t" << name << ", " << Size << '\n';
|
||||
if (MAI->hasDotTypeDotSizeDirective()) {
|
||||
O << "\t.size\t";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ", " << Size << '\n';
|
||||
}
|
||||
|
||||
EmitGlobalConstant(C);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user