[ir] Only show type on lhs

This CL updates the IR to only show types on the LHS of an assignment.
The RHS does not show the types anymore. This removes a lot of clutter
from the output.

Bug: tint:1718
Change-Id: I5e9cff2ae5cd727a7a8cb256d08b417233a197d3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133240
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/ir/disassembler.cc b/src/tint/ir/disassembler.cc
index 577d646..f68b21a 100644
--- a/src/tint/ir/disassembler.cc
+++ b/src/tint/ir/disassembler.cc
@@ -352,6 +352,13 @@
     return out_.str();
 }
 
+void Disassembler::EmitValueWithType(const Value* val) {
+    EmitValue(val);
+    if (auto* i = val->As<ir::Instruction>(); i->Type() != nullptr) {
+        out_ << ":" << i->Type()->FriendlyName();
+    }
+}
+
 void Disassembler::EmitValue(const Value* val) {
     tint::Switch(
         val,
@@ -396,12 +403,7 @@
             };
             emit(constant->value);
         },
-        [&](const ir::Instruction* i) {
-            out_ << "%" << IdOf(i);
-            if (i->Type() != nullptr) {
-                out_ << ":" << i->Type()->FriendlyName();
-            }
-        },
+        [&](const ir::Instruction* i) { out_ << "%" << IdOf(i); },
         [&](const ir::BlockParam* p) {
             out_ << "%" << IdOf(p) << ":" << p->Type()->FriendlyName();
         },
@@ -413,28 +415,28 @@
         inst,  //
         [&](const ir::Binary* b) { EmitBinary(b); }, [&](const ir::Unary* u) { EmitUnary(u); },
         [&](const ir::Bitcast* b) {
-            EmitValue(b);
+            EmitValueWithType(b);
             out_ << " = bitcast ";
             EmitArgs(b);
         },
         [&](const ir::Discard*) { out_ << "discard"; },
         [&](const ir::Builtin* b) {
-            EmitValue(b);
+            EmitValueWithType(b);
             out_ << " = " << builtin::str(b->Func()) << " ";
             EmitArgs(b);
         },
         [&](const ir::Construct* c) {
-            EmitValue(c);
+            EmitValueWithType(c);
             out_ << " = construct ";
             EmitArgs(c);
         },
         [&](const ir::Convert* c) {
-            EmitValue(c);
+            EmitValueWithType(c);
             out_ << " = convert " << c->FromType()->FriendlyName() << ", ";
             EmitArgs(c);
         },
         [&](const ir::Load* l) {
-            EmitValue(l);
+            EmitValueWithType(l);
             out_ << " = load ";
             EmitValue(l->from);
         },
