|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
| 3 | +require "etc" |
| 4 | + |
3 | 5 | $root = Pathname.new(__FILE__).dirname.realpath |
4 | 6 | $lib = $root / "lib" |
5 | 7 |
|
@@ -82,45 +84,84 @@ namespace :validate do |
82 | 84 | end |
83 | 85 | puts "All files validate against their schema" |
84 | 86 | end |
85 | | - task idl: "gen:arch" do |
86 | | - puts "Type checking IDL code..." |
87 | | - arch_def = arch_def_for("_") |
88 | | - progressbar = ProgressBar.create(title: "Instructions", total: arch_def.instructions.size) |
89 | | - arch_def.instructions.each do |inst| |
90 | | - progressbar.increment |
91 | | - inst.type_checked_operation_ast(arch_def.idl_compiler, arch_def.sym_table_32, 32) if inst.rv32? |
92 | | - inst.type_checked_operation_ast(arch_def.idl_compiler, arch_def.sym_table_64, 64) if inst.rv64? |
93 | | - # also need to check for an RV64 machine running with effective XLEN of 32 |
94 | | - inst.type_checked_operation_ast(arch_def.idl_compiler, arch_def.sym_table_64, 32) if inst.rv64? && inst.rv32? |
95 | | - end |
96 | | - progressbar = ProgressBar.create(title: "CSRs", total: arch_def.csrs.size) |
97 | | - arch_def.csrs.each do |csr| |
98 | | - progressbar.increment |
99 | | - if csr.has_custom_sw_read? |
100 | | - csr.type_checked_sw_read_ast(arch_def.sym_table_32) if csr.defined_in_base32? |
101 | | - csr.type_checked_sw_read_ast(arch_def.sym_table_64) if csr.defined_in_base64? |
102 | | - end |
103 | | - csr.fields.each do |field| |
104 | | - unless field.type_ast(arch_def.idl_compiler).nil? |
105 | | - field.type_checked_type_ast(arch_def.sym_table_32) if csr.defined_in_base32? && field.defined_in_base32? |
106 | | - field.type_checked_type_ast(arch_def.sym_table_64) if csr.defined_in_base64? && field.defined_in_base64? |
107 | | - end |
108 | | - unless field.reset_value_ast(arch_def.idl_compiler).nil? |
109 | | - field.type_checked_reset_value_ast(arch_def.sym_table_32) if csr.defined_in_base32? && field.defined_in_base32? |
110 | | - field.type_checked_reset_value_ast(arch_def.sym_table_64) if csr.defined_in_base64? && field.defined_in_base64? |
111 | | - end |
112 | | - unless field.sw_write_ast(arch_def.idl_compiler).nil? |
113 | | - field.type_checked_sw_write_ast(arch_def.sym_table_32, 32) if csr.defined_in_base32? && field.defined_in_base32? |
114 | | - field.type_checked_sw_write_ast(arch_def.sym_table_64, 64) if csr.defined_in_base64? && field.defined_in_base64? |
115 | | - end |
116 | | - end |
117 | | - end |
118 | | - progressbar = ProgressBar.create(title: "Functions", total: arch_def.functions.size) |
119 | | - arch_def.functions.each do |func| |
120 | | - progressbar.increment |
121 | | - func.type_check_body(arch_def.sym_table_32) |
122 | | - func.type_check_body(arch_def.sym_table_64) |
123 | | - end |
| 87 | + task idl: ["gen:arch", "#{$root}/.stamps/arch-gen-_32.stamp", "#{$root}/.stamps/arch-gen-_64.stamp"] do |
| 88 | + print "Parsing IDL code for RV32..." |
| 89 | + arch_def_32 = arch_def_for("_32") |
| 90 | + puts "done" |
| 91 | + |
| 92 | + arch_def_32.type_check |
| 93 | + |
| 94 | + print "Parsing IDL code for RV64..." |
| 95 | + arch_def_64 = arch_def_for("_64") |
| 96 | + puts "done" |
| 97 | + |
| 98 | + arch_def_64.type_check |
| 99 | + |
| 100 | + # arch_def_64 = arch_def_for("_64") |
| 101 | + # arch_def_64.type_check |
| 102 | + |
| 103 | + # puts "Type checking IDL code..." |
| 104 | + # progressbar = ProgressBar.create(title: "Instructions", total: arch_def_32.instructions.size + arch_def_64.instructions.size) |
| 105 | + # arch_def_32.instructions.each do |inst| |
| 106 | + # progressbar.increment |
| 107 | + # inst.type_checked_operation_ast(arch_def_32.idl_compiler, arch_def_32.symtab, 32) if inst.rv32? |
| 108 | + # end |
| 109 | + # arch_def_64.instructions.each do |inst| |
| 110 | + # progressbar.increment |
| 111 | + # inst.type_checked_operation_ast(arch_def_64.idl_compiler, arch_def_64.symtab, 64) if inst.rv64? |
| 112 | + # # also need to check for an RV64 machine running with effective XLEN of 32 |
| 113 | + # inst.type_checked_operation_ast(arch_def_64.idl_compiler, arch_def_64.symtab, 32) if inst.rv64? && inst.rv32? |
| 114 | + # end |
| 115 | + |
| 116 | + # progressbar = ProgressBar.create(title: "CSRs", total: arch_def_32.csrs.size + arch_def_64.csrs.size) |
| 117 | + # arch_def_32.csrs.each do |csr| |
| 118 | + # progressbar.increment |
| 119 | + # profile = RubyProf::Profile.new |
| 120 | + # result = profile.profile do |
| 121 | + # if csr.has_custom_sw_read? |
| 122 | + # csr.type_checked_sw_read_ast(arch_def_32.symtab) if csr.defined_in_base32? |
| 123 | + # end |
| 124 | + # csr.fields.each do |field| |
| 125 | + # unless field.type_ast(arch_def_32.symtab).nil? |
| 126 | + # field.type_checked_type_ast(arch_def_32.symtab) if csr.defined_in_base32? && field.defined_in_base32? |
| 127 | + # end |
| 128 | + # unless field.reset_value_ast(arch_def_32.symtab).nil? |
| 129 | + # field.type_checked_reset_value_ast(arch_def_32.symtab) if csr.defined_in_base32? && field.defined_in_base32? |
| 130 | + # end |
| 131 | + # unless field.sw_write_ast(arch_def_32.symtab).nil? |
| 132 | + # field.type_checked_sw_write_ast(arch_def_32.symtab, 32) if csr.defined_in_base32? && field.defined_in_base32? |
| 133 | + # end |
| 134 | + # end |
| 135 | + # end |
| 136 | + # RubyProf::GraphHtmlPrinter.new(result).print(File.open("#{csr.name}-prof.html", "w+"), {}) |
| 137 | + # end |
| 138 | + # arch_def_64.csrs.each do |csr| |
| 139 | + # progressbar.increment |
| 140 | + # if csr.has_custom_sw_read? |
| 141 | + # csr.type_checked_sw_read_ast(arch_def_64.symtab) if csr.defined_in_base64? |
| 142 | + # end |
| 143 | + # csr.fields.each do |field| |
| 144 | + # unless field.type_ast(arch_def_64.symtab).nil? |
| 145 | + # field.type_checked_type_ast(arch_def_64.symtab) if csr.defined_in_base64? && field.defined_in_base64? |
| 146 | + # end |
| 147 | + # unless field.reset_value_ast(arch_def_64.symtab).nil? |
| 148 | + # field.type_checked_reset_value_ast(arch_def_64.symtab) if csr.defined_in_base64? && field.defined_in_base64? |
| 149 | + # end |
| 150 | + # unless field.sw_write_ast(arch_def_64.symtab).nil? |
| 151 | + # field.type_checked_sw_write_ast(arch_def_64.symtab, 32) if csr.defined_in_base32? && field.defined_in_base32? |
| 152 | + # field.type_checked_sw_write_ast(arch_def_64.symtab, 64) if csr.defined_in_base64? && field.defined_in_base64? |
| 153 | + # end |
| 154 | + # end |
| 155 | + # end |
| 156 | + # progressbar = ProgressBar.create(title: "Functions", total: arch_def_32.functions.size + arch_def_64.functions.size) |
| 157 | + # arch_def_32.functions.each do |func| |
| 158 | + # progressbar.increment |
| 159 | + # func.type_check(arch_def_32.symtab) |
| 160 | + # end |
| 161 | + # arch_def_64.functions.each do |func| |
| 162 | + # progressbar.increment |
| 163 | + # func.type_check(arch_def_64.symtab) |
| 164 | + # end |
124 | 165 | puts "All IDL passed type checking" |
125 | 166 | end |
126 | 167 | end |
|
0 commit comments