Print -X like this:

double test(double l1_X) {
  return (-l1_X);
}

instead of like this:

double test(double l1_X) {
  return (-0x0p+0 - l1_X);
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20423 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-03-03 21:12:04 +00:00
parent f3f475efee
commit 6d9b69fd5f
2 changed files with 60 additions and 44 deletions

View File

@ -1358,31 +1358,39 @@ void CWriter::visitBinaryOperator(Instruction &I) {
printType(Out, I.getType());
Out << ")(";
}
writeOperand(I.getOperand(0));
switch (I.getOpcode()) {
case Instruction::Add: Out << " + "; break;
case Instruction::Sub: Out << " - "; break;
case Instruction::Mul: Out << '*'; break;
case Instruction::Div: Out << '/'; break;
case Instruction::Rem: Out << '%'; break;
case Instruction::And: Out << " & "; break;
case Instruction::Or: Out << " | "; break;
case Instruction::Xor: Out << " ^ "; break;
case Instruction::SetEQ: Out << " == "; break;
case Instruction::SetNE: Out << " != "; break;
case Instruction::SetLE: Out << " <= "; break;
case Instruction::SetGE: Out << " >= "; break;
case Instruction::SetLT: Out << " < "; break;
case Instruction::SetGT: Out << " > "; break;
case Instruction::Shl : Out << " << "; break;
case Instruction::Shr : Out << " >> "; break;
default: std::cerr << "Invalid operator type!" << I; abort();
// If this is a negation operation, print it out as such. For FP, we don't
// want to print "-0.0 - X".
if (BinaryOperator::isNeg(&I)) {
Out << "-";
writeOperand(BinaryOperator::getNegArgument(cast<BinaryOperator>(&I)));
} else {
writeOperand(I.getOperand(0));
switch (I.getOpcode()) {
case Instruction::Add: Out << " + "; break;
case Instruction::Sub: Out << " - "; break;
case Instruction::Mul: Out << '*'; break;
case Instruction::Div: Out << '/'; break;
case Instruction::Rem: Out << '%'; break;
case Instruction::And: Out << " & "; break;
case Instruction::Or: Out << " | "; break;
case Instruction::Xor: Out << " ^ "; break;
case Instruction::SetEQ: Out << " == "; break;
case Instruction::SetNE: Out << " != "; break;
case Instruction::SetLE: Out << " <= "; break;
case Instruction::SetGE: Out << " >= "; break;
case Instruction::SetLT: Out << " < "; break;
case Instruction::SetGT: Out << " > "; break;
case Instruction::Shl : Out << " << "; break;
case Instruction::Shr : Out << " >> "; break;
default: std::cerr << "Invalid operator type!" << I; abort();
}
writeOperand(I.getOperand(1));
}
writeOperand(I.getOperand(1));
if (needsCast) {
Out << "))";
}

View File

@ -1358,31 +1358,39 @@ void CWriter::visitBinaryOperator(Instruction &I) {
printType(Out, I.getType());
Out << ")(";
}
writeOperand(I.getOperand(0));
switch (I.getOpcode()) {
case Instruction::Add: Out << " + "; break;
case Instruction::Sub: Out << " - "; break;
case Instruction::Mul: Out << '*'; break;
case Instruction::Div: Out << '/'; break;
case Instruction::Rem: Out << '%'; break;
case Instruction::And: Out << " & "; break;
case Instruction::Or: Out << " | "; break;
case Instruction::Xor: Out << " ^ "; break;
case Instruction::SetEQ: Out << " == "; break;
case Instruction::SetNE: Out << " != "; break;
case Instruction::SetLE: Out << " <= "; break;
case Instruction::SetGE: Out << " >= "; break;
case Instruction::SetLT: Out << " < "; break;
case Instruction::SetGT: Out << " > "; break;
case Instruction::Shl : Out << " << "; break;
case Instruction::Shr : Out << " >> "; break;
default: std::cerr << "Invalid operator type!" << I; abort();
// If this is a negation operation, print it out as such. For FP, we don't
// want to print "-0.0 - X".
if (BinaryOperator::isNeg(&I)) {
Out << "-";
writeOperand(BinaryOperator::getNegArgument(cast<BinaryOperator>(&I)));
} else {
writeOperand(I.getOperand(0));
switch (I.getOpcode()) {
case Instruction::Add: Out << " + "; break;
case Instruction::Sub: Out << " - "; break;
case Instruction::Mul: Out << '*'; break;
case Instruction::Div: Out << '/'; break;
case Instruction::Rem: Out << '%'; break;
case Instruction::And: Out << " & "; break;
case Instruction::Or: Out << " | "; break;
case Instruction::Xor: Out << " ^ "; break;
case Instruction::SetEQ: Out << " == "; break;
case Instruction::SetNE: Out << " != "; break;
case Instruction::SetLE: Out << " <= "; break;
case Instruction::SetGE: Out << " >= "; break;
case Instruction::SetLT: Out << " < "; break;
case Instruction::SetGT: Out << " > "; break;
case Instruction::Shl : Out << " << "; break;
case Instruction::Shr : Out << " >> "; break;
default: std::cerr << "Invalid operator type!" << I; abort();
}
writeOperand(I.getOperand(1));
}
writeOperand(I.getOperand(1));
if (needsCast) {
Out << "))";
}