From 6f80b08c647c6b98bb2247df4ee64dd3ccc27b91 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 19 Aug 2016 17:47:05 +0000 Subject: GlobalISel: support translation of extractvalue instructions. llvm-svn: 279285 --- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp') diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index ac95b8262d9..ed0ce8d848b 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -182,6 +182,27 @@ bool IRTranslator::translateStore(const User &U) { return true; } +bool IRTranslator::translateExtractValue(const User &U) { + const ExtractValueInst &EVI = cast(U); + const Value *Src = EVI.getAggregateOperand(); + Type *Int32Ty = Type::getInt32Ty(EVI.getContext()); + SmallVector Indices; + + // getIndexedOffsetInType is designed for GEPs, so the first index is the + // usual array element rather than looking into the actual aggregate. + Indices.push_back(ConstantInt::get(Int32Ty, 0)); + for (auto Idx : EVI.indices()) + Indices.push_back(ConstantInt::get(Int32Ty, Idx)); + + uint64_t Offset = 8 * DL->getIndexedOffsetInType(Src->getType(), Indices); + + unsigned Res = getOrCreateVReg(EVI); + MIRBuilder.buildExtract(LLT{*EVI.getType()}, Res, getOrCreateVReg(*Src), + Offset); + + return true; +} + bool IRTranslator::translateBitCast(const User &U) { if (LLT{*U.getOperand(0)->getType()} == LLT{*U.getType()}) { unsigned &Reg = ValToVReg[&U]; -- cgit v1.2.3