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