#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/ADT/Statistic.h"
#include <algorithm>
using namespace llvm;
namespace {
- Statistic NumLowered("lowerswitch", "Number of SwitchInst's replaced");
-
/// LowerSwitch Pass - Replace all SwitchInst instructions with chained branch
/// instructions. Note that this cannot be a BasicBlock pass because it
/// modifies the CFG!
// operator<< - Used for debugging purposes.
//
-llvm_ostream& operator<<(llvm_ostream &O,
+std::ostream& operator<<(std::ostream &O,
const std::vector<LowerSwitch::Case> &C) {
O << "[";
return O << "]";
}
+OStream& operator<<(OStream &O, const std::vector<LowerSwitch::Case> &C) {
+ if (O.stream()) *O.stream() << C;
+ return O;
+}
// switchConvert - Convert the switch statement into a binary lookup of
// the case values. The function recursively builds this tree.
BasicBlock* NewNode = new BasicBlock("NodeBlock");
F->getBasicBlockList().insert(OrigBlock->getNext(), NewNode);
- SetCondInst* Comp = new SetCondInst(Instruction::SetLT, Val, Pivot.first,
- "Pivot");
+ ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_ULT, Val, Pivot.first, "Pivot");
NewNode->getInstList().push_back(Comp);
new BranchInst(LBranch, RBranch, Comp, NewNode);
return NewNode;
F->getBasicBlockList().insert(OrigBlock->getNext(), NewLeaf);
// Make the seteq instruction...
- SetCondInst* Comp = new SetCondInst(Instruction::SetEQ, Val,
- Leaf.first, "SwitchLeaf");
+ ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_EQ, Val,
+ Leaf.first, "SwitchLeaf");
NewLeaf->getInstList().push_back(Comp);
// Make the conditional branch...