the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / tools / llvm-diff / DiffLog.h
blob43e318ac4e9feb60111ec488ce9da7d895e05bb6
1 //===-- DiffLog.h - Difference Log Builder and accessories ------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header defines the interface to the LLVM difference log builder.
12 //===----------------------------------------------------------------------===//
14 #ifndef _LLVM_DIFFLOG_H_
15 #define _LLVM_DIFFLOG_H_
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/StringRef.h"
20 namespace llvm {
21 class Instruction;
22 class Value;
23 class Consumer;
25 /// Trichotomy assumption
26 enum DiffChange { DC_match, DC_left, DC_right };
28 /// A temporary-object class for building up log messages.
29 class LogBuilder {
30 Consumer &consumer;
32 /// The use of a stored StringRef here is okay because
33 /// LogBuilder should be used only as a temporary, and as a
34 /// temporary it will be destructed before whatever temporary
35 /// might be initializing this format.
36 StringRef Format;
38 SmallVector<Value*, 4> Arguments;
40 public:
41 LogBuilder(Consumer &c, StringRef Format)
42 : consumer(c), Format(Format) {}
44 LogBuilder &operator<<(Value *V) {
45 Arguments.push_back(V);
46 return *this;
49 ~LogBuilder();
51 StringRef getFormat() const;
52 unsigned getNumArguments() const;
53 Value *getArgument(unsigned I) const;
56 /// A temporary-object class for building up diff messages.
57 class DiffLogBuilder {
58 typedef std::pair<Instruction*,Instruction*> DiffRecord;
59 SmallVector<DiffRecord, 20> Diff;
61 Consumer &consumer;
63 public:
64 DiffLogBuilder(Consumer &c) : consumer(c) {}
65 ~DiffLogBuilder();
67 void addMatch(Instruction *L, Instruction *R);
68 // HACK: VS 2010 has a bug in the stdlib that requires this.
69 void addLeft(Instruction *L);
70 void addRight(Instruction *R);
72 unsigned getNumLines() const;
73 DiffChange getLineKind(unsigned I) const;
74 Instruction *getLeft(unsigned I) const;
75 Instruction *getRight(unsigned I) const;
80 #endif