Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -4737,6 +4737,7 @@ class UnaryFPToFPBuiltinOp<string mnemonic, string llvmOpName>
let llvmOp = llvmOpName;
}

def ASinOp : UnaryFPToFPBuiltinOp<"asin", "ASinOp">;
def CeilOp : UnaryFPToFPBuiltinOp<"ceil", "FCeilOp">;
def CosOp : UnaryFPToFPBuiltinOp<"cos", "CosOp">;
def ExpOp : UnaryFPToFPBuiltinOp<"exp", "ExpOp">;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
return emitBuiltinWithOneOverloadedType<1>(E, "acos");
}
case Builtin::BI__builtin_elementwise_asin:
llvm_unreachable("BI__builtin_elementwise_asin NYI");
return emitUnaryFPBuiltin<cir::ASinOp>(*this, *E);
case Builtin::BI__builtin_elementwise_atan:
llvm_unreachable("BI__builtin_elementwise_atan NYI");
case Builtin::BI__builtin_elementwise_atan2:
Expand Down
21 changes: 21 additions & 0 deletions clang/test/CIR/CodeGen/builtins-elementwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ void test_builtin_elementwise_acos(float f, double d, vfloat4 vf4,
vd4 = __builtin_elementwise_acos(vd4);
}

void test_builtin_elementwise_asin(float f, double d, vfloat4 vf4,
vdouble4 vd4) {
// CIR-LABEL: test_builtin_elementwise_asin
// LLVM-LABEL: test_builtin_elementwise_asin
// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.float
// LLVM: {{%.*}} = call float @llvm.asin.f32(float {{%.*}})
f = __builtin_elementwise_asin(f);

// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.double
// LLVM: {{%.*}} = call double @llvm.asin.f64(double {{%.*}})
d = __builtin_elementwise_asin(d);

// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.vector<!cir.float x 4>
// LLVM: {{%.*}} = call <4 x float> @llvm.asin.v4f32(<4 x float> {{%.*}})
vf4 = __builtin_elementwise_asin(vf4);

// CIR: {{%.*}} = cir.asin {{%.*}} : !cir.vector<!cir.double x 4>
// LLVM: {{%.*}} = call <4 x double> @llvm.asin.v4f64(<4 x double> {{%.*}})
vd4 = __builtin_elementwise_asin(vd4);
}

void test_builtin_elementwise_exp(float f, double d, vfloat4 vf4,
vdouble4 vd4) {
// CIR-LABEL: test_builtin_elementwise_exp
Expand Down
Loading