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