forked from OSchip/llvm-project
GlobalISel: Translate ConstantDataVector
Reviewers: qcolombet, aditya_nandakumar, dsanders, t.p.northover, javed.absar, ab Reviewed By: qcolombet, dsanders, ab Subscribers: dberris, rovka, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D30216 llvm-svn: 297670
This commit is contained in:
parent
e7d0fa68f3
commit
38a91a0de6
|
@ -1074,6 +1074,13 @@ bool IRTranslator::translate(const Constant &C, unsigned Reg) {
|
|||
Ops.push_back(getOrCreateVReg(Elt));
|
||||
}
|
||||
EntryBuilder.buildMerge(Reg, Ops);
|
||||
} else if (auto CV = dyn_cast<ConstantDataVector>(&C)) {
|
||||
std::vector<unsigned> Ops;
|
||||
for (unsigned i = 0; i < CV->getNumElements(); ++i) {
|
||||
Constant &Elt = *CV->getElementAsConstant(i);
|
||||
Ops.push_back(getOrCreateVReg(Elt));
|
||||
}
|
||||
EntryBuilder.buildMerge(Reg, Ops);
|
||||
} else if (auto CE = dyn_cast<ConstantExpr>(&C)) {
|
||||
switch(CE->getOpcode()) {
|
||||
#define HANDLE_INST(NUM, OPCODE, CLASS) \
|
||||
|
|
|
@ -1328,3 +1328,43 @@ define i32 @test_constantaggzerovector_v3i32() {
|
|||
%elt = extractelement <3 x i32> zeroinitializer, i32 1
|
||||
ret i32 %elt
|
||||
}
|
||||
|
||||
define <2 x i32> @test_constantdatavector_v2i32() {
|
||||
; CHECK-LABEL: name: test_constantdatavector_v2i32
|
||||
; CHECK: [[C1:%[0-9]+]](s32) = G_CONSTANT i32 1
|
||||
; CHECK: [[C2:%[0-9]+]](s32) = G_CONSTANT i32 2
|
||||
; CHECK: [[VEC:%[0-9]+]](<2 x s32>) = G_MERGE_VALUES [[C1]](s32), [[C2]](s32)
|
||||
; CHECK: %d0 = COPY [[VEC]](<2 x s32>)
|
||||
ret <2 x i32> <i32 1, i32 2>
|
||||
}
|
||||
|
||||
define i32 @test_constantdatavector_v3i32() {
|
||||
; CHECK-LABEL: name: test_constantdatavector_v3i32
|
||||
; CHECK: [[C1:%[0-9]+]](s32) = G_CONSTANT i32 1
|
||||
; CHECK: [[C2:%[0-9]+]](s32) = G_CONSTANT i32 2
|
||||
; CHECK: [[C3:%[0-9]+]](s32) = G_CONSTANT i32 3
|
||||
; CHECK: [[VEC:%[0-9]+]](<3 x s32>) = G_MERGE_VALUES [[C1]](s32), [[C2]](s32), [[C3]](s32)
|
||||
; CHECK: G_EXTRACT_VECTOR_ELT [[VEC]](<3 x s32>)
|
||||
%elt = extractelement <3 x i32> <i32 1, i32 2, i32 3>, i32 1
|
||||
ret i32 %elt
|
||||
}
|
||||
|
||||
define <4 x i32> @test_constantdatavector_v4i32() {
|
||||
; CHECK-LABEL: name: test_constantdatavector_v4i32
|
||||
; CHECK: [[C1:%[0-9]+]](s32) = G_CONSTANT i32 1
|
||||
; CHECK: [[C2:%[0-9]+]](s32) = G_CONSTANT i32 2
|
||||
; CHECK: [[C3:%[0-9]+]](s32) = G_CONSTANT i32 3
|
||||
; CHECK: [[C4:%[0-9]+]](s32) = G_CONSTANT i32 4
|
||||
; CHECK: [[VEC:%[0-9]+]](<4 x s32>) = G_MERGE_VALUES [[C1]](s32), [[C2]](s32), [[C3]](s32), [[C4]](s32)
|
||||
; CHECK: %q0 = COPY [[VEC]](<4 x s32>)
|
||||
ret <4 x i32> <i32 1, i32 2, i32 3, i32 4>
|
||||
}
|
||||
|
||||
define <2 x double> @test_constantdatavector_v2f64() {
|
||||
; CHECK-LABEL: name: test_constantdatavector_v2f64
|
||||
; CHECK: [[FC1:%[0-9]+]](s64) = G_FCONSTANT double 1.000000e+00
|
||||
; CHECK: [[FC2:%[0-9]+]](s64) = G_FCONSTANT double 2.000000e+00
|
||||
; CHECK: [[VEC:%[0-9]+]](<2 x s64>) = G_MERGE_VALUES [[FC1]](s64), [[FC2]](s64)
|
||||
; CHECK: %q0 = COPY [[VEC]](<2 x s64>)
|
||||
ret <2 x double> <double 1.0, double 2.0>
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue