Y("print","Print function to stderr");
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
- bool PrintName,
std::map<const Type *, std::string> &TypeTable,
SlotMachine *Machine);
/// @brief Internal constant writer.
static void WriteConstantInt(std::ostream &Out, const Constant *CV,
- bool PrintName,
std::map<const Type *, std::string> &TypeTable,
SlotMachine *Machine) {
const int IndentSize = 4;
Out << ' ';
printTypeInt(Out, ETy, TypeTable);
WriteAsOperandInternal(Out, CA->getOperand(0),
- PrintName, TypeTable, Machine);
+ TypeTable, Machine);
for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
Out << ", ";
printTypeInt(Out, ETy, TypeTable);
- WriteAsOperandInternal(Out, CA->getOperand(i), PrintName,
- TypeTable, Machine);
+ WriteAsOperandInternal(Out, CA->getOperand(i), TypeTable, Machine);
}
}
Out << " ]";
}
printTypeInt(Out, CS->getOperand(0)->getType(), TypeTable);
- WriteAsOperandInternal(Out, CS->getOperand(0),
- PrintName, TypeTable, Machine);
+ WriteAsOperandInternal(Out, CS->getOperand(0), TypeTable, Machine);
for (unsigned i = 1; i < N; i++) {
Out << ", ";
if (N > 2) Out << Indent;
printTypeInt(Out, CS->getOperand(i)->getType(), TypeTable);
- WriteAsOperandInternal(Out, CS->getOperand(i),
- PrintName, TypeTable, Machine);
+ WriteAsOperandInternal(Out, CS->getOperand(i), TypeTable, Machine);
}
if (N > 2) Indent.resize(Indent.size() - IndentSize);
}
Out << '<';
Out << ' ';
printTypeInt(Out, ETy, TypeTable);
- WriteAsOperandInternal(Out, CP->getOperand(0),
- PrintName, TypeTable, Machine);
+ WriteAsOperandInternal(Out, CP->getOperand(0), TypeTable, Machine);
for (unsigned i = 1, e = CP->getNumOperands(); i != e; ++i) {
Out << ", ";
printTypeInt(Out, ETy, TypeTable);
- WriteAsOperandInternal(Out, CP->getOperand(i), PrintName,
- TypeTable, Machine);
+ WriteAsOperandInternal(Out, CP->getOperand(i), TypeTable, Machine);
}
Out << " >";
} else if (isa<ConstantPointerNull>(CV)) {
for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) {
printTypeInt(Out, (*OI)->getType(), TypeTable);
- WriteAsOperandInternal(Out, *OI, PrintName, TypeTable, Machine);
+ WriteAsOperandInternal(Out, *OI, TypeTable, Machine);
if (OI+1 != CE->op_end())
Out << ", ";
}
/// the whole instruction that generated it.
///
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
- bool PrintName,
std::map<const Type*, std::string> &TypeTable,
SlotMachine *Machine) {
Out << ' ';
- if ((PrintName || isa<GlobalValue>(V)) && V->hasName())
+ if (V->hasName())
Out << getLLVMName(V->getName());
else {
const Constant *CV = dyn_cast<Constant>(V);
if (CV && !isa<GlobalValue>(CV)) {
- WriteConstantInt(Out, CV, PrintName, TypeTable, Machine);
+ WriteConstantInt(Out, CV, TypeTable, Machine);
} else if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
Out << "asm ";
if (IA->hasSideEffects())
if (PrintType)
printTypeInt(Out, V->getType(), TypeNames);
- WriteAsOperandInternal(Out, V, true, TypeNames, 0);
+ WriteAsOperandInternal(Out, V, TypeNames, 0);
return Out;
}
inline void write(const Constant *CPV) { printConstant(CPV); }
inline void write(const Type *Ty) { printType(Ty); }
- void writeOperand(const Value *Op, bool PrintType, bool PrintName = true);
+ void writeOperand(const Value *Op, bool PrintType);
const Module* getModule() { return TheModule; }
}
-void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType,
- bool PrintName) {
- if (Operand != 0) {
- if (PrintType) { Out << ' '; printType(Operand->getType()); }
- WriteAsOperandInternal(Out, Operand, PrintName, TypeNames, &Machine);
- } else {
+void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType) {
+ if (Operand == 0) {
Out << "<null operand!>";
+ } else {
+ if (PrintType) { Out << ' '; printType(Operand->getType()); }
+ WriteAsOperandInternal(Out, Operand, TypeNames, &Machine);
}
}
if (GV->hasInitializer()) {
Constant* C = cast<Constant>(GV->getInitializer());
assert(C && "GlobalVar initializer isn't constant?");
- writeOperand(GV->getInitializer(), false, isa<GlobalValue>(C));
+ writeOperand(GV->getInitializer(), false);
}
if (GV->hasSection())
// Print out name...
Out << "\t" << getLLVMName(CPV->getName()) << " =";
- // Write the value out now...
- writeOperand(CPV, true, false);
+ // Write the value out now.
+ writeOperand(CPV, true);
printInfoComment(*CPV);
Out << "\n";
Out << " No predecessors!";
} else {
Out << " preds =";
- writeOperand(*PI, false, true);
+ writeOperand(*PI, false);
for (++PI; PI != PE; ++PI) {
Out << ',';
- writeOperand(*PI, false, true);
+ writeOperand(*PI, false);
}
}
}
}
void InlineAsm::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
- WriteAsOperand(o, this, true, true, 0);
+ WriteAsOperand(o, this, true, 0);
}
void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
o << ' ' << getType()->getDescription() << ' ';
std::map<const Type *, std::string> TypeTable;
- WriteConstantInt(o, this, false, TypeTable, 0);
+ WriteConstantInt(o, this, TypeTable, 0);
}
void Type::print(std::ostream &o) const {
}
void Argument::print(std::ostream &o) const {
- WriteAsOperand(o, this, true, true,
- getParent() ? getParent()->getParent() : 0);
+ WriteAsOperand(o, this, true, getParent() ? getParent()->getParent() : 0);
}
// Value::dump - allow easy printing of Values from the debugger.
else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(&V))
AW->write(GV);
else
- AW->writeOperand(&V, true, true);
+ AW->writeOperand(&V, true);
return *this;
}