[llvm-commits] CVS: llvm/lib/CodeGen/Selection/DAGBuilder.cpp SelectionDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Aug 14 23:54:01 PDT 2003
Changes in directory llvm/lib/CodeGen/Selection:
DAGBuilder.cpp updated: 1.1 -> 1.2
SelectionDAG.cpp updated: 1.1 -> 1.2
---
Log message:
Add a bunch of new node types, etc
---
Diffs of the changes:
Index: llvm/lib/CodeGen/Selection/DAGBuilder.cpp
diff -u llvm/lib/CodeGen/Selection/DAGBuilder.cpp:1.1 llvm/lib/CodeGen/Selection/DAGBuilder.cpp:1.2
--- llvm/lib/CodeGen/Selection/DAGBuilder.cpp:1.1 Mon Aug 11 09:57:33 2003
+++ llvm/lib/CodeGen/Selection/DAGBuilder.cpp Thu Aug 14 23:53:16 2003
@@ -6,25 +6,31 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
-#include "llvm/Support/InstVisitor.h"
+#include "llvm/Type.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/Type.h"
-#include "llvm/Constants.h"
+#include "llvm/Support/InstVisitor.h"
struct SelectionDAGBuilder : public InstVisitor<SelectionDAGBuilder> {
// DAG - the current dag we are building.
SelectionDAG &DAG;
+ // SDTB - The target-specific builder interface, which indicates how to expand
+ // extremely target-specific aspects of the representation, such as function
+ // calls and arguments.
+ SelectionDAGTargetBuilder &SDTB;
+
// BB - The current machine basic block we are working on.
MachineBasicBlock *BB;
// CurRoot - The root built for the current basic block.
SelectionDAGNode *CurRoot;
- SelectionDAGBuilder(SelectionDAG &dag) : DAG(dag), BB(0), CurRoot(0) {}
+ SelectionDAGBuilder(SelectionDAG &dag, SelectionDAGTargetBuilder &sdtb)
+ : DAG(dag), SDTB(sdtb), BB(0), CurRoot(0) {}
void visitBB(BasicBlock &bb);
@@ -33,14 +39,21 @@
void visitAdd(BinaryOperator &BO);
void visitSub(BinaryOperator &BO);
void visitMul(BinaryOperator &BO);
- void visitRet(ReturnInst &RI);
void visitAnd(BinaryOperator &BO);
void visitOr (BinaryOperator &BO);
void visitXor(BinaryOperator &BO);
+ void visitSetEQ(BinaryOperator &BO);
+
+ void visitLoad(LoadInst &LI);
+ void visitCall(CallInst &CI);
+
+ void visitBr(BranchInst &BI);
+ void visitRet(ReturnInst &RI);
+
void visitInstruction(Instruction &I) {
- std::cerr << "Instruction Selection cannot select: " << I;
+ std::cerr << "DAGBuilder: Cannot instruction select: " << I;
abort();
}
@@ -116,6 +129,10 @@
Entry->addValue(new ReducedValue_Constant_f64(CFP->getValue()));
}
if (Entry) return Entry;
+ } else if (BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
+ Entry = new SelectionDAGNode(ISD::BasicBlock, ValueType);
+ Entry->addValue(new ReducedValue_BasicBlock_i32(DAG.BlockMap[BB]));
+ return Entry;
}
std::cerr << "Unhandled LLVM value in DAG Builder!: " << *V << "\n";
@@ -144,9 +161,9 @@
else {
// The previous basic block AND this basic block had roots, insert a
// block chain node now...
- CurRoot = DAG.addNode(new SelectionDAGNode(ISD::BlockChainNode,
- MVT::isVoid,
- BB, OldRoot, CurRoot));
+ CurRoot = DAG.addNode(new SelectionDAGNode(ISD::BlockChainNode,
+ MVT::isVoid,
+ BB, OldRoot, CurRoot));
}
}
}
@@ -180,6 +197,11 @@
getNodeFor(BO)->setNode(ISD::Xor, BB, getNodeFor(BO.getOperand(0)),
getNodeFor(BO.getOperand(1)));
}
+void SelectionDAGBuilder::visitSetEQ(BinaryOperator &BO) {
+ getNodeFor(BO)->setNode(ISD::SetEQ, BB, getNodeFor(BO.getOperand(0)),
+ getNodeFor(BO.getOperand(1)));
+}
+
void SelectionDAGBuilder::visitRet(ReturnInst &RI) {
if (RI.getNumOperands()) { // Value return
@@ -191,9 +213,30 @@
}
+void SelectionDAGBuilder::visitBr(BranchInst &BI) {
+ if (BI.isUnconditional())
+ addSeqNode(new SelectionDAGNode(ISD::Br, MVT::isVoid, BB,
+ getNodeFor(BI.getOperand(0))));
+ else
+ addSeqNode(new SelectionDAGNode(ISD::BrCond, MVT::isVoid, BB,
+ getNodeFor(BI.getCondition()),
+ getNodeFor(BI.getSuccessor(0)),
+ getNodeFor(BI.getSuccessor(1))));
+}
+
+
+void SelectionDAGBuilder::visitLoad(LoadInst &LI) {
+ // FIXME: this won't prevent reordering of loads!
+ getNodeFor(LI)->setNode(ISD::Load, BB, getNodeFor(LI.getOperand(0)));
+}
+
+void SelectionDAGBuilder::visitCall(CallInst &CI) {
+ SDTB.expandCall(DAG, CI);
+}
+
-// SelectionDAG constructor - Just use the SeelectionDAGBuilder to do all of the
+// SelectionDAG constructor - Just use the SelectionDAGBuilder to do all of the
// dirty work...
SelectionDAG::SelectionDAG(MachineFunction &f, const TargetMachine &tm,
SelectionDAGTargetBuilder &SDTB)
@@ -213,9 +256,9 @@
for (Function::const_iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
F.getBasicBlockList().push_back(BlockMap[I] = new MachineBasicBlock(I));
- SDTB.expandArguments(*this, f);
+ SDTB.expandArguments(*this);
- SelectionDAGBuilder SDB(*this);
+ SelectionDAGBuilder SDB(*this, SDTB);
for (Function::const_iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
SDB.visitBB(const_cast<BasicBlock&>(*I));
Root = SDB.CurRoot;
Index: llvm/lib/CodeGen/Selection/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/Selection/SelectionDAG.cpp:1.1 llvm/lib/CodeGen/Selection/SelectionDAG.cpp:1.2
--- llvm/lib/CodeGen/Selection/SelectionDAG.cpp:1.1 Mon Aug 11 09:57:33 2003
+++ llvm/lib/CodeGen/Selection/SelectionDAG.cpp Thu Aug 14 23:53:16 2003
@@ -37,6 +37,7 @@
case Type::ULongTyID: return MVT::i64;
case Type::FloatTyID: return MVT::f32;
case Type::DoubleTyID: return MVT::f64;
+ case Type::LabelTyID:
case Type::PointerTyID: return PointerType;
}
}
@@ -79,8 +80,11 @@
case ISD::ChainNode: std::cerr << "ChainNode"; break;
case ISD::BlockChainNode: std::cerr << "BlockChainNode"; break;
case ISD::ProtoNode: std::cerr << "ProtoNode"; break;
+
case ISD::Constant: std::cerr << "Constant"; break;
case ISD::FrameIndex: std::cerr << "FrameIndex"; break;
+ case ISD::BasicBlock: std::cerr << "BasicBlock"; break;
+
case ISD::Plus: std::cerr << "Plus"; break;
case ISD::Minus: std::cerr << "Minus"; break;
case ISD::Times: std::cerr << "Times"; break;
@@ -91,7 +95,16 @@
case ISD::And: std::cerr << "And"; break;
case ISD::Or: std::cerr << "Or"; break;
case ISD::Xor: std::cerr << "Xor"; break;
+
+ case ISD::SetEQ: std::cerr << "SetEQ"; break;
+ case ISD::SetNE: std::cerr << "SetNE"; break;
+ case ISD::SetLT: std::cerr << "SetLT"; break;
+ case ISD::SetLE: std::cerr << "SetLE"; break;
+ case ISD::SetGT: std::cerr << "SetGT"; break;
+ case ISD::SetGE: std::cerr << "SetGE"; break;
+
case ISD::Br: std::cerr << "Br"; break;
+ case ISD::BrCond: std::cerr << "BrCond"; break;
case ISD::Switch: std::cerr << "Switch"; break;
case ISD::Ret: std::cerr << "Ret"; break;
case ISD::RetVoid: std::cerr << "RetVoid"; break;
@@ -99,6 +112,9 @@
case ISD::Store: std::cerr << "Store"; break;
case ISD::PHI: std::cerr << "PHI"; break;
case ISD::Call: std::cerr << "Call"; break;
+
+ case ISD::Unspec1: std::cerr << "Unspec1"; break;
+ case ISD::Unspec2: std::cerr << "Unspec2"; break;
}
std::cerr << "\n";
More information about the llvm-commits
mailing list