Skip to content

Commit 380ba1c

Browse files
AmrDeveloperlanza
authored andcommitted
[CIR][CIRGen][Builtin][Neon] Lower neon_vsetq_lane_f64 (#1251)
Lowering Neon `vsetq_lane_f64` References: [Clang CGBuiltin Implementation](https://github.com/llvm/clangir/blob/2b1a638ea07ca10c5727ea835bfbe17b881175cc/clang/lib/CodeGen/CGBuiltin.cpp#L12348) [Builtin definition](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsetq_lane_f64)
1 parent 2f71d04 commit 380ba1c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3691,9 +3691,13 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
36913691
case NEON::BI__builtin_neon_vset_lane_f64:
36923692
// The vector type needs a cast for the v1f64 variant.
36933693
llvm_unreachable("NEON::BI__builtin_neon_vset_lane_f64 NYI");
3694-
case NEON::BI__builtin_neon_vsetq_lane_f64:
3695-
// The vector type needs a cast for the v2f64 variant.
3696-
llvm_unreachable("NEON::BI__builtin_neon_vsetq_lane_f64 NYI");
3694+
case NEON::BI__builtin_neon_vsetq_lane_f64: {
3695+
Ops.push_back(emitScalarExpr(E->getArg(2)));
3696+
Ops[1] = builder.createBitcast(
3697+
Ops[1], cir::VectorType::get(&getMLIRContext(), DoubleTy, 2));
3698+
return builder.create<cir::VecInsertOp>(getLoc(E->getExprLoc()), Ops[1],
3699+
Ops[0], Ops[2]);
3700+
}
36973701

36983702
case NEON::BI__builtin_neon_vget_lane_i8:
36993703
case NEON::BI__builtin_neon_vdupb_lane_i8:

clang/test/CIR/CodeGen/AArch64/neon-misc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ float32x4_t test_vsetq_lane_f32(float32_t a, float32x4_t b) {
137137
// LLVM: [[INTRN_RES:%.*]] = insertelement <4 x float> [[B]], float [[A]], i32 3
138138
// LLVM: ret <4 x float> [[INTRN_RES]]
139139

140+
float64x2_t test_vsetq_land_f64(float64_t a, float64x2_t b) {
141+
return vsetq_lane_f64(a, b, 0);
142+
}
143+
144+
// CIR-LABEL: test_vsetq_land_f64
145+
// CIR: [[IDX:%.*]] = cir.const #cir.int<0> : !s32i
146+
// CIR: {{%.*}} = cir.vec.insert {{%.*}}, {{%.*}}[[[IDX]] : !s32i] : !cir.vector<!cir.double x 2>
147+
148+
// LLVM: {{.*}}test_vsetq_land_f64(double{{.*}}[[A:%.*]], <2 x double>{{.*}}[[B:%.*]])
149+
// LLVM: [[INTRN_RES:%.*]] = insertelement <2 x double> [[B]], double [[A]], i32 0
150+
// LLVM: ret <2 x double> [[INTRN_RES]]
151+
140152
uint8_t test_vget_lane_u8(uint8x8_t a) {
141153
return vget_lane_u8(a, 7);
142154
}

0 commit comments

Comments
 (0)