pub struct CContext { /* private fields */ }Expand description
Context for C code generation, tracking variable names and SSA inlining.
Implementations§
Source§impl CContext
impl CContext
pub fn new(ref_counts: HashMap<u64, usize>) -> Self
Sourcepub fn get(&self, uop: &Arc<UOp>) -> &str
pub fn get(&self, uop: &Arc<UOp>) -> &str
Get the C expression for a UOp. Panics if not registered.
Sourcepub fn should_inline(&self, id: u64) -> bool
pub fn should_inline(&self, id: u64) -> bool
Check if a value should be inlined (single-use, expression-safe).
Sourcepub fn next_name(&mut self, prefix: &str) -> String
pub fn next_name(&mut self, prefix: &str) -> String
Generate a unique variable name with given prefix.
Sourcepub fn push_indent(&mut self)
pub fn push_indent(&mut self)
Increase indentation depth.
Sourcepub fn pop_indent(&mut self)
pub fn pop_indent(&mut self)
Decrease indentation depth.
Sourcepub fn register_reduce_pending(
&mut self,
reduce_id: u64,
acc_name: String,
dtype: DType,
)
pub fn register_reduce_pending( &mut self, reduce_id: u64, acc_name: String, dtype: DType, )
Register a pending reduce final load.
Auto Trait Implementations§
impl Freeze for CContext
impl RefUnwindSafe for CContext
impl Send for CContext
impl Sync for CContext
impl Unpin for CContext
impl UnsafeUnpin for CContext
impl UnwindSafe for CContext
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more