Chris.Dewhurst via llvm-dev
2016-Apr-15 17:17 UTC
[llvm-dev] [Sparc] Load address with SETHI
> > Some more information on what I have so far. I'll actually focus on the longjmp side, as the problem is probably easier. > > > > I need to get the SETHI / OR combination inserted where the comment > > "*** Need to use the SETHI / OR combination here. ***" appears in the > > code below, but I'm not sure that this is done anywhere near this piece > > of code, so I'll include all the relevant parts that I can find of my > > current implementation.> I don't understand what exactly you want to materialize here. Shouldn't > the address of the buffer already be an operand at this point?> JoergQuite possibly, I've over-simplified my example. Perhaps I should have focussed more on the setjmp part, which is actually where I was coding anyway. In this, I need to store the address of the instruction after I've lowered the intrinsic into a buffer so that I can recover this and jump back to it from the longjmp intrinsic. There are two or three parts, and I'm not sure how to go about either. After I get these working, the rest is (I think) plain-sailing: (1) I need to take the address of the instruction after the lowered setjmp intrinsic, which I think requires that I create a new basic block (2) I need to get the address of this basic block, at lowering time, and get it into a register using the SETHI / OR combination (I presume). Once it's in the register, I can store it in the buffer easily. There must surely be a good way to load an address using SETHI / OR, but nothing I've tried (including "makeAddress") works so far. I guess I could code each of SETHI and OR individually, but surely there's some code around to take care of this already. (3) Is there anything else? Do I need any indicators to let the back-end know it'll need to fix-up the address taken in step (2) later in the compilation - or possibly in the link - pipeline? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160415/bb2739c9/attachment.html>
Chris.Dewhurst via llvm-dev
2016-Apr-18 15:09 UTC
[llvm-dev] [Sparc] Load address with SETHI
Hi,
Can anyone help me to fill in the missing details here please? I'm sure this
is a very short piece of code, but I can't find the right way of doing
this...
MachineBasicBlock* SparcTargetLowering::
emitEHSjLjLongJmp(MachineInstr *MI,
MachineBasicBlock *MBB) const
{
[... Code omitted for brevity]
MVT PVT = getPointerTy(MF->getDataLayout());
unsigned PtrSize = PVT.getStoreSize();
// We'll deal with 64 bit implementations when the 32 bit version is
working!
assert(PVT == MVT::i32 && "Invalid Pointer Size!");
MachineBasicBlock *jumpToMBB = MF->CreateMachineBasicBlock(BB);
MF->insert(I, mainMBB);
const TargetRegisterClass *PtrRC = getRegClassFor(PVT);
unsigned LabelReg = MRI.createVirtualRegister(PtrRC);
// Need to load the address of "jumpToMBB" into register
"LabelReg", so that
// we can then (later) store this in a buffer, to be recovered by
"longjmp" as
// the location to resume execution at (via a JMPL instruction).
// We need something like this, garnered from the PPC implementation.
// What is the equivalent code in Sparc utilizing the instructions SETHI and
OR?
MIB = BuildMI(mainMBB, DL,
TII->get(Subtarget.isPPC64() ? PPC::MFLR8 : PPC::MFLR),
LabelReg);
// ...or possibly, it should be something like this, using addMBB (I know this
isn't legal, BTW)
MIB = BuildMI(mainMBB, DL,
TII->get(SP::LDri, LabelReg).addMBB(jumpToMBB);
[... Code omitted for brevity]
}
________________________________
From: Chris.Dewhurst
Sent: 15 April 2016 18:17
To: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] [Sparc] Load address with SETHI
> > Some more information on what I have so far. I'll actually focus
on the longjmp side, as the problem is probably easier.
> >
> > I need to get the SETHI / OR combination inserted where the comment
> > "*** Need to use the SETHI / OR combination here. ***"
appears in the
> > code below, but I'm not sure that this is done anywhere near this
piece
> > of code, so I'll include all the relevant parts that I can find of
my
> > current implementation.
> I don't understand what exactly you want to materialize here.
Shouldn't
> the address of the buffer already be an operand at this point?
> Joerg
Quite possibly, I've over-simplified my example. Perhaps I should have
focussed more on the setjmp part, which is actually where I was coding anyway.
In this, I need to store the address of the instruction after I've lowered
the intrinsic into a buffer so that I can recover this and jump back to it from
the longjmp intrinsic.
There are two or three parts, and I'm not sure how to go about either. After
I get these working, the rest is (I think) plain-sailing:
(1) I need to take the address of the instruction after the lowered setjmp
intrinsic, which I think requires that I create a new basic block
(2) I need to get the address of this basic block, at lowering time, and get it
into a register using the SETHI / OR combination (I presume). Once it's in
the register, I can store it in the buffer easily. There must surely be a good
way to load an address using SETHI / OR, but nothing I've tried (including
"makeAddress") works so far. I guess I could code each of SETHI and OR
individually, but surely there's some code around to take care of this
already.
(3) Is there anything else? Do I need any indicators to let the back-end know
it'll need to fix-up the address taken in step (2) later in the compilation
- or possibly in the link - pipeline?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20160418/b0a62d0d/attachment.html>