add missing bfloat16 repr and improve assertions (#403)

- `BF16TyID` was missing a repr implementation.
- Throw a better exception on impossible casts.
- Add a few assertions. Tested with a debug build.
- Add `pointer_dtype.__str__` to aid kernel debugging.
This commit is contained in:
Madeleine Thompson
2021-12-23 17:01:17 -08:00
committed by GitHub
parent d8fce83e7a
commit 985798f101
7 changed files with 12 additions and 12 deletions

View File

@@ -55,7 +55,7 @@ ir::type *computation_type(ir::type* a_ty, ir::type* b_ty, DivOrMod div_or_mod)
}
}
if (!a_ty->is_integer_ty() || !b_ty->is_integer_ty())
throw_unreachable("augment_types");
throw_unreachable("computation_type");
// 4 ) both operands are integer and undergo
// integer promotion
return integer_promote(a_ty, b_ty);
@@ -493,7 +493,7 @@ ir::value *dispatch::cast(ir::value *input, ir::type *dst_ty, ir::builder *build
other = builder->create_splat(other, src_ty->get_block_shapes());
return builder->create_icmpNE(input, other);
}
return throw_unreachable("cast");
return throw_unreachable("cast from " + src_sca_ty->repr() + " to " + dst_sca_ty->repr());
}
//===----------------------------------------------------------------------===//

View File

@@ -232,6 +232,7 @@ icmp_inst::icmp_inst(type *ty, cmp_pred_t pred,
icmp_inst* icmp_inst::create(cmp_pred_t pred, value *lhs, value *rhs, const std::string &name, instruction *next){
assert(is_int_predicate(pred));
assert(lhs->get_type() == rhs->get_type());
type *res_ty = make_cmp_result_type(lhs->get_type());
return new icmp_inst(res_ty, pred, lhs, rhs, name, next);
}
@@ -920,7 +921,5 @@ const constant_int* make_range::get_last() const {
return last_;
}
}
}