@@ -6050,18 +6050,16 @@ def freeze_tree(symtab)
60506050 def type_check(symtab)
60516051 @csr.type_check(symtab)
60526052
6053- type_error "CSR[#{ csr_name ( symtab ) } ] has no field named #{ @field_name } " if field_def(symtab).nil?
6054- type_error "CSR[#{ csr_name ( symtab ) } ].#{ @field_name } is not defined in RV32" if symtab.cfg_arch.mxlen == 32 && !field_def(symtab).defined_in_base32?
6055- type_error "CSR[#{ csr_name ( symtab ) } ].#{ @field_name } is not defined in RV64" if symtab.cfg_arch.mxlen == 64 && !field_def(symtab).defined_in_base64?
6053+ type_error "CSR[#{ csr_name } ] has no field named #{ @field_name } " if field_def(symtab).nil?
6054+ type_error "CSR[#{ csr_name } ].#{ @field_name } is not defined in RV32" if symtab.cfg_arch.mxlen == 32 && !field_def(symtab).defined_in_base32?
6055+ type_error "CSR[#{ csr_name } ].#{ @field_name } is not defined in RV64" if symtab.cfg_arch.mxlen == 64 && !field_def(symtab).defined_in_base64?
60566056 end
60576057
60586058 def csr_def(symtab)
60596059 @csr_obj
60606060 end
60616061
6062- def csr_name(symtab)
6063- csr_def(symtab).name
6064- end
6062+ def csr_name = @csr.csr_name
60656063
60666064 def field_def(symtab)
60676065 @csr_obj.fields.find { |f| f.name == @field_name }
@@ -6103,7 +6101,7 @@ def calc_type(symtab)
61036101 # @!macro value
61046102 def value(symtab)
61056103 if @value.nil?
6106- value_error "'#{ csr_name ( symtab ) } .#{ field_name ( symtab ) } ' is not RO"
6104+ value_error "'#{ csr_name } .#{ field_name ( symtab ) } ' is not RO"
61076105 else
61086106 @value
61096107 end
@@ -6115,7 +6113,7 @@ def calc_value(symtab)
61156113
61166114 symtab.cfg_arch.possible_xlens.each do |effective_xlen|
61176115 unless field_def(symtab).type(effective_xlen) == "RO"
6118- value_error "'#{ csr_name ( symtab ) } .#{ field_name ( symtab ) } ' is not RO"
6116+ value_error "'#{ csr_name } .#{ field_name ( symtab ) } ' is not RO"
61196117 end
61206118 end
61216119
@@ -6177,20 +6175,14 @@ def csr_known?(symtab)
61776175 !csr_def(symtab).nil?
61786176 end
61796177
6180- def csr_name(symtab)
6181- internal_error "No CSR" unless csr_known?(symtab)
6182-
6183- csr_def(symtab).name
6184- end
6185-
61866178 # @!macro value
61876179 def value(symtab)
61886180 if symtab.cfg_arch.fully_configured?
61896181 value_error "CSR is not implemented" unless symtab.cfg_arch.transitive_implemented_csrs.any? { |icsr| icsr.name == @csr_obj.name }
61906182 else
61916183 value_error "CSR is not defined" unless symtab.cfg_arch.csrs.any? { |icsr| icsr.name == @csr_obj.name }
61926184 end
6193- @csr_obj.fields.each { |f| value_error "#{ csr_name ( symtab ) } .#{ f . name } not RO" unless f.type(symtab) == "RO" }
6185+ @csr_obj.fields.each { |f| value_error "#{ csr_name } .#{ f . name } not RO" unless f.type(symtab) == "RO" }
61946186
61956187 csr_def(symtab).fields.reduce(0) { |val, f| val | (f.value << f.location.begin) }
61966188 end
@@ -6231,9 +6223,7 @@ def csr_known?(symtab)
62316223 csr.csr_known?(symtab)
62326224 end
62336225
6234- def csr_name(symtab)
6235- csr.csr_name(symtab)
6236- end
6226+ def csr_name = csr.csr_name
62376227
62386228 # @!macro value
62396229 def value(_symtab)
@@ -6299,7 +6289,7 @@ def type(symtab)
62996289 case function_name
63006290 when "sw_read"
63016291 if csr_known?(symtab)
6302- l = cfg_arch.csr(csr.csr_name(symtab) ).length
6292+ l = cfg_arch.csr(csr.csr_name).length
63036293 Type.new(:bits, width: (l.nil? ? :unknown : l))
63046294 else
63056295 Type.new(:bits, width: symtab.mxlen.nil? ? :unknown : symtab.mxlen)
@@ -6317,9 +6307,7 @@ def csr_known?(symtab)
63176307 csr.csr_known?(symtab)
63186308 end
63196309
6320- def csr_name(symtab)
6321- csr.csr_name(symtab)
6322- end
6310+ def csr_name = csr.csr_name
63236311
63246312 def csr_def(symtab)
63256313 csr.csr_def(symtab)
@@ -6331,7 +6319,7 @@ def value(symtab)
63316319 when "sw_read"
63326320 value_error "CSR not knowable" unless csr_known?(symtab)
63336321 cd = csr_def(symtab)
6334- cd.fields.each { |f| value_error "#{ csr_name ( symtab ) } .#{ f . name } not RO" unless f.type(symtab) == "RO" }
6322+ cd.fields.each { |f| value_error "#{ csr_name } .#{ f . name } not RO" unless f.type(symtab) == "RO" }
63356323
63366324 value_error "TODO: CSRs with sw_read function"
63376325 when "address"
0 commit comments