On 05/09/16 09:56, Richard Biener wrote:
> On Thu, 5 May 2016, Bernd Edlinger wrote:
>
>> Hi!
>>
>> this patch is inspired by recent discussion about basic asm:
>>
>> Currently a basic asm is an instruction scheduling barrier,
>> but not a memory barrier, and most surprising, basic asm
>> does _not_ implicitly clobber CC on targets where
>> extended asm always implicitly clobbers CC, even if
>> nothing is in the clobber section.
>>
>> This patch makes basic asm implicitly clobber CC on certain
>> targets, and makes the basic asm implicitly clobber memory,
>> but no general registers, which is what could be expected.
>>
>> This is however only done for basic asm with non-empty
>> assembler string, which is in sync with David's proposed
>> basic asm warnings patch.
>>
>> Due to the change in the tree representation, where
>> ASM_INPUT can now be the first element of a
>> PARALLEL block with the implicit clobber elements,
>> there are some changes necessary.
>>
>> Most of the changes in the middle end, were necessary
>> because extract_asm_operands can not be used to find out
>> if a PARALLEL block is an asm statement, but in most cases
>> asm_noperands can be used instead.
>>
>> There are also changes necessary in two targets: pa, and ia64.
>> I have successfully built cross-compilers for these targets.
>>
>> Boot-strapped and reg-tested on x86_64-pc-linux-gnu
>> OK for trunk?
>
> I'm generally sympathetic with the change but I wonder if it would
> make sense to re-write "basic asm" into general asms to not
> need to special case them.  I'd do that during gimplification
> for example.
>
> At least it sounds to me that its semantics can be fully expressed
> with generic asms?  (Maybe apart from the only-if-ASM_STRING-is-empty
> part)
>

That was also my first idea too.

In simple cases an asm ("whatever"); should do the same as
asm ("whatever" ::: );

Adding a "memory" to the clobber list would be simple that's true.

But in general it can be pretty complicated, especially if the
string contains the special characters % { | }.

For example asm ("#%") is OK, but asm ("#%" :) is an ERROR.
So, single % must be duplicated, that may be a general rule (hopefully).

On some targets { | } mean different things, and must be escaped,
but on other targets these must not be escaped.  So that is target
dependent.

Some targets replace whatever they want with the ASM_OUTPUT_OPCODE hook.
Example: i386 replaces "%v" with "v" or "", tilegx replaces "pseudo"
with "", this hook is only called with extended asm.  And we must know
what it does and reverse it's effect.  Here it starts to become
difficult.

And the ia64 target have different semantics for basic asm than without,
i.e. they always emit stop bits for traditional asms.  So they
make a difference between extended and basic asm.

I have really no idea how to do this when extended and basic asm have
exactly the same tree structure.

That's why I thought I can as well add the clobbers to the basic asm's
tree representation.



Thanks
Bernd.

> Thanks,
> Richard.
>

Reply via email to