diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-04-13 18:34:38 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-04-13 18:34:38 +0000 |
| commit | 8d48df2ebc54b5b4a63b2568213ab8cfbec0ebbb (patch) | |
| tree | b32f166ad862c75ea87fdda36c3ba6ec620e1c18 | |
| parent | fda0035ec9e5eaef910c2b7de8b8324225cf67cf (diff) | |
| download | bcm5719-llvm-8d48df2ebc54b5b4a63b2568213ab8cfbec0ebbb.tar.gz bcm5719-llvm-8d48df2ebc54b5b4a63b2568213ab8cfbec0ebbb.zip | |
* Clean up code to use isa & dyncast instead of poking directly into instructions
* Do not print the allocation size for a non array allocation (this used to work,
but was broken).
llvm-svn: 2235
| -rw-r--r-- | llvm/lib/VMCore/AsmWriter.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index f5e0fcfa922..aa11d81f27e 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -508,14 +508,14 @@ void AssemblyWriter::printInstruction(const Instruction *I) { const Value *Operand = I->getNumOperands() ? I->getOperand(0) : 0; // Special case conditional branches to swizzle the condition out to the front - if (I->getOpcode() == Instruction::Br && I->getNumOperands() > 1) { + if (isa<BranchInst>(I) && I->getNumOperands() > 1) { writeOperand(I->getOperand(2), true); Out << ","; writeOperand(Operand, true); Out << ","; writeOperand(I->getOperand(1), true); - } else if (I->getOpcode() == Instruction::Switch) { + } else if (isa<SwitchInst>(I)) { // Special case switch statement to get formatting nice and correct... writeOperand(Operand , true); Out << ","; writeOperand(I->getOperand(1), true); Out << " ["; @@ -548,8 +548,9 @@ void AssemblyWriter::printInstruction(const Instruction *I) { // only do this if the first argument is a pointer to a nonvararg function, // and if the value returned is not a pointer to a function. // - if (RetTy && !MTy->isVarArg() && - (!isa<PointerType>(RetTy)||!isa<FunctionType>(cast<PointerType>(RetTy)))){ + if (RetTy && MTy && !MTy->isVarArg() && + (!isa<PointerType>(RetTy) || + !isa<FunctionType>(cast<PointerType>(RetTy)))) { Out << " "; printType(RetTy); writeOperand(Operand, false); } else { @@ -578,13 +579,12 @@ void AssemblyWriter::printInstruction(const Instruction *I) { Out << " except"; writeOperand(II->getExceptionalDest(), true); - } else if (I->getOpcode() == Instruction::Malloc || - I->getOpcode() == Instruction::Alloca) { + } else if (const AllocationInst *AI = dyn_cast<AllocationInst>(I)) { Out << " "; - printType(cast<const PointerType>(I->getType())->getElementType()); - if (I->getNumOperands()) { + printType(AI->getType()->getElementType()); + if (AI->isArrayAllocation()) { Out << ","; - writeOperand(I->getOperand(0), true); + writeOperand(AI->getArraySize(), true); } } else if (isa<CastInst>(I)) { writeOperand(Operand, true); |

