DMA: Split the DMA device and IO device into seperate files
[gem5.git] / src / arch / isa_parser.py
index 95bbd15e4a7925f7abef552cb7ba44fe6cfc3847..c0cdebe11cc8802ed94f5328f1dbd4fe467db905 100755 (executable)
@@ -209,9 +209,6 @@ class Template(object):
                     op_wb_str = op_desc.op_wb + op_wb_str
             myDict['op_wb'] = op_wb_str
 
-            if d.operands.memOperand:
-                myDict['mem_acc_type'] = d.operands.memOperand.mem_acc_type
-
         elif isinstance(d, dict):
             # if the argument is a dictionary, we just use it.
             myDict.update(d)
@@ -453,11 +450,6 @@ class Operand(object):
         if hasattr(self, 'eff_ext'):
             self.ctype = parser.operandTypeMap[self.eff_ext]
 
-        # note that mem_acc_type is undefined for non-mem operands...
-        # template must be careful not to use it if it doesn't apply.
-        if self.isMem():
-            self.mem_acc_type = self.ctype
-
     # Finalize additional fields (primarily code fields).  This step
     # is done separately since some of these fields may depend on the
     # register index enumeration that hasn't been performed yet at the
@@ -695,8 +687,9 @@ class OperandList(object):
     def __init__(self, parser, code):
         self.items = []
         self.bases = {}
-        # delete comments so we don't match on reg specifiers inside
-        code = commentRE.sub('', code)
+        # delete strings and comments so we don't match on operands inside
+        for regEx in (stringRE, commentRE):
+            code = regEx.sub('', code)
         # search for operands
         next_pos = 0
         while 1:
@@ -810,8 +803,9 @@ class SubOperandList(OperandList):
     def __init__(self, parser, code, master_list):
         self.items = []
         self.bases = {}
-        # delete comments so we don't match on reg specifiers inside
-        code = commentRE.sub('', code)
+        # delete strings and comments so we don't match on operands inside
+        for regEx in (stringRE, commentRE):
+            code = regEx.sub('', code)
         # search for operands
         next_pos = 0
         while 1:
@@ -862,9 +856,13 @@ class SubOperandList(OperandList):
                     error("Code block has more than one memory operand.")
                 self.memOperand = op_desc
 
+# Regular expression object to match C++ strings
+stringRE = re.compile(r'"([^"\\]|\\.)*"')
+
 # Regular expression object to match C++ comments
 # (used in findOperands())
-commentRE = re.compile(r'//.*\n')
+commentRE = re.compile(r'(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
+        re.DOTALL | re.MULTILINE)
 
 # Regular expression object to match assignment statements
 # (used in findOperands())
@@ -1853,21 +1851,21 @@ StaticInstPtr
 
         # Define operand variables.
         operands = user_dict.keys()
+        extensions = self.operandTypeMap.keys()
 
-        operandsREString = (r'''
-        (?<![\w\.])      # neg. lookbehind assertion: prevent partial matches
-        ((%s)(?:\.(\w+))?)   # match: operand with optional '.' then suffix
-        (?![\w\.])       # neg. lookahead assertion: prevent partial matches
-        '''
-                            % string.join(operands, '|'))
+        operandsREString = r'''
+        (?<!\w)      # neg. lookbehind assertion: prevent partial matches
+        ((%s)(?:_(%s))?)   # match: operand with optional '_' then suffix
+        (?!\w)       # neg. lookahead assertion: prevent partial matches
+        ''' % (string.join(operands, '|'), string.join(extensions, '|'))
 
         self.operandsRE = re.compile(operandsREString, re.MULTILINE|re.VERBOSE)
 
         # Same as operandsREString, but extension is mandatory, and only two
         # groups are returned (base and ext, not full name as above).
         # Used for subtituting '_' for '.' to make C++ identifiers.
-        operandsWithExtREString = (r'(?<![\w\.])(%s)\.(\w+)(?![\w\.])'
-                                   % string.join(operands, '|'))
+        operandsWithExtREString = r'(?<!\w)(%s)_(%s)(?!\w)' \
+            % (string.join(operands, '|'), string.join(extensions, '|'))
 
         self.operandsWithExtRE = \
             re.compile(operandsWithExtREString, re.MULTILINE)