[llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Oct 14 21:38:52 PDT 2004



Changes in directory llvm/lib/CodeGen:

MachineInstr.cpp updated: 1.105 -> 1.106
---
Log message:

Allow machine operands to represent global variables with offsets.  This is
useful when you have a reference like:

int A[100];

void foo() { A[10] = 1; }

In this case, &A[10] is a single constant and should be treated as such.

Only MO_GlobalAddress and MO_ExternalSymbol are allowed to use this field, no
other operand type is.

This is another fine patch contributed by Jeff Cohen!!



---
Diffs of the changes:  (+9 -5)

Index: llvm/lib/CodeGen/MachineInstr.cpp
diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.105 llvm/lib/CodeGen/MachineInstr.cpp:1.106
--- llvm/lib/CodeGen/MachineInstr.cpp:1.105	Wed Sep  1 17:55:35 2004
+++ llvm/lib/CodeGen/MachineInstr.cpp	Thu Oct 14 23:38:41 2004
@@ -127,7 +127,7 @@
   assert(i < operands.size());          // may be explicit or implicit op
   operands[i].opType = opTy;
   operands[i].contents.value = V;
-  operands[i].regNum = -1;
+  operands[i].extra.regNum = -1;
 }
 
 void
@@ -141,7 +141,7 @@
   operands[i].opType = opTy;
   operands[i].contents.value = NULL;
   operands[i].contents.immedVal = intValue;
-  operands[i].regNum = -1;
+  operands[i].extra.regNum = -1;
   operands[i].flags = 0;
 }
 
@@ -150,7 +150,7 @@
 
   operands[i].opType = MachineOperand::MO_MachineRegister;
   operands[i].contents.value = NULL;
-  operands[i].regNum = regNum;
+  operands[i].extra.regNum = regNum;
 }
 
 // Used only by the SPARC back-end.
@@ -302,10 +302,14 @@
     OS << "<cp#" << MO.getConstantPoolIndex() << ">";
     break;
   case MachineOperand::MO_GlobalAddress:
-    OS << "<ga:" << ((Value*)MO.getGlobal())->getName() << ">";
+    OS << "<ga:" << ((Value*)MO.getGlobal())->getName();
+    if (MO.getOffset()) OS << "+" << MO.getOffset();
+    OS << ">";
     break;
   case MachineOperand::MO_ExternalSymbol:
-    OS << "<es:" << MO.getSymbolName() << ">";
+    OS << "<es:" << MO.getSymbolName();
+    if (MO.getOffset()) OS << "+" << MO.getOffset();
+    OS << ">";
     break;
   default:
     assert(0 && "Unrecognized operand type");






More information about the llvm-commits mailing list