diff options
author | Diana Picus <Diana-Magda.Picus@amd.com> | 2023-01-09 09:21:41 +0100 |
---|---|---|
committer | Diana Picus <Diana-Magda.Picus@amd.com> | 2023-01-13 09:32:58 +0100 |
commit | 2004ab422a01b24c183f958b10ec4845aeb9b453 (patch) | |
tree | 405e1cb44eec85a6cc6ff4df8e25161f56d79f38 /llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | |
parent | f95a5fbe7ce1ddc890868a2b4720b4561af672cf (diff) | |
download | llvm-2004ab422a01b24c183f958b10ec4845aeb9b453.zip llvm-2004ab422a01b24c183f958b10ec4845aeb9b453.tar.gz llvm-2004ab422a01b24c183f958b10ec4845aeb9b453.tar.bz2 |
MachineIRBuilder: Add buildMergeValues. NFC
Add a `buildMergeValues` method that unconditionally builds a
G_MERGE_VALUES instruction, as opposed to `buildMergeLikeInstr` which
may decide on a different opcode based on the input types.
I haven't audited all the uses of `buildMergeLikeInstr` to see if they
can be replaced with `buildMergeValues`, but I did find a couple of
obvious ones where we check that we're merging scalars right before
calling `buildMerge`.
This is a follow-up suggested in https://reviews.llvm.org/D140964
Differential Revision: https://reviews.llvm.org/D141373
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp index a6148a6..9100e06 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp @@ -597,6 +597,16 @@ MachineInstrBuilder MachineIRBuilder::buildUndef(const DstOp &Res) { return buildInstr(TargetOpcode::G_IMPLICIT_DEF, {Res}, {}); } +MachineInstrBuilder MachineIRBuilder::buildMergeValues(const DstOp &Res, + ArrayRef<Register> Ops) { + // Unfortunately to convert from ArrayRef<LLT> to ArrayRef<SrcOp>, + // we need some temporary storage for the DstOp objects. Here we use a + // sufficiently large SmallVector to not go through the heap. + SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end()); + assert(TmpVec.size() > 1); + return buildInstr(TargetOpcode::G_MERGE_VALUES, Res, TmpVec); +} + MachineInstrBuilder MachineIRBuilder::buildMergeLikeInstr(const DstOp &Res, ArrayRef<Register> Ops) { |