Skip to content

Commit beccc39

Browse files
ayokunle321lanza
authored andcommitted
[CIR][CodeGen] Support for __builtin_elementwise_asin (#1511)
Sub-issue of #1192. Adds CIR_ASinOp and support for __builtin_elementwise_asin.
1 parent 49be891 commit beccc39

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4737,6 +4737,7 @@ class UnaryFPToFPBuiltinOp<string mnemonic, string llvmOpName>
47374737
let llvmOp = llvmOpName;
47384738
}
47394739

4740+
def ASinOp : UnaryFPToFPBuiltinOp<"asin", "ASinOp">;
47404741
def CeilOp : UnaryFPToFPBuiltinOp<"ceil", "FCeilOp">;
47414742
def ACosOp : UnaryFPToFPBuiltinOp<"acos", "ACosOp">;
47424743
def CosOp : UnaryFPToFPBuiltinOp<"cos", "CosOp">;

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
14041404
return emitUnaryFPBuiltin<cir::ACosOp>(*this, *E);
14051405
}
14061406
case Builtin::BI__builtin_elementwise_asin:
1407-
llvm_unreachable("BI__builtin_elementwise_asin NYI");
1407+
return emitUnaryFPBuiltin<cir::ASinOp>(*this, *E);
14081408
case Builtin::BI__builtin_elementwise_atan:
14091409
llvm_unreachable("BI__builtin_elementwise_atan NYI");
14101410
case Builtin::BI__builtin_elementwise_atan2:

clang/test/CIR/CodeGen/builtins-elementwise.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@ void test_builtin_elementwise_acos(float f, double d, vfloat4 vf4,
5858
vd4 = __builtin_elementwise_acos(vd4);
5959
}
6060

61+
void test_builtin_elementwise_asin(float f, double d, vfloat4 vf4,
62+
vdouble4 vd4) {
63+
// CIR-LABEL: test_builtin_elementwise_asin
64+
// LLVM-LABEL: test_builtin_elementwise_asin
65+
// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.float
66+
// LLVM: {{%.*}} = call float @llvm.asin.f32(float {{%.*}})
67+
f = __builtin_elementwise_asin(f);
68+
69+
// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.double
70+
// LLVM: {{%.*}} = call double @llvm.asin.f64(double {{%.*}})
71+
d = __builtin_elementwise_asin(d);
72+
73+
// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.vector<!cir.float x 4>
74+
// LLVM: {{%.*}} = call <4 x float> @llvm.asin.v4f32(<4 x float> {{%.*}})
75+
vf4 = __builtin_elementwise_asin(vf4);
76+
77+
// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.vector<!cir.double x 4>
78+
// LLVM: {{%.*}} = call <4 x double> @llvm.asin.v4f64(<4 x double> {{%.*}})
79+
vd4 = __builtin_elementwise_asin(vd4);
80+
}
81+
6182
void test_builtin_elementwise_exp(float f, double d, vfloat4 vf4,
6283
vdouble4 vd4) {
6384
// CIR-LABEL: test_builtin_elementwise_exp

0 commit comments

Comments
 (0)