Instruction Naming
February 8, 2026 · View on GitHub
This document establishes the naming conventions for SakuraE IR instructions to prevent naming confusion.
- The prefix of every instruction name must be the instruction's unique identifier, with underscores ("_") used to replace hyphens ("-") in multi-word names.
e.g. The instruction cond-br should be named cond_br according to this convention. Example:
block.hpp: line 85:IRValue* createCondBr(IRValue* cond, IRValue* thenBlock, IRValue* elseBlock) { if (!instructions.back()->isTerminal()) return createInstruction(OpKind::cond_br, IRType::getVoidTy(), {cond, thenBlock, elseBlock}, "cond_br.(" + thenBlock->getName() + ").(" + elseBlock->getName() + ")"); return nullptr; }
- For instructions with directional or referential meaning, the target objects should be separated by a dot (.).
e.g.
generator.cpp: line 457:curFunc() ->block(thenExitBlockIndex) ->createInstruction(OpKind::br, IRType::getVoidTy(), {mergeBlock}, "br.if.merge");In the case of the cond-br instruction, the jump target mergeBlock should be appended to the instruction alias, separated by a dot (.).