LLVM  10.0.0svn
SelectionDAGTargetInfo.h
Go to the documentation of this file.
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.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
16 #define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
17 
20 #include "llvm/Support/CodeGen.h"
21 #include <utility>
22 
23 namespace llvm {
24 
25 class SelectionDAG;
26 
27 //===----------------------------------------------------------------------===//
28 /// Targets can subclass this to parameterize the
29 /// SelectionDAG lowering and instruction selection process.
30 ///
32 public:
33  explicit SelectionDAGTargetInfo() = default;
36  virtual ~SelectionDAGTargetInfo();
37 
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.
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();
59  }
60 
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.
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();
72  }
73 
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.
81  SDValue Chain, SDValue Op1,
82  SDValue Op2, SDValue Op3,
83  unsigned Align, bool isVolatile,
84  MachinePointerInfo DstPtrInfo) const {
85  return SDValue();
86  }
87 
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>
94  SDValue Op1, SDValue Op2, SDValue Op3,
95  MachinePointerInfo Op1PtrInfo,
96  MachinePointerInfo Op2PtrInfo) const {
97  return std::make_pair(SDValue(), SDValue());
98  }
99 
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>
106  SDValue Src, SDValue Char, SDValue Length,
107  MachinePointerInfo SrcPtrInfo) const {
108  return std::make_pair(SDValue(), SDValue());
109  }
110 
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>
119  SDValue Dest, SDValue Src,
120  MachinePointerInfo DestPtrInfo,
121  MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
122  return std::make_pair(SDValue(), SDValue());
123  }
124 
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>
131  SDValue Op1, SDValue Op2,
132  MachinePointerInfo Op1PtrInfo,
133  MachinePointerInfo Op2PtrInfo) const {
134  return std::make_pair(SDValue(), SDValue());
135  }
136 
137  virtual std::pair<SDValue, SDValue>
139  SDValue Src, MachinePointerInfo SrcPtrInfo) const {
140  return std::make_pair(SDValue(), SDValue());
141  }
142 
143  virtual std::pair<SDValue, SDValue>
145  SDValue Src, SDValue MaxLength,
146  MachinePointerInfo SrcPtrInfo) const {
147  return std::make_pair(SDValue(), SDValue());
148  }
149 
151  SDValue Chain, SDValue Addr,
152  SDValue Size,
153  MachinePointerInfo DstPtrInfo,
154  bool ZeroData) const {
155  return SDValue();
156  }
157 
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;
162  }
163 };
164 
165 } // end namespace llvm
166 
167 #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a strcmp, in cases where that is faster than a libcall...
This class represents lattice values for constants.
Definition: AllocatorList.h:23
virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, MachinePointerInfo DstPtrInfo) const
Emit target-specific code that performs a memset.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Src, SDValue Char, SDValue Length, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memchr, in cases where that is faster than a libcall...
SelectionDAGTargetInfo & operator=(const SelectionDAGTargetInfo &)=delete
virtual bool generateFMAsInMachineCombiner(CodeGenOpt::Level OptLevel) const
virtual SDValue EmitTargetCodeForMemmove(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memmove.
virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Addr, SDValue Size, MachinePointerInfo DstPtrInfo, bool ZeroData) const
virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memcpy.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
This class contains a discriminated union of information about pointers in memory operands...
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dest, SDValue Src, MachinePointerInfo DestPtrInfo, MachinePointerInfo SrcPtrInfo, bool isStpcpy) const
Emit target-specific code that performs a strcpy or stpcpy, in cases where that is faster than a libc...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:221
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, MachinePointerInfo SrcPtrInfo) const
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a memcmp, in cases where that is faster than a libcall...
uint32_t Size
Definition: Profile.cpp:46
static bool isVolatile(Instruction *Inst)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...