2005-01-07 07:46:32 +00:00
|
|
|
//===-- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ---------*- C++ -*-===//
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2005-01-07 07:46:32 +00:00
|
|
|
// This file declares the SelectionDAG class, and transitively defines the
|
|
|
|
// SDNode class and subclasses.
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-08-11 14:56:26 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_SELECTIONDAG_H
|
|
|
|
#define LLVM_CODEGEN_SELECTIONDAG_H
|
|
|
|
|
2008-07-28 21:51:04 +00:00
|
|
|
#include "llvm/ADT/ilist.h"
|
2008-10-27 18:17:03 +00:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2006-10-27 23:46:08 +00:00
|
|
|
#include "llvm/ADT/FoldingSet.h"
|
2008-06-23 21:08:32 +00:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2006-10-27 23:46:08 +00:00
|
|
|
#include "llvm/CodeGen/SelectionDAGNodes.h"
|
2009-04-29 23:29:43 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2008-07-22 18:04:23 +00:00
|
|
|
#include <cassert>
|
2006-08-16 21:01:10 +00:00
|
|
|
#include <vector>
|
2006-06-29 23:57:05 +00:00
|
|
|
#include <map>
|
2005-11-30 22:45:14 +00:00
|
|
|
#include <string>
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2008-07-28 21:51:04 +00:00
|
|
|
|
|
|
|
class AliasAnalysis;
|
|
|
|
class TargetLowering;
|
|
|
|
class MachineModuleInfo;
|
2009-01-09 19:11:50 +00:00
|
|
|
class DwarfWriter;
|
2008-07-28 21:51:04 +00:00
|
|
|
class MachineFunction;
|
|
|
|
class MachineConstantPoolValue;
|
|
|
|
class FunctionLoweringInfo;
|
|
|
|
|
2008-09-20 18:02:18 +00:00
|
|
|
template<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
|
|
|
|
private:
|
2009-03-27 18:37:13 +00:00
|
|
|
mutable ilist_node<SDNode> Sentinel;
|
2008-07-28 21:51:04 +00:00
|
|
|
public:
|
|
|
|
SDNode *createSentinel() const {
|
2009-03-04 06:57:48 +00:00
|
|
|
return static_cast<SDNode*>(&Sentinel);
|
2008-07-28 21:51:04 +00:00
|
|
|
}
|
|
|
|
static void destroySentinel(SDNode *) {}
|
|
|
|
|
2009-03-04 20:36:44 +00:00
|
|
|
SDNode *provideInitialHead() const { return createSentinel(); }
|
|
|
|
SDNode *ensureHead(SDNode*) const { return createSentinel(); }
|
2009-03-04 21:54:31 +00:00
|
|
|
static void noteHead(SDNode*, SDNode*) {}
|
2009-03-04 20:36:44 +00:00
|
|
|
|
2008-07-28 21:51:04 +00:00
|
|
|
static void deleteNode(SDNode *) {
|
|
|
|
assert(0 && "ilist_traits<SDNode> shouldn't see a deleteNode call!");
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
static void createNode(const SDNode &);
|
|
|
|
};
|
2005-01-07 07:46:32 +00:00
|
|
|
|
2008-11-24 14:53:14 +00:00
|
|
|
enum CombineLevel {
|
|
|
|
Unrestricted, // Combine may create illegal operations and illegal types.
|
|
|
|
NoIllegalTypes, // Combine may create illegal operations but no illegal types.
|
|
|
|
NoIllegalOperations // Combine may only create legal operations and types.
|
|
|
|
};
|
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// SelectionDAG class - This is used to represent a portion of an LLVM function
|
|
|
|
/// in a low-level Data Dependence DAG representation suitable for instruction
|
|
|
|
/// selection. This DAG is constructed as the first step of instruction
|
|
|
|
/// selection in order to allow implementation of machine specific optimizations
|
|
|
|
/// and code simplifications.
|
|
|
|
///
|
|
|
|
/// The representation used by the SelectionDAG is a target-independent
|
|
|
|
/// representation, which has some similarities to the GCC RTL representation,
|
|
|
|
/// but is significantly more simple, powerful, and is a graph form instead of a
|
|
|
|
/// linear form.
|
2003-08-11 14:56:26 +00:00
|
|
|
///
|
|
|
|
class SelectionDAG {
|
2005-01-23 04:36:06 +00:00
|
|
|
TargetLowering &TLI;
|
2008-08-27 23:52:12 +00:00
|
|
|
MachineFunction *MF;
|
2008-06-17 06:09:18 +00:00
|
|
|
FunctionLoweringInfo &FLI;
|
2007-01-26 21:22:28 +00:00
|
|
|
MachineModuleInfo *MMI;
|
2009-01-09 19:11:50 +00:00
|
|
|
DwarfWriter *DW;
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2008-08-23 02:25:05 +00:00
|
|
|
/// EntryNode - The starting token.
|
|
|
|
SDNode EntryNode;
|
|
|
|
|
|
|
|
/// Root - The root of the entire DAG.
|
|
|
|
SDValue Root;
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2006-08-14 22:19:25 +00:00
|
|
|
/// AllNodes - A linked list of nodes in the current DAG.
|
2008-07-28 21:51:04 +00:00
|
|
|
ilist<SDNode> AllNodes;
|
|
|
|
|
2008-08-23 02:25:05 +00:00
|
|
|
/// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use
|
|
|
|
/// pool allocation with recycling.
|
|
|
|
typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode),
|
|
|
|
AlignOf<MostAlignedSDNode>::Alignment>
|
|
|
|
NodeAllocatorType;
|
|
|
|
|
|
|
|
/// NodeAllocator - Pool allocation for nodes.
|
|
|
|
NodeAllocatorType NodeAllocator;
|
2005-05-03 17:19:30 +00:00
|
|
|
|
2006-08-14 22:19:25 +00:00
|
|
|
/// CSEMap - This structure is used to memoize nodes, automatically performing
|
|
|
|
/// CSE with existing nodes with a duplicate is requested.
|
2006-10-27 23:46:08 +00:00
|
|
|
FoldingSet<SDNode> CSEMap;
|
2006-08-14 22:19:25 +00:00
|
|
|
|
2008-08-23 02:25:05 +00:00
|
|
|
/// OperandAllocator - Pool allocation for machine-opcode SDNode operands.
|
|
|
|
BumpPtrAllocator OperandAllocator;
|
|
|
|
|
2008-07-17 19:10:17 +00:00
|
|
|
/// Allocator - Pool allocation for misc. objects that are created once per
|
|
|
|
/// SelectionDAG.
|
|
|
|
BumpPtrAllocator Allocator;
|
|
|
|
|
2008-07-21 10:20:31 +00:00
|
|
|
/// VerifyNode - Sanity check the given node. Aborts if it is invalid.
|
|
|
|
void VerifyNode(SDNode *N);
|
|
|
|
|
2008-10-27 18:17:03 +00:00
|
|
|
/// setGraphColorHelper - Implementation of setSubgraphColor.
|
|
|
|
/// Return whether we had to truncate the search.
|
|
|
|
///
|
2009-03-04 20:36:44 +00:00
|
|
|
bool setSubgraphColorHelper(SDNode *N, const char *Color,
|
|
|
|
DenseSet<SDNode *> &visited,
|
2008-10-27 18:17:03 +00:00
|
|
|
int level, bool &printed);
|
|
|
|
|
2003-08-11 14:56:26 +00:00
|
|
|
public:
|
2008-08-27 23:52:12 +00:00
|
|
|
SelectionDAG(TargetLowering &tli, FunctionLoweringInfo &fli);
|
2003-08-11 14:56:26 +00:00
|
|
|
~SelectionDAG();
|
|
|
|
|
2008-08-27 23:52:12 +00:00
|
|
|
/// init - Prepare this SelectionDAG to process code in the given
|
|
|
|
/// MachineFunction.
|
|
|
|
///
|
2009-01-09 19:11:50 +00:00
|
|
|
void init(MachineFunction &mf, MachineModuleInfo *mmi, DwarfWriter *dw);
|
2008-08-27 23:52:12 +00:00
|
|
|
|
|
|
|
/// clear - Clear state and free memory necessary to make this
|
2008-08-23 02:25:05 +00:00
|
|
|
/// SelectionDAG ready to process a new block.
|
|
|
|
///
|
2008-08-27 23:52:12 +00:00
|
|
|
void clear();
|
2008-08-23 02:25:05 +00:00
|
|
|
|
2008-08-27 23:52:12 +00:00
|
|
|
MachineFunction &getMachineFunction() const { return *MF; }
|
2005-01-23 04:36:06 +00:00
|
|
|
const TargetMachine &getTarget() const;
|
|
|
|
TargetLowering &getTargetLoweringInfo() const { return TLI; }
|
2008-06-17 06:09:18 +00:00
|
|
|
FunctionLoweringInfo &getFunctionLoweringInfo() const { return FLI; }
|
2007-01-26 21:22:28 +00:00
|
|
|
MachineModuleInfo *getMachineModuleInfo() const { return MMI; }
|
2009-01-13 00:35:13 +00:00
|
|
|
DwarfWriter *getDwarfWriter() const { return DW; }
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2006-10-02 12:26:53 +00:00
|
|
|
/// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
|
2005-01-10 23:05:53 +00:00
|
|
|
///
|
2008-07-21 20:00:07 +00:00
|
|
|
void viewGraph(const std::string &Title);
|
2008-07-30 18:48:53 +00:00
|
|
|
void viewGraph();
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2006-10-02 12:26:53 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
std::map<const SDNode *, std::string> NodeGraphAttrs;
|
|
|
|
#endif
|
2005-01-10 23:05:53 +00:00
|
|
|
|
2006-10-02 12:26:53 +00:00
|
|
|
/// clearGraphAttrs - Clear all previously defined node graph attributes.
|
|
|
|
/// Intended to be used from a debugging tool (eg. gdb).
|
|
|
|
void clearGraphAttrs();
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2006-10-02 12:26:53 +00:00
|
|
|
/// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".)
|
|
|
|
///
|
|
|
|
void setGraphAttrs(const SDNode *N, const char *Attrs);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2006-10-02 12:26:53 +00:00
|
|
|
/// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".)
|
|
|
|
/// Used from getNodeAttributes.
|
|
|
|
const std::string getGraphAttrs(const SDNode *N) const;
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2006-10-02 12:26:53 +00:00
|
|
|
/// setGraphColor - Convenience for setting node color attribute.
|
|
|
|
///
|
|
|
|
void setGraphColor(const SDNode *N, const char *Color);
|
2005-01-10 23:05:53 +00:00
|
|
|
|
2008-10-27 18:17:03 +00:00
|
|
|
/// setGraphColor - Convenience for setting subgraph color attribute.
|
|
|
|
///
|
|
|
|
void setSubgraphColor(SDNode *N, const char *Color);
|
|
|
|
|
2008-07-28 21:51:04 +00:00
|
|
|
typedef ilist<SDNode>::const_iterator allnodes_const_iterator;
|
2005-11-09 23:46:43 +00:00
|
|
|
allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
|
|
|
|
allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
|
2008-07-28 21:51:04 +00:00
|
|
|
typedef ilist<SDNode>::iterator allnodes_iterator;
|
2005-11-09 23:46:43 +00:00
|
|
|
allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
|
|
|
|
allnodes_iterator allnodes_end() { return AllNodes.end(); }
|
2008-07-28 21:51:04 +00:00
|
|
|
ilist<SDNode>::size_type allnodes_size() const {
|
2008-07-07 23:02:41 +00:00
|
|
|
return AllNodes.size();
|
|
|
|
}
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// getRoot - Return the root tag of the SelectionDAG.
|
2003-08-11 14:56:26 +00:00
|
|
|
///
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue &getRoot() const { return Root; }
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// getEntryNode - Return the token chain corresponding to the entry of the
|
|
|
|
/// function.
|
2008-08-23 02:25:05 +00:00
|
|
|
SDValue getEntryNode() const {
|
|
|
|
return SDValue(const_cast<SDNode *>(&EntryNode), 0);
|
|
|
|
}
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// setRoot - Set the current root tag of the SelectionDAG.
|
2003-08-11 14:56:26 +00:00
|
|
|
///
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue &setRoot(SDValue N) {
|
2008-08-28 21:40:38 +00:00
|
|
|
assert((!N.getNode() || N.getValueType() == MVT::Other) &&
|
2008-07-22 18:04:23 +00:00
|
|
|
"DAG root value is not a chain!");
|
|
|
|
return Root = N;
|
|
|
|
}
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2005-09-01 00:19:25 +00:00
|
|
|
/// Combine - This iterates over the nodes in the SelectionDAG, folding
|
2008-11-24 14:53:14 +00:00
|
|
|
/// certain types of nodes together, or eliminating superfluous nodes. The
|
|
|
|
/// Level argument controls whether Combine is allowed to produce nodes and
|
|
|
|
/// types that are illegal on the target.
|
2009-04-29 23:29:43 +00:00
|
|
|
void Combine(CombineLevel Level, AliasAnalysis &AA,
|
|
|
|
CodeGenOpt::Level OptLevel);
|
2008-11-24 14:53:14 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
/// LegalizeTypes - This transforms the SelectionDAG into a SelectionDAG that
|
2008-11-24 14:53:14 +00:00
|
|
|
/// only uses types natively supported by the target. Returns "true" if it
|
|
|
|
/// made any changes.
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
///
|
|
|
|
/// Note that this is an involved process that may invalidate pointers into
|
|
|
|
/// the graph.
|
2008-11-24 14:53:14 +00:00
|
|
|
bool LegalizeTypes();
|
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// Legalize - This transforms the SelectionDAG into a SelectionDAG that is
|
|
|
|
/// compatible with the target instruction selector, as indicated by the
|
|
|
|
/// TargetLowering object.
|
2003-08-11 14:56:26 +00:00
|
|
|
///
|
2005-01-07 07:46:32 +00:00
|
|
|
/// Note that this is an involved process that may invalidate pointers into
|
|
|
|
/// the graph.
|
2009-04-29 23:29:43 +00:00
|
|
|
void Legalize(bool TypesNeedLegalizing, CodeGenOpt::Level OptLevel);
|
2005-01-07 07:46:32 +00:00
|
|
|
|
2009-05-23 12:35:30 +00:00
|
|
|
/// LegalizeVectors - This transforms the SelectionDAG into a SelectionDAG
|
|
|
|
/// that only uses vector math operations supported by the target. This is
|
|
|
|
/// necessary as a separate step from Legalize because unrolling a vector
|
|
|
|
/// operation can introduce illegal types, which requires running
|
|
|
|
/// LegalizeTypes again.
|
|
|
|
///
|
|
|
|
/// This returns true if it made any changes; in that case, LegalizeTypes
|
|
|
|
/// is called again before Legalize.
|
|
|
|
///
|
|
|
|
/// Note that this is an involved process that may invalidate pointers into
|
|
|
|
/// the graph.
|
|
|
|
bool LegalizeVectors();
|
|
|
|
|
2005-01-07 21:08:55 +00:00
|
|
|
/// RemoveDeadNodes - This method deletes all unreachable nodes in the
|
2006-08-04 17:45:20 +00:00
|
|
|
/// SelectionDAG.
|
|
|
|
void RemoveDeadNodes();
|
2006-10-12 20:34:05 +00:00
|
|
|
|
|
|
|
/// DeleteNode - Remove the specified node from the system. This node must
|
|
|
|
/// have no referrers.
|
|
|
|
void DeleteNode(SDNode *N);
|
|
|
|
|
2006-08-15 17:46:01 +00:00
|
|
|
/// getVTList - Return an SDVTList that represents the list of values
|
|
|
|
/// specified.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDVTList getVTList(MVT VT);
|
|
|
|
SDVTList getVTList(MVT VT1, MVT VT2);
|
|
|
|
SDVTList getVTList(MVT VT1, MVT VT2, MVT VT3);
|
2008-12-01 23:28:22 +00:00
|
|
|
SDVTList getVTList(MVT VT1, MVT VT2, MVT VT3, MVT VT4);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDVTList getVTList(const MVT *VTs, unsigned NumVTs);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2006-08-30 05:56:52 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-08-15 17:46:01 +00:00
|
|
|
// Node creation methods.
|
|
|
|
//
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getConstant(uint64_t Val, MVT VT, bool isTarget = false);
|
|
|
|
SDValue getConstant(const APInt &Val, MVT VT, bool isTarget = false);
|
2008-09-12 18:08:03 +00:00
|
|
|
SDValue getConstant(const ConstantInt &Val, MVT VT, bool isTarget = false);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false);
|
|
|
|
SDValue getTargetConstant(uint64_t Val, MVT VT) {
|
2006-08-11 21:00:46 +00:00
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getTargetConstant(const APInt &Val, MVT VT) {
|
2008-02-08 22:59:30 +00:00
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2008-09-12 18:08:03 +00:00
|
|
|
SDValue getTargetConstant(const ConstantInt &Val, MVT VT) {
|
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getConstantFP(double Val, MVT VT, bool isTarget = false);
|
|
|
|
SDValue getConstantFP(const APFloat& Val, MVT VT, bool isTarget = false);
|
2008-09-12 18:08:03 +00:00
|
|
|
SDValue getConstantFP(const ConstantFP &CF, MVT VT, bool isTarget = false);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getTargetConstantFP(double Val, MVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getTargetConstantFP(const APFloat& Val, MVT VT) {
|
2007-08-30 00:23:21 +00:00
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2008-09-12 18:08:03 +00:00
|
|
|
SDValue getTargetConstantFP(const ConstantFP &Val, MVT VT) {
|
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getGlobalAddress(const GlobalValue *GV, MVT VT,
|
Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this
is legal (i.e. not in PIC mode, etc.)
This allows instruction selection to emit folded constant offsets
in more cases, such as the included testcase, eliminating the need
for explicit arithmetic instructions.
This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp
that attempted to achieve the same effect, but wasn't as effective.
Also, fix handling of offsets in GlobalAddressSDNodes in several
places, including changing GlobalAddressSDNode's offset from
int to int64_t.
The Mips, Alpha, Sparc, and CellSPU targets appear to be
unaware of GlobalAddress offsets currently, so set the hook to
false on those targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18 02:06:02 +00:00
|
|
|
int64_t offset = 0, bool isTargetGA = false);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getTargetGlobalAddress(const GlobalValue *GV, MVT VT,
|
Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this
is legal (i.e. not in PIC mode, etc.)
This allows instruction selection to emit folded constant offsets
in more cases, such as the included testcase, eliminating the need
for explicit arithmetic instructions.
This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp
that attempted to achieve the same effect, but wasn't as effective.
Also, fix handling of offsets in GlobalAddressSDNodes in several
places, including changing GlobalAddressSDNode's offset from
int to int64_t.
The Mips, Alpha, Sparc, and CellSPU targets appear to be
unaware of GlobalAddress offsets currently, so set the hook to
false on those targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18 02:06:02 +00:00
|
|
|
int64_t offset = 0) {
|
2006-08-11 21:00:46 +00:00
|
|
|
return getGlobalAddress(GV, VT, offset, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getFrameIndex(int FI, MVT VT, bool isTarget = false);
|
|
|
|
SDValue getTargetFrameIndex(int FI, MVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getFrameIndex(FI, VT, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getJumpTable(int JTI, MVT VT, bool isTarget = false);
|
|
|
|
SDValue getTargetJumpTable(int JTI, MVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getJumpTable(JTI, VT, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getConstantPool(Constant *C, MVT VT,
|
2006-08-11 21:55:30 +00:00
|
|
|
unsigned Align = 0, int Offs = 0, bool isT=false);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getTargetConstantPool(Constant *C, MVT VT,
|
2006-08-11 21:55:30 +00:00
|
|
|
unsigned Align = 0, int Offset = 0) {
|
|
|
|
return getConstantPool(C, VT, Align, Offset, true);
|
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getConstantPool(MachineConstantPoolValue *C, MVT VT,
|
2006-09-12 21:00:35 +00:00
|
|
|
unsigned Align = 0, int Offs = 0, bool isT=false);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getTargetConstantPool(MachineConstantPoolValue *C,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT VT, unsigned Align = 0,
|
2006-09-12 21:00:35 +00:00
|
|
|
int Offset = 0) {
|
|
|
|
return getConstantPool(C, VT, Align, Offset, true);
|
|
|
|
}
|
2009-02-04 01:17:06 +00:00
|
|
|
// When generating a branch to a BB, we don't in general know enough
|
|
|
|
// to provide debug info for the BB at that time, so keep this one around.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getBasicBlock(MachineBasicBlock *MBB);
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getBasicBlock(MachineBasicBlock *MBB, DebugLoc dl);
|
2008-09-16 21:48:12 +00:00
|
|
|
SDValue getExternalSymbol(const char *Sym, MVT VT);
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getExternalSymbol(const char *Sym, DebugLoc dl, MVT VT);
|
2008-09-16 21:48:12 +00:00
|
|
|
SDValue getTargetExternalSymbol(const char *Sym, MVT VT);
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getTargetExternalSymbol(const char *Sym, DebugLoc dl, MVT VT);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getArgFlags(ISD::ArgFlagsTy Flags);
|
|
|
|
SDValue getValueType(MVT);
|
|
|
|
SDValue getRegister(unsigned Reg, MVT VT);
|
2009-05-04 22:10:05 +00:00
|
|
|
SDValue getDbgStopPoint(DebugLoc DL, SDValue Root,
|
|
|
|
unsigned Line, unsigned Col, Value *CU);
|
2009-02-17 22:15:04 +00:00
|
|
|
SDValue getLabel(unsigned Opcode, DebugLoc dl, SDValue Root,
|
2009-01-29 00:47:48 +00:00
|
|
|
unsigned LabelID);
|
2005-01-07 07:46:32 +00:00
|
|
|
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getCopyToReg(SDValue Chain, DebugLoc dl, unsigned Reg, SDValue N) {
|
|
|
|
return getNode(ISD::CopyToReg, dl, MVT::Other, Chain,
|
|
|
|
getRegister(Reg, N.getValueType()), N);
|
|
|
|
}
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2005-08-30 01:56:13 +00:00
|
|
|
// This version of the getCopyToReg method takes an extra operand, which
|
|
|
|
// indicates that there is potentially an incoming flag value (if Flag is not
|
|
|
|
// null) and that there should be a flag result.
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getCopyToReg(SDValue Chain, DebugLoc dl, unsigned Reg, SDValue N,
|
2009-05-13 21:39:20 +00:00
|
|
|
SDValue Flag) {
|
2009-04-09 23:54:40 +00:00
|
|
|
SDVTList VTs = getVTList(MVT::Other, MVT::Flag);
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag };
|
2009-04-09 23:54:40 +00:00
|
|
|
return getNode(ISD::CopyToReg, dl, VTs, Ops, Flag.getNode() ? 4 : 3);
|
2009-02-03 22:26:09 +00:00
|
|
|
}
|
Teach tblgen to accept register source operands in patterns, e.g.
def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
"shl{b} {%cl, $dst|$dst, %CL}",
[(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
This generates a CopyToReg operand and added its 2nd result to the shl as
a flag operand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24557 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-01 00:18:45 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
// Similar to last getCopyToReg() except parameter Reg is a SDValue
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getCopyToReg(SDValue Chain, DebugLoc dl, SDValue Reg, SDValue N,
|
|
|
|
SDValue Flag) {
|
2009-04-09 23:54:40 +00:00
|
|
|
SDVTList VTs = getVTList(MVT::Other, MVT::Flag);
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue Ops[] = { Chain, Reg, N, Flag };
|
2009-04-09 23:54:40 +00:00
|
|
|
return getNode(ISD::CopyToReg, dl, VTs, Ops, Flag.getNode() ? 4 : 3);
|
2009-02-03 22:26:09 +00:00
|
|
|
}
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getCopyFromReg(SDValue Chain, DebugLoc dl, unsigned Reg, MVT VT) {
|
2009-04-09 23:54:40 +00:00
|
|
|
SDVTList VTs = getVTList(VT, MVT::Other);
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue Ops[] = { Chain, getRegister(Reg, VT) };
|
2009-04-09 23:54:40 +00:00
|
|
|
return getNode(ISD::CopyFromReg, dl, VTs, Ops, 2);
|
2009-02-03 22:26:09 +00:00
|
|
|
}
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2005-08-30 01:56:13 +00:00
|
|
|
// This version of the getCopyFromReg method takes an extra operand, which
|
|
|
|
// indicates that there is potentially an incoming flag value (if Flag is not
|
|
|
|
// null) and that there should be a flag result.
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getCopyFromReg(SDValue Chain, DebugLoc dl, unsigned Reg, MVT VT,
|
|
|
|
SDValue Flag) {
|
2009-04-09 23:54:40 +00:00
|
|
|
SDVTList VTs = getVTList(VT, MVT::Other, MVT::Flag);
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue Ops[] = { Chain, getRegister(Reg, VT), Flag };
|
2009-04-09 23:54:40 +00:00
|
|
|
return getNode(ISD::CopyFromReg, dl, VTs, Ops, Flag.getNode() ? 3 : 2);
|
2009-02-03 22:26:09 +00:00
|
|
|
}
|
2005-01-13 20:50:02 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getCondCode(ISD::CondCode Cond);
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2008-11-10 20:54:11 +00:00
|
|
|
/// Returns the ConvertRndSat Note: Avoid using this node because it may
|
|
|
|
/// disappear in the future and most targets don't support it.
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getConvertRndSat(MVT VT, DebugLoc dl, SDValue Val, SDValue DTy,
|
|
|
|
SDValue STy,
|
|
|
|
SDValue Rnd, SDValue Sat, ISD::CvtCode Code);
|
2009-04-27 18:41:29 +00:00
|
|
|
|
|
|
|
/// getVectorShuffle - Return an ISD::VECTOR_SHUFFLE node. The number of
|
|
|
|
/// elements in VT, which must be a vector type, must match the number of
|
2009-04-29 05:20:52 +00:00
|
|
|
/// mask elements NumElts. A integer mask element equal to -1 is treated as
|
2009-04-27 18:41:29 +00:00
|
|
|
/// undefined.
|
|
|
|
SDValue getVectorShuffle(MVT VT, DebugLoc dl, SDValue N1, SDValue N2,
|
|
|
|
const int *MaskElts);
|
2008-11-10 20:54:11 +00:00
|
|
|
|
2005-04-13 02:37:19 +00:00
|
|
|
/// getZeroExtendInReg - Return the expression required to zero extend the Op
|
|
|
|
/// value assuming it was the smaller SrcTy value.
|
2009-01-30 22:23:15 +00:00
|
|
|
SDValue getZeroExtendInReg(SDValue Op, DebugLoc DL, MVT SrcTy);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2009-01-22 17:39:32 +00:00
|
|
|
/// getNOT - Create a bitwise NOT operation as (XOR Val, -1).
|
2009-01-30 22:11:22 +00:00
|
|
|
SDValue getNOT(DebugLoc DL, SDValue Val, MVT VT);
|
2009-01-22 17:39:32 +00:00
|
|
|
|
2006-02-13 08:54:46 +00:00
|
|
|
/// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have
|
2009-02-06 23:05:02 +00:00
|
|
|
/// a flag result (to ensure it's not CSE'd). CALLSEQ_START does not have a
|
|
|
|
/// useful DebugLoc.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getCALLSEQ_START(SDValue Chain, SDValue Op) {
|
2009-04-09 23:54:40 +00:00
|
|
|
SDVTList VTs = getVTList(MVT::Other, MVT::Flag);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ops[] = { Chain, Op };
|
2009-02-17 22:15:04 +00:00
|
|
|
return getNode(ISD::CALLSEQ_START, DebugLoc::getUnknownLoc(),
|
2009-04-09 23:54:40 +00:00
|
|
|
VTs, Ops, 2);
|
2006-02-13 08:54:46 +00:00
|
|
|
}
|
2005-04-13 02:37:19 +00:00
|
|
|
|
2007-11-13 00:44:25 +00:00
|
|
|
/// getCALLSEQ_END - Return a new CALLSEQ_END node, which always must have a
|
2009-02-06 23:05:02 +00:00
|
|
|
/// flag result (to ensure it's not CSE'd). CALLSEQ_END does not have
|
|
|
|
/// a useful DebugLoc.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2,
|
|
|
|
SDValue InFlag) {
|
2007-11-13 00:44:25 +00:00
|
|
|
SDVTList NodeTys = getVTList(MVT::Other, MVT::Flag);
|
2008-07-27 21:46:04 +00:00
|
|
|
SmallVector<SDValue, 4> Ops;
|
2007-11-13 00:44:25 +00:00
|
|
|
Ops.push_back(Chain);
|
|
|
|
Ops.push_back(Op1);
|
|
|
|
Ops.push_back(Op2);
|
|
|
|
Ops.push_back(InFlag);
|
2009-02-06 23:05:02 +00:00
|
|
|
return getNode(ISD::CALLSEQ_END, DebugLoc::getUnknownLoc(), NodeTys,
|
2009-02-17 22:15:04 +00:00
|
|
|
&Ops[0],
|
2008-08-28 21:40:38 +00:00
|
|
|
(unsigned)Ops.size() - (InFlag.getNode() == 0 ? 1 : 0));
|
2007-11-13 00:44:25 +00:00
|
|
|
}
|
|
|
|
|
2009-02-06 23:05:02 +00:00
|
|
|
/// getUNDEF - Return an UNDEF node. UNDEF does not have a useful DebugLoc.
|
|
|
|
SDValue getUNDEF(MVT VT) {
|
|
|
|
return getNode(ISD::UNDEF, DebugLoc::getUnknownLoc(), VT);
|
|
|
|
}
|
|
|
|
|
2009-02-07 00:55:49 +00:00
|
|
|
/// getGLOBAL_OFFSET_TABLE - Return a GLOBAL_OFFSET_TABLE node. This does
|
|
|
|
/// not have a useful DebugLoc.
|
|
|
|
SDValue getGLOBAL_OFFSET_TABLE(MVT VT) {
|
|
|
|
return getNode(ISD::GLOBAL_OFFSET_TABLE, DebugLoc::getUnknownLoc(), VT);
|
|
|
|
}
|
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// getNode - Gets or creates the specified node.
|
2003-08-11 14:56:26 +00:00
|
|
|
///
|
2009-01-28 22:17:52 +00:00
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, SDValue N);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, SDValue N1, SDValue N2);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT,
|
|
|
|
SDValue N1, SDValue N2, SDValue N3);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT,
|
|
|
|
SDValue N1, SDValue N2, SDValue N3, SDValue N4);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT,
|
|
|
|
SDValue N1, SDValue N2, SDValue N3, SDValue N4,
|
|
|
|
SDValue N5);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT,
|
|
|
|
const SDUse *Ops, unsigned NumOps);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT,
|
|
|
|
const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL,
|
|
|
|
const std::vector<MVT> &ResultTys,
|
|
|
|
const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, const MVT *VTs, unsigned NumVTs,
|
|
|
|
const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
|
|
|
|
const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, SDValue N);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
|
|
|
|
SDValue N1, SDValue N2);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
|
|
|
|
SDValue N1, SDValue N2, SDValue N3);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
|
|
|
|
SDValue N1, SDValue N2, SDValue N3, SDValue N4);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
|
|
|
|
SDValue N1, SDValue N2, SDValue N3, SDValue N4,
|
|
|
|
SDValue N5);
|
2008-07-27 21:46:04 +00:00
|
|
|
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src,
|
2008-11-18 22:27:13 +00:00
|
|
|
SDValue Size, unsigned Align, bool AlwaysInline,
|
|
|
|
const Value *DstSV, uint64_t DstSVOff,
|
|
|
|
const Value *SrcSV, uint64_t SrcSVOff);
|
2007-10-19 10:41:11 +00:00
|
|
|
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src,
|
2008-11-18 22:27:13 +00:00
|
|
|
SDValue Size, unsigned Align,
|
|
|
|
const Value *DstSV, uint64_t DstOSVff,
|
|
|
|
const Value *SrcSV, uint64_t SrcSVOff);
|
2007-10-19 10:41:11 +00:00
|
|
|
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src,
|
2008-11-18 22:27:13 +00:00
|
|
|
SDValue Size, unsigned Align,
|
|
|
|
const Value *DstSV, uint64_t DstSVOff);
|
2007-10-19 10:41:11 +00:00
|
|
|
|
2005-08-09 20:20:18 +00:00
|
|
|
/// getSetCC - Helper function to make it easier to build SetCC's if you just
|
2008-07-27 21:46:04 +00:00
|
|
|
/// have an ISD::CondCode instead of an SDValue.
|
2005-08-09 20:20:18 +00:00
|
|
|
///
|
2009-01-30 02:23:43 +00:00
|
|
|
SDValue getSetCC(DebugLoc DL, MVT VT, SDValue LHS, SDValue RHS,
|
|
|
|
ISD::CondCode Cond) {
|
|
|
|
return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond));
|
2008-05-12 19:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// getVSetCC - Helper function to make it easier to build VSetCC's nodes
|
2008-07-27 21:46:04 +00:00
|
|
|
/// if you just have an ISD::CondCode instead of an SDValue.
|
2008-05-12 19:40:03 +00:00
|
|
|
///
|
2009-01-30 02:23:43 +00:00
|
|
|
SDValue getVSetCC(DebugLoc DL, MVT VT, SDValue LHS, SDValue RHS,
|
|
|
|
ISD::CondCode Cond) {
|
|
|
|
return getNode(ISD::VSETCC, DL, VT, LHS, RHS, getCondCode(Cond));
|
2005-08-09 20:20:18 +00:00
|
|
|
}
|
2005-08-10 20:51:12 +00:00
|
|
|
|
|
|
|
/// getSelectCC - Helper function to make it easier to build SelectCC's if you
|
2008-07-27 21:46:04 +00:00
|
|
|
/// just have an ISD::CondCode instead of an SDValue.
|
2005-08-10 20:51:12 +00:00
|
|
|
///
|
2009-01-30 02:23:43 +00:00
|
|
|
SDValue getSelectCC(DebugLoc DL, SDValue LHS, SDValue RHS,
|
|
|
|
SDValue True, SDValue False, ISD::CondCode Cond) {
|
|
|
|
return getNode(ISD::SELECT_CC, DL, True.getValueType(),
|
|
|
|
LHS, RHS, True, False, getCondCode(Cond));
|
2005-08-10 20:51:12 +00:00
|
|
|
}
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2006-01-25 18:21:52 +00:00
|
|
|
/// getVAArg - VAArg produces a result and token chain, and takes a pointer
|
|
|
|
/// and a source value as input.
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getVAArg(MVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr,
|
|
|
|
SDValue SV);
|
2005-08-16 19:49:35 +00:00
|
|
|
|
2009-02-17 22:15:04 +00:00
|
|
|
/// getAtomic - Gets a node for an atomic op, produces result and chain and
|
2008-10-17 18:22:58 +00:00
|
|
|
/// takes 3 operands
|
2009-02-17 22:15:04 +00:00
|
|
|
SDValue getAtomic(unsigned Opcode, DebugLoc dl, MVT MemVT, SDValue Chain,
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue Ptr, SDValue Cmp, SDValue Swp, const Value* PtrVal,
|
|
|
|
unsigned Alignment=0);
|
2008-02-21 06:45:13 +00:00
|
|
|
|
2008-10-17 18:22:58 +00:00
|
|
|
/// getAtomic - Gets a node for an atomic op, produces result and chain and
|
|
|
|
/// takes 2 operands.
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getAtomic(unsigned Opcode, DebugLoc dl, MVT MemVT, SDValue Chain,
|
|
|
|
SDValue Ptr, SDValue Val, const Value* PtrVal,
|
|
|
|
unsigned Alignment = 0);
|
2008-02-21 06:45:13 +00:00
|
|
|
|
2008-10-17 18:22:58 +00:00
|
|
|
/// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a
|
|
|
|
/// result and takes a list of operands.
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl,
|
|
|
|
const MVT *VTs, unsigned NumVTs,
|
|
|
|
const SDValue *Ops, unsigned NumOps,
|
|
|
|
MVT MemVT, const Value *srcValue, int SVOff,
|
|
|
|
unsigned Align = 0, bool Vol = false,
|
|
|
|
bool ReadMem = true, bool WriteMem = true);
|
2008-10-17 18:22:58 +00:00
|
|
|
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl, SDVTList VTList,
|
|
|
|
const SDValue *Ops, unsigned NumOps,
|
|
|
|
MVT MemVT, const Value *srcValue, int SVOff,
|
|
|
|
unsigned Align = 0, bool Vol = false,
|
|
|
|
bool ReadMem = true, bool WriteMem = true);
|
2008-10-17 18:22:58 +00:00
|
|
|
|
2008-07-02 17:40:58 +00:00
|
|
|
/// getMergeValues - Create a MERGE_VALUES node from the given operands.
|
2009-02-02 20:47:48 +00:00
|
|
|
SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, DebugLoc dl);
|
2008-06-30 10:19:09 +00:00
|
|
|
|
2008-09-13 01:54:27 +00:00
|
|
|
/// getCall - Create a CALL node from the given information.
|
|
|
|
///
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getCall(unsigned CallingConv, DebugLoc dl, bool IsVarArgs,
|
|
|
|
bool IsTailCall, bool isInreg, SDVTList VTs,
|
|
|
|
const SDValue *Operands, unsigned NumOperands);
|
2008-09-13 01:54:27 +00:00
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// getLoad - Loads are not normal binary operators: their result type is not
|
|
|
|
/// determined by their operands, and they produce a value AND a token chain.
|
2003-08-11 14:56:26 +00:00
|
|
|
///
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getLoad(MVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr,
|
|
|
|
const Value *SV, int SVOffset, bool isVolatile=false,
|
|
|
|
unsigned Alignment=0);
|
|
|
|
SDValue getExtLoad(ISD::LoadExtType ExtType, DebugLoc dl, MVT VT,
|
|
|
|
SDValue Chain, SDValue Ptr, const Value *SV,
|
|
|
|
int SVOffset, MVT EVT, bool isVolatile=false,
|
|
|
|
unsigned Alignment=0);
|
|
|
|
SDValue getIndexedLoad(SDValue OrigLoad, DebugLoc dl, SDValue Base,
|
|
|
|
SDValue Offset, ISD::MemIndexedMode AM);
|
|
|
|
SDValue getLoad(ISD::MemIndexedMode AM, DebugLoc dl, ISD::LoadExtType ExtType,
|
|
|
|
MVT VT, SDValue Chain,
|
|
|
|
SDValue Ptr, SDValue Offset,
|
|
|
|
const Value *SV, int SVOffset, MVT EVT,
|
|
|
|
bool isVolatile=false, unsigned Alignment=0);
|
2005-04-27 20:10:01 +00:00
|
|
|
|
2006-10-05 22:57:11 +00:00
|
|
|
/// getStore - Helper function to build ISD::STORE nodes.
|
|
|
|
///
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
|
|
|
|
const Value *SV, int SVOffset, bool isVolatile=false,
|
|
|
|
unsigned Alignment=0);
|
|
|
|
SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
|
|
|
|
const Value *SV, int SVOffset, MVT TVT,
|
|
|
|
bool isVolatile=false, unsigned Alignment=0);
|
|
|
|
SDValue getIndexedStore(SDValue OrigStoe, DebugLoc dl, SDValue Base,
|
|
|
|
SDValue Offset, ISD::MemIndexedMode AM);
|
2006-10-05 22:57:11 +00:00
|
|
|
|
2009-01-27 17:28:23 +00:00
|
|
|
/// getSrcValue - Construct a node to track a Value* through the backend.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getSrcValue(const Value *v);
|
2008-02-06 22:27:42 +00:00
|
|
|
|
2009-01-27 17:28:23 +00:00
|
|
|
/// getMemOperand - Construct a node to track a memory reference
|
|
|
|
/// through the backend.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getMemOperand(const MachineMemOperand &MO);
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2009-01-31 15:50:11 +00:00
|
|
|
/// getShiftAmountOperand - Return the specified value casted to
|
|
|
|
/// the target's desired shift amount type.
|
|
|
|
SDValue getShiftAmountOperand(SDValue Op);
|
|
|
|
|
2006-01-28 09:32:01 +00:00
|
|
|
/// UpdateNodeOperands - *Mutate* the specified node in-place to have the
|
|
|
|
/// specified operands. If the resultant node already exists in the DAG,
|
|
|
|
/// this does not modify the specified node, instead it returns the node that
|
|
|
|
/// already exists. If the resultant node does not exist in the DAG, the
|
|
|
|
/// input node is returned. As a degenerate case, if you specify the same
|
|
|
|
/// input operands as the node already has, the input node is returned.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue UpdateNodeOperands(SDValue N, SDValue Op);
|
|
|
|
SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2);
|
|
|
|
SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2,
|
|
|
|
SDValue Op3);
|
|
|
|
SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2,
|
|
|
|
SDValue Op3, SDValue Op4);
|
|
|
|
SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2,
|
|
|
|
SDValue Op3, SDValue Op4, SDValue Op5);
|
|
|
|
SDValue UpdateNodeOperands(SDValue N,
|
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2005-08-16 18:16:24 +00:00
|
|
|
/// SelectNodeTo - These are used for target selectors to *mutate* the
|
|
|
|
/// specified node to have the specified return type, Target opcode, and
|
|
|
|
/// operands. Note that target opcodes are stored as
|
2008-07-17 19:10:17 +00:00
|
|
|
/// ~TargetOpcode in the node opcode field. The resultant node is returned.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, SDValue Op1);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op1, SDValue Op2);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op1, SDValue Op2, SDValue Op3);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2008-07-02 23:23:19 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, MVT VT2);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, const SDValue *Ops, unsigned NumOps);
|
2008-07-02 23:23:19 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, MVT VT3, const SDValue *Ops, unsigned NumOps);
|
2008-12-01 23:28:22 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, MVT VT1,
|
|
|
|
MVT VT2, MVT VT3, MVT VT4, const SDValue *Ops,
|
|
|
|
unsigned NumOps);
|
2008-07-02 23:23:19 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, SDValue Op1);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, SDValue Op1, SDValue Op2);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
|
2008-12-01 23:28:22 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
|
|
|
MVT VT2, MVT VT3, SDValue Op1, SDValue Op2, SDValue Op3);
|
2008-07-02 23:23:19 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs,
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2006-08-27 08:08:54 +00:00
|
|
|
|
2008-07-17 19:10:17 +00:00
|
|
|
/// MorphNodeTo - These *mutate* the specified node to have the specified
|
|
|
|
/// return type, opcode, and operands.
|
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, SDValue Op1);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op1, SDValue Op2);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op1, SDValue Op2, SDValue Op3);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, MVT VT2);
|
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, const SDValue *Ops, unsigned NumOps);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, MVT VT3, const SDValue *Ops, unsigned NumOps);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, SDValue Op1);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, SDValue Op1, SDValue Op2);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
|
2008-07-27 21:46:04 +00:00
|
|
|
MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
|
2008-07-17 19:10:17 +00:00
|
|
|
SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2005-10-25 21:02:21 +00:00
|
|
|
|
2006-02-09 07:15:23 +00:00
|
|
|
/// getTargetNode - These are used for target selectors to create a new node
|
|
|
|
/// with specified return type(s), target opcode, and operands.
|
|
|
|
///
|
|
|
|
/// Note that getTargetNode returns the resultant node. If there is already a
|
|
|
|
/// node of the specified opcode and operands, it returns that node instead of
|
|
|
|
/// the current one.
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT, SDValue Op1);
|
2009-02-17 22:15:04 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT, SDValue Op1,
|
2009-01-29 09:01:55 +00:00
|
|
|
SDValue Op2);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT,
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue Op1, SDValue Op2, SDValue Op3);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT,
|
2009-01-29 00:47:48 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2);
|
2009-02-17 22:15:04 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2,
|
2009-01-29 09:01:55 +00:00
|
|
|
SDValue Op1);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1,
|
2009-01-29 00:47:48 +00:00
|
|
|
MVT VT2, SDValue Op1, SDValue Op2);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1,
|
2009-01-29 00:47:48 +00:00
|
|
|
MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2,
|
2009-01-29 00:47:48 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3,
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue Op1, SDValue Op2);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3,
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue Op1, SDValue Op2, SDValue Op3);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3,
|
2009-01-29 00:47:48 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-01-29 09:01:55 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3,
|
|
|
|
MVT VT4, const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, DebugLoc dl,
|
|
|
|
const std::vector<MVT> &ResultTys, const SDValue *Ops,
|
|
|
|
unsigned NumOps);
|
2008-03-22 01:55:50 +00:00
|
|
|
|
|
|
|
/// getNodeIfExists - Get the specified node if it's already available, or
|
|
|
|
/// else return NULL.
|
|
|
|
SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs,
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2008-02-03 06:49:24 +00:00
|
|
|
/// DAGUpdateListener - Clients of various APIs that cause global effects on
|
|
|
|
/// the DAG can optionally implement this interface. This allows the clients
|
|
|
|
/// to handle the various sorts of updates that happen.
|
|
|
|
class DAGUpdateListener {
|
|
|
|
public:
|
|
|
|
virtual ~DAGUpdateListener();
|
2008-06-11 11:42:12 +00:00
|
|
|
|
|
|
|
/// NodeDeleted - The node N that was deleted and, if E is not null, an
|
|
|
|
/// equivalent node E that replaced it.
|
|
|
|
virtual void NodeDeleted(SDNode *N, SDNode *E) = 0;
|
|
|
|
|
|
|
|
/// NodeUpdated - The node N that was updated.
|
2008-02-03 06:49:24 +00:00
|
|
|
virtual void NodeUpdated(SDNode *N) = 0;
|
|
|
|
};
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2008-02-03 06:49:24 +00:00
|
|
|
/// RemoveDeadNode - Remove the specified node from the system. If any of its
|
|
|
|
/// operands then becomes dead, remove them as well. Inform UpdateListener
|
|
|
|
/// for each node deleted.
|
|
|
|
void RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener = 0);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2008-07-07 20:57:48 +00:00
|
|
|
/// RemoveDeadNodes - This method deletes the unreachable nodes in the
|
|
|
|
/// given list, and any nodes that become unreachable as a result.
|
|
|
|
void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes,
|
|
|
|
DAGUpdateListener *UpdateListener = 0);
|
|
|
|
|
2005-08-17 18:59:17 +00:00
|
|
|
/// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead.
|
2005-08-26 18:35:58 +00:00
|
|
|
/// This can cause recursive merging of nodes in the DAG. Use the first
|
|
|
|
/// version if 'From' is known to have a single result, use the second
|
2009-04-15 20:06:30 +00:00
|
|
|
/// if you have two nodes with identical results (or if 'To' has a superset
|
|
|
|
/// of the results of 'From'), use the third otherwise.
|
2005-08-17 18:59:17 +00:00
|
|
|
///
|
2009-02-17 22:15:04 +00:00
|
|
|
/// These methods all take an optional UpdateListener, which (if not null) is
|
2008-02-03 06:49:24 +00:00
|
|
|
/// informed about nodes that are deleted and modified due to recursive
|
|
|
|
/// changes in the dag.
|
2005-09-07 05:36:18 +00:00
|
|
|
///
|
2009-01-21 20:50:09 +00:00
|
|
|
/// These functions only replace all existing uses. It's possible that as
|
|
|
|
/// these replacements are being performed, CSE may cause the From node
|
|
|
|
/// to be given new uses. These new uses of From are left in place, and
|
|
|
|
/// not automatically transfered to To.
|
|
|
|
///
|
2008-07-27 21:46:04 +00:00
|
|
|
void ReplaceAllUsesWith(SDValue From, SDValue Op,
|
2008-02-03 06:49:24 +00:00
|
|
|
DAGUpdateListener *UpdateListener = 0);
|
2005-09-07 05:36:18 +00:00
|
|
|
void ReplaceAllUsesWith(SDNode *From, SDNode *To,
|
2008-02-03 06:49:24 +00:00
|
|
|
DAGUpdateListener *UpdateListener = 0);
|
2008-07-27 21:46:04 +00:00
|
|
|
void ReplaceAllUsesWith(SDNode *From, const SDValue *To,
|
2008-02-03 06:49:24 +00:00
|
|
|
DAGUpdateListener *UpdateListener = 0);
|
2006-02-09 22:11:03 +00:00
|
|
|
|
2006-02-17 21:57:00 +00:00
|
|
|
/// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving
|
2008-02-03 06:49:24 +00:00
|
|
|
/// uses of other values produced by From.Val alone.
|
2008-07-27 21:46:04 +00:00
|
|
|
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To,
|
2008-02-03 06:49:24 +00:00
|
|
|
DAGUpdateListener *UpdateListener = 0);
|
2006-02-17 21:57:00 +00:00
|
|
|
|
2008-07-17 19:10:17 +00:00
|
|
|
/// ReplaceAllUsesOfValuesWith - Like ReplaceAllUsesOfValueWith, but
|
|
|
|
/// for multiple values at once. This correctly handles the case where
|
|
|
|
/// there is an overlap between the From values and the To values.
|
2008-07-27 21:46:04 +00:00
|
|
|
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To,
|
2008-07-17 19:10:17 +00:00
|
|
|
unsigned Num,
|
|
|
|
DAGUpdateListener *UpdateListener = 0);
|
|
|
|
|
2008-09-30 18:30:35 +00:00
|
|
|
/// AssignTopologicalOrder - Topological-sort the AllNodes list and a
|
|
|
|
/// assign a unique node id for each node in the DAG based on their
|
|
|
|
/// topological order. Returns the number of nodes.
|
|
|
|
unsigned AssignTopologicalOrder();
|
2006-08-01 08:20:41 +00:00
|
|
|
|
Eliminate the ISel priority queue, which used the topological order for a
priority function. Instead, just iterate over the AllNodes list, which is
already in topological order. This eliminates a fair amount of bookkeeping,
and speeds up the isel phase by about 15% on many testcases.
The impact on most targets is that AddToISelQueue calls can be simply removed.
In the x86 target, there are two additional notable changes.
The rule-bending AND+SHIFT optimization in MatchAddress that creates new
pre-isel nodes during isel is now a little more verbose, but more robust.
Instead of either creating an invalid DAG or creating an invalid topological
sort, as it has historically done, it can now just insert the new nodes into
the node list at a position where they will be consistent with the topological
ordering.
Also, the address-matching code has logic that checked to see if a node was
"already selected". However, when a node is selected, it has all its uses
taken away via ReplaceAllUsesWith or equivalent, so it won't recieve any
further visits from MatchAddress. This code is now removed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-05 04:14:16 +00:00
|
|
|
/// RepositionNode - Move node N in the AllNodes list to be immediately
|
|
|
|
/// before the given iterator Position. This may be used to update the
|
|
|
|
/// topological ordering when the list of nodes is modified.
|
|
|
|
void RepositionNode(allnodes_iterator Position, SDNode *N) {
|
|
|
|
AllNodes.insert(Position, AllNodes.remove(N));
|
|
|
|
}
|
|
|
|
|
2006-08-29 06:42:35 +00:00
|
|
|
/// isCommutativeBinOp - Returns true if the opcode is a commutative binary
|
|
|
|
/// operation.
|
|
|
|
static bool isCommutativeBinOp(unsigned Opcode) {
|
2008-01-25 06:20:20 +00:00
|
|
|
// FIXME: This should get its info from the td file, so that we can include
|
|
|
|
// target info.
|
2006-08-29 06:42:35 +00:00
|
|
|
switch (Opcode) {
|
|
|
|
case ISD::ADD:
|
|
|
|
case ISD::MUL:
|
|
|
|
case ISD::MULHU:
|
|
|
|
case ISD::MULHS:
|
2007-10-05 14:09:33 +00:00
|
|
|
case ISD::SMUL_LOHI:
|
|
|
|
case ISD::UMUL_LOHI:
|
2006-08-29 06:42:35 +00:00
|
|
|
case ISD::FADD:
|
|
|
|
case ISD::FMUL:
|
|
|
|
case ISD::AND:
|
|
|
|
case ISD::OR:
|
|
|
|
case ISD::XOR:
|
2009-03-19 18:53:45 +00:00
|
|
|
case ISD::SADDO:
|
|
|
|
case ISD::UADDO:
|
2009-02-17 22:15:04 +00:00
|
|
|
case ISD::ADDC:
|
2006-08-29 06:42:35 +00:00
|
|
|
case ISD::ADDE: return true;
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-11 14:56:26 +00:00
|
|
|
void dump() const;
|
2005-01-07 21:08:55 +00:00
|
|
|
|
2007-10-15 17:47:20 +00:00
|
|
|
/// CreateStackTemporary - Create a stack temporary, suitable for holding the
|
2008-07-05 20:40:31 +00:00
|
|
|
/// specified value type. If minAlign is specified, the slot size will have
|
|
|
|
/// at least that alignment.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue CreateStackTemporary(MVT VT, unsigned minAlign = 1);
|
2008-12-09 21:33:20 +00:00
|
|
|
|
|
|
|
/// CreateStackTemporary - Create a stack temporary suitable for holding
|
|
|
|
/// either of the specified value types.
|
|
|
|
SDValue CreateStackTemporary(MVT VT1, MVT VT2);
|
|
|
|
|
2009-02-17 22:15:04 +00:00
|
|
|
/// FoldConstantArithmetic -
|
2008-09-24 10:25:02 +00:00
|
|
|
SDValue FoldConstantArithmetic(unsigned Opcode,
|
|
|
|
MVT VT,
|
|
|
|
ConstantSDNode *Cst1,
|
|
|
|
ConstantSDNode *Cst2);
|
|
|
|
|
2006-10-14 00:41:01 +00:00
|
|
|
/// FoldSetCC - Constant fold a setcc to true or false.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue FoldSetCC(MVT VT, SDValue N1,
|
2009-02-03 00:47:48 +00:00
|
|
|
SDValue N2, ISD::CondCode Cond, DebugLoc dl);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2008-02-25 21:11:39 +00:00
|
|
|
/// SignBitIsZero - Return true if the sign bit of Op is known to be zero. We
|
|
|
|
/// use this predicate to simplify operations downstream.
|
2008-07-27 21:46:04 +00:00
|
|
|
bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const;
|
2008-02-25 21:11:39 +00:00
|
|
|
|
2007-06-22 14:59:07 +00:00
|
|
|
/// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero. We
|
|
|
|
/// use this predicate to simplify operations downstream. Op and Mask are
|
|
|
|
/// known to be the same type.
|
2008-07-27 21:46:04 +00:00
|
|
|
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth = 0)
|
2007-06-22 14:59:07 +00:00
|
|
|
const;
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2007-06-22 14:59:07 +00:00
|
|
|
/// ComputeMaskedBits - Determine which of the bits specified in Mask are
|
|
|
|
/// known to be either zero or one and return them in the KnownZero/KnownOne
|
|
|
|
/// bitsets. This code only analyzes bits in Mask, in order to short-circuit
|
2009-02-17 22:15:04 +00:00
|
|
|
/// processing. Targets can implement the computeMaskedBitsForTargetNode
|
2007-06-22 14:59:07 +00:00
|
|
|
/// method in the TargetLowering class to allow target nodes to be understood.
|
2008-07-27 21:46:04 +00:00
|
|
|
void ComputeMaskedBits(SDValue Op, const APInt &Mask, APInt &KnownZero,
|
2008-02-13 00:35:47 +00:00
|
|
|
APInt &KnownOne, unsigned Depth = 0) const;
|
|
|
|
|
2007-06-22 14:59:07 +00:00
|
|
|
/// ComputeNumSignBits - Return the number of times the sign bit of the
|
|
|
|
/// register is replicated into the other bits. We know that at least 1 bit
|
|
|
|
/// is always equal to the sign bit (itself), but other cases can give us
|
|
|
|
/// information. For example, immediately after an "SRA X, 2", we know that
|
|
|
|
/// the top 3 bits are all equal to each other, so we return 3. Targets can
|
|
|
|
/// implement the ComputeNumSignBitsForTarget method in the TargetLowering
|
|
|
|
/// class to allow target nodes to be understood.
|
2008-07-27 21:46:04 +00:00
|
|
|
unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const;
|
2008-02-02 04:07:54 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
/// isVerifiedDebugInfoDesc - Returns true if the specified SDValue has
|
2008-02-02 04:07:54 +00:00
|
|
|
/// been verified as a debug information descriptor.
|
2008-07-27 21:46:04 +00:00
|
|
|
bool isVerifiedDebugInfoDesc(SDValue Op) const;
|
2008-05-13 08:35:03 +00:00
|
|
|
|
|
|
|
/// getShuffleScalarElt - Returns the scalar element that will make up the ith
|
|
|
|
/// element of the result of the vector shuffle.
|
2009-04-29 05:20:52 +00:00
|
|
|
SDValue getShuffleScalarElt(const ShuffleVectorSDNode *N, unsigned Idx);
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2005-01-07 21:08:55 +00:00
|
|
|
private:
|
2008-09-13 01:54:27 +00:00
|
|
|
bool RemoveNodeFromCSEMaps(SDNode *N);
|
2009-01-25 16:29:12 +00:00
|
|
|
void AddModifiedNodeToCSEMaps(SDNode *N, DAGUpdateListener *UpdateListener);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos);
|
|
|
|
SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
|
2006-08-07 23:03:03 +00:00
|
|
|
void *&InsertPos);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDNode *FindModifiedNodeSlot(SDNode *N, const SDValue *Ops, unsigned NumOps,
|
2006-08-07 23:03:03 +00:00
|
|
|
void *&InsertPos);
|
2006-01-28 09:32:01 +00:00
|
|
|
|
2005-09-07 05:36:18 +00:00
|
|
|
void DeleteNodeNotInCSEMaps(SDNode *N);
|
2009-01-19 22:39:36 +00:00
|
|
|
void DeallocateNode(SDNode *N);
|
2008-07-08 23:46:32 +00:00
|
|
|
|
|
|
|
unsigned getMVTAlignment(MVT MemoryVT) const;
|
2008-08-23 02:25:05 +00:00
|
|
|
|
|
|
|
void allnodes_clear();
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2009-01-27 17:28:23 +00:00
|
|
|
/// VTList - List of non-single value types.
|
2008-07-17 19:10:17 +00:00
|
|
|
std::vector<SDVTList> VTList;
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2009-01-27 17:28:23 +00:00
|
|
|
/// CondCodeNodes - Maps to auto-CSE operations.
|
2005-08-09 20:20:18 +00:00
|
|
|
std::vector<CondCodeSDNode*> CondCodeNodes;
|
2005-01-14 22:07:46 +00:00
|
|
|
|
2005-07-10 00:07:11 +00:00
|
|
|
std::vector<SDNode*> ValueTypeNodes;
|
2008-06-08 20:54:56 +00:00
|
|
|
std::map<MVT, SDNode*, MVT::compareRawBits> ExtendedValueTypeNodes;
|
2008-09-16 21:48:12 +00:00
|
|
|
StringMap<SDNode*> ExternalSymbols;
|
|
|
|
StringMap<SDNode*> TargetExternalSymbols;
|
2003-08-11 14:56:26 +00:00
|
|
|
};
|
|
|
|
|
2005-01-10 23:05:53 +00:00
|
|
|
template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
|
|
|
|
typedef SelectionDAG::allnodes_iterator nodes_iterator;
|
|
|
|
static nodes_iterator nodes_begin(SelectionDAG *G) {
|
|
|
|
return G->allnodes_begin();
|
|
|
|
}
|
|
|
|
static nodes_iterator nodes_end(SelectionDAG *G) {
|
|
|
|
return G->allnodes_end();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-11-09 23:46:43 +00:00
|
|
|
} // end namespace llvm
|
2003-08-11 14:56:26 +00:00
|
|
|
|
|
|
|
#endif
|