Changeset 629

Show
Ignore:
Timestamp:
08/14/08 13:32:32 (3 months ago)
Author:
weyrick
Message:

finally get JIT running, calling into the runtime. turns out the x86 JIT module can't be linked into a shared lib on x86-64 right now. get around it for now by linking it to rphp binary instead

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rphp/compiler/CMakeLists.txt

    r628 r629  
    33 
    44# TODO: move this to a FindLLVM in cmake/modules 
    5 EXECUTE_PROCESS(COMMAND llvm-config --libs core jit bitreader bitwriter linker interpreter x86 OUTPUT_VARIABLE LLVM_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) 
     5EXECUTE_PROCESS(COMMAND llvm-config --libs core jit bitreader bitwriter linker interpreter OUTPUT_VARIABLE LLVM_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) 
    66EXECUTE_PROCESS(COMMAND llvm-config --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) 
    77EXECUTE_PROCESS(COMMAND llvm-config --cppflags OUTPUT_VARIABLE LLVM_CPP_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) 
  • trunk/rphp/compiler/pDriver.cpp

    r628 r629  
    197197 
    198198    // RUNTIME startup/shutdown test 
    199 //     const llvm::Type* rEnginePointer = llvm::PointerType::get(llvm::Type::Int8Ty,0); 
    200 //     llvm::FunctionType *runtimeStartupFuncType = llvm::FunctionType::get(rEnginePointer, std::vector<const llvm::Type*>(), false); 
    201 //     llvm::Function *runtimeStartupFunc = llvm::Function::Create(runtimeStartupFuncType, llvm::Function::ExternalLinkage, "rphp_newRuntimeEngine", M); 
    202 // 
    203 //     llvm::Instruction *runtimeStartInstr = llvm::CallInst::Create(runtimeStartupFunc, "runtime"); 
    204 // 
    205 //     std::vector<const llvm::Type*> engineSig(1, rEnginePointer); 
    206 //     llvm::FunctionType *runtimeDeleteFuncType = llvm::FunctionType::get(llvm::Type::VoidTy, engineSig, false); 
    207 //     llvm::Function *runtimeDeleteFunc = llvm::Function::Create(runtimeDeleteFuncType, llvm::Function::ExternalLinkage, "rphp_deleteRuntimeEngine", M); 
    208 // 
    209 //     std::vector<llvm::Value*> ArgsV; 
    210 //     ArgsV.push_back(runtimeStartInstr); 
    211 // 
    212 //     llvm::Instruction *runtimeDeleteInstr = llvm::CallInst::Create(runtimeDeleteFunc, ArgsV.begin(), ArgsV.end()); 
    213  
    214     llvm::FunctionType *helloFuncType = llvm::FunctionType::get(llvm::Type::VoidTy, std::vector<const llvm::Type*>(), false); 
    215     llvm::Function *helloFunc = llvm::Function::Create(helloFuncType, llvm::Function::ExternalLinkage, "sayHello", M); 
    216  
    217     llvm::Instruction *helloInstr = llvm::CallInst::Create(helloFunc); 
     199    const llvm::Type* rEnginePointer = llvm::PointerType::get(llvm::Type::Int8Ty,0); 
     200    llvm::FunctionType *runtimeStartupFuncType = llvm::FunctionType::get(rEnginePointer, std::vector<const llvm::Type*>(), false); 
     201    llvm::Function *runtimeStartupFunc = llvm::Function::Create(runtimeStartupFuncType, llvm::Function::ExternalLinkage, "rphp_newRuntimeEngine", M); 
     202 
     203    llvm::Instruction *runtimeStartInstr = llvm::CallInst::Create(runtimeStartupFunc, "runtime"); 
     204 
     205    std::vector<const llvm::Type*> engineSig(1, rEnginePointer); 
     206    llvm::FunctionType *runtimeDeleteFuncType = llvm::FunctionType::get(llvm::Type::VoidTy, engineSig, false); 
     207    llvm::Function *runtimeDeleteFunc = llvm::Function::Create(runtimeDeleteFuncType, llvm::Function::ExternalLinkage, "rphp_deleteRuntimeEngine", M); 
     208 
     209    std::vector<llvm::Value*> ArgsV; 
     210    ArgsV.push_back(runtimeStartInstr); 
     211 
     212    llvm::Instruction *runtimeDeleteInstr = llvm::CallInst::Create(runtimeDeleteFunc, ArgsV.begin(), ArgsV.end()); 
    218213 
    219214    // Get pointers to the constant integers... 
     
    228223    BB->getInstList().push_back(Add); 
    229224 
    230     //BB->getInstList().push_back(runtimeStartInstr); 
    231     //BB->getInstList().push_back(runtimeDeleteInstr); 
    232     BB->getInstList().push_back(helloInstr); 
     225    BB->getInstList().push_back(runtimeStartInstr); 
     226    BB->getInstList().push_back(runtimeDeleteInstr); 
    233227 
    234228    // Create the return instruction and add it to the basic block 
  • trunk/rphp/frontend/cli/CMakeLists.txt

    r613 r629  
    11# CLI frontend 
    22MESSAGE( STATUS "CLI frontend check" ) 
     3 
     4EXECUTE_PROCESS(COMMAND llvm-config --libs x86 OUTPUT_VARIABLE LLVM_X86_JIT OUTPUT_STRIP_TRAILING_WHITESPACE) 
     5EXECUTE_PROCESS(COMMAND llvm-config --ldflags OUTPUT_VARIABLE LLVM_LD_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) 
     6SEPARATE_ARGUMENTS(LLVM_X86_JIT) 
    37 
    48include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${RPHP_RUNTIME_INCLUDE_DIR} ${RPHP_COMPILER_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}) 
     
    913 
    1014add_executable( rphp ${CLI_SRC_FILES} ) 
    11 target_link_libraries( rphp rphp-eval rphp-runtime ${Boost_PROGRAM_OPTIONS_LIBRARY} ) 
     15set_target_properties( rphp 
     16                       PROPERTIES LINK_FLAGS ${LLVM_LD_FLAGS} 
     17                     ) 
     18target_link_libraries( rphp rphp-eval rphp-runtime ${Boost_PROGRAM_OPTIONS_LIBRARY} ${LLVM_X86_JIT} ) 
    1219 
  • trunk/rphp/runtime/include/pRuntime.h

    r626 r629  
    7676extern "C" { 
    7777 
    78     void sayHello(void); 
    79  
    8078    // create a new runtime engine 
    8179    rphp::pRuntimeEngine* rphp_newRuntimeEngine(); 
  • trunk/rphp/runtime/include/pVar.h

    r619 r629  
    3131 
    3232    /* 
    33      * Definition of the various types used in the rphp runtime, including the 
    34      * main pVar variant 
     33     * Definition of the main pVar variant 
    3534     */ 
    3635 
  • trunk/rphp/runtime/pRuntime.cpp

    r626 r629  
    6363    } 
    6464 
    65     void sayHello() { 
    66         std::cout << "saying hello" << std::endl; 
    67     } 
    68      
    6965} 
    7066