diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-04-08 01:17:59 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-04-08 01:17:59 +0000 |
| commit | 161e7cfc17ddad9867c6916ed9add3169da21919 (patch) | |
| tree | ec7bffc84e4c769c853e85d4b8d8a866a1815e32 | |
| parent | a348351da397170a075db21c9e614ba2cbec4f2e (diff) | |
| download | bcm5719-llvm-161e7cfc17ddad9867c6916ed9add3169da21919.tar.gz bcm5719-llvm-161e7cfc17ddad9867c6916ed9add3169da21919.zip | |
Add shufflevector reading support
llvm-svn: 27509
| -rw-r--r-- | llvm/lib/Bytecode/Reader/Reader.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp index 9f064468cad..d2acda0ed15 100644 --- a/llvm/lib/Bytecode/Reader/Reader.cpp +++ b/llvm/lib/Bytecode/Reader/Reader.cpp @@ -734,6 +734,20 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds, getValue(Type::UIntTyID, Oprnds[2])); break; } + case Instruction::ShuffleVector: { + const PackedType *PackedTy = dyn_cast<PackedType>(InstTy); + if (!PackedTy || Oprnds.size() != 3) + throw std::string("Invalid shufflevector instruction!"); + Value *V1 = getValue(iType, Oprnds[0]); + Value *V2 = getValue(iType, Oprnds[1]); + const PackedType *EltTy = + PackedType::get(Type::UIntTy, PackedTy->getNumElements()); + Value *V3 = getValue(getTypeSlot(EltTy), Oprnds[2]); + if (!ShuffleVectorInst::isValidOperands(V1, V2, V3)) + throw std::string("Invalid shufflevector instruction!"); + Result = new ShuffleVectorInst(V1, V2, V3); + break; + } case Instruction::Cast: Result = new CastInst(getValue(iType, Oprnds[0]), getSanitizedType(Oprnds[1])); @@ -1493,6 +1507,14 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { ConstantExpr::getInsertElement(ArgVec[0], ArgVec[1], ArgVec[2]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; + } else if (Opcode == Instruction::ShuffleVector) { + if (ArgVec.size() != 3 || + !ShuffleVectorInst::isValidOperands(ArgVec[0], ArgVec[1], ArgVec[2])) + error("shufflevector constant expr must have three arguments."); + Constant *Result = + ConstantExpr::getShuffleVector(ArgVec[0], ArgVec[1], ArgVec[2]); + if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); + return Result; } else { // All other 2-operand expressions Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); |

