llvm.org GIT mirror llvm / 1086572
Merging r232943: ------------------------------------------------------------------------ r232943 | petarj | 2015-03-23 12:28:13 +0000 (Mon, 23 Mar 2015) | 10 lines Fix sign extension for MIPS64 in makeLibCall function Fixing sign extension in makeLibCall for MIPS64. In MIPS64 architecture all 32 bit arguments (int, unsigned int, float 32 (soft float)) must be sign extended. This fixes test "MultiSource/Applications/oggenc/". Patch by Strahinja Petrovic. Differential Revision: http://reviews.llvm.org/D7791 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@235973 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 5 years ago
6 changed file(s) with 235 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
10591059 return false;
10601060 }
10611061
1062 /// Returns true if arguments should be sign-extended in lib calls.
1063 virtual bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const {
1064 return IsSigned;
1065 }
1066
10621067 /// Returns true if the given (atomic) load should be expanded by the
10631068 /// IR-level AtomicExpand pass into a load-linked instruction
10641069 /// (through emitLoadLinked()).
9595 for (unsigned i = 0; i != NumOps; ++i) {
9696 Entry.Node = Ops[i];
9797 Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext());
98 Entry.isSExt = isSigned;
99 Entry.isZExt = !isSigned;
98 Entry.isSExt = shouldSignExtendTypeInLibCall(Ops[i].getValueType(), isSigned);
99 Entry.isZExt = !shouldSignExtendTypeInLibCall(Ops[i].getValueType(), isSigned);
100100 Args.push_back(Entry);
101101 }
102102 SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC), getPointerTy());
103103
104104 Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
105105 TargetLowering::CallLoweringInfo CLI(DAG);
106 bool signExtend = shouldSignExtendTypeInLibCall(RetVT, isSigned);
106107 CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
107108 .setCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args), 0)
108109 .setNoReturn(doesNotReturn).setDiscardResult(!isReturnValueUsed)
109 .setSExtResult(isSigned).setZExtResult(!isSigned);
110 .setSExtResult(signExtend).setZExtResult(!signExtend);
110111 return LowerCallTo(CLI);
111112 }
112113
30583058 return CCInfo.CheckReturn(Outs, RetCC_Mips);
30593059 }
30603060
3061 bool
3062 MipsTargetLowering::shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const {
3063 if (Subtarget.hasMips3() && Subtarget.abiUsesSoftFloat()) {
3064 if (Type == MVT::i32)
3065 return true;
3066 }
3067 return IsSigned;
3068 }
3069
30613070 SDValue
30623071 MipsTargetLowering::LowerReturn(SDValue Chain,
30633072 CallingConv::ID CallConv, bool IsVarArg,
471471 const SmallVectorImpl &OutVals,
472472 SDLoc dl, SelectionDAG &DAG) const override;
473473
474 bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
475
474476 // Inline asm support
475477 ConstraintType
476478 getConstraintType(const std::string &Constraint) const override;
544544
545545 ; ALL-LABEL: load_LD_float:
546546 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gf1)
547 ; ALL: lwu $4, 0($[[R0]])
547 ; ALL: lw $4, 0($[[R0]])
548548 ; ALL: ld $25, %call16(__extendsftf2)
549549 ; ALL: jalr $25
550550
0 ; RUN: llc -march=mips64 -mcpu=mips64r2 -soft-float -O2 < %s | FileCheck %s
1
2 define void @foosf() #0 {
3 entry:
4 %in = alloca float, align 4
5 %out = alloca float, align 4
6 store volatile float 0xBFD59E1380000000, float* %in, align 4
7 %in.0.in.0. = load volatile float, float* %in, align 4
8 %rintf = tail call float @rintf(float %in.0.in.0.) #1
9 store volatile float %rintf, float* %out, align 4
10 ret void
11
12 ; CHECK-LABEL: foosf
13 ; CHECK-NOT: dsll
14 ; CHECK-NOT: dsrl
15 ; CHECK-NOT: lwu
16 }
17
18 declare float @rintf(float)
19
20 define float @foosf1(float* nocapture readonly %a) #0 {
21 entry:
22 %0 = load float, float* %a, align 4
23 %call = tail call float @roundf(float %0) #2
24 ret float %call
25
26 ; CHECK-LABEL: foosf1
27 ; CHECK-NOT: dsll
28 ; CHECK-NOT: dsrl
29 ; CHECK-NOT: lwu
30 }
31
32 declare float @roundf(float) #1
33
34 define float @foosf2(float* nocapture readonly %a) #0 {
35 entry:
36 %0 = load float, float* %a, align 4
37 %call = tail call float @truncf(float %0) #2
38 ret float %call
39
40 ; CHECK-LABEL: foosf2
41 ; CHECK-NOT: dsll
42 ; CHECK-NOT: dsrl
43 ; CHECK-NOT: lwu
44 }
45
46 declare float @truncf(float) #1
47
48 define float @foosf3(float* nocapture readonly %a) #0 {
49 entry:
50 %0 = load float, float* %a, align 4
51 %call = tail call float @floorf(float %0) #2
52 ret float %call
53
54 ; CHECK-LABEL: foosf3
55 ; CHECK-NOT: dsll
56 ; CHECK-NOT: dsrl
57 ; CHECK-NOT: lwu
58 }
59
60 declare float @floorf(float) #1
61
62 define float @foosf4(float* nocapture readonly %a) #0 {
63 entry:
64 %0 = load float, float* %a, align 4
65 %call = tail call float @nearbyintf(float %0) #2
66 ret float %call
67
68 ; CHECK-LABEL: foosf4
69 ; CHECK-NOT: dsll
70 ; CHECK-NOT: dsrl
71 ; CHECK-NOT: lwu
72 }
73
74 declare float @nearbyintf(float) #1
75
76 define float @foosf5(float* nocapture readonly %a) #0 {
77 entry:
78 %0 = load float, float* %a, align 4
79 %mul = fmul float %0, undef
80 ret float %mul
81
82 ; CHECK-LABEL: foosf5
83 ; CHECK-NOT: dsll
84 ; CHECK-NOT: dsrl
85 ; CHECK-NOT: lwu
86 }
87
88 define float @foosf6(float* nocapture readonly %a) #0 {
89 entry:
90 %0 = load float, float* %a, align 4
91 %sub = fsub float %0, undef
92 ret float %sub
93
94 ; CHECK-LABEL: foosf6
95 ; CHECK-NOT: dsll
96 ; CHECK-NOT: dsrl
97 ; CHECK-NOT: lwu
98 }
99
100 define float @foosf7(float* nocapture readonly %a) #0 {
101 entry:
102 %0 = load float, float* %a, align 4
103 %add = fadd float %0, undef
104 ret float %add
105
106 ; CHECK-LABEL: foosf7
107 ; CHECK-NOT: dsll
108 ; CHECK-NOT: dsrl
109 ; CHECK-NOT: lwu
110 }
111
112 define float @foosf8(float* nocapture readonly %a) #0 {
113 entry:
114 %b = alloca float, align 4
115 %b.0.b.0. = load volatile float, float* %b, align 4
116 %0 = load float, float* %a, align 4
117 %div = fdiv float %b.0.b.0., %0
118 ret float %div
119
120 ; CHECK-LABEL: foosf8
121 ; CHECK-NOT: dsll
122 ; CHECK-NOT: dsrl
123 ; CHECK-NOT: lwu
124 }
125
126 define float @foosf9() #0 {
127 entry:
128 %b = alloca float, align 4
129 %b.0.b.0. = load volatile float, float* %b, align 4
130 %conv = fpext float %b.0.b.0. to double
131 %b.0.b.0.3 = load volatile float, float* %b, align 4
132 %conv1 = fpext float %b.0.b.0.3 to double
133 %call = tail call double @pow(double %conv, double %conv1) #1
134 %conv2 = fptrunc double %call to float
135 ret float %conv2
136
137 ; CHECK-LABEL: foosf9
138 ; CHECK-NOT: dsll
139 ; CHECK-NOT: dsrl
140 ; CHECK-NOT: lwu
141 }
142
143 declare double @pow(double, double) #0
144
145 define float @foosf10() #0 {
146 entry:
147 %a = alloca float, align 4
148 %a.0.a.0. = load volatile float, float* %a, align 4
149 %conv = fpext float %a.0.a.0. to double
150 %call = tail call double @sin(double %conv) #1
151 %conv1 = fptrunc double %call to float
152 ret float %conv1
153
154 ; CHECK-LABEL: foosf10
155 ; CHECK-NOT: dsll
156 ; CHECK-NOT: dsrl
157 ; CHECK-NOT: lwu
158 }
159
160 declare double @sin(double) #0
161
162 define float @foosf11() #0 {
163 entry:
164 %b = alloca float, align 4
165 %b.0.b.0. = load volatile float, float* %b, align 4
166 %call = tail call float @ceilf(float %b.0.b.0.) #2
167 ret float %call
168
169 ; CHECK-LABEL: foosf11
170 ; CHECK-NOT: dsll
171 ; CHECK-NOT: dsrl
172 ; CHECK-NOT: lwu
173 }
174
175 declare float @ceilf(float) #1
176
177 define float @foosf12() #0 {
178 entry:
179 %b = alloca float, align 4
180 %a = alloca float, align 4
181 %b.0.b.0. = load volatile float, float* %b, align 4
182 %a.0.a.0. = load volatile float, float* %a, align 4
183 %call = tail call float @fmaxf(float %b.0.b.0., float %a.0.a.0.) #2
184 ret float %call
185
186 ; CHECK-LABEL: foosf12
187 ; CHECK-NOT: dsll
188 ; CHECK-NOT: dsrl
189 ; CHECK-NOT: lwu
190 }
191
192 declare float @fmaxf(float, float) #1
193
194 define float @foosf13() #0 {
195 entry:
196 %b = alloca float, align 4
197 %a = alloca float, align 4
198 %b.0.b.0. = load volatile float, float* %b, align 4
199 %a.0.a.0. = load volatile float, float* %a, align 4
200 %call = tail call float @fminf(float %b.0.b.0., float %a.0.a.0.) #2
201 ret float %call
202
203 ; CHECK-LABEL: foosf13
204 ; CHECK-NOT: dsll
205 ; CHECK-NOT: dsrl
206 ; CHECK-NOT: lwu
207 }
208
209 declare float @fminf(float, float) #1
210
211
212 attributes #0 = { nounwind "use-soft-float"="true" }
213 attributes #1 = { nounwind readnone "use-soft-float"="true" }