2007-01-27 03:53:50 +01:00
|
|
|
//===-- llvm/Target/TargetELFWriterInfo.h - ELF Writer Info -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-27 03:53:50 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the TargetELFWriterInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_TARGETELFWRITERINFO_H
|
|
|
|
#define LLVM_TARGET_TARGETELFWRITERINFO_H
|
|
|
|
|
2009-06-11 21:16:03 +02:00
|
|
|
#include "llvm/Target/TargetData.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "llvm/Function.h"
|
|
|
|
|
2007-01-27 03:53:50 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// TargetELFWriterInfo
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
class TargetELFWriterInfo {
|
2009-06-11 21:16:03 +02:00
|
|
|
protected:
|
2007-01-27 03:53:50 +01:00
|
|
|
// EMachine - This field is the target specific value to emit as the
|
|
|
|
// e_machine member of the ELF header.
|
|
|
|
unsigned short EMachine;
|
2009-06-11 21:16:03 +02:00
|
|
|
TargetMachine &TM;
|
2007-01-27 03:53:50 +01:00
|
|
|
public:
|
2009-06-06 05:56:29 +02:00
|
|
|
|
|
|
|
// Machine architectures
|
2007-01-27 03:53:50 +01:00
|
|
|
enum MachineType {
|
2009-06-06 05:56:29 +02:00
|
|
|
EM_NONE = 0, // No machine
|
|
|
|
EM_M32 = 1, // AT&T WE 32100
|
|
|
|
EM_SPARC = 2, // SPARC
|
|
|
|
EM_386 = 3, // Intel 386
|
|
|
|
EM_68K = 4, // Motorola 68000
|
|
|
|
EM_88K = 5, // Motorola 88000
|
|
|
|
EM_486 = 6, // Intel 486 (deprecated)
|
|
|
|
EM_860 = 7, // Intel 80860
|
|
|
|
EM_MIPS = 8, // MIPS R3000
|
|
|
|
EM_PPC = 20, // PowerPC
|
|
|
|
EM_ARM = 40, // ARM
|
|
|
|
EM_ALPHA = 41, // DEC Alpha
|
|
|
|
EM_SPARCV9 = 43, // SPARC V9
|
|
|
|
EM_X86_64 = 62 // AMD64
|
2007-01-27 03:53:50 +01:00
|
|
|
};
|
|
|
|
|
2009-06-11 21:16:03 +02:00
|
|
|
explicit TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {}
|
2007-01-27 03:53:50 +01:00
|
|
|
virtual ~TargetELFWriterInfo() {}
|
|
|
|
|
|
|
|
unsigned short getEMachine() const { return EMachine; }
|
2009-06-11 21:16:03 +02:00
|
|
|
|
|
|
|
/// getFunctionAlignment - Returns the alignment for function 'F', targets
|
|
|
|
/// with different alignment constraints should overload this method
|
|
|
|
virtual unsigned getFunctionAlignment(const Function *F) const {
|
|
|
|
const TargetData *TD = TM.getTargetData();
|
|
|
|
unsigned FnAlign = F->getAlignment();
|
|
|
|
unsigned TDAlign = TD->getPointerABIAlignment();
|
|
|
|
unsigned Align = std::max(FnAlign, TDAlign);
|
|
|
|
assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
|
|
|
|
return Align;
|
|
|
|
}
|
2007-01-27 03:53:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end llvm namespace
|
|
|
|
|
|
|
|
#endif // LLVM_TARGET_TARGETELFWRITERINFO_H
|