This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Introduce abi_word_mode

Andreas Krebbel <> writes:

> I'm currently working on a s390 patch which needs gcc to 
> use internally a different word mode than the ABI-visible one.
> More precisely I want 32bit applications to 
> make use of 64bit registers without breaking the 32bit ABI. 
> I think the only target providing something like that is power
> currently.
> The problem with this is that gcc is not aware that there
> might be two different word modes one representing the actual
> register width and one to be used whenever the ABI comes into
> play. Ulrichs idea was to introduce an abi_word_mode to address
> this. As the name suggests this would be the mode to be used
> whenever a register or a register-size value is externally
> visible. For everything else word_mode is used as before.

I think you are mixing together several different concepts, observing
that on the S/390 they all have the same size, and calling that size
the ABI word mode.  It's not obvious to me that there is any relation
between the different concepts you want to address.

It's clear that gcc uses word_mode too often.  word_mode is supposed
to be the size of a general purpose register.  Using that for things
like the return mode of the compare libcall is a good guess, but that
is all it is: a guess.  (Using TYPE_MODE (integer_type_node) would
also be a good guess.)

Similarly, word_mode is a good guess for allocate_stack.  But since it
is not always right, we have STACK_SIZE_MODE.

But despite the fact that word_mode is a good guess for both the
return mode of the compare libcall and for the allocate_stack mode, I
don't see any relationship between those two things.  There is no
reason to assume that a single mode which is not word_mode will be
correct for both.  So I don't see any obvious reason why we should
remove STACK_SIZE_MODE in favor of abi_word_mode.  To me it makes more
sense to introduce COMPARE_LIBCALL_MODE (In the target structure, of

In particular, you neglected to write any documentation for
abi_word_mode, and I think you would have a hard time writing that

> 1.) The errno variable should be a signed int right?! So the use 
> of word_mode in expand_errno_check looks odd to me. 
> The patch leaves this as is.

Yes, that definitely looks wrong.  It should be TYPE_MODE
(integer_type_mode).  Worse, that code looks horribly wrong when errno
is a thread local variable in a file which did not #include <errno.h>.
Fortunately that code is pretty much never executed, since only one
target defines TARGET_EDOM.

> 2.) expand_builtin_extend_pointer currently converts a ptr_mode
> address to word_mode. Shouldn't this be Pmode?
> Thats the reason why there is a BT_WORD primitive type defined in
> builtin-types.def. The only usage of this seems to be to define
> the function type of builtin_extend_pointer. The patch replaces
> word_mode with abi_word_mode to have 32bit pointers when building
> a 32bit application even if word_mode is defined to be 64bit.

__builtin_extend_pointer appears to be undocumented and I have no
immediate idea what it is for.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]