[spirv][ir] Add helper for printing extended instructions

Add a helper lambda for creating GLSL STD450 extended instructions.

Bug: 42250952
Change-Id: I280dbdc8cc4e93a473da43892ba15c288e35ca06
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/220935
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/spirv/writer/printer/printer.cc b/src/tint/lang/spirv/writer/printer/printer.cc
index ddc9307..a25edfc 100644
--- a/src/tint/lang/spirv/writer/printer/printer.cc
+++ b/src/tint/lang/spirv/writer/printer/printer.cc
@@ -1278,6 +1278,13 @@
         }
 
         spv::Op op = spv::Op::Max;
+
+        auto ext_inst = [&](enum GLSLstd450 inst) {
+            op = spv::Op::OpExtInst;
+            operands.push_back(ImportGlslStd450());
+            operands.push_back(U32Operand(inst));
+        };
+
         switch (builtin->Func()) {
             case spirv::BuiltinFn::kArrayLength:
                 op = spv::Op::OpArrayLength;
@@ -1369,9 +1376,7 @@
                 op = spv::Op::OpMatrixTimesVector;
                 break;
             case spirv::BuiltinFn::kNormalize:
-                op = spv::Op::OpExtInst;
-                operands.push_back(ImportGlslStd450());
-                operands.push_back(U32Operand(GLSLstd450Normalize));
+                ext_inst(GLSLstd450Normalize);
                 break;
             case spirv::BuiltinFn::kSampledImage:
                 op = spv::Op::OpSampledImage;
@@ -1386,9 +1391,7 @@
                 op = spv::Op::OpSelect;
                 break;
             case spirv::BuiltinFn::kInverse:
-                op = spv::Op::OpExtInst;
-                operands.push_back(ImportGlslStd450());
-                operands.push_back(U32Operand(GLSLstd450MatrixInverse));
+                ext_inst(GLSLstd450MatrixInverse);
                 break;
             case spirv::BuiltinFn::kUdot:
                 module_.PushExtension("SPV_KHR_integer_dot_product");