2010-08-08 10:44:17 +08: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-17 04:08:03 +08:00
|
|
|
|
|
|
|
#ifndef LLVM_C_TARGET_H
|
|
|
|
#define LLVM_C_TARGET_H
|
|
|
|
|
|
|
|
#include "llvm-c/Core.h"
|
2010-08-08 10:44:17 +08:00
|
|
|
#include "llvm/Config/llvm-config.h"
|
2008-03-17 04:08:03 +08:00
|
|
|
|
2013-10-24 01:56:52 +08:00
|
|
|
#if defined(_MSC_VER) && !defined(inline)
|
|
|
|
#define inline __inline
|
|
|
|
#endif
|
|
|
|
|
2008-03-17 04:08:03 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 11:54:29 +08:00
|
|
|
/**
|
|
|
|
* @defgroup LLVMCTarget Target information
|
|
|
|
* @ingroup LLVMC
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-01-10 06:27:07 +08:00
|
|
|
enum LLVMByteOrdering { LLVMBigEndian, LLVMLittleEndian };
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
|
2011-07-26 05:20:54 +08:00
|
|
|
typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
|
2008-03-17 04:08:03 +08:00
|
|
|
|
2009-06-24 07:59:40 +08:00
|
|
|
/* Declare all of the target-initialization functions that are available. */
|
2010-07-12 13:13:35 +08:00
|
|
|
#define LLVM_TARGET(TargetName) \
|
|
|
|
void LLVMInitialize##TargetName##TargetInfo(void);
|
2009-08-18 11:03:27 +08:00
|
|
|
#include "llvm/Config/Targets.def"
|
2009-12-21 15:52:40 +08:00
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
2013-10-24 01:56:29 +08:00
|
|
|
|
2010-04-29 04:24:45 +08:00
|
|
|
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void);
|
2009-06-24 07:59:40 +08:00
|
|
|
#include "llvm/Config/Targets.def"
|
2009-12-21 15:52:40 +08:00
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
2009-06-24 07:59:40 +08:00
|
|
|
|
2011-07-15 07:50:31 +08:00
|
|
|
#define LLVM_TARGET(TargetName) \
|
2011-07-23 05:58:54 +08:00
|
|
|
void LLVMInitialize##TargetName##TargetMC(void);
|
2011-07-19 14:37:02 +08:00
|
|
|
#include "llvm/Config/Targets.def"
|
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
2013-10-24 01:56:29 +08:00
|
|
|
|
2011-11-29 08:06:55 +08:00
|
|
|
/* Declare all of the available assembly printer initialization functions. */
|
|
|
|
#define LLVM_ASM_PRINTER(TargetName) \
|
2012-05-03 00:15:32 +08:00
|
|
|
void LLVMInitialize##TargetName##AsmPrinter(void);
|
2011-11-29 08:06:55 +08:00
|
|
|
#include "llvm/Config/AsmPrinters.def"
|
2012-03-27 06:15:12 +08:00
|
|
|
#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
|
2011-11-29 08:06:55 +08:00
|
|
|
|
|
|
|
/* Declare all of the available assembly parser initialization functions. */
|
|
|
|
#define LLVM_ASM_PARSER(TargetName) \
|
2012-05-03 00:15:32 +08:00
|
|
|
void LLVMInitialize##TargetName##AsmParser(void);
|
2011-11-29 08:06:55 +08:00
|
|
|
#include "llvm/Config/AsmParsers.def"
|
2012-03-27 06:15:12 +08:00
|
|
|
#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
|
2011-11-29 08:06:55 +08:00
|
|
|
|
|
|
|
/* Declare all of the available disassembler initialization functions. */
|
|
|
|
#define LLVM_DISASSEMBLER(TargetName) \
|
2012-05-03 00:15:32 +08:00
|
|
|
void LLVMInitialize##TargetName##Disassembler(void);
|
2011-11-29 08:06:55 +08:00
|
|
|
#include "llvm/Config/Disassemblers.def"
|
2012-03-27 06:15:12 +08:00
|
|
|
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
|
2013-10-24 01:56:29 +08:00
|
|
|
|
2009-08-18 11:03:27 +08:00
|
|
|
/** LLVMInitializeAllTargetInfos - The main program should call this function if
|
|
|
|
it wants access to all available targets that LLVM is configured to
|
|
|
|
support. */
|
2013-10-15 21:04:27 +08:00
|
|
|
static inline void LLVMInitializeAllTargetInfos(void) {
|
|
|
|
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
|
|
|
|
#include "llvm/Config/Targets.def"
|
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
2009-08-18 11:03:27 +08:00
|
|
|
|
2009-06-24 07:59:40 +08:00
|
|
|
/** LLVMInitializeAllTargets - The main program should call this function if it
|
|
|
|
wants to link in all available targets that LLVM is configured to
|
|
|
|
support. */
|
2013-10-15 21:04:27 +08:00
|
|
|
static inline void LLVMInitializeAllTargets(void) {
|
|
|
|
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
|
|
|
|
#include "llvm/Config/Targets.def"
|
|
|
|
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
2011-11-29 08:06:55 +08:00
|
|
|
|
|
|
|
/** LLVMInitializeAllTargetMCs - The main program should call this function if
|
|
|
|
it wants access to all available target MC that LLVM is configured to
|
|
|
|
support. */
|
2013-10-15 21:04:27 +08:00
|
|
|
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 */
|
|
|
|
}
|
2013-10-24 01:56:29 +08:00
|
|
|
|
2011-11-29 08:06:55 +08:00
|
|
|
/** 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. */
|
2013-10-15 21:04:27 +08:00
|
|
|
static inline void LLVMInitializeAllAsmPrinters(void) {
|
|
|
|
#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
|
|
|
|
#include "llvm/Config/AsmPrinters.def"
|
|
|
|
#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
2013-10-24 01:56:29 +08:00
|
|
|
|
2011-11-29 08:06:55 +08:00
|
|
|
/** 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. */
|
2013-10-15 21:04:27 +08:00
|
|
|
static inline void LLVMInitializeAllAsmParsers(void) {
|
|
|
|
#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
|
|
|
|
#include "llvm/Config/AsmParsers.def"
|
|
|
|
#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
2013-10-24 01:56:29 +08:00
|
|
|
|
2011-11-29 08:06:55 +08:00
|
|
|
/** 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. */
|
2013-10-15 21:04:27 +08:00
|
|
|
static inline void LLVMInitializeAllDisassemblers(void) {
|
|
|
|
#define LLVM_DISASSEMBLER(TargetName) \
|
|
|
|
LLVMInitialize##TargetName##Disassembler();
|
|
|
|
#include "llvm/Config/Disassemblers.def"
|
|
|
|
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
|
|
|
|
}
|
2013-10-24 01:56:29 +08:00
|
|
|
|
2009-06-24 07:59:40 +08:00
|
|
|
/** LLVMInitializeNativeTarget - The main program should call this function to
|
2013-10-24 01:56:29 +08:00
|
|
|
initialize the native target corresponding to the host. This is useful
|
2009-06-24 07:59:40 +08:00
|
|
|
for JIT applications to ensure that the target gets linked in correctly. */
|
2010-04-30 07:27:32 +08:00
|
|
|
static inline LLVMBool LLVMInitializeNativeTarget(void) {
|
2009-06-24 07:59:40 +08:00
|
|
|
/* If we have a native target, initialize it to ensure it is linked in. */
|
2010-08-31 02:34:48 +08:00
|
|
|
#ifdef LLVM_NATIVE_TARGET
|
|
|
|
LLVM_NATIVE_TARGETINFO();
|
|
|
|
LLVM_NATIVE_TARGET();
|
2011-07-23 05:58:54 +08:00
|
|
|
LLVM_NATIVE_TARGETMC();
|
2009-06-24 07:59:40 +08:00
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return 1;
|
|
|
|
#endif
|
2013-10-24 01:56:29 +08:00
|
|
|
}
|
2008-03-17 04:08:03 +08:00
|
|
|
|
2013-11-06 17:21:35 +08:00
|
|
|
/** LLVMInitializeNativeTargetAsmParser - The main program should call this
|
|
|
|
function to initialize the parser for the native target corresponding to the
|
|
|
|
host. */
|
2013-11-06 17:45:53 +08:00
|
|
|
static inline LLVMBool LLVMInitializeNativeAsmParser(void) {
|
|
|
|
#ifdef LLVM_NATIVE_ASMPARSER
|
2013-11-06 17:21:35 +08:00
|
|
|
LLVM_NATIVE_ASMPARSER();
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/** LLVMInitializeNativeTargetAsmPrinter - The main program should call this
|
|
|
|
function to initialize the printer for the native target corresponding to
|
|
|
|
the host. */
|
2013-11-06 17:45:53 +08:00
|
|
|
static inline LLVMBool LLVMInitializeNativeAsmPrinter(void) {
|
|
|
|
#ifdef LLVM_NATIVE_ASMPRINTER
|
2013-11-06 17:21:35 +08:00
|
|
|
LLVM_NATIVE_ASMPRINTER();
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/** LLVMInitializeNativeTargetDisassembler - The main program should call this
|
|
|
|
function to initialize the disassembler for the native target corresponding
|
|
|
|
to the host. */
|
2013-11-06 17:45:53 +08:00
|
|
|
static inline LLVMBool LLVMInitializeNativeDisassembler(void) {
|
|
|
|
#ifdef LLVM_NATIVE_DISASSEMBLER
|
2013-11-06 17:21:35 +08:00
|
|
|
LLVM_NATIVE_DISASSEMBLER();
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-03-17 04:08:03 +08:00
|
|
|
/*===-- Target Data -------------------------------------------------------===*/
|
|
|
|
|
|
|
|
/** Creates target data from a target layout string.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the constructor llvm::DataLayout::DataLayout. */
|
2008-03-17 04:08:03 +08:00
|
|
|
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. */
|
2013-11-06 19:52:40 +08:00
|
|
|
void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
2011-07-26 05:20:54 +08: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. */
|
2013-11-06 19:52:40 +08:00
|
|
|
void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
|
|
|
|
LLVMPassManagerRef PM);
|
2011-07-26 05:20:54 +08:00
|
|
|
|
2008-03-17 04:08:03 +08:00
|
|
|
/** Converts target data to a target layout string. The string must be disposed
|
|
|
|
with LLVMDisposeMessage.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the constructor llvm::DataLayout::DataLayout. */
|
2013-11-06 19:52:40 +08:00
|
|
|
char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Returns the byte order of a target, either LLVMBigEndian or
|
|
|
|
LLVMLittleEndian.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::isLittleEndian. */
|
2013-11-06 19:52:40 +08:00
|
|
|
enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Returns the pointer size in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getPointerSize. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned LLVMPointerSize(LLVMTargetDataRef TD);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
2012-10-16 00:24:29 +08:00
|
|
|
/** Returns the pointer size in bytes for a target for a specified
|
|
|
|
address space.
|
|
|
|
See the method llvm::DataLayout::getPointerSize. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS);
|
2012-10-16 00:24:29 +08:00
|
|
|
|
2008-03-17 04:08:03 +08:00
|
|
|
/** Returns the integer type that is the same size as a pointer on a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getIntPtrType. */
|
2013-11-06 19:52:40 +08:00
|
|
|
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
2012-10-16 00:24:29 +08:00
|
|
|
/** Returns the integer type that is the same size as a pointer on a target.
|
|
|
|
This version allows the address space to be specified.
|
|
|
|
See the method llvm::DataLayout::getIntPtrType. */
|
2013-11-06 19:52:40 +08:00
|
|
|
LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS);
|
2012-10-16 00:24:29 +08:00
|
|
|
|
2013-10-18 02:51:01 +08:00
|
|
|
/** Returns the integer type that is the same size as a pointer on a target.
|
|
|
|
See the method llvm::DataLayout::getIntPtrType. */
|
2013-11-06 19:52:40 +08:00
|
|
|
LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD);
|
2013-10-18 02:51:01 +08:00
|
|
|
|
|
|
|
/** Returns the integer type that is the same size as a pointer on a target.
|
|
|
|
This version allows the address space to be specified.
|
|
|
|
See the method llvm::DataLayout::getIntPtrType. */
|
2013-11-06 19:52:40 +08:00
|
|
|
LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD,
|
|
|
|
unsigned AS);
|
2013-10-18 02:51:01 +08:00
|
|
|
|
2008-03-17 04:08:03 +08:00
|
|
|
/** Computes the size of a type in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getTypeSizeInBits. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Computes the storage size of a type in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getTypeStoreSize. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Computes the ABI size of a type in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getTypeAllocSize. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Computes the ABI alignment of a type in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getTypeABISize. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Computes the call frame alignment of a type in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getTypeABISize. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Computes the preferred alignment of a type in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getTypeABISize. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Computes the preferred alignment of a global variable in bytes for a target.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the method llvm::DataLayout::getPreferredAlignment. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
|
2008-03-17 04:08:03 +08:00
|
|
|
LLVMValueRef GlobalVar);
|
|
|
|
|
|
|
|
/** Computes the structure element that contains the byte offset for a target.
|
|
|
|
See the method llvm::StructLayout::getElementContainingOffset. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
|
2008-03-17 04:08:03 +08:00
|
|
|
unsigned long long Offset);
|
|
|
|
|
|
|
|
/** Computes the byte offset of the indexed struct element for a target.
|
|
|
|
See the method llvm::StructLayout::getElementContainingOffset. */
|
2013-11-06 19:52:40 +08:00
|
|
|
unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD,
|
|
|
|
LLVMTypeRef StructTy, unsigned Element);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
/** Deallocates a TargetData.
|
2012-10-09 00:38:25 +08:00
|
|
|
See the destructor llvm::DataLayout::~DataLayout. */
|
2013-11-06 19:52:40 +08:00
|
|
|
void LLVMDisposeTargetData(LLVMTargetDataRef TD);
|
2008-03-17 04:08:03 +08:00
|
|
|
|
2012-03-21 11:54:29 +08:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2013-04-05 01:40:53 +08:00
|
|
|
#endif /* defined(__cplusplus) */
|
2008-03-17 04:08:03 +08:00
|
|
|
|
|
|
|
#endif
|