Skip to content

Commit

Permalink
Render array objects more accurately. Enables vectorization of 64-bit…
Browse files Browse the repository at this point in the history
… arithmetic.
  • Loading branch information
Arch D. Robison committed Sep 23, 2014
1 parent f7172d3 commit dc2bca9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,8 @@ static Value *emit_arraylen_prim(Value *t, jl_value_t *ty)
{
#ifdef STORE_ARRAY_LEN
(void)ty;
return emit_nthptr_recast(t, 2, tbaa_arraylen, T_psize);
Value* addr = builder.CreateStructGEP(builder.CreateBitCast(t,jl_parray_llvmt), 2);
return tbaa_decorate(tbaa_arraylen, builder.CreateLoad(addr, false));
#else
jl_value_t *p1 = jl_tparam1(ty);
if (jl_is_long(p1)) {
Expand Down Expand Up @@ -1320,7 +1321,8 @@ static Value *emit_arraylen(Value *t, jl_value_t *ex, jl_codectx_t *ctx)

static Value *emit_arrayptr(Value *t)
{
return emit_nthptr(t, 1, tbaa_arrayptr);
Value* addr = builder.CreateStructGEP(builder.CreateBitCast(t,jl_parray_llvmt), 1);
return tbaa_decorate(tbaa_arrayptr, builder.CreateLoad(addr, false));
}

static Value *emit_arrayptr(Value *t, jl_value_t *ex, jl_codectx_t *ctx)
Expand Down
12 changes: 12 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ static bool imaging_mode = false;
static Type *jl_value_llvmt;
static Type *jl_pvalue_llvmt;
static Type *jl_ppvalue_llvmt;
static Type* jl_parray_llvmt;
static FunctionType *jl_func_sig;
static Type *jl_pfptr_llvmt;
static Type *T_int1;
Expand Down Expand Up @@ -4155,6 +4156,17 @@ static void init_julia_llvm_env(Module *m)
assert(jl_func_sig != NULL);
jl_pfptr_llvmt = PointerType::get(PointerType::get(jl_func_sig, 0), 0);

Type* vaelts[] = {valueStructElts[0], T_pint8
#ifdef STORE_ARRAY_LEN
, T_size
#endif
};
Type* jl_array_llvmt =
StructType::create(getGlobalContext(),
ArrayRef<Type*>(vaelts,sizeof(vaelts)/sizeof(vaelts[0])),
"jl_array_t");
jl_parray_llvmt = PointerType::get(jl_array_llvmt,0);

#ifdef JL_GC_MARKSWEEP
jlpgcstack_var =
new GlobalVariable(*m, jl_ppvalue_llvmt,
Expand Down

0 comments on commit dc2bca9

Please sign in to comment.