18c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//==-- llvm/Target/TargetSelectionDAGInfo.h - SelectionDAG Info --*- C++ -*-==//
28c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//
38c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//                     The LLVM Compiler Infrastructure
48c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//
58c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman// This file is distributed under the University of Illinois Open Source
68c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman// License. See LICENSE.TXT for details.
78c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//
88c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//===----------------------------------------------------------------------===//
98c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//
108c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman// This file declares the TargetSelectionDAGInfo class, which targets can
118c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman// subclass to parameterize the SelectionDAG lowering and instruction
128c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman// selection process.
138c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//
148c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//===----------------------------------------------------------------------===//
158c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman
168c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman#ifndef LLVM_TARGET_TARGETSELECTIONDAGINFO_H
178c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman#define LLVM_TARGET_TARGETSELECTIONDAGINFO_H
188c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman
19ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman#include "llvm/CodeGen/SelectionDAGNodes.h"
20ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman
218c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohmannamespace llvm {
228c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman
233574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmowclass DataLayout;
24ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohmanclass TargetMachine;
25ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman
268c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman//===----------------------------------------------------------------------===//
2717c4a621fe61a70b106548d168271f37fce1e89dDan Gohman/// TargetSelectionDAGInfo - Targets can subclass this to parameterize the
288c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman/// SelectionDAG lowering and instruction selection process.
298c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman///
308c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohmanclass TargetSelectionDAGInfo {
31001d3dc976d7cda8a3dd8c7fd4020b0b96033f4eCraig Topper  TargetSelectionDAGInfo(const TargetSelectionDAGInfo &) LLVM_DELETED_FUNCTION;
32001d3dc976d7cda8a3dd8c7fd4020b0b96033f4eCraig Topper  void operator=(const TargetSelectionDAGInfo &) LLVM_DELETED_FUNCTION;
338c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman
3436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  const DataLayout *DL;
35ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman
36ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohmanprotected:
3736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  const DataLayout *getDataLayout() const { return DL; }
38ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman
398c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohmanpublic:
40cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines  explicit TargetSelectionDAGInfo(const DataLayout *DL);
418c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman  virtual ~TargetSelectionDAGInfo();
42ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman
43ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// EmitTargetCodeForMemcpy - Emit target-specific code that performs a
44ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// memcpy. This can be used by targets to provide code sequences for cases
45ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// that don't fit the target's parameters for simple loads/stores and can be
46ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// more efficient than using a library call. This function can return a null
47ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// SDValue if the target declines to use custom code and a different
48ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// lowering strategy should be used.
49ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  ///
50ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// If AlwaysInline is true, the size is constant and the target should not
51ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// emit any calls and is strongly encouraged to attempt to emit inline code
52ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// even if it is beyond the usual threshold because this intrinsic is being
53ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// expanded in a place where calls are not feasible (e.g. within the prologue
54ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// for another call). If the target chooses to decline an AlwaysInline
55ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// request here, legalize will resort to using simple loads and stores.
56ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  virtual SDValue
57ac6d9bec671252dd1e596fa71180ff6b39d06b5dAndrew Trick  EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl,
58ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                          SDValue Chain,
59ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                          SDValue Op1, SDValue Op2,
60ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                          SDValue Op3, unsigned Align, bool isVolatile,
61ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                          bool AlwaysInline,
62e72f2027e9116c55a5b39ac72732df8d6c45d37cChris Lattner                          MachinePointerInfo DstPtrInfo,
63e72f2027e9116c55a5b39ac72732df8d6c45d37cChris Lattner                          MachinePointerInfo SrcPtrInfo) const {
64ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman    return SDValue();
65ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  }
66ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman
67ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// EmitTargetCodeForMemmove - Emit target-specific code that performs a
68ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// memmove. This can be used by targets to provide code sequences for cases
69ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// that don't fit the target's parameters for simple loads/stores and can be
70ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// more efficient than using a library call. This function can return a null
71ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// SDValue if the target declines to use custom code and a different
72ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// lowering strategy should be used.
73ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  virtual SDValue
74ac6d9bec671252dd1e596fa71180ff6b39d06b5dAndrew Trick  EmitTargetCodeForMemmove(SelectionDAG &DAG, SDLoc dl,
75ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                           SDValue Chain,
76ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                           SDValue Op1, SDValue Op2,
77ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                           SDValue Op3, unsigned Align, bool isVolatile,
78e72f2027e9116c55a5b39ac72732df8d6c45d37cChris Lattner                           MachinePointerInfo DstPtrInfo,
79e72f2027e9116c55a5b39ac72732df8d6c45d37cChris Lattner                           MachinePointerInfo SrcPtrInfo) const {
80ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman    return SDValue();
81ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  }
82ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman
83ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// EmitTargetCodeForMemset - Emit target-specific code that performs a
84ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// memset. This can be used by targets to provide code sequences for cases
85ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// that don't fit the target's parameters for simple stores and can be more
86ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// efficient than using a library call. This function can return a null
87ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// SDValue if the target declines to use custom code and a different
88ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  /// lowering strategy should be used.
89ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  virtual SDValue
90ac6d9bec671252dd1e596fa71180ff6b39d06b5dAndrew Trick  EmitTargetCodeForMemset(SelectionDAG &DAG, SDLoc dl,
91ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                          SDValue Chain,
92ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                          SDValue Op1, SDValue Op2,
93ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman                          SDValue Op3, unsigned Align, bool isVolatile,
94e72f2027e9116c55a5b39ac72732df8d6c45d37cChris Lattner                          MachinePointerInfo DstPtrInfo) const {
95ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman    return SDValue();
96ff7a562751604a9fe13efc75bd59622244b54d35Dan Gohman  }
97ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford
98ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  /// EmitTargetCodeForMemcmp - Emit target-specific code that performs a
99ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  /// memcmp, in cases where that is faster than a libcall.  The first
100ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  /// returned SDValue is the result of the memcmp and the second is
101ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  /// the chain.  Both SDValues can be null if a normal libcall should
102ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  /// be used.
103ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  virtual std::pair<SDValue, SDValue>
104ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  EmitTargetCodeForMemcmp(SelectionDAG &DAG, SDLoc dl,
105ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford                          SDValue Chain,
106ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford                          SDValue Op1, SDValue Op2,
107ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford                          SDValue Op3, MachinePointerInfo Op1PtrInfo,
108ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford                          MachinePointerInfo Op2PtrInfo) const {
109ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford    return std::make_pair(SDValue(), SDValue());
1108c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  }
1118c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford
1128c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  /// EmitTargetCodeForMemchr - Emit target-specific code that performs a
1138c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  /// memchr, in cases where that is faster than a libcall.  The first
1148c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  /// returned SDValue is the result of the memchr and the second is
1158c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  /// the chain.  Both SDValues can be null if a normal libcall should
1168c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  /// be used.
1178c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  virtual std::pair<SDValue, SDValue>
1188c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford  EmitTargetCodeForMemchr(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
1198c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford                          SDValue Src, SDValue Char, SDValue Length,
1208c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford                          MachinePointerInfo SrcPtrInfo) const {
1218c20158fb0e1e5d747077f065eb0170c5af1fbfaRichard Sandiford    return std::make_pair(SDValue(), SDValue());
122ac168b8bc8773a083a10902f64e4ae57a925aee4Richard Sandiford  }
123e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford
1244fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  /// EmitTargetCodeForStrcpy - Emit target-specific code that performs a
1254fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  /// strcpy or stpcpy, in cases where that is faster than a libcall.
1264fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  /// The first returned SDValue is the result of the copy (the start
1274fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  /// of the destination string for strcpy, a pointer to the null terminator
1284fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  /// for stpcpy) and the second is the chain.  Both SDValues can be null
1294fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  /// if a normal libcall should be used.
1304fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  virtual std::pair<SDValue, SDValue>
1314fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  EmitTargetCodeForStrcpy(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
1324fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford                          SDValue Dest, SDValue Src,
1334fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford                          MachinePointerInfo DestPtrInfo,
1344fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford                          MachinePointerInfo SrcPtrInfo,
1354fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford                          bool isStpcpy) const {
1364fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford    return std::make_pair(SDValue(), SDValue());
1374fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford  }
1384fc7355a21e1fa838406e15459aaf54a58fcf909Richard Sandiford
139e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  /// EmitTargetCodeForStrcmp - Emit target-specific code that performs a
140e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  /// strcmp, in cases where that is faster than a libcall.  The first
141e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  /// returned SDValue is the result of the strcmp and the second is
142e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  /// the chain.  Both SDValues can be null if a normal libcall should
143e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  /// be used.
144e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  virtual std::pair<SDValue, SDValue>
145e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  EmitTargetCodeForStrcmp(SelectionDAG &DAG, SDLoc dl,
146e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford                          SDValue Chain,
147e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford                          SDValue Op1, SDValue Op2,
148e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford                          MachinePointerInfo Op1PtrInfo,
149e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford                          MachinePointerInfo Op2PtrInfo) const {
150e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford    return std::make_pair(SDValue(), SDValue());
151e1b2af731e2a45344a7c502232f66c55cd746da0Richard Sandiford  }
15219262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford
15319262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford  virtual std::pair<SDValue, SDValue>
15419262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford  EmitTargetCodeForStrlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
15519262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford                          SDValue Src, MachinePointerInfo SrcPtrInfo) const {
15619262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford    return std::make_pair(SDValue(), SDValue());
15719262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford  }
15819262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford
15919262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford  virtual std::pair<SDValue, SDValue>
16019262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford  EmitTargetCodeForStrnlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
16119262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford                           SDValue Src, SDValue MaxLength,
16219262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford                           MachinePointerInfo SrcPtrInfo) const {
16319262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford    return std::make_pair(SDValue(), SDValue());
16419262ee0725a09b7c621a3d2eb66ba1513ae932aRichard Sandiford  }
1658c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman};
1668c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman
1678c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman} // end llvm namespace
1688c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman
1698c0e89925d6b76b7671fe904a97c618d155dea42Dan Gohman#endif
170