@@ -654,6 +654,15 @@ class Builder {
654654 // / @returns the instruction
655655 ir::Discard* Discard ();
656656
657+ // / Creates a user function call instruction
658+ // / @param func the function to call
659+ // / @param args the call arguments
660+ // / @returns the instruction
661+ template <typename ... ARGS>
662+ ir::UserCall* Call (ir::Function* func, ARGS&&... args) {
663+ return Call (func->ReturnType (), func, std::forward<ARGS>(args)...);
664+ }
665+
657666 // / Creates a user function call instruction
658667 // / @param type the return type of the call
659668 // / @param func the function to call
@@ -688,6 +697,15 @@ class Builder {
688697 Values (std::forward<ARGS>(args)...)));
689698 }
690699
700+ // / Creates a value conversion instruction to the template type T
701+ // / @param val the value to be converted
702+ // / @returns the instruction
703+ template <typename T, typename VAL>
704+ ir::Convert* Convert (VAL&& val) {
705+ auto * type = ir.Types ().Get <T>();
706+ return Convert (type, std::forward<VAL>(val));
707+ }
708+
691709 // / Creates a value conversion instruction
692710 // / @param to the type converted to
693711 // / @param val the value to be converted
@@ -698,6 +716,15 @@ class Builder {
698716 Value (std::forward<VAL>(val))));
699717 }
700718
719+ // / Creates a value constructor instruction to the template type T
720+ // / @param args the arguments to the constructor
721+ // / @returns the instruction
722+ template <typename T, typename ... ARGS>
723+ ir::Construct* Construct (ARGS&&... args) {
724+ auto * type = ir.Types ().Get <T>();
725+ return Construct (type, std::forward<ARGS>(args)...);
726+ }
727+
701728 // / Creates a value constructor instruction
702729 // / @param type the type to constructed
703730 // / @param args the arguments to the constructor
@@ -768,6 +795,25 @@ class Builder {
768795 // / @returns the instruction
769796 ir::Var* Var (std::string_view name, const core::type::Pointer* type);
770797
798+ // / Creates a new `var` declaration with a name and initializer value
799+ // / @param name the var name
800+ // / @param init the var initializer
801+ // / @returns the instruction
802+ template <core::AddressSpace SPACE = core::AddressSpace::kFunction ,
803+ core::Access ACCESS = core::Access::kReadWrite ,
804+ typename VALUE = void >
805+ ir::Var* Var (std::string_view name, VALUE&& init) {
806+ auto * val = Value (std::forward<VALUE>(init));
807+ if (TINT_UNLIKELY (!val)) {
808+ TINT_ASSERT (val);
809+ return nullptr ;
810+ }
811+ auto * var = Var (name, ir.Types ().ptr (SPACE, val->Type (), ACCESS));
812+ var->SetInitializer (val);
813+ ir.SetName (var->Result (), name);
814+ return var;
815+ }
816+
771817 // / Creates a new `let` declaration
772818 // / @param name the let name
773819 // / @param value the let value
0 commit comments