2002-08-09 20:08:03 +00:00
|
|
|
//===-- llvm/CodeGen/MachineInstrAnnot.h ------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// Annotations used to pass information between code generation phases.
|
2002-05-19 15:30:21 +00:00
|
|
|
//
|
2002-08-09 20:08:03 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-05-19 15:30:21 +00:00
|
|
|
|
|
|
|
#ifndef MACHINE_INSTR_ANNOT_h
|
|
|
|
#define MACHINE_INSTR_ANNOT_h
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2003-05-31 07:43:41 +00:00
|
|
|
#include "llvm/Target/TargetRegInfo.h"
|
2002-05-19 15:30:21 +00:00
|
|
|
|
|
|
|
class Value;
|
|
|
|
class TmpInstruction;
|
|
|
|
class CallInst;
|
|
|
|
|
|
|
|
class CallArgInfo {
|
|
|
|
// Flag values for different argument passing methods
|
|
|
|
static const unsigned char IntArgReg = 0x1;
|
|
|
|
static const unsigned char FPArgReg = 0x2;
|
|
|
|
static const unsigned char StackSlot = 0x4;
|
|
|
|
|
2003-05-31 07:43:41 +00:00
|
|
|
const Value* argVal; // this argument
|
|
|
|
int argCopyReg; // register used for second copy of arg. when
|
|
|
|
// multiple copies must be passed in registers
|
|
|
|
unsigned char passingMethod; // flags recording passing methods
|
2002-05-19 15:30:21 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Constructors
|
|
|
|
CallArgInfo(const Value* _argVal)
|
2003-05-31 07:43:41 +00:00
|
|
|
: argVal(_argVal), argCopyReg(TargetRegInfo::getInvalidRegNum()),
|
|
|
|
passingMethod(0x0) {}
|
2002-05-19 15:30:21 +00:00
|
|
|
|
|
|
|
CallArgInfo(const CallArgInfo& obj)
|
2003-05-31 07:43:41 +00:00
|
|
|
: argVal(obj.argVal), argCopyReg(obj.argCopyReg),
|
2002-05-19 15:30:21 +00:00
|
|
|
passingMethod(obj.passingMethod) {}
|
|
|
|
|
|
|
|
// Accessor methods
|
|
|
|
const Value* getArgVal() { return argVal; }
|
2003-05-31 07:43:41 +00:00
|
|
|
int getArgCopy() { return argCopyReg; }
|
2002-07-10 21:51:46 +00:00
|
|
|
bool usesIntArgReg() { return (bool) (passingMethod & IntArgReg);}
|
|
|
|
bool usesFPArgReg() { return (bool) (passingMethod & FPArgReg); }
|
|
|
|
bool usesStackSlot() { return (bool) (passingMethod & StackSlot);}
|
2002-05-19 15:30:21 +00:00
|
|
|
|
|
|
|
// Modifier methods
|
|
|
|
void replaceArgVal(const Value* newVal) { argVal = newVal; }
|
|
|
|
void setUseIntArgReg() { passingMethod |= IntArgReg; }
|
|
|
|
void setUseFPArgReg() { passingMethod |= FPArgReg; }
|
|
|
|
void setUseStackSlot() { passingMethod |= StackSlot; }
|
2003-05-31 07:43:41 +00:00
|
|
|
void setArgCopy(int copyReg) { argCopyReg = copyReg; }
|
2002-05-19 15:30:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-10-29 19:41:18 +00:00
|
|
|
class CallArgsDescriptor {
|
|
|
|
|
2002-08-09 20:08:03 +00:00
|
|
|
std::vector<CallArgInfo> argInfoVec; // Descriptor for each argument
|
2002-05-19 15:30:21 +00:00
|
|
|
const CallInst* callInstr; // The call instruction == result value
|
|
|
|
const Value* funcPtr; // Pointer for indirect calls
|
|
|
|
TmpInstruction* retAddrReg; // Tmp value for return address reg.
|
|
|
|
bool isVarArgs; // Is this a varargs call?
|
|
|
|
bool noPrototype; // Is this a call with no prototype?
|
|
|
|
|
|
|
|
public:
|
|
|
|
CallArgsDescriptor(const CallInst* _callInstr, TmpInstruction* _retAddrReg,
|
|
|
|
bool _isVarArgs, bool _noPrototype);
|
|
|
|
|
|
|
|
// Accessor methods to retrieve information about the call
|
|
|
|
// Note that operands are numbered 1..#CallArgs
|
|
|
|
unsigned int getNumArgs() const { return argInfoVec.size(); }
|
|
|
|
CallArgInfo& getArgInfo(unsigned int op) { assert(op < argInfoVec.size());
|
|
|
|
return argInfoVec[op]; }
|
2002-10-29 19:41:18 +00:00
|
|
|
const CallInst* getCallInst() const { return callInstr; }
|
2002-09-28 17:03:54 +00:00
|
|
|
const CallInst* getReturnValue() const;
|
2002-05-19 15:30:21 +00:00
|
|
|
const Value* getIndirectFuncPtr() const { return funcPtr; }
|
|
|
|
TmpInstruction* getReturnAddrReg() const { return retAddrReg; }
|
|
|
|
bool isVarArgsFunc() const { return isVarArgs; }
|
|
|
|
bool hasNoPrototype() const { return noPrototype; }
|
2002-09-28 17:03:54 +00:00
|
|
|
|
2002-10-29 19:41:18 +00:00
|
|
|
// Mechanism to get the descriptor for a CALL MachineInstr.
|
|
|
|
//
|
|
|
|
static CallArgsDescriptor *get(const MachineInstr* MI);
|
2002-05-19 15:30:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-07-25 15:00:45 +00:00
|
|
|
#endif
|