blob: 13e68c042cf173261ec4f14effd4bb2df90365cb [file] [log] [blame]
Brian Gaeke03cac372004-04-25 07:04:49 +00001//===-- MachineInstrAnnot.h -------------------------------------*- C++ -*-===//
John Criswellb6445982003-10-20 20:19:47 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner02e7a862002-08-09 20:08:03 +00009//
Brian Gaeke03cac372004-04-25 07:04:49 +000010// Annotations used to pass information between SparcV9 code generation phases.
Vikram S. Adve1e454112002-05-19 15:30:21 +000011//
Chris Lattner02e7a862002-08-09 20:08:03 +000012//===----------------------------------------------------------------------===//
Vikram S. Adve1e454112002-05-19 15:30:21 +000013
Brian Gaeke03cac372004-04-25 07:04:49 +000014#ifndef MACHINEINSTRANNOT_H
15#define MACHINEINSTRANNOT_H
Vikram S. Adve1e454112002-05-19 15:30:21 +000016
Vikram S. Adve1e454112002-05-19 15:30:21 +000017#include "llvm/CodeGen/MachineInstr.h"
Brian Gaeke71509a92004-04-23 18:15:47 +000018#include "SparcV9RegInfo.h"
Vikram S. Adve1e454112002-05-19 15:30:21 +000019
Brian Gaeke960707c2003-11-11 22:41:34 +000020namespace llvm {
21
Vikram S. Adve1e454112002-05-19 15:30:21 +000022class Value;
23class TmpInstruction;
24class CallInst;
25
Vikram S. Adve1e454112002-05-19 15:30:21 +000026class CallArgInfo {
Vikram S. Adve1e454112002-05-19 15:30:21 +000027 // Flag values for different argument passing methods
28 static const unsigned char IntArgReg = 0x1;
29 static const unsigned char FPArgReg = 0x2;
30 static const unsigned char StackSlot = 0x4;
31
Vikram S. Advee2e50f22003-07-10 19:46:15 +000032 Value* argVal; // this argument
33 int argCopyReg; // register used for second copy of arg. when
Vikram S. Adve12067b652003-05-31 07:43:41 +000034 // multiple copies must be passed in registers
35 unsigned char passingMethod; // flags recording passing methods
Vikram S. Adve1e454112002-05-19 15:30:21 +000036
37public:
38 // Constructors
Vikram S. Advee2e50f22003-07-10 19:46:15 +000039 CallArgInfo(Value* _argVal)
Vikram S. Adve12067b652003-05-31 07:43:41 +000040 : argVal(_argVal), argCopyReg(TargetRegInfo::getInvalidRegNum()),
41 passingMethod(0x0) {}
Vikram S. Adve1e454112002-05-19 15:30:21 +000042
43 CallArgInfo(const CallArgInfo& obj)
Vikram S. Adve12067b652003-05-31 07:43:41 +000044 : argVal(obj.argVal), argCopyReg(obj.argCopyReg),
Vikram S. Adve1e454112002-05-19 15:30:21 +000045 passingMethod(obj.passingMethod) {}
46
47 // Accessor methods
Vikram S. Advee2e50f22003-07-10 19:46:15 +000048 Value* getArgVal() { return argVal; }
Vikram S. Adve12067b652003-05-31 07:43:41 +000049 int getArgCopy() { return argCopyReg; }
Vikram S. Adve72623d52002-07-10 21:51:46 +000050 bool usesIntArgReg() { return (bool) (passingMethod & IntArgReg);}
51 bool usesFPArgReg() { return (bool) (passingMethod & FPArgReg); }
52 bool usesStackSlot() { return (bool) (passingMethod & StackSlot);}
Vikram S. Adve1e454112002-05-19 15:30:21 +000053
54 // Modifier methods
Vikram S. Advee2e50f22003-07-10 19:46:15 +000055 void replaceArgVal(Value* newVal) { argVal = newVal; }
Vikram S. Adve1e454112002-05-19 15:30:21 +000056 void setUseIntArgReg() { passingMethod |= IntArgReg; }
57 void setUseFPArgReg() { passingMethod |= FPArgReg; }
58 void setUseStackSlot() { passingMethod |= StackSlot; }
Vikram S. Adve12067b652003-05-31 07:43:41 +000059 void setArgCopy(int copyReg) { argCopyReg = copyReg; }
Vikram S. Adve1e454112002-05-19 15:30:21 +000060};
61
62
Vikram S. Advea1b4f0f2002-10-29 19:41:18 +000063class CallArgsDescriptor {
64
Chris Lattner02e7a862002-08-09 20:08:03 +000065 std::vector<CallArgInfo> argInfoVec; // Descriptor for each argument
Vikram S. Advee2e50f22003-07-10 19:46:15 +000066 CallInst* callInstr; // The call instruction == result value
67 Value* funcPtr; // Pointer for indirect calls
Vikram S. Adve1e454112002-05-19 15:30:21 +000068 TmpInstruction* retAddrReg; // Tmp value for return address reg.
69 bool isVarArgs; // Is this a varargs call?
70 bool noPrototype; // Is this a call with no prototype?
71
72public:
Vikram S. Advee2e50f22003-07-10 19:46:15 +000073 CallArgsDescriptor(CallInst* _callInstr, TmpInstruction* _retAddrReg,
Vikram S. Adve1e454112002-05-19 15:30:21 +000074 bool _isVarArgs, bool _noPrototype);
75
76 // Accessor methods to retrieve information about the call
77 // Note that operands are numbered 1..#CallArgs
78 unsigned int getNumArgs() const { return argInfoVec.size(); }
79 CallArgInfo& getArgInfo(unsigned int op) { assert(op < argInfoVec.size());
80 return argInfoVec[op]; }
Vikram S. Advee2e50f22003-07-10 19:46:15 +000081 CallInst* getCallInst() const { return callInstr; }
82 CallInst* getReturnValue() const;
83 Value* getIndirectFuncPtr() const { return funcPtr; }
Vikram S. Adve1e454112002-05-19 15:30:21 +000084 TmpInstruction* getReturnAddrReg() const { return retAddrReg; }
85 bool isVarArgsFunc() const { return isVarArgs; }
86 bool hasNoPrototype() const { return noPrototype; }
Vikram S. Adve8076fe82002-09-28 17:03:54 +000087
Vikram S. Advea1b4f0f2002-10-29 19:41:18 +000088 // Mechanism to get the descriptor for a CALL MachineInstr.
89 //
90 static CallArgsDescriptor *get(const MachineInstr* MI);
Vikram S. Adve1e454112002-05-19 15:30:21 +000091};
92
Brian Gaeke960707c2003-11-11 22:41:34 +000093} // End llvm namespace
Vikram S. Adve1e454112002-05-19 15:30:21 +000094
Chris Lattner880cfed2002-07-25 15:00:45 +000095#endif