Re: New backend

BERTRAND Joël via Gcc-help <[email protected]> Wed, 31 Dec 2025 16:15:31 +0100
Newsgroups gmane.comp.gcc.help
Message-ID <[email protected]>
Segher Boessenkool a écrit :
> Hi!
> 
> On Wed, Dec 31, 2025 at 11:02:41AM +0100, BERTRAND Joël wrote:
>> Segher Boessenkool a écrit :
>>> On Tue, Dec 30, 2025 at 01:52:09PM +0100, BERTRAND Joël via Gcc-help wrote:
>>>> 	As it's the first time I'm trying to add a backend, I suppose I have
>>>> done a mistake. Help will be welcome.
>>>
>>> You get the errors
>>>
>>>> genautomata: unit `m6809' is not used
>>>> genautomata: unit `m6309' is not used
>>>
>>> and that is indeed true: you have define_unit's, but nothing actually
>>> uses those units, so nthe builld system thinks that perhaps you typoed
>>> things.  Either actually use the units, or remove the define_unit's
>>> (well, you probably don't really want the delete it, but you can comment
>>> it out for now?)
>>
>> 	Thanks for your answer. I have continued to learn gcc internal but it's
>> very cryptic.
>>
>> 	As I obtain errors or segmentation fault, I have tried in a first time
>> to port gcc/config/m6809 from gcc 4.3 to 15.2.
> 
> Wow, 4.3 is 18 years old now :-)

	Isn't it ? ;-)

>> Of course, build process
>> returns a lot of errors. I have fixed a lot of errors but some poisoned
>> defineds resist.
>>
>> 	RETURN_POPS_ARGS
> 
> This was converted to a target hook, so, a function instead of a C
> preprocessor macro, in 2003 or so.
> 
>> 	FUNCTION_ARG_ADVANCE
>> 	FUNCTION_ARG
>> 	TRAMPOLINE_TEMPLATE
>> 	INITIALIZE_TRAMPOLINE
>> 	LEGITIMATE_CONSTANT_P
>> 	LEGITIMIZE_ADDRESS
>> 	GO_IF_MODE_DEPENDENT_ADDRESS
>> 	FIXUNS_TRUNC_LIKE_FIX_TRUNC
>> 	FLOAT_TYPE_SIZE
>> 	TRULY_NOOP_TRUNCATION
>> 	NOTICE_UPDATE_CC
>>
>> 	I can send a tarball (63 KB) but is there somewhere a document to port
>> a backend from gcc 4.3 to recent gcc ?
> 
> I would do this in smaller steps, so, first, port from 4.3 to 4.7 or so
> (that's 4 years of new stuff and changes), and then 6.1, and then 10.1
> maybe, 14.1, and then trunk (I'd not try to make any specific release
> work, just trunk).

	I have modified some pieces of code. Only RETURN_POPS_ARGS is for me
crytic. In a first time, I have commented out this macro that only
returns 0.

	NOTICE_UPDATE_CC asks a lot of modifications in m6809.md (cc0 has to be
replaced by REG:CC HARD_CC_REGNUM.

	Now build crashes with following error :

build/genconditions ../../gcc-15.2.0/gcc/common.md
../../gcc-15.2.0/gcc/config/m6809/m6809.md > tmp-condmd.cc
/bin/bash ../../gcc-15.2.0/gcc/../move-if-change tmp-condmd.cc
build/gencondmd.cc
echo timestamp > s-conditions
build/genpreds -c ../../gcc-15.2.0/gcc/common.md
../../gcc-15.2.0/gcc/config/m6809/m6809.md > tmp-constrs.h
/bin/bash ../../gcc-15.2.0/gcc/../move-if-change tmp-constrs.h tm-constrs.h
echo timestamp > s-constrs-h
g++ -c   -g -O2     -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall
-Wno-error=narrowing -Wwrite-strings -Wcast-qual
-Wmissing-format-attribute -Wconditionally-supported
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings  -DHAVE_CONFIG_H  -DGENERATOR_FILE -I. -Ibuild
-I../../gcc-15.2.0/gcc -I../../gcc-15.2.0/gcc/build
-I../../gcc-15.2.0/gcc/../include
-I../../gcc-15.2.0/gcc/../libcpp/include  \
        -o build/gencondmd.o build/gencondmd.cc
../../gcc-15.2.0/gcc/config/m6809/m6809.md:2350:22: error:
‘power_of_two_p’ was not declared in this scope
 2350 |   "reload_completed && power_of_two_p (INTVAL (operands[1]) + 1)"
      |                      ^~~~~~~~~~~~~~
../../gcc-15.2.0/gcc/config/m6809/m6809.md:2350:22: error:
‘power_of_two_p’ was not declared in this scope
 2350 |   "reload_completed && power_of_two_p (INTVAL (operands[1]) + 1)"
      |                      ^~~~~~~~~~~~~~
../../gcc-15.2.0/gcc/config/m6809/m6809.md:1620:2: error:
‘far_functionp’ was not declared in this scope; did you mean
‘leaf_function_p’?
 1620 |   "far_functionp (operands[0])"
      |  ^~~~~~~~~~~~~
      |  leaf_function_p
../../gcc-15.2.0/gcc/config/m6809/m6809.md:1620:2: error:
‘far_functionp’ was not declared in this scope; did you mean
‘leaf_function_p’?
 1620 |   "far_functionp (operands[0])"
      |  ^~~~~~~~~~~~~
      |  leaf_function_p
../../gcc-15.2.0/gcc/config/m6809/m6809.md:2064:2: error:
‘m6809_match_peephole’ was not declared in this scope
 2064 |   "m6809_match_peephole2 (PEEP_LSRB_ADCB, PEEP_END)"
      |  ^~~~~~~~~~~~~~~~~~~~~
../../gcc-15.2.0/gcc/config/m6809/m6809.md:2064:2: error:
‘m6809_match_peephole’ was not declared in this scope
 2064 |   "m6809_match_peephole2 (PEEP_LSRB_ADCB, PEEP_END)"
      |  ^~~~~~~~~~~~~~~~~~~~~
../../gcc-15.2.0/gcc/config/m6809/m6809.md:2213:2: error:
‘m6809_match_peephole’ was not declared in this scope
 2213 |   "m6809_match_peephole2 (PEEP_DEC_IMPLIES_CC, PEEP_END)"
      |  ^~~~~~~~~~~~~~~~~~~~~
../../gcc-15.2.0/gcc/config/m6809/m6809.md:2213:2: error:
‘m6809_match_peephole’ was not declared in this scope
 2213 |   "m6809_match_peephole2 (PEEP_DEC_IMPLIES_CC, PEEP_END)"
      |  ^~~~~~~~~~~~~~~~~~~~~
../../gcc-15.2.0/gcc/config/m6809/m6809.md:2292:22: error:
‘m6809_match_peephole2’ was not declared in this scope

	Of courses, these functions were defined in m6809.cc. I suppose I have
forgotten something.

	To be continued.

	Regards,

	JB
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQQj8MW8iOsC2RXEznnFW/s/mMLXCAUCaVU+FAAKCRDFW/s/mMLX
CKqkAP0Z1D76s5zuqHT3p3SMIpKzSdev1uKF7aRWNo1opeG9IQEAqr1BOmkLCwQu
5jxKz4wQYaj8q7N4KsJvOudoeQg5xAs=
=UnwE
-----END PGP SIGNATURE-----