[PATCH] [arm] Parse tag names for eabi_attribute directive.

Logan Chien tzuhsiang.chien at gmail.com
Tue Dec 17 07:50:07 PST 2013


Hi richard.barton.arm, rengolin,

This commit adds the preliminary support to parse the tag name of the
eabi_attribute directive.  For example,

	.eabi_attribute Tag_ARM_ISA_use, 1

should be equivalent to:

	.eabi_attribute 8, 1

Most tag names are mapped and tested.  However, due to the incomplete
eabi_attribute directive parser, following tags are missing from the
test case: Tag_CPU_raw_name, Tag_CPU_name, Tag_compatibility,
Tag_also_compatible_with, and Tag_conformance.

http://llvm-reviews.chandlerc.com/D2424

Files:
  lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  test/MC/ARM/directive-eabi_attribute-str.s

Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -8025,10 +8025,64 @@
 /// parseDirectiveEabiAttr
 ///  ::= .eabi_attribute int, int
 bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
-  if (Parser.getTok().isNot(AsmToken::Integer))
-    return Error(L, "integer expected");
-  int64_t Tag = Parser.getTok().getIntVal();
-  Parser.Lex(); // eat tag integer
+  // Parse the eabi_attribute tag
+  const AsmToken &Token = Parser.getTok();
+  if (Token.isNot(AsmToken::Integer) && Token.isNot(AsmToken::Identifier))
+    return Error(L, "eabi_attribute tag expected");
+
+  int Tag = -1;
+  if (Token.is(AsmToken::Integer)) {
+    Tag = Parser.getTok().getIntVal();
+  } else {
+    Tag = StringSwitch<int>(Token.getString())
+#define CASE_EABI_ATTR_TAG(NAME) .Case("Tag_" #NAME, ARMBuildAttrs::NAME)
+      CASE_EABI_ATTR_TAG(CPU_raw_name)
+      CASE_EABI_ATTR_TAG(CPU_name)
+      CASE_EABI_ATTR_TAG(CPU_arch)
+      CASE_EABI_ATTR_TAG(CPU_arch_profile)
+      CASE_EABI_ATTR_TAG(ARM_ISA_use)
+      CASE_EABI_ATTR_TAG(THUMB_ISA_use)
+      CASE_EABI_ATTR_TAG(VFP_arch)
+      CASE_EABI_ATTR_TAG(WMMX_arch)
+      CASE_EABI_ATTR_TAG(Advanced_SIMD_arch)
+      CASE_EABI_ATTR_TAG(PCS_config)
+      CASE_EABI_ATTR_TAG(ABI_PCS_R9_use)
+      CASE_EABI_ATTR_TAG(ABI_PCS_RW_data)
+      CASE_EABI_ATTR_TAG(ABI_PCS_RO_data)
+      CASE_EABI_ATTR_TAG(ABI_PCS_GOT_use)
+      CASE_EABI_ATTR_TAG(ABI_PCS_wchar_t)
+      CASE_EABI_ATTR_TAG(ABI_FP_rounding)
+      CASE_EABI_ATTR_TAG(ABI_FP_denormal)
+      CASE_EABI_ATTR_TAG(ABI_FP_exceptions)
+      CASE_EABI_ATTR_TAG(ABI_FP_user_exceptions)
+      CASE_EABI_ATTR_TAG(ABI_FP_number_model)
+      CASE_EABI_ATTR_TAG(ABI_align8_needed)
+      CASE_EABI_ATTR_TAG(ABI_align8_preserved)
+      CASE_EABI_ATTR_TAG(ABI_enum_size)
+      CASE_EABI_ATTR_TAG(ABI_HardFP_use)
+      CASE_EABI_ATTR_TAG(ABI_VFP_args)
+      CASE_EABI_ATTR_TAG(ABI_WMMX_args)
+      CASE_EABI_ATTR_TAG(ABI_optimization_goals)
+      CASE_EABI_ATTR_TAG(ABI_FP_optimization_goals)
+      CASE_EABI_ATTR_TAG(compatibility)
+      CASE_EABI_ATTR_TAG(CPU_unaligned_access)
+      CASE_EABI_ATTR_TAG(FP_HP_extension)
+      CASE_EABI_ATTR_TAG(ABI_FP_16bit_format)
+      CASE_EABI_ATTR_TAG(MPextension_use)
+      CASE_EABI_ATTR_TAG(DIV_use)
+      CASE_EABI_ATTR_TAG(nodefaults)
+      CASE_EABI_ATTR_TAG(conformance)
+      CASE_EABI_ATTR_TAG(also_compatible_with)
+      CASE_EABI_ATTR_TAG(T2EE_use)
+      CASE_EABI_ATTR_TAG(Virtualization_use)
+#undef CASE_EABI_ATTR_TAG
+      .Case("Tag_FP_arch", ARMBuildAttrs::VFP_arch)
+      .Default(-1);
+
+    if (Tag == -1)
+      return Error(L, Twine("unknown eabi_attribute tag ", Token.getString()));
+  }
+  Parser.Lex(); // eat tag token
 
   if (Parser.getTok().isNot(AsmToken::Comma))
     return Error(L, "comma expected");
