Add x86 implementation of shuffle
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::ir;
|
||||
use crate::ir::builder::ReplaceBuilder;
|
||||
use crate::ir::extfunc::ExtFuncData;
|
||||
use crate::ir::instructions::{BranchInfo, CallInfo, InstructionData};
|
||||
use crate::ir::{types, ConstantPool};
|
||||
use crate::ir::{types, ConstantPool, Immediate};
|
||||
use crate::ir::{
|
||||
Ebb, FuncRef, Inst, SigRef, Signature, Type, Value, ValueLabelAssignments, ValueList,
|
||||
ValueListPool,
|
||||
@@ -19,6 +19,7 @@ use core::mem;
|
||||
use core::ops::{Index, IndexMut};
|
||||
use core::u16;
|
||||
use std::collections::HashMap;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// A data flow graph defines all instructions and extended basic blocks in a function as well as
|
||||
/// the data flow dependencies between them. The DFG also tracks values which can be either
|
||||
@@ -70,6 +71,9 @@ pub struct DataFlowGraph {
|
||||
|
||||
/// Constants used within the function
|
||||
pub constants: ConstantPool,
|
||||
|
||||
/// Stores large immediates that otherwise will not fit on InstructionData
|
||||
pub immediates: PrimaryMap<Immediate, Vec<u8>>,
|
||||
}
|
||||
|
||||
impl DataFlowGraph {
|
||||
@@ -85,6 +89,7 @@ impl DataFlowGraph {
|
||||
ext_funcs: PrimaryMap::new(),
|
||||
values_labels: None,
|
||||
constants: ConstantPool::new(),
|
||||
immediates: PrimaryMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +103,8 @@ impl DataFlowGraph {
|
||||
self.signatures.clear();
|
||||
self.ext_funcs.clear();
|
||||
self.values_labels = None;
|
||||
self.constants.clear()
|
||||
self.constants.clear();
|
||||
self.immediates.clear();
|
||||
}
|
||||
|
||||
/// Get the total number of instructions created in this function, whether they are currently
|
||||
|
||||
@@ -181,6 +181,29 @@ impl Constant {
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque reference to an immediate.
|
||||
///
|
||||
/// Some immediates (e.g. SIMD shuffle masks) are too large to store in the
|
||||
/// [`InstructionData`](super::instructions::InstructionData) struct and therefore must be
|
||||
/// tracked separately in [`DataFlowGraph::immediates`](super::dfg::DataFlowGraph). `Immediate`
|
||||
/// provides a way to reference values stored there.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Immediate(u32);
|
||||
entity_impl!(Immediate, "imm");
|
||||
|
||||
impl Immediate {
|
||||
/// Create an immediate reference from its number.
|
||||
///
|
||||
/// This method is for use by the parser.
|
||||
pub fn with_number(n: u32) -> Option<Self> {
|
||||
if n < u32::MAX {
|
||||
Some(Immediate(n))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque reference to a [jump table](https://en.wikipedia.org/wiki/Branch_table).
|
||||
///
|
||||
/// `JumpTable`s are used for indirect branching and are specialized for dense,
|
||||
|
||||
@@ -31,7 +31,8 @@ pub use crate::ir::builder::{InsertBuilder, InstBuilder, InstBuilderBase, InstIn
|
||||
pub use crate::ir::constant::{ConstantData, ConstantOffset, ConstantPool};
|
||||
pub use crate::ir::dfg::{DataFlowGraph, ValueDef};
|
||||
pub use crate::ir::entities::{
|
||||
Constant, Ebb, FuncRef, GlobalValue, Heap, Inst, JumpTable, SigRef, StackSlot, Table, Value,
|
||||
Constant, Ebb, FuncRef, GlobalValue, Heap, Immediate, Inst, JumpTable, SigRef, StackSlot,
|
||||
Table, Value,
|
||||
};
|
||||
pub use crate::ir::extfunc::{
|
||||
AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
|
||||
|
||||
Reference in New Issue
Block a user