diff options
author | Chris Lattner <sabre@nondot.org> | 2005-02-14 21:40:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-02-14 21:40:26 +0000 |
commit | 145569b0761a1f902a5c132eb17995979769e348 (patch) | |
tree | 03fb98b604de5797854d4a62a125f49905be530c /llvm/lib/CodeGen/AsmPrinter.cpp | |
parent | 3d2881066b941c1a22f3bab91b7df8a4b007998c (diff) | |
download | bcm5719-llvm-145569b0761a1f902a5c132eb17995979769e348.tar.gz bcm5719-llvm-145569b0761a1f902a5c132eb17995979769e348.zip |
Print GEP offsets as signed values instead of unsigned values. On X86, this
prints:
getelementptr (int* %A, int -1)
as: "(A) - 4" instead of "(A) + 18446744073709551612", which makes the
assembler much happier.
This fixes test/Regression/CodeGen/X86/2005-02-14-IllegalAssembler.ll,
and Benchmarks/Prolangs-C/cdecl with LLC on X86.
llvm-svn: 20183
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index 80f67023f43..4e77a78d81b 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -78,10 +78,14 @@ void AsmPrinter::emitConstantValueOnly(const Constant *CV) { // generate a symbolic expression for the byte address const Constant *ptrVal = CE->getOperand(0); std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end()); - if (uint64_t Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) { - O << "("; + if (int64_t Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) { + if (Offset) + O << "("; emitConstantValueOnly(ptrVal); - O << ") + " << Offset; + if (Offset > 0) + O << ") + " << Offset; + else if (Offset < 0) + O << ") - " << -Offset; } else { emitConstantValueOnly(ptrVal); } |