From 15c13d3e63d7745bccad74d547af4e3482193eaa Mon Sep 17 00:00:00 2001 From: Michael Ilseman Date: Tue, 27 Nov 2012 00:42:44 +0000 Subject: Fast-math flags for LLVM IR parsing and printing Added in the ability to read LLVM IR text that contains fast-math flags as a sequence of capital letters separated by spaces in any order. Added in the printing of the fast-math flags in a canonical order, and don't print the other flags when 'fast' is specified, as 'fast' implies all the others. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168645 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AsmWriter.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/VMCore') diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index c45a04f..433f3e0 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -703,6 +703,22 @@ static void writeAtomicRMWOperation(raw_ostream &Out, } static void WriteOptimizationInfo(raw_ostream &Out, const User *U) { + if (const FPMathOperator *FPO = dyn_cast(U)) { + // Unsafe algebra implies all the others, no need to write them all out + if (FPO->hasUnsafeAlgebra()) + Out << " fast"; + else { + if (FPO->hasNoNaNs()) + Out << " nnan"; + if (FPO->hasNoInfs()) + Out << " ninf"; + if (FPO->hasNoSignedZeros()) + Out << " nsz"; + if (FPO->hasAllowReciprocal()) + Out << " arcp"; + } + } + if (const OverflowingBinaryOperator *OBO = dyn_cast(U)) { if (OBO->hasNoUnsignedWrap()) -- cgit v1.1