branch.isa (7791:762276cd3cc7) branch.isa (13801:e18de9c80ce3)
1// -*- mode:c++ -*-
2
3// Copyright (c) 2009 The University of Edinburgh
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

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

43// Therefore, I've flagged all versions that update the link register (LR)
44// as calls, except bclrl (BranchLrCtrCond format) which is flagged as
45// a return.
46
47
48let {{
49
50# Simple code to update link register (LR).
1// -*- mode:c++ -*-
2
3// Copyright (c) 2009 The University of Edinburgh
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

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

43// Therefore, I've flagged all versions that update the link register (LR)
44// as calls, except bclrl (BranchLrCtrCond format) which is flagged as
45// a return.
46
47
48let {{
49
50# Simple code to update link register (LR).
51updateLrCode = 'LR = PC + 4;'
51updateLrCode = 'LR = CIA + 4;'
52
53}};
54
55// Instructions that unconditionally branch relative to the current PC.
56def format BranchPCRel(br_code, inst_flags = []) {{
57 inst_flags += ('IsUncondControl', 'IsDirectControl')
58 basic_code = br_code
59

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

100
101let {{
102
103# Check the condition register (CR) allows the branch to be taken.
104def GetCondCode(br_code):
105 cond_code = 'if(condOk(CR)) {\n'
106 cond_code += ' ' + br_code + '\n'
107 cond_code += '} else {\n'
52
53}};
54
55// Instructions that unconditionally branch relative to the current PC.
56def format BranchPCRel(br_code, inst_flags = []) {{
57 inst_flags += ('IsUncondControl', 'IsDirectControl')
58 basic_code = br_code
59

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

100
101let {{
102
103# Check the condition register (CR) allows the branch to be taken.
104def GetCondCode(br_code):
105 cond_code = 'if(condOk(CR)) {\n'
106 cond_code += ' ' + br_code + '\n'
107 cond_code += '} else {\n'
108 cond_code += ' NPC = NPC;\n'
108 cond_code += ' NIA = NIA;\n'
109 cond_code += '}\n'
110 return cond_code
111
112# Check the condition register (CR) and count register (CTR) allow the
113# branch to be taken. Also, in certain situations, decrement the count
114# register too. This takes place in ctrOk within BranchCond classes.
115def GetCtrCondCode(br_code):
116 cond_code = 'uint32_t ctr = CTR;\n'
117 cond_code += 'bool ctr_ok = ctrOk(ctr);\n'
118 cond_code += 'bool cond_ok = condOk(CR);\n'
119 cond_code += 'if(ctr_ok && cond_ok) {\n'
120 cond_code += ' ' + br_code + '\n'
121 cond_code += '} else {\n'
109 cond_code += '}\n'
110 return cond_code
111
112# Check the condition register (CR) and count register (CTR) allow the
113# branch to be taken. Also, in certain situations, decrement the count
114# register too. This takes place in ctrOk within BranchCond classes.
115def GetCtrCondCode(br_code):
116 cond_code = 'uint32_t ctr = CTR;\n'
117 cond_code += 'bool ctr_ok = ctrOk(ctr);\n'
118 cond_code += 'bool cond_ok = condOk(CR);\n'
119 cond_code += 'if(ctr_ok && cond_ok) {\n'
120 cond_code += ' ' + br_code + '\n'
121 cond_code += '} else {\n'
122 cond_code += ' NPC = NPC;\n'
122 cond_code += ' NIA = NIA;\n'
123 cond_code += '}\n'
124 cond_code += 'CTR = ctr;\n'
125 return cond_code
126
127}};
128
129// Instructions that conditionally branch relative to the current PC based on
130// the condition register (CR) and count register (CTR).

--- 92 unchanged lines hidden ---
123 cond_code += '}\n'
124 cond_code += 'CTR = ctr;\n'
125 return cond_code
126
127}};
128
129// Instructions that conditionally branch relative to the current PC based on
130// the condition register (CR) and count register (CTR).

--- 92 unchanged lines hidden ---