From: Chris Lattner Date: Thu, 9 May 2002 15:59:50 +0000 (+0000) Subject: Emit: X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8c8a37061a738cc435b27e74f2320dae03c06318;p=oota-llvm.git Emit: l3_reg109 = l81_this->field0; Instead of: l3_reg109 = l81_this[0u].field0; where possible git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2579 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 00b00ab9a82..5da8367a11a 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -517,8 +517,19 @@ void CInstPrintVisitor::visitFreeInst(FreeInst *I) { void CInstPrintVisitor::printIndexingExpr(MemAccessInst *MAI) { CW.writeOperand(MAI->getPointerOperand()); - for (MemAccessInst::op_iterator I = MAI->idx_begin(), E = MAI->idx_end(); - I != E; ++I) + MemAccessInst::op_iterator I = MAI->idx_begin(), E = MAI->idx_end(); + if (I == E) return; + + // Print out the -> operator if possible... + Constant *CI = dyn_cast(*I); + if (CI && CI->isNullValue() && I+1 != E && + (*(I+1))->getType() == Type::UByteTy) { + ++I; + Out << "->field" << cast(*I)->getValue(); + ++I; + } + + for (; I != E; ++I) if ((*I)->getType() == Type::UIntTy) { Out << "["; CW.writeOperand(*I); diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 00b00ab9a82..5da8367a11a 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -517,8 +517,19 @@ void CInstPrintVisitor::visitFreeInst(FreeInst *I) { void CInstPrintVisitor::printIndexingExpr(MemAccessInst *MAI) { CW.writeOperand(MAI->getPointerOperand()); - for (MemAccessInst::op_iterator I = MAI->idx_begin(), E = MAI->idx_end(); - I != E; ++I) + MemAccessInst::op_iterator I = MAI->idx_begin(), E = MAI->idx_end(); + if (I == E) return; + + // Print out the -> operator if possible... + Constant *CI = dyn_cast(*I); + if (CI && CI->isNullValue() && I+1 != E && + (*(I+1))->getType() == Type::UByteTy) { + ++I; + Out << "->field" << cast(*I)->getValue(); + ++I; + } + + for (; I != E; ++I) if ((*I)->getType() == Type::UIntTy) { Out << "["; CW.writeOperand(*I);