macroop.isa (5046:da031ef02439) macroop.isa (5161:e7334f2d7bef)
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:

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

137
138// Basic instruction class constructor template.
139def template MacroConstructor {{
140 inline X86Macroop::%(class_name)s::%(class_name)s(
141 ExtMachInst machInst, EmulEnv env)
142 : %(base_class)s("%(mnemonic)s", machInst, %(num_microops)s)
143 {
144 %(adjust_env)s;
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:

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

137
138// Basic instruction class constructor template.
139def template MacroConstructor {{
140 inline X86Macroop::%(class_name)s::%(class_name)s(
141 ExtMachInst machInst, EmulEnv env)
142 : %(base_class)s("%(mnemonic)s", machInst, %(num_microops)s)
143 {
144 %(adjust_env)s;
145 %(adjust_imm)s;
146 %(adjust_disp)s;
145 %(do_modrm)s;
146 %(constructor)s;
147 //alloc_microops is the code that sets up the microops
148 //array in the parent class.
149 %(alloc_microops)s;
150 }
151}};
152
153let {{
154 from micro_asm import Combinational_Macroop, Rom_Macroop
155 class X86Macroop(Combinational_Macroop):
156 def add_microop(self, mnemonic, microop):
157 microop.mnemonic = mnemonic
158 microop.micropc = len(self.microops)
159 self.microops.append(microop)
160 def setAdjustEnv(self, val):
161 self.adjust_env = val
147 %(do_modrm)s;
148 %(constructor)s;
149 //alloc_microops is the code that sets up the microops
150 //array in the parent class.
151 %(alloc_microops)s;
152 }
153}};
154
155let {{
156 from micro_asm import Combinational_Macroop, Rom_Macroop
157 class X86Macroop(Combinational_Macroop):
158 def add_microop(self, mnemonic, microop):
159 microop.mnemonic = mnemonic
160 microop.micropc = len(self.microops)
161 self.microops.append(microop)
162 def setAdjustEnv(self, val):
163 self.adjust_env = val
164 def adjustImm(self, val):
165 self.adjust_imm += val
166 def adjustDisp(self, val):
167 self.adjust_disp += val
162 def __init__(self, name):
163 super(X86Macroop, self).__init__(name)
164 self.directives = {
168 def __init__(self, name):
169 super(X86Macroop, self).__init__(name)
170 self.directives = {
165 "adjust_env" : self.setAdjustEnv
171 "adjust_env" : self.setAdjustEnv,
172 "adjust_imm" : self.adjustImm,
173 "adjust_disp" : self.adjustDisp
166 }
167 self.declared = False
168 self.adjust_env = ""
169 self.doModRM = ""
174 }
175 self.declared = False
176 self.adjust_env = ""
177 self.doModRM = ""
178 self.adjust_imm = '''
179 uint64_t adjustedImm = IMMEDIATE;
180 //This is to pacify gcc in case the immediate isn't used.
181 adjustedImm = adjustedImm;
182 '''
183 self.adjust_disp = '''
184 uint64_t adjustedDisp = DISPLACEMENT;
185 //This is to pacify gcc in case the displacement isn't used.
186 adjustedDisp = adjustedDisp;
187 '''
170 def getAllocator(self, env):
171 return "new X86Macroop::%s(machInst, %s)" % (self.name, env.getAllocator())
172 def getDeclaration(self):
173 #FIXME This first parameter should be the mnemonic. I need to
174 #write some code which pulls that out
175 declareLabels = ""
176 for (label, microop) in self.labels.items():
177 declareLabels += "const static uint64_t label_%s = %d;\n" \

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

193 (micropc, op.getAllocator(True, False,
194 micropc == 0,
195 micropc == numMicroops - 1))
196 micropc += 1
197 iop = InstObjParams(self.name, self.name, "Macroop",
198 {"code" : "", "num_microops" : numMicroops,
199 "alloc_microops" : allocMicroops,
200 "adjust_env" : self.adjust_env,
188 def getAllocator(self, env):
189 return "new X86Macroop::%s(machInst, %s)" % (self.name, env.getAllocator())
190 def getDeclaration(self):
191 #FIXME This first parameter should be the mnemonic. I need to
192 #write some code which pulls that out
193 declareLabels = ""
194 for (label, microop) in self.labels.items():
195 declareLabels += "const static uint64_t label_%s = %d;\n" \

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

211 (micropc, op.getAllocator(True, False,
212 micropc == 0,
213 micropc == numMicroops - 1))
214 micropc += 1
215 iop = InstObjParams(self.name, self.name, "Macroop",
216 {"code" : "", "num_microops" : numMicroops,
217 "alloc_microops" : allocMicroops,
218 "adjust_env" : self.adjust_env,
219 "adjust_imm" : self.adjust_imm,
220 "adjust_disp" : self.adjust_disp,
201 "do_modrm" : self.doModRM})
202 return MacroConstructor.subst(iop);
203}};
204
205let {{
206 class EmulEnv(object):
207 def __init__(self):
208 self.reg = "0"

--- 71 unchanged lines hidden ---
221 "do_modrm" : self.doModRM})
222 return MacroConstructor.subst(iop);
223}};
224
225let {{
226 class EmulEnv(object):
227 def __init__(self):
228 self.reg = "0"

--- 71 unchanged lines hidden ---