18 #include "llvm/TableGen/Record.h"
26 using llvm::StringInit;
31 if (
const auto *str = dyn_cast<StringInit>(init))
32 return str->getValue().trim();
55 assert((def->isSubClassOf(
"Property") || def->isSubClassOf(
"Attr")) &&
56 "must be subclass of TableGen 'Property' class");
59 Property::Property(
const DefInit *init) :
Property(init->getDef()) {}
61 Property::Property(StringRef summary, StringRef description,
62 StringRef storageType, StringRef interfaceType,
63 StringRef convertFromStorageCall,
64 StringRef assignToStorageCall,
65 StringRef convertToAttributeCall,
66 StringRef convertFromAttributeCall, StringRef parserCall,
67 StringRef optionalParserCall, StringRef printerCall,
68 StringRef readFromMlirBytecodeCall,
69 StringRef writeToMlirBytecodeCall,
70 StringRef hashPropertyCall, StringRef defaultValue,
71 StringRef storageTypeValueOverride)
72 : def(nullptr), summary(summary), description(description),
73 storageType(storageType), interfaceType(interfaceType),
74 convertFromStorageCall(convertFromStorageCall),
75 assignToStorageCall(assignToStorageCall),
76 convertToAttributeCall(convertToAttributeCall),
77 convertFromAttributeCall(convertFromAttributeCall),
78 parserCall(parserCall), optionalParserCall(optionalParserCall),
79 printerCall(printerCall),
80 readFromMlirBytecodeCall(readFromMlirBytecodeCall),
81 writeToMlirBytecodeCall(writeToMlirBytecodeCall),
82 hashPropertyCall(hashPropertyCall), defaultValue(defaultValue),
83 storageTypeValueOverride(storageTypeValueOverride) {
84 if (storageType.empty())
85 storageType =
"Property";
89 if (def->isAnonymous()) {
92 return def->getName();
98 const llvm::RecordVal *maybePred = def->getValue(
"predicate");
99 if (!maybePred || !maybePred->getValue())
101 return Pred(maybePred->getValue());
105 if (
const auto *defInit =
106 llvm::dyn_cast<llvm::DefInit>(def->getValueInit(
"baseProperty"))) {
107 return Property(defInit).getBaseProperty();
static StringRef getValueAsString(const Init *init)
StringRef getPropertyDefName() const
Pred getPredicate() const
Property(const llvm::Record *record)
Property getBaseProperty() const
Include the generated interface declarations.