Skip to content

Commit

Permalink
codegen: remove global type caches
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Feb 28, 2018
1 parent 4391c4d commit 43f5ab9
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 197 deletions.
7 changes: 2 additions & 5 deletions src/abi_ppc64le.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

struct ABI_PPC64leLayout : AbiLayout {

// count the homogeneous floating agregate size (saturating at max count of 8)
// count the homogeneous floating aggregate size (saturating at max count of 8)
unsigned isHFA(jl_datatype_t *ty, jl_datatype_t **ty0, bool *hva) const
{
size_t i, l = ty->layout->nfields;
Expand Down Expand Up @@ -133,10 +133,7 @@ Type *preferred_llvm_type(jl_datatype_t *dt, bool isret) const override
else {
jl_datatype_t *vecty = (jl_datatype_t*)jl_field_type(ty0, 0);
assert(jl_is_datatype(vecty) && vecty->name == jl_vecelement_typename);
jl_value_t *elemty = jl_tparam0(vecty);
assert(jl_is_primitivetype(elemty));

Type *ety = julia_type_to_llvm(elemty);
Type *ety = bitstype_to_llvm(jl_tparam0(vecty));
Type *vty = VectorType::get(ety, jl_datatype_nfields(ty0));
return ArrayType::get(vty, hfa);
}
Expand Down
28 changes: 17 additions & 11 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ static Value *julia_to_address(
return p;
}

Type *slottype = julia_struct_to_llvm(jvinfo.typ, NULL, NULL);
Type *slottype = julia_struct_to_llvm(ctx, jvinfo.typ, NULL, NULL);
// pass the address of an alloca'd thing, not a box
// since those are immutable.
Value *slot = emit_static_alloca(ctx, slottype);
Expand Down Expand Up @@ -806,7 +806,7 @@ static jl_cgval_t emit_cglobal(jl_codectx_t &ctx, jl_value_t **args, size_t narg
else {
rt = (jl_value_t*)jl_voidpointer_type;
}
Type *lrt = julia_type_to_llvm(rt);
Type *lrt = julia_type_to_llvm(ctx, rt);

interpret_symbol_arg(ctx, sym, args[1], "cglobal", false);

Expand Down Expand Up @@ -1030,7 +1030,7 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
for (size_t i = 0; i < nargt; ++i) {
jl_value_t *tti = jl_svecref(tt,i);
bool toboxed;
Type *t = julia_type_to_llvm(tti, &toboxed);
Type *t = julia_type_to_llvm(ctx, tti, &toboxed);
argtypes.push_back(t);
if (4 + i > nargs) {
jl_error("Missing arguments to llvmcall!");
Expand All @@ -1045,7 +1045,7 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar

Function *f;
bool retboxed;
Type *rettype = julia_type_to_llvm(rtt, &retboxed);
Type *rettype = julia_type_to_llvm(ctx, rtt, &retboxed);
if (isString) {
// Make sure to find a unique name
std::string ir_name;
Expand Down Expand Up @@ -1212,12 +1212,16 @@ class function_sig_t {
jl_unionall_t *unionall_env; // UnionAll environment for `at` and `rt`
size_t nargs; // number of actual arguments (can be different from the size of at when varargs)
size_t isVa;
jl_codegen_params_t *ctx;

function_sig_t(Type *lrt, jl_value_t *rt, bool retboxed, jl_svec_t *at, jl_unionall_t *unionall_env, size_t nargs, size_t isVa, CallingConv::ID cc, bool llvmcall)
function_sig_t(Type *lrt, jl_value_t *rt, bool retboxed,
jl_svec_t *at, jl_unionall_t *unionall_env, size_t nargs, size_t isVa,
CallingConv::ID cc, bool llvmcall,
jl_codegen_params_t *ctx)
: fargt_vasig(NULL), lrt(lrt), retboxed(retboxed),
prt(NULL), sret(0), cc(cc), llvmcall(llvmcall),
functype(NULL), at(at), rt(rt), unionall_env(unionall_env),
nargs(nargs), isVa(isVa)
nargs(nargs), isVa(isVa), ctx(ctx)
{
err_msg = generate_func_sig();
if (err_msg.empty())
Expand Down Expand Up @@ -1313,7 +1317,7 @@ std::string generate_func_sig()
}
}

t = julia_struct_to_llvm(tti, unionall_env, &isboxed);
t = _julia_struct_to_llvm(ctx, tti, unionall_env, &isboxed);
if (isboxed)
t = T_prjlvalue;
if (t == NULL || t == T_void) {
Expand Down Expand Up @@ -1415,6 +1419,7 @@ static std::pair<CallingConv::ID, bool> convert_cconv(jl_sym_t *lhd)

static const std::string verify_ccall_sig(size_t nccallargs, jl_value_t *&rt, jl_value_t *at,
jl_unionall_t *unionall_env, jl_svec_t *sparam_vals, const char *funcName,
jl_codegen_params_t *ctx,
size_t &nargt, bool &isVa, Type *&lrt, bool &retboxed, bool &static_rt)
{
assert(rt && !jl_is_abstract_ref_type(rt));
Expand All @@ -1426,7 +1431,7 @@ static const std::string verify_ccall_sig(size_t nccallargs, jl_value_t *&rt, jl
rt = (jl_value_t*)jl_any_type;
}

lrt = julia_struct_to_llvm(rt, unionall_env, &retboxed);
lrt = _julia_struct_to_llvm(ctx, rt, unionall_env, &retboxed);
if (lrt == NULL)
return "ccall: return type doesn't correspond to a C type";
else if (retboxed)
Expand Down Expand Up @@ -1552,6 +1557,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
nccallargs, rt, at, unionall,
ctx.spvals_ptr == NULL ? ctx.linfo->sparam_vals : NULL,
ctx.funcName.c_str(),
&ctx.emission_context,
/* outputs: */
nargt, isVa, lrt, retboxed, static_rt);
if (!err.empty()) {
Expand Down Expand Up @@ -1638,7 +1644,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
isboxed = false;
}
else {
largty = julia_struct_to_llvm(tti, unionall, &isboxed);
largty = julia_struct_to_llvm(ctx, tti, unionall, &isboxed);
}
if (isboxed) {
ary = boxed(ctx, argv[0]);
Expand Down Expand Up @@ -1808,7 +1814,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
}

function_sig_t sig(lrt, rt, retboxed, (jl_svec_t*)at, unionall, nccallargs,
isVa, cc, llvmcall);
isVa, cc, llvmcall, &ctx.emission_context);
jl_cgval_t retval = sig.emit_a_ccall(
ctx,
symarg,
Expand Down Expand Up @@ -2055,7 +2061,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
}
}
else {
Type *jlrt = julia_type_to_llvm(rt, &jlretboxed); // compute the real "julian" return type and compute whether it is boxed
Type *jlrt = julia_type_to_llvm(ctx, rt, &jlretboxed); // compute the real "julian" return type and compute whether it is boxed
if (jlretboxed) {
jlrt = T_prjlvalue;
}
Expand Down
Loading

0 comments on commit 43f5ab9

Please sign in to comment.