LLVM  14.0.0git
MachineLocation.h
Go to the documentation of this file.
1 //===- llvm/MC/MachineLocation.h --------------------------------*- 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 // The MachineLocation class is used to represent a simple location in a machine
9 // frame. Locations will be one of two forms; a register or an address formed
10 // from a base address plus an offset. Register indirection can be specified by
11 // explicitly passing an offset to the constructor.
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_MC_MACHINELOCATION_H
15 #define LLVM_MC_MACHINELOCATION_H
16 
17 #include <cstdint>
18 #include <cassert>
19 
20 namespace llvm {
21 
23 private:
24  bool IsRegister = false; ///< True if location is a register.
25  unsigned Register = 0; ///< gcc/gdb register number.
26 
27 public:
28  enum : uint32_t {
29  // The target register number for an abstract frame pointer. The value is
30  // an arbitrary value that doesn't collide with any real target register.
31  VirtualFP = ~0U
32  };
33 
34  MachineLocation() = default;
35  /// Create a direct register location.
36  explicit MachineLocation(unsigned R, bool Indirect = false)
37  : IsRegister(!Indirect), Register(R) {}
38 
39  bool operator==(const MachineLocation &Other) const {
40  return IsRegister == Other.IsRegister && Register == Other.Register;
41  }
42 
43  // Accessors.
44  /// \return true iff this is a register-indirect location.
45  bool isIndirect() const { return !IsRegister; }
46  bool isReg() const { return IsRegister; }
47  unsigned getReg() const { return Register; }
48  void setIsRegister(bool Is) { IsRegister = Is; }
49  void setRegister(unsigned R) { Register = R; }
50 };
51 
52 inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
53  return !(LHS == RHS);
54 }
55 
56 } // end namespace llvm
57 
58 #endif // LLVM_MC_MACHINELOCATION_H
llvm::MachineLocation
Definition: MachineLocation.h:22
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1983
llvm::MachineLocation::MachineLocation
MachineLocation(unsigned R, bool Indirect=false)
Create a direct register location.
Definition: MachineLocation.h:36
llvm::MachineLocation::operator==
bool operator==(const MachineLocation &Other) const
Definition: MachineLocation.h:39
llvm::MachineLocation::getReg
unsigned getReg() const
Definition: MachineLocation.h:47
llvm::MachineLocation::MachineLocation
MachineLocation()=default
llvm::MachineLocation::isReg
bool isReg() const
Definition: MachineLocation.h:46
llvm::MachineLocation::VirtualFP
@ VirtualFP
Definition: MachineLocation.h:31
uint32_t
llvm::MachineLocation::isIndirect
bool isIndirect() const
Definition: MachineLocation.h:45
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineLocation::setIsRegister
void setIsRegister(bool Is)
Definition: MachineLocation.h:48
llvm::MachineLocation::setRegister
void setRegister(unsigned R)
Definition: MachineLocation.h:49
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1184