Microblaze Target: PIC data text relative
authorAndrew Sadek <andrew.sadek.se@gmail.com>
Mon, 30 Apr 2018 11:16:55 +0000 (11:16 +0000)
committerMichael Eager <eager@gcc.gnu.org>
Mon, 30 Apr 2018 11:16:55 +0000 (11:16 +0000)
commitaf1682fc3aaff288f7ac95cf5585971cef15f0ab
treea18a830cd4148874dcac4c70eb18dd4b43f54a1b
parent5885f02733f9bab7e9508bfebbeed5b3c9254aaa
Microblaze Target: PIC data text relative
2018-04-30 Andrew Sadek  <andrew.sadek.se@gmail.com>

gcc/ChangeLog:
* config/microblaze/microblaze.opt: add new option -mpic-data-text-rel.
* config/microblaze/microblaze-protos.h (microblaze_constant_address_p):
Add declaration.
* gcc/config/microblaze/microblaze.h (microblaze_constant_address_p):
CONSTANT_ADDRESS_P definition to microblaze_constant_address_p.
* config/microblaze/microblaze.c (TARGET_PIC_DATA_TEXT_REL):
New addressing mode for data-text relative position indepenedent code.
(microblaze_classify_unspec): add 'UNSPEC_TEXT' case ->
'ADDRESS_SYMBOLIC_TXT_REL'.
(microblaze_classify_address): Add handling for UNSPEC + CONST_INT.
(microblaze_legitimate_pic_operand): Exclude function calls from
pic operands in case of TARGET_PIC_DATA_TEXT_REL option.
(microblaze_legitimize_address): Generate 'UNSPEC_TEXT' for all possible
addresses cases.
(microblaze_address_insns): Add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand): Add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand_address): Add 'ADDRESS_SYMBOLIC_TXT_REL' case + handling
for 'address + offset'.
(microblaze_expand_prologue): Add new function prologue call for
'r20' assignation.
(microblaze_asm_generate_pic_addr_dif_vec): Override new target hook
'TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC' to disable address diff vector
table in case of TARGET_PIC_DATA_TEXT_REL.
(expand_pic_symbol_ref): Add handling for 'UNSPEC_TEXT'.
* gcc/config/microblaze/microblaze.md (TARGET_PIC_DATA_TEXT_REL):
Add new macros 'UNSPEC_TEXT',
'UNSPEC_SET_TEXT' + add rule for setting r20 in function prologue
+ exclude function calls from 'UNSPEC_PLT' in case of data text
relative mode.
* doc/tm.texi.in (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): Add
new target hook for generating address diff vector tables in case of
flag_pic.
* doc/tm.texi : Regenerate.
* stmt.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): Append new condition
'targetm.asm_out.generate_pic_addr_diff_vec' to flag_pic in case
of addr diff vector generation.
* target.def (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): Add
target hook definition.
* targhooks.h, gcc/targhooks.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
Add default function for generate_pic_addr_diff_vec -> flag_pic.
* doc/invoke.texi (Add new pic option): Add new microblaze pic
option for data text relative.

testsuite/ChangeLog:
* gcc.target/microblaze/others/data_var1.c: Include
PIC case of r20 base register.
* gcc.target/microblaze/others/data_var2.c: Ditto.
* gcc.target/microblaze/others/picdtr.c: Add new
test case for -mpic-is-data-text-relative.
* gcc.target/microblaze/others/sdata_var1.c: Add
* gcc.target/microblaze/others/sdata_var2.c: Ditto.
* gcc.target/microblaze/others/sdata_var3.c: Ditto.
* gcc.target/microblaze/others/sdata_var4.c: Ditto.
* gcc.target/microblaze/others/sdata_var5.c: Ditto.
* gcc.target/microblaze/others/sdata_var6.c: Ditto.
* gcc.target/microblaze/others/string_cst1_gpopt.c: Ditto.
* gcc.target/microblaze/others/string_cst2_gpopt.c: Ditto.

From-SVN: r259758
24 files changed:
gcc/ChangeLog
gcc/config/microblaze/microblaze-protos.h
gcc/config/microblaze/microblaze.c
gcc/config/microblaze/microblaze.h
gcc/config/microblaze/microblaze.md
gcc/config/microblaze/microblaze.opt
gcc/doc/invoke.texi
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/stmt.c
gcc/target.def
gcc/targhooks.c
gcc/targhooks.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/microblaze/others/data_var1.c
gcc/testsuite/gcc.target/microblaze/others/data_var2.c
gcc/testsuite/gcc.target/microblaze/others/sdata_var1.c
gcc/testsuite/gcc.target/microblaze/others/sdata_var2.c
gcc/testsuite/gcc.target/microblaze/others/sdata_var3.c
gcc/testsuite/gcc.target/microblaze/others/sdata_var4.c
gcc/testsuite/gcc.target/microblaze/others/sdata_var5.c
gcc/testsuite/gcc.target/microblaze/others/sdata_var6.c
gcc/testsuite/gcc.target/microblaze/others/string_cst1_gpopt.c
gcc/testsuite/gcc.target/microblaze/others/string_cst2_gpopt.c