Ada support for llvm-gcc4

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

Ada support for llvm-gcc4

Duncan Sands
I'm trying to get the Ada gcc front-end to work with LLVM.
This series of patches gets things to the point where the
Ada compiler builds, though it fails to build itself or the
runtime.  While I was there I resurrected fortran and
java: as with Ada, the compilers build but not the runtimes.
Also, I've replaced the gcc 4.0 Ada front-end with a back-port
of the Ada front-end from FSF gcc head, since the 4.0 version
is known to be weak.

All testing done on x86-linux-gnu.  No attempt was made to build
for other targets.

Patch description:

1-usehooks.diff
        Apple made some backend changes that assume a C-like
front-end (C, C++ or ObjC): calls are made to decl_constant_value,
iasm_build_bracket and similar routines that mostly aren't defined
by the Ada, fortran and java front-ends.  However two of the calls,
to c_common_type_for_mode and pushdecl, could equivalently be made
to a langhook.  This patch switches these to langhook calls.

2-stubs.diff
        This adds a new file that provides dummy implementations
for all the routines mentioned in (1) that can't be turned into
langhook calls.  Putting these in one place means that Ada, java
and fortran can be made to compile by simply linking with this
file, and no longer need to individually define dummy routines.
I made the dummys be weak symbols because java does define some
of them.

3-fortran.diff
        Get fortran to compile: use the common stubs and rip out
the incomplete collection of dummy routines someone already put in.
With this patch, the fortran build dies at this point:

cc1: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:367: void llvm::ScheduleDAG::AddOperand(llvm:
:MachineInstr*, llvm::SDOperand, unsigned int, const llvm::TargetInstrDescriptor*, std::map<llvm::SDNode*, unsign
ed int, std::less<llvm::SDNode*>, std::allocator<std::pair<llvm::SDNode* const, unsigned int> > >&): Assertion `R
egMap->getRegClass(VReg) == RC && "Register class of operand and regclass of use don't agree!"' failed.
../../../gcc.llvm.master/libgfortran/runtime/environ.c:619: internal compiler error: Aborted


4-java.diff
        Get java to compile: use the common stubs and rip out
the incomplete collection of dummy routines someone already put in.
With this patch, the java build dies at this point:
libffi/src/x86/ffi.c: In function 'ffi_prep_cif_machdep':
libffi/src/x86/ffi.c:130: error: duplicate case value
libffi/src/x86/ffi.c:129: error: previously used here

5-ada-4.3.diff
        Replace the ada subdirectory with the one from gcc 4.3.
I haven't attached this patch to the email, since even compressed
it weighs in at 2.5MB.  If it is agreed that this patch series should
go in, I will mail it to the appropriate person.

The remaining patches make the adjustments needed to get the 4.3 Ada
front-end working with the 4.0 infrastructure and with LLVM.

6-build.diff
        Ada Makefile fixes.

7-vec.diff
        Ada fixes due to VEC changes.

8-langhooks.diff
        Ada fixes due to langhook changes.

9-misc.diff
        Grab-bag of small Ada fixes.

10-fold_build2.diff
        Convert fold_build2 to fold+build2.

11-tree_invariant.diff
        Backport recompute_tree_invariant_for_addr_expr from 4.3.

12-optimize.diff
        The Ada front-end makes use of the optimization level (-O1 etc),
however the level is not available in gcc-llvm4.  Pretend the optimization
level is 2, until a better solution is found.

13-optabs.diff
        Remove all uses of optabs by Ada.  These seem to be left-over from
older gcc versions: while optabs are initialized, they are not actually
used.

14-decl_rtl.diff
        Use the LLVM version of make_decl_rtl when compiling for LLVM.

15-gimplifier.diff
        Backport some gimplifier fixes from 4.3.  These almost certainly
will have no effect on languages other than Ada.

With these patches, the Ada build dies at this point:
Unhandled expression!
 <floor_mod_expr 0x40310c08...

The Ada bootstrap dies at this point:
 <view_convert_expr 0x403c6320...
llvm-convert.cpp:4248: static llvm::Constant* TreeConstantToLLVM::Convert(tree_node*): Assertion `0 && "Unknown constant to convert!"' failed.


Enjoy!

Duncan.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

