From 853a0858f33e6d27c1b3bc1a7cb29636a82e7663 Mon Sep 17 00:00:00 2001 From: Jack Whitman Date: Wed, 24 Jun 2009 21:22:46 -0700 Subject: ARM: Link register is trashed by non-executed branch and link operations. --- src/arch/arm/isa/formats/branch.isa | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/arch/arm/isa/formats/branch.isa') 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 -- cgit v1.2.3