1 //===--- SPIRVCallLowering.h - Call lowering --------------------*- 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 // This file describes how to lower LLVM calls to machine code calls.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_SPIRV_SPIRVCALLLOWERING_H
14 #define LLVM_LIB_TARGET_SPIRV_SPIRVCALLLOWERING_H
15 
16 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
17 
18 namespace llvm {
19 
20 class SPIRVGlobalRegistry;
21 class SPIRVSubtarget;
22 class SPIRVTargetLowering;
23 
24 class SPIRVCallLowering : public CallLowering {
25 private:
26   const SPIRVSubtarget &ST;
27   // Used to create and assign function, argument, and return type information.
28   SPIRVGlobalRegistry *GR;
29 
30 public:
31   SPIRVCallLowering(const SPIRVTargetLowering &TLI, const SPIRVSubtarget &ST,
32                     SPIRVGlobalRegistry *GR);
33 
34   // Built OpReturn or OpReturnValue.
35   bool lowerReturn(MachineIRBuilder &MIRBuiler, const Value *Val,
36                    ArrayRef<Register> VRegs, FunctionLoweringInfo &FLI,
37                    Register SwiftErrorVReg) const override;
38 
39   // Build OpFunction, OpFunctionParameter, and any EntryPoint or Linkage data.
40   bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
41                             ArrayRef<ArrayRef<Register>> VRegs,
42                             FunctionLoweringInfo &FLI) const override;
43 
44   // Build OpCall, or replace with a builtin function.
45   bool lowerCall(MachineIRBuilder &MIRBuilder,
46                  CallLoweringInfo &Info) const override;
47 };
48 } // end namespace llvm
49 
50 #endif // LLVM_LIB_TARGET_SPIRV_SPIRVCALLLOWERING_H
51