1-usehooks.diff (732 bytes) Download Attachment
2-stubs.diff (4K) Download Attachment
3-fortran.diff (2K) Download Attachment
4-java.diff (1K) Download Attachment
6-build.diff (8K) Download Attachment
7-vec.diff (6K) Download Attachment
8-langhooks.diff (2K) Download Attachment
9-misc.diff (4K) Download Attachment
10-fold_build2.diff (1K) Download Attachment
11-tree_invariant.diff (3K) Download Attachment
12-optimize.diff (1003 bytes) Download Attachment
13-optabs.diff (6K) Download Attachment
14-decl_rtl.diff (653 bytes) Download Attachment
15-gimplifier.diff (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Ada support for llvm-gcc4

Vikram S. Adve
Duncan,

It would be useful to know what motivated this work -- in particular, is some organization (company, open source project team, research group, any other kind) interested in having an Ada front-end?  Thanks,

--Vikram

----------------------------------------------------------------------
VIKRAM S. ADVE
Associate Professor, Computer Science       E-MAIL: [hidden email]
Siebel Center for Computer Science             PHONE:  (217) 244-2016
Univ. of Illinois at Urbana-Champaign          FAX:    (217) 265-6582
201 N. Goodwin Ave.                     http://www.cs.uiuc.edu/~vadve
Urbana IL 61801-2302.                        http://llvm.cs.uiuc.edu/
----------------------------------------------------------------------




On Jan 11, 2007, at 11:43 AM, Duncan Sands wrote:

I'm trying to get the Ada gcc front-end to work with LLVM.
This series of patches gets things to the point where the
Ada compiler builds, though it fails to build itself or the
runtime.  While I was there I resurrected fortran and
java: as with Ada, the compilers build but not the runtimes.
Also, I've replaced the gcc 4.0 Ada front-end with a back-port
of the Ada front-end from FSF gcc head, since the 4.0 version
is known to be weak.

All testing done on x86-linux-gnu.  No attempt was made to build
for other targets.

Patch description:

1-usehooks.diff
Apple made some backend changes that assume a C-like
front-end (C, C++ or ObjC): calls are made to decl_constant_value,
iasm_build_bracket and similar routines that mostly aren't defined
by the Ada, fortran and java front-ends.  However two of the calls,
to c_common_type_for_mode and pushdecl, could equivalently be made
to a langhook.  This patch switches these to langhook calls.

2-stubs.diff
This adds a new file that provides dummy implementations
for all the routines mentioned in (1) that can't be turned into
langhook calls.  Putting these in one place means that Ada, java
and fortran can be made to compile by simply linking with this
file, and no longer need to individually define dummy routines.
I made the dummys be weak symbols because java does define some
of them.

3-fortran.diff
Get fortran to compile: use the common stubs and rip out
the incomplete collection of dummy routines someone already put in.
With this patch, the fortran build dies at this point:

cc1: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:367: void llvm::ScheduleDAG::AddOperand(llvm:
:MachineInstr*, llvm::SDOperand, unsigned int, const llvm::TargetInstrDescriptor*, std::map<llvm::SDNode*, unsign
ed int, std::less<llvm::SDNode*>, std::allocator<std::pair<llvm::SDNode* const, unsigned int> > >&): Assertion `R
egMap->getRegClass(VReg) == RC && "Register class of operand and regclass of use don't agree!"' failed.
../../../gcc.llvm.master/libgfortran/runtime/environ.c:619: internal compiler error: Aborted


4-java.diff
Get java to compile: use the common stubs and rip out
the incomplete collection of dummy routines someone already put in.
With this patch, the java build dies at this point:
libffi/src/x86/ffi.c: In function 'ffi_prep_cif_machdep':
libffi/src/x86/ffi.c:130: error: duplicate case value
libffi/src/x86/ffi.c:129: error: previously used here

5-ada-4.3.diff
Replace the ada subdirectory with the one from gcc 4.3.
I haven't attached this patch to the email, since even compressed
it weighs in at 2.5MB.  If it is agreed that this patch series should
go in, I will mail it to the appropriate person.

The remaining patches make the adjustments needed to get the 4.3 Ada
front-end working with the 4.0 infrastructure and with LLVM.

6-build.diff
Ada Makefile fixes.

7-vec.diff
Ada fixes due to VEC changes.

8-langhooks.diff
Ada fixes due to langhook changes.

9-misc.diff
Grab-bag of small Ada fixes.

10-fold_build2.diff
Convert fold_build2 to fold+build2.

11-tree_invariant.diff
Backport recompute_tree_invariant_for_addr_expr from 4.3.

12-optimize.diff
The Ada front-end makes use of the optimization level (-O1 etc),
however the level is not available in gcc-llvm4.  Pretend the optimization
level is 2, until a better solution is found.

13-optabs.diff
Remove all uses of optabs by Ada.  These seem to be left-over from
older gcc versions: while optabs are initialized, they are not actually
used.

14-decl_rtl.diff
Use the LLVM version of make_decl_rtl when compiling for LLVM.

15-gimplifier.diff
Backport some gimplifier fixes from 4.3.  These almost certainly
will have no effect on languages other than Ada.

With these patches, the Ada build dies at this point:
Unhandled expression!
 <floor_mod_expr 0x40310c08...

The Ada bootstrap dies at this point:
 <view_convert_expr 0x403c6320...
llvm-convert.cpp:4248: static llvm::Constant* TreeConstantToLLVM::Convert(tree_node*): Assertion `0 && "Unknown constant to convert!"' failed.


Enjoy!

Duncan.
<1-usehooks.diff>
<2-stubs.diff>
<3-fortran.diff>
<4-java.diff>
<6-build.diff>
<7-vec.diff>
<8-langhooks.diff>
<9-misc.diff>
<10-fold_build2.diff>
<11-tree_invariant.diff>
<12-optimize.diff>
<13-optabs.diff>
<14-decl_rtl.diff>
<15-gimplifier.diff>
_______________________________________________
LLVM Developers mailing list


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Ada support for llvm-gcc4

Anton Korobeynikov
In reply to this post by Duncan Sands
Hello, Duncan.

> 3-fortran.diff
> Get fortran to compile: use the common stubs and rip out
> the incomplete collection of dummy routines someone already put in.
> With this patch, the fortran build dies at this point:
>
> cc1: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:367: void llvm::ScheduleDAG::AddOperand(llvm:
> :MachineInstr*, llvm::SDOperand, unsigned int, const llvm::TargetInstrDescriptor*, std::map<llvm::SDNode*, unsign
> ed int, std::less<llvm::SDNode*>, std::allocator<std::pair<llvm::SDNode* const, unsigned int> > >&): Assertion `R
> egMap->getRegClass(VReg) == RC && "Register class of operand and regclass of use don't agree!"' failed.
> ./../../gcc.llvm.master/libgfortran/runtime/environ.c:619: internal compiler error: Aborted
This looks like PR879. Will you try to build with -D__NO_MATH_INLINES and check, whether the assertion still exists?

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Ada support for llvm-gcc4

Duncan Sands
In reply to this post by Vikram S. Adve
> It would be useful to know what motivated this work -- in particular,  
> is some organization (company, open source project team, research  
> group, any other kind) interested in having an Ada front-end?  Thanks,

Hi Vikram, I'm doing this on my own time, for fun.  If, however, it proves
to be successful, I suppose ACT (Ada Core Technologies, the company that
maintains the Ada front-end) might become interested (they have already
ported the Ada front-end to a number of different backends, most recently
.net).  A number of open-source Ada guys I know have expressed an interest
in playing with it.  And lurking around in the back of my mind is the
possibility that my own company (which has a lot of Ada code) might find
it useful.  But for the moment I'm just testing the water.

Best wishes,

Duncan.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Ada support for llvm-gcc4

Duncan Sands
In reply to this post by Anton Korobeynikov
Hi Anton,

> > 3-fortran.diff
> > Get fortran to compile: use the common stubs and rip out
> > the incomplete collection of dummy routines someone already put in.
> > With this patch, the fortran build dies at this point:
> >
> > cc1: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:367: void llvm::ScheduleDAG::AddOperand(llvm:
> > :MachineInstr*, llvm::SDOperand, unsigned int, const llvm::TargetInstrDescriptor*, std::map<llvm::SDNode*, unsign
> > ed int, std::less<llvm::SDNode*>, std::allocator<std::pair<llvm::SDNode* const, unsigned int> > >&): Assertion `R
> > egMap->getRegClass(VReg) == RC && "Register class of operand and regclass of use don't agree!"' failed.
> > ./../../gcc.llvm.master/libgfortran/runtime/environ.c:619: internal compiler error: Aborted
> This looks like PR879. Will you try to build with -D__NO_MATH_INLINES and check, whether the assertion still exists?

you are right: a build with -D__NO_MATH_INLINES does not trigger that assertion.
Instead it triggers this one later on:

llvm-convert.cpp:4243: static llvm::Constant* TreeConstantToLLVM::Convert(tree_node*):
        Assertion `((__extension__ ({ const tree __t = (exp); char const __c = tree_code_type[(int)
        (((enum tree_code) (__t)->common.code))]; if (!((__c) != tcc_type)) tree_class_check_failed
        (__t, tcc_type, "../../gcc.llvm.master/gcc/llvm-convert.cpp", 4243, __FUNCTION__); __t; })
        ->common.constant_flag) || ((enum tree_code) (exp)->common.code) == STRING_CST) &&
        "Isn't a constant!"' failed.

libgfortran/intrinsics/selected_int_kind.f90: In function 'selected_int_kind':
libgfortran/intrinsics/selected_int_kind.f90:22: internal compiler error: Aborted

Best wishes,

Duncan.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Ada support for llvm-gcc4

Chris Lattner
In reply to this post by Duncan Sands
On Thu, 11 Jan 2007, Duncan Sands wrote:
> I'm trying to get the Ada gcc front-end to work with LLVM.
> This series of patches gets things to the point where the
> Ada compiler builds, though it fails to build itself or the
> runtime.  While I was there I resurrected fortran and
> java: as with Ada, the compilers build but not the runtimes.
> Also, I've replaced the gcc 4.0 Ada front-end with a back-port
> of the Ada front-end from FSF gcc head, since the 4.0 version
> is known to be weak.

Cool.  Can you post these patches individually to llvm-commits in an order
that is easiest to review?  For example, obvious makefile changes and
target independent things we can apply now.  Replacing the entire Ada
front-end should wait until it works better.

Nice work,

-Chris

> All testing done on x86-linux-gnu.  No attempt was made to build
> for other targets.
>
> Patch description:
>
> 1-usehooks.diff
> Apple made some backend changes that assume a C-like
> front-end (C, C++ or ObjC): calls are made to decl_constant_value,
> iasm_build_bracket and similar routines that mostly aren't defined
> by the Ada, fortran and java front-ends.  However two of the calls,
> to c_common_type_for_mode and pushdecl, could equivalently be made
> to a langhook.  This patch switches these to langhook calls.
>
> 2-stubs.diff
> This adds a new file that provides dummy implementations
> for all the routines mentioned in (1) that can't be turned into
> langhook calls.  Putting these in one place means that Ada, java
> and fortran can be made to compile by simply linking with this
> file, and no longer need to individually define dummy routines.
> I made the dummys be weak symbols because java does define some
> of them.
>
> 3-fortran.diff
> Get fortran to compile: use the common stubs and rip out
> the incomplete collection of dummy routines someone already put in.
> With this patch, the fortran build dies at this point:
>
> cc1: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:367: void llvm::ScheduleDAG::AddOperand(llvm:
> :MachineInstr*, llvm::SDOperand, unsigned int, const llvm::TargetInstrDescriptor*, std::map<llvm::SDNode*, unsign
> ed int, std::less<llvm::SDNode*>, std::allocator<std::pair<llvm::SDNode* const, unsigned int> > >&): Assertion `R
> egMap->getRegClass(VReg) == RC && "Register class of operand and regclass of use don't agree!"' failed.
> ../../../gcc.llvm.master/libgfortran/runtime/environ.c:619: internal compiler error: Aborted
>
>
> 4-java.diff
> Get java to compile: use the common stubs and rip out
> the incomplete collection of dummy routines someone already put in.
> With this patch, the java build dies at this point:
> libffi/src/x86/ffi.c: In function 'ffi_prep_cif_machdep':
> libffi/src/x86/ffi.c:130: error: duplicate case value
> libffi/src/x86/ffi.c:129: error: previously used here
>
> 5-ada-4.3.diff
> Replace the ada subdirectory with the one from gcc 4.3.
> I haven't attached this patch to the email, since even compressed
> it weighs in at 2.5MB.  If it is agreed that this patch series should
> go in, I will mail it to the appropriate person.
>
> The remaining patches make the adjustments needed to get the 4.3 Ada
> front-end working with the 4.0 infrastructure and with LLVM.
>
> 6-build.diff
> Ada Makefile fixes.
>
> 7-vec.diff
> Ada fixes due to VEC changes.
>
> 8-langhooks.diff
> Ada fixes due to langhook changes.
>
> 9-misc.diff
> Grab-bag of small Ada fixes.
>
> 10-fold_build2.diff
> Convert fold_build2 to fold+build2.
>
> 11-tree_invariant.diff
> Backport recompute_tree_invariant_for_addr_expr from 4.3.
>
> 12-optimize.diff
> The Ada front-end makes use of the optimization level (-O1 etc),
> however the level is not available in gcc-llvm4.  Pretend the optimization
> level is 2, until a better solution is found.
>
> 13-optabs.diff
> Remove all uses of optabs by Ada.  These seem to be left-over from
> older gcc versions: while optabs are initialized, they are not actually
> used.
>
> 14-decl_rtl.diff
> Use the LLVM version of make_decl_rtl when compiling for LLVM.
>
> 15-gimplifier.diff
> Backport some gimplifier fixes from 4.3.  These almost certainly
> will have no effect on languages other than Ada.
>
> With these patches, the Ada build dies at this point:
> Unhandled expression!
> <floor_mod_expr 0x40310c08...
>
> The Ada bootstrap dies at this point:
> <view_convert_expr 0x403c6320...
> llvm-convert.cpp:4248: static llvm::Constant* TreeConstantToLLVM::Convert(tree_node*): Assertion `0 && "Unknown constant to convert!"' failed.
>
>
> Enjoy!
>
> Duncan.
>

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev