Skip to content

Commit 65d1bc0

Browse files
committed
[binutils, ARM, 9/16] New BFL instruction for Armv8.1-M Mainline
This patch is part of a series of patches to add support for Armv8.1-M Mainline instructions to binutils. This patch adds the BFL instruction. *** gas/ChangeLog *** 2019-04-15 Sudakshina Das <[email protected]> Andre Vieira <[email protected]> * config/tc-arm.c (T16_32_TAB): New entrie for bfl. (do_t_v8_1_branch): New switch case for bfl. (insns): New instruction for bfl. * testsuite/gas/arm/armv8_1-m-bfl.d: New. * testsuite/gas/arm/armv8_1-m-bfl.s: New. * testsuite/gas/arm/armv8_1-m-bfl-bad.s: New. * testsuite/gas/arm/armv8_1-m-bfl-bad.d: New. * testsuite/gas/arm/armv8_1-m-bfl-bad.l: New. * testsuite/gas/arm/armv8_1-m-bfl-rel.d: New. * testsuite/gas/arm/armv8_1-m-bfl-rel.s: New. *** ld/ChangeLog *** 2019-04-15 Sudakshina Das <[email protected]> * testsuite/ld-arm/bfl.s: New. * testsuite/ld-arm/bfl.d: New. * testsuite/ld-arm/arm-elf.exp: Add above test. *** opcodes/ChangeLog *** 2019-04-15 Sudakshina Das <[email protected]> * arm-dis.c (thumb32_opcodes): New instruction bfl.
1 parent 1caf72a commit 65d1bc0

File tree

15 files changed

+150
-0
lines changed

15 files changed

+150
-0
lines changed

gas/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2019-04-15 Sudakshina Das <[email protected]>
2+
Andre Vieira <[email protected]>
3+
4+
* config/tc-arm.c (T16_32_TAB): New entrie for bfl.
5+
(do_t_v8_1_branch): New switch case for bfl.
6+
(insns): New instruction for bfl.
7+
* testsuite/gas/arm/armv8_1-m-bfl.d: New.
8+
* testsuite/gas/arm/armv8_1-m-bfl.s: New.
9+
* testsuite/gas/arm/armv8_1-m-bfl-bad.s: New.
10+
* testsuite/gas/arm/armv8_1-m-bfl-bad.d: New.
11+
* testsuite/gas/arm/armv8_1-m-bfl-bad.l: New.
12+
* testsuite/gas/arm/armv8_1-m-bfl-rel.d: New.
13+
* testsuite/gas/arm/armv8_1-m-bfl-rel.s: New.
14+
115
2019-04-15 Sudakshina Das <[email protected]>
216

317
* config/tc-arm.c (md_pcrel_from_section): New switch case for

gas/config/tc-arm.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10507,6 +10507,7 @@ encode_thumb32_addr_mode (int i, bfd_boolean is_t, bfd_boolean is_d)
1050710507
X(_bcond, d000, f0008000), \
1050810508
X(_bf, 0000, f040e001), \
1050910509
X(_bfx, 0000, f060e001), \
10510+
X(_bfl, 0000, f000c001), \
1051010511
X(_bflx, 0000, f070e001), \
1051110512
X(_bic, 4380, ea200000), \
1051210513
X(_bics, 4380, ea300000), \
@@ -13364,6 +13365,25 @@ do_t_branch_future (void)
1336413365
}
1336513366
break;
1336613367

13368+
case T_MNEM_bfl:
13369+
if (inst.operands[1].hasreloc == 0)
13370+
{
13371+
int val = inst.operands[1].imm;
13372+
if (v8_1_branch_value_check (inst.operands[1].imm, 19, TRUE) == FAIL)
13373+
as_bad (BAD_BRANCH_OFF);
13374+
13375+
int immA = (val & 0x0007f000) >> 12;
13376+
int immB = (val & 0x00000ffc) >> 2;
13377+
int immC = (val & 0x00000002) >> 1;
13378+
inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
13379+
}
13380+
else
13381+
{
13382+
inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF19;
13383+
inst.relocs[1].pc_rel = 1;
13384+
}
13385+
break;
13386+
1336713387
case T_MNEM_bfx:
1336813388
case T_MNEM_bflx:
1336913389
inst.instruction |= inst.operands[1].reg << 16;
@@ -21687,6 +21707,7 @@ static const struct asm_opcode insns[] =
2168721707
#define THUMB_VARIANT & arm_ext_v8_1m_main
2168821708
toC("bf", _bf, 2, (EXPs, EXPs), t_branch_future),
2168921709
toC("bfx", _bfx, 2, (EXPs, RRnpcsp), t_branch_future),
21710+
toC("bfl", _bfl, 2, (EXPs, EXPs), t_branch_future),
2169021711
toC("bflx", _bflx, 2, (EXPs, RRnpcsp), t_branch_future),
2169121712
};
2169221713
#undef ARM_VARIANT
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#name: Invalid Armv8.1-M Mainline BFL instructions
2+
#source: armv8_1-m-bfl-bad.s
3+
#as: -march=armv8.1-m.main
4+
#error_output: armv8_1-m-bfl-bad.l
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.*: Assembler messages:
2+
.*:6: Error: branch out of range or not a multiple of 2
3+
.*:7: Error: branch out of range or not a multiple of 2
4+
.*:8: Error: branch out of range or not a multiple of 2
5+
.*:9: Error: branch out of range or not a multiple of 2
6+
.*:11: Error: branch out of range or not a multiple of 2
7+
.*:12: Error: branch out of range or not a multiple of 2
8+
.*:13: Error: branch out of range or not a multiple of 2
9+
.*:14: Error: branch out of range or not a multiple of 2
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.syntax unified
2+
.text
3+
.thumb
4+
foo:
5+
# OP0 : Unsigned, 5-bit, even
6+
bfl 0, 36
7+
bfl -2, 36
8+
bfl 3, 36
9+
bfl 32, 36
10+
# OP1 : signed, 19-bit, even
11+
bf 2, -5
12+
bf 2, 5
13+
bf 2, 262144
14+
bf 2, -262146
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#name: Valid Armv8.1-M Mainline BFL instruction with relocation
2+
#as: -march=armv8.1-m.main
3+
#objdump: -dr --prefix-addresses --show-raw-insn
4+
#skip: *-*-pe *-wince-*
5+
6+
.*: +file format .*arm.*
7+
8+
Disassembly of section .text:
9+
0[0-9a-f]+ <[^>]+> f0ff c7ff bfl 2, 00000000 <.target>
10+
0: R_ARM_THM_BF18 .target
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.syntax unified
2+
.text
3+
.thumb
4+
foo:
5+
bfl 2, .target

