llvm.org GIT mirror llvm / fb3d844
Allow X86 addressing modes to represent globals with offsets. Patch contributed by Jeff Cohen! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17008 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
1 changed file(s) with 10 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
2929
3030 /// X86AddressMode - This struct holds a generalized full x86 address mode.
3131 /// The base register can be a frame index, which will eventually be replaced
32 /// with BP or SP and Disp being offsetted accordingly.
33 /// FIXME: add support for globals as a new base type.
32 /// with BP or SP and Disp being offsetted accordingly. The displacement may
33 /// also include the offset of a global value.
3434 struct X86AddressMode {
3535 enum {
3636 UnknownBase,
3737 RegBase,
38 FrameIndexBase
38 FrameIndexBase,
3939 } BaseType;
4040
4141 union {
4646 unsigned Scale;
4747 unsigned IndexReg;
4848 unsigned Disp;
49 GlobalValue *GV;
4950
50 X86AddressMode() : BaseType(UnknownBase) {}
51 X86AddressMode() : BaseType(UnknownBase), GV(NULL) {}
5152 };
5253
5354 /// addDirectMem - This function is used to add a direct memory reference to the
8182 MIB.addFrameIndex(AM.Base.FrameIndex);
8283 else
8384 assert (0);
84 return MIB.addZImm(AM.Scale).addReg(AM.IndexReg).addSImm(AM.Disp);
85 MIB.addZImm(AM.Scale).addReg(AM.IndexReg);
86 if (AM.GV)
87 return MIB.addGlobalAddress(AM.GV, false, AM.Disp);
88 else
89 return MIB.addSImm(AM.Disp);
8590 }
8691
8792 /// addFrameReference - This function is used to add a reference to the base of