blob: 255a22c37cbf0cb254cc07bedfb1a960f5790c04 [file] [log] [blame]
Bruno Cardoso Lopesd00d4152009-06-11 22:13:00 +00001//===-- 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"
18using namespace llvm;
19
20TargetELFWriterInfo::TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {}
21
22TargetELFWriterInfo::~TargetELFWriterInfo() {}
23
24/// getFunctionAlignment - Returns the alignment for function 'F', targets
25/// with different alignment constraints should overload this method
26unsigned 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}