Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:01

0001 /*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*/
0002 /*                                                                            */
0003 /* Part of the LLVM Project, under the Apache License v2.0 with LLVM          */
0004 /* Exceptions.                                                                */
0005 /* See https://llvm.org/LICENSE.txt for license information.                  */
0006 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    */
0007 /*                                                                            */
0008 /*===----------------------------------------------------------------------===*/
0009 /*                                                                            */
0010 /* This header declares the C interface to libLLVMTarget.a, which             */
0011 /* implements target information.                                             */
0012 /*                                                                            */
0013 /* Many exotic languages can interoperate with C code but have a harder time  */
0014 /* with C++ due to name mangling. So in addition to C, this interface enables */
0015 /* tools written in such languages.                                           */
0016 /*                                                                            */
0017 /*===----------------------------------------------------------------------===*/
0018 
0019 #ifndef LLVM_C_TARGET_H
0020 #define LLVM_C_TARGET_H
0021 
0022 #include "llvm-c/ExternC.h"
0023 #include "llvm-c/Types.h"
0024 #include "llvm/Config/llvm-config.h"
0025 
0026 LLVM_C_EXTERN_C_BEGIN
0027 
0028 /**
0029  * @defgroup LLVMCTarget Target information
0030  * @ingroup LLVMC
0031  *
0032  * @{
0033  */
0034 
0035 enum LLVMByteOrdering { LLVMBigEndian, LLVMLittleEndian };
0036 
0037 typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
0038 typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
0039 
0040 /* Declare all of the target-initialization functions that are available. */
0041 #define LLVM_TARGET(TargetName) \
0042   void LLVMInitialize##TargetName##TargetInfo(void);
0043 #include "llvm/Config/Targets.def"
0044 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
0045 
0046 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void);
0047 #include "llvm/Config/Targets.def"
0048 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
0049 
0050 #define LLVM_TARGET(TargetName) \
0051   void LLVMInitialize##TargetName##TargetMC(void);
0052 #include "llvm/Config/Targets.def"
0053 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
0054 
0055 /* Declare all of the available assembly printer initialization functions. */
0056 #define LLVM_ASM_PRINTER(TargetName) \
0057   void LLVMInitialize##TargetName##AsmPrinter(void);
0058 #include "llvm/Config/AsmPrinters.def"
0059 #undef LLVM_ASM_PRINTER  /* Explicit undef to make SWIG happier */
0060 
0061 /* Declare all of the available assembly parser initialization functions. */
0062 #define LLVM_ASM_PARSER(TargetName) \
0063   void LLVMInitialize##TargetName##AsmParser(void);
0064 #include "llvm/Config/AsmParsers.def"
0065 #undef LLVM_ASM_PARSER  /* Explicit undef to make SWIG happier */
0066 
0067 /* Declare all of the available disassembler initialization functions. */
0068 #define LLVM_DISASSEMBLER(TargetName) \
0069   void LLVMInitialize##TargetName##Disassembler(void);
0070 #include "llvm/Config/Disassemblers.def"
0071 #undef LLVM_DISASSEMBLER  /* Explicit undef to make SWIG happier */
0072 
0073 /** LLVMInitializeAllTargetInfos - The main program should call this function if
0074     it wants access to all available targets that LLVM is configured to
0075     support. */
0076 static inline void LLVMInitializeAllTargetInfos(void) {
0077 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
0078 #include "llvm/Config/Targets.def"
0079 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
0080 }
0081 
0082 /** LLVMInitializeAllTargets - The main program should call this function if it
0083     wants to link in all available targets that LLVM is configured to
0084     support. */
0085 static inline void LLVMInitializeAllTargets(void) {
0086 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
0087 #include "llvm/Config/Targets.def"
0088 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
0089 }
0090 
0091 /** LLVMInitializeAllTargetMCs - The main program should call this function if
0092     it wants access to all available target MC that LLVM is configured to
0093     support. */
0094 static inline void LLVMInitializeAllTargetMCs(void) {
0095 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
0096 #include "llvm/Config/Targets.def"
0097 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
0098 }
0099 
0100 /** LLVMInitializeAllAsmPrinters - The main program should call this function if
0101     it wants all asm printers that LLVM is configured to support, to make them
0102     available via the TargetRegistry. */
0103 static inline void LLVMInitializeAllAsmPrinters(void) {
0104 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
0105 #include "llvm/Config/AsmPrinters.def"
0106 #undef LLVM_ASM_PRINTER  /* Explicit undef to make SWIG happier */
0107 }
0108 
0109 /** LLVMInitializeAllAsmParsers - The main program should call this function if
0110     it wants all asm parsers that LLVM is configured to support, to make them
0111     available via the TargetRegistry. */
0112 static inline void LLVMInitializeAllAsmParsers(void) {
0113 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
0114 #include "llvm/Config/AsmParsers.def"
0115 #undef LLVM_ASM_PARSER  /* Explicit undef to make SWIG happier */
0116 }
0117 
0118 /** LLVMInitializeAllDisassemblers - The main program should call this function
0119     if it wants all disassemblers that LLVM is configured to support, to make
0120     them available via the TargetRegistry. */
0121 static inline void LLVMInitializeAllDisassemblers(void) {
0122 #define LLVM_DISASSEMBLER(TargetName) \
0123   LLVMInitialize##TargetName##Disassembler();
0124 #include "llvm/Config/Disassemblers.def"
0125 #undef LLVM_DISASSEMBLER  /* Explicit undef to make SWIG happier */
0126 }
0127 
0128 /** LLVMInitializeNativeTarget - The main program should call this function to
0129     initialize the native target corresponding to the host.  This is useful
0130     for JIT applications to ensure that the target gets linked in correctly. */
0131 static inline LLVMBool LLVMInitializeNativeTarget(void) {
0132   /* If we have a native target, initialize it to ensure it is linked in. */
0133 #ifdef LLVM_NATIVE_TARGET
0134   LLVM_NATIVE_TARGETINFO();
0135   LLVM_NATIVE_TARGET();
0136   LLVM_NATIVE_TARGETMC();
0137   return 0;
0138 #else
0139   return 1;
0140 #endif
0141 }
0142 
0143 /** LLVMInitializeNativeTargetAsmParser - The main program should call this
0144     function to initialize the parser for the native target corresponding to the
0145     host. */
0146 static inline LLVMBool LLVMInitializeNativeAsmParser(void) {
0147 #ifdef LLVM_NATIVE_ASMPARSER
0148   LLVM_NATIVE_ASMPARSER();
0149   return 0;
0150 #else
0151   return 1;
0152 #endif
0153 }
0154 
0155 /** LLVMInitializeNativeTargetAsmPrinter - The main program should call this
0156     function to initialize the printer for the native target corresponding to
0157     the host. */
0158 static inline LLVMBool LLVMInitializeNativeAsmPrinter(void) {
0159 #ifdef LLVM_NATIVE_ASMPRINTER
0160   LLVM_NATIVE_ASMPRINTER();
0161   return 0;
0162 #else
0163   return 1;
0164 #endif
0165 }
0166 
0167 /** LLVMInitializeNativeTargetDisassembler - The main program should call this
0168     function to initialize the disassembler for the native target corresponding
0169     to the host. */
0170 static inline LLVMBool LLVMInitializeNativeDisassembler(void) {
0171 #ifdef LLVM_NATIVE_DISASSEMBLER
0172   LLVM_NATIVE_DISASSEMBLER();
0173   return 0;
0174 #else
0175   return 1;
0176 #endif
0177 }
0178 
0179 /*===-- Target Data -------------------------------------------------------===*/
0180 
0181 /**
0182  * Obtain the data layout for a module.
0183  *
0184  * @see Module::getDataLayout()
0185  */
0186 LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M);
0187 
0188 /**
0189  * Set the data layout for a module.
0190  *
0191  * @see Module::setDataLayout()
0192  */
0193 void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL);
0194 
0195 /** Creates target data from a target layout string.
0196     See the constructor llvm::DataLayout::DataLayout. */
0197 LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep);
0198 
0199 /** Deallocates a TargetData.
0200     See the destructor llvm::DataLayout::~DataLayout. */
0201 void LLVMDisposeTargetData(LLVMTargetDataRef TD);
0202 
0203 /** Adds target library information to a pass manager. This does not take
0204     ownership of the target library info.
0205     See the method llvm::PassManagerBase::add. */
0206 void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
0207                               LLVMPassManagerRef PM);
0208 
0209 /** Converts target data to a target layout string. The string must be disposed
0210     with LLVMDisposeMessage.
0211     See the constructor llvm::DataLayout::DataLayout. */
0212 char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD);
0213 
0214 /** Returns the byte order of a target, either LLVMBigEndian or
0215     LLVMLittleEndian.
0216     See the method llvm::DataLayout::isLittleEndian. */
0217 enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD);
0218 
0219 /** Returns the pointer size in bytes for a target.
0220     See the method llvm::DataLayout::getPointerSize. */
0221 unsigned LLVMPointerSize(LLVMTargetDataRef TD);
0222 
0223 /** Returns the pointer size in bytes for a target for a specified
0224     address space.
0225     See the method llvm::DataLayout::getPointerSize. */
0226 unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS);
0227 
0228 /** Returns the integer type that is the same size as a pointer on a target.
0229     See the method llvm::DataLayout::getIntPtrType. */
0230 LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD);
0231 
0232 /** Returns the integer type that is the same size as a pointer on a target.
0233     This version allows the address space to be specified.
0234     See the method llvm::DataLayout::getIntPtrType. */
0235 LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS);
0236 
0237 /** Returns the integer type that is the same size as a pointer on a target.
0238     See the method llvm::DataLayout::getIntPtrType. */
0239 LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD);
0240 
0241 /** Returns the integer type that is the same size as a pointer on a target.
0242     This version allows the address space to be specified.
0243     See the method llvm::DataLayout::getIntPtrType. */
0244 LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD,
0245                                          unsigned AS);
0246 
0247 /** Computes the size of a type in bits for a target.
0248     See the method llvm::DataLayout::getTypeSizeInBits. */
0249 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty);
0250 
0251 /** Computes the storage size of a type in bytes for a target.
0252     See the method llvm::DataLayout::getTypeStoreSize. */
0253 unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
0254 
0255 /** Computes the ABI size of a type in bytes for a target.
0256     See the method llvm::DataLayout::getTypeAllocSize. */
0257 unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
0258 
0259 /** Computes the ABI alignment of a type in bytes for a target.
0260     See the method llvm::DataLayout::getTypeABISize. */
0261 unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
0262 
0263 /** Computes the call frame alignment of a type in bytes for a target.
0264     See the method llvm::DataLayout::getTypeABISize. */
0265 unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
0266 
0267 /** Computes the preferred alignment of a type in bytes for a target.
0268     See the method llvm::DataLayout::getTypeABISize. */
0269 unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
0270 
0271 /** Computes the preferred alignment of a global variable in bytes for a target.
0272     See the method llvm::DataLayout::getPreferredAlignment. */
0273 unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
0274                                         LLVMValueRef GlobalVar);
0275 
0276 /** Computes the structure element that contains the byte offset for a target.
0277     See the method llvm::StructLayout::getElementContainingOffset. */
0278 unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
0279                              unsigned long long Offset);
0280 
0281 /** Computes the byte offset of the indexed struct element for a target.
0282     See the method llvm::StructLayout::getElementContainingOffset. */
0283 unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD,
0284                                        LLVMTypeRef StructTy, unsigned Element);
0285 
0286 /**
0287  * @}
0288  */
0289 
0290 LLVM_C_EXTERN_C_END
0291 
0292 #endif