Skip to content
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

microblaze: Fix atomic boolean return value. #21

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gcc/config/microblaze/microblaze.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
(UNSPEC_TLS 106) ;; jump table
(UNSPEC_SET_TEXT 107) ;; set text start
(UNSPEC_TEXT 108) ;; data text relative
(UNSPECV_CAS_BOOL 201) ;; compare and swap (bool)
(UNSPECV_CAS_VAL 202) ;; compare and swap (val)
(UNSPECV_CAS_MEM 203) ;; compare and swap (mem)
])

(define_c_enum "unspec" [
Expand Down
28 changes: 17 additions & 11 deletions gcc/config/microblaze/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,32 @@
;; <http://www.gnu.org/licenses/>.

(define_insn "atomic_compare_and_swapsi"
[(match_operand:SI 0 "register_operand" "=&d") ;; bool output
(match_operand:SI 1 "register_operand" "=&d") ;; val output
(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
(match_operand:SI 3 "register_operand" "d") ;; expected value
(match_operand:SI 4 "register_operand" "d") ;; desired value
(match_operand:SI 5 "const_int_operand" "") ;; is_weak
(match_operand:SI 6 "const_int_operand" "") ;; mod_s
(match_operand:SI 7 "const_int_operand" "") ;; mod_f
[(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output
(unspec_volatile:SI
[(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
(match_operand:SI 3 "register_operand" "d") ;; expected value
(match_operand:SI 4 "register_operand" "d")] ;; desired value
UNSPECV_CAS_BOOL))
(set (match_operand:SI 1 "register_operand" "=&d") ;; val output
(unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_VAL))
(set (match_dup 2)
(unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_MEM))
(match_operand:SI 5 "const_int_operand" "") ;; is_weak
(match_operand:SI 6 "const_int_operand" "") ;; mod_s
(match_operand:SI 7 "const_int_operand" "") ;; mod_f
(clobber (match_scratch:SI 8 "=&d"))]
""
{
output_asm_insn ("addc \tr0,r0,r0", operands);
output_asm_insn ("add \t%0,r0,r0", operands);
output_asm_insn ("lwx \t%1,%y2,r0", operands);
output_asm_insn ("addic\t%8,r0,0", operands);
output_asm_insn ("bnei \t%8,.-8", operands);
output_asm_insn ("cmp \t%0,%1,%3", operands);
output_asm_insn ("bnei \t%0,.+16", operands);
output_asm_insn ("cmp \t%8,%1,%3", operands);
output_asm_insn ("bnei \t%8,.+20", operands);
output_asm_insn ("swx \t%4,%y2,r0", operands);
output_asm_insn ("addic\t%8,r0,0", operands);
output_asm_insn ("bnei \t%8,.-28", operands);
output_asm_insn ("addi \t%0,r0,1", operands);
return "";
}
)