2004-04-25 09:04:49 +02:00
|
|
|
//===-- MachineInstrAnnot.h -------------------------------------*- C++ -*-===//
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// 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.
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-09 22:08:03 +02:00
|
|
|
//
|
2004-04-25 09:04:49 +02:00
|
|
|
// Annotations used to pass information between SparcV9 code generation phases.
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2002-08-09 22:08:03 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-05-19 17:30:21 +02:00
|
|
|
|
2004-04-25 09:04:49 +02:00
|
|
|
#ifndef MACHINEINSTRANNOT_H
|
|
|
|
#define MACHINEINSTRANNOT_H
|
2002-05-19 17:30:21 +02:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2004-04-23 20:15:47 +02:00
|
|
|
#include "SparcV9RegInfo.h"
|
2002-05-19 17:30:21 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-05-19 17:30:21 +02: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;
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2003-07-10 21:46:15 +02:00
|
|
|
Value* argVal; // this argument
|
|
|
|
int argCopyReg; // register used for second copy of arg. when
|
2003-05-31 09:43:41 +02:00
|
|
|
// multiple copies must be passed in registers
|
|
|
|
unsigned char passingMethod; // flags recording passing methods
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-05-19 17:30:21 +02:00
|
|
|
public:
|
|
|
|
// Constructors
|
2003-07-10 21:46:15 +02:00
|
|
|
CallArgInfo(Value* _argVal)
|
2004-06-03 04:45:09 +02:00
|
|
|
: argVal(_argVal), argCopyReg(SparcV9RegInfo::getInvalidRegNum()),
|
2003-05-31 09:43:41 +02:00
|
|
|
passingMethod(0x0) {}
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-05-19 17:30:21 +02:00
|
|
|
CallArgInfo(const CallArgInfo& obj)
|
2003-05-31 09:43:41 +02:00
|
|
|
: argVal(obj.argVal), argCopyReg(obj.argCopyReg),
|
2002-05-19 17:30:21 +02:00
|
|
|
passingMethod(obj.passingMethod) {}
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-05-19 17:30:21 +02:00
|
|
|
// Accessor methods
|
2003-07-10 21:46:15 +02:00
|
|
|
Value* getArgVal() { return argVal; }
|
2003-05-31 09:43:41 +02:00
|
|
|
int getArgCopy() { return argCopyReg; }
|
2005-04-22 01:30:14 +02:00
|
|
|
bool usesIntArgReg() { return (bool) (passingMethod & IntArgReg);}
|
|
|
|
bool usesFPArgReg() { return (bool) (passingMethod & FPArgReg); }
|
|
|
|
bool usesStackSlot() { return (bool) (passingMethod & StackSlot);}
|
|
|
|
|
2002-05-19 17:30:21 +02:00
|
|
|
// Modifier methods
|
2003-07-10 21:46:15 +02:00
|
|
|
void replaceArgVal(Value* newVal) { argVal = newVal; }
|
2002-05-19 17:30:21 +02:00
|
|
|
void setUseIntArgReg() { passingMethod |= IntArgReg; }
|
|
|
|
void setUseFPArgReg() { passingMethod |= FPArgReg; }
|
|
|
|
void setUseStackSlot() { passingMethod |= StackSlot; }
|
2003-05-31 09:43:41 +02:00
|
|
|
void setArgCopy(int copyReg) { argCopyReg = copyReg; }
|
2002-05-19 17:30:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-10-29 20:41:18 +01:00
|
|
|
class CallArgsDescriptor {
|
|
|
|
|
2002-08-09 22:08:03 +02:00
|
|
|
std::vector<CallArgInfo> argInfoVec; // Descriptor for each argument
|
2003-07-10 21:46:15 +02:00
|
|
|
CallInst* callInstr; // The call instruction == result value
|
2005-04-22 01:30:14 +02:00
|
|
|
Value* funcPtr; // Pointer for indirect calls
|
2002-05-19 17:30:21 +02:00
|
|
|
TmpInstruction* retAddrReg; // Tmp value for return address reg.
|
|
|
|
bool isVarArgs; // Is this a varargs call?
|
|
|
|
bool noPrototype; // Is this a call with no prototype?
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-05-19 17:30:21 +02:00
|
|
|
public:
|
2003-07-10 21:46:15 +02:00
|
|
|
CallArgsDescriptor(CallInst* _callInstr, TmpInstruction* _retAddrReg,
|
2002-05-19 17:30:21 +02:00
|
|
|
bool _isVarArgs, bool _noPrototype);
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-05-19 17:30:21 +02:00
|
|
|
// 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]; }
|
2003-07-10 21:46:15 +02:00
|
|
|
CallInst* getCallInst() const { return callInstr; }
|
|
|
|
CallInst* getReturnValue() const;
|
|
|
|
Value* getIndirectFuncPtr() const { return funcPtr; }
|
2002-05-19 17:30:21 +02:00
|
|
|
TmpInstruction* getReturnAddrReg() const { return retAddrReg; }
|
|
|
|
bool isVarArgsFunc() const { return isVarArgs; }
|
|
|
|
bool hasNoPrototype() const { return noPrototype; }
|
2002-09-28 19:03:54 +02:00
|
|
|
|
2002-10-29 20:41:18 +01:00
|
|
|
// Mechanism to get the descriptor for a CALL MachineInstr.
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2002-10-29 20:41:18 +01:00
|
|
|
static CallArgsDescriptor *get(const MachineInstr* MI);
|
2002-05-19 17:30:21 +02:00
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
2002-05-19 17:30:21 +02:00
|
|
|
|
2002-07-25 17:00:45 +02:00
|
|
|
#endif
|