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 @@ -4814,6 +4814,7 @@ def RoundOp : UnaryFPToFPBuiltinOp<"round", "RoundOp">;
def RoundEvenOp : UnaryFPToFPBuiltinOp<"roundeven", "RoundEvenOp">;
def SinOp : UnaryFPToFPBuiltinOp<"sin", "SinOp">;
def SqrtOp : UnaryFPToFPBuiltinOp<"sqrt", "SqrtOp">;
def TanOp : UnaryFPToFPBuiltinOp<"tan", "TanOp">;
def TruncOp : UnaryFPToFPBuiltinOp<"trunc", "FTruncOp">;

def AbsOp : CIR_Op<"abs", [Pure, SameOperandsAndResultType]> {
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,8 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin_tanf16:
case Builtin::BI__builtin_tanl:
case Builtin::BI__builtin_tanf128:
llvm_unreachable("Builtin::BItan like NYI");
assert(!cir::MissingFeatures::fastMathFlags());
return emitUnaryMaybeConstrainedFPBuiltin<cir::TanOp>(*this, *E);

case Builtin::BItanh:
case Builtin::BItanhf:
Expand Down
68 changes: 68 additions & 0 deletions clang/test/CIR/CodeGen/builtin-floating-point.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,74 @@ long double call_sqrtl(long double f) {
// LLVM: }
}

// tan

float my_tanf(float f) {
return __builtin_tanf(f);
// CHECK: cir.func @my_tanf
// CHECK: {{.+}} = cir.tan {{.+}} : !cir.float

// LLVM: define dso_local float @my_tanf(float %0)
// LLVM: %{{.+}} = call float @llvm.tan.f32(float %{{.+}})
// LLVM: }
}

double my_tan(double f) {
return __builtin_tan(f);
// CHECK: cir.func @my_tan
// CHECK: {{.+}} = cir.tan {{.+}} : !cir.double

// LLVM: define dso_local double @my_tan(double %0)
// LLVM: %{{.+}} = call double @llvm.tan.f64(double %{{.+}})
// LLVM: }
}

long double my_tanl(long double f) {
return __builtin_tanl(f);
// CHECK: cir.func @my_tanl
// CHECK: {{.+}} = cir.tan {{.+}} : !cir.long_double<!cir.f80>
// AARCH64: {{.+}} = cir.tan {{.+}} : !cir.long_double<!cir.double>

// LLVM: define dso_local x86_fp80 @my_tanl(x86_fp80 %0)
// LLVM: %{{.+}} = call x86_fp80 @llvm.tan.f80(x86_fp80 %{{.+}})
// LLVM: }
}

float tanf(float);
double tan(double);
long double tanl(long double);

float call_tanf(float f) {
return tanf(f);
// CHECK: cir.func @call_tanf
// CHECK: {{.+}} = cir.tan {{.+}} : !cir.float

// LLVM: define dso_local float @call_tanf(float %0)
// LLVM: %{{.+}} = call float @llvm.tan.f32(float %{{.+}})
// LLVM: }
}

double call_tan(double f) {
return tan(f);
// CHECK: cir.func @call_tan
// CHECK: {{.+}} = cir.tan {{.+}} : !cir.double

// LLVM: define dso_local double @call_tan(double %0)
// LLVM: %{{.+}} = call double @llvm.tan.f64(double %{{.+}})
// LLVM: }
}

long double call_tanl(long double f) {
return tanl(f);
// CHECK: cir.func @call_tanl
// CHECK: {{.+}} = cir.tan {{.+}} : !cir.long_double<!cir.f80>
// AARCH64: {{.+}} = cir.tan {{.+}} : !cir.long_double<!cir.double>

// LLVM: define dso_local x86_fp80 @call_tanl(x86_fp80 %0)
// LLVM: %{{.+}} = call x86_fp80 @llvm.tan.f80(x86_fp80 %{{.+}})
// LLVM: }
}

// trunc

float my_truncf(float f) {
Expand Down
Loading