summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-07 19:24:15 +0000
committerChris Lattner <sabre@nondot.org>2001-07-07 19:24:15 +0000
commita41f50dea8573e4a610b5aa5e45b5c368559b084 (patch)
tree4e4bc17fa7fffd16e0f99e9229015ca6654ef802 /lib
parent30f24a402c27919e4809f6a54ec4046a921a889f (diff)
downloadllvm-a41f50dea8573e4a610b5aa5e45b5c368559b084.tar.gz
llvm-a41f50dea8573e4a610b5aa5e45b5c368559b084.tar.bz2
llvm-a41f50dea8573e4a610b5aa5e45b5c368559b084.tar.xz
Broad superficial changes:
* Renamed getOpcode to getOpcodeName * Changed getOpcodeName to return a const char * instead of string * Added a getOpcode method to replace getInstType * Changed code to use getOpcode instead of getInstType git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AsmParser/ParserInternals.h2
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h2
-rw-r--r--lib/Bytecode/Writer/InstructionWriter.cpp14
-rw-r--r--lib/Transforms/IPO/InlineSimple.cpp8
-rw-r--r--lib/Transforms/Scalar/ConstantProp.cpp6
-rw-r--r--lib/Transforms/Scalar/InductionVars.cpp8
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp8
-rw-r--r--lib/Transforms/Utils/UnifyFunctionExitNodes.cpp2
-rw-r--r--lib/VMCore/AsmWriter.cpp14
-rw-r--r--lib/VMCore/iOperators.cpp36
10 files changed, 53 insertions, 47 deletions
diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h
index 3aa0e7c144..bd26fdbaaf 100644
--- a/lib/AsmParser/ParserInternals.h
+++ b/lib/AsmParser/ParserInternals.h
@@ -118,7 +118,7 @@ struct InstPlaceHolderHelper : public Instruction {
InstPlaceHolderHelper(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
virtual Instruction *clone() const { abort(); }
- virtual string getOpcode() const { return "placeholder"; }
+ virtual const char *getOpcodeName() const { return "placeholder"; }
};
struct BBPlaceHolderHelper : public BasicBlock {
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index fffcdb83c7..c73b6c06e7 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -94,7 +94,7 @@ public:
struct InstPlaceHolderHelper : public Instruction {
InstPlaceHolderHelper(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
- virtual string getOpcode() const { return "placeholder"; }
+ virtual const char *getOpcodeName() const { return "placeholder"; }
virtual Instruction *clone() const { abort(); return 0; }
};
diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp
index 0cd93c04fd..3bd9a0902b 100644
--- a/lib/Bytecode/Writer/InstructionWriter.cpp
+++ b/lib/Bytecode/Writer/InstructionWriter.cpp
@@ -29,7 +29,7 @@ static void outputInstructionFormat0(const Instruction *I,
const SlotCalculator &Table,
unsigned Type, vector<uchar> &Out) {
// Opcode must have top two bits clear...
- output_vbr(I->getInstType(), Out); // Instruction Opcode ID
+ output_vbr(I->getOpcode(), Out); // Instruction Opcode ID
output_vbr(Type, Out); // Result type
unsigned NumArgs = I->getNumOperands();
@@ -51,7 +51,7 @@ static void outputInstructionFormat0(const Instruction *I,
static void outputInstructionFormat1(const Instruction *I,
const SlotCalculator &Table, int *Slots,
unsigned Type, vector<uchar> &Out) {
- unsigned IType = I->getInstType(); // Instruction Opcode ID
+ unsigned IType = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
// --------------------------
@@ -72,7 +72,7 @@ static void outputInstructionFormat1(const Instruction *I,
static void outputInstructionFormat2(const Instruction *I,
const SlotCalculator &Table, int *Slots,
unsigned Type, vector<uchar> &Out) {
- unsigned IType = I->getInstType(); // Instruction Opcode ID
+ unsigned IType = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
// --------------------------
@@ -96,7 +96,7 @@ static void outputInstructionFormat2(const Instruction *I,
static void outputInstructionFormat3(const Instruction *I,
const SlotCalculator &Table, int *Slots,
unsigned Type, vector<uchar> &Out) {
- unsigned IType = I->getInstType(); // Instruction Opcode ID
+ unsigned IType = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
// --------------------------
@@ -115,7 +115,7 @@ static void outputInstructionFormat3(const Instruction *I,
}
bool BytecodeWriter::processInstruction(const Instruction *I) {
- assert(I->getInstType() < 64 && "Opcode too big???");
+ assert(I->getOpcode() < 64 && "Opcode too big???");
unsigned NumOperands = I->getNumOperands();
int MaxOpSlot = 0;
@@ -136,8 +136,8 @@ bool BytecodeWriter::processInstruction(const Instruction *I) {
// we take the type of the instruction itself.
//
const Type *Ty = NumOperands ? I->getOperand(0)->getType() : I->getType();
- if (I->getInstType() == Instruction::Malloc ||
- I->getInstType() == Instruction::Alloca)
+ if (I->getOpcode() == Instruction::Malloc ||
+ I->getOpcode() == Instruction::Alloca)
Ty = I->getType(); // Malloc & Alloca ALWAYS want to encode the return type
unsigned Type;
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index de76dcd52d..b7cefacaf3 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -63,7 +63,7 @@ static inline void RemapInstruction(Instruction *I,
// method by one level.
//
bool opt::InlineMethod(BasicBlock::iterator CIIt) {
- assert((*CIIt)->getInstType() == Instruction::Call &&
+ assert((*CIIt)->getOpcode() == Instruction::Call &&
"InlineMethod only works on CallInst nodes!");
assert((*CIIt)->getParent() && "Instruction not embedded in basic block!");
assert((*CIIt)->getParent()->getParent() && "Instruction not in method!");
@@ -149,7 +149,7 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) {
}
// Copy over the terminator now...
- switch (TI->getInstType()) {
+ switch (TI->getOpcode()) {
case Instruction::Ret: {
const ReturnInst *RI = (const ReturnInst*)TI;
@@ -209,7 +209,7 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) {
// block of the inlined method.
//
TerminatorInst *Br = OrigBB->getTerminator();
- assert(Br && Br->getInstType() == Instruction::Br &&
+ assert(Br && Br->getOpcode() == Instruction::Br &&
"splitBasicBlock broken!");
Br->setOperand(0, ValueMap[CalledMeth->front()]);
@@ -249,7 +249,7 @@ static inline bool ShouldInlineMethod(const CallInst *CI, const Method *M) {
static inline bool DoMethodInlining(BasicBlock *BB) {
for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
- if ((*I)->getInstType() == Instruction::Call) {
+ if ((*I)->getOpcode() == Instruction::Call) {
// Check to see if we should inline this method
CallInst *CI = (CallInst*)*I;
Method *M = CI->getCalledMethod();
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index 91a21c3c6b..f6b76c9aa0 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -73,7 +73,7 @@ inline static bool
ConstantFoldUnaryInst(Method *M, Method::inst_iterator &DI,
UnaryOperator *Op, ConstPoolVal *D) {
ConstPoolVal *ReplaceWith =
- opt::ConstantFoldUnaryInstruction(Op->getInstType(), D);
+ opt::ConstantFoldUnaryInstruction(Op->getOpcode(), D);
if (!ReplaceWith) return false; // Nothing new to change...
@@ -100,7 +100,7 @@ ConstantFoldBinaryInst(Method *M, Method::inst_iterator &DI,
BinaryOperator *Op,
ConstPoolVal *D1, ConstPoolVal *D2) {
ConstPoolVal *ReplaceWith =
- opt::ConstantFoldBinaryInstruction(Op->getInstType(), D1, D2);
+ opt::ConstantFoldBinaryInstruction(Op->getOpcode(), D1, D2);
if (!ReplaceWith) return false; // Nothing new to change...
// Add the new value to the constant pool...
@@ -126,7 +126,7 @@ ConstantFoldBinaryInst(Method *M, Method::inst_iterator &DI,
//
bool opt::ConstantFoldTerminator(TerminatorInst *T) {
// Branch - See if we are conditional jumping on constant
- if (T->getInstType() == Instruction::Br) {
+ if (T->getOpcode() == Instruction::Br) {
BranchInst *BI = (BranchInst*)T;
if (BI->isUnconditional()) return false; // Can't optimize uncond branch
BasicBlock *Dest1 = BI->getOperand(0)->castBasicBlockAsserting();
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp
index b39a523f59..c59a441fad 100644
--- a/lib/Transforms/Scalar/InductionVars.cpp
+++ b/lib/Transforms/Scalar/InductionVars.cpp
@@ -78,7 +78,7 @@ static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V,
// loop variant computations must be instructions!
Instruction *I = V->castInstructionAsserting();
- switch (I->getInstType()) { // Handle each instruction seperately
+ switch (I->getOpcode()) { // Handle each instruction seperately
case Instruction::Neg: {
Value *SubV = ((UnaryOperator*)I)->getOperand(0);
LIVType SubLIVType = isLinearInductionVariableH(Int, SubV, PN);
@@ -107,12 +107,12 @@ static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V,
// either a Loop Invariant computation, or a LIV type.
if (SubLIVType1 == isLIC) {
// Loop invariant computation, we know this is a LIV then.
- return (I->getInstType() == Instruction::Add) ?
+ return (I->getOpcode() == Instruction::Add) ?
SubLIVType2 : neg(SubLIVType2);
}
// If the LHS is also a LIV Expression, we cannot add two LIVs together
- if (I->getInstType() == Instruction::Add) return isOther;
+ if (I->getOpcode() == Instruction::Add) return isOther;
// We can only subtract two LIVs if they are the same type, which yields
// a LIC, because the LIVs cancel each other out.
@@ -155,7 +155,7 @@ static inline bool isSimpleInductionVar(PHINode *PN) {
Value *StepExpr = PN->getIncomingValue(1);
if (!StepExpr->isInstruction() ||
- ((Instruction*)StepExpr)->getInstType() != Instruction::Add)
+ ((Instruction*)StepExpr)->getOpcode() != Instruction::Add)
return false;
BinaryOperator *I = (BinaryOperator*)StepExpr;
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 5bb75c7008..43eb26fd30 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -307,7 +307,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
if (IValue.isOverdefined())
return; // If already overdefined, we aren't going to effect anything
- switch (I->getInstType()) {
+ switch (I->getOpcode()) {
//===-----------------------------------------------------------------===//
// Handle PHI nodes...
//
@@ -424,7 +424,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
}
default: break; // Handle math operators as groups.
- } // end switch(I->getInstType())
+ } // end switch(I->getOpcode())
//===-------------------------------------------------------------------===//
@@ -437,7 +437,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
markOverdefined(I);
} else if (VState.isConstant()) { // Propogate constant value
ConstPoolVal *Result =
- opt::ConstantFoldUnaryInstruction(I->getInstType(),
+ opt::ConstantFoldUnaryInstruction(I->getOpcode(),
VState.getConstant());
if (Result) {
@@ -466,7 +466,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
markOverdefined(I);
} else if (V1State.isConstant() && V2State.isConstant()) {
ConstPoolVal *Result =
- opt::ConstantFoldBinaryInstruction(I->getInstType(),
+ opt::ConstantFoldBinaryInstruction(I->getOpcode(),
V1State.getConstant(),
V2State.getConstant());
if (Result) {
diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
index 0217ce0eab..ab600bd151 100644
--- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
+++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
@@ -25,7 +25,7 @@ BasicBlock *cfg::UnifyAllExitNodes(Method *M) {
// return.
//
for(Method::iterator I = M->begin(), E = M->end(); I != E; ++I)
- if ((*I)->getTerminator()->getInstType() == Instruction::Ret)
+ if ((*I)->getTerminator()->getOpcode() == Instruction::Ret)
ReturningBlocks.push_back(*I);
if (ReturningBlocks.size() == 0)
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index e2b2495605..398f7a87b8 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -154,20 +154,20 @@ bool AssemblyWriter::processInstruction(const Instruction *I) {
Out << "%" << I->getName() << " = ";
// Print out the opcode...
- Out << I->getOpcode();
+ Out << I->getOpcodeName();
// Print out the type of the operands...
const Value *Operand = I->getNumOperands() ? I->getOperand(0) : 0;
// Special case conditional branches to swizzle the condition out to the front
- if (I->getInstType() == Instruction::Br && I->getNumOperands() > 1) {
+ if (I->getOpcode() == Instruction::Br && I->getNumOperands() > 1) {
writeOperand(I->getOperand(2), true);
Out << ",";
writeOperand(Operand, true);
Out << ",";
writeOperand(I->getOperand(1), true);
- } else if (I->getInstType() == Instruction::Switch) {
+ } else if (I->getOpcode() == Instruction::Switch) {
// Special case switch statement to get formatting nice and correct...
writeOperand(Operand , true); Out << ",";
writeOperand(I->getOperand(1), true); Out << " [";
@@ -188,9 +188,9 @@ bool AssemblyWriter::processInstruction(const Instruction *I) {
writeOperand(I->getOperand(op ), false); Out << ",";
writeOperand(I->getOperand(op+1), false); Out << " ]";
}
- } else if (I->getInstType() == Instruction::Ret && !Operand) {
+ } else if (I->getOpcode() == Instruction::Ret && !Operand) {
Out << " void";
- } else if (I->getInstType() == Instruction::Call) {
+ } else if (I->getOpcode() == Instruction::Call) {
writeOperand(Operand, true);
Out << "(";
if (I->getNumOperands() > 1) writeOperand(I->getOperand(1), true);
@@ -200,8 +200,8 @@ bool AssemblyWriter::processInstruction(const Instruction *I) {
}
Out << " )";
- } else if (I->getInstType() == Instruction::Malloc ||
- I->getInstType() == Instruction::Alloca) {
+ } else if (I->getOpcode() == Instruction::Malloc ||
+ I->getOpcode() == Instruction::Alloca) {
Out << " " << ((const PointerType*)I->getType())->getValueType();
if (I->getNumOperands()) {
Out << ",";
diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp
index c1efb42e71..ef6933adb2 100644
--- a/lib/VMCore/iOperators.cpp
+++ b/lib/VMCore/iOperators.cpp
@@ -10,25 +10,31 @@
BinaryOperator *BinaryOperator::create(unsigned Op, Value *S1, Value *S2,
const string &Name) {
switch (Op) {
- // Standard binary operators...
- case Add: return new GenericBinaryInst(Op, S1, S2, "add", Name);
- case Sub: return new GenericBinaryInst(Op, S1, S2, "sub", Name);
- case Mul: return new GenericBinaryInst(Op, S1, S2, "mul", Name);
- case Div: return new GenericBinaryInst(Op, S1, S2, "div", Name);
- case Rem: return new GenericBinaryInst(Op, S1, S2, "rem", Name);
-
- // Logical operators...
- case And: return new GenericBinaryInst(Op, S1, S2, "and", Name);
- case Or : return new GenericBinaryInst(Op, S1, S2, "or", Name);
- case Xor: return new GenericBinaryInst(Op, S1, S2, "xor", Name);
-
// Binary comparison operators...
case SetLT: case SetGT: case SetLE:
case SetGE: case SetEQ: case SetNE:
return new SetCondInst((BinaryOps)Op, S1, S2, Name);
default:
- cerr << "Don't know how to GetBinaryOperator " << Op << endl;
+ return new GenericBinaryInst(Op, S1, S2, Name);
+ }
+}
+
+const char *GenericBinaryInst::getOpcodeName() const {
+ switch (getOpcode()) {
+ // Standard binary operators...
+ case Add: return "add";
+ case Sub: return "sub";
+ case Mul: return "mul";
+ case Div: return "div";
+ case Rem: return "rem";
+
+ // Logical operators...
+ case And: return "and";
+ case Or : return "or";
+ case Xor: return "xor";
+ default:
+ cerr << "Invalid binary operator type!" << getOpcode() << endl;
return 0;
}
}
@@ -45,10 +51,10 @@ SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2,
setType(Type::BoolTy); // setcc instructions always return bool type.
// Make sure it's a valid type...
- assert(getOpcode() != "Invalid opcode type to SetCondInst class!");
+ assert(getOpcodeName() != 0);
}
-string SetCondInst::getOpcode() const {
+const char *SetCondInst::getOpcodeName() const {
switch (OpType) {
case SetLE: return "setle";
case SetGE: return "setge";