File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
backends/cpp_hart_gen/lib Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module Idl
4+ class AstNode
5+ def constexpr? ( symtab )
6+ if children . empty?
7+ true
8+ else
9+ children . all? { |child | child . constexpr? ( symtab ) }
10+ end
11+ end
12+ end
13+ class IdAst
14+ def constexpr? ( symtab )
15+ sym = symtab . get ( name )
16+ return true if sym . nil? # assuming undefined syms are local (be sure to type check first!!)
17+ return true if sym . is_a? ( Type )
18+
19+ !sym . type . global?
20+ end
21+ end
22+ class PcAssignmentAst
23+ def constexpr? ( symtab ) = false
24+ end
25+ class FunctionCallExpressionAst
26+ def constexpr? ( symtab ) = false # conservative, can do better...
27+ end
28+ class CsrFieldReadExpressionAst
29+ def constexpr? ( symtab ) = false
30+ end
31+ class CsrReadExpressionAst
32+ def constexpr? ( symtab ) = false
33+ end
34+ class CsrSoftwareWriteAst
35+ def constexpr? ( symtab ) = false
36+ end
37+ class CsrFunctionCallAst
38+ def constexpr? ( symtab ) = function_name == "address"
39+ end
40+ class CsrWriteAst
41+ def constexpr? ( symtab ) = false
42+ end
43+ class FunctionDefAst
44+ # @return [Boolean] If the function is possibly C++ constexpr (does not access CSRs or registers)
45+ def constexpr? ( symtab )
46+ return false if builtin?
47+
48+ body . constexpr? ( symtab )
49+ end
50+ end
51+ end
You can’t perform that action at this time.
0 commit comments