Emit:
authorChris Lattner <sabre@nondot.org>
Thu, 9 May 2002 15:59:50 +0000 (15:59 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 9 May 2002 15:59:50 +0000 (15:59 +0000)
  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

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index 00b00ab9a8254a0d3b40591173746c955b028a9b..5da8367a11aebbb3e711fe605a5c17d25f5f3c12 100644 (file)
@@ -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<Constant>(*I);
+  if (CI && CI->isNullValue() && I+1 != E &&
+      (*(I+1))->getType() == Type::UByteTy) {
+    ++I;
+    Out << "->field" << cast<ConstantUInt>(*I)->getValue();
+    ++I;
+  }
+    
+  for (; I != E; ++I)
     if ((*I)->getType() == Type::UIntTy) {
       Out << "[";
       CW.writeOperand(*I);
index 00b00ab9a8254a0d3b40591173746c955b028a9b..5da8367a11aebbb3e711fe605a5c17d25f5f3c12 100644 (file)
@@ -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<Constant>(*I);
+  if (CI && CI->isNullValue() && I+1 != E &&
+      (*(I+1))->getType() == Type::UByteTy) {
+    ++I;
+    Out << "->field" << cast<ConstantUInt>(*I)->getValue();
+    ++I;
+  }
+    
+  for (; I != E; ++I)
     if ((*I)->getType() == Type::UIntTy) {
       Out << "[";
       CW.writeOperand(*I);