llvm.org GIT mirror llvm / e7d4e83
R600: Take alignment into account when calculating the stack offset git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199826 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 6 years ago
2 changed file(s) with 42 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7676 // Start the offset at 2 so we don't overwrite work group information.
7777 // XXX: We should only do this when the shader actually uses this
7878 // information.
79 unsigned Offset = 2;
79 unsigned OffsetBytes = 2 * (getStackWidth(MF) * 4);
8080 int UpperBound = FI == -1 ? MFI->getNumObjects() : FI;
8181
8282 for (int i = MFI->getObjectIndexBegin(); i < UpperBound; ++i) {
83 unsigned Size = MFI->getObjectSize(i);
84 Offset += (Size / (getStackWidth(MF) * 4));
83 OffsetBytes = RoundUpToAlignment(OffsetBytes, MFI->getObjectAlignment(i));
84 OffsetBytes += MFI->getObjectSize(i);
85 // Each regiter holds 4 bytes, so we must always align the offset to at
86 // least 4 bytes, so that 2 frame objects won't share the same register.
87 OffsetBytes = RoundUpToAlignment(OffsetBytes, 4);
8588 }
86 return Offset;
89
90 if (FI != -1)
91 OffsetBytes = RoundUpToAlignment(OffsetBytes, MFI->getObjectAlignment(FI));
92
93 return OffsetBytes / (getStackWidth(MF) * 4);
8794 }
8895
8996 const TargetFrameLowering::SpillSlot *
179179 ret void
180180 }
181181
182 ; Test that two stack objects are not stored in the same register
183 ; The second stack object should be in T3.X
184 ; FUNC-LABEL: @no_overlap
185 ; R600-CHECK: MOV {{\** *}}T3.X
186 ; SI-CHECK: V_MOV_B32_e32 v3
187 define void @no_overlap(i32 addrspace(1)* %out, i32 %in) {
188 entry:
189 %0 = alloca [3 x i8], align 1
190 %1 = alloca [2 x i8], align 1
191 %2 = getelementptr [3 x i8]* %0, i32 0, i32 0
192 %3 = getelementptr [3 x i8]* %0, i32 0, i32 1
193 %4 = getelementptr [3 x i8]* %0, i32 0, i32 2
194 %5 = getelementptr [2 x i8]* %1, i32 0, i32 0
195 %6 = getelementptr [2 x i8]* %1, i32 0, i32 1
196 store i8 0, i8* %2
197 store i8 1, i8* %3
198 store i8 2, i8* %4
199 store i8 1, i8* %5
200 store i8 0, i8* %6
201 %7 = getelementptr [3 x i8]* %0, i32 0, i32 %in
202 %8 = getelementptr [2 x i8]* %1, i32 0, i32 %in
203 %9 = load i8* %7
204 %10 = load i8* %8
205 %11 = add i8 %9, %10
206 %12 = sext i8 %11 to i32
207 store i32 %12, i32 addrspace(1)* %out
208 ret void
209 }
210
211
212
182213 declare i32 @llvm.r600.read.tidig.x() nounwind readnone