macroop.isa (5788:6d4161a36ca1) | macroop.isa (5966:833e487aa8f7) |
---|---|
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: --- 121 unchanged lines hidden (view full) --- 130def template MacroConstructor {{ 131 inline X86Macroop::%(class_name)s::%(class_name)s( 132 ExtMachInst machInst, EmulEnv _env) 133 : %(base_class)s("%(mnemonic)s", machInst, %(num_microops)s, _env) 134 { 135 %(adjust_env)s; 136 %(adjust_imm)s; 137 %(adjust_disp)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: --- 121 unchanged lines hidden (view full) --- 130def template MacroConstructor {{ 131 inline X86Macroop::%(class_name)s::%(class_name)s( 132 ExtMachInst machInst, EmulEnv _env) 133 : %(base_class)s("%(mnemonic)s", machInst, %(num_microops)s, _env) 134 { 135 %(adjust_env)s; 136 %(adjust_imm)s; 137 %(adjust_disp)s; |
138 %(do_modrm)s; | 138 %(init_env)s; |
139 %(constructor)s; 140 const char *macrocodeBlock = "%(class_name)s"; 141 //alloc_microops is the code that sets up the microops 142 //array in the parent class. 143 %(alloc_microops)s; 144 } 145}}; 146 --- 14 unchanged lines hidden (view full) --- 161 super(X86Macroop, self).__init__(name) 162 self.directives = { 163 "adjust_env" : self.setAdjustEnv, 164 "adjust_imm" : self.adjustImm, 165 "adjust_disp" : self.adjustDisp 166 } 167 self.declared = False 168 self.adjust_env = "" | 139 %(constructor)s; 140 const char *macrocodeBlock = "%(class_name)s"; 141 //alloc_microops is the code that sets up the microops 142 //array in the parent class. 143 %(alloc_microops)s; 144 } 145}}; 146 --- 14 unchanged lines hidden (view full) --- 161 super(X86Macroop, self).__init__(name) 162 self.directives = { 163 "adjust_env" : self.setAdjustEnv, 164 "adjust_imm" : self.adjustImm, 165 "adjust_disp" : self.adjustDisp 166 } 167 self.declared = False 168 self.adjust_env = "" |
169 self.doModRM = "" | 169 self.init_env = "" |
170 self.adjust_imm = ''' 171 uint64_t adjustedImm = IMMEDIATE; 172 //This is to pacify gcc in case the immediate isn't used. 173 adjustedImm = adjustedImm; 174 ''' 175 self.adjust_disp = ''' 176 uint64_t adjustedDisp = DISPLACEMENT; 177 //This is to pacify gcc in case the displacement isn't used. --- 45 unchanged lines hidden (view full) --- 223 iop = InstObjParams(self.getMnemonic(), self.name, "Macroop", 224 {"code" : "", "num_microops" : numMicroops, 225 "alloc_microops" : allocMicroops, 226 "adjust_env" : self.adjust_env, 227 "adjust_imm" : self.adjust_imm, 228 "adjust_disp" : self.adjust_disp, 229 "disassembly" : env.disassembly, 230 "regSize" : regSize, | 170 self.adjust_imm = ''' 171 uint64_t adjustedImm = IMMEDIATE; 172 //This is to pacify gcc in case the immediate isn't used. 173 adjustedImm = adjustedImm; 174 ''' 175 self.adjust_disp = ''' 176 uint64_t adjustedDisp = DISPLACEMENT; 177 //This is to pacify gcc in case the displacement isn't used. --- 45 unchanged lines hidden (view full) --- 223 iop = InstObjParams(self.getMnemonic(), self.name, "Macroop", 224 {"code" : "", "num_microops" : numMicroops, 225 "alloc_microops" : allocMicroops, 226 "adjust_env" : self.adjust_env, 227 "adjust_imm" : self.adjust_imm, 228 "adjust_disp" : self.adjust_disp, 229 "disassembly" : env.disassembly, 230 "regSize" : regSize, |
231 "do_modrm" : self.doModRM}) | 231 "init_env" : self.initEnv}) |
232 return MacroConstructor.subst(iop) + \ 233 MacroDisassembly.subst(iop); 234}}; 235 236let {{ 237 class EmulEnv(object): 238 def __init__(self): 239 self.reg = "0" --- 59 unchanged lines hidden (view full) --- 299 else: 300 if self.size != size: 301 raise Exception, "Conflicting register sizes %s and %s!" %\ 302 (self.size, size) 303}}; 304 305let {{ 306 doModRMString = "env.doModRM(machInst);\n" | 232 return MacroConstructor.subst(iop) + \ 233 MacroDisassembly.subst(iop); 234}}; 235 236let {{ 237 class EmulEnv(object): 238 def __init__(self): 239 self.reg = "0" --- 59 unchanged lines hidden (view full) --- 299 else: 300 if self.size != size: 301 raise Exception, "Conflicting register sizes %s and %s!" %\ 302 (self.size, size) 303}}; 304 305let {{ 306 doModRMString = "env.doModRM(machInst);\n" |
307 noModRMString = "env.setSeg(machInst);\n" |
|
307 def genMacroop(Name, env): 308 blocks = OutputBlocks() 309 if not macroopDict.has_key(Name): 310 raise Exception, "Unrecognized instruction: %s" % Name 311 macroop = macroopDict[Name] 312 if not macroop.declared: 313 if env.doModRM: | 308 def genMacroop(Name, env): 309 blocks = OutputBlocks() 310 if not macroopDict.has_key(Name): 311 raise Exception, "Unrecognized instruction: %s" % Name 312 macroop = macroopDict[Name] 313 if not macroop.declared: 314 if env.doModRM: |
314 macroop.doModRM = doModRMString | 315 macroop.initEnv = doModRMString 316 else: 317 macroop.initEnv = noModRMString |
315 blocks.header_output = macroop.getDeclaration() 316 blocks.decoder_output = macroop.getDefinition(env) 317 macroop.declared = True 318 blocks.decode_block = "return %s;\n" % macroop.getAllocator(env) 319 return blocks 320}}; | 318 blocks.header_output = macroop.getDeclaration() 319 blocks.decoder_output = macroop.getDefinition(env) 320 macroop.declared = True 321 blocks.decode_block = "return %s;\n" % macroop.getAllocator(env) 322 return blocks 323}}; |