[PATCH] D89108: [NFC] Add the getSize() interface for MachineConstantPoolValue

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 02:23:35 PDT 2020


steven.zhang created this revision.
steven.zhang added reviewers: nemanjai, MaskRay, echristo, RKSimon, lebedev.ri, PowerPC.
Herald added subscribers: atanasyan, jrtc27, hiraditya, sdardis.
Herald added a project: LLVM.
steven.zhang requested review of this revision.

Current implementation assumes that, each MachineConstantPoolValue takes up sizeof(MachineConstantPoolValue::Ty) bytes. For PowerPC, we want to lump all the constants with the same type as one MachineConstantPoolValue to save the cost that calculate the TOC entry for each const. So, we need to extend the MachineConstantPoolValue that break this assumption.
That is, transform:

  addis 3, 2, .LCPI0_0 at toc@ha
  lfd 0, .LCPI0_0 at toc@l(3)
  addis 3, 2, .LCPI0_1 at toc@ha
  lfd 1, .LCPI0_1 at toc@l(3)

to:

  addis 3, 2, .LC0 at toc@ha
  ld 3, .LC0 at toc@l(3)
  lfd 0, 8(3)
  lfd 1, 0(3)

And

  .LCPI0_0:
          .quad   0x40218d4fdf3b645a              # double 8.7759999999999998
  .LCPI0_1:
          .quad   0x49818d4fdf3b645a              # double 1.2525525751187504E+46

->

  .LCPI0_0:
          .quad   0x49818d4fdf3b645a              # double 1.2525525751187504E+46
          .quad   0x40218d4fdf3b645a              # double 8.7759999999999998
          .section        ".note.GNU-stack","", at progbits
          .section        .toc,"aw", at progbits
  .LC0:
          .tc .LCPI0_0[TC],.LCPI0_0

The more constants accessed, the more benefit we will have.

And this assumption also doesn't make sense to me also as we have already provided mechanism for target to customize the constant pool with MachineConstantPoolValue. We shouldn't assume its size.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89108

Files:
  llvm/include/llvm/CodeGen/MachineConstantPool.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
  llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89108.297154.patch
Type: text/x-patch
Size: 4417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201009/7b631a3f/attachment.bin>


More information about the llvm-commits mailing list