[llvm-dev] What pattern string corresponds to CopyToReg?
Craig Topper via llvm-dev
llvm-dev at lists.llvm.org
Sat Nov 4 21:23:40 PDT 2017
Do you have a pattern for loading an i16 immediate into a 16-bit register?
~Craig
On Sat, Nov 4, 2017 at 8:00 PM, Robert Baruch <robert.c.baruch at gmail.com>
wrote:
> Hmm, okay. Then what's the problem being reported here? I'm not sure what
> I'm supposed to do with "LLVM ERROR: Cannot select: t1: i16 =
> Constant<127>".BTW, the function is:
>
> ; ModuleID = 'return.c'
> source_filename = "return.c"
> target datalayout = "E-m:e-p:16:16:16-i1:16:16-i8:
> 16:16-i16:16:16-i32:16:16-i64:16:16-S16-n16"
> target triple = "tms9900"
>
> ; Function Attrs: noinline nounwind optnone
> define signext i16 @my_func() #0 {
> entry:
> ret i16 127
> }
>
> ------- debug output --------
>
> Optimized legalized selection DAG: BB#0 'my_func:entry'
> SelectionDAG has 5 nodes:
> t0: ch = EntryToken
> t3: ch,glue = CopyToReg t0, Register:i16 %R5, Constant:i16<127>
> t4: ch = TMS9900ISD::Ret t3, Register:i16 %R5, t3:1
>
> ===== Instruction selection begins: BB#0 'entry'
> Selecting: t4: ch = TMS9900ISD::Ret t3, Register:i16 %R5, t3:1
>
> ISEL: Starting pattern match on root node: t4: ch = TMS9900ISD::Ret t3,
> Register:i16 %R5, t3:1
>
> Morphed node: t4: ch,glue = Retr Register:i16 %R5, t3
>
> ISEL: Match complete!
> Selecting: t3: ch,glue = CopyToReg t0, Register:i16 %R5, Constant:i16<127>
>
> Selecting: t2: i16 = Register %R5
>
> Selecting: t1: i16 = Constant<127>
>
> ISEL: Starting pattern match on root node: t1: i16 = Constant<127>
>
> Initial Opcode index to 0
> Match failed at index 0
> LLVM ERROR: Cannot select: t1: i16 = Constant<127>
> In function: my_func
>
>
> On Sat, Nov 4, 2017 at 7:22 PM Craig Topper <craig.topper at gmail.com>
> wrote:
>
>> CopyToReg is not handle by patterns. It should be passed through isel
>> unchanged. It’s part of a special list of ISD opcodes that don’t change in
>> SelectioDAGISel::SelectCodeCommon
>>
>> It will then be turned into a TargetOpcode::COPY in
>> InstrEmitter::EmitSpecialNode when the DAG is turned into MachineInstrs.
>>
>> On Sat, Nov 4, 2017 at 7:02 PM Robert Baruch via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>>> So there's a DAG that looks like this in the debug output:
>>>
>>> Selecting: t3: ch,glue = CopyToReg t0, Register:i16 %R5,
>>> Constant:i16<127>
>>>
>>> In the instruction selection phase, what pattern would that match? I've
>>> constructed this so far:
>>>
>>> (??? REG16:$dst, i16imm:$src)
>>>
>>> but the problem is, I can't determine what to use as ???. There is an
>>> ISD::CopyToReg enum value, but I don't know how that translates to the
>>> string to use in the pattern.
>>>
>>> And more generally, how do I find out from a DAG diagram like the ones
>>> output by -view-isel-dags which node type corresponds to which pattern
>>> string?
>>>
>>> Thanks,
>>>
>>> --Rob
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>
>> --
>> ~Craig
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171104/1d361183/attachment.html>
More information about the llvm-dev
mailing list