X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FMachineInstrAnnot.cpp;h=9dd684c1cc06f087491bc4bd0bcfb8d42b88b26b;hb=3bba026994f01b2b5bdcdf4b628fa93a8ae9d6ef;hp=27cf7ad931ce76880fe0abd109c32c5bf7e017b5;hpb=a2bae305fb5a870c4ef753ed290a7ddea73ec82b;p=oota-llvm.git diff --git a/lib/CodeGen/MachineInstrAnnot.cpp b/lib/CodeGen/MachineInstrAnnot.cpp index 27cf7ad931c..9dd684c1cc0 100644 --- a/lib/CodeGen/MachineInstrAnnot.cpp +++ b/lib/CodeGen/MachineInstrAnnot.cpp @@ -1,19 +1,25 @@ //===-- MachineInstrAnnot.cpp ---------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file defines Annotations used to pass information between code // generation phases. // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/MachineInstrAnnot.h" -#include "llvm/CodeGen/InstrSelection.h" -#include "llvm/CodeGen/InstrSelectionSupport.h" +#include "../Target/SparcV9/MachineInstrAnnot.h" +#include "../Target/SparcV9/SparcV9TmpInstr.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" -#include "llvm/iOther.h" +#include "llvm/Instructions.h" #include "llvm/Type.h" +using namespace llvm; - -CallArgsDescriptor::CallArgsDescriptor(const CallInst* _callInstr, +CallArgsDescriptor::CallArgsDescriptor(CallInst* _callInstr, TmpInstruction* _retAddrReg, bool _isVarArgs, bool _noPrototype) : callInstr(_callInstr), @@ -21,8 +27,7 @@ CallArgsDescriptor::CallArgsDescriptor(const CallInst* _callInstr, ? NULL : _callInstr->getCalledValue()), retAddrReg(_retAddrReg), isVarArgs(_isVarArgs), - noPrototype(_noPrototype) -{ + noPrototype(_noPrototype) { unsigned int numArgs = callInstr->getNumOperands(); argInfoVec.reserve(numArgs); assert(callInstr->getOperand(0) == callInstr->getCalledValue() @@ -35,28 +40,29 @@ CallArgsDescriptor::CallArgsDescriptor(const CallInst* _callInstr, MachineCodeForInstruction::get(callInstr).setCallArgsDescriptor(this); } - -const CallInst* -CallArgsDescriptor::getReturnValue() const -{ +CallInst *CallArgsDescriptor::getReturnValue() const { return (callInstr->getType() == Type::VoidTy? NULL : callInstr); } - // Mechanism to get the descriptor for a CALL MachineInstr. // We get the LLVM CallInstr from the ret. addr. register argument -// of the CALL MachineInstr, then get the CallArgsDescriptor from the -// MachineCodeForInstruction object for the CallInstr. +// of the CALL MachineInstr (which is explicit operand #3 for indirect +// calls or the last implicit operand for direct calls). We then get +// the CallArgsDescriptor from the MachineCodeForInstruction object for +// the CallInstr. // This is roundabout but avoids adding a new map or annotation just // to keep track of CallArgsDescriptors. // -CallArgsDescriptor *CallArgsDescriptor::get(const MachineInstr* MI) -{ +CallArgsDescriptor *CallArgsDescriptor::get(const MachineInstr* MI) { const TmpInstruction* retAddrReg = - cast(MI->getImplicitRef(MI->getNumImplicitRefs()-1)); + cast(isa(MI->getOperand(0).getVRegValue()) + ? MI->getImplicitRef(MI->getNumImplicitRefs()-1) + : MI->getOperand(2).getVRegValue()); + assert(retAddrReg->getNumOperands() == 1 && isa(retAddrReg->getOperand(0)) && - "Order of implicit args of CALL instr. changed. FIX THIS CODE!"); + "Location of callInstr arg for CALL instr. changed? FIX THIS CODE!"); + const CallInst* callInstr = cast(retAddrReg->getOperand(0)); CallArgsDescriptor* desc =