@@ -60,11 +60,6 @@ bool DialectType::init(raw_ostream &errs, GenDialectsContext &context,
6060 ->getValue ();
6161 }
6262 }
63- if (auto *p = record->getValue (" structPrefix" ))
64- m_structPrefix = record->getValueAsString (" structPrefix" ).str ();
65- else
66- m_structPrefix =
67- (m_dialectRec->getValueAsString (" name" ).str () + " ." + m_mnemonic + " ." );
6863
6964 for (unsigned argIdx = 0 ; argIdx < m_arguments.size (); ++argIdx)
7065 m_canDerive.push_back (true );
@@ -269,6 +264,10 @@ void DialectType::emitDefinition(raw_ostream &out, GenDialect *dialect) const {
269264 fmt.addSubst (" types" , symbols.chooseName (" types" ));
270265 fmt.addSubst (" ints" , symbols.chooseName (" ints" ));
271266 fmt.addSubst (" _errs" , symbols.chooseName (" errs" ));
267+ fmt.addSubst (" os" , symbols.chooseName (" os" ));
268+ fmt.addSubst (" name" , symbols.chooseName (" name" ));
269+ fmt.addSubst (" fields" , symbols.chooseName (" fields" ));
270+ fmt.addSubst (" st" , symbols.chooseName (" st" ));
272271
273272 if (m_structBacked) {
274273 out << tgfmt (" $_type* $_type::get(" , &fmt);
@@ -297,29 +296,30 @@ void DialectType::emitDefinition(raw_ostream &out, GenDialect *dialect) const {
297296 }
298297 }
299298
300- out << " std::string __name; ::llvm::raw_string_ostream __os(__name);\n " ;
301- out << tgfmt (" __os << \" $0\" ;\n " , &fmt, m_structPrefix);
299+ out << tgfmt (
300+ " std::string $name; ::llvm::raw_string_ostream $os($name);\n " , &fmt);
301+ out << tgfmt (" $os << \" $0\" ;\n " , &fmt, m_mnemonic);
302302 for (const auto &getterArg : getterArgs)
303- out << " __os << (uint64_t) " << getterArg. name << " << '.' ;\n " ;
303+ out << tgfmt ( " $os << '.' << (uint64_t)$0 ;\n " , &fmt, getterArg. name ) ;
304304
305- out << tgfmt (" ::std::vector<::llvm::Type*> __fields ;\n " , &fmt);
305+ out << tgfmt (" ::std::vector<::llvm::Type*> $fields ;\n " , &fmt);
306306 out << tgfmt (
307- " __fields .push_back(::llvm::IntegerType::get($_context, $0));\n " ,
308- &fmt, Twine (m_structSentinelBitWidth));
307+ " $fields .push_back(::llvm::IntegerType::get($_context, $0));\n " , &fmt ,
308+ Twine (m_structSentinelBitWidth));
309309
310310 for (const auto &getterArg : getterArgs) {
311311 out << tgfmt (R"(
312312 if ($0 == 0)
313- __fields .push_back(::llvm::StructType::get($_context));
313+ $fields .push_back(::llvm::StructType::get($_context));
314314 else
315- __fields .push_back(::llvm::IntegerType::get($_context, $0));
315+ $fields .push_back(::llvm::IntegerType::get($_context, $0));
316316)" ,
317317 &fmt, getterArg.name );
318318 }
319- out << tgfmt (" auto *__st = ::llvm::StructType::create($_context, "
320- " __fields, __os .str(), /*isPacked=*/false);\n " ,
319+ out << tgfmt (" auto *$st = ::llvm::StructType::create($_context, "
320+ " $fields, $os .str(), /*isPacked=*/false);\n " ,
321321 &fmt);
322- out << tgfmt (" return static_cast<$_type *>(__st );\n }\n\n " , &fmt);
322+ out << tgfmt (" return static_cast<$_type *>($st );\n }\n\n " , &fmt);
323323
324324 out << tgfmt (R"(
325325bool $_type::classof(const ::llvm::Type *t) {
0 commit comments