-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Armv7-M: Allow register overlap in ldm + ldrd #153
base: main
Are you sure you want to change the base?
Changes from 3 commits
0a9ac4e
bc18688
3c8dd2f
1825961
7ce4998
89e54ee
25aaba0
ec8112c
da0c503
66fab54
02dd6fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,41 @@ | ||
|
||
start: | ||
// Instructions: 24 | ||
// Expected cycles: 26 | ||
// Expected IPC: 0.92 | ||
// | ||
// Cycle bound: 26.0 | ||
// IPC bound: 0.92 | ||
// | ||
// Wall time: 0.20s | ||
// User time: 0.20s | ||
// | ||
// ----- cycle (expected) ------> | ||
// 0 25 | ||
// |------------------------|---- | ||
ldr r6, [r0, #4] // *............................. // @slothy:reads=a | ||
add r10, r2, r6 // .*............................ | ||
eor.w r1, r10, r3 // ..*........................... | ||
smlabt r7, r2, r2, r1 // ..*........................... | ||
asrs r5, r7, #1 // ....*......................... | ||
str r5, [r0, #4] // ....*......................... // @slothy:writes=a | ||
ldm r0, {r7,r9,r11} // .....*........................ // @slothy:reads=a | ||
add r8, r9, r7 // ........*..................... | ||
eor.w r2, r8, r11 // .........*.................... | ||
smlabt r12, r9, r9, r2 // .........*.................... | ||
asrs r11, r12, #1 // ...........*.................. | ||
str r11, [r0, #4] // ...........*.................. // @slothy:writes=a | ||
ldm r0, {r7,r8,r10} // ............*................. // @slothy:reads=a | ||
add r6, r8, r7 // ...............*.............. | ||
eor.w r5, r6, r10 // ................*............. | ||
smlabt r12, r8, r8, r5 // ................*............. | ||
asrs r9, r12, #1 // ..................*........... | ||
str r9, [r0, #4] // ..................*........... // @slothy:writes=a | ||
ldm r0, {r1,r2,r8} // ...................*.......... // @slothy:reads=a | ||
add r14, r2, r1 // ......................*....... | ||
eor.w r5, r14, r8 // .......................*...... | ||
smlabt r10, r2, r2, r5 // .......................*...... | ||
asrs r3, r10, #1 // .........................*.... | ||
str r3, [r0, #4] // .........................*.... // @slothy:writes=a | ||
start: | ||
ldr r4, [r0, #4] // *............................. // @slothy:reads=a | ||
add r4, r2, r4 // .*............................ | ||
eor.w r4, r4, r3 // ..*........................... | ||
smlabt r2, r2, r2, r4 // ..*........................... | ||
asrs r2, r2, #1 // ....*......................... | ||
str r2, [r0, #4] // ....*......................... // @slothy:writes=a | ||
ldr r11, [r0, #0]// .....*........................ // @slothy:reads=a | ||
ldr r12, [r0, #4]// .....*........................ // @slothy:reads=a | ||
ldr r14, [r0, #8]// .....*........................ // @slothy:reads=a | ||
add r2, r12, r11 // ........*..................... | ||
eor.w r2, r2, r14 // .........*.................... | ||
smlabt r2, r12, r12, r2 // .........*.................... | ||
asrs r2, r2, #1 // ...........*.................. | ||
str r2, [r0, #4] // ...........*.................. // @slothy:writes=a | ||
ldr r11, [r0, #0]// ............*................. // @slothy:reads=a | ||
ldr r12, [r0, #4]// ............*................. // @slothy:reads=a | ||
ldr r14, [r0, #8]// ............*................. // @slothy:reads=a | ||
add r2, r12, r11 // ...............*.............. | ||
eor.w r2, r2, r14 // ................*............. | ||
smlabt r2, r12, r12, r2 // ................*............. | ||
asrs r2, r2, #1 // ..................*........... | ||
str r2, [r0, #4] // ..................*........... // @slothy:writes=a | ||
ldr r11, [r0, #0]// ...................*.......... // @slothy:reads=a | ||
ldr r12, [r0, #4]// ...................*.......... // @slothy:reads=a | ||
ldr r14, [r0, #8]// ...................*.......... // @slothy:reads=a | ||
add r2, r12, r11 // ......................*....... | ||
eor.w r14, r2, r14 // .......................*...... | ||
smlabt r6, r12, r12, r14 // .......................*...... | ||
ldr r4, [r14, #8]// ........................*..... | ||
ldr r2, [r14, #12]// ........................*..... | ||
str r14, [r0] // ........................*..... | ||
asrs r2, r6, #1 // .........................*.... | ||
str r2, [r0, #4] // .........................*.... // @slothy:writes=a | ||
ldr r1, [r0, #4]// ..........................*... | ||
ldr r2, [r0, #8]// ..........................*... | ||
ldr r3, [r0, #12]// ..........................*... | ||
ldr r0, [r0, #0]// ..........................*... | ||
end: | ||
|
||
// ------ cycle (expected) ------> | ||
// 0 25 | ||
// |------------------------|----- | ||
// ldr r1, [r0, #4] // *.............................. | ||
// add r1, r2,r1 // .*............................. | ||
// eor.w r1,r1, r3 // ..*............................ | ||
// smlabt r3,r2, r2, r1 // ..*............................ | ||
// asrs r3, r3,#1 // ....*.......................... | ||
// str r3, [r0,#4] // ....*.......................... | ||
// ldm r0, {r1-r2,r14} // .....*......................... | ||
// add r1, r2,r1 // ........*...................... | ||
// eor.w r1,r1, r14 // .........*..................... | ||
// smlabt r3,r2, r2, r1 // .........*..................... | ||
// asrs r3, r3,#1 // ...........*................... | ||
// str r3, [r0,#4] // ...........*................... | ||
// ldm r0, {r1-r3} // ............*.................. | ||
// add r1, r2,r1 // ...............*............... | ||
// eor.w r1,r1, r3 // ................*.............. | ||
// smlabt r3,r2, r2, r1 // ................*.............. | ||
// asrs r3, r3,#1 // ..................*............ | ||
// str r3, [r0,#4] // ..................*............ | ||
// ldm r0, {r1,r2,r3} // ...................*........... | ||
// add r1, r2,r1 // ......................*........ | ||
// eor.w r1,r1, r3 // .......................*....... | ||
// smlabt r3,r2, r2, r1 // .......................*....... | ||
// asrs r3, r3,#1 // .........................*..... | ||
// str r3, [r0,#4] // .........................*..... | ||
|
||
end: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1486,7 +1486,7 @@ def make(cls, src): | |
obj.increment = None | ||
obj.pre_index = 0 | ||
obj.addr = obj.args_in[0] | ||
obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
#obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove those, not comment them out. For that please make sure you have a clean copy of SLOTHY, and then run
This is going to run for a few hours. Then zip up the output files in |
||
return obj | ||
|
||
def write(self): | ||
|
@@ -1505,7 +1505,7 @@ def make(cls, src): | |
obj.increment = None | ||
obj.pre_index = obj.immediate | ||
obj.addr = obj.args_in[0] | ||
obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
#obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
return obj | ||
|
||
def write(self): | ||
|
@@ -1528,7 +1528,7 @@ def make(cls, src): | |
obj = Armv7mInstruction.build(cls, src) | ||
obj.increment = None | ||
obj.pre_index = obj.immediate | ||
obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
#obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
obj.addr = obj.args_in[0] | ||
return obj | ||
|
||
|
@@ -1545,7 +1545,7 @@ def make(cls, src): | |
obj = Armv7mInstruction.build(cls, src) | ||
obj.increment = None | ||
obj.pre_index = obj.immediate | ||
obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
#obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra | ||
obj.addr = obj.args_in[0] | ||
return obj | ||
|
||
|
@@ -1940,6 +1940,19 @@ def core(inst,t,log=None): | |
add_comments(inst.source_line.comments) | ||
ldr.source_line = ldr_src | ||
|
||
# In case the address register is also contained in the | ||
# register list, we need to overwrite the address register | ||
# in the last ldr | ||
ldrs_reordered = [] | ||
mkannwischer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for ldr, reg in zip(ldrs, regs): | ||
if reg != ptr: | ||
ldrs_reordered.append(ldr) | ||
|
||
for ldr, reg in zip(ldrs, regs): | ||
if reg == ptr: | ||
ldrs_reordered.append(ldr) | ||
ldrs = ldrs_reordered | ||
|
||
if log is not None: | ||
log(f"ldm splitting: {t.inst}; {[ldr for ldr in ldrs]}") | ||
|
||
|
@@ -2128,6 +2141,19 @@ def core(inst,t,log=None): | |
add_comments(inst.source_line.comments) | ||
ldr.source_line = ldr_src | ||
|
||
# In case the address register is also contained in the | ||
# register list, we need to overwrite the address register | ||
# in the last ldr | ||
ldrs_reordered = [] | ||
mkannwischer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for ldr, reg in zip(ldrs, regs): | ||
if reg != ptr: | ||
ldrs_reordered.append(ldr) | ||
|
||
for ldr, reg in zip(ldrs, regs): | ||
if reg == ptr: | ||
ldrs_reordered.append(ldr) | ||
ldrs = ldrs_reordered | ||
|
||
if log is not None: | ||
log(f"ldrd splitting: {t.inst}; {[ldr for ldr in ldrs]}") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to put the fusion_region before the optimize, otherwise this does not help SLOTHY find a better solution.