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
|
|
|
|
|
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"
|
2005-11-09 23:46:43 +00:00
|
|
|
|
2005-11-08 23:30:11 +00:00
|
|
|
#include <list>
|
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 {
|
2006-10-16 20:52:31 +00:00
|
|
|
class AliasAnalysis;
|
2005-01-07 07:46:32 +00:00
|
|
|
class TargetLowering;
|
|
|
|
class TargetMachine;
|
2007-01-26 21:22:28 +00:00
|
|
|
class MachineModuleInfo;
|
2005-01-07 07:46:32 +00:00
|
|
|
class MachineFunction;
|
2006-09-12 21:00:35 +00:00
|
|
|
class MachineConstantPoolValue;
|
2008-06-17 06:09:18 +00:00
|
|
|
class FunctionLoweringInfo;
|
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;
|
2005-01-07 07:46:32 +00:00
|
|
|
MachineFunction &MF;
|
2008-06-17 06:09:18 +00:00
|
|
|
FunctionLoweringInfo &FLI;
|
2007-01-26 21:22:28 +00:00
|
|
|
MachineModuleInfo *MMI;
|
2003-08-11 14:56:26 +00:00
|
|
|
|
2006-08-14 22:19:25 +00:00
|
|
|
/// Root - The root of the entire DAG. EntryNode - The starting token.
|
2005-01-07 07:46:32 +00:00
|
|
|
SDOperand Root, EntryNode;
|
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-07 23:02:41 +00:00
|
|
|
alist<SDNode, LargestSDNode> &AllNodes;
|
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
|
|
|
|
2003-08-11 14:56:26 +00:00
|
|
|
public:
|
2008-06-17 06:09:18 +00:00
|
|
|
SelectionDAG(TargetLowering &tli, MachineFunction &mf,
|
2008-07-07 23:02:41 +00:00
|
|
|
FunctionLoweringInfo &fli, MachineModuleInfo *mmi,
|
|
|
|
alist<SDNode, LargestSDNode> &NodePool)
|
|
|
|
: TLI(tli), MF(mf), FLI(fli), MMI(mmi), AllNodes(NodePool) {
|
2005-01-07 07:46:32 +00:00
|
|
|
EntryNode = Root = getNode(ISD::EntryToken, MVT::Other);
|
|
|
|
}
|
2003-08-11 14:56:26 +00:00
|
|
|
~SelectionDAG();
|
|
|
|
|
2005-01-07 07:46:32 +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; }
|
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
|
|
|
///
|
|
|
|
void viewGraph();
|
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();
|
|
|
|
|
|
|
|
/// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".)
|
|
|
|
///
|
|
|
|
void setGraphAttrs(const SDNode *N, const char *Attrs);
|
|
|
|
|
|
|
|
/// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".)
|
|
|
|
/// Used from getNodeAttributes.
|
|
|
|
const std::string getGraphAttrs(const SDNode *N) const;
|
|
|
|
|
|
|
|
/// setGraphColor - Convenience for setting node color attribute.
|
|
|
|
///
|
|
|
|
void setGraphColor(const SDNode *N, const char *Color);
|
2005-01-10 23:05:53 +00:00
|
|
|
|
2008-07-07 23:02:41 +00:00
|
|
|
typedef alist<SDNode, LargestSDNode>::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-07 23:02:41 +00:00
|
|
|
typedef alist<SDNode, LargestSDNode>::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-07 23:02:41 +00:00
|
|
|
alist<SDNode, LargestSDNode>::size_type allnodes_size() const {
|
|
|
|
return AllNodes.size();
|
|
|
|
}
|
2005-11-09 23:46:43 +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
|
|
|
///
|
2005-01-07 07:46:32 +00:00
|
|
|
const SDOperand &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.
|
|
|
|
const SDOperand &getEntryNode() const { return EntryNode; }
|
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
|
|
|
///
|
2005-01-07 07:46:32 +00:00
|
|
|
const SDOperand &setRoot(SDOperand N) { 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
|
|
|
|
/// certain types of nodes together, or eliminating superfluous nodes. When
|
|
|
|
/// the AfterLegalize argument is set to 'true', Combine takes care not to
|
|
|
|
/// generate any nodes that will be illegal on the target.
|
2006-10-16 20:52:31 +00:00
|
|
|
void Combine(bool AfterLegalize, AliasAnalysis &AA);
|
2005-09-01 00:19:25 +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
|
|
|
|
/// only uses types natively supported by the target.
|
|
|
|
///
|
|
|
|
/// Note that this is an involved process that may invalidate pointers into
|
|
|
|
/// the graph.
|
|
|
|
void 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.
|
2005-01-23 04:36:06 +00:00
|
|
|
void Legalize();
|
2005-01-07 07:46:32 +00:00
|
|
|
|
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);
|
|
|
|
SDVTList getVTList(const MVT *VTs, unsigned NumVTs);
|
2006-08-15 17:46:01 +00:00
|
|
|
|
|
|
|
/// getNodeValueTypes - These are obsolete, use getVTList instead.
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *getNodeValueTypes(MVT VT) {
|
2006-08-15 17:46:01 +00:00
|
|
|
return getVTList(VT).VTs;
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *getNodeValueTypes(MVT VT1, MVT VT2) {
|
2006-08-15 17:46:01 +00:00
|
|
|
return getVTList(VT1, VT2).VTs;
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *getNodeValueTypes(MVT VT1, MVT VT2, MVT VT3) {
|
2006-08-15 17:46:01 +00:00
|
|
|
return getVTList(VT1, VT2, VT3).VTs;
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *getNodeValueTypes(std::vector<MVT> &vtList) {
|
2008-05-19 20:15:12 +00:00
|
|
|
return getVTList(&vtList[0], (unsigned)vtList.size()).VTs;
|
2006-08-15 17:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-30 05:56:52 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-08-15 17:46:01 +00:00
|
|
|
// Node creation methods.
|
|
|
|
//
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getConstant(uint64_t Val, MVT VT, bool isTarget = false);
|
|
|
|
SDOperand getConstant(const APInt &Val, MVT VT, bool isTarget = false);
|
2008-01-17 07:00:52 +00:00
|
|
|
SDOperand getIntPtrConstant(uint64_t Val, bool isTarget = false);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getTargetConstant(uint64_t Val, MVT VT) {
|
2006-08-11 21:00:46 +00:00
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getTargetConstant(const APInt &Val, MVT VT) {
|
2008-02-08 22:59:30 +00:00
|
|
|
return getConstant(Val, VT, true);
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getConstantFP(double Val, MVT VT, bool isTarget = false);
|
|
|
|
SDOperand getConstantFP(const APFloat& Val, MVT VT, bool isTarget = false);
|
|
|
|
SDOperand getTargetConstantFP(double Val, MVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getTargetConstantFP(const APFloat& Val, MVT VT) {
|
2007-08-30 00:23:21 +00:00
|
|
|
return getConstantFP(Val, VT, true);
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getGlobalAddress(const GlobalValue *GV, MVT VT,
|
2006-08-11 21:00:46 +00:00
|
|
|
int offset = 0, bool isTargetGA = false);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getTargetGlobalAddress(const GlobalValue *GV, MVT VT,
|
2006-08-11 21:00:46 +00:00
|
|
|
int offset = 0) {
|
|
|
|
return getGlobalAddress(GV, VT, offset, true);
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getFrameIndex(int FI, MVT VT, bool isTarget = false);
|
|
|
|
SDOperand getTargetFrameIndex(int FI, MVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getFrameIndex(FI, VT, true);
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getJumpTable(int JTI, MVT VT, bool isTarget = false);
|
|
|
|
SDOperand getTargetJumpTable(int JTI, MVT VT) {
|
2006-08-11 21:55:30 +00:00
|
|
|
return getJumpTable(JTI, VT, true);
|
|
|
|
}
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getConstantPool(Constant *C, MVT VT,
|
2006-08-11 21:55:30 +00:00
|
|
|
unsigned Align = 0, int Offs = 0, bool isT=false);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand 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-06-06 12:08:01 +00:00
|
|
|
SDOperand getConstantPool(MachineConstantPoolValue *C, MVT VT,
|
2006-09-12 21:00:35 +00:00
|
|
|
unsigned Align = 0, int Offs = 0, bool isT=false);
|
|
|
|
SDOperand 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);
|
|
|
|
}
|
2005-01-07 07:46:32 +00:00
|
|
|
SDOperand getBasicBlock(MachineBasicBlock *MBB);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getExternalSymbol(const char *Sym, MVT VT);
|
|
|
|
SDOperand getTargetExternalSymbol(const char *Sym, MVT VT);
|
2008-03-21 09:14:45 +00:00
|
|
|
SDOperand getArgFlags(ISD::ArgFlagsTy Flags);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getValueType(MVT);
|
|
|
|
SDOperand getRegister(unsigned Reg, MVT VT);
|
2008-06-30 20:59:49 +00:00
|
|
|
SDOperand getDbgStopPoint(SDOperand Root, unsigned Line, unsigned Col,
|
|
|
|
const CompileUnitDesc *CU);
|
2008-07-01 00:05:16 +00:00
|
|
|
SDOperand getLabel(unsigned Opcode, SDOperand Root, unsigned LabelID);
|
2005-01-07 07:46:32 +00:00
|
|
|
|
2005-08-16 21:55:35 +00:00
|
|
|
SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N) {
|
|
|
|
return getNode(ISD::CopyToReg, 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.
|
|
|
|
SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N,
|
|
|
|
SDOperand Flag) {
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
|
2006-08-08 02:23:42 +00:00
|
|
|
SDOperand Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag };
|
2006-08-14 23:31:51 +00:00
|
|
|
return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
|
2005-08-30 01:56:13 +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
|
|
|
|
|
|
|
// Similar to last getCopyToReg() except parameter Reg is a SDOperand
|
|
|
|
SDOperand getCopyToReg(SDOperand Chain, SDOperand Reg, SDOperand N,
|
|
|
|
SDOperand Flag) {
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
|
2006-08-08 02:23:42 +00:00
|
|
|
SDOperand Ops[] = { Chain, Reg, N, Flag };
|
2006-08-14 23:31:51 +00:00
|
|
|
return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
|
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
|
|
|
}
|
2005-08-30 01:56:13 +00:00
|
|
|
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT VT) {
|
|
|
|
const MVT *VTs = getNodeValueTypes(VT, MVT::Other);
|
2006-08-08 01:09:31 +00:00
|
|
|
SDOperand Ops[] = { Chain, getRegister(Reg, VT) };
|
2006-08-14 23:31:51 +00:00
|
|
|
return getNode(ISD::CopyFromReg, VTs, 2, Ops, 2);
|
2005-01-13 20:50:02 +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.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT VT,
|
2005-08-30 01:56:13 +00:00
|
|
|
SDOperand Flag) {
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *VTs = getNodeValueTypes(VT, MVT::Other, MVT::Flag);
|
2006-08-08 01:09:31 +00:00
|
|
|
SDOperand Ops[] = { Chain, getRegister(Reg, VT), Flag };
|
2006-08-14 23:31:51 +00:00
|
|
|
return getNode(ISD::CopyFromReg, VTs, 3, Ops, Flag.Val ? 3 : 2);
|
2005-08-30 01:56:13 +00:00
|
|
|
}
|
2005-01-13 20:50:02 +00:00
|
|
|
|
2005-08-09 20:20:18 +00:00
|
|
|
SDOperand getCondCode(ISD::CondCode Cond);
|
2003-08-11 14:56:26 +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.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getZeroExtendInReg(SDOperand Op, MVT SrcTy);
|
2006-02-13 08:54:46 +00:00
|
|
|
|
|
|
|
/// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have
|
|
|
|
/// a flag result (to ensure it's not CSE'd).
|
|
|
|
SDOperand getCALLSEQ_START(SDOperand Chain, SDOperand Op) {
|
2008-06-06 12:08:01 +00:00
|
|
|
const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
|
2006-08-08 01:09:31 +00:00
|
|
|
SDOperand Ops[] = { Chain, Op };
|
2006-08-14 23:31:51 +00:00
|
|
|
return getNode(ISD::CALLSEQ_START, VTs, 2, 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
|
|
|
|
/// flag result (to ensure it's not CSE'd).
|
|
|
|
SDOperand getCALLSEQ_END(SDOperand Chain, SDOperand Op1, SDOperand Op2,
|
|
|
|
SDOperand InFlag) {
|
|
|
|
SDVTList NodeTys = getVTList(MVT::Other, MVT::Flag);
|
|
|
|
SmallVector<SDOperand, 4> Ops;
|
|
|
|
Ops.push_back(Chain);
|
|
|
|
Ops.push_back(Op1);
|
|
|
|
Ops.push_back(Op2);
|
|
|
|
Ops.push_back(InFlag);
|
|
|
|
return getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0],
|
2008-05-05 18:30:58 +00:00
|
|
|
(unsigned)Ops.size() - (InFlag.Val == 0 ? 1 : 0));
|
2007-11-13 00:44:25 +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
|
|
|
///
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT);
|
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT, SDOperand N);
|
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT, SDOperand N1, SDOperand N2);
|
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT,
|
2005-01-07 07:46:32 +00:00
|
|
|
SDOperand N1, SDOperand N2, SDOperand N3);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT,
|
2005-04-27 20:10:01 +00:00
|
|
|
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT,
|
2005-07-10 00:28:25 +00:00
|
|
|
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
|
|
|
|
SDOperand N5);
|
2008-07-07 18:26:29 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT,
|
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
|
|
|
SDOperand getNode(unsigned Opcode, MVT VT,
|
|
|
|
const SDUse *Ops, unsigned NumOps);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, std::vector<MVT> &ResultTys,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, const MVT *VTs, unsigned NumVTs,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2007-10-08 15:49:58 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, SDVTList VTs);
|
|
|
|
SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand N);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand N1, SDOperand N2);
|
2007-10-08 15:49:58 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, SDVTList VTs,
|
|
|
|
SDOperand N1, SDOperand N2, SDOperand N3);
|
|
|
|
SDOperand getNode(unsigned Opcode, SDVTList VTs,
|
|
|
|
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4);
|
|
|
|
SDOperand getNode(unsigned Opcode, SDVTList VTs,
|
|
|
|
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
|
|
|
|
SDOperand N5);
|
2006-08-16 22:57:08 +00:00
|
|
|
SDOperand getNode(unsigned Opcode, SDVTList VTs,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2007-10-19 10:41:11 +00:00
|
|
|
|
Drop ISD::MEMSET, ISD::MEMMOVE, and ISD::MEMCPY, which are not Legal
on any current target and aren't optimized in DAGCombiner. Instead
of using intermediate nodes, expand the operations, choosing between
simple loads/stores, target-specific code, and library calls,
immediately.
Previously, the code to emit optimized code for these operations
was only used at initial SelectionDAG construction time; now it is
used at all times. This fixes some cases where rep;movs was being
used for small copies where simple loads/stores would be better.
This also cleans up code that checks for alignments less than 4;
let the targets make that decision instead of doing it in
target-independent code. This allows x86 to use rep;movs in
low-alignment cases.
Also, this fixes a bug that resulted in the use of rep;stos for
memsets of 0 with non-constant memory size when the alignment was
at least 4. It's better to use the library in this case, which
can be significantly faster when the size is large.
This also preserves more SourceValue information when memory
intrinsics are lowered into simple loads/stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49572 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-12 04:36:06 +00:00
|
|
|
SDOperand getMemcpy(SDOperand Chain, SDOperand Dst, SDOperand Src,
|
|
|
|
SDOperand Size, unsigned Align,
|
|
|
|
bool AlwaysInline,
|
2008-04-28 17:15:20 +00:00
|
|
|
const Value *DstSV, uint64_t DstSVOff,
|
|
|
|
const Value *SrcSV, uint64_t SrcSVOff);
|
2007-10-19 10:41:11 +00:00
|
|
|
|
Drop ISD::MEMSET, ISD::MEMMOVE, and ISD::MEMCPY, which are not Legal
on any current target and aren't optimized in DAGCombiner. Instead
of using intermediate nodes, expand the operations, choosing between
simple loads/stores, target-specific code, and library calls,
immediately.
Previously, the code to emit optimized code for these operations
was only used at initial SelectionDAG construction time; now it is
used at all times. This fixes some cases where rep;movs was being
used for small copies where simple loads/stores would be better.
This also cleans up code that checks for alignments less than 4;
let the targets make that decision instead of doing it in
target-independent code. This allows x86 to use rep;movs in
low-alignment cases.
Also, this fixes a bug that resulted in the use of rep;stos for
memsets of 0 with non-constant memory size when the alignment was
at least 4. It's better to use the library in this case, which
can be significantly faster when the size is large.
This also preserves more SourceValue information when memory
intrinsics are lowered into simple loads/stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49572 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-12 04:36:06 +00:00
|
|
|
SDOperand getMemmove(SDOperand Chain, SDOperand Dst, SDOperand Src,
|
2008-04-23 17:50:15 +00:00
|
|
|
SDOperand Size, unsigned Align,
|
2008-04-28 17:15:20 +00:00
|
|
|
const Value *DstSV, uint64_t DstOSVff,
|
|
|
|
const Value *SrcSV, uint64_t SrcSVOff);
|
2007-10-19 10:41:11 +00:00
|
|
|
|
Drop ISD::MEMSET, ISD::MEMMOVE, and ISD::MEMCPY, which are not Legal
on any current target and aren't optimized in DAGCombiner. Instead
of using intermediate nodes, expand the operations, choosing between
simple loads/stores, target-specific code, and library calls,
immediately.
Previously, the code to emit optimized code for these operations
was only used at initial SelectionDAG construction time; now it is
used at all times. This fixes some cases where rep;movs was being
used for small copies where simple loads/stores would be better.
This also cleans up code that checks for alignments less than 4;
let the targets make that decision instead of doing it in
target-independent code. This allows x86 to use rep;movs in
low-alignment cases.
Also, this fixes a bug that resulted in the use of rep;stos for
memsets of 0 with non-constant memory size when the alignment was
at least 4. It's better to use the library in this case, which
can be significantly faster when the size is large.
This also preserves more SourceValue information when memory
intrinsics are lowered into simple loads/stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49572 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-12 04:36:06 +00:00
|
|
|
SDOperand getMemset(SDOperand Chain, SDOperand Dst, SDOperand Src,
|
|
|
|
SDOperand Size, unsigned Align,
|
2008-04-28 17:15:20 +00:00
|
|
|
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
|
|
|
|
/// have an ISD::CondCode instead of an SDOperand.
|
|
|
|
///
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getSetCC(MVT VT, SDOperand LHS, SDOperand RHS,
|
2005-08-09 20:20:18 +00:00
|
|
|
ISD::CondCode Cond) {
|
|
|
|
return getNode(ISD::SETCC, 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
|
|
|
|
/// if you just have an ISD::CondCode instead of an SDOperand.
|
|
|
|
///
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getVSetCC(MVT VT, SDOperand LHS, SDOperand RHS,
|
2008-05-12 19:40:03 +00:00
|
|
|
ISD::CondCode Cond) {
|
|
|
|
return getNode(ISD::VSETCC, 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
|
|
|
|
/// just have an ISD::CondCode instead of an SDOperand.
|
|
|
|
///
|
|
|
|
SDOperand getSelectCC(SDOperand LHS, SDOperand RHS,
|
|
|
|
SDOperand True, SDOperand False, ISD::CondCode Cond) {
|
2006-08-14 23:31:51 +00:00
|
|
|
return getNode(ISD::SELECT_CC, True.getValueType(), LHS, RHS, True, False,
|
|
|
|
getCondCode(Cond));
|
2005-08-10 20:51:12 +00:00
|
|
|
}
|
2005-08-09 20:20:18 +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.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getVAArg(MVT VT, SDOperand Chain, SDOperand Ptr,
|
2006-01-25 18:21:52 +00:00
|
|
|
SDOperand SV);
|
2005-08-16 19:49:35 +00:00
|
|
|
|
2008-02-21 06:45:13 +00:00
|
|
|
/// getAtomic - Gets a node for an atomic op, produces result and chain, takes
|
2008-06-25 08:15:39 +00:00
|
|
|
/// 3 operands
|
2008-02-21 06:45:13 +00:00
|
|
|
SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr,
|
2008-06-25 16:07:49 +00:00
|
|
|
SDOperand Cmp, SDOperand Swp, const Value* PtrVal,
|
2008-06-25 08:15:39 +00:00
|
|
|
unsigned Alignment=0);
|
2008-02-21 06:45:13 +00:00
|
|
|
|
|
|
|
/// getAtomic - Gets a node for an atomic op, produces result and chain, takes
|
2008-06-25 08:15:39 +00:00
|
|
|
/// 2 operands
|
2008-02-21 06:45:13 +00:00
|
|
|
SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr,
|
2008-06-25 16:07:49 +00:00
|
|
|
SDOperand Val, const Value* PtrVal,
|
2008-06-25 08:15:39 +00:00
|
|
|
unsigned Alignment = 0);
|
2008-02-21 06:45:13 +00:00
|
|
|
|
2008-07-02 17:40:58 +00:00
|
|
|
/// getMergeValues - Create a MERGE_VALUES node from the given operands.
|
|
|
|
/// Allowed to return something different (and simpler) if Simplify is true.
|
2008-07-07 18:26:29 +00:00
|
|
|
SDOperand getMergeValues(const SDOperand *Ops, unsigned NumOps,
|
2008-07-02 17:40:58 +00:00
|
|
|
bool Simplify = true);
|
|
|
|
|
2008-06-30 10:19:09 +00:00
|
|
|
/// getMergeValues - Create a MERGE_VALUES node from the given types and ops.
|
|
|
|
/// Allowed to return something different (and simpler) if Simplify is true.
|
2008-07-02 17:40:58 +00:00
|
|
|
/// May be faster than the above version if VTs is known and NumOps is large.
|
2008-07-07 18:26:29 +00:00
|
|
|
SDOperand getMergeValues(SDVTList VTs, const SDOperand *Ops, unsigned NumOps,
|
2008-06-30 10:19:09 +00:00
|
|
|
bool Simplify = true) {
|
|
|
|
if (Simplify && NumOps == 1)
|
|
|
|
return Ops[0];
|
|
|
|
return getNode(ISD::MERGE_VALUES, VTs, Ops, NumOps);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
///
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getLoad(MVT VT, SDOperand Chain, SDOperand Ptr,
|
2007-04-22 23:15:30 +00:00
|
|
|
const Value *SV, int SVOffset, bool isVolatile=false,
|
|
|
|
unsigned Alignment=0);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT VT,
|
2006-10-09 20:55:20 +00:00
|
|
|
SDOperand Chain, SDOperand Ptr, const Value *SV,
|
2008-06-06 12:08:01 +00:00
|
|
|
int SVOffset, MVT EVT, bool isVolatile=false,
|
2007-04-22 23:15:30 +00:00
|
|
|
unsigned Alignment=0);
|
2006-10-26 21:52:24 +00:00
|
|
|
SDOperand getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
|
2006-11-09 17:55:04 +00:00
|
|
|
SDOperand Offset, ISD::MemIndexedMode AM);
|
2008-03-28 09:45:24 +00:00
|
|
|
SDOperand getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT VT, SDOperand Chain,
|
2008-03-28 09:45:24 +00:00
|
|
|
SDOperand Ptr, SDOperand Offset,
|
2008-06-06 12:08:01 +00:00
|
|
|
const Value *SV, int SVOffset, MVT EVT,
|
2008-03-28 09:45:24 +00:00
|
|
|
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.
|
|
|
|
///
|
2006-11-05 19:31:28 +00:00
|
|
|
SDOperand getStore(SDOperand Chain, SDOperand Val, SDOperand Ptr,
|
2007-04-22 23:15:30 +00:00
|
|
|
const Value *SV, int SVOffset, bool isVolatile=false,
|
|
|
|
unsigned Alignment=0);
|
2006-11-05 19:31:28 +00:00
|
|
|
SDOperand getTruncStore(SDOperand Chain, SDOperand Val, SDOperand Ptr,
|
2008-06-06 12:08:01 +00:00
|
|
|
const Value *SV, int SVOffset, MVT TVT,
|
2007-04-22 23:15:30 +00:00
|
|
|
bool isVolatile=false, unsigned Alignment=0);
|
2006-11-05 09:30:09 +00:00
|
|
|
SDOperand getIndexedStore(SDOperand OrigStoe, SDOperand Base,
|
2006-11-09 17:55:04 +00:00
|
|
|
SDOperand Offset, ISD::MemIndexedMode AM);
|
2006-10-05 22:57:11 +00:00
|
|
|
|
2008-02-06 22:27:42 +00:00
|
|
|
// getSrcValue - Construct a node to track a Value* through the backend.
|
|
|
|
SDOperand getSrcValue(const Value *v);
|
|
|
|
|
|
|
|
// getMemOperand - Construct a node to track a memory reference
|
|
|
|
// through the backend.
|
2008-04-07 19:35:22 +00:00
|
|
|
SDOperand getMemOperand(const MachineMemOperand &MO);
|
2003-08-11 14:56:26 +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.
|
|
|
|
SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op);
|
|
|
|
SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2);
|
|
|
|
SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
|
|
|
|
SDOperand Op3);
|
|
|
|
SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
|
|
|
|
SDOperand Op3, SDOperand Op4);
|
2006-01-28 10:08:58 +00:00
|
|
|
SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
|
|
|
|
SDOperand Op3, SDOperand Op4, SDOperand Op5);
|
2008-07-07 18:26:29 +00:00
|
|
|
SDOperand UpdateNodeOperands(SDOperand N,
|
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
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
|
2005-11-30 22:45:14 +00:00
|
|
|
/// ISD::BUILTIN_OP_END+TargetOpcode in the node opcode field. The 0th value
|
|
|
|
/// of the resultant node is returned.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, SDOperand Op1);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
|
2006-08-26 08:00:10 +00:00
|
|
|
SDOperand Op1, SDOperand Op2);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
|
2006-08-26 08:00:10 +00:00
|
|
|
SDOperand Op1, SDOperand Op2, SDOperand Op3);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *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-07 18:26:29 +00:00
|
|
|
MVT VT2, const SDOperand *Ops, unsigned NumOps);
|
2008-07-02 23:23:19 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
2008-07-07 18:26:29 +00:00
|
|
|
MVT VT2, MVT VT3, const SDOperand *Ops, unsigned NumOps);
|
2008-07-02 23:23:19 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
|
|
|
MVT VT2, SDOperand Op1);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
|
|
|
MVT VT2, SDOperand Op1, SDOperand Op2);
|
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
|
|
|
|
MVT VT2, SDOperand Op1, SDOperand Op2, SDOperand Op3);
|
2008-07-02 23:23:19 +00:00
|
|
|
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2006-08-27 08:08:54 +00:00
|
|
|
|
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.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT, SDOperand Op1);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT, SDOperand Op1, SDOperand Op2);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT,
|
2006-02-09 07:15:23 +00:00
|
|
|
SDOperand Op1, SDOperand Op2, SDOperand Op3);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, SDOperand Op1);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1,
|
|
|
|
MVT VT2, SDOperand Op1, SDOperand Op2);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1,
|
|
|
|
MVT VT2, SDOperand Op1, SDOperand Op2, SDOperand Op3);
|
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3,
|
2006-02-09 07:15:23 +00:00
|
|
|
SDOperand Op1, SDOperand Op2);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3,
|
2007-04-20 21:38:10 +00:00
|
|
|
SDOperand Op1, SDOperand Op2, SDOperand Op3);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, MVT VT4,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2008-06-06 12:08:01 +00:00
|
|
|
SDNode *getTargetNode(unsigned Opcode, std::vector<MVT> &ResultTys,
|
2008-07-07 18:26:29 +00:00
|
|
|
const SDOperand *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-07 18:26:29 +00:00
|
|
|
const SDOperand *Ops, unsigned NumOps);
|
2005-08-17 18:59:17 +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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// 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);
|
|
|
|
|
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
|
|
|
|
/// if you have two nodes with identical results, use the third otherwise.
|
2005-08-17 18:59:17 +00:00
|
|
|
///
|
2008-02-03 06:49:24 +00:00
|
|
|
/// These methods all take an optional UpdateListener, which (if not null) is
|
|
|
|
/// informed about nodes that are deleted and modified due to recursive
|
|
|
|
/// changes in the dag.
|
2005-09-07 05:36:18 +00:00
|
|
|
///
|
|
|
|
void ReplaceAllUsesWith(SDOperand From, SDOperand 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-07 18:26:29 +00:00
|
|
|
void ReplaceAllUsesWith(SDNode *From, const SDOperand *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.
|
2006-02-17 21:57:00 +00:00
|
|
|
void ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To,
|
2008-02-03 06:49:24 +00:00
|
|
|
DAGUpdateListener *UpdateListener = 0);
|
2006-02-17 21:57:00 +00:00
|
|
|
|
2006-08-01 08:20:41 +00:00
|
|
|
/// AssignNodeIds - Assign a unique node id for each node in the DAG based on
|
|
|
|
/// their allnodes order. It returns the maximum id.
|
2006-07-27 07:36:47 +00:00
|
|
|
unsigned AssignNodeIds();
|
2006-07-27 06:38:21 +00:00
|
|
|
|
2006-08-01 08:20:41 +00:00
|
|
|
/// AssignTopologicalOrder - Assign a unique node id for each node in the DAG
|
2006-08-02 21:58:44 +00:00
|
|
|
/// based on their topological order. It returns the maximum id and a vector
|
|
|
|
/// of the SDNodes* in assigned order by reference.
|
|
|
|
unsigned AssignTopologicalOrder(std::vector<SDNode*> &TopOrder);
|
2006-08-01 08:20:41 +00:00
|
|
|
|
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:
|
|
|
|
case ISD::ADDC:
|
|
|
|
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.
|
|
|
|
SDOperand CreateStackTemporary(MVT VT, unsigned minAlign = 1);
|
|
|
|
|
2006-10-14 00:41:01 +00:00
|
|
|
/// FoldSetCC - Constant fold a setcc to true or false.
|
2008-06-06 12:08:01 +00:00
|
|
|
SDOperand FoldSetCC(MVT VT, SDOperand N1,
|
2006-10-14 00:41:01 +00:00
|
|
|
SDOperand N2, ISD::CondCode Cond);
|
|
|
|
|
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.
|
|
|
|
bool SignBitIsZero(SDOperand Op, unsigned Depth = 0) const;
|
|
|
|
|
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-02-25 21:11:39 +00:00
|
|
|
bool MaskedValueIsZero(SDOperand Op, const APInt &Mask, unsigned Depth = 0)
|
2007-06-22 14:59:07 +00:00
|
|
|
const;
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
/// processing. Targets can implement the computeMaskedBitsForTargetNode
|
|
|
|
/// method in the TargetLowering class to allow target nodes to be understood.
|
2008-02-13 22:28:48 +00:00
|
|
|
void ComputeMaskedBits(SDOperand 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.
|
|
|
|
unsigned ComputeNumSignBits(SDOperand Op, unsigned Depth = 0) const;
|
2008-02-02 04:07:54 +00:00
|
|
|
|
|
|
|
/// isVerifiedDebugInfoDesc - Returns true if the specified SDOperand has
|
|
|
|
/// been verified as a debug information descriptor.
|
|
|
|
bool isVerifiedDebugInfoDesc(SDOperand 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.
|
|
|
|
SDOperand getShuffleScalarElt(const SDNode *N, unsigned Idx);
|
2007-06-22 14:59:07 +00:00
|
|
|
|
2005-01-07 21:08:55 +00:00
|
|
|
private:
|
2008-07-07 23:02:41 +00:00
|
|
|
inline alist_traits<SDNode, LargestSDNode>::AllocatorType &getAllocator();
|
2005-08-16 18:16:24 +00:00
|
|
|
void RemoveNodeFromCSEMaps(SDNode *N);
|
2005-08-17 18:59:17 +00:00
|
|
|
SDNode *AddNonLeafNodeToCSEMaps(SDNode *N);
|
2006-08-07 23:03:03 +00:00
|
|
|
SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op, void *&InsertPos);
|
|
|
|
SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op1, SDOperand Op2,
|
|
|
|
void *&InsertPos);
|
2008-07-07 18:26:29 +00:00
|
|
|
SDNode *FindModifiedNodeSlot(SDNode *N, const SDOperand *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);
|
2008-07-08 23:46:32 +00:00
|
|
|
|
|
|
|
unsigned getMVTAlignment(MVT MemoryVT) const;
|
2005-08-09 20:20:18 +00:00
|
|
|
|
2005-11-08 23:30:11 +00:00
|
|
|
// List of non-single value types.
|
2008-06-06 12:08:01 +00:00
|
|
|
std::list<std::vector<MVT> > VTList;
|
2005-11-08 23:30:11 +00:00
|
|
|
|
2005-01-14 22:07:46 +00:00
|
|
|
// 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-06-23 21:08:32 +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
|