Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:12

0001 //===- llvm/MC/MachineLocation.h --------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 // The MachineLocation class is used to represent a simple location in a machine
0009 // frame.  Locations will be one of two forms; a register or an address formed
0010 // from a base address plus an offset.  Register indirection can be specified by
0011 // explicitly passing an offset to the constructor.
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_MC_MACHINELOCATION_H
0015 #define LLVM_MC_MACHINELOCATION_H
0016 
0017 #include <cstdint>
0018 #include <cassert>
0019 
0020 namespace llvm {
0021 
0022 class MachineLocation {
0023 private:
0024   bool IsRegister = false;              ///< True if location is a register.
0025   unsigned Register = 0;                ///< gcc/gdb register number.
0026 
0027 public:
0028   enum : uint32_t {
0029     // The target register number for an abstract frame pointer. The value is
0030     // an arbitrary value that doesn't collide with any real target register.
0031     VirtualFP = ~0U
0032   };
0033 
0034   MachineLocation() = default;
0035   /// Create a direct register location.
0036   explicit MachineLocation(unsigned R, bool Indirect = false)
0037       : IsRegister(!Indirect), Register(R) {}
0038 
0039   bool operator==(const MachineLocation &Other) const {
0040     return IsRegister == Other.IsRegister && Register == Other.Register;
0041   }
0042 
0043   // Accessors.
0044   /// \return true iff this is a register-indirect location.
0045   bool isIndirect()      const { return !IsRegister; }
0046   bool isReg()           const { return IsRegister; }
0047   unsigned getReg()      const { return Register; }
0048   void setIsRegister(bool Is)  { IsRegister = Is; }
0049   void setRegister(unsigned R) { Register = R; }
0050 };
0051 
0052 inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
0053   return !(LHS == RHS);
0054 }
0055 
0056 } // end namespace llvm
0057 
0058 #endif // LLVM_MC_MACHINELOCATION_H