Bruno Cardoso Lopes | d00d415 | 2009-06-11 22:13:00 +0000 | [diff] [blame^] | 1 | //===-- lib/Target/TargetELFWriterInfo.cpp - ELF Writer Info --0-*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the TargetELFWriterInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/Function.h" |
| 15 | #include "llvm/Target/TargetELFWriterInfo.h" |
| 16 | #include "llvm/Target/TargetData.h" |
| 17 | #include "llvm/Target/TargetMachine.h" |
| 18 | using namespace llvm; |
| 19 | |
| 20 | TargetELFWriterInfo::TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {} |
| 21 | |
| 22 | TargetELFWriterInfo::~TargetELFWriterInfo() {} |
| 23 | |
| 24 | /// getFunctionAlignment - Returns the alignment for function 'F', targets |
| 25 | /// with different alignment constraints should overload this method |
| 26 | unsigned TargetELFWriterInfo::getFunctionAlignment(const Function *F) const { |
| 27 | const TargetData *TD = TM.getTargetData(); |
| 28 | unsigned FnAlign = F->getAlignment(); |
| 29 | unsigned TDAlign = TD->getPointerABIAlignment(); |
| 30 | unsigned Align = std::max(FnAlign, TDAlign); |
| 31 | assert(!(Align & (Align-1)) && "Alignment is not a power of two!"); |
| 32 | return Align; |
| 33 | } |