branch.isa (6253:988a001820f8) branch.isa (6259:71dd4e07e626)
1// -*- mode:c++ -*-
2
3// Copyright (c) 2007-2008 The Florida State University
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

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

33// Control transfer instructions
34//
35
36def format Branch(code,*opt_flags) {{
37
38 #Build Instruction Flags
39 #Use Link & Likely Flags to Add Link/Condition Code
40 inst_flags = ('IsDirectControl', )
1// -*- mode:c++ -*-
2
3// Copyright (c) 2007-2008 The Florida State University
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

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

33// Control transfer instructions
34//
35
36def format Branch(code,*opt_flags) {{
37
38 #Build Instruction Flags
39 #Use Link & Likely Flags to Add Link/Condition Code
40 inst_flags = ('IsDirectControl', )
41 linking = False
41 for x in opt_flags:
42 if x == 'Link':
42 for x in opt_flags:
43 if x == 'Link':
44 linking = True
43 code += 'LR = NPC;\n'
44 else:
45 inst_flags += (x, )
46
47 #Take into account uncond. branch instruction
48 if 'cond == 1' in code:
49 inst_flags += ('IsUnCondControl', )
50 else:
51 inst_flags += ('IsCondControl', )
52
53 icode = 'if (testPredicate(Cpsr, condCode)) {\n'
54 icode += code
55 icode += ' NPC = NPC + 4 + disp;\n'
56 icode += '} else {\n'
57 icode += ' NPC = NPC;\n'
45 code += 'LR = NPC;\n'
46 else:
47 inst_flags += (x, )
48
49 #Take into account uncond. branch instruction
50 if 'cond == 1' in code:
51 inst_flags += ('IsUnCondControl', )
52 else:
53 inst_flags += ('IsCondControl', )
54
55 icode = 'if (testPredicate(Cpsr, condCode)) {\n'
56 icode += code
57 icode += ' NPC = NPC + 4 + disp;\n'
58 icode += '} else {\n'
59 icode += ' NPC = NPC;\n'
60 if linking:
61 icode += ' LR = LR;\n'
58 icode += '};\n'
59
60 code = icode
61
62 iop = InstObjParams(name, Name, 'Branch', code, inst_flags)
63 header_output = BasicDeclare.subst(iop)
64 decoder_output = BasicConstructor.subst(iop)
65 decode_block = BasicDecode.subst(iop)
66 exec_output = BasicExecute.subst(iop)
67}};
68
69def format BranchExchange(code,*opt_flags) {{
70 #Build Instruction Flags
71 #Use Link & Likely Flags to Add Link/Condition Code
72 inst_flags = ('IsIndirectControl', )
62 icode += '};\n'
63
64 code = icode
65
66 iop = InstObjParams(name, Name, 'Branch', code, inst_flags)
67 header_output = BasicDeclare.subst(iop)
68 decoder_output = BasicConstructor.subst(iop)
69 decode_block = BasicDecode.subst(iop)
70 exec_output = BasicExecute.subst(iop)
71}};
72
73def format BranchExchange(code,*opt_flags) {{
74 #Build Instruction Flags
75 #Use Link & Likely Flags to Add Link/Condition Code
76 inst_flags = ('IsIndirectControl', )
77 linking = False
73 for x in opt_flags:
74 if x == 'Link':
78 for x in opt_flags:
79 if x == 'Link':
80 linking = True
75 code += 'LR = NPC;\n'
76 else:
77 inst_flags += (x, )
78
79 #Take into account uncond. branch instruction
80 if 'cond == 1' in code:
81 inst_flags += ('IsUnCondControl', )
82 else:
83 inst_flags += ('IsCondControl', )
84
85 #Condition code
86
87 icode = 'if (testPredicate(Cpsr, condCode)) {\n'
88 icode += code
89 icode += ' NPC = Rm & 0xfffffffe; // Masks off bottom bit\n'
90 icode += '} else {\n'
91 icode += ' NPC = NPC;\n'
81 code += 'LR = NPC;\n'
82 else:
83 inst_flags += (x, )
84
85 #Take into account uncond. branch instruction
86 if 'cond == 1' in code:
87 inst_flags += ('IsUnCondControl', )
88 else:
89 inst_flags += ('IsCondControl', )
90
91 #Condition code
92
93 icode = 'if (testPredicate(Cpsr, condCode)) {\n'
94 icode += code
95 icode += ' NPC = Rm & 0xfffffffe; // Masks off bottom bit\n'
96 icode += '} else {\n'
97 icode += ' NPC = NPC;\n'
98 if linking:
99 icode += ' LR = LR;\n'
92 icode += '};\n'
93
94 code = icode
95
96 iop = InstObjParams(name, Name, 'BranchExchange', code, inst_flags)
97 header_output = BasicDeclare.subst(iop)
98 decoder_output = BasicConstructor.subst(iop)
99 decode_block = BasicDecode.subst(iop)

--- 24 unchanged lines hidden ---
100 icode += '};\n'
101
102 code = icode
103
104 iop = InstObjParams(name, Name, 'BranchExchange', code, inst_flags)
105 header_output = BasicDeclare.subst(iop)
106 decoder_output = BasicConstructor.subst(iop)
107 decode_block = BasicDecode.subst(iop)

--- 24 unchanged lines hidden ---