P4C
The P4 Compiler
Loading...
Searching...
No Matches
substituteParameters.h
1/*
2 * SPDX-FileCopyrightText: 2013 Barefoot Networks, Inc.
3 * Copyright 2013-present Barefoot Networks, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8/* -*-C++-*- */
9
10#ifndef FRONTENDS_P4_EVALUATOR_SUBSTITUTEPARAMETERS_H_
11#define FRONTENDS_P4_EVALUATOR_SUBSTITUTEPARAMETERS_H_
12
13#include "frontends/common/resolveReferences/resolveReferences.h"
14#include "frontends/p4/parameterSubstitution.h"
15#include "frontends/p4/typeChecking/typeSubstitutionVisitor.h"
16#include "ir/ir.h"
17
18namespace P4 {
19
20class SubstituteParameters : public TypeVariableSubstitutionVisitor, public ResolutionContext {
21 protected:
22 const DeclarationLookup *refMap; // input
23 const ParameterSubstitution *subst; // input
24
26 bool useParameterSourceInfo(const IR::Expression *replacement) const;
27
28 public:
29 SubstituteParameters(const DeclarationLookup *refMap, const ParameterSubstitution *subst,
30 const TypeVariableSubstitution *tvs)
31 : TypeVariableSubstitutionVisitor(tvs), refMap(refMap), subst(subst) {
32 CHECK_NULL(subst);
33 CHECK_NULL(tvs);
34 visitDagOnce = true;
35 setName("SubstituteParameters");
36 LOG1("Will substitute " << std::endl << subst << bindings);
37 }
38 using TypeVariableSubstitutionVisitor::postorder;
39 const IR::Node *postorder(IR::PathExpression *expr) override;
40 const IR::Node *postorder(IR::Type_Name *type) override;
41 const IR::Node *postorder(IR::This *t) override;
42};
43
44} // namespace P4
45
46#endif /* FRONTENDS_P4_EVALUATOR_SUBSTITUTEPARAMETERS_H_ */
Definition referenceMap.h:48
Definition node.h:44
Definition parameterSubstitution.h:21
bool useParameterSourceInfo(const IR::Expression *replacement) const
Use the parameter's location for compiler temporaries or arguments with no source location.
Definition substituteParameters.cpp:10
Definition typeSubstitution.h:64
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13