LLVM  14.0.0git
TargetMachine.h
Go to the documentation of this file.
1 /*===-- llvm-c/TargetMachine.h - Target Machine Library C Interface - C++ -*-=*\
2 |* *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4 |* Exceptions. *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This header declares the C interface to the Target and TargetMachine *|
11 |* classes, which can be used to generate assembly or object files. *|
12 |* *|
13 |* Many exotic languages can interoperate with C code but have a harder time *|
14 |* with C++ due to name mangling. So in addition to C, this interface enables *|
15 |* tools written in such languages. *|
16 |* *|
17 \*===----------------------------------------------------------------------===*/
18 
19 #ifndef LLVM_C_TARGETMACHINE_H
20 #define LLVM_C_TARGETMACHINE_H
21 
22 #include "llvm-c/ExternC.h"
23 #include "llvm-c/Target.h"
24 #include "llvm-c/Types.h"
25 
27 
28 typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;
29 typedef struct LLVMTarget *LLVMTargetRef;
30 
31 typedef enum {
37 
38 typedef enum {
47 
48 typedef enum {
57 
58 typedef enum {
62 
63 /** Returns the first llvm::Target in the registered targets list. */
65 /** Returns the next llvm::Target given a previous one (or null if there's none) */
67 
68 /*===-- Target ------------------------------------------------------------===*/
69 /** Finds the target corresponding to the given name and stores it in \p T.
70  Returns 0 on success. */
72 
73 /** Finds the target corresponding to the given triple and stores it in \p T.
74  Returns 0 on success. Optionally returns any error in ErrorMessage.
75  Use LLVMDisposeMessage to dispose the message. */
76 LLVMBool LLVMGetTargetFromTriple(const char* Triple, LLVMTargetRef *T,
77  char **ErrorMessage);
78 
79 /** Returns the name of a target. See llvm::Target::getName */
80 const char *LLVMGetTargetName(LLVMTargetRef T);
81 
82 /** Returns the description of a target. See llvm::Target::getDescription */
84 
85 /** Returns if the target has a JIT */
87 
88 /** Returns if the target has a TargetMachine associated */
90 
91 /** Returns if the target as an ASM backend (required for emitting output) */
93 
94 /*===-- Target Machine ----------------------------------------------------===*/
95 /** Creates a new llvm::TargetMachine. See llvm::Target::createTargetMachine */
97  const char *Triple, const char *CPU, const char *Features,
99 
100 /** Dispose the LLVMTargetMachineRef instance generated by
101  LLVMCreateTargetMachine. */
103 
104 /** Returns the Target used in a TargetMachine */
106 
107 /** Returns the triple used creating this target machine. See
108  llvm::TargetMachine::getTriple. The result needs to be disposed with
109  LLVMDisposeMessage. */
111 
112 /** Returns the cpu used creating this target machine. See
113  llvm::TargetMachine::getCPU. The result needs to be disposed with
114  LLVMDisposeMessage. */
116 
117 /** Returns the feature string used creating this target machine. See
118  llvm::TargetMachine::getFeatureString. The result needs to be disposed with
119  LLVMDisposeMessage. */
121 
122 /** Create a DataLayout based on the targetMachine. */
124 
125 /** Set the target machine's ASM verbosity. */
127  LLVMBool VerboseAsm);
128 
129 /** Emits an asm or object file for the given module to the filename. This
130  wraps several c++ only classes (among them a file stream). Returns any
131  error in ErrorMessage. Use LLVMDisposeMessage to dispose the message. */
133  char *Filename, LLVMCodeGenFileType codegen, char **ErrorMessage);
134 
135 /** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */
137  LLVMCodeGenFileType codegen, char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf);
138 
139 /*===-- Triple ------------------------------------------------------------===*/
140 /** Get a triple for the host machine as a string. The result needs to be
141  disposed with LLVMDisposeMessage. */
142 char* LLVMGetDefaultTargetTriple(void);
143 
144 /** Normalize a target triple. The result needs to be disposed with
145  LLVMDisposeMessage. */
146 char* LLVMNormalizeTargetTriple(const char* triple);
147 
148 /** Get the host CPU as a string. The result needs to be disposed with
149  LLVMDisposeMessage. */
150 char* LLVMGetHostCPUName(void);
151 
152 /** Get the host CPU's features as a string. The result needs to be disposed
153  with LLVMDisposeMessage. */
154 char* LLVMGetHostCPUFeatures(void);
155 
156 /** Adds the target-specific analysis passes to the pass manager. */
158 
160 
161 #endif
LLVMRelocROPI_RWPI
@ LLVMRelocROPI_RWPI
Definition: TargetMachine.h:45
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
LLVMCodeModelKernel
@ LLVMCodeModelKernel
Definition: TargetMachine.h:53
LLVMTargetHasAsmBackend
LLVMBool LLVMTargetHasAsmBackend(LLVMTargetRef T)
Returns if the target as an ASM backend (required for emitting output)
Definition: TargetMachineC.cpp:98
LLVMCodeGenLevelLess
@ LLVMCodeGenLevelLess
Definition: TargetMachine.h:33
LLVMRelocDynamicNoPic
@ LLVMRelocDynamicNoPic
Definition: TargetMachine.h:42
Types.h
LLVMGetTargetMachineFeatureString
char * LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T)
Returns the feature string used creating this target machine.
Definition: TargetMachineC.cpp:171
codegen
Since we know that Vector is byte aligned and we know the element offset of we should change the load into a lve *x instead of doing a load store lve *x sequence Implement passing vectors by value into calls and receiving them as arguments GCC apparently tries to codegen
Definition: README_ALTIVEC.txt:46
LLVMCodeGenLevelNone
@ LLVMCodeGenLevelNone
Definition: TargetMachine.h:32
LLVMCodeGenOptLevel
LLVMCodeGenOptLevel
Definition: TargetMachine.h:31
LLVMCreateTargetMachine
LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, LLVMCodeModel CodeModel)
Creates a new llvm::TargetMachine.
Definition: TargetMachineC.cpp:102
LLVMGetTargetName
const char * LLVMGetTargetName(LLVMTargetRef T)
Returns the name of a target.
Definition: TargetMachineC.cpp:82
LLVMGetDefaultTargetTriple
char * LLVMGetDefaultTargetTriple(void)
Get a triple for the host machine as a string.
Definition: TargetMachineC.cpp:245
T
#define T
Definition: Mips16ISelLowering.cpp:341
LLVMCodeModelMedium
@ LLVMCodeModelMedium
Definition: TargetMachine.h:54
LLVMCodeGenLevelDefault
@ LLVMCodeGenLevelDefault
Definition: TargetMachine.h:34
LLVMNormalizeTargetTriple
char * LLVMNormalizeTargetTriple(const char *triple)
Normalize a target triple.
Definition: TargetMachineC.cpp:249
LLVMTargetDataRef
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Definition: DataLayout.h:41
LLVMCodeGenFileType
LLVMCodeGenFileType
Definition: TargetMachine.h:58
llvm::MSP430Attrs::CodeModel
CodeModel
Definition: MSP430Attributes.h:37
LLVMGetHostCPUName
char * LLVMGetHostCPUName(void)
Get the host CPU as a string.
Definition: TargetMachineC.cpp:253
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: TargetMachineC.cpp:232
LLVMCodeModelJITDefault
@ LLVMCodeModelJITDefault
Definition: TargetMachine.h:50
LLVMCreateTargetDataLayout
LLVMTargetDataRef LLVMCreateTargetDataLayout(LLVMTargetMachineRef T)
Create a DataLayout based on the targetMachine.
Definition: TargetMachineC.cpp:181
LLVMGetTargetDescription
const char * LLVMGetTargetDescription(LLVMTargetRef T)
Returns the description of a target.
Definition: TargetMachineC.cpp:86
LLVMRelocRWPI
@ LLVMRelocRWPI
Definition: TargetMachine.h:44
LLVMRelocDefault
@ LLVMRelocDefault
Definition: TargetMachine.h:39
LLVMAddAnalysisPasses
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM)
Adds the target-specific analysis passes to the pass manager.
Definition: TargetMachineC.cpp:268
LLVMAssemblyFile
@ LLVMAssemblyFile
Definition: TargetMachine.h:59
LLVMTargetRef
struct LLVMTarget * LLVMTargetRef
Definition: TargetMachine.h:29
LLVMGetFirstTarget
LLVMTargetRef LLVMGetFirstTarget(void)
Returns the first llvm::Target in the registered targets list.
Definition: TargetMachineC.cpp:47
LLVMCodeGenLevelAggressive
@ LLVMCodeGenLevelAggressive
Definition: TargetMachine.h:35
LLVMGetTargetMachineCPU
char * LLVMGetTargetMachineCPU(LLVMTargetMachineRef T)
Returns the cpu used creating this target machine.
Definition: TargetMachineC.cpp:166
Target.h
LLVMGetNextTarget
LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T)
Returns the next llvm::Target given a previous one (or null if there's none)
Definition: TargetMachineC.cpp:55
LLVMObjectFile
@ LLVMObjectFile
Definition: TargetMachine.h:60
LLVMTargetMachineRef
typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
Definition: TargetMachine.h:28
LLVMGetTargetFromName
LLVMTargetRef LLVMGetTargetFromName(const char *Name)
Finds the target corresponding to the given name and stores it in T.
Definition: TargetMachineC.cpp:59
LLVMSetTargetMachineAsmVerbosity
void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T, LLVMBool VerboseAsm)
Set the target machine's ASM verbosity.
Definition: TargetMachineC.cpp:176
LLVMPassManagerRef
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:127
LLVMGetTargetMachineTriple
char * LLVMGetTargetMachineTriple(LLVMTargetMachineRef T)
Returns the triple used creating this target machine.
Definition: TargetMachineC.cpp:161
LLVMRelocStatic
@ LLVMRelocStatic
Definition: TargetMachine.h:40
LLVMGetHostCPUFeatures
char * LLVMGetHostCPUFeatures(void)
Get the host CPU's features as a string.
Definition: TargetMachineC.cpp:257
llvm::PICLevel::Level
Level
Definition: CodeGen.h:33
LLVMGetTargetFromTriple
LLVMBool LLVMGetTargetFromTriple(const char *Triple, LLVMTargetRef *T, char **ErrorMessage)
Finds the target corresponding to the given triple and stores it in T.
Definition: TargetMachineC.cpp:66
LLVM_C_EXTERN_C_END
#define LLVM_C_EXTERN_C_END
Definition: ExternC.h:36
LLVMRelocMode
LLVMRelocMode
Definition: TargetMachine.h:38
LLVMRelocROPI
@ LLVMRelocROPI
Definition: TargetMachine.h:43
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
LLVMBool
int LLVMBool
Definition: Types.h:28
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.
Definition: TargetMachineC.cpp:219
LLVMCodeModelTiny
@ LLVMCodeModelTiny
Definition: TargetMachine.h:51
LLVMCodeModelLarge
@ LLVMCodeModelLarge
Definition: TargetMachine.h:55
LLVM_C_EXTERN_C_BEGIN
#define LLVM_C_EXTERN_C_BEGIN
Definition: ExternC.h:35
LLVMCodeModel
LLVMCodeModel
Definition: TargetMachine.h:48
LLVMTargetHasJIT
LLVMBool LLVMTargetHasJIT(LLVMTargetRef T)
Returns if the target has a JIT.
Definition: TargetMachineC.cpp:90
LLVMDisposeTargetMachine
void LLVMDisposeTargetMachine(LLVMTargetMachineRef T)
Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine.
Definition: TargetMachineC.cpp:154
LLVMRelocPIC
@ LLVMRelocPIC
Definition: TargetMachine.h:41
LLVMGetTargetMachineTarget
LLVMTargetRef LLVMGetTargetMachineTarget(LLVMTargetMachineRef T)
Returns the Target used in a TargetMachine.
Definition: TargetMachineC.cpp:156
LLVMCodeModelDefault
@ LLVMCodeModelDefault
Definition: TargetMachine.h:49
LLVMMemoryBufferRef
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
Definition: Types.h:48
LLVMTargetHasTargetMachine
LLVMBool LLVMTargetHasTargetMachine(LLVMTargetRef T)
Returns if the target has a TargetMachine associated.
Definition: TargetMachineC.cpp:94
ExternC.h
LLVMCodeModelSmall
@ LLVMCodeModelSmall
Definition: TargetMachine.h:52
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61