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; |
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 |
168 def __init__(self, name): 169 super(X86Macroop, self).__init__(name) 170 self.directives = { |
171 "adjust_env" : self.setAdjustEnv, 172 "adjust_imm" : self.adjustImm, 173 "adjust_disp" : self.adjustDisp |
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 ''' |
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, |
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 --- |