35 return reinterpret_cast<TargetMachine *>(
P);
38 return reinterpret_cast<Target*>(
P);
41 return reinterpret_cast<LLVMTargetMachineRef>(const_cast<TargetMachine *>(
P));
44 return reinterpret_cast<LLVMTargetRef>(const_cast<Target*>(
P));
62 [&](
const Target &
T) {
return T.getName() == NameRef; });
87 return unwrap(
T)->getShortDescription();
95 return unwrap(
T)->hasTargetMachine();
99 return unwrap(
T)->hasMCAsmBackend();
103 const char *
Triple,
const char *CPU,
const char *Features,
162 std::string StringRep =
unwrap(
T)->getTargetTriple().str();
163 return strdup(StringRep.c_str());
167 std::string StringRep = std::string(
unwrap(
T)->getTargetCPU());
168 return strdup(StringRep.c_str());
172 std::string StringRep = std::string(
unwrap(
T)->getTargetFeatureString());
173 return strdup(StringRep.c_str());
178 unwrap(
T)->Options.MCOptions.AsmVerbose = VerboseAsm;
196 Mod->setDataLayout(
TM->createDataLayout());
207 if (
TM->addPassesToEmitFile(
pass, OS,
nullptr, ft)) {
208 error =
"TargetMachine can't emit a file of this type";
262 for (
auto &
F : HostFeatures)
265 return strdup(Features.
getString().c_str());
A parsed version of the target data layout string in and methods for querying it.
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
A Module instance is used to store all the information related to an LLVM module.
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
char * LLVMGetDefaultTargetTriple(void)
Get a triple for the host machine as a string.
std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
std::string getString() const
Returns features as a string.
A raw_ostream that writes to an SmallVector or SmallString.
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
LLVMTargetDataRef LLVMCreateTargetDataLayout(LLVMTargetMachineRef T)
Create a DataLayout based on the targetMachine.
char * LLVMGetHostCPUName(void)
Get the host CPU as a string.
LLVMTargetRef LLVMGetTargetMachineTarget(LLVMTargetMachineRef T)
Returns the Target used in a TargetMachine.
LLVMBool LLVMTargetHasAsmBackend(LLVMTargetRef T)
Returns if the target as an ASM backend (required for emitting output)
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Attribute unwrap(LLVMAttributeRef Attr)
void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T, LLVMBool VerboseAsm)
Set the target machine's ASM verbosity.
void AddFeature(StringRef String, bool Enable=true)
Adds Features.
const char * LLVMGetTargetName(LLVMTargetRef T)
Returns the name of a target.
static std::unique_ptr< TargetMachine > createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M)
char * LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T)
Returns the feature string used creating this target machine.
static iterator_range< iterator > targets()
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.
json::OStream allows writing well-formed JSON without materializing all structures as json::Value ahe...
static void codegen(Module *M, llvm::raw_pwrite_stream &OS, function_ref< std::unique_ptr< TargetMachine >()> TMFactory, CodeGenFileType FileType)
PassManager manages ModulePassManagers.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
llvm::StringLiteral ErrorMessage
LLVMBool LLVMGetTargetFromTriple(const char *TripleStr, LLVMTargetRef *T, char **ErrorMessage)
Finds the target corresponding to the given triple and stores it in T.
void LLVMDisposeTargetMachine(LLVMTargetMachineRef T)
Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine.
struct LLVMTarget * LLVMTargetRef
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.
static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M, raw_pwrite_stream &OS, LLVMCodeGenFileType codegen, char **ErrorMessage)
const char * LLVMGetTargetDescription(LLVMTargetRef T)
Returns the description of a target.
typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
LLVMBool LLVMTargetHasTargetMachine(LLVMTargetRef T)
Returns if the target has a TargetMachine associated.
LLVMTargetRef LLVMGetFirstTarget()
Returns the first llvm::Target in the registered targets list.
Triple - Helper class for working with autoconf configuration names.
char * LLVMGetTargetMachineTriple(LLVMTargetMachineRef T)
Returns the triple used creating this target machine.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T)
Returns the next llvm::Target given a previous one (or null if there's none)
Module.h This file contains the declarations for the Module class.
modulo schedule Modulo Schedule test pass
std::string normalize() const
Return the normalized form of this triple's string.
The access may modify the value stored in memory.
struct LLVMOpaquePassManager * LLVMPassManagerRef
char * LLVMGetTargetMachineCPU(LLVMTargetMachineRef T)
Returns the cpu used creating this target machine.
Target - Wrapper for Target specific information.
Manages the enabling and disabling of subtarget specific features.
LLVMAttributeRef wrap(Attribute Attr)
A raw_ostream that writes to a file descriptor.
StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
LLVMBool LLVMTargetHasJIT(LLVMTargetRef T)
Returns if the target has a JIT.
char * LLVMNormalizeTargetTriple(const char *triple)
Normalize a target triple.
LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, LLVMCodeModel CodeModel)
Creates a new llvm::TargetMachine.
char * LLVMGetHostCPUFeatures(void)
Get the host CPU's features as a string.
An abstract base class for streams implementations that also support a pwrite operation.
Lightweight error class with error context and mandatory checking.
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM)
Adds the target-specific analysis passes to the pass manager.
LLVMTargetRef LLVMGetTargetFromName(const char *Name)
Finds the target corresponding to the given name and stores it in T.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool getHostCPUFeatures(StringMap< bool, MallocAllocator > &Features)
getHostCPUFeatures - Get the LLVM names for the host CPU features.