Skip to main content

Context

Struct Context 

Source
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: DialectRegistry

Implementations§

Source§

impl Context

Source

pub fn new() -> Self

Source

pub fn intern_string(&mut self, s: &str) -> StringId

Source

pub fn resolve_string(&self, id: StringId) -> &str

Source

pub fn intern_type(&mut self, ty: CoreType) -> TypeId

Source

pub fn resolve_type(&self, id: TypeId) -> &CoreType

Source

pub fn make_integer_type(&mut self, bits: u32, signed: bool) -> TypeId

Source

pub fn make_float_type(&mut self, bits: u32) -> TypeId

Source

pub fn make_bool_type(&mut self) -> TypeId

Source

pub fn make_void_type(&mut self) -> TypeId

Source

pub fn make_index_type(&mut self) -> TypeId

Source

pub fn make_tensor_type( &mut self, shape: Vec<Dimension>, dtype: DataType, layout: MemoryLayout, ) -> TypeId

Source

pub fn make_qubit_type(&mut self) -> TypeId

Source

pub fn make_physical_qubit_type( &mut self, id: usize, t1: f64, t2: f64, freq: f64, fidelity: f64, ) -> TypeId

Source

pub fn make_bit_type(&mut self) -> TypeId

Source

pub fn make_hamiltonian_type(&mut self, num_qubits: usize) -> TypeId

Source

pub fn make_function_type( &mut self, params: Vec<TypeId>, returns: Vec<TypeId>, ) -> TypeId

Source

pub fn make_tuple_type(&mut self, elems: Vec<TypeId>) -> TypeId

Source

pub fn create_value( &mut self, ty: TypeId, name: Option<StringId>, def: DefSite, ) -> ValueKey

Source

pub fn get_value(&self, key: ValueKey) -> Option<&ValueData>

Source

pub fn value_type(&self, key: ValueKey) -> Option<TypeId>

Source

pub fn create_op( &mut self, name: &str, dialect: &str, inputs: Vec<ValueKey>, result_types: Vec<TypeId>, attrs: Attributes, location: Location, ) -> (OpKey, Vec<ValueKey>)

Source

pub fn get_op(&self, key: OpKey) -> Option<&OperationData>

Source

pub fn get_op_mut(&mut self, key: OpKey) -> Option<&mut OperationData>

Source

pub fn op_name(&self, key: OpKey) -> &str

Source

pub fn op_dialect(&self, key: OpKey) -> &str

Source

pub fn create_block(&mut self) -> BlockKey

Source

pub fn create_block_arg(&mut self, block: BlockKey, ty: TypeId) -> ValueKey

Source

pub fn add_op_to_block(&mut self, block: BlockKey, op: OpKey)

Source

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.

Source

pub fn get_block(&self, key: BlockKey) -> Option<&BlockData>

Source

pub fn create_region(&mut self) -> RegionKey

Source

pub fn add_block_to_region(&mut self, region: RegionKey, block: BlockKey)

Source

pub fn attach_region_to_op(&mut self, op: OpKey, region: RegionKey)

Source

pub fn get_region(&self, key: RegionKey) -> Option<&RegionData>

Source

pub fn create_module(&mut self, name: &str) -> usize

Source

pub fn get_module(&self, index: usize) -> Option<&ModuleData>

Source

pub fn get_module_mut(&mut self, index: usize) -> Option<&mut ModuleData>

Source

pub fn add_function_to_module( &mut self, module_index: usize, func: FunctionData, )

Source

pub fn snapshot(&self) -> ContextSnapshot

Source

pub fn is_qubit_type(&self, ty: TypeId) -> bool

Source

pub fn is_tensor_type(&self, ty: TypeId) -> bool

Source

pub fn is_bit_type(&self, ty: TypeId) -> bool

Source

pub fn get_tensor_info(&self, ty: TypeId) -> Option<&TensorTypeInfo>

Trait Implementations§

Source§

impl Debug for Context

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Context

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.