@@ -445,7 +447,7 @@
             EmitValue(s->from);
         },
         [&](const ir::UserCall* uc) {
-            EmitValue(uc);
+            EmitValueWithType(uc);
             out_ << " = call " << uc->name.Name();
             if (uc->args.Length() > 0) {
                 out_ << ", ";
@@ -453,7 +455,7 @@
             EmitArgs(uc);
         },
         [&](const ir::Var* v) {
-            EmitValue(v);
+            EmitValueWithType(v);
             out_ << " = var";
             if (v->initializer) {
                 out_ << ", ";
@@ -474,7 +476,7 @@
 }
 
 void Disassembler::EmitBinary(const Binary* b) {
-    EmitValue(b);
+    EmitValueWithType(b);
     out_ << " = ";
     switch (b->kind) {
         case Binary::Kind::kAdd:
@@ -533,7 +535,7 @@
 }
 
 void Disassembler::EmitUnary(const Unary* u) {
-    EmitValue(u);
+    EmitValueWithType(u);
     out_ << " = ";
     switch (u->kind) {
         case Unary::Kind::kComplement:
diff --git a/src/tint/ir/disassembler.h b/src/tint/ir/disassembler.h
index 2438d80..c8953db 100644
--- a/src/tint/ir/disassembler.h
+++ b/src/tint/ir/disassembler.h
@@ -55,6 +55,7 @@
 
     void Walk(const FlowNode* node);
     void EmitInstruction(const Instruction* inst);
+    void EmitValueWithType(const Value* val);
     void EmitValue(const Value* val);
     void EmitArgs(const Call* call);
     void EmitBinary(const Binary* b);
diff --git a/src/tint/ir/from_program_binary_test.cc b/src/tint/ir/from_program_binary_test.cc
index 1319083..85377ff 100644
--- a/src/tint/ir/from_program_binary_test.cc
+++ b/src/tint/ir/from_program_binary_test.cc
@@ -42,7 +42,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = add %1:u32, 4u
+    %tint_symbol:u32 = add %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -64,9 +64,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = add %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = add %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -88,9 +88,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = add %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = add %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -113,7 +113,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = sub %1:u32, 4u
+    %tint_symbol:u32 = sub %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -135,9 +135,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:i32 = load %v1:ptr<private, i32, read_write>
-    %3:i32 = sub %2:i32, 1i
-    store %v1:ptr<private, i32, read_write>, %3:i32
+    %2:i32 = load %v1
+    %3:i32 = sub %2, 1i
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -159,9 +159,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = sub %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = sub %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -184,7 +184,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = mul %1:u32, 4u
+    %tint_symbol:u32 = mul %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -206,9 +206,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = mul %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = mul %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -231,7 +231,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = div %1:u32, 4u
+    %tint_symbol:u32 = div %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -253,9 +253,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = div %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = div %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -278,7 +278,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = mod %1:u32, 4u
+    %tint_symbol:u32 = mod %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -300,9 +300,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = mod %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = mod %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -325,7 +325,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = and %1:u32, 4u
+    %tint_symbol:u32 = and %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -347,9 +347,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:bool = load %v1:ptr<private, bool, read_write>
-    %3:bool = and %2:bool, false
-    store %v1:ptr<private, bool, read_write>, %3:bool
+    %2:bool = load %v1
+    %3:bool = and %2, false
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -372,7 +372,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = or %1:u32, 4u
+    %tint_symbol:u32 = or %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -394,9 +394,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:bool = load %v1:ptr<private, bool, read_write>
-    %3:bool = or %2:bool, false
-    store %v1:ptr<private, bool, read_write>, %3:bool
+    %2:bool = load %v1
+    %3:bool = or %2, false
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -419,7 +419,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = xor %1:u32, 4u
+    %tint_symbol:u32 = xor %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -441,9 +441,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = xor %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = xor %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -468,14 +468,14 @@
     %1:bool = call my_func
   } -> %fn5 # branch
 
-  %fn5 = if %1:bool [t: %fn6, f: %fn7, m: %fn8]
+  %fn5 = if %1 [t: %fn6, f: %fn7, m: %fn8]
     # true branch
     %fn6 = block {
     } -> %fn8 false # branch
 
     # false branch
     %fn7 = block {
-    } -> %fn8 %1:bool # branch
+    } -> %fn8 %1 # branch
 
   # if merge
   %fn8 = block (%2:bool) {
@@ -516,10 +516,10 @@
     %1:bool = call my_func
   } -> %fn5 # branch
 
-  %fn5 = if %1:bool [t: %fn6, f: %fn7, m: %fn8]
+  %fn5 = if %1 [t: %fn6, f: %fn7, m: %fn8]
     # true branch
     %fn6 = block {
-    } -> %fn8 %1:bool # branch
+    } -> %fn8 %1 # branch
 
     # false branch
     %fn7 = block {
@@ -562,7 +562,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:bool = eq %1:u32, 4u
+    %tint_symbol:bool = eq %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -585,7 +585,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:bool = neq %1:u32, 4u
+    %tint_symbol:bool = neq %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -608,7 +608,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:bool = lt %1:u32, 4u
+    %tint_symbol:bool = lt %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -631,7 +631,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:bool = gt %1:u32, 4u
+    %tint_symbol:bool = gt %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -654,7 +654,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:bool = lte %1:u32, 4u
+    %tint_symbol:bool = lte %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -677,7 +677,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:bool = gte %1:u32, 4u
+    %tint_symbol:bool = gte %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -700,7 +700,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = shiftl %1:u32, 4u
+    %tint_symbol:u32 = shiftl %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -722,9 +722,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = shiftl %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = shiftl %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -747,7 +747,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = shiftr %1:u32, 4u
+    %tint_symbol:u32 = shiftr %1, 4u
   } -> %func_end # return
 } %func_end
 
@@ -769,9 +769,9 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:u32 = load %v1:ptr<private, u32, read_write>
-    %3:u32 = shiftr %2:u32, 1u
-    store %v1:ptr<private, u32, read_write>, %3:u32
+    %2:u32 = load %v1
+    %3:u32 = shiftr %2, 1u
+    store %v1, %3
   } -> %func_end # return
 } %func_end
 
@@ -796,22 +796,22 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:f32 = call my_func
-    %2:bool = lt %1:f32, 2.0f
+    %2:bool = lt %1, 2.0f
   } -> %fn5 # branch
 
-  %fn5 = if %2:bool [t: %fn6, f: %fn7, m: %fn8]
+  %fn5 = if %2 [t: %fn6, f: %fn7, m: %fn8]
     # true branch
     %fn6 = block {
       %3:f32 = call my_func
       %4:f32 = call my_func
-      %5:f32 = mul 2.29999995231628417969f, %4:f32
-      %6:f32 = div %3:f32, %5:f32
-      %7:bool = gt 2.5f, %6:f32
-    } -> %fn8 %7:bool # branch
+      %5:f32 = mul 2.29999995231628417969f, %4
+      %6:f32 = div %3, %5
+      %7:bool = gt 2.5f, %6
+    } -> %fn8 %7 # branch
 
     # false branch
     %fn7 = block {
-    } -> %fn8 %2:bool # branch
+    } -> %fn8 %2 # branch
 
   # if merge
   %fn8 = block (%tint_symbol:bool) {
diff --git a/src/tint/ir/from_program_call_test.cc b/src/tint/ir/from_program_call_test.cc
index f6422e2..038f4dd 100644
--- a/src/tint/ir/from_program_call_test.cc
+++ b/src/tint/ir/from_program_call_test.cc
@@ -43,7 +43,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:f32 = call my_func
-    %tint_symbol:f32 = bitcast %1:f32
+    %tint_symbol:f32 = bitcast %1
   } -> %func_end # return
 } %func_end
 
@@ -106,8 +106,8 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:i32 = load %i:ptr<private, i32, read_write>
-    %tint_symbol:f32 = convert i32, %2:i32
+    %2:i32 = load %i
+    %tint_symbol:f32 = convert i32, %2
   } -> %func_end # return
 } %func_end
 
@@ -144,8 +144,8 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    %2:f32 = load %i:ptr<private, f32, read_write>
-    %tint_symbol:vec3<f32> = construct 2.0f, 3.0f, %2:f32
+    %2:f32 = load %i
+    %tint_symbol:vec3<f32> = construct 2.0f, 3.0f, %2
   } -> %func_end # return
 } %func_end
 
diff --git a/src/tint/ir/from_program_store_test.cc b/src/tint/ir/from_program_store_test.cc
index 808138c..5bb6398 100644
--- a/src/tint/ir/from_program_store_test.cc
+++ b/src/tint/ir/from_program_store_test.cc
@@ -42,7 +42,7 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    store %a:ptr<private, u32, read_write>, 4u
+    store %a, 4u
   } -> %func_end # return
 } %func_end
 
diff --git a/src/tint/ir/from_program_unary_test.cc b/src/tint/ir/from_program_unary_test.cc
index e386554..2afd2a2 100644
--- a/src/tint/ir/from_program_unary_test.cc
+++ b/src/tint/ir/from_program_unary_test.cc
@@ -42,7 +42,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:bool = call my_func
-    %tint_symbol:bool = eq %1:bool, false
+    %tint_symbol:bool = eq %1, false
   } -> %func_end # return
 } %func_end
 
@@ -65,7 +65,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:u32 = call my_func
-    %tint_symbol:u32 = complement %1:u32
+    %tint_symbol:u32 = complement %1
   } -> %func_end # return
 } %func_end
 
@@ -88,7 +88,7 @@
 %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn4 = block {
     %1:i32 = call my_func
-    %tint_symbol:i32 = negation %1:i32
+    %tint_symbol:i32 = negation %1
   } -> %func_end # return
 } %func_end
 
@@ -135,7 +135,7 @@
 
 %fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
   %fn3 = block {
-    store %v3:ptr<private, i32, read_write>, 42i
+    store %v3, 42i
   } -> %func_end # return
 } %func_end