Fixing silly "not-implemented" bug in AsmPrinter. This fixes PR1169.
authorAnton Korobeynikov <asl@math.spbu.ru>
Sun, 4 Feb 2007 23:27:42 +0000 (23:27 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sun, 4 Feb 2007 23:27:42 +0000 (23:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33888 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter.cpp

index ae082a63a298252387ef35591a8c7d59f49809e6..37fb51f1c56353bfd805c3e480be7f6c325e5a49 100644 (file)
@@ -608,7 +608,8 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
     }
   } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
     const TargetData *TD = TM.getTargetData();
-    switch(CE->getOpcode()) {
+    unsigned Opcode = CE->getOpcode();    
+    switch (Opcode) {
     case Instruction::GetElementPtr: {
       // generate a symbolic expression for the byte address
       const Constant *ptrVal = CE->getOperand(0);
@@ -666,9 +667,10 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
       break;
     }
     case Instruction::Add:
+    case Instruction::Sub:
       O << "(";
       EmitConstantValueOnly(CE->getOperand(0));
-      O << ") + (";
+      O << (Opcode==Instruction::Add ? ") + (" : ") - (");
       EmitConstantValueOnly(CE->getOperand(1));
       O << ")";
       break;