]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
Upgrade to OpenSSH 7.3p1.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / CodeGen / GlobalISel / CallLowering.h
1 //===-- llvm/CodeGen/GlobalISel/CallLowering.h - Call lowering --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file describes how to lower LLVM calls to machine code calls.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
16 #define LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
17
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/IR/Function.h"
20
21 namespace llvm {
22 // Forward declarations.
23 class MachineIRBuilder;
24 class TargetLowering;
25 class Value;
26
27 class CallLowering {
28   const TargetLowering *TLI;
29  protected:
30   /// Getter for generic TargetLowering class.
31   const TargetLowering *getTLI() const {
32     return TLI;
33   }
34
35   /// Getter for target specific TargetLowering class.
36   template <class XXXTargetLowering>
37     const XXXTargetLowering *getTLI() const {
38     return static_cast<const XXXTargetLowering *>(TLI);
39   }
40  public:
41   CallLowering(const TargetLowering *TLI) : TLI(TLI) {}
42   virtual ~CallLowering() {}
43
44   /// This hook must be implemented to lower outgoing return values, described
45   /// by \p Val, into the specified virtual register \p VReg.
46   /// This hook is used by GlobalISel.
47   ///
48   /// \return True if the lowering succeeds, false otherwise.
49   virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
50                            unsigned VReg) const {
51     return false;
52   }
53
54   /// This hook must be implemented to lower the incoming (formal)
55   /// arguments, described by \p Args, for GlobalISel. Each argument
56   /// must end up in the related virtual register described by VRegs.
57   /// In other words, the first argument should end up in VRegs[0],
58   /// the second in VRegs[1], and so on.
59   /// \p MIRBuilder is set to the proper insertion for the argument
60   /// lowering.
61   ///
62   /// \return True if the lowering succeeded, false otherwise.
63   virtual bool
64   lowerFormalArguments(MachineIRBuilder &MIRBuilder,
65                        const Function::ArgumentListType &Args,
66                        const SmallVectorImpl<unsigned> &VRegs) const {
67     return false;
68   }
69 };
70 } // End namespace llvm.
71
72 #endif