Permalink
Browse files

Update LLVM to 3.1, this breaks backwards compatibility.

Updated the code base to use the llvm 3.1 release instead of the previous version. This breaks backwards compatibility with llvm 2.9. I have not tested with llvm 3.0, but it might work. The major differences are in the execution handling code gen, the introduction of the ArrayRef<> and a number of data types are no longer const in the llvm API.

It compiles and runs, but some specs are still failing. Still investigating the cause of the failed specs.
  • Loading branch information...
1 parent 960fa9b commit 6e73329cfa143c9aa6b9c933f016facce5a62428 @ashgti committed Jun 29, 2012
Showing with 273 additions and 189 deletions.
  1. +3 −3 bin/rubyc
  2. +13 −13 bridgesupport.cpp
  3. +149 −121 compiler.cpp
  4. +20 −20 compiler.h
  5. +3 −3 debugger.cpp
  6. +6 −0 icu-1060/unicode/unistr.h
  7. +5 −5 rakelib/builder.rake
  8. +8 −8 rakelib/builder/options.rb
  9. +4 −4 rakelib/builder/templates.rb
  10. +1 −1 spec/macruby/spec_helper.rb
  11. +61 −11 vm.cpp
View
@@ -104,8 +104,8 @@ class MacRuby::Compiler
@tmpfiles = []
# Locate necessary programs.
- @gcc = locate('gcc')
- @gcxx = locate('g++')
+ @gcc = locate('clang')
+ @gcxx = locate('clang++')
@nm = locate('nm')
@lipo = locate('lipo')
@strip = locate('strip')
@@ -122,7 +122,7 @@ class MacRuby::Compiler
if system("#{@llc} -help | grep jit-enable-eh >& /dev/null")
@llc_flags << '-jit-enable-eh'
else
- @llc_flags << '-enable-eh'
+ @llc_flags << '-enable-correct-eh-support'
end
end
View
@@ -277,7 +277,8 @@ RoxorCompiler::compile_set_struct(Value *rcv, int field, Value *val)
ConstantInt::get(Int32Ty, field),
val
};
- CallInst::Create(setStructFunc, args, args + 3, "", bb);
+
+ CallInst::Create(setStructFunc, ArrayRef<Value*>(args, args+3), "", bb);
}
Function *
@@ -295,7 +296,7 @@ RoxorCompiler::compile_bs_struct_writer(rb_vm_bs_boxed_t *bs_boxed, int field)
assert((unsigned)field < bs_boxed->as.s->fields_count);
const char *ftype = bs_boxed->as.s->fields[field].type;
- const Type *llvm_type = convert_type(ftype);
+ Type *llvm_type = convert_type(ftype);
Value *fval = new AllocaInst(llvm_type, "", bb);
val = compile_conversion_to_c(ftype, val, fval);
@@ -337,7 +338,7 @@ RoxorCompiler::compile_bs_struct_new(rb_vm_bs_boxed_t *bs_boxed)
for (unsigned i = 0; i < bs_boxed->as.s->fields_count; i++) {
const char *ftype = bs_boxed->as.s->fields[i].type;
- const Type *llvm_type = convert_type(ftype);
+ Type *llvm_type = convert_type(ftype);
Value *fval = new AllocaInst(llvm_type, "", bb);
const size_t type_size = GET_CORE()->get_sizeof(llvm_type);
@@ -349,11 +350,11 @@ RoxorCompiler::compile_bs_struct_new(rb_vm_bs_boxed_t *bs_boxed)
ConstantInt::get(Int32Ty, 0), // align
ConstantInt::get(Int1Ty, 0) // volatile
};
- const Type *Tys[] = { args[0]->getType(), args[2]->getType() };
+ Type *Tys[] = { args[0]->getType(), args[2]->getType() };
Function *memset_func = Intrinsic::getDeclaration(module,
- Intrinsic::memset, Tys, 2);
+ Intrinsic::memset, ArrayRef<Type*>(Tys, Tys + 2));
assert(memset_func != NULL);
- CallInst::Create(memset_func, args, args + 5, "", bb);
+ CallInst::Create(memset_func, ArrayRef<Value*>(args, args+5), "", bb);
fval = new LoadInst(fval, "", bb);
fval = compile_conversion_to_ruby(ftype, llvm_type, fval);
@@ -373,7 +374,7 @@ RoxorCompiler::compile_bs_struct_new(rb_vm_bs_boxed_t *bs_boxed)
for (unsigned i = 0; i < bs_boxed->as.s->fields_count; i++) {
const char *ftype = bs_boxed->as.s->fields[i].type;
- const Type *llvm_type = convert_type(ftype);
+ Type *llvm_type = convert_type(ftype);
Value *fval = new AllocaInst(llvm_type, "", bb);
Value *index = ConstantInt::get(Int32Ty, i);
@@ -1456,13 +1457,13 @@ RoxorCompiler::compile_ffi_function(void *stub, void *imp, int argc)
// VALUE *argv = alloca(...);
// return stub(imp, argc, argv);
// }
- std::vector<const Type *> f_types;
+ std::vector<Type *> f_types;
f_types.push_back(RubyObjTy);
f_types.push_back(PtrTy);
for (int i = 0; i < argc; i++) {
f_types.push_back(RubyObjTy);
}
- FunctionType *ft = FunctionType::get(RubyObjTy, f_types, false);
+ FunctionType *ft = FunctionType::get(RubyObjTy, ArrayRef<Type*>(f_types), false);
Function *f = cast<Function>(module->getOrInsertFunction("", ft));
bb = BasicBlock::Create(context, "EntryBlock", f);
@@ -1472,7 +1473,7 @@ RoxorCompiler::compile_ffi_function(void *stub, void *imp, int argc)
arg++; // skip sel
std::vector<Value *> params;
- std::vector<const Type *> stub_types;
+ std::vector<Type *> stub_types;
// First argument is the function implementation.
params.push_back(compile_const_pointer(imp));
@@ -1501,13 +1502,12 @@ RoxorCompiler::compile_ffi_function(void *stub, void *imp, int argc)
stub_types.push_back(RubyObjPtrTy);
// Cast the given stub using the correct function signature.
- FunctionType *stub_ft = FunctionType::get(RubyObjTy, stub_types, false);
+ FunctionType *stub_ft = FunctionType::get(RubyObjTy, ArrayRef<Type*>(stub_types), false);
Value *stub_val = new BitCastInst(compile_const_pointer(stub),
PointerType::getUnqual(stub_ft), "", bb);
// Call the stub and return its return value.
- CallInst *stub_call = CallInst::Create(stub_val, params.begin(),
- params.end(), "", bb);
+ CallInst *stub_call = CallInst::Create(stub_val, ArrayRef<Value*>(params), "", bb);
ReturnInst::Create(context, stub_call, bb);
return f;
Oops, something went wrong.

1 comment on commit 6e73329

Owner
ashgti commented on 6e73329 Jun 29, 2012

Oh, one other thing of note: This uses clang and assumes the llvm was built with libc++ (llvm) instead of libstdc++ (gcc).

Please sign in to comment.