branch.isa (7720:65d338a8dba4) | branch.isa (7794:8a7ba5a1b35d) |
---|---|
1// -*- mode:c++ -*- 2 3// Copyright (c) 2003-2005 The Regents of The University of Michigan 4// All rights reserved. 5// 6// Redistribution and use in source and binary forms, with or without 7// modification, are permitted provided that the following conditions are 8// met: redistributions of source code must retain the above copyright --- 207 unchanged lines hidden (view full) --- 216 ? (StaticInst *)new %(class_name)s(machInst) 217 : (StaticInst *)new %(class_name)sAndLink(machInst); 218}}; 219 220def format CondBranch(code) {{ 221 code = ''' 222 bool cond; 223 %(code)s; | 1// -*- mode:c++ -*- 2 3// Copyright (c) 2003-2005 The Regents of The University of Michigan 4// All rights reserved. 5// 6// Redistribution and use in source and binary forms, with or without 7// modification, are permitted provided that the following conditions are 8// met: redistributions of source code must retain the above copyright --- 207 unchanged lines hidden (view full) --- 216 ? (StaticInst *)new %(class_name)s(machInst) 217 : (StaticInst *)new %(class_name)sAndLink(machInst); 218}}; 219 220def format CondBranch(code) {{ 221 code = ''' 222 bool cond; 223 %(code)s; |
224 PCState pc = PCS; | |
225 if (cond) | 224 if (cond) |
226 pc.npc(pc.npc() + disp); 227 PCS = pc; | 225 NPC = NPC + disp; 226 else 227 NPC = NPC; |
228 ''' % { "code" : code } 229 iop = InstObjParams(name, Name, 'Branch', code, 230 ('IsDirectControl', 'IsCondControl')) 231 header_output = BasicDeclare.subst(iop) 232 decoder_output = BasicConstructor.subst(iop) 233 decode_block = BasicDecode.subst(iop) 234 exec_output = BasicExecute.subst(iop) 235}}; 236 237let {{ 238def UncondCtrlBase(name, Name, base_class, npc_expr, flags): 239 # Declare basic control transfer w/o link (i.e. link reg is R31) | 228 ''' % { "code" : code } 229 iop = InstObjParams(name, Name, 'Branch', code, 230 ('IsDirectControl', 'IsCondControl')) 231 header_output = BasicDeclare.subst(iop) 232 decoder_output = BasicConstructor.subst(iop) 233 decode_block = BasicDecode.subst(iop) 234 exec_output = BasicExecute.subst(iop) 235}}; 236 237let {{ 238def UncondCtrlBase(name, Name, base_class, npc_expr, flags): 239 # Declare basic control transfer w/o link (i.e. link reg is R31) |
240 readpc_code = 'PCState pc = PCS;' 241 nolink_code = 'pc.npc(%s);\nPCS = pc' % npc_expr | 240 nolink_code = 'NPC = %s;\n' % npc_expr |
242 nolink_iop = InstObjParams(name, Name, base_class, | 241 nolink_iop = InstObjParams(name, Name, base_class, |
243 readpc_code + nolink_code, flags) | 242 nolink_code, flags) |
244 header_output = BasicDeclare.subst(nolink_iop) 245 decoder_output = BasicConstructor.subst(nolink_iop) 246 exec_output = BasicExecute.subst(nolink_iop) 247 248 # Generate declaration of '*AndLink' version, append to decls | 243 header_output = BasicDeclare.subst(nolink_iop) 244 decoder_output = BasicConstructor.subst(nolink_iop) 245 exec_output = BasicExecute.subst(nolink_iop) 246 247 # Generate declaration of '*AndLink' version, append to decls |
249 link_code = 'Ra = pc.npc() & ~3;\n' + nolink_code | 248 link_code = 'Ra = NPC & ~3;\n' + nolink_code |
250 link_iop = InstObjParams(name, Name + 'AndLink', base_class, | 249 link_iop = InstObjParams(name, Name + 'AndLink', base_class, |
251 readpc_code + link_code, flags) | 250 link_code, flags) |
252 header_output += BasicDeclare.subst(link_iop) 253 decoder_output += BasicConstructor.subst(link_iop) 254 exec_output += BasicExecute.subst(link_iop) 255 256 # need to use link_iop for the decode template since it is expecting 257 # the shorter version of class_name (w/o "AndLink") 258 259 return (header_output, decoder_output, 260 JumpOrBranchDecode.subst(nolink_iop), exec_output) 261}}; 262 263def format UncondBranch(*flags) {{ 264 flags += ('IsUncondControl', 'IsDirectControl') 265 (header_output, decoder_output, decode_block, exec_output) = \ | 251 header_output += BasicDeclare.subst(link_iop) 252 decoder_output += BasicConstructor.subst(link_iop) 253 exec_output += BasicExecute.subst(link_iop) 254 255 # need to use link_iop for the decode template since it is expecting 256 # the shorter version of class_name (w/o "AndLink") 257 258 return (header_output, decoder_output, 259 JumpOrBranchDecode.subst(nolink_iop), exec_output) 260}}; 261 262def format UncondBranch(*flags) {{ 263 flags += ('IsUncondControl', 'IsDirectControl') 264 (header_output, decoder_output, decode_block, exec_output) = \ |
266 UncondCtrlBase(name, Name, 'Branch', 'pc.npc() + disp', flags) | 265 UncondCtrlBase(name, Name, 'Branch', 'NPC + disp', flags) |
267}}; 268 269def format Jump(*flags) {{ 270 flags += ('IsUncondControl', 'IsIndirectControl') 271 (header_output, decoder_output, decode_block, exec_output) = \ | 266}}; 267 268def format Jump(*flags) {{ 269 flags += ('IsUncondControl', 'IsIndirectControl') 270 (header_output, decoder_output, decode_block, exec_output) = \ |
272 UncondCtrlBase(name, Name, 'Jump', '(Rb & ~3) | (pc.npc() & 1)', flags) | 271 UncondCtrlBase(name, Name, 'Jump', '(Rb & ~3) | (NPC & 1)', flags) |
273}}; 274 275 | 272}}; 273 274 |