#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
#include "llvm/SymbolTable.h"
+#include "llvm/Support/CFG.h"
#include "Support/StringExtras.h"
#include "Support/STLExtras.h"
#include <algorithm>
(unsigned char)cast<ConstantSInt>(CA->getOperand(i))->getValue() :
(unsigned char)cast<ConstantUInt>(CA->getOperand(i))->getValue();
- if (isprint(C) && C != '"') {
+ if (isprint(C) && C != '"' && C != '\\') {
Out << C;
} else {
Out << '\\'
Out << CE->getOpcodeName();
bool isGEP = CE->getOpcode() == Instruction::GetElementPtr;
- Out << (isGEP? " (" : " ");
+ Out << " (";
for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) {
printTypeInt(Out, (*OI)->getType(), TypeTable);
Out << ", ";
}
- if (isGEP)
- Out << ")";
+ if (CE->getOpcode() == Instruction::Cast) {
+ Out << " to ";
+ printTypeInt(Out, CE->getType(), TypeTable);
+ }
+ Out << ")";
+
} else {
Out << "<placeholder or erroneous Constant>";
}
if (GV->hasName()) Out << "%" << GV->getName() << " = ";
if (GV->hasInternalLinkage()) Out << "internal ";
- if (!GV->hasInitializer()) Out << "uninitialized ";
+ if (!GV->hasInitializer()) Out << "external ";
Out << (GV->isConstant() ? "constant " : "global ");
printType(GV->getType()->getElementType());
// Loop over the arguments, printing them...
const FunctionType *FT = F->getFunctionType();
- if (!F->isExternal()) {
- for(Function::const_aiterator I = F->abegin(), E = F->aend(); I != E; ++I)
- printArgument(I);
- } else {
- // Loop over the arguments, printing them...
- for (FunctionType::ParamTypes::const_iterator I = FT->getParamTypes().begin(),
- E = FT->getParamTypes().end(); I != E; ++I) {
- if (I != FT->getParamTypes().begin()) Out << ", ";
- printType(*I);
- }
- }
+ for(Function::const_aiterator I = F->abegin(), E = F->aend(); I != E; ++I)
+ printArgument(I);
// Finish printing arguments...
if (FT->isVarArg()) {
//
void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
if (BB->hasName()) { // Print out the label if it exists...
- Out << "\n" << BB->getName() << ":\t\t\t\t\t;[#uses="
- << BB->use_size() << "]"; // Output # uses
+ Out << "\n" << BB->getName() << ":";
} else if (!BB->use_empty()) { // Don't print block # of no uses...
int Slot = Table.getValSlot(BB);
Out << "\n; <label>:";
Out << Slot; // Extra newline seperates out label's
else
Out << "<badref>";
- Out << "\t\t\t\t\t;[#uses=" << BB->use_size() << "]"; // Output # uses
+ }
+
+ // Output predecessors for the block...
+ Out << "\t\t;";
+ pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB);
+
+ if (PI == PE) {
+ Out << " No predecessors!";
+ } else {
+ Out << " preds =";
+ writeOperand(*PI, false, true);
+ for (++PI; PI != PE; ++PI) {
+ Out << ",";
+ writeOperand(*PI, false, true);
+ }
}
Out << "\n";
void Constant::print(std::ostream &o) const {
if (this == 0) { o << "<null> constant value\n"; return; }
+
+ // Handle CPR's special, because they have context information...
+ if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(this)) {
+ CPR->getValue()->print(o); // Print as a global value, with context info.
+ return;
+ }
+
o << " " << getType()->getDescription() << " ";
map<const Type *, string> TypeTable;