+/// WriteAsOperandInternal - Write the name of the specified value out to
+/// the specified ostream. This can be useful when you just want to print
+/// int %reg126, not the whole instruction that generated it.
+///
+static void WriteAsOperandInternal(std::ostream &Out, const Type *T,
+ bool PrintName,
+ std::map<const Type*, std::string> &TypeTable,
+ SlotMachine *Machine) {
+ Out << ' ';
+ int Slot;
+ if (Machine) {
+ Slot = Machine->getSlot(T);
+ if (Slot != -1)
+ Out << '%' << Slot;
+ else
+ Out << "<badref>";
+ } else {
+ Out << T->getDescription();
+ }
+}
+
+/// WriteAsOperand - Write the name of the specified value out to the specified
+/// ostream. This can be useful when you just want to print int %reg126, not
+/// the whole instruction that generated it.
+///
+std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Type *Ty,
+ bool PrintType, bool PrintName,
+ const Module *Context) {
+ std::map<const Type *, std::string> TypeNames;
+ assert(Context != 0 && "Can't write types as operand without module context");
+
+ fillTypeNameTable(Context, TypeNames);
+
+ // if (PrintType)
+ // printTypeInt(Out, V->getType(), TypeNames);
+
+ printTypeInt(Out, Ty, TypeNames);
+
+ WriteAsOperandInternal(Out, Ty, PrintName, TypeNames, 0);
+ return Out;
+}
+