Module llvm_target

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.

This file enumerates variables from the LLVM configuration so that they can be in exported headers and won't override package specific directives.

Types

ByteOrdering = enum 
  BigEndian, LittleEndian
TargetDataRef = ptr object 
TargetLibraryInfoRef = ptr object 

Vars

LLVM_BINDIR: cstring
Installation directory for binary executables
LLVM_CONFIGTIME: cstring
Time at which LLVM was configured
LLVM_DATADIR: cstring
Installation directory for data files
LLVM_DEFAULT_TARGET_TRIPLE: cstring
Target triple LLVM will generate code for by default
LLVM_DOCSDIR: cstring
Installation directory for documentation
LLVM_ENABLE_THREADS: cint
Define if threads enabled
LLVM_ETCDIR: cstring
Installation directory for config files
LLVM_HAS_ATOMICS: cint
Has gcc/MSVC atomic intrinsics
LLVM_HOST_TRIPLE: cstring
Host triple LLVM will be executed on
LLVM_INCLUDEDIR: cstring
Installation directory for include files
LLVM_INFODIR: cstring
Installation directory for .info files
LLVM_MANDIR: cstring
Installation directory for man pages
LLVM_NATIVE_ARCH: proc () {.cdecl.}
LLVM architecture name for the native architecture, if available
LLVM_NATIVE_ASMPARSER: proc () {.nimcall.}
LLVM name for the native AsmParser init function, if available
LLVM_NATIVE_ASMPRINTER: proc () {.nimcall.}
LLVM name for the native AsmPrinter init function, if available
LLVM_NATIVE_DISASSEMBLER: proc () {.nimcall.}
LLVM name for the native Disassembler init function, if available
LLVM_NATIVE_TARGET: proc () {.nimcall.}
LLVM name for the native Target init function, if available
LLVM_NATIVE_TARGETINFO: proc () {.nimcall.}
LLVM name for the native TargetInfo init function, if available
LLVM_NATIVE_TARGETMC: proc () {.nimcall.}
LLVM name for the native target MC init function, if available
LLVM_ON_UNIX: cint
Define if this is Unixish platform
LLVM_ON_WIN32: cint
Define if this is Win32ish platform
LLVM_PREFIX: cstring
Installation prefix directory
LLVM_USE_INTEL_JITEVENTS: cint
Define if we have the Intel JIT API runtime support library
LLVM_USE_OPROFILE: cint
Define if we have the oprofile JIT-support library
LLVM_VERSION_MAJOR: cint
Major version of the LLVM API
LLVM_VERSION_MINOR: cint
Minor version of the LLVM API

Consts

Targets = ["R600", "SystemZ", "NVPTX", "CppBackend", "AArch64", "ARM", 
           "PowerPC", "X86"]
AsmPrinters = ["X86", "PowerPC", "ARM", "AArch64", "NVPTX", "SystemZ", "R600"]
AsmParsers = ["X86", "PowerPC", "ARM", "AArch64", "SystemZ"]
Disassemblers = ["X86", "PowerPC", "ARM", "AArch64", "SystemZ"]

Procs

proc initializeR600TargetInfo() {.importc: "LLVMInitializeR600TargetInfo", 
                                  cdecl, dynlib: dllname.}
proc initializeSystemZTargetInfo() {.importc: "LLVMInitializeSystemZTargetInfo", 
                                     cdecl, dynlib: dllname.}
proc initializeNVPTXTargetInfo() {.importc: "LLVMInitializeNVPTXTargetInfo", 
                                   cdecl, dynlib: dllname.}
proc initializeCppBackendTargetInfo() {.importc: "LLVMInitializeCppBackendTargetInfo", 
                                        cdecl, dynlib: dllname.}
proc initializeAArch64TargetInfo() {.importc: "LLVMInitializeAArch64TargetInfo", 
                                     cdecl, dynlib: dllname.}
