mirror of
https://github.com/RPCSX/llvm.git
synced 2025-03-01 17:35:38 +00:00
For Darwin, put constant data into .const, .const_data, .literal{4|8|16}
sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35017 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f0b5d56efd
commit
98ded765c2
@ -743,7 +743,8 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
|
|||||||
|
|
||||||
std::string name = Mang->getValueName(I);
|
std::string name = Mang->getValueName(I);
|
||||||
Constant *C = I->getInitializer();
|
Constant *C = I->getInitializer();
|
||||||
unsigned Size = TD->getTypeSize(C->getType());
|
const Type *Type = C->getType();
|
||||||
|
unsigned Size = TD->getTypeSize(Type);
|
||||||
unsigned Align = TD->getPreferredAlignmentLog(I);
|
unsigned Align = TD->getPreferredAlignmentLog(I);
|
||||||
|
|
||||||
if (I->hasHiddenVisibility())
|
if (I->hasHiddenVisibility())
|
||||||
@ -829,9 +830,29 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
|
|||||||
} else {
|
} else {
|
||||||
if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection())
|
if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection())
|
||||||
SwitchToDataSection(TAI->getBSSSection(), I);
|
SwitchToDataSection(TAI->getBSSSection(), I);
|
||||||
|
else if (!I->isConstant())
|
||||||
|
SwitchToDataSection(TAI->getDataSection(), I);
|
||||||
|
else {
|
||||||
|
// Read-only data.
|
||||||
|
bool isIntFPLiteral = Type->isInteger() || Type->isFloatingPoint();
|
||||||
|
if (C->ContainsRelocations() && Subtarget->isTargetDarwin() &&
|
||||||
|
TM.getRelocationModel() != Reloc::Static)
|
||||||
|
SwitchToDataSection("\t.const_data\n");
|
||||||
|
else if (isIntFPLiteral && Size == 4 &&
|
||||||
|
TAI->getFourByteConstantSection())
|
||||||
|
SwitchToDataSection(TAI->getFourByteConstantSection(), I);
|
||||||
|
else if (isIntFPLiteral && Size == 8 &&
|
||||||
|
TAI->getEightByteConstantSection())
|
||||||
|
SwitchToDataSection(TAI->getEightByteConstantSection(), I);
|
||||||
|
else if (isIntFPLiteral && Size == 16 &&
|
||||||
|
TAI->getSixteenByteConstantSection())
|
||||||
|
SwitchToDataSection(TAI->getSixteenByteConstantSection(), I);
|
||||||
|
else if (TAI->getReadOnlySection())
|
||||||
|
SwitchToDataSection(TAI->getReadOnlySection(), I);
|
||||||
else
|
else
|
||||||
SwitchToDataSection(TAI->getDataSection(), I);
|
SwitchToDataSection(TAI->getDataSection(), I);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
|
|||||||
HiddenDirective = "\t.private_extern\t";
|
HiddenDirective = "\t.private_extern\t";
|
||||||
JumpTableDataSection = ".const";
|
JumpTableDataSection = ".const";
|
||||||
CStringSection = "\t.cstring";
|
CStringSection = "\t.cstring";
|
||||||
|
FourByteConstantSection = "\t.literal4\n";
|
||||||
|
EightByteConstantSection = "\t.literal8\n";
|
||||||
|
ReadOnlySection = "\t.const\n";
|
||||||
HasDotTypeDotSizeDirective = false;
|
HasDotTypeDotSizeDirective = false;
|
||||||
if (TM.getRelocationModel() == Reloc::Static) {
|
if (TM.getRelocationModel() == Reloc::Static) {
|
||||||
StaticCtorsSection = ".constructor";
|
StaticCtorsSection = ".constructor";
|
||||||
|
@ -893,7 +893,8 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
|
|||||||
O << Directive << name << "\n";
|
O << Directive << name << "\n";
|
||||||
|
|
||||||
Constant *C = I->getInitializer();
|
Constant *C = I->getInitializer();
|
||||||
unsigned Size = TD->getTypeSize(C->getType());
|
const Type *Type = C->getType();
|
||||||
|
unsigned Size = TD->getTypeSize(Type);
|
||||||
unsigned Align = TD->getPreferredAlignmentLog(I);
|
unsigned Align = TD->getPreferredAlignmentLog(I);
|
||||||
|
|
||||||
if (C->isNullValue() && /* FIXME: Verify correct */
|
if (C->isNullValue() && /* FIXME: Verify correct */
|
||||||
@ -937,7 +938,28 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchToDataSection("\t.data", I);
|
if (!I->isConstant())
|
||||||
|
SwitchToDataSection(TAI->getDataSection(), I);
|
||||||
|
else {
|
||||||
|
// Read-only data.
|
||||||
|
bool isIntFPLiteral = Type->isInteger() || Type->isFloatingPoint();
|
||||||
|
if (C->ContainsRelocations() &&
|
||||||
|
TM.getRelocationModel() != Reloc::Static)
|
||||||
|
SwitchToDataSection("\t.const_data\n");
|
||||||
|
else if (isIntFPLiteral && Size == 4 &&
|
||||||
|
TAI->getFourByteConstantSection())
|
||||||
|
SwitchToDataSection(TAI->getFourByteConstantSection(), I);
|
||||||
|
else if (isIntFPLiteral && Size == 8 &&
|
||||||
|
TAI->getEightByteConstantSection())
|
||||||
|
SwitchToDataSection(TAI->getEightByteConstantSection(), I);
|
||||||
|
else if (isIntFPLiteral && Size == 16 &&
|
||||||
|
TAI->getSixteenByteConstantSection())
|
||||||
|
SwitchToDataSection(TAI->getSixteenByteConstantSection(), I);
|
||||||
|
else if (TAI->getReadOnlySection())
|
||||||
|
SwitchToDataSection(TAI->getReadOnlySection(), I);
|
||||||
|
else
|
||||||
|
SwitchToDataSection(TAI->getDataSection(), I);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cerr << "Unknown linkage type!";
|
cerr << "Unknown linkage type!";
|
||||||
|
@ -57,6 +57,9 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
|
|||||||
JumpTableDataSection = ".const";
|
JumpTableDataSection = ".const";
|
||||||
GlobalDirective = "\t.globl\t";
|
GlobalDirective = "\t.globl\t";
|
||||||
CStringSection = "\t.cstring";
|
CStringSection = "\t.cstring";
|
||||||
|
FourByteConstantSection = "\t.literal4\n";
|
||||||
|
EightByteConstantSection = "\t.literal8\n";
|
||||||
|
ReadOnlySection = "\t.const\n";
|
||||||
if (TM.getRelocationModel() == Reloc::Static) {
|
if (TM.getRelocationModel() == Reloc::Static) {
|
||||||
StaticCtorsSection = ".constructor";
|
StaticCtorsSection = ".constructor";
|
||||||
StaticDtorsSection = ".destructor";
|
StaticDtorsSection = ".destructor";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user