Index: test/MC/ARM/directive-eabi_attribute-str.s
===================================================================
--- /dev/null
+++ test/MC/ARM/directive-eabi_attribute-str.s
@@ -0,0 +1,86 @@
+@ Check the mapping between Tag_names and build attribute number
+
+@ RUN: llvm-mc < %s -triple armv7-unknown-linux-gnueabi -o - | FileCheck %s
+
+@ FIXME: Special cases not supported by assembly parser at the moment.
+@	.eabi_attribute Tag_CPU_raw_name, "cortex-a15"
+@ FIXME-CHECK: .eabi_attribute 4, "cortex-a15"
+@	.eabi_attribute Tag_CPU_name, "cortex-a15"
+@ FIXME-CHECK: .eabi_attribute 5, "cortex-a15"
+@	.eabi_attribute Tag_compatibility, 1, "aeabi"
+@ FIXME-CHECK: .eabi_attribute 32, 1, "aeabi"
+@	.eabi_attribute Tag_also_compatible_with, 1, ""
+@ FIXME-CHECK: .eabi_attribute 65, 1, ""
+@	.eabi_attribute Tag_conformance, "2.09"
+@ FIXME-CHECK: .eabi_attribute 67, "2.09"
+
+	.eabi_attribute Tag_CPU_arch, 0
+@ CHECK: .eabi_attribute 6, 0
+	.eabi_attribute Tag_CPU_arch_profile, 0
+@ CHECK: .eabi_attribute 7, 0
+	.eabi_attribute Tag_ARM_ISA_use, 0
+@ CHECK: .eabi_attribute 8, 0
+	.eabi_attribute Tag_THUMB_ISA_use, 0
+@ CHECK: .eabi_attribute 9, 0
+	.eabi_attribute Tag_VFP_arch, 0
+@ CHECK: .eabi_attribute 10, 0
+	.eabi_attribute Tag_FP_arch, 0
+@ CHECK: .eabi_attribute 10, 0
+	.eabi_attribute Tag_WMMX_arch, 0
+@ CHECK: .eabi_attribute 11, 0
+	.eabi_attribute Tag_Advanced_SIMD_arch, 0
+@ CHECK: .eabi_attribute 12, 0
+	.eabi_attribute Tag_PCS_config, 0
+@ CHECK: .eabi_attribute 13, 0
+	.eabi_attribute Tag_ABI_PCS_R9_use, 0
+@ CHECK: .eabi_attribute 14, 0
+	.eabi_attribute Tag_ABI_PCS_RW_data, 0
+@ CHECK: .eabi_attribute 15, 0
+	.eabi_attribute Tag_ABI_PCS_RO_data, 0
+@ CHECK: .eabi_attribute 16, 0
+	.eabi_attribute Tag_ABI_PCS_GOT_use, 0
+@ CHECK: .eabi_attribute 17, 0
+	.eabi_attribute Tag_ABI_PCS_wchar_t, 0
+@ CHECK: .eabi_attribute 18, 0
+	.eabi_attribute Tag_ABI_FP_rounding, 0
+@ CHECK: .eabi_attribute 19, 0
+	.eabi_attribute Tag_ABI_FP_denormal, 0
+@ CHECK: .eabi_attribute 20, 0
+	.eabi_attribute Tag_ABI_FP_exceptions, 0
+@ CHECK: .eabi_attribute 21, 0
+	.eabi_attribute Tag_ABI_FP_user_exceptions, 0
+@ CHECK: .eabi_attribute 22, 0
+	.eabi_attribute Tag_ABI_FP_number_model, 0
+@ CHECK: .eabi_attribute 23, 0
+	.eabi_attribute Tag_ABI_align8_needed, 0
+@ CHECK: .eabi_attribute 24, 0
+	.eabi_attribute Tag_ABI_align8_preserved, 0
+@ CHECK: .eabi_attribute 25, 0
+	.eabi_attribute Tag_ABI_enum_size, 0
+@ CHECK: .eabi_attribute 26, 0
+	.eabi_attribute Tag_ABI_HardFP_use, 0
+@ CHECK: .eabi_attribute 27, 0
+	.eabi_attribute Tag_ABI_VFP_args, 0
+@ CHECK: .eabi_attribute 28, 0
+	.eabi_attribute Tag_ABI_WMMX_args, 0
+@ CHECK: .eabi_attribute 29, 0
+	.eabi_attribute Tag_ABI_optimization_goals, 0
+@ CHECK: .eabi_attribute 30, 0
+	.eabi_attribute Tag_ABI_FP_optimization_goals, 0
+@ CHECK: .eabi_attribute 31, 0
+	.eabi_attribute Tag_CPU_unaligned_access, 0
+@ CHECK: .eabi_attribute 34, 0
+	.eabi_attribute Tag_FP_HP_extension, 0
+@ CHECK: .eabi_attribute 36, 0
+	.eabi_attribute Tag_ABI_FP_16bit_format, 0
+@ CHECK: .eabi_attribute 38, 0
+	.eabi_attribute Tag_MPextension_use, 0
+@ CHECK: .eabi_attribute 42, 0
+	.eabi_attribute Tag_DIV_use, 0
+@ CHECK: .eabi_attribute 44, 0
+	.eabi_attribute Tag_nodefaults, 0
+@ CHECK: .eabi_attribute 64, 0
+	.eabi_attribute Tag_T2EE_use, 0
+@ CHECK: .eabi_attribute 66, 0
+	.eabi_attribute Tag_Virtualization_use, 0
+@ CHECK: .eabi_attribute 68, 0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2424.1.patch
Type: text/x-patch
Size: 6374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131217/33ee40e0/attachment.bin>


More information about the llvm-commits mailing list