Remove the requirement that Variable implement Default.
This commit is contained in:
@@ -17,7 +17,7 @@ use cretonne::entity::{EntityRef, EntityMap, EntitySet};
|
|||||||
/// functions, rather than dropped, preserving the underlying allocations.
|
/// functions, rather than dropped, preserving the underlying allocations.
|
||||||
pub struct ILBuilder<Variable>
|
pub struct ILBuilder<Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
ssa: SSABuilder<Variable>,
|
ssa: SSABuilder<Variable>,
|
||||||
ebbs: EntityMap<Ebb, EbbData>,
|
ebbs: EntityMap<Ebb, EbbData>,
|
||||||
@@ -29,7 +29,7 @@ where
|
|||||||
/// Temporary object used to build a single Cretonne IL `Function`.
|
/// Temporary object used to build a single Cretonne IL `Function`.
|
||||||
pub struct FunctionBuilder<'a, Variable: 'a>
|
pub struct FunctionBuilder<'a, Variable: 'a>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
/// The function currently being built.
|
/// The function currently being built.
|
||||||
/// This field is public so the function can be re-borrowed.
|
/// This field is public so the function can be re-borrowed.
|
||||||
@@ -59,7 +59,7 @@ struct Position {
|
|||||||
|
|
||||||
impl<Variable> ILBuilder<Variable>
|
impl<Variable> ILBuilder<Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
/// Creates a ILBuilder structure. The structure is automatically cleared after each
|
/// Creates a ILBuilder structure. The structure is automatically cleared after each
|
||||||
/// [`FunctionBuilder`](struct.FunctionBuilder.html) completes translating a function.
|
/// [`FunctionBuilder`](struct.FunctionBuilder.html) completes translating a function.
|
||||||
@@ -89,7 +89,7 @@ where
|
|||||||
/// one convenience method per Cretonne IL instruction.
|
/// one convenience method per Cretonne IL instruction.
|
||||||
pub struct FuncInstBuilder<'short, 'long: 'short, Variable: 'long>
|
pub struct FuncInstBuilder<'short, 'long: 'short, Variable: 'long>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
builder: &'short mut FunctionBuilder<'long, Variable>,
|
builder: &'short mut FunctionBuilder<'long, Variable>,
|
||||||
ebb: Ebb,
|
ebb: Ebb,
|
||||||
@@ -97,7 +97,7 @@ where
|
|||||||
|
|
||||||
impl<'short, 'long, Variable> FuncInstBuilder<'short, 'long, Variable>
|
impl<'short, 'long, Variable> FuncInstBuilder<'short, 'long, Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
fn new<'s, 'l>(
|
fn new<'s, 'l>(
|
||||||
builder: &'s mut FunctionBuilder<'l, Variable>,
|
builder: &'s mut FunctionBuilder<'l, Variable>,
|
||||||
@@ -108,7 +108,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short, 'long, Variable>
|
impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short, 'long, Variable>
|
||||||
where Variable: EntityRef + Default
|
where Variable: EntityRef
|
||||||
{
|
{
|
||||||
fn data_flow_graph(&self) -> &DataFlowGraph {
|
fn data_flow_graph(&self) -> &DataFlowGraph {
|
||||||
&self.builder.func.dfg
|
&self.builder.func.dfg
|
||||||
@@ -221,7 +221,7 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
|
|||||||
/// return instruction with arguments that don't match the function's signature.
|
/// return instruction with arguments that don't match the function's signature.
|
||||||
impl<'a, Variable> FunctionBuilder<'a, Variable>
|
impl<'a, Variable> FunctionBuilder<'a, Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
/// Creates a new FunctionBuilder structure that will operate on a `Function` using a
|
/// Creates a new FunctionBuilder structure that will operate on a `Function` using a
|
||||||
/// `IlBuilder`.
|
/// `IlBuilder`.
|
||||||
@@ -442,7 +442,7 @@ where
|
|||||||
/// in ways that can be unsafe if used incorrectly.
|
/// in ways that can be unsafe if used incorrectly.
|
||||||
impl<'a, Variable> FunctionBuilder<'a, Variable>
|
impl<'a, Variable> FunctionBuilder<'a, Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
/// Retrieves all the parameters for an `Ebb` currently inferred from the jump instructions
|
/// Retrieves all the parameters for an `Ebb` currently inferred from the jump instructions
|
||||||
/// inserted that target it and the SSA construction.
|
/// inserted that target it and the SSA construction.
|
||||||
@@ -527,7 +527,7 @@ where
|
|||||||
|
|
||||||
impl<'a, Variable> Drop for FunctionBuilder<'a, Variable>
|
impl<'a, Variable> Drop for FunctionBuilder<'a, Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
/// When a `FunctionBuilder` goes out of scope, it means that the function is fully built.
|
/// When a `FunctionBuilder` goes out of scope, it means that the function is fully built.
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
@@ -549,7 +549,7 @@ where
|
|||||||
// Helper functions
|
// Helper functions
|
||||||
impl<'a, Variable> FunctionBuilder<'a, Variable>
|
impl<'a, Variable> FunctionBuilder<'a, Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
fn move_to_next_basic_block(&mut self) {
|
fn move_to_next_basic_block(&mut self) {
|
||||||
self.position.basic_block = self.builder.ssa.declare_ebb_body_block(
|
self.position.basic_block = self.builder.ssa.declare_ebb_body_block(
|
||||||
@@ -685,11 +685,6 @@ mod tests {
|
|||||||
self.0 as usize
|
self.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Default for Variable {
|
|
||||||
fn default() -> Variable {
|
|
||||||
Variable(u32::MAX)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sample_function(lazy_seal: bool) {
|
fn sample_function(lazy_seal: bool) {
|
||||||
let mut sig = Signature::new(CallConv::Native);
|
let mut sig = Signature::new(CallConv::Native);
|
||||||
|
|||||||
@@ -56,11 +56,6 @@
|
|||||||
//! self.0 as usize
|
//! self.0 as usize
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//! impl Default for Variable {
|
|
||||||
//! fn default() -> Variable {
|
|
||||||
//! Variable(u32::MAX)
|
|
||||||
//! }
|
|
||||||
//! }
|
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! let mut sig = Signature::new(CallConv::Native);
|
//! let mut sig = Signature::new(CallConv::Native);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use std::mem;
|
|||||||
/// can be declared.
|
/// can be declared.
|
||||||
pub struct SSABuilder<Variable>
|
pub struct SSABuilder<Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
// Records for every variable and for every revelant block, the last definition of
|
// Records for every variable and for every revelant block, the last definition of
|
||||||
// the variable in the block.
|
// the variable in the block.
|
||||||
@@ -145,7 +145,7 @@ impl ReservedValue for Block {
|
|||||||
|
|
||||||
impl<Variable> SSABuilder<Variable>
|
impl<Variable> SSABuilder<Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
/// Allocate a new blank SSA builder struct. Use the API function to interact with the struct.
|
/// Allocate a new blank SSA builder struct. Use the API function to interact with the struct.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@@ -252,7 +252,7 @@ fn emit_zero(ty: Type, mut cur: FuncCursor) -> Value {
|
|||||||
///
|
///
|
||||||
impl<Variable> SSABuilder<Variable>
|
impl<Variable> SSABuilder<Variable>
|
||||||
where
|
where
|
||||||
Variable: EntityRef + Default,
|
Variable: EntityRef,
|
||||||
{
|
{
|
||||||
/// Declares a new definition of a variable in a given basic block.
|
/// Declares a new definition of a variable in a given basic block.
|
||||||
/// The SSA value is passed as an argument because it should be created with
|
/// The SSA value is passed as an argument because it should be created with
|
||||||
@@ -735,11 +735,6 @@ mod tests {
|
|||||||
self.0 as usize
|
self.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Default for Variable {
|
|
||||||
fn default() -> Variable {
|
|
||||||
Variable(u32::MAX)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_block() {
|
fn simple_block() {
|
||||||
|
|||||||
Reference in New Issue
Block a user