diff options
author | David Faust <david.faust@oracle.com> | 2022-12-08 10:08:22 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2022-12-08 10:49:40 -0800 |
commit | 5ddfe794405a514824382e96b1047d3195af23cc (patch) | |
tree | ec153f538fea36809f6f731380b9498420118678 /gcc/config/bpf | |
parent | bd0485f20f4794f9787237706a6308473a8e9415 (diff) | |
download | gcc-5ddfe794405a514824382e96b1047d3195af23cc.zip gcc-5ddfe794405a514824382e96b1047d3195af23cc.tar.gz gcc-5ddfe794405a514824382e96b1047d3195af23cc.tar.bz2 |
bpf: add define_insn for bswap
The eBPF architecture provides 'end[be,le]' instructions for endianness
swapping. Add a define_insn for bswap<mode>2 to use them instaed of
falling back on a libcall.
gcc/
* config/bpf/bpf.md (bswap<mode>2): New define_insn.
gcc/testsuite/
* gcc.target/bpf/bswap-1.c: New test.
Diffstat (limited to 'gcc/config/bpf')
-rw-r--r-- | gcc/config/bpf/bpf.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md index a28021a..22a133f 100644 --- a/gcc/config/bpf/bpf.md +++ b/gcc/config/bpf/bpf.md @@ -341,6 +341,23 @@ "rsh<msuffix>\t%0,%2" [(set_attr "type" "<mtype>")]) +;;;; Endianness conversion + +(define_mode_iterator BSM [HI SI DI]) +(define_mode_attr endmode [(HI "16") (SI "32") (DI "64")]) + +(define_insn "bswap<BSM:mode>2" + [(set (match_operand:BSM 0 "register_operand" "=r") + (bswap:BSM (match_operand:BSM 1 "register_operand" " r")))] + "" +{ + if (TARGET_BIG_ENDIAN) + return "endle\t%0, <endmode>"; + else + return "endbe\t%0, <endmode>"; +} + [(set_attr "type" "end")]) + ;;;; Conditional branches ;; The eBPF jump instructions use 64-bit arithmetic when evaluating |