Permalink
Browse files

Update Rubinius to LLVM 3.0

  • Loading branch information...
1 parent 46dae28 commit 420c7557c02f07213d554396c41473ad9227864b @dbussink dbussink committed with evanphx Dec 4, 2011
View
@@ -65,11 +65,11 @@ class Configure
@llvm_prebuilt_name = nil
@llvm_system_name = get_system_name
- @llvm_version = "2.8"
- @llvm_api_version = 208
- @llvm_source = "llvm-2.8.tgz"
- @llvm_source_dir = "llvm-2.8"
- @llvm_source_url = "http://llvm.org/releases/2.8/llvm-2.8.tgz"
+ @llvm_version = "3.0"
+ @llvm_api_version = 300
+ @llvm_source = "llvm-3.0.tgz"
+ @llvm_source_dir = "llvm-3.0.src"
+ @llvm_source_url = "http://llvm.org/releases/3.0/llvm-3.0.tar.gz"
@llvm_asset_path = "http://asset.rubini.us/prebuilt"
@@ -611,7 +611,7 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
@log.print " Checking for existing LLVM library tree: "
if File.directory?("#{@llvm_default}/Release")
version = `#{@perl} #{@llvm_default}/Release/bin/llvm-config --version`.strip
- if version == "2.8"
+ if version == "3.0"
# See if this has rtti turned off and reject it.
if `#{@perl} #{@llvm_default}/Release/bin/llvm-config --cxxflags`.index("-fno-rtti")
@log.write "incorrectly configure (rtti is off)"
@@ -670,10 +670,10 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
api_version = ("%d%02d" % parts[0..1]).to_i
if `#{@perl} #{config} --cxxflags`.index("-fno-rtti")
@log.write "incorrectly configured llvm (rtti is off)"
- elsif api_version != 208 and api_version != 209
- @log.write "only LLVM 2.8 and 2.9 are supported"
+ elsif api_version != 300
+ @log.write "only LLVM 3.0 is supported"
else
- @log.write "found! (version #{version})"
+ @log.write "found! (version #{version} - api: #{api_version})"
@llvm_configure = config
@llvm = :config
@llvm_api_version = api_version
View
@@ -63,5 +63,5 @@ def gcc_major_version
def llvm_config_flags
"--build=#{host_triple} --host=#{host_triple} " \
- "--enable-optimized --enable-targets=host-only"
+ "--enable-optimized --enable-targets=host,cpp"
end
View
@@ -28,10 +28,12 @@ namespace :jit do
rubinius::Numeric
rubinius::Float
rubinius::jit::RuntimeData
+ rubinius::jit::GCLiteral
rubinius::CallUnit
rubinius::MethodCacheEntry
- memory::Address
- jit_state!
+ rubinius::RefCount
+ atomic::integer
+ memory::Address!
require 'tempfile'
files = %w!vm/call_frame.hpp
@@ -73,18 +75,18 @@ namespace :jit do
end
end
- opaque = %w!VM TypeInfo VMMethod Fixnum Symbol Selector LookupTable MethodTable
+ opaque = %w!VM State TypeInfo VMMethod Fixnum Symbol Selector LookupTable MethodTable
jit::RuntimeDataHolder Inliners!
File.open("vm/gen/types.ll","w+") do |f|
opaque.each do |o|
- f.puts "%\"struct.rubinius::#{o}\" = type opaque"
+ f.puts "%\"struct.rubinius::#{o}\" = type {}"
end
f.puts(*types)
end
- `vendor/llvm/Release/bin/llvm-as < vm/gen/types.ll > vm/gen/types.bc`
- `vendor/llvm/Release/bin/llc -march=cpp -cppgen=contents -o vm/llvm/types.cpp.gen vm/gen/types.bc`
+ `llvm-as < vm/gen/types.ll > vm/gen/types.bc`
+ `llc -march=cpp -cppgen=contents -o vm/llvm/types.cpp.gen vm/gen/types.bc`
end
task :generate_header do
View
@@ -7,7 +7,6 @@
#include <llvm/CallingConv.h>
#include <llvm/Support/CFG.h>
#include <llvm/Analysis/Passes.h>
-#include <llvm/Target/TargetSelect.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/Module.h>
View
@@ -2,16 +2,14 @@
#include "vm/config.h"
#include "llvm/disassembler.hpp"
-#if RBX_LLVM_API_VER == 208
-#include <llvm/System/Host.h>
-#elif RBX_LLVM_API_VER == 209
#include <llvm/Support/Host.h>
-#endif
#include <llvm/Instructions.h>
-#include <llvm/Target/TargetRegistry.h>
-#include <llvm/Target/TargetSelect.h>
+#include <llvm/Support/TargetSelect.h>
+#include <llvm/Support/TargetRegistry.h>
+#include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetInstrInfo.h>
-#include <llvm/Target/TargetInstrDesc.h>
+#include <llvm/MC/MCDisassembler.h>
+#include <llvm/MC/MCSubtargetInfo.h>
#include <llvm/MC/MCInstPrinter.h>
#include <llvm/MC/MCAsmInfo.h>
#include <llvm/MC/MCInst.h>
@@ -33,17 +31,20 @@ namespace rubinius {
llvm::InitializeNativeTargetAsmPrinter();
llvm::InitializeAllDisassemblers();
target = llvm::TargetRegistry::lookupTarget(host, error);
- target_machine = target->createTargetMachine(host, error);
- asm_info = target_machine->getMCAsmInfo();
+ target_machine = target->createTargetMachine(host, llvm::sys::getHostCPUName(), "");
+
+ sub_target = target->createMCSubtargetInfo(host, llvm::sys::getHostCPUName(), "");
+ asm_info = target->createMCAsmInfo(host);
if(asm_info) {
- disassembler = target->createMCDisassembler();
+ disassembler = target->createMCDisassembler(*sub_target);
memory_object = new JITMemoryObject((const uint8_t*)buffer, (uint64_t) size);
}
}
JITDisassembler::~JITDisassembler() {
if(memory_object) delete memory_object;
if(disassembler) delete disassembler;
+ if(sub_target) delete sub_target;
if(target_machine) delete target_machine;
}
@@ -56,7 +57,8 @@ namespace rubinius {
return std::string("Can't create assembly information for target");
}
- llvm::MCInstPrinter* printer = target->createMCInstPrinter(asm_info->getAssemblerDialect(), *asm_info);
+ llvm::MCInstPrinter* printer = target->createMCInstPrinter(
+ asm_info->getAssemblerDialect(), *asm_info, *sub_target);
if(!printer) {
return std::string("No instruction printer for target");
}
@@ -75,13 +77,13 @@ namespace rubinius {
uint64_t instruction_position = instruction_offset + instruction_pointer;
if(disassembler->getInstruction(instruction, instruction_size,
*memory_object, instruction_pointer,
- llvm::nulls())) {
- printer->printInst(&instruction, out);
+ llvm::nulls(), llvm::nulls())) {
+ printer->printInst(&instruction, out, "");
output << "0x" << instruction_position << " ";
output << std::setw(30) << std::left << out.str();
- const llvm::TargetInstrDesc &inst_descr = inst_info->get(instruction.getOpcode());
+ const llvm::MCInstrDesc &inst_descr = inst_info->get(instruction.getOpcode());
for(uint8_t i = 0; i < instruction.getNumOperands(); ++i) {
llvm::MCOperand& op = instruction.getOperand(i);
View
@@ -5,8 +5,7 @@
#include <string.h>
#include <iostream>
-#include <llvm/Target/TargetRegistry.h>
-#include <llvm/Target/TargetMachine.h>
+#include <llvm/Support/TargetRegistry.h>
#include <llvm/MC/MCAsmInfo.h>
#include <llvm/MC/MCDisassembler.h>
#include <llvm/Support/MemoryObject.h>
@@ -74,6 +73,7 @@ namespace rubinius {
const llvm::Target* target;
const llvm::TargetMachine* target_machine;
+ const llvm::MCSubtargetInfo* sub_target;
const llvm::MCAsmInfo* asm_info;
llvm::MCDisassembler* disassembler;
const JITMemoryObject* memory_object;
View
@@ -140,14 +140,14 @@ namespace rubinius {
check_recv(klass);
ops_.setup_out_args(count_);
- std::vector<const Type*> ftypes;
+ std::vector<Type*> ftypes;
ftypes.push_back(ops_.state()->ptr_type("VM"));
ftypes.push_back(ops_.state()->ptr_type("CallFrame"));
ftypes.push_back(ops_.state()->ptr_type("Executable"));
ftypes.push_back(ops_.state()->ptr_type("Module"));
ftypes.push_back(ops_.state()->ptr_type("Arguments"));
- const Type *ft = llvm::PointerType::getUnqual(FunctionType::get(ops_.state()->ptr_type("Object"), ftypes, false));
+ Type *ft = llvm::PointerType::getUnqual(FunctionType::get(ops_.state()->ptr_type("Object"), ftypes, false));
// We can't extract and use a specialized version of cm because we don't
// yet have the ability to check if the specialized version has been
@@ -184,7 +184,7 @@ namespace rubinius {
ops_.out_args()
};
- Value* dc_res = ops_.b().CreateCall(func, call_args, call_args+5, "dc_res");
+ Value* dc_res = ops_.b().CreateCall(func, call_args, "dc_res");
set_result(dc_res);
goto remember;
@@ -658,7 +658,7 @@ namespace rubinius {
context_.leave_inline();
}
- const Type* find_type(JITOperations& ops_, size_t type) {
+ Type* find_type(JITOperations& ops_, size_t type) {
switch(type) {
case RBX_FFI_TYPE_CHAR:
case RBX_FFI_TYPE_UCHAR:
@@ -709,9 +709,9 @@ namespace rubinius {
///
std::vector<Value*> ffi_args;
- std::vector<const Type*> ffi_type;
+ std::vector<Type*> ffi_type;
- std::vector<const Type*> struct_types;
+ std::vector<Type*> struct_types;
struct_types.push_back(ops_.state()->Int32Ty);
struct_types.push_back(ops_.state()->Int1Ty);
@@ -736,7 +736,7 @@ namespace rubinius {
Value* val = sig.call("rbx_ffi_to_int", call_args, 3, "to_int",
ops_.b());
- const Type* type = find_type(ops_, nf->ffi_data->arg_types[i]);
+ Type* type = find_type(ops_, nf->ffi_data->arg_types[i]);
ffi_type.push_back(type);
if(type != ops_.NativeIntTy) {
@@ -829,7 +829,7 @@ namespace rubinius {
break;
case RBX_FFI_TYPE_PTR: {
- const Type* type = llvm::PointerType::getUnqual(ops_.state()->Int8Ty);
+ Type* type = llvm::PointerType::getUnqual(ops_.state()->Int8Ty);
Signature sig(ops_.state(), type);
sig << "VM";
@@ -852,7 +852,7 @@ namespace rubinius {
}
case RBX_FFI_TYPE_STRING: {
- const Type* type = llvm::PointerType::getUnqual(ops_.state()->Int8Ty);
+ Type* type = llvm::PointerType::getUnqual(ops_.state()->Int8Ty);
Signature sig(ops_.state(), type);
sig << "VM";
@@ -886,15 +886,14 @@ namespace rubinius {
Value* check_args[] = { ops_.vm(), ops_.call_frame() };
check.call("rbx_enter_unmanaged", check_args, 2, "unused", ops_.b());
- const Type* return_type = find_type(ops_, nf->ffi_data->ret_type);
+ Type* return_type = find_type(ops_, nf->ffi_data->ret_type);
FunctionType* ft = FunctionType::get(return_type, ffi_type, false);
Value* ep_ptr = ops_.b().CreateIntToPtr(
ConstantInt::get(ops_.state()->IntPtrTy, (intptr_t)nf->ffi_data->ep),
llvm::PointerType::getUnqual(ft), "cast_to_function");
- Value* ffi_result = ops_.b().CreateCall(ep_ptr, ffi_args.begin(),
- ffi_args.end(), "ffi_result");
+ Value* ffi_result = ops_.b().CreateCall(ep_ptr, ffi_args, "ffi_result");
check.call("rbx_exit_unmanaged", check_args, 2, "unused", ops_.b());
@@ -456,7 +456,7 @@ namespace rubinius {
perform->moveAfter(convert_block);
ops.set_block(perform);
- PHINode* rhs = ops.b().CreatePHI(fix_rhs->getType(), "rhs");
+ PHINode* rhs = ops.b().CreatePHI(fix_rhs->getType(), 2, "rhs");
rhs->addIncoming(unboxed_rhs, unbox_block);
rhs->addIncoming(fix_rhs, convert_block);
@@ -544,7 +544,7 @@ namespace rubinius {
do_compare->moveAfter(converted_block);
- PHINode* rhs = ops.b().CreatePHI(converted_rhs->getType(), "float_rhs");
+ PHINode* rhs = ops.b().CreatePHI(converted_rhs->getType(), 2, "float_rhs");
rhs->addIncoming(unboxed_rhs, unboxed_block);
rhs->addIncoming(converted_rhs, converted_block);
View
@@ -17,7 +17,7 @@ namespace rubinius {
namespace jit {
void BlockBuilder::setup() {
- std::vector<const Type*> ftypes;
+ std::vector<Type*> ftypes;
ftypes.push_back(ls_->ptr_type("VM"));
ftypes.push_back(ls_->ptr_type("CallFrame"));
ftypes.push_back(ls_->ptr_type("BlockEnvironment"));
@@ -115,7 +115,7 @@ namespace jit {
"invocation.module");
Value* creation_mod = b().CreateLoad(
- get_field(block_env, offset::blockenv_module),
+ get_field(block_env, offset::BlockEnvironment::module),
"env.module");
Value* mod = b().CreateSelect(
@@ -136,7 +136,7 @@ namespace jit {
// the scope the block was created in, not the top scope for depth
// variables to work.
Value* be_scope = b().CreateLoad(
- get_field(block_env, offset::blockenv_scope),
+ get_field(block_env, offset::BlockEnvironment::scope),
"env.scope");
b().CreateStore(be_scope, get_field(vars, offset::vars_parent));
@@ -148,7 +148,7 @@ namespace jit {
void BlockBuilder::initialize_frame(int stack_size) {
Value* cm_gep = get_field(call_frame, offset::CallFrame::cm);
- method = b().CreateLoad(get_field(block_env, offset::blockenv_code),
+ method = b().CreateLoad(get_field(block_env, offset::BlockEnvironment::code),
"env.code");
// previous
@@ -195,7 +195,7 @@ namespace jit {
// top_scope
top_scope = b().CreateLoad(
- get_field(block_env, offset::blockenv_top_scope),
+ get_field(block_env, offset::BlockEnvironment::top_scope),
"env.top_scope");
b().CreateStore(top_scope, get_field(call_frame, offset::CallFrame::top_scope));
@@ -316,7 +316,7 @@ namespace jit {
b().CreateStore(
b().CreateLoad(
b().CreateGEP(arg_ary, loop_val)),
- b().CreateGEP(vars, idx2, idx2+3));
+ b().CreateGEP(vars, idx2));
// *loop_i = loop_val + 1
b().CreateStore(
@@ -375,7 +375,7 @@ namespace jit {
b().CreateStore(
b().CreateLoad(
b().CreateGEP(arg_ary, loop_val)),
- b().CreateGEP(vars, idx2, idx2+3));
+ b().CreateGEP(vars, idx2));
// *loop_i = loop_val + 1
b().CreateStore(
@@ -432,7 +432,7 @@ namespace jit {
b().CreateStore(
b().CreateLoad(
b().CreateGEP(arg_ary, loop_val)),
- b().CreateGEP(vars, idx2, idx2+3));
+ b().CreateGEP(vars, idx2));
// *loop_i = loop_val + 1
b().CreateStore(
@@ -474,7 +474,7 @@ namespace jit {
cint(vmm_->splat_position)
};
- Value* pos = b().CreateGEP(vars, idx3, idx3+3, "splat_pos");
+ Value* pos = b().CreateGEP(vars, idx3, "splat_pos");
b().CreateStore(splat_val, pos);
}
}
Oops, something went wrong.

0 comments on commit 420c755

Please sign in to comment.