mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 02:36:06 +00:00
Fixed call stack alignment. Improved AsmPrinter alignment issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53585 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f0d286b77f
commit
b27cb55923
@ -486,9 +486,24 @@ doFinalization(Module &M)
|
|||||||
|
|
||||||
O << "\n\n";
|
O << "\n\n";
|
||||||
std::string name = Mang->getValueName(I);
|
std::string name = Mang->getValueName(I);
|
||||||
Constant *C = I->getInitializer();
|
Constant *C = I->getInitializer();
|
||||||
unsigned Size = TD->getABITypeSize(C->getType());
|
const Type *CTy = C->getType();
|
||||||
unsigned Align = TD->getPreferredAlignmentLog(I);
|
unsigned Size = TD->getABITypeSize(CTy);
|
||||||
|
bool printSizeAndType = true;
|
||||||
|
|
||||||
|
// A data structure or array is aligned in memory to the largest
|
||||||
|
// alignment boundary required by any data type inside it (this matches
|
||||||
|
// the Preferred Type Alignment). For integral types, the alignment is
|
||||||
|
// the type size.
|
||||||
|
//unsigned Align = TD->getPreferredAlignmentLog(I);
|
||||||
|
//unsigned Align = TD->getPrefTypeAlignment(C->getType());
|
||||||
|
unsigned Align;
|
||||||
|
if (CTy->getTypeID() == Type::IntegerTyID ||
|
||||||
|
CTy->getTypeID() == Type::VoidTyID) {
|
||||||
|
assert(!(Size & (Size-1)) && "Alignment is not a power of two!");
|
||||||
|
Align = Log2_32(Size);
|
||||||
|
} else
|
||||||
|
Align = TD->getPreferredTypeAlignmentShift(CTy);
|
||||||
|
|
||||||
// Is this correct ?
|
// Is this correct ?
|
||||||
if (C->isNullValue() && (I->hasLinkOnceLinkage() ||
|
if (C->isNullValue() && (I->hasLinkOnceLinkage() ||
|
||||||
@ -549,10 +564,20 @@ doFinalization(Module &M)
|
|||||||
else if (!I->isConstant())
|
else if (!I->isConstant())
|
||||||
SwitchToDataSection(TAI->getDataSection(), I);
|
SwitchToDataSection(TAI->getDataSection(), I);
|
||||||
else {
|
else {
|
||||||
// Read-only data.
|
// Read-only data. We have two possible scenary here
|
||||||
if (TAI->getReadOnlySection())
|
// 1) Readonly section for strings (char arrays).
|
||||||
|
// 2) for other types.
|
||||||
|
if (TAI->getReadOnlySection()) {
|
||||||
|
const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
|
||||||
|
if (CVA && CVA->isString()) {
|
||||||
|
std::string SectionName = "\t.section\t.rodata.str1.4,"
|
||||||
|
"\"aMS\",@progbits,1";
|
||||||
|
SwitchToDataSection(SectionName.c_str());
|
||||||
|
printSizeAndType = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
SwitchToDataSection(TAI->getReadOnlySection(), I);
|
SwitchToDataSection(TAI->getReadOnlySection(), I);
|
||||||
else
|
} else
|
||||||
SwitchToDataSection(TAI->getDataSection(), I);
|
SwitchToDataSection(TAI->getDataSection(), I);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -568,17 +593,18 @@ doFinalization(Module &M)
|
|||||||
abort();
|
abort();
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unknown linkage type!");
|
assert(0 && "Unknown linkage type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
O << "\t.align " << Align << "\n";
|
if (Align)
|
||||||
|
O << "\t.align " << Align << "\n";
|
||||||
|
|
||||||
if (TAI->hasDotTypeDotSizeDirective()) {
|
if (TAI->hasDotTypeDotSizeDirective() && printSizeAndType) {
|
||||||
O << "\t.type " << name << ",@object\n";
|
O << "\t.type " << name << ",@object\n";
|
||||||
O << "\t.size " << name << "," << Size << "\n";
|
O << "\t.size " << name << "," << Size << "\n";
|
||||||
}
|
}
|
||||||
O << name << ":\n";
|
O << name << ":\n";
|
||||||
EmitGlobalConstant(C);
|
EmitGlobalConstant(C);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
O << "\n";
|
O << "\n";
|
||||||
|
@ -370,10 +370,12 @@ LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC)
|
|||||||
SmallVector<CCValAssign, 16> ArgLocs;
|
SmallVector<CCValAssign, 16> ArgLocs;
|
||||||
CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs);
|
CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs);
|
||||||
|
|
||||||
// To meet ABI, Mips must always allocate 16 bytes on
|
// To meet O32 ABI, Mips must always allocate 16 bytes on
|
||||||
// the stack (even if less than 4 are used as arguments)
|
// the stack (even if less than 4 are used as arguments)
|
||||||
int VTsize = MVT(MVT::i32).getSizeInBits()/8;
|
if (Subtarget->isABI_O32()) {
|
||||||
MFI->CreateFixedObject(VTsize, (VTsize*3));
|
int VTsize = MVT(MVT::i32).getSizeInBits()/8;
|
||||||
|
MFI->CreateFixedObject(VTsize, (VTsize*3));
|
||||||
|
}
|
||||||
|
|
||||||
CCInfo.AnalyzeCallOperands(Op.Val, CC_Mips);
|
CCInfo.AnalyzeCallOperands(Op.Val, CC_Mips);
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ emitPrologue(MachineFunction &MF) const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// No need to allocate space on the stack.
|
// No need to allocate space on the stack.
|
||||||
if (NumBytes == 0) return;
|
if (NumBytes == 0 && !MFI->hasCalls()) return;
|
||||||
|
|
||||||
int FPOffset, RAOffset;
|
int FPOffset, RAOffset;
|
||||||
|
|
||||||
@ -389,7 +389,8 @@ void MipsRegisterInfo::
|
|||||||
processFunctionBeforeFrameFinalized(MachineFunction &MF) const {
|
processFunctionBeforeFrameFinalized(MachineFunction &MF) const {
|
||||||
// Set the SPOffset on the FI where GP must be saved/loaded.
|
// Set the SPOffset on the FI where GP must be saved/loaded.
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
if (MFI->hasCalls()) {
|
bool isPIC = (MF.getTarget().getRelocationModel() == Reloc::PIC_);
|
||||||
|
if (MFI->hasCalls() && isPIC) {
|
||||||
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
|
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DOUT << "processFunctionBeforeFrameFinalized\n";
|
DOUT << "processFunctionBeforeFrameFinalized\n";
|
||||||
|
@ -31,7 +31,7 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM) {
|
|||||||
BSSSection = "\t.section\t.bss";
|
BSSSection = "\t.section\t.bss";
|
||||||
LCOMMDirective = "\t.lcomm\t";
|
LCOMMDirective = "\t.lcomm\t";
|
||||||
|
|
||||||
if (TM.getRelocationModel() == Reloc::Static)
|
if (!TM.getSubtarget<MipsSubtarget>().hasABICall())
|
||||||
JumpTableDirective = "\t.word\t";
|
JumpTableDirective = "\t.word\t";
|
||||||
else
|
else
|
||||||
JumpTableDirective = "\t.gpword\t";
|
JumpTableDirective = "\t.gpword\t";
|
||||||
|
@ -38,8 +38,8 @@ createTargetAsmInfo() const
|
|||||||
MipsTargetMachine::
|
MipsTargetMachine::
|
||||||
MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle=false):
|
MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle=false):
|
||||||
Subtarget(*this, M, FS, isLittle),
|
Subtarget(*this, M, FS, isLittle),
|
||||||
DataLayout(isLittle ? std::string("e-p:32:32:32") :
|
DataLayout(isLittle ? std::string("e-p:32:32:32-i8:8:32-i16:16:32") :
|
||||||
std::string("E-p:32:32:32")),
|
std::string("E-p:32:32:32-i8:8:32-i16:16:32")),
|
||||||
InstrInfo(*this),
|
InstrInfo(*this),
|
||||||
FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0),
|
FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0),
|
||||||
TLInfo(*this)
|
TLInfo(*this)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user