From a2bae305fb5a870c4ef753ed290a7ddea73ec82b Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Tue, 29 Oct 2002 19:41:18 +0000 Subject: Remove separate vector of implicit refs from MachineInstr, and instead record them as extra operands in the operands[] vector. Also, move CallArgsDescriptor into this class instead of making it an annotation on the machine instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4399 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineInstrAnnot.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/MachineInstrAnnot.cpp') diff --git a/lib/CodeGen/MachineInstrAnnot.cpp b/lib/CodeGen/MachineInstrAnnot.cpp index b4809a6be8..27cf7ad931 100644 --- a/lib/CodeGen/MachineInstrAnnot.cpp +++ b/lib/CodeGen/MachineInstrAnnot.cpp @@ -6,18 +6,17 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineInstrAnnot.h" -#include "llvm/Annotation.h" +#include "llvm/CodeGen/InstrSelection.h" +#include "llvm/CodeGen/InstrSelectionSupport.h" +#include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/iOther.h" #include "llvm/Type.h" -AnnotationID CallArgsDescriptor::AID(AnnotationManager:: - getID("CodeGen::CallArgsDescriptor")); CallArgsDescriptor::CallArgsDescriptor(const CallInst* _callInstr, TmpInstruction* _retAddrReg, bool _isVarArgs, bool _noPrototype) - : Annotation(AID), - callInstr(_callInstr), + : callInstr(_callInstr), funcPtr(isa(_callInstr->getCalledValue()) ? NULL : _callInstr->getCalledValue()), retAddrReg(_retAddrReg), @@ -30,6 +29,10 @@ CallArgsDescriptor::CallArgsDescriptor(const CallInst* _callInstr, && "Operand 0 is ignored in the loop below!"); for (unsigned int i=1; i < numArgs; ++i) argInfoVec.push_back(CallArgInfo(callInstr->getOperand(i))); + + // Enter this object in the MachineCodeForInstr object of the CallInst. + // This transfers ownership of this object. + MachineCodeForInstruction::get(callInstr).setCallArgsDescriptor(this); } @@ -38,3 +41,26 @@ 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. +// This is roundabout but avoids adding a new map or annotation just +// to keep track of CallArgsDescriptors. +// +CallArgsDescriptor *CallArgsDescriptor::get(const MachineInstr* MI) +{ + const TmpInstruction* retAddrReg = + cast(MI->getImplicitRef(MI->getNumImplicitRefs()-1)); + assert(retAddrReg->getNumOperands() == 1 && + isa(retAddrReg->getOperand(0)) && + "Order of implicit args of CALL instr. changed. FIX THIS CODE!"); + const CallInst* callInstr = cast(retAddrReg->getOperand(0)); + + CallArgsDescriptor* desc = + MachineCodeForInstruction::get(callInstr).getCallArgsDescriptor(); + assert(desc->getCallInst()==callInstr && "Incorrect call args descriptor?"); + return desc; +} -- cgit v1.2.3