clarify: stub emission depends on the version of the linker you use, it has nothing
[oota-llvm.git] / lib / Target / TargetELFWriterInfo.cpp
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   is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
22   isLittleEndian = TM.getTargetData()->isLittleEndian();
23 }
24
25 TargetELFWriterInfo::~TargetELFWriterInfo() {}
26
27 /// getFunctionAlignment - Returns the alignment for function 'F', targets
28 /// with different alignment constraints should overload this method
29 unsigned TargetELFWriterInfo::getFunctionAlignment(const Function *F) const {
30   const TargetData *TD = TM.getTargetData();
31   unsigned FnAlign = F->getAlignment();
32   unsigned TDAlign = TD->getPointerABIAlignment();
33   unsigned Align = std::max(FnAlign, TDAlign);
34   assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
35   return Align;
36 }