Report when output register annotation is missing (#1289)
This commit is contained in:
@@ -231,18 +231,8 @@ impl SubTest for TestBinEmit {
|
|||||||
// Send legal encodings into the emitter.
|
// Send legal encodings into the emitter.
|
||||||
if enc.is_legal() {
|
if enc.is_legal() {
|
||||||
// Generate a better error message if output locations are not specified.
|
// Generate a better error message if output locations are not specified.
|
||||||
if let Some(&v) = func
|
validate_location_annotations(&func, inst, isa, false)?;
|
||||||
.dfg
|
|
||||||
.inst_results(inst)
|
|
||||||
.iter()
|
|
||||||
.find(|&&v| !func.locations[v].is_assigned())
|
|
||||||
{
|
|
||||||
return Err(format!(
|
|
||||||
"Missing register/stack slot for {} in {}",
|
|
||||||
v,
|
|
||||||
func.dfg.display_inst(inst, isa)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
let before = sink.offset;
|
let before = sink.offset;
|
||||||
isa.emit_inst(&func, inst, &mut divert, &mut sink);
|
isa.emit_inst(&func, inst, &mut divert, &mut sink);
|
||||||
let emitted = sink.offset - before;
|
let emitted = sink.offset - before;
|
||||||
@@ -260,19 +250,9 @@ impl SubTest for TestBinEmit {
|
|||||||
if let Some(want) = bins.remove(&inst) {
|
if let Some(want) = bins.remove(&inst) {
|
||||||
if !enc.is_legal() {
|
if !enc.is_legal() {
|
||||||
// A possible cause of an unencoded instruction is a missing location for
|
// A possible cause of an unencoded instruction is a missing location for
|
||||||
// one of the input operands.
|
// one of the input/output operands.
|
||||||
if let Some(&v) = func
|
validate_location_annotations(&func, inst, isa, true)?;
|
||||||
.dfg
|
validate_location_annotations(&func, inst, isa, false)?;
|
||||||
.inst_args(inst)
|
|
||||||
.iter()
|
|
||||||
.find(|&&v| !func.locations[v].is_assigned())
|
|
||||||
{
|
|
||||||
return Err(format!(
|
|
||||||
"Missing register/stack slot for {} in {}",
|
|
||||||
v,
|
|
||||||
func.dfg.display_inst(inst, isa)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do any encodings exist?
|
// Do any encodings exist?
|
||||||
let encodings = isa
|
let encodings = isa
|
||||||
@@ -337,3 +317,27 @@ impl SubTest for TestBinEmit {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Validate registers/stack slots are correctly annotated.
|
||||||
|
fn validate_location_annotations(
|
||||||
|
func: &ir::Function,
|
||||||
|
inst: ir::Inst,
|
||||||
|
isa: &dyn isa::TargetIsa,
|
||||||
|
validate_inputs: bool,
|
||||||
|
) -> SubtestResult<()> {
|
||||||
|
let values = if validate_inputs {
|
||||||
|
func.dfg.inst_args(inst)
|
||||||
|
} else {
|
||||||
|
func.dfg.inst_results(inst)
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(&v) = values.iter().find(|&&v| !func.locations[v].is_assigned()) {
|
||||||
|
Err(format!(
|
||||||
|
"Need register/stack slot annotation for {} in {}",
|
||||||
|
v,
|
||||||
|
func.dfg.display_inst(inst, isa)
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user