忍者ブログ

なんだか

知らないほうが幸せかもしれない

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

rx-elf-gcc(4.7.2)でbtst命令を使うようにしてみようという試み、その4

その1では、ここまでできました。

0000 FB E2 00 00 00 00     mov.L #_bar1, r14
0006 CC EE                 mov.B [r14], r14
0008 7C 0E                 btst #0, r14
000a FB E2 00 00 00 00     mov.L #_bar, r14
0010 1C                    bne .L5
0011 F0 E0                 bset #0, [r14].B
0013 02                    rts
                       .L5:
0014 F0 E8                 bclr #0, [r14].B
0016 02                    rts

ズバリ、以下をrx.mdに追加します。

(define_insn_and_split "*cbranchqi4_tst_ext_bitmem"
  [(set (pc)
    (if_then_else
      (match_operator 4 "rx_z_comparison_operator"
        [(zero_extract:SI
        (match_operand:QI 0 "rx_restricted_mem_operand" "Q")
        (match_operand    1 "rx_constshift_operand" "")
        (match_operand    2 "rx_constshift_operand" ""))
         (const_int 0)])
      (match_operand 3 "label_ref_operand" "")
      (pc)))]
  "INTVAL (operands[1]) == 1"
  "#"
  "reload_completed"
  [(const_int 0)]
{
  HOST_WIDE_INT mask;
  rtx x;

  mask = 1;
  mask <<= INTVAL (operands[1]);
  mask -= 1;
  mask <<= INTVAL (operands[2]);
  x = gen_rtx_AND (SImode, operands[0], gen_int_mode (mask, SImode));

  rx_split_cbranch (CC_ZSmode, GET_CODE (operands[4]),
            x, const0_rtx, operands[3]);
  DONE;
})

(define_insn "*tstqi_bitmem"
  [(set (reg:CC_ZS CC_REG)
    (compare:CC_ZS
      (and:SI (match_operand:QI 0 "rx_restricted_mem_operand"  "Q")
           (match_operand:QI 1 "const_int_operand" ""))
      (const_int 0)))]
  "reload_completed
   && exact_log2 (INTVAL (operands[1])) >= 0
   && exact_log2 (INTVAL (operands[1])) <= 7"
  "*
{
  rtx xoperands[2];
  xoperands[0] = operands[0];
  xoperands[1] = GEN_INT (exact_log2 (INTVAL (operands[1]) & 0xff));
  output_asm_insn (\"btst\\t%1, %0.B\", xoperands);
  return \"\";
}
  "
  [(set_attr "timings" "33")
   (set_attr "length"  "3")]
)


追加したrx-elf-gccでコンパイルすると

0000 FB E2 00 00 00 00    mov.L   #_bar1, r14
0006 F4 E0                btst    #0, [r14].B
0008 FB E2 00 00 00 00    mov.L   #_bar, r14
000e 1C                   bne     .L5
000f F0 E0                bset    #0, [r14].B
0011 02                   rts
                      .L5:
0012 F0 E8                bclr    #0, [r14].B
0014 02                   rts

こうなります。

拍手[0回]

PR

コメント

お名前
タイトル
文字色
メールアドレス
URL
コメント
パスワード Vodafone絵文字 i-mode絵文字 Ezweb絵文字

カレンダー

03 2024/04 05
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

フリーエリア

最新CM

最新記事

(07/27)
(03/27)
(03/26)
(03/23)
(03/22)
(03/19)
(03/18)
(03/18)
(03/15)
(03/14)
(03/13)
(03/12)
(03/11)
(03/11)
(03/08)
(03/08)
(03/06)
(03/05)
(03/02)
(03/01)
(02/28)
(02/27)
(02/24)
(02/23)
(02/22)

プロフィール

HN:
kenrou
性別:
非公開

バーコード

ブログ内検索

最古記事

(12/15)
(12/16)
(12/17)
(12/18)
(12/19)
(12/20)
(12/21)
(12/22)
(12/23)
(12/24)
(12/25)
(12/26)
(12/27)
(12/28)
(12/29)
(12/30)
(12/31)
(01/01)
(01/02)
(01/21)
(01/22)
(01/23)
(01/24)
(01/24)
(01/28)

P R

忍者アナライズ

コガネモチ

忍者カウンター

カレンダー

03 2024/04 05
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30