1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

TargetAsmInfo::getAddressSize() was incorrect for x86-64 and 64-bit targets

other than PPC64. Instead of fixing it, just remove it and fix all the
places that use it to use TargetData::getPointerSize() instead, as there
aren't very many. Most of the references were in DwarfWriter.cpp.

llvm-svn: 42419
This commit is contained in:
Dan Gohman 2007-09-27 23:12:31 +00:00
parent b20ff7f981
commit 50747737a5
5 changed files with 18 additions and 26 deletions

View File

@ -56,10 +56,6 @@ namespace llvm {
/// section on this target. Null if this target doesn't support zerofill.
const char *ZeroFillDirective; // Default is null.
/// AddressSize - Size of addresses used in file.
///
unsigned AddressSize; // Defaults to 4.
/// NeedsSet - True if target asm can't compute addresses on data
/// directives.
bool NeedsSet; // Defaults to false.
@ -400,9 +396,6 @@ namespace llvm {
const char *getZeroFillDirective() const {
return ZeroFillDirective;
}
unsigned getAddressSize() const {
return AddressSize;
}
bool needsSet() const {
return NeedsSet;
}

View File

@ -829,12 +829,13 @@ public:
AsmPrinter *getAsm() const { return Asm; }
MachineModuleInfo *getMMI() const { return MMI; }
const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
const TargetData *getTargetData() const { return TD; }
void PrintRelDirective(bool Force32Bit = false, bool isInSection = false)
const {
if (isInSection && TAI->getDwarfSectionOffsetDirective())
O << TAI->getDwarfSectionOffsetDirective();
else if (Force32Bit || TAI->getAddressSize() == sizeof(int32_t))
else if (Force32Bit || TD->getPointerSize() == sizeof(int32_t))
O << TAI->getData32bitsDirective();
else
O << TAI->getData64bitsDirective();
@ -969,7 +970,7 @@ public:
int stackGrowth =
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
TargetFrameInfo::StackGrowsUp ?
TAI->getAddressSize() : -TAI->getAddressSize();
TD->getPointerSize() : -TD->getPointerSize();
bool IsLocal = BaseLabel && strcmp(BaseLabel, "label") == 0;
for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
@ -1392,7 +1393,7 @@ private:
///
DIE *ConstructPointerType(CompileUnit *Unit, const std::string &Name) {
DIE Buffer(DW_TAG_pointer_type);
AddUInt(&Buffer, DW_AT_byte_size, 0, TAI->getAddressSize());
AddUInt(&Buffer, DW_AT_byte_size, 0, TD->getPointerSize());
if (!Name.empty()) AddString(&Buffer, DW_AT_name, DW_FORM_string, Name);
return Unit->AddDie(Buffer);
}
@ -2146,7 +2147,7 @@ private:
Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF version number");
EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false);
Asm->EOL("Offset Into Abbrev. Section");
Asm->EmitInt8(TAI->getAddressSize()); Asm->EOL("Address Size (in bytes)");
Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
EmitDIE(Die);
// FIXME - extra padding for gdb bug.
@ -2297,7 +2298,7 @@ private:
// Define the line address.
Asm->EmitInt8(0); Asm->EOL("Extended Op");
Asm->EmitInt8(TAI->getAddressSize() + 1); Asm->EOL("Op size");
Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
Asm->EmitInt8(DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
EmitReference("label", LabelID); Asm->EOL("Location label");
@ -2335,7 +2336,7 @@ private:
// Define last address of section.
Asm->EmitInt8(0); Asm->EOL("Extended Op");
Asm->EmitInt8(TAI->getAddressSize() + 1); Asm->EOL("Op size");
Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
Asm->EmitInt8(DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
EmitReference("section_end", j + 1); Asm->EOL("Section end label");
@ -2359,7 +2360,7 @@ private:
int stackGrowth =
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
TargetFrameInfo::StackGrowsUp ?
TAI->getAddressSize() : -TAI->getAddressSize();
TD->getPointerSize() : -TD->getPointerSize();
// Start the dwarf frame section.
Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
@ -2517,7 +2518,7 @@ private:
EmitReference("info_begin", Unit->getID());
Asm->EOL("Offset of Compilation Unit Info");
Asm->EmitInt8(TAI->getAddressSize()); Asm->EOL("Size of Address");
Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Size of Address");
Asm->EmitInt8(0); Asm->EOL("Size of Segment Descriptor");
@ -2781,7 +2782,7 @@ private:
int stackGrowth =
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
TargetFrameInfo::StackGrowsUp ?
TAI->getAddressSize() : -TAI->getAddressSize();
TD->getPointerSize() : -TD->getPointerSize();
// Begin eh frame section.
Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection());
@ -2898,7 +2899,7 @@ private:
if (EHFrameInfo.hasLandingPads) {
EmitReference("exception", EHFrameInfo.Number, true);
} else if(TAI->getAddressSize() == 8) {
} else if (TD->getPointerSize() == 8) {
Asm->EmitInt64((int)0);
} else {
Asm->EmitInt32((int)0);
@ -3183,7 +3184,7 @@ private:
for (unsigned i = 0, e = CallSites.size(); i < e; ++i)
SizeSites += Asm->SizeULEB128(CallSites[i].Action);
unsigned SizeTypes = TypeInfos.size() * TAI->getAddressSize();
unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize();
unsigned TypeOffset = sizeof(int8_t) + // Call site format
Asm->SizeULEB128(SizeSites) + // Call-site table length
@ -3244,7 +3245,7 @@ private:
Asm->EOL("Region length");
if (!S.PadLabel) {
if (TAI->getAddressSize() == sizeof(int32_t))
if (TD->getPointerSize() == sizeof(int32_t))
Asm->EmitInt32(0);
else
Asm->EmitInt64(0);
@ -3484,7 +3485,7 @@ void DIEDwarfLabel::EmitValue(DwarfDebug &DD, unsigned Form) {
/// SizeOf - Determine size of label value in bytes.
///
unsigned DIEDwarfLabel::SizeOf(const DwarfDebug &DD, unsigned Form) const {
return DD.getTargetAsmInfo()->getAddressSize();
return DD.getTargetData()->getPointerSize();
}
//===----------------------------------------------------------------------===//
@ -3498,7 +3499,7 @@ void DIEObjectLabel::EmitValue(DwarfDebug &DD, unsigned Form) {
/// SizeOf - Determine size of label value in bytes.
///
unsigned DIEObjectLabel::SizeOf(const DwarfDebug &DD, unsigned Form) const {
return DD.getTargetAsmInfo()->getAddressSize();
return DD.getTargetData()->getPointerSize();
}
//===----------------------------------------------------------------------===//
@ -3514,7 +3515,7 @@ void DIEDelta::EmitValue(DwarfDebug &DD, unsigned Form) {
///
unsigned DIEDelta::SizeOf(const DwarfDebug &DD, unsigned Form) const {
if (Form == DW_FORM_data4) return 4;
return DD.getTargetAsmInfo()->getAddressSize();
return DD.getTargetData()->getPointerSize();
}
//===----------------------------------------------------------------------===//

View File

@ -29,7 +29,6 @@ PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
AssemblerDialect = TM.getSubtargetImpl()->getAsmFlavor();
NeedsSet = true;
AddressSize = isPPC64 ? 8 : 4;
DwarfEHFrameSection =
".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
DwarfExceptionSection = ".section __DATA,__gcc_except_tab";

View File

@ -25,7 +25,6 @@ TargetAsmInfo::TargetAsmInfo() :
TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
ZeroFillDirective(0),
AddressSize(4),
NeedsSet(false),
MaxInstLength(4),
PCSymbol("$"),

View File

@ -1508,13 +1508,13 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
if (MMI && MMI->needsFrameInfo()) {
std::vector<MachineMove> &Moves = MMI->getFrameMoves();
const TargetAsmInfo *TAI = MF.getTarget().getTargetAsmInfo();
const TargetData *TD = MF.getTarget().getTargetData();
// Calculate amount of bytes used for return address storing
int stackGrowth =
(MF.getTarget().getFrameInfo()->getStackGrowthDirection() ==
TargetFrameInfo::StackGrowsUp ?
TAI->getAddressSize() : -TAI->getAddressSize());
TD->getPointerSize() : -TD->getPointerSize());
if (StackSize) {
// Show update of SP.