This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
I am having a problem with structures using the arm cross complier I've built. Initially I noticed that my structures were not being packed in memory. I realize now that this is meant to be efficient, however, I need to share these structures with legacy code on another processor and with specialty hardware that both expect/need them to be packed. I tried the pragma route, the attribute route and finally was successful packing my structures with the directive -fpack_struct. Unfortunately this resulted the compiler being extremely conservative in how it accessed elements of the struct. It now reads one byte at a time from memory and reconstructs longwords in registers (I assume it is worried about the whole structure being unaligned in memory.) I attempted to use the attribute of aligned(4) for the structure and for instances, but this had no discernable effect. I've included a version of the struct and the resulting disassembled code with and without the pack-struct option. (I'm not sure if this is important, but in this example the instance is on the stack.) Any help would be appreciated. typedef struct { union { uint32 A; uint32 B; }; union { int16 C; int16 D; }; uint16 E; uint32 F; uint32 G; union { uint32 H; uint32 I; struct { uint16 J; uint16 K; }; }; union { int16 L; int16 M; struct { uint8 N; uint8 O; }; }; uint16 P; uint32 Q; uint32 R; } my_struct __attribute__((aligned(4))); /*=+=+=+ Unpacked version accessing the last element at an offest 36 =+=+=+=+*/ val = struc_inst->R; 11002bb0: e51b3010 ldr r3, [fp, #-16] 11002bb4: e5933024 ldr r3, [r3, #36] 11002bb8: e50b3014 str r3, [fp, #-20] /*=+=+=+ Packed version accessing the last element 1 byte at a time =+=+=+=+*/ val = struct_inst->R; 11002c18: e51b2010 ldr r2, [fp, #-16] 11002c1c: e5d2101c ldrb r1, [r2, #28] 11002c20: e5d2301d ldrb r3, [r2, #29] 11002c24: e1a03403 mov r3, r3, lsl #8 11002c28: e1831001 orr r1, r3, r1 11002c2c: e5d2301e ldrb r3, [r2, #30] 11002c30: e1a03803 mov r3, r3, lsl #16 11002c34: e1831001 orr r1, r3, r1 11002c38: e5d2301f ldrb r3, [r2, #31] 11002c3c: e1a03c03 mov r3, r3, lsl #24 11002c40: e1833001 orr r3, r3, r1 11002c44: e50b3014 str r3, [fp, #-20] -- For unsubscribe information see http://sourceware.org/lists.html#faq
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |