This is a workaround for type mismatch problem between IR expression and operands in jbc2mpl generated code (issue opened with jbc2mpl at OpenArkCompiler under harmonyos - attached below).

In this patch, the code generator for Maple Engine checks if an expression/instruction has operands returning different primary type than expected by the expr/insn, and if so, if the operand is a dread/regread of less than 4 bytes, it inserts a OP_cvt instruction to convert the operand's return data type to what the expr/insn expects.

================
https://gitee.com/harmonyos/OpenArkCompiler/issues/I1TV8X

jbc2mpl generated code with mismatching type which causes failure when code is executed.

  1. Test.java

public class Test {
private byte byteVar;

public static void main(String[] args) {
Test test = new Test();
test.nestedByteVar();
System.out.println(test.byteVar);
}

void nestedByteVar() {
byteVar = 1;
Nested nested = new Nested();
nested.incByte();
}

class Nested {
void incByte() {
byteVar += 1;
}
}
}

  1. Type mismatch generated by jbc2mpl in Test.mpl

213 #LINE Test.java : 19, INSTIDX : 12||000c: iadd
214 dassign %Reg1_I 0 (add i32 (dread i8 %Reg1_B, dread i32 %Reg2_I)) <----- type mismatch between add i32 and dread i8.