Enable PTX backend

This commit is contained in:
Siu Kwan Lam 2012-08-14 15:05:22 -07:00
commit f85713a736
7 changed files with 176 additions and 20 deletions

View file

@ -54,6 +54,7 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/IntrinsicInst.h"
@ -114,6 +115,11 @@ char *do_print(W obj)
return strdup(buf.str().c_str());
}
int LLVMInitializeNativeTargetAsmPrinter()
{
return llvm::InitializeNativeTargetAsmPrinter();
}
LLVMTargetMachineRef LLVMTargetMachineFromEngineBuilder(LLVMEngineBuilderRef eb)
{
@ -134,8 +140,6 @@ unsigned char* LLVMTargetMachineEmitFile(LLVMTargetMachineRef tmref,
using namespace llvm;
assert(lenp);
InitializeNativeTargetAsmPrinter();
Module *modulep = unwrap(modref);
assert(modulep);
@ -190,6 +194,43 @@ unsigned char* LLVMTargetMachineEmitFile(LLVMTargetMachineRef tmref,
return bytes;
}
const char* LLVMTargetMachineGetTargetName(LLVMTargetMachineRef tm)
{
return strdup(llvm::unwrap(tm)->getTarget().getName());
}
const char* LLVMTargetMachineGetTargetShortDescription(LLVMTargetMachineRef tm)
{
return strdup(llvm::unwrap(tm)->getTarget().getShortDescription());
}
const char* LLVMTargetMachineGetTriple(LLVMTargetMachineRef tm)
{
return strdup(llvm::unwrap(tm)->getTargetTriple().str().c_str());
}
const char* LLVMTargetMachineGetCPU(LLVMTargetMachineRef tm)
{
return strdup(llvm::unwrap(tm)->getTargetCPU().str().c_str());
}
const char* LLVMTargetMachineGetFS(LLVMTargetMachineRef tm)
{
return strdup(llvm::unwrap(tm)->getTargetFeatureString().str().c_str());
}
void LLVMPrintRegisteredTargetsForVersion(){
llvm::TargetRegistry::printRegisteredTargetsForVersion();
}
LLVMTargetDataRef LLVMTargetMachineGetTargetData(LLVMTargetMachineRef tm)
{
using namespace llvm;
return wrap(new TargetData(*unwrap(tm)->getTargetData()));
}
unsigned char* LLVMGetNativeCodeFromModule(LLVMModuleRef module, int assembly,
unsigned * lenp)
{
@ -205,7 +246,6 @@ unsigned char* LLVMGetNativeCodeFromModule(LLVMModuleRef module, int assembly,
return LLVMTargetMachineEmitFile(wrap(tm), module, assembly, lenp);
}
static
llvm::AtomicOrdering atomic_ordering_from_string(const char * ordering)
{