This revision was automatically updated to reflect the committed changes. Closed by commit rL283251: [clang] make reciprocal estimate codegen a function attribute (authored by spatel).
Changed prior to commit: https://reviews.llvm.org/D24815?vs=73364&id=73548#toc Repository: rL LLVM https://reviews.llvm.org/D24815 Files: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/test/CodeGen/attr-mrecip.c Index: cfe/trunk/test/CodeGen/attr-mrecip.c =================================================================== --- cfe/trunk/test/CodeGen/attr-mrecip.c +++ cfe/trunk/test/CodeGen/attr-mrecip.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -mrecip=!sqrtf,vec-divf:3 -emit-llvm %s -o - | FileCheck %s + +int baz(int a) { return 4; } + +// CHECK: baz{{.*}} #0 +// CHECK: #0 = {{.*}}"reciprocal-estimates"="!sqrtf,vec-divf:3" + Index: cfe/trunk/lib/CodeGen/CGCall.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGCall.cpp +++ cfe/trunk/lib/CodeGen/CGCall.cpp @@ -1730,6 +1730,9 @@ FuncAttrs.addAttribute("no-trapping-math", llvm::toStringRef(CodeGenOpts.NoTrappingMath)); + + // TODO: Are these all needed? + // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags. FuncAttrs.addAttribute("no-infs-fp-math", llvm::toStringRef(CodeGenOpts.NoInfsFPMath)); FuncAttrs.addAttribute("no-nans-fp-math", @@ -1746,6 +1749,12 @@ "correctly-rounded-divide-sqrt-fp-math", llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt)); + // TODO: Reciprocal estimate codegen options should apply to instructions? + std::vector<std::string> &Recips = getTarget().getTargetOpts().Reciprocals; + if (!Recips.empty()) + FuncAttrs.addAttribute("reciprocal-estimates", + llvm::join(Recips.begin(), Recips.end(), ",")); + if (CodeGenOpts.StackRealignment) FuncAttrs.addAttribute("stackrealign"); if (CodeGenOpts.Backchain) Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp =================================================================== --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp @@ -533,9 +533,6 @@ llvm::TargetOptions Options; - if (!TargetOpts.Reciprocals.empty()) - Options.Reciprocals = TargetRecip(TargetOpts.Reciprocals); - Options.ThreadModel = llvm::StringSwitch<llvm::ThreadModel::Model>(CodeGenOpts.ThreadModel) .Case("posix", llvm::ThreadModel::POSIX)
Index: cfe/trunk/test/CodeGen/attr-mrecip.c =================================================================== --- cfe/trunk/test/CodeGen/attr-mrecip.c +++ cfe/trunk/test/CodeGen/attr-mrecip.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -mrecip=!sqrtf,vec-divf:3 -emit-llvm %s -o - | FileCheck %s + +int baz(int a) { return 4; } + +// CHECK: baz{{.*}} #0 +// CHECK: #0 = {{.*}}"reciprocal-estimates"="!sqrtf,vec-divf:3" + Index: cfe/trunk/lib/CodeGen/CGCall.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGCall.cpp +++ cfe/trunk/lib/CodeGen/CGCall.cpp @@ -1730,6 +1730,9 @@ FuncAttrs.addAttribute("no-trapping-math", llvm::toStringRef(CodeGenOpts.NoTrappingMath)); + + // TODO: Are these all needed? + // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags. FuncAttrs.addAttribute("no-infs-fp-math", llvm::toStringRef(CodeGenOpts.NoInfsFPMath)); FuncAttrs.addAttribute("no-nans-fp-math", @@ -1746,6 +1749,12 @@ "correctly-rounded-divide-sqrt-fp-math", llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt)); + // TODO: Reciprocal estimate codegen options should apply to instructions? + std::vector<std::string> &Recips = getTarget().getTargetOpts().Reciprocals; + if (!Recips.empty()) + FuncAttrs.addAttribute("reciprocal-estimates", + llvm::join(Recips.begin(), Recips.end(), ",")); + if (CodeGenOpts.StackRealignment) FuncAttrs.addAttribute("stackrealign"); if (CodeGenOpts.Backchain) Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp =================================================================== --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp @@ -533,9 +533,6 @@ llvm::TargetOptions Options; - if (!TargetOpts.Reciprocals.empty()) - Options.Reciprocals = TargetRecip(TargetOpts.Reciprocals); - Options.ThreadModel = llvm::StringSwitch<llvm::ThreadModel::Model>(CodeGenOpts.ThreadModel) .Case("posix", llvm::ThreadModel::POSIX)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits