pub struct Context {
pub values: SlotMap<ValueKey, ValueData>,
pub ops: SlotMap<OpKey, OperationData>,
pub blocks: SlotMap<BlockKey, BlockData>,
pub regions: SlotMap<RegionKey, RegionData>,
pub strings: StringInterner,
pub types: TypeInterner,
pub modules: Vec<ModuleData>,
pub dialects: DialectRegistry,
}Fields§
§values: SlotMap<ValueKey, ValueData>§ops: SlotMap<OpKey, OperationData>§blocks: SlotMap<BlockKey, BlockData>§regions: SlotMap<RegionKey, RegionData>§strings: StringInterner§types: TypeInterner§modules: Vec<ModuleData>§dialects: DialectRegistryImplementations§
Source§impl Context
impl Context
pub fn new() -> Self
pub fn intern_string(&mut self, s: &str) -> StringId
pub fn resolve_string(&self, id: StringId) -> &str
pub fn intern_type(&mut self, ty: CoreType) -> TypeId
pub fn resolve_type(&self, id: TypeId) -> &CoreType
pub fn make_integer_type(&mut self, bits: u32, signed: bool) -> TypeId
pub fn make_float_type(&mut self, bits: u32) -> TypeId
pub fn make_bool_type(&mut self) -> TypeId
pub fn make_void_type(&mut self) -> TypeId
pub fn make_index_type(&mut self) -> TypeId
pub fn make_tensor_type( &mut self, shape: Vec<Dimension>, dtype: DataType, layout: MemoryLayout, ) -> TypeId
pub fn make_qubit_type(&mut self) -> TypeId
pub fn make_physical_qubit_type( &mut self, id: usize, t1: f64, t2: f64, freq: f64, fidelity: f64, ) -> TypeId
pub fn make_bit_type(&mut self) -> TypeId
pub fn make_hamiltonian_type(&mut self, num_qubits: usize) -> TypeId
pub fn make_function_type( &mut self, params: Vec<TypeId>, returns: Vec<TypeId>, ) -> TypeId
pub fn make_tuple_type(&mut self, elems: Vec<TypeId>) -> TypeId
pub fn create_value( &mut self, ty: TypeId, name: Option<StringId>, def: DefSite, ) -> ValueKey
pub fn get_value(&self, key: ValueKey) -> Option<&ValueData>
pub fn value_type(&self, key: ValueKey) -> Option<TypeId>
pub fn create_op( &mut self, name: &str, dialect: &str, inputs: Vec<ValueKey>, result_types: Vec<TypeId>, attrs: Attributes, location: Location, ) -> (OpKey, Vec<ValueKey>)
pub fn get_op(&self, key: OpKey) -> Option<&OperationData>
pub fn get_op_mut(&mut self, key: OpKey) -> Option<&mut OperationData>
pub fn op_name(&self, key: OpKey) -> &str
pub fn op_dialect(&self, key: OpKey) -> &str
pub fn create_block(&mut self) -> BlockKey
pub fn create_block_arg(&mut self, block: BlockKey, ty: TypeId) -> ValueKey
pub fn add_op_to_block(&mut self, block: BlockKey, op: OpKey)
Sourcepub fn insert_op_before(&mut self, before: OpKey, op: OpKey)
pub fn insert_op_before(&mut self, before: OpKey, op: OpKey)
Inserts an operation immediately before before in its block.
If before has no parent block, falls back to appending at the end.
pub fn get_block(&self, key: BlockKey) -> Option<&BlockData>
pub fn create_region(&mut self) -> RegionKey
pub fn add_block_to_region(&mut self, region: RegionKey, block: BlockKey)
pub fn attach_region_to_op(&mut self, op: OpKey, region: RegionKey)
pub fn get_region(&self, key: RegionKey) -> Option<&RegionData>
pub fn create_module(&mut self, name: &str) -> usize
pub fn get_module(&self, index: usize) -> Option<&ModuleData>
pub fn get_module_mut(&mut self, index: usize) -> Option<&mut ModuleData>
pub fn add_function_to_module( &mut self, module_index: usize, func: FunctionData, )
pub fn snapshot(&self) -> ContextSnapshot
pub fn is_qubit_type(&self, ty: TypeId) -> bool
pub fn is_tensor_type(&self, ty: TypeId) -> bool
pub fn is_bit_type(&self, ty: TypeId) -> bool
pub fn get_tensor_info(&self, ty: TypeId) -> Option<&TensorTypeInfo>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl !UnwindSafe for Context
impl Freeze for Context
impl Unpin for Context
impl UnsafeUnpin for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more