diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-28 06:56:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-28 06:56:37 +0000 |
commit | fb39f99fa4cdeab24c1b462cdd954a7d792323b7 (patch) | |
tree | 4439dbf586a50a50242909e113b23062ae732fcf /lib/CodeGen/SelectionDAG/CallingConvLower.cpp | |
parent | e5876ce21a23aeef913b25ffc09ad3829e6ade1e (diff) |
add methods to analyze calls and formals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34736 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/CallingConvLower.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/CallingConvLower.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp index b045fcb818..3b3fa3ba27 100644 --- a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp +++ b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/CallingConvLower.h" +#include "llvm/CodeGen/SelectionDAGNodes.h" #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetMachine.h" using namespace llvm; @@ -35,3 +36,36 @@ void CCState::MarkAllocated(unsigned Reg) { for (; (Reg = *RegAliases); ++RegAliases) UsedRegs[Reg/32] |= 1 << (Reg&31); } + +/// AnalyzeCallOperands - Analyze an ISD::CALL node, incorporating info +/// about the passed values into this state. +void CCState::AnalyzeCallOperands(SDNode *TheCall, CCAssignFn Fn) { + unsigned NumOps = (TheCall->getNumOperands() - 5) / 2; + for (unsigned i = 0; i != NumOps; ++i) { + MVT::ValueType ArgVT = TheCall->getOperand(5+2*i).getValueType(); + SDOperand FlagOp = TheCall->getOperand(5+2*i+1); + unsigned ArgFlags =cast<ConstantSDNode>(FlagOp)->getValue(); + if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) { + cerr << "Call operand #" << i << " has unhandled type " + << MVT::getValueTypeString(ArgVT) << "\n"; + abort(); + } + } +} + +/// AnalyzeFormalArguments - Analyze an ISD::FORMAL_ARGUMENTS node, +/// incorporating info about the formals into this state. +void CCState::AnalyzeFormalArguments(SDNode *TheArgs, CCAssignFn Fn) { + unsigned NumArgs = TheArgs->getNumValues()-1; + + for (unsigned i = 0; i != NumArgs; ++i) { + MVT::ValueType ArgVT = TheArgs->getValueType(i); + SDOperand FlagOp = TheArgs->getOperand(3+i); + unsigned ArgFlags = cast<ConstantSDNode>(FlagOp)->getValue(); + if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) { + cerr << "Formal argument #" << i << " has unhandled type " + << MVT::getValueTypeString(ArgVT) << "\n"; + abort(); + } + } +} |