diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-02-05 01:29:18 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-02-05 01:29:18 +0000 |
| commit | a9b2525d3e0476a03658b2a0cae0c16a74dad9ac (patch) | |
| tree | c26bc5e6bf1972f2750117f1e301c15748b5977d /llvm/lib/CodeGen | |
| parent | 9d0b2f7b50e11d28ad5e8b9ef4815a39a07a5c92 (diff) | |
| download | bcm5719-llvm-a9b2525d3e0476a03658b2a0cae0c16a74dad9ac.tar.gz bcm5719-llvm-a9b2525d3e0476a03658b2a0cae0c16a74dad9ac.zip | |
Implement the AsmPrinter::getPreferredAlignmentLog method.
llvm-svn: 25978
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index db223dee179..b489df66c14 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -171,6 +171,22 @@ void AsmPrinter::EmitXXStructorList(Constant *List) { } } +/// getPreferredAlignmentLog - Return the preferred alignment of the +/// specified global, returned in log form. This includes an explicitly +/// requested alignment (if the global has one). +unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const { + unsigned Alignment = TM.getTargetData().getTypeAlignmentShift(GV->getType()); + if (GV->getAlignment() > (1U << Alignment)) + Alignment = Log2_32(GV->getAlignment()); + + if (GV->hasInitializer() && Alignment < 4) { + // If the global is not external, see if it is large. If so, give it a + // larger alignment. + if (TM.getTargetData().getTypeSize(GV->getType()->getElementType()) > 128) + Alignment = 4; // 16-byte alignment. + } + return Alignment; +} // EmitAlignment - Emit an alignment directive to the specified power of two. void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const { |

