LLVM 23.0.0git
BundleAttributes.cpp
Go to the documentation of this file.
1//===- llvm/BundleAttributes.cpp - LLVM Bundle Attributes -------*- 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
10
12#include "llvm/IR/Constants.h"
13
14using namespace llvm;
15
17 switch (BA) {
18#define ATTR(Name, Str) \
19 case BundleAttr::Name: \
20 return #Str;
21#include "llvm/IR/BundleAttributes.def"
23 return "none";
24 }
25}
26
28 return StringSwitch<BundleAttr>(Str)
29#define ATTR(Name, Str) .Case(#Str, BundleAttr::Name)
30#include "llvm/IR/BundleAttributes.def"
32}
33
35 assert(OBU.getTagName() == "align" && OBU.Inputs.size() >= 2 &&
36 OBU.Inputs.size() <= 3);
37 AssumeAlignInfo Ret{OBU.Inputs[0], OBU.Inputs[1], std::nullopt, std::nullopt};
38 if (auto *Align = dyn_cast<ConstantInt>(OBU.Inputs[1]))
39 Ret.AlignmentVal = Align->getZExtValue();
40 if (OBU.Inputs.size() == 3) {
41 if (auto *Offset = dyn_cast<ConstantInt>(OBU.Inputs[2]))
42 Ret.OffsetVal = Offset->getZExtValue();
43 } else {
44 Ret.OffsetVal = 0;
45 }
46 return Ret;
47}
48
51 assert(OBU.getTagName() == "separate_storage" && OBU.Inputs.size() == 2);
52 return {OBU.Inputs[0], OBU.Inputs[1]};
53}
54
56 assert(OBU.getTagName() == "nonnull" && OBU.Inputs.size() == 1);
57 return {OBU.Inputs[0]};
58}
59
62 assert(OBU.getTagName() == "dereferenceable" && OBU.Inputs.size() == 2);
63 AssumeDereferenceableInfo Ret{OBU.Inputs[0], OBU.Inputs[1], std::nullopt};
64
65 if (auto *Size = dyn_cast<ConstantInt>(OBU.Inputs[1]))
66 Ret.CountVal = Size->getZExtValue();
67 return Ret;
68}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
A switch()-like statement whose cases are string literals.
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:558
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI AssumeSeparateStorageInfo getAssumeSeparateStorageInfo(OperandBundleUse)
LLVM_ABI BundleAttr getBundleAttrFromString(StringRef)
LLVM_ABI AssumeNonNullInfo getAssumeNonNullInfo(OperandBundleUse)
LLVM_ABI StringRef getNameFromBundleAttr(BundleAttr)
LLVM_ABI AssumeAlignInfo getAssumeAlignInfo(OperandBundleUse)
LLVM_ABI AssumeDereferenceableInfo getAssumeDereferenceableInfo(OperandBundleUse)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
std::optional< uint64_t > AlignmentVal
std::optional< uint64_t > OffsetVal
std::optional< uint64_t > CountVal
A lightweight accessor for an operand bundle meant to be passed around by value.
StringRef getTagName() const
Return the tag of this operand bundle as a string.
ArrayRef< Use > Inputs