[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 20 12:06:59 PDT 2005
Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.104 -> 1.105
---
Log message:
Fix CONSTRUCTOR lowering on big-endian bitfield systems, like Darwin. This
fixes SingleSource/UnitTests/2004-06-20-StaticBitfieldInit.c. This corrects
code like this:
struct T {
unsigned X : 5;
unsigned Y : 6;
unsigned Z : 5;
};
struct T GV = { 1, 5, 1 };
Initializing GV to the correct constant for big-endian order.
---
Diffs of the changes: (+7 -1)
llvm-expand.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletion(-)
Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.104 llvm-gcc/gcc/llvm-expand.c:1.105
--- llvm-gcc/gcc/llvm-expand.c:1.104 Fri Jul 15 21:14:08 2005
+++ llvm-gcc/gcc/llvm-expand.c Wed Jul 20 14:06:48 2005
@@ -3985,13 +3985,19 @@
assert(llvm_type_is_integral(FieldType) && "Bad bitfield member ty!");
assert(ElVal->Ty == FieldType && "Types do not agree!");
+ /* If this target lays out bitfields in big-endian order, compute the
+ * actual bit number before we insert the value.
+ */
+ if (BITS_BIG_ENDIAN)
+ FieldOffset = llvm_type_get_size(FieldType)*8-FieldOffset-FieldSize;
+
/* If there is already a value set for this field, mask out any bits
* that are part of the current field (in case the current field is
* multiply initialized to different values). LLVM will constant fold
* all of the constant expressions generated.
*/
if (Result[FieldIndexVal]) {
- long long MaskVal = ~(((1 << FieldSize)-1) << FieldOffset);
+ long long MaskVal = ~(((1ULL << FieldSize)-1) << FieldOffset);
llvm_value *Mask;
assert(sizeof(long long) == 8 && "Must have 64-bit long long!");
More information about the llvm-commits
mailing list