[NDS32] Implement DATA_ALIGNMENT, LOCAL_ALIGNMENT and TARGET_CONSTANT_ALIGNMENT.
gcc/ * config/nds32/nds32-protos.h (nds32_data_alignment, nds32_local_alignment): Declare. * config/nds32/nds32.c (nds32_data_alignment, nds32_constant_alignment, nds32_local_alignment): New functions. (TARGET_CONSTANT_ALIGNMENT): Define. * config/nds32/nds32.h (DATA_ALIGNMENT, LOCAL_ALIGNMENT): Define. From-SVN: r259548
This commit is contained in:
parent
50256c75f4
commit
79498ad8ba
@ -1,3 +1,12 @@
|
||||
2018-04-22 Chung-Ju Wu <jasonwucj@gmail.com>
|
||||
|
||||
* config/nds32/nds32-protos.h (nds32_data_alignment,
|
||||
nds32_local_alignment): Declare.
|
||||
* config/nds32/nds32.c (nds32_data_alignment, nds32_constant_alignment,
|
||||
nds32_local_alignment): New functions.
|
||||
(TARGET_CONSTANT_ALIGNMENT): Define.
|
||||
* config/nds32/nds32.h (DATA_ALIGNMENT, LOCAL_ALIGNMENT): Define.
|
||||
|
||||
2018-04-22 Chung-Ju Wu <jasonwucj@gmail.com>
|
||||
|
||||
* config/nds32/nds32.c
|
||||
|
@ -223,6 +223,8 @@ extern int nds32_can_use_return_insn (void);
|
||||
/* Auxiliary functions to decide output alignment or not. */
|
||||
|
||||
extern int nds32_target_alignment (rtx_insn *);
|
||||
extern unsigned int nds32_data_alignment (tree, unsigned int);
|
||||
extern unsigned int nds32_local_alignment (tree, unsigned int);
|
||||
|
||||
/* Auxiliary functions to expand builtin functions. */
|
||||
|
||||
|
@ -4812,6 +4812,63 @@ nds32_target_alignment (rtx_insn *label)
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Return alignment for data. */
|
||||
unsigned int
|
||||
nds32_data_alignment (tree data,
|
||||
unsigned int basic_align)
|
||||
{
|
||||
if ((basic_align < BITS_PER_WORD)
|
||||
&& (TREE_CODE (data) == ARRAY_TYPE
|
||||
|| TREE_CODE (data) == UNION_TYPE
|
||||
|| TREE_CODE (data) == RECORD_TYPE))
|
||||
return BITS_PER_WORD;
|
||||
else
|
||||
return basic_align;
|
||||
}
|
||||
|
||||
/* Return alignment for constant value. */
|
||||
static HOST_WIDE_INT
|
||||
nds32_constant_alignment (const_tree constant,
|
||||
HOST_WIDE_INT basic_align)
|
||||
{
|
||||
/* Make string literal and constant for constructor to word align. */
|
||||
if (((TREE_CODE (constant) == STRING_CST
|
||||
|| TREE_CODE (constant) == CONSTRUCTOR
|
||||
|| TREE_CODE (constant) == UNION_TYPE
|
||||
|| TREE_CODE (constant) == RECORD_TYPE
|
||||
|| TREE_CODE (constant) == ARRAY_TYPE)
|
||||
&& basic_align < BITS_PER_WORD))
|
||||
return BITS_PER_WORD;
|
||||
else
|
||||
return basic_align;
|
||||
}
|
||||
|
||||
/* Return alignment for local variable. */
|
||||
unsigned int
|
||||
nds32_local_alignment (tree local ATTRIBUTE_UNUSED,
|
||||
unsigned int basic_align)
|
||||
{
|
||||
bool at_least_align_to_word = false;
|
||||
/* Make local array, struct and union at least align to word for make
|
||||
sure it can unroll memcpy when initialize by constant. */
|
||||
switch (TREE_CODE (local))
|
||||
{
|
||||
case ARRAY_TYPE:
|
||||
case RECORD_TYPE:
|
||||
case UNION_TYPE:
|
||||
at_least_align_to_word = true;
|
||||
break;
|
||||
default:
|
||||
at_least_align_to_word = false;
|
||||
break;
|
||||
}
|
||||
if (at_least_align_to_word
|
||||
&& (basic_align < BITS_PER_WORD))
|
||||
return BITS_PER_WORD;
|
||||
else
|
||||
return basic_align;
|
||||
}
|
||||
|
||||
bool
|
||||
nds32_split_double_word_load_store_p(rtx *operands, bool load_p)
|
||||
{
|
||||
@ -4865,6 +4922,9 @@ nds32_use_blocks_for_constant_p (machine_mode mode,
|
||||
#undef TARGET_EXPAND_TO_RTL_HOOK
|
||||
#define TARGET_EXPAND_TO_RTL_HOOK nds32_expand_to_rtl_hook
|
||||
|
||||
#undef TARGET_CONSTANT_ALIGNMENT
|
||||
#define TARGET_CONSTANT_ALIGNMENT nds32_constant_alignment
|
||||
|
||||
|
||||
/* Layout of Source Language Data Types. */
|
||||
|
||||
|
@ -688,6 +688,12 @@ enum nds32_builtins
|
||||
|
||||
#define BIGGEST_ALIGNMENT 64
|
||||
|
||||
#define DATA_ALIGNMENT(constant, basic_align) \
|
||||
nds32_data_alignment (constant, basic_align)
|
||||
|
||||
#define LOCAL_ALIGNMENT(type, basic_align) \
|
||||
nds32_local_alignment (type, basic_align)
|
||||
|
||||
#define EMPTY_FIELD_BOUNDARY 32
|
||||
|
||||
#define STRUCTURE_SIZE_BOUNDARY 8
|
||||
|
Loading…
Reference in New Issue
Block a user