use melior::ir::{
Location, Operation, Value,
operation::{OperationBuilder, OperationLike},
};
use crate::dialect::felt::FeltType;
pub fn load<'c>(
location: Location<'c>,
addr: Value<'c, '_>,
out_type: Option<FeltType<'c>>,
) -> Operation<'c> {
let ctx = location.context();
let out_type = out_type.unwrap_or_else(|| FeltType::new(unsafe { ctx.to_ref() }));
OperationBuilder::new("ram.load", location)
.add_operands(&[addr])
.add_results(&[out_type.into()])
.build()
.expect("valid operation")
}
#[inline]
pub fn is_ram_load<'c: 'a, 'a>(op: &impl OperationLike<'c, 'a>) -> bool {
crate::operation::isa(op, "ram.load")
}
pub fn store<'c>(location: Location<'c>, addr: Value<'c, '_>, val: Value<'c, '_>) -> Operation<'c> {
OperationBuilder::new("ram.store", location)
.add_operands(&[addr, val])
.build()
.expect("valid operation")
}
#[inline]
pub fn is_ram_store<'c: 'a, 'a>(op: &impl OperationLike<'c, 'a>) -> bool {
crate::operation::isa(op, "ram.store")
}