Re: how to force mem constraint for symbol ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/7/19 11:02 AM, William Tambe wrote:
> Let's consider the following code snippet that retrieve the address of a label:
> 
> mylabel:
> void* ptr = &&mylabel;
> 
> when compiling the above, GCC associate the label with the constraint "i".
> 
> However, I am unable to force GCC to associate symbols with the
> constraint "A" that I am defining in the excerpt below:
> 
> ----------------------------------------
> (define_constraint "A"
>  "A memory address."
>  (and (match_code "mem")
>       (ior (match_test "GET_CODE (XEXP (op, 0)) == SYMBOL_REF")
>            (match_test "GET_CODE (XEXP (op, 0)) == LABEL_REF")
>            (match_test "GET_CODE (XEXP (op, 0)) == CONST"))))
> 
> (define_insn "movsi"
>  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r")
>        (match_operand:SI 1 "general_operand"      "A,i"))]
>  ""
>  "@
>   gip %0, %1
>   li %0, %1")
> ----------------------------------------------------------
> 
> GCC always choose to match the line "li %0, %1" instead of the line
> "gip %0, %1".
> 
> How can I force GCC to match "gip %0, %1" for a symbol ?
> 
You'd have to debug the register allocation and reloading phase to
determine what it's doing and why.

And, in general, you want your constraints and predicates to match as
closely as possible.  So in the above case your predicates are
"nonimmediate_operand and "general_operand".  You'd be better off with
"register_operand" and "immediate_operand" since operand 0's constraints
only allow registers and operand 1's constraints only allow immediates.

Jeff



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux