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
3 changes: 2 additions & 1 deletion clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -4737,9 +4737,10 @@ class UnaryFPToFPBuiltinOp<string mnemonic, string llvmOpName>
let llvmOp = llvmOpName;
}

def ACosOp : UnaryFPToFPBuiltinOp<"acos", "ACosOp">;
def ASinOp : UnaryFPToFPBuiltinOp<"asin", "ASinOp">;
def ATanOp : UnaryFPToFPBuiltinOp<"atan", "ATanOp">;
def CeilOp : UnaryFPToFPBuiltinOp<"ceil", "FCeilOp">;
def ACosOp : UnaryFPToFPBuiltinOp<"acos", "ACosOp">;
def CosOp : UnaryFPToFPBuiltinOp<"cos", "CosOp">;
def ExpOp : UnaryFPToFPBuiltinOp<"exp", "ExpOp">;
def Exp2Op : UnaryFPToFPBuiltinOp<"exp2", "Exp2Op">;
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 @@ -1406,7 +1406,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin_elementwise_asin:
return emitUnaryFPBuiltin<cir::ASinOp>(*this, *E);
case Builtin::BI__builtin_elementwise_atan:
llvm_unreachable("BI__builtin_elementwise_atan NYI");
return emitUnaryFPBuiltin<cir::ATanOp>(*this, *E);
case Builtin::BI__builtin_elementwise_atan2:
llvm_unreachable("BI__builtin_elementwise_atan2 NYI");
case Builtin::BI__builtin_elementwise_ceil:
Expand Down
55 changes: 38 additions & 17 deletions clang/test/CIR/CodeGen/builtins-elementwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,44 @@ void test_builtin_elementwise_acos(float f, double d, vfloat4 vf4,

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);
// 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_atan(float f, double d, vfloat4 vf4,
vdouble4 vd4) {
// CIR-LABEL: test_builtin_elementwise_atan
// LLVM-LABEL: test_builtin_elementwise_atan
// CIR: {{%.*}} = cir.atan {{%.*}} : !cir.float
// LLVM: {{%.*}} = call float @llvm.atan.f32(float {{%.*}})
f = __builtin_elementwise_atan(f);

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

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

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

void test_builtin_elementwise_exp(float f, double d, vfloat4 vf4,
Expand Down
Loading