Bug Summary

File:llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
Warning:line 617, column 60
Division by zero

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name MachineIRBuilder.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/build-llvm/lib/CodeGen/GlobalISel -resource-dir /usr/lib/llvm-13/lib/clang/13.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/build-llvm/lib/CodeGen/GlobalISel -I /build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel -I /build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/build-llvm/include -I /build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-13/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/build-llvm/lib/CodeGen/GlobalISel -fdebug-prefix-map=/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82=. -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2021-06-21-164211-33944-1 -x c++ /build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

1//===-- llvm/CodeGen/GlobalISel/MachineIRBuilder.cpp - MIBuilder--*- C++ -*-==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file implements the MachineIRBuidler class.
10//===----------------------------------------------------------------------===//
11#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
12#include "llvm/Analysis/MemoryLocation.h"
13#include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
14#include "llvm/CodeGen/MachineFunction.h"
15#include "llvm/CodeGen/MachineInstr.h"
16#include "llvm/CodeGen/MachineInstrBuilder.h"
17#include "llvm/CodeGen/MachineRegisterInfo.h"
18#include "llvm/CodeGen/TargetInstrInfo.h"
19#include "llvm/CodeGen/TargetLowering.h"
20#include "llvm/CodeGen/TargetOpcodes.h"
21#include "llvm/CodeGen/TargetSubtargetInfo.h"
22#include "llvm/IR/DebugInfo.h"
23
24using namespace llvm;
25
26void MachineIRBuilder::setMF(MachineFunction &MF) {
27 State.MF = &MF;
28 State.MBB = nullptr;
29 State.MRI = &MF.getRegInfo();
30 State.TII = MF.getSubtarget().getInstrInfo();
31 State.DL = DebugLoc();
32 State.II = MachineBasicBlock::iterator();
33 State.Observer = nullptr;
34}
35
36//------------------------------------------------------------------------------
37// Build instruction variants.
38//------------------------------------------------------------------------------
39
40MachineInstrBuilder MachineIRBuilder::buildInstrNoInsert(unsigned Opcode) {
41 MachineInstrBuilder MIB = BuildMI(getMF(), getDL(), getTII().get(Opcode));
42 return MIB;
43}
44
45MachineInstrBuilder MachineIRBuilder::insertInstr(MachineInstrBuilder MIB) {
46 getMBB().insert(getInsertPt(), MIB);
47 recordInsertion(MIB);
48 return MIB;
49}
50
51MachineInstrBuilder
52MachineIRBuilder::buildDirectDbgValue(Register Reg, const MDNode *Variable,
53 const MDNode *Expr) {
54 assert(isa<DILocalVariable>(Variable) && "not a variable")(static_cast <bool> (isa<DILocalVariable>(Variable
) && "not a variable") ? void (0) : __assert_fail ("isa<DILocalVariable>(Variable) && \"not a variable\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 54, __extension__ __PRETTY_FUNCTION__))
;
55 assert(cast<DIExpression>(Expr)->isValid() && "not an expression")(static_cast <bool> (cast<DIExpression>(Expr)->
isValid() && "not an expression") ? void (0) : __assert_fail
("cast<DIExpression>(Expr)->isValid() && \"not an expression\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 55, __extension__ __PRETTY_FUNCTION__))
;
56 assert((static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 58, __extension__ __PRETTY_FUNCTION__))
57 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) &&(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 58, __extension__ __PRETTY_FUNCTION__))
58 "Expected inlined-at fields to agree")(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 58, __extension__ __PRETTY_FUNCTION__))
;
59 return insertInstr(BuildMI(getMF(), getDL(),
60 getTII().get(TargetOpcode::DBG_VALUE),
61 /*IsIndirect*/ false, Reg, Variable, Expr));
62}
63
64MachineInstrBuilder
65MachineIRBuilder::buildIndirectDbgValue(Register Reg, const MDNode *Variable,
66 const MDNode *Expr) {
67 assert(isa<DILocalVariable>(Variable) && "not a variable")(static_cast <bool> (isa<DILocalVariable>(Variable
) && "not a variable") ? void (0) : __assert_fail ("isa<DILocalVariable>(Variable) && \"not a variable\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 67, __extension__ __PRETTY_FUNCTION__))
;
68 assert(cast<DIExpression>(Expr)->isValid() && "not an expression")(static_cast <bool> (cast<DIExpression>(Expr)->
isValid() && "not an expression") ? void (0) : __assert_fail
("cast<DIExpression>(Expr)->isValid() && \"not an expression\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 68, __extension__ __PRETTY_FUNCTION__))
;
69 assert((static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 71, __extension__ __PRETTY_FUNCTION__))
70 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) &&(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 71, __extension__ __PRETTY_FUNCTION__))
71 "Expected inlined-at fields to agree")(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 71, __extension__ __PRETTY_FUNCTION__))
;
72 return insertInstr(BuildMI(getMF(), getDL(),
73 getTII().get(TargetOpcode::DBG_VALUE),
74 /*IsIndirect*/ true, Reg, Variable, Expr));
75}
76
77MachineInstrBuilder MachineIRBuilder::buildFIDbgValue(int FI,
78 const MDNode *Variable,
79 const MDNode *Expr) {
80 assert(isa<DILocalVariable>(Variable) && "not a variable")(static_cast <bool> (isa<DILocalVariable>(Variable
) && "not a variable") ? void (0) : __assert_fail ("isa<DILocalVariable>(Variable) && \"not a variable\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 80, __extension__ __PRETTY_FUNCTION__))
;
81 assert(cast<DIExpression>(Expr)->isValid() && "not an expression")(static_cast <bool> (cast<DIExpression>(Expr)->
isValid() && "not an expression") ? void (0) : __assert_fail
("cast<DIExpression>(Expr)->isValid() && \"not an expression\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 81, __extension__ __PRETTY_FUNCTION__))
;
82 assert((static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 84, __extension__ __PRETTY_FUNCTION__))
83 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) &&(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 84, __extension__ __PRETTY_FUNCTION__))
84 "Expected inlined-at fields to agree")(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 84, __extension__ __PRETTY_FUNCTION__))
;
85 return buildInstr(TargetOpcode::DBG_VALUE)
86 .addFrameIndex(FI)
87 .addImm(0)
88 .addMetadata(Variable)
89 .addMetadata(Expr);
90}
91
92MachineInstrBuilder MachineIRBuilder::buildConstDbgValue(const Constant &C,
93 const MDNode *Variable,
94 const MDNode *Expr) {
95 assert(isa<DILocalVariable>(Variable) && "not a variable")(static_cast <bool> (isa<DILocalVariable>(Variable
) && "not a variable") ? void (0) : __assert_fail ("isa<DILocalVariable>(Variable) && \"not a variable\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 95, __extension__ __PRETTY_FUNCTION__))
;
96 assert(cast<DIExpression>(Expr)->isValid() && "not an expression")(static_cast <bool> (cast<DIExpression>(Expr)->
isValid() && "not an expression") ? void (0) : __assert_fail
("cast<DIExpression>(Expr)->isValid() && \"not an expression\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 96, __extension__ __PRETTY_FUNCTION__))
;
97 assert((static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 99, __extension__ __PRETTY_FUNCTION__))
98 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) &&(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 99, __extension__ __PRETTY_FUNCTION__))
99 "Expected inlined-at fields to agree")(static_cast <bool> (cast<DILocalVariable>(Variable
)->isValidLocationForIntrinsic(getDL()) && "Expected inlined-at fields to agree"
) ? void (0) : __assert_fail ("cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 99, __extension__ __PRETTY_FUNCTION__))
;
100 auto MIB = buildInstrNoInsert(TargetOpcode::DBG_VALUE);
101 if (auto *CI = dyn_cast<ConstantInt>(&C)) {
102 if (CI->getBitWidth() > 64)
103 MIB.addCImm(CI);
104 else
105 MIB.addImm(CI->getZExtValue());
106 } else if (auto *CFP = dyn_cast<ConstantFP>(&C)) {
107 MIB.addFPImm(CFP);
108 } else {
109 // Insert $noreg if we didn't find a usable constant and had to drop it.
110 MIB.addReg(Register());
111 }
112
113 MIB.addImm(0).addMetadata(Variable).addMetadata(Expr);
114 return insertInstr(MIB);
115}
116
117MachineInstrBuilder MachineIRBuilder::buildDbgLabel(const MDNode *Label) {
118 assert(isa<DILabel>(Label) && "not a label")(static_cast <bool> (isa<DILabel>(Label) &&
"not a label") ? void (0) : __assert_fail ("isa<DILabel>(Label) && \"not a label\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 118, __extension__ __PRETTY_FUNCTION__))
;
119 assert(cast<DILabel>(Label)->isValidLocationForIntrinsic(State.DL) &&(static_cast <bool> (cast<DILabel>(Label)->isValidLocationForIntrinsic
(State.DL) && "Expected inlined-at fields to agree") ?
void (0) : __assert_fail ("cast<DILabel>(Label)->isValidLocationForIntrinsic(State.DL) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 120, __extension__ __PRETTY_FUNCTION__))
120 "Expected inlined-at fields to agree")(static_cast <bool> (cast<DILabel>(Label)->isValidLocationForIntrinsic
(State.DL) && "Expected inlined-at fields to agree") ?
void (0) : __assert_fail ("cast<DILabel>(Label)->isValidLocationForIntrinsic(State.DL) && \"Expected inlined-at fields to agree\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 120, __extension__ __PRETTY_FUNCTION__))
;
121 auto MIB = buildInstr(TargetOpcode::DBG_LABEL);
122
123 return MIB.addMetadata(Label);
124}
125
126MachineInstrBuilder MachineIRBuilder::buildDynStackAlloc(const DstOp &Res,
127 const SrcOp &Size,
128 Align Alignment) {
129 assert(Res.getLLTTy(*getMRI()).isPointer() && "expected ptr dst type")(static_cast <bool> (Res.getLLTTy(*getMRI()).isPointer(
) && "expected ptr dst type") ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).isPointer() && \"expected ptr dst type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 129, __extension__ __PRETTY_FUNCTION__))
;
130 auto MIB = buildInstr(TargetOpcode::G_DYN_STACKALLOC);
131 Res.addDefToMIB(*getMRI(), MIB);
132 Size.addSrcToMIB(MIB);
133 MIB.addImm(Alignment.value());
134 return MIB;
135}
136
137MachineInstrBuilder MachineIRBuilder::buildFrameIndex(const DstOp &Res,
138 int Idx) {
139 assert(Res.getLLTTy(*getMRI()).isPointer() && "invalid operand type")(static_cast <bool> (Res.getLLTTy(*getMRI()).isPointer(
) && "invalid operand type") ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 139, __extension__ __PRETTY_FUNCTION__))
;
140 auto MIB = buildInstr(TargetOpcode::G_FRAME_INDEX);
141 Res.addDefToMIB(*getMRI(), MIB);
142 MIB.addFrameIndex(Idx);
143 return MIB;
144}
145
146MachineInstrBuilder MachineIRBuilder::buildGlobalValue(const DstOp &Res,
147 const GlobalValue *GV) {
148 assert(Res.getLLTTy(*getMRI()).isPointer() && "invalid operand type")(static_cast <bool> (Res.getLLTTy(*getMRI()).isPointer(
) && "invalid operand type") ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 148, __extension__ __PRETTY_FUNCTION__))
;
149 assert(Res.getLLTTy(*getMRI()).getAddressSpace() ==(static_cast <bool> (Res.getLLTTy(*getMRI()).getAddressSpace
() == GV->getType()->getAddressSpace() && "address space mismatch"
) ? void (0) : __assert_fail ("Res.getLLTTy(*getMRI()).getAddressSpace() == GV->getType()->getAddressSpace() && \"address space mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 151, __extension__ __PRETTY_FUNCTION__))
150 GV->getType()->getAddressSpace() &&(static_cast <bool> (Res.getLLTTy(*getMRI()).getAddressSpace
() == GV->getType()->getAddressSpace() && "address space mismatch"
) ? void (0) : __assert_fail ("Res.getLLTTy(*getMRI()).getAddressSpace() == GV->getType()->getAddressSpace() && \"address space mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 151, __extension__ __PRETTY_FUNCTION__))
151 "address space mismatch")(static_cast <bool> (Res.getLLTTy(*getMRI()).getAddressSpace
() == GV->getType()->getAddressSpace() && "address space mismatch"
) ? void (0) : __assert_fail ("Res.getLLTTy(*getMRI()).getAddressSpace() == GV->getType()->getAddressSpace() && \"address space mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 151, __extension__ __PRETTY_FUNCTION__))
;
152
153 auto MIB = buildInstr(TargetOpcode::G_GLOBAL_VALUE);
154 Res.addDefToMIB(*getMRI(), MIB);
155 MIB.addGlobalAddress(GV);
156 return MIB;
157}
158
159MachineInstrBuilder MachineIRBuilder::buildJumpTable(const LLT PtrTy,
160 unsigned JTI) {
161 return buildInstr(TargetOpcode::G_JUMP_TABLE, {PtrTy}, {})
162 .addJumpTableIndex(JTI);
163}
164
165void MachineIRBuilder::validateUnaryOp(const LLT Res, const LLT Op0) {
166 assert((Res.isScalar() || Res.isVector()) && "invalid operand type")(static_cast <bool> ((Res.isScalar() || Res.isVector())
&& "invalid operand type") ? void (0) : __assert_fail
("(Res.isScalar() || Res.isVector()) && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 166, __extension__ __PRETTY_FUNCTION__))
;
167 assert((Res == Op0) && "type mismatch")(static_cast <bool> ((Res == Op0) && "type mismatch"
) ? void (0) : __assert_fail ("(Res == Op0) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 167, __extension__ __PRETTY_FUNCTION__))
;
168}
169
170void MachineIRBuilder::validateBinaryOp(const LLT Res, const LLT Op0,
171 const LLT Op1) {
172 assert((Res.isScalar() || Res.isVector()) && "invalid operand type")(static_cast <bool> ((Res.isScalar() || Res.isVector())
&& "invalid operand type") ? void (0) : __assert_fail
("(Res.isScalar() || Res.isVector()) && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 172, __extension__ __PRETTY_FUNCTION__))
;
173 assert((Res == Op0 && Res == Op1) && "type mismatch")(static_cast <bool> ((Res == Op0 && Res == Op1)
&& "type mismatch") ? void (0) : __assert_fail ("(Res == Op0 && Res == Op1) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 173, __extension__ __PRETTY_FUNCTION__))
;
174}
175
176void MachineIRBuilder::validateShiftOp(const LLT Res, const LLT Op0,
177 const LLT Op1) {
178 assert((Res.isScalar() || Res.isVector()) && "invalid operand type")(static_cast <bool> ((Res.isScalar() || Res.isVector())
&& "invalid operand type") ? void (0) : __assert_fail
("(Res.isScalar() || Res.isVector()) && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 178, __extension__ __PRETTY_FUNCTION__))
;
179 assert((Res == Op0) && "type mismatch")(static_cast <bool> ((Res == Op0) && "type mismatch"
) ? void (0) : __assert_fail ("(Res == Op0) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 179, __extension__ __PRETTY_FUNCTION__))
;
180}
181
182MachineInstrBuilder MachineIRBuilder::buildPtrAdd(const DstOp &Res,
183 const SrcOp &Op0,
184 const SrcOp &Op1) {
185 assert(Res.getLLTTy(*getMRI()).getScalarType().isPointer() &&(static_cast <bool> (Res.getLLTTy(*getMRI()).getScalarType
().isPointer() && Res.getLLTTy(*getMRI()) == Op0.getLLTTy
(*getMRI()) && "type mismatch") ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).getScalarType().isPointer() && Res.getLLTTy(*getMRI()) == Op0.getLLTTy(*getMRI()) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 186, __extension__ __PRETTY_FUNCTION__))
186 Res.getLLTTy(*getMRI()) == Op0.getLLTTy(*getMRI()) && "type mismatch")(static_cast <bool> (Res.getLLTTy(*getMRI()).getScalarType
().isPointer() && Res.getLLTTy(*getMRI()) == Op0.getLLTTy
(*getMRI()) && "type mismatch") ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).getScalarType().isPointer() && Res.getLLTTy(*getMRI()) == Op0.getLLTTy(*getMRI()) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 186, __extension__ __PRETTY_FUNCTION__))
;
187 assert(Op1.getLLTTy(*getMRI()).getScalarType().isScalar() && "invalid offset type")(static_cast <bool> (Op1.getLLTTy(*getMRI()).getScalarType
().isScalar() && "invalid offset type") ? void (0) : __assert_fail
("Op1.getLLTTy(*getMRI()).getScalarType().isScalar() && \"invalid offset type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 187, __extension__ __PRETTY_FUNCTION__))
;
188
189 return buildInstr(TargetOpcode::G_PTR_ADD, {Res}, {Op0, Op1});
190}
191
192Optional<MachineInstrBuilder>
193MachineIRBuilder::materializePtrAdd(Register &Res, Register Op0,
194 const LLT ValueTy, uint64_t Value) {
195 assert(Res == 0 && "Res is a result argument")(static_cast <bool> (Res == 0 && "Res is a result argument"
) ? void (0) : __assert_fail ("Res == 0 && \"Res is a result argument\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 195, __extension__ __PRETTY_FUNCTION__))
;
196 assert(ValueTy.isScalar() && "invalid offset type")(static_cast <bool> (ValueTy.isScalar() && "invalid offset type"
) ? void (0) : __assert_fail ("ValueTy.isScalar() && \"invalid offset type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 196, __extension__ __PRETTY_FUNCTION__))
;
197
198 if (Value == 0) {
199 Res = Op0;
200 return None;
201 }
202
203 Res = getMRI()->createGenericVirtualRegister(getMRI()->getType(Op0));
204 auto Cst = buildConstant(ValueTy, Value);
205 return buildPtrAdd(Res, Op0, Cst.getReg(0));
206}
207
208MachineInstrBuilder MachineIRBuilder::buildMaskLowPtrBits(const DstOp &Res,
209 const SrcOp &Op0,
210 uint32_t NumBits) {
211 LLT PtrTy = Res.getLLTTy(*getMRI());
212 LLT MaskTy = LLT::scalar(PtrTy.getSizeInBits());
213 Register MaskReg = getMRI()->createGenericVirtualRegister(MaskTy);
214 buildConstant(MaskReg, maskTrailingZeros<uint64_t>(NumBits));
215 return buildPtrMask(Res, Op0, MaskReg);
216}
217
218MachineInstrBuilder MachineIRBuilder::buildBr(MachineBasicBlock &Dest) {
219 return buildInstr(TargetOpcode::G_BR).addMBB(&Dest);
220}
221
222MachineInstrBuilder MachineIRBuilder::buildBrIndirect(Register Tgt) {
223 assert(getMRI()->getType(Tgt).isPointer() && "invalid branch destination")(static_cast <bool> (getMRI()->getType(Tgt).isPointer
() && "invalid branch destination") ? void (0) : __assert_fail
("getMRI()->getType(Tgt).isPointer() && \"invalid branch destination\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 223, __extension__ __PRETTY_FUNCTION__))
;
224 return buildInstr(TargetOpcode::G_BRINDIRECT).addUse(Tgt);
225}
226
227MachineInstrBuilder MachineIRBuilder::buildBrJT(Register TablePtr,
228 unsigned JTI,
229 Register IndexReg) {
230 assert(getMRI()->getType(TablePtr).isPointer() &&(static_cast <bool> (getMRI()->getType(TablePtr).isPointer
() && "Table reg must be a pointer") ? void (0) : __assert_fail
("getMRI()->getType(TablePtr).isPointer() && \"Table reg must be a pointer\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 231, __extension__ __PRETTY_FUNCTION__))
231 "Table reg must be a pointer")(static_cast <bool> (getMRI()->getType(TablePtr).isPointer
() && "Table reg must be a pointer") ? void (0) : __assert_fail
("getMRI()->getType(TablePtr).isPointer() && \"Table reg must be a pointer\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 231, __extension__ __PRETTY_FUNCTION__))
;
232 return buildInstr(TargetOpcode::G_BRJT)
233 .addUse(TablePtr)
234 .addJumpTableIndex(JTI)
235 .addUse(IndexReg);
236}
237
238MachineInstrBuilder MachineIRBuilder::buildCopy(const DstOp &Res,
239 const SrcOp &Op) {
240 return buildInstr(TargetOpcode::COPY, Res, Op);
241}
242
243MachineInstrBuilder MachineIRBuilder::buildAssertSExt(const DstOp &Res,
244 const SrcOp &Op,
245 unsigned Size) {
246 return buildInstr(TargetOpcode::G_ASSERT_SEXT, Res, Op).addImm(Size);
247}
248
249MachineInstrBuilder MachineIRBuilder::buildAssertZExt(const DstOp &Res,
250 const SrcOp &Op,
251 unsigned Size) {
252 return buildInstr(TargetOpcode::G_ASSERT_ZEXT, Res, Op).addImm(Size);
253}
254
255MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
256 const ConstantInt &Val) {
257 LLT Ty = Res.getLLTTy(*getMRI());
258 LLT EltTy = Ty.getScalarType();
259 assert(EltTy.getScalarSizeInBits() == Val.getBitWidth() &&(static_cast <bool> (EltTy.getScalarSizeInBits() == Val
.getBitWidth() && "creating constant with the wrong size"
) ? void (0) : __assert_fail ("EltTy.getScalarSizeInBits() == Val.getBitWidth() && \"creating constant with the wrong size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 260, __extension__ __PRETTY_FUNCTION__))
260 "creating constant with the wrong size")(static_cast <bool> (EltTy.getScalarSizeInBits() == Val
.getBitWidth() && "creating constant with the wrong size"
) ? void (0) : __assert_fail ("EltTy.getScalarSizeInBits() == Val.getBitWidth() && \"creating constant with the wrong size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 260, __extension__ __PRETTY_FUNCTION__))
;
261
262 if (Ty.isVector()) {
263 auto Const = buildInstr(TargetOpcode::G_CONSTANT)
264 .addDef(getMRI()->createGenericVirtualRegister(EltTy))
265 .addCImm(&Val);
266 return buildSplatVector(Res, Const);
267 }
268
269 auto Const = buildInstr(TargetOpcode::G_CONSTANT);
270 Const->setDebugLoc(DebugLoc());
271 Res.addDefToMIB(*getMRI(), Const);
272 Const.addCImm(&Val);
273 return Const;
274}
275
276MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
277 int64_t Val) {
278 auto IntN = IntegerType::get(getMF().getFunction().getContext(),
279 Res.getLLTTy(*getMRI()).getScalarSizeInBits());
280 ConstantInt *CI = ConstantInt::get(IntN, Val, true);
281 return buildConstant(Res, *CI);
282}
283
284MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
285 const ConstantFP &Val) {
286 LLT Ty = Res.getLLTTy(*getMRI());
287 LLT EltTy = Ty.getScalarType();
288
289 assert(APFloat::getSizeInBits(Val.getValueAPF().getSemantics())(static_cast <bool> (APFloat::getSizeInBits(Val.getValueAPF
().getSemantics()) == EltTy.getSizeInBits() && "creating fconstant with the wrong size"
) ? void (0) : __assert_fail ("APFloat::getSizeInBits(Val.getValueAPF().getSemantics()) == EltTy.getSizeInBits() && \"creating fconstant with the wrong size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 291, __extension__ __PRETTY_FUNCTION__))
290 == EltTy.getSizeInBits() &&(static_cast <bool> (APFloat::getSizeInBits(Val.getValueAPF
().getSemantics()) == EltTy.getSizeInBits() && "creating fconstant with the wrong size"
) ? void (0) : __assert_fail ("APFloat::getSizeInBits(Val.getValueAPF().getSemantics()) == EltTy.getSizeInBits() && \"creating fconstant with the wrong size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 291, __extension__ __PRETTY_FUNCTION__))
291 "creating fconstant with the wrong size")(static_cast <bool> (APFloat::getSizeInBits(Val.getValueAPF
().getSemantics()) == EltTy.getSizeInBits() && "creating fconstant with the wrong size"
) ? void (0) : __assert_fail ("APFloat::getSizeInBits(Val.getValueAPF().getSemantics()) == EltTy.getSizeInBits() && \"creating fconstant with the wrong size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 291, __extension__ __PRETTY_FUNCTION__))
;
292
293 assert(!Ty.isPointer() && "invalid operand type")(static_cast <bool> (!Ty.isPointer() && "invalid operand type"
) ? void (0) : __assert_fail ("!Ty.isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 293, __extension__ __PRETTY_FUNCTION__))
;
294
295 if (Ty.isVector()) {
296 auto Const = buildInstr(TargetOpcode::G_FCONSTANT)
297 .addDef(getMRI()->createGenericVirtualRegister(EltTy))
298 .addFPImm(&Val);
299
300 return buildSplatVector(Res, Const);
301 }
302
303 auto Const = buildInstr(TargetOpcode::G_FCONSTANT);
304 Const->setDebugLoc(DebugLoc());
305 Res.addDefToMIB(*getMRI(), Const);
306 Const.addFPImm(&Val);
307 return Const;
308}
309
310MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
311 const APInt &Val) {
312 ConstantInt *CI = ConstantInt::get(getMF().getFunction().getContext(), Val);
313 return buildConstant(Res, *CI);
314}
315
316MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
317 double Val) {
318 LLT DstTy = Res.getLLTTy(*getMRI());
319 auto &Ctx = getMF().getFunction().getContext();
320 auto *CFP =
321 ConstantFP::get(Ctx, getAPFloatFromSize(Val, DstTy.getScalarSizeInBits()));
322 return buildFConstant(Res, *CFP);
323}
324
325MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
326 const APFloat &Val) {
327 auto &Ctx = getMF().getFunction().getContext();
328 auto *CFP = ConstantFP::get(Ctx, Val);
329 return buildFConstant(Res, *CFP);
330}
331
332MachineInstrBuilder MachineIRBuilder::buildBrCond(const SrcOp &Tst,
333 MachineBasicBlock &Dest) {
334 assert(Tst.getLLTTy(*getMRI()).isScalar() && "invalid operand type")(static_cast <bool> (Tst.getLLTTy(*getMRI()).isScalar()
&& "invalid operand type") ? void (0) : __assert_fail
("Tst.getLLTTy(*getMRI()).isScalar() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 334, __extension__ __PRETTY_FUNCTION__))
;
335
336 auto MIB = buildInstr(TargetOpcode::G_BRCOND);
337 Tst.addSrcToMIB(MIB);
338 MIB.addMBB(&Dest);
339 return MIB;
340}
341
342MachineInstrBuilder
343MachineIRBuilder::buildLoad(const DstOp &Dst, const SrcOp &Addr,
344 MachinePointerInfo PtrInfo, Align Alignment,
345 MachineMemOperand::Flags MMOFlags,
346 const AAMDNodes &AAInfo) {
347 MMOFlags |= MachineMemOperand::MOLoad;
348 assert((MMOFlags & MachineMemOperand::MOStore) == 0)(static_cast <bool> ((MMOFlags & MachineMemOperand::
MOStore) == 0) ? void (0) : __assert_fail ("(MMOFlags & MachineMemOperand::MOStore) == 0"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 348, __extension__ __PRETTY_FUNCTION__))
;
349
350 uint64_t Size = MemoryLocation::getSizeOrUnknown(
351 TypeSize::Fixed(Dst.getLLTTy(*getMRI()).getSizeInBytes()));
352 MachineMemOperand *MMO =
353 getMF().getMachineMemOperand(PtrInfo, MMOFlags, Size, Alignment, AAInfo);
354 return buildLoad(Dst, Addr, *MMO);
355}
356
357MachineInstrBuilder MachineIRBuilder::buildLoadInstr(unsigned Opcode,
358 const DstOp &Res,
359 const SrcOp &Addr,
360 MachineMemOperand &MMO) {
361 assert(Res.getLLTTy(*getMRI()).isValid() && "invalid operand type")(static_cast <bool> (Res.getLLTTy(*getMRI()).isValid() &&
"invalid operand type") ? void (0) : __assert_fail ("Res.getLLTTy(*getMRI()).isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 361, __extension__ __PRETTY_FUNCTION__))
;
362 assert(Addr.getLLTTy(*getMRI()).isPointer() && "invalid operand type")(static_cast <bool> (Addr.getLLTTy(*getMRI()).isPointer
() && "invalid operand type") ? void (0) : __assert_fail
("Addr.getLLTTy(*getMRI()).isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 362, __extension__ __PRETTY_FUNCTION__))
;
363
364 auto MIB = buildInstr(Opcode);
365 Res.addDefToMIB(*getMRI(), MIB);
366 Addr.addSrcToMIB(MIB);
367 MIB.addMemOperand(&MMO);
368 return MIB;
369}
370
371MachineInstrBuilder MachineIRBuilder::buildLoadFromOffset(
372 const DstOp &Dst, const SrcOp &BasePtr,
373 MachineMemOperand &BaseMMO, int64_t Offset) {
374 LLT LoadTy = Dst.getLLTTy(*getMRI());
375 MachineMemOperand *OffsetMMO =
376 getMF().getMachineMemOperand(&BaseMMO, Offset, LoadTy.getSizeInBytes());
377
378 if (Offset == 0) // This may be a size or type changing load.
379 return buildLoad(Dst, BasePtr, *OffsetMMO);
380
381 LLT PtrTy = BasePtr.getLLTTy(*getMRI());
382 LLT OffsetTy = LLT::scalar(PtrTy.getSizeInBits());
383 auto ConstOffset = buildConstant(OffsetTy, Offset);
384 auto Ptr = buildPtrAdd(PtrTy, BasePtr, ConstOffset);
385 return buildLoad(Dst, Ptr, *OffsetMMO);
386}
387
388MachineInstrBuilder MachineIRBuilder::buildStore(const SrcOp &Val,
389 const SrcOp &Addr,
390 MachineMemOperand &MMO) {
391 assert(Val.getLLTTy(*getMRI()).isValid() && "invalid operand type")(static_cast <bool> (Val.getLLTTy(*getMRI()).isValid() &&
"invalid operand type") ? void (0) : __assert_fail ("Val.getLLTTy(*getMRI()).isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 391, __extension__ __PRETTY_FUNCTION__))
;
392 assert(Addr.getLLTTy(*getMRI()).isPointer() && "invalid operand type")(static_cast <bool> (Addr.getLLTTy(*getMRI()).isPointer
() && "invalid operand type") ? void (0) : __assert_fail
("Addr.getLLTTy(*getMRI()).isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 392, __extension__ __PRETTY_FUNCTION__))
;
393
394 auto MIB = buildInstr(TargetOpcode::G_STORE);
395 Val.addSrcToMIB(MIB);
396 Addr.addSrcToMIB(MIB);
397 MIB.addMemOperand(&MMO);
398 return MIB;
399}
400
401MachineInstrBuilder
402MachineIRBuilder::buildStore(const SrcOp &Val, const SrcOp &Addr,
403 MachinePointerInfo PtrInfo, Align Alignment,
404 MachineMemOperand::Flags MMOFlags,
405 const AAMDNodes &AAInfo) {
406 MMOFlags |= MachineMemOperand::MOStore;
407 assert((MMOFlags & MachineMemOperand::MOLoad) == 0)(static_cast <bool> ((MMOFlags & MachineMemOperand::
MOLoad) == 0) ? void (0) : __assert_fail ("(MMOFlags & MachineMemOperand::MOLoad) == 0"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 407, __extension__ __PRETTY_FUNCTION__))
;
408
409 uint64_t Size = MemoryLocation::getSizeOrUnknown(
410 TypeSize::Fixed(Val.getLLTTy(*getMRI()).getSizeInBytes()));
411 MachineMemOperand *MMO =
412 getMF().getMachineMemOperand(PtrInfo, MMOFlags, Size, Alignment, AAInfo);
413 return buildStore(Val, Addr, *MMO);
414}
415
416MachineInstrBuilder MachineIRBuilder::buildAnyExt(const DstOp &Res,
417 const SrcOp &Op) {
418 return buildInstr(TargetOpcode::G_ANYEXT, Res, Op);
419}
420
421MachineInstrBuilder MachineIRBuilder::buildSExt(const DstOp &Res,
422 const SrcOp &Op) {
423 return buildInstr(TargetOpcode::G_SEXT, Res, Op);
424}
425
426MachineInstrBuilder MachineIRBuilder::buildZExt(const DstOp &Res,
427 const SrcOp &Op) {
428 return buildInstr(TargetOpcode::G_ZEXT, Res, Op);
429}
430
431unsigned MachineIRBuilder::getBoolExtOp(bool IsVec, bool IsFP) const {
432 const auto *TLI = getMF().getSubtarget().getTargetLowering();
433 switch (TLI->getBooleanContents(IsVec, IsFP)) {
434 case TargetLoweringBase::ZeroOrNegativeOneBooleanContent:
435 return TargetOpcode::G_SEXT;
436 case TargetLoweringBase::ZeroOrOneBooleanContent:
437 return TargetOpcode::G_ZEXT;
438 default:
439 return TargetOpcode::G_ANYEXT;
440 }
441}
442
443MachineInstrBuilder MachineIRBuilder::buildBoolExt(const DstOp &Res,
444 const SrcOp &Op,
445 bool IsFP) {
446 unsigned ExtOp = getBoolExtOp(getMRI()->getType(Op.getReg()).isVector(), IsFP);
447 return buildInstr(ExtOp, Res, Op);
448}
449
450MachineInstrBuilder MachineIRBuilder::buildExtOrTrunc(unsigned ExtOpc,
451 const DstOp &Res,
452 const SrcOp &Op) {
453 assert((TargetOpcode::G_ANYEXT == ExtOpc || TargetOpcode::G_ZEXT == ExtOpc ||(static_cast <bool> ((TargetOpcode::G_ANYEXT == ExtOpc ||
TargetOpcode::G_ZEXT == ExtOpc || TargetOpcode::G_SEXT == ExtOpc
) && "Expecting Extending Opc") ? void (0) : __assert_fail
("(TargetOpcode::G_ANYEXT == ExtOpc || TargetOpcode::G_ZEXT == ExtOpc || TargetOpcode::G_SEXT == ExtOpc) && \"Expecting Extending Opc\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 455, __extension__ __PRETTY_FUNCTION__))
454 TargetOpcode::G_SEXT == ExtOpc) &&(static_cast <bool> ((TargetOpcode::G_ANYEXT == ExtOpc ||
TargetOpcode::G_ZEXT == ExtOpc || TargetOpcode::G_SEXT == ExtOpc
) && "Expecting Extending Opc") ? void (0) : __assert_fail
("(TargetOpcode::G_ANYEXT == ExtOpc || TargetOpcode::G_ZEXT == ExtOpc || TargetOpcode::G_SEXT == ExtOpc) && \"Expecting Extending Opc\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 455, __extension__ __PRETTY_FUNCTION__))
455 "Expecting Extending Opc")(static_cast <bool> ((TargetOpcode::G_ANYEXT == ExtOpc ||
TargetOpcode::G_ZEXT == ExtOpc || TargetOpcode::G_SEXT == ExtOpc
) && "Expecting Extending Opc") ? void (0) : __assert_fail
("(TargetOpcode::G_ANYEXT == ExtOpc || TargetOpcode::G_ZEXT == ExtOpc || TargetOpcode::G_SEXT == ExtOpc) && \"Expecting Extending Opc\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 455, __extension__ __PRETTY_FUNCTION__))
;
456 assert(Res.getLLTTy(*getMRI()).isScalar() ||(static_cast <bool> (Res.getLLTTy(*getMRI()).isScalar()
|| Res.getLLTTy(*getMRI()).isVector()) ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).isScalar() || Res.getLLTTy(*getMRI()).isVector()"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 457, __extension__ __PRETTY_FUNCTION__))
457 Res.getLLTTy(*getMRI()).isVector())(static_cast <bool> (Res.getLLTTy(*getMRI()).isScalar()
|| Res.getLLTTy(*getMRI()).isVector()) ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).isScalar() || Res.getLLTTy(*getMRI()).isVector()"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 457, __extension__ __PRETTY_FUNCTION__))
;
458 assert(Res.getLLTTy(*getMRI()).isScalar() ==(static_cast <bool> (Res.getLLTTy(*getMRI()).isScalar()
== Op.getLLTTy(*getMRI()).isScalar()) ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).isScalar() == Op.getLLTTy(*getMRI()).isScalar()"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 459, __extension__ __PRETTY_FUNCTION__))
459 Op.getLLTTy(*getMRI()).isScalar())(static_cast <bool> (Res.getLLTTy(*getMRI()).isScalar()
== Op.getLLTTy(*getMRI()).isScalar()) ? void (0) : __assert_fail
("Res.getLLTTy(*getMRI()).isScalar() == Op.getLLTTy(*getMRI()).isScalar()"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 459, __extension__ __PRETTY_FUNCTION__))
;
460
461 unsigned Opcode = TargetOpcode::COPY;
462 if (Res.getLLTTy(*getMRI()).getSizeInBits() >
463 Op.getLLTTy(*getMRI()).getSizeInBits())
464 Opcode = ExtOpc;
465 else if (Res.getLLTTy(*getMRI()).getSizeInBits() <
466 Op.getLLTTy(*getMRI()).getSizeInBits())
467 Opcode = TargetOpcode::G_TRUNC;
468 else
469 assert(Res.getLLTTy(*getMRI()) == Op.getLLTTy(*getMRI()))(static_cast <bool> (Res.getLLTTy(*getMRI()) == Op.getLLTTy
(*getMRI())) ? void (0) : __assert_fail ("Res.getLLTTy(*getMRI()) == Op.getLLTTy(*getMRI())"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 469, __extension__ __PRETTY_FUNCTION__))
;
470
471 return buildInstr(Opcode, Res, Op);
472}
473
474MachineInstrBuilder MachineIRBuilder::buildSExtOrTrunc(const DstOp &Res,
475 const SrcOp &Op) {
476 return buildExtOrTrunc(TargetOpcode::G_SEXT, Res, Op);
477}
478
479MachineInstrBuilder MachineIRBuilder::buildZExtOrTrunc(const DstOp &Res,
480 const SrcOp &Op) {
481 return buildExtOrTrunc(TargetOpcode::G_ZEXT, Res, Op);
482}
483
484MachineInstrBuilder MachineIRBuilder::buildAnyExtOrTrunc(const DstOp &Res,
485 const SrcOp &Op) {
486 return buildExtOrTrunc(TargetOpcode::G_ANYEXT, Res, Op);
487}
488
489MachineInstrBuilder MachineIRBuilder::buildZExtInReg(const DstOp &Res,
490 const SrcOp &Op,
491 int64_t ImmOp) {
492 LLT ResTy = Res.getLLTTy(*getMRI());
493 auto Mask = buildConstant(
494 ResTy, APInt::getLowBitsSet(ResTy.getScalarSizeInBits(), ImmOp));
495 return buildAnd(Res, Op, Mask);
496}
497
498MachineInstrBuilder MachineIRBuilder::buildCast(const DstOp &Dst,
499 const SrcOp &Src) {
500 LLT SrcTy = Src.getLLTTy(*getMRI());
501 LLT DstTy = Dst.getLLTTy(*getMRI());
502 if (SrcTy == DstTy)
503 return buildCopy(Dst, Src);
504
505 unsigned Opcode;
506 if (SrcTy.isPointer() && DstTy.isScalar())
507 Opcode = TargetOpcode::G_PTRTOINT;
508 else if (DstTy.isPointer() && SrcTy.isScalar())
509 Opcode = TargetOpcode::G_INTTOPTR;
510 else {
511 assert(!SrcTy.isPointer() && !DstTy.isPointer() && "n G_ADDRCAST yet")(static_cast <bool> (!SrcTy.isPointer() && !DstTy
.isPointer() && "n G_ADDRCAST yet") ? void (0) : __assert_fail
("!SrcTy.isPointer() && !DstTy.isPointer() && \"n G_ADDRCAST yet\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 511, __extension__ __PRETTY_FUNCTION__))
;
512 Opcode = TargetOpcode::G_BITCAST;
513 }
514
515 return buildInstr(Opcode, Dst, Src);
516}
517
518MachineInstrBuilder MachineIRBuilder::buildExtract(const DstOp &Dst,
519 const SrcOp &Src,
520 uint64_t Index) {
521 LLT SrcTy = Src.getLLTTy(*getMRI());
522 LLT DstTy = Dst.getLLTTy(*getMRI());
523
524#ifndef NDEBUG
525 assert(SrcTy.isValid() && "invalid operand type")(static_cast <bool> (SrcTy.isValid() && "invalid operand type"
) ? void (0) : __assert_fail ("SrcTy.isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 525, __extension__ __PRETTY_FUNCTION__))
;
526 assert(DstTy.isValid() && "invalid operand type")(static_cast <bool> (DstTy.isValid() && "invalid operand type"
) ? void (0) : __assert_fail ("DstTy.isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 526, __extension__ __PRETTY_FUNCTION__))
;
527 assert(Index + DstTy.getSizeInBits() <= SrcTy.getSizeInBits() &&(static_cast <bool> (Index + DstTy.getSizeInBits() <=
SrcTy.getSizeInBits() && "extracting off end of register"
) ? void (0) : __assert_fail ("Index + DstTy.getSizeInBits() <= SrcTy.getSizeInBits() && \"extracting off end of register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 528, __extension__ __PRETTY_FUNCTION__))
528 "extracting off end of register")(static_cast <bool> (Index + DstTy.getSizeInBits() <=
SrcTy.getSizeInBits() && "extracting off end of register"
) ? void (0) : __assert_fail ("Index + DstTy.getSizeInBits() <= SrcTy.getSizeInBits() && \"extracting off end of register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 528, __extension__ __PRETTY_FUNCTION__))
;
529#endif
530
531 if (DstTy.getSizeInBits() == SrcTy.getSizeInBits()) {
532 assert(Index == 0 && "insertion past the end of a register")(static_cast <bool> (Index == 0 && "insertion past the end of a register"
) ? void (0) : __assert_fail ("Index == 0 && \"insertion past the end of a register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 532, __extension__ __PRETTY_FUNCTION__))
;
533 return buildCast(Dst, Src);
534 }
535
536 auto Extract = buildInstr(TargetOpcode::G_EXTRACT);
537 Dst.addDefToMIB(*getMRI(), Extract);
538 Src.addSrcToMIB(Extract);
539 Extract.addImm(Index);
540 return Extract;
541}
542
543void MachineIRBuilder::buildSequence(Register Res, ArrayRef<Register> Ops,
544 ArrayRef<uint64_t> Indices) {
545#ifndef NDEBUG
546 assert(Ops.size() == Indices.size() && "incompatible args")(static_cast <bool> (Ops.size() == Indices.size() &&
"incompatible args") ? void (0) : __assert_fail ("Ops.size() == Indices.size() && \"incompatible args\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 546, __extension__ __PRETTY_FUNCTION__))
;
547 assert(!Ops.empty() && "invalid trivial sequence")(static_cast <bool> (!Ops.empty() && "invalid trivial sequence"
) ? void (0) : __assert_fail ("!Ops.empty() && \"invalid trivial sequence\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 547, __extension__ __PRETTY_FUNCTION__))
;
548 assert(llvm::is_sorted(Indices) &&(static_cast <bool> (llvm::is_sorted(Indices) &&
"sequence offsets must be in ascending order") ? void (0) : __assert_fail
("llvm::is_sorted(Indices) && \"sequence offsets must be in ascending order\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 549, __extension__ __PRETTY_FUNCTION__))
549 "sequence offsets must be in ascending order")(static_cast <bool> (llvm::is_sorted(Indices) &&
"sequence offsets must be in ascending order") ? void (0) : __assert_fail
("llvm::is_sorted(Indices) && \"sequence offsets must be in ascending order\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 549, __extension__ __PRETTY_FUNCTION__))
;
550
551 assert(getMRI()->getType(Res).isValid() && "invalid operand type")(static_cast <bool> (getMRI()->getType(Res).isValid(
) && "invalid operand type") ? void (0) : __assert_fail
("getMRI()->getType(Res).isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 551, __extension__ __PRETTY_FUNCTION__))
;
552 for (auto Op : Ops)
553 assert(getMRI()->getType(Op).isValid() && "invalid operand type")(static_cast <bool> (getMRI()->getType(Op).isValid()
&& "invalid operand type") ? void (0) : __assert_fail
("getMRI()->getType(Op).isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 553, __extension__ __PRETTY_FUNCTION__))
;
554#endif
555
556 LLT ResTy = getMRI()->getType(Res);
557 LLT OpTy = getMRI()->getType(Ops[0]);
558 unsigned OpSize = OpTy.getSizeInBits();
559 bool MaybeMerge = true;
560 for (unsigned i = 0; i < Ops.size(); ++i) {
561 if (getMRI()->getType(Ops[i]) != OpTy || Indices[i] != i * OpSize) {
562 MaybeMerge = false;
563 break;
564 }
565 }
566
567 if (MaybeMerge && Ops.size() * OpSize == ResTy.getSizeInBits()) {
568 buildMerge(Res, Ops);
569 return;
570 }
571
572 Register ResIn = getMRI()->createGenericVirtualRegister(ResTy);
573 buildUndef(ResIn);
574
575 for (unsigned i = 0; i < Ops.size(); ++i) {
576 Register ResOut = i + 1 == Ops.size()
577 ? Res
578 : getMRI()->createGenericVirtualRegister(ResTy);
579 buildInsert(ResOut, ResIn, Ops[i], Indices[i]);
580 ResIn = ResOut;
581 }
582}
583
584MachineInstrBuilder MachineIRBuilder::buildUndef(const DstOp &Res) {
585 return buildInstr(TargetOpcode::G_IMPLICIT_DEF, {Res}, {});
586}
587
588MachineInstrBuilder MachineIRBuilder::buildMerge(const DstOp &Res,
589 ArrayRef<Register> Ops) {
590 // Unfortunately to convert from ArrayRef<LLT> to ArrayRef<SrcOp>,
591 // we need some temporary storage for the DstOp objects. Here we use a
592 // sufficiently large SmallVector to not go through the heap.
593 SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
594 assert(TmpVec.size() > 1)(static_cast <bool> (TmpVec.size() > 1) ? void (0) :
__assert_fail ("TmpVec.size() > 1", "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 594, __extension__ __PRETTY_FUNCTION__))
;
595 return buildInstr(TargetOpcode::G_MERGE_VALUES, Res, TmpVec);
596}
597
598MachineInstrBuilder
599MachineIRBuilder::buildMerge(const DstOp &Res,
600 std::initializer_list<SrcOp> Ops) {
601 assert(Ops.size() > 1)(static_cast <bool> (Ops.size() > 1) ? void (0) : __assert_fail
("Ops.size() > 1", "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 601, __extension__ __PRETTY_FUNCTION__))
;
602 return buildInstr(TargetOpcode::G_MERGE_VALUES, Res, Ops);
603}
604
605MachineInstrBuilder MachineIRBuilder::buildUnmerge(ArrayRef<LLT> Res,
606 const SrcOp &Op) {
607 // Unfortunately to convert from ArrayRef<LLT> to ArrayRef<DstOp>,
608 // we need some temporary storage for the DstOp objects. Here we use a
609 // sufficiently large SmallVector to not go through the heap.
610 SmallVector<DstOp, 8> TmpVec(Res.begin(), Res.end());
611 assert(TmpVec.size() > 1)(static_cast <bool> (TmpVec.size() > 1) ? void (0) :
__assert_fail ("TmpVec.size() > 1", "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 611, __extension__ __PRETTY_FUNCTION__))
;
612 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec, Op);
613}
614
615MachineInstrBuilder MachineIRBuilder::buildUnmerge(LLT Res,
616 const SrcOp &Op) {
617 unsigned NumReg = Op.getLLTTy(*getMRI()).getSizeInBits() / Res.getSizeInBits();
1
Calling 'LLT::getSizeInBits'
4
Returning from 'LLT::getSizeInBits'
5
Division by zero
618 SmallVector<Register, 8> TmpVec;
619 for (unsigned I = 0; I != NumReg; ++I)
620 TmpVec.push_back(getMRI()->createGenericVirtualRegister(Res));
621 return buildUnmerge(TmpVec, Op);
622}
623
624MachineInstrBuilder MachineIRBuilder::buildUnmerge(ArrayRef<Register> Res,
625 const SrcOp &Op) {
626 // Unfortunately to convert from ArrayRef<Register> to ArrayRef<DstOp>,
627 // we need some temporary storage for the DstOp objects. Here we use a
628 // sufficiently large SmallVector to not go through the heap.
629 SmallVector<DstOp, 8> TmpVec(Res.begin(), Res.end());
630 assert(TmpVec.size() > 1)(static_cast <bool> (TmpVec.size() > 1) ? void (0) :
__assert_fail ("TmpVec.size() > 1", "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 630, __extension__ __PRETTY_FUNCTION__))
;
631 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec, Op);
632}
633
634MachineInstrBuilder MachineIRBuilder::buildBuildVector(const DstOp &Res,
635 ArrayRef<Register> Ops) {
636 // Unfortunately to convert from ArrayRef<Register> to ArrayRef<SrcOp>,
637 // we need some temporary storage for the DstOp objects. Here we use a
638 // sufficiently large SmallVector to not go through the heap.
639 SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
640 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
641}
642
643MachineInstrBuilder MachineIRBuilder::buildSplatVector(const DstOp &Res,
644 const SrcOp &Src) {
645 SmallVector<SrcOp, 8> TmpVec(Res.getLLTTy(*getMRI()).getNumElements(), Src);
646 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
647}
648
649MachineInstrBuilder
650MachineIRBuilder::buildBuildVectorTrunc(const DstOp &Res,
651 ArrayRef<Register> Ops) {
652 // Unfortunately to convert from ArrayRef<Register> to ArrayRef<SrcOp>,
653 // we need some temporary storage for the DstOp objects. Here we use a
654 // sufficiently large SmallVector to not go through the heap.
655 SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
656 return buildInstr(TargetOpcode::G_BUILD_VECTOR_TRUNC, Res, TmpVec);
657}
658
659MachineInstrBuilder MachineIRBuilder::buildShuffleSplat(const DstOp &Res,
660 const SrcOp &Src) {
661 LLT DstTy = Res.getLLTTy(*getMRI());
662 assert(Src.getLLTTy(*getMRI()) == DstTy.getElementType() &&(static_cast <bool> (Src.getLLTTy(*getMRI()) == DstTy.getElementType
() && "Expected Src to match Dst elt ty") ? void (0) :
__assert_fail ("Src.getLLTTy(*getMRI()) == DstTy.getElementType() && \"Expected Src to match Dst elt ty\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 663, __extension__ __PRETTY_FUNCTION__))
663 "Expected Src to match Dst elt ty")(static_cast <bool> (Src.getLLTTy(*getMRI()) == DstTy.getElementType
() && "Expected Src to match Dst elt ty") ? void (0) :
__assert_fail ("Src.getLLTTy(*getMRI()) == DstTy.getElementType() && \"Expected Src to match Dst elt ty\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 663, __extension__ __PRETTY_FUNCTION__))
;
664 auto UndefVec = buildUndef(DstTy);
665 auto Zero = buildConstant(LLT::scalar(64), 0);
666 auto InsElt = buildInsertVectorElement(DstTy, UndefVec, Src, Zero);
667 SmallVector<int, 16> ZeroMask(DstTy.getNumElements());
668 return buildShuffleVector(DstTy, InsElt, UndefVec, ZeroMask);
669}
670
671MachineInstrBuilder MachineIRBuilder::buildShuffleVector(const DstOp &Res,
672 const SrcOp &Src1,
673 const SrcOp &Src2,
674 ArrayRef<int> Mask) {
675 LLT DstTy = Res.getLLTTy(*getMRI());
676 LLT Src1Ty = Src1.getLLTTy(*getMRI());
677 LLT Src2Ty = Src2.getLLTTy(*getMRI());
678 assert(Src1Ty.getNumElements() + Src2Ty.getNumElements() >= Mask.size())(static_cast <bool> (Src1Ty.getNumElements() + Src2Ty.getNumElements
() >= Mask.size()) ? void (0) : __assert_fail ("Src1Ty.getNumElements() + Src2Ty.getNumElements() >= Mask.size()"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 678, __extension__ __PRETTY_FUNCTION__))
;
679 assert(DstTy.getElementType() == Src1Ty.getElementType() &&(static_cast <bool> (DstTy.getElementType() == Src1Ty.getElementType
() && DstTy.getElementType() == Src2Ty.getElementType
()) ? void (0) : __assert_fail ("DstTy.getElementType() == Src1Ty.getElementType() && DstTy.getElementType() == Src2Ty.getElementType()"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 680, __extension__ __PRETTY_FUNCTION__))
680 DstTy.getElementType() == Src2Ty.getElementType())(static_cast <bool> (DstTy.getElementType() == Src1Ty.getElementType
() && DstTy.getElementType() == Src2Ty.getElementType
()) ? void (0) : __assert_fail ("DstTy.getElementType() == Src1Ty.getElementType() && DstTy.getElementType() == Src2Ty.getElementType()"
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 680, __extension__ __PRETTY_FUNCTION__))
;
681 (void)DstTy;
682 (void)Src1Ty;
683 (void)Src2Ty;
684 ArrayRef<int> MaskAlloc = getMF().allocateShuffleMask(Mask);
685 return buildInstr(TargetOpcode::G_SHUFFLE_VECTOR, {Res}, {Src1, Src2})
686 .addShuffleMask(MaskAlloc);
687}
688
689MachineInstrBuilder
690MachineIRBuilder::buildConcatVectors(const DstOp &Res, ArrayRef<Register> Ops) {
691 // Unfortunately to convert from ArrayRef<Register> to ArrayRef<SrcOp>,
692 // we need some temporary storage for the DstOp objects. Here we use a
693 // sufficiently large SmallVector to not go through the heap.
694 SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
695 return buildInstr(TargetOpcode::G_CONCAT_VECTORS, Res, TmpVec);
696}
697
698MachineInstrBuilder MachineIRBuilder::buildInsert(const DstOp &Res,
699 const SrcOp &Src,
700 const SrcOp &Op,
701 unsigned Index) {
702 assert(Index + Op.getLLTTy(*getMRI()).getSizeInBits() <=(static_cast <bool> (Index + Op.getLLTTy(*getMRI()).getSizeInBits
() <= Res.getLLTTy(*getMRI()).getSizeInBits() && "insertion past the end of a register"
) ? void (0) : __assert_fail ("Index + Op.getLLTTy(*getMRI()).getSizeInBits() <= Res.getLLTTy(*getMRI()).getSizeInBits() && \"insertion past the end of a register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 704, __extension__ __PRETTY_FUNCTION__))
703 Res.getLLTTy(*getMRI()).getSizeInBits() &&(static_cast <bool> (Index + Op.getLLTTy(*getMRI()).getSizeInBits
() <= Res.getLLTTy(*getMRI()).getSizeInBits() && "insertion past the end of a register"
) ? void (0) : __assert_fail ("Index + Op.getLLTTy(*getMRI()).getSizeInBits() <= Res.getLLTTy(*getMRI()).getSizeInBits() && \"insertion past the end of a register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 704, __extension__ __PRETTY_FUNCTION__))
704 "insertion past the end of a register")(static_cast <bool> (Index + Op.getLLTTy(*getMRI()).getSizeInBits
() <= Res.getLLTTy(*getMRI()).getSizeInBits() && "insertion past the end of a register"
) ? void (0) : __assert_fail ("Index + Op.getLLTTy(*getMRI()).getSizeInBits() <= Res.getLLTTy(*getMRI()).getSizeInBits() && \"insertion past the end of a register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 704, __extension__ __PRETTY_FUNCTION__))
;
705
706 if (Res.getLLTTy(*getMRI()).getSizeInBits() ==
707 Op.getLLTTy(*getMRI()).getSizeInBits()) {
708 return buildCast(Res, Op);
709 }
710
711 return buildInstr(TargetOpcode::G_INSERT, Res, {Src, Op, uint64_t(Index)});
712}
713
714MachineInstrBuilder MachineIRBuilder::buildIntrinsic(Intrinsic::ID ID,
715 ArrayRef<Register> ResultRegs,
716 bool HasSideEffects) {
717 auto MIB =
718 buildInstr(HasSideEffects ? TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS
719 : TargetOpcode::G_INTRINSIC);
720 for (unsigned ResultReg : ResultRegs)
721 MIB.addDef(ResultReg);
722 MIB.addIntrinsicID(ID);
723 return MIB;
724}
725
726MachineInstrBuilder MachineIRBuilder::buildIntrinsic(Intrinsic::ID ID,
727 ArrayRef<DstOp> Results,
728 bool HasSideEffects) {
729 auto MIB =
730 buildInstr(HasSideEffects ? TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS
731 : TargetOpcode::G_INTRINSIC);
732 for (DstOp Result : Results)
733 Result.addDefToMIB(*getMRI(), MIB);
734 MIB.addIntrinsicID(ID);
735 return MIB;
736}
737
738MachineInstrBuilder MachineIRBuilder::buildTrunc(const DstOp &Res,
739 const SrcOp &Op) {
740 return buildInstr(TargetOpcode::G_TRUNC, Res, Op);
741}
742
743MachineInstrBuilder MachineIRBuilder::buildFPTrunc(const DstOp &Res,
744 const SrcOp &Op,
745 Optional<unsigned> Flags) {
746 return buildInstr(TargetOpcode::G_FPTRUNC, Res, Op, Flags);
747}
748
749MachineInstrBuilder MachineIRBuilder::buildICmp(CmpInst::Predicate Pred,
750 const DstOp &Res,
751 const SrcOp &Op0,
752 const SrcOp &Op1) {
753 return buildInstr(TargetOpcode::G_ICMP, Res, {Pred, Op0, Op1});
754}
755
756MachineInstrBuilder MachineIRBuilder::buildFCmp(CmpInst::Predicate Pred,
757 const DstOp &Res,
758 const SrcOp &Op0,
759 const SrcOp &Op1,
760 Optional<unsigned> Flags) {
761
762 return buildInstr(TargetOpcode::G_FCMP, Res, {Pred, Op0, Op1}, Flags);
763}
764
765MachineInstrBuilder MachineIRBuilder::buildSelect(const DstOp &Res,
766 const SrcOp &Tst,
767 const SrcOp &Op0,
768 const SrcOp &Op1,
769 Optional<unsigned> Flags) {
770
771 return buildInstr(TargetOpcode::G_SELECT, {Res}, {Tst, Op0, Op1}, Flags);
772}
773
774MachineInstrBuilder
775MachineIRBuilder::buildInsertVectorElement(const DstOp &Res, const SrcOp &Val,
776 const SrcOp &Elt, const SrcOp &Idx) {
777 return buildInstr(TargetOpcode::G_INSERT_VECTOR_ELT, Res, {Val, Elt, Idx});
778}
779
780MachineInstrBuilder
781MachineIRBuilder::buildExtractVectorElement(const DstOp &Res, const SrcOp &Val,
782 const SrcOp &Idx) {
783 return buildInstr(TargetOpcode::G_EXTRACT_VECTOR_ELT, Res, {Val, Idx});
784}
785
786MachineInstrBuilder MachineIRBuilder::buildAtomicCmpXchgWithSuccess(
787 Register OldValRes, Register SuccessRes, Register Addr, Register CmpVal,
788 Register NewVal, MachineMemOperand &MMO) {
789#ifndef NDEBUG
790 LLT OldValResTy = getMRI()->getType(OldValRes);
791 LLT SuccessResTy = getMRI()->getType(SuccessRes);
792 LLT AddrTy = getMRI()->getType(Addr);
793 LLT CmpValTy = getMRI()->getType(CmpVal);
794 LLT NewValTy = getMRI()->getType(NewVal);
795 assert(OldValResTy.isScalar() && "invalid operand type")(static_cast <bool> (OldValResTy.isScalar() && "invalid operand type"
) ? void (0) : __assert_fail ("OldValResTy.isScalar() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 795, __extension__ __PRETTY_FUNCTION__))
;
796 assert(SuccessResTy.isScalar() && "invalid operand type")(static_cast <bool> (SuccessResTy.isScalar() &&
"invalid operand type") ? void (0) : __assert_fail ("SuccessResTy.isScalar() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 796, __extension__ __PRETTY_FUNCTION__))
;
797 assert(AddrTy.isPointer() && "invalid operand type")(static_cast <bool> (AddrTy.isPointer() && "invalid operand type"
) ? void (0) : __assert_fail ("AddrTy.isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 797, __extension__ __PRETTY_FUNCTION__))
;
798 assert(CmpValTy.isValid() && "invalid operand type")(static_cast <bool> (CmpValTy.isValid() && "invalid operand type"
) ? void (0) : __assert_fail ("CmpValTy.isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 798, __extension__ __PRETTY_FUNCTION__))
;
799 assert(NewValTy.isValid() && "invalid operand type")(static_cast <bool> (NewValTy.isValid() && "invalid operand type"
) ? void (0) : __assert_fail ("NewValTy.isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 799, __extension__ __PRETTY_FUNCTION__))
;
800 assert(OldValResTy == CmpValTy && "type mismatch")(static_cast <bool> (OldValResTy == CmpValTy &&
"type mismatch") ? void (0) : __assert_fail ("OldValResTy == CmpValTy && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 800, __extension__ __PRETTY_FUNCTION__))
;
801 assert(OldValResTy == NewValTy && "type mismatch")(static_cast <bool> (OldValResTy == NewValTy &&
"type mismatch") ? void (0) : __assert_fail ("OldValResTy == NewValTy && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 801, __extension__ __PRETTY_FUNCTION__))
;
802#endif
803
804 return buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG_WITH_SUCCESS)
805 .addDef(OldValRes)
806 .addDef(SuccessRes)
807 .addUse(Addr)
808 .addUse(CmpVal)
809 .addUse(NewVal)
810 .addMemOperand(&MMO);
811}
812
813MachineInstrBuilder
814MachineIRBuilder::buildAtomicCmpXchg(Register OldValRes, Register Addr,
815 Register CmpVal, Register NewVal,
816 MachineMemOperand &MMO) {
817#ifndef NDEBUG
818 LLT OldValResTy = getMRI()->getType(OldValRes);
819 LLT AddrTy = getMRI()->getType(Addr);
820 LLT CmpValTy = getMRI()->getType(CmpVal);
821 LLT NewValTy = getMRI()->getType(NewVal);
822 assert(OldValResTy.isScalar() && "invalid operand type")(static_cast <bool> (OldValResTy.isScalar() && "invalid operand type"
) ? void (0) : __assert_fail ("OldValResTy.isScalar() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 822, __extension__ __PRETTY_FUNCTION__))
;
823 assert(AddrTy.isPointer() && "invalid operand type")(static_cast <bool> (AddrTy.isPointer() && "invalid operand type"
) ? void (0) : __assert_fail ("AddrTy.isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 823, __extension__ __PRETTY_FUNCTION__))
;
824 assert(CmpValTy.isValid() && "invalid operand type")(static_cast <bool> (CmpValTy.isValid() && "invalid operand type"
) ? void (0) : __assert_fail ("CmpValTy.isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 824, __extension__ __PRETTY_FUNCTION__))
;
825 assert(NewValTy.isValid() && "invalid operand type")(static_cast <bool> (NewValTy.isValid() && "invalid operand type"
) ? void (0) : __assert_fail ("NewValTy.isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 825, __extension__ __PRETTY_FUNCTION__))
;
826 assert(OldValResTy == CmpValTy && "type mismatch")(static_cast <bool> (OldValResTy == CmpValTy &&
"type mismatch") ? void (0) : __assert_fail ("OldValResTy == CmpValTy && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 826, __extension__ __PRETTY_FUNCTION__))
;
827 assert(OldValResTy == NewValTy && "type mismatch")(static_cast <bool> (OldValResTy == NewValTy &&
"type mismatch") ? void (0) : __assert_fail ("OldValResTy == NewValTy && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 827, __extension__ __PRETTY_FUNCTION__))
;
828#endif
829
830 return buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG)
831 .addDef(OldValRes)
832 .addUse(Addr)
833 .addUse(CmpVal)
834 .addUse(NewVal)
835 .addMemOperand(&MMO);
836}
837
838MachineInstrBuilder MachineIRBuilder::buildAtomicRMW(
839 unsigned Opcode, const DstOp &OldValRes,
840 const SrcOp &Addr, const SrcOp &Val,
841 MachineMemOperand &MMO) {
842
843#ifndef NDEBUG
844 LLT OldValResTy = OldValRes.getLLTTy(*getMRI());
845 LLT AddrTy = Addr.getLLTTy(*getMRI());
846 LLT ValTy = Val.getLLTTy(*getMRI());
847 assert(OldValResTy.isScalar() && "invalid operand type")(static_cast <bool> (OldValResTy.isScalar() && "invalid operand type"
) ? void (0) : __assert_fail ("OldValResTy.isScalar() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 847, __extension__ __PRETTY_FUNCTION__))
;
848 assert(AddrTy.isPointer() && "invalid operand type")(static_cast <bool> (AddrTy.isPointer() && "invalid operand type"
) ? void (0) : __assert_fail ("AddrTy.isPointer() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 848, __extension__ __PRETTY_FUNCTION__))
;
849 assert(ValTy.isValid() && "invalid operand type")(static_cast <bool> (ValTy.isValid() && "invalid operand type"
) ? void (0) : __assert_fail ("ValTy.isValid() && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 849, __extension__ __PRETTY_FUNCTION__))
;
850 assert(OldValResTy == ValTy && "type mismatch")(static_cast <bool> (OldValResTy == ValTy && "type mismatch"
) ? void (0) : __assert_fail ("OldValResTy == ValTy && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 850, __extension__ __PRETTY_FUNCTION__))
;
851 assert(MMO.isAtomic() && "not atomic mem operand")(static_cast <bool> (MMO.isAtomic() && "not atomic mem operand"
) ? void (0) : __assert_fail ("MMO.isAtomic() && \"not atomic mem operand\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 851, __extension__ __PRETTY_FUNCTION__))
;
852#endif
853
854 auto MIB = buildInstr(Opcode);
855 OldValRes.addDefToMIB(*getMRI(), MIB);
856 Addr.addSrcToMIB(MIB);
857 Val.addSrcToMIB(MIB);
858 MIB.addMemOperand(&MMO);
859 return MIB;
860}
861
862MachineInstrBuilder
863MachineIRBuilder::buildAtomicRMWXchg(Register OldValRes, Register Addr,
864 Register Val, MachineMemOperand &MMO) {
865 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_XCHG, OldValRes, Addr, Val,
866 MMO);
867}
868MachineInstrBuilder
869MachineIRBuilder::buildAtomicRMWAdd(Register OldValRes, Register Addr,
870 Register Val, MachineMemOperand &MMO) {
871 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_ADD, OldValRes, Addr, Val,
872 MMO);
873}
874MachineInstrBuilder
875MachineIRBuilder::buildAtomicRMWSub(Register OldValRes, Register Addr,
876 Register Val, MachineMemOperand &MMO) {
877 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_SUB, OldValRes, Addr, Val,
878 MMO);
879}
880MachineInstrBuilder
881MachineIRBuilder::buildAtomicRMWAnd(Register OldValRes, Register Addr,
882 Register Val, MachineMemOperand &MMO) {
883 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_AND, OldValRes, Addr, Val,
884 MMO);
885}
886MachineInstrBuilder
887MachineIRBuilder::buildAtomicRMWNand(Register OldValRes, Register Addr,
888 Register Val, MachineMemOperand &MMO) {
889 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_NAND, OldValRes, Addr, Val,
890 MMO);
891}
892MachineInstrBuilder MachineIRBuilder::buildAtomicRMWOr(Register OldValRes,
893 Register Addr,
894 Register Val,
895 MachineMemOperand &MMO) {
896 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_OR, OldValRes, Addr, Val,
897 MMO);
898}
899MachineInstrBuilder
900MachineIRBuilder::buildAtomicRMWXor(Register OldValRes, Register Addr,
901 Register Val, MachineMemOperand &MMO) {
902 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_XOR, OldValRes, Addr, Val,
903 MMO);
904}
905MachineInstrBuilder
906MachineIRBuilder::buildAtomicRMWMax(Register OldValRes, Register Addr,
907 Register Val, MachineMemOperand &MMO) {
908 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_MAX, OldValRes, Addr, Val,
909 MMO);
910}
911MachineInstrBuilder
912MachineIRBuilder::buildAtomicRMWMin(Register OldValRes, Register Addr,
913 Register Val, MachineMemOperand &MMO) {
914 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_MIN, OldValRes, Addr, Val,
915 MMO);
916}
917MachineInstrBuilder
918MachineIRBuilder::buildAtomicRMWUmax(Register OldValRes, Register Addr,
919 Register Val, MachineMemOperand &MMO) {
920 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_UMAX, OldValRes, Addr, Val,
921 MMO);
922}
923MachineInstrBuilder
924MachineIRBuilder::buildAtomicRMWUmin(Register OldValRes, Register Addr,
925 Register Val, MachineMemOperand &MMO) {
926 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_UMIN, OldValRes, Addr, Val,
927 MMO);
928}
929
930MachineInstrBuilder
931MachineIRBuilder::buildAtomicRMWFAdd(
932 const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val,
933 MachineMemOperand &MMO) {
934 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FADD, OldValRes, Addr, Val,
935 MMO);
936}
937
938MachineInstrBuilder
939MachineIRBuilder::buildAtomicRMWFSub(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val,
940 MachineMemOperand &MMO) {
941 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FSUB, OldValRes, Addr, Val,
942 MMO);
943}
944
945MachineInstrBuilder
946MachineIRBuilder::buildFence(unsigned Ordering, unsigned Scope) {
947 return buildInstr(TargetOpcode::G_FENCE)
948 .addImm(Ordering)
949 .addImm(Scope);
950}
951
952MachineInstrBuilder
953MachineIRBuilder::buildBlockAddress(Register Res, const BlockAddress *BA) {
954#ifndef NDEBUG
955 assert(getMRI()->getType(Res).isPointer() && "invalid res type")(static_cast <bool> (getMRI()->getType(Res).isPointer
() && "invalid res type") ? void (0) : __assert_fail (
"getMRI()->getType(Res).isPointer() && \"invalid res type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 955, __extension__ __PRETTY_FUNCTION__))
;
956#endif
957
958 return buildInstr(TargetOpcode::G_BLOCK_ADDR).addDef(Res).addBlockAddress(BA);
959}
960
961void MachineIRBuilder::validateTruncExt(const LLT DstTy, const LLT SrcTy,
962 bool IsExtend) {
963#ifndef NDEBUG
964 if (DstTy.isVector()) {
965 assert(SrcTy.isVector() && "mismatched cast between vector and non-vector")(static_cast <bool> (SrcTy.isVector() && "mismatched cast between vector and non-vector"
) ? void (0) : __assert_fail ("SrcTy.isVector() && \"mismatched cast between vector and non-vector\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 965, __extension__ __PRETTY_FUNCTION__))
;
966 assert(SrcTy.getNumElements() == DstTy.getNumElements() &&(static_cast <bool> (SrcTy.getNumElements() == DstTy.getNumElements
() && "different number of elements in a trunc/ext") ?
void (0) : __assert_fail ("SrcTy.getNumElements() == DstTy.getNumElements() && \"different number of elements in a trunc/ext\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 967, __extension__ __PRETTY_FUNCTION__))
967 "different number of elements in a trunc/ext")(static_cast <bool> (SrcTy.getNumElements() == DstTy.getNumElements
() && "different number of elements in a trunc/ext") ?
void (0) : __assert_fail ("SrcTy.getNumElements() == DstTy.getNumElements() && \"different number of elements in a trunc/ext\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 967, __extension__ __PRETTY_FUNCTION__))
;
968 } else
969 assert(DstTy.isScalar() && SrcTy.isScalar() && "invalid extend/trunc")(static_cast <bool> (DstTy.isScalar() && SrcTy.
isScalar() && "invalid extend/trunc") ? void (0) : __assert_fail
("DstTy.isScalar() && SrcTy.isScalar() && \"invalid extend/trunc\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 969, __extension__ __PRETTY_FUNCTION__))
;
970
971 if (IsExtend)
972 assert(DstTy.getSizeInBits() > SrcTy.getSizeInBits() &&(static_cast <bool> (DstTy.getSizeInBits() > SrcTy.getSizeInBits
() && "invalid narrowing extend") ? void (0) : __assert_fail
("DstTy.getSizeInBits() > SrcTy.getSizeInBits() && \"invalid narrowing extend\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 973, __extension__ __PRETTY_FUNCTION__))
973 "invalid narrowing extend")(static_cast <bool> (DstTy.getSizeInBits() > SrcTy.getSizeInBits
() && "invalid narrowing extend") ? void (0) : __assert_fail
("DstTy.getSizeInBits() > SrcTy.getSizeInBits() && \"invalid narrowing extend\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 973, __extension__ __PRETTY_FUNCTION__))
;
974 else
975 assert(DstTy.getSizeInBits() < SrcTy.getSizeInBits() &&(static_cast <bool> (DstTy.getSizeInBits() < SrcTy.getSizeInBits
() && "invalid widening trunc") ? void (0) : __assert_fail
("DstTy.getSizeInBits() < SrcTy.getSizeInBits() && \"invalid widening trunc\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 976, __extension__ __PRETTY_FUNCTION__))
976 "invalid widening trunc")(static_cast <bool> (DstTy.getSizeInBits() < SrcTy.getSizeInBits
() && "invalid widening trunc") ? void (0) : __assert_fail
("DstTy.getSizeInBits() < SrcTy.getSizeInBits() && \"invalid widening trunc\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 976, __extension__ __PRETTY_FUNCTION__))
;
977#endif
978}
979
980void MachineIRBuilder::validateSelectOp(const LLT ResTy, const LLT TstTy,
981 const LLT Op0Ty, const LLT Op1Ty) {
982#ifndef NDEBUG
983 assert((ResTy.isScalar() || ResTy.isVector() || ResTy.isPointer()) &&(static_cast <bool> ((ResTy.isScalar() || ResTy.isVector
() || ResTy.isPointer()) && "invalid operand type") ?
void (0) : __assert_fail ("(ResTy.isScalar() || ResTy.isVector() || ResTy.isPointer()) && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 984, __extension__ __PRETTY_FUNCTION__))
984 "invalid operand type")(static_cast <bool> ((ResTy.isScalar() || ResTy.isVector
() || ResTy.isPointer()) && "invalid operand type") ?
void (0) : __assert_fail ("(ResTy.isScalar() || ResTy.isVector() || ResTy.isPointer()) && \"invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 984, __extension__ __PRETTY_FUNCTION__))
;
985 assert((ResTy == Op0Ty && ResTy == Op1Ty) && "type mismatch")(static_cast <bool> ((ResTy == Op0Ty && ResTy ==
Op1Ty) && "type mismatch") ? void (0) : __assert_fail
("(ResTy == Op0Ty && ResTy == Op1Ty) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 985, __extension__ __PRETTY_FUNCTION__))
;
986 if (ResTy.isScalar() || ResTy.isPointer())
987 assert(TstTy.isScalar() && "type mismatch")(static_cast <bool> (TstTy.isScalar() && "type mismatch"
) ? void (0) : __assert_fail ("TstTy.isScalar() && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 987, __extension__ __PRETTY_FUNCTION__))
;
988 else
989 assert((TstTy.isScalar() ||(static_cast <bool> ((TstTy.isScalar() || (TstTy.isVector
() && TstTy.getNumElements() == Op0Ty.getNumElements(
))) && "type mismatch") ? void (0) : __assert_fail ("(TstTy.isScalar() || (TstTy.isVector() && TstTy.getNumElements() == Op0Ty.getNumElements())) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 992, __extension__ __PRETTY_FUNCTION__))
990 (TstTy.isVector() &&(static_cast <bool> ((TstTy.isScalar() || (TstTy.isVector
() && TstTy.getNumElements() == Op0Ty.getNumElements(
))) && "type mismatch") ? void (0) : __assert_fail ("(TstTy.isScalar() || (TstTy.isVector() && TstTy.getNumElements() == Op0Ty.getNumElements())) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 992, __extension__ __PRETTY_FUNCTION__))
991 TstTy.getNumElements() == Op0Ty.getNumElements())) &&(static_cast <bool> ((TstTy.isScalar() || (TstTy.isVector
() && TstTy.getNumElements() == Op0Ty.getNumElements(
))) && "type mismatch") ? void (0) : __assert_fail ("(TstTy.isScalar() || (TstTy.isVector() && TstTy.getNumElements() == Op0Ty.getNumElements())) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 992, __extension__ __PRETTY_FUNCTION__))
992 "type mismatch")(static_cast <bool> ((TstTy.isScalar() || (TstTy.isVector
() && TstTy.getNumElements() == Op0Ty.getNumElements(
))) && "type mismatch") ? void (0) : __assert_fail ("(TstTy.isScalar() || (TstTy.isVector() && TstTy.getNumElements() == Op0Ty.getNumElements())) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 992, __extension__ __PRETTY_FUNCTION__))
;
993#endif
994}
995
996MachineInstrBuilder MachineIRBuilder::buildInstr(unsigned Opc,
997 ArrayRef<DstOp> DstOps,
998 ArrayRef<SrcOp> SrcOps,
999 Optional<unsigned> Flags) {
1000 switch (Opc) {
1001 default:
1002 break;
1003 case TargetOpcode::G_SELECT: {
1004 assert(DstOps.size() == 1 && "Invalid select")(static_cast <bool> (DstOps.size() == 1 && "Invalid select"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid select\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1004, __extension__ __PRETTY_FUNCTION__))
;
1005 assert(SrcOps.size() == 3 && "Invalid select")(static_cast <bool> (SrcOps.size() == 3 && "Invalid select"
) ? void (0) : __assert_fail ("SrcOps.size() == 3 && \"Invalid select\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1005, __extension__ __PRETTY_FUNCTION__))
;
1006 validateSelectOp(
1007 DstOps[0].getLLTTy(*getMRI()), SrcOps[0].getLLTTy(*getMRI()),
1008 SrcOps[1].getLLTTy(*getMRI()), SrcOps[2].getLLTTy(*getMRI()));
1009 break;
1010 }
1011 case TargetOpcode::G_FNEG:
1012 case TargetOpcode::G_ABS:
1013 // All these are unary ops.
1014 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1014, __extension__ __PRETTY_FUNCTION__))
;
1015 assert(SrcOps.size() == 1 && "Invalid Srcs")(static_cast <bool> (SrcOps.size() == 1 && "Invalid Srcs"
) ? void (0) : __assert_fail ("SrcOps.size() == 1 && \"Invalid Srcs\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1015, __extension__ __PRETTY_FUNCTION__))
;
1016 validateUnaryOp(DstOps[0].getLLTTy(*getMRI()),
1017 SrcOps[0].getLLTTy(*getMRI()));
1018 break;
1019 case TargetOpcode::G_ADD:
1020 case TargetOpcode::G_AND:
1021 case TargetOpcode::G_MUL:
1022 case TargetOpcode::G_OR:
1023 case TargetOpcode::G_SUB:
1024 case TargetOpcode::G_XOR:
1025 case TargetOpcode::G_UDIV:
1026 case TargetOpcode::G_SDIV:
1027 case TargetOpcode::G_UREM:
1028 case TargetOpcode::G_SREM:
1029 case TargetOpcode::G_SMIN:
1030 case TargetOpcode::G_SMAX:
1031 case TargetOpcode::G_UMIN:
1032 case TargetOpcode::G_UMAX:
1033 case TargetOpcode::G_UADDSAT:
1034 case TargetOpcode::G_SADDSAT:
1035 case TargetOpcode::G_USUBSAT:
1036 case TargetOpcode::G_SSUBSAT: {
1037 // All these are binary ops.
1038 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1038, __extension__ __PRETTY_FUNCTION__))
;
1039 assert(SrcOps.size() == 2 && "Invalid Srcs")(static_cast <bool> (SrcOps.size() == 2 && "Invalid Srcs"
) ? void (0) : __assert_fail ("SrcOps.size() == 2 && \"Invalid Srcs\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1039, __extension__ __PRETTY_FUNCTION__))
;
1040 validateBinaryOp(DstOps[0].getLLTTy(*getMRI()),
1041 SrcOps[0].getLLTTy(*getMRI()),
1042 SrcOps[1].getLLTTy(*getMRI()));
1043 break;
1044 }
1045 case TargetOpcode::G_SHL:
1046 case TargetOpcode::G_ASHR:
1047 case TargetOpcode::G_LSHR:
1048 case TargetOpcode::G_USHLSAT:
1049 case TargetOpcode::G_SSHLSAT: {
1050 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1050, __extension__ __PRETTY_FUNCTION__))
;
1051 assert(SrcOps.size() == 2 && "Invalid Srcs")(static_cast <bool> (SrcOps.size() == 2 && "Invalid Srcs"
) ? void (0) : __assert_fail ("SrcOps.size() == 2 && \"Invalid Srcs\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1051, __extension__ __PRETTY_FUNCTION__))
;
1052 validateShiftOp(DstOps[0].getLLTTy(*getMRI()),
1053 SrcOps[0].getLLTTy(*getMRI()),
1054 SrcOps[1].getLLTTy(*getMRI()));
1055 break;
1056 }
1057 case TargetOpcode::G_SEXT:
1058 case TargetOpcode::G_ZEXT:
1059 case TargetOpcode::G_ANYEXT:
1060 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1060, __extension__ __PRETTY_FUNCTION__))
;
1061 assert(SrcOps.size() == 1 && "Invalid Srcs")(static_cast <bool> (SrcOps.size() == 1 && "Invalid Srcs"
) ? void (0) : __assert_fail ("SrcOps.size() == 1 && \"Invalid Srcs\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1061, __extension__ __PRETTY_FUNCTION__))
;
1062 validateTruncExt(DstOps[0].getLLTTy(*getMRI()),
1063 SrcOps[0].getLLTTy(*getMRI()), true);
1064 break;
1065 case TargetOpcode::G_TRUNC:
1066 case TargetOpcode::G_FPTRUNC: {
1067 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1067, __extension__ __PRETTY_FUNCTION__))
;
1068 assert(SrcOps.size() == 1 && "Invalid Srcs")(static_cast <bool> (SrcOps.size() == 1 && "Invalid Srcs"
) ? void (0) : __assert_fail ("SrcOps.size() == 1 && \"Invalid Srcs\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1068, __extension__ __PRETTY_FUNCTION__))
;
1069 validateTruncExt(DstOps[0].getLLTTy(*getMRI()),
1070 SrcOps[0].getLLTTy(*getMRI()), false);
1071 break;
1072 }
1073 case TargetOpcode::G_BITCAST: {
1074 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1074, __extension__ __PRETTY_FUNCTION__))
;
1075 assert(SrcOps.size() == 1 && "Invalid Srcs")(static_cast <bool> (SrcOps.size() == 1 && "Invalid Srcs"
) ? void (0) : __assert_fail ("SrcOps.size() == 1 && \"Invalid Srcs\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1075, __extension__ __PRETTY_FUNCTION__))
;
1076 assert(DstOps[0].getLLTTy(*getMRI()).getSizeInBits() ==(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getSizeInBits
() == SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() &&
"invalid bitcast") ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"invalid bitcast\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1077, __extension__ __PRETTY_FUNCTION__))
1077 SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() && "invalid bitcast")(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getSizeInBits
() == SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() &&
"invalid bitcast") ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"invalid bitcast\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1077, __extension__ __PRETTY_FUNCTION__))
;
1078 break;
1079 }
1080 case TargetOpcode::COPY:
1081 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1081, __extension__ __PRETTY_FUNCTION__))
;
1082 // If the caller wants to add a subreg source it has to be done separately
1083 // so we may not have any SrcOps at this point yet.
1084 break;
1085 case TargetOpcode::G_FCMP:
1086 case TargetOpcode::G_ICMP: {
1087 assert(DstOps.size() == 1 && "Invalid Dst Operands")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst Operands"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst Operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1087, __extension__ __PRETTY_FUNCTION__))
;
1088 assert(SrcOps.size() == 3 && "Invalid Src Operands")(static_cast <bool> (SrcOps.size() == 3 && "Invalid Src Operands"
) ? void (0) : __assert_fail ("SrcOps.size() == 3 && \"Invalid Src Operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1088, __extension__ __PRETTY_FUNCTION__))
;
1089 // For F/ICMP, the first src operand is the predicate, followed by
1090 // the two comparands.
1091 assert(SrcOps[0].getSrcOpKind() == SrcOp::SrcType::Ty_Predicate &&(static_cast <bool> (SrcOps[0].getSrcOpKind() == SrcOp::
SrcType::Ty_Predicate && "Expecting predicate") ? void
(0) : __assert_fail ("SrcOps[0].getSrcOpKind() == SrcOp::SrcType::Ty_Predicate && \"Expecting predicate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1092, __extension__ __PRETTY_FUNCTION__))
1092 "Expecting predicate")(static_cast <bool> (SrcOps[0].getSrcOpKind() == SrcOp::
SrcType::Ty_Predicate && "Expecting predicate") ? void
(0) : __assert_fail ("SrcOps[0].getSrcOpKind() == SrcOp::SrcType::Ty_Predicate && \"Expecting predicate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1092, __extension__ __PRETTY_FUNCTION__))
;
1093 assert([&]() -> bool {(static_cast <bool> ([&]() -> bool { CmpInst::Predicate
Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::
G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate
(Pred); }() && "Invalid predicate") ? void (0) : __assert_fail
("[&]() -> bool { CmpInst::Predicate Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate(Pred); }() && \"Invalid predicate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1097, __extension__ __PRETTY_FUNCTION__))
1094 CmpInst::Predicate Pred = SrcOps[0].getPredicate();(static_cast <bool> ([&]() -> bool { CmpInst::Predicate
Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::
G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate
(Pred); }() && "Invalid predicate") ? void (0) : __assert_fail
("[&]() -> bool { CmpInst::Predicate Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate(Pred); }() && \"Invalid predicate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1097, __extension__ __PRETTY_FUNCTION__))
1095 return Opc == TargetOpcode::G_ICMP ? CmpInst::isIntPredicate(Pred)(static_cast <bool> ([&]() -> bool { CmpInst::Predicate
Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::
G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate
(Pred); }() && "Invalid predicate") ? void (0) : __assert_fail
("[&]() -> bool { CmpInst::Predicate Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate(Pred); }() && \"Invalid predicate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1097, __extension__ __PRETTY_FUNCTION__))
1096 : CmpInst::isFPPredicate(Pred);(static_cast <bool> ([&]() -> bool { CmpInst::Predicate
Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::
G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate
(Pred); }() && "Invalid predicate") ? void (0) : __assert_fail
("[&]() -> bool { CmpInst::Predicate Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate(Pred); }() && \"Invalid predicate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1097, __extension__ __PRETTY_FUNCTION__))
1097 }() && "Invalid predicate")(static_cast <bool> ([&]() -> bool { CmpInst::Predicate
Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::
G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate
(Pred); }() && "Invalid predicate") ? void (0) : __assert_fail
("[&]() -> bool { CmpInst::Predicate Pred = SrcOps[0].getPredicate(); return Opc == TargetOpcode::G_ICMP ? CmpInst::isIntPredicate(Pred) : CmpInst::isFPPredicate(Pred); }() && \"Invalid predicate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1097, __extension__ __PRETTY_FUNCTION__))
;
1098 assert(SrcOps[1].getLLTTy(*getMRI()) == SrcOps[2].getLLTTy(*getMRI()) &&(static_cast <bool> (SrcOps[1].getLLTTy(*getMRI()) == SrcOps
[2].getLLTTy(*getMRI()) && "Type mismatch") ? void (0
) : __assert_fail ("SrcOps[1].getLLTTy(*getMRI()) == SrcOps[2].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1099, __extension__ __PRETTY_FUNCTION__))
1099 "Type mismatch")(static_cast <bool> (SrcOps[1].getLLTTy(*getMRI()) == SrcOps
[2].getLLTTy(*getMRI()) && "Type mismatch") ? void (0
) : __assert_fail ("SrcOps[1].getLLTTy(*getMRI()) == SrcOps[2].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1099, __extension__ __PRETTY_FUNCTION__))
;
1100 assert([&]() -> bool {(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1101 LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI());(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1102 LLT DstTy = DstOps[0].getLLTTy(*getMRI());(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1103 if (Op0Ty.isScalar() || Op0Ty.isPointer())(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1104 return DstTy.isScalar();(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1105 else(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1106 return DstTy.isVector() &&(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1107 DstTy.getNumElements() == Op0Ty.getNumElements();(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
1108 }() && "Type Mismatch")(static_cast <bool> ([&]() -> bool { LLT Op0Ty =
SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy
(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return
DstTy.isScalar(); else return DstTy.isVector() && DstTy
.getNumElements() == Op0Ty.getNumElements(); }() && "Type Mismatch"
) ? void (0) : __assert_fail ("[&]() -> bool { LLT Op0Ty = SrcOps[1].getLLTTy(*getMRI()); LLT DstTy = DstOps[0].getLLTTy(*getMRI()); if (Op0Ty.isScalar() || Op0Ty.isPointer()) return DstTy.isScalar(); else return DstTy.isVector() && DstTy.getNumElements() == Op0Ty.getNumElements(); }() && \"Type Mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1108, __extension__ __PRETTY_FUNCTION__))
;
1109 break;
1110 }
1111 case TargetOpcode::G_UNMERGE_VALUES: {
1112 assert(!DstOps.empty() && "Invalid trivial sequence")(static_cast <bool> (!DstOps.empty() && "Invalid trivial sequence"
) ? void (0) : __assert_fail ("!DstOps.empty() && \"Invalid trivial sequence\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1112, __extension__ __PRETTY_FUNCTION__))
;
1113 assert(SrcOps.size() == 1 && "Invalid src for Unmerge")(static_cast <bool> (SrcOps.size() == 1 && "Invalid src for Unmerge"
) ? void (0) : __assert_fail ("SrcOps.size() == 1 && \"Invalid src for Unmerge\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1113, __extension__ __PRETTY_FUNCTION__))
;
1114 assert(llvm::all_of(DstOps,(static_cast <bool> (llvm::all_of(DstOps, [&, this]
(const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in output list"
) ? void (0) : __assert_fail ("llvm::all_of(DstOps, [&, this](const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in output list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1119, __extension__ __PRETTY_FUNCTION__))
1115 [&, this](const DstOp &Op) {(static_cast <bool> (llvm::all_of(DstOps, [&, this]
(const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in output list"
) ? void (0) : __assert_fail ("llvm::all_of(DstOps, [&, this](const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in output list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1119, __extension__ __PRETTY_FUNCTION__))
1116 return Op.getLLTTy(*getMRI()) ==(static_cast <bool> (llvm::all_of(DstOps, [&, this]
(const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in output list"
) ? void (0) : __assert_fail ("llvm::all_of(DstOps, [&, this](const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in output list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1119, __extension__ __PRETTY_FUNCTION__))
1117 DstOps[0].getLLTTy(*getMRI());(static_cast <bool> (llvm::all_of(DstOps, [&, this]
(const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in output list"
) ? void (0) : __assert_fail ("llvm::all_of(DstOps, [&, this](const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in output list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1119, __extension__ __PRETTY_FUNCTION__))
1118 }) &&(static_cast <bool> (llvm::all_of(DstOps, [&, this]
(const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in output list"
) ? void (0) : __assert_fail ("llvm::all_of(DstOps, [&, this](const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in output list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1119, __extension__ __PRETTY_FUNCTION__))
1119 "type mismatch in output list")(static_cast <bool> (llvm::all_of(DstOps, [&, this]
(const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in output list"
) ? void (0) : __assert_fail ("llvm::all_of(DstOps, [&, this](const DstOp &Op) { return Op.getLLTTy(*getMRI()) == DstOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in output list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1119, __extension__ __PRETTY_FUNCTION__))
;
1120 assert(DstOps.size() * DstOps[0].getLLTTy(*getMRI()).getSizeInBits() ==(static_cast <bool> (DstOps.size() * DstOps[0].getLLTTy
(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input operands do not cover output register"
) ? void (0) : __assert_fail ("DstOps.size() * DstOps[0].getLLTTy(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input operands do not cover output register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1122, __extension__ __PRETTY_FUNCTION__))
1121 SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() &&(static_cast <bool> (DstOps.size() * DstOps[0].getLLTTy
(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input operands do not cover output register"
) ? void (0) : __assert_fail ("DstOps.size() * DstOps[0].getLLTTy(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input operands do not cover output register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1122, __extension__ __PRETTY_FUNCTION__))
1122 "input operands do not cover output register")(static_cast <bool> (DstOps.size() * DstOps[0].getLLTTy
(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input operands do not cover output register"
) ? void (0) : __assert_fail ("DstOps.size() * DstOps[0].getLLTTy(*getMRI()).getSizeInBits() == SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input operands do not cover output register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1122, __extension__ __PRETTY_FUNCTION__))
;
1123 break;
1124 }
1125 case TargetOpcode::G_MERGE_VALUES: {
1126 assert(!SrcOps.empty() && "invalid trivial sequence")(static_cast <bool> (!SrcOps.empty() && "invalid trivial sequence"
) ? void (0) : __assert_fail ("!SrcOps.empty() && \"invalid trivial sequence\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1126, __extension__ __PRETTY_FUNCTION__))
;
1127 assert(DstOps.size() == 1 && "Invalid Dst")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1127, __extension__ __PRETTY_FUNCTION__))
;
1128 assert(llvm::all_of(SrcOps,(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1133, __extension__ __PRETTY_FUNCTION__))
1129 [&, this](const SrcOp &Op) {(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1133, __extension__ __PRETTY_FUNCTION__))
1130 return Op.getLLTTy(*getMRI()) ==(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1133, __extension__ __PRETTY_FUNCTION__))
1131 SrcOps[0].getLLTTy(*getMRI());(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1133, __extension__ __PRETTY_FUNCTION__))
1132 }) &&(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1133, __extension__ __PRETTY_FUNCTION__))
1133 "type mismatch in input list")(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1133, __extension__ __PRETTY_FUNCTION__))
;
1134 assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input operands do not cover output register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input operands do not cover output register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1136, __extension__ __PRETTY_FUNCTION__))
1135 DstOps[0].getLLTTy(*getMRI()).getSizeInBits() &&(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input operands do not cover output register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input operands do not cover output register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1136, __extension__ __PRETTY_FUNCTION__))
1136 "input operands do not cover output register")(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input operands do not cover output register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input operands do not cover output register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1136, __extension__ __PRETTY_FUNCTION__))
;
1137 if (SrcOps.size() == 1)
1138 return buildCast(DstOps[0], SrcOps[0]);
1139 if (DstOps[0].getLLTTy(*getMRI()).isVector()) {
1140 if (SrcOps[0].getLLTTy(*getMRI()).isVector())
1141 return buildInstr(TargetOpcode::G_CONCAT_VECTORS, DstOps, SrcOps);
1142 return buildInstr(TargetOpcode::G_BUILD_VECTOR, DstOps, SrcOps);
1143 }
1144 break;
1145 }
1146 case TargetOpcode::G_EXTRACT_VECTOR_ELT: {
1147 assert(DstOps.size() == 1 && "Invalid Dst size")(static_cast <bool> (DstOps.size() == 1 && "Invalid Dst size"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid Dst size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1147, __extension__ __PRETTY_FUNCTION__))
;
1148 assert(SrcOps.size() == 2 && "Invalid Src size")(static_cast <bool> (SrcOps.size() == 2 && "Invalid Src size"
) ? void (0) : __assert_fail ("SrcOps.size() == 2 && \"Invalid Src size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1148, __extension__ __PRETTY_FUNCTION__))
;
1149 assert(SrcOps[0].getLLTTy(*getMRI()).isVector() && "Invalid operand type")(static_cast <bool> (SrcOps[0].getLLTTy(*getMRI()).isVector
() && "Invalid operand type") ? void (0) : __assert_fail
("SrcOps[0].getLLTTy(*getMRI()).isVector() && \"Invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1149, __extension__ __PRETTY_FUNCTION__))
;
1150 assert((DstOps[0].getLLTTy(*getMRI()).isScalar() ||(static_cast <bool> ((DstOps[0].getLLTTy(*getMRI()).isScalar
() || DstOps[0].getLLTTy(*getMRI()).isPointer()) && "Invalid operand type"
) ? void (0) : __assert_fail ("(DstOps[0].getLLTTy(*getMRI()).isScalar() || DstOps[0].getLLTTy(*getMRI()).isPointer()) && \"Invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1152, __extension__ __PRETTY_FUNCTION__))
1151 DstOps[0].getLLTTy(*getMRI()).isPointer()) &&(static_cast <bool> ((DstOps[0].getLLTTy(*getMRI()).isScalar
() || DstOps[0].getLLTTy(*getMRI()).isPointer()) && "Invalid operand type"
) ? void (0) : __assert_fail ("(DstOps[0].getLLTTy(*getMRI()).isScalar() || DstOps[0].getLLTTy(*getMRI()).isPointer()) && \"Invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1152, __extension__ __PRETTY_FUNCTION__))
1152 "Invalid operand type")(static_cast <bool> ((DstOps[0].getLLTTy(*getMRI()).isScalar
() || DstOps[0].getLLTTy(*getMRI()).isPointer()) && "Invalid operand type"
) ? void (0) : __assert_fail ("(DstOps[0].getLLTTy(*getMRI()).isScalar() || DstOps[0].getLLTTy(*getMRI()).isPointer()) && \"Invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1152, __extension__ __PRETTY_FUNCTION__))
;
1153 assert(SrcOps[1].getLLTTy(*getMRI()).isScalar() && "Invalid operand type")(static_cast <bool> (SrcOps[1].getLLTTy(*getMRI()).isScalar
() && "Invalid operand type") ? void (0) : __assert_fail
("SrcOps[1].getLLTTy(*getMRI()).isScalar() && \"Invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1153, __extension__ __PRETTY_FUNCTION__))
;
1154 assert(SrcOps[0].getLLTTy(*getMRI()).getElementType() ==(static_cast <bool> (SrcOps[0].getLLTTy(*getMRI()).getElementType
() == DstOps[0].getLLTTy(*getMRI()) && "Type mismatch"
) ? void (0) : __assert_fail ("SrcOps[0].getLLTTy(*getMRI()).getElementType() == DstOps[0].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1156, __extension__ __PRETTY_FUNCTION__))
1155 DstOps[0].getLLTTy(*getMRI()) &&(static_cast <bool> (SrcOps[0].getLLTTy(*getMRI()).getElementType
() == DstOps[0].getLLTTy(*getMRI()) && "Type mismatch"
) ? void (0) : __assert_fail ("SrcOps[0].getLLTTy(*getMRI()).getElementType() == DstOps[0].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1156, __extension__ __PRETTY_FUNCTION__))
1156 "Type mismatch")(static_cast <bool> (SrcOps[0].getLLTTy(*getMRI()).getElementType
() == DstOps[0].getLLTTy(*getMRI()) && "Type mismatch"
) ? void (0) : __assert_fail ("SrcOps[0].getLLTTy(*getMRI()).getElementType() == DstOps[0].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1156, __extension__ __PRETTY_FUNCTION__))
;
1157 break;
1158 }
1159 case TargetOpcode::G_INSERT_VECTOR_ELT: {
1160 assert(DstOps.size() == 1 && "Invalid dst size")(static_cast <bool> (DstOps.size() == 1 && "Invalid dst size"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid dst size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1160, __extension__ __PRETTY_FUNCTION__))
;
1161 assert(SrcOps.size() == 3 && "Invalid src size")(static_cast <bool> (SrcOps.size() == 3 && "Invalid src size"
) ? void (0) : __assert_fail ("SrcOps.size() == 3 && \"Invalid src size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1161, __extension__ __PRETTY_FUNCTION__))
;
1162 assert(DstOps[0].getLLTTy(*getMRI()).isVector() &&(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).isVector
() && SrcOps[0].getLLTTy(*getMRI()).isVector() &&
"Invalid operand type") ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).isVector() && SrcOps[0].getLLTTy(*getMRI()).isVector() && \"Invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1163, __extension__ __PRETTY_FUNCTION__))
1163 SrcOps[0].getLLTTy(*getMRI()).isVector() && "Invalid operand type")(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).isVector
() && SrcOps[0].getLLTTy(*getMRI()).isVector() &&
"Invalid operand type") ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).isVector() && SrcOps[0].getLLTTy(*getMRI()).isVector() && \"Invalid operand type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1163, __extension__ __PRETTY_FUNCTION__))
;
1164 assert(DstOps[0].getLLTTy(*getMRI()).getElementType() ==(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getElementType
() == SrcOps[1].getLLTTy(*getMRI()) && "Type mismatch"
) ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getElementType() == SrcOps[1].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1166, __extension__ __PRETTY_FUNCTION__))
1165 SrcOps[1].getLLTTy(*getMRI()) &&(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getElementType
() == SrcOps[1].getLLTTy(*getMRI()) && "Type mismatch"
) ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getElementType() == SrcOps[1].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1166, __extension__ __PRETTY_FUNCTION__))
1166 "Type mismatch")(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getElementType
() == SrcOps[1].getLLTTy(*getMRI()) && "Type mismatch"
) ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getElementType() == SrcOps[1].getLLTTy(*getMRI()) && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1166, __extension__ __PRETTY_FUNCTION__))
;
1167 assert(SrcOps[2].getLLTTy(*getMRI()).isScalar() && "Invalid index")(static_cast <bool> (SrcOps[2].getLLTTy(*getMRI()).isScalar
() && "Invalid index") ? void (0) : __assert_fail ("SrcOps[2].getLLTTy(*getMRI()).isScalar() && \"Invalid index\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1167, __extension__ __PRETTY_FUNCTION__))
;
1168 assert(DstOps[0].getLLTTy(*getMRI()).getNumElements() ==(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getNumElements
() == SrcOps[0].getLLTTy(*getMRI()).getNumElements() &&
"Type mismatch") ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getNumElements() == SrcOps[0].getLLTTy(*getMRI()).getNumElements() && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1170, __extension__ __PRETTY_FUNCTION__))
1169 SrcOps[0].getLLTTy(*getMRI()).getNumElements() &&(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getNumElements
() == SrcOps[0].getLLTTy(*getMRI()).getNumElements() &&
"Type mismatch") ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getNumElements() == SrcOps[0].getLLTTy(*getMRI()).getNumElements() && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1170, __extension__ __PRETTY_FUNCTION__))
1170 "Type mismatch")(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).getNumElements
() == SrcOps[0].getLLTTy(*getMRI()).getNumElements() &&
"Type mismatch") ? void (0) : __assert_fail ("DstOps[0].getLLTTy(*getMRI()).getNumElements() == SrcOps[0].getLLTTy(*getMRI()).getNumElements() && \"Type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1170, __extension__ __PRETTY_FUNCTION__))
;
1171 break;
1172 }
1173 case TargetOpcode::G_BUILD_VECTOR: {
1174 assert((!SrcOps.empty() || SrcOps.size() < 2) &&(static_cast <bool> ((!SrcOps.empty() || SrcOps.size() <
2) && "Must have at least 2 operands") ? void (0) : __assert_fail
("(!SrcOps.empty() || SrcOps.size() < 2) && \"Must have at least 2 operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1175, __extension__ __PRETTY_FUNCTION__))
1175 "Must have at least 2 operands")(static_cast <bool> ((!SrcOps.empty() || SrcOps.size() <
2) && "Must have at least 2 operands") ? void (0) : __assert_fail
("(!SrcOps.empty() || SrcOps.size() < 2) && \"Must have at least 2 operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1175, __extension__ __PRETTY_FUNCTION__))
;
1176 assert(DstOps.size() == 1 && "Invalid DstOps")(static_cast <bool> (DstOps.size() == 1 && "Invalid DstOps"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid DstOps\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1176, __extension__ __PRETTY_FUNCTION__))
;
1177 assert(DstOps[0].getLLTTy(*getMRI()).isVector() &&(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).isVector
() && "Res type must be a vector") ? void (0) : __assert_fail
("DstOps[0].getLLTTy(*getMRI()).isVector() && \"Res type must be a vector\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1178, __extension__ __PRETTY_FUNCTION__))
1178 "Res type must be a vector")(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).isVector
() && "Res type must be a vector") ? void (0) : __assert_fail
("DstOps[0].getLLTTy(*getMRI()).isVector() && \"Res type must be a vector\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1178, __extension__ __PRETTY_FUNCTION__))
;
1179 assert(llvm::all_of(SrcOps,(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1184, __extension__ __PRETTY_FUNCTION__))
1180 [&, this](const SrcOp &Op) {(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1184, __extension__ __PRETTY_FUNCTION__))
1181 return Op.getLLTTy(*getMRI()) ==(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1184, __extension__ __PRETTY_FUNCTION__))
1182 SrcOps[0].getLLTTy(*getMRI());(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1184, __extension__ __PRETTY_FUNCTION__))
1183 }) &&(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1184, __extension__ __PRETTY_FUNCTION__))
1184 "type mismatch in input list")(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1184, __extension__ __PRETTY_FUNCTION__))
;
1185 assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input scalars do not exactly cover the output vector register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input scalars do not exactly cover the output vector register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1187, __extension__ __PRETTY_FUNCTION__))
1186 DstOps[0].getLLTTy(*getMRI()).getSizeInBits() &&(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input scalars do not exactly cover the output vector register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input scalars do not exactly cover the output vector register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1187, __extension__ __PRETTY_FUNCTION__))
1187 "input scalars do not exactly cover the output vector register")(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input scalars do not exactly cover the output vector register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input scalars do not exactly cover the output vector register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1187, __extension__ __PRETTY_FUNCTION__))
;
1188 break;
1189 }
1190 case TargetOpcode::G_BUILD_VECTOR_TRUNC: {
1191 assert((!SrcOps.empty() || SrcOps.size() < 2) &&(static_cast <bool> ((!SrcOps.empty() || SrcOps.size() <
2) && "Must have at least 2 operands") ? void (0) : __assert_fail
("(!SrcOps.empty() || SrcOps.size() < 2) && \"Must have at least 2 operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1192, __extension__ __PRETTY_FUNCTION__))
1192 "Must have at least 2 operands")(static_cast <bool> ((!SrcOps.empty() || SrcOps.size() <
2) && "Must have at least 2 operands") ? void (0) : __assert_fail
("(!SrcOps.empty() || SrcOps.size() < 2) && \"Must have at least 2 operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1192, __extension__ __PRETTY_FUNCTION__))
;
1193 assert(DstOps.size() == 1 && "Invalid DstOps")(static_cast <bool> (DstOps.size() == 1 && "Invalid DstOps"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid DstOps\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1193, __extension__ __PRETTY_FUNCTION__))
;
1194 assert(DstOps[0].getLLTTy(*getMRI()).isVector() &&(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).isVector
() && "Res type must be a vector") ? void (0) : __assert_fail
("DstOps[0].getLLTTy(*getMRI()).isVector() && \"Res type must be a vector\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1195, __extension__ __PRETTY_FUNCTION__))
1195 "Res type must be a vector")(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).isVector
() && "Res type must be a vector") ? void (0) : __assert_fail
("DstOps[0].getLLTTy(*getMRI()).isVector() && \"Res type must be a vector\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1195, __extension__ __PRETTY_FUNCTION__))
;
1196 assert(llvm::all_of(SrcOps,(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1201, __extension__ __PRETTY_FUNCTION__))
1197 [&, this](const SrcOp &Op) {(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1201, __extension__ __PRETTY_FUNCTION__))
1198 return Op.getLLTTy(*getMRI()) ==(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1201, __extension__ __PRETTY_FUNCTION__))
1199 SrcOps[0].getLLTTy(*getMRI());(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1201, __extension__ __PRETTY_FUNCTION__))
1200 }) &&(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1201, __extension__ __PRETTY_FUNCTION__))
1201 "type mismatch in input list")(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI()); }) && "type mismatch in input list"
) ? void (0) : __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI()); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1201, __extension__ __PRETTY_FUNCTION__))
;
1202 if (SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==
1203 DstOps[0].getLLTTy(*getMRI()).getElementType().getSizeInBits())
1204 return buildInstr(TargetOpcode::G_BUILD_VECTOR, DstOps, SrcOps);
1205 break;
1206 }
1207 case TargetOpcode::G_CONCAT_VECTORS: {
1208 assert(DstOps.size() == 1 && "Invalid DstOps")(static_cast <bool> (DstOps.size() == 1 && "Invalid DstOps"
) ? void (0) : __assert_fail ("DstOps.size() == 1 && \"Invalid DstOps\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1208, __extension__ __PRETTY_FUNCTION__))
;
1209 assert((!SrcOps.empty() || SrcOps.size() < 2) &&(static_cast <bool> ((!SrcOps.empty() || SrcOps.size() <
2) && "Must have at least 2 operands") ? void (0) : __assert_fail
("(!SrcOps.empty() || SrcOps.size() < 2) && \"Must have at least 2 operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1210, __extension__ __PRETTY_FUNCTION__))
1210 "Must have at least 2 operands")(static_cast <bool> ((!SrcOps.empty() || SrcOps.size() <
2) && "Must have at least 2 operands") ? void (0) : __assert_fail
("(!SrcOps.empty() || SrcOps.size() < 2) && \"Must have at least 2 operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1210, __extension__ __PRETTY_FUNCTION__))
;
1211 assert(llvm::all_of(SrcOps,(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector
() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI
())); }) && "type mismatch in input list") ? void (0)
: __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1217, __extension__ __PRETTY_FUNCTION__))
1212 [&, this](const SrcOp &Op) {(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector
() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI
())); }) && "type mismatch in input list") ? void (0)
: __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1217, __extension__ __PRETTY_FUNCTION__))
1213 return (Op.getLLTTy(*getMRI()).isVector() &&(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector
() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI
())); }) && "type mismatch in input list") ? void (0)
: __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1217, __extension__ __PRETTY_FUNCTION__))
1214 Op.getLLTTy(*getMRI()) ==(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector
() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI
())); }) && "type mismatch in input list") ? void (0)
: __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1217, __extension__ __PRETTY_FUNCTION__))
1215 SrcOps[0].getLLTTy(*getMRI()));(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector
() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI
())); }) && "type mismatch in input list") ? void (0)
: __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1217, __extension__ __PRETTY_FUNCTION__))
1216 }) &&(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector
() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI
())); }) && "type mismatch in input list") ? void (0)
: __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1217, __extension__ __PRETTY_FUNCTION__))
1217 "type mismatch in input list")(static_cast <bool> (llvm::all_of(SrcOps, [&, this]
(const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector
() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI
())); }) && "type mismatch in input list") ? void (0)
: __assert_fail ("llvm::all_of(SrcOps, [&, this](const SrcOp &Op) { return (Op.getLLTTy(*getMRI()).isVector() && Op.getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())); }) && \"type mismatch in input list\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1217, __extension__ __PRETTY_FUNCTION__))
;
1218 assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input vectors do not exactly cover the output vector register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input vectors do not exactly cover the output vector register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1220, __extension__ __PRETTY_FUNCTION__))
1219 DstOps[0].getLLTTy(*getMRI()).getSizeInBits() &&(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input vectors do not exactly cover the output vector register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input vectors do not exactly cover the output vector register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1220, __extension__ __PRETTY_FUNCTION__))
1220 "input vectors do not exactly cover the output vector register")(static_cast <bool> (SrcOps.size() * SrcOps[0].getLLTTy
(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).
getSizeInBits() && "input vectors do not exactly cover the output vector register"
) ? void (0) : __assert_fail ("SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && \"input vectors do not exactly cover the output vector register\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1220, __extension__ __PRETTY_FUNCTION__))
;
1221 break;
1222 }
1223 case TargetOpcode::G_UADDE: {
1224 assert(DstOps.size() == 2 && "Invalid no of dst operands")(static_cast <bool> (DstOps.size() == 2 && "Invalid no of dst operands"
) ? void (0) : __assert_fail ("DstOps.size() == 2 && \"Invalid no of dst operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1224, __extension__ __PRETTY_FUNCTION__))
;
1225 assert(SrcOps.size() == 3 && "Invalid no of src operands")(static_cast <bool> (SrcOps.size() == 3 && "Invalid no of src operands"
) ? void (0) : __assert_fail ("SrcOps.size() == 3 && \"Invalid no of src operands\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1225, __extension__ __PRETTY_FUNCTION__))
;
1226 assert(DstOps[0].getLLTTy(*getMRI()).isScalar() && "Invalid operand")(static_cast <bool> (DstOps[0].getLLTTy(*getMRI()).isScalar
() && "Invalid operand") ? void (0) : __assert_fail (
"DstOps[0].getLLTTy(*getMRI()).isScalar() && \"Invalid operand\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1226, __extension__ __PRETTY_FUNCTION__))
;
1227 assert((DstOps[0].getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())) &&(static_cast <bool> ((DstOps[0].getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI())) && (DstOps[0].getLLTTy(*getMRI
()) == SrcOps[1].getLLTTy(*getMRI())) && "Invalid operand"
) ? void (0) : __assert_fail ("(DstOps[0].getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())) && (DstOps[0].getLLTTy(*getMRI()) == SrcOps[1].getLLTTy(*getMRI())) && \"Invalid operand\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1229, __extension__ __PRETTY_FUNCTION__))
1228 (DstOps[0].getLLTTy(*getMRI()) == SrcOps[1].getLLTTy(*getMRI())) &&(static_cast <bool> ((DstOps[0].getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI())) && (DstOps[0].getLLTTy(*getMRI
()) == SrcOps[1].getLLTTy(*getMRI())) && "Invalid operand"
) ? void (0) : __assert_fail ("(DstOps[0].getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())) && (DstOps[0].getLLTTy(*getMRI()) == SrcOps[1].getLLTTy(*getMRI())) && \"Invalid operand\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1229, __extension__ __PRETTY_FUNCTION__))
1229 "Invalid operand")(static_cast <bool> ((DstOps[0].getLLTTy(*getMRI()) == SrcOps
[0].getLLTTy(*getMRI())) && (DstOps[0].getLLTTy(*getMRI
()) == SrcOps[1].getLLTTy(*getMRI())) && "Invalid operand"
) ? void (0) : __assert_fail ("(DstOps[0].getLLTTy(*getMRI()) == SrcOps[0].getLLTTy(*getMRI())) && (DstOps[0].getLLTTy(*getMRI()) == SrcOps[1].getLLTTy(*getMRI())) && \"Invalid operand\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1229, __extension__ __PRETTY_FUNCTION__))
;
1230 assert(DstOps[1].getLLTTy(*getMRI()).isScalar() && "Invalid operand")(static_cast <bool> (DstOps[1].getLLTTy(*getMRI()).isScalar
() && "Invalid operand") ? void (0) : __assert_fail (
"DstOps[1].getLLTTy(*getMRI()).isScalar() && \"Invalid operand\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1230, __extension__ __PRETTY_FUNCTION__))
;
1231 assert(DstOps[1].getLLTTy(*getMRI()) == SrcOps[2].getLLTTy(*getMRI()) &&(static_cast <bool> (DstOps[1].getLLTTy(*getMRI()) == SrcOps
[2].getLLTTy(*getMRI()) && "type mismatch") ? void (0
) : __assert_fail ("DstOps[1].getLLTTy(*getMRI()) == SrcOps[2].getLLTTy(*getMRI()) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1232, __extension__ __PRETTY_FUNCTION__))
1232 "type mismatch")(static_cast <bool> (DstOps[1].getLLTTy(*getMRI()) == SrcOps
[2].getLLTTy(*getMRI()) && "type mismatch") ? void (0
) : __assert_fail ("DstOps[1].getLLTTy(*getMRI()) == SrcOps[2].getLLTTy(*getMRI()) && \"type mismatch\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp"
, 1232, __extension__ __PRETTY_FUNCTION__))
;
1233 break;
1234 }
1235 }
1236
1237 auto MIB = buildInstr(Opc);
1238 for (const DstOp &Op : DstOps)
1239 Op.addDefToMIB(*getMRI(), MIB);
1240 for (const SrcOp &Op : SrcOps)
1241 Op.addSrcToMIB(MIB);
1242 if (Flags)
1243 MIB->setFlags(*Flags);
1244 return MIB;
1245}

/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h

1//== llvm/Support/LowLevelTypeImpl.h --------------------------- -*- C++ -*-==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// Implement a low-level type suitable for MachineInstr level instruction
10/// selection.
11///
12/// For a type attached to a MachineInstr, we only care about 2 details: total
13/// size and the number of vector lanes (if any). Accordingly, there are 4
14/// possible valid type-kinds:
15///
16/// * `sN` for scalars and aggregates
17/// * `<N x sM>` for vectors, which must have at least 2 elements.
18/// * `pN` for pointers
19///
20/// Other information required for correct selection is expected to be carried
21/// by the opcode, or non-type flags. For example the distinction between G_ADD
22/// and G_FADD for int/float or fast-math flags.
23///
24//===----------------------------------------------------------------------===//
25
26#ifndef LLVM_SUPPORT_LOWLEVELTYPEIMPL_H
27#define LLVM_SUPPORT_LOWLEVELTYPEIMPL_H
28
29#include "llvm/ADT/DenseMapInfo.h"
30#include "llvm/Support/Debug.h"
31#include "llvm/Support/MachineValueType.h"
32#include <cassert>
33
34namespace llvm {
35
36class DataLayout;
37class Type;
38class raw_ostream;
39
40class LLT {
41public:
42 /// Get a low-level scalar or aggregate "bag of bits".
43 static LLT scalar(unsigned SizeInBits) {
44 assert(SizeInBits > 0 && "invalid scalar size")(static_cast <bool> (SizeInBits > 0 && "invalid scalar size"
) ? void (0) : __assert_fail ("SizeInBits > 0 && \"invalid scalar size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 44, __extension__ __PRETTY_FUNCTION__))
;
45 return LLT{/*isPointer=*/false, /*isVector=*/false, /*NumElements=*/0,
46 SizeInBits, /*AddressSpace=*/0};
47 }
48
49 /// Get a low-level pointer in the given address space.
50 static LLT pointer(unsigned AddressSpace, unsigned SizeInBits) {
51 assert(SizeInBits > 0 && "invalid pointer size")(static_cast <bool> (SizeInBits > 0 && "invalid pointer size"
) ? void (0) : __assert_fail ("SizeInBits > 0 && \"invalid pointer size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 51, __extension__ __PRETTY_FUNCTION__))
;
52 return LLT{/*isPointer=*/true, /*isVector=*/false, /*NumElements=*/0,
53 SizeInBits, AddressSpace};
54 }
55
56 /// Get a low-level vector of some number of elements and element width.
57 /// \p NumElements must be at least 2.
58 static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits) {
59 assert(NumElements > 1 && "invalid number of vector elements")(static_cast <bool> (NumElements > 1 && "invalid number of vector elements"
) ? void (0) : __assert_fail ("NumElements > 1 && \"invalid number of vector elements\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 59, __extension__ __PRETTY_FUNCTION__))
;
60 assert(ScalarSizeInBits > 0 && "invalid vector element size")(static_cast <bool> (ScalarSizeInBits > 0 &&
"invalid vector element size") ? void (0) : __assert_fail ("ScalarSizeInBits > 0 && \"invalid vector element size\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 60, __extension__ __PRETTY_FUNCTION__))
;
61 return LLT{/*isPointer=*/false, /*isVector=*/true, NumElements,
62 ScalarSizeInBits, /*AddressSpace=*/0};
63 }
64
65 /// Get a low-level vector of some number of elements and element type.
66 static LLT vector(uint16_t NumElements, LLT ScalarTy) {
67 assert(NumElements > 1 && "invalid number of vector elements")(static_cast <bool> (NumElements > 1 && "invalid number of vector elements"
) ? void (0) : __assert_fail ("NumElements > 1 && \"invalid number of vector elements\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 67, __extension__ __PRETTY_FUNCTION__))
;
68 assert(!ScalarTy.isVector() && "invalid vector element type")(static_cast <bool> (!ScalarTy.isVector() && "invalid vector element type"
) ? void (0) : __assert_fail ("!ScalarTy.isVector() && \"invalid vector element type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 68, __extension__ __PRETTY_FUNCTION__))
;
69 return LLT{ScalarTy.isPointer(), /*isVector=*/true, NumElements,
70 ScalarTy.getSizeInBits(),
71 ScalarTy.isPointer() ? ScalarTy.getAddressSpace() : 0};
72 }
73
74 static LLT scalarOrVector(uint16_t NumElements, LLT ScalarTy) {
75 return NumElements == 1 ? ScalarTy : LLT::vector(NumElements, ScalarTy);
76 }
77
78 static LLT scalarOrVector(uint16_t NumElements, unsigned ScalarSize) {
79 return scalarOrVector(NumElements, LLT::scalar(ScalarSize));
80 }
81
82 explicit LLT(bool isPointer, bool isVector, uint16_t NumElements,
83 unsigned SizeInBits, unsigned AddressSpace) {
84 init(isPointer, isVector, NumElements, SizeInBits, AddressSpace);
85 }
86 explicit LLT() : IsPointer(false), IsVector(false), RawData(0) {}
87
88 explicit LLT(MVT VT);
89
90 bool isValid() const { return RawData != 0; }
91
92 bool isScalar() const { return isValid() && !IsPointer && !IsVector; }
93
94 bool isPointer() const { return isValid() && IsPointer && !IsVector; }
95
96 bool isVector() const { return isValid() && IsVector; }
97
98 /// Returns the number of elements in a vector LLT. Must only be called on
99 /// vector types.
100 uint16_t getNumElements() const {
101 assert(IsVector && "cannot get number of elements on scalar/aggregate")(static_cast <bool> (IsVector && "cannot get number of elements on scalar/aggregate"
) ? void (0) : __assert_fail ("IsVector && \"cannot get number of elements on scalar/aggregate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 101, __extension__ __PRETTY_FUNCTION__))
;
102 if (!IsPointer)
103 return getFieldValue(VectorElementsFieldInfo);
104 else
105 return getFieldValue(PointerVectorElementsFieldInfo);
106 }
107
108 /// Returns the total size of the type. Must only be called on sized types.
109 unsigned getSizeInBits() const {
110 if (isPointer() || isScalar())
2
Taking false branch
111 return getScalarSizeInBits();
112 return getScalarSizeInBits() * getNumElements();
3
Returning zero
113 }
114
115 /// Returns the total size of the type in bytes, i.e. number of whole bytes
116 /// needed to represent the size in bits. Must only be called on sized types.
117 unsigned getSizeInBytes() const {
118 return (getSizeInBits() + 7) / 8;
119 }
120
121 LLT getScalarType() const {
122 return isVector() ? getElementType() : *this;
123 }
124
125 /// If this type is a vector, return a vector with the same number of elements
126 /// but the new element type. Otherwise, return the new element type.
127 LLT changeElementType(LLT NewEltTy) const {
128 return isVector() ? LLT::vector(getNumElements(), NewEltTy) : NewEltTy;
129 }
130
131 /// If this type is a vector, return a vector with the same number of elements
132 /// but the new element size. Otherwise, return the new element type. Invalid
133 /// for pointer types. For pointer types, use changeElementType.
134 LLT changeElementSize(unsigned NewEltSize) const {
135 assert(!getScalarType().isPointer() &&(static_cast <bool> (!getScalarType().isPointer() &&
"invalid to directly change element size for pointers") ? void
(0) : __assert_fail ("!getScalarType().isPointer() && \"invalid to directly change element size for pointers\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 136, __extension__ __PRETTY_FUNCTION__))
136 "invalid to directly change element size for pointers")(static_cast <bool> (!getScalarType().isPointer() &&
"invalid to directly change element size for pointers") ? void
(0) : __assert_fail ("!getScalarType().isPointer() && \"invalid to directly change element size for pointers\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 136, __extension__ __PRETTY_FUNCTION__))
;
137 return isVector() ? LLT::vector(getNumElements(), NewEltSize)
138 : LLT::scalar(NewEltSize);
139 }
140
141 /// Return a vector or scalar with the same element type and the new number of
142 /// elements.
143 LLT changeNumElements(unsigned NewNumElts) const {
144 return LLT::scalarOrVector(NewNumElts, getScalarType());
145 }
146
147 /// Return a type that is \p Factor times smaller. Reduces the number of
148 /// elements if this is a vector, or the bitwidth for scalar/pointers. Does
149 /// not attempt to handle cases that aren't evenly divisible.
150 LLT divide(int Factor) const {
151 assert(Factor != 1)(static_cast <bool> (Factor != 1) ? void (0) : __assert_fail
("Factor != 1", "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 151, __extension__ __PRETTY_FUNCTION__))
;
152 if (isVector()) {
153 assert(getNumElements() % Factor == 0)(static_cast <bool> (getNumElements() % Factor == 0) ? void
(0) : __assert_fail ("getNumElements() % Factor == 0", "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 153, __extension__ __PRETTY_FUNCTION__))
;
154 return scalarOrVector(getNumElements() / Factor, getElementType());
155 }
156
157 assert(getSizeInBits() % Factor == 0)(static_cast <bool> (getSizeInBits() % Factor == 0) ? void
(0) : __assert_fail ("getSizeInBits() % Factor == 0", "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 157, __extension__ __PRETTY_FUNCTION__))
;
158 return scalar(getSizeInBits() / Factor);
159 }
160
161 bool isByteSized() const { return (getSizeInBits() & 7) == 0; }
162
163 unsigned getScalarSizeInBits() const {
164 assert(RawData != 0 && "Invalid Type")(static_cast <bool> (RawData != 0 && "Invalid Type"
) ? void (0) : __assert_fail ("RawData != 0 && \"Invalid Type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 164, __extension__ __PRETTY_FUNCTION__))
;
165 if (!IsVector) {
166 if (!IsPointer)
167 return getFieldValue(ScalarSizeFieldInfo);
168 else
169 return getFieldValue(PointerSizeFieldInfo);
170 } else {
171 if (!IsPointer)
172 return getFieldValue(VectorSizeFieldInfo);
173 else
174 return getFieldValue(PointerVectorSizeFieldInfo);
175 }
176 }
177
178 unsigned getAddressSpace() const {
179 assert(RawData != 0 && "Invalid Type")(static_cast <bool> (RawData != 0 && "Invalid Type"
) ? void (0) : __assert_fail ("RawData != 0 && \"Invalid Type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 179, __extension__ __PRETTY_FUNCTION__))
;
180 assert(IsPointer && "cannot get address space of non-pointer type")(static_cast <bool> (IsPointer && "cannot get address space of non-pointer type"
) ? void (0) : __assert_fail ("IsPointer && \"cannot get address space of non-pointer type\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 180, __extension__ __PRETTY_FUNCTION__))
;
181 if (!IsVector)
182 return getFieldValue(PointerAddressSpaceFieldInfo);
183 else
184 return getFieldValue(PointerVectorAddressSpaceFieldInfo);
185 }
186
187 /// Returns the vector's element type. Only valid for vector types.
188 LLT getElementType() const {
189 assert(isVector() && "cannot get element type of scalar/aggregate")(static_cast <bool> (isVector() && "cannot get element type of scalar/aggregate"
) ? void (0) : __assert_fail ("isVector() && \"cannot get element type of scalar/aggregate\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 189, __extension__ __PRETTY_FUNCTION__))
;
190 if (IsPointer)
191 return pointer(getAddressSpace(), getScalarSizeInBits());
192 else
193 return scalar(getScalarSizeInBits());
194 }
195
196 void print(raw_ostream &OS) const;
197
198#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
199 LLVM_DUMP_METHOD__attribute__((noinline)) __attribute__((__used__)) void dump() const {
200 print(dbgs());
201 dbgs() << '\n';
202 }
203#endif
204
205 bool operator==(const LLT &RHS) const {
206 return IsPointer == RHS.IsPointer && IsVector == RHS.IsVector &&
207 RHS.RawData == RawData;
208 }
209
210 bool operator!=(const LLT &RHS) const { return !(*this == RHS); }
211
212 friend struct DenseMapInfo<LLT>;
213 friend class GISelInstProfileBuilder;
214
215private:
216 /// LLT is packed into 64 bits as follows:
217 /// isPointer : 1
218 /// isVector : 1
219 /// with 62 bits remaining for Kind-specific data, packed in bitfields
220 /// as described below. As there isn't a simple portable way to pack bits
221 /// into bitfields, here the different fields in the packed structure is
222 /// described in static const *Field variables. Each of these variables
223 /// is a 2-element array, with the first element describing the bitfield size
224 /// and the second element describing the bitfield offset.
225 typedef int BitFieldInfo[2];
226 ///
227 /// This is how the bitfields are packed per Kind:
228 /// * Invalid:
229 /// gets encoded as RawData == 0, as that is an invalid encoding, since for
230 /// valid encodings, SizeInBits/SizeOfElement must be larger than 0.
231 /// * Non-pointer scalar (isPointer == 0 && isVector == 0):
232 /// SizeInBits: 32;
233 static const constexpr BitFieldInfo ScalarSizeFieldInfo{32, 0};
234 /// * Pointer (isPointer == 1 && isVector == 0):
235 /// SizeInBits: 16;
236 /// AddressSpace: 24;
237 static const constexpr BitFieldInfo PointerSizeFieldInfo{16, 0};
238 static const constexpr BitFieldInfo PointerAddressSpaceFieldInfo{
239 24, PointerSizeFieldInfo[0] + PointerSizeFieldInfo[1]};
240 /// * Vector-of-non-pointer (isPointer == 0 && isVector == 1):
241 /// NumElements: 16;
242 /// SizeOfElement: 32;
243 static const constexpr BitFieldInfo VectorElementsFieldInfo{16, 0};
244 static const constexpr BitFieldInfo VectorSizeFieldInfo{
245 32, VectorElementsFieldInfo[0] + VectorElementsFieldInfo[1]};
246 /// * Vector-of-pointer (isPointer == 1 && isVector == 1):
247 /// NumElements: 16;
248 /// SizeOfElement: 16;
249 /// AddressSpace: 24;
250 static const constexpr BitFieldInfo PointerVectorElementsFieldInfo{16, 0};
251 static const constexpr BitFieldInfo PointerVectorSizeFieldInfo{
252 16,
253 PointerVectorElementsFieldInfo[1] + PointerVectorElementsFieldInfo[0]};
254 static const constexpr BitFieldInfo PointerVectorAddressSpaceFieldInfo{
255 24, PointerVectorSizeFieldInfo[1] + PointerVectorSizeFieldInfo[0]};
256
257 uint64_t IsPointer : 1;
258 uint64_t IsVector : 1;
259 uint64_t RawData : 62;
260
261 static uint64_t getMask(const BitFieldInfo FieldInfo) {
262 const int FieldSizeInBits = FieldInfo[0];
263 return (((uint64_t)1) << FieldSizeInBits) - 1;
264 }
265 static uint64_t maskAndShift(uint64_t Val, uint64_t Mask, uint8_t Shift) {
266 assert(Val <= Mask && "Value too large for field")(static_cast <bool> (Val <= Mask && "Value too large for field"
) ? void (0) : __assert_fail ("Val <= Mask && \"Value too large for field\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 266, __extension__ __PRETTY_FUNCTION__))
;
267 return (Val & Mask) << Shift;
268 }
269 static uint64_t maskAndShift(uint64_t Val, const BitFieldInfo FieldInfo) {
270 return maskAndShift(Val, getMask(FieldInfo), FieldInfo[1]);
271 }
272 uint64_t getFieldValue(const BitFieldInfo FieldInfo) const {
273 return getMask(FieldInfo) & (RawData >> FieldInfo[1]);
274 }
275
276 void init(bool IsPointer, bool IsVector, uint16_t NumElements,
277 unsigned SizeInBits, unsigned AddressSpace) {
278 this->IsPointer = IsPointer;
279 this->IsVector = IsVector;
280 if (!IsVector) {
281 if (!IsPointer)
282 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo);
283 else
284 RawData = maskAndShift(SizeInBits, PointerSizeFieldInfo) |
285 maskAndShift(AddressSpace, PointerAddressSpaceFieldInfo);
286 } else {
287 assert(NumElements > 1 && "invalid number of vector elements")(static_cast <bool> (NumElements > 1 && "invalid number of vector elements"
) ? void (0) : __assert_fail ("NumElements > 1 && \"invalid number of vector elements\""
, "/build/llvm-toolchain-snapshot-13~++20210621111111+acefe0eaaf82/llvm/include/llvm/Support/LowLevelTypeImpl.h"
, 287, __extension__ __PRETTY_FUNCTION__))
;
288 if (!IsPointer)
289 RawData = maskAndShift(NumElements, VectorElementsFieldInfo) |
290 maskAndShift(SizeInBits, VectorSizeFieldInfo);
291 else
292 RawData =
293 maskAndShift(NumElements, PointerVectorElementsFieldInfo) |
294 maskAndShift(SizeInBits, PointerVectorSizeFieldInfo) |
295 maskAndShift(AddressSpace, PointerVectorAddressSpaceFieldInfo);
296 }
297 }
298
299 uint64_t getUniqueRAWLLTData() const {
300 return ((uint64_t)RawData) << 2 | ((uint64_t)IsPointer) << 1 |
301 ((uint64_t)IsVector);
302 }
303};
304
305inline raw_ostream& operator<<(raw_ostream &OS, const LLT &Ty) {
306 Ty.print(OS);
307 return OS;
308}
309
310template<> struct DenseMapInfo<LLT> {
311 static inline LLT getEmptyKey() {
312 LLT Invalid;
313 Invalid.IsPointer = true;
314 return Invalid;
315 }
316 static inline LLT getTombstoneKey() {
317 LLT Invalid;
318 Invalid.IsVector = true;
319 return Invalid;
320 }
321 static inline unsigned getHashValue(const LLT &Ty) {
322 uint64_t Val = Ty.getUniqueRAWLLTData();
323 return DenseMapInfo<uint64_t>::getHashValue(Val);
324 }
325 static bool isEqual(const LLT &LHS, const LLT &RHS) {
326 return LHS == RHS;
327 }
328};
329
330}
331
332#endif // LLVM_SUPPORT_LOWLEVELTYPEIMPL_H