[PATCH] D13749: x86 atomic codegen: don't drop globals
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 14 15:38:28 PDT 2015
pete added a comment.
> I'm not a huge fan of the code duplication, but it seems easier to read that cleverly reusing partially-constructed MIs.
Yeah, this isn't the easiest thing to avoid here.
One option is to change addDisp to take an Optional<MachineOperand> or something like that which only applies the displacement when its set.
Another alternative is that you create a temporary MachineOperand on the stack and rely on the code in addDisp which checks for immediates, and if they are immediates just adds to them. That is, you could do
MachineOperand ZeroDisp = MachineOperand::createImm(0);
BuildMI(...)
.add...
.addDisp(hasDisp ? Disp : ZeroDisp)
then you won't have any duplication. Thats the least duplication I could come up with.
Cheers!
Pete
http://reviews.llvm.org/D13749
More information about the llvm-commits
mailing list