@@ -237,6 +237,8 @@ static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
237
237
static bool arm_cannot_force_const_mem (rtx x);
238
238
/* APPLE LOCAL ARM 5602348 */
239
239
static rtx arm_delegitimize_address (rtx);
240
+ /* APPLE LOCAL ARM 6008578 */
241
+ static HOST_WIDE_INT get_label_pad (rtx, HOST_WIDE_INT);
240
242
241
243
/* Initialize the GCC target structure. */
242
244
#if TARGET_DLLIMPORT_DECL_ATTRIBUTES
@@ -8522,6 +8524,11 @@ create_fix_barrier (Mfix *fix, HOST_WIDE_INT max_address)
8522
8524
/* Count the length of this insn. */
8523
8525
count += get_attr_length (from);
8524
8526
8527
+ /* APPLE LOCAL begin ARM 6008578 */
8528
+ if (LABEL_P (from))
8529
+ count += get_label_pad (from, fix->address + count);
8530
+ /* APPLE LOCAL end ARM 6008578 */
8531
+
8525
8532
/* If there is a jump table, add its length. */
8526
8533
tmp = is_jump_table (from);
8527
8534
if (tmp != NULL)
@@ -8967,6 +8974,37 @@ static int clear_npools (void **slot, void *info ATTRIBUTE_UNUSED)
8967
8974
/* APPLE LOCAL end ARM strings in code */
8968
8975
/* APPLE LOCAL end ARM 20060306 merge these from mainline */
8969
8976
8977
+ /* APPLE LOCAL begin ARM 6008578 */
8978
+ /* Return the bytes of padding that will be inserted to align
8979
+ the label INSN given the current pc ADDRESS. */
8980
+ static HOST_WIDE_INT
8981
+ get_label_pad (rtx insn, HOST_WIDE_INT address)
8982
+ {
8983
+ int label_align, max_skip;
8984
+ unsigned HOST_WIDE_INT align_mask;
8985
+ int pad_needed;
8986
+
8987
+ gcc_assert (LABEL_P (insn));
8988
+
8989
+ label_align = label_to_alignment (insn);
8990
+ max_skip = label_to_max_skip (insn);
8991
+ align_mask = ((unsigned int) 1 << label_align) - 1;
8992
+
8993
+ /* Already aligned. */
8994
+ if ((address & align_mask) == 0)
8995
+ return 0;
8996
+
8997
+ pad_needed = ((address | align_mask) + 1) - address;
8998
+
8999
+ /* We would have to insert more than max_skip bytes to
9000
+ align this label. */
9001
+ if (max_skip && (pad_needed > max_skip))
9002
+ return 0;
9003
+
9004
+ return pad_needed;
9005
+ }
9006
+ /* APPLE LOCAL end ARM 6008578 */
9007
+
8970
9008
/* Gcc puts the pool in the wrong place for ARM, since we can only
8971
9009
load addresses a limited distance around the pc. We do some
8972
9010
special munging to move the constant pool values to the correct
@@ -9008,6 +9046,10 @@ arm_reorg (void)
9008
9046
9009
9047
if (GET_CODE (insn) == BARRIER)
9010
9048
push_minipool_barrier (insn, address);
9049
+ /* APPLE LOCAL begin ARM 6008578 */
9050
+ else if (LABEL_P (insn))
9051
+ address += get_label_pad (insn, address);
9052
+ /* APPLE LOCAL end ARM 6008578 */
9011
9053
else if (INSN_P (insn))
9012
9054
{
9013
9055
rtx table;
@@ -15992,41 +16034,44 @@ arm_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
15992
16034
HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
15993
16035
tree function)
15994
16036
{
16037
+ /* APPLE LOCAL begin ARM 4620953 4745175 5920116 */
15995
16038
static int thunk_label = 0;
15996
16039
char label[256];
15997
- /* APPLE LOCAL ARM mainline 2006-07-25 4620953 */
15998
16040
char labelpc[256];
15999
16041
int mi_delta = delta;
16000
16042
const char *const mi_op = mi_delta < 0 ? "sub" : "add";
16001
16043
int shift = 0;
16002
16044
int this_regno = (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)), function)
16003
16045
? 1 : 0);
16004
- /* APPLE LOCAL begin ARM 4745175 */
16005
16046
rtx function_rtx = XEXP (DECL_RTL (function), 0);
16006
16047
const char *function_name;
16048
+ bool is_longcall = arm_is_longcall_p (function_rtx,
16049
+ SYMBOL_REF_FLAGS (function_rtx),
16050
+ 1);
16051
+ bool is_indirected = false;
16007
16052
16008
16053
/* Darwin/mach-o: use a stub for dynamic references. */
16009
16054
#if TARGET_MACHO
16010
16055
if (TARGET_MACHO
16011
- && (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
16012
- && ! machopic_data_defined_p (function_rtx))
16013
- function_name =
16014
- machopic_indirection_name (function_rtx, true);
16056
+ && MACHOPIC_INDIRECT
16057
+ && (! machopic_data_defined_p (function_rtx)))
16058
+ {
16059
+ function_name = machopic_indirection_name (function_rtx, !is_longcall);
16060
+ is_indirected = true;
16061
+ }
16015
16062
else
16016
16063
#endif
16017
16064
function_name = XSTR (function_rtx, 0);
16018
- /* APPLE LOCAL end ARM 4745175 */
16019
16065
16020
16066
if (mi_delta < 0)
16021
16067
mi_delta = - mi_delta;
16022
- if (TARGET_THUMB)
16068
+ if (TARGET_THUMB || is_longcall )
16023
16069
{
16024
16070
int labelno = thunk_label++;
16025
16071
ASM_GENERATE_INTERNAL_LABEL (label, "LTHUMBFUNC", labelno);
16026
16072
fputs ("\tldr\tr12, ", file);
16027
16073
assemble_name (file, label);
16028
16074
fputc ('\n', file);
16029
- /* APPLE LOCAL begin ARM mainline 2006-07-25 4620953 */
16030
16075
if (flag_pic)
16031
16076
{
16032
16077
/* If we are generating PIC, the ldr instruction below loads
@@ -16044,7 +16089,8 @@ arm_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
16044
16089
fputs (":\n", file);
16045
16090
fputs ("\tadd\tr12, pc, r12\n", file);
16046
16091
}
16047
- /* APPLE LOCAL end ARM mainline 2006-07-25 4620953 */
16092
+ if (is_indirected)
16093
+ fputs ("\tldr\tr12, [r12]\n", file);
16048
16094
}
16049
16095
while (mi_delta != 0)
16050
16096
{
@@ -16059,29 +16105,25 @@ arm_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
16059
16105
shift += 8;
16060
16106
}
16061
16107
}
16062
- if (TARGET_THUMB)
16108
+ if (TARGET_THUMB || is_longcall )
16063
16109
{
16064
16110
fprintf (file, "\tbx\tr12\n");
16065
16111
ASM_OUTPUT_ALIGN (file, 2);
16066
16112
assemble_name (file, label);
16067
16113
fputs (":\n", file);
16068
- /* APPLE LOCAL begin ARM mainline 2006-07-25 4620953 */
16069
16114
if (flag_pic)
16070
16115
{
16071
- /* APPLE LOCAL begin ARM 4745175 */
16072
- /* If we're branching to a local routine, output:
16116
+ /* If we're branching to a local Thumb routine, output:
16073
16117
".word .LTHUNKn-7-.LTHUNKPCn".
16074
16118
Otherwise, output:
16075
16119
".word .LTHUNKn-8-.LTHUNKPCn".
16076
16120
(inter-module thumbness is fixed up by the linker). */
16077
16121
rtx tem = gen_rtx_SYMBOL_REF (Pmode, function_name);
16078
16122
16079
- if (TARGET_MACHO
16080
- && ! machopic_data_defined_p (function_rtx))
16123
+ if (TARGET_MACHO && (TARGET_ARM || is_indirected))
16081
16124
tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-8));
16082
16125
else
16083
16126
tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-7));
16084
- /* APPLE LOCAL end ARM 4745175 */
16085
16127
16086
16128
tem = gen_rtx_MINUS (GET_MODE (tem),
16087
16129
tem,
@@ -16091,21 +16133,18 @@ arm_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
16091
16133
}
16092
16134
else
16093
16135
/* Output ".word .LTHUNKn". */
16094
- /* APPLE LOCAL begin ARM 4745175 */
16095
16136
assemble_integer (gen_rtx_SYMBOL_REF (Pmode, function_name),
16096
16137
4, BITS_PER_WORD, 1);
16097
- /* APPLE LOCAL end ARM 4745175 */
16098
- /* APPLE LOCAL end ARM mainline 2006-07-25 4620953 */
16099
16138
}
16100
16139
else
16101
16140
{
16102
16141
fputs ("\tb\t", file);
16103
- /* APPLE LOCAL ARM 4745175 */
16104
16142
assemble_name (file, function_name);
16105
16143
if (NEED_PLT_RELOC)
16106
16144
fputs ("(PLT)", file);
16107
16145
fputc ('\n', file);
16108
16146
}
16147
+ /* APPLE LOCAL end ARM 4620953 4745175 5920116 */
16109
16148
}
16110
16149
16111
16150
int
@@ -17471,3 +17510,30 @@ arm_delegitimize_address (rtx addr)
17471
17510
return addr;
17472
17511
}
17473
17512
/* APPLE LOCAL end ARM 5602348 */
17513
+ /* APPLE LOCAL begin ARM 6008578 */
17514
+ /* Minimum alignment of a function entry point, in bits. */
17515
+ int
17516
+ arm_function_boundary (void)
17517
+ {
17518
+ int min_align = TARGET_ARM ? 32 : 16;
17519
+
17520
+ /* Even in Thumb mode, thunks are output as ARM functions. */
17521
+ if (cfun && current_function_is_thunk)
17522
+ min_align = MAX (min_align, 32);
17523
+
17524
+ /* e.g., Thumb functions with jump tables. */
17525
+ if (cfun && cfun->needs_4byte_alignment)
17526
+ min_align = MAX (min_align, 32);
17527
+
17528
+ /* If -falign-loops was specified, use that alignment. This is _not_
17529
+ needed to guarantee that loop alignments within the function are
17530
+ honored -- that's handled by the assembler and linker. However,
17531
+ if we don't align the function, then our address calculations (in
17532
+ arm_reorg) are incorrect, potentially wreaking havoc on the
17533
+ constant pool calculations. */
17534
+ min_align = MAX (min_align, align_loops * BITS_PER_UNIT);
17535
+
17536
+ return min_align;
17537
+ }
17538
+ /* APPLE LOCAL end ARM 6008578 */
17539
+
0 commit comments