Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/IR/BuiltinAttributes.cpp
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/// Twine support for StringAttr. | /// Twine support for StringAttr. | ||||
StringAttr StringAttr::get(const Twine &twine, Type type) { | StringAttr StringAttr::get(const Twine &twine, Type type) { | ||||
SmallVector<char, 32> tempStr; | SmallVector<char, 32> tempStr; | ||||
return Base::get(type.getContext(), twine.toStringRef(tempStr), type); | return Base::get(type.getContext(), twine.toStringRef(tempStr), type); | ||||
} | } | ||||
StringRef StringAttr::getValue() const { return getImpl()->value; } | |||||
Dialect *StringAttr::getReferencedDialect() const { | |||||
return getImpl()->referencedDialect; | |||||
} | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// FloatAttr | // FloatAttr | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
double FloatAttr::getValueAsDouble() const { | double FloatAttr::getValueAsDouble() const { | ||||
return getValueAsDouble(getValue()); | return getValueAsDouble(getValue()); | ||||
} | } | ||||
double FloatAttr::getValueAsDouble(APFloat value) { | double FloatAttr::getValueAsDouble(APFloat value) { | ||||
▲ Show 20 Lines • Show All 970 Lines • ▼ Show 20 Lines | return attr.isa<DenseElementsAttr>() && | ||||
attr.getType().cast<ShapedType>().getElementType().isIntOrIndex(); | attr.getType().cast<ShapedType>().getElementType().isIntOrIndex(); | ||||
} | } | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// OpaqueElementsAttr | // OpaqueElementsAttr | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
bool OpaqueElementsAttr::decode(ElementsAttr &result) { | bool OpaqueElementsAttr::decode(ElementsAttr &result) { | ||||
Dialect *dialect = getDialect().getDialect(); | Dialect *dialect = getContext()->getLoadedDialect(getDialect()); | ||||
if (!dialect) | if (!dialect) | ||||
return true; | return true; | ||||
auto *interface = | auto *interface = | ||||
dialect->getRegisteredInterface<DialectDecodeAttributesInterface>(); | dialect->getRegisteredInterface<DialectDecodeAttributesInterface>(); | ||||
if (!interface) | if (!interface) | ||||
return true; | return true; | ||||
return failed(interface->decode(*this, result)); | return failed(interface->decode(*this, result)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |