summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-08-19 17:47:05 +0000
committerTim Northover <tnorthover@apple.com>2016-08-19 17:47:05 +0000
commit6f80b08c647c6b98bb2247df4ee64dd3ccc27b91 (patch)
treed883e948ef4c6e2405c4d70a2cdba22f8a83a2f3 /llvm/lib/CodeGen
parente309d2d0c3d28e79fe61a9c65be2eeb424d328a1 (diff)
downloadbcm5719-llvm-6f80b08c647c6b98bb2247df4ee64dd3ccc27b91.tar.gz
bcm5719-llvm-6f80b08c647c6b98bb2247df4ee64dd3ccc27b91.zip
GlobalISel: support translation of extractvalue instructions.
llvm-svn: 279285
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp21
-rw-r--r--llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp2
-rw-r--r--llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp2
3 files changed, 23 insertions, 2 deletions
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<ExtractValueInst>(U);
+ const Value *Src = EVI.getAggregateOperand();
+ Type *Int32Ty = Type::getInt32Ty(EVI.getContext());
+ SmallVector<Value *, 1> 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];
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index 92dbab05e03..0ee70999b08 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -143,7 +143,7 @@ MachineInstrBuilder MachineIRBuilder::buildAnyExtend(LLT Ty, unsigned Res,
MachineInstrBuilder
MachineIRBuilder::buildExtract(LLT Ty, ArrayRef<unsigned> Results, unsigned Src,
- ArrayRef<unsigned> Indexes) {
+ ArrayRef<uint64_t> Indexes) {
assert(Results.size() == Indexes.size() && "inconsistent number of regs");
MachineInstrBuilder MIB = buildInstr(TargetOpcode::G_EXTRACT, Ty);
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp b/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp
index d999fbe8892..6d2d1057a6b 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp
@@ -51,7 +51,7 @@ MachineLegalizeHelper::LegalizeResult MachineLegalizeHelper::legalizeInstr(
void MachineLegalizeHelper::extractParts(unsigned Reg, LLT Ty, int NumParts,
SmallVectorImpl<unsigned> &VRegs) {
unsigned Size = Ty.getSizeInBits();
- SmallVector<unsigned, 4> Indexes;
+ SmallVector<uint64_t, 4> Indexes;
for (int i = 0; i < NumParts; ++i) {
VRegs.push_back(MRI.createGenericVirtualRegister(Size));
Indexes.push_back(i * Size);
OpenPOWER on IntegriCloud