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