#ifndef LLVM_CODEGEN_SELECTIONDAG_H
#define LLVM_CODEGEN_SELECTIONDAG_H
-#include "llvm/CodeGen/SelectionDAGCSEMap.h"
+#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/ilist"
+#include "llvm/CodeGen/SelectionDAGNodes.h"
#include <list>
#include <vector>
#include <string>
namespace llvm {
+ class AliasAnalysis;
class TargetLowering;
class TargetMachine;
- class MachineDebugInfo;
+ class MachineModuleInfo;
class MachineFunction;
class MachineConstantPoolValue;
class SelectionDAG {
TargetLowering &TLI;
MachineFunction &MF;
- MachineDebugInfo *DI;
+ MachineModuleInfo *MMI;
/// Root - The root of the entire DAG. EntryNode - The starting token.
SDOperand Root, EntryNode;
/// CSEMap - This structure is used to memoize nodes, automatically performing
/// CSE with existing nodes with a duplicate is requested.
- SelectionDAGCSEMap CSEMap;
+ FoldingSet<SDNode> CSEMap;
public:
- SelectionDAG(TargetLowering &tli, MachineFunction &mf, MachineDebugInfo *di)
- : TLI(tli), MF(mf), DI(di) {
+ SelectionDAG(TargetLowering &tli, MachineFunction &mf, MachineModuleInfo *mmi)
+ : TLI(tli), MF(mf), MMI(mmi) {
EntryNode = Root = getNode(ISD::EntryToken, MVT::Other);
}
~SelectionDAG();
MachineFunction &getMachineFunction() const { return MF; }
const TargetMachine &getTarget() const;
TargetLowering &getTargetLoweringInfo() const { return TLI; }
- MachineDebugInfo *getMachineDebugInfo() const { return DI; }
+ MachineModuleInfo *getMachineModuleInfo() const { return MMI; }
/// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
///
/// 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.
- void Combine(bool AfterLegalize);
+ void Combine(bool AfterLegalize, AliasAnalysis &AA);
/// Legalize - This transforms the SelectionDAG into a SelectionDAG that is
/// compatible with the target instruction selector, as indicated by the
/// RemoveDeadNodes - This method deletes all unreachable nodes in the
/// SelectionDAG.
void RemoveDeadNodes();
+
+ /// RemoveDeadNode - Remove the specified node from the system. If any of its
+ /// operands then becomes dead, remove them as well. The vector Deleted is
+ /// populated with nodes that are deleted.
+ void RemoveDeadNode(SDNode *N, std::vector<SDNode*> &Deleted);
+ /// DeleteNode - Remove the specified node from the system. This node must
+ /// have no referrers.
+ void DeleteNode(SDNode *N);
+
/// getVTList - Return an SDVTList that represents the list of values
/// specified.
SDVTList getVTList(MVT::ValueType VT);
/// determined by their operands, and they produce a value AND a token chain.
///
SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
- const Value *SV, int SVOffset, bool isVolatile=false);
+ const Value *SV, int SVOffset, bool isVolatile=false,
+ unsigned Alignment=0);
SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
SDOperand Chain, SDOperand Ptr, const Value *SV,
- int SVOffset, MVT::ValueType EVT, bool isVolatile=false);
+ int SVOffset, MVT::ValueType EVT, bool isVolatile=false,
+ unsigned Alignment=0);
+ SDOperand getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
+ SDOperand Offset, ISD::MemIndexedMode AM);
SDOperand getVecLoad(unsigned Count, MVT::ValueType VT, SDOperand Chain,
SDOperand Ptr, SDOperand SV);
/// getStore - Helper function to build ISD::STORE nodes.
///
- SDOperand getStore(SDOperand Chain, SDOperand Value, SDOperand Ptr,
- SDOperand SV);
+ SDOperand getStore(SDOperand Chain, SDOperand Val, SDOperand Ptr,
+ const Value *SV, int SVOffset, bool isVolatile=false,
+ unsigned Alignment=0);
+ SDOperand getTruncStore(SDOperand Chain, SDOperand Val, SDOperand Ptr,
+ const Value *SV, int SVOffset, MVT::ValueType TVT,
+ bool isVolatile=false, unsigned Alignment=0);
+ SDOperand getIndexedStore(SDOperand OrigStoe, SDOperand Base,
+ SDOperand Offset, ISD::MemIndexedMode AM);
// getSrcValue - construct a node to track a Value* through the backend
SDOperand getSrcValue(const Value* I, int offset = 0);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3,
SDOperand Op1, SDOperand Op2);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, MVT::ValueType VT3,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3,
const SDOperand *Ops, unsigned NumOps);
void ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To,
std::vector<SDNode*> &Deleted);
- /// DeleteNode - Remove the specified node from the system. This node must
- /// have no referrers.
- void DeleteNode(SDNode *N);
-
/// AssignNodeIds - Assign a unique node id for each node in the DAG based on
/// their allnodes order. It returns the maximum id.
unsigned AssignNodeIds();
void dump() const;
+ /// FoldSetCC - Constant fold a setcc to true or false.
+ SDOperand FoldSetCC(MVT::ValueType VT, SDOperand N1,
+ SDOperand N2, ISD::CondCode Cond);
+
private:
void RemoveNodeFromCSEMaps(SDNode *N);
SDNode *AddNonLeafNodeToCSEMaps(SDNode *N);
void DeleteNodeNotInCSEMaps(SDNode *N);
- /// SimplifySetCC - Try to simplify a setcc built with the specified operands
- /// and cc. If unable to simplify it, return a null SDOperand.
- SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N1,
- SDOperand N2, ISD::CondCode Cond);
-
// List of non-single value types.
std::list<std::vector<MVT::ValueType> > VTList;