LLVM  14.0.0git
Typedefs | Enumerations | Functions
TargetMachine.h File Reference
#include "llvm-c/ExternC.h"
#include "llvm-c/Target.h"
#include "llvm-c/Types.h"
Include dependency graph for TargetMachine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
 
typedef struct LLVMTarget * LLVMTargetRef
 

Enumerations

enum  LLVMCodeGenOptLevel { LLVMCodeGenLevelNone, LLVMCodeGenLevelLess, LLVMCodeGenLevelDefault, LLVMCodeGenLevelAggressive }
 
enum  LLVMRelocMode {
  LLVMRelocDefault, LLVMRelocStatic, LLVMRelocPIC, LLVMRelocDynamicNoPic,
  LLVMRelocROPI, LLVMRelocRWPI, LLVMRelocROPI_RWPI
}
 
enum  LLVMCodeModel {
  LLVMCodeModelDefault, LLVMCodeModelJITDefault, LLVMCodeModelTiny, LLVMCodeModelSmall,
  LLVMCodeModelKernel, LLVMCodeModelMedium, LLVMCodeModelLarge
}
 
enum  LLVMCodeGenFileType { LLVMAssemblyFile, LLVMObjectFile }
 

Functions

LLVMTargetRef LLVMGetFirstTarget (void)
 Returns the first llvm::Target in the registered targets list. More...
 
