Files
revng-revng/include/revng/BasicAnalyses/MaterializedValue.h
T
Alessandro Di Federico 5009074e9e Introduce AdvancedValueInfo for JT discovery
* Introduce `ShrinkInstructionOperandsPass`: a transformation shrinking
  operands and the results of instructions if they are
  zero/sign-extended immediately before and after the instruction.
* Introduce `ConstantRangeSet`: similar to `ConstantRange` but allows
  disjoint ranges.
* Introduce `MaterializedValue`: a class that can represent a constant
  value or a symbol plus offset pair.
* Introduce `DropHelperCallsPass`: a transformation removing calls to
  helpers and replacing them with a function call reading the CSVs that
  the helper reads and writing the CSVs that the helper writes
  (according to CSAA).
* Introduce `DropRangeMetadataPass`: a transformation dropping the
  `range` metadata, which, in certain situations, lowers the quality of
  the results provided by `LazyValueInfo`.
* Introduce `AdvancedValueInfo`: an analysis exploiting results of
  `LazyValueInfo` but collecting them as `ConstantRangeSet` with a
  monotone framework. It produces `MaterializedValue`.
* Anticipate linking of helpers: `AVI` requires `CSAA`, which requires
  helper functions to be linked in.
* Drop `--no-link`.
* Force x86-64 `DataLayout`.
* Reorganize harvesting to either collect simple literals or go with
  (incremental) `AVI`.
* Drop `SET`, `OSRA`, the reaching definition analysis, the
  `SimplifyComparisonsPass` and all the sumjump-related code: e now
  clone `root`, optimize it and analyze it with `AVI`.
* Temporarily drop the `NoReturnAnalysis`.
* Link `libLLVMInstCombine`, `libLLVMCodeGen` and `libLLVMPasses`.
* Introduce tests for `AdvancedValueInfo`,
  `ShrinkInstructionOperandsPass` and `ConstantRangeSet`.
* Fix test results.
* Add `llvm.bswap.i64` and `@pc` to the LLVM template module for unit
  tests.
2019-05-22 21:30:29 +02:00

77 lines
1.9 KiB
C++

#ifndef REVNG_MATERIALIZEDVALUE_H
#define REVNG_MATERIALIZEDVALUE_H
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
// Standard includes
#include <set>
// LLVM includes
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
// Local libraries includes
#include "revng/Support/Debug.h"
const uint64_t MaxMaterializedValues = (1 << 16);
/// \brief Class representing either a constant value or an offset from a symbol
class MaterializedValue {
private:
bool IsValid;
llvm::Optional<llvm::StringRef> SymbolName;
uint64_t Value;
public:
MaterializedValue() : IsValid(false), Value(0) {}
MaterializedValue(uint64_t Value) : IsValid(true), Value(Value) {}
MaterializedValue(llvm::StringRef Name, uint64_t Offset) :
IsValid(true),
SymbolName(Name),
Value(Offset) {}
public:
static MaterializedValue invalid() { return MaterializedValue(); }
public:
bool operator==(const MaterializedValue &Other) const {
auto This = std::tie(IsValid, SymbolName, Value);
auto That = std::tie(Other.IsValid, Other.SymbolName, Other.Value);
return This == That;
}
bool operator<(const MaterializedValue &Other) const {
auto This = std::tie(IsValid, SymbolName, Value);
auto That = std::tie(Other.IsValid, Other.SymbolName, Other.Value);
return This < That;
}
uint64_t value() const {
revng_assert(isValid());
return Value;
}
bool isValid() const { return IsValid; }
bool hasSymbol() const { return SymbolName.hasValue(); }
llvm::StringRef symbolName() const {
revng_assert(isValid());
revng_assert(hasSymbol());
return *SymbolName;
}
void dump() const debug_function {
if (not isValid()) {
dbg << "(invalid)";
} else {
if (hasSymbol())
dbg << symbolName().data() << "+";
dbg << "0x" << std::hex << value();
}
}
};
using MaterializedValues = std::vector<MaterializedValue>;
#endif // REVNG_MATERIALIZEDVALUE_H