From: Nick Hildenbrandt Date: Wed, 25 Sep 2002 20:29:26 +0000 (+0000) Subject: Strings now handled correctly. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e548f009f782bdd85764616a1f9c69e5b879b351;p=oota-llvm.git Strings now handled correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3920 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 3b8c67d45b1..e54d4575125 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -985,18 +985,23 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I, writeOperandInternal(Ptr); - if (HasImplicitAddress && (!CI || !CI->isNullValue())) + if (HasImplicitAddress && (!CI || !CI->isNullValue())) { Out << ")"; + HasImplicitAddress = false; // HIA is only true if we haven't addressed yet + } + + assert(!HasImplicitAddress || (CI && CI->isNullValue()) && + "Can only have implicit address with direct accessing"); - // Print out the -> operator if possible... - if (CI && CI->isNullValue() && I+1 != E) { + if (HasImplicitAddress) { + ++I; + } else if (CI && CI->isNullValue() && I+1 != E) { + // Print out the -> operator if possible... if ((*(I+1))->getType() == Type::UByteTy) { Out << (HasImplicitAddress ? "." : "->"); Out << "field" << cast(*(I+1))->getValue(); I += 2; - } else { // First array index of 0: Just skip it - ++I; - } + } } for (; I != E; ++I) @@ -1015,14 +1020,14 @@ void CWriter::visitLoadInst(LoadInst &I) { } void CWriter::visitStoreInst(StoreInst &I) { - Out << "*"; + //Out << "*"; writeOperand(I.getPointerOperand()); Out << " = "; writeOperand(I.getOperand(0)); } void CWriter::visitGetElementPtrInst(GetElementPtrInst &I) { - Out << "&"; + //Out << "&"; printIndexingExpression(I.getPointerOperand(), I.idx_begin(), I.idx_end()); } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 3b8c67d45b1..e54d4575125 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -985,18 +985,23 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I, writeOperandInternal(Ptr); - if (HasImplicitAddress && (!CI || !CI->isNullValue())) + if (HasImplicitAddress && (!CI || !CI->isNullValue())) { Out << ")"; + HasImplicitAddress = false; // HIA is only true if we haven't addressed yet + } + + assert(!HasImplicitAddress || (CI && CI->isNullValue()) && + "Can only have implicit address with direct accessing"); - // Print out the -> operator if possible... - if (CI && CI->isNullValue() && I+1 != E) { + if (HasImplicitAddress) { + ++I; + } else if (CI && CI->isNullValue() && I+1 != E) { + // Print out the -> operator if possible... if ((*(I+1))->getType() == Type::UByteTy) { Out << (HasImplicitAddress ? "." : "->"); Out << "field" << cast(*(I+1))->getValue(); I += 2; - } else { // First array index of 0: Just skip it - ++I; - } + } } for (; I != E; ++I) @@ -1015,14 +1020,14 @@ void CWriter::visitLoadInst(LoadInst &I) { } void CWriter::visitStoreInst(StoreInst &I) { - Out << "*"; + //Out << "*"; writeOperand(I.getPointerOperand()); Out << " = "; writeOperand(I.getOperand(0)); } void CWriter::visitGetElementPtrInst(GetElementPtrInst &I) { - Out << "&"; + //Out << "&"; printIndexingExpression(I.getPointerOperand(), I.idx_begin(), I.idx_end()); }