[PATCH] arm-asm: Improve immediate error message in asm_data_processing_opcode.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] arm-asm: Improve immediate error message in asm_data_processing_opcode.

Danny Milosavljevic
---
 arm-asm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arm-asm.c b/arm-asm.c
index f392f4f..fc92898 100644
--- a/arm-asm.c
+++ b/arm-asm.c
@@ -643,6 +643,7 @@ static void asm_data_processing_opcode(TCCState *s1, int token)
                 immediate_value = ((immediate_value & 0x3FFFFFFF) << 2) | ((immediate_value & 0xC0000000) >> 30);
             }
             if (half_immediate_rotation >= 16) {
+                immediate_value = ops[2].e.v;
                 tcc_error("immediate value 0x%X cannot be encoded into ARM immediate", (unsigned) immediate_value);
                 return;
             }

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

arm-asm: Test script

Danny Milosavljevic
Updated test script for all of this (should I also commit this?  Where?):

#!/bin/sh

set -e
cd ~/src/tinycc-upstream/tinycc

cat arm-tok.h |grep DEF_ASM_CONDED |grep -v '#define' |grep -v '/[*]' |sed -e 's;DEF_ASM_CONDED.\(.*\).$;\1;'| grep -v 'not useful' >L
total_count=0

# Note: "{r3}" is definitely different--but would complicate the assembler.

for s in $(cat L)
do
        ok=0
        for args in "r3, r4, r5, r6" \
                    "r3, r4, r5" \
                    "r3, r4, r5, asl #7" \
                    "r3, r4, r5, lsl #7" \
                    "r3, r4, r5, asr #7" \
                    "r3, r4, r5, lsr #7" \
                    "r3, r4, r5, ror #7" \
                    "r3, r4, r5, rrx" \
                    "r3, r4, r5, asl r6" \
                    "r3, r4, r5, lsl r6" \
                    "r3, r4, r5, asr r6" \
                    "r3, r4, r5, lsr r6" \
                    "r3, r4, r5, ror r6" \
                    "r3, r4, #5, asl #7" \
                    "r3, r4, #5, lsl #7" \
                    "r3, r4, #5, asr #7" \
                    "r3, r4, #5, lsr #7" \
                    "r3, r4, #5, ror #7" \
                    "r3, r4, #5, rrx" \
                    "r3, #5, r4" \
                    "r3, #4, #8" \
                    "r3, r4, asl #5" \
                    "r3, r4, lsl #5" \
                    "r3, r4, asr #5" \
                    "r3, r4, lsr #5" \
                    "r3, r4, ror #5" \
                    "r3, r4, ror #8" \
                    "r3, r4, asl r5" \
                    "r3, r4, lsl r5" \
                    "r3, r4, asr r5" \
                    "r3, r4, lsr r5" \
                    "r3, r4, ror r5" \
                    "r3, r4, ror #8" \
                    "r3, r4, ror #16" \
                    "r3, r4, ror #24" \
                    "r3, r4, rrx" \
                    "r3, #4, asl #5" \
                    "r3, #4, lsl #5" \
                    "r3, #4, asr #5" \
                    "r3, #4, lsr #5" \
                    "r3, #4, ror #5" \
                    "r3, r4, rrx" \
                    "r3, r4" \
                    "r3" \
                    "{r3,r4,r5}" \
                    "{r3,r5,r4}" \
                    "r2!, {r3,r4,r5}" \
                    "r2!, {r3,r5,r4}" \
                    "r2, [r3, r4]" \
                    "r2, [r3, r4]!" \
                    "r2, [r3, -r4]" \
                    "r2, [r3, -r4]!" \
                    "r2, [r3], r4" \
                    "r2, [r3, #4]" \
                    "r2, [r3, #-4]" \
                    "r2, r3, #4" \
                    "r2, r3, #-4" \
                    "r2, #4" \
                    "r2, #-4" \
                    "r2, #0xEFFF" \
                    "r3, #0x0000" \
                    "r4, #0x0201" \
                    "r4, #0xFFFFFF00" \
                    "r2, #-4" \
                    "#4" \
                    "#-4" \
                    ""
        do
                #echo ".syntax unified" > a.s
                echo "$s $args" > a.s
                #cat a.s
                if "${CROSS_COMPILE}as" -mlittle-endian -o a.o a.s 2>err
                then
                        cat err
                        total_count=`expr $total_count + 1`
                        objdump -S a.o |grep "^[ ]*0:" >a.expected

                        echo '__asm__("'"$s ${args}"'");' > a.c
                        if ./tcc -o a.o -c a.c
                        then
                                objdump -S a.o |grep "^[ ]*0:" >a.got
                                diff -u a.got a.expected || {
                                        echo "warning: $s $args did not work in tcc (see above)">&2
                                }
                        else
                                echo "warning: $s $args did not work in tcc">&2
                        fi
                        ok=1
                fi
        done
        if [ "${ok}" -eq "0" ]
        then
                echo "warning: $s could not be used.">&2
                continue
        fi
