LLVM 20.0.0git
InlineAsmLowering.h
Go to the documentation of this file.
1//===- llvm/CodeGen/GlobalISel/InlineAsmLowering.h --------------*- 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 inline asm to machine code INLINEASM.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_GLOBALISEL_INLINEASMLOWERING_H
15#define LLVM_CODEGEN_GLOBALISEL_INLINEASMLOWERING_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include <functional>
19
20namespace llvm {
21class CallBase;
22class MachineIRBuilder;
23class MachineOperand;
24class Register;
25class TargetLowering;
26class Value;
27
29 const TargetLowering *TLI;
30
31 virtual void anchor();
32
33public:
34 /// Lower the given inline asm call instruction
35 /// \p GetOrCreateVRegs is a callback to materialize a register for the
36 /// input and output operands of the inline asm
37 /// \return True if the lowering succeeds, false otherwise.
38 bool lowerInlineAsm(MachineIRBuilder &MIRBuilder, const CallBase &CB,
39 std::function<ArrayRef<Register>(const Value &Val)>
40 GetOrCreateVRegs) const;
41
42 /// Lower the specified operand into the Ops vector.
43 /// \p Val is the IR input value to be lowered
44 /// \p Constraint is the user supplied constraint string
45 /// \p Ops is the vector to be filled with the lowered operands
46 /// \return True if the lowering succeeds, false otherwise.
47 virtual bool lowerAsmOperandForConstraint(Value *Val, StringRef Constraint,
48 std::vector<MachineOperand> &Ops,
49 MachineIRBuilder &MIRBuilder) const;
50
51protected:
52 /// Getter for generic TargetLowering class.
53 const TargetLowering *getTLI() const { return TLI; }
54
55 /// Getter for target specific TargetLowering class.
56 template <class XXXTargetLowering> const XXXTargetLowering *getTLI() const {
57 return static_cast<const XXXTargetLowering *>(TLI);
58 }
59
60public:
61 InlineAsmLowering(const TargetLowering *TLI) : TLI(TLI) {}
62 virtual ~InlineAsmLowering() = default;
63};
64
65} // end namespace llvm
66
67#endif // LLVM_CODEGEN_GLOBALISEL_INLINEASMLOWERING_H
Promote Memory to Register
Definition: Mem2Reg.cpp:110
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1120
const TargetLowering * getTLI() const
Getter for generic TargetLowering class.
bool lowerInlineAsm(MachineIRBuilder &MIRBuilder, const CallBase &CB, std::function< ArrayRef< Register >(const Value &Val)> GetOrCreateVRegs) const
Lower the given inline asm call instruction GetOrCreateVRegs is a callback to materialize a register ...
InlineAsmLowering(const TargetLowering *TLI)
virtual ~InlineAsmLowering()=default
const XXXTargetLowering * getTLI() const
Getter for target specific TargetLowering class.
virtual bool lowerAsmOperandForConstraint(Value *Val, StringRef Constraint, std::vector< MachineOperand > &Ops, MachineIRBuilder &MIRBuilder) const
Lower the specified operand into the Ops vector.
Helper class to build MachineInstr.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
LLVM Value Representation.
Definition: Value.h:74
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18