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