Patchwork [AArch64] Support --mcmodel=tiny.

login
register
mail settings
Submitter Marcus Shawcroft
Date May 29, 2013, 1:10 p.m.
Message ID <51A5FE3E.5070301@arm.com>
Download mbox | patch
Permalink /patch/247264/
State New
Headers show

Comments

Marcus Shawcroft - May 29, 2013, 1:10 p.m.
On 29/05/13 14:08, Marcus Shawcroft wrote:
> Hi, This patch adds support for the tiny absolute memory model.
>
> Regressed for aarch64-none-elf with each of
>    -mcmodel=tiny
>    -mcmodel=small
>    -mcmodel=small -fPIC
>
> Applied.

This time with patch attached, oops, sorry.

/Marcus

>
> /Marcus
>
> 2012-05-29  Chris Schlumberger-Socha <chris.schlumberger-socha@arm.com>
>              Marcus Shawcroft  <marcus.shawcroft@arm.com>
>
>          * config/aarch64/aarch64-protos.h (aarch64_symbol_type): Define
>          SYMBOL_TINY_ABSOLUTE.
>          * config/aarch64/aarch64.c (aarch64_load_symref_appropriately):
> Handle
>          SYMBOL_TINY_ABSOLUTE.
>          (aarch64_expand_mov_immediate): Likewise.
>          (aarch64_classify_symbol): Likewise.
>          (aarch64_mov_operand_p): Remove ATTRIBUTE_UNUSED.
>          Permit SYMBOL_TINY_ABSOLUTE.
>          * config/aarch64/predicates.md (aarch64_mov_operand): Permit
> CONST.

Patch

diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 91fcde8..bdb6b04 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -81,6 +81,7 @@  enum aarch64_symbol_type
   SYMBOL_SMALL_TLSDESC,
   SYMBOL_SMALL_GOTTPREL,
   SYMBOL_SMALL_TPREL,
+  SYMBOL_TINY_ABSOLUTE,
   SYMBOL_FORCE_TO_MEM
 };
 
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index cbe7847..074eb1c 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -524,6 +524,10 @@  aarch64_load_symref_appropriately (rtx dest, rtx imm,
 	return;
       }
 
+    case SYMBOL_TINY_ABSOLUTE:
+      emit_insn (gen_rtx_SET (Pmode, dest, imm));
+      return;
+
     case SYMBOL_SMALL_GOT:
       {
 	rtx tmp_reg = dest;
@@ -826,6 +830,7 @@  aarch64_expand_mov_immediate (rtx dest, rtx imm)
 
         case SYMBOL_SMALL_TPREL:
 	case SYMBOL_SMALL_ABSOLUTE:
+	case SYMBOL_TINY_ABSOLUTE:
 	  aarch64_load_symref_appropriately (dest, imm, sty);
 	  return;
 
@@ -5030,6 +5035,8 @@  aarch64_classify_symbol (rtx x,
 
 	case AARCH64_CMODEL_TINY_PIC:
 	case AARCH64_CMODEL_TINY:
+	  return SYMBOL_TINY_ABSOLUTE;
+
 	case AARCH64_CMODEL_SMALL_PIC:
 	case AARCH64_CMODEL_SMALL:
 	  return SYMBOL_SMALL_ABSOLUTE;
@@ -5051,6 +5058,10 @@  aarch64_classify_symbol (rtx x,
       switch (aarch64_cmodel)
 	{
 	case AARCH64_CMODEL_TINY:
+	  if (SYMBOL_REF_WEAK (x))
+	    return SYMBOL_FORCE_TO_MEM;
+	  return SYMBOL_TINY_ABSOLUTE;
+
 	case AARCH64_CMODEL_SMALL:
 	  if (SYMBOL_REF_WEAK (x))
 	    return SYMBOL_FORCE_TO_MEM;
@@ -6444,10 +6455,9 @@  aarch64_simd_imm_scalar_p (rtx x, enum machine_mode mode ATTRIBUTE_UNUSED)
 
 bool
 aarch64_mov_operand_p (rtx x,
-		       enum aarch64_symbol_context context ATTRIBUTE_UNUSED,
+		       enum aarch64_symbol_context context,
 		       enum machine_mode mode)
 {
-
   if (GET_CODE (x) == HIGH
       && aarch64_valid_symref (XEXP (x, 0), GET_MODE (XEXP (x, 0))))
     return true;
@@ -6458,7 +6468,8 @@  aarch64_mov_operand_p (rtx x,
   if (GET_CODE (x) == SYMBOL_REF && mode == DImode && CONSTANT_ADDRESS_P (x))
     return true;
 
-  return false;
+  return aarch64_classify_symbolic_expression (x, context)
+    == SYMBOL_TINY_ABSOLUTE;
 }
 
 /* Return a const_int vector of VAL.  */
diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md
index 16c4385..3248f61 100644
--- a/gcc/config/aarch64/predicates.md
+++ b/gcc/config/aarch64/predicates.md
@@ -166,7 +166,7 @@ 
 })
 
 (define_predicate "aarch64_mov_operand"
-  (and (match_code "reg,subreg,mem,const_int,symbol_ref,high")
+  (and (match_code "reg,subreg,mem,const,const_int,symbol_ref,label_ref,high")
        (ior (match_operand 0 "register_operand")
 	    (ior (match_operand 0 "memory_operand")
 		 (match_test "aarch64_mov_operand_p (op, SYMBOL_CONTEXT_ADR, mode)")))))