2004-04-14 04:55:49 +08:00
|
|
|
//===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===//
|
2005-04-22 08:00:37 +08:00
|
|
|
//
|
2004-04-14 04:55:49 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:37:13 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 08:00:37 +08:00
|
|
|
//
|
2004-04-14 04:55:49 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// fpcmp is a tool that basically works like the 'cmp' tool, except that it can
|
2005-01-23 11:15:47 +08:00
|
|
|
// tolerate errors due to floating point noise, with the -r and -a options.
|
2004-04-14 04:55:49 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-09-02 06:55:40 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2005-01-23 11:15:47 +08:00
|
|
|
#include "llvm/Support/FileUtilities.h"
|
2010-04-15 11:47:24 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2004-04-14 04:55:49 +08:00
|
|
|
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);
|
|
|
|
|
2005-01-23 11:15:47 +08:00
|
|
|
std::string ErrorMsg;
|
2013-06-14 04:41:00 +08:00
|
|
|
int DF = DiffFilesWithTolerance(File1, File2, AbsTolerance, RelTolerance,
|
|
|
|
&ErrorMsg);
|
2005-01-23 11:15:47 +08:00
|
|
|
if (!ErrorMsg.empty())
|
2010-04-15 11:47:24 +08:00
|
|
|
errs() << argv[0] << ": " << ErrorMsg << "\n";
|
2005-01-23 11:15:47 +08:00
|
|
|
return DF;
|
2004-04-14 04:55:49 +08:00
|
|
|
}
|
|
|
|
|