diff options
author | Shih-wei Liao <sliao@google.com> | 2010-02-10 11:10:31 -0800 |
---|---|---|
committer | Shih-wei Liao <sliao@google.com> | 2010-02-10 11:10:31 -0800 |
commit | e264f62ca09a8f65c87a46d562a4d0f9ec5d457e (patch) | |
tree | 59e3d57ef656cef79afa708ae0a3daf25cd91fcf /utils/fpcmp | |
download | external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.zip external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.gz external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.bz2 |
Check in LLVM r95781.
Diffstat (limited to 'utils/fpcmp')
-rw-r--r-- | utils/fpcmp/Makefile | 16 | ||||
-rw-r--r-- | utils/fpcmp/fpcmp.cpp | 43 |
2 files changed, 59 insertions, 0 deletions
diff --git a/utils/fpcmp/Makefile b/utils/fpcmp/Makefile new file mode 100644 index 0000000..fd2f747 --- /dev/null +++ b/utils/fpcmp/Makefile @@ -0,0 +1,16 @@ +##===- utils/fpcmp/Makefile --------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +TOOLNAME = fpcmp +USEDLIBS = LLVMSupport.a LLVMSystem.a +NO_INSTALL = 1 + +include $(LEVEL)/Makefile.common + diff --git a/utils/fpcmp/fpcmp.cpp b/utils/fpcmp/fpcmp.cpp new file mode 100644 index 0000000..66d8ab1 --- /dev/null +++ b/utils/fpcmp/fpcmp.cpp @@ -0,0 +1,43 @@ +//===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// fpcmp is a tool that basically works like the 'cmp' tool, except that it can +// tolerate errors due to floating point noise, with the -r and -a options. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" +#include <iostream> +using namespace llvm; + +namespace { + cl::opt<std::string> + File1(cl::Positional, cl::desc("<input file #1>"), cl::Required); + cl::opt<std::string> + File2(cl::Positional, cl::desc("<input file #2>"), cl::Required); + + cl::opt<double> + RelTolerance("r", cl::desc("Relative error tolerated"), cl::init(0)); + cl::opt<double> + AbsTolerance("a", cl::desc("Absolute error tolerated"), cl::init(0)); +} + +int main(int argc, char **argv) { + cl::ParseCommandLineOptions(argc, argv); + + std::string ErrorMsg; + int DF = DiffFilesWithTolerance(sys::PathWithStatus(File1), + sys::PathWithStatus(File2), + AbsTolerance, RelTolerance, &ErrorMsg); + if (!ErrorMsg.empty()) + std::cerr << argv[0] << ": " << ErrorMsg << "\n"; + return DF; +} + |