aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/X86/InstSelectSimple.cpp
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2002-12-13 09:28:50 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2002-12-13 09:28:50 +0000
commited6902ca8991b895025a9a11ddeb200e7b5ae6ae (patch)
tree7075a93d01972f93bf9cf01c7575db84c32fc7aa /lib/Target/X86/InstSelectSimple.cpp
parent95780cccef3f6630a912aba9e2241819d7a00ba4 (diff)
lib/Target/X86/InstSelectSimple.cpp: Start counting arguments with 2,
because arguments start two stack slots off of EBP. Break out of the for loop once the argument is found. Increment the counter at the end of the loop instead of the beginning. Use addRegOffset and compute the scale * index part at compile time instead of using the fancy load instruction. Just because an instruction set has wacky addressing modes doesn't mean we ought to use them (at least, if you believe Dave Patterson). lib/Target/X86/X86InstrBuilder.h: Add some comments. test/Regression/Jello/test-loadstore.ll: Let main return int 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4999 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/InstSelectSimple.cpp')
-rw-r--r--lib/Target/X86/InstSelectSimple.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp
index 40d757b645..54cf29229d 100644
--- a/lib/Target/X86/InstSelectSimple.cpp
+++ b/lib/Target/X86/InstSelectSimple.cpp
@@ -159,23 +159,24 @@ namespace {
} else if (Argument *A = dyn_cast<Argument>(V)) {
// Find the position of the argument in the argument list.
const Function *f = F->getFunction ();
- int counter = 0, argPosition = -1;
+ // The function's arguments look like this:
+ // [EBP] -- copy of old EBP
+ // [EBP + 4] -- return address
+ // [EBP + 8] -- first argument (leftmost lexically)
+ // So we want to start with counter = 2.
+ int counter = 2, argPosition = -1;
for (Function::const_aiterator ai = f->abegin (), ae = f->aend ();
ai != ae; ++ai) {
- ++counter;
if (&(*ai) == A) {
argPosition = counter;
+ break; // Only need to find it once. ;-)
}
+ ++counter;
}
assert (argPosition != -1
&& "Argument not found in current function's argument list");
// Load it out of the stack frame at EBP + 4*argPosition.
- // (First, load Reg with argPosition, then load Reg with DWORD
- // PTR [EBP + 4*Reg].)
- BuildMI (BB, X86::MOVir32, 1, Reg).addZImm (argPosition);
- BuildMI (BB, X86::MOVmr32, 4,
- Reg).addReg (X86::EBP).addZImm (4).addReg (Reg).addSImm (0);
- // std::cerr << "ERROR: Arguments not implemented in SimpleInstSel\n";
+ addRegOffset (BuildMI (BB, X86::MOVmr32, 4, Reg), X86::EBP, 4*argPosition);
}
return Reg;