Skip to content

Commit 4389b29

Browse files
committed
[binutils, ARM, 6/16] New BF 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 BF instruction. ChangeLog entries are as follows: *** gas/ChangeLog *** 2019-04-15 Sudakshina Das <[email protected]> Andre Vieira <[email protected]> * config/tc-arm.c (T16_32_TAB): New entries for bf. (do_t_branch_future): New. (insns): New instruction for bf. * testsuite/gas/arm/armv8_1-m-bf.d: New. * testsuite/gas/arm/armv8_1-m-bf.s: New. * testsuite/gas/arm/armv8_1-m-bf-bad.s: New. * testsuite/gas/arm/armv8_1-m-bf-bad.l: New. * testsuite/gas/arm/armv8_1-m-bf-bad.d: New. * testsuite/gas/arm/armv8_1-m-bf-rel.d: New. * testsuite/gas/arm/armv8_1-m-bf-rel.s: New. *** ld/ChangeLog *** 2019-04-15 Sudakshina Das <[email protected]> * testsuite/ld-arm/bf.s: New. * testsuite/ld-arm/bf.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 instructions for bf.
1 parent e5d6e09 commit 4389b29

File tree

15 files changed

+194
-0
lines changed

15 files changed

+194
-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 entries for bf.
5+
(do_t_branch_future): New.
6+
(insns): New instruction for bf.
7+
* testsuite/gas/arm/armv8_1-m-bf.d: New.
8+
* testsuite/gas/arm/armv8_1-m-bf.s: New.
9+
* testsuite/gas/arm/armv8_1-m-bf-bad.s: New.
10+
* testsuite/gas/arm/armv8_1-m-bf-bad.l: New.
11+
* testsuite/gas/arm/armv8_1-m-bf-bad.d: New.
12+
* testsuite/gas/arm/armv8_1-m-bf-rel.d: New.
13+
* testsuite/gas/arm/armv8_1-m-bf-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: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10505,6 +10505,7 @@ encode_thumb32_addr_mode (int i, bfd_boolean is_t, bfd_boolean is_d)
1050510505
X(_asrs, 1000, fa50f000), \
1050610506
X(_b, e000, f000b000), \
1050710507
X(_bcond, d000, f0008000), \
10508+
X(_bf, 0000, f040e001), \
1050810509
X(_bic, 4380, ea200000), \
1050910510
X(_bics, 4380, ea300000), \
1051010511
X(_cmn, 42c0, eb100f00), \
@@ -13320,6 +13321,51 @@ v8_1_branch_value_check (int val, int nbits, int is_signed)
1332013321
return SUCCESS;
1332113322
}
1332213323

13324+
/* For branches in Armv8.1-M Mainline. */
13325+
static void
13326+
do_t_branch_future (void)
13327+
{
13328+
unsigned long insn = inst.instruction;
13329+
13330+
inst.instruction = THUMB_OP32 (inst.instruction);
13331+
if (inst.operands[0].hasreloc == 0)
13332+
{
13333+
if (v8_1_branch_value_check (inst.operands[0].imm, 5, FALSE) == FAIL)
13334+
as_bad (BAD_BRANCH_OFF);
13335+
13336+
inst.instruction |= ((inst.operands[0].imm & 0x1f) >> 1) << 23;
13337+
}
13338+
else
13339+
{
13340+
inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH5;
13341+
inst.relocs[0].pc_rel = 1;
13342+
}
13343+
13344+
switch (insn)
13345+
{
13346+
case T_MNEM_bf:
13347+
if (inst.operands[1].hasreloc == 0)
13348+
{
13349+
int val = inst.operands[1].imm;
13350+
if (v8_1_branch_value_check (inst.operands[1].imm, 17, TRUE) == FAIL)
13351+
as_bad (BAD_BRANCH_OFF);
13352+
13353+
int immA = (val & 0x0001f000) >> 12;
13354+
int immB = (val & 0x00000ffc) >> 2;
13355+
int immC = (val & 0x00000002) >> 1;
13356+
inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
13357+
}
13358+
else
13359+
{
13360+
inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF17;
13361+
inst.relocs[1].pc_rel = 1;
13362+
}
13363+
break;
13364+
13365+
default: abort ();
13366+
}
13367+
}
13368+
1332313369
/* Neon instruction encoder helpers. */
1332413370

