forked from OSchip/llvm-project
[AArch64] Trivial implementation of lower return for the IRTranslator.
llvm-svn: 260574
This commit is contained in:
parent
72fde09f19
commit
5cf7b415cc
|
@ -21,6 +21,9 @@
|
|||
#include "MCTargetDesc/AArch64AddressingModes.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/CodeGen/CallingConvLower.h"
|
||||
#ifdef LLVM_BUILD_GLOBAL_ISEL
|
||||
# include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
|
||||
#endif
|
||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
|
@ -3392,6 +3395,32 @@ AArch64TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
|
|||
return DAG.getNode(AArch64ISD::RET_FLAG, DL, MVT::Other, RetOps);
|
||||
}
|
||||
|
||||
#ifdef LLVM_BUILD_GLOBAL_ISEL
|
||||
bool AArch64TargetLowering::LowerReturn(MachineIRBuilder &MIRBuilder,
|
||||
const Value *Val, unsigned VReg) const {
|
||||
MachineInstr *Return = MIRBuilder.buildInstr(AArch64::RET_ReallyLR);
|
||||
assert(Return && "Unable to build a return instruction?!");
|
||||
|
||||
assert(((Val && VReg) || (!Val && !VReg)) && "Return value without a vreg");
|
||||
if (VReg) {
|
||||
assert(Val->getType()->isIntegerTy() && "Type not supported yet");
|
||||
unsigned Size = Val->getType()->getPrimitiveSizeInBits();
|
||||
assert((Size == 64 || Size == 32) && "Size not supported yet");
|
||||
unsigned ResReg = (Size == 32) ? AArch64::W0 : AArch64::X0;
|
||||
// Set the insertion point to be right before Return.
|
||||
MIRBuilder.setInstr(*Return, /* Before */ true);
|
||||
MachineInstr *Copy =
|
||||
MIRBuilder.buildInstr(TargetOpcode::COPY, ResReg, VReg);
|
||||
(void)Copy;
|
||||
assert(Copy->getNextNode() == Return &&
|
||||
"The insertion did not happen where we expected");
|
||||
MachineInstrBuilder(MIRBuilder.getMF(), Return)
|
||||
.addReg(ResReg, RegState::Implicit);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Other Lowering Code
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -452,6 +452,11 @@ private:
|
|||
const SmallVectorImpl<SDValue> &OutVals, SDLoc DL,
|
||||
SelectionDAG &DAG) const override;
|
||||
|
||||
#ifdef LLVM_BUILD_GLOBAL_ISEL
|
||||
bool LowerReturn(MachineIRBuilder &MIRBuiler, const Value *Val,
|
||||
unsigned VReg) const override;
|
||||
#endif
|
||||
|
||||
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
||||
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
|
||||
SDValue LowerDarwinGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
|
||||
|
|
Loading…
Reference in New Issue