souper-harvest: Do not generate assignments of constants
It turns out that Souper does not allow a constant to be assigned to a variable, they may only be used as operands. The 2.0.0 version of the `souper-ir` crate correctly reflects this. In the `cranelift_codegen::souper_harvest` module, we need to modify our Souper IR harvester so that it delays converting `iconst` and `bconst` into Souper IR until their values are used as operands. Finally, some unit tests in the `peepmatic-souper` crate need some small updates as well.
This commit is contained in:
@@ -174,7 +174,6 @@ fn convert_operand(
|
||||
}
|
||||
Some(format!("{}", convert_name(&assn.name)))
|
||||
}
|
||||
ast::AssignmentRhs::Constant(c) => Some(format!("{}", c.value)),
|
||||
ast::AssignmentRhs::Instruction(inst) => match inst {
|
||||
// Unsupported instructions.
|
||||
ast::Instruction::Bswap { .. }
|
||||
@@ -619,8 +618,7 @@ mod tests {
|
||||
"
|
||||
%0:i64 = var
|
||||
%1:i32 = trunc %0
|
||||
%2:i32 = 0
|
||||
cand %1 %2
|
||||
cand %1 0
|
||||
",
|
||||
"\
|
||||
(=> (when (ireduce {i32} $v0)
|
||||
@@ -631,8 +629,7 @@ mod tests {
|
||||
"
|
||||
%0:i32 = var
|
||||
%1:i64 = sext %0
|
||||
%2:i64 = 0
|
||||
cand %1 %2
|
||||
cand %1 0
|
||||
",
|
||||
"\
|
||||
(=> (when (sextend {i64} $v0)
|
||||
@@ -643,8 +640,7 @@ mod tests {
|
||||
"
|
||||
%0:i32 = var
|
||||
%1:i64 = zext %0
|
||||
%2:i64 = 0
|
||||
cand %1 %2
|
||||
cand %1 0
|
||||
",
|
||||
"\
|
||||
(=> (when (uextend {i64} $v0)
|
||||
@@ -677,8 +673,7 @@ mod tests {
|
||||
%1:i32 = var
|
||||
%2:i1 = eq %0, %1
|
||||
%3:i32 = zext %2
|
||||
%4:i32 = 0
|
||||
cand %3 %4
|
||||
cand %3 0
|
||||
",
|
||||
"\
|
||||
(=> (when (bint (icmp eq $v0 $v1))
|
||||
@@ -693,8 +688,7 @@ mod tests {
|
||||
"
|
||||
%0:i32 = var
|
||||
%1:i32 = add %0, 1
|
||||
%2:i32 = 0
|
||||
cand %1 %2
|
||||
cand %1 0
|
||||
",
|
||||
"\
|
||||
(=> (when (iadd_imm 1 $v0)
|
||||
@@ -705,8 +699,7 @@ mod tests {
|
||||
"
|
||||
%0:i32 = var
|
||||
%1:i32 = add 1, %0
|
||||
%2:i32 = 0
|
||||
cand %1 %2
|
||||
cand %1 0
|
||||
",
|
||||
"\
|
||||
(=> (when (iadd_imm 1 $v0)
|
||||
|
||||
Reference in New Issue
Block a user