diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-11-15 01:34:59 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-11-15 01:34:59 +0000 |
commit | 59d3ae6cdc4316ad338cd848251f33a236ccb36c (patch) | |
tree | aec8d2396d4a436295845b109fb15b73279a2186 /lib/Bitcode | |
parent | 2b7fef0ad4bfaaf9fd41cda5abda35aab701b598 (diff) | |
download | external_llvm-59d3ae6cdc4316ad338cd848251f33a236ccb36c.zip external_llvm-59d3ae6cdc4316ad338cd848251f33a236ccb36c.tar.gz external_llvm-59d3ae6cdc4316ad338cd848251f33a236ccb36c.tar.bz2 |
Add addrspacecast instruction.
Patch by Michele Scandale!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 14 | ||||
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index d25b33e..e052e6e 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -128,6 +128,7 @@ static int GetDecodedCastOpcode(unsigned Val) { case bitc::CAST_PTRTOINT: return Instruction::PtrToInt; case bitc::CAST_INTTOPTR: return Instruction::IntToPtr; case bitc::CAST_BITCAST : return Instruction::BitCast; + case bitc::CAST_ADDRSPACECAST : return Instruction::AddrSpaceCast; } } static int GetDecodedBinaryOpcode(unsigned Val, Type *Ty) { @@ -1356,7 +1357,8 @@ error_code BitcodeReader::ParseConstants() { if (!OpTy) return Error(InvalidRecord); Constant *Op = ValueList.getConstantFwdRef(Record[2], OpTy); - V = ConstantExpr::getCast(Opc, Op, CurTy); + V = UpgradeBitCastExpr(Opc, Op, CurTy); + if (!V) V = ConstantExpr::getCast(Opc, Op, CurTy); } break; } @@ -2296,7 +2298,15 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) { int Opc = GetDecodedCastOpcode(Record[OpNum+1]); if (Opc == -1 || ResTy == 0) return Error(InvalidRecord); - I = CastInst::Create((Instruction::CastOps)Opc, Op, ResTy); + Instruction *Temp = 0; + if ((I = UpgradeBitCastInst(Opc, Op, ResTy, Temp))) { + if (Temp) { + InstructionList.push_back(Temp); + CurBB->getInstList().push_back(Temp); + } + } else { + I = CastInst::Create((Instruction::CastOps)Opc, Op, ResTy); + } InstructionList.push_back(I); break; } diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 6f7aa14..02ee917 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -78,6 +78,7 @@ static unsigned GetEncodedCastOpcode(unsigned Opcode) { case Instruction::PtrToInt: return bitc::CAST_PTRTOINT; case Instruction::IntToPtr: return bitc::CAST_INTTOPTR; case Instruction::BitCast : return bitc::CAST_BITCAST; + case Instruction::AddrSpaceCast : return bitc::CAST_ADDRSPACECAST; } } |