Print "X-42" instead of "X+-42".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81203 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-09-08 06:37:35 +00:00
parent be73e8c4e7
commit d19ceb9b12

View File

@ -51,7 +51,17 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
switch (BE.getOpcode()) {
default: assert(0 && "Invalid opcode!");
case MCBinaryExpr::Add: OS << '+'; break;
case MCBinaryExpr::Add:
// Print "X-42" instead of "X+-42".
if (const MCConstantExpr *RHSC = dyn_cast<MCConstantExpr>(BE.getRHS())) {
if (RHSC->getValue() < 0) {
OS << RHSC->getValue();
return;
}
}
OS << '+';
break;
case MCBinaryExpr::And: OS << '&'; break;
case MCBinaryExpr::Div: OS << '/'; break;
case MCBinaryExpr::EQ: OS << "=="; break;