[PATCH] D30216: GlobalISel: Translate ConstantDataVector
Volkan Keles via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 10:38:20 PST 2017
volkan created this revision.
Herald added subscribers: kristof.beyls, rovka, dberris.
Herald added a reviewer: javed.absar.
https://reviews.llvm.org/D30216
Files:
lib/CodeGen/GlobalISel/IRTranslator.cpp
test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
Index: test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
===================================================================
--- test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
+++ test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
@@ -1189,3 +1189,13 @@
ret void
}
+
+define <2 x i32> @test_constant_datavector() {
+; CHECK-LABEL: name: test_constant_datavector
+; CHECK: [[ONE:%[0-9]+]](s32) = G_CONSTANT i32 1
+; CHECK: [[TWO:%[0-9]+]](s32) = G_CONSTANT i32 2
+; CHECK: [[RES:%[0-9]+]](<2 x s32>) = G_SEQUENCE [[ONE]](s32), 0, [[TWO]](s32), 32
+; CHECK: %d0 = COPY [[RES]](<2 x s32>)
+entry:
+ ret <2 x i32> <i32 1, i32 2>
+}
Index: lib/CodeGen/GlobalISel/IRTranslator.cpp
===================================================================
--- lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -979,7 +979,16 @@
EntryBuilder.buildConstant(Reg, 0);
else if (auto GV = dyn_cast<GlobalValue>(&C))
EntryBuilder.buildGlobalValue(Reg, GV);
- else if (auto CE = dyn_cast<ConstantExpr>(&C)) {
+ else if (auto CV = dyn_cast<ConstantDataVector>(&C)) {
+ std::vector<unsigned> Ops;
+ std::vector<uint64_t> Indices;
+ for (unsigned i = 0; i < CV->getNumElements(); ++i) {
+ Constant &Elt = *CV->getElementAsConstant(i);
+ Ops.push_back(getOrCreateVReg(Elt));
+ Indices.push_back(i * (CV->getElementByteSize() * 8));
+ }
+ EntryBuilder.buildSequence(Reg, Ops, Indices);
+ } else if (auto CE = dyn_cast<ConstantExpr>(&C)) {
switch(CE->getOpcode()) {
#define HANDLE_INST(NUM, OPCODE, CLASS) \
case Instruction::OPCODE: return translate##OPCODE(*CE, EntryBuilder);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30216.89242.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170221/ae198827/attachment.bin>
More information about the llvm-commits
mailing list