@@ -176,6 +176,11 @@ struct Env {
176176 &func, src, const_cast <void *>(static_cast <const void *>(&fs)))));
177177 }
178178
179+ // Convenience: create + insert a Branch via pure C factory.
180+ Register* emitBranch (BasicBlock* target) {
181+ return emitCInstr (static_cast <Instr*>(hir_c_create_branch (target)));
182+ }
183+
179184 // Insert a pre-created instruction from a C factory into the current block.
180185 // Sets bytecode offset, inserts at cursor, computes output type.
181186 // Returns the output register (or nullptr if no output).
@@ -237,12 +242,12 @@ struct Env {
237242 block = bb1;
238243 cursor = bb1->end ();
239244 Register* bb1_reg = do_bb1 ();
240- emit<Branch> (tail);
245+ emitBranch (tail);
241246
242247 block = bb2;
243248 cursor = bb2->end ();
244249 Register* bb2_reg = do_bb2 ();
245- emit<Branch> (tail);
250+ emitBranch (tail);
246251
247252 block = tail;
248253 cursor = tail->begin ();
@@ -283,7 +288,7 @@ struct Env {
283288 block = slow_path;
284289 cursor = slow_path->begin ();
285290 auto slow_path_value = do_slow_path ();
286- emit<Branch> (fast_path);
291+ emitBranch (fast_path);
287292
288293 block = fast_path;
289294 cursor = fast_path->begin ();
@@ -498,7 +503,7 @@ Register* simplifyCondBranch(Env& env, const CondBranch* instr) {
498503 // Constant condition folds into an unconditional jump.
499504 if (hir_type_has_int_spec (&cond_hir)) {
500505 auto spec = hir_type_int_spec (&cond_hir);
501- return env.emit <Branch> (spec ? instr->true_bb () : instr->false_bb ());
506+ return env.emitBranch (spec ? instr->true_bb () : instr->false_bb ());
502507 }
503508 // Common pattern of CondBranch getting its condition from an IntConvert,
504509 // which had been simplified down from an IsTruthy. Can forward the value
@@ -522,13 +527,13 @@ Register* simplifyCondBranchCheckType(
522527 Type expected_type = instr->type ();
523528 if (actual_type <= expected_type) {
524529 env.emit <UseType>(value, actual_type);
525- return env.emit <Branch> (instr->true_bb ());
530+ return env.emitBranch (instr->true_bb ());
526531 }
527532 HirType actual_hir = to_hir (actual_type);
528533 HirType expected_hir = to_hir (expected_type);
529534 if (!hir_type_could_be (&actual_hir, &expected_hir)) {
530535 env.emit <UseType>(value, actual_type);
531- return env.emit <Branch> (instr->false_bb ());
536+ return env.emitBranch (instr->false_bb ());
532537 }
533538 return nullptr ;
534539}
0 commit comments