1 //===-- llvm/Target/TargetELFWriterInfo.h - ELF Writer Info -----*- 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 defines the TargetELFWriterInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_TARGETELFWRITERINFO_H
15 #define LLVM_TARGET_TARGETELFWRITERINFO_H
17 #include "llvm/Target/TargetData.h"
18 #include "llvm/Target/TargetMachine.h"
19 #include "llvm/Function.h"
23 //===--------------------------------------------------------------------===//
24 // TargetELFWriterInfo
25 //===--------------------------------------------------------------------===//
27 class TargetELFWriterInfo {
29 // EMachine - This field is the target specific value to emit as the
30 // e_machine member of the ELF header.
31 unsigned short EMachine;
35 // Machine architectures
37 EM_NONE = 0, // No machine
38 EM_M32 = 1, // AT&T WE 32100
39 EM_SPARC = 2, // SPARC
40 EM_386 = 3, // Intel 386
41 EM_68K = 4, // Motorola 68000
42 EM_88K = 5, // Motorola 88000
43 EM_486 = 6, // Intel 486 (deprecated)
44 EM_860 = 7, // Intel 80860
45 EM_MIPS = 8, // MIPS R3000
46 EM_PPC = 20, // PowerPC
48 EM_ALPHA = 41, // DEC Alpha
49 EM_SPARCV9 = 43, // SPARC V9
50 EM_X86_64 = 62 // AMD64
53 explicit TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {}
54 virtual ~TargetELFWriterInfo() {}
56 unsigned short getEMachine() const { return EMachine; }
58 /// getFunctionAlignment - Returns the alignment for function 'F', targets
59 /// with different alignment constraints should overload this method
60 virtual unsigned getFunctionAlignment(const Function *F) const {
61 const TargetData *TD = TM.getTargetData();
62 unsigned FnAlign = F->getAlignment();
63 unsigned TDAlign = TD->getPointerABIAlignment();
64 unsigned Align = std::max(FnAlign, TDAlign);
65 assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
70 } // end llvm namespace
72 #endif // LLVM_TARGET_TARGETELFWRITERINFO_H