LLVM 24.0.0git
MachineOperand.h
Go to the documentation of this file.
1//===-- llvm/CodeGen/MachineOperand.h - MachineOperand class ----*- 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//
9// This file contains the declaration of the MachineOperand class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_MACHINEOPERAND_H
14#define LLVM_CODEGEN_MACHINEOPERAND_H
15
18#include "llvm/IR/Intrinsics.h"
19#include "llvm/MC/LaneBitmask.h"
21#include <cassert>
22
23namespace llvm {
24
25class LLT;
26class BlockAddress;
27class Constant;
28class ConstantFP;
29class ConstantInt;
30class GlobalValue;
32class MachineInstr;
35class MDNode;
38class hash_code;
39class raw_ostream;
40class MCSymbol;
41
42/// MachineOperand class - Representation of each machine instruction operand.
43///
44/// This class isn't a POD type because it has a private constructor, but its
45/// destructor must be trivial. Functions like MachineInstr::addOperand(),
46/// MachineRegisterInfo::moveOperands(), and MF::DeleteMachineInstr() depend on
47/// not having to call the MachineOperand destructor.
48///
49class MachineOperand {
50public:
51 enum MachineOperandType : unsigned char {
52 MO_Register, ///< Register operand.
53 MO_Immediate, ///< Immediate operand
54 MO_CImmediate, ///< Immediate >64bit operand
55 MO_FPImmediate, ///< Floating-point immediate operand
56 MO_MachineBasicBlock, ///< MachineBasicBlock reference
57 MO_FrameIndex, ///< Abstract Stack Frame Index
58 MO_ConstantPoolIndex, ///< Address of indexed Constant in Constant Pool
59 MO_TargetIndex, ///< Target-dependent index+offset operand.
60 MO_JumpTableIndex, ///< Address of indexed Jump Table for switch
61 MO_ExternalSymbol, ///< Name of external global symbol
62 MO_GlobalAddress, ///< Address of a global value
63 MO_BlockAddress, ///< Address of a basic block
64 MO_RegisterMask, ///< Mask of preserved registers.
65 MO_RegisterLiveOut, ///< Mask of live-out registers.
66 MO_Metadata, ///< Metadata reference (for debug info)
67 MO_MCSymbol, ///< MCSymbol reference (for debug/eh info)
68 MO_CFIIndex, ///< MCCFIInstruction index.
69 MO_IntrinsicID, ///< Intrinsic ID for ISel
70 MO_Predicate, ///< Generic predicate for ISel
71 MO_ShuffleMask, ///< Other IR Constant for ISel (shuffle masks)
72 MO_DbgInstrRef, ///< Integer indices referring to an instruction+operand
73 MO_LaneMask, ///< Mask to represent active parts of registers
75 };
76
77private:
78 /// OpKind - Specify what kind of operand this is. This discriminates the
79 /// union.
80 unsigned OpKind : 8;
81
82 /// Subregister number for MO_Register. A value of 0 indicates the
83 /// MO_Register has no subReg.
84 ///
85 /// For all other kinds of operands, this field holds target-specific flags.
86 unsigned SubReg_TargetFlags : 12;
87
88 /// TiedTo - Non-zero when this register operand is tied to another register
89 /// operand. The encoding of this field is described in the block comment
90 /// before MachineInstr::tieOperands().
91 unsigned TiedTo : 4;
92
93 /// IsDef - True if this is a def, false if this is a use of the register.
94 /// This is only valid on register operands.
95 ///
96 unsigned IsDef : 1;
97
98 /// IsImp - True if this is an implicit def or use, false if it is explicit.
99 /// This is only valid on register opderands.
100 ///
101 unsigned IsImp : 1;
102
103 /// IsDeadOrKill
104 /// For uses: IsKill - Conservatively indicates the last use of a register
105 /// on this path through the function. A register operand with true value of
106 /// this flag must be the last use of the register, a register operand with
107 /// false value may or may not be the last use of the register. After regalloc
108 /// we can use recomputeLivenessFlags to get precise kill flags.
109 /// For defs: IsDead - True if this register is never used by a subsequent
110 /// instruction.
111 /// This is only valid on register operands.
112 unsigned IsDeadOrKill : 1;
113
114 /// See isRenamable().
115 unsigned IsRenamable : 1;
116
117 /// IsUndef - True if this register operand reads an "undef" value, i.e. the
118 /// read value doesn't matter. This flag can be set on both use and def
119 /// operands. On a sub-register def operand, it refers to the part of the
120 /// register that isn't written. On a full-register def operand, it is a
121 /// noop. See readsReg().
122 ///
123 /// This is only valid on registers.
124 ///
125 /// Note that an instruction may have multiple <undef> operands referring to
126 /// the same register. In that case, the instruction may depend on those
127 /// operands reading the same dont-care value. For example:
128 ///
129 /// $eax = XOR32rr undef $eax, undef $eax
130 ///
131 /// Any register can be used, and its value doesn't matter, but the operands
132 /// must be the same register. Rewriting a tie renames only the tied
133 /// operand, so an undef use of a virtual register may not be tied to a def
134 /// of another register while another undef operand reads the same register;
135 /// read an IMPLICIT_DEF instead.
136 ///
137 unsigned IsUndef : 1;
138
139 /// IsInternalRead - True if this operand reads a value that was defined
140 /// inside the same instruction or bundle. This flag can be set on both use
141 /// and def operands. On a sub-register def operand, it refers to the part
142 /// of the register that isn't written. On a full-register def operand, it
143 /// is a noop.
144 ///
145 /// When this flag is set, the instruction bundle must contain at least one
146 /// other def of the register. If multiple instructions in the bundle define
147 /// the register, the meaning is target-defined.
148 unsigned IsInternalRead : 1;
149
150 /// IsEarlyClobber - True if this MO_Register 'def' operand is written to
151 /// by the MachineInstr before all input registers are read. This is used to
152 /// model the GCC inline asm '&' constraint modifier.
153 unsigned IsEarlyClobber : 1;
154
155 /// IsDebug - True if this MO_Register 'use' operand is in a debug pseudo,
156 /// not a real instruction. Such uses should be ignored during codegen.
157 unsigned IsDebug : 1;
158
159 /// SmallContents - This really should be part of the Contents union, but
160 /// lives out here so we can get a better packed struct.
161 /// MO_Register: Register number.
162 /// OffsetedInfo: Low bits of offset.
163 union {
164 unsigned RegNo; // For MO_Register.
165 unsigned OffsetLo; // Matches Contents.OffsetedInfo.OffsetHi.
166 } SmallContents;
167
168 /// ParentMI - This is the instruction that this operand is embedded into.
169 /// This is valid for all operand types, when the operand is in an instr.
170 MachineInstr *ParentMI = nullptr;
171
172 /// Contents union - This contains the payload for the various operand types.
173 union ContentsUnion {
174 ContentsUnion() {}
175 MachineBasicBlock *MBB; // For MO_MachineBasicBlock.
176 const ConstantFP *CFP; // For MO_FPImmediate.
177 const ConstantInt *CI; // For MO_CImmediate. Integers > 64bit.
178 int64_t ImmVal; // For MO_Immediate.
179 const uint32_t *RegMask; // For MO_RegisterMask and MO_RegisterLiveOut.
180 const MDNode *MD; // For MO_Metadata.
181 MCSymbol *Sym; // For MO_MCSymbol.
182 unsigned CFIIndex; // For MO_CFI.
183 Intrinsic::ID IntrinsicID; // For MO_IntrinsicID.
184 unsigned Pred; // For MO_Predicate
185 ArrayRef<int> ShuffleMask; // For MO_ShuffleMask
186 LaneBitmask LaneMask; // For MO_LaneMask
187
188 struct { // For MO_Register.
189 // Register number is in SmallContents.RegNo.
190 MachineOperand *Prev; // Access list for register. See MRI.
191 MachineOperand *Next;
192 } Reg;
193
194 struct { // For MO_DbgInstrRef.
195 unsigned InstrIdx;
196 unsigned OpIdx;
197 } InstrRef;
198
199 /// OffsetedInfo - This struct contains the offset and an object identifier.
200 /// this represent the object as with an optional offset from it.
201 struct {
202 union {
203 int Index; // For MO_*Index - The index itself.
204 const char *SymbolName; // For MO_ExternalSymbol.
205 const GlobalValue *GV; // For MO_GlobalAddress.
206 const BlockAddress *BA; // For MO_BlockAddress.
207 } Val;
208 // Low bits of offset are in SmallContents.OffsetLo.
209 int OffsetHi; // An offset from the object, high 32 bits.
210 } OffsetedInfo;
211 } Contents;
212
213 explicit MachineOperand(MachineOperandType K)
214 : OpKind(K), SubReg_TargetFlags(0) {
215 // Assert that the layout is what we expect. It's easy to grow this object.
216 static_assert(alignof(MachineOperand) <= alignof(int64_t),
217 "MachineOperand shouldn't be more than 8 byte aligned");
218 static_assert(sizeof(Contents) <= 2 * sizeof(void *),
219 "Contents should be at most two pointers");
220 static_assert(sizeof(MachineOperand) <=
221 alignTo<alignof(int64_t)>(2 * sizeof(unsigned) +
222 3 * sizeof(void *)),
223 "MachineOperand too big. Should be Kind, SmallContents, "
224 "ParentMI, and Contents");
225 }
226
227public:
228 /// getType - Returns the MachineOperandType for this operand.
229 ///
231
232 unsigned getTargetFlags() const {
233 return isReg() ? 0 : SubReg_TargetFlags;
234 }
235 void setTargetFlags(unsigned F) {
236 assert(!isReg() && "Register operands can't have target flags");
237 SubReg_TargetFlags = F;
238 assert(SubReg_TargetFlags == F && "Target flags out of range");
239 }
240 void addTargetFlag(unsigned F) {
241 assert(!isReg() && "Register operands can't have target flags");
242 SubReg_TargetFlags |= F;
243 assert((SubReg_TargetFlags & F) && "Target flags out of range");
244 }
245
246
247 /// getParent - Return the instruction that this operand belongs to.
248 ///
249 MachineInstr *getParent() { return ParentMI; }
250 const MachineInstr *getParent() const { return ParentMI; }
251
252 /// clearParent - Reset the parent pointer.
253 ///
254 /// The MachineOperand copy constructor also copies ParentMI, expecting the
255 /// original to be deleted. If a MachineOperand is ever stored outside a
256 /// MachineInstr, the parent pointer must be cleared.
257 ///
258 /// Never call clearParent() on an operand in a MachineInstr.
259 ///
260 void clearParent() { ParentMI = nullptr; }
261
262 /// Returns the index of this operand in the instruction that it belongs to.
263 LLVM_ABI unsigned getOperandNo() const;
264
265 /// Print a subreg index operand.
266 /// MO_Immediate operands can also be subreg idices. If it's the case, the
267 /// subreg index name will be printed. MachineInstr::isOperandSubregIdx can be
268 /// called to check this.
269 LLVM_ABI static void printSubRegIdx(raw_ostream &OS, uint64_t Index,
270 const TargetRegisterInfo *TRI);
271
272 /// Print operand target flags.
273 LLVM_ABI static void printTargetFlags(raw_ostream &OS,
274 const MachineOperand &Op);
275
276 /// Print a MCSymbol as an operand.
277 LLVM_ABI static void printSymbol(raw_ostream &OS, MCSymbol &Sym);
278
279 /// Print a stack object reference.
281 unsigned FrameIndex,
282 bool IsFixed, StringRef Name);
283
284 /// Print the offset with explicit +/- signs.
285 LLVM_ABI static void printOperandOffset(raw_ostream &OS, int64_t Offset);
286
287 /// Print an IRSlotNumber.
288 LLVM_ABI static void printIRSlotNumber(raw_ostream &OS, int Slot);
289
290 /// Print the MachineOperand to \p os.
291 /// Providing a valid \p TRI results in a more target-specific printing. If
292 /// \p TRI is null, the function will try to pick it up from the parent.
293 LLVM_ABI void print(raw_ostream &os,
294 const TargetRegisterInfo *TRI = nullptr) const;
295
296 /// More complex way of printing a MachineOperand.
297 /// \param TypeToPrint specifies the generic type to be printed on uses and
298 /// defs. It can be determined using MachineInstr::getTypeToPrint.
299 /// \param OpIdx - specifies the index of the operand in machine instruction.
300 /// This will be used by target dependent MIR formatter. Could be std::nullopt
301 /// if the index is unknown, e.g. called by dump().
302 /// \param PrintDef - whether we want to print `def` on an operand which
303 /// isDef. Sometimes, if the operand is printed before '=', we don't print
304 /// `def`.
305 /// \param IsStandalone - whether we want a verbose output of the MO. This
306 /// prints extra information that can be easily inferred when printing the
307 /// whole function, but not when printing only a fragment of it.
308 /// \param ShouldPrintRegisterTies - whether we want to print register ties.
309 /// Sometimes they are easily determined by the instruction's descriptor
310 /// (MachineInstr::hasComplexRegiterTies can determine if it's needed).
311 /// \param TiedOperandIdx - if we need to print register ties this needs to
312 /// provide the index of the tied register. If not, it will be ignored.
313 /// \param TRI - provide more target-specific information to the printer.
314 /// Unlike the previous function, this one will not try and get the
315 /// information from it's parent.
316 LLVM_ABI void print(raw_ostream &os, ModuleSlotTracker &MST, LLT TypeToPrint,
317 std::optional<unsigned> OpIdx, bool PrintDef,
318 bool IsStandalone, bool ShouldPrintRegisterTies,
319 unsigned TiedOperandIdx,
320 const TargetRegisterInfo *TRI) const;
321
322 /// Same as print(os, TRI), but allows to specify the low-level type to be
323 /// printed the same way the full version of print(...) does it.
324 LLVM_ABI void print(raw_ostream &os, LLT TypeToPrint,
325 const TargetRegisterInfo *TRI = nullptr) const;
326
327 LLVM_ABI void dump() const;
328
329 //===--------------------------------------------------------------------===//
330 // Accessors that tell you what kind of MachineOperand you're looking at.
331 //===--------------------------------------------------------------------===//
332
333 /// isReg - Tests if this is a MO_Register operand.
334 bool isReg() const { return OpKind == MO_Register; }
335 /// isImm - Tests if this is a MO_Immediate operand.
336 bool isImm() const { return OpKind == MO_Immediate; }
337 /// isCImm - Test if this is a MO_CImmediate operand.
338 bool isCImm() const { return OpKind == MO_CImmediate; }
339 /// isFPImm - Tests if this is a MO_FPImmediate operand.
340 bool isFPImm() const { return OpKind == MO_FPImmediate; }
341 /// isMBB - Tests if this is a MO_MachineBasicBlock operand.
342 bool isMBB() const { return OpKind == MO_MachineBasicBlock; }
343 /// isFI - Tests if this is a MO_FrameIndex operand.
344 bool isFI() const { return OpKind == MO_FrameIndex; }
345 /// isCPI - Tests if this is a MO_ConstantPoolIndex operand.
346 bool isCPI() const { return OpKind == MO_ConstantPoolIndex; }
347 /// isTargetIndex - Tests if this is a MO_TargetIndex operand.
348 bool isTargetIndex() const { return OpKind == MO_TargetIndex; }
349 /// isJTI - Tests if this is a MO_JumpTableIndex operand.
350 bool isJTI() const { return OpKind == MO_JumpTableIndex; }
351 /// isGlobal - Tests if this is a MO_GlobalAddress operand.
352 bool isGlobal() const { return OpKind == MO_GlobalAddress; }
353 /// isSymbol - Tests if this is a MO_ExternalSymbol operand.
354 bool isSymbol() const { return OpKind == MO_ExternalSymbol; }
355 /// isBlockAddress - Tests if this is a MO_BlockAddress operand.
356 bool isBlockAddress() const { return OpKind == MO_BlockAddress; }
357 /// isRegMask - Tests if this is a MO_RegisterMask operand.
358 bool isRegMask() const { return OpKind == MO_RegisterMask; }
359 /// isRegLiveOut - Tests if this is a MO_RegisterLiveOut operand.
360 bool isRegLiveOut() const { return OpKind == MO_RegisterLiveOut; }
361 /// isMetadata - Tests if this is a MO_Metadata operand.
362 bool isMetadata() const { return OpKind == MO_Metadata; }
363 bool isMCSymbol() const { return OpKind == MO_MCSymbol; }
364 bool isDbgInstrRef() const { return OpKind == MO_DbgInstrRef; }
365 bool isCFIIndex() const { return OpKind == MO_CFIIndex; }
366 bool isIntrinsicID() const { return OpKind == MO_IntrinsicID; }
367 bool isPredicate() const { return OpKind == MO_Predicate; }
368 bool isShuffleMask() const { return OpKind == MO_ShuffleMask; }
369 bool isLaneMask() const { return OpKind == MO_LaneMask; }
370 //===--------------------------------------------------------------------===//
371 // Accessors for Register Operands
372 //===--------------------------------------------------------------------===//
373
374 /// getReg - Returns the register number.
375 Register getReg() const {
376 assert(isReg() && "This is not a register operand!");
377 return Register(SmallContents.RegNo);
378 }
379
380 unsigned getSubReg() const {
381 assert(isReg() && "Wrong MachineOperand accessor");
382 return SubReg_TargetFlags;
383 }
384
385 bool isUse() const {
386 assert(isReg() && "Wrong MachineOperand accessor");
387 return !IsDef;
388 }
389
390 bool isDef() const {
391 assert(isReg() && "Wrong MachineOperand accessor");
392 return IsDef;
393 }
394
395 bool isImplicit() const {
396 assert(isReg() && "Wrong MachineOperand accessor");
397 return IsImp;
398 }
399
400 bool isDead() const {
401 assert(isReg() && "Wrong MachineOperand accessor");
402 return IsDeadOrKill & IsDef;
403 }
404
405 bool isKill() const {
406 assert(isReg() && "Wrong MachineOperand accessor");
407 return IsDeadOrKill && !IsDef;
408 }
409
410 bool isUndef() const {
411 assert(isReg() && "Wrong MachineOperand accessor");
412 return IsUndef;
413 }
414
415 /// isRenamable - Returns true if this register may be renamed, i.e. it does
416 /// not generate a value that is somehow read in a way that is not represented
417 /// by the Machine IR (e.g. to meet an ABI or ISA requirement). This is only
418 /// valid on physical register operands. Virtual registers are assumed to
419 /// always be renamable regardless of the value of this field.
420 ///
421 /// Operands that are renamable can freely be changed to any other register
422 /// that is a member of the register class returned by
423 /// MI->getRegClassConstraint().
424 ///
425 /// isRenamable can return false for several different reasons:
426 ///
427 /// - ABI constraints (since liveness is not always precisely modeled). We
428 /// conservatively handle these cases by setting all physical register
429 /// operands that didn’t start out as virtual regs to not be renamable.
430 /// Also any physical register operands created after register allocation or
431 /// whose register is changed after register allocation will not be
432 /// renamable. This state is tracked in the MachineOperand::IsRenamable
433 /// bit.
434 ///
435 /// - Opcode/target constraints: for opcodes that have complex register class
436 /// requirements (e.g. that depend on other operands/instructions), we set
437 /// hasExtraSrcRegAllocReq/hasExtraDstRegAllocReq in the machine opcode
438 /// description. Operands belonging to instructions with opcodes that are
439 /// marked hasExtraSrcRegAllocReq/hasExtraDstRegAllocReq return false from
440 /// isRenamable(). Additionally, the AllowRegisterRenaming target property
441 /// prevents any operands from being marked renamable for targets that don't
442 /// have detailed opcode hasExtraSrcRegAllocReq/hasExtraDstRegAllocReq
443 /// values.
444 LLVM_ABI bool isRenamable() const;
445
446 bool isInternalRead() const {
447 assert(isReg() && "Wrong MachineOperand accessor");
448 return IsInternalRead;
449 }
450
451 bool isEarlyClobber() const {
452 assert(isReg() && "Wrong MachineOperand accessor");
453 return IsEarlyClobber;
454 }
455
456 /// Return true if this operand is an early-clobber def or a use tied to one.
457 LLVM_ABI bool isEarlyClobberDefOrUse() const;
458
459 bool isTied() const {
460 assert(isReg() && "Wrong MachineOperand accessor");
461 return TiedTo;
462 }
463
464 bool isDebug() const {
465 assert(isReg() && "Wrong MachineOperand accessor");
466 return IsDebug;
467 }
468
469 /// readsReg - Returns true if this operand reads the previous value of its
470 /// register. A use operand with the <undef> flag set doesn't read its
471 /// register. A sub-register def implicitly reads the other parts of the
472 /// register being redefined unless the <undef> flag is set.
473 ///
474 /// This refers to reading the register value from before the current
475 /// instruction or bundle. Internal bundle reads are not included.
476 bool readsReg() const {
477 assert(isReg() && "Wrong MachineOperand accessor");
478 return !isUndef() && !isInternalRead() && (isUse() || getSubReg());
479 }
480
481 /// Return true if this operand can validly be appended to an arbitrary
482 /// operand list. i.e. this behaves like an implicit operand.
483 bool isValidExcessOperand() const {
484 if ((isReg() && isImplicit()) || isRegMask())
485 return true;
486
487 // Debug operands
488 return isMetadata() || isMCSymbol();
489 }
490
491 //===--------------------------------------------------------------------===//
492 // Mutators for Register Operands
493 //===--------------------------------------------------------------------===//
494
495 /// Change the register this operand corresponds to.
496 ///
498
499 void setSubReg(unsigned subReg) {
500 assert(isReg() && "Wrong MachineOperand mutator");
501 SubReg_TargetFlags = subReg;
502 assert(SubReg_TargetFlags == subReg && "SubReg out of range");
503 }
504
505 /// substVirtReg - Substitute the current register with the virtual
506 /// subregister Reg:SubReg. Take any existing SubReg index into account,
507 /// using TargetRegisterInfo to compose the subreg indices if necessary.
508 /// Reg must be a virtual register, SubIdx can be 0.
509 ///
510 LLVM_ABI void substVirtReg(Register Reg, unsigned SubIdx,
511 const TargetRegisterInfo &);
512
513 /// substPhysReg - Substitute the current register with the physical register
514 /// Reg, taking any existing SubReg into account. For instance,
515 /// substPhysReg(%eax) will change %reg1024:sub_8bit to %al.
516 ///
518
519 void setIsUse(bool Val = true) { setIsDef(!Val); }
520
521 /// Change a def to a use, or a use to a def.
522 LLVM_ABI void setIsDef(bool Val = true);
523
524 void setImplicit(bool Val = true) {
525 assert(isReg() && "Wrong MachineOperand mutator");
526 IsImp = Val;
527 }
528
529 void setIsKill(bool Val = true) {
530 assert(isReg() && !IsDef && "Wrong MachineOperand mutator");
531 assert((!Val || !isDebug()) && "Marking a debug operation as kill");
532 IsDeadOrKill = Val;
533 }
534
535 void setIsDead(bool Val = true) {
536 assert(isReg() && IsDef && "Wrong MachineOperand mutator");
537 IsDeadOrKill = Val;
538 }
539
540 void setIsUndef(bool Val = true) {
541 assert(isReg() && "Wrong MachineOperand mutator");
542 IsUndef = Val;
543 }
544
545 LLVM_ABI void setIsRenamable(bool Val = true);
546
547 void setIsInternalRead(bool Val = true) {
548 assert(isReg() && "Wrong MachineOperand mutator");
549 IsInternalRead = Val;
550 }
551
552 void setIsEarlyClobber(bool Val = true) {
553 assert(isReg() && IsDef && "Wrong MachineOperand mutator");
554 IsEarlyClobber = Val;
555 }
556
557 void setIsDebug(bool Val = true) {
558 assert(isReg() && !IsDef && "Wrong MachineOperand mutator");
559 IsDebug = Val;
560 }
561
562 //===--------------------------------------------------------------------===//
563 // Accessors for various operand types.
564 //===--------------------------------------------------------------------===//
565
566 int64_t getImm() const {
567 assert(isImm() && "Wrong MachineOperand accessor");
568 return Contents.ImmVal;
569 }
570
571 const ConstantInt *getCImm() const {
572 assert(isCImm() && "Wrong MachineOperand accessor");
573 return Contents.CI;
574 }
575
576 const ConstantFP *getFPImm() const {
577 assert(isFPImm() && "Wrong MachineOperand accessor");
578 return Contents.CFP;
579 }
580
582 assert(isMBB() && "Wrong MachineOperand accessor");
583 return Contents.MBB;
584 }
585
586 int getIndex() const {
587 assert((isFI() || isCPI() || isTargetIndex() || isJTI()) &&
588 "Wrong MachineOperand accessor");
589 return Contents.OffsetedInfo.Val.Index;
590 }
591
592 const GlobalValue *getGlobal() const {
593 assert(isGlobal() && "Wrong MachineOperand accessor");
594 return Contents.OffsetedInfo.Val.GV;
595 }
596
598 assert(isBlockAddress() && "Wrong MachineOperand accessor");
599 return Contents.OffsetedInfo.Val.BA;
600 }
601
603 assert(isMCSymbol() && "Wrong MachineOperand accessor");
604 return Contents.Sym;
605 }
606
607 unsigned getInstrRefInstrIndex() const {
608 assert(isDbgInstrRef() && "Wrong MachineOperand accessor");
609 return Contents.InstrRef.InstrIdx;
610 }
611
612 unsigned getInstrRefOpIndex() const {
613 assert(isDbgInstrRef() && "Wrong MachineOperand accessor");
614 return Contents.InstrRef.OpIdx;
615 }
616
617 unsigned getCFIIndex() const {
618 assert(isCFIIndex() && "Wrong MachineOperand accessor");
619 return Contents.CFIIndex;
620 }
621
623 assert(isIntrinsicID() && "Wrong MachineOperand accessor");
624 return Contents.IntrinsicID;
625 }
626
627 unsigned getPredicate() const {
628 assert(isPredicate() && "Wrong MachineOperand accessor");
629 return Contents.Pred;
630 }
631
633 assert(isShuffleMask() && "Wrong MachineOperand accessor");
634 return Contents.ShuffleMask;
635 }
636
638 assert(isLaneMask() && "Wrong MachineOperand accessor");
639 return Contents.LaneMask;
640 }
641
642 /// Return the offset from the symbol in this operand. This always returns 0
643 /// for ExternalSymbol operands.
644 int64_t getOffset() const {
645 assert((isGlobal() || isSymbol() || isMCSymbol() || isCPI() ||
647 "Wrong MachineOperand accessor");
648 return int64_t(uint64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
649 SmallContents.OffsetLo;
650 }
651
652 const char *getSymbolName() const {
653 assert(isSymbol() && "Wrong MachineOperand accessor");
654 return Contents.OffsetedInfo.Val.SymbolName;
655 }
656
657 /// clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
658 /// It is sometimes necessary to detach the register mask pointer from its
659 /// machine operand. This static method can be used for such detached bit
660 /// mask pointers.
661 static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg) {
662 // See TargetRegisterInfo.h.
663 assert((!PhysReg.isValid() || PhysReg.isPhysical()) &&
664 "Not a physical register");
665 return !(RegMask[PhysReg.id() / 32] & (1u << PhysReg.id() % 32));
666 }
667
668 /// clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.
669 bool clobbersPhysReg(MCRegister PhysReg) const {
670 return clobbersPhysReg(getRegMask(), PhysReg);
671 }
672
673 /// getRegMask - Returns a bit mask of registers preserved by this RegMask
674 /// operand.
675 const uint32_t *getRegMask() const {
676 assert(isRegMask() && "Wrong MachineOperand accessor");
677 return Contents.RegMask;
678 }
679
680 /// Returns number of elements needed for a regmask array.
681 static unsigned getRegMaskSize(unsigned NumRegs) {
682 return (NumRegs + 31) / 32;
683 }
684
685 /// getRegLiveOut - Returns a bit mask of live-out registers.
686 const uint32_t *getRegLiveOut() const {
687 assert(isRegLiveOut() && "Wrong MachineOperand accessor");
688 return Contents.RegMask;
689 }
690
691 const MDNode *getMetadata() const {
692 assert(isMetadata() && "Wrong MachineOperand accessor");
693 return Contents.MD;
694 }
695
696 //===--------------------------------------------------------------------===//
697 // Mutators for various operand types.
698 //===--------------------------------------------------------------------===//
699
700 void setImm(int64_t immVal) {
701 assert(isImm() && "Wrong MachineOperand mutator");
702 Contents.ImmVal = immVal;
703 }
704
705 void setCImm(const ConstantInt *CI) {
706 assert(isCImm() && "Wrong MachineOperand mutator");
707 Contents.CI = CI;
708 }
709
710 void setFPImm(const ConstantFP *CFP) {
711 assert(isFPImm() && "Wrong MachineOperand mutator");
712 Contents.CFP = CFP;
713 }
714
715 void setOffset(int64_t Offset) {
716 assert((isGlobal() || isSymbol() || isMCSymbol() || isCPI() ||
718 "Wrong MachineOperand mutator");
719 SmallContents.OffsetLo = unsigned(Offset);
720 Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
721 }
722
723 void setIndex(int Idx) {
724 assert((isFI() || isCPI() || isTargetIndex() || isJTI()) &&
725 "Wrong MachineOperand mutator");
726 Contents.OffsetedInfo.Val.Index = Idx;
727 }
728
729 void setMetadata(const MDNode *MD) {
730 assert(isMetadata() && "Wrong MachineOperand mutator");
731 Contents.MD = MD;
732 }
733
734 void setInstrRefInstrIndex(unsigned InstrIdx) {
735 assert(isDbgInstrRef() && "Wrong MachineOperand mutator");
736 Contents.InstrRef.InstrIdx = InstrIdx;
737 }
738 void setInstrRefOpIndex(unsigned OpIdx) {
739 assert(isDbgInstrRef() && "Wrong MachineOperand mutator");
740 Contents.InstrRef.OpIdx = OpIdx;
741 }
742
744 assert(isMBB() && "Wrong MachineOperand mutator");
745 Contents.MBB = MBB;
746 }
747
748 /// Sets value of register mask operand referencing Mask. The
749 /// operand does not take ownership of the memory referenced by Mask, it must
750 /// remain valid for the lifetime of the operand. See CreateRegMask().
751 /// Any physreg with a 0 bit in the mask is clobbered by the instruction.
752 void setRegMask(const uint32_t *RegMaskPtr) {
753 assert(isRegMask() && "Wrong MachineOperand mutator");
754 Contents.RegMask = RegMaskPtr;
755 }
756
758 assert(isIntrinsicID() && "Wrong MachineOperand mutator");
759 Contents.IntrinsicID = IID;
760 }
761
762 void setPredicate(unsigned Predicate) {
763 assert(isPredicate() && "Wrong MachineOperand mutator");
764 Contents.Pred = Predicate;
765 }
766
767 //===--------------------------------------------------------------------===//
768 // Other methods.
769 //===--------------------------------------------------------------------===//
770
771 /// Returns true if this operand is identical to the specified operand except
772 /// for liveness related flags (isKill, isUndef and isDead). Note that this
773 /// should stay in sync with the hash_value overload below.
774 LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const;
775
776 /// MachineOperand hash_value overload.
777 ///
778 /// Note that this includes the same information in the hash that
779 /// isIdenticalTo uses for comparison. It is thus suited for use in hash
780 /// tables which use that function for equality comparisons only. This must
781 /// stay exactly in sync with isIdenticalTo above.
782 LLVM_ABI friend hash_code hash_value(const MachineOperand &MO);
783
784 /// ChangeToImmediate - Replace this operand with a new immediate operand of
785 /// the specified value. If an operand is known to be an immediate already,
786 /// the setImm method should be used.
787 LLVM_ABI void ChangeToImmediate(int64_t ImmVal, unsigned TargetFlags = 0);
788
789 /// ChangeToFPImmediate - Replace this operand with a new FP immediate operand
790 /// of the specified value. If an operand is known to be an FP immediate
791 /// already, the setFPImm method should be used.
792 LLVM_ABI void ChangeToFPImmediate(const ConstantFP *FPImm,
793 unsigned TargetFlags = 0);
794
795 /// ChangeToES - Replace this operand with a new external symbol operand.
796 LLVM_ABI void ChangeToES(const char *SymName, unsigned TargetFlags = 0);
797
798 /// ChangeToGA - Replace this operand with a new global address operand.
799 LLVM_ABI void ChangeToGA(const GlobalValue *GV, int64_t Offset,
800 unsigned TargetFlags = 0);
801
802 /// ChangeToBA - Replace this operand with a new block address operand.
803 LLVM_ABI void ChangeToBA(const BlockAddress *BA, int64_t Offset,
804 unsigned TargetFlags = 0);
805
806 /// ChangeToCPI - Replace this operand with a new constant pool index operand.
807 LLVM_ABI void ChangeToCPI(unsigned Idx, int Offset, unsigned TargetFlags = 0);
808
809 /// ChangeToMCSymbol - Replace this operand with a new MC symbol operand.
810 LLVM_ABI void ChangeToMCSymbol(MCSymbol *Sym, unsigned TargetFlags = 0);
811
812 /// Replace this operand with a frame index.
813 LLVM_ABI void ChangeToFrameIndex(int Idx, unsigned TargetFlags = 0);
814
815 /// Replace this operand with a target index.
816 LLVM_ABI void ChangeToTargetIndex(unsigned Idx, int64_t Offset,
817 unsigned TargetFlags = 0);
818
819 /// Replace this operand with an Instruction Reference.
820 LLVM_ABI void ChangeToDbgInstrRef(unsigned InstrIdx, unsigned OpIdx,
821 unsigned TargetFlags = 0);
822
823 /// ChangeToRegister - Replace this operand with a new register operand of
824 /// the specified value. If an operand is known to be an register already,
825 /// the setReg method should be used.
826 LLVM_ABI void ChangeToRegister(Register Reg, bool isDef, bool isImp = false,
827 bool isKill = false, bool isDead = false,
828 bool isUndef = false, bool isDebug = false);
829
830 /// getTargetIndexName - If this MachineOperand is a TargetIndex that has a
831 /// name, attempt to get the name. Returns nullptr if the TargetIndex does not
832 /// have a name. Asserts if MO is not a TargetIndex.
833 LLVM_ABI const char *getTargetIndexName() const;
834
835 //===--------------------------------------------------------------------===//
836 // Construction methods.
837 //===--------------------------------------------------------------------===//
838
839 static MachineOperand CreateImm(int64_t Val) {
840 MachineOperand Op(MachineOperand::MO_Immediate);
841 Op.setImm(Val);
842 return Op;
843 }
844
845 static MachineOperand CreateCImm(const ConstantInt *CI) {
846 MachineOperand Op(MachineOperand::MO_CImmediate);
847 Op.Contents.CI = CI;
848 return Op;
849 }
850
851 static MachineOperand CreateFPImm(const ConstantFP *CFP) {
852 MachineOperand Op(MachineOperand::MO_FPImmediate);
853 Op.Contents.CFP = CFP;
854 return Op;
855 }
856
857 static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp = false,
858 bool isKill = false, bool isDead = false,
859 bool isUndef = false,
860 bool isEarlyClobber = false,
861 unsigned SubReg = 0, bool isDebug = false,
862 bool isInternalRead = false,
863 bool isRenamable = false) {
864 assert(!(isDead && !isDef) && "Dead flag on non-def");
865 assert(!(isKill && isDef) && "Kill flag on def");
866 MachineOperand Op(MachineOperand::MO_Register);
867 Op.IsDef = isDef;
868 Op.IsImp = isImp;
869 Op.IsDeadOrKill = isKill | isDead;
870 Op.IsRenamable = isRenamable;
871 Op.IsUndef = isUndef;
872 Op.IsInternalRead = isInternalRead;
873 Op.IsEarlyClobber = isEarlyClobber;
874 Op.TiedTo = 0;
875 Op.IsDebug = isDebug;
876 Op.SmallContents.RegNo = Reg.id();
877 Op.Contents.Reg.Prev = nullptr;
878 Op.Contents.Reg.Next = nullptr;
879 Op.setSubReg(SubReg);
880 return Op;
881 }
882 static MachineOperand CreateMBB(MachineBasicBlock *MBB,
883 unsigned TargetFlags = 0) {
885 Op.setMBB(MBB);
886 Op.setTargetFlags(TargetFlags);
887 return Op;
888 }
889 static MachineOperand CreateFI(int Idx) {
890 MachineOperand Op(MachineOperand::MO_FrameIndex);
891 Op.setIndex(Idx);
892 return Op;
893 }
894 static MachineOperand CreateCPI(unsigned Idx, int Offset,
895 unsigned TargetFlags = 0) {
897 Op.setIndex(Idx);
898 Op.setOffset(Offset);
899 Op.setTargetFlags(TargetFlags);
900 return Op;
901 }
902 static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset,
903 unsigned TargetFlags = 0) {
904 MachineOperand Op(MachineOperand::MO_TargetIndex);
905 Op.setIndex(Idx);
906 Op.setOffset(Offset);
907 Op.setTargetFlags(TargetFlags);
908 return Op;
909 }
910 static MachineOperand CreateJTI(unsigned Idx, unsigned TargetFlags = 0) {
912 Op.setIndex(Idx);
913 Op.setTargetFlags(TargetFlags);
914 return Op;
915 }
916 static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset,
917 unsigned TargetFlags = 0) {
918 MachineOperand Op(MachineOperand::MO_GlobalAddress);
919 Op.Contents.OffsetedInfo.Val.GV = GV;
920 Op.setOffset(Offset);
921 Op.setTargetFlags(TargetFlags);
922 return Op;
923 }
924 static MachineOperand CreateES(const char *SymName,
925 unsigned TargetFlags = 0) {
927 Op.Contents.OffsetedInfo.Val.SymbolName = SymName;
928 Op.setOffset(0); // Offset is always 0.
929 Op.setTargetFlags(TargetFlags);
930 return Op;
931 }
932 static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset,
933 unsigned TargetFlags = 0) {
934 MachineOperand Op(MachineOperand::MO_BlockAddress);
935 Op.Contents.OffsetedInfo.Val.BA = BA;
936 Op.setOffset(Offset);
937 Op.setTargetFlags(TargetFlags);
938 return Op;
939 }
940 /// CreateRegMask - Creates a register mask operand referencing Mask. The
941 /// operand does not take ownership of the memory referenced by Mask, it
942 /// must remain valid for the lifetime of the operand.
943 ///
944 /// A RegMask operand represents a set of non-clobbered physical registers
945 /// on an instruction that clobbers many registers, typically a call. The
946 /// bit mask has a bit set for each physreg that is preserved by this
947 /// instruction, as described in the documentation for
948 /// TargetRegisterInfo::getCallPreservedMask().
949 ///
950 /// Any physreg with a 0 bit in the mask is clobbered by the instruction.
951 ///
952 static MachineOperand CreateRegMask(const uint32_t *Mask) {
953 assert(Mask && "Missing register mask");
954 MachineOperand Op(MachineOperand::MO_RegisterMask);
955 Op.Contents.RegMask = Mask;
956 return Op;
957 }
958 static MachineOperand CreateRegLiveOut(const uint32_t *Mask) {
959 assert(Mask && "Missing live-out register mask");
961 Op.Contents.RegMask = Mask;
962 return Op;
963 }
964 static MachineOperand CreateMetadata(const MDNode *Meta) {
965 MachineOperand Op(MachineOperand::MO_Metadata);
966 Op.Contents.MD = Meta;
967 return Op;
968 }
969
970 static MachineOperand CreateMCSymbol(MCSymbol *Sym,
971 unsigned TargetFlags = 0) {
972 MachineOperand Op(MachineOperand::MO_MCSymbol);
973 Op.Contents.Sym = Sym;
974 Op.setOffset(0);
975 Op.setTargetFlags(TargetFlags);
976 return Op;
977 }
978
979 static MachineOperand CreateDbgInstrRef(unsigned InstrIdx, unsigned OpIdx) {
980 MachineOperand Op(MachineOperand::MO_DbgInstrRef);
981 Op.Contents.InstrRef.InstrIdx = InstrIdx;
982 Op.Contents.InstrRef.OpIdx = OpIdx;
983 return Op;
984 }
985
986 static MachineOperand CreateCFIIndex(unsigned CFIIndex) {
987 MachineOperand Op(MachineOperand::MO_CFIIndex);
988 Op.Contents.CFIIndex = CFIIndex;
989 return Op;
990 }
991
992 static MachineOperand CreateIntrinsicID(Intrinsic::ID ID) {
993 MachineOperand Op(MachineOperand::MO_IntrinsicID);
994 Op.Contents.IntrinsicID = ID;
995 return Op;
996 }
997
998 static MachineOperand CreatePredicate(unsigned Pred) {
999 MachineOperand Op(MachineOperand::MO_Predicate);
1000 Op.Contents.Pred = Pred;
1001 return Op;
1002 }
1003
1004 static MachineOperand CreateShuffleMask(ArrayRef<int> Mask) {
1005 MachineOperand Op(MachineOperand::MO_ShuffleMask);
1006 Op.Contents.ShuffleMask = Mask;
1007 return Op;
1008 }
1009
1010 static MachineOperand CreateLaneMask(LaneBitmask LaneMask) {
1011 MachineOperand Op(MachineOperand::MO_LaneMask);
1012 Op.Contents.LaneMask = LaneMask;
1013 return Op;
1014 }
1015
1016 friend class MachineInstr;
1018
1019private:
1020 // If this operand is currently a register operand, and if this is in a
1021 // function, deregister the operand from the register's use/def list.
1022 void removeRegFromUses();
1023
1024 /// Artificial kinds for DenseMap usage.
1025 enum : unsigned char {
1026 MO_Empty = MO_Last + 1,
1027 };
1028
1029 friend struct DenseMapInfo<MachineOperand>;
1030
1031 //===--------------------------------------------------------------------===//
1032 // Methods for handling register use/def lists.
1033 //===--------------------------------------------------------------------===//
1034
1035 /// isOnRegUseList - Return true if this operand is on a register use/def
1036 /// list or false if not. This can only be called for register operands
1037 /// that are part of a machine instruction.
1038 bool isOnRegUseList() const {
1039 assert(isReg() && "Can only add reg operand to use lists");
1040 return Contents.Reg.Prev != nullptr;
1041 }
1042};
1043
1044template <> struct DenseMapInfo<MachineOperand> {
1045 static unsigned getHashValue(const MachineOperand &MO) {
1046 return hash_value(MO);
1047 }
1048 static bool isEqual(const MachineOperand &LHS, const MachineOperand &RHS) {
1049 if (LHS.getType() == static_cast<MachineOperand::MachineOperandType>(
1050 MachineOperand::MO_Empty))
1051 return LHS.getType() == RHS.getType();
1052 return LHS.isIdenticalTo(RHS);
1053 }
1054};
1055
1057 MO.print(OS);
1058 return OS;
1059}
1060
1061// See friend declaration above. This additional declaration is required in
1062// order to compile LLVM with IBM xlC compiler.
1063LLVM_ABI hash_code hash_value(const MachineOperand &MO);
1064} // namespace llvm
1065
1066#endif
SDValue Pred
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
MachineBasicBlock & MBB
#define LLVM_ABI
Definition Compiler.h:211
This file defines DenseMapInfo traits for DenseMap.
A common definition of LaneBitmask for use in TableGen and CodeGen.
#define F(x, y, z)
Definition MD5.cpp:54
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
Value * RHS
Value * LHS
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
The address of a basic block.
Definition Constants.h:1088
ConstantFP - Floating Point Values [float, double].
Definition Constants.h:420
This is the shared class of boolean and integer constants.
Definition Constants.h:87
This is an important base class in LLVM.
Definition Constant.h:44
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
constexpr bool isValid() const
Definition MCRegister.h:84
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Definition MCRegister.h:72
constexpr unsigned id() const
Definition MCRegister.h:82
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Metadata node.
Definition Metadata.h:1087
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
void setSubReg(unsigned subReg)
unsigned getSubReg() const
void setIsUse(bool Val=true)
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned TargetFlags=0)
unsigned getInstrRefOpIndex() const
void setInstrRefInstrIndex(unsigned InstrIdx)
LLVM_ABI unsigned getOperandNo() const
Returns the index of this operand in the instruction that it belongs to.
const GlobalValue * getGlobal() const
void setImplicit(bool Val=true)
void setIsInternalRead(bool Val=true)
LLVM_ABI void substVirtReg(Register Reg, unsigned SubIdx, const TargetRegisterInfo &)
substVirtReg - Substitute the current register with the virtual subregister Reg:SubReg.
LLVM_ABI void ChangeToFrameIndex(int Idx, unsigned TargetFlags=0)
Replace this operand with a frame index.
const uint32_t * getRegLiveOut() const
getRegLiveOut - Returns a bit mask of live-out registers.
void setInstrRefOpIndex(unsigned OpIdx)
static MachineOperand CreateES(const char *SymName, unsigned TargetFlags=0)
const ConstantInt * getCImm() const
LLVM_ABI const char * getTargetIndexName() const
getTargetIndexName - If this MachineOperand is a TargetIndex that has a name, attempt to get the name...
static LLVM_ABI void printStackObjectReference(raw_ostream &OS, unsigned FrameIndex, bool IsFixed, StringRef Name)
Print a stack object reference.
static LLVM_ABI void printSubRegIdx(raw_ostream &OS, uint64_t Index, const TargetRegisterInfo *TRI)
Print a subreg index operand.
static MachineOperand CreateFPImm(const ConstantFP *CFP)
void setImm(int64_t immVal)
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
void setRegMask(const uint32_t *RegMaskPtr)
Sets value of register mask operand referencing Mask.
int64_t getImm() const
unsigned getInstrRefInstrIndex() const
static LLVM_ABI void printTargetFlags(raw_ostream &OS, const MachineOperand &Op)
Print operand target flags.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
void setFPImm(const ConstantFP *CFP)
LLVM_ABI void ChangeToFPImmediate(const ConstantFP *FPImm, unsigned TargetFlags=0)
ChangeToFPImmediate - Replace this operand with a new FP immediate operand of the specified value.
bool isIntrinsicID() const
LLVM_ABI void setIsRenamable(bool Val=true)
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
const MDNode * getMetadata() const
MachineBasicBlock * getMBB() const
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
static MachineOperand CreateCImm(const ConstantInt *CI)
void setIsDead(bool Val=true)
ArrayRef< int > getShuffleMask() const
LLVM_ABI void ChangeToMCSymbol(MCSymbol *Sym, unsigned TargetFlags=0)
ChangeToMCSymbol - Replace this operand with a new MC symbol operand.
LLVM_ABI void ChangeToTargetIndex(unsigned Idx, int64_t Offset, unsigned TargetFlags=0)
Replace this operand with a target index.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
void setMetadata(const MDNode *MD)
LLVM_ABI void dump() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isValidExcessOperand() const
Return true if this operand can validly be appended to an arbitrary operand list.
LLVM_ABI void ChangeToImmediate(int64_t ImmVal, unsigned TargetFlags=0)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value.
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
bool clobbersPhysReg(MCRegister PhysReg) const
clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
LLVM_ABI void ChangeToES(const char *SymName, unsigned TargetFlags=0)
ChangeToES - Replace this operand with a new external symbol operand.
void clearParent()
clearParent - Reset the parent pointer.
bool isShuffleMask() const
LLVM_ABI void ChangeToGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
ChangeToGA - Replace this operand with a new global address operand.
LLVM_ABI void print(raw_ostream &os, const TargetRegisterInfo *TRI=nullptr) const
Print the MachineOperand to os.
LaneBitmask getLaneMask() const
unsigned getCFIIndex() const
void setIsKill(bool Val=true)
LLVM_ABI bool isRenamable() const
isRenamable - Returns true if this register may be renamed, i.e.
LLVM_ABI void ChangeToBA(const BlockAddress *BA, int64_t Offset, unsigned TargetFlags=0)
ChangeToBA - Replace this operand with a new block address operand.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
static MachineOperand CreateMetadata(const MDNode *Meta)
static LLVM_ABI void printOperandOffset(raw_ostream &OS, int64_t Offset)
Print the offset with explicit +/- signs.
LLVM_ABI void ChangeToDbgInstrRef(unsigned InstrIdx, unsigned OpIdx, unsigned TargetFlags=0)
Replace this operand with an Instruction Reference.
LLVM_ABI void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value.
const BlockAddress * getBlockAddress() const
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
LLVM_ABI void substPhysReg(MCRegister Reg, const TargetRegisterInfo &)
substPhysReg - Substitute the current register with the physical register Reg, taking any existing Su...
static MachineOperand CreatePredicate(unsigned Pred)
void setMBB(MachineBasicBlock *MBB)
bool isRegLiveOut() const
isRegLiveOut - Tests if this is a MO_RegisterLiveOut operand.
LLVM_ABI bool isEarlyClobberDefOrUse() const
Return true if this operand is an early-clobber def or a use tied to one.
void setIsEarlyClobber(bool Val=true)
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
void setOffset(int64_t Offset)
void setCImm(const ConstantInt *CI)
static LLVM_ABI void printIRSlotNumber(raw_ostream &OS, int Slot)
Print an IRSlotNumber.
unsigned getTargetFlags() const
static MachineOperand CreateImm(int64_t Val)
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
void setPredicate(unsigned Predicate)
static MachineOperand CreateShuffleMask(ArrayRef< int > Mask)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MachineOperand CreateJTI(unsigned Idx, unsigned TargetFlags=0)
const char * getSymbolName() const
static MachineOperand CreateDbgInstrRef(unsigned InstrIdx, unsigned OpIdx)
void setIsUndef(bool Val=true)
void setIsDebug(bool Val=true)
bool isEarlyClobber() const
bool isBlockAddress() const
isBlockAddress - Tests if this is a MO_BlockAddress operand.
Register getReg() const
getReg - Returns the register number.
bool isTargetIndex() const
isTargetIndex - Tests if this is a MO_TargetIndex operand.
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
void setIntrinsicID(Intrinsic::ID IID)
void addTargetFlag(unsigned F)
bool isDbgInstrRef() const
Intrinsic::ID getIntrinsicID() const
bool isInternalRead() const
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned TargetFlags=0)
void setTargetFlags(unsigned F)
static MachineOperand CreateLaneMask(LaneBitmask LaneMask)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
LLVM_ABI void ChangeToCPI(unsigned Idx, int Offset, unsigned TargetFlags=0)
ChangeToCPI - Replace this operand with a new constant pool index operand.
friend class MachineRegisterInfo
static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned TargetFlags=0)
LLVM_ABI friend hash_code hash_value(const MachineOperand &MO)
MachineOperand hash_value overload.
LLVM_ABI void setIsDef(bool Val=true)
Change a def to a use, or a use to a def.
const ConstantFP * getFPImm() const
static LLVM_ABI void printSymbol(raw_ostream &OS, MCSymbol &Sym)
Print a MCSymbol as an operand.
const MachineInstr * getParent() const
unsigned getPredicate() const
MCSymbol * getMCSymbol() const
@ MO_CFIIndex
MCCFIInstruction index.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_MCSymbol
MCSymbol reference (for debug/eh info)
@ MO_Predicate
Generic predicate for ISel.
@ MO_GlobalAddress
Address of a global value.
@ MO_RegisterMask
Mask of preserved registers.
@ MO_ShuffleMask
Other IR Constant for ISel (shuffle masks)
@ MO_CImmediate
Immediate >64bit operand.
@ MO_BlockAddress
Address of a basic block.
@ MO_DbgInstrRef
Integer indices referring to an instruction+operand.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_LaneMask
Mask to represent active parts of registers.
@ MO_FrameIndex
Abstract Stack Frame Index.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_IntrinsicID
Intrinsic ID for ISel.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
@ MO_TargetIndex
Target-dependent index+offset operand.
@ MO_Metadata
Metadata reference (for debug info)
@ MO_FPImmediate
Floating-point immediate operand.
@ MO_RegisterLiveOut
Mask of live-out registers.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned TargetFlags=0)
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0)
int64_t getOffset() const
Return the offset from the symbol in this operand.
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
static MachineOperand CreateFI(int Idx)
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Manage lifetime of a slot tracker for printing IR.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
An opaque object representing a hash code.
Definition Hashing.h:77
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
hash_code hash_value(const FixedPointSemantics &Val)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:149
@ Other
Any other memory.
Definition ModRef.h:68
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
Definition InstrProf.h:147
static unsigned getHashValue(const MachineOperand &MO)
static bool isEqual(const MachineOperand &LHS, const MachineOperand &RHS)
An information struct used to provide DenseMap with the various necessary components for a given valu...