AArch64CallLowering.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //===- AArch64CallLowering.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. /// \file
  10. /// This file describes how to lower LLVM calls to machine code calls.
  11. ///
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING_H
  14. #define LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING_H
  15. #include "llvm/ADT/ArrayRef.h"
  16. #include "llvm/CodeGen/GlobalISel/CallLowering.h"
  17. #include "llvm/IR/CallingConv.h"
  18. #include <cstdint>
  19. #include <functional>
  20. namespace llvm {
  21. class AArch64TargetLowering;
  22. class CCValAssign;
  23. class MachineIRBuilder;
  24. class Type;
  25. class AArch64CallLowering: public CallLowering {
  26. public:
  27. AArch64CallLowering(const AArch64TargetLowering &TLI);
  28. bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
  29. ArrayRef<Register> VRegs, FunctionLoweringInfo &FLI,
  30. Register SwiftErrorVReg) const override;
  31. bool fallBackToDAGISel(const MachineFunction &MF) const override;
  32. bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
  33. ArrayRef<ArrayRef<Register>> VRegs,
  34. FunctionLoweringInfo &FLI) const override;
  35. bool lowerCall(MachineIRBuilder &MIRBuilder,
  36. CallLoweringInfo &Info) const override;
  37. /// Returns true if the call can be lowered as a tail call.
  38. bool
  39. isEligibleForTailCallOptimization(MachineIRBuilder &MIRBuilder,
  40. CallLoweringInfo &Info,
  41. SmallVectorImpl<ArgInfo> &InArgs,
  42. SmallVectorImpl<ArgInfo> &OutArgs) const;
  43. bool supportSwiftError() const override { return true; }
  44. bool isTypeIsValidForThisReturn(EVT Ty) const override;
  45. private:
  46. using RegHandler = std::function<void(MachineIRBuilder &, Type *, unsigned,
  47. CCValAssign &)>;
  48. using MemHandler =
  49. std::function<void(MachineIRBuilder &, int, CCValAssign &)>;
  50. bool lowerTailCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info,
  51. SmallVectorImpl<ArgInfo> &OutArgs) const;
  52. bool
  53. doCallerAndCalleePassArgsTheSameWay(CallLoweringInfo &Info,
  54. MachineFunction &MF,
  55. SmallVectorImpl<ArgInfo> &InArgs) const;
  56. bool
  57. areCalleeOutgoingArgsTailCallable(CallLoweringInfo &Info, MachineFunction &MF,
  58. SmallVectorImpl<ArgInfo> &OutArgs) const;
  59. };
  60. } // end namespace llvm
  61. #endif // LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING_H