diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-03 19:33:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-03 19:33:45 +0000 |
commit | 603c56213d3769948720a2373b8b0530eb0478e8 (patch) | |
tree | bc6947ece15d9da5f33b1797ece23d8a497d7262 | |
parent | 1d8addbc169b7c91b646eee1aa78f0f195ab8ed1 (diff) |
* Reformat some code
* Emit bools as 1/0 instead of true/false, fixing compilation of eon and
PR 83 & Jello/2003-11-03-GlobalBool.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9683 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/Printer.cpp | 76 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmPrinter.cpp | 76 |
2 files changed, 68 insertions, 84 deletions
diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index c8072da052..f1e29c5579 100644 --- a/lib/Target/X86/Printer.cpp +++ b/lib/Target/X86/Printer.cpp @@ -222,49 +222,41 @@ Printer::printSingleConstantValue(const Constant* CV) } O << "\t"; - if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV)) - { - // Constant expression built from operators, constants, and - // symbolic addrs - O << ConstantExprToString(CE) << "\n"; - } - else if (type->isPrimitiveType()) - { - if (type->isFloatingPoint()) { - // FP Constants are printed as integer constants to avoid losing - // precision... - double Val = cast<ConstantFP>(CV)->getValue(); - if (type == Type::FloatTy) { - float FVal = (float)Val; - char *ProxyPtr = (char*)&FVal; // Abide by C TBAA rules - O << *(unsigned int*)ProxyPtr; - } else if (type == Type::DoubleTy) { - char *ProxyPtr = (char*)&Val; // Abide by C TBAA rules - O << *(uint64_t*)ProxyPtr; - } else { - assert(0 && "Unknown floating point type!"); - } - - O << "\t# " << type->getDescription() << " value: " << Val << "\n"; - } else { - WriteAsOperand(O, CV, false, false) << "\n"; - } - } - else if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV)) - { - // This is a constant address for a global variable or method. - // Use the name of the variable or method as the address value. - O << Mang->getValueName(CPR->getValue()) << "\n"; - } - else if (isa<ConstantPointerNull>(CV)) - { - // Null pointer value - O << "0\n"; - } - else - { - assert(0 && "Unknown elementary type for constant"); + if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV)) { + // Constant expression built from operators, constants, and + // symbolic addrs + O << ConstantExprToString(CE) << "\n"; + } else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { + O << (CB->getValue() ? "1\n" : "0\n"); + } else if (type->isFloatingPoint()) { + // FP Constants are printed as integer constants to avoid losing + // precision... + double Val = cast<ConstantFP>(CV)->getValue(); + if (type == Type::FloatTy) { + float FVal = (float)Val; + char *ProxyPtr = (char*)&FVal; // Abide by C TBAA rules + O << *(unsigned int*)ProxyPtr; + } else if (type == Type::DoubleTy) { + char *ProxyPtr = (char*)&Val; // Abide by C TBAA rules + O << *(uint64_t*)ProxyPtr; + } else { + assert(0 && "Unknown floating point type!"); } + + O << "\t# " << type->getDescription() << " value: " << Val << "\n"; + } else if (type->isPrimitiveType()) { + + WriteAsOperand(O, CV, false, false) << "\n"; + } else if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV)) { + // This is a constant address for a global variable or method. + // Use the name of the variable or method as the address value. + O << Mang->getValueName(CPR->getValue()) << "\n"; + } else if (isa<ConstantPointerNull>(CV)) { + // Null pointer value + O << "0\n"; + } else { + assert(0 && "Unknown elementary type for constant"); + } } /// isStringCompatible - Can we treat the specified array as a string? diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index c8072da052..f1e29c5579 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -222,49 +222,41 @@ Printer::printSingleConstantValue(const Constant* CV) } O << "\t"; - if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV)) - { - // Constant expression built from operators, constants, and - // symbolic addrs - O << ConstantExprToString(CE) << "\n"; - } - else if (type->isPrimitiveType()) - { - if (type->isFloatingPoint()) { - // FP Constants are printed as integer constants to avoid losing - // precision... - double Val = cast<ConstantFP>(CV)->getValue(); - if (type == Type::FloatTy) { - float FVal = (float)Val; - char *ProxyPtr = (char*)&FVal; // Abide by C TBAA rules - O << *(unsigned int*)ProxyPtr; - } else if (type == Type::DoubleTy) { - char *ProxyPtr = (char*)&Val; // Abide by C TBAA rules - O << *(uint64_t*)ProxyPtr; - } else { - assert(0 && "Unknown floating point type!"); - } - - O << "\t# " << type->getDescription() << " value: " << Val << "\n"; - } else { - WriteAsOperand(O, CV, false, false) << "\n"; - } - } - else if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV)) - { - // This is a constant address for a global variable or method. - // Use the name of the variable or method as the address value. - O << Mang->getValueName(CPR->getValue()) << "\n"; - } - else if (isa<ConstantPointerNull>(CV)) - { - // Null pointer value - O << "0\n"; - } - else - { - assert(0 && "Unknown elementary type for constant"); + if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV)) { + // Constant expression built from operators, constants, and + // symbolic addrs + O << ConstantExprToString(CE) << "\n"; + } else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { + O << (CB->getValue() ? "1\n" : "0\n"); + } else if (type->isFloatingPoint()) { + // FP Constants are printed as integer constants to avoid losing + // precision... + double Val = cast<ConstantFP>(CV)->getValue(); + if (type == Type::FloatTy) { + float FVal = (float)Val; + char *ProxyPtr = (char*)&FVal; // Abide by C TBAA rules + O << *(unsigned int*)ProxyPtr; + } else if (type == Type::DoubleTy) { + char *ProxyPtr = (char*)&Val; // Abide by C TBAA rules + O << *(uint64_t*)ProxyPtr; + } else { + assert(0 && "Unknown floating point type!"); } + + O << "\t# " << type->getDescription() << " value: " << Val << "\n"; + } else if (type->isPrimitiveType()) { + + WriteAsOperand(O, CV, false, false) << "\n"; + } else if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV)) { + // This is a constant address for a global variable or method. + // Use the name of the variable or method as the address value. + O << Mang->getValueName(CPR->getValue()) << "\n"; + } else if (isa<ConstantPointerNull>(CV)) { + // Null pointer value + O << "0\n"; + } else { + assert(0 && "Unknown elementary type for constant"); + } } /// isStringCompatible - Can we treat the specified array as a string? |