summaryrefslogtreecommitdiff
path: root/lib/VMCore
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/VMCore
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/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp14
-rw-r--r--lib/VMCore/iOperators.cpp36
2 files changed, 28 insertions, 22 deletions
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";