LLVM 22.0.0git
MCInstrDesc.h
Go to the documentation of this file.
1//===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- 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 defines the MCOperandInfo and MCInstrDesc classes, which
10// are used to describe target instructions and their operands.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_MC_MCINSTRDESC_H
15#define LLVM_MC_MCINSTRDESC_H
16
17#include "llvm/ADT/ArrayRef.h"
19#include "llvm/MC/MCRegister.h"
21
22namespace llvm {
23class MCRegisterInfo;
24
25class MCInst;
26
27//===----------------------------------------------------------------------===//
28// Machine Operand Flags and Description
29//===----------------------------------------------------------------------===//
30
31namespace MCOI {
32/// Operand constraints. These are encoded in 16 bits with one of the
33/// low-order 3 bits specifying that a constraint is present and the
34/// corresponding high-order hex digit specifying the constraint value.
35/// This allows for a maximum of 3 constraints.
37 TIED_TO = 0, // Must be allocated the same register as specified value.
38 EARLY_CLOBBER // If present, operand is an early clobber register.
39};
40
41// Define a macro to produce each constraint value.
42#define MCOI_TIED_TO(op) \
43 ((1 << MCOI::TIED_TO) | ((op) << (4 + MCOI::TIED_TO * 4)))
44
45#define MCOI_EARLY_CLOBBER \
46 (1 << MCOI::EARLY_CLOBBER)
47
48/// These are flags set on operands, but should be considered
49/// private, all access should go through the MCOperandInfo accessors.
50/// See the accessors for a description of what these are.
58
59/// Operands are tagged with one of the values of this enum.
82
83} // namespace MCOI
84
85/// This holds information about one operand of a machine instruction,
86/// indicating the register class for register operands, etc.
88public:
89 /// This specifies the register class enumeration of the operand if the
90 /// operand is a register. If LookupRegClassByHwMode is set, then this is an
91 /// index into a table in TargetInstrInfo or MCInstrInfo which contains the
92 /// real register class ID.
93 ///
94 /// If isLookupPtrRegClass is set, then this is an index that is passed to
95 /// TargetRegisterInfo::getPointerRegClass(x) to get a dynamic register class.
96 int16_t RegClass;
97
98 /// These are flags from the MCOI::OperandFlags enum.
100
101 /// Information about the type of the operand.
103
104 /// Operand constraints (see OperandConstraint enum).
106
107 /// Set if this operand is a pointer value and it requires a callback
108 /// to look up its register class.
109 // TODO: Deprecated in favor of isLookupRegClassByHwMode
110 bool isLookupPtrRegClass() const {
111 return Flags & (1 << MCOI::LookupPtrRegClass);
112 }
113
114 /// Set if this operand is a value that requires the current hwmode to look up
115 /// its register class.
117 return Flags & (1 << MCOI::LookupRegClassByHwMode);
118 }
119
120 /// Set if this is one of the operands that made up of the predicate
121 /// operand that controls an isPredicable() instruction.
122 bool isPredicate() const { return Flags & (1 << MCOI::Predicate); }
123
124 /// Set if this operand is a optional def.
125 bool isOptionalDef() const { return Flags & (1 << MCOI::OptionalDef); }
126
127 /// Set if this operand is a branch target.
128 bool isBranchTarget() const { return Flags & (1 << MCOI::BranchTarget); }
129
134
135 unsigned getGenericTypeIndex() const {
136 assert(isGenericType() && "non-generic types don't have an index");
138 }
139
144
145 unsigned getGenericImmIndex() const {
146 assert(isGenericImm() && "non-generic immediates don't have an index");
148 }
149};
150
151//===----------------------------------------------------------------------===//
152// Machine Instruction Flags and Description
153//===----------------------------------------------------------------------===//
154
204
205/// Describe properties that are true of each instruction in the target
206/// description file. This captures information about side effects, register
207/// use and many other things. There is one instance of this struct for each
208/// target instruction class, and the MachineInstr class points to this struct
209/// directly to describe itself.
211public:
212 // FIXME: Disable copies and moves.
213 // Do not allow MCInstrDescs to be copied or moved. They should only exist in
214 // the <Target>Insts table because they rely on knowing their own address to
215 // find other information elsewhere in the same table.
216
217 unsigned short Opcode; // The opcode number
218 unsigned short NumOperands; // Num of args (may be more if variable_ops)
219 unsigned char NumDefs; // Num of args that are definitions
220 unsigned char Size; // Number of bytes in encoding.
221 unsigned short SchedClass; // enum identifying instr sched class
222 unsigned char NumImplicitUses; // Num of regs implicitly used
223 unsigned char NumImplicitDefs; // Num of regs implicitly defined
224 unsigned short OpInfoOffset; // Offset to info about operands
225 unsigned int ImplicitOffset; // Offset to start of implicit op list
226 uint64_t Flags; // Flags identifying machine instr class
227 uint64_t TSFlags; // Target Specific Flag values
228
229 /// Returns the value of the specified operand constraint if
230 /// it is present. Returns -1 if it is not present.
231 int getOperandConstraint(unsigned OpNum,
232 MCOI::OperandConstraint Constraint) const {
233 if (OpNum < NumOperands &&
234 (operands()[OpNum].Constraints & (1 << Constraint))) {
235 unsigned ValuePos = 4 + Constraint * 4;
236 return (int)(operands()[OpNum].Constraints >> ValuePos) & 0x0f;
237 }
238 return -1;
239 }
240
241 /// Return the opcode number for this descriptor.
242 unsigned getOpcode() const { return Opcode; }
243
244 /// Return the number of declared MachineOperands for this
245 /// MachineInstruction. Note that variadic (isVariadic() returns true)
246 /// instructions may have additional operands at the end of the list, and note
247 /// that the machine instruction may include implicit register def/uses as
248 /// well.
249 unsigned getNumOperands() const { return NumOperands; }
250
252 auto OpInfo = reinterpret_cast<const MCOperandInfo *>(this + Opcode + 1);
253 return ArrayRef(OpInfo + OpInfoOffset, NumOperands);
254 }
255
256 /// Return the number of MachineOperands that are register
257 /// definitions. Register definitions always occur at the start of the
258 /// machine operand list. This is the number of "outs" in the .td file,
259 /// and does not include implicit defs.
260 unsigned getNumDefs() const { return NumDefs; }
261
262 /// Return flags of this instruction.
263 uint64_t getFlags() const { return Flags; }
264
265 /// \returns true if this instruction is emitted before instruction selection
266 /// and should be legalized/regbankselected/selected.
267 bool isPreISelOpcode() const { return Flags & (1ULL << MCID::PreISelOpcode); }
268
269 /// Return true if this instruction can have a variable number of
270 /// operands. In this case, the variable operands will be after the normal
271 /// operands but before the implicit definitions and uses (if any are
272 /// present).
273 bool isVariadic() const { return Flags & (1ULL << MCID::Variadic); }
274
275 /// Set if this instruction has an optional definition, e.g.
276 /// ARM instructions which can set condition code if 's' bit is set.
277 bool hasOptionalDef() const { return Flags & (1ULL << MCID::HasOptionalDef); }
278
279 /// Return true if this is a pseudo instruction that doesn't
280 /// correspond to a real machine instruction.
281 bool isPseudo() const { return Flags & (1ULL << MCID::Pseudo); }
282
283 /// Return true if this is a meta instruction that doesn't
284 /// produce any output in the form of executable instructions.
285 bool isMetaInstruction() const { return Flags & (1ULL << MCID::Meta); }
286
287 /// Return true if the instruction is a return.
288 bool isReturn() const { return Flags & (1ULL << MCID::Return); }
289
290 /// Return true if the instruction is an add instruction.
291 bool isAdd() const { return Flags & (1ULL << MCID::Add); }
292
293 /// Return true if this instruction is a trap.
294 bool isTrap() const { return Flags & (1ULL << MCID::Trap); }
295
296 /// Return true if the instruction is a register to register move.
297 bool isMoveReg() const { return Flags & (1ULL << MCID::MoveReg); }
298
299 /// Return true if the instruction is a call.
300 bool isCall() const { return Flags & (1ULL << MCID::Call); }
301
302 /// Returns true if the specified instruction stops control flow
303 /// from executing the instruction immediately following it. Examples include
304 /// unconditional branches and return instructions.
305 bool isBarrier() const { return Flags & (1ULL << MCID::Barrier); }
306
307 /// Returns true if this instruction part of the terminator for
308 /// a basic block. Typically this is things like return and branch
309 /// instructions.
310 ///
311 /// Various passes use this to insert code into the bottom of a basic block,
312 /// but before control flow occurs.
313 bool isTerminator() const { return Flags & (1ULL << MCID::Terminator); }
314
315 /// Returns true if this is a conditional, unconditional, or
316 /// indirect branch. Predicates below can be used to discriminate between
317 /// these cases, and the TargetInstrInfo::analyzeBranch method can be used to
318 /// get more information.
319 bool isBranch() const { return Flags & (1ULL << MCID::Branch); }
320
321 /// Return true if this is an indirect branch, such as a
322 /// branch through a register.
323 bool isIndirectBranch() const { return Flags & (1ULL << MCID::IndirectBranch); }
324
325 /// Return true if this is a branch which may fall
326 /// through to the next instruction or may transfer control flow to some other
327 /// block. The TargetInstrInfo::analyzeBranch method can be used to get more
328 /// information about this branch.
329 bool isConditionalBranch() const {
330 return isBranch() && !isBarrier() && !isIndirectBranch();
331 }
332
333 /// Return true if this is a branch which always
334 /// transfers control flow to some other block. The
335 /// TargetInstrInfo::analyzeBranch method can be used to get more information
336 /// about this branch.
338 return isBranch() && isBarrier() && !isIndirectBranch();
339 }
340
341 /// Return true if this is a branch or an instruction which directly
342 /// writes to the program counter. Considered 'may' affect rather than
343 /// 'does' affect as things like predication are not taken into account.
345 const MCRegisterInfo &RI) const;
346
347 /// Return true if this instruction has a predicate operand
348 /// that controls execution. It may be set to 'always', or may be set to other
349 /// values. There are various methods in TargetInstrInfo that can be used to
350 /// control and modify the predicate in this instruction.
351 bool isPredicable() const { return Flags & (1ULL << MCID::Predicable); }
352
353 /// Return true if this instruction is a comparison.
354 bool isCompare() const { return Flags & (1ULL << MCID::Compare); }
355
356 /// Return true if this instruction is a move immediate
357 /// (including conditional moves) instruction.
358 bool isMoveImmediate() const { return Flags & (1ULL << MCID::MoveImm); }
359
360 /// Return true if this instruction is a bitcast instruction.
361 bool isBitcast() const { return Flags & (1ULL << MCID::Bitcast); }
362
363 /// Return true if this is a select instruction.
364 bool isSelect() const { return Flags & (1ULL << MCID::Select); }
365
366 /// Return true if this instruction cannot be safely
367 /// duplicated. For example, if the instruction has a unique labels attached
368 /// to it, duplicating it would cause multiple definition errors.
369 bool isNotDuplicable() const { return Flags & (1ULL << MCID::NotDuplicable); }
370
371 /// Returns true if the specified instruction has a delay slot which
372 /// must be filled by the code generator.
373 bool hasDelaySlot() const { return Flags & (1ULL << MCID::DelaySlot); }
374
375 /// Return true for instructions that can be folded as memory operands
376 /// in other instructions. The most common use for this is instructions that
377 /// are simple loads from memory that don't modify the loaded value in any
378 /// way, but it can also be used for instructions that can be expressed as
379 /// constant-pool loads, such as V_SETALLONES on x86, to allow them to be
380 /// folded when it is beneficial. This should only be set on instructions
381 /// that return a value in their only virtual register definition.
382 bool canFoldAsLoad() const { return Flags & (1ULL << MCID::FoldableAsLoad); }
383
384 /// Return true if this instruction behaves
385 /// the same way as the generic REG_SEQUENCE instructions.
386 /// E.g., on ARM,
387 /// dX VMOVDRR rY, rZ
388 /// is equivalent to
389 /// dX = REG_SEQUENCE rY, ssub_0, rZ, ssub_1.
390 ///
391 /// Note that for the optimizers to be able to take advantage of
392 /// this property, TargetInstrInfo::getRegSequenceLikeInputs has to be
393 /// override accordingly.
394 bool isRegSequenceLike() const { return Flags & (1ULL << MCID::RegSequence); }
395
396 /// Return true if this instruction behaves
397 /// the same way as the generic EXTRACT_SUBREG instructions.
398 /// E.g., on ARM,
399 /// rX, rY VMOVRRD dZ
400 /// is equivalent to two EXTRACT_SUBREG:
401 /// rX = EXTRACT_SUBREG dZ, ssub_0
402 /// rY = EXTRACT_SUBREG dZ, ssub_1
403 ///
404 /// Note that for the optimizers to be able to take advantage of
405 /// this property, TargetInstrInfo::getExtractSubregLikeInputs has to be
406 /// override accordingly.
407 bool isExtractSubregLike() const {
408 return Flags & (1ULL << MCID::ExtractSubreg);
409 }
410
411 /// Return true if this instruction behaves
412 /// the same way as the generic INSERT_SUBREG instructions.
413 /// E.g., on ARM,
414 /// dX = VSETLNi32 dY, rZ, Imm
415 /// is equivalent to a INSERT_SUBREG:
416 /// dX = INSERT_SUBREG dY, rZ, translateImmToSubIdx(Imm)
417 ///
418 /// Note that for the optimizers to be able to take advantage of
419 /// this property, TargetInstrInfo::getInsertSubregLikeInputs has to be
420 /// override accordingly.
421 bool isInsertSubregLike() const { return Flags & (1ULL << MCID::InsertSubreg); }
422
423
424 /// Return true if this instruction is convergent.
425 ///
426 /// Convergent instructions may not be made control-dependent on any
427 /// additional values.
428 bool isConvergent() const { return Flags & (1ULL << MCID::Convergent); }
429
430 /// Return true if variadic operands of this instruction are definitions.
431 bool variadicOpsAreDefs() const {
432 return Flags & (1ULL << MCID::VariadicOpsAreDefs);
433 }
434
435 /// Return true if this instruction authenticates a pointer (e.g. LDRAx/BRAx
436 /// from ARMv8.3, which perform loads/branches with authentication).
437 ///
438 /// An authenticated instruction may fail in an ABI-defined manner when
439 /// operating on an invalid signed pointer.
440 bool isAuthenticated() const {
441 return Flags & (1ULL << MCID::Authenticated);
442 }
443
444 //===--------------------------------------------------------------------===//
445 // Side Effect Analysis
446 //===--------------------------------------------------------------------===//
447
448 /// Return true if this instruction could possibly read memory.
449 /// Instructions with this flag set are not necessarily simple load
450 /// instructions, they may load a value and modify it, for example.
451 bool mayLoad() const { return Flags & (1ULL << MCID::MayLoad); }
452
453 /// Return true if this instruction could possibly modify memory.
454 /// Instructions with this flag set are not necessarily simple store
455 /// instructions, they may store a modified value based on their operands, or
456 /// may not actually modify anything, for example.
457 bool mayStore() const { return Flags & (1ULL << MCID::MayStore); }
458
459 /// Return true if this instruction may raise a floating-point exception.
460 bool mayRaiseFPException() const {
461 return Flags & (1ULL << MCID::MayRaiseFPException);
462 }
463
464 /// Return true if this instruction has side
465 /// effects that are not modeled by other flags. This does not return true
466 /// for instructions whose effects are captured by:
467 ///
468 /// 1. Their operand list and implicit definition/use list. Register use/def
469 /// info is explicit for instructions.
470 /// 2. Memory accesses. Use mayLoad/mayStore.
471 /// 3. Calling, branching, returning: use isCall/isReturn/isBranch.
472 ///
473 /// Examples of side effects would be modifying 'invisible' machine state like
474 /// a control register, flushing a cache, modifying a register invisible to
475 /// LLVM, etc.
477 return Flags & (1ULL << MCID::UnmodeledSideEffects);
478 }
479
480 //===--------------------------------------------------------------------===//
481 // Flags that indicate whether an instruction can be modified by a method.
482 //===--------------------------------------------------------------------===//
483
484 /// Return true if this may be a 2- or 3-address instruction (of the
485 /// form "X = op Y, Z, ..."), which produces the same result if Y and Z are
486 /// exchanged. If this flag is set, then the
487 /// TargetInstrInfo::commuteInstruction method may be used to hack on the
488 /// instruction.
489 ///
490 /// Note that this flag may be set on instructions that are only commutable
491 /// sometimes. In these cases, the call to commuteInstruction will fail.
492 /// Also note that some instructions require non-trivial modification to
493 /// commute them.
494 bool isCommutable() const { return Flags & (1ULL << MCID::Commutable); }
495
496 /// Return true if this is a 2-address instruction which can be changed
497 /// into a 3-address instruction if needed. Doing this transformation can be
498 /// profitable in the register allocator, because it means that the
499 /// instruction can use a 2-address form if possible, but degrade into a less
500 /// efficient form if the source and dest register cannot be assigned to the
501 /// same register. For example, this allows the x86 backend to turn a "shl
502 /// reg, 3" instruction into an LEA instruction, which is the same speed as
503 /// the shift but has bigger code size.
504 ///
505 /// If this returns true, then the target must implement the
506 /// TargetInstrInfo::convertToThreeAddress method for this instruction, which
507 /// is allowed to fail if the transformation isn't valid for this specific
508 /// instruction (e.g. shl reg, 4 on x86).
509 ///
510 bool isConvertibleTo3Addr() const {
511 return Flags & (1ULL << MCID::ConvertibleTo3Addr);
512 }
513
514 /// Return true if this instruction requires custom insertion support
515 /// when the DAG scheduler is inserting it into a machine basic block. If
516 /// this is true for the instruction, it basically means that it is a pseudo
517 /// instruction used at SelectionDAG time that is expanded out into magic code
518 /// by the target when MachineInstrs are formed.
519 ///
520 /// If this is true, the TargetLoweringInfo::InsertAtEndOfBasicBlock method
521 /// is used to insert this into the MachineBasicBlock.
523 return Flags & (1ULL << MCID::UsesCustomInserter);
524 }
525
526 /// Return true if this instruction requires *adjustment* after
527 /// instruction selection by calling a target hook. For example, this can be
528 /// used to fill in ARM 's' optional operand depending on whether the
529 /// conditional flag register is used.
530 bool hasPostISelHook() const { return Flags & (1ULL << MCID::HasPostISelHook); }
531
532 /// Returns true if this instruction is a candidate for remat. This
533 /// flag is only used in TargetInstrInfo method isTriviallyRematerializable.
534 ///
535 /// If this flag is set, the isReallyTriviallyReMaterializable() method is
536 /// called to verify the instruction is really rematerializable.
537 bool isRematerializable() const {
538 return Flags & (1ULL << MCID::Rematerializable);
539 }
540
541 /// Returns true if this instruction has the same cost (or less) than a
542 /// move instruction. This is useful during certain types of optimizations
543 /// (e.g., remat during two-address conversion or machine licm) where we would
544 /// like to remat or hoist the instruction, but not if it costs more than
545 /// moving the instruction into the appropriate register. Note, we are not
546 /// marking copies from and to the same register class with this flag.
547 ///
548 /// This method could be called by interface TargetInstrInfo::isAsCheapAsAMove
549 /// for different subtargets.
550 bool isAsCheapAsAMove() const { return Flags & (1ULL << MCID::CheapAsAMove); }
551
552 /// Returns true if this instruction source operands have special
553 /// register allocation requirements that are not captured by the operand
554 /// register classes. e.g. ARM::STRD's two source registers must be an even /
555 /// odd pair, ARM::STM registers have to be in ascending order. Post-register
556 /// allocation passes should not attempt to change allocations for sources of
557 /// instructions with this flag.
559 return Flags & (1ULL << MCID::ExtraSrcRegAllocReq);
560 }
561
562 /// Returns true if this instruction def operands have special register
563 /// allocation requirements that are not captured by the operand register
564 /// classes. e.g. ARM::LDRD's two def registers must be an even / odd pair,
565 /// ARM::LDM registers have to be in ascending order. Post-register
566 /// allocation passes should not attempt to change allocations for definitions
567 /// of instructions with this flag.
569 return Flags & (1ULL << MCID::ExtraDefRegAllocReq);
570 }
571
572 /// Return a list of registers that are potentially read by any
573 /// instance of this machine instruction. For example, on X86, the "adc"
574 /// instruction adds two register operands and adds the carry bit in from the
575 /// flags register. In this case, the instruction is marked as implicitly
576 /// reading the flags. Likewise, the variable shift instruction on X86 is
577 /// marked as implicitly reading the 'CL' register, which it always does.
579 auto ImplicitOps =
580 reinterpret_cast<const MCPhysReg *>(this + Opcode + 1) + ImplicitOffset;
581 return {ImplicitOps, NumImplicitUses};
582 }
583
584 /// Return a list of registers that are potentially written by any
585 /// instance of this machine instruction. For example, on X86, many
586 /// instructions implicitly set the flags register. In this case, they are
587 /// marked as setting the FLAGS. Likewise, many instructions always deposit
588 /// their result in a physical register. For example, the X86 divide
589 /// instruction always deposits the quotient and remainder in the EAX/EDX
590 /// registers. For that instruction, this will return a list containing the
591 /// EAX/EDX/EFLAGS registers.
593 auto ImplicitOps =
594 reinterpret_cast<const MCPhysReg *>(this + Opcode + 1) + ImplicitOffset;
595 return {ImplicitOps + NumImplicitUses, NumImplicitDefs};
596 }
597
598 /// Return true if this instruction implicitly
599 /// uses the specified physical register.
603
604 /// Return true if this instruction implicitly
605 /// defines the specified physical register.
606 LLVM_ABI bool
608 const MCRegisterInfo *MRI = nullptr) const;
609
610 /// Return the scheduling class for this instruction. The
611 /// scheduling class is an index into the InstrItineraryData table. This
612 /// returns zero if there is no known scheduling information for the
613 /// instruction.
614 unsigned getSchedClass() const { return SchedClass; }
615
616 /// Return the number of bytes in the encoding of this instruction,
617 /// or zero if the encoding size cannot be known from the opcode.
618 unsigned getSize() const { return Size; }
619
620 /// Find the index of the first operand in the
621 /// operand list that is used to represent the predicate. It returns -1 if
622 /// none is found.
624 if (isPredicable()) {
625 for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
626 if (operands()[i].isPredicate())
627 return i;
628 }
629 return -1;
630 }
631
632 /// Return true if this instruction defines the specified physical
633 /// register, either explicitly or implicitly.
635 const MCRegisterInfo &RI) const;
636};
637
638} // end namespace llvm
639
640#endif
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
IRTranslator LLVM IR MI
Register Reg
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Describe properties that are true of each instruction in the target description file.
unsigned char NumImplicitUses
unsigned getSchedClass() const
Return the scheduling class for this instruction.
uint64_t getFlags() const
Return flags of this instruction.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
unsigned char NumImplicitDefs
ArrayRef< MCOperandInfo > operands() const
bool isInsertSubregLike() const
Return true if this instruction behaves the same way as the generic INSERT_SUBREG instructions.
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool isBitcast() const
Return true if this instruction is a bitcast instruction.
bool isIndirectBranch() const
Return true if this is an indirect branch, such as a branch through a register.
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate.
bool usesCustomInsertionHook() const
Return true if this instruction requires custom insertion support when the DAG scheduler is inserting...
bool isBarrier() const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
bool isSelect() const
Return true if this is a select instruction.
bool isAsCheapAsAMove() const
Returns true if this instruction has the same cost (or less) than a move instruction.
bool mayLoad() const
Return true if this instruction could possibly read memory.
bool hasOptionalDef() const
Set if this instruction has an optional definition, e.g.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
bool isConvergent() const
Return true if this instruction is convergent.
bool canFoldAsLoad() const
Return true for instructions that can be folded as memory operands in other instructions.
bool isMoveReg() const
Return true if the instruction is a register to register move.
LLVM_ABI bool hasDefOfPhysReg(const MCInst &MI, MCRegister Reg, const MCRegisterInfo &RI) const
Return true if this instruction defines the specified physical register, either explicitly or implici...
unsigned short NumOperands
LLVM_ABI bool mayAffectControlFlow(const MCInst &MI, const MCRegisterInfo &RI) const
Return true if this is a branch or an instruction which directly writes to the program counter.
bool isRematerializable() const
Returns true if this instruction is a candidate for remat.
bool isCompare() const
Return true if this instruction is a comparison.
bool isMetaInstruction() const
Return true if this is a meta instruction that doesn't produce any output in the form of executable i...
bool isBranch() const
Returns true if this is a conditional, unconditional, or indirect branch.
bool variadicOpsAreDefs() const
Return true if variadic operands of this instruction are definitions.
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specified operand constraint if it is present.
bool hasExtraDefRegAllocReq() const
Returns true if this instruction def operands have special register allocation requirements that are ...
bool mayRaiseFPException() const
Return true if this instruction may raise a floating-point exception.
unsigned int ImplicitOffset
ArrayRef< MCPhysReg > implicit_defs() const
Return a list of registers that are potentially written by any instance of this machine instruction.
bool isUnconditionalBranch() const
Return true if this is a branch which always transfers control flow to some other block.
unsigned char Size
bool isPredicable() const
Return true if this instruction has a predicate operand that controls execution.
bool isCommutable() const
Return true if this may be a 2- or 3-address instruction (of the form "X = op Y, Z,...
bool isNotDuplicable() const
Return true if this instruction cannot be safely duplicated.
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by other flags.
bool hasPostISelHook() const
Return true if this instruction requires adjustment after instruction selection by calling a target h...
bool isExtractSubregLike() const
Return true if this instruction behaves the same way as the generic EXTRACT_SUBREG instructions.
bool isCall() const
Return true if the instruction is a call.
bool isConvertibleTo3Addr() const
Return true if this is a 2-address instruction which can be changed into a 3-address instruction if n...
unsigned short SchedClass
bool isTerminator() const
Returns true if this instruction part of the terminator for a basic block.
bool hasDelaySlot() const
Returns true if the specified instruction has a delay slot which must be filled by the code generator...
bool isReturn() const
Return true if the instruction is a return.
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
bool isAdd() const
Return true if the instruction is an add instruction.
unsigned short Opcode
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
bool isTrap() const
Return true if this instruction is a trap.
bool hasImplicitUseOfPhysReg(MCRegister Reg) const
Return true if this instruction implicitly uses the specified physical register.
bool isMoveImmediate() const
Return true if this instruction is a move immediate (including conditional moves) instruction.
bool isPreISelOpcode() const
bool isConditionalBranch() const
Return true if this is a branch which may fall through to the next instruction or may transfer contro...
ArrayRef< MCPhysReg > implicit_uses() const
Return a list of registers that are potentially read by any instance of this machine instruction.
bool isAuthenticated() const
Return true if this instruction authenticates a pointer (e.g.
unsigned getOpcode() const
Return the opcode number for this descriptor.
unsigned char NumDefs
bool isPseudo() const
Return true if this is a pseudo instruction that doesn't correspond to a real machine instruction.
unsigned short OpInfoOffset
bool isRegSequenceLike() const
Return true if this instruction behaves the same way as the generic REG_SEQUENCE instructions.
bool hasExtraSrcRegAllocReq() const
Returns true if this instruction source operands have special register allocation requirements that a...
LLVM_ABI bool hasImplicitDefOfPhysReg(MCRegister Reg, const MCRegisterInfo *MRI=nullptr) const
Return true if this instruction implicitly defines the specified physical register.
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition MCInstrDesc.h:87
unsigned getGenericTypeIndex() const
bool isOptionalDef() const
Set if this operand is a optional def.
unsigned getGenericImmIndex() const
bool isBranchTarget() const
Set if this operand is a branch target.
uint16_t Constraints
Operand constraints (see OperandConstraint enum).
uint8_t OperandType
Information about the type of the operand.
bool isLookupRegClassByHwMode() const
Set if this operand is a value that requires the current hwmode to look up its register class.
bool isLookupPtrRegClass() const
Set if this operand is a pointer value and it requires a callback to look up its register class.
uint8_t Flags
These are flags from the MCOI::OperandFlags enum.
Definition MCInstrDesc.h:99
bool isGenericImm() const
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
Definition MCInstrDesc.h:96
bool isGenericType() const
bool isPredicate() const
Set if this is one of the operands that made up of the predicate operand that controls an isPredicabl...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:33
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
@ ExtraDefRegAllocReq
@ MayRaiseFPException
@ ExtraSrcRegAllocReq
@ UnmodeledSideEffects
OperandFlags
These are flags set on operands, but should be considered private, all access should go through the M...
Definition MCInstrDesc.h:51
@ LookupPtrRegClass
Definition MCInstrDesc.h:52
@ LookupRegClassByHwMode
Definition MCInstrDesc.h:53
OperandConstraint
Operand constraints.
Definition MCInstrDesc.h:36
OperandType
Operands are tagged with one of the values of this enum.
Definition MCInstrDesc.h:60
@ OPERAND_GENERIC_4
Definition MCInstrDesc.h:72
@ OPERAND_GENERIC_2
Definition MCInstrDesc.h:70
@ OPERAND_GENERIC_1
Definition MCInstrDesc.h:69
@ OPERAND_FIRST_TARGET
Definition MCInstrDesc.h:80
@ OPERAND_GENERIC_IMM_0
Definition MCInstrDesc.h:77
@ OPERAND_GENERIC_3
Definition MCInstrDesc.h:71
@ OPERAND_IMMEDIATE
Definition MCInstrDesc.h:62
@ OPERAND_LAST_GENERIC
Definition MCInstrDesc.h:74
@ OPERAND_FIRST_GENERIC
Definition MCInstrDesc.h:67
@ OPERAND_GENERIC_0
Definition MCInstrDesc.h:68
@ OPERAND_GENERIC_5
Definition MCInstrDesc.h:73
@ OPERAND_FIRST_GENERIC_IMM
Definition MCInstrDesc.h:76
@ OPERAND_LAST_GENERIC_IMM
Definition MCInstrDesc.h:78
This is an optimization pass for GlobalISel generic memory operations.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1877