Skip to content

Commit 4176755

Browse files
committed
[SOL] Use the value size for lowering arguments
1 parent 440b6d3 commit 4176755

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

llvm/lib/Target/SBF/SBFISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ SDValue SBFTargetLowering::LowerFormalArguments(
407407
if (Subtarget->getHasDynamicFrames()) {
408408
// In the new convention, arguments are in at the end of the callee
409409
// frame.
410-
uint64_t Size = PtrVT.getFixedSizeInBits() / 8;
410+
uint64_t Size = VA.getLocVT().getFixedSizeInBits() / 8;
411411
int64_t Offset = -static_cast<int64_t>(VA.getLocMemOffset() + Size);
412412
int FrameIndex =
413413
MF.getFrameInfo().CreateFixedObject(Size, Offset, false);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
; RUN: llc -march=sbf -mcpu=v2 < %s | FileCheck %s
2+
3+
define i64 @test_func(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e) {
4+
start:
5+
; CHECK-LABEL: test_func:
6+
7+
; CHECK: stw [r10 - 20], 300
8+
; CHECK: stdw [r10 - 32], 5400
9+
; CHECK: stw [r10 - 12], 65516
10+
; CHECK: stw [r10 - 4], 5
11+
12+
%res = call i64 @func(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e, i8 5, i16 -20, i32 300, i64 5400)
13+
ret i64 %res
14+
}
15+
16+
define i64 @func(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e, i8 %b8, i16 %b16, i32 %b32, i64 %b64) {
17+
start:
18+
; CHECK-LABEL: func:
19+
; CHECK: add64 r10, -64
20+
%a1 = add i64 %a, %b
21+
%a2 = sub i64 %a1, %c
22+
%a3 = mul i64 %a2, %d
23+
%a4 = add i64 %a3, %e
24+
25+
; -64 + 32 = -32, so this is 5400 in %a5
26+
; CHECK: ldxdw r4, [r10 + 32]
27+
28+
; -64 + 60 = -4, so this is 5 in %b8
29+
; CHECK: ldxw w4, [r10 + 60]
30+
%c0 = trunc i64 %a to i8
31+
%b1 = add i8 %b8, %c0
32+
33+
; -64 + 52 = -12, so this is -20 in %b16
34+
; ldxw w1, [r10 + 52]
35+
%c1 = trunc i64 %b to i16
36+
%b2 = add i16 %b16, %c1
37+
38+
; -64 + 44 = -20, so this is 300 in %b32
39+
; CHECK: ldxw w1, [r10 + 44]
40+
%c2 = trunc i64 %c to i32
41+
%b3 = add i32 %b32, %c2
42+
43+
%a5 = add i64 %a4, %b64
44+
%b4 = sext i8 %b1 to i64
45+
%a6 = sub i64 %a5, %b4
46+
47+
%b5 = sext i16 %b2 to i64
48+
%a7 = mul i64 %a6, %b5
49+
50+
%b6 = sext i32 %b3 to i64
51+
%a8 = add i64 %a7, %b6
52+
53+
ret i64 %a8
54+
}

0 commit comments

Comments
 (0)