diff options
author | Devang Patel <dpatel@apple.com> | 2008-02-19 22:15:16 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-02-19 22:15:16 +0000 |
commit | 295711f5832c892816511bd8560dad95ff90bcbf (patch) | |
tree | 2dc721a37d37c1c287fdb5742f5f21bea24f7df6 /llvm/lib/VMCore/Instructions.cpp | |
parent | ca0fd02cdd4af05845d5fa21afd113dfc7c02138 (diff) | |
download | bcm5719-llvm-295711f5832c892816511bd8560dad95ff90bcbf.tar.gz bcm5719-llvm-295711f5832c892816511bd8560dad95ff90bcbf.zip |
Add GetResultInst. First step for multiple return value support.
llvm-svn: 47348
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 863f011cd07..959ac9b6174 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -2698,6 +2698,29 @@ void SwitchInst::setSuccessorV(unsigned idx, BasicBlock *B) { setSuccessor(idx, B); } +//===----------------------------------------------------------------------===// +// GetResultInst Implementation +//===----------------------------------------------------------------------===// + +GetResultInst::GetResultInst(Value *Aggr, Value *Index, + const std::string &Name, + Instruction *InsertBef) + : Instruction(Aggr->getType(), + GetResult, Ops, 2, InsertBef) { + assert(isValidOperands(Aggr, Index) && "Invalid GetResultInst operands!"); + Ops[0].init(Aggr, this); + Ops[1].init(Index, this); + setName(Name); +} + +bool GetResultInst::isValidOperands(const Value *Aggr, const Value *Index) { + if (!Aggr || !Index) + return false; + if (!isa<StructType>(Aggr->getType()) || Index->getType() != Type::Int32Ty) + return false; + return true; +} + // Define these methods here so vtables don't get emitted into every translation // unit that uses these classes. @@ -2754,3 +2777,4 @@ SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); } InvokeInst *InvokeInst::clone() const { return new InvokeInst(*this); } UnwindInst *UnwindInst::clone() const { return new UnwindInst(); } UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();} +GetResultInst *GetResultInst::clone() const { return new GetResultInst(*this); } |