LLVMTargetRef LLVMGetNextTarget (LLVMTargetRef T)
 Returns the next llvm::Target given a previous one (or null if there's none) More...
 
LLVMTargetRef LLVMGetTargetFromName (const char *Name)
 Finds the target corresponding to the given name and stores it in T. More...
 
LLVMBool LLVMGetTargetFromTriple (const char *Triple, LLVMTargetRef *T, char **ErrorMessage)
 Finds the target corresponding to the given triple and stores it in T. More...
 
const char * LLVMGetTargetName (LLVMTargetRef T)
 Returns the name of a target. More...
 
const char * LLVMGetTargetDescription (LLVMTargetRef T)
 Returns the description of a target. More...
 
LLVMBool LLVMTargetHasJIT (LLVMTargetRef T)
 Returns if the target has a JIT. More...
 
LLVMBool LLVMTargetHasTargetMachine (LLVMTargetRef T)
 Returns if the target has a TargetMachine associated. More...
 
LLVMBool LLVMTargetHasAsmBackend (LLVMTargetRef T)
 Returns if the target as an ASM backend (required for emitting output) More...
 
LLVMTargetMachineRef LLVMCreateTargetMachine (LLVMTargetRef T, const char *Triple, const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, LLVMCodeModel CodeModel)
 Creates a new llvm::TargetMachine. More...
 
void LLVMDisposeTargetMachine (LLVMTargetMachineRef T)
 Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine. More...
 
LLVMTargetRef LLVMGetTargetMachineTarget (LLVMTargetMachineRef T)
 Returns the Target used in a TargetMachine. More...
 
char * LLVMGetTargetMachineTriple (LLVMTargetMachineRef T)
 Returns the triple used creating this target machine. More...
 
char * LLVMGetTargetMachineCPU (LLVMTargetMachineRef T)
 Returns the cpu used creating this target machine. More...
 
char * LLVMGetTargetMachineFeatureString (LLVMTargetMachineRef T)
 Returns the feature string used creating this target machine. More...
 
LLVMTargetDataRef LLVMCreateTargetDataLayout (LLVMTargetMachineRef T)
 Create a DataLayout based on the targetMachine. More...
 
void LLVMSetTargetMachineAsmVerbosity (LLVMTargetMachineRef T, LLVMBool VerboseAsm)
 Set the target machine's ASM verbosity. More...
 
LLVMBool LLVMTargetMachineEmitToFile (LLVMTargetMachineRef T, LLVMModuleRef M, char *Filename, LLVMCodeGenFileType codegen, char **ErrorMessage)
 Emits an asm or object file for the given module to the filename. More...
 
LLVMBool LLVMTargetMachineEmitToMemoryBuffer (LLVMTargetMachineRef T, LLVMModuleRef M, LLVMCodeGenFileType codegen, char **ErrorMessage, LLVMMemoryBufferRef *OutMemBuf)
 Compile the LLVM IR stored in M and store the result in OutMemBuf. More...
 
char * LLVMGetDefaultTargetTriple (void)
 Get a triple for the host machine as a string. More...
 
char * LLVMNormalizeTargetTriple (const char *triple)
 Normalize a target triple. More...
 
char * LLVMGetHostCPUName (void)
 Get the host CPU as a string. More...
 
char * LLVMGetHostCPUFeatures (void)
 Get the host CPU's features as a string. More...
 
void LLVMAddAnalysisPasses (LLVMTargetMachineRef T, LLVMPassManagerRef PM)
 Adds the target-specific analysis passes to the pass manager. More...
 

Typedef Documentation

◆ LLVMTargetMachineRef

typedef typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine* LLVMTargetMachineRef

Definition at line 28 of file TargetMachine.h.

◆ LLVMTargetRef

typedef struct LLVMTarget* LLVMTargetRef

Definition at line 29 of file TargetMachine.h.

Enumeration Type Documentation

◆ LLVMCodeGenFileType

Enumerator
LLVMAssemblyFile 
LLVMObjectFile 

Definition at line 58 of file TargetMachine.h.

◆ LLVMCodeGenOptLevel

Enumerator
LLVMCodeGenLevelNone 
LLVMCodeGenLevelLess 
LLVMCodeGenLevelDefault 
LLVMCodeGenLevelAggressive 

Definition at line 31 of file TargetMachine.h.

◆ LLVMCodeModel

Enumerator
LLVMCodeModelDefault 
LLVMCodeModelJITDefault 
LLVMCodeModelTiny 
LLVMCodeModelSmall 
LLVMCodeModelKernel 
LLVMCodeModelMedium 
LLVMCodeModelLarge 

Definition at line 48 of file TargetMachine.h.

◆ LLVMRelocMode

Enumerator
LLVMRelocDefault 
LLVMRelocStatic 
LLVMRelocPIC 
LLVMRelocDynamicNoPic 
LLVMRelocROPI 
LLVMRelocRWPI 
LLVMRelocROPI_RWPI 

Definition at line 38 of file TargetMachine.h.

Function Documentation

◆ LLVMAddAnalysisPasses()

void LLVMAddAnalysisPasses ( LLVMTargetMachineRef  T,
LLVMPassManagerRef  PM 
)

Adds the target-specific analysis passes to the pass manager.

Definition at line 268 of file TargetMachineC.cpp.

References llvm::createTargetTransformInfoWrapperPass(), T, and llvm::unwrap().

◆ LLVMCreateTargetDataLayout()

LLVMTargetDataRef LLVMCreateTargetDataLayout ( LLVMTargetMachineRef  T)

Create a DataLayout based on the targetMachine.

Definition at line 181 of file TargetMachineC.cpp.

References T, llvm::unwrap(), and llvm::wrap().

◆ LLVMCreateTargetMachine()

LLVMTargetMachineRef LLVMCreateTargetMachine ( LLVMTargetRef  T,
const char *  Triple,
const char *  CPU,
const char *  Features,
LLVMCodeGenOptLevel  Level,
LLVMRelocMode  Reloc,
LLVMCodeModel  CodeModel 
)

◆ LLVMDisposeTargetMachine()

void LLVMDisposeTargetMachine ( LLVMTargetMachineRef  T)

Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine.

Definition at line 154 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

Referenced by LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine().

◆ LLVMGetDefaultTargetTriple()

char* LLVMGetDefaultTargetTriple ( void  )

Get a triple for the host machine as a string.

The result needs to be disposed with LLVMDisposeMessage.

Definition at line 245 of file TargetMachineC.cpp.

References llvm::c_str(), and llvm::sys::getDefaultTargetTriple().

◆ LLVMGetFirstTarget()

LLVMTargetRef LLVMGetFirstTarget ( void  )

Returns the first llvm::Target in the registered targets list.

Definition at line 47 of file TargetMachineC.cpp.

References llvm::sys::path::begin(), llvm::sys::path::end(), llvm::TargetRegistry::targets(), and llvm::wrap().

◆ LLVMGetHostCPUFeatures()

char* LLVMGetHostCPUFeatures ( void  )

Get the host CPU's features as a string.

The result needs to be disposed with LLVMDisposeMessage.

Definition at line 257 of file TargetMachineC.cpp.

References llvm::SubtargetFeatures::AddFeature(), F, llvm::sys::getHostCPUFeatures(), and llvm::SubtargetFeatures::getString().

◆ LLVMGetHostCPUName()

char* LLVMGetHostCPUName ( void  )

Get the host CPU as a string.

The result needs to be disposed with LLVMDisposeMessage.

Definition at line 253 of file TargetMachineC.cpp.

References llvm::sys::getHostCPUName().

◆ LLVMGetNextTarget()

LLVMTargetRef LLVMGetNextTarget ( LLVMTargetRef  T)

Returns the next llvm::Target given a previous one (or null if there's none)

Definition at line 55 of file TargetMachineC.cpp.

References T, llvm::unwrap(), and llvm::wrap().

◆ LLVMGetTargetDescription()

const char* LLVMGetTargetDescription ( LLVMTargetRef  T)

Returns the description of a target.

See llvm::Target::getDescription

Definition at line 86 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMGetTargetFromName()

LLVMTargetRef LLVMGetTargetFromName ( const char *  Name)

Finds the target corresponding to the given name and stores it in T.

Returns 0 on success.

Definition at line 59 of file TargetMachineC.cpp.

References llvm::find_if(), I, T, llvm::TargetRegistry::targets(), and llvm::wrap().

◆ LLVMGetTargetFromTriple()

LLVMBool LLVMGetTargetFromTriple ( const char *  Triple,
LLVMTargetRef T,
char **  ErrorMessage 
)

Finds the target corresponding to the given triple and stores it in T.

Returns 0 on success. Optionally returns any error in ErrorMessage. Use LLVMDisposeMessage to dispose the message.

Definition at line 66 of file TargetMachineC.cpp.

References llvm::TargetRegistry::lookupTarget(), T, and llvm::wrap().

◆ LLVMGetTargetMachineCPU()

char* LLVMGetTargetMachineCPU ( LLVMTargetMachineRef  T)

Returns the cpu used creating this target machine.

See llvm::TargetMachine::getCPU. The result needs to be disposed with LLVMDisposeMessage.

Definition at line 166 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMGetTargetMachineFeatureString()

char* LLVMGetTargetMachineFeatureString ( LLVMTargetMachineRef  T)

Returns the feature string used creating this target machine.

See llvm::TargetMachine::getFeatureString. The result needs to be disposed with LLVMDisposeMessage.

Definition at line 171 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMGetTargetMachineTarget()

LLVMTargetRef LLVMGetTargetMachineTarget ( LLVMTargetMachineRef  T)

Returns the Target used in a TargetMachine.

Definition at line 156 of file TargetMachineC.cpp.

References T, llvm::unwrap(), and llvm::wrap().

◆ LLVMGetTargetMachineTriple()

char* LLVMGetTargetMachineTriple ( LLVMTargetMachineRef  T)

Returns the triple used creating this target machine.

See llvm::TargetMachine::getTriple. The result needs to be disposed with LLVMDisposeMessage.

Definition at line 161 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMGetTargetName()

const char* LLVMGetTargetName ( LLVMTargetRef  T)

Returns the name of a target.

See llvm::Target::getName

Definition at line 82 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMNormalizeTargetTriple()

char* LLVMNormalizeTargetTriple ( const char *  triple)

Normalize a target triple.

The result needs to be disposed with LLVMDisposeMessage.

Definition at line 249 of file TargetMachineC.cpp.

References llvm::c_str(), and llvm::Triple::normalize().

◆ LLVMSetTargetMachineAsmVerbosity()

void LLVMSetTargetMachineAsmVerbosity ( LLVMTargetMachineRef  T,
LLVMBool  VerboseAsm 
)

Set the target machine's ASM verbosity.

Definition at line 176 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMTargetHasAsmBackend()

LLVMBool LLVMTargetHasAsmBackend ( LLVMTargetRef  T)

Returns if the target as an ASM backend (required for emitting output)

Definition at line 98 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMTargetHasJIT()

LLVMBool LLVMTargetHasJIT ( LLVMTargetRef  T)

Returns if the target has a JIT.

Definition at line 90 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMTargetHasTargetMachine()

LLVMBool LLVMTargetHasTargetMachine ( LLVMTargetRef  T)

Returns if the target has a TargetMachine associated.

Definition at line 94 of file TargetMachineC.cpp.

References T, and llvm::unwrap().

◆ LLVMTargetMachineEmitToFile()

LLVMBool LLVMTargetMachineEmitToFile ( LLVMTargetMachineRef  T,
LLVMModuleRef  M,
char *  Filename,
LLVMCodeGenFileType  codegen,
char **  ErrorMessage 
)

Emits an asm or object file for the given module to the filename.

This wraps several c++ only classes (among them a file stream). Returns any error in ErrorMessage. Use LLVMDisposeMessage to dispose the message.

Definition at line 219 of file TargetMachineC.cpp.

References codegen, llvm::raw_ostream::flush(), LLVMTargetMachineEmit(), M, llvm::sys::fs::OF_None, and T.

◆ LLVMTargetMachineEmitToMemoryBuffer()

LLVMBool LLVMTargetMachineEmitToMemoryBuffer ( LLVMTargetMachineRef  T,
LLVMModuleRef  M,
LLVMCodeGenFileType  codegen,
char **  ErrorMessage,
LLVMMemoryBufferRef OutMemBuf 
)

Compile the LLVM IR stored in M and store the result in OutMemBuf.

Definition at line 232 of file TargetMachineC.cpp.

References codegen, llvm::Data, LLVMCreateMemoryBufferWithMemoryRangeCopy(), LLVMTargetMachineEmit(), M, llvm::raw_svector_ostream::str(), and T.