diff mbox series

Correct comment for ADDR_EXPR tree code.

Message ID 217ce49a-cc7e-c142-6ae5-d580c486d771@foss.arm.com
State New
Headers show
Series Correct comment for ADDR_EXPR tree code. | expand

Commit Message

Renlin Li March 23, 2018, 3:44 p.m. UTC
Hi all,

This is a simple patch to correct the comment for ADDR_EXPR tree code.

The resulting expression of ADDR_EXPR is a tree with POINTER_TYPE.
So the result mode should ptr_mode instead of Pmode.

As far as I understand, Pmode is the addressing mode. But not the mode to represent a pointer (or address?).

Okay to commit?

Regards,
Renlin

gcc/ChangeLog:

2018-03-23  Renlin Li  <renlin.li@arm.com>

	* tree.def (ADDR_EXPR): Correct the commnet.

Comments

Jeff Law March 23, 2018, 11:19 p.m. UTC | #1
On 03/23/2018 09:44 AM, Renlin Li wrote:
> Hi all,
> 
> This is a simple patch to correct the comment for ADDR_EXPR tree code.
> 
> The resulting expression of ADDR_EXPR is a tree with POINTER_TYPE.
> So the result mode should ptr_mode instead of Pmode.
> 
> As far as I understand, Pmode is the addressing mode. But not the mode
> to represent a pointer (or address?).
> 
> Okay to commit?
> 
> Regards,
> Renlin
> 
> gcc/ChangeLog:
> 
> 2018-03-23  Renlin Li  <renlin.li@arm.com>
> 
>     * tree.def (ADDR_EXPR): Correct the commnet.I'm not sure this is strictly correct.  More importantly, I'm not sure
why we care :-0

Modes are more of a target/RTL issue.  Why a tree node needs to specify
a mode in this case vs a type seems to be the more important question.

jeff
Renlin Li March 24, 2018, 9:25 p.m. UTC | #2
Hi Jeff,

On 23/03/18 23:19, Jeff Law wrote:
> On 03/23/2018 09:44 AM, Renlin Li wrote:
>> Hi all,
>>
>> This is a simple patch to correct the comment for ADDR_EXPR tree code.
>>
>> The resulting expression of ADDR_EXPR is a tree with POINTER_TYPE.
>> So the result mode should ptr_mode instead of Pmode.
>>
>> As far as I understand, Pmode is the addressing mode. But not the mode
>> to represent a pointer (or address?).
>>
>> Okay to commit?
>>
>> Regards,
>> Renlin
>>
>> gcc/ChangeLog:
>>
>> 2018-03-23  Renlin Li  <renlin.li@arm.com>
>>
>>      * tree.def (ADDR_EXPR): Correct the commnet.I'm not sure this is strictly correct.  More importantly, I'm not sure
> why we care :-0
> 
> Modes are more of a target/RTL issue.  Why a tree node needs to specify
> a mode in this case vs a type seems to be the more important question.

It is a very minor issue, I just come cross the comment which doesn't seem very right.

I agree, the type is more meaningful than the machine mode to describe a tree node.
The result of ADDR_EXPR should be an expression of POINTER_TYPE or REFERENCE_TYPE as the document indicates.

I can replace the sentence "Result mode is Pmode." with "The result expression will always have pointer or reference type."

Thanks!
Renlin


> 
> jeff
> 
> 
>
diff mbox series

Patch

diff --git a/gcc/tree.def b/gcc/tree.def
index 31de6c0994de43c175b924d4ba578a131fb4d524..1e5aca811f801c54be9215a9d86028f50a4ec608 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -870,7 +870,7 @@  DEFTREECODE (COMPOUND_LITERAL_EXPR, "compound_literal_expr", tcc_expression, 1)
 DEFTREECODE (SAVE_EXPR, "save_expr", tcc_expression, 1)
 
 /* & in C.  Value is the address at which the operand's value resides.
-   Operand may have any mode.  Result mode is Pmode.  */
+   Operand may have any mode.  Result mode is ptr_mode.  */
 DEFTREECODE (ADDR_EXPR, "addr_expr", tcc_expression, 1)
 
 /* Operand0 is a function constant; result is part N of a function