Remove reserved_reg functionality. (#424)

* Remove reserved_reg functionality.

This wasn't implemented, and if we need it in the future, it seems like
it would be better to extend the concept of global values to cover this.

* Use GlobalValue::reserved_value() for sentinal values.
This commit is contained in:
Dan Gohman
2018-07-31 07:57:37 -07:00
committed by GitHub
parent d9d40e1cdf
commit 1b42105faa
7 changed files with 23 additions and 57 deletions

View File

@@ -7,8 +7,8 @@ use std::fmt;
/// Information about a heap declaration.
#[derive(Clone)]
pub struct HeapData {
/// Method for determining the heap base address.
pub base: HeapBase,
/// The address of the start of the heap's storage.
pub base: GlobalValue,
/// Guaranteed minimum heap size in bytes. Heap accesses before `min_size` don't need bounds
/// checking.
@@ -21,18 +21,6 @@ pub struct HeapData {
pub style: HeapStyle,
}
/// Method for determining the base address of a heap.
#[derive(Clone)]
pub enum HeapBase {
/// The heap base lives in a reserved register.
///
/// This feature is not yet implemented.
ReservedReg,
/// The heap base is a global value.
GlobalValue(GlobalValue),
}
/// Style of heap including style-specific information.
#[derive(Clone)]
pub enum HeapStyle {
@@ -57,12 +45,7 @@ impl fmt::Display for HeapData {
HeapStyle::Static { .. } => "static",
})?;
match self.base {
HeapBase::ReservedReg => write!(f, " reserved_reg")?,
HeapBase::GlobalValue(gv) => write!(f, " {}", gv)?,
}
write!(f, ", min {}", self.min_size)?;
write!(f, " {}, min {}", self.base, self.min_size)?;
match self.style {
HeapStyle::Dynamic { bound_gv } => write!(f, ", bound {}", bound_gv)?,
HeapStyle::Static { bound } => write!(f, ", bound {}", bound)?,

View File

@@ -31,7 +31,7 @@ pub use ir::extfunc::{AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData,
pub use ir::extname::ExternalName;
pub use ir::function::Function;
pub use ir::globalvalue::GlobalValueData;
pub use ir::heap::{HeapBase, HeapData, HeapStyle};
pub use ir::heap::{HeapData, HeapStyle};
pub use ir::instructions::{InstructionData, Opcode, ValueList, ValueListPool, VariableArgs};
pub use ir::jumptable::JumpTableData;
pub use ir::layout::Layout;

View File

@@ -154,11 +154,7 @@ fn offset_addr(
}
// Add the heap base address base
match pos.func.heaps[heap].base {
ir::HeapBase::ReservedReg => unimplemented!(),
ir::HeapBase::GlobalValue(base_gv) => {
let base = pos.ins().global_value(addr_ty, base_gv);
pos.func.dfg.replace(inst).iadd(base, offset);
}
}
let base_gv = pos.func.heaps[heap].base;
let base = pos.ins().global_value(addr_ty, base_gv);
pos.func.dfg.replace(inst).iadd(base, offset);
}