2014-09-16 13:08 GMT+04:00 Uros Bizjak <ubiz...@gmail.com>: > Hello! > >> This patch adds size relocation support for i386 target. Relocation is used >> to compute bounds for static objects with incomplete type. >> >> Thanks, >> Ilya >> -- >> gcc/ >> >> 2014-06-11 Ilya Enkovich <ilya.enkov...@intel.com> >> >> * config/i386/i386.md (UNSPEC_SIZEOF): New. >> (move_size_reloc_si): New. >> (move_size_reloc_di): New. >> * config/i386/predicates.md (symbol_operand): New. >> >> >> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md >> index 32db2c6..5fd556b 100644 >> --- a/gcc/config/i386/i386.md >> +++ b/gcc/config/i386/i386.md >> @@ -79,6 +79,7 @@ >> UNSPEC_PLTOFF >> UNSPEC_MACHOPIC_OFFSET >> UNSPEC_PCREL >> + UNSPEC_SIZEOF >> >> ;; Prologue support >> UNSPEC_STACK_ALLOC >> @@ -18340,6 +18341,32 @@ >> "bndstx\t{%2, %3|%3, %2}" >> [(set_attr "type" "mpxst")]) >> >> +(define_insn "move_size_reloc_si" >> + [(set (match_operand:SI 0 "register_operand" "=r") >> + (unspec:SI >> + [(match_operand:SI 1 "symbol_operand")] >> + UNSPEC_SIZEOF))] >> + "TARGET_MPX" >> + "mov{l}\t{%1@SIZE, %0|%0, %1@SIZE}" >> + [(set_attr "type" "imov") >> + (set_attr "mode" "SI")]) >> + >> +(define_insn "move_size_reloc_di" >> + [(set (match_operand:DI 0 "register_operand" "=r") >> + (unspec:DI >> + [(match_operand:DI 1 "symbol_operand")] >> + UNSPEC_SIZEOF))] >> + "TARGET_64BIT && TARGET_MPX" >> +{ >> + if (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE >> + || ix86_cmodel == CM_MEDIUM_PIC || ix86_cmodel == CM_LARGE_PIC) >> + return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}"; > > Can x86_64_immediate_operand predicate be used here?
I think it cannot be used because of TLS symbols not counting as immediate. Thanks, Ilya > >> + else >> + return "mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE}"; >> +} >> + [(set_attr "type" "imov") >> + (set_attr "mode" "DI")]) >> + >> (include "mmx.md") >> (include "sse.md") >> (include "sync.md") >> diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md >> index a738033..e4c5d21 100644 >> --- a/gcc/config/i386/predicates.md >> +++ b/gcc/config/i386/predicates.md >> @@ -119,6 +119,10 @@ >> (match_test "TARGET_64BIT") >> (match_test "REGNO (op) > BX_REG"))) >> >> +;; Return true if VALUE is symbol reference >> +(define_predicate "symbol_operand" >> + (match_code "symbol_ref")) >> + >> ;; Return true if VALUE can be stored in a sign extended immediate field. >> (define_predicate "x86_64_immediate_operand" >> (match_code "const_int,symbol_ref,label_ref,const") > > Uros.