[llvm-commits] CVS: llvm/lib/Target/X86/X86InstrBuilder.h

Chris Lattner lattner at cs.uiuc.edu
Thu Oct 14 21:43:31 PDT 2004



Changes in directory llvm/lib/Target/X86:

X86InstrBuilder.h updated: 1.12 -> 1.13
---
Log message:

Allow X86 addressing modes to represent globals with offsets.  Patch contributed
by Jeff Cohen!


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

Index: llvm/lib/Target/X86/X86InstrBuilder.h
diff -u llvm/lib/Target/X86/X86InstrBuilder.h:1.12 llvm/lib/Target/X86/X86InstrBuilder.h:1.13
--- llvm/lib/Target/X86/X86InstrBuilder.h:1.12	Sun Aug 29 19:13:26 2004
+++ llvm/lib/Target/X86/X86InstrBuilder.h	Thu Oct 14 23:43:20 2004
@@ -30,13 +30,13 @@
 
 /// X86AddressMode - This struct holds a generalized full x86 address mode.
 /// The base register can be a frame index, which will eventually be replaced
-/// with BP or SP and Disp being offsetted accordingly.
-/// FIXME: add support for globals as a new base type.
+/// with BP or SP and Disp being offsetted accordingly.  The displacement may
+/// also include the offset of a global value.
 struct X86AddressMode {
     enum {
       UnknownBase,
       RegBase,
-      FrameIndexBase
+      FrameIndexBase,
     } BaseType;
 
     union {
@@ -47,8 +47,9 @@
     unsigned Scale;
     unsigned IndexReg;
     unsigned Disp;
+    GlobalValue *GV;
 
-    X86AddressMode() : BaseType(UnknownBase) {}
+    X86AddressMode() : BaseType(UnknownBase), GV(NULL) {}
 };
 
 /// addDirectMem - This function is used to add a direct memory reference to the
@@ -82,7 +83,11 @@
     MIB.addFrameIndex(AM.Base.FrameIndex);
   else
     assert (0);
-  return MIB.addZImm(AM.Scale).addReg(AM.IndexReg).addSImm(AM.Disp);
+  MIB.addZImm(AM.Scale).addReg(AM.IndexReg);
+  if (AM.GV)
+    return MIB.addGlobalAddress(AM.GV, false, AM.Disp);
+  else
+    return MIB.addSImm(AM.Disp);
 }
 
 /// addFrameReference - This function is used to add a reference to the base of






More information about the llvm-commits mailing list