aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-09 22:26:29 +0000
committerChris Lattner <sabre@nondot.org>2001-09-09 22:26:29 +0000
commite6fdb11e1ae823d69e646e76828ccb5d427a9d3a (patch)
tree253085ba1c133f67309338b4cd792592e96354aa /lib/CodeGen/MachineInstr.cpp
parent167ed34a1f42045e0c18d3d3f33d917684c96ed5 (diff)
Fix problems with freeing memory twice
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@520 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r--lib/CodeGen/MachineInstr.cpp77
1 files changed, 37 insertions, 40 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index a53d29c657..aa9765d21d 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -17,7 +17,6 @@
#include "llvm/Method.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/Instruction.h"
-#include <strstream>
//************************ Class Implementations **************************/
@@ -105,47 +104,45 @@ operator<< (ostream& os, const MachineInstr& minstr)
return os;
}
-ostream&
-operator<< (ostream& os, const MachineOperand& mop)
-{
- strstream regInfo;
- if (mop.opType == MachineOperand::MO_VirtualRegister)
- regInfo << "(val " << mop.value << ")" << ends;
- else if (mop.opType == MachineOperand::MO_MachineRegister)
- regInfo << "(" << mop.regNum << ")" << ends;
- else if (mop.opType == MachineOperand::MO_CCRegister)
- regInfo << "(val " << mop.value << ")" << ends;
-
- switch(mop.opType)
- {
- case MachineOperand::MO_VirtualRegister:
- case MachineOperand::MO_MachineRegister:
- os << "%reg" << regInfo.str();
- free(regInfo.str());
- break;
-
- case MachineOperand::MO_CCRegister:
- os << "%ccreg" << regInfo.str();
- free(regInfo.str());
- break;
-
- case MachineOperand::MO_SignExtendedImmed:
- os << mop.immedVal;
- break;
-
- case MachineOperand::MO_UnextendedImmed:
- os << mop.immedVal;
- break;
+static inline ostream &OutputOperand(ostream &os, const MachineOperand &mop) {
+ switch (mop.getOperandType()) {
+ case MachineOperand::MO_CCRegister:
+ case MachineOperand::MO_VirtualRegister:
+ return os << "(val " << mop.getVRegValue() << ")";
+ case MachineOperand::MO_MachineRegister:
+ return os << "(" << mop.getMachineRegNum() << ")";
+ default:
+ assert(0 && "Unknown operand type");
+ return os;
+ }
+}
- case MachineOperand::MO_PCRelativeDisp:
- os << "%disp(label " << mop.value << ")";
- break;
-
- default:
- assert(0 && "Unrecognized operand type");
- break;
- }
+ostream &operator<<(ostream &os, const MachineOperand &mop) {
+ switch(mop.opType) {
+ case MachineOperand::MO_VirtualRegister:
+ case MachineOperand::MO_MachineRegister:
+ os << "%reg";
+ return OutputOperand(os, mop);
+ case MachineOperand::MO_CCRegister:
+ os << "%ccreg";
+ return OutputOperand(os, mop);
+
+ case MachineOperand::MO_SignExtendedImmed:
+ return os << mop.immedVal;
+
+ case MachineOperand::MO_UnextendedImmed:
+ return os << mop.immedVal;
+
+ case MachineOperand::MO_PCRelativeDisp:
+ os << "%disp(label ";
+ return OutputOperand(os, mop) << ")";
+
+ default:
+ assert(0 && "Unrecognized operand type");
+ break;
+ }
+
return os;
}