blob: 09c318513d7c1fac6506db820e5b68f9adc34845 [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 Lopesc997d452009-06-11 19:16:03 +000015#include "llvm/Target/TargetMachine.h"
16#include "llvm/DerivedTypes.h"
Bill Wendling40d77642007-01-27 02:54:30 +000017using namespace llvm;
18
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +000019X86ELFWriterInfo::X86ELFWriterInfo(TargetMachine &TM)
20 : TargetELFWriterInfo(TM) {
21 bool is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
22 EMachine = is64Bit ? EM_X86_64 : EM_386;
23 }
24
Bill Wendling0db1f0b2007-01-27 11:40:32 +000025X86ELFWriterInfo::~X86ELFWriterInfo() {}
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +000026
27unsigned X86ELFWriterInfo::getFunctionAlignment(const Function *F) const {
28 unsigned FnAlign = 4;
29
30 if (F->hasFnAttr(Attribute::OptimizeForSize))
31 FnAlign = 1;
32
33 if (F->getAlignment())
34 FnAlign = Log2_32(F->getAlignment());
35
36 return (1 << FnAlign);
37}