[LLVMdev] Advice on field access, adding a Modula-3 front end
Rodney M. Bates
rodney_bates at lcwb.coop
Thu Apr 10 18:40:21 PDT 2014
I am doing some preliminary investigation into splicing the Modula-3
compiler front end onto llvm. I have a number of questions and will
no doubt have more, but will start by asking for advice on this one.
The M3 front end has lowered things farther than the llvm IR expects.
Whereas llvm accesses fields/data members of records/structs by field
number, M3 has already laid out the format of records, and its IR
accesses fields by bit offsets.
I could probably create llvm IR in this style by generating explicit
address arithmetic, but I suspect that might hurt the optimization
possibilities, perhaps a lot. It looks like re-raising the level to
field numbers would not be horribly difficult, but it would require
using information in the M3 IR that is apparently intended to be debug
info only. Also, it looks like M3 IR follows the same principle that
llvm does, i.e., that debug information should not affect translation.
I presume llvm does its own memory layout for structs?
It is worse with global variables and constants. Here, in the M3 IR,
for each compilation unit, these have been collected into two records,
one for constants and one for variables, with the memory layout within
them already done. These are accessed with byte offsets within the
two records. What makes it more complicated is that some of the
fields are in a fixed layout that the runtime system expects. So to
use field number access, I would still need to force llvm to accept
the memory layout I supply. Can I do that?
Local variables come through at a matching level, so are not a
problem.
Any advice would be greatly appreciated
--
Rodney Bates
rodney.m.bates at acm.org
More information about the llvm-dev
mailing list