diff options
author | Jack Whitman <jack-m5ml2@cs.york.ac.uk> | 2009-06-24 21:22:46 -0700 |
---|---|---|
committer | Jack Whitman <jack-m5ml2@cs.york.ac.uk> | 2009-06-24 21:22:46 -0700 |
commit | 853a0858f33e6d27c1b3bc1a7cb29636a82e7663 (patch) | |
tree | 7a01f9cecf1546ea2ab7f15e8026829c45c67be8 /src/arch/arm | |
parent | 6dd42728040751dec6f83d7bd89a2b33f2339fc6 (diff) | |
download | gem5-853a0858f33e6d27c1b3bc1a7cb29636a82e7663.tar.xz |
ARM: Link register is trashed by non-executed branch and link operations.
Diffstat (limited to 'src/arch/arm')
-rw-r--r-- | src/arch/arm/isa/decoder.isa | 4 | ||||
-rw-r--r-- | src/arch/arm/isa/formats/branch.isa | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/arch/arm/isa/decoder.isa b/src/arch/arm/isa/decoder.isa index af325b57a..20f5b99f0 100644 --- a/src/arch/arm/isa/decoder.isa +++ b/src/arch/arm/isa/decoder.isa @@ -246,7 +246,7 @@ decode COND_CODE default Unknown::unknown() { }}); } 0x3: decode OPCODE_24_21 { - 0x9: BranchExchange::blx({{ LR = NPC; }}); + 0x9: BranchExchange::blx({{ }}, Link); } } } @@ -661,7 +661,7 @@ decode COND_CODE default Unknown::unknown() { 0x5: decode OPCODE_24 { // Branch (and Link) Instructions 0: Branch::b({{ }}); - 1: Branch::bl({{ LR = NPC; }}); + 1: Branch::bl({{ }}, Link); } 0x6: decode CPNUM { 0x1: decode PUNWL { diff --git a/src/arch/arm/isa/formats/branch.isa b/src/arch/arm/isa/formats/branch.isa index b8fbb982d..95f4f14e1 100644 --- a/src/arch/arm/isa/formats/branch.isa +++ b/src/arch/arm/isa/formats/branch.isa @@ -38,8 +38,10 @@ def format Branch(code,*opt_flags) {{ #Build Instruction Flags #Use Link & Likely Flags to Add Link/Condition Code inst_flags = ('IsDirectControl', ) + linking = False for x in opt_flags: if x == 'Link': + linking = True code += 'LR = NPC;\n' else: inst_flags += (x, ) @@ -55,6 +57,8 @@ def format Branch(code,*opt_flags) {{ icode += ' NPC = NPC + 4 + disp;\n' icode += '} else {\n' icode += ' NPC = NPC;\n' + if linking: + icode += ' LR = LR;\n' icode += '};\n' code = icode @@ -70,8 +74,10 @@ def format BranchExchange(code,*opt_flags) {{ #Build Instruction Flags #Use Link & Likely Flags to Add Link/Condition Code inst_flags = ('IsIndirectControl', ) + linking = False for x in opt_flags: if x == 'Link': + linking = True code += 'LR = NPC;\n' else: inst_flags += (x, ) @@ -89,6 +95,8 @@ def format BranchExchange(code,*opt_flags) {{ icode += ' NPC = Rm & 0xfffffffe; // Masks off bottom bit\n' icode += '} else {\n' icode += ' NPC = NPC;\n' + if linking: + icode += ' LR = LR;\n' icode += '};\n' code = icode |