Teach emitAlignment to handle explicit alignment requests by globals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-11-14 19:00:06 +00:00
parent ac7fd7fcc6
commit a1ab72daad
2 changed files with 6 additions and 3 deletions

View File

@ -137,8 +137,9 @@ namespace llvm {
/// emitAlignment - Emit an alignment directive to the specified power of /// emitAlignment - Emit an alignment directive to the specified power of
/// two boundary. For example, if you pass in 3 here, you will get an 8 /// two boundary. For example, if you pass in 3 here, you will get an 8
/// byte alignment. /// byte alignment. If a global value is specified, and if that global has
void emitAlignment(unsigned NumBits) const; /// an explicit alignment requested, it will override the alignment request.
void emitAlignment(unsigned NumBits, const GlobalValue *GV = 0) const;
/// emitZeros - Emit a block of zeros. /// emitZeros - Emit a block of zeros.
/// ///

View File

@ -35,7 +35,9 @@ void AsmPrinter::setupMachineFunction(MachineFunction &MF) {
} }
// emitAlignment - Emit an alignment directive to the specified power of two. // emitAlignment - Emit an alignment directive to the specified power of two.
void AsmPrinter::emitAlignment(unsigned NumBits) const { void AsmPrinter::emitAlignment(unsigned NumBits, const GlobalValue *GV) const {
if (GV && GV->getAlignment())
NumBits = Log2_32(GV->getAlignment());
if (NumBits == 0) return; // No need to emit alignment. if (NumBits == 0) return; // No need to emit alignment.
if (AlignmentIsInBytes) NumBits = 1 << NumBits; if (AlignmentIsInBytes) NumBits = 1 << NumBits;
O << AlignDirective << NumBits << "\n"; O << AlignDirective << NumBits << "\n";