mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
ae65e281f3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
91 lines
2.6 KiB
C++
91 lines
2.6 KiB
C++
//===-- DiffConsumer.h - Difference Consumer --------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This header defines the interface to the LLVM difference Consumer
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TOOLS_LLVM_DIFF_DIFFCONSUMER_H
|
|
#define LLVM_TOOLS_LLVM_DIFF_DIFFCONSUMER_H
|
|
|
|
#include "DiffLog.h"
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/IR/Value.h"
|
|
#include "llvm/Support/Casting.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
namespace llvm {
|
|
class StringRef;
|
|
class Module;
|
|
class Value;
|
|
class Function;
|
|
|
|
/// The interface for consumers of difference data.
|
|
class Consumer {
|
|
virtual void anchor();
|
|
public:
|
|
/// Record that a local context has been entered. Left and
|
|
/// Right are IR "containers" of some sort which are being
|
|
/// considered for structural equivalence: global variables,
|
|
/// functions, blocks, instructions, etc.
|
|
virtual void enterContext(Value *Left, Value *Right) = 0;
|
|
|
|
/// Record that a local context has been exited.
|
|
virtual void exitContext() = 0;
|
|
|
|
/// Record a difference within the current context.
|
|
virtual void log(StringRef Text) = 0;
|
|
|
|
/// Record a formatted difference within the current context.
|
|
virtual void logf(const LogBuilder &Log) = 0;
|
|
|
|
/// Record a line-by-line instruction diff.
|
|
virtual void logd(const DiffLogBuilder &Log) = 0;
|
|
|
|
protected:
|
|
virtual ~Consumer() {}
|
|
};
|
|
|
|
class DiffConsumer : public Consumer {
|
|
private:
|
|
struct DiffContext {
|
|
DiffContext(Value *L, Value *R)
|
|
: L(L), R(R), Differences(false), IsFunction(isa<Function>(L)) {}
|
|
Value *L;
|
|
Value *R;
|
|
bool Differences;
|
|
bool IsFunction;
|
|
DenseMap<Value*,unsigned> LNumbering;
|
|
DenseMap<Value*,unsigned> RNumbering;
|
|
};
|
|
|
|
raw_ostream &out;
|
|
SmallVector<DiffContext, 5> contexts;
|
|
bool Differences;
|
|
unsigned Indent;
|
|
|
|
void printValue(Value *V, bool isL);
|
|
void header();
|
|
void indent();
|
|
|
|
public:
|
|
DiffConsumer()
|
|
: out(errs()), Differences(false), Indent(0) {}
|
|
|
|
bool hadDifferences() const;
|
|
void enterContext(Value *L, Value *R) override;
|
|
void exitContext() override;
|
|
void log(StringRef text) override;
|
|
void logf(const LogBuilder &Log) override;
|
|
void logd(const DiffLogBuilder &Log) override;
|
|
};
|
|
}
|
|
|
|
#endif
|