comparison src/pt-jit.cc @ 14955:609dcc297db5

src/pt-jit.cc (jit_info::~jit_info): New function
author Max Brister <max@2bass.com>
date Fri, 15 Jun 2012 14:10:24 -0500
parents 2871d5f8d922
children 4b98b3f66e46
comparison
equal deleted inserted replaced
14954:2871d5f8d922 14955:609dcc297db5
2818 pass_manager->run (*fn); 2818 pass_manager->run (*fn);
2819 } 2819 }
2820 2820
2821 // -------------------- jit_info -------------------- 2821 // -------------------- jit_info --------------------
2822 jit_info::jit_info (tree_jit& tjit, tree& tee) 2822 jit_info::jit_info (tree_jit& tjit, tree& tee)
2823 : engine (tjit.get_engine ()) 2823 : engine (tjit.get_engine ()), llvm_function (0)
2824 { 2824 {
2825 llvm::Function *fun = 0;
2826 try 2825 try
2827 { 2826 {
2828 jit_convert conv (tjit.get_module (), tee); 2827 jit_convert conv (tjit.get_module (), tee);
2829 fun = conv.get_function (); 2828 llvm_function = conv.get_function ();
2830 arguments = conv.get_arguments (); 2829 arguments = conv.get_arguments ();
2831 bounds = conv.get_bounds (); 2830 bounds = conv.get_bounds ();
2832 } 2831 }
2833 catch (const jit_fail_exception& e) 2832 catch (const jit_fail_exception& e)
2834 { 2833 {
2836 if (e.known ()) 2835 if (e.known ())
2837 std::cout << "jit fail: " << e.what () << std::endl; 2836 std::cout << "jit fail: " << e.what () << std::endl;
2838 #endif 2837 #endif
2839 } 2838 }
2840 2839
2841 if (! fun) 2840 if (! llvm_function)
2842 { 2841 {
2843 function = 0; 2842 function = 0;
2844 return; 2843 return;
2845 } 2844 }
2846 2845
2847 tjit.optimize (fun); 2846 tjit.optimize (llvm_function);
2848 2847
2849 #ifdef OCTAVE_JIT_DEBUG 2848 #ifdef OCTAVE_JIT_DEBUG
2850 std::cout << "-------------------- optimized llvm ir --------------------\n"; 2849 std::cout << "-------------------- optimized llvm ir --------------------\n";
2851 llvm::raw_os_ostream llvm_cout (std::cout); 2850 llvm::raw_os_ostream llvm_cout (std::cout);
2852 fun->print (llvm_cout); 2851 llvm_function->print (llvm_cout);
2853 std::cout << std::endl; 2852 std::cout << std::endl;
2854 #endif 2853 #endif
2855 2854
2856 function = reinterpret_cast<jited_function>(engine->getPointerToFunction (fun)); 2855 function = reinterpret_cast<jited_function>(engine->getPointerToFunction (llvm_function));
2856 }
2857
2858 jit_info::~jit_info (void)
2859 {
2860 if (llvm_function)
2861 llvm_function->eraseFromParent ();
2857 } 2862 }
2858 2863
2859 bool 2864 bool
2860 jit_info::execute (void) const 2865 jit_info::execute (void) const
2861 { 2866 {