Skip to content

bloqade.lanes.rewrite.stackify.CloneConstants

← Module overview

classCloneConstantssource

bloqade.lanes.rewrite.stackify.CloneConstants

Bases: RewriteRule

Clone ``ConstantLike`` (``Const*``) args to be immediately before their consumer.

class CloneConstants

Stack discipline: for a consumer with args [a0, ..., aN] where index 0 is the top of the stack and index N is the deepest, the defining statement of aN must be emitted first and a0 last. This rule iterates args from highest index to lowest; each insert_before(node) call places the new clone right before the consumer, so successive insertions build up: [clone_N, ..., clone_0, consumer].

methodrewrite_Statementsource

bloqade.lanes.rewrite.stackify.CloneConstants.rewrite_Statement

def rewrite_Statement(node: ir.Statement) -> RewriteResult

Parameters

NameTypeDescription
nodeir.Statement

Returns

RewriteResult

source