Changeset View
Changeset View
Standalone View
Standalone View
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
Show First 20 Lines • Show All 407 Lines • ▼ Show 20 Lines | void DefGenerator::emitDefDecl(const AttrOrTypeDef &def) { | ||||
if (def.genAccessors()) { | if (def.genAccessors()) { | ||||
SmallVector<AttrOrTypeParameter, 4> parameters; | SmallVector<AttrOrTypeParameter, 4> parameters; | ||||
def.getParameters(parameters); | def.getParameters(parameters); | ||||
for (AttrOrTypeParameter ¶meter : parameters) { | for (AttrOrTypeParameter ¶meter : parameters) { | ||||
SmallString<16> name = parameter.getName(); | SmallString<16> name = parameter.getName(); | ||||
name[0] = llvm::toUpper(name[0]); | name[0] = llvm::toUpper(name[0]); | ||||
os << formatv(" {0} get{1}() const;\n", parameter.getCppType(), name); | os << formatv(" {0} get{1}() const;\n", parameter.getCppAccessorType(), | ||||
name); | |||||
} | } | ||||
} | } | ||||
// Emit any interface method declarations. | // Emit any interface method declarations. | ||||
for (const Trait &trait : def.getTraits()) { | for (const Trait &trait : def.getTraits()) { | ||||
if (const auto *traitDef = dyn_cast<InterfaceTrait>(&trait)) { | if (const auto *traitDef = dyn_cast<InterfaceTrait>(&trait)) { | ||||
if (traitDef->shouldDeclareMethods()) | if (traitDef->shouldDeclareMethods()) | ||||
emitInterfaceMethodDecls(traitDef, os); | emitInterfaceMethodDecls(traitDef, os); | ||||
▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | if (def.genAccessors() && def.genStorageClass()) { | ||||
.toVector(paramStorageName); | .toVector(paramStorageName); | ||||
} else { | } else { | ||||
paramStorageName = param.getName(); | paramStorageName = param.getName(); | ||||
} | } | ||||
SmallString<16> name = param.getName(); | SmallString<16> name = param.getName(); | ||||
name[0] = llvm::toUpper(name[0]); | name[0] = llvm::toUpper(name[0]); | ||||
os << formatv("{0} {3}::get{1}() const {{ return getImpl()->{2}; }\n", | os << formatv("{0} {3}::get{1}() const {{ return getImpl()->{2}; }\n", | ||||
param.getCppType(), name, paramStorageName, | param.getCppAccessorType(), name, paramStorageName, | ||||
def.getCppClassName()); | def.getCppClassName()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// If mnemonic is specified maybe print definitions for the parser and printer | // If mnemonic is specified maybe print definitions for the parser and printer | ||||
// code, if they're specified. | // code, if they're specified. | ||||
if (def.getMnemonic()) | if (def.getMnemonic()) | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |