forked from OSchip/llvm-project
Revert "Give attributes C++ namespaces."
This reverts commit 0a34492f36
.
This change turned out to be very intrusive wrt some internal projects.
Reverting until this can be sorted out.
This commit is contained in:
parent
e4e23c55c0
commit
df295fac6c
|
@ -791,16 +791,12 @@ class Attr<Pred condition, string descr = ""> :
|
||||||
// instantiation.
|
// instantiation.
|
||||||
// TOOD(b/132458159): deduplicate the fields in attribute wrapper classes.
|
// TOOD(b/132458159): deduplicate the fields in attribute wrapper classes.
|
||||||
Attr baseAttr = ?;
|
Attr baseAttr = ?;
|
||||||
|
|
||||||
// The fully-qualified C++ namespace where the generated class lives.
|
|
||||||
string cppNamespace = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// An attribute of a specific dialect.
|
// An attribute of a specific dialect.
|
||||||
class DialectAttr<Dialect d, Pred condition, string descr = ""> :
|
class DialectAttr<Dialect d, Pred condition, string descr = ""> :
|
||||||
Attr<condition, descr> {
|
Attr<condition, descr> {
|
||||||
Dialect dialect = d;
|
Dialect dialect = d;
|
||||||
let cppNamespace = d.cppNamespace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1119,6 +1115,16 @@ class EnumAttrInfo<string name, list<EnumAttrCaseInfo> cases> {
|
||||||
// underlying type is not explicitly specified.
|
// underlying type is not explicitly specified.
|
||||||
string underlyingType = "";
|
string underlyingType = "";
|
||||||
|
|
||||||
|
// The C++ namespaces that the enum class definition and utility functions
|
||||||
|
// should be placed into.
|
||||||
|
//
|
||||||
|
// Normally you want to place the full namespace path here. If it is nested,
|
||||||
|
// use "::" as the delimiter, e.g., given "A::B", generated code will be
|
||||||
|
// placed in `namespace A { namespace B { ... } }`. To avoid placing in any
|
||||||
|
// namespace, use "".
|
||||||
|
// TODO: use dialect to provide the namespace.
|
||||||
|
string cppNamespace = "";
|
||||||
|
|
||||||
// The name of the utility function that converts a value of the underlying
|
// The name of the utility function that converts a value of the underlying
|
||||||
// type to the corresponding symbol. It will have the following signature:
|
// type to the corresponding symbol. It will have the following signature:
|
||||||
//
|
//
|
||||||
|
@ -1457,8 +1463,7 @@ class StructFieldAttr<string thisName, Attr thisType> {
|
||||||
// useful when representing data that would normally be in a structure.
|
// useful when representing data that would normally be in a structure.
|
||||||
class StructAttr<string name, Dialect d,
|
class StructAttr<string name, Dialect d,
|
||||||
list<StructFieldAttr> attributes> :
|
list<StructFieldAttr> attributes> :
|
||||||
DictionaryAttrBase<CPred<"$_self.isa<" # d.cppNamespace
|
DictionaryAttrBase<CPred<"$_self.isa<" # name # ">()">,
|
||||||
# "::" # name # ">()">,
|
|
||||||
"DictionaryAttr with field(s): " #
|
"DictionaryAttr with field(s): " #
|
||||||
StrJoin<!foreach(a, attributes, "'" # a.name # "'"), ", ">.result #
|
StrJoin<!foreach(a, attributes, "'" # a.name # "'"), ", ">.result #
|
||||||
" (each field having its own constraints)"> {
|
" (each field having its own constraints)"> {
|
||||||
|
@ -1466,16 +1471,14 @@ class StructAttr<string name, Dialect d,
|
||||||
string className = name;
|
string className = name;
|
||||||
|
|
||||||
// Return type should match the name of the structure.
|
// Return type should match the name of the structure.
|
||||||
let returnType = d.cppNamespace # "::" # name;
|
let returnType = name;
|
||||||
|
|
||||||
// Storage type should match the name of the structure.
|
// Storage type should match the name of the structure.
|
||||||
let storageType = d.cppNamespace # "::" # name;
|
let storageType = name;
|
||||||
|
|
||||||
// The dialect this StructAttr belongs to.
|
// The dialect this StructAttr belongs to.
|
||||||
Dialect dialect = d;
|
Dialect dialect = d;
|
||||||
|
|
||||||
let cppNamespace = d.cppNamespace;
|
|
||||||
|
|
||||||
// List of fields that the StructAttr contains.
|
// List of fields that the StructAttr contains.
|
||||||
list<StructFieldAttr> fields = attributes;
|
list<StructFieldAttr> fields = attributes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,11 +219,11 @@ std::string SymbolInfoMap::SymbolInfo::getVarDecl(StringRef name) const {
|
||||||
case Kind::Operand: {
|
case Kind::Operand: {
|
||||||
// Use operand range for captured operands (to support potential variadic
|
// Use operand range for captured operands (to support potential variadic
|
||||||
// operands).
|
// operands).
|
||||||
return std::string(formatv(
|
return std::string(
|
||||||
"::mlir::Operation::operand_range {0}(op0->getOperands());\n", name));
|
formatv("Operation::operand_range {0}(op0->getOperands());\n", name));
|
||||||
}
|
}
|
||||||
case Kind::Value: {
|
case Kind::Value: {
|
||||||
return std::string(formatv("::llvm::ArrayRef<::mlir::Value> {0};\n", name));
|
return std::string(formatv("ArrayRef<Value> {0};\n", name));
|
||||||
}
|
}
|
||||||
case Kind::Result: {
|
case Kind::Result: {
|
||||||
// Use the op itself for captured results.
|
// Use the op itself for captured results.
|
||||||
|
|
|
@ -487,7 +487,16 @@ void OpEmitter::genAttrGetters() {
|
||||||
|
|
||||||
// Emit with return type specified.
|
// Emit with return type specified.
|
||||||
auto emitAttrWithReturnType = [&](StringRef name, Attribute attr) {
|
auto emitAttrWithReturnType = [&](StringRef name, Attribute attr) {
|
||||||
auto *method = opClass.addMethodAndPrune(attr.getReturnType(), name);
|
Dialect attrDialect = attr.getDialect();
|
||||||
|
// Does the current operation have a different namespace than the attribute?
|
||||||
|
bool differentNamespace =
|
||||||
|
attrDialect && opDialect && attrDialect != opDialect;
|
||||||
|
std::string returnType = differentNamespace
|
||||||
|
? (llvm::Twine(attrDialect.getCppNamespace()) +
|
||||||
|
"::" + attr.getReturnType())
|
||||||
|
.str()
|
||||||
|
: attr.getReturnType().str();
|
||||||
|
auto *method = opClass.addMethodAndPrune(returnType, name);
|
||||||
auto &body = method->body();
|
auto &body = method->body();
|
||||||
body << " auto attr = " << name << "Attr();\n";
|
body << " auto attr = " << name << "Attr();\n";
|
||||||
if (attr.hasDefaultValue()) {
|
if (attr.hasDefaultValue()) {
|
||||||
|
@ -1991,8 +2000,8 @@ void OpEmitter::genOpAsmInterface() {
|
||||||
opClass.addTrait("::mlir::OpAsmOpInterface::Trait");
|
opClass.addTrait("::mlir::OpAsmOpInterface::Trait");
|
||||||
|
|
||||||
// Generate the right accessor for the number of results.
|
// Generate the right accessor for the number of results.
|
||||||
auto *method = opClass.addMethodAndPrune(
|
auto *method = opClass.addMethodAndPrune("void", "getAsmResultNames",
|
||||||
"void", "getAsmResultNames", "::mlir::OpAsmSetValueNameFn", "setNameFn");
|
"OpAsmSetValueNameFn", "setNameFn");
|
||||||
auto &body = method->body();
|
auto &body = method->body();
|
||||||
for (int i = 0; i != numResults; ++i) {
|
for (int i = 0; i != numResults; ++i) {
|
||||||
body << " auto resultGroup" << i << " = getODSResults(" << i << ");\n"
|
body << " auto resultGroup" << i << " = getODSResults(" << i << ");\n"
|
||||||
|
|
|
@ -221,8 +221,7 @@ void PatternEmitter::emitOpMatch(DagNode tree, int depth) {
|
||||||
|
|
||||||
int indent = 4 + 2 * depth;
|
int indent = 4 + 2 * depth;
|
||||||
os.indent(indent) << formatv(
|
os.indent(indent) << formatv(
|
||||||
"auto castedOp{0} = ::llvm::dyn_cast_or_null<{1}>(op{0}); "
|
"auto castedOp{0} = dyn_cast_or_null<{1}>(op{0}); (void)castedOp{0};\n",
|
||||||
"(void)castedOp{0};\n",
|
|
||||||
depth, op.getQualCppClassName());
|
depth, op.getQualCppClassName());
|
||||||
// Skip the operand matching at depth 0 as the pattern rewriter already does.
|
// Skip the operand matching at depth 0 as the pattern rewriter already does.
|
||||||
if (depth != 0) {
|
if (depth != 0) {
|
||||||
|
@ -536,7 +535,7 @@ void PatternEmitter::emit(StringRef rewriteName) {
|
||||||
os << "\n// Rewrite\n";
|
os << "\n// Rewrite\n";
|
||||||
emitRewriteLogic();
|
emitRewriteLogic();
|
||||||
|
|
||||||
os << "return ::mlir::success();\n";
|
os << "return success();\n";
|
||||||
}
|
}
|
||||||
os << "};\n";
|
os << "};\n";
|
||||||
}
|
}
|
||||||
|
@ -1146,8 +1145,8 @@ static void emitRewriters(const RecordKeeper &recordKeeper, raw_ostream &os) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit function to add the generated matchers to the pattern list.
|
// Emit function to add the generated matchers to the pattern list.
|
||||||
os << "void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::MLIRContext "
|
os << "void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(MLIRContext "
|
||||||
"*context, ::mlir::OwningRewritePatternList *patterns) {\n";
|
"*context, OwningRewritePatternList *patterns) {\n";
|
||||||
for (const auto &name : rewriterNames) {
|
for (const auto &name : rewriterNames) {
|
||||||
os << " patterns->insert<" << name << ">(context);\n";
|
os << " patterns->insert<" << name << ">(context);\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue