Skip to content

Commit c69ecf5

Browse files
committed
Move code to very pretty c++ that works on 15 and 16
without complaints
1 parent 4353ad0 commit c69ecf5

File tree

9 files changed

+57
-57
lines changed

9 files changed

+57
-57
lines changed

src/APInt-C.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const unsigned int host_char_bit = 8;
3030
/* TODO: this memcpy assumes little-endian,
3131
* for big-endian, need to align the copy to the other end */ \
3232
memcpy(data_a64, p##s, RoundUpToAlignment(numbits, host_char_bit) / host_char_bit); \
33-
s = APInt(numbits, makeArrayRef(data_a64, nbytes / sizeof(integerPart))); \
33+
s = APInt(numbits, ArrayRef<long unsigned>(data_a64, nbytes / sizeof(integerPart))); \
3434
} \
3535
else { \
36-
s = APInt(numbits, makeArrayRef(p##s, numbits / integerPartWidth)); \
36+
s = APInt(numbits, ArrayRef<long unsigned>(p##s, numbits / integerPartWidth)); \
3737
}
3838

3939
/* assign to "integerPart *pr" from "APInt a" */

src/ccall.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,21 +439,21 @@ static Value *llvm_type_rewrite(
439439
Value *from;
440440
Value *to;
441441
const DataLayout &DL = ctx.builder.GetInsertBlock()->getModule()->getDataLayout();
442-
unsigned align = std::max(DL.getPrefTypeAlignment(target_type), DL.getPrefTypeAlignment(from_type));
442+
Align align = std::max(DL.getPrefTypeAlign(target_type), DL.getPrefTypeAlign(from_type));
443443
if (DL.getTypeAllocSize(target_type) >= DL.getTypeAllocSize(from_type)) {
444444
to = emit_static_alloca(ctx, target_type);
445445
setName(ctx.emission_context, to, "type_rewrite_buffer");
446-
cast<AllocaInst>(to)->setAlignment(Align(align));
446+
cast<AllocaInst>(to)->setAlignment(align);
447447
from = emit_bitcast(ctx, to, from_type->getPointerTo());
448448
}
449449
else {
450450
from = emit_static_alloca(ctx, from_type);
451451
setName(ctx.emission_context, from, "type_rewrite_buffer");
452-
cast<AllocaInst>(from)->setAlignment(Align(align));
452+
cast<AllocaInst>(from)->setAlignment(align);
453453
to = emit_bitcast(ctx, from, target_type->getPointerTo());
454454
}
455-
ctx.builder.CreateAlignedStore(v, from, Align(align));
456-
auto pun = ctx.builder.CreateAlignedLoad(target_type, to, Align(align));
455+
ctx.builder.CreateAlignedStore(v, from, align);
456+
auto pun = ctx.builder.CreateAlignedLoad(target_type, to, align);
457457
setName(ctx.emission_context, pun, "type_rewrite");
458458
return pun;
459459
}
@@ -472,7 +472,7 @@ static Value *runtime_apply_type_env(jl_codectx_t &ctx, jl_value_t *ty)
472472
ctx.spvals_ptr,
473473
ConstantInt::get(ctx.types().T_size, sizeof(jl_svec_t) / sizeof(jl_value_t*)))
474474
};
475-
auto call = ctx.builder.CreateCall(prepare_call(jlapplytype_func), makeArrayRef(args));
475+
auto call = ctx.builder.CreateCall(prepare_call(jlapplytype_func), ArrayRef<Value*>(args));
476476
addRetAttr(call, Attribute::getWithAlignment(ctx.builder.getContext(), Align(16)));
477477
return call;
478478
}
@@ -1055,7 +1055,7 @@ class function_sig_t {
10551055
FunctionType *functype(LLVMContext &ctxt) const {
10561056
assert(err_msg.empty());
10571057
if (nreqargs > 0)
1058-
return FunctionType::get(sret ? getVoidTy(ctxt) : prt, makeArrayRef(fargt_sig).slice(0, nreqargs), true);
1058+
return FunctionType::get(sret ? getVoidTy(ctxt) : prt, ArrayRef<Type*>(fargt_sig).slice(0, nreqargs), true);
10591059
else
10601060
return FunctionType::get(sret ? getVoidTy(ctxt) : prt, fargt_sig, false);
10611061
}
@@ -1903,7 +1903,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
19031903
decay_derived(ctx, data_pointer(ctx, val)),
19041904
T_pint8_derived)
19051905
};
1906-
Value *ret = ctx.builder.CreateCall(prepare_call(jl_object_id__func), makeArrayRef(args));
1906+
Value *ret = ctx.builder.CreateCall(prepare_call(jl_object_id__func), ArrayRef<Value*>(args));
19071907
setName(ctx.emission_context, ret, "object_id");
19081908
JL_GC_POP();
19091909
return mark_or_box_ccall_result(ctx, ret, retboxed, rt, unionall, static_rt);

src/cgutils.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static Type *_julia_struct_to_llvm(jl_codegen_params_t *ctx, LLVMContext &ctxt,
825825
// unsigned remainder = fsz % al;
826826
// while (remainder--)
827827
// Elements.push_back(getInt8Ty(ctxt));
828-
// lty = StructType::get(lty->getContext(), makeArrayRef(Elements));
828+
// lty = StructType::get(lty->getContext(),ArrayRef<Type*>(Elements));
829829
// }
830830
if (isboxed) *isboxed = true;
831831
return JuliaType::get_prjlvalue_ty(ctxt);
@@ -2389,11 +2389,11 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
23892389
assert((cast<ArrayType>(strct.V->getType())->getElementType() == ctx.types().T_prjlvalue) == isboxed);
23902390
Value *idx = idx0();
23912391
unsigned i = 0;
2392-
Value *fld = ctx.builder.CreateExtractValue(strct.V, makeArrayRef(i));
2392+
Value *fld = ctx.builder.CreateExtractValue(strct.V, ArrayRef<unsigned>(i));
23932393
for (i = 1; i < nfields; i++) {
23942394
fld = ctx.builder.CreateSelect(
23952395
ctx.builder.CreateICmpEQ(idx, ConstantInt::get(idx->getType(), i)),
2396-
ctx.builder.CreateExtractValue(strct.V, makeArrayRef(i)),
2396+
ctx.builder.CreateExtractValue(strct.V, ArrayRef<unsigned>(i)),
23972397
fld);
23982398
}
23992399
setName(ctx.emission_context, fld, "getfield");
@@ -2639,7 +2639,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
26392639
unsigned i = 0;
26402640
for (; i < fsz / align; i++) {
26412641
unsigned fld = st_idx + i;
2642-
Value *fldv = ctx.builder.CreateExtractValue(obj, makeArrayRef(fld));
2642+
Value *fldv = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(fld));
26432643
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(ET, lv, i);
26442644
ctx.builder.CreateAlignedStore(fldv, fldp, Align(align));
26452645
}
@@ -2648,14 +2648,14 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
26482648
Value *staddr = ctx.builder.CreateConstInBoundsGEP1_32(ET, lv, i);
26492649
staddr = ctx.builder.CreateBitCast(staddr, getInt8PtrTy(ctx.builder.getContext()));
26502650
for (; i < ptindex - st_idx; i++) {
2651-
Value *fldv = ctx.builder.CreateExtractValue(obj, makeArrayRef(st_idx + i));
2651+
Value *fldv = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(st_idx + i));
26522652
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(getInt8Ty(ctx.builder.getContext()), staddr, i);
26532653
ctx.builder.CreateAlignedStore(fldv, fldp, Align(1));
26542654
}
26552655
}
26562656
setNameWithField(ctx.emission_context, lv, get_objname, jt, idx, Twine());
26572657
}
2658-
Value *tindex0 = ctx.builder.CreateExtractValue(obj, makeArrayRef(ptindex));
2658+
Value *tindex0 = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(ptindex));
26592659
Value *tindex = ctx.builder.CreateNUWAdd(ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 1), tindex0);
26602660
setNameWithField(ctx.emission_context, tindex, get_objname, jt, idx, Twine(".tindex"));
26612661
return mark_julia_slot(lv, jfty, tindex, ctx.tbaa().tbaa_stack);
@@ -2668,7 +2668,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
26682668
st_idx = convert_struct_offset(ctx, T, byte_offset);
26692669
else
26702670
llvm_unreachable("encountered incompatible type for a struct");
2671-
fldv = ctx.builder.CreateExtractValue(obj, makeArrayRef(st_idx));
2671+
fldv = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(st_idx));
26722672
setNameWithField(ctx.emission_context, fldv, get_objname, jt, idx, Twine());
26732673
}
26742674
if (maybe_null) {
@@ -3278,7 +3278,7 @@ static Value *_boxed_special(jl_codectx_t &ctx, const jl_cgval_t &vinfo, Type *t
32783278
unsigned zero = 0;
32793279
Value *v = as_value(ctx, t, vinfo);
32803280
assert(v->getType() == ctx.emission_context.llvmtypes[jl_ssavalue_type]);
3281-
v = ctx.builder.CreateExtractValue(v, makeArrayRef(&zero, 1));
3281+
v = ctx.builder.CreateExtractValue(v, ArrayRef<unsigned>(&zero, 1));
32823282
box = call_with_attrs(ctx, box_ssavalue_func, v);
32833283
}
32843284
else if (!jb->name->abstract && jl_datatype_nbits(jb) == 0) {
@@ -3458,7 +3458,7 @@ static Function *mangleIntrinsic(IntrinsicInst *call) //mangling based on replac
34583458

34593459
auto newfType = FunctionType::get(
34603460
oldfType->getReturnType(),
3461-
makeArrayRef(argTys).slice(0, oldfType->getNumParams()),
3461+
ArrayRef<Type*>(argTys).slice(0, oldfType->getNumParams()),
34623462
oldfType->isVarArg());
34633463

34643464
// Accumulate an array of overloaded types for the given intrinsic
@@ -3714,7 +3714,7 @@ static Value *emit_new_bits(jl_codectx_t &ctx, Value *jt, Value *pval)
37143714
// if ptr is NULL this emits a write barrier _back_
37153715
static void emit_write_barrier(jl_codectx_t &ctx, Value *parent, Value *ptr)
37163716
{
3717-
emit_write_barrier(ctx, parent, makeArrayRef(ptr));
3717+
emit_write_barrier(ctx, parent, ArrayRef<Value*>(ptr));
37183718
}
37193719

37203720
static void emit_write_barrier(jl_codectx_t &ctx, Value *parent, ArrayRef<Value*> ptrs)
@@ -4013,7 +4013,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
40134013
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(ET, lv, i);
40144014
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_stack);
40154015
Value *fldv = ai.decorateInst(ctx.builder.CreateAlignedLoad(ET, fldp, Align(al)));
4016-
strct = ctx.builder.CreateInsertValue(strct, fldv, makeArrayRef(llvm_idx + i));
4016+
strct = ctx.builder.CreateInsertValue(strct, fldv, ArrayRef<unsigned>(llvm_idx + i));
40174017
}
40184018
// emit remaining bytes up to tindex
40194019
if (i < ptindex - llvm_idx) {
@@ -4023,14 +4023,14 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
40234023
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(getInt8Ty(ctx.builder.getContext()), staddr, i);
40244024
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_stack);
40254025
Value *fldv = ai.decorateInst(ctx.builder.CreateAlignedLoad(getInt8Ty(ctx.builder.getContext()), fldp, Align(1)));
4026-
strct = ctx.builder.CreateInsertValue(strct, fldv, makeArrayRef(llvm_idx + i));
4026+
strct = ctx.builder.CreateInsertValue(strct, fldv, ArrayRef<unsigned>(llvm_idx + i));
40274027
}
40284028
}
40294029
}
40304030
llvm_idx = ptindex;
40314031
fval = tindex;
40324032
if (jl_is_vecelement_type(ty))
4033-
fval = ctx.builder.CreateInsertValue(strct, fval, makeArrayRef(llvm_idx));
4033+
fval = ctx.builder.CreateInsertValue(strct, fval, ArrayRef<unsigned>(llvm_idx));
40344034
}
40354035
else {
40364036
Value *ptindex = emit_struct_gep(ctx, lt, strct, offs + fsz);
@@ -4057,7 +4057,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
40574057
else if (lt->isVectorTy())
40584058
strct = ctx.builder.CreateInsertElement(strct, fval, ConstantInt::get(getInt32Ty(ctx.builder.getContext()), llvm_idx));
40594059
else if (lt->isAggregateType())
4060-
strct = ctx.builder.CreateInsertValue(strct, fval, makeArrayRef(llvm_idx));
4060+
strct = ctx.builder.CreateInsertValue(strct, fval, ArrayRef<unsigned>(llvm_idx));
40614061
else
40624062
assert(false);
40634063
}
@@ -4071,7 +4071,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
40714071
int fsz = jl_field_size(sty, i) - 1;
40724072
unsigned llvm_idx = convert_struct_offset(ctx, cast<StructType>(lt), offs + fsz);
40734073
if (init_as_value)
4074-
strct = ctx.builder.CreateInsertValue(strct, ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 0), makeArrayRef(llvm_idx));
4074+
strct = ctx.builder.CreateInsertValue(strct, ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 0), ArrayRef<unsigned>(llvm_idx));
40754075
else {
40764076
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_unionselbyte);
40774077
ai.decorateInst(ctx.builder.CreateAlignedStore(

src/codegen.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ struct jl_typecache_t {
334334
};
335335
static_assert(sizeof(jl_array_flags_t) == sizeof(int16_t),
336336
"Size of jl_array_flags_t is not the same as int16_t");
337-
T_jlarray = StructType::get(context, makeArrayRef(vaelts));
337+
T_jlarray = StructType::get(context, ArrayRef<Type*>(vaelts));
338338
T_pjlarray = PointerType::get(T_jlarray, 0);
339339
}
340340
};
@@ -605,7 +605,7 @@ AttributeSet Attributes(LLVMContext &C, std::initializer_list<Attribute::AttrKin
605605
SmallVector<Attribute, 8> attrs(attrkinds.size());
606606
for (size_t i = 0; i < attrkinds.size(); i++)
607607
attrs[i] = Attribute::get(C, attrkinds.begin()[i]);
608-
return AttributeSet::get(C, makeArrayRef(attrs));
608+
return AttributeSet::get(C, ArrayRef<Attribute>(attrs));
609609
}
610610

611611
static Type *get_pjlvalue(LLVMContext &C) { return JuliaType::get_pjlvalue_ty(C); }
@@ -1099,7 +1099,7 @@ static const auto jlapplytype_func = new JuliaFunction<>{
10991099
[](LLVMContext &C) {
11001100
return AttributeList::get(C,
11011101
AttributeSet(),
1102-
AttributeSet::get(C, makeArrayRef({Attribute::get(C, Attribute::NonNull),
1102+
AttributeSet::get(C, ArrayRef<Attribute>({Attribute::get(C, Attribute::NonNull),
11031103
Attribute::getWithAlignment(C, Align(16))})),
11041104
None);
11051105
},
@@ -1313,7 +1313,7 @@ static const auto except_enter_func = new JuliaFunction<>{
13131313
"julia.except_enter",
13141314
[](LLVMContext &C) { return FunctionType::get(getInt32Ty(C), false); },
13151315
[](LLVMContext &C) { return AttributeList::get(C,
1316-
AttributeSet::get(C, makeArrayRef({Attribute::get(C, Attribute::ReturnsTwice)})),
1316+
AttributeSet::get(C, ArrayRef<Attribute>({Attribute::get(C, Attribute::ReturnsTwice)})),
13171317
AttributeSet(),
13181318
None); },
13191319
};
@@ -3131,7 +3131,7 @@ static Value *emit_bits_compare(jl_codectx_t &ctx, jl_cgval_t arg1, jl_cgval_t a
31313131
nroots++;
31323132
if ((gc_uses[nroots] = get_gc_root_for(arg2)))
31333133
nroots++;
3134-
OperandBundleDef OpBundle("jl_roots", makeArrayRef(gc_uses, nroots));
3134+
OperandBundleDef OpBundle("jl_roots", ArrayRef<Value*>(gc_uses, nroots));
31353135
auto answer = ctx.builder.CreateCall(prepare_call(memcmp_func), {
31363136
ctx.builder.CreateBitCast(varg1, getInt8PtrTy(ctx.builder.getContext())),
31373137
ctx.builder.CreateBitCast(varg2, getInt8PtrTy(ctx.builder.getContext())),
@@ -5712,7 +5712,7 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr, ssize_t ssaidx_
57125712
Value *mdargs[] = { name, literal_pointer_val(ctx, (jl_value_t*)mod), bp, literal_pointer_val(ctx, bnd) };
57135713
jl_cgval_t gf = mark_julia_type(
57145714
ctx,
5715-
ctx.builder.CreateCall(prepare_call(jlgenericfunction_func), makeArrayRef(mdargs)),
5715+
ctx.builder.CreateCall(prepare_call(jlgenericfunction_func), ArrayRef<Value*>(mdargs)),
57165716
true,
57175717
jl_function_type);
57185718
return gf;
@@ -5731,7 +5731,7 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr, ssize_t ssaidx_
57315731
};
57325732
jl_cgval_t meth = mark_julia_type(
57335733
ctx,
5734-
ctx.builder.CreateCall(prepare_call(jlmethod_func), makeArrayRef(mdargs)),
5734+
ctx.builder.CreateCall(prepare_call(jlmethod_func), ArrayRef<Value*>(mdargs)),
57355735
true,
57365736
jl_method_type);
57375737
return meth;
@@ -7113,7 +7113,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
71137113
fsig.push_back(AT->getPointerTo());
71147114
argnames.push_back("union_bytes_return");
71157115
Type *pair[] = { ctx.types().T_prjlvalue, getInt8Ty(ctx.builder.getContext()) };
7116-
rt = StructType::get(ctx.builder.getContext(), makeArrayRef(pair));
7116+
rt = StructType::get(ctx.builder.getContext(), ArrayRef<Type*>(pair));
71177117
}
71187118
else if (allunbox) {
71197119
props.cc = jl_returninfo_t::Ghosts;

0 commit comments

Comments
 (0)