From a95589be3fae3f13230e2aa96b46b4a63fb4a995 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19457 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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;