[PATCH] D45067: [GISel] Refactor MachineIRBuilder so we can optionally do constant folding/other transformations during building

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 29 15:45:37 PDT 2018


aditya_nandakumar created this revision.
aditya_nandakumar added reviewers: volkan, qcolombet, dsanders, bogner, aemerson, rovka.

This change attempts to do two things:

1. It separates out the state that is stored in the MachineIRBuilder (insertion point, MF, MRI, InsertFunction etc.) into a separate object called MachineIRBuilderState.
2. Add the ability to constant fold operations while building instructions (optionally). MachineIRBuilder is now refactored into a MachineIRBuilderBase which contains lots of non foldable build methods and their implementation. Instructions which can be constant folded/transformed are now in a class called FoldableInstructionBuilder which uses CRTP to use the implementation of the derived class for buildBinaryOps. Additionally buildInstr in the derived class can be used to implement other kinds of transformations.

MachineIRBuilder currently does no transformations where as ConstantFoldingMachineIRBuilder does constant folding (as used in the unit test).


Repository:
  rL LLVM

https://reviews.llvm.org/D45067

Files:
  include/llvm/CodeGen/GlobalISel/ConstantFoldingMIRBuilder.h
  include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
  lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
  unittests/CodeGen/GlobalISel/PatternMatchTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45067.140348.patch
Type: text/x-patch
Size: 60745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180329/eee4ec28/attachment.bin>


More information about the llvm-commits mailing list