[LLVMdev] Branch-like intrinsic

Edward Lee edilee at gmail.com
Thu Apr 17 12:41:23 PDT 2008

On Mon, Apr 14, 2008 at 8:17 PM, Chris Lattner <sabre at nondot.org> wrote:
> On Mon, 14 Apr 2008, Edward Lee wrote:
>  > Or is there another way for me to have my intrinsic return a Value
>  > that causes the codegen to emit an unconditional jump yet keep the CFG
>  > intact?
>  No.

After thinking about it a bit more, if I choose not to Lower the
intrinsic, I can emit x86 code by changing Target/X86/...td. If I'm
understanding the codebase correctly, LLVM will basically treat the
intrinsic as a black box and emit whatever I tell it to emit.

So for "my_intrinsic : Intrinsic<llvm_i1_ty>", I can "X86Inst<bits I
want in binary>". Where bits is actually 2 x86 instructions: The
special opcode sequence I want followed by a load immediate of 1 into
the output register.

I suppose the other possibility based on Chris' suggestion is to Lower
the intrinsic and specially handle the block layout to not kill the
edge. I would then lower the intrinsic into an inline asm call for the
special opcode followed by an a ConstantInt 1. (Could I get a pointer
to a file/method to modify for block layout/CFG optimization?)


More information about the llvm-dev mailing list