cranelift: Add narrower and wider constraints to the instruction DSL (#6013)

* Add narrower and wider constraints to the instruction DSL

* Add docs to narrower/wider operands

* Update cranelift/codegen/meta/src/cdsl/instructions.rs

Co-authored-by: Jamey Sharp <jamey@minilop.net>

* Fix assertion message

* Simplify upper bounds for the wider constraint

* Remove additional unnecessary cases in the verifier

* Remove unused variables

* Remove changes to is_ctrl_typevar_candidate

These changes were only necessary when the type returned by an
instruction was a variable constrained by narrow or widen. As we have
switched to requiring that constraints must appear on argument types and
not return types, these changes were not longer necessary.

---------

Co-authored-by: Jamey Sharp <jamey@minilop.net>
This commit is contained in:
Trevor Elliott
2023-03-14 09:34:17 -07:00
committed by GitHub
parent 5c1b468648
commit f5ad74e546
6 changed files with 145 additions and 111 deletions

View File

@@ -113,14 +113,28 @@ block2(v3: f32, v4: i8):
function %bad_extend() {
block0:
v0 = iconst.i32 10
v1 = uextend.i16 v0 ; error: input i32 must be smaller than output i16
v1 = uextend.i16 v0 ; error: arg 0 (v0) with type i32 failed to satisfy type set
return
}
function %bad_reduce() {
block0:
v0 = iconst.i32 10
v1 = ireduce.i64 v0 ; error: input i32 must be larger than output i64
v1 = ireduce.i64 v0 ; error: arg 0 (v0) with type i32 failed to satisfy type set
return
}
function %bad_fdemote() {
block0:
v0 = f32const 0xf.f
v1 = fdemote.f64 v0 ; error: arg 0 (v0) with type f32 failed to satisfy type set
return
}
function %bad_fpromote() {
block0:
v0 = f64const 0xf.f
v1 = fpromote.f32 v0 ; error: arg 0 (v0) with type f64 failed to satisfy type set
return
}