@@ -125,6 +125,81 @@ void VETargetLowering::initRegisterClasses() {
125
125
}
126
126
}
127
127
128
+ SDValue
129
+ VETargetLowering::LowerReturn (SDValue Chain, CallingConv::ID CallConv,
130
+ bool IsVarArg,
131
+ const SmallVectorImpl<ISD::OutputArg> &Outs,
132
+ const SmallVectorImpl<SDValue> &OutVals,
133
+ const SDLoc &DL, SelectionDAG &DAG) const {
134
+ // CCValAssign - represent the assignment of the return value to locations.
135
+ SmallVector<CCValAssign, 16 > RVLocs;
136
+
137
+ // CCState - Info about the registers and stack slot.
138
+ CCState CCInfo (CallConv, IsVarArg, DAG.getMachineFunction (), RVLocs,
139
+ *DAG.getContext ());
140
+
141
+ // Analyze return values.
142
+ CCInfo.AnalyzeReturn (Outs, getReturnCC (CallConv));
143
+
144
+ SDValue Flag;
145
+ SmallVector<SDValue, 4 > RetOps (1 , Chain);
146
+
147
+ // Copy the result values into the output registers.
148
+ for (unsigned i = 0 ; i != RVLocs.size (); ++i) {
149
+ CCValAssign &VA = RVLocs[i];
150
+ assert (VA.isRegLoc () && " Can only return in registers!" );
151
+ assert (!VA.needsCustom () && " Unexpected custom lowering" );
152
+ SDValue OutVal = OutVals[i];
153
+
154
+ // Integer return values must be sign or zero extended by the callee.
155
+ switch (VA.getLocInfo ()) {
156
+ case CCValAssign::Full:
157
+ break ;
158
+ case CCValAssign::SExt:
159
+ OutVal = DAG.getNode (ISD::SIGN_EXTEND, DL, VA.getLocVT (), OutVal);
160
+ break ;
161
+ case CCValAssign::ZExt:
162
+ OutVal = DAG.getNode (ISD::ZERO_EXTEND, DL, VA.getLocVT (), OutVal);
163
+ break ;
164
+ case CCValAssign::AExt:
165
+ OutVal = DAG.getNode (ISD::ANY_EXTEND, DL, VA.getLocVT (), OutVal);
166
+ break ;
167
+ case CCValAssign::BCvt: {
168
+ // Convert a float return value to i64 with padding.
169
+ // 63 31 0
170
+ // +------+------+
171
+ // | float| 0 |
172
+ // +------+------+
173
+ assert (VA.getLocVT () == MVT::i64 );
174
+ assert (VA.getValVT () == MVT::f32 );
175
+ SDValue Undef = SDValue (
176
+ DAG.getMachineNode (TargetOpcode::IMPLICIT_DEF, DL, MVT::i64 ), 0 );
177
+ SDValue Sub_f32 = DAG.getTargetConstant (VE::sub_f32, DL, MVT::i32 );
178
+ OutVal = SDValue (DAG.getMachineNode (TargetOpcode::INSERT_SUBREG, DL,
179
+ MVT::i64 , Undef, OutVal, Sub_f32),
180
+ 0 );
181
+ break ;
182
+ }
183
+ default :
184
+ llvm_unreachable (" Unknown loc info!" );
185
+ }
186
+
187
+ Chain = DAG.getCopyToReg (Chain, DL, VA.getLocReg (), OutVal, Flag);
188
+
189
+ // Guarantee that all emitted copies are stuck together with flags.
190
+ Flag = Chain.getValue (1 );
191
+ RetOps.push_back (DAG.getRegister (VA.getLocReg (), VA.getLocVT ()));
192
+ }
193
+
194
+ RetOps[0 ] = Chain; // Update chain.
195
+
196
+ // Add the flag if we have it.
197
+ if (Flag.getNode ())
198
+ RetOps.push_back (Flag);
199
+
200
+ return DAG.getNode (VEISD::RET_FLAG, DL, MVT::Other, RetOps);
201
+ }
202
+
128
203
SDValue VETargetLowering::LowerFormalArguments (
129
204
SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
130
205
const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &DL,
@@ -590,81 +665,6 @@ SDValue VETargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
590
665
return Chain;
591
666
}
592
667
593
- SDValue
594
- VETargetLowering::LowerReturn (SDValue Chain, CallingConv::ID CallConv,
595
- bool IsVarArg,
596
- const SmallVectorImpl<ISD::OutputArg> &Outs,
597
- const SmallVectorImpl<SDValue> &OutVals,
598
- const SDLoc &DL, SelectionDAG &DAG) const {
599
- // CCValAssign - represent the assignment of the return value to locations.
600
- SmallVector<CCValAssign, 16 > RVLocs;
601
-
602
- // CCState - Info about the registers and stack slot.
603
- CCState CCInfo (CallConv, IsVarArg, DAG.getMachineFunction (), RVLocs,
604
- *DAG.getContext ());
605
-
606
- // Analyze return values.
607
- CCInfo.AnalyzeReturn (Outs, getReturnCC (CallConv));
608
-
609
- SDValue Flag;
610
- SmallVector<SDValue, 4 > RetOps (1 , Chain);
611
-
612
- // Copy the result values into the output registers.
613
- for (unsigned i = 0 ; i != RVLocs.size (); ++i) {
614
- CCValAssign &VA = RVLocs[i];
615
- assert (VA.isRegLoc () && " Can only return in registers!" );
616
- assert (!VA.needsCustom () && " Unexpected custom lowering" );
617
- SDValue OutVal = OutVals[i];
618
-
619
- // Integer return values must be sign or zero extended by the callee.
620
- switch (VA.getLocInfo ()) {
621
- case CCValAssign::Full:
622
- break ;
623
- case CCValAssign::SExt:
624
- OutVal = DAG.getNode (ISD::SIGN_EXTEND, DL, VA.getLocVT (), OutVal);
625
- break ;
626
- case CCValAssign::ZExt:
627
- OutVal = DAG.getNode (ISD::ZERO_EXTEND, DL, VA.getLocVT (), OutVal);
628
- break ;
629
- case CCValAssign::AExt:
630
- OutVal = DAG.getNode (ISD::ANY_EXTEND, DL, VA.getLocVT (), OutVal);
631
- break ;
632
- case CCValAssign::BCvt: {
633
- // Convert a float return value to i64 with padding.
634
- // 63 31 0
635
- // +------+------+
636
- // | float| 0 |
637
- // +------+------+
638
- assert (VA.getLocVT () == MVT::i64 );
639
- assert (VA.getValVT () == MVT::f32 );
640
- SDValue Undef = SDValue (
641
- DAG.getMachineNode (TargetOpcode::IMPLICIT_DEF, DL, MVT::i64 ), 0 );
642
- SDValue Sub_f32 = DAG.getTargetConstant (VE::sub_f32, DL, MVT::i32 );
643
- OutVal = SDValue (DAG.getMachineNode (TargetOpcode::INSERT_SUBREG, DL,
644
- MVT::i64 , Undef, OutVal, Sub_f32),
645
- 0 );
646
- break ;
647
- }
648
- default :
649
- llvm_unreachable (" Unknown loc info!" );
650
- }
651
-
652
- Chain = DAG.getCopyToReg (Chain, DL, VA.getLocReg (), OutVal, Flag);
653
-
654
- // Guarantee that all emitted copies are stuck together with flags.
655
- Flag = Chain.getValue (1 );
656
- RetOps.push_back (DAG.getRegister (VA.getLocReg (), VA.getLocVT ()));
657
- }
658
-
659
- RetOps[0 ] = Chain; // Update chain.
660
-
661
- // Add the flag if we have it.
662
- if (Flag.getNode ())
663
- RetOps.push_back (Flag);
664
-
665
- return DAG.getNode (VEISD::RET_FLAG, DL, MVT::Other, RetOps);
666
- }
667
-
668
668
bool VETargetLowering::isOffsetFoldingLegal (
669
669
const GlobalAddressSDNode *GA) const {
670
670
// VE uses 64 bit addressing, so we need multiple instructions to generate
0 commit comments