store struct member data as hardware RAM modules.
For example in dhrystone with union removed: %struct.record = type { %struct.record *, i32, i32, i32, [31 x i8], i32, [31 x i8], i8, i8 }
Contains: i8, i32, array of i8 and struct pointer (i32)
1: Smallest member addressable RAM
84 x i8 (84 bytes)
Pros:
Cons:
2: Largest member addressable RAM
21 x i32 (84 bytes)
Pros:
Cons:
3: Entirely addressable RAM
1 x i672 (84 bytes)
Pros:
Cons:
4: Split into groups by addressability
5 x i32, 64 x i8 (84 bytes)
Pros:
Cons:
5. One RAM per member
i32, i32, i32, i32, i32, 31xi8, 31xi8, i8, i8 (84 bytes)
Pros:
Cons:
6. Word-addressable RAM
21 x i32 (84 bytes)
Pros:
Cons:
7. Word-addressable RAM x2 (if word-address % 2 = 0, store in ram 1, otherwise store in ram 2)
11 x i32 + 10 x i32 (84 bytes)
Pros:
Cons:
8. Smallest member addressable RAM x largest member size / smallest member size
21 x i8, 21 x i8, 21 x i8, 21 x i8 (84 bytes)
Pros:
Cons:
Arrays of Structs:
Arrays of Structs, Structs of Arrays, Structs of Structs…:
Struct Alignment:
alloca: alloca %struct.conglomerate, align 8
getelementptr: getelementptr inbounds %struct.conglomerate* %r, i32 0, i32 3
memcpy: call void @llvm.memcpy.i32(i8* %r22, i8* %r1, i32 124, i32 8)
memset: call void @llvm.memset.i32(i8* %r1, i8 0, i32 124, i32 8)
load: load i32* %5, align 4
store: store i8 97, i8* %r1, align 8
bitcast: bitcast %struct.record* %1 to i8*
ptrtoint: %78 = ptrtoint %struct.record* %77 to i32
Find space required for the struct, figure out alignment size
Make sure pointer returned is aligned with the same size as the struct
memcpy/memset to the struct alignment
May take more than one cycle, depending on size
May need to read prior, may need more than one cycle to store, depending on size
May not need to modify
May not need to modify