the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / tools / llvm-diff / DiffLog.cpp
blob9cc0c889fd1f83770835361c64f9478a802f2b53
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 #include "DiffLog.h"
15 #include "DiffConsumer.h"
17 #include "llvm/Instructions.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
21 using namespace llvm;
23 LogBuilder::~LogBuilder() {
24 consumer.logf(*this);
27 StringRef LogBuilder::getFormat() const { return Format; }
29 unsigned LogBuilder::getNumArguments() const { return Arguments.size(); }
30 Value *LogBuilder::getArgument(unsigned I) const { return Arguments[I]; }
32 DiffLogBuilder::~DiffLogBuilder() { consumer.logd(*this); }
34 void DiffLogBuilder::addMatch(Instruction *L, Instruction *R) {
35 Diff.push_back(DiffRecord(L, R));
37 void DiffLogBuilder::addLeft(Instruction *L) {
38 // HACK: VS 2010 has a bug in the stdlib that requires this.
39 Diff.push_back(DiffRecord(L, DiffRecord::second_type(0)));
41 void DiffLogBuilder::addRight(Instruction *R) {
42 // HACK: VS 2010 has a bug in the stdlib that requires this.
43 Diff.push_back(DiffRecord(DiffRecord::first_type(0), R));
46 unsigned DiffLogBuilder::getNumLines() const { return Diff.size(); }
48 DiffChange DiffLogBuilder::getLineKind(unsigned I) const {
49 return (Diff[I].first ? (Diff[I].second ? DC_match : DC_left)
50 : DC_right);
52 Instruction *DiffLogBuilder::getLeft(unsigned I) const { return Diff[I].first; }
53 Instruction *DiffLogBuilder::getRight(unsigned I) const { return Diff[I].second; }