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"
|
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-09-25 20:36:54 +00:00
|
|
|
#include "llvm/Support/RecyclingAllocator.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;
|
2009-12-18 23:32:53 +00:00
|
|
|
class MachineConstantPoolValue;
|
|
|
|
class MachineFunction;
|
2010-03-29 20:48:30 +00:00
|
|
|
class MDNode;
|
2009-12-18 23:32:53 +00:00
|
|
|
class SDNodeOrdering;
|
2010-03-10 22:13:47 +00:00
|
|
|
class SDDbgValue;
|
2009-12-18 23:32:53 +00:00
|
|
|
class TargetLowering;
|
2010-05-11 17:31:57 +00:00
|
|
|
class TargetSelectionDAGInfo;
|
2008-07-28 21:51:04 +00:00
|
|
|
|
2008-09-20 18:02:18 +00:00
|
|
|
template<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
|
|
|
|
private:
|
2009-08-26 19:16:32 +00:00
|
|
|
mutable ilist_half_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
|
|
|
|
2010-03-10 22:13:47 +00:00
|
|
|
/// SDDbgInfo - Keeps track of dbg_value information through SDISel. We do
|
|
|
|
/// not build SDNodes for these so as not to perturb the generated code;
|
2010-03-25 01:38:16 +00:00
|
|
|
/// instead the info is kept off to the side in this structure. Each SDNode may
|
|
|
|
/// have one or more associated dbg_value entries. This information is kept in
|
|
|
|
/// DbgValMap.
|
2010-04-26 20:06:49 +00:00
|
|
|
/// Byval parameters are handled separately because they don't use alloca's,
|
|
|
|
/// which busts the normal mechanism. There is good reason for handling all
|
|
|
|
/// parameters separately: they may not have code generated for them, they
|
|
|
|
/// should always go at the beginning of the function regardless of other code
|
|
|
|
/// motion, and debug info for them is potentially useful even if the parameter
|
|
|
|
/// is unused. Right now only byval parameters are handled separately.
|
2010-03-10 22:13:47 +00:00
|
|
|
class SDDbgInfo {
|
2010-03-25 01:38:16 +00:00
|
|
|
SmallVector<SDDbgValue*, 32> DbgValues;
|
2010-04-26 20:06:49 +00:00
|
|
|
SmallVector<SDDbgValue*, 32> ByvalParmDbgValues;
|
2010-03-25 06:26:14 +00:00
|
|
|
DenseMap<const SDNode*, SmallVector<SDDbgValue*, 2> > DbgValMap;
|
2010-03-10 22:13:47 +00:00
|
|
|
|
|
|
|
void operator=(const SDDbgInfo&); // Do not implement.
|
|
|
|
SDDbgInfo(const SDDbgInfo&); // Do not implement.
|
|
|
|
public:
|
|
|
|
SDDbgInfo() {}
|
|
|
|
|
2010-04-26 20:06:49 +00:00
|
|
|
void add(SDDbgValue *V, const SDNode *Node, bool isParameter) {
|
|
|
|
if (isParameter) {
|
|
|
|
ByvalParmDbgValues.push_back(V);
|
|
|
|
} else DbgValues.push_back(V);
|
2010-03-25 01:38:16 +00:00
|
|
|
if (Node)
|
2010-03-25 06:26:14 +00:00
|
|
|
DbgValMap[Node].push_back(V);
|
2010-03-10 22:13:47 +00:00
|
|
|
}
|
2010-03-25 01:38:16 +00:00
|
|
|
|
2010-03-10 22:13:47 +00:00
|
|
|
void clear() {
|
2010-03-25 06:26:14 +00:00
|
|
|
DbgValMap.clear();
|
2010-03-25 01:38:16 +00:00
|
|
|
DbgValues.clear();
|
2010-04-26 20:06:49 +00:00
|
|
|
ByvalParmDbgValues.clear();
|
2010-03-25 01:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool empty() const {
|
2010-04-26 20:06:49 +00:00
|
|
|
return DbgValues.empty() && ByvalParmDbgValues.empty();
|
2010-03-10 22:13:47 +00:00
|
|
|
}
|
2010-03-25 01:38:16 +00:00
|
|
|
|
|
|
|
SmallVector<SDDbgValue*,2> &getSDDbgValues(const SDNode *Node) {
|
2010-03-25 06:26:14 +00:00
|
|
|
return DbgValMap[Node];
|
2010-03-10 22:13:47 +00:00
|
|
|
}
|
2010-03-25 01:38:16 +00:00
|
|
|
|
|
|
|
typedef SmallVector<SDDbgValue*,32>::iterator DbgIterator;
|
|
|
|
DbgIterator DbgBegin() { return DbgValues.begin(); }
|
|
|
|
DbgIterator DbgEnd() { return DbgValues.end(); }
|
2010-04-26 20:06:49 +00:00
|
|
|
DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); }
|
|
|
|
DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); }
|
2010-03-10 22:13:47 +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.
|
|
|
|
};
|
|
|
|
|
2010-01-20 20:13:31 +00:00
|
|
|
class SelectionDAG;
|
|
|
|
void checkForCycles(const SDNode *N);
|
|
|
|
void checkForCycles(const SelectionDAG *DAG);
|
|
|
|
|
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 {
|
2010-04-19 19:22:07 +00:00
|
|
|
const TargetMachine &TM;
|
2010-04-17 15:26:15 +00:00
|
|
|
const TargetLowering &TLI;
|
2010-05-11 17:31:57 +00:00
|
|
|
const TargetSelectionDAGInfo &TSI;
|
2008-08-27 23:52:12 +00:00
|
|
|
MachineFunction *MF;
|
2010-04-05 06:19:28 +00:00
|
|
|
LLVMContext *Context;
|
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
|
2009-08-21 17:41:48 +00:00
|
|
|
/// CSE with existing nodes when 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;
|
|
|
|
|
2009-12-18 23:32:53 +00:00
|
|
|
/// SDNodeOrdering - The ordering of the SDNodes. It roughly corresponds to
|
|
|
|
/// the ordering of the original LLVM instructions.
|
|
|
|
SDNodeOrdering *Ordering;
|
2009-12-16 20:10:05 +00:00
|
|
|
|
2010-03-10 22:13:47 +00:00
|
|
|
/// DbgInfo - Tracks dbg_value information through SDISel.
|
|
|
|
SDDbgInfo *DbgInfo;
|
|
|
|
|
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);
|
|
|
|
|
2009-12-16 20:10:05 +00:00
|
|
|
void operator=(const SelectionDAG&); // Do not implement.
|
|
|
|
SelectionDAG(const SelectionDAG&); // Do not implement.
|
|
|
|
|
2003-08-11 14:56:26 +00:00
|
|
|
public:
|
2010-05-29 17:03:36 +00:00
|
|
|
explicit SelectionDAG(const TargetMachine &TM);
|
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.
|
|
|
|
///
|
2010-04-05 06:10:13 +00:00
|
|
|
void init(MachineFunction &mf);
|
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; }
|
2010-04-19 19:22:07 +00:00
|
|
|
const TargetMachine &getTarget() const { return TM; }
|
2010-04-17 15:26:15 +00:00
|
|
|
const TargetLowering &getTargetLoweringInfo() const { return TLI; }
|
2010-05-11 17:31:57 +00:00
|
|
|
const TargetSelectionDAGInfo &getSelectionDAGInfo() const { return TSI; }
|
2009-07-09 17:57:24 +00:00
|
|
|
LLVMContext *getContext() const {return Context; }
|
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) {
|
2009-08-11 20:47:22 +00:00
|
|
|
assert((!N.getNode() || N.getValueType() == MVT::Other) &&
|
2008-07-22 18:04:23 +00:00
|
|
|
"DAG root value is not a chain!");
|
2010-01-20 20:13:31 +00:00
|
|
|
if (N.getNode())
|
|
|
|
checkForCycles(N.getNode());
|
|
|
|
Root = N;
|
|
|
|
if (N.getNode())
|
|
|
|
checkForCycles(this);
|
|
|
|
return Root;
|
2008-07-22 18:04:23 +00:00
|
|
|
}
|
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-12-05 17:51:33 +00:00
|
|
|
void Legalize(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.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDVTList getVTList(EVT VT);
|
|
|
|
SDVTList getVTList(EVT VT1, EVT VT2);
|
|
|
|
SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3);
|
|
|
|
SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4);
|
|
|
|
SDVTList getVTList(const EVT *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.
|
|
|
|
//
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getConstant(uint64_t Val, EVT VT, bool isTarget = false);
|
|
|
|
SDValue getConstant(const APInt &Val, EVT VT, bool isTarget = false);
|
|
|
|
SDValue getConstant(const ConstantInt &Val, EVT VT, bool isTarget = false);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getTargetConstant(uint64_t Val, EVT VT) {
|
2006-08-11 21:00:46 +00:00
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getTargetConstant(const APInt &Val, EVT VT) {
|
2008-02-08 22:59:30 +00:00
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getTargetConstant(const ConstantInt &Val, EVT VT) {
|
2008-09-12 18:08:03 +00:00
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2010-05-07 21:35:53 +00:00
|
|
|
// The forms below that take a double should only be used for simple
|
|
|
|
// constants that can be exactly represented in VT. No checks are made.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getConstantFP(double Val, EVT VT, bool isTarget = false);
|
|
|
|
SDValue getConstantFP(const APFloat& Val, EVT VT, bool isTarget = false);
|
|
|
|
SDValue getConstantFP(const ConstantFP &CF, EVT VT, bool isTarget = false);
|
|
|
|
SDValue getTargetConstantFP(double Val, EVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getTargetConstantFP(const APFloat& Val, EVT VT) {
|
2007-08-30 00:23:21 +00:00
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getTargetConstantFP(const ConstantFP &Val, EVT VT) {
|
2008-09-12 18:08:03 +00:00
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2010-07-06 22:08:15 +00:00
|
|
|
SDValue getGlobalAddress(const GlobalValue *GV, DebugLoc DL, EVT VT,
|
2009-06-25 21:21:14 +00:00
|
|
|
int64_t offset = 0, bool isTargetGA = false,
|
|
|
|
unsigned char TargetFlags = 0);
|
2010-07-06 22:08:15 +00:00
|
|
|
SDValue getTargetGlobalAddress(const GlobalValue *GV, DebugLoc DL, EVT VT,
|
2009-06-25 21:21:14 +00:00
|
|
|
int64_t offset = 0,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2010-07-06 22:08:15 +00:00
|
|
|
return getGlobalAddress(GV, DL, VT, offset, true, TargetFlags);
|
2006-08-11 21:00:46 +00:00
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false);
|
|
|
|
SDValue getTargetFrameIndex(int FI, EVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getFrameIndex(FI, VT, true);
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false,
|
2009-06-25 21:35:31 +00:00
|
|
|
unsigned char TargetFlags = 0);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags = 0) {
|
2009-06-25 21:35:31 +00:00
|
|
|
return getJumpTable(JTI, VT, true, TargetFlags);
|
2006-08-11 21:55:30 +00:00
|
|
|
}
|
2010-04-15 01:51:59 +00:00
|
|
|
SDValue getConstantPool(const Constant *C, EVT VT,
|
2009-06-25 21:35:31 +00:00
|
|
|
unsigned Align = 0, int Offs = 0, bool isT=false,
|
|
|
|
unsigned char TargetFlags = 0);
|
2010-04-15 01:51:59 +00:00
|
|
|
SDValue getTargetConstantPool(const Constant *C, EVT VT,
|
2009-06-25 21:35:31 +00:00
|
|
|
unsigned Align = 0, int Offset = 0,
|
|
|
|
unsigned char TargetFlags = 0) {
|
|
|
|
return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
|
2006-08-11 21:55:30 +00:00
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getConstantPool(MachineConstantPoolValue *C, EVT VT,
|
2009-06-25 21:35:31 +00:00
|
|
|
unsigned Align = 0, int Offs = 0, bool isT=false,
|
|
|
|
unsigned char TargetFlags = 0);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getTargetConstantPool(MachineConstantPoolValue *C,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT, unsigned Align = 0,
|
2009-06-25 21:35:31 +00:00
|
|
|
int Offset = 0, unsigned char TargetFlags=0) {
|
|
|
|
return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
|
2006-09-12 21:00:35 +00:00
|
|
|
}
|
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);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getExternalSymbol(const char *Sym, EVT VT);
|
|
|
|
SDValue getExternalSymbol(const char *Sym, DebugLoc dl, EVT VT);
|
|
|
|
SDValue getTargetExternalSymbol(const char *Sym, EVT VT,
|
2009-06-25 18:45:50 +00:00
|
|
|
unsigned char TargetFlags = 0);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getValueType(EVT);
|
|
|
|
SDValue getRegister(unsigned Reg, EVT VT);
|
2010-03-14 02:33:54 +00:00
|
|
|
SDValue getEHLabel(DebugLoc dl, SDValue Root, MCSymbol *Label);
|
2010-04-15 01:51:59 +00:00
|
|
|
SDValue getBlockAddress(const BlockAddress *BA, EVT VT,
|
2009-11-20 23:18:13 +00:00
|
|
|
bool isTarget = false, unsigned char TargetFlags = 0);
|
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) {
|
2009-08-11 20:47:22 +00:00
|
|
|
return getNode(ISD::CopyToReg, dl, MVT::Other, Chain,
|
2009-02-03 22:26:09 +00:00
|
|
|
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
|
2010-12-23 17:24:32 +00:00
|
|
|
// indicates that there is potentially an incoming glue value (if Glue is not
|
|
|
|
// null) and that there should be a glue result.
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getCopyToReg(SDValue Chain, DebugLoc dl, unsigned Reg, SDValue N,
|
2010-12-23 17:24:32 +00:00
|
|
|
SDValue Glue) {
|
2010-12-21 02:38:05 +00:00
|
|
|
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
|
2010-12-23 17:24:32 +00:00
|
|
|
SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue };
|
|
|
|
return getNode(ISD::CopyToReg, dl, VTs, Ops, Glue.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,
|
2010-12-23 17:24:32 +00:00
|
|
|
SDValue Glue) {
|
2010-12-21 02:38:05 +00:00
|
|
|
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
|
2010-12-23 17:24:32 +00:00
|
|
|
SDValue Ops[] = { Chain, Reg, N, Glue };
|
|
|
|
return getNode(ISD::CopyToReg, dl, VTs, Ops, Glue.getNode() ? 4 : 3);
|
2009-02-03 22:26:09 +00:00
|
|
|
}
|
2009-02-17 22:15:04 +00:00
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getCopyFromReg(SDValue Chain, DebugLoc dl, unsigned Reg, EVT VT) {
|
2009-08-11 20:47:22 +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
|
2010-12-23 17:24:32 +00:00
|
|
|
// indicates that there is potentially an incoming glue value (if Glue is not
|
|
|
|
// null) and that there should be a glue result.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getCopyFromReg(SDValue Chain, DebugLoc dl, unsigned Reg, EVT VT,
|
2010-12-23 17:24:32 +00:00
|
|
|
SDValue Glue) {
|
2010-12-21 02:38:05 +00:00
|
|
|
SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue);
|
2010-12-23 17:24:32 +00:00
|
|
|
SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue };
|
|
|
|
return getNode(ISD::CopyFromReg, dl, VTs, Ops, Glue.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-08-10 22:56:29 +00:00
|
|
|
SDValue getConvertRndSat(EVT VT, DebugLoc dl, SDValue Val, SDValue DTy,
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue STy,
|
|
|
|
SDValue Rnd, SDValue Sat, ISD::CvtCode Code);
|
2011-03-07 18:29:47 +00:00
|
|
|
|
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.
|
2011-03-07 18:29:47 +00:00
|
|
|
SDValue getVectorShuffle(EVT VT, DebugLoc dl, SDValue N1, SDValue N2,
|
2009-04-27 18:41:29 +00:00
|
|
|
const int *MaskElts);
|
2008-11-10 20:54:11 +00:00
|
|
|
|
2009-10-13 21:04:12 +00:00
|
|
|
/// getSExtOrTrunc - Convert Op, which must be of integer type, to the
|
|
|
|
/// integer type VT, by either sign-extending or truncating it.
|
|
|
|
SDValue getSExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT);
|
|
|
|
|
|
|
|
/// getZExtOrTrunc - Convert Op, which must be of integer type, to the
|
|
|
|
/// integer type VT, by either zero-extending or truncating it.
|
|
|
|
SDValue getZExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT);
|
|
|
|
|
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-08-10 22:56:29 +00:00
|
|
|
SDValue getZeroExtendInReg(SDValue Op, DebugLoc DL, EVT 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-08-10 22:56:29 +00:00
|
|
|
SDValue getNOT(DebugLoc DL, SDValue Val, EVT 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
|
2010-12-23 17:24:32 +00:00
|
|
|
/// a glue result (to ensure it's not CSE'd). CALLSEQ_START does not have a
|
2009-02-06 23:05:02 +00:00
|
|
|
/// useful DebugLoc.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getCALLSEQ_START(SDValue Chain, SDValue Op) {
|
2010-12-21 02:38:05 +00:00
|
|
|
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ops[] = { Chain, Op };
|
2010-04-02 20:20:41 +00:00
|
|
|
return getNode(ISD::CALLSEQ_START, DebugLoc(), 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
|
2010-12-23 17:24:32 +00:00
|
|
|
/// glue result (to ensure it's not CSE'd). CALLSEQ_END does not have
|
2009-02-06 23:05:02 +00:00
|
|
|
/// a useful DebugLoc.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2,
|
2010-12-23 17:24:32 +00:00
|
|
|
SDValue InGlue) {
|
2010-12-21 02:38:05 +00:00
|
|
|
SDVTList NodeTys = getVTList(MVT::Other, MVT::Glue);
|
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);
|
2010-12-23 17:24:32 +00:00
|
|
|
Ops.push_back(InGlue);
|
2010-04-02 20:20:41 +00:00
|
|
|
return getNode(ISD::CALLSEQ_END, DebugLoc(), NodeTys, &Ops[0],
|
2010-12-23 17:24:32 +00:00
|
|
|
(unsigned)Ops.size() - (InGlue.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.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getUNDEF(EVT VT) {
|
2010-04-02 20:20:41 +00:00
|
|
|
return getNode(ISD::UNDEF, DebugLoc(), VT);
|
2009-02-06 23:05:02 +00:00
|
|
|
}
|
|
|
|
|
2009-02-07 00:55:49 +00:00
|
|
|
/// getGLOBAL_OFFSET_TABLE - Return a GLOBAL_OFFSET_TABLE node. This does
|
|
|
|
/// not have a useful DebugLoc.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getGLOBAL_OFFSET_TABLE(EVT VT) {
|
2010-04-02 20:20:41 +00:00
|
|
|
return getNode(ISD::GLOBAL_OFFSET_TABLE, DebugLoc(), VT);
|
2009-02-07 00:55:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-07 07:46:32 +00:00
|
|
|
/// getNode - Gets or creates the specified node.
|
2003-08-11 14:56:26 +00:00
|
|
|
///
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT, SDValue N);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT, SDValue N1, SDValue N2);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
|
2009-01-28 22:17:52 +00:00
|
|
|
SDValue N1, SDValue N2, SDValue N3);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
|
2009-01-28 22:17:52 +00:00
|
|
|
SDValue N1, SDValue N2, SDValue N3, SDValue N4);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
|
2009-01-28 22:17:52 +00:00
|
|
|
SDValue N1, SDValue N2, SDValue N3, SDValue N4,
|
|
|
|
SDValue N5);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
|
2009-01-28 22:17:52 +00:00
|
|
|
const SDUse *Ops, unsigned NumOps);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
|
2009-01-28 22:17:52 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL,
|
2009-08-10 22:56:29 +00:00
|
|
|
const std::vector<EVT> &ResultTys,
|
2009-01-28 22:17:52 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue getNode(unsigned Opcode, DebugLoc DL, const EVT *VTs, unsigned NumVTs,
|
2009-01-28 22:17:52 +00:00
|
|
|
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
|
|
|
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
/// getStackArgumentTokenFactor - Compute a TokenFactor to force all
|
|
|
|
/// the incoming stack arguments to be loaded from the stack. This is
|
|
|
|
/// used in tail call lowering to protect stack arguments from being
|
|
|
|
/// clobbered.
|
|
|
|
SDValue getStackArgumentTokenFactor(SDValue Chain);
|
|
|
|
|
2009-02-03 22:26:09 +00:00
|
|
|
SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src,
|
Reapply address space patch after fixing an issue in MemCopyOptimizer.
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100304 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-04 03:10:48 +00:00
|
|
|
SDValue Size, unsigned Align, bool isVol, bool AlwaysInline,
|
2010-09-21 05:40:29 +00:00
|
|
|
MachinePointerInfo DstPtrInfo,
|
|
|
|
MachinePointerInfo SrcPtrInfo);
|
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,
|
Reapply address space patch after fixing an issue in MemCopyOptimizer.
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100304 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-04 03:10:48 +00:00
|
|
|
SDValue Size, unsigned Align, bool isVol,
|
2010-09-21 05:40:29 +00:00
|
|
|
MachinePointerInfo DstPtrInfo,
|
|
|
|
MachinePointerInfo SrcPtrInfo);
|
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,
|
Reapply address space patch after fixing an issue in MemCopyOptimizer.
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100304 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-04 03:10:48 +00:00
|
|
|
SDValue Size, unsigned Align, bool isVol,
|
2010-09-21 05:40:29 +00:00
|
|
|
MachinePointerInfo DstPtrInfo);
|
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-08-10 22:56:29 +00:00
|
|
|
SDValue getSetCC(DebugLoc DL, EVT VT, SDValue LHS, SDValue RHS,
|
2009-01-30 02:23:43 +00:00
|
|
|
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-08-10 22:56:29 +00:00
|
|
|
SDValue getVSetCC(DebugLoc DL, EVT VT, SDValue LHS, SDValue RHS,
|
2009-01-30 02:23:43 +00:00
|
|
|
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-08-10 22:56:29 +00:00
|
|
|
SDValue getVAArg(EVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr,
|
2010-07-11 04:01:49 +00:00
|
|
|
SDValue SV, unsigned Align);
|
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-08-10 22:56:29 +00:00
|
|
|
SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
|
2010-09-21 04:53:42 +00:00
|
|
|
SDValue Ptr, SDValue Cmp, SDValue Swp,
|
|
|
|
MachinePointerInfo PtrInfo, unsigned Alignment=0);
|
2009-09-25 20:36:54 +00:00
|
|
|
SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
|
|
|
|
SDValue Ptr, SDValue Cmp, SDValue Swp,
|
|
|
|
MachineMemOperand *MMO);
|
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-08-10 22:56:29 +00:00
|
|
|
SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue Ptr, SDValue Val, const Value* PtrVal,
|
|
|
|
unsigned Alignment = 0);
|
2009-09-25 20:36:54 +00:00
|
|
|
SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
|
|
|
|
SDValue Ptr, SDValue Val,
|
|
|
|
MachineMemOperand *MMO);
|
2008-02-21 06:45:13 +00:00
|
|
|
|
2008-10-17 18:22:58 +00:00
|
|
|
/// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a
|
2009-09-25 20:36:54 +00:00
|
|
|
/// result and takes a list of operands. Opcode may be INTRINSIC_VOID,
|
|
|
|
/// INTRINSIC_W_CHAIN, or a target-specific opcode with a value not
|
|
|
|
/// less than FIRST_TARGET_MEMORY_OPCODE.
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl,
|
2009-08-10 22:56:29 +00:00
|
|
|
const EVT *VTs, unsigned NumVTs,
|
2009-01-29 00:47:48 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps,
|
2010-09-21 04:57:15 +00:00
|
|
|
EVT MemVT, MachinePointerInfo PtrInfo,
|
2009-01-29 00:47:48 +00:00
|
|
|
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,
|
2010-09-21 04:57:15 +00:00
|
|
|
EVT MemVT, MachinePointerInfo PtrInfo,
|
2009-01-29 00:47:48 +00:00
|
|
|
unsigned Align = 0, bool Vol = false,
|
|
|
|
bool ReadMem = true, bool WriteMem = true);
|
2008-10-17 18:22:58 +00:00
|
|
|
|
2009-09-25 20:36:54 +00:00
|
|
|
SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl, SDVTList VTList,
|
|
|
|
const SDValue *Ops, unsigned NumOps,
|
|
|
|
EVT MemVT, MachineMemOperand *MMO);
|
|
|
|
|
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
|
|
|
|
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
|
|
|
///
|
2010-09-21 05:40:29 +00:00
|
|
|
SDValue getLoad(EVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr,
|
|
|
|
MachinePointerInfo PtrInfo, bool isVolatile,
|
2010-10-20 00:31:05 +00:00
|
|
|
bool isNonTemporal, unsigned Alignment,
|
|
|
|
const MDNode *TBAAInfo = 0);
|
2011-02-16 16:23:55 +00:00
|
|
|
SDValue getExtLoad(ISD::LoadExtType ExtType, DebugLoc dl, EVT VT,
|
2010-09-21 05:40:29 +00:00
|
|
|
SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo,
|
|
|
|
EVT MemVT, bool isVolatile,
|
2010-10-20 00:31:05 +00:00
|
|
|
bool isNonTemporal, unsigned Alignment,
|
|
|
|
const MDNode *TBAAInfo = 0);
|
2009-01-29 00:47:48 +00:00
|
|
|
SDValue getIndexedLoad(SDValue OrigLoad, DebugLoc dl, SDValue Base,
|
2010-07-07 22:15:37 +00:00
|
|
|
SDValue Offset, ISD::MemIndexedMode AM);
|
2010-09-21 05:10:45 +00:00
|
|
|
SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
|
|
|
|
EVT VT, DebugLoc dl,
|
|
|
|
SDValue Chain, SDValue Ptr, SDValue Offset,
|
|
|
|
MachinePointerInfo PtrInfo, EVT MemVT,
|
2010-10-20 00:31:05 +00:00
|
|
|
bool isVolatile, bool isNonTemporal, unsigned Alignment,
|
|
|
|
const MDNode *TBAAInfo = 0);
|
2010-07-07 22:15:37 +00:00
|
|
|
SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
|
|
|
|
EVT VT, DebugLoc dl,
|
|
|
|
SDValue Chain, SDValue Ptr, SDValue Offset,
|
2009-09-25 20:36:54 +00:00
|
|
|
EVT MemVT, MachineMemOperand *MMO);
|
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,
|
2010-09-21 05:10:45 +00:00
|
|
|
MachinePointerInfo PtrInfo, bool isVolatile,
|
2010-10-20 00:31:05 +00:00
|
|
|
bool isNonTemporal, unsigned Alignment,
|
|
|
|
const MDNode *TBAAInfo = 0);
|
2009-09-25 20:36:54 +00:00
|
|
|
SDValue getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
|
|
|
|
MachineMemOperand *MMO);
|
2010-09-21 05:10:45 +00:00
|
|
|
SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
|
|
|
|
MachinePointerInfo PtrInfo, EVT TVT,
|
|
|
|
bool isNonTemporal, bool isVolatile,
|
2010-10-20 00:31:05 +00:00
|
|
|
unsigned Alignment,
|
|
|
|
const MDNode *TBAAInfo = 0);
|
2009-09-25 20:36:54 +00:00
|
|
|
SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
|
|
|
|
EVT TVT, MachineMemOperand *MMO);
|
2009-01-29 00:47:48 +00:00
|
|
|
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
|
|
|
|
2010-04-07 05:20:54 +00:00
|
|
|
/// getMDNode - Return an MDNodeSDNode which holds an MDNode.
|
|
|
|
SDValue getMDNode(const MDNode *MD);
|
2011-03-07 18:29:47 +00:00
|
|
|
|
2009-01-31 15:50:11 +00:00
|
|
|
/// getShiftAmountOperand - Return the specified value casted to
|
|
|
|
/// the target's desired shift amount type.
|
2011-03-07 18:29:47 +00:00
|
|
|
SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op);
|
2009-01-31 15:50:11 +00:00
|
|
|
|
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.
|
2010-06-18 15:30:29 +00:00
|
|
|
SDNode *UpdateNodeOperands(SDNode *N, SDValue Op);
|
|
|
|
SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2);
|
|
|
|
SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op3);
|
2010-06-18 15:30:29 +00:00
|
|
|
SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op3, SDValue Op4);
|
2010-06-18 15:30:29 +00:00
|
|
|
SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op3, SDValue Op4, SDValue Op5);
|
2010-06-18 15:30:29 +00:00
|
|
|
SDNode *UpdateNodeOperands(SDNode *N,
|
2008-07-27 21:46:04 +00:00
|
|
|
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.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT, SDValue Op1);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op1, SDValue Op2);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op1, SDValue Op2, SDValue Op3);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, EVT VT2);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
|
|
|
|
EVT VT2, const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
|
|
|
|
EVT VT2, EVT VT3, const SDValue *Ops, unsigned NumOps);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
|
|
|
|
EVT VT2, EVT VT3, EVT VT4, const SDValue *Ops,
|
2008-12-01 23:28:22 +00:00
|
|
|
unsigned NumOps);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
|
|
|
|
EVT VT2, SDValue Op1);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
|
|
|
|
EVT VT2, SDValue Op1, SDValue Op2);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
|
|
|
|
EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
|
|
|
|
EVT VT2, EVT 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
|
|
|
|
2010-03-01 22:20:05 +00:00
|
|
|
/// MorphNodeTo - This *mutates* the specified node to have the specified
|
2008-07-17 19:10:17 +00:00
|
|
|
/// return type, opcode, and operands.
|
|
|
|
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
|
|
|
|
2009-09-25 18:54:59 +00:00
|
|
|
/// getMachineNode - These are used for target selectors to create a new node
|
|
|
|
/// with specified return type(s), MachineInstr opcode, and operands.
|
2006-02-09 07:15:23 +00:00
|
|
|
///
|
2009-09-25 18:54:59 +00:00
|
|
|
/// Note that getMachineNode 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-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT);
|
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
|
|
|
|
SDValue Op1);
|
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
|
|
|
|
SDValue Op1, SDValue Op2);
|
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
|
2009-09-25 18:54:59 +00:00
|
|
|
SDValue Op1, SDValue Op2, SDValue Op3);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
|
2009-09-25 18:54:59 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2);
|
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
|
2009-09-25 18:54:59 +00:00
|
|
|
SDValue Op1);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1,
|
2009-09-25 18:54:59 +00:00
|
|
|
EVT VT2, SDValue Op1, SDValue Op2);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1,
|
2009-09-25 18:54:59 +00:00
|
|
|
EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
|
2009-09-25 18:54:59 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
|
2009-09-25 18:54:59 +00:00
|
|
|
EVT VT3, SDValue Op1, SDValue Op2);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
|
2009-09-25 18:54:59 +00:00
|
|
|
EVT VT3, SDValue Op1, SDValue Op2, SDValue Op3);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
|
2009-09-25 18:54:59 +00:00
|
|
|
EVT VT3, const SDValue *Ops, unsigned NumOps);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
|
2009-09-25 18:54:59 +00:00
|
|
|
EVT VT3, EVT VT4, const SDValue *Ops, unsigned NumOps);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl,
|
2009-09-25 20:36:54 +00:00
|
|
|
const std::vector<EVT> &ResultTys, const SDValue *Ops,
|
|
|
|
unsigned NumOps);
|
2009-10-10 01:29:16 +00:00
|
|
|
MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, SDVTList VTs,
|
2009-09-25 20:36:54 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps);
|
2008-03-22 01:55:50 +00:00
|
|
|
|
2009-08-19 18:16:17 +00:00
|
|
|
/// getTargetExtractSubreg - A convenience function for creating
|
|
|
|
/// TargetInstrInfo::EXTRACT_SUBREG nodes.
|
|
|
|
SDValue getTargetExtractSubreg(int SRIdx, DebugLoc DL, EVT VT,
|
|
|
|
SDValue Operand);
|
|
|
|
|
2009-10-08 18:49:46 +00:00
|
|
|
/// getTargetInsertSubreg - A convenience function for creating
|
|
|
|
/// TargetInstrInfo::INSERT_SUBREG nodes.
|
|
|
|
SDValue getTargetInsertSubreg(int SRIdx, DebugLoc DL, EVT VT,
|
|
|
|
SDValue Operand, SDValue Subreg);
|
|
|
|
|
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
|
|
|
|
2010-03-29 20:48:30 +00:00
|
|
|
/// getDbgValue - Creates a SDDbgValue node.
|
|
|
|
///
|
|
|
|
SDDbgValue *getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R, uint64_t Off,
|
|
|
|
DebugLoc DL, unsigned O);
|
2010-04-15 01:51:59 +00:00
|
|
|
SDDbgValue *getDbgValue(MDNode *MDPtr, const Value *C, uint64_t Off,
|
2010-03-29 20:48:30 +00:00
|
|
|
DebugLoc DL, unsigned O);
|
|
|
|
SDDbgValue *getDbgValue(MDNode *MDPtr, unsigned FI, uint64_t Off,
|
|
|
|
DebugLoc DL, unsigned O);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-18 23:32:53 +00:00
|
|
|
/// AssignOrdering - Assign an order to the SDNode.
|
2010-01-28 21:51:40 +00:00
|
|
|
void AssignOrdering(const SDNode *SD, unsigned Order);
|
2009-12-18 23:32:53 +00:00
|
|
|
|
2009-12-21 21:59:52 +00:00
|
|
|
/// GetOrdering - Get the order for the SDNode.
|
|
|
|
unsigned GetOrdering(const SDNode *SD) const;
|
|
|
|
|
2010-03-25 01:38:16 +00:00
|
|
|
/// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the
|
|
|
|
/// value is produced by SD.
|
2010-04-26 20:06:49 +00:00
|
|
|
void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter);
|
2010-03-10 22:13:47 +00:00
|
|
|
|
2010-03-25 01:38:16 +00:00
|
|
|
/// GetDbgValues - Get the debug values which reference the given SDNode.
|
|
|
|
SmallVector<SDDbgValue*,2> &GetDbgValues(const SDNode* SD) {
|
|
|
|
return DbgInfo->getSDDbgValues(SD);
|
|
|
|
}
|
2011-03-07 18:29:47 +00:00
|
|
|
|
2011-01-25 23:27:42 +00:00
|
|
|
/// TransferDbgValues - Transfer SDDbgValues.
|
|
|
|
void TransferDbgValues(SDValue From, SDValue To);
|
2010-03-10 22:13:47 +00:00
|
|
|
|
2010-03-25 01:38:16 +00:00
|
|
|
/// hasDebugValues - Return true if there are any SDDbgValue nodes associated
|
|
|
|
/// with this SelectionDAG.
|
|
|
|
bool hasDebugValues() const { return !DbgInfo->empty(); }
|
2010-03-10 22:13:47 +00:00
|
|
|
|
2010-03-25 01:38:16 +00:00
|
|
|
SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); }
|
|
|
|
SDDbgInfo::DbgIterator DbgEnd() { return DbgInfo->DbgEnd(); }
|
2011-03-07 18:29:47 +00:00
|
|
|
SDDbgInfo::DbgIterator ByvalParmDbgBegin() {
|
|
|
|
return DbgInfo->ByvalParmDbgBegin();
|
2010-04-26 20:06:49 +00:00
|
|
|
}
|
2011-03-07 18:29:47 +00:00
|
|
|
SDDbgInfo::DbgIterator ByvalParmDbgEnd() {
|
|
|
|
return DbgInfo->ByvalParmDbgEnd();
|
2010-04-26 20:06:49 +00:00
|
|
|
}
|
2010-03-10 22:13:47 +00:00
|
|
|
|
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.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue CreateStackTemporary(EVT 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.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue CreateStackTemporary(EVT VT1, EVT VT2);
|
2008-12-09 21:33:20 +00:00
|
|
|
|
2009-02-17 22:15:04 +00:00
|
|
|
/// FoldConstantArithmetic -
|
2008-09-24 10:25:02 +00:00
|
|
|
SDValue FoldConstantArithmetic(unsigned Opcode,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT,
|
2008-09-24 10:25:02 +00:00
|
|
|
ConstantSDNode *Cst1,
|
|
|
|
ConstantSDNode *Cst2);
|
|
|
|
|
2006-10-14 00:41:01 +00:00
|
|
|
/// FoldSetCC - Constant fold a setcc to true or false.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue FoldSetCC(EVT 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
|
|
|
|
2011-02-13 22:30:09 +00:00
|
|
|
/// isBaseWithConstantOffset - Return true if the specified operand is an
|
|
|
|
/// ISD::ADD with a ConstantSDNode on the right-hand side, or if it is an
|
|
|
|
/// ISD::OR with a ConstantSDNode that is guaranteed to have the same
|
|
|
|
/// semantics as an ADD. This handles the equivalence:
|
2011-02-14 06:14:42 +00:00
|
|
|
/// X|Cst == X+Cst iff X&Cst = 0.
|
2011-02-13 22:30:09 +00:00
|
|
|
bool isBaseWithConstantOffset(SDValue Op) const;
|
2011-03-07 18:29:47 +00:00
|
|
|
|
2009-09-03 20:34:31 +00:00
|
|
|
/// isKnownNeverNan - Test whether the given SDValue is known to never be NaN.
|
|
|
|
bool isKnownNeverNaN(SDValue Op) const;
|
|
|
|
|
2010-02-24 06:52:40 +00:00
|
|
|
/// isKnownNeverZero - Test whether the given SDValue is known to never be
|
|
|
|
/// positive or negative Zero.
|
|
|
|
bool isKnownNeverZero(SDValue Op) const;
|
|
|
|
|
|
|
|
/// isEqualTo - Test whether two SDValues are known to compare equal. This
|
|
|
|
/// is true if they are the same value, or if one is negative zero and the
|
|
|
|
/// other positive zero.
|
|
|
|
bool isEqualTo(SDValue A, SDValue B) const;
|
|
|
|
|
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
|
|
|
|
2009-11-30 02:42:02 +00:00
|
|
|
/// UnrollVectorOp - Utility function used by legalize and lowering to
|
|
|
|
/// "unroll" a vector operation by splitting out the scalars and operating
|
|
|
|
/// on each element individually. If the ResNE is 0, fully unroll the vector
|
|
|
|
/// op. If ResNE is less than the width of the vector op, unroll up to ResNE.
|
|
|
|
/// If the ResNE is greater than the width of the vector op, unroll the
|
|
|
|
/// vector op and fill the end of the resulting vector with UNDEFS.
|
|
|
|
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
|
|
|
|
|
2011-03-07 18:29:47 +00:00
|
|
|
/// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a
|
|
|
|
/// location that is 'Dist' units away from the location that the 'Base' load
|
2009-12-09 01:36:00 +00:00
|
|
|
/// is loading from.
|
|
|
|
bool isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base,
|
|
|
|
unsigned Bytes, int Dist) const;
|
|
|
|
|
2009-12-09 01:04:59 +00:00
|
|
|
/// InferPtrAlignment - Infer alignment of a load / store address. Return 0 if
|
|
|
|
/// it cannot be inferred.
|
2009-12-09 01:10:37 +00:00
|
|
|
unsigned InferPtrAlignment(SDValue Ptr) const;
|
2009-12-09 01:04:59 +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
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
unsigned getEVTAlignment(EVT 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;
|
2009-08-10 22:56:29 +00:00
|
|
|
std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
|
2008-09-16 21:48:12 +00:00
|
|
|
StringMap<SDNode*> ExternalSymbols;
|
2011-03-07 18:29:47 +00:00
|
|
|
|
2009-06-25 18:45:50 +00:00
|
|
|
std::map<std::pair<std::string, unsigned char>,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
|