InlineAsmLowering.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/CodeGen/GlobalISel/InlineAsmLowering.h --------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \file
  15. /// This file describes how to lower LLVM inline asm to machine code INLINEASM.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_GLOBALISEL_INLINEASMLOWERING_H
  19. #define LLVM_CODEGEN_GLOBALISEL_INLINEASMLOWERING_H
  20. #include "llvm/ADT/ArrayRef.h"
  21. #include <functional>
  22. namespace llvm {
  23. class CallBase;
  24. class MachineIRBuilder;
  25. class MachineOperand;
  26. class Register;
  27. class TargetLowering;
  28. class Value;
  29. class InlineAsmLowering {
  30. const TargetLowering *TLI;
  31. virtual void anchor();
  32. public:
  33. /// Lower the given inline asm call instruction
  34. /// \p GetOrCreateVRegs is a callback to materialize a register for the
  35. /// input and output operands of the inline asm
  36. /// \return True if the lowering succeeds, false otherwise.
  37. bool lowerInlineAsm(MachineIRBuilder &MIRBuilder, const CallBase &CB,
  38. std::function<ArrayRef<Register>(const Value &Val)>
  39. GetOrCreateVRegs) const;
  40. /// Lower the specified operand into the Ops vector.
  41. /// \p Val is the IR input value to be lowered
  42. /// \p Constraint is the user supplied constraint string
  43. /// \p Ops is the vector to be filled with the lowered operands
  44. /// \return True if the lowering succeeds, false otherwise.
  45. virtual bool lowerAsmOperandForConstraint(Value *Val, StringRef Constraint,
  46. std::vector<MachineOperand> &Ops,
  47. MachineIRBuilder &MIRBuilder) const;
  48. protected:
  49. /// Getter for generic TargetLowering class.
  50. const TargetLowering *getTLI() const { return TLI; }
  51. /// Getter for target specific TargetLowering class.
  52. template <class XXXTargetLowering> const XXXTargetLowering *getTLI() const {
  53. return static_cast<const XXXTargetLowering *>(TLI);
  54. }
  55. public:
  56. InlineAsmLowering(const TargetLowering *TLI) : TLI(TLI) {}
  57. virtual ~InlineAsmLowering() = default;
  58. };
  59. } // end namespace llvm
  60. #endif // LLVM_CODEGEN_GLOBALISEL_INLINEASMLOWERING_H
  61. #ifdef __GNUC__
  62. #pragma GCC diagnostic pop
  63. #endif