X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fmini-llvm-cpp.cpp;h=e3219686ae2cf5beb7eb8ea5adb7fc9987e51d86;hb=58e8a9f85176c9607e605b888ef45db01a0f6997;hp=f87e62929a0983ff81fc4e5f771746a7656cc1db;hpb=e4559812129b62624444ab4ce96ddf2ca7de5e3d;p=mono.git diff --git a/mono/mini/mini-llvm-cpp.cpp b/mono/mini/mini-llvm-cpp.cpp index f87e62929a0..e3219686ae2 100644 --- a/mono/mini/mini-llvm-cpp.cpp +++ b/mono/mini/mini-llvm-cpp.cpp @@ -3,6 +3,7 @@ // // (C) 2009-2011 Novell, Inc. // Copyright 2011 Xamarin, Inc (http://www.xamarin.com) +// Licensed under the MIT license. See LICENSE file in the project root for full license information. // // @@ -217,3 +218,62 @@ mono_llvm_set_call_preserveall_cc (LLVMValueRef func) { unwrap(func)->setCallingConv (CallingConv::PreserveAll); } + +#if LLVM_API_VERSION > 100 + +void* +mono_llvm_create_di_builder (LLVMModuleRef module) +{ + return new DIBuilder (*unwrap(module)); +} + +void* +mono_llvm_di_create_compile_unit (void *di_builder, const char *cu_name, const char *dir, const char *producer) +{ + DIBuilder *builder = (DIBuilder*)di_builder; + + return builder->createCompileUnit (dwarf::DW_LANG_C99, cu_name, dir, producer, true, "", 0); +} + +void* +mono_llvm_di_create_function (void *di_builder, void *cu, const char *name, const char *mangled_name, const char *dir, const char *file, int line) +{ + DIBuilder *builder = (DIBuilder*)di_builder; + DIFile *di_file; + DISubroutineType *type; + + // FIXME: Share DIFile + di_file = builder->createFile (file, dir); + type = builder->createSubroutineType (builder->getOrCreateTypeArray (ArrayRef ())); + return builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0); +} + +void* +mono_llvm_di_create_file (void *di_builder, const char *dir, const char *file) +{ + DIBuilder *builder = (DIBuilder*)di_builder; + + return builder->createFile (file, dir); +} + +void* +mono_llvm_di_create_location (void *di_builder, void *scope, int row, int column) +{ + return DILocation::get (*unwrap(LLVMGetGlobalContext ()), row, column, (Metadata*)scope); +} + +void +mono_llvm_di_set_location (LLVMBuilderRef builder, void *loc_md) +{ + unwrap(builder)->SetCurrentDebugLocation ((DILocation*)loc_md); +} + +void +mono_llvm_di_builder_finalize (void *di_builder) +{ + DIBuilder *builder = (DIBuilder*)di_builder; + + builder->finalize (); +} + +#endif /* #if LLVM_API_VERSION > 100 */