Hi, I'm trying to align long long variable on a 4 byte boundary. I tried to change to clang frontend as follow: LongLongAlign = 32 ; LongLongWidth = 64; The asm output is still 8 bytes, when I declare a long long global array: .align 8 How can I change the alignment from 8 byte to 4 byte for long long variables? Do I need to write an ASMprinter class or change something in my backend? Thank you. -- Best Regards, Kumail Ahmed M.Sc. Student TU Kaiserslautern
Krzysztof Parzyszek via llvm-dev
2016-Jan-14 19:54 UTC
[llvm-dev] Aligning Long Long Vairables
Does this happen for individual "long long" variables, or only for arrays? There is something like "long array alignment", and "long array size" that could increase the alignment for arrays that are considered long (according to these settings). I don't remember the exact names, but it's in the same place in clang. -Krzysztof On 1/14/2016 1:01 PM, Kumail Ahmed via llvm-dev wrote:> Hi, > > I'm trying to align long long variable on a 4 byte boundary. I tried > to change to clang frontend as follow: > > LongLongAlign = 32 ; LongLongWidth = 64; > > The asm output is still 8 bytes, when I declare a long long global array: > > .align 8 > > > How can I change the alignment from 8 byte to 4 byte for long long > variables? Do I need to write an ASMprinter class or change something > in my backend? > > Thank you. >-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
On 14 January 2016 at 11:01, Kumail Ahmed via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I'm trying to align long long variable on a 4 byte boundary. I tried > to change to clang frontend as follow: > > LongLongAlign = 32 ; LongLongWidth = 64;These mostly affect things like the preprocessor defines and (possibly) applications of _Alignof.> The asm output is still 8 bytes, when I declare a long long global array:What's your target's DataLayout? You should be able to see it at the top of any module you dump. This is what I'd expect to affect how the backend deals with alignment (including struct/array layout and variable definitions). There should be an "-i64:N-" bit for your 64-bit type, and it sounds you want that to read "-i64:32-". If there's no i64 entry, then the default is (oddly) 32, so this isn't the issue. Cheers. Tim.
Hi Tim, Thanks for your quick reply. My backend doesn't have a true i64 type. I combine two i32 registers to create an extended register, that's supported by my architecture. My datalayout is: ....i64:32:32.... -- Best Regards, Kumail Ahmed M.Sc. Student TU Kaiserslautern On 14 Jan 2016 8:58 p.m., "Tim Northover" <t.p.northover at gmail.com> wrote:> On 14 January 2016 at 11:01, Kumail Ahmed via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > I'm trying to align long long variable on a 4 byte boundary. I tried > > to change to clang frontend as follow: > > > > LongLongAlign = 32 ; LongLongWidth = 64; > > These mostly affect things like the preprocessor defines and > (possibly) applications of _Alignof. > > > The asm output is still 8 bytes, when I declare a long long global array: > > What's your target's DataLayout? You should be able to see it at the > top of any module you dump. > > This is what I'd expect to affect how the backend deals with alignment > (including struct/array layout and variable definitions). There should > be an "-i64:N-" bit for your 64-bit type, and it sounds you want that > to read "-i64:32-". If there's no i64 entry, then the default is > (oddly) 32, so this isn't the issue. > > Cheers. > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160114/43820552/attachment.html>