proc initializeARMTargetInfo() {.importc: "LLVMInitializeARMTargetInfo", 
                                 cdecl, dynlib: dllname.}
proc initializePowerPCTargetInfo() {.importc: "LLVMInitializePowerPCTargetInfo", 
                                     cdecl, dynlib: dllname.}
proc initializeX86TargetInfo() {.importc: "LLVMInitializeX86TargetInfo", 
                                 cdecl, dynlib: dllname.}
proc initializeR600Target() {.importc: "LLVMInitializeR600Target", 
                              cdecl, dynlib: dllname.}
proc initializeSystemZTarget() {.importc: "LLVMInitializeSystemZTarget", 
                                 cdecl, dynlib: dllname.}
proc initializeNVPTXTarget() {.importc: "LLVMInitializeNVPTXTarget", 
                               cdecl, dynlib: dllname.}
proc initializeCppBackendTarget() {.importc: "LLVMInitializeCppBackendTarget", 
                                    cdecl, dynlib: dllname.}
proc initializeAArch64Target() {.importc: "LLVMInitializeAArch64Target", 
                                 cdecl, dynlib: dllname.}
proc initializeARMTarget() {.importc: "LLVMInitializeARMTarget", 
                             cdecl, dynlib: dllname.}
proc initializePowerPCTarget() {.importc: "LLVMInitializePowerPCTarget", 
                                 cdecl, dynlib: dllname.}
proc initializeX86Target() {.importc: "LLVMInitializeX86Target", 
                             cdecl, dynlib: dllname.}
proc initializeR600TargetMC() {.importc: "LLVMInitializeR600TargetMC", 
                                cdecl, dynlib: dllname.}
proc initializeSystemZTargetMC() {.importc: "LLVMInitializeSystemZTargetMC", 
                                   cdecl, dynlib: dllname.}
proc initializeNVPTXTargetMC() {.importc: "LLVMInitializeNVPTXTargetMC", 
                                 cdecl, dynlib: dllname.}
proc initializeCppBackendTargetMC() {.importc: "LLVMInitializeCppBackendTargetMC", 
                                      cdecl, dynlib: dllname.}
proc initializeAArch64TargetMC() {.importc: "LLVMInitializeAArch64TargetMC", 
                                   cdecl, dynlib: dllname.}
proc initializeARMTargetMC() {.importc: "LLVMInitializeARMTargetMC", 
                               cdecl, dynlib: dllname.}
proc initializePowerPCTargetMC() {.importc: "LLVMInitializePowerPCTargetMC", 
                                   cdecl, dynlib: dllname.}
proc initializeX86TargetMC() {.importc: "LLVMInitializeX86TargetMC", 
                               cdecl, dynlib: dllname.}
proc initializeX86AsmPrinter() {.importc: "LLVMInitializeX86AsmPrinter", 
                                 cdecl, dynlib: dllname.}
proc initializePowerPCAsmPrinter() {.importc: "LLVMInitializePowerPCAsmPrinter", 
                                     cdecl, dynlib: dllname.}
proc initializeARMAsmPrinter() {.importc: "LLVMInitializeARMAsmPrinter", 
                                 cdecl, dynlib: dllname.}
proc initializeAArch64AsmPrinter() {.importc: "LLVMInitializeAArch64AsmPrinter", 
                                     cdecl, dynlib: dllname.}
proc initializeNVPTXAsmPrinter() {.importc: "LLVMInitializeNVPTXAsmPrinter", 
                                   cdecl, dynlib: dllname.}
proc initializeSystemZAsmPrinter() {.importc: "LLVMInitializeSystemZAsmPrinter", 
                                     cdecl, dynlib: dllname.}
proc initializeR600AsmPrinter() {.importc: "LLVMInitializeR600AsmPrinter", 
                                  cdecl, dynlib: dllname.}
proc initializeX86AsmParser() {.importc: "LLVMInitializeX86AsmParser", 
                                cdecl, dynlib: dllname.}
proc initializePowerPCAsmParser() {.importc: "LLVMInitializePowerPCAsmParser", 
                                    cdecl, dynlib: dllname.}
proc initializeARMAsmParser() {.importc: "LLVMInitializeARMAsmParser", 
                                cdecl, dynlib: dllname.}
proc initializeAArch64AsmParser() {.importc: "LLVMInitializeAArch64AsmParser", 
                                    cdecl, dynlib: dllname.}
proc initializeSystemZAsmParser() {.importc: "LLVMInitializeSystemZAsmParser", 
                                    cdecl, dynlib: dllname.}
proc initializeX86Disassembler() {.importc: "LLVMInitializeX86Disassembler", 
                                   cdecl, dynlib: dllname.}
proc initializePowerPCDisassembler() {.importc: "LLVMInitializePowerPCDisassembler", 
                                       cdecl, dynlib: dllname.}
proc initializeARMDisassembler() {.importc: "LLVMInitializeARMDisassembler", 
                                   cdecl, dynlib: dllname.}
proc initializeAArch64Disassembler() {.importc: "LLVMInitializeAArch64Disassembler", 
                                       cdecl, dynlib: dllname.}
proc initializeSystemZDisassembler() {.importc: "LLVMInitializeSystemZDisassembler", 
                                       cdecl, dynlib: dllname.}
proc initializeAllTargetInfos() {.inline, raises: [], tags: [].}
The main program should call this function if it wants access to all available targets that LLVM is configured to support.
proc initializeAllTargets() {.inline, raises: [], tags: [].}
The main program should call this function if it wants to link in all available targets that LLVM is configured to support.
proc initializeAllTargetMCs() {.inline, raises: [], tags: [].}
The main program should call this function if it wants access to all available target MC that LLVM is configured to support.
proc initializeAllAsmPrinters() {.inline, raises: [], tags: [].}
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.
proc initializeAllAsmParsers() {.inline, raises: [], tags: [].}
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.
proc initializeAllDisassemblers() {.inline, raises: [], tags: [].}
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.
proc initializeNativeTarget(): Bool {.inline, raises: [Exception], 
                                      tags: [RootEffect].}
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.
proc initializeNativeAsmParser(): Bool {.inline, raises: [Exception], 
    tags: [RootEffect].}
The main program should call this function to initialize the parser for the native target corresponding to the host.
proc initializeNativeAsmPrinter(): Bool {.inline, raises: [Exception], 
    tags: [RootEffect].}
The main program should call this function to initialize the printer for the native target corresponding to the host.
proc initializeNativeDisassembler(): Bool {.inline, raises: [Exception], 
    tags: [RootEffect].}
The main program should call this function to initialize the disassembler for the native target corresponding to the host.
proc createTargetData(stringRep: cstring): TargetDataRef {.
    importc: "LLVMCreateTargetData", cdecl, dynlib: dllname.}
Creates target data from a target layout string.
proc addTargetData(td: TargetDataRef; pm: PassManagerRef) {.
    importc: "LLVMAddTargetData", cdecl, dynlib: dllname.}
Adds target data information to a pass manager. This does not take ownership of the target data.
proc addTargetLibraryInfo(tli: TargetLibraryInfoRef; pm: PassManagerRef) {.
    importc: "LLVMAddTargetLibraryInfo", cdecl, dynlib: dllname.}
Adds target library information to a pass manager. This does not take ownership of the target library info.
proc copyStringRepOfTargetData(td: TargetDataRef): cstring {.
    importc: "LLVMCopyStringRepOfTargetData", cdecl, dynlib: dllname.}
Converts target data to a target layout string. The string must be disposed with LLVMDisposeMessage.
proc byteOrder(td: TargetDataRef): ByteOrdering {.importc: "LLVMByteOrder", 
    cdecl, dynlib: dllname.}
