2012-04-13 01:08:20 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2006-08-26 11:35:28 +00:00
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: Verilator: Propagate constants across AST
|
|
|
|
//
|
2019-11-08 03:33:59 +00:00
|
|
|
// Code available from: https://verilator.org
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2023-01-01 15:18:39 +00:00
|
|
|
// Copyright 2003-2023 by Wilson Snyder. This program is free software; you
|
2020-03-21 15:24:24 +00:00
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2009-05-04 21:07:57 +00:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
2019-10-05 00:17:11 +00:00
|
|
|
|
2021-03-04 02:57:07 +00:00
|
|
|
#ifndef VERILATOR_V3CONST_H_
|
|
|
|
#define VERILATOR_V3CONST_H_
|
2018-10-14 17:43:24 +00:00
|
|
|
|
2006-12-18 19:20:45 +00:00
|
|
|
#include "config_build.h"
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 17:43:24 +00:00
|
|
|
|
2022-11-13 20:33:11 +00:00
|
|
|
#include "V3Ast.h"
|
2023-09-25 02:12:23 +00:00
|
|
|
#include "V3ThreadSafety.h"
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2020-11-19 02:32:16 +00:00
|
|
|
class V3Const final {
|
2006-08-26 11:35:28 +00:00
|
|
|
public:
|
2023-09-25 02:12:23 +00:00
|
|
|
static AstNode* constifyParamsEdit(AstNode* nodep) VL_MT_DISABLED;
|
|
|
|
static AstNodeExpr* constifyParamsEdit(AstNodeExpr* exprp) VL_MT_DISABLED {
|
2022-11-13 20:33:11 +00:00
|
|
|
return VN_AS(constifyParamsEdit(static_cast<AstNode*>(exprp)), NodeExpr);
|
|
|
|
}
|
2023-09-25 02:12:23 +00:00
|
|
|
static AstNode* constifyParamsNoWarnEdit(AstNode* nodep) VL_MT_DISABLED;
|
|
|
|
static AstNodeExpr* constifyParamsNoWarnEdit(AstNodeExpr* exprp) VL_MT_DISABLED {
|
2023-07-03 17:55:24 +00:00
|
|
|
return VN_AS(constifyParamsNoWarnEdit(static_cast<AstNode*>(exprp)), NodeExpr);
|
|
|
|
}
|
2023-09-25 02:12:23 +00:00
|
|
|
static AstNode* constifyGenerateParamsEdit(AstNode* nodep) VL_MT_DISABLED;
|
2010-12-29 02:23:16 +00:00
|
|
|
// Only do constant pushing, without removing dead logic
|
2023-09-25 02:12:23 +00:00
|
|
|
static void constifyAllLive(AstNetlist* nodep) VL_MT_DISABLED;
|
2006-08-26 11:35:28 +00:00
|
|
|
// Everything that's possible
|
2023-09-25 02:12:23 +00:00
|
|
|
static void constifyAll(AstNetlist* nodep) VL_MT_DISABLED;
|
2006-08-26 11:35:28 +00:00
|
|
|
// Also, warn
|
2023-09-25 02:12:23 +00:00
|
|
|
static void constifyAllLint(AstNetlist* nodep) VL_MT_DISABLED;
|
2006-08-26 11:35:28 +00:00
|
|
|
// C++ datatypes
|
2023-09-25 02:12:23 +00:00
|
|
|
static void constifyCpp(AstNetlist* nodep) VL_MT_DISABLED;
|
2006-08-26 11:35:28 +00:00
|
|
|
// Only the current node and lower
|
2009-10-15 00:13:04 +00:00
|
|
|
// Return new node that may have replaced nodep
|
2023-09-25 02:12:23 +00:00
|
|
|
static AstNode* constifyEditCpp(AstNode* nodep) VL_MT_DISABLED;
|
|
|
|
static AstNodeExpr* constifyEditCpp(AstNodeExpr* exprp) VL_MT_DISABLED {
|
2022-11-13 20:33:11 +00:00
|
|
|
return VN_AS(constifyEditCpp(static_cast<AstNode*>(exprp)), NodeExpr);
|
|
|
|
}
|
2022-08-02 12:36:14 +00:00
|
|
|
// Only the current node and lower
|
|
|
|
// Return new node that may have replaced nodep
|
2023-09-25 02:12:23 +00:00
|
|
|
static AstNode* constifyEdit(AstNode* nodep) VL_MT_DISABLED;
|
|
|
|
static AstNodeExpr* constifyEdit(AstNodeExpr* exprp) VL_MT_DISABLED {
|
2022-11-13 20:33:11 +00:00
|
|
|
return VN_AS(constifyEdit(static_cast<AstNode*>(exprp)), NodeExpr);
|
|
|
|
}
|
2009-01-07 14:37:59 +00:00
|
|
|
// Only the current node and lower, with special SenTree optimization
|
2009-10-15 00:13:04 +00:00
|
|
|
// Return new node that may have replaced nodep
|
2023-09-25 02:12:23 +00:00
|
|
|
static AstNode* constifyExpensiveEdit(AstNode* nodep) VL_MT_DISABLED;
|
2006-08-26 11:35:28 +00:00
|
|
|
};
|
|
|
|
|
2019-05-19 20:13:13 +00:00
|
|
|
#endif // Guard
|