aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/X86/InstSelectSimple.cpp
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2002-12-13 07:56:18 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2002-12-13 07:56:18 +0000
commit95780cccef3f6630a912aba9e2241819d7a00ba4 (patch)
tree39474209056a7b89d2fde53c2c3ff587939e0441 /lib/Target/X86/InstSelectSimple.cpp
parent3153b35a520f40954c2bded460e0b055f15727b9 (diff)
InstSelectSimple.cpp: Give promote32 a comment. Add initial
implementation of getReg() for arguments. MachineCodeEmitter.cpp: Fix using EBP with index, scale and no displacement (whew!) due to Chris. Printer.cpp: Fix printing out index and scale in memory references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/InstSelectSimple.cpp')
-rw-r--r--lib/Target/X86/InstSelectSimple.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp
index f8be684500..40d757b645 100644
--- a/lib/Target/X86/InstSelectSimple.cpp
+++ b/lib/Target/X86/InstSelectSimple.cpp
@@ -114,9 +114,10 @@ namespace {
abort();
}
- void promote32(unsigned targetReg, Value *V);
-
- // emitGEPOperation - Common code shared between visitGetElemenPtrInst and
+ /// promote32 - Make a value 32-bits wide, and put it somewhere.
+ void promote32 (const unsigned targetReg, Value *v);
+
+ // emitGEPOperation - Common code shared between visitGetElementPtrInst and
// constant expression GEP support.
//
void emitGEPOperation(Value *Src, User::op_iterator IdxBegin,
@@ -156,7 +157,25 @@ namespace {
// Move the address of the global into the register
BuildMI(BB, X86::MOVir32, 1, Reg).addReg(GV);
} else if (Argument *A = dyn_cast<Argument>(V)) {
- std::cerr << "ERROR: Arguments not implemented in SimpleInstSel\n";
+ // Find the position of the argument in the argument list.
+ const Function *f = F->getFunction ();
+ int counter = 0, argPosition = -1;
+ for (Function::const_aiterator ai = f->abegin (), ae = f->aend ();
+ ai != ae; ++ai) {
+ ++counter;
+ if (&(*ai) == A) {
+ argPosition = 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";
}
return Reg;