You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
x gets stored as a word, but is then retrieved as a byte. At least on a big endian machine, this is going to result in an incorrect read.
I tried looking into the callers of GenWriteLocal in cgmips.c, but I am having a hard time tracking down why they might be passing the wrong value for opSz, especially since the loads are being generated fine.
The text was updated successfully, but these errors were encountered:
if (!isStruct)
{
// This is a special case for initialization of integers smaller than int.// Since a local integer variable always takes as much space as a whole int,// we can optimize code generation a bit by storing the initializer as an int.// This is an old accidental optimization and I preserve it for now.// Note, this implies a little-endian CPU.stack[sp-1][1] =SizeOfWord;
}
It may be worth considering a BIG_ENDIAN define or some official way to disable this optimization. Or consider ifndef MIPS around this.
Yes, that's the place responsible for word-sized initialization of locals.
Off the top of my head, I don't know what else may be broken for big endian CPUs.
There has never been a goal to support big endian CPUs and I should at last document it explicitly.
alexfru
changed the title
Issue working with char / short locals in MIPS
char / short locals in MIPS big-endian
Jan 6, 2020
I am running into functional code issues when using
char
andshort
(or any type smaller than a word) with MIPS code generation.Consider the following example:
When I inspect the output, I see an issue with the handling of
x
:x
gets stored as a word, but is then retrieved as a byte. At least on a big endian machine, this is going to result in an incorrect read.I tried looking into the callers of
GenWriteLocal
incgmips.c
, but I am having a hard time tracking down why they might be passing the wrong value foropSz
, especially since the loads are being generated fine.The text was updated successfully, but these errors were encountered: