[llvm-dev] MachineFunction at end of ISel taking away one operand from our custom instruction in (RISCV) LLVM backend

Reshabh Sharma via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 23 12:58:52 PDT 2019


Hello all,

Thanks for all the suggestions so far :) They were really helpful!

Brief background: We are trying to support 64 bit pointers (in address
space 1) using custom store/load instructions for an open-source RISCV
based GPGPU (bjump.org/manycore/). We aim to keep the 64 bit address into
two 32 bit register and use our custom store example CUSTOM_STORE rs rd1
rd2 where rd1 and rd2 store 32 bit address parts.

Legalizer was the main source of pain, so we are breaking the address
during legalization and replacing the store node with our custom node
during the same phase.

The DAG after ISel (and probably also after scheduling):

===== Instruction selection ends:
Selected selection DAG: %bb.0 'main:entry'
SelectionDAG has 20 nodes:
t0: ch = EntryToken
t5: i32 = ADDI Register:i32 $x0, TargetConstant:i32<87>
t15: i32 = LUI TargetGlobalAddress:i32<[1 x i32] addrspace(1)* @foo> 0
[TF=2]
t16: i32 = ADDI t15, TargetGlobalAddress:i32<[1 x i32] addrspace(1)* @foo>
0 [TF=3]
t19: i32 = LUI TargetGlobalAddress:i32<[1 x i32] addrspace(1)* @foo> 0
[TF=4]
t20: i32 = ADDI t19, TargetGlobalAddress:i32<[1 x i32] addrspace(1)* @foo>
0 [TF=1]
t4: ch = SW<Mem:(store 4 into %ir.retval)> t28, TargetFrameIndex:i32<0>,
TargetConstant:i32<0>, t0
t23: ch = CUSTOM_STORE t5, t16, t20, t4
t11: ch,glue = CopyToReg t23, Register:i32 $x10, t28
t28: i32,ch = CopyFromReg t0, Register:i32 $x0
t12: ch = PseudoRET Register:i32 $x10, t11, t11:1

But after MachineFunction at end of ISel  Machine code for function main:
IsSSA, TracksLiveness we lost the value operand from our custom store.

%0:gpr = COPY $x0
SW %0:gpr, %stack.0.retval, 0 :: (store 4 into %ir.retval)
%1:gpr = LUI target-flags(<unknown>) @foo
%2:gpr = ADDI killed %1:gpr, target-flags(<unknown>) @foo
%3:gpr = LUI target-flags(<unknown>) @foo
%4:gpr = ADDI killed %3:gpr, target-flags(<unknown>) @foo
%5:gpr = ADDI $x0, 87
CUSTOM_STORE killed %4:gpr, killed %2:gpr
$x10 = COPY %0:gpr
PseudoRET implicit $x10

I could not understand why t23: ch = CUSTOM_STORE t5, t16, t20, t4 was
converted into CUSTOM_STORE killed %4:gpr, killed %2:gpr. We expect it to
be CUSTOM_STORE %5:gpr, killed %4:gpr, killed %2:gpr

Many thanks,
Reshabh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190724/12b3694a/attachment.html>


More information about the llvm-dev mailing list