Returns the byte order of a target, either LLVMBigEndian or LLVMLittleEndian.
proc pointerSize(td: TargetDataRef): cuint {.importc: "LLVMPointerSize", 
    cdecl, dynlib: dllname.}
Returns the pointer size in bytes for a target.
proc pointerSizeForAS(td: TargetDataRef; addressSpace: cuint): cuint {.
    importc: "LLVMPointerSizeForAS", cdecl, dynlib: dllname.}
Returns the pointer size in bytes for a target for a specified address space.
proc intPtrType(td: TargetDataRef): TypeRef {.importc: "LLVMIntPtrType", 
    cdecl, dynlib: dllname.}
Returns the integer type that is the same size as a pointer on a target.
proc intPtrTypeForAS(td: TargetDataRef; addressSpace: cuint): TypeRef {.
    importc: "LLVMIntPtrTypeForAS", cdecl, dynlib: dllname.}
Returns the integer type that is the same size as a pointer on a target. This version allows the address space to be specified.
proc intPtrTypeInContext(c: ContextRef; td: TargetDataRef): TypeRef {.
    importc: "LLVMIntPtrTypeInContext", cdecl, dynlib: dllname.}
Returns the integer type that is the same size as a pointer on a target.
proc intPtrTypeForASInContext(c: ContextRef; td: TargetDataRef; 
                              addressSpace: cuint): TypeRef {.
    importc: "LLVMIntPtrTypeForASInContext", cdecl, dynlib: dllname.}
Returns the integer type that is the same size as a pointer on a target. This version allows the address space to be specified.
proc SizeOfTypeInBits(td: TargetDataRef; ty: TypeRef): culonglong {.
    importc: "LLVMSizeOfTypeInBits", cdecl, dynlib: dllname.}
Computes the size of a type in bytes for a target.
proc storeSizeOfType(td: TargetDataRef; ty: TypeRef): culonglong {.
    importc: "LLVMStoreSizeOfType", cdecl, dynlib: dllname.}
Computes the storage size of a type in bytes for a target.
proc abiSizeOfType(td: TargetDataRef; ty: TypeRef): culonglong {.
    importc: "LLVMABISizeOfType", cdecl, dynlib: dllname.}
Computes the ABI size of a type in bytes for a target.
proc abiAlignmentOfType(td: TargetDataRef; ty: TypeRef): cuint {.
    importc: "LLVMABIAlignmentOfType", cdecl, dynlib: dllname.}
Computes the ABI alignment of a type in bytes for a target.
proc callFrameAlignmentOfType(td: TargetDataRef; ty: TypeRef): cuint {.
    importc: "LLVMCallFrameAlignmentOfType", cdecl, dynlib: dllname.}
Computes the call frame alignment of a type in bytes for a target.
proc preferredAlignmentOfType(td: TargetDataRef; ty: TypeRef): cuint {.
    importc: "LLVMPreferredAlignmentOfType", cdecl, dynlib: dllname.}
Computes the preferred alignment of a type in bytes for a target.
proc preferredAlignmentOfGlobal(td: TargetDataRef; globalVar: ValueRef): cuint {.
    importc: "LLVMPreferredAlignmentOfGlobal", cdecl, dynlib: dllname.}
Computes the preferred alignment of a global variable in bytes for a target.
proc elementAtOffset(td: TargetDataRef; structTy: TypeRef; offset: culonglong): cuint {.
    importc: "LLVMElementAtOffset", cdecl, dynlib: dllname.}
Computes the structure element that contains the byte offset for a target.
proc offsetOfElement(td: TargetDataRef; structTy: TypeRef; element: cuint): culonglong {.
    importc: "LLVMOffsetOfElement", cdecl, dynlib: dllname.}
Computes the byte offset of the indexed struct element for a target.
proc disposeTargetData(td: TargetDataRef) {.importc: "LLVMDisposeTargetData", 
    cdecl, dynlib: dllname.}
Deallocates a TargetData.