2020-04-01 16:48:34 +08:00
|
|
|
//===- Pass.cpp - Pass related classes ------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "mlir/TableGen/Pass.h"
|
|
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
|
|
|
|
using namespace mlir;
|
|
|
|
using namespace mlir::tblgen;
|
|
|
|
|
2020-04-01 16:50:29 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// PassOption
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
StringRef PassOption::getCppVariableName() const {
|
|
|
|
return def->getValueAsString("cppName");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef PassOption::getArgument() const {
|
|
|
|
return def->getValueAsString("argument");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef PassOption::getType() const { return def->getValueAsString("type"); }
|
|
|
|
|
|
|
|
Optional<StringRef> PassOption::getDefaultValue() const {
|
|
|
|
StringRef defaultVal = def->getValueAsString("defaultValue");
|
|
|
|
return defaultVal.empty() ? Optional<StringRef>() : defaultVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef PassOption::getDescription() const {
|
|
|
|
return def->getValueAsString("description");
|
|
|
|
}
|
|
|
|
|
|
|
|
Optional<StringRef> PassOption::getAdditionalFlags() const {
|
|
|
|
StringRef additionalFlags = def->getValueAsString("additionalOptFlags");
|
|
|
|
return additionalFlags.empty() ? Optional<StringRef>() : additionalFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PassOption::isListOption() const {
|
|
|
|
return def->isSubClassOf("ListOption");
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// PassStatistic
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
StringRef PassStatistic::getCppVariableName() const {
|
|
|
|
return def->getValueAsString("cppName");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef PassStatistic::getName() const {
|
|
|
|
return def->getValueAsString("name");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef PassStatistic::getDescription() const {
|
|
|
|
return def->getValueAsString("description");
|
|
|
|
}
|
|
|
|
|
2020-04-01 16:48:34 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pass
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-04-01 16:50:29 +08:00
|
|
|
Pass::Pass(const llvm::Record *def) : def(def) {
|
|
|
|
for (auto *init : def->getValueAsListOfDefs("options"))
|
|
|
|
options.push_back(PassOption(init));
|
|
|
|
for (auto *init : def->getValueAsListOfDefs("statistics"))
|
|
|
|
statistics.push_back(PassStatistic(init));
|
|
|
|
}
|
2020-04-01 16:48:34 +08:00
|
|
|
|
|
|
|
StringRef Pass::getArgument() const {
|
|
|
|
return def->getValueAsString("argument");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef Pass::getSummary() const { return def->getValueAsString("summary"); }
|
|
|
|
|
|
|
|
StringRef Pass::getDescription() const {
|
|
|
|
return def->getValueAsString("description");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef Pass::getConstructor() const {
|
|
|
|
return def->getValueAsString("constructor");
|
|
|
|
}
|
2020-04-01 16:50:29 +08:00
|
|
|
|
|
|
|
ArrayRef<PassOption> Pass::getOptions() const { return options; }
|
|
|
|
|
|
|
|
ArrayRef<PassStatistic> Pass::getStatistics() const { return statistics; }
|