blob: d84034b9ed4fabe5fc1f93d0f0e9e0ec7eed862c [file] [log] [blame]
Bill Wendling40d77642007-01-27 02:54:30 +00001//===-- X86ELFWriterInfo.cpp - ELF Writer Info for the X86 backend --------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bill Wendling40d77642007-01-27 02:54:30 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements ELF writer information for the X86 backend.
11//
12//===----------------------------------------------------------------------===//
13
14#include "X86ELFWriterInfo.h"
Bruno Cardoso Lopesd00d4152009-06-11 22:13:00 +000015#include "llvm/Function.h"
16#include "llvm/Target/TargetData.h"
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +000017#include "llvm/Target/TargetMachine.h"
Bill Wendling40d77642007-01-27 02:54:30 +000018using namespace llvm;
19
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +000020X86ELFWriterInfo::X86ELFWriterInfo(TargetMachine &TM)
21 : TargetELFWriterInfo(TM) {
22 bool is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
23 EMachine = is64Bit ? EM_X86_64 : EM_386;
24 }
25
Bill Wendling0db1f0b2007-01-27 11:40:32 +000026X86ELFWriterInfo::~X86ELFWriterInfo() {}
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +000027
28unsigned X86ELFWriterInfo::getFunctionAlignment(const Function *F) const {
29 unsigned FnAlign = 4;
30
31 if (F->hasFnAttr(Attribute::OptimizeForSize))
32 FnAlign = 1;
33
34 if (F->getAlignment())
35 FnAlign = Log2_32(F->getAlignment());
36
37 return (1 << FnAlign);
38}