gas/testsuite/gas/arm/armv8_1-m-bfl.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#name: Valid Armv8.1-M Mainline BFL instruction
2+
#as: -march=armv8.1-m.main
3+
#objdump: -dr --prefix-addresses --show-raw-insn
4+
5+
.*: +file format .*arm.*
6+
7+
Disassembly of section .text:
8+
0[0-9a-f]+ <[^>]+> f080 c803 bfl 2, 0000000a <foo\+0xa>
9+
0[0-9a-f]+ <[^>]+> 4608 mov r0, r1
10+
0[0-9a-f]+ <[^>]+> f100 c801 bfl 4, 0000000c <foo\+0xc>
11+
0[0-9a-f]+ <[^>]+> 460a mov r2, r1
12+
0[0-9a-f]+ <[^>]+> 4613 mov r3, r2
13+
0[0-9a-f]+ <[^>]+> 4614 mov r4, r2

gas/testsuite/gas/arm/armv8_1-m-bfl.s

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.syntax unified
2+
.text
3+
.thumb
4+
foo:
5+
bfl 2, 6
6+
mov r0, r1
7+
bfl .LBranch, .LB2
8+
mov r2, r1
9+
.LB2:
10+
mov r3, r2
11+
.LBranch:
12+
mov r4, r2

ld/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2019-04-15 Sudakshina Das <[email protected]>
2+
3+
* testsuite/ld-arm/bfl.s: New.
4+
* testsuite/ld-arm/bfl.d: New.
5+
* testsuite/ld-arm/arm-elf.exp: Add above test.
6+
17
2019-04-15 Sudakshina Das <[email protected]>
28

39
* testsuite/ld-arm/bf.s: New.

ld/testsuite/ld-arm/arm-elf.exp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@ set armeabitests_nonacl {
670670
{"Armv8.1-M Mainline BF" "-r -Ttext 0x1000 --section-start .foo=0x1001000" "" "-march=armv8.1-m.main" {bf.s}
671671
{{objdump -dr bf.d}}
672672
"bf"}
673+
{"Armv8.1-M Mainline BFL" "-r -Ttext 0x1000 --section-start .foo=0x1001000" "" "-march=armv8.1-m.main" {bfl.s}
674+
{{objdump -dr bfl.d}}
675+
"bfl"}
673676

674677
{"R_ARM_THM_JUMP24 Relocation veneers: Short 1"
675678
"--no-fix-arm1176 --section-start destsect=0x00009000 --section-start .text=0x8000" ""

ld/testsuite/ld-arm/bfl.d

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
.*: file format elf32-.*arm
3+
4+
5+
Disassembly of section .text:
6+
7+
00001000 <_start>:
8+
1000: f0ff c7ff bfl 2, 1001000 <bar>
9+
1000: R_ARM_THM_BF18 bar
10+
11+
Disassembly of section .foo:
12+
13+
01001000 <bar>:
14+
1001000: 4770 bx lr

ld/testsuite/ld-arm/bfl.s

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.global _start
2+
.syntax unified
3+
4+
@ We will place the section .text at 0x1000.
5+
6+
.text
7+
.thumb_func
8+
9+
_start:
10+
bfl 2, bar
11+
12+
@ We will place the section .foo at 0x1001000.
13+
14+
.section .foo, "xa"
15+
.thumb_func
16+
17+
bar:
18+
bx lr
19+

opcodes/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019-04-15 Sudakshina Das <[email protected]>
2+
3+
* arm-dis.c (thumb32_opcodes): New instruction bfl.
4+
15
2019-04-15 Sudakshina Das <[email protected]>
26

37
* arm-dis.c (print_insn_thumb32): Updated to accept new %Y pattern.

opcodes/arm-dis.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,8 @@ static const struct opcode32 thumb32_opcodes[] =
27532753
0xf040e001, 0xf860f001, "bf%c\t%G, %W"},
27542754
{ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN),
27552755
0xf060e001, 0xf8f0f001, "bfx%c\t%G, %16-19S"},
2756+
{ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN),
2757+
0xf000c001, 0xf800f001, "bfl%c\t%G, %Y"},
27562758
{ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN),
27572759
0xf070e001, 0xf8f0f001, "bflx%c\t%G, %16-19S"},
27582760

0 commit comments

Comments
 (0)