1 //===-- lib/Target/TargetELFWriterInfo.cpp - ELF Writer Info --0-*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the TargetELFWriterInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Function.h"
15 #include "llvm/Target/TargetELFWriterInfo.h"
16 #include "llvm/Target/TargetData.h"
17 #include "llvm/Target/TargetMachine.h"
20 TargetELFWriterInfo::TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {
21 is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
22 isLittleEndian = TM.getTargetData()->isLittleEndian();
25 TargetELFWriterInfo::~TargetELFWriterInfo() {}
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!");