[5/5,ARC] Check if an input asm file is rf16 compliant

Message ID 20180724142641.2678-5-claziss@gmail.com
State New
Headers show
Series
  • [1/5,ARC] Update handling AUX-registers.
Related show

Commit Message

Claudiu Zissulescu July 24, 2018, 2:26 p.m.
From: claziss <claziss@synopsys.com>


Check if an input asm file is rf16 compliant; if not, and the tag says
otherwise, fix the tag and emit a warning.

Ok to apply?
Claudiu

gas/
2017-09-20  Claudiu Zissulescu <claziss@synopsys.com>

	* config/tc-arc.c (rf16_only): New static variable.
	(autodetect_attributes): Check if we are rf16 compliant.
	(arc_set_public_attributes): Fix and emit the warning is required.
	* testsuite/gas/arc/attr-rf16.d: New file.
	* testsuite/gas/arc/attr-rf16.err: Likewise.
	* testsuite/gas/arc/attr-rf16.s: Likewise.
---
 gas/config/tc-arc.c                 | 25 +++++++++++++++++++++++++
 gas/testsuite/gas/arc/attr-rf16.d   | 10 ++++++++++
 gas/testsuite/gas/arc/attr-rf16.err |  2 ++
 gas/testsuite/gas/arc/attr-rf16.s   |  4 ++++
 4 files changed, 41 insertions(+)
 create mode 100644 gas/testsuite/gas/arc/attr-rf16.d
 create mode 100644 gas/testsuite/gas/arc/attr-rf16.err
 create mode 100644 gas/testsuite/gas/arc/attr-rf16.s

-- 
2.17.1

Comments

Nick Clifton July 31, 2018, 4:08 p.m. | #1
Hi Claudiu,

> gas/

> 2017-09-20  Claudiu Zissulescu <claziss@synopsys.com>

> 

> 	* config/tc-arc.c (rf16_only): New static variable.

> 	(autodetect_attributes): Check if we are rf16 compliant.

> 	(arc_set_public_attributes): Fix and emit the warning is required.

> 	* testsuite/gas/arc/attr-rf16.d: New file.

> 	* testsuite/gas/arc/attr-rf16.err: Likewise.

> 	* testsuite/gas/arc/attr-rf16.s: Likewise.

 
Approved - please apply.

Cheers
  Nick

Patch

diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index ddc5de8363..672895b6a1 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -475,6 +475,9 @@  static const struct cpu_type
 /* Information about the cpu/variant we're assembling for.  */
 static struct cpu_type selected_cpu = { 0, 0, 0, E_ARC_OSABI_CURRENT, 0 };
 
+/* TRUE if current assembly code uses RF16 only registers.  */
+static bfd_boolean rf16_only = TRUE;
+
 /* MPY option.  */
 static unsigned mpy_option = 0;
 
@@ -2382,6 +2385,17 @@  autodetect_attributes (const struct arc_opcode *opcode,
 	default:
 	  break;
 	}
+
+      switch (tok[i].X_op)
+	{
+	case O_register:
+	  if ((tok[i].X_add_number >= 4 && tok[i].X_add_number <= 9)
+	      || (tok[i].X_add_number >= 16 && tok[i].X_add_number <= 25))
+	    rf16_only = FALSE;
+	  break;
+	default:
+	  break;
+	}
     }
 }
 
@@ -5016,6 +5030,17 @@  arc_set_public_attributes (void)
 
   /* Tag_ARC_ATR_version.  */
   arc_set_attribute_int (Tag_ARC_ATR_version, 1);
+
+  /* Tag_ARC_ABI_rf16.  */
+  if (attributes_set_explicitly[Tag_ARC_ABI_rf16]
+      && bfd_elf_get_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+				   Tag_ARC_ABI_rf16)
+      && !rf16_only)
+    {
+      as_warn (_("Overwrite explicitly set Tag_ARC_ABI_rf16 to full "
+		 "register file"));
+      bfd_elf_add_proc_attr_int (stdoutput, Tag_ARC_ABI_rf16, 0);
+    }
 }
 
 /* Add the default contents for the .ARC.attributes section.  */
diff --git a/gas/testsuite/gas/arc/attr-rf16.d b/gas/testsuite/gas/arc/attr-rf16.d
new file mode 100644
index 0000000000..fcbac17a70
--- /dev/null
+++ b/gas/testsuite/gas/arc/attr-rf16.d
@@ -0,0 +1,10 @@ 
+#error-output: attr-rf16.err
+#as:
+#readelf: -A
+
+Attribute Section: ARC
+File Attributes
+  Tag_ARC_CPU_base: ARCEM
+  Tag_ARC_CPU_name: "em"
+  Tag_ARC_ABI_osver: v4
+  Tag_ARC_ATR_version: 1
diff --git a/gas/testsuite/gas/arc/attr-rf16.err b/gas/testsuite/gas/arc/attr-rf16.err
new file mode 100644
index 0000000000..a33cbc5c05
--- /dev/null
+++ b/gas/testsuite/gas/arc/attr-rf16.err
@@ -0,0 +1,2 @@ 
+[^:]*: Assembler messages:
+[^:]*: Warning: Overwrite explicitly set Tag_ARC_ABI_rf16 to full register file
diff --git a/gas/testsuite/gas/arc/attr-rf16.s b/gas/testsuite/gas/arc/attr-rf16.s
new file mode 100644
index 0000000000..cc0573cd10
--- /dev/null
+++ b/gas/testsuite/gas/arc/attr-rf16.s
@@ -0,0 +1,4 @@ 
+	.cpu em
+	.arc_attribute Tag_ARC_ABI_rf16,1
+	mov 	r8,0
+	mov	r16,0