1332513371
/* Encodings for the different types for various Neon opcodes. */
@@ -19538,6 +19584,11 @@ static struct asm_barrier_opt barrier_opt_names[] =
1953819584
{ mnem, OPS##nops ops, OT_unconditional, 0x0, 0x##top, 0, THUMB_VARIANT, \
1953919585
NULL, do_##te }
1954019586

19587+
/* T_MNEM_xyz enumerator variants of ToC. */
19588+
#define toC(mnem, top, nops, ops, te) \
19589+
{ mnem, OPS##nops ops, OT_csuffix, 0x0, T_MNEM##top, 0, THUMB_VARIANT, NULL, \
19590+
do_##te }
19591+
1954119592
/* Legacy mnemonics that always have conditional infix after the third
1954219593
character. */
1954319594
#define CL(mnem, op, nops, ops, ae) \
@@ -21623,6 +21674,11 @@ static const struct asm_opcode insns[] =
2162321674
#define THUMB_VARIANT & arm_ext_v8m_main
2162421675
ToC("vlldm", ec300a00, 1, (RRnpc), rn),
2162521676
ToC("vlstm", ec200a00, 1, (RRnpc), rn),
21677+
21678+
/* Armv8.1-M Mainline instructions. */
21679+
#undef THUMB_VARIANT
21680+
#define THUMB_VARIANT & arm_ext_v8_1m_main
21681+
toC("bf", _bf, 2, (EXPs, EXPs), t_branch_future),
2162621682
};
2162721683
#undef ARM_VARIANT
2162821684
#undef THUMB_VARIANT
@@ -21633,8 +21689,10 @@ static const struct asm_opcode insns[] =
2163321689
#undef cCE
2163421690
#undef cCL
2163521691
#undef C3E
21692+
#undef C3
2163621693
#undef CE
2163721694
#undef CM
21695+
#undef CL
2163821696
#undef UE
2163921697
#undef UF
2164021698
#undef UT
@@ -21650,6 +21708,9 @@ static const struct asm_opcode insns[] =
2165021708
#undef OPS5
2165121709
#undef OPS6
2165221710
#undef do_0
21711+
#undef ToC
21712+
#undef toC
21713+
#undef ToU
2165321714

2165421715
/* MD interface: bits in the object file. */
2165521716

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 BF instructions
2+
#source: armv8_1-m-bf-bad.s
3+
#as: -march=armv8.1-m.main
4+
#error_output: armv8_1-m-bf-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+
bf 0, 36
7+
bf -2, 36
8+
bf 3, 36
9+
bf 32, 36
10+
# OP1 : signed, 17-bit, even
11+
bf 2, -5
12+
bf 2, 5
13+
bf 2, 65536
14+
bf 2, -65538
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 BF 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]+ <[^>]+> f0df e7ff bf 2, 00000000 <.target>
10+
0: R_ARM_THM_BF16 .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+
bf 2, .target

gas/testsuite/gas/arm/armv8_1-m-bf.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 BF 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]+ <[^>]+> f0c0 e803 bf 2, 0000000a <foo\+0xa>
9+
0[0-9a-f]+ <[^>]+> 4609 mov r1, r1
10+
0[0-9a-f]+ <[^>]+> f140 e801 bf 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-bf.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+
bf 2, 6
6+
mov r1, r1
7+
bf .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/bf.s: New.
4+
* testsuite/ld-arm/bf.d: New.
5+
* testsuite/ld-arm/arm-elf.exp: Add above test.
6+
17
2019-04-15 Thomas Preud'homme <[email protected]>
28

39
* testsuite/ld-arm/attr-merge-13.attr: New test.

0 commit comments

Comments
 (0)