LLVM
15.0.0git
include
llvm
Support
SaveAndRestore.h
Go to the documentation of this file.
1
//===-- SaveAndRestore.h - Utility -------------------------------*- 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
/// \file
10
/// This file provides utility classes that use RAII to save and restore
11
/// values.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_SUPPORT_SAVEANDRESTORE_H
16
#define LLVM_SUPPORT_SAVEANDRESTORE_H
17
18
namespace
llvm
{
19
20
/// A utility class that uses RAII to save and restore the value of a variable.
21
template
<
typename
T>
struct
SaveAndRestore
{
22
SaveAndRestore
(T &X) :
X
(
X
), OldValue(
X
) {}
23
SaveAndRestore
(T &X,
const
T &NewValue) :
X
(
X
), OldValue(
X
) {
24
X
= NewValue;
25
}
26
~SaveAndRestore
() { X = OldValue; }
27
T
get
() {
return
OldValue; }
28
29
private
:
30
T
&X;
31
T
OldValue;
32
};
33
34
}
// namespace llvm
35
36
#endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:17
T
#define T
Definition:
Mips16ISelLowering.cpp:341
llvm::SaveAndRestore::SaveAndRestore
SaveAndRestore(T &X)
Definition:
SaveAndRestore.h:22
llvm::SaveAndRestore::get
T get()
Definition:
SaveAndRestore.h:27
llvm::SaveAndRestore::~SaveAndRestore
~SaveAndRestore()
Definition:
SaveAndRestore.h:26
X
Since we know that Vector is byte aligned and we know the element offset of X
Definition:
README_ALTIVEC.txt:37
llvm::SaveAndRestore
A utility class that uses RAII to save and restore the value of a variable.
Definition:
SaveAndRestore.h:21
llvm::SaveAndRestore::SaveAndRestore
SaveAndRestore(T &X, const T &NewValue)
Definition:
SaveAndRestore.h:23
Generated on Sat May 28 2022 13:56:44 for LLVM by
1.8.17