Generalize def_inst() to def_entity().
Use this source map method for assigning a location to any entity whose source number is not exposed. This could be - Instructions. - Signatures defined implicitly by function decls. These entities only appear in the location map, not the entity number maps.
This commit is contained in:
@@ -837,7 +837,7 @@ impl<'a> Parser<'a> {
|
|||||||
let inst = ctx.function.dfg.make_inst(inst_data);
|
let inst = ctx.function.dfg.make_inst(inst_data);
|
||||||
let num_results = ctx.function.dfg.make_inst_results(inst, ctrl_typevar);
|
let num_results = ctx.function.dfg.make_inst_results(inst, ctrl_typevar);
|
||||||
ctx.function.layout.append_inst(inst, ebb);
|
ctx.function.layout.append_inst(inst, ebb);
|
||||||
ctx.map.def_inst(inst, &opcode_loc).expect("duplicate inst references created");
|
ctx.map.def_entity(inst.into(), &opcode_loc).expect("duplicate inst references created");
|
||||||
|
|
||||||
if results.len() != num_results {
|
if results.len() != num_results {
|
||||||
return err!(self.loc,
|
return err!(self.loc,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
//! clients.
|
//! clients.
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use cretonne::ir::{StackSlot, JumpTable, Ebb, Value, Inst};
|
use cretonne::ir::{StackSlot, JumpTable, Ebb, Value};
|
||||||
use cretonne::ir::entities::AnyEntity;
|
use cretonne::ir::entities::AnyEntity;
|
||||||
use error::{Result, Location};
|
use error::{Result, Location};
|
||||||
use lexer::split_entity_name;
|
use lexer::split_entity_name;
|
||||||
@@ -128,9 +128,9 @@ pub trait MutableSourceMap {
|
|||||||
fn def_ss(&mut self, src_num: u32, entity: StackSlot, loc: &Location) -> Result<()>;
|
fn def_ss(&mut self, src_num: u32, entity: StackSlot, loc: &Location) -> Result<()>;
|
||||||
fn def_jt(&mut self, src_num: u32, entity: JumpTable, loc: &Location) -> Result<()>;
|
fn def_jt(&mut self, src_num: u32, entity: JumpTable, loc: &Location) -> Result<()>;
|
||||||
|
|
||||||
/// Define an instruction. Since instruction numbers never appear in source, only the location
|
/// Define an entity without an associated source number. This can be used for instructions
|
||||||
/// is recorded.
|
/// whose numbers never appear in source, or implicitly defined signatures.
|
||||||
fn def_inst(&mut self, entity: Inst, loc: &Location) -> Result<()>;
|
fn def_entity(&mut self, entity: AnyEntity, loc: &Location) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MutableSourceMap for SourceMap {
|
impl MutableSourceMap for SourceMap {
|
||||||
@@ -147,45 +147,37 @@ impl MutableSourceMap for SourceMap {
|
|||||||
fn def_value(&mut self, src: Value, entity: Value, loc: &Location) -> Result<()> {
|
fn def_value(&mut self, src: Value, entity: Value, loc: &Location) -> Result<()> {
|
||||||
if self.values.insert(src, entity).is_some() {
|
if self.values.insert(src, entity).is_some() {
|
||||||
err!(loc, "duplicate value: {}", src)
|
err!(loc, "duplicate value: {}", src)
|
||||||
} else if self.locations.insert(entity.into(), loc.clone()).is_some() {
|
|
||||||
err!(loc, "duplicate entity: {}", entity)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
self.def_entity(entity.into(), loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_ebb(&mut self, src: Ebb, entity: Ebb, loc: &Location) -> Result<()> {
|
fn def_ebb(&mut self, src: Ebb, entity: Ebb, loc: &Location) -> Result<()> {
|
||||||
if self.ebbs.insert(src, entity).is_some() {
|
if self.ebbs.insert(src, entity).is_some() {
|
||||||
err!(loc, "duplicate EBB: {}", src)
|
err!(loc, "duplicate EBB: {}", src)
|
||||||
} else if self.locations.insert(entity.into(), loc.clone()).is_some() {
|
|
||||||
err!(loc, "duplicate entity: {}", entity)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
self.def_entity(entity.into(), loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_ss(&mut self, src_num: u32, entity: StackSlot, loc: &Location) -> Result<()> {
|
fn def_ss(&mut self, src_num: u32, entity: StackSlot, loc: &Location) -> Result<()> {
|
||||||
if self.stack_slots.insert(src_num, entity).is_some() {
|
if self.stack_slots.insert(src_num, entity).is_some() {
|
||||||
err!(loc, "duplicate stack slot: ss{}", src_num)
|
err!(loc, "duplicate stack slot: ss{}", src_num)
|
||||||
} else if self.locations.insert(entity.into(), loc.clone()).is_some() {
|
|
||||||
err!(loc, "duplicate entity: {}", entity)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
self.def_entity(entity.into(), loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_jt(&mut self, src_num: u32, entity: JumpTable, loc: &Location) -> Result<()> {
|
fn def_jt(&mut self, src_num: u32, entity: JumpTable, loc: &Location) -> Result<()> {
|
||||||
if self.jump_tables.insert(src_num, entity).is_some() {
|
if self.jump_tables.insert(src_num, entity).is_some() {
|
||||||
err!(loc, "duplicate jump table: jt{}", src_num)
|
err!(loc, "duplicate jump table: jt{}", src_num)
|
||||||
} else if self.locations.insert(entity.into(), loc.clone()).is_some() {
|
|
||||||
err!(loc, "duplicate entity: {}", entity)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
self.def_entity(entity.into(), loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_inst(&mut self, entity: Inst, loc: &Location) -> Result<()> {
|
fn def_entity(&mut self, entity: AnyEntity, loc: &Location) -> Result<()> {
|
||||||
if self.locations.insert(entity.into(), loc.clone()).is_some() {
|
if self.locations.insert(entity, loc.clone()).is_some() {
|
||||||
err!(loc, "duplicate entity: {}", entity)
|
err!(loc, "duplicate entity: {}", entity)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user