isa_parser.py (6992:0288d8e8b192) | isa_parser.py (7092:fbdf4fca0844) |
---|---|
1# Copyright (c) 2003-2005 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 374 unchanged lines hidden (view full) --- 383class Operand(object): 384 '''Base class for operand descriptors. An instance of this class 385 (or actually a class derived from this one) represents a specific 386 operand for a code block (e.g, "Rc.sq" as a dest). Intermediate 387 derived classes encapsulates the traits of a particular operand 388 type (e.g., "32-bit integer register").''' 389 390 def buildReadCode(self, func = None): | 1# Copyright (c) 2003-2005 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 374 unchanged lines hidden (view full) --- 383class Operand(object): 384 '''Base class for operand descriptors. An instance of this class 385 (or actually a class derived from this one) represents a specific 386 operand for a code block (e.g, "Rc.sq" as a dest). Intermediate 387 derived classes encapsulates the traits of a particular operand 388 type (e.g., "32-bit integer register").''' 389 390 def buildReadCode(self, func = None): |
391 code = self.read_code % {"name": self.base_name, 392 "func": func, 393 "op_idx": self.src_reg_idx, 394 "reg_idx": self.reg_spec, 395 "size": self.size, 396 "ctype": self.ctype} | 391 subst_dict = {"name": self.base_name, 392 "func": func, 393 "reg_idx": self.reg_spec, 394 "size": self.size, 395 "ctype": self.ctype} 396 if hasattr(self, 'src_reg_idx'): 397 subst_dict['op_idx'] = self.src_reg_idx 398 code = self.read_code % subst_dict |
397 if self.size != self.dflt_size: 398 return '%s = bits(%s, %d, 0);\n' % \ 399 (self.base_name, code, self.size-1) 400 else: 401 return '%s = %s;\n' % \ 402 (self.base_name, code) 403 404 def buildWriteCode(self, func = None): 405 if (self.size != self.dflt_size and self.is_signed): 406 final_val = 'sext<%d>(%s)' % (self.size, self.base_name) 407 else: 408 final_val = self.base_name | 399 if self.size != self.dflt_size: 400 return '%s = bits(%s, %d, 0);\n' % \ 401 (self.base_name, code, self.size-1) 402 else: 403 return '%s = %s;\n' % \ 404 (self.base_name, code) 405 406 def buildWriteCode(self, func = None): 407 if (self.size != self.dflt_size and self.is_signed): 408 final_val = 'sext<%d>(%s)' % (self.size, self.base_name) 409 else: 410 final_val = self.base_name |
409 code = self.write_code % {"name": self.base_name, 410 "func": func, 411 "op_idx": self.dest_reg_idx, 412 "reg_idx": self.reg_spec, 413 "size": self.size, 414 "ctype": self.ctype, 415 "final_val": final_val} | 411 subst_dict = {"name": self.base_name, 412 "func": func, 413 "reg_idx": self.reg_spec, 414 "size": self.size, 415 "ctype": self.ctype, 416 "final_val": final_val} 417 if hasattr(self, 'dest_reg_idx'): 418 subst_dict['op_idx'] = self.dest_reg_idx 419 code = self.write_code % subst_dict |
416 return ''' 417 { 418 %s final_val = %s; 419 %s; 420 if (traceData) { traceData->setData(final_val); } 421 }''' % (self.dflt_ctype, final_val, code) 422 423 def __init__(self, parser, full_name, ext, is_src, is_dest): --- 1655 unchanged lines hidden --- | 420 return ''' 421 { 422 %s final_val = %s; 423 %s; 424 if (traceData) { traceData->setData(final_val); } 425 }''' % (self.dflt_ctype, final_val, code) 426 427 def __init__(self, parser, full_name, ext, is_src, is_dest): --- 1655 unchanged lines hidden --- |