1 //===-- llvm/CodeGen/GlobalISel/CallLowering.h - Call lowering --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file describes how to lower LLVM calls to machine code calls.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
16 #define LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/IR/Function.h"
22 // Forward declarations.
23 class MachineIRBuilder;
28 const TargetLowering *TLI;
30 /// Getter for generic TargetLowering class.
31 const TargetLowering *getTLI() const {
35 /// Getter for target specific TargetLowering class.
36 template <class XXXTargetLowering>
37 const XXXTargetLowering *getTLI() const {
38 return static_cast<const XXXTargetLowering *>(TLI);
41 CallLowering(const TargetLowering *TLI) : TLI(TLI) {}
42 virtual ~CallLowering() {}
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.
48 /// \return True if the lowering succeeds, false otherwise.
49 virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
50 unsigned VReg) const {
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
62 /// \return True if the lowering succeeded, false otherwise.
64 lowerFormalArguments(MachineIRBuilder &MIRBuilder,
65 const Function::ArgumentListType &Args,
66 const SmallVectorImpl<unsigned> &VRegs) const {
70 } // End namespace llvm.