[PATCH] D52131: [GISel][NFC]: Make MachineIRBuilder fully stateless
Aditya Nandakumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 17 21:23:14 PDT 2018
aditya_nandakumar added a comment.
In https://reviews.llvm.org/D52131#1236995, @aemerson wrote:
> Looks ok, if a bit cumbersome with the additional state (do we need to hold references to it?). I'd like to see how this state is used with the CSE builder first though.
I'm in the process of reworking parts of the CSEBuilder - I'll try to have a patch in a few days. It would look something like this unit test
void someFoo(MachineIRBuilderState &State) {
CSEMIRBuilder CSEB(State);
CSEB.setInsertionPoint(SomeMI);
auto A = CSEB.buildConstant(s32, 42);
auto B = CSEB.buildConstant(s32, 42);
assert(A == B);
MachineIRBuilder B(State);
auto C = B.buildConstant(s32, 42);
assert(C != A);
unsigned NewReg = MRI.createGenericVReg(s32);
auto Copy = CSEB.buildConstant(NewReg, 42);
assert(Copy->getOpcode() == COPY);
assert (Source of Copy == A);
}
As of now the State has a CSEInfo object which has info about what instructions are available in the CSEMap and will use them if available instead of creating a new vreg + new inst or materialize a copy if a specific destreg is passed in.
Repository:
rL LLVM
https://reviews.llvm.org/D52131
More information about the llvm-commits
mailing list