Permalink
Browse files

add support for llvm 2.9, test it by passing CFLAGS=-D__SUPPORT_LLVM_…

…29__ to rake

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5269 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent dea88a2 commit c3fac488fe50731cde8e9d09938e2464336b6446 @lrz lrz committed Mar 10, 2011
Showing with 52 additions and 1 deletion.
  1. +3 −0 bridgesupport.cpp
  2. +20 −0 compiler.cpp
  3. +4 −0 compiler.h
  4. +3 −0 debugger.cpp
  5. +3 −0 llvm.h
  6. +19 −1 vm.cpp
View
@@ -18,6 +18,9 @@
# include <llvm/Instructions.h>
# include <llvm/Intrinsics.h>
# include <llvm/Analysis/DebugInfo.h>
+# if __SUPPORT_LLVM_29__
+# include <llvm/Analysis/DIBuilder.h>
+# endif
# include <llvm/ExecutionEngine/JIT.h>
# include <llvm/PassManager.h>
# include <llvm/Target/TargetData.h>
View
@@ -150,7 +150,11 @@ RoxorCompiler *RoxorCompiler::shared = NULL;
RoxorCompiler::RoxorCompiler(bool _debug_mode)
{
assert(RoxorCompiler::module != NULL);
+#if __SUPPORT_LLVM_29__
+ debug_info = new DIBuilder(*RoxorCompiler::module);
+#else
debug_info = new DIFactory(*RoxorCompiler::module);
+#endif
can_interpret = false;
debug_mode = _debug_mode;
@@ -835,8 +839,18 @@ void
RoxorCompiler::attach_current_line_metadata(Instruction *insn)
{
if (fname != NULL) {
+#if __SUPPORT_LLVM_29__
+ Value *args[] = {
+ ConstantInt::get(Int32Ty, current_line),
+ ConstantInt::get(Int32Ty, 0),
+ debug_compile_unit,
+ DILocation(NULL)
+ };
+ DILocation loc = DILocation(MDNode::get(context, args, 4));
+#else
DILocation loc = debug_info->CreateLocation(current_line, 0,
debug_compile_unit, DILocation(NULL));
+#endif
insn->setMetadata(dbg_mdkind, loc);
}
}
@@ -4880,8 +4894,14 @@ RoxorCompiler::set_fname(const char *_fname)
assert(strlen(dir) > 0);
assert(strlen(base) > 0);
+#if __SUPPORT_LLVM_29__
+ debug_info->createCompileUnit(DW_LANG_Ruby, base, dir,
+ RUBY_DESCRIPTION, true, "", 1);
+ debug_compile_unit = DICompileUnit(debug_info->getCU());
+#else
debug_compile_unit = debug_info->CreateCompileUnit(DW_LANG_Ruby,
base, dir, RUBY_DESCRIPTION, false, false, "");
+#endif
}
}
}
View
@@ -79,7 +79,11 @@ class RoxorCompiler {
void generate_location_path(std::string &path, DILocation loc);
protected:
+#if __SUPPORT_LLVM_29__
+ DIBuilder *debug_info;
+#else
DIFactory *debug_info;
+#endif
DICompileUnit debug_compile_unit;
DISubprogram debug_subprogram;
View
@@ -15,6 +15,9 @@
#include <llvm/Instructions.h>
#include <llvm/Intrinsics.h>
#include <llvm/Analysis/DebugInfo.h>
+#if __SUPPORT_LLVM_29__
+# include <llvm/Analysis/DIBuilder.h>
+#endif
#include <llvm/ExecutionEngine/JIT.h>
#include <llvm/PassManager.h>
#include <llvm/Target/TargetData.h>
View
3 llvm.h
@@ -17,6 +17,9 @@
#include <llvm/Instructions.h>
#include <llvm/Intrinsics.h>
#include <llvm/Analysis/DebugInfo.h>
+#if __SUPPORT_LLVM_29__
+# include <llvm/Analysis/DIBuilder.h>
+#endif
#include <llvm/ExecutionEngine/JIT.h>
#include <llvm/PassManager.h>
#include <llvm/Target/TargetData.h>
View
20 vm.cpp
@@ -21,6 +21,9 @@
# include <llvm/Instructions.h>
# include <llvm/PassManager.h>
# include <llvm/Analysis/DebugInfo.h>
+# if __SUPPORT_LLVM_29__
+# include <llvm/Analysis/DIBuilder.h>
+# endif
# include <llvm/Analysis/Verifier.h>
# include <llvm/Target/TargetData.h>
# include <llvm/CodeGen/MachineFunction.h>
@@ -35,6 +38,9 @@
# include <llvm/Transforms/Scalar.h>
# include <llvm/Transforms/IPO.h>
# include <llvm/Support/raw_ostream.h>
+# if __SUPPORT_LLVM_29__
+# include <llvm/Support/system_error.h>
+# endif
# include <llvm/Support/PrettyStackTrace.h>
# include <llvm/Support/MemoryBuffer.h>
# include <llvm/Support/StandardPasses.h>
@@ -4923,11 +4929,23 @@ Init_PreVM(void)
// To not corrupt stack pointer (essential for backtracing).
llvm::NoFramePointerElim = true;
- MemoryBuffer *mbuf;
+ MemoryBuffer *mbuf = NULL;
const char *kernel_file = getenv("VM_KERNEL_PATH");
if (kernel_file != NULL) {
std::string err;
+#if __SUPPORT_LLVM_29__
+ OwningPtr<MemoryBuffer> MB;
+ error_code errcode = MemoryBuffer::getFile(kernel_file, MB);
+ if (errcode) {
+ err = errcode.message();
+ }
+ else {
+ mbuf = MB.take();
+ assert(mbuf != NULL);
+ }
+#else
mbuf = MemoryBuffer::getFile(kernel_file, &err);
+#endif
if (mbuf == NULL) {
printf("can't open given kernel file `%s': %s\n", kernel_file,
err.c_str());

0 comments on commit c3fac48

Please sign in to comment.