2010-08-08 02:44:17 +00:00
|
|
|
/*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*/
|
|
|
|
/* */
|
|
|
|
/* The LLVM Compiler Infrastructure */
|
|
|
|
/* */
|
|
|
|
/* This file is distributed under the University of Illinois Open Source */
|
|
|
|
/* License. See LICENSE.TXT for details. */
|
|
|
|
/* */
|
|
|
|
/*===----------------------------------------------------------------------===*/
|
|
|
|
/* */
|
|
|
|
/* This header declares the C interface to libLLVMTarget.a, which */
|
|
|
|
/* implements target information. */
|
|
|
|
/* */
|
|
|
|
/* Many exotic languages can interoperate with C code but have a harder time */
|
|
|
|
/* with C++ due to name mangling. So in addition to C, this interface enables */
|
|
|
|
/* tools written in such languages. */
|
|
|
|
/* */
|
|
|
|
/*===----------------------------------------------------------------------===*/
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_C_TARGET_H
|
|
|
|
#define LLVM_C_TARGET_H
|
|
|
|
|
|
|
|
#include "llvm-c/Core.h"
|
2010-08-08 02:44:17 +00:00
|
|
|
#include "llvm/Config/llvm-config.h"
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 03:54:29 +00:00
|
|
|
/**
|
|
|
|
* @defgroup LLVMCTarget Target information
|
|
|
|
* @ingroup LLVMC
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-01-09 22:27:07 +00:00
|
|
|
enum LLVMByteOrdering { LLVMBigEndian, LLVMLittleEndian };
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
|
2011-07-25 21:20:54 +00:00
|
|
|
typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
|
2008-03-16 20:08:03 +00:00
|
|
|
typedef struct LLVMStructLayout *LLVMStructLayoutRef;
|
|
|
|
|
2009-06-23 23:59:40 +00:00
|
|
|
/* Declare all of the target-initialization functions that are available. */
|
2010-07-12 05:13:35 +00:00
|
|
|
#define LLVM_TARGET(TargetName) \
|
|
|
|
void LLVMInitialize##TargetName##TargetInfo(void);
|
2009-08-18 03:03:27 +00:00
|
|
|
#include "llvm/Config/Targets.def"
|
2009-12-21 07:52:40 +00:00
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
|
|
|
|
2010-04-28 20:24:45 +00:00
|
|
|
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void);
|
2009-06-23 23:59:40 +00:00
|
|
|
#include "llvm/Config/Targets.def"
|
2009-12-21 07:52:40 +00:00
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
2009-06-23 23:59:40 +00:00
|
|
|
|
2011-07-14 23:50:31 +00:00
|
|
|
#define LLVM_TARGET(TargetName) \
|
2011-07-22 21:58:54 +00:00
|
|
|
void LLVMInitialize##TargetName##TargetMC(void);
|
2011-07-19 06:37:02 +00:00
|
|
|
#include "llvm/Config/Targets.def"
|
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
|
|
|
|
2011-11-29 00:06:55 +00:00
|
|
|
/* Declare all of the available assembly printer initialization functions. */
|
|
|
|
#define LLVM_ASM_PRINTER(TargetName) \
|
2012-05-02 16:15:32 +00:00
|
|
|
void LLVMInitialize##TargetName##AsmPrinter(void);
|
2011-11-29 00:06:55 +00:00
|
|
|
#include "llvm/Config/AsmPrinters.def"
|
2012-03-26 22:15:12 +00:00
|
|
|
#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
|
2011-11-29 00:06:55 +00:00
|
|
|
|
|
|
|
/* Declare all of the available assembly parser initialization functions. */
|
|
|
|
#define LLVM_ASM_PARSER(TargetName) \
|
2012-05-02 16:15:32 +00:00
|
|
|
void LLVMInitialize##TargetName##AsmParser(void);
|
2011-11-29 00:06:55 +00:00
|
|
|
#include "llvm/Config/AsmParsers.def"
|
2012-03-26 22:15:12 +00:00
|
|
|
#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
|
2011-11-29 00:06:55 +00:00
|
|
|
|
|
|
|
/* Declare all of the available disassembler initialization functions. */
|
|
|
|
#define LLVM_DISASSEMBLER(TargetName) \
|
2012-05-02 16:15:32 +00:00
|
|
|
void LLVMInitialize##TargetName##Disassembler(void);
|
2011-11-29 00:06:55 +00:00
|
|
|
#include "llvm/Config/Disassemblers.def"
|
2012-03-26 22:15:12 +00:00
|
|
|
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
|
2011-11-29 00:06:55 +00:00
|
|
|
|
2009-08-18 03:03:27 +00:00
|
|
|
/** LLVMInitializeAllTargetInfos - The main program should call this function if
|
|
|
|
it wants access to all available targets that LLVM is configured to
|
|
|
|
support. */
|
2010-04-29 23:27:32 +00:00
|
|
|
static inline void LLVMInitializeAllTargetInfos(void) {
|
2009-08-18 03:03:27 +00:00
|
|
|
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
|
|
|
|
#include "llvm/Config/Targets.def"
|
2009-12-21 07:52:40 +00:00
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
2009-08-18 03:03:27 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 23:59:40 +00:00
|
|
|
/** LLVMInitializeAllTargets - The main program should call this function if it
|
|
|
|
wants to link in all available targets that LLVM is configured to
|
|
|
|
support. */
|
2010-04-29 23:27:32 +00:00
|
|
|
static inline void LLVMInitializeAllTargets(void) {
|
2009-06-23 23:59:40 +00:00
|
|
|
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
|
|
|
|
#include "llvm/Config/Targets.def"
|
2009-12-21 07:52:40 +00:00
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
2009-06-23 23:59:40 +00:00
|
|
|
}
|
2011-11-29 00:06:55 +00:00
|
|
|
|
|
|
|
/** LLVMInitializeAllTargetMCs - The main program should call this function if
|
|
|
|
it wants access to all available target MC that LLVM is configured to
|
|
|
|
support. */
|
|
|
|
static inline void LLVMInitializeAllTargetMCs(void) {
|
|
|
|
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
|
|
|
|
#include "llvm/Config/Targets.def"
|
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
|
|
|
|
|
|
|
/** LLVMInitializeAllAsmPrinters - The main program should call this function if
|
|
|
|
it wants all asm printers that LLVM is configured to support, to make them
|
|
|
|
available via the TargetRegistry. */
|
2012-05-02 16:15:32 +00:00
|
|
|
static inline void LLVMInitializeAllAsmPrinters(void) {
|
2011-11-29 00:06:55 +00:00
|
|
|
#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
|
|
|
|
#include "llvm/Config/AsmPrinters.def"
|
|
|
|
#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
|
|
|
|
|
|
|
/** LLVMInitializeAllAsmParsers - The main program should call this function if
|
|
|
|
it wants all asm parsers that LLVM is configured to support, to make them
|
|
|
|
available via the TargetRegistry. */
|
2012-05-02 16:15:32 +00:00
|
|
|
static inline void LLVMInitializeAllAsmParsers(void) {
|
2011-11-29 00:06:55 +00:00
|
|
|
#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
|
|
|
|
#include "llvm/Config/AsmParsers.def"
|
|
|
|
#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
|
|
|
|
|
|
|
/** LLVMInitializeAllDisassemblers - The main program should call this function
|
|
|
|
if it wants all disassemblers that LLVM is configured to support, to make
|
|
|
|
them available via the TargetRegistry. */
|
2012-05-02 16:15:32 +00:00
|
|
|
static inline void LLVMInitializeAllDisassemblers(void) {
|
2011-11-29 00:06:55 +00:00
|
|
|
#define LLVM_DISASSEMBLER(TargetName) \
|
|
|
|
LLVMInitialize##TargetName##Disassembler();
|
|
|
|
#include "llvm/Config/Disassemblers.def"
|
|
|
|
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
2009-06-23 23:59:40 +00:00
|
|
|
|
|
|
|
/** LLVMInitializeNativeTarget - The main program should call this function to
|
|
|
|
initialize the native target corresponding to the host. This is useful
|
|
|
|
for JIT applications to ensure that the target gets linked in correctly. */
|
2010-04-29 23:27:32 +00:00
|
|
|
static inline LLVMBool LLVMInitializeNativeTarget(void) {
|
2009-06-23 23:59:40 +00:00
|
|
|
/* If we have a native target, initialize it to ensure it is linked in. */
|
2010-08-30 18:34:48 +00:00
|
|
|
#ifdef LLVM_NATIVE_TARGET
|
|
|
|
LLVM_NATIVE_TARGETINFO();
|
|
|
|
LLVM_NATIVE_TARGET();
|
2011-07-22 21:58:54 +00:00
|
|
|
LLVM_NATIVE_TARGETMC();
|
2009-06-23 23:59:40 +00:00
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
/*===-- Target Data -------------------------------------------------------===*/
|
|
|
|
|
|
|
|
/** Creates target data from a target layout string.
|
|
|
|
See the constructor llvm::TargetData::TargetData. */
|
|
|
|
LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep);
|
|
|
|
|
|
|
|
/** Adds target data information to a pass manager. This does not take ownership
|
|
|
|
of the target data.
|
|
|
|
See the method llvm::PassManagerBase::add. */
|
|
|
|
void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef);
|
|
|
|
|
2011-07-25 21:20:54 +00:00
|
|
|
/** Adds target library information to a pass manager. This does not take
|
|
|
|
ownership of the target library info.
|
|
|
|
See the method llvm::PassManagerBase::add. */
|
|
|
|
void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef, LLVMPassManagerRef);
|
|
|
|
|
2008-03-16 20:08:03 +00:00
|
|
|
/** Converts target data to a target layout string. The string must be disposed
|
|
|
|
with LLVMDisposeMessage.
|
|
|
|
See the constructor llvm::TargetData::TargetData. */
|
|
|
|
char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef);
|
|
|
|
|
|
|
|
/** Returns the byte order of a target, either LLVMBigEndian or
|
|
|
|
LLVMLittleEndian.
|
|
|
|
See the method llvm::TargetData::isLittleEndian. */
|
2010-01-09 23:25:21 +00:00
|
|
|
enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef);
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
/** Returns the pointer size in bytes for a target.
|
|
|
|
See the method llvm::TargetData::getPointerSize. */
|
|
|
|
unsigned LLVMPointerSize(LLVMTargetDataRef);
|
|
|
|
|
|
|
|
/** Returns the integer type that is the same size as a pointer on a target.
|
|
|
|
See the method llvm::TargetData::getIntPtrType. */
|
|
|
|
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef);
|
|
|
|
|
|
|
|
/** Computes the size of a type in bytes for a target.
|
|
|
|
See the method llvm::TargetData::getTypeSizeInBits. */
|
|
|
|
unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef);
|
|
|
|
|
|
|
|
/** Computes the storage size of a type in bytes for a target.
|
|
|
|
See the method llvm::TargetData::getTypeStoreSize. */
|
|
|
|
unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef);
|
|
|
|
|
|
|
|
/** Computes the ABI size of a type in bytes for a target.
|
2009-05-09 07:06:46 +00:00
|
|
|
See the method llvm::TargetData::getTypeAllocSize. */
|
2008-03-16 20:08:03 +00:00
|
|
|
unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef);
|
|
|
|
|
|
|
|
/** Computes the ABI alignment of a type in bytes for a target.
|
|
|
|
See the method llvm::TargetData::getTypeABISize. */
|
|
|
|
unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
|
|
|
|
|
|
|
|
/** Computes the call frame alignment of a type in bytes for a target.
|
|
|
|
See the method llvm::TargetData::getTypeABISize. */
|
|
|
|
unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
|
|
|
|
|
|
|
|
/** Computes the preferred alignment of a type in bytes for a target.
|
|
|
|
See the method llvm::TargetData::getTypeABISize. */
|
|
|
|
unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
|
|
|
|
|
|
|
|
/** Computes the preferred alignment of a global variable in bytes for a target.
|
|
|
|
See the method llvm::TargetData::getPreferredAlignment. */
|
|
|
|
unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef,
|
|
|
|
LLVMValueRef GlobalVar);
|
|
|
|
|
|
|
|
/** Computes the structure element that contains the byte offset for a target.
|
|
|
|
See the method llvm::StructLayout::getElementContainingOffset. */
|
|
|
|
unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy,
|
|
|
|
unsigned long long Offset);
|
|
|
|
|
|
|
|
/** Computes the byte offset of the indexed struct element for a target.
|
|
|
|
See the method llvm::StructLayout::getElementContainingOffset. */
|
|
|
|
unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy,
|
|
|
|
unsigned Element);
|
|
|
|
|
|
|
|
/** Deallocates a TargetData.
|
|
|
|
See the destructor llvm::TargetData::~TargetData. */
|
|
|
|
void LLVMDisposeTargetData(LLVMTargetDataRef);
|
|
|
|
|
2012-03-21 03:54:29 +00:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class TargetData;
|
2011-07-25 21:20:54 +00:00
|
|
|
class TargetLibraryInfo;
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
inline TargetData *unwrap(LLVMTargetDataRef P) {
|
|
|
|
return reinterpret_cast<TargetData*>(P);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LLVMTargetDataRef wrap(const TargetData *P) {
|
|
|
|
return reinterpret_cast<LLVMTargetDataRef>(const_cast<TargetData*>(P));
|
|
|
|
}
|
2011-07-25 21:20:54 +00:00
|
|
|
|
|
|
|
inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) {
|
|
|
|
return reinterpret_cast<TargetLibraryInfo*>(P);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
|
|
|
|
TargetLibraryInfo *X = const_cast<TargetLibraryInfo*>(P);
|
|
|
|
return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
|
|
|
|
}
|
2008-03-16 20:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* defined(__cplusplus) */
|
|
|
|
|
|
|
|
#endif
|