[LLVMdev] How to handle size_t in front ends?
Talin
viridia at gmail.com
Tue May 6 23:12:12 PDT 2008
For the most part, it appears that writing a front end can be almost
entirely platform-independent. For example, my front end doesn't know
how big a pointer is, and for the most part doesn't care. All of the
platform-specific aspects of compilation have, up to this point, been
hidden behind the IR.
However, where things get tricky is in calling C functions that take a
size_t as a parameter. Since a size_t is the same size as a pointer, it
may be either 32 or 64 bits depending on the target platform. All of a
sudden, I can no longer generate 'target-neutral' IR, but instead must
introduce into the front end knowledge about the target platform.
So my questions are:
1) Is there a way to declare an integer type in the IR that represents
"an int the same size as a pointer" without specifying exactly the size
of a pointer?
2) Assuming the above answer is "no", what's the best way for the front
end to measure the size of a pointer?
-- Talin
More information about the llvm-dev
mailing list