From f867443d7e789e9b8bf68d88360c224a99cc2e35 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 11 Jan 2005 04:40:19 +0000 Subject: [PATCH] Teach the address selector to make 'reg+reg' addressing modes. llvm-svn: 19457 --- lib/Target/X86/X86ISelPattern.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp index f2edb651ae0..bd060772158 100644 --- a/lib/Target/X86/X86ISelPattern.cpp +++ b/lib/Target/X86/X86ISelPattern.cpp @@ -443,9 +443,18 @@ bool ISel::SelectAddress(SDOperand N, X86AddressMode &AM) { } } - if (AM.BaseType != X86AddressMode::RegBase || - AM.Base.Reg) + // Is the base register already occupied? + if (AM.BaseType != X86AddressMode::RegBase || AM.Base.Reg) { + // If so, check to see if the scale index register is set. + if (AM.IndexReg == 0) { + AM.IndexReg = SelectExpr(N); + AM.Scale = 1; + return false; + } + + // Otherwise, we cannot select it. return true; + } // Default, generate it as a register. AM.BaseType = X86AddressMode::RegBase;