[Alignment][NFC] Migrate Instructions to Align
[llvm-core.git] / include / llvm / CodeGen / SelectionDAGTargetInfo.h
blob6f6a9a5ae2695c674efad2673565234abc0e6240
1 //==- llvm/CodeGen/SelectionDAGTargetInfo.h - SelectionDAG Info --*- 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 // This file declares the SelectionDAGTargetInfo class, which targets can
10 // subclass to parameterize the SelectionDAG lowering and instruction
11 // selection process.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
16 #define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
18 #include "llvm/CodeGen/MachineMemOperand.h"
19 #include "llvm/CodeGen/SelectionDAGNodes.h"
20 #include "llvm/Support/CodeGen.h"
21 #include <utility>
23 namespace llvm {
25 class SelectionDAG;
27 //===----------------------------------------------------------------------===//
28 /// Targets can subclass this to parameterize the
29 /// SelectionDAG lowering and instruction selection process.
30 ///
31 class SelectionDAGTargetInfo {
32 public:
33 explicit SelectionDAGTargetInfo() = default;
34 SelectionDAGTargetInfo(const SelectionDAGTargetInfo &) = delete;
35 SelectionDAGTargetInfo &operator=(const SelectionDAGTargetInfo &) = delete;
36 virtual ~SelectionDAGTargetInfo();
38 /// Emit target-specific code that performs a memcpy.
39 /// This can be used by targets to provide code sequences for cases
40 /// that don't fit the target's parameters for simple loads/stores and can be
41 /// more efficient than using a library call. This function can return a null
42 /// SDValue if the target declines to use custom code and a different
43 /// lowering strategy should be used.
44 ///
45 /// If AlwaysInline is true, the size is constant and the target should not
46 /// emit any calls and is strongly encouraged to attempt to emit inline code
47 /// even if it is beyond the usual threshold because this intrinsic is being
48 /// expanded in a place where calls are not feasible (e.g. within the prologue
49 /// for another call). If the target chooses to decline an AlwaysInline
50 /// request here, legalize will resort to using simple loads and stores.
51 virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
52 SDValue Chain, SDValue Op1,
53 SDValue Op2, SDValue Op3,
54 unsigned Align, bool isVolatile,
55 bool AlwaysInline,
56 MachinePointerInfo DstPtrInfo,
57 MachinePointerInfo SrcPtrInfo) const {
58 return SDValue();
61 /// Emit target-specific code that performs a memmove.
62 /// This can be used by targets to provide code sequences for cases
63 /// that don't fit the target's parameters for simple loads/stores and can be
64 /// more efficient than using a library call. This function can return a null
65 /// SDValue if the target declines to use custom code and a different
66 /// lowering strategy should be used.
67 virtual SDValue EmitTargetCodeForMemmove(
68 SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1,
69 SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile,
70 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
71 return SDValue();
74 /// Emit target-specific code that performs a memset.
75 /// This can be used by targets to provide code sequences for cases
76 /// that don't fit the target's parameters for simple stores and can be more
77 /// efficient than using a library call. This function can return a null
78 /// SDValue if the target declines to use custom code and a different
79 /// lowering strategy should be used.
80 virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl,
81 SDValue Chain, SDValue Op1,
82 SDValue Op2, SDValue Op3,
83 unsigned Align, bool isVolatile,
84 MachinePointerInfo DstPtrInfo) const {
85 return SDValue();
88 /// Emit target-specific code that performs a memcmp, in cases where that is
89 /// faster than a libcall. The first returned SDValue is the result of the
90 /// memcmp and the second is the chain. Both SDValues can be null if a normal
91 /// libcall should be used.
92 virtual std::pair<SDValue, SDValue>
93 EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
94 SDValue Op1, SDValue Op2, SDValue Op3,
95 MachinePointerInfo Op1PtrInfo,
96 MachinePointerInfo Op2PtrInfo) const {
97 return std::make_pair(SDValue(), SDValue());
100 /// Emit target-specific code that performs a memchr, in cases where that is
101 /// faster than a libcall. The first returned SDValue is the result of the
102 /// memchr and the second is the chain. Both SDValues can be null if a normal
103 /// libcall should be used.
104 virtual std::pair<SDValue, SDValue>
105 EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
106 SDValue Src, SDValue Char, SDValue Length,
107 MachinePointerInfo SrcPtrInfo) const {
108 return std::make_pair(SDValue(), SDValue());
111 /// Emit target-specific code that performs a strcpy or stpcpy, in cases
112 /// where that is faster than a libcall.
113 /// The first returned SDValue is the result of the copy (the start
114 /// of the destination string for strcpy, a pointer to the null terminator
115 /// for stpcpy) and the second is the chain. Both SDValues can be null
116 /// if a normal libcall should be used.
117 virtual std::pair<SDValue, SDValue>
118 EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
119 SDValue Dest, SDValue Src,
120 MachinePointerInfo DestPtrInfo,
121 MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
122 return std::make_pair(SDValue(), SDValue());
125 /// Emit target-specific code that performs a strcmp, in cases where that is
126 /// faster than a libcall.
127 /// The first returned SDValue is the result of the strcmp and the second is
128 /// the chain. Both SDValues can be null if a normal libcall should be used.
129 virtual std::pair<SDValue, SDValue>
130 EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain,
131 SDValue Op1, SDValue Op2,
132 MachinePointerInfo Op1PtrInfo,
133 MachinePointerInfo Op2PtrInfo) const {
134 return std::make_pair(SDValue(), SDValue());
137 virtual std::pair<SDValue, SDValue>
138 EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
139 SDValue Src, MachinePointerInfo SrcPtrInfo) const {
140 return std::make_pair(SDValue(), SDValue());
143 virtual std::pair<SDValue, SDValue>
144 EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain,
145 SDValue Src, SDValue MaxLength,
146 MachinePointerInfo SrcPtrInfo) const {
147 return std::make_pair(SDValue(), SDValue());
150 virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl,
151 SDValue Chain, SDValue Addr,
152 SDValue Size,
153 MachinePointerInfo DstPtrInfo,
154 bool ZeroData) const {
155 return SDValue();
158 // Return true when the decision to generate FMA's (or FMS, FMLA etc) rather
159 // than FMUL and ADD is delegated to the machine combiner.
160 virtual bool generateFMAsInMachineCombiner(CodeGenOpt::Level OptLevel) const {
161 return false;
165 } // end namespace llvm
167 #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H