Deleted Added
sdiff udiff text old ( 5786:07f635cab026 ) new ( 5788:6d4161a36ca1 )
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:

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

71
72output header {{
73
74 // Base class for combinationally generated macroops
75 class Macroop : public X86ISA::MacroopBase
76 {
77 public:
78 Macroop(const char *mnem, ExtMachInst _machInst,
79 uint32_t _numMicroops, X86ISA::EmulEnv _emulEnv)
80 : MacroopBase(mnem, _machInst, _numMicroops, _emulEnv)
81 {}
82 %(MacroExecPanic)s
83 };
84}};
85
86//////////////////////////////////////////////////////////////////////////////
87//
88// X86 specific

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

97 * Static instruction class for "%(mnemonic)s".
98 */
99 class %(class_name)s : public %(base_class)s
100 {
101 private:
102 %(declareLabels)s
103 public:
104 // Constructor.
105 %(class_name)s(ExtMachInst machInst, X86ISA::EmulEnv env);
106 };
107 };
108}};
109
110// Basic instruction class constructor template.
111def template MacroConstructor {{
112 inline X86Macroop::%(class_name)s::%(class_name)s(
113 ExtMachInst machInst, EmulEnv env)
114 : %(base_class)s("%(mnemonic)s", machInst, %(num_microops)s, env)
115 {
116 %(adjust_env)s;
117 %(adjust_imm)s;
118 %(adjust_disp)s;
119 %(do_modrm)s;
120 %(constructor)s;
121 //alloc_microops is the code that sets up the microops
122 //array in the parent class.
123 %(alloc_microops)s;
124 }
125}};
126
127let {{
128 from micro_asm import Combinational_Macroop, Rom_Macroop

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

153 adjustedImm = adjustedImm;
154 '''
155 self.adjust_disp = '''
156 uint64_t adjustedDisp = DISPLACEMENT;
157 //This is to pacify gcc in case the displacement isn't used.
158 adjustedDisp = adjustedDisp;
159 '''
160 def getAllocator(self, env):
161 return "new X86Macroop::%s(machInst, %s)" % (self.name, env.getAllocator())
162 def getDeclaration(self):
163 #FIXME This first parameter should be the mnemonic. I need to
164 #write some code which pulls that out
165 declareLabels = ""
166 for (label, microop) in self.labels.items():
167 declareLabels += "const static uint64_t label_%s = %d;\n" \
168 % (label, microop.micropc)
169 iop = InstObjParams(self.name, self.name, "Macroop",
170 {"code" : "",
171 "declareLabels" : declareLabels
172 })
173 return MacroDeclare.subst(iop);
174 def getDefinition(self):
175 #FIXME This first parameter should be the mnemonic. I need to
176 #write some code which pulls that out
177 numMicroops = len(self.microops)
178 allocMicroops = ''
179 micropc = 0
180 for op in self.microops:
181 isLast = (micropc == numMicroops - 1)
182 allocMicroops += \
183 "microops[%d] = %s;\n" % \
184 (micropc, op.getAllocator(True, not isLast,
185 micropc == 0, isLast))
186 micropc += 1
187 iop = InstObjParams(self.name, self.name, "Macroop",
188 {"code" : "", "num_microops" : numMicroops,
189 "alloc_microops" : allocMicroops,
190 "adjust_env" : self.adjust_env,
191 "adjust_imm" : self.adjust_imm,
192 "adjust_disp" : self.adjust_disp,
193 "do_modrm" : self.doModRM})
194 return MacroConstructor.subst(iop);
195}};
196
197let {{
198 class EmulEnv(object):
199 def __init__(self):
200 self.reg = "0"
201 self.regUsed = False
202 self.regm = "0"
203 self.regmUsed = False
204 self.seg = "SEGMENT_REG_DS"
205 self.size = None
206 self.addressSize = "ADDRSIZE"
207 self.dataSize = "OPSIZE"
208 self.stackSize = "STACKSIZE"
209 self.doModRM = False
210
211 def getAllocator(self):
212 if self.size == 'b':
213 self.dataSize = 1
214 elif self.size == 'd':
215 self.dataSize = 4
216 #This is for "double plus" which is normally a double word unless
217 #the REX W bit is set, in which case it's a quad word. It's used
218 #for some SSE instructions.

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

259 blocks = OutputBlocks()
260 if not macroopDict.has_key(Name):
261 raise Exception, "Unrecognized instruction: %s" % Name
262 macroop = macroopDict[Name]
263 if not macroop.declared:
264 if env.doModRM:
265 macroop.doModRM = doModRMString
266 blocks.header_output = macroop.getDeclaration()
267 blocks.decoder_output = macroop.getDefinition()
268 macroop.declared = True
269 blocks.decode_block = "return %s;\n" % macroop.getAllocator(env)
270 return blocks
271}};