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 bool isTied() const {
457 assert(isReg() && "Wrong MachineOperand accessor");
458 return TiedTo;
459 }
460
461 bool isDebug() const {
462 assert(isReg() && "Wrong MachineOperand accessor");
463 return IsDebug;
464 }
465
466 /// readsReg - Returns true if this operand reads the previous value of its
467 /// register. A use operand with the <undef> flag set doesn't read its
468 /// register. A sub-register def implicitly reads the other parts of the
469 /// register being redefined unless the <undef> flag is set.
470 ///
471 /// This refers to reading the register value from before the current
472 /// instruction or bundle. Internal bundle reads are not included.
473 bool readsReg() const {
474 assert(isReg() && "Wrong MachineOperand accessor");
475 return !isUndef() && !isInternalRead() && (isUse() || getSubReg());
476 }
477
478 /// Return true if this operand can validly be appended to an arbitrary
479 /// operand list. i.e. this behaves like an implicit operand.
480 bool isValidExcessOperand() const {
481 if ((isReg() && isImplicit()) || isRegMask())
482 return true;
483
484 // Debug operands
485 return isMetadata() || isMCSymbol();
486 }
487
488 //===--------------------------------------------------------------------===//
489 // Mutators for Register Operands
490 //===--------------------------------------------------------------------===//
491
492 /// Change the register this operand corresponds to.
493 ///
495
496 void setSubReg(unsigned subReg) {
497 assert(isReg() && "Wrong MachineOperand mutator");
498 SubReg_TargetFlags = subReg;
499 assert(SubReg_TargetFlags == subReg && "SubReg out of range");
500 }
501
502 /// substVirtReg - Substitute the current register with the virtual
503 /// subregister Reg:SubReg. Take any existing SubReg index into account,
504 /// using TargetRegisterInfo to compose the subreg indices if necessary.
505 /// Reg must be a virtual register, SubIdx can be 0.
506 ///
507 LLVM_ABI void substVirtReg(Register Reg, unsigned SubIdx,
508 const TargetRegisterInfo &);
509
510 /// substPhysReg - Substitute the current register with the physical register
511 /// Reg, taking any existing SubReg into account. For instance,
512 /// substPhysReg(%eax) will change %reg1024:sub_8bit to %al.
513 ///
515
516 void setIsUse(bool Val = true) { setIsDef(!Val); }
517
518 /// Change a def to a use, or a use to a def.
519 LLVM_ABI void setIsDef(bool Val = true);
520
521 void setImplicit(bool Val = true) {
522 assert(isReg() && "Wrong MachineOperand mutator");
523 IsImp = Val;
524 }
525
526 void setIsKill(bool Val = true) {
527 assert(isReg() && !IsDef && "Wrong MachineOperand mutator");
528 assert((!Val || !isDebug()) && "Marking a debug operation as kill");
529 IsDeadOrKill = Val;
530 }
531
532 void setIsDead(bool Val = true) {
533 assert(isReg() && IsDef && "Wrong MachineOperand mutator");
534 IsDeadOrKill = Val;
535 }
536
537 void setIsUndef(bool Val = true) {
538 assert(isReg() && "Wrong MachineOperand mutator");
539 IsUndef = Val;
540 }
541
542 LLVM_ABI void setIsRenamable(bool Val = true);
543
544 void setIsInternalRead(bool Val = true) {
545 assert(isReg() && "Wrong MachineOperand mutator");
546 IsInternalRead = Val;
547 }
548
549 void setIsEarlyClobber(bool Val = true) {
550 assert(isReg() && IsDef && "Wrong MachineOperand mutator");
551 IsEarlyClobber = Val;
552 }
553
554 void setIsDebug(bool Val = true) {
555 assert(isReg() && !IsDef && "Wrong MachineOperand mutator");
556 IsDebug = Val;
557 }
558
559 //===--------------------------------------------------------------------===//
560 // Accessors for various operand types.
561 //===--------------------------------------------------------------------===//
562
563 int64_t getImm() const {
564 assert(isImm() && "Wrong MachineOperand accessor");
565 return Contents.ImmVal;
566 }
567
568 const ConstantInt *getCImm() const {
569 assert(isCImm() && "Wrong MachineOperand accessor");
570 return Contents.CI;
571 }
572
573 const ConstantFP *getFPImm() const {
574 assert(isFPImm() && "Wrong MachineOperand accessor");
575 return Contents.CFP;
576 }
577
579 assert(isMBB() && "Wrong MachineOperand accessor");
580 return Contents.MBB;
581 }
582
583 int getIndex() const {
584 assert((isFI() || isCPI() || isTargetIndex() || isJTI()) &&
585 "Wrong MachineOperand accessor");
586 return Contents.OffsetedInfo.Val.Index;
587 }
588
589 const GlobalValue *getGlobal() const {
590 assert(isGlobal() && "Wrong MachineOperand accessor");
591 return Contents.OffsetedInfo.Val.GV;
592 }
593
595 assert(isBlockAddress() && "Wrong MachineOperand accessor");
596 return Contents.OffsetedInfo.Val.BA;
597 }
598
600 assert(isMCSymbol() && "Wrong MachineOperand accessor");
601 return Contents.Sym;
602 }
603
604 unsigned getInstrRefInstrIndex() const {
605 assert(isDbgInstrRef() && "Wrong MachineOperand accessor");
606 return Contents.InstrRef.InstrIdx;
607 }
608
609 unsigned getInstrRefOpIndex() const {
610 assert(isDbgInstrRef() && "Wrong MachineOperand accessor");
611 return Contents.InstrRef.OpIdx;
612 }
613
614 unsigned getCFIIndex() const {
615 assert(isCFIIndex() && "Wrong MachineOperand accessor");
616 return Contents.CFIIndex;
617 }
618
620 assert(isIntrinsicID() && "Wrong MachineOperand accessor");
621 return Contents.IntrinsicID;
622 }
623
624 unsigned getPredicate() const {
625 assert(isPredicate() && "Wrong MachineOperand accessor");
626 return Contents.Pred;
627 }
628
630 assert(isShuffleMask() && "Wrong MachineOperand accessor");
631 return Contents.ShuffleMask;
632 }
633
635 assert(isLaneMask() && "Wrong MachineOperand accessor");
636 return Contents.LaneMask;
637 }
638
639 /// Return the offset from the symbol in this operand. This always returns 0
640 /// for ExternalSymbol operands.
641 int64_t getOffset() const {
642 assert((isGlobal() || isSymbol() || isMCSymbol() || isCPI() ||
644 "Wrong MachineOperand accessor");
645 return int64_t(uint64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
646 SmallContents.OffsetLo;
647 }
648
649 const char *getSymbolName() const {
650 assert(isSymbol() && "Wrong MachineOperand accessor");
651 return Contents.OffsetedInfo.Val.SymbolName;
652 }
653
654 /// clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
655 /// It is sometimes necessary to detach the register mask pointer from its
656 /// machine operand. This static method can be used for such detached bit
657 /// mask pointers.
658 static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg) {
659 // See TargetRegisterInfo.h.
660 assert((!PhysReg.isValid() || PhysReg.isPhysical()) &&
661 "Not a physical register");
662 return !(RegMask[PhysReg.id() / 32] & (1u << PhysReg.id() % 32));
663 }
664
665 /// clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.
666 bool clobbersPhysReg(MCRegister PhysReg) const {
667 return clobbersPhysReg(getRegMask(), PhysReg);
668 }
669
670 /// getRegMask - Returns a bit mask of registers preserved by this RegMask
671 /// operand.
672 const uint32_t *getRegMask() const {
673 assert(isRegMask() && "Wrong MachineOperand accessor");
674 return Contents.RegMask;
675 }
676
677 /// Returns number of elements needed for a regmask array.
678 static unsigned getRegMaskSize(unsigned NumRegs) {
679 return (NumRegs + 31) / 32;
680 }
681
682 /// getRegLiveOut - Returns a bit mask of live-out registers.
683 const uint32_t *getRegLiveOut() const {
684 assert(isRegLiveOut() && "Wrong MachineOperand accessor");
685 return Contents.RegMask;
686 }
687
688 const MDNode *getMetadata() const {
689 assert(isMetadata() && "Wrong MachineOperand accessor");
690 return Contents.MD;
691 }
692
693 //===--------------------------------------------------------------------===//
694 // Mutators for various operand types.
695 //===--------------------------------------------------------------------===//
696
697 void setImm(int64_t immVal) {
698 assert(isImm() && "Wrong MachineOperand mutator");
699 Contents.ImmVal = immVal;
700 }
701
702 void setCImm(const ConstantInt *CI) {
703 assert(isCImm() && "Wrong MachineOperand mutator");
704 Contents.CI = CI;
705 }
706
707 void setFPImm(const ConstantFP *CFP) {
708 assert(isFPImm() && "Wrong MachineOperand mutator");
709 Contents.CFP = CFP;
710 }
711
712 void setOffset(int64_t Offset) {
713 assert((isGlobal() || isSymbol() || isMCSymbol() || isCPI() ||
715 "Wrong MachineOperand mutator");
716 SmallContents.OffsetLo = unsigned(Offset);
717 Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
718 }
719
720 void setIndex(int Idx) {
721 assert((isFI() || isCPI() || isTargetIndex() || isJTI()) &&
722 "Wrong MachineOperand mutator");
723 Contents.OffsetedInfo.Val.Index = Idx;
724 }
725
726 void setMetadata(const MDNode *MD) {
727 assert(isMetadata() && "Wrong MachineOperand mutator");
728 Contents.MD = MD;
729 }
730
731 void setInstrRefInstrIndex(unsigned InstrIdx) {
732 assert(isDbgInstrRef() && "Wrong MachineOperand mutator");
733 Contents.InstrRef.InstrIdx = InstrIdx;
734 }
735 void setInstrRefOpIndex(unsigned OpIdx) {
736 assert(isDbgInstrRef() && "Wrong MachineOperand mutator");
737 Contents.InstrRef.OpIdx = OpIdx;
738 }
739
741 assert(isMBB() && "Wrong MachineOperand mutator");
742 Contents.MBB = MBB;
743 }
744
745 /// Sets value of register mask operand referencing Mask. The
746 /// operand does not take ownership of the memory referenced by Mask, it must
747 /// remain valid for the lifetime of the operand. See CreateRegMask().
748 /// Any physreg with a 0 bit in the mask is clobbered by the instruction.
749 void setRegMask(const uint32_t *RegMaskPtr) {
750 assert(isRegMask() && "Wrong MachineOperand mutator");
751 Contents.RegMask = RegMaskPtr;
752 }
753
755 assert(isIntrinsicID() && "Wrong MachineOperand mutator");
756 Contents.IntrinsicID = IID;
757 }
758
759 void setPredicate(unsigned Predicate) {
760 assert(isPredicate() && "Wrong MachineOperand mutator");
761 Contents.Pred = Predicate;
762 }
763
764 //===--------------------------------------------------------------------===//
765 // Other methods.
766 //===--------------------------------------------------------------------===//
767
768 /// Returns true if this operand is identical to the specified operand except
769 /// for liveness related flags (isKill, isUndef and isDead). Note that this
770 /// should stay in sync with the hash_value overload below.
771 LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const;
772
773 /// MachineOperand hash_value overload.
774 ///
775 /// Note that this includes the same information in the hash that
776 /// isIdenticalTo uses for comparison. It is thus suited for use in hash
777 /// tables which use that function for equality comparisons only. This must
778 /// stay exactly in sync with isIdenticalTo above.
779 LLVM_ABI friend hash_code hash_value(const MachineOperand &MO);
780
781 /// ChangeToImmediate - Replace this operand with a new immediate operand of
782 /// the specified value. If an operand is known to be an immediate already,
783 /// the setImm method should be used.
784 LLVM_ABI void ChangeToImmediate(int64_t ImmVal, unsigned TargetFlags = 0);
785
786 /// ChangeToFPImmediate - Replace this operand with a new FP immediate operand
787 /// of the specified value. If an operand is known to be an FP immediate
788 /// already, the setFPImm method should be used.
789 LLVM_ABI void ChangeToFPImmediate(const ConstantFP *FPImm,
790 unsigned TargetFlags = 0);
791
792 /// ChangeToES - Replace this operand with a new external symbol operand.
793 LLVM_ABI void ChangeToES(const char *SymName, unsigned TargetFlags = 0);
794
795 /// ChangeToGA - Replace this operand with a new global address operand.
796 LLVM_ABI void ChangeToGA(const GlobalValue *GV, int64_t Offset,
797 unsigned TargetFlags = 0);
798
799 /// ChangeToBA - Replace this operand with a new block address operand.
800 LLVM_ABI void ChangeToBA(const BlockAddress *BA, int64_t Offset,
801 unsigned TargetFlags = 0);
802
803 /// ChangeToCPI - Replace this operand with a new constant pool index operand.
804 LLVM_ABI void ChangeToCPI(unsigned Idx, int Offset, unsigned TargetFlags = 0);
805
806 /// ChangeToMCSymbol - Replace this operand with a new MC symbol operand.
807 LLVM_ABI void ChangeToMCSymbol(MCSymbol *Sym, unsigned TargetFlags = 0);
808
809 /// Replace this operand with a frame index.
810 LLVM_ABI void ChangeToFrameIndex(int Idx, unsigned TargetFlags = 0);
811
812 /// Replace this operand with a target index.
813 LLVM_ABI void ChangeToTargetIndex(unsigned Idx, int64_t Offset,
814 unsigned TargetFlags = 0);
815
816 /// Replace this operand with an Instruction Reference.
817 LLVM_ABI void ChangeToDbgInstrRef(unsigned InstrIdx, unsigned OpIdx,
818 unsigned TargetFlags = 0);
819
820 /// ChangeToRegister - Replace this operand with a new register operand of
821 /// the specified value. If an operand is known to be an register already,
822 /// the setReg method should be used.
823 LLVM_ABI void ChangeToRegister(Register Reg, bool isDef, bool isImp = false,
824 bool isKill = false, bool isDead = false,
825 bool isUndef = false, bool isDebug = false);
826
827 /// getTargetIndexName - If this MachineOperand is a TargetIndex that has a
828 /// name, attempt to get the name. Returns nullptr if the TargetIndex does not
829 /// have a name. Asserts if MO is not a TargetIndex.
830 LLVM_ABI const char *getTargetIndexName() const;
831
832 //===--------------------------------------------------------------------===//
833 // Construction methods.
834 //===--------------------------------------------------------------------===//
835
836 static MachineOperand CreateImm(int64_t Val) {
837 MachineOperand Op(MachineOperand::MO_Immediate);
838 Op.setImm(Val);
839 return Op;
840 }
841
842 static MachineOperand CreateCImm(const ConstantInt *CI) {
843 MachineOperand Op(MachineOperand::MO_CImmediate);
844 Op.Contents.CI = CI;
845 return Op;
846 }
847
848 static MachineOperand CreateFPImm(const ConstantFP *CFP) {
849 MachineOperand Op(MachineOperand::MO_FPImmediate);
850 Op.Contents.CFP = CFP;
851 return Op;
852 }
853
854 static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp = false,
855 bool isKill = false, bool isDead = false,
856 bool isUndef = false,
857 bool isEarlyClobber = false,
858 unsigned SubReg = 0, bool isDebug = false,
859 bool isInternalRead = false,
860 bool isRenamable = false) {
861 assert(!(isDead && !isDef) && "Dead flag on non-def");
862 assert(!(isKill && isDef) && "Kill flag on def");
863 MachineOperand Op(MachineOperand::MO_Register);
864 Op.IsDef = isDef;
865 Op.IsImp = isImp;
866 Op.IsDeadOrKill = isKill | isDead;
867 Op.IsRenamable = isRenamable;
868 Op.IsUndef = isUndef;
869 Op.IsInternalRead = isInternalRead;
870 Op.IsEarlyClobber = isEarlyClobber;
871 Op.TiedTo = 0;
872 Op.IsDebug = isDebug;
873 Op.SmallContents.RegNo = Reg.id();
874 Op.Contents.Reg.Prev = nullptr;
875 Op.Contents.Reg.Next = nullptr;
876 Op.setSubReg(SubReg);
877 return Op;
878 }
879 static MachineOperand CreateMBB(MachineBasicBlock *MBB,
880 unsigned TargetFlags = 0) {
882 Op.setMBB(MBB);
883 Op.setTargetFlags(TargetFlags);
884 return Op;
885 }
886 static MachineOperand CreateFI(int Idx) {
887 MachineOperand Op(MachineOperand::MO_FrameIndex);
888 Op.setIndex(Idx);
889 return Op;
890 }
891 static MachineOperand CreateCPI(unsigned Idx, int Offset,
892 unsigned TargetFlags = 0) {
894 Op.setIndex(Idx);
895 Op.setOffset(Offset);
896 Op.setTargetFlags(TargetFlags);
897 return Op;
898 }
899 static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset,
900 unsigned TargetFlags = 0) {
901 MachineOperand Op(MachineOperand::MO_TargetIndex);
902 Op.setIndex(Idx);
903 Op.setOffset(Offset);
904 Op.setTargetFlags(TargetFlags);
905 return Op;
906 }
907 static MachineOperand CreateJTI(unsigned Idx, unsigned TargetFlags = 0) {
909 Op.setIndex(Idx);
910 Op.setTargetFlags(TargetFlags);
911 return Op;
912 }
913 static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset,
914 unsigned TargetFlags = 0) {
915 MachineOperand Op(MachineOperand::MO_GlobalAddress);
916 Op.Contents.OffsetedInfo.Val.GV = GV;
917 Op.setOffset(Offset);
918 Op.setTargetFlags(TargetFlags);
919 return Op;
920 }
921 static MachineOperand CreateES(const char *SymName,
922 unsigned TargetFlags = 0) {
924 Op.Contents.OffsetedInfo.Val.SymbolName = SymName;
925 Op.setOffset(0); // Offset is always 0.
926 Op.setTargetFlags(TargetFlags);
927 return Op;
928 }
929 static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset,
930 unsigned TargetFlags = 0) {
931 MachineOperand Op(MachineOperand::MO_BlockAddress);
932 Op.Contents.OffsetedInfo.Val.BA = BA;
933 Op.setOffset(Offset);
934 Op.setTargetFlags(TargetFlags);
935 return Op;
936 }
937 /// CreateRegMask - Creates a register mask operand referencing Mask. The
938 /// operand does not take ownership of the memory referenced by Mask, it
939 /// must remain valid for the lifetime of the operand.
940 ///
941 /// A RegMask operand represents a set of non-clobbered physical registers
942 /// on an instruction that clobbers many registers, typically a call. The
943 /// bit mask has a bit set for each physreg that is preserved by this
944 /// instruction, as described in the documentation for
945 /// TargetRegisterInfo::getCallPreservedMask().
946 ///
947 /// Any physreg with a 0 bit in the mask is clobbered by the instruction.
948 ///
949 static MachineOperand CreateRegMask(const uint32_t *Mask) {
950 assert(Mask && "Missing register mask");
951 MachineOperand Op(MachineOperand::MO_RegisterMask);
952 Op.Contents.RegMask = Mask;
953 return Op;
954 }
955 static MachineOperand CreateRegLiveOut(const uint32_t *Mask) {
956 assert(Mask && "Missing live-out register mask");
958 Op.Contents.RegMask = Mask;
959 return Op;
960 }
961 static MachineOperand CreateMetadata(const MDNode *Meta) {
962 MachineOperand Op(MachineOperand::MO_Metadata);
963 Op.Contents.MD = Meta;
964 return Op;
965 }
966
967 static MachineOperand CreateMCSymbol(MCSymbol *Sym,
968 unsigned TargetFlags = 0) {
969 MachineOperand Op(MachineOperand::MO_MCSymbol);
970 Op.Contents.Sym = Sym;
971 Op.setOffset(0);
972 Op.setTargetFlags(TargetFlags);
973 return Op;
974 }
975
976 static MachineOperand CreateDbgInstrRef(unsigned InstrIdx, unsigned OpIdx) {
977 MachineOperand Op(MachineOperand::MO_DbgInstrRef);
978 Op.Contents.InstrRef.InstrIdx = InstrIdx;
979 Op.Contents.InstrRef.OpIdx = OpIdx;
980 return Op;
981 }
982
983 static MachineOperand CreateCFIIndex(unsigned CFIIndex) {
984 MachineOperand Op(MachineOperand::MO_CFIIndex);
985 Op.Contents.CFIIndex = CFIIndex;
986 return Op;
987 }
988
989 static MachineOperand CreateIntrinsicID(Intrinsic::ID ID) {
990 MachineOperand Op(MachineOperand::MO_IntrinsicID);
991 Op.Contents.IntrinsicID = ID;
992 return Op;
993 }
994
995 static MachineOperand CreatePredicate(unsigned Pred) {
996 MachineOperand Op(MachineOperand::MO_Predicate);
997 Op.Contents.Pred = Pred;
998 return Op;
999 }
1000
1001 static MachineOperand CreateShuffleMask(ArrayRef<int> Mask) {
1002 MachineOperand Op(MachineOperand::MO_ShuffleMask);
1003 Op.Contents.ShuffleMask = Mask;
1004 return Op;
1005 }
1006
1007 static MachineOperand CreateLaneMask(LaneBitmask LaneMask) {
1008 MachineOperand Op(MachineOperand::MO_LaneMask);
1009 Op.Contents.LaneMask = LaneMask;
1010 return Op;
1011 }
1012
1013 friend class MachineInstr;
1015
1016private:
1017 // If this operand is currently a register operand, and if this is in a
1018 // function, deregister the operand from the register's use/def list.
1019 void removeRegFromUses();
1020
1021 /// Artificial kinds for DenseMap usage.
1022 enum : unsigned char {
1023 MO_Empty = MO_Last + 1,
1024 };
1025
1026 friend struct DenseMapInfo<MachineOperand>;
1027
1028 //===--------------------------------------------------------------------===//
1029 // Methods for handling register use/def lists.
1030 //===--------------------------------------------------------------------===//
1031
1032 /// isOnRegUseList - Return true if this operand is on a register use/def
1033 /// list or false if not. This can only be called for register operands
1034 /// that are part of a machine instruction.
1035 bool isOnRegUseList() const {
1036 assert(isReg() && "Can only add reg operand to use lists");
1037 return Contents.Reg.Prev != nullptr;
1038 }
1039};
1040
1041template <> struct DenseMapInfo<MachineOperand> {
1042 static unsigned getHashValue(const MachineOperand &MO) {
1043 return hash_value(MO);
1044 }
1045 static bool isEqual(const MachineOperand &LHS, const MachineOperand &RHS) {
1046 if (LHS.getType() == static_cast<MachineOperand::MachineOperandType>(
1047 MachineOperand::MO_Empty))
1048 return LHS.getType() == RHS.getType();
1049 return LHS.isIdenticalTo(RHS);
1050 }
1051};
1052
1054 MO.print(OS);
1055 return OS;
1056}
1057
1058// See friend declaration above. This additional declaration is required in
1059// order to compile LLVM with IBM xlC compiler.
1060LLVM_ABI hash_code hash_value(const MachineOperand &MO);
1061} // namespace llvm
1062
1063#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
MachineBasicBlock & MBB
#define LLVM_ABI
Definition Compiler.h:215
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:43
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:1081
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.
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:144
@ 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...