mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Teach TargetData to handle 'preferred' alignment for each target, and use
these alignment amounts to align scalars when we can. Patch by Scott Michel! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33409 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -241,7 +241,7 @@ void ELFWriter::EmitGlobal(GlobalVariable *GV) {
|
||||
}
|
||||
|
||||
const Type *GVType = (const Type*)GV->getType();
|
||||
unsigned Align = TM.getTargetData()->getTypeAlignment(GVType);
|
||||
unsigned Align = TM.getTargetData()->getTypeAlignmentPref(GVType);
|
||||
unsigned Size = TM.getTargetData()->getTypeSize(GVType);
|
||||
|
||||
// If this global has a zero initializer, it is part of the .bss or common
|
||||
|
||||
@@ -309,7 +309,7 @@ void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) {
|
||||
unsigned Size = TM.getTargetData()->getTypeSize(Ty);
|
||||
unsigned Align = GV->getAlignment();
|
||||
if (Align == 0)
|
||||
Align = TM.getTargetData()->getTypeAlignment(Ty);
|
||||
Align = TM.getTargetData()->getTypeAlignmentPref(Ty);
|
||||
|
||||
MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TM);
|
||||
|
||||
|
||||
@@ -123,7 +123,8 @@ MachineFunction::MachineFunction(const Function *F,
|
||||
const TargetData &TD = *TM.getTargetData();
|
||||
bool IsPic = TM.getRelocationModel() == Reloc::PIC_;
|
||||
unsigned EntrySize = IsPic ? 4 : TD.getPointerSize();
|
||||
unsigned Alignment = IsPic ? TD.getIntAlignment() : TD.getPointerAlignment();
|
||||
unsigned Alignment = IsPic ? TD.getIntABIAlignment()
|
||||
: TD.getPointerABIAlignment();
|
||||
JumpTableInfo = new MachineJumpTableInfo(EntrySize, Alignment);
|
||||
|
||||
BasicBlocks.Parent = this;
|
||||
|
||||
@@ -3029,7 +3029,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
||||
// new ones, as reuse may inhibit scheduling.
|
||||
const Type *Ty = MVT::getTypeForValueType(ExtraVT);
|
||||
unsigned TySize = (unsigned)TLI.getTargetData()->getTypeSize(Ty);
|
||||
unsigned Align = TLI.getTargetData()->getTypeAlignment(Ty);
|
||||
unsigned Align = TLI.getTargetData()->getTypeAlignmentPref(Ty);
|
||||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
int SSFI =
|
||||
MF.getFrameInfo()->CreateStackObject((unsigned)TySize, Align);
|
||||
@@ -3937,7 +3937,9 @@ SDOperand SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) {
|
||||
SDOperand SelectionDAGLegalize::CreateStackTemporary(MVT::ValueType VT) {
|
||||
MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo();
|
||||
unsigned ByteSize = MVT::getSizeInBits(VT)/8;
|
||||
int FrameIdx = FrameInfo->CreateStackObject(ByteSize, ByteSize);
|
||||
const Type *Ty = MVT::getTypeForValueType(VT);
|
||||
unsigned StackAlign = (unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty);
|
||||
int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign);
|
||||
return DAG.getFrameIndex(FrameIdx, TLI.getPointerTy());
|
||||
}
|
||||
|
||||
@@ -4242,9 +4244,12 @@ SDOperand SelectionDAGLegalize::ExpandLegalINT_TO_FP(bool isSigned,
|
||||
if (Op0.getValueType() == MVT::i32) {
|
||||
// simple 32-bit [signed|unsigned] integer to float/double expansion
|
||||
|
||||
// get the stack frame index of a 8 byte buffer
|
||||
// get the stack frame index of a 8 byte buffer, pessimistically aligned
|
||||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8);
|
||||
const Type *F64Type = MVT::getTypeForValueType(MVT::f64);
|
||||
unsigned StackAlign =
|
||||
(unsigned)TLI.getTargetData()->getTypeAlignmentPref(F64Type);
|
||||
int SSFI = MF.getFrameInfo()->CreateStackObject(8, StackAlign);
|
||||
// get address of 8 byte buffer
|
||||
SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
|
||||
// word offset constant for Hi/Lo address computation
|
||||
|
||||
@@ -244,17 +244,9 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli,
|
||||
const Type *Ty = AI->getAllocatedType();
|
||||
uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
|
||||
unsigned Align =
|
||||
std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty),
|
||||
std::max((unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty),
|
||||
AI->getAlignment());
|
||||
|
||||
// If the alignment of the value is smaller than the size of the
|
||||
// value, and if the size of the value is particularly small
|
||||
// (<= 8 bytes), round up to the size of the value for potentially
|
||||
// better performance.
|
||||
//
|
||||
// FIXME: This could be made better with a preferred alignment hook in
|
||||
// TargetData. It serves primarily to 8-byte align doubles for X86.
|
||||
if (Align < TySize && TySize <= 8) Align = TySize;
|
||||
TySize *= CUI->getZExtValue(); // Get total allocated size.
|
||||
if (TySize == 0) TySize = 1; // Don't create zero-sized stack objects.
|
||||
StaticAllocaMap[AI] =
|
||||
@@ -1729,8 +1721,9 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) {
|
||||
|
||||
const Type *Ty = I.getAllocatedType();
|
||||
uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
|
||||
unsigned Align = std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty),
|
||||
I.getAlignment());
|
||||
unsigned Align =
|
||||
std::max((unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty),
|
||||
I.getAlignment());
|
||||
|
||||
SDOperand AllocSize = getValue(I.getArraySize());
|
||||
MVT::ValueType IntPtr = TLI.getPointerTy();
|
||||
|
||||
Reference in New Issue
Block a user