Add default LoopOptionsAttrBuilder constructor and method to check if empty() (NFC)

Also move setters out-of-line to make sure the templated helper is
actually instantiated.
This commit is contained in:
Mehdi Amini 2021-03-09 21:03:20 +00:00
parent 9b6ac9e999
commit fe81e8f3b5
2 changed files with 28 additions and 9 deletions

View File

@ -79,27 +79,27 @@ bool satisfiesLLVMModule(Operation *op);
/// creation once all the options are in place.
class LoopOptionsAttrBuilder {
public:
/// Construct a empty builder.
LoopOptionsAttrBuilder() = default;
/// Construct a builder with an initial list of options from an existing
/// LoopOptionsAttr.
LoopOptionsAttrBuilder(LoopOptionsAttr attr);
/// Set the `disable_licm` option to the provided value. If no value
/// is provided the option is deleted.
LoopOptionsAttrBuilder &setDisableLICM(Optional<bool> value) {
return setOption(LoopOptionCase::disable_licm, value);
}
LoopOptionsAttrBuilder &setDisableLICM(Optional<bool> value);
/// Set the `interleave_count` option to the provided value. If no value
/// is provided the option is deleted.
LoopOptionsAttrBuilder &setInterleaveCount(Optional<uint64_t> count) {
return setOption(LoopOptionCase::interleave_count, count);
}
LoopOptionsAttrBuilder &setInterleaveCount(Optional<uint64_t> count);
/// Set the `disable_unroll` option to the provided value. If no value
/// is provided the option is deleted.
LoopOptionsAttrBuilder &setDisableUnroll(Optional<bool> value) {
return setOption(LoopOptionCase::disable_unroll, value);
}
LoopOptionsAttrBuilder &setDisableUnroll(Optional<bool> value);
/// Returns true if any option has been set.
bool empty() { return options.empty(); }
private:
template <typename T>

View File

@ -2412,6 +2412,25 @@ LoopOptionsAttrBuilder &LoopOptionsAttrBuilder::setOption(LoopOptionCase tag,
return *this;
}
LoopOptionsAttrBuilder &
LoopOptionsAttrBuilder::setDisableLICM(Optional<bool> value) {
return setOption(LoopOptionCase::disable_licm, value);
}
/// Set the `interleave_count` option to the provided value. If no value
/// is provided the option is deleted.
LoopOptionsAttrBuilder &
LoopOptionsAttrBuilder::setInterleaveCount(Optional<uint64_t> count) {
return setOption(LoopOptionCase::interleave_count, count);
}
/// Set the `disable_unroll` option to the provided value. If no value
/// is provided the option is deleted.
LoopOptionsAttrBuilder &
LoopOptionsAttrBuilder::setDisableUnroll(Optional<bool> value) {
return setOption(LoopOptionCase::disable_unroll, value);
}
template <typename T>
static Optional<T>
getOption(ArrayRef<std::pair<LoopOptionCase, int64_t>> options,