Jim Grosbach
2012-May-10 18:39 UTC
[LLVMdev] Inserting a branch in PPCTargetLowering::LowerFormalArguments_SVR4
Hi Hal, For lowering code that requires inserting branches, you need to use a custom inserter, yes. Theoretically, that does indeed sound like what you want to do here. It's complicated by the general structure of argument passing, though. In particular, there's lots of assumptions about the call sequence stuff. I don't know if things are smart enough (EH in particular worries me) to handle this sort of thing. On the plus side, there are copious assert() bits in there to catch it if the compiler gets itself confused, so you should know sooner rather than later if something goes wonky. -Jim On May 10, 2012, at 11:25 AM, Hal Finkel <hfinkel at anl.gov> wrote:> I hate to be bothersome, but can someone please comment on this? > > Thanks again, > Hal > > On Thu, 3 May 2012 14:49:04 -0500 > Hal Finkel <hfinkel at anl.gov> wrote: > >> Hello, >> >> The current code in PPCTargetLowering::LowerFormalArguments_SVR4 >> contains a FIXME over the code which saves the live floating-point >> registers to the stack. The FIXME states that this should only be done >> if CR bit 6 is set. I've been told that the lack of this check is >> preventing clang/LLVM from compiling a functional FreeBSD kernel on >> PPC. >> >> Is is possible to insert another branch in LowerFormalArguments? Some >> of the atomic instructions insert branches, but those are handled in >> EmitInstrWithCustomInserter. Can branches be inserted inside >> LowerFormalArguments in the same way? >> >> Thanks in advance, >> Hal >> > > > > -- > Hal Finkel > Postdoctoral Appointee > Leadership Computing Facility > Argonne National Laboratory > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hal Finkel
2012-May-10 19:16 UTC
[LLVMdev] Inserting a branch in PPCTargetLowering::LowerFormalArguments_SVR4
Jim, Thanks! Might it be possible to do this another way? For example, could I insert some special pseudo-instructions and then turn them into branches later on? -Hal On Thu, 10 May 2012 11:39:10 -0700 Jim Grosbach <grosbach at apple.com> wrote:> Hi Hal, > > For lowering code that requires inserting branches, you need to use a > custom inserter, yes. Theoretically, that does indeed sound like what > you want to do here. > > It's complicated by the general structure of argument passing, > though. In particular, there's lots of assumptions about the call > sequence stuff. I don't know if things are smart enough (EH in > particular worries me) to handle this sort of thing. On the plus > side, there are copious assert() bits in there to catch it if the > compiler gets itself confused, so you should know sooner rather than > later if something goes wonky. > > -Jim > > On May 10, 2012, at 11:25 AM, Hal Finkel <hfinkel at anl.gov> wrote: > > > I hate to be bothersome, but can someone please comment on this? > > > > Thanks again, > > Hal > > > > On Thu, 3 May 2012 14:49:04 -0500 > > Hal Finkel <hfinkel at anl.gov> wrote: > > > >> Hello, > >> > >> The current code in PPCTargetLowering::LowerFormalArguments_SVR4 > >> contains a FIXME over the code which saves the live floating-point > >> registers to the stack. The FIXME states that this should only be > >> done if CR bit 6 is set. I've been told that the lack of this > >> check is preventing clang/LLVM from compiling a functional FreeBSD > >> kernel on PPC. > >> > >> Is is possible to insert another branch in LowerFormalArguments? > >> Some of the atomic instructions insert branches, but those are > >> handled in EmitInstrWithCustomInserter. Can branches be inserted > >> inside LowerFormalArguments in the same way? > >> > >> Thanks in advance, > >> Hal > >> > > > > > > > > -- > > Hal Finkel > > Postdoctoral Appointee > > Leadership Computing Facility > > Argonne National Laboratory > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Postdoctoral Appointee Leadership Computing Facility Argonne National Laboratory
Jim Grosbach
2012-May-10 19:34 UTC
[LLVMdev] Inserting a branch in PPCTargetLowering::LowerFormalArguments_SVR4
Hi Hal, Yes, you could definitely expand them later. Custom inserters are effectively just a very early expand pseudo instruction. You can even expand them very late in the MC lowering (asmprinter) if you really need to. That could get tricky, as you'll effectively be fibbing to the register allocator. ARM uses quite a lot of late expanded pseudo-instructions, for example, though generally not w/ branching involved, so the regalloc implications are more easily modeled.>From the context, I gather that CR6 changes state dynamically over the course of a program's execution? It's not a compile time determinable thing? If it were compile time, you could deal with this as a different calling convention instead, which changes which regs are call clobbered vs. call preserved. Sounds like this is more complicated than that, though.-Jim On May 10, 2012, at 12:16 PM, Hal Finkel <hfinkel at anl.gov> wrote:> Jim, > > Thanks! Might it be possible to do this another way? For example, could > I insert some special pseudo-instructions and then turn them into > branches later on? > > -Hal > > On Thu, 10 May 2012 11:39:10 -0700 > Jim Grosbach <grosbach at apple.com> wrote: > >> Hi Hal, >> >> For lowering code that requires inserting branches, you need to use a >> custom inserter, yes. Theoretically, that does indeed sound like what >> you want to do here. >> >> It's complicated by the general structure of argument passing, >> though. In particular, there's lots of assumptions about the call >> sequence stuff. I don't know if things are smart enough (EH in >> particular worries me) to handle this sort of thing. On the plus >> side, there are copious assert() bits in there to catch it if the >> compiler gets itself confused, so you should know sooner rather than >> later if something goes wonky. >> >> -Jim >> >> On May 10, 2012, at 11:25 AM, Hal Finkel <hfinkel at anl.gov> wrote: >> >>> I hate to be bothersome, but can someone please comment on this? >>> >>> Thanks again, >>> Hal >>> >>> On Thu, 3 May 2012 14:49:04 -0500 >>> Hal Finkel <hfinkel at anl.gov> wrote: >>> >>>> Hello, >>>> >>>> The current code in PPCTargetLowering::LowerFormalArguments_SVR4 >>>> contains a FIXME over the code which saves the live floating-point >>>> registers to the stack. The FIXME states that this should only be >>>> done if CR bit 6 is set. I've been told that the lack of this >>>> check is preventing clang/LLVM from compiling a functional FreeBSD >>>> kernel on PPC. >>>> >>>> Is is possible to insert another branch in LowerFormalArguments? >>>> Some of the atomic instructions insert branches, but those are >>>> handled in EmitInstrWithCustomInserter. Can branches be inserted >>>> inside LowerFormalArguments in the same way? >>>> >>>> Thanks in advance, >>>> Hal >>>> >>> >>> >>> >>> -- >>> Hal Finkel >>> Postdoctoral Appointee >>> Leadership Computing Facility >>> Argonne National Laboratory >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > > > -- > Hal Finkel > Postdoctoral Appointee > Leadership Computing Facility > Argonne National Laboratory
Maybe Matching Threads
- [LLVMdev] Inserting a branch in PPCTargetLowering::LowerFormalArguments_SVR4
- [LLVMdev] Inserting a branch in PPCTargetLowering::LowerFormalArguments_SVR4
- [LLVMdev] Inserting a branch in PPCTargetLowering::LowerFormalArguments_SVR4
- [LLVMdev] Inserting a branch in PPCTargetLowering::LowerFormalArguments_SVR4
- [LLVMdev] making a copy of a byval aggregate on the callee's frame