[llvm-dev] Alignment Member Functions should be Virtual

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Wed May 2 14:07:58 PDT 2018


On 5/1/2018 4:35 AM, Hiroyuki Chishiro via llvm-dev wrote:
> Dear community,
>
> I have developed a backend of new 32-bit RISC ISA, which does not have
> unaligned memory access instructions (e.g., LWL, LWR, SWL, and SWR in
> MIPS).
> Since char and short variables are not 32-bit alignment, these
> variables cannot be correctly accessed.
> Therefore, alignment member functions, especially getCharAlign() and
> getShortAlign() of TargetInfo class in
> clang/include/clang/Basic/TargetInfo.h, should be virtual, in order to
> achieve an ISA-specific alignment in an ISA-specific subclass of
> TargetInfo class.
> In my subclass, these return values are 32.

Even if you fix TargetInfo, the assumption that getCharSize() == 
getCharAlign() == 8 is hardcoded all over the place; you'll have a very 
hard time making that work.  And even if you do make it work, almost all 
software written in C assumes CHAR_BIT == 8, so you'll have a compiler 
which can't actually build any existing software.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list