done
echo "total count: ${total_count}">&2

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: arm-asm: Test script

Michael Matz-4
Hello,

On Sun, 3 Jan 2021, Danny Milosavljevic wrote:

> Updated test script for all of this (should I also commit this?  Where?):

Yeah, put it into tests/ I'd say.  The x86 assembler also has a little
testfile in there that isn't used by default (as it shows a few
differences between GNU as and tcc; and needs updates from time to time
to cater to stricter versions of GNU as).  Maybe you can wire it into the
existing asmtest target when $(ARCH) is arm.


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: arm-asm: Test script

Danny Milosavljevic
Hi,

On Mon, 4 Jan 2021 05:05:40 +0100 (CET)
Michael Matz <[hidden email]> wrote:

> Yeah, put it into tests/ I'd say.

Ok, I've added it as tests/arm-asm-testsuite.sh .

>  The x86 assembler also has a little
> testfile in there that isn't used by default (as it shows a few
> differences between GNU as and tcc; and needs updates from time to time
> to cater to stricter versions of GNU as).

>Maybe you can wire it into the
> existing asmtest target when $(ARCH) is arm.

Hmm, how can I get the name of the tcc executable to use for tests from
inside the shell script?  Do I just use ./tcc ?


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: arm-asm: Test script

Michael Matz-4
Hello,

On Tue, 5 Jan 2021, Danny Milosavljevic wrote:

> Hi,
>
> On Mon, 4 Jan 2021 05:05:40 +0100 (CET)
> Michael Matz <[hidden email]> wrote:
>
>> Yeah, put it into tests/ I'd say.
>
> Ok, I've added it as tests/arm-asm-testsuite.sh .
>
>>  The x86 assembler also has a little
>> testfile in there that isn't used by default (as it shows a few
>> differences between GNU as and tcc; and needs updates from time to time
>> to cater to stricter versions of GNU as).
>
>> Maybe you can wire it into the
>> existing asmtest target when $(ARCH) is arm.
>
> Hmm, how can I get the name of the tcc executable to use for tests from
> inside the shell script?  Do I just use ./tcc ?

Probably easiest to pass $(TCC) to the shell script as an argument I
guess.  It needs -B and -I flags to work correctly from uninstalled paths
and the Makefile sets that up correctly.


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: arm-asm: Test script

Danny Milosavljevic
Hello,

On Wed, 6 Jan 2021 00:07:07 +0100 (CET)
Michael Matz <[hidden email]> wrote:

> > Hmm, how can I get the name of the tcc executable to use for tests from
> > inside the shell script?  Do I just use ./tcc ?  
>
> Probably easiest to pass $(TCC) to the shell script as an argument I
> guess.  It needs -B and -I flags to work correctly from uninstalled paths
> and the Makefile sets that up correctly.

Does that mean I should use ${TCC} without quotes in the shell script?

Do I need $(TCCFLAGS), too?

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: arm-asm: Test script

Michael Matz-4
Hello,

On Wed, 6 Jan 2021, Danny Milosavljevic wrote:

> Hello,
>
> On Wed, 6 Jan 2021 00:07:07 +0100 (CET)
> Michael Matz <[hidden email]> wrote:
>
>>> Hmm, how can I get the name of the tcc executable to use for tests from
>>> inside the shell script?  Do I just use ./tcc ?
>>
>> Probably easiest to pass $(TCC) to the shell script as an argument I
>> guess.  It needs -B and -I flags to work correctly from uninstalled paths
>> and the Makefile sets that up correctly.
>
> Does that mean I should use ${TCC} without quotes in the shell script?

No, it's currently not exported from make, so not available in the
environment.  What I meant is something like this: extend the script to
take an optional compiler-with-arguments argument, so that it can be
called like:

% ./the-test-script.sh -c "../tcc -B.. -I.. -whatever-else"

and then use it with that argument in the makefile like so:

---- snip ----
mytarget: the-test-script.sh
  ./the-test-script.sh -c "$(TCC)"
---- snap ----

> Do I need $(TCCFLAGS), too?

The Makevariable $(TCC) should contain everything that's needed.
Still, even the above might be overdesigning it a bit :)
(I see you also access the tcc-tok file directly, so that might further
complicate things from the tests/ Makefile, so don't bother if that gets
you into the rabbit hole too far)


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel