1 //===-- PPCCallLowering.h - Call lowering for GlobalISel -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file implements the lowering of LLVM calls to machine code calls for
11 /// GlobalISel.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "PPCCallLowering.h"
16 #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
17 #include "llvm/Support/Debug.h"
18
19 #define DEBUG_TYPE "ppc-call-lowering"
20
21 using namespace llvm;
22
PPCCallLowering(const PPCTargetLowering & TLI)23 PPCCallLowering::PPCCallLowering(const PPCTargetLowering &TLI)
24 : CallLowering(&TLI) {}
25
lowerReturn(MachineIRBuilder & MIRBuilder,const Value * Val,ArrayRef<Register> VRegs,FunctionLoweringInfo & FLI,Register SwiftErrorVReg) const26 bool PPCCallLowering::lowerReturn(MachineIRBuilder &MIRBuilder,
27 const Value *Val, ArrayRef<Register> VRegs,
28 FunctionLoweringInfo &FLI,
29 Register SwiftErrorVReg) const {
30 assert(((Val && !VRegs.empty()) || (!Val && VRegs.empty())) &&
31 "Return value without a vreg");
32 if (VRegs.size() > 0)
33 return false;
34
35 MIRBuilder.buildInstr(PPC::BLR8);
36 return true;
37 }
38
lowerFormalArguments(MachineIRBuilder & MIRBuilder,const Function & F,ArrayRef<ArrayRef<Register>> VRegs,FunctionLoweringInfo & FLI) const39 bool PPCCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
40 const Function &F,
41 ArrayRef<ArrayRef<Register>> VRegs,
42 FunctionLoweringInfo &FLI) const {
43
44 // If VRegs is empty, then there are no formal arguments to lower and thus can
45 // always return true. If there are formal arguments, we currently do not
46 // handle them and thus return false.
47 return VRegs.empty();
48 }
49
lowerCall(MachineIRBuilder & MIRBuilder,CallLoweringInfo & Info) const50 bool PPCCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
51 CallLoweringInfo &Info) const {
52 return false;
53 }
54