blob: 86854c53f1797e6b38c14db094ae37188b91c2cd [file] [log] [blame]
Eugene Zelenko076468c2017-09-20 21:35:51 +00001//===- llvm/lib/Target/ARM/ARMCallLowering.h - Call lowering ----*- C++ -*-===//
Diana Picus22274932016-11-11 08:27:37 +00002//
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//===----------------------------------------------------------------------===//
Eugene Zelenko076468c2017-09-20 21:35:51 +00009//
Diana Picus22274932016-11-11 08:27:37 +000010/// \file
11/// This file describes how to lower LLVM calls to machine code calls.
Eugene Zelenko076468c2017-09-20 21:35:51 +000012//
Diana Picus22274932016-11-11 08:27:37 +000013//===----------------------------------------------------------------------===//
14
Eugene Zelenko076468c2017-09-20 21:35:51 +000015#ifndef LLVM_LIB_TARGET_ARM_ARMCALLLOWERING_H
16#define LLVM_LIB_TARGET_ARM_ARMCALLLOWERING_H
Diana Picus22274932016-11-11 08:27:37 +000017
Eugene Zelenko076468c2017-09-20 21:35:51 +000018#include "llvm/ADT/ArrayRef.h"
Diana Picus22274932016-11-11 08:27:37 +000019#include "llvm/CodeGen/GlobalISel/CallLowering.h"
Eugene Zelenko076468c2017-09-20 21:35:51 +000020#include "llvm/IR/CallingConv.h"
21#include <cstdint>
22#include <functional>
Diana Picus22274932016-11-11 08:27:37 +000023
24namespace llvm {
25
26class ARMTargetLowering;
Eugene Zelenko076468c2017-09-20 21:35:51 +000027class MachineFunction;
Diana Picus812caee2016-12-16 12:54:46 +000028class MachineInstrBuilder;
Eugene Zelenko076468c2017-09-20 21:35:51 +000029class MachineIRBuilder;
30class Value;
Diana Picus22274932016-11-11 08:27:37 +000031
32class ARMCallLowering : public CallLowering {
33public:
34 ARMCallLowering(const ARMTargetLowering &TLI);
35
36 bool lowerReturn(MachineIRBuilder &MIRBuiler, const Value *Val,
37 unsigned VReg) const override;
38
39 bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
40 ArrayRef<unsigned> VRegs) const override;
Diana Picus812caee2016-12-16 12:54:46 +000041
Diana Picusd79253a2017-03-20 14:40:18 +000042 bool lowerCall(MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv,
43 const MachineOperand &Callee, const ArgInfo &OrigRet,
Diana Picus613b6562017-02-21 11:33:59 +000044 ArrayRef<ArgInfo> OrigArgs) const override;
45
Diana Picus812caee2016-12-16 12:54:46 +000046private:
47 bool lowerReturnVal(MachineIRBuilder &MIRBuilder, const Value *Val,
48 unsigned VReg, MachineInstrBuilder &Ret) const;
Diana Picus32cd9b42017-02-02 14:01:00 +000049
Eugene Zelenko076468c2017-09-20 21:35:51 +000050 using SplitArgTy = std::function<void(unsigned Reg, uint64_t Offset)>;
Diana Picus8cca8cb2017-05-29 07:01:52 +000051
Diana Picus32cd9b42017-02-02 14:01:00 +000052 /// Split an argument into one or more arguments that the CC lowering can cope
53 /// with (e.g. replace pointers with integers).
54 void splitToValueTypes(const ArgInfo &OrigArg,
55 SmallVectorImpl<ArgInfo> &SplitArgs,
Diana Picus8cca8cb2017-05-29 07:01:52 +000056 MachineFunction &MF,
57 const SplitArgTy &PerformArgSplit) const;
Diana Picus22274932016-11-11 08:27:37 +000058};
Eugene Zelenko076468c2017-09-20 21:35:51 +000059
60} // end namespace llvm
61
62#endif // LLVM_LIB_TARGET_ARM_ARMCALLLOWERING_H