diff --git a/backends/dpdk/dpdkArch.cpp b/backends/dpdk/dpdkArch.cpp index 7c081300223..eae382689c4 100644 --- a/backends/dpdk/dpdkArch.cpp +++ b/backends/dpdk/dpdkArch.cpp @@ -792,7 +792,7 @@ bool ExpressionUnroll::preorder(const IR::Operation_Unary *u) { } else { un_expr = u; } - root = new IR::PathExpression(IR::ID(refMap->newName("tmp"))); + root = new IR::PathExpression(IR::ID(refMap->newName("tmpAE"))); stmt.push_back(new IR::AssignmentStatement(root, un_expr)); decl.push_back(new IR::Declaration_Variable(root->path->name, u->type)); return false; @@ -808,7 +808,7 @@ bool ExpressionUnroll::preorder(const IR::Operation_Binary *bin) { if (!left_root) left_root = bin->left; if (!right_root) right_root = bin->right; - root = new IR::PathExpression(IR::ID(refMap->newName("tmp"))); + root = new IR::PathExpression(IR::ID(refMap->newName("tmpAF"))); decl.push_back(new IR::Declaration_Variable(root->path->name, bin->type)); @@ -831,7 +831,7 @@ bool ExpressionUnroll::preorder(const IR::MethodCallExpression *m) { else args->push_back(new IR::Argument(root)); } - root = new IR::PathExpression(IR::ID(refMap->newName("tmp"))); + root = new IR::PathExpression(IR::ID(refMap->newName("tmpAG"))); decl.push_back(new IR::Declaration_Variable(root->path->name, m->type)); auto new_m = new IR::MethodCallExpression(m->method, args); stmt.push_back(new IR::AssignmentStatement(root, new_m)); @@ -943,7 +943,7 @@ bool LogicalExpressionUnroll::preorder(const IR::Operation_Unary *u) { un_expr = u; } - auto tmp = new IR::PathExpression(IR::ID(refMap->newName("tmp"))); + auto tmp = new IR::PathExpression(IR::ID(refMap->newName("tmpAH"))); root = tmp; stmt.push_back(new IR::AssignmentStatement(root, un_expr)); decl.push_back(new IR::Declaration_Variable(tmp->path->name, u->type)); @@ -967,7 +967,7 @@ bool LogicalExpressionUnroll::preorder(const IR::Operation_Binary *bin) { bin_expr->right = right_root; root = bin_expr; } else { - auto tmp = new IR::PathExpression(IR::ID(refMap->newName("tmp"))); + auto tmp = new IR::PathExpression(IR::ID(refMap->newName("tmpAI"))); root = tmp; decl.push_back(new IR::Declaration_Variable(tmp->path->name, bin->type)); IR::Operation_Binary *bin_expr; @@ -993,7 +993,7 @@ bool LogicalExpressionUnroll::preorder(const IR::MethodCallExpression *m) { root = m->clone(); return false; } - auto tmp = new IR::PathExpression(IR::ID(refMap->newName("tmp"))); + auto tmp = new IR::PathExpression(IR::ID(refMap->newName("tmpAJ"))); root = tmp; decl.push_back(new IR::Declaration_Variable(tmp->path->name, m->type)); auto new_m = new IR::MethodCallExpression(m->method, args); @@ -1049,7 +1049,7 @@ const IR::Node *ConvertBinaryOperationTo2Params::postorder(IR::AssignmentStateme IR::IndexedVector code_block; auto control = findOrigCtxt(); auto parser = findOrigCtxt(); - auto tmpOp1 = new IR::PathExpression(IR::ID(refMap->newName("tmp"))); + auto tmpOp1 = new IR::PathExpression(IR::ID(refMap->newName("tmpAK"))); injector.collect(control, parser, new IR::Declaration_Variable(tmpOp1->path->name, left->type)); code_block.push_back(new IR::AssignmentStatement(tmpOp1, r->left)); @@ -1338,7 +1338,7 @@ const IR::Node *DismantleMuxExpressions::preorder(IR::Mux *expression) { cstring DismantleMuxExpressions::createTemporary(const IR::Type *type) { type = type->getP4Type(); - auto tmp = refMap->newName("tmp"); + auto tmp = refMap->newName("tmpAL"); auto decl = new IR::Declaration_Variable(IR::ID(tmp, nullptr), type); toInsert.push_back(decl); return tmp; diff --git a/backends/dpdk/dpdkHelpers.cpp b/backends/dpdk/dpdkHelpers.cpp index 79d2475a2d0..9006e1780ed 100644 --- a/backends/dpdk/dpdkHelpers.cpp +++ b/backends/dpdk/dpdkHelpers.cpp @@ -184,7 +184,7 @@ bool ConvertStatementToDpdk::preorder(const IR::AssignmentStatement *a) { auto maskMsb = tmp->value << (consOrgBitwidth - 1); // Move param to metadata as DPDK expects it to be in metadata BUG_CHECK(metadataStruct, "Metadata structure missing unexpectedly!"); - IR::ID src1(refmap->newName("tmp")); + IR::ID src1(refmap->newName("tmpAM")); metadataStruct->fields.push_back(new IR::StructField(src1, src2Op->type)); auto src1Member = new IR::Member(new IR::PathExpression("m"), src1); add_instr( diff --git a/backends/ebpf/codeGen.cpp b/backends/ebpf/codeGen.cpp index 83b9459f2ba..8834564e63f 100644 --- a/backends/ebpf/codeGen.cpp +++ b/backends/ebpf/codeGen.cpp @@ -188,6 +188,8 @@ bool CodeGenInspector::preorder(const IR::Cast *c) { widthCheck(c); int prec = expressionPrecedence; bool useParens = prec > c->getPrecedence(); + std::cout << "CGI::preorder(IR::Cast), " << (void *)c << ", destType " + << c->destType->toString() << std::endl; if (useParens) builder->append("("); builder->append("("); auto et = EBPFTypeFactory::instance->create(c->destType); @@ -352,15 +354,29 @@ void CodeGenInspector::emitAssignStatement(const IR::Type *ltype, const IR::Expr memcpy = !EBPFScalarType::generatesScalar(width); } + builder->emitIndent(); + if (lexpr == nullptr) + builder->appendFormat("/* lexpr = nil, lpath %s */", lpath); + else + builder->appendFormat("/* lexpr = %s */", lexpr->toString()); + builder->newline(); + builder->emitIndent(); + builder->appendFormat("/* rexpr = %s */", rexpr->toString()); + builder->newline(); builder->emitIndent(); if (memcpy) { - builder->append("__builtin_memcpy(&"); + builder->append("__builtin_memcpy/*G*/(&"); if (lexpr != nullptr) { visit(lexpr); } else { builder->append(lpath); } - builder->append(", &"); + builder->append(", "); + auto rtype = EBPFTypeFactory::instance->create(typeMap->getType(rexpr)); + if (rtype->is() && rtype->is_array()) + builder->append("& /* no */"); + else + builder->append("/* yes */"); if (rexpr->is()) { builder->appendFormat("(u8[%u])", scalar->bytesRequired()); } @@ -455,6 +471,7 @@ bool CodeGenInspector::preorder(const IR::MethodCallStatement *s) { } void CodeGenInspector::widthCheck(const IR::Node *node) const { +#if 0 // This is a temporary solution. // Rather than generate incorrect results, we reject programs that // do not perform arithmetic on machine-supported widths. @@ -472,6 +489,9 @@ void CodeGenInspector::widthCheck(const IR::Node *node) const { } ::P4::error(ErrorType::ERR_UNSUPPORTED_ON_TARGET, "%1%: Computations on %2% bits not supported", node, tb->size); +#else + (void)node; +#endif } void CodeGenInspector::emitAndConvertByteOrder(const IR::Expression *expr, cstring byte_order) { diff --git a/backends/ebpf/ebpfDeparser.cpp b/backends/ebpf/ebpfDeparser.cpp index 8569955732e..9286da3dff6 100644 --- a/backends/ebpf/ebpfDeparser.cpp +++ b/backends/ebpf/ebpfDeparser.cpp @@ -203,7 +203,7 @@ void DeparserHdrEmitTranslator::emitField(CodeBuilder *builder, cstring field, builder->endOfStatement(true); msgStr = absl::StrFormat("Deparser: emitting field %s=0x%%llx (%u bits)", field, widthToEmit); - builder->target->emitTraceMessage(builder, msgStr.c_str(), 1, "tmp"); + builder->target->emitTraceMessage(builder, msgStr.c_str(), 1, "tmpAC"); builder->blockEnd(true); } } else { diff --git a/backends/ebpf/ebpfType.cpp b/backends/ebpf/ebpfType.cpp index c3a18d1ac81..26e905555fe 100644 --- a/backends/ebpf/ebpfType.cpp +++ b/backends/ebpf/ebpfType.cpp @@ -53,7 +53,8 @@ EBPFType *EBPFTypeFactory::create(const IR::Type *type) { // Implement error type as scalar of width 8 bits result = new EBPFScalarType(IR::Type_Bits::get(8, false)); } else { - ::P4::error(ErrorType::ERR_UNSUPPORTED_ON_TARGET, "Type %1% not supported", type); + ::P4::error(ErrorType::ERR_UNSUPPORTED_ON_TARGET, "Type %1% not supported [factory create]", + type); } return result; diff --git a/backends/ebpf/ebpfType.h b/backends/ebpf/ebpfType.h index c3493b6affc..74f81937d96 100644 --- a/backends/ebpf/ebpfType.h +++ b/backends/ebpf/ebpfType.h @@ -39,6 +39,7 @@ class EBPFType : public EBPFObject { virtual void declareArray(CodeBuilder * /*builder*/, cstring /*id*/, unsigned /*size*/) { BUG("%1%: unsupported array", type); } + virtual bool is_array() { return (false); } DECLARE_TYPEINFO(EBPFType, EBPFObject); }; @@ -121,6 +122,8 @@ class EBPFScalarType : public EBPFType, public IHasWidth { unsigned implementationWidthInBits() const override { return bytesRequired() * 8; } // True if this width is small enough to store in a machine scalar static bool generatesScalar(unsigned width) { return width <= 64; } + // XXX Should we be using generatesScalar instead of defining another method? + virtual bool is_array() override { return (width > 64); } DECLARE_TYPEINFO(EBPFScalarType, EBPFType, IHasWidth); }; diff --git a/backends/tc/backend.cpp b/backends/tc/backend.cpp index ca7a8293696..b9ca07dab52 100644 --- a/backends/tc/backend.cpp +++ b/backends/tc/backend.cpp @@ -40,6 +40,106 @@ const cstring pnaParserMeta = "pna_main_parser_input_metadata_t"_cs; const cstring pnaInputMeta = "pna_main_input_metadata_t"_cs; const cstring pnaOutputMeta = "pna_main_output_metadata_t"_cs; +const IR::Node *FIXUP_CASTS::preorder(IR::Statement *s) { + CONTAINER *c; + + std::cout << "cast fixup: preorder: " << (void *)s << '\n' << s->toString() << std::endl; + c = new CONTAINER; + c->temps = 0; + c->s = s; + c->link = contain; + contain = c; + return (s); +} + +const IR::Node *FIXUP_CASTS::postorder(IR::Statement *s) { + CONTAINER *c; + DECLLIST *temps; + DECLLIST *t; + IR::BlockStatement *b; + + std::cout << "cast fixup: postorder: " << (void *)s << '\n' << s->toString() << std::endl; + c = contain; + if (c->s != s) abort(); + contain = c->link; + temps = c->temps; + c->temps = 0; + delete c; + if (!temps) return (s); + std::cout << "Declarations:"; + for (t = temps; t; t = t->link) std::cout << " " << t->decl->toString(); + std::cout << std::endl; + b = new IR::BlockStatement(); + for (t = temps; t; t = t->link) b->append(t->decl); + b->append(s); + return (b); +} + +static void save_temp(TC::CONTAINER *c, IR::Declaration *d) { + DECLLIST *dl; + + dl = new DECLLIST; + dl->decl = d; + dl->link = c->temps; + c->temps = dl; +} + +/* + * The dance for IR::Type_Type is because I see such coming back from + * typemap->getType(). I don't know why and I don't know what it + * means; I hope someone who does know can fix up anything necessary. + */ +const IR::Node *FIXUP_CASTS::postorder(IR::Cast *e) { + CONTAINER *c; + + if (!EBPF::EBPFTypeFactory::instance) abort(); + std::cout << "cast fixup: cast expression: " << e->toString() << std::endl; + std::cout << "Contained in:"; + for (c = contain; c; c = c->link) std::cout << ' ' << (void *)c->s; + std::cout << std::endl; + const IR::Type *argtype; + argtype = typemap->getType(e->expr, true); + if (argtype->is()) argtype = argtype->to()->type; + std::cout << "Arg type: " << argtype->toString() << std::endl; + const IR::Type *casttype; + casttype = typemap->getType(e->destType, true); + if (casttype->is()) casttype = casttype->to()->type; + std::cout << "Cast-to type: " << casttype->toString() << std::endl; + auto aet = EBPF::EBPFTypeFactory::instance->create(argtype); + std::cout << "Arg EBPF type: " << (void *)aet << std::endl; + std::cout << " (" << aet->type->toString() << ")" << std::endl; + auto cet = EBPF::EBPFTypeFactory::instance->create(casttype); + std::cout << "Cast-to EBPF type: " << (void *)cet << std::endl; + std::cout << " (" << cet->type->toString() << ")" << std::endl; + std::cout << "Arg is scalar: " << (aet->is() ? "YES" : "NO") + << "; result is scalar: " << (cet->is() ? "YES" : "NO") + << std::endl; + if (!aet->is() || !cet->is()) return (e); + auto aw = aet->to()->implementationWidthInBits(); + auto cw = cet->to()->implementationWidthInBits(); + std::cout << "Arg width: " << aw + << ", scalar: " << (EBPF::EBPFScalarType::generatesScalar(aw) ? "YES" : "NO") << '\n'; + std::cout << "Result width: " << cw + << ", scalar: " << (EBPF::EBPFScalarType::generatesScalar(cw) ? "YES" : "NO") + << std::endl; + if (EBPF::EBPFScalarType::generatesScalar(aw) && EBPF::EBPFScalarType::generatesScalar(cw)) + return (e); + auto sn = refmap->newName("cast_src"); + auto dn = refmap->newName("cast_dst"); + std::cout << "sn=" << sn << ", dn=" << dn << std::endl; + auto sd = new IR::Declaration_Variable(IR::ID(sn, nullptr), argtype); + auto dd = new IR::Declaration_Variable(IR::ID(dn, nullptr), casttype); + std::cout << "Src declaration: " << sd->toString() << std::endl; + std::cout << "Dst declaration: " << dd->toString() << std::endl; + save_temp(contain, sd); + save_temp(contain, dd); + auto px = new IR::PathExpression(dd->getName()); + std::cout << "Cast expression: " << (void *)e << ", " << e->toString() << std::endl; + std::cout << "Replacement expression: " << (void *)px << ", " << px->toString() << std::endl; + return (px); + // return(e); +} + bool Backend::process() { CHECK_NULL(toplevel); if (toplevel->getMain() == nullptr) { @@ -52,9 +152,11 @@ bool Backend::process() { parseTCAnno = new ParseTCAnnotations(); tcIR = new ConvertToBackendIR(toplevel, pipeline, refMap, typeMap, options); genIJ = new IntrospectionGenerator(pipeline, refMap, typeMap); + EBPF::EBPFTypeFactory::createFactory(typeMapEBPF); PassManager backEnd = {}; backEnd.addPasses({parseTCAnno, new P4::ClearTypeMap(typeMap), - new P4::TypeChecking(refMap, typeMap, true), tcIR, genIJ}); + new P4::TypeChecking(refMap, typeMap, true), tcIR, genIJ, + new FIXUP_CASTS(refMap, typeMap)}); backEnd.addDebugHook(hook, true); toplevel->getProgram()->apply(backEnd); if (::P4::errorCount() > 0) return false; @@ -101,7 +203,7 @@ bool Backend::ebpfCodeGen(P4::ReferenceMap *refMapEBPF, P4::TypeMap *typeMapEBPF main->apply(*parsePnaArch); program = top->getProgram(); - EBPF::EBPFTypeFactory::createFactory(typeMapEBPF); + // EBPF::EBPFTypeFactory::createFactory(typeMapEBPF); auto convertToEbpf = new ConvertToEbpfPNA(ebpfOption, refMapEBPF, typeMapEBPF, tcIR); PassManager toEBPF = { new P4::DiscoverStructure(&structure), diff --git a/backends/tc/backend.h b/backends/tc/backend.h index 3b57f96ed41..7c4b45f6fff 100644 --- a/backends/tc/backend.h +++ b/backends/tc/backend.h @@ -43,6 +43,33 @@ extern cstring PnaMainOutputMetaFields[TC::MAX_PNA_OUTPUT_META]; class PNAEbpfGenerator; +typedef struct decllist DECLLIST; +struct decllist { + DECLLIST *link; + IR::Declaration *decl; +}; + +typedef struct container CONTAINER; +struct container { + CONTAINER *link; + DECLLIST *temps; + IR::Statement *s; +}; + +class FIXUP_CASTS : public Transform { + private: + CONTAINER *contain; + P4::ReferenceMap *refmap; + P4::TypeMap *typemap; + const IR::Node *preorder(IR::Statement *) override; + const IR::Node *postorder(IR::Statement *) override; + const IR::Node *postorder(IR::Cast *) override; + + public: + explicit FIXUP_CASTS(P4::ReferenceMap *rm, P4::TypeMap *tm) + : contain(0), refmap(rm), typemap(tm){}; +}; + /** * Backend code generation from midend IR */ diff --git a/backends/tc/ebpfCodeGen.cpp b/backends/tc/ebpfCodeGen.cpp index 962f29c1d29..b67bd60ab89 100644 --- a/backends/tc/ebpfCodeGen.cpp +++ b/backends/tc/ebpfCodeGen.cpp @@ -665,7 +665,7 @@ void PnaStateTranslationVisitor::compileExtractField(const IR::Expression *expr, unsigned shift = loadSize - alignment - widthToExtract; builder->emitIndent(); if (noEndiannessConversion) { - builder->appendFormat("__builtin_memcpy(&"); + builder->appendFormat("__builtin_memcpy/*A*/(&"); visit(expr); builder->appendFormat(".%s, %s + BYTES(%s), %d)", fieldName, program->packetStartVar.c_str(), program->offsetVar.c_str(), @@ -1881,7 +1881,7 @@ void ControlBodyTranslatorPNA::processApply(const P4::ApplyMethod *method) { builder->emitIndent(); if (memcpy) { - builder->appendFormat("__builtin_memcpy(&(%s.%s[0]), &(", keyname.c_str(), + builder->appendFormat("__builtin_memcpy/*B*/(&(%s.%s[0]), &(", keyname.c_str(), fieldName.c_str()); table->codeGen->visit(c->expression); builder->appendFormat("[0]), %d)", scalar->bytesRequired()); @@ -2269,7 +2269,7 @@ void DeparserHdrEmitTranslatorPNA::emitField(EBPF::CodeBuilder *builder, cstring builder->endOfStatement(true); msgStr = absl::StrFormat("Deparser: emitting field %s=0x%%llx (%u bits)", field, widthToEmit); - builder->target->emitTraceMessage(builder, msgStr.c_str(), 1, "tmp"); + builder->target->emitTraceMessage(builder, msgStr.c_str(), 1, "tmpAD"); builder->blockEnd(true); } } else { diff --git a/backends/tc/tcExterns.cpp b/backends/tc/tcExterns.cpp index 089a4cea893..059af717e01 100644 --- a/backends/tc/tcExterns.cpp +++ b/backends/tc/tcExterns.cpp @@ -58,7 +58,7 @@ void EBPFRegisterPNA::emitRegisterRead(EBPF::CodeBuilder *builder, const P4::Ext builder->appendLine("ext_val = *ext_val_ptr;"); if (leftExpression != nullptr) { builder->emitIndent(); - builder->append("__builtin_memcpy(&"); + builder->append("__builtin_memcpy/*C*/(&"); translator->visit(leftExpression); builder->append(", ext_val.out_params, sizeof("); this->valueType->declare(builder, cstring::empty, false); @@ -73,7 +73,7 @@ void EBPFRegisterPNA::emitRegisterWrite(EBPF::CodeBuilder *builder, const P4::Ex builder->newline(); builder->emitIndent(); - builder->append("__builtin_memcpy(ext_val.out_params, &"); + builder->append("__builtin_memcpy/*D*/(ext_val.out_params, &"); translator->visit(value); builder->append(", sizeof("); this->valueType->declare(builder, cstring::empty, false); diff --git a/backends/ubpf/ubpfControl.cpp b/backends/ubpf/ubpfControl.cpp index 79f9922cea9..26ba0f4e691 100644 --- a/backends/ubpf/ubpfControl.cpp +++ b/backends/ubpf/ubpfControl.cpp @@ -346,7 +346,7 @@ bool UBPFControlBodyTranslator::emitRegisterRead(const IR::AssignmentStatement * pRegister->emitKeyInstance(builder, method); auto etype = UBPFTypeFactory::instance->create(pRegister->keyType); - auto tmp = control->program->refMap->newName("tmp"); + auto tmp = control->program->refMap->newName("tmpAA"); etype->declare(builder, tmp, true); builder->endOfStatement(true); diff --git a/backends/ubpf/ubpfParser.cpp b/backends/ubpf/ubpfParser.cpp index 6f5fe0cc20d..a40a49d4850 100644 --- a/backends/ubpf/ubpfParser.cpp +++ b/backends/ubpf/ubpfParser.cpp @@ -341,7 +341,7 @@ void UBPFStateTranslationVisitor::compileLookahead(const IR::Expression *destina void UBPFStateTranslationVisitor::compileAdvance(const IR::Expression *expr) { auto type = state->parser->typeMap->getType(expr); auto etype = UBPFTypeFactory::instance->create(type); - cstring tmpVarName = refMap->newName("tmp"); + cstring tmpVarName = refMap->newName("tmpAB"); builder->emitIndent(); builder->blockStart(); diff --git a/frontends/p4/moveConstructors.cpp b/frontends/p4/moveConstructors.cpp index 1c8d2450f42..b678cec939e 100644 --- a/frontends/p4/moveConstructors.cpp +++ b/frontends/p4/moveConstructors.cpp @@ -119,7 +119,7 @@ const IR::Node *MoveConstructors::preorder(IR::P4Table *table) { const IR::Node *MoveConstructors::postorder(IR::ConstructorCallExpression *expression) { if (convert == Region::Outside) return expression; - auto tmpvar = nameGen.newName("tmp"); + auto tmpvar = nameGen.newName("tmpAS"); auto tmpref = new IR::PathExpression(IR::ID(expression->srcInfo, tmpvar)); cmap.add(expression, tmpvar); return tmpref; diff --git a/frontends/p4/sideEffects.cpp b/frontends/p4/sideEffects.cpp index 9e50ebd2527..3047d4a7145 100644 --- a/frontends/p4/sideEffects.cpp +++ b/frontends/p4/sideEffects.cpp @@ -29,7 +29,7 @@ namespace P4 { cstring DoSimplifyExpressions::createTemporary(const IR::Type *type) { type = type->getP4Type(); BUG_CHECK(type && !type->is(), "Can't create don't-care temps"); - auto tmp = nameGen.newName("tmp"); + auto tmp = nameGen.newName("tmpAT"); auto decl = new IR::Declaration_Variable(IR::ID(tmp, nullptr), type); toInsert.push_back(decl); return tmp; diff --git a/midend/copyStructures.cpp b/midend/copyStructures.cpp index a7f1faa12fc..cc48e40adf7 100644 --- a/midend/copyStructures.cpp +++ b/midend/copyStructures.cpp @@ -32,7 +32,7 @@ const IR::Node *RemoveAliases::postorder(IR::AssignmentStatement *statement) { if (!rw.mayAlias(statement->left, statement->right, getContext())) { return statement; } - auto tmp = refMap->newName("tmp"); + auto tmp = refMap->newName("tmpAR"); auto *decl = new IR::Declaration_Variable(IR::ID(tmp), type->getP4Type(), nullptr); declarations.push_back(decl); auto *result = new IR::IndexedVector(); diff --git a/midend/expandLookahead.cpp b/midend/expandLookahead.cpp index 92e98a2319f..921e0a27d55 100644 --- a/midend/expandLookahead.cpp +++ b/midend/expandLookahead.cpp @@ -86,7 +86,7 @@ DoExpandLookahead::ExpansionInfo *DoExpandLookahead::convertLookahead( if (width < 0) return nullptr; auto bittype = IR::Type_Bits::get(width); - auto name = refMap->newName("tmp"); + auto name = refMap->newName("tmpAP"); auto decl = new IR::Declaration_Variable(IR::ID(name), bittype, nullptr); newDecls.push_back(decl); diff --git a/midend/flattenUnions.cpp b/midend/flattenUnions.cpp index 15123a462ba..18051dee397 100644 --- a/midend/flattenUnions.cpp +++ b/midend/flattenUnions.cpp @@ -53,7 +53,7 @@ const IR::Node *HandleValidityHeaderUnion::expandIsValid( if (auto bim = mi->to()) { if (bim->name == "isValid") { // hdr.u.isValid() or u.isValid if (auto huType = bim->appliedTo->type->to()) { // u or hdr.u - cstring tmp = refMap->newName("tmp"); + cstring tmp = refMap->newName("tmpAQ"); IR::PathExpression *tmpVar = new IR::PathExpression(IR::ID(tmp)); toInsert.push_back( new IR::Declaration_Variable(IR::ID(tmp), IR::Type_Bits::get(32))); diff --git a/midend/removeComplexExpressions.cpp b/midend/removeComplexExpressions.cpp index dc23be3ff03..5bc241b9cd5 100644 --- a/midend/removeComplexExpressions.cpp +++ b/midend/removeComplexExpressions.cpp @@ -47,7 +47,7 @@ class ComplexExpression : public Inspector { const IR::PathExpression *RemoveComplexExpressions::createTemporary( const IR::Expression *expression) { auto type = typeMap->getType(expression, true); - auto name = refMap->newName("tmp"); + auto name = refMap->newName("tmpAN"); auto decl = new IR::Declaration_Variable(IR::ID(name), type->getP4Type()); newDecls.push_back(decl); typeMap->setType(decl, type); @@ -177,7 +177,7 @@ const IR::Node *RemoveComplexExpressions::postorder(IR::MethodCallStatement *sta em->method->name != P4::P4CoreLibrary::instance().packetIn.lookahead.name) return simpleStatement(statement); auto type = em->actualMethodType->returnType; - auto name = refMap->newName("tmp"); + auto name = refMap->newName("tmpAO"); LOG3("Adding variable for lookahead " << name); auto decl = new IR::Declaration_Variable(IR::ID(name), type->getP4Type()); newDecls.push_back(decl);