1 #include <llvm-c/Target.h>
2 #include <llvm/Target/TargetData.h>
3 #include <llvm/ModuleProvider.h>
4 #include <llvm/Support/SourceMgr.h>
5 #include <llvm/Support/raw_ostream.h>
6 #include <llvm/Assembly/Parser.h>
9 // Declare here so the inline definition gets into the lib. Why is
10 // there an inline function in a binding header anyways. :(
11 int CLLLVM_LLVMInitializeNativeTarget() {
12 LLVMInitializeNativeTarget();
15 // Functions missing in the LLVM C API
19 LLVMModuleRef
CLLLVM_LLVMModuleProviderGetModule(LLVMModuleProviderRef modprovider
) {
20 return llvm::wrap(llvm::unwrap(modprovider
)->getModule());
23 LLVMModuleRef
CLLLVM_LLVMParseAssemblyString(const char *AsmString
,
25 LLVMContextRef Context
) {
26 class llvm::SMDiagnostic Error
;
28 llvm::wrap(llvm::ParseAssemblyString(AsmString
, llvm::unwrap(M
), Error
, *llvm::unwrap(Context
)));
29 Error
.Print("sbcl", llvm::errs());
32 LLVMTypeRef
CLLLVM_LLVMIntPtrTypeInContext(LLVMContextRef Context
, LLVMTargetDataRef TD
) {
33 return llvm::wrap(llvm::unwrap(TD
)->getIntPtrType(*llvm::unwrap(Context
)));
36 char *CLLLVM_LLVMDumpModuleToString(LLVMModuleRef module
)
39 llvm::raw_string_ostream
buf(s
);
40 llvm::unwrap(module
)->print(buf
, NULL
);
41 return strdup(buf
.str().c_str());
44 char *CLLLVM_LLVMDumpTypeToString(LLVMTypeRef type
)
47 llvm::raw_string_ostream
buf(s
);
48 llvm::unwrap(type
)->print(buf
);
49 return strdup(buf
.str().c_str());
52 char *CLLLVM_LLVMDumpValueToString(LLVMValueRef value
)
55 llvm::raw_string_ostream
buf(s
);
56 llvm::unwrap(value
)->print(buf
);
57 return strdup(buf
.str().c_str());