Go to the documentation of this file.
16 #ifndef LLVM_ADT_OPTIONAL_H
17 #define LLVM_ADT_OPTIONAL_H
32 namespace optional_detail {
55 std::is_trivially_copy_assignable<T>::value &&
57 !std::is_move_constructible<T>::value) &&
58 (std::is_trivially_move_assignable<T>::value ||
59 !std::is_move_assignable<T>::value))>
78 if (other.hasValue()) {
83 template <
class...
Args>
85 : value(
std::forward<
Args>(args)...), hasVal(
true) {}
111 ::new ((
void *)std::addressof(value))
T(std::forward<Args>(args)...);
119 ::new ((
void *)std::addressof(value))
T(
y);
139 ::new ((
void *)std::addressof(value))
T(other.
value);
149 if (other.hasValue()) {
181 template <
class...
Args>
209 ::new ((
void *)std::addressof(
value))
T(std::forward<Args>(args)...);
235 template <
typename T>
class Optional {
236 optional_detail::OptionalStorage<T> Storage;
250 template <
typename... ArgTypes>
261 template <
typename... ArgTypes>
void emplace(ArgTypes &&...
Args) {
262 Storage.emplace(std::forward<ArgTypes>(
Args)...);
277 constexpr
const T *
getPointer()
const {
return &Storage.getValue(); }
282 constexpr
explicit operator bool()
const {
return hasValue(); }
283 constexpr
bool hasValue()
const {
return Storage.hasValue(); }
294 template <
class Function>
309 template <
class Function>
322 template <
typename T,
typename U>
326 return X.hasValue() ==
Y.hasValue();
329 template <
typename T,
typename U>
334 template <
typename T,
typename U>
338 return X.hasValue() <
Y.hasValue();
341 template <
typename T,
typename U>
346 template <
typename T,
typename U>
351 template <
typename T,
typename U>
356 template <
typename T>
361 template <
typename T>
366 template <
typename T>
371 template <
typename T>
384 template <
typename T>
389 template <
typename T>
402 template <
typename T>
407 template <
typename T>
412 template <
typename T>
417 template <
typename T>
422 template <
typename T>
427 template <
typename T>
432 template <
typename T>
437 template <
typename T>
442 template <
typename T>
447 template <
typename T>
452 template <
typename T>
457 template <
typename T>
462 template <
typename T>
467 template <
typename T>
474 template <typename T, typename = decltype(std::declval<raw_ostream &>()
475 << std::declval<const T &>())>
486 #endif // LLVM_ADT_OPTIONAL_H
auto map(const Function &F) &&-> Optional< decltype(F(std::move(*this).getValue()))>
Apply a function to the value if present; otherwise return None.
constexpr OptionalStorage(OptionalStorage &&other)
This is an optimization pass for GlobalISel generic memory operations.
constexpr Optional(NoneType)
bool operator<=(int64_t V1, const APSInt &V2)
constexpr Optional(const T &y)
OptionalStorage & operator=(OptionalStorage &&other)
Optional & operator=(T &&y)
constexpr OptionalStorage() noexcept
bool operator!=(uint64_t V1, const APInt &V2)
constexpr OptionalStorage(in_place_t, Args &&...args)
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
constexpr const T * getPointer() const
constexpr bool hasValue() const
T getValueOr(U &&value) &&
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
constexpr T getValueOr(U &&value) const &
void emplace(Args &&...args)
auto map(const Function &F) const &-> Optional< decltype(F(getValue()))>
Apply a function to the value if present; otherwise return None.
constexpr OptionalStorage(OptionalStorage const &other)
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
static constexpr Optional create(const T *y)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
constexpr Optional(T &&y)
bool operator>=(int64_t V1, const APSInt &V2)
constexpr OptionalStorage(in_place_t, Args &&... args)
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having t...
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
bool operator<(int64_t V1, const APSInt &V2)
constexpr bool hasValue() const noexcept
constexpr Optional(in_place_t, ArgTypes &&...Args)
constexpr const T & getValue() const &noexcept
An implementation of std::is_trivially_move_constructible since we have users with STLs that don't ye...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
constexpr const T & getValue() const &
bool operator==(uint64_t V1, const APInt &V2)
OptionalStorage & operator=(T const &y)
constexpr in_place_t in_place
constexpr OptionalStorage() noexcept
T && getValue() &&noexcept
An implementation of std::is_trivially_copy_constructible since we have users with STLs that don't ye...
OptionalStorage & operator=(OptionalStorage const &other)
constexpr const T * operator->() const
constexpr bool hasValue() const noexcept
OptionalStorage & operator=(T &&y)
constexpr const T & getValue() const &noexcept
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
OptionalStorage & operator=(T &&y)
into llvm powi allowing the code generator to produce balanced multiplication trees the intrinsic needs to be extended to support and second the code generator needs to be enhanced to lower these to multiplication trees Interesting testcase for add shift mul int y
void emplace(Args &&...args)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Optional & operator=(const T &y)
bool operator>(int64_t V1, const APSInt &V2)
T && getValue() &&noexcept
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr Optional()=default
OptionalStorage & operator=(T const &y)
An opaque object representing a hash code.
constexpr const T & operator*() const &