Memory read inside if-statement not generating correct code
maltevonehren opened this issue · comments
Malte von Ehren commented
Hello,
I have noticed that a memory access placed inside of an if statement does not generate code for actually reading the memory.
A small example:
This behavior describtion generates the following code:
behavior: {
if ((signed<32>)MEM[0] > 0)
X[1] = 1;
}
partInit.code() += "cpu->instructionPointer = " + std::to_string(ic.current_address_ + 4U) + ";\n";
partInit.code() += "if ((etiss_int32)(mem_val_0) > 0U) {\n";
partInit.code() += "*((RV32IMACFD*)cpu)->X[" + std::to_string(1U) + "] = 1U;\n";
partInit.code() += "}\n";
Where I would have expected it to generate the code below or throw an error.
partInit.code() += "cpu->instructionPointer = " + std::to_string(ic.current_address_ + 4U) + ";\n";
partInit.code() += "etiss_uint32 mem_val_0;\n";
partInit.code() += "exception |= (*(system->dread))(system->handle, cpu, "
+ std::to_string(0U) + ", (etiss_uint8*)&mem_val_0, 4);\n";
partInit.code() += "if ((etiss_int32)(mem_val_0) > 0U) {\n";
partInit.code() += "*((RV32IMACFD*)cpu)->X[" + std::to_string(1U) + "] = 1U;\n";
partInit.code() += "}\n";
Thanks
Malte von Ehren commented
Works fine now. Thanks!