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