Deleted Added
sdiff udiff text old ( 4601:38c989d15fef ) new ( 4609:29b5f66fed1a )
full compact
1// -*- mode:c++ -*-
2
3// Copyright (c) 2007 The Hewlett-Packard Development Company
4// All rights reserved.
5//
6// Redistribution and use of this software in source and binary forms,
7// with or without modification, are permitted provided that the
8// following conditions are met:

--- 50 unchanged lines hidden (view full) ---

59//
60// Code to "specialize" a microcode sequence to use a particular
61// variety of operands
62//
63
64let {{
65 # This code builds up a decode block which decodes based on switchval.
66 # vals is a dict which matches case values with what should be decoded to.
67 # builder is called on the exploded contents of "vals" values to generate
68 # whatever code should be used.
69 def doSplitDecode(builder, switchVal, vals, default = None):
70 blocks = OutputBlocks()
71 blocks.decode_block = 'switch(%s) {\n' % switchVal
72 for (val, todo) in vals.items():
73 new_blocks = builder(*todo)
74 new_blocks.decode_block = \
75 '\tcase %s: %s\n' % (val, new_blocks.decode_block)
76 blocks.append(new_blocks)
77 if default:
78 new_blocks = builder(*default)
79 new_blocks.decode_block = \
80 '\tdefault: %s\n' % new_blocks.decode_block
81 blocks.append(new_blocks)
82 blocks.decode_block += '}\n'
83 return blocks
84}};
85
86let {{
87 class OpType(object):
88 parser = re.compile(r"(?P<tag>[A-Z]+)(?P<size>[a-z]*)|(r(?P<reg>[A-Z0-9]+)(?P<rsize>[a-z]*))")
89 def __init__(self, opTypeString):
90 match = OpType.parser.search(opTypeString)
91 if match == None:
92 raise Exception, "Problem parsing operand type %s" % opTypeString
93 self.reg = match.group("reg")
94 self.tag = match.group("tag")

--- 42 unchanged lines hidden (view full) ---

137 # This might refer to memory or to a register. We need to
138 # divide it up farther.
139 regEnv = copy.copy(env)
140 regEnv.addReg(ModRMRMIndex)
141 # This refers to memory. The macroop constructor should set up
142 # modrm addressing.
143 memEnv = copy.copy(env)
144 memEnv.doModRM = True
145 return doSplitDecode(specializeInst, "MODRM_MOD",
146 {"3" : (Name + "_R", copy.copy(opTypes), regEnv)},
147 (Name + "_M", copy.copy(opTypes), memEnv))
148 elif opType.tag in ("I", "J"):
149 # Immediates
150 Name += "_I"
151 elif opType.tag in ("PR", "R", "VR"):
152 # Non register modrm settings should cause an error
153 env.addReg(ModRMRMIndex)
154 Name += "_R"
155 else:
156 raise Exception, "Unrecognized tag %s." % opType.tag
157
158 # Generate code to return a macroop of the given name which will
159 # operate in the "emulation environment" env
160 return genMacroop(Name, env)
161}};