// If this operand is a constant, emit the code to copy the constant into
// the register here...
//
- if (Constant *C = dyn_cast<Constant>(V))
+ if (Constant *C = dyn_cast<Constant>(V)) {
copyConstantToRegister(C, Reg);
+ } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
+ // 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";
+ } else {
+ assert(0 && "Don't know how to handle a value of this type!");
+ }
return Reg;
}
{
// Push the arguments on the stack in reverse order, as specified by
// the ABI.
- for (unsigned i = CI.getNumOperands (); i >= 1; --i)
+ for (unsigned i = CI.getNumOperands()-1; i >= 1; --i)
{
Value *v = CI.getOperand (i);
- unsigned argReg = getReg (v);
switch (getClass (v->getType ()))
{
case cByte:
BuildMI (BB, X86::PUSHr32, 1).addReg (X86::EAX);
break;
case cInt:
- case cFloat:
- BuildMI (BB, X86::PUSHr32, 1).addReg (argReg);
+ case cFloat: {
+ unsigned Reg = getReg(v);
+ BuildMI (BB, X86::PUSHr32, 1).addReg(Reg);
break;
+ }
default:
// FIXME: long/ulong/double args not handled.
visitInstruction (CI);