LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MachineInstrAnnot.h

Go to the documentation of this file.
00001 //===-- MachineInstrAnnot.h -------------------------------------*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // Annotations used to pass information between SparcV9 code generation phases.
00011 // 
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef MACHINEINSTRANNOT_H
00015 #define MACHINEINSTRANNOT_H
00016 
00017 #include "llvm/CodeGen/MachineInstr.h"
00018 #include "SparcV9RegInfo.h"
00019 
00020 namespace llvm {
00021 
00022 class Value;
00023 class TmpInstruction;
00024 class CallInst;
00025 
00026 class CallArgInfo {
00027   // Flag values for different argument passing methods
00028   static const unsigned char IntArgReg = 0x1;
00029   static const unsigned char FPArgReg  = 0x2;
00030   static const unsigned char StackSlot = 0x4;
00031   
00032   Value*        argVal;         // this argument
00033   int           argCopyReg;     // register used for second copy of arg. when
00034                                 // multiple  copies must be passed in registers
00035   unsigned char passingMethod;  // flags recording passing methods
00036   
00037 public:
00038   // Constructors
00039   CallArgInfo(Value* _argVal)
00040     : argVal(_argVal), argCopyReg(SparcV9RegInfo::getInvalidRegNum()),
00041       passingMethod(0x0) {}
00042   
00043   CallArgInfo(const CallArgInfo& obj)
00044     : argVal(obj.argVal), argCopyReg(obj.argCopyReg),
00045       passingMethod(obj.passingMethod) {}
00046   
00047   // Accessor methods
00048   Value*        getArgVal()       { return argVal; }
00049   int           getArgCopy()      { return argCopyReg; }
00050   bool          usesIntArgReg()   { return (bool) (passingMethod & IntArgReg);} 
00051   bool          usesFPArgReg()    { return (bool) (passingMethod & FPArgReg); } 
00052   bool          usesStackSlot()   { return (bool) (passingMethod & StackSlot);} 
00053   
00054   // Modifier methods
00055   void          replaceArgVal(Value* newVal) { argVal = newVal; }
00056   void          setUseIntArgReg() { passingMethod |= IntArgReg; }
00057   void          setUseFPArgReg()  { passingMethod |= FPArgReg; }
00058   void          setUseStackSlot() { passingMethod |= StackSlot; }
00059   void          setArgCopy(int copyReg) { argCopyReg = copyReg; }
00060 };
00061 
00062 
00063 class CallArgsDescriptor {
00064 
00065   std::vector<CallArgInfo> argInfoVec;  // Descriptor for each argument
00066   CallInst* callInstr;                  // The call instruction == result value
00067   Value* funcPtr;                       // Pointer for indirect calls 
00068   TmpInstruction* retAddrReg;           // Tmp value for return address reg.
00069   bool isVarArgs;                       // Is this a varargs call?
00070   bool noPrototype;                     // Is this a call with no prototype?
00071   
00072 public:
00073   CallArgsDescriptor(CallInst* _callInstr, TmpInstruction* _retAddrReg,
00074                      bool _isVarArgs, bool _noPrototype);
00075   
00076   // Accessor methods to retrieve information about the call
00077   // Note that operands are numbered 1..#CallArgs
00078   unsigned int    getNumArgs() const          { return argInfoVec.size(); }
00079   CallArgInfo&    getArgInfo(unsigned int op) { assert(op < argInfoVec.size());
00080                                                 return argInfoVec[op]; }
00081   CallInst*       getCallInst() const         { return callInstr; }
00082   CallInst*       getReturnValue() const;
00083   Value*          getIndirectFuncPtr() const  { return funcPtr; }
00084   TmpInstruction* getReturnAddrReg() const    { return retAddrReg; }
00085   bool            isVarArgsFunc() const       { return isVarArgs; }
00086   bool            hasNoPrototype() const      { return noPrototype; }
00087 
00088   // Mechanism to get the descriptor for a CALL MachineInstr.
00089   // 
00090   static CallArgsDescriptor *get(const MachineInstr* MI);
00091 };
00092 
00093 } // End llvm namespace
00094 
00095 #endif