Implementing llvm.memory.barrier on PowerPC

Hi all,

I want to implement llvm.memory.barrier on PowerPC. The
implementation would be the single instruction "sync", but
currently it's defined with:

setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand)

in lib/Target/PowerPC/PPCISelLowering.cpp, which causes it
to be a noop. I replaced the "Expand" with "Legal" in the
hope I'd get an error message that'd point me to where I
need to start adding stuff, but I just got the cryptic:

  Cannot yet select: 0x10fc0500: ch = MemBarrier 0x10fc0368, 0x10fc0698, 0x10fc0610, 0x10fc0698, 0x10fc0698, 0x10fc0698".

Can anyone point me in the right direction?

Cheers,
Gary

Hi Gary,

You're probably missing the required recipe in the .td file. Look at the documentation for tablegen and maybe try to find some examples to copy.

Good luck!

-bw

Hi all,

I want to implement llvm.memory.barrier on PowerPC. The
implementation would be the single instruction "sync", but
currently it's defined with:

setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand)

in lib/Target/PowerPC/PPCISelLowering.cpp, which causes it
to be a noop. I replaced the "Expand" with "Legal" in the

That's not necessary. You can just remove this line. The default action is "legal".

hope I'd get an error message that'd point me to where I
need to start adding stuff, but I just got the cryptic:

Cannot yet select: 0x10fc0500: ch = MemBarrier 0x10fc0368, 0x10fc0698, 0x10fc0610, 0x10fc0698, 0x10fc0698, 0x10fc0698".

Can anyone point me in the right direction?

You need to add a pattern to match "membarrier" (see Target/TargetSelectionDAG.td) to the right target instruction(s) in PPCInstrInfo.td. You can take a look at the examples in X86InstrSSE.td.

Evan