[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>
This commit is contained in:
dan sinclair 2023-05-17 21:56:43 +00:00 committed by Dawn LUCI CQ
parent 3f18fc9a05
commit 43b110ce53
6 changed files with 91 additions and 88 deletions

View File

@ -352,6 +352,13 @@ std::string Disassembler::Disassemble() {
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 @@ void Disassembler::EmitValue(const Value* val) {
};
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 @@ void Disassembler::EmitInstruction(const Instruction* inst) {
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 @@ void Disassembler::EmitInstruction(const Instruction* inst) {
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 @@ void Disassembler::EmitInstruction(const Instruction* inst) {
EmitArgs(uc);
},
[&](const ir::Var* v) {
EmitValue(v);
EmitValueWithType(v);
out_ << " = var";
if (v->initializer) {
out_ << ", ";
@ -474,7 +476,7 @@ void Disassembler::EmitArgs(const Call* call) {
}
void Disassembler::EmitBinary(const Binary* b) {
EmitValue(b);
EmitValueWithType(b);
out_ << " = ";
switch (b->kind) {
case Binary::Kind::kAdd:
@ -533,7 +535,7 @@ void Disassembler::EmitBinary(const Binary* b) {
}
void Disassembler::EmitUnary(const Unary* u) {
EmitValue(u);
EmitValueWithType(u);
out_ << " = ";
switch (u->kind) {
case Unary::Kind::kComplement:

View File

@ -55,6 +55,7 @@ class Disassembler {
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);

View File

@ -42,7 +42,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Add) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Increment) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAdd) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Subtract) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Decrement) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundSubtract) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Multiply) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundMultiply) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Div) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundDiv) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Modulo) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundModulo) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_And) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAnd) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Or) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundOr) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Xor) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundXor) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalAnd) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalOr) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Equal) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_NotEqual) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThan) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThan) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThanEqual) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThanEqual) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftLeft) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftLeft) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftRight) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftRight) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound) {
%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) {

View File

@ -43,7 +43,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Bitcast) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Convert) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Construct) {
%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

View File

@ -42,7 +42,7 @@ TEST_F(IR_BuilderImplTest, EmitStatement_Assign) {
%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

View File

@ -42,7 +42,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Not) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Complement) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Negation) {
%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 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Indirection) {
%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